diff --git a/archive/ALittlePatate/ezfrags.txt b/archive/ALittlePatate/ezfrags.txt new file mode 100644 index 00000000..c018e0c0 --- /dev/null +++ b/archive/ALittlePatate/ezfrags.txt @@ -0,0 +1,1596 @@ +Project Path: arc_ALittlePatate_ezfrags_4n_koao2 + +Source Tree: + +```txt +arc_ALittlePatate_ezfrags_4n_koao2 +├── Ezfrags +│ ├── AimAssist.cpp +│ ├── AimAssist.h +│ ├── Aimlock.cpp +│ ├── Aimlock.h +│ ├── BunnyHop.cpp +│ ├── BunnyHop.h +│ ├── Ezfrags.cpp +│ ├── Ezfrags.h +│ ├── Ezfrags.vcxproj +│ ├── Ezfrags.vcxproj.filters +│ ├── Ezfrags.vcxproj.user +│ ├── Get.cpp +│ ├── Get.h +│ ├── GlowESP.cpp +│ ├── GlowESP.h +│ ├── KillMessage.cpp +│ ├── KillMessage.h +│ ├── MemManager.cpp +│ ├── MemManager.h +│ ├── NoFlash.cpp +│ ├── NoFlash.h +│ ├── Radar.cpp +│ ├── Radar.h +│ ├── Settings.hpp +│ ├── ShowFeatures.cpp +│ ├── ShowFeatures.h +│ ├── Signatures.cpp +│ ├── Signatures.h +│ ├── Triggerbot.cpp +│ ├── Triggerbot.h +│ ├── WaitForKeys.cpp +│ ├── WaitForKeys.h +│ └── netvars.h +├── Ezfrags.sln +├── README.md +├── Reversing +│ └── ezfrags.exe.idb +├── Tools +│ ├── convert_pattern.py +│ └── decrypt_string.cpp +└── how to use.txt + +``` + +`Ezfrags.sln`: + +```sln + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31729.503 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ezfrags", "Ezfrags\Ezfrags.vcxproj", "{A5502949-41D2-47BC-9AD3-0BDF34E83300}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A5502949-41D2-47BC-9AD3-0BDF34E83300}.Debug|x64.ActiveCfg = Debug|x64 + {A5502949-41D2-47BC-9AD3-0BDF34E83300}.Debug|x64.Build.0 = Debug|x64 + {A5502949-41D2-47BC-9AD3-0BDF34E83300}.Debug|x86.ActiveCfg = Debug|Win32 + {A5502949-41D2-47BC-9AD3-0BDF34E83300}.Debug|x86.Build.0 = Debug|Win32 + {A5502949-41D2-47BC-9AD3-0BDF34E83300}.Release|x64.ActiveCfg = Release|x64 + {A5502949-41D2-47BC-9AD3-0BDF34E83300}.Release|x64.Build.0 = Release|x64 + {A5502949-41D2-47BC-9AD3-0BDF34E83300}.Release|x86.ActiveCfg = Release|Win32 + {A5502949-41D2-47BC-9AD3-0BDF34E83300}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {182C1B8B-3A39-4D63-A976-D0317374C0BF} + EndGlobalSection +EndGlobal + +``` + +`Ezfrags/AimAssist.cpp`: + +```cpp +#include "Settings.hpp" +#include "AimAssist.h" + +void aim_assist_thread() { + cheat_thread_state::aim_assist_thread_status = 1; +} +``` + +`Ezfrags/AimAssist.h`: + +```h +#pragma once + +void aim_assist_thread(); +``` + +`Ezfrags/Aimlock.cpp`: + +```cpp +#include "Settings.hpp" +#include "Aimlock.h" + +void aimlock_thread() { + cheat_thread_state::aimlock_thread_status = 1; +} +``` + +`Ezfrags/Aimlock.h`: + +```h +#pragma once + +void aimlock_thread(); +``` + +`Ezfrags/BunnyHop.cpp`: + +```cpp +#include "Settings.hpp" +#include "MemManager.h" +#include "Signatures.h" +#include "BunnyHop.h" +#include "Signatures.h" + +#include +#include + +//This function is about 90% decompiled +void bunnyhop_thread() { + cheat_thread_state::bunnyhop_thread_status = 1; + while (1) { + while (!settings::bunnyhop_bool || !Mem::csgo_found || !Mem::client_dll_found) { + Sleep(5u); + } + + //Mem::RPM(Mem::client + get_sigs::dwLocalPlayer) + bool player_alive = true; + if (player_alive && GetAsyncKeyState(32) < 0)// If we're alive and we're pressing space + { + Mem::WPM(Mem::client + Signatures::dwForceJump, 5);// force jump + Sleep(10u); + Mem::WPM(Mem::client + Signatures::dwForceJump, 4);// unjump + } + Sleep(1u); + + /* + while ( !bunnyhop_bool || !csgo_module || !client_module_found || !byte_4FBF0C || LocalPlayer_notsure == 1 ) + Sleep(5u); + if ( ReadProcessMemory_2(player, v2, v3, v4, v5) && GetAsyncKeyState(32) < 0 )// If we're alive and we're pressing space + { + write_memory((LPVOID)(client + dwForceJump), 5);// force jump + Sleep(10u); + write_memory((LPVOID)(client + dwForceJump), 4);// unjump + } + Sleep(1u); + */ + } +} +``` + +`Ezfrags/BunnyHop.h`: + +```h +#pragma once + +void bunnyhop_thread(); +``` + +`Ezfrags/Ezfrags.cpp`: + +```cpp +#include +#include + +#include "MemManager.cpp" +#include "Signatures.cpp" +#include "ShowFeatures.cpp" +#include "WaitForKeys.cpp" + +#include "AimAssist.cpp" +#include "Aimlock.cpp" +#include "BunnyHop.cpp" +#include "GlowESP.cpp" +#include "KillMessage.cpp" +#include "NoFlash.cpp" +#include "Radar.cpp" +#include "Triggerbot.cpp" + +#include "Settings.hpp" +#include "Ezfrags.h" + +#include "StringObfuscation.hpp" + +time_t TimeUpdate; +time_t current_time; // eax + +int main() +{ + start_obfuscation(); + current_time = time(0); // current time in seconds + srand((unsigned int)current_time); // sets the seed for random numbers to the current time + // randomness will be used later for the kill message + + std::cout << console_title << std::endl; + SetConsoleTitleA("EZfrags CS:GO multihack v9.65 public [www.EZfrags.co.uk]"); //Ezfrag premium ++ spinbout edition + std::cout << "EZfrags CS:GO multihack v9.65 public [www.EZfrags.co.uk]" << "\n"; + + time(&TimeUpdate); + if (TimeUpdate - 1591304279 > 864000) // If our version is older than 10 days + { + std::cout << '\n' << "!!! WARNING !!!: This version is more than 10 days old."; + std::cout << '\n' << "You should go and download a new build from www.EZfrags.co.uk" << std::endl; + } + + std::cout << '\n' << "The hack will start loading once CS:GO is started." << std::endl; + + std::cout << "\n" << "Loading csgo.exe"; + CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Mem::get_csgo, 0, 0, 0); + + //All this instant thing is just from me, that doesn't figure in the original code + //So yeah that's to change ig + bool instant_csgo = true; + while (!Mem::csgo_found) + { + Sleep(250); + + if (Mem::csgo_found) + { + break; + } + + std::cout << "."; + + instant_csgo = false; + } + + if (instant_csgo) { + std::cout << "...."; + } + + std::cout << std::endl; + + std::cout << "Loading client.dll"; + CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Mem::get_client_base_address, 0, 0, 0); + + bool instant_client = true; + while (!Mem::client_dll_found) + { + Sleep(250); + + if (Mem::client_dll_found) + { + break; + } + + std::cout << "."; + + instant_client = false; + } + + if (instant_client) { + std::cout << "...."; + } + + std::cout << std::endl; + + + std::cout << "Loading engine.dll"; + CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Mem::get_engine_base_address, 0, 0, 0); + + bool instant_engine = true; + while (!Mem::engine_dll_found) + { + + Sleep(250); + + if (Mem::engine_dll_found) + { + break; + } + std::cout << "."; + + instant_engine = false; + } + + if (instant_engine) { + std::cout << "...."; + } + + std::cout << std::endl; + + std::cout << "\n" << "Scanning for offsets..."; + + get_sigs::start(); + + CreateThread(0, 0, (LPTHREAD_START_ROUTINE)radar_thread, 0, 0, 0);// Stuck + CreateThread(0, 0, (LPTHREAD_START_ROUTINE)aim_assist_thread, 0, 0, 0);// + CreateThread(0, 0, (LPTHREAD_START_ROUTINE)no_flash_thread, 0, 0, 0);// Done ! + CreateThread(0, 0, (LPTHREAD_START_ROUTINE)bunnyhop_thread, 0, 0, 0);// Done ! + CreateThread(0, 0, (LPTHREAD_START_ROUTINE)aimlock_thread, 0, 0, 0);// + CreateThread(0, 0, (LPTHREAD_START_ROUTINE)glow_esp_thread, 0, 0, 0);// + CreateThread(0, 0, (LPTHREAD_START_ROUTINE)kill_message_thread, 0, 0, 0);// + CreateThread(0, 0, (LPTHREAD_START_ROUTINE)trigger_thread, 0, 0, 0);// + while (!cheat_thread_state::aim_assist_thread_status + || !cheat_thread_state::aimlock_thread_status + || !cheat_thread_state::no_flash_thread_status + || !cheat_thread_state::glow_esp_thread_status + || !cheat_thread_state::radar_thread_status + || !cheat_thread_state::bunnyhop_thread_status + || !cheat_thread_state::trigger_thread_status + || !cheat_thread_state::kill_message_thread_status) + Sleep(100u); + + settings::glow_esp_bool = 1; + settings::trigger_mode_switch_1 = 0; + settings::aimlock_bool = 1; + settings::radar_bool = 1; + settings::aim_assist_bool = 1; + settings::trigger_mode_switch_2 = 0; + settings::bunnyhop_bool = 1; + settings::kill_message_bool = 1; + settings::no_flash_bool = 1; + update(); + + while (WaitForSingleObject(Mem::process_handle, 0)) { + wait_for_keys(); + } + CloseHandle(Mem::process_handle); + exit(0); +} + + +``` + +`Ezfrags/Ezfrags.h`: + +```h +#pragma once + +int main(); +``` + +`Ezfrags/Ezfrags.vcxproj`: + +```vcxproj + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {a5502949-41d2-47bc-9ad3-0bdf34e83300} + Ezfrags + 10.0 + + + + Application + true + v142 + MultiByte + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +`Ezfrags/Ezfrags.vcxproj.filters`: + +```filters + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {22c8e2bf-5511-4a73-baf5-ff24109b3af1} + + + {252e8f23-1acb-462d-b403-e33b980580de} + + + {93ecdca2-1ebf-408b-b23c-89a0bdb5cbc1} + + + + + Fichiers sources + + + Memory + + + Memory + + + + + Memory + + + Memory + + + Console + + + Fichiers sources + + + Console + + + Hacks + + + Hacks + + + Hacks + + + Hacks + + + Hacks + + + Hacks + + + Hacks + + + Hacks + + + Console + + + Console + + + Memory + + + Memory + + + Hacks + + + Hacks + + + Hacks + + + Hacks + + + Hacks + + + Hacks + + + Hacks + + + Hacks + + + Fichiers sources + + + Memory + + + +``` + +`Ezfrags/Ezfrags.vcxproj.user`: + +```user + + + + +``` + +`Ezfrags/Get.cpp`: + +```cpp +#include "MemManager.h" +#include "Signatures.h" +#include "Get.h" + +namespace Get { + INT32 LocalPlayer() { + return Mem::RPM(Mem::client + Signatures::dwLocalPlayer); + } +} + +``` + +`Ezfrags/Get.h`: + +```h +#pragma once +#include + +namespace Get { + INT32 LocalPlayer(); +} +``` + +`Ezfrags/GlowESP.cpp`: + +```cpp +#include "Settings.hpp" +#include "GlowESP.h" + +void glow_esp_thread() { + cheat_thread_state::glow_esp_thread_status = 1; +} +``` + +`Ezfrags/GlowESP.h`: + +```h +#pragma once + +void glow_esp_thread(); +``` + +`Ezfrags/KillMessage.cpp`: + +```cpp +#include "Settings.hpp" +#include "KillMessage.h" + +void kill_message_thread() { + cheat_thread_state::kill_message_thread_status = 1; +} +``` + +`Ezfrags/KillMessage.h`: + +```h +#pragma once + +void kill_message_thread(); +``` + +`Ezfrags/MemManager.cpp`: + +```cpp +#include +#include +#include +#include +#include "MemManager.h" + +namespace Mem { + inline MODULEENTRY32 get_module(const char* modName, DWORD proc_id) { + HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, proc_id); + if (hSnap != INVALID_HANDLE_VALUE) { + MODULEENTRY32 modEntry; + modEntry.dwSize = sizeof(modEntry); + if (Module32First(hSnap, &modEntry)) { + do { + if (!strcmp(modEntry.szModule, modName)) { + CloseHandle(hSnap); + return modEntry; + } + } while (Module32Next(hSnap, &modEntry)); + } + } + MODULEENTRY32 module = { (DWORD)-1 }; + return module; + } + + inline void get_csgo() { + while (1) { + //Get a window handle to csgo + HWND hw_csgo = FindWindowA(NULL, "Counter-Strike: Global Offensive - Direct3D 9"); + + if (hw_csgo) { + csgo_found = true; + //Get csgo's process ID using the handle (No need to make some big function for procid like every other paster does) + GetWindowThreadProcessId(hw_csgo, &dw_process_id); + Mem::process_handle = OpenProcess(PROCESS_VM_READ | PROCESS_VM_OPERATION | PROCESS_VM_WRITE, false, dw_process_id); + break; + } + } + + } + + inline void get_client_base_address() { + while (1) { + Mem::dw_client_address = get_module("client.dll", dw_process_id); + Mem::client_bytes = new uint8_t[Mem::dw_client_address.modBaseSize]; //making a variable size of the module + + Mem::client = (uintptr_t)dw_client_address.modBaseAddr; + + if (Mem::client_bytes) { + client_dll_found = true; + break; + } + + DWORD bytes_read; + ReadProcessMemory(process_handle, Mem::dw_client_address.modBaseAddr, Mem::client_bytes, Mem::dw_client_address.modBaseSize, &bytes_read); //reading the module and storing as bytes_read + if (bytes_read != Mem::dw_client_address.modBaseSize) throw; //checking that the size of bytes read is = to size of bytes in the module + delete[] Mem::client_bytes; + } + } + + inline void get_engine_base_address() { + while (1) { + MODULEENTRY32 dw_engine_address = get_module("engine.dll", dw_process_id); + engine_bytes = new uint8_t[dw_engine_address.modBaseSize]; //making a variable size of the module + + Mem::engine = (uintptr_t)dw_engine_address.modBaseAddr; + + if (engine_bytes) { + engine_dll_found = true; + break; + } + + DWORD bytes_read; + ReadProcessMemory(process_handle, dw_engine_address.modBaseAddr, engine_bytes, dw_engine_address.modBaseSize, &bytes_read); //reading the module and storing as bytes_read + if (bytes_read != dw_engine_address.modBaseSize) throw; //checking that the size of bytes read is = to size of bytes in the module + delete[] Mem::engine_bytes; + } + } + + //https://github.com/Made0x0000000a/nyfox/blob/main/csgoCheat/patternscan.cpp + DWORD FindAddress(const wchar_t* moduleName, const char* pattern, const char* mask, const int offset=0, const int extra=0) { + const MODULEENTRY32 moduleEntry = Mem::dw_client_address; + const HANDLE hProcess = Mem::process_handle; + + // No Module Entry found + if (!moduleEntry.th32ModuleID) { + return NULL; + } + + // Module base address = scan starting point + uintptr_t base = (uintptr_t)moduleEntry.modBaseAddr; + // Size of Module = scan end point + uintptr_t size = base + moduleEntry.modBaseSize; + + uintptr_t curChunk = base; + SIZE_T bytesRead; + DWORD res; + int res_plus_offset = 0; + + while (curChunk < size) { + // Area to scan + char buffer[4096]; + + // Change read protection, raed memory and change read protection back to the original + DWORD oProtect; + VirtualProtectEx(hProcess, (LPVOID)curChunk, sizeof(buffer), PAGE_EXECUTE_READWRITE, &oProtect); + ReadProcessMemory(hProcess, (LPVOID)curChunk, &buffer, sizeof(buffer), &bytesRead); + VirtualProtectEx(hProcess, (LPVOID)curChunk, sizeof(buffer), oProtect, &oProtect); + + // No bytes read + if (bytesRead == 0) { + return NULL; + } + + DWORD internalAddr = Mem::FindPattern((char*)&buffer, bytesRead, pattern, mask); + + if (internalAddr != NULL) { + // Calculate real address + uintptr_t offsetFromBuffer = (uintptr_t)internalAddr - (uintptr_t)&buffer; + res = (DWORD)(curChunk + offsetFromBuffer); + res_plus_offset = Mem::RPM(res + offset); //Adding the offset + return res_plus_offset - (DWORD)Mem::dw_client_address.modBaseAddr + extra; //adding the extra + } + else { + // Next chunk + curChunk += bytesRead; + } + } + return NULL; + } + + // Find matching pattern + DWORD FindPattern(char* base, size_t size, const char* pattern, const char* mask) { + size_t patternLen = strlen(mask); + + for (DWORD i = 0; i < size - patternLen; i++) { + bool found = true; + + for (DWORD j = 0; j < patternLen; j++) { + + if (mask[j] != '?' && pattern[j] != *(base + i + j)) { + found = false; + break; + } + } + + if (found) { + return (DWORD)(base + i); + } + } + + return NULL; + } + + template T RPM(SIZE_T address) { + T buffer; + ReadProcessMemory(process_handle, (LPCVOID)address, &buffer, sizeof(T), NULL); + return buffer; + } + + template void WPM(SIZE_T address, T buffer) { + WriteProcessMemory(process_handle, (LPVOID)address, &buffer, sizeof(buffer), NULL); + } +} +``` + +`Ezfrags/MemManager.h`: + +```h +#pragma once +#include +#include +#include +#include + +namespace Mem { + static bool csgo_found = false; + static bool client_dll_found = false; + static bool engine_dll_found = false; + static uintptr_t client; + static uintptr_t engine; + static DWORD dw_process_id; + static MODULEENTRY32 dw_client_address; + static MODULEENTRY32 dw_engine_address; + static HANDLE process_handle; + static uint8_t* client_bytes; + static uint8_t* engine_bytes; + + inline MODULEENTRY32 get_module(const char* modName, DWORD proc_id); + inline void get_csgo(); + inline void get_client_base_address(); + inline void get_engine_base_address(); + DWORD FindAddress(const wchar_t* moduleName, const char* pattern, const char* mask, const int offset, const int extra); + DWORD FindPattern(char* base, size_t size, const char* pattern, const char* mask); + + template T RPM(SIZE_T address); + template void WPM(SIZE_T address, T buffer); +} + +``` + +`Ezfrags/NoFlash.cpp`: + +```cpp +#include "Settings.hpp" +#include "MemManager.h" +#include "Signatures.h" +#include "Get.h" +#include "NoFlash.h" + +//This function has been 100% decompiled ! +//Not actually, still remains : +/* + while ( !csgo_module || !client_module_found || !byte_4FBF0C ) + Sleep(5u); +*/ +//But i simplified it here +//No idea what byte_4FBF0C is, seems used in the GetEngine function of Ezfrags, it's yet to be decompiled + +void no_flash_thread() { + cheat_thread_state::no_flash_thread_status = 1; + + while (1) + { + while (!Mem::csgo_found || !Mem::client_dll_found) + Sleep(5u); + + if (settings::no_flash_bool) + { + /* + if (ReadProcessMemory_0((char*)player + m_flFlashMaxAlpha) > 0.0)// If flash value is > 0 + WriteProcessMemory_0((char*)player + m_flFlashMaxAlpha, (float)0.0);// We put anti flash + */ + if (Mem::RPM(Get::LocalPlayer() + Netvars::m_flFlashMaxAlpha) > 0.0f) + Mem::WPM(Get::LocalPlayer() + Netvars::m_flFlashMaxAlpha, 0.0f); + } + + /* + else if (0.0 == ReadProcessMemory_0((char*)player + m_flFlashMaxAlpha))// We need to reset the flash value to 255 + { + WriteProcessMemory_0((char*)player + m_flFlashMaxAlpha, (float)255.0);// Yop + } + */ + + else if (Mem::RPM(Get::LocalPlayer() + Netvars::m_flFlashMaxAlpha) == 0.0f) { + Mem::WPM(Get::LocalPlayer() + Netvars::m_flFlashMaxAlpha, 255.0f); + } + + //std::cout << Mem::RPM(Signatures::dwLocalPlayer + Netvars::m_flFlashMaxAlpha) << std::endl; + //Sleep(300); + Sleep(1u); + } +} +``` + +`Ezfrags/NoFlash.h`: + +```h +#pragma once + +void no_flash_thread(); +``` + +`Ezfrags/Radar.cpp`: + +```cpp +#include "Settings.hpp" +#include "MemManager.h" +#include "netvars.h" +#include "Radar.h" + +#define BYTE1(Entities) (*((char *)(&Entities) + 1)) + +/* +Still a prototype of what it would look like +I don't know where they actually get the Entities_unk variable +Also i don't know anything about byte_4FBF0C, doesn't seem that important +*/ + +void radar_thread() { + int Entities[157]; + + cheat_thread_state::radar_thread_status = 1; + + return; //don't wanna cause errors + while (1) + { + while (!Mem::csgo_found || !settings::radar_bool || !Mem::client_dll_found) //|| !byte_4FBF0C) Don't know about this byte + Sleep(5u); + + for (int i = 0; i <= 63 && Mem::csgo_found == 1 && Mem::client_dll_found == 1; i++)//For every player in the map. //&& byte_4FBF0C == 1; ++i) Same byte as before + { + //memcpy(Entities, (char*)&Entities_unk + 628 * i, sizeof(Entities)); + if (BYTE1(Entities[146]) + && LOBYTE(Entities[141]) + && LOBYTE(Entities[78]) + && BYTE1(Entities[118]) != 1 + && BYTE1(Entities[99]) != 1 + //&& Entities[4] != dword_4FBEF0 + && (Mem::RPM(Entities[120] + Netvars::m_bSpotted) != 1)) // If ennemy is not spotted + //&& (unsigned __int8)RPM((LPCVOID)(Entities[120] + m_bSpotted)) != 1) + { + //Mem::WPM_test((LPVOID)(Entities[120] + Netvars::m_bSpotted), 1); + //WPM((LPVOID)(Entities[120] + m_bSpotted), 1);// Set entity is spotted + } + } + Sleep(1u); + } + +} +``` + +`Ezfrags/Radar.h`: + +```h +#pragma once + +void radar_thread(); +``` + +`Ezfrags/Settings.hpp`: + +```hpp +#pragma once + +namespace settings { + bool glow_esp_bool; + int trigger_mode_switch_1; + int trigger_mode_switch_2; + int trigger_delay = 30; + bool aimlock_bool; + int aimlock_bone = 6; //8 : chest, 6 : head + bool radar_bool; + bool aim_assist_bool; + int aim_assist_bone = 6; //8 : chest, 6 : head + float aim_fov = 25.0; + bool bunnyhop_bool; + bool kill_message_bool; + bool no_flash_bool; +}; + +namespace cheat_thread_state { + bool aim_assist_thread_status = 0; + bool aimlock_thread_status = 0; + bool no_flash_thread_status = 0; + bool glow_esp_thread_status = 0; + bool radar_thread_status = 0; + bool bunnyhop_thread_status = 0; + bool trigger_thread_status = 0; + bool kill_message_thread_status = 0; +} +``` + +`Ezfrags/ShowFeatures.cpp`: + +```cpp +#include +#include +#include "ShowFeatures.h" +#include "Settings.hpp" + +time_t Time; + +void update() { + system("cls"); + + std::cout << "EZfrags CS:GO multihack v9.65 public [www.EZfrags.co.uk]" << "\n"; + + time(&Time); + if (Time - 1591304279 > 864000) // If our version is older than 10 days + { + std::cout << '\n' << "!!! WARNING !!!: This version is more than 10 days old."; + std::cout << '\n' << "You should go and download a new build from www.EZfrags.co.uk" << std::endl; + } + + std::cout << '\n' << "The hack has been loaded. Have fun!" << std::endl; + + std::cout << "\n" << "TRIGGERBOT "; + if (settings::trigger_mode_switch_2 && settings::trigger_mode_switch_1 != 1) + { + std::cout << "AUTO"; + } + else if (settings::trigger_mode_switch_2 != 1 && settings::trigger_mode_switch_1) + { + std::cout << "HOLD"; + } + else if (settings::trigger_mode_switch_2 != 1 && settings::trigger_mode_switch_1 != 1) + { + std::cout << "OFF"; + } + + std::cout << " @ " << settings::trigger_delay << " MS"; + + std::cout << std::endl; + + std::cout << "AIM ASSIST " << settings::aim_assist_bool << " @ "; + if (settings::aim_assist_bone == 8) { + std::cout << "CHEST" << std::endl; + } + else { + std::cout << "HEAD" << std::endl; + } + + std::cout << "AIMLOCK " << settings::aimlock_bool << " @ "; + if (settings::aimlock_bone == 8) { + std::cout << "CHEST" << std::endl; + } + else { + std::cout << "HEAD" << std::endl; + } + + std::cout << "GLOW ESP " << settings::glow_esp_bool << std::endl; + + std::cout << "RADAR HACK " << settings::radar_bool << std::endl; + + std::cout << "NO FLASH HACK " << settings::no_flash_bool << std::endl; + + std::cout << "BUNNY HOP " << settings::bunnyhop_bool << std::endl; + + std::cout << "KILL MESSAGE " << settings::kill_message_bool; +} +``` + +`Ezfrags/ShowFeatures.h`: + +```h +#pragma once + +void update(); +``` + +`Ezfrags/Signatures.cpp`: + +```cpp +#include "MemManager.h" +#include "netvars.h" +#include "Signatures.h" +#include +#include + +namespace get_sigs { + //https://github.com/HeathHowren/Pattern-Scanning/blob/master/patternscanexternal/Source.cpp + + void start() { + //Netvars + DWORD dwGetAllClasses = Mem::FindAddress(L"client.dll", "\xA1\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xA1\x00\x00\x00\x00\xB9","x????xxxxxxxxxxxx????x", 1, 0) + (uintptr_t)Mem::dw_client_address.modBaseAddr; + DWORD dwGetAllClasses_deref = Mem::RPM(dwGetAllClasses); + DWORD dwGetAllClasses_offset = dwGetAllClasses_deref - (uintptr_t)Mem::dw_client_address.modBaseAddr; + + std::unique_ptr NetvarManager(new NetvarsClass((uintptr_t)Mem::dw_client_address.modBaseAddr + dwGetAllClasses_offset)); + Netvars::m_fFlags = NetvarManager->NETVAR("DT_CSPlayer", "m_fFlags"); + Netvars::m_flFlashMaxAlpha = NetvarManager->NETVAR("DT_CSPlayer", "m_flFlashMaxAlpha"); + Netvars::m_bSpotted = NetvarManager->NETVAR("DT_BaseEntity", "m_bSpotted"); + + //Signatures + Signatures::dwLocalPlayer = Mem::FindAddress(L"client.dll", "\x8D\x34\x85\x00\x00\x00\x00\x89\x15\x00\x00\x00\x00\x8B\x41\x08\x8B\x48\x04\x83\xF9\xFF", "xxx????xx????xxxxxxxxx", 3, 4); + Signatures::dwForceJump = Mem::FindAddress(L"client.dll", "\x8B\x0D\x00\x00\x00\x00\x8B\xD6\x8B\xC1\x83\xCA\x02", "xx????xxxxxxx", 2, 0); + } +} + +``` + +`Ezfrags/Signatures.h`: + +```h +#pragma once +#include + +namespace get_sigs { + void start(); +} + +namespace Signatures { + static DWORD dwForceJump; + static DWORD dwLocalPlayer; +} + +namespace Netvars { + static int m_fFlags; + static int m_flFlashMaxAlpha; + static int m_bSpotted; +} +``` + +`Ezfrags/Triggerbot.cpp`: + +```cpp +#include "Settings.hpp" +#include "Triggerbot.h" + +void trigger_thread() { + cheat_thread_state::trigger_thread_status = 1; +} +``` + +`Ezfrags/Triggerbot.h`: + +```h +#pragma once + +void trigger_thread(); +``` + +`Ezfrags/WaitForKeys.cpp`: + +```cpp +#include +#include +#include "WaitForKeys.h" +#include "ShowFeatures.h" +#include "Settings.hpp" + +void wait_for_keys() +{ + if (GetAsyncKeyState(16) >= 0 && GetAsyncKeyState(117) < 0)// + // F6 - cycle through triggerbot modes (autofire, hold key, disabled - default) + // SHIFT+F6 - cycle through triggerbot delays (10, 30 - default, 50, 80, 110, 140) + { + while (GetAsyncKeyState(16) >= 0 && GetAsyncKeyState(117) < 0) + Sleep(75u); + if (settings::trigger_mode_switch_2 && settings::trigger_mode_switch_1 != 1)// mode switching (f6) + { + settings::trigger_mode_switch_2 = 0; + settings::trigger_mode_switch_1 = 1; + } + else if (settings::trigger_mode_switch_2 != 1 && settings::trigger_mode_switch_1) + { + settings::trigger_mode_switch_2 = 0; + settings::trigger_mode_switch_1 = 0; + } + else if (settings::trigger_mode_switch_2 != 1 && settings::trigger_mode_switch_1 != 1) + { + settings::trigger_mode_switch_2 = 1; + settings::trigger_mode_switch_1 = 0; + } + update(); + } + if (GetAsyncKeyState(16) < 0 && GetAsyncKeyState(117) < 0) + { + while (GetAsyncKeyState(16) < 0 && GetAsyncKeyState(117) < 0) + Sleep(75u); + if (settings::trigger_delay == 140) // Delay switching (shift + f6) + { + settings::trigger_delay = 10; + } + else if (settings::trigger_delay == 10 || settings::trigger_delay == 30) + { + settings::trigger_delay += 20; + } + else + { + settings::trigger_delay += 30; + } + update(); + } + if (GetAsyncKeyState(16) >= 0 && GetAsyncKeyState(118) < 0)// + // F7 - toggle aim assist + // SHIFT+F7 - toggle aim assist mode (rage/legit) + { + while (GetAsyncKeyState(16) >= 0 && GetAsyncKeyState(118) < 0) + Sleep(75u); + settings::aim_assist_bool = settings::aim_assist_bool == 0; + update(); + } + if (GetAsyncKeyState(16) < 0 && GetAsyncKeyState(118) < 0) + { + while (GetAsyncKeyState(16) < 0 && GetAsyncKeyState(118) < 0) + Sleep(75u); + if (settings::aim_assist_bone == 8) // mode switching (shift + f7) + { + settings::aim_assist_bone = 6; // switching between bones, head and chest + settings::aim_fov = 25.0; // switching between 25.0 and 100.0 fov + } + else + { + settings::aim_assist_bone = 8; + settings::aim_fov = 100.0; + } + update(); + } + if (GetAsyncKeyState(16) >= 0 && GetAsyncKeyState(119) < 0)// + // F8 - toggle aimlock 119 + // SHIFT+F8 - toggle aimlock target (head/chest) + { + while (GetAsyncKeyState(16) >= 0 && GetAsyncKeyState(119) < 0) + Sleep(75u); + settings::aimlock_bool = settings::aimlock_bool == 0; + update(); + } + if (GetAsyncKeyState(16) < 0 && GetAsyncKeyState(119) < 0) + { + while (GetAsyncKeyState(16) < 0 && GetAsyncKeyState(119) < 0) + Sleep(75u); + if (settings::aimlock_bone == 8) // switching between bones, head and chest + settings::aimlock_bone = 6; + else + settings::aimlock_bone = 8; + update(); + } + if (GetAsyncKeyState(16) >= 0 && GetAsyncKeyState(120) < 0)// + // F9 - toggle GlowESP 120 + // SHIFT+F9 - toggle radar hack + { + while (GetAsyncKeyState(16) >= 0 && GetAsyncKeyState(120) < 0) + Sleep(75u); + settings::glow_esp_bool = settings::glow_esp_bool == 0; + update(); + } + if (GetAsyncKeyState(16) < 0 && GetAsyncKeyState(120) < 0) + { + while (GetAsyncKeyState(16) < 0 && GetAsyncKeyState(120) < 0) + Sleep(75u); + settings::radar_bool = settings::radar_bool == 0; + update(); + } + if (GetAsyncKeyState(121) < 0) // + // F10 - toggle no flash hack + { + while (GetAsyncKeyState(121) < 0) + Sleep(75u); + settings::no_flash_bool = settings::no_flash_bool == 0; + update(); + } + if (GetAsyncKeyState(16) >= 0 && GetAsyncKeyState(122) < 0)// + // F11 - toggle bunny hop 122 + // SHIFT+F11 - toggle kill message + { + while (GetAsyncKeyState(16) >= 0 && GetAsyncKeyState(122) < 0) + Sleep(75u); + settings::bunnyhop_bool = settings::bunnyhop_bool == 0; + update(); + } + if (GetAsyncKeyState(16) < 0 && GetAsyncKeyState(122) < 0) + { + while (GetAsyncKeyState(16) < 0 && GetAsyncKeyState(122) < 0) + Sleep(75u); + settings::kill_message_bool = settings::kill_message_bool == 0; + update(); + } + Sleep(25u); +} +``` + +`Ezfrags/WaitForKeys.h`: + +```h +#pragma once + +void wait_for_keys(); +``` + +`Ezfrags/netvars.h`: + +```h +#pragma once +#include +#include +#include + +#include "MemManager.h" + +class NetvarsClass { +private: + class RecvTable { + public: + std::string GetTableName() { + DWORD offset = Mem::RPM((DWORD)this + 0xC); + char tableName[128]; + ReadProcessMemory(Mem::process_handle, (LPCVOID)offset, &tableName, sizeof(tableName), 0); + return std::string(tableName); + } + void* GetProperty(int i) { // RecvProp* + return (void*)(Mem::RPM((DWORD)this) + 0x3C * i); + } + int GetMaxProp() { + return Mem::RPM((DWORD)this + 0x4); + } + }; + class ClientClass { + public: + void* GetTable() { // RecvTable* + return Mem::RPM((DWORD)this + 0xC); + } + void* GetNextClass() { // ClientClass* + return Mem::RPM((DWORD)this + 0x10); + } + }; + class RecvProp { + public: + std::string GetVarName() { + DWORD offset = Mem::RPM((DWORD)this); + char vName[128]; + ReadProcessMemory(Mem::process_handle, (LPCVOID)offset, &vName, sizeof(vName), 0); + return std::string(vName); + } + int GetOffset() { + return Mem::RPM((DWORD)this + 0x2C); + } + void* GetDataTable() { // RecvTable* + return Mem::RPM((DWORD)this + 0x28); + } + }; + DWORD CheckProps(RecvTable* DataTable, std::string NetVarName) { + for (int i = 0; i < DataTable->GetMaxProp(); i++) { + auto pRecvProp = reinterpret_cast(DataTable->GetProperty(i)); + auto VarName = pRecvProp->GetVarName(); + if (isdigit(VarName[0])) continue; + if (NetVarName.compare(VarName) == 0) return pRecvProp->GetOffset(); + if (auto DataTable2 = reinterpret_cast(pRecvProp->GetDataTable())) + if (auto Offset = CheckProps(DataTable2, NetVarName)) return Offset; + } + return NULL; + } + DWORD dwGetAllClasses; + +public: + NetvarsClass(DWORD Base) : dwGetAllClasses(Base) {} + DWORD NETVAR(std::string ClassName, std::string NetVarName) { + if (auto pClass = reinterpret_cast(dwGetAllClasses)) + for (; pClass != NULL; pClass = reinterpret_cast(pClass->GetNextClass())) + if (auto Table = reinterpret_cast(pClass->GetTable())) + if (Table->GetTableName().compare(ClassName) == 0) + if (auto Offset = CheckProps(Table, NetVarName)) return Offset; + return NULL; + } +}; +``` + +`README.md`: + +```md +# Ezfrags +Ezfrags was the first cheat of a lot of people, and probably their last. This cheat is so popular that it became a meme in the CS:GO community. + +# Why ? +I wanted to start this project because a lot of people are not sure if Ezfrags is a virus, if it's detected etc.. Also because the updates are slow to arrive. And obviously because i couldn't resist to make the code of this masterpiece public. +The point is that we can update the cheat, make it undetected, paste it, or just play with a clean version. It's also a training for me who'se learning reverse engineering. + +# How ? +I'm currently using IDA 7.5 to decompile this cheat, [the database is avalaible in the repo](https://github.com/ALittlePatate/ezfrags/blob/master/Reversing/ezfrags.exe.idb). +Then you just have to read the code, try to understand and with some time you'll get there. +The version of Ezfrags i'm using here is the v9.65, from 05/06/2020. We don't need to use newer version as they just patch the signatures/structs. +I'm trying to replicate the function as close as they were written but a lot of them are very hard to understand (especially for a begginer like me). +Also the strings are obfuscated but idk how, i know where, but not how. +All the memory related things aren't decompiled yet so i'm using some pasted stuff for the Netvars/Signatures dump. + +# Decompilation state : +* ### UI : 100% +* ## Cheats + * ### [Triggerbot](https://github.com/ALittlePatate/ezfrags/blob/master/Ezfrags/Triggerbot.cpp) : 0% + * ### [AimAssist](https://gith](https://github.com/ALittlePatate/ezfrags/blob/master/Ezfrags/Aimlock.cpp)ub.com/ALittlePatate/ezfrags/blob/master/Ezfrags/AimAssist.cpp) : 0% + * ### [Aimlock](https://github.com/ALittlePatate/ezfrags/blob/master/Ezfrags/Aimlock.cpp) : 0% + * ### [GlowESP](https://github.com/ALittlePatate/ezfrags/blob/master/Ezfrags/GlowESP.cpp) : ~10-20% (see the IDA database) + * ### [Radar](https://github.com/ALittlePatate/ezfrags/blob/master/Ezfrags/Radar.cpp) : ~60% (see the IDA database) + * ### [Noflash](https://github.com/ALittlePatate/ezfrags/blob/master/Ezfrags/NoFlash.cpp) : 99% (missing 1 single variable) + * ### [Bhop](https://github.com/ALittlePatate/ezfrags/blob/master/Ezfrags/BunnyHop.cpp) : 99% (missing 1 single variable) + * ### [KillMessage](https://github.com/ALittlePatate/ezfrags/blob/master/Ezfrags/KillMessage.cpp) : 0% +* ### [Memory Management](https://github.com/ALittlePatate/ezfrags/blob/master/Ezfrags/MemManager.cpp) : 2% + +# The tools +I provided in the [Tools/ folder](https://github.com/ALittlePatate/ezfrags/tree/master/Tools) all the tools i'm using for this project. + +## Contact + +You can add me on discord at patate#1252 + +## Contributing + +Note: before contrubuting please make sure that your code is as close as the IDA database as you can, also try to stick to the general structure of the project. +Open an [issue](https://github.com/ALittlePatate/ezfrags/issues/new) or make a [pull request](https://github.com/ALittlePatate/ezfrags/pulls), i'll be glad to improve my project with you ! + +``` + +`Tools/convert_pattern.py`: + +```py +import sys + +""" +Basically converting a given pattern in this form : +8D 34 85 ? ? ? ? 89 15 ? ? ? ? 8B 41 08 8B 48 04 83 F9 FF +to this : +\x8D\x34\x85\x00\x00\x00\x00\x89\x15\x00\x00\x00\x00\x8B\x41\x08\x8B\x48\x04\x83\xF9\xFF +xxx????xx????xxxxxxxxx + +It also generates the mask for the signature. +The code isn't optimized because idc +""" + +sig = sys.argv[1] +sig = "\\x" + sig +temp = sig.replace(" ","\\x") +res = temp.replace("?","00") +print(res) + +res_list = sig.split(" ") +res_mask = "" +for charac in res_list : + if charac == "?" : + res_mask += "?" + else : + res_mask += "x" + +print(res_mask) +``` + +`Tools/decrypt_string.cpp`: + +```cpp +#include +#include + +void Decrypt(int a1, int size) +{ + unsigned int i; // [esp+10h] [ebp-4h] + + for (i = 0; i <= (size - 2); ++i) + *(char*)(a1 + i) ^= (char)i + 3; + *(char*)(a1 + (size - 1)) = 0; +} + + +int main() +{ + char string[] = "Pgdhiagm+jb|/"; + + Decrypt((int)string, sizeof(string)); + + std::cout << string << std::endl; + + return 0; +} +``` + +`how to use.txt`: + +```txt +The hack will start loading once CS:GO is started. +If the hack doesn't work, try clicking the 'Unblock' button in the .exe's properties. +Running the hack with administrator rights might sort it out, too. + +Keys: +- Left ALT - hold LALT to lock onto an enemy +- SPACE - hold SPACE to use bunny hop +- MOUSE5 and Middle Mouse Button - triggerbot hold keys + +- F6 - cycle through triggerbot modes (autofire, hold key, disabled - default) +- SHIFT+F6 - cycle through triggerbot delays (10, 30 - default, 50, 80, 110, 140) +- F7 - toggle aim assist +- SHIFT+F7 - toggle aim assist mode (rage/legit) +- F8 - toggle aimlock +- SHIFT+F8 - toggle aimlock target (head/chest) +- F9 - toggle GlowESP +- SHIFT+F9 - toggle radar hack +- F10 - toggle no flash hack +- F11 - toggle bunny hop +- SHIFT+F11 - toggle kill message +``` \ No newline at end of file diff --git a/archive/Akatsyk/2k17-club.txt b/archive/Akatsyk/2k17-club.txt new file mode 100644 index 00000000..1bf16166 --- /dev/null +++ b/archive/Akatsyk/2k17-club.txt @@ -0,0 +1,310298 @@ +Project Path: arc_Akatsyk_2k17-club_am3l1tw6 + +Source Tree: + +```txt +arc_Akatsyk_2k17-club_am3l1tw6 +├── CUtlMemory.hpp +├── CUtlString.cpp +├── CUtlString.hpp +├── CUtlVector.hpp +├── Counter-Strike Global Offensive.filters +├── Counter-Strike Global Offensive.vcxproj.user +├── LuaBridge +│ ├── List.h +│ ├── LuaBridge.h +│ ├── Map.h +│ ├── RefCountedObject.h +│ ├── RefCountedPtr.h +│ ├── Vector.h +│ └── detail +│ ├── CFunctions.h +│ ├── ClassInfo.h +│ ├── Constructor.h +│ ├── FuncTraits.h +│ ├── Iterator.h +│ ├── LuaException.h +│ ├── LuaHelpers.h +│ ├── LuaRef.h +│ ├── Namespace.h +│ ├── Security.h +│ ├── Stack.h +│ ├── TypeList.h +│ ├── TypeTraits.h +│ ├── Userdata.h +│ └── dump.h +├── aimbot.cpp +├── aimbot.hpp +├── anti_aimbot.cpp +├── anti_aimbot.hpp +├── auto.hpp +├── autostop.txt +├── autowall.cpp +├── autowall.hpp +├── beams.cpp +├── bell.hpp +├── chams.cpp +├── chams.hpp +├── clientstate.cpp +├── core.hpp +├── createmove.cpp +├── cutl_block_mem.hpp +├── cutl_fixed_mem.hpp +├── detours.h +├── detours.lib +├── displacement.cpp +├── displacement.hpp +├── drawing.cpp +├── entity.cpp +├── entity.hpp +├── event_manager.cpp +├── framestagenotify.cpp +├── fully updated fake.txt +├── grenades.cpp +├── grenades.hpp +├── hooge.hpp +├── hooked.hpp +├── horizon.hpp +├── i_menu.cpp +├── i_menu.hpp +├── icon_font.hpp +├── icons.hpp +├── imgui +│ ├── imconfig.h +│ ├── imgui.cpp +│ ├── imgui.h +│ ├── imgui_demo.cpp +│ ├── imgui_draw.cpp +│ ├── imgui_impl_dx9.cpp +│ ├── imgui_impl_dx9.h +│ ├── imgui_internal.h +│ ├── stb_rect_pack.h +│ ├── stb_textedit.h +│ └── stb_truetype.h +├── imgui_extension.cpp +├── imgui_extension.hpp +├── include +│ ├── VMProtectSDK32.dll +│ ├── lib +│ │ ├── VirtualizerSDK32.lib +│ │ ├── detours.lib +│ │ └── luajit.lib +│ ├── luajit-2.0.5 +│ │ ├── COPYRIGHT +│ │ ├── Makefile +│ │ ├── README +│ │ ├── doc +│ │ │ ├── bluequad-print.css +│ │ │ ├── bluequad.css +│ │ │ ├── changes.html +│ │ │ ├── contact.html +│ │ │ ├── ext_c_api.html +│ │ │ ├── ext_ffi.html +│ │ │ ├── ext_ffi_api.html +│ │ │ ├── ext_ffi_semantics.html +│ │ │ ├── ext_ffi_tutorial.html +│ │ │ ├── ext_jit.html +│ │ │ ├── extensions.html +│ │ │ ├── faq.html +│ │ │ ├── img +│ │ │ │ └── contact.png +│ │ │ ├── install.html +│ │ │ ├── luajit.html +│ │ │ ├── running.html +│ │ │ └── status.html +│ │ ├── dynasm +│ │ │ ├── dasm_arm.h +│ │ │ ├── dasm_arm.lua +│ │ │ ├── dasm_mips.h +│ │ │ ├── dasm_mips.lua +│ │ │ ├── dasm_ppc.h +│ │ │ ├── dasm_ppc.lua +│ │ │ ├── dasm_proto.h +│ │ │ ├── dasm_x64.lua +│ │ │ ├── dasm_x86.h +│ │ │ ├── dasm_x86.lua +│ │ │ └── dynasm.lua +│ │ ├── etc +│ │ │ ├── luajit.1 +│ │ │ └── luajit.pc +│ │ └── src +│ │ ├── Makefile +│ │ ├── Makefile.dep +│ │ ├── buildvm.exp +│ │ ├── buildvm.lib +│ │ ├── compile.cmd +│ │ ├── compiled.ljbc +│ │ ├── host +│ │ │ ├── README +│ │ │ ├── buildvm.c +│ │ │ ├── buildvm.h +│ │ │ ├── buildvm_asm.c +│ │ │ ├── buildvm_fold.c +│ │ │ ├── buildvm_lib.c +│ │ │ ├── buildvm_peobj.c +│ │ │ ├── genminilua.lua +│ │ │ └── minilua.c +│ │ ├── jit +│ │ │ ├── bc.lua +│ │ │ ├── bcsave.lua +│ │ │ ├── dis_arm.lua +│ │ │ ├── dis_mips.lua +│ │ │ ├── dis_mipsel.lua +│ │ │ ├── dis_ppc.lua +│ │ │ ├── dis_x64.lua +│ │ │ ├── dis_x86.lua +│ │ │ ├── dump.lua +│ │ │ ├── v.lua +│ │ │ └── vmdef.lua +│ │ ├── lauxlib.h +│ │ ├── lib_aux.c +│ │ ├── lib_base.c +│ │ ├── lib_bit.c +│ │ ├── lib_debug.c +│ │ ├── lib_ffi.c +│ │ ├── lib_init.c +│ │ ├── lib_io.c +│ │ ├── lib_jit.c +│ │ ├── lib_math.c +│ │ ├── lib_os.c +│ │ ├── lib_package.c +│ │ ├── lib_string.c +│ │ ├── lib_table.c +│ │ ├── lj.supp +│ │ ├── lj_alloc.c +│ │ ├── lj_alloc.h +│ │ ├── lj_api.c +│ │ ├── lj_arch.h +│ │ ├── lj_asm.c +│ │ ├── lj_asm.h +│ │ ├── lj_asm_arm.h +│ │ ├── lj_asm_mips.h +│ │ ├── lj_asm_ppc.h +│ │ ├── lj_asm_x86.h +│ │ ├── lj_bc.c +│ │ ├── lj_bc.h +│ │ ├── lj_bcdump.h +│ │ ├── lj_bcread.c +│ │ ├── lj_bcwrite.c +│ │ ├── lj_carith.c +│ │ ├── lj_carith.h +│ │ ├── lj_ccall.c +│ │ ├── lj_ccall.h +│ │ ├── lj_ccallback.c +│ │ ├── lj_ccallback.h +│ │ ├── lj_cconv.c +│ │ ├── lj_cconv.h +│ │ ├── lj_cdata.c +│ │ ├── lj_cdata.h +│ │ ├── lj_char.c +│ │ ├── lj_char.h +│ │ ├── lj_clib.c +│ │ ├── lj_clib.h +│ │ ├── lj_cparse.c +│ │ ├── lj_cparse.h +│ │ ├── lj_crecord.c +│ │ ├── lj_crecord.h +│ │ ├── lj_ctype.c +│ │ ├── lj_ctype.h +│ │ ├── lj_debug.c +│ │ ├── lj_debug.h +│ │ ├── lj_def.h +│ │ ├── lj_dispatch.c +│ │ ├── lj_dispatch.h +│ │ ├── lj_emit_arm.h +│ │ ├── lj_emit_mips.h +│ │ ├── lj_emit_ppc.h +│ │ ├── lj_emit_x86.h +│ │ ├── lj_err.c +│ │ ├── lj_err.h +│ │ ├── lj_errmsg.h +│ │ ├── lj_ff.h +│ │ ├── lj_ffrecord.c +│ │ ├── lj_ffrecord.h +│ │ ├── lj_frame.h +│ │ ├── lj_func.c +│ │ ├── lj_func.h +│ │ ├── lj_gc.c +│ │ ├── lj_gc.h +│ │ ├── lj_gdbjit.c +│ │ ├── lj_gdbjit.h +│ │ ├── lj_ir.c +│ │ ├── lj_ir.h +│ │ ├── lj_ircall.h +│ │ ├── lj_iropt.h +│ │ ├── lj_jit.h +│ │ ├── lj_lex.c +│ │ ├── lj_lex.h +│ │ ├── lj_lib.c +│ │ ├── lj_lib.h +│ │ ├── lj_load.c +│ │ ├── lj_mcode.c +│ │ ├── lj_mcode.h +│ │ ├── lj_meta.c +│ │ ├── lj_meta.h +│ │ ├── lj_obj.c +│ │ ├── lj_obj.h +│ │ ├── lj_opt_dce.c +│ │ ├── lj_opt_fold.c +│ │ ├── lj_opt_loop.c +│ │ ├── lj_opt_mem.c +│ │ ├── lj_opt_narrow.c +│ │ ├── lj_opt_sink.c +│ │ ├── lj_opt_split.c +│ │ ├── lj_parse.c +│ │ ├── lj_parse.h +│ │ ├── lj_record.c +│ │ ├── lj_record.h +│ │ ├── lj_snap.c +│ │ ├── lj_snap.h +│ │ ├── lj_state.c +│ │ ├── lj_state.h +│ │ ├── lj_str.c +│ │ ├── lj_str.h +│ │ ├── lj_strscan.c +│ │ ├── lj_strscan.h +│ │ ├── lj_tab.c +│ │ ├── lj_tab.h +│ │ ├── lj_target.h +│ │ ├── lj_target_arm.h +│ │ ├── lj_target_mips.h +│ │ ├── lj_target_ppc.h +│ │ ├── lj_target_x86.h +│ │ ├── lj_trace.c +│ │ ├── lj_trace.h +│ │ ├── lj_traceerr.h +│ │ ├── lj_udata.c +│ │ ├── lj_udata.h +│ │ ├── lj_vm.h +│ │ ├── lj_vmevent.c +│ │ ├── lj_vmevent.h +│ │ ├── lj_vmmath.c +│ │ ├── ljamalg.c +│ │ ├── lua.h +│ │ ├── lua.hpp +│ │ ├── lua51.dll +│ │ ├── lua51.exp +│ │ ├── lua51.lib +│ │ ├── luaconf.h +│ │ ├── luajit.c +│ │ ├── luajit.exe +│ │ ├── luajit.exp +│ │ ├── luajit.h +│ │ ├── luajit.lib +│ │ ├── lualib.h +│ │ ├── minilua.exp +│ │ ├── minilua.lib +│ │ ├── msvcbuild.bat +│ │ ├── ps4build.bat +│ │ ├── psvitabuild.bat +│ │ ├── script.lua +│ │ ├── vm_arm.dasc +│ │ ├── vm_mips.dasc +│ │ ├── vm_ppc.dasc +│ │ ├── vm_ppcspe.dasc +│ │ ├── vm_x86.dasc +│ │ └── xedkbuild.bat +│ ├── sdk +│ │ ├── Readme.txt +│ │ ├── Via ASM module +│ │ │ ├── How to add ASM files in your Solution.pdf +│ │ │ ├── Readme.txt +│ │ │ ├── VirtualizerSDKCustomVMsMacros.h +│ │ │ ├── VirtualizerSDKCustomVmMacros.asm +│ │ │ ├── VirtualizerSDKMacros.asm +│ │ │ ├── VirtualizerSDKMacros.h +│ │ │ ├── VirtualizerSDK_FISH_LITE.asm +│ │ │ └── VirtualizerSDK_FISH_LITE.h +│ │ ├── VirtualizerSDK.h +│ │ ├── VirtualizerSDK_BorlandC_inline.h +│ │ ├── VirtualizerSDK_BorlandC_inline_FISH_LITE.h +│ │ ├── VirtualizerSDK_CustomVMs.h +│ │ ├── VirtualizerSDK_CustomVMs_BorlandC_inline.h +│ │ ├── VirtualizerSDK_CustomVMs_GNU_inline.h +│ │ ├── VirtualizerSDK_CustomVMs_ICL_inline.h +│ │ ├── VirtualizerSDK_CustomVMs_LCC_inline.h +│ │ ├── VirtualizerSDK_CustomVMs_VC_inline.h +│ │ ├── VirtualizerSDK_FISH_LITE.h +│ │ ├── VirtualizerSDK_GNU_inline.h +│ │ ├── VirtualizerSDK_GNU_inline_FISH_LITE.h +│ │ ├── VirtualizerSDK_ICL_inline.h +│ │ ├── VirtualizerSDK_ICL_inline_FISH_LITE.h +│ │ ├── VirtualizerSDK_LCC_inline.h +│ │ ├── VirtualizerSDK_LCC_inline_FISH_LITE.h +│ │ ├── VirtualizerSDK_VC_inline.h +│ │ └── VirtualizerSDK_VC_inline_FISH_LITE.h +│ ├── sol +│ │ └── sol.hpp +│ ├── stb_image.h +│ └── stb_image_resize.h +├── internet.cpp +├── internet.hpp +├── knifebot.cpp +├── lag_comp.cpp +├── lag_comp.hpp +├── linkedlist.hpp +├── luabuild +│ ├── Makefile +│ ├── lapi.c +│ ├── lapi.h +│ ├── lauxlib.c +│ ├── lauxlib.h +│ ├── lbaselib.c +│ ├── lbitlib.c +│ ├── lcode.c +│ ├── lcode.h +│ ├── lcorolib.c +│ ├── lctype.c +│ ├── lctype.h +│ ├── ldblib.c +│ ├── ldebug.c +│ ├── ldebug.h +│ ├── ldo.c +│ ├── ldo.h +│ ├── ldump.c +│ ├── lfunc.c +│ ├── lfunc.h +│ ├── lgc.c +│ ├── lgc.h +│ ├── linit.c +│ ├── liolib.c +│ ├── llex.c +│ ├── llex.h +│ ├── llimits.h +│ ├── lmathlib.c +│ ├── lmem.c +│ ├── lmem.h +│ ├── loadlib.c +│ ├── lobject.c +│ ├── lobject.h +│ ├── lopcodes.c +│ ├── lopcodes.h +│ ├── loslib.c +│ ├── lparser.c +│ ├── lparser.h +│ ├── lprefix.h +│ ├── lstate.c +│ ├── lstate.h +│ ├── lstring.c +│ ├── lstring.h +│ ├── lstrlib.c +│ ├── ltable.c +│ ├── ltable.h +│ ├── ltablib.c +│ ├── ltm.c +│ ├── ltm.h +│ ├── lua.c +│ ├── lua.h +│ ├── lua.hpp +│ ├── luac.c +│ ├── luaconf.h +│ ├── lualib.h +│ ├── lundump.c +│ ├── lundump.h +│ ├── lutf8lib.c +│ ├── lvm.c +│ ├── lvm.h +│ ├── lzio.c +│ └── lzio.h +├── main.cpp +├── math.cpp +├── math.hpp +├── matrix.cpp +├── matrix.hpp +├── menu +│ ├── gui +│ │ ├── container +│ │ │ ├── section.cpp +│ │ │ ├── section.h +│ │ │ ├── tab.cpp +│ │ │ ├── tab.h +│ │ │ ├── window.cpp +│ │ │ └── window.h +│ │ ├── controls +│ │ │ ├── button.cpp +│ │ │ ├── button.h +│ │ │ ├── checkbox.cpp +│ │ │ ├── checkbox.h +│ │ │ ├── colorpicker.cpp +│ │ │ ├── colorpicker.h +│ │ │ ├── combobox.cpp +│ │ │ ├── combobox.h +│ │ │ ├── keybind.cpp +│ │ │ ├── keybind.h +│ │ │ ├── multibox.cpp +│ │ │ ├── multibox.h +│ │ │ ├── slider.cpp +│ │ │ └── slider.h +│ │ └── element.h +│ ├── input +│ │ ├── input.cpp +│ │ └── input.h +│ ├── menu +│ │ ├── menu_v2.cpp +│ │ └── menu_v2.h +│ └── setup +│ ├── settings.h +│ ├── setup — копия.cpp +│ └── setup.cpp +├── menu.cpp +├── menu.hpp +├── menu_icons.hpp +├── misc.cpp +├── misc.hpp +├── misc_hooks.cpp +├── movement.cpp +├── movement.hpp +├── music_player.cpp +├── music_player.hpp +├── open this cutie.sln +├── open this cutie.vcxproj +├── open this cutie.vcxproj.user +├── optional.hpp +├── os.hpp +├── overrideview.cpp +├── paint.cpp +├── parser.cpp +├── parser.hpp +├── player.cpp +├── player.hpp +├── prediction.cpp +├── prediction.hpp +├── prediction_hooks.cpp +├── print.cpp +├── print.hpp +├── prop_manager.cpp +├── prop_manager.hpp +├── qangle.cpp +├── qangle.hpp +├── rage_aimbot.cpp +├── rage_aimbot.hpp +├── ray_tracer.cpp +├── ray_tracer.hpp +├── rendering.cpp +├── rendering.hpp +├── resolver.cpp +├── resolver.hpp +├── scan.cpp +├── scan.hpp +├── screenshot_sound.hpp +├── sdk.cpp +├── sdk.hpp +├── server_lag_comp.cpp +├── server_lag_comp.hpp +├── singleton.hpp +├── sound_parser.cpp +├── sound_parser.hpp +├── source — копия.cpp +├── source.cpp +├── source.hpp +├── threading +│ ├── MinHook.h +│ ├── atomic_lock.cpp +│ ├── atomic_lock.h +│ ├── mutex.cpp +│ ├── mutex.h +│ ├── packed_heap.cpp +│ ├── packed_heap.h +│ ├── semaphores.cpp +│ ├── semaphores.h +│ ├── shared_mutex.cpp +│ ├── shared_mutex.h +│ ├── threading.cpp +│ └── threading.h +├── usercmd.cpp +├── usercmd.hpp +├── vcall.hpp +├── vdf_parser.cpp +├── vdf_parser.hpp +├── vector.cpp +├── vector.hpp +├── vector2d.cpp +├── vector2d.hpp +├── vector4d.cpp +├── vector4d.hpp +├── visitor.hpp +├── visuals.cpp +├── visuals.hpp +├── vmpsdk.h +├── vmt_swap.hpp +├── weapon.cpp +├── weapon.hpp +├── weather_controller.cpp +├── weather_controller.hpp +└── wndproc.cpp + +``` + +`CUtlMemory.hpp`: + +```hpp +#pragma once + +#include +//#include "platform.hpp" + +template< class T, class I = int > +class CUtlMemory +{ +public: + // constructor, destructor + CUtlMemory( int nGrowSize = 0, int nInitSize = 0 ); + CUtlMemory( T* pMemory, int numElements ); + CUtlMemory( const T* pMemory, int numElements ); + ~CUtlMemory(); + + // Set the size by which the memory grows + void Init( int nGrowSize = 0, int nInitSize = 0 ); + + class Iterator_t + { + public: + Iterator_t( I i ) : index( i ) {} + I index; + + bool operator==( const Iterator_t it ) const { return index == it.index; } + bool operator!=( const Iterator_t it ) const { return index != it.index; } + }; + Iterator_t First() const { return Iterator_t( IsIdxValid( 0 ) ? 0 : InvalidIndex() ); } + Iterator_t Next( const Iterator_t &it ) const { return Iterator_t( IsIdxValid( it.index + 1 ) ? it.index + 1 : InvalidIndex() ); } + I GetIndex( const Iterator_t &it ) const { return it.index; } + bool IsIdxAfter( I i, const Iterator_t &it ) const { return i > it.index; } + bool IsValidIterator( const Iterator_t &it ) const { return IsIdxValid( it.index ); } + Iterator_t InvalidIterator() const { return Iterator_t( InvalidIndex() ); } + + // element access + T& operator[]( I i ); + const T& operator[]( I i ) const; + T& Element( I i ); + const T& Element( I i ) const; + + // Can we use this index? + bool IsIdxValid( I i ) const; + + // Specify the invalid ('null') index that we'll only return on failure + static const I INVALID_INDEX = ( I )-1; // For use with COMPILE_TIME_ASSERT + static I InvalidIndex() { return INVALID_INDEX; } + + // Gets the base address (can change when adding elements!) + T* Base(); + const T* Base() const; + + // Attaches the buffer to external memory.... + void SetExternalBuffer( T* pMemory, int numElements ); + void SetExternalBuffer( const T* pMemory, int numElements ); + void AssumeMemory( T *pMemory, int nSize ); + T* Detach(); + void *DetachMemory(); + + // Fast swap + void Swap( CUtlMemory< T, I > &mem ); + + // Switches the buffer from an external memory buffer to a reallocatable buffer + // Will copy the current contents of the external buffer to the reallocatable buffer + void ConvertToGrowableMemory( int nGrowSize ); + + // Size + int NumAllocated() const; + int Count() const; + + // Grows the memory, so that at least allocated + num elements are allocated + void Grow( int num = 1 ); + + // Makes sure we've got at least this much memory + void EnsureCapacity( int num ); + + // Memory deallocation + void Purge(); + + // Purge all but the given number of elements + void Purge( int numElements ); + + // is the memory externally allocated? + bool IsExternallyAllocated() const; + + // is the memory read only? + bool IsReadOnly() const; + + // Set the size by which the memory grows + void SetGrowSize( int size ); + +protected: + void ValidateGrowSize() + { +#ifdef _X360 + if ( m_nGrowSize && m_nGrowSize != EXTERNAL_BUFFER_MARKER ) + { + // Max grow size at 128 bytes on XBOX + const int MAX_GROW = 128; + if ( m_nGrowSize * sizeof(T) > MAX_GROW ) + { + m_nGrowSize = max( 1, MAX_GROW / sizeof(T) ); + } + } +#endif + } + + enum + { + EXTERNAL_BUFFER_MARKER = -1, + EXTERNAL_CONST_BUFFER_MARKER = -2, + }; + + T* m_pMemory; + int m_nAllocationCount; + int m_nGrowSize; +}; + +//----------------------------------------------------------------------------- +// constructor, destructor +//----------------------------------------------------------------------------- + +template< class T, class I > +CUtlMemory::CUtlMemory(int nGrowSize, int nInitAllocationCount) : m_pMemory(0), +m_nAllocationCount(nInitAllocationCount), m_nGrowSize(nGrowSize) +{ + ValidateGrowSize(); + assert(nGrowSize >= 0); + if (m_nAllocationCount) { + m_pMemory = (T*)new unsigned char[m_nAllocationCount * sizeof(T)]; + //m_pMemory = (T*)malloc(m_nAllocationCount * sizeof(T)); + } +} + +template< class T, class I > +CUtlMemory::CUtlMemory(T* pMemory, int numElements) : m_pMemory(pMemory), +m_nAllocationCount(numElements) +{ + // Special marker indicating externally supplied modifyable memory + m_nGrowSize = EXTERNAL_BUFFER_MARKER; +} + +template< class T, class I > +CUtlMemory::CUtlMemory(const T* pMemory, int numElements) : m_pMemory((T*)pMemory), +m_nAllocationCount(numElements) +{ + // Special marker indicating externally supplied modifyable memory + m_nGrowSize = EXTERNAL_CONST_BUFFER_MARKER; +} + +template< class T, class I > +CUtlMemory::~CUtlMemory() +{ + Purge(); +} + +template< class T, class I > +void CUtlMemory::Init(int nGrowSize /*= 0*/, int nInitSize /*= 0*/) +{ + Purge(); + + m_nGrowSize = nGrowSize; + m_nAllocationCount = nInitSize; + ValidateGrowSize(); + assert(nGrowSize >= 0); + if (m_nAllocationCount) { + m_pMemory = (T*)malloc(m_nAllocationCount * sizeof(T)); + } +} + +//----------------------------------------------------------------------------- +// Fast swap +//----------------------------------------------------------------------------- +template< class T, class I > +void CUtlMemory::Swap(CUtlMemory& mem) +{ + V_swap(m_nGrowSize, mem.m_nGrowSize); + V_swap(m_pMemory, mem.m_pMemory); + V_swap(m_nAllocationCount, mem.m_nAllocationCount); +} + + +//----------------------------------------------------------------------------- +// Switches the buffer from an external memory buffer to a reallocatable buffer +//----------------------------------------------------------------------------- +template< class T, class I > +void CUtlMemory::ConvertToGrowableMemory(int nGrowSize) +{ + if (!IsExternallyAllocated()) + return; + + m_nGrowSize = nGrowSize; + if (m_nAllocationCount) { + int nNumBytes = m_nAllocationCount * sizeof(T); + T* pMemory = (T*)malloc(nNumBytes); + memcpy(pMemory, m_pMemory, nNumBytes); + m_pMemory = pMemory; + } + else { + m_pMemory = NULL; + } +} + + +//----------------------------------------------------------------------------- +// Attaches the buffer to external memory.... +//----------------------------------------------------------------------------- +template< class T, class I > +void CUtlMemory::SetExternalBuffer(T* pMemory, int numElements) +{ + // Blow away any existing allocated memory + Purge(); + + m_pMemory = pMemory; + m_nAllocationCount = numElements; + + // Indicate that we don't own the memory + m_nGrowSize = EXTERNAL_BUFFER_MARKER; +} + +template< class T, class I > +void CUtlMemory::SetExternalBuffer(const T* pMemory, int numElements) +{ + // Blow away any existing allocated memory + Purge(); + + m_pMemory = const_cast(pMemory); + m_nAllocationCount = numElements; + + // Indicate that we don't own the memory + m_nGrowSize = EXTERNAL_CONST_BUFFER_MARKER; +} + +template< class T, class I > +void CUtlMemory::AssumeMemory(T* pMemory, int numElements) +{ + // Blow away any existing allocated memory + Purge(); + + // Simply take the pointer but don't mark us as external + m_pMemory = pMemory; + m_nAllocationCount = numElements; +} + +template< class T, class I > +void* CUtlMemory::DetachMemory() +{ + if (IsExternallyAllocated()) + return NULL; + + void* pMemory = m_pMemory; + m_pMemory = 0; + m_nAllocationCount = 0; + return pMemory; +} + +template< class T, class I > +inline T* CUtlMemory::Detach() +{ + return (T*)DetachMemory(); +} + + +//----------------------------------------------------------------------------- +// element access +//----------------------------------------------------------------------------- +template< class T, class I > +inline T& CUtlMemory::operator[](I i) +{ + assert(!IsReadOnly()); + assert(IsIdxValid(i)); + return m_pMemory[i]; +} + +template< class T, class I > +inline const T& CUtlMemory::operator[](I i) const +{ + assert(IsIdxValid(i)); + return m_pMemory[i]; +} + +template< class T, class I > +inline T& CUtlMemory::Element(I i) +{ + assert(!IsReadOnly()); + assert(IsIdxValid(i)); + return m_pMemory[i]; +} + +template< class T, class I > +inline const T& CUtlMemory::Element(I i) const +{ + assert(IsIdxValid(i)); + return m_pMemory[i]; +} + + +//----------------------------------------------------------------------------- +// is the memory externally allocated? +//----------------------------------------------------------------------------- +template< class T, class I > +bool CUtlMemory::IsExternallyAllocated() const +{ + return (m_nGrowSize < 0); +} + + +//----------------------------------------------------------------------------- +// is the memory read only? +//----------------------------------------------------------------------------- +template< class T, class I > +bool CUtlMemory::IsReadOnly() const +{ + return (m_nGrowSize == EXTERNAL_CONST_BUFFER_MARKER); +} + + +template< class T, class I > +void CUtlMemory::SetGrowSize(int nSize) +{ + assert(!IsExternallyAllocated()); + assert(nSize >= 0); + m_nGrowSize = nSize; + ValidateGrowSize(); +} + + +//----------------------------------------------------------------------------- +// Gets the base address (can change when adding elements!) +//----------------------------------------------------------------------------- +template< class T, class I > +inline T* CUtlMemory::Base() +{ + assert(!IsReadOnly()); + return m_pMemory; +} + +template< class T, class I > +inline const T* CUtlMemory::Base() const +{ + return m_pMemory; +} + + +//----------------------------------------------------------------------------- +// Size +//----------------------------------------------------------------------------- +template< class T, class I > +inline int CUtlMemory::NumAllocated() const +{ + return m_nAllocationCount; +} + +template< class T, class I > +inline int CUtlMemory::Count() const +{ + return m_nAllocationCount; +} + + +//----------------------------------------------------------------------------- +// Is element index valid? +//----------------------------------------------------------------------------- +template< class T, class I > +inline bool CUtlMemory::IsIdxValid(I i) const +{ + // GCC warns if I is an unsigned type and we do a ">= 0" against it (since the comparison is always 0). + // We Get the warning even if we cast inside the expression. It only goes away if we assign to another variable. + long x = i; + return (x >= 0) && (x < m_nAllocationCount); +} + +//----------------------------------------------------------------------------- +// Grows the memory +//----------------------------------------------------------------------------- +inline int UtlMemory_CalcNewAllocationCount(int nAllocationCount, int nGrowSize, int nNewSize, int nBytesItem) +{ + if (nGrowSize) { + nAllocationCount = ((1 + ((nNewSize - 1) / nGrowSize)) * nGrowSize); + } + else { + if (!nAllocationCount) { + // Compute an allocation which is at least as big as a cache line... + nAllocationCount = (31 + nBytesItem) / nBytesItem; + } + + while (nAllocationCount < nNewSize) { +#ifndef _X360 + nAllocationCount *= 2; +#else + int nNewAllocationCount = (nAllocationCount * 9) / 8; // 12.5 % + if (nNewAllocationCount > nAllocationCount) + nAllocationCount = nNewAllocationCount; + else + nAllocationCount *= 2; +#endif + } + } + + return nAllocationCount; +} + +template< class T, class I > +void CUtlMemory::Grow(int num) +{ + assert(num > 0); + + if (IsExternallyAllocated()) { + // Can't grow a buffer whose memory was externally allocated + assert(0); + return; + } + + + auto oldAllocationCount = m_nAllocationCount; + // Make sure we have at least numallocated + num allocations. + // Use the grow rules specified for this memory (in m_nGrowSize) + int nAllocationRequested = m_nAllocationCount + num; + + int nNewAllocationCount = UtlMemory_CalcNewAllocationCount(m_nAllocationCount, m_nGrowSize, nAllocationRequested, sizeof(T)); + + // if m_nAllocationRequested wraps index type I, recalculate + if ((int)(I)nNewAllocationCount < nAllocationRequested) { + if ((int)(I)nNewAllocationCount == 0 && (int)(I)(nNewAllocationCount - 1) >= nAllocationRequested) { + --nNewAllocationCount; // deal w/ the common case of m_nAllocationCount == MAX_USHORT + 1 + } + else { + if ((int)(I)nAllocationRequested != nAllocationRequested) { + // we've been asked to grow memory to a size s.t. the index type can't address the requested amount of memory + assert(0); + return; + } + while ((int)(I)nNewAllocationCount < nAllocationRequested) { + nNewAllocationCount = (nNewAllocationCount + nAllocationRequested) / 2; + } + } + } + + m_nAllocationCount = nNewAllocationCount; + + if (m_pMemory) { + auto ptr = new unsigned char[m_nAllocationCount * sizeof(T)]; + + memcpy(ptr, m_pMemory, oldAllocationCount * sizeof(T)); + m_pMemory = (T*)ptr; + } + else { + m_pMemory = (T*)new unsigned char[m_nAllocationCount * sizeof(T)]; + } +} + + +//----------------------------------------------------------------------------- +// Makes sure we've got at least this much memory +//----------------------------------------------------------------------------- +template< class T, class I > +inline void CUtlMemory::EnsureCapacity(int num) +{ + if (m_nAllocationCount >= num) + return; + + if (IsExternallyAllocated()) { + // Can't grow a buffer whose memory was externally allocated + assert(0); + return; + } + m_nAllocationCount = num; + + if (m_pMemory) { + m_pMemory = (T*)realloc(m_pMemory, m_nAllocationCount * sizeof(T)); + } + else { + m_pMemory = (T*)malloc(m_nAllocationCount * sizeof(T)); + } +} + + +//----------------------------------------------------------------------------- +// Memory deallocation +//----------------------------------------------------------------------------- +template< class T, class I > +void CUtlMemory::Purge() +{ + if (!IsExternallyAllocated()) { + if (m_pMemory) { + //free((void*)m_pMemory); + + m_pMemory = 0; + } + m_nAllocationCount = 0; + } +} + +template< class T, class I > +void CUtlMemory::Purge(int numElements) +{ + assert(numElements >= 0); + + if (numElements > m_nAllocationCount) { + // Ensure this isn't a grow request in disguise. + assert(numElements <= m_nAllocationCount); + return; + } + + // If we have zero elements, simply do a purge: + if (numElements == 0) { + Purge(); + return; + } + + if (IsExternallyAllocated()) { + // Can't shrink a buffer whose memory was externally allocated, fail silently like purge + return; + } + + // If the number of elements is the same as the allocation count, we are done. + if (numElements == m_nAllocationCount) { + return; + } + + + if (!m_pMemory) { + // Allocation count is non zero, but memory is null. + assert(m_pMemory); + return; + } + m_nAllocationCount = numElements; + m_pMemory = (T*)realloc(m_pMemory, m_nAllocationCount * sizeof(T)); +} + +//----------------------------------------------------------------------------- +// The CUtlMemory class: +// A growable memory class which doubles in size by default. +//----------------------------------------------------------------------------- +template< class T, int nAlignment > +class CUtlMemoryAligned : public CUtlMemory +{ +public: + // constructor, destructor + CUtlMemoryAligned(int nGrowSize = 0, int nInitSize = 0); + CUtlMemoryAligned(T* pMemory, int numElements); + CUtlMemoryAligned(const T* pMemory, int numElements); + ~CUtlMemoryAligned(); + + // Attaches the buffer to external memory.... + void SetExternalBuffer(T* pMemory, int numElements); + void SetExternalBuffer(const T* pMemory, int numElements); + + // Grows the memory, so that at least allocated + num elements are allocated + void Grow(int num = 1); + + // Makes sure we've got at least this much memory + void EnsureCapacity(int num); + + // Memory deallocation + void Purge(); + + // Purge all but the given number of elements (NOT IMPLEMENTED IN CUtlMemoryAligned) + void Purge(int numElements) { assert(0); } + +private: + void* Align(const void* pAddr); +}; + + +//----------------------------------------------------------------------------- +// Aligns a pointer +//----------------------------------------------------------------------------- +template< class T, int nAlignment > +void* CUtlMemoryAligned::Align(const void* pAddr) +{ + size_t nAlignmentMask = nAlignment - 1; + return (void*)(((size_t)pAddr + nAlignmentMask) & (~nAlignmentMask)); +} + + +//----------------------------------------------------------------------------- +// constructor, destructor +//----------------------------------------------------------------------------- +template< class T, int nAlignment > +CUtlMemoryAligned::CUtlMemoryAligned(int nGrowSize, int nInitAllocationCount) +{ + CUtlMemory::m_pMemory = 0; + CUtlMemory::m_nAllocationCount = nInitAllocationCount; + CUtlMemory::m_nGrowSize = nGrowSize; + this->ValidateGrowSize(); + + // Alignment must be a power of two + COMPILE_TIME_ASSERT((nAlignment & (nAlignment - 1)) == 0); + assert((nGrowSize >= 0) && (nGrowSize != CUtlMemory::EXTERNAL_BUFFER_MARKER)); + if (CUtlMemory::m_nAllocationCount) { + CUtlMemory::m_pMemory = (T*)_aligned_malloc(nInitAllocationCount * sizeof(T), nAlignment); + } +} + +template< class T, int nAlignment > +CUtlMemoryAligned::CUtlMemoryAligned(T* pMemory, int numElements) +{ + // Special marker indicating externally supplied memory + CUtlMemory::m_nGrowSize = CUtlMemory::EXTERNAL_BUFFER_MARKER; + + CUtlMemory::m_pMemory = (T*)Align(pMemory); + CUtlMemory::m_nAllocationCount = ((int)(pMemory + numElements) - (int)CUtlMemory::m_pMemory) / sizeof(T); +} + +template< class T, int nAlignment > +CUtlMemoryAligned::CUtlMemoryAligned(const T* pMemory, int numElements) +{ + // Special marker indicating externally supplied memory + CUtlMemory::m_nGrowSize = CUtlMemory::EXTERNAL_CONST_BUFFER_MARKER; + + CUtlMemory::m_pMemory = (T*)Align(pMemory); + CUtlMemory::m_nAllocationCount = ((int)(pMemory + numElements) - (int)CUtlMemory::m_pMemory) / sizeof(T); +} + +template< class T, int nAlignment > +CUtlMemoryAligned::~CUtlMemoryAligned() +{ + Purge(); +} + + +//----------------------------------------------------------------------------- +// Attaches the buffer to external memory.... +//----------------------------------------------------------------------------- +template< class T, int nAlignment > +void CUtlMemoryAligned::SetExternalBuffer(T* pMemory, int numElements) +{ + // Blow away any existing allocated memory + Purge(); + + CUtlMemory::m_pMemory = (T*)Align(pMemory); + CUtlMemory::m_nAllocationCount = ((int)(pMemory + numElements) - (int)CUtlMemory::m_pMemory) / sizeof(T); + + // Indicate that we don't own the memory + CUtlMemory::m_nGrowSize = CUtlMemory::EXTERNAL_BUFFER_MARKER; +} + +template< class T, int nAlignment > +void CUtlMemoryAligned::SetExternalBuffer(const T* pMemory, int numElements) +{ + // Blow away any existing allocated memory + Purge(); + + CUtlMemory::m_pMemory = (T*)Align(pMemory); + CUtlMemory::m_nAllocationCount = ((int)(pMemory + numElements) - (int)CUtlMemory::m_pMemory) / sizeof(T); + + // Indicate that we don't own the memory + CUtlMemory::m_nGrowSize = CUtlMemory::EXTERNAL_CONST_BUFFER_MARKER; +} + + +//----------------------------------------------------------------------------- +// Grows the memory +//----------------------------------------------------------------------------- +template< class T, int nAlignment > +void CUtlMemoryAligned::Grow(int num) +{ + assert(num > 0); + + if (this->IsExternallyAllocated()) { + // Can't grow a buffer whose memory was externally allocated + assert(0); + return; + } + + + + // Make sure we have at least numallocated + num allocations. + // Use the grow rules specified for this memory (in m_nGrowSize) + int nAllocationRequested = CUtlMemory::m_nAllocationCount + num; + + CUtlMemory::m_nAllocationCount = UtlMemory_CalcNewAllocationCount(CUtlMemory::m_nAllocationCount, CUtlMemory::m_nGrowSize, nAllocationRequested, sizeof(T)); + + + + if (CUtlMemory::m_pMemory) { + CUtlMemory::m_pMemory = (T*)MemAlloc_ReallocAligned(CUtlMemory::m_pMemory, CUtlMemory::m_nAllocationCount * sizeof(T), nAlignment); + assert(CUtlMemory::m_pMemory); + } + else { + CUtlMemory::m_pMemory = (T*)MemAlloc_AllocAligned(CUtlMemory::m_nAllocationCount * sizeof(T), nAlignment); + assert(CUtlMemory::m_pMemory); + } +} + + +//----------------------------------------------------------------------------- +// Makes sure we've got at least this much memory +//----------------------------------------------------------------------------- +template< class T, int nAlignment > +inline void CUtlMemoryAligned::EnsureCapacity(int num) +{ + if (CUtlMemory::m_nAllocationCount >= num) + return; + + if (this->IsExternallyAllocated()) { + // Can't grow a buffer whose memory was externally allocated + assert(0); + return; + } + + + + CUtlMemory::m_nAllocationCount = num; + + + + if (CUtlMemory::m_pMemory) { + CUtlMemory::m_pMemory = (T*)MemAlloc_ReallocAligned(CUtlMemory::m_pMemory, CUtlMemory::m_nAllocationCount * sizeof(T), nAlignment); + } + else { + CUtlMemory::m_pMemory = (T*)MemAlloc_AllocAligned(CUtlMemory::m_nAllocationCount * sizeof(T), nAlignment); + } +} + + +//----------------------------------------------------------------------------- +// Memory deallocation +//----------------------------------------------------------------------------- +template< class T, int nAlignment > +void CUtlMemoryAligned::Purge() +{ + if (!this->IsExternallyAllocated()) { + if (CUtlMemory::m_pMemory) { + + MemAlloc_FreeAligned(CUtlMemory::m_pMemory); + CUtlMemory::m_pMemory = 0; + } + CUtlMemory::m_nAllocationCount = 0; + } +} +``` + +`CUtlString.cpp`: + +```cpp + +#define NOMINMAX +#include +#include +#include "CUtlString.hpp" + +//----------------------------------------------------------------------------- +// Base class, containing simple memory management +//----------------------------------------------------------------------------- +CUtlBinaryBlock::CUtlBinaryBlock(int growSize, int initSize) : m_Memory(growSize, initSize) +{ + m_nActualLength = 0; +} + +CUtlBinaryBlock::CUtlBinaryBlock(void* pMemory, int nSizeInBytes, int nInitialLength) : m_Memory((unsigned char*)pMemory, nSizeInBytes) +{ + m_nActualLength = nInitialLength; +} + +CUtlBinaryBlock::CUtlBinaryBlock(const void* pMemory, int nSizeInBytes) : m_Memory((const unsigned char*)pMemory, nSizeInBytes) +{ + m_nActualLength = nSizeInBytes; +} + +CUtlBinaryBlock::CUtlBinaryBlock(const CUtlBinaryBlock& src) +{ + Set(src.Get(), src.Length()); +} + +void CUtlBinaryBlock::Get(void* pValue, int nLen) const +{ + assert(nLen > 0); + if (m_nActualLength < nLen) { + nLen = m_nActualLength; + } + + if (nLen > 0) { + memcpy(pValue, m_Memory.Base(), nLen); + } +} + +void CUtlBinaryBlock::SetLength(int nLength) +{ + assert(!m_Memory.IsReadOnly()); + + m_nActualLength = nLength; + if (nLength > m_Memory.NumAllocated()) { + int nOverFlow = nLength - m_Memory.NumAllocated(); + m_Memory.Grow(nOverFlow); + + // If the reallocation failed, clamp length + if (nLength > m_Memory.NumAllocated()) { + m_nActualLength = m_Memory.NumAllocated(); + } + } + +#ifdef _DEBUG + if (m_Memory.NumAllocated() > m_nActualLength) { + memset(((char*)m_Memory.Base()) + m_nActualLength, 0xEB, m_Memory.NumAllocated() - m_nActualLength); + } +#endif +} + +void CUtlBinaryBlock::Set(const void* pValue, int nLen) +{ + assert(!m_Memory.IsReadOnly()); + + if (!pValue) { + nLen = 0; + } + + SetLength(nLen); + + if (m_nActualLength) { + if (((const char*)m_Memory.Base()) >= ((const char*)pValue) + nLen || + ((const char*)m_Memory.Base()) + m_nActualLength <= ((const char*)pValue)) { + memcpy(m_Memory.Base(), pValue, m_nActualLength); + } + else { + memmove(m_Memory.Base(), pValue, m_nActualLength); + } + } +} + + +CUtlBinaryBlock& CUtlBinaryBlock::operator=(const CUtlBinaryBlock& src) +{ + assert(!m_Memory.IsReadOnly()); + Set(src.Get(), src.Length()); + return *this; +} + + +bool CUtlBinaryBlock::operator==(const CUtlBinaryBlock& src) const +{ + if (src.Length() != Length()) + return false; + + return !memcmp(src.Get(), Get(), Length()); +} + + +//----------------------------------------------------------------------------- +// Simple string class. +//----------------------------------------------------------------------------- +CUtlString::CUtlString() +{ +} + +CUtlString::CUtlString(const char* pString) +{ + Set(pString); +} + +CUtlString::CUtlString(const CUtlString& string) +{ + Set(string.Get()); +} + +// Attaches the string to external memory. Useful for avoiding a copy +CUtlString::CUtlString(void* pMemory, int nSizeInBytes, int nInitialLength) : m_Storage(pMemory, nSizeInBytes, nInitialLength) +{ +} + +CUtlString::CUtlString(const void* pMemory, int nSizeInBytes) : m_Storage(pMemory, nSizeInBytes) +{ +} + +void CUtlString::Set(const char* pValue) +{ + assert(!m_Storage.IsReadOnly()); + int nLen = pValue ? strlen(pValue) + 1 : 0; + m_Storage.Set(pValue, nLen); +} + +// Returns strlen +int CUtlString::Length() const +{ + return m_Storage.Length() ? m_Storage.Length() - 1 : 0; +} + +// Sets the length (used to serialize into the buffer ) +void CUtlString::SetLength(int nLen) +{ + assert(!m_Storage.IsReadOnly()); + + // Add 1 to account for the NULL + m_Storage.SetLength(nLen > 0 ? nLen + 1 : 0); +} + +const char* CUtlString::Get() const +{ + if (m_Storage.Length() == 0) { + return ""; + } + + return reinterpret_cast(m_Storage.Get()); +} + +// Converts to c-strings +CUtlString::operator const char* () const +{ + return Get(); +} + +char* CUtlString::Get() +{ + assert(!m_Storage.IsReadOnly()); + + if (m_Storage.Length() == 0) { + // In general, we optimise away small mallocs for empty strings + // but if you ask for the non-const bytes, they must be writable + // so we can't return "" here, like we do for the const version - jd + m_Storage.SetLength(1); + m_Storage[0] = '\0'; + } + + return reinterpret_cast(m_Storage.Get()); +} + +CUtlString& CUtlString::operator=(const CUtlString& src) +{ + assert(!m_Storage.IsReadOnly()); + m_Storage = src.m_Storage; + return *this; +} + +CUtlString& CUtlString::operator=(const char* src) +{ + assert(!m_Storage.IsReadOnly()); + Set(src); + return *this; +} + +bool CUtlString::operator==(const CUtlString& src) const +{ + return m_Storage == src.m_Storage; +} + +bool CUtlString::operator==(const char* src) const +{ + return (strcmp(Get(), src) == 0); +} + +CUtlString& CUtlString::operator+=(const CUtlString& rhs) +{ + assert(!m_Storage.IsReadOnly()); + + const int lhsLength(Length()); + const int rhsLength(rhs.Length()); + const int requestedLength(lhsLength + rhsLength); + + SetLength(requestedLength); + const int allocatedLength(Length()); + const int copyLength(allocatedLength - lhsLength < rhsLength ? allocatedLength - lhsLength : rhsLength); + memcpy(Get() + lhsLength, rhs.Get(), copyLength); + m_Storage[allocatedLength] = '\0'; + + return *this; +} + +CUtlString& CUtlString::operator+=(const char* rhs) +{ + assert(!m_Storage.IsReadOnly()); + + const int lhsLength(Length()); + const int rhsLength(strlen(rhs)); + const int requestedLength(lhsLength + rhsLength); + + SetLength(requestedLength); + const int allocatedLength(Length()); + const int copyLength(allocatedLength - lhsLength < rhsLength ? allocatedLength - lhsLength : rhsLength); + memcpy(Get() + lhsLength, rhs, copyLength); + m_Storage[allocatedLength] = '\0'; + + return *this; +} + +CUtlString& CUtlString::operator+=(char c) +{ + assert(!m_Storage.IsReadOnly()); + + int nLength = Length(); + SetLength(nLength + 1); + m_Storage[nLength] = c; + m_Storage[nLength + 1] = '\0'; + return *this; +} + +CUtlString& CUtlString::operator+=(int rhs) +{ + assert(!m_Storage.IsReadOnly()); + assert(sizeof(rhs) == 4); + + char tmpBuf[12]; // Sufficient for a signed 32 bit integer [ -2147483648 to +2147483647 ] + snprintf(tmpBuf, sizeof(tmpBuf), "%d", rhs); + tmpBuf[sizeof(tmpBuf) - 1] = '\0'; + + return operator+=(tmpBuf); +} + +CUtlString& CUtlString::operator+=(double rhs) +{ + assert(!m_Storage.IsReadOnly()); + + char tmpBuf[256]; // How big can doubles be??? Dunno. + snprintf(tmpBuf, sizeof(tmpBuf), "%lg", rhs); + tmpBuf[sizeof(tmpBuf) - 1] = '\0'; + + return operator+=(tmpBuf); +} + +int CUtlString::Format(const char* pFormat, ...) +{ + assert(!m_Storage.IsReadOnly()); + + char tmpBuf[4096]; //< Nice big 4k buffer, as much memory as my first computer had, a Radio Shack Color Computer + + va_list marker; + + va_start(marker, pFormat); + int len = _vsnprintf_s(tmpBuf, 4096, sizeof(tmpBuf) - 1, pFormat, marker); + va_end(marker); + + // Len < 0 represents an overflow + if (len < 0) { + len = sizeof(tmpBuf) - 1; + tmpBuf[sizeof(tmpBuf) - 1] = 0; + } + + Set(tmpBuf); + + return len; +} + +//----------------------------------------------------------------------------- +// Strips the trailing slash +//----------------------------------------------------------------------------- +void CUtlString::StripTrailingSlash() +{ + if (IsEmpty()) + return; + + int nLastChar = Length() - 1; + char c = m_Storage[nLastChar]; + if (c == '\\' || c == '/') { + m_Storage[nLastChar] = 0; + m_Storage.SetLength(m_Storage.Length() - 1); + } +} +``` + +`CUtlString.hpp`: + +```hpp +#pragma once + +#include +#include + +#include "CUtlMemory.hpp" + +class CUtlBinaryBlock +{ +public: + CUtlBinaryBlock(int growSize = 0, int initSize = 0); + + // NOTE: nInitialLength indicates how much of the buffer starts full + CUtlBinaryBlock(void* pMemory, int nSizeInBytes, int nInitialLength); + CUtlBinaryBlock(const void* pMemory, int nSizeInBytes); + CUtlBinaryBlock(const CUtlBinaryBlock& src); + + void Get(void* pValue, int nMaxLen) const; + void Set(const void* pValue, int nLen); + const void* Get() const; + void* Get(); + + unsigned char& operator[](int i); + const unsigned char& operator[](int i) const; + + int Length() const; + void SetLength(int nLength); // Undefined memory will result + bool IsEmpty() const; + void Clear(); + void Purge(); + + bool IsReadOnly() const; + + CUtlBinaryBlock& operator=(const CUtlBinaryBlock& src); + + // Test for equality + bool operator==(const CUtlBinaryBlock& src) const; + +private: + CUtlMemory m_Memory; + int m_nActualLength; +}; + + +//----------------------------------------------------------------------------- +// class inlines +//----------------------------------------------------------------------------- +inline const void* CUtlBinaryBlock::Get() const +{ + return m_Memory.Base(); +} + +inline void* CUtlBinaryBlock::Get() +{ + return m_Memory.Base(); +} + +inline int CUtlBinaryBlock::Length() const +{ + return m_nActualLength; +} + +inline unsigned char& CUtlBinaryBlock::operator[](int i) +{ + return m_Memory[i]; +} + +inline const unsigned char& CUtlBinaryBlock::operator[](int i) const +{ + return m_Memory[i]; +} + +inline bool CUtlBinaryBlock::IsReadOnly() const +{ + return m_Memory.IsReadOnly(); +} + +inline bool CUtlBinaryBlock::IsEmpty() const +{ + return Length() == 0; +} + +inline void CUtlBinaryBlock::Clear() +{ + SetLength(0); +} + +inline void CUtlBinaryBlock::Purge() +{ + SetLength(0); + m_Memory.Purge(); +} + +//----------------------------------------------------------------------------- +// Simple string class. +// NOTE: This is *not* optimal! Use in tools, but not runtime code +//----------------------------------------------------------------------------- +class CUtlString +{ +public: + CUtlString(); + CUtlString(const char* pString); + CUtlString(const CUtlString& string); + + // Attaches the string to external memory. Useful for avoiding a copy + CUtlString(void* pMemory, int nSizeInBytes, int nInitialLength); + CUtlString(const void* pMemory, int nSizeInBytes); + + const char* Get() const; + void Set(const char* pValue); + + // Set directly and don't look for a null terminator in pValue. + void SetDirect(const char* pValue, int nChars); + + // Converts to c-strings + operator const char* () const; + + // for compatibility switching items from UtlSymbol + const char* String() const { return Get(); } + + // Returns strlen + int Length() const; + bool IsEmpty() const; + + // Sets the length (used to serialize into the buffer ) + // Note: If nLen != 0, then this adds an extra uint8_t for a null-terminator. + void SetLength(int nLen); + char* Get(); + void Clear(); + void Purge(); + + // Strips the trailing slash + void StripTrailingSlash(); + + CUtlString& operator=(const CUtlString& src); + CUtlString& operator=(const char* src); + + // Test for equality + bool operator==(const CUtlString& src) const; + bool operator==(const char* src) const; + bool operator!=(const CUtlString& src) const { return !operator==(src); } + bool operator!=(const char* src) const { return !operator==(src); } + + CUtlString& operator+=(const CUtlString& rhs); + CUtlString& operator+=(const char* rhs); + CUtlString& operator+=(char c); + CUtlString& operator+=(int rhs); + CUtlString& operator+=(double rhs); + + CUtlString operator+(const char* pOther); + CUtlString operator+(int rhs); + + int Format(const char* pFormat, ...); + + // Take a piece out of the string. + // If you only specify nStart, it'll go from nStart to the end. + // You can use negative numbers and it'll wrap around to the start. + CUtlString Slice(int32_t nStart = 0, int32_t nEnd = INT32_MAX); + + // Grab a substring starting from the left or the right side. + CUtlString Left(int32_t nChars); + CUtlString Right(int32_t nChars); + + // Replace all instances of one character with another. + CUtlString Replace(char cFrom, char cTo); + + // Calls right through to V_MakeAbsolutePath. + CUtlString AbsPath(const char* pStartingDir = NULL); + + // Gets the filename (everything except the path.. c:\a\b\c\somefile.txt -> somefile.txt). + CUtlString UnqualifiedFilename(); + + // Strips off one directory. Uses V_StripLastDir but strips the last slash also! + CUtlString DirName(); + + // Works like V_ComposeFileName. + static CUtlString PathJoin(const char* pStr1, const char* pStr2); + + // These can be used for utlvector sorts. + static int __cdecl SortCaseInsensitive(const CUtlString* pString1, const CUtlString* pString2); + static int __cdecl SortCaseSensitive(const CUtlString* pString1, const CUtlString* pString2); + +private: + CUtlBinaryBlock m_Storage; +}; + + +//----------------------------------------------------------------------------- +// Inline methods +//----------------------------------------------------------------------------- +inline bool CUtlString::IsEmpty() const +{ + return Length() == 0; +} + +inline int __cdecl CUtlString::SortCaseInsensitive(const CUtlString* pString1, const CUtlString* pString2) +{ + return _stricmp(pString1->String(), pString2->String()); +} + +inline int __cdecl CUtlString::SortCaseSensitive(const CUtlString* pString1, const CUtlString* pString2) +{ + return strcmp(pString1->String(), pString2->String()); +} +``` + +`CUtlVector.hpp`: + +```hpp +#pragma once + +#include +#include "CUtlMemory.hpp" + +template< class T, class A = CUtlMemory > +class CUtlVector +{ + typedef T* iterator; + typedef const T* const_iterator; + typedef A CAllocator; +public: + typedef T ElemType_t; + + // constructor, destructor + CUtlVector(int growSize = 0, int initSize = 0); + CUtlVector(T* pMemory, int allocationCount, int numElements = 0); + ~CUtlVector(); + + // Copy the array. + CUtlVector& operator=(const CUtlVector& other); + + // element access + T& operator[](int i); + const T& operator[](int i) const; + T& Element(int i); + const T& Element(int i) const; + T& Head(); + const T& Head() const; + T& Tail(); + const T& Tail() const; + + // Gets the base address (can change when adding elements!) + T* Base() { return m_Memory.Base(); } + const T* Base() const { return m_Memory.Base(); } + // Returns the number of elements in the vector + int Count() const; + // Is element index valid? + bool IsValidIndex(int i) const; + static int InvalidIndex(); + // Adds an element, uses default constructor + int AddToHead(); + int AddToTail(); + int InsertBefore(int elem); + int InsertAfter(int elem); + // Adds an element, uses copy constructor + int AddToHead(const T& src); + int AddToTail(const T& src); + int InsertBefore(int elem, const T& src); + int InsertAfter(int elem, const T& src); + // Adds multiple elements, uses default constructor + int AddMultipleToHead(int num); + int AddMultipleToTail(int num); + int AddMultipleToTail(int num, const T* pToCopy); + int InsertMultipleBefore(int elem, int num); + int InsertMultipleBefore(int elem, int num, const T* pToCopy); + int InsertMultipleAfter(int elem, int num); + // Calls RemoveAll() then AddMultipleToTail. + void SetSize(int size); + void SetCount(int count); + void SetCountNonDestructively(int count); //sets count by adding or removing elements to tail TODO: This should probably be the default behavior for SetCount + void CopyArray(const T* pArray, int size); //Calls SetSize and copies each element. + // Fast swap + void Swap(CUtlVector< T, A >& vec); + // Add the specified array to the tail. + int AddVectorToTail(CUtlVector const& src); + // Finds an element (element needs operator== defined) + int GetOffset(const T& src) const; + void FillWithValue(const T& src); + bool HasElement(const T& src) const; + // Makes sure we have enough memory allocated to store a requested # of elements + void EnsureCapacity(int num); + // Makes sure we have at least this many elements + void EnsureCount(int num); + // Element removal + void FastRemove(int elem); // doesn't preserve order + void Remove(int elem); // preserves order, shifts elements + bool Find(const T& src); + bool FindAndRemove(const T& src); // removes first occurrence of src, preserves order, shifts elements + bool FindAndFastRemove(const T& src); // removes first occurrence of src, doesn't preserve order + void RemoveMultiple(int elem, int num); // preserves order, shifts elements + void RemoveMultipleFromHead(int num); // removes num elements from tail + void RemoveMultipleFromTail(int num); // removes num elements from tail + void RemoveAll(); // doesn't deallocate memory + void Purge(); // Memory deallocation + // Purges the list and calls delete on each element in it. + void PurgeAndDeleteElements(); + // Compacts the vector to the number of elements actually in use + void Compact(); + // Set the size by which it grows when it needs to allocate more memory. + void SetGrowSize(int size) { m_Memory.SetGrowSize(size); } + int NumAllocated() const; // Only use this if you really know what you're doing! + void Sort(int(__cdecl* pfnCompare)(const T*, const T*)); + + iterator begin() { return Base(); } + const_iterator begin() const { return Base(); } + iterator end() { return Base() + Count(); } + const_iterator end() const { return Base() + Count(); } + +protected: + // Can't copy this unless we explicitly do it! + CUtlVector(CUtlVector const& vec) { assert(0); } + + // Grows the vector + void GrowVector(int num = 1); + + // Shifts elements.... + void ShiftElementsRight(int elem, int num = 1); + void ShiftElementsLeft(int elem, int num = 1); + +public: + CAllocator m_Memory; + int m_Size; + + // For easier access to the elements through the debugger + // it's in release builds so this can be used in libraries correctly + T* m_pElements; + + inline void ResetDbgInfo() + { + m_pElements = Base(); + } +}; + + +template +inline T* CopyConstruct(T* pMemory, T const& src) +{ + return ::new(pMemory) T(src); +} + +//----------------------------------------------------------------------------- +// constructor, destructor +//----------------------------------------------------------------------------- +template< typename T, class A > +inline CUtlVector::CUtlVector(int growSize, int initSize) : + m_Memory(growSize, initSize), m_Size(0) +{ + ResetDbgInfo(); +} + +template +inline T* Construct(T* pMemory) +{ + return ::new(pMemory) T; +} + +template< typename T, class A > +inline CUtlVector::CUtlVector(T* pMemory, int allocationCount, int numElements) : + m_Memory(pMemory, allocationCount), m_Size(numElements) +{ + ResetDbgInfo(); +} + +template< typename T, class A > +inline CUtlVector::~CUtlVector() +{ + Purge(); +} + +template< typename T, class A > +inline CUtlVector& CUtlVector::operator=(const CUtlVector& other) +{ + int nCount = other.Count(); + SetSize(nCount); + for (int i = 0; i < nCount; i++) { + (*this)[i] = other[i]; + } + return *this; +} + + +//----------------------------------------------------------------------------- +// element access +//----------------------------------------------------------------------------- +template< typename T, class A > +inline T& CUtlVector::operator[](int i) +{ + assert(i < m_Size); + return m_Memory[i]; +} + +template< typename T, class A > +inline const T& CUtlVector::operator[](int i) const +{ + assert(i < m_Size); + return m_Memory[i]; +} + +template< typename T, class A > +inline T& CUtlVector::Element(int i) +{ + assert(i < m_Size); + return m_Memory[i]; +} + +template< typename T, class A > +inline const T& CUtlVector::Element(int i) const +{ + assert(i < m_Size); + return m_Memory[i]; +} + +template< typename T, class A > +inline T& CUtlVector::Head() +{ + assert(m_Size > 0); + return m_Memory[0]; +} + +template< typename T, class A > +inline const T& CUtlVector::Head() const +{ + assert(m_Size > 0); + return m_Memory[0]; +} + +template< typename T, class A > +inline T& CUtlVector::Tail() +{ + assert(m_Size > 0); + return m_Memory[m_Size - 1]; +} + +template< typename T, class A > +inline const T& CUtlVector::Tail() const +{ + assert(m_Size > 0); + return m_Memory[m_Size - 1]; +} + + +//----------------------------------------------------------------------------- +// Count +//----------------------------------------------------------------------------- +template< typename T, class A > +inline int CUtlVector::Count() const +{ + return m_Size; +} + + +//----------------------------------------------------------------------------- +// Is element index valid? +//----------------------------------------------------------------------------- +template< typename T, class A > +inline bool CUtlVector::IsValidIndex(int i) const +{ + return (i >= 0) && (i < m_Size); +} + + +//----------------------------------------------------------------------------- +// Returns in invalid index +//----------------------------------------------------------------------------- +template< typename T, class A > +inline int CUtlVector::InvalidIndex() +{ + return -1; +} + + +//----------------------------------------------------------------------------- +// Grows the vector +//----------------------------------------------------------------------------- +template< typename T, class A > +void CUtlVector::GrowVector(int num) +{ + if (m_Size + num > m_Memory.NumAllocated()) { + m_Memory.Grow(m_Size + num - m_Memory.NumAllocated()); + } + + m_Size += num; + ResetDbgInfo(); +} + + +//----------------------------------------------------------------------------- +// Sorts the vector +//----------------------------------------------------------------------------- +template< typename T, class A > +void CUtlVector::Sort(int(__cdecl* pfnCompare)(const T*, const T*)) +{ + typedef int(__cdecl * QSortCompareFunc_t)(const void*, const void*); + if (Count() <= 1) + return; + + if (Base()) { + qsort(Base(), Count(), sizeof(T), (QSortCompareFunc_t)(pfnCompare)); + } + else { + assert(0); + // this path is untested + // if you want to sort vectors that use a non-sequential memory allocator, + // you'll probably want to patch in a quicksort algorithm here + // I just threw in this bubble sort to have something just in case... + + for (int i = m_Size - 1; i >= 0; --i) { + for (int j = 1; j <= i; ++j) { + if (pfnCompare(&Element(j - 1), &Element(j)) < 0) { + V_swap(Element(j - 1), Element(j)); + } + } + } + } +} + +//----------------------------------------------------------------------------- +// Makes sure we have enough memory allocated to store a requested # of elements +//----------------------------------------------------------------------------- +template< typename T, class A > +void CUtlVector::EnsureCapacity(int num) +{ + m_Memory.EnsureCapacity(num); + ResetDbgInfo(); +} + + +//----------------------------------------------------------------------------- +// Makes sure we have at least this many elements +//----------------------------------------------------------------------------- +template< typename T, class A > +void CUtlVector::EnsureCount(int num) +{ + if (Count() < num) { + AddMultipleToTail(num - Count()); + } +} + + +//----------------------------------------------------------------------------- +// Shifts elements +//----------------------------------------------------------------------------- +template< typename T, class A > +void CUtlVector::ShiftElementsRight(int elem, int num) +{ + assert(IsValidIndex(elem) || (m_Size == 0) || (num == 0)); + int numToMove = m_Size - elem - num; + if ((numToMove > 0) && (num > 0)) + memmove(&Element(elem + num), &Element(elem), numToMove * sizeof(T)); +} + +template< typename T, class A > +void CUtlVector::ShiftElementsLeft(int elem, int num) +{ + assert(IsValidIndex(elem) || (m_Size == 0) || (num == 0)); + int numToMove = m_Size - elem - num; + if ((numToMove > 0) && (num > 0)) { + memmove(&Element(elem), &Element(elem + num), numToMove * sizeof(T)); + +#ifdef _DEBUG + memset(&Element(m_Size - num), 0xDD, num * sizeof(T)); +#endif + } +} + + +//----------------------------------------------------------------------------- +// Adds an element, uses default constructor +//----------------------------------------------------------------------------- +template< typename T, class A > +inline int CUtlVector::AddToHead() +{ + return InsertBefore(0); +} + +template< typename T, class A > +inline int CUtlVector::AddToTail() +{ + return InsertBefore(m_Size); +} + +template< typename T, class A > +inline int CUtlVector::InsertAfter(int elem) +{ + return InsertBefore(elem + 1); +} + +template< typename T, class A > +int CUtlVector::InsertBefore(int elem) +{ + // Can insert at the end + assert((elem == Count()) || IsValidIndex(elem)); + + GrowVector(); + ShiftElementsRight(elem); + Construct(&Element(elem)); + return elem; +} + + +//----------------------------------------------------------------------------- +// Adds an element, uses copy constructor +//----------------------------------------------------------------------------- +template< typename T, class A > +inline int CUtlVector::AddToHead(const T& src) +{ + // Can't insert something that's in the list... reallocation may hose us + assert((Base() == NULL) || (&src < Base()) || (&src >= (Base() + Count()))); + return InsertBefore(0, src); +} + +template< typename T, class A > +inline int CUtlVector::AddToTail(const T& src) +{ + // Can't insert something that's in the list... reallocation may hose us + assert((Base() == NULL) || (&src < Base()) || (&src >= (Base() + Count()))); + return InsertBefore(m_Size, src); +} + +template< typename T, class A > +inline int CUtlVector::InsertAfter(int elem, const T& src) +{ + // Can't insert something that's in the list... reallocation may hose us + assert((Base() == NULL) || (&src < Base()) || (&src >= (Base() + Count()))); + return InsertBefore(elem + 1, src); +} + +template< typename T, class A > +int CUtlVector::InsertBefore(int elem, const T& src) +{ + // Can't insert something that's in the list... reallocation may hose us + assert((Base() == NULL) || (&src < Base()) || (&src >= (Base() + Count()))); + + // Can insert at the end + assert((elem == Count()) || IsValidIndex(elem)); + + GrowVector(); + ShiftElementsRight(elem); + CopyConstruct(&Element(elem), src); + return elem; +} + + +//----------------------------------------------------------------------------- +// Adds multiple elements, uses default constructor +//----------------------------------------------------------------------------- +template< typename T, class A > +inline int CUtlVector::AddMultipleToHead(int num) +{ + return InsertMultipleBefore(0, num); +} + +template< typename T, class A > +inline int CUtlVector::AddMultipleToTail(int num) +{ + return InsertMultipleBefore(m_Size, num); +} + +template< typename T, class A > +inline int CUtlVector::AddMultipleToTail(int num, const T* pToCopy) +{ + // Can't insert something that's in the list... reallocation may hose us + assert((Base() == NULL) || !pToCopy || (pToCopy + num <= Base()) || (pToCopy >= (Base() + Count()))); + + return InsertMultipleBefore(m_Size, num, pToCopy); +} + +template< typename T, class A > +int CUtlVector::InsertMultipleAfter(int elem, int num) +{ + return InsertMultipleBefore(elem + 1, num); +} + + +template< typename T, class A > +void CUtlVector::SetCount(int count) +{ + RemoveAll(); + AddMultipleToTail(count); +} + +template< typename T, class A > +inline void CUtlVector::SetSize(int size) +{ + SetCount(size); +} + +template< typename T, class A > +void CUtlVector::SetCountNonDestructively(int count) +{ + int delta = count - m_Size; + if (delta > 0) AddMultipleToTail(delta); + else if (delta < 0) RemoveMultipleFromTail(-delta); +} + +template< typename T, class A > +void CUtlVector::CopyArray(const T* pArray, int size) +{ + // Can't insert something that's in the list... reallocation may hose us + assert((Base() == NULL) || !pArray || (Base() >= (pArray + size)) || (pArray >= (Base() + Count()))); + + SetSize(size); + for (int i = 0; i < size; i++) { + (*this)[i] = pArray[i]; + } +} + +template< typename T, class A > +void CUtlVector::Swap(CUtlVector< T, A >& vec) +{ + m_Memory.Swap(vec.m_Memory); + V_swap(m_Size, vec.m_Size); +#ifndef _X360 + V_swap(m_pElements, vec.m_pElements); +#endif +} + +template< typename T, class A > +int CUtlVector::AddVectorToTail(CUtlVector const& src) +{ + assert(&src != this); + + int base = Count(); + + // Make space. + int nSrcCount = src.Count(); + EnsureCapacity(base + nSrcCount); + + // Copy the elements. + m_Size += nSrcCount; + for (int i = 0; i < nSrcCount; i++) { + CopyConstruct(&Element(base + i), src[i]); + } + return base; +} + +template< typename T, class A > +inline int CUtlVector::InsertMultipleBefore(int elem, int num) +{ + if (num == 0) + return elem; + + // Can insert at the end + assert((elem == Count()) || IsValidIndex(elem)); + + GrowVector(num); + ShiftElementsRight(elem, num); + + // Invoke default constructors + for (int i = 0; i < num; ++i) { + Construct(&Element(elem + i)); + } + + return elem; +} + +template< typename T, class A > +inline int CUtlVector::InsertMultipleBefore(int elem, int num, const T* pToInsert) +{ + if (num == 0) + return elem; + + // Can insert at the end + assert((elem == Count()) || IsValidIndex(elem)); + + GrowVector(num); + ShiftElementsRight(elem, num); + + // Invoke default constructors + if (!pToInsert) { + for (int i = 0; i < num; ++i) { + Construct(&Element(elem + i)); + } + } + else { + for (int i = 0; i < num; i++) { + CopyConstruct(&Element(elem + i), pToInsert[i]); + } + } + + return elem; +} + + +//----------------------------------------------------------------------------- +// Finds an element (element needs operator== defined) +//----------------------------------------------------------------------------- +template< typename T, class A > +int CUtlVector::GetOffset(const T& src) const +{ + for (int i = 0; i < Count(); ++i) { + if (Element(i) == src) + return i; + } + return -1; +} + +template< typename T, class A > +void CUtlVector::FillWithValue(const T& src) +{ + for (int i = 0; i < Count(); i++) { + Element(i) = src; + } +} + +template< typename T, class A > +bool CUtlVector::HasElement(const T& src) const +{ + return (GetOffset(src) >= 0); +} + + +//----------------------------------------------------------------------------- +// Element removal +//----------------------------------------------------------------------------- +template< typename T, class A > +void CUtlVector::FastRemove(int elem) +{ + assert(IsValidIndex(elem)); + + Destruct(&Element(elem)); + if (m_Size > 0) { + if (elem != m_Size - 1) + memcpy(&Element(elem), &Element(m_Size - 1), sizeof(T)); + --m_Size; + } +} + +template< typename T, class A > +void CUtlVector::Remove(int elem) +{ + Destruct(&Element(elem)); + ShiftElementsLeft(elem); + --m_Size; +} + +template< typename T, class A > +bool CUtlVector::Find(const T& src) +{ + return GetOffset(src); +} + +template< typename T, class A > +bool CUtlVector::FindAndRemove(const T& src) +{ + int elem = GetOffset(src); + if (elem != -1) { + Remove(elem); + return true; + } + return false; +} + +template< typename T, class A > +bool CUtlVector::FindAndFastRemove(const T& src) +{ + int elem = GetOffset(src); + if (elem != -1) { + FastRemove(elem); + return true; + } + return false; +} + +template< typename T, class A > +void CUtlVector::RemoveMultiple(int elem, int num) +{ + assert(elem >= 0); + assert(elem + num <= Count()); + + for (int i = elem + num; --i >= elem; ) + Destruct(&Element(i)); + + ShiftElementsLeft(elem, num); + m_Size -= num; +} + +template< typename T, class A > +void CUtlVector::RemoveMultipleFromHead(int num) +{ + assert(num <= Count()); + + for (int i = num; --i >= 0; ) + Destruct(&Element(i)); + + ShiftElementsLeft(0, num); + m_Size -= num; +} + +template< typename T, class A > +void CUtlVector::RemoveMultipleFromTail(int num) +{ + assert(num <= Count()); + + for (int i = m_Size - num; i < m_Size; i++) + Destruct(&Element(i)); + + m_Size -= num; +} + +template +inline void Destruct(T* pMemory) +{ + pMemory->~T(); + +#ifdef _DEBUG + memset(pMemory, 0xDD, sizeof(T)); +#endif +} + +template< typename T, class A > +void CUtlVector::RemoveAll() +{ + for (int i = m_Size; --i >= 0; ) { + Destruct(&Element(i)); + } + + m_Size = 0; +} + + +//----------------------------------------------------------------------------- +// Memory deallocation +//----------------------------------------------------------------------------- + +template< typename T, class A > +inline void CUtlVector::Purge() +{ + RemoveAll(); + m_Memory.Purge(); + ResetDbgInfo(); +} + + +template< typename T, class A > +inline void CUtlVector::PurgeAndDeleteElements() +{ + for (int i = 0; i < m_Size; i++) { + delete Element(i); + } + Purge(); +} + +template< typename T, class A > +inline void CUtlVector::Compact() +{ + m_Memory.Purge(m_Size); +} + +template< typename T, class A > +inline int CUtlVector::NumAllocated() const +{ + return m_Memory.NumAllocated(); +} + + +//----------------------------------------------------------------------------- +// Data and memory validation +//----------------------------------------------------------------------------- +#ifdef DBGFLAG_VALIDATE +template< typename T, class A > +void CUtlVector::Validate(CValidator& validator, char* pchName) +{ + validator.Push(typeid(*this).name(), this, pchName); + + m_Memory.Validate(validator, "m_Memory"); + + validator.Pop(); +} +#endif // DBGFLAG_VALIDATE + +// A vector class for storing pointers, so that the elements pointed to by the pointers are deleted +// on exit. +template class CUtlVectorAutoPurge : public CUtlVector< T, CUtlMemory< T, int> > +{ +public: + ~CUtlVectorAutoPurge(void) + { + this->PurgeAndDeleteElements(); + } +}; + +// easy string list class with dynamically allocated strings. For use with V_SplitString, etc. +// Frees the dynamic strings in destructor. +class CUtlStringList : public CUtlVectorAutoPurge< char*> +{ +public: + void CopyAndAddToTail(char const* pString) // clone the string and add to the end + { + char* pNewStr = new char[1 + strlen(pString)]; + strcpy_s(pNewStr, 1 + strlen(pString), pString); + AddToTail(pNewStr); + } + + static int __cdecl SortFunc(char* const* sz1, char* const* sz2) + { + return strcmp(*sz1, *sz2); + } + +}; +``` + +`Counter-Strike Global Offensive.filters`: + +```filters + + + + + {d9575ed4-b3b4-4b35-9715-450fd649126b} + + + {41483e86-f744-4484-a527-99a75fc9ae59} + + + {74483f8d-c1bb-44bf-aef2-72f57f9240bd} + + + {0b8ba8d0-6ca4-41b0-af2a-a9575fb25456} + + + {afab3aa9-a591-4015-baa1-441cf2a7286c} + + + {0da61017-6a41-4c48-8a51-81e55e0908c6} + + + {63fe72a3-3796-4265-90ac-a6a6f533aa70} + + + {c19225b9-87db-4485-a546-a3158b8d7757} + + + {3bfc70c2-c268-42f3-9903-e6ae45313e7e} + + + {d8bcae19-60fb-49bd-9683-74354a11b74c} + + + {4f47dc83-0c5c-4c90-8ace-bce5ec86def9} + + + {adf8f900-81fb-46b8-9476-438ce0f30a98} + + + {b3bd3363-0705-4107-9ec4-35f9ca95029e} + + + {ff3e2749-42ad-47b7-92c3-60c89777c02f} + + + {4cc2d6d6-a135-432b-911d-c981f2974f06} + + + {30893de0-7593-4e1a-b59d-467657d4e0b0} + + + {52aa079b-642e-4c11-95d4-038b619cd42b} + + + {37a5b03d-f837-4e53-a7a6-5b869fe980fd} + + + {9f3bc3ac-e4e0-440e-a140-6db11d8843db} + + + {982959de-563f-4a8c-8acc-2c070678622d} + + + {f288fc6b-aca6-4fd4-9ccb-6f388c5938e2} + + + {497da6d5-8eca-4116-a2c9-af8812723deb} + + + {639dee94-3ce0-4627-80d0-a4a478baa147} + + + {d76421d9-81d4-4272-b7f9-eb18300ac5b4} + + + {e516d161-2001-4ed2-9d3c-a5a832b2ff03} + + + {5c476034-c984-48d9-afde-86ce9e74b6f7} + + + {3ca11f71-d245-46cd-afe4-8abe7ba6dd63} + + + {1f9527f9-0f87-4188-8ba2-8766e26decd6} + + + {2596b440-db59-4c92-b74b-94c927b1c960} + + + {3391ea8e-8016-4ae4-a7bc-16825bc73a9e} + + + {d70dbeed-7a32-429d-a6bc-bcfa5ac059e6} + + + {7a381163-645c-4fc4-ac8a-dca65dce2c77} + + + {f31d3854-6c2d-4b9a-b1f1-d64df5b5b8e7} + + + {88951108-a8e3-4b13-b527-c19c54e51ddf} + + + {a298ce18-8279-48c7-868a-3ca4fc0e039e} + + + {2494cbc3-1aff-4cdc-97be-99132bdc9544} + + + {2f251372-5664-4384-8655-ed42b2bc4600} + + + {3f59b5a9-50e4-4c9a-a212-39896a4a2b89} + + + {dcd30636-3d7e-45ae-989f-f766ca881a80} + + + {b8419b12-ec79-431a-ac07-302434fc8e50} + + + {3a63a686-4b4c-4813-9c36-e63002ac9d4f} + + + {b133e837-374e-4e28-82eb-8dad7d5a4218} + + + {9b8722a8-6bae-4161-8701-fc73913d5511} + + + {175f754f-4dad-4c4b-be2c-81cca2ee223f} + + + {492fb937-9c37-43e0-b947-4791798e1f4e} + + + + + main + + + source + + + source\hooked + + + valve\core + + + valve\core + + + valve\core + + + valve\core + + + valve\core + + + engine\prop-manager + + + valve + + + engine\displacement + + + source\hooked + + + horizon\memory + + + horizon\win32 + + + valve\object + + + valve\object + + + valve\object + + + engine\prediction + + + valve\core + + + valve\core + + + source\hooked + + + source\hooked + + + source\hooked + + + engine\movement + + + engine\rage-bot\anti-aimbot + + + engine\misc + + + source\hooked + + + engine\rage-bot\anti-anti-aim + + + engine\visuals + + + engine\rage-bot\extra + + + engine\rage-bot\lag-compensation + + + engine\visuals\models + + + engine\rage-bot\rage-aimbot + + + engine\rage-bot\autowall + + + source\hooked + + + source\hooked + + + source\hooked + + + engine\visuals + + + engine\menu + + + engine\misc\music-player + + + engine\menu\menu-v2\gui\container + + + engine\menu\menu-v2\gui\container + + + engine\menu\menu-v2\gui\container + + + engine\menu\menu-v2\gui\controls + + + engine\menu\menu-v2\gui\controls + + + engine\menu\menu-v2\gui\controls + + + engine\menu\menu-v2\gui\controls + + + engine\menu\menu-v2\gui\controls + + + engine\menu\menu-v2\gui\controls + + + engine\menu\menu-v2\gui\controls + + + engine\menu\menu-v2\input + + + engine\menu\menu-v2\settings + + + engine\menu\menu-v2\menu + + + engine\misc + + + include + + + engine\visuals\sound + + + horizon\threading + + + horizon\threading + + + horizon\threading + + + horizon\threading + + + horizon\threading + + + horizon\threading + + + source\hooked\server debugging + + + horizon\core + + + engine\visuals\grenades + + + engine\rage-bot\rage-aimbot\knife_aimbot + + + include + + + engine\visuals\precipitation + + + engine\visuals\dx9render + + + engine\visuals\dx9render\menu + + + include\imgui_extended + + + include + + + include + + + include + + + include + + + engine\legit-aimbot + + + + + include + + + include + + + valve + + + horizon\memory + + + horizon\memory + + + horizon + + + source\hooked + + + valve\core + + + valve\core + + + valve\core + + + valve\core + + + valve\core + + + valve\core + + + horizon\core + + + engine\prop-manager + + + engine\displacement + + + horizon\memory + + + horizon\win32 + + + valve\object + + + valve\object + + + valve\object + + + engine\prediction + + + valve\core + + + include + + + engine\movement + + + engine\rage-bot\anti-aimbot + + + include + + + include + + + include + + + include + + + include + + + engine\misc + + + include + + + engine\rage-bot\anti-anti-aim + + + engine\visuals + + + engine\rage-bot\extra + + + engine\rage-bot\lag-compensation + + + engine\visuals\models + + + engine\rage-bot\rage-aimbot + + + engine\rage-bot\autowall + + + engine\menu + + + engine\misc\music-player + + + engine\menu\menu-v2\gui + + + engine\menu\menu-v2\gui\container + + + engine\menu\menu-v2\gui\container + + + engine\menu\menu-v2\gui\container + + + engine\menu\menu-v2\gui\controls + + + engine\menu\menu-v2\gui\controls + + + engine\menu\menu-v2\gui\controls + + + engine\menu\menu-v2\gui\controls + + + engine\menu\menu-v2\gui\controls + + + engine\menu\menu-v2\gui\controls + + + engine\menu\menu-v2\gui\controls + + + engine\menu\menu-v2\input + + + engine\menu\menu-v2\settings + + + engine\menu\menu-v2\menu + + + engine\misc + + + include + + + include + + + engine\visuals\sound + + + include + + + include + + + horizon\threading + + + horizon\threading + + + horizon\threading + + + horizon\threading + + + horizon\threading + + + horizon\threading + + + horizon\threading + + + include + + + source\hooked\server debugging + + + include + + + horizon\core + + + engine\visuals\grenades + + + include + + + engine\visuals\precipitation + + + include + + + include + + + include + + + engine\visuals\dx9render + + + engine\visuals\dx9render\menu + + + include\imgui_extended + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + engine\legit-aimbot + + + source + + + +``` + +`Counter-Strike Global Offensive.vcxproj.user`: + +```user + + + + +``` + +`LuaBridge/List.h`: + +```h +// https://github.com/vinniefalco/LuaBridge +// +// Copyright 2018, Dmitry Tarakanov +// SPDX-License-Identifier: MIT + +#pragma once + +#include + +#include + +namespace luabridge { + +template +struct Stack > +{ + static void push(lua_State* L, std::list const& list) + { + lua_createtable (L, static_cast (list.size ()), 0); + typename std::list ::const_iterator item = list.begin(); + for (std::size_t i = 1; i <= list.size (); ++i) + { + lua_pushinteger (L, static_cast (i)); + Stack ::push (L, *item); + lua_settable (L, -3); + ++item; + } + } + + static std::list get(lua_State* L, int index) + { + if (!lua_istable(L, index)) + { + luaL_error(L, "#%d argments must be table", index); + } + + std::list list; + + int const absindex = lua_absindex (L, index); + lua_pushnil (L); + while (lua_next (L, absindex) != 0) + { + list.push_back (Stack ::get (L, -1)); + lua_pop (L, 1); + } + return list; + } +}; + +template +struct Stack const&> : Stack > +{ +}; + +} // namespace luabridge + +``` + +`LuaBridge/LuaBridge.h`: + +```h +//------------------------------------------------------------------------------ +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco "vinnie.falco@gmail.com" + Copyright 2007, Nathan Reed + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +//============================================================================== + +#pragma once + +// All #include dependencies are listed here +// instead of in the individual header files. +// + +#define LUABRIDGE_MAJOR_VERSION 2 +#define LUABRIDGE_MINOR_VERSION 0 +#define LUABRIDGE_VERSION 200 + +#ifndef LUA_VERSION_NUM +#error "Lua headers must be included prior to LuaBridge ones" +#endif + + +#include "LuaBridge/detail/LuaHelpers.h" +#include "LuaBridge/detail/TypeTraits.h" +#include "LuaBridge/detail/TypeList.h" +#include "LuaBridge/detail/FuncTraits.h" +#include "LuaBridge/detail/Constructor.h" +#include "LuaBridge/detail/ClassInfo.h" +#include "LuaBridge/detail/LuaException.h" +#include "LuaBridge/detail/LuaRef.h" +#include "LuaBridge/detail/Iterator.h" +#include "LuaBridge/detail/Userdata.h" +#include "LuaBridge/detail/CFunctions.h" +#include "LuaBridge/detail/Security.h" +#include "LuaBridge/detail/Stack.h" +#include "LuaBridge/detail/Namespace.h" + +``` + +`LuaBridge/Map.h`: + +```h +// https://github.com/vinniefalco/LuaBridge +// +// Copyright 2018, Dmitry Tarakanov +// SPDX-License-Identifier: MIT + +#pragma once + +#include + +#include + +namespace luabridge { + +template +struct Stack > +{ + typedef std::map Map; + + static void push(lua_State* L, const Map& map) + { + lua_createtable (L, 0, static_cast (map.size ())); + typedef typename Map::const_iterator ConstIter; + for (ConstIter i = map.begin(); i != map.end(); ++i) + { + Stack ::push (L, i->first); + Stack ::push (L, i->second); + lua_settable (L, -3); + } + } + + static Map get(lua_State* L, int index) + { + if (!lua_istable(L, index)) + { + luaL_error(L, "#%d argments must be table", index); + } + + Map map; + int const absindex = lua_absindex (L, index); + lua_pushnil (L); + while (lua_next (L, absindex) != 0) + { + map.emplace (Stack ::get (L, -2), Stack ::get (L, -1)); + lua_pop (L, 1); + } + return map; + } +}; + +template +struct Stack const&> : Stack > +{ +}; + +} // namespace luabridge + +``` + +`LuaBridge/RefCountedObject.h`: + +```h +//============================================================================== +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco + Copyright 2004-11 by Raw Material Software Ltd. + + This is a derivative work used by permission from part of + JUCE, available at http://www.rawaterialsoftware.com + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + + This file incorporates work covered by the following copyright and + permission notice: + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-11 by Raw Material Software Ltd. +*/ +//============================================================================== + +#pragma once + +//#define LUABRIDGE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1 + +#include + +#include + +namespace luabridge { + +//============================================================================== +/** + Adds reference-counting to an object. + + To add reference-counting to a class, derive it from this class, and + use the RefCountedObjectPtr class to point to it. + + e.g. @code + class MyClass : public RefCountedObjectType + { + void foo(); + + // This is a neat way of declaring a typedef for a pointer class, + // rather than typing out the full templated name each time.. + typedef RefCountedObjectPtr Ptr; + }; + + MyClass::Ptr p = new MyClass(); + MyClass::Ptr p2 = p; + p = 0; + p2->foo(); + @endcode + + Once a new RefCountedObjectType has been assigned to a pointer, be + careful not to delete the object manually. +*/ +template +class RefCountedObjectType +{ +public: + //============================================================================== + /** Increments the object's reference count. + + This is done automatically by the smart pointer, but is public just + in case it's needed for nefarious purposes. + */ + inline void incReferenceCount() const + { + ++refCount; + } + + /** Decreases the object's reference count. + + If the count gets to zero, the object will be deleted. + */ + inline void decReferenceCount() const + { + assert (getReferenceCount() > 0); + + if (--refCount == 0) + delete this; + } + + /** Returns the object's current reference count. */ + inline int getReferenceCount() const + { + return static_cast (refCount); + } + +protected: + //============================================================================== + /** Creates the reference-counted object (with an initial ref count of zero). */ + RefCountedObjectType() : refCount () + { + } + + /** Destructor. */ + virtual ~RefCountedObjectType() + { + // it's dangerous to delete an object that's still referenced by something else! + assert (getReferenceCount() == 0); + } + +private: + //============================================================================== + CounterType mutable refCount; +}; + +//============================================================================== + +/** Non thread-safe reference counted object. + + This creates a RefCountedObjectType that uses a non-atomic integer + as the counter. +*/ +typedef RefCountedObjectType RefCountedObject; + +//============================================================================== +/** + A smart-pointer class which points to a reference-counted object. + + The template parameter specifies the class of the object you want to point + to - the easiest way to make a class reference-countable is to simply make + it inherit from RefCountedObjectType, but if you need to, you could roll + your own reference-countable class by implementing a pair of methods called + incReferenceCount() and decReferenceCount(). + + When using this class, you'll probably want to create a typedef to + abbreviate the full templated name - e.g. + + @code + + typedef RefCountedObjectPtr MyClassPtr; + + @endcode +*/ +template +class RefCountedObjectPtr +{ +public: + /** The class being referenced by this pointer. */ + typedef ReferenceCountedObjectClass ReferencedType; + + //============================================================================== + /** Creates a pointer to a null object. */ + inline RefCountedObjectPtr() : referencedObject (0) + { + } + + /** Creates a pointer to an object. + + This will increment the object's reference-count if it is non-null. + */ + inline RefCountedObjectPtr (ReferenceCountedObjectClass* const refCountedObject) + : referencedObject (refCountedObject) + { + if (refCountedObject != 0) + refCountedObject->incReferenceCount(); + } + + /** Copies another pointer. + This will increment the object's reference-count (if it is non-null). + */ + inline RefCountedObjectPtr (const RefCountedObjectPtr& other) + : referencedObject (other.referencedObject) + { + if (referencedObject != 0) + referencedObject->incReferenceCount(); + } + +#if LUABRIDGE_COMPILER_SUPPORTS_MOVE_SEMANTICS + /** Takes-over the object from another pointer. */ + inline RefCountedObjectPtr (RefCountedObjectPtr&& other) + : referencedObject (other.referencedObject) + { + other.referencedObject = 0; + } +#endif + + /** Copies another pointer. + This will increment the object's reference-count (if it is non-null). + */ + template + inline RefCountedObjectPtr (const RefCountedObjectPtr& other) + : referencedObject (static_cast (other.getObject())) + { + if (referencedObject != 0) + referencedObject->incReferenceCount(); + } + + /** Changes this pointer to point at a different object. + + The reference count of the old object is decremented, and it might be + deleted if it hits zero. The new object's count is incremented. + */ + RefCountedObjectPtr& operator= (const RefCountedObjectPtr& other) + { + return operator= (other.referencedObject); + } + + /** Changes this pointer to point at a different object. + + The reference count of the old object is decremented, and it might be + deleted if it hits zero. The new object's count is incremented. + */ + template + RefCountedObjectPtr& operator= (const RefCountedObjectPtr& other) + { + return operator= (static_cast (other.getObject())); + } + +#if LUABRIDGE_COMPILER_SUPPORTS_MOVE_SEMANTICS + /** Takes-over the object from another pointer. */ + RefCountedObjectPtr& operator= (RefCountedObjectPtr&& other) + { + std::swap (referencedObject, other.referencedObject); + return *this; + } +#endif + + /** Changes this pointer to point at a different object. + + The reference count of the old object is decremented, and it might be + deleted if it hits zero. The new object's count is incremented. + */ + RefCountedObjectPtr& operator= (ReferenceCountedObjectClass* const newObject) + { + if (referencedObject != newObject) + { + if (newObject != 0) + newObject->incReferenceCount(); + + ReferenceCountedObjectClass* const oldObject = referencedObject; + referencedObject = newObject; + + if (oldObject != 0) + oldObject->decReferenceCount(); + } + + return *this; + } + + /** Destructor. + + This will decrement the object's reference-count, and may delete it if it + gets to zero. + */ + inline ~RefCountedObjectPtr() + { + if (referencedObject != 0) + referencedObject->decReferenceCount(); + } + + /** Returns the object that this pointer references. + The pointer returned may be zero, of course. + */ + inline operator ReferenceCountedObjectClass*() const + { + return referencedObject; + } + + // the -> operator is called on the referenced object + inline ReferenceCountedObjectClass* operator->() const + { + return referencedObject; + } + + /** Returns the object that this pointer references. + The pointer returned may be zero, of course. + */ + inline ReferenceCountedObjectClass* getObject() const + { + return referencedObject; + } + +private: + //============================================================================== + ReferenceCountedObjectClass* referencedObject; +}; + +/** Compares two ReferenceCountedObjectPointers. */ +template +bool operator== (const RefCountedObjectPtr& object1, ReferenceCountedObjectClass* const object2) +{ + return object1.getObject() == object2; +} + +/** Compares two ReferenceCountedObjectPointers. */ +template +bool operator== (const RefCountedObjectPtr& object1, const RefCountedObjectPtr& object2) +{ + return object1.getObject() == object2.getObject(); +} + +/** Compares two ReferenceCountedObjectPointers. */ +template +bool operator== (ReferenceCountedObjectClass* object1, RefCountedObjectPtr& object2) +{ + return object1 == object2.getObject(); +} + +/** Compares two ReferenceCountedObjectPointers. */ +template +bool operator!= (const RefCountedObjectPtr& object1, const ReferenceCountedObjectClass* object2) +{ + return object1.getObject() != object2; +} + +/** Compares two ReferenceCountedObjectPointers. */ +template +bool operator!= (const RefCountedObjectPtr& object1, RefCountedObjectPtr& object2) +{ + return object1.getObject() != object2.getObject(); +} + +/** Compares two ReferenceCountedObjectPointers. */ +template +bool operator!= (ReferenceCountedObjectClass* object1, RefCountedObjectPtr& object2) +{ + return object1 != object2.getObject(); +} + +//============================================================================== + +namespace luabridge +{ + +template +struct ContainerTraits > +{ + typedef T Type; + + static T* get (RefCountedObjectPtr const& c) + { + return c.getObject (); + } +}; + +} + +//============================================================================== + +} // namespace luabridge + +``` + +`LuaBridge/RefCountedPtr.h`: + +```h +//============================================================================== +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco + Copyright 2007, Nathan Reed + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +//============================================================================== + +#pragma once + +#include + +namespace luabridge { + +//============================================================================== +/** + Support for our RefCountedPtr. +*/ +struct RefCountedPtrBase +{ + // Declaration of container for the refcounts + typedef std::unordered_map RefCountsType; + +protected: + inline RefCountsType& getRefCounts () const + { + static RefCountsType refcounts; + return refcounts ; + } +}; + +//============================================================================== +/** + A reference counted smart pointer. + + The api is compatible with boost::RefCountedPtr and std::RefCountedPtr, in the + sense that it implements a strict subset of the functionality. + + This implementation uses a hash table to look up the reference count + associated with a particular pointer. + + @tparam T The class type. + + @todo Decompose RefCountedPtr using a policy. At a minimum, the underlying + reference count should be policy based (to support atomic operations) + and the delete behavior should be policy based (to support custom + disposal methods). + + @todo Provide an intrusive version of RefCountedPtr. +*/ +template +class RefCountedPtr : private RefCountedPtrBase +{ +public: + template + struct rebind + { + typedef RefCountedPtr other; + }; + + /** Construct as nullptr or from existing pointer to T. + + @param p The optional, existing pointer to assign from. + */ + RefCountedPtr (T* p = 0) : m_p (p) + { + ++getRefCounts () [m_p]; + } + + /** Construct from another RefCountedPtr. + + @param rhs The RefCountedPtr to assign from. + */ + RefCountedPtr (RefCountedPtr const& rhs) : m_p (rhs.get()) + { + ++getRefCounts () [m_p]; + } + + /** Construct from a RefCountedPtr of a different type. + + @invariant A pointer to U must be convertible to a pointer to T. + + @param rhs The RefCountedPtr to assign from. + @tparam U The other object type. + */ + template + RefCountedPtr (RefCountedPtr const& rhs) : m_p (static_cast (rhs.get())) + { + ++getRefCounts () [m_p]; + } + + /** Release the object. + + If there are no more references then the object is deleted. + */ + ~RefCountedPtr () + { + reset(); + } + + /** Assign from another RefCountedPtr. + + @param rhs The RefCountedPtr to assign from. + @return A reference to the RefCountedPtr. + */ + RefCountedPtr & operator= (RefCountedPtr const& rhs) + { + if (m_p != rhs.m_p) + { + reset (); + m_p = rhs.m_p; + ++getRefCounts () [m_p]; + } + return *this; + } + + /** Assign from another RefCountedPtr of a different type. + + @note A pointer to U must be convertible to a pointer to T. + + @tparam U The other object type. + @param rhs The other RefCountedPtr to assign from. + @return A reference to the RefCountedPtr. + */ + template + RefCountedPtr & operator= (RefCountedPtr const& rhs) + { + reset (); + m_p = static_cast (rhs.get()); + ++getRefCounts () [m_p]; + return *this; + } + + /** Retrieve the raw pointer. + + @return A pointer to the object. + */ + T* get () const + { + return m_p; + } + + /** Retrieve the raw pointer. + + @return A pointer to the object. + */ + T* operator* () const + { + return m_p; + } + + /** Retrieve the raw pointer. + + @return A pointer to the object. + */ + T* operator-> () const + { + return m_p; + } + + /** Determine the number of references. + + @note This is not thread-safe. + + @return The number of active references. + */ + long use_count () const + { + return getRefCounts () [m_p]; + } + + /** Release the pointer. + + The reference count is decremented. If the reference count reaches + zero, the object is deleted. + */ + void reset () + { + if (m_p != 0) + { + if (--getRefCounts () [m_p] <= 0) + delete m_p; + + m_p = 0; + } + } + +private: + T* m_p; +}; + +//============================================================================== + +// forward declaration +template +struct ContainerTraits; + +template +struct ContainerTraits > +{ + typedef T Type; + + static T* get (RefCountedPtr const& c) + { + return c.get (); + } +}; + +} // namespace luabridge + +``` + +`LuaBridge/Vector.h`: + +```h +// https://github.com/vinniefalco/LuaBridge +// +// Copyright 2018, Dmitry Tarakanov +// SPDX-License-Identifier: MIT + +#pragma once + +#include + +#include + +namespace luabridge { + +template +struct Stack > +{ + static void push(lua_State* L, std::vector const& vector) + { + lua_createtable (L, static_cast (vector.size ()), 0); + for (std::size_t i = 0; i < vector.size (); ++i) + { + lua_pushinteger (L, static_cast (i + 1)); + Stack ::push (L, vector [i]); + lua_settable (L, -3); + } + } + + static std::vector get(lua_State* L, int index) + { + if (!lua_istable(L, index)) + { + luaL_error(L, "#%d argments must be table", index); + } + + std::vector vector; + vector.reserve (static_cast (get_length (L, index))); + + int const absindex = lua_absindex (L, index); + lua_pushnil (L); + while (lua_next (L, absindex) != 0) + { + vector.push_back (Stack ::get (L, -1)); + lua_pop (L, 1); + } + return vector; + } +}; + +template +struct Stack const&> : Stack > +{ +}; + +} // namespace luabridge + +``` + +`LuaBridge/detail/CFunctions.h`: + +```h +//------------------------------------------------------------------------------ +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +//============================================================================== + +#pragma once + +#include + +namespace luabridge { + +// We use a structure so we can define everything in the header. +// +struct CFunc +{ + //---------------------------------------------------------------------------- + /** + __index metamethod for a namespace or class static members. + + This handles: + Retrieving functions and class static methods, stored in the metatable. + Reading global and class static data, stored in the __propget table. + Reading global and class properties, stored in the __propget table. + */ + static int indexMetaMethod (lua_State* L) + { + int result = 0; + lua_getmetatable (L, 1); // push metatable of arg1 + for (;;) + { + lua_pushvalue (L, 2); // push key arg2 + lua_rawget (L, -2); // lookup key in metatable + if (lua_isnil (L, -1)) // not found + { + lua_pop (L, 1); // discard nil + rawgetfield (L, -1, "__propget"); // lookup __propget in metatable + lua_pushvalue (L, 2); // push key arg2 + lua_rawget (L, -2); // lookup key in __propget + lua_remove (L, -2); // discard __propget + if (lua_iscfunction (L, -1)) + { + lua_remove (L, -2); // discard metatable + lua_pushvalue (L, 1); // push arg1 + lua_call (L, 1, 1); // call cfunction + result = 1; + break; + } + else + { + assert (lua_isnil (L, -1)); + lua_pop (L, 1); // discard nil and fall through + } + } + else + { + assert (lua_istable (L, -1) || lua_iscfunction (L, -1)); + lua_remove (L, -2); + result = 1; + break; + } + + rawgetfield (L, -1, "__parent"); + if (lua_istable (L, -1)) + { + // Remove metatable and repeat the search in __parent. + lua_remove (L, -2); + } + else + { + // Discard metatable and return nil. + assert (lua_isnil (L, -1)); + lua_remove (L, -2); + result = 1; + break; + } + } + + return result; + } + + //---------------------------------------------------------------------------- + /** + __newindex metamethod for a namespace or class static members. + + The __propset table stores proxy functions for assignment to: + Global and class static data. + Global and class properties. + */ + static int newindexMetaMethod (lua_State* L) + { + int result = 0; + lua_getmetatable (L, 1); // push metatable of arg1 + for (;;) + { + rawgetfield (L, -1, "__propset"); // lookup __propset in metatable + assert (lua_istable (L, -1)); + lua_pushvalue (L, 2); // push key arg2 + lua_rawget (L, -2); // lookup key in __propset + lua_remove (L, -2); // discard __propset + if (lua_iscfunction (L, -1)) // ensure value is a cfunction + { + lua_remove (L, -2); // discard metatable + lua_pushvalue (L, 3); // push new value arg3 + lua_call (L, 1, 0); // call cfunction + result = 0; + break; + } + else + { + assert (lua_isnil (L, -1)); + lua_pop (L, 1); + } + + rawgetfield (L, -1, "__parent"); + if (lua_istable (L, -1)) + { + // Remove metatable and repeat the search in __parent. + lua_remove (L, -2); + } + else + { + assert (lua_isnil (L, -1)); + lua_pop (L, 2); + result = luaL_error (L, "no writable variable '%s'", lua_tostring (L, 2)); + } + } + + return result; + } + + //---------------------------------------------------------------------------- + /** + lua_CFunction to report an error writing to a read-only value. + + The name of the variable is in the first upvalue. + */ + static int readOnlyError (lua_State* L) + { + std::string s; + + s = s + "'" + lua_tostring (L, lua_upvalueindex (1)) + "' is read-only"; + + return luaL_error (L, s.c_str ()); + } + + //---------------------------------------------------------------------------- + /** + lua_CFunction to get a variable. + + This is used for global variables or class static data members. + + The pointer to the data is in the first upvalue. + */ + template + static int getVariable (lua_State* L) + { + assert (lua_islightuserdata (L, lua_upvalueindex (1))); + T const* ptr = static_cast (lua_touserdata (L, lua_upvalueindex (1))); + assert (ptr != 0); + Stack ::push (L, *ptr); + return 1; + } + + //---------------------------------------------------------------------------- + /** + lua_CFunction to set a variable. + + This is used for global variables or class static data members. + + The pointer to the data is in the first upvalue. + */ + template + static int setVariable (lua_State* L) + { + assert (lua_islightuserdata (L, lua_upvalueindex (1))); + T* ptr = static_cast (lua_touserdata (L, lua_upvalueindex (1))); + assert (ptr != 0); + *ptr = Stack ::get (L, 1); + return 0; + } + + //---------------------------------------------------------------------------- + /** + lua_CFunction to call a function with a return value. + + This is used for global functions, global properties, class static methods, + and class static properties. + + The function pointer is in the first upvalue. + */ + template ::ReturnType> + struct Call + { + typedef typename FuncTraits ::Params Params; + static int f (lua_State* L) + { + assert (isfulluserdata (L, lua_upvalueindex (1))); + FnPtr const& fnptr = *static_cast (lua_touserdata (L, lua_upvalueindex (1))); + assert (fnptr != 0); + ArgList args (L); + Stack ::ReturnType>::push (L, FuncTraits ::call (fnptr, args)); + return 1; + } + }; + + //---------------------------------------------------------------------------- + /** + lua_CFunction to call a function with no return value. + + This is used for global functions, global properties, class static methods, + and class static properties. + + The function pointer is in the first upvalue. + */ + template + struct Call + { + typedef typename FuncTraits ::Params Params; + static int f (lua_State* L) + { + assert (isfulluserdata (L, lua_upvalueindex (1))); + FnPtr const& fnptr = *static_cast (lua_touserdata (L, lua_upvalueindex (1))); + assert (fnptr != 0); + ArgList args (L); + FuncTraits ::call (fnptr, args); + return 0; + } + }; + + //---------------------------------------------------------------------------- + /** + lua_CFunction to call a class member function with a return value. + + The member function pointer is in the first upvalue. + The class userdata object is at the top of the Lua stack. + */ + template ::ReturnType> + struct CallMember + { + typedef typename FuncTraits ::ClassType T; + typedef typename FuncTraits ::Params Params; + + static int f (lua_State* L) + { + assert (isfulluserdata (L, lua_upvalueindex (1))); + T* const t = Userdata::get (L, 1, false); + MemFnPtr const& fnptr = *static_cast (lua_touserdata (L, lua_upvalueindex (1))); + assert (fnptr != 0); + ArgList args (L); + Stack ::push (L, FuncTraits ::call (t, fnptr, args)); + return 1; + } + }; + + template ::ReturnType> + struct CallConstMember + { + typedef typename FuncTraits ::ClassType T; + typedef typename FuncTraits ::Params Params; + + static int f (lua_State* L) + { + assert (isfulluserdata (L, lua_upvalueindex (1))); + T const* const t = Userdata::get (L, 1, true); + MemFnPtr const& fnptr = *static_cast (lua_touserdata (L, lua_upvalueindex (1))); + assert (fnptr != 0); + ArgList args (L); + Stack ::push (L, FuncTraits ::call (t, fnptr, args)); + return 1; + } + }; + + //---------------------------------------------------------------------------- + /** + lua_CFunction to call a class member function with no return value. + + The member function pointer is in the first upvalue. + The class userdata object is at the top of the Lua stack. + */ + template + struct CallMember + { + typedef typename FuncTraits ::ClassType T; + typedef typename FuncTraits ::Params Params; + + static int f (lua_State* L) + { + assert (isfulluserdata (L, lua_upvalueindex (1))); + T* const t = Userdata::get (L, 1, false); + MemFnPtr const& fnptr = *static_cast (lua_touserdata (L, lua_upvalueindex (1))); + assert (fnptr != 0); + ArgList args (L); + FuncTraits ::call (t, fnptr, args); + return 0; + } + }; + + template + struct CallConstMember + { + typedef typename FuncTraits ::ClassType T; + typedef typename FuncTraits ::Params Params; + + static int f (lua_State* L) + { + assert (isfulluserdata (L, lua_upvalueindex (1))); + T const* const t = Userdata::get (L, 1, true); + MemFnPtr const& fnptr = *static_cast (lua_touserdata (L, lua_upvalueindex (1))); + assert (fnptr != 0); + ArgList args (L); + FuncTraits ::call (t, fnptr, args); + return 0; + } + }; + + //-------------------------------------------------------------------------- + /** + lua_CFunction to call a class member lua_CFunction. + + The member function pointer is in the first upvalue. + The class userdata object is at the top of the Lua stack. + */ + template + struct CallMemberCFunction + { + static int f (lua_State* L) + { + assert (isfulluserdata (L, lua_upvalueindex (1))); + typedef int (T::*MFP)(lua_State* L); + T* const t = Userdata::get (L, 1, false); + MFP const& fnptr = *static_cast (lua_touserdata (L, lua_upvalueindex (1))); + assert (fnptr != 0); + return (t->*fnptr) (L); + } + }; + + template + struct CallConstMemberCFunction + { + static int f (lua_State* L) + { + assert (isfulluserdata (L, lua_upvalueindex (1))); + typedef int (T::*MFP)(lua_State* L); + T const* const t = Userdata::get (L, 1, true); + MFP const& fnptr = *static_cast (lua_touserdata (L, lua_upvalueindex (1))); + assert (fnptr != 0); + return (t->*fnptr) (L); + } + }; + + //-------------------------------------------------------------------------- + + // SFINAE Helpers + + template + struct CallMemberFunctionHelper + { + static void add (lua_State* L, char const* name, MemFnPtr mf) + { + new (lua_newuserdata (L, sizeof (MemFnPtr))) MemFnPtr (mf); + lua_pushcclosure (L, &CallConstMember ::f, 1); + lua_pushvalue (L, -1); + rawsetfield (L, -5, name); // const table + rawsetfield (L, -3, name); // class table + } + }; + + template + struct CallMemberFunctionHelper + { + static void add (lua_State* L, char const* name, MemFnPtr mf) + { + new (lua_newuserdata (L, sizeof (MemFnPtr))) MemFnPtr (mf); + lua_pushcclosure (L, &CallMember ::f, 1); + rawsetfield (L, -3, name); // class table + } + }; + + //-------------------------------------------------------------------------- + /** + __gc metamethod for a class. + */ + template + static int gcMetaMethod (lua_State* L) + { + Userdata* const ud = Userdata::getExact (L, 1); + ud->~Userdata (); + return 0; + } + + //-------------------------------------------------------------------------- + /** + lua_CFunction to get a class data member. + + The pointer-to-member is in the first upvalue. + The class userdata object is at the top of the Lua stack. + */ + template + static int getProperty (lua_State* L) + { + C const* const c = Userdata::get (L, 1, true); + T C::** mp = static_cast (lua_touserdata (L, lua_upvalueindex (1))); + Stack ::push (L, c->**mp); + return 1; + } + + //-------------------------------------------------------------------------- + /** + lua_CFunction to set a class data member. + + The pointer-to-member is in the first upvalue. + The class userdata object is at the top of the Lua stack. + */ + template + static int setProperty (lua_State* L) + { + C* const c = Userdata::get (L, 1, false); + T C::** mp = static_cast (lua_touserdata (L, lua_upvalueindex (1))); + c->**mp = Stack ::get (L, 2); + return 0; + } +}; + +} // namespace luabridge + +``` + +`LuaBridge/detail/ClassInfo.h`: + +```h +//------------------------------------------------------------------------------ +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +//============================================================================== + +#pragma once + +namespace luabridge { + +/** Unique Lua registry keys for a class. + + Each registered class inserts three keys into the registry, whose + values are the corresponding static, class, and const metatables. This + allows a quick and reliable lookup for a metatable from a template type. +*/ +template +class ClassInfo +{ +public: + /** Get the key for the static table. + + The static table holds the static data members, static properties, and + static member functions for a class. + */ + static void const* getStaticKey () + { + static char value; + return &value; + } + + /** Get the key for the class table. + + The class table holds the data members, properties, and member functions + of a class. Read-only data and properties, and const member functions are + also placed here (to save a lookup in the const table). + */ + static void const* getClassKey () + { + static char value; + return &value; + } + + /** Get the key for the const table. + + The const table holds read-only data members and properties, and const + member functions of a class. + */ + static void const* getConstKey () + { + static char value; + return &value; + } +}; + +} // namespace luabridge + +``` + +`LuaBridge/detail/Constructor.h`: + +```h +//------------------------------------------------------------------------------ +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco + Copyright 2007, Nathan Reed + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +//============================================================================== + +#pragma once + +namespace luabridge { + +/* +* Constructor generators. These templates allow you to call operator new and +* pass the contents of a type/value list to the Constructor. Like the +* function pointer containers, these are only defined up to 8 parameters. +*/ + +/** Constructor generators. + + These templates call operator new with the contents of a type/value + list passed to the Constructor with up to 8 parameters. Two versions + of call() are provided. One performs a regular new, the other performs + a placement new. +*/ +template +struct Constructor {}; + +template +struct Constructor +{ + static T* call (TypeListValues const&) + { + return new T; + } + static T* call (void* mem, TypeListValues const&) + { + return new (mem) T; + } +}; + +template +struct Constructor > +{ + static T* call (const TypeListValues > &tvl) + { + return new T(tvl.hd); + } + static T* call (void* mem, const TypeListValues > &tvl) + { + return new (mem) T(tvl.hd); + } +}; + +template +struct Constructor > > +{ + static T* call (const TypeListValues > > &tvl) + { + return new T(tvl.hd, tvl.tl.hd); + } + static T* call (void* mem, const TypeListValues > > &tvl) + { + return new (mem) T(tvl.hd, tvl.tl.hd); + } +}; + +template +struct Constructor > > > +{ + static T* call (const TypeListValues > > > &tvl) + { + return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd); + } + static T* call (void* mem, const TypeListValues > > > &tvl) + { + return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd); + } +}; + +template +struct Constructor > > > > +{ + static T* call (const TypeListValues > > > > &tvl) + { + return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd); + } + static T* call (void* mem, const TypeListValues > > > > &tvl) + { + return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd); + } +}; + +template +struct Constructor > > > > > +{ + static T* call (const TypeListValues > > > > > &tvl) + { + return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, + tvl.tl.tl.tl.tl.hd); + } + static T* call (void* mem, const TypeListValues > > > > > &tvl) + { + return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, + tvl.tl.tl.tl.tl.hd); + } +}; + +template +struct Constructor > > > > > > +{ + static T* call (const TypeListValues > > > > > > &tvl) + { + return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, + tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd); + } + static T* call (void* mem, const TypeListValues > > > > > > &tvl) + { + return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, + tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct Constructor > > > > > > > +{ + static T* call (const TypeListValues > > > > > > > &tvl) + { + return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, + tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, + tvl.tl.tl.tl.tl.tl.tl.hd); + } + static T* call (void* mem, const TypeListValues > > > > > > > &tvl) + { + return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, + tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, + tvl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct Constructor > > > > > > > > +{ + static T* call (const TypeListValues > > > > > > > > &tvl) + { + return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, + tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, + tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd); + } + static T* call (void* mem, const TypeListValues > > > > > > > > &tvl) + { + return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, + tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, + tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +} // namespace luabridge + +``` + +`LuaBridge/detail/FuncTraits.h`: + +```h +//------------------------------------------------------------------------------ +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +//============================================================================== + +#pragma once + +namespace luabridge { + +/** + Since the throw specification is part of a function signature, the FuncTraits + family of templates needs to be specialized for both types. The + LUABRIDGE_THROWSPEC macro controls whether we use the 'throw ()' form, or + 'noexcept' (if C++11 is available) to distinguish the functions. +*/ +#if defined (__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__clang__) || defined(__GNUC__) || \ + (defined (_MSC_VER) && (_MSC_VER >= 1700)) +// Do not define LUABRIDGE_THROWSPEC since the Xcode and gcc compilers do not +// distinguish the throw specification in the function signature. +#else +// Visual Studio 10 and earlier pay too much mind to useless throw() spec. +// +# define LUABRIDGE_THROWSPEC throw() +#endif + +//============================================================================== +/** + Traits for function pointers. + + There are three types of functions: global, non-const member, and const + member. These templates determine the type of function, which class type it + belongs to if it is a class member, the const-ness if it is a member + function, and the type information for the return value and argument list. + + Expansions are provided for functions with up to 8 parameters. This can be + manually extended, or expanded to an arbitrary amount using C++11 features. +*/ +template +struct FuncTraits +{ +}; + +/* Ordinary function pointers. */ + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef None Params; + static R call (D fp, TypeListValues ) + { + return fp (); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > > > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > > > > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +/* Windows: WINAPI (a.k.a. __stdcall) function pointers. */ + +#ifdef _M_IX86 // Windows 32bit only + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef None Params; + static R call (D fp, TypeListValues ) + { + return fp (); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > > > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > > > > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +#endif // _M_IX86 + +/* Non-const member function pointers. */ + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef None Params; + static R call (T* obj, D fp, TypeListValues ) + { + return (obj->*fp)(); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > > Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > > > Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +/* Const member function pointers. */ + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef None Params; + static R call (T const* obj, D fp, TypeListValues ) + { + return (obj->*fp)(); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList Params; + static R call (T const* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > Params; + static R call (T const* obj, R (T::*fp) (P1, P2) const, + TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > Params; + static R call (T const* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > Params; + static R call (T const* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > Params; + static R call (T const* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > Params; + static R call (T const* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > > Params; + static R call (T const* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > > > Params; + static R call (T const* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +#if defined (LUABRIDGE_THROWSPEC) + +/* Ordinary function pointers. */ + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef None Params; + static R call (D fp, TypeListValues const&) + { + return fp (); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > > > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > > > > > Params; + static R call (D fp, TypeListValues tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +/* Non-const member function pointers with THROWSPEC. */ + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef None Params; + static R call (T* obj, D fp, TypeListValues const&) + { + return (obj->*fp)(); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > > Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > > > Params; + static R call (T* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +/* Const member function pointers with THROWSPEC. */ + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef None Params; + static R call (T const* obj, D fp, TypeListValues ) + { + return (obj->*fp)(); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList Params; + static R call (T const* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > Params; + static R call (T const* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > Params; + static R call (T const* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > Params; + static R call (T const* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > Params; + static R call (T const* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, + tvl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > Params; + static R call (T const* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > > Params; + static R call (T const* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > > > Params; + static R call (T const* obj, D fp, TypeListValues tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd); + } +}; + +#endif + +} // namespace luabridge + +``` + +`LuaBridge/detail/Iterator.h`: + +```h +//------------------------------------------------------------------------------ +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +//============================================================================== + +#pragma once + +#include "LuaBridge/detail/LuaRef.h" + +#include + +namespace luabridge { + +/** Allows table iteration. +*/ +class Iterator +{ +private: + lua_State* m_L; + LuaRef m_table; + LuaRef m_key; + LuaRef m_value; + + void next () + { + m_table.push (); + m_key.push (); + if (lua_next (m_L, -2)) + { + m_value.pop (); + m_key.pop (); + } + else + { + m_key = Nil (); + m_value = Nil (); + } + lua_pop (m_L, 1); + } + +public: + explicit Iterator (const LuaRef& table, bool isEnd = false) + : m_L (table.state ()) + , m_table (table) + , m_key (table.state ()) // m_key is nil + , m_value (table.state ()) // m_value is nil + { + if (!isEnd) + { + next (); // get the first (key, value) pair from table + } + } + + lua_State* state () const + { + return m_L; + } + + std::pair operator* () const + { + return std::make_pair (m_key, m_value); + } + + LuaRef operator-> () const + { + return m_value; + } + + bool operator!= (const Iterator& rhs) const + { + assert (m_L == rhs.m_L); + return !m_table.rawequal (rhs.m_table) || !m_key.rawequal (rhs.m_key); + } + + Iterator& operator++ () + { + if (isNil()) + { + // if the iterator reaches the end, do nothing + return *this; + } + else + { + next(); + return *this; + } + } + + bool isNil () const + { + return m_key.isNil (); + } + + LuaRef key () const + { + return m_key; + } + + LuaRef value () const + { + return m_value; + } + +private: + // Don't use postfix increment, it is less efficient + Iterator operator++ (int); +}; + +class Range +{ + Iterator m_begin; + Iterator m_end; + +public: + Range (const Iterator& begin, const Iterator& end) + : m_begin (begin) + , m_end (end) + { + } + + const Iterator& begin () const { return m_begin; } + const Iterator& end () const { return m_end; } +}; + +inline Range pairs(const LuaRef& table) +{ + return Range (Iterator (table, false), Iterator (table, true)); +} + +} // namespace luabridge + +``` + +`LuaBridge/detail/LuaException.h`: + +```h +//------------------------------------------------------------------------------ +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco + Copyright 2008, Nigel Atkinson + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +//============================================================================== + +#pragma once + +#include +#include + +namespace luabridge { + +class LuaException : public std::exception +{ +private: + lua_State* m_L; + std::string m_what; + +public: + //---------------------------------------------------------------------------- + /** + Construct a LuaException after a lua_pcall(). + */ + LuaException (lua_State* L, int /*code*/) + : m_L (L) + { + whatFromStack (); + } + + //---------------------------------------------------------------------------- + + LuaException (lua_State *L, + char const*, + char const*, + long) + : m_L (L) + { + whatFromStack (); + } + + //---------------------------------------------------------------------------- + + ~LuaException() throw () + { + } + + //---------------------------------------------------------------------------- + + char const* what() const throw () + { + return m_what.c_str(); + } + + //============================================================================ + /** + Throw an exception. + + This centralizes all the exceptions thrown, so that we can set + breakpoints before the stack is unwound, or otherwise customize the + behavior. + */ + template + static void Throw (Exception e) + { + throw e; + } + + //---------------------------------------------------------------------------- + /** + Wrapper for lua_pcall that throws. + */ + static void pcall (lua_State* L, int nargs = 0, int nresults = 0, int msgh = 0) + { + int code = lua_pcall (L, nargs, nresults, msgh); + + if (code != LUABRIDGE_LUA_OK) + Throw (LuaException (L, code)); + } + + //---------------------------------------------------------------------------- + +protected: + void whatFromStack () + { + if (lua_gettop (m_L) > 0) + { + char const* s = lua_tostring (m_L, -1); + m_what = s ? s : ""; + } + else + { + // stack is empty + m_what = "missing error"; + } + } +}; + +} // namespace luabridge + +``` + +`LuaBridge/detail/LuaHelpers.h`: + +```h +//------------------------------------------------------------------------------ +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco + Copyright 2007, Nathan Reed + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +//============================================================================== + +#pragma once + +#include + +namespace luabridge { + +// These are for Lua versions prior to 5.2.0. +// +#if LUA_VERSION_NUM < 502 +inline int lua_absindex (lua_State* L, int idx) +{ + if (idx > LUA_REGISTRYINDEX && idx < 0) + return lua_gettop (L) + idx + 1; + else + return idx; +} + +inline void lua_rawgetp (lua_State* L, int idx, void const* p) +{ + idx = lua_absindex (L, idx); + lua_pushlightuserdata (L, const_cast (p)); + lua_rawget (L,idx); +} + +inline void lua_rawsetp (lua_State* L, int idx, void const* p) +{ + idx = lua_absindex (L, idx); + lua_pushlightuserdata (L, const_cast (p)); + // put key behind value + lua_insert (L, -2); + lua_rawset (L, idx); +} + +#define LUA_OPEQ 1 +#define LUA_OPLT 2 +#define LUA_OPLE 3 + +inline int lua_compare (lua_State* L, int idx1, int idx2, int op) +{ + switch (op) + { + case LUA_OPEQ: + return lua_equal (L, idx1, idx2); + break; + + case LUA_OPLT: + return lua_lessthan (L, idx1, idx2); + break; + + case LUA_OPLE: + return lua_equal (L, idx1, idx2) || lua_lessthan (L, idx1, idx2); + break; + + default: + return 0; + }; +} + +inline int get_length (lua_State* L, int idx) +{ + return int (lua_objlen (L, idx)); +} + +#else +inline int get_length (lua_State* L, int idx) +{ + lua_len (L, idx); + int len = int (luaL_checknumber (L, -1)); + lua_pop (L, 1); + return len; +} + +#endif + +#ifndef LUA_OK +# define LUABRIDGE_LUA_OK 0 +#else +# define LUABRIDGE_LUA_OK LUA_OK +#endif + +/** Get a table value, bypassing metamethods. +*/ +inline void rawgetfield (lua_State* L, int index, char const* key) +{ + assert (lua_istable (L, index)); + index = lua_absindex (L, index); + lua_pushstring (L, key); + lua_rawget (L, index); +} + +/** Set a table value, bypassing metamethods. +*/ +inline void rawsetfield (lua_State* L, int index, char const* key) +{ + assert (lua_istable (L, index)); + index = lua_absindex (L, index); + lua_pushstring (L, key); + lua_insert (L, -2); + lua_rawset (L, index); +} + +/** Returns true if the value is a full userdata (not light). +*/ +inline bool isfulluserdata (lua_State* L, int index) +{ + return lua_isuserdata (L, index) && !lua_islightuserdata (L, index); +} + +/** Test lua_State objects for global equality. + + This can determine if two different lua_State objects really point + to the same global state, such as when using coroutines. + + @note This is used for assertions. +*/ +inline bool equalstates (lua_State* L1, lua_State* L2) +{ + return lua_topointer (L1, LUA_REGISTRYINDEX) == + lua_topointer (L2, LUA_REGISTRYINDEX); +} + +} // namespace luabridge + +``` + +`LuaBridge/detail/LuaRef.h`: + +```h +//------------------------------------------------------------------------------ +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2018, Dmitry Tarakanov + Copyright 2012, Vinnie Falco + Copyright 2008, Nigel Atkinson + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +//============================================================================== + +#pragma once + +#include "LuaBridge/detail/LuaException.h" +#include "LuaBridge/detail/Stack.h" + +#include +#include +#include +#include + +namespace luabridge { + +//------------------------------------------------------------------------------ +/** + Type tag for representing LUA_TNIL. + + Construct one of these using `Nil()` to represent a Lua nil. This is faster + than creating a reference in the registry to nil. Example: + + LuaRef t (LuaRef::createTable (L)); + ... + t ["k"] = Nil(); // assign nil +*/ +struct Nil +{ +}; + + +//------------------------------------------------------------------------------ +/** + Stack specialization for Nil. +*/ +template <> +struct Stack +{ + static void push (lua_State* L, Nil) + { + lua_pushnil (L); + } +}; + +/** + * Base class for LuaRef and table value proxy classes. + */ +template +class LuaRefBase +{ +protected: + //---------------------------------------------------------------------------- + /** + Pop the Lua stack. + + Pops the specified number of stack items on destruction. We use this + when returning objects, to avoid an explicit temporary variable, since + the destructor executes after the return statement. For example: + + template + U cast (lua_State* L) + { + StackPop p (L, 1); + ... + return U (); // dtor called after this line + } + + @note The `StackPop` object must always be a named local variable. + */ + class StackPop + { + public: + /** Create a StackPop object. + + @param count The number of stack entries to pop on destruction. + */ + StackPop (lua_State* L, int count) + : m_L (L) + , m_count (count) + { + } + + ~StackPop () + { + lua_pop (m_L, m_count); + } + + private: + lua_State* m_L; + int m_count; + }; + + friend struct Stack ; + + //---------------------------------------------------------------------------- + /** + Type tag for stack construction. + */ + struct FromStack { }; + + LuaRefBase (lua_State* L) + : m_L (L) + { + } + + //---------------------------------------------------------------------------- + /** + Create a reference to this ref. + + This is used internally. + */ + int createRef () const + { + impl ().push (); + return luaL_ref (m_L, LUA_REGISTRYINDEX); + } + +public: + //---------------------------------------------------------------------------- + /** + converts to a string using luas tostring function + */ + std::string tostring() const + { + lua_getglobal (m_L, "tostring"); + impl ().push (); + lua_call (m_L, 1, 1); + const char* str = lua_tostring (m_L, -1); + lua_pop (m_L, 1); + return std::string(str); + } + + //---------------------------------------------------------------------------- + /** + Print a text description of the value to a stream. + + This is used for diagnostics. + */ + void print (std::ostream& os) const + { + switch (type ()) + { + case LUA_TNIL: + os << "nil"; + break; + + case LUA_TNUMBER: + os << cast (); + break; + + case LUA_TBOOLEAN: + os << (cast () ? "true" : "false"); + break; + + case LUA_TSTRING: + os << '"' << cast () << '"'; + break; + + case LUA_TTABLE: + os << "table: " << tostring(); + break; + + case LUA_TFUNCTION: + os << "function: " << tostring(); + break; + + case LUA_TUSERDATA: + os << "userdata: " << tostring(); + break; + + case LUA_TTHREAD: + os << "thread: " << tostring(); + break; + + case LUA_TLIGHTUSERDATA: + os << "lightuserdata: " << tostring(); + break; + + default: + os << "unknown"; + break; + } + } + + //------------------------------------------------------------------------------ + /** + Write a LuaRef to a stream. + + This allows LuaRef and table proxies to work with streams. + */ + friend std::ostream& operator<< (std::ostream& os, LuaRefBase const& ref) + { + ref.print (os); + return os; + } + + //============================================================================ + // + // This group of member functions is mirrored in Proxy + // + + /** Retrieve the lua_State associated with the reference. + */ + lua_State* state () const + { + return m_L; + } + + //---------------------------------------------------------------------------- + /** + Place the object onto the Lua stack. + */ + void push (lua_State* L) const + { + assert (equalstates (L, m_L)); + (void) L; + impl ().push (); + } + + //---------------------------------------------------------------------------- + /** + Pop the top of Lua stack and assign the ref to m_ref + */ + void pop (lua_State* L) + { + assert (equalstates (L, m_L)); + (void) L; + impl ().pop (); + } + + //---------------------------------------------------------------------------- + /** + Determine the object type. + + The return values are the same as for `lua_type`. + */ + /** @{ */ + int type () const + { + impl ().push (); + StackPop p (m_L, 1); + return lua_type (m_L, -1); + } + + // should never happen + // bool isNone () const { return m_ref == LUA_NOREF; } + + bool isNil () const { return type () == LUA_TNIL; } + bool isBool () const { return type () == LUA_TBOOLEAN; } + bool isNumber () const { return type () == LUA_TNUMBER; } + bool isString () const { return type () == LUA_TSTRING; } + bool isTable () const { return type () == LUA_TTABLE; } + bool isFunction () const { return type () == LUA_TFUNCTION; } + bool isUserdata () const { return type () == LUA_TUSERDATA; } + bool isThread () const { return type () == LUA_TTHREAD; } + bool isLightUserdata () const { return type () == LUA_TLIGHTUSERDATA; } + + /** @} */ + + //---------------------------------------------------------------------------- + /** + Perform an explicit conversion. + */ + template + T cast () const + { + StackPop p (m_L, 1); + impl ().push (); + + // lua_gettop is used because Userdata::getClass() doesn't handle + // negative stack indexes. + // + return Stack ::get (m_L, lua_gettop (m_L)); + } + + //---------------------------------------------------------------------------- + /** + Universal implicit conversion operator. + + NOTE: Visual Studio 2010 and 2012 have a bug where this function + is not used. See: + + http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/e30b2664-a92d-445c-9db2-e8e0fbde2014 + https://connect.microsoft.com/VisualStudio/feedback/details/771509/correct-code-doesnt-compile + + // This code snippet fails to compile in vs2010,vs2012 + struct S { + template operator T () const { return T (); } + }; + int main () { + S () || false; + return 0; + } + */ + template + operator T () const + { + return cast (); + } + + //---------------------------------------------------------------------------- + /** + Universal comparison operators. + */ + /** @{ */ + template + bool operator== (T rhs) const + { + StackPop p (m_L, 2); + impl ().push (); + Stack ::push (m_L, rhs); + return lua_compare (m_L, -2, -1, LUA_OPEQ) == 1; + } + + template + bool operator< (T rhs) const + { + StackPop p (m_L, 2); + impl ().push ();; + Stack ::push (m_L, rhs); + int lhsType = lua_type (m_L, -2); + int rhsType = lua_type (m_L, -1); + if (lhsType != rhsType) + { + return lhsType < rhsType; + } + return lua_compare (m_L, -2, -1, LUA_OPLT) == 1; + } + + template + bool operator<= (T rhs) const + { + StackPop p (m_L, 2); + impl ().push ();; + Stack ::push (m_L, rhs); + int lhsType = lua_type (m_L, -2); + int rhsType = lua_type (m_L, -1); + if (lhsType != rhsType) + { + return lhsType <= rhsType; + } + return lua_compare (m_L, -2, -1, LUA_OPLE) == 1; + } + + template + bool operator> (T rhs) const + { + StackPop p (m_L, 2); + impl ().push ();; + Stack ::push (m_L, rhs); + int lhsType = lua_type (m_L, -2); + int rhsType = lua_type (m_L, -1); + if (lhsType != rhsType) + { + return lhsType > rhsType; + } + return lua_compare (m_L, -1, -2, LUA_OPLT) == 1; + } + + template + bool operator>= (T rhs) const + { + StackPop p (m_L, 2); + impl ().push ();; + Stack ::push (m_L, rhs); + int lhsType = lua_type (m_L, -2); + int rhsType = lua_type (m_L, -1); + if (lhsType != rhsType) + { + return lhsType >= rhsType; + } + return lua_compare (m_L, -1, -2, LUA_OPLE) == 1; + } + + template + bool rawequal (T rhs) const + { + StackPop p (m_L, 2); + impl ().push ();; + Stack ::push (m_L, rhs); + return lua_rawequal (m_L, -1, -2) == 1; + } + /** @} */ + + //---------------------------------------------------------------------------- + /** + Append a value to the table. + + If the table is a sequence this will add another element to it. + */ + template + void append (T v) const + { + impl ().push ();; + Stack ::push (m_L, v); + luaL_ref (m_L, -2); + lua_pop (m_L, 1); + } + + //---------------------------------------------------------------------------- + /** + Call the length operator. + + This is identical to applying the Lua # operator. + */ + int length () const + { + StackPop p (m_L, 1); + impl ().push ();; + return get_length (m_L, -1); + } + + //---------------------------------------------------------------------------- + /** + Call Lua code. + + These overloads allow Lua code to be called with up to 8 parameters. + The return value is provided as a LuaRef (which may be LUA_REFNIL). + If an error occurs, a LuaException is thrown. + */ + /** @{ */ + LuaRef operator() () const + { + impl ().push ();; + LuaException::pcall (m_L, 0, 1); + return LuaRef::fromStack (m_L); + } + + template + LuaRef operator() (P1 p1) const + { + impl ().push ();; + Stack ::push (m_L, p1); + LuaException::pcall (m_L, 1, 1); + return LuaRef::fromStack (m_L); + } + + template + LuaRef operator() (P1 p1, P2 p2) const + { + impl ().push ();; + Stack ::push (m_L, p1); + Stack ::push (m_L, p2); + LuaException::pcall (m_L, 2, 1); + return LuaRef::fromStack (m_L); + } + + template + LuaRef operator() (P1 p1, P2 p2, P3 p3) const + { + impl ().push ();; + Stack ::push (m_L, p1); + Stack ::push (m_L, p2); + Stack ::push (m_L, p3); + LuaException::pcall (m_L, 3, 1); + return LuaRef::fromStack (m_L); + } + + template + LuaRef operator() (P1 p1, P2 p2, P3 p3, P4 p4) const + { + impl ().push ();; + Stack ::push (m_L, p1); + Stack ::push (m_L, p2); + Stack ::push (m_L, p3); + Stack ::push (m_L, p4); + LuaException::pcall (m_L, 4, 1); + return LuaRef::fromStack (m_L); + } + + template + LuaRef operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) const + { + impl ().push ();; + Stack ::push (m_L, p1); + Stack ::push (m_L, p2); + Stack ::push (m_L, p3); + Stack ::push (m_L, p4); + Stack ::push (m_L, p5); + LuaException::pcall (m_L, 5, 1); + return LuaRef::fromStack (m_L); + } + + template + LuaRef operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) const + { + impl ().push ();; + Stack ::push (m_L, p1); + Stack ::push (m_L, p2); + Stack ::push (m_L, p3); + Stack ::push (m_L, p4); + Stack ::push (m_L, p5); + Stack ::push (m_L, p6); + LuaException::pcall (m_L, 6, 1); + return LuaRef::fromStack (m_L); + } + + template + LuaRef operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) const + { + impl ().push ();; + Stack ::push (m_L, p1); + Stack ::push (m_L, p2); + Stack ::push (m_L, p3); + Stack ::push (m_L, p4); + Stack ::push (m_L, p5); + Stack ::push (m_L, p6); + Stack ::push (m_L, p7); + LuaException::pcall (m_L, 7, 1); + return LuaRef::fromStack (m_L); + } + + template + LuaRef operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) const + { + impl ().push (); + Stack ::push (m_L, p1); + Stack ::push (m_L, p2); + Stack ::push (m_L, p3); + Stack ::push (m_L, p4); + Stack ::push (m_L, p5); + Stack ::push (m_L, p6); + Stack ::push (m_L, p7); + Stack ::push (m_L, p8); + LuaException::pcall (m_L, 8, 1); + return LuaRef::fromStack (m_L); + } + /** @} */ + + //============================================================================ + +protected: + lua_State* m_L; + +private: + const Impl& impl() const + { + return static_cast (*this); + } + + Impl& impl() + { + return static_cast (*this); + } +}; + +//------------------------------------------------------------------------------ +/** + Lightweight reference to a Lua object. + + The reference is maintained for the lifetime of the C++ object. +*/ +class LuaRef : public LuaRefBase +{ + //---------------------------------------------------------------------------- + /** + A proxy for representing table values. + */ + class Proxy : public LuaRefBase + { + friend class LuaRef; + + public: + //-------------------------------------------------------------------------- + /** + Construct a Proxy from a table value. + + The table is in the registry, and the key is at the top of the stack. + The key is popped off the stack. + */ + Proxy (lua_State* L, int tableRef) + : LuaRefBase (L) + , m_tableRef (LUA_NOREF) + , m_keyRef (luaL_ref (L, LUA_REGISTRYINDEX)) + { + lua_rawgeti (m_L, LUA_REGISTRYINDEX, tableRef); + m_tableRef = luaL_ref (L, LUA_REGISTRYINDEX); + } + + //-------------------------------------------------------------------------- + /** + Create a Proxy via copy constructor. + + It is best to avoid code paths that invoke this, because it creates + an extra temporary Lua reference. Typically this is done by passing + the Proxy parameter as a `const` reference. + */ + Proxy (Proxy const& other) + : LuaRefBase (other.m_L) + , m_tableRef (LUA_NOREF) + , m_keyRef (LUA_NOREF) + { + lua_rawgeti (m_L, LUA_REGISTRYINDEX, other.m_tableRef); + m_tableRef = luaL_ref (m_L, LUA_REGISTRYINDEX); + + lua_rawgeti (m_L, LUA_REGISTRYINDEX, other.m_keyRef); + m_keyRef = luaL_ref (m_L, LUA_REGISTRYINDEX); + } + + //-------------------------------------------------------------------------- + /** + Destroy the proxy. + + This does not destroy the table value. + */ + ~Proxy () + { + luaL_unref (m_L, LUA_REGISTRYINDEX, m_keyRef); + luaL_unref (m_L, LUA_REGISTRYINDEX, m_tableRef); + } + + //-------------------------------------------------------------------------- + /** + Assign a new value to this table key. + + This may invoke metamethods. + */ + template + Proxy& operator= (T v) + { + StackPop p (m_L, 1); + lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_tableRef); + lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_keyRef); + Stack ::push (m_L, v); + lua_settable (m_L, -3); + return *this; + } + + //-------------------------------------------------------------------------- + /** + Assign a new value to this table key. + + The assignment is raw, no metamethods are invoked. + */ + template + Proxy& rawset (T v) + { + StackPop p (m_L, 1); + lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_tableRef); + lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_keyRef); + Stack ::push (m_L, v); + lua_rawset (m_L, -3); + return *this; + } + + //-------------------------------------------------------------------------- + /** + Push the value onto the Lua stack. + */ + using LuaRefBase::push; + + void push () const + { + lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_tableRef); + lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_keyRef); + lua_gettable (m_L, -2); + lua_remove (m_L, -2); // remove the table + } + + //-------------------------------------------------------------------------- + /** + Access a table value using a key. + + This invokes metamethods. + */ + template + Proxy operator[] (T key) const + { + return LuaRef (*this) [key]; + } + + //-------------------------------------------------------------------------- + /** + Access a table value using a key. + + The operation is raw, metamethods are not invoked. The result is + passed by value and may not be modified. + */ + template + LuaRef rawget (T key) const + { + return LuaRef (*this).rawget (key); + } + + private: + int m_tableRef; + int m_keyRef; + }; + + friend struct Stack ; + + //---------------------------------------------------------------------------- + /** + Create a reference to an object at the top of the Lua stack and pop it. + + This constructor is private and not invoked directly. + Instead, use the `fromStack` function. + + @note The object is popped. + */ + LuaRef (lua_State* L, FromStack) + : LuaRefBase (L) + , m_ref (luaL_ref (m_L, LUA_REGISTRYINDEX)) + { + } + + //---------------------------------------------------------------------------- + /** + Create a reference to an object on the Lua stack. + + This constructor is private and not invoked directly. + Instead, use the `fromStack` function. + + @note The object is not popped. + */ + LuaRef (lua_State* L, int index, FromStack) + : LuaRefBase (L) + , m_ref (LUA_NOREF) + { + lua_pushvalue (m_L, index); + m_ref = luaL_ref (m_L, LUA_REGISTRYINDEX); + } + + +public: + //---------------------------------------------------------------------------- + /** + Create a nil reference. + + The LuaRef may be assigned later. + */ + LuaRef (lua_State* L) + : LuaRefBase (L) + , m_ref (LUA_NOREF) + { + } + + //---------------------------------------------------------------------------- + /** + Create a reference to a value. + */ + template + LuaRef (lua_State* L, T v) + : LuaRefBase (L) + , m_ref (LUA_NOREF) + { + Stack ::push (m_L, v); + m_ref = luaL_ref (m_L, LUA_REGISTRYINDEX); + } + + //---------------------------------------------------------------------------- + /** + Create a reference to a table value. + */ + LuaRef (Proxy const& v) + : LuaRefBase (v.state ()) + , m_ref (v.createRef ()) + { + } + + //---------------------------------------------------------------------------- + /** + Create a new reference to an existing reference. + */ + LuaRef (LuaRef const& other) + : LuaRefBase (other.m_L) + , m_ref (other.createRef ()) + { + } + + //---------------------------------------------------------------------------- + /** + Destroy a reference. + + The corresponding Lua registry reference will be released. + + @note If the state refers to a thread, it is the responsibility of the + caller to ensure that the thread still exists when the LuaRef + is destroyed. + */ + ~LuaRef () + { + luaL_unref (m_L, LUA_REGISTRYINDEX, m_ref); + } + + //---------------------------------------------------------------------------- + /** + Return a LuaRef from a top stack item. + + The stack item is not popped. + */ + static LuaRef fromStack (lua_State* L) + { + return LuaRef (L, FromStack ()); + } + + //---------------------------------------------------------------------------- + /** + Return a LuaRef from a stack item. + + The stack item is not popped. + */ + static LuaRef fromStack (lua_State* L, int index) + { + lua_pushvalue (L, index); + return LuaRef (L, FromStack ()); + } + + //---------------------------------------------------------------------------- + /** + Create a new empty table and return a reference to it. + + It is also possible to use the free function `newTable`. + + @see ::luabridge::newTable + */ + static LuaRef newTable (lua_State* L) + { + lua_newtable (L); + return LuaRef (L, FromStack ()); + } + + //---------------------------------------------------------------------------- + /** + Return a reference to a named global. + + It is also possible to use the free function `getGlobal`. + + @see ::luabridge::getGlobal + */ + static LuaRef getGlobal (lua_State *L, char const* name) + { + lua_getglobal (L, name); + return LuaRef (L, FromStack ()); + } + + //---------------------------------------------------------------------------- + /** + Assign another LuaRef to this LuaRef. + */ + LuaRef& operator= (LuaRef const& rhs) + { + LuaRef ref (rhs); + swap (ref); + return *this; + } + + //---------------------------------------------------------------------------- + /** + Assign Proxy to this LuaRef. + */ + LuaRef& operator= (LuaRef::Proxy const& rhs) + { + LuaRef ref (rhs); + swap (ref); + return *this; + } + + //---------------------------------------------------------------------------- + /** + Assign nil to this LuaRef. + */ + LuaRef& operator= (Nil const&) + { + LuaRef ref (m_L); + swap (ref); + return *this; + } + + //---------------------------------------------------------------------------- + /** + Assign a different value to this LuaRef. + */ + template + LuaRef& operator= (T rhs) + { + LuaRef ref (m_L, rhs); + swap (ref); + return *this; + } + + //---------------------------------------------------------------------------- + /** + Place the object onto the Lua stack. + */ + using LuaRefBase::push; + + void push () const + { + lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_ref); + } + + //---------------------------------------------------------------------------- + /** + Pop the top of Lua stack and assign the ref to m_ref + */ + void pop () + { + luaL_unref (m_L, LUA_REGISTRYINDEX, m_ref); + m_ref = luaL_ref (m_L, LUA_REGISTRYINDEX); + } + + //---------------------------------------------------------------------------- + /** + Access a table value using a key. + + This invokes metamethods. + */ + template + Proxy operator[] (T key) const + { + Stack ::push (m_L, key); + return Proxy (m_L, m_ref); + } + + //-------------------------------------------------------------------------- + /** + Access a table value using a key. + + The operation is raw, metamethods are not invoked. The result is + passed by value and may not be modified. + */ + template + LuaRef rawget (T key) const + { + StackPop (m_L, 1); + push (m_L); + Stack ::push (m_L, key); + lua_rawget (m_L, -2); + return LuaRef (m_L, FromStack ()); + } + +private: + void swap (LuaRef& other) + { + std::swap (m_L, other.m_L); + std::swap (m_ref, other.m_ref); + } + + int m_ref; +}; + +//------------------------------------------------------------------------------ +/** + Stack specialization for LuaRef. +*/ +template <> +struct Stack +{ + // The value is const& to prevent a copy construction. + // + static void push (lua_State* L, LuaRef const& v) + { + v.push (L); + } + + static LuaRef get (lua_State* L, int index) + { + return LuaRef::fromStack (L, index); + } +}; + +//------------------------------------------------------------------------------ +/** + Stack specialization for Proxy. +*/ +template <> +struct Stack +{ + // The value is const& to prevent a copy construction. + // + static void push (lua_State* L, LuaRef::Proxy const& v) + { + v.push (L); + } +}; + +//------------------------------------------------------------------------------ +/** + Create a reference to a new, empty table. + + This is a syntactic abbreviation for LuaRef::newTable(). +*/ +inline LuaRef newTable (lua_State* L) +{ + return LuaRef::newTable (L); +} + +//------------------------------------------------------------------------------ +/** + Create a reference to a value in the global table. + + This is a syntactic abbreviation for LuaRef::getGlobal(). +*/ +inline LuaRef getGlobal (lua_State *L, char const* name) +{ + return LuaRef::getGlobal (L, name); +} + +//------------------------------------------------------------------------------ + +// more C++-like cast syntax +// +template +T LuaRef_cast(LuaRef const& lr) +{ + return lr.cast(); +} + +} // namespace luabridge + +``` + +`LuaBridge/detail/Namespace.h`: + +```h +//------------------------------------------------------------------------------ +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco + Copyright 2007, Nathan Reed + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +//============================================================================== + +#pragma once + +#include "LuaBridge/detail/Security.h" +#include "LuaBridge/detail/TypeTraits.h" + +#include +#include + +namespace luabridge { + +/** Provides C++ to Lua registration capabilities. + + This class is not instantiated directly, call `getGlobalNamespace` to start + the registration process. +*/ +class Namespace +{ +private: + Namespace& operator= (Namespace const& other); + + lua_State* const L; + int mutable m_stackSize; + +private: + //============================================================================ + /** + Error reporting. + + VF: This function looks handy, why aren't we using it? + */ +#if 0 + static int luaError (lua_State* L, std::string message) + { + assert (lua_isstring (L, lua_upvalueindex (1))); + std::string s; + + // Get information on the caller's caller to format the message, + // so the error appears to originate from the Lua source. + lua_Debug ar; + int result = lua_getstack (L, 2, &ar); + if (result != 0) + { + lua_getinfo (L, "Sl", &ar); + s = ar.short_src; + if (ar.currentline != -1) + { + // poor mans int to string to avoid . + lua_pushnumber (L, ar.currentline); + s = s + ":" + lua_tostring (L, -1) + ": "; + lua_pop (L, 1); + } + } + + s = s + message; + + return luaL_error (L, s.c_str ()); + } +#endif + + //---------------------------------------------------------------------------- + /** + Pop the Lua stack. + */ + void pop (int n) const + { + if (m_stackSize >= n && lua_gettop (L) >= n) + { + lua_pop (L, n); + m_stackSize -= n; + } + else + { + throw std::logic_error ("invalid stack"); + } + } + +private: + /** + Factored base to reduce template instantiations. + */ + class ClassBase + { + private: + ClassBase& operator= (ClassBase const& other); + + protected: + friend class Namespace; + + lua_State* const L; + int mutable m_stackSize; + + protected: + //-------------------------------------------------------------------------- + /** + __index metamethod for a class. + + This implements member functions, data members, and property members. + Functions are stored in the metatable and const metatable. Data members + and property members are in the __propget table. + + If the key is not found, the search proceeds up the hierarchy of base + classes. + */ + static int indexMetaMethod (lua_State* L) + { + int result = 0; + + assert (lua_isuserdata (L, 1)); // warn on security bypass + lua_getmetatable (L, 1); // get metatable for object + for (;;) + { + lua_pushvalue (L, 2); // push key arg2 + lua_rawget (L, -2); // lookup key in metatable + if (lua_iscfunction (L, -1)) // ensure its a cfunction + { + lua_remove (L, -2); // remove metatable + result = 1; + break; + } + else if (lua_isnil (L, -1)) + { + lua_pop (L, 1); + } + else + { + lua_pop (L, 2); + throw std::logic_error ("not a cfunction"); + } + + rawgetfield (L, -1, "__propget"); // get __propget table + if (lua_istable (L, -1)) // ensure it is a table + { + lua_pushvalue (L, 2); // push key arg2 + lua_rawget (L, -2); // lookup key in __propget + lua_remove (L, -2); // remove __propget + if (lua_iscfunction (L, -1)) // ensure its a cfunction + { + lua_remove (L, -2); // remove metatable + lua_pushvalue (L, 1); // push class arg1 + lua_call (L, 1, 1); + result = 1; + break; + } + else if (lua_isnil (L, -1)) + { + lua_pop (L, 1); + } + else + { + lua_pop (L, 2); + + // We only put cfunctions into __propget. + throw std::logic_error ("not a cfunction"); + } + } + else + { + lua_pop (L, 2); + + // __propget is missing, or not a table. + throw std::logic_error ("missing __propget table"); + } + + // Repeat the lookup in the __parent metafield, + // or return nil if the field doesn't exist. + rawgetfield (L, -1, "__parent"); + if (lua_istable (L, -1)) + { + // Remove metatable and repeat the search in __parent. + lua_remove (L, -2); + } + else if (lua_isnil (L, -1)) + { + result = 1; + break; + } + else + { + lua_pop (L, 2); + + throw std::logic_error ("__parent is not a table"); + } + } + + return result; + } + + //-------------------------------------------------------------------------- + /** + __newindex metamethod for classes. + + This supports writable variables and properties on class objects. The + corresponding object is passed in the first parameter to the set function. + */ + static int newindexMetaMethod (lua_State* L) + { + int result = 0; + + lua_getmetatable (L, 1); + + for (;;) + { + // Check __propset + rawgetfield (L, -1, "__propset"); + if (!lua_isnil (L, -1)) + { + lua_pushvalue (L, 2); + lua_rawget (L, -2); + if (!lua_isnil (L, -1)) + { + // found it, call the setFunction. + assert (lua_isfunction (L, -1)); + lua_pushvalue (L, 1); + lua_pushvalue (L, 3); + lua_call (L, 2, 0); + result = 0; + break; + } + lua_pop (L, 1); + } + lua_pop (L, 1); + + // Repeat the lookup in the __parent metafield. + rawgetfield (L, -1, "__parent"); + if (lua_isnil (L, -1)) + { + // Either the property or __parent must exist. + result = luaL_error (L, + "no member named '%s'", lua_tostring (L, 2)); + } + lua_remove (L, -2); + } + + return result; + } + + //-------------------------------------------------------------------------- + /** + Create the const table. + */ + void createConstTable (char const* name) + { + lua_newtable (L); + lua_pushvalue (L, -1); + lua_setmetatable (L, -2); + lua_pushboolean (L, 1); + lua_rawsetp (L, -2, getIdentityKey ()); + lua_pushstring (L, (std::string ("const ") + name).c_str ()); + rawsetfield (L, -2, "__type"); + lua_pushcfunction (L, &indexMetaMethod); + rawsetfield (L, -2, "__index"); + lua_pushcfunction (L, &newindexMetaMethod); + rawsetfield (L, -2, "__newindex"); + lua_newtable (L); + rawsetfield (L, -2, "__propget"); + + if (Security::hideMetatables ()) + { + lua_pushnil (L); + rawsetfield (L, -2, "__metatable"); + } + } + + //-------------------------------------------------------------------------- + /** + Create the class table. + + The Lua stack should have the const table on top. + */ + void createClassTable (char const* name) + { + lua_newtable (L); + lua_pushvalue (L, -1); + lua_setmetatable (L, -2); + lua_pushboolean (L, 1); + lua_rawsetp (L, -2, getIdentityKey ()); + lua_pushstring (L, name); + rawsetfield (L, -2, "__type"); + lua_pushcfunction (L, &indexMetaMethod); + rawsetfield (L, -2, "__index"); + lua_pushcfunction (L, &newindexMetaMethod); + rawsetfield (L, -2, "__newindex"); + lua_newtable (L); + rawsetfield (L, -2, "__propget"); + lua_newtable (L); + rawsetfield (L, -2, "__propset"); + + lua_pushvalue (L, -2); + rawsetfield (L, -2, "__const"); // point to const table + + lua_pushvalue (L, -1); + rawsetfield (L, -3, "__class"); // point const table to class table + + if (Security::hideMetatables ()) + { + lua_pushnil (L); + rawsetfield (L, -2, "__metatable"); + } + } + + //-------------------------------------------------------------------------- + /** + Create the static table. + + The Lua stack should have: + -1 class table + -2 const table + -3 enclosing namespace + */ + void createStaticTable (char const* name) + { + lua_newtable (L); + lua_newtable (L); + lua_pushvalue (L, -1); + lua_setmetatable (L, -3); + lua_insert (L, -2); + rawsetfield (L, -5, name); + +#if 0 + lua_pushlightuserdata (L, this); + lua_pushcclosure (L, &tostringMetaMethod, 1); + rawsetfield (L, -2, "__tostring"); +#endif + lua_pushcfunction (L, &CFunc::indexMetaMethod); + rawsetfield (L, -2, "__index"); + lua_pushcfunction (L, &CFunc::newindexMetaMethod); + rawsetfield (L, -2, "__newindex"); + lua_newtable (L); + rawsetfield (L, -2, "__propget"); + lua_newtable (L); + rawsetfield (L, -2, "__propset"); + + lua_pushvalue (L, -2); + rawsetfield (L, -2, "__class"); // point to class table + + if (Security::hideMetatables ()) + { + lua_pushnil (L); + rawsetfield (L, -2, "__metatable"); + } + } + + //========================================================================== + /** + lua_CFunction to construct a class object wrapped in a container. + */ + template + static int ctorContainerProxy (lua_State* L) + { + typedef typename ContainerTraits ::Type T; + ArgList args (L); + T* const p = Constructor ::call (args); + UserdataSharedHelper ::push (L, p); + return 1; + } + + //-------------------------------------------------------------------------- + /** + lua_CFunction to construct a class object in-place in the userdata. + */ + template + static int ctorPlacementProxy (lua_State* L) + { + ArgList args (L); + Constructor ::call (UserdataValue ::place (L), args); + return 1; + } + + //-------------------------------------------------------------------------- + /** + Pop the Lua stack. + */ + void pop (int n) const + { + if (m_stackSize >= n && lua_gettop (L) >= n) + { + lua_pop (L, n); + m_stackSize -= n; + } + else + { + throw std::logic_error ("invalid stack"); + } + } + + public: + //-------------------------------------------------------------------------- + explicit ClassBase (lua_State* L_) + : L (L_) + , m_stackSize (0) + { + } + + //-------------------------------------------------------------------------- + /** + Copy Constructor. + */ + ClassBase (ClassBase const& other) + : L (other.L) + , m_stackSize (0) + { + m_stackSize = other.m_stackSize; + other.m_stackSize = 0; + } + + ~ClassBase () + { + pop (m_stackSize); + } + }; + + //============================================================================ + // + // Class + // + //============================================================================ + /** + Provides a class registration in a lua_State. + + After contstruction the Lua stack holds these objects: + -1 static table + -2 class table + -3 const table + -4 (enclosing namespace) + */ + template + class Class : public ClassBase + { + public: + //========================================================================== + /** + Register a new class or add to an existing class registration. + */ + Class (char const* name, Namespace const* parent) : ClassBase (parent->L) + { + m_stackSize = parent->m_stackSize + 3; + parent->m_stackSize = 0; + + assert (lua_istable (L, -1)); + rawgetfield (L, -1, name); + + if (lua_isnil (L, -1)) + { + lua_pop (L, 1); + + createConstTable (name); + lua_pushcfunction (L, &CFunc::gcMetaMethod ); + rawsetfield (L, -2, "__gc"); + + createClassTable (name); + lua_pushcfunction (L, &CFunc::gcMetaMethod ); + rawsetfield (L, -2, "__gc"); + + createStaticTable (name); + + // Map T back to its tables. + lua_pushvalue (L, -1); + lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo ::getStaticKey ()); + lua_pushvalue (L, -2); + lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo ::getClassKey ()); + lua_pushvalue (L, -3); + lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo ::getConstKey ()); + } + else + { + // Map T back from its stored tables + lua_rawgetp(L, LUA_REGISTRYINDEX, ClassInfo ::getClassKey()); + lua_rawgetp(L, LUA_REGISTRYINDEX, ClassInfo ::getConstKey()); + + // Reverse the top 3 stack elements + lua_insert (L, -3); + lua_insert (L, -2); + } + } + + //========================================================================== + /** + Derive a new class. + */ + Class (char const* name, Namespace const* parent, void const* const staticKey) + : ClassBase (parent->L) + { + m_stackSize = parent->m_stackSize + 3; + parent->m_stackSize = 0; + + assert (lua_istable (L, -1)); + + createConstTable (name); + lua_pushcfunction (L, &CFunc::gcMetaMethod ); + rawsetfield (L, -2, "__gc"); + + createClassTable (name); + lua_pushcfunction (L, &CFunc::gcMetaMethod ); + rawsetfield (L, -2, "__gc"); + + createStaticTable (name); + + lua_rawgetp (L, LUA_REGISTRYINDEX, staticKey); + assert (lua_istable (L, -1)); + rawgetfield (L, -1, "__class"); + assert (lua_istable (L, -1)); + rawgetfield (L, -1, "__const"); + assert (lua_istable (L, -1)); + + rawsetfield (L, -6, "__parent"); + rawsetfield (L, -4, "__parent"); + rawsetfield (L, -2, "__parent"); + + lua_pushvalue (L, -1); + lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo ::getStaticKey ()); + lua_pushvalue (L, -2); + lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo ::getClassKey ()); + lua_pushvalue (L, -3); + lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo ::getConstKey ()); + } + + //-------------------------------------------------------------------------- + /** + Continue registration in the enclosing namespace. + */ + Namespace endClass () + { + return Namespace (this); + } + + //-------------------------------------------------------------------------- + /** + Add or replace a static data member. + */ + template + Class & addStaticData (char const* name, U* pu, bool isWritable = true) + { + assert (lua_istable (L, -1)); + + rawgetfield (L, -1, "__propget"); + assert (lua_istable (L, -1)); + lua_pushlightuserdata (L, pu); + lua_pushcclosure (L, &CFunc::getVariable , 1); + rawsetfield (L, -2, name); + lua_pop (L, 1); + + rawgetfield (L, -1, "__propset"); + assert (lua_istable (L, -1)); + if (isWritable) + { + lua_pushlightuserdata (L, pu); + lua_pushcclosure (L, &CFunc::setVariable , 1); + } + else + { + lua_pushstring (L, name); + lua_pushcclosure (L, &CFunc::readOnlyError, 1); + } + rawsetfield (L, -2, name); + lua_pop (L, 1); + + return *this; + } + + //-------------------------------------------------------------------------- + /** + Add or replace a static property member. + + If the set function is null, the property is read-only. + */ + template + Class & addStaticProperty (char const* name, U (*get)(), void (*set)(U) = 0) + { + typedef U (*get_t)(); + typedef void (*set_t)(U); + + assert (lua_istable (L, -1)); + + rawgetfield (L, -1, "__propget"); + assert (lua_istable (L, -1)); + new (lua_newuserdata (L, sizeof (get))) get_t (get); + lua_pushcclosure (L, &CFunc::Call ::f, 1); + rawsetfield (L, -2, name); + lua_pop (L, 1); + + rawgetfield (L, -1, "__propset"); + assert (lua_istable (L, -1)); + if (set != 0) + { + new (lua_newuserdata (L, sizeof (set))) set_t (set); + lua_pushcclosure (L, &CFunc::Call ::f, 1); + } + else + { + lua_pushstring (L, name); + lua_pushcclosure (L, &CFunc::readOnlyError, 1); + } + rawsetfield (L, -2, name); + lua_pop (L, 1); + + return *this; + } + + //-------------------------------------------------------------------------- + /** + Add or replace a static member function. + */ + template + Class & addStaticFunction (char const* name, FP const fp) + { + new (lua_newuserdata (L, sizeof (fp))) FP (fp); + lua_pushcclosure (L, &CFunc::Call ::f, 1); + rawsetfield (L, -2, name); + + return *this; + } + + //-------------------------------------------------------------------------- + /** + Add or replace a lua_CFunction. + */ + Class & addStaticCFunction (char const* name, int (*const fp)(lua_State*)) + { + lua_pushcfunction (L, fp); + rawsetfield (L, -2, name); + return *this; + } + + //-------------------------------------------------------------------------- + /** + Add or replace a data member. + */ + template + Class & addData (char const* name, const U T::* mp, bool isWritable = true) + { + typedef const U T::*mp_t; + + // Add to __propget in class and const tables. + { + rawgetfield (L, -2, "__propget"); + rawgetfield (L, -4, "__propget"); + new (lua_newuserdata (L, sizeof (mp_t))) mp_t (mp); + lua_pushcclosure (L, &CFunc::getProperty , 1); + lua_pushvalue (L, -1); + rawsetfield (L, -4, name); + rawsetfield (L, -2, name); + lua_pop (L, 2); + } + + if (isWritable) + { + // Add to __propset in class table. + rawgetfield (L, -2, "__propset"); + assert (lua_istable (L, -1)); + new (lua_newuserdata (L, sizeof (mp_t))) mp_t (mp); + lua_pushcclosure (L, &CFunc::setProperty , 1); + rawsetfield (L, -2, name); + lua_pop (L, 1); + } + + return *this; + } + + //-------------------------------------------------------------------------- + /** + Add or replace a property member. + */ + template + Class & addProperty (char const* name, TG (T::* get) () const, void (T::* set) (TS)) + { + // Add to __propget in class and const tables. + { + rawgetfield (L, -2, "__propget"); + rawgetfield (L, -4, "__propget"); + typedef TG (T::*get_t) () const; + new (lua_newuserdata (L, sizeof (get_t))) get_t (get); + lua_pushcclosure (L, &CFunc::CallConstMember ::f, 1); + lua_pushvalue (L, -1); + rawsetfield (L, -4, name); + rawsetfield (L, -2, name); + lua_pop (L, 2); + } + + { + // Add to __propset in class table. + rawgetfield (L, -2, "__propset"); + assert (lua_istable (L, -1)); + typedef void (T::* set_t) (TS); + new (lua_newuserdata (L, sizeof (set_t))) set_t (set); + lua_pushcclosure (L, &CFunc::CallMember ::f, 1); + rawsetfield (L, -2, name); + lua_pop (L, 1); + } + + return *this; + } + + // read-only + template + Class & addProperty (char const* name, TG (T::* get) () const) + { + // Add to __propget in class and const tables. + rawgetfield (L, -2, "__propget"); + rawgetfield (L, -4, "__propget"); + typedef TG (T::*get_t) () const; + new (lua_newuserdata (L, sizeof (get_t))) get_t (get); + lua_pushcclosure (L, &CFunc::CallConstMember ::f, 1); + lua_pushvalue (L, -1); + rawsetfield (L, -4, name); + rawsetfield (L, -2, name); + lua_pop (L, 2); + + return *this; + } + + //-------------------------------------------------------------------------- + /** + Add or replace a property member, by proxy. + + When a class is closed for modification and does not provide (or cannot + provide) the function signatures necessary to implement get or set for + a property, this will allow non-member functions act as proxies. + + Both the get and the set functions require a T const* and T* in the first + argument respectively. + */ + template + Class & addProperty (char const* name, TG (*get) (T const*), void (*set) (T*, TS) = 0) + { + // Add to __propget in class and const tables. + { + rawgetfield (L, -2, "__propget"); + rawgetfield (L, -4, "__propget"); + typedef TG (*get_t) (T const*); + new (lua_newuserdata (L, sizeof (get_t))) get_t (get); + lua_pushcclosure (L, &CFunc::Call ::f, 1); + lua_pushvalue (L, -1); + rawsetfield (L, -4, name); + rawsetfield (L, -2, name); + lua_pop (L, 2); + } + + if (set != 0) + { + // Add to __propset in class table. + rawgetfield (L, -2, "__propset"); + assert (lua_istable (L, -1)); + typedef void (*set_t) (T*, TS); + new (lua_newuserdata (L, sizeof (set_t))) set_t (set); + lua_pushcclosure (L, &CFunc::Call ::f, 1); + rawsetfield (L, -2, name); + lua_pop (L, 1); + } + + return *this; + } + + //-------------------------------------------------------------------------- + /** + Add or replace a member function. + */ + template + Class & addFunction (char const* name, MemFn mf) + { + CFunc::CallMemberFunctionHelper ::isConstMemberFunction>::add (L, name, mf); + return *this; + } + + //-------------------------------------------------------------------------- + /** + Add or replace a member lua_CFunction. + */ + Class & addCFunction (char const* name, int (T::*mfp)(lua_State*)) + { + typedef int (T::*MFP)(lua_State*); + assert (lua_istable (L, -1)); + new (lua_newuserdata (L, sizeof (mfp))) MFP (mfp); + lua_pushcclosure (L, &CFunc::CallMemberCFunction ::f, 1); + rawsetfield (L, -3, name); // class table + + return *this; + } + + //-------------------------------------------------------------------------- + /** + Add or replace a const member lua_CFunction. + */ + Class & addCFunction (char const* name, int (T::*mfp)(lua_State*) const) + { + typedef int (T::*MFP)(lua_State*) const; + assert (lua_istable (L, -1)); + new (lua_newuserdata (L, sizeof (mfp))) MFP (mfp); + lua_pushcclosure (L, &CFunc::CallConstMemberCFunction ::f, 1); + lua_pushvalue (L, -1); + rawsetfield (L, -5, name); // const table + rawsetfield (L, -3, name); // class table + + return *this; + } + + //-------------------------------------------------------------------------- + /** + Add or replace a primary Constructor. + + The primary Constructor is invoked when calling the class type table + like a function. + + The template parameter should be a function pointer type that matches + the desired Constructor (since you can't take the address of a Constructor + and pass it as an argument). + */ + template + Class & addConstructor () + { + lua_pushcclosure (L, + &ctorContainerProxy ::Params, C>, 0); + rawsetfield(L, -2, "__call"); + + return *this; + } + + template + Class & addConstructor () + { + lua_pushcclosure (L, + &ctorPlacementProxy ::Params, T>, 0); + rawsetfield(L, -2, "__call"); + + return *this; + } + }; + +private: + //---------------------------------------------------------------------------- + /** + Open the global namespace for registrations. + */ + explicit Namespace (lua_State* L_) + : L (L_) + , m_stackSize (1) + { + lua_getglobal (L, "_G"); + } + + //---------------------------------------------------------------------------- + /** + Open a namespace for registrations. + + The namespace is created if it doesn't already exist. + The parent namespace is at the top of the Lua stack. + */ + Namespace (char const* name, Namespace const* parent) + : L (parent->L) + , m_stackSize (0) + { + m_stackSize = parent->m_stackSize + 1; + parent->m_stackSize = 0; + + assert (lua_istable (L, -1)); + rawgetfield (L, -1, name); + if (lua_isnil (L, -1)) + { + lua_pop (L, 1); + + lua_newtable (L); + lua_pushvalue (L, -1); + lua_setmetatable (L, -2); + lua_pushcfunction (L, &CFunc::indexMetaMethod); + rawsetfield (L, -2, "__index"); + lua_pushcfunction (L, &CFunc::newindexMetaMethod); + rawsetfield (L, -2, "__newindex"); + lua_newtable (L); + rawsetfield (L, -2, "__propget"); + lua_newtable (L); + rawsetfield (L, -2, "__propset"); + lua_pushvalue (L, -1); + rawsetfield (L, -3, name); +#if 0 + lua_pushcfunction (L, &tostringMetaMethod); + rawsetfield (L, -2, "__tostring"); +#endif + } + } + + //---------------------------------------------------------------------------- + /** + Creates a continued registration from a child namespace. + */ + explicit Namespace (Namespace const* child) + : L (child->L) + , m_stackSize (0) + { + m_stackSize = child->m_stackSize - 1; + child->m_stackSize = 1; + child->pop (1); + + // It is not necessary or valid to call + // endNamespace() for the global namespace! + // + assert (m_stackSize != 0); + } + + //---------------------------------------------------------------------------- + /** + Creates a continued registration from a child class. + */ + explicit Namespace (ClassBase const* child) + : L (child->L) + , m_stackSize (0) + { + m_stackSize = child->m_stackSize - 3; + child->m_stackSize = 3; + child->pop (3); + } + +public: + //---------------------------------------------------------------------------- + /** + Copy Constructor. + + Ownership of the stack is transferred to the new object. This happens + when the compiler emits temporaries to hold these objects while chaining + registrations across namespaces. + */ + Namespace (Namespace const& other) : L (other.L) + { + m_stackSize = other.m_stackSize; + other.m_stackSize = 0; + } + + //---------------------------------------------------------------------------- + /** + Closes this namespace registration. + */ + ~Namespace () + { + pop (m_stackSize); + } + + //---------------------------------------------------------------------------- + /** + Open the global namespace. + */ + static Namespace getGlobalNamespace (lua_State* L) + { + return Namespace (L); + } + + //---------------------------------------------------------------------------- + /** + Open a new or existing namespace for registrations. + */ + Namespace beginNamespace (char const* name) + { + return Namespace (name, this); + } + + //---------------------------------------------------------------------------- + /** + Continue namespace registration in the parent. + + Do not use this on the global namespace. + */ + Namespace endNamespace () + { + return Namespace (this); + } + + //---------------------------------------------------------------------------- + /** + Add or replace a variable. + */ + template + Namespace& addVariable (char const* name, T* pt, bool isWritable = true) + { + if (m_stackSize == 1) + { + throw std::logic_error ("Unsupported addVariable on global namespace"); + } + + assert (lua_istable (L, -1)); + + rawgetfield (L, -1, "__propget"); + assert (lua_istable (L, -1)); + lua_pushlightuserdata (L, pt); + lua_pushcclosure (L, &CFunc::getVariable , 1); + rawsetfield (L, -2, name); + lua_pop (L, 1); + + rawgetfield (L, -1, "__propset"); + assert (lua_istable (L, -1)); + if (isWritable) + { + lua_pushlightuserdata (L, pt); + lua_pushcclosure (L, &CFunc::setVariable , 1); + } + else + { + lua_pushstring (L, name); + lua_pushcclosure (L, &CFunc::readOnlyError, 1); + } + rawsetfield (L, -2, name); + lua_pop (L, 1); + + return *this; + } + + //---------------------------------------------------------------------------- + /** + Add or replace a property. + + If the set function is omitted or null, the property is read-only. + */ + template + Namespace& addProperty (char const* name, TG (*get) (), void (*set)(TS) = 0) + { + if (m_stackSize == 1) + { + throw std::logic_error ("Unsupported addProperty on global namespace"); + } + + assert (lua_istable (L, -1)); + + rawgetfield (L, -1, "__propget"); + assert (lua_istable (L, -1)); + typedef TG (*get_t) (); + new (lua_newuserdata (L, sizeof (get_t))) get_t (get); + lua_pushcclosure (L, &CFunc::Call ::f, 1); + rawsetfield (L, -2, name); + lua_pop (L, 1); + + rawgetfield (L, -1, "__propset"); + assert (lua_istable (L, -1)); + if (set != 0) + { + typedef void (*set_t) (TS); + new (lua_newuserdata (L, sizeof (set_t))) set_t (set); + lua_pushcclosure (L, &CFunc::Call ::f, 1); + } + else + { + lua_pushstring (L, name); + lua_pushcclosure (L, &CFunc::readOnlyError, 1); + } + rawsetfield (L, -2, name); + lua_pop (L, 1); + + return *this; + } + + //---------------------------------------------------------------------------- + /** + Add or replace a free function. + */ + template + Namespace& addFunction (char const* name, FP const fp) + { + assert (lua_istable (L, -1)); + + new (lua_newuserdata (L, sizeof (fp))) FP (fp); + lua_pushcclosure (L, &CFunc::Call ::f, 1); + rawsetfield (L, -2, name); + + return *this; + } + + //---------------------------------------------------------------------------- + /** + Add or replace a lua_CFunction. + */ + Namespace& addCFunction (char const* name, int (*const fp)(lua_State*)) + { + lua_pushcfunction (L, fp); + rawsetfield (L, -2, name); + + return *this; + } + + //---------------------------------------------------------------------------- + /** + Open a new or existing class for registrations. + */ + template + Class beginClass (char const* name) + { + return Class (name, this); + } + + //---------------------------------------------------------------------------- + /** + Derive a new class for registrations. + + To continue registrations for the class later, use beginClass(). + Do not call deriveClass() again. + */ + template + Class deriveClass (char const* name) + { + return Class (name, this, ClassInfo ::getStaticKey ()); + } +}; + +//------------------------------------------------------------------------------ +/** + Retrieve the global namespace. + + It is recommended to put your namespace inside the global namespace, and + then add your classes and functions to it, rather than adding many classes + and functions directly to the global namespace. +*/ +inline Namespace getGlobalNamespace (lua_State* L) +{ + return Namespace::getGlobalNamespace (L); +} + +} // namespace luabridge + +``` + +`LuaBridge/detail/Security.h`: + +```h +#pragma once + +namespace luabridge { + +//------------------------------------------------------------------------------ +/** +security options. +*/ +class Security +{ +public: + static bool hideMetatables() + { + return getSettings().hideMetatables; + } + + static void setHideMetatables(bool shouldHide) + { + getSettings().hideMetatables = shouldHide; + } + +private: + struct Settings + { + Settings() : hideMetatables(true) + { + } + + bool hideMetatables; + }; + + static Settings& getSettings() + { + static Settings settings; + return settings; + } +}; + +//------------------------------------------------------------------------------ +/** +Push an object onto the Lua stack. +*/ +template +inline void push(lua_State* L, T t) +{ + Stack ::push(L, t); +} + +//------------------------------------------------------------------------------ +/** +Set a global value in the lua_State. + +@note This works on any type specialized by `Stack`, including `LuaRef` and +its table proxies. +*/ +template +inline void setGlobal(lua_State* L, T t, char const* name) +{ + push(L, t); + lua_setglobal(L, name); +} + +//------------------------------------------------------------------------------ +/** +Change whether or not metatables are hidden (on by default). +*/ +inline void setHideMetatables(bool shouldHide) +{ + Security::setHideMetatables(shouldHide); +} + +} // namespace luabridge + +``` + +`LuaBridge/detail/Stack.h`: + +```h +//------------------------------------------------------------------------------ +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco + Copyright 2007, Nathan Reed + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +//============================================================================== + +#pragma once + +#include "LuaBridge/detail/LuaHelpers.h" + +#include + +namespace luabridge { + +template +struct Stack; + +//------------------------------------------------------------------------------ +/** + Receive the lua_State* as an argument. +*/ +template <> +struct Stack +{ + static lua_State* get (lua_State* L, int) + { + return L; + } +}; + +//------------------------------------------------------------------------------ +/** + Push a lua_CFunction. +*/ +template <> +struct Stack +{ + static void push (lua_State* L, lua_CFunction f) + { + lua_pushcfunction (L, f); + } + + static lua_CFunction get (lua_State* L, int index) + { + return lua_tocfunction (L, index); + } +}; + +//------------------------------------------------------------------------------ +/** + Stack specialization for `int`. +*/ +template <> +struct Stack +{ + static inline void push (lua_State* L, int value) + { + lua_pushinteger (L, static_cast (value)); + } + + static inline int get (lua_State* L, int index) + { + return static_cast (luaL_checkinteger (L, index)); + } +}; + +template <> +struct Stack : public Stack +{ +}; + +//------------------------------------------------------------------------------ +/** + Stack specialization for `unsigned int`. +*/ +template <> +struct Stack +{ + static inline void push (lua_State* L, unsigned int value) + { + lua_pushinteger (L, static_cast (value)); + } + + static inline unsigned int get (lua_State* L, int index) + { + return static_cast (luaL_checkinteger (L, index)); + } +}; + +template <> +struct Stack : Stack +{ +}; + +//------------------------------------------------------------------------------ +/** + Stack specialization for `unsigned char`. +*/ +template <> +struct Stack +{ + static inline void push (lua_State* L, unsigned char value) + { + lua_pushinteger (L, static_cast (value)); + } + + static inline unsigned char get (lua_State* L, int index) + { + return static_cast (luaL_checkinteger (L, index)); + } +}; + +template <> +struct Stack : Stack +{ +}; + +//------------------------------------------------------------------------------ +/** + Stack specialization for `short`. +*/ +template <> +struct Stack +{ + static inline void push (lua_State* L, short value) + { + lua_pushinteger (L, static_cast (value)); + } + + static inline short get (lua_State* L, int index) + { + return static_cast (luaL_checkinteger (L, index)); + } +}; + +template <> +struct Stack : Stack +{ +}; + +//------------------------------------------------------------------------------ +/** + Stack specialization for `unsigned short`. +*/ +template <> +struct Stack +{ + static inline void push (lua_State* L, unsigned short value) + { + lua_pushinteger (L, static_cast (value)); + } + + static inline unsigned short get (lua_State* L, int index) + { + return static_cast (luaL_checkinteger (L, index)); + } +}; + +template <> +struct Stack : Stack +{ +}; + +//------------------------------------------------------------------------------ +/** + Stack specialization for `long`. +*/ +template <> +struct Stack +{ + static inline void push (lua_State* L, long value) + { + lua_pushinteger (L, static_cast (value)); + } + + static inline long get (lua_State* L, int index) + { + return static_cast (luaL_checkinteger (L, index)); + } +}; + +template <> +struct Stack : public Stack +{ +}; + +//------------------------------------------------------------------------------ +/** + Stack specialization for `unsigned long`. +*/ +template <> +struct Stack +{ + static inline void push (lua_State* L, unsigned long value) + { + lua_pushinteger (L, static_cast (value)); + } + + static inline unsigned long get (lua_State* L, int index) + { + return static_cast (luaL_checkinteger (L, index)); + } +}; + +template <> +struct Stack : public Stack +{ +}; + +//------------------------------------------------------------------------------ +/** + Stack specialization for `float`. +*/ +template <> +struct Stack +{ + static inline void push (lua_State* L, float value) + { + lua_pushnumber (L, static_cast (value)); + } + + static inline float get (lua_State* L, int index) + { + return static_cast (luaL_checknumber (L, index)); + } +}; + +template <> +struct Stack : Stack +{ +}; + +//------------------------------------------------------------------------------ +/** + Stack specialization for `double`. +*/ +template <> struct Stack +{ + static inline void push (lua_State* L, double value) + { + lua_pushnumber (L, static_cast (value)); + } + + static inline double get (lua_State* L, int index) + { + return static_cast (luaL_checknumber (L, index)); + } +}; + +template <> +struct Stack : Stack +{ +}; + +//------------------------------------------------------------------------------ +/** + Stack specialization for `bool`. +*/ +template <> +struct Stack +{ + static inline void push (lua_State* L, bool value) + { + lua_pushboolean (L, value ? 1 : 0); + } + + static inline bool get (lua_State* L, int index) + { + return lua_toboolean (L, index) ? true : false; + } +}; + +template <> +struct Stack : Stack +{ +}; + +//------------------------------------------------------------------------------ +/** + Stack specialization for `char`. +*/ +template <> +struct Stack +{ + static inline void push (lua_State* L, char value) + { + lua_pushlstring (L, &value, 1); + } + + static inline char get (lua_State* L, int index) + { + return luaL_checkstring (L, index) [0]; + } +}; + +template <> +struct Stack : Stack +{ +}; + +//------------------------------------------------------------------------------ +/** + Stack specialization for `const char*`. +*/ +template <> +struct Stack +{ + static inline void push (lua_State* L, char const* str) + { + if (str != 0) + lua_pushstring (L, str); + else + lua_pushnil (L); + } + + static inline char const* get (lua_State* L, int index) + { + return lua_isnil (L, index) ? 0 : luaL_checkstring (L, index); + } +}; + +//------------------------------------------------------------------------------ +/** + Stack specialization for `std::string`. +*/ +template <> +struct Stack +{ + static inline void push (lua_State* L, std::string const& str) + { + lua_pushlstring (L, str.data (), str.size()); + } + + static inline std::string get (lua_State* L, int index) + { + size_t len; + const char *str = luaL_checklstring (L, index, &len); + return std::string (str, len); + } +}; + +template <> +struct Stack : Stack +{ +}; + +//------------------------------------------------------------------------------ +/** +Stack specialization for `long long`. +*/ +template <> +struct Stack +{ + static inline void push (lua_State* L, long long value) + { + lua_pushinteger (L, static_cast (value)); + } + static inline long long get (lua_State* L, int index) + { + return static_cast (luaL_checkinteger (L, index)); + } +}; + +template <> +struct Stack : public Stack +{ +}; + +//------------------------------------------------------------------------------ +/** +Stack specialization for `unsigned long long`. +*/ +template <> +struct Stack +{ + static inline void push (lua_State* L, unsigned long long value) + { + lua_pushinteger (L, static_cast (value)); + } + static inline unsigned long long get (lua_State* L, int index) + { + return static_cast (luaL_checkinteger (L, index)); + } +}; + +template <> +struct Stack : Stack +{ +}; + +} // namespace luabridge + +``` + +`LuaBridge/detail/TypeList.h`: + +```h +//------------------------------------------------------------------------------ +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco + Copyright 2007, Nathan Reed + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + + This file incorporates work covered by the following copyright and + permission notice: + + The Loki Library + Copyright (c) 2001 by Andrei Alexandrescu + This code accompanies the book: + Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design + Patterns Applied". Copyright (c) 2001. Addison-Wesley. + Permission to use, copy, modify, distribute and sell this software for any + purpose is hereby granted without fee, provided that the above copyright + notice appear in all copies and that both that copyright notice and this + permission notice appear in supporting documentation. + The author or Addison-Welsey Longman make no representations about the + suitability of this software for any purpose. It is provided "as is" + without express or implied warranty. +*/ +//============================================================================== + +#pragma once + +#include "LuaBridge/detail/Stack.h" + +#include +#include + +namespace luabridge { + +/** + None type means void parameters or return value. +*/ +typedef void None; + +template +struct TypeList +{ +}; + +/** + A TypeList with actual values. +*/ +template +struct TypeListValues +{ + static std::string const tostring (bool) + { + return ""; + } +}; + +/** + TypeListValues recursive template definition. +*/ +template +struct TypeListValues > +{ + Head hd; + TypeListValues tl; + + TypeListValues (Head hd_, TypeListValues const& tl_) + : hd (hd_), tl (tl_) + { + } + + static std::string const tostring (bool comma = false) + { + std::string s; + + if (comma) + s = ", "; + + s = s + typeid (Head).name (); + + return s + TypeListValues ::tostring (true); + } +}; + +// Specializations of type/value list for head types that are references and +// const-references. We need to handle these specially since we can't count +// on the referenced object hanging around for the lifetime of the list. + +template +struct TypeListValues > +{ + Head hd; + TypeListValues tl; + + TypeListValues (Head& hd_, TypeListValues const& tl_) + : hd (hd_), tl (tl_) + { + } + + static std::string const tostring (bool comma = false) + { + std::string s; + + if (comma) + s = ", "; + + s = s + typeid (Head).name () + "&"; + + return s + TypeListValues ::tostring (true); + } +}; + +template +struct TypeListValues > +{ + Head hd; + TypeListValues tl; + + TypeListValues (Head const& hd_, const TypeListValues & tl_) + : hd (hd_), tl (tl_) + { + } + + static std::string const tostring (bool comma = false) + { + std::string s; + + if (comma) + s = ", "; + + s = s + typeid (Head).name () + " const&"; + + return s + TypeListValues ::tostring (true); + } +}; + +//============================================================================== +/** + Subclass of a TypeListValues constructable from the Lua stack. +*/ + +template +struct ArgList +{ +}; + +template +struct ArgList : public TypeListValues +{ + ArgList (lua_State*) + { + } +}; + +template +struct ArgList , Start> + : public TypeListValues > +{ + ArgList (lua_State* L) + : TypeListValues > (Stack ::get (L, Start), + ArgList (L)) + { + } +}; + +} // namespace luabridge + +``` + +`LuaBridge/detail/TypeTraits.h`: + +```h +//------------------------------------------------------------------------------ +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +//============================================================================== + +#pragma once + +namespace luabridge { + +//------------------------------------------------------------------------------ +/** + Container traits. + + Unspecialized ContainerTraits has the isNotContainer typedef for SFINAE. + All user defined containers must supply an appropriate specialization for + ContinerTraits (without the typedef isNotContainer). The containers that + come with LuaBridge also come with the appropriate ContainerTraits + specialization. See the corresponding declaration for details. + + A specialization of ContainerTraits for some generic type ContainerType + looks like this: + + template + struct ContainerTraits > + { + typedef typename T Type; + + static T* get (ContainerType const& c) + { + return c.get (); // Implementation-dependent on ContainerType + } + }; +*/ +template +struct ContainerTraits +{ + typedef bool isNotContainer; + typedef T Type; +}; + +//------------------------------------------------------------------------------ +/** + Type traits. + + Specializations return information about a type. +*/ +struct TypeTraits +{ + /** Determine if type T is a container. + + To be considered a container, there must be a specialization of + ContainerTraits with the required fields. + */ + template + class isContainer + { + private: + typedef char yes[1]; // sizeof (yes) == 1 + typedef char no [2]; // sizeof (no) == 2 + + template + static no& test (typename C::isNotContainer*); + + template + static yes& test (...); + + public: + static const bool value = sizeof (test >(0)) == sizeof (yes); + }; + + /** Determine if T is const qualified. + */ + /** @{ */ + template + struct isConst + { + static bool const value = false; + }; + + template + struct isConst + { + static bool const value = true; + }; + /** @} */ + + /** Remove the const qualifier from T. + */ + /** @{ */ + template + struct removeConst + { + typedef T Type; + }; + + template + struct removeConst + { + typedef T Type; + }; + /**@}*/ +}; + +} // namespace luabridge + +``` + +`LuaBridge/detail/Userdata.h`: + +```h +//------------------------------------------------------------------------------ +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +//============================================================================== + +#pragma once + +#include "LuaBridge/detail/TypeList.h" + +#include + +namespace luabridge { + +//============================================================================== +/** + Return the identity pointer for our lightuserdata tokens. + + LuaBridge metatables are tagged with a security "token." The token is a + lightuserdata created from the identity pointer, used as a key in the + metatable. The value is a boolean = true, although any value could have been + used. + + Because of Lua's dynamic typing and our improvised system of imposing C++ + class structure, there is the possibility that executing scripts may + knowingly or unknowingly cause invalid data to get passed to the C functions + created by LuaBridge. In particular, our security model addresses the + following: + + Notes: + 1. Scripts cannot create a userdata (ignoring the debug lib). + 2. Scripts cannot create a lightuserdata (ignoring the debug lib). + 3. Scripts cannot set the metatable on a userdata. + 4. Our identity key is a unique pointer in the process. + 5. Our metatables have a lightuserdata identity key / value pair. + 6. Our metatables have "__metatable" set to a boolean = false. + 7. Our lightuserdata is unique. +*/ +inline void* getIdentityKey () +{ + static char value; + return &value; +} + +/** + Interface to a class pointer retrievable from a userdata. +*/ +class Userdata +{ +protected: + void* m_p; // subclasses must set this + + //-------------------------------------------------------------------------- + /** + Get an untyped pointer to the contained class. + */ + inline void* const getPointer () + { + return m_p; + } + +private: + //-------------------------------------------------------------------------- + /** + Validate and retrieve a Userdata on the stack. + + The Userdata must exactly match the corresponding class table or + const table, or else a Lua error is raised. This is used for the + __gc metamethod. + */ + static Userdata* getExactClass (lua_State* L, + int narg, + void const* classKey) + { + Userdata* ud = 0; + int const index = lua_absindex (L, narg); + + bool mismatch = false; + char const* got = 0; + + lua_rawgetp (L, LUA_REGISTRYINDEX, classKey); + assert (lua_istable (L, -1)); + + // Make sure we have a userdata. + if (!lua_isuserdata (L, index)) + mismatch = true; + + // Make sure it's metatable is ours. + if (!mismatch) + { + lua_getmetatable (L, index); + lua_rawgetp (L, -1, getIdentityKey ()); + if (lua_isboolean (L, -1)) + { + lua_pop (L, 1); + } + else + { + lua_pop (L, 2); + mismatch = true; + } + } + + if (!mismatch) + { + if (lua_rawequal (L, -1, -2)) + { + // Matches class table. + lua_pop (L, 2); + ud = static_cast (lua_touserdata (L, index)); + } + else + { + rawgetfield (L, -2, "__const"); + if (lua_rawequal (L, -1, -2)) + { + // Matches const table + lua_pop (L, 3); + ud = static_cast (lua_touserdata (L, index)); + } + else + { + // Mismatch, but its one of ours so get a type name. + rawgetfield (L, -2, "__type"); + lua_insert (L, -4); + lua_pop (L, 2); + got = lua_tostring (L, -2); + mismatch = true; + } + } + } + + if (mismatch) + { + rawgetfield (L, -1, "__type"); + assert (lua_type (L, -1) == LUA_TSTRING); + char const* const expected = lua_tostring (L, -1); + + if (got == 0) + got = lua_typename (L, lua_type (L, index)); + + char const* const msg = lua_pushfstring ( + L, "%s expected, got %s", expected, got); + + if (narg > 0) + luaL_argerror (L, narg, msg); + else + lua_error (L); + } + + return ud; + } + + //-------------------------------------------------------------------------- + /** + Validate and retrieve a Userdata on the stack. + + The Userdata must be derived from or the same as the given base class, + identified by the key. If canBeConst is false, generates an error if + the resulting Userdata represents to a const object. We do the type check + first so that the error message is informative. + */ + static Userdata* getClass (lua_State* L, + int index, + void const* baseClassKey, + bool canBeConst) + { + assert (index > 0); + Userdata* ud = 0; + + bool mismatch = false; + char const* got = 0; + + lua_rawgetp (L, LUA_REGISTRYINDEX, baseClassKey); + assert (lua_istable (L, -1)); + + // Make sure we have a userdata. + if (lua_isuserdata (L, index)) + { + // Make sure it's metatable is ours. + lua_getmetatable (L, index); + lua_rawgetp (L, -1, getIdentityKey ()); + if (lua_isboolean (L, -1)) + { + lua_pop (L, 1); + + // If __const is present, object is NOT const. + rawgetfield (L, -1, "__const"); + assert (lua_istable (L, -1) || lua_isnil (L, -1)); + bool const isConst = lua_isnil (L, -1); + lua_pop (L, 1); + + // Replace the class table with the const table if needed. + if (isConst) + { + rawgetfield (L, -2, "__const"); + assert (lua_istable (L, -1)); + lua_replace (L, -3); + } + + for (;;) + { + if (lua_rawequal (L, -1, -2)) + { + lua_pop (L, 2); + + // Match, now check const-ness. + if (isConst && !canBeConst) + { + luaL_argerror (L, index, "cannot be const"); + } + else + { + ud = static_cast (lua_touserdata (L, index)); + break; + } + } + else + { + // Replace current metatable with it's base class. + rawgetfield (L, -1, "__parent"); +/* +ud +class metatable +ud metatable +ud __parent (nil) +*/ + + if (lua_isnil (L, -1)) + { + lua_remove (L, -1); + // Mismatch, but its one of ours so get a type name. + rawgetfield (L, -1, "__type"); + lua_insert (L, -3); + lua_pop (L, 1); + got = lua_tostring (L, -2); + mismatch = true; + break; + } + else + { + lua_remove (L, -2); + } + } + } + } + else + { + lua_pop (L, 2); + mismatch = true; + } + } + else + { + mismatch = true; + } + + if (mismatch) + { + assert (lua_type (L, -1) == LUA_TTABLE); + rawgetfield (L, -1, "__type"); + assert (lua_type (L, -1) == LUA_TSTRING); + char const* const expected = lua_tostring (L, -1); + + if (got == 0) + got = lua_typename (L, lua_type (L, index)); + + char const* const msg = lua_pushfstring ( + L, "%s expected, got %s", expected, got); + + luaL_argerror (L, index, msg); + } + + return ud; + } + +public: + virtual ~Userdata () { } + + //-------------------------------------------------------------------------- + /** + Returns the Userdata* if the class on the Lua stack matches. + + If the class does not match, a Lua error is raised. + */ + template + static inline Userdata* getExact (lua_State* L, int index) + { + return getExactClass (L, index, ClassInfo ::getClassKey ()); + } + + //-------------------------------------------------------------------------- + /** + Get a pointer to the class from the Lua stack. + + If the object is not the class or a subclass, or it violates the + const-ness, a Lua error is raised. + */ + template + static inline T* get (lua_State* L, int index, bool canBeConst) + { + if (lua_isnil (L, index)) + return 0; + else + return static_cast (getClass (L, index, + ClassInfo ::getClassKey (), canBeConst)->getPointer ()); + } +}; + +//---------------------------------------------------------------------------- +/** + Wraps a class object stored in a Lua userdata. + + The lifetime of the object is managed by Lua. The object is constructed + inside the userdata using placement new. +*/ +template +class UserdataValue : public Userdata +{ +private: + UserdataValue (UserdataValue const&); + UserdataValue operator= (UserdataValue const&); + + char m_storage [sizeof (T)]; + + inline T* getObject () + { + // If this fails to compile it means you forgot to provide + // a Container specialization for your container! + // + return reinterpret_cast (&m_storage [0]); + } + +private: + /** + Used for placement construction. + */ + UserdataValue () + { + m_p = getObject (); + } + + ~UserdataValue () + { + getObject ()->~T (); + } + +public: + /** + Push a T via placement new. + + The caller is responsible for calling placement new using the + returned uninitialized storage. + */ + static void* place (lua_State* const L) + { + UserdataValue * const ud = new ( + lua_newuserdata (L, sizeof (UserdataValue ))) UserdataValue (); + lua_rawgetp (L, LUA_REGISTRYINDEX, ClassInfo ::getClassKey ()); + // If this goes off it means you forgot to register the class! + assert (lua_istable (L, -1)); + lua_setmetatable (L, -2); + return ud->getPointer (); + } + + /** + Push T via copy construction from U. + */ + template + static inline void push (lua_State* const L, U const& u) + { + new (place (L)) U (u); + } +}; + +//---------------------------------------------------------------------------- +/** + Wraps a pointer to a class object inside a Lua userdata. + + The lifetime of the object is managed by C++. +*/ +class UserdataPtr : public Userdata +{ +private: + UserdataPtr (UserdataPtr const&); + UserdataPtr operator= (UserdataPtr const&); + +private: + /** Push non-const pointer to object using metatable key. + */ + static void push (lua_State* L, void* const p, void const* const key) + { + if (p) + { + new (lua_newuserdata (L, sizeof (UserdataPtr))) UserdataPtr (p); + lua_rawgetp (L, LUA_REGISTRYINDEX, key); + // If this goes off it means you forgot to register the class! + assert (lua_istable (L, -1)); + lua_setmetatable (L, -2); + } + else + { + lua_pushnil (L); + } + } + + /** Push const pointer to object using metatable key. + */ + static void push (lua_State* L, void const* const p, void const* const key) + { + if (p) + { + new (lua_newuserdata (L, sizeof (UserdataPtr))) + UserdataPtr (const_cast (p)); + lua_rawgetp (L, LUA_REGISTRYINDEX, key); + // If this goes off it means you forgot to register the class! + assert (lua_istable (L, -1)); + lua_setmetatable (L, -2); + } + else + { + lua_pushnil (L); + } + } + + explicit UserdataPtr (void* const p) + { + m_p = p; + + // Can't construct with a null pointer! + // + assert (m_p != 0); + } + +public: + /** Push non-const pointer to object. + */ + template + static inline void push (lua_State* const L, T* const p) + { + if (p) + push (L, p, ClassInfo ::getClassKey ()); + else + lua_pushnil (L); + } + + /** Push const pointer to object. + */ + template + static inline void push (lua_State* const L, T const* const p) + { + if (p) + push (L, p, ClassInfo ::getConstKey ()); + else + lua_pushnil (L); + } +}; + +//============================================================================ +/** + Wraps a container thet references a class object. + + The template argument C is the container type, ContainerTraits must be + specialized on C or else a compile error will result. +*/ +template +class UserdataShared : public Userdata +{ +private: + UserdataShared (UserdataShared const&); + UserdataShared & operator= (UserdataShared const&); + + typedef typename TypeTraits::removeConst < + typename ContainerTraits ::Type>::Type T; + + C m_c; + +private: + ~UserdataShared () + { + } + +public: + /** + Construct from a container to the class or a derived class. + */ + template + explicit UserdataShared (U const& u) : m_c (u) + { + m_p = const_cast (reinterpret_cast ( + (ContainerTraits ::get (m_c)))); + } + + /** + Construct from a pointer to the class or a derived class. + */ + template + explicit UserdataShared (U* u) : m_c (u) + { + m_p = const_cast (reinterpret_cast ( + (ContainerTraits ::get (m_c)))); + } +}; + +//---------------------------------------------------------------------------- +// +// SFINAE helpers. +// + +// non-const objects +template +struct UserdataSharedHelper +{ + typedef typename TypeTraits::removeConst < + typename ContainerTraits ::Type>::Type T; + + static void push (lua_State* L, C const& c) + { + if (ContainerTraits ::get (c) != 0) + { + new (lua_newuserdata (L, sizeof (UserdataShared ))) UserdataShared (c); + lua_rawgetp (L, LUA_REGISTRYINDEX, ClassInfo ::getClassKey ()); + // If this goes off it means the class T is unregistered! + assert (lua_istable (L, -1)); + lua_setmetatable (L, -2); + } + else + { + lua_pushnil (L); + } + } + + static void push (lua_State* L, T* const t) + { + if (t) + { + new (lua_newuserdata (L, sizeof (UserdataShared ))) UserdataShared (t); + lua_rawgetp (L, LUA_REGISTRYINDEX, ClassInfo ::getClassKey ()); + // If this goes off it means the class T is unregistered! + assert (lua_istable (L, -1)); + lua_setmetatable (L, -2); + } + else + { + lua_pushnil (L); + } + } +}; + +// const objects +template +struct UserdataSharedHelper +{ + typedef typename TypeTraits::removeConst < + typename ContainerTraits ::Type>::Type T; + + static void push (lua_State* L, C const& c) + { + if (ContainerTraits ::get (c) != 0) + { + new (lua_newuserdata (L, sizeof (UserdataShared ))) UserdataShared (c); + lua_rawgetp (L, LUA_REGISTRYINDEX, ClassInfo ::getConstKey ()); + // If this goes off it means the class T is unregistered! + assert (lua_istable (L, -1)); + lua_setmetatable (L, -2); + } + else + { + lua_pushnil (L); + } + } + + static void push (lua_State* L, T* const t) + { + if (t) + { + new (lua_newuserdata (L, sizeof (UserdataShared ))) UserdataShared (t); + lua_rawgetp (L, LUA_REGISTRYINDEX, ClassInfo ::getConstKey ()); + // If this goes off it means the class T is unregistered! + assert (lua_istable (L, -1)); + lua_setmetatable (L, -2); + } + else + { + lua_pushnil (L); + } + } +}; + +/** + Pass by container. + + The container controls the object lifetime. Typically this will be a + lifetime shared by C++ and Lua using a reference count. Because of type + erasure, containers like std::shared_ptr will not work. Containers must + either be of the intrusive variety, or in the style of the RefCountedPtr + type provided by LuaBridge (that uses a global hash table). +*/ +template +struct StackHelper +{ + static inline void push (lua_State* L, C const& c) + { + UserdataSharedHelper ::Type>::value>::push (L, c); + } + + typedef typename TypeTraits::removeConst < + typename ContainerTraits ::Type>::Type T; + + static inline C get (lua_State* L, int index) + { + return Userdata::get (L, index, true); + } +}; + +/** + Pass by value. + + Lifetime is managed by Lua. A C++ function which accesses a pointer or + reference to an object outside the activation record in which it was + retrieved may result in undefined behavior if Lua garbage collected it. +*/ +template +struct StackHelper +{ + static inline void push (lua_State* L, T const& t) + { + UserdataValue ::push (L, t); + } + + static inline T const& get (lua_State* L, int index) + { + return *Userdata::get (L, index, true); + } +}; + +//============================================================================== + +/** + Lua stack conversions for class objects passed by value. +*/ +template +struct Stack +{ +public: + static inline void push (lua_State* L, T const& t) + { + StackHelper ::value>::push (L, t); + } + + static inline T get (lua_State* L, int index) + { + return StackHelper ::value>::get (L, index); + } +}; + +//------------------------------------------------------------------------------ +/** + Lua stack conversions for pointers and references to class objects. + + Lifetime is managed by C++. Lua code which remembers a reference to the + value may result in undefined behavior if C++ destroys the object. The + handling of the const and volatile qualifiers happens in UserdataPtr. +*/ + +// pointer +template +struct Stack +{ + static inline void push (lua_State* L, T* const p) + { + UserdataPtr::push (L, p); + } + + static inline T* const get (lua_State* L, int index) + { + return Userdata::get (L, index, false); + } +}; + +// Strips the const off the right side of * +template +struct Stack +{ + static inline void push (lua_State* L, T* const p) + { + UserdataPtr::push (L, p); + } + + static inline T* const get (lua_State* L, int index) + { + return Userdata::get (L, index, false); + } +}; + +// pointer to const +template +struct Stack +{ + static inline void push (lua_State* L, T const* const p) + { + UserdataPtr::push (L, p); + } + + static inline T const* const get (lua_State* L, int index) + { + return Userdata::get (L, index, true); + } +}; + +// Strips the const off the right side of * +template +struct Stack +{ + static inline void push (lua_State* L, T const* const p) + { + UserdataPtr::push (L, p); + } + + static inline T const* const get (lua_State* L, int index) + { + return Userdata::get (L, index, true); + } +}; + +// reference +template +struct Stack +{ + static inline void push (lua_State* L, T& t) + { + UserdataPtr::push (L, &t); + } + + static T& get (lua_State* L, int index) + { + T* const t = Userdata::get (L, index, false); + if (!t) + luaL_error (L, "nil passed to reference"); + return *t; + } +}; + +template +struct RefStackHelper +{ + typedef C return_type; + + static inline void push (lua_State* L, C const& t) + { + UserdataSharedHelper ::Type>::value>::push (L, t); + } + + typedef typename TypeTraits::removeConst < + typename ContainerTraits ::Type>::Type T; + + static return_type get (lua_State* L, int index) + { + return Userdata::get (L, index, true); + } +}; + +template +struct RefStackHelper +{ + typedef T const& return_type; + + static inline void push (lua_State* L, T const& t) + { + UserdataPtr::push (L, &t); + } + + static return_type get (lua_State* L, int index) + { + T const* const t = Userdata::get (L, index, true); + + if (!t) + luaL_error (L, "nil passed to reference"); + return *t; + } + +}; + +// reference to const +template +struct Stack +{ + typedef RefStackHelper ::value> helper_t; + + static inline void push (lua_State* L, T const& t) + { + helper_t::push (L, t); + } + + static typename helper_t::return_type get (lua_State* L, int index) + { + return helper_t::get (L, index); + } +}; + +} // namespace luabridge + +``` + +`LuaBridge/detail/dump.h`: + +```h +//============================================================================== +/* + https://github.com/vinniefalco/LuaBridge + + Copyright 2012, Vinnie Falco + Copyright 2007, Nathan Reed + + License: The MIT License (http://www.opensource.org/licenses/mit-license.php) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +//============================================================================== + +#pragma once + +#include +#include + +namespace luabridge { + +std::string dumpLuaState(lua_State *L) { + std::stringstream ostr; + int i; + int top = lua_gettop(L); + ostr << "top=" << top << ":\n"; + for (i = 1; i <= top; ++i) { + int t = lua_type(L, i); + switch(t) { + case LUA_TSTRING: + ostr << " " << i << ": '" << lua_tostring(L, i) << "'\n"; + break; + case LUA_TBOOLEAN: + ostr << " " << i << ": " << + (lua_toboolean(L, i) ? "true" : "false") << "\n"; + break; + case LUA_TNUMBER: + ostr << " " << i << ": " << lua_tonumber(L, i) << "\n"; + break; + default: + ostr << " " << i << ": TYPE=" << lua_typename(L, t) << "\n"; + break; + } + } + return ostr.str(); +} + +} // namespace luabridge + +``` + +`aimbot.cpp`: + +```cpp +#include "sdk.hpp" +#include "aimbot.hpp" +#include "source.hpp" +#include "weapon.hpp" +#include "misc.hpp" +#include "autowall.hpp" +#include "player.hpp" + +constexpr int getWeaponIndex(int weaponId) noexcept +{ + switch (weaponId) { + default: return 0; + + case WEAPON_GLOCK: return 1; + case WEAPON_HKP2000: return 2; + case WEAPON_USP_SILENCER: return 3; + case WEAPON_ELITE: return 4; + case WEAPON_P250: return 5; + case WEAPON_TEC9: return 6; + case WEAPON_FIVESEVEN: return 7; + case WEAPON_CZ75A: return 8; + case WEAPON_DEAGLE: return 9; + case WEAPON_REVOLVER: return 10; + + case WEAPON_NOVA: return 11; + case WEAPON_XM1014: return 12; + case WEAPON_SAWEDOFF: return 13; + case WEAPON_MAG7: return 14; + case WEAPON_M249: return 15; + case WEAPON_NEGEV: return 16; + + case WEAPON_MAC10: return 17; + case WEAPON_MP9: return 18; + case WEAPON_MP7: return 19; + case WEAPON_MP5SD: return 20; + case WEAPON_UMP45: return 21; + case WEAPON_P90: return 22; + case WEAPON_BIZON: return 23; + + case WEAPON_GALILAR: return 24; + case WEAPON_FAMAS: return 25; + case WEAPON_AK47: return 26; + case WEAPON_M4A1: return 27; + case WEAPON_M4A1_SILENCER: return 28; + case WEAPON_SSG08: return 29; + case WEAPON_SG556: return 30; + case WEAPON_AUG: return 31; + case WEAPON_AWP: return 32; + case WEAPON_G3SG1: return 33; + case WEAPON_SCAR20: return 34; + + case WEAPON_TASER: return 39; + } +} + +constexpr int getWeaponClass(int weaponId) noexcept +{ + switch (weaponId) { + default: return 0; + + case WEAPON_GLOCK: + case WEAPON_HKP2000: + case WEAPON_USP_SILENCER: + case WEAPON_ELITE: + case WEAPON_P250: + case WEAPON_TEC9: + case WEAPON_FIVESEVEN: + case WEAPON_CZ75A: + case WEAPON_DEAGLE: + case WEAPON_REVOLVER: return 35; + + case WEAPON_NOVA: + case WEAPON_XM1014: + case WEAPON_SAWEDOFF: + case WEAPON_MAG7: + case WEAPON_M249: + case WEAPON_NEGEV: return 36; + + case WEAPON_MAC10: + case WEAPON_MP9: + case WEAPON_MP7: + case WEAPON_MP5SD: + case WEAPON_UMP45: + case WEAPON_P90: + case WEAPON_BIZON: return 37; + + case WEAPON_GALILAR: + case WEAPON_FAMAS: + case WEAPON_AK47: + case WEAPON_M4A1: + case WEAPON_M4A1_SILENCER: + case WEAPON_SSG08: + case WEAPON_SG556: + case WEAPON_AUG: + case WEAPON_AWP: + case WEAPON_G3SG1: + case WEAPON_SCAR20: return 38; + } +} + +QAngle CalculateRelativeAngle(const Vector& source, const Vector& destination, QAngle view_angles) noexcept +{ + QAngle angles = Math::CalcAngle(source, destination); + + return (angles - view_angles).Normalized(); +} + +auto kill_delay_time = 0; +void c_legitaimbot::kill_delay(IGameEvent* event) +{ + player_info po; + if (!ctx.m_local() || ctx.m_local()->IsDead() || csgo.m_engine()->GetPlayerInfo(ctx.m_local()->entindex(), &po)) + return; + + if (event->GetInt("attacker") != po.userid || event->GetInt("userid") == po.userid) + return; + + auto* const active_weapon = ctx.m_local()->get_weapon(); + if (!active_weapon || !active_weapon->m_iClip1()) + return; + + if (ctx.m_local()->m_iShotsFired() > 0 && !ctx.latest_weapon_data->bFullAuto) + return; + + auto weapon_index = getWeaponIndex(active_weapon->m_iItemDefinitionIndex()); + if (!weapon_index) + return; + + const auto weapon_class = getWeaponClass(active_weapon->m_iItemDefinitionIndex()); + if (!ctx.m_settings.aimbot[weapon_index].enabled) + weapon_index = weapon_class; + + if (!ctx.m_settings.aimbot[weapon_index].enabled) + weapon_index = 0; + + kill_delay_time = csgo.m_globals()->realtime + ctx.m_settings.aimbot[weapon_index].killdelay; +} + +auto pressed = false; +auto last_pressed = false; + +bool goes_thru_smoke(const Vector& start, const Vector& end) +{ + typedef bool(__cdecl* GoesThroughSmoke)(Vector, Vector); + + static auto linegoesthrusmoke = Memory::Scan(sxor("client.dll"), "55 8B EC 83 EC 08 8B 15 ? ? ? ? 0F 57 C0"); + + if (!linegoesthrusmoke) + return false; + + static GoesThroughSmoke goesthru_fn = (GoesThroughSmoke)(linegoesthrusmoke); + + return goesthru_fn(start, end); +} + +void c_legitaimbot::run(CUserCmd* cmd) +{ + const auto is_visible = [&](C_BasePlayer* m_player, Vector start, Vector end) -> bool + { + if (!m_player) return false; + CGameTrace tr; + Ray_t ray; + static CTraceFilter traceFilter; + traceFilter.pSkip = ctx.m_local(); + + ray.Init(start, end); + + csgo.m_engine_trace()->TraceRay(ray, 0x4600400B, &traceFilter, &tr); + + return (tr.m_pEnt == m_player || tr.fraction >= 0.99f); + }; + + if (GetAsyncKeyState(VK_LBUTTON) & 1) + { + if (!pressed) + { + pressed = true; + last_pressed = true; + } + } + else + { + pressed = false; + } + + if (!ctx.m_local() || ctx.m_local()->m_flNextAttack() > csgo.m_globals()->curtime || kill_delay_time > csgo.m_globals()->realtime || ctx.m_local()->m_bIsDefusing() || + ctx.m_local()->m_bWaitForNoAttack()) + return; + + auto active_weapon = m_weapon(); + if (!active_weapon || !active_weapon->m_iClip1()) + return; + + if (ctx.m_local()->m_iShotsFired() > 0 && !ctx.latest_weapon_data->bFullAuto) + return; + + auto weapon_index = getWeaponIndex(active_weapon->m_iItemDefinitionIndex()); + if (!weapon_index) + return; + + const auto weapon_class = getWeaponClass(active_weapon->m_iItemDefinitionIndex()); + if (!ctx.m_settings.aimbot[weapon_index].enabled) + weapon_index = weapon_class; + + if (!ctx.m_settings.aimbot[weapon_index].enabled) + weapon_index = 0; + + if (!ctx.m_settings.aimbot[weapon_index].betweenShots && active_weapon->m_flNextPrimaryAttack() > csgo.m_globals()->curtime) + return; + + if (!ctx.m_settings.aimbot[weapon_index].ignoreFlash && ctx.m_local()->m_flFlashMaxAlpha() > 100.f) + return; + + if (ctx.m_settings.aimbot[weapon_index].onKey) + { + if (!ctx.m_settings.aimbot[weapon_index].keyMode) + { + if (!GetAsyncKeyState(ctx.m_settings.aimbot[weapon_index].key)) + return; + } + else + { + static auto toggle = true; + if (GetAsyncKeyState(ctx.m_settings.aimbot[weapon_index].key) & 1) + toggle = !toggle; + if (!toggle) + return; + } + } + + if (ctx.m_settings.aimbot[weapon_index].enabled + && (cmd->buttons & IN_ATTACK + || ctx.m_settings.aimbot[weapon_index].autoShot + || ctx.m_settings.aimbot[weapon_index].aimlock) + && active_weapon->GetInaccuracy() <= ctx.m_settings.aimbot[weapon_index].maxAimInaccuracy) + { + if (ctx.m_settings.aimbot[weapon_index].scopedOnly && active_weapon->IsSniper() && !ctx.m_local()->m_bIsScoped()) + return; + + auto best_fov = ctx.m_settings.aimbot[weapon_index].fov; + Vector best_target{}; + const auto local_player_eye_position = ctx.m_local()->GetEyePosition(); + + auto need_rcs = ctx.latest_weapon_data->flRecoilMagnitude < 35.0f && ctx.latest_weapon_data->flRecoveryTimeStand > ctx.latest_weapon_data->flCycleTime; + + const auto aim_punch = ctx.m_settings.aimbot[weapon_index].rcsfov >= best_fov && need_rcs ? ctx.m_local()->m_aimPunchAngle() : QAngle{}; + + for (auto i = 1; i <= csgo.m_engine()->GetMaxClients(); i++) + { + auto entity = csgo.m_entity_list()->GetClientEntity(i); + if (!entity + || entity == ctx.m_local() + || entity->IsDormant() + || entity->IsDead() + || entity->m_iTeamNum() == ctx.m_local()->m_iTeamNum() && !ctx.m_settings.aimbot[weapon_index].friendlyFire + || entity->m_bGunGameImmunity()) + continue; + + for (auto bone : { 8, 4, 3, 7, 6, 5 }) + { + auto bone_position = entity->get_bone_pos( + ctx.m_settings.aimbot[weapon_index].bone > 1 ? 10 - ctx.m_settings.aimbot[weapon_index].bone : bone); + const auto angle = CalculateRelativeAngle(local_player_eye_position, bone_position, + cmd->viewangles + aim_punch); + + const auto fov = std::hypot(angle.x, angle.y); + if (fov > best_fov) + continue; + + if (!ctx.m_settings.aimbot[weapon_index].ignoreSmoke + && goes_thru_smoke(local_player_eye_position, bone_position)) + continue; + + auto mdmg = ctx.m_settings.aimbot[weapon_index].killshot ? entity->m_iHealth() : ctx.m_settings.aimbot[weapon_index].minDamage; + + if (!is_visible(entity, local_player_eye_position, bone_position) + && (ctx.m_settings.aimbot[weapon_index].visibleOnly + || feature::autowall->CanHit(local_player_eye_position, bone_position, ctx.m_local(), entity, 0) >= mdmg)) + continue; + + if (fov < best_fov) + { + best_fov = fov; + best_target = bone_position; + } + if (ctx.m_settings.aimbot[weapon_index].bone) + break; + } + } + + if (best_target.IsValid() + && !best_target.IsZero()) + { + static auto last_angles{ cmd->viewangles }; + static int last_command{}; + + const auto can_use_silent = ctx.m_settings.aimbot[weapon_index].silent && best_fov <= ctx.m_settings.aimbot[weapon_index].silentfov && !(ctx.m_local()->m_iShotsFired() > 1); + + auto angle = CalculateRelativeAngle(local_player_eye_position, best_target, cmd->viewangles + aim_punch); + auto clamped{ false }; + + if (std::abs(angle.x) > 255.0f + || std::abs(angle.y) > 255.0f) + { + angle.x = Math::clamp(angle.x, -255.0f, 255.0f); + angle.y = Math::clamp(angle.y, -255.0f, 255.0f); + clamped = true; + } + + if (last_command < cmd->command_number + && !last_angles.IsZero() + && can_use_silent) + cmd->viewangles = Math::CalcAngle(local_player_eye_position, best_target); + + angle /= ctx.m_settings.aimbot[weapon_index].smooth; + + cmd->viewangles.y += angle.y; + cmd->viewangles.x += angle.x; + + if (!can_use_silent) + csgo.m_engine()->SetViewAngles(cmd->viewangles); + + if (ctx.m_settings.aimbot[weapon_index].autoScope + && active_weapon->m_flNextPrimaryAttack() <= csgo.m_globals()->curtime + && active_weapon->IsSniper() + && !ctx.m_local()->m_bIsScoped()) + cmd->buttons |= IN_ATTACK2; + + if (ctx.m_settings.aimbot[weapon_index].autoShot + && active_weapon->m_flNextPrimaryAttack() <= csgo.m_globals()->curtime + && !clamped && active_weapon->GetInaccuracy() <= ctx.m_settings.aimbot[weapon_index].maxShotInaccuracy) + cmd->buttons |= IN_ATTACK; + + if (clamped) + cmd->buttons &= ~IN_ATTACK; + + if (clamped || ctx.m_settings.aimbot[weapon_index].smooth > 1.0f) + last_angles = cmd->viewangles; + else + last_angles = QAngle(); + + static auto max_time = .0f; + static auto can_reset_auto_delay_time = true; + + if (ctx.m_settings.aimbot[weapon_index].autodelay && !can_use_silent && !ctx.m_local()->m_iShotsFired()) + { + static const auto fov = .05f; + + const auto id = ctx.m_local()->m_iCrosshairID(); + + if (id) + { + auto entity = csgo.m_entity_list()->GetClientEntity(id); + if (entity->GetClientClass()->m_ClassID == CCSPlayer) + { + max_time = 0; + can_reset_auto_delay_time = false; + } + } + + if (best_fov > fov && can_reset_auto_delay_time) + { + max_time = csgo.m_globals()->curtime + best_fov / ctx.m_settings.aimbot[weapon_index].smooth; + can_reset_auto_delay_time = false; + } + + if (!id && max_time > csgo.m_globals()->curtime) + { + cmd->buttons &= ~IN_ATTACK; + csgo.m_engine()->SetViewAngles(cmd->viewangles); + } + } + + last_command = cmd->command_number; + } + } +} + +``` + +`aimbot.hpp`: + +```hpp +#pragma once + +class c_legitaimbot +{ +public: + virtual void run(CUserCmd*); + virtual void kill_delay(IGameEvent* event); +}; +``` + +`anti_aimbot.cpp`: + +```cpp +#include "source.hpp" +#include "entity.hpp" +#include "player.hpp" +#include "weapon.hpp" +#include "hooked.hpp" +#include "math.hpp" +#include "displacement.hpp" +#include "anti_aimbot.hpp" +#include "prediction.hpp" +#include +#include +#include "menu.hpp" +#include "movement.hpp" +#include "usercmd.hpp" +#include "autowall.hpp" +#include "resolver.hpp" +#include "rage_aimbot.hpp" + +float c_antiaimbot::get_max_desync_delta(C_BasePlayer* ent) //autistic but w/e +{ + auto animstate = ent->get_animation_state(); + auto speedfraction = max(0.f, min(animstate->m_speed_as_portion_of_walk_top_speed, 1.f)); + auto speedfactor = max(0.f, min(animstate->m_speed_as_portion_of_crouch_top_speed, 1.f)); + + auto lol = ((animstate->m_walk_run_transition * -0.30000001f) - 0.19999999f) * speedfraction + 1.f; + + if (animstate->m_anim_duck_amount > 0.0f) + lol += ((animstate->m_anim_duck_amount * speedfactor) * (0.5f - lol)); + + return (animstate->m_aim_yaw_max * lol); +} + +bool IsVisible(Vector start, Vector end, C_BasePlayer* skip, C_BasePlayer* ent) +{ + trace_t trace; + //util_trace_line(start, end, MASK_SHOT_HULL, filter, &trace); + Ray_t ray; + ray.Init(start, end); + + if (skip) + { + CTraceFilter filter; + filter.pSkip = skip; + csgo.m_engine_trace()->TraceRay(ray, MASK_SHOT_HULL, &filter, &trace); + } + else + { + CTraceFilterWorldOnly filter; + csgo.m_engine_trace()->TraceRay(ray, MASK_SHOT_HULL, &filter, &trace); + } + + return trace.m_pEnt == ent; +} + +void c_antiaimbot::get_targets() +{ + players.clear(); + + C_BasePlayer* target = nullptr; + + QAngle original_viewangles; + csgo.m_engine()->GetViewAngles(original_viewangles); + + float lowest_distance = 99999.f; + for (auto i = 1; i < 64; i++) + { + origins[i - 1] = Vector::Zero; + auto player = csgo.m_entity_list()->GetClientEntity(i); + + if (!player || player->IsDead() || player->m_iTeamNum() == ctx.m_local()->m_iTeamNum() || player == ctx.m_local()) + continue; + + const auto idx = player->entindex() - 1; + + const auto& curlog = &feature::lagcomp->records[idx]; + + origins[i - 1] = player->m_vecAbsOrigin(); + player->GetWorldSpaceCenter(origins[i-1]); + + if (!player->IsDormant() && curlog->records_count > 0)// && abs(player->m_flSimulationTime() - TICKS_TO_TIME(csgo.m_globals()->tickcount)) > 5.f) + curlog->last_scan_time = csgo.m_client_state()->m_clockdrift_manager.m_nServerTick; + + if (std::abs(csgo.m_client_state()->m_clockdrift_manager.m_nServerTick - curlog->last_scan_time) >= 20) + continue; + + if (IsVisible(ctx.m_local()->GetEyePosition(), origins[i - 1], ctx.m_local(), player)) + players.push_back(player); + + QAngle angle = Math::CalcAngle(ctx.m_local()->GetEyePosition(), origins[i - 1]); + QAngle delta = angle - original_viewangles; + delta.Normalize(); + delta.z = 0.f; + + float dist = sqrt(delta.x * delta.x + delta.y * delta.y); + + if (dist < lowest_distance) + { + target = player; + lowest_distance = dist; + } + } + + if (!target || *(void**)target == nullptr) + return; + + players.push_back(target); +} + +void c_antiaimbot::run_at_target(float& yaw) +{ + auto GetFOV = [](const QAngle& view_angles, const Vector& start, const Vector& end) -> float { + Vector dir, fw; + + // get direction and normalize. + dir = (end - start).Normalized(); + + // get the forward direction vector of the view angles. + Math::AngleVectors(view_angles, &fw); + + // get the angle between the view angles forward directional vector and the target location. + return max(RAD2DEG(std::acos(fw.Dot(dir))), 0.f); + }; + + if (!ctx.m_settings.anti_aim_at_target[0] && !ctx.m_settings.anti_aim_at_target[1]) + return; + + const auto mode = (ctx.m_settings.anti_aim_at_target[0] && ctx.m_settings.anti_aim_at_target[1] ? 3 : (ctx.m_settings.anti_aim_at_target[0] ? 1 : 2)); + + Vector best_origin = Vector::Zero; + float best_distance = 9999.f; + float best_fov = 9999.f; + int best_idx = -1; + bool best_dormant = false; + + QAngle viewangles; + csgo.m_engine()->GetViewAngles(viewangles); + + for (auto i = 1; i < 64; i++) + { + if (origins[i-1].IsZero()) + continue; + + auto player = csgo.m_entity_list()->GetClientEntity(i); + + if (!player || player->IsDead() || player->m_iTeamNum() == ctx.m_local()->m_iTeamNum() || player == ctx.m_local()) + continue; + + const auto idx = player->entindex() - 1; + + const auto& curlog = &feature::lagcomp->records[idx]; + + if (abs(csgo.m_client_state()->m_clockdrift_manager.m_nServerTick - curlog->last_scan_time) >= 20) + continue; + + //Vector forward; + //Math::AngleVectors(Math::CalcAngle(ctx.m_eye_position, origins[i-1]), &forward); + + const auto dist = (origins[i-1] - ctx.m_local()->GetEyePosition()).LengthSquared(); + Vector wsc = origins[i-1]; + /*const*/ auto fov = GetFOV(viewangles, ctx.m_local()->GetEyePosition(), wsc); + + switch (mode) + { + case 1: + if (fov < best_fov) + { + best_origin = origins[i - 1]; + best_distance = dist; + best_dormant = !player->IsDormant(); + best_fov = fov; + best_idx = i; + } + break; + case 2: + if (dist < best_distance) + { + best_origin = origins[i - 1]; + best_distance = dist; + best_dormant = !player->IsDormant(); + best_fov = fov; + best_idx = i; + } + break; + case 3: + if (dist <= (best_distance*0.9f) && fov < best_fov) + { + best_origin = origins[i - 1]; + best_dormant = !player->IsDormant(); + best_distance = dist; + best_fov = fov; + best_idx=i; + } + break; + } + } + + if (feature::ragebot->m_target != nullptr && !feature::ragebot->m_target->IsDormant() && !feature::ragebot->m_target->IsDead() && feature::ragebot->m_target->entindex() != best_idx) { + best_origin = feature::ragebot->m_target->m_vecOrigin() + feature::ragebot->m_target->m_vecVelocity() * csgo.m_globals()->interval_per_tick; + } + + if (best_origin.IsZero()) + return; + + const auto angle = Math::CalcAngle(ctx.m_local()->GetEyePosition(), best_origin); + yaw = Math::normalize_angle(angle.y); +} + +void c_antiaimbot::auto_direction() { + // constants. + static constexpr float STEP{ 4.f }; + static constexpr float RANGE{ 32.f }; + + if (!ctx.m_local() || ctx.m_local()->IsDead()) + return; + + AutoTarget_t target = AutoTarget_t{ 180.f - 1.f, nullptr }; + + // iterate players. + for (int i{ 0 }; i <= csgo.m_globals()->maxClients; ++i) { + C_BasePlayer* player = csgo.m_entity_list()->GetClientEntity(i); + + if (!player || player->IsDead() || player->entindex() < 0 || player->entindex() > 64 || player->m_iTeamNum() == ctx.m_local()->m_iTeamNum() || player == ctx.m_local()) + continue; + + const auto idx = player->entindex() - 1; + + auto* curlog = &feature::lagcomp->records[idx]; + + if (!curlog || abs(csgo.m_client_state()->m_clockdrift_manager.m_nServerTick - curlog->last_scan_time) >= 20) + continue; + + auto absorg = player->m_vecAbsOrigin(); + player->GetWorldSpaceCenter(absorg); + + // get best target based on fov. + float fov = Math::GetFov(Engine::Movement::Instance()->m_qRealAngles, Math::CalcAngle(ctx.m_local()->GetEyePosition(), absorg)); + + if (fov < target.fov) { + target.fov = fov; + target.player = player; + } + } + + if (!target.player || !target.player->IsPlayer()) { + // we have a timeout. + /*if (m_auto_last > 0.f && m_auto_time > 2.5f && csgo.m_globals()->curtime < (m_auto_last + 2.5f)) + return;*/ + + // set angle to backwards. + m_auto = Math::normalize_angle(Engine::Movement::Instance()->m_qRealAngles.y - 179.f); + m_auto_dist = -1.f; + return; + } + + // construct vector of angles to test. + std::vector angles = {}; + angles.emplace_back(Engine::Movement::Instance()->m_qRealAngles.y - 179.f); + angles.emplace_back(Engine::Movement::Instance()->m_qRealAngles.y + 90.f); + angles.emplace_back(Engine::Movement::Instance()->m_qRealAngles.y - 90.f); + + // see if we got any valid result. + // if this is false the path was not obstructed with anything. + bool valid = false; + + const auto start = target.player->Weapon_ShootPosition(); + + // iterate vector of angles. + for (auto i = 0; i < (int)angles.size(); ++i) { + + auto it = &angles.at(i); + + // compute the 'rough' estimation of where our head will be. + Vector end{ ctx.m_local()->GetEyePosition().x + std::cos(DEG2RAD(it->m_yaw)) * RANGE, + ctx.m_local()->GetEyePosition().y + std::sin(DEG2RAD(it->m_yaw)) * RANGE, + ctx.m_local()->GetEyePosition().z }; + + // draw a line for debugging purposes. + //g_csgo.m_debug_overlay->AddLineOverlay( start, end, 255, 0, 0, true, 0.1f ); + + // compute the direction. + auto dir = end - start; + float len = dir.Normalize(); + + // should never happen. + if (len <= 0.f) + continue; + + // step thru the total distance, 4 units per step. + for (float i{ 0.f }; i < len; i += STEP) { + // get the current step position. + const auto point = start + (dir * i); + + // get the contents at this point. + const int contents = csgo.m_engine_trace()->GetPointContents(point, MASK_SHOT_HULL); + + // contains nothing that can stop a bullet. + if (!(contents & MASK_SHOT_HULL)) + continue; + + float mult = 1.f; + + // over 50% of the total length, prioritize this shit. + if (i > (len * 0.5f)) + mult = 1.25f; + + // over 90% of the total length, prioritize this shit. + if (i > (len * 0.75f)) + mult = 1.25f; + + // over 90% of the total length, prioritize this shit. + if (i > (len * 0.9f)) + mult = 2.f; + + // append 'penetrated distance'. + it->m_dist += (STEP * mult); + + // mark that we found anything. + valid = true; + } + } + + if (!valid || angles.empty()) { + // set angle to backwards. + m_auto = Math::normalize_angle(Engine::Movement::Instance()->m_qRealAngles.y - 179.f); + m_auto_dist = -1.f; + return; + } + + // put the most distance at the front of the container. + std::sort(angles.begin(), angles.end(), + [](const AdaptiveAngle& a, const AdaptiveAngle& b) { + return a.m_dist > b.m_dist; + }); + + // the best angle should be at the front now. + AdaptiveAngle* best = &angles.front(); + + // check if we are not doing a useless change. + if (best->m_dist != m_auto_dist) { + // set yaw to the best result. + m_auto = Math::normalize_angle(best->m_yaw); + m_auto_dist = best->m_dist; + m_auto_last = csgo.m_globals()->curtime; + } +} + +void c_antiaimbot::change_angles(CUserCmd* cmd, bool* send_packet) +{ +#ifdef VIRTUALIZER + +#endif // VIRTUALIZER + + auto animstate = ctx.m_local()->get_animation_state(); + + get_targets(); + + const auto at_target = ctx.m_settings.anti_aim_at_target && (ctx.m_settings.anti_aim_at_target[2] && ctx.side == -1 || !ctx.m_settings.anti_aim_at_target[2]); + + if (at_target) + run_at_target(cmd->viewangles.y); + + auto_direction(); + + max_delta = get_max_desync_delta(ctx.m_local()); + + auto lol = RandInt(0, 1); + + if (ctx.m_settings.anti_aim_typex == 1) + cmd->viewangles.x = (lol == 1 ? 179.0f : 178.975261f); + else if (ctx.m_settings.anti_aim_typex == 2) + cmd->viewangles.x = (lol == 1 ? -179.0f : -178.975261f); + else if (ctx.m_settings.anti_aim_typex == 3) + cmd->viewangles.x = 0.0f; + + //int aa_mode = is_moving ? cheat::Cvars.anti_aim_m_yaw.GetValue() : cheat::Cvars.anti_aim_s_yaw.GetValue(); + int aa_switch = /*is_moving ? ctx.m_settings.anti_aim_jittering_type : */ctx.m_settings.anti_aim_jittering_type; // you know + int aa_switchspeed = /*is_moving ? ctx.m_settings.anti_aim_jittering_speed : */ctx.m_settings.anti_aim_jittering_speed; + int aa_switchang = /*is_moving ? ctx.m_settings.anti_aim_jittering : */ctx.m_settings.anti_aim_jittering; + + //float left_max_limit = ctx.m_settings.anti_aim_fake_left_limit; + float f_max_limit = ctx.m_settings.anti_aim_fake_limit; + + int aa_type = ctx.m_settings.anti_aim_typey; + int aa_ftype = ctx.m_settings.anti_aim_typeyfake; + + if (ctx.side != -1) + { + if (!ctx.side) + cmd->viewangles.y += 90.f; + else if (ctx.side == 1) + cmd->viewangles.y -= 90.f; + else if (ctx.side == 2) + cmd->viewangles.y += 178.f; + } + else { + if (aa_type == 1) + cmd->viewangles.y += 178.f; + else if (aa_type == 2) // zero + cmd->viewangles += 0; + else if (aa_type == 3) + cmd->viewangles.y = ctx.m_local()->m_flLowerBodyYawTarget() + 90.f; + else if (aa_type == 4) + cmd->viewangles.y += Math::normalize_angle(csgo.m_globals()->curtime * 250.f); + } + + const auto prev_side = ctx.fside; + + //static auto yaw = 0.f; + + if (ctx.m_settings.anti_aim_freestanding_fake_type > 0 && *send_packet) { + if (m_auto_dist != -1) { + ctx.fside = Math::AngleDiff(Engine::Movement::Instance()->m_qRealAngles.y, m_auto) < 0 ? -1 : 1; + if (ctx.m_settings.anti_aim_freestanding_fake_type == 1) + ctx.fside *= -1; + if (ctx.m_settings.anti_aim_typeyfake != 2) + ctx.fside *= -1; + } + //cmd->viewangles.y = yaw; + } + + if (ctx.allow_freestanding) { + if ((m_auto_dist != -1 && at_target) || !at_target) + cmd->viewangles.y = m_auto; + } + + //static float old_yaw = 0.f; + + const auto v81 = !ctx.m_local()->m_bIsScoped(); + float v90; + + if (v81) + v90 = ctx.latest_weapon_data->max_speed * 0.25f; + else + v90 = ctx.latest_weapon_data->max_speed_alt * 0.25f; + + static float previous_hp = ctx.m_local()->m_iHealth(); + + //static int old_shots = 0; + const auto can_switch_side = *send_packet && ((ctx.m_settings.anti_aim_automatic_side[2] && ctx.m_local()->m_vecVelocity().Length2D() > v90) + || ctx.m_settings.anti_aim_automatic_side[1] && (ctx.exploit_allowed && ctx.has_exploit_toggled && ctx.main_exploit != 0)); + + previous_hp = ctx.m_local()->m_iHealth(); + + //if (old_shots != ctx.m_local()->m_iShotsFired()) + // old_shots = ctx.m_local()->m_iShotsFired(); + + //static int old_side = ctx.fside; + //static bool did_twist = false; + static bool force_choke = false; + + //auto curtime = csgo.m_globals()->curtime; + + const auto move_speed = sqrtf((cmd->forwardmove * cmd->forwardmove) + (cmd->sidemove * cmd->sidemove)); + const auto vel_speed = sqrtf((ctx.m_local()->m_vecVelocity().y * ctx.m_local()->m_vecVelocity().y) + (ctx.m_local()->m_vecVelocity().x * ctx.m_local()->m_vecVelocity().x)); + + //if (ctx.m_settings.anti_aim_typelby == 2) { + // //if (ctx.m_settings.aimbot_position_adjustment_old) { + // // //if (updated_lby()) + // // //{ + // // + // // if (((m_next_lby_update_time - curtime) <= 0.02f || m_will_lby_update) && !send_packet) + // // { + // // switch (ctx.m_settings.anti_aim_typelby) + // // { + // // case 1: + // // if (m_will_lby_update) + // // cmd->viewangles.y = ctx.m_local()->m_angEyeAngles().y + 180.f; + // // break; + // // case 2: + // // if (!m_will_lby_update) + // // cmd->viewangles.y = ctx.m_local()->m_angEyeAngles().y + Math::normalize_angle(180.f * (ctx.fside == 0 ? 1.f : -1.f)); + // // //else + // // // cmd->viewangles.y += Math::normalize_angle(120.f * (ctx.fside == 0 ? -1.f : 1.f)); + // // break; + // // } + // // + // // /*switch (ctx.m_settings.anti_aim_typelby) + // // { + // // case 1: + // // cmd->viewangles.y += 180.f; + // // break; + // // case 2: + // // cmd->viewangles.y += ctx.fside > 0 ? 120.f : -120.f; + // // break; + // // }*/ + // // cmd->viewangles.y = Math::normalize_angle(cmd->viewangles.y); + // // cmd->viewangles.Clamp(); + // // force_choke = true; + // // send_packet = false; + // // + // // return; + // // } + // //} + // //else { + // if (csgo.m_client_state()->m_iChockedCommands == 0 && ctx.m_local()->m_vecVelocity().Length2D() < 6.f) + // { + // cmd->viewangles.y = Math::normalize_angle(ctx.m_local()->m_angEyeAngles().y + (180.f * ctx.fside)/*+ (ctx.fside ? 180.f : -180.f)*/); + // *send_packet = false; + + // lby_expected = cmd->viewangles.y; + // cmd->viewangles.Clamp(); + // force_choke = true; + + // if (!feature::anti_aim->skip_fakelag_this_tick) { + // if (cmd->command_number & 1) + // cmd->forwardmove -= (ctx.m_local()->m_vecViewOffset().z < 64.f ? 4.941177f : 1.01f); + // else + // cmd->forwardmove += (ctx.m_local()->m_vecViewOffset().z < 64.f ? 4.941177f : 1.01f); + // } + + // return; + // } + // //} + //} + /*else + { + if (TICKS_TO_TIME(ctx.m_local()->m_nTickBase()) > feature::anti_aim->lby_timer && csgo.m_client_state()->m_iChockedCommands < 14 && ctx.m_settings.anti_aim_typelby == 0) + { + cmd->viewangles.y = Math::normalize_angle(ctx.m_local()->m_angEyeAngles().y - (180.f - ctx.fside)); + send_packet = false; + force_choke = true; + + cmd->viewangles.Clamp(); + + return; + } + }*/ + + if (force_choke) + { + *send_packet = false; + force_choke = false; + } + + if (can_switch_side) + ctx.fside *= -1; + + const auto new_max_delta = max_delta * (f_max_limit / 60.f); + //if (ctx.changed_fake_side) + // old_side *= -1; + + //if (is_moving && ctx.m_settings.anti_aim_automatic_side[1]) { + // if (abs(Math::AngleDiff(ctx.angles[ANGLE_FAKE], ctx.angles[ANGLE_REAL])) <= 45.f/*just a quick test value*/&& ctx.m_settings.anti_aim_typeyfake == 2 && !ctx.start_switching && prev_side == ctx.fside) { + // if (send_packet) + // ctx.fside *= /*(cmd->command_number % 2 == 0 ? 1 : */-1/*)*/; + + // did_twist = true; + // } + // else { + // if (!did_twist) { + // old_side = ctx.fside; + // } + // else + // { + // ctx.fside = old_side; + // did_twist = false; + // } + // } + //} + + //if (ctx.m_settings.anti_aim_automatic_side[4] && ctx.m_local()->m_fFlags() & FL_ONGROUND) + //{ + // if (speed < 0.1f) + // { + // auto delta = Math::AngleDiff(ctx.m_local()->m_angEyeAngles().y, ctx.angles[ANGLE_FAKE]); + + // if (ctx.m_local()->get_animation_layer(3).m_flWeight == 0.0f && ctx.m_local()->get_animation_layer(6).m_flWeight <= 0.01f && ctx.m_local()->get_animation_layer(3).m_flCycle == 0.0f) + // ctx.fside = (delta <= 0.f ? 1 : -1); + // } + // else if (int(ctx.m_local()->get_animation_layer(12).m_flWeight * 1000.f) == 0) + // { + // //2 = -1; 3 = 1; 1 = fake; + // if (int(ctx.m_local()->get_animation_layer(6).m_flWeight * 1000.f) >= int(ctx.m_local()->get_animation_layer(6).m_flWeight * 1000.f)) + // { + // float delta1 = abs(ctx.m_local()->get_animation_layer(6).m_flPlaybackRate - ctx.local_layers[2][6].m_flPlaybackRate); + // float delta2 = abs(ctx.m_local()->get_animation_layer(6).m_flPlaybackRate - ctx.local_layers[0][6].m_flPlaybackRate); + // float delta3 = abs(ctx.m_local()->get_animation_layer(6).m_flPlaybackRate - ctx.local_layers[1][6].m_flPlaybackRate); + + // if (delta1 < delta3 || delta2 <= delta3 || int(delta3 * 1000.0f) != 0) { + // if (delta1 >= delta2 && delta3 > delta2 && int(delta2 * 1000.0f) == 0) + // ctx.fside = -1; + // } + // else + // ctx.fside = 1; + // } + // } + //} + + RandomSeed(cmd->command_number & 255); + + /*static float last_random_body_lean_mult = 0.f; + static float last_random_body_lean_time = 0.f; + + if (ctx.m_settings.anti_aim_fake_jittering) { + if (fabs(last_random_body_lean_time - csgo.m_globals()->realtime) > (0.5f - (ctx.m_settings.anti_aim_fake_jittering_speed * 0.05f))) { + last_random_body_lean_mult = RandomFloat(ctx.m_settings.anti_aim_fake_jittering_min, ctx.m_settings.anti_aim_fake_jittering_max) * 0.01f; + last_random_body_lean_time = csgo.m_globals()->realtime; + } + + max_delta *= last_random_body_lean_mult; + }*/ + + /*if (ctx.m_settings.anti_aim_fake_jittering && ctx.m_settings.anti_aim_typeyfake == 2) + { + if (ctx.m_local()->m_vecVelocity().Length2D() < 40) { + if (ctx.changed_fake_side) + old_side *= -1; + + ctx.fside *= -1; + did_twist = true; + } + else + { + if (!did_twist) { + old_side = ctx.fside; + } + else + { + ctx.fside = old_side; + did_twist = false; + } + } + }*/ + + if (aa_switch > 0 && (*send_packet)) + { + static float last_switch_ang = 0.f; + static float last_switch_time = 0.f; + static bool lmao = false; + + if (aa_switch == 1) + { + //cmd->viewangles.y += last_switch_ang < 0.f ? (abs(aa_switchang) / 2.f) : -(abs(aa_switchang) / 2.f); + + if (/*fabs(last_switch_time - csgo.m_globals()->realtime) > (1.f - (aa_switchspeed * 0.01f)) && */*send_packet) { + auto lol = abs(aa_switchang); + lmao = !lmao; + //RandomSeed(cmd->command_number & 255); + last_switch_ang = (lmao ? (-lol / 2) : (lol / 2)); + last_switch_time = csgo.m_globals()->realtime; + } + + } + else if (aa_switch == 2) + { + cmd->viewangles.y -= (fabs(aa_switchang) / 2.f); + + if (fabs(last_switch_time - csgo.m_globals()->realtime) > 0.0015f && *send_packet) + { + if (fabs(last_switch_ang) < fabs(aa_switchang)) + last_switch_ang += copysign(aa_switchspeed * 0.1f, aa_switchang); + else + last_switch_ang = 0.f; + + last_switch_time = csgo.m_globals()->realtime; + } + } + + cmd->viewangles.y = Math::normalize_angle(Math::normalize_angle(cmd->viewangles.y) + last_switch_ang); + } + + if (aa_ftype == 3) + { + auto should_switch = + ctx.m_local()->m_vecVelocity().Length2D() > 2 && + (!(int(ctx.m_local()->animation_layer(12).m_flWeight * 1000.f) || ctx.m_local()->animation_layer(7).m_flWeight == 1.f) + || abs(ctx.m_local()->m_vecVelocity().Length2D() - Engine::Prediction::Instance()->GetVelocity().Length2D()) <= 5.f); + + if (*send_packet && should_switch) + ctx.fside *= -1; + } + + + static auto is_inverted = false; + + if (fabs(ctx.fside) != 1 && csgo.m_client_state()->m_iChockedCommands == 1) + { + is_inverted = (ctx.fside > 0); + ctx.fside /= 2; + } + else + is_inverted = (ctx.fside > 0); + + cmd->viewangles.y = Math::normalize_angle(cmd->viewangles.y); + + last_real_angle = cmd->viewangles; + + //const auto dsy = ctx.m_settings.anti_aim_fake_static_real ? send_packet : !send_packet; + + auto inv_body_lean = new_max_delta; + auto view_yaw = last_real_angle.y; + float leaned_yaw = 0.f; + float abs_lean = 0.f; + float j = 0.f; + float k = 0.f; + + float v8, chto_blyad, i; + bool v12; + + if (aa_ftype == 1) + { + if (!ctx.m_settings.aimbot_position_adjustment_old) + { + if (is_inverted) + last_real_angle.y -= new_max_delta / 2.f; + else + last_real_angle.y += new_max_delta / 2.f; + } + + //if (ctx.m_settings.aimbot_position_adjustment_old) + // last_real_angle.y = Math::normalize_angle(last_real_angle.y - 180.f); + + if (*send_packet)// || !send_packet && ctx.m_settings.aimbot_position_adjustment_old) + { + if (is_inverted) + cmd->viewangles.y = Math::normalize_angle(last_real_angle.y + new_max_delta); + else + cmd->viewangles.y = Math::normalize_angle(last_real_angle.y - new_max_delta); + + //if (ctx.m_settings.aimbot_position_adjustment_old) + // cmd->viewangles.y = Math::normalize_angle(last_real_angle.y - 180.f + RandomFloat(-30.f, 30.f)); + } + else //if (!ctx.m_settings.aimbot_position_adjustment_old) + { + if (is_inverted) + cmd->viewangles.y = Math::normalize_angle(last_real_angle.y - new_max_delta); + else + cmd->viewangles.y = Math::normalize_angle(last_real_angle.y + new_max_delta); + } + } + else if (aa_ftype == 2) + { + static bool invert_jitter = false; + + if (invert_jitter) { + cmd->viewangles.y = last_real_angle.y + 180.0f; + last_real_angle.y = Math::normalize_angle(cmd->viewangles.y); + } + + if (*send_packet) { + invert_jitter = !invert_jitter; + + if (!invert_jitter) + cmd->viewangles.y = Math::normalize_angle(last_real_angle.y + (new_max_delta * 0.5f) * ctx.fside); + else + cmd->viewangles.y = Math::normalize_angle(last_real_angle.y - (new_max_delta * 0.5f) * ctx.fside); + } + else /*if (!flick_lby)*/ { + if (invert_jitter) + cmd->viewangles.y = Math::normalize_angle(last_real_angle.y - (new_max_delta + 5.0f) * ctx.fside); + else + cmd->viewangles.y = Math::normalize_angle(last_real_angle.y + (new_max_delta + 5.0f) * ctx.fside); + } + /*else { + if (invert_jitter) + cmd->viewangles.y = (last_real_angle.y + 90.0f * ctx.fside); + else + cmd->viewangles.y = (last_real_angle.y - 90.0f * ctx.fside); + }*/ + + + } + else if (aa_ftype == 3) + { + + if (!is_inverted) + inv_body_lean *= -1.f; + + // current abs rotation + for (leaned_yaw = inv_body_lean + last_real_angle.y; leaned_yaw > 180.0; leaned_yaw = leaned_yaw - 360.0) + ; + for (; leaned_yaw < -180.0; leaned_yaw = leaned_yaw + 360.0) + ; + v8 = ctx.angles[ANGLE_REAL]; + if (v8 > 180.0) + { + do + v8 = v8 - 360.0; + while (v8 > 180.0); + } + for (; v8 < -180.0; v8 = v8 + 360.0) + ; + for (abs_lean = v8 - leaned_yaw; abs_lean > 180.0; abs_lean = abs_lean - 360.0) + ; + for (; abs_lean < -180.0; abs_lean = abs_lean + 360.0) + ; + chto_blyad = *(float*)(uintptr_t(csgo.m_globals()) + 0x20) * 102.0f; + // max body yaw * yaw modifier + if (abs(abs_lean) <= chto_blyad && new_max_delta < max_delta) + goto LABEL_57; + if (abs(abs_lean) <= (180.0f - (max_delta + chto_blyad))) + { + if (abs_lean <= 0.0) + view_yaw = max_delta + leaned_yaw; + else + view_yaw = leaned_yaw - max_delta; + } + else + { + view_yaw = leaned_yaw; + } + v12 = 1; + i = ctx.angles[ANGLE_REAL]; + if (new_max_delta >= max_delta) + { + for (j = last_real_angle.y; j > 180.0; j = j - 360.0) + ; + for (; j < -180.0; j = j + 360.0) + ; + for (; i > 180.0; i = i - 360.0) + ; + for (; i < -180.0; i = i + 360.0) + ; + for (k = i - j; k > 180.0; k = k - 360.0) + ; + for (; k < -180.0; k = k + 360.0) + ; + if (is_inverted) + { + if (k < new_max_delta || k >= 179.0) + goto LABEL_46; + } + else if ((new_max_delta * -1.f) < k || k <= -179.0f) + { + goto LABEL_50; + } + v12 = 0; + if (*send_packet) + goto LABEL_59; + LABEL_46: + if (is_inverted) + { + if (k > 0.0 && k < 179.0) + view_yaw = last_real_angle.y + 120.0f; + goto LABEL_53; + } + LABEL_50: + if (k < 0.0 && k > -179.0) + view_yaw = last_real_angle.y - 120.0f; + LABEL_53: + if (!v12) + goto LABEL_57; + } + LABEL_57: + if (!*send_packet && csgo.m_client_state()->m_iChockedCommands < 14u) + { + //view_yaw = last_real_angle.y; + goto LABEL_63; + } + LABEL_59: + view_yaw = last_real_angle.y; + LABEL_63: + + cmd->viewangles.y = Math::normalize_angle(view_yaw); + } + + //if (ctx.m_settings.security_safety_mode != 0) + cmd->viewangles.Clamp(); + +#ifdef VIRTUALIZER + +#endif // VIRTUALIZER +} + +bool c_antiaimbot::peek_fake_lag(CUserCmd* cmd, bool* send_packet) +{ + auto choked = 15; + + if (!m_weapon()) + return false; + + const auto weapon_info = ctx.latest_weapon_data; + + if (!weapon_info) + return false; + + auto simulated_origin = ctx.m_local()->m_vecOrigin(); + auto move_per_tick = ctx.m_local()->m_vecVelocity() * csgo.m_globals()->interval_per_tick; + + int when_started_to_penetrate = 0; + + Vector vDuckHullMin = csgo.m_movement()->GetPlayerMins(true); + Vector vStandHullMin = csgo.m_movement()->GetPlayerMins(false); + + float fMore = (vDuckHullMin.z - vStandHullMin.z); + + Vector vecDuckViewOffset = csgo.m_movement()->GetPlayerViewOffset(true); + Vector vecStandViewOffset = csgo.m_movement()->GetPlayerViewOffset(false); + float duckFraction = min(1.f, ctx.m_local()->m_flDuckAmount() + 0.06f); + + float tempz = ((vecDuckViewOffset.z - fMore) * duckFraction) + + (vecStandViewOffset.z * (1 - duckFraction)); + + /* + csgo.m_engine()->GetViewAngles(ang); + */ + + Vector direction; + Math::AngleVectors(Engine::Movement::Instance()->m_qRealAngles, &direction); + auto max_range = weapon_info->range * 2; + auto dmg = (float)weapon_info->damage; + CTraceFilter filter; + filter.pSkip = ctx.m_local(); + CGameTrace enterTrace; + + + for (int i = 0; i < choked; i++) { + simulated_origin += move_per_tick; + + Vector start = simulated_origin + Vector(0,0, tempz); + Vector end = start + (direction * max_range); + auto currentDistance = 0.f; + + feature::autowall->TraceLine(start, end, MASK_SHOT | CONTENTS_GRATE, ctx.m_local(), &enterTrace); + + if (enterTrace.fraction == 1.0f) + dmg = 0.f; + else + //calculate the damage based on the distance the bullet traveled. + currentDistance += enterTrace.fraction * max_range; + + //Let's make our damage drops off the further away the bullet is. + dmg *= pow(weapon_info->range_modifier, (currentDistance / 500.f)); + + auto enterSurfaceData = csgo.m_phys_props()->GetSurfaceData(enterTrace.surface.surfaceProps); + float enterSurfPenetrationModifier = enterSurfaceData->game.penetrationmodifier; + + if (currentDistance > 3000.0 && weapon_info->penetration > 0.f || enterSurfPenetrationModifier < 0.1f) + dmg = -1.f; + + if (enterTrace.m_pEnt != nullptr) + { + //This looks gay as fuck if we put it into 1 long line of code. + bool canDoDamage = (enterTrace.hitgroup - 1) <= 7; + bool isPlayer = (enterTrace.m_pEnt->GetClientClass() && enterTrace.m_pEnt->GetClientClass()->m_ClassID == class_ids::CCSPlayer); + //bool isEnemy = (ctx.m_local()->m_iTeamNum() != ((C_BasePlayer*)enterTrace.m_pEnt)->m_iTeamNum()); + bool onTeam = (((C_BasePlayer*)enterTrace.m_pEnt)->m_iTeamNum() == 2 || ((C_BasePlayer*)enterTrace.m_pEnt)->m_iTeamNum() == 3); + + //TODO: Team check config + if (canDoDamage && isPlayer && onTeam) + feature::autowall->ScaleDamage(enterTrace, weapon_info, dmg); + + if (!canDoDamage && isPlayer) + dmg = -1.f; + } + + auto penetrate_count = 4; + + ctx.force_low_quality_autowalling = true; + if (!feature::autowall->HandleBulletPenetration(ctx.m_local(), weapon_info, enterTrace, start, direction, penetrate_count, dmg, weapon_info->penetration, 0.f, true)) + dmg = -1.f; + ctx.force_low_quality_autowalling = false; + + if (penetrate_count <= 0) + dmg = -1.f; + + auto can_penetrate = dmg > 0.f; + + if (can_penetrate) + when_started_to_penetrate = i; + + //csgo.m_debug_overlay()->AddBoxOverlay(start, Vector(-3, -3, -3), Vector(3, 3, 3), Vector(0, 0, 0), can_penetrate ? 255 : 0, !can_penetrate ? 255 : 0, 0, 255, csgo.m_globals()->interval_per_tick * 2.f); + + /*auto distance = feature::anti_aim->sent_data.m_vecOrigin.DistanceSquared(simulated_origin); + if (distance > 4096.0f) + return true;*/ + } + + if (when_started_to_penetrate == 4) { + *send_packet = true; + return true; + } + else { + *send_packet = false; + return true; + } +} + +void c_antiaimbot::fake_lag(CUserCmd* cmd, bool* send_packet) +{ +#ifdef VIRTUALIZER + +#endif // VIRTUALIZER + if (!cmd || cmd == nullptr || ctx.m_local() == nullptr) + return; + + unchocking = false; + + bool lag = false; static float lag_timer = 0.f; static float old_delta = 0.f; + + bool force_nade_choke = false; + + static bool is_throwing = false; + if (m_weapon() != nullptr && ctx.latest_weapon_data != nullptr && m_weapon()->IsGrenade() && m_weapon()->IsBeingThrowed()) + { + if (!(cmd->buttons & IN_ATTACK || cmd->buttons & IN_ATTACK2) && throw_nade || is_throwing) { + is_throwing = true; + enable_delay = csgo.m_globals()->realtime + csgo.m_globals()->interval_per_tick; + } + else + { + //maximal_choke = max(maximal_choke, 10); + force_nade_choke = true; + lag = true; + + throw_nade = true; + is_throwing = false; + } + } + else { + throw_nade = false; + is_throwing = false; + } + + if (ctx.fakeducking/* || skip_fakelag_this_tick*/) + return; + + const auto chocked_ticks = csgo.m_client_state()->m_iChockedCommands; + + const auto new_velo = (animation_speed > 7.f ? animation_speed : 0.f); + + RandomSeed(cmd->random_seed & 255); + + if (ctx.m_settings.anti_aim_enabled || !ctx.m_settings.fake_lag_enabled) { + lag = (cmd->command_number % 2) == 0; + } + + const auto origin_delta = sent_data.m_vecOrigin.IsZero() ? 0.f : sent_data.m_vecOrigin.Distance(ctx.m_local()->m_vecOrigin()); + auto choke_value = (int)ctx.m_settings.fake_lag_value; + + auto v6 = min(1, ctx.m_settings.fake_lag_variance) * 3; + + if (v6 > 0 && csgo.m_client_state()->m_iChockedCommands != 15) + choke_value -= RandomInt(0, (v6 / 10));// v6 * (2 * (csgo.m_globals()->tickcount & 1) - 1); + + //if (ctx.m_settings.fake_lag_type == 0 && choke_value > 10 && RandomInt(0, 1) == 1) + // choke_value -= RandomInt(1, 3); + + static bool byte_3CF29400 = false; + static int tick; + static bool something; + + static int dword_3CF29404 = 0; + auto v54 = cmd->command_number % 31; + auto v55 = 8 * (cmd->command_number % 31); + + + auto units_per_second = ctx.m_local()->m_vecVelocity().Length2D() * csgo.m_globals()->interval_per_tick; + + if (!ctx.m_settings.fake_lag_type) + lag = Math::clamp(ceil(64.0f / units_per_second), 1, 16) < choke_value; + else if (ctx.m_settings.fake_lag_type == 1) + lag = (chocked_ticks <= choke_value); //ye kind of randomizer + else if (ctx.m_settings.fake_lag_type == 2) + { + if ((cmd->command_number % max(1, ctx.m_settings.fake_lag_value)) > (choke_value / 2)) //ye kind of randomizer + lag = (chocked_ticks < (choke_value / 2)); + else + lag = (chocked_ticks < choke_value); + } + + static bool ducked = false; + const auto currently_ducked = cmd->buttons & IN_DUCK && !ctx.fakeducking; + bool is_onground = ctx.m_local()->m_fFlags() & FL_ONGROUND; + //static float prev_playback = ctx.m_local()->get_animation_layer(6).m_flPlaybackRate; + + if (ctx.m_settings.fake_lag_special) + { + const auto pre_prediction_speed = Engine::Prediction::Instance()->GetVelocity().Length2D(); + const auto post_prediction_speed = ctx.m_local()->m_vecVelocity().Length2D(); + + if (is_onground && pre_prediction_speed > post_prediction_speed && post_prediction_speed > 2.f + || is_onground && ctx.m_local()->get_animation_layers_count() > 6 && max(pre_prediction_speed, post_prediction_speed) > 5 && ctx.m_local()->get_animation_layer(6).m_flPlaybackRate < 0.1f + || ctx.can_aimbot && !m_weapon()->can_shoot() + || (cmd->buttons & IN_JUMP || !(Engine::Prediction::Instance()->GetFlags() & FL_ONGROUND && ctx.m_local()->m_fFlags() & FL_ONGROUND)) + /*|| currently_ducked != ducked && !currently_ducked && ctx.m_local()->m_flDuckAmount() > 0.f*/) + lag_timer = csgo.m_globals()->realtime + TICKS_TO_TIME(17); + + //const auto new_delta = max_delta; + + //if (Engine::Prediction::Instance()->GetVelocity().Length() > feature::anti_aim->animation_speed && Engine::Prediction::Instance()->GetVelocity().Length() > 6.f) + // lag_timer = csgo.m_globals()->realtime + 0.5f; + //prev_playback = ctx.m_local()->get_animation_layer(6).m_flPlaybackRate; + //old_delta = new_delta; + } + + //if (ctx.m_settings.fake_lag_between_shots && !m_weapon()->can_shoot()) + // lag_timer = csgo.m_globals()->realtime + 0.5f; + + auto maximal_choke = ctx.m_local()->m_vecVelocity().Length() < 5 ? 1 : max(1, choke_value); + + if (lag_timer >= csgo.m_globals()->realtime) { + lag = true; + maximal_choke = max(choke_value, max(1, ctx.m_settings.fake_lag_value)); + } + + if (ctx.m_settings.fake_lag_peek && ctx.m_local()->m_fFlags() & FL_ONGROUND && lag_timer <= csgo.m_globals()->realtime && m_weapon() && ctx.m_local()->m_vecVelocity().Length2D() >= Engine::Prediction::Instance()->GetVelocity().Length2D() && peek_fake_lag(cmd, send_packet)) + { + if (*send_packet) + { + lag_timer = csgo.m_globals()->realtime + TICKS_TO_TIME(17); + lag = !*send_packet; + } + maximal_choke = 14; + } + + if (csgo.m_engine()->IsVoiceRecording()/* || cheat::features::music.m_playing*/) + maximal_choke = min(choke_value, 3); + + if (ctx.has_exploit_toggled && ctx.main_exploit > 0 && ctx.exploit_allowed && ctx.ticks_allowed > 4 || ctx.allow_shooting > cmd->command_number + || enable_delay > csgo.m_globals()->realtime) + maximal_choke = min(choke_value, 1); + + //auto v32 = csgo.m_client_state()->m_clockdrift_manager.m_nServerTick - ctx.m_local()->entindex() % csgo.m_globals()->nTimestampRandomizeWindow; + //auto some_tick = v32 - v32 % csgo.m_globals()->nTimestampNetworkingBase; + + int entityMod = ctx.m_local()->entindex() % 32; + //int nBaseTick = 100 * (((ctx.current_tickcount + 8) - nEntityMod) / 100); + + //if (TIME_TO_TICKS(ctx.m_local()->m_flOldSimulationTime()) < some_tick + // && TIME_TO_TICKS(ctx.m_local()->m_flSimulationTime()) == some_tick) + //{ + // //lag_timer = csgo.m_globals()->realtime + TICKS_TO_TIME(17); + + // //if (csgo.m_client_state()->m_iChockedCommands <= min(16, choke_value)) + // maximal_choke = min(maximal_choke, 1); + //} + //if ((cmd->buttons & (IN_MOVELEFT | IN_MOVERIGHT | IN_FORWARD | IN_BACK)) != (Engine::Prediction::Instance()->prev_buttons & (IN_MOVELEFT | IN_MOVERIGHT | IN_FORWARD | IN_BACK))); + // maximal_choke = min(choke_value, 1); + + maximal_choke = max(maximal_choke, 1); + + ctx.accurate_max_previous_chocked_amt = (!lag ? csgo.m_client_state()->m_iChockedCommands : maximal_choke); + + if (chocked_ticks > maximal_choke) { + *send_packet = true; + last_chocked_amount = chocked_ticks; + } + else + *send_packet = !lag; + + if (ctx.m_settings.fake_lag_lag_compensation) { + auto tick_count = ctx.current_tickcount + 8 - entityMod; + + auto nBaseTick = 100 * (tick_count / 100); + if (nBaseTick <= 100 * ((tick_count - 1) / 100)) + { + auto v26 = (cmd->tick_count) - entityMod; + if (100 * ((v26 + 1) / 100) <= 100 * (v26 / 100)) + { + if (100 + * (((ctx.current_tickcount + 8) + - csgo.m_client_state()->m_iChockedCommands + - entityMod + + 4) + / 100) <= nBaseTick) + { + // + } + else + *send_packet = 0; + } + else + *send_packet = 1; + } + } + + unchocking = chocked_ticks == (maximal_choke - 1); + + //if (m_weapon() && last_unchoke_time <= m_weapon()->m_flLastShotTime() && (cmd->buttons & IN_ATTACK || cmd->buttons & IN_ATTACK2) && m_weapon()->can_shoot()) + // send_packet = true; + //if (force_nade_choke) + + /*if (m_weapon() && ctx.m_settings.aimbot_psilent_aim) { + auto ticks = TIME_TO_TICKS(csgo.m_globals()->curtime - m_weapon()->m_flLastShotTime()); + + if (ticks > 0 && ticks < 3) { + send_packet = true; + unchocking = true; + } + }*/ + + if (currently_ducked != ducked && !currently_ducked && ctx.m_local()->m_flDuckAmount() <= 0.2f || currently_ducked) + ducked = cmd->buttons & IN_DUCK && !ctx.fakeducking; + + ////if (ctx.m_settings.aimbot_nasa_psilent && !ctx.fakeducking && (!ctx.m_settings.aimbot_tickbase_exploit || !ctx.exploit_allowed)) + ////{ + ///* if (ctx.send_next_tick & PACKET_CHOKE) { + // send_packet = false; + // ctx.send_next_tick = PACKET_SEND; + // } + // else */if (ctx.send_next_tick & PACKET_SEND) + // { + // send_packet = true; + // ctx.send_next_tick = PACKET_NONE; + // unchocking = true; + // } + //} + +#ifdef VIRTUALIZER + +#endif // VIRTUALIZER +} + +void c_antiaimbot::fake_lagv2(CUserCmd* cmd, bool* send_packet) +{ +#ifdef VIRTUALIZER + +#endif // VIRTUALIZER + if (!cmd || cmd == nullptr || ctx.m_local() == nullptr) + return; + + unchocking = false; + + bool lag = false; static float lag_timer = 0.f; static float old_delta = 0.f; + + bool force_nade_choke = false; + + static bool is_throwing = false; + if (m_weapon() != nullptr && ctx.latest_weapon_data != nullptr && m_weapon()->IsGrenade() && m_weapon()->IsBeingThrowed()) + { + if (!(cmd->buttons & IN_ATTACK || cmd->buttons & IN_ATTACK2) && throw_nade || is_throwing) { + is_throwing = true; + enable_delay = csgo.m_globals()->realtime + csgo.m_globals()->interval_per_tick; + } + else + { + //maximal_choke = max(maximal_choke, 10); + force_nade_choke = true; + lag = true; + + throw_nade = true; + is_throwing = false; + } + } + else { + throw_nade = false; + is_throwing = false; + } + + if (ctx.fakeducking) + return; + + const auto chocked_ticks = csgo.m_client_state()->m_iChockedCommands; + const auto new_velo = (animation_speed > 2.f ? animation_speed : 0.f); + + RandomSeed(cmd->random_seed & 255); + + //const auto origin_delta = sent_data.m_vecOrigin.IsZero() ? 0.f : sent_data.m_vecOrigin.Distance(ctx.m_local()->m_vecOrigin()); + auto choke_value = (int)ctx.m_settings.fake_lag_value; + + auto v6 = RandomInt(0, choke_value / 4); + + if (choke_value > 2 && chocked_ticks != 15) + choke_value -= v6;// v6 * (2 * (csgo.m_globals()->tickcount & 1) - 1); + + if (new_velo < 2.f) + choke_value = 2; + + auto v7 = 0; + auto v8 = 2; + auto v9 = new_velo * csgo.m_globals()->interval_per_tick; + + switch (ctx.m_settings.fake_lag_type) + { + case 0: + if (chocked_ticks < choke_value) + lag = 1; + else + lag = false; + break; + case 1: + while (float(v7 * v9) <= 68.0f) + { + if (float((v8 - 1) * v9) > 68.0f) + { + ++v7; + break; + } + if (float(v8 * v9) > 68.0f) + { + v7 += 2; + break; + } + if (float(float(v8 + 1) * v9) > 68.0f) + { + v7 += 3; + break; + } + if (float(float(v8 + 2) * v9) > 68.0f) + { + v7 += 4; + break; + } + v8 += 5; + v7 += 5; + if (v8 > 16) + break; + } + if (chocked_ticks < choke_value) + lag = 1; + else + lag = false; + break; + default: + break; + } + + if (!ctx.m_settings.fake_lag_enabled) + lag = false; + + if (lag) + { + if (csgo.m_engine()->IsVoiceRecording() && chocked_ticks > 3) + lag = false; + + if (chocked_ticks > 0 && (ctx.has_exploit_toggled && ctx.main_exploit > 0 && ctx.exploit_allowed && ctx.ticks_allowed > 4 || ctx.allow_shooting > cmd->command_number + || enable_delay > csgo.m_globals()->realtime)) + lag = false; + } + else + { + if (ctx.m_settings.anti_aim_enabled && !ctx.m_settings.fake_lag_enabled) + lag = (cmd->command_number % 2) == 0; + } + + if (lag) + *send_packet = false; + + //if (currently_ducked != ducked && !currently_ducked && ctx.m_local()->m_flDuckAmount() <= 0.2f || currently_ducked) + // ducked = cmd->buttons & IN_DUCK && !ctx.fakeducking; + +#ifdef VIRTUALIZER + +#endif // VIRTUALIZER +} + + +void c_antiaimbot::work(CUserCmd* cmd, bool* send_packet) +{ + if (cmd == nullptr || ctx.m_local() == nullptr) + return; + +#ifdef VIRTUALIZER + +#endif // VIRTUALIZER + + /*auto pressed_move_key = (cmd->buttons & IN_MOVELEFT + || cmd->buttons & IN_MOVERIGHT + || cmd->buttons & IN_BACK + || cmd->buttons & IN_FORWARD);*/ + + if (ctx.m_settings.anti_aim_enabled && m_weapon()->m_reloadState() == 0/*!(cmd->buttons & (IN_ATTACK | IN_ATTACK2 | IN_MOVERIGHT | IN_MOVELEFT | IN_USE | IN_BACK | IN_FORWARD | IN_JUMP))*/ + && sqrtf((cmd->forwardmove * cmd->forwardmove) + (cmd->sidemove * cmd->sidemove)) < 0.1f) + { + if (sqrtf((ctx.m_local()->m_vecVelocity().y * ctx.m_local()->m_vecVelocity().y) + (ctx.m_local()->m_vecVelocity().x * ctx.m_local()->m_vecVelocity().x)) < 0.1f) + { + auto v12 = 1.01f;/* : -1.01f;*/ + + if (ctx.m_local()->m_bDucking() || ctx.m_local()->m_fFlags() & 2) + v12 = v12 / (((ctx.m_local()->m_flDuckAmount() * 0.34f) + 1.0f) - ctx.m_local()->m_flDuckAmount()); + + if (!(cmd->command_number & 1)) + v12 *= -1; + + cmd->forwardmove = v12; + } + } + + //if (/*!pressed_move_key &&*/ move_speed <= 0.1f && vel_speed <= 0.1f + // && ctx.m_local()->m_fFlags() & FL_ONGROUND && Engine::Prediction::Instance()->GetFlags() & FL_ONGROUND + // && (ctx.m_settings.anti_aim_typelby == 1 || ctx.m_settings.anti_aim_typelby == 0 && ctx.main_exploit > 0 && ctx.has_exploit_toggled && ctx.exploit_allowed)) + //{ + // const auto duck_amnt = ctx.m_local()->m_flDuckAmount(); + // float duck_amnt2; + // const auto in_duck_button = (cmd->buttons & IN_DUCK); + + // if (in_duck_button || ctx.fakeducking) + // duck_amnt2 = fminf(1.0f, ((csgzo.m_globals()->interval_per_tick * 0.8f) * ctx.m_local()->m_flDuckSpeed()) + duck_amnt); + // else + // duck_amnt2 = fmaxf(0.0f, duck_amnt - (fmaxf(1.5f, ctx.m_local()->m_flDuckSpeed()) * csgo.m_globals()->interval_per_tick)); + + // if (!(cmd->command_number & 1)) + // cmd->forwardmove = -(ctx.m_local()->m_vecViewOffset().z < 64.f ? 3.f * duck_amnt2 : 1.01f); + // else + // cmd->forwardmove = (ctx.m_local()->m_vecViewOffset().z < 64.f ? 3.f * duck_amnt2 : 1.01f); + + // /*static float old_forwardmove = 1.01f; + + // auto newforwardmove = old_forwardmove; + // auto duck_amnt = ctx.m_local()->m_flDuckAmount(); + // float duck_amnt2 = 0.f; + // auto in_duck_button = (cmd->buttons & IN_DUCK); + + // if (in_duck_button) + // duck_amnt2 = fminf(1.0f, ((csgo.m_globals()->interval_per_tick * 0.8f) * ctx.m_local()->m_flDuckSpeed()) + duck_amnt); + // else + // duck_amnt2 = fmaxf(0.0f, duck_amnt - (fmaxf(1.5f, ctx.m_local()->m_flDuckSpeed()) * csgo.m_globals()->interval_per_tick)); + + // if (in_duck_button || ctx.m_local()->m_bDucked() || ctx.m_local()->m_fFlags() & 2) + // newforwardmove = newforwardmove / (((duck_amnt2 * 0.34f) + 1.0f) - duck_amnt2); + + // old_forwardmove *= -1.f; + + // auto old_move = cmd->forwardmove; + + // if (old_move != 0.0f) + // { + // if (old_move >= 0.0f) + // newforwardmove = newforwardmove + old_move; + // else + // newforwardmove = old_move - newforwardmove; + // } + + // cmd->forwardmove = newforwardmove;*/ + //} + + if (ctx.fside == 0) + previous_side = ctx.fside = 1; + + ctx.changed_fake_side = false; + + const bool can_show = !(enable_delay > csgo.m_globals()->realtime || !m_weapon() || !ctx.m_settings.anti_aim_enabled || ctx.m_local()->m_MoveType() == 9 || ctx.m_local()->m_MoveType() == 8 || (cmd->buttons & IN_USE && !(m_weapon()->m_iItemDefinitionIndex() == WEAPON_C4 || ctx.m_local()->m_bIsDefusing()))); + + if (ctx.get_key_press(ctx.m_settings.anti_aim_fake_switch.key)) { + ctx.fside *= -1; + + previous_side = ctx.fside; + + if (can_show) { + ctx.changed_fake_side = true; + ctx.active_keybinds[7].mode = 4; + } + } + + if (ctx.get_key_press(ctx.m_settings.anti_aim_yaw_left_switch.key)){ + ctx.side = (ctx.side == 0 ? -1 : 0); + + if (can_show) + ctx.active_keybinds[10].mode = 4; + } + + if (ctx.get_key_press(ctx.m_settings.anti_aim_yaw_right_switch.key)){ + ctx.side = (ctx.side == 1 ? -1 : 1); + + if (can_show) + ctx.active_keybinds[9].mode = 4; + } + + if (ctx.get_key_press(ctx.m_settings.anti_aim_yaw_backward_switch.key)) { + ctx.side = (ctx.side == 2 ? -1 : 2); + + if (can_show) + ctx.active_keybinds[8].mode = 4; + } + + if (!can_show || ctx.onshot_aa_cmd == cmd->command_number/*ctx.onshot_desync == 2 && m_weapon()->can_shoot() && ctx.do_autostop*/) return; + + if (cmd->buttons & IN_USE) + { + static bool force_choke = false; + + if (m_weapon()->m_iItemDefinitionIndex() == WEAPON_C4 || ctx.m_local()->m_bIsDefusing()) + { + if (TICKS_TO_TIME(ctx.m_local()->m_nTickBase()) > feature::anti_aim->lby_timer && csgo.m_client_state()->m_iChockedCommands == 0) + { + cmd->viewangles.y = Math::normalize_angle(ctx.m_local()->m_angEyeAngles().y - (180.f - ctx.fside)); + *send_packet = false; + force_choke = true; + + cmd->viewangles.Clamp(); + + return; + } + + if (force_choke) + { + *send_packet = false; + force_choke = false; + } + + return; + } + else //legit aimbot on USE key can be there. + return; + } + + //#TODO: planting & defusing anti-aim to be less hittable + + change_angles(cmd, send_packet); + +#ifdef VIRTUALIZER + +#endif // VIRTUALIZER +} +``` + +`anti_aimbot.hpp`: + +```hpp +#pragma once +#include "sdk.hpp" + +struct last_sent_data +{ + void store(float _simtime, + Vector _m_vecOrigin, + Vector _m_vecVelocity, + Vector _eye_position, + QAngle _m_angEyeAngles, + int _tickbase, + int _command_number, + int _m_fFlags) + { + simtime = _simtime; + m_vecOrigin = _m_vecOrigin; + m_vecVelocity = _m_vecVelocity; + eye_position = _eye_position; + m_angEyeAngles = _m_angEyeAngles; + tickbase = _tickbase; + command_number = _command_number; + m_fFlags = _m_fFlags; + } + + float simtime; + Vector m_vecOrigin; + Vector m_vecVelocity; + Vector eye_position; + QAngle m_angEyeAngles; + int tickbase; + int command_number; + int m_fFlags; +}; + +class AdaptiveAngle { +public: + float m_yaw; + float m_dist; + +public: + // ctor. + AdaptiveAngle(const float& yaw, const float& penalty = 0.f) { + // set yaw. + m_yaw = Math::normalize_angle(yaw); + + // init distance. + m_dist = 0.f; + + // remove penalty. + m_dist -= penalty; + } +}; + +// best target. +struct AutoTarget_t { float fov; C_BasePlayer* player; }; + +class c_antiaimbot +{ +public: + virtual float get_max_desync_delta(C_BasePlayer* ent); + virtual void get_targets(); + virtual void run_at_target(float& yaw); + virtual void auto_direction(); + //bool run_freestand(float& yaw); + /*virtual*/ void change_angles(CUserCmd* cmd, bool* send_packet); + virtual bool peek_fake_lag(CUserCmd* cmd, bool* send_packet); + virtual void fake_lag(CUserCmd* cmd, bool* send_packet); + virtual void fake_lagv2(CUserCmd* cmd, bool* send_packet); + virtual void work(CUserCmd* cmd, bool* send_packet); + + float enable_delay = 0.f; + bool flip_side = false; + int previous_side = 0; + bool extend = false; + QAngle last_real_angle = QAngle::Zero; + float fake_yaw_diff_with_backwards = 0.f; + float real_yaw_diff_with_backwards = 0.f; + QAngle visual_real_angle = QAngle::Zero; + + float m_next_lby_update_time = 0.f, m_last_lby_update = 0.f, m_last_attempted_lby = 0.f; + bool m_will_lby_update = false; + + float min_delta = 0.f, max_delta = 0.f, + feet_speed_stand = 0.f, feet_speed_ducked = 0.f; + + float animation_speed = 0.f; + Vector previous_velocity = Vector::Zero; + Vector animation_velocity = Vector::Zero; + float m_auto_dist; + float m_auto; + float m_auto_time; + float m_auto_last; + + last_sent_data sent_data; + float last_unchoke_time = 0.f; + bool unchocking = false; + bool skip_fakelag_this_tick = false; + int last_chocked_amount = 0; + float lby_timer = 0.f; + float lby_expected = 0.f; + bool throw_nade = false; + + float stop_to_full_running_fraction = 0.f; + + bool is_standing = false; + + bool did_shot_in_chocked_cycle = false; + std::vector players; + Vector origins[64]; +}; +``` + +`auto.hpp`: + +```hpp +#pragma once + +#include "os.hpp" + +#include +#include +#include + +#include + +//#include "lua_engine.hpp" +// +//#define SOL_USING_CXX_LUA 1 +//#define SOL_USING_CXX_LUAJIT 1 +////#define SOL_SAFE_REFERENCES 1 +//#define SOL_SAFE_FUNCTION_CALLS 1 +// +////#include +//#pragma comment(lib, "src/lua51.lib") + +struct s_interface +{ + s_interface(const char* dll, const char* name, void* interfaceBase) + : m_module(dll) + , m_name(name) + , m_interface(interfaceBase) + { + + } + + const char* m_module; + const char* m_name; + void* m_interface; +}; + +//-------------------------------------------------------------------------------- +//-- XorCompileTime.hpp +// +// Author: frk +// Date: 12.12.2015 +// +//-------------------------------------------------------------------------------- + +#pragma once +#include +#include +#include + +#define BEGIN_NAMESPACE( x ) namespace x { +#define END_NAMESPACE } + +BEGIN_NAMESPACE(strenc) + +constexpr auto time = __TIME__; +constexpr auto seed = static_cast(time[7]) + static_cast(time[6]) * 10 + static_cast(time[4]) * 60 + static_cast(time[3]) * 600 + static_cast(time[1]) * 3600 + static_cast(time[0]) * 36000; + +// 1988, Stephen Park and Keith Miller +// "Random Number Generators: Good Ones Are Hard To Find", considered as "minimal standard" +// Park-Miller 31 bit pseudo-random number generator, implemented with G. Carta's optimisation: +// with 32-bit math and without division + +template < int N > +struct RandomGenerator +{ +private: + static constexpr unsigned a = 16807; // 7^5 + static constexpr unsigned m = 2147483647; // 2^31 - 1 + + static constexpr unsigned s = RandomGenerator< N - 1 >::value; + static constexpr unsigned lo = a * (s & 0xFFFF); // Multiply lower 16 bits by 16807 + static constexpr unsigned hi = a * (s >> 16); // Multiply higher 16 bits by 16807 + static constexpr unsigned lo2 = lo + ((hi & 0x7FFF) << 16); // Combine lower 15 bits of hi with lo's upper bits + static constexpr unsigned hi2 = hi >> 15; // Discard lower 15 bits of hi + static constexpr unsigned lo3 = lo2 + hi; + +public: + static constexpr unsigned max = m; + static constexpr unsigned value = lo3 > m ? lo3 - m : lo3; +}; + +template <> +struct RandomGenerator< 0 > +{ + static constexpr unsigned value = seed; +}; + +template < int N, int M > +struct RandomInt +{ + static constexpr auto value = RandomGenerator< N + 1 >::value % M; +}; + +template < int N > +struct RandomChar +{ + static const char value = static_cast(1 + RandomInt< N, 0x7F - 1 >::value); +}; + +template < size_t N, int K > +struct XorString +{ +private: + const char _key; + std::array< char, N + 1 > _encrypted; + bool decrypted = false; + + constexpr char enc(char c) const + { + return c ^ _key; + } + + char dec(char c) const + { + return c ^ _key; + } + +public: + template < size_t... Is > + constexpr FORCEINLINE XorString(const char* str, std::index_sequence< Is... >) : _key(RandomChar< K >::value), _encrypted{ enc(str[Is])... } + { + } + + FORCEINLINE decltype(auto) decrypt(void) + { + if (!decrypted) + { + for (size_t i = 0; i < N; ++i) + { + _encrypted[i] = dec(_encrypted[i]); + } + _encrypted[N] = '\0'; + decrypted = true; + } + return _encrypted.data(); + } +}; + +//-------------------------------------------------------------------------------- +//-- Note: XorStr will __NOT__ work directly with functions like printf. +// To work with them you need a wrapper function that takes a const char* +// as parameter and passes it to printf and alike. +// +// The Microsoft Compiler/Linker is not working correctly with variadic +// templates! +// +// Use the functions below or use std::cout (and similar)! +//-------------------------------------------------------------------------------- + +static auto w_printf = [](const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + vprintf_s(fmt, args); + va_end(args); +}; + +static auto w_printf_s = [](const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + vprintf_s(fmt, args); + va_end(args); +}; + +static auto w_sprintf = [](char* buf, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + vsprintf(buf, fmt, args); + va_end(args); +}; + +static auto w_sprintf_s = [](char* buf, size_t buf_size, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + vsprintf_s(buf, buf_size, fmt, args); + va_end(args); +}; + +//for compatibility with debug mode +struct debug_ret +{ +private: + const char* ret; + +public: + debug_ret(const char* str) : ret(str) { }; + + auto decrypt() + { + return ret; + } +}; + +#ifndef DEBUG +#define xor_raw( s ) ( strenc::XorString< sizeof( s ) - 1, __COUNTER__ >( s, std::make_index_sequence< sizeof( s ) - 1>() ) ) +#define sxor( s ) ( strenc::XorString< sizeof( s ) - 1, __COUNTER__ >( s, std::make_index_sequence< sizeof( s ) - 1>() ).decrypt() ) +#else +#define xor_raw( s ) ( [ ]{ strenc::debug_ret ret{ s }; return ret; }( ) ) +#define sxor( s ) ( s ) +#endif + +END_NAMESPACE + +#ifndef AUTH + +#define get_object(object, NAME) (object) + +#else + +#define get_object(object, NAME) ((decltype(object))[]() -> DWORD { \ + const static int marker = 0xDEADBABE; \ + static DWORD _fiddler_##NAME = __LINE__ + 1; \ + static DWORD _keyiddler_##NAME = __LINE__; \ + static DWORD _offsetidller_##NAME = 0; \ + return (_fiddler_##NAME ^ _keyiddler_##NAME) - marker; \ + }()) + +#define get_object_no_cast(NAME) ([]() -> DWORD { \ + const static int marker = 0xDEADBABE; \ + static DWORD _fiddler_##NAME = __LINE__ + 1; \ + static DWORD _keyiddler_##NAME = __LINE__; \ + static DWORD _offsetidller_##NAME = 0; \ + return (_fiddler_##NAME ^ _keyiddler_##NAME) - marker; \ + }()) + +#endif + +#include "vmpsdk.h" + +#pragma once +#include + +//fnv1a 32 and 64 bit hash functions +// key is the data to hash, len is the size of the data (or how much of it to hash against) +// code license: public domain or equivalent +// post: https://notes.underscorediscovery.com/constexpr-fnv1a/ + +constexpr uint32_t val_32_const = 0x811c9dc5; +constexpr uint32_t prime_32_const = 0x1000193; +constexpr uint64_t val_64_const = 0xcbf29ce484222325; +constexpr uint64_t prime_64_const = 0x100000001b3; + +inline const uint32_t hash_32_fnv1a(const void* key, const uint32_t len) { + + const char* data = (char*)key; + uint32_t hash = 0x811c9dc5; + uint32_t prime = 0x1000193; + + for (int i = 0; i < (int)len; ++i) { + uint8_t value = data[i]; + hash = hash ^ value; + hash *= prime; + } + + return hash; + +} //hash_32_fnv1a + +inline const uint64_t hash_64_fnv1a(const void* key, const uint64_t len) { + + const char* data = (char*)key; + uint64_t hash = 0xcbf29ce484222325; + uint64_t prime = 0x100000001b3; + + for (int i = 0; i < len; ++i) { + uint8_t value = data[i]; + hash = hash ^ value; + hash *= prime; + } + + return hash; + +} //hash_64_fnv1a + +inline constexpr uint32_t hash_32_fnv1a_const(const char* const str, const uint32_t value = val_32_const) noexcept { + return (str[0] == '\0') ? value : hash_32_fnv1a_const(&str[1], (value ^ uint32_t(str[0])) * prime_32_const); +} + +inline constexpr uint64_t hash_64_fnv1a_const(const char* const str, const uint64_t value = val_64_const) noexcept { + return (str[0] == '\0') ? value : hash_64_fnv1a_const(&str[1], (value ^ uint64_t(str[0])) * prime_64_const); +} + + +typedef uint32_t u32; +typedef uint64_t u64; +typedef unsigned char uchar; + +template +struct LinearGenerator { + static const u32 state = ((u64)S * A + C) % M; + static const u32 value = state; + typedef LinearGenerator next; + struct Split { + typedef LinearGenerator< state, A* A, 0, M> Gen1; + typedef LinearGenerator Gen2; + }; +}; + +template +struct Generate { + static const uchar value = Generate::state, index - 1>::value; +}; + +template +struct Generate { + static const uchar value = static_cast (LinearGenerator::value); +}; + +template +struct StList {}; + +template +struct Concat; + +template +struct Concat, StList> { + typedef StList type; +}; + +template +using Concat_t = typename Concat::type; + +template +struct Count { + typedef Concat_t::type, StList> type; +}; + +template<> +struct Count<0> { + typedef StList<> type; +}; + +template +using Count_t = typename Count::type; + +template +constexpr uchar get_scrambled_char(const char(&a)[N]) { + return static_cast(a[index]) + Generate::value; +} + +template +struct cipher_helper; + +template +struct cipher_helper> { + static constexpr std::array get_array(const char(&a)[sizeof...(SL)]) { + return{ { get_scrambled_char(a)... } }; + } +}; + +template +constexpr std::array get_cipher_text(const char(&a)[N]) { + return cipher_helper>::get_array(a); +} + +template +struct noise_helper; + +template +struct noise_helper> { + static constexpr std::array get_array() { + return{ { Generate::value ... } }; + } +}; + +template +constexpr std::array get_key() { + return noise_helper>::get_array(); +} + + +template +struct array_info; + +template +struct array_info +{ + typedef T type; + enum { size = N }; +}; + +template +struct array_info : array_info {}; + +template +class obfuscated_string { +private: + std::array cipher_text_; + std::array key_; +public: + explicit constexpr obfuscated_string(const char(&a)[N]) : cipher_text_(get_cipher_text(a)), key_(get_key()) + {} + + operator std::string() const { + char plain_text[N]; + for (volatile std::size_t i = 0; i < N; ++i) { + volatile char temp = static_cast(cipher_text_[i] - key_[i]); + plain_text[i] = temp; + } + + std::string temp{ plain_text, plain_text + N }; + for (volatile std::size_t i = 0; i < N; ++i) + plain_text[i] = '\0'; + + return temp; + } +}; + +template +std::ostream& operator<< (std::ostream& s, const obfuscated_string& str) { + s << static_cast(str); + return s; +} + +#define RNG_SEED ((__TIME__[7] - '0') * 1 + (__TIME__[6] - '0') * 10 + \ + (__TIME__[4] - '0') * 60 + (__TIME__[3] - '0') * 600 + \ + (__TIME__[1] - '0') * 3600 + (__TIME__[0] - '0') * 36000) + \ + (__LINE__ * 100000) + + +#define LIT(STR) \ + obfuscated_string::size>{STR} +``` + +`autostop.txt`: + +```txt +float& C_BasePlayer::m_surfaceFriction() +{ + static unsigned int _m_surfaceFriction = FindInDataMap(GetPredDescMap(), "m_surfaceFriction"); + return *(float*)((uintptr_t)this + _m_surfaceFriction); +} + +void Movement::Quick_stop(CUserCmd* cmd) + { + if (!ctx.m_local()) + return; + + Vector hvel = ctx.m_local()->m_vecVelocity(); + hvel.z = 0; + float speed = hvel.Length2D(); + + if (speed < 1.f) + { + cmd->forwardmove = 0.f; + cmd->sidemove = 0.f; + return; + } + + static float accel = csgo.m_engine_cvars()->FindVar("sv_accelerate")->GetFloat(); + static float maxSpeed = csgo.m_engine_cvars()->FindVar("sv_maxspeed")->GetFloat(); + float playerSurfaceFriction = ctx.m_local()->m_surfaceFriction(); + float max_accelspeed = accel * csgo.m_globals()->interval_per_tick * maxSpeed * playerSurfaceFriction; + + float wishspeed{}; + + if (speed - max_accelspeed <= -1.f) + { + // speed - accelspeed = 0 + // speed - accel*frametime*wishspeed = 0 + // accel*frametime*wishspeed = speed + // wishspeed = speed / (accel*frametime) + wishspeed = max_accelspeed / (speed / (accel * csgo.m_globals()->interval_per_tick)); + } + else // Full deceleration, since it won't overshoot + { + // Or use max_accelspeed, doesn't matter + wishspeed = max_accelspeed; + } + + Vector ndir = (hvel * -1.f); Math::VectorAngles(ndir, ndir); + ndir.y = cmd->viewangles.y - ndir.y; + Math::AngleVectors(ndir, &ndir); + + cmd->forwardmove = ndir.x * wishspeed; + cmd->sidemove = ndir.y * wishspeed; + } + + +ctx.do_autostop = true в аимботе + +саму функцию вызывать ПЕРЕД EnginePrediction. + +void c_aimbot::autostop(CUserCmd* cmd, bool& send_packet, C_WeaponCSBaseGun* local_weapon) +{ + static auto accel = csgo.m_engine_cvars()->FindVar("sv_accelerate"); + + if (ctx.m_settings.aimbot_autostop == 0) + return; + + static bool was_onground = ctx.m_local()->m_fFlags() & FL_ONGROUND; + + if (ctx.do_autostop && local_weapon && local_weapon->GetCSWeaponData() && was_onground && ctx.m_local()->m_fFlags() & FL_ONGROUND) + { + auto speed = ((cmd->sidemove * cmd->sidemove) + (cmd->forwardmove * cmd->forwardmove)); + auto lol = sqrt(speed); + + auto velocity = ctx.m_local()->m_vecVelocity() + (ctx.m_local()->m_vecVelocity() * csgo.m_globals()->interval_per_tick); + float maxspeed = 30.f; + + if (!ctx.m_local()->m_bIsScoped()) + maxspeed = *(float*)(uintptr_t(local_weapon->GetCSWeaponData()) + 0x130); + else + maxspeed = *(float*)(uintptr_t(local_weapon->GetCSWeaponData()) + 0x134);//local_weapon->GetCSWeaponData()->max_speed; + + maxspeed *= 0.31f; + + float max_accelspeed = accel->GetFloat() * csgo.m_globals()->interval_per_tick * m_weapon()->GetMaxWeaponSpeed() * ctx.m_local()->m_surfaceFriction(); + + switch (ctx.m_settings.aimbot_autostop) + { + case 1: + { + cmd->buttons |= IN_SPEED; + + if ((velocity.Length2D() + 1.f) > maxspeed) + { + // cmd->buttons |= IN_WALK; + //Engine::Movement::Instance()->quick_stop(cmd); + + if ((maxspeed + 1.0f) <= velocity.Length2D()) + { + cmd->forwardmove = 0.0f; + cmd->sidemove = 0.0f; + } + else + { + cmd->sidemove = (maxspeed * (cmd->sidemove / lol)); + cmd->forwardmove = (maxspeed * (cmd->forwardmove / lol)); + } + } + } + break; + case 2: + { + cmd->buttons |= IN_SPEED; + Engine::Movement::Instance()->Quick_stop(cmd); + } + break; + } + + /*Engine::Movement::Instance()->m_qAnglesView.y = RAD2DEG(std::atan2(ctx.m_local()->m_vecVelocity().y, ctx.m_local()->m_vecVelocity().x)) - 180.f;*/ + + ctx.do_autostop = false; + } + + was_onground = (ctx.m_local()->m_fFlags() & FL_ONGROUND); +} +``` + +`autowall.cpp`: + +```cpp +#include "sdk.hpp" +#include "autowall.hpp" +#include "rage_aimbot.hpp" +#include "source.hpp" +#include "entity.hpp" +#include "player.hpp" +#include "weapon.hpp" +#include "hooked.hpp" +#include "math.hpp" +#include "displacement.hpp" + +#include + +#define SLOBYTE(x) (*((int8_t*)&(x))) + +void c_autowall::TraceLine(Vector& absStart, const Vector& absEnd, unsigned int mask, C_BasePlayer* ignore, CGameTrace* ptr) +{ + Ray_t ray; + ray.Init(absStart, absEnd); + CTraceFilter filter; + filter.pSkip = ignore; + + csgo.m_engine_trace()->TraceRay(ray, mask, &filter, ptr); +} + +float c_autowall::ScaleDamage(C_BasePlayer* player, float damage, float armor_ratio, int hitgroup) { + if (!player || !player->GetClientClass() || !ctx.m_local()->get_weapon() || player->GetClientClass()->m_ClassID != class_ids::CCSPlayer) + return 0.f; + + auto new_damage = damage; + + const auto is_zeus = ctx.m_local()->get_weapon()->m_iItemDefinitionIndex() == WEAPON_TASER; + + static auto is_armored = [](C_BasePlayer* player, int armor, int hitgroup) { + if (player && player->m_ArmorValue() > 0) + { + if (player->m_bHasHelmet() && hitgroup == HITGROUP_HEAD || (hitgroup >= HITGROUP_CHEST && hitgroup <= HITGROUP_RIGHTARM || hitgroup == 8 || hitgroup == 0)) + return true; + } + return false; + }; + + if (!is_zeus) { + switch (hitgroup) + { + case HITGROUP_HEAD: + new_damage *= 4.f; + break; + case HITGROUP_STOMACH: + new_damage *= 1.25f; + break; + case HITGROUP_LEFTLEG: + case HITGROUP_RIGHTLEG: + new_damage *= .75f; + break; + default: + break; + /*4.0; 1 + 1.0; 2 + 1.25; 3 + 1.0; 4 + 1.0; 5 + 0.75; 6 + 0.75; 7 + 1.0; 8*/ + } + } + else + new_damage *= 0.92f; + + if (is_armored(player, player->m_ArmorValue(), hitgroup)) + { + float flHeavyRatio = 1.0f; + float flBonusRatio = 0.5f; + float flRatio = armor_ratio * 0.5f; + float flNewDamage; + + if (!player->m_bHasHeavyArmor()) + { + flNewDamage = damage * flRatio; + } + else + { + flBonusRatio = 0.33f; + flRatio = armor_ratio * 0.25f; + flHeavyRatio = 0.33f; + flNewDamage = (damage * flRatio) * 0.85f; + } + + int iArmor = player->m_ArmorValue(); + + if (((damage - flNewDamage) * (flHeavyRatio * flBonusRatio)) > iArmor) + flNewDamage = damage - (iArmor / flBonusRatio); + + new_damage = flNewDamage; + } + + return floorf(new_damage); +} + +void c_autowall::ScaleDamage(CGameTrace& enterTrace, weapon_info* weaponData, float& currentDamage) +{ + if (!enterTrace.m_pEnt || !enterTrace.m_pEnt->GetClientClass() || !ctx.m_local()->get_weapon() || enterTrace.m_pEnt->GetClientClass()->m_ClassID != class_ids::CCSPlayer) + return; + + C_BasePlayer* target = (C_BasePlayer*)enterTrace.m_pEnt; + + auto new_damage = currentDamage; + + const int hitgroup = enterTrace.hitgroup; + const auto is_zeus = ctx.m_local()->get_weapon()->m_iItemDefinitionIndex() == WEAPON_TASER; + + static auto is_armored = [](C_BasePlayer* player, int armor, int hitgroup) { + if (player && player->m_ArmorValue() > 0) + { + if (player->m_bHasHelmet() && hitgroup == HITGROUP_HEAD || (hitgroup >= HITGROUP_CHEST && hitgroup <= HITGROUP_RIGHTARM)) + return true; + } + return false; + }; + + if (!is_zeus) { + switch (hitgroup) + { + case HITGROUP_HEAD: + new_damage *= 4.f; + break; + case HITGROUP_STOMACH: + new_damage *= 1.25f; + break; + case HITGROUP_LEFTLEG: + case HITGROUP_RIGHTLEG: + new_damage *= .75f; + break; + default: + break; + /*4.0; 1 + 1.0; 2 + 1.25; 3 + 1.0; 4 + 1.0; 5 + 0.75; 6 + 0.75; 7 + 1.0; 8*/ + } + } + else + new_damage *= 0.92f; + + if (is_armored(target, target->m_ArmorValue(), hitgroup)) + { + float flHeavyRatio = 1.0f; + float flBonusRatio = 0.5f; + float flRatio = weaponData->armor_ratio * 0.5f; + float flNewDamage; + + if (!target->m_bHasHeavyArmor()) + { + flNewDamage = new_damage * flRatio; + } + else + { + flBonusRatio = 0.33f; + flRatio = weaponData->armor_ratio * 0.5f; + flHeavyRatio = 0.33f; + flNewDamage = (new_damage * (flRatio * 0.5)) * 0.85f; + } + + int iArmor = target->m_ArmorValue(); + + if (((new_damage - flNewDamage) * (flBonusRatio * flHeavyRatio)) > iArmor) + flNewDamage = new_damage - (iArmor / flBonusRatio); + + new_damage = flNewDamage; + } + + currentDamage = new_damage; +} + +//void c_autowall::ScaleDamage(C_BasePlayer* entity, int hitgroup, weapon_info* weaponData, float& currentDamage) +//{ +// if (!entity || entity->IsDormant() || !entity->GetClientClass() || !ctx.m_local()->get_weapon()) { +// currentDamage = 0.0f; +// return; +// } +// +// const auto is_zeus = ctx.m_local()->get_weapon()->m_iItemDefinitionIndex() == WEAPON_TASER; +// +// const auto is_armored = [&]() -> bool +// { +// if (entity->m_ArmorValue() > 0) +// { +// switch (hitgroup) +// { +// case HITGROUP_GENERIC: +// case HITGROUP_CHEST: +// case HITGROUP_STOMACH: +// case HITGROUP_LEFTARM: +// case HITGROUP_RIGHTARM: +// return true; +// case HITGROUP_HEAD: +// return entity->m_bHasHelmet(); +// default: +// break; +// } +// } +// +// return false; +// }; +// +// float new_damage = currentDamage; +// +// if (!is_zeus) { +// switch (hitgroup) +// { +// case HITGROUP_HEAD: +// if (entity->m_bHasHeavyArmor()) +// new_damage = currentDamage * 2.0f; +// else +// new_damage = currentDamage * 4.0f; +// break; +// case HITGROUP_STOMACH: +// new_damage = currentDamage * 1.25f; +// break; +// case HITGROUP_LEFTLEG: +// case HITGROUP_RIGHTLEG: +// new_damage = currentDamage * .75f; +// break; +// default: +// new_damage = currentDamage; +// break; +// /*4.0; 1 +// 1.0; 2 +// 1.25; 3 +// 1.0; 4 +// 1.0; 5 +// 0.75; 6 +// 0.75; 7 +// 1.0; 8*/ +// } +// } +// else +// new_damage = currentDamage * 0.92f; +// +// if (is_armored()) +// { +// auto modifier = 1.f, armor_bonus_ratio = .5f, armor_ratio = weaponData->armor_ratio * .5f; +// +// if (entity->m_bHasHeavyArmor()) +// { +// armor_bonus_ratio = 0.33f; +// armor_ratio *= 0.2f; +// modifier = 0.25f; +// } +// +// auto new_damage = currentDamage * armor_ratio; +// +// if (entity->m_bHasHeavyArmor()) +// new_damage *= 0.85f; +// +// const auto scaled_armor_ratio = (currentDamage - new_damage) * (modifier * armor_bonus_ratio); +// +// if (scaled_armor_ratio > entity->m_ArmorValue()) +// new_damage = currentDamage - (entity->m_ArmorValue() / armor_bonus_ratio); +// +// currentDamage = new_damage; +// } +// +// currentDamage = new_damage; +//} + +uint32_t c_autowall::get_filter_simple_vtable() +{ + return *reinterpret_cast(Engine::Displacement::Signatures[c_signatures::TRACEFILTER_SIMPLE] + 0x3d); +} + +bool c_autowall::TraceToExit(const Vector& start, const Vector dir, Vector& out, trace_t* enter_trace, trace_t* exit_trace) +{ + static ConVar* sv_clip_penetration_traces_to_players = csgo.m_engine_cvars()->FindVar(sxor("sv_clip_penetration_traces_to_players")); + + Vector new_end; + float dist = 0.0f; + int iterations = 23; + int first_contents = 0; + int contents; + Ray_t r{}; + + while (1) + { + iterations--; + + if (iterations <= 0 || dist > 90.f) + break; + + dist += 4.0f; + out = start + (dir * dist); + + contents = csgo.m_engine_trace()->GetPointContents(out, 0x4600400B, nullptr); + + if (first_contents == -1) + first_contents = contents; + + if (contents & 0x600400B && (!(contents & CONTENTS_HITBOX) || first_contents == contents)) + continue; + + new_end = out - (dir * 4.f); + + //r.Init(out, new_end); + //CTraceFilter filter; + //filter.pSkip = nullptr; + //csgo.m_engine_trace()->TraceRay(r, MASK_SHOT, &filter, exit_trace); + TraceLine(out, new_end, 0x4600400B, nullptr, exit_trace); + + if (exit_trace->startsolid && (exit_trace->surface.flags & SURF_HITBOX) != 0) + { + //r.Init(out, start); + //filter.pSkip = exit_trace->m_pEnt; + //filter.pSkip = (exit_trace->m_pEnt); + //csgo.m_engine_trace()->TraceRay(r, MASK_SHOT_HULL, &filter, exit_trace); + TraceLine(out, start, MASK_SHOT_HULL, (C_BasePlayer*)exit_trace->m_pEnt, exit_trace); + + if (exit_trace->DidHit() && !exit_trace->startsolid) + { + out = exit_trace->endpos; + return true; + } + continue; + } + + if (!exit_trace->DidHit() || exit_trace->startsolid) + { + if (enter_trace->m_pEnt != csgo.m_entity_list()->GetClientEntity(0)) { + if (exit_trace->m_pEnt && exit_trace->m_pEnt->is_breakable()) + { + exit_trace->surface.surfaceProps = enter_trace->surface.surfaceProps; + exit_trace->endpos = start + dir; + return true; + } + } + + continue; + } + + if ((exit_trace->surface.flags & 0x80u) != 0) + { + if (enter_trace->m_pEnt && enter_trace->m_pEnt->is_breakable() + && exit_trace->m_pEnt && exit_trace->m_pEnt->is_breakable()) + { + out = exit_trace->endpos; + return true; + } + + if (!(enter_trace->surface.flags & 0x80u)) + continue; + } + + if (exit_trace->plane.normal.Dot(dir) <= 1.f) // exit nodraw is only valid if our entrace is also nodraw + { + out -= dir * (exit_trace->fraction * 4.0f); + return true; + } + } + + return false; +} + +bool c_autowall::HandleBulletPenetration(C_BasePlayer* ignore,weapon_info* weaponData, trace_t& enterTrace, Vector& eyePosition, Vector direction, int& possibleHitsRemaining, float& currentDamage, float penetrationPower, float ff_damage_bullet_penetration, bool pskip) +{ + static ConVar* ff_damage_reduction_bullets = csgo.m_engine_cvars()->FindVar(sxor("ff_damage_reduction_bullets")); + + if (possibleHitsRemaining <= 0 || weaponData->penetration <= 0 || currentDamage < 1) { + //possibleHitsRemaining = 0; + return false; + } + + //SafeLocalPlayer() false; + CGameTrace exitTrace; + auto* pEnemy = (C_BasePlayer*)enterTrace.m_pEnt; + auto* const enterSurfaceData = csgo.m_phys_props()->GetSurfaceData(enterTrace.surface.surfaceProps); + const int enter_material = enterSurfaceData->game.material; + + if (!enterSurfaceData || enterSurfaceData->game.penetrationmodifier <= 0) + return false; + + const auto enter_penetration_modifier = enterSurfaceData->game.penetrationmodifier; + //float enterDamageModifier = enterSurfaceData->game.damagemodifier;// , modifier, finalDamageModifier, combinedPenetrationModifier; + const bool isSolidSurf = (enterTrace.contents & CONTENTS_GRATE); + const bool isLightSurf = (enterTrace.surface.flags & SURF_NODRAW); + + if ((possibleHitsRemaining <= 0 && !isLightSurf && !isSolidSurf && enter_material != CHAR_TEX_GRATE && enter_material != CHAR_TEX_GLASS) + || penetrationPower <= 0) + return false; + + Vector end; + + if (!TraceToExit(enterTrace.endpos, direction, end, &enterTrace, &exitTrace)) { + if (!(csgo.m_engine_trace()->GetPointContents(end, 0x600400B) & 0x600400B)) + return false; + } + + auto* const exitSurfaceData = csgo.m_phys_props()->GetSurfaceData(exitTrace.surface.surfaceProps); + const int exitMaterial = exitSurfaceData->game.material; + const float exitSurfPenetrationModifier = exitSurfaceData->game.penetrationmodifier; + //float exitDamageModifier = exitSurfaceData->game.damagemodifier; + + float combined_damage_modifier = 0.16f; + float combined_penetration_modifier; + + //Are we using the newer penetration system? + if (enter_material == CHAR_TEX_GLASS || enter_material == CHAR_TEX_GRATE) { + combined_damage_modifier = 0.05f; + combined_penetration_modifier = 3; + } + else if (isSolidSurf || isLightSurf) { + combined_damage_modifier = 0.16f; + combined_penetration_modifier = 1; + } + else if (enter_material == CHAR_TEX_FLESH && ff_damage_reduction_bullets->GetFloat() == 0 && pEnemy != nullptr && pEnemy->IsPlayer() && pEnemy->m_iTeamNum() == ctx.m_local()->m_iTeamNum()) + { + if (ff_damage_bullet_penetration == 0) + { + // don't allow penetrating players when FF is off + combined_penetration_modifier = 0; + return false; + } + + combined_penetration_modifier = ff_damage_bullet_penetration; + } + else { + combined_penetration_modifier = (enter_penetration_modifier + exitSurfPenetrationModifier) / 2; + } + + if (enter_material == exitMaterial) { + if (exitMaterial == CHAR_TEX_WOOD || exitMaterial == CHAR_TEX_CARDBOARD) + combined_penetration_modifier = 3; + else if (exitMaterial == CHAR_TEX_PLASTIC) + combined_penetration_modifier = 2; + } + + /*auto v22 = fmaxf(1.0f / combined_penetration_modifier, 0.0f); + auto v23 = fmaxf(3.0f / penetrationPower, 0.0f); + + auto penetration_modifier = fmaxf(0.f, 1.f / combined_penetration_modifier); + auto penetration_distance = (exitTrace.endpos - enterTrace.endpos).Length(); + + auto damage_lost = ((currentDamage * combined_damage_modifier) + ((v23 * v22) * 3.0f)) + (((penetration_distance * penetration_distance) * v22) * 0.041666668f); + + auto new_damage = currentDamage - damage_lost; + + currentDamage = new_damage; + + if (new_damage > 0.0f) + { + *eyePosition = exitTrace.endpos; + --possibleHitsRemaining; + return true; + }*/ + + auto penetration_mod = fmaxf(0.f, (3.f / penetrationPower) * 1.25f); + + float modifier = fmaxf(0, 1.0f / combined_penetration_modifier); + + auto thickness = (exitTrace.endpos - enterTrace.endpos).Length(); + /*thickness *= thickness; + thickness *= flPenMod; + thickness /= 24.f;*/ + + const auto lost_damage = ((modifier * 3.f) * penetration_mod + (currentDamage * combined_damage_modifier)) + (((thickness * thickness) * modifier) / 24.f); + /*fmaxf(0, currentDamage * combined_damage_modifier + flPenMod + * 3.f * fmaxf(0, 3.f / penetrationPower) * 1.25f + thickness);*/ + + currentDamage -= std::fmaxf(0.f, lost_damage); + + if (currentDamage < 1.f) + return false; + + eyePosition = exitTrace.endpos; + --possibleHitsRemaining; + + return true; +} + +void c_autowall::FixTraceRay(Vector end, Vector start, trace_t* oldtrace, C_BasePlayer* ent) { + if (!ent) + return; + + const auto mins = ent->OBBMins(); + const auto maxs = ent->OBBMaxs(); + + auto dir(end - start); + auto len = dir.Normalize(); + + const auto center = (mins + maxs) / 2; + const auto pos(ent->m_vecOrigin() + center); + + auto to = pos - start; + const float range_along = dir.Dot(to); + + float range; + if (range_along < 0.f) { + range = -(to).Length(); + } + else if (range_along > len) { + range = -(pos - end).Length(); + } + else { + auto ray(pos - (start + (dir * range_along))); + range = ray.Length(); + } + + if (range <= 60.f) { + + Ray_t ray; + ray.Init(start, end); + + trace_t trace; + csgo.m_engine_trace()->ClipRayToEntity(ray, 0x4600400B, ent, &trace); + + if (oldtrace->fraction > trace.fraction) + * oldtrace = trace; + } +} + +void c_autowall::ClipTraceToPlayers(const Vector& start, const Vector& end, uint32_t mask, ITraceFilter* filter, trace_t* tr) { + Vector pos, to, dir, on_ray; + float len, range_along, range; + //CGameTrace new_trace; + + float smallestFraction = tr->fraction; + constexpr float maxRange = 60.0f; + + //Vector delta(vecAbsEnd - vecAbsStart); + //const float delta_length = delta.Normalize(); + + dir = start - end; + len = dir.Normalize(); + + Ray_t ray; + ray.Init(start, end); + + for (int i = 1; i <= 64; ++i) { + C_BasePlayer* ent = csgo.m_entity_list()->GetClientEntity(i); + if (!ent || ent->IsDormant() || ent->IsDead()) + continue; + + if (filter && !filter->ShouldHitEntity(ent, mask)) + continue; + + //matrix3x4_t coordinate_frame; + //Math::AngleMatrix(ent->get_abs_angles(), ent->m_vecOrigin(), coordinate_frame); + + //auto collideble = ent->GetCollideable(); + //auto mins = collideble->OBBMins(); + //auto maxs = collideble->OBBMaxs(); + + //auto obb_center = (maxs + mins) * 0.5f; + //Math::VectorTransform(obb_center, coordinate_frame, obb_center); + + /*auto extend = (obb_center - vecAbsStart); + auto rangeAlong = delta.Dot(extend); + + float range; + if (rangeAlong >= 0.0f) { + if (rangeAlong <= delta_length) + range = Vector(obb_center - ((delta * rangeAlong) + vecAbsStart)).Length(); + else + range = -(obb_center - vecAbsEnd).Length(); + } + else { + range = -extend.Length(); + }*/ + + // set some local vars. + pos = ent->m_vecOrigin() + ((ent->OBBMins() + ent->OBBMaxs()) * 0.5f); + to = pos - start; + range_along = dir.Dot(to); + + // off start point. + if (range_along < 0.f) + range = -(to).Length(); + + // off end point. + else if (range_along > len) + range = -(pos - end).Length(); + + // within ray bounds. + else { + on_ray = start + (dir * range_along); + range = (pos - on_ray).Length(); + } + + if (/*range > 0.0f && */range <= maxRange) { + trace_t playerTrace; + + //ray.Init(start, end); + + csgo.m_engine_trace()->ClipRayToEntity(ray, 0x4600400B, ent, &playerTrace); + + if (playerTrace.fraction < smallestFraction) { + // we shortened the ray - save off the trace + *tr = playerTrace; + smallestFraction = playerTrace.fraction; + } + } + } +} + +int c_autowall::HitboxToHitgroup(C_BasePlayer* m_player, int ihitbox) +{/* + if (ihitbox < 0 || ihitbox > 19) return 0; + + if (!m_player) return 0; + + const auto model = m_player->GetModel(); + + if (!model) + return 0; + + auto pStudioHdr = csgo.m_model_info()->GetStudioModel(model); + + if (!pStudioHdr) + return 0; + + auto hitbox = pStudioHdr->pHitbox(ihitbox, m_player->m_nHitboxSet()); + + if (!hitbox) + return 0; + + return hitbox->group;*/ + + switch (ihitbox) + { + case HITBOX_HEAD: + case HITBOX_NECK: + return HITGROUP_HEAD; + case HITBOX_UPPER_CHEST: + case HITBOX_CHEST: + case HITBOX_THORAX: + case HITBOX_LEFT_UPPER_ARM: + case HITBOX_RIGHT_UPPER_ARM: + return HITGROUP_CHEST; + case HITBOX_PELVIS: + case HITBOX_LEFT_THIGH: + case HITBOX_RIGHT_THIGH: + case HITBOX_BODY: + return HITGROUP_STOMACH; + case HITBOX_LEFT_CALF: + case HITBOX_LEFT_FOOT: + return HITGROUP_LEFTLEG; + case HITBOX_RIGHT_CALF: + case HITBOX_RIGHT_FOOT: + return HITGROUP_RIGHTLEG; + case HITBOX_LEFT_FOREARM: + case HITBOX_LEFT_HAND: + return HITGROUP_LEFTARM; + case HITBOX_RIGHT_FOREARM: + case HITBOX_RIGHT_HAND: + return HITGROUP_RIGHTARM; + default: + return HITGROUP_STOMACH; + } +} + +bool c_autowall::FireBullet(Vector eyepos, C_WeaponCSBaseGun* pWeapon, Vector& direction, float& currentDamage, C_BasePlayer* ignore, C_BasePlayer* to_who, int hitbox, bool* was_viable, std::vector* power) +{ + if (!pWeapon || !ignore) + return false; + + //SafeLocalPlayer() false; + //bool sv_penetration_type; + // Current bullet travel Power to penetrate Distance to penetrate Range Player bullet reduction convars Amount to extend ray by + float currentDistance = 0; + + static ConVar* damageBulletPenetration = csgo.m_engine_cvars()->FindVar(sxor("ff_damage_bullet_penetration")); + + const float ff_damage_bullet_penetration = damageBulletPenetration->GetFloat(); + + weapon_info* weaponData = ctx.latest_weapon_data; + CGameTrace enterTrace; + + CTraceFilter filter; + filter.pSkip = ignore; + + if (!weaponData) + return false; + + //Set our current damage to what our gun's initial damage reports it will do + currentDamage = float(weaponData->damage); + auto maxRange = weaponData->range; + auto penetrationDistance = weaponData->range; + auto penetrationPower = weaponData->penetration; + auto RangeModifier = weaponData->range_modifier; + + //This gets set in FX_Firebullets to 4 as a pass-through value. + //CS:GO has a maximum of 4 surfaces a bullet can pass-through before it 100% stops. + //Excerpt from Valve: https://steamcommunity.com/sharedfiles/filedetails/?id=275573090 + //"The total number of surfaces any bullet can penetrate in a single flight is capped at 4." -CS:GO Official + ctx.last_penetrated_count = 4; + ctx.last_hitgroup = -1; + + if (power) + { + maxRange = power->at(0); + penetrationDistance = power->at(1); + penetrationPower = power->at(2); + currentDamage = power->at(3); + RangeModifier = power->at(4); + } + + int penetrated = 0; + + //If our damage is greater than (or equal to) 1, and we can shoot, let's shoot. + while (/*ctx.last_penetrated_count >= 0 &&*/currentDamage > 0) + { + //Calculate max bullet range + + //Create endpoint of bullet + Vector end = eyepos + direction * (maxRange - currentDistance); + + TraceLine(eyepos, end, 0x4600400B/*_HULL | CONTENTS_HITBOX*/, ignore, &enterTrace); + + /*if (enterTrace.startsolid) + { + enterTrace.endpos = enterTrace.startpos; + enterTrace.fraction = 0.0f; + }*/ + //else + //if (!(enterTrace.contents & CONTENTS_HITBOX)) { + if (to_who/* && target_hitbox == HITBOX_HEAD*/ || enterTrace.contents & CONTENTS_HITBOX && enterTrace.m_pEnt) { + //Pycache/aimware traceray fix for head while players are jumping + FixTraceRay(eyepos + (direction * 40.f), eyepos, &enterTrace, (to_who != nullptr ? to_who : (C_BasePlayer*)enterTrace.m_pEnt)); + } + else + ClipTraceToPlayers(eyepos, eyepos + (direction * 40.f), 0x4600400B, &filter, &enterTrace); + //} + + if (enterTrace.fraction == 1.0f) + return false; + + //if (enterTrace.m_pEnt == nullptr || !((C_BasePlayer*)enterTrace.m_pEnt)->IsPlayer())// !hit_entity || !hit_entity->is_player + // enterTrace.m_pEnt = nullptr; + + //We have to do this *after* tracing to the player. + //int enterMaterial = enterSurfaceData->game.material; + + //calculate the damage based on the distance the bullet traveled. + currentDistance += enterTrace.fraction * (maxRange - currentDistance); + + //Let's make our damage drops off the further away the bullet is. + currentDamage *= powf(RangeModifier, (currentDistance / 500)); + + if (!(enterTrace.contents & CONTENTS_HITBOX)) + enterTrace.hitgroup = 1; + + //This looks gay as fuck if we put it into 1 long line of code. + const bool canDoDamage = enterTrace.hitgroup > 0 && enterTrace.hitgroup <= 8 || enterTrace.hitgroup == HITGROUP_GEAR; + const bool isPlayer = enterTrace.m_pEnt != nullptr + && enterTrace.m_pEnt->GetClientClass() + && enterTrace.m_pEnt->GetClientClass()->m_ClassID == class_ids::CCSPlayer + && (!ctx.m_local() || ctx.m_local()->IsDead() || ((C_BasePlayer*)enterTrace.m_pEnt)->m_iTeamNum() != ctx.m_local()->m_iTeamNum()); + + if (to_who) + { + if (enterTrace.m_pEnt && to_who == enterTrace.m_pEnt && canDoDamage && isPlayer) { + const int group = (pWeapon->m_iItemDefinitionIndex() == WEAPON_TASER) ? HITGROUP_GENERIC : enterTrace.hitgroup; + ctx.last_hitgroup = group; + + ScaleDamage(enterTrace, weaponData, currentDamage); + + if (was_viable != nullptr) + *was_viable = (penetrated == 0); + + ctx.force_hitbox_penetration_accuracy = false; + + return true; + } + } + else + { + if (enterTrace.m_pEnt && canDoDamage && isPlayer) { + const int group = (pWeapon->m_iItemDefinitionIndex() == WEAPON_TASER) ? HITGROUP_GENERIC : enterTrace.hitgroup; + ctx.last_hitgroup = group; + + ScaleDamage(enterTrace, weaponData, currentDamage); + + if (was_viable != nullptr) + *was_viable = (penetrated == 0); + + ctx.force_hitbox_penetration_accuracy = false; + + return true; + } + } + + //Sanity checking / Can we actually shoot through? + if (currentDistance > maxRange && penetrationPower + || csgo.m_phys_props()->GetSurfaceData(enterTrace.surface.surfaceProps)->game.penetrationmodifier < 0.1f) { + return false;//ctx.last_penetrated_count = 0; + } + + const auto prev = ctx.last_penetrated_count; + + //Calling HandleBulletPenetration here reduces our penetrationCounter, and if it returns true, we can't shoot through it. + if (!HandleBulletPenetration(ignore, weaponData, enterTrace, eyepos, direction, ctx.last_penetrated_count, currentDamage, penetrationPower, ff_damage_bullet_penetration)) { + break; + } + if (prev != ctx.last_penetrated_count) + penetrated++; + } + + return false; +} + +////////////////////////////////////// Usage Calls ////////////////////////////////////// +float c_autowall::CanHit(Vector& vecEyePos, Vector& point) +{ + Vector angles, direction; + Vector tmp = point - vecEyePos; + float currentDamage = 0; + + Math::VectorAngles(tmp, angles); + Math::AngleVectors(angles, &direction); + direction.Normalize(); + + if (m_weapon() != nullptr && m_weapon()->IsGun() && FireBullet(vecEyePos, m_weapon(), direction, currentDamage, ctx.m_local())) + return currentDamage; + + return -1; //That wall is just a bit too thick buddy +} + +float c_autowall::CanHit(const Vector& vecEyePos, Vector& point, C_BasePlayer* ignore_ent, C_BasePlayer* to_who, int hitbox, bool* was_viable) +{ + if (ignore_ent == nullptr || to_who == nullptr) + return 0; + + Vector direction; + Vector tmp = point - vecEyePos; + float currentDamage = 0; + + //Math::VectorAngles(tmp, angles); + //Math::AngleVectors(angles, &direction); + direction = tmp.Normalized(); + + if (m_weapon() != nullptr) + { + if (m_weapon()->IsGun() && FireBullet(vecEyePos, m_weapon(), direction, currentDamage, ignore_ent, to_who, hitbox, was_viable)) + return currentDamage; + else + return -1; + } + + return -1; //That wall is just a bit too thick buddy +} + +float c_autowall::SimulateShot(Vector& vecEyePos, Vector& point, C_BasePlayer* ignore_ent, C_BasePlayer* to_who, bool* was_viable) +{ + if (ignore_ent == nullptr || to_who == nullptr) + return 0; + + Vector angles, direction; + const Vector tmp(point - vecEyePos); + float currentDamage = 0.f; + + Math::VectorAngles(tmp, angles); + Math::AngleVectors(angles, &direction); + direction.Normalize(); + + /* + maxRange = power[0]; + penetrationDistance = power[1]; + penetrationPower = power[2]; + currentDamage = power[3]; + */ + + static std::vector power = { 4000.f, 4000.f, 2.50f, 80.f, 1.f}; + + if (m_weapon() != nullptr) + { + if (FireBullet(vecEyePos, m_weapon(), direction, currentDamage, ignore_ent, to_who, -1, was_viable, &power)) + return currentDamage; + else + return -1; + } + + return -1; //That wall is just a bit too thick buddy +} +``` + +`autowall.hpp`: + +```hpp +#pragma once + +#define DAMAGE_NO 0 +#define DAMAGE_EVENTS_ONLY 1 +#define DAMAGE_YES 2 +#define DAMAGE_AIM 3 + +enum TextureCharacters { + CHAR_TEX_ANTLION = 'A', + CHAR_TEX_BLOODYFLESH = 'B', + CHAR_TEX_CONCRETE = 'C', + CHAR_TEX_DIRT = 'D', + CHAR_TEX_EGGSHELL = 'E', + CHAR_TEX_FLESH = 'F', + CHAR_TEX_GRATE = 'G', + CHAR_TEX_ALIENFLESH = 'H', + CHAR_TEX_CLIP = 'I', + CHAR_TEX_PLASTIC = 'L', + CHAR_TEX_METAL = 'M', + CHAR_TEX_SAND = 'N', + CHAR_TEX_FOLIAGE = 'O', + CHAR_TEX_COMPUTER = 'P', + CHAR_TEX_SLOSH = 'S', + CHAR_TEX_TILE = 'T', + CHAR_TEX_CARDBOARD = 'U', + CHAR_TEX_VENT = 'V', + CHAR_TEX_WOOD = 'W', + CHAR_TEX_GLASS = 'Y', + CHAR_TEX_WARPSHIELD = 'Z', +}; + +#define CHAR_TEX_STEAM_PIPE 11 + +class c_autowall +{ +public: + virtual void TraceLine(Vector& absStart, const Vector& absEnd, unsigned int mask, C_BasePlayer* ignore, CGameTrace* ptr); + virtual float ScaleDamage(C_BasePlayer* player, float damage, float armor_ratio, int hitgroup); + virtual void ScaleDamage(CGameTrace& enterTrace, weapon_info* weaponData, float& currentDamage); + //void ScaleDamage(C_BasePlayer* entity, int hitgroup, weapon_info* weaponData, float& currentDamage); + virtual uint32_t get_filter_simple_vtable(); + virtual bool TraceToExit(const Vector& start, const Vector dir, Vector& out, trace_t* enter_trace, trace_t* exit_trace); + //bool TraceToExit(trace_t& enter_trace, trace_t& exit_trace, C_BasePlayer* ignore, const Vector start_position, const Vector direction); + virtual bool HandleBulletPenetration(C_BasePlayer* ignore, weapon_info* weaponData, trace_t& enterTrace, Vector& eyePosition, Vector direction, int& possibleHitsRemaining, float& currentDamage, float penetrationPower, float ff_damage_bullet_penetration, bool pskip = false); + //bool HandleBulletPenetration(weapon_info* weaponData, trace_t& enterTrace, Vector& eyePosition, Vector direction, int& possibleHitsRemaining, float& currentDamage, float penetrationPower, float shit, bool pskip = false); + virtual void FixTraceRay(Vector end, Vector start, trace_t* oldtrace, C_BasePlayer* ent); + virtual void ClipTraceToPlayers(const Vector& vecAbsStart, const Vector& vecAbsEnd, uint32_t mask, ITraceFilter* filter, trace_t* tr); + virtual int HitboxToHitgroup(C_BasePlayer* m_player, int ihitbox); + virtual bool FireBullet(Vector eyepos, C_WeaponCSBaseGun* pWeapon, Vector& direction, float& currentDamage, C_BasePlayer* ignore, C_BasePlayer* to_who = nullptr, int hitbox = -1, bool* was_viable = nullptr, std::vector* = nullptr); + virtual float CanHit(Vector& vecEyePos, Vector& point); + virtual float CanHit(const Vector& vecEyePos, Vector& point, C_BasePlayer* ignore_ent, C_BasePlayer* start_ent, int hitbox, bool* was_viable = nullptr); + virtual float SimulateShot(Vector& vecEyePos, Vector& point, C_BasePlayer* ignore_ent, C_BasePlayer* to_who, bool* was_viable = nullptr); +}; +``` + +`beams.cpp`: + +```cpp +#include "visuals.hpp" +#include "source.hpp" +#include "entity.hpp" +#include "player.hpp" +#include "weapon.hpp" +#include "hooked.hpp" +#include "displacement.hpp" +#include "anti_aimbot.hpp" +#include "resolver.hpp" +#include "prop_manager.hpp" +#include +#include "movement.hpp" +#include "menu.hpp" +#include +#include "prediction.hpp" +#include "rage_aimbot.hpp" +#include "lag_comp.hpp" + +#include +#include + +void c_visuals::draw_beam(Vector Start, Vector End, Color color, float Width) +{ + BeamInfo_t beamInfo; + beamInfo.m_nType = TE_BEAMPOINTS; + beamInfo.m_pszModelName = "sprites/purplelaser1.vmt"; + beamInfo.m_nModelIndex = -1; + beamInfo.m_flHaloScale = 0.0f; + beamInfo.m_flLife = 4.f; + + beamInfo.m_flWidth = Width; + beamInfo.m_flEndWidth = Width; + + beamInfo.m_flFadeLength = 0.0f; + beamInfo.m_flAmplitude = 2.0f; + beamInfo.m_flBrightness = 255.f; + beamInfo.m_flSpeed = 0.2f; + beamInfo.m_nStartFrame = 0; + beamInfo.m_flFrameRate = 0.f; + beamInfo.m_nSegments = 2; + beamInfo.m_bRenderable = true; + beamInfo.m_nFlags = FBEAM_ONLYNOISEONCE | FBEAM_NOTILE | FBEAM_HALOBEAM; + + beamInfo.m_flRed = color.r(); + beamInfo.m_flGreen = color.g(); + beamInfo.m_flBlue = color.b(); + + beamInfo.m_vecStart = Start; + beamInfo.m_vecEnd = End; + + auto myBeam = csgo.m_beams()->CreateBeamPoints(beamInfo); + + if (myBeam) + csgo.m_beams()->DrawBeam(myBeam); +} + +void c_visuals::render_tracers() +{ + if (!ctx.m_local() || ctx.m_local()->IsDead()) return; + + if (bullet_tracers.empty() || !ctx.m_settings.visuals_draw_local_beams) return; + + /*for (size_t i = 0; i < bullet_tracers.size(); i++) + {*/ + /*for (auto it = bullet_tracers.begin(); it != bullet_tracers.end();) + { + const auto& current = *it; + + if (it == bullet_tracers.end()) + break;*/ + auto it = bullet_tracers.begin(); + while (it != bullet_tracers.end()) + { + const auto& current = *it; + auto next = (it + 1); + + if (next != bullet_tracers.end() && current.time == (*next).time/* || current.time == csgo.m_globals()->curtime*/) { + it = bullet_tracers.erase(it); + continue; + } + + draw_beam(current.src - (current.is_local ? Vector(0.f,0.f,2.f) : Vector(0.f,0.f,0.f)), current.dst, current.color1, 2.0f); + + it = bullet_tracers.erase(it); + } + + bullet_tracers.clear(); +} +``` + +`bell.hpp`: + +```hpp +/* D:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\sound\bell.wav (18.12.2019 0:48:40) + StartOffset(h): 00000000, EndOffset(h): 0000A523, Длина(h): 0000A524 */ + +unsigned char bell[42276] = { + 0x52, 0x49, 0x46, 0x46, 0x1C, 0xA5, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45, + 0x66, 0x6D, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, + 0x44, 0xAC, 0x00, 0x00, 0x10, 0xB1, 0x02, 0x00, 0x04, 0x00, 0x10, 0x00, + 0x64, 0x61, 0x74, 0x61, 0xEC, 0xA3, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x00, + 0x03, 0x00, 0xFE, 0xFF, 0xFB, 0xFF, 0x02, 0x00, 0x06, 0x00, 0xFF, 0xFF, + 0xFA, 0xFF, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFD, 0xFF, 0x02, 0x00, 0x02, 0x00, + 0xFE, 0xFF, 0xFD, 0xFF, 0x02, 0x00, 0x03, 0x00, 0xFE, 0xFF, 0xFD, 0xFF, + 0x00, 0x00, 0x03, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFA, 0xFF, 0x01, 0x00, + 0x05, 0x00, 0x04, 0x00, 0x11, 0x00, 0x0C, 0x00, 0xF8, 0xFF, 0xF4, 0xFF, + 0xF6, 0xFF, 0xF2, 0xFF, 0x07, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0xF9, 0xFF, + 0x02, 0x00, 0x0B, 0x00, 0xF6, 0xFF, 0x02, 0x00, 0xF6, 0xFF, 0x02, 0x00, + 0x08, 0x00, 0x13, 0x00, 0x07, 0x00, 0xFD, 0xFF, 0x07, 0x00, 0x04, 0x00, + 0x15, 0x00, 0xFD, 0xFF, 0xF5, 0xFF, 0xEC, 0xFF, 0xF3, 0xFF, 0xFB, 0xFF, + 0x11, 0x00, 0x12, 0x00, 0xEB, 0xFF, 0x05, 0x00, 0xF1, 0xFF, 0x03, 0x00, + 0xFF, 0xFF, 0x06, 0x00, 0x04, 0x00, 0xEE, 0xFF, 0x19, 0x00, 0x05, 0x00, + 0x1E, 0x00, 0x0C, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF1, 0xFF, + 0x02, 0x00, 0xEC, 0xFF, 0xFE, 0xFF, 0x01, 0x00, 0xE5, 0xFF, 0xFE, 0xFF, + 0x05, 0x00, 0x1E, 0x00, 0xEF, 0xFF, 0x02, 0x00, 0xED, 0xFF, 0xF4, 0xFF, + 0x07, 0x00, 0xEF, 0xFF, 0xFA, 0xFF, 0xE6, 0xFF, 0xE3, 0xFF, 0xF1, 0xFF, + 0x00, 0x00, 0xEA, 0xFF, 0xE5, 0xFF, 0xD7, 0xFF, 0xEE, 0xFF, 0x01, 0x00, + 0xFB, 0xFF, 0x03, 0x00, 0xFF, 0xFF, 0xFC, 0xFF, 0x08, 0x00, 0x16, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x32, 0x00, 0x01, 0x00, 0x22, 0x00, + 0xFD, 0xFF, 0x05, 0x00, 0xF5, 0xFF, 0x25, 0x00, 0x02, 0x00, 0x13, 0x00, + 0xCC, 0xFF, 0xDE, 0xFF, 0x1A, 0x00, 0x13, 0x00, 0xF4, 0xFF, 0xFA, 0xFF, + 0x0F, 0x00, 0x01, 0x00, 0x13, 0x00, 0xF4, 0xFF, 0xF9, 0xFF, 0xF2, 0xFF, + 0xF5, 0xFF, 0x0D, 0x00, 0x0D, 0x00, 0xFF, 0xFF, 0x2F, 0x00, 0xF0, 0xFF, + 0x02, 0x00, 0xFE, 0xFF, 0x29, 0x00, 0x1A, 0x00, 0x29, 0x00, 0xFF, 0xFF, + 0x5C, 0x00, 0x04, 0x00, 0x11, 0x00, 0x18, 0x00, 0x14, 0x00, 0x18, 0x00, + 0xE9, 0xFF, 0xC3, 0xFF, 0xE7, 0xFF, 0x12, 0x00, 0x08, 0x00, 0x11, 0x00, + 0xE5, 0xFF, 0xD1, 0xFF, 0xEE, 0xFF, 0xF0, 0xFF, 0xEA, 0xFF, 0x01, 0x00, + 0x02, 0x00, 0x0D, 0x00, 0x0B, 0x00, 0x1C, 0x00, 0x18, 0x00, 0x41, 0x00, + 0xF1, 0xFF, 0x2B, 0x00, 0xFD, 0xFF, 0xF6, 0xFF, 0x02, 0x00, 0xE4, 0xFF, + 0xFA, 0xFF, 0x05, 0x00, 0x0A, 0x00, 0xF2, 0xFF, 0x1A, 0x00, 0x18, 0x00, + 0xE4, 0xFF, 0x21, 0x00, 0x07, 0x00, 0x01, 0x00, 0x34, 0x00, 0x09, 0x00, + 0x01, 0x00, 0xEF, 0xFF, 0xDE, 0xFF, 0xEC, 0xFF, 0xF2, 0xFF, 0x02, 0x00, + 0xE3, 0xFF, 0xD0, 0xFF, 0xEF, 0xFF, 0xEA, 0xFF, 0xFA, 0xFF, 0x07, 0x00, + 0xE2, 0xFF, 0xDE, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0x09, 0x00, 0x01, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x01, 0x00, 0xE4, 0xFF, 0x08, 0x00, 0x0A, 0x00, + 0xFD, 0xFF, 0xEE, 0xFF, 0xE6, 0xFF, 0xE9, 0xFF, 0xFC, 0xFF, 0x04, 0x00, + 0x2F, 0x00, 0x30, 0x00, 0xFD, 0xFF, 0x06, 0x00, 0x05, 0x00, 0xFC, 0xFF, + 0x03, 0x00, 0x04, 0x00, 0xE9, 0xFF, 0xE9, 0xFF, 0xFC, 0xFF, 0xEC, 0xFF, + 0xCB, 0xFF, 0xBA, 0xFF, 0xD9, 0xFF, 0xDA, 0xFF, 0x0B, 0x00, 0x03, 0x00, + 0x0C, 0x00, 0xFB, 0xFF, 0xFA, 0xFF, 0x1A, 0x00, 0x0A, 0x00, 0x29, 0x00, + 0xF9, 0xFF, 0xF1, 0xFF, 0x08, 0x00, 0xFC, 0xFF, 0xE5, 0xFF, 0xE8, 0xFF, + 0xE9, 0xFF, 0x02, 0x00, 0xFB, 0xFF, 0x0F, 0x00, 0xF3, 0xFF, 0xF0, 0xFF, + 0x0D, 0x00, 0xF7, 0xFF, 0xFF, 0xFF, 0xD6, 0xFF, 0xFF, 0xFF, 0xE1, 0xFF, + 0x22, 0x00, 0x24, 0x00, 0x11, 0x00, 0x17, 0x00, 0xEC, 0xFF, 0xEE, 0xFF, + 0xF4, 0xFF, 0x19, 0x00, 0xE8, 0xFF, 0x00, 0x00, 0xF1, 0xFF, 0x03, 0x00, + 0xF5, 0xFF, 0x18, 0x00, 0xF2, 0xFF, 0x0D, 0x00, 0xFB, 0xFF, 0xFC, 0xFF, + 0xEE, 0xFF, 0xF0, 0xFF, 0xFE, 0xFF, 0x03, 0x00, 0xF7, 0xFF, 0xFF, 0xFF, + 0xD9, 0xFF, 0xC3, 0xFF, 0xE9, 0xFF, 0xF1, 0xFF, 0xD1, 0xFF, 0xE8, 0xFF, + 0xFF, 0xFF, 0xDF, 0xFF, 0x05, 0x00, 0xF8, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, + 0x0D, 0x00, 0x16, 0x00, 0x0D, 0x00, 0x06, 0x00, 0xFB, 0xFF, 0xF2, 0xFF, + 0x47, 0x00, 0x26, 0x00, 0x27, 0x00, 0xF9, 0xFF, 0xD5, 0xFF, 0xCF, 0xFF, + 0x0A, 0x00, 0x16, 0x00, 0xFF, 0xFF, 0xE0, 0xFF, 0x0E, 0x00, 0x17, 0x00, + 0xFD, 0xFF, 0x01, 0x00, 0xED, 0xFF, 0x19, 0x00, 0xFF, 0xFF, 0x34, 0x00, + 0x07, 0x00, 0x18, 0x00, 0xF0, 0xFF, 0x0A, 0x00, 0x07, 0x00, 0x05, 0x00, + 0xF8, 0xFF, 0xE2, 0xFF, 0xDE, 0xFF, 0xE6, 0xFF, 0x30, 0x00, 0x41, 0x00, + 0xFF, 0xFF, 0x13, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x12, 0x00, 0xEF, 0xFF, + 0xF4, 0xFF, 0xFC, 0xFF, 0xFB, 0xFF, 0xFE, 0xFF, 0xF8, 0xFF, 0xEF, 0xFF, + 0xE7, 0xFF, 0x0D, 0x00, 0xE9, 0xFF, 0xE9, 0xFF, 0xE2, 0xFF, 0xFC, 0xFF, + 0x0B, 0x00, 0xF4, 0xFF, 0x13, 0x00, 0xFB, 0xFF, 0xF5, 0xFF, 0x1D, 0x00, + 0xEB, 0xFF, 0xED, 0xFF, 0xFE, 0xFF, 0xED, 0xFF, 0xF4, 0xFF, 0xED, 0xFF, + 0xE6, 0xFF, 0xE0, 0xFF, 0x08, 0x00, 0x08, 0x00, 0x0A, 0x00, 0x16, 0x00, + 0x17, 0x00, 0x11, 0x00, 0x2E, 0x00, 0x4B, 0x00, 0x3C, 0x00, 0x1E, 0x00, + 0x2A, 0x00, 0x16, 0x00, 0x1B, 0x00, 0x16, 0x00, 0x02, 0x00, 0xD8, 0xFF, + 0x0F, 0x00, 0xF8, 0xFF, 0x1C, 0x00, 0x10, 0x00, 0xFF, 0xFF, 0x05, 0x00, + 0x28, 0x00, 0x24, 0x00, 0x12, 0x00, 0x26, 0x00, 0xFE, 0xFF, 0x1C, 0x00, + 0x23, 0x00, 0x1A, 0x00, 0x23, 0x00, 0x11, 0x00, 0xEE, 0xFF, 0xFF, 0xFF, + 0xF5, 0xFF, 0x18, 0x00, 0xFE, 0xFF, 0x02, 0x00, 0x09, 0x00, 0x3A, 0x00, + 0xF9, 0xFF, 0x17, 0x00, 0xFA, 0xFF, 0xF6, 0xFF, 0x32, 0x00, 0x00, 0x00, + 0xDE, 0xFF, 0xFC, 0xFF, 0xF2, 0xFF, 0xFF, 0xFF, 0x20, 0x00, 0xF2, 0xFF, + 0x05, 0x00, 0x06, 0x00, 0x05, 0x00, 0x07, 0x00, 0xD6, 0xFF, 0xE6, 0xFF, + 0x21, 0x00, 0xFB, 0xFF, 0x22, 0x00, 0x3C, 0x00, 0xF3, 0xFF, 0x0D, 0x00, + 0x1D, 0x00, 0xFA, 0xFF, 0xF0, 0xFF, 0xF6, 0xFF, 0xFA, 0xFF, 0x03, 0x00, + 0x0B, 0x00, 0xED, 0xFF, 0x07, 0x00, 0xF8, 0xFF, 0x17, 0x00, 0x2B, 0x00, + 0xEB, 0xFF, 0xE1, 0xFF, 0x04, 0x00, 0xEC, 0xFF, 0x49, 0x00, 0x2F, 0x00, + 0x02, 0x00, 0xF9, 0xFF, 0x19, 0x00, 0x19, 0x00, 0x28, 0x00, 0x18, 0x00, + 0xF9, 0xFF, 0x15, 0x00, 0x1E, 0x00, 0x09, 0x00, 0x1F, 0x00, 0x09, 0x00, + 0x15, 0x00, 0x1C, 0x00, 0xF1, 0xFF, 0xF3, 0xFF, 0xE8, 0xFF, 0xEF, 0xFF, + 0x20, 0x00, 0x17, 0x00, 0x36, 0x00, 0x28, 0x00, 0xED, 0xFF, 0xF3, 0xFF, + 0x19, 0x00, 0x29, 0x00, 0xEE, 0xFF, 0x0B, 0x00, 0xDF, 0xFF, 0xE1, 0xFF, + 0x05, 0x00, 0x05, 0x00, 0xD5, 0xFF, 0xF7, 0xFF, 0xDF, 0xFF, 0xF1, 0xFF, + 0x07, 0x00, 0xF4, 0xFF, 0xF9, 0xFF, 0xF7, 0xFF, 0x1B, 0x00, 0x11, 0x00, + 0x09, 0x00, 0xDF, 0xFF, 0xE7, 0xFF, 0xC6, 0xFF, 0x13, 0x00, 0x05, 0x00, + 0xF7, 0xFF, 0xF7, 0xFF, 0x00, 0x00, 0x05, 0x00, 0x0B, 0x00, 0x0F, 0x00, + 0xFB, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x15, 0x00, 0x0C, 0x00, 0x20, 0x00, + 0x22, 0x00, 0x24, 0x00, 0x00, 0x00, 0x09, 0x00, 0xE0, 0xFF, 0xE1, 0xFF, + 0x17, 0x00, 0xFC, 0xFF, 0xF3, 0xFF, 0xE2, 0xFF, 0x16, 0x00, 0x12, 0x00, + 0x14, 0x00, 0x23, 0x00, 0x01, 0x00, 0x1D, 0x00, 0x0F, 0x00, 0x18, 0x00, + 0x07, 0x00, 0xF1, 0xFF, 0xF5, 0xFF, 0xF9, 0xFF, 0x10, 0x00, 0xF2, 0xFF, + 0x0B, 0x00, 0xF4, 0xFF, 0xF7, 0xFF, 0xD4, 0xFF, 0x02, 0x00, 0xE2, 0xFF, + 0xE4, 0xFF, 0xDC, 0xFF, 0x0E, 0x00, 0x08, 0x00, 0xFB, 0xFF, 0xD7, 0xFF, + 0xF3, 0xFF, 0xEA, 0xFF, 0xF4, 0xFF, 0xEA, 0xFF, 0x01, 0x00, 0xDD, 0xFF, + 0xE1, 0xFF, 0xF1, 0xFF, 0xF4, 0xFF, 0x0E, 0x00, 0xE1, 0xFF, 0x14, 0x00, + 0xE7, 0xFF, 0xE4, 0xFF, 0x01, 0x00, 0x18, 0x00, 0xF9, 0xFF, 0x00, 0x00, + 0x07, 0x00, 0xF4, 0xFF, 0xFC, 0xFF, 0xF8, 0xFF, 0x02, 0x00, 0x15, 0x00, + 0xFA, 0xFF, 0x18, 0x00, 0xE3, 0xFF, 0xE3, 0xFF, 0xFB, 0xFF, 0x0E, 0x00, + 0x04, 0x00, 0x1A, 0x00, 0xDD, 0xFF, 0x11, 0x00, 0xE1, 0xFF, 0x08, 0x00, + 0x19, 0x00, 0x13, 0x00, 0x2D, 0x00, 0x10, 0x00, 0x10, 0x00, 0xE0, 0xFF, + 0x06, 0x00, 0xF6, 0xFF, 0x0E, 0x00, 0x05, 0x00, 0xF0, 0xFF, 0xF6, 0xFF, + 0xF5, 0xFF, 0xF3, 0xFF, 0xD8, 0xFF, 0xCF, 0xFF, 0xE4, 0xFF, 0xC6, 0xFF, + 0xDE, 0xFF, 0xD2, 0xFF, 0xF9, 0xFF, 0xF0, 0xFF, 0x2D, 0x00, 0x17, 0x00, + 0xE6, 0xFF, 0xE6, 0xFF, 0xEC, 0xFF, 0xE9, 0xFF, 0x05, 0x00, 0xF7, 0xFF, + 0xF9, 0xFF, 0xFA, 0xFF, 0x07, 0x00, 0x01, 0x00, 0x0F, 0x00, 0xF7, 0xFF, + 0xFD, 0xFF, 0xF9, 0xFF, 0x1F, 0x00, 0x25, 0x00, 0x2F, 0x00, 0x21, 0x00, + 0x16, 0x00, 0x1E, 0x00, 0x11, 0x00, 0x2D, 0x00, 0xDC, 0xFF, 0x0C, 0x00, + 0xE5, 0xFF, 0xF9, 0xFF, 0xFE, 0xFF, 0x06, 0x00, 0xFD, 0xFF, 0x01, 0x00, + 0x02, 0x00, 0x04, 0x00, 0x02, 0x00, 0x10, 0x00, 0x09, 0x00, 0x0B, 0x00, + 0x0C, 0x00, 0xFC, 0xFF, 0x0A, 0x00, 0xFC, 0xFF, 0x00, 0x00, 0x0F, 0x00, + 0x00, 0x00, 0xF1, 0xFF, 0xF7, 0xFF, 0xF1, 0xFF, 0x1B, 0x00, 0xF8, 0xFF, + 0x0D, 0x00, 0xF8, 0xFF, 0x12, 0x00, 0x0B, 0x00, 0xF8, 0xFF, 0xFE, 0xFF, + 0xE0, 0xFF, 0xF7, 0xFF, 0xE8, 0xFF, 0xEB, 0xFF, 0xCB, 0xFF, 0xC9, 0xFF, + 0xD3, 0xFF, 0xC8, 0xFF, 0xD6, 0xFF, 0xDB, 0xFF, 0xEE, 0xFF, 0xD7, 0xFF, + 0x03, 0x00, 0x1B, 0x00, 0x02, 0x00, 0x20, 0x00, 0x30, 0x00, 0x25, 0x00, + 0x0C, 0x00, 0x10, 0x00, 0xEE, 0xFF, 0xF0, 0xFF, 0x0B, 0x00, 0xF2, 0xFF, + 0xF2, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0x0B, 0x00, 0xFA, 0xFF, 0x0E, 0x00, + 0x15, 0x00, 0x03, 0x00, 0xF6, 0xFF, 0xD8, 0xFF, 0x0D, 0x00, 0x0F, 0x00, + 0x2A, 0x00, 0x24, 0x00, 0x08, 0x00, 0xE3, 0xFF, 0x0F, 0x00, 0xFB, 0xFF, + 0xE9, 0xFF, 0xD1, 0xFF, 0xE6, 0xFF, 0xF1, 0xFF, 0x0B, 0x00, 0x0B, 0x00, + 0xF5, 0xFF, 0x06, 0x00, 0xE8, 0xFF, 0xF9, 0xFF, 0xFB, 0xFF, 0xF4, 0xFF, + 0xEF, 0xFF, 0x05, 0x00, 0xFC, 0xFF, 0xF2, 0xFF, 0xE1, 0xFF, 0xEA, 0xFF, + 0xF4, 0xFF, 0xE2, 0xFF, 0xC9, 0xFF, 0xB9, 0xFF, 0xCC, 0xFF, 0xD4, 0xFF, + 0xEF, 0xFF, 0xE7, 0xFF, 0xED, 0xFF, 0x01, 0x00, 0x0F, 0x00, 0x26, 0x00, + 0xEE, 0xFF, 0xFD, 0xFF, 0xFB, 0xFF, 0xFB, 0xFF, 0xD9, 0xFF, 0xCD, 0xFF, + 0xEA, 0xFF, 0xE5, 0xFF, 0x06, 0x00, 0x0A, 0x00, 0xFD, 0xFF, 0xEF, 0xFF, + 0xF3, 0xFF, 0x19, 0x00, 0x0A, 0x00, 0xF5, 0xFF, 0x15, 0x00, 0xD7, 0xFF, + 0x1E, 0x00, 0x0C, 0x00, 0xE9, 0xFF, 0xED, 0xFF, 0xF2, 0xFF, 0xE4, 0xFF, + 0xF5, 0xFF, 0xEC, 0xFF, 0xDF, 0xFF, 0xF8, 0xFF, 0xD5, 0xFF, 0xF3, 0xFF, + 0xE5, 0xFF, 0xC8, 0xFF, 0xFC, 0xFF, 0xDA, 0xFF, 0xEA, 0xFF, 0xE5, 0xFF, + 0x09, 0x00, 0xE6, 0xFF, 0xD9, 0xFF, 0xBB, 0xFF, 0xE0, 0xFF, 0xEC, 0xFF, + 0xE4, 0xFF, 0xF1, 0xFF, 0x0A, 0x00, 0xFF, 0xFF, 0xDB, 0xFF, 0xFC, 0xFF, + 0x02, 0x00, 0x0A, 0x00, 0xE7, 0xFF, 0x0B, 0x00, 0x09, 0x00, 0x03, 0x00, + 0xD7, 0xFF, 0xDF, 0xFF, 0x14, 0x00, 0x22, 0x00, 0xDF, 0xFF, 0xEC, 0xFF, + 0x82, 0xFF, 0x8E, 0xFF, 0xF5, 0xFF, 0x08, 0x00, 0xA8, 0xFF, 0xA7, 0xFF, + 0x30, 0x00, 0x10, 0x00, 0xF5, 0xFF, 0x0F, 0x00, 0x89, 0xFF, 0x99, 0xFF, + 0x26, 0x00, 0x25, 0x00, 0x9D, 0x00, 0x90, 0x00, 0x62, 0xFF, 0x6C, 0xFF, + 0x5D, 0x00, 0x78, 0x00, 0x49, 0x00, 0x54, 0x00, 0x92, 0xFF, 0x83, 0xFF, + 0x85, 0xFF, 0x78, 0xFF, 0x71, 0xFF, 0x71, 0xFF, 0x38, 0x01, 0x0D, 0x01, + 0xC1, 0xFF, 0xC3, 0xFF, 0xF9, 0xFE, 0x05, 0xFF, 0x8A, 0x00, 0x70, 0x00, + 0xAF, 0x00, 0x8F, 0x00, 0x1C, 0xFF, 0x2A, 0xFF, 0x5C, 0x00, 0x71, 0x00, + 0xD4, 0xFF, 0xA4, 0xFF, 0x9C, 0xFF, 0xBA, 0xFF, 0x2B, 0xFF, 0x41, 0xFF, + 0x09, 0xFF, 0x22, 0xFF, 0x05, 0x02, 0xEE, 0x01, 0x19, 0x01, 0x03, 0x01, + 0xC4, 0xFF, 0xD2, 0xFF, 0x03, 0x00, 0xEF, 0xFF, 0x9F, 0xFF, 0x9C, 0xFF, + 0x40, 0xFF, 0x5E, 0xFF, 0xE2, 0x00, 0xE5, 0x00, 0x2D, 0x00, 0x31, 0x00, + 0x2A, 0x00, 0x48, 0x00, 0xDF, 0xFE, 0xE9, 0xFE, 0x9C, 0xFE, 0xEB, 0xFE, + 0xF4, 0x00, 0x01, 0x01, 0x87, 0x00, 0xAD, 0x00, 0x82, 0xFF, 0x7C, 0xFF, + 0x82, 0xFF, 0x5F, 0xFF, 0xBE, 0xFE, 0x1B, 0xFF, 0x16, 0x00, 0x5D, 0x00, + 0x6B, 0x01, 0x6B, 0x01, 0xE8, 0xFF, 0xFF, 0xFF, 0xF7, 0x00, 0xA9, 0x00, + 0xEA, 0xFE, 0xF2, 0xFE, 0x72, 0xFE, 0x95, 0xFE, 0x45, 0x00, 0x21, 0x00, + 0x82, 0x00, 0xAF, 0x00, 0x18, 0xFF, 0x2D, 0xFF, 0x5C, 0xFF, 0x58, 0xFF, + 0xEA, 0xFF, 0x20, 0x00, 0xBF, 0x01, 0xCF, 0x01, 0xA6, 0x02, 0x77, 0x02, + 0xBA, 0x00, 0xC5, 0x00, 0xCF, 0xFE, 0x76, 0xFE, 0x77, 0xFD, 0x38, 0xFD, + 0x88, 0xFF, 0xB3, 0xFF, 0x35, 0x01, 0x73, 0x01, 0x5A, 0x02, 0x24, 0x02, + 0xEF, 0xFF, 0xB6, 0xFF, 0x99, 0xFE, 0xA1, 0xFE, 0x0E, 0xFF, 0x6F, 0xFF, + 0xD8, 0x00, 0xF9, 0x00, 0x16, 0x02, 0x0F, 0x02, 0xAB, 0x01, 0xA8, 0x01, + 0x87, 0xFE, 0x50, 0xFE, 0x39, 0xFC, 0x17, 0xFC, 0x7E, 0xFE, 0x83, 0xFE, + 0x2B, 0x02, 0xBD, 0x02, 0x01, 0x04, 0xEC, 0x03, 0xA0, 0x00, 0x3A, 0x00, + 0x50, 0xFD, 0x47, 0xFD, 0xFE, 0xFD, 0x32, 0xFE, 0xB7, 0xFF, 0xE1, 0xFF, + 0xBC, 0x01, 0xF8, 0x01, 0xBB, 0x02, 0xAC, 0x02, 0xE3, 0xFE, 0xC7, 0xFE, + 0xB6, 0xFD, 0x7B, 0xFD, 0xD6, 0xFE, 0xBA, 0xFE, 0xB6, 0x01, 0xD6, 0x01, + 0x9F, 0x02, 0x8F, 0x02, 0xF8, 0x00, 0xFD, 0x00, 0x83, 0xFF, 0x1E, 0xFF, + 0x0B, 0xFF, 0x12, 0xFF, 0xC9, 0xFE, 0x83, 0xFF, 0xE8, 0xFF, 0x9B, 0x00, + 0x64, 0x02, 0x48, 0x02, 0x04, 0x01, 0x71, 0x00, 0x9D, 0xFE, 0x12, 0xFE, + 0x6C, 0xFD, 0x80, 0xFD, 0x5E, 0x00, 0x65, 0x00, 0x35, 0x01, 0x46, 0x01, + 0xA4, 0xFF, 0xF1, 0xFF, 0xF7, 0xFE, 0xCD, 0xFE, 0x6B, 0xFF, 0x50, 0xFF, + 0x36, 0x00, 0x53, 0x00, 0x6A, 0x01, 0xBB, 0x01, 0x95, 0x00, 0xAA, 0x00, + 0x32, 0xFE, 0x06, 0xFE, 0xDC, 0xFE, 0x75, 0xFE, 0xC7, 0xFF, 0x86, 0xFF, + 0x70, 0x01, 0x82, 0x01, 0xB0, 0x01, 0xDA, 0x01, 0x0D, 0x00, 0x39, 0x00, + 0x87, 0xFE, 0x64, 0xFE, 0xA1, 0xFF, 0x7E, 0xFF, 0xEC, 0x00, 0x04, 0x01, + 0x3A, 0x02, 0x3E, 0x02, 0x21, 0x01, 0x0B, 0x01, 0x5C, 0xFD, 0x74, 0xFD, + 0x96, 0xFD, 0xBA, 0xFD, 0x52, 0x00, 0x36, 0x00, 0x6E, 0x02, 0xAB, 0x02, + 0xFD, 0x01, 0x0E, 0x02, 0x5B, 0xFF, 0x1A, 0xFF, 0x50, 0xFD, 0x2E, 0xFD, + 0x59, 0xFE, 0x9C, 0xFE, 0x83, 0x00, 0x91, 0x00, 0x37, 0x02, 0xFD, 0x01, + 0x07, 0x02, 0x8E, 0x01, 0xD5, 0xFE, 0xD1, 0xFE, 0x21, 0xFD, 0x89, 0xFD, + 0x26, 0xFF, 0x51, 0xFF, 0x52, 0x01, 0x9B, 0x01, 0x41, 0x02, 0xAF, 0x02, + 0x8D, 0x00, 0x7F, 0x00, 0x03, 0xFE, 0x59, 0xFD, 0xE2, 0xFD, 0xB5, 0xFD, + 0x20, 0x00, 0x30, 0x00, 0x31, 0x02, 0x3E, 0x02, 0x1E, 0x03, 0xD8, 0x02, + 0x78, 0x00, 0xF8, 0xFF, 0xF8, 0xFC, 0x0B, 0xFD, 0x22, 0xFE, 0xA8, 0xFE, + 0xFA, 0xFF, 0x7C, 0x00, 0xBB, 0x01, 0xBC, 0x01, 0xB1, 0x00, 0xAC, 0x00, + 0x28, 0x00, 0xE4, 0xFF, 0x81, 0xFF, 0x10, 0xFF, 0x8E, 0xFF, 0xAD, 0xFF, + 0x8B, 0x00, 0x1B, 0x01, 0x2F, 0x01, 0x59, 0x01, 0x14, 0x00, 0xFE, 0xFF, + 0xEC, 0xFE, 0xC6, 0xFE, 0xFD, 0xFE, 0x1E, 0xFF, 0x52, 0xFF, 0xD8, 0xFF, + 0xED, 0x00, 0xD6, 0x00, 0x7A, 0xFF, 0xA1, 0xFF, 0x47, 0x00, 0x52, 0x00, + 0x42, 0x00, 0xFF, 0xFF, 0x10, 0x00, 0x64, 0x00, 0x39, 0x00, 0x70, 0x00, + 0x7D, 0xFF, 0x64, 0xFF, 0xBB, 0xFE, 0xDE, 0xFE, 0xE6, 0xFF, 0xB1, 0xFF, + 0x54, 0x00, 0x16, 0x00, 0xFF, 0x00, 0x17, 0x01, 0x2A, 0x02, 0x9D, 0x01, + 0xFE, 0xFE, 0x3E, 0xFF, 0x2C, 0xFF, 0x51, 0xFF, 0x33, 0xFF, 0x6A, 0xFF, + 0x8E, 0x00, 0xA5, 0x00, 0x5A, 0x01, 0xDF, 0x00, 0x45, 0xFF, 0x34, 0xFF, + 0xB7, 0xFE, 0xEE, 0xFE, 0x35, 0x00, 0x25, 0x00, 0x96, 0xFF, 0xD2, 0xFF, + 0x9B, 0x01, 0xB1, 0x01, 0x55, 0x02, 0x06, 0x02, 0xF8, 0xFF, 0xAE, 0xFF, + 0x57, 0xFF, 0x98, 0xFE, 0xAB, 0xFD, 0xFE, 0xFD, 0x43, 0x00, 0x9A, 0x00, + 0x81, 0x01, 0x47, 0x01, 0x5B, 0xFF, 0x45, 0xFF, 0xAD, 0xFF, 0x83, 0xFF, + 0x7C, 0x01, 0x00, 0x01, 0xD9, 0xFF, 0x4F, 0x00, 0xDA, 0x00, 0x11, 0x01, + 0xC1, 0x00, 0xA2, 0x00, 0xD1, 0x00, 0xA8, 0x00, 0x6E, 0x00, 0x75, 0xFF, + 0xC0, 0xFD, 0xCE, 0xFD, 0x54, 0x00, 0xC9, 0x00, 0xCE, 0x00, 0x13, 0x01, + 0xEF, 0xFF, 0x09, 0x00, 0x4F, 0x01, 0xF5, 0x00, 0xCB, 0x00, 0x30, 0x00, + 0x0F, 0xFF, 0x51, 0xFF, 0xF2, 0xFF, 0x3B, 0x00, 0x4E, 0xFF, 0x77, 0xFF, + 0xC7, 0x00, 0xBD, 0x00, 0x4E, 0x00, 0xE8, 0xFF, 0x0E, 0x00, 0xBB, 0xFF, + 0x4E, 0x01, 0xF6, 0x00, 0xA9, 0xFF, 0xD6, 0xFF, 0xEC, 0xFF, 0x06, 0x00, + 0x98, 0x01, 0x50, 0x01, 0xA1, 0x00, 0x38, 0x00, 0xC9, 0xFF, 0x72, 0xFF, + 0xE8, 0xFF, 0xF2, 0xFF, 0x24, 0xFF, 0x7A, 0xFF, 0xE1, 0x00, 0xCE, 0x00, + 0x90, 0xFF, 0x9C, 0xFF, 0x26, 0x00, 0x37, 0x00, 0x96, 0x00, 0x46, 0x00, + 0xA8, 0xFF, 0x5B, 0xFF, 0x08, 0x00, 0xDD, 0xFF, 0xE8, 0xFF, 0xBD, 0xFF, + 0x5A, 0xFF, 0xAC, 0xFF, 0x37, 0x00, 0x89, 0x00, 0x49, 0x00, 0xF6, 0xFF, + 0xCD, 0xFF, 0xF9, 0xFF, 0xAF, 0x00, 0x58, 0x00, 0x70, 0xFF, 0x19, 0xFF, + 0xD0, 0xFF, 0xFB, 0xFF, 0xF3, 0xFE, 0x04, 0xFF, 0x1B, 0x00, 0xC0, 0xFF, + 0xC5, 0x00, 0x13, 0x00, 0x8F, 0xFF, 0x3A, 0xFF, 0xB7, 0xFE, 0x6B, 0xFF, + 0x79, 0xFF, 0xE9, 0xFF, 0xB8, 0xFF, 0xD5, 0xFF, 0x5B, 0x00, 0x66, 0x00, + 0x59, 0x00, 0x86, 0xFF, 0x99, 0xFF, 0x69, 0xFF, 0x2B, 0x00, 0x63, 0x00, + 0x0A, 0xFE, 0xB7, 0xFE, 0xBE, 0xFE, 0x1A, 0xFF, 0x9D, 0x00, 0x2F, 0x00, + 0x16, 0x00, 0xD8, 0xFF, 0xF5, 0xFF, 0x0D, 0x00, 0x90, 0xFF, 0xCC, 0xFF, + 0xD7, 0xFE, 0x76, 0xFF, 0x59, 0x01, 0x46, 0x01, 0x7A, 0x00, 0xF4, 0xFF, + 0xC9, 0xFF, 0xE9, 0xFF, 0x89, 0x00, 0x63, 0x00, 0xC9, 0xFF, 0xF1, 0xFF, + 0xD7, 0xFF, 0x04, 0x00, 0xB8, 0xFF, 0x69, 0xFF, 0x96, 0xFF, 0x4B, 0xFF, + 0xE2, 0x01, 0x9E, 0x01, 0x3F, 0x00, 0xFF, 0xFF, 0x53, 0xFE, 0x96, 0xFE, + 0xF4, 0xFF, 0xCE, 0xFF, 0x0C, 0xFF, 0xF8, 0xFE, 0xBD, 0x00, 0x84, 0x00, + 0x02, 0x00, 0xB2, 0xFF, 0xBA, 0xFF, 0xBB, 0xFF, 0xAD, 0x00, 0x75, 0x00, + 0x1A, 0xFF, 0x03, 0xFF, 0xAF, 0xFF, 0xEE, 0xFF, 0x62, 0x00, 0x9E, 0x00, + 0xE0, 0xFD, 0x56, 0xFE, 0x35, 0xFF, 0x48, 0xFF, 0x82, 0x00, 0xEB, 0xFF, + 0x70, 0x00, 0x7B, 0x00, 0x22, 0x01, 0x11, 0x01, 0xC1, 0xFF, 0x1A, 0x00, + 0xCA, 0xFF, 0xFC, 0xFF, 0x58, 0x01, 0x57, 0x01, 0x06, 0x00, 0x1D, 0x00, + 0x0C, 0xFF, 0x4B, 0xFF, 0x6A, 0xFE, 0xE4, 0xFE, 0x72, 0xFE, 0x22, 0xFF, + 0xB0, 0xFE, 0x80, 0xFE, 0x0F, 0x00, 0xB5, 0xFF, 0x01, 0x01, 0xD4, 0x00, + 0xA3, 0x00, 0x4A, 0x00, 0xE4, 0xFE, 0x1F, 0xFF, 0x7B, 0xFE, 0x29, 0xFF, + 0x2B, 0x03, 0x63, 0x03, 0xAC, 0xFF, 0x2E, 0xFF, 0xEA, 0xFD, 0x18, 0xFE, + 0x64, 0x03, 0xD7, 0x03, 0x30, 0xFF, 0xF3, 0xFE, 0xB9, 0xF8, 0xC2, 0xF8, + 0x03, 0xFD, 0x01, 0xFE, 0x46, 0x02, 0x20, 0x02, 0xCE, 0xFD, 0x79, 0xFD, + 0xD5, 0xF6, 0x38, 0xF7, 0xC1, 0x00, 0x64, 0x02, 0x2E, 0x0A, 0xA1, 0x09, + 0x0F, 0xFD, 0xE4, 0xFB, 0x1E, 0xF9, 0x5F, 0xFA, 0xE2, 0x0A, 0x8F, 0x0A, + 0x33, 0x0C, 0xEF, 0x0A, 0x16, 0x01, 0x47, 0x01, 0x3A, 0xF8, 0x21, 0xF9, + 0x7C, 0x02, 0x4C, 0x02, 0xC7, 0x03, 0x6C, 0x03, 0xCE, 0xFD, 0x1D, 0xFF, + 0x19, 0xFE, 0x88, 0xFF, 0x55, 0xFA, 0x29, 0xF9, 0xE3, 0xF7, 0x34, 0xF7, + 0x1D, 0xFD, 0x4E, 0xFF, 0x00, 0x09, 0x9E, 0x07, 0x04, 0x04, 0x06, 0x02, + 0x50, 0xEF, 0x73, 0xF0, 0x07, 0xF3, 0x23, 0xF6, 0xCC, 0x11, 0x83, 0x12, + 0x83, 0x11, 0x3D, 0x0F, 0x2B, 0x02, 0x8C, 0x02, 0x31, 0xEC, 0x78, 0xED, + 0x33, 0xFE, 0x0F, 0xFD, 0x30, 0xFE, 0xF9, 0xFE, 0xA8, 0xFC, 0x8D, 0x00, + 0x5F, 0x05, 0xD9, 0x03, 0xCF, 0xF9, 0x19, 0xF7, 0x83, 0xF4, 0xFE, 0xF5, + 0xB9, 0x00, 0x6F, 0x05, 0xBE, 0x19, 0x06, 0x19, 0x05, 0x0E, 0xAE, 0x09, + 0xEB, 0xFA, 0x56, 0xF9, 0xE2, 0xF8, 0xA0, 0xFA, 0x9B, 0x16, 0xB5, 0x15, + 0xE6, 0xFC, 0xAB, 0xFB, 0x47, 0xE7, 0x69, 0xEB, 0x50, 0xF8, 0x19, 0xF8, + 0x0A, 0xFA, 0xEF, 0xF7, 0x58, 0xF5, 0x1A, 0xF8, 0x03, 0xFD, 0x32, 0x01, + 0xF8, 0x0F, 0xA7, 0x0F, 0x26, 0x10, 0x52, 0x0D, 0x03, 0x06, 0x65, 0x03, + 0x4C, 0xFC, 0x2E, 0xFF, 0x31, 0x06, 0x29, 0x05, 0x57, 0xFB, 0xAD, 0xF8, + 0xF7, 0xF6, 0x0B, 0xF9, 0xCD, 0x04, 0x42, 0x05, 0x80, 0xF3, 0x79, 0xF3, + 0xD4, 0xEE, 0x79, 0xEE, 0xBA, 0x04, 0x8A, 0x06, 0xB7, 0x0E, 0xAE, 0x10, + 0x7F, 0x09, 0xD6, 0x09, 0x66, 0x01, 0xFE, 0xFE, 0x09, 0xFC, 0xF4, 0xF8, + 0xA5, 0x05, 0x84, 0x03, 0x4A, 0xF9, 0xD8, 0xF9, 0x85, 0xF4, 0x5A, 0xF6, + 0xA8, 0x0C, 0xF3, 0x0E, 0xB8, 0xFD, 0x49, 0xFE, 0xDF, 0xF6, 0x50, 0xF6, + 0x18, 0xFF, 0xBA, 0x01, 0x83, 0x02, 0xA5, 0x03, 0x94, 0x05, 0x0E, 0x07, + 0x1F, 0x01, 0x57, 0x01, 0x43, 0x04, 0x64, 0x02, 0xB4, 0x08, 0x46, 0x08, + 0xC9, 0xF7, 0xCA, 0xF7, 0xA9, 0xF9, 0x00, 0xF7, 0xDE, 0x08, 0xD5, 0x04, + 0x39, 0xF8, 0x2A, 0xF8, 0x67, 0xF6, 0x6D, 0xF7, 0x61, 0xFC, 0x41, 0xFC, + 0x5C, 0x0A, 0xC8, 0x09, 0x1B, 0x09, 0x83, 0x0A, 0x74, 0xF3, 0x5C, 0xF7, + 0x64, 0xFD, 0x0F, 0xFF, 0x2C, 0x11, 0xE9, 0x10, 0x03, 0x06, 0x8B, 0x07, + 0xD3, 0xF7, 0xAC, 0xF8, 0xC9, 0xFB, 0x8F, 0xFA, 0x63, 0xF6, 0x3C, 0xF5, + 0xAF, 0xF9, 0x14, 0xF7, 0xA9, 0x02, 0xE1, 0xFF, 0x88, 0x09, 0x5D, 0x0A, + 0xD7, 0x01, 0x37, 0x02, 0xAB, 0xF4, 0x70, 0xF6, 0xAE, 0xF0, 0x02, 0xF1, + 0x6C, 0x04, 0x78, 0x05, 0x94, 0x0C, 0xCF, 0x0D, 0x91, 0x00, 0x24, 0xFE, + 0x47, 0x03, 0x3A, 0x02, 0xB1, 0xF6, 0x13, 0xF6, 0x63, 0xFE, 0xC5, 0xFE, + 0x36, 0x10, 0x98, 0x0F, 0x7F, 0x0D, 0xDE, 0x0D, 0x1B, 0x06, 0x54, 0x06, + 0x36, 0x02, 0x24, 0x03, 0x74, 0xF9, 0x83, 0xFA, 0x71, 0xFD, 0x26, 0x00, + 0x0B, 0x05, 0xF4, 0x06, 0x5D, 0x01, 0x5E, 0x03, 0x34, 0xFC, 0x30, 0xFC, + 0x7F, 0xF8, 0xC6, 0xF3, 0x4B, 0x0C, 0x03, 0x0A, 0xD4, 0x05, 0x85, 0x03, + 0x23, 0xF2, 0x77, 0xF1, 0xFD, 0xE7, 0x57, 0xE7, 0x0A, 0x11, 0xBA, 0x0F, + 0xCD, 0x1F, 0x57, 0x1F, 0x27, 0xF1, 0xDF, 0xF2, 0x9B, 0xF5, 0x37, 0xF6, + 0x27, 0x0F, 0xAD, 0x10, 0x80, 0x1A, 0x70, 0x1A, 0x87, 0xFB, 0xBA, 0xFA, + 0x7D, 0xFD, 0xE5, 0xFC, 0x6E, 0x05, 0x8B, 0x03, 0xA7, 0x00, 0xD4, 0x00, + 0x68, 0xF2, 0x2C, 0xF3, 0x14, 0x01, 0x72, 0x02, 0x97, 0xFA, 0xF0, 0xFA, + 0x77, 0xE9, 0x9B, 0xEA, 0x8C, 0x0F, 0x67, 0x0E, 0x53, 0x08, 0xC6, 0x07, + 0xA3, 0xE5, 0x00, 0xE5, 0x56, 0xE9, 0x83, 0xE8, 0xEB, 0x28, 0xAF, 0x26, + 0x7D, 0x2D, 0xC5, 0x2C, 0x6B, 0x13, 0xE9, 0x12, 0x61, 0xEE, 0x84, 0xF1, + 0x32, 0xEF, 0xA8, 0xF1, 0x40, 0xFA, 0xCE, 0xF3, 0x1D, 0xF1, 0x2A, 0xF3, + 0x7B, 0xFE, 0xB2, 0x02, 0xED, 0x04, 0xA7, 0x02, 0xD4, 0xF6, 0x0B, 0xF3, + 0xF6, 0x0E, 0x6E, 0x11, 0x4E, 0x2F, 0x8F, 0x32, 0x34, 0x11, 0xA4, 0x0F, + 0xEC, 0x04, 0xC4, 0x02, 0x4F, 0x07, 0x60, 0x07, 0x25, 0x13, 0xB8, 0x0F, + 0x4B, 0x06, 0x13, 0x01, 0xAA, 0xD5, 0xCD, 0xD6, 0x31, 0xD6, 0x69, 0xD7, + 0x44, 0x05, 0xA5, 0x00, 0x8D, 0xE8, 0xED, 0xE8, 0xF4, 0xF3, 0x40, 0xFB, + 0xC8, 0x21, 0xCA, 0x1C, 0xBF, 0x1A, 0xFC, 0x15, 0xDC, 0xFB, 0xE0, 0x00, + 0xFF, 0xF3, 0xFB, 0xF5, 0x42, 0x12, 0x7C, 0x10, 0x34, 0x09, 0x62, 0x01, + 0xAD, 0xF1, 0x33, 0xF1, 0x04, 0xFB, 0x34, 0x01, 0x9E, 0xFB, 0xDD, 0xF6, + 0x80, 0xD6, 0x71, 0xD4, 0x22, 0xEF, 0x77, 0xF4, 0x83, 0x1A, 0x73, 0x19, + 0x39, 0x04, 0xDE, 0x01, 0xCE, 0xE3, 0xAF, 0xE9, 0x08, 0xF2, 0xC8, 0xF5, + 0x7C, 0x16, 0xCD, 0x11, 0xB5, 0x18, 0x14, 0x0B, 0xA8, 0x03, 0x97, 0x00, + 0x9B, 0x10, 0xA5, 0x17, 0x77, 0x0C, 0x09, 0x08, 0x15, 0xED, 0xBA, 0xEA, + 0x73, 0x00, 0x1D, 0x06, 0xE1, 0x1A, 0x43, 0x1E, 0xFB, 0xF1, 0xFE, 0xEC, + 0xF2, 0xDB, 0xC4, 0xDB, 0x75, 0xED, 0x33, 0xF2, 0xB7, 0xFF, 0x33, 0xFE, + 0xF6, 0x06, 0x61, 0x03, 0x00, 0xF1, 0x02, 0xED, 0x06, 0x0E, 0x24, 0x0B, + 0xF2, 0x1B, 0x93, 0x13, 0x9E, 0xFA, 0x13, 0xF8, 0x5C, 0x03, 0xF2, 0x06, + 0xD0, 0x13, 0x81, 0x1A, 0x8D, 0xEB, 0xD4, 0xF4, 0x27, 0xEE, 0x62, 0xF3, + 0xE6, 0xF7, 0xF5, 0xFA, 0xB0, 0xEF, 0x3B, 0xEF, 0x40, 0xF0, 0xE8, 0xED, + 0x62, 0xE1, 0x3A, 0xDE, 0x50, 0x12, 0xB4, 0x12, 0x69, 0x22, 0xB0, 0x1B, + 0xA0, 0x04, 0xD1, 0x02, 0x1B, 0x30, 0x5C, 0x31, 0xF4, 0x18, 0xFD, 0x16, + 0x0E, 0x8C, 0xE5, 0x8E, 0x46, 0xCE, 0xB6, 0xD9, 0x74, 0x35, 0xAB, 0x3C, + 0x43, 0x2C, 0x02, 0x29, 0x78, 0xED, 0x96, 0xE5, 0xBC, 0xD5, 0x47, 0xD1, + 0xAA, 0x37, 0xE7, 0x36, 0x6C, 0x2A, 0x14, 0x1F, 0xFB, 0xF2, 0xFA, 0xEF, + 0x52, 0xF4, 0x22, 0xFE, 0x04, 0xC3, 0x92, 0xC8, 0x00, 0x80, 0xB8, 0x81, + 0xE4, 0xFF, 0x1D, 0x11, 0xFF, 0x7F, 0xFF, 0x7F, 0xD0, 0x4D, 0x65, 0x42, + 0x62, 0xC5, 0x7A, 0xB8, 0xC9, 0xB9, 0xED, 0xB9, 0x02, 0x1B, 0x84, 0x24, + 0x0E, 0x10, 0x2F, 0x0A, 0x65, 0x0C, 0x01, 0x08, 0xAE, 0x76, 0xD5, 0x76, + 0x7F, 0x30, 0x2E, 0x30, 0x02, 0x80, 0x00, 0x80, 0x34, 0xC2, 0x03, 0xC9, + 0xBA, 0x5C, 0x3F, 0x61, 0x18, 0x4F, 0x25, 0x4B, 0xBF, 0xD0, 0x6C, 0xC5, + 0x11, 0xE0, 0x8C, 0xDC, 0xF9, 0xF4, 0x40, 0xF2, 0x7F, 0xAB, 0x70, 0xAB, + 0x3A, 0xAB, 0xAA, 0xB9, 0x50, 0x3A, 0xF1, 0x45, 0x38, 0x5E, 0x2A, 0x51, + 0xAC, 0x02, 0x9C, 0xFA, 0x2F, 0xFF, 0x4E, 0x12, 0x86, 0xFB, 0xBD, 0x06, + 0x09, 0x96, 0x73, 0x95, 0xE3, 0xAC, 0xB1, 0xA8, 0xD6, 0x2B, 0x3B, 0x26, + 0x03, 0x7C, 0x05, 0x7C, 0x2F, 0x3C, 0x33, 0x39, 0x6D, 0x94, 0x09, 0x9C, + 0x50, 0xAF, 0x28, 0xD1, 0x20, 0x0F, 0x05, 0x13, 0xD4, 0x30, 0xBC, 0x23, + 0x0B, 0x2A, 0x1D, 0x3C, 0x48, 0x4F, 0xDD, 0x4F, 0x70, 0x1E, 0x88, 0x0B, + 0x69, 0x0E, 0x71, 0x0C, 0x56, 0x00, 0x0B, 0x15, 0xF3, 0x12, 0x13, 0x2B, + 0xB3, 0x75, 0xFC, 0x59, 0x0E, 0x24, 0xF0, 0x02, 0x95, 0xAA, 0x8B, 0xAF, + 0x97, 0xAE, 0x12, 0xB0, 0xB0, 0xE7, 0x6F, 0xDF, 0xCF, 0x06, 0xD2, 0x01, + 0x6A, 0x12, 0x4B, 0x1C, 0x69, 0x39, 0x08, 0x41, 0xC6, 0x2D, 0xF8, 0x33, + 0x85, 0xC7, 0x7F, 0xDC, 0xDF, 0x9F, 0x3F, 0xAB, 0xB6, 0xB6, 0x3B, 0xB3, + 0x61, 0x05, 0x86, 0xF9, 0x15, 0xFA, 0x77, 0xE5, 0xF3, 0xC0, 0xB9, 0xB0, + 0xBA, 0x97, 0xFA, 0x9E, 0x5B, 0xAE, 0x4E, 0xBC, 0x89, 0x8A, 0x46, 0x93, + 0x11, 0xD9, 0x3D, 0xD5, 0x22, 0x69, 0x30, 0x51, 0xEB, 0x70, 0xB5, 0x68, + 0x61, 0x4D, 0x8E, 0x52, 0x04, 0xE2, 0xDE, 0xF5, 0x24, 0x0D, 0xA3, 0x1D, + 0x73, 0x3D, 0x0D, 0x35, 0xD0, 0xEC, 0x10, 0xE2, 0xA7, 0xA5, 0x5A, 0xA5, + 0xD6, 0x03, 0x12, 0xF2, 0xFF, 0xF8, 0x00, 0xE8, 0x41, 0x9A, 0x9E, 0xB0, + 0x5E, 0x1A, 0x4A, 0x21, 0xEA, 0x7A, 0x19, 0x79, 0x80, 0x7F, 0x09, 0x65, + 0xB8, 0x35, 0x92, 0x16, 0x94, 0x1C, 0x1A, 0x27, 0xCB, 0x64, 0x56, 0x69, + 0x88, 0xFC, 0x5C, 0xFC, 0x00, 0x80, 0x99, 0x8A, 0x60, 0xB1, 0xA5, 0xC3, + 0x16, 0x19, 0xB2, 0xFB, 0xBC, 0xBF, 0x82, 0xAE, 0xBD, 0xAB, 0xC0, 0xBD, + 0xB4, 0x06, 0xD1, 0x09, 0xC9, 0x34, 0x4B, 0x12, 0x12, 0x27, 0xEA, 0xFE, + 0x6C, 0x27, 0xA3, 0x2E, 0xFF, 0x7F, 0xFF, 0x7F, 0xAA, 0x55, 0x1B, 0x50, + 0xAB, 0xD4, 0xE1, 0xE3, 0x96, 0x9C, 0xD2, 0xD5, 0xE0, 0xB8, 0x7F, 0xD4, + 0x76, 0x8E, 0x12, 0x83, 0x94, 0xAE, 0x60, 0xA3, 0xAA, 0x16, 0x67, 0x0A, + 0xF7, 0x2F, 0xAF, 0x24, 0xFC, 0x2A, 0xA3, 0x0D, 0x0B, 0x19, 0xD1, 0x17, + 0x98, 0x53, 0x59, 0x5A, 0xFF, 0x7F, 0xFF, 0x7F, 0x90, 0x75, 0x98, 0x73, + 0x95, 0x4E, 0xC7, 0x50, 0xBF, 0xD9, 0x4A, 0xF1, 0x77, 0x8C, 0x29, 0xA6, + 0xD7, 0x90, 0xAE, 0x90, 0x98, 0xAD, 0x5D, 0xAB, 0xD9, 0xE9, 0xE5, 0xE6, + 0x68, 0x3B, 0x94, 0x27, 0x94, 0x4B, 0x42, 0x3A, 0x0B, 0x34, 0x8D, 0x25, + 0x42, 0x1C, 0x2B, 0x24, 0x7E, 0x20, 0x49, 0x2A, 0x9C, 0x42, 0xE6, 0x38, + 0x07, 0x0A, 0xCC, 0x06, 0xAE, 0xB1, 0x10, 0xC9, 0x55, 0x99, 0x7B, 0xB3, + 0x00, 0x80, 0xB9, 0x8F, 0x40, 0x9E, 0x24, 0xA0, 0x9B, 0xEB, 0xD9, 0xF3, + 0xAA, 0x36, 0x01, 0x32, 0x72, 0x5A, 0x5E, 0x40, 0xAF, 0x11, 0x77, 0x01, + 0xC9, 0xFE, 0xC2, 0x05, 0x9D, 0x35, 0xC5, 0x3C, 0x4D, 0x3C, 0xF5, 0x2F, + 0x41, 0xD9, 0x2E, 0xDD, 0x8C, 0xFE, 0xBC, 0x0F, 0x98, 0x16, 0x9C, 0x24, + 0x4F, 0xD7, 0x34, 0xE2, 0xA7, 0x9E, 0x26, 0xBC, 0xC6, 0xC3, 0x9D, 0xD7, + 0xB4, 0x4E, 0x90, 0x54, 0xCF, 0x7A, 0x7D, 0x6C, 0x83, 0x6B, 0x1B, 0x4F, + 0xCB, 0x45, 0x3E, 0x3B, 0x7B, 0x53, 0x8B, 0x44, 0x00, 0x12, 0xF7, 0x0B, + 0x9E, 0xE9, 0xE4, 0xF9, 0x8C, 0xF7, 0xF0, 0xFE, 0xA4, 0xDA, 0x67, 0xD5, + 0xDF, 0x9A, 0x3A, 0xA3, 0x00, 0x80, 0x97, 0x91, 0x96, 0xA4, 0xB8, 0xBA, + 0x7E, 0x05, 0x8D, 0xEF, 0xAB, 0x2A, 0x84, 0xF8, 0x9B, 0x2E, 0xAC, 0x0F, + 0xB3, 0x54, 0xC2, 0x3B, 0x02, 0x1E, 0xA6, 0x14, 0x75, 0xCC, 0x27, 0xDD, + 0x8E, 0x99, 0xB8, 0xB6, 0x61, 0xBF, 0x1B, 0xC4, 0x9C, 0xCB, 0x7B, 0xC5, + 0x81, 0xAE, 0x82, 0xB3, 0x59, 0x9E, 0xF1, 0xAF, 0x61, 0xB7, 0xC0, 0xD6, + 0x08, 0x09, 0xC3, 0x05, 0x93, 0x18, 0x0A, 0xFC, 0xE0, 0x2F, 0x07, 0x11, + 0x2D, 0x51, 0x39, 0x3A, 0xFF, 0x7F, 0x1E, 0x69, 0x40, 0x2F, 0xA2, 0x36, + 0xA5, 0xC6, 0x2B, 0xF2, 0x2D, 0xFA, 0x88, 0x10, 0x8A, 0x3B, 0xBA, 0x2B, + 0xCD, 0x4D, 0x21, 0x2E, 0xDB, 0xDD, 0x8D, 0xEB, 0x0F, 0x9E, 0xF3, 0xC4, + 0x40, 0xC7, 0xF9, 0xCD, 0x58, 0xEB, 0xA7, 0xE7, 0x00, 0x13, 0xEE, 0x15, + 0x75, 0x58, 0x3E, 0x52, 0xFF, 0x7F, 0x9A, 0x6A, 0x42, 0x61, 0xF3, 0x4E, + 0x66, 0x0B, 0xBE, 0x1E, 0x33, 0xE0, 0xD5, 0xF2, 0xEB, 0xBD, 0x72, 0xC0, + 0xAA, 0xA9, 0x81, 0xA0, 0xE6, 0xC8, 0x2E, 0xC9, 0x1B, 0x00, 0xD2, 0x08, + 0x37, 0xDD, 0x39, 0xE6, 0x4B, 0xB0, 0x34, 0xC1, 0x98, 0xDC, 0x0F, 0xF3, + 0x1F, 0x21, 0xFD, 0x1C, 0x13, 0x49, 0x4E, 0x23, 0xA4, 0x22, 0xD4, 0x0E, + 0x18, 0xF1, 0x07, 0xF6, 0x97, 0xAB, 0x9D, 0xCD, 0x13, 0xA1, 0x07, 0xB5, + 0x00, 0x80, 0xF0, 0x8A, 0x75, 0xB2, 0x1A, 0xC5, 0x1B, 0xF9, 0xD9, 0xFE, + 0xF2, 0xFC, 0xF9, 0x00, 0x07, 0xFB, 0xDA, 0x14, 0xEB, 0x11, 0xDE, 0x2F, + 0x67, 0x1D, 0xD5, 0x1D, 0x5A, 0x40, 0x4D, 0x2A, 0x79, 0x55, 0x8D, 0x43, + 0x7F, 0x4D, 0x21, 0x4D, 0x5A, 0x42, 0xBB, 0x45, 0x44, 0xC7, 0x94, 0xCC, + 0x21, 0x82, 0x48, 0x94, 0x28, 0xB6, 0x9E, 0xC7, 0x95, 0x00, 0xEC, 0xF9, + 0xEA, 0xF6, 0x9B, 0xEF, 0x3A, 0x19, 0xE8, 0x1D, 0xA3, 0x48, 0xF3, 0x46, + 0x1E, 0x64, 0x17, 0x56, 0x34, 0x37, 0x9C, 0x25, 0x6B, 0x4D, 0x1F, 0x32, + 0xCF, 0x6E, 0x57, 0x53, 0x65, 0x4C, 0xA6, 0x33, 0xAF, 0xF1, 0xF8, 0xE9, + 0x16, 0x87, 0x1A, 0x83, 0xC5, 0x84, 0x61, 0x8B, 0x3A, 0xA5, 0x32, 0xA9, + 0x9F, 0xD3, 0x0D, 0xD1, 0x2F, 0xEF, 0x8E, 0xF5, 0x85, 0x44, 0x7F, 0x3C, + 0x7F, 0x41, 0xF4, 0x36, 0x23, 0x23, 0xCF, 0x12, 0xE7, 0x08, 0xCA, 0x01, + 0xD0, 0x06, 0x77, 0x00, 0x60, 0x57, 0x8B, 0x35, 0xE0, 0x23, 0xAE, 0x04, + 0x8B, 0xB4, 0xD6, 0xC9, 0x57, 0xA2, 0xFC, 0xCF, 0x4A, 0xB9, 0x7C, 0xCF, + 0x70, 0xB0, 0x6F, 0xBF, 0xD0, 0xE3, 0x44, 0xF3, 0x18, 0x54, 0x91, 0x4D, + 0x1C, 0x5B, 0xA1, 0x4C, 0x27, 0x35, 0x8E, 0x2D, 0x30, 0x01, 0xC3, 0x0C, + 0x29, 0x17, 0xC1, 0x21, 0x2A, 0x6A, 0xD9, 0x43, 0x82, 0x37, 0x2D, 0x10, + 0x72, 0x02, 0x7F, 0x07, 0x7A, 0xDE, 0x6C, 0xF8, 0x9D, 0xC9, 0x82, 0xDD, + 0x51, 0xA8, 0xBE, 0xC3, 0x40, 0xB7, 0x31, 0xCF, 0x71, 0x2F, 0xA3, 0x1F, + 0xEB, 0x44, 0x49, 0x25, 0xD7, 0x49, 0xA8, 0x38, 0x66, 0xFD, 0xEF, 0x06, + 0xD1, 0xCA, 0x1E, 0xD0, 0xF2, 0xE3, 0xF6, 0xC9, 0x32, 0x0E, 0x33, 0xE5, + 0x55, 0x05, 0xA4, 0xF8, 0x6A, 0xF7, 0x5B, 0xFC, 0x1A, 0xEB, 0x39, 0xFE, + 0xCB, 0xB3, 0xE1, 0xDB, 0xAC, 0xCF, 0x24, 0xFC, 0x06, 0x16, 0xD9, 0x19, + 0x28, 0x7D, 0xE1, 0x65, 0x04, 0x63, 0x2D, 0x4B, 0x40, 0x06, 0xF4, 0xF8, + 0x34, 0x9F, 0x00, 0xBF, 0x80, 0xAC, 0x9F, 0xB5, 0x3F, 0xCF, 0xBF, 0xCD, + 0x7E, 0xF2, 0x8D, 0xF4, 0x70, 0x25, 0x52, 0x25, 0x77, 0x42, 0x39, 0x44, + 0xA1, 0x24, 0xF4, 0x42, 0xA6, 0x1C, 0x19, 0x37, 0x00, 0x36, 0xB9, 0x38, + 0xEE, 0x36, 0x74, 0x21, 0xF5, 0x6D, 0xD6, 0x50, 0x8F, 0x59, 0xC4, 0x58, + 0x08, 0x2C, 0x8C, 0x1F, 0x27, 0xBA, 0xC1, 0xB8, 0xBC, 0x99, 0xFF, 0xAB, + 0xFF, 0xC2, 0x93, 0xD0, 0x06, 0xC0, 0x63, 0xBE, 0xFD, 0xD7, 0x65, 0xDC, + 0x36, 0x00, 0xCF, 0x0F, 0x67, 0x07, 0x91, 0x17, 0xED, 0xF9, 0xCA, 0xFF, + 0xEA, 0xD9, 0xB6, 0xDD, 0x47, 0x11, 0x52, 0x05, 0xCA, 0x69, 0x54, 0x4C, + 0xE2, 0x4B, 0x71, 0x30, 0xB1, 0xCF, 0x82, 0xCE, 0x5D, 0x87, 0x04, 0xA1, + 0x54, 0x81, 0x3B, 0x90, 0x9A, 0x87, 0xCB, 0x8B, 0x36, 0xCE, 0xFE, 0xD7, + 0x64, 0x0F, 0x12, 0x1A, 0x1B, 0x27, 0xFC, 0x2D, 0xB3, 0x20, 0x0B, 0x24, + 0x8D, 0x00, 0x01, 0x0E, 0x44, 0x07, 0x0B, 0x12, 0x51, 0x4E, 0x5E, 0x3A, + 0xD4, 0x5A, 0xB1, 0x3B, 0x53, 0x19, 0x33, 0x0D, 0x43, 0xD2, 0xFC, 0xEB, + 0x4B, 0xB3, 0x9F, 0xCF, 0x47, 0xA0, 0x75, 0xB0, 0xBD, 0xD9, 0x61, 0xE3, + 0x32, 0x1A, 0x24, 0x19, 0x89, 0x3F, 0x83, 0x46, 0xD6, 0x72, 0x9D, 0x6F, + 0x83, 0x3F, 0x23, 0x37, 0xBC, 0xE1, 0x1A, 0xEE, 0x31, 0x16, 0x2B, 0x11, + 0xB3, 0x50, 0x70, 0x24, 0xDD, 0x11, 0x42, 0xF8, 0x72, 0xD5, 0xCF, 0xE4, + 0x4D, 0xA4, 0x00, 0xBD, 0x51, 0x86, 0x7C, 0x9A, 0x8F, 0x80, 0x89, 0x95, + 0x50, 0x97, 0x94, 0xB5, 0x7D, 0x03, 0x1E, 0xFD, 0xFE, 0x7F, 0x67, 0x69, + 0xE3, 0x4B, 0xB5, 0x4D, 0x6D, 0xE0, 0x2A, 0xEF, 0x2B, 0xEF, 0x10, 0xF7, + 0x21, 0x15, 0x3E, 0x05, 0xD2, 0x09, 0xAE, 0xFD, 0x61, 0xD7, 0xE6, 0xDF, + 0x30, 0xB6, 0x02, 0xCD, 0x62, 0x92, 0x92, 0xB2, 0x00, 0x80, 0x62, 0x9D, + 0x78, 0x91, 0xBA, 0xB2, 0x29, 0xF7, 0xE2, 0x07, 0x86, 0x77, 0x43, 0x7B, + 0x5E, 0x66, 0x0B, 0x61, 0xD5, 0x51, 0x8C, 0x45, 0xA7, 0x38, 0xEA, 0x39, + 0xAD, 0x14, 0xF2, 0x09, 0xE4, 0xDF, 0x25, 0xD9, 0xE1, 0xFB, 0x6E, 0xFF, + 0x0D, 0xF7, 0x1D, 0x0C, 0x2D, 0xBB, 0x34, 0xCF, 0x1B, 0xC8, 0xB9, 0xDA, + 0x67, 0x83, 0xA4, 0xAF, 0x95, 0xCF, 0xF7, 0xEC, 0x6D, 0x47, 0x01, 0x3F, + 0xB8, 0x7E, 0x49, 0x5B, 0xAD, 0x59, 0x50, 0x39, 0x3F, 0x18, 0xDD, 0x04, + 0x38, 0xEF, 0x57, 0xE8, 0x62, 0xD9, 0x47, 0xD9, 0x71, 0xEB, 0x18, 0xE8, + 0xD1, 0xC0, 0x90, 0xBB, 0x53, 0xD7, 0x36, 0xD3, 0x4B, 0xED, 0x06, 0xFA, + 0x12, 0xC3, 0x4B, 0xE5, 0x82, 0xB2, 0x4F, 0xD4, 0x98, 0xE0, 0xE2, 0xEC, + 0xF5, 0x41, 0xE9, 0x29, 0xEA, 0x62, 0x12, 0x3A, 0x1B, 0x43, 0x2A, 0x29, + 0x6A, 0x01, 0x72, 0x02, 0xEF, 0xE5, 0xE3, 0xED, 0xA8, 0xD1, 0x16, 0xD7, + 0x94, 0xA1, 0x3C, 0xA8, 0x63, 0xC7, 0xE7, 0xD0, 0x4A, 0x0F, 0x26, 0x14, + 0x7E, 0x3D, 0x81, 0x38, 0xC7, 0x03, 0x18, 0x15, 0x9F, 0xE4, 0x24, 0xFB, + 0xFA, 0x1E, 0x0D, 0x20, 0x08, 0x7A, 0xF9, 0x51, 0xBA, 0x51, 0x6F, 0x36, + 0x0B, 0x19, 0xCC, 0x18, 0xE7, 0xE4, 0x42, 0xF0, 0x0F, 0x97, 0xE0, 0xA9, + 0xD4, 0x9D, 0x24, 0xA1, 0xF2, 0xA8, 0x7D, 0xB3, 0xDA, 0x06, 0xAC, 0xFE, + 0x99, 0x44, 0x6E, 0x30, 0x3E, 0x29, 0x53, 0x17, 0xB4, 0xED, 0x6B, 0xF8, + 0xF4, 0xFD, 0x72, 0xFF, 0xCB, 0x22, 0xB0, 0x0A, 0x18, 0x33, 0x0B, 0x11, + 0xDA, 0x11, 0xC0, 0xFF, 0xA0, 0xEE, 0x1C, 0xF6, 0xFB, 0xC4, 0xAF, 0xD1, + 0xD8, 0x92, 0xBA, 0x9B, 0x00, 0x80, 0x8B, 0x80, 0x29, 0xA7, 0x03, 0xA3, + 0xF3, 0x1D, 0x61, 0xFF, 0xE6, 0x45, 0x4C, 0x32, 0x19, 0x33, 0x2D, 0x37, + 0x5D, 0x1F, 0xFE, 0x27, 0x8E, 0x29, 0x39, 0x19, 0xD3, 0x40, 0xE1, 0x2A, + 0x50, 0x45, 0xB2, 0x31, 0x48, 0x2C, 0x90, 0x23, 0xD7, 0x0A, 0x9C, 0x01, + 0xB5, 0xBB, 0x17, 0xD1, 0x0A, 0x85, 0xD2, 0xA7, 0x8A, 0x95, 0xBE, 0xA8, + 0xC1, 0xE7, 0x3D, 0xE5, 0x8B, 0x5C, 0x47, 0x4A, 0x07, 0x76, 0x7F, 0x6F, + 0xDD, 0x74, 0x6B, 0x5C, 0x51, 0x4A, 0x24, 0x3E, 0xD7, 0x30, 0xCB, 0x1E, + 0xDE, 0x3E, 0x78, 0x2C, 0x3B, 0x09, 0x64, 0xFA, 0x88, 0x09, 0x61, 0xFE, + 0x47, 0xF8, 0xEA, 0x00, 0x8C, 0xB6, 0x4B, 0xCB, 0x2F, 0x84, 0xA6, 0x8A, + 0x78, 0xAB, 0x45, 0xAD, 0xC6, 0x09, 0xB5, 0xFC, 0x59, 0x59, 0x96, 0x2A, + 0x51, 0x64, 0x35, 0x3D, 0xE4, 0x3E, 0x74, 0x24, 0xBC, 0x21, 0x7D, 0x14, + 0x7F, 0xE4, 0x04, 0xE4, 0xAC, 0xC9, 0x9E, 0xC1, 0xC5, 0xD0, 0x08, 0xCC, + 0x5B, 0x0D, 0x3B, 0x0B, 0xB1, 0xE9, 0x89, 0xF3, 0xE2, 0xA2, 0xEA, 0xAF, + 0x5A, 0x8F, 0xF9, 0x9A, 0x93, 0xD3, 0x2A, 0xE5, 0x32, 0x51, 0xF2, 0x2F, + 0xFF, 0x7F, 0x69, 0x52, 0x4C, 0x5D, 0xBA, 0x4C, 0xBD, 0x40, 0xC0, 0x41, + 0x8A, 0x2B, 0xF7, 0x2E, 0x70, 0xDB, 0xE6, 0xDA, 0xDE, 0xC3, 0xD6, 0xC8, + 0xC7, 0xF8, 0x4B, 0xF7, 0x8F, 0x2A, 0xF4, 0x27, 0x86, 0xFD, 0x9B, 0x10, + 0x17, 0xBA, 0x1F, 0xE6, 0x87, 0xEF, 0x99, 0xFC, 0x1E, 0x44, 0xA0, 0x27, + 0x34, 0x76, 0x9B, 0x58, 0xA4, 0x7A, 0x3E, 0x6A, 0x58, 0x63, 0x7F, 0x5D, + 0x1E, 0x57, 0xFC, 0x43, 0xE0, 0xEE, 0xAE, 0xD5, 0xFD, 0x97, 0x69, 0x96, + 0x28, 0xAC, 0xAF, 0xB9, 0xE8, 0x0F, 0x69, 0xFD, 0x67, 0x08, 0x85, 0x01, + 0xA7, 0xC8, 0x32, 0xEC, 0xE1, 0xC0, 0xD7, 0xEA, 0x35, 0xFF, 0xE7, 0x04, + 0x46, 0x45, 0x54, 0x20, 0xE0, 0x27, 0x5A, 0x05, 0x33, 0x4B, 0xB8, 0x3B, + 0xFB, 0x62, 0x89, 0x52, 0x6B, 0x0D, 0xDE, 0x05, 0x26, 0xA1, 0x84, 0xAA, + 0x7B, 0xA2, 0x1A, 0x9E, 0xFD, 0xD1, 0x96, 0xC5, 0x66, 0xF4, 0x55, 0xED, + 0x57, 0xEA, 0x09, 0x07, 0xCC, 0xF4, 0x6A, 0x08, 0x47, 0x38, 0x4C, 0x34, + 0xEF, 0x34, 0x71, 0x27, 0xCB, 0x33, 0x9C, 0x1D, 0x95, 0x47, 0xB2, 0x34, + 0xC7, 0x62, 0x6B, 0x4A, 0x7B, 0x4A, 0xB0, 0x45, 0x02, 0xDD, 0x71, 0xF0, + 0xB7, 0x91, 0x21, 0xAB, 0x98, 0x9F, 0x59, 0xA8, 0x5A, 0xFC, 0xAC, 0xFC, + 0xC9, 0x23, 0x3A, 0x2E, 0xFE, 0x2A, 0x4B, 0x3C, 0x9A, 0x2F, 0xDF, 0x46, + 0xB6, 0x21, 0xDA, 0x2E, 0x54, 0x17, 0xB5, 0x07, 0x9E, 0x11, 0x9E, 0xF1, + 0x43, 0x22, 0xE3, 0x06, 0xF0, 0x31, 0x61, 0x2B, 0xD9, 0x1E, 0x7B, 0x25, + 0x74, 0xC2, 0x70, 0xC7, 0xA8, 0x89, 0x7D, 0x8E, 0x59, 0x85, 0xE6, 0x96, + 0x43, 0xC5, 0x79, 0xD4, 0xB1, 0x28, 0x98, 0x28, 0x78, 0x32, 0x9B, 0x33, + 0x8E, 0x06, 0x86, 0x12, 0x12, 0x03, 0x12, 0x07, 0x5E, 0x04, 0x08, 0xEA, + 0x90, 0x01, 0x83, 0xE6, 0x7C, 0x16, 0x48, 0x11, 0x7A, 0x2B, 0xA8, 0x32, + 0xFD, 0xE7, 0x7B, 0xF2, 0xAD, 0x96, 0xCD, 0xB7, 0x3B, 0xA3, 0x40, 0xC3, + 0xBE, 0xE4, 0x5D, 0xE1, 0x4B, 0x2B, 0x65, 0x17, 0xE6, 0x2A, 0x6D, 0x24, + 0x83, 0x45, 0xC0, 0x57, 0xE1, 0x67, 0x43, 0x6D, 0x3B, 0x3C, 0x9D, 0x2B, + 0xB3, 0xD0, 0xEE, 0xBE, 0xD6, 0xE4, 0x07, 0xE5, 0x9D, 0x29, 0xEB, 0x26, + 0x36, 0x06, 0x02, 0x0D, 0x2B, 0xB3, 0x89, 0xD5, 0x6F, 0x96, 0xBF, 0xAE, + 0xFA, 0xD7, 0x78, 0xDF, 0x3C, 0xF6, 0x25, 0xEB, 0x51, 0x05, 0x26, 0xFA, + 0x07, 0x2B, 0x21, 0x34, 0xA3, 0x6F, 0x62, 0x6B, 0xA3, 0x49, 0x91, 0x32, + 0x62, 0xCD, 0x76, 0xC3, 0xC6, 0xA1, 0xA5, 0xA4, 0x9D, 0xD3, 0x42, 0xD1, + 0xDA, 0xEF, 0x25, 0xF0, 0x47, 0xCB, 0x4A, 0xE4, 0xCD, 0x99, 0x2A, 0xC2, + 0xBC, 0xB1, 0x43, 0xD1, 0xAD, 0xF3, 0x7F, 0xE8, 0x15, 0x02, 0xBB, 0xEB, + 0x82, 0x1C, 0x30, 0x1A, 0xC1, 0x67, 0x06, 0x63, 0xAD, 0x5D, 0x5C, 0x54, + 0x7D, 0x14, 0x5B, 0x12, 0x4B, 0xCC, 0x80, 0xDE, 0xBD, 0xBD, 0x0C, 0xC2, + 0x46, 0xDB, 0x37, 0xE1, 0x20, 0xC0, 0x72, 0xD9, 0xB5, 0xDF, 0x86, 0xF7, + 0x5C, 0x01, 0x32, 0x19, 0x53, 0x16, 0xC2, 0x1B, 0xC7, 0xF7, 0xEF, 0xF0, + 0xF1, 0x0C, 0xCE, 0xFC, 0x56, 0x4E, 0xC8, 0x3A, 0x07, 0x7A, 0xF4, 0x68, + 0xDF, 0x46, 0xA0, 0x48, 0x5A, 0xE0, 0xD1, 0xE5, 0x61, 0xB6, 0x58, 0xB6, + 0xF6, 0xA8, 0x5D, 0xB3, 0x65, 0xDE, 0x94, 0xE2, 0xC0, 0xE7, 0x2E, 0xEE, + 0x53, 0xFA, 0x25, 0x0D, 0xEA, 0xFB, 0xCE, 0x0F, 0xC9, 0xED, 0xD9, 0xF2, + 0x9F, 0xEA, 0x86, 0xDB, 0x5B, 0x01, 0x5F, 0xE0, 0x6B, 0x33, 0x79, 0x19, + 0x83, 0x5A, 0x5B, 0x46, 0x0B, 0x07, 0x63, 0x03, 0x7B, 0xA1, 0x23, 0xAC, + 0xC2, 0x8C, 0xEB, 0x98, 0x51, 0x9F, 0x18, 0xA6, 0x60, 0xD7, 0xBF, 0xD7, + 0x11, 0xFB, 0x5F, 0xFE, 0xD8, 0x0F, 0xF2, 0x20, 0xEF, 0x26, 0x58, 0x34, + 0xCF, 0x23, 0x93, 0x1D, 0x82, 0x07, 0x18, 0xF6, 0xEE, 0x1D, 0x07, 0x0C, + 0x99, 0x4C, 0x12, 0x41, 0x00, 0x1E, 0x94, 0x1B, 0x47, 0xB8, 0x4D, 0xCC, + 0x88, 0xA8, 0xAC, 0xBF, 0x70, 0xA9, 0xA5, 0xC2, 0xD6, 0xC9, 0x2D, 0xCC, + 0xBC, 0xE5, 0x32, 0xE8, 0x61, 0x1D, 0xEC, 0x28, 0x85, 0x63, 0x88, 0x6E, + 0x63, 0x61, 0x7D, 0x51, 0xA3, 0xFF, 0xB6, 0xF1, 0xF3, 0xFF, 0x88, 0xFF, + 0x66, 0x27, 0x6B, 0x22, 0xBF, 0x02, 0x18, 0x04, 0xB8, 0xF4, 0x04, 0xF0, + 0xDE, 0xAB, 0xBD, 0xC8, 0x39, 0x92, 0x8B, 0xB3, 0x88, 0xA8, 0x0F, 0xBA, + 0xDA, 0xAE, 0x3D, 0xB1, 0xF0, 0xDE, 0x9E, 0xE7, 0x45, 0x3F, 0x7B, 0x43, + 0xEB, 0x6F, 0x9D, 0x6A, 0x94, 0x2E, 0x95, 0x1D, 0xBF, 0xE5, 0xFB, 0xDB, + 0x12, 0xF6, 0x78, 0xEE, 0xF4, 0xFD, 0x2E, 0xE6, 0xED, 0x0D, 0xB7, 0xFF, + 0x49, 0xE1, 0xCB, 0xEE, 0xCC, 0xB5, 0xD7, 0xE0, 0x08, 0xB0, 0x56, 0xD0, + 0x51, 0xBE, 0x2A, 0xBD, 0x0E, 0xD8, 0x8C, 0xC7, 0x5D, 0x29, 0x7E, 0x2A, + 0x6E, 0x76, 0xF4, 0x6E, 0xF3, 0x70, 0xBD, 0x63, 0xED, 0x41, 0xA1, 0x31, + 0x28, 0xDE, 0x80, 0xD8, 0x98, 0xDC, 0x07, 0xD8, 0x61, 0xF1, 0x08, 0xE5, + 0xC7, 0xFA, 0x6F, 0x01, 0xFE, 0xEF, 0x36, 0x11, 0x1B, 0xE7, 0x4B, 0x01, + 0x2F, 0xD8, 0xE1, 0xDF, 0xC5, 0xC6, 0xA7, 0xCD, 0x58, 0x0D, 0x53, 0x0B, + 0x71, 0x67, 0x0A, 0x57, 0x57, 0x65, 0x35, 0x4F, 0x71, 0x38, 0xCF, 0x38, + 0xBA, 0xF2, 0xB3, 0xF5, 0x67, 0xBC, 0x49, 0xAF, 0x51, 0xBE, 0x6A, 0xA8, + 0x76, 0xCA, 0x95, 0xC5, 0xB0, 0xCE, 0x65, 0xE0, 0xAB, 0xEC, 0x90, 0x09, + 0xC3, 0xFB, 0x86, 0x0E, 0xD7, 0xED, 0xDD, 0xF4, 0xBD, 0xE9, 0x89, 0xE3, + 0x4A, 0x2A, 0x9F, 0x14, 0xE6, 0x78, 0xBB, 0x67, 0xA3, 0x66, 0x24, 0x5A, + 0xE6, 0x36, 0x18, 0x30, 0x38, 0xBC, 0x4C, 0xC0, 0x57, 0xAE, 0x6C, 0xAC, + 0xA7, 0xC2, 0xAB, 0xB7, 0xBB, 0xC5, 0x06, 0xC4, 0x1C, 0xF9, 0xA2, 0x07, + 0x3E, 0x33, 0xDC, 0x46, 0x88, 0x4B, 0xE4, 0x57, 0xB9, 0x08, 0x2F, 0x04, + 0x3F, 0x34, 0x70, 0x17, 0x3F, 0x6D, 0xEA, 0x53, 0x0A, 0x75, 0x4B, 0x5F, + 0xA2, 0x54, 0x0E, 0x43, 0x80, 0x04, 0x08, 0x03, 0xE5, 0xC6, 0x70, 0xCF, + 0x43, 0x99, 0x86, 0xA3, 0x5E, 0x9F, 0x14, 0xA5, 0x59, 0xD0, 0xEB, 0xD8, + 0xCE, 0x1E, 0xF3, 0x2E, 0xFD, 0x3C, 0xC7, 0x4E, 0x3D, 0x3C, 0x6E, 0x37, + 0x64, 0x32, 0x18, 0x16, 0xB8, 0x12, 0x37, 0xF9, 0x9A, 0x32, 0x70, 0x15, + 0x45, 0x4B, 0xBC, 0x2D, 0xE1, 0x1F, 0xA8, 0x14, 0x4A, 0xE5, 0x39, 0xF7, + 0xBE, 0xA0, 0x23, 0xB6, 0xD8, 0x8B, 0xA0, 0x95, 0xD3, 0x93, 0xD5, 0x90, + 0x54, 0xE1, 0xE3, 0xEB, 0x41, 0x45, 0x8B, 0x53, 0xA6, 0x4A, 0x7A, 0x42, + 0xE6, 0x24, 0x44, 0x25, 0x47, 0x00, 0xD7, 0xF7, 0x7F, 0x0F, 0xA0, 0xFD, + 0xEB, 0x27, 0x2B, 0x0A, 0x0B, 0x36, 0x86, 0x25, 0x0F, 0x02, 0x3D, 0x0F, + 0x97, 0xE3, 0xCC, 0xFA, 0x6F, 0xC8, 0xC7, 0xD7, 0x9E, 0xAA, 0xEB, 0xB8, + 0x37, 0xD6, 0x33, 0xDF, 0xC5, 0x2F, 0xF8, 0x2C, 0x58, 0x7F, 0x68, 0x7F, + 0xC3, 0x6E, 0xAD, 0x6F, 0xE9, 0x34, 0x4F, 0x41, 0x4E, 0xF6, 0xB1, 0xFB, + 0xDE, 0xFB, 0x1F, 0xE9, 0x23, 0x0F, 0x34, 0xF9, 0x49, 0xFA, 0x7D, 0xF2, + 0xC5, 0xE8, 0x34, 0xEC, 0x7B, 0xE0, 0x14, 0xF6, 0x5F, 0xB9, 0x2D, 0xD5, + 0x15, 0xDB, 0x0B, 0xE6, 0xF3, 0x1A, 0x89, 0x12, 0x87, 0x34, 0xAB, 0x22, + 0xA8, 0x6E, 0xD3, 0x5E, 0x50, 0x66, 0xE4, 0x63, 0xE3, 0x21, 0xD8, 0x19, + 0x2D, 0xF0, 0x75, 0xE2, 0xD2, 0xDB, 0x2F, 0xCE, 0xD0, 0xC0, 0x3B, 0xBA, + 0xAB, 0xC0, 0x56, 0xD2, 0xBC, 0xE1, 0x22, 0xFE, 0xD6, 0xD8, 0x68, 0xE6, + 0xD9, 0xD4, 0xE7, 0xC6, 0x80, 0xDD, 0x1A, 0xD2, 0x44, 0x02, 0xAD, 0xF2, + 0xD2, 0x63, 0x0A, 0x49, 0x52, 0x6C, 0xDD, 0x5C, 0x06, 0x39, 0x1D, 0x4A, + 0x31, 0x16, 0x52, 0x30, 0xA2, 0xFB, 0x27, 0xF2, 0xC2, 0xAF, 0x72, 0x9D, + 0xA1, 0xA9, 0xA0, 0xBA, 0xCA, 0xE0, 0xA4, 0xFF, 0xF6, 0xE0, 0xA3, 0xE5, + 0x86, 0xFD, 0x08, 0xF6, 0x39, 0xF4, 0x3A, 0xE5, 0x7C, 0xF9, 0x9C, 0xE1, + 0xB3, 0x23, 0xEE, 0x10, 0xAD, 0x55, 0x65, 0x63, 0xAC, 0x50, 0x68, 0x67, + 0x81, 0x2F, 0xC9, 0x36, 0x04, 0xF1, 0xCA, 0xFE, 0x3B, 0xBC, 0xEA, 0xC2, + 0xD5, 0xAC, 0x5E, 0x9D, 0x11, 0xAD, 0x2D, 0xA7, 0x94, 0xE8, 0x44, 0x01, + 0x53, 0x08, 0x2D, 0x2E, 0x60, 0x13, 0x82, 0x0C, 0xDE, 0xF3, 0x7B, 0xB5, + 0x93, 0xFB, 0xE5, 0xD9, 0x75, 0x24, 0xC8, 0x29, 0xF8, 0x3C, 0xC8, 0x3B, + 0xBA, 0x39, 0x7A, 0x49, 0x7D, 0xFE, 0xBB, 0x30, 0x9F, 0xCE, 0xAE, 0xD9, + 0xC7, 0xB8, 0xA3, 0xAA, 0x02, 0xA9, 0x6A, 0x9D, 0x8E, 0xBF, 0x7E, 0xC1, + 0x45, 0x0A, 0xBE, 0x29, 0x56, 0x3D, 0x8F, 0x46, 0x3E, 0x2E, 0x94, 0x16, + 0x62, 0x1D, 0x07, 0x08, 0xFD, 0x1F, 0x2B, 0x20, 0xBB, 0x29, 0xE8, 0x20, + 0x88, 0x20, 0x72, 0x22, 0x73, 0xF5, 0xCE, 0x15, 0x16, 0xF7, 0xE3, 0x0B, + 0x16, 0xB1, 0x13, 0xB1, 0xEB, 0x82, 0x04, 0x80, 0xE0, 0x8F, 0x53, 0x93, + 0x78, 0xE0, 0x36, 0xFB, 0xE3, 0x4F, 0xF8, 0x68, 0x84, 0x51, 0x30, 0x4C, + 0x51, 0x2E, 0xDF, 0x2A, 0x42, 0x15, 0x9D, 0x16, 0xDD, 0x36, 0xD8, 0x15, + 0x09, 0xF3, 0x86, 0xE1, 0xB0, 0xE0, 0x87, 0x02, 0xC4, 0xD5, 0xA1, 0xF6, + 0x52, 0xCC, 0xD5, 0xB9, 0xAE, 0xD0, 0x7C, 0xBA, 0x00, 0x80, 0x6E, 0x86, + 0x8F, 0xAA, 0xDE, 0xC3, 0xFE, 0x05, 0x09, 0x10, 0x97, 0x4D, 0xBC, 0x42, + 0x9C, 0x47, 0x01, 0x52, 0x58, 0x3C, 0xBF, 0x3E, 0xDA, 0x33, 0x54, 0x1F, + 0x88, 0xFB, 0xF8, 0xF1, 0xF1, 0xEB, 0x1A, 0xF6, 0xE3, 0xF0, 0x17, 0xFD, + 0x90, 0x00, 0xC0, 0x05, 0xC7, 0xDF, 0x3A, 0xD9, 0x69, 0xB1, 0x50, 0xAD, + 0xAD, 0xC0, 0xF1, 0xC0, 0x52, 0xE4, 0x5E, 0xD7, 0xCF, 0x36, 0x12, 0x37, + 0xFC, 0x47, 0x02, 0x63, 0xDD, 0x51, 0xF6, 0x66, 0x43, 0x36, 0x9D, 0x35, + 0x47, 0xFD, 0x86, 0xF6, 0x8B, 0xE6, 0xD1, 0xF2, 0x33, 0xC1, 0x8D, 0xCB, + 0x35, 0xDB, 0xFF, 0xEF, 0x9E, 0xE8, 0xC7, 0xF4, 0x6C, 0xEA, 0x87, 0xED, + 0x82, 0xB3, 0xE2, 0xBB, 0x4C, 0xCB, 0x45, 0xCB, 0x98, 0x13, 0x7C, 0x10, + 0x57, 0x3A, 0xE9, 0x37, 0xEF, 0x41, 0xA9, 0x41, 0xD1, 0x40, 0xFD, 0x30, + 0xAC, 0x11, 0xC4, 0x0D, 0x1A, 0xB9, 0xC6, 0xAA, 0x05, 0xA9, 0x49, 0xA9, + 0x18, 0xA3, 0xEC, 0xB2, 0x9C, 0xE4, 0xEF, 0xEF, 0x8D, 0x03, 0x90, 0x0A, + 0x8A, 0xDA, 0x36, 0xD5, 0xAA, 0xD8, 0xBC, 0xC2, 0xBA, 0x07, 0x1A, 0xF5, + 0x6C, 0x2E, 0xAB, 0x2F, 0xD2, 0x44, 0x0A, 0x3B, 0x50, 0x39, 0x6B, 0x2D, + 0xF4, 0x15, 0xA1, 0x0A, 0x93, 0xF6, 0x38, 0xF6, 0xD9, 0xC5, 0x6B, 0xC9, + 0x0B, 0x91, 0xA6, 0x95, 0xCD, 0xAF, 0xC0, 0xB7, 0xAA, 0xF5, 0x1D, 0x07, + 0xB2, 0x0A, 0x25, 0x0A, 0xB9, 0x07, 0x8C, 0xEF, 0x60, 0x1D, 0xBD, 0x0E, + 0xB6, 0x36, 0x2C, 0x38, 0xE2, 0x3E, 0xFE, 0x40, 0x10, 0x48, 0x5A, 0x4A, + 0x27, 0x1F, 0xD9, 0x30, 0x2C, 0x14, 0xBC, 0x25, 0xB1, 0xE3, 0xC2, 0xDF, + 0xC9, 0x92, 0x88, 0x85, 0xCA, 0x9B, 0xD9, 0xA1, 0xA1, 0xDD, 0xFA, 0xF6, + 0xBE, 0x06, 0x7B, 0x15, 0xC6, 0x23, 0x1F, 0x1D, 0xFF, 0x35, 0xBA, 0x31, + 0x2E, 0x3A, 0x35, 0x2B, 0x96, 0x44, 0x6E, 0x3C, 0x14, 0x1D, 0x93, 0x22, + 0x9B, 0xFF, 0x20, 0x07, 0xE4, 0x13, 0x69, 0x27, 0xE0, 0x0D, 0xE6, 0x09, + 0xA5, 0xC4, 0x2F, 0xB3, 0x0C, 0x96, 0xDA, 0x92, 0x3A, 0xB2, 0xD4, 0xC2, + 0x28, 0xF4, 0x0C, 0x07, 0x26, 0x24, 0xF3, 0x18, 0xD2, 0x24, 0xF5, 0x18, + 0x0F, 0x34, 0x45, 0x32, 0x01, 0x4B, 0xAD, 0x46, 0x66, 0x2C, 0xB6, 0x24, + 0x56, 0xEF, 0x49, 0xF5, 0x8A, 0xEC, 0x98, 0x07, 0x49, 0x0A, 0x09, 0x23, + 0x06, 0xE6, 0x07, 0xDC, 0xC0, 0xA9, 0x51, 0x94, 0x33, 0x9F, 0x38, 0xAB, + 0xFA, 0xEA, 0x27, 0xFB, 0xC0, 0x21, 0x09, 0x21, 0x39, 0x2F, 0x32, 0x32, + 0xA3, 0x51, 0x47, 0x51, 0xF0, 0x5E, 0x6D, 0x55, 0x2B, 0x3D, 0xA1, 0x36, + 0x63, 0xEF, 0xC6, 0xF2, 0x68, 0xE1, 0x79, 0xF8, 0x9C, 0xFF, 0x45, 0x15, + 0xDF, 0xF8, 0xA6, 0xF4, 0x5D, 0xCA, 0xC6, 0xC4, 0x6A, 0xA2, 0xAC, 0xAB, + 0x92, 0xDC, 0x60, 0xE4, 0x1B, 0x0A, 0xCD, 0x0E, 0x0A, 0x3E, 0xB9, 0x34, + 0x61, 0x63, 0x7C, 0x5A, 0xB9, 0x50, 0xF7, 0x43, 0xAD, 0x46, 0x22, 0x31, + 0xFE, 0xFA, 0x71, 0xE6, 0x7B, 0xD0, 0x9E, 0xD4, 0x49, 0xC1, 0x9D, 0xD7, + 0xEC, 0x00, 0x8B, 0x09, 0x19, 0xF7, 0xFA, 0xF6, 0xEC, 0xBB, 0x28, 0xC4, + 0x5B, 0xD8, 0x69, 0xE6, 0x24, 0x0E, 0xFD, 0x0F, 0xCD, 0x52, 0xEE, 0x5B, + 0x62, 0x39, 0x02, 0x3C, 0x56, 0x3E, 0x5E, 0x40, 0x53, 0x4C, 0x77, 0x43, + 0x63, 0x32, 0xD1, 0x1C, 0xBB, 0xDA, 0x19, 0xCF, 0x97, 0xA2, 0xF0, 0xAF, + 0xE7, 0xD0, 0x02, 0xE7, 0x88, 0xDC, 0x46, 0xEF, 0x98, 0xD1, 0xE0, 0xE2, + 0x5F, 0xE3, 0x63, 0xE9, 0x8C, 0x14, 0x8A, 0x1F, 0x73, 0x30, 0xC0, 0x37, + 0x1E, 0x2E, 0x24, 0x37, 0xD8, 0x3A, 0xDB, 0x38, 0x89, 0x43, 0x27, 0x3D, + 0x6B, 0x45, 0x6D, 0x3D, 0x58, 0xF3, 0xEE, 0xDC, 0x65, 0xB0, 0x08, 0x98, + 0x31, 0xA9, 0xC1, 0xB9, 0xF7, 0xCB, 0x26, 0xF3, 0x76, 0xE3, 0x84, 0xE5, + 0x0C, 0xEE, 0x13, 0xDE, 0xCD, 0x29, 0x22, 0x24, 0xCB, 0x27, 0x4D, 0x2C, + 0x3D, 0x37, 0x7F, 0x1F, 0x46, 0x1A, 0xE8, 0xFB, 0x24, 0x27, 0xFF, 0x27, + 0xFC, 0x4D, 0xBC, 0x55, 0x16, 0x19, 0x11, 0x06, 0xDA, 0xC1, 0xC8, 0xAB, + 0x81, 0xB3, 0x2C, 0xBA, 0x00, 0xDB, 0xAA, 0xEC, 0x54, 0xE4, 0xCB, 0xF3, + 0x7B, 0x04, 0x56, 0x06, 0x08, 0x0D, 0x7A, 0x0E, 0xD1, 0x26, 0x2C, 0x37, + 0x35, 0x46, 0x71, 0x3F, 0x4F, 0x1C, 0x75, 0x00, 0x70, 0x0E, 0xC2, 0x0F, + 0xF4, 0x24, 0xA2, 0x45, 0x35, 0x24, 0x36, 0x2B, 0x01, 0xF1, 0xC9, 0xCF, + 0xBD, 0xB1, 0xC7, 0xAF, 0x44, 0xB2, 0xF5, 0xC8, 0x09, 0xCA, 0x6E, 0xDD, + 0x5D, 0x0D, 0x3F, 0x04, 0x47, 0x1B, 0x3C, 0x18, 0xA6, 0x2A, 0xCD, 0x4A, + 0x3C, 0x4C, 0xC3, 0x47, 0xE8, 0x34, 0x62, 0x13, 0x9E, 0x06, 0x3F, 0x01, + 0x7C, 0x03, 0x45, 0x15, 0xE5, 0x13, 0x1F, 0x09, 0x2C, 0xED, 0xA6, 0xD3, + 0x59, 0xB3, 0xDB, 0xB1, 0xE4, 0xA3, 0xF7, 0xA7, 0xE6, 0xDF, 0x48, 0xCC, + 0xBD, 0x07, 0x2B, 0xEC, 0x2F, 0xFD, 0xC8, 0x03, 0xBA, 0x0F, 0xAD, 0x36, + 0xC3, 0x49, 0xFF, 0x4F, 0xF1, 0x4F, 0x40, 0x38, 0x2F, 0x15, 0x55, 0x0D, + 0xAD, 0xFF, 0x31, 0x13, 0x1F, 0x0C, 0xCC, 0x11, 0x22, 0xFF, 0x2B, 0xEE, + 0x9F, 0xD0, 0x49, 0xC8, 0xE0, 0x95, 0x12, 0x96, 0x5E, 0xC7, 0x42, 0xCA, + 0x74, 0x01, 0xB3, 0xF8, 0x1E, 0xFD, 0xF0, 0x0D, 0x19, 0x0A, 0xEE, 0x27, + 0xF6, 0x4E, 0xE3, 0x51, 0x47, 0x5A, 0x61, 0x49, 0x14, 0x1F, 0x54, 0x1B, + 0x3C, 0xE5, 0x1A, 0xE5, 0x11, 0xEF, 0xEA, 0xE4, 0x5F, 0xF0, 0x12, 0xEE, + 0x82, 0xBC, 0x14, 0xC4, 0x68, 0xBD, 0x20, 0xCD, 0xCB, 0xC5, 0x3D, 0xC2, + 0xE6, 0xF2, 0x4E, 0xF1, 0xAF, 0xFA, 0xCA, 0x11, 0x8C, 0x15, 0x24, 0x26, + 0x3F, 0x36, 0xD4, 0x31, 0xB5, 0x52, 0x56, 0x47, 0x75, 0x3E, 0x76, 0x26, + 0x4B, 0xF1, 0xAF, 0xCD, 0xB0, 0xDC, 0xCF, 0xC9, 0x59, 0xCE, 0x9E, 0xCE, + 0x09, 0xD6, 0x6D, 0xDF, 0x38, 0xD6, 0xF0, 0xE0, 0x73, 0xD9, 0x88, 0xD0, + 0x2B, 0xFE, 0x48, 0xF3, 0xAD, 0x0B, 0xFB, 0x0E, 0x8D, 0x13, 0x4A, 0x16, + 0x5E, 0x17, 0xBD, 0x23, 0x29, 0x4B, 0xEF, 0x5C, 0x4C, 0x55, 0x23, 0x52, + 0xF0, 0x09, 0xFB, 0xE9, 0x40, 0xD5, 0x4F, 0xC2, 0x63, 0xB7, 0x7E, 0xC0, + 0x65, 0xD1, 0xC0, 0xEB, 0x08, 0xD2, 0xD9, 0xDD, 0xA9, 0xCE, 0x30, 0xC4, + 0xF5, 0xE0, 0x2C, 0xE7, 0x95, 0x0F, 0xF4, 0x19, 0x62, 0x27, 0xBF, 0x17, + 0xD1, 0x13, 0x09, 0x11, 0x89, 0x33, 0x85, 0x56, 0x04, 0x56, 0x6A, 0x58, + 0xB0, 0x29, 0xF1, 0x0D, 0xDE, 0xD9, 0xE3, 0xB4, 0xE3, 0xB1, 0x8D, 0xA5, + 0x39, 0xBB, 0xC8, 0xD3, 0xE2, 0xDF, 0xA9, 0xE2, 0x02, 0xDF, 0x29, 0xD8, + 0xEC, 0xD5, 0x70, 0xEC, 0x0F, 0x15, 0xB8, 0x23, 0x60, 0x43, 0xFF, 0x20, + 0x95, 0x27, 0x16, 0x05, 0xDB, 0x21, 0x26, 0x26, 0x23, 0x3B, 0xB0, 0x3C, + 0x27, 0x1D, 0x25, 0x02, 0x7A, 0xE5, 0xF0, 0xC6, 0x57, 0xCB, 0xFE, 0xBB, + 0xF8, 0xBC, 0x05, 0xC6, 0xF0, 0xD3, 0xB7, 0xD0, 0xCF, 0xCD, 0x4C, 0xD0, + 0xAD, 0xD8, 0x89, 0xF5, 0x78, 0x1C, 0x56, 0x32, 0x6B, 0x4E, 0x0F, 0x38, + 0xD5, 0x33, 0x21, 0x19, 0xA3, 0x1D, 0x8F, 0x2B, 0xF5, 0x22, 0xDD, 0x2C, + 0xA2, 0x1A, 0x3B, 0x1F, 0x3B, 0x0D, 0x56, 0x01, 0x9B, 0xCD, 0x1F, 0xCC, + 0x88, 0xA3, 0xE6, 0xAE, 0x16, 0xBC, 0x22, 0xAE, 0x2D, 0xCE, 0xB6, 0xC1, + 0x5C, 0xC8, 0x33, 0xE8, 0xA8, 0x05, 0x50, 0x31, 0x8B, 0x58, 0xC2, 0x54, + 0x1F, 0x59, 0xA1, 0x45, 0x7E, 0x34, 0x38, 0x2E, 0xBF, 0x1B, 0x62, 0x1E, + 0x5B, 0x07, 0x95, 0x07, 0x16, 0x1A, 0x0D, 0x1B, 0x81, 0xEA, 0xF4, 0xEE, + 0x34, 0xC1, 0x2E, 0xB7, 0x17, 0xC9, 0xBC, 0xA7, 0xA2, 0xD5, 0xC7, 0xC6, + 0xBF, 0xD4, 0xB9, 0xE7, 0x78, 0xF8, 0x3B, 0x07, 0x6C, 0x3E, 0xFD, 0x40, + 0x6B, 0x4F, 0xB7, 0x48, 0x62, 0x52, 0x14, 0x3F, 0x35, 0x19, 0x7D, 0xFA, + 0x6F, 0xF9, 0x1D, 0xEA, 0x31, 0xF7, 0x9C, 0x0C, 0x0D, 0xEF, 0x24, 0x11, + 0xFC, 0xD0, 0x64, 0xD9, 0x35, 0xD4, 0x64, 0xC7, 0x6E, 0xDE, 0xD2, 0xCB, + 0x1F, 0xE9, 0xA4, 0xDA, 0x50, 0xEC, 0xF1, 0xF4, 0x17, 0x18, 0x6B, 0x3A, + 0x40, 0x4C, 0xD8, 0x5A, 0xCA, 0x3D, 0x07, 0x2C, 0xE5, 0x1E, 0xAC, 0x02, + 0x6A, 0xE9, 0xF9, 0xE2, 0x32, 0xE8, 0x42, 0x00, 0xC3, 0xE9, 0x54, 0xFE, + 0x04, 0xD4, 0x21, 0xE1, 0x38, 0xD0, 0x97, 0xD7, 0xC2, 0xED, 0x43, 0xE6, + 0xD5, 0x08, 0xFD, 0xEF, 0x3F, 0xFA, 0xCF, 0xF5, 0x73, 0x14, 0xFD, 0x22, + 0xA6, 0x47, 0x0F, 0x65, 0xFC, 0x42, 0x58, 0x53, 0x81, 0x2F, 0xA7, 0x14, + 0x24, 0xF4, 0xBA, 0xCE, 0xC6, 0xE8, 0x32, 0xD4, 0x11, 0xE7, 0xA6, 0xE1, + 0x06, 0xE0, 0xD7, 0xE5, 0xE4, 0xCF, 0x0E, 0xE6, 0xF4, 0xF2, 0xD2, 0x03, + 0x1F, 0x18, 0xB2, 0x0D, 0x1D, 0x1D, 0x1A, 0x0D, 0x91, 0x33, 0x1C, 0x42, + 0x05, 0x18, 0xAD, 0x37, 0x83, 0x34, 0x27, 0x57, 0xC1, 0x39, 0x28, 0x38, + 0xB8, 0x1A, 0xC6, 0x02, 0xB8, 0xE8, 0x06, 0xD0, 0xC9, 0xD4, 0x1A, 0xC6, + 0x60, 0xC8, 0xEE, 0xCB, 0x31, 0xB8, 0x81, 0xD3, 0xAE, 0xD8, 0x87, 0xF9, + 0x5A, 0x0C, 0xBD, 0x07, 0x6F, 0x23, 0x40, 0x1B, 0xF3, 0x17, 0x85, 0x11, + 0x71, 0x0B, 0xE9, 0x17, 0xE7, 0x18, 0x1F, 0x34, 0xB7, 0x2C, 0x4C, 0x3C, + 0xC6, 0x1D, 0x71, 0x17, 0x78, 0xF3, 0x6F, 0xE6, 0xE5, 0xDF, 0xDF, 0xCD, + 0x12, 0xDE, 0xC7, 0xC9, 0x63, 0xC6, 0x61, 0xC4, 0xCD, 0xCC, 0xD0, 0xE4, + 0x4A, 0xF7, 0x8F, 0x05, 0x85, 0x2D, 0x22, 0x1C, 0x69, 0x3F, 0xE8, 0x22, + 0x74, 0x2B, 0x08, 0x16, 0x1E, 0x19, 0xAE, 0x2B, 0xF0, 0x2D, 0x43, 0x4B, + 0x35, 0x2C, 0xA5, 0x37, 0xC2, 0xFB, 0x3E, 0xF1, 0x40, 0xDB, 0x7A, 0xCA, + 0xFA, 0xDC, 0xA4, 0xBF, 0xE2, 0xCD, 0xB6, 0xB8, 0x1E, 0xD9, 0x1B, 0xD9, + 0xB8, 0xF1, 0x9E, 0x03, 0x91, 0x13, 0xCB, 0x29, 0x45, 0x4F, 0x68, 0x44, + 0x57, 0x3D, 0x88, 0x1E, 0x85, 0x22, 0x29, 0x11, 0xEC, 0x1A, 0x67, 0x28, + 0xD9, 0x1C, 0xF6, 0x33, 0x36, 0xE3, 0x4C, 0xFB, 0xF6, 0xC2, 0xF9, 0xD5, + 0x88, 0xCC, 0xFA, 0xC3, 0x31, 0xC8, 0x35, 0xB8, 0x71, 0xCE, 0xFF, 0xE1, + 0x12, 0xC8, 0xA1, 0xEB, 0x40, 0x01, 0x1E, 0x27, 0x0F, 0x3E, 0x52, 0x4C, + 0xF0, 0x49, 0x53, 0x31, 0x22, 0x25, 0xD6, 0x08, 0x42, 0x16, 0x3B, 0x13, + 0x8C, 0x0D, 0x98, 0x1F, 0x75, 0xEA, 0x9F, 0x04, 0x37, 0xCC, 0xC2, 0xE6, + 0xDA, 0xDC, 0x8F, 0xD4, 0x46, 0xDB, 0x32, 0xC7, 0x28, 0xCF, 0xFD, 0xBA, + 0x47, 0xE3, 0x30, 0xD6, 0xD3, 0xF8, 0xEC, 0x13, 0x54, 0x2D, 0x30, 0x57, + 0x7B, 0x46, 0xD8, 0x52, 0x3E, 0x31, 0x40, 0x1D, 0x22, 0x24, 0xF2, 0x0F, + 0xF1, 0x19, 0x48, 0x08, 0xE3, 0xFC, 0xF1, 0xF6, 0xCC, 0xD9, 0x44, 0xE0, + 0x16, 0xB6, 0xFD, 0xB2, 0x16, 0xDC, 0x2D, 0xCF, 0x18, 0xEE, 0x9A, 0xD9, + 0xAB, 0xEF, 0xCD, 0xD1, 0x93, 0xEE, 0x32, 0xF5, 0xDF, 0x09, 0x53, 0x39, + 0x4C, 0x39, 0x1F, 0x61, 0xE9, 0x3F, 0x8A, 0x46, 0xE1, 0x23, 0x36, 0x1A, + 0x07, 0xFF, 0x35, 0xEF, 0xEB, 0xE6, 0xD7, 0xD8, 0x13, 0xB8, 0xB9, 0xC2, + 0x65, 0xB5, 0x18, 0xC0, 0xE5, 0xC0, 0x8F, 0xD7, 0xFA, 0xE4, 0xA7, 0xE6, + 0x59, 0x06, 0xDB, 0xE2, 0x86, 0xFC, 0x57, 0xE7, 0x2F, 0x0D, 0x54, 0x20, + 0x57, 0x2E, 0xAA, 0x4A, 0x68, 0x41, 0x71, 0x53, 0x96, 0x22, 0xCB, 0x2A, + 0x0C, 0xFC, 0x54, 0xFB, 0x47, 0xF2, 0x01, 0xDF, 0xB3, 0xBE, 0x75, 0xAE, + 0x32, 0xC6, 0xCC, 0xD7, 0x3F, 0xC7, 0xEB, 0xE1, 0x59, 0xDC, 0x56, 0xEA, + 0x2B, 0x04, 0x71, 0xE3, 0x1B, 0x06, 0x5C, 0xDE, 0xAA, 0x0F, 0x02, 0x08, + 0x7D, 0x27, 0x7B, 0x38, 0xA7, 0x4A, 0xBB, 0x61, 0xE6, 0x24, 0xD7, 0x3A, + 0xA3, 0x11, 0xAD, 0x17, 0xDB, 0xE7, 0x6A, 0xDA, 0x39, 0xDC, 0x45, 0xBE, + 0xE9, 0xD6, 0xDB, 0xBE, 0x1A, 0xB1, 0x14, 0xC4, 0x75, 0xC7, 0xD2, 0xEA, + 0x66, 0xEA, 0x3D, 0xF9, 0xF0, 0x0E, 0x06, 0x01, 0x49, 0x0F, 0x60, 0xFE, + 0x6B, 0x31, 0x4A, 0x2B, 0xF5, 0x49, 0xCB, 0x4E, 0xA8, 0x28, 0x9E, 0x3B, + 0x0E, 0x08, 0x78, 0x11, 0x20, 0xCF, 0x96, 0xC1, 0x08, 0xD5, 0x30, 0xBC, + 0x12, 0xD1, 0x93, 0xAD, 0x6C, 0xB8, 0x55, 0xAD, 0x6C, 0xC1, 0xFF, 0xD6, + 0x99, 0xF9, 0x85, 0x12, 0xDB, 0x2A, 0xEB, 0x31, 0x8D, 0x26, 0x44, 0x14, + 0xC3, 0x2F, 0x8E, 0x1E, 0x5A, 0x36, 0x87, 0x2F, 0x0A, 0x35, 0xDA, 0x3F, + 0x1A, 0x04, 0x4D, 0x13, 0xFC, 0xEB, 0x9A, 0xF8, 0xAE, 0xE3, 0xB7, 0xE5, + 0x44, 0xE4, 0x01, 0xC9, 0x65, 0xDB, 0x58, 0xB4, 0x86, 0xD5, 0x3B, 0xC0, + 0xD1, 0xF7, 0x9B, 0x07, 0xDF, 0x17, 0x45, 0x30, 0x2B, 0x23, 0xE9, 0x2A, + 0x30, 0x27, 0xEC, 0x1D, 0x6B, 0x2D, 0xC8, 0x22, 0x82, 0x24, 0xEF, 0x27, + 0x26, 0x1A, 0x67, 0x26, 0x6B, 0xF9, 0xF7, 0x05, 0xC8, 0xE4, 0x2F, 0xFC, + 0xAB, 0xDF, 0x73, 0xE2, 0x58, 0xD8, 0x5A, 0xB2, 0x0A, 0xC7, 0x54, 0xA3, + 0x3F, 0xD3, 0xB2, 0xDF, 0xE7, 0xFC, 0x17, 0x1D, 0x69, 0x20, 0x49, 0x30, + 0x01, 0x23, 0x69, 0x2E, 0x07, 0x25, 0xF4, 0x21, 0x81, 0x2D, 0xDD, 0x1F, + 0x85, 0x1D, 0x75, 0x03, 0x9E, 0xFE, 0x95, 0xFB, 0x68, 0xDE, 0xBF, 0xFE, + 0xC1, 0xDC, 0x18, 0xF7, 0x48, 0xE5, 0x95, 0xD6, 0x9F, 0xE1, 0xCD, 0xBE, + 0x06, 0xE9, 0x3F, 0xD7, 0xF9, 0x07, 0xE1, 0x0F, 0xFA, 0x32, 0xD7, 0x41, + 0x2A, 0x40, 0x30, 0x4B, 0x9A, 0x33, 0xCE, 0x30, 0x8F, 0x29, 0xC2, 0x13, + 0xDA, 0x15, 0x12, 0xFB, 0xDE, 0x07, 0xA7, 0xEB, 0xB2, 0xE7, 0x38, 0xEE, + 0x9E, 0xE1, 0x65, 0x00, 0xE2, 0xED, 0x9B, 0xF5, 0x53, 0xF6, 0xF8, 0xD8, + 0x7D, 0xF5, 0x07, 0xDC, 0x79, 0x02, 0xFF, 0xFC, 0xA2, 0x2A, 0xAE, 0x35, + 0x4E, 0x37, 0x1D, 0x4A, 0x0C, 0x2C, 0x94, 0x3C, 0x83, 0x13, 0x58, 0x21, + 0xDD, 0x08, 0x18, 0xF8, 0x44, 0xF4, 0xB0, 0xD1, 0x45, 0xD7, 0x9D, 0xC2, + 0x57, 0xD4, 0x18, 0xDE, 0x4A, 0xDB, 0x92, 0xEF, 0x25, 0xE5, 0x80, 0xEA, + 0x4F, 0xED, 0x1D, 0xE6, 0xCB, 0x04, 0xE3, 0x01, 0x37, 0x30, 0xC4, 0x40, + 0x7B, 0x38, 0x87, 0x52, 0xD3, 0x2E, 0xCD, 0x47, 0xBE, 0x19, 0xB4, 0x2A, + 0xE6, 0x0D, 0x13, 0x0B, 0xE5, 0x01, 0x27, 0xDF, 0xEF, 0xE2, 0xB3, 0xB5, + 0x24, 0xD5, 0x39, 0xC4, 0x93, 0xCD, 0x39, 0xE2, 0xE7, 0xF3, 0x4E, 0x0B, + 0x9C, 0x01, 0x28, 0x01, 0xA1, 0x1B, 0xC2, 0x0B, 0x23, 0x3F, 0xCE, 0x39, + 0x54, 0x36, 0xD8, 0x3B, 0x79, 0x37, 0xED, 0x3C, 0xF4, 0x23, 0x57, 0x2D, + 0xC6, 0x15, 0xBA, 0x1E, 0x4C, 0xF3, 0xD2, 0xE7, 0xA6, 0xE7, 0x27, 0xB9, + 0xA6, 0xCF, 0xEB, 0xA3, 0xBF, 0xCA, 0x9E, 0xCA, 0x8A, 0xE8, 0x80, 0x01, + 0x67, 0x0A, 0x9F, 0x0B, 0x12, 0x31, 0x2E, 0x29, 0xFC, 0x1E, 0x4B, 0x16, + 0x75, 0x1E, 0x8F, 0x20, 0x38, 0x1A, 0xA8, 0x1A, 0x17, 0x1D, 0x81, 0x1D, + 0xB5, 0x16, 0x16, 0x31, 0x3F, 0xF6, 0x03, 0x0B, 0x60, 0xEC, 0x09, 0xD2, + 0xE8, 0xC6, 0x86, 0x8D, 0x5B, 0xC2, 0x11, 0xB1, 0x18, 0xD0, 0xB7, 0xDE, + 0xB3, 0xF4, 0xE1, 0x08, 0x6C, 0x1F, 0x56, 0x27, 0x2C, 0x1E, 0x54, 0x22, + 0xE4, 0x2C, 0xE3, 0x31, 0x20, 0x26, 0xF8, 0x1E, 0x10, 0x2E, 0x2E, 0x1F, + 0x8C, 0x14, 0xEB, 0x1F, 0x80, 0x0F, 0xD6, 0x2D, 0x32, 0xFD, 0x13, 0xFD, + 0xE0, 0xDB, 0x5B, 0xB6, 0xA3, 0xBF, 0xE3, 0x9E, 0x62, 0xC6, 0x92, 0xC7, + 0x40, 0x00, 0x19, 0x12, 0xCA, 0x06, 0xC4, 0x1C, 0x2B, 0x2E, 0xCD, 0x3C, + 0xDC, 0x36, 0x02, 0x44, 0x0D, 0x3D, 0x2E, 0x31, 0x24, 0x36, 0x01, 0x15, + 0x9B, 0x13, 0xE8, 0x05, 0xD6, 0x04, 0x3C, 0x1C, 0xFC, 0xED, 0x54, 0x04, + 0x00, 0xD8, 0x0D, 0xD2, 0x73, 0xB7, 0x07, 0xA3, 0x95, 0xBB, 0x34, 0xB3, + 0x55, 0xDA, 0xA3, 0xE6, 0x17, 0xF5, 0x14, 0x01, 0x3A, 0x1F, 0x88, 0x37, + 0x62, 0x2F, 0xC5, 0x4E, 0x7F, 0x38, 0xAD, 0x41, 0x3E, 0x21, 0xE1, 0x05, + 0x58, 0x01, 0xB7, 0xE5, 0x60, 0xEC, 0xCB, 0xEB, 0xC5, 0xE9, 0x56, 0xF9, + 0x35, 0xDE, 0xDB, 0xE7, 0x95, 0xC4, 0x58, 0xBD, 0xFD, 0xD5, 0x57, 0xCB, + 0xA0, 0xDF, 0xCD, 0xD5, 0x2C, 0x01, 0xF8, 0xFE, 0x3A, 0x1F, 0x54, 0x2D, + 0x81, 0x37, 0x00, 0x59, 0x37, 0x40, 0xCA, 0x5C, 0xA2, 0x28, 0x5D, 0x25, + 0x5A, 0x02, 0x33, 0xE1, 0x0B, 0xE8, 0xA2, 0xC7, 0x77, 0xE3, 0x04, 0xE3, + 0xA7, 0xD8, 0x60, 0xE2, 0xB2, 0xE0, 0xDB, 0xDF, 0x7D, 0xF1, 0x6C, 0xEB, + 0xCE, 0xF2, 0xB7, 0xE6, 0xD0, 0xFF, 0x62, 0xF2, 0x7B, 0x14, 0x5A, 0x0C, + 0xDA, 0x29, 0x9E, 0x36, 0xE7, 0x30, 0x32, 0x50, 0x32, 0x20, 0x59, 0x38, + 0xD7, 0xFB, 0xFF, 0xEE, 0xFA, 0xDA, 0xAB, 0xB5, 0x33, 0xC3, 0x8B, 0xB4, + 0x44, 0xC7, 0x56, 0xCC, 0x83, 0xE6, 0x34, 0xF8, 0x63, 0xEF, 0xA0, 0xFB, + 0x92, 0xF6, 0x0B, 0xF5, 0x8D, 0xF3, 0x00, 0xEC, 0xD4, 0xFC, 0xBB, 0xED, + 0xC3, 0x0B, 0x62, 0x01, 0xF1, 0x24, 0x6A, 0x35, 0x46, 0x1A, 0x67, 0x46, + 0x64, 0x02, 0x50, 0x14, 0xA3, 0xE4, 0x53, 0xCD, 0xEC, 0xCC, 0xFC, 0xB1, + 0x6A, 0xD9, 0x33, 0xD6, 0x7C, 0xE1, 0x59, 0xEE, 0xE2, 0xFD, 0x20, 0x07, + 0x8D, 0x08, 0xF0, 0x0B, 0x42, 0x0F, 0x37, 0x12, 0x4B, 0x04, 0x8E, 0xFD, + 0xF5, 0x09, 0xE8, 0xF2, 0x33, 0x1C, 0xD8, 0x1A, 0xA3, 0x1E, 0x7E, 0x43, + 0x39, 0x1D, 0x5E, 0x37, 0x9E, 0xF5, 0x3D, 0xEC, 0xF9, 0xD7, 0xE4, 0xB7, + 0x28, 0xD0, 0x19, 0xB3, 0xCE, 0xCF, 0x1F, 0xCB, 0x66, 0xE9, 0x11, 0xF1, + 0xFF, 0xFD, 0x24, 0x0D, 0xE6, 0x0E, 0x1F, 0x27, 0xF3, 0x0A, 0xC9, 0x16, + 0xE9, 0x12, 0xA9, 0xFE, 0x42, 0x16, 0xF9, 0xF6, 0x16, 0x13, 0xEB, 0x0E, + 0x29, 0x13, 0x09, 0x2A, 0xA6, 0xE8, 0xD3, 0xEE, 0x46, 0xD9, 0x48, 0xC7, + 0xAF, 0xBF, 0x7B, 0xAC, 0xB7, 0xB8, 0xDB, 0xAB, 0x5F, 0xC8, 0x9A, 0xC2, + 0x46, 0xED, 0x10, 0xF2, 0x04, 0x11, 0x0A, 0x2F, 0xB5, 0x1F, 0x75, 0x44, + 0x14, 0x2D, 0x95, 0x2F, 0xBF, 0x26, 0x7B, 0x01, 0x0C, 0x25, 0x13, 0x13, + 0xEE, 0x08, 0x4C, 0x17, 0x19, 0xFF, 0x78, 0x16, 0x31, 0xEF, 0x7A, 0x01, + 0xE6, 0xD3, 0x1A, 0xCF, 0xBF, 0xC0, 0x7C, 0xB8, 0x13, 0xBB, 0x1A, 0xA8, + 0x66, 0xE6, 0x3E, 0xD5, 0x41, 0x18, 0x32, 0x21, 0xE0, 0x45, 0x18, 0x69, + 0xD2, 0x4B, 0xD0, 0x67, 0x9E, 0x3C, 0x3C, 0x35, 0x86, 0x2C, 0x22, 0x1E, + 0xF9, 0x0B, 0x5B, 0x06, 0x0A, 0xFB, 0x1E, 0x04, 0x93, 0xEA, 0x8D, 0xFC, + 0xA0, 0xE0, 0x68, 0xEA, 0xC8, 0xCC, 0x8E, 0xC9, 0xBF, 0xBD, 0xFC, 0xAD, + 0xAF, 0xCB, 0x35, 0xB6, 0xB1, 0xF2, 0x63, 0xE8, 0x3B, 0x28, 0x69, 0x3D, + 0x0A, 0x44, 0x3A, 0x69, 0x22, 0x3C, 0x72, 0x45, 0x1C, 0x16, 0x8A, 0x05, + 0xFF, 0xF4, 0x39, 0xDC, 0x7A, 0xE1, 0x32, 0xD2, 0xB6, 0xDF, 0x81, 0xE4, + 0x56, 0xE5, 0x99, 0xF0, 0x6F, 0xD9, 0x5C, 0xE3, 0x17, 0xD2, 0xE7, 0xD2, + 0x50, 0xD6, 0xA5, 0xC7, 0x9F, 0xF5, 0xAD, 0xDB, 0x97, 0x1F, 0xB0, 0x1B, + 0x15, 0x46, 0x0E, 0x67, 0x6F, 0x42, 0x2D, 0x5C, 0x8A, 0x1E, 0xA9, 0x1F, + 0xE7, 0x0A, 0x66, 0xF7, 0x5E, 0xE9, 0xFC, 0xC9, 0x93, 0xE1, 0x82, 0xCE, + 0x8F, 0xE9, 0x50, 0xE7, 0x01, 0xFA, 0xB1, 0x05, 0xF4, 0xFC, 0xEC, 0x10, + 0x04, 0xF7, 0x4C, 0x00, 0x6B, 0xF9, 0xA6, 0xE6, 0x8E, 0x15, 0x10, 0x02, + 0x41, 0x3E, 0x2C, 0x48, 0x1D, 0x3B, 0x07, 0x60, 0x49, 0x34, 0x22, 0x57, + 0x01, 0x16, 0x34, 0x12, 0xB9, 0xEB, 0xDA, 0xC4, 0xA7, 0xCF, 0xD7, 0xA7, + 0x74, 0xCC, 0xBA, 0xB2, 0xF3, 0xE5, 0x3F, 0xDD, 0xF3, 0xFF, 0x1E, 0x11, + 0xAE, 0x06, 0xDA, 0x2A, 0xA6, 0xF9, 0x1C, 0x07, 0x0E, 0x03, 0x1D, 0xF6, + 0xBA, 0x22, 0x83, 0x2A, 0x3F, 0x2C, 0x9F, 0x4A, 0x83, 0x25, 0x5D, 0x48, + 0x8C, 0x19, 0x37, 0x25, 0x35, 0xFD, 0xBF, 0xEB, 0xAC, 0xD0, 0x9E, 0xB9, + 0x19, 0xBF, 0xFB, 0xA6, 0xF3, 0xCB, 0x0F, 0xB1, 0x7E, 0xF7, 0x9C, 0xF5, + 0x3D, 0x11, 0x10, 0x35, 0x7A, 0x16, 0x04, 0x2F, 0xFD, 0x29, 0x93, 0x27, + 0xDB, 0x1E, 0x23, 0x09, 0xD1, 0x1E, 0x81, 0x0B, 0x09, 0x21, 0xB2, 0x30, + 0x1B, 0x2B, 0xD9, 0x44, 0x00, 0x1D, 0xCD, 0x2C, 0x37, 0xF3, 0x5A, 0xF6, + 0x6C, 0xC6, 0x24, 0xBC, 0xCA, 0xBE, 0xF4, 0x99, 0xD4, 0xE8, 0x89, 0xC7, + 0x0E, 0x0A, 0x80, 0x13, 0x75, 0x26, 0xC5, 0x33, 0x7D, 0x2A, 0x0B, 0x2F, + 0x28, 0x22, 0x78, 0x15, 0x6D, 0x0D, 0x18, 0xF1, 0xED, 0x06, 0xFD, 0xF9, + 0xA9, 0x07, 0x59, 0x13, 0x04, 0x04, 0x65, 0x17, 0xC4, 0xF1, 0x81, 0x06, + 0x5D, 0xCD, 0x73, 0xD7, 0xF2, 0xB7, 0x6D, 0xA3, 0x3D, 0xC9, 0xDF, 0xA5, + 0x29, 0xF7, 0xD2, 0xE8, 0x89, 0x23, 0x69, 0x3E, 0xB8, 0x36, 0xBD, 0x5F, + 0x7B, 0x32, 0x4A, 0x48, 0x37, 0x18, 0x0D, 0x0B, 0x11, 0x00, 0x71, 0xEC, + 0xF2, 0xF6, 0xAB, 0xF2, 0xE5, 0xF4, 0xE6, 0xFD, 0x3B, 0xF8, 0x03, 0x0A, + 0x3C, 0xE4, 0xF0, 0xF8, 0xAB, 0xD4, 0x73, 0xDA, 0xCF, 0xCB, 0x69, 0xAF, + 0x4F, 0xF8, 0x0A, 0xE9, 0x5A, 0x28, 0x7A, 0x36, 0x66, 0x41, 0x7E, 0x5E, + 0x8A, 0x49, 0x14, 0x70, 0x37, 0x3B, 0x0D, 0x4B, 0xAF, 0x20, 0xDB, 0x16, + 0x4C, 0xF8, 0xD0, 0xED, 0x45, 0xE6, 0x54, 0xDD, 0x05, 0xF4, 0xD6, 0xED, + 0x3E, 0xEF, 0xD8, 0xF6, 0xCB, 0xDB, 0x6D, 0xE6, 0xE9, 0xDA, 0xF8, 0xCC, + 0xB2, 0xD9, 0xD9, 0xB8, 0x66, 0xFC, 0xA9, 0xD8, 0xED, 0x28, 0x29, 0x28, + 0xDB, 0x46, 0x09, 0x75, 0x88, 0x48, 0x31, 0x71, 0xDA, 0x2E, 0xEA, 0x3A, + 0x87, 0xFA, 0x44, 0xEF, 0xDA, 0xD1, 0x6F, 0xB8, 0xD7, 0xC1, 0x8D, 0x9E, + 0x02, 0xD1, 0x2E, 0xC8, 0xE0, 0xD5, 0x55, 0xD8, 0x2B, 0xCD, 0x3A, 0xD1, + 0x14, 0xD6, 0x86, 0xD7, 0x87, 0xE8, 0xBA, 0xC6, 0x0A, 0x11, 0x63, 0xF4, + 0x66, 0x35, 0x87, 0x3D, 0x6D, 0x45, 0x85, 0x67, 0x7D, 0x48, 0x02, 0x60, + 0xDD, 0x1E, 0xAA, 0x27, 0xBE, 0xEB, 0xF9, 0xE7, 0xD7, 0xBF, 0xD8, 0xAC, + 0x63, 0xCC, 0x85, 0xC0, 0x79, 0xEF, 0xCC, 0xF8, 0xCB, 0xEB, 0xA4, 0x09, + 0xF8, 0x07, 0xB5, 0x20, 0xC9, 0x0C, 0x82, 0xFC, 0x29, 0x1D, 0xBA, 0xF7, + 0xC5, 0x1F, 0xD0, 0x10, 0x06, 0x33, 0xE9, 0x41, 0x5A, 0x3F, 0x57, 0x57, + 0xA9, 0x33, 0x63, 0x4B, 0xD3, 0x07, 0x81, 0x17, 0x3E, 0xC7, 0xA2, 0xB7, + 0x5B, 0xC2, 0xFF, 0xAC, 0x98, 0xD0, 0x8B, 0xBF, 0x7F, 0xEE, 0x42, 0xEE, + 0x03, 0x09, 0x61, 0x22, 0x8D, 0x0D, 0xA9, 0x16, 0xB1, 0x0D, 0x83, 0xF9, + 0xFA, 0x03, 0xE3, 0xE9, 0xD0, 0x0B, 0xA0, 0x04, 0x8B, 0x10, 0xE2, 0x15, + 0x09, 0x1F, 0xC7, 0x2C, 0x8C, 0x07, 0x74, 0x1B, 0xA2, 0xC4, 0x13, 0xC4, + 0xEC, 0xBB, 0xDD, 0x9C, 0xEC, 0xB2, 0x8D, 0x87, 0x67, 0xDB, 0x7F, 0xC1, + 0x04, 0x00, 0x13, 0x16, 0xBF, 0x1E, 0x02, 0x42, 0xB9, 0x27, 0xEA, 0x31, + 0x37, 0x22, 0x78, 0x11, 0x17, 0x16, 0x70, 0x03, 0x0C, 0x05, 0xAC, 0xF8, + 0xEF, 0x0E, 0xAB, 0x0D, 0x55, 0x07, 0x2F, 0x1F, 0xDA, 0xE8, 0x22, 0xEE, + 0xB0, 0xC5, 0xA9, 0xBE, 0xB4, 0xCF, 0x4F, 0xB6, 0x40, 0xDF, 0xA9, 0xB8, + 0x7F, 0xFB, 0x2F, 0xF3, 0xC5, 0x20, 0xF3, 0x3C, 0xD0, 0x2F, 0x82, 0x4C, + 0x90, 0x39, 0x0E, 0x44, 0x6A, 0x20, 0x7A, 0x1E, 0x6A, 0xFD, 0xE8, 0xF4, + 0x2B, 0xF6, 0x53, 0xEF, 0x81, 0xE7, 0xCC, 0xE9, 0xC5, 0xF0, 0xE8, 0x06, + 0xA7, 0xE7, 0x51, 0xFB, 0xBF, 0xD0, 0x7A, 0xC6, 0x49, 0xC0, 0x25, 0x92, + 0x43, 0xD2, 0x91, 0xAA, 0x2A, 0xF4, 0x41, 0xF7, 0x69, 0x16, 0x77, 0x34, + 0xAD, 0x34, 0xB1, 0x4E, 0x69, 0x2B, 0x4B, 0x3E, 0xAE, 0x09, 0xF0, 0x0B, + 0x0E, 0xEF, 0xC6, 0xED, 0x2A, 0xEA, 0x03, 0xE2, 0xB3, 0xE9, 0x39, 0xE3, + 0x6C, 0xF7, 0x61, 0x0F, 0x29, 0xEC, 0xA1, 0x07, 0x6A, 0xDA, 0xCC, 0xD1, + 0x74, 0xE1, 0x30, 0xBB, 0x49, 0xFB, 0x3D, 0xE6, 0xA5, 0x17, 0x04, 0x1D, + 0x62, 0x3B, 0xE8, 0x49, 0x29, 0x41, 0x29, 0x52, 0x8D, 0x27, 0x75, 0x34, + 0xD2, 0xFD, 0x51, 0xF1, 0xD4, 0xE4, 0x00, 0xCB, 0xAB, 0xE2, 0xE3, 0xC9, + 0xA6, 0xF3, 0xEA, 0xFB, 0x5B, 0xFE, 0x15, 0x22, 0x89, 0xF2, 0x46, 0x01, + 0x60, 0xF0, 0x0D, 0xDB, 0x7A, 0xEE, 0x1E, 0xCF, 0x18, 0x05, 0x91, 0xF6, + 0x7D, 0x19, 0x5D, 0x1C, 0xE3, 0x31, 0xE5, 0x47, 0x92, 0x22, 0x04, 0x31, + 0x3E, 0x00, 0x43, 0x02, 0x5F, 0xE4, 0xE1, 0xD9, 0x13, 0xC4, 0x32, 0xA2, + 0x24, 0xD2, 0xE7, 0xB6, 0x34, 0xE6, 0xCF, 0xF0, 0x1D, 0xF4, 0xB4, 0x0B, + 0x4F, 0xFD, 0x91, 0xFF, 0x40, 0xFE, 0xD7, 0xE9, 0x70, 0x01, 0x94, 0xF6, + 0xF1, 0x08, 0x2F, 0x0B, 0x9E, 0x22, 0xAD, 0x36, 0x7E, 0x2E, 0x45, 0x4E, + 0xD0, 0x25, 0x0D, 0x41, 0xFF, 0x01, 0x8C, 0x12, 0xA2, 0xD8, 0xF2, 0xBC, + 0x20, 0xCD, 0x70, 0xA0, 0x99, 0xDB, 0xF2, 0xC8, 0xE3, 0xF2, 0x10, 0x09, + 0xA4, 0x0B, 0x86, 0x22, 0x55, 0x24, 0xCE, 0x27, 0x75, 0x27, 0x3D, 0x20, + 0xAE, 0x2C, 0x67, 0x2D, 0x75, 0x23, 0x40, 0x32, 0x02, 0x20, 0x4C, 0x2A, + 0xEF, 0x2D, 0xC5, 0x48, 0xEB, 0x26, 0xC3, 0x4A, 0x2B, 0xFC, 0x5D, 0x04, + 0x3C, 0xDB, 0xA6, 0xB3, 0xF6, 0xC9, 0xD6, 0x9D, 0x01, 0xD4, 0x60, 0xCB, + 0xA3, 0xE4, 0x92, 0xF4, 0xF1, 0x0B, 0xA7, 0x14, 0xB2, 0x2A, 0x03, 0x27, + 0x85, 0x1B, 0xB2, 0x12, 0x4F, 0x18, 0x79, 0x0C, 0xF5, 0xFD, 0x5F, 0xF2, + 0x09, 0x06, 0xF6, 0x0A, 0x55, 0x07, 0x32, 0x2B, 0x4C, 0xF9, 0x05, 0x18, + 0xA3, 0xDF, 0xB2, 0xD0, 0x8B, 0xCB, 0xC7, 0x9B, 0x0D, 0xD1, 0x24, 0xB4, + 0x31, 0xDC, 0x00, 0xDC, 0x45, 0x0C, 0xD8, 0x1B, 0xDD, 0x25, 0x2C, 0x30, + 0x00, 0x32, 0xF4, 0x37, 0x6B, 0x23, 0x8C, 0x26, 0xDB, 0x04, 0x69, 0xF2, + 0xC3, 0x05, 0xF2, 0xF0, 0x3E, 0x00, 0x4F, 0x0C, 0x04, 0x02, 0x12, 0x2C, + 0xEF, 0xF2, 0x56, 0x06, 0x20, 0xF8, 0xAF, 0xE3, 0x89, 0xF1, 0x7F, 0xD5, + 0x9B, 0xF0, 0xC5, 0xE8, 0xFC, 0x17, 0x84, 0x27, 0xFF, 0x21, 0x42, 0x39, + 0xEA, 0x38, 0x4F, 0x51, 0xA4, 0x2E, 0x0F, 0x45, 0xB3, 0x1F, 0xB1, 0x1A, + 0xE9, 0x02, 0xE8, 0xE3, 0x9B, 0xF2, 0xD4, 0xE0, 0x38, 0xEE, 0x6E, 0x04, + 0x47, 0xE7, 0x3C, 0x05, 0xF0, 0xE8, 0xBF, 0xE9, 0x03, 0xE7, 0x88, 0xD3, + 0x97, 0xEB, 0x28, 0xD9, 0x19, 0xF4, 0x5F, 0xF6, 0x00, 0x11, 0x83, 0x17, + 0xDF, 0x10, 0x5D, 0x1F, 0xC7, 0x1F, 0x10, 0x3E, 0x1F, 0x22, 0x96, 0x34, + 0xC5, 0x06, 0x7B, 0xF0, 0xF0, 0xEC, 0xF5, 0xC7, 0x3F, 0xDA, 0x7E, 0xD2, + 0xFA, 0xD8, 0x2D, 0xEE, 0x64, 0xDB, 0x25, 0xEA, 0x0A, 0xE9, 0x1A, 0xE2, + 0x42, 0xF6, 0x23, 0xE8, 0x60, 0x02, 0x60, 0xEF, 0xA2, 0x0D, 0x05, 0x04, + 0xDA, 0x16, 0xB4, 0x1D, 0x85, 0x2B, 0xA9, 0x53, 0xF8, 0x31, 0x7C, 0x65, + 0xC4, 0x22, 0xA5, 0x31, 0xDA, 0x0D, 0xD8, 0xEC, 0x8D, 0xEB, 0x67, 0xCB, + 0xDC, 0xD6, 0xA4, 0xD8, 0x47, 0xDA, 0x3A, 0xE6, 0x0A, 0xEB, 0x2C, 0xEA, + 0xC4, 0x01, 0xA4, 0xF5, 0xB5, 0x13, 0xD6, 0x0D, 0xAE, 0x1C, 0x41, 0x0F, + 0xA0, 0x15, 0x64, 0x07, 0x1E, 0x17, 0x31, 0x25, 0xF0, 0x19, 0x9F, 0x4A, + 0xE0, 0x13, 0x66, 0x39, 0xB4, 0x01, 0x68, 0xFA, 0x36, 0xE8, 0x50, 0xC5, + 0x84, 0xDA, 0x97, 0xC2, 0x60, 0xCB, 0xE0, 0xC6, 0x49, 0xDB, 0x2C, 0xE0, + 0x92, 0xF2, 0x81, 0xFD, 0x57, 0x0A, 0x52, 0x12, 0x1A, 0x1D, 0xCA, 0x1A, + 0x60, 0x15, 0x94, 0xFE, 0xF4, 0x10, 0xEA, 0x02, 0x63, 0x04, 0xC6, 0x18, + 0xCB, 0xFC, 0x45, 0x2B, 0xB4, 0xF5, 0xEF, 0x0D, 0x5B, 0xEE, 0x5E, 0xDE, + 0x59, 0xE3, 0x75, 0xC6, 0x19, 0xDC, 0xDA, 0xCC, 0x16, 0xE4, 0x13, 0xE8, + 0x86, 0xF5, 0xAC, 0xFE, 0xF7, 0x14, 0x88, 0x25, 0xBB, 0x26, 0xBF, 0x37, + 0x75, 0x32, 0x6E, 0x2E, 0x02, 0x2B, 0xEE, 0x10, 0x70, 0x14, 0x66, 0x0B, + 0x87, 0xFC, 0xFB, 0x1E, 0x38, 0xF1, 0x10, 0x18, 0xC1, 0xEF, 0x2D, 0xEF, + 0x70, 0xE6, 0xA5, 0xCD, 0xAD, 0xE9, 0x29, 0xCE, 0xD7, 0xED, 0x0A, 0xDE, + 0x59, 0xF3, 0x22, 0xEC, 0xFD, 0x01, 0x0F, 0x0B, 0xD9, 0x13, 0x9A, 0x33, + 0x63, 0x20, 0x53, 0x37, 0x00, 0x26, 0xF4, 0x11, 0xDF, 0x17, 0x48, 0xF5, + 0xC3, 0x01, 0xE7, 0x01, 0x20, 0xE2, 0xD2, 0xFB, 0x4A, 0xD5, 0x32, 0xE2, + 0xDE, 0xD8, 0xC9, 0xC5, 0x39, 0xDD, 0xE5, 0xC3, 0xDF, 0xE9, 0x12, 0xD3, + 0xDC, 0xEA, 0x8A, 0xD4, 0xAC, 0xFB, 0x0B, 0xEF, 0x66, 0x05, 0xDD, 0x1D, + 0xDC, 0x16, 0xB6, 0x40, 0x86, 0x1F, 0x16, 0x2B, 0xBB, 0x23, 0x82, 0x07, + 0xD5, 0x15, 0xF2, 0x00, 0xDC, 0xF2, 0xE3, 0x00, 0x2C, 0xDF, 0xFA, 0xEE, + 0x71, 0xD3, 0x3A, 0xDD, 0xDE, 0xE6, 0x8A, 0xE5, 0xB2, 0xF5, 0xBF, 0xEE, + 0x6D, 0x0A, 0xD4, 0xF2, 0x55, 0x13, 0x7C, 0xF5, 0x1E, 0x13, 0x3B, 0x14, + 0x81, 0x16, 0x6E, 0x43, 0x26, 0x1A, 0x34, 0x43, 0x1C, 0x22, 0x5A, 0x22, + 0x67, 0x1C, 0x9B, 0x08, 0x3D, 0x06, 0x74, 0xFB, 0xDF, 0xEA, 0x60, 0xF4, + 0x16, 0xE4, 0xB2, 0xEB, 0x7D, 0xDF, 0x46, 0xE7, 0x94, 0xE2, 0xA3, 0xE7, + 0x64, 0xF8, 0xB3, 0xEA, 0x32, 0x02, 0x16, 0xDB, 0xA4, 0x0C, 0x57, 0xF2, + 0x47, 0x06, 0x1C, 0x1C, 0x4C, 0x01, 0x67, 0x30, 0xBE, 0x06, 0x35, 0x1A, + 0x0A, 0x05, 0x26, 0xF8, 0x45, 0x07, 0x96, 0xEF, 0xD3, 0xF4, 0x06, 0xDD, + 0x07, 0xE4, 0xEF, 0xD8, 0xE1, 0xCE, 0xC0, 0xCE, 0x6C, 0xD2, 0xC9, 0xE2, + 0x30, 0xE4, 0xDF, 0xF1, 0x6E, 0xFF, 0xD1, 0xF1, 0x95, 0x18, 0x9B, 0xF6, + 0x20, 0x24, 0x8D, 0x1B, 0x90, 0x16, 0xB4, 0x37, 0xD2, 0x07, 0x02, 0x2D, + 0x9E, 0x10, 0x6C, 0x14, 0x4A, 0x06, 0xF2, 0xEE, 0x0B, 0x05, 0xC7, 0xEB, + 0x3D, 0xFD, 0x6A, 0xED, 0x04, 0xED, 0xA2, 0xE4, 0x23, 0xE6, 0x3D, 0xF0, + 0x45, 0xE5, 0x86, 0x04, 0xA0, 0xFD, 0xF6, 0x10, 0x59, 0x22, 0x39, 0x10, + 0x29, 0x36, 0x06, 0x1B, 0x1D, 0x26, 0x9E, 0x33, 0x31, 0x0C, 0xA1, 0x2A, + 0x76, 0x03, 0x05, 0x1D, 0x33, 0xEF, 0xE1, 0xF4, 0x75, 0xEF, 0xC8, 0xE0, + 0x6A, 0xEF, 0x44, 0xD7, 0xD9, 0xED, 0x77, 0xCB, 0xBE, 0xE3, 0x95, 0xD1, + 0xAD, 0xDA, 0x04, 0xEC, 0x5D, 0xE3, 0xC8, 0x07, 0xE5, 0x05, 0xDC, 0x0B, + 0xA8, 0x29, 0x5B, 0x11, 0x95, 0x20, 0xDB, 0x17, 0x99, 0x17, 0xDF, 0x2C, + 0x67, 0xFE, 0xDC, 0x1C, 0x71, 0xE4, 0x18, 0xF6, 0x05, 0xDE, 0x7D, 0xDC, + 0x87, 0xE1, 0x2A, 0xD6, 0x27, 0xF4, 0x71, 0xD5, 0xBC, 0xFE, 0xDC, 0xD7, + 0x8C, 0xF7, 0x15, 0xEF, 0xEE, 0xEF, 0x69, 0x13, 0xE3, 0x05, 0x09, 0x27, + 0xF4, 0x21, 0xAD, 0x1F, 0xB9, 0x2F, 0x07, 0x2B, 0xBD, 0x3B, 0x6A, 0x3D, + 0x47, 0x23, 0xFC, 0x2F, 0x15, 0x06, 0x05, 0x15, 0xC9, 0xE6, 0xCC, 0xF6, + 0xB7, 0xDF, 0x44, 0xE9, 0x00, 0xF2, 0x9C, 0xE5, 0xB9, 0x0B, 0x54, 0xE1, + 0x47, 0x11, 0x25, 0xF0, 0xBB, 0x0C, 0x98, 0x16, 0x86, 0x03, 0x76, 0x24, + 0x85, 0x0B, 0xFD, 0x1F, 0x43, 0x24, 0x62, 0x16, 0x6C, 0x1D, 0x4D, 0x0C, + 0x77, 0x21, 0x14, 0x18, 0x04, 0x0D, 0x9F, 0x10, 0x3E, 0xEF, 0xFB, 0xF6, + 0xA8, 0xD1, 0x2E, 0xE0, 0xB7, 0xCF, 0xEA, 0xD7, 0xEE, 0xE6, 0x8E, 0xCC, + 0x48, 0x05, 0x14, 0xD2, 0x98, 0x11, 0x44, 0xFD, 0x5B, 0x0C, 0x77, 0x1B, + 0x3A, 0xFE, 0x54, 0x17, 0x5D, 0xF5, 0x88, 0x09, 0x41, 0x07, 0xE3, 0xFC, + 0x00, 0x1A, 0x04, 0x07, 0x7D, 0x1E, 0x05, 0x0D, 0xFC, 0x0E, 0x89, 0x02, + 0x4C, 0xEA, 0xE1, 0xF1, 0x35, 0xCE, 0x1D, 0xEC, 0xC5, 0xD0, 0x5C, 0xE2, + 0x30, 0xFA, 0xE2, 0xE5, 0x28, 0x25, 0xC2, 0x0C, 0x36, 0x24, 0xF1, 0x30, + 0x4D, 0x1D, 0x40, 0x40, 0x3C, 0x0E, 0xD1, 0x31, 0xA6, 0x0B, 0x39, 0x19, + 0x51, 0x08, 0x4E, 0x05, 0xF6, 0x17, 0x43, 0x0A, 0xF4, 0x1B, 0xCC, 0x03, + 0xF8, 0x08, 0xBF, 0xFB, 0x96, 0xDD, 0xAC, 0xEF, 0xBB, 0xCC, 0x92, 0xEB, + 0x6B, 0xE8, 0x4E, 0xE3, 0x12, 0x0E, 0x8E, 0xFE, 0x5F, 0x31, 0x7B, 0x21, + 0x4C, 0x25, 0x3B, 0x25, 0x76, 0x18, 0x21, 0x30, 0xAA, 0xFD, 0xCA, 0x12, + 0x2D, 0xE6, 0x1E, 0xF4, 0xA2, 0xE9, 0xA6, 0xE8, 0xAE, 0x04, 0x12, 0xEA, + 0x41, 0x0E, 0x53, 0xE3, 0xF5, 0xEF, 0xCC, 0xE1, 0x67, 0xC8, 0x68, 0xDC, + 0x29, 0xD3, 0xC2, 0xDE, 0x42, 0xFD, 0x88, 0xEB, 0x79, 0x12, 0xCE, 0xF4, + 0x96, 0x26, 0x29, 0x16, 0xC9, 0x2F, 0xEC, 0x3B, 0x04, 0x1C, 0xEA, 0x31, + 0x3E, 0xF4, 0xA1, 0x0F, 0x46, 0xD8, 0x0F, 0xF2, 0x01, 0xE6, 0x8C, 0xE4, + 0x36, 0x04, 0x78, 0xDE, 0x62, 0x0C, 0xDF, 0xE6, 0x75, 0xEE, 0x9D, 0xF2, + 0xA2, 0xE2, 0x9B, 0xF1, 0x86, 0xF7, 0xCA, 0x05, 0x7F, 0x02, 0x51, 0x05, + 0x69, 0x20, 0x55, 0x15, 0xBB, 0x36, 0x23, 0x36, 0x05, 0x38, 0xD5, 0x42, + 0x8A, 0x10, 0xE7, 0x23, 0xCF, 0xD5, 0x0D, 0xF6, 0x08, 0xBD, 0x38, 0xD4, + 0x2B, 0xDC, 0xD2, 0xCB, 0xB1, 0x03, 0x84, 0xD6, 0x1A, 0xFD, 0x10, 0xE5, + 0x04, 0xF9, 0x30, 0x08, 0x78, 0xF1, 0x2F, 0x10, 0x56, 0xEB, 0xB7, 0xFB, + 0x79, 0xF3, 0x42, 0xEE, 0x9D, 0x08, 0x66, 0x02, 0xF3, 0x27, 0x75, 0x1F, + 0x07, 0x22, 0xEB, 0x1A, 0x27, 0xF2, 0xE9, 0xFE, 0xE3, 0xB8, 0x1E, 0xDA, + 0x82, 0xBE, 0x00, 0xC3, 0xD0, 0xE7, 0x68, 0xCC, 0xC4, 0x05, 0x7A, 0xDE, + 0xAC, 0x14, 0x58, 0xFC, 0x51, 0x05, 0x90, 0x1B, 0x7F, 0xF7, 0xEE, 0x1A, + 0xED, 0xEB, 0x5A, 0x09, 0xE0, 0xF5, 0x2D, 0x03, 0x20, 0x12, 0xC0, 0x10, + 0x9B, 0x39, 0x73, 0x24, 0x0C, 0x30, 0x7F, 0x1E, 0x2D, 0xEB, 0x12, 0xFE, + 0xB4, 0xD5, 0x3E, 0xE1, 0xA8, 0xDA, 0xA6, 0xCD, 0x1D, 0xF3, 0xF7, 0xD2, + 0xE8, 0x1A, 0x94, 0xF4, 0x07, 0x29, 0x7F, 0x25, 0xDD, 0x26, 0x55, 0x3D, + 0x16, 0x07, 0x3A, 0x21, 0x4B, 0xE8, 0xF7, 0xFE, 0x0D, 0xDE, 0x08, 0xEE, + 0x9F, 0x0F, 0x8F, 0x03, 0x0F, 0x26, 0xDD, 0x06, 0xCD, 0x02, 0x19, 0x01, + 0xB0, 0xD5, 0x5F, 0xE1, 0xE3, 0xB1, 0x27, 0xBD, 0xD2, 0xCE, 0x89, 0xC8, + 0xF6, 0xF9, 0xFE, 0xD8, 0xC7, 0x1E, 0xF7, 0x00, 0x4D, 0x24, 0x72, 0x1B, + 0xDC, 0x1C, 0x12, 0x26, 0x49, 0xF0, 0xEE, 0x08, 0xC5, 0xC6, 0x96, 0xE7, + 0x5D, 0xD7, 0xDD, 0xE2, 0x47, 0x11, 0x5A, 0xF8, 0x2F, 0x12, 0xBE, 0xFD, + 0x28, 0xE6, 0xAD, 0xEE, 0x80, 0xDC, 0xF1, 0xEF, 0xA2, 0xCF, 0x4C, 0xE0, + 0xEB, 0xE2, 0x4E, 0xD3, 0xC1, 0xFE, 0xB7, 0xE0, 0xF1, 0x2A, 0x80, 0x15, + 0x3F, 0x4F, 0xED, 0x48, 0x6C, 0x2E, 0x74, 0x3D, 0xD8, 0xEE, 0xBA, 0x1A, + 0xD6, 0xDA, 0x80, 0xFC, 0x75, 0xF1, 0x76, 0xF2, 0x3A, 0x14, 0x45, 0xFC, + 0x88, 0x20, 0x85, 0x00, 0x2F, 0x09, 0x74, 0x0F, 0x62, 0xE5, 0x50, 0x04, + 0x89, 0xD7, 0x82, 0xE6, 0xCC, 0xDC, 0xB9, 0xD3, 0x9B, 0x04, 0xDD, 0xF3, + 0x45, 0x3E, 0x01, 0x29, 0x73, 0x54, 0xE6, 0x43, 0xEB, 0x1E, 0xE6, 0x29, + 0x63, 0xCA, 0xF2, 0xEE, 0x9D, 0xCB, 0x2F, 0xD0, 0x39, 0xE8, 0xF1, 0xCB, + 0x12, 0x04, 0x01, 0xD9, 0x15, 0x0B, 0xC2, 0xEC, 0x66, 0xFA, 0x27, 0x00, + 0xD1, 0xE9, 0x16, 0xFA, 0x2E, 0xDB, 0xE5, 0xE1, 0xF2, 0xD9, 0x20, 0xD7, + 0x95, 0x04, 0x43, 0xFC, 0x41, 0x40, 0xC8, 0x2D, 0x8E, 0x38, 0x75, 0x3B, + 0xCF, 0xF8, 0x32, 0x0C, 0x53, 0xBE, 0xCD, 0xDA, 0x93, 0xBA, 0x43, 0xCD, + 0x5F, 0xE4, 0x6C, 0xC7, 0x06, 0x11, 0xB9, 0xE1, 0xC1, 0x24, 0x15, 0x0D, + 0x7C, 0x1A, 0x39, 0x21, 0x05, 0x00, 0xD7, 0x11, 0xB9, 0xE4, 0x5C, 0x01, + 0x6F, 0xE4, 0x13, 0xFF, 0x71, 0x21, 0x4B, 0x22, 0xBC, 0x34, 0x84, 0x38, + 0xF4, 0x26, 0xBB, 0x33, 0x4C, 0x06, 0x32, 0x20, 0x58, 0xC2, 0xE5, 0xE7, + 0xFA, 0xB4, 0x10, 0xB9, 0x97, 0xD9, 0x14, 0xB8, 0xB2, 0x08, 0x17, 0xE4, + 0x9F, 0x27, 0xE6, 0x18, 0x24, 0x2A, 0xE9, 0x2E, 0xAE, 0x0A, 0xD0, 0x1D, + 0xCE, 0xE2, 0xD9, 0xFF, 0x98, 0xF6, 0x50, 0xFD, 0x35, 0x2D, 0xBC, 0x21, + 0x37, 0x3C, 0x83, 0x29, 0xF3, 0x24, 0x91, 0x1A, 0x27, 0xE1, 0xE1, 0xFA, + 0x2C, 0xB5, 0xB1, 0xCB, 0xAF, 0xB5, 0x49, 0xA9, 0x2F, 0xDB, 0x39, 0xB8, + 0xB1, 0x0E, 0x2D, 0xEF, 0x11, 0x40, 0x49, 0x2B, 0xDD, 0x38, 0x66, 0x33, + 0x63, 0xED, 0x88, 0x09, 0x02, 0xEF, 0x3E, 0x05, 0x14, 0x00, 0x7C, 0xFC, + 0x81, 0x18, 0x3D, 0x04, 0xC4, 0x3C, 0xE8, 0x22, 0x60, 0x24, 0x5E, 0x2C, + 0x83, 0xF8, 0x72, 0x14, 0xC7, 0xCE, 0xDC, 0xE0, 0xFD, 0xCA, 0xEF, 0xC3, + 0x8F, 0xE3, 0xE3, 0xCF, 0x08, 0x27, 0x3A, 0x0E, 0x06, 0x4C, 0xFE, 0x41, + 0xC2, 0x22, 0x45, 0x34, 0xF3, 0xF1, 0x38, 0x17, 0x79, 0xCC, 0xBD, 0xF6, + 0x9D, 0xE4, 0x31, 0xE6, 0xBC, 0x20, 0x4E, 0xF9, 0xAD, 0x3F, 0xB3, 0x1D, + 0xFD, 0x20, 0x49, 0x24, 0xCB, 0xF1, 0x95, 0x03, 0x8C, 0xCA, 0x57, 0xD2, + 0x65, 0xC1, 0x3B, 0xC0, 0xE1, 0xEE, 0x01, 0xE7, 0xBD, 0x35, 0x89, 0x23, + 0x58, 0x32, 0x2B, 0x3D, 0x63, 0x02, 0xB5, 0x26, 0xBC, 0xE1, 0x42, 0x08, + 0x45, 0xBD, 0x3D, 0xD5, 0x70, 0xDC, 0x8A, 0xC6, 0x6A, 0x0A, 0x04, 0xDF, + 0xFB, 0x20, 0x5F, 0x08, 0xED, 0x23, 0x1C, 0x21, 0x80, 0x00, 0x0B, 0x01, + 0xD1, 0xD8, 0xE6, 0xDF, 0x45, 0xDD, 0x0D, 0xDC, 0x28, 0x1D, 0x97, 0x18, + 0x6F, 0x54, 0x64, 0x4B, 0xCB, 0x53, 0xFE, 0x4D, 0xA7, 0x1F, 0xD8, 0x3F, + 0xE0, 0xCF, 0x08, 0x04, 0xEC, 0xBD, 0xD5, 0xD4, 0xDB, 0xDB, 0x7C, 0xC5, + 0xED, 0x09, 0x93, 0xE8, 0x79, 0x36, 0xED, 0x1E, 0xE4, 0x3D, 0xF2, 0x30, + 0x7B, 0x0B, 0xC2, 0x0F, 0xA4, 0xF6, 0x20, 0xF9, 0xFC, 0x05, 0x7A, 0x04, + 0x69, 0x0F, 0x6E, 0x09, 0xC6, 0x4E, 0x5A, 0x39, 0xAA, 0x50, 0xB3, 0x52, + 0x05, 0x16, 0xD9, 0x3C, 0x8A, 0xD6, 0xEE, 0xF9, 0x9B, 0xBA, 0xCA, 0xB5, + 0x43, 0xC6, 0x8B, 0xA9, 0x72, 0xF0, 0x09, 0xD6, 0x8E, 0x20, 0x75, 0x0C, + 0xD2, 0x0F, 0xF4, 0x09, 0x00, 0xEC, 0x9D, 0xF7, 0x76, 0xD1, 0x5D, 0xE9, + 0x37, 0xD1, 0x57, 0xDD, 0x76, 0x0C, 0xFE, 0xF2, 0xB2, 0x3B, 0x5F, 0x1E, + 0x1A, 0x33, 0x36, 0x3B, 0x9D, 0x02, 0x5E, 0x22, 0x20, 0xCB, 0x83, 0xDC, + 0x1F, 0xB5, 0xDB, 0xB0, 0x47, 0xC6, 0xA9, 0xB8, 0x5F, 0x0E, 0x0C, 0xF7, + 0x3C, 0x26, 0xC3, 0x22, 0xE2, 0x23, 0x77, 0x32, 0x2E, 0x0C, 0x7F, 0x28, + 0x51, 0xD6, 0xCD, 0xFB, 0x7B, 0xE5, 0xD5, 0xEC, 0x4D, 0x19, 0x1F, 0x02, + 0x33, 0x38, 0xCA, 0x29, 0x9F, 0x2F, 0xC8, 0x3F, 0xA9, 0x0D, 0x08, 0x25, + 0x72, 0xDF, 0xC6, 0xE6, 0xEF, 0xBF, 0x05, 0xB7, 0x23, 0xF0, 0x8B, 0xDE, + 0xBB, 0x2C, 0x33, 0x19, 0x4C, 0x46, 0xB4, 0x34, 0x0E, 0x38, 0xAF, 0x3E, + 0x33, 0xF7, 0xB4, 0x1F, 0xFC, 0xCF, 0xC9, 0xF3, 0x54, 0xDB, 0x88, 0xD4, + 0x42, 0x04, 0x39, 0xEA, 0x2F, 0x1B, 0xBA, 0x0F, 0xBC, 0x1E, 0xB1, 0x1D, + 0x26, 0xF3, 0xBC, 0xF2, 0x30, 0xD7, 0x10, 0xC8, 0xAF, 0xC3, 0x9C, 0xB5, + 0x8F, 0xCE, 0x61, 0xBF, 0xD6, 0x1F, 0xB5, 0xFD, 0xD4, 0x57, 0x20, 0x3D, + 0x49, 0x40, 0x65, 0x51, 0x2A, 0xFB, 0x85, 0x25, 0x70, 0xD1, 0x32, 0xE8, + 0xD4, 0xCF, 0x6D, 0xC7, 0x09, 0xE8, 0x81, 0xD9, 0x14, 0x08, 0x9C, 0x01, + 0x81, 0x10, 0xB2, 0x0C, 0xB1, 0xDA, 0xAD, 0xDB, 0x01, 0xBF, 0x45, 0xC2, + 0x07, 0xC7, 0x9E, 0xCE, 0x79, 0xFE, 0xD3, 0xF0, 0xF2, 0x47, 0x97, 0x2A, + 0x79, 0x5E, 0xA3, 0x5B, 0xB2, 0x35, 0x8D, 0x5D, 0x7C, 0xF8, 0x43, 0x27, + 0x7C, 0xD5, 0x0B, 0xE4, 0xCF, 0xCD, 0xE4, 0xC6, 0xD2, 0xF8, 0x51, 0xEA, + 0xA9, 0x08, 0xCA, 0xFC, 0x11, 0x0B, 0x92, 0x03, 0xCB, 0x05, 0xC7, 0x04, + 0xAF, 0xD1, 0x56, 0xE2, 0x42, 0xC9, 0xB2, 0xCE, 0x15, 0xF8, 0xF3, 0xDE, + 0xB7, 0x39, 0xBC, 0x1E, 0xED, 0x3C, 0xF5, 0x47, 0x62, 0x20, 0x3F, 0x46, + 0x4B, 0xF9, 0x3E, 0x0D, 0x6E, 0xCD, 0xF3, 0xC9, 0x17, 0xE1, 0xAE, 0xCC, + 0xAC, 0xF3, 0x9B, 0xD9, 0x98, 0x18, 0xBF, 0xFB, 0x83, 0x2B, 0xC7, 0x17, + 0x2F, 0x03, 0x40, 0x0D, 0xD4, 0xCA, 0xD6, 0xE2, 0xBF, 0xD0, 0xDD, 0xD2, + 0x9E, 0x05, 0xCC, 0xEE, 0xFC, 0x2C, 0x2A, 0x23, 0xB9, 0x34, 0x69, 0x47, + 0x48, 0x1A, 0x4F, 0x2E, 0x93, 0xE7, 0x27, 0xF1, 0xF6, 0xCE, 0x17, 0xC4, + 0xF9, 0xDE, 0x68, 0xCA, 0x37, 0xF7, 0x21, 0xE3, 0x76, 0x32, 0x25, 0x19, + 0xC3, 0x3A, 0x30, 0x3A, 0x00, 0x01, 0xBB, 0x21, 0x9F, 0xDA, 0xFD, 0xF9, + 0xE3, 0xDF, 0xB3, 0xDB, 0xDC, 0x04, 0x8D, 0xF4, 0x37, 0x13, 0x20, 0x18, + 0xD6, 0x1C, 0x59, 0x2F, 0xCA, 0xF5, 0x5D, 0x03, 0x10, 0xC7, 0xB5, 0xC8, + 0xAC, 0xC1, 0x30, 0xC1, 0x22, 0xCA, 0x6D, 0xBD, 0x87, 0x14, 0xE9, 0xF0, + 0x2B, 0x3E, 0x55, 0x1E, 0x75, 0x27, 0x80, 0x30, 0xBB, 0xF2, 0x30, 0x13, + 0x7D, 0xDB, 0x93, 0xEA, 0xC4, 0xD9, 0xE8, 0xD4, 0x96, 0xF0, 0xAE, 0xEA, + 0x28, 0x01, 0xBA, 0x08, 0x8E, 0x00, 0x64, 0x07, 0xE6, 0x04, 0x1E, 0x09, + 0xBF, 0xD9, 0xF3, 0xDD, 0x94, 0xB6, 0x45, 0xB4, 0x1B, 0xD7, 0xDC, 0xBA, + 0x44, 0x19, 0x05, 0xEC, 0xB8, 0x39, 0x00, 0x27, 0x44, 0x25, 0xEF, 0x40, + 0x87, 0x06, 0xA5, 0x2F, 0x6A, 0xF7, 0x7C, 0x07, 0x1C, 0xF7, 0xD3, 0xF5, + 0x44, 0x17, 0xE3, 0x12, 0x86, 0x24, 0xF7, 0x24, 0x40, 0x2B, 0xF1, 0x26, + 0xAF, 0x08, 0x35, 0x0B, 0x86, 0xCF, 0x00, 0xE0, 0x94, 0xBF, 0x8F, 0xC4, + 0xF9, 0xEE, 0xFA, 0xCE, 0xBD, 0x27, 0x31, 0x04, 0xB0, 0x38, 0xA0, 0x3E, + 0x58, 0x26, 0x87, 0x4A, 0x54, 0x00, 0xB6, 0x1C, 0x65, 0xF5, 0x1B, 0xFC, + 0x4F, 0xEC, 0x83, 0xE7, 0x9E, 0xF0, 0x7A, 0xE5, 0x0D, 0x13, 0x01, 0xFF, + 0x93, 0x1C, 0x62, 0x0B, 0xD7, 0xF0, 0x1C, 0xFB, 0x91, 0xBF, 0xA3, 0xD1, + 0x14, 0xC9, 0x3A, 0xBE, 0x1D, 0x02, 0xF5, 0xDA, 0xF5, 0x20, 0x85, 0x0A, + 0x75, 0x20, 0x1B, 0x2F, 0x8A, 0xF9, 0xFA, 0x18, 0x26, 0xE6, 0x6B, 0xFC, + 0xD3, 0xD9, 0xAD, 0xE4, 0xCD, 0xCE, 0x87, 0xCB, 0xCA, 0xF4, 0x11, 0xDC, + 0xFE, 0x26, 0x2D, 0x01, 0x14, 0x27, 0x3C, 0x1A, 0xB1, 0xEE, 0x10, 0x05, + 0x95, 0xD5, 0x88, 0xEB, 0x5E, 0xF6, 0xC0, 0xEB, 0x02, 0x26, 0x86, 0x11, + 0x9B, 0x2A, 0x47, 0x32, 0x99, 0x22, 0x3F, 0x3E, 0x8D, 0x17, 0x0A, 0x39, + 0xF4, 0xF7, 0x4A, 0x10, 0x6C, 0xCF, 0x23, 0xE1, 0x89, 0xCD, 0x39, 0xC7, + 0x42, 0x08, 0x44, 0xE5, 0xEF, 0x33, 0xA7, 0x10, 0x41, 0x1E, 0x71, 0x20, + 0xF9, 0xF3, 0x92, 0x11, 0x79, 0xF5, 0x6C, 0x04, 0x15, 0x08, 0x58, 0xFD, + 0xD3, 0x23, 0x07, 0x1C, 0x96, 0x29, 0xE1, 0x32, 0xF4, 0x1E, 0x00, 0x2C, + 0x76, 0x0A, 0xDB, 0x1C, 0xAC, 0xD6, 0x3D, 0xEB, 0xA1, 0xB5, 0x93, 0xC1, + 0xD0, 0xD4, 0x6F, 0xC0, 0x07, 0x14, 0xA8, 0xE3, 0x14, 0x27, 0xE3, 0x04, + 0xAA, 0x10, 0x82, 0x16, 0x4F, 0xF1, 0x31, 0x03, 0x0D, 0xF9, 0xBE, 0xFD, + 0xD3, 0x01, 0x87, 0xF9, 0xE8, 0x05, 0xE3, 0xFC, 0x5F, 0x1E, 0x7C, 0x20, + 0x17, 0x2F, 0xB8, 0x38, 0xD6, 0x10, 0x6E, 0x26, 0x40, 0xCD, 0xA8, 0xEC, + 0x57, 0xBF, 0x11, 0xCB, 0x7A, 0xF6, 0x3E, 0xD1, 0xBC, 0x29, 0xED, 0xF5, + 0x07, 0x22, 0x8A, 0x18, 0x06, 0x0B, 0xE7, 0x1A, 0xB3, 0x01, 0xB9, 0x14, + 0x28, 0xFD, 0x86, 0x08, 0x1D, 0xF6, 0x0A, 0xFB, 0x91, 0x00, 0xA0, 0x09, + 0x31, 0x2E, 0xB3, 0x2C, 0x8E, 0x33, 0xA7, 0x34, 0xF2, 0xF3, 0x5C, 0x0E, + 0x58, 0xC2, 0x76, 0xDD, 0x8D, 0xD2, 0x24, 0xC3, 0xBD, 0x03, 0x1A, 0xD9, + 0x75, 0x22, 0x21, 0x07, 0x46, 0x23, 0xDA, 0x27, 0xDE, 0x0E, 0xF0, 0x26, + 0x78, 0xFF, 0x24, 0x17, 0x02, 0xEB, 0x59, 0xF7, 0x0D, 0xE3, 0xC8, 0xE7, + 0x7E, 0x01, 0x64, 0xF8, 0x51, 0x1F, 0xC7, 0x0A, 0xB3, 0x14, 0x74, 0x11, + 0x94, 0xDF, 0x1A, 0xF4, 0xCF, 0xCB, 0x85, 0xD6, 0x8F, 0xE8, 0x3D, 0xCB, + 0x09, 0x15, 0xED, 0xF3, 0xEB, 0x2D, 0x0F, 0x22, 0xDF, 0x26, 0x61, 0x2E, + 0x18, 0x1D, 0xD8, 0x34, 0x0C, 0xFB, 0x42, 0x15, 0x3D, 0xD9, 0x04, 0xF4, + 0xB8, 0xE2, 0xBE, 0xE9, 0x8F, 0x14, 0xF5, 0xFE, 0x2A, 0x2C, 0x40, 0x14, + 0x35, 0x0D, 0xB1, 0x11, 0x9F, 0xE6, 0xCF, 0xF5, 0x99, 0xE7, 0xDA, 0xE2, + 0xD2, 0x09, 0xDD, 0xF0, 0x0A, 0x14, 0x93, 0xF9, 0xB4, 0x1E, 0x2D, 0x1C, + 0x22, 0x29, 0x5A, 0x3C, 0xE0, 0x20, 0x57, 0x3E, 0xF8, 0xF1, 0xEC, 0x17, + 0x2B, 0xCC, 0x59, 0xE8, 0x2F, 0xE6, 0x82, 0xDC, 0x26, 0x17, 0xC8, 0xF0, + 0xAC, 0x17, 0xFB, 0xFE, 0x13, 0xEC, 0x11, 0xF2, 0xC6, 0xDD, 0xFA, 0xDD, + 0x31, 0xE7, 0xE3, 0xD6, 0xD8, 0xF4, 0x5D, 0xE0, 0x9B, 0x01, 0x35, 0xF3, + 0xAA, 0x1E, 0x71, 0x1C, 0xBB, 0x2E, 0x21, 0x34, 0x44, 0x0A, 0xC0, 0x1F, + 0x63, 0xCD, 0xCD, 0xEF, 0x4A, 0xBF, 0x50, 0xD0, 0xF4, 0xEE, 0x63, 0xD5, + 0x8E, 0x0F, 0x35, 0xEC, 0xD8, 0x03, 0xC0, 0xF5, 0xBB, 0xF8, 0x7F, 0x00, + 0x40, 0xF9, 0xAA, 0x06, 0xEE, 0xFB, 0x82, 0xF8, 0x7A, 0xFD, 0xB1, 0xF3, + 0xB6, 0x12, 0x64, 0x07, 0x14, 0x31, 0x7A, 0x2B, 0xA3, 0x2B, 0x22, 0x36, + 0x4C, 0xF1, 0x60, 0x19, 0xA7, 0xC4, 0x53, 0xF1, 0x06, 0xDD, 0xF6, 0xDD, + 0x3C, 0xFE, 0x01, 0xE9, 0x1E, 0x17, 0x9F, 0xFE, 0xFC, 0x18, 0x9E, 0x0F, + 0x6A, 0x10, 0xDE, 0x1F, 0xB5, 0x03, 0x61, 0x15, 0xEB, 0xEF, 0x13, 0xFA, + 0x89, 0xF1, 0xA1, 0xF0, 0xA5, 0x12, 0xA7, 0x09, 0xBA, 0x30, 0x42, 0x25, + 0xB4, 0x10, 0x3E, 0x1C, 0x2D, 0xD6, 0x32, 0xF8, 0x89, 0xC8, 0xC2, 0xD3, + 0x00, 0xE8, 0x73, 0xCC, 0xC6, 0x06, 0xE1, 0xD7, 0x27, 0x0F, 0x76, 0xEB, + 0xFB, 0x0E, 0x3B, 0x08, 0x87, 0x0C, 0xC7, 0x14, 0xB9, 0xFE, 0x20, 0x0A, + 0x70, 0xE5, 0x10, 0xF2, 0xDF, 0xEB, 0xA7, 0xEC, 0x5E, 0x15, 0x8B, 0x01, + 0xAD, 0x1F, 0x8A, 0x11, 0x57, 0xF2, 0x49, 0x08, 0xC8, 0xD2, 0x1B, 0xE3, + 0xB5, 0xDB, 0x25, 0xD2, 0xBD, 0xEE, 0x43, 0xD6, 0xCB, 0x0D, 0x84, 0xE8, + 0xE0, 0x1C, 0x82, 0x05, 0x47, 0x2A, 0x1C, 0x26, 0x99, 0x22, 0x32, 0x2E, + 0x56, 0xF8, 0xE6, 0x14, 0x32, 0xDD, 0x7F, 0xFA, 0xB4, 0xF3, 0x84, 0xF7, + 0x45, 0x17, 0x6A, 0x0C, 0x31, 0x03, 0x65, 0x07, 0xE4, 0xE9, 0xC0, 0xFF, + 0x9D, 0xE1, 0xBD, 0xF8, 0xDB, 0xE6, 0xF4, 0xE6, 0x0E, 0xFA, 0x46, 0xDC, + 0x3E, 0x06, 0x25, 0xE6, 0xEF, 0x22, 0x5F, 0x0E, 0x0F, 0x30, 0x05, 0x2B, + 0x92, 0x10, 0x81, 0x26, 0x13, 0xDA, 0x4A, 0x05, 0xF5, 0xE0, 0xE9, 0xF4, + 0xA2, 0xF9, 0x7A, 0xF6, 0xA4, 0x06, 0x6B, 0xF8, 0xD2, 0x0C, 0x5D, 0xFC, + 0x5E, 0xE5, 0xAB, 0xEF, 0xBF, 0xD9, 0x14, 0xE6, 0x29, 0xE0, 0x8B, 0xDB, + 0x61, 0xEE, 0x26, 0xDC, 0x1D, 0x0A, 0x1E, 0xF2, 0x2D, 0x37, 0x4B, 0x1E, + 0x0E, 0x39, 0xC4, 0x34, 0x1C, 0x09, 0xD8, 0x23, 0xF9, 0xE1, 0x6B, 0x01, + 0x0A, 0xEB, 0x61, 0xEC, 0xA1, 0x0E, 0x0A, 0xF5, 0xD0, 0x12, 0xE7, 0xF4, + 0x28, 0xFD, 0x37, 0xF7, 0xDC, 0xEA, 0x4F, 0xFA, 0x29, 0xEA, 0xED, 0xF5, + 0x30, 0xF1, 0x4C, 0xF0, 0x68, 0xFE, 0x8C, 0xF5, 0xB9, 0x27, 0x71, 0x17, + 0x7D, 0x45, 0x85, 0x36, 0x9A, 0x1F, 0x22, 0x34, 0x9C, 0xF3, 0xA6, 0x12, + 0x1D, 0xD3, 0xFF, 0xF1, 0x29, 0xE1, 0x5E, 0xEB, 0x38, 0x07, 0x07, 0xEB, + 0x26, 0x0C, 0xD3, 0xF0, 0x8E, 0x01, 0xCD, 0xF8, 0x38, 0xFE, 0x91, 0x01, + 0xE7, 0xF1, 0x88, 0xF9, 0x62, 0xE2, 0x79, 0xEE, 0x05, 0xF5, 0xEA, 0xF7, + 0xAB, 0x25, 0xE8, 0x18, 0xE9, 0x1F, 0xCA, 0x22, 0xA0, 0xEF, 0x0F, 0x0D, + 0xFB, 0xD1, 0x04, 0xFA, 0x78, 0xCB, 0x02, 0xE3, 0x98, 0xEE, 0xF8, 0xD9, + 0xB9, 0x00, 0x41, 0xDB, 0xBE, 0x07, 0x11, 0xEB, 0xFD, 0x0D, 0x6E, 0x00, + 0xB2, 0x0A, 0xD2, 0x0A, 0x19, 0xF2, 0xC3, 0x02, 0xE4, 0xE9, 0x91, 0xFD, + 0x98, 0x19, 0x6A, 0x12, 0x56, 0x26, 0xE2, 0x24, 0xB4, 0x15, 0x31, 0x22, + 0x89, 0xFC, 0x33, 0x14, 0x90, 0xD8, 0x14, 0xFA, 0xCA, 0xDF, 0x0C, 0xE9, + 0x44, 0xF6, 0xB1, 0xE3, 0x27, 0x08, 0x9B, 0xEB, 0xD7, 0x1B, 0x8F, 0x02, + 0x85, 0x2C, 0x65, 0x1C, 0x52, 0x1A, 0x19, 0x20, 0x61, 0xF4, 0x79, 0x0D, + 0x8D, 0x02, 0x1D, 0x13, 0xBC, 0x19, 0x46, 0x15, 0x4E, 0x21, 0x9B, 0x13, + 0x97, 0x11, 0xA6, 0x15, 0x53, 0xE5, 0x84, 0x05, 0x62, 0xD4, 0x34, 0xF0, + 0xD7, 0xDC, 0x66, 0xDC, 0x8A, 0xEF, 0x73, 0xD8, 0xD6, 0x06, 0x55, 0xE6, + 0x58, 0x2B, 0xE6, 0x06, 0xF6, 0x22, 0x3A, 0x14, 0x9D, 0x07, 0x0A, 0x0E, + 0xA4, 0xEF, 0xCD, 0x02, 0x73, 0xE1, 0xB9, 0xF2, 0x49, 0x0B, 0x56, 0xFF, + 0xCA, 0x20, 0x5C, 0x0D, 0x7C, 0x0A, 0x39, 0x0A, 0xF1, 0xE5, 0x2E, 0xF7, + 0x49, 0xE0, 0x59, 0xE9, 0x98, 0xDE, 0x5C, 0xDA, 0xF6, 0xE6, 0x33, 0xDA, + 0x53, 0x0C, 0xD2, 0xF5, 0x30, 0x2E, 0x27, 0x1A, 0x05, 0x17, 0x54, 0x23, + 0x56, 0xEF, 0x4F, 0x14, 0x85, 0xE2, 0xCC, 0x09, 0xFF, 0xF2, 0x12, 0x02, + 0x29, 0x19, 0x5C, 0x0D, 0xC0, 0x14, 0x17, 0x0E, 0x34, 0xFB, 0x5C, 0x05, + 0xB7, 0xEE, 0x05, 0xF9, 0x57, 0xEA, 0x72, 0xEE, 0xD7, 0xE3, 0xC2, 0xE6, + 0xA7, 0x00, 0x87, 0xF0, 0xA7, 0x21, 0xEE, 0x15, 0x22, 0x30, 0x09, 0x2D, + 0x33, 0x24, 0x79, 0x2F, 0xDE, 0xE7, 0x98, 0x11, 0xEC, 0xC9, 0x04, 0xF3, + 0xDC, 0xE5, 0x7E, 0xEF, 0x36, 0xFF, 0x75, 0xF2, 0xD3, 0xFE, 0x6D, 0xF4, + 0x2F, 0xFE, 0xBE, 0xF4, 0x3B, 0x03, 0xF7, 0xF4, 0xA8, 0xEF, 0x60, 0xE4, + 0x0A, 0x01, 0xE2, 0xF3, 0x3E, 0x1A, 0x35, 0x07, 0x21, 0x26, 0x87, 0x12, + 0xE3, 0x35, 0x7E, 0x28, 0x95, 0x03, 0xAF, 0x1C, 0x0A, 0xD7, 0x4B, 0x05, + 0xF5, 0xD3, 0xA0, 0xED, 0xF3, 0xEB, 0xAE, 0xE6, 0xFD, 0xF3, 0x36, 0xE5, + 0xEE, 0xFE, 0x19, 0xEC, 0x13, 0x0B, 0x18, 0xF5, 0x7E, 0xFA, 0xC9, 0xF4, + 0x2F, 0x00, 0xCC, 0xFA, 0xF1, 0xFF, 0x96, 0xFE, 0xDC, 0x13, 0x7A, 0x0E, + 0xB5, 0x3C, 0x4F, 0x2D, 0x88, 0x2C, 0x39, 0x36, 0x49, 0xF4, 0x96, 0x1C, + 0x82, 0xD4, 0x61, 0xFB, 0x56, 0xD5, 0x70, 0xE5, 0x3F, 0xDE, 0xBE, 0xDC, + 0x6F, 0xE7, 0xE1, 0xDB, 0xF0, 0x02, 0xB9, 0xEF, 0x70, 0x07, 0xC8, 0xFB, + 0x06, 0xF9, 0x88, 0xFC, 0x89, 0xEE, 0xFB, 0xFF, 0xF3, 0xF3, 0xE3, 0xFC, + 0xC0, 0x25, 0x30, 0x14, 0x71, 0x39, 0x7E, 0x2B, 0x37, 0x11, 0xEF, 0x21, + 0x0F, 0xDE, 0x73, 0xFF, 0xD0, 0xCB, 0x2F, 0xE1, 0x4B, 0xD5, 0x60, 0xD8, + 0x87, 0xE2, 0x8C, 0xD5, 0xCA, 0xFD, 0x36, 0xE9, 0x62, 0x1A, 0xFE, 0xFF, + 0x97, 0x21, 0xF3, 0x0E, 0xD2, 0x04, 0x36, 0x0F, 0xC3, 0xE7, 0xB8, 0xFD, + 0x11, 0xFC, 0x8E, 0xFF, 0x04, 0x21, 0x5E, 0x13, 0x4C, 0x23, 0x95, 0x20, + 0x07, 0xF9, 0x7B, 0x0B, 0x12, 0xE1, 0x1C, 0xF4, 0xCC, 0xDE, 0xD4, 0xE4, + 0x47, 0xF1, 0x89, 0xE3, 0xA5, 0x09, 0xA1, 0xEF, 0xB0, 0x15, 0x0D, 0xFA, + 0xC3, 0x33, 0x81, 0x16, 0x02, 0x2B, 0x75, 0x25, 0xFE, 0xFF, 0x15, 0x16, + 0x95, 0xEB, 0xA5, 0x03, 0x0F, 0x05, 0xB6, 0x07, 0xCF, 0x15, 0x01, 0x13, + 0x8A, 0xFE, 0x70, 0x0B, 0xF2, 0xE9, 0x59, 0xFB, 0x87, 0xDD, 0xE8, 0xE9, + 0xB2, 0xDF, 0x1E, 0xD9, 0xAA, 0xE5, 0x27, 0xD8, 0xEA, 0xF6, 0x30, 0xE3, + 0x2A, 0x29, 0xCE, 0x03, 0x72, 0x40, 0x41, 0x22, 0x42, 0x1F, 0x2D, 0x25, + 0xDC, 0xED, 0x58, 0x0C, 0x98, 0xED, 0xE6, 0xFF, 0xA0, 0xFF, 0xB4, 0xFE, + 0xAA, 0xF4, 0x39, 0xFA, 0x03, 0xED, 0x17, 0xF6, 0x2A, 0xDB, 0x89, 0xDB, + 0x39, 0xDE, 0xCB, 0xDA, 0x9D, 0xE5, 0xF7, 0xDD, 0xD0, 0xE9, 0xA3, 0xDF, + 0x6C, 0x11, 0xCC, 0xF2, 0x53, 0x3E, 0x05, 0x15, 0x66, 0x3C, 0xA3, 0x2F, + 0xFF, 0x08, 0xD7, 0x23, 0x86, 0xEE, 0xBC, 0x0E, 0xF6, 0xF0, 0x2C, 0x00, + 0x7F, 0xFB, 0xF2, 0x03, 0xDD, 0xF4, 0x8B, 0xF9, 0x00, 0xF3, 0xA7, 0xF0, + 0x58, 0x02, 0x45, 0xF9, 0xFA, 0xF9, 0xA0, 0xF5, 0x3C, 0xE8, 0x5D, 0xF0, + 0x88, 0xEC, 0x6B, 0xE8, 0x96, 0x1D, 0x64, 0x00, 0x35, 0x3C, 0x4A, 0x24, + 0x29, 0x29, 0x29, 0x36, 0xF2, 0xFF, 0x6E, 0x23, 0xA6, 0xEE, 0xE7, 0x08, + 0x87, 0xF1, 0x99, 0xFE, 0x81, 0xF9, 0x38, 0xF5, 0x46, 0x05, 0x33, 0xFA, + 0xCF, 0x01, 0x9E, 0xEE, 0x15, 0x03, 0x9B, 0xF0, 0xA6, 0xE3, 0xBA, 0xE6, + 0x58, 0xCE, 0x46, 0xD5, 0x72, 0xF3, 0x01, 0xE1, 0x36, 0x24, 0xD1, 0x04, + 0xBF, 0x32, 0x59, 0x2D, 0xA0, 0x19, 0x42, 0x2E, 0x51, 0xFE, 0x07, 0x19, + 0x78, 0xEC, 0x12, 0xFC, 0x79, 0xE4, 0xFD, 0xE7, 0x9F, 0xE4, 0x02, 0xE0, + 0xAE, 0xFB, 0x7E, 0xE4, 0xC4, 0x1A, 0x35, 0xFA, 0xE8, 0x0B, 0xC3, 0x00, + 0x71, 0xE2, 0x32, 0xED, 0x02, 0xDD, 0x35, 0xE2, 0x46, 0x0B, 0x95, 0xFD, + 0x66, 0x31, 0x27, 0x27, 0xCA, 0x20, 0xE0, 0x2F, 0x7E, 0xFC, 0xAB, 0x1B, + 0x03, 0xE6, 0xE7, 0x01, 0x1C, 0xE5, 0x5E, 0xF4, 0x8A, 0xE1, 0xC6, 0xE8, + 0x92, 0xE9, 0xA1, 0xDF, 0x6D, 0x0E, 0xB6, 0xEE, 0x0E, 0x27, 0x87, 0x0B, + 0x41, 0x0F, 0xBF, 0x12, 0xEE, 0xE9, 0x47, 0xFE, 0x7F, 0xF1, 0x9F, 0xF8, + 0x3A, 0x14, 0xF7, 0x0F, 0xAA, 0x1C, 0x1C, 0x23, 0xBA, 0x04, 0x76, 0x1C, + 0xFA, 0xEF, 0xB1, 0x03, 0x81, 0xE9, 0x52, 0xF4, 0xC7, 0xDD, 0x63, 0xE6, + 0x21, 0xD7, 0x5C, 0xD4, 0xCE, 0xF8, 0x5C, 0xDA, 0x5F, 0x1C, 0x37, 0xF1, + 0x77, 0x25, 0x0B, 0x11, 0xBC, 0x03, 0x29, 0x0E, 0x6C, 0xF8, 0x29, 0x07, + 0x97, 0x0B, 0x2B, 0x0C, 0x46, 0x15, 0x9D, 0x18, 0x9A, 0x18, 0x95, 0x21, + 0xC2, 0x09, 0x76, 0x10, 0xD0, 0x00, 0x9C, 0x06, 0xA3, 0xE7, 0x69, 0xF5, + 0xEC, 0xCF, 0xCD, 0xDD, 0x03, 0xD9, 0xC6, 0xCD, 0xBF, 0x06, 0x0E, 0xDE, + 0xC3, 0x2C, 0x17, 0x08, 0x95, 0x28, 0x73, 0x25, 0x35, 0x0E, 0xF5, 0x1D, + 0xFC, 0x07, 0x2F, 0x18, 0x77, 0x0F, 0xF0, 0x1A, 0xC1, 0x0C, 0xB7, 0x15, + 0x71, 0x09, 0x97, 0x11, 0x19, 0x0B, 0xD5, 0x0E, 0x74, 0x04, 0x96, 0x0C, + 0xC8, 0xE5, 0xA6, 0xF7, 0xDF, 0xCB, 0x5B, 0xD4, 0xBE, 0xE7, 0x03, 0xD0, + 0x6E, 0x1B, 0xA6, 0xF2, 0x7C, 0x26, 0xBA, 0x15, 0xA9, 0x0F, 0xB0, 0x1A, + 0x03, 0xF7, 0xA0, 0x0B, 0x8E, 0xF1, 0xDC, 0x02, 0x4E, 0xF2, 0x72, 0xFE, + 0x5D, 0xFA, 0x8D, 0x00, 0xBB, 0x08, 0xFE, 0x00, 0xED, 0x12, 0x65, 0x05, + 0xC9, 0x07, 0xEB, 0x07, 0xA1, 0xE1, 0xD7, 0xEF, 0x72, 0xDC, 0xD7, 0xD7, + 0xB9, 0x05, 0x98, 0xE7, 0x72, 0x29, 0xCF, 0x10, 0x9F, 0x22, 0x5A, 0x24, + 0x07, 0x07, 0x4D, 0x1B, 0x1C, 0xFB, 0x28, 0x10, 0xD4, 0xEE, 0x55, 0xFF, + 0xAB, 0xE9, 0x4E, 0xF7, 0x7A, 0xEE, 0x5D, 0xEC, 0x74, 0x0B, 0x32, 0xF6, + 0x2F, 0x19, 0xAE, 0x08, 0xDB, 0xFE, 0x54, 0x07, 0xA8, 0xEC, 0x1C, 0xF7, + 0xAC, 0x04, 0x8A, 0xF3, 0x0E, 0x2E, 0xA1, 0x1A, 0x90, 0x31, 0x37, 0x29, + 0x5B, 0x22, 0x0E, 0x29, 0xED, 0x07, 0xEF, 0x1D, 0x6E, 0xF1, 0x0A, 0x0D, + 0xB1, 0xDB, 0x68, 0xFA, 0x27, 0xCE, 0xF7, 0xDE, 0xC3, 0xE8, 0x30, 0xD9, + 0x3D, 0x0D, 0x98, 0xEB, 0x29, 0x16, 0x4E, 0x07, 0x64, 0xFE, 0xAA, 0xFF, + 0x71, 0x02, 0x2F, 0xFC, 0xDB, 0x11, 0xD2, 0xFE, 0xD1, 0x14, 0x59, 0x01, + 0xCF, 0x25, 0x4A, 0x1D, 0xEE, 0x1D, 0xC2, 0x25, 0x46, 0x0E, 0xA7, 0x21, + 0x6A, 0xEE, 0x6E, 0x0C, 0xA8, 0xD6, 0xD5, 0xF2, 0xC9, 0xD7, 0xB6, 0xD6, + 0xEC, 0xF4, 0x6F, 0xD3, 0xA0, 0x12, 0x77, 0xEF, 0x68, 0x0D, 0x2F, 0x02, + 0x1F, 0x02, 0xE1, 0xFC, 0x75, 0xF6, 0xD1, 0xEF, 0x16, 0xFE, 0x66, 0xF6, + 0xFF, 0x0F, 0x19, 0x0B, 0xD9, 0x23, 0xF7, 0x25, 0xA4, 0x25, 0x5D, 0x2B, + 0xC2, 0x0D, 0x20, 0x20, 0x2A, 0xE3, 0x35, 0x04, 0x61, 0xCE, 0x6A, 0xE4, + 0xBC, 0xE3, 0x72, 0xD5, 0xD6, 0x09, 0xED, 0xE6, 0x3B, 0x13, 0xB9, 0xFB, + 0xA3, 0x0B, 0x26, 0x0A, 0x77, 0x01, 0x34, 0x0C, 0xA8, 0xFC, 0x44, 0x04, + 0xF3, 0x01, 0xE8, 0x07, 0xC1, 0x03, 0x46, 0x0B, 0x81, 0x0E, 0x00, 0x11, + 0xD7, 0x0E, 0x78, 0x12, 0xF2, 0xF5, 0xEF, 0x09, 0x78, 0xD0, 0x76, 0xEB, + 0xE9, 0xD7, 0xA1, 0xD3, 0x16, 0xFD, 0x77, 0xDE, 0x8C, 0x23, 0x8E, 0xFC, + 0xCF, 0x2A, 0x64, 0x11, 0x77, 0x14, 0x1C, 0x18, 0xC9, 0x02, 0x2C, 0x11, + 0xE8, 0xFC, 0x64, 0x0E, 0x1E, 0xF9, 0xBC, 0x0A, 0x8A, 0xF8, 0xD8, 0xFE, + 0x81, 0x01, 0x63, 0xF8, 0xD1, 0x03, 0x9D, 0xFE, 0x1A, 0xF1, 0xB8, 0xFB, + 0xB0, 0xDB, 0x61, 0xDF, 0x0D, 0xF4, 0xF5, 0xD8, 0x4E, 0x11, 0xB0, 0xE6, + 0x9D, 0x1F, 0xAE, 0xFE, 0x15, 0x26, 0x8F, 0x1C, 0xB5, 0x1A, 0xBA, 0x22, + 0x4B, 0x06, 0x20, 0x1C, 0xB7, 0xF5, 0xEB, 0x13, 0x3D, 0xED, 0xAB, 0x01, + 0x9D, 0xF9, 0x1F, 0xF6, 0xB7, 0x03, 0xE2, 0xF4, 0x45, 0xF4, 0x9D, 0xF9, + 0xE2, 0xE2, 0xB0, 0xE6, 0xCA, 0xDE, 0x62, 0xD9, 0x1B, 0xEC, 0xEE, 0xDE, + 0x71, 0x05, 0xC5, 0xEB, 0x27, 0x1B, 0x1D, 0x08, 0x9B, 0x27, 0x7E, 0x1F, + 0x80, 0x1B, 0xF7, 0x24, 0x58, 0xFB, 0x48, 0x17, 0x28, 0xE0, 0x30, 0x04, + 0xFC, 0xE0, 0xD6, 0xEE, 0x72, 0xFB, 0x24, 0xF1, 0xC7, 0xF7, 0x72, 0xED, + 0x75, 0xED, 0x7C, 0xEF, 0xE5, 0xE7, 0x2D, 0xF1, 0x5F, 0xE3, 0xDD, 0xE0, + 0xDD, 0xF4, 0x01, 0xDF, 0x99, 0x10, 0xD5, 0xF5, 0xB7, 0x23, 0x61, 0x11, + 0xC3, 0x24, 0x12, 0x1F, 0x57, 0x11, 0x26, 0x21, 0x36, 0xEC, 0xB2, 0x12, + 0xF5, 0xD8, 0x1D, 0xFB, 0x87, 0xEA, 0x33, 0xE8, 0xCC, 0xFB, 0x16, 0xEC, + 0x5A, 0x04, 0xBB, 0xF5, 0x32, 0x05, 0x96, 0xFE, 0xE8, 0xF5, 0x3E, 0xF7, + 0x8C, 0xF3, 0xDF, 0xEC, 0xB5, 0x02, 0x8F, 0xF5, 0xCE, 0x16, 0xB4, 0x08, + 0xC4, 0x26, 0xC6, 0x1A, 0x53, 0x1C, 0xDF, 0x1E, 0xCC, 0xFC, 0x1F, 0x1B, + 0xFD, 0xDC, 0xE9, 0x05, 0x66, 0xDC, 0xD2, 0xEB, 0x66, 0xEF, 0x7F, 0xDE, + 0xF7, 0xFB, 0xC9, 0xDF, 0xC4, 0x08, 0xC9, 0xF5, 0xBE, 0x04, 0xF6, 0x01, + 0xF9, 0x00, 0x82, 0x01, 0x7F, 0xFA, 0x4C, 0xF9, 0xC8, 0xFD, 0x17, 0xFD, + 0x6E, 0x0C, 0xA8, 0x06, 0x51, 0x1B, 0x29, 0x12, 0x97, 0x06, 0xBA, 0x17, + 0x85, 0xE2, 0xB4, 0xFE, 0x53, 0xD5, 0xCD, 0xED, 0x62, 0xD5, 0x18, 0xDE, + 0xB3, 0xF4, 0xEA, 0xDA, 0x6C, 0x0E, 0xCD, 0xEA, 0x75, 0x14, 0x4C, 0xFB, + 0xBA, 0x11, 0x45, 0x05, 0x9F, 0x07, 0x97, 0x05, 0x28, 0xFA, 0x2B, 0x08, + 0xA1, 0xF9, 0x91, 0x07, 0xC4, 0x07, 0x9F, 0x0B, 0x2C, 0x10, 0x8F, 0x18, + 0x82, 0xF4, 0xAB, 0x10, 0x35, 0xDE, 0x51, 0x02, 0x46, 0xDA, 0xAE, 0xF1, + 0x3E, 0xE4, 0xD1, 0xDB, 0xF4, 0x02, 0x9E, 0xE2, 0x27, 0x1B, 0xC4, 0xFA, + 0x0E, 0x1E, 0x15, 0x0A, 0x86, 0x10, 0x5A, 0x0D, 0x64, 0xFF, 0xEF, 0x0F, + 0x10, 0xF5, 0x8B, 0x12, 0x3D, 0xFC, 0x22, 0x0B, 0xE1, 0xFA, 0x1A, 0x09, + 0xC0, 0xFE, 0x08, 0x0C, 0xFD, 0xF8, 0x73, 0x06, 0xE5, 0xE1, 0xDC, 0xFA, + 0xF4, 0xD5, 0xF7, 0xE1, 0x17, 0xE0, 0x7F, 0xD3, 0x02, 0xFF, 0x9A, 0xE3, + 0x60, 0x1B, 0xA4, 0xFE, 0x1D, 0x27, 0x75, 0x11, 0x6A, 0x17, 0x82, 0x17, + 0xDB, 0x00, 0x06, 0x19, 0x32, 0xFF, 0x5C, 0x16, 0x0C, 0x03, 0xA6, 0x0A, + 0x22, 0x07, 0x1A, 0x01, 0x9A, 0x05, 0x77, 0x01, 0x50, 0xF1, 0x5F, 0x01, + 0xCB, 0xE1, 0x2A, 0xF4, 0x76, 0xE4, 0x03, 0xE5, 0xFD, 0xF7, 0xDA, 0xE5, + 0x2A, 0x12, 0xB0, 0xF5, 0xBE, 0x29, 0x20, 0x0A, 0xBB, 0x27, 0x7B, 0x1B, + 0xC2, 0x11, 0xDD, 0x1E, 0x68, 0xF2, 0x67, 0x10, 0xC0, 0xDF, 0xE6, 0x00, + 0xE3, 0xEF, 0x4C, 0xF5, 0xDB, 0x07, 0xE4, 0xF8, 0x43, 0x09, 0x7C, 0x03, + 0xC7, 0xF1, 0xA0, 0xFB, 0xEB, 0xE8, 0x52, 0xF0, 0x0F, 0xF0, 0x26, 0xEC, + 0xD7, 0x01, 0x7E, 0xF7, 0x51, 0x12, 0x67, 0x03, 0x94, 0x25, 0x12, 0x16, + 0xBF, 0x10, 0xAF, 0x1F, 0x3E, 0xEE, 0x04, 0x16, 0xDE, 0xE0, 0x30, 0x0B, + 0xA0, 0xD6, 0x67, 0xEE, 0x89, 0xEC, 0xF7, 0xE4, 0xDD, 0x03, 0x17, 0xF3, + 0xA4, 0x09, 0x5A, 0x00, 0x41, 0xFD, 0x67, 0xFA, 0xEB, 0xF5, 0xF6, 0xF3, + 0x43, 0xFC, 0xDF, 0xFC, 0xB6, 0x12, 0xFD, 0x06, 0x72, 0x26, 0x4A, 0x1E, + 0xF6, 0x27, 0x23, 0x25, 0x12, 0x1A, 0x78, 0x20, 0x9B, 0xF4, 0xB1, 0x17, + 0x4C, 0xD8, 0xC3, 0xFF, 0xB4, 0xD9, 0x58, 0xE9, 0x47, 0xEF, 0xD6, 0xE2, + 0x0E, 0x03, 0x02, 0xEC, 0xDA, 0x0C, 0x6B, 0xF4, 0xDF, 0x0B, 0x49, 0xF9, + 0x54, 0x00, 0x30, 0xFA, 0x63, 0x13, 0xE5, 0x0C, 0x33, 0x25, 0x70, 0x19, + 0x05, 0x28, 0x34, 0x1A, 0xA1, 0x2A, 0x80, 0x20, 0x8C, 0x0D, 0x49, 0x20, + 0x14, 0xE4, 0x18, 0x0D, 0x6B, 0xCF, 0xD9, 0xEF, 0x33, 0xD9, 0x8F, 0xDE, + 0x7A, 0xEE, 0x6A, 0xDD, 0x01, 0x01, 0x64, 0xE5, 0xB1, 0x0E, 0x59, 0xF2, + 0x09, 0x0A, 0xC5, 0x01, 0xC7, 0x07, 0x14, 0x09, 0x7C, 0x0A, 0xC6, 0x0F, + 0xF9, 0x06, 0xC3, 0x0A, 0x22, 0x18, 0x4C, 0x0F, 0xFB, 0x1A, 0xB5, 0x1B, + 0xF9, 0xFF, 0x3F, 0x19, 0xD6, 0xDC, 0x30, 0x00, 0x13, 0xD1, 0x3C, 0xE4, + 0x63, 0xE2, 0x77, 0xDC, 0x17, 0xFD, 0x8B, 0xE5, 0xDD, 0x15, 0xBD, 0xF5, + 0xAE, 0x18, 0x5C, 0x06, 0xBF, 0x11, 0xEF, 0x13, 0xA1, 0x08, 0xDB, 0x17, + 0xFB, 0xFE, 0x51, 0x11, 0xEB, 0x08, 0x51, 0x09, 0xE2, 0x14, 0x39, 0x0C, + 0x34, 0x11, 0x5C, 0x13, 0xD0, 0xF4, 0xB7, 0x06, 0x02, 0xDD, 0x0F, 0xEE, + 0x9E, 0xD8, 0x31, 0xDC, 0x61, 0xED, 0x44, 0xDC, 0xA8, 0x0E, 0x54, 0xF2, + 0x13, 0x1D, 0x27, 0x01, 0x28, 0x27, 0x76, 0x13, 0x14, 0x14, 0x59, 0x1D, + 0x3B, 0xF8, 0xA2, 0x17, 0xAD, 0xF3, 0x04, 0x0D, 0xE1, 0x06, 0xC4, 0x08, + 0xD3, 0x0E, 0x3B, 0x08, 0x71, 0xFF, 0x7E, 0xFF, 0x4C, 0xEA, 0x02, 0xEF, + 0x12, 0xE0, 0x99, 0xDF, 0x69, 0xE1, 0x86, 0xD8, 0x53, 0xFE, 0xCE, 0xE1, + 0x02, 0x1B, 0xD9, 0xF6, 0xD2, 0x24, 0xA2, 0x08, 0x6C, 0x27, 0x06, 0x21, + 0xB7, 0x0C, 0xB6, 0x26, 0x19, 0xF3, 0xA9, 0x16, 0xBD, 0xF2, 0x75, 0x04, + 0x55, 0x05, 0xED, 0x01, 0xD1, 0x0E, 0xE5, 0x06, 0xCB, 0xFE, 0xD9, 0xF7, + 0xE9, 0xE7, 0x97, 0xE6, 0xBD, 0xE9, 0x30, 0xDE, 0x83, 0xF2, 0xD8, 0xE3, + 0x59, 0x01, 0x21, 0xF3, 0x37, 0x1B, 0x2F, 0xFF, 0x3A, 0x30, 0x8D, 0x15, + 0xB1, 0x2B, 0xD7, 0x2B, 0x4D, 0x08, 0x67, 0x25, 0xE4, 0xEA, 0xFC, 0x09, + 0x2D, 0xE8, 0x5B, 0xF6, 0x35, 0xF6, 0x42, 0xF5, 0x27, 0xFC, 0x8A, 0xF4, + 0x6B, 0xF0, 0x47, 0xE7, 0xA9, 0xE9, 0x13, 0xE4, 0x51, 0xEA, 0x0B, 0xE9, + 0xFE, 0xF1, 0x15, 0xF1, 0x58, 0x0A, 0xC6, 0xF8, 0x0C, 0x27, 0x5D, 0x09, + 0xE3, 0x2D, 0x4A, 0x1F, 0xFA, 0x16, 0xC4, 0x28, 0xFC, 0xEE, 0x83, 0x12, + 0x51, 0xDA, 0x56, 0xF8, 0x07, 0xE3, 0xA1, 0xEE, 0x98, 0xF4, 0xF8, 0xE9, + 0xEC, 0xFC, 0x98, 0xEB, 0x1A, 0xFC, 0x5A, 0xEA, 0x8E, 0x03, 0xA7, 0xF9, + 0xBC, 0xF9, 0x2C, 0xFE, 0xAD, 0xF9, 0x13, 0xFB, 0x85, 0x11, 0xDB, 0x01, + 0xCE, 0x2F, 0x4A, 0x1A, 0xC3, 0x2E, 0xAE, 0x2C, 0x66, 0x05, 0x22, 0x1D, + 0x2B, 0xE6, 0xBE, 0x02, 0x58, 0xE0, 0x56, 0xF1, 0x29, 0xF0, 0x1C, 0xE8, + 0x59, 0x01, 0x02, 0xE9, 0x8A, 0x0A, 0x82, 0xEC, 0xD9, 0x10, 0xB3, 0xF5, + 0x1B, 0x09, 0x16, 0x04, 0xB6, 0xF6, 0x47, 0x02, 0x3B, 0xF4, 0xBA, 0xF7, + 0x31, 0x12, 0x61, 0x05, 0x70, 0x28, 0xE6, 0x1E, 0x16, 0x18, 0x21, 0x21, + 0x66, 0xF3, 0xDE, 0x0B, 0xF4, 0xDC, 0x41, 0xEE, 0xB1, 0xE4, 0x72, 0xE9, + 0x31, 0xEC, 0x0F, 0xE6, 0xA9, 0xFF, 0xF8, 0xE3, 0xF4, 0x0F, 0xBE, 0xE8, + 0xFA, 0x14, 0xB1, 0xFC, 0x73, 0x03, 0xD5, 0x08, 0x18, 0xF0, 0x2C, 0x03, + 0x59, 0xF5, 0x46, 0x00, 0x1B, 0x09, 0x97, 0x0C, 0x91, 0x13, 0x67, 0x1C, + 0x18, 0xFB, 0x0B, 0x0F, 0x66, 0xEA, 0xD2, 0x00, 0x25, 0xE2, 0x5A, 0xF2, + 0x39, 0xE0, 0x31, 0xE8, 0x12, 0xEE, 0x8C, 0xE1, 0x92, 0x08, 0x67, 0xE4, + 0x94, 0x20, 0x34, 0xFB, 0x08, 0x1D, 0x7A, 0x12, 0x59, 0x04, 0x2E, 0x16, + 0xE3, 0xF4, 0x84, 0x0B, 0xF3, 0xFB, 0x8D, 0x0B, 0xA0, 0x0C, 0x53, 0x14, + 0x88, 0x04, 0xE7, 0x0E, 0x8C, 0xF6, 0x10, 0x01, 0xDB, 0xEF, 0x8C, 0xF5, + 0x75, 0xE5, 0x9E, 0xEE, 0xAB, 0xE1, 0xCB, 0xE3, 0xEA, 0xF0, 0xD7, 0xDB, + 0xB9, 0x13, 0x62, 0xEC, 0xAE, 0x2A, 0xA6, 0x0E, 0x6D, 0x1F, 0x97, 0x22, + 0x2C, 0x01, 0xBC, 0x18, 0x84, 0xF2, 0x33, 0x0A, 0x5D, 0xF9, 0x27, 0x08, + 0x1F, 0x03, 0xC1, 0x06, 0x43, 0x02, 0x52, 0xFE, 0x5D, 0xF8, 0xAE, 0xF1, + 0x0D, 0xE8, 0x1E, 0xEA, 0x92, 0xDC, 0x65, 0xE7, 0x5F, 0xE0, 0x61, 0xE0, + 0x8A, 0xFC, 0xBE, 0xE4, 0x7D, 0x20, 0x3D, 0x01, 0xE5, 0x31, 0xDB, 0x27, + 0xE5, 0x17, 0x29, 0x2A, 0xB3, 0xFC, 0xE9, 0x19, 0xB8, 0xED, 0x67, 0x07, + 0x36, 0xEA, 0xF3, 0xFA, 0x77, 0xFA, 0x88, 0xF9, 0x76, 0x03, 0xB2, 0xF3, + 0x02, 0x03, 0xDF, 0xF4, 0x52, 0xF3, 0x6F, 0xF7, 0x4F, 0xE7, 0x82, 0xF1, + 0x25, 0xEF, 0x15, 0xE9, 0x90, 0x0E, 0x65, 0xF8, 0x4A, 0x2B, 0xCF, 0x1C, + 0xFA, 0x26, 0x85, 0x2E, 0xD2, 0x04, 0x2F, 0x22, 0x04, 0xEB, 0xB5, 0x0C, + 0x5E, 0xE3, 0x54, 0xFC, 0x80, 0xE8, 0x38, 0xF4, 0x3D, 0xF7, 0xA6, 0xEA, + 0x47, 0x07, 0x72, 0xEB, 0x7D, 0x06, 0x80, 0xF5, 0x87, 0xF7, 0xDF, 0xFB, + 0xB5, 0xE8, 0x0B, 0xEF, 0x33, 0xF8, 0x4A, 0xF1, 0xEA, 0x1E, 0x6C, 0x0E, + 0xB9, 0x23, 0xB0, 0x24, 0xEC, 0x16, 0x8D, 0x27, 0x46, 0xFF, 0xB3, 0x13, + 0x7A, 0xE2, 0x65, 0xFE, 0x4A, 0xD9, 0x96, 0xF3, 0xB1, 0xE1, 0xDC, 0xE7, + 0xA7, 0xF6, 0x26, 0xE0, 0x37, 0x09, 0x48, 0xEA, 0x58, 0x0D, 0x9C, 0x00, + 0x13, 0xFC, 0xB9, 0x02, 0xEC, 0xF6, 0xAF, 0xF8, 0x19, 0x10, 0x62, 0x0B, + 0xD1, 0x23, 0x34, 0x1E, 0x98, 0x27, 0xBF, 0x26, 0x2B, 0x18, 0x2E, 0x22, + 0x16, 0xFA, 0xFA, 0x11, 0x8A, 0xDE, 0xF1, 0x00, 0x11, 0xDA, 0x7F, 0xF1, + 0x8D, 0xE8, 0xFE, 0xDE, 0x8A, 0x04, 0x50, 0xE0, 0x07, 0x17, 0x6A, 0xF7, + 0x66, 0x15, 0xD6, 0x0B, 0x73, 0x04, 0x1C, 0x09, 0xDD, 0x07, 0xB4, 0x0A, + 0xCA, 0x12, 0x7B, 0x14, 0x8E, 0x10, 0xC0, 0x12, 0x18, 0x17, 0x51, 0x18, + 0xAC, 0x0A, 0x4A, 0x11, 0xBF, 0xEF, 0x6C, 0x05, 0xB1, 0xD6, 0x41, 0xF2, + 0x92, 0xCF, 0xED, 0xD6, 0x35, 0xE9, 0xC3, 0xCD, 0x4E, 0x09, 0x68, 0xE1, + 0xDA, 0x15, 0xAB, 0x01, 0xE6, 0x0F, 0xE2, 0x11, 0xB5, 0xFF, 0x3C, 0x0E, + 0x2B, 0xF9, 0x6D, 0x09, 0xB0, 0xFD, 0xDA, 0x0A, 0x5F, 0x0B, 0x4B, 0x11, + 0x81, 0x0B, 0xB5, 0x09, 0xBF, 0x00, 0xBB, 0x04, 0xBB, 0xE7, 0x45, 0xFB, + 0xAF, 0xD2, 0x12, 0xE7, 0x60, 0xD5, 0xE6, 0xCE, 0x95, 0xF7, 0x7E, 0xD7, + 0xA0, 0x16, 0xE2, 0xFC, 0xCD, 0x1E, 0x57, 0x18, 0xAD, 0x1E, 0x3F, 0x27, + 0x9C, 0x05, 0xA0, 0x19, 0xCC, 0xF8, 0x26, 0x12, 0x4E, 0xFD, 0x74, 0x10, + 0xDB, 0x06, 0x03, 0x08, 0xEB, 0x09, 0x00, 0x00, 0xB9, 0xFF, 0x73, 0xFF, + 0x0B, 0xED, 0xF2, 0xF9, 0x7D, 0xE2, 0xCC, 0xE4, 0xAA, 0xED, 0x56, 0xD6, + 0x51, 0x11, 0xD1, 0xF0, 0x8C, 0x26, 0x51, 0x0F, 0xC2, 0x27, 0x24, 0x1F, + 0xFE, 0x16, 0xB5, 0x20, 0xEE, 0xFB, 0x05, 0x16, 0xE0, 0xE9, 0xB2, 0x09, + 0x6B, 0xED, 0x93, 0xFC, 0x2B, 0xFC, 0x6D, 0xEF, 0xCF, 0x01, 0x67, 0xEE, + 0xF6, 0xF7, 0x81, 0xF3, 0x9A, 0xE4, 0xFB, 0xE5, 0x84, 0xEF, 0x44, 0xE0, + 0x8B, 0xFA, 0xEF, 0xDF, 0x9D, 0x08, 0x2E, 0xF3, 0x05, 0x1C, 0x71, 0x10, + 0xB2, 0x20, 0x36, 0x21, 0x62, 0x11, 0xA1, 0x23, 0x2A, 0xF5, 0xE6, 0x19, + 0xB8, 0xE2, 0xF1, 0x04, 0x57, 0xE6, 0x66, 0xEA, 0x4E, 0xF8, 0x0F, 0xE1, + 0x68, 0x02, 0x4C, 0xF0, 0xF5, 0xF9, 0x63, 0xF0, 0xE6, 0xF1, 0x02, 0xEE, + 0xE2, 0xF4, 0xCB, 0xF3, 0xF6, 0x02, 0x4F, 0xF8, 0x9C, 0x1B, 0x92, 0x0D, + 0x4F, 0x2B, 0x2D, 0x20, 0xA4, 0x24, 0x6F, 0x27, 0xCA, 0x07, 0x06, 0x22, + 0x39, 0xEA, 0x19, 0x13, 0x95, 0xDE, 0xDC, 0xF5, 0x2E, 0xEA, 0x39, 0xDF, + 0xD1, 0xF4, 0xF2, 0xDC, 0xF9, 0x00, 0x77, 0xEE, 0x1A, 0x07, 0x22, 0xFE, + 0x80, 0xFC, 0x29, 0xFC, 0xA0, 0xF3, 0x33, 0xF3, 0xD7, 0xFC, 0x99, 0xFA, + 0x31, 0x17, 0x99, 0x0E, 0x8C, 0x24, 0x54, 0x1A, 0x12, 0x15, 0xC1, 0x1B, + 0x70, 0xF5, 0x90, 0x13, 0xDA, 0xDE, 0xB7, 0xFC, 0x81, 0xDC, 0x18, 0xDC, + 0x4E, 0xEE, 0x9F, 0xD5, 0x2B, 0x00, 0x53, 0xDF, 0x71, 0x08, 0xA9, 0xF1, + 0x8B, 0x08, 0x34, 0x02, 0x23, 0x01, 0x20, 0x05, 0x91, 0xFD, 0xCB, 0x08, + 0x7F, 0x07, 0x4E, 0x10, 0x62, 0x18, 0x34, 0x13, 0x14, 0x1D, 0x54, 0x15, + 0xAC, 0x0B, 0x09, 0x18, 0x65, 0xEA, 0xEA, 0x09, 0xC8, 0xDE, 0x72, 0xEA, + 0x3D, 0xE7, 0xC4, 0xD7, 0xEE, 0xF7, 0xC8, 0xDC, 0x24, 0x0F, 0xFB, 0xF1, + 0x52, 0x19, 0x58, 0x08, 0x7E, 0x15, 0x82, 0x11, 0x01, 0x08, 0xD3, 0x14, + 0x0A, 0x03, 0x4D, 0x17, 0xA9, 0x06, 0xB0, 0x10, 0x29, 0x0C, 0x14, 0x05, + 0xDD, 0x08, 0xD7, 0x0A, 0x0F, 0xF2, 0x76, 0xFF, 0x35, 0xDF, 0x4A, 0xF2, + 0xC3, 0xDD, 0x52, 0xE9, 0xC7, 0xE3, 0x7B, 0xD4, 0x61, 0xF7, 0xCE, 0xD5, + 0x13, 0x12, 0x14, 0xED, 0xE3, 0x1C, 0x9F, 0x04, 0xEE, 0x11, 0xFB, 0x11, + 0x63, 0xFE, 0x07, 0x19, 0x22, 0xF8, 0x32, 0x17, 0xD0, 0xFC, 0xAC, 0x09, + 0xFD, 0xFF, 0xB6, 0xFD, 0x31, 0xF1, 0x04, 0xFA, 0x88, 0xE5, 0x67, 0xF6, + 0x29, 0xE7, 0x06, 0xF4, 0x3E, 0xE5, 0x03, 0xE3, 0xA6, 0xEB, 0x93, 0xD8, + 0x6F, 0x02, 0x75, 0xE5, 0x5E, 0x1E, 0xB6, 0x00, 0x12, 0x29, 0x9A, 0x1B, + 0x4D, 0x18, 0xB6, 0x2A, 0x73, 0x01, 0x65, 0x2A, 0x5B, 0xFD, 0x36, 0x17, + 0xC4, 0xFE, 0xBC, 0x06, 0xE0, 0xFF, 0x96, 0xF9, 0x60, 0xFF, 0x4B, 0xF7, + 0x4F, 0xF7, 0x5A, 0xFC, 0xD8, 0xEC, 0xA6, 0xF2, 0x8E, 0xEB, 0x20, 0xE9, + 0x4C, 0xFA, 0x47, 0xEB, 0x07, 0x13, 0xBD, 0xF9, 0x6F, 0x26, 0x74, 0x0B, + 0x5B, 0x24, 0xA4, 0x1E, 0xAB, 0x0C, 0xB8, 0x29, 0x36, 0xF8, 0x56, 0x18, + 0xE2, 0xF0, 0xEC, 0xFE, 0x84, 0xED, 0x55, 0xE7, 0x91, 0xF5, 0x32, 0xE1, + 0x94, 0xFA, 0x64, 0xEC, 0x59, 0xF3, 0xF2, 0xED, 0xFC, 0xE9, 0x9C, 0xE8, + 0x0F, 0xEB, 0x2B, 0xE8, 0xBE, 0xFE, 0xCF, 0xF5, 0x28, 0x17, 0x5E, 0x03, + 0x9F, 0x1E, 0x82, 0x10, 0x77, 0x0E, 0xAB, 0x22, 0x3A, 0xF6, 0xCB, 0x1B, + 0x89, 0xE8, 0x12, 0x0A, 0x0C, 0xE6, 0x83, 0xF4, 0xDD, 0xEC, 0x03, 0xDF, + 0x49, 0xF8, 0x1D, 0xE1, 0x2F, 0x02, 0xC2, 0xEF, 0x2B, 0x01, 0xD5, 0xF8, + 0x5B, 0xF7, 0x41, 0xFD, 0xAD, 0xFA, 0xB6, 0x08, 0x4B, 0x14, 0xF1, 0x17, + 0xE6, 0x2A, 0xC5, 0x20, 0xE6, 0x1C, 0xE2, 0x28, 0x85, 0x09, 0x4F, 0x2B, + 0xDA, 0xF7, 0xDA, 0x1C, 0x82, 0xEA, 0x2E, 0x05, 0x2F, 0xEB, 0x80, 0xE9, + 0x62, 0xF1, 0x0E, 0xDD, 0x24, 0xFF, 0xF3, 0xE3, 0xFD, 0x06, 0x91, 0xEE, + 0x87, 0x04, 0x06, 0xFB, 0x48, 0xFD, 0x8C, 0x0A, 0x38, 0x08, 0xBC, 0x12, + 0xD1, 0x17, 0x34, 0x1D, 0x99, 0x1C, 0x1E, 0x1A, 0xB3, 0x13, 0x90, 0x0F, + 0xA1, 0xFB, 0x4A, 0x10, 0xFE, 0xE3, 0x60, 0x07, 0x29, 0xD9, 0x79, 0xEF, + 0x90, 0xDE, 0xBA, 0xD9, 0xD5, 0xEF, 0x56, 0xD6, 0x49, 0x05, 0x08, 0xDE, + 0x71, 0x0D, 0x35, 0xEB, 0x68, 0x09, 0x16, 0x01, 0x71, 0x08, 0x1F, 0x17, + 0x50, 0x14, 0xC8, 0x1B, 0x40, 0x19, 0x05, 0x16, 0x8C, 0x10, 0xF7, 0x09, + 0x10, 0x05, 0x5B, 0x0C, 0x12, 0xF7, 0x8D, 0x11, 0x05, 0xE9, 0x2F, 0x04, + 0x2D, 0xDF, 0x0B, 0xEB, 0xF4, 0xE8, 0x25, 0xE0, 0x7D, 0x07, 0x57, 0xE8, + 0x55, 0x1D, 0x42, 0xF6, 0xE2, 0x19, 0xC6, 0x0B, 0x92, 0x15, 0xBC, 0x20, + 0xC6, 0x0F, 0xDF, 0x2B, 0x3F, 0x0B, 0x4C, 0x24, 0x04, 0x10, 0x1D, 0x12, + 0xB3, 0x0A, 0xA0, 0x04, 0x65, 0x02, 0xFE, 0x05, 0x9A, 0xF4, 0x52, 0x01, + 0xC5, 0xE4, 0x6F, 0xF1, 0x1E, 0xDF, 0xB0, 0xE3, 0x0D, 0xF0, 0xDF, 0xE3, + 0xB4, 0x0D, 0xE0, 0xEA, 0xAA, 0x18, 0x8A, 0x04, 0x2A, 0x15, 0xD2, 0x18, + 0x50, 0x08, 0x2A, 0x1D, 0x05, 0xFC, 0xCE, 0x1E, 0xAC, 0xFB, 0xA8, 0x0D, + 0x89, 0xFF, 0x7E, 0xFD, 0x7D, 0x00, 0x01, 0xF7, 0x50, 0xF8, 0xA9, 0xF1, + 0xBB, 0xEA, 0x56, 0xE6, 0x00, 0xE0, 0xAE, 0xDF, 0x4F, 0xE8, 0xFA, 0xE1, + 0x2C, 0x03, 0x0C, 0xF2, 0x46, 0x1B, 0xBF, 0xFF, 0x37, 0x23, 0x93, 0x0A, + 0x20, 0x1A, 0x14, 0x1E, 0x58, 0x0B, 0xB5, 0x2F, 0x69, 0xFF, 0x19, 0x29, + 0xEF, 0xF9, 0xA0, 0x0F, 0x4C, 0xFC, 0xF8, 0xFA, 0xCD, 0x03, 0xEF, 0xF2, + 0xC1, 0x01, 0xCB, 0xEC, 0xE2, 0xF4, 0x53, 0xE5, 0x8A, 0xEC, 0x39, 0xEB, + 0x12, 0x05, 0x97, 0xF6, 0xB6, 0x1F, 0x7B, 0x06, 0xC3, 0x26, 0x84, 0x0F, + 0x3A, 0x22, 0xEF, 0x16, 0x2D, 0x13, 0xEF, 0x26, 0x54, 0x04, 0xD1, 0x2A, + 0xEB, 0xF5, 0xD8, 0x16, 0xCB, 0xED, 0x9A, 0xF8, 0x3F, 0xF1, 0x31, 0xE7, + 0x4E, 0xFB, 0xD4, 0xDF, 0x16, 0xF3, 0x2B, 0xDA, 0xC2, 0xF0, 0x54, 0xDF, + 0x35, 0xEF, 0x62, 0xEB, 0x80, 0xF7, 0x0D, 0xFE, 0xF4, 0x12, 0xBD, 0x06, + 0x15, 0x26, 0xC5, 0x09, 0xF3, 0x20, 0xD4, 0x15, 0x50, 0x08, 0x29, 0x20, + 0x5E, 0xF1, 0xED, 0x15, 0x8E, 0xE1, 0xE0, 0xFB, 0x99, 0xDF, 0x31, 0xE7, + 0x27, 0xEB, 0x70, 0xDC, 0x36, 0xF8, 0x3C, 0xD9, 0xA8, 0xF2, 0x28, 0xE2, + 0xD6, 0xF0, 0x53, 0xFB, 0x70, 0xFF, 0xED, 0x0C, 0xCB, 0x1A, 0x6B, 0x11, + 0xFC, 0x28, 0x89, 0x1A, 0xCC, 0x1F, 0x47, 0x29, 0xEE, 0x11, 0x5C, 0x26, + 0x53, 0xFE, 0x9F, 0x15, 0x1F, 0xE9, 0x8F, 0xFB, 0x87, 0xE1, 0xCD, 0xE9, + 0x22, 0xF1, 0x9A, 0xE5, 0x91, 0x04, 0x58, 0xE2, 0x3D, 0x09, 0x30, 0xE5, + 0x6D, 0x05, 0x59, 0xFB, 0x32, 0x06, 0xA6, 0x12, 0xC8, 0x13, 0xFA, 0x1D, + 0x60, 0x1E, 0x19, 0x21, 0x69, 0x18, 0x17, 0x13, 0xF7, 0x0B, 0xCC, 0x0B, + 0x05, 0xFE, 0xDD, 0x06, 0x01, 0xE9, 0xF6, 0xF6, 0x3D, 0xD4, 0x07, 0xE3, + 0x21, 0xD8, 0x6E, 0xD8, 0x65, 0xEE, 0xF5, 0xD1, 0x4A, 0x05, 0xF1, 0xD3, + 0xB7, 0x04, 0x5A, 0xE3, 0xDF, 0x01, 0x3D, 0x01, 0x45, 0x0A, 0x01, 0x16, + 0xB2, 0x0A, 0xFD, 0x17, 0xA5, 0x09, 0x94, 0x0F, 0x9E, 0x06, 0x17, 0x06, + 0xBB, 0x04, 0x85, 0x03, 0x75, 0xF8, 0x7D, 0xF9, 0x71, 0xE3, 0xF8, 0xED, + 0xA8, 0xD5, 0x4C, 0xE2, 0xE4, 0xE2, 0x40, 0xDF, 0x9B, 0xFF, 0xF7, 0xDF, + 0xBA, 0x10, 0x2E, 0xEF, 0x41, 0x12, 0xEC, 0x0A, 0x7F, 0x10, 0xB8, 0x24, + 0xC8, 0x0D, 0x45, 0x2B, 0x57, 0x08, 0xE1, 0x1E, 0xE4, 0x06, 0xF8, 0x11, + 0x0F, 0x08, 0xE7, 0x0A, 0x5F, 0x05, 0xD5, 0x00, 0x84, 0xF2, 0xFD, 0xEF, + 0x8D, 0xDC, 0xA5, 0xE4, 0xE4, 0xD9, 0xFB, 0xE3, 0x3A, 0xF2, 0x8C, 0xE3, + 0x11, 0x0A, 0x67, 0xEA, 0x05, 0x16, 0x79, 0x07, 0x3A, 0x14, 0xED, 0x15, + 0xBC, 0x0B, 0x7B, 0x1E, 0x4A, 0x00, 0x5F, 0x1B, 0xED, 0xF4, 0xD3, 0x0C, + 0x2A, 0xF7, 0x1B, 0x03, 0xF1, 0xFE, 0x00, 0xF8, 0x1D, 0xFA, 0xA3, 0xE6, + 0x2C, 0xE3, 0x8B, 0xD7, 0xF2, 0xD5, 0xE9, 0xD6, 0x76, 0xE6, 0x1F, 0xE2, + 0xBE, 0x07, 0xEE, 0xF1, 0x87, 0x16, 0x87, 0xFC, 0x2F, 0x19, 0xDC, 0x0C, + 0x63, 0x16, 0x13, 0x22, 0x7B, 0x0C, 0xFC, 0x2B, 0x0F, 0xFD, 0x0C, 0x22, + 0x11, 0xF4, 0x5A, 0x11, 0x42, 0xF9, 0x39, 0x01, 0x29, 0x04, 0xD0, 0xEF, + 0x40, 0xF8, 0xF8, 0xDF, 0xD4, 0xE7, 0xE7, 0xE0, 0x37, 0xF0, 0x37, 0xEB, + 0x14, 0xFB, 0x3A, 0xFD, 0xB0, 0x10, 0xB8, 0x0C, 0x4F, 0x24, 0xD3, 0x17, + 0x48, 0x2A, 0x8B, 0x27, 0x8E, 0x1F, 0x97, 0x2D, 0x9D, 0x08, 0xEE, 0x25, + 0x62, 0xF0, 0x68, 0x15, 0x2B, 0xE7, 0x6F, 0x02, 0x4C, 0xF0, 0x56, 0xEB, + 0xBF, 0xF5, 0x79, 0xD9, 0x22, 0xEC, 0x66, 0xD7, 0x04, 0xE6, 0xC7, 0xE3, + 0x8C, 0xEC, 0x72, 0xF6, 0x3E, 0xFC, 0xA9, 0x02, 0x33, 0x12, 0x83, 0x0A, + 0x00, 0x20, 0x18, 0x18, 0xC3, 0x22, 0x25, 0x22, 0x1E, 0x10, 0xA0, 0x1C, + 0xD6, 0xEE, 0x0C, 0x08, 0x67, 0xD9, 0x4F, 0xF7, 0x08, 0xE1, 0x4C, 0xE8, + 0xA7, 0xEF, 0x38, 0xD8, 0xA4, 0xEF, 0xB1, 0xD3, 0x0B, 0xF5, 0x95, 0xDF, + 0xB1, 0xFA, 0x98, 0xF9, 0x51, 0x01, 0xA7, 0x0E, 0x56, 0x0E, 0x4B, 0x18, + 0x26, 0x1B, 0xF3, 0x20, 0x45, 0x27, 0x54, 0x29, 0x11, 0x25, 0x8C, 0x28, + 0xAA, 0x08, 0x64, 0x14, 0xF3, 0xE7, 0x15, 0x02, 0x97, 0xDE, 0x0F, 0xF0, + 0x17, 0xEC, 0xD0, 0xDF, 0x73, 0x02, 0x64, 0xE3, 0x8C, 0x0C, 0xB3, 0xEC, + 0x69, 0x08, 0x2B, 0xFC, 0x63, 0x03, 0x59, 0x0E, 0x27, 0x09, 0x62, 0x1B, + 0x3D, 0x0F, 0x84, 0x21, 0xE6, 0x19, 0xA8, 0x24, 0xEC, 0x1D, 0x94, 0x1F, + 0x45, 0x13, 0x92, 0x0E, 0xAB, 0xEF, 0x19, 0xF8, 0x55, 0xD6, 0x62, 0xE4, + 0x44, 0xDD, 0xDA, 0xD4, 0x5D, 0xEA, 0x51, 0xD6, 0x32, 0xFE, 0x2F, 0xDE, + 0x52, 0x07, 0x00, 0xEA, 0x3F, 0x07, 0xC0, 0xFD, 0x8D, 0x03, 0xF7, 0x0C, + 0xC4, 0x00, 0x93, 0x15, 0xAD, 0x03, 0xD5, 0x1A, 0xB9, 0x0B, 0xE5, 0x16, + 0x2D, 0x0B, 0xF3, 0x07, 0x81, 0xF7, 0x39, 0xF3, 0xC4, 0xDA, 0xE0, 0xDE, + 0x55, 0xD4, 0x7B, 0xDF, 0xD7, 0xE1, 0xDA, 0xE4, 0xEF, 0xFB, 0x19, 0xE8, + 0x4D, 0x12, 0xCF, 0xF0, 0xD4, 0x1E, 0xB1, 0x07, 0x33, 0x1D, 0x1E, 0x1D, + 0x60, 0x13, 0xAB, 0x28, 0xBF, 0x03, 0xAC, 0x28, 0x6F, 0x05, 0x66, 0x25, + 0x7A, 0x0D, 0xCB, 0x17, 0xC7, 0xFD, 0xF0, 0xFE, 0x79, 0xFA, 0x7C, 0xF2, + 0x20, 0xEB, 0xAC, 0xEB, 0x7F, 0xDE, 0xC8, 0xE9, 0x07, 0xE8, 0xB0, 0xE8, + 0x27, 0x00, 0x68, 0xEE, 0x7A, 0x17, 0x56, 0xFF, 0x17, 0x25, 0x1A, 0x16, + 0x13, 0x23, 0xA3, 0x23, 0x7F, 0x0C, 0x33, 0x22, 0x25, 0xFB, 0xCC, 0x19, + 0x3F, 0xFC, 0x58, 0x0A, 0x7F, 0xFE, 0x12, 0xF2, 0xF0, 0xFB, 0x77, 0xE1, + 0x63, 0xEC, 0x70, 0xD7, 0xCF, 0xD4, 0xFD, 0xD1, 0x46, 0xD2, 0xB3, 0xD3, + 0xF3, 0xE4, 0x69, 0xDD, 0xEE, 0x03, 0x54, 0xF3, 0xE8, 0x1C, 0xBC, 0x0D, + 0xE0, 0x29, 0xAE, 0x1F, 0xC1, 0x18, 0x88, 0x23, 0x45, 0xFC, 0x5F, 0x1B, + 0x30, 0xF5, 0xB5, 0x0A, 0xCA, 0xF3, 0x40, 0xFD, 0xD1, 0xFE, 0x59, 0xF1, + 0xEE, 0x03, 0x2F, 0xE6, 0xA8, 0xF5, 0xDF, 0xE2, 0x35, 0xEB, 0xBD, 0xE8, + 0xC8, 0xF0, 0x25, 0xF5, 0xE2, 0x03, 0xC5, 0x06, 0x48, 0x1C, 0x86, 0x1E, + 0xE4, 0x33, 0x21, 0x33, 0xCE, 0x2C, 0x0A, 0x36, 0xCF, 0x0D, 0x99, 0x29, + 0xA8, 0xF1, 0xB9, 0x15, 0x43, 0xE7, 0x63, 0x03, 0xBA, 0xF3, 0x6B, 0xF3, + 0x9A, 0x03, 0x11, 0xE4, 0x28, 0x00, 0xCF, 0xDD, 0x3C, 0xF6, 0xD4, 0xE2, + 0x0D, 0xEE, 0x6A, 0xEB, 0x8F, 0xF3, 0xC1, 0xF9, 0xBA, 0x00, 0xF9, 0x0C, + 0x2F, 0x1A, 0x6F, 0x1F, 0xB8, 0x22, 0xA2, 0x23, 0x98, 0x07, 0x69, 0x18, + 0x34, 0xF1, 0xD4, 0x01, 0xFF, 0xD9, 0x80, 0xEE, 0xC7, 0xD3, 0x51, 0xDE, + 0xE7, 0xE4, 0xA5, 0xD2, 0xF8, 0xF6, 0xC3, 0xD2, 0x4C, 0xFD, 0x83, 0xDC, + 0xD8, 0x00, 0x49, 0xEF, 0x58, 0xFE, 0x13, 0xFF, 0x69, 0x07, 0x42, 0x17, + 0x04, 0x19, 0x7B, 0x29, 0x13, 0x29, 0x00, 0x32, 0xA7, 0x28, 0x42, 0x26, + 0xE0, 0x16, 0x97, 0x15, 0x64, 0xF5, 0x7B, 0x05, 0x6B, 0xDB, 0xB2, 0xF4, + 0xA9, 0xDF, 0x06, 0xE7, 0xC1, 0xF7, 0xD4, 0xE5, 0x93, 0x10, 0xF0, 0xF2, + 0xE8, 0x19, 0x5D, 0xFE, 0xF7, 0x16, 0x8B, 0x0C, 0xA3, 0x12, 0xD6, 0x1F, + 0xFE, 0x1E, 0xA9, 0x33, 0xF8, 0x19, 0x1F, 0x30, 0x89, 0x1D, 0x86, 0x24, + 0x7F, 0x1C, 0x1A, 0x11, 0x68, 0x05, 0xFC, 0x00, 0xC8, 0xE3, 0xDC, 0xED, + 0xCB, 0xD4, 0xAF, 0xDF, 0x9A, 0xDE, 0x4C, 0xD7, 0xFC, 0xEA, 0xB9, 0xD5, + 0x72, 0xFE, 0x28, 0xE2, 0x9A, 0x10, 0xEE, 0xFC, 0x9E, 0x0F, 0x5B, 0x15, + 0x92, 0x04, 0x95, 0x1A, 0x1A, 0xFC, 0xDC, 0x19, 0xAF, 0xFB, 0x82, 0x10, + 0x67, 0x11, 0xA9, 0x0C, 0xDA, 0x0D, 0xEA, 0xFE, 0xDE, 0xF8, 0x0F, 0xF2, + 0x1B, 0xDF, 0xFC, 0xE2, 0x18, 0xD4, 0x9E, 0xD3, 0xC8, 0xDE, 0x06, 0xD7, + 0xAF, 0xFE, 0xA3, 0xEB, 0x35, 0x1D, 0x4D, 0x0A, 0x59, 0x26, 0xE7, 0x26, + 0x9B, 0x26, 0x97, 0x31, 0xFC, 0x0A, 0x00, 0x28, 0x9B, 0xF8, 0x10, 0x1F, + 0x4C, 0x02, 0xB1, 0x15, 0x9F, 0x15, 0x6F, 0x0F, 0x03, 0x14, 0xFE, 0x03, + 0x12, 0xF6, 0xA5, 0xEC, 0x6E, 0xE7, 0x89, 0xE3, 0x75, 0xE7, 0x3C, 0xE3, + 0x87, 0xFA, 0x25, 0xF4, 0x74, 0x1F, 0xF4, 0x12, 0x8F, 0x2E, 0x78, 0x21, + 0xAD, 0x2C, 0x7C, 0x26, 0xA0, 0x15, 0xF3, 0x24, 0x9B, 0xF2, 0xBC, 0x19, + 0xAE, 0xE9, 0x73, 0x0C, 0x90, 0xFD, 0x4A, 0x02, 0x5C, 0x02, 0x06, 0xEE, + 0x91, 0xF6, 0xB1, 0xDA, 0xDB, 0xE3, 0x40, 0xCD, 0x09, 0xDD, 0x73, 0xCE, + 0xDB, 0xF0, 0x28, 0xE4, 0x0A, 0xFA, 0x16, 0xF7, 0xAF, 0x0C, 0x5D, 0x08, + 0x8B, 0x29, 0xE7, 0x1A, 0x9C, 0x2B, 0x33, 0x23, 0xFE, 0x0C, 0xF7, 0x1F, + 0x90, 0xEF, 0x4F, 0x12, 0x3B, 0xE9, 0x04, 0xFE, 0x7A, 0xF0, 0xC0, 0xEA, + 0x9B, 0xF3, 0x61, 0xDD, 0x8B, 0xF0, 0xC3, 0xD7, 0x28, 0xF1, 0x7C, 0xDF, + 0x63, 0xEE, 0xA5, 0xED, 0xD4, 0xF5, 0xF9, 0x00, 0x90, 0x0B, 0x22, 0x19, + 0x2D, 0x2B, 0xFF, 0x2B, 0xFF, 0x3E, 0x24, 0x37, 0x5E, 0x2C, 0x7A, 0x32, + 0xCE, 0x03, 0xDD, 0x1F, 0xC7, 0xEA, 0xBD, 0x06, 0x48, 0xE2, 0x09, 0xEB, + 0x0C, 0xEA, 0x62, 0xDC, 0x5F, 0xF7, 0xB6, 0xDC, 0xE4, 0xF4, 0xE1, 0xDE, + 0x3E, 0xFC, 0xC0, 0xED, 0xD7, 0xFB, 0x8D, 0xFD, 0xD4, 0xF5, 0xAD, 0x09, + 0xDE, 0x0A, 0x20, 0x1A, 0x44, 0x2B, 0xAF, 0x26, 0x4F, 0x2F, 0x5C, 0x25, + 0x92, 0x0F, 0x6F, 0x14, 0x1B, 0xE7, 0x02, 0xF4, 0x91, 0xD4, 0x67, 0xD9, + 0xB9, 0xD7, 0x53, 0xCB, 0xE4, 0xE4, 0x79, 0xC7, 0x0C, 0xF5, 0x18, 0xD4, + 0x0E, 0x02, 0xC0, 0xE4, 0x74, 0x04, 0xC9, 0xF5, 0x3F, 0xF8, 0xA6, 0x05, + 0x93, 0xFA, 0x6D, 0x14, 0xA3, 0x13, 0x73, 0x20, 0x0F, 0x2E, 0x20, 0x28, + 0x3B, 0x23, 0xD1, 0x1E, 0xF7, 0x00, 0x62, 0x04, 0x74, 0xE3, 0x01, 0xEA, + 0x21, 0xDC, 0xC2, 0xDA, 0x1A, 0xE9, 0xF9, 0xD5, 0x7B, 0xF8, 0x93, 0xE5, + 0x25, 0x0C, 0x31, 0xF6, 0x6F, 0x1D, 0x46, 0x08, 0x33, 0x18, 0x86, 0x1B, + 0x72, 0x03, 0xFA, 0x22, 0x29, 0x02, 0xC2, 0x23, 0xF9, 0x12, 0xA5, 0x20, + 0xE3, 0x1E, 0xF1, 0x1D, 0x33, 0x0E, 0x1E, 0x0C, 0x65, 0xED, 0x9F, 0xEC, + 0x2D, 0xD5, 0xB3, 0xD0, 0x35, 0xD4, 0xB8, 0xCF, 0x68, 0xE1, 0x41, 0xDB, + 0x93, 0xF9, 0x24, 0xE7, 0xDB, 0x15, 0x34, 0xF6, 0x4D, 0x1B, 0xEC, 0x07, + 0x41, 0x07, 0xAE, 0x14, 0xEA, 0xF2, 0xE5, 0x13, 0x52, 0xF2, 0x20, 0x0C, + 0xF6, 0x01, 0xD2, 0x08, 0x45, 0x01, 0x5B, 0xFA, 0x63, 0xE8, 0x69, 0xDE, + 0x58, 0xDF, 0xDC, 0xD1, 0x30, 0xDB, 0xFC, 0xCF, 0x3B, 0xD5, 0xC5, 0xD3, + 0xD8, 0xE2, 0xB8, 0xDF, 0xEF, 0x06, 0x9D, 0xF3, 0xCB, 0x2A, 0xDB, 0x11, + 0x1B, 0x2C, 0x4C, 0x28, 0xEF, 0x11, 0x3A, 0x2B, 0xA5, 0xFF, 0x33, 0x21, + 0xBB, 0x00, 0x1B, 0x14, 0xF5, 0x04, 0x31, 0x07, 0x20, 0xFF, 0xCA, 0xF0, + 0xD9, 0xFC, 0x5C, 0xE9, 0x5C, 0xFA, 0xA0, 0xE9, 0x47, 0xE8, 0xA3, 0xE5, + 0x5C, 0xDC, 0xA4, 0xE6, 0x6D, 0xF4, 0xF1, 0xF6, 0x9C, 0x26, 0x22, 0x17, + 0x16, 0x3D, 0xC1, 0x30, 0x88, 0x26, 0x1F, 0x32, 0x51, 0x02, 0x48, 0x20, + 0xE3, 0xF4, 0x2D, 0x0E, 0x25, 0xF6, 0x3D, 0xFA, 0xD6, 0xF4, 0x91, 0xEC, + 0x03, 0xF6, 0x57, 0xE2, 0x3C, 0xF6, 0x8B, 0xD7, 0x22, 0xEA, 0x20, 0xD2, + 0x93, 0xD8, 0x6F, 0xD8, 0x35, 0xDD, 0x16, 0xE8, 0xEA, 0x00, 0x64, 0x01, + 0x58, 0x26, 0xE1, 0x1B, 0x80, 0x27, 0x07, 0x29, 0xCA, 0x0D, 0xAA, 0x20, + 0x70, 0xF3, 0xAA, 0x09, 0xB0, 0xE5, 0x4F, 0xF4, 0x58, 0xE3, 0xA5, 0xE5, + 0xAA, 0xED, 0xE4, 0xE0, 0xDF, 0xFB, 0x70, 0xDB, 0x9F, 0x03, 0x95, 0xDF, + 0xDB, 0xF7, 0x1A, 0xEB, 0x46, 0xED, 0x10, 0xFD, 0x5B, 0xFB, 0xED, 0x0F, + 0xDC, 0x1E, 0xFB, 0x25, 0x94, 0x34, 0x10, 0x39, 0x83, 0x23, 0x1D, 0x34, + 0xCA, 0x10, 0x61, 0x24, 0xB5, 0xF8, 0x6A, 0x09, 0x18, 0xE2, 0x1E, 0xEF, + 0x3D, 0xDB, 0x33, 0xE0, 0x3B, 0xEE, 0xF5, 0xDE, 0xE0, 0x08, 0x55, 0xE6, + 0x06, 0x0F, 0x86, 0xF4, 0xC6, 0x03, 0xAA, 0x06, 0x0C, 0xFD, 0xA4, 0x13, + 0xB3, 0x0F, 0x9C, 0x20, 0xEB, 0x24, 0x6A, 0x2D, 0xC7, 0x28, 0x91, 0x30, + 0x58, 0x19, 0xE8, 0x1E, 0x16, 0xFE, 0xAD, 0xFF, 0x7F, 0xDC, 0x3A, 0xDF, + 0x57, 0xC5, 0x81, 0xCB, 0x4B, 0xCB, 0x07, 0xC8, 0x0F, 0xEF, 0x67, 0xD3, + 0x47, 0x0F, 0xC8, 0xE7, 0x3B, 0x12, 0x5C, 0xFF, 0x0D, 0x03, 0x09, 0x0E, + 0x3A, 0x02, 0x0F, 0x19, 0x14, 0x18, 0x9A, 0x29, 0x5B, 0x1B, 0x66, 0x23, + 0x3D, 0x16, 0x2C, 0x17, 0x86, 0x0D, 0xDB, 0x07, 0x63, 0xF8, 0x17, 0xF1, + 0x41, 0xDB, 0x25, 0xDE, 0x00, 0xCD, 0x2A, 0xD6, 0x30, 0xE3, 0x4B, 0xDC, + 0x0A, 0x0B, 0x09, 0xEE, 0x4E, 0x22, 0xFE, 0x09, 0xE0, 0x1D, 0xF2, 0x23, + 0x6F, 0x17, 0x14, 0x33, 0x2C, 0x0D, 0xD6, 0x2D, 0x15, 0x0B, 0x7C, 0x23, + 0xBC, 0x0F, 0x7B, 0x1C, 0xD7, 0x16, 0xEA, 0x14, 0x76, 0x11, 0x78, 0x02, + 0x18, 0xF9, 0xA7, 0xEE, 0xF5, 0xD8, 0x03, 0xDF, 0x94, 0xCF, 0x97, 0xD6, + 0x95, 0xEB, 0x58, 0xDF, 0xD8, 0x13, 0xC4, 0xFD, 0xC5, 0x23, 0x7B, 0x1D, + 0x17, 0x17, 0xCE, 0x2B, 0x5E, 0x08, 0xBD, 0x23, 0x47, 0xF8, 0xB7, 0x0F, + 0x4F, 0xF6, 0x6F, 0x06, 0xEE, 0xFB, 0xC2, 0xFE, 0x0E, 0x08, 0xE2, 0xF4, + 0x93, 0x02, 0x7B, 0xE5, 0x96, 0xE6, 0xE6, 0xD6, 0x0B, 0xCD, 0xB1, 0xCF, + 0x79, 0xD9, 0x65, 0xD6, 0x26, 0x05, 0xAA, 0xF4, 0x2B, 0x26, 0x66, 0x1E, + 0xFD, 0x2E, 0xBC, 0x2E, 0x7C, 0x1D, 0x68, 0x2A, 0x03, 0x08, 0xDC, 0x1E, + 0xB3, 0xF5, 0x23, 0x11, 0xD9, 0xF2, 0x5C, 0x08, 0x75, 0x01, 0x47, 0xFD, + 0x74, 0x0D, 0x02, 0xEF, 0xC7, 0x08, 0x69, 0xE9, 0x2B, 0xEC, 0x46, 0xE4, + 0x7F, 0xE4, 0x91, 0xE9, 0xA7, 0x05, 0x00, 0x06, 0xDC, 0x1D, 0xAE, 0x19, + 0x10, 0x2D, 0x81, 0x2C, 0xB1, 0x32, 0x44, 0x3B, 0x01, 0x22, 0x6A, 0x34, + 0x45, 0x06, 0xD1, 0x1F, 0x53, 0xE9, 0x72, 0x06, 0x26, 0xE4, 0x72, 0xEF, + 0xFC, 0xF5, 0xCF, 0xE0, 0x9C, 0x03, 0x0A, 0xDB, 0x24, 0xF3, 0x57, 0xDA, + 0x2A, 0xE1, 0x27, 0xDF, 0xB8, 0xEC, 0x0E, 0xF1, 0x38, 0xFA, 0x17, 0x00, + 0x9E, 0x10, 0x5D, 0x13, 0xDB, 0x22, 0x72, 0x25, 0xFE, 0x23, 0xBF, 0x26, + 0xF9, 0x0F, 0xC5, 0x17, 0x6B, 0xEA, 0xDD, 0xFC, 0xE6, 0xCF, 0x40, 0xE3, + 0x1C, 0xD3, 0xB8, 0xCD, 0x49, 0xF0, 0xD0, 0xCC, 0xAC, 0xFC, 0x43, 0xD8, + 0xB7, 0xF2, 0xEE, 0xE5, 0x5F, 0xF1, 0xBD, 0xF8, 0xEC, 0xF9, 0xDD, 0x08, + 0xBC, 0x09, 0x28, 0x18, 0x64, 0x20, 0xB2, 0x2B, 0x6A, 0x2D, 0x90, 0x32, + 0x1A, 0x29, 0x68, 0x29, 0x16, 0x0E, 0x88, 0x14, 0x16, 0xE2, 0xB5, 0xF6, + 0xE1, 0xCF, 0x92, 0xDB, 0x22, 0xE5, 0xC6, 0xD3, 0xD5, 0xF9, 0x77, 0xDE, + 0xB4, 0x10, 0x37, 0xF7, 0x4F, 0x13, 0x81, 0x0E, 0x85, 0x02, 0x15, 0x14, + 0xC6, 0xFB, 0x47, 0x16, 0x64, 0x04, 0x35, 0x1F, 0xA5, 0x16, 0xC1, 0x26, + 0x90, 0x24, 0x88, 0x21, 0x47, 0x19, 0xA3, 0x0C, 0xC4, 0xF4, 0x38, 0xF2, + 0x91, 0xD0, 0xEF, 0xD4, 0x38, 0xCC, 0x72, 0xC2, 0x2E, 0xED, 0x17, 0xCC, + 0xD4, 0x03, 0x20, 0xE1, 0x70, 0x0D, 0x74, 0xF9, 0xC3, 0x0A, 0x66, 0x0B, + 0x60, 0xFE, 0x68, 0x0E, 0x2A, 0xF6, 0x9E, 0x11, 0x4C, 0xFD, 0x75, 0x16, + 0x10, 0x0B, 0x0F, 0x12, 0x85, 0x16, 0x8B, 0x02, 0x7F, 0x01, 0x17, 0xEE, + 0x0A, 0xE0, 0xDA, 0xDA, 0x4A, 0xD1, 0x99, 0xC6, 0x05, 0xD7, 0x77, 0xCD, + 0x7D, 0xF2, 0x26, 0xE2, 0xBD, 0x15, 0xE8, 0x00, 0x54, 0x28, 0xB2, 0x1D, + 0x92, 0x23, 0x07, 0x29, 0xCF, 0x10, 0x9E, 0x29, 0x15, 0xFD, 0xB7, 0x24, + 0xE0, 0xFA, 0x83, 0x18, 0x85, 0x06, 0x8C, 0x06, 0x37, 0x0A, 0x9C, 0xF7, + 0x5E, 0xEA, 0x1A, 0xDE, 0x44, 0xE0, 0x62, 0xDF, 0xC8, 0xDA, 0x61, 0xDF, + 0xF9, 0xDF, 0x60, 0xDC, 0x1A, 0xFC, 0xB3, 0xEE, 0x21, 0x1A, 0x44, 0x0E, + 0xD4, 0x2A, 0x62, 0x26, 0x8D, 0x21, 0xBD, 0x2B, 0x9C, 0x06, 0x1E, 0x24, + 0x4F, 0xEF, 0x9D, 0x11, 0x08, 0xF0, 0xFD, 0xF9, 0xA3, 0xF4, 0xD6, 0xE4, + 0x3D, 0xFE, 0x1C, 0xDD, 0x1F, 0xF5, 0x38, 0xDC, 0x9B, 0xDA, 0x61, 0xD5, + 0x0D, 0xC9, 0xD4, 0xCB, 0xA9, 0xDB, 0x48, 0xDA, 0x77, 0x02, 0x26, 0xFD, + 0x9D, 0x27, 0x63, 0x1E, 0x90, 0x32, 0x64, 0x2A, 0x1C, 0x22, 0xF5, 0x28, + 0xD2, 0xFE, 0xC2, 0x18, 0x00, 0xEF, 0x4C, 0x00, 0xBF, 0xF7, 0xA4, 0xE7, + 0xCE, 0xFD, 0xF8, 0xDE, 0x29, 0x05, 0x9A, 0xE5, 0x47, 0xF9, 0x88, 0xEA, + 0x6B, 0xE7, 0xEF, 0xE7, 0x8D, 0xE5, 0x6E, 0xEE, 0x7B, 0xFC, 0xE8, 0x07, + 0x93, 0x1C, 0xED, 0x24, 0x99, 0x33, 0x70, 0x31, 0x2F, 0x30, 0x13, 0x33, + 0x27, 0x12, 0xB2, 0x27, 0xC6, 0xF1, 0xA2, 0x05, 0xDD, 0xE0, 0x11, 0xF0, + 0x63, 0xE5, 0xDC, 0xDD, 0x42, 0xF9, 0x28, 0xD9, 0x1F, 0x04, 0xA3, 0xE4, + 0xDD, 0xFE, 0x5C, 0xED, 0x76, 0xEF, 0x8D, 0xF0, 0x61, 0xEE, 0x2F, 0xFE, + 0x4E, 0xFC, 0xDD, 0x14, 0xD6, 0x18, 0xCE, 0x24, 0xA9, 0x25, 0xC1, 0x26, + 0xF2, 0x0D, 0x5E, 0x18, 0x3C, 0xF8, 0x91, 0x06, 0x1E, 0xDD, 0x93, 0xEC, + 0x73, 0xCC, 0xDA, 0xCD, 0xF3, 0xD7, 0x81, 0xBF, 0x58, 0xF2, 0x95, 0xCF, + 0xEC, 0x05, 0x57, 0xE7, 0xA2, 0x05, 0xD3, 0xF6, 0x17, 0x01, 0x44, 0x06, + 0xEE, 0x00, 0xDE, 0x1C, 0xA0, 0x13, 0x64, 0x2D, 0x86, 0x27, 0xBD, 0x2F, + 0x4B, 0x24, 0x79, 0x27, 0x28, 0x17, 0xF4, 0x14, 0x75, 0xFA, 0x73, 0x00, + 0xB5, 0xD9, 0x27, 0xE4, 0xB1, 0xD3, 0x9D, 0xCF, 0xB3, 0xE9, 0x7C, 0xD6, + 0x6C, 0x08, 0x63, 0xEF, 0xB4, 0x1A, 0x93, 0x06, 0x8E, 0x1D, 0xD5, 0x19, + 0xF9, 0x13, 0xD2, 0x2B, 0x51, 0x0F, 0x1A, 0x34, 0xF4, 0x1E, 0x18, 0x34, + 0x42, 0x1D, 0x9D, 0x1F, 0x56, 0x17, 0xD4, 0x0C, 0x02, 0x09, 0x10, 0x02, + 0x9B, 0xE8, 0x25, 0xED, 0x42, 0xCF, 0xAA, 0xD1, 0x18, 0xD0, 0x16, 0xC8, + 0x50, 0xEB, 0xDB, 0xDA, 0xBB, 0x0B, 0xCB, 0xF6, 0x17, 0x1D, 0x40, 0x0E, + 0xB7, 0x16, 0x7C, 0x1F, 0x60, 0x0E, 0xA1, 0x28, 0x8E, 0xFC, 0x9E, 0x1E, + 0x68, 0xF9, 0x0F, 0x0A, 0xFC, 0x05, 0xA1, 0xF8, 0xA7, 0x0E, 0x38, 0xF4, + 0xEC, 0xFE, 0x93, 0xED, 0xD1, 0xE0, 0x75, 0xD9, 0x2E, 0xCF, 0x92, 0xCB, + 0x7E, 0xD9, 0xF0, 0xD7, 0xB2, 0xFB, 0x73, 0xF8, 0x6E, 0x1F, 0x86, 0x17, + 0x3A, 0x29, 0x3A, 0x2D, 0x3F, 0x18, 0x62, 0x39, 0x9D, 0x08, 0x2F, 0x30, + 0xD1, 0xFB, 0xED, 0x1B, 0x2D, 0xFF, 0x95, 0x04, 0x3A, 0x0C, 0x62, 0xF9, + 0x86, 0x0E, 0xEB, 0xF7, 0x54, 0xFD, 0xC9, 0xEF, 0xDC, 0xE6, 0x82, 0xE1, + 0x28, 0xDE, 0xAD, 0xE3, 0x57, 0xF4, 0x26, 0xFC, 0x79, 0x17, 0xA9, 0x19, + 0x20, 0x2E, 0x12, 0x37, 0x58, 0x2E, 0xEE, 0x34, 0x10, 0x19, 0x74, 0x2C, + 0x3E, 0xFA, 0x69, 0x1E, 0xAA, 0xE7, 0xDC, 0x01, 0x70, 0xEC, 0x21, 0xEA, + 0xCC, 0xFB, 0xE3, 0xE3, 0x3D, 0x00, 0x40, 0xE3, 0xFB, 0xF4, 0xA2, 0xDA, + 0xF1, 0xE2, 0xBA, 0xD6, 0x54, 0xE7, 0xA6, 0xE9, 0x06, 0x0A, 0xF6, 0x0B, + 0xFE, 0x1B, 0xCA, 0x1A, 0x56, 0x24, 0xA6, 0x1D, 0x6E, 0x23, 0x9E, 0x23, + 0xF2, 0x0A, 0xF2, 0x21, 0x2D, 0xEE, 0x8F, 0x0A, 0xE2, 0xDE, 0xEE, 0xE9, + 0xCB, 0xE8, 0x52, 0xDB, 0xE4, 0xF9, 0x5C, 0xDF, 0x93, 0x01, 0xAF, 0xE1, + 0x0E, 0xF7, 0x5C, 0xE4, 0xB1, 0xF1, 0x9B, 0xF5, 0x96, 0x04, 0x60, 0x13, + 0x1B, 0x0F, 0xFB, 0x22, 0x2D, 0x20, 0xA8, 0x28, 0xD2, 0x2E, 0x98, 0x2C, + 0xBC, 0x24, 0x9E, 0x2F, 0x7B, 0x07, 0xF8, 0x1E, 0xD0, 0xE6, 0x3B, 0xFB, + 0x1E, 0xDC, 0x24, 0xDF, 0x0C, 0xE6, 0xA7, 0xDA, 0xA8, 0xF9, 0x5F, 0xE1, + 0x93, 0x00, 0x55, 0xE9, 0x37, 0xFD, 0xBE, 0xFE, 0x7A, 0xFC, 0xB1, 0x0E, + 0x0D, 0xFF, 0xB1, 0x1C, 0xF3, 0x09, 0x6F, 0x1F, 0xD1, 0x1B, 0xEE, 0x1B, + 0xA4, 0x22, 0xBC, 0x1D, 0x07, 0x12, 0x2A, 0x17, 0x82, 0xF0, 0xAE, 0xF8, + 0xBF, 0xD1, 0x46, 0xD2, 0x99, 0xCD, 0x3F, 0xC2, 0xF3, 0xE1, 0x2D, 0xCB, + 0xB1, 0xF7, 0x0B, 0xDF, 0x96, 0x08, 0x2C, 0xF3, 0xD4, 0x0B, 0x7A, 0x07, + 0xAE, 0x01, 0x06, 0x1A, 0x7D, 0xFC, 0xA6, 0x1F, 0x3D, 0x05, 0xF0, 0x17, + 0x36, 0x18, 0x8F, 0x16, 0x00, 0x1F, 0xFD, 0x17, 0xBC, 0x0D, 0x43, 0x05, + 0x05, 0xEA, 0x2C, 0xE1, 0x21, 0xD7, 0x40, 0xCC, 0x05, 0xE6, 0xDA, 0xD0, + 0x5C, 0xFA, 0x8B, 0xE8, 0x38, 0x13, 0xF1, 0x00, 0xAE, 0x22, 0xD2, 0x13, + 0xB1, 0x1D, 0xF4, 0x28, 0x9A, 0x0D, 0x8F, 0x31, 0x8E, 0x02, 0x06, 0x26, + 0x2F, 0x09, 0xA8, 0x16, 0x7E, 0x12, 0x22, 0x10, 0xDB, 0x0F, 0xB5, 0x04, + 0x3E, 0xF5, 0x7E, 0xE8, 0x39, 0xDA, 0x65, 0xCF, 0xED, 0xD5, 0xAA, 0xCB, + 0xD9, 0xE2, 0x2F, 0xDF, 0x56, 0xFC, 0xC1, 0xF3, 0xE3, 0x19, 0x85, 0x05, + 0x03, 0x23, 0xEB, 0x1A, 0x01, 0x17, 0x46, 0x2B, 0x31, 0x01, 0x72, 0x23, + 0x35, 0xF4, 0x9C, 0x09, 0xCE, 0xF4, 0x34, 0xF7, 0x4E, 0xFB, 0x83, 0xEE, + 0xBD, 0xF6, 0x16, 0xE0, 0x9B, 0xDD, 0x42, 0xC9, 0xFE, 0xD9, 0xE0, 0xCB, + 0x3F, 0xDE, 0xDF, 0xDB, 0x52, 0xED, 0xB4, 0xEE, 0x13, 0x0B, 0x0B, 0xFF, + 0xAE, 0x25, 0x30, 0x15, 0x6F, 0x2B, 0xE8, 0x2D, 0x0D, 0x19, 0x77, 0x32, + 0x2D, 0xFF, 0x09, 0x1A, 0x78, 0xF2, 0x3D, 0xFF, 0xD7, 0xF7, 0x22, 0xF2, + 0x61, 0xF7, 0x1D, 0xE2, 0x1D, 0xFF, 0x4D, 0xE3, 0xA0, 0xFB, 0x6C, 0xE5, + 0x85, 0xEB, 0x12, 0xE9, 0xF4, 0xE4, 0x92, 0xF5, 0x55, 0xF7, 0x4B, 0x01, + 0xEB, 0x17, 0xB9, 0x12, 0xCE, 0x2D, 0xCE, 0x2A, 0x07, 0x2C, 0x75, 0x3A, + 0xCE, 0x12, 0x76, 0x28, 0x6C, 0xF5, 0x5E, 0x05, 0x06, 0xEA, 0xAF, 0xEA, + 0x6F, 0xF1, 0x4D, 0xDA, 0x6D, 0xF8, 0xE7, 0xDB, 0xAD, 0xFA, 0x64, 0xDC, + 0x78, 0xF0, 0xE9, 0xDE, 0x1D, 0xE5, 0x13, 0xED, 0xA9, 0xE8, 0x92, 0xFA, + 0x4D, 0xFE, 0x1A, 0x05, 0x97, 0x18, 0xE0, 0x15, 0x03, 0x26, 0x68, 0x29, + 0xE3, 0x17, 0x4E, 0x24, 0x6A, 0xF9, 0x3F, 0x04, 0xCA, 0xE1, 0x6A, 0xDF, + 0x9D, 0xDA, 0x39, 0xD3, 0x3F, 0xE6, 0xC8, 0xD5, 0xC7, 0xF8, 0xBD, 0xD7, + 0x6A, 0x02, 0x60, 0xDE, 0x75, 0xFF, 0xB0, 0xF4, 0x34, 0xF9, 0x95, 0x0B, + 0x2D, 0xFE, 0x8C, 0x15, 0xB7, 0x0C, 0x18, 0x1B, 0x07, 0x20, 0x44, 0x2B, + 0x81, 0x22, 0xAC, 0x2F, 0x7F, 0x05, 0x4D, 0x12, 0xD6, 0xF1, 0x4F, 0xF8, + 0x63, 0xE4, 0x70, 0xE5, 0xA1, 0xDE, 0xC7, 0xDB, 0xB3, 0xEC, 0xB7, 0xD9, + 0xDD, 0xFE, 0x7C, 0xDD, 0x48, 0x0C, 0xF8, 0xF6, 0xF7, 0x0B, 0xBC, 0x15, + 0x01, 0x08, 0x71, 0x24, 0x33, 0x06, 0xE8, 0x1F, 0xDD, 0x11, 0x52, 0x21, + 0xCE, 0x19, 0x39, 0x23, 0x23, 0x0D, 0xFC, 0x0F, 0x33, 0x00, 0xF5, 0xF9, + 0x6B, 0xE9, 0xAC, 0xE1, 0xFD, 0xD2, 0x7F, 0xD1, 0x78, 0xD4, 0x24, 0xCD, + 0x2C, 0xEA, 0x71, 0xCF, 0x72, 0x06, 0x52, 0xE6, 0x9A, 0x14, 0xC1, 0x0B, + 0x3E, 0x16, 0x16, 0x28, 0x2E, 0x0C, 0xC8, 0x25, 0x57, 0x0A, 0xCD, 0x1D, + 0xC7, 0x11, 0xD2, 0x18, 0x42, 0x0E, 0xCB, 0x0B, 0x8B, 0x0A, 0x22, 0xFD, + 0xB7, 0xFB, 0xC3, 0xE8, 0x4A, 0xE3, 0x94, 0xDB, 0x36, 0xD6, 0xB1, 0xD7, + 0x8F, 0xE3, 0xBE, 0xD9, 0x30, 0x00, 0x88, 0xE8, 0x2A, 0x1D, 0x69, 0x0F, + 0x4F, 0x27, 0x90, 0x34, 0xBA, 0x1E, 0x8F, 0x3C, 0x39, 0x16, 0xC9, 0x32, + 0x56, 0x06, 0xD4, 0x19, 0xA5, 0x02, 0x5B, 0x0B, 0x98, 0x0A, 0xBB, 0x03, + 0x7B, 0x0B, 0x99, 0xF4, 0xE2, 0xF9, 0x49, 0xE7, 0xE3, 0xE2, 0x1F, 0xE2, + 0xBE, 0xDB, 0x93, 0xE1, 0x67, 0xEB, 0xA4, 0xE5, 0xF8, 0x08, 0x80, 0xFF, + 0x81, 0x1E, 0xB6, 0x24, 0xA8, 0x20, 0x03, 0x38, 0xEC, 0x0C, 0x16, 0x2C, + 0xA7, 0xFA, 0xC2, 0x11, 0xEF, 0xF1, 0x73, 0xFE, 0x5E, 0xF6, 0x7D, 0xF3, + 0xD0, 0xFF, 0x6C, 0xE6, 0xAF, 0xFC, 0xFA, 0xDA, 0x1F, 0xEE, 0x0E, 0xDE, + 0x27, 0xE3, 0xC7, 0xE6, 0x13, 0xE7, 0x98, 0xEA, 0xFE, 0xFD, 0x41, 0xF9, + 0xFB, 0x18, 0x28, 0x1A, 0x2B, 0x25, 0xDC, 0x36, 0x59, 0x21, 0xD0, 0x34, + 0x6D, 0x0F, 0xA9, 0x1F, 0x81, 0xF7, 0xFB, 0x07, 0xE7, 0xED, 0xCD, 0xF8, + 0x1A, 0xF5, 0x89, 0xE8, 0x0D, 0x00, 0xC8, 0xDD, 0xFF, 0x01, 0x79, 0xE4, + 0x5D, 0xFC, 0x99, 0xF8, 0x64, 0xF9, 0x9B, 0x02, 0x37, 0x01, 0xAD, 0x08, + 0x0E, 0x1D, 0x25, 0x27, 0x10, 0x25, 0x01, 0x2F, 0x5E, 0x25, 0x55, 0x32, + 0x0B, 0x1F, 0x05, 0x2D, 0xD2, 0x06, 0x26, 0x18, 0xAC, 0xEE, 0xDC, 0x01, + 0x35, 0xE5, 0xF2, 0xE8, 0x36, 0xED, 0xEE, 0xD3, 0x93, 0xF7, 0x5C, 0xD1, + 0xCE, 0xFA, 0x47, 0xE7, 0x5A, 0xF8, 0x1F, 0xFC, 0xD0, 0x00, 0x69, 0x0D, + 0xC8, 0x02, 0xC7, 0x0E, 0x82, 0x09, 0x5B, 0x13, 0xD4, 0x17, 0xEF, 0x20, + 0x51, 0x1F, 0x7A, 0x25, 0xF2, 0x12, 0x14, 0x17, 0x16, 0xF7, 0x02, 0x02, + 0x83, 0xDF, 0x37, 0xE9, 0x8A, 0xDB, 0x76, 0xCF, 0x9D, 0xE6, 0x73, 0xC3, + 0x93, 0xF6, 0xA4, 0xD7, 0x96, 0x00, 0xED, 0xF9, 0x21, 0x03, 0x58, 0x10, + 0x29, 0x07, 0x25, 0x1A, 0x42, 0x09, 0xFF, 0x1A, 0x1F, 0x11, 0xA9, 0x20, + 0xE7, 0x1B, 0xF9, 0x22, 0x6E, 0x1D, 0x90, 0x19, 0x50, 0x0B, 0xBD, 0x0A, + 0x8F, 0xF1, 0x93, 0xFA, 0x81, 0xE0, 0x3B, 0xE3, 0xA2, 0xE4, 0xE7, 0xCF, + 0x90, 0xF5, 0x36, 0xD8, 0x4E, 0x08, 0xC2, 0xFE, 0x71, 0x13, 0x5E, 0x1B, + 0x0A, 0x14, 0xA4, 0x27, 0x96, 0x0B, 0x2D, 0x25, 0x38, 0x05, 0x2B, 0x20, + 0xF0, 0x09, 0x2A, 0x1B, 0x15, 0x12, 0x35, 0x0E, 0x0F, 0x0D, 0xE1, 0xFD, + 0x4E, 0xF8, 0x54, 0xF2, 0x94, 0xE1, 0x01, 0xE2, 0x2A, 0xDB, 0x5A, 0xCE, + 0xC0, 0xEC, 0xB3, 0xD5, 0xDC, 0xFC, 0x4E, 0xE5, 0xFB, 0x0C, 0xDC, 0x04, + 0xA3, 0x18, 0x92, 0x23, 0x7B, 0x14, 0x6A, 0x2B, 0xDA, 0x06, 0xD6, 0x24, + 0x5F, 0xFE, 0x32, 0x18, 0x5D, 0x02, 0x9F, 0x04, 0x1B, 0x04, 0x40, 0xED, + 0x0F, 0xFC, 0xA9, 0xE1, 0x46, 0xEA, 0x8F, 0xDD, 0xDA, 0xDE, 0xAD, 0xD4, + 0xBC, 0xE6, 0x8F, 0xD2, 0x3B, 0xF5, 0x40, 0xE3, 0x6C, 0x09, 0x85, 0x00, + 0xC2, 0x1E, 0xFD, 0x22, 0x88, 0x24, 0xD1, 0x32, 0x6E, 0x17, 0x11, 0x32, + 0xA8, 0x03, 0x5F, 0x24, 0xA3, 0xFB, 0xD6, 0x0E, 0xF3, 0xFB, 0xA2, 0xEE, + 0x73, 0xFB, 0xD0, 0xDD, 0x7D, 0xF1, 0x38, 0xDD, 0xD3, 0xE4, 0x1B, 0xD9, + 0xE3, 0xE8, 0x40, 0xE8, 0xD5, 0xF0, 0xF3, 0xEF, 0xAB, 0xFD, 0xB3, 0xFA, + 0xB7, 0x12, 0x53, 0x13, 0x7A, 0x22, 0x19, 0x27, 0xE2, 0x1D, 0x8A, 0x2C, + 0xB8, 0x09, 0x9A, 0x25, 0xAB, 0xF5, 0xE7, 0x12, 0x4D, 0xEE, 0x67, 0xF0, + 0xD1, 0xEE, 0x43, 0xD4, 0x56, 0xE9, 0xEE, 0xCC, 0x47, 0xEE, 0x05, 0xDC, + 0xC8, 0xF0, 0x5B, 0xED, 0x6E, 0xEF, 0xCB, 0xF2, 0x9D, 0xF3, 0xE2, 0xF5, + 0x71, 0x03, 0x12, 0x07, 0x3D, 0x19, 0x92, 0x1A, 0x55, 0x22, 0x70, 0x23, + 0x2A, 0x18, 0x7D, 0x22, 0x28, 0x00, 0x6F, 0x17, 0xDA, 0xF0, 0xB5, 0xFA, + 0x56, 0xEC, 0x8A, 0xD8, 0xB9, 0xEF, 0x15, 0xCC, 0xA2, 0xF7, 0x3A, 0xD7, + 0x90, 0xFC, 0x6C, 0xEE, 0x9B, 0xFD, 0x6B, 0x00, 0x11, 0xFD, 0x24, 0x07, + 0x66, 0x03, 0x54, 0x12, 0x16, 0x11, 0xBF, 0x1C, 0x73, 0x1E, 0x2B, 0x21, + 0xD6, 0x1D, 0x75, 0x1D, 0xBE, 0x0B, 0x60, 0x18, 0xE4, 0xF5, 0x0F, 0x03, + 0x22, 0xE7, 0xEE, 0xDA, 0x24, 0xE7, 0x5B, 0xCF, 0xFD, 0xED, 0xD9, 0xD0, + 0x74, 0xF8, 0x4C, 0xE2, 0xA7, 0x00, 0xB8, 0xF8, 0x4F, 0x02, 0x4C, 0x08, + 0x3E, 0xFF, 0xF8, 0x12, 0xF3, 0x01, 0x3B, 0x1C, 0x44, 0x0D, 0xE5, 0x19, + 0x43, 0x15, 0x8E, 0x12, 0x2B, 0x0C, 0xA2, 0x0B, 0x6E, 0xF3, 0xA9, 0xF4, + 0x49, 0xE6, 0xC2, 0xEC, 0x6F, 0xE2, 0x81, 0xDC, 0x26, 0xE4, 0xF5, 0xC8, + 0x20, 0xF0, 0xB1, 0xCD, 0x95, 0x00, 0x3E, 0xE8, 0xBB, 0x0C, 0xE3, 0x05, + 0x51, 0x0B, 0x41, 0x1B, 0x3F, 0x08, 0xB1, 0x2A, 0xD7, 0x0B, 0x91, 0x2A, + 0x75, 0x14, 0x26, 0x1C, 0x28, 0x11, 0xD7, 0x0B, 0x7E, 0xFE, 0x87, 0xFF, + 0x53, 0xF5, 0xA9, 0xF8, 0x57, 0xED, 0x97, 0xEC, 0x79, 0xE7, 0x41, 0xD8, + 0xD9, 0xEB, 0xC7, 0xD2, 0x8D, 0xFC, 0xF2, 0xE5, 0x0A, 0x11, 0xE5, 0x04, + 0x93, 0x19, 0x82, 0x1F, 0x75, 0x13, 0xA7, 0x32, 0x43, 0x0D, 0x43, 0x34, + 0xD5, 0x0C, 0xB7, 0x20, 0xBC, 0x09, 0xD4, 0x07, 0x57, 0x04, 0x2B, 0xF3, + 0xCD, 0xF9, 0xCD, 0xEC, 0xE9, 0xED, 0x3D, 0xEC, 0x87, 0xE3, 0xAB, 0xDF, + 0x8B, 0xE0, 0x60, 0xD6, 0xCC, 0xED, 0xFC, 0xDF, 0x93, 0x07, 0xA3, 0xFA, + 0x70, 0x1B, 0x14, 0x14, 0x27, 0x1B, 0xC6, 0x29, 0x23, 0x0F, 0xB7, 0x30, + 0xB0, 0x09, 0x76, 0x1E, 0x13, 0x02, 0x12, 0x06, 0x90, 0xFD, 0x38, 0xED, + 0xBF, 0xFB, 0x8D, 0xE1, 0x9A, 0xF6, 0x69, 0xE4, 0xFE, 0xEE, 0x1C, 0xE4, + 0xDA, 0xE7, 0xBB, 0xE1, 0xC6, 0xEC, 0xA8, 0xEA, 0x1F, 0x01, 0x83, 0x00, + 0x30, 0x19, 0x80, 0x15, 0x45, 0x21, 0xBC, 0x28, 0x19, 0x19, 0xC6, 0x32, + 0xC4, 0x0A, 0xE1, 0x2C, 0x2E, 0x00, 0x3B, 0x18, 0x48, 0xFC, 0xF5, 0xF8, + 0x6A, 0xFC, 0xF4, 0xDF, 0x1A, 0xFB, 0x4E, 0xDD, 0x24, 0xF8, 0x95, 0xE3, + 0x0F, 0xF1, 0x30, 0xEC, 0xC0, 0xEF, 0xC3, 0xF8, 0xA3, 0xFA, 0x0B, 0x0C, + 0x0A, 0x11, 0x0B, 0x1B, 0x6D, 0x1E, 0xD6, 0x25, 0xD8, 0x19, 0xB4, 0x33, + 0xE5, 0x0C, 0xE2, 0x28, 0x39, 0xFE, 0x80, 0x18, 0x99, 0xF4, 0x14, 0xFE, + 0x6B, 0xF0, 0x8C, 0xE0, 0x5F, 0xF1, 0xA3, 0xD2, 0x2D, 0xF5, 0xA5, 0xD8, + 0x4E, 0xF7, 0x99, 0xE5, 0x15, 0xF6, 0x34, 0xF8, 0x30, 0xFA, 0xD7, 0x0B, + 0xD9, 0x0A, 0xF1, 0x1B, 0x96, 0x1C, 0xB6, 0x29, 0xA6, 0x1C, 0x00, 0x1F, + 0x17, 0x13, 0x44, 0x18, 0x52, 0x04, 0xCB, 0x17, 0x42, 0xF8, 0xB7, 0x0C, + 0x2E, 0xEF, 0x3F, 0xEF, 0xFF, 0xED, 0x66, 0xD8, 0x5C, 0xF3, 0x22, 0xD4, + 0x46, 0xFE, 0x42, 0xDF, 0x38, 0x01, 0xA3, 0xF2, 0xEB, 0x02, 0xE8, 0x0C, + 0x25, 0x10, 0x24, 0x23, 0xCA, 0x12, 0xD4, 0x27, 0x07, 0x18, 0xDB, 0x1F, + 0xBC, 0x19, 0xE3, 0x14, 0xCA, 0x10, 0xFB, 0x13, 0xA8, 0x01, 0xB9, 0x0E, + 0xB7, 0xF1, 0x92, 0xFA, 0x02, 0xE9, 0xD9, 0xE1, 0x98, 0xE8, 0xFE, 0xD5, + 0xD7, 0xF4, 0x50, 0xDC, 0x56, 0xFF, 0x20, 0xEE, 0x5D, 0x04, 0x0D, 0x0B, + 0x0E, 0x08, 0x73, 0x26, 0xE4, 0x06, 0x0D, 0x2B, 0x62, 0x0B, 0x72, 0x22, + 0xE8, 0x10, 0xDE, 0x10, 0xC8, 0x0E, 0x23, 0x07, 0xC7, 0x03, 0xC3, 0x02, + 0x1E, 0xF5, 0x7D, 0xF9, 0x41, 0xE6, 0x0C, 0xE5, 0x47, 0xE1, 0x71, 0xDA, + 0xD7, 0xED, 0x44, 0xDB, 0x9C, 0x01, 0x52, 0xEC, 0xD8, 0x0B, 0x61, 0x0E, + 0x65, 0x0D, 0xA4, 0x1B, 0xAF, 0x0B, 0xC7, 0x28, 0xB7, 0x09, 0xF9, 0x2B, + 0xB8, 0x0D, 0xA4, 0x1C, 0x95, 0x0E, 0x85, 0x08, 0xF2, 0x09, 0x40, 0xFC, + 0xA7, 0xFE, 0x04, 0xF2, 0x0A, 0xEF, 0x42, 0xE4, 0x16, 0xE5, 0xC3, 0xDA, + 0xF7, 0xEC, 0xE2, 0xDE, 0xE6, 0x00, 0xDB, 0xF1, 0x3D, 0x11, 0x96, 0x01, + 0x9F, 0x15, 0x6E, 0x11, 0xB1, 0x0F, 0x71, 0x26, 0x9C, 0x08, 0x18, 0x34, + 0x5B, 0x08, 0xF4, 0x29, 0x1E, 0x07, 0xD7, 0x0E, 0x92, 0x04, 0x81, 0xF6, + 0x5F, 0xFD, 0xB3, 0xE7, 0x17, 0xF3, 0x07, 0xDB, 0x06, 0xE5, 0x37, 0xD5, + 0x3E, 0xE5, 0x7A, 0xDD, 0x22, 0xF9, 0xAB, 0xEC, 0xA4, 0x06, 0x6A, 0xFE, + 0x9E, 0x11, 0x0A, 0x0C, 0x8C, 0x12, 0xB9, 0x1A, 0x99, 0x0B, 0x4A, 0x2B, + 0x53, 0x04, 0x13, 0x2A, 0x52, 0xFF, 0x29, 0x13, 0x48, 0xFB, 0x55, 0xF7, + 0x50, 0xFA, 0x6F, 0xE3, 0x15, 0xF5, 0x6D, 0xD7, 0xA2, 0xEB, 0xD8, 0xD4, + 0x2B, 0xEA, 0xE4, 0xDF, 0xDA, 0xEF, 0x9A, 0xF4, 0x36, 0x00, 0xDE, 0x07, + 0xC7, 0x15, 0xC2, 0x11, 0x13, 0x1F, 0x49, 0x18, 0x8E, 0x18, 0x36, 0x23, + 0x27, 0x0A, 0x5D, 0x26, 0xBC, 0xFD, 0xA2, 0x17, 0x9D, 0xF4, 0x34, 0xFD, + 0xB8, 0xF4, 0xC5, 0xE6, 0x0F, 0xF5, 0x6C, 0xD7, 0xB6, 0xED, 0x1E, 0xD4, + 0x41, 0xF0, 0x77, 0xDF, 0xA3, 0xF1, 0x78, 0xF4, 0x02, 0xF9, 0x3E, 0x0C, + 0xB7, 0x0B, 0x00, 0x19, 0x29, 0x19, 0x08, 0x1A, 0xAE, 0x19, 0xE5, 0x1A, + 0x97, 0x0D, 0xE4, 0x1B, 0x24, 0xFF, 0x52, 0x11, 0x58, 0xF0, 0x43, 0xFA, + 0x7E, 0xEB, 0xAE, 0xE3, 0xD9, 0xEE, 0x2A, 0xD3, 0x23, 0xF0, 0x06, 0xCC, + 0x89, 0xF6, 0x1A, 0xD9, 0x04, 0xF6, 0x5A, 0xED, 0x7C, 0xF4, 0x7A, 0x07, + 0x02, 0x01, 0x81, 0x1B, 0x54, 0x11, 0x01, 0x1F, 0xB0, 0x19, 0x08, 0x1A, + 0xCF, 0x14, 0x8A, 0x16, 0xE9, 0x08, 0x5B, 0x0D, 0x7E, 0xF7, 0x0B, 0xFC, + 0x18, 0xEB, 0xF1, 0xE5, 0x96, 0xEC, 0xB0, 0xD1, 0x8B, 0xF5, 0x79, 0xD8, + 0xB6, 0xFF, 0x14, 0xE1, 0x01, 0x02, 0x6D, 0xEA, 0xAD, 0xFC, 0x8C, 0xFF, + 0x88, 0xFF, 0x28, 0x19, 0x6D, 0x0A, 0xD5, 0x24, 0xE3, 0x13, 0x82, 0x21, + 0x67, 0x15, 0x23, 0x18, 0x2A, 0x0E, 0x59, 0x0E, 0x04, 0xFE, 0x0D, 0xFC, + 0xA7, 0xEB, 0x90, 0xE3, 0xA2, 0xE5, 0xC2, 0xDE, 0x6C, 0xEB, 0xEF, 0xE0, + 0x8E, 0xFB, 0x82, 0xE3, 0x75, 0x06, 0x02, 0xE6, 0xA0, 0x05, 0x1C, 0xF6, + 0xEF, 0xFF, 0x9A, 0x10, 0xBB, 0x01, 0x91, 0x24, 0x3B, 0x06, 0x4F, 0x24, + 0x11, 0x0B, 0x33, 0x1A, 0x47, 0x0A, 0xA1, 0x0B, 0x8F, 0xF8, 0xAF, 0xF3, + 0x08, 0xF0, 0x33, 0xE6, 0x90, 0xE5, 0xF8, 0xDD, 0x2F, 0xDF, 0xB5, 0xDD, + 0xEF, 0xEB, 0xE2, 0xE3, 0x8A, 0x00, 0x99, 0xE8, 0x6E, 0x0D, 0x6B, 0xF5, + 0xE9, 0x0B, 0xAF, 0x0C, 0x86, 0x0A, 0xBA, 0x24, 0xA7, 0x08, 0xBD, 0x29, + 0x67, 0x0C, 0x53, 0x21, 0x58, 0x0C, 0xED, 0x0E, 0xA3, 0x04, 0x2A, 0xF6, + 0xF4, 0xFE, 0xF3, 0xE8, 0xD5, 0xF2, 0x21, 0xDF, 0xE8, 0xE2, 0xBF, 0xDC, + 0x2D, 0xE4, 0xD6, 0xE4, 0x8C, 0xF9, 0x49, 0xF0, 0xA7, 0x0F, 0x5A, 0xFB, + 0x78, 0x17, 0xB1, 0x0C, 0x20, 0x13, 0x10, 0x20, 0xDE, 0x0B, 0x0C, 0x2A, + 0x7D, 0x05, 0xF1, 0x21, 0x0F, 0x06, 0x25, 0x0D, 0xA3, 0x02, 0xEE, 0xFB, + 0xD7, 0xFF, 0x47, 0xEB, 0xFB, 0xF8, 0x5B, 0xDB, 0xE0, 0xE6, 0x85, 0xD3, + 0xCA, 0xDC, 0x78, 0xDD, 0x8A, 0xE9, 0x66, 0xF0, 0xD0, 0x03, 0x84, 0x01, + 0x47, 0x15, 0xD3, 0x10, 0xA6, 0x16, 0x77, 0x1F, 0x0D, 0x0D, 0xF0, 0x26, + 0xB4, 0x02, 0x1E, 0x20, 0xB0, 0xF7, 0x32, 0x0F, 0xAA, 0xF4, 0xE5, 0xFD, + 0x47, 0xFC, 0xFE, 0xEF, 0x4A, 0x03, 0x35, 0xE0, 0x59, 0xF9, 0x10, 0xD6, + 0x79, 0xE9, 0x48, 0xDD, 0xBA, 0xE8, 0x7B, 0xF3, 0x42, 0xFC, 0x20, 0x0A, + 0xF7, 0x11, 0x14, 0x1A, 0x19, 0x1E, 0x62, 0x26, 0xD7, 0x18, 0xB3, 0x29, + 0xCE, 0x06, 0x9B, 0x21, 0x86, 0xFB, 0xA6, 0x0F, 0xE8, 0xF1, 0x72, 0xFE, + 0x92, 0xF4, 0x1F, 0xF3, 0xDA, 0x00, 0xBC, 0xE6, 0x7B, 0x04, 0x7E, 0xDA, + 0x88, 0xF8, 0x41, 0xDB, 0xE9, 0xEE, 0xB0, 0xEE, 0x58, 0xF6, 0xEF, 0x08, + 0x38, 0x0B, 0xAD, 0x1C, 0x4C, 0x1B, 0xCD, 0x27, 0x79, 0x1A, 0xF0, 0x29, + 0x44, 0x12, 0x96, 0x1C, 0x88, 0x02, 0xFC, 0x09, 0x08, 0xEE, 0xFB, 0xF8, + 0x78, 0xE3, 0x60, 0xEE, 0x9B, 0xED, 0xEC, 0xE6, 0x79, 0xFE, 0xBB, 0xDE, + 0x2A, 0x01, 0xFC, 0xDB, 0xBF, 0xFA, 0xDC, 0xEA, 0x4C, 0xF8, 0xE7, 0x03, + 0x4F, 0x04, 0x42, 0x1C, 0xDE, 0x15, 0x20, 0x2C, 0x80, 0x18, 0xCD, 0x27, + 0xEA, 0x15, 0xCB, 0x1C, 0x08, 0x0F, 0xE2, 0x0D, 0xD8, 0xFB, 0x8D, 0xFC, + 0x17, 0xE7, 0x3A, 0xF0, 0x41, 0xE4, 0x79, 0xEA, 0xEB, 0xF5, 0xD9, 0xE6, + 0x13, 0x06, 0x59, 0xE5, 0x23, 0x0A, 0x41, 0xF0, 0xFA, 0x03, 0xD9, 0x04, + 0xB2, 0x05, 0xF5, 0x1C, 0x43, 0x0F, 0x06, 0x2E, 0x98, 0x0F, 0x4A, 0x29, + 0x97, 0x11, 0x7D, 0x1E, 0xB0, 0x15, 0x31, 0x11, 0x70, 0x0B, 0x06, 0xFE, + 0xB8, 0xF1, 0x3A, 0xEC, 0x9F, 0xDE, 0x2A, 0xE4, 0xA7, 0xE3, 0xB4, 0xE2, + 0xFA, 0xF9, 0x7B, 0xE7, 0xBE, 0x08, 0xF5, 0xEF, 0xBA, 0x0B, 0x03, 0x04, + 0xAA, 0x08, 0x8D, 0x1D, 0x9B, 0x03, 0x0A, 0x21, 0x76, 0x00, 0x25, 0x1F, + 0x97, 0x02, 0x69, 0x1C, 0xB7, 0x0D, 0x50, 0x15, 0x98, 0x10, 0xDB, 0x01, + 0x0B, 0xFF, 0xEC, 0xEA, 0xB3, 0xE2, 0xFE, 0xDA, 0x09, 0xD8, 0xC5, 0xDA, + 0x5D, 0xE9, 0xE6, 0xE2, 0xC9, 0x02, 0x8F, 0xF2, 0xE6, 0x0F, 0xE4, 0x09, + 0xAE, 0x14, 0xF5, 0x16, 0x40, 0x0F, 0x4D, 0x1E, 0x95, 0x02, 0xA4, 0x20, + 0xFD, 0xF9, 0x28, 0x20, 0x5E, 0x00, 0xCB, 0x1A, 0x82, 0x0F, 0x98, 0x0A, + 0x00, 0x10, 0x14, 0xF2, 0x94, 0xFA, 0xD8, 0xDD, 0x7E, 0xE4, 0x63, 0xD8, + 0xFF, 0xE6, 0xD5, 0xE1, 0x3C, 0xFD, 0x7E, 0xF4, 0x2F, 0x17, 0xE2, 0x0C, + 0x6D, 0x1E, 0xAF, 0x19, 0xA2, 0x1A, 0x26, 0x1F, 0x4A, 0x0C, 0xC9, 0x1D, + 0x9A, 0xF9, 0xAF, 0x18, 0xD7, 0xF1, 0x6A, 0x12, 0x9D, 0xFD, 0xDA, 0x06, + 0xE9, 0x09, 0x6B, 0xF2, 0x68, 0x04, 0x27, 0xDD, 0xC8, 0xEC, 0x58, 0xD2, + 0xE6, 0xE1, 0x53, 0xD9, 0xF3, 0xF3, 0xEA, 0xF1, 0x8C, 0x00, 0x68, 0x04, + 0xA7, 0x0F, 0xFA, 0x14, 0x93, 0x1C, 0x2C, 0x20, 0x47, 0x1A, 0x16, 0x20, + 0xD7, 0x05, 0x54, 0x16, 0x1B, 0xED, 0xD5, 0x0A, 0xC4, 0xE6, 0x40, 0xFF, + 0xC5, 0xF5, 0x2F, 0xF1, 0x87, 0xFF, 0x18, 0xDF, 0xCE, 0xF8, 0x30, 0xD6, + 0x8D, 0xEB, 0x9F, 0xDC, 0xE9, 0xEA, 0x02, 0xEE, 0xF8, 0xF6, 0x80, 0x04, + 0x2B, 0x09, 0xCF, 0x19, 0xF1, 0x1D, 0xCF, 0x29, 0xB8, 0x28, 0x2D, 0x2B, + 0xE7, 0x1C, 0x5D, 0x1E, 0xE1, 0xFD, 0xA6, 0x0B, 0x75, 0xE4, 0x46, 0xFA, + 0x96, 0xE7, 0x1D, 0xED, 0x2A, 0xF9, 0xA0, 0xE0, 0x92, 0xFA, 0x49, 0xD7, + 0x0B, 0xFF, 0x7C, 0xDF, 0xEB, 0xFB, 0x2B, 0xEE, 0x19, 0xF5, 0x4A, 0xFD, + 0xB4, 0xF8, 0xD8, 0x0F, 0x04, 0x08, 0x21, 0x21, 0xC8, 0x1C, 0x35, 0x28, + 0x53, 0x23, 0x9C, 0x1E, 0x3D, 0x10, 0x13, 0x09, 0xBE, 0xEF, 0x04, 0xF3, + 0xA3, 0xDE, 0x76, 0xE2, 0x05, 0xE9, 0x4C, 0xDA, 0x7F, 0xFA, 0x1D, 0xD6, + 0xDF, 0x03, 0xFB, 0xE0, 0x26, 0x05, 0x5F, 0xEF, 0x54, 0xFD, 0x00, 0xFB, + 0x9D, 0xF7, 0xDD, 0x09, 0xF4, 0xF7, 0xF2, 0x19, 0x5B, 0x08, 0x3C, 0x25, + 0x7E, 0x1A, 0xE4, 0x21, 0x11, 0x1C, 0xBA, 0x0F, 0xE2, 0x00, 0x42, 0xF8, + 0xBB, 0xE3, 0xCA, 0xE3, 0xF2, 0xE2, 0x51, 0xD7, 0x23, 0xEC, 0x01, 0xDF, + 0x1E, 0xFF, 0x07, 0xEC, 0xF8, 0x10, 0x14, 0xF9, 0x44, 0x15, 0x73, 0x03, + 0x17, 0x0D, 0x9A, 0x0E, 0x17, 0xFD, 0x9B, 0x18, 0x17, 0xFB, 0xE3, 0x22, + 0xA8, 0x07, 0xD8, 0x21, 0xA4, 0x18, 0xD2, 0x16, 0x86, 0x0C, 0xE4, 0xFC, + 0x51, 0xEE, 0xC6, 0xE0, 0xD0, 0xDE, 0x3E, 0xD9, 0x1A, 0xDE, 0x10, 0xDA, + 0x4D, 0xEE, 0xF6, 0xE3, 0x40, 0x06, 0xBB, 0xF2, 0x66, 0x18, 0x6E, 0x02, + 0x75, 0x1A, 0x12, 0x0D, 0xCA, 0x08, 0xB3, 0x13, 0x6C, 0xF5, 0xB7, 0x18, + 0xE2, 0xF1, 0x57, 0x18, 0xA0, 0x04, 0xF0, 0x0F, 0xEB, 0x0A, 0x3E, 0xFB, + 0x4D, 0xF4, 0xC7, 0xDE, 0xFF, 0xE9, 0x19, 0xD7, 0x42, 0xE0, 0xDB, 0xD6, + 0xC0, 0xDE, 0x7C, 0xDC, 0x95, 0xF0, 0xD5, 0xED, 0xD5, 0x0C, 0x96, 0x04, + 0xA7, 0x21, 0x1F, 0x15, 0x2A, 0x20, 0x20, 0x1D, 0x6E, 0x07, 0xBB, 0x1C, + 0xAB, 0xF4, 0x81, 0x1A, 0x63, 0xF8, 0x36, 0x11, 0xAC, 0x03, 0xCE, 0xFB, + 0x83, 0x0C, 0xB4, 0xF2, 0x69, 0x05, 0xB3, 0xE8, 0x55, 0xF2, 0x64, 0xDE, + 0xD1, 0xE1, 0x76, 0xDB, 0x88, 0xE4, 0xF4, 0xE9, 0xB5, 0xFC, 0x1A, 0x04, + 0x75, 0x1C, 0x26, 0x1C, 0xE7, 0x2E, 0x77, 0x27, 0x53, 0x1F, 0x87, 0x25, + 0x5F, 0x00, 0xF8, 0x1A, 0xA8, 0xF6, 0x6B, 0x0B, 0xE5, 0xF0, 0xED, 0xFB, + 0x1E, 0xFB, 0x2F, 0xF0, 0x64, 0x08, 0x06, 0xE7, 0x02, 0x04, 0xF7, 0xDC, + 0xC0, 0xF2, 0x9A, 0xD7, 0x3B, 0xE4, 0x86, 0xE0, 0xD6, 0xE8, 0xFC, 0xF8, + 0x46, 0x00, 0x04, 0x15, 0x64, 0x1D, 0x68, 0x26, 0xB1, 0x20, 0x46, 0x26, + 0x59, 0x08, 0x81, 0x19, 0xBC, 0xE9, 0xCF, 0x04, 0x49, 0xDE, 0x04, 0xF4, + 0x40, 0xE6, 0xFE, 0xE9, 0x78, 0xFB, 0x72, 0xE6, 0xA4, 0x07, 0x22, 0xE4, + 0x8C, 0x05, 0x4D, 0xE2, 0x07, 0xF8, 0x6B, 0xE8, 0xCE, 0xEE, 0xE7, 0xFB, + 0xD1, 0xF4, 0x76, 0x16, 0x22, 0x11, 0x20, 0x2C, 0x07, 0x25, 0x05, 0x31, + 0xB2, 0x15, 0xAC, 0x23, 0x54, 0x07, 0x87, 0x10, 0x23, 0xF1, 0x38, 0xFC, + 0x18, 0xE1, 0xCE, 0xEB, 0xB5, 0xE8, 0xD9, 0xE5, 0xC8, 0xFC, 0xCA, 0xE7, + 0xA4, 0x0E, 0xEC, 0xEB, 0xE4, 0x10, 0xF2, 0xF1, 0xFD, 0x05, 0x9C, 0xFF, + 0x9C, 0xFB, 0x1D, 0x13, 0x11, 0x05, 0xCC, 0x25, 0x49, 0x19, 0xA2, 0x2D, + 0x31, 0x22, 0x4A, 0x23, 0xBE, 0x17, 0xA9, 0x0F, 0x99, 0xFC, 0x2D, 0xF8, + 0x71, 0xDD, 0x9E, 0xE1, 0x91, 0xD4, 0x3B, 0xD7, 0xC0, 0xE1, 0xE5, 0xDA, + 0x31, 0xFE, 0x20, 0xE7, 0x86, 0x13, 0x32, 0xF4, 0x72, 0x17, 0x57, 0x02, + 0xE0, 0x05, 0xCB, 0x11, 0x0B, 0xFC, 0x66, 0x1F, 0xC0, 0x0C, 0x42, 0x2A, + 0xCE, 0x0E, 0x0F, 0x20, 0x52, 0x12, 0x29, 0x11, 0x38, 0x0C, 0xEC, 0x00, + 0x11, 0xF4, 0x74, 0xEB, 0x06, 0xDE, 0xE8, 0xDB, 0x6F, 0xD8, 0x11, 0xDB, + 0x7F, 0xEB, 0x08, 0xEA, 0x7C, 0x0B, 0x26, 0xFE, 0x6B, 0x20, 0xF9, 0x0F, + 0x8E, 0x1A, 0xF7, 0x1D, 0x5D, 0x0A, 0x85, 0x2B, 0xCD, 0xFB, 0xA2, 0x25, + 0x8A, 0xFB, 0x0F, 0x1C, 0xE5, 0x0B, 0x32, 0x16, 0xC1, 0x17, 0x93, 0x0C, + 0xE1, 0x0E, 0xCB, 0xF8, 0xDF, 0xF3, 0x7A, 0xE1, 0xB2, 0xDC, 0xA7, 0xD5, + 0x9D, 0xD9, 0x63, 0xDE, 0x68, 0xF3, 0x8A, 0xF2, 0x3E, 0x15, 0xEE, 0x09, + 0x85, 0x1A, 0x1A, 0x1D, 0x2A, 0x16, 0xC8, 0x1D, 0xFE, 0x01, 0x03, 0x18, + 0xB7, 0xEB, 0x76, 0x0F, 0xA2, 0xED, 0x8C, 0x09, 0x0E, 0xFE, 0xC5, 0x02, + 0x1B, 0x0B, 0x9B, 0xF6, 0x04, 0x02, 0xAC, 0xE1, 0xE3, 0xEF, 0xC7, 0xD3, + 0x87, 0xDE, 0x5E, 0xD5, 0x7E, 0xEA, 0xEB, 0xEB, 0x8D, 0x0C, 0x36, 0x0B, + 0xB8, 0x20, 0x57, 0x1B, 0xA5, 0x26, 0xCE, 0x22, 0xA6, 0x18, 0x92, 0x22, + 0x9C, 0xFA, 0x35, 0x19, 0x82, 0xE9, 0x6B, 0x0C, 0x03, 0xEE, 0x03, 0x03, + 0xBA, 0x01, 0xB8, 0xFB, 0xEA, 0x0B, 0xBD, 0xEE, 0xA9, 0x08, 0x30, 0xE2, + 0x57, 0xF5, 0x8D, 0xE0, 0x61, 0xEF, 0xA5, 0xF1, 0x70, 0x07, 0xD0, 0x0F, + 0x3E, 0x14, 0xA4, 0x1F, 0x59, 0x24, 0xA3, 0x28, 0xFD, 0x2A, 0x21, 0x2C, + 0xC8, 0x15, 0xA5, 0x21, 0x1E, 0xF6, 0x08, 0x0D, 0x70, 0xE4, 0xA5, 0xFA, + 0xF0, 0xE8, 0xAE, 0xEF, 0x8D, 0xF9, 0x87, 0xE7, 0x64, 0x03, 0x63, 0xDD, + 0x01, 0xFE, 0xB5, 0xDB, 0x69, 0xF3, 0x1B, 0xEC, 0x23, 0xEF, 0x44, 0xFC, + 0xB0, 0xF7, 0xC0, 0x0C, 0x40, 0x0F, 0xF0, 0x1C, 0xBF, 0x26, 0x3D, 0x27, + 0xBE, 0x23, 0x3E, 0x22, 0xC4, 0x05, 0xD9, 0x0B, 0x78, 0xE5, 0xBD, 0xF1, + 0x7B, 0xD5, 0xE3, 0xE0, 0xB7, 0xE0, 0xC2, 0xDB, 0xCE, 0xF6, 0xC0, 0xDA, + 0x3F, 0xFD, 0x77, 0xDF, 0x58, 0x06, 0x0A, 0xEE, 0x58, 0x01, 0x91, 0xFF, + 0xD4, 0xF4, 0x99, 0x0F, 0x7F, 0xFA, 0x01, 0x1E, 0x0C, 0x12, 0x7A, 0x29, + 0x4B, 0x24, 0xF8, 0x2A, 0xF7, 0x1C, 0x2E, 0x1A, 0x45, 0x03, 0x85, 0xFE, + 0x61, 0xE8, 0xC0, 0xE6, 0xF4, 0xE1, 0x43, 0xDE, 0x17, 0xF2, 0xE6, 0xDF, + 0x04, 0x0C, 0xB8, 0xE8, 0x4B, 0x19, 0xF1, 0xF8, 0x06, 0x17, 0x1B, 0x08, + 0xBC, 0x04, 0x5E, 0x13, 0xD1, 0xF6, 0xA1, 0x19, 0x5B, 0xFD, 0x34, 0x1F, + 0x4B, 0x11, 0x2D, 0x21, 0xA5, 0x1A, 0x1D, 0x17, 0x25, 0x0F, 0x74, 0xFC, + 0x1D, 0xF1, 0xB4, 0xDF, 0x8A, 0xD9, 0x3F, 0xCF, 0x52, 0xE2, 0x32, 0xCF, + 0x4A, 0xEE, 0x5A, 0xDE, 0x34, 0x04, 0xBB, 0xEF, 0x2B, 0x1A, 0x4A, 0x01, + 0x1F, 0x17, 0xD5, 0x0E, 0x29, 0x02, 0x53, 0x14, 0x87, 0xF1, 0x17, 0x14, + 0xA7, 0xF6, 0x9D, 0x15, 0x09, 0x04, 0x58, 0x11, 0x41, 0x09, 0x0B, 0x00, + 0xE0, 0xF8, 0x8F, 0xE4, 0xEA, 0xE0, 0x7D, 0xD0, 0x80, 0xD8, 0x11, 0xD3, + 0x5C, 0xE0, 0xCE, 0xE2, 0x87, 0xF8, 0x89, 0xF5, 0xCD, 0x1B, 0x22, 0x0A, + 0x67, 0x2B, 0x1C, 0x1C, 0x45, 0x1F, 0x6B, 0x23, 0x8E, 0x02, 0xB2, 0x1E, + 0x53, 0xF3, 0x03, 0x18, 0xCC, 0xF5, 0x36, 0x12, 0x8F, 0x04, 0xD2, 0x06, + 0xD4, 0x05, 0x58, 0xF0, 0xF8, 0xEF, 0x6C, 0xD8, 0x74, 0xEC, 0xCF, 0xD9, + 0x78, 0xE7, 0xD1, 0xE3, 0x3D, 0xEB, 0xF4, 0xEF, 0x2D, 0x05, 0x96, 0x01, + 0xC4, 0x22, 0x8D, 0x16, 0x26, 0x2A, 0x49, 0x22, 0x4E, 0x15, 0x1D, 0x1D, + 0xC0, 0xF7, 0x3E, 0x0D, 0x8E, 0xEA, 0x98, 0x02, 0xB0, 0xF0, 0xAA, 0xF7, + 0x65, 0xF7, 0xAF, 0xE0, 0x6C, 0xFE, 0xBD, 0xDA, 0x58, 0xFB, 0x90, 0xD8, + 0x2B, 0xEB, 0x0F, 0xD9, 0x58, 0xDE, 0xB2, 0xE1, 0xE2, 0xE9, 0xAF, 0xF3, + 0x81, 0x0B, 0x20, 0x0E, 0xF2, 0x26, 0xD5, 0x24, 0x7F, 0x27, 0xF8, 0x27, + 0x6B, 0x0D, 0xB8, 0x19, 0x1C, 0xF2, 0x9D, 0x07, 0x82, 0xED, 0x12, 0xF6, + 0xF0, 0xED, 0x65, 0xEF, 0xD2, 0xFA, 0x51, 0xEB, 0x0C, 0x0A, 0xC0, 0xE5, + 0x4B, 0x08, 0xCE, 0xE5, 0x7B, 0xF8, 0xF9, 0xED, 0x5F, 0xEE, 0x27, 0xFC, + 0x22, 0xFD, 0x8F, 0x12, 0xCF, 0x17, 0x98, 0x2A, 0x45, 0x28, 0xA8, 0x35, + 0x40, 0x1B, 0xF2, 0x27, 0x66, 0xFF, 0x97, 0x0F, 0xE5, 0xE5, 0x89, 0xF7, + 0xC7, 0xDF, 0x9C, 0xEB, 0xA7, 0xEA, 0xD3, 0xE6, 0xF5, 0xFF, 0x4D, 0xE2, + 0x0D, 0x0E, 0x4F, 0xE4, 0x01, 0x08, 0xC0, 0xEB, 0xC2, 0xF5, 0x7A, 0xF6, + 0xA1, 0xEF, 0x25, 0x04, 0xB3, 0xFC, 0x64, 0x18, 0x56, 0x13, 0x0B, 0x27, + 0x40, 0x18, 0x8E, 0x20, 0x89, 0xFE, 0x15, 0x05, 0xB0, 0xEE, 0x27, 0xEE, + 0xE2, 0xDF, 0x8E, 0xE0, 0xA8, 0xD6, 0x4B, 0xD9, 0x76, 0xE4, 0xA3, 0xD8, + 0xB9, 0xFF, 0xAC, 0xE0, 0x04, 0x12, 0x08, 0xF1, 0x30, 0x0F, 0xBE, 0x01, + 0x69, 0x01, 0x68, 0x0D, 0x0F, 0xFF, 0x78, 0x1C, 0x87, 0x0B, 0x3A, 0x2A, + 0xD7, 0x16, 0x18, 0x27, 0x27, 0x17, 0xE2, 0x18, 0x15, 0x0B, 0x7B, 0x02, + 0x62, 0xF4, 0xC6, 0xED, 0x95, 0xDC, 0xED, 0xE1, 0xEB, 0xD9, 0xB3, 0xDE, + 0xE1, 0xF2, 0xC3, 0xE7, 0xB8, 0x13, 0x1A, 0xFC, 0x64, 0x25, 0x25, 0x13, + 0xB1, 0x1B, 0x48, 0x1E, 0x31, 0x0B, 0x15, 0x24, 0x47, 0x0C, 0xC0, 0x2B, + 0xD4, 0x07, 0xE4, 0x24, 0xE6, 0x09, 0x03, 0x17, 0xB3, 0x0F, 0x34, 0x04, + 0xC1, 0x05, 0x76, 0xED, 0xED, 0xEC, 0x55, 0xDD, 0x19, 0xD6, 0x20, 0xD4, + 0xB2, 0xD9, 0x30, 0xD8, 0x87, 0xF5, 0x06, 0xEB, 0xDC, 0x14, 0xC1, 0x07, + 0x3E, 0x1C, 0xD8, 0x18, 0x1D, 0x0D, 0x44, 0x1C, 0xB4, 0xFB, 0x5E, 0x1E, + 0x23, 0xF1, 0x64, 0x12, 0x41, 0xF3, 0x91, 0x08, 0xFD, 0x01, 0x93, 0xFF, + 0xA4, 0x09, 0x03, 0xF0, 0x60, 0xFF, 0xBC, 0xE2, 0xDB, 0xE6, 0x5B, 0xDA, + 0x7F, 0xDA, 0x49, 0xDB, 0x40, 0xE8, 0x44, 0xEC, 0x33, 0x0C, 0x50, 0x0B, + 0xC2, 0x25, 0x37, 0x26, 0x99, 0x1E, 0x05, 0x30, 0xA6, 0x12, 0x8D, 0x26, + 0x60, 0x00, 0x92, 0x19, 0x3F, 0xF1, 0xDE, 0x11, 0x6D, 0xF6, 0x5E, 0x0B, + 0x00, 0x06, 0xC0, 0xFD, 0xA4, 0x0E, 0x32, 0xF1, 0x2B, 0x03, 0xD6, 0xE7, + 0x9C, 0xF0, 0x08, 0xE5, 0x23, 0xEC, 0x24, 0xEC, 0xE3, 0x02, 0x55, 0x06, + 0x49, 0x1F, 0x62, 0x24, 0xB7, 0x2A, 0xF2, 0x2E, 0x7E, 0x22, 0xB2, 0x26, + 0xDE, 0x09, 0x53, 0x14, 0x0E, 0xED, 0x2B, 0x05, 0x93, 0xE0, 0xF2, 0xF9, + 0x3F, 0xE9, 0x5C, 0xED, 0x7F, 0xFD, 0x2E, 0xE3, 0x72, 0x05, 0x55, 0xDF, + 0x4E, 0xFD, 0x11, 0xE0, 0x6E, 0xEE, 0x60, 0xE4, 0x0F, 0xF4, 0x55, 0xF8, + 0xFA, 0x11, 0xC6, 0x1A, 0x90, 0x1A, 0x44, 0x25, 0x8A, 0x1D, 0x68, 0x23, + 0x5B, 0x16, 0xED, 0x17, 0x9A, 0xFE, 0x8F, 0x08, 0x0E, 0xE5, 0x81, 0xFA, + 0x18, 0xDD, 0x3D, 0xED, 0x9A, 0xEB, 0x4C, 0xE4, 0x9C, 0x02, 0xBF, 0xE6, + 0x3F, 0x0B, 0x14, 0xEE, 0xE5, 0x02, 0xB5, 0xF5, 0x64, 0x02, 0xA0, 0x0B, + 0x53, 0x01, 0x9A, 0x16, 0xEB, 0x0A, 0xBB, 0x24, 0x71, 0x1E, 0xD5, 0x31, + 0x3D, 0x28, 0x68, 0x2D, 0x06, 0x1C, 0xEA, 0x1B, 0x37, 0xFC, 0x58, 0x05, + 0xC2, 0xE0, 0x70, 0xEF, 0x92, 0xDA, 0xA1, 0xDD, 0x84, 0xEE, 0xAD, 0xDB, + 0xBB, 0x04, 0x49, 0xE7, 0x7E, 0x07, 0x38, 0xF5, 0x4A, 0x09, 0x37, 0x02, + 0x28, 0x01, 0x5A, 0x09, 0xA3, 0xF9, 0xEB, 0x12, 0xF9, 0x01, 0xD4, 0x1F, + 0x33, 0x12, 0x4A, 0x20, 0xC2, 0x18, 0x46, 0x12, 0x56, 0x07, 0xCB, 0xFB, + 0x44, 0xEA, 0xCA, 0xE4, 0x1D, 0xD4, 0x27, 0xCF, 0x4A, 0xDC, 0x3E, 0xCB, + 0x33, 0xF6, 0x6E, 0xDA, 0xDA, 0x0E, 0x69, 0xF2, 0x4B, 0x18, 0xFF, 0x05, + 0xB1, 0x10, 0xDE, 0x0D, 0x1D, 0x00, 0xF8, 0x12, 0x95, 0xF8, 0xE1, 0x1B, + 0x13, 0x02, 0x4B, 0x20, 0xBE, 0x12, 0x9F, 0x18, 0xD7, 0x15, 0x55, 0x08, + 0x16, 0x05, 0x47, 0xF5, 0xBD, 0xE8, 0x07, 0xE0, 0x79, 0xDF, 0xC7, 0xD6, + 0x28, 0xF7, 0x84, 0xE5, 0x14, 0x0A, 0x52, 0xFC, 0x7A, 0x1D, 0x54, 0x14, + 0x18, 0x27, 0x5D, 0x21, 0x49, 0x1A, 0x15, 0x22, 0xDD, 0x03, 0x15, 0x21, + 0x52, 0xF8, 0x43, 0x1E, 0x6B, 0xFE, 0xF4, 0x13, 0x26, 0x0A, 0xA8, 0x03, + 0xEA, 0x06, 0x18, 0xF2, 0xEC, 0xF1, 0x29, 0xDE, 0x42, 0xE1, 0xE3, 0xD0, + 0xAB, 0xDB, 0x09, 0xD3, 0xAB, 0xEB, 0x5D, 0xE6, 0x24, 0x0A, 0x57, 0x03, + 0xB1, 0x25, 0xBA, 0x19, 0x22, 0x26, 0xEB, 0x1C, 0xD7, 0x0E, 0xAE, 0x17, + 0x70, 0xF1, 0x93, 0x0E, 0x65, 0xE5, 0x15, 0x01, 0xD0, 0xEB, 0x3D, 0xF0, + 0x5B, 0xF8, 0x32, 0xE4, 0x2D, 0xF6, 0xFD, 0xD9, 0x5F, 0xE1, 0xAA, 0xCB, + 0xBA, 0xE1, 0xA2, 0xD4, 0x08, 0xE9, 0xD2, 0xE5, 0x69, 0xFC, 0x70, 0x00, + 0x50, 0x1B, 0x0D, 0x1D, 0x5D, 0x2E, 0x56, 0x29, 0xAD, 0x26, 0x44, 0x27, + 0xBA, 0x0A, 0x87, 0x1D, 0x3E, 0xEF, 0x21, 0x0D, 0x2E, 0xEA, 0x1B, 0xFB, + 0x71, 0xF6, 0x50, 0xEE, 0xCE, 0xFB, 0x66, 0xE1, 0x3E, 0x05, 0x55, 0xEA, + 0x99, 0x02, 0xCB, 0xEF, 0x1C, 0xF4, 0x00, 0xEF, 0xE6, 0xF0, 0x4A, 0xFB, + 0xDE, 0x03, 0xE4, 0x13, 0x98, 0x20, 0x46, 0x27, 0xA4, 0x2C, 0x9B, 0x2A, + 0x71, 0x1E, 0x04, 0x22, 0x66, 0xFE, 0xBB, 0x0F, 0x62, 0xE6, 0xC0, 0xF5, + 0x67, 0xE8, 0xE7, 0xDF, 0x7F, 0xEF, 0x44, 0xDB, 0xD9, 0xFB, 0x66, 0xE0, + 0xFB, 0x04, 0xF5, 0xE5, 0x17, 0xFC, 0x5D, 0xE4, 0x29, 0xEF, 0x9E, 0xEB, + 0xDF, 0xEE, 0x83, 0xFF, 0x5D, 0x03, 0x58, 0x16, 0x36, 0x18, 0xDD, 0x1E, + 0x6B, 0x1C, 0x42, 0x1D, 0xDC, 0x05, 0x51, 0x0D, 0x97, 0xE8, 0x82, 0xF0, + 0x16, 0xD9, 0xC1, 0xDE, 0x5E, 0xDC, 0xB5, 0xD7, 0x25, 0xF0, 0x68, 0xDD, + 0xEB, 0x09, 0x57, 0xEC, 0x1A, 0x13, 0x03, 0xF5, 0x66, 0x0A, 0xA5, 0xFD, + 0xA4, 0xFB, 0xA4, 0x0B, 0xB7, 0xFC, 0xEE, 0x1E, 0x53, 0x0A, 0x98, 0x27, + 0x9F, 0x1A, 0xF6, 0x27, 0x17, 0x15, 0xF7, 0x1B, 0x56, 0xF5, 0x49, 0xFE, + 0xB2, 0xE9, 0x93, 0xEF, 0xF3, 0xE0, 0x61, 0xE1, 0x59, 0xE3, 0x4A, 0xDC, + 0xE7, 0xF9, 0x0A, 0xE9, 0x18, 0x13, 0xDB, 0xF8, 0xD0, 0x19, 0x93, 0x03, + 0xA3, 0x0D, 0xF6, 0x0D, 0xBC, 0xFD, 0x5F, 0x19, 0x97, 0xFD, 0xD7, 0x1E, + 0xE9, 0x08, 0xE4, 0x1A, 0xAB, 0x09, 0x8A, 0x0C, 0x69, 0x06, 0x28, 0xFD, + 0x94, 0xF7, 0x5F, 0xEB, 0xC5, 0xDD, 0x58, 0xD4, 0x47, 0xCD, 0x2D, 0xC6, + 0x92, 0xD8, 0x4C, 0xD0, 0xD2, 0xFB, 0xFB, 0xE9, 0x63, 0x19, 0xAF, 0x00, + 0x8D, 0x20, 0x01, 0x12, 0x3D, 0x10, 0x3A, 0x1D, 0xFA, 0x00, 0x4E, 0x20, + 0xFA, 0x04, 0xE7, 0x1C, 0xD3, 0x02, 0x9F, 0x0C, 0xC9, 0x06, 0x61, 0x01, + 0xAF, 0x09, 0x8B, 0xFA, 0x83, 0xFB, 0x5F, 0xEB, 0x83, 0xE4, 0x34, 0xDA, + 0xEE, 0xDA, 0x0C, 0xDB, 0x6B, 0xF0, 0xD4, 0xF1, 0x0C, 0x13, 0x7C, 0x0D, + 0x09, 0x2B, 0x92, 0x22, 0x2C, 0x24, 0x44, 0x2E, 0xF1, 0x0E, 0x61, 0x2E, + 0xA8, 0xFE, 0x21, 0x22, 0xF9, 0xF5, 0xAF, 0x0F, 0xC0, 0xFA, 0xEE, 0x01, + 0xB3, 0x08, 0x29, 0xFD, 0xB2, 0x0A, 0xED, 0xF3, 0x7F, 0xF8, 0x51, 0xE2, + 0x3E, 0xE1, 0xF4, 0xD8, 0xC8, 0xDF, 0xC3, 0xE5, 0xCC, 0xF8, 0x57, 0xFF, + 0x6A, 0x19, 0xAB, 0x16, 0x3A, 0x23, 0xCE, 0x23, 0xCE, 0x0F, 0xD8, 0x24, + 0x01, 0xFD, 0x39, 0x16, 0xF8, 0xEA, 0x2A, 0x00, 0x77, 0xE2, 0xEC, 0xEC, + 0x08, 0xEE, 0x79, 0xE7, 0x8B, 0xFF, 0xE1, 0xE7, 0xCF, 0x02, 0x0F, 0xE2, + 0xD4, 0xF3, 0x11, 0xDB, 0xE8, 0xE6, 0x96, 0xE4, 0xEA, 0xF1, 0x54, 0xFC, + 0xB3, 0x0F, 0x2E, 0x17, 0x56, 0x23, 0x4E, 0x2C, 0x1B, 0x28, 0xAF, 0x2C, + 0xBD, 0x18, 0x4E, 0x23, 0x6B, 0xFD, 0xFD, 0x12, 0x3C, 0xE4, 0x8B, 0xFB, + 0x9D, 0xE1, 0xAB, 0xEE, 0x66, 0xF5, 0xF4, 0xEE, 0x96, 0x0C, 0xFE, 0xF1, + 0xB8, 0x10, 0xBE, 0xF0, 0xD0, 0x05, 0x51, 0xF7, 0x98, 0xFE, 0x95, 0x08, + 0x5B, 0x0A, 0x11, 0x1D, 0xF9, 0x24, 0xDA, 0x31, 0x98, 0x26, 0x1B, 0x2E, + 0xB4, 0x1F, 0x4A, 0x26, 0x14, 0x0E, 0x14, 0x1A, 0x67, 0xF0, 0xE5, 0xFF, + 0x4C, 0xD9, 0xEF, 0xE6, 0x59, 0xDC, 0x09, 0xDE, 0xF3, 0xF3, 0x30, 0xE2, + 0x99, 0x09, 0xF1, 0xE6, 0x63, 0x08, 0xD8, 0xEC, 0xB0, 0xFD, 0x97, 0xFB, + 0x33, 0x01, 0xF4, 0x11, 0x6B, 0xFE, 0x07, 0x15, 0x06, 0x05, 0x6C, 0x13, + 0x72, 0x13, 0x38, 0x16, 0x20, 0x17, 0x6A, 0x15, 0x38, 0x04, 0xE5, 0x02, + 0x14, 0xE3, 0xF0, 0xE5, 0x7B, 0xD0, 0x32, 0xD4, 0xAE, 0xDB, 0x63, 0xD7, + 0x02, 0xFA, 0xFC, 0xE2, 0xCD, 0x0E, 0xF2, 0xF2, 0xE8, 0x0D, 0x4F, 0x08, + 0x5B, 0x09, 0x80, 0x16, 0xA5, 0x03, 0x55, 0x1E, 0x8C, 0x01, 0x08, 0x1F, + 0x84, 0x0C, 0x54, 0x1F, 0x37, 0x1A, 0xEE, 0x20, 0xCA, 0x1A, 0x5B, 0x16, + 0xFD, 0x01, 0xFC, 0xFB, 0x4B, 0xE4, 0x4C, 0xE2, 0x6B, 0xDA, 0x4D, 0xDC, + 0x97, 0xF1, 0xF3, 0xE6, 0x10, 0x10, 0x01, 0xFA, 0xA0, 0x1D, 0x2F, 0x11, + 0x14, 0x1E, 0x1E, 0x1D, 0x36, 0x11, 0xFE, 0x21, 0x05, 0xFE, 0xDE, 0x1C, + 0x96, 0xF7, 0x89, 0x13, 0x62, 0x01, 0x7F, 0x0F, 0x1F, 0x10, 0x0B, 0x0A, + 0x5B, 0x0A, 0x57, 0xF5, 0xDB, 0xF0, 0xAC, 0xDA, 0x5A, 0xD7, 0xB6, 0xCB, + 0xB4, 0xDC, 0x0F, 0xD3, 0x66, 0xFE, 0x5D, 0xEB, 0x87, 0x10, 0xB0, 0xFC, + 0xF9, 0x1A, 0x1C, 0x0D, 0xE2, 0x18, 0x30, 0x1B, 0x06, 0x07, 0xB7, 0x1B, + 0x11, 0xF2, 0xD0, 0x0E, 0xA1, 0xED, 0x4A, 0x04, 0x8B, 0xFB, 0x03, 0x00, + 0x06, 0x0A, 0x3F, 0xF6, 0x47, 0x01, 0x52, 0xE3, 0x2C, 0xEB, 0x5F, 0xD6, + 0x46, 0xE8, 0x84, 0xDC, 0x31, 0xEF, 0xC2, 0xEF, 0x0B, 0x05, 0x93, 0x05, + 0x4D, 0x21, 0x26, 0x1A, 0xFC, 0x30, 0xF6, 0x2C, 0x6E, 0x28, 0x49, 0x32, + 0x67, 0x09, 0x6A, 0x22, 0x89, 0xEE, 0x71, 0x0C, 0x83, 0xE8, 0xB2, 0xFE, + 0x67, 0xFA, 0x2C, 0xF8, 0xEC, 0x02, 0xF3, 0xEA, 0x54, 0xF4, 0x6E, 0xDD, + 0x65, 0xEF, 0x1E, 0xE2, 0xC3, 0xED, 0xAF, 0xEF, 0x08, 0xF3, 0xA5, 0xFD, + 0xAC, 0x07, 0x4C, 0x0C, 0xA8, 0x1E, 0xCE, 0x1D, 0x39, 0x28, 0x98, 0x28, + 0x0F, 0x15, 0xC4, 0x1D, 0x67, 0xF3, 0xDC, 0x02, 0xD6, 0xD9, 0x2E, 0xEB, + 0xA3, 0xE0, 0xE6, 0xE0, 0xC8, 0xF1, 0x91, 0xD9, 0x1B, 0xF6, 0x46, 0xD2, + 0x92, 0xFA, 0x3E, 0xDA, 0x29, 0xF5, 0xB6, 0xE7, 0xA3, 0xED, 0x1E, 0xF5, + 0x01, 0xF5, 0x16, 0x02, 0x44, 0x0A, 0x33, 0x13, 0xC2, 0x21, 0x3F, 0x24, + 0x4D, 0x25, 0x02, 0x26, 0xD9, 0x0D, 0x05, 0x11, 0x1A, 0xEC, 0x6D, 0xF6, + 0x37, 0xDF, 0xB2, 0xE6, 0x52, 0xEE, 0x35, 0xDD, 0xA3, 0xFF, 0x1F, 0xE6, + 0xCA, 0x0C, 0x9D, 0xF0, 0xA1, 0x0E, 0xEE, 0xFA, 0xE8, 0x04, 0xEB, 0x06, + 0x43, 0xFC, 0x39, 0x0F, 0x4A, 0x00, 0xCA, 0x17, 0xBC, 0x11, 0x8E, 0x24, + 0xEA, 0x22, 0x33, 0x2C, 0xE8, 0x1B, 0xDE, 0x1E, 0x7C, 0xFC, 0x77, 0x01, + 0xF0, 0xE3, 0x14, 0xE5, 0x3F, 0xD9, 0x76, 0xDC, 0xAD, 0xE6, 0x5E, 0xE0, + 0xD3, 0xFF, 0x3E, 0xE6, 0xBF, 0x12, 0xA1, 0xF0, 0x30, 0x12, 0xF7, 0xFE, + 0xDF, 0x03, 0x53, 0x08, 0x96, 0xF3, 0xC5, 0x09, 0xEA, 0xF2, 0xF8, 0x0D, + 0x85, 0x01, 0xD2, 0x14, 0xD5, 0x0C, 0xC8, 0x0F, 0xE5, 0xFD, 0xA7, 0xF7, + 0x56, 0xDB, 0x1E, 0xD9, 0xA6, 0xD2, 0xA5, 0xD0, 0xCB, 0xD7, 0x2C, 0xD4, + 0x47, 0xEC, 0xA5, 0xDB, 0x77, 0x07, 0x57, 0xEA, 0x4B, 0x1B, 0x67, 0x01, + 0x03, 0x1B, 0x08, 0x14, 0xB9, 0x0A, 0x35, 0x19, 0x75, 0xF8, 0x97, 0x16, + 0xD1, 0xFC, 0x17, 0x1A, 0xAB, 0x0C, 0x4A, 0x19, 0xE9, 0x06, 0x0F, 0x03, + 0x70, 0x05, 0x9D, 0xF6, 0xA9, 0xF6, 0xD9, 0xEB, 0x1B, 0xE2, 0x87, 0xE3, + 0x2E, 0xE1, 0x5C, 0xE3, 0x89, 0xF6, 0xC9, 0xED, 0xF8, 0x16, 0x54, 0x06, + 0x47, 0x2A, 0x8E, 0x20, 0x15, 0x26, 0xFB, 0x2A, 0x09, 0x0C, 0x20, 0x23, + 0xCF, 0xFA, 0xA7, 0x19, 0x2A, 0x00, 0xD9, 0x0F, 0x19, 0x05, 0xD7, 0x05, + 0x57, 0x07, 0x56, 0xF7, 0xED, 0xFE, 0x1C, 0xE6, 0xD4, 0xE7, 0x01, 0xD9, + 0xFB, 0xD8, 0x7B, 0xD5, 0xC3, 0xDD, 0x84, 0xDB, 0x64, 0xF9, 0x1C, 0xF1, + 0x1F, 0x17, 0x78, 0x0F, 0x20, 0x25, 0x87, 0x23, 0xB9, 0x11, 0x0F, 0x1F, + 0xBE, 0xF5, 0x2A, 0x0F, 0x03, 0xED, 0xA1, 0x02, 0x95, 0xEA, 0x26, 0xF6, + 0xFB, 0xF6, 0x27, 0xEE, 0x66, 0x03, 0x1D, 0xE6, 0x35, 0xFD, 0xCB, 0xE0, + 0x7B, 0xEE, 0x56, 0xE1, 0x7E, 0xE5, 0x19, 0xE7, 0x5B, 0xF1, 0xB4, 0xF7, + 0xBB, 0x0C, 0x6B, 0x14, 0xD7, 0x27, 0x5E, 0x2F, 0xFE, 0x26, 0xB0, 0x33, + 0x2A, 0x09, 0xB4, 0x23, 0x55, 0xF5, 0xBB, 0x0F, 0x51, 0xEA, 0x87, 0x00, + 0x83, 0xF0, 0x51, 0xF8, 0x04, 0x02, 0x6A, 0xF1, 0xCA, 0x0B, 0x5D, 0xEE, + 0x85, 0x05, 0x54, 0xF0, 0xF4, 0xF8, 0x32, 0xF5, 0x23, 0xF2, 0x4D, 0xFC, + 0xE4, 0xFE, 0x2F, 0x0E, 0x3A, 0x18, 0xF3, 0x25, 0x14, 0x1E, 0xB2, 0x2D, + 0x20, 0x1C, 0x33, 0x24, 0x64, 0x04, 0xF1, 0x0B, 0x79, 0xE3, 0xBD, 0xF3, + 0xF3, 0xD3, 0x17, 0xE4, 0x8C, 0xDF, 0xB9, 0xDB, 0xD4, 0xF5, 0xEE, 0xDA, + 0x7E, 0x05, 0x1E, 0xE4, 0x36, 0x07, 0xDA, 0xF0, 0xC2, 0xFE, 0x9F, 0xF9, + 0xFD, 0xFA, 0x94, 0x04, 0x2A, 0x08, 0x35, 0x17, 0xD1, 0x1E, 0xA7, 0x27, + 0x13, 0x1F, 0x28, 0x21, 0x0D, 0x12, 0x2F, 0x0F, 0xB6, 0xF6, 0xBC, 0xFA, + 0x37, 0xDE, 0x1A, 0xEB, 0x3F, 0xDA, 0x2A, 0xE1, 0x85, 0xED, 0xED, 0xE0, + 0xD9, 0x06, 0x29, 0xED, 0x72, 0x1A, 0xF7, 0x02, 0x5A, 0x18, 0x81, 0x11, + 0x13, 0x0D, 0xE5, 0x19, 0x55, 0x10, 0x83, 0x29, 0x18, 0x0C, 0x8A, 0x27, + 0x66, 0x13, 0x21, 0x25, 0x2B, 0x1E, 0x84, 0x1F, 0x1D, 0x14, 0xC3, 0x0F, + 0x71, 0xF8, 0x1E, 0xFC, 0x2A, 0xE0, 0x70, 0xE9, 0x89, 0xDD, 0xD6, 0xDD, + 0xFB, 0xEE, 0xB8, 0xE1, 0x9B, 0x09, 0x38, 0xF6, 0x75, 0x17, 0x59, 0x0B, + 0x6C, 0x0E, 0xFA, 0x18, 0x88, 0x02, 0x02, 0x16, 0xCD, 0xF6, 0xFB, 0x0F, + 0x07, 0xF7, 0x90, 0x0F, 0x16, 0x07, 0xB3, 0x0E, 0x73, 0x0E, 0xC4, 0x03, + 0xA8, 0x00, 0xB1, 0xF2, 0x02, 0xE7, 0x32, 0xE0, 0x9C, 0xD6, 0xAB, 0xD1, + 0x37, 0xDD, 0x78, 0xD0, 0x57, 0xF9, 0x62, 0xE5, 0xE6, 0x11, 0xD2, 0x03, + 0xCC, 0x1F, 0x68, 0x17, 0xB9, 0x18, 0x3A, 0x1B, 0xB0, 0x01, 0xF6, 0x15, + 0x58, 0xF0, 0xA8, 0x11, 0x3B, 0xF8, 0x5B, 0x10, 0x60, 0x0A, 0x13, 0x0A, + 0x1F, 0x12, 0xF1, 0xFF, 0x54, 0x06, 0x05, 0xF4, 0xBC, 0xF4, 0x22, 0xE9, + 0xB8, 0xEC, 0x13, 0xE4, 0x32, 0xFB, 0x04, 0xF2, 0x4E, 0x1D, 0x6D, 0x12, + 0x1F, 0x29, 0x59, 0x24, 0xE8, 0x29, 0x02, 0x2C, 0x57, 0x18, 0x6D, 0x27, + 0xA3, 0xFC, 0x32, 0x1C, 0x49, 0xEE, 0x34, 0x10, 0x7E, 0xF6, 0x28, 0x04, + 0x4B, 0x03, 0x20, 0xF7, 0x84, 0x06, 0x3E, 0xEE, 0xE4, 0xF8, 0x9F, 0xE4, + 0x58, 0xEA, 0x45, 0xDE, 0x3A, 0xF2, 0x58, 0xEA, 0xAF, 0xF6, 0xA2, 0xF5, + 0x09, 0x07, 0xA8, 0x08, 0x95, 0x1E, 0x45, 0x1C, 0x8C, 0x21, 0x4C, 0x20, + 0xD6, 0x08, 0x69, 0x15, 0xAC, 0xE9, 0x78, 0x03, 0x9E, 0xDE, 0xB9, 0xF1, + 0x13, 0xE6, 0xE3, 0xE1, 0xC5, 0xF3, 0x31, 0xDB, 0x98, 0xF7, 0x35, 0xDB, + 0xF8, 0xEF, 0xC1, 0xDC, 0x01, 0xF0, 0xD9, 0xE7, 0x48, 0xF3, 0xC7, 0xF5, + 0x2F, 0xFE, 0x41, 0x08, 0x15, 0x18, 0x3E, 0x1F, 0x29, 0x2A, 0x82, 0x2A, + 0xE2, 0x22, 0x34, 0x26, 0xAB, 0x04, 0xE5, 0x15, 0x64, 0xEC, 0x67, 0x02, + 0x22, 0xE6, 0x9E, 0xEE, 0x36, 0xF3, 0x37, 0xE5, 0x20, 0x01, 0x6F, 0xE7, + 0xDE, 0x03, 0xBB, 0xED, 0x08, 0x09, 0xD2, 0xFC, 0x80, 0x04, 0xDB, 0x06, + 0x6D, 0xFC, 0xA9, 0x0D, 0xB1, 0x05, 0x9E, 0x1A, 0xE1, 0x19, 0x2B, 0x24, + 0xD7, 0x22, 0xD6, 0x22, 0x85, 0x11, 0xA0, 0x14, 0x01, 0xF5, 0xDD, 0xFF, + 0x00, 0xE0, 0x1C, 0xE7, 0xF1, 0xDF, 0x78, 0xD6, 0x9D, 0xF0, 0xE7, 0xD4, + 0x7E, 0xFD, 0xCA, 0xE0, 0x7D, 0x07, 0x17, 0xF1, 0xB8, 0x06, 0x65, 0xFB, + 0x8B, 0xF9, 0x87, 0x00, 0x64, 0xF2, 0x08, 0x08, 0xA1, 0xFE, 0xCF, 0x10, + 0x2A, 0x10, 0x28, 0x13, 0x40, 0x12, 0x69, 0x0B, 0x08, 0xFF, 0xF5, 0xFC, + 0x0B, 0xE7, 0x00, 0xE8, 0xBE, 0xE0, 0x0F, 0xD6, 0x71, 0xE3, 0xD7, 0xD4, + 0xCB, 0xF4, 0xE6, 0xE2, 0xE7, 0x0E, 0x9C, 0xF8, 0xD5, 0x1F, 0xF1, 0x0B, + 0xD3, 0x18, 0xEC, 0x14, 0x82, 0x05, 0xCF, 0x19, 0xF2, 0xFC, 0xE9, 0x1C, + 0x26, 0x05, 0xCB, 0x1B, 0xD6, 0x0E, 0xF5, 0x13, 0x0D, 0x0A, 0xA5, 0x08, + 0x77, 0xF8, 0xD0, 0xF7, 0x90, 0xE2, 0xB6, 0xE0, 0xD1, 0xE2, 0x8A, 0xE0, + 0x1E, 0xED, 0xB0, 0xE7, 0xF1, 0x01, 0xB2, 0xF5, 0xB5, 0x1A, 0xCD, 0x08, + 0xE0, 0x21, 0xA0, 0x15, 0x2D, 0x10, 0x94, 0x19, 0x7A, 0xF9, 0x3D, 0x17, + 0xCB, 0xF0, 0x52, 0x0F, 0x0C, 0xF9, 0x01, 0x05, 0x02, 0xFE, 0x39, 0xF8, + 0x44, 0xF0, 0x19, 0xE4, 0x25, 0xED, 0xF1, 0xDF, 0x43, 0xE6, 0x20, 0xDB, + 0x23, 0xDD, 0xCE, 0xD5, 0xA3, 0xE4, 0x31, 0xDD, 0x34, 0x01, 0x98, 0xF3, + 0x7B, 0x1C, 0xCC, 0x0A, 0xAD, 0x1E, 0x85, 0x18, 0x4E, 0x0A, 0xAC, 0x1A, + 0x86, 0xF7, 0xE6, 0x14, 0x62, 0xF5, 0x5F, 0x08, 0x02, 0xFB, 0x79, 0xF9, + 0x03, 0x02, 0xED, 0xF1, 0xF1, 0x02, 0x1B, 0xEF, 0x11, 0xFD, 0x80, 0xEC, + 0x50, 0xEF, 0xCF, 0xE7, 0x54, 0xEA, 0x1A, 0xEC, 0x01, 0xFB, 0x40, 0xFE, + 0x86, 0x1A, 0x50, 0x16, 0xCD, 0x2B, 0xE9, 0x26, 0xB7, 0x21, 0x7E, 0x2B, + 0xCD, 0x07, 0x15, 0x24, 0xD9, 0xF6, 0x43, 0x13, 0xA5, 0xF6, 0xCA, 0xFE, + 0xA4, 0xF8, 0x36, 0xF3, 0x2E, 0xFE, 0x7E, 0xEE, 0x4D, 0x02, 0x69, 0xED, + 0x0E, 0xFB, 0x94, 0xEA, 0x20, 0xED, 0xD9, 0xEA, 0x2C, 0xEB, 0xE0, 0xF4, + 0xCC, 0xFE, 0x7C, 0x07, 0x7C, 0x16, 0xE8, 0x16, 0xC8, 0x19, 0x20, 0x1D, + 0x52, 0x06, 0x8E, 0x16, 0xA1, 0xED, 0xE9, 0x02, 0x38, 0xE2, 0x32, 0xF2, + 0x6B, 0xE1, 0xE5, 0xE2, 0x4B, 0xEA, 0x24, 0xDB, 0xAB, 0xF9, 0x18, 0xDD, + 0x8C, 0x02, 0x6A, 0xE3, 0xC9, 0xFB, 0xF8, 0xEA, 0xF6, 0xF1, 0x04, 0xF7, + 0xB0, 0xF6, 0xEE, 0x08, 0x2B, 0x0D, 0x2F, 0x1A, 0x0D, 0x1C, 0x78, 0x22, + 0xAA, 0x10, 0xE8, 0x1E, 0x97, 0x05, 0xF3, 0x12, 0xB6, 0xF7, 0x1C, 0x04, + 0x28, 0xEA, 0x0F, 0xF4, 0x76, 0xE8, 0x62, 0xE8, 0x6B, 0xF6, 0x3A, 0xE8, + 0x0F, 0x0C, 0xA5, 0xF1, 0x11, 0x15, 0xB4, 0xFD, 0x57, 0x0E, 0x88, 0x0B, + 0xE0, 0x05, 0x50, 0x19, 0x0A, 0x0D, 0xF5, 0x24, 0x1B, 0x18, 0x75, 0x2A, + 0xFE, 0x19, 0x62, 0x21, 0xDD, 0x10, 0x0D, 0x14, 0xD8, 0x00, 0x2B, 0x07, + 0xCD, 0xEC, 0x7B, 0xF6, 0x12, 0xDF, 0x95, 0xE5, 0x35, 0xE1, 0x9D, 0xDD, + 0x6B, 0xF7, 0x7F, 0xE3, 0xA6, 0x0D, 0xB8, 0xF0, 0x16, 0x13, 0x1A, 0x00, + 0x06, 0x07, 0x38, 0x0D, 0xBC, 0xFF, 0x1D, 0x16, 0x18, 0x07, 0xD5, 0x19, + 0xEA, 0x04, 0x93, 0x0E, 0x50, 0x03, 0xEB, 0x02, 0x92, 0x00, 0xE4, 0xFA, + 0x04, 0xF6, 0xEF, 0xF0, 0x90, 0xE5, 0x3D, 0xE4, 0x11, 0xDD, 0x63, 0xDC, + 0xE7, 0xE9, 0xAF, 0xE1, 0x69, 0x07, 0x5D, 0xF2, 0x8E, 0x1B, 0x6A, 0x06, + 0xA8, 0x19, 0xE9, 0x17, 0x2F, 0x0F, 0x41, 0x25, 0xB4, 0x04, 0x7B, 0x22, + 0xAB, 0x02, 0x58, 0x1A, 0x91, 0x07, 0x98, 0x11, 0xF8, 0x0C, 0xD5, 0x09, + 0xD0, 0x0B, 0x44, 0x01, 0x70, 0xFE, 0x50, 0xF6, 0xC9, 0xEC, 0x2B, 0xEC, + 0x2D, 0xE8, 0xBF, 0xEC, 0x42, 0xFD, 0x27, 0xF8, 0x07, 0x18, 0xE6, 0x0A, + 0x58, 0x1D, 0x9F, 0x1E, 0xF5, 0x18, 0xBB, 0x23, 0x65, 0x09, 0x03, 0x20, + 0x32, 0xF9, 0xFB, 0x17, 0x9B, 0xF3, 0x7F, 0x0B, 0x68, 0xF7, 0xFE, 0xFE, + 0xC7, 0xFF, 0xF7, 0xF3, 0x6F, 0xFF, 0xC8, 0xE9, 0x13, 0xF3, 0xD1, 0xE0, + 0x77, 0xE5, 0x6A, 0xDF, 0x3A, 0xED, 0xD7, 0xE8, 0x02, 0x06, 0x54, 0xFB, + 0x60, 0x1A, 0xF5, 0x10, 0xA0, 0x1A, 0x7F, 0x15, 0x08, 0x0D, 0x30, 0x14, + 0x39, 0xFA, 0xB9, 0x10, 0x79, 0xED, 0x41, 0x07, 0xA7, 0xEB, 0x73, 0xFB, + 0x05, 0xF7, 0x74, 0xF1, 0x93, 0x03, 0xDE, 0xEA, 0xB0, 0x05, 0x6E, 0xE7, + 0xAA, 0xF9, 0xE9, 0xE8, 0xC0, 0xF6, 0xAC, 0xF4, 0xB0, 0x0C, 0x50, 0x0B, + 0xB5, 0x17, 0x2C, 0x18, 0xC8, 0x1F, 0x14, 0x20, 0x3B, 0x20, 0x55, 0x24, + 0xFC, 0x12, 0x70, 0x22, 0xEC, 0xFF, 0x45, 0x18, 0x2F, 0xF0, 0x0A, 0x08, + 0x19, 0xEE, 0x2D, 0xF8, 0x43, 0xFA, 0xCD, 0xED, 0xEB, 0x04, 0x78, 0xE8, + 0x67, 0x01, 0xAD, 0xEA, 0x0D, 0xFE, 0x88, 0xF7, 0xDE, 0xF9, 0x2C, 0x04, + 0xC1, 0x00, 0x78, 0x0F, 0x21, 0x10, 0x74, 0x17, 0x0C, 0x1A, 0x3F, 0x1A, + 0xA4, 0x14, 0x0E, 0x17, 0xE2, 0x02, 0x1A, 0x0C, 0x2B, 0xEB, 0xEE, 0xFA, + 0xF1, 0xDB, 0x95, 0xE8, 0x95, 0xDF, 0x94, 0xDC, 0xDD, 0xF1, 0x6B, 0xD8, + 0x69, 0xFD, 0xB6, 0xDD, 0x4F, 0xFA, 0x39, 0xEC, 0x48, 0xFA, 0x9B, 0xFA, + 0xCA, 0xFB, 0xAD, 0x07, 0x9C, 0x04, 0x84, 0x12, 0xE0, 0x0F, 0x63, 0x17, + 0x7F, 0x15, 0x50, 0x16, 0x4E, 0x0F, 0x43, 0x0E, 0xB9, 0xFE, 0xD8, 0x00, + 0x55, 0xEA, 0x37, 0xF1, 0x27, 0xE5, 0x02, 0xE6, 0x95, 0xF4, 0x1E, 0xE4, + 0x44, 0x07, 0x5F, 0xEB, 0xAC, 0x14, 0x78, 0xFA, 0xD7, 0x14, 0x24, 0x0A, + 0x85, 0x0C, 0xB2, 0x17, 0x04, 0x08, 0xE7, 0x20, 0x3A, 0x0A, 0xEA, 0x22, + 0xF9, 0x0F, 0x8C, 0x1D, 0x6F, 0x11, 0x64, 0x12, 0xC1, 0x0A, 0x0F, 0x03, + 0x48, 0xF6, 0xC0, 0xF2, 0xFF, 0xE5, 0x69, 0xE5, 0x98, 0xED, 0xC3, 0xDF, + 0x34, 0xF8, 0x38, 0xE7, 0xEA, 0x07, 0x28, 0xF3, 0x5B, 0x13, 0x4F, 0xFF, + 0xEE, 0x0F, 0x29, 0x0B, 0x8B, 0x05, 0x6A, 0x13, 0x39, 0xFB, 0x45, 0x15, + 0x69, 0xF8, 0x00, 0x0F, 0x7C, 0xFA, 0x83, 0x03, 0x8F, 0xFD, 0xDF, 0xF4, + 0xFC, 0xF2, 0x30, 0xE6, 0x4A, 0xE3, 0xCE, 0xDA, 0x64, 0xDF, 0xDF, 0xD6, + 0x4C, 0xE7, 0xE7, 0xE0, 0x22, 0xFB, 0x09, 0xEF, 0x72, 0x12, 0xCD, 0xFD, + 0x02, 0x1B, 0xD0, 0x0B, 0x1E, 0x15, 0x90, 0x16, 0xF0, 0x05, 0x99, 0x1A, + 0x5B, 0xFA, 0x10, 0x17, 0xB1, 0xF6, 0xE4, 0x0C, 0x9B, 0xFE, 0x12, 0x00, + 0x83, 0x00, 0xFF, 0xF1, 0xE5, 0xF2, 0x98, 0xE4, 0x40, 0xF2, 0x5E, 0xE9, + 0x34, 0xF3, 0x38, 0xF2, 0x8E, 0xFB, 0x0A, 0xFC, 0x15, 0x0F, 0x85, 0x07, + 0x67, 0x1E, 0x17, 0x13, 0x6B, 0x1F, 0x63, 0x1B, 0xD2, 0x12, 0x05, 0x1E, + 0x9A, 0xFE, 0xC5, 0x18, 0x86, 0xF1, 0x4B, 0x0D, 0xBA, 0xF1, 0x5F, 0xFD, + 0x67, 0xF4, 0xD4, 0xE8, 0x3D, 0xFB, 0x06, 0xE4, 0x1F, 0xF9, 0xE8, 0xE3, + 0xB3, 0xED, 0xB8, 0xE5, 0x63, 0xE9, 0x8B, 0xEC, 0xB8, 0xF5, 0xF1, 0xF8, + 0x11, 0x0A, 0x69, 0x06, 0x52, 0x16, 0x62, 0x10, 0xCE, 0x14, 0x27, 0x13, + 0x4C, 0x03, 0x78, 0x0F, 0xD6, 0xEF, 0xDB, 0x04, 0x9D, 0xEA, 0xFB, 0xF2, + 0x62, 0xEB, 0x36, 0xE9, 0x3A, 0xF6, 0x43, 0xE4, 0x15, 0x01, 0xD7, 0xE1, + 0x44, 0xFE, 0x21, 0xE4, 0x54, 0xF7, 0xBA, 0xED, 0x5F, 0xF9, 0x87, 0xFE, + 0x4F, 0x07, 0x1D, 0x10, 0x7C, 0x15, 0x49, 0x1D, 0x51, 0x1B, 0x61, 0x20, + 0x03, 0x12, 0xE8, 0x1B, 0x7A, 0xFE, 0x0C, 0x11, 0xB6, 0xED, 0x74, 0x00, + 0xA5, 0xEB, 0xD2, 0xF7, 0xA4, 0xF5, 0x6A, 0xF2, 0x74, 0x05, 0x4D, 0xED, + 0xF2, 0x0A, 0x90, 0xEC, 0xCF, 0x05, 0x71, 0xF3, 0xBA, 0xFF, 0xB2, 0x01, + 0xAA, 0x01, 0x0D, 0x12, 0x1B, 0x08, 0x43, 0x1D, 0xD5, 0x0F, 0x59, 0x1E, + 0xEC, 0x0D, 0xC5, 0x15, 0x60, 0xF9, 0x17, 0x06, 0xA9, 0xEE, 0x46, 0xF8, + 0xC5, 0xE4, 0x65, 0xED, 0xE0, 0xE1, 0x46, 0xE5, 0x86, 0xEE, 0x61, 0xE0, + 0x2E, 0xFE, 0xA0, 0xE1, 0xD8, 0x05, 0x8B, 0xE9, 0xEE, 0x04, 0x3B, 0xF8, + 0x13, 0x02, 0x2C, 0x09, 0xEB, 0x02, 0xF0, 0x16, 0x36, 0x07, 0x36, 0x1A, + 0x7F, 0x07, 0x83, 0x12, 0xB0, 0x06, 0xC3, 0x04, 0x44, 0xFE, 0x9E, 0xF7, + 0x5B, 0xEE, 0x64, 0xEE, 0xA2, 0xE1, 0x6F, 0xE8, 0x26, 0xE8, 0xC0, 0xE7, + 0x58, 0xFC, 0xC1, 0xEC, 0x87, 0x10, 0x4B, 0xF7, 0xDE, 0x18, 0x65, 0x05, + 0x76, 0x18, 0x6B, 0x15, 0x09, 0x11, 0x2B, 0x23, 0x04, 0x0D, 0x0F, 0x28, + 0x52, 0x0F, 0xD2, 0x1F, 0x66, 0x0B, 0x65, 0x11, 0x13, 0x08, 0xC1, 0x02, + 0x53, 0xFD, 0xA0, 0xF5, 0x61, 0xED, 0xB1, 0xED, 0x9A, 0xE6, 0xFA, 0xEA, + 0x94, 0xF1, 0x58, 0xEF, 0x04, 0x05, 0xEC, 0xF8, 0x7F, 0x14, 0xE4, 0x04, + 0x1F, 0x17, 0x00, 0x11, 0xE2, 0x0D, 0x6D, 0x1A, 0x8F, 0x03, 0x04, 0x1F, + 0x16, 0xF8, 0xC7, 0x14, 0xA7, 0xF4, 0x5B, 0x06, 0xC0, 0xFA, 0x09, 0xF8, + 0x56, 0xFC, 0x25, 0xEB, 0x90, 0xF2, 0x75, 0xE2, 0xD7, 0xE5, 0x02, 0xE0, + 0xFF, 0xE6, 0x13, 0xE6, 0xE0, 0xF5, 0x9C, 0xF3, 0x60, 0x0B, 0x9A, 0x02, + 0x08, 0x17, 0x60, 0x0F, 0x7B, 0x11, 0x0A, 0x1B, 0x7E, 0x08, 0x3E, 0x18, + 0x3E, 0xFB, 0xD0, 0x11, 0x3C, 0xF2, 0x9A, 0x0B, 0x89, 0xF6, 0x16, 0x02, + 0x00, 0x01, 0x92, 0xF7, 0x83, 0x03, 0x58, 0xED, 0x1D, 0xFB, 0xF6, 0xE8, + 0xF4, 0xF6, 0xCA, 0xED, 0x25, 0xFE, 0xF9, 0xFC, 0xDF, 0x10, 0x6F, 0x0F, + 0xC3, 0x1F, 0xC8, 0x1C, 0x16, 0x21, 0xE7, 0x23, 0x06, 0x19, 0x6F, 0x1E, + 0x3D, 0x08, 0x6F, 0x16, 0xCA, 0xF4, 0x56, 0x0F, 0x67, 0xEE, 0x84, 0x05, + 0x44, 0xF6, 0x57, 0xF9, 0x05, 0x00, 0x52, 0xED, 0xC3, 0xFF, 0xBE, 0xE5, + 0xCC, 0xFA, 0xDF, 0xE6, 0xB2, 0xF9, 0x13, 0xF3, 0x00, 0x03, 0xE0, 0x05, + 0x05, 0x14, 0x89, 0x17, 0xBE, 0x14, 0x45, 0x18, 0xAF, 0x10, 0xC3, 0x11, + 0xE2, 0x06, 0x36, 0x0A, 0xF5, 0xF3, 0x80, 0x03, 0xEE, 0xE4, 0xD1, 0xFA, + 0x2E, 0xE6, 0xAB, 0xF1, 0x83, 0xF2, 0x59, 0xE8, 0xFE, 0xFD, 0xB1, 0xE3, + 0x23, 0xFF, 0x47, 0xE3, 0x48, 0xFF, 0x91, 0xEF, 0x50, 0x07, 0xA3, 0x06, + 0xE5, 0x07, 0xA6, 0x13, 0xF2, 0x0C, 0xF1, 0x1A, 0x3B, 0x15, 0x1E, 0x1B, + 0x7C, 0x17, 0x01, 0x15, 0xF6, 0x09, 0xD0, 0x0B, 0xBE, 0xF4, 0x1D, 0x01, + 0x4F, 0xE9, 0xE6, 0xF7, 0x28, 0xEF, 0x07, 0xF1, 0x4D, 0xFD, 0xA9, 0xEE, + 0xC5, 0x07, 0x17, 0xEF, 0xA6, 0x0B, 0x27, 0xF8, 0x74, 0x0B, 0x62, 0x0C, + 0x9F, 0x0A, 0x30, 0x17, 0x99, 0x09, 0x19, 0x1E, 0x7A, 0x0D, 0xCA, 0x1F, + 0x02, 0x12, 0xB2, 0x17, 0x8D, 0x0C, 0x07, 0x0A, 0xE4, 0xF9, 0xD7, 0xFA, + 0x29, 0xE7, 0x85, 0xED, 0x34, 0xE2, 0x07, 0xE6, 0xA1, 0xED, 0x48, 0xE4, + 0x5A, 0xFD, 0xF3, 0xE7, 0xBA, 0x08, 0x5C, 0xF3, 0xA9, 0x0B, 0x69, 0xFC, + 0xA8, 0x08, 0x43, 0x07, 0x28, 0x01, 0xF1, 0x12, 0xF4, 0xFD, 0x20, 0x19, + 0x5A, 0x02, 0x5F, 0x14, 0xEB, 0x06, 0x3F, 0x07, 0x38, 0x00, 0xE8, 0xF6, + 0xA4, 0xF0, 0x77, 0xE7, 0x3D, 0xE5, 0x1D, 0xDF, 0x11, 0xEA, 0xD9, 0xE0, + 0x5B, 0xFE, 0x82, 0xE9, 0x9F, 0x0B, 0x3E, 0xF8, 0xBA, 0x14, 0x19, 0x04, + 0x29, 0x18, 0x2E, 0x0D, 0xA0, 0x10, 0xFC, 0x16, 0xAA, 0x04, 0xB6, 0x1D, + 0x34, 0x00, 0x44, 0x1C, 0x7D, 0x04, 0xCE, 0x11, 0xC6, 0x06, 0x58, 0x02, + 0x09, 0xFD, 0x02, 0xF1, 0x31, 0xF0, 0xD1, 0xE5, 0x15, 0xF0, 0x7B, 0xE5, + 0xD4, 0xF5, 0xAE, 0xF0, 0x74, 0x02, 0x03, 0xFF, 0xCF, 0x12, 0x47, 0x0A, + 0xB9, 0x1D, 0xD6, 0x0F, 0x15, 0x19, 0x9D, 0x13, 0x9F, 0x06, 0xB2, 0x15, + 0x73, 0xF4, 0xB5, 0x12, 0x38, 0xEF, 0xCE, 0x08, 0x4C, 0xF3, 0x77, 0xFA, + 0x11, 0xF4, 0xB8, 0xE9, 0x43, 0xED, 0x99, 0xDC, 0xA3, 0xE6, 0x51, 0xDA, + 0x8E, 0xEB, 0x6E, 0xE4, 0x0E, 0xF5, 0x1C, 0xF4, 0xBA, 0x04, 0x49, 0x04, + 0x1A, 0x15, 0x86, 0x0D, 0xA1, 0x1B, 0x41, 0x11, 0x47, 0x0F, 0xB6, 0x10, + 0x73, 0xF9, 0xB2, 0x0C, 0x75, 0xEA, 0x89, 0x03, 0xC3, 0xEC, 0x1E, 0xF9, + 0x29, 0xF5, 0xC8, 0xED, 0xB2, 0xF3, 0x55, 0xDE, 0xB6, 0xF9, 0x14, 0xE2, + 0xF6, 0xFB, 0xDF, 0xEA, 0xEF, 0xFB, 0xCD, 0xF7, 0xDD, 0x02, 0x70, 0x09, + 0xBF, 0x11, 0x8B, 0x17, 0xFF, 0x1F, 0xE0, 0x1C, 0x58, 0x1E, 0x3E, 0x1B, + 0x8A, 0x0B, 0x46, 0x13, 0x79, 0xF5, 0x31, 0x09, 0x2C, 0xED, 0xA6, 0xFD, + 0x0B, 0xF1, 0xEA, 0xED, 0x85, 0xFA, 0x81, 0xEC, 0xFB, 0x00, 0x43, 0xEC, + 0x7F, 0x01, 0xB2, 0xE9, 0xFF, 0xFC, 0xA5, 0xEE, 0x32, 0xFB, 0x6A, 0xFE, + 0x69, 0x01, 0x0F, 0x10, 0xF0, 0x0E, 0x50, 0x19, 0x5A, 0x15, 0x45, 0x18, + 0xD9, 0x0B, 0x4A, 0x0F, 0x74, 0xF4, 0x79, 0x01, 0x14, 0xE4, 0x4C, 0xF3, + 0xDE, 0xE3, 0xFD, 0xE7, 0xEF, 0xEA, 0xDD, 0xE6, 0x16, 0xF7, 0xC8, 0xE8, + 0xF8, 0x01, 0xBB, 0xE7, 0x13, 0x05, 0x66, 0xEB, 0xA5, 0x01, 0xCF, 0xF8, + 0xC8, 0xFE, 0x7E, 0x0B, 0x12, 0x04, 0x9A, 0x18, 0x7B, 0x0D, 0xFE, 0x1A, + 0x79, 0x0E, 0x29, 0x14, 0xBD, 0xFF, 0x52, 0x05, 0x9F, 0xEA, 0x08, 0xF3, + 0x2D, 0xE6, 0x33, 0xEC, 0x5F, 0xEB, 0x4E, 0xEC, 0x2D, 0xF7, 0x05, 0xF0, + 0x6D, 0x06, 0x02, 0xF3, 0x7A, 0x12, 0x79, 0xF6, 0x21, 0x13, 0xFA, 0xFF, + 0x01, 0x0C, 0x30, 0x10, 0xE3, 0x04, 0xA3, 0x1C, 0xAF, 0x08, 0x78, 0x21, + 0xF9, 0x0B, 0x15, 0x1A, 0xE2, 0xFF, 0x02, 0x07, 0xCA, 0xF9, 0xE5, 0xF8, + 0xDD, 0xEF, 0xED, 0xEC, 0xD3, 0xE5, 0x92, 0xE5, 0xF3, 0xE5, 0x95, 0xE7, + 0x7B, 0xF3, 0x3A, 0xEE, 0x42, 0x08, 0x7D, 0xF5, 0x31, 0x15, 0x2A, 0xFE, + 0xB9, 0x13, 0xF3, 0x0A, 0x4F, 0x07, 0xBB, 0x15, 0xA9, 0xFF, 0xCC, 0x19, + 0x46, 0xFF, 0xCE, 0x13, 0x20, 0xFF, 0xBE, 0x04, 0xA9, 0xFC, 0x18, 0xF8, + 0xCA, 0xF5, 0x52, 0xEB, 0x72, 0xEA, 0xAA, 0xE0, 0x95, 0xE4, 0x3F, 0xE1, + 0x72, 0xEB, 0xC0, 0xEB, 0x93, 0x00, 0x90, 0xF9, 0xE1, 0x16, 0x8E, 0x05, + 0xF5, 0x1F, 0x4A, 0x11, 0x2E, 0x15, 0x41, 0x1A, 0xA1, 0x04, 0x1A, 0x1C, + 0x6B, 0xFE, 0x2A, 0x17, 0x15, 0xFB, 0x39, 0x0C, 0x20, 0xFE, 0x99, 0x01, + 0xE5, 0x00, 0x90, 0xF5, 0xF5, 0xFB, 0xD2, 0xE8, 0x54, 0xF3, 0x8D, 0xE4, + 0xBC, 0xEF, 0x1D, 0xEE, 0xB9, 0xFA, 0x77, 0xFE, 0xEB, 0x0F, 0x1F, 0x0E, + 0xCA, 0x20, 0xE8, 0x18, 0xAD, 0x1C, 0x33, 0x1E, 0x7E, 0x09, 0xA4, 0x1D, + 0x5C, 0xF7, 0xFE, 0x11, 0xE5, 0xEE, 0xAB, 0x05, 0x16, 0xF0, 0x11, 0xFD, + 0x3D, 0xF8, 0xBD, 0xF4, 0x49, 0xFC, 0xD3, 0xE8, 0x69, 0xF9, 0xCD, 0xE0, + 0x05, 0xF2, 0x63, 0xE5, 0xA4, 0xF2, 0x1A, 0xF5, 0x06, 0x00, 0x76, 0x07, + 0xD5, 0x14, 0xB3, 0x14, 0xEA, 0x1B, 0x82, 0x1B, 0xE6, 0x0B, 0x5A, 0x18, + 0x8F, 0xFD, 0xA9, 0x0C, 0x58, 0xEF, 0xFB, 0xFF, 0x9F, 0xE7, 0x2E, 0xF8, + 0xA5, 0xED, 0x38, 0xF4, 0xE7, 0xF9, 0x21, 0xEE, 0x12, 0x03, 0x53, 0xE7, + 0x1D, 0x03, 0xAC, 0xE8, 0x7B, 0xFF, 0xEE, 0xF6, 0x07, 0x04, 0x0E, 0x0A, + 0x17, 0x13, 0xBD, 0x1A, 0x45, 0x1E, 0x6B, 0x24, 0x5B, 0x1C, 0xD7, 0x1E, + 0xD8, 0x0F, 0x04, 0x14, 0xAF, 0xFB, 0xDA, 0x05, 0x06, 0xEB, 0xF8, 0xFA, + 0x34, 0xE7, 0x32, 0xF6, 0xF9, 0xF2, 0xD0, 0xF3, 0x12, 0x03, 0xDF, 0xEE, + 0x39, 0x0E, 0x69, 0xEE, 0x2A, 0x0C, 0x81, 0xF7, 0x4C, 0x08, 0xAB, 0x08, + 0x12, 0x11, 0x8E, 0x1C, 0xDC, 0x0E, 0xA3, 0x1D, 0xDE, 0x0E, 0x00, 0x19, + 0x87, 0x0E, 0x27, 0x12, 0x16, 0x03, 0xEF, 0x04, 0x87, 0xF0, 0x48, 0xF5, + 0x5C, 0xE1, 0x51, 0xEC, 0xC6, 0xE1, 0x20, 0xEA, 0x95, 0xF0, 0x89, 0xEA, + 0x0E, 0x04, 0x3D, 0xEB, 0x04, 0x0D, 0x53, 0xF4, 0x10, 0x0D, 0xE9, 0x07, + 0x5C, 0x06, 0x96, 0x11, 0xA8, 0x01, 0x53, 0x15, 0x11, 0x04, 0xB5, 0x17, + 0xF1, 0x0A, 0x57, 0x16, 0x42, 0x0A, 0x10, 0x0C, 0x47, 0xFE, 0xC9, 0xF9, + 0x58, 0xEC, 0x4A, 0xEB, 0xB9, 0xE2, 0xFB, 0xE6, 0x52, 0xE9, 0x4F, 0xEA, + 0xC4, 0xFF, 0xD8, 0xEF, 0xA9, 0x13, 0xD1, 0xFA, 0xCD, 0x17, 0x5F, 0x0B, + 0x8E, 0x14, 0x64, 0x14, 0x8F, 0x0A, 0x6C, 0x18, 0x40, 0x02, 0x48, 0x1A, + 0x06, 0x03, 0x86, 0x19, 0x1C, 0x07, 0xC3, 0x11, 0x8B, 0x05, 0x26, 0x00, + 0x1C, 0xFA, 0x02, 0xED, 0xFE, 0xEB, 0x2A, 0xE4, 0xBB, 0xE7, 0x29, 0xE6, + 0xFC, 0xF5, 0xD4, 0xEE, 0x83, 0x0F, 0xAA, 0xFD, 0xDA, 0x19, 0xB7, 0x07, + 0xFB, 0x18, 0xF7, 0x0F, 0x43, 0x0E, 0xFD, 0x14, 0x44, 0xFE, 0x7A, 0x14, + 0x15, 0xF4, 0x5F, 0x11, 0xAD, 0xF5, 0x78, 0x0B, 0x2C, 0xFB, 0xE2, 0xFD, + 0xE3, 0xFC, 0xA2, 0xEB, 0xE9, 0xF2, 0x1F, 0xDF, 0x7C, 0xEA, 0x48, 0xE0, + 0x63, 0xF6, 0x75, 0xEC, 0xC8, 0xFE, 0x36, 0xFA, 0xA6, 0x0D, 0x0B, 0x07, + 0x09, 0x1E, 0x95, 0x12, 0x9C, 0x1F, 0x0D, 0x19, 0x45, 0x0F, 0x21, 0x16, + 0x32, 0xF9, 0x09, 0x0F, 0x83, 0xED, 0x5F, 0x08, 0x7B, 0xEF, 0x19, 0xFF, + 0xD6, 0xF7, 0x3D, 0xF0, 0x8E, 0xF9, 0x32, 0xE3, 0xEC, 0xF4, 0xA3, 0xE1, + 0x6C, 0xF4, 0xF7, 0xEC, 0xD8, 0xFA, 0x5C, 0xFC, 0xAB, 0x07, 0x1B, 0x0A, + 0x7C, 0x1B, 0x5C, 0x17, 0x16, 0x25, 0x87, 0x1E, 0x67, 0x1C, 0x72, 0x1A, + 0x67, 0x03, 0x2C, 0x0E, 0xC2, 0xEC, 0xEA, 0x02, 0x86, 0xE3, 0xCA, 0xF9, + 0xC3, 0xEB, 0xBA, 0xEE, 0x8E, 0xF6, 0x86, 0xE2, 0x2B, 0xF7, 0xD7, 0xDE, + 0xED, 0xFB, 0xD7, 0xE8, 0x19, 0xFC, 0xBD, 0xF6, 0x5A, 0xFD, 0x6E, 0x04, + 0xD0, 0x08, 0x5E, 0x11, 0x62, 0x17, 0x77, 0x1B, 0x27, 0x1B, 0xE2, 0x19, + 0xB9, 0x0C, 0x51, 0x0D, 0x81, 0xF4, 0x68, 0xFD, 0x92, 0xE2, 0x06, 0xF4, + 0x4F, 0xE3, 0x8C, 0xEB, 0x2C, 0xF0, 0x99, 0xE1, 0xBD, 0xFF, 0xB3, 0xE4, + 0x2D, 0x08, 0xCE, 0xEC, 0x26, 0x07, 0x22, 0xF7, 0xFC, 0x00, 0xC3, 0x02, + 0xEE, 0x01, 0x8C, 0x0E, 0xC3, 0x0B, 0xC5, 0x1A, 0xB0, 0x16, 0x0F, 0x1E, + 0x4B, 0x14, 0x17, 0x14, 0x54, 0x03, 0x72, 0x01, 0x39, 0xEC, 0xF6, 0xF3, + 0x31, 0xE2, 0x62, 0xEB, 0xB3, 0xED, 0x39, 0xE5, 0x03, 0xFB, 0xD0, 0xEA, + 0x99, 0x09, 0x55, 0xF2, 0x54, 0x12, 0xD8, 0xFA, 0x5A, 0x0E, 0xC4, 0x03, + 0x14, 0x06, 0x1C, 0x0D, 0x66, 0x02, 0xB6, 0x16, 0x95, 0x06, 0x3C, 0x1C, + 0xD8, 0x09, 0x69, 0x14, 0x72, 0x02, 0x48, 0x02, 0xAE, 0xEF, 0xB9, 0xEF, + 0xC9, 0xDE, 0x1B, 0xE2, 0xFA, 0xDE, 0xA4, 0xE4, 0x4D, 0xEA, 0xAB, 0xE9, + 0xA9, 0xFD, 0xE9, 0xEE, 0x70, 0x10, 0x62, 0xF7, 0xC7, 0x17, 0xC7, 0x02, + 0x85, 0x0F, 0xB7, 0x0B, 0xA9, 0x02, 0x44, 0x13, 0x16, 0xFA, 0x7B, 0x18, + 0x3E, 0xFD, 0x4C, 0x16, 0xF7, 0xFE, 0xCA, 0x06, 0xDC, 0xF0, 0x11, 0xF1, + 0x0F, 0xEE, 0x4E, 0xE7, 0x0A, 0xEA, 0x9D, 0xE6, 0x58, 0xE6, 0x13, 0xE9, + 0x02, 0xF0, 0xF7, 0xED, 0x1E, 0x06, 0x04, 0xF9, 0x84, 0x1B, 0xBE, 0x07, + 0x8D, 0x1F, 0x73, 0x11, 0x98, 0x13, 0x80, 0x15, 0x97, 0x01, 0x16, 0x17, + 0x40, 0xFB, 0xDB, 0x15, 0x3D, 0xFC, 0xDD, 0x09, 0x22, 0xFB, 0x92, 0xF4, + 0x04, 0xFC, 0x04, 0xEB, 0x4F, 0xF7, 0xE5, 0xE7, 0x67, 0xEC, 0xC0, 0xE7, + 0x35, 0xEB, 0xE7, 0xEB, 0x76, 0xF9, 0xA7, 0xF7, 0x93, 0x12, 0xAB, 0x08, + 0xC4, 0x21, 0x53, 0x15, 0x90, 0x1D, 0x49, 0x17, 0x95, 0x07, 0xC1, 0x14, + 0x98, 0xF4, 0x13, 0x10, 0x50, 0xEF, 0x6E, 0x02, 0x27, 0xF0, 0x95, 0xF8, + 0xE5, 0xF6, 0x56, 0xEE, 0x54, 0xFB, 0x49, 0xE6, 0x55, 0xF6, 0xA2, 0xE4, + 0x29, 0xEF, 0xE2, 0xE8, 0x61, 0xF2, 0x41, 0xF5, 0x4E, 0x04, 0xCA, 0x08, + 0xFD, 0x19, 0xC7, 0x1A, 0x2A, 0x21, 0xCD, 0x1F, 0x4F, 0x12, 0xBB, 0x19, + 0x48, 0xF8, 0x68, 0x10, 0x4C, 0xEA, 0xB6, 0x04, 0x1D, 0xE8, 0xC4, 0xFA, + 0x71, 0xF0, 0x31, 0xF1, 0x37, 0xFD, 0x66, 0xE9, 0x19, 0x03, 0x00, 0xE8, + 0x71, 0xFE, 0x61, 0xEB, 0xCF, 0xF9, 0x05, 0xF5, 0x93, 0xFE, 0xF5, 0x06, + 0xAE, 0x11, 0x42, 0x1B, 0x45, 0x1F, 0xBF, 0x23, 0xA8, 0x14, 0x66, 0x1E, + 0x71, 0x08, 0xEE, 0x0E, 0x27, 0xF6, 0x05, 0x01, 0x0A, 0xE4, 0xEE, 0xF7, + 0x19, 0xE1, 0x13, 0xF0, 0xEA, 0xED, 0xF8, 0xE9, 0x22, 0x00, 0x94, 0xE9, + 0x34, 0x09, 0xAD, 0xED, 0x03, 0x08, 0xCF, 0xF5, 0x80, 0x04, 0x8D, 0x03, + 0xC5, 0x0A, 0xA1, 0x16, 0xBE, 0x15, 0x45, 0x22, 0x05, 0x18, 0xC3, 0x1D, + 0x3A, 0x0F, 0xB9, 0x0F, 0x62, 0xFE, 0x85, 0x00, 0xCD, 0xE8, 0xE3, 0xF5, + 0x7E, 0xDC, 0x25, 0xEE, 0x73, 0xE1, 0x71, 0xE9, 0x72, 0xF6, 0x73, 0xEB, + 0x44, 0x0B, 0x64, 0xF3, 0x8E, 0x15, 0xFE, 0xFC, 0xC5, 0x10, 0xC1, 0x07, + 0x69, 0x0B, 0x8F, 0x16, 0x8B, 0x11, 0xE0, 0x23, 0xAE, 0x0D, 0x9D, 0x1F, + 0xEA, 0x0A, 0x1A, 0x13, 0xC5, 0x06, 0xA9, 0x03, 0x64, 0xF8, 0x08, 0xF7, + 0xA9, 0xE6, 0x16, 0xED, 0xC1, 0xDE, 0x21, 0xE7, 0x95, 0xE9, 0x38, 0xE8, + 0xDA, 0x01, 0xEE, 0xF3, 0x7F, 0x16, 0x87, 0xFF, 0x20, 0x1A, 0x98, 0x0A, + 0x84, 0x14, 0x30, 0x1A, 0x51, 0x07, 0x8A, 0x1A, 0x37, 0x00, 0xEF, 0x18, + 0xD8, 0x01, 0x24, 0x14, 0x4A, 0x06, 0x19, 0x08, 0xEE, 0x01, 0x5A, 0xFA, + 0x11, 0xF4, 0x85, 0xED, 0xE7, 0xE3, 0xBA, 0xE4, 0xB7, 0xE1, 0x04, 0xE3, + 0x36, 0xF2, 0x55, 0xEE, 0xD3, 0x0D, 0xE3, 0xFE, 0x24, 0x1E, 0x3D, 0x0D, + 0x3B, 0x18, 0x7B, 0x18, 0x6A, 0x0D, 0xCD, 0x17, 0xAC, 0xFF, 0x0D, 0x16, + 0xA1, 0xF7, 0xB9, 0x13, 0x03, 0xFA, 0x3C, 0x0A, 0xDC, 0xFF, 0xE2, 0xFD, + 0xE1, 0xFE, 0x47, 0xF2, 0x97, 0xF4, 0xC9, 0xE8, 0xBD, 0xEA, 0x68, 0xE4, + 0x1A, 0xF0, 0x64, 0xEC, 0x20, 0x07, 0x54, 0xFF, 0x88, 0x1F, 0x3F, 0x13, + 0x68, 0x24, 0xF1, 0x18, 0x11, 0x1B, 0x7E, 0x17, 0xBA, 0x07, 0xF0, 0x14, + 0xEF, 0xF4, 0xAA, 0x11, 0xAB, 0xED, 0x3A, 0x08, 0x9A, 0xF4, 0x32, 0xFC, + 0x50, 0xFD, 0xC6, 0xF0, 0x29, 0x00, 0x9A, 0xE8, 0x49, 0xF6, 0x08, 0xE2, + 0x1F, 0xF3, 0xD8, 0xE7, 0xCC, 0x06, 0x5D, 0xFD, 0x38, 0x10, 0x6D, 0x0D, + 0xAD, 0x1A, 0x30, 0x17, 0xE9, 0x21, 0x82, 0x19, 0x40, 0x17, 0xCE, 0x15, + 0x33, 0x00, 0xD0, 0x0F, 0xDE, 0xE9, 0x64, 0x04, 0x44, 0xE4, 0x9B, 0xF7, + 0x61, 0xEC, 0x4B, 0xED, 0x26, 0xF9, 0x9E, 0xE8, 0xEF, 0xFA, 0x14, 0xE5, + 0xCF, 0xF7, 0x88, 0xE9, 0x81, 0xFD, 0xB1, 0xFC, 0x7D, 0x02, 0x1C, 0x0B, + 0x7B, 0x0E, 0x17, 0x18, 0x1C, 0x1E, 0xD2, 0x1E, 0x3B, 0x1F, 0x9C, 0x1B, + 0x31, 0x0E, 0x55, 0x13, 0xE8, 0xF2, 0x1F, 0x06, 0x80, 0xE0, 0x3E, 0xF6, + 0x20, 0xE0, 0xB8, 0xEA, 0x76, 0xF0, 0xFE, 0xE6, 0x46, 0xFF, 0xAF, 0xE7, + 0xB6, 0x01, 0x85, 0xED, 0xB4, 0x03, 0x3A, 0xF7, 0x3F, 0x03, 0xC4, 0x04, + 0x7D, 0x06, 0x87, 0x14, 0x8A, 0x12, 0x43, 0x1E, 0xF7, 0x1A, 0x72, 0x1C, + 0x3D, 0x15, 0x43, 0x12, 0xB7, 0xFF, 0x2E, 0x03, 0xCB, 0xE6, 0x6F, 0xF0, + 0xB3, 0xDA, 0x7E, 0xE2, 0x7C, 0xE5, 0x58, 0xDF, 0xDC, 0xF8, 0x6B, 0xE2, + 0x99, 0x0A, 0xDC, 0xEE, 0x59, 0x10, 0x42, 0xF9, 0x7E, 0x0A, 0x34, 0x02, + 0xC9, 0x02, 0x55, 0x0F, 0x6D, 0x04, 0x06, 0x1A, 0xC0, 0x0B, 0x04, 0x1B, + 0x4E, 0x10, 0x27, 0x13, 0x8A, 0x07, 0x7C, 0x06, 0x1A, 0xF4, 0x23, 0xF5, + 0x01, 0xE0, 0x50, 0xE5, 0x23, 0xDF, 0x1F, 0xE0, 0xC6, 0xF5, 0xC1, 0xE6, + 0x81, 0x06, 0x56, 0xF5, 0x85, 0x14, 0xD0, 0x01, 0x1F, 0x18, 0x1D, 0x09, + 0xAF, 0x0F, 0x75, 0x12, 0xB5, 0x04, 0x1F, 0x1A, 0xCC, 0x00, 0xB5, 0x1A, + 0x17, 0x03, 0xD4, 0x12, 0x9A, 0x04, 0x52, 0x07, 0x18, 0xFA, 0x5D, 0xF7, + 0x2B, 0xE8, 0xE8, 0xE5, 0xA6, 0xDF, 0xC2, 0xDB, 0x9B, 0xE4, 0x06, 0xE2, + 0x43, 0xF6, 0x74, 0xF0, 0x0A, 0x0F, 0xDA, 0xFE, 0xAC, 0x1F, 0xD7, 0x07, + 0xFA, 0x1D, 0xB1, 0x0F, 0xF8, 0x0C, 0xF2, 0x14, 0xC4, 0xFB, 0x69, 0x14, + 0x38, 0xF2, 0x35, 0x0B, 0x89, 0xF5, 0x13, 0x01, 0x50, 0xF6, 0xF7, 0xF3, + 0xCE, 0xE7, 0x32, 0xE0, 0x16, 0xE9, 0xC5, 0xDE, 0x9A, 0xE8, 0xFE, 0xE1, + 0x97, 0xEB, 0x4D, 0xEB, 0xF4, 0xFD, 0x78, 0xFA, 0x52, 0x16, 0x00, 0x09, + 0xA6, 0x23, 0x43, 0x13, 0x79, 0x1C, 0x59, 0x1A, 0x62, 0x07, 0xC9, 0x18, + 0x79, 0xF4, 0xDA, 0x0F, 0x40, 0xEF, 0x44, 0x03, 0x39, 0xF0, 0xD2, 0xF2, + 0xCB, 0xF9, 0x81, 0xEF, 0xDE, 0xFC, 0xB6, 0xEC, 0x8F, 0xF5, 0x6A, 0xE7, + 0x7A, 0xEC, 0x4D, 0xE9, 0x63, 0xF3, 0x25, 0xF7, 0x98, 0x09, 0x04, 0x09, + 0xEC, 0x20, 0xF9, 0x16, 0x9F, 0x26, 0x32, 0x1F, 0xC7, 0x17, 0xF4, 0x1D, + 0x6D, 0xFC, 0xB8, 0x11, 0x36, 0xEA, 0x2B, 0x00, 0x9C, 0xEB, 0x8E, 0xF1, + 0xE1, 0xF1, 0x59, 0xEC, 0x34, 0xFB, 0x10, 0xEA, 0xE8, 0xFD, 0xF4, 0xE4, + 0x79, 0xF6, 0x90, 0xE4, 0x89, 0xF2, 0xA6, 0xEF, 0xD4, 0xFC, 0xEC, 0x01, + 0xC5, 0x10, 0xF1, 0x11, 0x39, 0x1F, 0x59, 0x1B, 0x05, 0x1A, 0xBD, 0x1B, + 0x8C, 0x02, 0xC1, 0x0F, 0xE1, 0xE7, 0xF3, 0xFA, 0x3F, 0xDE, 0xA3, 0xED, + 0x1A, 0xE3, 0x9B, 0xE8, 0x77, 0xF3, 0x37, 0xE9, 0xFD, 0x02, 0x70, 0xE9, + 0x54, 0x06, 0x18, 0xEB, 0xFB, 0xFF, 0xE1, 0xF4, 0xAB, 0xFE, 0x81, 0x06, + 0x6D, 0x06, 0xEB, 0x15, 0x9A, 0x15, 0x0F, 0x20, 0x12, 0x1A, 0xC2, 0x21, + 0xF1, 0x05, 0x6E, 0x14, 0xA9, 0xF8, 0x4C, 0x06, 0xC3, 0xE9, 0xBE, 0xF6, + 0x95, 0xDD, 0x48, 0xEA, 0x26, 0xE4, 0x61, 0xE8, 0xA3, 0xF8, 0x9F, 0xEB, + 0xED, 0x0B, 0xBF, 0xF0, 0x64, 0x10, 0x53, 0xFA, 0x5A, 0x0D, 0xDC, 0x09, + 0x10, 0x0A, 0x27, 0x17, 0x5B, 0x0F, 0xAB, 0x1E, 0x5C, 0x14, 0x66, 0x1E, + 0xD0, 0x0D, 0x1D, 0x14, 0xA8, 0x03, 0x4D, 0x05, 0x15, 0xF3, 0x86, 0xF3, + 0x04, 0xDE, 0xCD, 0xE2, 0x29, 0xD8, 0x28, 0xDE, 0xA9, 0xE7, 0x2E, 0xE3, + 0xFE, 0x02, 0x40, 0xED, 0xBD, 0x15, 0x52, 0xF9, 0x14, 0x1A, 0xD4, 0x09, + 0xF5, 0x11, 0x2B, 0x17, 0xF2, 0x0A, 0xCC, 0x1C, 0x01, 0x0C, 0x00, 0x1D, + 0x09, 0x06, 0x41, 0x11, 0x86, 0x02, 0x9B, 0x05, 0xCD, 0xFC, 0x12, 0xF9, + 0xB9, 0xEC, 0x3B, 0xEA, 0x27, 0xDE, 0x50, 0xE2, 0xEB, 0xE0, 0x85, 0xE6, + 0xB7, 0xF7, 0xE8, 0xF1, 0x79, 0x13, 0x06, 0x01, 0x35, 0x22, 0x90, 0x11, + 0xB7, 0x1E, 0xDF, 0x1F, 0x88, 0x12, 0xBC, 0x25, 0x9F, 0x02, 0x4C, 0x1D, + 0x99, 0xFA, 0x6C, 0x11, 0x54, 0xFD, 0x0E, 0x09, 0x66, 0x03, 0xBE, 0x00, + 0x96, 0xFD, 0x8B, 0xF2, 0xB7, 0xED, 0x4D, 0xE6, 0x86, 0xE2, 0x53, 0xE4, + 0xC5, 0xEB, 0x39, 0xED, 0xCA, 0x03, 0x56, 0xFB, 0xAB, 0x1C, 0xD7, 0x0C, + 0xD7, 0x22, 0x39, 0x1B, 0x0F, 0x13, 0x04, 0x20, 0x5D, 0x03, 0x5E, 0x16, + 0x8C, 0xF3, 0x67, 0x07, 0x5D, 0xED, 0x74, 0xFD, 0xB6, 0xF4, 0x2C, 0xF7, + 0x46, 0xFC, 0xF2, 0xED, 0x26, 0xF8, 0xEE, 0xE3, 0xC8, 0xED, 0x33, 0xE1, + 0x06, 0xEC, 0x28, 0xEA, 0xE6, 0xFC, 0x60, 0xF9, 0x60, 0x16, 0x43, 0x0C, + 0x50, 0x25, 0xD5, 0x1F, 0x83, 0x22, 0x19, 0x21, 0x71, 0x12, 0x2B, 0x1A, + 0x0B, 0xFA, 0xD9, 0x0D, 0x4C, 0xE7, 0x99, 0x01, 0x09, 0xE7, 0xF2, 0xF9, + 0x51, 0xF6, 0x63, 0xF4, 0x6D, 0x01, 0xE2, 0xEC, 0xFA, 0x01, 0x47, 0xEB, + 0x35, 0xFB, 0x39, 0xF1, 0xBB, 0x00, 0xF8, 0xFF, 0x3B, 0x17, 0x8E, 0x15, + 0x48, 0x1E, 0x64, 0x1D, 0x09, 0x21, 0x2E, 0x21, 0x8C, 0x1E, 0x9F, 0x21, + 0x94, 0x0B, 0x19, 0x17, 0x81, 0xF0, 0x48, 0x05, 0x30, 0xDF, 0x36, 0xF6, + 0x39, 0xE5, 0x81, 0xED, 0xCD, 0xF4, 0x47, 0xE6, 0x75, 0x00, 0x06, 0xE4, + 0xB0, 0xFE, 0x5C, 0xE9, 0x76, 0xFE, 0x8E, 0xF7, 0xB1, 0x08, 0x32, 0x0A, + 0xD2, 0x0A, 0x63, 0x10, 0x6D, 0x10, 0xA2, 0x14, 0x05, 0x19, 0x1D, 0x19, + 0x7B, 0x12, 0xAB, 0x12, 0xDF, 0xFA, 0xCE, 0x01, 0xEB, 0xDF, 0xE2, 0xEF, + 0xCF, 0xD7, 0x8E, 0xE5, 0x18, 0xE5, 0x95, 0xE1, 0x0F, 0xFA, 0x54, 0xE2, + 0xF5, 0x06, 0x32, 0xEC, 0xD2, 0x0A, 0xB6, 0xFE, 0x35, 0x0A, 0x71, 0x0B, + 0xE8, 0x08, 0xF7, 0x13, 0x2E, 0x0B, 0x31, 0x1A, 0x1F, 0x14, 0x45, 0x1F, + 0x3D, 0x18, 0x24, 0x1C, 0xE6, 0x0B, 0x11, 0x0D, 0xFE, 0xF1, 0xEE, 0xF8, + 0x48, 0xDD, 0xDD, 0xEA, 0x6B, 0xDF, 0x1D, 0xE5, 0x99, 0xF3, 0xE6, 0xE6, + 0x7E, 0x0A, 0x80, 0xF3, 0xB8, 0x16, 0xFA, 0x01, 0x67, 0x17, 0x87, 0x0F, + 0x4B, 0x0F, 0x25, 0x18, 0xED, 0x05, 0x2E, 0x1A, 0x2C, 0x04, 0x14, 0x1A, + 0x01, 0x0B, 0xF5, 0x15, 0x29, 0x0B, 0xD6, 0x08, 0x98, 0xFC, 0x03, 0xF4, + 0x27, 0xE4, 0x51, 0xE2, 0xEE, 0xD9, 0x8B, 0xD9, 0x8E, 0xEA, 0x56, 0xDC, + 0x92, 0xFB, 0x93, 0xE7, 0xE5, 0x0C, 0x6F, 0xF6, 0x3D, 0x1B, 0x5F, 0x07, + 0x10, 0x1B, 0xAD, 0x13, 0x82, 0x0D, 0x2C, 0x16, 0x17, 0xFD, 0xE2, 0x12, + 0xA1, 0xF9, 0xDB, 0x0D, 0x69, 0xFD, 0xEE, 0x03, 0xA2, 0xFC, 0x75, 0xF3, + 0xA2, 0xED, 0xCE, 0xE3, 0x49, 0xE0, 0x85, 0xDC, 0xDB, 0xE4, 0x98, 0xDE, + 0x8E, 0xF2, 0xEB, 0xEC, 0x5F, 0x07, 0x86, 0xFD, 0xD5, 0x1E, 0x7D, 0x0F, + 0xC4, 0x29, 0x6E, 0x1E, 0x45, 0x20, 0x3C, 0x22, 0x61, 0x07, 0xAC, 0x1B, + 0x28, 0xF4, 0x2A, 0x12, 0x3D, 0xF1, 0x52, 0x07, 0x16, 0xF8, 0xD6, 0xF9, + 0xD6, 0xF6, 0x6B, 0xEB, 0xD2, 0xE9, 0xB9, 0xDF, 0xE9, 0xEB, 0xD9, 0xE6, + 0x7A, 0xF2, 0x8C, 0xF1, 0x1F, 0xFD, 0xC4, 0xFA, 0x02, 0x11, 0xF8, 0x07, + 0x3A, 0x24, 0xB0, 0x17, 0x97, 0x26, 0x51, 0x1E, 0xC8, 0x11, 0xFB, 0x17, + 0xAE, 0xF3, 0x9E, 0x09, 0x72, 0xE4, 0xA9, 0xFC, 0x99, 0xE7, 0x5A, 0xEE, + 0x1B, 0xEA, 0x16, 0xDE, 0x06, 0xF4, 0x1A, 0xDC, 0x6A, 0xF6, 0x1F, 0xE1, + 0x74, 0xF1, 0xE4, 0xE7, 0xC4, 0xF0, 0x4A, 0xF0, 0x4C, 0xFD, 0xC2, 0xFD, + 0x7F, 0x14, 0x65, 0x10, 0xBD, 0x25, 0x5C, 0x1D, 0x1D, 0x20, 0xFF, 0x1B, + 0x01, 0x05, 0xA2, 0x0E, 0x90, 0xE9, 0x67, 0xFF, 0x6D, 0xE2, 0x72, 0xF1, + 0x85, 0xEC, 0x11, 0xE4, 0xAA, 0xF8, 0xAA, 0xE5, 0x05, 0x02, 0x82, 0xEC, + 0xBD, 0x02, 0x0B, 0xF4, 0xFA, 0xFE, 0x77, 0xFC, 0xD0, 0xFE, 0xA9, 0x06, + 0xE4, 0x0A, 0x6B, 0x15, 0x52, 0x1C, 0x9F, 0x22, 0x4C, 0x23, 0xC7, 0x23, + 0x08, 0x11, 0x9B, 0x17, 0x7B, 0xF2, 0x82, 0x04, 0x8F, 0xDF, 0x2B, 0xEF, + 0xB0, 0xDE, 0x43, 0xE9, 0xC6, 0xEB, 0x69, 0xE7, 0x6B, 0xFD, 0xC3, 0xE7, + 0x66, 0x08, 0x90, 0xED, 0x72, 0x09, 0x07, 0xF7, 0xB2, 0x01, 0x84, 0x00, + 0x58, 0xFF, 0xF8, 0x0B, 0x1E, 0x06, 0x1B, 0x17, 0xCA, 0x12, 0x39, 0x1B, + 0xD1, 0x0C, 0xB0, 0x0F, 0x7E, 0xF0, 0xB3, 0xF9, 0x7D, 0xE0, 0xAB, 0xEA, + 0x3B, 0xD9, 0xB6, 0xE1, 0xDB, 0xDB, 0xFF, 0xDC, 0x67, 0xEC, 0xB9, 0xDD, + 0xED, 0x01, 0xCA, 0xE7, 0xBD, 0x12, 0x37, 0xF8, 0xBD, 0x13, 0x29, 0x07, + 0x29, 0x0C, 0xDC, 0x12, 0x45, 0x06, 0x20, 0x1C, 0x94, 0x0D, 0x7B, 0x20, + 0x20, 0x10, 0x63, 0x18, 0xDF, 0xFF, 0xF7, 0x04, 0xE5, 0xF6, 0xF4, 0xF7, + 0x3F, 0xEB, 0x4A, 0xEF, 0x06, 0xE1, 0xA9, 0xE8, 0xBA, 0xE6, 0xFD, 0xE6, + 0x6F, 0xFB, 0x82, 0xEF, 0x05, 0x16, 0x2F, 0x01, 0x97, 0x24, 0xEC, 0x12, + 0x14, 0x1F, 0x71, 0x1D, 0x36, 0x0F, 0x43, 0x22, 0x8B, 0x06, 0x40, 0x21, + 0x80, 0x06, 0xD4, 0x16, 0x8E, 0x04, 0x7A, 0x08, 0x05, 0xFE, 0x2B, 0xF8, + 0x72, 0xF1, 0x05, 0xEB, 0xD4, 0xE1, 0x52, 0xE1, 0x21, 0xDC, 0x3B, 0xDD, + 0x18, 0xE8, 0x63, 0xE3, 0xB3, 0x03, 0xFF, 0xF4, 0xF7, 0x1E, 0xB7, 0x0A, + 0xC9, 0x24, 0x9B, 0x17, 0x0A, 0x14, 0xDD, 0x1A, 0xAD, 0x03, 0xDB, 0x17, + 0x3D, 0xF3, 0x2C, 0x0B, 0x0D, 0xF1, 0xB9, 0xFD, 0x5E, 0xF8, 0xEC, 0xF1, + 0x88, 0xFA, 0x75, 0xE8, 0xEC, 0xF2, 0x5B, 0xE3, 0x80, 0xE8, 0xBE, 0xE1, + 0xBE, 0xE7, 0x81, 0xE7, 0x4F, 0xF9, 0xD0, 0xF8, 0xBF, 0x16, 0x05, 0x11, + 0xA9, 0x2A, 0x08, 0x23, 0xAC, 0x23, 0xEA, 0x27, 0x81, 0x08, 0x11, 0x22, + 0x79, 0xF7, 0x0A, 0x15, 0x42, 0xEF, 0xA9, 0x07, 0xCE, 0xF3, 0x30, 0xFC, + 0x29, 0xFC, 0xB8, 0xF2, 0x8E, 0x00, 0xD3, 0xEE, 0x43, 0xFB, 0xA4, 0xED, + 0xF7, 0xF4, 0x02, 0xF1, 0x22, 0xF7, 0xA2, 0xFC, 0xBE, 0x0D, 0x04, 0x11, + 0x3D, 0x25, 0x3C, 0x23, 0xB5, 0x25, 0xCC, 0x2A, 0x15, 0x1A, 0xBD, 0x1F, + 0x23, 0x01, 0x58, 0x0F, 0xDC, 0xE7, 0x04, 0x00, 0xB6, 0xDE, 0x01, 0xF2, + 0x0D, 0xE6, 0x5A, 0xE7, 0x79, 0xF5, 0x0A, 0xE3, 0xD8, 0xFE, 0x04, 0xE4, + 0xFC, 0xFE, 0xAC, 0xE8, 0xE2, 0xFA, 0x86, 0xF1, 0x76, 0x03, 0xDB, 0x03, + 0xC4, 0x1C, 0xBE, 0x1B, 0x2A, 0x20, 0xDF, 0x1D, 0x25, 0x1B, 0x8E, 0x17, + 0x18, 0x0C, 0xC9, 0x0D, 0x25, 0xF3, 0xF4, 0x01, 0xD3, 0xDF, 0x66, 0xF4, + 0xC2, 0xDD, 0x70, 0xE9, 0x2D, 0xEC, 0x43, 0xE5, 0xA6, 0x01, 0x36, 0xEB, + 0xF6, 0x0C, 0x66, 0xF3, 0x89, 0x0C, 0xBF, 0xFF, 0x8A, 0x12, 0x79, 0x14, + 0x80, 0x0E, 0x8C, 0x1D, 0xF4, 0x12, 0x46, 0x23, 0x2F, 0x1E, 0x4A, 0x25, + 0xA0, 0x1E, 0x9E, 0x1E, 0x7C, 0x0B, 0x60, 0x11, 0x1C, 0xF0, 0x7E, 0xFF, + 0x38, 0xDD, 0xA8, 0xEE, 0x0C, 0xDE, 0xDB, 0xE4, 0xF5, 0xF0, 0xC4, 0xE7, + 0x22, 0x08, 0x7C, 0xF2, 0xC9, 0x11, 0x88, 0xFF, 0x53, 0x0E, 0x0E, 0x10, + 0x0E, 0x08, 0x17, 0x15, 0x5E, 0x04, 0x86, 0x17, 0xEF, 0x0A, 0x16, 0x19, + 0xB4, 0x10, 0x28, 0x13, 0x93, 0x0A, 0xBB, 0x06, 0xF1, 0xF5, 0x67, 0xF5, + 0x84, 0xDF, 0x7B, 0xE3, 0x02, 0xD4, 0x12, 0xD7, 0x19, 0xE0, 0xE5, 0xD7, + 0x25, 0xFC, 0x8D, 0xE6, 0xE8, 0x12, 0x37, 0xFC, 0x2A, 0x1B, 0x23, 0x09, + 0x13, 0x14, 0x1A, 0x11, 0x67, 0x06, 0x0B, 0x17, 0xFE, 0x00, 0xEA, 0x19, + 0xF9, 0x04, 0xA8, 0x15, 0xED, 0x09, 0x6D, 0x0B, 0x11, 0x04, 0xB2, 0xFD, + 0xA3, 0xF6, 0x2B, 0xEF, 0x1B, 0xE5, 0x67, 0xE2, 0xC9, 0xE5, 0xF9, 0xE1, + 0x6C, 0x00, 0x95, 0xF1, 0xC5, 0x14, 0xE2, 0x04, 0x0D, 0x24, 0x94, 0x15, + 0x50, 0x28, 0x0C, 0x20, 0xCD, 0x19, 0xD8, 0x23, 0x56, 0x07, 0x84, 0x21, + 0x9B, 0xFB, 0xF3, 0x17, 0x46, 0xFC, 0xB3, 0x0A, 0x61, 0xFD, 0x20, 0xFC, + 0x7C, 0xFA, 0x11, 0xEF, 0x65, 0xEB, 0x60, 0xE1, 0x97, 0xE2, 0xD2, 0xDC, + 0xE9, 0xF0, 0x72, 0xE8, 0xBB, 0xFD, 0x7A, 0xF7, 0xBE, 0x11, 0x15, 0x08, + 0x10, 0x24, 0x33, 0x15, 0x27, 0x20, 0xFF, 0x19, 0x72, 0x0A, 0x1E, 0x16, + 0xEB, 0xF1, 0xF2, 0x09, 0xCD, 0xE5, 0xB8, 0xF9, 0x27, 0xE7, 0x5D, 0xEB, + 0xB0, 0xED, 0xD7, 0xE0, 0xED, 0xED, 0xCE, 0xD9, 0xC3, 0xE6, 0x3F, 0xD7, + 0x74, 0xEA, 0x66, 0xE2, 0x42, 0xF5, 0xD6, 0xF3, 0x8D, 0x09, 0xCE, 0x07, + 0x2D, 0x23, 0xA6, 0x19, 0x32, 0x2D, 0xB6, 0x22, 0xEA, 0x1E, 0xEA, 0x20, + 0xEC, 0x02, 0xBF, 0x15, 0xA0, 0xE9, 0x23, 0x03, 0x56, 0xE3, 0xF2, 0xF3, + 0x4D, 0xEC, 0x4C, 0xEA, 0xD1, 0xF1, 0xB7, 0xE2, 0xCF, 0xFF, 0xB8, 0xEB, + 0x07, 0x03, 0x75, 0xF5, 0x5F, 0xFC, 0xA9, 0xFD, 0x27, 0xFF, 0x80, 0x0A, + 0x06, 0x12, 0x73, 0x19, 0xFF, 0x24, 0x96, 0x23, 0x00, 0x26, 0x8D, 0x23, + 0xD0, 0x11, 0xCB, 0x18, 0x8A, 0xF4, 0xAF, 0x04, 0x9B, 0xDF, 0x38, 0xEF, + 0x78, 0xDF, 0x8B, 0xE1, 0x76, 0xEF, 0x07, 0xDC, 0xF8, 0xFC, 0x37, 0xE3, + 0xFA, 0x03, 0xA1, 0xEB, 0x6F, 0xFE, 0xA6, 0xF1, 0xBE, 0xF8, 0x0B, 0xFC, + 0xAD, 0xFE, 0x41, 0x09, 0x32, 0x0F, 0x27, 0x14, 0xBB, 0x18, 0xA9, 0x16, + 0xD3, 0x11, 0x39, 0x0F, 0xCF, 0xF8, 0x3F, 0xFE, 0xE2, 0xDE, 0x34, 0xE9, + 0x9C, 0xD7, 0x02, 0xD8, 0x01, 0xDF, 0x1F, 0xDA, 0xAB, 0xF3, 0xE8, 0xE4, + 0x11, 0x0B, 0xD5, 0xF0, 0x14, 0x14, 0x2A, 0xFB, 0x0E, 0x0F, 0x9E, 0x07, + 0x9D, 0x07, 0x1B, 0x14, 0x75, 0x0A, 0x5E, 0x1E, 0x3E, 0x10, 0x22, 0x20, + 0x0F, 0x13, 0xFD, 0x1B, 0x2A, 0x05, 0x1E, 0x0D, 0xBC, 0xE9, 0x5A, 0xF4, + 0x68, 0xE0, 0x87, 0xEA, 0xBD, 0xE0, 0xAE, 0xE7, 0x29, 0xEB, 0x17, 0xEA, + 0x8F, 0x03, 0x2A, 0xF3, 0xC3, 0x17, 0xE2, 0xFE, 0x0D, 0x1D, 0x14, 0x0C, + 0x74, 0x12, 0xBC, 0x16, 0x84, 0x08, 0x04, 0x1D, 0x17, 0x03, 0x88, 0x1A, + 0xD9, 0x05, 0x60, 0x13, 0x1C, 0x01, 0xA9, 0x04, 0xE6, 0xEC, 0x88, 0xED, + 0xAA, 0xE6, 0x9C, 0xE2, 0x6D, 0xDE, 0x13, 0xDB, 0xDB, 0xD9, 0xF6, 0xD7, + 0x5B, 0xEA, 0x69, 0xE0, 0xCD, 0x06, 0x87, 0xF0, 0x49, 0x1C, 0xD8, 0x02, + 0x65, 0x1D, 0xEA, 0x11, 0x21, 0x10, 0xAA, 0x18, 0x09, 0x02, 0xD8, 0x16, + 0xE0, 0xFB, 0x22, 0x0E, 0x6D, 0xF9, 0xE9, 0xFE, 0x98, 0xFA, 0x7C, 0xF5, + 0xE0, 0xF8, 0x78, 0xED, 0xEB, 0xEE, 0xF0, 0xE4, 0x77, 0xE2, 0xE1, 0xE0, + 0xB8, 0xE6, 0x80, 0xE8, 0x95, 0x00, 0x90, 0xFA, 0x35, 0x1F, 0xCB, 0x10, + 0xFC, 0x2E, 0x64, 0x23, 0x8B, 0x26, 0xF1, 0x2B, 0x0C, 0x11, 0x70, 0x27, + 0xBC, 0xFF, 0x37, 0x19, 0xEB, 0xF4, 0x52, 0x09, 0xD7, 0xF5, 0xBF, 0xFD, + 0x22, 0xFE, 0x92, 0xF5, 0x5C, 0xFE, 0x2B, 0xED, 0xC8, 0xF2, 0x0D, 0xE7, + 0x9F, 0xE8, 0xC3, 0xE8, 0x40, 0xF2, 0x7D, 0xF5, 0x6B, 0x0A, 0x6A, 0x08, + 0x21, 0x22, 0xAA, 0x1A, 0x9F, 0x23, 0xBE, 0x23, 0x8A, 0x0D, 0xE7, 0x1D, + 0xAB, 0xF7, 0xDC, 0x0C, 0xF7, 0xE5, 0x5A, 0xF9, 0x22, 0xDE, 0x59, 0xEA, + 0x7B, 0xE7, 0x2B, 0xE3, 0x3A, 0xF4, 0xCB, 0xDF, 0xCB, 0xF7, 0xAC, 0xDE, + 0x57, 0xF0, 0xB3, 0xE2, 0xF9, 0xF0, 0xB9, 0xEF, 0x24, 0x00, 0xFA, 0x02, + 0x6B, 0x19, 0xB8, 0x17, 0x46, 0x26, 0x75, 0x24, 0xC1, 0x19, 0xEB, 0x22, + 0x9A, 0x09, 0x8E, 0x15, 0x92, 0xF4, 0xEB, 0x03, 0x20, 0xE1, 0xB7, 0xF3, + 0x4D, 0xE1, 0xA4, 0xEB, 0x01, 0xF3, 0xE2, 0xEA, 0x5D, 0x05, 0xA7, 0xEE, + 0x4E, 0x0A, 0xF1, 0xF5, 0x94, 0x07, 0x45, 0x02, 0xAB, 0x0A, 0x35, 0x12, + 0xEC, 0x17, 0x3F, 0x22, 0x85, 0x26, 0xC8, 0x2F, 0xEC, 0x22, 0xD6, 0x29, + 0xFE, 0x15, 0xF1, 0x1C, 0x68, 0x01, 0x8C, 0x0C, 0xDD, 0xE6, 0x40, 0xF9, + 0x1C, 0xD8, 0x1E, 0xEA, 0x20, 0xE1, 0x47, 0xE4, 0xA2, 0xF7, 0x24, 0xE6, + 0x2C, 0x0A, 0x97, 0xEE, 0x40, 0x0C, 0x4F, 0xF9, 0x7E, 0x09, 0x66, 0x07, + 0x10, 0x11, 0xA7, 0x18, 0xF4, 0x0B, 0xE7, 0x17, 0xF6, 0x09, 0xC0, 0x12, + 0x2F, 0x0D, 0x3D, 0x0E, 0x07, 0x07, 0x4B, 0x04, 0x0A, 0xF2, 0xA2, 0xF3, + 0x88, 0xD9, 0x2F, 0xE2, 0x1E, 0xD3, 0xAD, 0xD9, 0x5E, 0xE4, 0x33, 0xDC, + 0xB5, 0xFF, 0x9F, 0xE8, 0x14, 0x12, 0x7D, 0xFA, 0x48, 0x16, 0x4F, 0x0D, + 0xA6, 0x12, 0x03, 0x1D, 0x31, 0x0C, 0x81, 0x1E, 0x75, 0x08, 0xE6, 0x1A, + 0x6C, 0x0C, 0x50, 0x18, 0xA2, 0x0F, 0xAD, 0x11, 0x4B, 0x07, 0x9D, 0x04, + 0x55, 0xF1, 0x25, 0xF4, 0x42, 0xE0, 0x8A, 0xE8, 0xBA, 0xE3, 0xD7, 0xE7, + 0xBD, 0xFC, 0x40, 0xF2, 0x4C, 0x17, 0xD7, 0x04, 0x1B, 0x23, 0x5F, 0x1B, + 0x29, 0x21, 0x22, 0x23, 0x25, 0x15, 0xA3, 0x22, 0x2B, 0x05, 0x33, 0x1D, + 0x6F, 0xFD, 0x80, 0x15, 0x10, 0x00, 0x6E, 0x0B, 0x7B, 0x03, 0x96, 0xFE, + 0xE3, 0xF8, 0xA4, 0xED, 0xD8, 0xE6, 0xB3, 0xDF, 0x49, 0xDC, 0xBF, 0xD8, + 0x9D, 0xEA, 0x3C, 0xE0, 0x62, 0x09, 0x0D, 0xF7, 0x25, 0x19, 0x02, 0x06, + 0x6C, 0x1D, 0xF8, 0x10, 0x62, 0x17, 0x72, 0x17, 0x3E, 0x05, 0xFF, 0x14, + 0x5B, 0xF3, 0x92, 0x0B, 0x2F, 0xED, 0xFF, 0xFF, 0x61, 0xF5, 0x1C, 0xF5, + 0xB5, 0xF9, 0x63, 0xE9, 0xA3, 0xF3, 0x46, 0xE0, 0xD6, 0xE7, 0xCD, 0xDC, + 0xE3, 0xEC, 0x15, 0xE6, 0xE3, 0x07, 0x31, 0xFC, 0x76, 0x16, 0xA6, 0x0D, + 0xC5, 0x22, 0xD2, 0x1C, 0x60, 0x29, 0x22, 0x28, 0x37, 0x1D, 0x3E, 0x27, + 0x74, 0x03, 0x6E, 0x1B, 0x29, 0xEE, 0xC1, 0x0A, 0xCA, 0xEB, 0x36, 0xFC, + 0x4C, 0xF6, 0x37, 0xF1, 0x04, 0xFB, 0xA8, 0xE9, 0x0E, 0xF6, 0x85, 0xE7, + 0x93, 0xF6, 0x35, 0xEF, 0x3C, 0xFB, 0x60, 0xFC, 0xFA, 0x06, 0xD2, 0x0A, + 0x76, 0x18, 0xF2, 0x18, 0x31, 0x27, 0x96, 0x23, 0xAD, 0x24, 0x4C, 0x23, + 0x4A, 0x0B, 0x69, 0x15, 0x8E, 0xEA, 0xFF, 0xFF, 0x20, 0xD7, 0x19, 0xEB, + 0x62, 0xDC, 0xBE, 0xDD, 0xBD, 0xE9, 0x20, 0xD7, 0xED, 0xED, 0x40, 0xD7, + 0xDB, 0xF5, 0x47, 0xE2, 0xEE, 0xF8, 0xA3, 0xEF, 0xA3, 0xFA, 0x68, 0xFC, + 0x0E, 0x05, 0x80, 0x0A, 0x51, 0x15, 0x76, 0x17, 0x9B, 0x20, 0x28, 0x1D, + 0x20, 0x17, 0xA1, 0x15, 0x9C, 0xFB, 0x03, 0x04, 0x17, 0xE0, 0xAE, 0xEF, + 0x94, 0xDB, 0x5A, 0xE2, 0xA3, 0xE9, 0x25, 0xDE, 0x70, 0xFC, 0x00, 0xE3, + 0x8E, 0x0A, 0xA6, 0xF2, 0xB9, 0x0F, 0x8A, 0x02, 0xDE, 0x0C, 0xC3, 0x0E, + 0x60, 0x0B, 0x0C, 0x19, 0x58, 0x10, 0x3D, 0x21, 0x96, 0x1B, 0xEA, 0x24, + 0x13, 0x1D, 0x14, 0x1F, 0x72, 0x0C, 0xA1, 0x0E, 0x42, 0xEE, 0x50, 0xF9, + 0x23, 0xDC, 0x04, 0xE7, 0xD6, 0xE2, 0x8A, 0xDC, 0x93, 0xF1, 0x67, 0xE4, + 0x8B, 0x03, 0xF2, 0xF0, 0x9A, 0x11, 0x97, 0xFD, 0x81, 0x13, 0x62, 0x08, + 0x76, 0x0B, 0xF4, 0x0F, 0xCF, 0x02, 0xDD, 0x13, 0x56, 0x02, 0x0B, 0x14, + 0x2B, 0x07, 0xC7, 0x0D, 0xF0, 0x01, 0x55, 0x00, 0x35, 0xED, 0x9D, 0xEC, + 0x93, 0xD4, 0x33, 0xD5, 0x75, 0xD2, 0xD9, 0xD2, 0x81, 0xDE, 0x8F, 0xD8, + 0x3B, 0xF3, 0x4A, 0xE2, 0xE9, 0x0A, 0xE3, 0xF1, 0xAA, 0x1A, 0xDD, 0x03, + 0xAF, 0x19, 0xC7, 0x11, 0xA6, 0x0C, 0x17, 0x19, 0x03, 0xFF, 0x38, 0x18, + 0xCA, 0xFF, 0x14, 0x14, 0x85, 0x02, 0x05, 0x09, 0x40, 0xF3, 0x3E, 0xF4, + 0x80, 0xF0, 0xCF, 0xEC, 0x47, 0xEB, 0x93, 0xE9, 0x5E, 0xE5, 0x2B, 0xE7, + 0x1B, 0xED, 0x94, 0xEB, 0xE3, 0x02, 0x84, 0xF9, 0x94, 0x1D, 0xEC, 0x0D, + 0x38, 0x2A, 0x4A, 0x1F, 0x63, 0x22, 0x41, 0x27, 0x4C, 0x0C, 0xAB, 0x23, + 0x54, 0xFD, 0x9C, 0x18, 0xE5, 0xFA, 0x89, 0x09, 0xCA, 0xF8, 0xE1, 0xF6, + 0x60, 0xF8, 0x94, 0xED, 0x81, 0xF2, 0x7C, 0xE7, 0x29, 0xE6, 0x23, 0xE1, + 0x8B, 0xE2, 0x3C, 0xE1, 0x1D, 0xEE, 0xD6, 0xEA, 0x74, 0x08, 0x11, 0xFE, + 0x6B, 0x1F, 0x28, 0x11, 0x6D, 0x23, 0x9A, 0x1B, 0xEC, 0x0D, 0x5F, 0x18, + 0xF5, 0xF3, 0x74, 0x0A, 0x13, 0xE9, 0x71, 0xF7, 0xDA, 0xE6, 0x8B, 0xEA, + 0x40, 0xED, 0x22, 0xE3, 0x88, 0xF3, 0x77, 0xDF, 0xB0, 0xF0, 0x68, 0xDE, + 0x3C, 0xEC, 0x5B, 0xE2, 0xC0, 0xEE, 0x1C, 0xEE, 0x14, 0x01, 0x7F, 0x02, + 0x9D, 0x1A, 0x7F, 0x18, 0x34, 0x2B, 0x2A, 0x28, 0x19, 0x20, 0x41, 0x28, + 0x68, 0x03, 0x2C, 0x19, 0x8D, 0xEE, 0xEB, 0x08, 0x67, 0xE7, 0x6D, 0xFA, + 0xEC, 0xED, 0x87, 0xF0, 0xB5, 0xFA, 0x58, 0xEC, 0xE0, 0x01, 0xD8, 0xEC, + 0xAC, 0x01, 0x0D, 0xF2, 0x24, 0xFD, 0xDA, 0xFB, 0x1B, 0x01, 0x0E, 0x0B, + 0xB2, 0x0F, 0x40, 0x1C, 0x14, 0x23, 0x1F, 0x29, 0xED, 0x22, 0xFF, 0x28, + 0xD3, 0x07, 0x47, 0x1A, 0x06, 0xF4, 0xE3, 0x06, 0x59, 0xE3, 0x7D, 0xF3, + 0x60, 0xDC, 0x2B, 0xE4, 0x4C, 0xE5, 0x70, 0xDD, 0xFA, 0xF4, 0xF1, 0xDE, + 0xBE, 0x00, 0xEA, 0xE6, 0x9E, 0x03, 0x89, 0xF2, 0xB6, 0x00, 0xBE, 0x00, + 0x87, 0x05, 0x9B, 0x0F, 0x87, 0x12, 0xE8, 0x1A, 0x9E, 0x17, 0x0C, 0x1E, + 0x9B, 0x11, 0x21, 0x12, 0xF9, 0xFF, 0x9B, 0x01, 0x29, 0xE8, 0x7D, 0xF1, + 0x16, 0xD8, 0x02, 0xE4, 0x61, 0xDA, 0xEA, 0xDD, 0x40, 0xEE, 0x72, 0xE2, + 0xD9, 0x06, 0xDE, 0xEE, 0x16, 0x19, 0xB5, 0x00, 0x7D, 0x1A, 0x8A, 0x11, + 0x93, 0x16, 0x53, 0x20, 0xE3, 0x1B, 0x94, 0x2B, 0xD9, 0x16, 0xEA, 0x26, + 0x4D, 0x14, 0xF1, 0x1C, 0x30, 0x10, 0xED, 0x11, 0x0B, 0x00, 0xD1, 0x03, + 0xB0, 0xEB, 0x3F, 0xF4, 0xD2, 0xDE, 0x6D, 0xE8, 0x44, 0xE5, 0x40, 0xE6, + 0x2F, 0xFA, 0x07, 0xEF, 0xA6, 0x13, 0x0B, 0x00, 0x06, 0x1E, 0x51, 0x11, + 0x88, 0x18, 0x36, 0x1E, 0x97, 0x0F, 0xDC, 0x24, 0x51, 0x03, 0x05, 0x1B, + 0xD2, 0xFE, 0x08, 0x0E, 0xBE, 0x01, 0x72, 0x03, 0xFC, 0xFC, 0x6D, 0xF7, + 0xC7, 0xEE, 0xA5, 0xE9, 0xC2, 0xDD, 0x2C, 0xDD, 0x6D, 0xD8, 0x48, 0xD8, + 0x61, 0xE5, 0xF1, 0xDF, 0x4E, 0x02, 0x76, 0xF1, 0x53, 0x1A, 0xA9, 0x07, + 0xC4, 0x1C, 0xC8, 0x1B, 0x4C, 0x13, 0xFA, 0x1B, 0x87, 0x03, 0x83, 0x15, + 0xE0, 0xF7, 0x75, 0x0D, 0x6A, 0xF9, 0x97, 0x05, 0xD4, 0xFD, 0xCB, 0xFC, + 0x50, 0xFD, 0x58, 0xF3, 0x0B, 0xF4, 0xB7, 0xE9, 0xB7, 0xEB, 0xAC, 0xE6, + 0x8C, 0xEE, 0xF4, 0xEB, 0x7C, 0x05, 0xFE, 0xFD, 0x7D, 0x21, 0xFA, 0x17, + 0x1D, 0x2E, 0xC9, 0x24, 0x9D, 0x28, 0xCD, 0x28, 0xBC, 0x14, 0x12, 0x26, + 0x74, 0xFD, 0x86, 0x1B, 0x58, 0xF2, 0x65, 0x0D, 0x72, 0xF3, 0x16, 0xFF, + 0x91, 0xFA, 0x86, 0xF3, 0x6C, 0xFB, 0xEC, 0xE9, 0x94, 0xF6, 0xA3, 0xE5, + 0xE5, 0xEF, 0xF5, 0xE7, 0x6F, 0xF9, 0x87, 0xF5, 0xAC, 0x16, 0x6A, 0x0D, + 0xE1, 0x1D, 0xFD, 0x15, 0xEF, 0x1E, 0x08, 0x1A, 0xC3, 0x15, 0x2E, 0x1A, + 0xC1, 0xFE, 0x74, 0x10, 0x9D, 0xE8, 0x20, 0x00, 0xE9, 0xDF, 0x10, 0xEF, + 0xA6, 0xE4, 0xA3, 0xE2, 0x1F, 0xF0, 0x48, 0xDC, 0x1B, 0xF4, 0xE6, 0xDA, + 0x4B, 0xF3, 0xF7, 0xE1, 0xBF, 0xFC, 0xCC, 0xF4, 0xCE, 0x00, 0x7D, 0x02, + 0x68, 0x0D, 0x49, 0x10, 0x30, 0x20, 0x4B, 0x1D, 0x8E, 0x26, 0x6C, 0x23, + 0x39, 0x17, 0x69, 0x1D, 0x4C, 0xFB, 0xC3, 0x0C, 0x54, 0xE5, 0x63, 0xF9, + 0xBE, 0xDF, 0xB2, 0xEA, 0x7B, 0xEB, 0x3C, 0xE4, 0x29, 0xFB, 0xA6, 0xE6, + 0x5C, 0x01, 0x9D, 0xF0, 0xA6, 0x08, 0x5E, 0x00, 0x02, 0x0A, 0xDD, 0x0E, + 0xF6, 0x0B, 0x33, 0x1A, 0x86, 0x17, 0xDF, 0x22, 0xFC, 0x20, 0x97, 0x25, + 0xB4, 0x1C, 0x15, 0x1F, 0x32, 0x06, 0x03, 0x0E, 0xE2, 0xEB, 0x07, 0xF8, + 0x8B, 0xDA, 0xC4, 0xE4, 0x19, 0xDE, 0x99, 0xDA, 0x33, 0xEF, 0x72, 0xDB, + 0x98, 0x01, 0x31, 0xE7, 0x39, 0x0B, 0xAA, 0xF5, 0x25, 0x0A, 0xFD, 0x02, + 0x64, 0x03, 0x16, 0x0D, 0x68, 0x04, 0x4B, 0x13, 0xE0, 0x0B, 0x3D, 0x15, + 0x6C, 0x10, 0x99, 0x10, 0xAA, 0x06, 0x5F, 0x03, 0x91, 0xF2, 0x51, 0xF0, + 0x7B, 0xDC, 0xF7, 0xDD, 0x9E, 0xD7, 0xB8, 0xD4, 0x1E, 0xEA, 0xDE, 0xD6, + 0x8E, 0xFC, 0x41, 0xE6, 0xB5, 0x0F, 0x3B, 0xF9, 0xF6, 0x1A, 0x29, 0x0B, + 0x41, 0x17, 0x4A, 0x18, 0x87, 0x0E, 0xCB, 0x1E, 0xC1, 0x0A, 0xBC, 0x1E, + 0xBF, 0x0B, 0x57, 0x19, 0x28, 0x0A, 0x82, 0x0D, 0xA7, 0xFE, 0x8F, 0xFD, + 0x34, 0xED, 0x00, 0xED, 0xFA, 0xE0, 0x6A, 0xDE, 0xF7, 0xE5, 0x3B, 0xE5, + 0x16, 0xF6, 0x60, 0xF1, 0x83, 0x0D, 0x65, 0xFE, 0x10, 0x21, 0x6E, 0x0D, + 0xEF, 0x23, 0x87, 0x1A, 0xD6, 0x15, 0xBC, 0x1F, 0x41, 0x05, 0x5D, 0x1C, + 0x64, 0xF9, 0x70, 0x11, 0x9E, 0xF7, 0x91, 0x04, 0xE5, 0xF3, 0x8B, 0xF3, + 0x75, 0xE4, 0x3B, 0xDF, 0x5E, 0xE3, 0x14, 0xDB, 0x9A, 0xE2, 0xCE, 0xDC, + 0x18, 0xE3, 0xA6, 0xE0, 0x85, 0xF2, 0x48, 0xEA, 0x02, 0x0C, 0xF8, 0xFA, + 0xC3, 0x1E, 0xBB, 0x0D, 0x62, 0x1C, 0x9E, 0x18, 0xA7, 0x0B, 0xEE, 0x17, + 0xFA, 0xF7, 0x39, 0x0D, 0xCD, 0xEF, 0x93, 0xFF, 0x76, 0xEF, 0x88, 0xF0, + 0x7E, 0xED, 0xE9, 0xE0, 0x05, 0xF3, 0x03, 0xE1, 0xC6, 0xF3, 0xD3, 0xE5, + 0x1C, 0xEE, 0xA9, 0xEA, 0xB2, 0xF3, 0x32, 0xF4, 0xEA, 0x08, 0x9D, 0x04, + 0x31, 0x22, 0x37, 0x18, 0x9F, 0x2B, 0x2F, 0x26, 0xCA, 0x1F, 0xCE, 0x26, + 0x9A, 0x07, 0x56, 0x1C, 0x88, 0xF3, 0x9D, 0x0A, 0xFD, 0xEC, 0x08, 0xF5, + 0x60, 0xF0, 0x0B, 0xEE, 0x7F, 0xF8, 0x5B, 0xEB, 0x45, 0xFD, 0x88, 0xEA, + 0xE1, 0xF7, 0x8F, 0xEC, 0xB9, 0xF3, 0xDD, 0xF3, 0xF6, 0xFB, 0xA3, 0x00, + 0x54, 0x10, 0x85, 0x11, 0xA7, 0x1F, 0x9A, 0x1E, 0x53, 0x1D, 0x20, 0x21, + 0x48, 0x07, 0x34, 0x15, 0xC8, 0xEC, 0xD8, 0xFE, 0x62, 0xDD, 0x8E, 0xED, + 0x78, 0xDC, 0xFB, 0xE1, 0x6F, 0xE7, 0xB7, 0xDB, 0x5F, 0xF6, 0x96, 0xDB, + 0x1D, 0xFC, 0x17, 0xE2, 0xF0, 0xF9, 0x04, 0xEE, 0x89, 0xF9, 0x71, 0xFC, + 0xD0, 0x04, 0x37, 0x0D, 0xEC, 0x13, 0x36, 0x1B, 0xB0, 0x1B, 0x9A, 0x20, + 0xAA, 0x0F, 0xF8, 0x17, 0x0E, 0xF3, 0xBD, 0x03, 0x87, 0xE7, 0x9C, 0xF5, + 0x55, 0xE2, 0x8E, 0xEB, 0x5B, 0xE6, 0xCB, 0xE4, 0xEC, 0xF6, 0x60, 0xE5, + 0x47, 0x08, 0x7B, 0xEE, 0x8D, 0x0F, 0x56, 0xFD, 0xDD, 0x0E, 0xBE, 0x0D, + 0x0D, 0x0F, 0x5E, 0x1C, 0xE3, 0x16, 0x5E, 0x27, 0x39, 0x1C, 0x7A, 0x29, + 0x71, 0x12, 0xA1, 0x1E, 0x58, 0x08, 0xC5, 0x0E, 0x79, 0xF8, 0xF6, 0xFD, + 0x00, 0xE5, 0xC6, 0xEE, 0x20, 0xDB, 0xAD, 0xE3, 0x41, 0xE4, 0x58, 0xE0, + 0x7A, 0xFB, 0xD1, 0xE7, 0x08, 0x0F, 0x4A, 0xF7, 0x6F, 0x16, 0x6D, 0x09, + 0xC4, 0x12, 0xC1, 0x16, 0x14, 0x0F, 0x13, 0x1E, 0xD0, 0x0F, 0x7C, 0x1E, + 0xD2, 0x07, 0x4A, 0x11, 0xFC, 0xFF, 0x5E, 0x01, 0xC5, 0xF7, 0x06, 0xF3, + 0xD9, 0xE8, 0x70, 0xE6, 0x9B, 0xDA, 0x85, 0xDD, 0xA1, 0xD9, 0x20, 0xDA, + 0x54, 0xED, 0xC5, 0xE1, 0x22, 0x08, 0x93, 0xF3, 0xA6, 0x1B, 0xD5, 0x09, + 0x05, 0x1D, 0xCD, 0x1A, 0x8C, 0x15, 0x9D, 0x23, 0x29, 0x0D, 0xB8, 0x22, + 0x58, 0x03, 0xD3, 0x16, 0x6F, 0xFF, 0x7B, 0x09, 0x72, 0x00, 0x6A, 0xFD, + 0x56, 0xFB, 0x7E, 0xF3, 0x39, 0xEF, 0x12, 0xEC, 0xA6, 0xE5, 0xD5, 0xE8, + 0x67, 0xED, 0xDA, 0xED, 0xCE, 0x04, 0x74, 0xFD, 0xE7, 0x1D, 0x89, 0x12, + 0x73, 0x27, 0x28, 0x24, 0xAB, 0x1E, 0xD0, 0x2D, 0x99, 0x0F, 0xC8, 0x24, + 0xB2, 0xFF, 0x02, 0x17, 0x23, 0xF5, 0x5F, 0x08, 0x12, 0xF5, 0x7C, 0xFA, + 0x01, 0xF8, 0xCA, 0xEE, 0x18, 0xF4, 0xE1, 0xE6, 0x44, 0xEA, 0x09, 0xE3, + 0x6A, 0xE7, 0xC0, 0xE5, 0xDA, 0xF5, 0x06, 0xF1, 0x65, 0x0E, 0xD4, 0x04, + 0xF5, 0x20, 0x1E, 0x1C, 0x1B, 0x1F, 0x79, 0x1D, 0xE2, 0x10, 0x16, 0x17, + 0xB0, 0xFC, 0x19, 0x0E, 0x16, 0xEB, 0x60, 0x02, 0xCF, 0xE5, 0x7D, 0xF4, + 0x27, 0xEE, 0x09, 0xE9, 0x14, 0xF6, 0x80, 0xE2, 0xD1, 0xF7, 0x0E, 0xE3, + 0x4C, 0xF3, 0x4C, 0xE7, 0xAA, 0xFA, 0xFE, 0xF4, 0xAE, 0x13, 0xD6, 0x0D, + 0x7B, 0x1E, 0xC3, 0x1A, 0xFE, 0x22, 0xEA, 0x21, 0x3F, 0x22, 0x36, 0x24, + 0xBB, 0x13, 0xE6, 0x1E, 0x17, 0xFD, 0xB3, 0x12, 0xCA, 0xEA, 0x28, 0x01, + 0x07, 0xEA, 0xA1, 0xF1, 0x4F, 0xF4, 0xA4, 0xE8, 0x7F, 0xFE, 0xD4, 0xE8, + 0xEF, 0xFE, 0x20, 0xEF, 0x01, 0x01, 0x0F, 0xFC, 0x44, 0x0E, 0x38, 0x10, + 0xB4, 0x12, 0xFD, 0x19, 0xDD, 0x17, 0xD5, 0x1E, 0xB6, 0x1D, 0x91, 0x20, + 0xF3, 0x16, 0x61, 0x1A, 0x01, 0x02, 0x11, 0x0D, 0x01, 0xE8, 0x6B, 0xFA, + 0xD0, 0xDA, 0x96, 0xE7, 0xA2, 0xE0, 0xFE, 0xDB, 0xF7, 0xEF, 0xE3, 0xDA, + 0xF1, 0xFB, 0x3E, 0xE4, 0xF7, 0x02, 0x7F, 0xF6, 0xE7, 0x04, 0xE3, 0x02, + 0xFF, 0x06, 0x61, 0x0D, 0x5B, 0x0C, 0x9D, 0x16, 0x48, 0x14, 0xC3, 0x1A, + 0x23, 0x16, 0x1C, 0x16, 0x61, 0x0A, 0x69, 0x0A, 0xF0, 0xF2, 0xE2, 0xF9, + 0x9C, 0xDE, 0x8B, 0xE8, 0x13, 0xDC, 0x77, 0xDC, 0xB5, 0xEC, 0xD6, 0xDC, + 0xAD, 0x00, 0x08, 0xEA, 0x80, 0x10, 0xDB, 0xFB, 0x82, 0x16, 0xD3, 0x0C, + 0x77, 0x14, 0xEC, 0x19, 0x30, 0x11, 0x1E, 0x23, 0x6C, 0x11, 0xBB, 0x24, + 0x87, 0x13, 0xA6, 0x1D, 0x79, 0x10, 0x6A, 0x10, 0x9E, 0x01, 0x0A, 0x00, + 0x8C, 0xEC, 0x37, 0xEF, 0xE1, 0xDF, 0x95, 0xE1, 0x35, 0xE7, 0xBB, 0xDE, + 0xF5, 0xFE, 0xA8, 0xE9, 0x08, 0x0E, 0x0E, 0xFA, 0xD1, 0x16, 0x9D, 0x09, + 0xBA, 0x17, 0x19, 0x16, 0x48, 0x10, 0x4B, 0x1D, 0x16, 0x06, 0x66, 0x1C, + 0xC5, 0x00, 0x88, 0x12, 0x2D, 0xFF, 0x16, 0x03, 0x66, 0xFA, 0xE3, 0xF2, + 0x3D, 0xEB, 0x19, 0xE4, 0xA8, 0xDC, 0x4F, 0xD8, 0x84, 0xDF, 0xAD, 0xD4, + 0x6E, 0xEA, 0xCF, 0xDF, 0x6F, 0xFD, 0x98, 0xF0, 0x9B, 0x12, 0x4F, 0x02, + 0xC2, 0x1E, 0x62, 0x11, 0xB9, 0x1B, 0x66, 0x1B, 0x6F, 0x0B, 0x3D, 0x1C, + 0xF0, 0xFB, 0xE3, 0x13, 0x66, 0xF4, 0xDC, 0x03, 0xA3, 0xF5, 0x5D, 0xF5, + 0xAB, 0xF1, 0xB0, 0xE8, 0x65, 0xE6, 0x19, 0xDD, 0x9A, 0xE8, 0x02, 0xE3, + 0x0C, 0xF1, 0xCF, 0xED, 0xF5, 0xFD, 0x01, 0xFA, 0x10, 0x12, 0x65, 0x09, + 0x74, 0x23, 0x27, 0x18, 0x7A, 0x28, 0xCE, 0x22, 0x4C, 0x1A, 0x73, 0x24, + 0xAE, 0x03, 0xDF, 0x1B, 0x50, 0xF1, 0xB5, 0x09, 0xC8, 0xEE, 0x25, 0xF7, + 0xD6, 0xEF, 0x0A, 0xE8, 0x60, 0xEB, 0xC5, 0xDD, 0xBD, 0xF0, 0x85, 0xE3, + 0x4E, 0xF3, 0xAA, 0xEB, 0x7F, 0xF5, 0xE3, 0xF3, 0x42, 0x01, 0x5D, 0x00, + 0x08, 0x13, 0xE3, 0x0D, 0x14, 0x20, 0xE4, 0x17, 0x05, 0x1C, 0xAA, 0x1A, + 0x3D, 0x06, 0xF6, 0x12, 0xCD, 0xED, 0x43, 0x02, 0xF5, 0xE1, 0xBE, 0xED, + 0x76, 0xE2, 0xB7, 0xDA, 0x6D, 0xEC, 0x8B, 0xDA, 0xE6, 0xF4, 0x4B, 0xE0, + 0x68, 0xF7, 0x89, 0xE6, 0x0C, 0xF7, 0xAA, 0xEF, 0x7A, 0xFC, 0x72, 0xFE, + 0xC3, 0x0A, 0x72, 0x0E, 0x87, 0x1B, 0x09, 0x1B, 0x87, 0x21, 0xE7, 0x1E, + 0x90, 0x14, 0xFD, 0x1A, 0xBA, 0xFA, 0xE9, 0x0B, 0x11, 0xE8, 0x7F, 0xF4, + 0xBB, 0xE3, 0xFB, 0xE9, 0x02, 0xED, 0x73, 0xE7, 0xAA, 0xFB, 0xFC, 0xE8, + 0xA0, 0x05, 0x7F, 0xEE, 0xF8, 0x07, 0x3A, 0xF8, 0x67, 0x07, 0x63, 0x07, + 0x49, 0x0A, 0xC2, 0x16, 0x83, 0x12, 0xDB, 0x20, 0x47, 0x19, 0xB4, 0x21, + 0xB3, 0x13, 0x0E, 0x1B, 0xA3, 0xFE, 0x64, 0x0B, 0xB1, 0xE3, 0xC7, 0xF3, + 0x0E, 0xDD, 0x59, 0xE8, 0x1F, 0xE1, 0x32, 0xE2, 0x1F, 0xED, 0x05, 0xE0, + 0x0C, 0xFC, 0x03, 0xE5, 0x67, 0x07, 0xEC, 0xEF, 0x55, 0x0A, 0x5A, 0x00, + 0x31, 0x09, 0xFC, 0x10, 0x0E, 0x08, 0xB4, 0x1A, 0xCC, 0x0C, 0x24, 0x1B, + 0x33, 0x0C, 0xCE, 0x12, 0x33, 0xFA, 0x59, 0x01, 0x05, 0xF1, 0x60, 0xF4, + 0xEE, 0xE5, 0xD7, 0xE8, 0x05, 0xDD, 0x4B, 0xDF, 0x13, 0xE1, 0xCE, 0xDC, + 0xCE, 0xF2, 0xE9, 0xE3, 0x29, 0x09, 0x95, 0xF2, 0x8A, 0x18, 0x59, 0x06, + 0x74, 0x1B, 0x17, 0x1A, 0x53, 0x16, 0xC5, 0x26, 0x63, 0x11, 0x7D, 0x26, + 0x34, 0x0E, 0xE2, 0x1B, 0x85, 0x08, 0xA7, 0x0C, 0x8F, 0x00, 0xDE, 0xFE, + 0xFC, 0xF4, 0x2B, 0xF3, 0x6E, 0xE7, 0x3A, 0xE9, 0x5E, 0xE3, 0x8C, 0xE5, + 0xEE, 0xED, 0x73, 0xEA, 0x0C, 0x04, 0x3E, 0xF7, 0x1F, 0x1A, 0xB8, 0x08, + 0x18, 0x23, 0x58, 0x1B, 0x77, 0x1B, 0xD4, 0x26, 0x35, 0x10, 0x8C, 0x25, + 0xA1, 0x00, 0x2F, 0x17, 0x93, 0xF8, 0x56, 0x05, 0xBC, 0xF7, 0x0B, 0xF6, + 0x0F, 0xF5, 0xEB, 0xEA, 0xA1, 0xEC, 0x9E, 0xE2, 0x02, 0xE4, 0x7D, 0xDF, + 0x01, 0xE5, 0x7F, 0xE4, 0x9D, 0xF4, 0x42, 0xF1, 0x7C, 0x0C, 0x91, 0x02, + 0x94, 0x1E, 0x02, 0x15, 0xD5, 0x1D, 0x6D, 0x21, 0x83, 0x0C, 0x11, 0x22, + 0x99, 0xFC, 0xD2, 0x14, 0xB4, 0xF1, 0x0F, 0x03, 0x49, 0xF0, 0x75, 0xF4, + 0xBC, 0xF3, 0xDB, 0xEA, 0x36, 0xF5, 0xFA, 0xE4, 0x9D, 0xF1, 0x93, 0xE4, + 0x76, 0xF0, 0x97, 0xEB, 0x57, 0xF8, 0x7A, 0xFA, 0x75, 0x0D, 0x25, 0x0C, + 0xCA, 0x22, 0x52, 0x1D, 0x70, 0x27, 0x8C, 0x2C, 0xB5, 0x1E, 0xD0, 0x27, + 0xE2, 0x0B, 0x09, 0x1C, 0xEF, 0xF6, 0x32, 0x0D, 0x20, 0xEC, 0xB0, 0xFD, + 0x99, 0xED, 0x9C, 0xF0, 0x95, 0xF5, 0x9E, 0xE8, 0x07, 0xFA, 0x87, 0xE5, + 0xC3, 0xFB, 0x20, 0xEC, 0xC3, 0xFC, 0x09, 0xF9, 0xA2, 0x08, 0x48, 0x0A, + 0xEA, 0x1C, 0xAC, 0x1D, 0xBC, 0x20, 0x70, 0x1F, 0x81, 0x1B, 0x99, 0x1B, + 0x8B, 0x0E, 0x08, 0x16, 0xFB, 0xF8, 0xEB, 0x0A, 0x34, 0xE7, 0xB4, 0xFA, + 0xA2, 0xE0, 0x28, 0xEB, 0x7A, 0xE8, 0x22, 0xE1, 0xE2, 0xF3, 0xB7, 0xDD, + 0x99, 0xFD, 0x46, 0xE4, 0x68, 0x00, 0x6B, 0xF3, 0x6B, 0x06, 0x20, 0x07, + 0x67, 0x15, 0xA1, 0x19, 0x10, 0x16, 0xD8, 0x1B, 0x19, 0x16, 0x00, 0x19, + 0xAD, 0x13, 0x18, 0x16, 0x6F, 0x05, 0x4C, 0x0D, 0x25, 0xF1, 0x14, 0xFF, + 0x45, 0xE3, 0xAE, 0xF0, 0x0F, 0xE4, 0xD4, 0xE6, 0xEE, 0xF1, 0x89, 0xE4, + 0xDA, 0x01, 0x25, 0xEA, 0xAD, 0x0C, 0xC6, 0xFA, 0x77, 0x14, 0xB4, 0x13, + 0xD2, 0x12, 0x1D, 0x1E, 0x2D, 0x12, 0xA5, 0x21, 0x27, 0x15, 0xC2, 0x20, + 0x26, 0x17, 0xC2, 0x1B, 0x6D, 0x0E, 0x80, 0x10, 0x8E, 0xFB, 0xBF, 0x00, + 0x64, 0xE7, 0xA7, 0xEF, 0xCC, 0xDD, 0xA1, 0xE4, 0x98, 0xE4, 0x51, 0xDF, + 0xA5, 0xF7, 0x73, 0xE4, 0x71, 0x09, 0xBD, 0xF7, 0x22, 0x13, 0xED, 0x06, + 0xB1, 0x12, 0xF6, 0x13, 0x68, 0x0C, 0x0A, 0x1D, 0x8E, 0x08, 0x40, 0x1D, + 0x6F, 0x08, 0x22, 0x16, 0x85, 0x06, 0x33, 0x09, 0x29, 0xFD, 0xDA, 0xF8, + 0x84, 0xED, 0x40, 0xE8, 0xCA, 0xE0, 0x11, 0xDE, 0xD7, 0xE0, 0x1A, 0xDB, + 0x44, 0xF1, 0xDD, 0xE1, 0x0E, 0x0B, 0xD7, 0xF3, 0x27, 0x17, 0x9A, 0x03, + 0x51, 0x1A, 0x21, 0x13, 0x5E, 0x15, 0xBA, 0x1F, 0x01, 0x0C, 0xBB, 0x21, + 0xE3, 0x04, 0x77, 0x1A, 0x9F, 0x02, 0xAA, 0x0C, 0x43, 0xFF, 0x1D, 0xFC, + 0x31, 0xF8, 0xF5, 0xEB, 0x1C, 0xEC, 0x30, 0xE2, 0x7B, 0xE7, 0x97, 0xE1, + 0x34, 0xF6, 0x1C, 0xEA, 0x21, 0x03, 0xFC, 0xF8, 0x21, 0x13, 0x09, 0x08, + 0x6C, 0x21, 0x95, 0x16, 0x5A, 0x22, 0x17, 0x22, 0x38, 0x15, 0xED, 0x23, + 0xF8, 0x02, 0x86, 0x1A, 0x63, 0xF6, 0x2E, 0x0A, 0xCD, 0xF0, 0xFE, 0xF6, + 0xC4, 0xEE, 0xB7, 0xE5, 0x92, 0xE9, 0x4A, 0xDB, 0xE6, 0xE5, 0x35, 0xDA, + 0xB5, 0xEA, 0x8F, 0xE6, 0xAF, 0xF5, 0x2E, 0xF5, 0x77, 0x06, 0xC8, 0x01, + 0xB2, 0x19, 0x9C, 0x0E, 0x1C, 0x22, 0xD8, 0x19, 0x5D, 0x1A, 0x99, 0x1D, + 0xEC, 0x04, 0xF4, 0x15, 0xC3, 0xF0, 0xA2, 0x06, 0x24, 0xE6, 0x7C, 0xF4, + 0xB0, 0xE7, 0xC1, 0xE3, 0xE3, 0xEA, 0x40, 0xD9, 0x14, 0xEA, 0x74, 0xD9, + 0xF1, 0xF2, 0x61, 0xE7, 0xCF, 0xFA, 0x3B, 0xF8, 0x46, 0x04, 0x2D, 0x06, + 0x27, 0x14, 0x4A, 0x12, 0xF3, 0x21, 0x9E, 0x1C, 0x4D, 0x22, 0x3A, 0x20, + 0x31, 0x12, 0xA5, 0x19, 0x6C, 0xFA, 0xAE, 0x0A, 0xD8, 0xE9, 0xA9, 0xF9, + 0xB5, 0xE6, 0x15, 0xE9, 0xD6, 0xEA, 0x8F, 0xDA, 0x20, 0xF7, 0x3A, 0xE0, + 0x55, 0xFF, 0xD1, 0xEB, 0x2A, 0x01, 0x5D, 0xF9, 0x4A, 0x02, 0xB0, 0x06, + 0x3E, 0x0A, 0x5C, 0x12, 0x53, 0x16, 0x90, 0x1A, 0x29, 0x1C, 0xD9, 0x1C, + 0xDB, 0x13, 0xEC, 0x14, 0x65, 0xFE, 0xEB, 0x06, 0x5E, 0xE8, 0x66, 0xF5, + 0x3B, 0xDE, 0x08, 0xE0, 0xB0, 0xE2, 0x2E, 0xDE, 0x19, 0xEF, 0x4D, 0xE0, + 0x00, 0xFD, 0x8A, 0xE4, 0x40, 0x04, 0xD0, 0xEF, 0x50, 0x06, 0x70, 0x00, + 0x04, 0x07, 0x87, 0x0F, 0x86, 0x0C, 0x01, 0x1A, 0x08, 0x11, 0x41, 0x1C, + 0x31, 0x10, 0x6B, 0x16, 0xF1, 0x00, 0xF8, 0x06, 0x20, 0xE9, 0xAC, 0xF1, + 0xED, 0xDF, 0x73, 0xE8, 0xCD, 0xE0, 0xE5, 0xE4, 0x08, 0xE9, 0x9D, 0xE2, + 0xFF, 0xF8, 0x26, 0xE4, 0x0C, 0x08, 0x43, 0xEF, 0x06, 0x11, 0x3F, 0x02, + 0x2B, 0x11, 0xCB, 0x14, 0x38, 0x10, 0x24, 0x21, 0x2C, 0x0F, 0x2B, 0x24, + 0xCF, 0x0E, 0x71, 0x1C, 0xCA, 0x05, 0x2E, 0x0B, 0x32, 0xF1, 0xFE, 0xF5, + 0x24, 0xEA, 0x82, 0xEB, 0xDC, 0xE5, 0x82, 0xE7, 0xB6, 0xE4, 0xD5, 0xE4, + 0x47, 0xEF, 0x85, 0xE5, 0xBA, 0x01, 0x2D, 0xEE, 0xF0, 0x11, 0x63, 0xFF, + 0xBA, 0x17, 0x43, 0x12, 0x0C, 0x13, 0x81, 0x1E, 0xA6, 0x0B, 0x63, 0x21, + 0x3A, 0x05, 0x97, 0x18, 0x02, 0xFC, 0x2B, 0x04, 0xDC, 0xF6, 0x94, 0xF4, + 0x73, 0xF0, 0xA2, 0xE8, 0x5C, 0xE7, 0x3B, 0xE2, 0x94, 0xE0, 0x3C, 0xE1, + 0xA9, 0xE5, 0x7B, 0xE4, 0x21, 0xF8, 0x47, 0xEE, 0x1C, 0x0F, 0x6F, 0xFF, + 0x11, 0x1E, 0xC3, 0x12, 0x03, 0x1D, 0x3B, 0x20, 0xEC, 0x10, 0x03, 0x23, + 0xA3, 0x04, 0xBD, 0x18, 0x94, 0xF9, 0x08, 0x0A, 0x55, 0xF5, 0x9A, 0xF9, + 0x4F, 0xF5, 0xA2, 0xEA, 0x3E, 0xF2, 0x46, 0xE2, 0x8C, 0xEC, 0xD1, 0xE2, + 0x51, 0xEB, 0xAE, 0xE9, 0x93, 0xF6, 0x64, 0xF5, 0xAC, 0x0B, 0xE7, 0x06, + 0x39, 0x1F, 0x7E, 0x19, 0x58, 0x24, 0xBC, 0x25, 0xA3, 0x18, 0x0B, 0x27, + 0x87, 0x04, 0xB8, 0x1D, 0x5E, 0xF6, 0x17, 0x0D, 0x90, 0xEF, 0xE5, 0xFB, + 0x37, 0xF0, 0x73, 0xEB, 0xC5, 0xF2, 0xEC, 0xE0, 0x58, 0xF2, 0x57, 0xE0, + 0x46, 0xF0, 0x94, 0xE8, 0xD9, 0xF4, 0xBB, 0xF5, 0x13, 0x03, 0x16, 0x07, + 0x3E, 0x17, 0xFF, 0x17, 0x12, 0x22, 0x6F, 0x23, 0xBA, 0x18, 0xC0, 0x25, + 0x1E, 0x0A, 0x16, 0x18, 0x2B, 0xF8, 0xB1, 0x08, 0x30, 0xE9, 0xFF, 0xFA, + 0x22, 0xE6, 0x19, 0xED, 0x4D, 0xEC, 0xA4, 0xE1, 0xF2, 0xF4, 0x55, 0xDF, + 0x87, 0xF9, 0xDD, 0xE6, 0x55, 0xFD, 0xDE, 0xF5, 0x62, 0x05, 0xD7, 0x06, + 0xAF, 0x14, 0xF6, 0x18, 0xBC, 0x20, 0x33, 0x26, 0xFE, 0x1E, 0xEB, 0x21, + 0xF7, 0x12, 0x09, 0x16, 0x8D, 0x00, 0xD3, 0x09, 0x6D, 0xED, 0x91, 0xFE, + 0x2F, 0xE4, 0x96, 0xF2, 0xB4, 0xE7, 0x03, 0xE7, 0xBC, 0xF4, 0x52, 0xE2, + 0xB8, 0x00, 0x98, 0xE8, 0xC4, 0x08, 0x9B, 0xF7, 0xB3, 0x0C, 0xFE, 0x09, + 0x4D, 0x14, 0x4B, 0x1C, 0x32, 0x1F, 0x72, 0x28, 0xE9, 0x19, 0x5F, 0x22, + 0x0B, 0x11, 0x9F, 0x15, 0xDF, 0x04, 0xE3, 0x07, 0x49, 0xF3, 0x1D, 0xFC, + 0xF3, 0xE3, 0x48, 0xF1, 0x52, 0xE0, 0x47, 0xE7, 0xDD, 0xE9, 0x05, 0xE2, + 0x5A, 0xFB, 0x95, 0xE7, 0xBD, 0x08, 0xA2, 0xF5, 0x13, 0x10, 0x44, 0x09, + 0xF9, 0x16, 0xF8, 0x1F, 0x8C, 0x11, 0x11, 0x22, 0x41, 0x0D, 0x62, 0x1E, + 0xAD, 0x0C, 0xCD, 0x16, 0xD4, 0x08, 0xCA, 0x09, 0x75, 0xFC, 0xA0, 0xFB, + 0xAD, 0xEB, 0x08, 0xF0, 0x34, 0xE0, 0x39, 0xE6, 0xA2, 0xE2, 0x92, 0xE1, + 0x7A, 0xF2, 0x8A, 0xE4, 0xB9, 0x06, 0x63, 0xF3, 0xB2, 0x14, 0x46, 0x0B, + 0xF0, 0x17, 0xD5, 0x16, 0x00, 0x13, 0xF3, 0x1C, 0x57, 0x0C, 0xA7, 0x20, + 0x08, 0x09, 0xA2, 0x1C, 0xBB, 0x06, 0xF0, 0x0E, 0x08, 0x01, 0xC1, 0xFC, + 0x49, 0xF5, 0x4D, 0xEE, 0xFE, 0xE8, 0xB6, 0xE4, 0xEB, 0xE4, 0xD2, 0xE0, + 0x99, 0xEF, 0x16, 0xE5, 0x8D, 0x04, 0xF1, 0xF3, 0x37, 0x19, 0x02, 0x0A, + 0x90, 0x1D, 0x39, 0x15, 0x78, 0x18, 0x51, 0x1B, 0xFD, 0x0D, 0xA9, 0x1F, + 0xB3, 0x03, 0xB7, 0x1C, 0x82, 0xFD, 0x5B, 0x0F, 0xE0, 0xFA, 0xA6, 0xFB, + 0xF9, 0xF5, 0xF5, 0xEA, 0x15, 0xEF, 0xE4, 0xE1, 0xD8, 0xE7, 0x73, 0xDF, + 0x1B, 0xED, 0xD3, 0xE5, 0xC4, 0x03, 0xD1, 0xF7, 0x6F, 0x0F, 0x74, 0x06, + 0x4E, 0x19, 0xF0, 0x12, 0x44, 0x1E, 0x9E, 0x1B, 0xD0, 0x16, 0x64, 0x1F, + 0xED, 0x06, 0x23, 0x1C, 0x56, 0xF8, 0x28, 0x0F, 0x01, 0xF1, 0xEA, 0xFA, + 0x0A, 0xF0, 0x01, 0xE8, 0xED, 0xED, 0x08, 0xDD, 0x6A, 0xEB, 0xFF, 0xDB, + 0x25, 0xF0, 0xE8, 0xE4, 0x74, 0xF8, 0xFE, 0xF3, 0xFD, 0x05, 0xF4, 0x04, + 0xFF, 0x16, 0x1C, 0x14, 0x1C, 0x23, 0x45, 0x1D, 0x9E, 0x20, 0xFF, 0x1E, + 0x79, 0x0F, 0x4B, 0x1A, 0xDA, 0xF9, 0x8D, 0x0E, 0xA0, 0xEA, 0x6D, 0xFB, + 0xAE, 0xE7, 0x0B, 0xE8, 0xE9, 0xEA, 0xCE, 0xDB, 0x3C, 0xEC, 0x9B, 0xD9, + 0xC8, 0xF4, 0x57, 0xE5, 0x19, 0xFC, 0x25, 0xF5, 0x5E, 0x02, 0x1E, 0x05, + 0xF5, 0x0D, 0x9A, 0x14, 0xCA, 0x1A, 0xCB, 0x1D, 0x74, 0x1F, 0x0A, 0x1E, + 0x5A, 0x14, 0x62, 0x17, 0x54, 0xFF, 0xE2, 0x0B, 0xE8, 0xEA, 0xEC, 0xFA, + 0xE1, 0xE2, 0xBC, 0xE8, 0xE8, 0xE6, 0x6A, 0xDC, 0xA9, 0xEF, 0xBC, 0xD9, + 0x27, 0xFB, 0x34, 0xE6, 0x7C, 0x02, 0x76, 0xF5, 0xA0, 0x04, 0x1D, 0x04, + 0x83, 0x09, 0x48, 0x13, 0x1D, 0x12, 0x6A, 0x1D, 0xFC, 0x18, 0x36, 0x1D, + 0xD3, 0x14, 0x6B, 0x14, 0x73, 0x04, 0x01, 0x07, 0xC1, 0xEE, 0xF1, 0xF7, + 0xCC, 0xE0, 0x30, 0xE7, 0x66, 0xE1, 0xC7, 0xD7, 0x70, 0xEC, 0xF0, 0xDC, + 0x17, 0xFB, 0xE3, 0xE7, 0xD1, 0x06, 0xEA, 0xF2, 0x29, 0x0B, 0x98, 0xFF, + 0x6E, 0x0C, 0xFF, 0x0F, 0x27, 0x0E, 0x20, 0x1D, 0xD1, 0x11, 0x36, 0x20, + 0x21, 0x10, 0x1F, 0x16, 0x32, 0x06, 0x34, 0x08, 0x30, 0xF3, 0x8D, 0xF7, + 0x2C, 0xE1, 0xC2, 0xE3, 0x9B, 0xDE, 0x44, 0xE0, 0xC7, 0xE6, 0xC3, 0xE2, + 0x19, 0xF5, 0x13, 0xE8, 0x82, 0x05, 0x0D, 0xF1, 0x4D, 0x10, 0xE1, 0xFD, + 0xEC, 0x12, 0xDA, 0x0E, 0x8F, 0x0F, 0x05, 0x1E, 0x0D, 0x0C, 0x71, 0x23, + 0x0B, 0x08, 0x65, 0x1A, 0xAC, 0x02, 0xDB, 0x09, 0x21, 0xF6, 0x96, 0xF7, + 0x97, 0xE3, 0x4B, 0xE5, 0xA0, 0xE2, 0x69, 0xE2, 0x50, 0xE6, 0x1E, 0xE4, + 0x4D, 0xEE, 0xA5, 0xE7, 0x5C, 0xFE, 0xA5, 0xF0, 0x3E, 0x0F, 0x00, 0xFD, + 0xDC, 0x17, 0xD9, 0x0B, 0x8F, 0x15, 0x30, 0x1A, 0xFA, 0x0B, 0x6E, 0x20, + 0x5D, 0x04, 0xDF, 0x19, 0xC5, 0xFD, 0x63, 0x08, 0xD5, 0xF1, 0xD3, 0xF0, + 0x3B, 0xF0, 0x2B, 0xE7, 0x46, 0xED, 0xE4, 0xE2, 0xCE, 0xE7, 0x90, 0xE0, + 0xF8, 0xE7, 0xDC, 0xE3, 0xC9, 0xF4, 0x96, 0xEF, 0x1C, 0x0A, 0xD5, 0xFE, + 0x86, 0x1B, 0x85, 0x0E, 0x81, 0x1F, 0xA0, 0x1B, 0xEA, 0x15, 0x51, 0x23, + 0xF7, 0x06, 0xB2, 0x1D, 0x86, 0xFA, 0x85, 0x09, 0xC2, 0xF3, 0x7E, 0xF8, + 0x0F, 0xF2, 0x2A, 0xEC, 0xEC, 0xF1, 0x41, 0xE4, 0x92, 0xEE, 0x0E, 0xE1, + 0x4D, 0xEC, 0x76, 0xE5, 0x83, 0xF2, 0x04, 0xF3, 0x21, 0x04, 0xC0, 0x04, + 0xD3, 0x17, 0xE0, 0x14, 0xF8, 0x21, 0xC2, 0x1F, 0xF5, 0x1A, 0xF8, 0x24, + 0x47, 0x09, 0x05, 0x1F, 0xBC, 0xF6, 0x40, 0x0C, 0x46, 0xED, 0x07, 0xFB, + 0x1B, 0xEC, 0x18, 0xED, 0x23, 0xF0, 0x42, 0xE3, 0xDC, 0xF2, 0x64, 0xDF, + 0x80, 0xF2, 0x9C, 0xE2, 0x02, 0xF4, 0x03, 0xF0, 0x6C, 0xFE, 0x86, 0x03, + 0x7D, 0x0F, 0x04, 0x15, 0xBA, 0x1D, 0x30, 0x1F, 0xB7, 0x1C, 0x6E, 0x21, + 0xF3, 0x09, 0x0D, 0x1A, 0x8B, 0xFA, 0x0B, 0x0B, 0x87, 0xED, 0x49, 0xFA, + 0x6C, 0xE6, 0x90, 0xEB, 0x9D, 0xE9, 0x57, 0xE2, 0x41, 0xF2, 0xFF, 0xDE, + 0x7C, 0xF9, 0x0D, 0xE3, 0x87, 0xFD, 0x93, 0xF0, 0xA1, 0x03, 0x5C, 0x06, + 0xE5, 0x0F, 0x3E, 0x1A, 0x4E, 0x1C, 0x18, 0x25, 0xA9, 0x1C, 0x78, 0x26, + 0x6B, 0x14, 0x82, 0x1A, 0xB8, 0x04, 0x40, 0x0C, 0x1D, 0xF2, 0x67, 0xFE, + 0x27, 0xE4, 0xFA, 0xF0, 0x14, 0xE3, 0x11, 0xE8, 0xF0, 0xED, 0xAD, 0xE4, + 0xE7, 0xFC, 0x38, 0xE8, 0xA7, 0x07, 0x8F, 0xF3, 0xC7, 0x0D, 0xD2, 0x07, + 0xEF, 0x12, 0x66, 0x1C, 0x1E, 0x19, 0x97, 0x27, 0xA5, 0x1C, 0x26, 0x27, + 0x1F, 0x13, 0x08, 0x19, 0x02, 0x06, 0x0D, 0x09, 0x7E, 0xF6, 0x3F, 0xFB, + 0x12, 0xE7, 0x2A, 0xEE, 0x62, 0xDF, 0x25, 0xE5, 0x9C, 0xE5, 0x99, 0xE2, + 0xE2, 0xF5, 0x72, 0xE6, 0x4F, 0x07, 0xA5, 0xF0, 0x86, 0x10, 0x8E, 0x02, + 0x1A, 0x14, 0x59, 0x17, 0x86, 0x18, 0xAA, 0x27, 0xC1, 0x10, 0x30, 0x22, + 0xEF, 0x09, 0x29, 0x15, 0x81, 0x05, 0x0E, 0x08, 0x9A, 0xFD, 0x5B, 0xFB, + 0xC2, 0xF0, 0x2F, 0xEE, 0x80, 0xE4, 0x4B, 0xE5, 0xAC, 0xE2, 0xA0, 0xE3, + 0x51, 0xEF, 0xF5, 0xE9, 0x8B, 0x03, 0x63, 0xF4, 0x09, 0x14, 0x80, 0x05, + 0xFF, 0x1B, 0x9D, 0x1E, 0x76, 0x17, 0x20, 0x24, 0x40, 0x0F, 0xC1, 0x22, + 0xE3, 0x07, 0x55, 0x1C, 0xC4, 0x03, 0xD5, 0x10, 0xB6, 0xFF, 0xB8, 0x01, + 0xA6, 0xF8, 0x95, 0xF2, 0x7D, 0xED, 0x92, 0xE6, 0x55, 0xE7, 0x45, 0xE4, + 0x42, 0xEC, 0x85, 0xE9, 0x7C, 0xFF, 0x32, 0xF6, 0xF6, 0x14, 0xE0, 0x0A, + 0x6E, 0x1D, 0xD0, 0x14, 0x14, 0x1B, 0xCC, 0x1B, 0xEE, 0x11, 0x84, 0x20, + 0x7B, 0x05, 0x33, 0x1D, 0x1D, 0xFC, 0xA3, 0x10, 0xBC, 0xF7, 0x38, 0xFF, + 0x18, 0xF6, 0xA7, 0xED, 0x3B, 0xF1, 0xF1, 0xDE, 0x5D, 0xEB, 0x70, 0xDA, + 0x3A, 0xEB, 0x5D, 0xE1, 0x3F, 0xF9, 0x3E, 0xF1, 0xD0, 0x11, 0xE7, 0x05, + 0x57, 0x1A, 0xC0, 0x10, 0x1B, 0x1C, 0xD4, 0x17, 0xB5, 0x17, 0xDE, 0x1D, + 0x0A, 0x0B, 0x12, 0x1C, 0xBB, 0xFB, 0x06, 0x11, 0x84, 0xF2, 0xDD, 0x00, + 0xFF, 0xF0, 0x33, 0xF0, 0x36, 0xF3, 0x6B, 0xE2, 0x46, 0xF1, 0xBC, 0xDC, + 0xAF, 0xF1, 0xD2, 0xE4, 0x2E, 0xFF, 0x2D, 0xF9, 0x13, 0x08, 0x50, 0x0A, + 0xC9, 0x13, 0xE5, 0x16, 0x71, 0x1F, 0x62, 0x1F, 0xFA, 0x21, 0xB3, 0x23, + 0x8A, 0x16, 0xD4, 0x1F, 0x92, 0x01, 0x5E, 0x13, 0x29, 0xEF, 0xDF, 0x01, + 0x85, 0xE7, 0x04, 0xF1, 0x1E, 0xEB, 0x08, 0xE3, 0x47, 0xF0, 0x19, 0xDC, + 0x7B, 0xF4, 0xD1, 0xE3, 0xD5, 0xFA, 0x11, 0xF3, 0x64, 0x02, 0x82, 0x04, + 0x8A, 0x0B, 0x75, 0x13, 0xAB, 0x16, 0x0F, 0x1C, 0x63, 0x1C, 0x43, 0x1E, + 0x95, 0x16, 0x37, 0x18, 0x12, 0x04, 0x44, 0x0A, 0x0D, 0xEE, 0xE9, 0xF7, + 0x2A, 0xE0, 0x11, 0xE8, 0x0E, 0xE2, 0x07, 0xDC, 0xE8, 0xEB, 0xFD, 0xD6, + 0xCB, 0xF5, 0x62, 0xDD, 0x0B, 0x00, 0x29, 0xED, 0x56, 0x06, 0x76, 0x00, + 0x02, 0x0B, 0xB1, 0x12, 0xA9, 0x11, 0xAB, 0x1D, 0x58, 0x17, 0xA1, 0x20, + 0xE9, 0x16, 0x3E, 0x1A, 0x45, 0x0B, 0x1F, 0x0C, 0x01, 0xF7, 0x28, 0xF9, + 0x32, 0xE5, 0x3F, 0xEA, 0xFD, 0xE0, 0xDC, 0xE0, 0x3B, 0xEB, 0x6F, 0xDB, + 0x7B, 0xFA, 0x3E, 0xE7, 0x50, 0x07, 0xA2, 0xF5, 0xC4, 0x0E, 0x19, 0x05, + 0x14, 0x11, 0x57, 0x15, 0x61, 0x11, 0xF0, 0x20, 0x24, 0x11, 0x41, 0x23, + 0xF7, 0x0F, 0xBA, 0x1C, 0x86, 0x09, 0x26, 0x0D, 0xD6, 0xFA, 0x09, 0xFA, + 0x20, 0xE8, 0x34, 0xE8, 0x18, 0xDF, 0xBB, 0xDA, 0xEC, 0xE2, 0x4A, 0xDF, + 0x73, 0xF0, 0xD5, 0xE7, 0x3C, 0x01, 0x73, 0xEF, 0x7B, 0x0E, 0xA7, 0xFA, + 0x7D, 0x13, 0x2C, 0x0A, 0xCE, 0x10, 0x81, 0x17, 0xDB, 0x09, 0x10, 0x1C, + 0xCB, 0x03, 0x5C, 0x17, 0xEE, 0xFE, 0x9A, 0x09, 0x53, 0xF7, 0x0F, 0xF6, + 0xEC, 0xE9, 0x38, 0xE3, 0x9A, 0xDC, 0x51, 0xD7, 0x24, 0xE1, 0x1E, 0xDD, + 0x9D, 0xEC, 0xE1, 0xE7, 0xCE, 0xFC, 0xA9, 0xF1, 0xC3, 0x0D, 0x99, 0xFD, + 0x96, 0x19, 0xF8, 0x0C, 0x20, 0x1A, 0x96, 0x1A, 0x50, 0x11, 0x4C, 0x20, + 0x3C, 0x04, 0xBB, 0x1B, 0x22, 0xFD, 0xAC, 0x0F, 0x0A, 0xF8, 0x9E, 0xFC, + 0xCE, 0xEB, 0x35, 0xE5, 0xBE, 0xED, 0xDD, 0xE1, 0x2C, 0xEE, 0xA8, 0xE5, + 0x11, 0xEE, 0x94, 0xEC, 0x25, 0xF6, 0x98, 0xF5, 0x73, 0x06, 0x6D, 0x01, + 0xC3, 0x17, 0xAC, 0x0F, 0xD7, 0x1F, 0xB0, 0x1C, 0x68, 0x19, 0x89, 0x20, + 0xFB, 0x08, 0xCF, 0x1B, 0x9C, 0xF9, 0xB3, 0x0D, 0x18, 0xF0, 0x6C, 0xF6, + 0x4E, 0xEF, 0xC4, 0xE9, 0x47, 0xF0, 0x25, 0xE1, 0x9B, 0xEE, 0x32, 0xDC, + 0x48, 0xEB, 0xF8, 0xDF, 0x8D, 0xEE, 0xE1, 0xEA, 0x1E, 0xFB, 0x7D, 0xFA, + 0xE1, 0x0D, 0x5C, 0x0B, 0xF2, 0x1B, 0x95, 0x19, 0xAF, 0x1C, 0x72, 0x1E, + 0x83, 0x0C, 0xBD, 0x18, 0xA2, 0xF8, 0xE2, 0x0A, 0xEB, 0xEB, 0x9D, 0xF6, + 0x90, 0xE9, 0xD0, 0xEB, 0xC1, 0xEE, 0x54, 0xE4, 0x03, 0xF4, 0xE2, 0xDE, + 0x84, 0xF5, 0x95, 0xE2, 0x7B, 0xF7, 0x6F, 0xEF, 0x8F, 0xFE, 0xE4, 0x01, + 0x4C, 0x0C, 0x82, 0x14, 0x7A, 0x1A, 0x17, 0x23, 0x39, 0x20, 0x07, 0x28, + 0x1D, 0x15, 0x4F, 0x20, 0x08, 0xFD, 0xB0, 0x0E, 0xAD, 0xEF, 0xFB, 0xFF, + 0x02, 0xEA, 0x80, 0xF4, 0x00, 0xEC, 0xC4, 0xEA, 0x6D, 0xF3, 0xAB, 0xE3, + 0xA0, 0xFA, 0xF7, 0xE4, 0x2A, 0xFF, 0xB6, 0xF0, 0xC9, 0x03, 0xC2, 0x02, + 0xAC, 0x09, 0xA0, 0x14, 0xE6, 0x13, 0x53, 0x22, 0xDB, 0x19, 0x71, 0x25, + 0x6E, 0x10, 0xDA, 0x1B, 0x53, 0x04, 0x15, 0x0A, 0xA3, 0xF3, 0xFA, 0xF7, + 0xA6, 0xE3, 0xFC, 0xEA, 0x42, 0xDE, 0x57, 0xE2, 0x94, 0xE5, 0x36, 0xDD, + 0xD1, 0xF3, 0x23, 0xDF, 0x0B, 0x01, 0xBE, 0xEA, 0xBF, 0x0A, 0xB4, 0xFD, + 0xEC, 0x0E, 0xF8, 0x10, 0x63, 0x13, 0xED, 0x1F, 0xD5, 0x17, 0x66, 0x25, + 0xA5, 0x12, 0xCC, 0x1B, 0x92, 0x09, 0x9E, 0x0B, 0x32, 0xFD, 0xBE, 0xFA, + 0xFA, 0xEC, 0x0D, 0xEE, 0x63, 0xE3, 0x45, 0xE7, 0x4B, 0xE5, 0x2B, 0xE5, + 0x88, 0xF3, 0xF8, 0xE8, 0xA6, 0x05, 0x15, 0xF5, 0x34, 0x15, 0xE9, 0x07, + 0xB0, 0x1A, 0xFD, 0x1A, 0x7D, 0x19, 0xA7, 0x28, 0xD0, 0x17, 0xA2, 0x2D, + 0xD0, 0x0E, 0x9E, 0x22, 0xCE, 0x07, 0x32, 0x12, 0xA6, 0x01, 0xA2, 0x00, + 0x1B, 0xF6, 0x50, 0xF1, 0xE5, 0xE9, 0x6D, 0xE8, 0xD0, 0xE4, 0xE1, 0xE5, + 0xD7, 0xEB, 0x97, 0xE8, 0x03, 0xFD, 0xA8, 0xF3, 0xCA, 0x0F, 0xD5, 0x03, + 0x52, 0x1A, 0x44, 0x15, 0x41, 0x19, 0x3E, 0x25, 0x0D, 0x0E, 0x79, 0x1F, + 0x67, 0x02, 0xE5, 0x14, 0x35, 0xFC, 0x4D, 0x0A, 0x93, 0xFA, 0xD8, 0xFB, + 0xD5, 0xF5, 0x9F, 0xEB, 0x7A, 0xED, 0xE6, 0xE0, 0x3D, 0xE6, 0x47, 0xDD, + 0xF5, 0xE7, 0x45, 0xE2, 0x58, 0xF5, 0xA1, 0xED, 0x6C, 0x0B, 0x2B, 0x01, + 0x7F, 0x1C, 0xB0, 0x18, 0x82, 0x1F, 0x20, 0x1F, 0xD3, 0x16, 0xB2, 0x1D, + 0xC2, 0x07, 0x13, 0x1A, 0xD1, 0xFB, 0x1E, 0x13, 0x16, 0xF8, 0x4A, 0x06, + 0x2E, 0xF8, 0xA6, 0xF5, 0x45, 0xF7, 0xC7, 0xE8, 0x22, 0xF4, 0x8B, 0xE4, + 0xD8, 0xF3, 0xC9, 0xE9, 0x13, 0xFB, 0x56, 0xF6, 0x69, 0x0C, 0xF3, 0x09, + 0xBF, 0x21, 0x66, 0x1F, 0x57, 0x24, 0xE1, 0x24, 0x87, 0x1D, 0xBE, 0x22, + 0xE6, 0x0E, 0x2E, 0x1D, 0x80, 0xFD, 0xE6, 0x13, 0xF6, 0xF1, 0x06, 0x06, + 0x10, 0xF0, 0xD4, 0xF4, 0xC5, 0xF1, 0xC1, 0xE5, 0x91, 0xF4, 0xD2, 0xDF, + 0xBB, 0xF3, 0x4E, 0xE2, 0x02, 0xF7, 0x67, 0xEE, 0x43, 0x08, 0xBF, 0x05, + 0x2E, 0x0D, 0x1F, 0x10, 0xD0, 0x13, 0x3F, 0x17, 0xFC, 0x19, 0xA8, 0x1A, + 0xE4, 0x13, 0x50, 0x16, 0xCE, 0x01, 0x24, 0x0C, 0xCB, 0xEE, 0x04, 0xFE, + 0x70, 0xE5, 0xB5, 0xED, 0xB8, 0xE6, 0x04, 0xE0, 0xC1, 0xED, 0xA9, 0xD9, + 0x19, 0xF5, 0x2F, 0xDF, 0xCD, 0xFD, 0x55, 0xF1, 0xED, 0x03, 0xB5, 0x01, + 0x55, 0x0A, 0x25, 0x11, 0xAD, 0x13, 0x2C, 0x1F, 0xEC, 0x1D, 0xF6, 0x25, + 0x90, 0x1D, 0x5A, 0x21, 0x52, 0x0F, 0x55, 0x14, 0x73, 0xF9, 0x48, 0x04, + 0x74, 0xE9, 0x0E, 0xF4, 0x2A, 0xE5, 0x69, 0xE6, 0x67, 0xED, 0xA2, 0xE0, + 0x0A, 0xFA, 0x1C, 0xE6, 0xC6, 0x04, 0x08, 0xF6, 0xAC, 0x0C, 0x95, 0x06, + 0xDB, 0x0E, 0x97, 0x14, 0x6A, 0x10, 0x89, 0x20, 0xC6, 0x14, 0x5E, 0x25, + 0xA1, 0x16, 0x5B, 0x1F, 0x83, 0x0E, 0x81, 0x0F, 0x75, 0xFC, 0xCF, 0xFC, + 0x98, 0xE9, 0x39, 0xEB, 0xE7, 0xDE, 0x12, 0xDD, 0x46, 0xE2, 0xCF, 0xD6, + 0x1F, 0xF2, 0x40, 0xDC, 0xE3, 0xFF, 0xDB, 0xEA, 0xE2, 0x09, 0x19, 0xFB, + 0xCC, 0x0D, 0x78, 0x09, 0xC8, 0x0B, 0x72, 0x15, 0x77, 0x0A, 0x85, 0x1C, + 0x3E, 0x0B, 0xDF, 0x18, 0x63, 0x08, 0x41, 0x0B, 0x60, 0xFE, 0xA4, 0xF8, + 0xCC, 0xEE, 0xB0, 0xE8, 0xB8, 0xE2, 0x04, 0xDD, 0x8A, 0xE4, 0x6A, 0xD8, + 0x10, 0xEE, 0xA5, 0xE2, 0xCA, 0xFE, 0x64, 0xF3, 0xB1, 0x11, 0x26, 0x04, + 0xB1, 0x1C, 0xF3, 0x12, 0xB9, 0x1A, 0x2E, 0x1E, 0xE6, 0x11, 0x99, 0x24, + 0xB2, 0x09, 0x7E, 0x21, 0xF2, 0x03, 0xE5, 0x13, 0x43, 0xFD, 0x48, 0x00, + 0x75, 0xF3, 0x1C, 0xEF, 0x49, 0xE9, 0xFA, 0xE2, 0xAD, 0xE3, 0x8E, 0xDD, + 0x0A, 0xEC, 0x12, 0xE8, 0xB4, 0xF9, 0x62, 0xF6, 0x64, 0x0B, 0x2C, 0x04, + 0x40, 0x1A, 0xC2, 0x10, 0x1B, 0x1D, 0x30, 0x19, 0x35, 0x12, 0xAB, 0x1C, + 0x55, 0x03, 0x59, 0x18, 0xE8, 0xF6, 0xFC, 0x09, 0x0C, 0xF1, 0x78, 0xF6, + 0xFE, 0xEB, 0xA3, 0xE3, 0x2A, 0xE2, 0x12, 0xD3, 0x59, 0xE6, 0xD9, 0xD6, + 0x99, 0xEA, 0x4E, 0xDF, 0xAA, 0xEE, 0x16, 0xE9, 0x9A, 0xFB, 0x91, 0xF7, + 0x15, 0x0F, 0x1C, 0x08, 0x26, 0x1C, 0x97, 0x14, 0xF7, 0x19, 0xCF, 0x1A, + 0x24, 0x0B, 0x4A, 0x18, 0x61, 0xFB, 0x14, 0x0E, 0x9A, 0xF1, 0x3E, 0xFC, + 0xFF, 0xEB, 0xBE, 0xE5, 0x9F, 0xF0, 0x60, 0xE2, 0xF8, 0xF5, 0x49, 0xE5, + 0x75, 0xF7, 0x53, 0xE9, 0xA7, 0xF6, 0x0E, 0xF1, 0x40, 0xFD, 0x56, 0x00, + 0x22, 0x0D, 0x3F, 0x12, 0x32, 0x1E, 0xAA, 0x20, 0x43, 0x22, 0x1A, 0x25, + 0xBB, 0x16, 0x58, 0x22, 0x50, 0x02, 0x6F, 0x15, 0x65, 0xF1, 0x69, 0xFE, + 0xFB, 0xEA, 0x08, 0xF1, 0x0C, 0xED, 0xB9, 0xE8, 0x4C, 0xF4, 0x25, 0xE4, + 0x8E, 0xF9, 0x6E, 0xE4, 0x0C, 0xFA, 0xC8, 0xEA, 0x68, 0xFA, 0xE9, 0xF8, + 0xD6, 0x01, 0x81, 0x0A, 0x00, 0x0F, 0xFD, 0x18, 0xA7, 0x16, 0x09, 0x1D, + 0xDE, 0x10, 0xB4, 0x17, 0x6F, 0xFE, 0x45, 0x09, 0x30, 0xE8, 0xB2, 0xF3, + 0x86, 0xE0, 0x37, 0xE6, 0x54, 0xE1, 0xA8, 0xDD, 0xDB, 0xE8, 0xBC, 0xD9, + 0xC8, 0xF4, 0xE3, 0xDC, 0xF9, 0xFD, 0xAD, 0xE6, 0x59, 0x01, 0x06, 0xF7, + 0x91, 0x05, 0xA8, 0x0B, 0x58, 0x0D, 0xE3, 0x1C, 0x06, 0x17, 0x46, 0x24, + 0x4C, 0x16, 0x07, 0x1F, 0x0B, 0x05, 0x9E, 0x0E, 0x61, 0xFA, 0x73, 0x00, + 0xF9, 0xEF, 0xE9, 0xF3, 0xFD, 0xE6, 0x64, 0xE9, 0xE4, 0xE7, 0x6F, 0xE4, + 0xA4, 0xF4, 0xFC, 0xE7, 0x97, 0x05, 0xCE, 0xF2, 0x52, 0x10, 0xED, 0x02, + 0xD3, 0x13, 0x4E, 0x16, 0xF9, 0x14, 0x74, 0x26, 0x05, 0x17, 0xBC, 0x2B, + 0xDA, 0x13, 0xB0, 0x23, 0x12, 0x0C, 0x07, 0x13, 0xBF, 0x00, 0xA0, 0x01, + 0x39, 0xF3, 0x59, 0xF2, 0x97, 0xE5, 0xA6, 0xE5, 0xC3, 0xDF, 0xD7, 0xDE, + 0x56, 0xE7, 0xDB, 0xE0, 0x76, 0xFA, 0x25, 0xEB, 0x09, 0x0C, 0x8A, 0xFA, + 0x20, 0x14, 0x07, 0x0C, 0x29, 0x12, 0xDB, 0x1A, 0x64, 0x0D, 0x3C, 0x20, + 0x62, 0x09, 0x0F, 0x19, 0x2F, 0x00, 0x0A, 0x08, 0xDD, 0xF8, 0x55, 0xF7, + 0x0D, 0xF3, 0x5E, 0xEA, 0xF3, 0xEA, 0x23, 0xE1, 0x56, 0xE3, 0x10, 0xDD, + 0xB7, 0xE5, 0xE8, 0xE1, 0x12, 0xF6, 0x9A, 0xEF, 0x67, 0x0D, 0x4C, 0x02, + 0x29, 0x1D, 0x5E, 0x15, 0x23, 0x1F, 0x28, 0x25, 0xDD, 0x17, 0xB2, 0x2C, + 0xE7, 0x0B, 0x14, 0x23, 0x50, 0x02, 0x10, 0x14, 0x1B, 0xFD, 0xB3, 0x04, + 0xB5, 0xFB, 0xD9, 0xF7, 0xBE, 0xF8, 0xA7, 0xED, 0x29, 0xF2, 0x91, 0xE8, + 0x0A, 0xEE, 0x19, 0xEB, 0xA4, 0xF5, 0xA6, 0xF7, 0x45, 0x09, 0x00, 0x08, + 0x2D, 0x1C, 0xAB, 0x19, 0xAE, 0x21, 0x8F, 0x29, 0x1E, 0x1B, 0x42, 0x27, + 0x84, 0x0C, 0x5E, 0x1D, 0x4D, 0xFC, 0x3F, 0x10, 0x62, 0xF1, 0xF1, 0xFF, + 0x23, 0xEF, 0x1F, 0xF1, 0xD7, 0xF1, 0xA2, 0xE4, 0xEE, 0xF1, 0xCF, 0xDD, + 0xB7, 0xEE, 0x3E, 0xDE, 0x31, 0xF0, 0x5E, 0xE9, 0x95, 0xFD, 0xAF, 0xFA, + 0xD7, 0x10, 0x61, 0x0D, 0x3E, 0x1E, 0xC3, 0x1D, 0x99, 0x19, 0xF7, 0x1A, + 0x28, 0x0D, 0x75, 0x13, 0x5D, 0xFD, 0xB5, 0x0A, 0x64, 0xEF, 0x2D, 0xFE, + 0xE7, 0xE9, 0x26, 0xF1, 0x6F, 0xEF, 0x83, 0xE7, 0xAF, 0xF7, 0x24, 0xE3, + 0xA7, 0xFC, 0x44, 0xE6, 0x98, 0xFD, 0x6B, 0xF2, 0xDC, 0x05, 0xA6, 0x06, + 0x79, 0x19, 0xC4, 0x1E, 0x89, 0x1D, 0x0A, 0x25, 0xA5, 0x1D, 0xB7, 0x24, + 0x3C, 0x1A, 0xAF, 0x21, 0x0A, 0x0E, 0xDC, 0x19, 0xA1, 0xFB, 0x10, 0x0B, + 0xCF, 0xEC, 0x72, 0xFA, 0x11, 0xEA, 0xC5, 0xEC, 0x45, 0xF3, 0xB8, 0xE6, + 0x2A, 0xFC, 0xF4, 0xE6, 0x5C, 0x01, 0x4E, 0xF2, 0xAC, 0x09, 0x05, 0x08, + 0x0F, 0x0B, 0xD2, 0x14, 0x25, 0x0E, 0x95, 0x1B, 0x81, 0x13, 0x78, 0x1D, + 0x45, 0x15, 0xFA, 0x19, 0x95, 0x0D, 0x1C, 0x10, 0xEA, 0xFB, 0x55, 0xFF, + 0x40, 0xE7, 0xBF, 0xEC, 0xF6, 0xDB, 0x9B, 0xDD, 0x84, 0xE0, 0x32, 0xD7, + 0x4E, 0xEF, 0x29, 0xD9, 0xBD, 0xFC, 0xAF, 0xE5, 0x1C, 0x05, 0x8D, 0xFC, + 0xB2, 0x08, 0xBF, 0x0A, 0xA0, 0x0A, 0xDF, 0x14, 0xD9, 0x0D, 0x60, 0x1B, + 0x60, 0x10, 0x42, 0x1A, 0x41, 0x0F, 0x32, 0x12, 0xE2, 0x05, 0x2F, 0x04, + 0x8C, 0xF5, 0x69, 0xF3, 0xB0, 0xE6, 0x5A, 0xE6, 0x75, 0xE5, 0xD8, 0xE0, + 0xBE, 0xF3, 0xD7, 0xE5, 0x32, 0x07, 0x93, 0xF5, 0x31, 0x13, 0xE9, 0x05, + 0xFB, 0x17, 0xF8, 0x15, 0xD9, 0x16, 0x45, 0x23, 0x0C, 0x13, 0x2B, 0x29, + 0x49, 0x0E, 0x52, 0x24, 0x3A, 0x0B, 0xEB, 0x17, 0x48, 0x06, 0xAE, 0x06, + 0xFC, 0xFB, 0xCA, 0xF3, 0xD5, 0xEB, 0x6E, 0xE4, 0xF0, 0xE3, 0xBD, 0xDD, + 0x86, 0xEE, 0x1B, 0xE1, 0xB4, 0xFA, 0x9F, 0xEE, 0xC6, 0x08, 0x21, 0xFD, + 0x32, 0x14, 0xA4, 0x0A, 0x96, 0x16, 0xA3, 0x16, 0xD2, 0x0F, 0xD1, 0x1B, + 0x52, 0x03, 0xA7, 0x16, 0xDB, 0xF9, 0x96, 0x09, 0xD5, 0xF4, 0xCF, 0xF7, + 0x15, 0xF1, 0x79, 0xE6, 0xCC, 0xE7, 0xF0, 0xD7, 0xAD, 0xE0, 0x8A, 0xD1, + 0xB0, 0xE3, 0xE3, 0xDA, 0x11, 0xF0, 0x3C, 0xEA, 0x2E, 0x02, 0x0E, 0xFA, + 0x7C, 0x14, 0xBE, 0x09, 0x32, 0x1E, 0x3E, 0x18, 0x95, 0x1B, 0xB2, 0x20, + 0x4B, 0x0D, 0xAE, 0x1E, 0x32, 0xFD, 0xED, 0x12, 0xA2, 0xF3, 0x50, 0x02, + 0xCB, 0xF3, 0xE8, 0xF1, 0x7E, 0xF2, 0xAD, 0xE4, 0x97, 0xEB, 0x2E, 0xDE, + 0x8B, 0xF1, 0x43, 0xE9, 0x69, 0xF9, 0x75, 0xF8, 0xA2, 0x03, 0x28, 0x06, + 0x0B, 0x12, 0xAE, 0x12, 0x43, 0x1E, 0xB7, 0x1D, 0x94, 0x20, 0xA9, 0x23, + 0x20, 0x15, 0x3C, 0x20, 0xB2, 0xFF, 0x34, 0x12, 0xA0, 0xEF, 0xFD, 0xFF, + 0x76, 0xEA, 0xF4, 0xEC, 0x4A, 0xE9, 0x85, 0xDA, 0xE1, 0xF0, 0xD2, 0xDB, + 0x3E, 0xF4, 0xF6, 0xE1, 0x62, 0xF3, 0x72, 0xEA, 0xD4, 0xF5, 0xE7, 0xF5, + 0xA0, 0xFF, 0x3B, 0x03, 0x5F, 0x0D, 0x14, 0x0F, 0xB7, 0x16, 0xB7, 0x16, + 0xA3, 0x13, 0x93, 0x14, 0x1C, 0x02, 0xC4, 0x09, 0x1E, 0xED, 0x99, 0xF7, + 0x16, 0xE3, 0x19, 0xE2, 0x92, 0xE4, 0x0D, 0xDC, 0xAD, 0xEE, 0x40, 0xDD, + 0x12, 0xF9, 0x33, 0xE1, 0xE1, 0xFD, 0x9D, 0xEA, 0xA7, 0x00, 0x17, 0xFA, + 0x9C, 0x05, 0xFA, 0x0B, 0x74, 0x0E, 0x9E, 0x1A, 0x3C, 0x17, 0x69, 0x23, + 0xA0, 0x19, 0x35, 0x22, 0x52, 0x0E, 0xA4, 0x17, 0x40, 0xF9, 0x2E, 0x05, + 0x31, 0xE7, 0x9F, 0xEF, 0x9D, 0xE6, 0x63, 0xEA, 0x7D, 0xEF, 0x32, 0xEA, + 0xD7, 0xFB, 0xAB, 0xEA, 0xB2, 0x04, 0x20, 0xF1, 0x7A, 0x09, 0xA5, 0xFE, + 0x88, 0x0A, 0x2B, 0x0F, 0x80, 0x0B, 0x0B, 0x1C, 0x16, 0x0D, 0x26, 0x21, + 0x10, 0x10, 0x0C, 0x1E, 0xE9, 0x09, 0xAC, 0x10, 0x37, 0xF4, 0x8F, 0xF9, + 0xDF, 0xE9, 0x47, 0xEB, 0x3B, 0xE2, 0x95, 0xE1, 0x1C, 0xE0, 0x79, 0xDB, + 0xB5, 0xE8, 0x7C, 0xDA, 0x26, 0xF7, 0xBA, 0xE1, 0xCC, 0x04, 0x65, 0xF1, + 0x50, 0x0C, 0x12, 0x05, 0x70, 0x0C, 0xB1, 0x14, 0x0F, 0x0A, 0x2D, 0x1C, + 0x17, 0x09, 0x40, 0x19, 0xAC, 0x03, 0x4E, 0x0B, 0xA4, 0xFF, 0x47, 0xFC, + 0x46, 0xF7, 0x28, 0xEF, 0x1B, 0xEB, 0x7B, 0xE5, 0x15, 0xE3, 0x35, 0xE1, + 0x0F, 0xE8, 0x7C, 0xE3, 0x53, 0xF8, 0x4F, 0xED, 0xDA, 0x0C, 0x95, 0xFE, + 0x23, 0x1C, 0xB9, 0x13, 0xFD, 0x1F, 0x9E, 0x24, 0x06, 0x18, 0xDC, 0x2B, + 0x99, 0x0E, 0xE3, 0x26, 0x46, 0x09, 0x7A, 0x17, 0x00, 0x03, 0x95, 0x07, + 0x17, 0xFE, 0x2C, 0xF9, 0xA5, 0xF5, 0x19, 0xED, 0x24, 0xEC, 0x26, 0xE7, + 0x53, 0xE9, 0x9D, 0xE7, 0xEF, 0xF1, 0x4B, 0xEF, 0x33, 0x03, 0x54, 0xFD, + 0xEB, 0x15, 0xA9, 0x0F, 0xB3, 0x1D, 0x17, 0x1F, 0x2D, 0x16, 0x0F, 0x24, + 0xAE, 0x07, 0xCC, 0x1D, 0xB2, 0xF8, 0x88, 0x0C, 0x2D, 0xF1, 0x17, 0xFA, + 0x62, 0xF1, 0xB2, 0xEA, 0xF5, 0xF0, 0x41, 0xDF, 0xCD, 0xEC, 0x78, 0xDA, + 0x6D, 0xE8, 0x8E, 0xDD, 0xAC, 0xEB, 0x4B, 0xE7, 0x3D, 0xF8, 0x4D, 0xF7, + 0xA6, 0x0C, 0x81, 0x0A, 0xF5, 0x1B, 0x10, 0x1C, 0x7D, 0x19, 0x3F, 0x25, + 0x5D, 0x0F, 0xBC, 0x1D, 0xC0, 0xFF, 0xC3, 0x0F, 0x97, 0xF2, 0x13, 0x02, + 0x73, 0xF0, 0x3D, 0xF5, 0xF0, 0xF4, 0x00, 0xEB, 0x48, 0xF9, 0x7A, 0xE6, + 0x4A, 0xFA, 0x82, 0xEA, 0xE5, 0xFC, 0xDE, 0xF5, 0x59, 0x03, 0x26, 0x06, + 0x2B, 0x12, 0x14, 0x18, 0xE0, 0x20, 0x4D, 0x27, 0x9F, 0x24, 0xDF, 0x2E, + 0xBB, 0x1B, 0xA5, 0x25, 0x1C, 0x0A, 0x88, 0x16, 0x18, 0xF6, 0x99, 0x07, + 0xDA, 0xEB, 0x71, 0xF8, 0xAF, 0xEC, 0x53, 0xEB, 0x4A, 0xF4, 0xDD, 0xE3, + 0xD9, 0xFA, 0x33, 0xE5, 0xC2, 0xFF, 0x20, 0xF0, 0xB9, 0x01, 0x8D, 0xFE, + 0x8B, 0x08, 0xD3, 0x0E, 0x28, 0x17, 0x13, 0x20, 0x22, 0x15, 0x61, 0x1C, + 0x57, 0x10, 0x70, 0x13, 0x2D, 0x07, 0xBC, 0x09, 0x20, 0xF6, 0xA2, 0xFD, + 0xBA, 0xE6, 0xB6, 0xEF, 0xB2, 0xE1, 0x26, 0xE3, 0xD4, 0xE7, 0x39, 0xDB, + 0xAE, 0xF4, 0xD5, 0xDD, 0xA2, 0xFF, 0x7A, 0xE9, 0x3F, 0x07, 0xB2, 0xFC, + 0xEF, 0x0F, 0x12, 0x15, 0xA4, 0x0E, 0x17, 0x1C, 0xE1, 0x0F, 0x1C, 0x1E, + 0xC3, 0x14, 0x88, 0x1D, 0x08, 0x15, 0x96, 0x17, 0x26, 0x09, 0x2E, 0x0B, + 0xFD, 0xF6, 0x1D, 0xFD, 0x13, 0xEA, 0x56, 0xEF, 0xC7, 0xE8, 0x29, 0xE7, + 0x69, 0xF3, 0xBF, 0xE6, 0x9D, 0x03, 0x7E, 0xF2, 0xC6, 0x0F, 0xCD, 0x08, + 0x88, 0x15, 0xFE, 0x17, 0x8D, 0x13, 0xB6, 0x20, 0x46, 0x0E, 0xA7, 0x24, + 0x41, 0x0D, 0x2E, 0x22, 0x9F, 0x0D, 0x11, 0x18, 0xD8, 0x07, 0xFF, 0x07, + 0xFB, 0xF9, 0xF0, 0xF6, 0x05, 0xEB, 0xD7, 0xE7, 0x3B, 0xE3, 0x58, 0xDE, + 0xF3, 0xE7, 0xFC, 0xDB, 0xD7, 0xF7, 0x1D, 0xE6, 0x3A, 0x0B, 0xE2, 0xFB, + 0x09, 0x12, 0x12, 0x09, 0x1E, 0x10, 0x27, 0x12, 0x3E, 0x08, 0x51, 0x18, + 0xD2, 0x01, 0x39, 0x17, 0xE1, 0xFF, 0x61, 0x0E, 0x85, 0xFF, 0x57, 0xFF, + 0xD6, 0xF9, 0x43, 0xEF, 0xCF, 0xF0, 0x40, 0xE3, 0xDE, 0xE7, 0x73, 0xDC, + 0x00, 0xE9, 0x84, 0xDE, 0x91, 0xFB, 0x28, 0xED, 0x80, 0x08, 0xCB, 0xFD, + 0xBF, 0x15, 0x0D, 0x0F, 0xFC, 0x1E, 0x33, 0x1E, 0x3F, 0x1B, 0x86, 0x26, + 0xBB, 0x0E, 0x9E, 0x25, 0x5D, 0x03, 0xCD, 0x1A, 0xF8, 0xFD, 0x88, 0x09, + 0xAF, 0xFA, 0xEF, 0xF6, 0x57, 0xF6, 0xB6, 0xE9, 0x2C, 0xF0, 0xB9, 0xE3, + 0xD7, 0xEF, 0xB8, 0xE5, 0x58, 0xF5, 0x9F, 0xF2, 0x7E, 0x00, 0x8C, 0x01, + 0x63, 0x10, 0xA7, 0x0F, 0xEB, 0x1E, 0xCA, 0x1B, 0x39, 0x1F, 0xAE, 0x21, + 0x27, 0x11, 0x35, 0x1F, 0x96, 0xFD, 0x12, 0x13, 0x04, 0xF0, 0x11, 0x00, + 0x2D, 0xEA, 0x41, 0xEB, 0x40, 0xEA, 0xFD, 0xDB, 0x45, 0xEA, 0xEF, 0xD5, + 0x81, 0xE8, 0x2E, 0xD9, 0x3A, 0xEF, 0x74, 0xE6, 0x97, 0xF6, 0x23, 0xF5, + 0x2F, 0x02, 0x73, 0x03, 0x06, 0x12, 0x67, 0x10, 0x3C, 0x1B, 0x95, 0x18, + 0xFB, 0x14, 0x57, 0x18, 0x71, 0x03, 0x8E, 0x0F, 0x7C, 0xF1, 0xAB, 0xFF, + 0x58, 0xE9, 0x87, 0xED, 0xAF, 0xEA, 0xB4, 0xDF, 0x87, 0xEE, 0xAF, 0xD8, + 0x92, 0xF9, 0xF0, 0xE3, 0xF0, 0x00, 0x9B, 0xF3, 0xAC, 0x02, 0xE6, 0x01, + 0x1E, 0x06, 0x65, 0x0F, 0xCB, 0x10, 0xBA, 0x1B, 0x6E, 0x1C, 0x60, 0x22, + 0x43, 0x1D, 0x7A, 0x21, 0x61, 0x10, 0xD7, 0x17, 0x99, 0xFC, 0x09, 0x09, + 0x3B, 0xED, 0xB5, 0xF5, 0x45, 0xE9, 0x49, 0xE2, 0xBE, 0xEE, 0x08, 0xE1, + 0x1A, 0xF9, 0xED, 0xE7, 0xEB, 0x02, 0x13, 0xF1, 0xD8, 0x05, 0x9A, 0xFC, + 0x78, 0x04, 0x24, 0x09, 0x1E, 0x06, 0x8A, 0x14, 0x8C, 0x0C, 0x8E, 0x19, + 0x93, 0x0F, 0xBE, 0x16, 0xE2, 0x08, 0xCA, 0x0B, 0xD7, 0xF7, 0x87, 0xFC, + 0x5C, 0xE6, 0x22, 0xEA, 0x4D, 0xDC, 0x5A, 0xD7, 0x0F, 0xE0, 0x9B, 0xD6, + 0xF2, 0xEB, 0xA5, 0xDC, 0x8B, 0xFB, 0x9D, 0xE5, 0xAC, 0x06, 0xB8, 0xF3, + 0x93, 0x09, 0x3D, 0x04, 0xB1, 0x07, 0x13, 0x13, 0x98, 0x08, 0x67, 0x1B, + 0x9C, 0x0A, 0x70, 0x19, 0xD9, 0x09, 0x7F, 0x10, 0x56, 0x00, 0xF6, 0x01, + 0x76, 0xED, 0x4E, 0xED, 0x86, 0xEA, 0x0C, 0xE9, 0x25, 0xEB, 0x42, 0xE8, + 0x1C, 0xEF, 0x64, 0xE8, 0xFB, 0xFB, 0x5C, 0xEE, 0xB4, 0x0C, 0x24, 0xFC, + 0x69, 0x16, 0x03, 0x0E, 0x0D, 0x16, 0xA6, 0x1E, 0x1E, 0x10, 0xFC, 0x26, + 0x45, 0x0C, 0xF9, 0x24, 0x50, 0x08, 0x67, 0x17, 0x00, 0xFE, 0xB2, 0x02, + 0xAD, 0xF9, 0x75, 0xF5, 0x7D, 0xF3, 0x7C, 0xEC, 0xE6, 0xEA, 0xF6, 0xE5, + 0x47, 0xE5, 0xA1, 0xE2, 0x89, 0xEC, 0xC5, 0xE6, 0x01, 0xFF, 0x05, 0xF3, + 0xED, 0x10, 0x55, 0x04, 0xEA, 0x16, 0xB6, 0x14, 0xE1, 0x10, 0xD0, 0x1D, + 0x0D, 0x06, 0x15, 0x1B, 0x00, 0xFD, 0xFB, 0x0C, 0x1A, 0xF7, 0x30, 0xF8, + 0xD9, 0xF2, 0x1B, 0xEA, 0x00, 0xF1, 0x0F, 0xE2, 0x00, 0xED, 0x3D, 0xDE, + 0x15, 0xE8, 0x15, 0xDF, 0x2F, 0xEA, 0x69, 0xE6, 0x71, 0xF9, 0xB1, 0xF4, + 0xFA, 0x0E, 0xBF, 0x07, 0x59, 0x1D, 0x56, 0x19, 0x4E, 0x1C, 0x20, 0x25, + 0x35, 0x10, 0x93, 0x24, 0xE6, 0x01, 0xC7, 0x15, 0x09, 0xF9, 0x7E, 0x06, + 0x00, 0xF6, 0xCE, 0xF7, 0x3A, 0xF8, 0xDD, 0xEC, 0x02, 0xFA, 0x01, 0xE8, + 0xBF, 0xF7, 0xCF, 0xE9, 0xE2, 0xF4, 0x2E, 0xF2, 0x49, 0xFB, 0x6D, 0x00, + 0x3D, 0x0B, 0x4C, 0x11, 0xA7, 0x1B, 0x35, 0x20, 0x2C, 0x1F, 0x32, 0x28, + 0xFC, 0x11, 0x4E, 0x26, 0x11, 0x04, 0x02, 0x18, 0x47, 0xF6, 0xB4, 0x05, + 0x18, 0xEC, 0xB0, 0xF3, 0x3E, 0xEB, 0x79, 0xE5, 0x6D, 0xF1, 0x82, 0xDE, + 0x81, 0xF6, 0x54, 0xE0, 0xBB, 0xF6, 0x31, 0xE9, 0x7E, 0xF8, 0x9D, 0xF8, + 0xFB, 0x01, 0x6E, 0x08, 0xC1, 0x10, 0x7A, 0x16, 0x95, 0x17, 0x5A, 0x20, + 0x00, 0x13, 0x9A, 0x18, 0xA0, 0x06, 0x62, 0x0C, 0xC1, 0xF6, 0x54, 0x00, + 0xAB, 0xE8, 0xC5, 0xF2, 0xA3, 0xE4, 0x65, 0xE6, 0x6F, 0xEC, 0xA1, 0xDF, + 0x19, 0xFA, 0x04, 0xE2, 0x5B, 0x03, 0x39, 0xED, 0x7E, 0x07, 0x3E, 0xFF, + 0x41, 0x0C, 0x87, 0x12, 0x6A, 0x15, 0xEF, 0x21, 0x89, 0x1E, 0xAC, 0x29, + 0x05, 0x1A, 0xFF, 0x21, 0xE1, 0x10, 0xA9, 0x16, 0xAA, 0x04, 0xE7, 0x0B, + 0xA3, 0xF5, 0x4E, 0xFF, 0x11, 0xEA, 0x46, 0xF2, 0xBA, 0xEA, 0xFC, 0xE8, + 0xB5, 0xF6, 0x1B, 0xE8, 0x8D, 0x05, 0x26, 0xF1, 0xBD, 0x0C, 0x51, 0x01, + 0x20, 0x0F, 0x36, 0x14, 0xCF, 0x14, 0xBB, 0x25, 0x10, 0x10, 0x3E, 0x23, + 0xD2, 0x0B, 0xEA, 0x19, 0x7F, 0x09, 0x4D, 0x0F, 0x45, 0x04, 0x38, 0x04, + 0x36, 0xF8, 0x44, 0xF7, 0xBC, 0xE8, 0x0B, 0xEA, 0x7A, 0xE0, 0x76, 0xDF, + 0xCB, 0xE6, 0xB0, 0xDD, 0x8D, 0xF7, 0x43, 0xE4, 0xBB, 0x06, 0x6B, 0xF5, + 0xE5, 0x0E, 0xD0, 0x0D, 0xC1, 0x0D, 0x6B, 0x17, 0x60, 0x09, 0x84, 0x19, + 0xB5, 0x05, 0x87, 0x17, 0xB8, 0x04, 0xCA, 0x0F, 0xEA, 0x03, 0xE1, 0x04, + 0x9F, 0xFF, 0x57, 0xF8, 0xE8, 0xF4, 0x75, 0xED, 0x7F, 0xEA, 0xD0, 0xE5, + 0xA2, 0xEA, 0x89, 0xE5, 0xCD, 0xF9, 0xC3, 0xED, 0x66, 0x0D, 0x36, 0xFF, + 0xDB, 0x1A, 0x04, 0x17, 0x24, 0x1C, 0xDA, 0x20, 0xFF, 0x15, 0xF1, 0x24, + 0xF7, 0x0C, 0x63, 0x24, 0xFD, 0x04, 0xF6, 0x1A, 0x4F, 0x01, 0xFC, 0x0B, + 0x7F, 0x00, 0xF3, 0xFB, 0xC5, 0xFB, 0xE4, 0xEE, 0xE5, 0xF2, 0x34, 0xE7, + 0x6C, 0xEC, 0xA3, 0xE5, 0xA2, 0xF3, 0x39, 0xED, 0xED, 0x08, 0xE9, 0xFF, + 0x58, 0x12, 0x54, 0x0B, 0x0C, 0x16, 0xCC, 0x14, 0x37, 0x15, 0xC6, 0x1C, + 0x31, 0x0C, 0x11, 0x1E, 0x36, 0xFE, 0x85, 0x14, 0x01, 0xF4, 0xCF, 0x02, + 0x3F, 0xF1, 0x8C, 0xEF, 0xEC, 0xF2, 0xBA, 0xE0, 0x67, 0xEF, 0xFF, 0xD8, + 0xA8, 0xEA, 0xC2, 0xDA, 0x04, 0xF2, 0xAE, 0xE6, 0x5C, 0xF9, 0x7C, 0xF5, + 0xE3, 0x05, 0x75, 0x04, 0x88, 0x14, 0x9C, 0x11, 0x61, 0x1C, 0xD5, 0x1B, + 0xB9, 0x17, 0x51, 0x1F, 0x0E, 0x08, 0xC2, 0x18, 0xB2, 0xF6, 0x54, 0x09, + 0x1B, 0xEE, 0xA2, 0xF6, 0x54, 0xF0, 0x7B, 0xE7, 0xEE, 0xF4, 0xC7, 0xE0, + 0xA1, 0xF6, 0x48, 0xE4, 0x78, 0xF8, 0x59, 0xF1, 0x8F, 0xFF, 0x56, 0x02, + 0x3A, 0x09, 0x0B, 0x11, 0xD8, 0x14, 0xC8, 0x1B, 0x18, 0x1D, 0xC6, 0x21, + 0xCB, 0x1C, 0xEB, 0x21, 0x74, 0x0F, 0x67, 0x1A, 0x17, 0xFB, 0xC4, 0x0A, + 0x35, 0xEA, 0xC3, 0xF6, 0x99, 0xE7, 0x31, 0xE5, 0x55, 0xEE, 0xDC, 0xDB, + 0xA6, 0xF3, 0xB6, 0xDD, 0x78, 0xFB, 0x88, 0xEA, 0x95, 0xFF, 0x55, 0xFA, + 0xD7, 0x01, 0x89, 0x08, 0x01, 0x07, 0xA4, 0x12, 0x02, 0x0E, 0x10, 0x17, + 0x45, 0x12, 0x5E, 0x15, 0x23, 0x0D, 0xF8, 0x0D, 0x28, 0xFD, 0xA2, 0xFF, + 0xE5, 0xE9, 0xB9, 0xEE, 0x27, 0xE1, 0x5A, 0xDE, 0x9C, 0xE6, 0x48, 0xD4, + 0x84, 0xF2, 0x84, 0xDA, 0x5B, 0xFE, 0x4F, 0xE8, 0xEC, 0x05, 0x33, 0xF8, + 0x75, 0x08, 0x68, 0x09, 0x57, 0x0A, 0x18, 0x17, 0x8F, 0x0C, 0xEF, 0x1D, + 0x2D, 0x10, 0x42, 0x1C, 0xEC, 0x0F, 0x36, 0x14, 0x67, 0x07, 0xFE, 0x06, + 0x03, 0xF6, 0x42, 0xF8, 0xB7, 0xE8, 0xAA, 0xE9, 0xC8, 0xE8, 0xD7, 0xDE, + 0x59, 0xF2, 0x7F, 0xE6, 0x5E, 0x00, 0x43, 0xF2, 0x1D, 0x0C, 0x3A, 0xFE, + 0x82, 0x11, 0x32, 0x0D, 0xBB, 0x10, 0xA0, 0x1A, 0x62, 0x0B, 0xCA, 0x20, + 0xE7, 0x06, 0xDF, 0x1C, 0xA0, 0x04, 0xAA, 0x10, 0x0E, 0x01, 0xEA, 0x01, + 0x59, 0xF5, 0x30, 0xF1, 0x91, 0xE4, 0xE8, 0xDE, 0x19, 0xE3, 0xEC, 0xDE, + 0x8A, 0xE8, 0x91, 0xE2, 0x03, 0xF3, 0x0B, 0xE7, 0x3D, 0x01, 0xE7, 0xEF, + 0x4D, 0x0D, 0x0D, 0xFF, 0x09, 0x11, 0x76, 0x0F, 0x1E, 0x0C, 0x04, 0x1A, + 0xA4, 0x01, 0xCC, 0x18, 0x65, 0xFC, 0x63, 0x0E, 0x7C, 0xFA, 0x21, 0xFE, + 0xFE, 0xF0, 0xD0, 0xE9, 0xC3, 0xF0, 0x11, 0xE4, 0x44, 0xEE, 0x5C, 0xE3, + 0x41, 0xEA, 0xCD, 0xE4, 0x94, 0xEE, 0xC3, 0xE9, 0x8C, 0xFC, 0xC0, 0xF4, + 0xB6, 0x0E, 0x94, 0x04, 0x64, 0x1B, 0xCE, 0x16, 0xF5, 0x1B, 0x41, 0x23, + 0x9D, 0x10, 0xC6, 0x25, 0x0F, 0x04, 0x00, 0x1B, 0x5D, 0xFC, 0xC8, 0x05, + 0x7E, 0xFA, 0x81, 0xF7, 0xAC, 0xFA, 0x52, 0xEE, 0x34, 0xF8, 0x71, 0xE8, + 0x4A, 0xF2, 0x24, 0xE8, 0xE5, 0xF0, 0x7E, 0xED, 0xD1, 0xF7, 0x17, 0xF8, + 0x17, 0x07, 0xC5, 0x05, 0xF2, 0x15, 0x86, 0x14, 0x0E, 0x1C, 0x43, 0x1F, + 0xFA, 0x11, 0xE7, 0x20, 0x3D, 0x00, 0x9D, 0x15, 0x3F, 0xF3, 0x39, 0x00, + 0x8C, 0xED, 0x42, 0xF0, 0x6B, 0xEF, 0xDC, 0xE4, 0x1F, 0xF3, 0x7F, 0xDD, + 0x29, 0xF3, 0xC6, 0xDD, 0xF2, 0xF1, 0xAE, 0xE5, 0x6A, 0xF4, 0x34, 0xF3, + 0x0B, 0xFE, 0x5D, 0x02, 0x08, 0x0C, 0x69, 0x10, 0x3E, 0x17, 0xF0, 0x1A, + 0x64, 0x14, 0xD0, 0x1C, 0xFA, 0x01, 0x59, 0x12, 0x42, 0xF5, 0xFF, 0x03, + 0xA2, 0xED, 0x80, 0xF5, 0xF5, 0xEC, 0xF7, 0xE8, 0x84, 0xF3, 0x8E, 0xE1, + 0x5B, 0xFA, 0x42, 0xE2, 0xCE, 0xFE, 0xC3, 0xEC, 0xE8, 0x01, 0xAB, 0xFD, + 0x6B, 0x06, 0x24, 0x10, 0xE1, 0x0F, 0x50, 0x1E, 0xD4, 0x19, 0x3A, 0x26, + 0xC7, 0x17, 0xE0, 0x25, 0x64, 0x11, 0xAE, 0x1A, 0x12, 0x03, 0xC5, 0x0B, + 0xAB, 0xF1, 0x0E, 0xFD, 0x1F, 0xE8, 0x41, 0xEF, 0xD6, 0xEA, 0x8B, 0xE5, + 0x14, 0xF5, 0xA0, 0xE2, 0x30, 0x00, 0x68, 0xEA, 0xA0, 0x07, 0x71, 0xFA, + 0xF1, 0x0A, 0x68, 0x0D, 0xAF, 0x0C, 0x0B, 0x1B, 0xB2, 0x10, 0x6A, 0x20, + 0x44, 0x14, 0x4A, 0x1E, 0xE8, 0x0C, 0x10, 0x10, 0x4A, 0x01, 0x0A, 0x01, + 0xFD, 0xF1, 0x63, 0xF4, 0xB6, 0xE5, 0x77, 0xE9, 0xF2, 0xE2, 0x46, 0xE1, + 0xDD, 0xEB, 0xFA, 0xDE, 0x5D, 0xFA, 0x98, 0xE5, 0x13, 0x09, 0xFB, 0xF5, + 0x61, 0x0F, 0x77, 0x0A, 0x69, 0x0F, 0x3B, 0x1B, 0x7B, 0x11, 0xC5, 0x24, + 0x48, 0x0B, 0x1E, 0x1D, 0x1C, 0x08, 0x1E, 0x11, 0xCC, 0x06, 0xBF, 0x05, + 0x6D, 0xFF, 0x4D, 0xFB, 0xA0, 0xF3, 0xEB, 0xF1, 0x38, 0xEB, 0xAE, 0xEB, + 0xF0, 0xEC, 0x90, 0xE9, 0xE4, 0xF8, 0x5A, 0xEF, 0x1C, 0x0A, 0xA5, 0xFC, + 0x57, 0x16, 0x05, 0x11, 0x70, 0x18, 0xD1, 0x24, 0x35, 0x12, 0xD2, 0x27, + 0x35, 0x09, 0x13, 0x21, 0xA2, 0x03, 0x0C, 0x16, 0x01, 0x03, 0x5D, 0x08, + 0x29, 0x00, 0xA8, 0xFA, 0x72, 0xF8, 0xB8, 0xEE, 0x74, 0xEE, 0xFA, 0xE7, + 0x88, 0xEA, 0x0C, 0xE6, 0x18, 0xF0, 0xE3, 0xEA, 0x67, 0x00, 0x50, 0xF6, + 0x3E, 0x11, 0x64, 0x08, 0xBA, 0x17, 0xC2, 0x1C, 0x0A, 0x13, 0x12, 0x1E, + 0x52, 0x07, 0x44, 0x18, 0x0B, 0xFC, 0xD4, 0x0F, 0x1A, 0xF8, 0x42, 0x03, + 0x99, 0xF8, 0xCD, 0xF4, 0x30, 0xF8, 0xD2, 0xE8, 0x10, 0xF4, 0x66, 0xE2, + 0x54, 0xF0, 0xF0, 0xE3, 0x99, 0xF1, 0x99, 0xEA, 0x1D, 0xFE, 0x38, 0xF8, + 0x00, 0x13, 0x7D, 0x0E, 0xAC, 0x19, 0x2F, 0x17, 0x94, 0x19, 0x7A, 0x1C, + 0x31, 0x12, 0x4C, 0x1F, 0xD6, 0x04, 0x52, 0x1B, 0x59, 0xFA, 0xDC, 0x0E, + 0x5E, 0xF7, 0x1E, 0xFE, 0x9D, 0xF8, 0x1D, 0xEE, 0x95, 0xFA, 0x94, 0xE5, + 0xD8, 0xF8, 0xF4, 0xE5, 0xF8, 0xF8, 0x84, 0xEF, 0xC8, 0x03, 0x76, 0x00, + 0xEC, 0x08, 0xEC, 0x0C, 0xFD, 0x10, 0x17, 0x16, 0x1A, 0x1A, 0x9C, 0x1C, + 0x78, 0x19, 0x10, 0x1F, 0x21, 0x0C, 0x98, 0x19, 0xE5, 0xF9, 0x4F, 0x0C, + 0xF8, 0xED, 0x00, 0xFA, 0xEC, 0xEA, 0xD1, 0xE7, 0xE7, 0xEE, 0xB3, 0xDC, + 0xB2, 0xF3, 0x8E, 0xDC, 0x4E, 0xF7, 0xA4, 0xE7, 0x02, 0xFC, 0x12, 0xFA, + 0x42, 0x00, 0xE4, 0x06, 0xA9, 0x06, 0xD9, 0x0F, 0x1A, 0x11, 0x48, 0x16, + 0x2B, 0x16, 0x00, 0x18, 0x2B, 0x0F, 0x3D, 0x13, 0xFF, 0xFD, 0x04, 0x08, + 0x2C, 0xEE, 0x36, 0xF8, 0x9F, 0xE6, 0x7B, 0xE8, 0xC9, 0xEA, 0x2E, 0xDD, + 0x7D, 0xF4, 0x04, 0xDD, 0x2A, 0xFD, 0x82, 0xEA, 0x53, 0x05, 0x46, 0xFB, + 0xC1, 0x08, 0xBD, 0x0B, 0xE2, 0x09, 0x91, 0x18, 0x38, 0x0F, 0x61, 0x1F, + 0x13, 0x15, 0xE0, 0x1E, 0xE7, 0x13, 0xA8, 0x17, 0x5A, 0x08, 0x26, 0x0B, + 0x0E, 0xF8, 0x1D, 0xFC, 0x98, 0xEB, 0x39, 0xED, 0xB9, 0xE9, 0xD6, 0xE1, + 0xBB, 0xF3, 0x4A, 0xDF, 0x01, 0xFF, 0x91, 0xEA, 0xCB, 0x08, 0x51, 0xFA, + 0x2E, 0x0D, 0x58, 0x0A, 0xFB, 0x0A, 0x1E, 0x17, 0xC8, 0x08, 0x34, 0x1D, + 0x5F, 0x09, 0xA3, 0x1A, 0xC6, 0x09, 0xC1, 0x10, 0xF0, 0x03, 0xD1, 0x01, + 0x86, 0xF7, 0x8B, 0xF3, 0xF2, 0xE9, 0xB2, 0xE5, 0x5C, 0xE5, 0xCD, 0xD9, + 0xF0, 0xE8, 0x9F, 0xDD, 0x6E, 0xF4, 0xF1, 0xE6, 0xF8, 0x03, 0x6A, 0xF2, + 0xA7, 0x0F, 0x75, 0x01, 0xAC, 0x10, 0x30, 0x10, 0x4B, 0x0A, 0x1A, 0x1A, + 0x15, 0x04, 0x12, 0x1A, 0x32, 0x01, 0x7B, 0x11, 0x50, 0xFE, 0x34, 0x02, + 0x8A, 0xF8, 0x17, 0xF3, 0x35, 0xEF, 0xFA, 0xE6, 0x2B, 0xE6, 0x0F, 0xDE, + 0x1E, 0xEB, 0x38, 0xE5, 0xCE, 0xF4, 0x2D, 0xEF, 0xF8, 0x02, 0xA9, 0xF8, + 0x25, 0x12, 0x8F, 0x05, 0x52, 0x19, 0x14, 0x14, 0x79, 0x14, 0xCD, 0x1E, + 0x14, 0x0A, 0x72, 0x20, 0x46, 0x00, 0x78, 0x17, 0x24, 0xFC, 0x38, 0x07, + 0x8E, 0xF8, 0xDA, 0xF4, 0x6A, 0xEF, 0x4D, 0xE3, 0x5C, 0xF1, 0x6D, 0xE3, + 0xDE, 0xF1, 0x71, 0xE8, 0xD1, 0xF0, 0x8C, 0xED, 0x2E, 0xF7, 0x49, 0xF4, + 0x18, 0x06, 0x95, 0xFF, 0x31, 0x14, 0x0F, 0x0D, 0xE0, 0x16, 0x60, 0x18, + 0xA5, 0x0D, 0x2F, 0x1B, 0x51, 0x00, 0xB7, 0x14, 0x6B, 0xF6, 0x11, 0x04, + 0x37, 0xF1, 0xFC, 0xED, 0x1C, 0xF2, 0x69, 0xE3, 0x62, 0xF4, 0x85, 0xE0, + 0x71, 0xF4, 0x8C, 0xE2, 0x95, 0xF1, 0xC0, 0xE8, 0x5D, 0xF3, 0x75, 0xF2, + 0x97, 0xFE, 0xB1, 0xFF, 0x0B, 0x0F, 0x79, 0x0D, 0x13, 0x18, 0x84, 0x18, + 0x27, 0x14, 0xDF, 0x1B, 0xDA, 0x05, 0xD5, 0x16, 0xED, 0xF7, 0xA4, 0x08, + 0x8C, 0xF0, 0xE3, 0xF2, 0xCD, 0xF0, 0xF6, 0xE9, 0x09, 0xF6, 0x7C, 0xE6, + 0x7A, 0xFB, 0x4C, 0xE6, 0x70, 0xFC, 0x1C, 0xED, 0xA0, 0xFB, 0x10, 0xF9, + 0xCA, 0xFF, 0x59, 0x07, 0xF3, 0x0A, 0xC4, 0x14, 0x3D, 0x15, 0xF1, 0x1C, + 0x04, 0x16, 0xAE, 0x1E, 0x77, 0x0A, 0xAE, 0x17, 0xA0, 0xF7, 0xF3, 0x05, + 0xE1, 0xEE, 0x26, 0xF9, 0xAD, 0xEB, 0x4E, 0xED, 0x35, 0xEE, 0x00, 0xE3, + 0x18, 0xF6, 0x76, 0xDF, 0x4C, 0xFD, 0xEA, 0xE5, 0x91, 0xFF, 0x5D, 0xF4, + 0xC7, 0x00, 0xC0, 0x05, 0x86, 0x05, 0xB7, 0x14, 0x4A, 0x0E, 0xFE, 0x1C, + 0xD0, 0x11, 0x78, 0x1C, 0x4F, 0x08, 0x6F, 0x13, 0x32, 0xFF, 0x6B, 0x05, + 0x35, 0xF4, 0xAF, 0xF7, 0x96, 0xE9, 0x43, 0xEC, 0x3A, 0xE6, 0xBC, 0xE2, + 0x19, 0xEE, 0x3C, 0xDF, 0x3A, 0xFC, 0x21, 0xE5, 0xAB, 0x06, 0x31, 0xF4, + 0xE6, 0x0A, 0x5D, 0x07, 0x2F, 0x0C, 0x96, 0x18, 0x65, 0x0F, 0xF4, 0x21, + 0x87, 0x11, 0xC9, 0x20, 0x34, 0x0E, 0x77, 0x16, 0xC2, 0x06, 0xE6, 0x07, + 0x64, 0xFD, 0x4F, 0xFB, 0xDB, 0xF1, 0xA8, 0xF1, 0xF6, 0xE9, 0xFF, 0xE9, + 0x58, 0xEC, 0x53, 0xE6, 0xCF, 0xF9, 0x4B, 0xEA, 0x37, 0x09, 0x31, 0xF7, + 0x37, 0x12, 0x7C, 0x09, 0x47, 0x12, 0xBB, 0x1A, 0x43, 0x0F, 0xE3, 0x23, + 0x84, 0x0D, 0x15, 0x22, 0xB1, 0x06, 0xA4, 0x14, 0x1C, 0x01, 0x9A, 0x04, + 0x1D, 0xFD, 0x28, 0xF7, 0xEF, 0xF5, 0xCB, 0xED, 0xBE, 0xEC, 0xB7, 0xE7, + 0xD0, 0xE8, 0xB4, 0xE5, 0xF4, 0xF0, 0x60, 0xE9, 0xD9, 0x01, 0x95, 0xF5, + 0x50, 0x10, 0x04, 0x06, 0x9F, 0x14, 0x57, 0x17, 0x1D, 0x11, 0x06, 0x23, + 0xA3, 0x07, 0x5A, 0x1E, 0xBC, 0xFF, 0x57, 0x12, 0xF0, 0xFB, 0x4E, 0x04, + 0xB1, 0xFB, 0x74, 0xF6, 0x38, 0xFA, 0x57, 0xEC, 0x84, 0xF4, 0x22, 0xE7, + 0x06, 0xEE, 0x42, 0xE7, 0x49, 0xF0, 0xD6, 0xEC, 0x82, 0xFD, 0x0A, 0xF9, + 0x8E, 0x0F, 0xFD, 0x08, 0x83, 0x19, 0x8C, 0x19, 0xD4, 0x16, 0x16, 0x26, + 0xAF, 0x0E, 0x11, 0x21, 0xF2, 0x03, 0xAE, 0x16, 0x4F, 0xFB, 0x90, 0x0A, + 0xC0, 0xF8, 0xB5, 0xFB, 0x88, 0xFA, 0x25, 0xEF, 0xE1, 0xFA, 0x7D, 0xE8, + 0x32, 0xF7, 0x92, 0xE8, 0x06, 0xF5, 0xA1, 0xEF, 0x11, 0xFC, 0xCB, 0xFA, + 0xD8, 0x0A, 0x26, 0x0A, 0xA7, 0x18, 0x83, 0x1C, 0x6E, 0x18, 0x0B, 0x1D, + 0x03, 0x11, 0xBD, 0x19, 0x48, 0x05, 0x45, 0x15, 0xB1, 0xF8, 0xF7, 0x0B, + 0x0D, 0xF1, 0x14, 0xFD, 0x7D, 0xF2, 0xC1, 0xED, 0x9D, 0xF7, 0xB3, 0xE3, + 0xBA, 0xFA, 0x1E, 0xE3, 0x0D, 0xF9, 0xE3, 0xE9, 0xE0, 0xFB, 0xCF, 0xF7, + 0x59, 0x0A, 0xDC, 0x0B, 0x83, 0x0E, 0x73, 0x13, 0x91, 0x11, 0x8F, 0x16, + 0xF4, 0x12, 0x94, 0x17, 0xCF, 0x0C, 0x03, 0x15, 0x39, 0xFF, 0xCE, 0x0C, + 0x7A, 0xF1, 0x26, 0xFF, 0x55, 0xEC, 0xE7, 0xEE, 0x2C, 0xF1, 0xEA, 0xE3, + 0xDD, 0xF8, 0x0B, 0xE1, 0x52, 0xFD, 0xBE, 0xE9, 0xCA, 0x02, 0x57, 0xFC, + 0x4B, 0x05, 0x0A, 0x0B, 0xB3, 0x09, 0x95, 0x15, 0x37, 0x10, 0x97, 0x1C, + 0x1F, 0x15, 0xEA, 0x1C, 0x9E, 0x12, 0xC6, 0x17, 0x42, 0x07, 0xEA, 0x0D, + 0x9A, 0xF6, 0x4C, 0x00, 0x58, 0xEA, 0x86, 0xF0, 0xA3, 0xE9, 0x49, 0xE4, + 0x45, 0xF3, 0x3C, 0xE0, 0x65, 0xFD, 0xE5, 0xE7, 0xA1, 0x03, 0x47, 0xFA, + 0x6B, 0x07, 0x94, 0x08, 0xBB, 0x08, 0x31, 0x14, 0x7B, 0x0A, 0x09, 0x1C, + 0xD8, 0x0C, 0xE2, 0x1B, 0x92, 0x0D, 0xCA, 0x14, 0x6C, 0x08, 0x2E, 0x09, + 0xCA, 0xFB, 0xD6, 0xFB, 0x52, 0xED, 0x21, 0xEE, 0x6A, 0xE7, 0xAF, 0xE2, + 0x3B, 0xEE, 0x57, 0xDF, 0x70, 0xFC, 0x86, 0xE7, 0xAA, 0x06, 0x3D, 0xF5, + 0x7B, 0x0B, 0x67, 0x04, 0xE9, 0x0B, 0xB1, 0x12, 0xC4, 0x09, 0x72, 0x1C, + 0x9B, 0x07, 0x7D, 0x1D, 0x47, 0x07, 0xCD, 0x14, 0xEA, 0x05, 0x0E, 0x07, + 0x06, 0x00, 0x57, 0xF8, 0xB5, 0xF3, 0xED, 0xEB, 0x83, 0xEA, 0xFF, 0xE2, + 0x08, 0xEF, 0x5B, 0xE0, 0xEF, 0xF7, 0xC8, 0xE9, 0x2F, 0x04, 0x96, 0xF7, + 0xD4, 0x0F, 0x47, 0x05, 0x89, 0x14, 0xB1, 0x12, 0x43, 0x11, 0xB9, 0x1C, + 0xCE, 0x08, 0xF7, 0x1E, 0x69, 0x01, 0x5B, 0x16, 0xA0, 0xFD, 0xE3, 0x06, + 0x95, 0xFB, 0x0C, 0xF6, 0xB1, 0xF4, 0x4C, 0xE9, 0x43, 0xEC, 0x9A, 0xE1, + 0x3E, 0xEA, 0xC1, 0xDF, 0x39, 0xF1, 0x9C, 0xEA, 0x8B, 0xFD, 0xE2, 0xF7, + 0xCB, 0x0B, 0xF5, 0x03, 0xF2, 0x14, 0x76, 0x0F, 0x4B, 0x15, 0xF6, 0x18, + 0x94, 0x0B, 0x2C, 0x1C, 0xF1, 0xFE, 0xAF, 0x15, 0x4C, 0xF6, 0x16, 0x06, + 0x69, 0xF5, 0xD5, 0xF4, 0x73, 0xF4, 0x99, 0xE6, 0x23, 0xED, 0x03, 0xDC, + 0xAC, 0xEF, 0x23, 0xE2, 0x42, 0xF3, 0x2D, 0xEC, 0xE2, 0xF8, 0x72, 0xF6, + 0x0A, 0x04, 0x61, 0x01, 0x4E, 0x10, 0xA0, 0x0C, 0x8B, 0x16, 0x8D, 0x15, + 0xFC, 0x11, 0x41, 0x1A, 0x6E, 0x04, 0xD8, 0x15, 0xCA, 0xF7, 0xA0, 0x09, + 0xD0, 0xF2, 0x68, 0xF7, 0x68, 0xF1, 0x24, 0xE5, 0xF1, 0xF6, 0x2F, 0xE2, + 0xB5, 0xF9, 0x51, 0xE6, 0x75, 0xF8, 0xC9, 0xEC, 0x56, 0xF8, 0xBB, 0xF6, + 0xE2, 0xFE, 0x25, 0x03, 0x41, 0x0A, 0xCC, 0x0E, 0x3F, 0x14, 0x9A, 0x16, + 0x9D, 0x15, 0xCC, 0x19, 0x35, 0x0B, 0xB0, 0x15, 0x79, 0xFA, 0x14, 0x0A, + 0x91, 0xEF, 0x4D, 0xF8, 0xE4, 0xEE, 0xA6, 0xE5, 0xB7, 0xF3, 0x50, 0xE3, + 0x14, 0xFA, 0x7C, 0xE6, 0xC1, 0xFC, 0x90, 0xEB, 0x1A, 0xFD, 0xBF, 0xF5, + 0x3A, 0xFF, 0x6D, 0x03, 0x18, 0x05, 0x09, 0x10, 0x35, 0x0D, 0x86, 0x17, + 0xB5, 0x11, 0xFC, 0x17, 0x1C, 0x0C, 0xA7, 0x13, 0x06, 0xFD, 0xAF, 0x07, + 0x55, 0xED, 0x4E, 0xF3, 0x45, 0xE9, 0xCE, 0xEA, 0x6A, 0xED, 0xD2, 0xE5, + 0xF3, 0xF5, 0x39, 0xE3, 0x87, 0xFD, 0x22, 0xE6, 0x2A, 0x02, 0xD6, 0xF0, + 0x87, 0x03, 0x7D, 0x01, 0x95, 0x05, 0x46, 0x12, 0x7E, 0x08, 0x89, 0x1B, + 0x85, 0x0D, 0x81, 0x1C, 0x67, 0x0C, 0x62, 0x15, 0xB2, 0xFE, 0xA4, 0x06, + 0x55, 0xF6, 0xA1, 0xFA, 0x04, 0xEF, 0x65, 0xF0, 0xE1, 0xEA, 0x32, 0xE8, + 0x8D, 0xEF, 0x57, 0xE4, 0xF0, 0xF9, 0x22, 0xE7, 0x0E, 0x05, 0xC0, 0xF1, + 0x54, 0x0B, 0xF5, 0x02, 0x18, 0x0D, 0x1D, 0x15, 0xEE, 0x0A, 0xEE, 0x1F, + 0x32, 0x0B, 0xD5, 0x1F, 0x5A, 0x0A, 0x7E, 0x16, 0x41, 0x03, 0x62, 0x07, + 0x8C, 0xFD, 0x10, 0xFB, 0x70, 0xF5, 0x17, 0xF1, 0x8F, 0xEC, 0x72, 0xE9, + 0x2B, 0xEC, 0x62, 0xE6, 0xA2, 0xF4, 0x5F, 0xE9, 0x0A, 0x03, 0xEE, 0xF2, + 0xBB, 0x0E, 0x4C, 0x02, 0xF6, 0x12, 0x64, 0x13, 0x82, 0x0E, 0x2C, 0x1F, + 0x40, 0x08, 0x6F, 0x1F, 0xED, 0x04, 0xB5, 0x14, 0x65, 0x00, 0xCC, 0x05, + 0xFD, 0xFC, 0x28, 0xF8, 0xF2, 0xF7, 0x87, 0xED, 0x1A, 0xF0, 0x93, 0xE6, + 0xE2, 0xEB, 0x2F, 0xE5, 0x66, 0xF0, 0x5F, 0xEA, 0x52, 0xFD, 0xC0, 0xF4, + 0xCD, 0x0C, 0x2C, 0x03, 0x02, 0x16, 0x64, 0x13, 0x3C, 0x14, 0xA1, 0x1F, + 0x7D, 0x0B, 0x14, 0x22, 0x2E, 0x01, 0xC3, 0x16, 0x6B, 0xFB, 0xD3, 0x07, + 0x1F, 0xFB, 0xF2, 0xF9, 0x7E, 0xFB, 0x0E, 0xEF, 0x17, 0xF8, 0x09, 0xE8, + 0xDE, 0xF2, 0x95, 0xE7, 0x9B, 0xF2, 0xD9, 0xED, 0xCB, 0xF9, 0xD4, 0xF9, + 0x82, 0x08, 0x13, 0x07, 0x85, 0x15, 0xD8, 0x15, 0x3B, 0x16, 0xDD, 0x22, + 0x48, 0x10, 0xA3, 0x20, 0xB8, 0x04, 0x65, 0x17, 0xE0, 0xF8, 0x65, 0x0B, + 0xE0, 0xF4, 0xF6, 0xFD, 0xFF, 0xF6, 0xF6, 0xF1, 0xAB, 0xF9, 0xD2, 0xE8, + 0x2F, 0xF9, 0xD3, 0xE6, 0x61, 0xF8, 0xA7, 0xEC, 0x3E, 0xFB, 0x66, 0xF9, + 0x28, 0x05, 0x4E, 0x07, 0x64, 0x11, 0x42, 0x14, 0xB3, 0x17, 0x5F, 0x1F, + 0xCA, 0x12, 0xDA, 0x1A, 0x16, 0x07, 0x5B, 0x12, 0xBA, 0xF8, 0xCC, 0x08, + 0x18, 0xF0, 0x02, 0xFD, 0xFE, 0xEF, 0x1E, 0xF1, 0xCA, 0xF5, 0x99, 0xE7, + 0xA9, 0xFA, 0x22, 0xE4, 0x04, 0xFE, 0x5D, 0xEA, 0x76, 0xFF, 0x20, 0xF8, + 0xAE, 0x04, 0xCD, 0x08, 0x55, 0x11, 0x00, 0x1A, 0x2E, 0x12, 0x00, 0x1B, + 0xE1, 0x10, 0xE1, 0x17, 0xC7, 0x0C, 0x0D, 0x14, 0x68, 0x01, 0x13, 0x0D, + 0xAE, 0xF4, 0xAB, 0x01, 0x52, 0xEE, 0x19, 0xF5, 0x96, 0xF0, 0x67, 0xEA, + 0x78, 0xF8, 0xFF, 0xE5, 0xA2, 0xFF, 0xEC, 0xE9, 0x48, 0x04, 0xAA, 0xF8, + 0x08, 0x0A, 0x37, 0x0D, 0x02, 0x0A, 0xD6, 0x17, 0xE4, 0x0A, 0x46, 0x1B, + 0xE2, 0x0E, 0x88, 0x1A, 0x92, 0x10, 0x5E, 0x16, 0x0D, 0x09, 0xB7, 0x0D, + 0x17, 0xFB, 0xE8, 0x00, 0x8B, 0xEE, 0xDE, 0xF3, 0xED, 0xEA, 0x5A, 0xE9, + 0x70, 0xF0, 0x37, 0xE4, 0x10, 0xFB, 0xC9, 0xE6, 0x40, 0x04, 0xD5, 0xF3, + 0x78, 0x08, 0xE1, 0x08, 0xB7, 0x08, 0x25, 0x13, 0xD8, 0x06, 0x43, 0x17, + 0x8F, 0x07, 0xC7, 0x17, 0xB1, 0x09, 0x36, 0x13, 0xE8, 0x07, 0x99, 0x09, + 0xDA, 0xFE, 0xB4, 0xFC, 0x17, 0xF3, 0x04, 0xF0, 0xB0, 0xEB, 0xA1, 0xE7, + 0x9C, 0xED, 0x9C, 0xE3, 0xA9, 0xF8, 0x73, 0xE7, 0x04, 0x07, 0x62, 0xF7, + 0x23, 0x0E, 0x52, 0x04, 0x28, 0x0F, 0x02, 0x11, 0x59, 0x0B, 0x1E, 0x1B, + 0xA6, 0x06, 0xDF, 0x1D, 0x1E, 0x05, 0x36, 0x18, 0x4D, 0x05, 0x60, 0x0C, + 0xBA, 0x01, 0x7F, 0xFD, 0x65, 0xFA, 0x81, 0xEF, 0x3A, 0xF1, 0x33, 0xE7, + 0x51, 0xEF, 0x6F, 0xE5, 0xF1, 0xF9, 0x8A, 0xEB, 0x29, 0x03, 0x56, 0xF7, + 0x00, 0x0D, 0xBD, 0x04, 0x94, 0x14, 0xA1, 0x11, 0xF0, 0x12, 0xF3, 0x1B, + 0x56, 0x0A, 0x22, 0x1E, 0x35, 0x01, 0xE5, 0x17, 0x2B, 0xFD, 0xDE, 0x0A, + 0xD3, 0xFA, 0x31, 0xFA, 0x57, 0xF7, 0x74, 0xEA, 0xBB, 0xF0, 0xFF, 0xE0, + 0x17, 0xED, 0x54, 0xE0, 0x15, 0xF2, 0x2A, 0xE7, 0xA7, 0xF9, 0x1A, 0xF4, + 0xB3, 0x04, 0x7A, 0x00, 0xC1, 0x10, 0x41, 0x0C, 0x7C, 0x14, 0xD5, 0x15, + 0x6F, 0x0D, 0x34, 0x19, 0xB4, 0x00, 0x88, 0x14, 0xA6, 0xF7, 0xF6, 0x08, + 0xF2, 0xF3, 0x30, 0xF9, 0x1E, 0xF4, 0xA8, 0xE9, 0x53, 0xF3, 0xF0, 0xDF, + 0x9C, 0xF0, 0x12, 0xDF, 0x1F, 0xF5, 0xF0, 0xEA, 0xFE, 0xFA, 0xD3, 0xF8, + 0xD0, 0x02, 0xBA, 0x04, 0x7D, 0x0E, 0x2D, 0x0F, 0xC6, 0x16, 0xDC, 0x17, + 0x60, 0x14, 0x13, 0x1B, 0x92, 0x08, 0x32, 0x17, 0x99, 0xFA, 0x12, 0x0C, + 0x42, 0xF3, 0x24, 0xFE, 0xEF, 0xF2, 0x43, 0xEE, 0x8B, 0xF3, 0xFA, 0xE1, + 0xED, 0xF9, 0xCA, 0xE4, 0xE8, 0xFD, 0x63, 0xEE, 0xDF, 0xFD, 0x0A, 0xFA, + 0x17, 0xFF, 0x5F, 0x05, 0x63, 0x06, 0xCD, 0x0E, 0xD3, 0x0F, 0x18, 0x16, + 0x2C, 0x13, 0x94, 0x17, 0x33, 0x0B, 0x35, 0x12, 0xD9, 0xFC, 0xB3, 0x06, + 0xB6, 0xF0, 0xE0, 0xF8, 0x32, 0xEC, 0xDF, 0xE9, 0xC7, 0xEF, 0xD2, 0xDC, + 0x12, 0xF6, 0x9D, 0xDF, 0x68, 0xFC, 0x1C, 0xE8, 0xEC, 0xFE, 0x53, 0xF3, + 0x33, 0xFF, 0x32, 0x00, 0xC6, 0x01, 0x2A, 0x0C, 0xBA, 0x08, 0x41, 0x14, + 0xDD, 0x0D, 0x46, 0x16, 0x8B, 0x0B, 0x4A, 0x10, 0x80, 0x00, 0xEE, 0x05, + 0x51, 0xF3, 0x95, 0xF8, 0xDF, 0xEA, 0x60, 0xE7, 0xEC, 0xEC, 0x49, 0xE6, + 0xA1, 0xF4, 0xE7, 0xE7, 0x7E, 0xFE, 0xED, 0xEA, 0x4F, 0x06, 0xC2, 0xF3, + 0xAA, 0x08, 0x49, 0x02, 0xB2, 0x07, 0xEF, 0x10, 0x74, 0x08, 0x1D, 0x1B, + 0x87, 0x0A, 0xA8, 0x1D, 0x52, 0x0B, 0x36, 0x18, 0xB8, 0x04, 0x92, 0x0B, + 0xD0, 0xF5, 0x6C, 0xF9, 0x6B, 0xF1, 0xC1, 0xF1, 0xE7, 0xEF, 0x90, 0xED, + 0x8B, 0xF0, 0x16, 0xEA, 0x11, 0xF8, 0x86, 0xE9, 0x34, 0x03, 0xB0, 0xF0, + 0xC9, 0x0A, 0x7B, 0xFE, 0x5A, 0x0B, 0xAA, 0x0D, 0xA0, 0x07, 0x03, 0x18, + 0xDA, 0x05, 0x6C, 0x1B, 0xAB, 0x04, 0x8F, 0x14, 0x29, 0xFE, 0x97, 0x04, + 0x3F, 0xFA, 0x3C, 0xF6, 0x00, 0xF5, 0xE5, 0xEB, 0x11, 0xEE, 0xF1, 0xE5, + 0x2D, 0xEA, 0xE9, 0xE3, 0xFE, 0xEE, 0xD2, 0xE5, 0x75, 0xFC, 0x6C, 0xEE, + 0xF1, 0x0A, 0xD1, 0xFC, 0x9A, 0x11, 0x07, 0x0D, 0x5C, 0x0F, 0xB9, 0x18, + 0xE3, 0x08, 0x01, 0x1D, 0x9D, 0x03, 0x4D, 0x17, 0x23, 0x00, 0xA3, 0x07, + 0x39, 0xFD, 0xAA, 0xFA, 0xD5, 0xFA, 0xA4, 0xF0, 0xC3, 0xF6, 0x49, 0xEA, + 0xFF, 0xF1, 0x82, 0xE9, 0x16, 0xF2, 0x6A, 0xED, 0xAA, 0xFB, 0x82, 0xF6, + 0x99, 0x0A, 0x7E, 0x04, 0x10, 0x16, 0x73, 0x13, 0x5D, 0x16, 0x6F, 0x1E, + 0xB1, 0x0D, 0x12, 0x21, 0x02, 0x04, 0xFE, 0x19, 0x81, 0xFC, 0x2D, 0x0D, + 0x2E, 0xF9, 0xA8, 0xFE, 0x73, 0xF9, 0xCE, 0xF0, 0x45, 0xF9, 0xB5, 0xE7, + 0x50, 0xF6, 0xD4, 0xE5, 0xE0, 0xF2, 0x86, 0xEA, 0xFD, 0xF5, 0x03, 0xF4, + 0x14, 0x01, 0x01, 0x02, 0x82, 0x0E, 0x9C, 0x0F, 0xE6, 0x12, 0xFC, 0x18, + 0x77, 0x0B, 0xE9, 0x1B, 0x56, 0x01, 0x69, 0x12, 0xBD, 0xF7, 0x0F, 0x06, + 0x96, 0xF1, 0x74, 0xFA, 0xD3, 0xF1, 0x6A, 0xEE, 0xB8, 0xF5, 0x7E, 0xE5, + 0x2E, 0xF9, 0x59, 0xE3, 0x1E, 0xF9, 0x78, 0xE9, 0xA1, 0xFA, 0x4D, 0xF5, + 0x8E, 0x01, 0xC4, 0x04, 0xF9, 0x0D, 0xD4, 0x13, 0xB0, 0x15, 0x4A, 0x1D, + 0x5A, 0x12, 0x7A, 0x1F, 0x80, 0x0A, 0x2C, 0x16, 0xEF, 0xFF, 0x37, 0x0B, + 0xEC, 0xF5, 0xBE, 0x01, 0xFF, 0xF1, 0x13, 0xF7, 0xC2, 0xF5, 0xB5, 0xED, + 0x70, 0xFD, 0x6C, 0xEA, 0xA7, 0x02, 0x6D, 0xEF, 0x85, 0x04, 0x50, 0xFB, + 0xC3, 0x06, 0x1C, 0x0A, 0x26, 0x0D, 0x6B, 0x18, 0x0E, 0x15, 0x45, 0x23, + 0x9B, 0x12, 0x44, 0x1E, 0xC7, 0x0B, 0xF3, 0x13, 0x64, 0x02, 0x95, 0x09, + 0xDF, 0xF6, 0xE9, 0xFF, 0x1A, 0xEE, 0x08, 0xF5, 0x6E, 0xED, 0x07, 0xEB, + 0x4D, 0xF4, 0xF8, 0xE4, 0x39, 0xFE, 0x62, 0xE8, 0xAE, 0x02, 0x19, 0xF2, + 0x96, 0x04, 0x87, 0x01, 0x04, 0x0A, 0x8C, 0x13, 0x2E, 0x08, 0x84, 0x17, + 0x59, 0x07, 0x08, 0x15, 0xCB, 0x07, 0x43, 0x0F, 0xBB, 0x04, 0x54, 0x06, + 0x75, 0xFC, 0xE3, 0xFC, 0xAE, 0xF1, 0x51, 0xF3, 0xE5, 0xEB, 0x0D, 0xEB, + 0xAA, 0xEF, 0x97, 0xE6, 0x1D, 0xFB, 0x6F, 0xEA, 0x53, 0x06, 0x9E, 0xF5, + 0x0B, 0x0C, 0x33, 0x06, 0x4E, 0x0D, 0x6C, 0x18, 0x19, 0x0B, 0xE5, 0x1C, + 0x05, 0x09, 0x31, 0x1C, 0xD9, 0x08, 0x08, 0x18, 0xE9, 0x07, 0x51, 0x0E, + 0xF3, 0x03, 0xCE, 0x02, 0x21, 0xFB, 0x71, 0xF8, 0x88, 0xF2, 0xFB, 0xEF, + 0x85, 0xF0, 0x05, 0xEC, 0x3A, 0xF9, 0x3E, 0xEE, 0x88, 0x06, 0xF8, 0xF8, + 0x0D, 0x10, 0x62, 0x0B, 0xEF, 0x10, 0x1E, 0x13, 0x6F, 0x0C, 0x7F, 0x17, + 0xE3, 0x05, 0x05, 0x1A, 0x3C, 0x01, 0xCB, 0x16, 0x29, 0xFF, 0xA8, 0x0B, + 0x1A, 0xFE, 0xBE, 0xFC, 0xAB, 0xF9, 0x92, 0xEE, 0x85, 0xF2, 0x37, 0xE5, + 0x7C, 0xEC, 0x8A, 0xE0, 0x09, 0xF1, 0x6B, 0xE4, 0xDD, 0xFF, 0x74, 0xF2, + 0x01, 0x09, 0xCC, 0xFE, 0xB0, 0x0D, 0x39, 0x09, 0xCD, 0x0D, 0x8E, 0x11, + 0x11, 0x08, 0xA1, 0x16, 0xB6, 0x00, 0x97, 0x15, 0xD0, 0xFA, 0x4C, 0x0C, + 0x29, 0xFA, 0x84, 0xFD, 0x7C, 0xFA, 0x9B, 0xEF, 0xC5, 0xF8, 0xE6, 0xE6, + 0x16, 0xF4, 0xB7, 0xE4, 0x71, 0xF5, 0xDC, 0xEA, 0x3E, 0x01, 0x32, 0xF9, + 0x53, 0x09, 0x01, 0x07, 0xF6, 0x10, 0x92, 0x12, 0xD1, 0x15, 0x56, 0x1A, + 0x48, 0x12, 0x3F, 0x1D, 0x01, 0x08, 0xFC, 0x1A, 0xAF, 0xFC, 0x7B, 0x11, + 0xDE, 0xF6, 0x68, 0x02, 0x6C, 0xF7, 0x16, 0xF3, 0x34, 0xF9, 0x90, 0xE8, + 0x11, 0xF8, 0x9A, 0xE5, 0x77, 0xF8, 0xA1, 0xEB, 0x53, 0xFB, 0xF2, 0xF6, + 0x2D, 0x01, 0x87, 0x03, 0xFC, 0x09, 0xCA, 0x0E, 0x07, 0x11, 0xF7, 0x14, + 0xB9, 0x10, 0x71, 0x15, 0x54, 0x07, 0xBD, 0x10, 0x3C, 0xF9, 0x11, 0x07, + 0xB1, 0xED, 0x92, 0xF8, 0x98, 0xEB, 0x70, 0xE9, 0xBE, 0xEF, 0x18, 0xDF, + 0x8D, 0xF2, 0x6D, 0xDB, 0x98, 0xF8, 0x9F, 0xE4, 0xE2, 0xFB, 0x1F, 0xF1, + 0x41, 0xFE, 0x84, 0xFE, 0x1E, 0x04, 0xB4, 0x0B, 0xA1, 0x0B, 0xE2, 0x14, + 0x70, 0x10, 0x74, 0x16, 0x4B, 0x0D, 0x73, 0x12, 0xA9, 0x02, 0x9A, 0x09, + 0xC1, 0xF5, 0x0D, 0xFE, 0x82, 0xEF, 0x75, 0xF0, 0x1D, 0xF2, 0x64, 0xE4, + 0x82, 0xFA, 0x86, 0xE7, 0x94, 0x02, 0x67, 0xF0, 0xE1, 0x06, 0xA3, 0xF9, + 0x6A, 0x07, 0xA4, 0x04, 0x55, 0x08, 0x38, 0x11, 0xF6, 0x0A, 0xDA, 0x1A, + 0x3B, 0x0E, 0x1C, 0x1C, 0x99, 0x0D, 0x5B, 0x16, 0x02, 0x07, 0xD5, 0x0B, + 0xCF, 0xF9, 0xB6, 0xFE, 0xFC, 0xEE, 0x7B, 0xF0, 0xFD, 0xED, 0x2E, 0xE4, + 0x3D, 0xF3, 0xEB, 0xE5, 0xBE, 0xFB, 0x42, 0xEC, 0x79, 0x03, 0xB1, 0xF2, + 0x52, 0x06, 0xA5, 0xFB, 0x86, 0x05, 0x30, 0x07, 0x60, 0x03, 0xE7, 0x10, + 0x48, 0x02, 0x92, 0x13, 0xEB, 0x01, 0x3B, 0x0D, 0x6A, 0xFF, 0x4E, 0x02, + 0x2F, 0xF7, 0x38, 0xF5, 0x1A, 0xEB, 0xC9, 0xE4, 0xF4, 0xE9, 0x53, 0xE2, + 0x06, 0xEE, 0x5D, 0xE4, 0x72, 0xF6, 0xC1, 0xE8, 0xA7, 0x01, 0x7E, 0xF0, + 0xB1, 0x0A, 0xDF, 0xFB, 0xA0, 0x0D, 0x4C, 0x09, 0x54, 0x0B, 0x32, 0x16, + 0x31, 0x06, 0x6F, 0x1B, 0xF8, 0x03, 0xC4, 0x17, 0x85, 0x02, 0x58, 0x0C, + 0x46, 0xFB, 0x5F, 0xFB, 0x92, 0xFA, 0xDC, 0xF3, 0x00, 0xF8, 0xFC, 0xEF, + 0xE7, 0xF3, 0xA1, 0xED, 0x71, 0xF5, 0x88, 0xEF, 0xBB, 0xFE, 0x18, 0xF7, + 0x5A, 0x0B, 0x3F, 0x02, 0x16, 0x13, 0x69, 0x0E, 0xE0, 0x12, 0x57, 0x19, + 0x21, 0x0B, 0xC8, 0x1D, 0x96, 0x02, 0xCC, 0x18, 0xB8, 0xFD, 0x70, 0x0B, + 0xF3, 0xFA, 0xE4, 0xF9, 0x8B, 0xF9, 0xB6, 0xEF, 0xCC, 0xF6, 0x69, 0xE9, + 0x30, 0xF1, 0xC0, 0xE4, 0xCB, 0xEE, 0x0F, 0xE6, 0x23, 0xF4, 0x2C, 0xEE, + 0x24, 0x00, 0x36, 0xFA, 0x37, 0x0B, 0x49, 0x06, 0x96, 0x0F, 0xE1, 0x0F, + 0x62, 0x09, 0xF1, 0x14, 0x9A, 0xFE, 0x1F, 0x11, 0x0F, 0xF7, 0xA5, 0x03, + 0xA6, 0xF3, 0xCE, 0xF7, 0x69, 0xF5, 0x90, 0xEE, 0xC5, 0xF8, 0x36, 0xE8, + 0x51, 0xF8, 0x47, 0xE5, 0x1A, 0xF7, 0x0F, 0xE9, 0x40, 0xF9, 0x52, 0xF4, + 0xF7, 0x01, 0xB6, 0x03, 0x29, 0x0D, 0x9C, 0x11, 0x31, 0x15, 0x6B, 0x1B, + 0xFB, 0x12, 0x74, 0x1F, 0xF9, 0x06, 0x3B, 0x1A, 0x84, 0xFD, 0x0D, 0x10, + 0xD0, 0xF7, 0xD3, 0x03, 0x3B, 0xF7, 0x50, 0xF8, 0x4A, 0xFB, 0x2E, 0xF0, + 0x86, 0xFE, 0x56, 0xEC, 0x47, 0xFF, 0x46, 0xEE, 0xE4, 0xFE, 0xD0, 0xF7, + 0x44, 0x02, 0x3C, 0x06, 0xB4, 0x08, 0x8A, 0x13, 0x6A, 0x10, 0x11, 0x1B, + 0xC9, 0x10, 0xCC, 0x1B, 0x5E, 0x06, 0xDA, 0x15, 0xC8, 0xFC, 0xA4, 0x08, + 0x36, 0xF3, 0x87, 0xFA, 0x09, 0xED, 0xA4, 0xEE, 0x33, 0xEF, 0xFD, 0xE6, + 0x87, 0xF5, 0x72, 0xE3, 0x66, 0xFB, 0x74, 0xE5, 0x9D, 0xFE, 0x5C, 0xEE, + 0xC7, 0x00, 0xD6, 0xFD, 0x89, 0x04, 0xC3, 0x0C, 0x16, 0x0A, 0x3D, 0x16, + 0xBC, 0x0C, 0x52, 0x19, 0x5C, 0x09, 0x5E, 0x10, 0x66, 0x02, 0x2D, 0x06, + 0xC5, 0xF8, 0xBB, 0xFC, 0xC5, 0xF0, 0x1B, 0xF4, 0xD9, 0xEF, 0x31, 0xEE, + 0xC8, 0xF6, 0x8B, 0xEC, 0xF9, 0x00, 0x71, 0xEF, 0xB6, 0x09, 0xB2, 0xF8, + 0x72, 0x0D, 0x29, 0x07, 0x5A, 0x0E, 0x15, 0x17, 0xA5, 0x10, 0xEC, 0x21, + 0x73, 0x0D, 0xD1, 0x1F, 0xDB, 0x0A, 0xD8, 0x17, 0xDD, 0x08, 0xAB, 0x0E, + 0x96, 0x02, 0xA0, 0x04, 0x12, 0xF9, 0xE8, 0xF9, 0xAD, 0xF1, 0x6B, 0xF1, + 0xAC, 0xF2, 0x0D, 0xEE, 0x48, 0xFA, 0xA7, 0xEF, 0xD1, 0x04, 0xBF, 0xF6, + 0x0C, 0x0B, 0x82, 0x02, 0xB9, 0x0B, 0x57, 0x10, 0xDD, 0x08, 0xC0, 0x1A, + 0xB9, 0x02, 0x0C, 0x16, 0x83, 0xFE, 0xB4, 0x0C, 0x48, 0xFE, 0xB3, 0x03, + 0x92, 0xFC, 0x15, 0xFA, 0xC2, 0xF6, 0x94, 0xEF, 0x2F, 0xEF, 0x64, 0xE7, + 0x90, 0xEC, 0xEC, 0xE4, 0xD1, 0xF1, 0x3D, 0xE9, 0x33, 0xFE, 0xC1, 0xF1, + 0xB5, 0x09, 0x32, 0xFF, 0x7F, 0x0E, 0x38, 0x11, 0x78, 0x0C, 0x45, 0x15, + 0x39, 0x06, 0x28, 0x15, 0x4C, 0x00, 0x76, 0x12, 0xE6, 0xFE, 0x87, 0x0C, + 0x14, 0x00, 0xA4, 0x03, 0xB7, 0xFF, 0x23, 0xF9, 0xBF, 0xFB, 0x1F, 0xF0, + 0x11, 0xF8, 0xA5, 0xED, 0x88, 0xF9, 0xD7, 0xF1, 0x3D, 0x02, 0xD2, 0xFB, + 0xE2, 0x0F, 0xBB, 0x0B, 0x7D, 0x14, 0xC0, 0x13, 0xB2, 0x13, 0x32, 0x19, + 0xE7, 0x0D, 0x27, 0x1C, 0x67, 0x04, 0x5B, 0x19, 0xC1, 0xFC, 0x91, 0x10, + 0x05, 0xFB, 0xAC, 0x04, 0xAC, 0xFB, 0x60, 0xF7, 0x74, 0xFB, 0x1D, 0xEC, + 0x9E, 0xF7, 0x1E, 0xE6, 0x05, 0xF6, 0x86, 0xE9, 0xBD, 0xFD, 0x5B, 0xF5, + 0xB5, 0x01, 0x82, 0xFF, 0xDB, 0x06, 0x52, 0x07, 0xB8, 0x0C, 0xD6, 0x0D, + 0x2E, 0x0C, 0x58, 0x11, 0x63, 0x03, 0xD5, 0x0E, 0xAF, 0xF7, 0x2F, 0x06, + 0x33, 0xF1, 0xF8, 0xFA, 0xDA, 0xF0, 0x69, 0xEF, 0x25, 0xF4, 0x88, 0xE5, + 0x20, 0xF6, 0x3A, 0xE1, 0xC0, 0xF7, 0xB2, 0xE6, 0x47, 0xFC, 0x9D, 0xF4, + 0x1A, 0x01, 0xF2, 0x01, 0x57, 0x07, 0xAF, 0x0C, 0xAF, 0x0F, 0xF1, 0x14, + 0x38, 0x13, 0x14, 0x19, 0x6E, 0x0E, 0x28, 0x17, 0xC1, 0x02, 0x01, 0x0F, + 0x53, 0xF8, 0x05, 0x04, 0x81, 0xF4, 0x32, 0xF9, 0xC1, 0xF7, 0x27, 0xF0, + 0x1C, 0xFD, 0xF9, 0xEB, 0x8F, 0x00, 0x60, 0xF0, 0xE8, 0x04, 0x8B, 0xFB, + 0x1E, 0x07, 0x3B, 0x08, 0x4C, 0x08, 0x3E, 0x12, 0xC6, 0x0B, 0x32, 0x18, + 0x2C, 0x0F, 0x77, 0x19, 0x78, 0x0D, 0xB6, 0x14, 0x35, 0x04, 0x86, 0x0A, + 0x14, 0xF8, 0xE3, 0xFC, 0x6B, 0xEF, 0xDA, 0xF0, 0xE4, 0xEE, 0x3F, 0xE7, + 0x8E, 0xF4, 0x1C, 0xE2, 0x3F, 0xFB, 0x9B, 0xE6, 0xF8, 0xFF, 0xB5, 0xEF, + 0xBF, 0x01, 0x95, 0xFA, 0x11, 0x01, 0x68, 0x05, 0x8D, 0x01, 0xD8, 0x0C, + 0xE1, 0x03, 0xB1, 0x0F, 0x9E, 0x05, 0xAB, 0x0C, 0x09, 0x02, 0xEF, 0x03, + 0xB3, 0xF9, 0xAD, 0xF7, 0xA8, 0xF0, 0x6D, 0xED, 0x54, 0xEE, 0xF8, 0xE6, + 0xA0, 0xF4, 0x4F, 0xE4, 0x7D, 0xFC, 0xDA, 0xEC, 0x45, 0x05, 0x8F, 0xF7, + 0xC0, 0x0B, 0xB8, 0x02, 0xA6, 0x0C, 0x0A, 0x0E, 0xFB, 0x09, 0x2C, 0x16, + 0x67, 0x07, 0x19, 0x19, 0xD2, 0x06, 0x5A, 0x16, 0x7E, 0x05, 0x52, 0x0D, + 0x89, 0x00, 0x7D, 0x01, 0xFB, 0xF8, 0xB3, 0xF5, 0x0F, 0xF3, 0x80, 0xEB, + 0x53, 0xF5, 0x5C, 0xEF, 0x75, 0xFB, 0x2E, 0xF5, 0xA6, 0x03, 0x15, 0xFA, + 0xA8, 0x0B, 0x27, 0x01, 0xC3, 0x0E, 0x72, 0x0A, 0x89, 0x0A, 0x6E, 0x11, + 0x7E, 0x03, 0x8D, 0x13, 0x73, 0xFD, 0x71, 0x0F, 0x8B, 0xFB, 0x13, 0x07, + 0xFC, 0xF8, 0x64, 0xF9, 0xD0, 0xF1, 0x16, 0xEA, 0xC5, 0xF0, 0xED, 0xE4, + 0x96, 0xF0, 0x98, 0xE5, 0x0E, 0xF1, 0xCD, 0xE8, 0xD5, 0xF6, 0x85, 0xEE, + 0x3D, 0x01, 0x79, 0xF7, 0x79, 0x0A, 0xF6, 0x02, 0xEA, 0x0B, 0x36, 0x0C, + 0x5F, 0x06, 0x20, 0x10, 0x8E, 0xFE, 0x2A, 0x0E, 0xEC, 0xFA, 0x9C, 0x07, + 0x13, 0xFA, 0x88, 0xFC, 0x86, 0xF8, 0xE5, 0xEE, 0xC8, 0xFA, 0x9E, 0xEC, + 0xA4, 0xFB, 0x98, 0xEE, 0x65, 0xFA, 0xAE, 0xF2, 0xB3, 0xFC, 0x53, 0xF9, + 0x59, 0x04, 0xBE, 0x02, 0x88, 0x0E, 0xA1, 0x0D, 0xBE, 0x13, 0x75, 0x16, + 0x0E, 0x10, 0x2F, 0x19, 0x6C, 0x06, 0x6A, 0x16, 0xCD, 0xFD, 0x1F, 0x0E, + 0xB1, 0xF9, 0x6C, 0xFF, 0x4B, 0xFA, 0x97, 0xF8, 0x9B, 0xFC, 0xDB, 0xF2, + 0xCE, 0xFD, 0xAE, 0xEE, 0x2A, 0xFC, 0x35, 0xEF, 0xD5, 0xFA, 0xAF, 0xF4, + 0x73, 0xFD, 0xB9, 0xFD, 0x00, 0x05, 0x2E, 0x08, 0x8B, 0x0B, 0x69, 0x10, + 0x40, 0x0B, 0xA8, 0x12, 0x71, 0x02, 0x82, 0x0D, 0x6D, 0xF7, 0xC8, 0x02, + 0x92, 0xF0, 0x62, 0xF8, 0x93, 0xEF, 0xCB, 0xEF, 0xFA, 0xF2, 0x08, 0xE9, + 0x2A, 0xF8, 0x41, 0xE5, 0x7E, 0xFB, 0x93, 0xE7, 0x70, 0xFC, 0xD4, 0xEF, + 0xBF, 0xFD, 0xC0, 0xFB, 0x9D, 0x02, 0x8F, 0x08, 0x42, 0x09, 0x09, 0x13, + 0x24, 0x0D, 0xEF, 0x16, 0xF5, 0x08, 0x1A, 0x13, 0xEB, 0xFD, 0x25, 0x09, + 0x21, 0xF9, 0x6A, 0x00, 0xCE, 0xF6, 0xBE, 0xF9, 0x8E, 0xF7, 0x72, 0xF4, + 0xAA, 0xFC, 0x20, 0xF1, 0x06, 0x03, 0xF5, 0xF2, 0x0E, 0x07, 0x75, 0xFA, + 0x1C, 0x08, 0x8F, 0x05, 0x64, 0x08, 0xE9, 0x10, 0x3F, 0x0B, 0xD7, 0x19, + 0x20, 0x0D, 0x27, 0x1C, 0x82, 0x09, 0x98, 0x16, 0x1A, 0x05, 0x0F, 0x0C, + 0x11, 0xFE, 0x0B, 0x01, 0x50, 0xF6, 0x2B, 0xF8, 0xD9, 0xF1, 0x6D, 0xF1, + 0xAC, 0xF3, 0x27, 0xED, 0x1E, 0xFB, 0x9B, 0xED, 0xDC, 0x02, 0xD4, 0xF3, + 0xDD, 0x06, 0xCE, 0xFD, 0x0E, 0x06, 0xD2, 0x07, 0x67, 0x04, 0x3C, 0x0F, + 0xE2, 0x04, 0xC8, 0x12, 0x7A, 0x01, 0xA6, 0x0B, 0x13, 0xFE, 0xB9, 0x01, + 0xF7, 0xFA, 0x5E, 0xF8, 0x09, 0xF6, 0x45, 0xF1, 0x51, 0xF1, 0xAA, 0xEC, + 0xEC, 0xF0, 0x3C, 0xEB, 0x89, 0xF7, 0xE1, 0xED, 0x48, 0x02, 0xA1, 0xF6, + 0x1C, 0x0B, 0xFA, 0x01, 0x71, 0x0D, 0xDC, 0x0D, 0xDA, 0x0B, 0xEF, 0x17, + 0xF7, 0x06, 0x5E, 0x17, 0x99, 0x03, 0x17, 0x13, 0xB2, 0x02, 0x14, 0x0D, + 0xB9, 0x02, 0xEE, 0x04, 0x40, 0x00, 0xAD, 0xFC, 0xD4, 0xFB, 0x9F, 0xF6, + 0xE0, 0xF7, 0x2F, 0xF4, 0x7E, 0xF9, 0xBD, 0xF5, 0x71, 0x01, 0xB6, 0xFC, + 0x81, 0x0B, 0x1C, 0x07, 0x27, 0x10, 0x32, 0x11, 0x33, 0x0D, 0x0D, 0x19, + 0x6D, 0x07, 0x33, 0x16, 0xE6, 0x00, 0x0F, 0x10, 0x81, 0xFC, 0x9D, 0x09, + 0x67, 0xFB, 0xB7, 0x00, 0x83, 0xFB, 0x15, 0xF7, 0xD4, 0xF9, 0x93, 0xEF, + 0x45, 0xF6, 0xB4, 0xEB, 0x9E, 0xF4, 0xB1, 0xEC, 0x05, 0xF9, 0x8A, 0xF2, + 0x57, 0x02, 0x2B, 0xFD, 0x4D, 0x0A, 0x57, 0x0A, 0x2E, 0x0A, 0x73, 0x0C, + 0x56, 0x05, 0x0C, 0x0B, 0x53, 0xFE, 0x0E, 0x09, 0x5F, 0xF8, 0xC6, 0x05, + 0x87, 0xF6, 0x42, 0xFF, 0x2B, 0xF9, 0x57, 0xF7, 0x2F, 0xFC, 0xAA, 0xF0, + 0xBB, 0xFD, 0xA3, 0xEE, 0xA5, 0xFC, 0xB0, 0xF0, 0x4B, 0xFF, 0xC3, 0xF8, + 0x76, 0x08, 0x81, 0x06, 0xA3, 0x0C, 0x1C, 0x0F, 0x00, 0x0F, 0x2D, 0x14, + 0x0B, 0x0F, 0x9E, 0x15, 0x99, 0x09, 0xB4, 0x13, 0x6F, 0x01, 0xC9, 0x0E, + 0x7C, 0xFA, 0xE8, 0x06, 0x22, 0xF9, 0x9D, 0xFD, 0xCC, 0xFB, 0x83, 0xF5, + 0x80, 0xFF, 0x4C, 0xF2, 0x01, 0x00, 0x7B, 0xF3, 0x9F, 0x00, 0x1D, 0xFA, + 0x07, 0x05, 0xF7, 0x05, 0x39, 0x06, 0x29, 0x0C, 0x26, 0x08, 0xB2, 0x0F, + 0x34, 0x0A, 0xBD, 0x10, 0x7C, 0x07, 0x5A, 0x0D, 0xD6, 0xFF, 0xBE, 0x06, + 0x4F, 0xF6, 0x02, 0xFE, 0xD1, 0xF0, 0x07, 0xF4, 0x94, 0xF1, 0x1B, 0xEC, + 0xA3, 0xF6, 0x4B, 0xE8, 0x75, 0xFB, 0x95, 0xEA, 0x60, 0xFE, 0x8C, 0xF3, + 0x8A, 0xFF, 0x6D, 0xFB, 0xB8, 0x00, 0x66, 0x03, 0x5E, 0x03, 0x1E, 0x0B, + 0x06, 0x07, 0x51, 0x0F, 0x0B, 0x08, 0xAA, 0x0D, 0x4E, 0x04, 0xC1, 0x07, + 0xF2, 0xFC, 0xED, 0xFF, 0x26, 0xF6, 0x9F, 0xF7, 0xA5, 0xF4, 0x29, 0xF1, + 0xEB, 0xF9, 0x1D, 0xEF, 0x04, 0x01, 0xDE, 0xF2, 0x4E, 0x07, 0xBD, 0xFB, + 0xD1, 0x09, 0xCF, 0x04, 0x04, 0x09, 0xA3, 0x0C, 0xA5, 0x07, 0x48, 0x13, + 0x8A, 0x07, 0xFA, 0x15, 0xD2, 0x07, 0x50, 0x13, 0x90, 0x06, 0xED, 0x0B, + 0xAC, 0x01, 0xCB, 0x02, 0xC1, 0xFA, 0xA0, 0xF9, 0x98, 0xF5, 0x01, 0xF2, + 0xE5, 0xF6, 0xC3, 0xEE, 0xC3, 0xFE, 0xC8, 0xF1, 0xA3, 0x03, 0xD7, 0xF8, + 0xCB, 0x06, 0x3C, 0x00, 0xF4, 0x06, 0x3B, 0x06, 0x39, 0x04, 0x03, 0x0B, + 0x7E, 0x00, 0xFB, 0x0C, 0x5A, 0xFE, 0x2D, 0x0A, 0x42, 0xFD, 0xBD, 0x02, + 0xA6, 0xFB, 0x83, 0xF9, 0xFD, 0xF6, 0x9C, 0xF0, 0x1E, 0xF2, 0xED, 0xE9, + 0x7A, 0xF2, 0x11, 0xE7, 0x25, 0xF6, 0x93, 0xEC, 0x4B, 0xFD, 0x18, 0xF5, + 0x93, 0x05, 0xD6, 0xFD, 0xB7, 0x0A, 0x96, 0x05, 0x22, 0x0A, 0x98, 0x0B, + 0x3F, 0x05, 0x08, 0x0F, 0x41, 0x00, 0x11, 0x0E, 0x88, 0xFD, 0x5E, 0x08, + 0xD3, 0xFD, 0x93, 0x00, 0x0B, 0xFD, 0xC4, 0xF8, 0x18, 0xF9, 0xDD, 0xF0, + 0x48, 0xFA, 0xE8, 0xF2, 0x7F, 0xFC, 0x41, 0xF7, 0x0D, 0x00, 0x48, 0xFD, + 0x9C, 0x06, 0x0D, 0x04, 0xB4, 0x0C, 0x08, 0x0B, 0x5C, 0x0E, 0xC6, 0x0F, + 0xF3, 0x09, 0xED, 0x11, 0x58, 0x02, 0xC1, 0x0F, 0x1C, 0xFC, 0x49, 0x09, + 0x43, 0xFA, 0xE1, 0xFF, 0x18, 0xFB, 0xCE, 0xF7, 0x4C, 0x49, 0x53, 0x54, + 0x74, 0x00, 0x00, 0x00, 0x49, 0x4E, 0x46, 0x4F, 0x49, 0x4E, 0x41, 0x4D, + 0x1C, 0x00, 0x00, 0x00, 0x53, 0x6F, 0x75, 0x6E, 0x64, 0x42, 0x69, 0x62, + 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x20, 0x4D, 0x75, 0x73, 0x74, 0x20, + 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, 0x00, 0x00, 0x49, 0x41, 0x52, 0x54, + 0x1C, 0x00, 0x00, 0x00, 0x53, 0x6F, 0x75, 0x6E, 0x64, 0x42, 0x69, 0x62, + 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x20, 0x4D, 0x75, 0x73, 0x74, 0x20, + 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, 0x00, 0x00, 0x49, 0x43, 0x4F, 0x50, + 0x20, 0x00, 0x00, 0x00, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, + 0x69, 0x6F, 0x6E, 0x20, 0x33, 0x2E, 0x30, 0x20, 0x53, 0x6F, 0x75, 0x6E, + 0x64, 0x42, 0x69, 0x62, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x00, 0x00, + 0x69, 0x64, 0x33, 0x20, 0x88, 0x00, 0x00, 0x00, 0x49, 0x44, 0x33, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x54, 0x49, 0x54, 0x32, 0x00, 0x00, + 0x00, 0x1B, 0x00, 0x00, 0x00, 0x53, 0x6F, 0x75, 0x6E, 0x64, 0x42, 0x69, + 0x62, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x20, 0x4D, 0x75, 0x73, 0x74, + 0x20, 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, 0x54, 0x50, 0x45, 0x31, 0x00, + 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x53, 0x6F, 0x75, 0x6E, 0x64, 0x42, + 0x69, 0x62, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x20, 0x4D, 0x75, 0x73, + 0x74, 0x20, 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, 0x54, 0x58, 0x58, 0x58, + 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x43, 0x6F, 0x70, 0x79, 0x72, + 0x69, 0x67, 0x68, 0x74, 0x00, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, + 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x33, 0x2E, 0x30, 0x20, 0x53, 0x6F, 0x75, + 0x6E, 0x64, 0x42, 0x69, 0x62, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x00 +}; + +``` + +`chams.cpp`: + +```cpp +#include "chams.hpp" +#include "source.hpp" +#include "entity.hpp" +#include "player.hpp" +#include "weapon.hpp" +#include "hooked.hpp" +#include "math.hpp" +#include "displacement.hpp" +#include "lag_comp.hpp" +#include "resolver.hpp" +#include "usercmd.hpp" +#include "anti_aimbot.hpp" +#include +#include +#include "menu.hpp" +#include "visuals.hpp" + +#include +#include +#include +//if (ctx.m_settings.chams_backtrack && !ctx.m_local()->IsDead() && log->player == entity && log->oldest_valid_record && log->pre_old_valid_record && (entity->get_abs_origin() - log->oldest_valid_record->origin).LengthSquared() > 10.f) +//{ +// static c_chams_settings b_settings; + +// b_settings.color = ctx.m_settings.colors_chams_backtrack; +// b_settings.hidden_color = ctx.m_settings.colors_chams_backtrack; +// b_settings.white_color = Color::White(); +// b_settings.reflectivity_clr = ctx.m_settings.chams_reflectivity_c_backtrack; +// b_settings.reflectivity = ctx.m_settings.chams_reflectivity_backtrack; +// b_settings.shine = ctx.m_settings.chams_shine_backtrack; +// b_settings.pearlescent = ctx.m_settings.chams_pearlescent_backtrack; +// b_settings.rim = ctx.m_settings.chams_rim_backtrack; +// b_settings.type = ctx.m_settings.chams_material_backtrack; +// b_settings.wireframe = ctx.m_settings.chams_wireframe_backtrack; +// b_settings.redraw = ctx.m_settings.chams_redraw_backtrack; +// b_settings.setting_type = 3; + +// //const auto backup_lol = entity->GetBoneCount(); +// memcpy(render_matrix, log->oldest_valid_record->matrixes, sizeof(matrix3x4_t) * 128); + +// static bool lol[] = { true,true }; + +// //float time = csgo.m_globals()->curtime; +// //float interval = csgo.m_globals()->interval_per_tick; + +// float time = feature::lagcomp->get_interpolated_time(); +// +// /* +// float LagCompensation::GetInterpolatedTime(int tickbase_shift) +// { +// int tick_count = g_GlobalVars->tickcount; +// if (g_LocalPlayer) +// tick_count = g_LocalPlayer->m_nFinalPredictedTick();// NETVAR_EX(int, m_nFinalPredictedTick, "DT_BasePlayer", "m_nTickBase", 0x4); + +// auto curtime = ((TICKS_TO_TIME(tick_count - tickbase_shift) +// - g_GlobalVars->interval_per_tick) + (g_GlobalVars->interpolation_amount * g_GlobalVars->interval_per_tick)) +// - (LagCompensation::_lerp_time + LagCompensation::_latency); + +// return curtime; +// } +// */ + +// /* +// if (record->render_time >= lerped_render_time && lerped_render_time >= previous_record->render_time) +// { +// auto v1 = record->render_time - lerped_render_time; +// auto v2 = record->render_time - previous_record->render_time; +// auto lerp_time = 1.0f - std::fminf(v1 / v2, 1.0f); +// auto pos = previous_record->origin + (record->origin - previous_record->origin) * lerp_time; +// } +// */ + +// auto v24 = log->oldest_valid_record->animation_time; +// auto v25 = Math::clamp(v24, time - 0.2f, time + 0.2f); +// float interpolation = (time - v24) / (log->pre_old_valid_record->animation_time - v24); +// interpolation = Math::clamp(interpolation, 0, 1); +// Vector lerp = Math::Lerp(log->oldest_valid_record->origin, log->pre_old_valid_record->origin, interpolation); + +// const auto distance = (entity->get_abs_origin() - lerp).LengthSquared(); + +// if (entity->m_bone_count() > 0 && distance > 10) +// { +// const auto alpha = Math::clamp(distance * 0.002f, 0, 1); +// b_settings.color._a() = b_settings.color.malpha(alpha); + +// for (size_t i{ }; i < 128; ++i) +// { +// render_matrix[i][0][3] -= log->oldest_valid_record->origin.x; +// render_matrix[i][1][3] -= log->oldest_valid_record->origin.y; +// render_matrix[i][2][3] -= log->oldest_valid_record->origin.z; + +// render_matrix[i][0][3] += lerp.x; +// render_matrix[i][1][3] += lerp.y; +// render_matrix[i][2][3] += lerp.z; +// } + +// c_chams::player_chams(extra_chams, b_settings, false, lol); +// } + +// //entity->GetBoneCount() = backup_lol; + +// //return odme; +//} + +std::vector hit_chams; + +void c_chams::set_ignorez(const bool enabled, IMaterial* mat) +{ + if (!csgo.m_engine()->IsInGame() || ctx.m_local() == nullptr || mat == nullptr) + return; + + if (mat && !mat->IsErrorMaterial()) { + mat->SetMaterialVarFlag(MATERIAL_VAR_IGNOREZ, enabled); + mat->SetMaterialVarFlag(MATERIAL_VAR_ZNEARER, enabled); + mat->SetMaterialVarFlag(MATERIAL_VAR_NOFOG, enabled); + } +} + +void c_chams::set_wireframe(const bool enabled, IMaterial* mat) +{ + if (!csgo.m_engine()->IsInGame() || ctx.m_local() == nullptr || mat == nullptr) + return; + + if (mat && !mat->IsErrorMaterial()) + mat->SetMaterialVarFlag(MATERIAL_VAR_WIREFRAME, enabled); +} + +IMaterial* c_chams::get_material(int material) { + + if (!csgo.m_engine()->IsInGame() || ctx.m_local() == nullptr) + return 0; + + static bool init_materials = false; + + if (!init_materials) { + std::ofstream(sxor("csgo\\materials\\dsv_textured.vmt")) << R"("VertexLitGeneric" + { + "$basetexture" "vgui/white_additive" + "$model" "1" + "$flat" "0" + "$nocull" "1" + "$halflambert" "1" + "$nofog" "1" + "$ignorez" "0" + "$znearer" "0" + "$wireframe" "0" + })"; + + std::ofstream(sxor("csgo\\materials\\skeet_glow.vmt")) << R"("VertexLitGeneric" { + "$basetexture" "models/effects/cube_white" + "$additive" "1" + "$envmap" "models/effects/cube_white" + "$envmaptint" "[1.0 1.0. 1.0]" + "$envmapfresnel" "1.0" + "$envmapfresnelminmaxexp" "[0.0 1.0 2.0]" + "$alpha" "0.99" + })"; + + + std::ofstream(sxor("csgo\\materials\\dsv_flat.vmt")) << R"("VertexLitGeneric" + { + "$basetexture" "vgui/white" + "$ignorez" "0" + "$envmap" " " + "$nofog" "1" + "$model" "1" + "$nocull" "0" + "$selfillum" "1" + "$halflambert" "1" + "$znearer" "0" + "$flat" "0" + "$wireframe" "0" + })"; + init_materials = true; + } + + switch (material) + { + default: + case 0: /* flat */ + return csgo.m_material_system()->FindMaterial(sxor("dsv_flat")); + case 1: /* flat */ + return csgo.m_material_system()->FindMaterial(sxor("dsv_flat")); + case 2: /* glowing */ + return csgo.m_material_system()->FindMaterial(sxor("dev/glow_armsrace")); + } +} + +void InitKeyValues(KeyValues* keyValues, const char* name) +{ + if (!Engine::Displacement::Signatures[c_signatures::INIT_KEY_VALUES]) { + return; + } + + auto pfunc = Engine::Displacement::Signatures[c_signatures::INIT_KEY_VALUES]; + + __asm + { + push name + mov ecx, keyValues + call pfunc + } +} + +static Color old_clr[4]; +static float old_reflectivity[4]; +static float old_pearlescent[4]; +static float old_shine[4]; +static float old_rim[4]; + +void c_chams::modifications(IMaterial* mat, c_chams_settings settings) +{ + static KeyValues* kv = nullptr; + if (!kv) { + kv = static_cast(malloc(36)); + InitKeyValues(kv, sxor("VertexLitGeneric")); + } + else { + static bool something_changed = true; + + Color clr = settings.reflectivity_clr;//ctx.m_settings.chams_reflectivity_c[0]; + float reflectivity = settings.reflectivity;//ctx.m_settings.chams_reflectivity[0]; + float pearlescent = settings.pearlescent;//ctx.m_settings.chams_pearlescent[0] * 0.5f; + float shine = settings.shine;//ctx.m_settings.chams_shine[0]; + float rim = settings.rim;//ctx.m_settings.chams_rim[0]; + + if (old_clr[settings.setting_type] != clr || + old_reflectivity[settings.setting_type] != reflectivity || + old_pearlescent[settings.setting_type] != pearlescent || + old_shine[settings.setting_type] != shine || + old_rim[settings.setting_type] != rim + ) { + something_changed = true; + } + + if (something_changed) { + + kv->SetString(sxor("$basetexture"), sxor("vgui/white_additive")); + + // reflectivity + { + char _envmaptint[64]; + sprintf(_envmaptint, sxor("[%f %f %f]"), (clr.r() / 255) * (reflectivity / 100), (clr.g() / 255) * (reflectivity / 100), (clr.b() / 255) * (reflectivity / 100)); + + kv->SetString(sxor("$envmaptint"), _envmaptint); + kv->SetString(sxor("$envmap"), sxor("env_cubemap")); + } + + // pearlescence + { + char _pearlescent[64]; + sprintf(_pearlescent, sxor("%f"), pearlescent); + + kv->SetString(sxor("$pearlescent"), _pearlescent); + } + + // shine + { + kv->SetInt(sxor("$phong"), 1); + kv->SetInt(sxor("$phongexponent"), 15); + kv->SetInt(sxor("$normalmapalphaenvmask"), 1); + + char _phongboost[64]; + sprintf(_phongboost, sxor("[%f %f %f]"), shine / 100, shine / 100, shine / 100); + + kv->SetString(sxor("$phongboost"), _phongboost); + kv->SetString(sxor("$phongfresnelranges"), sxor("[.5 .5 1]")); + kv->SetInt(sxor("$BasemapAlphaPhongMask"), 1); + } + + // rim + { + kv->SetInt(sxor("$rimlight"), 1); + kv->SetInt(sxor("$rimlightexponent"), 2); + char _rimlightboost[64]; + sprintf(_rimlightboost, sxor("%f"), rim / 100); + kv->SetString(sxor("$rimlightboost"), _rimlightboost); + } + + /*{ + if (settings.discoball) + kv->SetString(sxor("$bumpmap"), sxor("models/weapons/customization/materials/origamil_camo")); + }*/ + + old_clr[settings.setting_type] = clr; + old_reflectivity[settings.setting_type] = reflectivity; + old_pearlescent[settings.setting_type] = pearlescent; + old_shine[settings.setting_type] = shine; + old_rim[settings.setting_type] = rim; + + //kv->LoadFromBuffer("csgo\\materials\\dsv_textured.vmt", tmp); + mat->SetShaderAndParams(kv); + + something_changed = false; + } + } +} + +void c_chams::set_modulation(c_chams_settings settings, IMaterial* material) +{ + if (!csgo.m_engine()->IsInGame() || ctx.m_local() == nullptr || material == nullptr) + return; + + if (material && !material->IsErrorMaterial()) + { + material->ColorModulate(settings.color[0]/255.f, settings.color[1]/255.f, settings.color[2]/255.f); + + if (settings.type >= 0) { + if (settings.type == 0) + { + modifications(material, settings); + } + else + { + auto envmaptint = material->FindVar(sxor("$envmaptint"), nullptr); + + if (envmaptint) + envmaptint->SetVecValue(Vector((settings.reflectivity_clr.r() / 255.f), (settings.reflectivity_clr.g() / 255.f), (settings.reflectivity_clr.b() / 255.f))); + } + } + /*auto pearlescent = material->FindVar("$pearlescent", nullptr); + + if (pearlescent) { + char $pearlescent[64]; + sprintf($pearlescent, "%f", float(ctx.m_settings.chams_pearlescent[3])); + + pearlescent->SetStringValue($pearlescent); + }*/ + } + + float c[] = { settings.color[0] / 255.f, settings.color[1] / 255.f, settings.color[2] / 255.f }; + + csgo.m_render_view()->SetColorModulation(c); +} + +void c_chams::modulate_exp(IMaterial* material, const float alpha, const float width) +{ + if (!csgo.m_engine()->IsInGame() || ctx.m_local() == nullptr || material == nullptr) + return; + + if (!material || material->IsErrorMaterial()) + return; + + + + const auto transform = material->FindVar(sxor("$envmapfresnelminmaxexp"), 0); + + if (transform) + transform->SetVectorComponent(width * alpha, 1); +} + +void c_chams::player_chams(const std::function original, c_chams_settings settings, bool scope_blend, bool* vis_type) +{ + bool preserve = ctx.m_settings.menu_chams_type == 3; + + IMaterial* mat = get_material(1); + + if (!mat || mat->IsErrorMaterial() || mat == nullptr) + return; + + mat->IncrementReferenceCount(); + + debugdrawflat = csgo.m_material_system()->FindMaterial(("debug/debugdrawflat"), ("Model textures")); + debugdrawflat->IncrementReferenceCount(); + const auto needs_shit = ctx.m_settings.menu_chams_type >= 2; + + //mat->Refresh(); + + const float alpha = settings.color.a(); + + float old_blend = csgo.m_render_view()->GetBlend(); + + const auto first_color = settings.color; + const auto hidden_color = settings.hidden_color; + const auto lol = settings.white_color; + const auto reflect_color = settings.reflectivity_clr; + const auto type = settings.type; + + auto nigger = settings.type < 2; + //auto org = mat->GetShaderParams(); + + float nigger_alpha = settings.hidden_color.a(); + + if (preserve) + { + settings.color = (settings.redraw ? first_color : lol); + settings.reflectivity_clr = lol; + settings.type = -1; + set_modulation(settings, mat); + mat->AlphaModulate(settings.redraw ? (scope_blend ? Math::clamp(ctx.m_settings.local_chams_scope_trans / 100.f, 0, 1) : (alpha / 255.f)) : 0); + csgo.m_render_view()->SetBlend(settings.redraw ? (scope_blend ? Math::clamp(ctx.m_settings.local_chams_scope_trans / 100.f, 0, 1) : (alpha / 255.f)) : 0); + original(); + settings.type = type; + settings.color = first_color; + settings.reflectivity_clr = reflect_color; + csgo.m_model_render()->ForcedMaterialOverride(nullptr); + } + + const float a = (scope_blend ? Math::clamp(2.55f * settings.scope_blend, 0, 255) : alpha); + + if (needs_shit) + modulate_exp(mat, 1.f); + + mat->SetMaterialVarFlag(MATERIAL_VAR_UNUSED, true); + + if (vis_type != nullptr && !needs_shit) + { + if (*vis_type) { + csgo.m_render_view()->SetBlend((nigger ? nigger_alpha : a) / 255.f); + set_ignorez(true, mat); + settings.color = hidden_color; + set_modulation(settings, mat); + mat->AlphaModulate((nigger ? nigger_alpha : a) / 255.f); + + settings.color = first_color; + csgo.m_model_render()->ForcedMaterialOverride(mat); + original(); + + } + + if (*vis_type) { + csgo.m_render_view()->SetBlend(a / 255.f); + set_ignorez(false, mat); + set_modulation(settings, mat); + mat->AlphaModulate(a / 255.f); + + csgo.m_model_render()->ForcedMaterialOverride(mat); + original(); + } + } + else + { + csgo.m_render_view()->SetBlend(a / 255.f); + set_ignorez(false, mat); + set_modulation(settings, mat); + mat->AlphaModulate(a / 255.f); + + csgo.m_model_render()->ForcedMaterialOverride(mat); + original(); + } + + set_wireframe(false, mat); + csgo.m_render_view()->SetBlend(old_blend); +} + +//void c_chams::player_chams(Menu22::visaul::chams_& conf, c_cs_player* entity, bool draw_fake, bool scope_blend) +//{ +// if (!entity) +// return; +// +// if (conf.material_type == 0) +// return; +// +// c_color c = c_color(conf.color[0] * 255, conf.color[1] * 255, conf.color[2] * 255, conf.color[3] * 255); +// bool preserve = conf.preserve_model; +// bool pulse = conf.pulse; +// bool wireframe = conf.wireframe; +// +// static c_material* pMatGloss = material_system()->find_material("models/inventory_items/trophy_majors/gloss", TEXTURE_GROUP_OTHER); //you can create your own material to really make it shiny, but i like this subtle one +// +// auto mat = GetMat(conf.material_type - 1); +// +// if (!mat) +// return; +// +// if (!entity->is_alive()) +// return; +// +// if (!mat->is_error_material()) +// { +// mat->incrementreferencecount(); +// +// const auto alpha = pulse ? instance()->alpha : c.alpha; +// if (preserve) +// { +// +// modulate(c_color(255, 255, 255, 255), conf, mat); +// render_view()->set_blend((preserve ? 255 : alpha) / 255.f); +// entity->draw_model(0x1, 255); +// } +// +// modulate(c_color(conf.color[0] * 255, conf.color[1] * 255, conf.color[2] * 255, conf.color[3] * 255), conf, mat); +// do_wireframe(mat, wireframe); +// +// if (conf.xqz) +// { +// modulate(c_color(conf.color[0] * 255, conf.color[1] * 255, conf.color[2] * 255, conf.color[3] * 255), conf, mat); +// set_ignorez(true, mat); +// render_view()->set_blend(scope_blend ? std::clamp(alpha / 2, 0, 255) : alpha / 255.f); +// model_render()->forced_material_override(mat); +// modulate(c_color(conf.color[0] * 255, conf.color[1] * 255, conf.color[2] * 255, conf.color[3] * 255), conf, mat); +// entity->draw_model(0x1, 255); +// +// render_view()->set_blend(scope_blend ? std::clamp(alpha / 2, 0, 255) : alpha / 255.f); +// model_render()->forced_material_override(mat); +// modulate(c_color(conf.color[0] * 255, conf.color[1] * 255, conf.color[2] * 255, conf.color[3] * 255), conf, mat); +// entity->draw_model(0x1, 255); +// } +// else +// { +// set_ignorez(false, mat); +// modulate(c_color(conf.color[0] * 255, conf.color[1] * 255, conf.color[2] * 255, conf.color[3] * 255), conf, mat); +// render_view()->set_blend(scope_blend ? std::clamp(alpha / 2, 0, 255) : alpha / 255.f); +// model_render()->forced_material_override(mat); +// entity->draw_model(0x1, 255); +// } +// } +//} + +inline bool is_arms(const char* name) { + return (strstr(name, ("arms")) != nullptr || strstr(name, ("v_models")) != nullptr); +} + +inline bool is_weapon(const char* name) { + auto is_sleeve = strstr(name, ("sleeve")) != nullptr; + auto is_arm = strstr(name, ("arms")) != nullptr; + return (strstr(name, ("weapons/v_")) != nullptr || strstr(name, ("weapons/w_knife")) != nullptr || strstr(name, ("v_")) != nullptr || strstr(name, ("uid")) != nullptr || strstr(name, ("stattrak")) != nullptr) && (strstr(name, ("arms")) == nullptr) /*&& (strstr(name, "knife") == nullptr)*/ && !is_sleeve; +} + +int c_chams::work(void* context, void* state, ModelRenderInfo_t& info, matrix3x4_t* pCustomBoneToWorld) +{ + auto renderable_entity = (C_BasePlayer*)(((IClientRenderable*)info.pRenderable)->GetIClientUnknown()->GetBaseEntity()); + + if (!ctx.m_local() || !csgo.m_engine()->IsInGame() || renderable_entity == nullptr) + return -1; + + auto client_class = renderable_entity->GetClientClass(); + + if (client_class == nullptr || !client_class->m_ClassID) + return -1; + + const auto classid = client_class->m_ClassID; + + if (/*classid != class_ids::CPredictedViewModel && classid != class_ids::CBaseAnimating && + classid != class_ids::CBaseWeaponWorldModel && classid != class_ids::CBreakableProp &&*/ + classid != class_ids::CCSPlayer) + return -1; + + matrix3x4_t render_matrix[128]; + + + const auto original = [&]() -> void + { + csgo.m_model_render()->DrawModelExecute(context, state, info, pCustomBoneToWorld); + }; + const auto extra_chams = [&]() -> void + { + csgo.m_model_render()->DrawModelExecute(context, state, info, render_matrix); + }; + + Color hecolor = (ctx.m_settings.colors_chams_enemy_hidden); + Color vecolor = (ctx.m_settings.colors_chams_enemy_viable); + + //Color htcolor = ctx.m_settings.colors_chams_teammate_hidden; + //Color vtcolor = ctx.m_settings.colors_chams_teammate_viable; + + Color acolor = ctx.m_settings.colors_chams_local_desync; + Color lcolor = ctx.flt2color(ctx.m_settings.colors_chams_local); + + Color hwcolor = ctx.m_settings.colors_chams_weapon_hidden; + Color vwcolor = ctx.m_settings.colors_chams_weapon_viable; + + Color hhcolor = ctx.m_settings.colors_chams_hands_hidden; + Color vhcolor = ctx.m_settings.colors_chams_hands_viable; + + const auto entity = csgo.m_entity_list()->GetClientEntity(info.entity_index); + + if (classid == class_ids::CCSPlayer && strstr(info.pModel->szName, ("models/player")) != nullptr) + { + if (info.entity_index == csgo.m_engine()->GetLocalPlayer() && ctx.m_settings.scope_transparency < 100) + csgo.m_render_view()->SetBlend(ctx.m_settings.scope_transparency / 100.f); + + if (entity != nullptr && entity->GetClientClass() != nullptr && !entity->m_bIsRagdoll() && !entity->IsDead() && entity->m_iHealth() > 0) + { + //if (!c_chams::instance()->second_pass && c_chams::instance()->current_player == entity && !entity->is_local_player()) + // return; + + float c[] = { 0.f,0.f,0.f }; + + csgo.m_render_view()->GetColorModulation(c); + + if (entity != ctx.m_local()) + { + /*if (c_chams::instance()->current_matrix) + { + c_chams::player_chams(original, _config.Visuals.backtrack, false); + } + else */if (!entity->IsDormant() && ctx.m_settings.chams_enemy && entity->m_iTeamNum() != ctx.m_local()->m_iTeamNum()) + { + auto log = &feature::lagcomp->records[entity->entindex() - 1]; + + static c_chams_settings settings; + + settings.color = vecolor; + settings.hidden_color = hecolor; + settings.white_color = Color::White(); + settings.reflectivity_clr = ctx.m_settings.chams_reflectivity_c[0]; + settings.reflectivity = ctx.m_settings.chams_reflectivity[0]; + settings.shine = ctx.m_settings.chams_shine[0]; + settings.pearlescent = ctx.m_settings.chams_pearlescent[0]; + settings.rim = ctx.m_settings.chams_rim[0]; + settings.type = ctx.m_settings.chams_material_type[0]; + settings.wireframe = ctx.m_settings.chams_wireframe[0]; + settings.redraw = ctx.m_settings.chams_redraw[0]; + settings.setting_type = 0; + + + c_chams::player_chams(original, settings, false, &ctx.m_settings.chams_walls); + } + } + else + { + static c_chams_settings d_settings; + + d_settings.color = acolor; + d_settings.hidden_color = acolor; + d_settings.white_color = Color::White(); + d_settings.reflectivity_clr = ctx.m_settings.chams_reflectivity_c[3]; + d_settings.reflectivity = ctx.m_settings.chams_reflectivity[3]; + d_settings.shine = ctx.m_settings.chams_shine[3]; + d_settings.pearlescent = ctx.m_settings.chams_pearlescent[3]; + d_settings.rim = ctx.m_settings.chams_rim[3]; + d_settings.type = ctx.m_settings.chams_material_type[3]; + d_settings.wireframe = ctx.m_settings.chams_wireframe[3]; + d_settings.redraw = ctx.m_settings.chams_redraw[3]; + d_settings.scope_blend = ctx.m_settings.local_chams_fake_scope_trans; + d_settings.setting_type = 3; + + memcpy(&render_matrix[0], &ctx.fake_matrix[0], sizeof(matrix3x4_t) * 128); + + auto fake_pos = Vector(ctx.fake_matrix[8][0][3], ctx.fake_matrix[8][1][3], ctx.fake_matrix[8][2][3]); + + if (ctx.m_settings.chams_local_player && !fake_pos.IsZero() && ctx.m_local()->get_bone_pos(8).DistanceSquared(fake_pos) > 1/* && feature::anti_aim->enable_delay <= csgo.m_globals()->realtime && entity->m_bone_count() <= 128 && entity->m_bone_count() > 0*/) + c_chams::player_chams(extra_chams, d_settings, (entity->m_bIsScoped() && csgo.m_input()->is_in_tp())); + + float p[] = { 1.f,1.f,1.f }; + csgo.m_render_view()->SetColorModulation(p); + csgo.m_model_render()->ForcedMaterialOverride(nullptr); + + //if (_config.Ragebot.enable && _config.Ragebot._antiaim && (_config.Ragebot.fakelag_enable || _config.Ragebot._antiaim) && antiaim->last_fakelag_matrix && local->get_velocity().length2d() > 5 && _config.Visuals.fakelag.material_type != 0) + //{ + // const auto weapon = reinterpret_cast( + // client_entity_list()->get_client_entity_from_handle(c_cs_player::get_local_player()->get_current_weapon_handle())); + + // if (!weapon) + // return; + + // c_chams::instance()->current_matrix = antiaim->last_fakelag_matrix; + + // c_chams::player_chams(original, d_settings, (entity->m_bIsScoped() && csgo.m_input()->is_in_tp())); + + // if (c_chams::instance()->current_matrix && !(_config.Ragebot.disableaaonknife && (weapon_system->get_weapon_data(weapon->get_item_definition())->WeaponType == weapontype_knife))) { + // c_chams::player_chams(original, _config.Visuals.fakelag, true, (entity->is_local_player() && entity->is_scoped() && true)); + // original(); + // } + // csgo.m_render_view()->set_color_modulation(c_color(255, 255, 255)); + // csgo.m_model_render()->forced_material_override(nullptr); + //} + + //csgo.m_render_view()->SetColorModulation(p); + //csgo.m_model_render()->ForcedMaterialOverride(nullptr); + + //static c_chams_settings settings; + + //settings.color = lcolor; + //settings.hidden_color = lcolor; + //settings.white_color = Color::White(); + //settings.reflectivity_clr = ctx.m_settings.chams_reflectivity_c[2]; + //settings.reflectivity = ctx.m_settings.chams_reflectivity[2]; + //settings.shine = ctx.m_settings.chams_shine[2]; + //settings.pearlescent = ctx.m_settings.chams_pearlescent[2]; + //settings.rim = ctx.m_settings.chams_rim[2]; + //settings.type = ctx.m_settings.chams_material_type[2]; + //settings.wireframe = ctx.m_settings.chams_wireframe[2]; + //settings.redraw = ctx.m_settings.chams_redraw[2]; + //settings.scope_blend = ctx.m_settings.local_chams_scope_trans; + //settings.setting_type = 2; + + ////c_chams::player_chams(_config.Visuals.local, entity, false, (entity->is_local_player() && entity->is_scoped() && _config.Visuals.local.blend && input->camera_in_third_person)); + //if (ctx.m_settings.chams_local_player) + // c_chams::player_chams(original, settings, (entity->m_bIsScoped() && csgo.m_input()->is_in_tp())); + } + + csgo.m_render_view()->SetColorModulation(c); + } + //else if (!ctx.m_local()->IsDead() && !csgo.m_input()->is_in_tp()) { + + //bool piska[] = { true,true }; + + /*if (is_weapon(info.pModel->szName) && entity && ctx.m_settings.chams_misc[1]) + { + const auto owner = csgo.m_entity_list()->GetClientEntityFromHandle((CBaseHandle)entity->m_hOwnerEntity()); + + static c_chams_settings settings; + + settings.color = vwcolor; + settings.hidden_color = vwcolor; + settings.white_color = Color::White(); + settings.reflectivity_clr = ctx.m_settings.chams_reflectivity_c[5]; + settings.reflectivity = ctx.m_settings.chams_reflectivity[5]; + settings.shine = ctx.m_settings.chams_shine[5]; + settings.pearlescent = ctx.m_settings.chams_pearlescent[5]; + settings.rim = ctx.m_settings.chams_rim[5]; + settings.type = ctx.m_settings.chams_material_type[5]; + settings.wireframe = ctx.m_settings.chams_wireframe[5]; + settings.redraw = ctx.m_settings.chams_redraw[5]; + settings.setting_type = 5; + + if (ctx.m_settings.chams_weapon_apply_only_on[0] && strstr(info.pModel->szName, ("weapons/v_knife")) != nullptr + || !ctx.m_settings.chams_weapon_apply_only_on[0]) + c_chams::player_chams(original, settings, false); + }*/ + /*else if (is_arms(info.pModel->szName) && ctx.m_settings.chams_misc[0] && csgo.m_material_system()->FindMaterial(info.pModel->szName, ("Model textures"))) + { + static c_chams_settings settings; + + settings.color = vhcolor; + settings.hidden_color = vhcolor; + settings.white_color = Color::White(); + settings.reflectivity_clr = ctx.m_settings.chams_reflectivity_c[4]; + settings.reflectivity = ctx.m_settings.chams_reflectivity[4]; + settings.shine = ctx.m_settings.chams_shine[4]; + settings.pearlescent = ctx.m_settings.chams_pearlescent[4]; + settings.rim = ctx.m_settings.chams_rim[4]; + settings.type = ctx.m_settings.chams_material_type[4]; + settings.wireframe = ctx.m_settings.chams_wireframe[4]; + settings.redraw = ctx.m_settings.chams_redraw[4]; + settings.setting_type = 4; + + c_chams::player_chams(original, settings, false); + }*/ + + } + + original(); + auto lol = csgo.m_model_render()->DrawModelExecute(context, state, info, pCustomBoneToWorld); + csgo.m_model_render()->ForcedMaterialOverride(nullptr); + + return lol; +} + +bool strstric(const std::string& strHaystack, const std::string& strNeedle) +{ + auto it = std::search( + strHaystack.begin(), strHaystack.end(), + strNeedle.begin(), strNeedle.end(), + [](char ch1, char ch2) { return std::toupper(ch1) == std::toupper(ch2); } + ); + return (it != strHaystack.end()); +} + +void c_chams::night_mode() +{ + static auto sv_skyname = csgo.m_engine_cvars()->FindVar(sxor("sv_skyname")); + static auto original = sv_skyname->GetString(); + + + const auto reset = [&]() + { + csgo.m_engine_cvars()->FindVar(sxor("r_DrawSpecificStaticProp"))->SetValue(1); + sv_skyname->SetValue(original); + + for (auto i = csgo.m_material_system()->FirstMaterial(); i != csgo.m_material_system()->InvalidMaterial(); i = csgo.m_material_system()->NextMaterial(i)) + { + auto mat = csgo.m_material_system()->GetMaterial(i); + if (!mat) + continue; + + if (mat->IsErrorMaterial()) + continue; + + std::string name = mat->GetName(); + auto tex_name = mat->GetTextureGroupName(); + + + if (strstr(tex_name, sxor("World")) || strstr(tex_name, sxor("StaticProp")) || strstr(tex_name, sxor("SkyBox"))) + { + mat->ColorModulate(1, 1, 1); + mat->AlphaModulate(1); + } + } + }; + + //_(sky_csgo_night02, "sky_csgo_night02"); + const auto set = [&]() + { + //static auto load_named_sky = reinterpret_cast(sig("engine.dll", "55 8B EC 81 EC ? ? ? ? 56 57 8B F9 C7 45")); + //load_named_sky(sky_csgo_night02); + + sv_skyname->SetValue(sxor("sky_csgo_night02")); + + csgo.m_engine_cvars()->FindVar(sxor("r_DrawSpecificStaticProp"))->SetValue(0); + + for (auto i = csgo.m_material_system()->FirstMaterial(); i != csgo.m_material_system()->InvalidMaterial(); i = csgo.m_material_system()->NextMaterial(i)) + { + auto mat = csgo.m_material_system()->GetMaterial(i); + if (!mat) + continue; + + if (mat->IsErrorMaterial()) + continue; + + std::string name = mat->GetName(); + auto tex_name = mat->GetTextureGroupName(); + + if (ctx.m_settings.misc_visuals_world_modulation[1] && strstr(tex_name, sxor("World"))) + { + mat->ColorModulate(0.13f, 0.109f, 0.14f); + } + if (strstr(tex_name, sxor("StaticProp"))) + { + /*if ( !strstric( name, "box" ) && !strstric( name, "crate" ) && !strstric( name, "door" ) && ! + strstric( name, "stoneblock" ) && !strstric( name, "tree" ) && !strstric( name, "flower" ) && ! + strstric( name, "light" ) && !strstric( name, "lamp" ) && !strstric( name, "props_junk" ) && ! + strstric( name, "props_pipe" ) && !strstric( name, "chair" ) && !strstric( name, "furniture" ) && ! + strstric( name, "debris" ) && !strstric( name, "tire" ) && !strstric( name, "refrigerator" ) && ! + strstric( name, "fence" ) && !strstric( name, "pallet" ) && !strstric( name, "barrel" ) && !strstric( + name, "wagon" ) && !strstric( name, "wood" ) && !strstric( name, "wall" ) && !strstric( name, "pole" ) && !strstric( name, "props_urban" ) && !strstric( name, "bench" ) && !strstric( name, "trashcan" ) && !strstric( name, "infwll" ) && !strstric( name, "cash_register" ) && !strstric( name, "prop_vehicles" ) && !strstric( name, "rocks" ) && !strstric( name, "artillery" ) && !strstric( name, "plaster_brick" ) && !strstric( name, "props_interiors" ) && !strstric( name, "props_farm" ) && !strstric( name, "props_highway" ) && !strstric( name, "orange" ) && !strstric( name, "wheel" ) ) + continue;*/ + + if (ctx.m_settings.misc_visuals_world_modulation[1]) + mat->ColorModulate(0.43f, 0.409f, 0.44f); + if ( /*!strstric( name, "wood" ) &&*/ !strstric(name, sxor("wall"))) + mat->AlphaModulate(1.f - float(ctx.m_settings.visuals_props_alpha * 0.01f)); + } + + /*if (ctx.m_settings.misc_visuals_nightmode && strstr(tex_name, "SkyBox")) + { + mat->ColorModulate(228.f / 255.f, 35.f / 255.f, 157.f / 255.f); + }*/ + + } + }; + + static auto done = true; + static auto last_setting = false; + static auto last_transparency = 0; + static auto was_ingame = false; + + if (!done) + { + if (last_setting || last_transparency) + { + reset(); + set(); + done = true; + } + else + { + reset(); + done = true; + } + } + + if (was_ingame != csgo.m_engine()->IsInGame() || last_setting != ctx.m_settings.misc_visuals_world_modulation[1] || last_transparency != ctx.m_settings.visuals_props_alpha) + { + last_setting = ctx.m_settings.misc_visuals_world_modulation[1]; + last_transparency = ctx.m_settings.visuals_props_alpha; + was_ingame = csgo.m_engine()->IsInGame(); + + done = false; + } +} +``` + +`chams.hpp`: + +```hpp +#pragma once +#include "sdk.hpp" +#include +#include +#include +#include "lag_comp.hpp" +#include "source.hpp" + +struct c_chams_settings +{ + Color color; + Color hidden_color; + Color white_color = Color::White(); + Color reflectivity_clr; + float reflectivity; + float shine; + float pearlescent; + float rim; + int type; + bool wireframe; + int setting_type; + IMaterial* setuped_mat; + bool redraw; + bool discoball; + float scope_blend; +}; + +class c_chams +{ +public: + virtual void set_ignorez(const bool enabled, IMaterial* mat); + virtual void set_wireframe(const bool enabled, IMaterial* mat); + virtual IMaterial* get_material(int material); + virtual void modifications(IMaterial* mat, c_chams_settings settings); + virtual void set_modulation(c_chams_settings settings, IMaterial* material); + virtual void modulate_exp(IMaterial* material, const float alpha = 1., const float width = 6.f); + virtual void player_chams(const std::function original, c_chams_settings settings, bool scope_blend, bool* vis_type = nullptr); + //virtual bool get_backtrack_matrix(C_BasePlayer* player, matrix3x4_t* out); + virtual int work(void* context, void* state, ModelRenderInfo_t& info, matrix3x4_t* pCustomBoneToWorld); + virtual void night_mode(); + IMaterial* debugdrawflat; +}; + +class c_hit_chams +{ +public: + c_hit_chams(C_Tickrecord src, int entindex) + { + this->_src = src; + this->_entindex = entindex; + this->_time = csgo.m_globals()->realtime + 4.f; + } + + C_Tickrecord _src; + int _entindex; + float _time; +}; + +extern std::vector hit_chams; +``` + +`clientstate.cpp`: + +```cpp +#include "hooked.hpp" +#include "displacement.hpp" +#include "player.hpp" +#include "weapon.hpp" +#include "prediction.hpp" +#include "movement.hpp" +#include "rage_aimbot.hpp" +#include "anti_aimbot.hpp" +#include "lag_comp.hpp" +#include +#include "menu.hpp" +#include "usercmd.hpp" +#include "visuals.hpp" +#include "prop_manager.hpp" +#include "sound_parser.hpp" + +struct twoints +{ + int first; int second; +}; + +std::vector g_states; + +namespace Hooked +{ + //bool in_ping_spike{}, flipped_state{}; + // + //float calculate_wanted_ping(INetChannel* channel) + //{ + // if (!csgo.m_engine()->GetNetChannelInfo()) + // return 0.f; + // + // auto wanted_ping = 0.f; + // + // /*if (in_ping_spike) + // wanted_ping = (200.f / 1000.f); + // else */if (ctx.m_settings.misc_extend_backtrack) + // wanted_ping = (200.f / 1000.f) - ctx.lerp_time; + // else + // return 0.f; + // + // return max(0.f, wanted_ping - csgo.m_engine()->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING) * 2.f); + //} + + //void set_suitable_in_sequence(INetChannel* channel) + //{ + // if (flipped_state || ctx.exploit_allowed && ctx.m_settings.aimbot_tickbase_exploit > 0) + // { + // flipped_state = false; + // return; + // } + // + // const auto spike = TIME_TO_TICKS(calculate_wanted_ping(channel)); + // + // if (channel->in_sequence_nr > spike) + // channel->in_sequence_nr -= spike; + //} + + //void flip_state(INetChannel* channel) + //{ + // static auto last_reliable_state = -1; + // + // if (channel->in_reliable_state != last_reliable_state) + // flipped_state = true; + // + // last_reliable_state = channel->in_reliable_state; + //} + + //void __fastcall ProcessPacket(INetChannel* channel, uint32_t, void* packet, bool header) + //{ + // static auto ofunc = vmt.m_net_channel->VCall(39); + // ofunc(channel, packet, header); + // + // if (csgo.m_engine()->IsInGame() && ctx.m_local() && !ctx.m_local()->IsDead()) { + // flip_state(channel); + // + // auto v5 = channel->in_sequence_nr; + // auto v6 = channel->in_reliable_state; + // auto v10 = channel->in_sequence_nr; + // auto v11 = v6; + // + // g_states.emplace_back(twoints{ v10, v6 }); + // + // if (g_states.size() > 0 && (v10 - g_states.back().first) > 128) + // g_states.pop_back(); + // } + //} + + bool __fastcall ProcessTempEntities(pPastaState* cl_state, void* EDX, void* msg) + { + using Fn = bool(__thiscall*)(void*, void*); + static auto ofunc = vmt.m_clientstate->VCall(36); + + auto o_ents = csgo.m_client_state()->m_nMaxClients; + csgo.m_client_state()->m_nMaxClients = 1; + const auto ret = ofunc(cl_state, msg); + csgo.m_client_state()->m_nMaxClients = o_ents; + + csgo.m_engine()->FireEvents(); + + return ret; + } + + void __fastcall PacketEnd(pPastaState* cl_state, void* EDX) + { + using Fn = void(__thiscall*)(void*); + static auto ofunc = vmt.m_clientstate->VCall(6); + + if (!csgo.m_engine()->IsInGame()) { + ctx.m_corrections_data.clear(); + ctx.command_numbers.clear(); + return ofunc(cl_state); + } + + if (!ctx.m_local() || ctx.m_local()->IsDead()) { + ctx.m_corrections_data.clear(); + ctx.command_numbers.clear(); + return ofunc(cl_state); + } + + if (*reinterpret_cast(uintptr_t(cl_state) + 0x164) == *reinterpret_cast(uintptr_t(cl_state) + 0x16C)) { + //const auto command_ack = *reinterpret_cast(uintptr_t(cl_state) + 0x4D34); + //constexpr auto m_p_offset = offsetof(CClientState, m_iCommandAck) - 0x4D2C; + //const auto m_last_server_tick = *reinterpret_cast(uintptr_t(cl_state) + 0x4D2C); + + feature::sound_parser->get_active_sounds(); + + //if (!ctx.m_corrections_data.empty()) { + // const auto correct = std::find_if(ctx.m_corrections_data.begin(), ctx.m_corrections_data.end(), [command_ack](const timing_data& a) { + // return a.cmd_num == command_ack; + // }); + + //if (correct != ctx.m_corrections_data.begin() && correct != ctx.m_corrections_data.end()) { + + // if (csgo.m_client_state()->m_iCommandAck != csgo.m_client_state()->m_iLastCommandAck) { + + // auto ticks = csgo.m_client_state()->m_clockdrift_manager.m_nServerTick - correct->tick_count; + // + // if (ticks < 0) + // ticks = 0; + + // if (ticks > ctx.tickrate) + // ticks = ctx.tickrate; + + // ctx.last_4_deltas.emplace_front(ticks); + // } + // /*else + // ctx.last_cmd_delta = 0;*/ + + auto lastCommand = (*(int(__thiscall**)(void*))(*(uintptr_t*)csgo.m_engine() + 820))(csgo.m_engine()); + + //auto m_latency_arr = &ctx.m_arr_latency[csgo.m_client_state()->m_iCommandAck % 150]; + + if (csgo.m_client_state()->m_iCommandAck != lastCommand) + { + auto& v85 = Engine::Prediction::Instance()->m_tick_history[lastCommand % 150]; + + if (v85.command_num == lastCommand + && abs(lastCommand - v85.command_num) <= 150) { + auto ticks = Math::clamp(csgo.m_engine()->GetTick() - v85.m_tick, 0, 64); + //ctx.last_cmd_delta = ticks; + + //ctx.m_last_servertick_delta.emplace_front(ticks); + + ctx.last_4_deltas.emplace_front(ticks);// Math::clamp(csgo.m_globals()->tickcount - csgo.m_client_state()->m_clockdrift_manager.m_nServerTick, 0, 64); + } + } + + while (ctx.last_4_deltas.size() >= 8) + ctx.last_4_deltas.pop_back(); + + if (ctx.allow_shooting > 0 && lastCommand >= ctx.allow_shooting) + ctx.allow_shooting = 0; + //} + //} + } + + ofunc(cl_state); + + } + + int __fastcall SendDatagram(void* netchan, void*, void* datagram) + { + const auto ofunc = vmt.m_net_channel->VCall(46); + + if (!csgo.m_engine()->IsInGame() || !ctx.m_local()) + return ofunc(netchan, datagram); + + //auto* const net_channel = static_cast(netchan); + /* + const auto backup_seqnr = net_channel->in_sequence_nr; + const auto backup_relst = net_channel->in_reliable_state; + + ping_spike(net_channel); + + const auto ret = ofunc(net_channel, datagram); + net_channel->in_sequence_nr = backup_seqnr; + net_channel->in_reliable_state = backup_relst; + + return ret;*/ + + /*const auto backup_in_seq = net_channel->in_sequence_nr; + const auto backup_in_rel = net_channel->in_sequence_nr; + + auto net = csgo.m_engine()->GetNetChannelInfo();*/ + + //if (!net || !ctx.m_settings.misc_extend_backtrack) + ctx.in_send_datagram = true; + //auto pflow = (netflow_t*)(uintptr_t(netchan) + 0x78B * (0) + 0x127); + /*float old_flow, oldflow_avg; + if (pflow) { + old_flow = pflow->latency; + oldflow_avg = pflow->avglatency; + }*/ + auto org = ofunc(netchan, datagram); + /*if (pflow) { + pflow->latency = old_flow; + pflow->avglatency = oldflow_avg; + }*/ + //feature::lagcomp->update_network_info() + + ctx.in_send_datagram = false; + + //auto latency_out = net->GetLatency(FLOW_OUTGOING); + //if (latency_out < 0.2f) + //{ + // auto v13 = net_channel->in_sequence_nr - (((0.2f - latency_out) / csgo.m_globals()->interval_per_tick) + 0.5f); + // net_channel->in_sequence_nr = v13; + + // for (auto i = 0; i < g_states.size(); i++) + // { + // if (g_states[i].first != v13) + // continue; + + // net_channel->in_reliable_state = g_states[i].second; + // } + //} + + ////set_suitable_in_sequence(net_channel); + + //const auto original = ofunc(netchan, datagram); + //net_channel->in_sequence_nr = backup_in_seq; + //net_channel->in_reliable_state = backup_in_rel; + return org; + } + + /*void WriteUsercmd(bf_write* buf, CUserCmd* incmd, CUserCmd* outcmd) { + using WriteUsercmd_t = void(__fastcall*)(void*, CUserCmd*, CUserCmd*); + static WriteUsercmd_t WriteUsercmdF = (WriteUsercmd_t)Memory::Scan("client.dll", ("55 8B EC 83 E4 F8 51 53 56 8B D9 8B 0D")); + + __asm + { + mov ecx, buf + mov edx, incmd + push outcmd + call WriteUsercmdF + add esp, 4 + } + }*/ + + //void tickbase_manipulation(CCLCMsg_Move_t* CL_Move, INetChannel* pNetChan) { + // // not shifting or dont need do extra fakelag + // if (ctx.shift_amount == 0 && (CL_Move->m_nNewCommands != 15 || csgo.m_client_state()->m_iChockedCommands <= 14)) + // return; + // + // using assign_lol = std::string& (__thiscall*)(void*, uint8_t*, size_t); + // auto assign_std_autistic_string = (assign_lol)Memory::Scan("client.dll", "55 8B EC 53 8B 5D 08 56 8B F1 85 DB 74 57 8B 4E 14 83 F9 10 72 04 8B 06 EB 02"); // "55 8B EC 53 8B 5D 08 56 8B F1 85 DB 74 57 8B 4E 14 83 F9 10 72 04 8B 06 EB 02" + // + // // rebuild CL_SendMove + // uint8_t data[4000]; + // bf_write buf; + // buf.m_nDataBytes = 4000; + // buf.m_nDataBits = 32000; + // buf.m_pData = data; + // buf.m_iCurBit = false; + // buf.m_bOverflow = false; + // buf.m_bAssertOnOverflow = false; + // buf.m_pDebugName = false; + // int numCmd = csgo.m_client_state()->m_iChockedCommands + 1; + // int nextCmdNr = csgo.m_client_state()->m_iLastOutgoingCommand + numCmd; + // if (numCmd > 62) + // numCmd = 62; + // + // bool bOk = true; + // + // auto to = nextCmdNr - numCmd + 1; + // auto from = -1; + // if (to <= nextCmdNr) { + // int newcmdnr = to >= (nextCmdNr - numCmd + 1); + // do { + // bOk = bOk && csgo.m_client()->WriteUsercmdDeltaToBuffer(0, &buf, from, to, to >= newcmdnr); + // from = to++; + // } while (to <= nextCmdNr); + // } + // + // if (bOk) { + // if (ctx.shift_amount > 0) { + // CUserCmd from_cmd, to_cmd; + // from_cmd = *csgo.m_input()->GetUserCmd(nextCmdNr); + // to_cmd = from_cmd; + // to_cmd.tick_count = INT_MAX; + // + // do { + // if (numCmd >= 62) { + // ctx.shift_amount = 0; + // break; + // } + // + // to_cmd.command_number++; + // WriteUsercmd(&buf, &to_cmd, &from_cmd); + // + // ctx.shift_amount--; + // numCmd++; + // } while (ctx.shift_amount > 0); + // } + // else { + // ctx.shift_amount = 0; + // } + // + // // bypass choke limit + // CL_Move->m_nNewCommands = numCmd; + // CL_Move->m_nBackupCommands = 0; + // + // int curbit = (buf.m_iCurBit + 7) >> 3; + // assign_std_autistic_string(CL_Move->m_data, buf.m_pData, curbit); + // } + //} + + void __fastcall PacketStart(void* ecx, void* edx, int incoming_sequence, int outgoing_acknowledged) + { + using Fn = void(__thiscall*)(void*, int, int); + static auto ofunc = vmt.m_clientstate->VCall(5); + + //if (ctx.fix_senddatagram) + // outgoing_acknowledged = ((pPastaState*)ecx)->m_iLastCommandAck; + + /*if (csgo.m_engine()->IsInGame() && *(int*)(uintptr_t(ecx) + 0x16C) >= 0) { + for (auto i = 1; i < 64; i++) + { + auto ent = csgo.m_entity_list()->GetClientEntity(i); + + if (ent == nullptr || + !ent->IsPlayer() || + ent->IsDormant() || + ent == ctx.m_local()) + continue; + + auto log = &feature::lagcomp->records[ent->entindex() - 1]; + + if (log->player != ent && log->player != nullptr) + continue; + + log->uninterpolated_record.simulation_time = ent->m_flSimulationTime(); + } + }*/ + + /*if (!csgo.m_engine()->IsInGame() || ecx == nullptr) { + ctx.m_corrections_data.clear(); + ctx.command_numbers.clear(); + return ofunc(ecx, incoming_sequence, outgoing_acknowledged);; + } + + if (!ctx.m_local() || ctx.m_local()->IsDead()) { + ctx.m_corrections_data.clear(); + ctx.command_numbers.clear(); + return ofunc(ecx, incoming_sequence, outgoing_acknowledged); + }*/ + + ////auto retaddr = _ReturnAddress(); auto mod = GetModuleHandleA("engine.dll"); + + //if (!csgo.m_engine()->IsInGame() || !csgo.m_game_rules() || csgo.m_game_rules()->IsValveDS() || !ctx.m_settings.aimbot_position_adjustment + // /*|| game_rules->is_freeze_period() || !c_events::is_active_round*/) + // return ofunc(ecx, incoming_sequence, outgoing_acknowledged); + + //static int outgoing = outgoing_acknowledged; + + //if (ctx.command_numbers.begin() != ctx.command_numbers.end()) { + // for (auto it = ctx.command_numbers.begin(); it != ctx.command_numbers.end();) + // { + // if (it == ctx.command_numbers.end()) + // break; + + // if (*it == outgoing_acknowledged) + // { + // it = ctx.command_numbers.erase(it); + // outgoing = *it; + // //ofunc(ecx, incoming_sequence, outgoing_acknowledged); + // //return ofunc(ecx, incoming_sequence, outgoing_acknowledged); + // } + + // ++it; + // } + //} + + /*if (ctx.fix_senddatagram[outgoing_acknowledged % 150] <= 0) { + ofunc(ecx, + incoming_sequence, outgoing_acknowledged); + return; + }*/ + + if (!ctx.command_numbers.empty() && /*(!csgo.m_game_rules() || !csgo.m_game_rules()->IsValveDS()) &&*/ ctx.m_settings.aimbot_enabled) { + for (auto it = ctx.command_numbers.rbegin(); it != ctx.command_numbers.rend(); ++it) { + if (!it->is_outgoing) { + continue; + } + + if (it->command_nr == outgoing_acknowledged + || outgoing_acknowledged > it->command_nr && (!it->is_used || it->prev_command_nr == outgoing_acknowledged)) { + + it->prev_command_nr = outgoing_acknowledged; + it->is_used = true; + ofunc(ecx, + incoming_sequence, it->command_nr); + + break; + } + } + + auto result = false; + + for (auto it = ctx.command_numbers.begin(); it != ctx.command_numbers.end(); ) { + if (outgoing_acknowledged == it->command_nr || outgoing_acknowledged == it->prev_command_nr) + result = true; + + if (outgoing_acknowledged > it->command_nr && outgoing_acknowledged > it->prev_command_nr) { + it = ctx.command_numbers.erase(it); + } + else { + it++; + } + } + + if (!result) + ofunc(ecx,incoming_sequence, outgoing_acknowledged); + } + else { + //if (ctx.command_numbers.size() > 3) { + // if (ctx.command_numbers.begin() != ctx.command_numbers.end()) { + // for (auto it = ctx.command_numbers.begin(); it != ctx.command_numbers.end();) + // { + // if (it == ctx.command_numbers.end()) + // break; + + // if ((*it).command_nr < outgoing_acknowledged) + // { + // it = ctx.command_numbers.erase(it); + // //outgoing = (*it).command_nr; + // //ofunc(ecx, incoming_sequence, outgoing_acknowledged); + // //return ofunc(ecx, incoming_sequence, outgoing_acknowledged); + // } + // else + // { + // ofunc(ecx, + // incoming_sequence, outgoing_acknowledged); + // } + + // ++it; + // } + // } + //} + //else + ofunc(ecx, + incoming_sequence, outgoing_acknowledged); + } + + /*static auto outgoing_command = 0; + if (csgo.m_engine()->IsInGame() && ctx.m_settings.aimbot_position_adjustment && csgo.m_game_rules() && !csgo.m_game_rules()->IsValveDS()) + { + outgoing_command = outgoing_acknowledged; + auto v6 = ctx.fix_senddatagram[outgoing_acknowledged % 150]; + auto v7 = 0; + if (v6 == outgoing_acknowledged) + v7 = v6 + 1; + if (v7) + outgoing_command = v7; + } + else + { + outgoing_command = outgoing_acknowledged; + } + + ofunc(ecx, incoming_sequence, outgoing_command); +*/ + + //return; + } + + bool __fastcall SendNetMsg(INetChannel* pNetChan, void* edx, INetMessage& msg, bool bForceReliable, bool bVoice) + { + using Fn = bool(__thiscall*)(INetChannel * pNetChan, INetMessage & msg, bool bForceReliable, bool bVoice); + const auto ofc = vmt.m_net_channel->VCall(40); + + if (ctx.m_local() && ctx.m_local() != nullptr && csgo.m_engine()->IsInGame()) + { + /*if (msg.GetGroup() == 11 && ctx.m_settings.aimbot_tickbase_exploit && ctx.speed_hack <= 0) { + uintptr_t uiMsg = (uintptr_t)(&msg); + + tickbase_manipulation((CCLCMsg_Move_t*)&msg, pNetChan); + + return ofc(pNetChan, msg, bForceReliable, bVoice); + }*/ + + if (msg.GetType() == 14) // Return and don't send messsage if its FileCRCCheck + return true; + + if (msg.GetGroup() == 9) // Fix lag when transmitting voice and fakelagging + bVoice = true; + + return ofc(pNetChan, msg, bForceReliable, bVoice); + } + + return ofc(pNetChan, msg, bForceReliable, bVoice); + } + + void __fastcall Shutdown(INetChannel* pNetChan, void* EDX, const char* reason) { + using Fn = void(__thiscall*)(INetChannel*, const char*); + const auto ofc = vmt.m_net_channel->VCall(27); + + vmt.m_net_channel.reset(); + vmt.m_net_channel = nullptr; + + return ofc(pNetChan, reason); + } +} +``` + +`core.hpp`: + +```hpp +#pragma once + +#include "auto.hpp" + +constexpr auto RadPi = 3.14159265358979323846; +constexpr auto DegPi = 180.0; + +class Vector2D; +class Vector; +class Vector4D; + +class QAngle; + +struct matrix3x4_t; +class VMatrix; + +template +T Square( T value ) +{ + return ( value * value ); +} + +template +void LimitValue( T& value, const T& min, const T& max ) +{ + if( value > max ) + value = max; + else if( value < min ) + value = min; +} + +template +T ToRadians( T degrees ) +{ + return ( degrees * ( static_cast( RadPi ) / static_cast( DegPi ) ) ); +} + +template +T ToDegrees( T radians ) +{ + return ( radians * static_cast(57.295776f) ); +} + +void FORCEINLINE AngleNormalize( float& angle ) +{ + angle = fmodf( angle, 360.0f ); + + if( angle > 180.0f ) + angle -= 360.0f; + else if( angle < -180.0f ) + angle += 360.0f; +} +``` + +`createmove.cpp`: + +```cpp +#include "hooked.hpp" +#include "displacement.hpp" +#include "player.hpp" +#include "weapon.hpp" +#include "prediction.hpp" +#include "movement.hpp" +#include "anti_aimbot.hpp" +#include "misc.hpp" +#include +#include "usercmd.hpp" +#include "lag_comp.hpp" +#include "rage_aimbot.hpp" +//#include "music_player.hpp" +#include "grenades.hpp" +#include "resolver.hpp" +#include "visuals.hpp" +#include "menu.hpp" +#include "aimbot.hpp" + +void ApplyDTShift(int cmd_num, int commands_to_shift, int original_choke) +{ + auto shift_data = &Engine::Prediction::Instance()->m_tickbase_array[cmd_num % 150]; + + auto latency_ticks = ctx.last_cmd_delta; + + if (ctx.last_4_deltas.size() >= 3) { + latency_ticks = 0; + int added = 0; + + + for (auto d : ctx.last_4_deltas) + { + latency_ticks += d; + ++added; + if (added >= 4) + break; + } + + latency_ticks /= 4; + } + + auto serverTickcount = csgo.m_globals()->tickcount + latency_ticks; + const int nCorrectionTicks = TIME_TO_TICKS(0.029999999f); + + int nIdealFinalTick = serverTickcount + nCorrectionTicks; + auto simulation_ticks = commands_to_shift + 1 + original_choke; + int nCorrectedTick = nIdealFinalTick - simulation_ticks + 1; + + shift_data->command_num = cmd_num; + shift_data->extra_shift = 0; + shift_data->increace = false; + shift_data->doubletap = true; + shift_data->tickbase_original = nCorrectedTick; + + csgo.m_prediction()->m_previous_startframe = -1; + csgo.m_prediction()->m_nCommandsPredicted = 0; +} + +void CopyCommandSkeet(CUserCmd* from_cmd) +{ + auto viewangles = QAngle::Zero; + + auto net_channel = static_cast(csgo.m_client_state()->m_ptrNetChannel); + + csgo.m_engine()->GetViewAngles(viewangles); + + const auto o_chocked = csgo.m_client_state()->m_iChockedCommands; + + auto commands_to_shift = ctx.ticks_allowed - o_chocked - 1; + + if (commands_to_shift > 13) + commands_to_shift = 13; + + if (commands_to_shift > 0 && net_channel) + { + const auto time = csgo.m_globals()->curtime; + + from_cmd->sidemove = Engine::Movement::Instance()->old_movement.y; + from_cmd->forwardmove = Engine::Movement::Instance()->old_movement.x; + + if (!ctx.m_settings.aimbot_extra_doubletap_options[0] || ctx.m_local()->m_vecVelocity().Length2D() <= 2) { + from_cmd->sidemove = 0.f; + from_cmd->forwardmove = 0.f; + } + else + { + if (abs(from_cmd->sidemove) > 10.f) + from_cmd->sidemove = copysignf(450.f, from_cmd->sidemove); + else + from_cmd->sidemove = 0.f; + + if (abs(from_cmd->forwardmove) > 10.f) + from_cmd->forwardmove = copysignf(450.f, from_cmd->forwardmove); + else + from_cmd->forwardmove = 0.f; + } + + auto m_nTickBase = &ctx.m_local()->m_nTickBase(); + + *m_nTickBase -= commands_to_shift; + + csgo.m_globals()->curtime = TICKS_TO_TIME(*m_nTickBase); + ++* m_nTickBase; + + std::vector cmds = {}; + + for (auto i = 0; i < commands_to_shift; i++) + { + auto command = &cmds.emplace_back(); + + memcpy(command, from_cmd, 0x64); + + command->viewangles = viewangles; + command->command_number += i; + + Engine::Prediction::Instance()->Predict(command); + /*csgo.m_prediction()->Update(csgo.m_client_state()->m_iDeltaTick, + csgo.m_client_state()->m_iDeltaTick > 0, + csgo.m_client_state()->m_iLastCommandAck, + csgo.m_client_state()->m_iLastOutgoingCommand + csgo.m_client_state()->m_iChockedCommands + i);*/ + + Engine::Movement::Instance()->FixMove(command, ctx.cmd_original_angles); + + command->viewangles.Clamp(); + } + + csgo.m_globals()->curtime = time; + + for (auto i = 0; i < commands_to_shift; i++) + { + auto command = csgo.m_input()->GetUserCmd(cmds[i].command_number); + auto v8 = csgo.m_input()->GetVerifiedUserCmd(cmds[i].command_number); + + memcpy(command, &cmds[i], sizeof(CUserCmd)); + + bool v6 = command->tick_count == 0x7F7FFFFF; + command->hasbeenpredicted = v6; + + v8->m_cmd = *command; + v8->m_crc = command->GetChecksum(); + + ++net_channel->choked_packets; + ++net_channel->out_sequence_nr; + ++csgo.m_client_state()->m_iChockedCommands; + } + + if (commands_to_shift <= 15) + ApplyDTShift(from_cmd->command_number, commands_to_shift, o_chocked); + + ctx.force_aimbot = commands_to_shift + from_cmd->command_number; + ctx.allow_shooting = commands_to_shift + from_cmd->command_number; + + cmds.clear(); + } +} + +void CopyCommand(CUserCmd* from_cmd) +{ + // [COLLAPSED LOCAL DECLARATIONS. PRESS KEYPAD CTRL-"+" TO EXPAND] + // + //if (ctx.ticks_allowed < 13) + // return; + // + //ctx.shifted_cmd = 14; + // + //csgo.m_prediction()->Update(csgo.m_client_state()->m_iDeltaTick, csgo.m_client_state()->m_iDeltaTick > 0, csgo.m_client_state()->m_iLastCommandAck, csgo.m_client_state()->m_iLastOutgoingCommand + csgo.m_client_state()->m_iChockedCommands); + // + ////--ctx.m_local()->m_nTickBase(); + //ctx.shift_amount = 14; + // + //return; + + auto net_channel = static_cast(csgo.m_client_state()->m_ptrNetChannel); + + auto viewangles = QAngle::Zero; + + csgo.m_engine()->GetViewAngles(viewangles); + auto pred = &Engine::Prediction::Instance(); + + //auto max_speed = m_weapon()->GetMaxWeaponSpeed(); + + /*const auto v63 =(ctx.m_local()->m_flDuckAmount() * 0.34f) + 1.0f; + const auto v46 = 1.0f / (v63 - ctx.m_local()->m_flDuckAmount());*/ + + //bool before = false; + + //Engine::Prediction::Instance()->doubletap_data = Engine::Prediction::Instance()->restore_data; + //Engine::Prediction::Instance()->doubletap2_data.Setup(ctx.m_local()); + + from_cmd->sidemove = Engine::Movement::Instance()->old_movement.y; + from_cmd->forwardmove = Engine::Movement::Instance()->old_movement.x; + + if (!ctx.m_settings.aimbot_extra_doubletap_options[0] || ctx.m_local()->m_vecVelocity().Length2D() <= 2) { + from_cmd->sidemove = 0.f; + from_cmd->forwardmove = 0.f; + } + else + { + if (abs(from_cmd->sidemove) > 10.f) + from_cmd->sidemove = copysignf(450.f, from_cmd->sidemove); + else + from_cmd->sidemove = 0.f; + + if (abs(from_cmd->forwardmove) > 10.f) + from_cmd->forwardmove = copysignf(450.f, from_cmd->forwardmove); + else + from_cmd->forwardmove = 0.f; + } + + //ctx.original_tickbase = ctx.m_local()->m_nTickBase() + 1 + 1; + from_cmd->buttons &= ~(IN_ATTACK | IN_ATTACK2); + //from_cmd->hasbeenpredicted = false; + + ctx.started_speedhack = ctx.current_tickcount; + ctx.shifted_cmd = from_cmd->command_number; + + ctx.tickbase_started_teleport = ctx.m_local()->m_nTickBase(); + + auto commands_to_shift = 13; + + if (commands_to_shift <= 0 || ctx.ticks_allowed < 13) + return; + + ctx.speedhack_choke = csgo.m_client_state()->m_iChockedCommands; + + int* tb = &ctx.m_local()->m_nTickBase(); + const auto btb = *tb; + + auto latency_ticks = ctx.last_cmd_delta; + + if (ctx.last_4_deltas.size() >= 3) { + latency_ticks = 0; + int added = 0; + for (auto d : ctx.last_4_deltas) + { + latency_ticks += d; + ++added; + if (added >= 4) + break; + } + latency_ticks /= 4; + } + + auto serverTickcount = ctx.current_tickcount + latency_ticks; + auto simulation_ticks = 13 + csgo.m_client_state()->m_iChockedCommands; + int nCorrectedTick = TIME_TO_TICKS(0.03f) + serverTickcount - simulation_ticks + 1; + + auto cmd_nr = csgo.m_client_state()->m_iLastOutgoingCommand + 1; + + auto shift_data = &pred->m_tickbase_array[cmd_nr % 150]; + + if (shift_data) + { + shift_data->command_num = cmd_nr; + shift_data->increace = true; + shift_data->doubletap = true; + shift_data->tickbase_original = nCorrectedTick; + } + + net_channel->set_chocked(); + ++csgo.m_client_state()->m_iChockedCommands; + + const auto time = csgo.m_globals()->curtime; + + csgo.m_prediction()->m_nCommandsPredicted = 0; + csgo.m_prediction()->m_previous_startframe = -1; + + auto commands_to_add = 0; + do + { + csgo.m_prediction()->Update(csgo.m_client_state()->m_iDeltaTick, true, csgo.m_client_state()->m_iLastCommandAck, + csgo.m_client_state()->m_iLastOutgoingCommand + csgo.m_client_state()->m_iChockedCommands); + + const auto v2 = commands_to_add + from_cmd->command_number; + auto command = csgo.m_input()->GetUserCmd(v2); + auto v8 = csgo.m_input()->GetVerifiedUserCmd(v2); + + memcpy(command, from_cmd, 0x64); + auto v7 = (command->tick_count == 0x7F7FFFFF); + + auto vel = sqrtf((ctx.m_local()->m_vecVelocity().z * ctx.m_local()->m_vecVelocity().z) + + (ctx.m_local()->m_vecVelocity().x * ctx.m_local()->m_vecVelocity().x) + + (ctx.m_local()->m_vecVelocity().y * ctx.m_local()->m_vecVelocity().y)); + + command->command_number = v2; + + if (ctx.m_local()->m_fFlags() & FL_ONGROUND && ctx.m_settings.aimbot_extra_doubletap_options[1] && commands_to_add >= (4 * int((ctx.max_weapon_speed * 0.34f) > vel) + 7)) + Engine::Movement::Instance()->Quick_stop(command); + + if (!ctx.auto_peek_spot.IsZero()) + { + auto angle = Math::CalcAngle(ctx.m_local()->m_vecAbsOrigin(), ctx.auto_peek_spot); + viewangles.y = angle.y; + + command->forwardmove = 450.f; + command->sidemove = 0.0f; + } + + auto v64 = (ctx.m_local()->m_flDuckAmount() * 0.34f) + 1.0f; + auto v47 = 1.0f / (v64 - ctx.m_local()->m_flDuckAmount()); + command->forwardmove = command->forwardmove * v47; + command->sidemove = v47 * command->sidemove; + + if (command->sidemove > 450.f) + command->sidemove = 450.f; + else if (command->sidemove < -450.f) + command->sidemove = -450.f; + + if (command->forwardmove > 450.f) + command->forwardmove = 450.f; + else if (command->forwardmove < -450.f) + command->forwardmove = -450.f; + + Engine::Movement::Instance()->FixMove(command, viewangles); + + Engine::Prediction::Instance()->Predict(command); + { + const auto bFirstCommandPredicted = *(bool*)(uintptr_t(csgo.m_prediction()) + 0x18); + const auto m_bInPrediction = csgo.m_prediction()->m_in_prediction; + + *(BYTE*)(uintptr_t(csgo.m_prediction()) + 0x18) = 0; + csgo.m_prediction()->m_in_prediction = true; + + ctx.m_local()->SetCurrentCommand(command); + C_BaseEntity::SetPredictionRandomSeed(command); + C_BaseEntity::SetPredictionPlayer(ctx.m_local()); + + csgo.m_globals()->curtime = TICKS_TO_TIME(*tb - 1); + + csgo.m_move_helper()->SetHost(ctx.m_local()); + csgo.m_prediction()->RunCommand(ctx.m_local(), command, csgo.m_move_helper()); + + csgo.m_move_helper()->SetHost(nullptr); + *(bool*)(uintptr_t(csgo.m_prediction()) + 0x18) = bFirstCommandPredicted; + csgo.m_prediction()->m_in_prediction = m_bInPrediction; + + C_BaseEntity::SetPredictionRandomSeed(nullptr); + C_BaseEntity::SetPredictionPlayer(nullptr); + ctx.m_local()->SetCurrentCommand(0); + } + + //m_weapon()->m_flLastShotTime() = last_shot_time; + //m_weapon()->m_flAccuracyPenalty() = last_acc; + + command->hasbeenpredicted = 0; + + command->viewangles.Clamp(); + memcpy(&v8->m_cmd, command, 0x64); + v8->m_crc = command->GetChecksum(); + + if ((commands_to_add + 1) < commands_to_shift) { + net_channel->set_chocked(); + ++csgo.m_client_state()->m_iChockedCommands; + } + //++net_channel->choked_packets; + //++net_channel->out_sequence_nr; + + ++commands_to_add; + ctx.ticks_allowed--; + } while (commands_to_add < commands_to_shift); + + csgo.m_globals()->curtime = time; + + //const auto next_cmd_nr = csgo.m_client_state()->m_iLastOutgoingCommand + csgo.m_client_state()->m_iChockedCommands + 1; + + ctx.force_aimbot = from_cmd->command_number + 13;// -2; + ctx.allow_shooting = from_cmd->command_number + 1;// - 2; + + //*tb = btb; + + //*tb += commands_to_shift; + + ctx.last_speedhack_time = csgo.m_globals()->realtime; +} + +//void PrepareCommandsForInput(int command_nr, CUserCmd* commands, int count_of_commands) +//{ +// int v3; // edi +// DWORD* v4; // eax +// +// v3 = ~count_of_commands - *(_DWORD*)m_nChokedCommands; +// v4 = (DWORD*)(pizdec + 8 * ((*(_DWORD*)LastOutgoingCommand + 1) % 150)); +// *v4 = *(DWORD*)LastOutgoingCommand + 1; +// v4[1] = v3; +// WriteCommandsToInput(command_nr + 1, commands, count_of_commands); +// // force repredict +// *(DWORD*)(csgo.m_prediction() + 0xC) = -1; +// *(DWORD*)(csgo.m_prediction() + 0x1C) = 0; +//} + +bool IsTickcountValid(int tick) { + return (ctx.cmd_tickcount + 64 + 8) > tick; +} + +void ApplyShift(CUserCmd* cmd, bool* bSendPacket) { + if (*bSendPacket) { + INetChannel* net_channel = (INetChannel*)(csgo.m_client_state()->m_ptrNetChannel); + //auto v10 = net_channel->choked_packets; + //if (v10 >= 0) { + // auto v11 = cmd->command_number - v10; + // //auto v33 = cmd->command_number - v10; + // do { + // auto v12 = &csgo.m_input()->m_pCommands[cmd->command_number - 150 * (v11 / 150) - v10]; + // auto v14 = &csgo.m_input()->m_pVerifiedCommands[cmd->command_number - 150 * (v11 / 150) - v10]; + // if (!v12 || !v14 || IsTickcountValid(cmd->tick_count)) { + // auto v13 = --ctx.ticks_allowed; + // if (v13 <= 0) + // v13 = 0; + // ctx.ticks_allowed = v13; + // } + // //v11 = v33 + 1; + // ++v11; + // --v10; + // } while (v10 >= 0); + //} + auto v7 = net_channel->choked_packets; + if (v7 >= 0) { + auto v8 = ctx.ticks_allowed; + auto v9 = cmd->command_number - v7; + do + { + auto v10 = &csgo.m_input()->m_pCommands[cmd->command_number - 150 * (v9 / 150) - v7]; + if (!v10 + || IsTickcountValid(v10->tick_count)) + { + if (--v8 <= 0) + v8 = 0; + ctx.ticks_allowed = v8; + } + ++v9; + --v7; + } + while (v7 >= 0); + } + } + + auto v14 = ctx.ticks_allowed; + if (v14 > 16) { + auto v15 = v14 - 1; + ctx.ticks_allowed = Math::clamp(v15, 0, 16); + } +} + +//class activity_modifiers_wrapper +//{ +//private: +// MEMBER_REL("server.dll", "?", add_activity_modifier(const char* name), void(__thiscall*)(void*, const char*))(name); +// uint32_t gap[0x4D]{ 0 }; +// CUtlVector modifiers{}; +// +//public: +// activity_modifiers_wrapper() = default; +// +// explicit activity_modifiers_wrapper(CUtlVector current_modifiers) +// { +// modifiers.RemoveAll(); +// modifiers.SetGrowSize(current_modifiers.Count()); +// +// for (auto i = 0; i < current_modifiers.Count(); i++) +// modifiers[i] = current_modifiers[i]; +// } +// +// void add_modifier(const char* name) +// { +// add_activity_modifier(name); +// } +// +// CUtlVector get() const +// { +// return modifiers; +// } +//}; +// +//CUtlVector build_activity_modifiers() +//{ +// activity_modifiers_wrapper modifier_wrapper{}; +// +// modifier_wrapper.add_modifier(state->get_active_weapon_prefix()); +// +// if (state->running_speed > .25f) +// modifier_wrapper.add_modifier("moving"); +// +// if (state->duck_amount > .55f) +// modifier_wrapper.add_modifier("crouch"); +// +// return modifier_wrapper.get(); +//} +// +//inline void try_initiate_animation(size_t layer, int32_t activity, CUtlVector modifiers) +//{ +// typedef void* (__thiscall * find_mapping_t)(void*); +// static const auto find_mapping = (find_mapping_t)PATTERN_REL(uintptr_t, "server.dll", "?")(); +// +// typedef int32_t(__thiscall * select_weighted_sequence_from_modifiers_t)(void*, void*, int32_t, const void*, int32_t); +// static const auto select_weighted_sequence_from_modifiers = (select_weighted_sequence_from_modifiers_t)PATTERN(uintptr_t, "server.dll", "?")(); +// +// const auto mapping = find_mapping(ctx.m_local()->GetModelPtr()); +// const auto sequence = select_weighted_sequence_from_modifiers(mapping, ctx.m_local()->GetModelPtr(), activity, &modifiers[0], modifiers.Count()); +// +// if (sequence < 2) +// return; +// +// auto& l = ctx.m_local()->get_animation_layer(layer); +// l.m_flPlaybackRate = get_layer_sequence_cycle_rate(&l, sequence); +// l.m_nSequence = sequence; +// l.m_flCycle = l.m_flWeight = 0.f; +//} + +void CheckPaused(CUserCmd* cmd) +{ + if (!csgo.m_engine()->IsPaused()) + return; + cmd->buttons = 0; + cmd->forwardmove = 0; + cmd->sidemove = 0; + cmd->upmove = 0; + + // Don't allow changing weapons while paused + cmd->weaponselect = 0; +} + +namespace Hooked +{ + bool __stdcall CreateMove(float flInputSampleTime, CUserCmd* cmd) + { +#ifdef VIRTUALIZER + +#endif // VIRTUALIZER + + ctx.fix_modify_eye_pos = false; + + //ctx.latest_weapon_data = nullptr; + auto& prediction = Engine::Prediction::Instance(); + auto& movement = Engine::Movement::Instance(); + + bool cant_repredict = false; + //ctx.doubletap_now = false; + + if (ctx.updated_skin) + { + /*m_weapon()->set_model_index(ctx.knife_model_index + 1); + m_weapon()->pre_data_update(0); + m_weapon()->on_data_changed(0); + m_weapon()->post_data_update(0); + m_weapon()->set_model_index(ctx.knife_model_index); + m_weapon()->post_data_update(0); + m_weapon()->on_data_changed(0);*/ + if (csgo.m_engine()->IsInGame() && ctx.m_local()) { + csgo.m_client_state()->m_iDeltaTick = -1; + } + ctx.updated_skin = false; + + return false; + } + + /*if (ctx.last_shot_time_clientside < 0.f) + ctx.last_shot_time_clientside = 1.f;*/ + + if (!cmd || !ctx.m_local()) + return false; + + bool original = vmt.m_clientmode->VCall(Index::IBaseClientDLL::CreateMove)(flInputSampleTime, cmd); + + if (original) { + csgo.m_engine()->SetViewAngles(cmd->viewangles); + csgo.m_prediction()->SetLocalViewAngles(cmd->viewangles); + } + + if (cmd->command_number == 0) + return false; + + feature::lagcomp->update_lerp(); + feature::lagcomp->update_network_info(); + + /*if (ctx.charged_commands != 0) + { + ctx.m_local()->m_nTickBase() += ctx.charged_commands; + ctx.charged_commands = 0; + }*/ + + //if (cmd->tick_count == 0) + //{ + // //do something. + // return false; + // //cmd->tick_count = csgo.m_globals()->tickcount; + //} + + if (ctx.buy_weapons && ctx.m_settings.misc_autobuy_enabled) + { + std::string buy; + + ctx.ticks_allowed = 0; + + // ImGui::Text(sxor("Autobuy primary")); + //ImGui::Combo(sxor("##Autoprimary"), &ctx.m_settings.misc_autobuy_primary, "none\0AK47/M4A1\0AWP\0SCAR20/G3\0SSG-08\0\0"); + //ImGui::Text(sxor("Autobuy secondary")); + //ImGui::Combo(sxor("##Autoecondary"), &ctx.m_settings.misc_autobuy_secondary, "none\0Deagle/R8\0Tec9/FiveSeven\0Dual berettas\0P250/CZ-74\0"); + + + if (ctx.m_settings.misc_autobuy_primary == 1) + { + buy += "buy ak-47; "; + } + else if (ctx.m_settings.misc_autobuy_primary == 2) + { + buy += "buy awp; "; + + } + else if (ctx.m_settings.misc_autobuy_primary == 3) { + buy += "buy scar20; "; + + } + else if (ctx.m_settings.misc_autobuy_primary == 5) { + buy += "buy ssg08; "; + + } + + if (ctx.m_settings.misc_autobuy_secondary == 1) + { + buy += "buy deagle; "; + + } + else if (ctx.m_settings.misc_autobuy_secondary == 2) + { + buy += "buy tec9; "; + + } + else if (ctx.m_settings.misc_autobuy_secondary == 3) + { + buy += "buy elite; "; + + } + else if (ctx.m_settings.misc_autobuy_secondary == 4) + { + buy += "buy p250; "; + + } + + if (ctx.m_settings.misc_autobuy_etc[4]) { + buy += "buy hegrenade; "; + + } + if (ctx.m_settings.misc_autobuy_etc[7]) { + buy += "buy molotov; "; + + } + if (ctx.m_settings.misc_autobuy_etc[3]) { + buy += "buy smokegrenade; "; + + } + if (ctx.m_settings.misc_autobuy_etc[5]) { + buy += "buy flashbang; "; + + } + if (ctx.m_settings.misc_autobuy_etc[6]) { + buy += "buy flashbang; "; + + } + if (ctx.m_settings.misc_autobuy_etc[0]) { + buy += "buy taser; "; + + } + if (ctx.m_settings.misc_autobuy_etc[2]) { + buy += "buy defuser; "; + + } + if (ctx.m_settings.misc_autobuy_etc[1]) + { + buy += "buy vesthelm; "; + buy += "buy vest; "; + + } + + if (!buy.empty() && (ctx.m_settings.misc_autobuy_money_limit == 0 || ctx.m_local()->m_iAccount() > ctx.m_settings.misc_autobuy_money_limit)) + csgo.m_engine()->ClientCmd_Unrestricted(buy.c_str()); //TODO: maybe find another method how to autobuy? since this one is ghetto asf + + ctx.has_scar = false; + ctx.buy_weapons = false; + } + + ctx.fix_modify_eye_pos = true; + + //if (ctx.original_model_index > 0) + // ctx.m_local()->set_model_index(ctx.original_model_index); + + ctx.applied_tickbase = false; + bool send_packet = true; + //static bool was_jumping = false; + static bool did_shift_before = false; + ctx.start_switching = false; + ctx.did_shot = false; + //ctx.next_shift_amount = 0; + ctx.exploit_tickbase_shift = 0; + //ctx.prediction_tickbase = -1; + ctx.shift_amount = 0; + //ctx.speed_hack = 0; + ctx.max_weapon_speed = 250.f; + ctx.can_aimbot = true; + bool skip_fakelags = false; + feature::anti_aim->skip_fakelag_this_tick = false; + Engine::Movement::Instance()->did_force = false; + + ctx.active_keybinds[14].mode = 0; + + ctx.air_stuck = ctx.get_key_press(ctx.m_settings.anti_aim_timestop_key); + if (ctx.air_stuck) + ctx.active_keybinds[14].mode = ctx.m_settings.anti_aim_timestop_key.mode + 1; + + if (csgo.m_game_rules()) { + ctx.active_keybinds[0].mode = 0; + if (ctx.fakeducking) + { + if (!csgo.m_game_rules()->IsValveDS()) + ctx.active_keybinds[0].mode = ctx.m_settings.anti_aim_fakeduck_key.mode + 1; + } + } + + //ctx.auto_peek_spot.clear(); + //static int cur_exploit = ctx.m_settings.aimbot_tickbase_exploit; + + //if (csgo.m_client_state()) + // ctx.shift_amount = ticks_allowed - csgo.m_client_state()->m_iChockedCommands; + + //if (csgo.m_client_state() != nullptr && csgo.m_prediction() != nullptr && csgo.m_engine()->IsInGame() && ctx.m_local() && !ctx.m_local()->IsDead()/* && ctx.last_frame_stage == FRAME_NET_UPDATE_END*/) { + // const auto ticks = ctx.host_frameticks() + csgo.m_client_state()->m_iChockedCommands; + // const auto lag_limit = (int)ctx.m_settings.fake_lag_value + 2; + // + // if (ticks > lag_limit) // detected rubberbanding + // { + // auto delta = ticks - lag_limit; + // + // for (int i = 0; i < delta; ++i) { + // csgo.m_prediction()->Update(csgo.m_client_state()->m_iDeltaTick, true/*csgo.m_client_state()->m_iDeltaTick > 0*/, csgo.m_client_state()->m_iLastCommandAck, + // csgo.m_client_state()->m_iLastOutgoingCommand + i); + // } + // } + //} + + //ctx.fix_modify_eye_pos = (ctx.m_local()->m_flDuckAmount() > 0.01f && ctx.fakeducking || ctx.m_local()->get_animation_state() && ctx.m_local()->get_animation_state()->hitgr_anim); + + //if (ctx.m_settings.aimbot_doubletap) + // ctx.m_settings.anti_aim_typelby = 1; + + //static int ticks_allowed = 0; + + ctx.doubletap_charged = false; + ctx.is_cocking = false; + ctx.is_able_to_shoot = false; + + ctx.cmd_original_angles = cmd->viewangles; + ctx.cmd_tickcount = cmd->tick_count; + //ctx.current_tickcount = csgo.m_input()->m_pCommands[cmd->command_number % 150].tick_count; + + //ctx.current_tickcount = csgo.m_globals()->tickcount; + + //m_latency->cmd_num = cmd->command_number; + //m_latency->tick_count = ctx.current_tickcount; + + ctx.cmd_original_buttons = cmd->buttons; + ctx.current_realtime = csgo.m_globals()->realtime; + ctx.tickrate = 1.f / csgo.m_globals()->interval_per_tick; + + const auto is_switching_weapons = cmd->weaponselect != 0; + + if (feature::anti_aim->did_shot_in_chocked_cycle && csgo.m_client_state()->m_iChockedCommands == 0) + feature::anti_aim->did_shot_in_chocked_cycle = false; + + if (is_switching_weapons || feature::menu->_menu_opened || ctx.m_local()->m_bWaitForNoAttack() || ctx.m_settings.fake_lag_shooting && feature::anti_aim->did_shot_in_chocked_cycle) { + cmd->buttons &= ~IN_ATTACK; + //cmd->buttons &= ~IN_ATTACK2; + } + + if (ctx.m_local() && m_weapon() != nullptr) { + ctx.latest_weapon_data = m_weapon()->GetCSWeaponData(); + ctx.max_weapon_speed = (!ctx.m_local()->m_bIsScoped() ? *(float*)(uintptr_t(ctx.latest_weapon_data) + 0x130) : *(float*)(uintptr_t(ctx.latest_weapon_data) + 0x134)); + } + + ctx.m_eye_position.clear(); + + const auto aim_toggled = ctx.m_settings.aimbot_enabled; + + ctx.allows_aimbot = ctx.m_settings.aimbot_enabled; + + if (ctx.m_local() && ctx.m_local()->GetClientClass() && !ctx.m_local()->IsDead()) + { + if ((vmt.m_clientstate == nullptr || !vmt.m_clientstate->is_hooked) && csgo.m_client_state() != nullptr && (CClientState*)(uint32_t(csgo.m_client_state()) + 8) != nullptr && csgo.m_game_rules())// && ctx.m_local() != nullptr && !ctx.m_local()->IsDead()) + { + vmt.m_clientstate = std::make_shared((CClientState*)(uint32_t(csgo.m_client_state()) + 8)); + + if (vmt.m_clientstate) { + vmt.m_clientstate->Hook(&Hooked::PacketEnd, 6); + vmt.m_clientstate->Hook(&Hooked::PacketStart, 5); + //vmt.m_clientstate->Hook(&Hooked::ProcessTempEntities, 36); + } + } + + if ((vmt.m_net_channel == nullptr || !vmt.m_net_channel->is_hooked) && csgo.m_client_state() != nullptr && csgo.m_client_state()->m_ptrNetChannel != nullptr && csgo.m_game_rules())// && ctx.m_local() != nullptr && !ctx.m_local()->IsDead()) + { + vmt.m_net_channel = std::make_shared((DWORD**)csgo.m_client_state()->m_ptrNetChannel); + + if (vmt.m_net_channel) { + vmt.m_net_channel->Hook(&Hooked::SendNetMsg, 40); + vmt.m_net_channel->Hook(&Hooked::Shutdown, 27); + vmt.m_net_channel->Hook(&Hooked::SendDatagram, 46); + //vmt.m_net_channel->Hook(&Hooked::ProcessPacket, 39); + } + //vmt.m_net_channel->Hook(&Hooked::SendDatagram, 46); + } + + /*static auto* cl_righthand = csgo.m_engine_cvars()->FindVar(sxor("cl_righthand")); + static auto old_value = cl_righthand->GetInt(); + static auto old_value_fc = !ctx.m_settings.visuals_force_crosshair; + static int old_fc = INT_MAX; + + if (old_value_fc != ctx.m_settings.visuals_force_crosshair) { + static auto* m_iCrosshairData = csgo.m_engine_cvars()->FindVar(sxor("weapon_debug_spread_show")); + + if (old_fc == INT_MAX) + old_fc = m_iCrosshairData->GetInt(); + + if (ctx.m_settings.visuals_force_crosshair && !ctx.m_local()->m_bIsScoped()) + m_iCrosshairData->SetValue(3); + else + m_iCrosshairData->SetValue(old_fc); + + old_value_fc = ctx.m_settings.visuals_force_crosshair; + }*/ + + //cmd->command_number - 1 - csgo.m_client_state()->m_iLastCommandAck <= 149 && + + //auto v24 = csgo.m_globals()->curtime - ctx.m_local()->m_flSpawnTime(); + + //if (v24 < 1.0f || csgo.m_client_state()->m_iChockedCommands > 0 || ctx.ticks_allowed >= 14) { + if (ctx.last_frame_stage == 4) { + csgo.m_prediction()->Update(csgo.m_client_state()->m_iDeltaTick, csgo.m_client_state()->m_iDeltaTick > 0, csgo.m_client_state()->m_iLastCommandAck, + csgo.m_client_state()->m_iLastOutgoingCommand + csgo.m_client_state()->m_iChockedCommands); + + //prediction->FixNetvarCompression(cmd->command_number - 1); + } + //} + + //if (ctx.has_exploit_toggled && !ctx.fakeducking) + //{ + // auto can_charge = false; + + // if (ctx.latest_weapon_data != nullptr) + // { + // auto charge = std::fmaxf(ctx.latest_weapon_data->flCycleTime, 0.5f); + + // if (ctx.fakeducking_prev_state) + // { + // ctx.last_speedhack_time = csgo.m_globals()->realtime; + // can_charge = false; + // } + + // if (std::fabsf(csgo.m_globals()->realtime - ctx.last_speedhack_time) >= charge) + // can_charge = true; + // } + + // static int first_tickbase = 0; + + // if (ctx.ticks_allowed < 15 && (csgo.m_globals()->realtime - ctx.last_speedhack_time) > 0.25f && !ctx.air_stuck && ctx.exploit_allowed && can_charge && m_weapon() != nullptr && !m_weapon()->IsGrenade()) { // createmove + // + // if (first_tickbase == 0) + // first_tickbase = ctx.m_local()->m_nTickBase(); + // + // cmd->tick_count = 0x7FFFFFFF; + // cmd->forwardmove = 0.0f; + // cmd->sidemove = 0.0f; + // cmd->upmove = 0.0f; + // ctx.force_aimbot = 0; + // ctx.is_charging = true; + // ctx.last_time_charged = csgo.m_globals()->realtime; + // csgo.m_globals()->interpolation_amount = 0.f; + // + // auto shift_data = &Engine::Prediction::Instance()->m_tickbase_array[cmd->command_number % 150]; + + // if (shift_data) + // { + // shift_data->command_num = cmd->command_number; + // shift_data->increace = true; + // shift_data->doubletap = true; + // shift_data->charge = true; + // shift_data->tickbase_original = ++first_tickbase; + // //_events.push_back({"tb: " + std::to_string(nCorrectedTick)}); + // } + + // *reinterpret_cast(*reinterpret_cast(static_cast(_AddressOfReturnAddress()) - 0x4) - 0x1C) = false; + + // return false; + // } + // else { + // ctx.is_charging = false; + + // first_tickbase = 0; + + // if (m_weapon() != nullptr) + // ctx.doubletap_charged = abs((csgo.m_globals()->curtime - TICKS_TO_TIME(ctx.main_exploit == 2 ? 14 : 13)) - m_weapon()->m_flNextPrimaryAttack()) >= TICKS_TO_TIME(ctx.main_exploit == 2 ? 14 : 13); + // } + + // //if (ctx.ticks_allowed > 13) + // // ctx.allow_shooting = 0; + //} + + //if (ctx.allow_shooting <= 0) + //ctx.exploit_allowed = ctx.ticks_allowed > 13; + + ctx.last_usercmd = cmd; // we don't need usercmds from non-reliable ticks + + //auto v23 = -ctx.accurate_max_previous_chocked_amt; + // + //do + //{ + // v23 += ctx.last_usercmd->command_number - ctx.accurate_max_previous_chocked_amt; + // if (v23 > prediction->prev_cmd_command_num) + // { + // auto v28 = csgo.m_input()->GetUserCmd(v23 % 150); + // if (v28 && !v28->hasbeenpredicted) + // prediction->Predict(v28); + // //EnginePrediction(v6, v28); + // } + // ++v23; + //} while (v23 < 0); + + auto exploit_toggled = (!ctx.has_exploit_toggled ? 0 : ctx.main_exploit); + + //if (auto weapon = m_weapon(); + // weapon != nullptr && + // exploit_toggled == 2 && + // ctx.exploit_allowed && + // !ctx.fakeducking && + // weapon->IsGun() && + // weapon->can_exploit(14) && + // fabs(csgo.m_globals()->realtime - ctx.last_speedhack_time) > 0.5f) + //{ + // //old_tickbase = ctx.m_local()->m_nTickBase(); + // ctx.m_local()->AdjustPlayerTimeBase(ctx.m_local()->DetermineSimulationTicks()); + + // //if (old_tickbase != ctx.m_local()->m_nTickBase()) + // // ctx.prediction_tickbase = ctx.m_local()->m_nTickBase(); + //} + + ctx.fps = 1 / csgo.m_globals()->frametime; + + feature::misc->pre_prediction(cmd); + + ctx.active_keybinds[4].mode = 0; + //if (csgo.m_client_state() != nullptr && csgo.m_prediction() != nullptr && csgo.m_globals()->tickcount != ctx.current_tickcount && csgo.m_engine()->IsInGame() && ctx.m_local() && !ctx.m_local()->IsDead()) { + // const auto ticks = ctx.host_frameticks(); + // // + // //if (ticks > (ctx.m_settings.fake_lag_value + 1)) { // detected rubberbanding + // // *(DWORD*)(csgo.m_prediction() + 0xC) = -1; + // // *(DWORD*)(csgo.m_prediction() + 0x1C) = 0; + // // send_packet = true; + // //} + // + // static int last_outgoing = -1; + // if ((ticks + csgo.m_client_state()->m_iChockedCommands) > (ctx.accurate_max_previous_chocked_amt + 2)) + // { + // //auto PING = TIME_TO_TICKS(csgo.m_engine()->GetNetChannelInfo()->GetLatency(0)); + // //for (int i = 0; i < (ticks + csgo.m_client_state()->m_iChockedCommands - ctx.accurate_max_previous_chocked_amt + PING); ++i) { + // // auto prev_cmd = *(&csgo.m_input()->m_pCommands[prediction->prev_cmd_command_num % 150]); + // // //CUserCmd prev_cmd; + // // prev_cmd.viewangles = ctx.m_local()->m_angEyeAngles(); + // // prev_cmd.tick_count = -1337; + // // prev_cmd.command_number = (last_outgoing + 1) % 150; + // // //m_nTickBase = TIME_TO_TICKS(flTimeBase); + // // + // // csgo.m_input()->m_pCommands[(last_outgoing + 1) % 150] = prev_cmd; + // //} + // send_packet = true; + // skip_fakelags = true; + // csgo.m_prediction()->m_bPreviousAckHadErrors = 1; + // csgo.m_prediction()->m_nCommandsPredicted = 0; + // } + // last_outgoing = csgo.m_client_state()->m_iLastOutgoingCommand; + //} + + //csgo.m_globals()->curtime = TICKS_TO_TIME(ctx.m_local()->m_nTickBase()); + + if (ctx.doubletap_now && ctx.speed_hacking && ctx.shifted_cmd != cmd->command_number) + { + if (!ctx.m_settings.aimbot_extra_doubletap_options[0]) + { + cmd->sidemove = 0.f; + cmd->forwardmove = 0.f; + } + + ctx.was_teleporting = true; + + cmd->buttons &= ~IN_ATTACK; + } + + movement->Begin(cmd, send_packet); + movement->did_force = false; + + prediction->PrePrediction(cmd); + + /*if (csgo.m_prediction()->m_nCommandsPredicted <= 0) + { + prediction->m_vecPredVelocity.clear(); + prediction->m_vecPrePredVelocity.clear(); + }*/ + + //const auto prev_state = ctx.exploit_allowed; + prediction->SetupMovement(cmd); + + if (ctx.m_settings.aimbot_enabled) + cmd->tick_count += TIME_TO_TICKS(ctx.lerp_time); + + //static bool was_ducking_before_fd = false; + //static bool went_full_chocking_cycle = false; + + if (csgo.m_game_rules() != nullptr && !csgo.m_game_rules()->IsValveDS()/* && cmd->buttons & IN_DUCK*/ || ctx.fakeducking) + cmd->buttons |= IN_BULLRUSH; + + ctx.fakeduck_will_choke = 0; + + if (ctx.fakeducking) + { + if (!ctx.fakeducking_prev_state) + { + if (ctx.m_local()->m_flDuckAmount() > 0) + cmd->buttons |= IN_DUCK; + + send_packet = true; + } + else + { + if (csgo.m_client_state()->m_iChockedCommands <= 6) + cmd->buttons &= ~IN_DUCK; + else + cmd->buttons |= IN_DUCK; + + // credits: onetap + ctx.fakeduck_will_choke = (14 - csgo.m_client_state()->m_iChockedCommands); + + send_packet = (csgo.m_client_state()->m_iChockedCommands >= 14); + } + + ctx.accurate_max_previous_chocked_amt = 14; + + ctx.next_shift_amount = 0; + ctx.shift_amount = 0; + } + + const Vector old_move = Vector(cmd->forwardmove, cmd->sidemove, cmd->upmove); + const bool pressed_b4 = cmd->buttons & 0x20000u; + + if (ctx.was_teleporting && !ctx.doubletap_now && !ctx.speed_hacking) + ctx.do_autostop = true; + + if (m_weapon()) { + if (ctx.do_autostop) + feature::ragebot->autostop(cmd, m_weapon()); + } + + movement->FixMove(cmd, movement->m_qAnglesView); + + /*auto shift = max(ctx.shift_amount, ctx.next_shift_amount); + + if (ctx.fakeducking || !ctx.exploit_allowed || !ctx.has_exploit_toggled || ctx.main_exploit == 0) + shift = 0; + else { + if (ctx.exploit_allowed && ctx.has_exploit_toggled && !ctx.fakeducking) + { + if (ctx.main_exploit == 2) + shift = 0; + + if (ctx.main_exploit == 2 && ctx.allow_shooting <= 0 && ctx.force_aimbot < 1 && ctx.ticks_allowed > 12 && abs(ctx.current_tickcount - ctx.started_speedhack) > 13) { + + auto serverTickcount = ctx.current_tickcount + 1; + const int nCorrectionTicks = TIME_TO_TICKS(0.029999999f); + + serverTickcount += TIME_TO_TICKS(ctx.latency[FLOW_OUTGOING]); + + int nIdealFinalTick = serverTickcount + nCorrectionTicks; + auto simulation_ticks = 13 + 1 + csgo.m_client_state()->m_iChockedCommands; + int nCorrectedTick = nIdealFinalTick - simulation_ticks + 1; + + shift = ctx.m_local()->m_nTickBase() - nCorrectedTick; + } + } + } + + int ticks = 0; + + if (m_weapon()->IsGun() && shift > 0) { + ticks = ctx.m_local()->m_nTickBase(); + ctx.m_local()->m_nTickBase() -= shift; + + csgo.m_globals()->curtime = TICKS_TO_TIME(ctx.m_local()->m_nTickBase()); + }*/ + + prediction->Predict(cmd); + + /*if (m_weapon()->IsGun() && ticks > 0) { + ctx.m_local()->m_nTickBase() = ticks; + + csgo.m_globals()->curtime = TICKS_TO_TIME(ticks); + }*/ + + C_BasePlayer* viewmodel = csgo.m_entity_list()->GetClientEntityFromHandle( + reinterpret_cast(ctx.m_local()->m_hViewModel())); + + prediction->m_hWeapon = 0; + + if (viewmodel) + { + prediction->m_hWeapon = ((C_BaseViewModel*)viewmodel)->get_viewmodel_weapon(); + prediction->m_nViewModelIndex = ((C_BaseViewModel*)viewmodel)->m_nViewModelIndex(); + prediction->m_nSequence = ((C_BaseViewModel*)viewmodel)->m_nSequence(); + + prediction->networkedCycle = viewmodel->m_flCycle(); + prediction->m_nAnimationParity = ((C_BaseViewModel*)viewmodel)->m_nAnimationParity(); + prediction->animationTime = ((C_BaseViewModel*)viewmodel)->m_flModelAnimTime(); + } + + /*if (!ctx.fakeducking) + { + auto ticks_to_stop = 0; + + static auto sv_friction = csgo.m_engine_cvars()->FindVar(sxor("sv_friction")); + static auto sv_stopspeed = csgo.m_engine_cvars()->FindVar(sxor("sv_stopspeed")); + static auto sv_accelerate = csgo.m_engine_cvars()->FindVar(sxor("sv_accelerate")); + + auto MaxSpeed = ctx.m_local()->get_weapon() ? ctx.m_local()->get_weapon()->GetMaxWeaponSpeed() : 250.f; + + static auto predict_velocity = [&](Vector* velocity) { + float speed = velocity->Length(); + if (speed >= 0.1f) { + float friction = fmaxf(sv_friction->GetFloat(), ctx.m_local()->m_surfaceFriction()); + float stop_speed = std::max< float >(speed, sv_stopspeed->GetFloat()); + float time = std::max< float >(csgo.m_globals()->interval_per_tick, csgo.m_globals()->frametime); + *velocity *= std::max< float >(0.f, speed - friction * stop_speed * time / speed); + + auto accel = sv_accelerate->GetFloat() * MaxSpeed * time * ctx.m_local()->m_surfaceFriction(); + *velocity -= accel; + } + }; + + auto m_vel = Engine::Prediction::Instance()->GetVelocity(); + + for (ticks_to_stop = 0; ticks_to_stop < 15; ticks_to_stop++) + { + if (m_vel.Length2D() < (MaxSpeed * 0.34f)) + break; + + predict_velocity(&m_vel); + } + + ctx.ticks_to_stop = ticks_to_stop; + }*/ + + /*if (ctx.m_local() && !ctx.m_local()->IsDead()) { + const auto oldposeparam = *(float*)(uintptr_t(ctx.m_local()) + (Engine::Displacement::DT_CSPlayer::m_flPoseParameter + 48)); + + auto angles = QAngle(0.f, !ctx.shot_angles.IsZero() ? ctx.shot_angles.y : Engine::Movement::Instance()->m_qRealAngles.y, 0); + ctx.m_local()->set_abs_angles(QAngle(0, angles.y, 0)); + + auto v114 = ctx.cmd_original_angles.x + ctx.m_local()->m_aimPunchAngleScaled().x; + + if (v114 > 180.0f) + v114 = v114 - 360.f; + + auto v115 = fminf(fmaxf(v114, -90.f), 90.f); + + *(float*)(uintptr_t(ctx.m_local()) + (Engine::Displacement::DT_CSPlayer::m_flPoseParameter + 48)) = (v115 + 90.f) / 180.f; + ctx.m_local()->force_bone_rebuild(); + ctx.m_local()->SetupBonesEx(BONE_USED_BY_HITBOX); + + ctx.m_eye_position = ctx.m_local()->GetEyePosition(); + *(float*)(uintptr_t(ctx.m_local()) + (Engine::Displacement::DT_CSPlayer::m_flPoseParameter + 48)) = oldposeparam; + }*/ + + feature::grenades->think(cmd); + + ctx.active_keybinds[5].mode = 0; + ctx.active_keybinds[6].mode = 0; + ctx.active_keybinds[7].mode = 0; + ctx.active_keybinds[10].mode = 0; + ctx.active_keybinds[12].mode = 0; + ctx.allow_freestanding = false; + if (ctx.get_key_press(ctx.m_settings.anti_aim_freestanding_key)) { + ctx.active_keybinds[12].mode = ctx.m_settings.anti_aim_freestanding_key.mode + 1; + ctx.allow_freestanding = true; + } + + ctx.active_keybinds[9].mode = 0; + ctx.active_keybinds[8].mode = 0; + + //else { + // //ctx.was_fakeducking_before = false; + // went_full_chocking_cycle = false; + // was_ducking_before_fd = (cmd->buttons & IN_DUCK) || ctx.m_local()->m_flDuckAmount() > 0.1f; + //} + //ctx.fix_velocity_modifier = true; + + //feature::anti_aim->DoLBY(cmd, &send_packet); + //movement->FixMove(cmd, movement->m_qAnglesView); + + //ctx.shot_angles = QAngle(0, 0, 0); + + /*static auto wasonground = true; + + const auto player_flags = ctx.m_local()->m_fFlags(); + + if (!wasonground || !(ctx.m_local()->m_fFlags() & FL_ONGROUND)) + ctx.m_local()->m_fFlags() &= ~FL_ONGROUND; + + if (!csgo.m_client_state()->m_iChockedCommands) + wasonground = player_flags & FL_ONGROUND; + + const auto inlandanim = ctx.m_local()->get_animation_state() && ctx.m_local()->get_animation_state()->hitgr_anim; + const bool onground = ctx.m_local()->m_fFlags() & FL_ONGROUND; + + if (inlandanim && onground && wasonground) + feature::anti_aim->visual_real_angle.x = -10.f; + + ctx.m_local()->m_fFlags() = player_flags;*/ + + //static float last_dt_hc = ctx.m_settings.aimbot_doubletap_hitchance_val; + + if (m_weapon() != nullptr && ctx.m_local()->m_MoveType() != 10) + { + //ctx.latest_weapon_data = m_weapon()->GetCSWeaponData(); + + /*if (ctx.m_settings.misc_knife_hand_switch) + { + int should_be = 1; + + if (m_weapon()->is_knife()) + should_be = 0; + + if (cl_righthand->GetInt() != should_be) + cl_righthand->SetValue(should_be); + }*/ + //else { + // + // if (cl_righthand->GetInt() != old_value) + // old_value = cl_righthand->GetInt(); + //} + //if (ctx.m_settings.aimbot_tickbase_exploit != 0 && !ctx.fakeducking && m_weapon()->IsGun() && m_weapon()->m_iItemDefinitionIndex() != WEAPON_REVOLVER && cmd->weaponselect <= 0) + //{ + // static bool did_shift_before = false; + // + // if (ctx.m_settings.aimbot_tickbase_exploit >= 2) + // { + // auto fast_recovery = true; + // auto can_shift_shot = m_weapon()->can_exploit(12); + // auto can_shot = m_weapon()->can_exploit(abs(-1 - ctx.estimated_shift_amount)); + // + // if (can_shift_shot || (!can_shot || !fast_recovery) && !did_shift_before) + // ctx.estimated_shift_amount = 12; + // else + // ctx.estimated_shift_amount = 0; + // + // /*if (can_shift_shot) + // ctx.can_aimbot = true; + // else + // { + // if (ctx.double_tapped > 10) { + // ctx.can_aimbot = false; + // cmd->buttons &= ~IN_ATTACK; + // } + // }*/ + // } + // else + // ctx.estimated_shift_amount = 12; + //} + + if (exploit_toggled == 0 || !ctx.exploit_allowed || exploit_toggled == 2 || /*ctx.double_tapped > 0*/ctx.m_local()->m_iShotsFired() > 0 && ctx.next_shift_amount > 0 && exploit_toggled == 3) + ctx.next_shift_amount = 0; + + //ctx.prediction_tickbase = -1; + + //if (ctx.m_settings.aimbot_enabled) { + + feature::lagcomp->backup_players(false); + + if (ctx.m_settings.aimbot_enabled) + feature::anti_aim->fake_lagv2(cmd, &send_packet); + else + { + if (ctx.m_settings.anti_aim_enabled) + { + if (csgo.m_client_state()->m_iChockedCommands == 0) + send_packet = false; + } + } + + if (ctx.was_teleporting && !ctx.doubletap_now && !ctx.speed_hacking) { + ctx.was_teleporting = false; + + //auto v13 = csgo.m_client_state()->m_iLastOutgoingCommand + 1; + + //int nCorrectedTick = TIME_TO_TICKS(0.03f) - csgo.m_client_state()->m_iChockedCommands + csgo.m_globals()->tickcount + ctx.last_cmd_delta + 1; + + //auto shift_data = &Engine::Prediction::Instance()->m_tickbase_array[v13 % 150]; + + //if (shift_data) + //{ + // shift_data->command_num = v13; + // shift_data->increace = true; + // shift_data->doubletap = true; + // shift_data->tickbase_original = nCorrectedTick; + // //_events.push_back({"tb: " + std::to_string(nCorrectedTick)}); + //} + + } + + /*if (ctx.force_next_packet_choke) + send_packet = false;*/ + + if (csgo.m_client_state()->m_iChockedCommands >= 15u) + send_packet = 1; + + if (auto weapon = m_weapon(); weapon != nullptr && ctx.m_settings.aimbot_enabled && ctx.m_settings.aimbot_auto_revolver) + { + if (weapon->m_iItemDefinitionIndex() == 64) + { + auto v29 = /*(float)*/ctx.m_local()->m_nTickBase() * csgo.m_globals()->interval_per_tick; + ctx.is_cocking = 1; + cmd->buttons &= ~0x800u; + + if (weapon->can_cock() && !ctx.is_charging) + { + if (ctx.r8_timer <= v29) + { + if (weapon->m_flPostponeFireReadyTime() <= v29) + ctx.r8_timer = v29 + 0.234375f; + else + cmd->buttons |= 0x800u; + } + else + cmd->buttons |= 1u; + + ctx.is_cocking = v29 > ctx.r8_timer; + } + else + { + ctx.r8_timer = v29 + 0.234375f; + ctx.is_cocking = 0; + cmd->buttons &= ~1u; + } + } + } + + if (ctx.doubletap_now && ctx.speed_hacking && ctx.shifted_cmd != cmd->command_number) + send_packet = false; + + /*if (!m_weapon()->m_flNextPrimaryAttack() || csgo.m_globals()->curtime > ctx.m_local()->m_flNextAttack()) + ctx.is_able_to_shoot = !m_weapon()->m_flNextPrimaryAttack() || csgo.m_globals()->curtime > ctx.m_local()->m_flNextAttack();*/ + + const auto did_shot = !ctx.m_settings.aimbot_enabled ? false : feature::ragebot->think(cmd, &send_packet); + + if (!ctx.m_settings.aimbot_enabled) + feature::legitbot->run(cmd); + + const auto can_firstattak = (cmd->buttons & IN_ATTACK && (did_shot || ctx.pressed_keys[1] && m_weapon()->m_iItemDefinitionIndex() == 64 || m_weapon()->m_iItemDefinitionIndex() != 64)) && !is_switching_weapons && !ctx.m_local()->m_bWaitForNoAttack(); + const auto can_secondattk = (cmd->buttons & IN_ATTACK2 && (did_shot && m_weapon()->m_iItemDefinitionIndex() == 64 || m_weapon()->is_knife())) && !is_switching_weapons; + + if (skip_fakelags) + send_packet = true; + + //feature::anti_aim->yaw_diff_with_backwards = FLT_MAX; + + if (!ctx.fakeducking && feature::anti_aim->did_shot_in_chocked_cycle && ctx.m_settings.anti_aim_typeyfake_shot > 0 && (cmd->command_number - ctx.m_ragebot_shot_nr) == 1) { + send_packet = true; + feature::anti_aim->did_shot_in_chocked_cycle = false; + } + + if (/*ctx.allow_shooting <= cmd->command_number &&*/!ctx.speed_hacking && (can_firstattak || can_secondattk) && (did_shot || m_weapon()->can_shoot()) && (m_weapon()->IsGun() || m_weapon()->is_knife()))//&& ctx.last_shot_time_clientside + 0.05f < ctx.last_time_command_arrived) + { + //m_weapon()->UpdateAccuracyPenalty(); + + if (ctx.m_settings.aimbot_enabled && ctx.m_settings.aimbot_no_spread) + { + auto weapon_inaccuracy = m_weapon()->GetInaccuracy(); + auto weapon_spread = m_weapon()->GetSpread(); + + RandomSeed((cmd->random_seed & 255)); + + auto rand1 = RandomFloat(0.0f, 1.0f); + auto rand_pi1 = RandomFloat(0.0f, 2.0f * RadPi); + auto rand2 = RandomFloat(0.0f, 1.0f); + auto rand_pi2 = RandomFloat(0.0f, 2.0f * RadPi); + + int id = m_weapon()->m_iItemDefinitionIndex(); + auto recoil_index = m_weapon()->m_flRecoilIndex(); + + if (id == 64) + { + if (cmd->buttons & IN_ATTACK2) + { + rand1 = 1.0f - rand1 * rand1; + rand2 = 1.0f - rand2 * rand2; + } + } + else if (id == 28 && recoil_index < 3.0f) + { + for (int i = 3; i <= recoil_index; i--) + { + rand1 *= rand1; + rand2 *= rand2; + } + + rand1 = 1.0f - rand1; + rand2 = 1.0f - rand2; + } + + auto rand_inaccuracy = rand1 * weapon_inaccuracy; + auto rand_spread = rand2 * weapon_spread; + + Vector2D spread = + { + cosf(rand_pi1) * rand_inaccuracy + cosf(rand_pi2) * rand_spread, + sinf(rand_pi1) * rand_inaccuracy + sinf(rand_pi2) * rand_spread, + }; + + // + // pitch/yaw/roll + // + Vector side, up; + Vector forward = QAngle::Zero.ToVectors(&side, &up); + + Vector direction = forward + (side * spread.x) + (up * spread.y); + //direction.Normalize(); + + QAngle angles_spread; + Math::VectorAngles(direction, angles_spread); + + angles_spread.x -= cmd->viewangles.x; + angles_spread.Normalize(); + + forward = angles_spread.ToVectorsTranspose(&side, &up); + + Math::VectorAngles(forward, up, angles_spread); + angles_spread.Normalize(); + + angles_spread.y += cmd->viewangles.y; + angles_spread.Normalize(); + + if (angles_spread.x != 0 || angles_spread.y != 0) + cmd->viewangles = angles_spread; + + // + // pitch/roll + // + // cmd->viewangles.x += ToDegrees( std::atan( spread.Length() ) ); + // cmd->viewangles.z = -ToDegrees( std::atan2( spread.x, spread.y ) ); + // + // + // yaw/roll + // + // cmd->viewangles.y += ToDegrees( std::atan( spread.Length() ) ); + // cmd->viewangles.z = -( ToDegrees( std::atan2( spread.x, spread.y ) ) - 90.0f ); + } + + ctx.start_switching = true; + //cmd->viewangles.Normalize(); + + if (!ctx.autopeek_back) + ctx.autopeek_back = true; + + if (!send_packet) + feature::anti_aim->did_shot_in_chocked_cycle = true; + + if (ctx.m_settings.aimbot_enabled && ctx.m_settings.aimbot_no_spread) { + auto recoil = ctx.m_local()->m_aimPunchAngleScaled(); + + if (recoil.x != 0 || recoil.y != 0) { + cmd->viewangles.x = Math::normalize_angle(cmd->viewangles.x) - recoil.x; + cmd->viewangles.y = Math::normalize_angle(cmd->viewangles.y) - recoil.y; + cmd->viewangles.z = Math::normalize_angle(cmd->viewangles.z) - recoil.z; + } + } + //cmd->viewangles.Normalize(); + + //ctx.speed_hack = 13; + //if (ctx.last_shot_time_clientside != -1.f) + ctx.last_shot_time_clientside = csgo.m_globals()->realtime; + ctx.m_ragebot_shot_nr = cmd->command_number; + ctx.m_ragebot_shot_ang = cmd->viewangles; + ctx.hold_angles = cmd->viewangles; + + ctx.hold_aim = true; + ctx.hold_aim_ticks = 0; + ctx.force_aimbot = 0; + + if (!did_shot) + feature::resolver->add_shot(ctx.m_eye_position, Vector(0, 0, 0), nullptr, 0, -1, -1); + + //cant_repredict = true; + //if (!cant_repredict) + // prediction->Predict(cmd); + } + else + { + if (ctx.m_settings.aimbot_enabled && m_weapon()->m_iItemDefinitionIndex() != 64 && !m_weapon()->IsGrenade() && m_weapon()->IsGun()) + cmd->buttons &= ~IN_ATTACK; + + //if (!cant_repredict) + // prediction->Predict(cmd); + + if (ctx.m_settings.aimbot_enabled || ctx.m_settings.anti_aim_enabled) + feature::anti_aim->work(cmd, &send_packet); + } + + if (ctx.doubletap_now && ctx.speed_hacking && ctx.shifted_cmd != cmd->command_number) + send_packet = false; + + + /*if (ctx.force_next_packet_choke) + send_packet = false;*/ + + //if (!send_packet) + feature::usercmd->cmd_info[cmd->command_number % 150].store(cmd->command_number, ctx.cmd_original_angles, Vector(cmd->forwardmove, cmd->sidemove, cmd->upmove), cmd->viewangles, ctx.m_local()->m_flSimulationTime(), ctx.m_local()->m_fFlags(), ctx.m_local()->m_flDuckAmount(), ctx.m_local()->m_flLowerBodyYawTarget(), ctx.m_local()->m_nTickBase(), ctx.m_local()->m_vecVelocity()); + + movement->End(cmd); + + if (ctx.m_settings.aimbot_enabled &&/*send_packet &&*/ ctx.m_local()->m_fFlags() & FL_ONGROUND) + feature::misc->end(cmd); + + //prediction->Predict(cmd); + + feature::lagcomp->backup_players(true); + + ctx.last_angles = cmd->viewangles; + + /*prediction->m_tickbase_array[cmd->command_number % 150].tickbase_original = ctx.m_local()->m_nTickBase(); + prediction->m_tickbase_array[cmd->command_number % 150].extra_shift = 0;*/ + + if (exploit_toggled != 0 && ctx.exploit_allowed && !ctx.fakeducking && m_weapon()->IsGun() && m_weapon()->m_iItemDefinitionIndex() != WEAPON_REVOLVER && !is_switching_weapons && ctx.ticks_allowed > 12 && exploit_toggled > 0) + { + ctx.next_shift_amount = 0; + ctx.shift_amount = 0; + + if (exploit_toggled == 2) + { + //auto can_shift_shot = m_weapon()->can_exploit(14); + + if (cmd->buttons & IN_ATTACK && m_weapon()->can_exploit(13)) { + + + ctx.speed_hacking = true; + ctx.doubletap_now = true; + //CopyCommand(cmd); + //ctx.m_eye_position = ctx.m_local()->GetEyePosition(); + + //ctx.original_tickbase = ctx.m_local()->m_nTickBase(); + //ctx.exploit_tickbase_shift = 14; + //ctx.tickbase_shift_nr = cmd->command_number; + + ctx.started_speedhack = ctx.current_tickcount; + ctx.shifted_cmd = cmd->command_number; + + //*tb = btb; + + //*tb += commands_to_shift; + + ctx.last_speedhack_time = csgo.m_globals()->realtime; + + send_packet = false; + //send_packet = false; + //ctx.force_next_packet_choke = true; + + //ctx.m_local()->AdjustPlayerTimeBase(ctx.m_local()->DetermineSimulationTicks()); + } + else + { + /*if (ctx.m_settings.aimbot_extra_doubletap_options[2]) + { + if (ctx.ticks_allowed > 12 && std::fabsf(csgo.m_globals()->realtime - ctx.last_speedhack_time) > 0.5f && ctx.allow_shooting <= cmd->command_number && ctx.force_aimbot < 1) { + ctx.next_shift_amount = 12; + ctx.shift_amount = ctx.next_shift_amount; + send_packet = true; + } + }*/ + } + } + else if (exploit_toggled == 3) + { + static auto fast_recovery = false; + const auto can_shift_shot = m_weapon()->can_exploit(13); + const auto can_shot = m_weapon()->can_exploit(-1 - ctx.next_shift_amount); + + if (can_shift_shot || (!can_shot || !fast_recovery) && !did_shift_before) + { + ctx.next_shift_amount = 13; + ctx.double_tapped = 0; + } + else { + ctx.double_tapped++; + + /*if (exploit_toggled == 3 && !can_shift_shot && ctx.m_local()->m_vecVelocity().Length() > 10.f) { + ctx.speed_hack = 13; + }*/ + ctx.shift_amount = 0; + ctx.next_shift_amount = 0; + } + + /*if (can_shift_shot) + ctx.can_aimbot = true; + else + { + if (ctx.double_tapped > 10) { + ctx.can_aimbot = false; + cmd->buttons &= ~IN_ATTACK; + } + }*/ + } + else + ctx.next_shift_amount = 11; + + if (exploit_toggled != 2) + { + if (ctx.next_shift_amount > 0 && ctx.ticks_allowed > 11) { + if (m_weapon()->can_exploit(ctx.next_shift_amount) && cmd->buttons & IN_ATTACK && !(cmd->buttons & IN_ATTACK2)) { + ctx.shift_amount = ctx.next_shift_amount; + + auto shift_data = &prediction->m_tickbase_array[cmd->command_number % 150]; + + if (ctx.shift_amount > 0) { + shift_data->command_num = cmd->command_number; + + shift_data->extra_shift = ~ctx.shift_amount; + + auto latency_ticks = 1; + + if (ctx.last_4_deltas.size() >= 2) { + latency_ticks = 0; + int added = 0; + for (auto d : ctx.last_4_deltas) + { + latency_ticks += d; + ++added; + if (added >= 4) + break; + } + latency_ticks /= 4; + } + + auto serverTickcount = csgo.m_globals()->tickcount; + + auto simulation_ticks = ctx.shift_amount + csgo.m_client_state()->m_iChockedCommands; + int nCorrectedTick = TIME_TO_TICKS(0.03f) - simulation_ticks + serverTickcount + latency_ticks; + + shift_data->tickbase_original = nCorrectedTick; + + shift_data->increace = true; + } + + send_packet = true; + } + } + + //if (exploit_toggled == 1 && (ctx.shift_amount == 0 || ctx.ticks_allowed <= 11)) { + // //auto can_shift_shot = m_weapon()->can_exploit(13); + // cmd->buttons &= ~IN_ATTACK; + // ctx.can_aimbot = false; + //} + + did_shift_before = ctx.shift_amount != 0; + } + + cant_repredict = true; + } + else + ctx.next_shift_amount = 0; + } + + //if (!cant_repredict) + // prediction->Predict(cmd); + + // createmove + if (ctx.shift_amount > 0 /*|| ctx.doubletap_now*/) + { + ctx.original_tickbase = ctx.m_local()->m_nTickBase(); + ctx.exploit_tickbase_shift = ctx.doubletap_now ? 14 : abs(ctx.shift_amount); + ctx.tickbase_shift_nr = cmd->command_number; + } + //const auto t = ctx.m_local()->m_nTickBase(); + + /*if (old_tickbase > 0) + ctx.m_local()->m_nTickBase() = old_tickbase;*/ + + if (ctx.m_local()->m_vecVelocity().Length2D() > 0.1f || ctx.m_local()->get_animation_state()->m_velocity_length_xy > 100) + feature::anti_aim->lby_timer = TICKS_TO_TIME(ctx.m_local()->m_nTickBase()) + 0.22f; + else + { + if (TICKS_TO_TIME(ctx.m_local()->m_nTickBase()) > feature::anti_aim->lby_timer) { + feature::anti_aim->lby_timer = TICKS_TO_TIME(ctx.m_local()->m_nTickBase()) + 1.1f; + } + } + + if (!ctx.air_stuck) { + const auto bk = ctx.m_local()->m_flThirdpersonRecoil(); + + const auto movestate = ctx.m_local()->m_iMoveState(); + const auto iswalking = ctx.m_local()->m_bIsWalking(); + + ctx.m_local()->m_iMoveState() = 0; + ctx.m_local()->m_bIsWalking() = false; + + auto m_forward = cmd->buttons & IN_FORWARD; + auto m_back = cmd->buttons & IN_BACK; + auto m_right = cmd->buttons & IN_MOVERIGHT; + auto m_left = cmd->buttons & IN_MOVELEFT; + auto m_walking = cmd->buttons & IN_SPEED; + + bool m_walk_state = m_walking ? true : false; + + if (cmd->buttons & IN_DUCK || ctx.m_local()->m_bDucking() || ctx.m_local()->m_fFlags() & FL_DUCKING) + m_walk_state = false; + else if (m_walking) + { + float m_max_speed = ctx.m_local()->m_flMaxSpeed() * 0.52f; + + if (m_max_speed + 25.f > ctx.m_local()->m_vecVelocity().Length()) + ctx.m_local()->m_bIsWalking() = true; + } + + auto move_buttons_pressed = cmd->buttons & (IN_FORWARD | IN_BACK | IN_MOVELEFT | IN_MOVERIGHT | IN_RUN); + + bool holding_forward_and_back; + bool holding_right_and_left; + + if (!m_forward) + holding_forward_and_back = false; + else + holding_forward_and_back = m_back; + + if (!m_right) + holding_right_and_left = false; + else + holding_right_and_left = m_left; + + if (move_buttons_pressed) + { + if (holding_forward_and_back) + { + if (holding_right_and_left) // if pressing two keys you get stopped + ctx.m_local()->m_iMoveState() = 0; + else if (m_right || m_left) + ctx.m_local()->m_iMoveState() = 2; + else //none of keys pressed. + ctx.m_local()->m_iMoveState() = 0; + } + else + { + if (holding_forward_and_back) // if pressing two keys you get stopped + ctx.m_local()->m_iMoveState() = 0; + else if (m_back || m_forward) + ctx.m_local()->m_iMoveState() = 2; + else //none of keys pressed. + ctx.m_local()->m_iMoveState() = 0; + } + } + + if (ctx.m_local()->m_iMoveState() == 2 && m_walk_state) + ctx.m_local()->m_iMoveState() = 1; + + feature::lagcomp->update_local_animations(cmd, &send_packet); + + ctx.m_local()->m_iMoveState() = movestate; + ctx.m_local()->m_bIsWalking() = iswalking; + ctx.m_local()->m_flThirdpersonRecoil() = bk; + } + + feature::anti_aim->previous_velocity = feature::anti_aim->animation_velocity;//ctx.m_local()->m_vecAbsVelocity().Length2D() > 4.f ? ctx.m_local()->m_vecAbsVelocity() : Vector::Zero; + //ctx.m_local()->m_nTickBase() = t; + /*if (ctx.m_local()->get_animation_state() != nullptr + && (ctx.m_local()->get_animation_state()->hitgr_anim || ctx.m_local()->get_animation_state()->on_ground && (ctx.m_local()->get_animation_state()->duck_amt > 0.f || ctx.m_local()->get_animation_state()->landing_duck > 0.f) && !(cmd->buttons & IN_DUCK)) + && !(cmd->buttons & IN_JUMP) + && !was_jumping) + feature::anti_aim->visual_real_angle.x = -10.f;*/ + + if (send_packet) { + ctx.breaks_lc = (ctx.m_local()->m_vecOrigin() - feature::anti_aim->sent_data.m_vecOrigin).LengthSquared() > 4096; + + feature::anti_aim->last_unchoke_time = csgo.m_globals()->curtime; + feature::anti_aim->visual_real_angle = cmd->viewangles; + feature::anti_aim->sent_data.store(ctx.m_local()->m_flSimulationTime(), ctx.m_local()->m_vecOrigin(), ctx.m_local()->m_vecVelocity(), ctx.m_eye_position, cmd->viewangles, ctx.m_local()->m_nTickBase(), cmd->command_number, ctx.m_local()->m_fFlags()); + + //feature::usercmd->command_numbers.clear(); + feature::anti_aim->did_shot_in_chocked_cycle = false; + ctx.last_sent_tick = csgo.m_globals()->tickcount; + ctx.hold_aim = false; + + //feature::usercmd->command_numbers.clear(); + feature::usercmd->cmd_info[cmd->command_number % 150].command_number = 0; + } + + if (!send_packet) + ctx.skip_communication = false; + + if (!skip_fakelags) + ApplyShift(cmd, &send_packet); + + ctx.force_next_packet_choke = false; + + //if (send_packet && ctx.m_local()->m_fFlags() & FL_ONGROUND && ctx.m_local()->m_MoveType() != MOVETYPE_LADDER + // && ctx.m_settings.anti_aim_enabled) + //{ + // //Desync the feet for other players + // + // if (cmd->forwardmove < 0.0f) + // cmd->buttons |= IN_FORWARD; + // else if (cmd->forwardmove > 0.0f) + // cmd->buttons |= IN_BACK; + // + // if (cmd->sidemove < 0.0f) + // cmd->buttons |= IN_MOVERIGHT; + // else if (cmd->sidemove > 0.0f) + // cmd->buttons |= IN_MOVELEFT; + //} + } + //else + // prediction->m_tickbase_array[cmd->command_number % 150].tickbase_original = ctx.m_local()->m_nTickBase(); + + ctx.m_settings.aimbot_enabled = aim_toggled; + + prediction->End(); + + ctx.previous_tickcount = ctx.current_tickcount; + ctx.previous_buttons = cmd->buttons; + + /*static auto previous_org = ctx.m_local()->m_vecOrigin(); + if (send_packet) + { + if (GetAsyncKeyState('V')) + { + auto choke = TICKS_TO_TIME(csgo.m_client_state()->m_iChockedCommands + 1); + auto velocity = (ctx.m_local()->m_vecOrigin() - previous_org) / choke; + printf("%.2f calc | %.2f real | %.2f diff\n", velocity.Length(), ctx.m_local()->m_vecVelocity().Length(), + std::fabsf(velocity.Length() - ctx.m_local()->m_vecVelocity().Length())); + } + + previous_org = ctx.m_local()->m_vecOrigin(); + }*/ + + ctx.fix_modify_eye_pos = false; + + if (ctx.m_local() != nullptr) { + ctx.m_corrections_data.emplace_front(ctx.m_local()->m_nTickBase(), ctx.doubletap_now ? 13 : ctx.shift_amount, cmd->command_number, csgo.m_client_state()->m_clockdrift_manager.m_nServerTick); + ctx.local_spawntime = ctx.m_local()->m_flSpawnTime(); + } + + while (int(ctx.m_corrections_data.size()) > int(1.0f / csgo.m_globals()->interval_per_tick)) { + ctx.m_corrections_data.pop_back(); + } + + if (send_packet) + { + auto cmd_num = csgo.m_client_state()->m_iLastOutgoingCommand + 1; + auto v84 = cmd->command_number; + if (v84 >= cmd_num && (v84 - cmd_num) <= 150) + { + do + { + auto& v85 = Engine::Prediction::Instance()->m_tick_history[cmd_num % 150]; + v85.command_num = cmd_num++; + v85.m_tick = csgo.m_engine()->GetTick();//csgo.m_globals()->tickcount;//csgo.m_client_state()->m_clockdrift_manager.m_nServerTick; + } while (cmd_num <= v84); + } + } + + //if (send_packet) + //{ + // ctx.command_numbers.push_front(cmd->command_number); + + + auto& out = ctx.command_numbers.emplace_back(); + out.is_outgoing = send_packet; + out.command_nr = cmd->command_number; + out.is_used = false; + out.prev_command_nr = /*ctx.command_numbers.size() > 1 ? ctx.command_numbers.at(1).command_nr : */0; + + while (int(ctx.command_numbers.size()) > int(1.0f / csgo.m_globals()->interval_per_tick)) { + ctx.command_numbers.pop_front(); + } + //} + + /*if (ctx.air_stuck) { + cmd->tick_count = 0x7FFFFFFF; + cmd->command_number = 0x7FFFFFFF; + }*/ + + //if (!send_packet && ctx.m_settings.aimbot_enabled)// && (!ctx.exploit_allowed || !ctx.has_exploit_toggled || ctx.ticks_allowed < 13 && ctx.allow_shooting <= 0 || ctx.fakeducking)) + //{ + // if (csgo.m_client_state() != nullptr /*&& (!csgo.m_game_rules() || !csgo.m_game_rules()->IsValveDS())*/) { + // INetChannel* net_channel = (INetChannel*)(csgo.m_client_state()->m_ptrNetChannel); + // if (net_channel != nullptr && net_channel->choked_packets > 0 && !(net_channel->choked_packets % 4)) { + // const auto current_choke = net_channel->choked_packets; + // net_channel->choked_packets = 0; + // const auto v4 = net_channel->send_datagram(0); + // //ctx.fix_senddatagram[v4] = v4; + // --net_channel->out_sequence_nr; + // net_channel->choked_packets = current_choke; + // } + // } + //} + + *reinterpret_cast(*reinterpret_cast(static_cast(_AddressOfReturnAddress()) - 0x4) - 0x1C) = send_packet; + +#ifdef VIRTUALIZER + +#endif // VIRTUALIZER + + return false; + } +} +``` + +`cutl_block_mem.hpp`: + +```hpp +//===== Copyright 1996-2005, Valve Corporation, All rights reserved. ======// +// +// Purpose: +// +// $NoKeywords: $ +// +// A growable memory class. +//===========================================================================// + +#ifndef UTLBLOCKMEMORY_H +#define UTLBLOCKMEMORY_H + +#ifdef _WIN32 +#pragma once +#endif + +//#include "tier0/dbg.h" +//#include "tier0/platform.h" +//#include "mathlib/mathlib.h" + + +#pragma warning (disable:4100) +#pragma warning (disable:4514) + +//----------------------------------------------------------------------------- + +#ifdef UTBLOCKLMEMORY_TRACK +#define UTLBLOCKMEMORY_TRACK_ALLOC() MemAlloc_RegisterAllocation( "Sum of all UtlBlockMemory", 0, NumAllocated() * sizeof(T), NumAllocated() * sizeof(T), 0 ) +#define UTLBLOCKMEMORY_TRACK_FREE() if ( !m_pMemory ) ; else MemAlloc_RegisterDeallocation( "Sum of all UtlBlockMemory", 0, NumAllocated() * sizeof(T), NumAllocated() * sizeof(T), 0 ) +#else +#define UTLBLOCKMEMORY_TRACK_ALLOC() ((void)0) +#define UTLBLOCKMEMORY_TRACK_FREE() ((void)0) +#endif + + +//----------------------------------------------------------------------------- +// The CUtlBlockMemory class: +// A growable memory class that allocates non-sequential blocks, but is indexed sequentially +//----------------------------------------------------------------------------- +template< class T, class I > +class CUtlBlockMemory +{ +public: + // constructor, destructor + CUtlBlockMemory(int nGrowSize = 0, int nInitSize = 0); + ~CUtlBlockMemory(); + + // Set the size by which the memory grows - round up to the next power of 2 + void Init(int nGrowSize = 0, int nInitSize = 0); + + // here to match CUtlMemory, but only used by ResetDbgInfo, so it can just return NULL + T* Base() { return NULL; } + const T* Base() const { return NULL; } + + class Iterator_t + { + public: + Iterator_t(I i) : index(i) {} + I index; + + bool operator==(const Iterator_t it) const { return index == it.index; } + bool operator!=(const Iterator_t it) const { return index != it.index; } + }; + Iterator_t First() const { return Iterator_t(IsIdxValid(0) ? 0 : InvalidIndex()); } + Iterator_t Next(const Iterator_t& it) const { return Iterator_t(IsIdxValid(it.index + 1) ? it.index + 1 : InvalidIndex()); } + I GetIndex(const Iterator_t& it) const { return it.index; } + bool IsIdxAfter(I i, const Iterator_t& it) const { return i > it.index; } + bool IsValidIterator(const Iterator_t& it) const { return IsIdxValid(it.index); } + Iterator_t InvalidIterator() const { return Iterator_t(InvalidIndex()); } + + // element access + T& operator[](I i); + const T& operator[](I i) const; + T& Element(I i); + const T& Element(I i) const; + + // Can we use this index? + bool IsIdxValid(I i) const; + static I InvalidIndex() { return (I)-1; } + + void Swap(CUtlBlockMemory< T, I >& mem); + + // Size + int NumAllocated() const; + int Count() const { return NumAllocated(); } + + // Grows memory by max(num,growsize) rounded up to the next power of 2, and returns the allocation index/ptr + void Grow(int num = 1); + + // Makes sure we've got at least this much memory + void EnsureCapacity(int num); + + // Memory deallocation + void Purge(); + + // Purge all but the given number of elements + void Purge(int numElements); + +protected: + int Index(int major, int minor) const { return (major << m_nIndexShift) | minor; } + int MajorIndex(int i) const { return i >> m_nIndexShift; } + int MinorIndex(int i) const { return i & m_nIndexMask; } + void ChangeSize(int nBlocks); + int NumElementsInBlock() const { return m_nIndexMask + 1; } + + T** m_pMemory; + int m_nBlocks; + int m_nIndexMask : 27; + int m_nIndexShift : 5; +}; + +//----------------------------------------------------------------------------- +// constructor, destructor +//----------------------------------------------------------------------------- + +template< class T, class I > +CUtlBlockMemory::CUtlBlockMemory(int nGrowSize, int nInitAllocationCount) + : m_pMemory(0), m_nBlocks(0), m_nIndexMask(0), m_nIndexShift(0) +{ + Init(nGrowSize, nInitAllocationCount); +} + +template< class T, class I > +CUtlBlockMemory::~CUtlBlockMemory() +{ + Purge(); +} + + +//----------------------------------------------------------------------------- +// Fast swap +//----------------------------------------------------------------------------- +template< class T, class I > +void CUtlBlockMemory::Swap(CUtlBlockMemory< T, I >& mem) +{ + V_swap(m_pMemory, mem.m_pMemory); + V_swap(m_nBlocks, mem.m_nBlocks); + V_swap(m_nIndexMask, mem.m_nIndexMask); + V_swap(m_nIndexShift, mem.m_nIndexShift); +} + + +//----------------------------------------------------------------------------- +// Set the size by which the memory grows - round up to the next power of 2 +//----------------------------------------------------------------------------- +template< class T, class I > +void CUtlBlockMemory::Init(int nGrowSize /* = 0 */, int nInitSize /* = 0 */) +{ + Purge(); + + if (nGrowSize == 0) + { + // default grow size is smallest size s.t. c++ allocation overhead is ~6% of block size + nGrowSize = (127 + sizeof(T)) / sizeof(T); + } + m_nIndexMask = nGrowSize - 1; + + m_nIndexShift = 0; + while (nGrowSize > 1) + { + nGrowSize >>= 1; + ++m_nIndexShift; + } + //Assert( m_nIndexMask + 1 == ( 1 << m_nIndexShift ) ); + + Grow(nInitSize); +} + + +//----------------------------------------------------------------------------- +// element access +//----------------------------------------------------------------------------- +template< class T, class I > +inline T& CUtlBlockMemory::operator[](I i) +{ + //Assert( IsIdxValid(i) ); + T* pBlock = m_pMemory[MajorIndex(i)]; + return pBlock[MinorIndex(i)]; +} + +template< class T, class I > +inline const T& CUtlBlockMemory::operator[](I i) const +{ + //Assert( IsIdxValid(i) ); + const T* pBlock = m_pMemory[MajorIndex(i)]; + return pBlock[MinorIndex(i)]; +} + +template< class T, class I > +inline T& CUtlBlockMemory::Element(I i) +{ + //Assert( IsIdxValid(i) ); + T* pBlock = m_pMemory[MajorIndex(i)]; + return pBlock[MinorIndex(i)]; +} + +template< class T, class I > +inline const T& CUtlBlockMemory::Element(I i) const +{ + //Assert( IsIdxValid(i) ); + const T* pBlock = m_pMemory[MajorIndex(i)]; + return pBlock[MinorIndex(i)]; +} + + +//----------------------------------------------------------------------------- +// Size +//----------------------------------------------------------------------------- +template< class T, class I > +inline int CUtlBlockMemory::NumAllocated() const +{ + return m_nBlocks * NumElementsInBlock(); +} + + +//----------------------------------------------------------------------------- +// Is element index valid? +//----------------------------------------------------------------------------- +template< class T, class I > +inline bool CUtlBlockMemory::IsIdxValid(I i) const +{ + return (i >= 0) && (MajorIndex(i) < m_nBlocks); +} + +template< class T, class I > +void CUtlBlockMemory::Grow(int num) +{ + if (num <= 0) + return; + + int nBlockSize = NumElementsInBlock(); + int nBlocks = (num + nBlockSize - 1) / nBlockSize; + + ChangeSize(m_nBlocks + nBlocks); +} + +template< class T, class I > +void CUtlBlockMemory::ChangeSize(int nBlocks) +{ + UTLBLOCKMEMORY_TRACK_FREE(); // this must stay before the recalculation of m_nBlocks, since it implicitly uses the old value + + int nBlocksOld = m_nBlocks; + m_nBlocks = nBlocks; + + UTLBLOCKMEMORY_TRACK_ALLOC(); // this must stay after the recalculation of m_nBlocks, since it implicitly uses the new value + + // free old blocks if shrinking + for (int i = m_nBlocks; i < nBlocksOld; ++i) + { + UTLBLOCKMEMORY_TRACK_FREE(); + free((void*)m_pMemory[i]); + } + + if (m_pMemory) + { + //(); + m_pMemory = (T**)realloc(m_pMemory, m_nBlocks * sizeof(T*)); + //Assert( m_pMemory ); + } + else + { + //(); + m_pMemory = (T**)malloc(m_nBlocks * sizeof(T*)); + //Assert( m_pMemory ); + } + + if (!m_pMemory) + { + exit(EXIT_SUCCESS); + //Error( "CUtlBlockMemory overflow!\n" ); + } + + // allocate new blocks if growing + int nBlockSize = NumElementsInBlock(); + for (int i = nBlocksOld; i < m_nBlocks; ++i) + { + + m_pMemory[i] = (T*)malloc(nBlockSize * sizeof(T)); + //Assert( m_pMemory[ i ] ); + } +} + + +//----------------------------------------------------------------------------- +// Makes sure we've got at least this much memory +//----------------------------------------------------------------------------- +template< class T, class I > +inline void CUtlBlockMemory::EnsureCapacity(int num) +{ + Grow(num - NumAllocated()); +} + + +//----------------------------------------------------------------------------- +// Memory deallocation +//----------------------------------------------------------------------------- +template< class T, class I > +void CUtlBlockMemory::Purge() +{ + if (!m_pMemory) + return; + + for (int i = 0; i < m_nBlocks; ++i) + { + UTLBLOCKMEMORY_TRACK_FREE(); + free((void*)m_pMemory[i]); + } + m_nBlocks = 0; + + UTLBLOCKMEMORY_TRACK_FREE(); + free((void*)m_pMemory); + m_pMemory = 0; +} + +template< class T, class I > +void CUtlBlockMemory::Purge(int numElements) +{ + //Assert( numElements >= 0 ); + + int nAllocated = NumAllocated(); + if (numElements > nAllocated) + { + // Ensure this isn't a grow request in disguise. + //Assert( numElements <= nAllocated ); + return; + } + + if (numElements <= 0) + { + Purge(); + return; + } + + int nBlockSize = NumElementsInBlock(); + int nBlocksOld = m_nBlocks; + int nBlocks = (numElements + nBlockSize - 1) / nBlockSize; + + // If the number of blocks is the same as the allocated number of blocks, we are done. + if (nBlocks == m_nBlocks) + return; + + ChangeSize(nBlocks); +} + +#endif // UTLBLOCKMEMORY_H +``` + +`cutl_fixed_mem.hpp`: + +```hpp +//===== Copyright 1996-2005, Valve Corporation, All rights reserved. ======// +// +// Purpose: +// +// $NoKeywords: $ +// +// A growable memory class. +//===========================================================================// + +#ifndef UTLFIXEDMEMORY_H +#define UTLFIXEDMEMORY_H + +#ifdef _WIN32 +#pragma once +#endif + +//#include "dbg.h" +////#include "tier0/platform.h" +// +//#include "memalloc.h" +//#include "memdbgon.h" + +#pragma warning (disable:4100) +#pragma warning (disable:4514) + +//----------------------------------------------------------------------------- + +#ifdef UTLFIXEDMEMORY_TRACK +#define UTLFIXEDMEMORY_TRACK_ALLOC() MemAlloc_RegisterAllocation( "Sum of all UtlFixedMemory", 0, NumAllocated() * sizeof(T), NumAllocated() * sizeof(T), 0 ) +#define UTLFIXEDMEMORY_TRACK_FREE() if ( !m_pMemory ) ; else MemAlloc_RegisterDeallocation( "Sum of all UtlFixedMemory", 0, NumAllocated() * sizeof(T), NumAllocated() * sizeof(T), 0 ) +#else +#define UTLFIXEDMEMORY_TRACK_ALLOC() ((void)0) +#define UTLFIXEDMEMORY_TRACK_FREE() ((void)0) +#endif + + +//----------------------------------------------------------------------------- +// The CUtlFixedMemory class: +// A growable memory class that allocates non-sequential blocks, but is indexed sequentially +//----------------------------------------------------------------------------- +template< class T > +class CUtlFixedMemory +{ +public: + // constructor, destructor + CUtlFixedMemory(int nGrowSize = 0, int nInitSize = 0); + ~CUtlFixedMemory(); + + // Set the size by which the memory grows + void Init(int nGrowSize = 0, int nInitSize = 0); + + // here to match CUtlMemory, but only used by ResetDbgInfo, so it can just return NULL + T* Base() { return NULL; } + const T* Base() const { return NULL; } + +protected: + struct BlockHeader_t; + +public: + class Iterator_t + { + public: + Iterator_t(BlockHeader_t* p, int i) : m_pBlockHeader(p), m_nIndex(i) {} + BlockHeader_t* m_pBlockHeader; + int m_nIndex; + + bool operator==(const Iterator_t it) const { return m_pBlockHeader == it.m_pBlockHeader && m_nIndex == it.m_nIndex; } + bool operator!=(const Iterator_t it) const { return m_pBlockHeader != it.m_pBlockHeader || m_nIndex != it.m_nIndex; } + }; + Iterator_t First() const { return m_pBlocks ? Iterator_t(m_pBlocks, 0) : InvalidIterator(); } + Iterator_t Next(const Iterator_t& it) const + { + Assert(IsValidIterator(it)); + if (!IsValidIterator(it)) + return InvalidIterator(); + + BlockHeader_t* __restrict pHeader = it.m_pBlockHeader; + if (it.m_nIndex + 1 < pHeader->m_nBlockSize) + return Iterator_t(pHeader, it.m_nIndex + 1); + + return pHeader->m_pNext ? Iterator_t(pHeader->m_pNext, 0) : InvalidIterator(); + } + int GetIndex(const Iterator_t& it) const + { + Assert(IsValidIterator(it)); + if (!IsValidIterator(it)) + return InvalidIndex(); + + return (int)(HeaderToBlock(it.m_pBlockHeader) + it.m_nIndex); + } + bool IsIdxAfter(int i, const Iterator_t& it) const + { + Assert(IsValidIterator(it)); + if (!IsValidIterator(it)) + return false; + + if (IsInBlock(i, it.m_pBlockHeader)) + return i > GetIndex(it); + + for (BlockHeader_t* __restrict pbh = it.m_pBlockHeader->m_pNext; pbh; pbh = pbh->m_pNext) + { + if (IsInBlock(i, pbh)) + return true; + } + return false; + } + bool IsValidIterator(const Iterator_t& it) const { return it.m_pBlockHeader && it.m_nIndex >= 0 && it.m_nIndex < it.m_pBlockHeader->m_nBlockSize; } + Iterator_t InvalidIterator() const { return Iterator_t(NULL, -1); } + + // element access + T& operator[](int i); + const T& operator[](int i) const; + T& Element(int i); + const T& Element(int i) const; + + // Can we use this index? + bool IsIdxValid(int i) const; + + // Specify the invalid ('null') index that we'll only return on failure + static const int INVALID_INDEX = 0; // For use with COMPILE_TIME_ASSERT + static int InvalidIndex() { return INVALID_INDEX; } + + // Size + int NumAllocated() const; + int Count() const { return NumAllocated(); } + + // Grows memory by max(num,growsize), and returns the allocation index/ptr + void Grow(int num = 1); + + // Makes sure we've got at least this much memory + void EnsureCapacity(int num); + + // Memory deallocation + void Purge(); + +protected: + // Fast swap - WARNING: Swap invalidates all ptr-based indices!!! + void Swap(CUtlFixedMemory< T >& mem); + + bool IsInBlock(int i, BlockHeader_t* pBlockHeader) const + { + T* p = (T*)i; + const T* p0 = HeaderToBlock(pBlockHeader); + return p >= p0 && p < p0 + pBlockHeader->m_nBlockSize; + } + + struct BlockHeader_t + { + BlockHeader_t* m_pNext; + int m_nBlockSize; + }; + + const T* HeaderToBlock(const BlockHeader_t* pHeader) const { return (T*)(pHeader + 1); } + const BlockHeader_t* BlockToHeader(const T* pBlock) const { return (BlockHeader_t*)(pBlock)-1; } + + BlockHeader_t* m_pBlocks; + int m_nAllocationCount; + int m_nGrowSize; +}; + +//----------------------------------------------------------------------------- +// constructor, destructor +//----------------------------------------------------------------------------- + +template< class T > +CUtlFixedMemory::CUtlFixedMemory(int nGrowSize, int nInitAllocationCount) + : m_pBlocks(0), m_nAllocationCount(0), m_nGrowSize(0) +{ + Init(nGrowSize, nInitAllocationCount); +} + +template< class T > +CUtlFixedMemory::~CUtlFixedMemory() +{ + Purge(); +} + + +//----------------------------------------------------------------------------- +// Fast swap - WARNING: Swap invalidates all ptr-based indices!!! +//----------------------------------------------------------------------------- +template< class T > +void CUtlFixedMemory::Swap(CUtlFixedMemory< T >& mem) +{ + V_swap(m_pBlocks, mem.m_pBlocks); + V_swap(m_nAllocationCount, mem.m_nAllocationCount); + V_swap(m_nGrowSize, mem.m_nGrowSize); +} + + +//----------------------------------------------------------------------------- +// Set the size by which the memory grows - round up to the next power of 2 +//----------------------------------------------------------------------------- +template< class T > +void CUtlFixedMemory::Init(int nGrowSize /* = 0 */, int nInitSize /* = 0 */) +{ + Purge(); + + m_nGrowSize = nGrowSize; + + Grow(nInitSize); +} + +//----------------------------------------------------------------------------- +// element access +//----------------------------------------------------------------------------- +template< class T > +inline T& CUtlFixedMemory::operator[](int i) +{ + Assert(IsIdxValid(i)); + return *(T*)i; +} + +template< class T > +inline const T& CUtlFixedMemory::operator[](int i) const +{ + Assert(IsIdxValid(i)); + return *(T*)i; +} + +template< class T > +inline T& CUtlFixedMemory::Element(int i) +{ + Assert(IsIdxValid(i)); + return *(T*)i; +} + +template< class T > +inline const T& CUtlFixedMemory::Element(int i) const +{ + Assert(IsIdxValid(i)); + return *(T*)i; +} + + +//----------------------------------------------------------------------------- +// Size +//----------------------------------------------------------------------------- +template< class T > +inline int CUtlFixedMemory::NumAllocated() const +{ + return m_nAllocationCount; +} + + +//----------------------------------------------------------------------------- +// Is element index valid? +//----------------------------------------------------------------------------- +template< class T > +inline bool CUtlFixedMemory::IsIdxValid(int i) const +{ +#ifdef _DEBUG + for (BlockHeader_t* pbh = m_pBlocks; pbh; pbh = pbh->m_pNext) + { + if (IsInBlock(i, pbh)) + return true; + } + return false; +#else + return i != InvalidIndex(); +#endif +} + +template< class T > +void CUtlFixedMemory::Grow(int num) +{ + if (num <= 0) + return; + + int nBlockSize = m_nGrowSize; + if (nBlockSize == 0) + { + if (m_nAllocationCount) + { + nBlockSize = m_nAllocationCount; + } + else + { + // Compute an allocation which is at least as big as a cache line... + nBlockSize = (31 + sizeof(T)) / sizeof(T); + Assert(nBlockSize); + } + } + if (nBlockSize < num) + { + int n = (num + nBlockSize - 1) / nBlockSize; + Assert(n * nBlockSize >= num); + Assert((n - 1) * nBlockSize < num); + nBlockSize *= n; + } + m_nAllocationCount += nBlockSize; + + BlockHeader_t* __restrict pBlockHeader = (BlockHeader_t*)malloc(sizeof(BlockHeader_t) + nBlockSize * sizeof(T)); + if (!pBlockHeader) + { + exit(EXIT_SUCCESS); + //Error( "CUtlFixedMemory overflow!\n" ); + } + pBlockHeader->m_pNext = NULL; + pBlockHeader->m_nBlockSize = nBlockSize; + + if (!m_pBlocks) + { + m_pBlocks = pBlockHeader; + } + else + { +#if 1 // IsIdxAfter assumes that newly allocated blocks are at the end + BlockHeader_t* __restrict pbh = m_pBlocks; + while (pbh->m_pNext) + { + pbh = pbh->m_pNext; + } + pbh->m_pNext = pBlockHeader; +#else + pBlockHeader = m_pBlocks; + pBlockHeader->m_pNext = m_pBlocks; +#endif + } +} + + +//----------------------------------------------------------------------------- +// Makes sure we've got at least this much memory +//----------------------------------------------------------------------------- +template< class T > +inline void CUtlFixedMemory::EnsureCapacity(int num) +{ + Grow(num - NumAllocated()); +} + + +//----------------------------------------------------------------------------- +// Memory deallocation +//----------------------------------------------------------------------------- +template< class T > +void CUtlFixedMemory::Purge() +{ + if (!m_pBlocks) + return; + + for (BlockHeader_t* pbh = m_pBlocks; pbh; ) + { + BlockHeader_t* pFree = pbh; + pbh = pbh->m_pNext; + free(pFree); + } + m_pBlocks = NULL; + m_nAllocationCount = 0; +} + +#endif // UTLFIXEDMEMORY_H +``` + +`detours.h`: + +```h +////////////////////////////////////////////////////////////////////////////// +// +// File: detours.h +// Module: detours.lib +// +// Detours for binary functions. Version 1.5 (Build 46) +// +// Copyright 1995-2001, Microsoft Corporation +// + +#pragma once +#ifndef _DETOURS_H_ +#define _DETOURS_H_ + +#pragma comment(lib, "detours") + +////////////////////////////////////////////////////////////////////////////// +// +#ifndef GUID_DEFINED +#define GUID_DEFINED +typedef struct _GUID +{ + DWORD Data1; + WORD Data2; + WORD Data3; + BYTE Data4[8]; +} GUID; +#endif // !GUID_DEFINED + +#if defined(__cplusplus) +#ifndef _REFGUID_DEFINED +#define _REFGUID_DEFINED +#define REFGUID const GUID & +#endif // !_REFGUID_DEFINED +#else // !__cplusplus +#ifndef _REFGUID_DEFINED +#define _REFGUID_DEFINED +#define REFGUID const GUID * const +#endif // !_REFGUID_DEFINED +#endif // !__cplusplus +// +////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + + /////////////////////////////////////////////////// Instruction Target Macros. + // +#define DETOUR_INSTRUCTION_TARGET_NONE ((PBYTE)0) +#define DETOUR_INSTRUCTION_TARGET_DYNAMIC ((PBYTE)~0ul) + + /////////////////////////////////////////////////////////// Trampoline Macros. + // + // DETOUR_TRAMPOLINE(trampoline_prototype, target_name) + // + // The naked trampoline must be at least DETOUR_TRAMPOLINE_SIZE bytes. + // +#define DETOUR_TRAMPOLINE_SIZE 32 +#define DETOUR_SECTION_HEADER_SIGNATURE 0x00727444 // "Dtr\0" + +#define DETOUR_TRAMPOLINE(trampoline,target) \ + static PVOID __fastcall _Detours_GetVA_##target(VOID) \ + { \ + return ⌖ \ +} \ + \ + __declspec(naked) trampoline \ + { \ + __asm { nop }; \ + __asm { nop }; \ + __asm { call _Detours_GetVA_##target }; \ + __asm { jmp eax }; \ + __asm { ret }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ +} + +#define DETOUR_TRAMPOLINE_EMPTY(trampoline) \ + __declspec(naked) trampoline \ + { \ + __asm { nop }; \ + __asm { nop }; \ + __asm { xor eax, eax }; \ + __asm { mov eax, [eax] }; \ + __asm { ret }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ + __asm { nop }; \ +} + + /////////////////////////////////////////////////////////// Binary Structures. + // +#pragma pack(push, 8) + typedef struct _DETOUR_SECTION_HEADER + { + DWORD cbHeaderSize; + DWORD nSignature; + DWORD nDataOffset; + DWORD cbDataSize; + + DWORD nOriginalImportVirtualAddress; + DWORD nOriginalImportSize; + DWORD nOriginalBoundImportVirtualAddress; + DWORD nOriginalBoundImportSize; + + DWORD nOriginalIatVirtualAddress; + DWORD nOriginalIatSize; + DWORD nOriginalSizeOfImage; + DWORD nReserve; + } DETOUR_SECTION_HEADER, *PDETOUR_SECTION_HEADER; + + typedef struct _DETOUR_SECTION_RECORD + { + DWORD cbBytes; + DWORD nReserved; + GUID guid; + } DETOUR_SECTION_RECORD, *PDETOUR_SECTION_RECORD; +#pragma pack(pop) + +#define DETOUR_SECTION_HEADER_DECLARE(cbSectionSize) \ + { \ + sizeof(DETOUR_SECTION_HEADER), \ + DETOUR_SECTION_HEADER_SIGNATURE, \ + sizeof(DETOUR_SECTION_HEADER), \ + (cbSectionSize), \ + \ + 0, \ + 0, \ + 0, \ + 0, \ + \ + 0, \ + 0, \ + 0, \ + 0, \ + } + + ///////////////////////////////////////////////////////////// Binary Typedefs. + // + typedef BOOL(CALLBACK *PF_DETOUR_BINARY_BYWAY_CALLBACK)(PVOID pContext, + PCHAR pszFile, + PCHAR *ppszOutFile); + typedef BOOL(CALLBACK *PF_DETOUR_BINARY_FILE_CALLBACK)(PVOID pContext, + PCHAR pszOrigFile, + PCHAR pszFile, + PCHAR *ppszOutFile); + typedef BOOL(CALLBACK *PF_DETOUR_BINARY_SYMBOL_CALLBACK)(PVOID pContext, + DWORD nOrdinal, + PCHAR pszOrigSymbol, + PCHAR pszSymbol, + PCHAR *ppszOutSymbol); + typedef BOOL(CALLBACK *PF_DETOUR_BINARY_FINAL_CALLBACK)(PVOID pContext); + typedef BOOL(CALLBACK *PF_DETOUR_BINARY_EXPORT_CALLBACK)(PVOID pContext, + DWORD nOrdinal, + PCHAR pszName, + PBYTE pbCode); + + typedef VOID * PDETOUR_BINARY; + typedef VOID * PDETOUR_LOADED_BINARY; + + //////////////////////////////////////////////////////// Trampoline Functions. + // + PBYTE WINAPI DetourFunction(PBYTE pbTargetFunction, + PBYTE pbDetourFunction); + + BOOL WINAPI DetourFunctionWithEmptyTrampoline(PBYTE pbTrampoline, + PBYTE pbTarget, + PBYTE pbDetour); + + BOOL WINAPI DetourFunctionWithEmptyTrampolineEx(PBYTE pbTrampoline, + PBYTE pbTarget, + PBYTE pbDetour, + PBYTE *ppbRealTrampoline, + PBYTE *ppbRealTarget, + PBYTE *ppbRealDetour); + + BOOL WINAPI DetourFunctionWithTrampoline(PBYTE pbTrampoline, + PBYTE pbDetour); + + BOOL WINAPI DetourFunctionWithTrampolineEx(PBYTE pbTrampoline, + PBYTE pbDetour, + PBYTE *ppbRealTrampoline, + PBYTE *ppbRealTarget); + + BOOL WINAPI DetourRemove(PBYTE pbTrampoline, PBYTE pbDetour); + + ////////////////////////////////////////////////////////////// Code Functions. + // + PBYTE WINAPI DetourFindFunction(PCHAR pszModule, PCHAR pszFunction); + PBYTE WINAPI DetourGetFinalCode(PBYTE pbCode, BOOL fSkipJmp); + + PBYTE WINAPI DetourCopyInstruction(PBYTE pbDst, PBYTE pbSrc, PBYTE *ppbTarget); + PBYTE WINAPI DetourCopyInstructionEx(PBYTE pbDst, + PBYTE pbSrc, + PBYTE *ppbTarget, + LONG *plExtra); + + ///////////////////////////////////////////////////// Loaded Binary Functions. + // + HMODULE WINAPI DetourEnumerateModules(HMODULE hModuleLast); + PBYTE WINAPI DetourGetEntryPoint(HMODULE hModule); + BOOL WINAPI DetourEnumerateExports(HMODULE hModule, + PVOID pContext, + PF_DETOUR_BINARY_EXPORT_CALLBACK pfExport); + + PBYTE WINAPI DetourFindPayload(HMODULE hModule, REFGUID rguid, DWORD *pcbData); + DWORD WINAPI DetourGetSizeOfPayloads(HMODULE hModule); + + ///////////////////////////////////////////////// Persistent Binary Functions. + // + BOOL WINAPI DetourBinaryBindA(PCHAR pszFile, PCHAR pszDll, PCHAR pszPath); + BOOL WINAPI DetourBinaryBindW(PWCHAR pwzFile, PWCHAR pwzDll, PWCHAR pwzPath); +#ifdef UNICODE +#define DetourBinaryBind DetourBinaryBindW +#else +#define DetourBinaryBind DetourBinaryBindA +#endif // !UNICODE + + PDETOUR_BINARY WINAPI DetourBinaryOpen(HANDLE hFile); + PBYTE WINAPI DetourBinaryEnumeratePayloads(PDETOUR_BINARY pBinary, + GUID *pGuid, + DWORD *pcbData, + DWORD *pnIterator); + PBYTE WINAPI DetourBinaryFindPayload(PDETOUR_BINARY pBinary, + REFGUID rguid, + DWORD *pcbData); + PBYTE WINAPI DetourBinarySetPayload(PDETOUR_BINARY pBinary, + REFGUID rguid, + PBYTE pbData, + DWORD cbData); + BOOL WINAPI DetourBinaryDeletePayload(PDETOUR_BINARY pBinary, REFGUID rguid); + BOOL WINAPI DetourBinaryPurgePayloads(PDETOUR_BINARY pBinary); + BOOL WINAPI DetourBinaryResetImports(PDETOUR_BINARY pBinary); + BOOL WINAPI DetourBinaryEditImports(PDETOUR_BINARY pBinary, + PVOID pContext, + PF_DETOUR_BINARY_BYWAY_CALLBACK pfByway, + PF_DETOUR_BINARY_FILE_CALLBACK pfFile, + PF_DETOUR_BINARY_SYMBOL_CALLBACK pfSymbol, + PF_DETOUR_BINARY_FINAL_CALLBACK pfFinal); + BOOL WINAPI DetourBinaryWrite(PDETOUR_BINARY pBinary, HANDLE hFile); + BOOL WINAPI DetourBinaryClose(PDETOUR_BINARY pBinary); + + /////////////////////////////////////////////// First Chance Exception Filter. + // + LPTOP_LEVEL_EXCEPTION_FILTER WINAPI + DetourFirstChanceExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelFilter); + + ///////////////////////////////////////////////// Create Process & Inject Dll. + // + typedef BOOL(WINAPI *PDETOUR_CREATE_PROCESS_ROUTINEA) + (LPCSTR lpApplicationName, + LPSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, + DWORD dwCreationFlags, + LPVOID lpEnvironment, + LPCSTR lpCurrentDirectory, + LPSTARTUPINFOA lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation); + + typedef BOOL(WINAPI *PDETOUR_CREATE_PROCESS_ROUTINEW) + (LPCWSTR lpApplicationName, + LPWSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, + DWORD dwCreationFlags, + LPVOID lpEnvironment, + LPCWSTR lpCurrentDirectory, + LPSTARTUPINFOW lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation); + + BOOL WINAPI DetourCreateProcessWithDllA(LPCSTR lpApplicationName, + LPSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, + DWORD dwCreationFlags, + LPVOID lpEnvironment, + LPCSTR lpCurrentDirectory, + LPSTARTUPINFOA lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation, + LPCSTR lpDllName, + PDETOUR_CREATE_PROCESS_ROUTINEA + pfCreateProcessA); + + BOOL WINAPI DetourCreateProcessWithDllW(LPCWSTR lpApplicationName, + LPWSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, + DWORD dwCreationFlags, + LPVOID lpEnvironment, + LPCWSTR lpCurrentDirectory, + LPSTARTUPINFOW lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation, + LPCWSTR lpDllName, + PDETOUR_CREATE_PROCESS_ROUTINEW + pfCreateProcessW); + +#ifdef UNICODE +#define DetourCreateProcessWithDll DetourCreateProcessWithDllW +#define PDETOUR_CREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINEW +#else +#define DetourCreateProcessWithDll DetourCreateProcessWithDllA +#define PDETOUR_CREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINEA +#endif // !UNICODE + + BOOL WINAPI DetourContinueProcessWithDllA(HANDLE hProcess, LPCSTR lpDllName); + BOOL WINAPI DetourContinueProcessWithDllW(HANDLE hProcess, LPCWSTR lpDllName); + +#ifdef UNICODE +#define DetourContinueProcessWithDll DetourContinueProcessWithDllW +#else +#define DetourContinueProcessWithDll DetourContinueProcessWithDllA +#endif // !UNICODE + // + ////////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +} +#endif // __cplusplus + +/////////////////////////////////////////////////////////////////// Old Names. +// +#define ContinueProcessWithDll DetourContinueProcessWithDll +#define ContinueProcessWithDllA DetourContinueProcessWithDllA +#define ContinueProcessWithDllW DetourContinueProcessWithDllW +#define CreateProcessWithDll DetourCreateProcessWithDll +#define CreateProcessWithDllA DetourCreateProcessWithDllA +#define CreateProcessWithDllW DetourCreateProcessWithDllW +#define DETOUR_TRAMPOLINE_WO_TARGET DETOUR_TRAMPOLINE_EMPTY +#define DetourBinaryPurgePayload DetourBinaryPurgePayloads +#define DetourEnumerateExportsForInstance DetourEnumerateExports +#define DetourEnumerateInstances DetourEnumerateModules +#define DetourFindEntryPointForInstance DetourGetEntryPoint +#define DetourFindFinalCode DetourGetFinalCode +#define DetourFindPayloadInBinary DetourFindPayload +#define DetourGetSizeOfBinary DetourGetSizeOfPayloads +#define DetourRemoveWithTrampoline DetourRemove +#define PCREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINE +#define PCREATE_PROCESS_ROUTINEA PDETOUR_CREATE_PROCESS_ROUTINEA +#define PCREATE_PROCESS_ROUTINEW PDETOUR_CREATE_PROCESS_ROUTINEW +// + +//////////////////////////////////////////////// Detours Internal Definitions. +// +#ifdef __cplusplus +#ifdef DETOURS_INTERNAL + +////////////////////////////////////////////////////////////////////////////// +// +#ifdef IMAGEAPI // defined by IMAGEHLP.H +typedef LPAPI_VERSION(NTAPI *PF_ImagehlpApiVersionEx)(LPAPI_VERSION AppVersion); + +typedef BOOL(NTAPI *PF_SymInitialize)(IN HANDLE hProcess, + IN LPSTR UserSearchPath, + IN BOOL fInvadeProcess); +typedef DWORD(NTAPI *PF_SymSetOptions)(IN DWORD SymOptions); +typedef DWORD(NTAPI *PF_SymGetOptions)(VOID); +typedef BOOL(NTAPI *PF_SymLoadModule)(IN HANDLE hProcess, + IN HANDLE hFile, + IN PSTR ImageName, + IN PSTR ModuleName, + IN DWORD BaseOfDll, + IN DWORD SizeOfDll); +typedef BOOL(NTAPI *PF_SymGetModuleInfo)(IN HANDLE hProcess, + IN DWORD dwAddr, + OUT PIMAGEHLP_MODULE ModuleInfo); +typedef BOOL(NTAPI *PF_SymGetSymFromName)(IN HANDLE hProcess, + IN LPSTR Name, + OUT PIMAGEHLP_SYMBOL Symbol); +typedef BOOL(NTAPI *PF_BindImage)(IN LPSTR pszImageName, + IN LPSTR pszDllPath, + IN LPSTR pszSymbolPath); + +typedef struct _DETOUR_SYM_INFO +{ + HANDLE hProcess; + HMODULE hImageHlp; + PF_ImagehlpApiVersionEx pfImagehlpApiVersionEx; + PF_SymInitialize pfSymInitialize; + PF_SymSetOptions pfSymSetOptions; + PF_SymGetOptions pfSymGetOptions; + PF_SymLoadModule pfSymLoadModule; + PF_SymGetModuleInfo pfSymGetModuleInfo; + PF_SymGetSymFromName pfSymGetSymFromName; + PF_BindImage pfBindImage; +} DETOUR_SYM_INFO, *PDETOUR_SYM_INFO; + +PDETOUR_SYM_INFO DetourLoadImageHlp(VOID); + +#endif // IMAGEAPI + +////////////////////////////////////////////////////////////////////////////// +// +class CDetourEnableWriteOnCodePage +{ +public: + CDetourEnableWriteOnCodePage(PBYTE pbCode, LONG cbCode = DETOUR_TRAMPOLINE_SIZE) + { + m_pbCode = pbCode; + m_cbCode = cbCode; + m_dwOldPerm = 0; + m_hProcess = GetCurrentProcess(); + + if (m_pbCode && m_cbCode) { + if (!FlushInstructionCache(m_hProcess, pbCode, cbCode)) { + return; + } + if (!VirtualProtect(pbCode, + cbCode, + PAGE_EXECUTE_READWRITE, + &m_dwOldPerm)) { + return; + } + } + } + + ~CDetourEnableWriteOnCodePage() + { + if (m_dwOldPerm && m_pbCode && m_cbCode) { + DWORD dwTemp = 0; + if (!FlushInstructionCache(m_hProcess, m_pbCode, m_cbCode)) { + return; + } + if (!VirtualProtect(m_pbCode, m_cbCode, m_dwOldPerm, &dwTemp)) { + return; + } + } + } + + BOOL SetPermission(DWORD dwPerms) + { + if (m_dwOldPerm && m_pbCode && m_cbCode) { + m_dwOldPerm = dwPerms; + return TRUE; + } + return FALSE; + } + + BOOL IsValid(VOID) + { + return m_pbCode && m_cbCode && m_dwOldPerm; + } + +private: + HANDLE m_hProcess; + PBYTE m_pbCode; + LONG m_cbCode; + DWORD m_dwOldPerm; +}; + +////////////////////////////////////////////////////////////////////////////// +// +inline PBYTE DetourGenMovEax(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xB8; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenMovEbx(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xBB; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenMovEcx(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xB9; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenMovEdx(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xBA; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenMovEsi(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xBE; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenMovEdi(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xBF; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenMovEbp(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xBD; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenMovEsp(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xBC; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenPush(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0x68; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenPushad(PBYTE pbCode) +{ + *pbCode++ = 0x60; + return pbCode; +} + +inline PBYTE DetourGenPopad(PBYTE pbCode) +{ + *pbCode++ = 0x61; + return pbCode; +} + +inline PBYTE DetourGenJmp(PBYTE pbCode, PBYTE pbJmpDst, PBYTE pbJmpSrc = 0) +{ + if (pbJmpSrc == 0) { + pbJmpSrc = pbCode; + } + *pbCode++ = 0xE9; + *((INT32*&)pbCode)++ = pbJmpDst - (pbJmpSrc + 5); + return pbCode; +} + +inline PBYTE DetourGenCall(PBYTE pbCode, PBYTE pbJmpDst, PBYTE pbJmpSrc = 0) +{ + if (pbJmpSrc == 0) { + pbJmpSrc = pbCode; + } + *pbCode++ = 0xE8; + *((INT32*&)pbCode)++ = pbJmpDst - (pbJmpSrc + 5); + return pbCode; +} + +inline PBYTE DetourGenBreak(PBYTE pbCode) +{ + *pbCode++ = 0xcc; + return pbCode; +} + +inline PBYTE DetourGenRet(PBYTE pbCode) +{ + *pbCode++ = 0xc3; + return pbCode; +} + +inline PBYTE DetourGenNop(PBYTE pbCode) +{ + *pbCode++ = 0x90; + return pbCode; +} +#endif DETOURS_INTERAL +#endif // __cplusplus + +#endif // _DETOURS_H_ +// +//////////////////////////////////////////////////////////////// End of File. + +``` + +`displacement.cpp`: + +```cpp +#include "displacement.hpp" +#include "prop_manager.hpp" + +namespace Engine::Displacement +{ + + DECLSPEC_NOINLINE bool Create() + { + + + +#ifdef VIRTUALIZER + +#endif // VIRTUALIZER + auto& pPropManager = PropManager::Instance(); + + C_BaseEntity::m_MoveType = pPropManager->GetOffset(sxor("DT_BaseEntity"), sxor("m_nRenderMode")) + 1; + C_BaseEntity::m_rgflCoordinateFrame = pPropManager->GetOffset(sxor("DT_BaseEntity"), sxor("m_CollisionGroup")) - 48; + + DT_BaseEntity::m_iTeamNum = pPropManager->GetOffset(sxor("DT_BaseEntity"), sxor("m_iTeamNum")); + DT_BaseEntity::m_vecOrigin = pPropManager->GetOffset(sxor("DT_BaseEntity"), sxor("m_vecOrigin")); + + DT_BaseCombatCharacter::m_hActiveWeapon = pPropManager->GetOffset(sxor("DT_BaseCombatCharacter"), sxor("m_hActiveWeapon")); + + auto m_hConstraintEntity = pPropManager->GetOffset(sxor("DT_BasePlayer"), sxor("m_hConstraintEntity")); + + C_BasePlayer::m_pCurrentCommand = int(m_hConstraintEntity - 0xC);//Memory::Scan( "client.dll"), sxor("89 ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? 85 FF 75" ) + 2 ); + + DT_BasePlayer::m_aimPunchAngle = pPropManager->GetOffset(sxor("DT_BasePlayer"), sxor("m_aimPunchAngle")); + DT_BasePlayer::m_viewPunchAngle = pPropManager->GetOffset(sxor("DT_BasePlayer"), sxor("m_viewPunchAngle")); + DT_BasePlayer::m_vecViewOffset = pPropManager->GetOffset(sxor("DT_BasePlayer"), sxor("m_vecViewOffset[0]")); + DT_BasePlayer::m_vecVelocity = pPropManager->GetOffset(sxor("DT_BasePlayer"), sxor("m_vecVelocity[0]")); + DT_BasePlayer::m_vecBaseVelocity = pPropManager->GetOffset(sxor("DT_BasePlayer"), sxor("m_vecBaseVelocity")); + DT_BasePlayer::m_flFallVelocity = pPropManager->GetOffset(sxor("DT_BasePlayer"), sxor("m_flFallVelocity")); + DT_BasePlayer::m_lifeState = pPropManager->GetOffset(sxor("DT_CSPlayer"), sxor("m_lifeState")); + DT_BasePlayer::m_nTickBase = pPropManager->GetOffset(sxor("DT_BasePlayer"), sxor("m_nTickBase")); + DT_BasePlayer::m_iHealth = pPropManager->GetOffset(sxor("DT_BasePlayer"), sxor("m_iHealth")); + DT_BasePlayer::m_fFlags = pPropManager->GetOffset(sxor("DT_BasePlayer"), sxor("m_fFlags")); + DT_BasePlayer::m_flSimulationTime = pPropManager->GetOffset(sxor("DT_BasePlayer"), sxor("m_flSimulationTime")); + + DT_CSPlayer::m_angEyeAngles = pPropManager->GetOffset(sxor("DT_CSPlayer"), sxor("m_angEyeAngles[0]")); + DT_CSPlayer::m_bIsScoped = pPropManager->GetOffset(sxor("DT_CSPlayer"), sxor("m_bIsScoped")); + DT_CSPlayer::m_flDuckAmount = pPropManager->GetOffset(sxor("DT_BasePlayer"), sxor("m_flDuckAmount")); + DT_CSPlayer::m_flPoseParameter = pPropManager->GetOffset(sxor("DT_CSPlayer"), sxor("m_flPoseParameter")); + DT_CSPlayer::m_bHasHelmet = pPropManager->GetOffset(sxor("DT_CSPlayer"), sxor("m_bHasHelmet")); + DT_CSPlayer::m_flLowerBodyYawTarget = pPropManager->GetOffset(sxor("DT_CSPlayer"), sxor("m_flLowerBodyYawTarget")); + + DT_BaseAnimating::m_nForceBone = pPropManager->GetOffset(sxor("DT_BaseAnimating"), sxor("m_nForceBone")); + DT_BaseAnimating::m_bClientSideAnimation = pPropManager->GetOffset(sxor("DT_BaseAnimating"), sxor("m_bClientSideAnimation")); + DT_BaseAnimating::m_nSequence = pPropManager->GetOffset(sxor("DT_BaseAnimating"), sxor("m_nSequence")); + DT_BaseAnimating::m_nHitboxSet = pPropManager->GetOffset(sxor("DT_BaseAnimating"), sxor("m_nHitboxSet")); + DT_BaseAnimating::m_flCycle = pPropManager->GetOffset(sxor("DT_BaseAnimating"), sxor("m_flCycle")); + + DT_BaseCombatWeapon::m_flNextPrimaryAttack = pPropManager->GetOffset(sxor("DT_BaseCombatWeapon"), sxor("m_flNextPrimaryAttack")); + DT_BaseCombatWeapon::m_flNextSecondaryAttack = pPropManager->GetOffset(sxor("DT_BaseCombatWeapon"), sxor("m_flNextSecondaryAttack")); + DT_BaseCombatWeapon::m_hOwner = pPropManager->GetOffset(sxor("DT_BaseCombatWeapon"), sxor("m_hOwner")); + DT_BaseCombatWeapon::m_iClip1 = pPropManager->GetOffset(sxor("DT_BaseCombatWeapon"), sxor("m_iClip1")); + DT_BaseCombatWeapon::m_iItemDefinitionIndex = pPropManager->GetOffset(sxor("DT_BaseCombatWeapon"), sxor("m_iItemDefinitionIndex")); + + DT_WeaponCSBase::m_flRecoilIndex = pPropManager->GetOffset(sxor("DT_WeaponCSBase"), sxor("m_flRecoilIndex")); + + auto m_nForceBone = pPropManager->GetOffset(sxor("DT_BaseAnimating"), sxor("m_nForceBone")); + + //Data::m_uMoveHelper = **(std::uintptr_t * *)(Memory::Scan(sxor("client.dll"), sxor("8B 0D ?? ?? ?? ?? 8B 45 ?? 51 8B D4 89 02 8B 01")) + 2); + //Data::m_uInput = *(std::uintptr_t*)(Memory::Scan(sxor("client.dll"), sxor("B9 ?? ?? ?? ?? F3 0F 11 04 24 FF 50 10")) + 1); + //Data::m_uPredictionRandomSeed = *(std::uintptr_t*)(Memory::Scan(sxor("client.dll"), sxor("8B 0D ?? ?? ?? ?? BA ?? ?? ?? ?? E8 ?? ?? ?? ?? 83 C4 04")) + 2); + //Data::m_uPredictionPlayer = *(std::uintptr_t*)(Memory::Scan(sxor("client.dll"), sxor("89 ?? ?? ?? ?? ?? F3 0F 10 48 20")) + 2); + + const auto image_vstdlib = GetModuleHandleA(sxor("vstdlib.dll")); + + Function::m_uRandomSeed = (std::uintptr_t)(GetProcAddress(image_vstdlib, sxor("RandomSeed"))); + Function::m_uRandomFloat = (std::uintptr_t)(GetProcAddress(image_vstdlib, sxor("RandomFloat"))); + Function::m_uRandomInt = (std::uintptr_t)(GetProcAddress(image_vstdlib, sxor("RandomInt"))); + + InitMiscSignatures(); + + DT_BaseAnimating::m_BoneAccessor = m_nForceBone + 0x1C; // todo + DT_BaseAnimating::m_iMostRecentModelBoneCounter = *(int*)(Signatures[INVALIDATEBONECACHE] + 0x1B); + DT_BaseAnimating::m_flLastBoneSetupTime = *(int*)(Signatures[INVALIDATEBONECACHE] + 0x11); + + Data::m_uModelBoneCounter = *(std::uintptr_t*)(Signatures[INVALIDATEBONECACHE] + 0xA); + + Data::m_nLastCommandAck = *(int*)(Signatures[CL_PREDICT] + 0x20); + Data::m_nDeltaTick = *(int*)(Signatures[CL_PREDICT] + 0x10); + Data::m_nLastOutgoingCommand = *(int*)(Signatures[CL_PREDICT] + 0xA); + Data::m_nChokedCommands = *(int*)(Signatures[CL_PREDICT] + 0x4); + Data::m_bIsHLTV = *(int*)(Signatures[CL_MOVE] + 0x4); + +#ifdef VIRTUALIZER + +#endif // VIRTUALIZER + + + + return true; + } + + DECLSPEC_NOINLINE void InitMiscSignatures() + { +#ifdef VIRTUALIZER + +#endif // VIRTUALIZER + + + + + Signatures[TRACEFILTER_SIMPLE] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 E4 F0 83 EC 7C 56 52")); + Signatures[INIT_KEY_VALUES] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 51 33 C0 C7 45")); + Signatures[CL_PREDICT] = Memory::Scan(sxor("engine.dll"), sxor("75 30 8B 87 ?? ?? ?? ??")); + Signatures[CL_MOVE] = Memory::Scan(sxor("engine.dll"), sxor("74 0F 80 BF ?? ?? ?? ?? ??")); + Signatures[DX9DEVICE] = **(std::uintptr_t**)(Memory::Scan(sxor("shaderapidx9.dll"), sxor("A1 ? ? ? ? 50 8B 08 FF 51 0C")) + 1); + Signatures[INVALIDATEBONECACHE] = Memory::Scan(sxor("client.dll"), sxor("80 3D ?? ?? ?? ?? ?? 74 16 A1 ?? ?? ?? ?? 48 C7 81")); + Signatures[MOVEHELPER] = **(std::uintptr_t**)(Memory::Scan(sxor("client.dll"), sxor("8B 0D ?? ?? ?? ?? 8B 45 ?? 51 8B D4 89 02 8B 01")) + 2); + Signatures[IINPUT] = *(std::uintptr_t*)(Memory::Scan(sxor("client.dll"), sxor("B9 ?? ?? ?? ?? F3 0F 11 04 24 FF 50 10")) + 1); + Signatures[PREDRANDOMSEED] = *(std::uintptr_t*)(Memory::Scan(sxor("client.dll"), sxor("8B 0D ?? ?? ?? ?? BA ?? ?? ?? ?? E8 ?? ?? ?? ?? 83 C4 04")) + 2); + Signatures[PREDPLAYER] = *(std::uintptr_t*)(Memory::Scan(sxor("client.dll"), sxor("89 ?? ?? ?? ?? ?? F3 0F 10 48 20")) + 2); + Signatures[BREAKABLE] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 51 56 8B F1 85 F6 74 68")); + Signatures[SET_CLAN_TAG] = Memory::Scan(sxor("engine.dll"), sxor("53 56 57 8B DA 8B F9 FF 15")); + Signatures[COMMANDS_LIMIT] = Memory::Scan(sxor("engine.dll"), sxor("55 8B EC A1 ? ? ? ? 81 EC ? ? ? ? B9 ? ? ? ? 53 8B 98")); + Signatures[SETUPVEL_SPEED] = Memory::Scan(sxor("client.dll"), sxor("0F 2F 15 ? ? ? ? 0F 86 ? ? ? ? F3 0F 7E 4C 24")); + Signatures[GAMERULES] = Memory::Scan(sxor("client.dll"), sxor("A1 ? ? ? ? 85 C0 0F 84 ? ? ? ? 80 B8 ? ? ? ? ? 74 7A")); + Signatures[UPDATEHUDWEAPONS] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 51 53 56 8B 75 08 8B D9 57 6B FE 2C")); + Signatures[CLEARDEATHNOTICES] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 EC 0C 53 56 8B 71 58")); + Signatures[RESETANIMSTATE] = Memory::Scan(sxor("client.dll"), sxor("56 6A 01 68 ? ? ? ? 8B F1")); + Signatures[OVERRIDEPOSTPROCESS] = Memory::Scan(sxor("client.dll"), sxor("80 3D ? ? ? ? ? 53 56 57 0F 85")); + Signatures[VGUI_START_DRAW] = Memory::Scan(sxor("vguimatsurface.dll"), sxor("55 8B EC 83 E4 C0 83 EC 38")); + Signatures[VGUI_END_DRAW] = Memory::Scan(sxor("vguimatsurface.dll"), sxor("8B 0D ? ? ? ? 56 C6 05")); + Signatures[LIST_LEAVES] = Memory::Scan(sxor("client.dll"), sxor("56 52 FF 50 18")); + Signatures[PTR_ANIMATION_LAYER] = Memory::Scan(sxor("client.dll"), sxor("8B 89 ?? ?? ?? ?? 8D 0C D1")); + Signatures[GET_ANIMATION_LAYER] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 57 8B F9 8B 97 ? ? ? ? 85 D2")); + Signatures[UPDATEVISIBILITY_ALLENTS] = Memory::Scan("client.dll", sxor("E8 ? ? ? ? 83 7D D8 00 7C 0F")); + Signatures[UPDATEANIMSTATE] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 E4 F8 83 EC 18 56 57 8B F9 F3 0F 11 54 24")); + Signatures[SETABSANGLES] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 E4 F8 83 EC 64 53 56 57 8B F1 E8")); + Signatures[DELAYUNSCOPE] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC A1 ? ? ? ? 57 8B F9 B9 ? ? ? ? FF 50 ? 85 C0 75 ? 32 C0")); + Signatures[SETABSORIGIN] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 E4 F8 51 53 56 57 8B F1 E8")); + Signatures[INVALIDATEPHYSICS] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 E4 F8 83 EC 0C 53 8B 5D 08 8B C3 56 83 E0 04")); + Signatures[SETCOLLISIONBOUNDS] = Memory::Scan(sxor("client.dll"), sxor("53 8B DC 83 EC 08 83 E4 F8 83 C4 04 55 8B 6B 04 89 6C 24 04 8B EC 83 EC 10 56 57 8B 7B")); + Signatures[LOOKUPSEQUENCE] = Memory::follow_rel32((DWORD)Memory::Scan(sxor("client.dll"), sxor("E8 ? ? ? ? 5E 83 F8 FF ")), 1); + Signatures[LOOKUPBONE] = Memory::follow_rel32((DWORD)Memory::Scan(sxor("client.dll"), sxor("E8 ? ? ? ? 89 44 24 5C")), 1); + Signatures[GETSEQUENCEACTIVITY] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 53 8B 5D 08 56 8B F1 83")); + Signatures[STUDIOHDR] = Memory::Scan(sxor("client.dll"), sxor("8B B7 ?? ?? ?? ?? 89 74 24 20")); + Signatures[SERVER_GLOBALS] = Memory::Scan(sxor("server.dll"), sxor("8B 15 ? ? ? ? 33 C9 83 7A 18 01")); + Signatures[GETSEQUENCEMOVEDIST] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 EC 0C 56 8B F1 57 8B FA 85 F6 75 14 68")); + Signatures[DRAWSERVERHITBOXES] = Memory::Scan(sxor("server.dll"), sxor("55 8B EC 81 EC ? ? ? ? 53 56 8B 35 ? ? ? ? 8B D9 57 8B CE")); + Signatures[STUDIOSETPOSEPARAM] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 E4 F8 83 EC 08 F3 0F 11 54 24 ? 85 D2")); + Signatures[SETPOSEPARAM] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 51 56 8B F1 0F 28 C2 57 F3 0F 11 45 FC")); + Signatures[MD5_PSEUDORANDOM] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 E4 F8 83 EC 70 6A 58")); + Signatures[RET_MAINTAINSEQUENCETRANS] = Memory::Scan(sxor("client.dll"), sxor("84 C0 74 17 8B 87")); //C_BaseAnimating::MaintainSequenceTransitions + Signatures[RET_SETUPBONES_PRED_TIME] = Memory::Scan(sxor("client.dll"), sxor("84 C0 74 0A F3 0F 10 05 ? ? ? ? EB 05")); + Signatures[RET_CALCPLAYERVIEW_DRIFTPITCH] = Memory::Scan(sxor("client.dll"), sxor("84 C0 75 0B 8B 0D ? ? ? ? 8B 01 FF 50 4C")); + Signatures[RET_CALCPLAYERVIEW] = Memory::Scan(sxor("client.dll"), sxor("84 C0 75 08 57 8B CE E8 ? ? ? ? 8B 06")); + Signatures[GET_WEAPON_PREFIX] = Memory::Scan(sxor("client.dll"), sxor("53 56 57 8B F9 33 F6 8B 4F 60 8B 01")); + Signatures[LOADFROMBUFFEREX] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 E4 F8 83 EC 34 53 8B 5D 0C 89")); + Signatures[PTR_PREDICTIONHTLV_MUSOR] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 E4 F8 81 EC ? ? ? ? 53 8B 1D ? ? ? ? 56 57 85 DB 0F 84 ? ? ? ? 8B CB E8 ? ? ? ? 84 C0 0F 84 ? ? ? ? A1 ? ? ? ? 8B 40 1C")); + Signatures[ALLOW_EXTRAPOLATION] = Memory::Scan(sxor("client.dll"), sxor("A2 ? ? ? ? 8B 45 E8")); + Signatures[PREDICTED_VIEWMODEL] = Memory::Scan(sxor("client.dll"), sxor("F3 0F 11 45 ? E8 ? ? ? ? 5E 5F")); + Signatures[RET_CROSSHAIRCOLOR] = Memory::Scan(sxor("client.dll"), sxor("FF 50 3C 80 7D 2C")); + Signatures[RET_CROSSHAIROUTLINECOLOR] = Memory::Scan(sxor("client.dll"), sxor("FF 50 3C F3 0F 10 4D ? 66 0F 6E C6")); + Signatures[WRITEUSERCMD] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 E4 F8 51 53 56 8B D9 8B 0D")); + Signatures[RET_SETUPVELOCITY] = Memory::Scan(sxor("client.dll"), sxor("8B CE E8 ? ? ? ? F3 0F 10 A6")); + Signatures[RET_HLTV_ACCUMULATE_LAYERS] = Memory::Scan(sxor("client.dll"), sxor("84 C0 75 0D F6 87")); + Signatures[RET_HLTV_SETUPVELOCITY] = Memory::Scan(sxor("client.dll"), sxor("84 C0 75 38 8B 0D ? ? ? ? 8B 01 8B 80")); + Signatures[RET_ISLOADOUT_ALLOWED] = Memory::Scan(sxor("client.dll"), sxor("84 C0 75 04 B0 01 5F")); + Signatures[CLIENT_STATE] = Memory::Scan(sxor("engine.dll"), sxor("A1 ? ? ? ? 8B 80 ? ? ? ? C3")); + Signatures[BEAMS] = Memory::Scan(("client.dll"), sxor("B9 ? ? ? ? A1 ? ? ? ? FF 10 A1 ? ? ? ? B9")); + Signatures[GLOW_OBJECTS] = Memory::Scan(("client.dll"), sxor("0F 11 05 ? ? ? ? 83 C8 01")); + Signatures[PTR_STANDARDBLENDINGRULES] = (Memory::Scan(("client.dll"), ("55 8B EC 83 E4 F0 B8 ? ? ? ? E8 ? ? ? ? 56 8B 75 08 57 8B F9 85 F6"))); + Signatures[PTR_SETUPVELOCITY] = (Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 E4 F8 83 EC 30 56 57 8B 3D"))); + Signatures[PTR_SETUPMOVEMENT] = (Memory::Scan(sxor("client.dll"), sxor("55 8B EC 81 EC ? ? ? ? 53 56 57 8B 3D"))); + Signatures[PTR_SHOULDCOLLIDE] = (Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 B9 ? ? ? ? ? 75 0F"))); + Signatures[PTR_ACCUMULATELAYERS] = (Memory::Scan(("client.dll"), sxor("55 8B EC 57 8B F9 8B 0D ? ? ? ? 8B 01 8B"))); + Signatures[PTR_DOEXTRABONESPROCESSING] = (Memory::Scan(("client.dll"), sxor("55 8B EC 83 E4 F8 81 EC ? ? ? ? 53 56 8B F1 57 89 74 24 1C"))); + Signatures[PTR_GETFOREIGNFALLBACKFONT] = (Memory::Scan(("vguimatsurface.dll"), sxor("80 3D ? ? ? ? ? 74 06 B8"))); + Signatures[PTR_UPDATECLIENTSIDEANIMS] = (Memory::Scan(("client.dll"), sxor("55 8B EC 51 56 8B F1 80 BE ? ? 00 00 00 74 36"))); + Signatures[PTR_SETUPBONES] = (Memory::Scan(("client.dll"), sxor("55 8B EC 83 E4 F0 B8 D8"))); + Signatures[PTR_CALCVIEWBOB] = (Memory::Scan(("client.dll"), sxor("55 8B EC A1 ? ? ? ? 83 EC 10 56 8B F1 B9"))); + Signatures[PTR_ADDVIEWMODELBOB] = (Memory::Scan(("client.dll"), sxor("55 8B EC A1 ? ? ? ? 56 8B F1 B9 ? ? ? ? FF 50 34 85 C0 74 35"))); + Signatures[PTR_SHOULDSKIPANIMFRAME] = (Memory::follow_rel32(Memory::Scan(("client.dll"), sxor("E8 ? ? ? ? 88 44 24 0B")), 1)); + Signatures[PTR_SHOULDHITENTITY] = (Memory::Scan(("client.dll"), sxor("55 8B EC 8B 55 0C 56 8B 75 08 57"))); + Signatures[PTR_MODIFYEYEPOS] = (Memory::Scan(("client.dll"), sxor("55 8B EC 83 E4 F8 83 EC 5C 53 8B D9 56 57 83"))); + Signatures[PTR_CL_MOVE] = (Memory::Scan(("engine.dll"), sxor("55 8B EC 81 EC 64 01 00 00 53 56 57 8B 3D"))); + Signatures[PTR_PROCESSINTERPLIST] = (Memory::Scan(("client.dll"), sxor("53 0F B7 1D ? ? ? ? 56"))); + Signatures[PTR_SETVIEWMODELOFFSETS] = (Memory::Scan(("client.dll"), sxor("55 8B EC 8B 45 08 F3 0F 7E 45"))); + Signatures[PTR_GETCOLORMODULATION] = (Memory::Scan(("materialsystem.dll"), sxor("55 8B EC 83 EC ? 56 8B F1 8A 46"))); + Signatures[PTR_ISUSINGSTATICPROPDBGMODES] = (Memory::Scan(("engine.dll"), sxor("8B 0D ? ? ? ? 81 F9 ? ? ? ? 75 ? A1 ? ? ? ? 35 ? ? ? ? EB ? 8B 01 FF 50 ? 83 F8 ? 0F 85 ? ? ? ? 8B 0D"))); + Signatures[PTR_REPORTHIT] = (Memory::Scan(("client.dll"), sxor("55 8B EC 8B 55 08 83 EC 1C F6 42 1C 01"))); + Signatures[PTR_CALCVIEW] = (Memory::Scan(("client.dll"), sxor("55 8B EC 56 8B F1 57 8B 8E ? ? ? ? 83 F9 FF 74 3E 0F B7 C1 C1 E0 04 05 ? ? ? ? C1 E9 10 39 48 04 75 2B 8B 08 85 C9 74 25 8B 01"))); + Signatures[CLIENT_EFFECTS] = Memory::Scan(sxor("client.dll"), sxor("8B 35 ? ? ? ? 85 F6 0F 84 ? ? ? ? 0F 1F ? 8B 3E")); + Signatures[HOST_FRAMETICKS] = Memory::Scan(sxor("engine.dll"), sxor("03 05 ? ? ? ? 83 CF 10")); + Signatures[FIND_HUD_ELEMENT_PTHIS] = Memory::Scan(sxor("client.dll"), sxor("B9 ? ? ? ? E8 ? ? ? ? 8B 5D 08")); + Signatures[FIND_HUD_ELEMENT] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 53 8B 5D 08 56 57 8B F9 33 F6 39 77 28")); + Signatures[LINEGOESTHRUSMOKE] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 EC 08 8B 15 ? ? ? ? 0F 57 C0")); + Signatures[PHYSICS_RUN_THINK] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 83 EC 10 53 56 57 8B F9 8B 87")); + Signatures[SETNEXTTHINK] = Memory::Scan(sxor("client.dll"), sxor("55 8B EC 56 57 8B F9 8B B7 ? ? ? ? 8B")); + + + +#ifdef VIRTUALIZER + +#endif // VIRTUALIZER + } + + void Destroy() + { + + } + + std::uintptr_t Signatures[SIGNATURES_MAX]; + + namespace C_BaseEntity + { + int m_MoveType = 0; + int m_rgflCoordinateFrame = 0; + } + namespace DT_BaseAnimating + { + int m_nForceBone = 0; + int m_bClientSideAnimation = 0; + int m_nSequence = 0; + int m_flCycle = 0; + int m_nHitboxSet = 0; + DWORD32 m_BoneAccessor; + DWORD32 m_iMostRecentModelBoneCounter; + DWORD32 m_flLastBoneSetupTime; + } + namespace DT_BaseEntity + { + int m_iTeamNum = 0; + int m_vecOrigin = 0; + } + namespace DT_BaseCombatCharacter + { + int m_hActiveWeapon = 0; + } + namespace C_BasePlayer + { + int m_pCurrentCommand = 0; + } + namespace DT_BasePlayer + { + int m_aimPunchAngle = 0; + int m_viewPunchAngle = 0; + int m_vecViewOffset = 0; + int m_vecVelocity = 0; + int m_vecBaseVelocity = 0; + int m_flFallVelocity = 0; + int m_lifeState = 0; + int m_nTickBase = 0; + int m_iHealth = 0; + int m_fFlags = 0; + int m_flSimulationTime = 0; + } + namespace DT_CSPlayer + { + int m_flLowerBodyYawTarget = 0; + int m_angEyeAngles = 0; + int m_bIsScoped = 0; + int m_flDuckAmount = 0; + int m_flPoseParameter = 0; + int m_bHasHelmet = 0; + } + namespace DT_BaseCombatWeapon + { + int m_flNextPrimaryAttack = 0; + int m_flNextSecondaryAttack = 0; + int m_hOwner = 0; + int m_iClip1 = 0; + int m_iItemDefinitionIndex = 0; + } + namespace DT_WeaponCSBase + { + int m_flRecoilIndex = 0; + } + namespace Data + { + //std::uintptr_t m_uMoveHelper = 0u; + //std::uintptr_t m_uInput = 0u; + //std::uintptr_t m_uPredictionRandomSeed = 0u; + //std::uintptr_t m_uPredictionPlayer = 0u; + std::uintptr_t m_uModelBoneCounter = 0u; + DWORD32 m_nDeltaTick = 0; + DWORD32 m_nChokedCommands = 0; + DWORD32 m_nLastOutgoingCommand = 0; + DWORD32 m_nLastCommandAck = 0; + DWORD32 m_bIsHLTV = 0; + } + namespace Function + { + std::uintptr_t m_uRandomSeed = 0u; + std::uintptr_t m_uRandomFloat = 0u; + std::uintptr_t m_uRandomInt = 0u; + } + +} + +``` + +`displacement.hpp`: + +```hpp +#pragma once + +#include "sdk.hpp" + +enum c_signatures : int +{ + TRACEFILTER_SIMPLE, + INIT_KEY_VALUES, + CL_PREDICT, + CL_MOVE, + INVALIDATEBONECACHE, + MOVEHELPER, + IINPUT, + PREDRANDOMSEED, + PREDPLAYER, + BREAKABLE, + SET_CLAN_TAG, + COMMANDS_LIMIT, + SETUPVEL_SPEED, + GAMERULES, + UPDATEHUDWEAPONS, + CLEARDEATHNOTICES, + RESETANIMSTATE, + OVERRIDEPOSTPROCESS, + VGUI_START_DRAW, + VGUI_END_DRAW, + LIST_LEAVES, + PTR_ANIMATION_LAYER, + GET_ANIMATION_LAYER, + UPDATEVISIBILITY_ALLENTS, + UPDATEANIMSTATE, + SETABSANGLES, + SETABSORIGIN, + DELAYUNSCOPE, + INVALIDATEPHYSICS, + SETCOLLISIONBOUNDS, + LOOKUPSEQUENCE, + LOOKUPBONE, + GETSEQUENCEACTIVITY, + STUDIOHDR, + SERVER_GLOBALS, + GETSEQUENCEMOVEDIST, + DRAWSERVERHITBOXES, + STUDIOSETPOSEPARAM, + SETPOSEPARAM, + MD5_PSEUDORANDOM, + RET_MAINTAINSEQUENCETRANS, + RET_SETUPBONES_PRED_TIME, + RET_CALCPLAYERVIEW_DRIFTPITCH, + RET_CALCPLAYERVIEW, + GET_WEAPON_PREFIX, + LOADFROMBUFFEREX, + ALLOW_EXTRAPOLATION, + PREDICTED_VIEWMODEL, + RET_CROSSHAIRCOLOR, + RET_CROSSHAIROUTLINECOLOR, + WRITEUSERCMD, + RET_SETUPVELOCITY, + PTR_SETUPVELOCITY, + PTR_SETUPMOVEMENT, + PTR_ACCUMULATELAYERS, + RET_HLTV_ACCUMULATE_LAYERS, + RET_HLTV_SETUPVELOCITY, + RET_ISLOADOUT_ALLOWED, + CLIENT_STATE, + BEAMS, + GLOW_OBJECTS, + DX9DEVICE, + PTR_STANDARDBLENDINGRULES, + PTR_PREDICTIONHTLV_MUSOR, + PTR_SHOULDCOLLIDE, + PTR_DOEXTRABONESPROCESSING, + PTR_GETFOREIGNFALLBACKFONT, + PTR_UPDATECLIENTSIDEANIMS, + PTR_SETUPBONES, + PTR_CALCVIEWBOB, + PTR_ADDVIEWMODELBOB, + PTR_SHOULDSKIPANIMFRAME, + PTR_SHOULDHITENTITY, + PTR_MODIFYEYEPOS, + PTR_PROCESSINTERPLIST, + PTR_SETVIEWMODELOFFSETS, + PTR_GETCOLORMODULATION, + PTR_ISUSINGSTATICPROPDBGMODES, + PTR_REPORTHIT, + PTR_CALCVIEW, + PTR_CL_MOVE, + CLIENT_EFFECTS, + HOST_FRAMETICKS, + FIND_HUD_ELEMENT_PTHIS, + FIND_HUD_ELEMENT, + LINEGOESTHRUSMOKE, + PHYSICS_RUN_THINK, + SETNEXTTHINK, + SIGNATURES_MAX +}; + +namespace Engine::Displacement +{ + +bool Create(); +void InitMiscSignatures(); +void Destroy(); + +extern std::uintptr_t Signatures[SIGNATURES_MAX]; + +namespace C_BaseEntity +{ + extern int m_MoveType; + extern int m_rgflCoordinateFrame; +} +namespace DT_BaseAnimating +{ + extern int m_nForceBone; + extern int m_bClientSideAnimation; + extern int m_nSequence; + extern int m_flCycle; + extern int m_nHitboxSet; + extern DWORD32 m_BoneAccessor; + extern DWORD32 m_iMostRecentModelBoneCounter; + extern DWORD32 m_flLastBoneSetupTime; +} +namespace DT_BaseEntity +{ + extern int m_iTeamNum; + extern int m_vecOrigin; +} +namespace DT_BaseCombatCharacter +{ + extern int m_hActiveWeapon; +} +namespace C_BasePlayer +{ + extern int m_pCurrentCommand; +} +namespace DT_BasePlayer +{ + extern int m_aimPunchAngle; + extern int m_viewPunchAngle; + extern int m_vecViewOffset; + extern int m_vecVelocity; + extern int m_vecBaseVelocity; + extern int m_flFallVelocity; + extern int m_lifeState; + extern int m_nTickBase; + extern int m_iHealth; + extern int m_fFlags; + extern int m_flSimulationTime; +} +namespace DT_CSPlayer +{ + extern int m_flLowerBodyYawTarget; + extern int m_angEyeAngles; + extern int m_bIsScoped; + extern int m_flDuckAmount; + extern int m_flPoseParameter; + extern int m_bHasHelmet; +} +namespace DT_BaseCombatWeapon +{ + extern int m_flNextPrimaryAttack; + extern int m_flNextSecondaryAttack; + extern int m_hOwner; + extern int m_iClip1; + extern int m_iItemDefinitionIndex; +} +namespace DT_WeaponCSBase +{ + extern int m_flRecoilIndex; +} +namespace Data +{ +//extern std::uintptr_t m_uMoveHelper; +//extern std::uintptr_t m_uInput; +//extern std::uintptr_t m_uPredictionRandomSeed; +//extern std::uintptr_t m_uPredictionPlayer; +extern std::uintptr_t m_uModelBoneCounter; +extern DWORD32 m_nDeltaTick; +extern DWORD32 m_nChokedCommands; +extern DWORD32 m_nLastOutgoingCommand; +extern DWORD32 m_nLastCommandAck; +extern DWORD32 m_bIsHLTV; +} +namespace Function +{ +extern std::uintptr_t m_uRandomSeed; +extern std::uintptr_t m_uRandomFloat; +extern std::uintptr_t m_uRandomInt; +} + +} + +``` + +`drawing.cpp`: + +```cpp +#include "hooked.hpp" +#define STB_IMAGE_IMPLEMENTATION +#include "include/stb_image.h" + + +vgui::HFont F::Menu; +vgui::HFont F::MenuV2; +vgui::HFont F::MenuV2i; +vgui::HFont F::MenuV2n; +vgui::HFont F::ESPInfo; +vgui::HFont F::ESP; +vgui::HFont F::LBY; +vgui::HFont F::Events; +vgui::HFont F::Icons; +vgui::HFont F::MenuIcons; + +const char* Drawing::LastFontName; + +void Drawing::CreateFonts() +{ + + + LastFontName = ""; + + LastFontName = "Verdana"; //yes + csgo.m_surface()->SetFontGlyphSet(F::MenuV2 = csgo.m_surface()->CreateFont_(), sxor("Verdana"), 12, 500, NULL, NULL, FONTFLAG_DROPSHADOW | FONTFLAG_ANTIALIAS); // supremacy + csgo.m_surface()->SetFontGlyphSet(F::MenuV2i = csgo.m_surface()->CreateFont_(), sxor("Verdana"), 12, 700, NULL, NULL, FONTFLAG_DROPSHADOW | FONTFLAG_ANTIALIAS); // supremacy + LastFontName = "Segoe UI"; //yes + csgo.m_surface()->SetFontGlyphSet(F::Menu = csgo.m_surface()->CreateFont_(), sxor("Segoe UI"), 13, 400, NULL, NULL, FONTFLAG_DROPSHADOW | FONTFLAG_ANTIALIAS);//sxor("Visitor_Rus"), 12, 400, NULL, NULL, FONTFLAG_DROPSHADOW); + LastFontName = "Tahoma"; //yes + csgo.m_surface()->SetFontGlyphSet(F::ESP = csgo.m_surface()->CreateFont_(), sxor("Tahoma"), 12, 400, NULL, NULL, FONTFLAG_DROPSHADOW | FONTFLAG_ANTIALIAS); // supremacy esp + csgo.m_surface()->SetFontGlyphSet(F::MenuV2n = csgo.m_surface()->CreateFont_(), sxor("Tahoma"), 12, 500, NULL, NULL, 0); // supremacy + LastFontName = "Verdana"; //yes + csgo.m_surface()->SetFontGlyphSet(F::LBY = csgo.m_surface()->CreateFont_(), sxor("Verdana"), 26, 700, NULL, NULL, 144); + LastFontName = "Smallest Pixel-7"; //yes + csgo.m_surface()->SetFontGlyphSet(F::ESPInfo = csgo.m_surface()->CreateFont_(), sxor("Smallest Pixel-7"), 10, 100, NULL, NULL, FONTFLAG_OUTLINE); + LastFontName = "Lucida Console"; //yes + csgo.m_surface()->SetFontGlyphSet(F::Events = csgo.m_surface()->CreateFont_(), sxor("Lucida Console"), 10, NULL, NULL, NULL, FONTFLAG_DROPSHADOW); + LastFontName = "undefeated"; //yes + csgo.m_surface()->SetFontGlyphSet(F::Icons = csgo.m_surface()->CreateFont_(), sxor("undefeated"), 12, 500, NULL, NULL, FONTFLAG_ANTIALIAS | FONTFLAG_DROPSHADOW); + LastFontName = "SkeetFont"; //yes + csgo.m_surface()->SetFontGlyphSet(F::MenuIcons = csgo.m_surface()->CreateFont_(), sxor("SkeetFont"), 36, 500, NULL, NULL, FONTFLAG_ANTIALIAS | FONTFLAG_DROPSHADOW); + LastFontName = ""; + + + +} + +void Drawing::Texture(const int32_t x, const int32_t y, const int32_t w, const int32_t h, const int texture, const Color tint) +{ + csgo.m_surface()->DrawSetColor(tint.r(), tint.g(), tint.b(), tint.a()); + + csgo.m_surface()->DrawTexturedRect(x, y, x + w, y + h); +} + +void Drawing::LimitDrawingArea(int x, int y, int w, int h) { + typedef void(__thiscall * OriginalFn)(void*, int, int, int, int); + Memory::VCall(csgo.m_surface(), 147)(csgo.m_surface(), x, y, x + w + 1, y + h + 1); +} + +void Drawing::GetDrawingArea(int& x, int& y, int& w, int& h) { + typedef void(__thiscall * OriginalFn)(void*, int&, int&, int&, int&); + Memory::VCall(csgo.m_surface(), 146)(csgo.m_surface(), x, y, w, h); +} + +void Drawing::ColorPicker(Vector2D pos, int width, int height, float alpha) { + static auto gradient_texture = csgo.m_surface()->CreateNewTextureID(true); + static std::unique_ptr gradient = nullptr; + + if (!gradient) { + gradient = std::make_unique(width * height); + + // hue, saturation, lightness + auto h = 0.f, l = 1.f; + const auto s = 1; + + // loop through each pixel in the picker + for (auto x = 0; x < width; x++) { + l -= 1.f / float(width); // slowly change lightness from 1 - 0 + for (auto y = 0; y < height; y++) { + h += 1.f / float(height); // slowly change hue to 0 - 1 + + Color current = Color(0, 0, 0); // init + *reinterpret_cast(gradient.get() + x + y * width) = current.FromHSL(h, s, l); + } + + h = 0.f; // reset hue after each loop on the "y" axis + } + + csgo.m_surface()->DrawSetTextureRGBA(gradient_texture, reinterpret_cast(gradient.get()), width, height); + } + csgo.m_surface()->DrawSetColor(Color(255, 255, 255, alpha)); + csgo.m_surface()->DrawSetTexture(gradient_texture); + csgo.m_surface()->DrawTexturedRect(pos.x, pos.y, pos.x + width, pos.y + height); +} + +void Drawing::DrawString(vgui::HFont font, int x, int y, Color color, DWORD alignment, const char* msg, ...) +{ + va_list va_alist; + char buf[1024]; + va_start(va_alist, msg); + _vsnprintf_s(buf, sizeof(buf), msg, va_alist); + va_end(va_alist); + wchar_t wbuf[1024]; + MultiByteToWideChar(CP_UTF8, 0, buf, 256, wbuf, 256); + + int r = 255, g = 255, b = 255, a = 255; + color.GetColor(r, g, b, a); + + int width, height; + csgo.m_surface()->GetTextSize(font, wbuf, width, height); + + if (alignment & FONT_RIGHT) + x -= width; + if (alignment & FONT_CENTER) + x -= width / 2; + + csgo.m_surface()->DrawSetTextFont(font); + + if (width > 65536) + return; + + if (alignment & FONT_OUTLINE) + { + csgo.m_surface()->DrawSetTextColor(Color(0, 0, 0, color.a())); + csgo.m_surface()->DrawSetTextPos(x + 1, y /*+ 1*/); + csgo.m_surface()->DrawPrintText(wbuf, wcslen(wbuf)); + + csgo.m_surface()->DrawSetTextColor(Color(0, 0, 0, color.a())); + csgo.m_surface()->DrawSetTextPos(x - 1, y /*- 1*/); + csgo.m_surface()->DrawPrintText(wbuf, wcslen(wbuf)); + } + + csgo.m_surface()->DrawSetTextColor(r, g, b, a); + csgo.m_surface()->DrawSetTextPos(x, y /*- height / 2*/); + csgo.m_surface()->DrawPrintText(wbuf, wcslen(wbuf)); +} + +void Drawing::DrawStringFont(vgui::HFont font, int x, int y, Color clrColor, bool bCenter, const char* szText, ...) +{ + if (!szText) + return; + + va_list va_alist; + char buf[1024]; + va_start(va_alist, szText); + _vsnprintf_s(buf, sizeof(buf), szText, va_alist); + va_end(va_alist); + wchar_t wbuf[1024]; + MultiByteToWideChar(CP_UTF8, 0, buf, 256, wbuf, 256); + + if (bCenter) + { + int Wide = 0, Tall = 0; + + csgo.m_surface()->GetTextSize(font, wbuf, Wide, Tall); + + x -= Wide / 2; + } + + csgo.m_surface()->DrawSetTextFont(font); + csgo.m_surface()->DrawSetTextPos(x, y); + csgo.m_surface()->DrawSetTextColor(clrColor); + csgo.m_surface()->DrawPrintText(wbuf, wcslen(wbuf)); +} + +void Drawing::DrawStringUnicode(vgui::HFont font, int x, int y, Color color, bool bCenter, const wchar_t* msg, ...) +{ + int r = 255, g = 255, b = 255, a = 255; + color.GetColor(r, g, b, a); + + int iWidth, iHeight; + + csgo.m_surface()->GetTextSize(font, msg, iWidth, iHeight); + csgo.m_surface()->DrawSetTextFont(font); + csgo.m_surface()->DrawSetTextColor(r, g, b, a); + csgo.m_surface()->DrawSetTextPos(x, y); + csgo.m_surface()->DrawPrintText(msg, wcslen(msg)); +} + +void Drawing::DrawRect(int x, int y, int w, int h, Color col) +{ + csgo.m_surface()->DrawSetColor(col); + csgo.m_surface()->DrawFilledRect(x, y, x + w, y + h); +} + +void Drawing::DrawRectA(int x, int y, int w, int h, Color col) +{ + csgo.m_surface()->DrawSetColor(col); + csgo.m_surface()->DrawFilledRect(x, y, w, h); +} + +void Drawing::Rectangle(float x, float y, float w, float h, float px, Color col) +{ + DrawRect(x, (y + h - px), w, px, col); + DrawRect(x, y, px, h, col); + DrawRect(x, y, w, px, col); + DrawRect((x + w - px), y, px, h, col); +} + +void Drawing::Border(int x, int y, int w, int h, int line, Color col) +{ + DrawRect(x, y, w, line, col); + DrawRect(x, y, line, h, col); + DrawRect((x + w), y, line, h, col); + DrawRect(x, (y + h), (w + line), line, col); +} + +void Drawing::DrawRectRainbow(int x, int y, int width, int height, float flSpeed, float& flRainbow) +{ + Color colColor(0, 0, 0); + + flRainbow += flSpeed; + if (flRainbow > 1.f) flRainbow = 0.f; + + for (int i = 0; i < width; i++) + { + float hue = (1.f / (float)width) * i; + hue -= flRainbow; + if (hue < 0.f) hue += 1.f; + + Color colRainbow = colColor.FromHSB(hue, 1.f, 1.f); + Drawing::DrawRect(x + i, y, 1, height, colRainbow); + } +} + +void Drawing::DrawRectGradientVertical(int x, int y, int width, int height, Color color1, Color color2) +{ + float flDifferenceR = (float)(color2.r() - color1.r()) / (float)height; + float flDifferenceG = (float)(color2.g() - color1.g()) / (float)height; + float flDifferenceB = (float)(color2.b() - color1.b()) / (float)height; + float flDifferenceA = (float)(color2.a() - color1.a()) / (float)height; + + for (float i = 0.f; i < height; i++) + { + Color colGradient = Color(color1.r() + (flDifferenceR * i), color1.g() + (flDifferenceG * i), color1.b() + (flDifferenceB * i), color1.a() + (flDifferenceA * i)); + Drawing::DrawRect(x, y + i, width, 1, colGradient); + } +} + +void Drawing::DrawRectGradientVerticalA(int x, int y, int width, int height, Color color1, Color color2) +{ + auto draw_filled_rect = [&](bool reversed) { + csgo.m_surface()->DrawFilledRectFade(x, y, width, height, + reversed ? color1.a() : 0, reversed ? 0 : color2.a(), false); + }; + + csgo.m_surface()->DrawSetColor(color1); + draw_filled_rect(true); + + csgo.m_surface()->DrawSetColor(color2); + draw_filled_rect(false); +} + +void Drawing::DrawRectGradientHorizontal(int x, int y, int width, int height, Color color1, Color color2) +{ + float flDifferenceR = (float)(color2.r() - color1.r()) / (float)width; + float flDifferenceG = (float)(color2.g() - color1.g()) / (float)width; + float flDifferenceB = (float)(color2.b() - color1.b()) / (float)width; + float flDifferenceA = (float)(color2.a() - color1.a()) / (float)width; + + for (float i = 0.f; i < width; i++) + { + Color colGradient = Color(color1.r() + (flDifferenceR * i), color1.g() + (flDifferenceG * i), color1.b() + (flDifferenceB * i), color1.a() + (flDifferenceA * i)); + Drawing::DrawRect(x + i, y, 1, height, colGradient); + } +} + +void Drawing::DrawPixel(int x, int y, Color col) +{ + csgo.m_surface()->DrawSetColor(col); + csgo.m_surface()->DrawFilledRect(x, y, x + 1, y + 1); +} + +void Drawing::DrawOutlinedRect(int x, int y, int w, int h, Color col) +{ + csgo.m_surface()->DrawSetColor(col); + csgo.m_surface()->DrawOutlinedRect(x, y, x + w, y + h); +} + +void Drawing::DrawOutlinedRectA(int x, int y, int w, int h, Color col) +{ + csgo.m_surface()->DrawSetColor(col); + csgo.m_surface()->DrawOutlinedRect(x, y, w, h); +} + +void Drawing::DrawOutlinedCircle(int x, int y, int r, Color col) +{ + csgo.m_surface()->DrawSetColor(col); + csgo.m_surface()->DrawOutlinedCircle(x, y, r, 1); +} + +void Drawing::DrawLine(int x0, int y0, int x1, int y1, Color col) +{ + csgo.m_surface()->DrawSetColor(col); + csgo.m_surface()->DrawLine(x0, y0, x1, y1); +} + +void Drawing::DrawCircularProgressBar(Vector2D pos, float radius, int thickness, int num_segments, float progress, Color color) { + Vector2D size{ radius * 2, radius * 2 }; + + int start = static_cast(abs(sin(static_cast(csgo.m_globals()->realtime * 1.8f)) * (num_segments - 5))); + const float a_min = M_PI * 2.0f * ((float)start) / (float)num_segments; + const float a_max = M_PI * 2.0f * ((float)num_segments - 3) / (float)num_segments; + const auto&& centre = pos + radius; + for (auto i = 0; i < num_segments; i++) { + const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min); + auto time = static_cast(csgo.m_globals()->realtime); + DrawLine(centre.x + cos(a + time * 8) * (radius - thickness), centre.y + sin(a + time * 8) * (radius - thickness), centre.x + cos(a + time * 8) * radius, + centre.y + sin(a + time * 8) * radius, color); + } + + //window->DrawList->PathStroke(GetColorU32(color), false, thickness); +} + +void Drawing::DrawCorner(int iX, int iY, int iWidth, int iHeight, bool bRight, bool bDown, Color colDraw) +{ + int iRealX = bRight ? iX - iWidth : iX; + int iRealY = bDown ? iY - iHeight : iY; + + if (bDown && bRight) + iWidth = iWidth + 1; + + Drawing::DrawRect(iRealX, iY, iWidth, 1, colDraw); + Drawing::DrawRect(iX, iRealY, 1, iHeight, colDraw); + + Drawing::DrawRect(iRealX, bDown ? iY + 1 : iY - 1, !bDown && bRight ? iWidth + 1 : iWidth, 1, Color(0, 0, 0, 255)); + Drawing::DrawRect(bRight ? iX + 1 : iX - 1, bDown ? iRealY : iRealY - 1, 1, bDown ? iHeight + 2 : iHeight + 1, Color(0, 0, 0, 255)); +} +// +//#define COL2DWORD(x) (D3DCOLOR_ARGB(x.alpha, x.red, x.green, x.blue)) +//void Drawing::Triangle(Vector2D pos1, Vector2D pos2, Vector2D pos3, Color color) const +//{ +// const auto dwColor = COL2DWORD(color); +// Vertex vert[4] = +// { +// { pos1.x, pos1.y, 0.0f, 1.0f, dwColor }, +// { pos2.x, pos2.y, 0.0f, 1.0f, dwColor }, +// { pos3.x, pos3.y, 0.0f, 1.0f, dwColor }, +// { pos1.x, pos1.y, 0.0f, 1.0f, dwColor } +// }; +// +// this->pDevice->SetTexture(0, nullptr); +// this->pDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, 3, &vert, sizeof(Vertex)); +//} +// +// +//void Drawing::TriangleFilled(Vector2D pos1, Vector2D pos2, Vector2D pos3, Color color) const +//{ +// const auto dwColor = COL2DWORD(color); +// Vertex vert[3] = +// { +// { pos1.x, pos1.y, 0.0f, 1.0f, dwColor }, +// { pos2.x, pos2.y, 0.0f, 1.0f, dwColor }, +// { pos3.x, pos3.y, 0.0f, 1.0f, dwColor } +// }; +// +// this->pDevice->SetTexture(0, nullptr); +// this->pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 1, &vert, sizeof(Vertex)); +//} + +void Drawing::Triangle(Vector ldcorner, Vector rucorner, Color col) +{ + DrawLine(ldcorner.x, ldcorner.y, (rucorner.x / 2) - 1, rucorner.y, col); // left shit + + DrawLine(rucorner.x, ldcorner.y, (rucorner.x / 2) - 1, rucorner.y, col); // right shit + + DrawLine(ldcorner.x, ldcorner.y, rucorner.x, ldcorner.y/*(ldcorner.x - rucorner.x), (ldcorner.y - rucorner.y)*/, col); // down shit +} + +void Drawing::DrawPolygon(int count, Vertex_t* Vertexs, Color color) +{ + static int Texture = csgo.m_surface()->CreateNewTextureID(true); + unsigned char buffer[4] = { 255, 255, 255, 255 }; + + csgo.m_surface()->DrawSetTextureRGBA(Texture, buffer, 1, 1); + csgo.m_surface()->DrawSetColor(color); + csgo.m_surface()->DrawSetTexture(Texture); + + csgo.m_surface()->DrawTexturedPolygon(count, Vertexs); +} + +void Drawing::DrawBox(int x, int y, int w, int h, Color color) +{ + // top + DrawRect(x, y, w, 1, color); + // right + DrawRect(x, y + 1, 1, h - 1, color); + // left + DrawRect(x + w - 1, y + 1, 1, h - 1, color); + // bottom + DrawRect(x, y + h - 1, w - 1, 1, color); +} + +void Drawing::DrawRoundedBox(int x, int y, int w, int h, int r, int v, Color col) +{ + std::vector p; + for (int _i = 0; _i < 3; _i++) + { + int _x = x + (_i < 2 && r || w - r); + int _y = y + (_i % 3 > 0 && r || h - r); + for (int i = 0; i < v; i++) + { + int a = RAD2DEG((i / v) * -90 - _i * 90); + p.emplace_back(Vector2D(_x + sin(a) * r, _y + cos(a) * r)); + } + } + + Drawing::DrawPolygon(4 * (v + 1), &p[0], col); + /* + function DrawRoundedBox(x, y, w, h, r, v, col) + local p = {}; + for _i = 0, 3 do + local _x = x + (_i < 2 && r || w - r) + local _y = y + (_i%3 > 0 && r || h - r) + for i = 0, v do + local a = math.rad((i / v) * - 90 - _i * 90) + table.insert(p, {x = _x + math.sin(a) * r, y = _y + math.cos(a) * r}) + end + end + + surface.SetDrawColor(col.r, col.g, col.b, 255) + draw.NoTexture() + surface.DrawPoly(p) + end + */ + + // Notes: amount of vertexes is 4(v + 1) where v is the number of vertices on each corner bit. + // I did it in lua cause I have no idea how the vertex_t struct works and i'm still aids at C++ +} + +bool Drawing::ScreenTransform(const Vector& point, Vector& screen) // tots not pasted +{ + float w; + const VMatrix& worldToScreen = csgo.m_engine()->WorldToScreenMatrix(); + + screen.x = worldToScreen[0][0] * point[0] + worldToScreen[0][1] * point[1] + worldToScreen[0][2] * point[2] + worldToScreen[0][3]; + screen.y = worldToScreen[1][0] * point[0] + worldToScreen[1][1] * point[1] + worldToScreen[1][2] * point[2] + worldToScreen[1][3]; + w = worldToScreen[3][0] * point[0] + worldToScreen[3][1] * point[1] + worldToScreen[3][2] * point[2] + worldToScreen[3][3]; + screen.z = 0.0f; + + bool behind = false; + + if (w < 0.001f) + { + behind = true; + screen.x *= 100000; + screen.y *= 100000; + } + else + { + behind = false; + float invw = 1.0f / w; + screen.x *= invw; + screen.y *= invw; + } + + return behind; +} + +bool Drawing::WorldToScreen(const Vector& origin, Vector& screen) +{ + if (!ScreenTransform(origin, screen)) + { + float x = ctx.screen_size.x / 2; + float y = ctx.screen_size.y / 2; + x += 0.5 * screen.x * ctx.screen_size.x + 0.5; + y -= 0.5 * screen.y * ctx.screen_size.y + 0.5; + screen.x = x; + screen.y = y; + return true; + } + + return false; +} + +RECT Drawing::GetViewport() +{ + RECT Viewport = { 0, 0, 0, 0 }; + Viewport.right = ctx.screen_size.x; Viewport.bottom = ctx.screen_size.y; + return Viewport; +} + +int Drawing::GetStringWidth(vgui::HFont font, const char* msg, ...) +{ + va_list va_alist; + char buf[1024]; + va_start(va_alist, msg); + _vsnprintf_s(buf, sizeof(buf), msg, va_alist); + va_end(va_alist); + wchar_t wbuf[1024]; + MultiByteToWideChar(CP_UTF8, 0, buf, 256, wbuf, 256); + + int iWidth, iHeight; + + csgo.m_surface()->GetTextSize(font, wbuf, iWidth, iHeight); + + return iWidth; +} + +RECT Drawing::GetTextSize(vgui::HFont font, const char* text) +{ + /*size_t origsize = strlen(text) + 1; + const size_t newsize = 500; + size_t convertedChars = 0; + wchar_t wcstring[newsize]; + mbstowcs_s(&convertedChars, wcstring, origsize, text, _TRUNCATE);*/ + + RECT rect; + + rect.left = rect.right = rect.bottom = rect.top = 0; + + wchar_t wbuf[1024]; + if (MultiByteToWideChar(CP_UTF8, 0, text, -1, wbuf, 256) > 0 && wcslen(wbuf) > 0) { + int x, y; + csgo.m_surface()->GetTextSize(font, wbuf, x, y); + rect.left = x; rect.bottom = y; + rect.right = x; rect.top = y; + } + + return rect; +} + +RECT Drawing::GetTextSize(vgui::HFont font, const wchar_t* text) +{ + RECT rect; + + rect.left = rect.right = rect.bottom = rect.top = 0; + + int x, y; + csgo.m_surface()->GetTextSize(font, text, x, y); + rect.left = x; rect.bottom = y; + rect.right = x; rect.top = y; + + return rect; +} + +void Drawing::Draw3DBox(Vector* boxVectors, Color color) +{ + Vector boxVectors0, boxVectors1, boxVectors2, boxVectors3, + boxVectors4, boxVectors5, boxVectors6, boxVectors7; + + + if (Drawing::WorldToScreen(boxVectors[0], boxVectors0) && + Drawing::WorldToScreen(boxVectors[1], boxVectors1) && + Drawing::WorldToScreen(boxVectors[2], boxVectors2) && + Drawing::WorldToScreen(boxVectors[3], boxVectors3) && + Drawing::WorldToScreen(boxVectors[4], boxVectors4) && + Drawing::WorldToScreen(boxVectors[5], boxVectors5) && + Drawing::WorldToScreen(boxVectors[6], boxVectors6) && + Drawing::WorldToScreen(boxVectors[7], boxVectors7)) + { + + /* + .+--5---+ + .8 4 6'| + +--7---+' 11 + 9 | 10 | + | ,+--|3--+ + |.0 | 2' + +--1---+' + */ + + Vector2D lines[12][2]; + //bottom of box + lines[0][0] = { boxVectors0.x, boxVectors0.y }; + lines[0][1] = { boxVectors1.x, boxVectors1.y }; + lines[1][0] = { boxVectors1.x, boxVectors1.y }; + lines[1][1] = { boxVectors2.x, boxVectors2.y }; + lines[2][0] = { boxVectors2.x, boxVectors2.y }; + lines[2][1] = { boxVectors3.x, boxVectors3.y }; + lines[3][0] = { boxVectors3.x, boxVectors3.y }; + lines[3][1] = { boxVectors0.x, boxVectors0.y }; + + lines[4][0] = { boxVectors0.x, boxVectors0.y }; + lines[4][1] = { boxVectors6.x, boxVectors6.y }; + + // top of box + lines[5][0] = { boxVectors6.x, boxVectors6.y }; + lines[5][1] = { boxVectors5.x, boxVectors5.y }; + lines[6][0] = { boxVectors5.x, boxVectors5.y }; + lines[6][1] = { boxVectors4.x, boxVectors4.y }; + lines[7][0] = { boxVectors4.x, boxVectors4.y }; + lines[7][1] = { boxVectors7.x, boxVectors7.y }; + lines[8][0] = { boxVectors7.x, boxVectors7.y }; + lines[8][1] = { boxVectors6.x, boxVectors6.y }; + + + lines[9][0] = { boxVectors5.x, boxVectors5.y }; + lines[9][1] = { boxVectors1.x, boxVectors1.y }; + + lines[10][0] = { boxVectors4.x, boxVectors4.y }; + lines[10][1] = { boxVectors2.x, boxVectors2.y }; + + lines[11][0] = { boxVectors7.x, boxVectors7.y }; + lines[11][1] = { boxVectors3.x, boxVectors3.y }; + + for (int i = 0; i < 12; i++) + { + Drawing::DrawLine(lines[i][0].x, lines[i][0].y, lines[i][1].x, lines[i][1].y, color); + } + } +} + +void Drawing::rotate_point(Vector2D& point, Vector2D origin, bool clockwise, float angle) { + Vector2D delta = point - origin; + Vector2D rotated; + + if (clockwise) { + rotated = Vector2D(delta.x * cosf(angle) - delta.y * sinf(angle), delta.x * sinf(angle) + delta.y * cosf(angle)); + } + else { + rotated = Vector2D(delta.x * sinf(angle) - delta.y * cosf(angle), delta.x * cosf(angle) + delta.y * sinf(angle)); + } + + point = rotated + origin; +} + +void Drawing::DrawFilledCircle(int x, int y, int radius, int segments, Color color) { + std::vector< Vertex_t > vertices; + + float step = M_PI * 2.0f / segments; + + for (float a = 0; a < (M_PI * 2.0f); a += step) + vertices.emplace_back(radius * cosf(a) + x, radius * sinf(a) + y); + + TexturedPolygon(vertices.size(), vertices, color); +} + +void Drawing::TexturedPolygon(int n, std::vector< Vertex_t > vertice, Color color) { + static int texture_id = csgo.m_surface()->CreateNewTextureID(true); // + static unsigned char buf[4] = { 255, 255, 255, 255 }; + csgo.m_surface()->DrawSetTextureRGBA(texture_id, buf, 1, 1); // + csgo.m_surface()->DrawSetColor(color); // + csgo.m_surface()->DrawSetTexture(texture_id); // + csgo.m_surface()->DrawTexturedPolygon(n, vertice.data()); // +} + +/* +std::vector< Vertex_t > vertices = + { + Vertex_t{ Vector2D(position.x - size.x, position.y + size.y), Vector2D() }, + Vertex_t{ Vector2D(position.x, position.y - size.y), Vector2D() }, + Vertex_t{ position + size, Vector2D() }, + Vertex_t{ Vector2D(position.x, position.y + size.y * 0.2f), Vector2D() } + }; +*/ + + +void Drawing::filled_tilted_triangle(Vector2D position, Vector2D size, Vector2D origin, bool clockwise, float angle, Color color, bool rotate, Color col2) { + std::vector< Vertex_t > vertices = + { + Vertex_t{ Vector2D(position.x - size.x, position.y + size.y), Vector2D() }, + Vertex_t{ Vector2D(position.x, position.y + size.y * 0.3f), Vector2D() }, + Vertex_t{ position + size, Vector2D() }, + }; + + std::vector< Vertex_t > vertices2 = + { + Vertex_t{ Vector2D(position.x - size.x, position.y + size.y), Vector2D() }, + Vertex_t{ Vector2D(position.x, position.y - size.y), Vector2D() }, + Vertex_t{ Vector2D(position.x, position.y + size.y * 0.3f), Vector2D() }, + }; + + if (rotate) { + for (unsigned int p = 0; p < vertices.size(); p++) { + rotate_point(vertices[p].m_Position, origin, clockwise, angle); + } + + for (unsigned int p = 0; p < vertices2.size(); p++) { + rotate_point(vertices2[p].m_Position, origin, clockwise, angle); + } + } + + //int x, y, w, h; + ///Drawing::GetDrawingArea(x, y, w, h); + //Drawing::LimitDrawingArea(position.y + size.y * 0.2f) + + TexturedPolygon(vertices.size(), vertices, color.malpha(1.f)); + + //TexturedPolygon(vertices.size(), vertices, color.malpha(0.3f)); + + //DrawLine(vertices[0].m_Position.x, vertices[0].m_Position.y, vertices2[1].m_Position.x, vertices2[1].m_Position.y, col2); + //DrawLine(vertices2[1].m_Position.x, vertices2[1].m_Position.y, vertices[2].m_Position.x, vertices[2].m_Position.y, col2); + //DrawLine(vertices[2].m_Position.x, vertices[2].m_Position.y, vertices[1].m_Position.x, vertices[1].m_Position.y, col2); + //DrawLine(vertices[1].m_Position.x, vertices[1].m_Position.y, vertices[0].m_Position.x, vertices[0].m_Position.y, col2); + + //DrawLine(vertices2[1].m_Position.x, vertices2[1].m_Position.y, vertices[1].m_Position.x, vertices[1].m_Position.y, col2); + + //DrawLine(vertices[2].m_Position.x, vertices[2].m_Position.y, vertices[0].m_Position.x, vertices[0].m_Position.y, col2); + + //DrawLine(vertices[0].m_Position.x, vertices[0].m_Position.y, vertices[2].m_Position.x, vertices[2].m_Position.y, col2); + + //vertices.clear(); +} + +void Drawing::DrawCircle(float x, float y, float r, float s, Color color) +{ + float Step = M_PI * 2.0f / s; + for (float a = 0; a < (M_PI * 2.0f); a += Step) + { + float x1 = r * cosf(a) + x; + float y1 = r * sinf(a) + y; + float x2 = r * cosf(a + Step) + x; + float y2 = r * sinf(a + Step) + y; + + DrawLine(x1, y1, x2, y2, color); + } +} +``` + +`entity.cpp`: + +```cpp +#include "entity.hpp" +#include "displacement.hpp" +#include "prop_manager.hpp" + +void IHandleEntity::SetRefEHandle( const CBaseHandle& handle ) +{ + using Fn = void ( __thiscall* )( void*, const CBaseHandle& ); + return Memory::VCall( this, Index::IHandleEntity::SetRefEHandle )( this, handle ); +} + +const CBaseHandle& IHandleEntity::GetRefEHandle() +{ + using Fn = const CBaseHandle& ( __thiscall* )( void* ); + return Memory::VCall( this, Index::IHandleEntity::GetRefEHandle )( this ); +} + +ICollideable* IClientUnknown::GetCollideable() +{ + static auto m_Collision = Engine::PropManager::Instance()->GetOffset("DT_BaseEntity", "m_Collision"); + + return (ICollideable*)(uintptr_t(this) + m_Collision); + //using Fn = ICollideable* ( __thiscall* )( void* ); + //return Memory::VCall( this, Index::IClientUnknown::GetCollideable )( this ); +} + +IClientNetworkable* IClientUnknown::GetClientNetworkable() +{ + //using Fn = IClientNetworkable* ( __thiscall* )( void* ); + //return Memory::VCall( this, Index::IClientUnknown::GetClientNetworkable )( this ); + return (IClientNetworkable*)(uintptr_t(this) + 0x8); +} + +IClientRenderable* IClientUnknown::GetClientRenderable() +{ + /*if (Source::m_pClientState->m_iDeltaTick == -1 || Source::m_pCvar->FindVar("mat_norendering")->GetInt()) + return nullptr;*/ + //using Fn = IClientRenderable* ( __thiscall* )( void* ); + //return Memory::VCall( this, Index::IClientUnknown::GetClientRenderable )( this ); + return (IClientRenderable*)(uintptr_t(this) + 0x4); +} + +IClientEntity* IClientUnknown::GetIClientEntity() +{ + using Fn = IClientEntity* ( __thiscall* )( void* ); + return Memory::VCall( this, Index::IClientUnknown::GetIClientEntity )( this ); +} + +C_BaseEntity* IClientUnknown::GetBaseEntity() +{ + using Fn = C_BaseEntity* ( __thiscall* )( void* ); + return Memory::VCall( this, Index::IClientUnknown::GetBaseEntity )( this ); +} + +Vector& ICollideable::OBBMins() +{ + using Fn = Vector& ( __thiscall* )( void* ); + return Memory::VCall( this, Index::ICollideable::OBBMins )( this ); +} + +Vector& ICollideable::OBBMaxs() +{ + using Fn = Vector& ( __thiscall* )( void* ); + return Memory::VCall( this, Index::ICollideable::OBBMaxs )( this ); +} + +solid_type ICollideable::GetSolidType() +{ + using Fn = solid_type(__thiscall*)(void*); + return Memory::VCall(this, Index::ICollideable::SolidType)(this); +} + +//ClientClass* IClientNetworkable::GetClientClass() +//{ +// using Fn = ClientClass* ( __thiscall* )( void* ); +// return Memory::VCall( this, Index::IClientNetworkable::GetClientClass )( this ); +//} + +bool IClientNetworkable::IsDormant() +{ + using Fn = bool ( __thiscall* )( void* ); + return Memory::VCall( this, Index::IClientNetworkable::IsDormant )( this ); +} + +int IClientNetworkable::entindex() +{ + using Fn = int(__thiscall*)(void*); + + if (this && *(void**)this != nullptr) + return Memory::VCall(this, Index::IClientNetworkable::entindex)(this); + else + return 0; +} + +Vector& IClientEntity::OBBMins() +{ + return GetCollideable()->OBBMins(); +} + +Vector& IClientEntity::OBBMaxs() +{ + return GetCollideable()->OBBMaxs(); +} + +ClientClass* IClientEntity::GetClientClass() +{ + return GetClientNetworkable()->GetClientClass(); +} + +bool IClientEntity::IsDormant() +{ + if (this == nullptr || *(void**)this == nullptr) + return true; + + //auto networkable = GetClientNetworkable(); + return *(bool*)(uintptr_t(this) + 0xED);//networkable->IsDormant(); +} + +int IClientEntity::entindex() +{ + //auto networkable = GetClientNetworkable(); + //return networkable->entindex(); + if (!this) + return 0; + + return *(int*)(uintptr_t(this) + 0x64); +} + +const model_t* IClientEntity::GetModel() +{ + //if (!GetClientRenderable()) + // return nullptr; + return GetClientRenderable()->GetModel(); +} + +void IClientEntity::GetWorldSpaceCenter(Vector& wSpaceCenter) { + void* cRender = (void*)(this + 0x4); + typedef void(__thiscall * fn)(void*, Vector&, Vector&); + Vector va, vb; + Memory::VCall(cRender, 17)(cRender, va, vb); // GetRenderBounds : 17 + wSpaceCenter.z += (va.z + vb.z) * 0.5f; +} + +bool IClientEntity::is_breakable() +{ + //if (!this) + // return false; + + static auto is_breakable_fn = reinterpret_cast(Engine::Displacement::Signatures[c_signatures::BREAKABLE]); + + //const auto result = is_breakable_fn(this); + + //if (!result && GetClientClass() != nullptr && + // (GetClientClass()->m_ClassID == class_ids::CBaseDoor || + // GetClientClass()->m_ClassID == class_ids::CBreakableSurface || + // (GetClientClass()->m_ClassID == class_ids::CBaseEntity && GetCollideable() != nullptr && GetCollideable()->GetSolidType() == solid_bsp/*solid_bsp*/))) + // return true; + + //return result; + + if (!this || !GetCollideable() || !GetClientClass()) + return false; + + auto client_class = GetClientClass(); + + if (this->entindex() > 0) { + if (client_class) + { + auto v3 = (int)client_class->m_pNetworkName; + if (*(DWORD*)v3 == 0x65724243) + { + if (*(DWORD*)(v3 + 7) == 0x53656C62) + return 1; + } + if (*(DWORD*)v3 == 0x73614243) + { + if (*(DWORD*)(v3 + 7) == 0x79746974) + return 1; + } + + return is_breakable_fn(this); + } + + return is_breakable_fn(this); + } + return 0; + + //auto m_take_damage = *(uintptr_t*)((uintptr_t)Engine::Displacement::Signatures[c_signatures::BREAKABLE] + 38); + //auto backup = *(uint8_t*)(uintptr_t(this) + m_take_damage); + + //// fix world desync between server and client ds + + //auto hash_name = hash_32_fnv1a_const(client_class->m_pNetworkName); + //if (hash_name == hash_32_fnv1a_const("CBreakableSurface")) + // * (uint8_t*)(uintptr_t(this) + m_take_damage) = 2; // DAMAGE_YES + //else if (hash_name == hash_32_fnv1a_const("CBaseDoor") || hash_name == hash_32_fnv1a_const(("CDynamicProp"))) + // * (uint8_t*)(uintptr_t(this) + m_take_damage) = 0; // DAMAGE_NO + + //using fn_t = bool(__thiscall*)(IClientEntity*); + //auto result = ((fn_t)Engine::Displacement::Signatures[c_signatures::BREAKABLE])(this); + //*(uint8_t*)(uintptr_t(this) + m_take_damage) = backup; + + //return result; +} + +bool IClientEntity::SetupBones( matrix3x4a_t* pBoneToWorld, int nMaxBones, int boneMask, float currentTime ) +{ + auto renderable = GetClientRenderable(); + return renderable->SetupBones( pBoneToWorld, nMaxBones, boneMask, currentTime ); +} + +bool C_BaseEntity::IsPlayer() +{ + using Fn = bool ( __thiscall* )( void* ); + return Memory::VCall( this, Index::C_BaseEntity::IsPlayer )( this ); +} + +unsigned char& C_BaseEntity::m_MoveType() +{ + return *(unsigned char* )(uintptr_t(this) + Engine::Displacement::C_BaseEntity::m_MoveType ); +} + +unsigned char& C_BaseEntity::m_MoveCollide() +{ + return *(unsigned char* )(uintptr_t(this) + Engine::Displacement::C_BaseEntity::m_MoveType + 1 ); +} + +matrix3x4_t& C_BaseEntity::m_rgflCoordinateFrame() +{ + return *( matrix3x4_t* )(uintptr_t(this) + Engine::Displacement::C_BaseEntity::m_rgflCoordinateFrame ); +} + +int& C_BaseEntity::m_iTeamNum() +{ + return *( int* )(uintptr_t(this) + Engine::Displacement::DT_BaseEntity::m_iTeamNum ); +} + +Vector& C_BaseEntity::m_vecOrigin() +{ + return *( Vector* )(uintptr_t(this) + Engine::Displacement::DT_BaseEntity::m_vecOrigin ); +} + +void C_BaseEntity::SetPredictionRandomSeed( CUserCmd* cmd ) +{ + *( int* )(Engine::Displacement::Signatures[c_signatures::PREDRANDOMSEED]) = cmd ? cmd->random_seed : -1; +} + +void C_BaseEntity::SetPredictionPlayer( C_BasePlayer* player ) +{ + *( C_BasePlayer** )(Engine::Displacement::Signatures[c_signatures::PREDPLAYER]) = player; +} + +CBaseHandle& C_BaseCombatCharacter::m_hActiveWeapon() +{ + return *( CBaseHandle* )(uintptr_t(this) + Engine::Displacement::DT_BaseCombatCharacter::m_hActiveWeapon ); +} +``` + +`entity.hpp`: + +```hpp +#pragma once + +#include "sdk.hpp" + +#pragma region decl_indices +namespace Index +{ +namespace IHandleEntity +{ +enum +{ + SetRefEHandle = 1, + GetRefEHandle = 2, +}; +} +namespace IClientUnknown +{ +enum +{ + GetCollideable = 3, + GetClientNetworkable = 4, + GetClientRenderable = 5, + GetIClientEntity = 6, + GetBaseEntity = 7, +}; +} +namespace ICollideable +{ + enum + { + OBBMins = 1, + OBBMaxs = 2, + SolidType = 11, + }; +} +namespace IClientNetworkable +{ + enum + { + GetClientClass = 2, + IsDormant = 9, + entindex = 10, + GetDataTableBasePtr = 12, + }; +} +namespace IClientRenderable +{ +enum +{ + GetModel = 8, + SetupBones = 13, +}; +} +namespace C_BaseEntity +{ +enum +{ + IsPlayer = 157, +}; +} +} +#pragma endregion + +class IHandleEntity +{ +public: + void SetRefEHandle( const CBaseHandle& handle ); + const CBaseHandle& GetRefEHandle(); +}; + +class IClientUnknown : public IHandleEntity +{ +public: + ICollideable* GetCollideable(); + IClientNetworkable* GetClientNetworkable(); + IClientRenderable* GetClientRenderable(); + IClientEntity* GetIClientEntity(); + C_BaseEntity* GetBaseEntity(); +}; + +enum solid_type : int +{ + solid_none = 0, + solid_bsp = 1, + solid_bbox = 2, + solid_obb = 3, + solid_obb_yaw = 4, + solid_custom = 5, + solid_vphysics = 6, + solid_last +}; + +class ICollideable +{ +public: + Vector& OBBMins(); + Vector& OBBMaxs(); + solid_type GetSolidType(); +}; + +class IClientNetworkable +{ +public: + virtual IClientUnknown* GetIClientUnknown() = 0; + + // Called by the engine when the server deletes the entity. + virtual void Release() = 0; + + // Supplied automatically by the IMPLEMENT_CLIENTCLASS macros. + virtual ClientClass* GetClientClass() = 0; + + // This tells the entity what the server says for ShouldTransmit on this entity. + // Note: This used to be EntityEnteredPVS/EntityRemainedInPVS/EntityLeftPVS. + virtual void NotifyShouldTransmit(int state) = 0; + + + + // + // NOTE FOR ENTITY WRITERS: + // + // In 90% of the cases, you should hook OnPreDataChanged/OnDataChanged instead of + // PreDataUpdate/PostDataUpdate. + // + // The DataChanged events are only called once per frame whereas Pre/PostDataUpdate + // are called once per packet (and sometimes multiple times per frame). + // + // OnDataChanged is called during simulation where entity origins are correct and + // attachments can be used. whereas PostDataUpdate is called while parsing packets + // so attachments and other entity origins may not be valid yet. + // + + virtual void OnPreDataChanged(int updateType) = 0; + virtual void OnDataChanged(int updateType) = 0; + + // Called when data is being updated across the network. + // Only low-level entities should need to know about these. + virtual void PreDataUpdate(int updateType) = 0; + virtual void PostDataUpdate(int updateType) = 0; + + //ClientClass* GetClientClass(); + bool IsDormant(); + int entindex(); +}; + +typedef unsigned short ClientShadowHandle_t; +typedef unsigned short ClientRenderHandle_t; +typedef unsigned short ModelInstanceHandle_t; +typedef unsigned char uint8_t; + +class matrix3x4a_t; +class IClientUnknown; +struct model_t; + +class IClientRenderable +{ +public: + virtual IClientUnknown* GetIClientUnknown() = 0; + virtual Vector const& GetRenderOrigin(void) = 0; + virtual QAngle const& GetRenderAngles(void) = 0; + virtual bool ShouldDraw(void) = 0; + virtual int GetRenderFlags(void) = 0; // ERENDERFLAGS_xxx + virtual void Unused(void) const {} + virtual ClientShadowHandle_t GetShadowHandle() const = 0; + virtual ClientRenderHandle_t& RenderHandle() = 0; + virtual const model_t* GetModel() const = 0; + virtual int DrawModel(int flags, const int /*RenderableInstance_t*/& instance) = 0; + virtual int GetBody() = 0; + virtual void GetColorModulation(float* color) = 0; + virtual bool LODTest() = 0; + virtual bool SetupBones(matrix3x4a_t* pBoneToWorldOut, int nMaxBones, int boneMask, float currentTime) = 0; + virtual void SetupWeights(const matrix3x4a_t* pBoneToWorld, int nFlexWeightCount, float* pFlexWeights, float* pFlexDelayedWeights) = 0; + virtual void DoAnimationEvents(void) = 0; + virtual void* /*IPVSNotify*/ GetPVSNotifyInterface() = 0; + virtual void GetRenderBounds(Vector& mins, Vector& maxs) = 0; + virtual void GetRenderBoundsWorldspace(Vector& mins, Vector& maxs) = 0; + virtual void GetShadowRenderBounds(Vector& mins, Vector& maxs, int /*ShadowType_t*/ shadowType) = 0; + virtual bool ShouldReceiveProjectedTextures(int flags) = 0; + virtual bool GetShadowCastDistance(float* pDist, int /*ShadowType_t*/ shadowType) const = 0; + virtual bool GetShadowCastDirection(Vector* pDirection, int /*ShadowType_t*/ shadowType) const = 0; + virtual bool IsShadowDirty() = 0; + virtual void MarkShadowDirty(bool bDirty) = 0; + virtual IClientRenderable* GetShadowParent() = 0; + virtual IClientRenderable* FirstShadowChild() = 0; + virtual IClientRenderable* NextShadowPeer() = 0; + virtual int /*ShadowType_t*/ ShadowCastType() = 0; + virtual void CreateModelInstance() = 0; + virtual ModelInstanceHandle_t GetModelInstance() = 0; + virtual const matrix3x4_t& RenderableToWorldTransform() = 0; + virtual int LookupAttachment(const char* pAttachmentName) = 0; + virtual bool GetAttachment(int number, Vector& origin, QAngle& angles) = 0; + virtual bool GetAttachment(int number, matrix3x4_t& matrix) = 0; + virtual float* GetRenderClipPlane(void) = 0; + virtual int GetSkin() = 0; + virtual void OnThreadedDrawSetup() = 0; + virtual bool UsesFlexDelayedWeights() = 0; + virtual void RecordToolMessage() = 0; + virtual bool ShouldDrawForSplitScreenUser(int nSlot) = 0; + virtual uint8_t OverrideAlphaModulation(uint8_t nAlpha) = 0; + virtual uint8_t OverrideShadowAlphaModulation(uint8_t nAlpha) = 0; +}; + +class IClientEntity : public IClientUnknown +{ +public: + Vector& OBBMins(); + Vector& OBBMaxs(); + + ClientClass* GetClientClass(); + bool IsDormant(); + int entindex(); + + const model_t* GetModel(); + void GetWorldSpaceCenter(Vector& wSpaceCenter); + bool is_breakable(); + bool SetupBones( matrix3x4a_t* pBoneToWorld, int nMaxBones, int boneMask, float currentTime ); +}; + +class C_BaseEntity : public IClientEntity +{ +public: + bool IsPlayer(); + + unsigned char& m_MoveType(); + unsigned char& m_MoveCollide(); + matrix3x4_t& m_rgflCoordinateFrame(); + + int& m_iTeamNum(); + Vector& m_vecOrigin(); + +public: + static void SetPredictionRandomSeed( CUserCmd* cmd ); + static void SetPredictionPlayer( C_BasePlayer* player ); +}; + +class C_BaseCombatCharacter : public C_BaseEntity +{ +public: + CBaseHandle& m_hActiveWeapon(); +}; +``` + +`event_manager.cpp`: + +```cpp +#include "hooked.hpp" +#include "displacement.hpp" +#include "player.hpp" +#include "weapon.hpp" +#include "prediction.hpp" +#include "movement.hpp" +#include "rage_aimbot.hpp" +#include "anti_aimbot.hpp" +#include +#include "visuals.hpp" +#include +#include "resolver.hpp" +#include "lag_comp.hpp" +#include "menu.hpp" +#include "autowall.hpp" +#include "visuals.hpp" +#include "sdk.hpp" +#include "source.hpp" +#include "music_player.hpp" +#include "aimbot.hpp" + +game_events::PlayerHurtListener player_hurt_listener; +game_events::BulletImpactListener bullet_impact_listener; +game_events::PlayerDeathListener player_death_listener; +game_events::RoundEndListener round_end_listener; +game_events::RoundStartListener round_start_listener; +game_events::BombPlantListener bomb_plant_listener; +game_events::PurchaseListener item_purchase_listener; +game_events::WeaponFireListener weapon_fire_listener; + +game_events::BombStartPlantListener bomb_plant_start_listener; +game_events::BombStopPlantListener bomb_plant_end_listener; +game_events::BombStartDefuseListener bomb_defuse_start_listener; +game_events::BombStopDefuseListener bomb_defuse_end_listener; + +//ctx.m_settings.misc_notifications, { "bomb info", "damage", "misses", "shots debug", "purchases" }); + +void game_events::init() +{ + csgo.m_event_manager()->AddListener(&item_purchase_listener, sxor("item_purchase"), false); + csgo.m_event_manager()->AddListener(&player_hurt_listener, sxor("player_hurt"), false); + csgo.m_event_manager()->AddListener(&bullet_impact_listener, sxor("bullet_impact"), false); + csgo.m_event_manager()->AddListener(&weapon_fire_listener, sxor("weapon_fire"), false); + csgo.m_event_manager()->AddListener(&player_death_listener, sxor("player_death"), false); + csgo.m_event_manager()->AddListener(&round_end_listener, sxor("round_end"), false); + csgo.m_event_manager()->AddListener(&round_start_listener, sxor("round_start"), false); + csgo.m_event_manager()->AddListener(&bomb_plant_listener, sxor("bomb_planted"), false); + + csgo.m_event_manager()->AddListener(&bomb_plant_start_listener, sxor("bomb_beginplant"), false); + csgo.m_event_manager()->AddListener(&bomb_plant_end_listener, sxor("bomb_abortplant"), false); + csgo.m_event_manager()->AddListener(&bomb_defuse_start_listener, sxor("bomb_begindefuse"), false); + csgo.m_event_manager()->AddListener(&bomb_defuse_end_listener, sxor("bomb_abortdefuse"), false); +} + +void game_events::BombStartPlantListener::FireGameEvent(IGameEvent* game_event) +{ + if (!game_event || ctx.m_local() == nullptr) + return; + + const auto userid = csgo.m_engine()->GetPlayerForUserID(game_event->GetInt(sxor("userid"))); + + player_info info; + + if (ctx.m_settings.misc_notifications[0] && csgo.m_engine()->GetPlayerInfo(userid, &info)) + _events.emplace_back(std::string(sxor("bomb is being planted by ") + std::string{ info.name }.substr(0, 24))); +} + +void game_events::WeaponFireListener::FireGameEvent(IGameEvent* game_event) +{ + if (!game_event || ctx.m_local() == nullptr) + return; + + //const auto userid = csgo.m_engine()->GetPlayerForUserID(game_event->GetInt(sxor("userid"))); + feature::resolver->listener(game_event); +} + +void game_events::BombStartDefuseListener::FireGameEvent(IGameEvent* game_event) +{ + if (!game_event || ctx.m_local() == nullptr) + return; + + const auto userid = csgo.m_engine()->GetPlayerForUserID(game_event->GetInt(sxor("userid"))); + + const auto haskit = game_event->GetBool(sxor("haskit")); + + player_info info; + + if (ctx.m_settings.misc_notifications[0] && csgo.m_engine()->GetPlayerInfo(userid, &info)) + _events.emplace_back(std::string(sxor("bomb is being defused ") + std::string(haskit ? sxor(" (using kit) ") : "") + sxor(" by ") + std::string{ info.name }.substr(0, 24))); +} + +void game_events::BombStopPlantListener::FireGameEvent(IGameEvent* game_event) +{ + if (!game_event || ctx.m_local() == nullptr) + return; + + const auto userid = csgo.m_engine()->GetPlayerForUserID(game_event->GetInt(sxor("userid"))); + + player_info info; + + if (ctx.m_settings.misc_notifications[0] && csgo.m_engine()->GetPlayerInfo(userid, &info)) + _events.emplace_back(std::string(std::string{ info.name }.substr(0, 24) + sxor(" stopped planting the bomb"))); +} + +void game_events::BombStopDefuseListener::FireGameEvent(IGameEvent* game_event) +{ + if (!game_event || ctx.m_local() == nullptr) + return; + + const auto userid = csgo.m_engine()->GetPlayerForUserID(game_event->GetInt(sxor("userid"))); + + player_info info; + + if (ctx.m_settings.misc_notifications[0] && csgo.m_engine()->GetPlayerInfo(userid, &info)) + _events.emplace_back(std::string(std::string{ info.name }.substr(0, 24) + sxor(" stopped defusing the bomb"))); +} + +void game_events::BombPlantListener::FireGameEvent(IGameEvent* game_event) +{ + if (!game_event || ctx.m_local() == nullptr) + return; + + //const auto &entity = csgo.m_entity_list()->GetClientEntity(csgo.m_engine()->GetPlayerForUserID(game_event->GetInt(sxor("userid")))); + + //const int bombsite = game_event->GetInt(sxor("site")); + const auto userid = csgo.m_engine()->GetPlayerForUserID(game_event->GetInt(sxor("userid"))); + + player_info info; + + if (ctx.m_settings.misc_notifications[0] &&csgo.m_engine()->GetPlayerInfo(userid, &info)) + _events.emplace_back(std::string(sxor("bomb has been planted by ") + std::string{ info.name }.substr(0, 24))); +} + +std::string hitgroup_to_name(const int hitgroup) { + switch (hitgroup) + { + case HITGROUP_HEAD: + return sxor("head"); + case HITGROUP_CHEST: + return sxor("chest"); + case HITGROUP_STOMACH: + return sxor("stomach"); + case HITGROUP_LEFTARM: + return sxor("left arm"); + case HITGROUP_RIGHTARM: + return sxor("right arm"); + case HITGROUP_LEFTLEG: + return sxor("left leg"); + case HITGROUP_RIGHTLEG: + return sxor("right leg"); + default: + return sxor("body"); + } +} + +int hitgroup_to_idx(const int hitgroup) { + switch (hitgroup) + { + case HITGROUP_HEAD: + return 0; + case HITGROUP_CHEST: + return HITBOX_CHEST; + case HITGROUP_STOMACH: + return HITBOX_BODY; + case HITGROUP_LEFTARM: + return HITBOX_LEFT_HAND; + case HITGROUP_RIGHTARM: + return HITBOX_RIGHT_HAND; + case HITGROUP_LEFTLEG: + return HITBOX_LEFT_FOOT; + case HITGROUP_RIGHTLEG: + return HITBOX_RIGHT_FOOT; + default: + return HITBOX_BODY; + } +} + +void game_events::PlayerHurtListener::FireGameEvent(IGameEvent* game_event) +{ + if (!game_event || ctx.m_local() == nullptr/* || !m_weapon() || !ctx.latest_weapon_data*/) + return; + + const auto& entity = csgo.m_entity_list()->GetClientEntity(csgo.m_engine()->GetPlayerForUserID(game_event->GetInt(sxor("userid")))); + + if (!entity || !entity->GetClientClass() || !entity->IsPlayer()) + return; + + auto entity_attacker = csgo.m_entity_list()->GetClientEntity(csgo.m_engine()->GetPlayerForUserID(game_event->GetInt(sxor("attacker")))); + + if (!entity_attacker || !entity_attacker->GetClientClass() || !entity_attacker->IsPlayer()) + return; + + if (entity->m_iTeamNum() == ctx.m_local()->m_iTeamNum() || entity_attacker != ctx.m_local()) { + if (entity == ctx.m_local()) + { + player_info attacker_info; + if (!csgo.m_engine()->GetPlayerInfo(entity_attacker->entindex(), &attacker_info)) + return; + + //hurt indicator + log + ctx.local_damage[entity->entindex() - 1] = { game_event->GetInt(sxor("dmg_health")), csgo.m_globals()->realtime }; + + if (ctx.m_settings.misc_notifications[5]) { + const auto name = std::string(attacker_info.name); + _events.emplace_back(std::string(sxor("Hurt by ") + name.substr(0, 24) + sxor(" in the ") + hitgroup_to_name(game_event->GetInt(sxor("hitgroup"))) + sxor(" for ") + std::to_string(game_event->GetInt(sxor("dmg_health"))) + sxor(" (") + std::to_string(game_event->GetInt(sxor("health"))) + sxor(" health remaining)"))); + } + } + + return; + } + + player_info player_info; + if (!csgo.m_engine()->GetPlayerInfo(entity->entindex(), &player_info)) + return; + + /*const auto& lag_data = &feature::resolver->player_records[entity->entindex() - 1]; + const auto& log = &feature::lagcomp->records[entity->entindex() - 1];*/ + + //bool no = true; + + //if (ctx.m_settings.misc_visuals_hitboxes[1] && entity->m_bone_count() > 0) + // feature::ragebot->visualize_hitboxes(entity, entity->m_CachedBoneData().Base(), ctx.m_settings.misc_visuals_hitboxes_color, ctx.m_settings.misc_visuals_hitboxes_time); + + //if (entity->m_bone_count() > 0) + // damage_indicators.emplace_back(ctx.m_eye_position, feature::ragebot->get_hitbox(entity, hitgroup_to_idx(game_event->GetInt(sxor("hitgroup"))), entity->m_CachedBoneData().Base()), game_event->GetInt(sxor("dmg_health")), game_event->GetInt(sxor("hitgroup")) == HITGROUP_HEAD); + + feature::resolver->hurt_listener(game_event); + + //if (ctx.fired_shot.size() > 0 && !ctx.fired_shot[max(int(ctx.fired_shot.size()) - 1, 0)]._hurt_called && m_weapon()->IsGun()) { + + // for (auto it = ctx.fired_shot.begin(); it != ctx.fired_shot.end(); it++) + // { + // const auto& record = &*it; + + // if (record->_target != entity || record->_target == nullptr || record->_target->IsDormant()) + // continue; + + // if (abs(record->_avg_hurt_tick - csgo.m_globals()->tickcount) <= 1) + // { + // record->_hurt_called = true; + // record->_final_damage = game_event->GetInt(sxor("dmg_health")); + // record->_final_hitgroup = game_event->GetInt(sxor("hitgroup")); + // record->_headshot = game_event->GetBool(sxor("headshot")); + + // if (record->_hitgroup == record->_final_hitgroup) + // { + // if (abs(record->_predicted_damage - record->_final_damage) < 15.f)// { + // lag_data->has_been_resolved = true; + + // if (game_event->GetBool(sxor("headshot")) && record->_tickrecord) + // lag_data->last_hurt_resolved = record->_tickrecord->resolver_index; + // //} + + // if (ctx.shots_fired[entity->entindex() - 1] > 0) + // ctx.shots_fired[entity->entindex() - 1] -= 1; + // } + // else + // { + // //if (record._spread < 0.0015f && record._hitchance > 100.f) + // //if (ctx.shots_fired[entity->entindex() - 1] > 0) + // // ctx.shots_fired[entity->entindex() - 1] -= 1; + // } + + // //if (abs(record._final_damage - record._predicted_damage) > 10.f) + // //{ + // //_events.push_back(_event(std::string("server answer has difference [" + std::to_string(record._final_hitgroup) + "]:[" + std::to_string(record._hitgroup) + "]"))); + // //const auto hp_left = game_event->GetInt("health"); + + // //if (hp_left > 0 && record._spread < 0.0015f && record._hitchance == 100.f && record._final_hitgroup != record._hitgroup) + // //{ + // //if (ctx.shots_fired[entity->entindex() - 1] > 0) + // // ctx.shots_fired[entity->entindex() - 1] -= 1; + // //} + // /*else + // { + // if (ctx.shots_fired[entity->entindex() - 1] > 0) + // ctx.shots_fired[entity->entindex() - 1] -= 1; + // }*/ + // // } + + // no = false; + // //break; + // } + // } + //} + + if (game_event->GetBool(sxor("headshot"))) + damage_indicators.emplace_back(Vector::Zero, csgo.m_globals()->tickcount, game_event->GetInt(sxor("dmg_health")), true); + + if (ctx.m_settings.misc_notifications[1]) { + const auto name = std::string(player_info.name); + _events.emplace_back(std::string(sxor("Hit ") + name.substr(0, 24) + sxor(" in the ") + hitgroup_to_name(game_event->GetInt(sxor("hitgroup"))) + sxor(" for ") + std::to_string(game_event->GetInt(sxor("dmg_health"))) + sxor(" (") + std::to_string(game_event->GetInt(sxor("health"))) + sxor(" health remaining)"))); + } + if (ctx.m_settings.misc_hitsound_type) + { + if (ctx.m_settings.misc_hitsound_type == 1) + csgo.m_surface()->PlaySound_(sxor("buttons\\arena_switch_press_02.wav")); + else + csgo.m_surface()->PlaySound_(sxor("bell.wav")); + } + + ctx.hurt_time = csgo.m_globals()->realtime + 0.3f; +} + +float last_bullet_impact_back = 0; + +void game_events::BulletImpactListener::FireGameEvent(IGameEvent* game_event) +{ + if (!game_event || ctx.m_local() == nullptr || !ctx.latest_weapon_data || !m_weapon()) + return; + + if (!csgo.m_engine()->IsConnected()) + return; + + const auto& entity = csgo.m_entity_list()->GetClientEntity(csgo.m_engine()->GetPlayerForUserID(game_event->GetInt(sxor("userid")))); + + if (!entity) + return; + + if (entity->IsDormant()) + return; + + Vector position(game_event->GetInt(sxor("x")), game_event->GetInt(sxor("y")), game_event->GetInt(sxor("z"))); + + const auto islocal = entity == ctx.m_local(); + + if (!islocal) + return; + + if (ctx.m_settings.visuals_draw_local_beams) + bullet_tracers.emplace_back(ctx.m_eye_position, position, csgo.m_globals()->curtime, (ctx.m_settings.local_beams_color), true); + + if (ctx.m_settings.visuals_draw_local_impacts) + csgo.m_debug_overlay()->AddBoxOverlay(position, Vector(-2.f, -2.f, -2.f), Vector(2.f, 2.f, 2.f), Vector(0.f, 0.f, 0.f), 0, 0, 255, 127, 4.f); + + feature::resolver->listener(game_event); + //if (ctx.fired_shot.size() > 0 && !ctx.fired_shot[max(int(ctx.fired_shot.size()) - 1, 0)]._hurt_called) + //{ + // for (auto it = ctx.fired_shot.rbegin(); it != ctx.fired_shot.rend(); ++it) + // { + // auto& record = *it; + // + // //auto tick_count = csgo.m_globals()->tickcount; + // + // if (record._impact_called) { + // + // if (/*record._impacts_count <= record._walls_penetrated && */(last_bullet_impact_back - csgo.m_globals()->realtime) == 0.0f) + // { + // record._impact_pos = position; + // record._impacts.emplace_back(position); + // record._impacts_count++; + // //csgo.m_debug_overlay()->AddBoxOverlay(position, Vector(-2, -2, -2), Vector(2, 2, 2), Vector::Zero, 0, 255, 255, 255, 5.f); + // break; + // } + // + // continue; + // } + // + // //if (abs(record._avg_impact_time - tick_count) <= 1) + // //{ + // record._impact_called = true; + // record._impact_pos = position; + // record._impacts.emplace_back(position); + // record._avg_hurt_tick = csgo.m_globals()->tickcount + 1; + // record._impacts_count++; + // break; + // //} + // } + // + // last_bullet_impact_back = csgo.m_globals()->realtime; + //} +} + +void game_events::PlayerDeathListener::FireGameEvent(IGameEvent* game_event) +{ + if (!game_event || ctx.m_local() == nullptr) + return; + + const auto& entity = csgo.m_entity_list()->GetClientEntity(csgo.m_engine()->GetPlayerForUserID(game_event->GetInt(sxor("userid")))); + + /*if (!entity || entity->m_iTeamNum() == cheat::main::local()->m_iTeamNum()) + { + if (entity != nullptr && entity == cheat::main::local()) + { + for (auto i = 0; i < 64; i++) + { + cheat::main::shots_fired[i] = 0; + cheat::main::shots_total[i] = 0; + + auto resolve_info = &cheat::features::aaa.player_resolver_records[i]; + + cheat::features::lagcomp.records[i].reset(true); + + resolve_info->leftrec.reset(); + resolve_info->rightrec.reset(); + } + } + + return; + }*/ + //if (game_event->GetInt("attacker") < 0 || Source::m_pEngine->GetPlayerForUserID(game_event->GetInt("attacker")) < 0) + // return; + + if (!entity || !entity->GetClientClass() || entity->GetClientClass()->m_ClassID != class_ids::CCSPlayer) + return; + + feature::legitbot->kill_delay(game_event); + + if (entity == ctx.m_local()) + { + ctx.auto_peek_spot.clear(); + ctx.m_settings.anti_aim_autopeek_key.toggled = false; + ctx.m_settings.anti_aim_slowwalk_key.toggled = false; + ctx.shots_fired.fill(0); + if (ctx.m_settings.anti_aim_slowwalk_key.key > 0) + ctx.pressed_keys[ctx.m_settings.anti_aim_slowwalk_key.key] = false; + ctx.m_local()->m_bIsScoped() = false; + } + + const auto& attacker = csgo.m_entity_list()->GetClientEntity(csgo.m_engine()->GetPlayerForUserID(game_event->GetInt(sxor("attacker")))); + + if (attacker == ctx.m_local()/* && !ctx.m_local()->IsDead()*/) + { + if (ctx.m_settings.misc_f12_kill_sound) + feature::music_player->play(sxor("csgo\\sound\\voice_input.wav"), 0.6f); + //if (cheat::Cvars.Visuals_misc_killtimer.GetValue() > 0.f) + // cheat::main::local()->m_flHealthShotBoostExpirationTime() = Source::m_pGlobalVars->curtime + cheat::Cvars.Visuals_misc_killtimer.GetValue(); + + //player_info pinfo; + + //if (Source::m_pEngine->GetPlayerInfo(entity->entindex(), &pinfo)/* && !pinfo.fakeplayer*/) + //{ + // cheat::main::local()->get_weapon()->m_iItemIDHigh() = -1; + // cheat::settings.stattrak[cheat::main::local()->get_weapon()->m_iItemDefinitionIndex()]++; + // cheat::main::local()->get_weapon()->m_nFallbackStatTrak() = cheat::settings.stattrak[cheat::main::local()->get_weapon()->m_iItemDefinitionIndex()]; + // cheat::main::local()->get_weapon()->post_data_update(DATA_UPDATE_CREATED); + // cheat::main::local()->get_weapon()->on_data_changed(DATA_UPDATE_CREATED); + //} + + if (ctx.m_settings.skinchanger_enabled && m_weapon() && m_weapon()->is_knife()) + { + const auto weapon = game_event->GetString(sxor("weapon")); + + char weaponmy[23] = { 'k','n','i','f','e' }; + + strcpy(weaponmy, ctx.m_local()->m_iTeamNum() == 2 ? sxor("knife_t") : sxor("knife_default_ct")); + + if (strstr(weapon, sxor("knife_default_ct")) + || strstr(weapon, sxor("knife")) + || strstr(weapon, sxor("bayonet")) + || strstr(weapon, sxor("knife_push")) + || strstr(weapon, sxor("knife_butterfly")) + || strstr(weapon, sxor("knife_survival_bowie")) + || strstr(weapon, sxor("knife_falchion")) + || strstr(weapon, sxor("knife_tactical")) + || strstr(weapon, sxor("knife_m9_bayonet")) + || strstr(weapon, sxor("knife_karambit")) + || strstr(weapon, sxor("knife_gut")) + || strstr(weapon, sxor("knife_flip")) + || strstr(weapon, sxor("knife_ursus")) + || strstr(weapon, sxor("knife_widowmaker")) + || strstr(weapon, sxor("knife_stiletto")) + || strstr(weapon, sxor("knife_gypsy_jackknife"))) + { + switch (parser::knifes.list[ctx.m_settings.skinchanger_knife].id) + { + case WEAPON_BAYONET: + strcpy(weaponmy, sxor("bayonet")); + break; + case WEAPON_KNIFE_FLIP: + strcpy(weaponmy, sxor("knife_flip")); + break; + case WEAPON_KNIFE_GUT: + strcpy(weaponmy, sxor("knife_gut")); + break; + case WEAPON_KNIFE_KARAMBIT: + strcpy(weaponmy, sxor("knife_karambit")); + break; + case WEAPON_KNIFE_M9_BAYONET: + strcpy(weaponmy, sxor("knife_m9_bayonet")); + break; + case WEAPON_KNIFE_TACTICAL: + strcpy(weaponmy, sxor("knife_tactical")); + break; + case WEAPON_KNIFE_FALCHION: + strcpy(weaponmy, sxor("knife_falchion")); + break; + case WEAPON_KNIFE_SURVIVAL_BOWIE: + strcpy(weaponmy, sxor("knife_survival_bowie")); + break; + case WEAPON_KNIFE_BUTTERFLY: + strcpy(weaponmy, sxor("knife_butterfly")); + break; + case WEAPON_KNIFE_PUSH: + strcpy(weaponmy, sxor("knife_push")); + break; + case WEAPON_KNIFE_URSUS: + strcpy(weaponmy, sxor("knife_ursus")); + break; + case WEAPON_KNIFE_WIDOWMAKER: + strcpy(weaponmy, sxor("knife_widowmaker")); + break; + case WEAPON_KNIFE_STILETTO: + strcpy(weaponmy, sxor("knife_stiletto")); + break; + case WEAPON_KNIFE_GYPSY_JACKKNIFE: + strcpy(weaponmy, sxor("knife_gypsy_jackknife")); + break; + default: + strcpy(weaponmy, ctx.m_local()->m_iTeamNum() == 2 ? sxor("knife_t") : sxor("knife_default_ct")); + break; + } + + if (strcmp(weapon, weaponmy)) + game_event->SetString(sxor("weapon"), weaponmy); + } + } + } +} + + +void game_events::RoundEndListener::FireGameEvent(IGameEvent* game_event) +{ + if (!game_event || ctx.m_local() == nullptr) + return; + + ctx.m_corrections_data.clear(); + /*ctx.pressed_keys[(int)cheat::Cvars.RageBot_MinDmgKey.GetValue()] = false; + ctx.pressed_keys[(int)cheat::Cvars.RageBot_Key.GetValue()] = false; + ctx.pressed_keys[(int)cheat::Cvars.RageBot_BaimKey.GetValue()] = false; + ctx.pressed_keys[(int)cheat::Cvars.Exploits_fakeduck.GetValue()] = false; + ctx.pressed_keys[(int)cheat::Cvars.LegitBot_Key.GetValue()] = false; + ctx.pressed_keys[(int)cheat::Cvars.Misc_CircleStrafer.GetValue()] = false;*/ + + feature::lagcomp->reset(); + + /*if (!ctx.m_local()->IsDead()) { + + auto weapons = ctx.m_local()->m_hMyWeapons(); + + for (int i = 0; weapons[i] != 0xFFFFFFFF; i++) + { + if (weapons[i] == 0) continue; + + if (i > 10) + break; + + auto weapon = (C_WeaponCSBaseGun*)csgo.m_entity_list()->GetClientEntityFromHandle(weapons[i]); + + if (weapon == nullptr) continue; + + if (weapon->m_iItemDefinitionIndex() == WEAPON_SCAR20 || weapon->m_iItemDefinitionIndex() == WEAPON_G3SG1) + ctx.has_scar = true; + } + }*/ + + /*for (auto i = 0; i++; i < 64) { + cheat::features::dormant.m_cSoundPlayers[i].reset(); + }*/ + + /*auto winner = game_event->GetInt("winner"); + + auto local_player = INTERFACES::ClientEntityList->GetClientEntity(INTERFACES::Engine->GetLocalPlayer()); + + if (!local_player) return; + + if (winner == local_player->GetTeam()) + should_disable_aa = true;*/ +} + +void game_events::RoundStartListener::FireGameEvent(IGameEvent* game_event) +{ + if (!game_event || ctx.m_local() == nullptr) + return; + + if (ctx.m_settings.misc_autobuy_enabled) + ctx.buy_weapons = true; + + ctx.shots_fired.fill(0); + ctx.shots_total.fill(0); + + if (!bullet_tracers.empty()) + bullet_tracers.clear(); + + //ctx.fired_shot.clear(); + csgo.m_debug_overlay()->ClearAllOverlays(); + + //memset(feature::visuals->dormant_alpha, 0, sizeof(int) * 128); + feature::visuals->dormant_alpha.fill(0.f); + + ctx.original_tickbase = 0; + ctx.exploit_tickbase_shift = 0; + ctx.m_corrections_data.clear(); + + ctx.ticks_allowed = 0; + + ctx.auto_peek_spot.clear(); + ctx.m_settings.anti_aim_autopeek_key.toggled = false; + ctx.m_settings.anti_aim_slowwalk_key.toggled = false; + + //feature::lagcomp->reset(); + + /*const auto sv_skyname = csgo.m_engine_cvars()->FindVar("sv_skyname"); + + static const char* skyboxes[] = { + "cs_tibet", + "cs_baggage_skybox_", + "embassy", + "italy", + "jungle", + "office", + "sky_cs15_daylight01_hdr", + "vertigoblue_hdr", + "sky_cs15_daylight02_hdr", + "vertigo", + "sky_day02_05_hdr", + "nukeblank", + "sky_venice", + "sky_cs15_daylight03_hdr", + "sky_cs15_daylight04_hdr", + "sky_csgo_cloudy01", + "sky_csgo_night02", + "sky_csgo_night02b", + "sky_csgo_night_flat", + "sky_dust", + "vietnam", + "amethyst", + "sky_descent", + "clear_night_sky", + "otherworld", + "cloudynight", + "dreamyocean", + "grimmnight", + "sky051", + "sky081", + "sky091", + "sky561", + }; + + if (sv_skyname) { + if (sv_skyname->m_nFlags & FCVAR_CHEAT) + sv_skyname->m_nFlags &= ~FCVAR_CHEAT; + + if (cheat::Cvars.Visuals_world_sky.GetValue()) + sv_skyname->SetValue(skyboxes[(int)cheat::Cvars.Visuals_world_sky.GetValue() - 1]); + }*/ + + const auto shit = csgo.m_engine_cvars()->FindVar(sxor("mp_freezetime")); + + if (shit) + feature::anti_aim->enable_delay = csgo.m_globals()->realtime + shit->GetFloat(); +} + +void game_events::PurchaseListener::FireGameEvent(IGameEvent* game_event) +{ + if (!game_event || ctx.m_local() == nullptr) + return; + + //const auto &entity = csgo.m_entity_list()->GetClientEntity(csgo.m_engine()->GetPlayerForUserID(game_event->GetInt(sxor("userid")))); + + const auto weapon = game_event->GetString(sxor("weapon")); + + const int idx = csgo.m_engine()->GetPlayerForUserID(game_event->GetInt(sxor("userid"))); + const int team = game_event->GetInt(sxor("team")); + + player_info info; + + if (ctx.m_settings.misc_notifications[4] && csgo.m_engine()->GetPlayerInfo(idx, &info) && (!ctx.m_local() || team != ctx.m_local()->m_iTeamNum())) + _events.emplace_back(std::string(std::string{ info.name }.substr(0, 24) + sxor(" bought ") + weapon)); +} +``` + +`framestagenotify.cpp`: + +```cpp +#include "hooked.hpp" +#include "prediction.hpp" +#include "lag_comp.hpp" +#include "chams.hpp" +#include "weapon.hpp" +#include "anti_aimbot.hpp" +#include "displacement.hpp" +#include "bell.hpp" +#include "screenshot_sound.hpp" +#include "music_player.hpp" +#include "movement.hpp" +#include "autowall.hpp" +#include "resolver.hpp" +#include "sound_parser.hpp" +#include "weather_controller.hpp" +#include +#include "prop_manager.hpp" + +using CNETMsg_File_constructor_fn = void(__thiscall*)(void*); +using CNETMsg_File_destructor_fn = void(__thiscall*)(void*); +using CNETMsg_File_proto_fn = void(__thiscall*)(void*, void*); + +template +t follow_rel32(uintptr_t address, size_t offset) { + + if (!address) + return t{}; + + auto offsetAddr = address + offset; + auto relative = *(uint32_t*)offsetAddr; + if (!relative) + return t{}; + + return (t)(offsetAddr + relative + sizeof(uint32_t)); +} + +const char* models_to_change[] = { +("models/player/custom_player/legacy/tm_phoenix.mdl"), +("models/player/custom_player/legacy/ctm_sas.mdl"), +("models/player/custom_player/legacy/tm_balkan_variantj.mdl"), +("models/player/custom_player/legacy/tm_balkan_variantg.mdl"), +("models/player/custom_player/legacy/tm_balkan_varianti.mdl"), +("models/player/custom_player/legacy/tm_balkan_variantf.mdl"), +("models/player/custom_player/legacy/ctm_st6_varianti.mdl"), +("models/player/custom_player/legacy/ctm_st6_variantm.mdl"), +("models/player/custom_player/legacy/ctm_st6_variantg.mdl"), +("models/player/custom_player/legacy/ctm_st6_variante.mdl"), +("models/player/custom_player/legacy/ctm_st6_variantk.mdl"), +("models/player/custom_player/legacy/tm_balkan_varianth.mdl"), +("models/player/custom_player/legacy/ctm_fbi_varianth.mdl"), +("models/player/custom_player/legacy/ctm_fbi_variantg.mdl"), +("models/player/custom_player/legacy/ctm_fbi_variantf.mdl"), +("models/player/custom_player/legacy/tm_phoenix_variantg.mdl"), +("models/player/custom_player/legacy/tm_phoenix_variantf.mdl"), +("models/player/custom_player/legacy/tm_phoenix_varianth.mdl"), +("models/player/custom_player/legacy/tm_leet_variantf.mdl"), +("models/player/custom_player/legacy/tm_leet_varianti.mdl"), +("models/player/custom_player/legacy/tm_leet_varianth.mdl"), +("models/player/custom_player/legacy/tm_leet_variantg.mdl"), +("models/player/custom_player/legacy/ctm_fbi_variantb.mdl"), +("models/player/custom_player/legacy/ctm_sas_variantf.mdl"), +("models/player/custom_player/legacy/tm_anarchist.mdl"), +("models/player/custom_player/legacy/tm_anarchist_varianta.mdl"), +("models/player/custom_player/legacy/tm_anarchist_variantb.mdl"), +("models/player/custom_player/legacy/tm_anarchist_variantc.mdl"), +("models/player/custom_player/legacy/tm_anarchist_variantd.mdl"), +("models/player/custom_player/legacy/tm_pirate.mdl"), +("models/player/custom_player/legacy/tm_pirate_varianta.mdl"), +("models/player/custom_player/legacy/tm_pirate_variantb.mdl"), +("models/player/custom_player/legacy/tm_pirate_variantc.mdl"), +("models/player/custom_player/legacy/tm_pirate_variantd.mdl"), +("models/player/custom_player/legacy/tm_professional.mdl"), +("models/player/custom_player/legacy/tm_professional_var1.mdl"), +("models/player/custom_player/legacy/tm_professional_var2.mdl"), +("models/player/custom_player/legacy/tm_professional_var3.mdl"), +("models/player/custom_player/legacy/tm_professional_var4.mdl"), +("models/player/custom_player/legacy/tm_separatist.mdl"), +("models/player/custom_player/legacy/tm_separatist_varianta.mdl"), +("models/player/custom_player/legacy/tm_separatist_variantb.mdl"), +("models/player/custom_player/legacy/tm_separatist_variantc.mdl"), +("models/player/custom_player/legacy/tm_separatist_variantd.mdl"), +("models/player/custom_player/legacy/ctm_gign.mdl"), +("models/player/custom_player/legacy/ctm_gign_varianta.mdl"), +("models/player/custom_player/legacy/ctm_gign_variantb.mdl"), +("models/player/custom_player/legacy/ctm_gign_variantc.mdl"), +("models/player/custom_player/legacy/ctm_gign_variantd.mdl"), +("models/player/custom_player/legacy/ctm_gsg9.mdl"), +("models/player/custom_player/legacy/ctm_gsg9_varianta.mdl"), +("models/player/custom_player/legacy/ctm_gsg9_variantb.mdl"), +("models/player/custom_player/legacy/ctm_gsg9_variantc.mdl"), +("models/player/custom_player/legacy/ctm_gsg9_variantd.mdl"), +("models/player/custom_player/legacy/ctm_idf.mdl"), +("models/player/custom_player/legacy/ctm_idf_variantb.mdl"), +("models/player/custom_player/legacy/ctm_idf_variantc.mdl"), +("models/player/custom_player/legacy/ctm_idf_variantd.mdl"), +("models/player/custom_player/legacy/ctm_idf_variante.mdl"), +("models/player/custom_player/legacy/ctm_idf_variantf.mdl"), +("models/player/custom_player/legacy/ctm_swat.mdl"), +("models/player/custom_player/legacy/ctm_swat_varianta.mdl"), +("models/player/custom_player/legacy/ctm_swat_variantb.mdl"), +("models/player/custom_player/legacy/ctm_swat_variantc.mdl"), +("models/player/custom_player/legacy/ctm_swat_variantd.mdl"), +("models/player/custom_player/legacy/ctm_sas_varianta.mdl"), +("models/player/custom_player/legacy/ctm_sas_variantb.mdl"), +("models/player/custom_player/legacy/ctm_sas_variantc.mdl"), +("models/player/custom_player/legacy/ctm_sas_variantd.mdl"), +("models/player/custom_player/legacy/ctm_st6.mdl"), +("models/player/custom_player/legacy/ctm_st6_varianta.mdl"), +("models/player/custom_player/legacy/ctm_st6_variantb.mdl"), +("models/player/custom_player/legacy/ctm_st6_variantc.mdl"), +("models/player/custom_player/legacy/ctm_st6_variantd.mdl"), +("models/player/custom_player/legacy/tm_balkan_variante.mdl"), +("models/player/custom_player/legacy/tm_balkan_varianta.mdl"), +("models/player/custom_player/legacy/tm_balkan_variantb.mdl"), +("models/player/custom_player/legacy/tm_balkan_variantc.mdl"), +("models/player/custom_player/legacy/tm_balkan_variantd.mdl"), +("models/player/custom_player/legacy/tm_jumpsuit_varianta.mdl"), +("models/player/custom_player/legacy/tm_jumpsuit_variantb.mdl"), +("models/player/custom_player/legacy/tm_jumpsuit_variantc.mdl"), +("models/player/custom_player/legacy/tm_phoenix_heavy.mdl"), +("models/player/custom_player/legacy/ctm_heavy.mdl"), +("models/player/custom_player/legacy/tm_leet_varianta.mdl"), +("models/player/custom_player/legacy/tm_leet_variantb.mdl"), +("models/player/custom_player/legacy/tm_leet_variantc.mdl"), +("models/player/custom_player/legacy/tm_leet_variantd.mdl"), +("models/player/custom_player/legacy/tm_leet_variante.mdl"), +("models/player/custom_player/legacy/tm_phoenix.mdl"), +("models/player/custom_player/legacy/tm_phoenix_varianta.mdl"), +("models/player/custom_player/legacy/tm_phoenix_variantb.mdl"), +("models/player/custom_player/legacy/tm_phoenix_variantc.mdl"), +("models/player/custom_player/legacy/tm_phoenix_variantd.mdl"), +("models/player/custom_player/legacy/ctm_fbi.mdl"), +("models/player/custom_player/legacy/ctm_fbi_varianta.mdl"), +("models/player/custom_player/legacy/ctm_fbi_variantc.mdl"), +("models/player/custom_player/legacy/ctm_fbi_variantd.mdl"), +("models/player/custom_player/legacy/ctm_fbi_variante.mdl"), +("models/player/custom_player/legacy/ctm_sas.mdl") +}; + +IMaterial* smoke1 = nullptr; +IMaterial* smoke2 = nullptr; +IMaterial* smoke3 = nullptr; +IMaterial* smoke4 = nullptr; + +namespace Hooked +{ + struct clientanimating_t { + C_BaseAnimating* pAnimating; + unsigned int flags; + clientanimating_t(C_BaseAnimating* _pAnim, unsigned int _flags) : pAnimating(_pAnim), flags(_flags) { } + }; + + tl::optional get_knife_by_id(uint16_t id) + { + for (auto& knife : parser::knifes.list) { + if (knife.id == id) { + return knife; + } + } + + return tl::nullopt; + } + + auto get_skin_by_paint_kit = [](int wpn, int id) -> int + { + for (auto i = 0; i < parser::weapons.list[wpn].skins.list.size(); i++) { + auto& skin = parser::weapons.list[wpn].skins.list[i]; + + if (skin.id == id) { + return i; + } + } + + return 0; + }; + + void __fastcall FrameStageNotify(void* ecx, void* edx, ClientFrameStage_t stage) + { + auto clantag_changer = []() -> void + { + static float oldTime = -1.f; + + auto setclantag = [](const char* tag, const char* lol) -> void + { + typedef void(__fastcall* SetClanTagFn)(const char*, const char*); + static auto set_clan_tag = reinterpret_cast(Engine::Displacement::Signatures[c_signatures::SET_CLAN_TAG]); + + if (!Engine::Displacement::Signatures[c_signatures::INIT_KEY_VALUES]) + return; + + set_clan_tag(tag, lol); + }; + + /*auto Marquee = [](std::string& clantag) -> void + { + std::string temp = clantag; + clantag.erase(0, 1); + clantag += temp[0]; + };*/ + + static int v22 = 0; + const auto v15 = (1.0f / csgo.m_globals()->interval_per_tick); + /*static int tick = ctx.current_tickcount; + if (v16 && ctx.current_tickcount != tick) + { + v17 = v16->GetAvgLatency(0); + v14 = TIME_TO_TICKS(v17); + tick = ctx.current_tickcount; + }*/ + + const auto v21 = static_cast((csgo.m_globals()->tickcount + TIME_TO_TICKS(ctx.latency[FLOW_OUTGOING])) / (v15 / 2)) % 17; + + if (!ctx.m_settings.visuals_clantag) { + if (oldTime > -1.f) { + setclantag(sxor(""), sxor("enrage.gg")); + oldTime = -1.f; + } + + return; + } + + if (csgo.m_engine()->IsInGame() && csgo.m_client_state() && csgo.m_client_state()->m_iChockedCommands <= 0) { + + if (v21 != v22) + { + oldTime = csgo.m_globals()->realtime; + v22 = v21; + //Marquee(cur_clantag); + switch (v21) + { + case 0: setclantag(sxor(" e.gg "), sxor("D.z")); break; + case 1: setclantag(sxor(" en.gg "), sxor("d.l")); break; + case 2: setclantag(sxor(" enr.gg "), sxor("d.k")); break; + case 3: setclantag(sxor(" enra.gg "), sxor("a.j")); break; + case 4: setclantag(sxor(" enrag.gg "), sxor("d.h")); break; + case 10: setclantag(sxor(" enrage.gg "), sxor("s.g")); break; + case 11: setclantag(sxor(" nrage.gg "), sxor("f.f")); break; + case 12: setclantag(sxor(" rage.gg "), sxor("g.s")); break; + case 13: setclantag(sxor(" age.gg "), sxor("h.d")); break; + case 14: setclantag(sxor(" ge.gg "), sxor("j.z")); break; + case 15: setclantag(sxor(" e.gg "), sxor("k.a")); break; + case 16: setclantag(sxor(" "), sxor("h.f")); break; + default: break; + } + } + } + }; + + auto extend_fakelag_packets = []() -> void + { + static bool noob = false; + + if (noob) + return; + + if (!noob) { + static DWORD lol = Engine::Displacement::Signatures[c_signatures::COMMANDS_LIMIT] + 0xBC + 1; + DWORD old; + + VirtualProtect((LPVOID)lol, 1, PAGE_READWRITE, &old); + *(int*)lol = 62; + VirtualProtect((LPVOID)lol, 1, old, &old); + + noob = true; + } + }; + + auto translate_id = [](int wpn) -> int + { + for (auto i = 0; i < parser::weapons.list.size(); i++) { + auto& skin = parser::weapons.list[i]; + + if (skin.id == wpn) { + return i; + } + } + + return 0; + }; + + auto change_skins = [translate_id](int stage)->void + { + if (!ctx.m_settings.skinchanger_enabled) { + + if (ctx.m_local() && !ctx.m_local()->IsDead()) + ctx.original_model_index = ctx.m_local()->m_nModelIndex(); + else + ctx.original_model_index = -1; + + return; + } + if (!csgo.m_engine()->IsInGame() || parser::knifes.list.size() <= 1) + return; + if (!ctx.m_local()) + return; + if (ctx.m_local()->m_iHealth() <= 0) + return; + + if (ctx.m_settings.skins_player_model) { + const int iTeam = ctx.m_local()->m_iTeamNum(); + + if (iTeam == 2 && ctx.m_settings.skins_player_model_type_t > 0) { + const auto TeroristModelIndex = csgo.m_model_info()->GetModelIndex(models_to_change[max(0, ctx.m_settings.skins_player_model_type_t)]); + + if (TeroristModelIndex > 0) { + if (ctx.m_local()->m_nModelIndex() != TeroristModelIndex) + ctx.original_model_index = ctx.m_local()->m_nModelIndex(); + ctx.m_local()->set_model_index(TeroristModelIndex); + } + else + ctx.original_model_index = ctx.m_local()->m_nModelIndex(); + } + else if (iTeam == 3 && ctx.m_settings.skins_player_model_type_ct > 0) { + const auto CTeroristModelIndex = csgo.m_model_info()->GetModelIndex(models_to_change[max(0, ctx.m_settings.skins_player_model_type_ct)]); + + if (CTeroristModelIndex > 0) { + if (ctx.m_local()->m_nModelIndex() != CTeroristModelIndex) + ctx.original_model_index = ctx.m_local()->m_nModelIndex(); + ctx.m_local()->set_model_index(CTeroristModelIndex); + } + else + ctx.original_model_index = ctx.m_local()->m_nModelIndex(); + } + } + else + ctx.original_model_index = ctx.m_local()->m_nModelIndex(); + //ctx.updating_skins = false; + + player_info local_info; + if (!csgo.m_engine()->GetPlayerInfo(csgo.m_engine()->GetLocalPlayer(), &local_info)) + return; + + auto* const weapons = ctx.m_local()->m_hMyWeapons(); + if (!weapons) return; + + C_WeaponCSBaseGun* i_weapon = m_weapon(); + + if (!i_weapon) return; + + C_BasePlayer* viewmodel = csgo.m_entity_list()->GetClientEntityFromHandle( + reinterpret_cast(ctx.m_local()->m_hViewModel())); + if (!viewmodel) return; + + C_BasePlayer* worldmodel = csgo.m_entity_list()->GetClientEntityFromHandle(i_weapon->m_hWeaponWorldModel()); + if (!worldmodel) return; + + //apply_gloves(local_info.xuidlow); + + if (!parser::knifes.list.empty() && i_weapon->is_knife()) + { + const auto new_knife_id = parser::knifes.list[ctx.m_settings.skinchanger_knife].id; + + auto knife = get_knife_by_id(new_knife_id); + + if (knife.has_value()) + { + viewmodel->set_model_index(knife->model_player); + worldmodel->set_model_index(knife->model_world); + } + } + + bool lol = false; + + auto cknife = translate_id(parser::knifes.list[ctx.m_settings.skinchanger_knife].id); + + for (int i = 0; weapons[i] != 0xFFFFFFFF; i++) + { + if (!weapons[i]) + continue; + + auto weapon = reinterpret_cast(csgo.m_entity_list()->GetClientEntityFromHandle(weapons[i])); + + if (!weapon) + continue; + + //auto& m_iItemIDHigh = weapon->m_iItemIDHigh(); + //auto& m_iItemDefinitionIndex = weapon->m_iItemDefinitionIndex(); + auto& m_nFallbackPaintKit = weapon->m_nFallbackPaintKit(); + //auto& m_iEntityQuality = weapon->m_iEntityQuality(); + //auto& m_iAccountID = weapon->m_iAccountID(); + auto& m_OriginalOwnerXuidLow = weapon->m_OriginalOwnerXuidLow(); + auto& m_OriginalOwnerXuidHigh = weapon->m_OriginalOwnerXuidHigh(); + //auto& m_szCustomName = weapon->m_szCustomName(); + + weapon->m_iItemIDHigh() = -1; + + weapon->m_iAccountID() = local_info.xuidlow; + + if (local_info.xuidhigh != m_OriginalOwnerXuidHigh || + local_info.xuidlow != m_OriginalOwnerXuidLow) + continue; // not OUR weapon + + if (!parser::knifes.list.empty() && weapon->is_knife()) + { + const auto new_knife_id = parser::knifes.list[ctx.m_settings.skinchanger_knife].id; + + auto knife = get_knife_by_id(new_knife_id); + + if (knife.has_value()) + { + if (static_cast(weapon->m_iItemDefinitionIndex()) != static_cast(new_knife_id)) { + weapon->m_iItemDefinitionIndex() = static_cast(new_knife_id); + weapon->m_iEntityQuality() = 3; + } + + if (knife->model_player == -1 || knife->model_world == -1) { + knife->model_world = csgo.m_model_info()->GetModelIndex(knife->model_world_path.c_str()); + knife->model_player = csgo.m_model_info()->GetModelIndex(knife->model_player_path.c_str()); + } + + ctx.knife_model_index = knife->model_player; + weapon->set_model_index(knife->model_player); + weapon->m_iWorldModelIndex() = knife->model_player + 1; + } + } + else + continue; + + if (parser::weapons.list.size() <= 1 || parser::weapons.list[cknife].skins.list.size() <= 1) + break; + + if (ctx.m_settings.chams_misc[1] || ctx.m_settings.skinchanger_knife_skin < 0 || ctx.m_settings.skinchanger_knife_skin >= parser::weapons.list[cknife].skins.list.size()) + { + m_nFallbackPaintKit = 0; + continue; + } + + const auto skin = parser::weapons.list[cknife].skins.list[ctx.m_settings.skinchanger_knife_skin].id; + if (skin != m_nFallbackPaintKit) + { + m_nFallbackPaintKit = skin; + //m_nFallbackSeed = item.Seed; + //m_nFallbackStatTrak = item.StatTrak; + //if (item.StatTrak >= 0) m_iEntityQuality = 9; + //if (item.Name) strcpy(m_szCustomName, item.Name); + lol = true; + } + + + + //weapon->m_nFallbackStatTrak() = cheat::settings.stattrak[cheat::main::local()->get_weapon()->m_iItemDefinitionIndex()]; + } + + if (lol && ctx.update_hud_weapons) + { + //ctx.updating_skins = true; + + auto ClearHudWeaponIcon = reinterpret_cast(ctx.update_hud_weapons); + + if (ClearHudWeaponIcon) { + auto dw_hud_weapon_selection = feature::find_hud_element(sxor("CCSGO_HudWeaponSelection")); + if (dw_hud_weapon_selection) + { + auto hud_weapons = reinterpret_cast(dw_hud_weapon_selection - 0xA0); + if (hud_weapons && *hud_weapons) + { + auto hud_weapons_count = reinterpret_cast(std::uintptr_t(hud_weapons) + 0x80); + + if (hud_weapons_count) { + for (int i = 0; i < *hud_weapons_count; i++) + i = ClearHudWeaponIcon(hud_weapons, i); + } + //hud_weapons = 0; + } + } + } + } + }; + + using Fn = void(__thiscall*)(void*, ClientFrameStage_t); + + //if (stage != FRAME_START) + ctx.last_frame_stage = stage; + + extend_fakelag_packets(); + + const auto is_valid = csgo.m_engine()->IsInGame() && ctx.m_local() && !ctx.m_local()->IsDead(); + + if (is_valid) { + if (stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START) + change_skins(stage); + } + else + ctx.latest_weapon_data = nullptr; + + static bool once = false; + + if (!once && ctx.init_finished) + { + //#ifdef AUTH + // erase_fn(Source::Create); + //#endif // AUTH + + if (parser::knifes.list.size() > 1) { + for (auto i = 0; i < parser::knifes.list.size(); i++) + { + auto skins = parser::knifes.list[i]; + std::string p = std::string(skins.translated_name.begin(), skins.translated_name.end()); + ctx.knifes.push_back(p); + } + + + //if (GetAsyncKeyState(VK_SHIFT)) { + // ctx.boost_fps = true; + //} + + auto cknife = translate_id(parser::knifes.list[ctx.m_settings.skinchanger_knife].id); + ctx.skins.clear(); + for (auto i = 0; i < parser::weapons.list[cknife].skins.list.size(); i++) + { + auto skins = parser::weapons.list[cknife].skins.list.data()[i]; + std::string p = std::string(skins.translated_name.begin(), skins.translated_name.end()); + ctx.skins.push_back(p); + } + } + + std::ofstream bell_stream(sxor("csgo\\sound\\bell.wav"), std::ios::binary); + + for (int i = 0; i < 42276; i++) + { + bell_stream << bell[i]; + } + + bell_stream.close(); + + std::ofstream voice_input_stream(sxor("csgo\\sound\\voice_input.wav"), std::ios::binary); + + for (int i = 0; i < 29526; i++) + { + voice_input_stream << screenshot[i]; + } + + voice_input_stream.close(); + + /*CRC32_t crc; + + CRC32_Init(&crc); + CRC32_ProcessBuffer(&crc, &screenshot, sizeof(unsigned char) * 29526); + CRC32_Final(&crc);*/ + + once = true; + } + + bool was_in_tp = false; + //bool filled = false; + + if (stage == FRAME_RENDER_START && is_valid) { + was_in_tp = csgo.m_input()->is_in_tp(); + + if (was_in_tp) { + ctx.m_local()->UpdateVisibilityAllEntities(); + } + + if (ctx.m_settings.visuals_bloom_enabled) { + static auto m_bUseCustomAutoExposureMin = Engine::PropManager::Instance().GetOffset(sxor("DT_EnvTonemapController"), sxor("m_bUseCustomAutoExposureMin")); + static auto m_bUseCustomAutoExposureMax = Engine::PropManager::Instance().GetOffset(sxor("DT_EnvTonemapController"), sxor("m_bUseCustomAutoExposureMax")); + static auto m_bUseCustomBloomScale = Engine::PropManager::Instance().GetOffset(sxor("DT_EnvTonemapController"), sxor("m_bUseCustomBloomScale")); + + static auto m_flCustomAutoExposureMin = Engine::PropManager::Instance().GetOffset(sxor("DT_EnvTonemapController"), sxor("m_flCustomAutoExposureMin")); + static auto m_flCustomAutoExposureMax = Engine::PropManager::Instance().GetOffset(sxor("DT_EnvTonemapController"), sxor("m_flCustomAutoExposureMax")); + + static auto m_flCustomBloomScale = Engine::PropManager::Instance().GetOffset(sxor("DT_EnvTonemapController"), sxor("m_flCustomBloomScale")); + + for (auto i = 64; i < csgo.m_entity_list()->GetHighestEntityIndex(); i++) { + auto entity = csgo.m_entity_list()->GetClientEntity(i); + if (!entity) + continue; + + auto client_class = entity->GetClientClass(); + + if (strcmp(client_class->m_pNetworkName, "CEnvTonemapController")) { + continue; + } + + *(bool*)(uintptr_t(entity) + m_bUseCustomAutoExposureMin) = true; + *(bool*)(uintptr_t(entity) + m_bUseCustomAutoExposureMax) = true; + *(bool*)(uintptr_t(entity) + m_bUseCustomBloomScale) = true; + + *(float*)(uintptr_t(entity) + m_flCustomAutoExposureMin) = ctx.m_settings.visuals_bloom_exposure / 10.0f; + *(float*)(uintptr_t(entity) + m_flCustomAutoExposureMax) = ctx.m_settings.visuals_bloom_exposure / 10.0f; + *(float*)(uintptr_t(entity) + m_flCustomBloomScale) = ctx.m_settings.visuals_bloom_scale / 10.0f; + + } + } + + if (ctx.is_charging) + csgo.m_globals()->interpolation_amount = 0.f; + + if (csgo.m_engine()->IsInGame()) + feature::lagcomp->interpolate(stage); + + csgo.m_input()->m_fCameraInThirdPerson = false; + + ctx.in_tp = ctx.get_key_press(ctx.m_settings.visuals_tp_key); + + ctx.active_keybinds[3].mode = 0; + + if (ctx.in_tp && ctx.m_settings.visuals_tp_key.mode != 3) + ctx.active_keybinds[3].mode = ctx.m_settings.visuals_tp_key.mode; + } + + if (csgo.m_engine()->IsInGame()) { + if (csgo.m_client_state()->m_iDeltaTick > 0 && stage == FRAME_RENDER_START) + clantag_changer(); + } + + if (stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START) + { + if (ctx.m_local() != nullptr) + { + if (ctx.m_settings.visuals_no_flash) + ctx.m_local()->m_flFlashDuration() = 0; + } + //weather.find_precipitation(); + //if (GetAsyncKeyState(VK_RETURN)) + //{ + // g_WeatherController.StopAllWeather(); + // for (int i = 0; i <= Interfaces::ClientEntList->GetHighestEntityIndex(); ++i) + // { + // CBaseEntity* bleh = Interfaces::ClientEntList->GetBaseEntity(i); + // if (bleh && bleh->GetClientClass() && bleh->GetClientClass()->m_ClassID == ClassID::_CPrecipitation) + // { + // int modelindex = bleh->GetModelIndex(); + // bleh->GetClientNetworkable()->Release(); + // } + // } + //} + //else + //{ + // int i = 1; + // if (!g_WeatherController.HasSpawnedWeatherOfType(CWeatherController::CClient_Precipitation::PRECIPITATION_TYPE_PARTICLESNOW)) + // { + // if (GetAsyncKeyState(VK_F1)) + // g_WeatherController.CreateWeather(CWeatherController::CClient_Precipitation::PRECIPITATION_TYPE_PARTICLESNOW); + // } + // if (!g_WeatherController.HasSpawnedWeatherOfType(CWeatherController::CClient_Precipitation::PRECIPITATION_TYPE_PARTICLERAIN)) + // { + // if (GetAsyncKeyState(VK_F2)) + // g_WeatherController.CreateWeather(CWeatherController::CClient_Precipitation::PRECIPITATION_TYPE_PARTICLERAIN); + // } + // g_WeatherController.UpdateAllWeather(); + //} + } + + + //static float networkedCycle = 0.0f; + //static float animationTime = 0.f; + + if (stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START && is_valid && csgo.m_input() && ctx.m_local()->m_hViewModel()) { + auto viewmodel = csgo.m_entity_list()->GetClientEntityFromHandle((CBaseHandle)ctx.m_local()->m_hViewModel()); + + // m_flAnimTime : 0x260 + if (viewmodel) { + // onetap.su + if (Engine::Prediction::Instance()->m_nSequence == ((C_BaseViewModel*)viewmodel)->m_nSequence() + && Engine::Prediction::Instance()->m_hWeapon == ((C_BaseViewModel*)viewmodel)->get_viewmodel_weapon() + && Engine::Prediction::Instance()->m_nAnimationParity == ((C_BaseViewModel*)viewmodel)->m_nAnimationParity()) { + viewmodel->m_flCycle() = Engine::Prediction::Instance()->networkedCycle; + ((C_BaseViewModel*)viewmodel)->m_flModelAnimTime() = Engine::Prediction::Instance()->animationTime; + ctx.update_cycle = CYCLE_NONE; + } + } + } + + + feature::resolver->approve_shots(stage); + + feature::resolver->update_missed_shots(stage); + + vmt.m_client->VCall(Index::IBaseClientDLL::FrameStageNotify)(ecx, stage); + + //ctx.setup_bones = false; + + if (csgo.m_engine()->IsInGame()) + feature::lagcomp->store_records(stage); + + if (ctx.current_tickcount % 2 == 0) { + if (csgo.m_engine()->IsInGame() && ctx.m_local()) { + + if (ctx.hud_death_notice == nullptr || ctx.update_hud_weapons == nullptr || csgo.m_player_resource() == nullptr || csgo.m_player_resource()->this_ptr == nullptr) + { + for (auto i = 0; i < parser::knifes.list.size(); i++) + { + auto knife = &parser::knifes.list[i]; + + knife->model_world = csgo.m_model_info()->GetModelIndex(knife->model_world_path.c_str()); + knife->model_player = csgo.m_model_info()->GetModelIndex(knife->model_player_path.c_str()); + } + + csgo.m_player_resource.set(C_PlayerResource::get()); + + if (csgo.m_game_rules() == nullptr) + csgo.m_game_rules.set((**reinterpret_cast(Engine::Displacement::Signatures[c_signatures::GAMERULES] + 0x1))); + if (ctx.hud_death_notice == nullptr) + ctx.hud_death_notice = feature::find_hud_element(sxor("CCSGO_HudDeathNotice")); + if (ctx.update_hud_weapons == nullptr) + ctx.update_hud_weapons = (void*)Engine::Displacement::Signatures[c_signatures::UPDATEHUDWEAPONS]; + } + } + else + { + if (csgo.m_game_rules() != nullptr) { + ctx.hud_death_notice = nullptr; + ctx.update_hud_weapons = nullptr; + ctx.fake_state.m_player = 0; + ctx.shots_fired.fill(0); + ctx.shots_total.fill(0); + //ctx.command_numbers.clear(); + vmt.m_net_channel.reset(); + vmt.m_clientstate.reset(); + csgo.m_game_rules.set(nullptr); + csgo.m_player_resource.set(nullptr); + } + } + + if (stage == FRAME_RENDER_START && is_valid && m_weapon() && ctx.latest_weapon_data) { + + //auto &weapon_info = ctx.latest_weapon_data; + + ctx.autowall_crosshair = -1; + + if ((int)ctx.latest_weapon_data > 0x1000 && m_weapon()->IsGun() && ctx.m_settings.visuals_autowall_crosshair) + { + Vector start = ctx.m_eye_position; + Vector direction; + auto ang = Engine::Movement::Instance()->m_qRealAngles; + csgo.m_engine()->GetViewAngles(ang); + Math::AngleVectors(ang, &direction); + + auto max_range = ctx.latest_weapon_data->range * 2; + auto dmg = (float)ctx.latest_weapon_data->damage; + + Vector end = start + (direction * max_range); + float currentDistance = 0; + + CGameTrace enterTrace; + + CTraceFilter filter; + filter.pSkip = ctx.m_local(); + + feature::autowall->TraceLine(start, end, MASK_SHOT | CONTENTS_GRATE, ctx.m_local(), &enterTrace); + + if (enterTrace.fraction == 1) + dmg = -1; + else + //calculate the damage based on the distance the bullet traveled. + currentDistance += enterTrace.fraction * max_range; + + //Let's make our damage drops off the further away the bullet is. + dmg *= pow(ctx.latest_weapon_data->range_modifier, currentDistance / 500); + + auto enterSurfaceData = csgo.m_phys_props()->GetSurfaceData(enterTrace.surface.surfaceProps); + float enterSurfPenetrationModifier = enterSurfaceData->game.penetrationmodifier; + + if (currentDistance > 3000 && ctx.latest_weapon_data->penetration > 0 || enterSurfPenetrationModifier <= 0) + dmg = -1; + + if (enterTrace.m_pEnt != nullptr) + { + //This looks gay as fuck if we put it into 1 long line of code. + bool canDoDamage = (enterTrace.hitgroup - 1) <= 7; + bool isPlayer = (enterTrace.m_pEnt->GetClientClass() && enterTrace.m_pEnt->GetClientClass()->m_ClassID == class_ids::CCSPlayer); + //bool isEnemy = (ctx.m_local()->m_iTeamNum() != ((C_BasePlayer*)enterTrace.m_pEnt)->m_iTeamNum()); + bool onTeam = (((C_BasePlayer*)enterTrace.m_pEnt)->m_iTeamNum() == 2 || ((C_BasePlayer*)enterTrace.m_pEnt)->m_iTeamNum() == 3); + + //TODO: Team check config + if (canDoDamage && isPlayer && onTeam) + feature::autowall->ScaleDamage(enterTrace, ctx.latest_weapon_data, dmg); + + if (!canDoDamage && isPlayer) + dmg = -1; + } + + auto penetrate_count = 4; + + ctx.force_low_quality_autowalling = true; + + if (!feature::autowall->HandleBulletPenetration(ctx.m_local(), ctx.latest_weapon_data, enterTrace, start, direction, penetrate_count, dmg, ctx.latest_weapon_data->penetration, 0.f, true)) + dmg = -1; + + ctx.force_low_quality_autowalling = false; + + if (penetrate_count <= 0) + dmg = -1; + + ctx.autowall_crosshair = (dmg > ctx.m_settings.aimbot_min_damage) ? 2 : (dmg > 0 ? 1 : 0); + } + } + } + + /*if (is_valid) + { + auto viewmodel = csgo.m_entity_list()->GetClientEntityFromHandle((CBaseHandle)ctx.m_local()->m_hViewModel()); + + if (viewmodel) + { + cycle = viewmodel->m_flCycle(); + anim_time = viewmodel->m_flAnimTime(); + } + }*/ + + //if (stage == FRAME_RENDER_START && is_valid) { + // + // if (ctx.m_settings.visuals_no_recoil && filled && !was_in_tp) { + // ctx.m_local()->m_aimPunchAngle() = aim; + // ctx.m_local()->m_viewPunchAngle() = view; + // } + // //Engine::Prediction::Instance()->DoInterpolateVars(); + //} + + if (is_valid && ctx.current_tickcount % 2 == 0) { + static float local_spawntime = ctx.m_local()->m_flSpawnTime(); + + if (local_spawntime != ctx.m_local()->m_flSpawnTime()) + { + if (ctx.m_settings.misc_preserve_killfeed) { + + ctx.hud_death_notice = feature::find_hud_element(sxor("CCSGO_HudDeathNotice")); + ctx.update_hud_weapons = reinterpret_cast(Engine::Displacement::Signatures[c_signatures::UPDATEHUDWEAPONS]); + + if (ctx.hud_death_notice) { + int* death_notices = reinterpret_cast(reinterpret_cast(ctx.hud_death_notice) - + 20); + + if (death_notices) { + auto ClearDeathNotices = reinterpret_cast(Engine::Displacement::Signatures[c_signatures::CLEARDEATHNOTICES]); + + if (ClearDeathNotices) + ClearDeathNotices(reinterpret_cast(ctx.hud_death_notice) - 20); + } + } + } + + local_spawntime = ctx.m_local()->m_flSpawnTime(); + } + } + + if (stage == FRAME_NET_UPDATE_POSTDATAUPDATE_END) { + if (!smoke1) + smoke1 = csgo.m_material_system()->FindMaterial(sxor("particle/vistasmokev1/vistasmokev1_fire"), sxor("Other textures")); + + if (!smoke2) + smoke2 = csgo.m_material_system()->FindMaterial(sxor("particle/vistasmokev1/vistasmokev1_smokegrenade"), sxor("Other textures")); + + if (!smoke3) + smoke3 = csgo.m_material_system()->FindMaterial(sxor("particle/vistasmokev1/vistasmokev1_emods"), sxor("Other textures")); + + if (!smoke4) + smoke4 = csgo.m_material_system()->FindMaterial(sxor("particle/vistasmokev1/vistasmokev1_emods_impactdust"), sxor("Other textures")); + + if (ctx.m_settings.visuals_no_smoke) { + if (!smoke1->GetMaterialVarFlag(MATERIAL_VAR_NO_DRAW)) + smoke1->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW, true); + + if (!smoke2->GetMaterialVarFlag(MATERIAL_VAR_NO_DRAW)) + smoke2->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW, true); + + if (!smoke3->GetMaterialVarFlag(MATERIAL_VAR_NO_DRAW)) + smoke3->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW, true); + + if (!smoke4->GetMaterialVarFlag(MATERIAL_VAR_NO_DRAW)) + smoke4->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW, true); + } + + else { + if (smoke1->GetMaterialVarFlag(MATERIAL_VAR_NO_DRAW)) + smoke1->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW, false); + + if (smoke2->GetMaterialVarFlag(MATERIAL_VAR_NO_DRAW)) + smoke2->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW, false); + + if (smoke3->GetMaterialVarFlag(MATERIAL_VAR_NO_DRAW)) + smoke3->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW, false); + + if (smoke4->GetMaterialVarFlag(MATERIAL_VAR_NO_DRAW)) + smoke4->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW, false); + } + } + + //if (stage == FRAME_RENDER_START && is_valid && csgo.m_input()->m_fCameraInThirdPerson) + // ctx.m_local()->DrawServerHitboxes(); + + //auto& prediction = Engine::Prediction::Instance(); + //prediction->OnFrameStageNotify(stage); + } + +} +``` + +`fully updated fake.txt`: + +```txt + if (is_local && ctx.m_local() && !ctx.m_local()->IsDead() && ctx.m_local()->get_animation_state()) + { + //if (csgo.m_client_state()) + + C_AnimationLayer backuplayers[14]; + memcpy(backuplayers, ctx.m_local()->animation_layers_ptr(), 0x38 * ctx.m_local()->get_animation_layers_count()); + + const auto dword_3CF22C70 = csgo.m_globals()->realtime; + const auto dword_3CF22C74 = csgo.m_globals()->curtime; + const auto dword_3CF22C78 = csgo.m_globals()->frametime; + const auto dword_3CF22C7C = csgo.m_globals()->absoluteframetime; + const auto dword_3CF22C80 = csgo.m_globals()->interpolation_amount; + const auto dword_3CF22C84 = csgo.m_globals()->framecount; + const auto dword_3CF22C88 = csgo.m_globals()->tickcount; + + csgo.m_globals()->realtime = TICKS_TO_TIME(feature::anti_aim.sent_data.tickbase); + csgo.m_globals()->curtime = TICKS_TO_TIME(feature::anti_aim.sent_data.tickbase); + csgo.m_globals()->frametime = csgo.m_globals()->interval_per_tick; + csgo.m_globals()->absoluteframetime = csgo.m_globals()->interval_per_tick; + csgo.m_globals()->framecount = feature::anti_aim.sent_data.tickbase; + csgo.m_globals()->tickcount = feature::anti_aim.sent_data.tickbase; + csgo.m_globals()->interpolation_amount = 0.0f; + + const auto backup_poses = ctx.m_local()->m_flPoseParameter(); + const auto backup_flags = ctx.m_local()->m_fFlags(); + const auto backup_duckamt = ctx.m_local()->m_flDuckAmount(); + const auto backup_lby = ctx.m_local()->m_flLowerBodyYawTarget(); + const auto backup_renderang = ctx.m_local()->get_render_angles(); + const auto backup_absvel = ctx.m_local()->m_vecAbsVelocity(); + + auto fake_angle = feature::anti_aim.visual_real_angle; + + if (feature::anti_aim.yaw_diff_with_backwards < FLT_MAX) + { + auto angles = QAngle(0, 0, 0); + csgo.m_engine()->GetViewAngles(angles); + + fake_angle.y = Math::normalize_angle(Math::normalize_angle(angles.y - 180.f) + feature::anti_aim.yaw_diff_with_backwards); + } + + auto state = *ctx.m_local()->get_animation_state(); + *ctx.m_local()->get_animation_state() = ctx.fake_state; + + //ctx.m_local()->get_animation_state()->feet_rate = 0.f; + /*if (!prev_poses.empty()) { + ctx.m_local()->get_animation_state()->feet_cycle = animlayers[6].m_flCycle; + + if (ctx.m_local()->m_fFlags() & FL_ONGROUND) + ctx.m_local()->get_animation_state()->feet_rate = animlayers[6].m_flWeight; + }*/ + + //ctx.m_local()->m_flPoseParameter() = ctx.poses[ANGLE_FAKE]; + + ctx.m_local()->get_animation_state()->feet_rate = 0.f; + //ctx.m_local()->get_animation_state()->unk_frac = 0.f; + + //ctx.m_local()->get_animation_state()->stop_to_full_run_frac = feature::anti_aim.stop_to_full_running_fraction; + + if (ctx.m_local()->get_animation_state()->last_anim_upd_tick >= csgo.m_globals()->framecount) + ctx.m_local()->get_animation_state()->last_anim_upd_tick = csgo.m_globals()->framecount - 1; + + //if (feature::anti_aim.last_chocked_amount <= 2) + //ctx.m_local()->get_animation_state()->last_anim_upd_time = csgo.m_globals()->curtime - (ctx.m_local()->m_flSimulationTime() - ctx.m_local()->m_flOldSimulationTime()); + + ctx.m_local()->m_flPoseParameter() = ctx.poses[ANGLE_FAKE]; + + /*memcpy(ctx.m_local()->animation_layers_ptr(), ctx.local_layers[ANGLE_REAL], 0x38 * ctx.m_local()->get_animation_layers_count());*/ + ctx.m_local()->get_animation_state()->ent = (void*)ctx.m_local(); + ctx.m_local()->get_animation_state()->stop_to_full_run_frac = feature::anti_aim.stop_to_full_running_fraction; + ctx.is_updating_fake = true; + ctx.m_local()->m_fFlags() = feature::anti_aim.sent_data.m_fFlags; + ctx.m_local()->m_vecAbsVelocity() = (feature::anti_aim.animation_speed > 6.f ? feature::anti_aim.sent_data.m_vecVelocity : Vector::Zero); + ctx.m_local()->update_animstate(ctx.m_local()->get_animation_state(), fake_angle); + //ctx.m_local()->invalidate_anims(); + ctx.is_updating_fake = false; + ctx.m_local()->m_vecAbsVelocity() = backup_absvel; + memcpy(ctx.local_layers[ANGLE_FAKE], ctx.m_local()->animation_layers_ptr(), 0x38 * ctx.m_local()->get_animation_layers_count()); + ctx.m_local()->m_fFlags() = backup_flags; + + ctx.angles[ANGLE_FAKE] = ctx.m_local()->get_animation_state()->abs_yaw; + ctx.poses[ANGLE_FAKE] = ctx.m_local()->m_flPoseParameter(); + + if (!ctx.m_settings.fake_lag_enabled && !ctx.m_settings.anti_aim_enabled) + { + ctx.angles[ANGLE_REAL] = ctx.m_local()->get_animation_state()->abs_yaw; + ctx.poses[ANGLE_REAL] = ctx.m_local()->m_flPoseParameter(); + memcpy(ctx.local_layers[ANGLE_REAL], ctx.m_local()->animation_layers_ptr(), 0x38 * ctx.m_local()->get_animation_layers_count()); + } + + ctx.fake_state = *ctx.m_local()->get_animation_state(); + + ctx.local_layers[ANGLE_FAKE][12].m_flWeight = 0.f; + ctx.local_layers[ANGLE_FAKE][3].m_flWeight = 0.f; + ctx.local_layers[ANGLE_FAKE][3].m_flCycle = 0.f; + + ctx.m_local()->m_flPoseParameter() = backup_poses; + memcpy(ctx.m_local()->animation_layers_ptr(), backuplayers, 0x38 * ctx.m_local()->get_animation_layers_count()); + ctx.m_local()->m_fFlags() = backup_flags; + ctx.m_local()->m_flDuckAmount() = backup_duckamt; + ctx.m_local()->m_flLowerBodyYawTarget() = backup_lby; + ctx.m_local()->get_render_angles() = backup_renderang; + *ctx.m_local()->get_animation_state() = state; + ctx.m_local()->m_vecAbsVelocity() = backup_absvel; + + csgo.m_globals()->realtime = dword_3CF22C70; + csgo.m_globals()->curtime = dword_3CF22C74; + csgo.m_globals()->frametime = dword_3CF22C78; + csgo.m_globals()->absoluteframetime = dword_3CF22C7C; + csgo.m_globals()->interpolation_amount = dword_3CF22C80; + csgo.m_globals()->framecount = dword_3CF22C84; + csgo.m_globals()->tickcount = dword_3CF22C88; + + static Vector old_origins[2] = { ctx.m_local()->get_abs_origin(), ctx.m_local()->get_abs_origin() }; + + ctx.m_local()->m_flPoseParameter() = ctx.poses[ANGLE_FAKE]; + ctx.m_local()->force_bone_rebuild(); + ctx.m_local()->set_abs_angles(QAngle(0, ctx.angles[ANGLE_FAKE], 0)); + memcpy(ctx.m_local()->animation_layers_ptr(), ctx.local_layers[ANGLE_FAKE], 0x38 * ctx.m_local()->get_animation_layers_count()); + + ctx.m_local()->SetupBonesEx(); + memcpy(ctx.fake_matrix, ctx.m_local()->m_CachedBoneData().Base(), ctx.m_local()->GetBoneCount() * sizeof(matrix3x4_t)); + ctx.m_local()->m_flPoseParameter() = backup_poses; + feature::lagcomp.build_local_bones(ctx.m_local()); + memcpy(ctx.m_local()->animation_layers_ptr(), backuplayers, 0x38 * ctx.m_local()->get_animation_layers_count()); + // //C_AnimationLayer backup_layers[15]; + // + // const auto backup_poses = ecx->m_flPoseParameter(); + // //memcpy(backup_layers, ecx->animation_layers_ptr(), 0x38 * ecx->get_animation_layers_count()); + // + // ecx->m_flPoseParameter() = ctx.poses[ANGLE_FAKE]; + // ecx->force_bone_rebuild(); + // ecx->set_abs_angles(QAngle(0, ctx.angles[ANGLE_FAKE], 0)); + // ecx->SetupBonesEx(); + // + // memcpy(ctx.fake_matrix, ecx->m_CachedBoneData().Base(), ecx->GetBoneCount() * sizeof(matrix3x4_t)); + // //memcpy(ecx->animation_layers_ptr(), backup_layers, 0x38 * ecx->get_animation_layers_count()); + // + // ecx->m_flPoseParameter() = ctx.poses[ANGLE_REAL]; + // feature::lagcomp.build_local_bones(ecx); + // + // //memcpy(ecx->animation_layers_ptr(), backup_layers, 0x38 * ecx->get_animation_layers_count()); + // ecx->m_flPoseParameter() = backup_poses; + } +``` + +`grenades.cpp`: + +```cpp +#include "source.hpp" +#include "sdk.hpp" +#include "grenades.hpp" +#include "player.hpp" +#include "weapon.hpp" +#include "visuals.hpp" +#include "hooked.hpp" +#include "autowall.hpp" +#include "prediction.hpp" +#include "movement.hpp" + +std::vector BrokenEntities; + +static std::vector Breakables; + +void dispatch_effect(const char* name, const CEffectData& data) +{ + // 55 8B EC 83 E4 F8 83 EC 20 56 57 8B F9 C7 44 24 + static auto dispatch_effect_fn + = reinterpret_cast( + Memory::Scan("client.dll", "55 8B EC 83 E4 F8 83 EC 20 56 57 8B F9 C7 44 24") + ); + + dispatch_effect_fn(name, data); +} + +void c_grenade_tracer::clear_broken() +{ + BrokenEntities.clear(); +} + +void c_grenade_tracer::add_broken(const Breakable& Breakable, IClientUnknown* Entity) +{ + static auto FindEntityByModel = [](const char* Model) -> C_BaseEntity * + { + auto Hash = hash_32_fnv1a_const(Model); + for (auto i = csgo.m_globals()->maxClients + 1; i <= csgo.m_entity_list()->GetHighestEntityIndex(); i++) + { + auto Entity = csgo.m_entity_list()->GetClientEntity(i); + if (!Entity) + continue; + + auto CurrentModel = csgo.m_model_info()->GetModelName(Entity->GetModel()); + if (hash_32_fnv1a_const(CurrentModel) == Hash) + return Entity; + } + + return nullptr; + }; + + if (find(BrokenEntities.begin(), BrokenEntities.end(), Entity) != BrokenEntities.end()) + return; // Should ONLY fix infinite loops caused by "co-breaking" entities and not cause any bugs + + BrokenEntities.emplace_back(Entity); + + for (const auto& Broken : Breakable.Breakables) + { + if (auto BrokenEntity = FindEntityByModel(Broken->Model.c_str())) + add_broken(*Broken, BrokenEntity); + } +} + +void c_grenade_tracer::add_broken(IClientUnknown* Entity) +{ + BrokenEntities.emplace_back(Entity); +} + +bool c_grenade_tracer::is_broken(IClientUnknown* Entity) +{ + return find(BrokenEntities.begin(), BrokenEntities.end(), Entity) != BrokenEntities.end(); +} + +void c_grenade_tracer::reset() { + m_start.clear(); + m_move.clear(); + m_velocity.clear(); + m_vel = 0.f; + m_power = 0.f; + m_collision_group = COLLISION_GROUP_PROJECTILE; + m_collision_ent = nullptr; + + m_path.clear(); + m_bounces.clear(); +} + +void c_grenade_tracer::paint() { + //static CTraceFilterSimple_game filter{}; + CGameTrace trace; + std::pair< float, C_BasePlayer* > target{ 0.f, nullptr }; + std::vector> damages; + + if (!ctx.m_settings.misc_grenade_preview) + return; + + // we dont want to do this if dead. + if (!ctx.m_local() || ctx.m_local()->IsDead() || !m_weapon() || !m_weapon()->IsGrenade()) + return; + + // aww man... + // we need some points at least. + if (m_path.size() < 2) + return; + + // setup trace filter for later. + //filter.SetPassEntity(g_cl.m_local); + + uint32_t filter[4] = { feature::autowall->get_filter_simple_vtable(), uint32_t(ctx.m_local()), 0, 0 }; + + // previous point, set to last point. + // or actually.. the first point, we are drawing in reverse. + Vector prev = m_path.front(); + + // iterate and draw path. + for (const auto& cur : m_path) { + Vector screen0, screen1; + + if (Drawing::WorldToScreen(prev, screen0) && Drawing::WorldToScreen(cur, screen1)) + Drawing::DrawLine(screen0.x, screen0.y, screen1.x, screen1.y, { 255, 255, 255 }); + + // store point for next iteration. + prev = cur; + } + + // iterate all players. + for (int i{ 1 }; i <= csgo.m_globals()->maxClients; ++i) { + C_BasePlayer* player = (C_BasePlayer * )csgo.m_entity_list()->GetClientEntity(i); + if (!player || player->IsDormant() || player->IsDead()) + continue; + + // get center of mass for player. + Vector center = player->get_abs_origin(); + player->GetWorldSpaceCenter(center); + + // get delta between center of mass and final nade pos. + Vector delta = center - prev; + + if (m_id == WEAPON_HEGRENADE) { + // pGrenade->m_flDamage = 100; + // pGrenade->m_DmgRadius = pGrenade->m_flDamage * 3.5f; + + // is within damage radius? + if (delta.Length() > 350.f) + continue; + + Ray_t l; + l.Init(prev, center); + + // check if our path was obstructed by anything using a trace. + csgo.m_engine_trace()->TraceRay(l, MASK_SHOT, (ITraceFilter*)& filter, &trace); + + // something went wrong here. + if (!trace.m_pEnt || trace.m_pEnt != player) + continue; + + // rather 'interesting' formula by valve to compute damage. + float d = (delta.Length() - 25.f) / 140.f; + float damage = 105.f * std::exp(-d * d); + + // scale damage. + damage = feature::autowall->ScaleDamage(player, damage, 1.f, HITGROUP_CHEST); + + // clip max damage. + damage = min(damage, (player->m_ArmorValue() > 0) ? 57.f : 98.f); + + //if (player->m_iTeamNum() != ctx.m_local()->m_iTeamNum()) + damages.emplace_back(player, damage); + + // better target? + if (damage > target.first) { + target.first = damage; + target.second = player; + } + } + else if (m_id == WEAPON_MOLOTOV || m_id == WEAPON_INCGRENADE) + { + // pGrenade->m_flDamage = 100; + // pGrenade->m_DmgRadius = pGrenade->m_flDamage * 3.5f; + + // is within damage radius? + if (delta.Length() > 150.f) + continue; + + Ray_t l; + l.Init(prev, center); + + // check if our path was obstructed by anything using a trace. + csgo.m_engine_trace()->TraceRay(l, MASK_SHOT, (ITraceFilter*)& filter, &trace); + + // something went wrong here. + if (!trace.m_pEnt || trace.m_pEnt != player) + continue; + + //if (player->m_iTeamNum() != ctx.m_local()->m_iTeamNum()) + damages.emplace_back(player, float(delta.Length() * 0.0254f) + 1337.0f); + } + } + + // we have a target for damage. + //if (target.second) { + // Vector screen; + + // replace the last bounce with green. + //if (!m_bounces.empty()) + // m_bounces.back().color = { 0, 255, 0, 255 }; + + //if (Drawing::WorldToScreen(prev, screen)) + // Drawing::DrawString(F::ESPInfo,screen.x, screen.y + 5, Color{ 255, 255, 255, 0xb4 }, FONT_CENTER,sxor("%i"), (int)target.first); + //} + + //if (damages.size() > 0) + //{ + // // replace the last bounce with green. + // if (!m_bounces.empty()) + // m_bounces.back().color = { 0, 255, 0, 255 }; + + // for (auto idmg : damages) + // { + // if (!idmg.first || idmg.first->IsDormant() || !idmg.first->GetClientClass()) + // continue; + + // Vector screen; + + // if (Drawing::WorldToScreen(idmg.first->get_abs_origin(), screen)) { + + // auto& info = idmg.second; + + // if (info < 100.f) + // Drawing::DrawString(F::ESPInfo, screen.x, screen.y + 15, info >= idmg.first->m_iHealth() ? Color{ 255, 0, 0, 250 } : Color{ 225, 225, 225, 240 }, FONT_CENTER, sxor("-%i"), (int)idmg.second); + // else + // Drawing::DrawString(F::ESPInfo, screen.x, screen.y + 15, ctx.m_settings.menu_color.alpha(250), FONT_CENTER, sxor("%.1fm"), float(idmg.second - 1337.f)); + // } + // } + //} + + // render bounces. + for (auto &b : m_bounces) { + Vector screen; + + if (b.point == m_bounces.back().point) + break; + + if (Drawing::WorldToScreen(b.point, screen)) { + Drawing::DrawRect(screen.x - 2, screen.y - 2, 4, 4, b.color); + Drawing::DrawOutlinedRect(screen.x - 3, screen.y - 3, 6, 6, Color{58,58,58, 0xb4}); + } + } + + if (m_bounces.size() > 0) + { + + /*if (m_id == WEAPON_MOLOTOV || m_id == WEAPON_INCGRENADE) + { + CEffectData data; + data.hitBox = iEffectIndex; + data.origin = m_bounces.back().point; + data.otherEntIndex = 0; + data.damageType = 2; + + dispatch_effect("weapon_molotov_held", data); + } + else *///if (m_id == WEAPON_SMOKEGRENADE) + // last_smoke_endpos = m_bounces.back().point; + + const float step = (M_PI * 2.f) / 24.0f; + auto radius = 24.0f; + static bool lol = true; + static auto start = 0.f; + static auto max_a = ((M_PI * 2.f) - step); + static float prev_a = 0.f; + Vector w2sCenter; + if (Drawing::WorldToScreen(m_bounces.back().point, w2sCenter)) { + Drawing::DrawBox(w2sCenter.x, w2sCenter.y, 10.f, 10.f, Color::Red().alpha(240)); + } + } +} + +void c_grenade_tracer::think(CUserCmd* cmd) { + bool attack, attack2; + + // reset some data. + reset(); + + if (!ctx.m_settings.misc_grenade_preview) + return; + + if (!ctx.m_local() || ctx.m_local()->IsDead()) + return; + + // validate nade. + if (!m_weapon() || !m_weapon()->IsGrenade()) + return; + + attack = (cmd->buttons & IN_ATTACK); + attack2 = (cmd->buttons & IN_ATTACK2); + + if (!attack && !attack2) + return; + + m_id = m_weapon()->m_iItemDefinitionIndex(); + m_power = m_weapon()->m_flThrowStrength(); + m_vel = ctx.latest_weapon_data->throw_velocity; + + if (m_id != WEAPON_SMOKEGRENADE) + last_smoke_endpos.clear(); + + simulate(); +} + +void c_grenade_tracer::simulate() { + // init member variables + // that will be used during the simulation. + setup(); + + // log positions 20 times per second. + size_t step = (size_t)TIME_TO_TICKS(0.05f), timer{ 0u }; + + // iterate until the container is full, should never happen. + for (size_t i{ 0u }; i < 4096u; ++i) { + + // the timer was reset, insert new point. + if (!timer) + m_path.emplace_back(m_start); + + // advance object to this frame. + size_t flags = advance(i); + + // if we detonated, we are done. + // our path is complete. + if ((flags & DETONATE)) + break; + + // reset or bounced. + // add a new point when bounced, and one every step. + if ((flags & BOUNCE) || timer >= step) + timer = 0; + + // increment timer. + else + ++timer; + + if (m_velocity == Vector{}) + break; + } + + // fire grenades can extend to the ground. + // this happens if their endpoint is within range of the floor. + // 131 units to be exact. + if (m_id == WEAPON_MOLOTOV || m_id == WEAPON_FIREBOMB) { + CGameTrace trace; + PhysicsPushEntity(m_start, { 0.f, 0.f, -131.f }, trace, ctx.m_local()); + + if (trace.fraction < 0.9f) + m_start = trace.endpos; + } + + // store final point. + // likely the point of detonation. + m_collision_ent = nullptr; + m_path.emplace_back(m_start); + m_bounces.emplace_back(m_start, Color::Red(250)); +} + +void c_grenade_tracer::setup() { + // get the last CreateMove angles. + QAngle angle = ctx.cmd_original_angles; + + //csgo.m_engine()->GetViewAngles(angle); + + // grab the pitch from these angles. + float pitch = angle.x; + + // correct the pitch. + if (pitch < -90.f) + pitch += 360.f; + + else if (pitch > 90.f) + pitch -= 360.f; + + // a rather 'interesting' approach at the approximation of some angle. + // lets keep it on a pitch 'correction'. + angle.x = pitch - (90.f - std::abs(pitch)) * 10.f / 90.f; + + // get ThrowVelocity from weapon files. + float vel = m_vel * 0.9f; + + // clipped to [ 15, 750 ] + Math::clamp(vel, 15.f, 750.f); + + // apply throw power to velocity. + // this is set depending on mouse states: + // m1=1 m1+m2=0.5 m2=0 + vel *= ((m_power * 0.7f) + 0.3f); + + // convert throw angle into forward direction. + Vector forward; + Math::AngleVectors(angle, &forward); + + // set start point to our shoot position. + m_start = ctx.m_local()->GetEyePosition(); + + // adjust starting point based on throw power. + m_start.z += (m_power * 12.f) - 12.f; + + // create end point from start point. + // and move it 22 units along the forward axis. + Vector end = m_start + (forward * 22.f); + + CGameTrace trace; + TraceHull(m_start, end, trace, ctx.m_local()); + + // we now have 'endpoint', set in our gametrace object. + + // move back start point 6 units along forward axis. + m_start = trace.endpos - (forward * 6.f); + + // finally, calculate the velocity where we will start off with. + // weird formula, valve.. + m_velocity = ctx.m_local()->m_vecAbsVelocity(); + m_velocity *= 1.25f; + m_velocity += (forward * vel); +} + +size_t c_grenade_tracer::advance(size_t tick) { + size_t flags{ NONE }; + CGameTrace trace; + + // apply gravity. + PhysicsAddGravityMove(m_move); + + // move object. + PhysicsPushEntity(m_start, m_move, trace, ctx.m_local()); + + // check if the object would detonate at this point. + // if so stop simulating further and endthe path here. + if (detonate(tick, trace)) + flags |= DETONATE; + + // fix collisions/bounces. + if (trace.fraction != 1.f) { + // mark as bounced. + flags |= BOUNCE; + + // adjust velocity. + ResolveFlyCollisionBounce(trace, &tick, &flags); + } + + // take new start point. + m_start = trace.endpos; + + return flags; +} + +bool c_grenade_tracer::detonate(size_t tick, CGameTrace& trace) { + + static auto weapon_molotov_maxdetonateslope = csgo.m_engine_cvars()->FindVar(sxor("weapon_molotov_maxdetonateslope")); + static auto molotov_throw_detonate_time = csgo.m_engine_cvars()->FindVar(sxor("molotov_throw_detonate_time")); + + // convert current simulation tick to time. + float time = TICKS_TO_TIME(tick); + + // CSmokeGrenadeProjectile::Think_Detonate + // speed <= 0.1 + // checked every 0.2s + + // CDecoyProjectile::Think_Detonate + // speed <= 0.2 + // checked every 0.2s + + // CBaseCSGrenadeProjectile::SetDetonateTimerLength + // auto detonate at 1.5s + // checked every 0.2s + + switch (m_id) { + case WEAPON_FLASHBANG: + case WEAPON_HEGRENADE: + return time >= 1.5f && !(tick % TIME_TO_TICKS(0.2f)); + + case WEAPON_SMOKEGRENADE: + return m_velocity.Length() <= 0.01f && !(tick % TIME_TO_TICKS(0.2f)); + + case WEAPON_DECOY: + return m_velocity.LengthSquared() <= 0.04f && !(tick % TIME_TO_TICKS(0.2f)); + + case WEAPON_MOLOTOV: + case WEAPON_FIREBOMB: + // detonate when hitting the floor. + if ((trace.fraction != 1.f || trace.m_pEnt && ((C_BasePlayer*)trace.m_pEnt)->GetClientClass() && !(((C_BasePlayer*)trace.m_pEnt)->GetClientClass()->m_ClassID != class_ids::CCSPlayer)) && (std::cos(DEG2RAD(weapon_molotov_maxdetonateslope->GetFloat())) <= trace.plane.normal.z)) + return true; + + // detonate if we have traveled for too long. + // checked every 0.1s + return time >= molotov_throw_detonate_time->GetFloat() && !(tick % TIME_TO_TICKS(0.2f)); + + default: + return false; + } + + return false; +} + +//void c_grenade_tracer::OnNewMap(const char* Map) // TO DO: Maybe handle more events +//{ +// struct EventData +// { +// EventData(const std::string& Targetname, const std::vector& OnBreak) : +// Targetname(Targetname), +// OnBreak(OnBreak) +// { } +// +// std::string Targetname; +// std::vector OnBreak; +// }; +// std::vector Events; +// Breakables.clear(); +// +// static auto FindEntitiesByTargetname = [](const std::vector& Events, const std::string& Targetname) // See https://github.com/LestaD/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/game/server/entitylist.cpp#L620 as well +// { +// std::vector Entities; +// +// for (size_t i = 0; i < Events.size(); ++i) +// { +// auto it1 = Events[i].Targetname.begin(); +// auto it2 = Targetname.begin(); +// +// while (it1 != Events[i].Targetname.end() && it2 != Targetname.end()) +// { +// if (*it1 != *it2 && tolower(*it1) != tolower(*it2)) +// break; +// +// ++it1; +// ++it2; +// } +// +// if (it2 == Targetname.end()) +// { +// if (it1 == Events[i].Targetname.end()) +// Entities.emplace_back(&Breakables[i]); +// } +// else if (*it2 == '*') +// Entities.emplace_back(&Breakables[i]); +// } +// +// return Entities; +// }; +// +// auto Entities = GetMapEntities(Map); // It's up to you to parse the BSP file +// for (const auto& Entity : Entities) +// { +// auto Classname = Entity.GetValue(sxor("classname")); +// +// BreakableType Type; +// if (Classname == sxor("func_breakable")) +// Type = BreakableType::func_breakable; +// else if (Classname == sxor("prop_dynamic") || Classname == sxor("prop_dynamic_override")) +// Type = BreakableType::prop_dynamic; +// else if (Classname == sxor("func_breakable_surf")) +// Type = BreakableType::func_breakable_surf; +// /*else if ( Classname == XorStringC( "prop_physics_multiplayer" ) ) // This never seems to break like I want it to so let's just ignore it, works fine in all official maps 10/4/17 +// Type = BreakableType::prop_physics_multiplayer;*/ +// else +// continue; +// +// if (Type == BreakableType::prop_dynamic && atoi(Entity.GetValue(sxor("solid")).c_str()) == solid_none) // TO DO: Figure out how to filter out bs better to save some iterations inside IsBreakableEntity +// continue; +// +// Breakable Breakable; +// Breakable.Model = Entity.GetValue(sxor("model")); +// Breakable.Health = atoi(Entity.GetValue(sxor("health")).c_str()); +// Breakable.Type = Type; +// Breakables.emplace_back(Breakable); +// +// Events.emplace_back(Entity.GetValue(sxor("targetname")), Entity.GetValues(sxor("OnBreak"))); +// } +// +// for (size_t i = 0; i < Events.size(); ++i) +// { +// for (const auto& OnBreak : Events[i].OnBreak) +// { +// auto Event = ParseEvent(OnBreak); // Just split the string with '\x1B' +// +// if (Event.TargetInput != sxor("Break")) +// continue; +// +// auto Found = FindEntitiesByTargetname(Events, Event.Target); // TO DO: Maybe use the delay, keeping in mind that it is completely useless in the official maps +// if (Found.empty()) +// continue; // Maybe error? +// +// Breakables[i].Breakables.insert(Breakables[i].Breakables.end(), Found.begin(), Found.end()); +// } +// } +//} + +//Breakable* IsBreakableEntity(C_BaseEntity* Entity) +//{ +// auto Model = Entity->GetModel(); +// if (!Model) +// return nullptr; +// +// auto ModelName = csgo.m_model_info()->GetModelName(Model); +// for (auto& Breakable : Breakables) +// { +// if (Breakable.Model == ModelName) +// { +// if (Breakable.Type == BreakableType::prop_dynamic || Breakable.Type == BreakableType::prop_physics_multiplayer) +// { +// auto Breakables = 0; +// if (auto Collide = csgo.m_model_info()->GetVCollide(Model)) +// { +// auto Parser = csgo.m_physcollision()->VPhysicsKeyParserCreate(Collide->pKeyValues); +// while (!Parser->Finished()) +// { +// if (!_strcmpi(Parser->GetCurrentBlockName(), sxor("break"))) +// ++Breakables; +// +// Parser->SkipBlock(); +// } +// csgo.m_physcollision()->VPhysicsKeyParserDestroy(Parser); +// } +// +// if (!Breakables) +// return nullptr; +// +// // TO DO: Properly look for "health" https://developer.valvesoftware.com/wiki/Prop_data, https://github.com/LestaD/SourceEngine2007/blob/master/se2007/game/shared/props_shared.cpp +// if (auto KeyValueText = csgo.m_model_info()->GetModelKeyValueText(Model)) +// { +// if (auto HealthLocation = strstr(KeyValueText, sxor("health"))) +// { +// Breakable.Health = atoi(HealthLocation + 9); +// +// return &Breakable; +// } +// +// if (!strstr(KeyValueText, sxor("Window"))) +// return nullptr; +// } +// else +// return nullptr; +// } +// +// return &Breakable; +// } +// } +// +// return nullptr; +//} + +//void c_grenade_tracer::Touch(C_BaseEntity* pOther, trace_t& g_TouchTrace) +//{ +// +// if (m_WeaponID == WEAPON_MOLOTOV || m_WeaponID == WEAPON_INCGRENADE) +// { +// if (!pOther->IsPlayer() && g_TouchTrace.plane.normal.z >= cos(weapon_molotov_maxdetonateslope->GetFloat())) +// Detonate(true); +// } +// else if (m_WeaponID == WEAPON_TAGRENADE) +// { +// if (!pOther->IsPlayer()) +// Detonate(true); +// } +//} + +void c_grenade_tracer::ResolveFlyCollisionBounce(CGameTrace& trace, size_t* tick, size_t *flags) { + // https://github.com/VSES/SourceEngine2007/blob/master/se2007/game/shared/physics_main_shared.cpp#L1341 + + // assume all surfaces have the same elasticity + float surface = 1.f; + + //if (trace.m_pEnt) { + // if (trace.m_pEnt->is_breakable()) { + // if (trace.m_pEnt->GetClientClass() != nullptr && + // (trace.m_pEnt->GetClientClass()->m_ClassID != class_ids::CFuncBrush || + // trace.m_pEnt->GetClientClass()->m_ClassID != class_ids::CBaseDoor || + // trace.m_pEnt->GetClientClass()->m_ClassID != class_ids::CCSPlayer || + // trace.m_pEnt->GetClientClass()->m_ClassID != class_ids::CBaseEntity)) + // { + // + // //!trace.m_entity->is(sxor("CFuncBrush")) && + // //!trace.m_entity->is(sxor("CBaseDoor")) && + // //!trace.m_entity->is(sxor("CCSPlayer")) && + // //!trace.m_entity->is(sxor("CBaseEntity"))) { + // + // // move object. + // PhysicsPushEntity(m_start, m_move, trace, (C_BasePlayer*)trace.m_pEnt); + // + // // deduct velocity penalty. + // m_velocity *= 0.4f; + // return; + // } + // } + //} + //if (trace.m_pEnt) + //{ + // //PhysicsPushEntity(m_start, m_move, trace, (C_BasePlayer*)trace.m_pEnt); + // + // if (!is_broken(trace.m_pEnt)) + // { + // if (trace.m_pEnt->GetClientClass() && trace.m_pEnt->GetClientClass()->m_ClassID == class_ids::CChicken) + // add_broken(trace.m_pEnt); + // if (trace.m_pEnt->is_breakable()) + // { + // const auto breakable = ((C_BasePlayer*)trace.m_pEnt)->m_iHealth(); + // add_broken(trace.m_pEnt); + // + // m_velocity *= 0.4f; + // } + // } + // else + // { + // if (trace.m_pEnt->is_breakable()) + // m_velocity *= 0.4f; + // } + // + // if (trace.m_pEnt && trace.m_pEnt->GetClientClass() && ((C_BaseEntity*)trace.m_pEnt)->IsPlayer()) + // surface = 0.3f; + // + // if (!trace.DidHitWorld()) + // { + // if (m_collision_ent == trace.m_pEnt) + // { + // if (((C_BaseEntity*)trace.m_pEnt)->IsPlayer() + // || trace.m_pEnt->GetClientClass() && (trace.m_pEnt->GetClientClass()->m_ClassID == class_ids::CHostage + // || trace.m_pEnt->GetClientClass()->m_ClassID == class_ids::CMolotovProjectile + // || trace.m_pEnt->GetClientClass()->m_ClassID == class_ids::CDecoyProjectile + // || trace.m_pEnt->GetClientClass()->m_ClassID == class_ids::CSmokeGrenadeProjectile + // || trace.m_pEnt->GetClientClass()->m_ClassID == class_ids::CSnowballProjectile + // || trace.m_pEnt->GetClientClass()->m_ClassID == class_ids::CBreachChargeProjectile + // || trace.m_pEnt->GetClientClass()->m_ClassID == class_ids::CBumpMineProjectile + // || trace.m_pEnt->GetClientClass()->m_ClassID == class_ids::CBaseCSGrenadeProjectile + // || trace.m_pEnt->GetClientClass()->m_ClassID == class_ids::CSensorGrenadeProjectile + // )) + // { + // m_collision_group = COLLISION_GROUP_DEBRIS; + // + // // if ( IsGrenadeProjectile ) + // // trace.m_pEnt->m_CollisionGroup = COLLISION_GROUP_DEBRIS; + // m_velocity *= 0.4f; + // } + // } + // + // m_collision_ent = trace.m_pEnt; + // } + // + // //PhysicsPushEntity(m_start, m_move, trace, (C_BasePlayer*)trace.m_pEnt); + //} + + if (trace.m_pEnt) + { + if (trace.m_pEnt->entindex() != 0) + { + m_velocity *= 0.3; + m_collision_ent = trace.m_pEnt; + } + + if (trace.m_pEnt->is_breakable()) + if (((C_BasePlayer*)trace.m_pEnt)->m_iHealth() <= 0) + { + m_velocity *= 0.4; + m_collision_ent = trace.m_pEnt; + return; + } + } + + // combine elasticities together. + float elasticity = 0.45f * surface; + + // clipped to [ 0, 0.9 ] + Math::clamp(elasticity, 0.f, 0.9f); + + Vector velocity; + PhysicsClipVelocity(m_velocity, trace.plane.normal, velocity, 2.f); + velocity *= elasticity; + + if (trace.plane.normal.z > 0.7f) { + float speed = velocity.LengthSquared(); + + // hit surface with insane speed. + if (speed > 96000.f) { + + // weird formula to slow down by normal angle? + float len = velocity.Normalized().Dot(trace.plane.normal); + if (len > 0.5f) + velocity *= 1.5f - len; + } + + // are we going too slow? + // just stop completely. + if (speed < 400.f) + m_velocity = Vector{}; + + else { + // set velocity. + m_velocity = velocity; + + // compute friction left. + float left = 1.f - trace.fraction; + + // advance forward. + PhysicsPushEntity(trace.endpos, velocity * (left * csgo.m_globals()->interval_per_tick), trace, ctx.m_local()); + } + } + + else { + // set velocity. + m_velocity = velocity; + + // compute friction left. + float left = 1.f - trace.fraction; + + // advance forward. + PhysicsPushEntity(trace.endpos, velocity * (left * csgo.m_globals()->interval_per_tick), trace, ctx.m_local()); + } + + m_bounces.emplace_back(trace.endpos, ctx.m_settings.menu_color.alpha(250)); +} + +void c_grenade_tracer::PhysicsPushEntity(Vector& start, const Vector& move, CGameTrace& trace, C_BasePlayer* ent, size_t *tick, size_t* flags) { + // compute end point. + Vector end = start + move; + + // trace through world. + TraceHull(start, end, trace, ent); + + if (trace.m_pEnt && tick && flags) + { + if (detonate(*tick, trace)) + *flags |= DETONATE; + } +} + +void c_grenade_tracer::TraceHull(const Vector& start, const Vector& end, CGameTrace& trace, C_BasePlayer* ent) { + uint32_t filter[4] = { feature::autowall->get_filter_simple_vtable(), uint32_t(ent), 0, 0 }; + + //filter.SetPassEntity(ent); + Ray_t t; t.Init(start, end, { -2.f, -2.f, -2.f }, { 2.f, 2.f, 2.f }); + + ctx.force_low_quality_autowalling = true; + + csgo.m_engine_trace()->TraceRay(t, MASK_SOLID, (ITraceFilter*)& filter, &trace); + ctx.force_low_quality_autowalling = false; +} + +void c_grenade_tracer::PhysicsAddGravityMove(Vector& move) { + // https://github.com/VSES/SourceEngine2007/blob/master/se2007/game/shared/physics_main_shared.cpp#L1264 + + // gravity for grenades. + float gravity = 800.f * 0.4f; + + // move one tick using current velocity. + move.x = m_velocity.x * csgo.m_globals()->interval_per_tick; + move.y = m_velocity.y * csgo.m_globals()->interval_per_tick; + + // apply linear acceleration due to gravity. + // calculate new z velocity. + float z = m_velocity.z - (gravity * csgo.m_globals()->interval_per_tick); + + // apply velocity to move, the average of the new and the old. + move.z = ((m_velocity.z + z) / 2.f) * csgo.m_globals()->interval_per_tick; + + // write back new gravity corrected z-velocity. + m_velocity.z = z; +} + +void c_grenade_tracer::PhysicsClipVelocity(const Vector& in, const Vector& normal, Vector& out, float overbounce) { + // https://github.com/VSES/SourceEngine2007/blob/master/se2007/game/shared/physics_main_shared.cpp#L1294 + constexpr float STOP_EPSILON = 0.1f; + + // https://github.com/VSES/SourceEngine2007/blob/master/se2007/game/shared/physics_main_shared.cpp#L1303 + + float backoff = in.Dot(normal) * overbounce; + + for (int i{}; i < 3; ++i) { + out[i] = in[i] - (normal[i] * backoff); + + if (out[i] > -STOP_EPSILON && out[i] < STOP_EPSILON) + out[i] = 0.f; + } +} +``` + +`grenades.hpp`: + +```hpp +#pragma once + +#include "sdk.hpp" + +enum class BreakableType +{ + func_breakable, + func_breakable_surf, + prop_physics_multiplayer, + prop_dynamic, + + Child +}; + +struct Breakable +{ + BreakableType Type; + std::string Model; // Maybe Hash? + int Health; + + std::vector Breakables; +}; + +class c_grenade_tracer { +private: + enum GrenadeFlags : size_t { + NONE = 0, + DETONATE, + BOUNCE, + }; + + struct bounce_t { + bounce_t(Vector _point, Color _color) + { + point = _point; + color = _color; + } + + Vector point; + Color color; + }; + + using path_t = std::vector< Vector >; + using bounces_t = std::vector< bounce_t >; + +private: + int m_id; + int m_collision_group; + path_t m_path; + bounces_t m_bounces; + float m_vel, m_power; + Vector m_start, m_velocity, m_move; + +public: + virtual void clear_broken(); + virtual void add_broken(const Breakable& Breakable, IClientUnknown* Entity); + virtual void add_broken(IClientUnknown* Entity); + virtual bool is_broken(IClientUnknown* Entity); + virtual void reset(); + virtual void paint(); + virtual void think(CUserCmd* cmd); + virtual void simulate(); + virtual void setup(); + virtual size_t advance(size_t tick); + virtual bool detonate(size_t tick, CGameTrace& trace); + //void OnNewMap(const char* Map); + virtual void ResolveFlyCollisionBounce(CGameTrace& trace, size_t* i = nullptr, size_t* o = nullptr); + virtual void PhysicsPushEntity(Vector& start, const Vector& move, CGameTrace& trace, C_BasePlayer* ent, size_t* i = nullptr, size_t* o = nullptr); + virtual void TraceHull(const Vector& start, const Vector& end, CGameTrace& trace, C_BasePlayer* ent); + virtual void PhysicsAddGravityMove(Vector& move); + virtual void PhysicsClipVelocity(const Vector& in, const Vector& normal, Vector& out, float overbounce); + + Vector last_smoke_endpos; + bool smoke_molly; + + void* m_collision_ent; +}; + +//extern Grenades g_grenades; +``` + +`hooge.hpp`: + +```hpp +#pragma once + + +unsigned char hooge[82644] = { + 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x04, 0x00, 0x10, + 0x4C, 0x54, 0x53, 0x48, 0x1E, 0x05, 0xF0, 0x38, 0x00, 0x00, 0x01, 0x1C, + 0x00, 0x00, 0x02, 0x44, 0x4F, 0x53, 0x2F, 0x32, 0x68, 0x2B, 0xA7, 0xBD, + 0x00, 0x00, 0x03, 0x60, 0x00, 0x00, 0x00, 0x56, 0x56, 0x44, 0x4D, 0x58, + 0x6A, 0x1E, 0x71, 0x77, 0x00, 0x00, 0x03, 0xB8, 0x00, 0x00, 0x05, 0xE0, + 0x63, 0x6D, 0x61, 0x70, 0xD3, 0x17, 0xA3, 0x97, 0x00, 0x00, 0x09, 0x98, + 0x00, 0x00, 0x03, 0x32, 0x63, 0x76, 0x74, 0x20, 0x04, 0xE2, 0x00, 0x7D, + 0x00, 0x00, 0x0C, 0xCC, 0x00, 0x00, 0x00, 0x14, 0x66, 0x70, 0x67, 0x6D, + 0xC9, 0x60, 0xB1, 0x9B, 0x00, 0x00, 0x0C, 0xE0, 0x00, 0x00, 0x01, 0x53, + 0x67, 0x61, 0x73, 0x70, 0x00, 0x17, 0x00, 0x09, 0x00, 0x00, 0x0E, 0x34, + 0x00, 0x00, 0x00, 0x10, 0x67, 0x6C, 0x79, 0x66, 0xCB, 0xFE, 0x4F, 0x7D, + 0x00, 0x00, 0x0E, 0x44, 0x00, 0x00, 0xEB, 0xC6, 0x68, 0x64, 0x6D, 0x78, + 0xAB, 0x48, 0x44, 0xD0, 0x00, 0x00, 0xFA, 0x0C, 0x00, 0x00, 0x24, 0x48, + 0x68, 0x65, 0x61, 0x64, 0xD4, 0xF3, 0x7F, 0x89, 0x00, 0x01, 0x1E, 0x54, + 0x00, 0x00, 0x00, 0x36, 0x68, 0x68, 0x65, 0x61, 0x09, 0xDE, 0x08, 0x9A, + 0x00, 0x01, 0x1E, 0x8C, 0x00, 0x00, 0x00, 0x24, 0x68, 0x6D, 0x74, 0x78, + 0x7A, 0xCC, 0x00, 0x00, 0x00, 0x01, 0x1E, 0xB0, 0x00, 0x00, 0x09, 0x00, + 0x6C, 0x6F, 0x63, 0x61, 0x9C, 0xAF, 0x61, 0xDC, 0x00, 0x01, 0x27, 0xB0, + 0x00, 0x00, 0x04, 0x82, 0x6D, 0x61, 0x78, 0x70, 0x04, 0x52, 0x01, 0x76, + 0x00, 0x01, 0x2C, 0x34, 0x00, 0x00, 0x00, 0x20, 0x6E, 0x61, 0x6D, 0x65, + 0x78, 0xAE, 0xD1, 0x77, 0x00, 0x01, 0x2C, 0x54, 0x00, 0x00, 0x06, 0xF6, + 0x70, 0x6F, 0x73, 0x74, 0x50, 0x3A, 0xA5, 0x28, 0x00, 0x01, 0x33, 0x4C, + 0x00, 0x00, 0x0F, 0x57, 0x70, 0x72, 0x65, 0x70, 0xE9, 0x5A, 0x84, 0xE3, + 0x00, 0x01, 0x42, 0xA4, 0x00, 0x00, 0x00, 0x2F, 0x00, 0x00, 0x02, 0x40, + 0x19, 0x01, 0x01, 0x01, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x01, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x00, 0x01, 0x01, 0xFD, 0x01, 0x90, 0x00, 0x05, 0x00, 0x00, 0x02, 0xBC, + 0x02, 0x8A, 0x00, 0x00, 0x00, 0x8F, 0x02, 0xBC, 0x02, 0x8A, 0x00, 0x00, + 0x01, 0xC5, 0x00, 0x32, 0x01, 0x03, 0x00, 0x00, 0x02, 0x00, 0x05, 0x06, + 0x02, 0x00, 0x00, 0x02, 0x00, 0x04, 0x80, 0x00, 0x02, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x53, + 0x53, 0x54, 0x00, 0x00, 0x00, 0x20, 0xF0, 0x02, 0x02, 0x71, 0xFF, 0x83, + 0x00, 0x2F, 0x03, 0x6B, 0x00, 0xFA, 0x20, 0x00, 0x01, 0x17, 0xC3, 0xC6, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x0C, 0x00, 0xF8, 0x08, 0xFF, 0x00, 0x08, 0x00, 0x07, + 0xFF, 0xFE, 0x00, 0x09, 0x00, 0x08, 0xFF, 0xFD, 0x00, 0x0A, 0x00, 0x09, + 0xFF, 0xFD, 0x00, 0x0B, 0x00, 0x0A, 0xFF, 0xFD, 0x00, 0x0C, 0x00, 0x0B, + 0xFF, 0xFD, 0x00, 0x0D, 0x00, 0x0C, 0xFF, 0xFC, 0x00, 0x0E, 0x00, 0x0D, + 0xFF, 0xFC, 0x00, 0x0F, 0x00, 0x0E, 0xFF, 0xFC, 0x00, 0x10, 0x00, 0x0E, + 0xFF, 0xFC, 0x00, 0x11, 0x00, 0x0F, 0xFF, 0xFB, 0x00, 0x12, 0x00, 0x10, + 0xFF, 0xFB, 0x00, 0x13, 0x00, 0x11, 0xFF, 0xFB, 0x00, 0x14, 0x00, 0x12, + 0xFF, 0xFB, 0x00, 0x15, 0x00, 0x13, 0xFF, 0xFA, 0x00, 0x16, 0x00, 0x14, + 0xFF, 0xFA, 0x00, 0x17, 0x00, 0x15, 0xFF, 0xFA, 0x00, 0x18, 0x00, 0x15, + 0xFF, 0xFA, 0x00, 0x19, 0x00, 0x16, 0xFF, 0xF9, 0x00, 0x1A, 0x00, 0x17, + 0xFF, 0xF9, 0x00, 0x1B, 0x00, 0x18, 0xFF, 0xF9, 0x00, 0x1C, 0x00, 0x19, + 0xFF, 0xF9, 0x00, 0x1D, 0x00, 0x1A, 0xFF, 0xF8, 0x00, 0x1E, 0x00, 0x1B, + 0xFF, 0xF8, 0x00, 0x1F, 0x00, 0x1C, 0xFF, 0xF8, 0x00, 0x20, 0x00, 0x1C, + 0xFF, 0xF8, 0x00, 0x21, 0x00, 0x1D, 0xFF, 0xF7, 0x00, 0x22, 0x00, 0x1E, + 0xFF, 0xF7, 0x00, 0x23, 0x00, 0x1F, 0xFF, 0xF7, 0x00, 0x24, 0x00, 0x20, + 0xFF, 0xF7, 0x00, 0x25, 0x00, 0x21, 0xFF, 0xF6, 0x00, 0x26, 0x00, 0x22, + 0xFF, 0xF6, 0x00, 0x27, 0x00, 0x23, 0xFF, 0xF6, 0x00, 0x28, 0x00, 0x23, + 0xFF, 0xF6, 0x00, 0x29, 0x00, 0x24, 0xFF, 0xF5, 0x00, 0x2A, 0x00, 0x25, + 0xFF, 0xF5, 0x00, 0x2B, 0x00, 0x26, 0xFF, 0xF5, 0x00, 0x2C, 0x00, 0x27, + 0xFF, 0xF5, 0x00, 0x2D, 0x00, 0x28, 0xFF, 0xF4, 0x00, 0x2E, 0x00, 0x29, + 0xFF, 0xF4, 0x00, 0x2F, 0x00, 0x2A, 0xFF, 0xF4, 0x00, 0x30, 0x00, 0x2A, + 0xFF, 0xF4, 0x00, 0x31, 0x00, 0x2B, 0xFF, 0xF3, 0x00, 0x32, 0x00, 0x2C, + 0xFF, 0xF3, 0x00, 0x33, 0x00, 0x2D, 0xFF, 0xF3, 0x00, 0x34, 0x00, 0x2E, + 0xFF, 0xF3, 0x00, 0x35, 0x00, 0x2F, 0xFF, 0xF2, 0x00, 0x36, 0x00, 0x30, + 0xFF, 0xF2, 0x00, 0x37, 0x00, 0x31, 0xFF, 0xF2, 0x00, 0x38, 0x00, 0x31, + 0xFF, 0xF2, 0x00, 0x39, 0x00, 0x32, 0xFF, 0xF1, 0x00, 0x3A, 0x00, 0x33, + 0xFF, 0xF1, 0x00, 0x3B, 0x00, 0x34, 0xFF, 0xF1, 0x00, 0x3C, 0x00, 0x35, + 0xFF, 0xF1, 0x00, 0x3D, 0x00, 0x36, 0xFF, 0xF0, 0x00, 0x3E, 0x00, 0x37, + 0xFF, 0xF0, 0x00, 0x3F, 0x00, 0x38, 0xFF, 0xF0, 0x00, 0x40, 0x00, 0x38, + 0xFF, 0xF0, 0x00, 0x41, 0x00, 0x39, 0xFF, 0xEF, 0x00, 0x42, 0x00, 0x3A, + 0xFF, 0xEF, 0x00, 0x43, 0x00, 0x3B, 0xFF, 0xEF, 0x00, 0x44, 0x00, 0x3C, + 0xFF, 0xEF, 0x00, 0x45, 0x00, 0x3D, 0xFF, 0xEE, 0x00, 0x46, 0x00, 0x3E, + 0xFF, 0xEE, 0x00, 0x47, 0x00, 0x3F, 0xFF, 0xEE, 0x00, 0x48, 0x00, 0x3F, + 0xFF, 0xEE, 0x00, 0x49, 0x00, 0x40, 0xFF, 0xED, 0x00, 0x4A, 0x00, 0x41, + 0xFF, 0xED, 0x00, 0x4B, 0x00, 0x42, 0xFF, 0xED, 0x00, 0x4C, 0x00, 0x43, + 0xFF, 0xED, 0x00, 0x4D, 0x00, 0x44, 0xFF, 0xEC, 0x00, 0x4E, 0x00, 0x45, + 0xFF, 0xEC, 0x00, 0x4F, 0x00, 0x46, 0xFF, 0xEC, 0x00, 0x50, 0x00, 0x46, + 0xFF, 0xEC, 0x00, 0x51, 0x00, 0x47, 0xFF, 0xEB, 0x00, 0x52, 0x00, 0x48, + 0xFF, 0xEB, 0x00, 0x53, 0x00, 0x49, 0xFF, 0xEB, 0x00, 0x54, 0x00, 0x4A, + 0xFF, 0xEB, 0x00, 0x55, 0x00, 0x4B, 0xFF, 0xEA, 0x00, 0x56, 0x00, 0x4C, + 0xFF, 0xEA, 0x00, 0x57, 0x00, 0x4D, 0xFF, 0xEA, 0x00, 0x58, 0x00, 0x4D, + 0xFF, 0xEA, 0x00, 0x59, 0x00, 0x4E, 0xFF, 0xE9, 0x00, 0x5A, 0x00, 0x4F, + 0xFF, 0xE9, 0x00, 0x5B, 0x00, 0x50, 0xFF, 0xE9, 0x00, 0x5C, 0x00, 0x51, + 0xFF, 0xE9, 0x00, 0x5D, 0x00, 0x52, 0xFF, 0xE8, 0x00, 0x5E, 0x00, 0x53, + 0xFF, 0xE8, 0x00, 0x5F, 0x00, 0x54, 0xFF, 0xE8, 0x00, 0x60, 0x00, 0x54, + 0xFF, 0xE8, 0x00, 0x61, 0x00, 0x55, 0xFF, 0xE7, 0x00, 0x62, 0x00, 0x56, + 0xFF, 0xE7, 0x00, 0x63, 0x00, 0x57, 0xFF, 0xE7, 0x00, 0x64, 0x00, 0x58, + 0xFF, 0xE7, 0x00, 0x65, 0x00, 0x59, 0xFF, 0xE6, 0x00, 0x66, 0x00, 0x5A, + 0xFF, 0xE6, 0x00, 0x67, 0x00, 0x5B, 0xFF, 0xE6, 0x00, 0x68, 0x00, 0x5B, + 0xFF, 0xE6, 0x00, 0x69, 0x00, 0x5C, 0xFF, 0xE5, 0x00, 0x6A, 0x00, 0x5D, + 0xFF, 0xE5, 0x00, 0x6B, 0x00, 0x5E, 0xFF, 0xE5, 0x00, 0x6C, 0x00, 0x5F, + 0xFF, 0xE5, 0x00, 0x6D, 0x00, 0x60, 0xFF, 0xE4, 0x00, 0x6E, 0x00, 0x61, + 0xFF, 0xE4, 0x00, 0x6F, 0x00, 0x62, 0xFF, 0xE4, 0x00, 0x70, 0x00, 0x62, + 0xFF, 0xE4, 0x00, 0x71, 0x00, 0x63, 0xFF, 0xE3, 0x00, 0x72, 0x00, 0x64, + 0xFF, 0xE3, 0x00, 0x73, 0x00, 0x65, 0xFF, 0xE3, 0x00, 0x74, 0x00, 0x66, + 0xFF, 0xE3, 0x00, 0x75, 0x00, 0x67, 0xFF, 0xE2, 0x00, 0x76, 0x00, 0x68, + 0xFF, 0xE2, 0x00, 0x77, 0x00, 0x69, 0xFF, 0xE2, 0x00, 0x78, 0x00, 0x69, + 0xFF, 0xE2, 0x00, 0x79, 0x00, 0x6A, 0xFF, 0xE1, 0x00, 0x7A, 0x00, 0x6B, + 0xFF, 0xE1, 0x00, 0x7B, 0x00, 0x6C, 0xFF, 0xE1, 0x00, 0x7C, 0x00, 0x6D, + 0xFF, 0xE1, 0x00, 0x7D, 0x00, 0x6E, 0xFF, 0xE0, 0x00, 0x7E, 0x00, 0x6F, + 0xFF, 0xE0, 0x00, 0x7F, 0x00, 0x70, 0xFF, 0xE0, 0x00, 0x80, 0x00, 0x70, + 0xFF, 0xE0, 0x00, 0x81, 0x00, 0x71, 0xFF, 0xDF, 0x00, 0x82, 0x00, 0x72, + 0xFF, 0xDF, 0x00, 0x83, 0x00, 0x73, 0xFF, 0xDF, 0x00, 0x84, 0x00, 0x74, + 0xFF, 0xDF, 0x00, 0x85, 0x00, 0x75, 0xFF, 0xDE, 0x00, 0x86, 0x00, 0x76, + 0xFF, 0xDE, 0x00, 0x87, 0x00, 0x77, 0xFF, 0xDE, 0x00, 0x88, 0x00, 0x77, + 0xFF, 0xDE, 0x00, 0x89, 0x00, 0x78, 0xFF, 0xDD, 0x00, 0x8A, 0x00, 0x79, + 0xFF, 0xDD, 0x00, 0x8B, 0x00, 0x7A, 0xFF, 0xDD, 0x00, 0x8C, 0x00, 0x7B, + 0xFF, 0xDD, 0x00, 0x8D, 0x00, 0x7C, 0xFF, 0xDC, 0x00, 0x8E, 0x00, 0x7D, + 0xFF, 0xDC, 0x00, 0x8F, 0x00, 0x7E, 0xFF, 0xDC, 0x00, 0x90, 0x00, 0x7E, + 0xFF, 0xDC, 0x00, 0x91, 0x00, 0x7F, 0xFF, 0xDB, 0x00, 0x92, 0x00, 0x80, + 0xFF, 0xDB, 0x00, 0x93, 0x00, 0x81, 0xFF, 0xDB, 0x00, 0x94, 0x00, 0x82, + 0xFF, 0xDB, 0x00, 0x95, 0x00, 0x83, 0xFF, 0xDA, 0x00, 0x96, 0x00, 0x84, + 0xFF, 0xDA, 0x00, 0x97, 0x00, 0x85, 0xFF, 0xDA, 0x00, 0x98, 0x00, 0x85, + 0xFF, 0xDA, 0x00, 0x99, 0x00, 0x86, 0xFF, 0xD9, 0x00, 0x9A, 0x00, 0x87, + 0xFF, 0xD9, 0x00, 0x9B, 0x00, 0x88, 0xFF, 0xD9, 0x00, 0x9C, 0x00, 0x89, + 0xFF, 0xD9, 0x00, 0x9D, 0x00, 0x8A, 0xFF, 0xD8, 0x00, 0x9E, 0x00, 0x8B, + 0xFF, 0xD8, 0x00, 0x9F, 0x00, 0x8C, 0xFF, 0xD8, 0x00, 0xA0, 0x00, 0x8C, + 0xFF, 0xD8, 0x00, 0xA1, 0x00, 0x8D, 0xFF, 0xD7, 0x00, 0xA2, 0x00, 0x8E, + 0xFF, 0xD7, 0x00, 0xA3, 0x00, 0x8F, 0xFF, 0xD7, 0x00, 0xA4, 0x00, 0x90, + 0xFF, 0xD7, 0x00, 0xA5, 0x00, 0x91, 0xFF, 0xD6, 0x00, 0xA6, 0x00, 0x92, + 0xFF, 0xD6, 0x00, 0xA7, 0x00, 0x93, 0xFF, 0xD6, 0x00, 0xA8, 0x00, 0x93, + 0xFF, 0xD6, 0x00, 0xA9, 0x00, 0x94, 0xFF, 0xD5, 0x00, 0xAA, 0x00, 0x95, + 0xFF, 0xD5, 0x00, 0xAB, 0x00, 0x96, 0xFF, 0xD5, 0x00, 0xAC, 0x00, 0x97, + 0xFF, 0xD5, 0x00, 0xAD, 0x00, 0x98, 0xFF, 0xD4, 0x00, 0xAE, 0x00, 0x99, + 0xFF, 0xD4, 0x00, 0xAF, 0x00, 0x9A, 0xFF, 0xD4, 0x00, 0xB0, 0x00, 0x9A, + 0xFF, 0xD4, 0x00, 0xB1, 0x00, 0x9B, 0xFF, 0xD3, 0x00, 0xB2, 0x00, 0x9C, + 0xFF, 0xD3, 0x00, 0xB3, 0x00, 0x9D, 0xFF, 0xD3, 0x00, 0xB4, 0x00, 0x9E, + 0xFF, 0xD3, 0x00, 0xB5, 0x00, 0x9F, 0xFF, 0xD2, 0x00, 0xB6, 0x00, 0xA0, + 0xFF, 0xD2, 0x00, 0xB7, 0x00, 0xA1, 0xFF, 0xD2, 0x00, 0xB8, 0x00, 0xA1, + 0xFF, 0xD2, 0x00, 0xB9, 0x00, 0xA2, 0xFF, 0xD1, 0x00, 0xBA, 0x00, 0xA3, + 0xFF, 0xD1, 0x00, 0xBB, 0x00, 0xA4, 0xFF, 0xD1, 0x00, 0xBC, 0x00, 0xA5, + 0xFF, 0xD1, 0x00, 0xBD, 0x00, 0xA6, 0xFF, 0xD0, 0x00, 0xBE, 0x00, 0xA7, + 0xFF, 0xD0, 0x00, 0xBF, 0x00, 0xA8, 0xFF, 0xD0, 0x00, 0xC0, 0x00, 0xA8, + 0xFF, 0xD0, 0x00, 0xC1, 0x00, 0xA9, 0xFF, 0xCF, 0x00, 0xC2, 0x00, 0xAA, + 0xFF, 0xCF, 0x00, 0xC3, 0x00, 0xAB, 0xFF, 0xCF, 0x00, 0xC4, 0x00, 0xAC, + 0xFF, 0xCF, 0x00, 0xC5, 0x00, 0xAD, 0xFF, 0xCE, 0x00, 0xC6, 0x00, 0xAE, + 0xFF, 0xCE, 0x00, 0xC7, 0x00, 0xAF, 0xFF, 0xCE, 0x00, 0xC8, 0x00, 0xAF, + 0xFF, 0xCE, 0x00, 0xC9, 0x00, 0xB0, 0xFF, 0xCD, 0x00, 0xCA, 0x00, 0xB1, + 0xFF, 0xCD, 0x00, 0xCB, 0x00, 0xB2, 0xFF, 0xCD, 0x00, 0xCC, 0x00, 0xB3, + 0xFF, 0xCD, 0x00, 0xCD, 0x00, 0xB4, 0xFF, 0xCC, 0x00, 0xCE, 0x00, 0xB5, + 0xFF, 0xCC, 0x00, 0xCF, 0x00, 0xB6, 0xFF, 0xCC, 0x00, 0xD0, 0x00, 0xB6, + 0xFF, 0xCC, 0x00, 0xD1, 0x00, 0xB7, 0xFF, 0xCB, 0x00, 0xD2, 0x00, 0xB8, + 0xFF, 0xCB, 0x00, 0xD3, 0x00, 0xB9, 0xFF, 0xCB, 0x00, 0xD4, 0x00, 0xBA, + 0xFF, 0xCB, 0x00, 0xD5, 0x00, 0xBB, 0xFF, 0xCA, 0x00, 0xD6, 0x00, 0xBC, + 0xFF, 0xCA, 0x00, 0xD7, 0x00, 0xBD, 0xFF, 0xCA, 0x00, 0xD8, 0x00, 0xBD, + 0xFF, 0xCA, 0x00, 0xD9, 0x00, 0xBE, 0xFF, 0xC9, 0x00, 0xDA, 0x00, 0xBF, + 0xFF, 0xC9, 0x00, 0xDB, 0x00, 0xC0, 0xFF, 0xC9, 0x00, 0xDC, 0x00, 0xC1, + 0xFF, 0xC9, 0x00, 0xDD, 0x00, 0xC2, 0xFF, 0xC8, 0x00, 0xDE, 0x00, 0xC3, + 0xFF, 0xC8, 0x00, 0xDF, 0x00, 0xC4, 0xFF, 0xC8, 0x00, 0xE0, 0x00, 0xC4, + 0xFF, 0xC8, 0x00, 0xE1, 0x00, 0xC5, 0xFF, 0xC7, 0x00, 0xE2, 0x00, 0xC6, + 0xFF, 0xC7, 0x00, 0xE3, 0x00, 0xC7, 0xFF, 0xC7, 0x00, 0xE4, 0x00, 0xC8, + 0xFF, 0xC7, 0x00, 0xE5, 0x00, 0xC9, 0xFF, 0xC6, 0x00, 0xE6, 0x00, 0xCA, + 0xFF, 0xC6, 0x00, 0xE7, 0x00, 0xCB, 0xFF, 0xC6, 0x00, 0xE8, 0x00, 0xCB, + 0xFF, 0xC6, 0x00, 0xE9, 0x00, 0xCC, 0xFF, 0xC5, 0x00, 0xEA, 0x00, 0xCD, + 0xFF, 0xC5, 0x00, 0xEB, 0x00, 0xCE, 0xFF, 0xC5, 0x00, 0xEC, 0x00, 0xCF, + 0xFF, 0xC5, 0x00, 0xED, 0x00, 0xD0, 0xFF, 0xC4, 0x00, 0xEE, 0x00, 0xD1, + 0xFF, 0xC4, 0x00, 0xEF, 0x00, 0xD2, 0xFF, 0xC4, 0x00, 0xF0, 0x00, 0xD2, + 0xFF, 0xC4, 0x00, 0xF1, 0x00, 0xD3, 0xFF, 0xC3, 0x00, 0xF2, 0x00, 0xD4, + 0xFF, 0xC3, 0x00, 0xF3, 0x00, 0xD5, 0xFF, 0xC3, 0x00, 0xF4, 0x00, 0xD6, + 0xFF, 0xC3, 0x00, 0xF5, 0x00, 0xD7, 0xFF, 0xC2, 0x00, 0xF6, 0x00, 0xD8, + 0xFF, 0xC2, 0x00, 0xF7, 0x00, 0xD9, 0xFF, 0xC2, 0x00, 0xF8, 0x00, 0xD9, + 0xFF, 0xC2, 0x00, 0xF9, 0x00, 0xDA, 0xFF, 0xC1, 0x00, 0xFA, 0x00, 0xDB, + 0xFF, 0xC1, 0x00, 0xFB, 0x00, 0xDC, 0xFF, 0xC1, 0x00, 0xFC, 0x00, 0xDD, + 0xFF, 0xC1, 0x00, 0xFD, 0x00, 0xDE, 0xFF, 0xC0, 0x00, 0xFE, 0x00, 0xDF, + 0xFF, 0xC0, 0x00, 0xFF, 0x00, 0xE0, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x03, 0x00, 0x01, + 0x00, 0x00, 0x01, 0x1A, 0x00, 0x00, 0x01, 0x06, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x06, 0x05, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, + 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, + 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, + 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, + 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, + 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, + 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x00, 0xCD, 0xCE, 0xD0, 0xD2, 0xD9, 0xDE, + 0xE3, 0xE6, 0xE5, 0xE7, 0xE9, 0xE8, 0xEA, 0xEC, 0xEE, 0xED, 0xEF, 0xF0, + 0xF2, 0xF1, 0xF3, 0xF4, 0xF5, 0xF7, 0xF6, 0xF8, 0xFA, 0xF9, 0xFE, 0xFD, + 0xFF, 0x00, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0xE4, 0x67, 0x68, + 0x69, 0x6A, 0x6B, 0x85, 0xCF, 0xDF, 0x00, 0x8F, 0x00, 0x00, 0x6C, 0x6D, + 0x00, 0x00, 0x00, 0x86, 0x00, 0x6E, 0x6F, 0x87, 0xEB, 0xFC, 0x70, 0x04, + 0x72, 0x88, 0x00, 0x89, 0x8A, 0x73, 0x74, 0x75, 0x03, 0xC9, 0xCC, 0xDD, + 0x00, 0x00, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0xFB, 0x8B, 0x01, 0x00, + 0x8C, 0x00, 0x8E, 0x7D, 0x00, 0x00, 0x7E, 0x03, 0x80, 0x81, 0x82, 0xCB, + 0xD3, 0xCA, 0xD4, 0xD1, 0xD6, 0xD7, 0xD8, 0xD5, 0xDB, 0xDC, 0x00, 0xDA, + 0xE1, 0xE2, 0xE0, 0x8D, 0x83, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x04, 0x02, 0x18, 0x00, 0x00, 0x00, 0x48, 0x00, 0x40, + 0x00, 0x05, 0x00, 0x08, 0x00, 0x22, 0x00, 0x7E, 0x00, 0xBF, 0x00, 0xCF, + 0x00, 0xDE, 0x00, 0xEF, 0x00, 0xF0, 0x00, 0xFC, 0x00, 0xFF, 0x01, 0x31, + 0x02, 0xC6, 0x02, 0xDC, 0x03, 0xC0, 0x04, 0x14, 0x04, 0x2E, 0x04, 0x2F, + 0x04, 0x4F, 0x04, 0x5F, 0x04, 0x91, 0x20, 0x22, 0x20, 0x26, 0x20, 0x30, + 0x20, 0x3A, 0x20, 0x44, 0x21, 0x22, 0x21, 0x26, 0x22, 0x06, 0x22, 0x12, + 0x22, 0x1A, 0x22, 0x48, 0x22, 0x60, 0x22, 0xC5, 0x22, 0xF2, 0x25, 0xCA, + 0xF0, 0x02, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x20, 0x00, 0x23, 0x00, 0xA0, + 0x00, 0xC0, 0x00, 0xD0, 0x00, 0xDF, 0x00, 0xF0, 0x00, 0xF1, 0x00, 0xFD, + 0x01, 0x31, 0x02, 0xC6, 0x02, 0xDC, 0x03, 0xC0, 0x04, 0x01, 0x04, 0x15, + 0x04, 0x2F, 0x04, 0x30, 0x04, 0x51, 0x04, 0x90, 0x20, 0x10, 0x20, 0x26, + 0x20, 0x30, 0x20, 0x39, 0x20, 0x44, 0x21, 0x22, 0x21, 0x26, 0x22, 0x06, + 0x22, 0x12, 0x22, 0x19, 0x22, 0x48, 0x22, 0x60, 0x22, 0xC5, 0x22, 0xF2, + 0x25, 0xCA, 0xF0, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xE1, 0x00, 0x00, + 0x00, 0x09, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0xFF, 0x5C, 0xFD, 0xBD, 0xFE, 0x26, 0xFC, 0xC6, 0x00, 0x00, 0xFD, 0xB8, + 0x00, 0x00, 0xFD, 0xB7, 0x00, 0x00, 0xFD, 0x7D, 0x00, 0x00, 0xE0, 0x4F, + 0xE0, 0x52, 0x00, 0x00, 0xE0, 0x48, 0xDF, 0x47, 0xDF, 0x61, 0xDE, 0x84, + 0xDF, 0x3B, 0x00, 0x00, 0xDE, 0x41, 0xDE, 0x25, 0xDE, 0x3E, 0xDD, 0x97, + 0xDA, 0xC1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x48, 0x00, 0x00, 0x00, 0x4A, + 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x00, 0x00, 0x9E, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9A, 0x00, 0x00, + 0x00, 0xBE, 0x00, 0x00, 0x00, 0xBC, 0x00, 0x00, 0x00, 0xD6, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xE6, 0x00, 0x00, 0x00, 0x03, 0x01, 0x06, 0x01, 0x05, + 0x00, 0x76, 0x01, 0x04, 0x00, 0x62, 0x00, 0x63, 0x00, 0x00, 0x00, 0x6C, + 0x00, 0x00, 0x00, 0x64, 0x00, 0x6B, 0x00, 0x68, 0x00, 0x6E, 0x00, 0x73, + 0x00, 0x72, 0x01, 0x4D, 0x00, 0x67, 0x00, 0x00, 0x00, 0x61, 0x00, 0x8F, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x6A, 0x00, 0x6D, 0x00, 0x66, 0x01, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x70, 0x02, 0x36, 0x00, 0xD9, 0x00, 0xDA, 0x00, 0xDB, + 0x00, 0xDC, 0x00, 0xDD, 0x00, 0xDE, 0x02, 0x37, 0x00, 0xDF, 0x00, 0xE0, + 0x00, 0xE1, 0x00, 0xE2, 0x00, 0xE3, 0x02, 0x38, 0x02, 0x39, 0x02, 0x3A, + 0x02, 0x3B, 0x02, 0x3C, 0x01, 0x01, 0x02, 0x20, 0x02, 0x07, 0x02, 0x09, + 0x02, 0x0F, 0x02, 0x1A, 0x01, 0xA1, 0x02, 0x12, 0x02, 0x0B, 0x02, 0x14, + 0x02, 0x18, 0x02, 0x1C, 0x02, 0x1E, 0x00, 0x00, 0x02, 0x16, 0x02, 0x22, + 0x01, 0xCA, 0x02, 0x3D, 0x01, 0xCB, 0x01, 0xCC, 0x02, 0x3E, 0x02, 0x3F, + 0x02, 0x21, 0x02, 0x08, 0x02, 0x0A, 0x02, 0x10, 0x02, 0x1B, 0x02, 0x11, + 0x02, 0x13, 0x02, 0x0C, 0x02, 0x15, 0x02, 0x19, 0x02, 0x1D, 0x02, 0x1F, + 0x00, 0x00, 0x02, 0x17, 0x02, 0x23, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x77, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7B, + 0x00, 0x7C, 0x00, 0x80, 0x00, 0x00, 0x00, 0x79, 0x00, 0x7A, 0x00, 0x81, + 0x00, 0x00, 0x00, 0x60, 0x00, 0x7E, 0x00, 0x65, 0x00, 0x8E, 0x00, 0x7D, + 0x00, 0x7F, 0x00, 0x88, 0x01, 0x58, 0x01, 0x56, 0x01, 0x57, 0x00, 0x00, + 0x00, 0x7D, 0x00, 0x7D, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x83, 0x00, 0x00, 0xB8, 0x00, 0x00, 0x2C, + 0x4B, 0xB8, 0x00, 0x09, 0x50, 0x58, 0xB1, 0x01, 0x01, 0x8E, 0x59, 0xB8, + 0x01, 0xFF, 0x85, 0xB8, 0x00, 0x44, 0x1D, 0xB9, 0x00, 0x09, 0x00, 0x03, + 0x5F, 0x5E, 0x2D, 0xB8, 0x00, 0x01, 0x2C, 0x20, 0x20, 0x45, 0x69, 0x44, + 0xB0, 0x01, 0x60, 0x2D, 0xB8, 0x00, 0x02, 0x2C, 0xB8, 0x00, 0x01, 0x2A, + 0x21, 0x2D, 0xB8, 0x00, 0x03, 0x2C, 0x20, 0x46, 0xB0, 0x03, 0x25, 0x46, + 0x52, 0x58, 0x23, 0x59, 0x20, 0x8A, 0x20, 0x8A, 0x49, 0x64, 0x8A, 0x20, + 0x46, 0x20, 0x68, 0x61, 0x64, 0xB0, 0x04, 0x25, 0x46, 0x20, 0x68, 0x61, + 0x64, 0x52, 0x58, 0x23, 0x65, 0x8A, 0x59, 0x2F, 0x20, 0xB0, 0x00, 0x53, + 0x58, 0x69, 0x20, 0xB0, 0x00, 0x54, 0x58, 0x21, 0xB0, 0x40, 0x59, 0x1B, + 0x69, 0x20, 0xB0, 0x00, 0x54, 0x58, 0x21, 0xB0, 0x40, 0x65, 0x59, 0x59, + 0x3A, 0x2D, 0xB8, 0x00, 0x04, 0x2C, 0x20, 0x46, 0xB0, 0x04, 0x25, 0x46, + 0x52, 0x58, 0x23, 0x8A, 0x59, 0x20, 0x46, 0x20, 0x6A, 0x61, 0x64, 0xB0, + 0x04, 0x25, 0x46, 0x20, 0x6A, 0x61, 0x64, 0x52, 0x58, 0x23, 0x8A, 0x59, + 0x2F, 0xFD, 0x2D, 0xB8, 0x00, 0x05, 0x2C, 0x4B, 0x20, 0xB0, 0x03, 0x26, + 0x50, 0x58, 0x51, 0x58, 0xB0, 0x80, 0x44, 0x1B, 0xB0, 0x40, 0x44, 0x59, + 0x1B, 0x21, 0x21, 0x20, 0x45, 0xB0, 0xC0, 0x50, 0x58, 0xB0, 0xC0, 0x44, + 0x1B, 0x21, 0x59, 0x59, 0x2D, 0xB8, 0x00, 0x06, 0x2C, 0x20, 0x20, 0x45, + 0x69, 0x44, 0xB0, 0x01, 0x60, 0x20, 0x20, 0x45, 0x7D, 0x69, 0x18, 0x44, + 0xB0, 0x01, 0x60, 0x2D, 0xB8, 0x00, 0x07, 0x2C, 0xB8, 0x00, 0x06, 0x2A, + 0x2D, 0xB8, 0x00, 0x08, 0x2C, 0x4B, 0x20, 0xB0, 0x03, 0x26, 0x53, 0x58, + 0xB0, 0x80, 0x1B, 0xB0, 0x40, 0x59, 0x8A, 0x8A, 0x20, 0xB0, 0x03, 0x26, + 0x53, 0x58, 0xB0, 0x02, 0x26, 0x21, 0xB0, 0xC0, 0x8A, 0x8A, 0x1B, 0x8A, + 0x23, 0x59, 0x20, 0xB0, 0x03, 0x26, 0x53, 0x58, 0x23, 0x21, 0xB8, 0x01, + 0x00, 0x8A, 0x8A, 0x1B, 0x8A, 0x23, 0x59, 0x20, 0xB8, 0x00, 0x03, 0x26, + 0x53, 0x58, 0xB0, 0x03, 0x25, 0x45, 0xB8, 0x01, 0x40, 0x50, 0x58, 0x23, + 0x21, 0xB8, 0x01, 0x40, 0x23, 0x21, 0x1B, 0xB0, 0x03, 0x25, 0x45, 0x23, + 0x21, 0x23, 0x21, 0x59, 0x1B, 0x21, 0x59, 0x44, 0x2D, 0xB8, 0x00, 0x09, + 0x2C, 0x4B, 0x53, 0x58, 0x45, 0x44, 0x1B, 0x21, 0x21, 0x59, 0x2D, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x00, 0x08, 0x00, 0x02, 0x00, 0x10, 0x00, 0x01, + 0xFF, 0xFF, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, + 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x1B, 0x40, 0x0F, 0x05, 0x02, + 0x04, 0x00, 0x00, 0x06, 0x02, 0x02, 0x05, 0x03, 0x03, 0x01, 0x01, 0x07, + 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0xFC, 0x10, 0xDC, 0x30, 0x31, 0x31, + 0x21, 0x11, 0x21, 0x13, 0x11, 0x33, 0x11, 0x01, 0x77, 0xFE, 0x89, 0x3E, + 0xFA, 0x02, 0x71, 0xFD, 0xCE, 0x01, 0xF4, 0xFE, 0x0C, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x1B, 0x00, 0x1F, + 0x00, 0x75, 0x40, 0x40, 0x1E, 0x1E, 0x19, 0x13, 0x13, 0x18, 0x0F, 0x0F, + 0x18, 0x0D, 0x0D, 0x19, 0x19, 0x00, 0x18, 0x04, 0x0B, 0x0B, 0x1D, 0x09, + 0x09, 0x05, 0x01, 0x01, 0x05, 0x00, 0x00, 0x1D, 0x05, 0x00, 0x1D, 0x04, + 0x16, 0x06, 0x11, 0x06, 0x08, 0x02, 0x03, 0x02, 0x1C, 0x12, 0x16, 0x1A, + 0x14, 0x1E, 0x0C, 0x11, 0x08, 0x11, 0x06, 0x12, 0x12, 0x01, 0x11, 0x04, + 0x04, 0x1E, 0x02, 0x1A, 0x1A, 0x01, 0x1E, 0x04, 0x2B, 0x10, 0xD0, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, + 0x35, 0x23, 0x35, 0x23, 0x15, 0x23, 0x35, 0x23, 0x15, 0x23, 0x15, 0x33, + 0x15, 0x23, 0x15, 0x33, 0x15, 0x33, 0x35, 0x33, 0x15, 0x33, 0x35, 0x33, + 0x35, 0x23, 0x35, 0x23, 0x33, 0x15, 0x23, 0x02, 0x71, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, + 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0xFF, 0x83, + 0x01, 0x77, 0x02, 0xEE, 0x00, 0x13, 0x00, 0x5A, 0x40, 0x32, 0x11, 0x00, + 0x00, 0x07, 0x00, 0x0D, 0x05, 0x00, 0x10, 0x04, 0x02, 0x08, 0x03, 0x06, + 0x00, 0x06, 0x0D, 0x02, 0x09, 0x02, 0x0C, 0x10, 0x0A, 0x10, 0x03, 0x0E, + 0x13, 0x0C, 0x00, 0x08, 0x04, 0x06, 0x00, 0x06, 0x0D, 0x04, 0x01, 0x0A, + 0x02, 0x0A, 0x01, 0x00, 0x0A, 0x03, 0x00, 0x01, 0x13, 0x04, 0x00, 0x0D, + 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xFC, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x2F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x33, 0x15, 0x33, 0x35, 0x33, 0x11, 0x23, 0x35, 0x33, 0x35, + 0x23, 0x35, 0x23, 0x15, 0x23, 0x11, 0x33, 0x15, 0x23, 0x15, 0x7D, 0x7D, + 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x01, 0x77, + 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x05, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x13, 0x00, 0x5B, 0x40, 0x32, 0x10, 0x00, 0x11, 0x0C, + 0x00, 0x11, 0x09, 0x00, 0x08, 0x00, 0x00, 0x11, 0x06, 0x0D, 0x06, 0x08, + 0x02, 0x05, 0x02, 0x0E, 0x01, 0x04, 0x0C, 0x04, 0x0A, 0x12, 0x0A, 0x13, + 0x08, 0x11, 0x06, 0x00, 0x04, 0x01, 0x00, 0x04, 0x0D, 0x02, 0x12, 0x02, + 0x13, 0x00, 0x01, 0x12, 0x00, 0x07, 0x12, 0x01, 0x11, 0x04, 0x2B, 0x10, + 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x00, + 0x3F, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, + 0x31, 0x37, 0x35, 0x23, 0x15, 0x37, 0x35, 0x23, 0x15, 0x27, 0x15, 0x33, + 0x35, 0x13, 0x15, 0x33, 0x35, 0x21, 0x15, 0x33, 0x35, 0xFA, 0x7D, 0xFA, + 0x7D, 0xFA, 0x7D, 0xFA, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, + 0xFA, 0xFA, 0xFA, 0x7D, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x09, + 0x00, 0x0D, 0x00, 0x11, 0x00, 0x56, 0x40, 0x32, 0x0F, 0x0F, 0x03, 0x0E, + 0x00, 0x01, 0x0B, 0x00, 0x05, 0x07, 0x00, 0x05, 0x07, 0x07, 0x0C, 0x03, + 0x00, 0x0D, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x0C, 0x04, 0x05, 0x06, 0x01, + 0x02, 0x10, 0x01, 0x0C, 0x08, 0x01, 0x0B, 0x04, 0x06, 0x00, 0x02, 0x0C, + 0x0C, 0x01, 0x05, 0x04, 0x0C, 0x03, 0x00, 0x01, 0x0F, 0x04, 0x2B, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0x00, 0x3F, 0x3F, + 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, + 0xFC, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x25, 0x11, 0x21, 0x15, + 0x23, 0x11, 0x21, 0x35, 0x33, 0x35, 0x23, 0x15, 0x21, 0x35, 0x37, 0x15, + 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x01, 0xF4, 0x7D, 0x82, 0xFE, + 0x8E, 0xFA, 0x7D, 0xFA, 0x01, 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, + 0x7D, 0xFA, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x01, 0x77, 0x00, 0x7D, + 0x02, 0x71, 0x00, 0x03, 0x00, 0x0F, 0x40, 0x07, 0x01, 0x02, 0x03, 0x03, + 0x01, 0x02, 0x04, 0x2B, 0x00, 0x2F, 0x3F, 0x30, 0x31, 0x13, 0x23, 0x15, + 0x33, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFA, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFA, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x3B, + 0x40, 0x20, 0x0A, 0x00, 0x08, 0x05, 0x00, 0x03, 0x01, 0x00, 0x03, 0x00, + 0x00, 0x08, 0x03, 0x06, 0x08, 0x02, 0x09, 0x02, 0x06, 0x02, 0x06, 0x0A, + 0x04, 0x0B, 0x01, 0x02, 0x02, 0x01, 0x01, 0x04, 0x02, 0x0A, 0x10, 0xD0, + 0x2B, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x19, + 0x01, 0x33, 0x15, 0x33, 0x35, 0x23, 0x11, 0x37, 0x23, 0x15, 0x33, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x7D, 0x01, + 0x77, 0x7D, 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFA, + 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x3D, 0x40, 0x21, 0x08, 0x00, + 0x09, 0x05, 0x00, 0x00, 0x03, 0x00, 0x09, 0x01, 0x00, 0x00, 0x09, 0x06, + 0x00, 0x02, 0x06, 0x0A, 0x06, 0x0B, 0x04, 0x01, 0x0A, 0x02, 0x0A, 0x02, + 0x0B, 0x00, 0x09, 0x0A, 0x01, 0x09, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, + 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x11, 0x15, 0x33, + 0x11, 0x33, 0x11, 0x23, 0x35, 0x03, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x89, 0x01, 0x77, 0x7D, 0xFE, 0x0C, + 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, + 0x00, 0x13, 0x00, 0x17, 0x00, 0x1B, 0x00, 0x83, 0x40, 0x48, 0x18, 0x00, + 0x19, 0x14, 0x00, 0x15, 0x11, 0x00, 0x15, 0x0B, 0x00, 0x19, 0x07, 0x00, + 0x19, 0x05, 0x05, 0x0E, 0x03, 0x03, 0x0F, 0x0F, 0x00, 0x0E, 0x04, 0x01, + 0x00, 0x15, 0x19, 0x06, 0x09, 0x06, 0x15, 0x02, 0x00, 0x02, 0x16, 0x08, + 0x12, 0x1A, 0x12, 0x1B, 0x10, 0x08, 0x10, 0x17, 0x0C, 0x08, 0x0C, 0x17, + 0x0A, 0x14, 0x01, 0x08, 0x01, 0x1A, 0x08, 0x17, 0x06, 0x1A, 0x06, 0x1B, + 0x02, 0x1A, 0x02, 0x1B, 0x00, 0x19, 0x1A, 0x01, 0x19, 0x04, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xFC, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, + 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x10, + 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x13, 0x15, 0x33, 0x15, 0x23, + 0x15, 0x33, 0x15, 0x33, 0x15, 0x33, 0x35, 0x23, 0x35, 0x33, 0x35, 0x23, + 0x35, 0x23, 0x35, 0x17, 0x35, 0x23, 0x15, 0x03, 0x15, 0x33, 0x35, 0x7D, + 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0xFA, 0x7D, 0xFA, 0x7D, 0xFA, + 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x29, 0x40, 0x16, + 0x06, 0x06, 0x0B, 0x04, 0x04, 0x00, 0x00, 0x00, 0x0B, 0x04, 0x09, 0x06, + 0x03, 0x02, 0x03, 0x08, 0x01, 0x09, 0x09, 0x01, 0x08, 0x04, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x30, 0x31, 0x01, 0x23, 0x35, 0x23, 0x15, 0x23, 0x15, 0x33, 0x15, + 0x33, 0x35, 0x33, 0x02, 0x71, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0xFA, 0x01, + 0x77, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0x00, 0x01, 0x00, 0x00, 0xFF, 0x83, + 0x00, 0x7D, 0x00, 0x7D, 0x00, 0x03, 0x00, 0x0F, 0x40, 0x07, 0x02, 0x08, + 0x03, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x00, 0x2F, 0x3F, 0x30, 0x31, 0x35, + 0x15, 0x33, 0x35, 0x7D, 0x7D, 0xFA, 0xFA, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0xFA, 0x01, 0x77, 0x01, 0x77, 0x00, 0x03, 0x00, 0x0A, 0x40, 0x04, + 0x02, 0x00, 0x03, 0x04, 0x00, 0x2B, 0x30, 0x31, 0x25, 0x35, 0x21, 0x15, + 0x01, 0x77, 0xFE, 0x89, 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7D, 0x00, 0x7D, 0x00, 0x03, 0x00, 0x10, 0x40, 0x08, + 0x00, 0x00, 0x01, 0x06, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x00, 0x3F, 0xFC, + 0x30, 0x31, 0x35, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xFA, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, + 0x00, 0x1D, 0x40, 0x0F, 0x02, 0x06, 0x07, 0x02, 0x06, 0x01, 0x02, 0x04, + 0x02, 0x02, 0x01, 0x01, 0x04, 0x02, 0x05, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x10, 0xFC, 0x00, 0x3F, 0x3F, 0x30, 0x31, 0x19, 0x01, 0x33, 0x11, 0x35, + 0x15, 0x33, 0x35, 0x7D, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, 0x77, 0xFA, + 0xFA, 0xFA, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x03, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, 0x06, 0x00, 0x00, 0x04, + 0x00, 0x02, 0x06, 0x00, 0x02, 0x05, 0x01, 0x02, 0x04, 0x00, 0x01, 0x07, + 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, + 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, 0x33, 0x01, 0xF4, 0xFE, 0x0C, 0x01, + 0xF4, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFA, 0x02, 0x71, 0x00, 0x05, + 0x00, 0x15, 0x40, 0x0B, 0x01, 0x00, 0x00, 0x04, 0x06, 0x00, 0x02, 0x04, + 0x01, 0x03, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x30, 0x31, 0x11, + 0x15, 0x33, 0x11, 0x33, 0x11, 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, + 0x02, 0x71, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x05, 0x00, 0x03, 0x01, 0x00, 0x08, + 0x04, 0x00, 0x00, 0x09, 0x03, 0x06, 0x09, 0x02, 0x0A, 0x02, 0x04, 0x08, + 0x07, 0x01, 0x02, 0x04, 0x08, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x15, 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, 0x21, 0x11, 0x21, 0x15, + 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0xFE, 0x89, 0x01, 0x77, 0xFE, 0x0C, + 0x01, 0xF4, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x23, + 0x40, 0x14, 0x07, 0x00, 0x09, 0x03, 0x00, 0x06, 0x04, 0x01, 0x00, 0x00, + 0x09, 0x06, 0x00, 0x02, 0x02, 0x07, 0x0A, 0x01, 0x07, 0x04, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x11, + 0x15, 0x21, 0x15, 0x23, 0x15, 0x33, 0x15, 0x21, 0x15, 0x21, 0x11, 0x01, + 0x77, 0xFA, 0xFA, 0xFE, 0x89, 0x01, 0xF4, 0x02, 0x71, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x09, 0x00, 0x21, 0x40, 0x14, 0x02, 0x00, 0x07, 0x04, + 0x09, 0x06, 0x05, 0x02, 0x00, 0x02, 0x03, 0x01, 0x06, 0x04, 0x01, 0x08, + 0x09, 0x01, 0x08, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, + 0x2B, 0x30, 0x31, 0x01, 0x23, 0x15, 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, + 0x33, 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0x01, 0x77, 0x7D, 0x02, 0x71, 0xFA, + 0xFA, 0xFE, 0x89, 0xFA, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x06, 0x00, 0x08, 0x0A, + 0x00, 0x05, 0x04, 0x00, 0x00, 0x02, 0x08, 0x06, 0x02, 0x02, 0x07, 0x04, + 0x0B, 0x01, 0x04, 0x04, 0x01, 0x09, 0x09, 0x01, 0x06, 0x04, 0x2B, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, + 0x30, 0x31, 0x13, 0x21, 0x35, 0x21, 0x11, 0x21, 0x15, 0x21, 0x15, 0x21, + 0x11, 0x21, 0x7D, 0x01, 0x77, 0xFE, 0x0C, 0x01, 0x77, 0xFE, 0x89, 0x01, + 0xF4, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x01, 0x77, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x08, 0x00, 0x05, 0x07, 0x00, 0x0B, + 0x04, 0x01, 0x00, 0x03, 0x05, 0x06, 0x03, 0x02, 0x02, 0x07, 0x07, 0x01, + 0x0B, 0x04, 0x00, 0x09, 0x09, 0x01, 0x05, 0x04, 0x2B, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, + 0x13, 0x35, 0x21, 0x35, 0x21, 0x11, 0x21, 0x11, 0x07, 0x23, 0x35, 0x33, + 0x7D, 0x01, 0x77, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, 0x01, 0x77, + 0x7D, 0x7D, 0xFD, 0x8F, 0x01, 0x77, 0xFA, 0x7D, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x05, 0x00, 0x15, 0x40, 0x0B, + 0x01, 0x00, 0x00, 0x04, 0x06, 0x00, 0x02, 0x04, 0x01, 0x03, 0x04, 0x2B, + 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x30, 0x31, 0x11, 0x15, 0x33, 0x11, 0x33, + 0x11, 0xFA, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x2B, 0x40, 0x1A, 0x08, 0x00, 0x00, 0x0A, 0x00, 0x07, + 0x04, 0x04, 0x00, 0x01, 0x06, 0x00, 0x02, 0x08, 0x01, 0x01, 0x04, 0x09, + 0x03, 0x01, 0x09, 0x04, 0x05, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x10, 0xFC, 0x00, 0x3F, 0x3F, 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x19, + 0x01, 0x21, 0x11, 0x03, 0x21, 0x35, 0x21, 0x27, 0x33, 0x15, 0x23, 0x01, + 0xF4, 0x7D, 0xFF, 0x00, 0x01, 0x00, 0xFA, 0xFA, 0xFA, 0x02, 0x71, 0xFD, + 0x8F, 0x02, 0x71, 0xFE, 0x0C, 0x7D, 0xFA, 0x7D, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2A, + 0x40, 0x19, 0x08, 0x00, 0x05, 0x0B, 0x00, 0x07, 0x04, 0x01, 0x00, 0x03, + 0x06, 0x05, 0x02, 0x02, 0x07, 0x0B, 0x01, 0x07, 0x04, 0x00, 0x09, 0x05, + 0x01, 0x09, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x25, 0x15, 0x21, 0x15, 0x21, 0x11, + 0x21, 0x11, 0x37, 0x33, 0x15, 0x23, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, + 0xFE, 0x0C, 0x7D, 0xFA, 0xFA, 0xFA, 0x7D, 0x7D, 0x02, 0x71, 0xFE, 0x89, + 0xFA, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x7D, 0x00, 0x7D, 0x01, 0xF4, + 0x00, 0x03, 0x00, 0x07, 0x00, 0x1C, 0x40, 0x10, 0x07, 0x00, 0x06, 0x04, + 0x03, 0x00, 0x02, 0x04, 0x02, 0x06, 0x00, 0x05, 0x06, 0x01, 0x05, 0x04, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x2B, 0x2B, 0x30, 0x31, 0x35, 0x15, + 0x33, 0x35, 0x27, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, + 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0xFF, 0x83, 0x00, 0x7D, + 0x01, 0xF4, 0x00, 0x03, 0x00, 0x07, 0x00, 0x1A, 0x40, 0x0E, 0x07, 0x00, + 0x06, 0x04, 0x02, 0x08, 0x02, 0x06, 0x00, 0x05, 0x06, 0x01, 0x05, 0x04, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x2B, 0x30, 0x31, 0x35, 0x15, + 0x33, 0x35, 0x03, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0xFA, + 0x01, 0x77, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x8B, 0x40, 0x4D, + 0x13, 0x00, 0x0C, 0x11, 0x11, 0x0B, 0x10, 0x10, 0x0E, 0x07, 0x00, 0x05, + 0x03, 0x00, 0x05, 0x03, 0x03, 0x08, 0x01, 0x01, 0x09, 0x01, 0x01, 0x0A, + 0x09, 0x00, 0x08, 0x04, 0x0B, 0x00, 0x0A, 0x04, 0x00, 0x00, 0x12, 0x0E, + 0x00, 0x12, 0x04, 0x0E, 0x00, 0x0C, 0x05, 0x06, 0x0C, 0x02, 0x10, 0x02, + 0x0D, 0x12, 0x0D, 0x13, 0x0A, 0x02, 0x0A, 0x11, 0x08, 0x12, 0x08, 0x13, + 0x06, 0x0F, 0x01, 0x12, 0x04, 0x12, 0x04, 0x13, 0x12, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x04, 0x02, 0x11, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, + 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x11, 0x15, 0x33, 0x15, 0x33, 0x15, 0x33, + 0x35, 0x23, 0x35, 0x23, 0x35, 0x37, 0x23, 0x15, 0x33, 0x23, 0x15, 0x33, + 0x35, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x01, + 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x7D, 0x01, 0xF4, 0x01, 0xF4, 0x00, 0x03, + 0x00, 0x07, 0x00, 0x0F, 0x40, 0x08, 0x06, 0x00, 0x05, 0x04, 0x03, 0x00, + 0x02, 0x04, 0x00, 0x2B, 0x2B, 0x30, 0x31, 0x11, 0x15, 0x21, 0x35, 0x01, + 0x21, 0x35, 0x21, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, + 0xF4, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x77, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x8D, + 0x40, 0x4E, 0x11, 0x00, 0x0D, 0x10, 0x10, 0x05, 0x0C, 0x00, 0x0D, 0x0C, + 0x0C, 0x12, 0x07, 0x07, 0x04, 0x06, 0x06, 0x13, 0x05, 0x00, 0x12, 0x04, + 0x04, 0x00, 0x13, 0x04, 0x03, 0x03, 0x08, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x09, 0x09, 0x00, 0x08, 0x04, 0x09, 0x00, 0x00, 0x0D, 0x06, 0x00, 0x02, + 0x10, 0x0E, 0x0A, 0x0E, 0x0A, 0x11, 0x08, 0x12, 0x08, 0x13, 0x06, 0x01, + 0x12, 0x04, 0x12, 0x04, 0x13, 0x12, 0x01, 0x0E, 0x02, 0x0E, 0x02, 0x11, + 0x00, 0x0D, 0x0E, 0x01, 0x0D, 0x04, 0x0E, 0x11, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, + 0x2F, 0x2B, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x11, 0x15, 0x33, + 0x15, 0x33, 0x15, 0x33, 0x35, 0x23, 0x35, 0x23, 0x35, 0x03, 0x15, 0x33, + 0x3D, 0x01, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, 0x0C, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x28, 0x40, 0x18, 0x0A, 0x00, + 0x08, 0x03, 0x00, 0x06, 0x04, 0x01, 0x00, 0x00, 0x08, 0x06, 0x00, 0x02, + 0x04, 0x0B, 0x0A, 0x01, 0x0B, 0x04, 0x06, 0x01, 0x03, 0x04, 0x2B, 0x2B, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, + 0x11, 0x15, 0x21, 0x15, 0x23, 0x15, 0x21, 0x11, 0x01, 0x33, 0x35, 0x23, + 0x01, 0x77, 0xFA, 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0x7D, + 0x7D, 0x7D, 0x01, 0x77, 0xFD, 0x8F, 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x11, 0x00, 0x43, + 0x40, 0x27, 0x0F, 0x00, 0x0D, 0x0B, 0x00, 0x0D, 0x11, 0x00, 0x0A, 0x04, + 0x05, 0x00, 0x03, 0x01, 0x00, 0x03, 0x00, 0x00, 0x0D, 0x03, 0x06, 0x0D, + 0x02, 0x0E, 0x02, 0x0C, 0x11, 0x06, 0x02, 0x04, 0x0A, 0x0A, 0x01, 0x11, + 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, + 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x15, 0x21, + 0x35, 0x21, 0x11, 0x17, 0x15, 0x33, 0x35, 0x23, 0x35, 0x23, 0x15, 0x33, + 0x15, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x7D, 0xFA, 0x7D, 0xFA, 0xFA, 0x01, + 0xF4, 0xFE, 0x89, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, + 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, 0x0A, 0x00, 0x00, 0x08, + 0x00, 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x09, 0x02, 0x04, + 0x0B, 0x07, 0x01, 0x0B, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, + 0x19, 0x01, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x07, 0x23, 0x35, 0x33, + 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0xFA, + 0x02, 0x71, 0xFA, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, + 0x0D, 0x00, 0x01, 0x08, 0x00, 0x00, 0x05, 0x05, 0x0A, 0x03, 0x03, 0x0F, + 0x0A, 0x00, 0x0F, 0x04, 0x01, 0x06, 0x00, 0x02, 0x0A, 0x0E, 0x08, 0x0D, + 0x06, 0x02, 0x02, 0x01, 0x0D, 0x04, 0x0E, 0x01, 0x01, 0x04, 0x2B, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, + 0x21, 0x35, 0x23, 0x35, 0x33, 0x35, 0x07, 0x15, 0x23, 0x35, 0x17, 0x15, + 0x23, 0x35, 0x01, 0xF4, 0x7D, 0x7D, 0x82, 0xF5, 0xF5, 0xF5, 0x02, 0x71, + 0xFD, 0x8F, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x1A, 0x40, 0x0E, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, + 0x01, 0x02, 0x06, 0x01, 0x03, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, + 0x10, 0xFC, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x11, + 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0xFD, + 0x8F, 0x7D, 0x01, 0x77, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x29, 0x40, 0x18, 0x09, 0x00, + 0x03, 0x08, 0x00, 0x01, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, + 0x01, 0x02, 0x06, 0x01, 0x09, 0x04, 0x0A, 0x01, 0x03, 0x04, 0x2B, 0x2B, + 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, + 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x33, 0x11, 0x23, 0x11, 0x23, + 0x11, 0x01, 0x77, 0xFE, 0x89, 0x01, 0x77, 0x7D, 0x82, 0xF5, 0x01, 0xF4, + 0x7D, 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, 0x77, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x23, + 0x40, 0x14, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, + 0x03, 0x06, 0x01, 0x02, 0x0A, 0x06, 0x06, 0x01, 0x03, 0x04, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x30, 0x31, 0x01, + 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, 0x01, 0xF4, 0x7D, + 0xFD, 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x1E, 0x40, 0x11, 0x07, 0x00, + 0x06, 0x04, 0x00, 0x00, 0x01, 0x04, 0x06, 0x01, 0x02, 0x08, 0x04, 0x04, + 0x01, 0x03, 0x04, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, + 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x33, 0x35, 0x33, 0x35, 0x23, 0x35, + 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0xFA, 0xFA, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, + 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x26, 0x40, 0x17, 0x07, 0x00, 0x0A, 0x04, + 0x01, 0x00, 0x03, 0x00, 0x00, 0x05, 0x06, 0x03, 0x02, 0x02, 0x06, 0x06, + 0x01, 0x0B, 0x04, 0x00, 0x01, 0x05, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x30, 0x31, 0x37, 0x11, 0x21, 0x35, + 0x21, 0x11, 0x21, 0x11, 0x23, 0x15, 0x33, 0x15, 0x7D, 0x01, 0x77, 0xFE, + 0x0C, 0x01, 0xF4, 0xFA, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0xFD, 0x8F, 0x01, + 0x77, 0x7D, 0x7D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, 0x40, 0x18, 0x01, 0x00, 0x08, 0x04, + 0x0A, 0x06, 0x05, 0x06, 0x0B, 0x02, 0x03, 0x02, 0x02, 0x06, 0x06, 0x01, + 0x05, 0x04, 0x00, 0x09, 0x0A, 0x01, 0x09, 0x04, 0x2B, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x30, 0x31, 0x01, 0x15, + 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x01, 0x77, + 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFD, 0x8F, 0xFA, + 0xFA, 0x02, 0x71, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, + 0x02, 0x71, 0x00, 0x03, 0x00, 0x10, 0x40, 0x08, 0x02, 0x06, 0x03, 0x02, + 0x02, 0x01, 0x01, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x30, 0x31, 0x19, 0x01, + 0x33, 0x11, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x05, 0x00, 0x13, + 0x40, 0x0A, 0x01, 0x00, 0x03, 0x06, 0x05, 0x02, 0x04, 0x01, 0x01, 0x04, + 0x2B, 0x00, 0x3F, 0x3F, 0xFC, 0x30, 0x31, 0x13, 0x11, 0x23, 0x15, 0x21, + 0x11, 0xFA, 0xFA, 0x01, 0x77, 0x02, 0x71, 0xFE, 0x0C, 0x7D, 0x02, 0x71, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0E, 0x0E, 0x04, 0x02, + 0x02, 0x0A, 0x04, 0x00, 0x0A, 0x04, 0x0B, 0x06, 0x00, 0x06, 0x0D, 0x02, + 0x06, 0x02, 0x0A, 0x0E, 0x08, 0x0F, 0x03, 0x0E, 0x0F, 0x01, 0x0E, 0x04, + 0x01, 0x06, 0x06, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, 0x35, 0x23, + 0x35, 0x23, 0x01, 0x35, 0x23, 0x15, 0x13, 0x23, 0x15, 0x33, 0x7D, 0xFA, + 0xFA, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0xFD, + 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x77, 0x02, 0x71, 0x00, 0x05, 0x00, 0x13, 0x40, 0x0A, 0x00, 0x00, + 0x03, 0x06, 0x02, 0x02, 0x00, 0x01, 0x03, 0x04, 0x2B, 0x00, 0x3F, 0x3F, + 0xFC, 0x30, 0x31, 0x37, 0x11, 0x23, 0x11, 0x21, 0x35, 0x7D, 0x7D, 0x01, + 0x77, 0x7D, 0x01, 0xF4, 0xFD, 0x8F, 0x7D, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x1A, + 0x07, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0A, 0x06, 0x05, 0x06, 0x01, 0x06, + 0x00, 0x02, 0x0A, 0x01, 0x09, 0x04, 0x06, 0x01, 0x05, 0x04, 0x02, 0x01, + 0x01, 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, + 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, + 0x33, 0x11, 0x33, 0x11, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFD, + 0x8F, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x02, 0x71, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x1D, 0x40, 0x11, 0x03, 0x00, 0x00, 0x06, 0x06, 0x01, 0x06, 0x00, + 0x02, 0x06, 0x01, 0x05, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, + 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x11, 0x33, + 0x11, 0x33, 0x11, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x01, 0xF4, + 0xFE, 0x0C, 0x02, 0x71, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, 0x06, 0x00, + 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, 0x02, 0x05, 0x01, 0x02, 0x04, 0x00, + 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, + 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, 0x33, 0x01, 0xF4, 0xFE, + 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0x7D, 0x01, + 0x77, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x05, 0x00, 0x09, 0x00, 0x23, 0x40, 0x15, 0x08, 0x00, 0x00, 0x06, + 0x00, 0x04, 0x04, 0x02, 0x06, 0x00, 0x02, 0x07, 0x02, 0x05, 0x01, 0x09, + 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, 0x21, 0x11, 0x07, + 0x23, 0x35, 0x33, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, + 0x8F, 0xFA, 0x01, 0x77, 0xFA, 0x7D, 0x00, 0x02, 0x00, 0x00, 0xFF, 0x83, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x32, 0x40, 0x1D, + 0x0A, 0x00, 0x03, 0x08, 0x00, 0x05, 0x07, 0x08, 0x05, 0x06, 0x01, 0x06, + 0x03, 0x02, 0x08, 0x00, 0x09, 0x01, 0x05, 0x04, 0x03, 0x01, 0x00, 0x00, + 0x01, 0x07, 0x04, 0x00, 0x0B, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x05, 0x35, 0x33, 0x11, 0x21, 0x11, 0x33, 0x15, 0x37, 0x23, 0x11, 0x33, + 0x01, 0x77, 0x7D, 0xFE, 0x0C, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x02, + 0x71, 0xFD, 0x8F, 0x7D, 0xFA, 0x01, 0x77, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x41, + 0x40, 0x25, 0x0E, 0x00, 0x05, 0x0C, 0x0C, 0x03, 0x01, 0x01, 0x0A, 0x03, + 0x00, 0x0A, 0x04, 0x0B, 0x06, 0x07, 0x06, 0x05, 0x02, 0x0D, 0x08, 0x08, + 0x01, 0x07, 0x04, 0x05, 0x00, 0x02, 0x0B, 0x01, 0x04, 0x00, 0x04, 0x04, + 0x01, 0x0C, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x35, 0x23, 0x35, 0x33, 0x35, 0x21, + 0x11, 0x33, 0x35, 0x33, 0x15, 0x03, 0x23, 0x35, 0x33, 0x01, 0xF4, 0x7D, + 0x7D, 0xFE, 0x0C, 0x7D, 0xFA, 0x05, 0xF5, 0xF5, 0xFA, 0x7D, 0xFA, 0xFD, + 0x8F, 0xFA, 0xFA, 0x01, 0x77, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x06, 0x00, + 0x08, 0x0A, 0x00, 0x05, 0x04, 0x00, 0x00, 0x02, 0x08, 0x06, 0x02, 0x02, + 0x07, 0x04, 0x0B, 0x01, 0x04, 0x04, 0x01, 0x09, 0x09, 0x01, 0x06, 0x04, + 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, + 0x10, 0xFC, 0x30, 0x31, 0x13, 0x21, 0x35, 0x21, 0x11, 0x21, 0x15, 0x21, + 0x15, 0x21, 0x11, 0x21, 0x7D, 0x01, 0x77, 0xFE, 0x0C, 0x01, 0x77, 0xFE, + 0x89, 0x01, 0xF4, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, + 0x01, 0x77, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x1A, 0x40, 0x0E, 0x06, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x05, 0x06, 0x00, 0x02, 0x05, 0x01, 0x04, 0x04, 0x2B, 0x00, 0x3F, 0x3F, + 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, 0x15, 0x33, 0x11, 0x33, + 0x11, 0x33, 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0x7D, + 0xFE, 0x0C, 0x01, 0xF4, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x07, 0x00, 0x1B, 0x40, 0x10, 0x01, 0x00, 0x05, 0x06, + 0x07, 0x02, 0x03, 0x02, 0x02, 0x01, 0x05, 0x04, 0x06, 0x01, 0x01, 0x04, + 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, 0x30, 0x31, 0x01, 0x11, 0x23, + 0x11, 0x23, 0x11, 0x21, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0xF4, 0x02, + 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x02, 0x71, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x2D, 0x40, 0x1A, 0x09, 0x00, 0x00, 0x06, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x06, 0x0B, 0x02, 0x04, 0x02, 0x01, 0x09, 0x0A, 0x01, 0x09, 0x04, + 0x00, 0x03, 0x03, 0x01, 0x06, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x3B, + 0x01, 0x35, 0x23, 0x11, 0x23, 0x11, 0x33, 0x13, 0x11, 0x33, 0x11, 0x7D, + 0xFA, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, 0x40, 0x19, 0x07, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x06, 0x0A, 0x02, 0x05, 0x02, 0x01, 0x02, 0x08, + 0x01, 0x0B, 0x04, 0x04, 0x01, 0x07, 0x04, 0x00, 0x01, 0x03, 0x04, 0x2B, + 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x21, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, + 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFE, 0x0C, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, + 0x00, 0x50, 0x40, 0x2C, 0x10, 0x10, 0x04, 0x09, 0x09, 0x0F, 0x07, 0x07, + 0x04, 0x01, 0x01, 0x0F, 0x04, 0x00, 0x0F, 0x04, 0x0E, 0x06, 0x00, 0x06, + 0x12, 0x02, 0x05, 0x02, 0x0A, 0x13, 0x08, 0x0E, 0x06, 0x0D, 0x04, 0x0E, + 0x0E, 0x01, 0x0D, 0x04, 0x02, 0x13, 0x00, 0x10, 0x10, 0x01, 0x13, 0x04, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x21, 0x35, + 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x15, 0x25, 0x15, + 0x33, 0x35, 0x25, 0x35, 0x23, 0x15, 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0x7D, + 0xFA, 0xFE, 0x89, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, + 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, + 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, 0x04, 0x09, 0x06, 0x0B, 0x02, 0x03, + 0x02, 0x08, 0x05, 0x02, 0x01, 0x05, 0x04, 0x00, 0x07, 0x0A, 0x01, 0x07, + 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xFC, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, + 0x21, 0x15, 0x21, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0xFE, 0x89, + 0x01, 0xF4, 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x40, 0x40, 0x24, 0x0F, 0x0F, 0x05, 0x0A, + 0x00, 0x08, 0x06, 0x06, 0x0D, 0x05, 0x00, 0x0D, 0x04, 0x03, 0x00, 0x01, + 0x08, 0x06, 0x01, 0x02, 0x0C, 0x0B, 0x09, 0x00, 0x04, 0x0E, 0x02, 0x08, + 0x0B, 0x01, 0x08, 0x04, 0x00, 0x01, 0x0E, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x35, + 0x21, 0x15, 0x21, 0x15, 0x07, 0x23, 0x15, 0x21, 0x35, 0x21, 0x35, 0x33, + 0x35, 0x23, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0xF4, + 0xFE, 0x89, 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, + 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0xFF, 0x83, 0x00, 0xFA, 0x02, 0xEE, + 0x00, 0x07, 0x00, 0x17, 0x40, 0x0D, 0x05, 0x00, 0x03, 0x01, 0x00, 0x00, + 0x04, 0x03, 0x08, 0x06, 0x01, 0x03, 0x04, 0x2B, 0x00, 0x3F, 0x2B, 0x10, + 0xFC, 0x30, 0x31, 0x13, 0x35, 0x23, 0x11, 0x33, 0x35, 0x23, 0x11, 0xFA, + 0xFA, 0xFA, 0x7D, 0x02, 0x71, 0x7D, 0xFC, 0x95, 0x7D, 0x02, 0x71, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFA, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x07, 0x00, 0x1D, 0x40, 0x0F, 0x02, 0x06, 0x07, 0x02, 0x06, 0x01, + 0x02, 0x04, 0x02, 0x02, 0x01, 0x01, 0x04, 0x02, 0x05, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xFC, 0x00, 0x3F, 0x3F, 0x30, 0x31, 0x19, 0x01, 0x33, + 0x11, 0x35, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, + 0x77, 0xFA, 0xFA, 0xFA, 0x00, 0x01, 0x00, 0x00, 0xFF, 0x83, 0x00, 0xFA, + 0x02, 0xEE, 0x00, 0x07, 0x00, 0x17, 0x40, 0x0D, 0x02, 0x00, 0x04, 0x06, + 0x00, 0x01, 0x04, 0x04, 0x08, 0x05, 0x01, 0x02, 0x04, 0x2B, 0x00, 0x3F, + 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x11, 0x33, 0x11, 0x23, 0x15, 0x33, 0x11, + 0x23, 0x7D, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0x7D, 0x03, 0x6B, + 0x00, 0x03, 0x00, 0x00, 0x01, 0x77, 0x01, 0x77, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x47, 0x40, 0x27, 0x0B, 0x00, 0x09, 0x08, + 0x08, 0x07, 0x04, 0x00, 0x09, 0x03, 0x00, 0x09, 0x01, 0x01, 0x06, 0x00, + 0x00, 0x07, 0x07, 0x00, 0x06, 0x04, 0x09, 0x02, 0x0A, 0x06, 0x09, 0x00, + 0x03, 0x01, 0x00, 0x01, 0x06, 0x06, 0x01, 0x05, 0x04, 0x06, 0x0B, 0x10, + 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xD0, + 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x13, 0x15, 0x33, 0x35, 0x21, 0x15, 0x33, + 0x35, 0x33, 0x35, 0x23, 0x15, 0xFA, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, + 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x71, 0x00, 0x7D, 0x00, 0x03, 0x00, 0x0B, 0x40, 0x04, + 0x00, 0x00, 0x01, 0x06, 0x00, 0x3F, 0xFC, 0x30, 0x31, 0x35, 0x15, 0x21, + 0x35, 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x01, 0x77, + 0x00, 0xFA, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x29, 0x40, 0x17, + 0x07, 0x00, 0x05, 0x04, 0x04, 0x03, 0x03, 0x00, 0x02, 0x04, 0x00, 0x00, + 0x05, 0x02, 0x05, 0x00, 0x03, 0x01, 0x00, 0x00, 0x01, 0x07, 0x04, 0x2B, + 0x10, 0xFC, 0x10, 0xD0, 0x00, 0x3F, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xFC, 0x30, 0x31, 0x13, 0x15, 0x33, 0x35, 0x23, 0x35, 0x23, 0x15, 0x7D, + 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x2A, 0x40, 0x19, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x04, 0x06, + 0x06, 0x01, 0x06, 0x00, 0x02, 0x09, 0x02, 0x04, 0x0B, 0x07, 0x01, 0x0B, + 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, + 0x33, 0x15, 0x33, 0x11, 0x07, 0x23, 0x35, 0x33, 0x7D, 0xFA, 0x7D, 0x7D, + 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x7D, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0D, 0x00, 0x01, 0x08, + 0x00, 0x00, 0x05, 0x05, 0x0A, 0x03, 0x03, 0x0F, 0x0A, 0x00, 0x0F, 0x04, + 0x01, 0x06, 0x00, 0x02, 0x0A, 0x0E, 0x08, 0x0D, 0x06, 0x02, 0x02, 0x01, + 0x0D, 0x04, 0x0E, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x21, 0x35, 0x23, 0x35, + 0x33, 0x35, 0x07, 0x15, 0x23, 0x35, 0x17, 0x15, 0x23, 0x35, 0x01, 0xF4, + 0x7D, 0x7D, 0x82, 0xF5, 0xF5, 0xF5, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0x7D, + 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1A, 0x40, 0x0E, + 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x06, 0x01, + 0x03, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x11, 0x01, 0xF4, 0xFE, 0x0C, + 0x01, 0xF4, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x01, 0x77, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x29, 0x40, 0x18, 0x09, 0x00, 0x03, 0x08, 0x00, 0x01, + 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x06, 0x01, + 0x09, 0x04, 0x0A, 0x01, 0x03, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x10, + 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x35, 0x21, + 0x11, 0x21, 0x35, 0x33, 0x11, 0x23, 0x11, 0x23, 0x11, 0x01, 0x77, 0xFE, + 0x89, 0x01, 0x77, 0x7D, 0x82, 0xF5, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, + 0x01, 0x77, 0xFE, 0x89, 0x01, 0x77, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x23, 0x40, 0x14, 0x09, 0x00, + 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, + 0x0A, 0x06, 0x06, 0x01, 0x03, 0x04, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, + 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, + 0xF4, 0xFE, 0x89, 0xFA, 0xFA, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x7D, + 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x09, 0x00, 0x1E, 0x40, 0x11, 0x07, 0x00, 0x06, 0x04, 0x00, 0x00, + 0x01, 0x04, 0x06, 0x01, 0x02, 0x08, 0x04, 0x04, 0x01, 0x03, 0x04, 0x2B, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x30, 0x31, 0x01, 0x35, + 0x21, 0x11, 0x33, 0x35, 0x33, 0x35, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x0C, + 0x7D, 0xFA, 0xFA, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0xFA, 0x7D, 0x7D, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, + 0x00, 0x26, 0x40, 0x17, 0x07, 0x00, 0x0A, 0x04, 0x01, 0x00, 0x03, 0x00, + 0x00, 0x05, 0x06, 0x03, 0x02, 0x02, 0x06, 0x06, 0x01, 0x0B, 0x04, 0x00, + 0x01, 0x05, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0xFC, 0x10, + 0xFC, 0x2B, 0x30, 0x31, 0x37, 0x11, 0x21, 0x35, 0x21, 0x11, 0x21, 0x11, + 0x23, 0x15, 0x33, 0x15, 0x7D, 0x01, 0x77, 0xFE, 0x0C, 0x01, 0xF4, 0xFA, + 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0xFD, 0x8F, 0x01, 0x77, 0x7D, 0x7D, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, + 0x00, 0x28, 0x40, 0x18, 0x01, 0x00, 0x08, 0x04, 0x0A, 0x06, 0x05, 0x06, + 0x0B, 0x02, 0x03, 0x02, 0x02, 0x06, 0x06, 0x01, 0x05, 0x04, 0x00, 0x09, + 0x0A, 0x01, 0x09, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x3F, 0x3F, 0x2B, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, + 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0xFA, + 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x10, 0x40, 0x08, 0x02, 0x06, 0x03, 0x02, 0x02, 0x01, 0x01, 0x04, + 0x2B, 0x00, 0x3F, 0x3F, 0x30, 0x31, 0x19, 0x01, 0x33, 0x11, 0x7D, 0x02, + 0x71, 0xFD, 0x8F, 0x02, 0x71, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x77, 0x02, 0x71, 0x00, 0x05, 0x00, 0x13, 0x40, 0x0A, 0x01, 0x00, + 0x03, 0x06, 0x05, 0x02, 0x04, 0x01, 0x01, 0x04, 0x2B, 0x00, 0x3F, 0x3F, + 0xFC, 0x30, 0x31, 0x13, 0x11, 0x23, 0x15, 0x21, 0x11, 0xFA, 0xFA, 0x01, + 0x77, 0x02, 0x71, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x3C, 0x40, 0x22, 0x0E, 0x0E, 0x04, 0x02, 0x02, 0x0A, 0x04, 0x00, + 0x0A, 0x04, 0x0B, 0x06, 0x00, 0x06, 0x0D, 0x02, 0x06, 0x02, 0x0A, 0x0E, + 0x08, 0x0F, 0x03, 0x0E, 0x0F, 0x01, 0x0E, 0x04, 0x01, 0x06, 0x06, 0x01, + 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, 0x35, 0x23, 0x35, 0x23, 0x01, 0x35, + 0x23, 0x15, 0x13, 0x23, 0x15, 0x33, 0x7D, 0xFA, 0xFA, 0x7D, 0x01, 0xF4, + 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, + 0x71, 0xFA, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, + 0x00, 0x05, 0x00, 0x13, 0x40, 0x0A, 0x00, 0x00, 0x03, 0x06, 0x02, 0x02, + 0x00, 0x01, 0x03, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0xFC, 0x30, 0x31, 0x37, + 0x11, 0x23, 0x11, 0x21, 0x35, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x01, 0xF4, + 0xFD, 0x8F, 0x7D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x1A, 0x07, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x0A, 0x06, 0x05, 0x06, 0x01, 0x06, 0x00, 0x02, 0x0A, 0x01, + 0x09, 0x04, 0x06, 0x01, 0x05, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, + 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x19, 0x01, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x01, 0xF4, 0xFE, + 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x02, 0x71, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, + 0x03, 0x00, 0x00, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x06, 0x01, 0x05, + 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x10, + 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, 0x7D, + 0xFA, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x01, 0xF4, 0xFE, 0x0C, 0x02, 0x71, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, + 0x06, 0x00, 0x02, 0x05, 0x01, 0x02, 0x04, 0x00, 0x01, 0x07, 0x04, 0x2B, + 0x2B, 0x00, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, 0x11, + 0x21, 0x27, 0x23, 0x11, 0x33, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, + 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, + 0x00, 0x23, 0x40, 0x15, 0x08, 0x00, 0x00, 0x06, 0x00, 0x04, 0x04, 0x02, + 0x06, 0x00, 0x02, 0x07, 0x02, 0x05, 0x01, 0x09, 0x04, 0x02, 0x01, 0x01, + 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, + 0x31, 0x19, 0x01, 0x33, 0x35, 0x21, 0x11, 0x07, 0x23, 0x35, 0x33, 0x7D, + 0x01, 0x77, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0x01, 0x77, + 0xFA, 0x7D, 0x00, 0x02, 0x00, 0x00, 0xFF, 0x83, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x32, 0x40, 0x1D, 0x0A, 0x00, 0x03, 0x08, + 0x00, 0x05, 0x07, 0x08, 0x05, 0x06, 0x01, 0x06, 0x03, 0x02, 0x08, 0x00, + 0x09, 0x01, 0x05, 0x04, 0x03, 0x01, 0x00, 0x00, 0x01, 0x07, 0x04, 0x00, + 0x0B, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x05, 0x35, 0x33, 0x11, + 0x21, 0x11, 0x33, 0x15, 0x37, 0x23, 0x11, 0x33, 0x01, 0x77, 0x7D, 0xFE, + 0x0C, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x7D, + 0xFA, 0x01, 0x77, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x41, 0x40, 0x25, 0x0E, 0x00, + 0x05, 0x0C, 0x0C, 0x03, 0x01, 0x01, 0x0A, 0x03, 0x00, 0x0A, 0x04, 0x0B, + 0x06, 0x07, 0x06, 0x05, 0x02, 0x0D, 0x08, 0x08, 0x01, 0x07, 0x04, 0x05, + 0x00, 0x02, 0x0B, 0x01, 0x04, 0x00, 0x04, 0x04, 0x01, 0x0C, 0x04, 0x2B, + 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, + 0x31, 0x21, 0x35, 0x23, 0x35, 0x33, 0x35, 0x21, 0x11, 0x33, 0x35, 0x33, + 0x15, 0x03, 0x23, 0x35, 0x33, 0x01, 0xF4, 0x7D, 0x7D, 0xFE, 0x0C, 0x7D, + 0xFA, 0x05, 0xF5, 0xF5, 0xFA, 0x7D, 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x01, + 0x77, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x06, 0x00, 0x08, 0x0A, 0x00, 0x05, + 0x04, 0x00, 0x00, 0x02, 0x08, 0x06, 0x02, 0x02, 0x07, 0x04, 0x0B, 0x01, + 0x04, 0x04, 0x01, 0x09, 0x09, 0x01, 0x06, 0x04, 0x2B, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, + 0x13, 0x21, 0x35, 0x21, 0x11, 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, 0x21, + 0x7D, 0x01, 0x77, 0xFE, 0x0C, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0xFE, + 0x89, 0x01, 0xF4, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x01, 0x77, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1A, + 0x40, 0x0E, 0x06, 0x00, 0x00, 0x02, 0x00, 0x00, 0x05, 0x06, 0x00, 0x02, + 0x05, 0x01, 0x04, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x01, 0x21, 0x15, 0x33, 0x11, 0x33, 0x11, 0x33, 0x01, 0x77, + 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, 0x01, 0xF4, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x1B, 0x40, 0x10, 0x01, 0x00, 0x05, 0x06, 0x07, 0x02, 0x03, 0x02, + 0x02, 0x01, 0x05, 0x04, 0x06, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x3F, + 0x3F, 0x3F, 0xFC, 0x30, 0x31, 0x01, 0x11, 0x23, 0x11, 0x23, 0x11, 0x21, + 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0xF4, 0x02, 0x71, 0xFE, 0x0C, 0x01, + 0xF4, 0xFD, 0x8F, 0x02, 0x71, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2D, 0x40, 0x1A, + 0x09, 0x00, 0x00, 0x06, 0x00, 0x00, 0x02, 0x00, 0x00, 0x06, 0x0B, 0x02, + 0x04, 0x02, 0x01, 0x09, 0x0A, 0x01, 0x09, 0x04, 0x00, 0x03, 0x03, 0x01, + 0x06, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, + 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x3B, 0x01, 0x35, 0x23, 0x11, + 0x23, 0x11, 0x33, 0x13, 0x11, 0x33, 0x11, 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, + 0xFA, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, + 0xF4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x28, 0x40, 0x19, 0x07, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x06, 0x0A, 0x02, 0x05, 0x02, 0x01, 0x02, 0x08, 0x01, 0x0B, 0x04, 0x04, + 0x01, 0x07, 0x04, 0x00, 0x01, 0x03, 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, + 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x11, 0x23, 0x11, + 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x02, 0x71, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, + 0xF4, 0xFD, 0x8F, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x50, 0x40, 0x2C, + 0x10, 0x10, 0x04, 0x09, 0x09, 0x0F, 0x07, 0x07, 0x04, 0x01, 0x01, 0x0F, + 0x04, 0x00, 0x0F, 0x04, 0x0E, 0x06, 0x00, 0x06, 0x12, 0x02, 0x05, 0x02, + 0x0A, 0x13, 0x08, 0x0E, 0x06, 0x0D, 0x04, 0x0E, 0x0E, 0x01, 0x0D, 0x04, + 0x02, 0x13, 0x00, 0x10, 0x10, 0x01, 0x13, 0x04, 0x2B, 0x10, 0xD0, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, + 0x23, 0x15, 0x33, 0x15, 0x33, 0x15, 0x25, 0x15, 0x33, 0x35, 0x25, 0x35, + 0x23, 0x15, 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFE, 0x89, 0x7D, + 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, + 0x7D, 0xFA, 0xFA, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, 0x07, 0x00, 0x09, 0x01, + 0x00, 0x06, 0x04, 0x09, 0x06, 0x0B, 0x02, 0x03, 0x02, 0x08, 0x05, 0x02, + 0x01, 0x05, 0x04, 0x00, 0x07, 0x0A, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, + 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, + 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0x02, 0x71, + 0xFA, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x40, 0x40, 0x24, 0x0F, 0x0F, 0x05, 0x0A, 0x00, 0x08, 0x06, 0x06, + 0x0D, 0x05, 0x00, 0x0D, 0x04, 0x03, 0x00, 0x01, 0x08, 0x06, 0x01, 0x02, + 0x0C, 0x0B, 0x09, 0x00, 0x04, 0x0E, 0x02, 0x08, 0x0B, 0x01, 0x08, 0x04, + 0x00, 0x01, 0x0E, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x35, 0x21, 0x15, 0x21, 0x15, + 0x07, 0x23, 0x15, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, 0x01, 0xF4, + 0xFE, 0x0C, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, + 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x00, 0x04, + 0x00, 0x00, 0xFF, 0x83, 0x01, 0x77, 0x02, 0xEE, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x13, 0x00, 0x65, 0x40, 0x37, 0x10, 0x00, 0x11, 0x09, + 0x09, 0x0F, 0x0E, 0x00, 0x0F, 0x04, 0x08, 0x08, 0x03, 0x01, 0x01, 0x06, + 0x03, 0x00, 0x06, 0x04, 0x00, 0x00, 0x11, 0x08, 0x10, 0x08, 0x0E, 0x08, + 0x0E, 0x11, 0x0C, 0x12, 0x01, 0x08, 0x0A, 0x02, 0x07, 0x02, 0x06, 0x0B, + 0x00, 0x08, 0x00, 0x11, 0x08, 0x01, 0x02, 0x08, 0x11, 0x02, 0x01, 0x05, + 0x04, 0x02, 0x0B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x33, + 0x35, 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x13, 0x35, 0x23, 0x15, 0x37, + 0x35, 0x23, 0x15, 0x11, 0x15, 0x33, 0x35, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0x01, 0x77, 0xFA, 0xFA, + 0xFA, 0x7D, 0x7D, 0xFD, 0x8F, 0x7D, 0x7D, 0x00, 0x00, 0x01, 0x00, 0x00, + 0xFF, 0x83, 0x00, 0x7D, 0x02, 0xEE, 0x00, 0x03, 0x00, 0x0F, 0x40, 0x07, + 0x02, 0x08, 0x03, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x00, 0x2F, 0x3F, 0x30, + 0x31, 0x19, 0x01, 0x33, 0x11, 0x7D, 0x02, 0xEE, 0xFC, 0x95, 0x03, 0x6B, + 0x00, 0x03, 0x00, 0x00, 0xFF, 0x83, 0x01, 0x77, 0x02, 0xEE, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x13, 0x00, 0x67, 0x40, 0x38, 0x10, 0x00, 0x11, 0x0C, + 0x00, 0x11, 0x03, 0x03, 0x08, 0x05, 0x00, 0x08, 0x04, 0x01, 0x01, 0x09, + 0x00, 0x00, 0x0E, 0x09, 0x00, 0x0E, 0x04, 0x11, 0x08, 0x0E, 0x12, 0x0E, + 0x13, 0x0A, 0x0C, 0x0A, 0x0D, 0x08, 0x12, 0x08, 0x13, 0x06, 0x11, 0x04, + 0x12, 0x04, 0x13, 0x02, 0x0C, 0x02, 0x0D, 0x00, 0x01, 0x0C, 0x01, 0x12, + 0x12, 0x01, 0x11, 0x04, 0x2B, 0x10, 0xFC, 0xFC, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x30, + 0x31, 0x25, 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, + 0x1D, 0x01, 0x35, 0x23, 0x15, 0x23, 0x15, 0x33, 0x35, 0x01, 0x77, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, + 0xFA, 0x7D, 0xFA, 0xFA, 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x00, 0xFA, 0x01, 0xF4, 0x01, 0xF4, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x69, 0x40, 0x38, 0x0D, 0x0D, 0x03, 0x08, 0x08, 0x03, 0x08, 0x08, + 0x0E, 0x05, 0x05, 0x0A, 0x01, 0x01, 0x0F, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x0E, 0x03, 0x00, 0x0A, 0x04, 0x03, 0x03, 0x0E, 0x0F, 0x00, 0x0E, 0x04, + 0x0E, 0x01, 0x06, 0x0C, 0x06, 0x01, 0x00, 0x06, 0x0D, 0x04, 0x00, 0x02, + 0x0A, 0x02, 0x0B, 0x00, 0x01, 0x0A, 0x00, 0x05, 0x0A, 0x01, 0x09, 0x04, + 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xFC, 0x00, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x13, + 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x35, 0x21, 0x15, 0x33, 0x35, 0x37, + 0x15, 0x33, 0x35, 0xFA, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0xFA, 0x7D, + 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x01, 0xF4, 0x00, 0x0B, + 0x00, 0x28, 0x40, 0x15, 0x05, 0x05, 0x0A, 0x03, 0x03, 0x0B, 0x0B, 0x00, + 0x0A, 0x04, 0x08, 0x06, 0x02, 0x02, 0x07, 0x00, 0x08, 0x08, 0x01, 0x07, + 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x2F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x13, 0x35, 0x23, 0x15, 0x23, 0x15, + 0x33, 0x15, 0x33, 0x35, 0x33, 0x35, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0xFA, 0xFA, 0x7D, 0x00, 0x02, 0x00, 0x00, + 0x00, 0xFA, 0x01, 0x77, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x1C, + 0x40, 0x11, 0x04, 0x00, 0x00, 0x06, 0x00, 0x02, 0x04, 0x00, 0x02, 0x02, + 0x01, 0x06, 0x04, 0x07, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x2B, + 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x21, 0x11, 0x07, 0x33, 0x15, 0x23, + 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0x02, 0x71, 0xFE, 0x89, 0x01, 0x77, 0x7D, + 0x7D, 0x00, 0x00, 0x01, 0x00, 0x00, 0xFF, 0x83, 0x01, 0x77, 0x02, 0x71, + 0x00, 0x0F, 0x00, 0x3D, 0x40, 0x22, 0x09, 0x00, 0x07, 0x01, 0x01, 0x0D, + 0x0D, 0x00, 0x0C, 0x04, 0x06, 0x08, 0x07, 0x06, 0x03, 0x06, 0x0F, 0x02, + 0x0A, 0x04, 0x0A, 0x01, 0x06, 0x0E, 0x01, 0x04, 0x00, 0x04, 0x04, 0x01, + 0x03, 0x04, 0x04, 0x01, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x13, 0x15, 0x23, 0x11, 0x33, 0x15, 0x33, + 0x35, 0x33, 0x35, 0x23, 0x35, 0x33, 0x35, 0x23, 0x35, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0xFA, 0xFA, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, + 0x7D, 0xFA, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x0D, 0x00, 0x32, 0x40, 0x1D, 0x0A, 0x00, 0x0C, 0x04, + 0x00, 0x00, 0x02, 0x02, 0x07, 0x08, 0x00, 0x07, 0x04, 0x00, 0x06, 0x0C, + 0x02, 0x0B, 0x03, 0x05, 0x0A, 0x0A, 0x01, 0x0D, 0x04, 0x02, 0x01, 0x03, + 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, + 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x35, 0x23, + 0x15, 0x23, 0x35, 0x33, 0x35, 0x23, 0x35, 0x33, 0x35, 0x21, 0x01, 0xF4, + 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFE, 0x89, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0xFF, 0x06, 0x01, 0x77, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x39, 0x40, 0x22, 0x0C, 0x00, 0x02, 0x0A, + 0x00, 0x00, 0x08, 0x00, 0x0F, 0x04, 0x04, 0x00, 0x07, 0x04, 0x02, 0x06, + 0x00, 0x02, 0x09, 0x0D, 0x05, 0x02, 0x03, 0x0F, 0x0D, 0x01, 0x02, 0x04, + 0x00, 0x08, 0x08, 0x01, 0x0F, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x2B, 0x10, 0xFC, 0x10, + 0xFC, 0x30, 0x31, 0x01, 0x21, 0x11, 0x33, 0x15, 0x23, 0x15, 0x21, 0x11, + 0x23, 0x35, 0x33, 0x03, 0x23, 0x35, 0x33, 0x01, 0x77, 0xFE, 0x89, 0xFA, + 0xFA, 0x01, 0x77, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, + 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x89, 0x7D, 0x00, 0x01, 0x00, 0x00, + 0x00, 0xFA, 0x00, 0x7D, 0x01, 0x77, 0x00, 0x03, 0x00, 0x0F, 0x40, 0x08, + 0x03, 0x00, 0x02, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x00, 0x2B, 0x30, + 0x31, 0x11, 0x15, 0x33, 0x35, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x09, 0x00, 0x0D, + 0x00, 0x30, 0x40, 0x1E, 0x0C, 0x00, 0x08, 0x04, 0x00, 0x08, 0x0A, 0x00, + 0x01, 0x04, 0x07, 0x06, 0x02, 0x06, 0x08, 0x02, 0x0C, 0x01, 0x09, 0x04, + 0x07, 0x01, 0x06, 0x04, 0x01, 0x0D, 0x04, 0x01, 0x0D, 0x04, 0x2B, 0x10, + 0xD0, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x35, 0x33, 0x15, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, 0x21, + 0x17, 0x23, 0x35, 0x33, 0xFA, 0x7D, 0x7D, 0x7D, 0xFD, 0x8F, 0xFA, 0x7D, + 0x7D, 0xFA, 0xFA, 0x01, 0xF4, 0xFE, 0x0C, 0x02, 0x71, 0xFA, 0x7D, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x09, 0x00, 0x1D, 0x40, 0x11, 0x07, 0x00, 0x00, 0x05, 0x00, 0x01, + 0x06, 0x00, 0x02, 0x03, 0x01, 0x08, 0x04, 0x06, 0x01, 0x01, 0x04, 0x2B, + 0x2B, 0x00, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x21, + 0x11, 0x07, 0x15, 0x23, 0x11, 0x33, 0x15, 0x01, 0xF4, 0xFA, 0x7D, 0xFA, + 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0xFA, 0xFA, 0x01, 0x77, 0x7D, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x0B, 0x00, 0x28, 0x40, 0x18, 0x0A, 0x00, 0x00, 0x06, 0x00, 0x09, + 0x04, 0x04, 0x00, 0x02, 0x00, 0x06, 0x02, 0x02, 0x05, 0x0A, 0x04, 0x01, + 0x03, 0x04, 0x01, 0x01, 0x0A, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x11, 0x21, + 0x17, 0x33, 0x15, 0x23, 0x15, 0x33, 0x15, 0x23, 0x01, 0xF4, 0xFE, 0x0C, + 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x77, 0x02, 0xEE, 0x02, 0x71, 0x00, 0x0D, + 0x00, 0x26, 0x40, 0x17, 0x09, 0x00, 0x00, 0x05, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x02, 0x0C, 0x0C, 0x01, 0x0B, 0x04, 0x08, 0x01, 0x07, 0x04, 0x04, + 0x01, 0x03, 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x2F, 0x3F, 0xFC, 0x10, 0xFC, + 0x10, 0xFC, 0x30, 0x31, 0x11, 0x15, 0x33, 0x15, 0x33, 0x35, 0x33, 0x15, + 0x33, 0x35, 0x33, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x01, 0x77, 0x00, 0xFA, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, + 0x00, 0x2D, 0x40, 0x19, 0x05, 0x05, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, + 0x07, 0x04, 0x00, 0x00, 0x02, 0x02, 0x04, 0x00, 0x01, 0x01, 0x07, 0x00, + 0x07, 0x07, 0x01, 0x06, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, + 0x00, 0x3F, 0xFC, 0x2B, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x13, + 0x33, 0x35, 0x23, 0x15, 0x23, 0x15, 0x33, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0x02, 0x71, + 0x01, 0x77, 0x02, 0xEF, 0x00, 0x03, 0x00, 0x07, 0x00, 0x19, 0x40, 0x10, + 0x07, 0x00, 0x06, 0x04, 0x03, 0x00, 0x02, 0x04, 0x06, 0x01, 0x05, 0x04, + 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x2B, 0x2B, 0x30, 0x31, 0x11, + 0x15, 0x33, 0x35, 0x17, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0x7D, 0x02, 0xEF, + 0x7D, 0x7D, 0x01, 0x7D, 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x71, 0x02, 0x71, 0x00, 0x13, 0x00, 0x17, 0x00, 0x1B, 0x00, 0xAD, + 0x40, 0x5E, 0x1B, 0x00, 0x14, 0x18, 0x18, 0x15, 0x0B, 0x0B, 0x10, 0x09, + 0x09, 0x11, 0x11, 0x00, 0x10, 0x04, 0x07, 0x07, 0x1A, 0x06, 0x00, 0x14, + 0x05, 0x05, 0x15, 0x02, 0x00, 0x14, 0x01, 0x01, 0x15, 0x00, 0x00, 0x1A, + 0x15, 0x00, 0x1A, 0x04, 0x15, 0x00, 0x14, 0x0E, 0x06, 0x14, 0x02, 0x03, + 0x02, 0x18, 0x0E, 0x16, 0x01, 0x1A, 0x14, 0x1A, 0x14, 0x1B, 0x12, 0x0E, + 0x12, 0x19, 0x10, 0x1A, 0x10, 0x1B, 0x1A, 0x01, 0x0E, 0x01, 0x0C, 0x0E, + 0x19, 0x0A, 0x02, 0x08, 0x0C, 0x08, 0x0D, 0x07, 0x02, 0x06, 0x0B, 0x00, + 0x0C, 0x00, 0x0D, 0x0C, 0x01, 0x02, 0x02, 0x01, 0x05, 0x04, 0x02, 0x0B, + 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xFC, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xFC, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xFC, + 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x13, 0x35, 0x23, 0x35, 0x23, 0x15, 0x33, + 0x15, 0x33, 0x15, 0x23, 0x15, 0x33, 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, + 0x35, 0x37, 0x15, 0x33, 0x35, 0x07, 0x15, 0x33, 0x35, 0xFA, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x01, + 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0xFF, 0x83, + 0x05, 0x5F, 0x02, 0xEE, 0x00, 0x03, 0x00, 0x0B, 0x00, 0x17, 0x00, 0x3F, + 0x40, 0x29, 0x13, 0x13, 0x0E, 0x10, 0x00, 0x17, 0x04, 0x0D, 0x00, 0x0E, + 0x0E, 0x12, 0x12, 0x00, 0x15, 0x04, 0x04, 0x00, 0x02, 0x00, 0x00, 0x08, + 0x04, 0x02, 0x08, 0x11, 0x01, 0x14, 0x04, 0x0D, 0x01, 0x10, 0x04, 0x03, + 0x01, 0x0B, 0x04, 0x04, 0x01, 0x02, 0x04, 0x2B, 0x2B, 0x2B, 0x2B, 0x00, + 0x3F, 0x2B, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0xFC, 0x2B, 0x10, 0xD0, + 0x2F, 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x25, 0x11, 0x33, 0x35, 0x21, + 0x15, 0x33, 0x11, 0x03, 0x33, 0x35, 0x23, 0x15, 0x21, 0x35, 0x23, 0x15, + 0x33, 0x15, 0x21, 0x05, 0x5F, 0xFA, 0xA1, 0x05, 0x5F, 0xFB, 0x1E, 0x7D, + 0x03, 0x6B, 0x7D, 0xFA, 0x82, 0x87, 0xFD, 0x99, 0x87, 0x82, 0x02, 0x71, + 0x02, 0xEE, 0xFC, 0x95, 0x7D, 0x01, 0xF5, 0x7C, 0x7C, 0xFE, 0x0B, 0x01, + 0x78, 0x7C, 0x7B, 0x7B, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x77, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2C, + 0x40, 0x1A, 0x08, 0x00, 0x00, 0x05, 0x00, 0x04, 0x0A, 0x00, 0x02, 0x04, + 0x04, 0x06, 0x00, 0x02, 0x06, 0x01, 0x04, 0x02, 0x02, 0x01, 0x0A, 0x04, + 0x0B, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x21, 0x19, + 0x01, 0x35, 0x21, 0x15, 0x13, 0x33, 0x15, 0x23, 0x01, 0x77, 0xFE, 0x89, + 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFE, 0x89, 0x01, 0x77, 0xFD, 0x8F, 0x7D, + 0x7D, 0x01, 0xF4, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, + 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, + 0x08, 0x00, 0x00, 0x05, 0x00, 0x04, 0x0A, 0x00, 0x02, 0x04, 0x04, 0x06, + 0x00, 0x02, 0x06, 0x01, 0x04, 0x02, 0x02, 0x01, 0x0A, 0x04, 0x0B, 0x01, + 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, + 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x21, 0x19, 0x01, 0x35, + 0x21, 0x15, 0x13, 0x33, 0x15, 0x23, 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x7D, + 0x7D, 0x02, 0x71, 0xFE, 0x89, 0x01, 0x77, 0xFD, 0x8F, 0x7D, 0x7D, 0x01, + 0xF4, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x26, 0x40, 0x17, 0x0A, 0x00, 0x08, 0x05, + 0x00, 0x04, 0x04, 0x01, 0x00, 0x00, 0x06, 0x08, 0x02, 0x04, 0x0B, 0x0B, + 0x01, 0x0A, 0x04, 0x02, 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x35, 0x21, 0x35, + 0x33, 0x35, 0x21, 0x11, 0x01, 0x23, 0x15, 0x33, 0x01, 0xF4, 0xFE, 0x89, + 0xFA, 0xFE, 0x89, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, + 0x02, 0x71, 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, + 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x0F, 0x04, 0x00, + 0x05, 0x01, 0x06, 0x05, 0x02, 0x01, 0x04, 0x00, 0x07, 0x04, 0x01, 0x07, + 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x30, + 0x31, 0x31, 0x33, 0x11, 0x23, 0x37, 0x35, 0x23, 0x15, 0x7D, 0x7D, 0x7D, + 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x71, 0x02, 0x71, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x56, 0x40, 0x2F, + 0x12, 0x00, 0x10, 0x09, 0x00, 0x07, 0x05, 0x00, 0x07, 0x03, 0x03, 0x0B, + 0x01, 0x01, 0x0E, 0x0B, 0x00, 0x0E, 0x04, 0x00, 0x00, 0x10, 0x06, 0x07, + 0x02, 0x11, 0x0F, 0x0E, 0x12, 0x0A, 0x0F, 0x0A, 0x12, 0x08, 0x13, 0x06, + 0x0F, 0x06, 0x12, 0x04, 0x00, 0x01, 0x0F, 0x0F, 0x01, 0x13, 0x04, 0x2B, + 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0xFC, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x25, 0x35, 0x33, 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, + 0x21, 0x15, 0x21, 0x15, 0x07, 0x33, 0x35, 0x23, 0x01, 0xF4, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x7D, 0x02, 0x71, 0x01, 0xF4, 0x00, 0x07, 0x00, 0x0F, + 0x00, 0x13, 0x00, 0x17, 0x00, 0xA0, 0x40, 0x56, 0x14, 0x14, 0x08, 0x12, + 0x12, 0x16, 0x10, 0x10, 0x08, 0x10, 0x10, 0x15, 0x0A, 0x0A, 0x0E, 0x0A, + 0x0A, 0x0F, 0x06, 0x06, 0x0E, 0x06, 0x06, 0x0F, 0x04, 0x04, 0x0D, 0x02, + 0x02, 0x0E, 0x02, 0x02, 0x0F, 0x0E, 0x00, 0x0D, 0x04, 0x00, 0x00, 0x08, + 0x00, 0x00, 0x15, 0x08, 0x00, 0x0F, 0x04, 0x08, 0x08, 0x15, 0x16, 0x00, + 0x15, 0x04, 0x14, 0x03, 0x10, 0x0B, 0x0D, 0x12, 0x01, 0x0B, 0x08, 0x0B, + 0x08, 0x13, 0x0B, 0x01, 0x0A, 0x04, 0x0B, 0x13, 0x05, 0x16, 0x01, 0x03, + 0x00, 0x03, 0x00, 0x17, 0x03, 0x01, 0x02, 0x04, 0x03, 0x17, 0x10, 0xD0, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x2B, + 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x2B, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x13, 0x23, + 0x15, 0x33, 0x15, 0x33, 0x35, 0x23, 0x25, 0x23, 0x15, 0x33, 0x15, 0x33, + 0x35, 0x23, 0x35, 0x33, 0x35, 0x23, 0x05, 0x33, 0x35, 0x23, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, + 0x89, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7D, 0x02, 0x71, + 0x01, 0xF4, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, + 0x00, 0x17, 0x00, 0x9A, 0x40, 0x52, 0x15, 0x15, 0x13, 0x14, 0x14, 0x00, + 0x10, 0x10, 0x16, 0x0D, 0x0D, 0x01, 0x0C, 0x0C, 0x17, 0x0C, 0x0C, 0x00, + 0x09, 0x09, 0x13, 0x09, 0x09, 0x16, 0x08, 0x08, 0x17, 0x08, 0x08, 0x00, + 0x05, 0x05, 0x12, 0x04, 0x04, 0x13, 0x04, 0x04, 0x16, 0x13, 0x00, 0x12, + 0x04, 0x01, 0x00, 0x00, 0x00, 0x17, 0x17, 0x00, 0x16, 0x04, 0x16, 0x01, + 0x12, 0x14, 0x12, 0x0D, 0x08, 0x0B, 0x01, 0x08, 0x06, 0x08, 0x04, 0x0F, + 0x08, 0x01, 0x0F, 0x04, 0x02, 0x11, 0x00, 0x12, 0x00, 0x15, 0x12, 0x01, + 0x11, 0x04, 0x12, 0x15, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xFC, 0x00, 0x2B, 0x10, 0xD0, 0x2F, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x01, 0x35, 0x23, 0x15, 0x05, 0x15, 0x33, 0x3D, 0x01, 0x15, + 0x33, 0x35, 0x23, 0x35, 0x23, 0x15, 0x05, 0x15, 0x33, 0x3D, 0x01, 0x15, + 0x33, 0x35, 0x01, 0xF4, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, + 0x77, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x00, 0x7D, 0x00, 0x03, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x1A, 0x08, 0x00, 0x09, 0x04, 0x00, 0x09, + 0x00, 0x00, 0x09, 0x06, 0x05, 0x06, 0x01, 0x06, 0x0A, 0x01, 0x09, 0x04, + 0x06, 0x01, 0x05, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x2B, 0x00, + 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x35, 0x15, + 0x33, 0x35, 0x21, 0x15, 0x33, 0x35, 0x21, 0x15, 0x33, 0x35, 0x7D, 0x01, + 0x77, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x00, 0x01, 0x00, 0x00, 0x00, 0xFA, 0x01, 0x77, 0x01, 0x77, 0x00, 0x03, + 0x00, 0x0A, 0x40, 0x04, 0x02, 0x00, 0x03, 0x04, 0x00, 0x2B, 0x30, 0x31, + 0x25, 0x35, 0x21, 0x15, 0x01, 0x77, 0xFE, 0x89, 0xFA, 0x7D, 0x7D, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0xFA, 0x01, 0xF4, 0x01, 0x77, 0x00, 0x03, + 0x00, 0x0A, 0x40, 0x04, 0x02, 0x00, 0x03, 0x04, 0x00, 0x2B, 0x30, 0x31, + 0x25, 0x35, 0x21, 0x15, 0x01, 0xF4, 0xFE, 0x0C, 0xFA, 0x7D, 0x7D, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x01, 0x77, 0x01, 0x77, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x07, 0x00, 0x17, 0x40, 0x0D, 0x06, 0x02, 0x00, 0x02, 0x07, 0x04, + 0x01, 0x07, 0x04, 0x03, 0x01, 0x02, 0x04, 0x2B, 0x2B, 0x00, 0x2F, 0x3F, + 0x3F, 0x30, 0x31, 0x01, 0x23, 0x15, 0x33, 0x23, 0x35, 0x23, 0x15, 0x01, + 0x77, 0x7D, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFA, 0x00, 0x02, + 0x00, 0x00, 0x01, 0x77, 0x01, 0x77, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, + 0x00, 0x17, 0x40, 0x0D, 0x06, 0x02, 0x00, 0x02, 0x07, 0x04, 0x01, 0x07, + 0x04, 0x03, 0x01, 0x02, 0x04, 0x2B, 0x2B, 0x00, 0x2F, 0x3F, 0x3F, 0x30, + 0x31, 0x01, 0x23, 0x15, 0x33, 0x23, 0x35, 0x23, 0x15, 0x01, 0x77, 0x7D, + 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFA, 0x00, 0x01, 0x00, 0x00, + 0x01, 0x77, 0x00, 0x7D, 0x02, 0x71, 0x00, 0x03, 0x00, 0x0F, 0x40, 0x07, + 0x02, 0x02, 0x03, 0x00, 0x01, 0x03, 0x04, 0x2B, 0x00, 0x2F, 0x3F, 0x30, + 0x31, 0x13, 0x35, 0x23, 0x15, 0x7D, 0x7D, 0x01, 0x77, 0xFA, 0xFA, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x77, 0x00, 0x7D, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x0F, 0x40, 0x07, 0x02, 0x02, 0x03, 0x00, 0x01, 0x03, 0x04, 0x2B, + 0x00, 0x2F, 0x3F, 0x30, 0x31, 0x13, 0x35, 0x23, 0x15, 0x7D, 0x7D, 0x01, + 0x77, 0xFA, 0xFA, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x7D, 0x00, 0xFA, + 0x01, 0xF4, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x4A, 0x40, 0x29, 0x08, 0x08, + 0x03, 0x05, 0x05, 0x02, 0x04, 0x04, 0x0B, 0x03, 0x00, 0x0A, 0x04, 0x02, + 0x00, 0x0B, 0x04, 0x01, 0x01, 0x06, 0x07, 0x00, 0x06, 0x04, 0x06, 0x0A, + 0x06, 0x0B, 0x04, 0x01, 0x0A, 0x02, 0x0A, 0x02, 0x0B, 0x00, 0x09, 0x0A, + 0x01, 0x09, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x2B, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x11, 0x15, + 0x33, 0x15, 0x33, 0x35, 0x23, 0x35, 0x07, 0x15, 0x33, 0x35, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, + 0x00, 0x01, 0x00, 0x00, 0xFF, 0x83, 0x01, 0x77, 0x02, 0xEE, 0x00, 0x13, + 0x00, 0x41, 0x40, 0x23, 0x0B, 0x0B, 0x10, 0x09, 0x09, 0x11, 0x11, 0x00, + 0x10, 0x04, 0x07, 0x07, 0x13, 0x05, 0x05, 0x02, 0x02, 0x00, 0x13, 0x04, + 0x0E, 0x08, 0x04, 0x12, 0x0E, 0x08, 0x0D, 0x04, 0x0D, 0x02, 0x0E, 0x0E, + 0x01, 0x0D, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x2F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x2B, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x35, 0x23, 0x35, 0x23, + 0x15, 0x23, 0x15, 0x33, 0x15, 0x23, 0x15, 0x33, 0x15, 0x33, 0x35, 0x33, + 0x35, 0x23, 0x35, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0xFA, + 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x7D, 0x01, 0x77, + 0x00, 0x03, 0x00, 0x0F, 0x40, 0x08, 0x03, 0x00, 0x02, 0x04, 0x02, 0x01, + 0x01, 0x04, 0x2B, 0x00, 0x2B, 0x30, 0x31, 0x11, 0x15, 0x33, 0x35, 0x7D, + 0x01, 0x77, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0xFF, 0x83, 0x00, 0x7D, + 0x00, 0x7D, 0x00, 0x03, 0x00, 0x0F, 0x40, 0x07, 0x02, 0x08, 0x03, 0x02, + 0x01, 0x01, 0x04, 0x2B, 0x00, 0x2F, 0x3F, 0x30, 0x31, 0x35, 0x15, 0x33, + 0x35, 0x7D, 0x7D, 0xFA, 0xFA, 0x00, 0x00, 0x02, 0x00, 0x00, 0xFF, 0x83, + 0x01, 0x77, 0x00, 0x7D, 0x00, 0x03, 0x00, 0x07, 0x00, 0x17, 0x40, 0x0D, + 0x06, 0x08, 0x01, 0x08, 0x07, 0x06, 0x01, 0x05, 0x04, 0x02, 0x01, 0x01, + 0x04, 0x2B, 0x2B, 0x00, 0x2F, 0x3F, 0x3F, 0x30, 0x31, 0x35, 0x15, 0x33, + 0x35, 0x33, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, + 0xFA, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x17, 0x00, 0x1B, + 0x00, 0x1F, 0x00, 0xD5, 0x40, 0x75, 0x1C, 0x1C, 0x05, 0x1A, 0x00, 0x15, + 0x19, 0x19, 0x0F, 0x18, 0x18, 0x1E, 0x17, 0x00, 0x15, 0x14, 0x14, 0x0F, + 0x10, 0x00, 0x11, 0x0F, 0x00, 0x1E, 0x0E, 0x00, 0x15, 0x0A, 0x00, 0x11, + 0x0A, 0x0A, 0x13, 0x07, 0x07, 0x13, 0x06, 0x00, 0x11, 0x04, 0x04, 0x1F, + 0x1E, 0x00, 0x1F, 0x04, 0x02, 0x00, 0x11, 0x02, 0x02, 0x13, 0x05, 0x00, + 0x13, 0x04, 0x11, 0x06, 0x08, 0x06, 0x00, 0x06, 0x15, 0x02, 0x0C, 0x02, + 0x1E, 0x03, 0x1A, 0x1C, 0x1A, 0x1D, 0x16, 0x18, 0x16, 0x19, 0x0D, 0x11, + 0x0C, 0x12, 0x0C, 0x13, 0x09, 0x14, 0x01, 0x18, 0x08, 0x18, 0x08, 0x19, + 0x18, 0x01, 0x1C, 0x05, 0x12, 0x05, 0x13, 0x01, 0x1C, 0x01, 0x1D, 0x1C, + 0x01, 0x03, 0x00, 0x03, 0x00, 0x1F, 0x03, 0x01, 0x12, 0x03, 0x1F, 0x12, + 0x01, 0x11, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xFC, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, + 0x31, 0x3B, 0x01, 0x35, 0x23, 0x35, 0x23, 0x15, 0x33, 0x17, 0x33, 0x35, + 0x23, 0x01, 0x23, 0x15, 0x33, 0x03, 0x15, 0x33, 0x35, 0x01, 0x35, 0x23, + 0x1D, 0x01, 0x35, 0x23, 0x1D, 0x01, 0x35, 0x23, 0x15, 0xFA, 0x7D, 0x7D, + 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, + 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, + 0xFE, 0x89, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x01, 0x77, 0x01, 0x77, 0x02, 0x71, + 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x47, 0x40, 0x27, 0x0B, 0x00, + 0x09, 0x08, 0x08, 0x07, 0x04, 0x00, 0x09, 0x03, 0x00, 0x09, 0x01, 0x01, + 0x06, 0x00, 0x00, 0x07, 0x07, 0x00, 0x06, 0x04, 0x09, 0x02, 0x0A, 0x06, + 0x09, 0x00, 0x03, 0x01, 0x00, 0x01, 0x06, 0x06, 0x01, 0x05, 0x04, 0x06, + 0x0B, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, + 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x13, 0x15, 0x33, 0x35, 0x21, + 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, 0x15, 0xFA, 0x7D, 0xFE, 0x89, 0x7D, + 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1D, + 0x40, 0x11, 0x03, 0x00, 0x00, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x06, + 0x01, 0x05, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, + 0x3F, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x11, 0x33, 0x11, 0x33, + 0x11, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x01, 0xF4, 0xFE, 0x0C, + 0x02, 0x71, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, + 0x00, 0x13, 0x00, 0x4A, 0x40, 0x29, 0x0B, 0x0B, 0x10, 0x09, 0x09, 0x11, + 0x11, 0x00, 0x10, 0x04, 0x07, 0x07, 0x13, 0x01, 0x01, 0x05, 0x05, 0x00, + 0x13, 0x04, 0x0E, 0x06, 0x04, 0x02, 0x08, 0x0E, 0x04, 0x12, 0x02, 0x01, + 0x12, 0x01, 0x0E, 0x12, 0x05, 0x0E, 0x01, 0x0D, 0x04, 0x0E, 0x09, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x35, 0x23, 0x35, 0x23, 0x15, + 0x21, 0x15, 0x33, 0x15, 0x23, 0x15, 0x33, 0x15, 0x33, 0x35, 0x21, 0x35, + 0x23, 0x35, 0x02, 0x71, 0x7D, 0x7D, 0xFE, 0x89, 0xFA, 0xFA, 0x7D, 0x7D, + 0x01, 0x77, 0xFA, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, + 0x01, 0xF4, 0x00, 0x0B, 0x00, 0x26, 0x40, 0x16, 0x05, 0x05, 0x0A, 0x01, + 0x01, 0x0A, 0x0B, 0x00, 0x0A, 0x04, 0x08, 0x06, 0x03, 0x06, 0x08, 0x01, + 0x07, 0x04, 0x04, 0x01, 0x03, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x11, 0x15, 0x33, 0x11, + 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, 0x33, 0x35, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x01, 0xF4, 0x7D, 0xFE, 0x89, 0x01, 0x77, 0xFE, 0x89, 0x01, 0x77, + 0x7D, 0x00, 0x00, 0x05, 0x00, 0x00, 0xFF, 0x83, 0x02, 0x71, 0x02, 0xEE, + 0x00, 0x07, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x17, 0x00, 0x1B, 0x00, 0x98, + 0x40, 0x56, 0x15, 0x00, 0x18, 0x14, 0x00, 0x19, 0x10, 0x00, 0x19, 0x0D, + 0x00, 0x18, 0x0B, 0x0B, 0x02, 0x09, 0x00, 0x18, 0x08, 0x00, 0x19, 0x06, + 0x06, 0x02, 0x04, 0x00, 0x18, 0x00, 0x19, 0x01, 0x00, 0x02, 0x04, 0x18, + 0x06, 0x14, 0x06, 0x10, 0x06, 0x08, 0x06, 0x19, 0x08, 0x11, 0x08, 0x18, + 0x14, 0x0E, 0x12, 0x0E, 0x13, 0x0C, 0x11, 0x0A, 0x12, 0x0A, 0x13, 0x08, + 0x01, 0x12, 0x05, 0x1A, 0x01, 0x14, 0x03, 0x14, 0x03, 0x19, 0x01, 0x12, + 0x01, 0x13, 0x12, 0x01, 0x11, 0x04, 0x00, 0x14, 0x00, 0x19, 0x14, 0x01, + 0x17, 0x04, 0x14, 0x19, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, + 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0xFC, + 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xFC, + 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, 0x15, 0x21, + 0x11, 0x33, 0x11, 0x23, 0x03, 0x35, 0x23, 0x11, 0x23, 0x11, 0x33, 0x15, + 0x23, 0x15, 0x33, 0x35, 0x21, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x35, + 0x01, 0xF4, 0xFE, 0x89, 0x01, 0x77, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x02, 0xEE, 0x7D, 0xFE, 0x0C, + 0x01, 0xF4, 0xFD, 0x8F, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, + 0x01, 0xF4, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x8B, + 0x40, 0x4D, 0x11, 0x11, 0x08, 0x0D, 0x00, 0x05, 0x0C, 0x0C, 0x09, 0x0A, + 0x0A, 0x0F, 0x03, 0x00, 0x05, 0x03, 0x03, 0x0E, 0x01, 0x01, 0x09, 0x01, + 0x01, 0x0F, 0x08, 0x00, 0x0F, 0x04, 0x08, 0x08, 0x12, 0x13, 0x00, 0x12, + 0x04, 0x00, 0x00, 0x05, 0x00, 0x00, 0x0E, 0x09, 0x00, 0x0E, 0x04, 0x05, + 0x06, 0x12, 0x01, 0x0A, 0x10, 0x0A, 0x0C, 0x06, 0x0A, 0x01, 0x0E, 0x0A, + 0x11, 0x08, 0x0E, 0x08, 0x0F, 0x0E, 0x01, 0x06, 0x01, 0x00, 0x06, 0x0D, + 0x01, 0x05, 0x00, 0x00, 0x01, 0x03, 0x04, 0x2B, 0x10, 0xD0, 0xD0, 0x10, + 0xD0, 0x10, 0xFC, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x00, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, + 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x37, 0x35, 0x23, 0x15, 0x33, + 0x15, 0x33, 0x35, 0x37, 0x15, 0x33, 0x35, 0x07, 0x15, 0x33, 0x35, 0x37, + 0x15, 0x33, 0x35, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7D, 0x01, 0xF4, + 0x02, 0xEE, 0x00, 0x07, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x17, 0x00, 0x1B, + 0x00, 0x1F, 0x00, 0xD4, 0x40, 0x72, 0x1D, 0x00, 0x1C, 0x19, 0x19, 0x0B, + 0x14, 0x14, 0x0B, 0x14, 0x14, 0x1A, 0x11, 0x11, 0x1F, 0x10, 0x10, 0x02, + 0x0D, 0x0D, 0x16, 0x09, 0x09, 0x1B, 0x08, 0x08, 0x0B, 0x08, 0x08, 0x1A, + 0x0B, 0x00, 0x16, 0x04, 0x0B, 0x0B, 0x1A, 0x1B, 0x00, 0x1A, 0x04, 0x05, + 0x00, 0x1C, 0x04, 0x04, 0x1F, 0x00, 0x00, 0x1F, 0x02, 0x00, 0x1F, 0x04, + 0x1C, 0x02, 0x11, 0x02, 0x03, 0x02, 0x00, 0x02, 0x18, 0x0E, 0x16, 0x1E, + 0x16, 0x1F, 0x14, 0x1D, 0x12, 0x1A, 0x01, 0x0E, 0x10, 0x0E, 0x10, 0x19, + 0x0C, 0x00, 0x0A, 0x1E, 0x0A, 0x1F, 0x08, 0x00, 0x08, 0x0D, 0x06, 0x0E, + 0x06, 0x19, 0x0E, 0x01, 0x00, 0x0E, 0x19, 0x04, 0x00, 0x04, 0x0D, 0x02, + 0x1E, 0x02, 0x1F, 0x00, 0x01, 0x1E, 0x00, 0x0D, 0x1E, 0x01, 0x1D, 0x04, + 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, + 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, + 0x13, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x35, 0x03, 0x35, 0x23, 0x15, + 0x33, 0x15, 0x33, 0x35, 0x11, 0x15, 0x33, 0x35, 0x01, 0x15, 0x33, 0x35, + 0x37, 0x15, 0x33, 0x35, 0x25, 0x15, 0x33, 0x35, 0xFA, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, 0x0C, 0x7D, 0xFA, 0x7D, 0xFE, 0x0C, + 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0x7C, 0x7C, 0xFE, 0x89, 0x7C, 0x7C, 0x7D, + 0x7D, 0x01, 0xF4, 0x7D, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0x7C, 0x7C, 0x7C, + 0xFB, 0x7C, 0x7C, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, + 0x02, 0x71, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x64, 0x40, 0x38, 0x10, 0x10, + 0x09, 0x0D, 0x0D, 0x09, 0x0D, 0x0D, 0x13, 0x0A, 0x0A, 0x13, 0x03, 0x03, + 0x08, 0x01, 0x01, 0x09, 0x01, 0x01, 0x13, 0x08, 0x00, 0x13, 0x04, 0x00, + 0x00, 0x12, 0x09, 0x00, 0x12, 0x04, 0x0C, 0x06, 0x06, 0x02, 0x08, 0x12, + 0x12, 0x01, 0x11, 0x04, 0x06, 0x0B, 0x04, 0x0C, 0x0C, 0x01, 0x0B, 0x04, + 0x02, 0x0F, 0x00, 0x01, 0x0F, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, + 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, + 0x25, 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, 0x23, 0x15, 0x33, 0x11, + 0x33, 0x11, 0x33, 0x15, 0x25, 0x15, 0x33, 0x35, 0x02, 0x71, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, 0x0C, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0xFE, 0x89, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x02, + 0x00, 0x00, 0x00, 0xFA, 0x01, 0x77, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, + 0x00, 0x1C, 0x40, 0x11, 0x04, 0x00, 0x00, 0x06, 0x00, 0x02, 0x04, 0x00, + 0x02, 0x02, 0x01, 0x06, 0x04, 0x07, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, + 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x21, 0x11, 0x07, 0x33, + 0x15, 0x23, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0x02, 0x71, 0xFE, 0x89, 0x01, + 0x77, 0x7D, 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFA, + 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x0F, 0x02, 0x06, + 0x07, 0x02, 0x06, 0x01, 0x02, 0x04, 0x02, 0x02, 0x01, 0x01, 0x04, 0x02, + 0x05, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0x00, 0x3F, 0x3F, 0x30, + 0x31, 0x19, 0x01, 0x33, 0x11, 0x35, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0x01, + 0x77, 0xFE, 0x89, 0x01, 0x77, 0xFA, 0xFA, 0xFA, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7D, 0x01, 0x77, 0x00, 0x03, 0x00, 0x0F, 0x40, 0x07, + 0x02, 0x06, 0x03, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x00, 0x2F, 0x3F, 0x30, + 0x31, 0x19, 0x01, 0x33, 0x11, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, 0x77, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x7D, 0x00, 0xFA, 0x01, 0xF4, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x48, 0x40, 0x28, 0x09, 0x09, 0x07, 0x01, 0x01, 0x05, + 0x01, 0x01, 0x06, 0x05, 0x00, 0x04, 0x04, 0x07, 0x00, 0x06, 0x04, 0x00, + 0x00, 0x0A, 0x0B, 0x00, 0x0A, 0x04, 0x08, 0x02, 0x06, 0x02, 0x06, 0x09, + 0x04, 0x0A, 0x01, 0x02, 0x02, 0x01, 0x01, 0x04, 0x02, 0x09, 0x10, 0xD0, + 0x2B, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x2B, + 0x10, 0xD0, 0x2F, 0x2B, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x11, 0x15, 0x33, 0x15, 0x33, 0x35, 0x23, 0x3D, + 0x01, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x77, 0x01, 0xF4, 0x00, 0x0F, 0x00, 0x30, 0x40, 0x1A, 0x0E, 0x00, + 0x00, 0x06, 0x06, 0x0A, 0x04, 0x04, 0x0D, 0x0A, 0x00, 0x0D, 0x04, 0x02, + 0x00, 0x00, 0x06, 0x09, 0x09, 0x0E, 0x07, 0x03, 0x03, 0x01, 0x0E, 0x04, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x2F, 0x3F, 0xFC, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x35, 0x23, + 0x35, 0x33, 0x35, 0x23, 0x35, 0x23, 0x15, 0x23, 0x15, 0x33, 0x15, 0x23, + 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, 0x0A, 0x00, + 0x00, 0x08, 0x00, 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x09, + 0x02, 0x04, 0x0B, 0x07, 0x01, 0x0B, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, + 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x07, 0x23, + 0x35, 0x33, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, + 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x32, 0x40, 0x1D, + 0x0B, 0x00, 0x03, 0x05, 0x05, 0x0D, 0x08, 0x00, 0x0D, 0x04, 0x00, 0x00, + 0x01, 0x03, 0x06, 0x01, 0x02, 0x08, 0x0C, 0x0C, 0x01, 0x03, 0x04, 0x00, + 0x04, 0x04, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, 0x17, 0x15, + 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xF5, 0xF5, + 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0D, 0x00, 0x01, 0x08, + 0x00, 0x00, 0x05, 0x05, 0x0A, 0x03, 0x03, 0x0F, 0x0A, 0x00, 0x0F, 0x04, + 0x01, 0x06, 0x00, 0x02, 0x0A, 0x0E, 0x08, 0x0D, 0x06, 0x02, 0x02, 0x01, + 0x0D, 0x04, 0x0E, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x21, 0x35, 0x23, 0x35, + 0x33, 0x35, 0x07, 0x15, 0x23, 0x35, 0x17, 0x15, 0x23, 0x35, 0x01, 0xF4, + 0x7D, 0x7D, 0x82, 0xF5, 0xF5, 0xF5, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0x7D, + 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x05, 0x00, 0x10, 0x40, 0x08, + 0x00, 0x00, 0x01, 0x02, 0x04, 0x01, 0x03, 0x04, 0x2B, 0x00, 0x3F, 0xFC, + 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x33, 0x11, 0x01, 0x77, 0xFE, 0x89, + 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x01, 0xF4, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x2E, + 0x40, 0x1B, 0x0B, 0x00, 0x03, 0x0A, 0x00, 0x07, 0x05, 0x00, 0x03, 0x01, + 0x00, 0x03, 0x00, 0x00, 0x07, 0x03, 0x06, 0x07, 0x02, 0x06, 0x01, 0x0B, + 0x04, 0x0C, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, + 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x13, 0x11, + 0x23, 0x15, 0x21, 0x35, 0x23, 0x11, 0x21, 0x15, 0x33, 0x11, 0x23, 0x11, + 0x3F, 0x3F, 0x02, 0x71, 0x3E, 0xFE, 0x89, 0xFA, 0xF5, 0x01, 0xF4, 0xFE, + 0x89, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0xFE, 0x89, 0x01, 0x77, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x23, + 0x40, 0x14, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, + 0x03, 0x06, 0x01, 0x02, 0x0A, 0x06, 0x06, 0x01, 0x03, 0x04, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x30, 0x31, 0x01, + 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, 0x01, 0xF4, 0x7D, + 0xFD, 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x71, 0x02, 0x71, 0x00, 0x13, 0x00, 0x17, 0x00, 0x1B, 0x00, 0x7C, + 0x40, 0x44, 0x1A, 0x1A, 0x10, 0x12, 0x12, 0x17, 0x0C, 0x0C, 0x10, 0x08, + 0x08, 0x10, 0x06, 0x06, 0x17, 0x02, 0x02, 0x17, 0x10, 0x00, 0x17, 0x04, + 0x15, 0x06, 0x04, 0x06, 0x00, 0x06, 0x19, 0x02, 0x0E, 0x02, 0x0A, 0x02, + 0x15, 0x12, 0x0F, 0x17, 0x0D, 0x12, 0x12, 0x01, 0x17, 0x04, 0x0B, 0x13, + 0x01, 0x0A, 0x09, 0x02, 0x07, 0x19, 0x07, 0x1A, 0x05, 0x1B, 0x01, 0x19, + 0x03, 0x19, 0x03, 0x1A, 0x01, 0x0A, 0x19, 0x01, 0x0A, 0x04, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x3B, 0x01, 0x35, 0x33, 0x15, 0x33, 0x35, 0x23, + 0x35, 0x23, 0x35, 0x23, 0x15, 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, + 0x07, 0x33, 0x35, 0x23, 0x01, 0x23, 0x15, 0x33, 0xFA, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x02, 0x71, + 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, + 0xFA, 0x01, 0x77, 0xFA, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x06, 0x00, 0x08, 0x02, + 0x00, 0x05, 0x04, 0x00, 0x00, 0x0A, 0x08, 0x06, 0x0A, 0x02, 0x07, 0x00, + 0x01, 0x06, 0x09, 0x01, 0x06, 0x04, 0x03, 0x01, 0x00, 0x04, 0x2B, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, + 0x30, 0x31, 0x11, 0x21, 0x15, 0x23, 0x15, 0x33, 0x15, 0x21, 0x15, 0x21, + 0x11, 0x21, 0x01, 0x77, 0xFA, 0xFA, 0xFE, 0x89, 0x01, 0xF4, 0xFE, 0x0C, + 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x24, 0x40, 0x15, + 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, 0x06, 0x09, 0x02, 0x03, 0x02, 0x07, + 0x02, 0x02, 0x01, 0x05, 0x04, 0x08, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x11, + 0x23, 0x11, 0x23, 0x11, 0x33, 0x15, 0x21, 0x11, 0x01, 0x77, 0xFA, 0x7D, + 0x7D, 0x01, 0x77, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, + 0x02, 0x71, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0x6B, + 0x00, 0x09, 0x00, 0x0D, 0x00, 0x31, 0x40, 0x1D, 0x0C, 0x00, 0x0B, 0x04, + 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, 0x06, 0x09, 0x02, 0x03, 0x02, 0x0B, + 0x00, 0x0A, 0x02, 0x07, 0x02, 0x02, 0x01, 0x05, 0x04, 0x09, 0x01, 0x00, + 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x30, 0x31, 0x01, 0x11, 0x23, 0x11, 0x23, + 0x11, 0x33, 0x15, 0x21, 0x11, 0x25, 0x33, 0x35, 0x23, 0x01, 0x77, 0xFA, + 0x7D, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0xFA, 0xFA, 0x02, 0x71, 0xFE, 0x0C, + 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0E, 0x0E, 0x04, 0x02, 0x02, 0x0A, + 0x04, 0x00, 0x0A, 0x04, 0x0B, 0x06, 0x00, 0x06, 0x0D, 0x02, 0x06, 0x02, + 0x0A, 0x0E, 0x08, 0x0F, 0x03, 0x0E, 0x0F, 0x01, 0x0E, 0x04, 0x01, 0x06, + 0x06, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, 0x35, 0x23, 0x35, 0x23, + 0x01, 0x35, 0x23, 0x15, 0x13, 0x23, 0x15, 0x33, 0x7D, 0xFA, 0xFA, 0x7D, + 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0xFD, 0x8F, 0xFA, + 0xFA, 0x02, 0x71, 0xFA, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x26, 0x40, 0x16, 0x06, 0x00, + 0x02, 0x04, 0x00, 0x02, 0x08, 0x06, 0x00, 0x06, 0x02, 0x02, 0x03, 0x08, + 0x08, 0x01, 0x07, 0x04, 0x02, 0x01, 0x05, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x33, + 0x11, 0x21, 0x15, 0x33, 0x21, 0x11, 0x33, 0x11, 0x01, 0x77, 0x7D, 0xFE, + 0x89, 0xFA, 0xFE, 0x89, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, 0x01, 0xF4, + 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x64, 0x40, 0x39, + 0x0E, 0x0E, 0x11, 0x0C, 0x00, 0x04, 0x0C, 0x0C, 0x12, 0x09, 0x09, 0x11, + 0x00, 0x12, 0x00, 0x04, 0x0B, 0x06, 0x06, 0x06, 0x01, 0x06, 0x04, 0x02, + 0x00, 0x02, 0x10, 0x07, 0x0C, 0x00, 0x0A, 0x12, 0x08, 0x0D, 0x08, 0x0E, + 0x04, 0x13, 0x03, 0x01, 0x00, 0x04, 0x00, 0x0F, 0x01, 0x0D, 0x0D, 0x01, + 0x12, 0x04, 0x12, 0x01, 0x07, 0x07, 0x01, 0x06, 0x04, 0x2B, 0x10, 0xFC, + 0x2B, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x10, + 0xFC, 0xFC, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x01, 0x11, 0x33, 0x11, 0x21, 0x23, 0x11, 0x3B, 0x01, 0x11, + 0x23, 0x11, 0x13, 0x23, 0x15, 0x33, 0x21, 0x33, 0x35, 0x23, 0x01, 0xF4, + 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0xFE, 0x89, + 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0xFD, 0x8F, 0x01, 0x77, + 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, 0x40, 0x18, 0x01, 0x00, + 0x08, 0x04, 0x0A, 0x06, 0x05, 0x06, 0x0B, 0x02, 0x03, 0x02, 0x02, 0x06, + 0x06, 0x01, 0x05, 0x04, 0x00, 0x09, 0x0A, 0x01, 0x09, 0x04, 0x2B, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x30, 0x31, + 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, + 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFD, + 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, + 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, 0x02, 0x05, 0x01, 0x02, + 0x04, 0x00, 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0xFC, 0x10, + 0xFC, 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, 0x33, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, + 0x7D, 0x01, 0x77, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, 0x03, 0x00, 0x00, 0x06, + 0x06, 0x01, 0x06, 0x00, 0x02, 0x06, 0x01, 0x05, 0x04, 0x02, 0x01, 0x01, + 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x30, 0x31, 0x19, + 0x01, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, 0x7D, 0xFA, 0x7D, 0x02, 0x71, + 0xFD, 0x8F, 0x01, 0xF4, 0xFE, 0x0C, 0x02, 0x71, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1A, 0x40, 0x0E, + 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x06, 0x01, + 0x03, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x11, 0x01, 0xF4, 0xFE, 0x0C, + 0x01, 0xF4, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x01, 0x77, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x1A, 0x40, 0x0E, 0x06, 0x00, 0x00, 0x02, 0x00, 0x00, 0x05, 0x06, + 0x00, 0x02, 0x05, 0x01, 0x04, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, + 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, 0x15, 0x33, 0x11, 0x33, 0x11, 0x33, + 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, + 0x01, 0xF4, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, + 0x04, 0x09, 0x06, 0x0B, 0x02, 0x03, 0x02, 0x08, 0x05, 0x02, 0x01, 0x05, + 0x04, 0x00, 0x07, 0x0A, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x15, + 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, 0x01, 0x77, + 0xFA, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0x02, 0x71, 0xFA, 0xFA, + 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x66, + 0x40, 0x39, 0x10, 0x10, 0x0C, 0x0E, 0x0E, 0x12, 0x06, 0x06, 0x0B, 0x00, + 0x0C, 0x0C, 0x13, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, 0x02, 0x04, + 0x00, 0x12, 0x12, 0x00, 0x13, 0x04, 0x09, 0x06, 0x02, 0x02, 0x09, 0x0E, + 0x09, 0x0D, 0x07, 0x13, 0x10, 0x01, 0x06, 0x04, 0x03, 0x13, 0x01, 0x0E, + 0x01, 0x0E, 0x01, 0x0D, 0x00, 0x01, 0x0F, 0x0F, 0x01, 0x0E, 0x04, 0x2B, + 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, + 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0xFC, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x23, 0x35, 0x23, 0x15, 0x23, + 0x11, 0x33, 0x15, 0x33, 0x35, 0x33, 0x27, 0x23, 0x35, 0x33, 0x05, 0x35, + 0x33, 0x15, 0x02, 0x71, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, + 0x7D, 0xFE, 0x89, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x50, + 0x40, 0x2C, 0x10, 0x10, 0x04, 0x09, 0x09, 0x0F, 0x07, 0x07, 0x04, 0x01, + 0x01, 0x0F, 0x04, 0x00, 0x0F, 0x04, 0x0E, 0x06, 0x00, 0x06, 0x12, 0x02, + 0x05, 0x02, 0x0A, 0x13, 0x08, 0x0E, 0x06, 0x0D, 0x04, 0x0E, 0x0E, 0x01, + 0x0D, 0x04, 0x02, 0x13, 0x00, 0x10, 0x10, 0x01, 0x13, 0x04, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x21, 0x35, 0x23, 0x35, + 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x15, 0x25, 0x15, 0x33, 0x35, + 0x25, 0x35, 0x23, 0x15, 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFE, + 0x89, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, + 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x32, 0x02, 0x71, 0x00, 0x09, 0x00, 0x20, 0x40, 0x13, 0x06, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x06, 0x09, 0x02, 0x04, 0x02, 0x08, 0x01, 0x09, + 0x04, 0x03, 0x01, 0x06, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, + 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x35, 0x23, 0x11, 0x23, 0x11, 0x23, + 0x11, 0x23, 0x02, 0x32, 0x3E, 0x7D, 0xFA, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, + 0x0C, 0x01, 0xF4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, 0x40, 0x19, 0x07, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x06, 0x0A, 0x02, 0x05, 0x02, 0x01, 0x02, 0x08, 0x01, 0x0B, + 0x04, 0x04, 0x01, 0x07, 0x04, 0x00, 0x01, 0x03, 0x04, 0x2B, 0x2B, 0x2B, + 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x11, + 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x02, 0x71, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, + 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x02, 0xAF, 0x02, 0x71, 0x00, 0x0D, 0x00, 0x2D, 0x40, 0x1C, 0x09, 0x00, + 0x00, 0x05, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x0C, 0x02, 0x07, 0x02, + 0x03, 0x02, 0x0A, 0x01, 0x0D, 0x04, 0x06, 0x01, 0x09, 0x04, 0x02, 0x01, + 0x05, 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, + 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x35, 0x23, 0x11, 0x23, 0x11, 0x23, + 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x02, 0xAF, 0x3E, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, + 0x01, 0xF4, 0xFD, 0x8F, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x32, + 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x09, 0x00, + 0x02, 0x05, 0x00, 0x0B, 0x04, 0x02, 0x06, 0x07, 0x02, 0x07, 0x01, 0x0A, + 0x05, 0x0A, 0x03, 0x01, 0x09, 0x04, 0x0A, 0x01, 0x02, 0x04, 0x0A, 0x06, + 0x10, 0xD0, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0x00, 0x3F, 0x3F, 0x2B, + 0x10, 0xFC, 0x30, 0x31, 0x11, 0x33, 0x11, 0x21, 0x11, 0x21, 0x35, 0x23, + 0x01, 0x15, 0x23, 0x35, 0x3E, 0x01, 0xF4, 0xFE, 0x89, 0xBB, 0x01, 0xB5, + 0xFA, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, 0x02, 0x71, 0x00, 0x05, + 0x00, 0x09, 0x00, 0x0D, 0x00, 0x29, 0x40, 0x19, 0x0B, 0x00, 0x06, 0x03, + 0x00, 0x0D, 0x04, 0x06, 0x06, 0x00, 0x06, 0x09, 0x02, 0x04, 0x02, 0x0C, + 0x04, 0x04, 0x01, 0x05, 0x04, 0x01, 0x01, 0x0B, 0x04, 0x2B, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x31, + 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, 0x33, 0x11, 0x23, 0x03, 0x15, 0x23, + 0x35, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0xFA, 0xFA, + 0x01, 0x77, 0xFA, 0xFD, 0x8F, 0x02, 0x71, 0xFE, 0x89, 0x7D, 0x7D, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, + 0x00, 0x09, 0x00, 0x23, 0x40, 0x15, 0x07, 0x00, 0x00, 0x03, 0x00, 0x09, + 0x04, 0x00, 0x06, 0x05, 0x02, 0x08, 0x04, 0x04, 0x01, 0x05, 0x04, 0x01, + 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, + 0xFC, 0x30, 0x31, 0x31, 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, 0x15, 0x23, + 0x35, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x01, 0x77, 0xFA, 0x01, 0x77, 0xFA, + 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3A, 0x40, 0x21, 0x0E, 0x0E, + 0x08, 0x0C, 0x00, 0x06, 0x02, 0x02, 0x0B, 0x08, 0x00, 0x0B, 0x04, 0x05, + 0x06, 0x00, 0x06, 0x06, 0x02, 0x0C, 0x02, 0x07, 0x0B, 0x03, 0x0D, 0x06, + 0x01, 0x0D, 0x04, 0x02, 0x01, 0x0B, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, 0x15, 0x33, + 0x11, 0x21, 0x15, 0x33, 0x15, 0x23, 0x37, 0x33, 0x15, 0x23, 0x82, 0xF5, + 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0x82, 0xF5, 0xF5, 0xFA, 0xFA, 0x02, 0x71, + 0xFA, 0x7D, 0xFA, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, 0x0A, 0x00, + 0x00, 0x08, 0x00, 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x09, + 0x02, 0x04, 0x0B, 0x07, 0x01, 0x0B, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, + 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x07, 0x23, + 0x35, 0x33, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, + 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x32, 0x40, 0x1D, + 0x0B, 0x00, 0x03, 0x05, 0x05, 0x0D, 0x08, 0x00, 0x0D, 0x04, 0x00, 0x00, + 0x01, 0x03, 0x06, 0x01, 0x02, 0x08, 0x0C, 0x0C, 0x01, 0x03, 0x04, 0x00, + 0x04, 0x04, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, 0x17, 0x15, + 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xF5, 0xF5, + 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0D, 0x00, 0x01, 0x08, + 0x00, 0x00, 0x05, 0x05, 0x0A, 0x03, 0x03, 0x0F, 0x0A, 0x00, 0x0F, 0x04, + 0x01, 0x06, 0x00, 0x02, 0x0A, 0x0E, 0x08, 0x0D, 0x06, 0x02, 0x02, 0x01, + 0x0D, 0x04, 0x0E, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x21, 0x35, 0x23, 0x35, + 0x33, 0x35, 0x07, 0x15, 0x23, 0x35, 0x17, 0x15, 0x23, 0x35, 0x01, 0xF4, + 0x7D, 0x7D, 0x82, 0xF5, 0xF5, 0xF5, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0x7D, + 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x05, 0x00, 0x10, 0x40, 0x08, + 0x00, 0x00, 0x01, 0x02, 0x04, 0x01, 0x03, 0x04, 0x2B, 0x00, 0x3F, 0xFC, + 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x33, 0x11, 0x01, 0x77, 0xFE, 0x89, + 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x01, 0xF4, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x2E, + 0x40, 0x1B, 0x0B, 0x00, 0x03, 0x0A, 0x00, 0x07, 0x05, 0x00, 0x03, 0x01, + 0x00, 0x03, 0x00, 0x00, 0x07, 0x03, 0x06, 0x07, 0x02, 0x06, 0x01, 0x0B, + 0x04, 0x0C, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, + 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x13, 0x11, + 0x23, 0x15, 0x21, 0x35, 0x23, 0x11, 0x21, 0x15, 0x33, 0x11, 0x23, 0x11, + 0x3F, 0x3F, 0x02, 0x71, 0x3E, 0xFE, 0x89, 0xFA, 0xF5, 0x01, 0xF4, 0xFE, + 0x89, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0xFE, 0x89, 0x01, 0x77, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x23, + 0x40, 0x14, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, + 0x03, 0x06, 0x01, 0x02, 0x0A, 0x06, 0x06, 0x01, 0x03, 0x04, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x30, 0x31, 0x01, + 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, 0x01, 0xF4, 0x7D, + 0xFD, 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x71, 0x02, 0x71, 0x00, 0x13, 0x00, 0x17, 0x00, 0x1B, 0x00, 0x7C, + 0x40, 0x44, 0x1A, 0x1A, 0x10, 0x12, 0x12, 0x17, 0x0C, 0x0C, 0x10, 0x08, + 0x08, 0x10, 0x06, 0x06, 0x17, 0x02, 0x02, 0x17, 0x10, 0x00, 0x17, 0x04, + 0x15, 0x06, 0x04, 0x06, 0x00, 0x06, 0x19, 0x02, 0x0E, 0x02, 0x0A, 0x02, + 0x15, 0x12, 0x0F, 0x17, 0x0D, 0x12, 0x12, 0x01, 0x17, 0x04, 0x0B, 0x13, + 0x01, 0x0A, 0x09, 0x02, 0x07, 0x19, 0x07, 0x1A, 0x05, 0x1B, 0x01, 0x19, + 0x03, 0x19, 0x03, 0x1A, 0x01, 0x0A, 0x19, 0x01, 0x0A, 0x04, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x3B, 0x01, 0x35, 0x33, 0x15, 0x33, 0x35, 0x23, + 0x35, 0x23, 0x35, 0x23, 0x15, 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, + 0x07, 0x33, 0x35, 0x23, 0x01, 0x23, 0x15, 0x33, 0xFA, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x02, 0x71, + 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, + 0xFA, 0x01, 0x77, 0xFA, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x06, 0x00, 0x08, 0x02, + 0x00, 0x05, 0x04, 0x00, 0x00, 0x0A, 0x08, 0x06, 0x0A, 0x02, 0x07, 0x00, + 0x01, 0x06, 0x09, 0x01, 0x06, 0x04, 0x03, 0x01, 0x00, 0x04, 0x2B, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, + 0x30, 0x31, 0x11, 0x21, 0x15, 0x23, 0x15, 0x33, 0x15, 0x21, 0x15, 0x21, + 0x11, 0x21, 0x01, 0x77, 0xFA, 0xFA, 0xFE, 0x89, 0x01, 0xF4, 0xFE, 0x0C, + 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x24, 0x40, 0x15, + 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, 0x06, 0x09, 0x02, 0x03, 0x02, 0x07, + 0x02, 0x02, 0x01, 0x05, 0x04, 0x08, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x11, + 0x23, 0x11, 0x23, 0x11, 0x33, 0x15, 0x21, 0x11, 0x01, 0x77, 0xFA, 0x7D, + 0x7D, 0x01, 0x77, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, + 0x02, 0x71, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0x6B, + 0x00, 0x09, 0x00, 0x0D, 0x00, 0x31, 0x40, 0x1D, 0x0C, 0x00, 0x0B, 0x04, + 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, 0x06, 0x09, 0x02, 0x03, 0x02, 0x0B, + 0x00, 0x0A, 0x02, 0x07, 0x02, 0x02, 0x01, 0x05, 0x04, 0x09, 0x01, 0x00, + 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x30, 0x31, 0x01, 0x11, 0x23, 0x11, 0x23, + 0x11, 0x33, 0x15, 0x21, 0x11, 0x25, 0x33, 0x35, 0x23, 0x01, 0x77, 0xFA, + 0x7D, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0xFA, 0xFA, 0x02, 0x71, 0xFE, 0x0C, + 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0E, 0x0E, 0x04, 0x02, 0x02, 0x0A, + 0x04, 0x00, 0x0A, 0x04, 0x0B, 0x06, 0x00, 0x06, 0x0D, 0x02, 0x06, 0x02, + 0x0A, 0x0E, 0x08, 0x0F, 0x03, 0x0E, 0x0F, 0x01, 0x0E, 0x04, 0x01, 0x06, + 0x06, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, 0x35, 0x23, 0x35, 0x23, + 0x01, 0x35, 0x23, 0x15, 0x13, 0x23, 0x15, 0x33, 0x7D, 0xFA, 0xFA, 0x7D, + 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0xFD, 0x8F, 0xFA, + 0xFA, 0x02, 0x71, 0xFA, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x26, 0x40, 0x16, 0x06, 0x00, + 0x02, 0x04, 0x00, 0x02, 0x08, 0x06, 0x00, 0x06, 0x02, 0x02, 0x03, 0x08, + 0x08, 0x01, 0x07, 0x04, 0x02, 0x01, 0x05, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x33, + 0x11, 0x21, 0x15, 0x33, 0x21, 0x11, 0x33, 0x11, 0x01, 0x77, 0x7D, 0xFE, + 0x89, 0xFA, 0xFE, 0x89, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, 0x01, 0xF4, + 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x64, 0x40, 0x39, + 0x0E, 0x0E, 0x11, 0x0C, 0x00, 0x04, 0x0C, 0x0C, 0x12, 0x09, 0x09, 0x11, + 0x00, 0x12, 0x00, 0x04, 0x0B, 0x06, 0x06, 0x06, 0x01, 0x06, 0x04, 0x02, + 0x00, 0x02, 0x10, 0x07, 0x0C, 0x00, 0x0A, 0x12, 0x08, 0x0D, 0x08, 0x0E, + 0x04, 0x13, 0x03, 0x01, 0x00, 0x04, 0x00, 0x0F, 0x01, 0x0D, 0x0D, 0x01, + 0x12, 0x04, 0x12, 0x01, 0x07, 0x07, 0x01, 0x06, 0x04, 0x2B, 0x10, 0xFC, + 0x2B, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x10, + 0xFC, 0xFC, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x01, 0x11, 0x33, 0x11, 0x21, 0x23, 0x11, 0x3B, 0x01, 0x11, + 0x23, 0x11, 0x13, 0x23, 0x15, 0x33, 0x21, 0x33, 0x35, 0x23, 0x01, 0xF4, + 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0xFE, 0x89, + 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0xFD, 0x8F, 0x01, 0x77, + 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, 0x40, 0x18, 0x01, 0x00, + 0x08, 0x04, 0x0A, 0x06, 0x05, 0x06, 0x0B, 0x02, 0x03, 0x02, 0x02, 0x06, + 0x06, 0x01, 0x05, 0x04, 0x00, 0x09, 0x0A, 0x01, 0x09, 0x04, 0x2B, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x30, 0x31, + 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, + 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFD, + 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, + 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, 0x02, 0x05, 0x01, 0x02, + 0x04, 0x00, 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0xFC, 0x10, + 0xFC, 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, 0x33, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, + 0x7D, 0x01, 0x77, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, 0x03, 0x00, 0x00, 0x06, + 0x06, 0x01, 0x06, 0x00, 0x02, 0x06, 0x01, 0x05, 0x04, 0x02, 0x01, 0x01, + 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x30, 0x31, 0x19, + 0x01, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, 0x7D, 0xFA, 0x7D, 0x02, 0x71, + 0xFD, 0x8F, 0x01, 0xF4, 0xFE, 0x0C, 0x02, 0x71, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1A, 0x40, 0x0E, + 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x06, 0x01, + 0x03, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x11, 0x01, 0xF4, 0xFE, 0x0C, + 0x01, 0xF4, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x01, 0x77, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x1A, 0x40, 0x0E, 0x06, 0x00, 0x00, 0x02, 0x00, 0x00, 0x05, 0x06, + 0x00, 0x02, 0x05, 0x01, 0x04, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, + 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, 0x15, 0x33, 0x11, 0x33, 0x11, 0x33, + 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, + 0x01, 0xF4, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, + 0x04, 0x09, 0x06, 0x0B, 0x02, 0x03, 0x02, 0x08, 0x05, 0x02, 0x01, 0x05, + 0x04, 0x00, 0x07, 0x0A, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x15, + 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, 0x01, 0x77, + 0xFA, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0x02, 0x71, 0xFA, 0xFA, + 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x66, + 0x40, 0x39, 0x10, 0x10, 0x0C, 0x0E, 0x0E, 0x12, 0x06, 0x06, 0x0B, 0x00, + 0x0C, 0x0C, 0x13, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, 0x02, 0x04, + 0x00, 0x12, 0x12, 0x00, 0x13, 0x04, 0x09, 0x06, 0x02, 0x02, 0x09, 0x0E, + 0x09, 0x0D, 0x07, 0x13, 0x10, 0x01, 0x06, 0x04, 0x03, 0x13, 0x01, 0x0E, + 0x01, 0x0E, 0x01, 0x0D, 0x00, 0x01, 0x0F, 0x0F, 0x01, 0x0E, 0x04, 0x2B, + 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, + 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0xFC, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x23, 0x35, 0x23, 0x15, 0x23, + 0x11, 0x33, 0x15, 0x33, 0x35, 0x33, 0x27, 0x23, 0x35, 0x33, 0x05, 0x35, + 0x33, 0x15, 0x02, 0x71, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, + 0x7D, 0xFE, 0x89, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x50, + 0x40, 0x2C, 0x10, 0x10, 0x04, 0x09, 0x09, 0x0F, 0x07, 0x07, 0x04, 0x01, + 0x01, 0x0F, 0x04, 0x00, 0x0F, 0x04, 0x0E, 0x06, 0x00, 0x06, 0x12, 0x02, + 0x05, 0x02, 0x0A, 0x13, 0x08, 0x0E, 0x06, 0x0D, 0x04, 0x0E, 0x0E, 0x01, + 0x0D, 0x04, 0x02, 0x13, 0x00, 0x10, 0x10, 0x01, 0x13, 0x04, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x21, 0x35, 0x23, 0x35, + 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x15, 0x25, 0x15, 0x33, 0x35, + 0x25, 0x35, 0x23, 0x15, 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFE, + 0x89, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, + 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x32, 0x02, 0x71, 0x00, 0x09, 0x00, 0x20, 0x40, 0x13, 0x06, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x06, 0x09, 0x02, 0x04, 0x02, 0x08, 0x01, 0x09, + 0x04, 0x03, 0x01, 0x06, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, + 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x35, 0x23, 0x11, 0x23, 0x11, 0x23, + 0x11, 0x23, 0x02, 0x32, 0x3E, 0x7D, 0xFA, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, + 0x0C, 0x01, 0xF4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x09, 0x00, 0x21, 0x40, 0x14, 0x01, 0x00, 0x06, 0x04, + 0x08, 0x06, 0x09, 0x02, 0x03, 0x02, 0x02, 0x01, 0x05, 0x04, 0x00, 0x07, + 0x08, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, + 0x2B, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, 0x33, + 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0x7D, 0x02, 0x71, 0xFA, 0xFA, + 0xFE, 0x89, 0xFA, 0x02, 0x71, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, 0x40, 0x19, 0x07, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x06, 0x0A, 0x02, 0x05, 0x02, 0x01, 0x02, 0x08, + 0x01, 0x0B, 0x04, 0x04, 0x01, 0x07, 0x04, 0x00, 0x01, 0x03, 0x04, 0x2B, + 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x21, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, + 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFE, 0x0C, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x02, 0xAF, 0x02, 0x71, 0x00, 0x0D, 0x00, 0x2D, 0x40, 0x1C, + 0x09, 0x00, 0x00, 0x05, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x0C, 0x02, + 0x07, 0x02, 0x03, 0x02, 0x0A, 0x01, 0x0D, 0x04, 0x06, 0x01, 0x09, 0x04, + 0x02, 0x01, 0x05, 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, + 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x35, 0x23, 0x11, 0x23, + 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x02, 0xAF, 0x3E, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, + 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x32, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, + 0x09, 0x00, 0x02, 0x05, 0x00, 0x0B, 0x04, 0x02, 0x06, 0x07, 0x02, 0x07, + 0x01, 0x0A, 0x05, 0x0A, 0x03, 0x01, 0x09, 0x04, 0x0A, 0x01, 0x02, 0x04, + 0x0A, 0x06, 0x10, 0xD0, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0x00, 0x3F, + 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x11, 0x33, 0x11, 0x21, 0x11, 0x21, + 0x35, 0x23, 0x01, 0x15, 0x23, 0x35, 0x3E, 0x01, 0xF4, 0xFE, 0x89, 0xBB, + 0x01, 0xB5, 0xFA, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0x77, 0xFA, 0xFE, 0x89, + 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, 0x02, 0x71, + 0x00, 0x05, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x29, 0x40, 0x19, 0x0B, 0x00, + 0x06, 0x03, 0x00, 0x0D, 0x04, 0x06, 0x06, 0x00, 0x06, 0x09, 0x02, 0x04, + 0x02, 0x0C, 0x04, 0x04, 0x01, 0x05, 0x04, 0x01, 0x01, 0x0B, 0x04, 0x2B, + 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, + 0x31, 0x31, 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, 0x33, 0x11, 0x23, 0x03, + 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x02, 0x71, 0x7D, 0x7D, + 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0xFD, 0x8F, 0x02, 0x71, 0xFE, 0x89, 0x7D, + 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x05, 0x00, 0x09, 0x00, 0x23, 0x40, 0x15, 0x07, 0x00, 0x00, 0x03, + 0x00, 0x09, 0x04, 0x00, 0x06, 0x05, 0x02, 0x08, 0x04, 0x04, 0x01, 0x05, + 0x04, 0x01, 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, + 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x01, 0x77, 0xFA, 0x01, + 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3A, 0x40, 0x21, + 0x0E, 0x0E, 0x08, 0x0C, 0x00, 0x06, 0x02, 0x02, 0x0B, 0x08, 0x00, 0x0B, + 0x04, 0x05, 0x06, 0x00, 0x06, 0x06, 0x02, 0x0C, 0x02, 0x07, 0x0B, 0x03, + 0x0D, 0x06, 0x01, 0x0D, 0x04, 0x02, 0x01, 0x0B, 0x04, 0x2B, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, + 0x15, 0x33, 0x11, 0x21, 0x15, 0x33, 0x15, 0x23, 0x37, 0x33, 0x15, 0x23, + 0x82, 0xF5, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0x82, 0xF5, 0xF5, 0xFA, 0xFA, + 0x02, 0x71, 0xFA, 0x7D, 0xFA, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, + 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, + 0x02, 0x09, 0x02, 0x04, 0x0B, 0x07, 0x01, 0x0B, 0x04, 0x02, 0x01, 0x01, + 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, + 0x07, 0x23, 0x35, 0x33, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFA, 0x02, 0x71, + 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x7D, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x32, + 0x40, 0x1D, 0x0B, 0x00, 0x03, 0x05, 0x05, 0x0D, 0x08, 0x00, 0x0D, 0x04, + 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x08, 0x0C, 0x0C, 0x01, 0x03, + 0x04, 0x00, 0x04, 0x04, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, + 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, + 0x17, 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, + 0xF5, 0xF5, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, + 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0D, 0x00, + 0x01, 0x08, 0x00, 0x00, 0x05, 0x05, 0x0A, 0x03, 0x03, 0x0F, 0x0A, 0x00, + 0x0F, 0x04, 0x01, 0x06, 0x00, 0x02, 0x0A, 0x0E, 0x08, 0x0D, 0x06, 0x02, + 0x02, 0x01, 0x0D, 0x04, 0x0E, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x21, 0x35, + 0x23, 0x35, 0x33, 0x35, 0x07, 0x15, 0x23, 0x35, 0x17, 0x15, 0x23, 0x35, + 0x01, 0xF4, 0x7D, 0x7D, 0x82, 0xF5, 0xF5, 0xF5, 0x02, 0x71, 0xFD, 0x8F, + 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x05, 0x00, 0x10, + 0x40, 0x08, 0x00, 0x00, 0x01, 0x02, 0x04, 0x01, 0x03, 0x04, 0x2B, 0x00, + 0x3F, 0xFC, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x33, 0x11, 0x01, 0x77, + 0xFE, 0x89, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x01, 0xF4, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x09, 0x00, 0x0D, + 0x00, 0x2E, 0x40, 0x1B, 0x0B, 0x00, 0x03, 0x0A, 0x00, 0x07, 0x05, 0x00, + 0x03, 0x01, 0x00, 0x03, 0x00, 0x00, 0x07, 0x03, 0x06, 0x07, 0x02, 0x06, + 0x01, 0x0B, 0x04, 0x0C, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, + 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x13, 0x11, 0x23, 0x15, 0x21, 0x35, 0x23, 0x11, 0x21, 0x15, 0x33, 0x11, + 0x23, 0x11, 0x3F, 0x3F, 0x02, 0x71, 0x3E, 0xFE, 0x89, 0xFA, 0xF5, 0x01, + 0xF4, 0xFE, 0x89, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0xFE, 0x89, 0x01, 0x77, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, + 0x00, 0x23, 0x40, 0x14, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, + 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x0A, 0x06, 0x06, 0x01, 0x03, 0x04, + 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x30, + 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, + 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, 0x01, + 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x13, 0x00, 0x17, 0x00, 0x1B, + 0x00, 0x7C, 0x40, 0x44, 0x1A, 0x1A, 0x10, 0x12, 0x12, 0x17, 0x0C, 0x0C, + 0x10, 0x08, 0x08, 0x10, 0x06, 0x06, 0x17, 0x02, 0x02, 0x17, 0x10, 0x00, + 0x17, 0x04, 0x15, 0x06, 0x04, 0x06, 0x00, 0x06, 0x19, 0x02, 0x0E, 0x02, + 0x0A, 0x02, 0x15, 0x12, 0x0F, 0x17, 0x0D, 0x12, 0x12, 0x01, 0x17, 0x04, + 0x0B, 0x13, 0x01, 0x0A, 0x09, 0x02, 0x07, 0x19, 0x07, 0x1A, 0x05, 0x1B, + 0x01, 0x19, 0x03, 0x19, 0x03, 0x1A, 0x01, 0x0A, 0x19, 0x01, 0x0A, 0x04, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x3B, 0x01, 0x35, 0x33, 0x15, 0x33, + 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, 0x23, 0x35, 0x23, 0x15, 0x33, + 0x15, 0x33, 0x07, 0x33, 0x35, 0x23, 0x01, 0x23, 0x15, 0x33, 0xFA, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, + 0x02, 0x71, 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, + 0x7D, 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x06, 0x00, + 0x08, 0x02, 0x00, 0x05, 0x04, 0x00, 0x00, 0x0A, 0x08, 0x06, 0x0A, 0x02, + 0x07, 0x00, 0x01, 0x06, 0x09, 0x01, 0x06, 0x04, 0x03, 0x01, 0x00, 0x04, + 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, + 0x10, 0xFC, 0x30, 0x31, 0x11, 0x21, 0x15, 0x23, 0x15, 0x33, 0x15, 0x21, + 0x15, 0x21, 0x11, 0x21, 0x01, 0x77, 0xFA, 0xFA, 0xFE, 0x89, 0x01, 0xF4, + 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x24, + 0x40, 0x15, 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, 0x06, 0x09, 0x02, 0x03, + 0x02, 0x07, 0x02, 0x02, 0x01, 0x05, 0x04, 0x08, 0x01, 0x01, 0x04, 0x2B, + 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x11, 0x23, 0x11, 0x23, 0x11, 0x33, 0x15, 0x21, 0x11, 0x01, 0x77, + 0xFA, 0x7D, 0x7D, 0x01, 0x77, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, + 0x0C, 0x7D, 0x02, 0x71, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x03, 0x6B, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x31, 0x40, 0x1D, 0x0C, 0x00, + 0x0B, 0x04, 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, 0x06, 0x09, 0x02, 0x03, + 0x02, 0x0B, 0x00, 0x0A, 0x02, 0x07, 0x02, 0x02, 0x01, 0x05, 0x04, 0x09, + 0x01, 0x00, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x30, 0x31, 0x01, 0x11, 0x23, + 0x11, 0x23, 0x11, 0x33, 0x15, 0x21, 0x11, 0x25, 0x33, 0x35, 0x23, 0x01, + 0x77, 0xFA, 0x7D, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0xFA, 0xFA, 0x02, 0x71, + 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0E, 0x0E, 0x04, 0x02, + 0x02, 0x0A, 0x04, 0x00, 0x0A, 0x04, 0x0B, 0x06, 0x00, 0x06, 0x0D, 0x02, + 0x06, 0x02, 0x0A, 0x0E, 0x08, 0x0F, 0x03, 0x0E, 0x0F, 0x01, 0x0E, 0x04, + 0x01, 0x06, 0x06, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, 0x35, 0x23, + 0x35, 0x23, 0x01, 0x35, 0x23, 0x15, 0x13, 0x23, 0x15, 0x33, 0x7D, 0xFA, + 0xFA, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0xFD, + 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x26, 0x40, 0x16, + 0x06, 0x00, 0x02, 0x04, 0x00, 0x02, 0x08, 0x06, 0x00, 0x06, 0x02, 0x02, + 0x03, 0x08, 0x08, 0x01, 0x07, 0x04, 0x02, 0x01, 0x05, 0x04, 0x2B, 0x2B, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x21, 0x33, 0x11, 0x21, 0x15, 0x33, 0x21, 0x11, 0x33, 0x11, 0x01, 0x77, + 0x7D, 0xFE, 0x89, 0xFA, 0xFE, 0x89, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, + 0x01, 0xF4, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, + 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x64, + 0x40, 0x39, 0x0E, 0x0E, 0x11, 0x0C, 0x00, 0x04, 0x0C, 0x0C, 0x12, 0x09, + 0x09, 0x11, 0x00, 0x12, 0x00, 0x04, 0x0B, 0x06, 0x06, 0x06, 0x01, 0x06, + 0x04, 0x02, 0x00, 0x02, 0x10, 0x07, 0x0C, 0x00, 0x0A, 0x12, 0x08, 0x0D, + 0x08, 0x0E, 0x04, 0x13, 0x03, 0x01, 0x00, 0x04, 0x00, 0x0F, 0x01, 0x0D, + 0x0D, 0x01, 0x12, 0x04, 0x12, 0x01, 0x07, 0x07, 0x01, 0x06, 0x04, 0x2B, + 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x10, 0xFC, 0xFC, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x11, 0x33, 0x11, 0x21, 0x23, 0x11, 0x3B, + 0x01, 0x11, 0x23, 0x11, 0x13, 0x23, 0x15, 0x33, 0x21, 0x33, 0x35, 0x23, + 0x01, 0xF4, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, + 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0xFD, 0x8F, + 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, 0x40, 0x18, + 0x01, 0x00, 0x08, 0x04, 0x0A, 0x06, 0x05, 0x06, 0x0B, 0x02, 0x03, 0x02, + 0x02, 0x06, 0x06, 0x01, 0x05, 0x04, 0x00, 0x09, 0x0A, 0x01, 0x09, 0x04, + 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, + 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, 0x33, 0x15, + 0x33, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, + 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x1D, + 0x40, 0x11, 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, 0x02, 0x05, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, + 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, + 0x33, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, 0x02, 0x71, + 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, 0x03, 0x00, + 0x00, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x06, 0x01, 0x05, 0x04, 0x02, + 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x30, + 0x31, 0x19, 0x01, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, 0x7D, 0xFA, 0x7D, + 0x02, 0x71, 0xFD, 0x8F, 0x01, 0xF4, 0xFE, 0x0C, 0x02, 0x71, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1A, + 0x40, 0x0E, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, + 0x06, 0x01, 0x03, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x11, 0x01, 0xF4, + 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, + 0x01, 0x77, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x1A, 0x40, 0x0E, 0x06, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x05, 0x06, 0x00, 0x02, 0x05, 0x01, 0x04, 0x04, 0x2B, 0x00, 0x3F, 0x3F, + 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, 0x15, 0x33, 0x11, 0x33, + 0x11, 0x33, 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0x7D, + 0xFE, 0x0C, 0x01, 0xF4, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, 0x07, 0x00, 0x09, 0x01, + 0x00, 0x06, 0x04, 0x09, 0x06, 0x0B, 0x02, 0x03, 0x02, 0x08, 0x05, 0x02, + 0x01, 0x05, 0x04, 0x00, 0x07, 0x0A, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, + 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, + 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0x02, 0x71, + 0xFA, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, + 0x00, 0x66, 0x40, 0x39, 0x10, 0x10, 0x0C, 0x0E, 0x0E, 0x12, 0x06, 0x06, + 0x0B, 0x00, 0x0C, 0x0C, 0x13, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, + 0x02, 0x04, 0x00, 0x12, 0x12, 0x00, 0x13, 0x04, 0x09, 0x06, 0x02, 0x02, + 0x09, 0x0E, 0x09, 0x0D, 0x07, 0x13, 0x10, 0x01, 0x06, 0x04, 0x03, 0x13, + 0x01, 0x0E, 0x01, 0x0E, 0x01, 0x0D, 0x00, 0x01, 0x0F, 0x0F, 0x01, 0x0E, + 0x04, 0x2B, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, + 0x10, 0xFC, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0xFC, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x23, 0x35, 0x23, + 0x15, 0x23, 0x11, 0x33, 0x15, 0x33, 0x35, 0x33, 0x27, 0x23, 0x35, 0x33, + 0x05, 0x35, 0x33, 0x15, 0x02, 0x71, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0xFA, + 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, 0xFE, 0x89, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, + 0x00, 0x50, 0x40, 0x2C, 0x10, 0x10, 0x04, 0x09, 0x09, 0x0F, 0x07, 0x07, + 0x04, 0x01, 0x01, 0x0F, 0x04, 0x00, 0x0F, 0x04, 0x0E, 0x06, 0x00, 0x06, + 0x12, 0x02, 0x05, 0x02, 0x0A, 0x13, 0x08, 0x0E, 0x06, 0x0D, 0x04, 0x0E, + 0x0E, 0x01, 0x0D, 0x04, 0x02, 0x13, 0x00, 0x10, 0x10, 0x01, 0x13, 0x04, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x21, 0x35, + 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x15, 0x25, 0x15, + 0x33, 0x35, 0x25, 0x35, 0x23, 0x15, 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0x7D, + 0xFA, 0xFE, 0x89, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, + 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x32, 0x02, 0x71, 0x00, 0x09, 0x00, 0x20, 0x40, 0x13, + 0x06, 0x00, 0x00, 0x02, 0x00, 0x00, 0x06, 0x09, 0x02, 0x04, 0x02, 0x08, + 0x01, 0x09, 0x04, 0x03, 0x01, 0x06, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, + 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x35, 0x23, 0x11, 0x23, + 0x11, 0x23, 0x11, 0x23, 0x02, 0x32, 0x3E, 0x7D, 0xFA, 0x7D, 0x7D, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, 0x40, 0x19, 0x07, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x06, 0x0A, 0x02, 0x05, 0x02, 0x01, 0x02, 0x08, + 0x01, 0x0B, 0x04, 0x04, 0x01, 0x07, 0x04, 0x00, 0x01, 0x03, 0x04, 0x2B, + 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x21, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, + 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFE, 0x0C, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x02, 0xAF, 0x02, 0x71, 0x00, 0x0D, 0x00, 0x2D, 0x40, 0x1C, + 0x09, 0x00, 0x00, 0x05, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x0C, 0x02, + 0x07, 0x02, 0x03, 0x02, 0x0A, 0x01, 0x0D, 0x04, 0x06, 0x01, 0x09, 0x04, + 0x02, 0x01, 0x05, 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, + 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x35, 0x23, 0x11, 0x23, + 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x02, 0xAF, 0x3E, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, + 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x32, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, + 0x09, 0x00, 0x02, 0x05, 0x00, 0x0B, 0x04, 0x02, 0x06, 0x07, 0x02, 0x07, + 0x01, 0x0A, 0x05, 0x0A, 0x03, 0x01, 0x09, 0x04, 0x0A, 0x01, 0x02, 0x04, + 0x0A, 0x06, 0x10, 0xD0, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0x00, 0x3F, + 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x11, 0x33, 0x11, 0x21, 0x11, 0x21, + 0x35, 0x23, 0x01, 0x15, 0x23, 0x35, 0x3E, 0x01, 0xF4, 0xFE, 0x89, 0xBB, + 0x01, 0xB5, 0xFA, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0x77, 0xFA, 0xFE, 0x89, + 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, 0x02, 0x71, + 0x00, 0x05, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x29, 0x40, 0x19, 0x0B, 0x00, + 0x06, 0x03, 0x00, 0x0D, 0x04, 0x06, 0x06, 0x00, 0x06, 0x09, 0x02, 0x04, + 0x02, 0x0C, 0x04, 0x04, 0x01, 0x05, 0x04, 0x01, 0x01, 0x0B, 0x04, 0x2B, + 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, + 0x31, 0x31, 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, 0x33, 0x11, 0x23, 0x03, + 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x02, 0x71, 0x7D, 0x7D, + 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0xFD, 0x8F, 0x02, 0x71, 0xFE, 0x89, 0x7D, + 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x05, 0x00, 0x09, 0x00, 0x23, 0x40, 0x15, 0x07, 0x00, 0x00, 0x03, + 0x00, 0x09, 0x04, 0x00, 0x06, 0x05, 0x02, 0x08, 0x04, 0x04, 0x01, 0x05, + 0x04, 0x01, 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, + 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x01, 0x77, 0xFA, 0x01, + 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3A, 0x40, 0x21, + 0x0E, 0x0E, 0x08, 0x0C, 0x00, 0x06, 0x02, 0x02, 0x0B, 0x08, 0x00, 0x0B, + 0x04, 0x05, 0x06, 0x00, 0x06, 0x06, 0x02, 0x0C, 0x02, 0x07, 0x0B, 0x03, + 0x0D, 0x06, 0x01, 0x0D, 0x04, 0x02, 0x01, 0x0B, 0x04, 0x2B, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, + 0x15, 0x33, 0x11, 0x21, 0x15, 0x33, 0x15, 0x23, 0x37, 0x33, 0x15, 0x23, + 0x82, 0xF5, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0x82, 0xF5, 0xF5, 0xFA, 0xFA, + 0x02, 0x71, 0xFA, 0x7D, 0xFA, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, + 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, + 0x02, 0x09, 0x02, 0x04, 0x0B, 0x07, 0x01, 0x0B, 0x04, 0x02, 0x01, 0x01, + 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, + 0x07, 0x23, 0x35, 0x33, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFA, 0x02, 0x71, + 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x7D, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x32, + 0x40, 0x1D, 0x0B, 0x00, 0x03, 0x05, 0x05, 0x0D, 0x08, 0x00, 0x0D, 0x04, + 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x08, 0x0C, 0x0C, 0x01, 0x03, + 0x04, 0x00, 0x04, 0x04, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, + 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, + 0x17, 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, + 0xF5, 0xF5, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, + 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0D, 0x00, + 0x01, 0x08, 0x00, 0x00, 0x05, 0x05, 0x0A, 0x03, 0x03, 0x0F, 0x0A, 0x00, + 0x0F, 0x04, 0x01, 0x06, 0x00, 0x02, 0x0A, 0x0E, 0x08, 0x0D, 0x06, 0x02, + 0x02, 0x01, 0x0D, 0x04, 0x0E, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x21, 0x35, + 0x23, 0x35, 0x33, 0x35, 0x07, 0x15, 0x23, 0x35, 0x17, 0x15, 0x23, 0x35, + 0x01, 0xF4, 0x7D, 0x7D, 0x82, 0xF5, 0xF5, 0xF5, 0x02, 0x71, 0xFD, 0x8F, + 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x05, 0x00, 0x10, + 0x40, 0x08, 0x00, 0x00, 0x01, 0x02, 0x04, 0x01, 0x03, 0x04, 0x2B, 0x00, + 0x3F, 0xFC, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x33, 0x11, 0x01, 0x77, + 0xFE, 0x89, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x01, 0xF4, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x09, 0x00, 0x0D, + 0x00, 0x2E, 0x40, 0x1B, 0x0B, 0x00, 0x03, 0x0A, 0x00, 0x07, 0x05, 0x00, + 0x03, 0x01, 0x00, 0x03, 0x00, 0x00, 0x07, 0x03, 0x06, 0x07, 0x02, 0x06, + 0x01, 0x0B, 0x04, 0x0C, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, + 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x13, 0x11, 0x23, 0x15, 0x21, 0x35, 0x23, 0x11, 0x21, 0x15, 0x33, 0x11, + 0x23, 0x11, 0x3F, 0x3F, 0x02, 0x71, 0x3E, 0xFE, 0x89, 0xFA, 0xF5, 0x01, + 0xF4, 0xFE, 0x89, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0xFE, 0x89, 0x01, 0x77, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, + 0x00, 0x23, 0x40, 0x14, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, + 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x0A, 0x06, 0x06, 0x01, 0x03, 0x04, + 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x30, + 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, + 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, 0x01, + 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x13, 0x00, 0x17, 0x00, 0x1B, + 0x00, 0x7C, 0x40, 0x44, 0x1A, 0x1A, 0x10, 0x12, 0x12, 0x17, 0x0C, 0x0C, + 0x10, 0x08, 0x08, 0x10, 0x06, 0x06, 0x17, 0x02, 0x02, 0x17, 0x10, 0x00, + 0x17, 0x04, 0x15, 0x06, 0x04, 0x06, 0x00, 0x06, 0x19, 0x02, 0x0E, 0x02, + 0x0A, 0x02, 0x15, 0x12, 0x0F, 0x17, 0x0D, 0x12, 0x12, 0x01, 0x17, 0x04, + 0x0B, 0x13, 0x01, 0x0A, 0x09, 0x02, 0x07, 0x19, 0x07, 0x1A, 0x05, 0x1B, + 0x01, 0x19, 0x03, 0x19, 0x03, 0x1A, 0x01, 0x0A, 0x19, 0x01, 0x0A, 0x04, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x3B, 0x01, 0x35, 0x33, 0x15, 0x33, + 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, 0x23, 0x35, 0x23, 0x15, 0x33, + 0x15, 0x33, 0x07, 0x33, 0x35, 0x23, 0x01, 0x23, 0x15, 0x33, 0xFA, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, + 0x02, 0x71, 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, + 0x7D, 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x06, 0x00, + 0x08, 0x02, 0x00, 0x05, 0x04, 0x00, 0x00, 0x0A, 0x08, 0x06, 0x0A, 0x02, + 0x07, 0x00, 0x01, 0x06, 0x09, 0x01, 0x06, 0x04, 0x03, 0x01, 0x00, 0x04, + 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, + 0x10, 0xFC, 0x30, 0x31, 0x11, 0x21, 0x15, 0x23, 0x15, 0x33, 0x15, 0x21, + 0x15, 0x21, 0x11, 0x21, 0x01, 0x77, 0xFA, 0xFA, 0xFE, 0x89, 0x01, 0xF4, + 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x24, + 0x40, 0x15, 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, 0x06, 0x09, 0x02, 0x03, + 0x02, 0x07, 0x02, 0x02, 0x01, 0x05, 0x04, 0x08, 0x01, 0x01, 0x04, 0x2B, + 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x11, 0x23, 0x11, 0x23, 0x11, 0x33, 0x15, 0x21, 0x11, 0x01, 0x77, + 0xFA, 0x7D, 0x7D, 0x01, 0x77, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, + 0x0C, 0x7D, 0x02, 0x71, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x03, 0x6B, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x31, 0x40, 0x1D, 0x0C, 0x00, + 0x0B, 0x04, 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, 0x06, 0x09, 0x02, 0x03, + 0x02, 0x0B, 0x00, 0x0A, 0x02, 0x07, 0x02, 0x02, 0x01, 0x05, 0x04, 0x09, + 0x01, 0x00, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x30, 0x31, 0x01, 0x11, 0x23, + 0x11, 0x23, 0x11, 0x33, 0x15, 0x21, 0x11, 0x25, 0x33, 0x35, 0x23, 0x01, + 0x77, 0xFA, 0x7D, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0xFA, 0xFA, 0x02, 0x71, + 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0E, 0x0E, 0x04, 0x02, + 0x02, 0x0A, 0x04, 0x00, 0x0A, 0x04, 0x0B, 0x06, 0x00, 0x06, 0x0D, 0x02, + 0x06, 0x02, 0x0A, 0x0E, 0x08, 0x0F, 0x03, 0x0E, 0x0F, 0x01, 0x0E, 0x04, + 0x01, 0x06, 0x06, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, 0x35, 0x23, + 0x35, 0x23, 0x01, 0x35, 0x23, 0x15, 0x13, 0x23, 0x15, 0x33, 0x7D, 0xFA, + 0xFA, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0xFD, + 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x26, 0x40, 0x16, + 0x06, 0x00, 0x02, 0x04, 0x00, 0x02, 0x08, 0x06, 0x00, 0x06, 0x02, 0x02, + 0x03, 0x08, 0x08, 0x01, 0x07, 0x04, 0x02, 0x01, 0x05, 0x04, 0x2B, 0x2B, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x21, 0x33, 0x11, 0x21, 0x15, 0x33, 0x21, 0x11, 0x33, 0x11, 0x01, 0x77, + 0x7D, 0xFE, 0x89, 0xFA, 0xFE, 0x89, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, + 0x01, 0xF4, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, + 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x64, + 0x40, 0x39, 0x0E, 0x0E, 0x11, 0x0C, 0x00, 0x04, 0x0C, 0x0C, 0x12, 0x09, + 0x09, 0x11, 0x00, 0x12, 0x00, 0x04, 0x0B, 0x06, 0x06, 0x06, 0x01, 0x06, + 0x04, 0x02, 0x00, 0x02, 0x10, 0x07, 0x0C, 0x00, 0x0A, 0x12, 0x08, 0x0D, + 0x08, 0x0E, 0x04, 0x13, 0x03, 0x01, 0x00, 0x04, 0x00, 0x0F, 0x01, 0x0D, + 0x0D, 0x01, 0x12, 0x04, 0x12, 0x01, 0x07, 0x07, 0x01, 0x06, 0x04, 0x2B, + 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x10, 0xFC, 0xFC, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x11, 0x33, 0x11, 0x21, 0x23, 0x11, 0x3B, + 0x01, 0x11, 0x23, 0x11, 0x13, 0x23, 0x15, 0x33, 0x21, 0x33, 0x35, 0x23, + 0x01, 0xF4, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, + 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0xFD, 0x8F, + 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, 0x40, 0x18, + 0x01, 0x00, 0x08, 0x04, 0x0A, 0x06, 0x05, 0x06, 0x0B, 0x02, 0x03, 0x02, + 0x02, 0x06, 0x06, 0x01, 0x05, 0x04, 0x00, 0x09, 0x0A, 0x01, 0x09, 0x04, + 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, + 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, 0x33, 0x15, + 0x33, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, + 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x1D, + 0x40, 0x11, 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, 0x02, 0x05, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, + 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, + 0x33, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, 0x02, 0x71, + 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, 0x03, 0x00, + 0x00, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x06, 0x01, 0x05, 0x04, 0x02, + 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x30, + 0x31, 0x19, 0x01, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, 0x7D, 0xFA, 0x7D, + 0x02, 0x71, 0xFD, 0x8F, 0x01, 0xF4, 0xFE, 0x0C, 0x02, 0x71, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1A, + 0x40, 0x0E, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, + 0x06, 0x01, 0x03, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x11, 0x01, 0xF4, + 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, + 0x01, 0x77, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x1A, 0x40, 0x0E, 0x06, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x05, 0x06, 0x00, 0x02, 0x05, 0x01, 0x04, 0x04, 0x2B, 0x00, 0x3F, 0x3F, + 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, 0x15, 0x33, 0x11, 0x33, + 0x11, 0x33, 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0x7D, + 0xFE, 0x0C, 0x01, 0xF4, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, 0x07, 0x00, 0x09, 0x01, + 0x00, 0x06, 0x04, 0x09, 0x06, 0x0B, 0x02, 0x03, 0x02, 0x08, 0x05, 0x02, + 0x01, 0x05, 0x04, 0x00, 0x07, 0x0A, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, + 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, + 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0x02, 0x71, + 0xFA, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, + 0x00, 0x66, 0x40, 0x39, 0x10, 0x10, 0x0C, 0x0E, 0x0E, 0x12, 0x06, 0x06, + 0x0B, 0x00, 0x0C, 0x0C, 0x13, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, + 0x02, 0x04, 0x00, 0x12, 0x12, 0x00, 0x13, 0x04, 0x09, 0x06, 0x02, 0x02, + 0x09, 0x0E, 0x09, 0x0D, 0x07, 0x13, 0x10, 0x01, 0x06, 0x04, 0x03, 0x13, + 0x01, 0x0E, 0x01, 0x0E, 0x01, 0x0D, 0x00, 0x01, 0x0F, 0x0F, 0x01, 0x0E, + 0x04, 0x2B, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, + 0x10, 0xFC, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0xFC, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x23, 0x35, 0x23, + 0x15, 0x23, 0x11, 0x33, 0x15, 0x33, 0x35, 0x33, 0x27, 0x23, 0x35, 0x33, + 0x05, 0x35, 0x33, 0x15, 0x02, 0x71, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0xFA, + 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, 0xFE, 0x89, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, + 0x00, 0x50, 0x40, 0x2C, 0x10, 0x10, 0x04, 0x09, 0x09, 0x0F, 0x07, 0x07, + 0x04, 0x01, 0x01, 0x0F, 0x04, 0x00, 0x0F, 0x04, 0x0E, 0x06, 0x00, 0x06, + 0x12, 0x02, 0x05, 0x02, 0x0A, 0x13, 0x08, 0x0E, 0x06, 0x0D, 0x04, 0x0E, + 0x0E, 0x01, 0x0D, 0x04, 0x02, 0x13, 0x00, 0x10, 0x10, 0x01, 0x13, 0x04, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x21, 0x35, + 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x15, 0x25, 0x15, + 0x33, 0x35, 0x25, 0x35, 0x23, 0x15, 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0x7D, + 0xFA, 0xFE, 0x89, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, + 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x32, 0x02, 0x71, 0x00, 0x09, 0x00, 0x20, 0x40, 0x13, + 0x06, 0x00, 0x00, 0x02, 0x00, 0x00, 0x06, 0x09, 0x02, 0x04, 0x02, 0x08, + 0x01, 0x09, 0x04, 0x03, 0x01, 0x06, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, + 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x35, 0x23, 0x11, 0x23, + 0x11, 0x23, 0x11, 0x23, 0x02, 0x32, 0x3E, 0x7D, 0xFA, 0x7D, 0x7D, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x21, 0x40, 0x14, 0x01, 0x00, + 0x06, 0x04, 0x08, 0x06, 0x09, 0x02, 0x03, 0x02, 0x02, 0x01, 0x05, 0x04, + 0x00, 0x07, 0x08, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x00, 0x3F, + 0x3F, 0x3F, 0x2B, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x21, + 0x15, 0x33, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0x7D, 0x02, 0x71, + 0xFA, 0xFA, 0xFE, 0x89, 0xFA, 0x02, 0x71, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, 0x40, 0x19, + 0x07, 0x00, 0x00, 0x03, 0x00, 0x00, 0x06, 0x0A, 0x02, 0x05, 0x02, 0x01, + 0x02, 0x08, 0x01, 0x0B, 0x04, 0x04, 0x01, 0x07, 0x04, 0x00, 0x01, 0x03, + 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x21, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, + 0x23, 0x11, 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFE, + 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x02, 0xAF, 0x02, 0x71, 0x00, 0x0D, 0x00, 0x2D, + 0x40, 0x1C, 0x09, 0x00, 0x00, 0x05, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, + 0x0C, 0x02, 0x07, 0x02, 0x03, 0x02, 0x0A, 0x01, 0x0D, 0x04, 0x06, 0x01, + 0x09, 0x04, 0x02, 0x01, 0x05, 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, + 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x35, 0x23, + 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x02, + 0xAF, 0x3E, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, + 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x32, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2C, + 0x40, 0x1A, 0x09, 0x00, 0x02, 0x05, 0x00, 0x0B, 0x04, 0x02, 0x06, 0x07, + 0x02, 0x07, 0x01, 0x0A, 0x05, 0x0A, 0x03, 0x01, 0x09, 0x04, 0x0A, 0x01, + 0x02, 0x04, 0x0A, 0x06, 0x10, 0xD0, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xFC, + 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x11, 0x33, 0x11, 0x21, + 0x11, 0x21, 0x35, 0x23, 0x01, 0x15, 0x23, 0x35, 0x3E, 0x01, 0xF4, 0xFE, + 0x89, 0xBB, 0x01, 0xB5, 0xFA, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0x77, 0xFA, + 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, + 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x29, 0x40, 0x19, + 0x0B, 0x00, 0x06, 0x03, 0x00, 0x0D, 0x04, 0x06, 0x06, 0x00, 0x06, 0x09, + 0x02, 0x04, 0x02, 0x0C, 0x04, 0x04, 0x01, 0x05, 0x04, 0x01, 0x01, 0x0B, + 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, + 0xFC, 0x30, 0x31, 0x31, 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, 0x33, 0x11, + 0x23, 0x03, 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x02, 0x71, + 0x7D, 0x7D, 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0xFD, 0x8F, 0x02, 0x71, 0xFE, + 0x89, 0x7D, 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x23, 0x40, 0x15, 0x07, 0x00, + 0x00, 0x03, 0x00, 0x09, 0x04, 0x00, 0x06, 0x05, 0x02, 0x08, 0x04, 0x04, + 0x01, 0x05, 0x04, 0x01, 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x11, 0x21, 0x35, + 0x23, 0x01, 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x01, 0x77, + 0xFA, 0x01, 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3A, + 0x40, 0x21, 0x0E, 0x0E, 0x08, 0x0C, 0x00, 0x06, 0x02, 0x02, 0x0B, 0x08, + 0x00, 0x0B, 0x04, 0x05, 0x06, 0x00, 0x06, 0x06, 0x02, 0x0C, 0x02, 0x07, + 0x0B, 0x03, 0x0D, 0x06, 0x01, 0x0D, 0x04, 0x02, 0x01, 0x0B, 0x04, 0x2B, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, + 0x35, 0x33, 0x15, 0x33, 0x11, 0x21, 0x15, 0x33, 0x15, 0x23, 0x37, 0x33, + 0x15, 0x23, 0x82, 0xF5, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0x82, 0xF5, 0xF5, + 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x7D, 0xFA, 0x7D, 0x00, 0x03, 0x00, 0x00, + 0x00, 0xFA, 0x01, 0xF4, 0x01, 0xF4, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x69, 0x40, 0x38, 0x0D, 0x0D, 0x03, 0x08, 0x08, 0x03, 0x08, 0x08, + 0x0E, 0x05, 0x05, 0x0A, 0x01, 0x01, 0x0F, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x0E, 0x03, 0x00, 0x0A, 0x04, 0x03, 0x03, 0x0E, 0x0F, 0x00, 0x0E, 0x04, + 0x0E, 0x01, 0x06, 0x0C, 0x06, 0x01, 0x00, 0x06, 0x0D, 0x04, 0x00, 0x02, + 0x0A, 0x02, 0x0B, 0x00, 0x01, 0x0A, 0x00, 0x05, 0x0A, 0x01, 0x09, 0x04, + 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xFC, 0x00, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x13, + 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x35, 0x21, 0x15, 0x33, 0x35, 0x37, + 0x15, 0x33, 0x35, 0xFA, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0xFA, 0x7D, + 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x7D, 0x01, 0x77, 0x00, 0x03, + 0x00, 0x0F, 0x40, 0x08, 0x03, 0x00, 0x02, 0x04, 0x02, 0x01, 0x01, 0x04, + 0x2B, 0x00, 0x2B, 0x30, 0x31, 0x11, 0x15, 0x33, 0x35, 0x7D, 0x01, 0x77, + 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x02, 0x71, + 0x00, 0x03, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x0F, 0x04, 0x00, 0x05, 0x01, + 0x06, 0x05, 0x02, 0x01, 0x04, 0x00, 0x07, 0x04, 0x01, 0x07, 0x04, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x30, 0x31, 0x31, + 0x33, 0x11, 0x23, 0x37, 0x35, 0x23, 0x15, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, + 0x77, 0x7D, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x01, 0x77, 0x01, 0x77, + 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x17, 0x40, 0x0D, 0x06, 0x02, + 0x00, 0x02, 0x07, 0x04, 0x01, 0x07, 0x04, 0x03, 0x01, 0x02, 0x04, 0x2B, + 0x2B, 0x00, 0x2F, 0x3F, 0x3F, 0x30, 0x31, 0x01, 0x23, 0x15, 0x33, 0x23, + 0x35, 0x23, 0x15, 0x01, 0x77, 0x7D, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, + 0xFA, 0xFA, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x02, 0x71, + 0x00, 0x03, 0x00, 0x07, 0x00, 0x1B, 0x40, 0x0E, 0x04, 0x00, 0x05, 0x06, + 0x01, 0x02, 0x01, 0x05, 0x00, 0x06, 0x06, 0x01, 0x05, 0x04, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0xFC, 0x30, 0x31, 0x13, 0x23, 0x11, + 0x33, 0x07, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, + 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x03, 0x6C, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, + 0x00, 0x44, 0x40, 0x29, 0x13, 0x00, 0x12, 0x04, 0x0F, 0x00, 0x0E, 0x04, + 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, + 0x02, 0x09, 0x0E, 0x08, 0x11, 0x06, 0x12, 0x04, 0x11, 0x12, 0x01, 0x11, + 0x04, 0x02, 0x0E, 0x00, 0x0D, 0x0E, 0x01, 0x0D, 0x04, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x2B, 0x2B, 0x30, 0x31, 0x19, 0x01, + 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x07, 0x23, 0x35, 0x33, 0x01, 0x15, + 0x33, 0x35, 0x17, 0x15, 0x33, 0x35, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFA, + 0xFE, 0x89, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, + 0x71, 0xFA, 0x7D, 0x01, 0x78, 0x7D, 0x7D, 0x01, 0x7D, 0x7D, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x13, 0x00, 0x17, + 0x00, 0x1B, 0x00, 0x58, 0x40, 0x32, 0x0D, 0x00, 0x1A, 0x04, 0x0B, 0x0B, + 0x0F, 0x09, 0x09, 0x12, 0x0F, 0x00, 0x12, 0x04, 0x14, 0x00, 0x04, 0x04, + 0x06, 0x06, 0x01, 0x06, 0x1A, 0x09, 0x18, 0x12, 0x15, 0x12, 0x14, 0x09, + 0x0E, 0x12, 0x0C, 0x09, 0x06, 0x0A, 0x04, 0x09, 0x0A, 0x01, 0x09, 0x04, + 0x02, 0x12, 0x00, 0x11, 0x12, 0x01, 0x11, 0x04, 0x2B, 0x10, 0xD0, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x2B, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x2B, 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, + 0x33, 0x15, 0x33, 0x11, 0x23, 0x35, 0x33, 0x35, 0x23, 0x35, 0x23, 0x15, + 0x23, 0x15, 0x33, 0x15, 0x17, 0x23, 0x35, 0x33, 0x27, 0x35, 0x33, 0x15, + 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, + 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7E, 0xF9, 0x7D, 0xFF, 0x73, 0x73, 0x00, 0x00, 0x01, + 0x00, 0x00, 0xFF, 0x06, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0D, 0x00, 0x2B, + 0x40, 0x1A, 0x06, 0x00, 0x08, 0x04, 0x00, 0x0A, 0x0C, 0x00, 0x01, 0x04, + 0x0A, 0x06, 0x02, 0x06, 0x08, 0x02, 0x01, 0x01, 0x0C, 0x04, 0x00, 0x05, + 0x05, 0x01, 0x0A, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, + 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x17, 0x33, 0x35, 0x33, 0x35, + 0x21, 0x11, 0x21, 0x35, 0x21, 0x11, 0x33, 0x15, 0x23, 0x7D, 0xFA, 0x7D, + 0xFE, 0x89, 0x01, 0x77, 0xFE, 0x0C, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0x01, + 0x77, 0x7D, 0xFD, 0x8F, 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x57, + 0x40, 0x32, 0x10, 0x10, 0x0C, 0x0C, 0x00, 0x0F, 0x04, 0x0C, 0x0C, 0x11, + 0x12, 0x00, 0x11, 0x04, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, + 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x10, 0x0F, 0x0D, 0x06, 0x0C, 0x13, + 0x0A, 0x06, 0x0A, 0x0E, 0x08, 0x12, 0x01, 0x0F, 0x01, 0x06, 0x06, 0x01, + 0x03, 0x04, 0x06, 0x0E, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, + 0x2F, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, + 0x35, 0x23, 0x35, 0x13, 0x23, 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, + 0x77, 0x7D, 0x7D, 0x7D, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x03, 0xE9, 0x00, 0x07, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x17, 0x00, 0x8F, + 0x40, 0x4D, 0x15, 0x15, 0x0B, 0x10, 0x10, 0x0B, 0x10, 0x10, 0x16, 0x0D, + 0x0D, 0x12, 0x09, 0x09, 0x17, 0x08, 0x08, 0x0B, 0x08, 0x08, 0x16, 0x0B, + 0x00, 0x12, 0x04, 0x0B, 0x0B, 0x16, 0x17, 0x00, 0x16, 0x04, 0x03, 0x00, + 0x00, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x14, 0x0E, 0x0C, 0x08, 0x0A, + 0x12, 0x0A, 0x13, 0x06, 0x16, 0x01, 0x0E, 0x04, 0x0E, 0x04, 0x15, 0x0E, + 0x01, 0x08, 0x0E, 0x15, 0x08, 0x01, 0x12, 0x08, 0x0D, 0x02, 0x12, 0x02, + 0x13, 0x00, 0x11, 0x12, 0x01, 0x11, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x19, + 0x01, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, 0x27, 0x35, 0x23, 0x15, 0x33, + 0x15, 0x33, 0x35, 0x21, 0x15, 0x33, 0x35, 0x37, 0x15, 0x33, 0x35, 0x7D, + 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0xFA, 0x7D, 0x02, + 0x71, 0xFD, 0x8F, 0x01, 0xF4, 0xFE, 0x0C, 0x02, 0x71, 0xFB, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x03, 0x6C, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x37, 0x40, 0x21, 0x0F, 0x00, 0x0E, 0x04, 0x0B, 0x00, + 0x0A, 0x04, 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, 0x02, 0x05, + 0x0A, 0x04, 0x0D, 0x01, 0x09, 0x0A, 0x01, 0x09, 0x04, 0x00, 0x0E, 0x0E, + 0x01, 0x0D, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x2B, 0x30, 0x31, 0x01, + 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, 0x33, 0x01, 0x15, 0x33, 0x35, 0x17, + 0x15, 0x33, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, + 0xFE, 0x89, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x7D, 0x01, 0x77, + 0x01, 0x78, 0x7D, 0x7D, 0x01, 0x7D, 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x03, 0x6C, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x2F, 0x40, 0x1C, 0x0F, 0x00, 0x0E, 0x04, 0x0B, 0x00, 0x0A, 0x04, + 0x01, 0x00, 0x05, 0x06, 0x06, 0x0A, 0x04, 0x0D, 0x02, 0x0E, 0x0E, 0x01, + 0x0D, 0x04, 0x00, 0x09, 0x0A, 0x01, 0x09, 0x04, 0x2B, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0xFC, 0x2B, 0x2B, 0x30, + 0x31, 0x01, 0x11, 0x23, 0x11, 0x23, 0x11, 0x21, 0x11, 0x27, 0x15, 0x33, + 0x35, 0x25, 0x15, 0x33, 0x35, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0xF4, 0x7D, + 0x7D, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, + 0x02, 0x71, 0xFA, 0x7D, 0x7D, 0x01, 0x7D, 0x7D, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x13, 0x00, 0x68, 0x40, 0x3B, 0x10, 0x10, 0x0C, 0x0C, 0x00, 0x0F, + 0x04, 0x0C, 0x0C, 0x11, 0x12, 0x00, 0x11, 0x04, 0x0A, 0x00, 0x00, 0x08, + 0x00, 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x11, 0x0B, 0x10, + 0x0F, 0x0D, 0x02, 0x0C, 0x13, 0x09, 0x02, 0x09, 0x0E, 0x08, 0x12, 0x07, + 0x01, 0x12, 0x04, 0x12, 0x04, 0x0B, 0x12, 0x01, 0x0F, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x04, 0x02, 0x0E, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, + 0x19, 0x01, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x07, 0x23, 0x35, 0x33, + 0x03, 0x23, 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, 0x7D, 0xFA, 0x7D, 0x7D, + 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0xFA, + 0xFA, 0x02, 0x71, 0xFA, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x13, 0x00, 0x64, 0x40, 0x39, 0x10, 0x10, 0x0F, 0x0F, + 0x00, 0x0E, 0x04, 0x0C, 0x0C, 0x13, 0x12, 0x00, 0x13, 0x04, 0x0A, 0x00, + 0x00, 0x08, 0x00, 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x12, + 0x02, 0x11, 0x0C, 0x0E, 0x0B, 0x09, 0x02, 0x09, 0x13, 0x08, 0x0F, 0x07, + 0x01, 0x0F, 0x04, 0x0F, 0x04, 0x0B, 0x0F, 0x01, 0x0C, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x04, 0x02, 0x13, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, + 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x19, 0x01, + 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x07, 0x23, 0x35, 0x33, 0x03, 0x15, + 0x33, 0x35, 0x23, 0x35, 0x23, 0x15, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFA, + 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, + 0xFA, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x05, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x13, 0x00, 0x17, 0x00, 0x6A, 0x40, 0x3C, 0x14, 0x14, 0x0F, 0x11, + 0x11, 0x16, 0x10, 0x10, 0x0F, 0x10, 0x10, 0x17, 0x0F, 0x00, 0x16, 0x04, + 0x0C, 0x0C, 0x17, 0x0E, 0x00, 0x17, 0x04, 0x0A, 0x00, 0x00, 0x08, 0x00, + 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x0E, 0x16, 0x0C, 0x11, + 0x09, 0x16, 0x08, 0x11, 0x06, 0x12, 0x04, 0x11, 0x12, 0x01, 0x11, 0x04, + 0x02, 0x16, 0x00, 0x15, 0x16, 0x01, 0x15, 0x04, 0x2B, 0x10, 0xD0, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x2B, 0x10, 0xD0, + 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, + 0x07, 0x23, 0x35, 0x33, 0x11, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x35, + 0x21, 0x15, 0x33, 0x35, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, + 0x7D, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, + 0xFA, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0x6C, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x13, 0x00, 0x44, 0x40, 0x29, 0x13, 0x00, 0x12, 0x04, + 0x0F, 0x00, 0x0E, 0x04, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x04, 0x06, + 0x06, 0x01, 0x06, 0x00, 0x02, 0x09, 0x0E, 0x08, 0x11, 0x06, 0x12, 0x04, + 0x11, 0x12, 0x01, 0x11, 0x04, 0x02, 0x0E, 0x00, 0x0D, 0x0E, 0x01, 0x0D, + 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x2B, 0x2B, + 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x07, 0x23, + 0x35, 0x33, 0x01, 0x15, 0x33, 0x35, 0x17, 0x15, 0x33, 0x35, 0x7D, 0xFA, + 0x7D, 0x7D, 0xFA, 0xFA, 0xFE, 0x89, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFD, + 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x7D, 0x01, 0x78, 0x7D, 0x7D, 0x01, + 0x7D, 0x7D, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE9, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x13, 0x00, 0x17, 0x00, 0x1B, 0x00, 0xA4, + 0x40, 0x59, 0x18, 0x18, 0x0F, 0x15, 0x15, 0x0F, 0x15, 0x15, 0x1B, 0x14, + 0x14, 0x0E, 0x11, 0x11, 0x1A, 0x10, 0x10, 0x1B, 0x0C, 0x0C, 0x0F, 0x0C, + 0x0C, 0x1B, 0x0F, 0x00, 0x1A, 0x04, 0x0E, 0x00, 0x1B, 0x04, 0x0A, 0x00, + 0x00, 0x08, 0x00, 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x14, + 0x12, 0x10, 0x0C, 0x0E, 0x1A, 0x0E, 0x1B, 0x09, 0x1A, 0x09, 0x1B, 0x08, + 0x12, 0x08, 0x15, 0x06, 0x16, 0x01, 0x12, 0x04, 0x12, 0x04, 0x15, 0x12, + 0x01, 0x0C, 0x12, 0x15, 0x0C, 0x01, 0x1A, 0x0C, 0x11, 0x02, 0x1A, 0x02, + 0x1B, 0x00, 0x19, 0x1A, 0x01, 0x19, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x3F, 0x2B, 0x10, 0xFC, 0x2B, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, + 0x33, 0x15, 0x33, 0x11, 0x07, 0x23, 0x35, 0x33, 0x03, 0x35, 0x23, 0x15, + 0x33, 0x15, 0x33, 0x3D, 0x01, 0x15, 0x33, 0x35, 0x05, 0x15, 0x33, 0x35, + 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, + 0x0C, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x7D, + 0x01, 0x78, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x13, + 0x00, 0x17, 0x00, 0x1B, 0x00, 0x58, 0x40, 0x32, 0x0D, 0x00, 0x1A, 0x04, + 0x0B, 0x0B, 0x0F, 0x09, 0x09, 0x12, 0x0F, 0x00, 0x12, 0x04, 0x14, 0x00, + 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, 0x1A, 0x09, 0x18, 0x12, 0x15, 0x12, + 0x14, 0x09, 0x0E, 0x12, 0x0C, 0x09, 0x06, 0x0A, 0x04, 0x09, 0x0A, 0x01, + 0x09, 0x04, 0x02, 0x12, 0x00, 0x11, 0x12, 0x01, 0x11, 0x04, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, + 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x2B, 0x30, 0x31, 0x19, 0x01, + 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x23, 0x35, 0x33, 0x35, 0x23, 0x35, + 0x23, 0x15, 0x23, 0x15, 0x33, 0x15, 0x17, 0x23, 0x35, 0x33, 0x27, 0x35, + 0x33, 0x15, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, + 0xFA, 0xFA, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7E, 0xF9, 0x7D, 0xFF, 0x73, 0x73, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x05, 0x5F, 0x02, 0x71, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x13, 0x00, 0x48, 0x40, 0x2E, 0x12, 0x00, 0x00, 0x10, + 0x00, 0x0A, 0x0E, 0x00, 0x00, 0x0C, 0x00, 0x0A, 0x08, 0x00, 0x00, 0x04, + 0x00, 0x00, 0x0A, 0x06, 0x06, 0x06, 0x02, 0x06, 0x00, 0x02, 0x12, 0x01, + 0x0F, 0x04, 0x0B, 0x01, 0x0A, 0x04, 0x07, 0x01, 0x06, 0x04, 0x04, 0x01, + 0x13, 0x04, 0x0D, 0x01, 0x02, 0x04, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x00, + 0x3F, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, + 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x11, 0x33, + 0x11, 0x33, 0x11, 0x33, 0x11, 0x33, 0x25, 0x23, 0x11, 0x33, 0x01, 0x23, + 0x11, 0x33, 0x05, 0x5F, 0xFA, 0xA1, 0x03, 0x6B, 0x7D, 0x7D, 0x7D, 0x7D, + 0xFC, 0x18, 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, + 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0x01, 0x77, 0xFE, + 0x89, 0x01, 0x77, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x03, 0xE8, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x57, 0x40, 0x32, + 0x10, 0x10, 0x0C, 0x0C, 0x00, 0x0F, 0x04, 0x0C, 0x0C, 0x11, 0x12, 0x00, + 0x11, 0x04, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, + 0x03, 0x06, 0x01, 0x02, 0x10, 0x0F, 0x0D, 0x06, 0x0C, 0x13, 0x0A, 0x06, + 0x0A, 0x0E, 0x08, 0x12, 0x01, 0x0F, 0x01, 0x06, 0x06, 0x01, 0x03, 0x04, + 0x06, 0x0E, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, + 0x10, 0xFC, 0x2B, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x30, + 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, + 0x35, 0x13, 0x23, 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, 0x01, 0xF4, 0xFE, + 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, + 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x55, 0x40, 0x30, 0x10, 0x10, + 0x0C, 0x0D, 0x00, 0x0C, 0x0C, 0x13, 0x13, 0x00, 0x12, 0x04, 0x09, 0x00, + 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, + 0x10, 0x0C, 0x0E, 0x06, 0x0A, 0x06, 0x0A, 0x0F, 0x08, 0x12, 0x01, 0x0C, + 0x01, 0x06, 0x0C, 0x11, 0x06, 0x01, 0x03, 0x04, 0x06, 0x0F, 0x10, 0xD0, + 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x2B, + 0x10, 0xD0, 0x2F, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x35, 0x21, + 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x13, 0x35, 0x23, + 0x15, 0x33, 0x15, 0x33, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, + 0x89, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, + 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x13, 0x00, 0x17, 0x00, 0x6A, 0x40, 0x3B, 0x14, 0x14, 0x0C, 0x11, + 0x11, 0x16, 0x10, 0x10, 0x17, 0x10, 0x10, 0x0C, 0x0D, 0x00, 0x0C, 0x0C, + 0x17, 0x17, 0x00, 0x16, 0x04, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, + 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x0E, 0x12, 0x0C, 0x15, 0x0A, + 0x12, 0x08, 0x15, 0x06, 0x12, 0x04, 0x16, 0x02, 0x11, 0x12, 0x01, 0x11, + 0x04, 0x00, 0x16, 0x16, 0x01, 0x15, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x2B, 0x10, 0xD0, + 0x2F, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, + 0x33, 0x35, 0x23, 0x35, 0x13, 0x35, 0x23, 0x15, 0x23, 0x15, 0x33, 0x35, + 0x33, 0x15, 0x33, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, + 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, + 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0x6C, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x46, 0x40, 0x2A, 0x13, 0x00, + 0x12, 0x04, 0x0F, 0x00, 0x0E, 0x04, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, + 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x0A, 0x12, 0x08, 0x0D, + 0x06, 0x12, 0x04, 0x0E, 0x02, 0x11, 0x12, 0x01, 0x11, 0x04, 0x00, 0x0E, + 0x0E, 0x01, 0x0D, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, + 0xFC, 0x2B, 0x2B, 0x2B, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, + 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x13, 0x15, 0x33, 0x35, 0x25, 0x15, + 0x33, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, + 0xFA, 0x7D, 0xFE, 0x0C, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x7D, + 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x01, 0x7D, 0x7D, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xFA, 0x03, 0xE8, 0x00, 0x03, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x34, 0x40, 0x1C, 0x09, 0x09, 0x04, 0x07, 0x00, 0x04, + 0x04, 0x00, 0x0B, 0x04, 0x02, 0x06, 0x08, 0x04, 0x05, 0x01, 0x0B, 0x02, + 0x0B, 0x02, 0x04, 0x0B, 0x00, 0x0A, 0x0B, 0x01, 0x0A, 0x04, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x00, 0x3F, + 0x2B, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x19, 0x01, 0x33, 0x11, + 0x35, 0x33, 0x35, 0x23, 0x15, 0x23, 0x15, 0x33, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0xFA, 0x7D, 0x7D, 0x7D, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFA, 0x03, 0xE8, 0x00, 0x03, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x38, 0x40, 0x1E, 0x08, 0x08, 0x04, 0x05, + 0x00, 0x04, 0x04, 0x0B, 0x0B, 0x00, 0x0A, 0x04, 0x02, 0x06, 0x08, 0x04, + 0x02, 0x0A, 0x01, 0x04, 0x00, 0x04, 0x00, 0x09, 0x04, 0x01, 0x07, 0x04, + 0x04, 0x09, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0xFC, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x13, 0x11, 0x33, 0x11, 0x27, 0x35, 0x23, 0x15, 0x33, 0x15, + 0x33, 0x35, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, + 0x02, 0x71, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x77, 0x03, 0xE8, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x5D, 0x40, 0x31, 0x0C, 0x0C, 0x08, 0x09, 0x00, 0x08, + 0x05, 0x05, 0x0E, 0x04, 0x04, 0x0F, 0x04, 0x04, 0x08, 0x08, 0x0F, 0x0F, + 0x00, 0x0E, 0x04, 0x02, 0x06, 0x0E, 0x01, 0x08, 0x0C, 0x08, 0x0A, 0x06, + 0x02, 0x08, 0x02, 0x0D, 0x08, 0x01, 0x06, 0x08, 0x0D, 0x00, 0x06, 0x00, + 0x0B, 0x06, 0x01, 0x05, 0x04, 0x06, 0x0B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xFC, 0x00, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, + 0x31, 0x13, 0x11, 0x33, 0x11, 0x27, 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, + 0x15, 0x33, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x03, 0x6B, + 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x38, 0x40, 0x1E, 0x05, 0x05, + 0x0A, 0x04, 0x04, 0x0B, 0x0B, 0x00, 0x0A, 0x04, 0x02, 0x06, 0x06, 0x01, + 0x04, 0x02, 0x04, 0x02, 0x05, 0x04, 0x01, 0x0A, 0x00, 0x0A, 0x00, 0x0B, + 0x0A, 0x01, 0x09, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x00, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x13, 0x11, 0x33, 0x11, 0x35, 0x15, 0x33, 0x35, + 0x21, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x02, 0x71, + 0xFD, 0x8F, 0x02, 0x71, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE9, 0x00, 0x07, 0x00, 0x0F, + 0x00, 0x13, 0x00, 0x17, 0x00, 0x8F, 0x40, 0x4D, 0x15, 0x15, 0x0B, 0x10, + 0x10, 0x0B, 0x10, 0x10, 0x16, 0x0D, 0x0D, 0x12, 0x09, 0x09, 0x17, 0x08, + 0x08, 0x0B, 0x08, 0x08, 0x16, 0x0B, 0x00, 0x12, 0x04, 0x0B, 0x0B, 0x16, + 0x17, 0x00, 0x16, 0x04, 0x03, 0x00, 0x00, 0x06, 0x06, 0x01, 0x06, 0x00, + 0x02, 0x14, 0x0E, 0x0C, 0x08, 0x0A, 0x12, 0x0A, 0x13, 0x06, 0x16, 0x01, + 0x0E, 0x04, 0x0E, 0x04, 0x15, 0x0E, 0x01, 0x08, 0x0E, 0x15, 0x08, 0x01, + 0x12, 0x08, 0x0D, 0x02, 0x12, 0x02, 0x13, 0x00, 0x11, 0x12, 0x01, 0x11, + 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, + 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x10, + 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x19, 0x01, 0x33, 0x11, 0x33, 0x11, 0x33, + 0x11, 0x27, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x35, 0x21, 0x15, 0x33, + 0x35, 0x37, 0x15, 0x33, 0x35, 0x7D, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, + 0xFE, 0x89, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x01, 0xF4, 0xFE, + 0x0C, 0x02, 0x71, 0xFB, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, + 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x51, 0x40, 0x2E, + 0x0C, 0x0C, 0x08, 0x08, 0x00, 0x0B, 0x04, 0x08, 0x08, 0x0D, 0x0E, 0x00, + 0x0D, 0x04, 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, 0x02, 0x0D, + 0x07, 0x0C, 0x0B, 0x09, 0x05, 0x08, 0x0F, 0x04, 0x0E, 0x00, 0x01, 0x0E, + 0x01, 0x0B, 0x01, 0x05, 0x05, 0x01, 0x02, 0x04, 0x05, 0x0A, 0x10, 0xD0, + 0x2B, 0x10, 0xFC, 0xFC, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x10, 0xD0, + 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, + 0x23, 0x11, 0x33, 0x03, 0x23, 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x01, 0x77, 0x7D, 0x7D, + 0x7D, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, + 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x4D, 0x40, 0x2C, + 0x0C, 0x0C, 0x0B, 0x0B, 0x00, 0x0A, 0x04, 0x08, 0x08, 0x0F, 0x0E, 0x00, + 0x0F, 0x04, 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, 0x02, 0x0E, + 0x05, 0x0D, 0x08, 0x0A, 0x07, 0x04, 0x0B, 0x00, 0x01, 0x0B, 0x01, 0x08, + 0x01, 0x05, 0x05, 0x01, 0x02, 0x04, 0x05, 0x0F, 0x10, 0xD0, 0x2B, 0x10, + 0xFC, 0xFC, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, + 0x2F, 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, 0x33, 0x03, + 0x15, 0x33, 0x35, 0x23, 0x35, 0x23, 0x15, 0x01, 0xF4, 0xFE, 0x0C, 0x01, + 0xF4, 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, + 0x7D, 0x01, 0x77, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x03, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x5D, 0x40, 0x34, 0x10, 0x10, + 0x0B, 0x0D, 0x0D, 0x12, 0x0C, 0x0C, 0x0B, 0x0C, 0x0C, 0x13, 0x0B, 0x00, + 0x12, 0x04, 0x08, 0x08, 0x13, 0x0A, 0x00, 0x13, 0x04, 0x06, 0x00, 0x00, + 0x04, 0x00, 0x02, 0x06, 0x00, 0x02, 0x0A, 0x12, 0x08, 0x0D, 0x05, 0x12, + 0x04, 0x0D, 0x01, 0x11, 0x12, 0x01, 0x11, 0x04, 0x00, 0x0E, 0x0E, 0x01, + 0x0D, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x10, + 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, + 0x33, 0x11, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x35, 0x21, 0x15, 0x33, + 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, + 0x7D, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x01, + 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x03, 0x6C, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x37, 0x40, 0x21, 0x0F, 0x00, 0x0E, 0x04, 0x0B, 0x00, + 0x0A, 0x04, 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, 0x02, 0x05, + 0x0A, 0x04, 0x0D, 0x01, 0x09, 0x0A, 0x01, 0x09, 0x04, 0x00, 0x0E, 0x0E, + 0x01, 0x0D, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x2B, 0x30, 0x31, 0x01, + 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, 0x33, 0x01, 0x15, 0x33, 0x35, 0x17, + 0x15, 0x33, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, + 0xFE, 0x89, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x7D, 0x01, 0x77, + 0x01, 0x78, 0x7D, 0x7D, 0x01, 0x7D, 0x7D, 0x00, 0x00, 0x05, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE9, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0F, + 0x00, 0x13, 0x00, 0x17, 0x00, 0x8D, 0x40, 0x4C, 0x14, 0x14, 0x0B, 0x11, + 0x11, 0x0B, 0x11, 0x11, 0x17, 0x10, 0x10, 0x0A, 0x0D, 0x0D, 0x16, 0x0C, + 0x0C, 0x17, 0x08, 0x08, 0x0B, 0x08, 0x08, 0x17, 0x0B, 0x00, 0x16, 0x04, + 0x0A, 0x00, 0x17, 0x04, 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, + 0x02, 0x10, 0x0E, 0x0C, 0x08, 0x0A, 0x16, 0x0A, 0x17, 0x05, 0x16, 0x05, + 0x17, 0x04, 0x0E, 0x04, 0x11, 0x01, 0x15, 0x00, 0x12, 0x01, 0x0E, 0x01, + 0x08, 0x0E, 0x11, 0x08, 0x01, 0x16, 0x08, 0x0D, 0x16, 0x01, 0x15, 0x04, + 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xFC, 0xFC, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, + 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, 0x33, 0x03, + 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x3D, 0x01, 0x15, 0x33, 0x35, 0x05, + 0x15, 0x33, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0xFD, 0x8F, + 0x7D, 0x01, 0x77, 0x01, 0x78, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x03, 0xE8, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3B, 0x40, 0x21, + 0x0D, 0x0D, 0x08, 0x0B, 0x00, 0x08, 0x08, 0x00, 0x0F, 0x04, 0x01, 0x00, + 0x05, 0x06, 0x0D, 0x02, 0x09, 0x00, 0x08, 0x0F, 0x07, 0x01, 0x00, 0x01, + 0x0F, 0x01, 0x02, 0x02, 0x01, 0x05, 0x04, 0x02, 0x0E, 0x10, 0xD0, 0x2B, + 0x10, 0xFC, 0xFC, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0xFC, 0x2B, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x11, 0x23, + 0x11, 0x23, 0x11, 0x21, 0x11, 0x27, 0x33, 0x35, 0x23, 0x15, 0x23, 0x15, + 0x33, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0xF4, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, + 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x02, 0x71, 0xFA, 0x7D, + 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x47, 0x40, 0x27, 0x0C, 0x0C, + 0x08, 0x09, 0x00, 0x08, 0x08, 0x0F, 0x0F, 0x00, 0x0E, 0x04, 0x01, 0x00, + 0x05, 0x06, 0x0F, 0x00, 0x0C, 0x08, 0x0A, 0x02, 0x07, 0x01, 0x0E, 0x00, + 0x0E, 0x01, 0x08, 0x01, 0x02, 0x08, 0x0D, 0x02, 0x01, 0x05, 0x04, 0x02, + 0x0B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0xFC, 0xD0, 0x10, 0xFC, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0xFC, 0x2B, 0x10, 0xD0, + 0x2F, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x11, 0x23, 0x11, 0x23, + 0x11, 0x21, 0x11, 0x27, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x35, 0x01, + 0x77, 0xFA, 0x7D, 0x01, 0xF4, 0xFA, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFE, + 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x02, 0x71, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x53, 0x40, 0x2D, 0x10, 0x10, + 0x08, 0x0D, 0x0D, 0x12, 0x0C, 0x0C, 0x13, 0x0C, 0x0C, 0x08, 0x09, 0x00, + 0x08, 0x08, 0x13, 0x13, 0x00, 0x12, 0x04, 0x01, 0x00, 0x05, 0x06, 0x0A, + 0x0E, 0x08, 0x11, 0x06, 0x12, 0x04, 0x0D, 0x02, 0x0E, 0x0E, 0x01, 0x0D, + 0x04, 0x00, 0x11, 0x12, 0x01, 0x11, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0xFC, + 0x2B, 0x10, 0xD0, 0x2F, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x11, 0x23, 0x11, 0x23, + 0x11, 0x21, 0x11, 0x27, 0x35, 0x23, 0x15, 0x23, 0x15, 0x33, 0x35, 0x33, + 0x15, 0x33, 0x35, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0xF4, 0x7D, 0xFA, 0x7D, + 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x02, + 0x71, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x03, 0x6C, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x2F, 0x40, 0x1C, 0x0F, 0x00, 0x0E, 0x04, 0x0B, 0x00, 0x0A, 0x04, + 0x01, 0x00, 0x05, 0x06, 0x06, 0x0A, 0x04, 0x0D, 0x02, 0x0E, 0x0E, 0x01, + 0x0D, 0x04, 0x00, 0x09, 0x0A, 0x01, 0x09, 0x04, 0x2B, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0xFC, 0x2B, 0x2B, 0x30, + 0x31, 0x01, 0x11, 0x23, 0x11, 0x23, 0x11, 0x21, 0x11, 0x27, 0x15, 0x33, + 0x35, 0x25, 0x15, 0x33, 0x35, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0xF4, 0x7D, + 0x7D, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, + 0x02, 0x71, 0xFA, 0x7D, 0x7D, 0x01, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x11, 0x00, 0x4C, + 0x40, 0x2B, 0x0D, 0x0D, 0x07, 0x0B, 0x0B, 0x10, 0x08, 0x00, 0x09, 0x07, + 0x00, 0x10, 0x04, 0x05, 0x00, 0x01, 0x09, 0x06, 0x03, 0x06, 0x01, 0x02, + 0x0D, 0x11, 0x08, 0x0F, 0x06, 0x0C, 0x06, 0x11, 0x0C, 0x04, 0x01, 0x03, + 0x04, 0x00, 0x0A, 0x01, 0x0C, 0x0C, 0x01, 0x0F, 0x04, 0x2B, 0x10, 0xFC, + 0xD0, 0x2B, 0x10, 0xD0, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x33, 0x11, 0x33, 0x15, + 0x07, 0x15, 0x33, 0x35, 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x01, 0xF4, + 0xFE, 0x0C, 0x7D, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0xFA, + 0xFD, 0x8F, 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x6B, 0x02, 0x71, 0x00, 0x0F, + 0x00, 0x13, 0x00, 0x44, 0x40, 0x27, 0x12, 0x00, 0x01, 0x10, 0x10, 0x0D, + 0x09, 0x00, 0x07, 0x05, 0x05, 0x0C, 0x0D, 0x00, 0x0C, 0x04, 0x00, 0x00, + 0x01, 0x07, 0x06, 0x03, 0x06, 0x01, 0x02, 0x11, 0x04, 0x0A, 0x0F, 0x06, + 0x13, 0x0F, 0x01, 0x13, 0x04, 0x04, 0x01, 0x03, 0x04, 0x2B, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x35, 0x21, 0x11, 0x33, 0x35, 0x33, 0x15, 0x21, 0x35, 0x21, 0x35, + 0x33, 0x35, 0x23, 0x35, 0x07, 0x23, 0x35, 0x33, 0x03, 0x6B, 0xFC, 0x95, + 0x7D, 0xFA, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0x01, + 0xF4, 0x7D, 0xFD, 0x8F, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x09, 0x00, 0x0F, 0x00, 0x35, 0x40, 0x20, 0x0D, 0x00, 0x00, 0x08, + 0x08, 0x0B, 0x06, 0x00, 0x02, 0x04, 0x04, 0x0A, 0x0A, 0x00, 0x0B, 0x04, + 0x02, 0x06, 0x00, 0x02, 0x09, 0x01, 0x0B, 0x04, 0x03, 0x01, 0x06, 0x04, + 0x0C, 0x01, 0x02, 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x2B, 0x10, + 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x01, + 0x21, 0x11, 0x21, 0x03, 0x33, 0x15, 0x23, 0x35, 0x33, 0x27, 0x15, 0x23, + 0x35, 0x33, 0x15, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0xFA, 0x7D, 0xFA, + 0x7D, 0x82, 0x78, 0xF5, 0x02, 0x71, 0xFD, 0x8F, 0x01, 0x77, 0xFA, 0x7D, + 0x7D, 0x7D, 0xFA, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, + 0x01, 0xF4, 0x00, 0x0F, 0x00, 0x30, 0x40, 0x1A, 0x0E, 0x00, 0x00, 0x06, + 0x06, 0x0A, 0x04, 0x04, 0x0D, 0x0A, 0x00, 0x0D, 0x04, 0x02, 0x00, 0x00, + 0x06, 0x09, 0x09, 0x0E, 0x07, 0x03, 0x03, 0x01, 0x0E, 0x04, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x2F, 0x3F, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x35, 0x23, 0x35, 0x33, + 0x35, 0x23, 0x35, 0x23, 0x15, 0x23, 0x15, 0x33, 0x15, 0x23, 0x01, 0x77, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x6B, 0x02, 0x71, + 0x00, 0x0F, 0x00, 0x13, 0x00, 0x44, 0x40, 0x27, 0x12, 0x00, 0x01, 0x10, + 0x10, 0x0D, 0x09, 0x00, 0x07, 0x05, 0x05, 0x0C, 0x0D, 0x00, 0x0C, 0x04, + 0x00, 0x00, 0x01, 0x07, 0x06, 0x03, 0x06, 0x01, 0x02, 0x11, 0x04, 0x0A, + 0x0F, 0x06, 0x13, 0x0F, 0x01, 0x13, 0x04, 0x04, 0x01, 0x03, 0x04, 0x2B, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x10, + 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xFC, + 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x33, 0x35, 0x33, 0x15, 0x21, 0x35, + 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x07, 0x23, 0x35, 0x33, 0x03, 0x6B, + 0xFC, 0x95, 0x7D, 0xFA, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, 0x7D, 0xFA, + 0xFA, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, + 0x00, 0x03, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x35, 0x40, 0x20, 0x0D, 0x00, + 0x00, 0x08, 0x08, 0x0B, 0x06, 0x00, 0x02, 0x04, 0x04, 0x0A, 0x0A, 0x00, + 0x0B, 0x04, 0x02, 0x06, 0x00, 0x02, 0x09, 0x01, 0x0B, 0x04, 0x03, 0x01, + 0x06, 0x04, 0x0C, 0x01, 0x02, 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, + 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, + 0x31, 0x01, 0x21, 0x11, 0x21, 0x03, 0x33, 0x15, 0x23, 0x35, 0x33, 0x27, + 0x15, 0x23, 0x35, 0x33, 0x15, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0xFA, + 0x7D, 0xFA, 0x7D, 0x82, 0x78, 0xF5, 0x02, 0x71, 0xFD, 0x8F, 0x01, 0x77, + 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, + 0x00, 0x64, 0x40, 0x39, 0x10, 0x10, 0x0F, 0x0F, 0x00, 0x0E, 0x04, 0x0C, + 0x0C, 0x13, 0x12, 0x00, 0x13, 0x04, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, + 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x12, 0x02, 0x11, 0x0C, 0x0E, + 0x0B, 0x09, 0x02, 0x09, 0x13, 0x08, 0x0F, 0x07, 0x01, 0x0F, 0x04, 0x0F, + 0x04, 0x0B, 0x0F, 0x01, 0x0C, 0x01, 0x02, 0x02, 0x01, 0x01, 0x04, 0x02, + 0x13, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, + 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, 0x33, 0x15, + 0x33, 0x11, 0x07, 0x23, 0x35, 0x33, 0x03, 0x15, 0x33, 0x35, 0x23, 0x35, + 0x23, 0x15, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, + 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x7D, 0x01, 0x77, + 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x03, 0xE9, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x13, 0x00, 0x17, 0x00, 0x1B, + 0x00, 0xA4, 0x40, 0x59, 0x18, 0x18, 0x0F, 0x15, 0x15, 0x0F, 0x15, 0x15, + 0x1B, 0x14, 0x14, 0x0E, 0x11, 0x11, 0x1A, 0x10, 0x10, 0x1B, 0x0C, 0x0C, + 0x0F, 0x0C, 0x0C, 0x1B, 0x0F, 0x00, 0x1A, 0x04, 0x0E, 0x00, 0x1B, 0x04, + 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, + 0x02, 0x14, 0x12, 0x10, 0x0C, 0x0E, 0x1A, 0x0E, 0x1B, 0x09, 0x1A, 0x09, + 0x1B, 0x08, 0x12, 0x08, 0x15, 0x06, 0x16, 0x01, 0x12, 0x04, 0x12, 0x04, + 0x15, 0x12, 0x01, 0x0C, 0x12, 0x15, 0x0C, 0x01, 0x1A, 0x0C, 0x11, 0x02, + 0x1A, 0x02, 0x1B, 0x00, 0x19, 0x1A, 0x01, 0x19, 0x04, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xFC, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x2B, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x19, 0x01, + 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x07, 0x23, 0x35, 0x33, 0x03, 0x35, + 0x23, 0x15, 0x33, 0x15, 0x33, 0x3D, 0x01, 0x15, 0x33, 0x35, 0x05, 0x15, + 0x33, 0x35, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, + 0xFA, 0x7D, 0x01, 0x78, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE9, + 0x00, 0x03, 0x00, 0x07, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x17, 0x00, 0x8D, + 0x40, 0x4C, 0x14, 0x14, 0x0B, 0x11, 0x11, 0x0B, 0x11, 0x11, 0x17, 0x10, + 0x10, 0x0A, 0x0D, 0x0D, 0x16, 0x0C, 0x0C, 0x17, 0x08, 0x08, 0x0B, 0x08, + 0x08, 0x17, 0x0B, 0x00, 0x16, 0x04, 0x0A, 0x00, 0x17, 0x04, 0x06, 0x00, + 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, 0x02, 0x10, 0x0E, 0x0C, 0x08, 0x0A, + 0x16, 0x0A, 0x17, 0x05, 0x16, 0x05, 0x17, 0x04, 0x0E, 0x04, 0x11, 0x01, + 0x15, 0x00, 0x12, 0x01, 0x0E, 0x01, 0x08, 0x0E, 0x11, 0x08, 0x01, 0x16, + 0x08, 0x0D, 0x16, 0x01, 0x15, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0x10, + 0xD0, 0x10, 0xFC, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x21, 0x11, + 0x21, 0x27, 0x23, 0x11, 0x33, 0x03, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, + 0x3D, 0x01, 0x15, 0x33, 0x35, 0x05, 0x15, 0x33, 0x35, 0x01, 0xF4, 0xFE, + 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, + 0x0C, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x01, 0x78, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x27, 0x40, 0x16, 0x08, 0x00, 0x09, 0x05, 0x00, 0x04, + 0x02, 0x00, 0x03, 0x04, 0x04, 0x06, 0x09, 0x02, 0x06, 0x0B, 0x04, 0x08, + 0x08, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x25, 0x35, 0x21, 0x15, 0x17, + 0x35, 0x23, 0x15, 0x13, 0x35, 0x23, 0x15, 0x01, 0x77, 0xFE, 0x89, 0xFA, + 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, + 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0x6C, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x3E, 0x40, 0x25, 0x13, 0x00, + 0x12, 0x04, 0x0F, 0x00, 0x0E, 0x04, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, + 0x04, 0x09, 0x06, 0x0A, 0x12, 0x08, 0x0D, 0x06, 0x11, 0x04, 0x0D, 0x02, + 0x0E, 0x0E, 0x01, 0x0D, 0x04, 0x00, 0x11, 0x12, 0x01, 0x11, 0x04, 0x2B, + 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x2B, 0x10, 0xFC, 0x2B, 0x2B, 0x30, 0x31, 0x01, 0x15, + 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, 0x25, 0x15, + 0x33, 0x35, 0x17, 0x15, 0x33, 0x35, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, + 0xFE, 0x89, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, + 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0xFB, 0x7D, 0x7D, 0x01, 0x7D, + 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0x6C, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x3E, 0x40, 0x25, 0x13, 0x00, + 0x12, 0x04, 0x0F, 0x00, 0x0E, 0x04, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, + 0x04, 0x09, 0x06, 0x0A, 0x12, 0x08, 0x0D, 0x06, 0x11, 0x04, 0x0D, 0x02, + 0x0E, 0x0E, 0x01, 0x0D, 0x04, 0x00, 0x11, 0x12, 0x01, 0x11, 0x04, 0x2B, + 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x2B, 0x10, 0xFC, 0x2B, 0x2B, 0x30, 0x31, 0x01, 0x15, + 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, 0x25, 0x15, + 0x33, 0x35, 0x17, 0x15, 0x33, 0x35, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, + 0xFE, 0x89, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, + 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0xFB, 0x7D, 0x7D, 0x01, 0x7D, + 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xFA, 0x01, 0x77, 0x02, 0x71, + 0x00, 0x03, 0x00, 0x07, 0x00, 0x1C, 0x40, 0x11, 0x04, 0x00, 0x00, 0x06, + 0x00, 0x02, 0x04, 0x00, 0x02, 0x02, 0x01, 0x06, 0x04, 0x07, 0x01, 0x01, + 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, + 0x21, 0x11, 0x07, 0x33, 0x15, 0x23, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0x02, + 0x71, 0xFE, 0x89, 0x01, 0x77, 0x7D, 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x7D, 0x00, 0xFA, 0x01, 0xF4, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x48, + 0x40, 0x28, 0x09, 0x09, 0x07, 0x01, 0x01, 0x05, 0x01, 0x01, 0x06, 0x05, + 0x00, 0x04, 0x04, 0x07, 0x00, 0x06, 0x04, 0x00, 0x00, 0x0A, 0x0B, 0x00, + 0x0A, 0x04, 0x08, 0x02, 0x06, 0x02, 0x06, 0x09, 0x04, 0x0A, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x04, 0x02, 0x09, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, + 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, + 0x11, 0x15, 0x33, 0x15, 0x33, 0x35, 0x23, 0x3D, 0x01, 0x15, 0x33, 0x35, + 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x17, 0x00, 0x6A, + 0x40, 0x3C, 0x14, 0x14, 0x0F, 0x11, 0x11, 0x16, 0x10, 0x10, 0x0F, 0x10, + 0x10, 0x17, 0x0F, 0x00, 0x16, 0x04, 0x0C, 0x0C, 0x17, 0x0E, 0x00, 0x17, + 0x04, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, + 0x00, 0x02, 0x0E, 0x16, 0x0C, 0x11, 0x09, 0x16, 0x08, 0x11, 0x06, 0x12, + 0x04, 0x11, 0x12, 0x01, 0x11, 0x04, 0x02, 0x16, 0x00, 0x15, 0x16, 0x01, + 0x15, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, + 0x2B, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x19, 0x01, + 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x07, 0x23, 0x35, 0x33, 0x11, 0x35, + 0x23, 0x15, 0x33, 0x15, 0x33, 0x35, 0x21, 0x15, 0x33, 0x35, 0x7D, 0xFA, + 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0xFE, 0x0C, 0x7D, 0x02, 0x71, + 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x7D, 0x01, 0x77, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x03, 0xE8, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x17, 0x00, 0x6A, + 0x40, 0x3B, 0x14, 0x14, 0x0C, 0x11, 0x11, 0x16, 0x10, 0x10, 0x17, 0x10, + 0x10, 0x0C, 0x0D, 0x00, 0x0C, 0x0C, 0x17, 0x17, 0x00, 0x16, 0x04, 0x09, + 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, + 0x02, 0x0E, 0x12, 0x0C, 0x15, 0x0A, 0x12, 0x08, 0x15, 0x06, 0x12, 0x04, + 0x16, 0x02, 0x11, 0x12, 0x01, 0x11, 0x04, 0x00, 0x16, 0x16, 0x01, 0x15, + 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, + 0x10, 0xFC, 0x2B, 0x2B, 0x10, 0xD0, 0x2F, 0xFC, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x35, + 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x13, 0x35, + 0x23, 0x15, 0x23, 0x15, 0x33, 0x35, 0x33, 0x15, 0x33, 0x35, 0x01, 0xF4, + 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0x7D, + 0xFA, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, + 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x13, 0x00, 0x68, 0x40, 0x3B, 0x10, 0x10, 0x0C, 0x0C, 0x00, 0x0F, + 0x04, 0x0C, 0x0C, 0x11, 0x12, 0x00, 0x11, 0x04, 0x0A, 0x00, 0x00, 0x08, + 0x00, 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x11, 0x0B, 0x10, + 0x0F, 0x0D, 0x02, 0x0C, 0x13, 0x09, 0x02, 0x09, 0x0E, 0x08, 0x12, 0x07, + 0x01, 0x12, 0x04, 0x12, 0x04, 0x0B, 0x12, 0x01, 0x0F, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x04, 0x02, 0x0E, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, + 0x19, 0x01, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x07, 0x23, 0x35, 0x33, + 0x03, 0x23, 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, 0x7D, 0xFA, 0x7D, 0x7D, + 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0xFA, + 0xFA, 0x02, 0x71, 0xFA, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x13, 0x00, 0x17, 0x00, 0x6A, 0x40, 0x3B, 0x14, 0x14, 0x0C, 0x11, + 0x11, 0x16, 0x10, 0x10, 0x17, 0x10, 0x10, 0x0C, 0x0D, 0x00, 0x0C, 0x0C, + 0x17, 0x17, 0x00, 0x16, 0x04, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, + 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x0E, 0x12, 0x0C, 0x15, 0x0A, + 0x12, 0x08, 0x15, 0x06, 0x12, 0x04, 0x16, 0x02, 0x11, 0x12, 0x01, 0x11, + 0x04, 0x00, 0x16, 0x16, 0x01, 0x15, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x2B, 0x10, 0xD0, + 0x2F, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, + 0x33, 0x35, 0x23, 0x35, 0x13, 0x35, 0x23, 0x15, 0x23, 0x15, 0x33, 0x35, + 0x33, 0x15, 0x33, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, + 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, + 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x55, 0x40, 0x30, 0x10, 0x10, + 0x0C, 0x0D, 0x00, 0x0C, 0x0C, 0x13, 0x13, 0x00, 0x12, 0x04, 0x09, 0x00, + 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, + 0x10, 0x0C, 0x0E, 0x06, 0x0A, 0x06, 0x0A, 0x0F, 0x08, 0x12, 0x01, 0x0C, + 0x01, 0x06, 0x0C, 0x11, 0x06, 0x01, 0x03, 0x04, 0x06, 0x0F, 0x10, 0xD0, + 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x2B, + 0x10, 0xD0, 0x2F, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x35, 0x21, + 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x13, 0x35, 0x23, + 0x15, 0x33, 0x15, 0x33, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, + 0x89, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, + 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x07, 0x00, 0x0F, + 0x00, 0x13, 0x00, 0x6B, 0x40, 0x3B, 0x12, 0x12, 0x0D, 0x09, 0x09, 0x0D, + 0x09, 0x09, 0x13, 0x0D, 0x00, 0x0C, 0x04, 0x0D, 0x0D, 0x13, 0x08, 0x08, + 0x10, 0x10, 0x00, 0x13, 0x04, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, + 0x06, 0x01, 0x02, 0x0E, 0x0A, 0x0C, 0x11, 0x0C, 0x12, 0x08, 0x06, 0x04, + 0x13, 0x00, 0x13, 0x01, 0x11, 0x01, 0x0A, 0x01, 0x06, 0x0A, 0x0F, 0x06, + 0x01, 0x03, 0x04, 0x06, 0x09, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xFC, + 0xFC, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x19, 0x01, + 0x15, 0x33, 0x15, 0x33, 0x35, 0x23, 0x35, 0x33, 0x23, 0x15, 0x33, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, + 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x01, 0xF4, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x03, 0xE8, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x48, 0x40, 0x29, + 0x0C, 0x0C, 0x0A, 0x0A, 0x00, 0x09, 0x04, 0x0A, 0x0A, 0x0F, 0x0E, 0x00, + 0x0F, 0x04, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, + 0x0E, 0x0A, 0x0C, 0x01, 0x0A, 0x01, 0x06, 0x09, 0x0F, 0x08, 0x06, 0x06, + 0x01, 0x03, 0x04, 0x06, 0x0B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xFC, 0xFC, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, + 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x35, + 0x21, 0x11, 0x21, 0x35, 0x21, 0x11, 0x35, 0x33, 0x35, 0x23, 0x33, 0x35, + 0x23, 0x15, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x7D, + 0xFA, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0xFA, 0x7D, + 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, + 0x00, 0x07, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x6B, 0x40, 0x3B, 0x12, 0x12, + 0x0D, 0x09, 0x09, 0x0D, 0x09, 0x09, 0x13, 0x0D, 0x00, 0x0C, 0x04, 0x0D, + 0x0D, 0x13, 0x08, 0x08, 0x10, 0x10, 0x00, 0x13, 0x04, 0x05, 0x00, 0x03, + 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x0E, 0x0A, 0x0C, 0x11, 0x0C, + 0x12, 0x08, 0x06, 0x04, 0x13, 0x00, 0x13, 0x01, 0x11, 0x01, 0x0A, 0x01, + 0x06, 0x0A, 0x0F, 0x06, 0x01, 0x03, 0x04, 0x06, 0x09, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xFC, 0xFC, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, + 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, + 0x35, 0x21, 0x19, 0x01, 0x15, 0x33, 0x15, 0x33, 0x35, 0x23, 0x35, 0x33, + 0x23, 0x15, 0x33, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0x7D, + 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x01, + 0x77, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x48, 0x40, 0x29, 0x0C, 0x0C, 0x0A, 0x0A, 0x00, 0x09, 0x04, 0x0A, + 0x0A, 0x0F, 0x0E, 0x00, 0x0F, 0x04, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, + 0x03, 0x06, 0x01, 0x02, 0x0E, 0x0A, 0x0C, 0x01, 0x0A, 0x01, 0x06, 0x09, + 0x0F, 0x08, 0x06, 0x06, 0x01, 0x03, 0x04, 0x06, 0x0B, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xFC, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x11, 0x35, 0x33, + 0x35, 0x23, 0x33, 0x35, 0x23, 0x15, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, + 0xFE, 0x89, 0x7D, 0x7D, 0xFA, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, + 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0x7D, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x51, 0x40, 0x2E, 0x0C, 0x0C, 0x08, 0x08, 0x00, 0x0B, 0x04, 0x08, + 0x08, 0x0D, 0x0E, 0x00, 0x0D, 0x04, 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, + 0x06, 0x00, 0x02, 0x0D, 0x07, 0x0C, 0x0B, 0x09, 0x05, 0x08, 0x0F, 0x04, + 0x0E, 0x00, 0x01, 0x0E, 0x01, 0x0B, 0x01, 0x05, 0x05, 0x01, 0x02, 0x04, + 0x05, 0x0A, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0xFC, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0xFC, 0x10, + 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, + 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, 0x33, 0x03, 0x23, 0x15, 0x33, 0x35, + 0x33, 0x35, 0x23, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x7D, 0x01, 0x77, + 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x13, 0x00, 0x5D, 0x40, 0x34, 0x10, 0x10, 0x0B, 0x0D, 0x0D, 0x12, + 0x0C, 0x0C, 0x0B, 0x0C, 0x0C, 0x13, 0x0B, 0x00, 0x12, 0x04, 0x08, 0x08, + 0x13, 0x0A, 0x00, 0x13, 0x04, 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, 0x06, + 0x00, 0x02, 0x0A, 0x12, 0x08, 0x0D, 0x05, 0x12, 0x04, 0x0D, 0x01, 0x11, + 0x12, 0x01, 0x11, 0x04, 0x00, 0x0E, 0x0E, 0x01, 0x0D, 0x04, 0x2B, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, + 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, 0x33, 0x11, 0x35, 0x23, + 0x15, 0x33, 0x15, 0x33, 0x35, 0x21, 0x15, 0x33, 0x35, 0x01, 0xF4, 0xFE, + 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0xFE, 0x0C, 0x7D, + 0x02, 0x71, 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x01, 0x77, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x03, 0xE8, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x4D, + 0x40, 0x2C, 0x0C, 0x0C, 0x0B, 0x0B, 0x00, 0x0A, 0x04, 0x08, 0x08, 0x0F, + 0x0E, 0x00, 0x0F, 0x04, 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, + 0x02, 0x0E, 0x05, 0x0D, 0x08, 0x0A, 0x07, 0x04, 0x0B, 0x00, 0x01, 0x0B, + 0x01, 0x08, 0x01, 0x05, 0x05, 0x01, 0x02, 0x04, 0x05, 0x0F, 0x10, 0xD0, + 0x2B, 0x10, 0xFC, 0xFC, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, + 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, + 0x33, 0x03, 0x15, 0x33, 0x35, 0x23, 0x35, 0x23, 0x15, 0x01, 0xF4, 0xFE, + 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, + 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3B, 0x40, 0x21, 0x0D, 0x0D, 0x08, 0x0B, + 0x00, 0x08, 0x08, 0x00, 0x0F, 0x04, 0x01, 0x00, 0x05, 0x06, 0x0D, 0x02, + 0x09, 0x00, 0x08, 0x0F, 0x07, 0x01, 0x00, 0x01, 0x0F, 0x01, 0x02, 0x02, + 0x01, 0x05, 0x04, 0x02, 0x0E, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0xFC, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0xFC, 0x2B, 0x10, 0xFC, + 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x11, 0x23, 0x11, 0x23, 0x11, 0x21, + 0x11, 0x27, 0x33, 0x35, 0x23, 0x15, 0x23, 0x15, 0x33, 0x01, 0x77, 0xFA, + 0x7D, 0x01, 0xF4, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFE, 0x0C, + 0x01, 0xF4, 0xFD, 0x8F, 0x02, 0x71, 0xFA, 0x7D, 0x7D, 0x7D, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x13, 0x00, 0x53, 0x40, 0x2D, 0x10, 0x10, 0x08, 0x0D, + 0x0D, 0x12, 0x0C, 0x0C, 0x13, 0x0C, 0x0C, 0x08, 0x09, 0x00, 0x08, 0x08, + 0x13, 0x13, 0x00, 0x12, 0x04, 0x01, 0x00, 0x05, 0x06, 0x0A, 0x0E, 0x08, + 0x11, 0x06, 0x12, 0x04, 0x0D, 0x02, 0x0E, 0x0E, 0x01, 0x0D, 0x04, 0x00, + 0x11, 0x12, 0x01, 0x11, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0xFC, 0x2B, 0x10, + 0xD0, 0x2F, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x11, 0x23, 0x11, 0x23, 0x11, 0x21, + 0x11, 0x27, 0x35, 0x23, 0x15, 0x23, 0x15, 0x33, 0x35, 0x33, 0x15, 0x33, + 0x35, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, + 0x7D, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x02, 0x71, 0xFA, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x47, + 0x40, 0x27, 0x0C, 0x0C, 0x08, 0x09, 0x00, 0x08, 0x08, 0x0F, 0x0F, 0x00, + 0x0E, 0x04, 0x01, 0x00, 0x05, 0x06, 0x0F, 0x00, 0x0C, 0x08, 0x0A, 0x02, + 0x07, 0x01, 0x0E, 0x00, 0x0E, 0x01, 0x08, 0x01, 0x02, 0x08, 0x0D, 0x02, + 0x01, 0x05, 0x04, 0x02, 0x0B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xFC, + 0xFC, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, + 0x11, 0x23, 0x11, 0x23, 0x11, 0x21, 0x11, 0x27, 0x35, 0x23, 0x15, 0x33, + 0x15, 0x33, 0x35, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0xF4, 0xFA, 0x7D, 0x7D, + 0x7D, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x02, 0x71, 0xFA, + 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0xFF, 0x83, 0x00, 0x7D, + 0x00, 0x7D, 0x00, 0x03, 0x00, 0x0F, 0x40, 0x07, 0x02, 0x08, 0x03, 0x02, + 0x01, 0x01, 0x04, 0x2B, 0x00, 0x2F, 0x3F, 0x30, 0x31, 0x35, 0x15, 0x33, + 0x35, 0x7D, 0x7D, 0xFA, 0xFA, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x0B, 0x00, 0x13, 0x00, 0x17, 0x00, 0x7C, + 0x40, 0x45, 0x16, 0x16, 0x11, 0x0D, 0x0D, 0x11, 0x0D, 0x0D, 0x17, 0x11, + 0x00, 0x10, 0x04, 0x11, 0x11, 0x17, 0x0C, 0x0C, 0x14, 0x14, 0x00, 0x17, + 0x04, 0x06, 0x00, 0x08, 0x0A, 0x00, 0x05, 0x04, 0x00, 0x00, 0x02, 0x08, + 0x06, 0x02, 0x02, 0x12, 0x0E, 0x10, 0x15, 0x10, 0x16, 0x0C, 0x0B, 0x09, + 0x17, 0x07, 0x04, 0x05, 0x15, 0x05, 0x16, 0x01, 0x17, 0x01, 0x15, 0x01, + 0x0E, 0x01, 0x0B, 0x0E, 0x13, 0x0B, 0x01, 0x04, 0x04, 0x00, 0x0D, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0xFC, 0xFC, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x13, 0x21, 0x35, 0x21, 0x11, 0x21, 0x15, 0x21, + 0x15, 0x21, 0x11, 0x21, 0x11, 0x15, 0x33, 0x15, 0x33, 0x35, 0x23, 0x35, + 0x33, 0x23, 0x15, 0x33, 0x7D, 0x01, 0x77, 0xFE, 0x0C, 0x01, 0x77, 0xFE, + 0x89, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x01, + 0xF4, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x01, 0x77, 0x02, 0x71, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x03, 0xE8, 0x00, 0x0B, 0x00, 0x13, 0x00, 0x17, 0x00, 0x7C, 0x40, 0x45, + 0x16, 0x16, 0x11, 0x0D, 0x0D, 0x11, 0x0D, 0x0D, 0x17, 0x11, 0x00, 0x10, + 0x04, 0x11, 0x11, 0x17, 0x0C, 0x0C, 0x14, 0x14, 0x00, 0x17, 0x04, 0x06, + 0x00, 0x08, 0x0A, 0x00, 0x05, 0x04, 0x00, 0x00, 0x02, 0x08, 0x06, 0x02, + 0x02, 0x12, 0x0E, 0x10, 0x15, 0x10, 0x16, 0x0C, 0x0B, 0x09, 0x17, 0x07, + 0x04, 0x05, 0x15, 0x05, 0x16, 0x01, 0x17, 0x01, 0x15, 0x01, 0x0E, 0x01, + 0x0B, 0x0E, 0x13, 0x0B, 0x01, 0x04, 0x04, 0x00, 0x0D, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xFC, 0xFC, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x13, 0x21, 0x35, 0x21, 0x11, 0x21, 0x15, 0x21, 0x15, 0x21, + 0x11, 0x21, 0x11, 0x15, 0x33, 0x15, 0x33, 0x35, 0x23, 0x35, 0x33, 0x23, + 0x15, 0x33, 0x7D, 0x01, 0x77, 0xFE, 0x0C, 0x01, 0x77, 0xFE, 0x89, 0x01, + 0xF4, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, + 0xFE, 0x89, 0x7D, 0x7D, 0x01, 0x77, 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x13, 0x00, 0x42, 0x40, 0x26, 0x0F, 0x00, 0x03, 0x0D, + 0x00, 0x09, 0x07, 0x00, 0x09, 0x05, 0x00, 0x03, 0x01, 0x01, 0x12, 0x00, + 0x00, 0x13, 0x13, 0x00, 0x12, 0x04, 0x03, 0x06, 0x09, 0x02, 0x10, 0x0C, + 0x06, 0x01, 0x0F, 0x04, 0x02, 0x0B, 0x0C, 0x01, 0x0B, 0x04, 0x2B, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x11, 0x15, 0x33, 0x15, 0x21, 0x35, 0x33, 0x11, 0x23, 0x35, 0x21, 0x15, + 0x33, 0x35, 0x33, 0x11, 0x23, 0x35, 0x33, 0x35, 0x7D, 0x01, 0x77, 0x7D, + 0x7D, 0xFE, 0x89, 0x7D, 0xF5, 0xF5, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0x7D, + 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x13, + 0x00, 0x42, 0x40, 0x26, 0x0F, 0x00, 0x03, 0x0D, 0x00, 0x09, 0x07, 0x00, + 0x09, 0x05, 0x00, 0x03, 0x01, 0x01, 0x12, 0x00, 0x00, 0x13, 0x13, 0x00, + 0x12, 0x04, 0x03, 0x06, 0x09, 0x02, 0x10, 0x0C, 0x06, 0x01, 0x0F, 0x04, + 0x02, 0x0B, 0x0C, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, + 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x11, 0x15, 0x33, 0x15, + 0x21, 0x35, 0x33, 0x11, 0x23, 0x35, 0x21, 0x15, 0x33, 0x35, 0x33, 0x11, + 0x23, 0x35, 0x33, 0x35, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, + 0xF5, 0xF5, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0x01, 0x77, 0x7D, 0xFA, + 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x5A, + 0x40, 0x33, 0x10, 0x10, 0x0E, 0x0E, 0x00, 0x0D, 0x04, 0x0E, 0x0E, 0x13, + 0x12, 0x00, 0x13, 0x04, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, 0x04, 0x09, + 0x06, 0x12, 0x0E, 0x11, 0x00, 0x0D, 0x13, 0x0C, 0x02, 0x0B, 0x01, 0x10, + 0x08, 0x05, 0x06, 0x10, 0x06, 0x00, 0x10, 0x01, 0x0E, 0x01, 0x02, 0x02, + 0x01, 0x05, 0x04, 0x02, 0x0F, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0xD0, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x2B, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, + 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, + 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, 0x25, 0x33, 0x35, 0x23, 0x33, 0x35, + 0x23, 0x15, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, + 0xFE, 0x89, 0x7D, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, + 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, + 0x00, 0x5A, 0x40, 0x33, 0x10, 0x10, 0x0E, 0x0E, 0x00, 0x0D, 0x04, 0x0E, + 0x0E, 0x13, 0x12, 0x00, 0x13, 0x04, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, + 0x04, 0x09, 0x06, 0x12, 0x0E, 0x11, 0x00, 0x0D, 0x13, 0x0C, 0x02, 0x0B, + 0x01, 0x10, 0x08, 0x05, 0x06, 0x10, 0x06, 0x00, 0x10, 0x01, 0x0E, 0x01, + 0x02, 0x02, 0x01, 0x05, 0x04, 0x02, 0x0F, 0x10, 0xD0, 0x2B, 0x10, 0xFC, + 0xFC, 0xD0, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x2B, 0x10, 0xFC, 0x2B, 0x10, + 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, + 0x23, 0x11, 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, 0x25, 0x33, 0x35, 0x23, + 0x33, 0x35, 0x23, 0x15, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0xFE, 0x89, + 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, 0xFA, + 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x44, 0x40, 0x28, 0x0D, 0x0D, 0x08, 0x0C, 0x0C, 0x05, 0x09, 0x00, + 0x08, 0x04, 0x07, 0x07, 0x0E, 0x05, 0x00, 0x04, 0x04, 0x05, 0x05, 0x0F, + 0x0E, 0x00, 0x0F, 0x04, 0x02, 0x06, 0x0B, 0x02, 0x0C, 0x02, 0x0A, 0x02, + 0x06, 0x01, 0x0F, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, + 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x19, 0x01, + 0x33, 0x35, 0x33, 0x35, 0x33, 0x35, 0x23, 0x35, 0x23, 0x35, 0x11, 0x35, + 0x33, 0x15, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xF5, 0x02, 0x71, 0xFD, 0x8F, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x44, 0x40, 0x28, 0x0D, 0x0D, 0x08, 0x0C, 0x0C, 0x05, 0x09, 0x00, + 0x08, 0x04, 0x07, 0x07, 0x0E, 0x05, 0x00, 0x04, 0x04, 0x05, 0x05, 0x0F, + 0x0E, 0x00, 0x0F, 0x04, 0x02, 0x06, 0x0B, 0x02, 0x0C, 0x02, 0x0A, 0x02, + 0x06, 0x01, 0x0F, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, + 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x19, 0x01, + 0x33, 0x35, 0x33, 0x35, 0x33, 0x35, 0x23, 0x35, 0x23, 0x35, 0x11, 0x35, + 0x33, 0x15, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xF5, 0x02, 0x71, 0xFD, 0x8F, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0xFA, 0x01, 0x77, 0x01, 0x77, 0x00, 0x03, 0x00, 0x0A, + 0x40, 0x04, 0x02, 0x00, 0x03, 0x04, 0x00, 0x2B, 0x30, 0x31, 0x25, 0x35, + 0x21, 0x15, 0x01, 0x77, 0xFE, 0x89, 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x7D, 0x01, 0x77, 0x01, 0xF4, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x13, 0x00, 0x83, 0x40, 0x46, 0x10, 0x10, 0x00, 0x0C, + 0x0C, 0x01, 0x09, 0x09, 0x12, 0x08, 0x08, 0x00, 0x08, 0x08, 0x13, 0x05, + 0x05, 0x01, 0x05, 0x05, 0x0F, 0x03, 0x03, 0x0E, 0x02, 0x02, 0x0F, 0x01, + 0x00, 0x0E, 0x04, 0x00, 0x00, 0x0F, 0x04, 0x00, 0x00, 0x13, 0x12, 0x00, + 0x13, 0x04, 0x0E, 0x00, 0x0E, 0x11, 0x0C, 0x13, 0x06, 0x0A, 0x06, 0x0B, + 0x04, 0x08, 0x01, 0x0A, 0x02, 0x0A, 0x02, 0x0B, 0x0A, 0x01, 0x00, 0x01, + 0x11, 0x00, 0x00, 0x01, 0x13, 0x04, 0x2B, 0x10, 0xD0, 0xD0, 0x10, 0xFC, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x13, 0x15, 0x33, 0x15, 0x33, 0x35, 0x23, + 0x35, 0x33, 0x35, 0x23, 0x15, 0x07, 0x15, 0x33, 0x3D, 0x02, 0x23, 0x15, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x01, 0x77, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x00, 0xFA, 0x02, 0x71, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1B, 0x0A, 0x00, 0x00, 0x08, + 0x08, 0x06, 0x04, 0x00, 0x00, 0x06, 0x00, 0x03, 0x04, 0x00, 0x02, 0x04, + 0x01, 0x0B, 0x04, 0x03, 0x01, 0x06, 0x04, 0x09, 0x01, 0x02, 0x04, 0x2B, + 0x2B, 0x2B, 0x00, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x10, 0xFC, + 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, 0x33, 0x15, 0x2B, 0x02, 0x35, + 0x33, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x02, 0x71, 0xFE, 0x89, 0xFA, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x03, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x34, 0x40, 0x1D, 0x0F, 0x00, 0x0D, 0x0C, 0x0C, 0x0B, 0x05, 0x05, + 0x09, 0x05, 0x05, 0x0A, 0x09, 0x00, 0x08, 0x04, 0x0B, 0x00, 0x0A, 0x04, + 0x04, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x06, 0x0D, 0x02, 0x00, 0x3F, 0x3F, + 0xFC, 0x10, 0xFC, 0x2B, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x35, 0x21, 0x11, 0x15, + 0x33, 0x15, 0x33, 0x35, 0x23, 0x35, 0x33, 0x35, 0x23, 0x15, 0x01, 0xF4, + 0xFE, 0x0C, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0x01, 0x77, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x03, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x34, 0x40, 0x1D, + 0x0C, 0x0C, 0x0A, 0x0A, 0x00, 0x0E, 0x04, 0x0A, 0x0A, 0x0F, 0x09, 0x00, + 0x06, 0x08, 0x08, 0x05, 0x05, 0x00, 0x0F, 0x04, 0x04, 0x00, 0x06, 0x01, + 0x00, 0x00, 0x06, 0x06, 0x02, 0x00, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x21, 0x35, 0x21, 0x15, 0x01, 0x23, 0x35, 0x23, 0x15, 0x33, + 0x15, 0x33, 0x21, 0x15, 0x33, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, + 0xFA, 0xFA, 0xFA, 0xFA, 0xFE, 0x0C, 0xFA, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0xFA, 0x01, 0x77, + 0x02, 0xEE, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x21, 0x40, 0x12, 0x0A, 0x00, + 0x04, 0x04, 0x07, 0x06, 0x0A, 0x04, 0x01, 0x0A, 0x01, 0x0B, 0x00, 0x0B, + 0x0B, 0x01, 0x03, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0xFC, 0x10, 0xD0, + 0x00, 0x2F, 0x2B, 0x30, 0x31, 0x13, 0x15, 0x23, 0x11, 0x21, 0x11, 0x23, + 0x35, 0x07, 0x33, 0x15, 0x23, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, + 0x7D, 0x02, 0xEE, 0x7D, 0xFE, 0x89, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x59, 0x02, 0x71, 0x00, 0x1B, + 0x00, 0x5C, 0x40, 0x3D, 0x17, 0x00, 0x00, 0x13, 0x00, 0x00, 0x0F, 0x00, + 0x00, 0x0B, 0x00, 0x00, 0x07, 0x00, 0x00, 0x03, 0x00, 0x00, 0x06, 0x1A, + 0x02, 0x15, 0x02, 0x11, 0x02, 0x0D, 0x02, 0x09, 0x02, 0x05, 0x02, 0x01, + 0x02, 0x18, 0x01, 0x1B, 0x04, 0x14, 0x01, 0x17, 0x04, 0x10, 0x01, 0x13, + 0x04, 0x0C, 0x01, 0x0F, 0x04, 0x08, 0x01, 0x0B, 0x04, 0x04, 0x01, 0x07, + 0x04, 0x00, 0x01, 0x03, 0x04, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, + 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, + 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x11, + 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, + 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, + 0x23, 0x11, 0x06, 0x59, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, + 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, + 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x27, + 0x40, 0x17, 0x09, 0x00, 0x00, 0x05, 0x00, 0x00, 0x01, 0x00, 0x00, 0x08, + 0x06, 0x03, 0x06, 0x00, 0x02, 0x08, 0x01, 0x07, 0x04, 0x04, 0x01, 0x03, + 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x10, + 0xFC, 0x30, 0x31, 0x11, 0x15, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, 0x33, + 0x11, 0x33, 0x35, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0xFE, + 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0x00, 0x03, 0x00, 0x00, + 0xFF, 0x83, 0x01, 0x77, 0x02, 0xEE, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x3A, 0x40, 0x20, 0x08, 0x00, 0x09, 0x01, 0x01, 0x07, 0x06, 0x00, + 0x07, 0x04, 0x00, 0x00, 0x09, 0x08, 0x06, 0x00, 0x04, 0x01, 0x00, 0x02, + 0x0A, 0x02, 0x0B, 0x00, 0x01, 0x0A, 0x00, 0x07, 0x0A, 0x01, 0x09, 0x04, + 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, + 0xD0, 0x00, 0x3F, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, + 0x33, 0x11, 0x23, 0x11, 0x13, 0x35, 0x23, 0x15, 0x03, 0x15, 0x33, 0x35, + 0xFA, 0x7D, 0xFA, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, + 0x7D, 0x7D, 0xFD, 0x8F, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x71, 0x02, 0x71, 0x00, 0x11, 0x00, 0x15, 0x00, 0x6D, 0x40, 0x3D, + 0x12, 0x12, 0x0D, 0x07, 0x07, 0x0C, 0x05, 0x05, 0x0D, 0x05, 0x05, 0x15, + 0x03, 0x03, 0x14, 0x01, 0x01, 0x0D, 0x01, 0x01, 0x15, 0x0D, 0x00, 0x0C, + 0x04, 0x0D, 0x0D, 0x15, 0x14, 0x00, 0x15, 0x04, 0x00, 0x00, 0x0F, 0x0A, + 0x06, 0x0F, 0x02, 0x10, 0x04, 0x0E, 0x0A, 0x0C, 0x15, 0x12, 0x01, 0x15, + 0x04, 0x06, 0x03, 0x03, 0x01, 0x04, 0x04, 0x00, 0x09, 0x0A, 0x01, 0x09, + 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x13, + 0x15, 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x15, 0x33, 0x35, 0x33, + 0x35, 0x23, 0x11, 0x21, 0x15, 0x05, 0x35, 0x23, 0x15, 0xFA, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x02, 0x71, 0x7D, 0x01, 0xF4, + 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0x7D, + 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, 0x03, 0x6B, + 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x12, 0x40, 0x09, 0x0B, 0x00, + 0x0A, 0x04, 0x04, 0x00, 0x05, 0x06, 0x02, 0x00, 0x2F, 0x3F, 0xFC, 0x2B, + 0x30, 0x31, 0x01, 0x11, 0x21, 0x19, 0x01, 0x15, 0x21, 0x35, 0x25, 0x15, + 0x21, 0x35, 0x01, 0x77, 0xFE, 0x89, 0x02, 0xEE, 0xFD, 0x12, 0x02, 0xEE, + 0x01, 0xF4, 0x01, 0x77, 0xFE, 0x89, 0xFE, 0x89, 0x7D, 0x7D, 0xFA, 0x7D, + 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x01, 0xF4, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x61, 0x40, 0x35, 0x0C, 0x0C, + 0x07, 0x08, 0x00, 0x09, 0x03, 0x03, 0x07, 0x03, 0x03, 0x0F, 0x07, 0x00, + 0x0E, 0x04, 0x01, 0x00, 0x09, 0x00, 0x00, 0x0F, 0x06, 0x00, 0x0F, 0x04, + 0x09, 0x06, 0x0A, 0x00, 0x08, 0x0E, 0x08, 0x0F, 0x06, 0x0E, 0x06, 0x0F, + 0x04, 0x00, 0x04, 0x0B, 0x02, 0x01, 0x00, 0x01, 0x0E, 0x00, 0x0B, 0x0E, + 0x01, 0x0D, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0xFC, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x13, 0x15, 0x33, + 0x35, 0x23, 0x35, 0x23, 0x1D, 0x02, 0x33, 0x35, 0x27, 0x15, 0x33, 0x35, + 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x01, 0x77, 0xFA, 0xFA, 0x7D, + 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2A, + 0x40, 0x19, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x04, 0x06, 0x06, 0x01, + 0x06, 0x00, 0x02, 0x09, 0x02, 0x04, 0x0B, 0x07, 0x01, 0x0B, 0x04, 0x02, + 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, 0x33, 0x15, + 0x33, 0x11, 0x07, 0x23, 0x35, 0x33, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFA, + 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x7D, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0D, 0x00, 0x01, 0x08, 0x00, 0x00, + 0x05, 0x05, 0x0A, 0x03, 0x03, 0x0F, 0x0A, 0x00, 0x0F, 0x04, 0x01, 0x06, + 0x00, 0x02, 0x0A, 0x0E, 0x08, 0x0D, 0x06, 0x02, 0x02, 0x01, 0x0D, 0x04, + 0x0E, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, + 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x21, 0x35, 0x23, 0x35, 0x33, 0x35, + 0x07, 0x15, 0x23, 0x35, 0x17, 0x15, 0x23, 0x35, 0x01, 0xF4, 0x7D, 0x7D, + 0x82, 0xF5, 0xF5, 0xF5, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0x7D, 0xFA, 0x7D, + 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1A, 0x40, 0x0E, 0x05, 0x00, + 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x06, 0x01, 0x03, 0x04, + 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x35, + 0x21, 0x11, 0x21, 0x35, 0x21, 0x11, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, + 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x23, + 0x40, 0x14, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, + 0x03, 0x06, 0x01, 0x02, 0x0A, 0x06, 0x06, 0x01, 0x03, 0x04, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x30, 0x31, 0x01, + 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, 0x01, 0xF4, 0x7D, + 0xFD, 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, 0x40, 0x18, 0x01, 0x00, + 0x08, 0x04, 0x0A, 0x06, 0x05, 0x06, 0x0B, 0x02, 0x03, 0x02, 0x02, 0x06, + 0x06, 0x01, 0x05, 0x04, 0x00, 0x09, 0x0A, 0x01, 0x09, 0x04, 0x2B, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x30, 0x31, + 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, + 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFD, + 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, + 0x40, 0x22, 0x0E, 0x0E, 0x04, 0x02, 0x02, 0x0A, 0x04, 0x00, 0x0A, 0x04, + 0x0B, 0x06, 0x00, 0x06, 0x0D, 0x02, 0x06, 0x02, 0x0A, 0x0E, 0x08, 0x0F, + 0x03, 0x0E, 0x0F, 0x01, 0x0E, 0x04, 0x01, 0x06, 0x06, 0x01, 0x07, 0x04, + 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, + 0x31, 0x33, 0x35, 0x33, 0x35, 0x23, 0x35, 0x23, 0x01, 0x35, 0x23, 0x15, + 0x13, 0x23, 0x15, 0x33, 0x7D, 0xFA, 0xFA, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, + 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x1D, 0x40, 0x11, 0x03, 0x00, 0x00, 0x06, 0x06, 0x01, 0x06, 0x00, + 0x02, 0x06, 0x01, 0x05, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, + 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x11, 0x33, + 0x11, 0x33, 0x11, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x01, 0xF4, + 0xFE, 0x0C, 0x02, 0x71, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, 0x06, 0x00, + 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, 0x02, 0x05, 0x01, 0x02, 0x04, 0x00, + 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, + 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, 0x33, 0x01, 0xF4, 0xFE, + 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0x7D, 0x01, + 0x77, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x05, 0x00, 0x09, 0x00, 0x23, 0x40, 0x15, 0x08, 0x00, 0x00, 0x06, + 0x00, 0x04, 0x04, 0x02, 0x06, 0x00, 0x02, 0x07, 0x02, 0x05, 0x01, 0x09, + 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, 0x21, 0x11, 0x07, + 0x23, 0x35, 0x33, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, + 0x8F, 0xFA, 0x01, 0x77, 0xFA, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x77, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1A, 0x40, 0x0E, 0x06, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x05, 0x06, 0x00, 0x02, 0x05, 0x01, 0x04, 0x04, + 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, + 0x15, 0x33, 0x11, 0x33, 0x11, 0x33, 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x7D, + 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, 0x01, 0xF4, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, 0x40, 0x19, + 0x07, 0x00, 0x00, 0x03, 0x00, 0x00, 0x06, 0x0A, 0x02, 0x05, 0x02, 0x01, + 0x02, 0x08, 0x01, 0x0B, 0x04, 0x04, 0x01, 0x07, 0x04, 0x00, 0x01, 0x03, + 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x21, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, + 0x23, 0x11, 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFE, + 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x13, 0x00, 0x50, 0x40, 0x2C, 0x10, 0x10, 0x04, 0x09, 0x09, 0x0F, + 0x07, 0x07, 0x04, 0x01, 0x01, 0x0F, 0x04, 0x00, 0x0F, 0x04, 0x0E, 0x06, + 0x00, 0x06, 0x12, 0x02, 0x05, 0x02, 0x0A, 0x13, 0x08, 0x0E, 0x06, 0x0D, + 0x04, 0x0E, 0x0E, 0x01, 0x0D, 0x04, 0x02, 0x13, 0x00, 0x10, 0x10, 0x01, + 0x13, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, + 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x15, + 0x25, 0x15, 0x33, 0x35, 0x25, 0x35, 0x23, 0x15, 0x01, 0xF4, 0x7D, 0xFA, + 0x7D, 0x7D, 0xFA, 0xFE, 0x89, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0xFA, + 0xFA, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2A, + 0x40, 0x19, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, 0x04, 0x09, 0x06, 0x0B, + 0x02, 0x03, 0x02, 0x08, 0x05, 0x02, 0x01, 0x05, 0x04, 0x00, 0x07, 0x0A, + 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, + 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, + 0xFE, 0x89, 0x01, 0xF4, 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, + 0x02, 0x71, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x09, 0x00, 0x0D, 0x00, 0x36, 0x40, 0x1F, 0x0B, 0x00, 0x03, 0x05, + 0x05, 0x0D, 0x08, 0x00, 0x0D, 0x04, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, + 0x02, 0x08, 0x0C, 0x06, 0x0B, 0x0C, 0x01, 0x03, 0x04, 0x00, 0x04, 0x04, + 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, 0x17, 0x15, + 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x82, 0xF5, 0xF5, 0xF5, + 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x05, + 0x00, 0x10, 0x40, 0x08, 0x00, 0x00, 0x01, 0x02, 0x04, 0x01, 0x03, 0x04, + 0x2B, 0x00, 0x3F, 0xFC, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x33, 0x11, + 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x01, 0xF4, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x13, + 0x00, 0x17, 0x00, 0x1B, 0x00, 0x7C, 0x40, 0x44, 0x1A, 0x1A, 0x10, 0x12, + 0x12, 0x17, 0x0C, 0x0C, 0x10, 0x08, 0x08, 0x10, 0x06, 0x06, 0x17, 0x02, + 0x02, 0x17, 0x10, 0x00, 0x17, 0x04, 0x15, 0x06, 0x04, 0x06, 0x00, 0x06, + 0x19, 0x02, 0x0E, 0x02, 0x0A, 0x02, 0x15, 0x12, 0x0F, 0x17, 0x0D, 0x12, + 0x12, 0x01, 0x17, 0x04, 0x0B, 0x13, 0x01, 0x0A, 0x09, 0x02, 0x07, 0x19, + 0x07, 0x1A, 0x05, 0x1B, 0x01, 0x19, 0x03, 0x19, 0x03, 0x1A, 0x01, 0x0A, + 0x19, 0x01, 0x0A, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x3B, 0x01, + 0x35, 0x33, 0x15, 0x33, 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, 0x23, + 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x07, 0x33, 0x35, 0x23, 0x01, 0x23, + 0x15, 0x33, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0xFA, 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, 0x7D, + 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2C, + 0x40, 0x1A, 0x06, 0x00, 0x08, 0x02, 0x00, 0x05, 0x04, 0x00, 0x00, 0x0A, + 0x08, 0x06, 0x0A, 0x02, 0x07, 0x00, 0x01, 0x06, 0x09, 0x01, 0x06, 0x04, + 0x03, 0x01, 0x00, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x11, 0x21, 0x15, 0x23, + 0x15, 0x33, 0x15, 0x21, 0x15, 0x21, 0x11, 0x21, 0x01, 0x77, 0xFA, 0xFA, + 0xFE, 0x89, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, + 0x02, 0x71, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x09, 0x00, 0x24, 0x40, 0x15, 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, + 0x06, 0x09, 0x02, 0x03, 0x02, 0x07, 0x02, 0x02, 0x01, 0x05, 0x04, 0x08, + 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, + 0x10, 0xFC, 0x30, 0x31, 0x01, 0x11, 0x23, 0x11, 0x23, 0x11, 0x33, 0x15, + 0x21, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0x01, 0x77, 0x02, 0x71, 0xFE, + 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x03, 0x6B, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x31, + 0x40, 0x1D, 0x0C, 0x00, 0x0B, 0x04, 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, + 0x06, 0x09, 0x02, 0x03, 0x02, 0x0B, 0x00, 0x0A, 0x02, 0x07, 0x02, 0x02, + 0x01, 0x05, 0x04, 0x09, 0x01, 0x00, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x30, + 0x31, 0x01, 0x11, 0x23, 0x11, 0x23, 0x11, 0x33, 0x15, 0x21, 0x11, 0x25, + 0x33, 0x35, 0x23, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0x01, 0x77, 0xFE, 0x89, + 0xFA, 0xFA, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0x02, + 0x71, 0x7D, 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x26, 0x40, 0x16, 0x06, 0x00, + 0x02, 0x04, 0x00, 0x02, 0x08, 0x06, 0x00, 0x06, 0x02, 0x02, 0x03, 0x08, + 0x08, 0x01, 0x07, 0x04, 0x02, 0x01, 0x05, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x33, + 0x11, 0x21, 0x15, 0x33, 0x21, 0x11, 0x33, 0x11, 0x01, 0x77, 0x7D, 0xFE, + 0x89, 0xFA, 0xFE, 0x89, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, 0x01, 0xF4, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x0D, + 0x00, 0x32, 0x40, 0x1D, 0x0B, 0x00, 0x03, 0x09, 0x00, 0x07, 0x05, 0x00, + 0x03, 0x01, 0x00, 0x03, 0x00, 0x00, 0x07, 0x03, 0x06, 0x07, 0x02, 0x08, + 0x0C, 0x06, 0x01, 0x0B, 0x04, 0x0C, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, + 0x10, 0xFC, 0x30, 0x31, 0x13, 0x11, 0x23, 0x15, 0x21, 0x35, 0x23, 0x11, + 0x21, 0x15, 0x33, 0x11, 0x23, 0x11, 0x3F, 0x3F, 0x02, 0x71, 0x3E, 0xFE, + 0x89, 0xFA, 0xFA, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, + 0xFE, 0x89, 0x01, 0x77, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, + 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, + 0x00, 0x64, 0x40, 0x39, 0x0E, 0x0E, 0x11, 0x0C, 0x00, 0x04, 0x0C, 0x0C, + 0x12, 0x09, 0x09, 0x11, 0x00, 0x12, 0x00, 0x04, 0x0B, 0x06, 0x06, 0x06, + 0x01, 0x06, 0x04, 0x02, 0x00, 0x02, 0x10, 0x07, 0x0C, 0x00, 0x0A, 0x12, + 0x08, 0x0D, 0x08, 0x0E, 0x04, 0x13, 0x03, 0x01, 0x00, 0x04, 0x00, 0x0F, + 0x01, 0x0D, 0x0D, 0x01, 0x12, 0x04, 0x12, 0x01, 0x07, 0x07, 0x01, 0x06, + 0x04, 0x2B, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0xFC, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x11, 0x33, 0x11, 0x21, 0x23, + 0x11, 0x3B, 0x01, 0x11, 0x23, 0x11, 0x13, 0x23, 0x15, 0x33, 0x21, 0x33, + 0x35, 0x23, 0x01, 0xF4, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, + 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, + 0xFD, 0x8F, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x02, 0xAF, 0x02, 0x71, 0x00, 0x0D, 0x00, 0x2D, + 0x40, 0x1C, 0x09, 0x00, 0x00, 0x05, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, + 0x0C, 0x02, 0x07, 0x02, 0x03, 0x02, 0x0A, 0x01, 0x0D, 0x04, 0x06, 0x01, + 0x09, 0x04, 0x02, 0x01, 0x05, 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, + 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x35, 0x23, + 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x02, + 0xAF, 0x3E, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, + 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x3E, 0x40, 0x23, 0x0D, 0x00, 0x03, 0x0C, 0x0C, 0x05, 0x00, 0x00, + 0x0B, 0x05, 0x00, 0x0B, 0x04, 0x09, 0x06, 0x01, 0x06, 0x03, 0x02, 0x0C, + 0x07, 0x09, 0x07, 0x04, 0x0B, 0x07, 0x01, 0x0B, 0x04, 0x00, 0x0E, 0x03, + 0x01, 0x0E, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xFC, 0x30, 0x31, 0x25, 0x15, 0x33, 0x11, 0x21, 0x15, 0x33, 0x15, + 0x07, 0x33, 0x35, 0x23, 0x37, 0x35, 0x33, 0x15, 0x01, 0x77, 0x7D, 0xFE, + 0x0C, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, 0x02, 0x71, 0xFA, + 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x23, 0x40, 0x15, + 0x07, 0x00, 0x00, 0x03, 0x00, 0x09, 0x04, 0x00, 0x06, 0x05, 0x02, 0x08, + 0x04, 0x04, 0x01, 0x05, 0x04, 0x01, 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x11, + 0x21, 0x35, 0x23, 0x01, 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x89, 0x7D, + 0x01, 0x77, 0xFA, 0x01, 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x32, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x2C, 0x40, 0x1A, 0x09, 0x00, 0x02, 0x05, 0x00, 0x0B, 0x04, 0x02, + 0x06, 0x07, 0x02, 0x07, 0x01, 0x0A, 0x05, 0x0A, 0x03, 0x01, 0x09, 0x04, + 0x0A, 0x01, 0x02, 0x04, 0x0A, 0x06, 0x10, 0xD0, 0x2B, 0x2B, 0x10, 0xD0, + 0x10, 0xFC, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x11, 0x33, + 0x11, 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, 0x15, 0x23, 0x35, 0x3E, 0x01, + 0xF4, 0xFE, 0x89, 0xBB, 0x01, 0xB5, 0xFA, 0x01, 0xF4, 0xFE, 0x0C, 0x01, + 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x02, 0xEE, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x29, + 0x40, 0x19, 0x0B, 0x00, 0x06, 0x03, 0x00, 0x0D, 0x04, 0x06, 0x06, 0x00, + 0x06, 0x09, 0x02, 0x04, 0x02, 0x0C, 0x04, 0x04, 0x01, 0x05, 0x04, 0x01, + 0x01, 0x0B, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, + 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, + 0x33, 0x11, 0x23, 0x03, 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x89, 0x7D, + 0x02, 0x71, 0x7D, 0x7D, 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0xFD, 0x8F, 0x02, + 0x71, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0F, 0x00, 0x3E, 0x40, 0x24, 0x0C, 0x00, + 0x0E, 0x0A, 0x00, 0x08, 0x06, 0x00, 0x08, 0x02, 0x00, 0x05, 0x04, 0x00, + 0x00, 0x0E, 0x08, 0x06, 0x0E, 0x02, 0x0E, 0x01, 0x09, 0x01, 0x07, 0x00, + 0x05, 0x01, 0x0C, 0x01, 0x01, 0x04, 0x03, 0x01, 0x00, 0x04, 0x2B, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, + 0xFC, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x11, 0x21, + 0x15, 0x23, 0x15, 0x33, 0x15, 0x21, 0x15, 0x21, 0x35, 0x33, 0x11, 0x23, + 0x35, 0x21, 0x01, 0x77, 0xFA, 0xFA, 0xFE, 0x89, 0x01, 0x77, 0x7D, 0x7D, + 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, 0x02, 0x71, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x37, 0x40, 0x22, 0x0E, 0x00, 0x0A, 0x0C, 0x00, 0x04, + 0x08, 0x00, 0x03, 0x04, 0x04, 0x06, 0x00, 0x06, 0x0A, 0x02, 0x06, 0x02, + 0x06, 0x01, 0x0F, 0x04, 0x03, 0x08, 0x0E, 0x01, 0x08, 0x04, 0x01, 0x0A, + 0x0A, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x2B, 0x00, + 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x31, + 0x33, 0x35, 0x33, 0x15, 0x21, 0x11, 0x21, 0x15, 0x23, 0x35, 0x23, 0x01, + 0x23, 0x11, 0x33, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0x7D, 0x02, + 0x71, 0xFA, 0xFA, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x0C, 0x01, + 0x77, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x09, 0x00, 0x21, 0x40, 0x14, 0x01, 0x00, 0x06, 0x04, 0x08, 0x06, + 0x09, 0x02, 0x03, 0x02, 0x02, 0x01, 0x05, 0x04, 0x00, 0x07, 0x08, 0x01, + 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x30, + 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, 0x33, 0x11, 0x01, + 0x77, 0xFA, 0x7D, 0x01, 0x77, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, + 0xFA, 0x02, 0x71, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x32, + 0x02, 0x71, 0x00, 0x09, 0x00, 0x20, 0x40, 0x13, 0x06, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x06, 0x09, 0x02, 0x04, 0x02, 0x08, 0x01, 0x09, 0x04, 0x03, + 0x01, 0x06, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x31, 0x21, 0x35, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, + 0x02, 0x32, 0x3E, 0x7D, 0xFA, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x01, + 0xF4, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x66, 0x40, 0x39, 0x10, 0x10, + 0x0C, 0x0E, 0x0E, 0x12, 0x06, 0x06, 0x0B, 0x00, 0x0C, 0x0C, 0x13, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, 0x02, 0x04, 0x00, 0x12, 0x12, 0x00, + 0x13, 0x04, 0x09, 0x06, 0x02, 0x02, 0x09, 0x0E, 0x09, 0x0D, 0x07, 0x13, + 0x10, 0x01, 0x06, 0x04, 0x03, 0x13, 0x01, 0x0E, 0x01, 0x0E, 0x01, 0x0D, + 0x00, 0x01, 0x0F, 0x0F, 0x01, 0x0E, 0x04, 0x2B, 0x10, 0xFC, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0xD0, 0x2F, 0x10, 0xFC, + 0x10, 0xD0, 0x2F, 0xFC, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x01, 0x23, 0x35, 0x23, 0x15, 0x23, 0x11, 0x33, 0x15, 0x33, + 0x35, 0x33, 0x27, 0x23, 0x35, 0x33, 0x05, 0x35, 0x33, 0x15, 0x02, 0x71, + 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, + 0x01, 0xF4, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, 0x0A, 0x00, 0x00, 0x08, + 0x00, 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x09, 0x02, 0x04, + 0x0B, 0x07, 0x01, 0x0B, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, + 0x19, 0x01, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x07, 0x23, 0x35, 0x33, + 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0xFA, + 0x02, 0x71, 0xFA, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x36, 0x40, 0x1F, 0x0B, 0x00, + 0x03, 0x05, 0x05, 0x0D, 0x08, 0x00, 0x0D, 0x04, 0x00, 0x00, 0x01, 0x03, + 0x06, 0x01, 0x02, 0x08, 0x0C, 0x06, 0x0B, 0x0C, 0x01, 0x03, 0x04, 0x00, + 0x04, 0x04, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, + 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, + 0x17, 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x82, 0xF5, + 0xF5, 0xF5, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, + 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0D, 0x00, + 0x01, 0x08, 0x00, 0x00, 0x05, 0x05, 0x0A, 0x03, 0x03, 0x0F, 0x0A, 0x00, + 0x0F, 0x04, 0x01, 0x06, 0x00, 0x02, 0x0A, 0x0E, 0x08, 0x0D, 0x06, 0x02, + 0x02, 0x01, 0x0D, 0x04, 0x0E, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x21, 0x35, + 0x23, 0x35, 0x33, 0x35, 0x07, 0x15, 0x23, 0x35, 0x17, 0x15, 0x23, 0x35, + 0x01, 0xF4, 0x7D, 0x7D, 0x82, 0xF5, 0xF5, 0xF5, 0x02, 0x71, 0xFD, 0x8F, + 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x05, 0x00, 0x10, + 0x40, 0x08, 0x00, 0x00, 0x01, 0x02, 0x04, 0x01, 0x03, 0x04, 0x2B, 0x00, + 0x3F, 0xFC, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x33, 0x11, 0x01, 0x77, + 0xFE, 0x89, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x01, 0xF4, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x0D, 0x00, 0x32, + 0x40, 0x1D, 0x0B, 0x00, 0x03, 0x09, 0x00, 0x07, 0x05, 0x00, 0x03, 0x01, + 0x00, 0x03, 0x00, 0x00, 0x07, 0x03, 0x06, 0x07, 0x02, 0x08, 0x0C, 0x06, + 0x01, 0x0B, 0x04, 0x0C, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x13, 0x11, 0x23, 0x15, 0x21, 0x35, 0x23, 0x11, 0x21, 0x15, + 0x33, 0x11, 0x23, 0x11, 0x3F, 0x3F, 0x02, 0x71, 0x3E, 0xFE, 0x89, 0xFA, + 0xFA, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0xFE, 0x89, + 0x01, 0x77, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x23, 0x40, 0x14, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, + 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x0A, 0x06, 0x06, 0x01, + 0x03, 0x04, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, + 0x2B, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, + 0x35, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0xFA, + 0xFA, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x13, 0x00, 0x17, + 0x00, 0x1B, 0x00, 0x7C, 0x40, 0x44, 0x1A, 0x1A, 0x10, 0x12, 0x12, 0x17, + 0x0C, 0x0C, 0x10, 0x08, 0x08, 0x10, 0x06, 0x06, 0x17, 0x02, 0x02, 0x17, + 0x10, 0x00, 0x17, 0x04, 0x15, 0x06, 0x04, 0x06, 0x00, 0x06, 0x19, 0x02, + 0x0E, 0x02, 0x0A, 0x02, 0x15, 0x12, 0x0F, 0x17, 0x0D, 0x12, 0x12, 0x01, + 0x17, 0x04, 0x0B, 0x13, 0x01, 0x0A, 0x09, 0x02, 0x07, 0x19, 0x07, 0x1A, + 0x05, 0x1B, 0x01, 0x19, 0x03, 0x19, 0x03, 0x1A, 0x01, 0x0A, 0x19, 0x01, + 0x0A, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x3B, 0x01, 0x35, 0x33, + 0x15, 0x33, 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, 0x23, 0x35, 0x23, + 0x15, 0x33, 0x15, 0x33, 0x07, 0x33, 0x35, 0x23, 0x01, 0x23, 0x15, 0x33, + 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, + 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, + 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, + 0x06, 0x00, 0x08, 0x02, 0x00, 0x05, 0x04, 0x00, 0x00, 0x0A, 0x08, 0x06, + 0x0A, 0x02, 0x07, 0x00, 0x01, 0x06, 0x09, 0x01, 0x06, 0x04, 0x03, 0x01, + 0x00, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, + 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x11, 0x21, 0x15, 0x23, 0x15, 0x33, + 0x15, 0x21, 0x15, 0x21, 0x11, 0x21, 0x01, 0x77, 0xFA, 0xFA, 0xFE, 0x89, + 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, + 0x00, 0x24, 0x40, 0x15, 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, 0x06, 0x09, + 0x02, 0x03, 0x02, 0x07, 0x02, 0x02, 0x01, 0x05, 0x04, 0x08, 0x01, 0x01, + 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x01, 0x11, 0x23, 0x11, 0x23, 0x11, 0x33, 0x15, 0x21, 0x11, + 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0x01, 0x77, 0x02, 0x71, 0xFE, 0x0C, 0x01, + 0xF4, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x03, 0x6B, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x31, 0x40, 0x1D, + 0x0C, 0x00, 0x0B, 0x04, 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, 0x06, 0x09, + 0x02, 0x03, 0x02, 0x0B, 0x00, 0x0A, 0x02, 0x07, 0x02, 0x02, 0x01, 0x05, + 0x04, 0x09, 0x01, 0x00, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x30, 0x31, 0x01, + 0x11, 0x23, 0x11, 0x23, 0x11, 0x33, 0x15, 0x21, 0x11, 0x25, 0x33, 0x35, + 0x23, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0xFA, 0xFA, + 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0x7D, + 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0E, 0x0E, + 0x04, 0x02, 0x02, 0x0A, 0x04, 0x00, 0x0A, 0x04, 0x0B, 0x06, 0x00, 0x06, + 0x0D, 0x02, 0x06, 0x02, 0x0A, 0x0E, 0x08, 0x0F, 0x03, 0x0E, 0x0F, 0x01, + 0x0E, 0x04, 0x01, 0x06, 0x06, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, + 0x35, 0x23, 0x35, 0x23, 0x01, 0x35, 0x23, 0x15, 0x13, 0x23, 0x15, 0x33, + 0x7D, 0xFA, 0xFA, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, + 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x26, + 0x40, 0x16, 0x06, 0x00, 0x02, 0x04, 0x00, 0x02, 0x08, 0x06, 0x00, 0x06, + 0x02, 0x02, 0x03, 0x08, 0x08, 0x01, 0x07, 0x04, 0x02, 0x01, 0x05, 0x04, + 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x21, 0x33, 0x11, 0x21, 0x15, 0x33, 0x21, 0x11, 0x33, 0x11, + 0x01, 0x77, 0x7D, 0xFE, 0x89, 0xFA, 0xFE, 0x89, 0x7D, 0x02, 0x71, 0x7D, + 0xFE, 0x0C, 0x01, 0xF4, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, + 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, + 0x00, 0x64, 0x40, 0x39, 0x0E, 0x0E, 0x11, 0x0C, 0x00, 0x04, 0x0C, 0x0C, + 0x12, 0x09, 0x09, 0x11, 0x00, 0x12, 0x00, 0x04, 0x0B, 0x06, 0x06, 0x06, + 0x01, 0x06, 0x04, 0x02, 0x00, 0x02, 0x10, 0x07, 0x0C, 0x00, 0x0A, 0x12, + 0x08, 0x0D, 0x08, 0x0E, 0x04, 0x13, 0x03, 0x01, 0x00, 0x04, 0x00, 0x0F, + 0x01, 0x0D, 0x0D, 0x01, 0x12, 0x04, 0x12, 0x01, 0x07, 0x07, 0x01, 0x06, + 0x04, 0x2B, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0xFC, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x11, 0x33, 0x11, 0x21, 0x23, + 0x11, 0x3B, 0x01, 0x11, 0x23, 0x11, 0x13, 0x23, 0x15, 0x33, 0x21, 0x33, + 0x35, 0x23, 0x01, 0xF4, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, + 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, + 0xFD, 0x8F, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, + 0x40, 0x18, 0x01, 0x00, 0x08, 0x04, 0x0A, 0x06, 0x05, 0x06, 0x0B, 0x02, + 0x03, 0x02, 0x02, 0x06, 0x06, 0x01, 0x05, 0x04, 0x00, 0x09, 0x0A, 0x01, + 0x09, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, + 0x3F, 0x2B, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, + 0x33, 0x15, 0x33, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x02, + 0x71, 0xFA, 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, + 0x00, 0x1D, 0x40, 0x11, 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, + 0x02, 0x05, 0x01, 0x02, 0x04, 0x00, 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x00, + 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, + 0x23, 0x11, 0x33, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, + 0x02, 0x71, 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, + 0x03, 0x00, 0x00, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x06, 0x01, 0x05, + 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x10, + 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, 0x7D, + 0xFA, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x01, 0xF4, 0xFE, 0x0C, 0x02, 0x71, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, + 0x00, 0x09, 0x00, 0x23, 0x40, 0x15, 0x08, 0x00, 0x00, 0x06, 0x00, 0x04, + 0x04, 0x02, 0x06, 0x00, 0x02, 0x07, 0x02, 0x05, 0x01, 0x09, 0x04, 0x02, + 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, + 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, 0x21, 0x11, 0x07, 0x23, 0x35, + 0x33, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0xFA, + 0x01, 0x77, 0xFA, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x07, 0x00, 0x1A, 0x40, 0x0E, 0x05, 0x00, 0x03, 0x00, + 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x06, 0x01, 0x03, 0x04, 0x2B, 0x00, + 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, + 0x21, 0x35, 0x21, 0x11, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, + 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1A, 0x40, 0x0E, + 0x06, 0x00, 0x00, 0x02, 0x00, 0x00, 0x05, 0x06, 0x00, 0x02, 0x05, 0x01, + 0x04, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x21, 0x15, 0x33, 0x11, 0x33, 0x11, 0x33, 0x01, 0x77, 0xFE, 0x89, + 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, 0x01, 0xF4, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2A, + 0x40, 0x19, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, 0x04, 0x09, 0x06, 0x0B, + 0x02, 0x03, 0x02, 0x08, 0x05, 0x02, 0x01, 0x05, 0x04, 0x00, 0x07, 0x0A, + 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, + 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, + 0xFE, 0x89, 0x01, 0xF4, 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, + 0x02, 0x71, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x66, 0x40, 0x39, 0x10, 0x10, + 0x0C, 0x0E, 0x0E, 0x12, 0x06, 0x06, 0x0B, 0x00, 0x0C, 0x0C, 0x13, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, 0x02, 0x04, 0x00, 0x12, 0x12, 0x00, + 0x13, 0x04, 0x09, 0x06, 0x02, 0x02, 0x09, 0x0E, 0x09, 0x0D, 0x07, 0x13, + 0x10, 0x01, 0x06, 0x04, 0x03, 0x13, 0x01, 0x0E, 0x01, 0x0E, 0x01, 0x0D, + 0x00, 0x01, 0x0F, 0x0F, 0x01, 0x0E, 0x04, 0x2B, 0x10, 0xFC, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0xD0, 0x2F, 0x10, 0xFC, + 0x10, 0xD0, 0x2F, 0xFC, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x01, 0x23, 0x35, 0x23, 0x15, 0x23, 0x11, 0x33, 0x15, 0x33, + 0x35, 0x33, 0x27, 0x23, 0x35, 0x33, 0x05, 0x35, 0x33, 0x15, 0x02, 0x71, + 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, + 0x01, 0xF4, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x50, 0x40, 0x2C, 0x10, 0x10, + 0x04, 0x09, 0x09, 0x0F, 0x07, 0x07, 0x04, 0x01, 0x01, 0x0F, 0x04, 0x00, + 0x0F, 0x04, 0x0E, 0x06, 0x00, 0x06, 0x12, 0x02, 0x05, 0x02, 0x0A, 0x13, + 0x08, 0x0E, 0x06, 0x0D, 0x04, 0x0E, 0x0E, 0x01, 0x0D, 0x04, 0x02, 0x13, + 0x00, 0x10, 0x10, 0x01, 0x13, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, + 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, + 0x33, 0x15, 0x33, 0x15, 0x25, 0x15, 0x33, 0x35, 0x25, 0x35, 0x23, 0x15, + 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFE, 0x89, 0x7D, 0x01, 0x77, + 0x7D, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, + 0xFA, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x32, 0x02, 0x71, + 0x00, 0x09, 0x00, 0x20, 0x40, 0x13, 0x06, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x06, 0x09, 0x02, 0x04, 0x02, 0x08, 0x01, 0x09, 0x04, 0x03, 0x01, 0x06, + 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x31, 0x21, 0x35, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x02, 0x32, + 0x3E, 0x7D, 0xFA, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, + 0x00, 0x21, 0x40, 0x14, 0x01, 0x00, 0x06, 0x04, 0x08, 0x06, 0x09, 0x02, + 0x03, 0x02, 0x02, 0x01, 0x05, 0x04, 0x00, 0x07, 0x08, 0x01, 0x07, 0x04, + 0x2B, 0x10, 0xD0, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x30, 0x31, 0x01, + 0x15, 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, 0x33, 0x11, 0x01, 0x77, 0xFA, + 0x7D, 0x01, 0x77, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, 0xFA, 0x02, + 0x71, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x28, 0x40, 0x19, 0x07, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x06, 0x0A, 0x02, 0x05, 0x02, 0x01, 0x02, 0x08, 0x01, 0x0B, 0x04, 0x04, + 0x01, 0x07, 0x04, 0x00, 0x01, 0x03, 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, + 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x11, 0x23, 0x11, + 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x02, 0x71, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, + 0xF4, 0xFD, 0x8F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0xAF, + 0x02, 0x71, 0x00, 0x0D, 0x00, 0x2D, 0x40, 0x1C, 0x09, 0x00, 0x00, 0x05, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x0C, 0x02, 0x07, 0x02, 0x03, 0x02, + 0x0A, 0x01, 0x0D, 0x04, 0x06, 0x01, 0x09, 0x04, 0x02, 0x01, 0x05, 0x04, + 0x2B, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x10, + 0xFC, 0x30, 0x31, 0x21, 0x35, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, + 0x11, 0x23, 0x11, 0x23, 0x11, 0x02, 0xAF, 0x3E, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, + 0xFD, 0x8F, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x32, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x09, 0x00, 0x02, 0x05, + 0x00, 0x0B, 0x04, 0x02, 0x06, 0x07, 0x02, 0x07, 0x01, 0x0A, 0x05, 0x0A, + 0x03, 0x01, 0x09, 0x04, 0x0A, 0x01, 0x02, 0x04, 0x0A, 0x06, 0x10, 0xD0, + 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, + 0x30, 0x31, 0x11, 0x33, 0x11, 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, 0x15, + 0x23, 0x35, 0x3E, 0x01, 0xF4, 0xFE, 0x89, 0xBB, 0x01, 0xB5, 0xFA, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, + 0x00, 0x0D, 0x00, 0x29, 0x40, 0x19, 0x0B, 0x00, 0x06, 0x03, 0x00, 0x0D, + 0x04, 0x06, 0x06, 0x00, 0x06, 0x09, 0x02, 0x04, 0x02, 0x0C, 0x04, 0x04, + 0x01, 0x05, 0x04, 0x01, 0x01, 0x0B, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x11, + 0x21, 0x35, 0x23, 0x01, 0x33, 0x11, 0x23, 0x03, 0x15, 0x23, 0x35, 0x01, + 0xF4, 0xFE, 0x89, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0xFA, 0xFA, 0x01, 0x77, + 0xFA, 0xFD, 0x8F, 0x02, 0x71, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, + 0x00, 0x23, 0x40, 0x15, 0x07, 0x00, 0x00, 0x03, 0x00, 0x09, 0x04, 0x00, + 0x06, 0x05, 0x02, 0x08, 0x04, 0x04, 0x01, 0x05, 0x04, 0x01, 0x01, 0x07, + 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, + 0x31, 0x31, 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, 0x15, 0x23, 0x35, 0x01, + 0xF4, 0xFE, 0x89, 0x7D, 0x01, 0x77, 0xFA, 0x01, 0x77, 0xFA, 0xFE, 0x89, + 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x0F, 0x00, 0x3E, 0x40, 0x24, 0x0C, 0x00, 0x0E, 0x0A, 0x00, 0x08, + 0x06, 0x00, 0x08, 0x02, 0x00, 0x05, 0x04, 0x00, 0x00, 0x0E, 0x08, 0x06, + 0x0E, 0x02, 0x0E, 0x01, 0x09, 0x01, 0x07, 0x00, 0x05, 0x01, 0x0C, 0x01, + 0x01, 0x04, 0x03, 0x01, 0x00, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, + 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x11, 0x21, 0x15, 0x23, 0x15, 0x33, + 0x15, 0x21, 0x15, 0x21, 0x35, 0x33, 0x11, 0x23, 0x35, 0x21, 0x01, 0x77, + 0xFA, 0xFA, 0xFE, 0x89, 0x01, 0x77, 0x7D, 0x7D, 0xFE, 0x89, 0x01, 0xF4, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x02, 0xEE, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x37, + 0x40, 0x22, 0x0E, 0x00, 0x0A, 0x0C, 0x00, 0x04, 0x08, 0x00, 0x03, 0x04, + 0x04, 0x06, 0x00, 0x06, 0x0A, 0x02, 0x06, 0x02, 0x06, 0x01, 0x0F, 0x04, + 0x03, 0x08, 0x0E, 0x01, 0x08, 0x04, 0x01, 0x0A, 0x0A, 0x01, 0x0B, 0x04, + 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, + 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, 0x15, + 0x21, 0x11, 0x21, 0x15, 0x23, 0x35, 0x23, 0x01, 0x23, 0x11, 0x33, 0x7D, + 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFA, + 0xFA, 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x0C, 0x01, 0x77, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x3E, 0x40, 0x23, 0x0D, 0x00, 0x03, 0x0C, 0x0C, 0x05, + 0x00, 0x00, 0x0B, 0x05, 0x00, 0x0B, 0x04, 0x09, 0x06, 0x01, 0x06, 0x03, + 0x02, 0x0C, 0x07, 0x09, 0x07, 0x04, 0x0B, 0x07, 0x01, 0x0B, 0x04, 0x00, + 0x0E, 0x03, 0x01, 0x0E, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x25, 0x15, 0x33, 0x11, 0x21, 0x15, + 0x33, 0x15, 0x07, 0x33, 0x35, 0x23, 0x37, 0x35, 0x33, 0x15, 0x01, 0x77, + 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, 0x02, + 0x71, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x05, 0x00, 0x13, 0x40, 0x0A, + 0x01, 0x00, 0x03, 0x06, 0x05, 0x02, 0x04, 0x01, 0x01, 0x04, 0x2B, 0x00, + 0x3F, 0x3F, 0xFC, 0x30, 0x31, 0x13, 0x11, 0x23, 0x15, 0x21, 0x11, 0xFA, + 0xFA, 0x01, 0x77, 0x02, 0x71, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x05, 0x00, 0x13, + 0x40, 0x0A, 0x01, 0x00, 0x03, 0x06, 0x05, 0x02, 0x04, 0x01, 0x01, 0x04, + 0x2B, 0x00, 0x3F, 0x3F, 0xFC, 0x30, 0x31, 0x13, 0x11, 0x23, 0x15, 0x21, + 0x11, 0xFA, 0xFA, 0x01, 0x77, 0x02, 0x71, 0xFE, 0x0C, 0x7D, 0x02, 0x71, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, + 0x00, 0x2C, 0x40, 0x1A, 0x06, 0x00, 0x08, 0x0A, 0x00, 0x05, 0x04, 0x00, + 0x00, 0x02, 0x08, 0x06, 0x02, 0x02, 0x07, 0x04, 0x0B, 0x01, 0x04, 0x04, + 0x01, 0x09, 0x09, 0x01, 0x06, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x13, 0x21, + 0x35, 0x21, 0x11, 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, 0x21, 0x7D, 0x01, + 0x77, 0xFE, 0x0C, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0xFE, 0x89, 0x01, + 0xF4, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x01, 0x77, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, + 0x06, 0x00, 0x08, 0x0A, 0x00, 0x05, 0x04, 0x00, 0x00, 0x02, 0x08, 0x06, + 0x02, 0x02, 0x07, 0x04, 0x0B, 0x01, 0x04, 0x04, 0x01, 0x09, 0x09, 0x01, + 0x06, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, + 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x13, 0x21, 0x35, 0x21, 0x11, 0x21, + 0x15, 0x21, 0x15, 0x21, 0x11, 0x21, 0x7D, 0x01, 0x77, 0xFE, 0x0C, 0x01, + 0x77, 0xFE, 0x89, 0x01, 0xF4, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0xFE, 0x89, + 0x7D, 0x7D, 0x01, 0x77, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x03, 0xE8, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x5A, 0x40, 0x33, + 0x10, 0x10, 0x0E, 0x0E, 0x00, 0x0D, 0x04, 0x0E, 0x0E, 0x13, 0x12, 0x00, + 0x13, 0x04, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, 0x04, 0x09, 0x06, 0x12, + 0x0E, 0x11, 0x00, 0x0D, 0x13, 0x0C, 0x02, 0x0B, 0x01, 0x10, 0x08, 0x05, + 0x06, 0x10, 0x06, 0x00, 0x10, 0x01, 0x0E, 0x01, 0x02, 0x02, 0x01, 0x05, + 0x04, 0x02, 0x0F, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0xD0, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x2B, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, + 0x21, 0x15, 0x21, 0x11, 0x25, 0x33, 0x35, 0x23, 0x33, 0x35, 0x23, 0x15, + 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0xFE, 0x89, + 0x7D, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, + 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x5A, + 0x40, 0x33, 0x10, 0x10, 0x0E, 0x0E, 0x00, 0x0D, 0x04, 0x0E, 0x0E, 0x13, + 0x12, 0x00, 0x13, 0x04, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, 0x04, 0x09, + 0x06, 0x12, 0x0E, 0x11, 0x00, 0x0D, 0x13, 0x0C, 0x02, 0x0B, 0x01, 0x10, + 0x08, 0x05, 0x06, 0x10, 0x06, 0x00, 0x10, 0x01, 0x0E, 0x01, 0x02, 0x02, + 0x01, 0x05, 0x04, 0x02, 0x0F, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0xD0, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x2B, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, + 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, + 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, 0x25, 0x33, 0x35, 0x23, 0x33, 0x35, + 0x23, 0x15, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, + 0xFE, 0x89, 0x7D, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, + 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x02, 0xEE, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x39, 0x40, 0x23, 0x0D, 0x00, 0x0A, 0x08, 0x00, 0x04, 0x06, 0x00, + 0x04, 0x03, 0x00, 0x0F, 0x04, 0x0A, 0x06, 0x00, 0x06, 0x04, 0x02, 0x0E, + 0x03, 0x05, 0x0A, 0x0A, 0x01, 0x09, 0x04, 0x03, 0x01, 0x07, 0x04, 0x01, + 0x01, 0x0D, 0x04, 0x2B, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x29, + 0x01, 0x11, 0x23, 0x35, 0x21, 0x15, 0x33, 0x21, 0x11, 0x33, 0x11, 0x05, + 0x15, 0x23, 0x35, 0x01, 0x77, 0x01, 0x77, 0xFA, 0xFE, 0x89, 0xFA, 0xFE, + 0x89, 0x7D, 0x01, 0xF4, 0x7D, 0x01, 0x77, 0xFA, 0x7D, 0xFE, 0x0C, 0x01, + 0xF4, 0xFA, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, + 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x39, 0x40, 0x23, + 0x0D, 0x00, 0x0A, 0x08, 0x00, 0x04, 0x06, 0x00, 0x04, 0x03, 0x00, 0x0F, + 0x04, 0x0A, 0x06, 0x00, 0x06, 0x04, 0x02, 0x0E, 0x03, 0x05, 0x0A, 0x0A, + 0x01, 0x09, 0x04, 0x03, 0x01, 0x07, 0x04, 0x01, 0x01, 0x0D, 0x04, 0x2B, + 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, + 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x29, 0x01, 0x11, 0x23, 0x35, + 0x21, 0x15, 0x33, 0x21, 0x11, 0x33, 0x11, 0x05, 0x15, 0x23, 0x35, 0x01, + 0x77, 0x01, 0x77, 0xFA, 0xFE, 0x89, 0xFA, 0xFE, 0x89, 0x7D, 0x01, 0xF4, + 0x7D, 0x01, 0x77, 0xFA, 0x7D, 0xFE, 0x0C, 0x01, 0xF4, 0xFA, 0x7D, 0x7D, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x10, 0x40, 0x08, 0x02, 0x06, 0x03, 0x02, 0x02, 0x01, 0x01, 0x04, + 0x2B, 0x00, 0x3F, 0x3F, 0x30, 0x31, 0x19, 0x01, 0x33, 0x11, 0x7D, 0x02, + 0x71, 0xFD, 0x8F, 0x02, 0x71, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7D, 0x02, 0x71, 0x00, 0x03, 0x00, 0x10, 0x40, 0x08, 0x02, 0x06, + 0x03, 0x02, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x30, 0x31, + 0x19, 0x01, 0x33, 0x11, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0xEE, 0x00, 0x07, + 0x00, 0x17, 0x40, 0x0D, 0x00, 0x00, 0x03, 0x02, 0x02, 0x06, 0x01, 0x05, + 0x04, 0x00, 0x01, 0x03, 0x04, 0x2B, 0x2B, 0x00, 0x2F, 0x3F, 0xFC, 0x30, + 0x31, 0x01, 0x35, 0x23, 0x15, 0x23, 0x11, 0x33, 0x11, 0x01, 0x77, 0x7D, + 0xFA, 0x7D, 0x01, 0xF4, 0xFA, 0x7D, 0xFD, 0x8F, 0x01, 0xF4, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0xEE, 0x00, 0x07, 0x00, 0x17, + 0x40, 0x0D, 0x00, 0x00, 0x03, 0x02, 0x02, 0x06, 0x01, 0x05, 0x04, 0x00, + 0x01, 0x03, 0x04, 0x2B, 0x2B, 0x00, 0x2F, 0x3F, 0xFC, 0x30, 0x31, 0x01, + 0x35, 0x23, 0x15, 0x23, 0x11, 0x33, 0x11, 0x01, 0x77, 0x7D, 0xFA, 0x7D, + 0x01, 0xF4, 0xFA, 0x7D, 0xFD, 0x8F, 0x01, 0xF4, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x03, 0x6C, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, + 0x00, 0x46, 0x40, 0x2A, 0x13, 0x00, 0x12, 0x04, 0x0F, 0x00, 0x0E, 0x04, + 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, + 0x01, 0x02, 0x0A, 0x12, 0x08, 0x0D, 0x06, 0x12, 0x04, 0x0E, 0x02, 0x11, + 0x12, 0x01, 0x11, 0x04, 0x00, 0x0E, 0x0E, 0x01, 0x0D, 0x04, 0x2B, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x2B, 0x2B, 0x30, 0x31, + 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, + 0x13, 0x15, 0x33, 0x35, 0x25, 0x15, 0x33, 0x35, 0x01, 0xF4, 0xFE, 0x0C, + 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, 0xFA, 0x7D, 0xFE, 0x0C, 0x7D, 0x01, + 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, + 0x01, 0x7D, 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x03, 0x6C, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x46, 0x40, 0x2A, + 0x13, 0x00, 0x12, 0x04, 0x0F, 0x00, 0x0E, 0x04, 0x09, 0x00, 0x08, 0x04, + 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x0A, 0x12, + 0x08, 0x0D, 0x06, 0x12, 0x04, 0x0E, 0x02, 0x11, 0x12, 0x01, 0x11, 0x04, + 0x00, 0x0E, 0x0E, 0x01, 0x0D, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, + 0xFC, 0x10, 0xFC, 0x2B, 0x2B, 0x2B, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, + 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x13, 0x15, 0x33, 0x35, + 0x25, 0x15, 0x33, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, + 0xFA, 0xFA, 0xFA, 0x7D, 0xFE, 0x0C, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, + 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x01, 0x7D, 0x7D, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x3E, 0x40, 0x24, 0x0C, 0x00, 0x0D, 0x09, 0x00, 0x08, + 0x04, 0x05, 0x00, 0x03, 0x01, 0x00, 0x03, 0x00, 0x00, 0x0D, 0x03, 0x06, + 0x0D, 0x02, 0x0E, 0x02, 0x0A, 0x02, 0x06, 0x02, 0x04, 0x0C, 0x0C, 0x01, + 0x09, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x10, + 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x15, 0x21, 0x35, + 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x21, 0x35, 0x21, 0x15, 0x7D, 0x01, + 0x77, 0xFE, 0x89, 0xFA, 0xFA, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0xFE, + 0x89, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3E, + 0x40, 0x24, 0x0C, 0x00, 0x0D, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, + 0x01, 0x00, 0x03, 0x00, 0x00, 0x0D, 0x03, 0x06, 0x0D, 0x02, 0x0E, 0x02, + 0x0A, 0x02, 0x06, 0x02, 0x04, 0x0C, 0x0C, 0x01, 0x09, 0x04, 0x02, 0x01, + 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x10, 0xFC, + 0x30, 0x31, 0x19, 0x01, 0x33, 0x15, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, + 0x23, 0x35, 0x21, 0x35, 0x21, 0x15, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0xFA, + 0xFA, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, + 0x03, 0xE8, 0x00, 0x05, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x40, 0x40, 0x24, + 0x0A, 0x0A, 0x06, 0x06, 0x00, 0x09, 0x04, 0x06, 0x06, 0x0B, 0x0C, 0x00, + 0x0B, 0x04, 0x00, 0x00, 0x01, 0x02, 0x0A, 0x09, 0x07, 0x04, 0x06, 0x0D, + 0x00, 0x0C, 0x01, 0x09, 0x01, 0x04, 0x04, 0x01, 0x03, 0x04, 0x04, 0x08, + 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x33, 0x11, 0x13, 0x23, 0x15, 0x33, + 0x35, 0x33, 0x35, 0x23, 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x01, 0xF4, 0x01, 0x77, 0x7D, + 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x03, 0xE8, + 0x00, 0x05, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x40, 0x40, 0x24, 0x0A, 0x0A, + 0x06, 0x06, 0x00, 0x09, 0x04, 0x06, 0x06, 0x0B, 0x0C, 0x00, 0x0B, 0x04, + 0x00, 0x00, 0x01, 0x02, 0x0A, 0x09, 0x07, 0x04, 0x06, 0x0D, 0x00, 0x0C, + 0x01, 0x09, 0x01, 0x04, 0x04, 0x01, 0x03, 0x04, 0x04, 0x08, 0x10, 0xD0, + 0x2B, 0x10, 0xFC, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, + 0x01, 0x35, 0x21, 0x11, 0x33, 0x11, 0x13, 0x23, 0x15, 0x33, 0x35, 0x33, + 0x35, 0x23, 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x01, 0xF4, 0x01, 0x77, 0x7D, 0x7D, 0x7D, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, 0x02, 0x71, 0x00, 0x0D, + 0x00, 0x11, 0x00, 0x42, 0x40, 0x27, 0x0F, 0x00, 0x0A, 0x07, 0x07, 0x11, + 0x01, 0x01, 0x0C, 0x0C, 0x00, 0x11, 0x04, 0x0A, 0x06, 0x05, 0x06, 0x0D, + 0x02, 0x03, 0x02, 0x0C, 0x10, 0x0A, 0x01, 0x0F, 0x04, 0x02, 0x06, 0x06, + 0x01, 0x05, 0x04, 0x00, 0x09, 0x10, 0x01, 0x09, 0x04, 0x2B, 0x10, 0xD0, + 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x15, + 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, 0x33, 0x15, 0x21, 0x11, 0x23, 0x35, + 0x13, 0x15, 0x23, 0x35, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0xFA, 0x01, 0x77, + 0xFA, 0x7D, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x01, + 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x02, 0xEE, 0x02, 0x71, 0x00, 0x0D, 0x00, 0x11, 0x00, 0x42, 0x40, 0x27, + 0x0F, 0x00, 0x0A, 0x07, 0x07, 0x11, 0x01, 0x01, 0x0C, 0x0C, 0x00, 0x11, + 0x04, 0x0A, 0x06, 0x05, 0x06, 0x0D, 0x02, 0x03, 0x02, 0x0C, 0x10, 0x0A, + 0x01, 0x0F, 0x04, 0x02, 0x06, 0x06, 0x01, 0x05, 0x04, 0x00, 0x09, 0x10, + 0x01, 0x09, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xFC, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, + 0x33, 0x15, 0x21, 0x11, 0x23, 0x35, 0x13, 0x15, 0x23, 0x35, 0x01, 0x77, + 0xFA, 0x7D, 0x7D, 0xFA, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0x02, 0x71, 0xFA, + 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x13, 0x00, 0x17, 0x00, 0x7C, 0x40, 0x46, 0x14, 0x14, + 0x10, 0x10, 0x00, 0x13, 0x04, 0x10, 0x10, 0x15, 0x16, 0x00, 0x15, 0x04, + 0x0E, 0x0E, 0x03, 0x01, 0x01, 0x0A, 0x03, 0x00, 0x0A, 0x04, 0x0B, 0x06, + 0x07, 0x06, 0x0D, 0x02, 0x05, 0x02, 0x15, 0x0D, 0x14, 0x13, 0x01, 0x08, + 0x11, 0x08, 0x10, 0x17, 0x01, 0x0D, 0x0A, 0x0D, 0x0A, 0x16, 0x04, 0x08, + 0x04, 0x12, 0x08, 0x01, 0x07, 0x04, 0x08, 0x12, 0x02, 0x0D, 0x02, 0x16, + 0x00, 0x0C, 0x0C, 0x01, 0x0D, 0x04, 0x0D, 0x16, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, + 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, 0x33, 0x15, + 0x13, 0x23, 0x15, 0x33, 0x03, 0x23, 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, + 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, + 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, + 0xFA, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x17, + 0x00, 0x7C, 0x40, 0x46, 0x14, 0x14, 0x10, 0x10, 0x00, 0x13, 0x04, 0x10, + 0x10, 0x15, 0x16, 0x00, 0x15, 0x04, 0x0E, 0x0E, 0x03, 0x01, 0x01, 0x0A, + 0x03, 0x00, 0x0A, 0x04, 0x0B, 0x06, 0x07, 0x06, 0x0D, 0x02, 0x05, 0x02, + 0x15, 0x0D, 0x14, 0x13, 0x01, 0x08, 0x11, 0x08, 0x10, 0x17, 0x01, 0x0D, + 0x0A, 0x0D, 0x0A, 0x16, 0x04, 0x08, 0x04, 0x12, 0x08, 0x01, 0x07, 0x04, + 0x08, 0x12, 0x02, 0x0D, 0x02, 0x16, 0x00, 0x0C, 0x0C, 0x01, 0x0D, 0x04, + 0x0D, 0x16, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, + 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, + 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, + 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, + 0x23, 0x11, 0x33, 0x35, 0x33, 0x15, 0x13, 0x23, 0x15, 0x33, 0x03, 0x23, + 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0x7D, + 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, + 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x03, 0xE8, 0x00, 0x03, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x5D, 0x40, 0x31, 0x0C, 0x0C, + 0x08, 0x09, 0x00, 0x08, 0x05, 0x05, 0x0E, 0x04, 0x04, 0x0F, 0x04, 0x04, + 0x08, 0x08, 0x0F, 0x0F, 0x00, 0x0E, 0x04, 0x02, 0x06, 0x0E, 0x01, 0x08, + 0x0C, 0x08, 0x0A, 0x06, 0x02, 0x08, 0x02, 0x0D, 0x08, 0x01, 0x06, 0x08, + 0x0D, 0x00, 0x06, 0x00, 0x0B, 0x06, 0x01, 0x05, 0x04, 0x06, 0x0B, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x00, 0x3F, 0x2B, 0x10, + 0xD0, 0x2F, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, + 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x13, 0x11, 0x33, 0x11, 0x27, 0x15, 0x33, + 0x35, 0x33, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0xFA, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0xFA, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x77, 0x03, 0xE8, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x5D, 0x40, 0x31, 0x0C, 0x0C, 0x08, 0x09, 0x00, 0x08, 0x05, 0x05, + 0x0E, 0x04, 0x04, 0x0F, 0x04, 0x04, 0x08, 0x08, 0x0F, 0x0F, 0x00, 0x0E, + 0x04, 0x02, 0x06, 0x0E, 0x01, 0x08, 0x0C, 0x08, 0x0A, 0x06, 0x02, 0x08, + 0x02, 0x0D, 0x08, 0x01, 0x06, 0x08, 0x0D, 0x00, 0x06, 0x00, 0x0B, 0x06, + 0x01, 0x05, 0x04, 0x06, 0x0B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xFC, 0x00, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x13, + 0x11, 0x33, 0x11, 0x27, 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, 0x15, 0x33, + 0x15, 0x33, 0x35, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, + 0x71, 0xFD, 0x8F, 0x02, 0x71, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0D, + 0x00, 0x2F, 0x40, 0x1C, 0x08, 0x00, 0x06, 0x04, 0x00, 0x06, 0x02, 0x00, + 0x0D, 0x04, 0x0B, 0x06, 0x00, 0x06, 0x06, 0x02, 0x05, 0x0D, 0x03, 0x0B, + 0x0B, 0x01, 0x0A, 0x04, 0x02, 0x01, 0x0D, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x30, + 0x31, 0x21, 0x33, 0x11, 0x23, 0x35, 0x33, 0x35, 0x21, 0x15, 0x33, 0x11, + 0x33, 0x35, 0x33, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, + 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0xFE, 0x0C, 0xFA, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0D, 0x00, 0x2F, + 0x40, 0x1C, 0x08, 0x00, 0x06, 0x04, 0x00, 0x06, 0x02, 0x00, 0x0D, 0x04, + 0x0B, 0x06, 0x00, 0x06, 0x06, 0x02, 0x05, 0x0D, 0x03, 0x0B, 0x0B, 0x01, + 0x0A, 0x04, 0x02, 0x01, 0x0D, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, + 0x33, 0x11, 0x23, 0x35, 0x33, 0x35, 0x21, 0x15, 0x33, 0x11, 0x33, 0x35, + 0x33, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x01, + 0x77, 0x7D, 0x7D, 0x7D, 0xFE, 0x0C, 0xFA, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0F, 0x00, 0x39, 0x40, 0x21, + 0x0A, 0x00, 0x08, 0x06, 0x00, 0x08, 0x02, 0x02, 0x0F, 0x04, 0x00, 0x0F, + 0x04, 0x0D, 0x06, 0x00, 0x06, 0x08, 0x02, 0x07, 0x0F, 0x05, 0x0D, 0x0D, + 0x01, 0x0C, 0x04, 0x04, 0x0F, 0x02, 0x01, 0x0F, 0x04, 0x2B, 0x10, 0xD0, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x33, 0x35, 0x23, 0x35, + 0x23, 0x35, 0x33, 0x35, 0x21, 0x15, 0x33, 0x11, 0x33, 0x35, 0x33, 0x01, + 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, + 0x7D, 0x7D, 0x7D, 0xFE, 0x0C, 0xFA, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0F, 0x00, 0x39, 0x40, 0x21, 0x0A, 0x00, + 0x08, 0x06, 0x00, 0x08, 0x02, 0x02, 0x0F, 0x04, 0x00, 0x0F, 0x04, 0x0D, + 0x06, 0x00, 0x06, 0x08, 0x02, 0x07, 0x0F, 0x05, 0x0D, 0x0D, 0x01, 0x0C, + 0x04, 0x04, 0x0F, 0x02, 0x01, 0x0F, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x33, 0x35, 0x23, 0x35, 0x23, 0x35, + 0x33, 0x35, 0x21, 0x15, 0x33, 0x11, 0x33, 0x35, 0x33, 0x01, 0x77, 0x7D, + 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, + 0x7D, 0xFE, 0x0C, 0xFA, 0x00, 0x01, 0x00, 0x00, 0xFF, 0x83, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x18, 0x00, 0x00, 0x08, 0x07, + 0x08, 0x08, 0x06, 0x04, 0x06, 0x0A, 0x01, 0x07, 0x01, 0x01, 0x04, 0x04, + 0x00, 0x07, 0x07, 0x01, 0x06, 0x04, 0x07, 0x0B, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x2B, 0x10, 0xFC, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x30, 0x31, + 0x25, 0x23, 0x11, 0x23, 0x11, 0x33, 0x15, 0x33, 0x35, 0x33, 0x11, 0x23, + 0x01, 0x77, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0xFD, + 0x8F, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x00, 0x01, 0x00, 0x00, 0xFF, 0x83, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x18, 0x00, 0x00, + 0x08, 0x07, 0x08, 0x08, 0x06, 0x04, 0x06, 0x0A, 0x01, 0x07, 0x01, 0x01, + 0x04, 0x04, 0x00, 0x07, 0x07, 0x01, 0x06, 0x04, 0x07, 0x0B, 0x10, 0xD0, + 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, + 0x30, 0x31, 0x25, 0x23, 0x11, 0x23, 0x11, 0x33, 0x15, 0x33, 0x35, 0x33, + 0x11, 0x23, 0x01, 0x77, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, + 0xF4, 0xFD, 0x8F, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x3C, 0x40, 0x22, 0x0D, 0x00, 0x01, 0x08, 0x00, 0x00, 0x05, 0x05, + 0x0A, 0x03, 0x03, 0x0F, 0x0A, 0x00, 0x0F, 0x04, 0x01, 0x06, 0x00, 0x02, + 0x0A, 0x0E, 0x08, 0x0D, 0x06, 0x02, 0x02, 0x01, 0x0D, 0x04, 0x0E, 0x01, + 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x19, 0x01, 0x21, 0x35, 0x23, 0x35, 0x33, 0x35, 0x07, 0x15, + 0x23, 0x35, 0x17, 0x15, 0x23, 0x35, 0x01, 0xF4, 0x7D, 0x7D, 0x82, 0xF5, + 0xF5, 0xF5, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, + 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, + 0x02, 0x71, 0x00, 0x13, 0x00, 0x17, 0x00, 0x1B, 0x00, 0x7C, 0x40, 0x44, + 0x1A, 0x1A, 0x10, 0x12, 0x12, 0x17, 0x0C, 0x0C, 0x10, 0x08, 0x08, 0x10, + 0x06, 0x06, 0x17, 0x02, 0x02, 0x17, 0x10, 0x00, 0x17, 0x04, 0x15, 0x06, + 0x04, 0x06, 0x00, 0x06, 0x19, 0x02, 0x0E, 0x02, 0x0A, 0x02, 0x15, 0x12, + 0x0F, 0x17, 0x0D, 0x12, 0x12, 0x01, 0x17, 0x04, 0x0B, 0x13, 0x01, 0x0A, + 0x09, 0x02, 0x07, 0x19, 0x07, 0x1A, 0x05, 0x1B, 0x01, 0x19, 0x03, 0x19, + 0x03, 0x1A, 0x01, 0x0A, 0x19, 0x01, 0x0A, 0x04, 0x2B, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x3B, 0x01, 0x35, 0x33, 0x15, 0x33, 0x35, 0x23, 0x35, 0x23, + 0x35, 0x23, 0x15, 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x07, 0x33, + 0x35, 0x23, 0x01, 0x23, 0x15, 0x33, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0x7D, + 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0x01, + 0x77, 0xFA, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0E, 0x0E, + 0x04, 0x02, 0x02, 0x0A, 0x04, 0x00, 0x0A, 0x04, 0x0B, 0x06, 0x00, 0x06, + 0x0D, 0x02, 0x06, 0x02, 0x0A, 0x0E, 0x08, 0x0F, 0x03, 0x0E, 0x0F, 0x01, + 0x0E, 0x04, 0x01, 0x06, 0x06, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, + 0x35, 0x23, 0x35, 0x23, 0x01, 0x35, 0x23, 0x15, 0x13, 0x23, 0x15, 0x33, + 0x7D, 0xFA, 0xFA, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, + 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x26, + 0x40, 0x16, 0x06, 0x00, 0x02, 0x04, 0x00, 0x02, 0x08, 0x06, 0x00, 0x06, + 0x02, 0x02, 0x03, 0x08, 0x08, 0x01, 0x07, 0x04, 0x02, 0x01, 0x05, 0x04, + 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x21, 0x33, 0x11, 0x21, 0x15, 0x33, 0x21, 0x11, 0x33, 0x11, + 0x01, 0x77, 0x7D, 0xFE, 0x89, 0xFA, 0xFE, 0x89, 0x7D, 0x02, 0x71, 0x7D, + 0xFE, 0x0C, 0x01, 0xF4, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, + 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, + 0x00, 0x64, 0x40, 0x39, 0x0E, 0x0E, 0x11, 0x0C, 0x00, 0x04, 0x0C, 0x0C, + 0x12, 0x09, 0x09, 0x11, 0x00, 0x12, 0x00, 0x04, 0x0B, 0x06, 0x06, 0x06, + 0x01, 0x06, 0x04, 0x02, 0x00, 0x02, 0x10, 0x07, 0x0C, 0x00, 0x0A, 0x12, + 0x08, 0x0D, 0x08, 0x0E, 0x04, 0x13, 0x03, 0x01, 0x00, 0x04, 0x00, 0x0F, + 0x01, 0x0D, 0x0D, 0x01, 0x12, 0x04, 0x12, 0x01, 0x07, 0x07, 0x01, 0x06, + 0x04, 0x2B, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0xFC, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x11, 0x33, 0x11, 0x21, 0x23, + 0x11, 0x3B, 0x01, 0x11, 0x23, 0x11, 0x13, 0x23, 0x15, 0x33, 0x21, 0x33, + 0x35, 0x23, 0x01, 0xF4, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, + 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, + 0xFD, 0x8F, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, + 0x40, 0x18, 0x01, 0x00, 0x08, 0x04, 0x0A, 0x06, 0x05, 0x06, 0x0B, 0x02, + 0x03, 0x02, 0x02, 0x06, 0x06, 0x01, 0x05, 0x04, 0x00, 0x09, 0x0A, 0x01, + 0x09, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, + 0x3F, 0x2B, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, + 0x33, 0x15, 0x33, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x02, + 0x71, 0xFA, 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, + 0x00, 0x1D, 0x40, 0x11, 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, + 0x02, 0x05, 0x01, 0x02, 0x04, 0x00, 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x00, + 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, + 0x23, 0x11, 0x33, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, + 0x02, 0x71, 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, + 0x03, 0x00, 0x00, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x06, 0x01, 0x05, + 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x10, + 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, 0x7D, + 0xFA, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x01, 0xF4, 0xFE, 0x0C, 0x02, 0x71, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x1A, 0x40, 0x0E, 0x06, 0x00, 0x00, 0x02, 0x00, 0x00, 0x05, 0x06, + 0x00, 0x02, 0x05, 0x01, 0x04, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, + 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, 0x15, 0x33, 0x11, 0x33, 0x11, 0x33, + 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, + 0x01, 0xF4, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, + 0x04, 0x09, 0x06, 0x0B, 0x02, 0x03, 0x02, 0x08, 0x05, 0x02, 0x01, 0x05, + 0x04, 0x00, 0x07, 0x0A, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x15, + 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, 0x01, 0x77, + 0xFA, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0x02, 0x71, 0xFA, 0xFA, + 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x66, + 0x40, 0x39, 0x10, 0x10, 0x0C, 0x0E, 0x0E, 0x12, 0x06, 0x06, 0x0B, 0x00, + 0x0C, 0x0C, 0x13, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, 0x02, 0x04, + 0x00, 0x12, 0x12, 0x00, 0x13, 0x04, 0x09, 0x06, 0x02, 0x02, 0x09, 0x0E, + 0x09, 0x0D, 0x07, 0x13, 0x10, 0x01, 0x06, 0x04, 0x03, 0x13, 0x01, 0x0E, + 0x01, 0x0E, 0x01, 0x0D, 0x00, 0x01, 0x0F, 0x0F, 0x01, 0x0E, 0x04, 0x2B, + 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, + 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0xFC, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x23, 0x35, 0x23, 0x15, 0x23, + 0x11, 0x33, 0x15, 0x33, 0x35, 0x33, 0x27, 0x23, 0x35, 0x33, 0x05, 0x35, + 0x33, 0x15, 0x02, 0x71, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, + 0x7D, 0xFE, 0x89, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x50, + 0x40, 0x2C, 0x10, 0x10, 0x04, 0x09, 0x09, 0x0F, 0x07, 0x07, 0x04, 0x01, + 0x01, 0x0F, 0x04, 0x00, 0x0F, 0x04, 0x0E, 0x06, 0x00, 0x06, 0x12, 0x02, + 0x05, 0x02, 0x0A, 0x13, 0x08, 0x0E, 0x06, 0x0D, 0x04, 0x0E, 0x0E, 0x01, + 0x0D, 0x04, 0x02, 0x13, 0x00, 0x10, 0x10, 0x01, 0x13, 0x04, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x21, 0x35, 0x23, 0x35, + 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x15, 0x25, 0x15, 0x33, 0x35, + 0x25, 0x35, 0x23, 0x15, 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFE, + 0x89, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, + 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x02, 0xAF, 0x02, 0x71, 0x00, 0x0D, 0x00, 0x2D, 0x40, 0x1C, 0x09, 0x00, + 0x00, 0x05, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x0C, 0x02, 0x07, 0x02, + 0x03, 0x02, 0x0A, 0x01, 0x0D, 0x04, 0x06, 0x01, 0x09, 0x04, 0x02, 0x01, + 0x05, 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, + 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x35, 0x23, 0x11, 0x23, 0x11, 0x23, + 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x02, 0xAF, 0x3E, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, + 0x01, 0xF4, 0xFD, 0x8F, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x32, + 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x09, 0x00, + 0x02, 0x05, 0x00, 0x0B, 0x04, 0x02, 0x06, 0x07, 0x02, 0x07, 0x01, 0x0A, + 0x05, 0x0A, 0x03, 0x01, 0x09, 0x04, 0x0A, 0x01, 0x02, 0x04, 0x0A, 0x06, + 0x10, 0xD0, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xFC, 0x00, 0x3F, 0x3F, 0x2B, + 0x10, 0xFC, 0x30, 0x31, 0x11, 0x33, 0x11, 0x21, 0x11, 0x21, 0x35, 0x23, + 0x01, 0x15, 0x23, 0x35, 0x3E, 0x01, 0xF4, 0xFE, 0x89, 0xBB, 0x01, 0xB5, + 0xFA, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, 0x02, 0x71, 0x00, 0x05, + 0x00, 0x09, 0x00, 0x0D, 0x00, 0x29, 0x40, 0x19, 0x0B, 0x00, 0x06, 0x03, + 0x00, 0x0D, 0x04, 0x06, 0x06, 0x00, 0x06, 0x09, 0x02, 0x04, 0x02, 0x0C, + 0x04, 0x04, 0x01, 0x05, 0x04, 0x01, 0x01, 0x0B, 0x04, 0x2B, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x31, + 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, 0x33, 0x11, 0x23, 0x03, 0x15, 0x23, + 0x35, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0xFA, 0xFA, + 0x01, 0x77, 0xFA, 0xFD, 0x8F, 0x02, 0x71, 0xFE, 0x89, 0x7D, 0x7D, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x13, + 0x00, 0x17, 0x00, 0x1B, 0x00, 0x7C, 0x40, 0x44, 0x1A, 0x1A, 0x10, 0x12, + 0x12, 0x17, 0x0C, 0x0C, 0x10, 0x08, 0x08, 0x10, 0x06, 0x06, 0x17, 0x02, + 0x02, 0x17, 0x10, 0x00, 0x17, 0x04, 0x15, 0x06, 0x04, 0x06, 0x00, 0x06, + 0x19, 0x02, 0x0E, 0x02, 0x0A, 0x02, 0x15, 0x12, 0x0F, 0x17, 0x0D, 0x12, + 0x12, 0x01, 0x17, 0x04, 0x0B, 0x13, 0x01, 0x0A, 0x09, 0x02, 0x07, 0x19, + 0x07, 0x1A, 0x05, 0x1B, 0x01, 0x19, 0x03, 0x19, 0x03, 0x1A, 0x01, 0x0A, + 0x19, 0x01, 0x0A, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x3B, 0x01, + 0x35, 0x33, 0x15, 0x33, 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, 0x23, + 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x07, 0x33, 0x35, 0x23, 0x01, 0x23, + 0x15, 0x33, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0xFA, 0x7D, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, 0x7D, + 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x21, + 0x40, 0x14, 0x01, 0x00, 0x06, 0x04, 0x08, 0x06, 0x09, 0x02, 0x03, 0x02, + 0x02, 0x01, 0x05, 0x04, 0x00, 0x07, 0x08, 0x01, 0x07, 0x04, 0x2B, 0x10, + 0xD0, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x30, 0x31, 0x01, 0x15, 0x23, + 0x35, 0x23, 0x11, 0x21, 0x15, 0x33, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x01, + 0x77, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, 0xFA, 0x02, 0x71, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, + 0x00, 0x28, 0x40, 0x19, 0x07, 0x00, 0x00, 0x03, 0x00, 0x00, 0x06, 0x0A, + 0x02, 0x05, 0x02, 0x01, 0x02, 0x08, 0x01, 0x0B, 0x04, 0x04, 0x01, 0x07, + 0x04, 0x00, 0x01, 0x03, 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, + 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x11, 0x23, 0x11, 0x23, 0x11, + 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, + 0x8F, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3E, 0x40, 0x23, 0x0D, 0x00, + 0x03, 0x0C, 0x0C, 0x05, 0x00, 0x00, 0x0B, 0x05, 0x00, 0x0B, 0x04, 0x09, + 0x06, 0x01, 0x06, 0x03, 0x02, 0x0C, 0x07, 0x09, 0x07, 0x04, 0x0B, 0x07, + 0x01, 0x0B, 0x04, 0x00, 0x0E, 0x03, 0x01, 0x0E, 0x04, 0x2B, 0x10, 0xD0, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x25, 0x15, + 0x33, 0x11, 0x21, 0x15, 0x33, 0x15, 0x07, 0x33, 0x35, 0x23, 0x37, 0x35, + 0x33, 0x15, 0x01, 0x77, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0xFA, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x7D, 0xFA, 0xFA, 0x7D, 0x7D, 0x7D, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, + 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x09, 0x02, 0x04, 0x0B, 0x07, + 0x01, 0x0B, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, + 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x07, 0x23, 0x35, 0x33, 0x7D, 0xFA, + 0x7D, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, + 0xFA, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0D, 0x00, + 0x01, 0x08, 0x00, 0x00, 0x05, 0x05, 0x0A, 0x03, 0x03, 0x0F, 0x0A, 0x00, + 0x0F, 0x04, 0x01, 0x06, 0x00, 0x02, 0x0A, 0x0E, 0x08, 0x0D, 0x06, 0x02, + 0x02, 0x01, 0x0D, 0x04, 0x0E, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x21, 0x35, + 0x23, 0x35, 0x33, 0x35, 0x07, 0x15, 0x23, 0x35, 0x17, 0x15, 0x23, 0x35, + 0x01, 0xF4, 0x7D, 0x7D, 0x82, 0xF5, 0xF5, 0xF5, 0x02, 0x71, 0xFD, 0x8F, + 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x05, 0x00, 0x10, + 0x40, 0x08, 0x00, 0x00, 0x01, 0x02, 0x04, 0x01, 0x03, 0x04, 0x2B, 0x00, + 0x3F, 0xFC, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x33, 0x11, 0x01, 0x77, + 0xFE, 0x89, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x01, 0xF4, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x23, + 0x40, 0x14, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, + 0x03, 0x06, 0x01, 0x02, 0x0A, 0x06, 0x06, 0x01, 0x03, 0x04, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x30, 0x31, 0x01, + 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, 0x01, 0xF4, 0x7D, + 0xFD, 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x71, 0x02, 0x71, 0x00, 0x13, 0x00, 0x17, 0x00, 0x1B, 0x00, 0x7C, + 0x40, 0x44, 0x1A, 0x1A, 0x10, 0x12, 0x12, 0x17, 0x0C, 0x0C, 0x10, 0x08, + 0x08, 0x10, 0x06, 0x06, 0x17, 0x02, 0x02, 0x17, 0x10, 0x00, 0x17, 0x04, + 0x15, 0x06, 0x04, 0x06, 0x00, 0x06, 0x19, 0x02, 0x0E, 0x02, 0x0A, 0x02, + 0x15, 0x12, 0x0F, 0x17, 0x0D, 0x12, 0x12, 0x01, 0x17, 0x04, 0x0B, 0x13, + 0x01, 0x0A, 0x09, 0x02, 0x07, 0x19, 0x07, 0x1A, 0x05, 0x1B, 0x01, 0x19, + 0x03, 0x19, 0x03, 0x1A, 0x01, 0x0A, 0x19, 0x01, 0x0A, 0x04, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x3B, 0x01, 0x35, 0x33, 0x15, 0x33, 0x35, 0x23, + 0x35, 0x23, 0x35, 0x23, 0x15, 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, + 0x07, 0x33, 0x35, 0x23, 0x01, 0x23, 0x15, 0x33, 0xFA, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x02, 0x71, + 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, + 0xFA, 0x01, 0x77, 0xFA, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x06, 0x00, 0x08, 0x02, + 0x00, 0x05, 0x04, 0x00, 0x00, 0x0A, 0x08, 0x06, 0x0A, 0x02, 0x07, 0x00, + 0x01, 0x06, 0x09, 0x01, 0x06, 0x04, 0x03, 0x01, 0x00, 0x04, 0x2B, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, + 0x30, 0x31, 0x11, 0x21, 0x15, 0x23, 0x15, 0x33, 0x15, 0x21, 0x15, 0x21, + 0x11, 0x21, 0x01, 0x77, 0xFA, 0xFA, 0xFE, 0x89, 0x01, 0xF4, 0xFE, 0x0C, + 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x24, 0x40, 0x15, + 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, 0x06, 0x09, 0x02, 0x03, 0x02, 0x07, + 0x02, 0x02, 0x01, 0x05, 0x04, 0x08, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x11, + 0x23, 0x11, 0x23, 0x11, 0x33, 0x15, 0x21, 0x11, 0x01, 0x77, 0xFA, 0x7D, + 0x7D, 0x01, 0x77, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, + 0x02, 0x71, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0x6B, + 0x00, 0x09, 0x00, 0x0D, 0x00, 0x31, 0x40, 0x1D, 0x0C, 0x00, 0x0B, 0x04, + 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, 0x06, 0x09, 0x02, 0x03, 0x02, 0x0B, + 0x00, 0x0A, 0x02, 0x07, 0x02, 0x02, 0x01, 0x05, 0x04, 0x09, 0x01, 0x00, + 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x30, 0x31, 0x01, 0x11, 0x23, 0x11, 0x23, + 0x11, 0x33, 0x15, 0x21, 0x11, 0x25, 0x33, 0x35, 0x23, 0x01, 0x77, 0xFA, + 0x7D, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0xFA, 0xFA, 0x02, 0x71, 0xFE, 0x0C, + 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0E, 0x0E, 0x04, 0x02, 0x02, 0x0A, + 0x04, 0x00, 0x0A, 0x04, 0x0B, 0x06, 0x00, 0x06, 0x0D, 0x02, 0x06, 0x02, + 0x0A, 0x0E, 0x08, 0x0F, 0x03, 0x0E, 0x0F, 0x01, 0x0E, 0x04, 0x01, 0x06, + 0x06, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, 0x35, 0x23, 0x35, 0x23, + 0x01, 0x35, 0x23, 0x15, 0x13, 0x23, 0x15, 0x33, 0x7D, 0xFA, 0xFA, 0x7D, + 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0xFD, 0x8F, 0xFA, + 0xFA, 0x02, 0x71, 0xFA, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x26, 0x40, 0x16, 0x06, 0x00, + 0x02, 0x04, 0x00, 0x02, 0x08, 0x06, 0x00, 0x06, 0x02, 0x02, 0x03, 0x08, + 0x08, 0x01, 0x07, 0x04, 0x02, 0x01, 0x05, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x33, + 0x11, 0x21, 0x15, 0x33, 0x21, 0x11, 0x33, 0x11, 0x01, 0x77, 0x7D, 0xFE, + 0x89, 0xFA, 0xFE, 0x89, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, 0x01, 0xF4, + 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x64, 0x40, 0x39, + 0x0E, 0x0E, 0x11, 0x0C, 0x00, 0x04, 0x0C, 0x0C, 0x12, 0x09, 0x09, 0x11, + 0x00, 0x12, 0x00, 0x04, 0x0B, 0x06, 0x06, 0x06, 0x01, 0x06, 0x04, 0x02, + 0x00, 0x02, 0x10, 0x07, 0x0C, 0x00, 0x0A, 0x12, 0x08, 0x0D, 0x08, 0x0E, + 0x04, 0x13, 0x03, 0x01, 0x00, 0x04, 0x00, 0x0F, 0x01, 0x0D, 0x0D, 0x01, + 0x12, 0x04, 0x12, 0x01, 0x07, 0x07, 0x01, 0x06, 0x04, 0x2B, 0x10, 0xFC, + 0x2B, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x10, + 0xFC, 0xFC, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x01, 0x11, 0x33, 0x11, 0x21, 0x23, 0x11, 0x3B, 0x01, 0x11, + 0x23, 0x11, 0x13, 0x23, 0x15, 0x33, 0x21, 0x33, 0x35, 0x23, 0x01, 0xF4, + 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0xFE, 0x89, + 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0xFD, 0x8F, 0x01, 0x77, + 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, 0x40, 0x18, 0x01, 0x00, + 0x08, 0x04, 0x0A, 0x06, 0x05, 0x06, 0x0B, 0x02, 0x03, 0x02, 0x02, 0x06, + 0x06, 0x01, 0x05, 0x04, 0x00, 0x09, 0x0A, 0x01, 0x09, 0x04, 0x2B, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x30, 0x31, + 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, + 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFD, + 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, + 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, 0x02, 0x05, 0x01, 0x02, + 0x04, 0x00, 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0xFC, 0x10, + 0xFC, 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, 0x33, 0x01, + 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, + 0x7D, 0x01, 0x77, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, 0x03, 0x00, 0x00, 0x06, + 0x06, 0x01, 0x06, 0x00, 0x02, 0x06, 0x01, 0x05, 0x04, 0x02, 0x01, 0x01, + 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x30, 0x31, 0x19, + 0x01, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, 0x7D, 0xFA, 0x7D, 0x02, 0x71, + 0xFD, 0x8F, 0x01, 0xF4, 0xFE, 0x0C, 0x02, 0x71, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x23, + 0x40, 0x15, 0x08, 0x00, 0x00, 0x06, 0x00, 0x04, 0x04, 0x02, 0x06, 0x00, + 0x02, 0x07, 0x02, 0x05, 0x01, 0x09, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, + 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x19, + 0x01, 0x33, 0x35, 0x21, 0x11, 0x07, 0x23, 0x35, 0x33, 0x7D, 0x01, 0x77, + 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0x01, 0x77, 0xFA, 0x7D, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x1A, 0x40, 0x0E, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, + 0x01, 0x02, 0x06, 0x01, 0x03, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, + 0x10, 0xFC, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x11, + 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0xFD, + 0x8F, 0x7D, 0x01, 0x77, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, + 0x02, 0x71, 0x00, 0x07, 0x00, 0x1A, 0x40, 0x0E, 0x06, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x05, 0x06, 0x00, 0x02, 0x05, 0x01, 0x04, 0x04, 0x2B, 0x00, + 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, 0x15, 0x33, + 0x11, 0x33, 0x11, 0x33, 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x02, + 0x71, 0x7D, 0xFE, 0x0C, 0x01, 0xF4, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, 0x07, 0x00, + 0x09, 0x01, 0x00, 0x06, 0x04, 0x09, 0x06, 0x0B, 0x02, 0x03, 0x02, 0x08, + 0x05, 0x02, 0x01, 0x05, 0x04, 0x00, 0x07, 0x0A, 0x01, 0x07, 0x04, 0x2B, + 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, + 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, 0x21, 0x15, + 0x21, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, + 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x13, 0x00, 0x66, 0x40, 0x39, 0x10, 0x10, 0x0C, 0x0E, 0x0E, 0x12, + 0x06, 0x06, 0x0B, 0x00, 0x0C, 0x0C, 0x13, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x04, 0x00, 0x02, 0x04, 0x00, 0x12, 0x12, 0x00, 0x13, 0x04, 0x09, 0x06, + 0x02, 0x02, 0x09, 0x0E, 0x09, 0x0D, 0x07, 0x13, 0x10, 0x01, 0x06, 0x04, + 0x03, 0x13, 0x01, 0x0E, 0x01, 0x0E, 0x01, 0x0D, 0x00, 0x01, 0x0F, 0x0F, + 0x01, 0x0E, 0x04, 0x2B, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, + 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, + 0x10, 0xFC, 0x10, 0xFC, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0xFC, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x23, + 0x35, 0x23, 0x15, 0x23, 0x11, 0x33, 0x15, 0x33, 0x35, 0x33, 0x27, 0x23, + 0x35, 0x33, 0x05, 0x35, 0x33, 0x15, 0x02, 0x71, 0xFA, 0x7D, 0xFA, 0xFA, + 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, + 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, + 0x00, 0x13, 0x00, 0x50, 0x40, 0x2C, 0x10, 0x10, 0x04, 0x09, 0x09, 0x0F, + 0x07, 0x07, 0x04, 0x01, 0x01, 0x0F, 0x04, 0x00, 0x0F, 0x04, 0x0E, 0x06, + 0x00, 0x06, 0x12, 0x02, 0x05, 0x02, 0x0A, 0x13, 0x08, 0x0E, 0x06, 0x0D, + 0x04, 0x0E, 0x0E, 0x01, 0x0D, 0x04, 0x02, 0x13, 0x00, 0x10, 0x10, 0x01, + 0x13, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, + 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x15, + 0x25, 0x15, 0x33, 0x35, 0x25, 0x35, 0x23, 0x15, 0x01, 0xF4, 0x7D, 0xFA, + 0x7D, 0x7D, 0xFA, 0xFE, 0x89, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0xFA, + 0xFA, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x32, 0x02, 0x71, 0x00, 0x09, 0x00, 0x20, + 0x40, 0x13, 0x06, 0x00, 0x00, 0x02, 0x00, 0x00, 0x06, 0x09, 0x02, 0x04, + 0x02, 0x08, 0x01, 0x09, 0x04, 0x03, 0x01, 0x06, 0x04, 0x2B, 0x2B, 0x00, + 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x35, 0x23, + 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x02, 0x32, 0x3E, 0x7D, 0xFA, 0x7D, + 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x21, 0x40, 0x14, + 0x01, 0x00, 0x06, 0x04, 0x08, 0x06, 0x09, 0x02, 0x03, 0x02, 0x02, 0x01, + 0x05, 0x04, 0x00, 0x07, 0x08, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, + 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, + 0x11, 0x21, 0x15, 0x33, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0x7D, + 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, 0xFA, 0x02, 0x71, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, + 0x40, 0x19, 0x07, 0x00, 0x00, 0x03, 0x00, 0x00, 0x06, 0x0A, 0x02, 0x05, + 0x02, 0x01, 0x02, 0x08, 0x01, 0x0B, 0x04, 0x04, 0x01, 0x07, 0x04, 0x00, + 0x01, 0x03, 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0xFC, + 0x10, 0xFC, 0x30, 0x31, 0x21, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, + 0x23, 0x11, 0x23, 0x11, 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, + 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0xAF, 0x02, 0x71, 0x00, 0x0D, + 0x00, 0x2D, 0x40, 0x1C, 0x09, 0x00, 0x00, 0x05, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x06, 0x0C, 0x02, 0x07, 0x02, 0x03, 0x02, 0x0A, 0x01, 0x0D, 0x04, + 0x06, 0x01, 0x09, 0x04, 0x02, 0x01, 0x05, 0x04, 0x2B, 0x2B, 0x2B, 0x00, + 0x3F, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, + 0x35, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, + 0x11, 0x02, 0xAF, 0x3E, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xF4, + 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x32, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x2C, 0x40, 0x1A, 0x09, 0x00, 0x02, 0x05, 0x00, 0x0B, 0x04, 0x02, + 0x06, 0x07, 0x02, 0x07, 0x01, 0x0A, 0x05, 0x0A, 0x03, 0x01, 0x09, 0x04, + 0x0A, 0x01, 0x02, 0x04, 0x0A, 0x06, 0x10, 0xD0, 0x2B, 0x2B, 0x10, 0xD0, + 0x10, 0xFC, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x11, 0x33, + 0x11, 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, 0x15, 0x23, 0x35, 0x3E, 0x01, + 0xF4, 0xFE, 0x89, 0xBB, 0x01, 0xB5, 0xFA, 0x01, 0xF4, 0xFE, 0x0C, 0x01, + 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x02, 0xEE, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x29, + 0x40, 0x19, 0x0B, 0x00, 0x06, 0x03, 0x00, 0x0D, 0x04, 0x06, 0x06, 0x00, + 0x06, 0x09, 0x02, 0x04, 0x02, 0x0C, 0x04, 0x04, 0x01, 0x05, 0x04, 0x01, + 0x01, 0x0B, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, + 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, + 0x33, 0x11, 0x23, 0x03, 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x89, 0x7D, + 0x02, 0x71, 0x7D, 0x7D, 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0xFD, 0x8F, 0x02, + 0x71, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x23, 0x40, 0x15, + 0x07, 0x00, 0x00, 0x03, 0x00, 0x09, 0x04, 0x00, 0x06, 0x05, 0x02, 0x08, + 0x04, 0x04, 0x01, 0x05, 0x04, 0x01, 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x11, + 0x21, 0x35, 0x23, 0x01, 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x89, 0x7D, + 0x01, 0x77, 0xFA, 0x01, 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0F, 0x00, 0x3E, + 0x40, 0x24, 0x0C, 0x00, 0x0E, 0x0A, 0x00, 0x08, 0x06, 0x00, 0x08, 0x02, + 0x00, 0x05, 0x04, 0x00, 0x00, 0x0E, 0x08, 0x06, 0x0E, 0x02, 0x0E, 0x01, + 0x09, 0x01, 0x07, 0x00, 0x05, 0x01, 0x0C, 0x01, 0x01, 0x04, 0x03, 0x01, + 0x00, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x11, 0x21, 0x15, 0x23, 0x15, 0x33, 0x15, 0x21, 0x15, 0x21, + 0x35, 0x33, 0x11, 0x23, 0x35, 0x21, 0x01, 0x77, 0xFA, 0xFA, 0xFE, 0x89, + 0x01, 0x77, 0x7D, 0x7D, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x01, 0x77, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x37, 0x40, 0x22, 0x0E, 0x00, + 0x0A, 0x0C, 0x00, 0x04, 0x08, 0x00, 0x03, 0x04, 0x04, 0x06, 0x00, 0x06, + 0x0A, 0x02, 0x06, 0x02, 0x06, 0x01, 0x0F, 0x04, 0x03, 0x08, 0x0E, 0x01, + 0x08, 0x04, 0x01, 0x0A, 0x0A, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, + 0xFC, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, 0x15, 0x21, 0x11, 0x21, 0x15, + 0x23, 0x35, 0x23, 0x01, 0x23, 0x11, 0x33, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, + 0x0C, 0x7D, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFA, 0xFA, 0x02, 0x71, 0xFA, + 0xFA, 0xFE, 0x0C, 0x01, 0x77, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, + 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x04, 0x06, 0x06, 0x01, 0x06, 0x00, + 0x02, 0x09, 0x02, 0x04, 0x0B, 0x07, 0x01, 0x0B, 0x04, 0x02, 0x01, 0x01, + 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, + 0x07, 0x23, 0x35, 0x33, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFA, 0x02, 0x71, + 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x7D, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x32, + 0x40, 0x1D, 0x0B, 0x00, 0x03, 0x05, 0x05, 0x0D, 0x08, 0x00, 0x0D, 0x04, + 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x08, 0x0C, 0x0C, 0x01, 0x03, + 0x04, 0x00, 0x04, 0x04, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, + 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, + 0x17, 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, + 0xF5, 0xF5, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, + 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0D, 0x00, + 0x01, 0x08, 0x00, 0x00, 0x05, 0x05, 0x0A, 0x03, 0x03, 0x0F, 0x0A, 0x00, + 0x0F, 0x04, 0x01, 0x06, 0x00, 0x02, 0x0A, 0x0E, 0x08, 0x0D, 0x06, 0x02, + 0x02, 0x01, 0x0D, 0x04, 0x0E, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x21, 0x35, + 0x23, 0x35, 0x33, 0x35, 0x07, 0x15, 0x23, 0x35, 0x17, 0x15, 0x23, 0x35, + 0x01, 0xF4, 0x7D, 0x7D, 0x82, 0xF5, 0xF5, 0xF5, 0x02, 0x71, 0xFD, 0x8F, + 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x05, 0x00, 0x10, + 0x40, 0x08, 0x00, 0x00, 0x01, 0x02, 0x04, 0x01, 0x03, 0x04, 0x2B, 0x00, + 0x3F, 0xFC, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x33, 0x11, 0x01, 0x77, + 0xFE, 0x89, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x01, 0xF4, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x09, 0x00, 0x0D, + 0x00, 0x2E, 0x40, 0x1B, 0x0B, 0x00, 0x03, 0x0A, 0x00, 0x07, 0x05, 0x00, + 0x03, 0x01, 0x00, 0x03, 0x00, 0x00, 0x07, 0x03, 0x06, 0x07, 0x02, 0x06, + 0x01, 0x0B, 0x04, 0x0C, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, + 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x13, 0x11, 0x23, 0x15, 0x21, 0x35, 0x23, 0x11, 0x21, 0x15, 0x33, 0x11, + 0x23, 0x11, 0x3F, 0x3F, 0x02, 0x71, 0x3E, 0xFE, 0x89, 0xFA, 0xF5, 0x01, + 0xF4, 0xFE, 0x89, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0xFE, 0x89, 0x01, 0x77, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, + 0x00, 0x23, 0x40, 0x14, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, + 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x0A, 0x06, 0x06, 0x01, 0x03, 0x04, + 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x30, + 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, + 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, 0x01, + 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x13, 0x00, 0x17, 0x00, 0x1B, + 0x00, 0x7C, 0x40, 0x44, 0x1A, 0x1A, 0x10, 0x12, 0x12, 0x17, 0x0C, 0x0C, + 0x10, 0x08, 0x08, 0x10, 0x06, 0x06, 0x17, 0x02, 0x02, 0x17, 0x10, 0x00, + 0x17, 0x04, 0x15, 0x06, 0x04, 0x06, 0x00, 0x06, 0x19, 0x02, 0x0E, 0x02, + 0x0A, 0x02, 0x15, 0x12, 0x0F, 0x17, 0x0D, 0x12, 0x12, 0x01, 0x17, 0x04, + 0x0B, 0x13, 0x01, 0x0A, 0x09, 0x02, 0x07, 0x19, 0x07, 0x1A, 0x05, 0x1B, + 0x01, 0x19, 0x03, 0x19, 0x03, 0x1A, 0x01, 0x0A, 0x19, 0x01, 0x0A, 0x04, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x3B, 0x01, 0x35, 0x33, 0x15, 0x33, + 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, 0x23, 0x35, 0x23, 0x15, 0x33, + 0x15, 0x33, 0x07, 0x33, 0x35, 0x23, 0x01, 0x23, 0x15, 0x33, 0xFA, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, + 0x02, 0x71, 0x7D, 0x7D, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, + 0x7D, 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x06, 0x00, + 0x08, 0x02, 0x00, 0x05, 0x04, 0x00, 0x00, 0x0A, 0x08, 0x06, 0x0A, 0x02, + 0x07, 0x00, 0x01, 0x06, 0x09, 0x01, 0x06, 0x04, 0x03, 0x01, 0x00, 0x04, + 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, + 0x10, 0xFC, 0x30, 0x31, 0x11, 0x21, 0x15, 0x23, 0x15, 0x33, 0x15, 0x21, + 0x15, 0x21, 0x11, 0x21, 0x01, 0x77, 0xFA, 0xFA, 0xFE, 0x89, 0x01, 0xF4, + 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x24, + 0x40, 0x15, 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, 0x06, 0x09, 0x02, 0x03, + 0x02, 0x07, 0x02, 0x02, 0x01, 0x05, 0x04, 0x08, 0x01, 0x01, 0x04, 0x2B, + 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x11, 0x23, 0x11, 0x23, 0x11, 0x33, 0x15, 0x21, 0x11, 0x01, 0x77, + 0xFA, 0x7D, 0x7D, 0x01, 0x77, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, + 0x0C, 0x7D, 0x02, 0x71, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x03, 0x6B, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x31, 0x40, 0x1D, 0x0C, 0x00, + 0x0B, 0x04, 0x05, 0x00, 0x07, 0x01, 0x00, 0x07, 0x06, 0x09, 0x02, 0x03, + 0x02, 0x0B, 0x00, 0x0A, 0x02, 0x07, 0x02, 0x02, 0x01, 0x05, 0x04, 0x09, + 0x01, 0x00, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x2B, 0x30, 0x31, 0x01, 0x11, 0x23, + 0x11, 0x23, 0x11, 0x33, 0x15, 0x21, 0x11, 0x25, 0x33, 0x35, 0x23, 0x01, + 0x77, 0xFA, 0x7D, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0xFA, 0xFA, 0x02, 0x71, + 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3C, 0x40, 0x22, 0x0E, 0x0E, 0x04, 0x02, + 0x02, 0x0A, 0x04, 0x00, 0x0A, 0x04, 0x0B, 0x06, 0x00, 0x06, 0x0D, 0x02, + 0x06, 0x02, 0x0A, 0x0E, 0x08, 0x0F, 0x03, 0x0E, 0x0F, 0x01, 0x0E, 0x04, + 0x01, 0x06, 0x06, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, 0x35, 0x23, + 0x35, 0x23, 0x01, 0x35, 0x23, 0x15, 0x13, 0x23, 0x15, 0x33, 0x7D, 0xFA, + 0xFA, 0x7D, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0xFD, + 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x26, 0x40, 0x16, + 0x06, 0x00, 0x02, 0x04, 0x00, 0x02, 0x08, 0x06, 0x00, 0x06, 0x02, 0x02, + 0x03, 0x08, 0x08, 0x01, 0x07, 0x04, 0x02, 0x01, 0x05, 0x04, 0x2B, 0x2B, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x21, 0x33, 0x11, 0x21, 0x15, 0x33, 0x21, 0x11, 0x33, 0x11, 0x01, 0x77, + 0x7D, 0xFE, 0x89, 0xFA, 0xFE, 0x89, 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, + 0x01, 0xF4, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, + 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x64, + 0x40, 0x39, 0x0E, 0x0E, 0x11, 0x0C, 0x00, 0x04, 0x0C, 0x0C, 0x12, 0x09, + 0x09, 0x11, 0x00, 0x12, 0x00, 0x04, 0x0B, 0x06, 0x06, 0x06, 0x01, 0x06, + 0x04, 0x02, 0x00, 0x02, 0x10, 0x07, 0x0C, 0x00, 0x0A, 0x12, 0x08, 0x0D, + 0x08, 0x0E, 0x04, 0x13, 0x03, 0x01, 0x00, 0x04, 0x00, 0x0F, 0x01, 0x0D, + 0x0D, 0x01, 0x12, 0x04, 0x12, 0x01, 0x07, 0x07, 0x01, 0x06, 0x04, 0x2B, + 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x10, 0xFC, 0xFC, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x11, 0x33, 0x11, 0x21, 0x23, 0x11, 0x3B, + 0x01, 0x11, 0x23, 0x11, 0x13, 0x23, 0x15, 0x33, 0x21, 0x33, 0x35, 0x23, + 0x01, 0xF4, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, + 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0xFD, 0x8F, + 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x28, 0x40, 0x18, + 0x01, 0x00, 0x08, 0x04, 0x0A, 0x06, 0x05, 0x06, 0x0B, 0x02, 0x03, 0x02, + 0x02, 0x06, 0x06, 0x01, 0x05, 0x04, 0x00, 0x09, 0x0A, 0x01, 0x09, 0x04, + 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, + 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, 0x33, 0x15, + 0x33, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, + 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x03, 0x00, 0x07, 0x00, 0x1D, + 0x40, 0x11, 0x06, 0x00, 0x00, 0x04, 0x00, 0x02, 0x06, 0x00, 0x02, 0x05, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x07, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, + 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, 0x11, 0x21, 0x27, 0x23, 0x11, + 0x33, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xFA, 0x02, 0x71, + 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1D, 0x40, 0x11, 0x03, 0x00, + 0x00, 0x06, 0x06, 0x01, 0x06, 0x00, 0x02, 0x06, 0x01, 0x05, 0x04, 0x02, + 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x30, + 0x31, 0x19, 0x01, 0x33, 0x11, 0x33, 0x11, 0x33, 0x11, 0x7D, 0xFA, 0x7D, + 0x02, 0x71, 0xFD, 0x8F, 0x01, 0xF4, 0xFE, 0x0C, 0x02, 0x71, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, + 0x00, 0x23, 0x40, 0x15, 0x08, 0x00, 0x00, 0x06, 0x00, 0x04, 0x04, 0x02, + 0x06, 0x00, 0x02, 0x07, 0x02, 0x05, 0x01, 0x09, 0x04, 0x02, 0x01, 0x01, + 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, + 0x31, 0x19, 0x01, 0x33, 0x35, 0x21, 0x11, 0x07, 0x23, 0x35, 0x33, 0x7D, + 0x01, 0x77, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0x01, 0x77, + 0xFA, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x07, 0x00, 0x1A, 0x40, 0x0E, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, + 0x03, 0x06, 0x01, 0x02, 0x06, 0x01, 0x03, 0x04, 0x2B, 0x00, 0x3F, 0x3F, + 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, + 0x21, 0x11, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0x01, 0xF4, + 0x7D, 0xFD, 0x8F, 0x7D, 0x01, 0x77, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x77, 0x02, 0x71, 0x00, 0x07, 0x00, 0x1A, 0x40, 0x0E, 0x06, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x05, 0x06, 0x00, 0x02, 0x05, 0x01, 0x04, 0x04, + 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x21, + 0x15, 0x33, 0x11, 0x33, 0x11, 0x33, 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x7D, + 0x7D, 0x02, 0x71, 0x7D, 0xFE, 0x0C, 0x01, 0xF4, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x19, + 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, 0x04, 0x09, 0x06, 0x0B, 0x02, 0x03, + 0x02, 0x08, 0x05, 0x02, 0x01, 0x05, 0x04, 0x00, 0x07, 0x0A, 0x01, 0x07, + 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xFC, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, + 0x21, 0x15, 0x21, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0xFE, 0x89, + 0x01, 0xF4, 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x13, 0x00, 0x66, 0x40, 0x39, 0x10, 0x10, 0x0C, 0x0E, + 0x0E, 0x12, 0x06, 0x06, 0x0B, 0x00, 0x0C, 0x0C, 0x13, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x04, 0x00, 0x02, 0x04, 0x00, 0x12, 0x12, 0x00, 0x13, 0x04, + 0x09, 0x06, 0x02, 0x02, 0x09, 0x0E, 0x09, 0x0D, 0x07, 0x13, 0x10, 0x01, + 0x06, 0x04, 0x03, 0x13, 0x01, 0x0E, 0x01, 0x0E, 0x01, 0x0D, 0x00, 0x01, + 0x0F, 0x0F, 0x01, 0x0E, 0x04, 0x2B, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xFC, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, + 0x2F, 0xFC, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x30, 0x31, + 0x01, 0x23, 0x35, 0x23, 0x15, 0x23, 0x11, 0x33, 0x15, 0x33, 0x35, 0x33, + 0x27, 0x23, 0x35, 0x33, 0x05, 0x35, 0x33, 0x15, 0x02, 0x71, 0xFA, 0x7D, + 0xFA, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x01, 0xF4, + 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x13, 0x00, 0x50, 0x40, 0x2C, 0x10, 0x10, 0x04, 0x09, + 0x09, 0x0F, 0x07, 0x07, 0x04, 0x01, 0x01, 0x0F, 0x04, 0x00, 0x0F, 0x04, + 0x0E, 0x06, 0x00, 0x06, 0x12, 0x02, 0x05, 0x02, 0x0A, 0x13, 0x08, 0x0E, + 0x06, 0x0D, 0x04, 0x0E, 0x0E, 0x01, 0x0D, 0x04, 0x02, 0x13, 0x00, 0x10, + 0x10, 0x01, 0x13, 0x04, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x15, 0x33, 0x15, + 0x33, 0x15, 0x25, 0x15, 0x33, 0x35, 0x25, 0x35, 0x23, 0x15, 0x01, 0xF4, + 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0xFE, 0x89, 0x7D, 0x01, 0x77, 0x7D, 0xFA, + 0x7D, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0xFA, 0xFA, 0x7D, 0xFA, 0xFA, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x32, 0x02, 0x71, 0x00, 0x09, + 0x00, 0x20, 0x40, 0x13, 0x06, 0x00, 0x00, 0x02, 0x00, 0x00, 0x06, 0x09, + 0x02, 0x04, 0x02, 0x08, 0x01, 0x09, 0x04, 0x03, 0x01, 0x06, 0x04, 0x2B, + 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, + 0x35, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x02, 0x32, 0x3E, 0x7D, + 0xFA, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x21, + 0x40, 0x14, 0x01, 0x00, 0x06, 0x04, 0x08, 0x06, 0x09, 0x02, 0x03, 0x02, + 0x02, 0x01, 0x05, 0x04, 0x00, 0x07, 0x08, 0x01, 0x07, 0x04, 0x2B, 0x10, + 0xD0, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x30, 0x31, 0x01, 0x15, 0x23, + 0x35, 0x23, 0x11, 0x21, 0x15, 0x33, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x01, + 0x77, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, 0xFA, 0x02, 0x71, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x0B, + 0x00, 0x28, 0x40, 0x19, 0x07, 0x00, 0x00, 0x03, 0x00, 0x00, 0x06, 0x0A, + 0x02, 0x05, 0x02, 0x01, 0x02, 0x08, 0x01, 0x0B, 0x04, 0x04, 0x01, 0x07, + 0x04, 0x00, 0x01, 0x03, 0x04, 0x2B, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, + 0x3F, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x11, 0x23, 0x11, 0x23, 0x11, + 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x02, 0x71, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, + 0x8F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0xAF, 0x02, 0x71, + 0x00, 0x0D, 0x00, 0x2D, 0x40, 0x1C, 0x09, 0x00, 0x00, 0x05, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x06, 0x0C, 0x02, 0x07, 0x02, 0x03, 0x02, 0x0A, 0x01, + 0x0D, 0x04, 0x06, 0x01, 0x09, 0x04, 0x02, 0x01, 0x05, 0x04, 0x2B, 0x2B, + 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, + 0x31, 0x21, 0x35, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, 0x11, 0x23, + 0x11, 0x23, 0x11, 0x02, 0xAF, 0x3E, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFD, 0x8F, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x32, 0x02, 0x71, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x09, 0x00, 0x02, 0x05, 0x00, 0x0B, + 0x04, 0x02, 0x06, 0x07, 0x02, 0x07, 0x01, 0x0A, 0x05, 0x0A, 0x03, 0x01, + 0x09, 0x04, 0x0A, 0x01, 0x02, 0x04, 0x0A, 0x06, 0x10, 0xD0, 0x2B, 0x2B, + 0x10, 0xD0, 0x10, 0xFC, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, + 0x11, 0x33, 0x11, 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, 0x15, 0x23, 0x35, + 0x3E, 0x01, 0xF4, 0xFE, 0x89, 0xBB, 0x01, 0xB5, 0xFA, 0x01, 0xF4, 0xFE, + 0x0C, 0x01, 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x02, 0xEE, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x0D, + 0x00, 0x29, 0x40, 0x19, 0x0B, 0x00, 0x06, 0x03, 0x00, 0x0D, 0x04, 0x06, + 0x06, 0x00, 0x06, 0x09, 0x02, 0x04, 0x02, 0x0C, 0x04, 0x04, 0x01, 0x05, + 0x04, 0x01, 0x01, 0x0B, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x21, 0x11, 0x21, 0x35, + 0x23, 0x01, 0x33, 0x11, 0x23, 0x03, 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, + 0x89, 0x7D, 0x02, 0x71, 0x7D, 0x7D, 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0xFD, + 0x8F, 0x02, 0x71, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x23, + 0x40, 0x15, 0x07, 0x00, 0x00, 0x03, 0x00, 0x09, 0x04, 0x00, 0x06, 0x05, + 0x02, 0x08, 0x04, 0x04, 0x01, 0x05, 0x04, 0x01, 0x01, 0x07, 0x04, 0x2B, + 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x31, + 0x21, 0x11, 0x21, 0x35, 0x23, 0x01, 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, + 0x89, 0x7D, 0x01, 0x77, 0xFA, 0x01, 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0F, + 0x00, 0x3E, 0x40, 0x24, 0x0C, 0x00, 0x0E, 0x0A, 0x00, 0x08, 0x06, 0x00, + 0x08, 0x02, 0x00, 0x05, 0x04, 0x00, 0x00, 0x0E, 0x08, 0x06, 0x0E, 0x02, + 0x0E, 0x01, 0x09, 0x01, 0x07, 0x00, 0x05, 0x01, 0x0C, 0x01, 0x01, 0x04, + 0x03, 0x01, 0x00, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x10, 0xFC, + 0x10, 0xFC, 0x30, 0x31, 0x11, 0x21, 0x15, 0x23, 0x15, 0x33, 0x15, 0x21, + 0x15, 0x21, 0x35, 0x33, 0x11, 0x23, 0x35, 0x21, 0x01, 0x77, 0xFA, 0xFA, + 0xFE, 0x89, 0x01, 0x77, 0x7D, 0x7D, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x02, 0xEE, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x37, 0x40, 0x22, + 0x0E, 0x00, 0x0A, 0x0C, 0x00, 0x04, 0x08, 0x00, 0x03, 0x04, 0x04, 0x06, + 0x00, 0x06, 0x0A, 0x02, 0x06, 0x02, 0x06, 0x01, 0x0F, 0x04, 0x03, 0x08, + 0x0E, 0x01, 0x08, 0x04, 0x01, 0x0A, 0x0A, 0x01, 0x0B, 0x04, 0x2B, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, + 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, 0x15, 0x21, 0x11, + 0x21, 0x15, 0x23, 0x35, 0x23, 0x01, 0x23, 0x11, 0x33, 0x7D, 0x7D, 0x01, + 0xF4, 0xFE, 0x0C, 0x7D, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFA, 0xFA, 0x02, + 0x71, 0xFA, 0xFA, 0xFE, 0x0C, 0x01, 0x77, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3A, + 0x40, 0x21, 0x0E, 0x0E, 0x08, 0x0C, 0x00, 0x06, 0x02, 0x02, 0x0B, 0x08, + 0x00, 0x0B, 0x04, 0x05, 0x06, 0x00, 0x06, 0x06, 0x02, 0x0C, 0x02, 0x07, + 0x0B, 0x03, 0x0D, 0x06, 0x01, 0x0D, 0x04, 0x02, 0x01, 0x0B, 0x04, 0x2B, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, + 0x35, 0x33, 0x15, 0x33, 0x11, 0x21, 0x15, 0x33, 0x15, 0x23, 0x37, 0x33, + 0x15, 0x23, 0x82, 0xF5, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0x82, 0xF5, 0xF5, + 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x7D, 0xFA, 0x7D, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0F, 0x00, 0x39, 0x40, 0x21, + 0x0A, 0x00, 0x08, 0x06, 0x00, 0x08, 0x02, 0x02, 0x0F, 0x04, 0x00, 0x0F, + 0x04, 0x0D, 0x06, 0x00, 0x06, 0x08, 0x02, 0x07, 0x0F, 0x05, 0x0D, 0x0D, + 0x01, 0x0C, 0x04, 0x04, 0x0F, 0x02, 0x01, 0x0F, 0x04, 0x2B, 0x10, 0xD0, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x33, 0x35, 0x23, 0x35, + 0x23, 0x35, 0x33, 0x35, 0x21, 0x15, 0x33, 0x11, 0x33, 0x35, 0x33, 0x01, + 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, + 0x7D, 0x7D, 0x7D, 0xFE, 0x0C, 0xFA, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0F, 0x00, 0x39, 0x40, 0x21, 0x0A, 0x00, + 0x08, 0x06, 0x00, 0x08, 0x02, 0x02, 0x0F, 0x04, 0x00, 0x0F, 0x04, 0x0D, + 0x06, 0x00, 0x06, 0x08, 0x02, 0x07, 0x0F, 0x05, 0x0D, 0x0D, 0x01, 0x0C, + 0x04, 0x04, 0x0F, 0x02, 0x01, 0x0F, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x33, 0x35, 0x23, 0x35, 0x23, 0x35, + 0x33, 0x35, 0x21, 0x15, 0x33, 0x11, 0x33, 0x35, 0x33, 0x01, 0x77, 0x7D, + 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, + 0x7D, 0xFE, 0x0C, 0xFA, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, + 0x03, 0xE8, 0x00, 0x05, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x40, 0x40, 0x24, + 0x0A, 0x0A, 0x06, 0x06, 0x00, 0x09, 0x04, 0x06, 0x06, 0x0B, 0x0C, 0x00, + 0x0B, 0x04, 0x00, 0x00, 0x01, 0x02, 0x0A, 0x09, 0x07, 0x04, 0x06, 0x0D, + 0x00, 0x0C, 0x01, 0x09, 0x01, 0x04, 0x04, 0x01, 0x03, 0x04, 0x04, 0x08, + 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x33, 0x11, 0x13, 0x23, 0x15, 0x33, + 0x35, 0x33, 0x35, 0x23, 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x01, 0xF4, 0x01, 0x77, 0x7D, + 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x03, 0xE8, + 0x00, 0x05, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x40, 0x40, 0x24, 0x0A, 0x0A, + 0x06, 0x06, 0x00, 0x09, 0x04, 0x06, 0x06, 0x0B, 0x0C, 0x00, 0x0B, 0x04, + 0x00, 0x00, 0x01, 0x02, 0x0A, 0x09, 0x07, 0x04, 0x06, 0x0D, 0x00, 0x0C, + 0x01, 0x09, 0x01, 0x04, 0x04, 0x01, 0x03, 0x04, 0x04, 0x08, 0x10, 0xD0, + 0x2B, 0x10, 0xFC, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, + 0x01, 0x35, 0x21, 0x11, 0x33, 0x11, 0x13, 0x23, 0x15, 0x33, 0x35, 0x33, + 0x35, 0x23, 0x01, 0x77, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, + 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x01, 0xF4, 0x01, 0x77, 0x7D, 0x7D, 0x7D, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, 0x00, 0x05, + 0x00, 0x13, 0x40, 0x0A, 0x01, 0x00, 0x03, 0x06, 0x05, 0x02, 0x04, 0x01, + 0x01, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0xFC, 0x30, 0x31, 0x13, 0x11, 0x23, + 0x15, 0x21, 0x11, 0xFA, 0xFA, 0x01, 0x77, 0x02, 0x71, 0xFE, 0x0C, 0x7D, + 0x02, 0x71, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0x71, + 0x00, 0x05, 0x00, 0x13, 0x40, 0x0A, 0x01, 0x00, 0x03, 0x06, 0x05, 0x02, + 0x04, 0x01, 0x01, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0xFC, 0x30, 0x31, 0x13, + 0x11, 0x23, 0x15, 0x21, 0x11, 0xFA, 0xFA, 0x01, 0x77, 0x02, 0x71, 0xFE, + 0x0C, 0x7D, 0x02, 0x71, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, + 0x02, 0xEE, 0x00, 0x07, 0x00, 0x17, 0x40, 0x0D, 0x00, 0x00, 0x03, 0x02, + 0x02, 0x06, 0x01, 0x05, 0x04, 0x00, 0x01, 0x03, 0x04, 0x2B, 0x2B, 0x00, + 0x2F, 0x3F, 0xFC, 0x30, 0x31, 0x01, 0x35, 0x23, 0x15, 0x23, 0x11, 0x33, + 0x11, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0x01, 0xF4, 0xFA, 0x7D, 0xFD, 0x8F, + 0x01, 0xF4, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x02, 0xEE, + 0x00, 0x07, 0x00, 0x17, 0x40, 0x0D, 0x00, 0x00, 0x03, 0x02, 0x02, 0x06, + 0x01, 0x05, 0x04, 0x00, 0x01, 0x03, 0x04, 0x2B, 0x2B, 0x00, 0x2F, 0x3F, + 0xFC, 0x30, 0x31, 0x01, 0x35, 0x23, 0x15, 0x23, 0x11, 0x33, 0x11, 0x01, + 0x77, 0x7D, 0xFA, 0x7D, 0x01, 0xF4, 0xFA, 0x7D, 0xFD, 0x8F, 0x01, 0xF4, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x3E, 0x40, 0x24, 0x0C, 0x00, 0x0D, 0x09, 0x00, 0x08, + 0x04, 0x05, 0x00, 0x03, 0x01, 0x00, 0x03, 0x00, 0x00, 0x0D, 0x03, 0x06, + 0x0D, 0x02, 0x0E, 0x02, 0x0A, 0x02, 0x06, 0x02, 0x04, 0x0C, 0x0C, 0x01, + 0x09, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x10, + 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x15, 0x21, 0x35, + 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x21, 0x35, 0x21, 0x15, 0x7D, 0x01, + 0x77, 0xFE, 0x89, 0xFA, 0xFA, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0xFE, + 0x89, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3E, + 0x40, 0x24, 0x0C, 0x00, 0x0D, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, 0x03, + 0x01, 0x00, 0x03, 0x00, 0x00, 0x0D, 0x03, 0x06, 0x0D, 0x02, 0x0E, 0x02, + 0x0A, 0x02, 0x06, 0x02, 0x04, 0x0C, 0x0C, 0x01, 0x09, 0x04, 0x02, 0x01, + 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x10, 0xFC, + 0x30, 0x31, 0x19, 0x01, 0x33, 0x15, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, + 0x23, 0x35, 0x21, 0x35, 0x21, 0x15, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0xFA, + 0xFA, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, + 0x02, 0x71, 0x00, 0x03, 0x00, 0x10, 0x40, 0x08, 0x02, 0x06, 0x03, 0x02, + 0x02, 0x01, 0x01, 0x04, 0x2B, 0x00, 0x3F, 0x3F, 0x30, 0x31, 0x19, 0x01, + 0x33, 0x11, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0x00, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x03, 0xE8, 0x00, 0x03, 0x00, 0x07, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x5D, 0x40, 0x31, 0x0C, 0x0C, 0x08, 0x09, + 0x00, 0x08, 0x05, 0x05, 0x0E, 0x04, 0x04, 0x0F, 0x04, 0x04, 0x08, 0x08, + 0x0F, 0x0F, 0x00, 0x0E, 0x04, 0x02, 0x06, 0x0E, 0x01, 0x08, 0x0C, 0x08, + 0x0A, 0x06, 0x02, 0x08, 0x02, 0x0D, 0x08, 0x01, 0x06, 0x08, 0x0D, 0x00, + 0x06, 0x00, 0x0B, 0x06, 0x01, 0x05, 0x04, 0x06, 0x0B, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x00, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, + 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, + 0x2F, 0x30, 0x31, 0x13, 0x11, 0x33, 0x11, 0x27, 0x15, 0x33, 0x35, 0x33, + 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, 0x35, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFD, 0x8F, 0x02, 0x71, 0xFA, 0x7D, 0x7D, + 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, + 0x03, 0xE8, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x5D, + 0x40, 0x31, 0x0C, 0x0C, 0x08, 0x09, 0x00, 0x08, 0x05, 0x05, 0x0E, 0x04, + 0x04, 0x0F, 0x04, 0x04, 0x08, 0x08, 0x0F, 0x0F, 0x00, 0x0E, 0x04, 0x02, + 0x06, 0x0E, 0x01, 0x08, 0x0C, 0x08, 0x0A, 0x06, 0x02, 0x08, 0x02, 0x0D, + 0x08, 0x01, 0x06, 0x08, 0x0D, 0x00, 0x06, 0x00, 0x0B, 0x06, 0x01, 0x05, + 0x04, 0x06, 0x0B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, + 0x00, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x13, 0x11, 0x33, + 0x11, 0x27, 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, 0x15, 0x33, 0x15, 0x33, + 0x35, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x02, 0x71, 0xFD, + 0x8F, 0x02, 0x71, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x39, 0x40, 0x23, 0x0D, 0x00, 0x0A, 0x08, 0x00, 0x04, + 0x06, 0x00, 0x04, 0x03, 0x00, 0x0F, 0x04, 0x0A, 0x06, 0x00, 0x06, 0x04, + 0x02, 0x0E, 0x03, 0x05, 0x0A, 0x0A, 0x01, 0x09, 0x04, 0x03, 0x01, 0x07, + 0x04, 0x01, 0x01, 0x0D, 0x04, 0x2B, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, + 0x31, 0x29, 0x01, 0x11, 0x23, 0x35, 0x21, 0x15, 0x33, 0x21, 0x11, 0x33, + 0x11, 0x05, 0x15, 0x23, 0x35, 0x01, 0x77, 0x01, 0x77, 0xFA, 0xFE, 0x89, + 0xFA, 0xFE, 0x89, 0x7D, 0x01, 0xF4, 0x7D, 0x01, 0x77, 0xFA, 0x7D, 0xFE, + 0x0C, 0x01, 0xF4, 0xFA, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x02, 0xEE, 0x02, 0x71, 0x00, 0x07, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x39, + 0x40, 0x23, 0x0D, 0x00, 0x0A, 0x08, 0x00, 0x04, 0x06, 0x00, 0x04, 0x03, + 0x00, 0x0F, 0x04, 0x0A, 0x06, 0x00, 0x06, 0x04, 0x02, 0x0E, 0x03, 0x05, + 0x0A, 0x0A, 0x01, 0x09, 0x04, 0x03, 0x01, 0x07, 0x04, 0x01, 0x01, 0x0D, + 0x04, 0x2B, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, + 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x29, 0x01, 0x11, + 0x23, 0x35, 0x21, 0x15, 0x33, 0x21, 0x11, 0x33, 0x11, 0x05, 0x15, 0x23, + 0x35, 0x01, 0x77, 0x01, 0x77, 0xFA, 0xFE, 0x89, 0xFA, 0xFE, 0x89, 0x7D, + 0x01, 0xF4, 0x7D, 0x01, 0x77, 0xFA, 0x7D, 0xFE, 0x0C, 0x01, 0xF4, 0xFA, + 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x5A, 0x40, 0x33, 0x10, 0x10, + 0x0E, 0x0E, 0x00, 0x0D, 0x04, 0x0E, 0x0E, 0x13, 0x12, 0x00, 0x13, 0x04, + 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, 0x04, 0x09, 0x06, 0x12, 0x0E, 0x11, + 0x00, 0x0D, 0x13, 0x0C, 0x02, 0x0B, 0x01, 0x10, 0x08, 0x05, 0x06, 0x10, + 0x06, 0x00, 0x10, 0x01, 0x0E, 0x01, 0x02, 0x02, 0x01, 0x05, 0x04, 0x02, + 0x0F, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0xD0, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, + 0x3F, 0x2B, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, 0x21, 0x15, + 0x21, 0x11, 0x25, 0x33, 0x35, 0x23, 0x33, 0x35, 0x23, 0x15, 0x01, 0x77, + 0xFA, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x7D, + 0xFA, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x02, 0x71, + 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x03, 0xE8, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x5A, 0x40, 0x33, + 0x10, 0x10, 0x0E, 0x0E, 0x00, 0x0D, 0x04, 0x0E, 0x0E, 0x13, 0x12, 0x00, + 0x13, 0x04, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, 0x04, 0x09, 0x06, 0x12, + 0x0E, 0x11, 0x00, 0x0D, 0x13, 0x0C, 0x02, 0x0B, 0x01, 0x10, 0x08, 0x05, + 0x06, 0x10, 0x06, 0x00, 0x10, 0x01, 0x0E, 0x01, 0x02, 0x02, 0x01, 0x05, + 0x04, 0x02, 0x0F, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, 0xD0, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x2B, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x21, 0x15, + 0x21, 0x15, 0x21, 0x11, 0x25, 0x33, 0x35, 0x23, 0x33, 0x35, 0x23, 0x15, + 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0xFE, 0x89, + 0x7D, 0x7D, 0xFA, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, + 0x02, 0x71, 0x7D, 0x7D, 0x7D, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x02, 0xEE, 0x02, 0x71, 0x00, 0x0D, 0x00, 0x11, 0x00, 0x42, 0x40, 0x27, + 0x0F, 0x00, 0x0A, 0x07, 0x07, 0x11, 0x01, 0x01, 0x0C, 0x0C, 0x00, 0x11, + 0x04, 0x0A, 0x06, 0x05, 0x06, 0x0D, 0x02, 0x03, 0x02, 0x0C, 0x10, 0x0A, + 0x01, 0x0F, 0x04, 0x02, 0x06, 0x06, 0x01, 0x05, 0x04, 0x00, 0x09, 0x10, + 0x01, 0x09, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, + 0x10, 0xFC, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, + 0x33, 0x15, 0x21, 0x11, 0x23, 0x35, 0x13, 0x15, 0x23, 0x35, 0x01, 0x77, + 0xFA, 0x7D, 0x7D, 0xFA, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0x02, 0x71, 0xFA, + 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x01, 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, 0x02, 0x71, 0x00, 0x0D, + 0x00, 0x11, 0x00, 0x42, 0x40, 0x27, 0x0F, 0x00, 0x0A, 0x07, 0x07, 0x11, + 0x01, 0x01, 0x0C, 0x0C, 0x00, 0x11, 0x04, 0x0A, 0x06, 0x05, 0x06, 0x0D, + 0x02, 0x03, 0x02, 0x0C, 0x10, 0x0A, 0x01, 0x0F, 0x04, 0x02, 0x06, 0x06, + 0x01, 0x05, 0x04, 0x00, 0x09, 0x10, 0x01, 0x09, 0x04, 0x2B, 0x10, 0xD0, + 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, + 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, 0x01, 0x15, + 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, 0x33, 0x15, 0x21, 0x11, 0x23, 0x35, + 0x13, 0x15, 0x23, 0x35, 0x01, 0x77, 0xFA, 0x7D, 0x7D, 0xFA, 0x01, 0x77, + 0xFA, 0x7D, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x01, + 0x77, 0xFA, 0xFE, 0x89, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x06, 0x00, + 0x08, 0x0A, 0x00, 0x05, 0x04, 0x00, 0x00, 0x02, 0x08, 0x06, 0x02, 0x02, + 0x07, 0x04, 0x0B, 0x01, 0x04, 0x04, 0x01, 0x09, 0x09, 0x01, 0x06, 0x04, + 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, + 0x10, 0xFC, 0x30, 0x31, 0x13, 0x21, 0x35, 0x21, 0x11, 0x21, 0x15, 0x21, + 0x15, 0x21, 0x11, 0x21, 0x7D, 0x01, 0x77, 0xFE, 0x0C, 0x01, 0x77, 0xFE, + 0x89, 0x01, 0xF4, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, + 0x01, 0x77, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x2C, 0x40, 0x1A, 0x06, 0x00, 0x08, 0x0A, 0x00, 0x05, + 0x04, 0x00, 0x00, 0x02, 0x08, 0x06, 0x02, 0x02, 0x07, 0x04, 0x0B, 0x01, + 0x04, 0x04, 0x01, 0x09, 0x09, 0x01, 0x06, 0x04, 0x2B, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x30, 0x31, + 0x13, 0x21, 0x35, 0x21, 0x11, 0x21, 0x15, 0x21, 0x15, 0x21, 0x11, 0x21, + 0x7D, 0x01, 0x77, 0xFE, 0x0C, 0x01, 0x77, 0xFE, 0x89, 0x01, 0xF4, 0xFE, + 0x89, 0x01, 0xF4, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x01, 0x77, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0D, 0x00, 0x2F, + 0x40, 0x1C, 0x08, 0x00, 0x06, 0x04, 0x00, 0x06, 0x02, 0x00, 0x0D, 0x04, + 0x0B, 0x06, 0x00, 0x06, 0x06, 0x02, 0x05, 0x0D, 0x03, 0x0B, 0x0B, 0x01, + 0x0A, 0x04, 0x02, 0x01, 0x0D, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, + 0x33, 0x11, 0x23, 0x35, 0x33, 0x35, 0x21, 0x15, 0x33, 0x11, 0x33, 0x35, + 0x33, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x01, + 0x77, 0x7D, 0x7D, 0x7D, 0xFE, 0x0C, 0xFA, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0D, 0x00, 0x2F, 0x40, 0x1C, + 0x08, 0x00, 0x06, 0x04, 0x00, 0x06, 0x02, 0x00, 0x0D, 0x04, 0x0B, 0x06, + 0x00, 0x06, 0x06, 0x02, 0x05, 0x0D, 0x03, 0x0B, 0x0B, 0x01, 0x0A, 0x04, + 0x02, 0x01, 0x0D, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x33, 0x11, + 0x23, 0x35, 0x33, 0x35, 0x21, 0x15, 0x33, 0x11, 0x33, 0x35, 0x33, 0x01, + 0x77, 0x7D, 0xFA, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, + 0x7D, 0x7D, 0xFE, 0x0C, 0xFA, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x17, + 0x00, 0x7C, 0x40, 0x46, 0x14, 0x14, 0x10, 0x10, 0x00, 0x13, 0x04, 0x10, + 0x10, 0x15, 0x16, 0x00, 0x15, 0x04, 0x0E, 0x0E, 0x03, 0x01, 0x01, 0x0A, + 0x03, 0x00, 0x0A, 0x04, 0x0B, 0x06, 0x07, 0x06, 0x0D, 0x02, 0x05, 0x02, + 0x15, 0x0D, 0x14, 0x13, 0x01, 0x08, 0x11, 0x08, 0x10, 0x17, 0x01, 0x0D, + 0x0A, 0x0D, 0x0A, 0x16, 0x04, 0x08, 0x04, 0x12, 0x08, 0x01, 0x07, 0x04, + 0x08, 0x12, 0x02, 0x0D, 0x02, 0x16, 0x00, 0x0C, 0x0C, 0x01, 0x0D, 0x04, + 0x0D, 0x16, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, + 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, + 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, + 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, + 0x23, 0x11, 0x33, 0x35, 0x33, 0x15, 0x13, 0x23, 0x15, 0x33, 0x03, 0x23, + 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0x7D, + 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, + 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x0B, + 0x00, 0x0F, 0x00, 0x13, 0x00, 0x17, 0x00, 0x7C, 0x40, 0x46, 0x14, 0x14, + 0x10, 0x10, 0x00, 0x13, 0x04, 0x10, 0x10, 0x15, 0x16, 0x00, 0x15, 0x04, + 0x0E, 0x0E, 0x03, 0x01, 0x01, 0x0A, 0x03, 0x00, 0x0A, 0x04, 0x0B, 0x06, + 0x07, 0x06, 0x0D, 0x02, 0x05, 0x02, 0x15, 0x0D, 0x14, 0x13, 0x01, 0x08, + 0x11, 0x08, 0x10, 0x17, 0x01, 0x0D, 0x0A, 0x0D, 0x0A, 0x16, 0x04, 0x08, + 0x04, 0x12, 0x08, 0x01, 0x07, 0x04, 0x08, 0x12, 0x02, 0x0D, 0x02, 0x16, + 0x00, 0x0C, 0x0C, 0x01, 0x0D, 0x04, 0x0D, 0x16, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, + 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, 0x33, 0x15, + 0x13, 0x23, 0x15, 0x33, 0x03, 0x23, 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, + 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, + 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, + 0xFA, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x03, 0x6C, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x46, + 0x40, 0x2A, 0x13, 0x00, 0x12, 0x04, 0x0F, 0x00, 0x0E, 0x04, 0x09, 0x00, + 0x08, 0x04, 0x05, 0x00, 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, + 0x0A, 0x12, 0x08, 0x0D, 0x06, 0x12, 0x04, 0x0E, 0x02, 0x11, 0x12, 0x01, + 0x11, 0x04, 0x00, 0x0E, 0x0E, 0x01, 0x0D, 0x04, 0x2B, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x2B, 0x2B, 0x2B, 0x30, 0x31, 0x01, 0x35, + 0x21, 0x11, 0x21, 0x35, 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x13, 0x15, + 0x33, 0x35, 0x25, 0x15, 0x33, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, + 0xFE, 0x89, 0xFA, 0xFA, 0xFA, 0x7D, 0xFE, 0x0C, 0x7D, 0x01, 0xF4, 0x7D, + 0xFD, 0x8F, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x01, 0x7D, + 0x7D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0x6C, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x46, 0x40, 0x2A, 0x13, 0x00, + 0x12, 0x04, 0x0F, 0x00, 0x0E, 0x04, 0x09, 0x00, 0x08, 0x04, 0x05, 0x00, + 0x03, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x0A, 0x12, 0x08, 0x0D, + 0x06, 0x12, 0x04, 0x0E, 0x02, 0x11, 0x12, 0x01, 0x11, 0x04, 0x00, 0x0E, + 0x0E, 0x01, 0x0D, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, + 0xFC, 0x2B, 0x2B, 0x2B, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, + 0x21, 0x35, 0x33, 0x35, 0x23, 0x35, 0x13, 0x15, 0x33, 0x35, 0x25, 0x15, + 0x33, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0xFE, 0x89, 0xFA, 0xFA, + 0xFA, 0x7D, 0xFE, 0x0C, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0x7D, 0x7D, + 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x01, 0x7D, 0x7D, 0x00, 0x00, 0x01, + 0x00, 0x00, 0xFF, 0x83, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2A, + 0x40, 0x18, 0x00, 0x00, 0x08, 0x07, 0x08, 0x08, 0x06, 0x04, 0x06, 0x0A, + 0x01, 0x07, 0x01, 0x01, 0x04, 0x04, 0x00, 0x07, 0x07, 0x01, 0x06, 0x04, + 0x07, 0x0B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0x00, 0x3F, + 0x3F, 0x3F, 0x10, 0xFC, 0x30, 0x31, 0x25, 0x23, 0x11, 0x23, 0x11, 0x33, + 0x15, 0x33, 0x35, 0x33, 0x11, 0x23, 0x01, 0x77, 0xFA, 0x7D, 0xFA, 0x7D, + 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0xFD, 0x8F, 0x7D, 0x7D, 0x02, 0x71, 0x00, + 0x00, 0x01, 0x00, 0x00, 0xFF, 0x83, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, + 0x00, 0x2A, 0x40, 0x18, 0x00, 0x00, 0x08, 0x07, 0x08, 0x08, 0x06, 0x04, + 0x06, 0x0A, 0x01, 0x07, 0x01, 0x01, 0x04, 0x04, 0x00, 0x07, 0x07, 0x01, + 0x06, 0x04, 0x07, 0x0B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xFC, + 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x30, 0x31, 0x25, 0x23, 0x11, 0x23, + 0x11, 0x33, 0x15, 0x33, 0x35, 0x33, 0x11, 0x23, 0x01, 0x77, 0xFA, 0x7D, + 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0xFD, 0x8F, 0x7D, 0x7D, 0x02, + 0x71, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, 0x00, 0x17, 0x00, 0x7C, 0x40, 0x46, + 0x14, 0x14, 0x10, 0x10, 0x00, 0x13, 0x04, 0x10, 0x10, 0x15, 0x16, 0x00, + 0x15, 0x04, 0x0E, 0x0E, 0x03, 0x01, 0x01, 0x0A, 0x03, 0x00, 0x0A, 0x04, + 0x0B, 0x06, 0x07, 0x06, 0x0D, 0x02, 0x05, 0x02, 0x15, 0x0D, 0x14, 0x13, + 0x01, 0x08, 0x11, 0x08, 0x10, 0x17, 0x01, 0x0D, 0x0A, 0x0D, 0x0A, 0x16, + 0x04, 0x08, 0x04, 0x12, 0x08, 0x01, 0x07, 0x04, 0x08, 0x12, 0x02, 0x0D, + 0x02, 0x16, 0x00, 0x0C, 0x0C, 0x01, 0x0D, 0x04, 0x0D, 0x16, 0x10, 0xD0, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, + 0xFC, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, + 0x30, 0x31, 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, + 0x33, 0x15, 0x13, 0x23, 0x15, 0x33, 0x03, 0x23, 0x15, 0x33, 0x35, 0x33, + 0x35, 0x23, 0x01, 0xF4, 0x7D, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, + 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, + 0x02, 0x71, 0xFA, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x03, 0xE8, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x13, + 0x00, 0x17, 0x00, 0x7C, 0x40, 0x46, 0x14, 0x14, 0x10, 0x10, 0x00, 0x13, + 0x04, 0x10, 0x10, 0x15, 0x16, 0x00, 0x15, 0x04, 0x0E, 0x0E, 0x03, 0x01, + 0x01, 0x0A, 0x03, 0x00, 0x0A, 0x04, 0x0B, 0x06, 0x07, 0x06, 0x0D, 0x02, + 0x05, 0x02, 0x15, 0x0D, 0x14, 0x13, 0x01, 0x08, 0x11, 0x08, 0x10, 0x17, + 0x01, 0x0D, 0x0A, 0x0D, 0x0A, 0x16, 0x04, 0x08, 0x04, 0x12, 0x08, 0x01, + 0x07, 0x04, 0x08, 0x12, 0x02, 0x0D, 0x02, 0x16, 0x00, 0x0C, 0x0C, 0x01, + 0x0D, 0x04, 0x0D, 0x16, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x10, 0xFC, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xD0, 0x2F, 0x2B, 0x10, + 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x21, 0x35, 0x23, 0x35, + 0x23, 0x35, 0x23, 0x11, 0x33, 0x35, 0x33, 0x15, 0x13, 0x23, 0x15, 0x33, + 0x03, 0x23, 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, 0x01, 0xF4, 0x7D, 0xFA, + 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0xFA, + 0x7D, 0xFA, 0xFD, 0x8F, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x01, 0xF4, 0x7D, + 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x0D, 0x00, 0x2F, 0x40, 0x1C, 0x08, 0x00, 0x06, 0x04, 0x00, 0x06, + 0x02, 0x00, 0x0D, 0x04, 0x0B, 0x06, 0x00, 0x06, 0x06, 0x02, 0x05, 0x0D, + 0x03, 0x0B, 0x0B, 0x01, 0x0A, 0x04, 0x02, 0x01, 0x0D, 0x04, 0x2B, 0x2B, + 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, + 0xFC, 0x30, 0x31, 0x21, 0x33, 0x11, 0x23, 0x35, 0x33, 0x35, 0x21, 0x15, + 0x33, 0x11, 0x33, 0x35, 0x33, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0xFE, 0x89, + 0x7D, 0x7D, 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0xFE, 0x0C, 0xFA, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0D, + 0x00, 0x2F, 0x40, 0x1C, 0x08, 0x00, 0x06, 0x04, 0x00, 0x06, 0x02, 0x00, + 0x0D, 0x04, 0x0B, 0x06, 0x00, 0x06, 0x06, 0x02, 0x05, 0x0D, 0x03, 0x0B, + 0x0B, 0x01, 0x0A, 0x04, 0x02, 0x01, 0x0D, 0x04, 0x2B, 0x2B, 0x10, 0xD0, + 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x30, + 0x31, 0x21, 0x33, 0x11, 0x23, 0x35, 0x33, 0x35, 0x21, 0x15, 0x33, 0x11, + 0x33, 0x35, 0x33, 0x01, 0x77, 0x7D, 0xFA, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, + 0x7D, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0xFE, 0x0C, 0xFA, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x03, 0xE8, 0x00, 0x05, 0x00, 0x09, + 0x00, 0x0D, 0x00, 0x40, 0x40, 0x24, 0x0A, 0x0A, 0x06, 0x06, 0x00, 0x09, + 0x04, 0x06, 0x06, 0x0B, 0x0C, 0x00, 0x0B, 0x04, 0x00, 0x00, 0x01, 0x02, + 0x0A, 0x09, 0x07, 0x04, 0x06, 0x0D, 0x00, 0x0C, 0x01, 0x09, 0x01, 0x04, + 0x04, 0x01, 0x03, 0x04, 0x04, 0x08, 0x10, 0xD0, 0x2B, 0x10, 0xFC, 0xFC, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0xFC, 0x2B, 0x10, + 0xD0, 0x2F, 0x2B, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, + 0x33, 0x11, 0x13, 0x23, 0x15, 0x33, 0x35, 0x33, 0x35, 0x23, 0x01, 0x77, + 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0xFD, + 0x8F, 0x01, 0xF4, 0x01, 0x77, 0x7D, 0x7D, 0x7D, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0F, 0x00, 0x39, 0x40, 0x21, + 0x0A, 0x00, 0x08, 0x06, 0x00, 0x08, 0x02, 0x02, 0x0F, 0x04, 0x00, 0x0F, + 0x04, 0x0D, 0x06, 0x00, 0x06, 0x08, 0x02, 0x07, 0x0F, 0x05, 0x0D, 0x0D, + 0x01, 0x0C, 0x04, 0x04, 0x0F, 0x02, 0x01, 0x0F, 0x04, 0x2B, 0x10, 0xD0, + 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x33, 0x35, 0x23, 0x35, + 0x23, 0x35, 0x33, 0x35, 0x21, 0x15, 0x33, 0x11, 0x33, 0x35, 0x33, 0x01, + 0x77, 0x7D, 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, + 0x7D, 0x7D, 0x7D, 0xFE, 0x0C, 0xFA, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0F, 0x00, 0x39, 0x40, 0x21, 0x0A, 0x00, + 0x08, 0x06, 0x00, 0x08, 0x02, 0x02, 0x0F, 0x04, 0x00, 0x0F, 0x04, 0x0D, + 0x06, 0x00, 0x06, 0x08, 0x02, 0x07, 0x0F, 0x05, 0x0D, 0x0D, 0x01, 0x0C, + 0x04, 0x04, 0x0F, 0x02, 0x01, 0x0F, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, + 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x21, 0x33, 0x35, 0x23, 0x35, 0x23, 0x35, + 0x33, 0x35, 0x21, 0x15, 0x33, 0x11, 0x33, 0x35, 0x33, 0x01, 0x77, 0x7D, + 0x7D, 0x7D, 0x7D, 0xFE, 0x89, 0x7D, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, + 0x7D, 0xFE, 0x0C, 0xFA, 0x00, 0x01, 0x00, 0x00, 0xFF, 0x83, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x2A, 0x40, 0x18, 0x00, 0x00, 0x08, 0x07, + 0x08, 0x08, 0x06, 0x04, 0x06, 0x0A, 0x01, 0x07, 0x01, 0x01, 0x04, 0x04, + 0x00, 0x07, 0x07, 0x01, 0x06, 0x04, 0x07, 0x0B, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x2B, 0x10, 0xFC, 0x00, 0x3F, 0x3F, 0x3F, 0x10, 0xFC, 0x30, 0x31, + 0x25, 0x23, 0x11, 0x23, 0x11, 0x33, 0x15, 0x33, 0x35, 0x33, 0x11, 0x23, + 0x01, 0x77, 0xFA, 0x7D, 0xFA, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xF4, 0xFD, + 0x8F, 0x7D, 0x7D, 0x02, 0x71, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3A, 0x40, 0x21, + 0x0E, 0x0E, 0x08, 0x0C, 0x00, 0x06, 0x02, 0x02, 0x0B, 0x08, 0x00, 0x0B, + 0x04, 0x05, 0x06, 0x00, 0x06, 0x06, 0x02, 0x0C, 0x02, 0x07, 0x0B, 0x03, + 0x0D, 0x06, 0x01, 0x0D, 0x04, 0x02, 0x01, 0x0B, 0x04, 0x2B, 0x2B, 0x10, + 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, + 0x2F, 0x10, 0xFC, 0x10, 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, + 0x15, 0x33, 0x11, 0x21, 0x15, 0x33, 0x15, 0x23, 0x37, 0x33, 0x15, 0x23, + 0x82, 0xF5, 0x7D, 0xFE, 0x0C, 0x7D, 0x7D, 0x82, 0xF5, 0xF5, 0xFA, 0xFA, + 0x02, 0x71, 0xFA, 0x7D, 0xFA, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x71, 0x02, 0x71, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x2E, 0x40, 0x1B, + 0x0B, 0x00, 0x03, 0x0A, 0x00, 0x07, 0x05, 0x00, 0x03, 0x01, 0x00, 0x03, + 0x00, 0x00, 0x07, 0x03, 0x06, 0x07, 0x02, 0x06, 0x01, 0x0B, 0x04, 0x0C, + 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, + 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, 0x13, 0x11, 0x23, 0x15, + 0x21, 0x35, 0x23, 0x11, 0x21, 0x15, 0x33, 0x11, 0x23, 0x11, 0x3F, 0x3F, + 0x02, 0x71, 0x3E, 0xFE, 0x89, 0xFA, 0xF5, 0x01, 0xF4, 0xFE, 0x89, 0x7D, + 0x7D, 0x01, 0xF4, 0x7D, 0xFE, 0x89, 0x01, 0x77, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x32, + 0x40, 0x1D, 0x0B, 0x00, 0x03, 0x05, 0x05, 0x0D, 0x08, 0x00, 0x0D, 0x04, + 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x02, 0x08, 0x0C, 0x0C, 0x01, 0x03, + 0x04, 0x00, 0x04, 0x04, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, + 0x30, 0x31, 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, + 0x17, 0x15, 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, + 0xF5, 0xF5, 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, + 0x7D, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x05, 0x00, 0x09, 0x00, 0x23, 0x40, 0x15, 0x08, 0x00, 0x00, 0x06, + 0x00, 0x04, 0x04, 0x02, 0x06, 0x00, 0x02, 0x07, 0x02, 0x05, 0x01, 0x09, + 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, 0x3F, 0x3F, + 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, 0x21, 0x11, 0x07, + 0x23, 0x35, 0x33, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0xFA, 0x02, 0x71, 0xFD, + 0x8F, 0xFA, 0x01, 0x77, 0xFA, 0x7D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x21, 0x40, 0x14, 0x01, 0x00, + 0x06, 0x04, 0x08, 0x06, 0x09, 0x02, 0x03, 0x02, 0x02, 0x01, 0x05, 0x04, + 0x00, 0x07, 0x08, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x00, 0x3F, + 0x3F, 0x3F, 0x2B, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, 0x11, 0x21, + 0x15, 0x33, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0x7D, 0x02, 0x71, + 0xFA, 0xFA, 0xFE, 0x89, 0xFA, 0x02, 0x71, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0F, 0x00, 0x3E, 0x40, 0x24, + 0x0C, 0x00, 0x0E, 0x0A, 0x00, 0x08, 0x06, 0x00, 0x08, 0x02, 0x00, 0x05, + 0x04, 0x00, 0x00, 0x0E, 0x08, 0x06, 0x0E, 0x02, 0x0E, 0x01, 0x09, 0x01, + 0x07, 0x00, 0x05, 0x01, 0x0C, 0x01, 0x01, 0x04, 0x03, 0x01, 0x00, 0x04, + 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x11, 0x21, 0x15, 0x23, 0x15, 0x33, 0x15, 0x21, 0x15, 0x21, 0x35, 0x33, + 0x11, 0x23, 0x35, 0x21, 0x01, 0x77, 0xFA, 0xFA, 0xFE, 0x89, 0x01, 0x77, + 0x7D, 0x7D, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, + 0x77, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x37, 0x40, 0x22, 0x0E, 0x00, 0x0A, 0x0C, + 0x00, 0x04, 0x08, 0x00, 0x03, 0x04, 0x04, 0x06, 0x00, 0x06, 0x0A, 0x02, + 0x06, 0x02, 0x06, 0x01, 0x0F, 0x04, 0x03, 0x08, 0x0E, 0x01, 0x08, 0x04, + 0x01, 0x0A, 0x0A, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x30, + 0x31, 0x31, 0x33, 0x35, 0x33, 0x15, 0x21, 0x11, 0x21, 0x15, 0x23, 0x35, + 0x23, 0x01, 0x23, 0x11, 0x33, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, + 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0xFA, 0xFE, + 0x0C, 0x01, 0x77, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x23, 0x40, 0x15, 0x08, 0x00, + 0x00, 0x06, 0x00, 0x04, 0x04, 0x02, 0x06, 0x00, 0x02, 0x07, 0x02, 0x05, + 0x01, 0x09, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, 0x21, + 0x11, 0x07, 0x23, 0x35, 0x33, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0xFA, 0x02, + 0x71, 0xFD, 0x8F, 0xFA, 0x01, 0x77, 0xFA, 0x7D, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0F, 0x00, 0x3E, 0x40, 0x24, + 0x0C, 0x00, 0x0E, 0x0A, 0x00, 0x08, 0x06, 0x00, 0x08, 0x02, 0x00, 0x05, + 0x04, 0x00, 0x00, 0x0E, 0x08, 0x06, 0x0E, 0x02, 0x0E, 0x01, 0x09, 0x01, + 0x07, 0x00, 0x05, 0x01, 0x0C, 0x01, 0x01, 0x04, 0x03, 0x01, 0x00, 0x04, + 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x00, 0x3F, + 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x30, 0x31, + 0x11, 0x21, 0x15, 0x23, 0x15, 0x33, 0x15, 0x21, 0x15, 0x21, 0x35, 0x33, + 0x11, 0x23, 0x35, 0x21, 0x01, 0x77, 0xFA, 0xFA, 0xFE, 0x89, 0x01, 0x77, + 0x7D, 0x7D, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, + 0x77, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x37, 0x40, 0x22, 0x0E, 0x00, 0x0A, 0x0C, + 0x00, 0x04, 0x08, 0x00, 0x03, 0x04, 0x04, 0x06, 0x00, 0x06, 0x0A, 0x02, + 0x06, 0x02, 0x06, 0x01, 0x0F, 0x04, 0x03, 0x08, 0x0E, 0x01, 0x08, 0x04, + 0x01, 0x0A, 0x0A, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, + 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x30, + 0x31, 0x31, 0x33, 0x35, 0x33, 0x15, 0x21, 0x11, 0x21, 0x15, 0x23, 0x35, + 0x23, 0x01, 0x23, 0x11, 0x33, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, 0x0C, 0x7D, + 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0xFA, 0xFE, + 0x0C, 0x01, 0x77, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, + 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x23, 0x40, 0x15, 0x08, 0x00, + 0x00, 0x06, 0x00, 0x04, 0x04, 0x02, 0x06, 0x00, 0x02, 0x07, 0x02, 0x05, + 0x01, 0x09, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, 0x35, 0x21, + 0x11, 0x07, 0x23, 0x35, 0x33, 0x7D, 0x01, 0x77, 0x7D, 0xFA, 0xFA, 0x02, + 0x71, 0xFD, 0x8F, 0xFA, 0x01, 0x77, 0xFA, 0x7D, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x21, 0x40, 0x14, + 0x01, 0x00, 0x06, 0x04, 0x08, 0x06, 0x09, 0x02, 0x03, 0x02, 0x02, 0x01, + 0x05, 0x04, 0x00, 0x07, 0x08, 0x01, 0x07, 0x04, 0x2B, 0x10, 0xD0, 0x2B, + 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x30, 0x31, 0x01, 0x15, 0x23, 0x35, 0x23, + 0x11, 0x21, 0x15, 0x33, 0x11, 0x01, 0x77, 0xFA, 0x7D, 0x01, 0x77, 0x7D, + 0x02, 0x71, 0xFA, 0xFA, 0xFE, 0x89, 0xFA, 0x02, 0x71, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0F, 0x00, 0x3E, + 0x40, 0x24, 0x0C, 0x00, 0x0E, 0x0A, 0x00, 0x08, 0x06, 0x00, 0x08, 0x02, + 0x00, 0x05, 0x04, 0x00, 0x00, 0x0E, 0x08, 0x06, 0x0E, 0x02, 0x0E, 0x01, + 0x09, 0x01, 0x07, 0x00, 0x05, 0x01, 0x0C, 0x01, 0x01, 0x04, 0x03, 0x01, + 0x00, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x11, 0x21, 0x15, 0x23, 0x15, 0x33, 0x15, 0x21, 0x15, 0x21, + 0x35, 0x33, 0x11, 0x23, 0x35, 0x21, 0x01, 0x77, 0xFA, 0xFA, 0xFE, 0x89, + 0x01, 0x77, 0x7D, 0x7D, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x01, 0x77, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x37, 0x40, 0x22, 0x0E, 0x00, + 0x0A, 0x0C, 0x00, 0x04, 0x08, 0x00, 0x03, 0x04, 0x04, 0x06, 0x00, 0x06, + 0x0A, 0x02, 0x06, 0x02, 0x06, 0x01, 0x0F, 0x04, 0x03, 0x08, 0x0E, 0x01, + 0x08, 0x04, 0x01, 0x0A, 0x0A, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, + 0xFC, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, 0x15, 0x21, 0x11, 0x21, 0x15, + 0x23, 0x35, 0x23, 0x01, 0x23, 0x11, 0x33, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, + 0x0C, 0x7D, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFA, 0xFA, 0x02, 0x71, 0xFA, + 0xFA, 0xFE, 0x0C, 0x01, 0x77, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x05, 0x00, 0x09, 0x00, 0x23, 0x40, 0x15, + 0x08, 0x00, 0x00, 0x06, 0x00, 0x04, 0x04, 0x02, 0x06, 0x00, 0x02, 0x07, + 0x02, 0x05, 0x01, 0x09, 0x04, 0x02, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x30, 0x31, 0x19, 0x01, 0x33, + 0x35, 0x21, 0x11, 0x07, 0x23, 0x35, 0x33, 0x7D, 0x01, 0x77, 0x7D, 0xFA, + 0xFA, 0x02, 0x71, 0xFD, 0x8F, 0xFA, 0x01, 0x77, 0xFA, 0x7D, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, 0x00, 0x0F, 0x00, 0x3E, + 0x40, 0x24, 0x0C, 0x00, 0x0E, 0x0A, 0x00, 0x08, 0x06, 0x00, 0x08, 0x02, + 0x00, 0x05, 0x04, 0x00, 0x00, 0x0E, 0x08, 0x06, 0x0E, 0x02, 0x0E, 0x01, + 0x09, 0x01, 0x07, 0x00, 0x05, 0x01, 0x0C, 0x01, 0x01, 0x04, 0x03, 0x01, + 0x00, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, 0x10, 0xD0, + 0x00, 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x11, 0x21, 0x15, 0x23, 0x15, 0x33, 0x15, 0x21, 0x15, 0x21, + 0x35, 0x33, 0x11, 0x23, 0x35, 0x21, 0x01, 0x77, 0xFA, 0xFA, 0xFE, 0x89, + 0x01, 0x77, 0x7D, 0x7D, 0xFE, 0x89, 0x01, 0xF4, 0x7D, 0x7D, 0x7D, 0x7D, + 0x7D, 0x01, 0x77, 0x7D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0xEE, + 0x02, 0x71, 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x37, 0x40, 0x22, 0x0E, 0x00, + 0x0A, 0x0C, 0x00, 0x04, 0x08, 0x00, 0x03, 0x04, 0x04, 0x06, 0x00, 0x06, + 0x0A, 0x02, 0x06, 0x02, 0x06, 0x01, 0x0F, 0x04, 0x03, 0x08, 0x0E, 0x01, + 0x08, 0x04, 0x01, 0x0A, 0x0A, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, + 0x10, 0xD0, 0x2B, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xFC, 0x10, + 0xFC, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, 0x15, 0x21, 0x11, 0x21, 0x15, + 0x23, 0x35, 0x23, 0x01, 0x23, 0x11, 0x33, 0x7D, 0x7D, 0x01, 0xF4, 0xFE, + 0x0C, 0x7D, 0x7D, 0x02, 0x71, 0xFA, 0xFA, 0xFA, 0xFA, 0x02, 0x71, 0xFA, + 0xFA, 0xFE, 0x0C, 0x01, 0x77, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xF4, 0x02, 0x71, 0x00, 0x09, 0x00, 0x0D, 0x00, 0x32, 0x40, 0x1D, + 0x0B, 0x00, 0x03, 0x05, 0x05, 0x0D, 0x08, 0x00, 0x0D, 0x04, 0x00, 0x00, + 0x01, 0x03, 0x06, 0x01, 0x02, 0x08, 0x0C, 0x0C, 0x01, 0x03, 0x04, 0x00, + 0x04, 0x04, 0x01, 0x0B, 0x04, 0x2B, 0x10, 0xD0, 0x2B, 0x10, 0xD0, 0x00, + 0x3F, 0x3F, 0x10, 0xFC, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x30, 0x31, + 0x01, 0x35, 0x21, 0x11, 0x21, 0x35, 0x23, 0x35, 0x23, 0x35, 0x17, 0x15, + 0x23, 0x35, 0x01, 0xF4, 0xFE, 0x0C, 0x01, 0xF4, 0x7D, 0xFA, 0xF5, 0xF5, + 0x01, 0xF4, 0x7D, 0xFD, 0x8F, 0xFA, 0x7D, 0x7D, 0xFA, 0x7D, 0x7D, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x71, 0x02, 0x71, 0x00, 0x09, + 0x00, 0x0D, 0x00, 0x2E, 0x40, 0x1B, 0x0B, 0x00, 0x03, 0x0A, 0x00, 0x07, + 0x05, 0x00, 0x03, 0x01, 0x00, 0x03, 0x00, 0x00, 0x07, 0x03, 0x06, 0x07, + 0x02, 0x06, 0x01, 0x0B, 0x04, 0x0C, 0x01, 0x01, 0x04, 0x2B, 0x2B, 0x00, + 0x3F, 0x3F, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, 0x10, 0xFC, + 0x30, 0x31, 0x13, 0x11, 0x23, 0x15, 0x21, 0x35, 0x23, 0x11, 0x21, 0x15, + 0x33, 0x11, 0x23, 0x11, 0x3F, 0x3F, 0x02, 0x71, 0x3E, 0xFE, 0x89, 0xFA, + 0xF5, 0x01, 0xF4, 0xFE, 0x89, 0x7D, 0x7D, 0x01, 0xF4, 0x7D, 0xFE, 0x89, + 0x01, 0x77, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x02, 0x71, + 0x00, 0x0B, 0x00, 0x0F, 0x00, 0x3A, 0x40, 0x21, 0x0E, 0x0E, 0x08, 0x0C, + 0x00, 0x06, 0x02, 0x02, 0x0B, 0x08, 0x00, 0x0B, 0x04, 0x05, 0x06, 0x00, + 0x06, 0x06, 0x02, 0x0C, 0x02, 0x07, 0x0B, 0x03, 0x0D, 0x06, 0x01, 0x0D, + 0x04, 0x02, 0x01, 0x0B, 0x04, 0x2B, 0x2B, 0x10, 0xD0, 0x10, 0xD0, 0x10, + 0xD0, 0x00, 0x3F, 0x3F, 0x3F, 0x2B, 0x10, 0xD0, 0x2F, 0x10, 0xFC, 0x10, + 0xD0, 0x2F, 0x30, 0x31, 0x31, 0x33, 0x35, 0x33, 0x15, 0x33, 0x11, 0x21, + 0x15, 0x33, 0x15, 0x23, 0x37, 0x33, 0x15, 0x23, 0x82, 0xF5, 0x7D, 0xFE, + 0x0C, 0x7D, 0x7D, 0x82, 0xF5, 0xF5, 0xFA, 0xFA, 0x02, 0x71, 0xFA, 0x7D, + 0xFA, 0x7D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x44, + 0x09, 0x10, 0x05, 0x00, 0x05, 0x01, 0x07, 0x05, 0x06, 0x07, 0x02, 0x03, + 0x03, 0x07, 0x07, 0x02, 0x05, 0x02, 0x03, 0x06, 0x03, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x05, 0x06, 0x06, 0x02, 0x02, 0x05, 0x06, 0x05, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x02, 0x05, 0x06, 0x05, + 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x07, 0x06, + 0x06, 0x06, 0x03, 0x03, 0x03, 0x05, 0x07, 0x03, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x02, 0x05, 0x06, 0x05, 0x07, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x07, 0x06, 0x06, 0x06, 0x05, 0x02, + 0x05, 0x06, 0x05, 0x05, 0x05, 0x06, 0x05, 0x02, 0x07, 0x06, 0x06, 0x08, + 0x03, 0x05, 0x07, 0x0E, 0x05, 0x05, 0x06, 0x02, 0x07, 0x07, 0x07, 0x07, + 0x01, 0x05, 0x06, 0x05, 0x05, 0x02, 0x02, 0x03, 0x05, 0x02, 0x02, 0x05, + 0x07, 0x05, 0x05, 0x07, 0x07, 0x07, 0x07, 0x06, 0x07, 0x05, 0x03, 0x02, + 0x03, 0x05, 0x06, 0x06, 0x06, 0x05, 0x07, 0x06, 0x07, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x07, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x07, 0x06, 0x06, + 0x07, 0x07, 0x06, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x07, 0x06, + 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x06, 0x07, 0x06, 0x06, 0x06, 0x07, 0x07, 0x06, 0x08, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x05, 0x07, 0x06, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, + 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x07, 0x06, 0x06, 0x07, 0x07, 0x06, + 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x07, 0x06, 0x07, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x07, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x07, 0x06, + 0x06, 0x06, 0x07, 0x07, 0x06, 0x08, 0x06, 0x06, 0x06, 0x02, 0x02, 0x05, + 0x02, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x0E, 0x06, 0x06, 0x06, 0x06, 0x03, 0x03, 0x05, 0x05, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x09, 0x07, + 0x05, 0x09, 0x07, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x05, 0x03, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x02, 0x06, 0x06, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x05, 0x07, 0x06, 0x06, 0x05, 0x10, 0x07, 0x05, 0x07, 0x08, 0x05, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x07, 0x06, 0x06, + 0x06, 0x05, 0x07, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x06, 0x06, + 0x06, 0x08, 0x06, 0x08, 0x06, 0x06, 0x07, 0x06, 0x06, 0x06, 0x05, 0x07, + 0x06, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x05, 0x06, 0x07, 0x06, 0x06, 0x06, 0x07, 0x07, 0x06, 0x08, 0x06, + 0x06, 0x08, 0x06, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x08, 0x08, 0x02, + 0x02, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x05, 0x05, 0x08, 0x08, 0x06, + 0x06, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x06, + 0x06, 0x07, 0x06, 0x06, 0x06, 0x05, 0x06, 0x07, 0x06, 0x07, 0x06, 0x08, + 0x07, 0x06, 0x07, 0x06, 0x06, 0x06, 0x05, 0x06, 0x07, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x07, 0x06, + 0x06, 0x06, 0x07, 0x07, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x06, 0x06, + 0x05, 0x07, 0x06, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x05, 0x06, 0x07, 0x06, 0x06, 0x06, 0x07, 0x07, 0x06, + 0x08, 0x06, 0x06, 0x08, 0x06, 0x06, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x06, 0x06, 0x02, 0x05, 0x05, 0x08, 0x08, 0x06, 0x06, 0x08, 0x08, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x07, 0x06, 0x06, 0x06, 0x06, + 0x08, 0x06, 0x06, 0x08, 0x06, 0x06, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, + 0x07, 0x06, 0x00, 0x00, 0x0A, 0x12, 0x05, 0x00, 0x05, 0x01, 0x08, 0x05, + 0x06, 0x08, 0x03, 0x04, 0x04, 0x08, 0x08, 0x03, 0x05, 0x03, 0x04, 0x06, + 0x04, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x03, 0x03, 0x05, + 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x03, 0x05, 0x06, 0x05, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x06, 0x06, 0x08, 0x06, 0x06, 0x06, 0x04, 0x04, 0x04, 0x05, 0x08, 0x04, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x03, 0x05, 0x06, 0x05, + 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x08, 0x06, + 0x06, 0x06, 0x05, 0x03, 0x05, 0x06, 0x05, 0x05, 0x05, 0x06, 0x05, 0x03, + 0x08, 0x06, 0x06, 0x09, 0x04, 0x05, 0x08, 0x0F, 0x05, 0x05, 0x06, 0x03, + 0x08, 0x08, 0x08, 0x08, 0x01, 0x05, 0x06, 0x05, 0x05, 0x03, 0x03, 0x04, + 0x05, 0x03, 0x03, 0x05, 0x08, 0x05, 0x05, 0x08, 0x08, 0x08, 0x08, 0x06, + 0x08, 0x05, 0x04, 0x03, 0x04, 0x05, 0x06, 0x06, 0x06, 0x05, 0x08, 0x06, + 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x08, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x06, 0x08, 0x06, 0x07, 0x08, 0x08, 0x07, 0x09, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x05, 0x08, 0x06, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x08, 0x06, + 0x06, 0x06, 0x06, 0x05, 0x06, 0x08, 0x06, 0x07, 0x06, 0x08, 0x08, 0x07, + 0x09, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x08, 0x06, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x08, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x08, 0x06, + 0x07, 0x08, 0x08, 0x07, 0x09, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x08, + 0x06, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x08, 0x06, 0x06, 0x06, 0x06, + 0x05, 0x06, 0x08, 0x06, 0x07, 0x06, 0x08, 0x08, 0x07, 0x09, 0x06, 0x06, + 0x06, 0x03, 0x03, 0x05, 0x03, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x0F, 0x06, 0x06, 0x06, 0x06, 0x04, + 0x04, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x0A, 0x08, 0x05, 0x0A, 0x08, 0x06, 0x06, 0x06, 0x05, 0x06, + 0x06, 0x05, 0x04, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x03, 0x06, 0x06, 0x08, 0x08, 0x06, + 0x06, 0x06, 0x06, 0x05, 0x05, 0x08, 0x06, 0x06, 0x05, 0x12, 0x08, 0x05, + 0x08, 0x09, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x05, 0x08, 0x06, 0x06, 0x06, 0x05, 0x08, 0x06, 0x06, 0x06, 0x06, 0x08, + 0x08, 0x08, 0x06, 0x06, 0x07, 0x09, 0x06, 0x09, 0x06, 0x07, 0x08, 0x06, + 0x06, 0x06, 0x05, 0x08, 0x06, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x08, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x08, 0x06, 0x07, 0x06, 0x08, + 0x08, 0x07, 0x09, 0x06, 0x06, 0x09, 0x06, 0x05, 0x05, 0x06, 0x06, 0x06, + 0x06, 0x09, 0x09, 0x03, 0x03, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x05, 0x09, 0x09, 0x06, 0x06, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x06, 0x06, 0x05, 0x06, 0x08, + 0x06, 0x08, 0x07, 0x09, 0x08, 0x06, 0x08, 0x06, 0x06, 0x06, 0x05, 0x06, + 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x05, 0x06, 0x08, 0x06, 0x07, 0x06, 0x08, 0x08, 0x07, 0x09, 0x06, 0x06, + 0x09, 0x06, 0x06, 0x06, 0x05, 0x08, 0x06, 0x08, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x08, 0x06, 0x07, + 0x06, 0x08, 0x08, 0x07, 0x09, 0x06, 0x06, 0x09, 0x06, 0x06, 0x06, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x03, 0x05, 0x05, 0x09, 0x09, + 0x06, 0x06, 0x09, 0x09, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x08, + 0x06, 0x06, 0x06, 0x06, 0x09, 0x06, 0x06, 0x09, 0x06, 0x06, 0x06, 0x09, + 0x06, 0x06, 0x09, 0x06, 0x08, 0x06, 0x00, 0x00, 0x0B, 0x13, 0x06, 0x00, + 0x06, 0x01, 0x08, 0x06, 0x07, 0x08, 0x03, 0x04, 0x04, 0x08, 0x08, 0x03, + 0x06, 0x03, 0x04, 0x07, 0x04, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x07, + 0x07, 0x03, 0x03, 0x06, 0x07, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x03, 0x06, 0x07, 0x06, 0x08, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x06, 0x07, 0x07, 0x08, 0x07, 0x07, 0x07, 0x04, 0x04, + 0x04, 0x06, 0x08, 0x04, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x03, 0x06, 0x07, 0x06, 0x08, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, + 0x07, 0x07, 0x08, 0x07, 0x07, 0x07, 0x06, 0x03, 0x06, 0x07, 0x06, 0x06, + 0x06, 0x07, 0x06, 0x03, 0x08, 0x07, 0x07, 0x0A, 0x04, 0x06, 0x08, 0x11, + 0x06, 0x06, 0x07, 0x03, 0x08, 0x08, 0x08, 0x08, 0x01, 0x06, 0x07, 0x06, + 0x06, 0x03, 0x03, 0x04, 0x06, 0x03, 0x03, 0x06, 0x08, 0x06, 0x06, 0x08, + 0x08, 0x08, 0x08, 0x07, 0x08, 0x06, 0x04, 0x03, 0x04, 0x06, 0x07, 0x07, + 0x07, 0x06, 0x08, 0x07, 0x08, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, + 0x07, 0x07, 0x07, 0x06, 0x07, 0x08, 0x07, 0x08, 0x08, 0x09, 0x08, 0x0A, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x08, 0x07, 0x08, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x08, 0x07, 0x07, 0x07, 0x07, 0x06, 0x07, 0x08, 0x07, 0x08, + 0x07, 0x08, 0x09, 0x08, 0x0A, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x08, + 0x07, 0x08, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x07, 0x07, + 0x06, 0x07, 0x08, 0x07, 0x08, 0x08, 0x09, 0x08, 0x0A, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x06, 0x08, 0x07, 0x08, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, + 0x07, 0x07, 0x07, 0x07, 0x06, 0x07, 0x08, 0x07, 0x08, 0x07, 0x08, 0x09, + 0x08, 0x0A, 0x07, 0x07, 0x07, 0x03, 0x03, 0x06, 0x03, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x11, 0x07, + 0x07, 0x07, 0x07, 0x04, 0x04, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0B, 0x08, 0x06, 0x0B, 0x08, 0x07, + 0x07, 0x07, 0x06, 0x07, 0x07, 0x06, 0x04, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x07, + 0x07, 0x08, 0x08, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x08, 0x07, 0x07, + 0x06, 0x13, 0x08, 0x06, 0x08, 0x0A, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x06, 0x08, 0x07, 0x07, 0x07, 0x06, 0x08, 0x07, + 0x07, 0x07, 0x07, 0x08, 0x08, 0x09, 0x07, 0x07, 0x08, 0x0A, 0x07, 0x0A, + 0x07, 0x08, 0x08, 0x07, 0x07, 0x07, 0x06, 0x08, 0x07, 0x08, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x07, 0x08, + 0x07, 0x08, 0x07, 0x08, 0x09, 0x08, 0x0A, 0x07, 0x07, 0x0A, 0x07, 0x06, + 0x06, 0x07, 0x07, 0x07, 0x07, 0x0A, 0x0A, 0x03, 0x03, 0x06, 0x06, 0x07, + 0x07, 0x07, 0x07, 0x06, 0x06, 0x0A, 0x0A, 0x07, 0x07, 0x06, 0x06, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x08, 0x07, 0x07, + 0x07, 0x06, 0x07, 0x08, 0x07, 0x09, 0x08, 0x0A, 0x08, 0x07, 0x08, 0x07, + 0x07, 0x07, 0x06, 0x07, 0x08, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x06, 0x07, 0x08, 0x07, 0x08, 0x07, 0x08, 0x09, + 0x08, 0x0A, 0x07, 0x07, 0x0A, 0x07, 0x07, 0x07, 0x06, 0x08, 0x07, 0x08, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, + 0x07, 0x08, 0x07, 0x08, 0x07, 0x08, 0x09, 0x08, 0x0A, 0x07, 0x07, 0x0A, + 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x03, + 0x06, 0x06, 0x0A, 0x0A, 0x07, 0x07, 0x0A, 0x0A, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x07, + 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x07, 0x07, 0x0A, 0x07, 0x07, 0x0A, + 0x07, 0x07, 0x07, 0x0A, 0x07, 0x07, 0x0A, 0x07, 0x08, 0x07, 0x00, 0x00, + 0x0C, 0x15, 0x06, 0x00, 0x06, 0x02, 0x09, 0x06, 0x08, 0x09, 0x03, 0x05, + 0x05, 0x09, 0x09, 0x03, 0x06, 0x03, 0x05, 0x08, 0x05, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x06, 0x08, 0x08, 0x03, 0x03, 0x06, 0x08, 0x06, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x03, 0x06, 0x08, 0x06, + 0x09, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x06, 0x08, 0x08, 0x09, 0x08, + 0x08, 0x08, 0x05, 0x05, 0x05, 0x06, 0x09, 0x05, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x03, 0x06, 0x08, 0x06, 0x09, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x06, 0x08, 0x08, 0x09, 0x08, 0x08, 0x08, 0x06, 0x03, + 0x06, 0x08, 0x06, 0x06, 0x06, 0x08, 0x06, 0x03, 0x09, 0x08, 0x08, 0x0B, + 0x05, 0x06, 0x09, 0x12, 0x06, 0x06, 0x08, 0x03, 0x09, 0x09, 0x09, 0x09, + 0x02, 0x06, 0x08, 0x06, 0x06, 0x03, 0x03, 0x05, 0x06, 0x03, 0x03, 0x06, + 0x09, 0x06, 0x06, 0x09, 0x09, 0x09, 0x09, 0x08, 0x09, 0x06, 0x05, 0x03, + 0x05, 0x06, 0x08, 0x08, 0x08, 0x06, 0x09, 0x08, 0x09, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x09, 0x08, 0x08, 0x08, 0x08, 0x06, 0x08, 0x09, 0x08, 0x08, + 0x09, 0x0A, 0x08, 0x0B, 0x08, 0x08, 0x08, 0x08, 0x08, 0x06, 0x09, 0x08, + 0x09, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x08, 0x08, 0x08, 0x08, 0x06, + 0x08, 0x09, 0x08, 0x08, 0x08, 0x09, 0x0A, 0x08, 0x0B, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x06, 0x09, 0x08, 0x09, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, + 0x08, 0x08, 0x08, 0x08, 0x06, 0x08, 0x09, 0x08, 0x08, 0x09, 0x0A, 0x08, + 0x0B, 0x08, 0x08, 0x08, 0x08, 0x08, 0x06, 0x09, 0x08, 0x09, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x09, 0x08, 0x08, 0x08, 0x08, 0x06, 0x08, 0x09, 0x08, + 0x08, 0x08, 0x09, 0x0A, 0x08, 0x0B, 0x08, 0x08, 0x08, 0x03, 0x03, 0x06, + 0x03, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x12, 0x08, 0x08, 0x08, 0x08, 0x05, 0x05, 0x06, 0x06, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0C, 0x09, + 0x06, 0x0C, 0x09, 0x08, 0x08, 0x08, 0x06, 0x08, 0x08, 0x06, 0x05, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x03, 0x08, 0x08, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x06, + 0x06, 0x09, 0x08, 0x08, 0x06, 0x15, 0x09, 0x06, 0x09, 0x0B, 0x06, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x06, 0x09, 0x08, 0x08, + 0x08, 0x06, 0x09, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x0A, 0x08, 0x08, + 0x08, 0x0B, 0x08, 0x0B, 0x08, 0x08, 0x09, 0x08, 0x08, 0x08, 0x06, 0x09, + 0x08, 0x09, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x06, 0x08, 0x09, 0x08, 0x08, 0x08, 0x09, 0x0A, 0x08, 0x0B, 0x08, + 0x08, 0x0B, 0x08, 0x06, 0x06, 0x08, 0x08, 0x08, 0x08, 0x0B, 0x0B, 0x03, + 0x03, 0x06, 0x06, 0x08, 0x08, 0x08, 0x08, 0x06, 0x06, 0x0B, 0x0B, 0x08, + 0x08, 0x06, 0x06, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x08, + 0x08, 0x09, 0x08, 0x08, 0x08, 0x06, 0x08, 0x09, 0x08, 0x0A, 0x08, 0x0B, + 0x09, 0x08, 0x09, 0x08, 0x08, 0x08, 0x06, 0x08, 0x09, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x09, 0x08, 0x08, 0x08, 0x08, 0x08, 0x06, 0x08, 0x09, 0x08, + 0x08, 0x08, 0x09, 0x0A, 0x08, 0x0B, 0x08, 0x08, 0x0B, 0x08, 0x08, 0x08, + 0x06, 0x09, 0x08, 0x09, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x06, 0x08, 0x09, 0x08, 0x08, 0x08, 0x09, 0x0A, 0x08, + 0x0B, 0x08, 0x08, 0x0B, 0x08, 0x08, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x08, 0x08, 0x03, 0x06, 0x06, 0x0B, 0x0B, 0x08, 0x08, 0x0B, 0x0B, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x06, 0x08, 0x08, 0x08, 0x08, 0x09, 0x08, 0x08, 0x08, 0x08, + 0x0B, 0x08, 0x08, 0x0B, 0x08, 0x08, 0x08, 0x0B, 0x08, 0x08, 0x0B, 0x08, + 0x09, 0x08, 0x00, 0x00, 0x0D, 0x17, 0x07, 0x00, 0x07, 0x02, 0x0A, 0x07, + 0x08, 0x0A, 0x03, 0x05, 0x05, 0x0A, 0x0A, 0x03, 0x07, 0x03, 0x05, 0x08, + 0x05, 0x08, 0x08, 0x08, 0x08, 0x08, 0x07, 0x08, 0x08, 0x03, 0x03, 0x07, + 0x08, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x03, 0x07, 0x08, 0x07, 0x0A, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x07, + 0x08, 0x08, 0x0A, 0x08, 0x08, 0x08, 0x05, 0x05, 0x05, 0x07, 0x0A, 0x05, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x03, 0x07, 0x08, 0x07, + 0x0A, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x07, 0x08, 0x08, 0x0A, 0x08, + 0x08, 0x08, 0x07, 0x03, 0x07, 0x08, 0x07, 0x07, 0x07, 0x08, 0x07, 0x03, + 0x0A, 0x08, 0x08, 0x0B, 0x05, 0x07, 0x0A, 0x14, 0x07, 0x07, 0x08, 0x03, + 0x0A, 0x0A, 0x0A, 0x0A, 0x02, 0x07, 0x08, 0x07, 0x07, 0x03, 0x03, 0x05, + 0x07, 0x03, 0x03, 0x07, 0x0A, 0x07, 0x07, 0x0A, 0x0A, 0x0A, 0x0A, 0x08, + 0x0A, 0x07, 0x05, 0x03, 0x05, 0x07, 0x08, 0x08, 0x08, 0x07, 0x0A, 0x08, + 0x0A, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0A, 0x08, 0x08, 0x08, 0x08, 0x07, + 0x08, 0x0A, 0x08, 0x09, 0x0A, 0x0B, 0x09, 0x0B, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x07, 0x0A, 0x08, 0x0A, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0A, 0x08, + 0x08, 0x08, 0x08, 0x07, 0x08, 0x0A, 0x08, 0x09, 0x08, 0x0A, 0x0B, 0x09, + 0x0B, 0x08, 0x08, 0x08, 0x08, 0x08, 0x07, 0x0A, 0x08, 0x0A, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x0A, 0x08, 0x08, 0x08, 0x08, 0x07, 0x08, 0x0A, 0x08, + 0x09, 0x0A, 0x0B, 0x09, 0x0B, 0x08, 0x08, 0x08, 0x08, 0x08, 0x07, 0x0A, + 0x08, 0x0A, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0A, 0x08, 0x08, 0x08, 0x08, + 0x07, 0x08, 0x0A, 0x08, 0x09, 0x08, 0x0A, 0x0B, 0x09, 0x0B, 0x08, 0x08, + 0x08, 0x03, 0x03, 0x07, 0x03, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x14, 0x08, 0x08, 0x08, 0x08, 0x05, + 0x05, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x0D, 0x0A, 0x07, 0x0D, 0x0A, 0x08, 0x08, 0x08, 0x07, 0x08, + 0x08, 0x07, 0x05, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x03, 0x08, 0x08, 0x0A, 0x0A, 0x08, + 0x08, 0x08, 0x08, 0x07, 0x07, 0x0A, 0x08, 0x08, 0x07, 0x17, 0x0A, 0x07, + 0x0A, 0x0B, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x07, 0x0A, 0x08, 0x08, 0x08, 0x07, 0x0A, 0x08, 0x08, 0x08, 0x08, 0x0A, + 0x0A, 0x0B, 0x08, 0x08, 0x09, 0x0B, 0x08, 0x0B, 0x08, 0x09, 0x0A, 0x08, + 0x08, 0x08, 0x07, 0x0A, 0x08, 0x0A, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0A, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x07, 0x08, 0x0A, 0x08, 0x09, 0x08, 0x0A, + 0x0B, 0x09, 0x0B, 0x08, 0x08, 0x0B, 0x08, 0x07, 0x07, 0x08, 0x08, 0x08, + 0x08, 0x0B, 0x0B, 0x03, 0x03, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x07, + 0x07, 0x0B, 0x0B, 0x08, 0x08, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x0A, 0x08, 0x08, 0x0A, 0x08, 0x08, 0x08, 0x07, 0x08, 0x0A, + 0x08, 0x0B, 0x09, 0x0B, 0x0A, 0x08, 0x0A, 0x08, 0x08, 0x08, 0x07, 0x08, + 0x0A, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0A, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x07, 0x08, 0x0A, 0x08, 0x09, 0x08, 0x0A, 0x0B, 0x09, 0x0B, 0x08, 0x08, + 0x0B, 0x08, 0x08, 0x08, 0x07, 0x0A, 0x08, 0x0A, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x0A, 0x08, 0x08, 0x08, 0x08, 0x08, 0x07, 0x08, 0x0A, 0x08, 0x09, + 0x08, 0x0A, 0x0B, 0x09, 0x0B, 0x08, 0x08, 0x0B, 0x08, 0x08, 0x08, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x03, 0x07, 0x07, 0x0B, 0x0B, + 0x08, 0x08, 0x0B, 0x0B, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x07, 0x08, 0x08, 0x08, 0x08, 0x0A, + 0x08, 0x08, 0x08, 0x08, 0x0B, 0x08, 0x08, 0x0B, 0x08, 0x08, 0x08, 0x0B, + 0x08, 0x08, 0x0B, 0x08, 0x0A, 0x08, 0x00, 0x00, 0x0E, 0x19, 0x07, 0x00, + 0x07, 0x02, 0x0B, 0x07, 0x09, 0x0B, 0x04, 0x05, 0x05, 0x0B, 0x0B, 0x04, + 0x07, 0x04, 0x05, 0x09, 0x05, 0x09, 0x09, 0x09, 0x09, 0x09, 0x07, 0x09, + 0x09, 0x04, 0x04, 0x07, 0x09, 0x07, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x04, 0x07, 0x09, 0x07, 0x0B, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x07, 0x09, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x05, 0x05, + 0x05, 0x07, 0x0B, 0x05, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x04, 0x07, 0x09, 0x07, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x07, + 0x09, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x07, 0x04, 0x07, 0x09, 0x07, 0x07, + 0x07, 0x09, 0x07, 0x04, 0x0B, 0x09, 0x09, 0x0C, 0x05, 0x07, 0x0B, 0x15, + 0x07, 0x07, 0x09, 0x04, 0x0B, 0x0B, 0x0B, 0x0B, 0x02, 0x07, 0x09, 0x07, + 0x07, 0x04, 0x04, 0x05, 0x07, 0x04, 0x04, 0x07, 0x0B, 0x07, 0x07, 0x0B, + 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x07, 0x05, 0x04, 0x05, 0x07, 0x09, 0x09, + 0x09, 0x07, 0x0B, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0B, 0x09, + 0x09, 0x09, 0x09, 0x07, 0x09, 0x0B, 0x09, 0x0A, 0x0B, 0x0B, 0x0A, 0x0C, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x07, 0x0B, 0x09, 0x0B, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x07, 0x09, 0x0B, 0x09, 0x0A, + 0x09, 0x0B, 0x0B, 0x0A, 0x0C, 0x09, 0x09, 0x09, 0x09, 0x09, 0x07, 0x0B, + 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, + 0x07, 0x09, 0x0B, 0x09, 0x0A, 0x0B, 0x0B, 0x0A, 0x0C, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x07, 0x0B, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0B, + 0x09, 0x09, 0x09, 0x09, 0x07, 0x09, 0x0B, 0x09, 0x0A, 0x09, 0x0B, 0x0B, + 0x0A, 0x0C, 0x09, 0x09, 0x09, 0x04, 0x04, 0x07, 0x04, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x15, 0x09, + 0x09, 0x09, 0x09, 0x05, 0x05, 0x07, 0x07, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0E, 0x0B, 0x07, 0x0E, 0x0B, 0x09, + 0x09, 0x09, 0x07, 0x09, 0x09, 0x07, 0x05, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x04, 0x09, + 0x09, 0x0B, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x07, 0x07, 0x0B, 0x09, 0x09, + 0x07, 0x19, 0x0B, 0x07, 0x0B, 0x0C, 0x07, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x07, 0x0B, 0x09, 0x09, 0x09, 0x07, 0x0B, 0x09, + 0x09, 0x09, 0x09, 0x0B, 0x0B, 0x0B, 0x09, 0x09, 0x0A, 0x0C, 0x09, 0x0C, + 0x09, 0x0A, 0x0B, 0x09, 0x09, 0x09, 0x07, 0x0B, 0x09, 0x0B, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x09, 0x07, 0x09, 0x0B, + 0x09, 0x0A, 0x09, 0x0B, 0x0B, 0x0A, 0x0C, 0x09, 0x09, 0x0C, 0x09, 0x07, + 0x07, 0x09, 0x09, 0x09, 0x09, 0x0C, 0x0C, 0x04, 0x04, 0x07, 0x07, 0x09, + 0x09, 0x09, 0x09, 0x07, 0x07, 0x0C, 0x0C, 0x09, 0x09, 0x07, 0x07, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0B, 0x09, 0x09, 0x0B, 0x09, 0x09, + 0x09, 0x07, 0x09, 0x0B, 0x09, 0x0B, 0x0A, 0x0C, 0x0B, 0x09, 0x0B, 0x09, + 0x09, 0x09, 0x07, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0B, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x07, 0x09, 0x0B, 0x09, 0x0A, 0x09, 0x0B, 0x0B, + 0x0A, 0x0C, 0x09, 0x09, 0x0C, 0x09, 0x09, 0x09, 0x07, 0x0B, 0x09, 0x0B, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x09, 0x07, + 0x09, 0x0B, 0x09, 0x0A, 0x09, 0x0B, 0x0B, 0x0A, 0x0C, 0x09, 0x09, 0x0C, + 0x09, 0x09, 0x09, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x09, 0x09, 0x04, + 0x07, 0x07, 0x0C, 0x0C, 0x09, 0x09, 0x0C, 0x0C, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x07, 0x09, + 0x09, 0x09, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x0C, 0x09, 0x09, 0x0C, + 0x09, 0x09, 0x09, 0x0C, 0x09, 0x09, 0x0C, 0x09, 0x0B, 0x09, 0x00, 0x00, + 0x0F, 0x1A, 0x08, 0x00, 0x08, 0x02, 0x0B, 0x08, 0x09, 0x0B, 0x04, 0x06, + 0x06, 0x0B, 0x0B, 0x04, 0x08, 0x04, 0x06, 0x09, 0x06, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x08, 0x09, 0x09, 0x04, 0x04, 0x08, 0x09, 0x08, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x04, 0x08, 0x09, 0x08, + 0x0B, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x08, 0x09, 0x09, 0x0B, 0x09, + 0x09, 0x09, 0x06, 0x06, 0x06, 0x08, 0x0B, 0x06, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x04, 0x08, 0x09, 0x08, 0x0B, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x08, 0x09, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x08, 0x04, + 0x08, 0x09, 0x08, 0x08, 0x08, 0x09, 0x08, 0x04, 0x0B, 0x09, 0x09, 0x0D, + 0x06, 0x08, 0x0B, 0x17, 0x08, 0x08, 0x09, 0x04, 0x0B, 0x0B, 0x0B, 0x0B, + 0x02, 0x08, 0x09, 0x08, 0x08, 0x04, 0x04, 0x06, 0x08, 0x04, 0x04, 0x08, + 0x0B, 0x08, 0x08, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x08, 0x06, 0x04, + 0x06, 0x08, 0x09, 0x09, 0x09, 0x08, 0x0B, 0x09, 0x0B, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x08, 0x09, 0x0B, 0x09, 0x0A, + 0x0B, 0x0C, 0x0A, 0x0D, 0x09, 0x09, 0x09, 0x09, 0x09, 0x08, 0x0B, 0x09, + 0x0B, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x08, + 0x09, 0x0B, 0x09, 0x0A, 0x09, 0x0B, 0x0C, 0x0A, 0x0D, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x08, 0x0B, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0B, + 0x09, 0x09, 0x09, 0x09, 0x08, 0x09, 0x0B, 0x09, 0x0A, 0x0B, 0x0C, 0x0A, + 0x0D, 0x09, 0x09, 0x09, 0x09, 0x09, 0x08, 0x0B, 0x09, 0x0B, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x08, 0x09, 0x0B, 0x09, + 0x0A, 0x09, 0x0B, 0x0C, 0x0A, 0x0D, 0x09, 0x09, 0x09, 0x04, 0x04, 0x08, + 0x04, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x17, 0x09, 0x09, 0x09, 0x09, 0x06, 0x06, 0x08, 0x08, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0F, 0x0B, + 0x08, 0x0F, 0x0B, 0x09, 0x09, 0x09, 0x08, 0x09, 0x09, 0x08, 0x06, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x04, 0x09, 0x09, 0x0B, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x08, + 0x08, 0x0B, 0x09, 0x09, 0x08, 0x1A, 0x0B, 0x08, 0x0B, 0x0D, 0x08, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x08, 0x0B, 0x09, 0x09, + 0x09, 0x08, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x0B, 0x0B, 0x0C, 0x09, 0x09, + 0x0A, 0x0D, 0x09, 0x0D, 0x09, 0x0A, 0x0B, 0x09, 0x09, 0x09, 0x08, 0x0B, + 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x08, 0x09, 0x0B, 0x09, 0x0A, 0x09, 0x0B, 0x0C, 0x0A, 0x0D, 0x09, + 0x09, 0x0D, 0x09, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x0D, 0x0D, 0x04, + 0x04, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x08, 0x08, 0x0D, 0x0D, 0x09, + 0x09, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0B, 0x09, + 0x09, 0x0B, 0x09, 0x09, 0x09, 0x08, 0x09, 0x0B, 0x09, 0x0C, 0x0A, 0x0D, + 0x0B, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x08, 0x09, 0x0B, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x09, 0x08, 0x09, 0x0B, 0x09, + 0x0A, 0x09, 0x0B, 0x0C, 0x0A, 0x0D, 0x09, 0x09, 0x0D, 0x09, 0x09, 0x09, + 0x08, 0x0B, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0B, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x08, 0x09, 0x0B, 0x09, 0x0A, 0x09, 0x0B, 0x0C, 0x0A, + 0x0D, 0x09, 0x09, 0x0D, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x09, 0x09, 0x04, 0x08, 0x08, 0x0D, 0x0D, 0x09, 0x09, 0x0D, 0x0D, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x08, 0x09, 0x09, 0x09, 0x09, 0x0B, 0x09, 0x09, 0x09, 0x09, + 0x0D, 0x09, 0x09, 0x0D, 0x09, 0x09, 0x09, 0x0D, 0x09, 0x09, 0x0D, 0x09, + 0x0B, 0x09, 0x00, 0x00, 0x10, 0x1C, 0x08, 0x00, 0x08, 0x02, 0x0C, 0x08, + 0x0A, 0x0C, 0x04, 0x06, 0x06, 0x0C, 0x0C, 0x04, 0x08, 0x04, 0x06, 0x0A, + 0x06, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x08, 0x0A, 0x0A, 0x04, 0x04, 0x08, + 0x0A, 0x08, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x04, 0x08, 0x0A, 0x08, 0x0C, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x08, + 0x0A, 0x0A, 0x0C, 0x0A, 0x0A, 0x0A, 0x06, 0x06, 0x06, 0x08, 0x0C, 0x06, + 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x04, 0x08, 0x0A, 0x08, + 0x0C, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x08, 0x0A, 0x0A, 0x0C, 0x0A, + 0x0A, 0x0A, 0x08, 0x04, 0x08, 0x0A, 0x08, 0x08, 0x08, 0x0A, 0x08, 0x04, + 0x0C, 0x0A, 0x0A, 0x0E, 0x06, 0x08, 0x0C, 0x18, 0x08, 0x08, 0x0A, 0x04, + 0x0C, 0x0C, 0x0C, 0x0C, 0x02, 0x08, 0x0A, 0x08, 0x08, 0x04, 0x04, 0x06, + 0x08, 0x04, 0x04, 0x08, 0x0C, 0x08, 0x08, 0x0C, 0x0C, 0x0C, 0x0C, 0x0A, + 0x0C, 0x08, 0x06, 0x04, 0x06, 0x08, 0x0A, 0x0A, 0x0A, 0x08, 0x0C, 0x0A, + 0x0C, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0C, 0x0A, 0x0A, 0x0A, 0x0A, 0x08, + 0x0A, 0x0C, 0x0A, 0x0B, 0x0C, 0x0D, 0x0B, 0x0E, 0x0A, 0x0A, 0x0A, 0x0A, + 0x0A, 0x08, 0x0C, 0x0A, 0x0C, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0C, 0x0A, + 0x0A, 0x0A, 0x0A, 0x08, 0x0A, 0x0C, 0x0A, 0x0B, 0x0A, 0x0C, 0x0D, 0x0B, + 0x0E, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x08, 0x0C, 0x0A, 0x0C, 0x0A, 0x0A, + 0x0A, 0x0A, 0x0A, 0x0C, 0x0A, 0x0A, 0x0A, 0x0A, 0x08, 0x0A, 0x0C, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0B, 0x0E, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x08, 0x0C, + 0x0A, 0x0C, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0C, 0x0A, 0x0A, 0x0A, 0x0A, + 0x08, 0x0A, 0x0C, 0x0A, 0x0B, 0x0A, 0x0C, 0x0D, 0x0B, 0x0E, 0x0A, 0x0A, + 0x0A, 0x04, 0x04, 0x08, 0x04, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x18, 0x0A, 0x0A, 0x0A, 0x0A, 0x06, + 0x06, 0x08, 0x08, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x0A, 0x0A, 0x10, 0x0C, 0x08, 0x10, 0x0C, 0x0A, 0x0A, 0x0A, 0x08, 0x0A, + 0x0A, 0x08, 0x06, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x04, 0x0A, 0x0A, 0x0C, 0x0C, 0x0A, + 0x0A, 0x0A, 0x0A, 0x08, 0x08, 0x0C, 0x0A, 0x0A, 0x08, 0x1C, 0x0C, 0x08, + 0x0C, 0x0E, 0x08, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x08, 0x0C, 0x0A, 0x0A, 0x0A, 0x08, 0x0C, 0x0A, 0x0A, 0x0A, 0x0A, 0x0C, + 0x0C, 0x0D, 0x0A, 0x0A, 0x0B, 0x0E, 0x0A, 0x0E, 0x0A, 0x0B, 0x0C, 0x0A, + 0x0A, 0x0A, 0x08, 0x0C, 0x0A, 0x0C, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0C, + 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x08, 0x0A, 0x0C, 0x0A, 0x0B, 0x0A, 0x0C, + 0x0D, 0x0B, 0x0E, 0x0A, 0x0A, 0x0E, 0x0A, 0x08, 0x08, 0x0A, 0x0A, 0x0A, + 0x0A, 0x0E, 0x0E, 0x04, 0x04, 0x08, 0x08, 0x0A, 0x0A, 0x0A, 0x0A, 0x08, + 0x08, 0x0E, 0x0E, 0x0A, 0x0A, 0x08, 0x08, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x0A, 0x0A, 0x0C, 0x0A, 0x0A, 0x0C, 0x0A, 0x0A, 0x0A, 0x08, 0x0A, 0x0C, + 0x0A, 0x0D, 0x0B, 0x0E, 0x0C, 0x0A, 0x0C, 0x0A, 0x0A, 0x0A, 0x08, 0x0A, + 0x0C, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0C, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x08, 0x0A, 0x0C, 0x0A, 0x0B, 0x0A, 0x0C, 0x0D, 0x0B, 0x0E, 0x0A, 0x0A, + 0x0E, 0x0A, 0x0A, 0x0A, 0x08, 0x0C, 0x0A, 0x0C, 0x0A, 0x0A, 0x0A, 0x0A, + 0x0A, 0x0C, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x08, 0x0A, 0x0C, 0x0A, 0x0B, + 0x0A, 0x0C, 0x0D, 0x0B, 0x0E, 0x0A, 0x0A, 0x0E, 0x0A, 0x0A, 0x0A, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x0A, 0x0A, 0x04, 0x08, 0x08, 0x0E, 0x0E, + 0x0A, 0x0A, 0x0E, 0x0E, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x08, 0x0A, 0x0A, 0x0A, 0x0A, 0x0C, + 0x0A, 0x0A, 0x0A, 0x0A, 0x0E, 0x0A, 0x0A, 0x0E, 0x0A, 0x0A, 0x0A, 0x0E, + 0x0A, 0x0A, 0x0E, 0x0A, 0x0C, 0x0A, 0x00, 0x00, 0x11, 0x1E, 0x09, 0x00, + 0x09, 0x02, 0x0D, 0x09, 0x0B, 0x0D, 0x04, 0x06, 0x06, 0x0D, 0x0D, 0x04, + 0x09, 0x04, 0x06, 0x0B, 0x06, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0B, + 0x0B, 0x04, 0x04, 0x09, 0x0B, 0x09, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x04, 0x09, 0x0B, 0x09, 0x0D, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0B, 0x0D, 0x0B, 0x0B, 0x0B, 0x06, 0x06, + 0x06, 0x09, 0x0D, 0x06, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x04, 0x09, 0x0B, 0x09, 0x0D, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, + 0x0B, 0x0B, 0x0D, 0x0B, 0x0B, 0x0B, 0x09, 0x04, 0x09, 0x0B, 0x09, 0x09, + 0x09, 0x0B, 0x09, 0x04, 0x0D, 0x0B, 0x0B, 0x0F, 0x06, 0x09, 0x0D, 0x1A, + 0x09, 0x09, 0x0B, 0x04, 0x0D, 0x0D, 0x0D, 0x0D, 0x02, 0x09, 0x0B, 0x09, + 0x09, 0x04, 0x04, 0x06, 0x09, 0x04, 0x04, 0x09, 0x0D, 0x09, 0x09, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0B, 0x0D, 0x09, 0x06, 0x04, 0x06, 0x09, 0x0B, 0x0B, + 0x0B, 0x09, 0x0D, 0x0B, 0x0D, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0D, 0x0B, + 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0D, 0x0B, 0x0C, 0x0D, 0x0E, 0x0C, 0x0F, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0D, 0x0B, 0x0D, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0D, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0D, 0x0B, 0x0C, + 0x0B, 0x0D, 0x0E, 0x0C, 0x0F, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0D, + 0x0B, 0x0D, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0D, 0x0B, 0x0B, 0x0B, 0x0B, + 0x09, 0x0B, 0x0D, 0x0B, 0x0C, 0x0D, 0x0E, 0x0C, 0x0F, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x09, 0x0D, 0x0B, 0x0D, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0D, + 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0D, 0x0B, 0x0C, 0x0B, 0x0D, 0x0E, + 0x0C, 0x0F, 0x0B, 0x0B, 0x0B, 0x04, 0x04, 0x09, 0x04, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x1A, 0x0B, + 0x0B, 0x0B, 0x0B, 0x06, 0x06, 0x09, 0x09, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x11, 0x0D, 0x09, 0x11, 0x0D, 0x0B, + 0x0B, 0x0B, 0x09, 0x0B, 0x0B, 0x09, 0x06, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x04, 0x0B, + 0x0B, 0x0D, 0x0D, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x09, 0x0D, 0x0B, 0x0B, + 0x09, 0x1E, 0x0D, 0x09, 0x0D, 0x0F, 0x09, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0D, 0x0B, 0x0B, 0x0B, 0x09, 0x0D, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0D, 0x0D, 0x0E, 0x0B, 0x0B, 0x0C, 0x0F, 0x0B, 0x0F, + 0x0B, 0x0C, 0x0D, 0x0B, 0x0B, 0x0B, 0x09, 0x0D, 0x0B, 0x0D, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0D, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0D, + 0x0B, 0x0C, 0x0B, 0x0D, 0x0E, 0x0C, 0x0F, 0x0B, 0x0B, 0x0F, 0x0B, 0x09, + 0x09, 0x0B, 0x0B, 0x0B, 0x0B, 0x0F, 0x0F, 0x04, 0x04, 0x09, 0x09, 0x0B, + 0x0B, 0x0B, 0x0B, 0x09, 0x09, 0x0F, 0x0F, 0x0B, 0x0B, 0x09, 0x09, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0D, 0x0B, 0x0B, 0x0D, 0x0B, 0x0B, + 0x0B, 0x09, 0x0B, 0x0D, 0x0B, 0x0E, 0x0C, 0x0F, 0x0D, 0x0B, 0x0D, 0x0B, + 0x0B, 0x0B, 0x09, 0x0B, 0x0D, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0D, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0D, 0x0B, 0x0C, 0x0B, 0x0D, 0x0E, + 0x0C, 0x0F, 0x0B, 0x0B, 0x0F, 0x0B, 0x0B, 0x0B, 0x09, 0x0D, 0x0B, 0x0D, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0D, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, + 0x0B, 0x0D, 0x0B, 0x0C, 0x0B, 0x0D, 0x0E, 0x0C, 0x0F, 0x0B, 0x0B, 0x0F, + 0x0B, 0x0B, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0B, 0x0B, 0x04, + 0x09, 0x09, 0x0F, 0x0F, 0x0B, 0x0B, 0x0F, 0x0F, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0D, 0x0B, 0x0B, 0x0B, 0x0B, 0x0F, 0x0B, 0x0B, 0x0F, + 0x0B, 0x0B, 0x0B, 0x0F, 0x0B, 0x0B, 0x0F, 0x0B, 0x0D, 0x0B, 0x00, 0x00, + 0x12, 0x20, 0x09, 0x00, 0x09, 0x02, 0x0E, 0x09, 0x0B, 0x0E, 0x05, 0x07, + 0x07, 0x0E, 0x0E, 0x05, 0x09, 0x05, 0x07, 0x0B, 0x07, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x09, 0x0B, 0x0B, 0x05, 0x05, 0x09, 0x0B, 0x09, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x05, 0x09, 0x0B, 0x09, + 0x0E, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0B, 0x0E, 0x0B, + 0x0B, 0x0B, 0x07, 0x07, 0x07, 0x09, 0x0E, 0x07, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x05, 0x09, 0x0B, 0x09, 0x0E, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0B, 0x0E, 0x0B, 0x0B, 0x0B, 0x09, 0x05, + 0x09, 0x0B, 0x09, 0x09, 0x09, 0x0B, 0x09, 0x05, 0x0E, 0x0B, 0x0B, 0x10, + 0x07, 0x09, 0x0E, 0x1B, 0x09, 0x09, 0x0B, 0x05, 0x0E, 0x0E, 0x0E, 0x0E, + 0x02, 0x09, 0x0B, 0x09, 0x09, 0x05, 0x05, 0x07, 0x09, 0x05, 0x05, 0x09, + 0x0E, 0x09, 0x09, 0x0E, 0x0E, 0x0E, 0x0E, 0x0B, 0x0E, 0x09, 0x07, 0x05, + 0x07, 0x09, 0x0B, 0x0B, 0x0B, 0x09, 0x0E, 0x0B, 0x0E, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0E, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0E, 0x0B, 0x0C, + 0x0E, 0x0F, 0x0C, 0x10, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0E, 0x0B, + 0x0E, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0E, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, + 0x0B, 0x0E, 0x0B, 0x0C, 0x0B, 0x0E, 0x0F, 0x0C, 0x10, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x09, 0x0E, 0x0B, 0x0E, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0E, + 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0E, 0x0B, 0x0C, 0x0E, 0x0F, 0x0C, + 0x10, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0E, 0x0B, 0x0E, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0E, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0E, 0x0B, + 0x0C, 0x0B, 0x0E, 0x0F, 0x0C, 0x10, 0x0B, 0x0B, 0x0B, 0x05, 0x05, 0x09, + 0x05, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x1B, 0x0B, 0x0B, 0x0B, 0x0B, 0x07, 0x07, 0x09, 0x09, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x12, 0x0E, + 0x09, 0x12, 0x0E, 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0B, 0x09, 0x07, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x05, 0x0B, 0x0B, 0x0E, 0x0E, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, + 0x09, 0x0E, 0x0B, 0x0B, 0x09, 0x20, 0x0E, 0x09, 0x0E, 0x10, 0x09, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0E, 0x0B, 0x0B, + 0x0B, 0x09, 0x0E, 0x0B, 0x0B, 0x0B, 0x0B, 0x0E, 0x0E, 0x0F, 0x0B, 0x0B, + 0x0C, 0x10, 0x0B, 0x10, 0x0B, 0x0C, 0x0E, 0x0B, 0x0B, 0x0B, 0x09, 0x0E, + 0x0B, 0x0E, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0E, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x09, 0x0B, 0x0E, 0x0B, 0x0C, 0x0B, 0x0E, 0x0F, 0x0C, 0x10, 0x0B, + 0x0B, 0x10, 0x0B, 0x09, 0x09, 0x0B, 0x0B, 0x0B, 0x0B, 0x10, 0x10, 0x05, + 0x05, 0x09, 0x09, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x09, 0x10, 0x10, 0x0B, + 0x0B, 0x09, 0x09, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0E, 0x0B, + 0x0B, 0x0E, 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0E, 0x0B, 0x0F, 0x0C, 0x10, + 0x0E, 0x0B, 0x0E, 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0E, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0E, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0E, 0x0B, + 0x0C, 0x0B, 0x0E, 0x0F, 0x0C, 0x10, 0x0B, 0x0B, 0x10, 0x0B, 0x0B, 0x0B, + 0x09, 0x0E, 0x0B, 0x0E, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0E, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x09, 0x0B, 0x0E, 0x0B, 0x0C, 0x0B, 0x0E, 0x0F, 0x0C, + 0x10, 0x0B, 0x0B, 0x10, 0x0B, 0x0B, 0x0B, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x0B, 0x0B, 0x05, 0x09, 0x09, 0x10, 0x10, 0x0B, 0x0B, 0x10, 0x10, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x09, 0x0B, 0x0B, 0x0B, 0x0B, 0x0E, 0x0B, 0x0B, 0x0B, 0x0B, + 0x10, 0x0B, 0x0B, 0x10, 0x0B, 0x0B, 0x0B, 0x10, 0x0B, 0x0B, 0x10, 0x0B, + 0x0E, 0x0B, 0x00, 0x00, 0x13, 0x21, 0x0A, 0x00, 0x0A, 0x02, 0x0E, 0x0A, + 0x0C, 0x0E, 0x05, 0x07, 0x07, 0x0E, 0x0E, 0x05, 0x0A, 0x05, 0x07, 0x0C, + 0x07, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0A, 0x0C, 0x0C, 0x05, 0x05, 0x0A, + 0x0C, 0x0A, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x05, 0x0A, 0x0C, 0x0A, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0A, + 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x07, 0x07, 0x07, 0x0A, 0x0E, 0x07, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x05, 0x0A, 0x0C, 0x0A, + 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0A, 0x0C, 0x0C, 0x0E, 0x0C, + 0x0C, 0x0C, 0x0A, 0x05, 0x0A, 0x0C, 0x0A, 0x0A, 0x0A, 0x0C, 0x0A, 0x05, + 0x0E, 0x0C, 0x0C, 0x11, 0x07, 0x0A, 0x0E, 0x1D, 0x0A, 0x0A, 0x0C, 0x05, + 0x0E, 0x0E, 0x0E, 0x0E, 0x02, 0x0A, 0x0C, 0x0A, 0x0A, 0x05, 0x05, 0x07, + 0x0A, 0x05, 0x05, 0x0A, 0x0E, 0x0A, 0x0A, 0x0E, 0x0E, 0x0E, 0x0E, 0x0C, + 0x0E, 0x0A, 0x07, 0x05, 0x07, 0x0A, 0x0C, 0x0C, 0x0C, 0x0A, 0x0E, 0x0C, + 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0A, + 0x0C, 0x0E, 0x0C, 0x0D, 0x0E, 0x0F, 0x0D, 0x11, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0A, 0x0E, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0A, 0x0C, 0x0E, 0x0C, 0x0D, 0x0C, 0x0E, 0x0F, 0x0D, + 0x11, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0A, 0x0E, 0x0C, 0x0E, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0A, 0x0C, 0x0E, 0x0C, + 0x0D, 0x0E, 0x0F, 0x0D, 0x11, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0A, 0x0E, + 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0A, 0x0C, 0x0E, 0x0C, 0x0D, 0x0C, 0x0E, 0x0F, 0x0D, 0x11, 0x0C, 0x0C, + 0x0C, 0x05, 0x05, 0x0A, 0x05, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1D, 0x0C, 0x0C, 0x0C, 0x0C, 0x07, + 0x07, 0x0A, 0x0A, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x13, 0x0E, 0x0A, 0x13, 0x0E, 0x0C, 0x0C, 0x0C, 0x0A, 0x0C, + 0x0C, 0x0A, 0x07, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x05, 0x0C, 0x0C, 0x0E, 0x0E, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0A, 0x0A, 0x0E, 0x0C, 0x0C, 0x0A, 0x21, 0x0E, 0x0A, + 0x0E, 0x11, 0x0A, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0A, 0x0E, 0x0C, 0x0C, 0x0C, 0x0A, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, + 0x0E, 0x0F, 0x0C, 0x0C, 0x0D, 0x11, 0x0C, 0x11, 0x0C, 0x0D, 0x0E, 0x0C, + 0x0C, 0x0C, 0x0A, 0x0E, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0A, 0x0C, 0x0E, 0x0C, 0x0D, 0x0C, 0x0E, + 0x0F, 0x0D, 0x11, 0x0C, 0x0C, 0x11, 0x0C, 0x0A, 0x0A, 0x0C, 0x0C, 0x0C, + 0x0C, 0x11, 0x11, 0x05, 0x05, 0x0A, 0x0A, 0x0C, 0x0C, 0x0C, 0x0C, 0x0A, + 0x0A, 0x11, 0x11, 0x0C, 0x0C, 0x0A, 0x0A, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0A, 0x0C, 0x0E, + 0x0C, 0x0F, 0x0D, 0x11, 0x0E, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0A, 0x0C, + 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0A, 0x0C, 0x0E, 0x0C, 0x0D, 0x0C, 0x0E, 0x0F, 0x0D, 0x11, 0x0C, 0x0C, + 0x11, 0x0C, 0x0C, 0x0C, 0x0A, 0x0E, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0A, 0x0C, 0x0E, 0x0C, 0x0D, + 0x0C, 0x0E, 0x0F, 0x0D, 0x11, 0x0C, 0x0C, 0x11, 0x0C, 0x0C, 0x0C, 0x0A, + 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0C, 0x0C, 0x05, 0x0A, 0x0A, 0x11, 0x11, + 0x0C, 0x0C, 0x11, 0x11, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0A, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, + 0x0C, 0x0C, 0x0C, 0x0C, 0x11, 0x0C, 0x0C, 0x11, 0x0C, 0x0C, 0x0C, 0x11, + 0x0C, 0x0C, 0x11, 0x0C, 0x0E, 0x0C, 0x00, 0x00, 0x14, 0x23, 0x0A, 0x00, + 0x0A, 0x03, 0x0F, 0x0A, 0x0D, 0x0F, 0x05, 0x08, 0x08, 0x0F, 0x0F, 0x05, + 0x0A, 0x05, 0x08, 0x0D, 0x08, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0A, 0x0D, + 0x0D, 0x05, 0x05, 0x0A, 0x0D, 0x0A, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x05, 0x0A, 0x0D, 0x0A, 0x0F, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0A, 0x0D, 0x0D, 0x0F, 0x0D, 0x0D, 0x0D, 0x08, 0x08, + 0x08, 0x0A, 0x0F, 0x08, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x05, 0x0A, 0x0D, 0x0A, 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0A, + 0x0D, 0x0D, 0x0F, 0x0D, 0x0D, 0x0D, 0x0A, 0x05, 0x0A, 0x0D, 0x0A, 0x0A, + 0x0A, 0x0D, 0x0A, 0x05, 0x0F, 0x0D, 0x0D, 0x12, 0x08, 0x0A, 0x0F, 0x1E, + 0x0A, 0x0A, 0x0D, 0x05, 0x0F, 0x0F, 0x0F, 0x0F, 0x03, 0x0A, 0x0D, 0x0A, + 0x0A, 0x05, 0x05, 0x08, 0x0A, 0x05, 0x05, 0x0A, 0x0F, 0x0A, 0x0A, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0D, 0x0F, 0x0A, 0x08, 0x05, 0x08, 0x0A, 0x0D, 0x0D, + 0x0D, 0x0A, 0x0F, 0x0D, 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0F, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0A, 0x0D, 0x0F, 0x0D, 0x0E, 0x0F, 0x10, 0x0E, 0x12, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0A, 0x0F, 0x0D, 0x0F, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0A, 0x0D, 0x0F, 0x0D, 0x0E, + 0x0D, 0x0F, 0x10, 0x0E, 0x12, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0A, 0x0F, + 0x0D, 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0A, 0x0D, 0x0F, 0x0D, 0x0E, 0x0F, 0x10, 0x0E, 0x12, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0A, 0x0F, 0x0D, 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0F, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0A, 0x0D, 0x0F, 0x0D, 0x0E, 0x0D, 0x0F, 0x10, + 0x0E, 0x12, 0x0D, 0x0D, 0x0D, 0x05, 0x05, 0x0A, 0x05, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x1E, 0x0D, + 0x0D, 0x0D, 0x0D, 0x08, 0x08, 0x0A, 0x0A, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x14, 0x0F, 0x0A, 0x14, 0x0F, 0x0D, + 0x0D, 0x0D, 0x0A, 0x0D, 0x0D, 0x0A, 0x08, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x05, 0x0D, + 0x0D, 0x0F, 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0A, 0x0A, 0x0F, 0x0D, 0x0D, + 0x0A, 0x23, 0x0F, 0x0A, 0x0F, 0x12, 0x0A, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0A, 0x0F, 0x0D, 0x0D, 0x0D, 0x0A, 0x0F, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0F, 0x0F, 0x10, 0x0D, 0x0D, 0x0E, 0x12, 0x0D, 0x12, + 0x0D, 0x0E, 0x0F, 0x0D, 0x0D, 0x0D, 0x0A, 0x0F, 0x0D, 0x0F, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0A, 0x0D, 0x0F, + 0x0D, 0x0E, 0x0D, 0x0F, 0x10, 0x0E, 0x12, 0x0D, 0x0D, 0x12, 0x0D, 0x0A, + 0x0A, 0x0D, 0x0D, 0x0D, 0x0D, 0x12, 0x12, 0x05, 0x05, 0x0A, 0x0A, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0A, 0x0A, 0x12, 0x12, 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0F, 0x0D, 0x0D, 0x0F, 0x0D, 0x0D, + 0x0D, 0x0A, 0x0D, 0x0F, 0x0D, 0x10, 0x0E, 0x12, 0x0F, 0x0D, 0x0F, 0x0D, + 0x0D, 0x0D, 0x0A, 0x0D, 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0F, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0A, 0x0D, 0x0F, 0x0D, 0x0E, 0x0D, 0x0F, 0x10, + 0x0E, 0x12, 0x0D, 0x0D, 0x12, 0x0D, 0x0D, 0x0D, 0x0A, 0x0F, 0x0D, 0x0F, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0A, + 0x0D, 0x0F, 0x0D, 0x0E, 0x0D, 0x0F, 0x10, 0x0E, 0x12, 0x0D, 0x0D, 0x12, + 0x0D, 0x0D, 0x0D, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0D, 0x0D, 0x05, + 0x0A, 0x0A, 0x12, 0x12, 0x0D, 0x0D, 0x12, 0x12, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0A, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x12, 0x0D, 0x0D, 0x12, + 0x0D, 0x0D, 0x0D, 0x12, 0x0D, 0x0D, 0x12, 0x0D, 0x0F, 0x0D, 0x00, 0x00, + 0x15, 0x25, 0x0B, 0x00, 0x0B, 0x03, 0x10, 0x0B, 0x0D, 0x10, 0x05, 0x08, + 0x08, 0x10, 0x10, 0x05, 0x0B, 0x05, 0x08, 0x0D, 0x08, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0B, 0x0D, 0x0D, 0x05, 0x05, 0x0B, 0x0D, 0x0B, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x05, 0x0B, 0x0D, 0x0B, + 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0B, 0x0D, 0x0D, 0x10, 0x0D, + 0x0D, 0x0D, 0x08, 0x08, 0x08, 0x0B, 0x10, 0x08, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x05, 0x0B, 0x0D, 0x0B, 0x10, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0B, 0x0D, 0x0D, 0x10, 0x0D, 0x0D, 0x0D, 0x0B, 0x05, + 0x0B, 0x0D, 0x0B, 0x0B, 0x0B, 0x0D, 0x0B, 0x05, 0x10, 0x0D, 0x0D, 0x12, + 0x08, 0x0B, 0x10, 0x20, 0x0B, 0x0B, 0x0D, 0x05, 0x10, 0x10, 0x10, 0x10, + 0x03, 0x0B, 0x0D, 0x0B, 0x0B, 0x05, 0x05, 0x08, 0x0B, 0x05, 0x05, 0x0B, + 0x10, 0x0B, 0x0B, 0x10, 0x10, 0x10, 0x10, 0x0D, 0x10, 0x0B, 0x08, 0x05, + 0x08, 0x0B, 0x0D, 0x0D, 0x0D, 0x0B, 0x10, 0x0D, 0x10, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0B, 0x0D, 0x10, 0x0D, 0x0E, + 0x10, 0x11, 0x0E, 0x12, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0B, 0x10, 0x0D, + 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0B, + 0x0D, 0x10, 0x0D, 0x0E, 0x0D, 0x10, 0x11, 0x0E, 0x12, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0B, 0x10, 0x0D, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x10, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0B, 0x0D, 0x10, 0x0D, 0x0E, 0x10, 0x11, 0x0E, + 0x12, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0B, 0x10, 0x0D, 0x10, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0B, 0x0D, 0x10, 0x0D, + 0x0E, 0x0D, 0x10, 0x11, 0x0E, 0x12, 0x0D, 0x0D, 0x0D, 0x05, 0x05, 0x0B, + 0x05, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x20, 0x0D, 0x0D, 0x0D, 0x0D, 0x08, 0x08, 0x0B, 0x0B, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x15, 0x10, + 0x0B, 0x15, 0x10, 0x0D, 0x0D, 0x0D, 0x0B, 0x0D, 0x0D, 0x0B, 0x08, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x05, 0x0D, 0x0D, 0x10, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0B, + 0x0B, 0x10, 0x0D, 0x0D, 0x0B, 0x25, 0x10, 0x0B, 0x10, 0x12, 0x0B, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0B, 0x10, 0x0D, 0x0D, + 0x0D, 0x0B, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x10, 0x10, 0x11, 0x0D, 0x0D, + 0x0E, 0x12, 0x0D, 0x12, 0x0D, 0x0E, 0x10, 0x0D, 0x0D, 0x0D, 0x0B, 0x10, + 0x0D, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0B, 0x0D, 0x10, 0x0D, 0x0E, 0x0D, 0x10, 0x11, 0x0E, 0x12, 0x0D, + 0x0D, 0x12, 0x0D, 0x0B, 0x0B, 0x0D, 0x0D, 0x0D, 0x0D, 0x12, 0x12, 0x05, + 0x05, 0x0B, 0x0B, 0x0D, 0x0D, 0x0D, 0x0D, 0x0B, 0x0B, 0x12, 0x12, 0x0D, + 0x0D, 0x0B, 0x0B, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x10, 0x0D, + 0x0D, 0x10, 0x0D, 0x0D, 0x0D, 0x0B, 0x0D, 0x10, 0x0D, 0x11, 0x0E, 0x12, + 0x10, 0x0D, 0x10, 0x0D, 0x0D, 0x0D, 0x0B, 0x0D, 0x10, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0B, 0x0D, 0x10, 0x0D, + 0x0E, 0x0D, 0x10, 0x11, 0x0E, 0x12, 0x0D, 0x0D, 0x12, 0x0D, 0x0D, 0x0D, + 0x0B, 0x10, 0x0D, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x10, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0B, 0x0D, 0x10, 0x0D, 0x0E, 0x0D, 0x10, 0x11, 0x0E, + 0x12, 0x0D, 0x0D, 0x12, 0x0D, 0x0D, 0x0D, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0D, 0x0D, 0x05, 0x0B, 0x0B, 0x12, 0x12, 0x0D, 0x0D, 0x12, 0x12, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0B, 0x0D, 0x0D, 0x0D, 0x0D, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, + 0x12, 0x0D, 0x0D, 0x12, 0x0D, 0x0D, 0x0D, 0x12, 0x0D, 0x0D, 0x12, 0x0D, + 0x10, 0x0D, 0x00, 0x00, 0x16, 0x27, 0x0B, 0x00, 0x0B, 0x03, 0x11, 0x0B, + 0x0E, 0x11, 0x06, 0x08, 0x08, 0x11, 0x11, 0x06, 0x0B, 0x06, 0x08, 0x0E, + 0x08, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0B, 0x0E, 0x0E, 0x06, 0x06, 0x0B, + 0x0E, 0x0B, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x06, 0x0B, 0x0E, 0x0B, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0B, + 0x0E, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x08, 0x08, 0x08, 0x0B, 0x11, 0x08, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x06, 0x0B, 0x0E, 0x0B, + 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0B, 0x0E, 0x0E, 0x11, 0x0E, + 0x0E, 0x0E, 0x0B, 0x06, 0x0B, 0x0E, 0x0B, 0x0B, 0x0B, 0x0E, 0x0B, 0x06, + 0x11, 0x0E, 0x0E, 0x13, 0x08, 0x0B, 0x11, 0x21, 0x0B, 0x0B, 0x0E, 0x06, + 0x11, 0x11, 0x11, 0x11, 0x03, 0x0B, 0x0E, 0x0B, 0x0B, 0x06, 0x06, 0x08, + 0x0B, 0x06, 0x06, 0x0B, 0x11, 0x0B, 0x0B, 0x11, 0x11, 0x11, 0x11, 0x0E, + 0x11, 0x0B, 0x08, 0x06, 0x08, 0x0B, 0x0E, 0x0E, 0x0E, 0x0B, 0x11, 0x0E, + 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0B, + 0x0E, 0x11, 0x0E, 0x0F, 0x11, 0x12, 0x0F, 0x13, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0B, 0x11, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x11, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0B, 0x0E, 0x11, 0x0E, 0x0F, 0x0E, 0x11, 0x12, 0x0F, + 0x13, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0B, 0x11, 0x0E, 0x11, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0B, 0x0E, 0x11, 0x0E, + 0x0F, 0x11, 0x12, 0x0F, 0x13, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0B, 0x11, + 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0B, 0x0E, 0x11, 0x0E, 0x0F, 0x0E, 0x11, 0x12, 0x0F, 0x13, 0x0E, 0x0E, + 0x0E, 0x06, 0x06, 0x0B, 0x06, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x21, 0x0E, 0x0E, 0x0E, 0x0E, 0x08, + 0x08, 0x0B, 0x0B, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x16, 0x11, 0x0B, 0x16, 0x11, 0x0E, 0x0E, 0x0E, 0x0B, 0x0E, + 0x0E, 0x0B, 0x08, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x06, 0x0E, 0x0E, 0x11, 0x11, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0B, 0x0B, 0x11, 0x0E, 0x0E, 0x0B, 0x27, 0x11, 0x0B, + 0x11, 0x13, 0x0B, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0B, 0x11, 0x0E, 0x0E, 0x0E, 0x0B, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x11, + 0x11, 0x12, 0x0E, 0x0E, 0x0F, 0x13, 0x0E, 0x13, 0x0E, 0x0F, 0x11, 0x0E, + 0x0E, 0x0E, 0x0B, 0x11, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x11, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0B, 0x0E, 0x11, 0x0E, 0x0F, 0x0E, 0x11, + 0x12, 0x0F, 0x13, 0x0E, 0x0E, 0x13, 0x0E, 0x0B, 0x0B, 0x0E, 0x0E, 0x0E, + 0x0E, 0x13, 0x13, 0x06, 0x06, 0x0B, 0x0B, 0x0E, 0x0E, 0x0E, 0x0E, 0x0B, + 0x0B, 0x13, 0x13, 0x0E, 0x0E, 0x0B, 0x0B, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x11, 0x0E, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0B, 0x0E, 0x11, + 0x0E, 0x12, 0x0F, 0x13, 0x11, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0B, 0x0E, + 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0B, 0x0E, 0x11, 0x0E, 0x0F, 0x0E, 0x11, 0x12, 0x0F, 0x13, 0x0E, 0x0E, + 0x13, 0x0E, 0x0E, 0x0E, 0x0B, 0x11, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0B, 0x0E, 0x11, 0x0E, 0x0F, + 0x0E, 0x11, 0x12, 0x0F, 0x13, 0x0E, 0x0E, 0x13, 0x0E, 0x0E, 0x0E, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0E, 0x0E, 0x06, 0x0B, 0x0B, 0x13, 0x13, + 0x0E, 0x0E, 0x13, 0x13, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0B, 0x0E, 0x0E, 0x0E, 0x0E, 0x11, + 0x0E, 0x0E, 0x0E, 0x0E, 0x13, 0x0E, 0x0E, 0x13, 0x0E, 0x0E, 0x0E, 0x13, + 0x0E, 0x0E, 0x13, 0x0E, 0x11, 0x0E, 0x00, 0x00, 0x17, 0x28, 0x0C, 0x00, + 0x0C, 0x03, 0x11, 0x0C, 0x0E, 0x11, 0x06, 0x09, 0x09, 0x11, 0x11, 0x06, + 0x0C, 0x06, 0x09, 0x0E, 0x09, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0C, 0x0E, + 0x0E, 0x06, 0x06, 0x0C, 0x0E, 0x0C, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x06, 0x0C, 0x0E, 0x0C, 0x11, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0C, 0x0E, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x09, 0x09, + 0x09, 0x0C, 0x11, 0x09, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x06, 0x0C, 0x0E, 0x0C, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0C, + 0x0E, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0C, 0x06, 0x0C, 0x0E, 0x0C, 0x0C, + 0x0C, 0x0E, 0x0C, 0x06, 0x11, 0x0E, 0x0E, 0x14, 0x09, 0x0C, 0x11, 0x23, + 0x0C, 0x0C, 0x0E, 0x06, 0x11, 0x11, 0x11, 0x11, 0x03, 0x0C, 0x0E, 0x0C, + 0x0C, 0x06, 0x06, 0x09, 0x0C, 0x06, 0x06, 0x0C, 0x11, 0x0C, 0x0C, 0x11, + 0x11, 0x11, 0x11, 0x0E, 0x11, 0x0C, 0x09, 0x06, 0x09, 0x0C, 0x0E, 0x0E, + 0x0E, 0x0C, 0x11, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x11, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0C, 0x0E, 0x11, 0x0E, 0x10, 0x11, 0x13, 0x10, 0x14, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0C, 0x11, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0C, 0x0E, 0x11, 0x0E, 0x10, + 0x0E, 0x11, 0x13, 0x10, 0x14, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0C, 0x11, + 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0C, 0x0E, 0x11, 0x0E, 0x10, 0x11, 0x13, 0x10, 0x14, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0C, 0x11, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x11, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0C, 0x0E, 0x11, 0x0E, 0x10, 0x0E, 0x11, 0x13, + 0x10, 0x14, 0x0E, 0x0E, 0x0E, 0x06, 0x06, 0x0C, 0x06, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x23, 0x0E, + 0x0E, 0x0E, 0x0E, 0x09, 0x09, 0x0C, 0x0C, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x17, 0x11, 0x0C, 0x17, 0x11, 0x0E, + 0x0E, 0x0E, 0x0C, 0x0E, 0x0E, 0x0C, 0x09, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x06, 0x0E, + 0x0E, 0x11, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0C, 0x0C, 0x11, 0x0E, 0x0E, + 0x0C, 0x28, 0x11, 0x0C, 0x11, 0x14, 0x0C, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0C, 0x11, 0x0E, 0x0E, 0x0E, 0x0C, 0x11, 0x0E, + 0x0E, 0x0E, 0x0E, 0x11, 0x11, 0x13, 0x0E, 0x0E, 0x10, 0x14, 0x0E, 0x14, + 0x0E, 0x10, 0x11, 0x0E, 0x0E, 0x0E, 0x0C, 0x11, 0x0E, 0x11, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0C, 0x0E, 0x11, + 0x0E, 0x10, 0x0E, 0x11, 0x13, 0x10, 0x14, 0x0E, 0x0E, 0x14, 0x0E, 0x0C, + 0x0C, 0x0E, 0x0E, 0x0E, 0x0E, 0x14, 0x14, 0x06, 0x06, 0x0C, 0x0C, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0C, 0x0C, 0x14, 0x14, 0x0E, 0x0E, 0x0C, 0x0C, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x11, 0x0E, 0x0E, 0x11, 0x0E, 0x0E, + 0x0E, 0x0C, 0x0E, 0x11, 0x0E, 0x13, 0x10, 0x14, 0x11, 0x0E, 0x11, 0x0E, + 0x0E, 0x0E, 0x0C, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x11, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0C, 0x0E, 0x11, 0x0E, 0x10, 0x0E, 0x11, 0x13, + 0x10, 0x14, 0x0E, 0x0E, 0x14, 0x0E, 0x0E, 0x0E, 0x0C, 0x11, 0x0E, 0x11, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0C, + 0x0E, 0x11, 0x0E, 0x10, 0x0E, 0x11, 0x13, 0x10, 0x14, 0x0E, 0x0E, 0x14, + 0x0E, 0x0E, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x0E, 0x06, + 0x0C, 0x0C, 0x14, 0x14, 0x0E, 0x0E, 0x14, 0x14, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0C, 0x0E, + 0x0E, 0x0E, 0x0E, 0x11, 0x0E, 0x0E, 0x0E, 0x0E, 0x14, 0x0E, 0x0E, 0x14, + 0x0E, 0x0E, 0x0E, 0x14, 0x0E, 0x0E, 0x14, 0x0E, 0x11, 0x0E, 0x00, 0x00, + 0x18, 0x2A, 0x0C, 0x00, 0x0C, 0x03, 0x12, 0x0C, 0x0F, 0x12, 0x06, 0x09, + 0x09, 0x12, 0x12, 0x06, 0x0C, 0x06, 0x09, 0x0F, 0x09, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0C, 0x0F, 0x0F, 0x06, 0x06, 0x0C, 0x0F, 0x0C, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x06, 0x0C, 0x0F, 0x0C, + 0x12, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x0F, 0x0F, 0x12, 0x0F, + 0x0F, 0x0F, 0x09, 0x09, 0x09, 0x0C, 0x12, 0x09, 0x0F, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0F, 0x06, 0x0C, 0x0F, 0x0C, 0x12, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0C, 0x0F, 0x0F, 0x12, 0x0F, 0x0F, 0x0F, 0x0C, 0x06, + 0x0C, 0x0F, 0x0C, 0x0C, 0x0C, 0x0F, 0x0C, 0x06, 0x12, 0x0F, 0x0F, 0x15, + 0x09, 0x0C, 0x12, 0x24, 0x0C, 0x0C, 0x0F, 0x06, 0x12, 0x12, 0x12, 0x12, + 0x03, 0x0C, 0x0F, 0x0C, 0x0C, 0x06, 0x06, 0x09, 0x0C, 0x06, 0x06, 0x0C, + 0x12, 0x0C, 0x0C, 0x12, 0x12, 0x12, 0x12, 0x0F, 0x12, 0x0C, 0x09, 0x06, + 0x09, 0x0C, 0x0F, 0x0F, 0x0F, 0x0C, 0x12, 0x0F, 0x12, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x12, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x0F, 0x12, 0x0F, 0x10, + 0x12, 0x13, 0x10, 0x15, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x12, 0x0F, + 0x12, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x12, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, + 0x0F, 0x12, 0x0F, 0x10, 0x0F, 0x12, 0x13, 0x10, 0x15, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0C, 0x12, 0x0F, 0x12, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x12, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x0F, 0x12, 0x0F, 0x10, 0x12, 0x13, 0x10, + 0x15, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x12, 0x0F, 0x12, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0F, 0x12, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x0F, 0x12, 0x0F, + 0x10, 0x0F, 0x12, 0x13, 0x10, 0x15, 0x0F, 0x0F, 0x0F, 0x06, 0x06, 0x0C, + 0x06, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x24, 0x0F, 0x0F, 0x0F, 0x0F, 0x09, 0x09, 0x0C, 0x0C, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x18, 0x12, + 0x0C, 0x18, 0x12, 0x0F, 0x0F, 0x0F, 0x0C, 0x0F, 0x0F, 0x0C, 0x09, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x06, 0x0F, 0x0F, 0x12, 0x12, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, + 0x0C, 0x12, 0x0F, 0x0F, 0x0C, 0x2A, 0x12, 0x0C, 0x12, 0x15, 0x0C, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x12, 0x0F, 0x0F, + 0x0F, 0x0C, 0x12, 0x0F, 0x0F, 0x0F, 0x0F, 0x12, 0x12, 0x13, 0x0F, 0x0F, + 0x10, 0x15, 0x0F, 0x15, 0x0F, 0x10, 0x12, 0x0F, 0x0F, 0x0F, 0x0C, 0x12, + 0x0F, 0x12, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x12, 0x0F, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0C, 0x0F, 0x12, 0x0F, 0x10, 0x0F, 0x12, 0x13, 0x10, 0x15, 0x0F, + 0x0F, 0x15, 0x0F, 0x0C, 0x0C, 0x0F, 0x0F, 0x0F, 0x0F, 0x15, 0x15, 0x06, + 0x06, 0x0C, 0x0C, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x0C, 0x15, 0x15, 0x0F, + 0x0F, 0x0C, 0x0C, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x12, 0x0F, + 0x0F, 0x12, 0x0F, 0x0F, 0x0F, 0x0C, 0x0F, 0x12, 0x0F, 0x13, 0x10, 0x15, + 0x12, 0x0F, 0x12, 0x0F, 0x0F, 0x0F, 0x0C, 0x0F, 0x12, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x12, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x0F, 0x12, 0x0F, + 0x10, 0x0F, 0x12, 0x13, 0x10, 0x15, 0x0F, 0x0F, 0x15, 0x0F, 0x0F, 0x0F, + 0x0C, 0x12, 0x0F, 0x12, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x12, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0C, 0x0F, 0x12, 0x0F, 0x10, 0x0F, 0x12, 0x13, 0x10, + 0x15, 0x0F, 0x0F, 0x15, 0x0F, 0x0F, 0x0F, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0F, 0x0F, 0x06, 0x0C, 0x0C, 0x15, 0x15, 0x0F, 0x0F, 0x15, 0x15, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0C, 0x0F, 0x0F, 0x0F, 0x0F, 0x12, 0x0F, 0x0F, 0x0F, 0x0F, + 0x15, 0x0F, 0x0F, 0x15, 0x0F, 0x0F, 0x0F, 0x15, 0x0F, 0x0F, 0x15, 0x0F, + 0x12, 0x0F, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, + 0x8C, 0xF7, 0x60, 0x09, 0x5F, 0x0F, 0x3C, 0xF5, 0x00, 0x19, 0x03, 0xE8, + 0x00, 0x00, 0x00, 0x00, 0xB7, 0xB6, 0x9D, 0xDC, 0x00, 0x00, 0x00, 0x00, + 0xB7, 0xB6, 0x9D, 0xDC, 0x00, 0x00, 0xFF, 0x06, 0x06, 0x59, 0x03, 0xE9, + 0x00, 0x00, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x03, 0x6B, 0xFF, 0x06, 0x00, 0x18, 0x06, 0xD6, + 0x00, 0x00, 0x00, 0x7D, 0x06, 0x59, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, + 0x01, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x00, 0x7F, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x00, + 0x01, 0x77, 0x00, 0x00, 0x01, 0x77, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x00, 0xFA, 0x00, 0x00, 0x01, 0x77, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x01, 0x77, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x00, 0xFA, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x00, 0xFA, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x01, 0x77, 0x00, 0x00, 0x01, 0x77, 0x00, 0x00, 0x01, 0x77, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x01, 0x77, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x00, 0xFA, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x03, 0x6B, 0x00, 0x00, 0x01, 0x77, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x05, 0xDC, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x00, 0xFA, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x00, 0x01, 0x77, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x01, 0x77, 0x00, 0x00, + 0x00, 0xFA, 0x00, 0x00, 0x01, 0x77, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xAF, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x03, 0x2C, 0x00, 0x00, + 0x02, 0xAF, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xAF, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x03, 0x2C, 0x00, 0x00, 0x02, 0xAF, 0x00, 0x00, + 0x03, 0x6B, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xAF, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x03, 0x2C, 0x00, 0x00, + 0x02, 0xAF, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xAF, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x03, 0x2C, 0x00, 0x00, 0x02, 0xAF, 0x00, 0x00, + 0x03, 0x6B, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x05, 0xDC, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x01, 0x77, 0x00, 0x00, + 0x01, 0x77, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x03, 0xE8, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x03, 0xE8, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x01, 0x77, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x00, 0xFA, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x06, 0xD6, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x03, 0x2C, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xAF, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xAF, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xAF, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x03, 0x2C, 0x00, 0x00, 0x02, 0xAF, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, + 0x00, 0xFA, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x03, 0x2C, 0x00, 0x00, 0x02, 0xAF, 0x00, 0x00, + 0x03, 0x6B, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xAF, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x03, 0x2C, 0x00, 0x00, 0x02, 0xAF, 0x00, 0x00, + 0x03, 0x6B, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x03, 0x6B, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0xAF, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x03, 0x2C, 0x00, 0x00, + 0x02, 0xAF, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, + 0x03, 0x6B, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, 0x03, 0x6B, 0x00, 0x00, + 0x02, 0x71, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02, 0x71, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x21, 0x00, 0x21, 0x00, 0x21, 0x00, 0x21, 0x00, 0x85, + 0x00, 0xCE, 0x01, 0x1E, 0x01, 0x68, 0x01, 0x7C, 0x01, 0xB0, 0x01, 0xE5, + 0x02, 0x4E, 0x02, 0x77, 0x02, 0x8A, 0x02, 0x9C, 0x02, 0xAF, 0x02, 0xCF, + 0x02, 0xF2, 0x03, 0x0B, 0x03, 0x39, 0x03, 0x60, 0x03, 0x84, 0x03, 0xB2, + 0x03, 0xE0, 0x03, 0xF9, 0x04, 0x28, 0x04, 0x55, 0x04, 0x74, 0x04, 0x92, + 0x04, 0xF6, 0x05, 0x11, 0x05, 0x76, 0x05, 0xA2, 0x05, 0xE1, 0x06, 0x0C, + 0x06, 0x46, 0x06, 0x66, 0x06, 0x93, 0x06, 0xBB, 0x06, 0xDE, 0x07, 0x08, + 0x07, 0x32, 0x07, 0x47, 0x07, 0x60, 0x07, 0x99, 0x07, 0xB2, 0x07, 0xDE, + 0x07, 0xFE, 0x08, 0x21, 0x08, 0x47, 0x08, 0x78, 0x08, 0xB3, 0x08, 0xE1, + 0x09, 0x00, 0x09, 0x21, 0x09, 0x4F, 0x09, 0x7A, 0x09, 0xC2, 0x09, 0xEE, + 0x0A, 0x2B, 0x0A, 0x48, 0x0A, 0x68, 0x0A, 0x84, 0x0A, 0xBE, 0x0A, 0xCF, + 0x0A, 0xF5, 0x0B, 0x20, 0x0B, 0x5A, 0x0B, 0x7A, 0x0B, 0xA7, 0x0B, 0xCF, + 0x0B, 0xF2, 0x0C, 0x1C, 0x0C, 0x46, 0x0C, 0x5B, 0x0C, 0x74, 0x0C, 0xAD, + 0x0C, 0xC6, 0x0C, 0xF2, 0x0D, 0x12, 0x0D, 0x35, 0x0D, 0x5B, 0x0D, 0x8C, + 0x0D, 0xC7, 0x0D, 0xF5, 0x0E, 0x14, 0x0E, 0x35, 0x0E, 0x63, 0x0E, 0x8E, + 0x0E, 0xD6, 0x0F, 0x02, 0x0F, 0x3F, 0x0F, 0x92, 0x0F, 0xA6, 0x0F, 0xF8, + 0x10, 0x48, 0x10, 0x70, 0x10, 0x91, 0x10, 0xC8, 0x10, 0xF7, 0x11, 0x30, + 0x11, 0x43, 0x11, 0x74, 0x11, 0x98, 0x11, 0xC2, 0x11, 0xEB, 0x12, 0x13, + 0x12, 0x31, 0x12, 0xAF, 0x12, 0xF7, 0x13, 0x26, 0x13, 0x55, 0x13, 0x80, + 0x13, 0x9F, 0x13, 0xE9, 0x14, 0x5E, 0x14, 0xD3, 0x14, 0xFE, 0x14, 0xFE, + 0x15, 0x10, 0x15, 0x22, 0x15, 0x3F, 0x15, 0x5C, 0x15, 0x70, 0x15, 0x84, + 0x15, 0xBE, 0x15, 0xFB, 0x16, 0x0E, 0x16, 0x21, 0x16, 0x3D, 0x16, 0xD9, + 0x17, 0x13, 0x17, 0x33, 0x17, 0x76, 0x17, 0x9F, 0x18, 0x18, 0x18, 0x7E, + 0x19, 0x1A, 0x19, 0x6B, 0x19, 0x8C, 0x19, 0xAC, 0x19, 0xC0, 0x19, 0xF9, + 0x1A, 0x28, 0x1A, 0x53, 0x1A, 0x86, 0x1A, 0xC0, 0x1A, 0xD8, 0x1B, 0x09, + 0x1B, 0x31, 0x1B, 0x96, 0x1B, 0xC2, 0x1B, 0xE9, 0x1C, 0x1D, 0x1C, 0x56, + 0x1C, 0x7E, 0x1C, 0xD5, 0x1C, 0xFF, 0x1D, 0x22, 0x1D, 0x42, 0x1D, 0x62, + 0x1D, 0x81, 0x1D, 0xAD, 0x1E, 0x01, 0x1E, 0x49, 0x1E, 0x6C, 0x1E, 0x97, + 0x1E, 0xC6, 0x1E, 0xF4, 0x1F, 0x24, 0x1F, 0x4A, 0x1F, 0x80, 0x1F, 0xAB, + 0x1F, 0xDE, 0x20, 0x18, 0x20, 0x30, 0x20, 0x61, 0x20, 0x89, 0x20, 0xEE, + 0x21, 0x1A, 0x21, 0x41, 0x21, 0x75, 0x21, 0xAE, 0x21, 0xD6, 0x22, 0x2D, + 0x22, 0x57, 0x22, 0x7A, 0x22, 0x9A, 0x22, 0xBA, 0x22, 0xD9, 0x23, 0x05, + 0x23, 0x59, 0x23, 0xA1, 0x23, 0xC4, 0x23, 0xE9, 0x24, 0x14, 0x24, 0x43, + 0x24, 0x71, 0x24, 0xA1, 0x24, 0xC7, 0x24, 0xFD, 0x25, 0x28, 0x25, 0x5B, + 0x25, 0x95, 0x25, 0xAD, 0x25, 0xDE, 0x26, 0x06, 0x26, 0x6B, 0x26, 0x97, + 0x26, 0xBE, 0x26, 0xF2, 0x27, 0x2B, 0x27, 0x53, 0x27, 0xAA, 0x27, 0xD4, + 0x27, 0xF7, 0x28, 0x17, 0x28, 0x37, 0x28, 0x56, 0x28, 0x82, 0x28, 0xD6, + 0x29, 0x1E, 0x29, 0x41, 0x29, 0x6C, 0x29, 0x9B, 0x29, 0xC9, 0x29, 0xF9, + 0x2A, 0x1F, 0x2A, 0x55, 0x2A, 0x80, 0x2A, 0xB3, 0x2A, 0xED, 0x2B, 0x05, + 0x2B, 0x36, 0x2B, 0x5E, 0x2B, 0xC3, 0x2B, 0xEF, 0x2C, 0x16, 0x2C, 0x4A, + 0x2C, 0x83, 0x2C, 0xAB, 0x2D, 0x02, 0x2D, 0x2C, 0x2D, 0x4F, 0x2D, 0x6F, + 0x2D, 0x8F, 0x2D, 0xAE, 0x2D, 0xDA, 0x2E, 0x2E, 0x2E, 0x76, 0x2E, 0x99, + 0x2E, 0xBE, 0x2E, 0xE9, 0x2F, 0x18, 0x2F, 0x46, 0x2F, 0x76, 0x2F, 0x9C, + 0x2F, 0xD2, 0x30, 0x22, 0x30, 0x35, 0x30, 0x54, 0x30, 0x71, 0x30, 0x91, + 0x30, 0xD5, 0x31, 0x29, 0x31, 0x57, 0x31, 0xA4, 0x32, 0x12, 0x32, 0x4E, + 0x32, 0x84, 0x32, 0xD9, 0x33, 0x2C, 0x33, 0x87, 0x33, 0xCB, 0x34, 0x48, + 0x34, 0x9C, 0x34, 0xE6, 0x35, 0x33, 0x35, 0x7F, 0x35, 0xDB, 0x36, 0x21, + 0x36, 0x52, 0x36, 0x86, 0x36, 0xD1, 0x37, 0x05, 0x37, 0x73, 0x37, 0xBB, + 0x38, 0x01, 0x38, 0x54, 0x38, 0x90, 0x39, 0x00, 0x39, 0x3B, 0x39, 0x7C, + 0x39, 0xC8, 0x39, 0xFE, 0x3A, 0x42, 0x3A, 0x84, 0x3A, 0xBC, 0x3A, 0xEB, + 0x3B, 0x2D, 0x3B, 0x65, 0x3B, 0xB8, 0x3C, 0x35, 0x3C, 0xA5, 0x3C, 0xD1, + 0x3D, 0x13, 0x3D, 0x55, 0x3D, 0x76, 0x3D, 0xAF, 0x3E, 0x0A, 0x3E, 0x66, + 0x3E, 0xBB, 0x3F, 0x17, 0x3F, 0x63, 0x3F, 0xBA, 0x3F, 0xFB, 0x40, 0x52, + 0x40, 0x93, 0x40, 0xDB, 0x41, 0x2E, 0x41, 0x74, 0x41, 0xAF, 0x41, 0xFB, + 0x42, 0x3C, 0x42, 0x4F, 0x42, 0xB4, 0x43, 0x19, 0x43, 0x59, 0x43, 0x99, + 0x43, 0xE8, 0x44, 0x37, 0x44, 0x73, 0x44, 0xAF, 0x44, 0xC1, 0x45, 0x22, + 0x45, 0x50, 0x45, 0x84, 0x45, 0xBA, 0x45, 0xE2, 0x46, 0x3B, 0x46, 0x64, + 0x46, 0x99, 0x46, 0xF1, 0x47, 0x15, 0x47, 0x60, 0x47, 0x8B, 0x47, 0xC5, + 0x47, 0xE5, 0x48, 0x0D, 0x48, 0x37, 0x48, 0x70, 0x48, 0x90, 0x48, 0xB3, + 0x48, 0xD9, 0x48, 0xF8, 0x49, 0x23, 0x49, 0x6B, 0x49, 0x97, 0x49, 0xCC, + 0x49, 0xE4, 0x4A, 0x49, 0x4A, 0x75, 0x4A, 0x9C, 0x4A, 0xD0, 0x4A, 0xF8, + 0x4B, 0x2A, 0x4B, 0x81, 0x4B, 0xB0, 0x4B, 0xEB, 0x4C, 0x11, 0x4C, 0x3F, + 0x4C, 0x6F, 0x4C, 0xA8, 0x4C, 0xDF, 0x4D, 0x04, 0x4D, 0x27, 0x4D, 0x7B, + 0x4D, 0xA6, 0x4D, 0xDB, 0x4E, 0x15, 0x4E, 0x2D, 0x4E, 0x5F, 0x4E, 0x87, + 0x4E, 0xEC, 0x4F, 0x18, 0x4F, 0x3F, 0x4F, 0x73, 0x4F, 0xAC, 0x4F, 0xD4, + 0x50, 0x2B, 0x50, 0x55, 0x50, 0x78, 0x50, 0x98, 0x50, 0xBE, 0x50, 0xDE, + 0x50, 0xFD, 0x51, 0x29, 0x51, 0x7D, 0x51, 0xC5, 0x51, 0xE8, 0x52, 0x0D, + 0x52, 0x38, 0x52, 0x67, 0x52, 0x95, 0x52, 0xC5, 0x52, 0xEB, 0x53, 0x24, + 0x53, 0x5B, 0x53, 0x96, 0x53, 0xAF, 0x53, 0xC8, 0x53, 0xF6, 0x54, 0x24, + 0x54, 0x73, 0x54, 0xC2, 0x54, 0xFC, 0x55, 0x36, 0x55, 0x4B, 0x55, 0x60, + 0x55, 0x7D, 0x55, 0x9A, 0x55, 0xE0, 0x56, 0x26, 0x56, 0x60, 0x56, 0x9A, + 0x56, 0xD5, 0x57, 0x10, 0x57, 0x4F, 0x57, 0x8E, 0x57, 0xF1, 0x58, 0x54, + 0x58, 0x9F, 0x58, 0xEA, 0x59, 0x19, 0x59, 0x48, 0x59, 0x7D, 0x59, 0xB2, + 0x59, 0xDD, 0x5A, 0x08, 0x5A, 0x42, 0x5A, 0xA7, 0x5A, 0xE0, 0x5B, 0x08, + 0x5B, 0x5F, 0x5B, 0x89, 0x5B, 0xAC, 0x5B, 0xCC, 0x5B, 0xEB, 0x5C, 0x17, + 0x5C, 0x6B, 0x5C, 0xB3, 0x5C, 0xE2, 0x5D, 0x10, 0x5D, 0x40, 0x5D, 0xA5, + 0x5D, 0xCA, 0x5D, 0xF5, 0x5E, 0x30, 0x5E, 0x5B, 0x5E, 0x95, 0x5E, 0xAD, + 0x5E, 0xD5, 0x5F, 0x3A, 0x5F, 0x66, 0x5F, 0x8D, 0x5F, 0xC1, 0x5F, 0xFA, + 0x60, 0x22, 0x60, 0x79, 0x60, 0xA3, 0x60, 0xC6, 0x60, 0xE6, 0x61, 0x0C, + 0x61, 0x2C, 0x61, 0x4B, 0x61, 0x77, 0x61, 0xCB, 0x62, 0x13, 0x62, 0x36, + 0x62, 0x5B, 0x62, 0x86, 0x62, 0xB5, 0x62, 0xE3, 0x63, 0x13, 0x63, 0x39, + 0x63, 0x72, 0x63, 0xA9, 0x63, 0xD4, 0x64, 0x07, 0x64, 0x41, 0x64, 0x59, + 0x64, 0x8A, 0x64, 0xB2, 0x65, 0x17, 0x65, 0x43, 0x65, 0x6A, 0x65, 0x9E, + 0x65, 0xD7, 0x65, 0xFF, 0x66, 0x56, 0x66, 0x80, 0x66, 0xA3, 0x66, 0xC3, + 0x66, 0xE9, 0x67, 0x09, 0x67, 0x28, 0x67, 0x54, 0x67, 0xA8, 0x67, 0xF0, + 0x68, 0x13, 0x68, 0x38, 0x68, 0x63, 0x68, 0x92, 0x68, 0xC0, 0x68, 0xF0, + 0x69, 0x16, 0x69, 0x4F, 0x69, 0x86, 0x69, 0xBC, 0x69, 0xF1, 0x6A, 0x26, + 0x6A, 0x61, 0x6A, 0x9C, 0x6A, 0xB5, 0x6A, 0xCE, 0x6A, 0xEB, 0x6B, 0x08, + 0x6B, 0x42, 0x6B, 0x7C, 0x6B, 0x91, 0x6B, 0xDC, 0x6C, 0x27, 0x6C, 0x61, + 0x6C, 0x9B, 0x6C, 0xEA, 0x6D, 0x39, 0x6D, 0x78, 0x6D, 0xB7, 0x6D, 0xE5, + 0x6E, 0x13, 0x6E, 0x42, 0x6E, 0x71, 0x6E, 0xD4, 0x6F, 0x37, 0x6F, 0x7D, + 0x6F, 0xC3, 0x6F, 0xEE, 0x70, 0x19, 0x70, 0x7C, 0x70, 0xDF, 0x71, 0x0E, + 0x71, 0x3D, 0x71, 0x78, 0x71, 0xAD, 0x71, 0xE2, 0x72, 0x0D, 0x72, 0x43, + 0x72, 0x74, 0x72, 0xA7, 0x72, 0xCD, 0x72, 0xF2, 0x73, 0x2B, 0x73, 0x62, + 0x73, 0x88, 0x73, 0xC1, 0x73, 0xF8, 0x74, 0x1E, 0x74, 0x43, 0x74, 0x7C, + 0x74, 0xB3, 0x74, 0xD9, 0x75, 0x12, 0x75, 0x49, 0x75, 0x7C, 0x75, 0xAD, + 0x75, 0xE3, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x40, 0x00, 0x20, + 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0A, 0x00, 0x00, 0x02, 0x00, 0x01, 0x53, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x18, 0x01, 0x26, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x10, 0x00, 0x54, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x07, 0x00, 0x64, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x03, 0x00, 0x3B, 0x00, 0x6B, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x10, 0x00, 0xA6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x05, 0x00, 0x11, 0x00, 0xB6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x06, 0x00, 0x0E, 0x00, 0xC7, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x00, 0x51, 0x00, 0xD5, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x09, 0x00, 0x2A, 0x01, 0x26, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0A, 0x00, 0x77, 0x01, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0B, 0x00, 0x13, 0x01, 0xC7, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0C, 0x00, 0x16, 0x01, 0xDA, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x00, 0x00, 0xA8, 0x01, 0xF0, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x01, 0x00, 0x20, 0x02, 0x98, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x02, 0x00, 0x0E, 0x02, 0xB8, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x03, 0x00, 0x76, 0x02, 0xC6, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x04, 0x00, 0x20, 0x03, 0x3C, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x05, 0x00, 0x22, 0x03, 0x5C, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x06, 0x00, 0x1C, 0x03, 0x7E, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x07, 0x00, 0xA2, 0x03, 0x9A, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x09, 0x00, 0x54, 0x04, 0x3C, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x0A, 0x00, 0xEE, 0x04, 0x90, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x0B, 0x00, 0x26, 0x05, 0x7E, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x0C, 0x00, 0x2C, 0x05, 0xA4, 0x43, 0x6F, 0x70, 0x79, 0x72, 0x69, + 0x67, 0x68, 0x74, 0x20, 0x28, 0x63, 0x29, 0x20, 0x43, 0x72, 0x61, 0x69, + 0x67, 0x20, 0x4B, 0x72, 0x6F, 0x65, 0x67, 0x65, 0x72, 0x20, 0x28, 0x65, + 0x6E, 0x67, 0x29, 0x20, 0x26, 0x20, 0x4E, 0x69, 0x6B, 0x6F, 0x6C, 0x61, + 0x79, 0x20, 0x44, 0x75, 0x62, 0x69, 0x6E, 0x61, 0x20, 0x28, 0x72, 0x75, + 0x73, 0x29, 0x2C, 0x20, 0x32, 0x30, 0x30, 0x31, 0x2E, 0x20, 0x41, 0x6C, + 0x6C, 0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x73, 0x20, 0x72, 0x65, 0x73, + 0x65, 0x72, 0x76, 0x65, 0x64, 0x2E, 0x68, 0x6F, 0x6F, 0x67, 0x65, 0x20, + 0x30, 0x35, 0x5F, 0x35, 0x35, 0x20, 0x43, 0x79, 0x72, 0x32, 0x52, 0x65, + 0x67, 0x75, 0x6C, 0x61, 0x72, 0x43, 0x72, 0x61, 0x69, 0x67, 0x4B, 0x72, + 0x6F, 0x65, 0x67, 0x65, 0x72, 0x28, 0x65, 0x6E, 0x67, 0x29, 0x26, 0x4E, + 0x69, 0x6B, 0x6F, 0x6C, 0x61, 0x79, 0x44, 0x75, 0x62, 0x69, 0x6E, 0x61, + 0x28, 0x72, 0x75, 0x73, 0x29, 0x3A, 0x20, 0x68, 0x6F, 0x6F, 0x67, 0x65, + 0x20, 0x30, 0x35, 0x5F, 0x35, 0x35, 0x20, 0x43, 0x79, 0x72, 0x3A, 0x20, + 0x32, 0x30, 0x30, 0x31, 0x68, 0x6F, 0x6F, 0x67, 0x65, 0x20, 0x30, 0x35, + 0x5F, 0x35, 0x35, 0x20, 0x43, 0x79, 0x72, 0x32, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6F, 0x6E, 0x20, 0x31, 0x2E, 0x32, 0x3B, 0x20, 0x32, 0x30, 0x30, + 0x31, 0x68, 0x6F, 0x6F, 0x67, 0x65, 0x30, 0x35, 0x5F, 0x35, 0x35, 0x43, + 0x79, 0x72, 0x32, 0x68, 0x6F, 0x6F, 0x67, 0x65, 0x20, 0x30, 0x35, 0x5F, + 0x35, 0x35, 0x20, 0x43, 0x79, 0x72, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, + 0x74, 0x72, 0x61, 0x64, 0x65, 0x6D, 0x61, 0x72, 0x6B, 0x20, 0x6F, 0x66, + 0x20, 0x74, 0x68, 0x65, 0x20, 0x43, 0x72, 0x61, 0x69, 0x67, 0x20, 0x4B, + 0x72, 0x6F, 0x65, 0x67, 0x65, 0x72, 0x20, 0x28, 0x65, 0x6E, 0x67, 0x29, + 0x20, 0x26, 0x20, 0x4E, 0x69, 0x6B, 0x6F, 0x6C, 0x61, 0x79, 0x20, 0x44, + 0x75, 0x62, 0x69, 0x6E, 0x61, 0x20, 0x28, 0x72, 0x75, 0x73, 0x29, 0x2E, + 0x43, 0x72, 0x61, 0x69, 0x67, 0x20, 0x4B, 0x72, 0x6F, 0x65, 0x67, 0x65, + 0x72, 0x20, 0x28, 0x65, 0x6E, 0x67, 0x29, 0x20, 0x26, 0x20, 0x4E, 0x69, + 0x6B, 0x6F, 0x6C, 0x61, 0x79, 0x20, 0x44, 0x75, 0x62, 0x69, 0x6E, 0x61, + 0x20, 0x28, 0x72, 0x75, 0x73, 0x29, 0x43, 0x6F, 0x70, 0x79, 0x72, 0x69, + 0x67, 0x68, 0x74, 0x20, 0x28, 0x63, 0x29, 0x20, 0x43, 0x72, 0x61, 0x69, + 0x67, 0x20, 0x4B, 0x72, 0x6F, 0x65, 0x67, 0x65, 0x72, 0x20, 0x28, 0x65, + 0x6E, 0x67, 0x29, 0x20, 0x7C, 0x20, 0x77, 0x77, 0x77, 0x2E, 0x6D, 0x69, + 0x6E, 0x69, 0x6D, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x20, 0x7C, 0x20, 0x26, + 0x20, 0x4E, 0x69, 0x6B, 0x6F, 0x6C, 0x61, 0x79, 0x20, 0x44, 0x75, 0x62, + 0x69, 0x6E, 0x61, 0x20, 0x28, 0x72, 0x75, 0x73, 0x29, 0x20, 0x7C, 0x20, + 0x77, 0x77, 0x77, 0x2E, 0x64, 0x2D, 0x73, 0x2E, 0x72, 0x75, 0x20, 0x7C, + 0x20, 0x2C, 0x20, 0x32, 0x30, 0x30, 0x31, 0x2E, 0x20, 0x41, 0x6C, 0x6C, + 0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x73, 0x20, 0x72, 0x65, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x64, 0x2E, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, + 0x76, 0x65, 0x64, 0x69, 0x2E, 0x64, 0x2D, 0x73, 0x2E, 0x72, 0x75, 0x2F, + 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x6D, + 0x69, 0x6E, 0x69, 0x6D, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x2F, 0x00, 0x43, + 0x00, 0x6F, 0x00, 0x70, 0x00, 0x79, 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, + 0x00, 0x68, 0x00, 0x74, 0x00, 0x20, 0x00, 0x28, 0x00, 0x63, 0x00, 0x29, + 0x00, 0x20, 0x00, 0x43, 0x00, 0x72, 0x00, 0x61, 0x00, 0x69, 0x00, 0x67, + 0x00, 0x20, 0x00, 0x4B, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x65, 0x00, 0x67, + 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x28, 0x00, 0x65, 0x00, 0x6E, + 0x00, 0x67, 0x00, 0x29, 0x00, 0x20, 0x00, 0x26, 0x00, 0x20, 0x00, 0x4E, + 0x00, 0x69, 0x00, 0x6B, 0x00, 0x6F, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x79, + 0x00, 0x20, 0x00, 0x44, 0x00, 0x75, 0x00, 0x62, 0x00, 0x69, 0x00, 0x6E, + 0x00, 0x61, 0x00, 0x20, 0x00, 0x28, 0x00, 0x72, 0x00, 0x75, 0x00, 0x73, + 0x00, 0x29, 0x00, 0x2C, 0x00, 0x20, 0x00, 0x32, 0x00, 0x30, 0x00, 0x30, + 0x00, 0x31, 0x00, 0x2E, 0x00, 0x20, 0x00, 0x41, 0x00, 0x6C, 0x00, 0x6C, + 0x00, 0x20, 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, 0x00, 0x68, 0x00, 0x74, + 0x00, 0x73, 0x00, 0x20, 0x00, 0x72, 0x00, 0x65, 0x00, 0x73, 0x00, 0x65, + 0x00, 0x72, 0x00, 0x76, 0x00, 0x65, 0x00, 0x64, 0x00, 0x2E, 0x00, 0x68, + 0x00, 0x6F, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x65, 0x00, 0x20, 0x00, 0x30, + 0x00, 0x35, 0x00, 0x5F, 0x00, 0x35, 0x00, 0x35, 0x00, 0x20, 0x00, 0x43, + 0x00, 0x79, 0x00, 0x72, 0x00, 0x32, 0x00, 0x52, 0x00, 0x65, 0x00, 0x67, + 0x00, 0x75, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x72, 0x00, 0x43, 0x00, 0x72, + 0x00, 0x61, 0x00, 0x69, 0x00, 0x67, 0x00, 0x4B, 0x00, 0x72, 0x00, 0x6F, + 0x00, 0x65, 0x00, 0x67, 0x00, 0x65, 0x00, 0x72, 0x00, 0x28, 0x00, 0x65, + 0x00, 0x6E, 0x00, 0x67, 0x00, 0x29, 0x00, 0x26, 0x00, 0x4E, 0x00, 0x69, + 0x00, 0x6B, 0x00, 0x6F, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x79, 0x00, 0x44, + 0x00, 0x75, 0x00, 0x62, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x28, + 0x00, 0x72, 0x00, 0x75, 0x00, 0x73, 0x00, 0x29, 0x00, 0x3A, 0x00, 0x20, + 0x00, 0x68, 0x00, 0x6F, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x65, 0x00, 0x20, + 0x00, 0x30, 0x00, 0x35, 0x00, 0x5F, 0x00, 0x35, 0x00, 0x35, 0x00, 0x20, + 0x00, 0x43, 0x00, 0x79, 0x00, 0x72, 0x00, 0x3A, 0x00, 0x20, 0x00, 0x32, + 0x00, 0x30, 0x00, 0x30, 0x00, 0x31, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x6F, + 0x00, 0x67, 0x00, 0x65, 0x00, 0x20, 0x00, 0x30, 0x00, 0x35, 0x00, 0x5F, + 0x00, 0x35, 0x00, 0x35, 0x00, 0x20, 0x00, 0x43, 0x00, 0x79, 0x00, 0x72, + 0x00, 0x32, 0x00, 0x56, 0x00, 0x65, 0x00, 0x72, 0x00, 0x73, 0x00, 0x69, + 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x31, 0x00, 0x2E, 0x00, 0x32, + 0x00, 0x3B, 0x00, 0x20, 0x00, 0x32, 0x00, 0x30, 0x00, 0x30, 0x00, 0x31, + 0x00, 0x68, 0x00, 0x6F, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x65, 0x00, 0x30, + 0x00, 0x35, 0x00, 0x5F, 0x00, 0x35, 0x00, 0x35, 0x00, 0x43, 0x00, 0x79, + 0x00, 0x72, 0x00, 0x32, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x6F, 0x00, 0x67, + 0x00, 0x65, 0x00, 0x20, 0x00, 0x30, 0x00, 0x35, 0x00, 0x5F, 0x00, 0x35, + 0x00, 0x35, 0x00, 0x20, 0x00, 0x43, 0x00, 0x79, 0x00, 0x72, 0x00, 0x20, + 0x00, 0x69, 0x00, 0x73, 0x00, 0x20, 0x00, 0x61, 0x00, 0x20, 0x00, 0x74, + 0x00, 0x72, 0x00, 0x61, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6D, 0x00, 0x61, + 0x00, 0x72, 0x00, 0x6B, 0x00, 0x20, 0x00, 0x6F, 0x00, 0x66, 0x00, 0x20, + 0x00, 0x74, 0x00, 0x68, 0x00, 0x65, 0x00, 0x20, 0x00, 0x43, 0x00, 0x72, + 0x00, 0x61, 0x00, 0x69, 0x00, 0x67, 0x00, 0x20, 0x00, 0x4B, 0x00, 0x72, + 0x00, 0x6F, 0x00, 0x65, 0x00, 0x67, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, + 0x00, 0x28, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x67, 0x00, 0x29, 0x00, 0x20, + 0x00, 0x26, 0x00, 0x20, 0x00, 0x4E, 0x00, 0x69, 0x00, 0x6B, 0x00, 0x6F, + 0x00, 0x6C, 0x00, 0x61, 0x00, 0x79, 0x00, 0x20, 0x00, 0x44, 0x00, 0x75, + 0x00, 0x62, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x20, 0x00, 0x28, + 0x00, 0x72, 0x00, 0x75, 0x00, 0x73, 0x00, 0x29, 0x00, 0x2E, 0x00, 0x43, + 0x00, 0x72, 0x00, 0x61, 0x00, 0x69, 0x00, 0x67, 0x00, 0x20, 0x00, 0x4B, + 0x00, 0x72, 0x00, 0x6F, 0x00, 0x65, 0x00, 0x67, 0x00, 0x65, 0x00, 0x72, + 0x00, 0x20, 0x00, 0x28, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x67, 0x00, 0x29, + 0x00, 0x20, 0x00, 0x26, 0x00, 0x20, 0x00, 0x4E, 0x00, 0x69, 0x00, 0x6B, + 0x00, 0x6F, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x79, 0x00, 0x20, 0x00, 0x44, + 0x00, 0x75, 0x00, 0x62, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x20, + 0x00, 0x28, 0x00, 0x72, 0x00, 0x75, 0x00, 0x73, 0x00, 0x29, 0x00, 0x43, + 0x00, 0x6F, 0x00, 0x70, 0x00, 0x79, 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, + 0x00, 0x68, 0x00, 0x74, 0x00, 0x20, 0x00, 0x28, 0x00, 0x63, 0x00, 0x29, + 0x00, 0x20, 0x00, 0x43, 0x00, 0x72, 0x00, 0x61, 0x00, 0x69, 0x00, 0x67, + 0x00, 0x20, 0x00, 0x4B, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x65, 0x00, 0x67, + 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x28, 0x00, 0x65, 0x00, 0x6E, + 0x00, 0x67, 0x00, 0x29, 0x00, 0x20, 0x00, 0x7C, 0x00, 0x20, 0x00, 0x77, + 0x00, 0x77, 0x00, 0x77, 0x00, 0x2E, 0x00, 0x6D, 0x00, 0x69, 0x00, 0x6E, + 0x00, 0x69, 0x00, 0x6D, 0x00, 0x6C, 0x00, 0x2E, 0x00, 0x63, 0x00, 0x6F, + 0x00, 0x6D, 0x00, 0x20, 0x00, 0x7C, 0x00, 0x20, 0x00, 0x26, 0x00, 0x20, + 0x00, 0x4E, 0x00, 0x69, 0x00, 0x6B, 0x00, 0x6F, 0x00, 0x6C, 0x00, 0x61, + 0x00, 0x79, 0x00, 0x20, 0x00, 0x44, 0x00, 0x75, 0x00, 0x62, 0x00, 0x69, + 0x00, 0x6E, 0x00, 0x61, 0x00, 0x20, 0x00, 0x28, 0x00, 0x72, 0x00, 0x75, + 0x00, 0x73, 0x00, 0x29, 0x00, 0x20, 0x00, 0x7C, 0x00, 0x20, 0x00, 0x77, + 0x00, 0x77, 0x00, 0x77, 0x00, 0x2E, 0x00, 0x64, 0x00, 0x2D, 0x00, 0x73, + 0x00, 0x2E, 0x00, 0x72, 0x00, 0x75, 0x00, 0x20, 0x00, 0x7C, 0x00, 0x20, + 0x00, 0x2C, 0x00, 0x20, 0x00, 0x32, 0x00, 0x30, 0x00, 0x30, 0x00, 0x31, + 0x00, 0x2E, 0x00, 0x20, 0x00, 0x41, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x20, + 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, 0x00, 0x68, 0x00, 0x74, 0x00, 0x73, + 0x00, 0x20, 0x00, 0x72, 0x00, 0x65, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, + 0x00, 0x76, 0x00, 0x65, 0x00, 0x64, 0x00, 0x2E, 0x00, 0x68, 0x00, 0x74, + 0x00, 0x74, 0x00, 0x70, 0x00, 0x3A, 0x00, 0x2F, 0x00, 0x2F, 0x00, 0x76, + 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x2E, 0x00, 0x64, 0x00, 0x2D, + 0x00, 0x73, 0x00, 0x2E, 0x00, 0x72, 0x00, 0x75, 0x00, 0x2F, 0x00, 0x68, + 0x00, 0x74, 0x00, 0x74, 0x00, 0x70, 0x00, 0x3A, 0x00, 0x2F, 0x00, 0x2F, + 0x00, 0x77, 0x00, 0x77, 0x00, 0x77, 0x00, 0x2E, 0x00, 0x6D, 0x00, 0x69, + 0x00, 0x6E, 0x00, 0x69, 0x00, 0x6D, 0x00, 0x6C, 0x00, 0x2E, 0x00, 0x63, + 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x2F, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7B, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x01, 0x02, 0x00, 0x02, + 0x00, 0x03, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0x0A, + 0x00, 0x0B, 0x00, 0x0C, 0x00, 0x0D, 0x00, 0x0E, 0x00, 0x0F, 0x00, 0x10, + 0x00, 0x11, 0x00, 0x12, 0x00, 0x13, 0x00, 0x14, 0x00, 0x15, 0x00, 0x16, + 0x00, 0x17, 0x00, 0x18, 0x00, 0x19, 0x00, 0x1A, 0x00, 0x1B, 0x00, 0x1C, + 0x00, 0x1D, 0x00, 0x1E, 0x00, 0x1F, 0x00, 0x20, 0x00, 0x21, 0x00, 0x22, + 0x00, 0x23, 0x00, 0x24, 0x00, 0x25, 0x00, 0x26, 0x00, 0x27, 0x00, 0x28, + 0x00, 0x29, 0x00, 0x2A, 0x00, 0x2B, 0x00, 0x2C, 0x00, 0x2D, 0x00, 0x2E, + 0x00, 0x2F, 0x00, 0x30, 0x00, 0x31, 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, + 0x00, 0x35, 0x00, 0x36, 0x00, 0x37, 0x00, 0x38, 0x00, 0x39, 0x00, 0x3A, + 0x00, 0x3B, 0x00, 0x3C, 0x00, 0x3D, 0x00, 0x3E, 0x00, 0x3F, 0x00, 0x40, + 0x00, 0x41, 0x00, 0x42, 0x00, 0x43, 0x00, 0x44, 0x00, 0x45, 0x00, 0x46, + 0x00, 0x47, 0x00, 0x48, 0x00, 0x49, 0x00, 0x4A, 0x00, 0x4B, 0x00, 0x4C, + 0x00, 0x4D, 0x00, 0x4E, 0x00, 0x4F, 0x00, 0x50, 0x00, 0x51, 0x00, 0x52, + 0x00, 0x53, 0x00, 0x54, 0x00, 0x55, 0x00, 0x56, 0x00, 0x57, 0x00, 0x58, + 0x00, 0x59, 0x00, 0x5A, 0x00, 0x5B, 0x00, 0x5C, 0x00, 0x5D, 0x00, 0x5E, + 0x00, 0x5F, 0x00, 0x60, 0x00, 0x61, 0x00, 0x82, 0x00, 0x83, 0x00, 0x84, + 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x8A, 0x00, 0x8B, + 0x00, 0x8C, 0x00, 0x8D, 0x00, 0x8E, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, + 0x00, 0x95, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9A, 0x00, 0x9C, 0x00, 0x9D, + 0x00, 0x9E, 0x00, 0x9F, 0x00, 0xA5, 0x00, 0xA6, 0x00, 0xA7, 0x00, 0xA8, + 0x00, 0xA9, 0x00, 0xAA, 0x00, 0xB0, 0x00, 0xB1, 0x00, 0xB2, 0x00, 0xB3, + 0x00, 0xB4, 0x00, 0xB5, 0x00, 0xC5, 0x00, 0xC6, 0x00, 0xE8, 0x00, 0xEF, + 0x00, 0xF1, 0x00, 0xF2, 0x00, 0xF3, 0x00, 0xF4, 0x00, 0xF5, 0x00, 0xF6, + 0x00, 0xFA, 0x01, 0x03, 0x01, 0x04, 0x01, 0x05, 0x01, 0x06, 0x00, 0xB6, + 0x01, 0x07, 0x01, 0x08, 0x01, 0x09, 0x00, 0x8F, 0x01, 0x0A, 0x01, 0x0B, + 0x01, 0x0C, 0x00, 0xB7, 0x00, 0xB9, 0x00, 0xBE, 0x00, 0xBB, 0x00, 0xBC, + 0x00, 0xBD, 0x01, 0x0D, 0x00, 0xC1, 0x00, 0xBF, 0x00, 0xC0, 0x00, 0xA2, + 0x01, 0x0E, 0x01, 0x0F, 0x00, 0xC4, 0x00, 0xC2, 0x00, 0xC3, 0x01, 0x10, + 0x01, 0x11, 0x01, 0x12, 0x01, 0x13, 0x01, 0x14, 0x01, 0x15, 0x01, 0x16, + 0x01, 0x17, 0x00, 0x96, 0x01, 0x18, 0x01, 0x19, 0x01, 0x1A, 0x01, 0x1B, + 0x01, 0x1C, 0x01, 0x1D, 0x01, 0x1E, 0x01, 0x1F, 0x01, 0x20, 0x01, 0x21, + 0x01, 0x22, 0x01, 0x23, 0x01, 0x24, 0x01, 0x25, 0x01, 0x26, 0x00, 0xAB, + 0x00, 0x97, 0x01, 0x27, 0x01, 0x28, 0x01, 0x29, 0x01, 0x2A, 0x00, 0xAC, + 0x00, 0xAD, 0x00, 0xC9, 0x00, 0xC7, 0x00, 0xAE, 0x00, 0x62, 0x00, 0x63, + 0x00, 0x90, 0x00, 0x64, 0x00, 0xCB, 0x00, 0x65, 0x00, 0xC8, 0x00, 0xCA, + 0x00, 0xCF, 0x00, 0xCC, 0x00, 0xCD, 0x00, 0xCE, 0x00, 0x66, 0x00, 0xD3, + 0x00, 0xD0, 0x00, 0xD1, 0x00, 0xAF, 0x00, 0x67, 0x00, 0x91, 0x00, 0xD6, + 0x00, 0xD4, 0x00, 0xD5, 0x00, 0x68, 0x00, 0x89, 0x00, 0x6A, 0x00, 0x69, + 0x00, 0x6B, 0x00, 0x6D, 0x00, 0x6C, 0x00, 0x6E, 0x00, 0xA0, 0x00, 0x6F, + 0x00, 0x71, 0x00, 0x70, 0x00, 0x72, 0x00, 0x73, 0x00, 0x75, 0x00, 0x74, + 0x00, 0x76, 0x00, 0x77, 0x00, 0x78, 0x00, 0x7A, 0x00, 0x79, 0x00, 0x7B, + 0x00, 0x7D, 0x00, 0x7C, 0x00, 0xB8, 0x00, 0xA1, 0x00, 0x7F, 0x00, 0x7E, + 0x00, 0x80, 0x00, 0x81, 0x00, 0xBA, 0x00, 0xD9, 0x01, 0x2B, 0x00, 0xA3, + 0x00, 0x05, 0x00, 0x04, 0x01, 0x2C, 0x01, 0x2D, 0x01, 0x2E, 0x01, 0x2F, + 0x01, 0x30, 0x01, 0x31, 0x01, 0x32, 0x01, 0x33, 0x01, 0x34, 0x01, 0x35, + 0x01, 0x36, 0x01, 0x37, 0x01, 0x38, 0x01, 0x39, 0x01, 0x3A, 0x01, 0x3B, + 0x01, 0x3C, 0x01, 0x3D, 0x01, 0x3E, 0x01, 0x3F, 0x01, 0x40, 0x01, 0x41, + 0x01, 0x42, 0x01, 0x43, 0x01, 0x44, 0x01, 0x45, 0x01, 0x46, 0x01, 0x47, + 0x01, 0x48, 0x01, 0x49, 0x01, 0x4A, 0x01, 0x4B, 0x01, 0x4C, 0x01, 0x4D, + 0x01, 0x4E, 0x01, 0x4F, 0x01, 0x50, 0x01, 0x51, 0x01, 0x52, 0x01, 0x53, + 0x01, 0x54, 0x01, 0x55, 0x01, 0x56, 0x01, 0x57, 0x01, 0x58, 0x01, 0x59, + 0x01, 0x5A, 0x01, 0x5B, 0x01, 0x5C, 0x01, 0x5D, 0x01, 0x5E, 0x01, 0x5F, + 0x01, 0x60, 0x01, 0x61, 0x01, 0x62, 0x01, 0x63, 0x01, 0x64, 0x01, 0x65, + 0x01, 0x66, 0x01, 0x67, 0x01, 0x68, 0x01, 0x69, 0x01, 0x6A, 0x01, 0x6B, + 0x01, 0x6C, 0x01, 0x6D, 0x01, 0x6E, 0x01, 0x6F, 0x01, 0x70, 0x01, 0x71, + 0x00, 0xD2, 0x01, 0x72, 0x01, 0x73, 0x01, 0x74, 0x01, 0x75, 0x01, 0x76, + 0x01, 0x77, 0x01, 0x78, 0x01, 0x79, 0x00, 0xF7, 0x00, 0xF8, 0x00, 0xF9, + 0x01, 0x7A, 0x01, 0x7B, 0x01, 0x7C, 0x01, 0x7D, 0x01, 0x7E, 0x01, 0x7F, + 0x01, 0x80, 0x01, 0x81, 0x01, 0x82, 0x01, 0x83, 0x01, 0x84, 0x01, 0x85, + 0x01, 0x86, 0x01, 0x87, 0x01, 0x88, 0x01, 0x89, 0x01, 0x8A, 0x01, 0x8B, + 0x01, 0x8C, 0x01, 0x8D, 0x01, 0x8E, 0x01, 0x8F, 0x01, 0x90, 0x01, 0x91, + 0x01, 0x92, 0x01, 0x93, 0x01, 0x94, 0x01, 0x95, 0x01, 0x96, 0x01, 0x97, + 0x01, 0x98, 0x01, 0x99, 0x01, 0x9A, 0x01, 0x9B, 0x01, 0x9C, 0x01, 0x9D, + 0x01, 0x9E, 0x01, 0x9F, 0x01, 0xA0, 0x01, 0xA1, 0x01, 0xA2, 0x01, 0xA3, + 0x01, 0xA4, 0x01, 0xA5, 0x01, 0xA6, 0x01, 0xA7, 0x01, 0xA8, 0x01, 0xA9, + 0x01, 0xAA, 0x01, 0xAB, 0x01, 0xAC, 0x01, 0xAD, 0x01, 0xAE, 0x01, 0xAF, + 0x01, 0xB0, 0x01, 0xB1, 0x01, 0xB2, 0x01, 0xB3, 0x01, 0xB4, 0x01, 0xB5, + 0x01, 0xB6, 0x01, 0xB7, 0x01, 0xB8, 0x01, 0xB9, 0x01, 0xBA, 0x01, 0xBB, + 0x01, 0xBC, 0x01, 0xBD, 0x01, 0xBE, 0x01, 0xBF, 0x01, 0xC0, 0x01, 0xC1, + 0x01, 0xC2, 0x01, 0xC3, 0x01, 0xC4, 0x01, 0xC5, 0x01, 0xC6, 0x01, 0xC7, + 0x01, 0xC8, 0x01, 0xC9, 0x01, 0xCA, 0x01, 0xCB, 0x01, 0xCC, 0x01, 0xCD, + 0x01, 0xCE, 0x01, 0xCF, 0x01, 0xD0, 0x01, 0xD1, 0x01, 0xD2, 0x01, 0xD3, + 0x01, 0xD4, 0x01, 0xD5, 0x01, 0xD6, 0x01, 0xD7, 0x01, 0xD8, 0x01, 0xD9, + 0x01, 0xDA, 0x01, 0xDB, 0x01, 0xDC, 0x01, 0xDD, 0x01, 0xDE, 0x01, 0xDF, + 0x01, 0xE0, 0x01, 0xE1, 0x01, 0xE2, 0x01, 0xE3, 0x01, 0xE4, 0x01, 0xE5, + 0x01, 0xE6, 0x01, 0xE7, 0x01, 0xE8, 0x01, 0xE9, 0x01, 0xEA, 0x01, 0xEB, + 0x01, 0xEC, 0x01, 0xED, 0x01, 0xEE, 0x01, 0xEF, 0x01, 0xF0, 0x01, 0xF1, + 0x01, 0xF2, 0x01, 0xF3, 0x01, 0xF4, 0x01, 0xF5, 0x01, 0xF6, 0x01, 0xF7, + 0x01, 0xF8, 0x01, 0xF9, 0x01, 0xFA, 0x01, 0xFB, 0x01, 0xFC, 0x01, 0xFD, + 0x01, 0xFE, 0x01, 0xFF, 0x02, 0x00, 0x02, 0x01, 0x02, 0x02, 0x02, 0x03, + 0x02, 0x04, 0x02, 0x05, 0x02, 0x06, 0x02, 0x07, 0x02, 0x08, 0x02, 0x09, + 0x02, 0x0A, 0x02, 0x0B, 0x02, 0x0C, 0x02, 0x0D, 0x02, 0x0E, 0x02, 0x0F, + 0x02, 0x10, 0x02, 0x11, 0x02, 0x12, 0x02, 0x13, 0x02, 0x14, 0x02, 0x15, + 0x02, 0x16, 0x02, 0x17, 0x02, 0x18, 0x02, 0x19, 0x02, 0x1A, 0x02, 0x1B, + 0x02, 0x1C, 0x02, 0x1D, 0x02, 0x1E, 0x02, 0x1F, 0x02, 0x20, 0x02, 0x21, + 0x02, 0x22, 0x02, 0x23, 0x02, 0x24, 0x02, 0x25, 0x02, 0x26, 0x02, 0x27, + 0x02, 0x28, 0x02, 0x29, 0x02, 0x2A, 0x02, 0x2B, 0x02, 0x2C, 0x02, 0x2D, + 0x02, 0x2E, 0x02, 0x2F, 0x02, 0x30, 0x02, 0x31, 0x02, 0x32, 0x02, 0x33, + 0x02, 0x34, 0x02, 0x35, 0x02, 0x36, 0x02, 0x37, 0x02, 0x38, 0x02, 0x39, + 0x02, 0x3A, 0x02, 0x3B, 0x02, 0x3C, 0x02, 0x3D, 0x02, 0x3E, 0x02, 0x3F, + 0x02, 0x40, 0x02, 0x41, 0x02, 0x42, 0x02, 0x43, 0x02, 0x44, 0x02, 0x45, + 0x02, 0x46, 0x02, 0x47, 0x02, 0x48, 0x02, 0x49, 0x02, 0x4A, 0x02, 0x4B, + 0x02, 0x4C, 0x02, 0x4D, 0x02, 0x4E, 0x02, 0x4F, 0x02, 0x50, 0x02, 0x51, + 0x02, 0x52, 0x02, 0x53, 0x02, 0x54, 0x02, 0x55, 0x02, 0x56, 0x00, 0xE9, + 0x00, 0xF0, 0x00, 0xEB, 0x00, 0xED, 0x00, 0xEA, 0x00, 0xEC, 0x00, 0xEE, + 0x02, 0x57, 0x02, 0x58, 0x02, 0x59, 0x05, 0x2E, 0x6E, 0x75, 0x6C, 0x6C, + 0x07, 0x46, 0x4C, 0x32, 0x30, 0x33, 0x39, 0x68, 0x07, 0x46, 0x4C, 0x30, + 0x30, 0x42, 0x31, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x43, 0x30, 0x68, + 0x07, 0x46, 0x4C, 0x30, 0x30, 0x43, 0x31, 0x68, 0x07, 0x46, 0x4C, 0x30, + 0x30, 0x43, 0x33, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x43, 0x34, 0x68, + 0x07, 0x46, 0x4C, 0x30, 0x30, 0x43, 0x35, 0x68, 0x07, 0x46, 0x4C, 0x30, + 0x30, 0x43, 0x37, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x43, 0x38, 0x68, + 0x07, 0x46, 0x4C, 0x30, 0x30, 0x43, 0x39, 0x68, 0x07, 0x46, 0x4C, 0x30, + 0x30, 0x44, 0x31, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x44, 0x36, 0x68, + 0x07, 0x46, 0x4C, 0x30, 0x30, 0x44, 0x38, 0x68, 0x07, 0x46, 0x4C, 0x30, + 0x30, 0x44, 0x43, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x44, 0x46, 0x68, + 0x07, 0x46, 0x4C, 0x30, 0x30, 0x45, 0x30, 0x68, 0x07, 0x46, 0x4C, 0x30, + 0x30, 0x45, 0x31, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x45, 0x32, 0x68, + 0x07, 0x46, 0x4C, 0x30, 0x30, 0x45, 0x33, 0x68, 0x07, 0x46, 0x4C, 0x30, + 0x30, 0x45, 0x34, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x45, 0x35, 0x68, + 0x07, 0x46, 0x4C, 0x30, 0x30, 0x45, 0x37, 0x68, 0x07, 0x46, 0x4C, 0x30, + 0x30, 0x45, 0x38, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x45, 0x39, 0x68, + 0x07, 0x46, 0x4C, 0x30, 0x30, 0x45, 0x41, 0x68, 0x07, 0x46, 0x4C, 0x30, + 0x30, 0x45, 0x42, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x45, 0x43, 0x68, + 0x07, 0x46, 0x4C, 0x30, 0x30, 0x45, 0x44, 0x68, 0x07, 0x46, 0x4C, 0x30, + 0x30, 0x45, 0x45, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x45, 0x46, 0x68, + 0x07, 0x46, 0x4C, 0x30, 0x30, 0x46, 0x31, 0x68, 0x07, 0x46, 0x4C, 0x30, + 0x30, 0x46, 0x32, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x46, 0x33, 0x68, + 0x07, 0x46, 0x4C, 0x30, 0x30, 0x46, 0x34, 0x68, 0x07, 0x46, 0x4C, 0x30, + 0x30, 0x46, 0x35, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x46, 0x36, 0x68, + 0x07, 0x46, 0x4C, 0x30, 0x30, 0x46, 0x39, 0x68, 0x07, 0x46, 0x4C, 0x30, + 0x30, 0x46, 0x41, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x46, 0x42, 0x68, + 0x07, 0x46, 0x4C, 0x30, 0x30, 0x46, 0x43, 0x68, 0x0E, 0x70, 0x65, 0x72, + 0x69, 0x6F, 0x64, 0x63, 0x65, 0x6E, 0x74, 0x65, 0x72, 0x65, 0x64, 0x05, + 0x46, 0x4C, 0x34, 0x30, 0x35, 0x05, 0x46, 0x4C, 0x34, 0x30, 0x36, 0x05, + 0x46, 0x4C, 0x34, 0x30, 0x38, 0x05, 0x46, 0x4C, 0x34, 0x31, 0x30, 0x05, + 0x46, 0x4C, 0x34, 0x31, 0x38, 0x05, 0x46, 0x4C, 0x34, 0x32, 0x33, 0x05, + 0x46, 0x4C, 0x34, 0x32, 0x39, 0x05, 0x46, 0x4C, 0x34, 0x33, 0x34, 0x05, + 0x46, 0x4C, 0x34, 0x33, 0x33, 0x05, 0x46, 0x4C, 0x34, 0x33, 0x35, 0x05, + 0x46, 0x4C, 0x34, 0x33, 0x37, 0x05, 0x46, 0x4C, 0x34, 0x33, 0x36, 0x05, + 0x46, 0x4C, 0x34, 0x33, 0x38, 0x05, 0x46, 0x4C, 0x34, 0x34, 0x30, 0x05, + 0x46, 0x4C, 0x34, 0x34, 0x32, 0x05, 0x46, 0x4C, 0x34, 0x34, 0x31, 0x05, + 0x46, 0x4C, 0x34, 0x34, 0x33, 0x05, 0x46, 0x4C, 0x34, 0x34, 0x34, 0x05, + 0x46, 0x4C, 0x34, 0x34, 0x36, 0x05, 0x46, 0x4C, 0x34, 0x34, 0x35, 0x05, + 0x46, 0x4C, 0x34, 0x34, 0x37, 0x05, 0x46, 0x4C, 0x34, 0x34, 0x38, 0x05, + 0x46, 0x4C, 0x34, 0x35, 0x30, 0x05, 0x46, 0x4C, 0x34, 0x35, 0x32, 0x05, + 0x46, 0x4C, 0x34, 0x35, 0x31, 0x05, 0x46, 0x4C, 0x34, 0x35, 0x33, 0x05, + 0x46, 0x4C, 0x34, 0x35, 0x35, 0x05, 0x46, 0x4C, 0x34, 0x35, 0x34, 0x05, + 0x46, 0x4C, 0x34, 0x35, 0x39, 0x05, 0x46, 0x4C, 0x34, 0x35, 0x38, 0x05, + 0x46, 0x4C, 0x34, 0x36, 0x30, 0x05, 0x46, 0x4C, 0x34, 0x36, 0x31, 0x05, + 0x46, 0x4C, 0x34, 0x33, 0x32, 0x05, 0x46, 0x4C, 0x34, 0x30, 0x37, 0x05, + 0x46, 0x4C, 0x34, 0x32, 0x35, 0x05, 0x46, 0x4C, 0x35, 0x33, 0x35, 0x05, + 0x46, 0x4C, 0x34, 0x33, 0x39, 0x05, 0x46, 0x4C, 0x34, 0x35, 0x37, 0x05, + 0x46, 0x4C, 0x34, 0x30, 0x31, 0x05, 0x46, 0x4C, 0x34, 0x30, 0x34, 0x05, + 0x46, 0x4C, 0x34, 0x32, 0x32, 0x05, 0x46, 0x4C, 0x34, 0x35, 0x36, 0x05, + 0x46, 0x4C, 0x34, 0x36, 0x34, 0x05, 0x46, 0x4C, 0x35, 0x31, 0x31, 0x05, + 0x46, 0x4C, 0x35, 0x31, 0x34, 0x05, 0x46, 0x4C, 0x35, 0x33, 0x32, 0x05, + 0x46, 0x4C, 0x34, 0x30, 0x33, 0x05, 0x46, 0x4C, 0x34, 0x31, 0x31, 0x05, + 0x46, 0x4C, 0x34, 0x30, 0x32, 0x05, 0x46, 0x4C, 0x34, 0x31, 0x32, 0x05, + 0x46, 0x4C, 0x34, 0x30, 0x39, 0x05, 0x46, 0x4C, 0x34, 0x31, 0x34, 0x05, + 0x46, 0x4C, 0x34, 0x31, 0x35, 0x05, 0x46, 0x4C, 0x34, 0x31, 0x36, 0x05, + 0x46, 0x4C, 0x34, 0x31, 0x33, 0x05, 0x46, 0x4C, 0x34, 0x32, 0x30, 0x05, + 0x46, 0x4C, 0x34, 0x32, 0x31, 0x05, 0x46, 0x4C, 0x34, 0x31, 0x39, 0x05, + 0x46, 0x4C, 0x34, 0x32, 0x37, 0x05, 0x46, 0x4C, 0x34, 0x32, 0x38, 0x05, + 0x46, 0x4C, 0x34, 0x32, 0x36, 0x05, 0x46, 0x4C, 0x35, 0x32, 0x31, 0x05, + 0x46, 0x4C, 0x35, 0x31, 0x32, 0x05, 0x46, 0x4C, 0x35, 0x32, 0x32, 0x05, + 0x46, 0x4C, 0x34, 0x31, 0x37, 0x05, 0x46, 0x4C, 0x34, 0x34, 0x39, 0x05, + 0x46, 0x4C, 0x34, 0x33, 0x30, 0x05, 0x46, 0x4C, 0x34, 0x36, 0x32, 0x05, + 0x46, 0x4C, 0x34, 0x33, 0x31, 0x05, 0x46, 0x4C, 0x34, 0x36, 0x33, 0x05, + 0x46, 0x4C, 0x34, 0x32, 0x34, 0x05, 0x46, 0x4C, 0x35, 0x32, 0x37, 0x05, + 0x46, 0x4C, 0x35, 0x35, 0x36, 0x05, 0x46, 0x4C, 0x35, 0x33, 0x37, 0x05, + 0x46, 0x4C, 0x35, 0x36, 0x39, 0x05, 0x46, 0x4C, 0x35, 0x33, 0x38, 0x05, + 0x46, 0x4C, 0x35, 0x37, 0x30, 0x05, 0x46, 0x4C, 0x35, 0x33, 0x34, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x31, 0x30, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x31, 0x32, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x32, 0x31, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x31, 0x35, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x31, 0x44, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x31, 0x41, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x31, 0x46, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x31, 0x45, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x32, 0x30, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x32, 0x32, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x32, 0x38, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x32, 0x35, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x32, 0x33, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x31, 0x31, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x31, 0x33, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x31, 0x36, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x31, 0x37, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x31, 0x38, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x31, 0x39, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x31, 0x42, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x31, 0x34, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x31, 0x43, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x32, 0x39, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x32, 0x46, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x32, 0x43, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x32, 0x41, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x32, 0x42, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x32, 0x44, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x32, 0x45, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x32, 0x37, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x32, 0x36, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x32, 0x34, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x33, 0x30, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x33, 0x31, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x33, 0x32, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x33, 0x33, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x33, 0x34, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x33, 0x35, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x33, 0x36, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x33, 0x37, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x33, 0x38, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x33, 0x39, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x33, 0x41, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x33, 0x42, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x33, 0x43, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x33, 0x44, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x33, 0x45, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x33, 0x46, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x34, 0x30, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x34, 0x31, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x34, 0x32, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x34, 0x33, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x34, 0x34, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x34, 0x35, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x34, 0x36, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x34, 0x37, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x34, 0x38, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x34, 0x39, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x34, 0x41, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x34, 0x42, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x34, 0x43, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x34, 0x44, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x34, 0x45, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x34, 0x46, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x30, 0x38, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x35, 0x38, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x30, 0x35, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x35, 0x35, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x30, 0x45, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x35, 0x45, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x30, 0x39, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x35, 0x39, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x30, 0x36, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x35, 0x36, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x39, 0x30, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x39, 0x31, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x30, 0x31, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x35, 0x31, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x30, 0x34, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x35, 0x34, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x30, 0x33, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x35, 0x33, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x30, 0x41, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x35, 0x41, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x30, 0x43, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x35, 0x43, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x30, 0x37, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x35, 0x37, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x30, 0x42, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x35, 0x42, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x30, 0x32, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, + 0x35, 0x32, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x34, 0x30, 0x46, 0x68, 0x07, + 0x46, 0x4C, 0x30, 0x34, 0x35, 0x46, 0x68, 0x05, 0x46, 0x4C, 0x35, 0x34, + 0x36, 0x05, 0x46, 0x4C, 0x35, 0x34, 0x37, 0x05, 0x46, 0x4C, 0x35, 0x34, + 0x38, 0x05, 0x46, 0x4C, 0x35, 0x34, 0x39, 0x05, 0x46, 0x4C, 0x35, 0x35, + 0x30, 0x05, 0x46, 0x4C, 0x35, 0x35, 0x31, 0x05, 0x46, 0x4C, 0x35, 0x35, + 0x32, 0x05, 0x46, 0x4C, 0x35, 0x35, 0x33, 0x05, 0x46, 0x4C, 0x35, 0x35, + 0x34, 0x05, 0x46, 0x4C, 0x35, 0x35, 0x35, 0x05, 0x46, 0x4C, 0x35, 0x35, + 0x36, 0x05, 0x46, 0x4C, 0x35, 0x35, 0x37, 0x05, 0x46, 0x4C, 0x35, 0x35, + 0x38, 0x05, 0x46, 0x4C, 0x35, 0x35, 0x39, 0x05, 0x46, 0x4C, 0x35, 0x36, + 0x30, 0x05, 0x46, 0x4C, 0x35, 0x36, 0x31, 0x05, 0x46, 0x4C, 0x35, 0x36, + 0x32, 0x05, 0x46, 0x4C, 0x35, 0x36, 0x33, 0x05, 0x46, 0x4C, 0x35, 0x36, + 0x34, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x31, 0x37, 0x09, + 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x31, 0x39, 0x09, 0x61, 0x66, + 0x69, 0x69, 0x31, 0x30, 0x30, 0x32, 0x30, 0x09, 0x61, 0x66, 0x69, 0x69, + 0x31, 0x30, 0x30, 0x32, 0x32, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x30, 0x32, 0x34, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x32, + 0x35, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x32, 0x36, 0x09, + 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x32, 0x37, 0x09, 0x61, 0x66, + 0x69, 0x69, 0x31, 0x30, 0x30, 0x32, 0x38, 0x09, 0x61, 0x66, 0x69, 0x69, + 0x31, 0x30, 0x30, 0x32, 0x39, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x30, 0x33, 0x30, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x33, + 0x31, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x33, 0x32, 0x09, + 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x33, 0x33, 0x09, 0x61, 0x66, + 0x69, 0x69, 0x31, 0x30, 0x30, 0x33, 0x34, 0x09, 0x61, 0x66, 0x69, 0x69, + 0x31, 0x30, 0x30, 0x33, 0x35, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x30, 0x33, 0x36, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x33, + 0x37, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x33, 0x38, 0x09, + 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x33, 0x39, 0x09, 0x61, 0x66, + 0x69, 0x69, 0x31, 0x30, 0x30, 0x34, 0x30, 0x09, 0x61, 0x66, 0x69, 0x69, + 0x31, 0x30, 0x30, 0x34, 0x31, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x30, 0x34, 0x32, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x34, + 0x33, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x34, 0x34, 0x09, + 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x34, 0x35, 0x09, 0x61, 0x66, + 0x69, 0x69, 0x31, 0x30, 0x30, 0x34, 0x36, 0x09, 0x61, 0x66, 0x69, 0x69, + 0x31, 0x30, 0x30, 0x34, 0x37, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x30, 0x34, 0x38, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x36, + 0x35, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x36, 0x36, 0x09, + 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x36, 0x37, 0x09, 0x61, 0x66, + 0x69, 0x69, 0x31, 0x30, 0x30, 0x36, 0x38, 0x09, 0x61, 0x66, 0x69, 0x69, + 0x31, 0x30, 0x30, 0x36, 0x39, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x30, 0x37, 0x30, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x37, + 0x32, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x37, 0x33, 0x09, + 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x37, 0x34, 0x09, 0x61, 0x66, + 0x69, 0x69, 0x31, 0x30, 0x30, 0x37, 0x35, 0x09, 0x61, 0x66, 0x69, 0x69, + 0x31, 0x30, 0x30, 0x37, 0x36, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x30, 0x37, 0x37, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x37, + 0x38, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x37, 0x39, 0x09, + 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x38, 0x30, 0x09, 0x61, 0x66, + 0x69, 0x69, 0x31, 0x30, 0x30, 0x38, 0x31, 0x09, 0x61, 0x66, 0x69, 0x69, + 0x31, 0x30, 0x30, 0x38, 0x32, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x30, 0x38, 0x33, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x38, + 0x34, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x38, 0x35, 0x09, + 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x38, 0x36, 0x09, 0x61, 0x66, + 0x69, 0x69, 0x31, 0x30, 0x30, 0x38, 0x37, 0x09, 0x61, 0x66, 0x69, 0x69, + 0x31, 0x30, 0x30, 0x38, 0x38, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x30, 0x38, 0x39, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x39, + 0x30, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x39, 0x31, 0x09, + 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x39, 0x32, 0x09, 0x61, 0x66, + 0x69, 0x69, 0x31, 0x30, 0x30, 0x39, 0x33, 0x09, 0x61, 0x66, 0x69, 0x69, + 0x31, 0x30, 0x30, 0x39, 0x34, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x30, 0x39, 0x35, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x39, + 0x36, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x39, 0x37, 0x09, + 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x35, 0x31, 0x09, 0x61, 0x66, + 0x69, 0x69, 0x31, 0x30, 0x30, 0x39, 0x39, 0x09, 0x61, 0x66, 0x69, 0x69, + 0x31, 0x30, 0x30, 0x35, 0x32, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x31, 0x30, 0x30, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x35, + 0x37, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x31, 0x30, 0x35, 0x09, + 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x35, 0x30, 0x09, 0x61, 0x66, + 0x69, 0x69, 0x31, 0x30, 0x30, 0x39, 0x38, 0x09, 0x61, 0x66, 0x69, 0x69, + 0x31, 0x30, 0x30, 0x35, 0x33, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x31, 0x30, 0x31, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x31, 0x30, + 0x33, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x35, 0x36, 0x09, + 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x31, 0x30, 0x34, 0x09, 0x61, 0x66, + 0x69, 0x69, 0x31, 0x30, 0x30, 0x35, 0x38, 0x09, 0x61, 0x66, 0x69, 0x69, + 0x31, 0x30, 0x31, 0x30, 0x36, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x30, 0x36, 0x32, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x31, 0x31, + 0x30, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x35, 0x39, 0x09, + 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x31, 0x30, 0x37, 0x09, 0x61, 0x66, + 0x69, 0x69, 0x31, 0x30, 0x30, 0x35, 0x34, 0x09, 0x61, 0x66, 0x69, 0x69, + 0x31, 0x30, 0x31, 0x30, 0x32, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x30, 0x36, 0x30, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x31, 0x30, + 0x38, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x36, 0x31, 0x09, + 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x31, 0x30, 0x39, 0x09, 0x61, 0x66, + 0x69, 0x69, 0x31, 0x30, 0x30, 0x32, 0x33, 0x09, 0x61, 0x66, 0x69, 0x69, + 0x31, 0x30, 0x30, 0x37, 0x31, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x31, 0x34, 0x35, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x31, 0x39, + 0x33, 0x06, 0x46, 0x4C, 0x30, 0x31, 0x34, 0x31, 0x06, 0x46, 0x4C, 0x30, + 0x31, 0x35, 0x37, 0x06, 0x46, 0x4C, 0x30, 0x31, 0x34, 0x32, 0x06, 0x46, + 0x4C, 0x30, 0x31, 0x35, 0x38, 0x06, 0x46, 0x4C, 0x30, 0x31, 0x32, 0x39, + 0x06, 0x46, 0x4C, 0x30, 0x31, 0x32, 0x38, 0x06, 0x46, 0x4C, 0x30, 0x31, + 0x34, 0x34, 0x06, 0x46, 0x4C, 0x30, 0x31, 0x34, 0x33, 0x07, 0x46, 0x4C, + 0x30, 0x39, 0x46, 0x30, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x39, 0x46, 0x33, + 0x68, 0x07, 0x46, 0x4C, 0x30, 0x39, 0x46, 0x37, 0x68, 0x07, 0x46, 0x4C, + 0x30, 0x30, 0x44, 0x30, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x44, 0x37, + 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x44, 0x44, 0x68, 0x07, 0x46, 0x4C, + 0x30, 0x30, 0x44, 0x45, 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x46, 0x30, + 0x68, 0x07, 0x46, 0x4C, 0x30, 0x30, 0x46, 0x44, 0x68, 0x07, 0x46, 0x4C, + 0x30, 0x30, 0x46, 0x45, 0x68, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, + 0x30, 0x31, 0x38, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x32, + 0x31, 0x09, 0x61, 0x66, 0x69, 0x69, 0x31, 0x30, 0x30, 0x34, 0x39, 0x00, + 0xBB, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x2B, 0x2B, 0xBD, + 0x00, 0x01, 0x00, 0x24, 0x00, 0x1C, 0x00, 0x14, 0x00, 0x0C, 0x00, 0x08, + 0x2B, 0xBD, 0x00, 0x00, 0x00, 0x24, 0x00, 0x1C, 0x00, 0x14, 0x00, 0x0C, + 0x00, 0x08, 0x2B, 0xBA, 0x00, 0x02, 0x00, 0x04, 0x00, 0x07, 0x2B, 0x00 +}; + +``` + +`hooked.hpp`: + +```hpp +#pragma once + +#include "source.hpp" + +namespace F +{ + extern vgui::HFont Menu; + extern vgui::HFont MenuV2; + extern vgui::HFont MenuV2i; + extern vgui::HFont MenuV2n; + extern vgui::HFont ESPInfo; + extern vgui::HFont ESP; + extern vgui::HFont LBY; + extern vgui::HFont Events; + extern vgui::HFont Icons; + extern vgui::HFont MenuIcons; +} + +namespace Drawing +{ + extern void CreateFonts(); + extern void Texture(const int32_t x, const int32_t y, const int32_t w, const int32_t h, const int texture, const Color tint); + extern void LimitDrawingArea(int x, int y, int w, int h); + extern void GetDrawingArea(int& x, int& y, int& w, int& h); + extern void ColorPicker(Vector2D pos, int width, int height, float alpha = 255.f); + extern void DrawString(vgui::HFont font, int x, int y, Color color, DWORD alignment, const char* msg, ...); + extern void DrawStringFont(vgui::HFont font, int x, int y, Color clrColor, bool bCenter, const char* szText, ...); + extern void DrawStringUnicode(vgui::HFont font, int x, int y, Color color, bool bCenter, const wchar_t* msg, ...); + extern void DrawRect(int x, int y, int w, int h, Color col); + extern void DrawRectA(int x, int y, int w, int h, Color col); + extern void Rectangle(float x, float y, float w, float h, float px, Color col); + extern void Border(int x, int y, int w, int h, int line, Color col); + extern void DrawRectRainbow(int x, int y, int w, int h, float flSpeed, float& flRainbow); + extern void DrawRectGradientVertical(int x, int y, int w, int h, Color color1, Color color2); + extern void DrawRectGradientVerticalA(int x, int y, int width, int height, Color color1, Color color2); + extern void DrawRectGradientHorizontal(int x, int y, int w, int h, Color color1, Color color2); + extern void DrawPixel(int x, int y, Color col); + extern void DrawOutlinedRect(int x, int y, int w, int h, Color col); + extern void DrawOutlinedRectA(int x, int y, int w, int h, Color col); + extern void DrawOutlinedCircle(int x, int y, int r, Color col); + extern void DrawLine(int x0, int y0, int x1, int y1, Color col); + extern void DrawCircularProgressBar(Vector2D pos, float radius, int thickness, int num_segments, float progress, Color color); + extern void DrawCorner(int iX, int iY, int iWidth, int iHeight, bool bRight, bool bDown, Color colDraw); + extern void DrawRoundedBox(int x, int y, int w, int h, int r, int v, Color col); + extern void Triangle(Vector ldcorner, Vector rucorner, Color col); + extern void DrawPolygon(int count, Vertex_t* Vertexs, Color color); + extern void DrawBox(int x, int y, int w, int h, Color color); + extern bool ScreenTransform(const Vector& point, Vector& screen); + extern bool WorldToScreen(const Vector& origin, Vector& screen); + extern RECT GetViewport(); + extern int GetStringWidth(vgui::HFont font, const char* msg, ...); + extern RECT GetTextSize(vgui::HFont font, const char* text); + extern RECT GetTextSize(vgui::HFont font, const wchar_t* text); + extern void Draw3DBox(Vector* boxVectors, Color color); + extern void rotate_point(Vector2D& point, Vector2D origin, bool clockwise, float angle); + extern void DrawFilledCircle(int x, int y, int radius, int segments, Color color); + extern void TexturedPolygon(int n, std::vector vertice, Color color); + extern void filled_tilted_triangle(Vector2D position, Vector2D size, Vector2D origin, bool clockwise, float angle, Color color, bool rotate = true, Color col2 = Color::Black()); + extern void DrawCircle(float x, float y, float r, float s, Color color); + + extern const char* LastFontName; +} + +using LevelInitPostEntity_t = void(__thiscall*)(void*); +using LevelShutdown_t = void(__thiscall*)(void*); +using EmitSound_t = int(__thiscall*)(void*, IRecipientFilter&, int, int, const char*, unsigned int, const char*, float, int, float, int, int, const Vector*, const Vector*, void*, bool, float, int, int); +using LevelInitPreEntity_t = void(__thiscall*)(void*, const char*); + +namespace Hooked +{ + + void __fastcall ProcessPacket(INetChannel* channel, uint32_t, void* packet, bool header); + bool __fastcall ProcessTempEntities(pPastaState* cl_state, void* EDX, void* msg); + void __fastcall PacketEnd(pPastaState* cl_state, void* EDX); + int __fastcall SendDatagram(void* netchan, void*, void* datagram); + void __fastcall OverrideView(void* ecx, void* edx, CViewSetup* vsView); + bool __stdcall CreateMove(float input_sample_frametime, CUserCmd* cmd); + void __fastcall FrameStageNotify(void* ecx, void* edx, ClientFrameStage_t stage); + void __fastcall ProcessMovement(void* ecx, void* edx, C_BasePlayer* basePlayer, CMoveData* moveData); + void __fastcall RunCommand(void* ecx, void* edx, C_BasePlayer* player, CUserCmd* ucmd, IMoveHelper* moveHelper); + bool __fastcall InPrediction(void* ecx, void* edx); + void __fastcall SetupMove(void* player, int edx, CUserCmd* ucmd, IMoveHelper* pHelper, CMoveData* move); + void __stdcall LockCursor(); + void __fastcall PaintTraverse(void* ecx, void* edx, unsigned int vguiPanel, bool forceRepaint, bool allowForce); + void _stdcall EngineVGUI_Paint(int mode); + void __fastcall SceneEnd(void* ecx, void* edx); + int __stdcall DrawModelExecute(void* context, void* state, ModelRenderInfo_t& info, matrix3x4_t* pCustomBoneToWorld); + void __fastcall PacketStart(void* ecx, void* edx, int incoming_sequence, int outgoing_acknowledged); + bool __fastcall SendNetMsg(INetChannel* pNetChan, void* edx, INetMessage& msg, bool bForceReliable, bool bVoice); + void __fastcall Shutdown(INetChannel* pNetChan, void* EDX, const char* reason); + bool __fastcall DoPostScreenEffects(void* clientmode, void*, int a1); + float __fastcall GetViewModelFOV(void* a1, int ecx); + int __fastcall ListLeavesInBox(void* bsp, void* edx, Vector& mins, Vector& maxs, unsigned short* pList, int listMax); + //void __fastcall StartLagCompensation(void* ecx, void* edx, uintptr_t player, int lagCompensationType, const Vector* weaponPos, const QAngle* weaponAngles, float weaponRange); + void __fastcall LevelInitPostEntity(void* ecx, void* edx); + void __fastcall LevelShutdown(void* ecx, void* edx); + long __stdcall EndScene(IDirect3DDevice9* device); + long __stdcall Reset(IDirect3DDevice9* device, D3DPRESENT_PARAMETERS* pp); + int __fastcall EmitSound1(void* _this, int edx, IRecipientFilter& filter, int iEntIndex, int iChannel, const char* pSoundEntry, unsigned int nSoundEntryHash, const char* pSample, float flVolume, int nSeed, float flAttenuation, int iFlags, int iPitch, const Vector* pOrigin, const Vector* pDirection, void* pUtlVecOrigins, bool bUpdatePositions, float soundtime, int speakerentity, int unk); + //int __fastcall IN_KeyEvent( int event, int key, const char* bind ); + void __fastcall LevelInitPreEntity(void* ecx, void* edx, const char* map); + + extern WNDPROC oldWindowProc; + extern LRESULT __stdcall WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); +} + + +#define CREATE_EVENT_LISTENER(class_name)\ +class class_name : public IGameEventListener\ +{\ +public:\ + ~class_name() { csgo.m_event_manager()->RemoveListener(this); }\ +\ + virtual void FireGameEvent(IGameEvent* game_event);\ +};\ + +namespace game_events //fuck namespaces, fuck ur style bolbi +{ + void init(); + + //CREATE_EVENT_LISTENER(ItemPurchaseListener); + CREATE_EVENT_LISTENER(PlayerHurtListener); + CREATE_EVENT_LISTENER(BulletImpactListener); + CREATE_EVENT_LISTENER(PlayerDeathListener); + CREATE_EVENT_LISTENER(RoundStartListener); + CREATE_EVENT_LISTENER(RoundEndListener); + CREATE_EVENT_LISTENER(PurchaseListener); + CREATE_EVENT_LISTENER(BombPlantListener); + CREATE_EVENT_LISTENER(WeaponFireListener); + CREATE_EVENT_LISTENER(BombDefuseListener); + CREATE_EVENT_LISTENER(BombStopPlantListener); + CREATE_EVENT_LISTENER(BombStopDefuseListener); + CREATE_EVENT_LISTENER(BombStartPlantListener); + CREATE_EVENT_LISTENER(BombStartDefuseListener); +}; +``` + +`horizon.hpp`: + +```hpp +#pragma once + +#include "scan.hpp" +#include "vcall.hpp" +#include "vmt_swap.hpp" +#include "singleton.hpp" +#include "print.hpp" + +// directx +#include +#include +#pragma comment(lib, "d3d9.lib") +#pragma comment(lib, "d3dx9.lib") + +// ImGUI +#include "imgui\imgui.h" +#include "imgui\imgui_impl_dx9.h" +#include "imgui\imgui_internal.h" +#include "imgui_extension.hpp" +``` + +`i_menu.cpp`: + +```cpp +#include "horizon.hpp" +#include "i_menu.hpp" +#include "parser.hpp" +#include "source.hpp" +//#include "background_img.hpp" +//#include "imgui_extension.hpp" +#include "rendering.hpp" +#include "menu.hpp" +#include "misc.hpp" +#include "menu/setup/settings.h" +#include "rage_aimbot.hpp" + +#pragma region "Key" +inline std::string get_kname(int key) { + switch (key) { + case VK_LBUTTON: + return "mouse1"; + case VK_RBUTTON: + return "mouse2"; + case VK_CANCEL: + return "break"; + case VK_MBUTTON: + return "mouse3"; + case VK_XBUTTON1: + return "mouse4"; + case VK_XBUTTON2: + return "mouse5"; + case VK_BACK: + return "backspace"; + case VK_TAB: + return "tab"; + case VK_CLEAR: + return "clear"; + case VK_RETURN: + return "enter"; + case VK_SHIFT: + return "shift"; + case VK_CONTROL: + return "ctrl"; + case VK_MENU: + return "alt"; + case VK_PAUSE: + return "[19]"; + case VK_CAPITAL: + return "capslock"; + case VK_SPACE: + return "space"; + case VK_PRIOR: + return "pgup"; + case VK_NEXT: + return "pgdown"; + case VK_END: + return "end"; + case VK_HOME: + return "home"; + case VK_LEFT: + return "left"; + case VK_UP: + return "up"; + case VK_RIGHT: + return "right"; + case VK_DOWN: + return "down"; + case VK_SELECT: + return "select"; + case VK_INSERT: + return "insert"; + case VK_DELETE: + return "delete"; + case '0': + return "0"; + case '1': + return "1"; + case '2': + return "2"; + case '3': + return "3"; + case '4': + return "4"; + case '5': + return "5"; + case '6': + return "6"; + case '7': + return "7"; + case '8': + return "8"; + case '9': + return "9"; + case 'A': + return "a"; + case 'B': + return "b"; + case 'C': + return "c"; + case 'D': + return "d"; + case 'E': + return "e"; + case 'F': + return "f"; + case 'G': + return "g"; + case 'H': + return "h"; + case 'I': + return "i"; + case 'J': + return "j"; + case 'K': + return "k"; + case 'L': + return "l"; + case 'M': + return "m"; + case 'N': + return "n"; + case 'O': + return "o"; + case 'P': + return "p"; + case 'Q': + return "q"; + case 'R': + return "r"; + case 'S': + return "s"; + case 'T': + return "t"; + case 'U': + return "u"; + case 'V': + return "v"; + case 'W': + return "w"; + case 'X': + return "x"; + case 'Y': + return "y"; + case 'Z': + return "z"; + case VK_LWIN: + return "left win"; + case VK_RWIN: + return "right win"; + case VK_NUMPAD0: + return "num 0"; + case VK_NUMPAD1: + return "num 1"; + case VK_NUMPAD2: + return "num 2"; + case VK_NUMPAD3: + return "num 3"; + case VK_NUMPAD4: + return "num 4"; + case VK_NUMPAD5: + return "num 5"; + case VK_NUMPAD6: + return "num 6"; + case VK_NUMPAD7: + return "num 7"; + case VK_NUMPAD8: + return "num 8"; + case VK_NUMPAD9: + return "num 9"; + case VK_MULTIPLY: + return "num mult"; + case VK_ADD: + return "num add"; + case VK_SEPARATOR: + return "|"; + case VK_SUBTRACT: + return "num sub"; + case VK_DECIMAL: + return "num decimal"; + case VK_DIVIDE: + return "num divide"; + case VK_F1: + return "f1"; + case VK_F2: + return "f2"; + case VK_F3: + return "f3"; + case VK_F4: + return "f4"; + case VK_F5: + return "f5"; + case VK_F6: + return "f6"; + case VK_F7: + return "f7"; + case VK_F8: + return "f8"; + case VK_F9: + return "f9"; + case VK_F10: + return "f10"; + case VK_F11: + return "f11"; + case VK_F12: + return "f12"; + case VK_NUMLOCK: + return "num lock"; + case VK_SCROLL: + return "break"; + case VK_LSHIFT: + return "shift"; + case VK_RSHIFT: + return "shift"; + case VK_LCONTROL: + return "ctrl"; + case VK_RCONTROL: + return "ctrl"; + case VK_LMENU: + return "alt"; + case VK_RMENU: + return "alt"; + case VK_OEM_COMMA: + return "),"; + case VK_OEM_PERIOD: + return "."; + case VK_OEM_1: + return ";"; + case VK_OEM_MINUS: + return "-"; + case VK_OEM_PLUS: + return "="; + case VK_OEM_2: + return "/"; + case VK_OEM_3: + return "grave"; + case VK_OEM_4: + return "["; + case VK_OEM_5: + return "\\"; + case VK_OEM_6: + return "]"; + case VK_OEM_7: + return "[222]"; + default: + return ""; + } +} +#pragma endregion + +template +static bool items_getter(void* data, int idx, const char** out_text) +{ + auto items = (T*)data; + if (out_text) { + *out_text = items[idx].item_name.data();//std::string(items[idx].name.begin(), items[idx].translated_name.end()).data(); + } + return true; +}; + +int tabcount = 0; + +struct s_tab +{ + const char* name = ""; + const char* icon = 0; + ImVec2 size = ImVec2(0, 0); + int num = 0; + + s_tab(const char* _name, const char* _icon = "", ImVec2 _size = ImVec2(0, 0)) + { + name = _name; + icon = _icon; + size = _size; + num = tabcount; + tabcount++; + } + + ~s_tab() + { + /*tabcount--; + name = ""; + icon = 0; + size = ImVec2(0, 0); + num = 0;*/ + } +}; + +namespace ImGui +{ + bool ColorButton(const char* desc_id, const float col[], ImGuiColorEditFlags flags, ImVec2 size) + { + return ImGui::ColorButton(desc_id, ImColor(col[0], col[1], col[2], col[3]), flags, size); + } + + ImGuiID Colorpicker_Close = 0; + __inline void CloseLeftoverPicker() { if (Colorpicker_Close) ImGui::ClosePopup(Colorpicker_Close); } + bool ColorPickerBox(const char* picker_idname, float col_ct[], float col_t[], float col_ct_invis[], float col_t_invis[], bool alpha = true, bool use_buttons = false) + { + bool ret = false; + + ImGui::SameLine(); + static bool switch_entity_teams = false; + static bool switch_color_vis = false; + + float* col = use_buttons ? (switch_entity_teams ? (switch_color_vis ? col_t : col_t_invis) : (switch_color_vis ? col_ct : col_ct_invis)) : col_ct; + + const auto cursor_pos_y = GetCursorPosY(); + + SetCursorPosY(cursor_pos_y + 5); + bool open_popup = ImGui::ColorButton(picker_idname, col, ImGuiColorEditFlags_NoSidePreview + | ImGuiColorEditFlags_NoSmallPreview + | ImGuiColorEditFlags_AlphaPreview + | ImGuiColorEditFlags_NoTooltip + | ImGuiColorEditFlags_ColorPicker + | ImGuiColorEditFlags_ColorPickerSameline, ImVec2(18, 10)); + + SetCursorPosY(GetCursorPosY() - 5); + + /*SetCursorPosY(cursor_pos_y);*/ + if (open_popup) { + ImGui::OpenPopup(picker_idname); + Colorpicker_Close = ImGui::GetID(picker_idname); + } + + if (ImGui::BeginPopup(picker_idname)) + { + if (use_buttons) { + const char* button_name0 = switch_entity_teams ? "Terrorists" : "Counter-Terrorists"; + if (ImGui::Button(button_name0, ImVec2(-1, 0))) + switch_entity_teams = !switch_entity_teams; + + const char* button_name1 = switch_color_vis ? "Visible" : "Invisible"; + if (ImGui::Button(button_name1, ImVec2(-1, 0))) + switch_color_vis = !switch_color_vis; + } + + std::string id_new = picker_idname; + id_new += "##pickeritself_"; + + ret = ImGui::ColorPicker(id_new.c_str(), col, (alpha ? ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaBar : 0)); + ImGui::EndPopup(); + } + + return ret; + } + + bool mouse_in_pos(ImRect minmaxs) + { + ImGuiContext& g = *GImGui; + return (g.IO.MousePos.x >= minmaxs.Min.x && g.IO.MousePos.y >= minmaxs.Min.y && g.IO.MousePos.x <= minmaxs.Max.x && g.IO.MousePos.y <= minmaxs.Max.y); + } + + bool Tab(const char* label, const ImVec2& size_arg, bool selected) + { + return ButtonEx(label, size_arg, (selected ? ImGuiItemFlags_TabButton : 0)); + } + + // NB: This is an internal helper. The user-facing IsItemHovered() is using data emitted from ItemAdd(), with a slightly different logic. + bool IsHovered(const ImRect& bb, ImGuiID id, bool flatten_childs) + { + ImGuiContext& g = *GImGui; + if (g.HoveredId == 0 || g.HoveredId == id || g.HoveredIdAllowOverlap) + { + ImGuiWindow* window = GetCurrentWindowRead(); + if (g.HoveredWindow == window || (flatten_childs && g.HoveredRootWindow == window->RootWindow)) + if ((g.ActiveId == 0 || g.ActiveId == id || g.ActiveIdAllowOverlap) && IsMouseHoveringRect(bb.Min, bb.Max)) + return true; + } + return false; + } + + + bool Bind(const char* label, int* key, const ImVec2& size_arg) + { + ImGuiWindow* window = GetCurrentWindow(); + + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiIO& io = g.IO; + const ImGuiStyle& style = g.Style; + + const ImGuiID id = window->GetID(label); + + ImVec2 label_size = CalcTextSize(label, NULL, true); + ImVec2 size = CalcItemSize(size_arg, CalcItemWidth() / 2, label_size.y + style.FramePadding.y);// *2.0f); + + const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size); + const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? (style.ItemInnerSpacing.x + label_size.x) : 0.0f, 0.0f)); + + ItemSize(total_bb, style.FramePadding.y); + + if (!ItemAdd(total_bb, id)) + return false; + + bool value_changed = false; + + std::string text = "None"; + + bool hovered = false, held = false; + + if (g.ActiveId == id) + { + text = "Press a Key"; + + if (!g.ActiveIdIsJustActivated) + { + for (int i = 0; i < 255; i++) + { + if (ctx.pressed_keys[i])//g.IO.KeysReleased[i]) + { + SetActiveID(0, window); + *key = (i == 0x1B/*VK_ESCAPE*/) ? 0 : i; + value_changed = true; + break; + } + } + + /*for (int i = 0; i < 6; i++) + { + if (g.IO.MouseReleased[i]) + { + SetActiveID(0); + *key = i + 1; + value_changed = true; + break; + } + }*/ + } + } + else + { + hovered = IsHovered(frame_bb, id, false); + + if (hovered) + { + SetHoveredID(id); + + if (g.IO.MouseDown[0]) + { + held = true; + FocusWindow(window); + } + else if (g.IO.MouseReleased[0]) + { + SetActiveID(id, window); + } + } + + text = get_kname(*key); + } + + const ImU32 col = GetColorU32((hovered && held) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); + RenderFrame(frame_bb.Min, frame_bb.Max, col, true, style.FrameRounding); // main frame + label_size = CalcTextSize(text.c_str(), NULL, true); + ImVec2 pos_min = frame_bb.Min; + ImVec2 pos_max = frame_bb.Max; + ImVec2 label_pos = pos_min; + label_pos.x = ImMax(label_pos.x, (label_pos.x + pos_max.x - label_size.x) * 0.5f); + label_pos.y = ImMax(label_pos.y, (label_pos.y + pos_max.y - label_size.y) * 0.5f); + RenderText(label_pos, text.c_str(), NULL); + RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y - 3), label); // render item lable + + return value_changed; + } +} + +namespace menu +{ + LPDIRECT3DTEXTURE9 flag_ewropi = NULL; + LPDIRECT3DTEXTURE9 m_tplayer_with_glow = NULL; + LPDIRECT3DTEXTURE9 m_tplayer_no_glow = NULL; + IDirect3DDevice9* m_device = nullptr; + + int category = -1; + int new_category = -1; + + void init(const float& alpha) + { + auto style = &ImGui::GetStyle(); + + ImVec4* colors = style->Colors; + + colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); + colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); + colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f); + colors[ImGuiCol_ChildBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.00f); + colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); + colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); + colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.29f, 0.48f, 0.54f); + colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); + colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f); + colors[ImGuiCol_TitleBgActive] = ImVec4(0.16f, 0.29f, 0.48f, 1.00f); + colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); + colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f); + colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f); + colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f); + colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f); + colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); + colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_SliderGrab] = ImVec4(0.24f, 0.52f, 0.88f, 1.00f); + colors[ImGuiCol_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); + colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); + colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f); + colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); + colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_Separator] = colors[ImGuiCol_Border];//ImVec4(0.61f, 0.61f, 0.61f, 1.00f); + colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f); + colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f); + colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.25f); + colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); + colors[ImGuiCol_CloseButton] = ImVec4(0.41f, 0.41f, 0.41f, 0.50f); + colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f); + colors[ImGuiCol_CloseButtonActive] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f); + colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); + colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); + colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); + colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); + colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); + colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); + colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); + + ImGui::GetIO().Fonts->AddFontDefault(); + } + + void skins_listbox(const char* label, std::string filter, int selected_rarity, int* current_item, skin_list_t& skins, int height_in_items, const float& alpha) + { + if (!ImGui::ListBoxHeader(label, skins.list.size(), height_in_items)) + return; + + for (int i = 0; i < skins.list.size(); i++) + { + const auto item_selected = (i == *current_item); + const auto item_text = skins.list[i].translated_name; + auto rarity = parser::rarities.get_by_id(skins.list[i].rarity); + auto color = rarity.Color.alpha(alpha * 255); + + if (selected_rarity != 0 && + selected_rarity != rarity.id) + continue; + + std::string pstr = std::string(item_text.begin(), item_text.end()); + + if (!filter.empty() && + parser::to_lower(pstr).find(parser::to_lower(filter)) == std::string::npos) + continue; + + ImGui::PushID(i); + ImGui::PushStyleColor(ImGuiCol_Text, (ImVec4)color); + if (ImGui::Selectable(pstr.data(), item_selected)) + { + *current_item = i; + } + ImGui::PopStyleColor(); + ImGui::PopID(); + } + + ImGui::ListBoxFooter(); + } + + void draw_skinchanger(const float& alpha) + { + static auto selected_item = 0; + static auto fake_wear = 1.f; + static auto fake_seed = 0; + static char fake_name[256] = ""; + static auto fake_stattrak = false; + static auto fake_stattrak_value = 0; + + //if (ImGui::Begin("Skin changer") + //{ + ImGui::Page::Begin(3); + ImGui::PushItemWidth(ImGui::GetCurrentWindow()->Size.x); + + ImGui::ListBox(sxor("##weapons"), &selected_item, items_getter, (void*)parser::weapons.list.data(), parser::weapons.list.size(), 22); + + ImGui::PopItemWidth(); + ImGui::Page::Next(); + ImGui::PushItemWidth(ImGui::GetCurrentWindow()->Size.x); + + static bool show_all_skins = false; + //ImGui::Checkbox("All skins", &show_all_skins); + + static char filter_buffer[64] = ""; + ImGui::InputText(sxor("##filter"), filter_buffer, 64); + + // draw rarities + static auto selected_rarity = 0; + { + static auto draw_rarity = [](rarity_t& rarity, int& selected_rarity, const float& alpha) { + + bool selected = false; + auto size = ImVec2(12, 8); + + auto rarity_col = rarity.Color.alpha(alpha * 255); + + ImGui::PushStyleColor(ImGuiCol_Button, selected_rarity == rarity.id ? (ImVec4)rarity_col : (ImVec4)rarity_col.malpha(0.3f)); //40 дохуя имхо + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)rarity_col.malpha(0.7f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)rarity_col.malpha(0.7f)); + + if (ImGui::Button(("##" + rarity.name).data(), size)) + selected_rarity = rarity.id; + + ImGui::PopStyleColor(3); + ImGui::SameLine(/*0.f, 10.4f*/); + + }; + + for (auto& rarity : parser::rarities.list) { + draw_rarity(rarity, selected_rarity, alpha); + } + + ImGui::NewLine(); + } + + auto selected_weapon = parser::weapons.list[selected_item].id; + auto selected_skin = 0; + /*for (auto i = 0u; i < parser::weapons.list[selected_item].skins.list.size(); i++) + { + auto skin = parser::weapons.list[selected_item].skins.list[i]; + if (skin.id == cheat::settings.paint[selected_weapon]) + selected_skin = i; + }*/ + auto old_skin = selected_skin; + + if (!parser::weapons.list.empty()) + skins_listbox(sxor("##skins"), std::string(filter_buffer), selected_rarity, &selected_skin, parser::weapons.list[selected_item].skins, 20, alpha); + + //if (selected_skin != old_skin) { + // ctx.m_settings.paint[selected_weapon] = parser::weapons.list[selected_item].skins.list[selected_skin].id; + // //game::full_update(); + //} + + ImGui::PopItemWidth(); + ImGui::Page::Next(); + ImGui::PushItemWidth(ImGui::GetCurrentWindow()->Size.x); + + ImGui::SliderFloat(sxor("wear"), &fake_wear, 0.f, 1.f); + ImGui::Spacing(); + + ImGui::Text(sxor("seed")); + ImGui::InputInt(sxor("##_seed"), &fake_seed); + ImGui::Spacing(); + + ImGui::Checkbox(sxor("stat trak"), &fake_stattrak); + if (fake_stattrak) { + ImGui::InputInt(sxor("##_stattrak_value"), &fake_stattrak_value); + } + ImGui::Spacing(); + + ImGui::Text(sxor("name")); + ImGui::InputText(sxor("##_name"), fake_name, 256); + ImGui::Spacing(); + + static auto selected_knife = 0; + static std::vector knife_list; + if (knife_list.empty()) + { + knife_list = parser::knifes.list; + + knife_t default_knife; + default_knife.id = 0; + default_knife.translated_name = L"Default"; + knife_list.insert(knife_list.begin(), default_knife); + } + + if (ImGui::ListBox("##knife_changer", &selected_knife, items_getter, (void*)knife_list.data(), knife_list.size(), 6)) + { + auto new_id = knife_list[selected_knife].id; + ctx.m_settings.skinchanger_knife = new_id; + //game::full_update(); + } + + ImGui::PopItemWidth(); + ImGui::Page::End(); + + //} + //ImGui::End(); + } + + bool add_tab(s_tab tab, int* var/*, bool is_clickable = true*/, ImVec2 override_size = ImVec2(-1, -1), bool hovered = true) + { + bool ret = false; + const auto allowed_to_use_icon = strlen(tab.icon) > 0; + + if (allowed_to_use_icon && !hovered) + ImGui::PushFont(d::fonts::menu_icons.imgui); + else + ImGui::PushFont(d::fonts::menu_tab.imgui); + + if (ImGui::Tab((allowed_to_use_icon && !hovered ? tab.icon : tab.name), override_size == ImVec2(-1, -1) ? tab.size : override_size, *var == tab.num)) + { + ret = true; + + if (/*is_clickable && */var != nullptr) + *var = tab.num; + } + + ImGui::PopFont(); + + //ImGui::SameLine(0); + return ret; + } + + std::list get_spec(int playerId) + { + std::list list; + + if (!csgo.m_engine()->IsInGame()) + return list; + + auto player = csgo.m_entity_list()->GetClientEntity(playerId); + if (!player) + return list; + + if (player->IsDead()) + { + auto observerTarget = player->m_hObserverTarget() ? csgo.m_entity_list()->GetClientEntityFromHandle(*player->m_hObserverTarget()) : nullptr; + if (!observerTarget) + return list; + + player = observerTarget; + } + + for (int i = 1; i < csgo.m_globals()->maxClients; i++) + { + auto pPlayer = csgo.m_entity_list()->GetClientEntity(i); + + if (!pPlayer) + continue; + + if (pPlayer->IsDormant() || !pPlayer->IsDead()) + continue; + + auto target = pPlayer->m_hObserverTarget() ? csgo.m_entity_list()->GetClientEntityFromHandle(*pPlayer->m_hObserverTarget()) : nullptr; + if (player != target) + continue; + + list.push_back(i); + } + + return list; + } + + void speclist() + { + if (!ctx.m_settings.misc_spectators_list) + return; + + ImGuiStyle& style = ImGui::GetStyle(); + //float oldAlpha = style.Colors[ImGuiCol_WindowBg].w; + //style.Colors[ImGuiCol_WindowBg].w = Vars.Visuals.SpectatorListAlpha / 255.0f; + + if (ImGui::Begin(sxor("spectator list"), &ctx.m_settings.misc_spectators_list, ImVec2(300, 300), 1.f, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_ShowBorders))// | ImGuiWindowFlags_ShowBorders)) + { + ImGui::TextColored(ImVec4(style.Colors[ImGuiCol_Text].x - 0.3f, style.Colors[ImGuiCol_Text].y - 0.3f, style.Colors[ImGuiCol_Text].z - 0.3f, style.Colors[ImGuiCol_Text].w), sxor("spectators:")); + ImGui::Separator(); + if (csgo.m_engine()->IsInGame()) { + for (int playerId : get_spec(csgo.m_engine()->GetLocalPlayer())) + { + auto player = csgo.m_entity_list()->GetClientEntity(playerId); + + player_info entityInformation; + csgo.m_engine()->GetPlayerInfo(playerId, &entityInformation); + + std::string name(entityInformation.name); + + if (name.size() > 31) + name.resize(31); + + ImGui::Text(name.c_str()); + } + } + //ImGui::Separator(); + + ImGui::End(); + } + //style.WindowPadding = oldPadding; + //style.Colors[ImGuiCol_WindowBg].w = oldAlpha; + } + + void draw(IDirect3DDevice9* device) + { + // ImGui::is_input_allowed = true; + // m_device = device; + + + // ImGuiIO& io = ImGui::GetIO(); + // io.MousePos.x = feature::menu->_cursor_position.x; + // io.MousePos.y = feature::menu->_cursor_position.y; + // //ImGui::GetIO().MouseDrawCursor = m_opened; // makes cursor dissapear when menu is closed ///клятий курсор, куди ти подівся + + // if (ctx.m_settings.misc_status_list) + // { + // static bool tr = true; + // float cursor_pos_y; + // ImGui::Begin("status list", &ctx.m_settings.misc_status_list, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_ShowBorders); + // { + // if (csgo.m_engine()->IsInGame() && !ctx.m_local()->IsDead()) + // { + // ImGui::is_input_allowed = false; + // int desync_range = fabs(Math::angle_diff(ctx.angles[ANGLE_REAL], ctx.angles[ANGLE_FAKE])); + // int fakelag_choke = csgo.m_client_state()->m_iChockedCommands; + + // ImGui::Text("desync delta:"); + // ImGui::SameLine(); + + // cursor_pos_y = ImGui::GetCursorPosY(); + + // ImGui::SetCursorPosY(cursor_pos_y + 8); + // ImGui::SliderInt("##lmao", &desync_range, 0, 60); + // ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 8); + // + // //ImGui::TextColored(lby_broken ? ImVec4(0.f, 1.f, 0.f, 1.f) : ImVec4(1.f, 0.f, 0.f, 1.f), "[is broken]"); + + // //ImGui::Text("lagcomp:"); + // //ImGui::SameLine(); + // //ImGui::TextColored(Vars.LC ? ImVec4(0.f, 1.f, 0.f, 1.f) : ImVec4(1.f, 0.f, 0.f, 1.f), "[is broken]"); + + // ImGui::Text("speed: %.0f", ctx.m_local()->m_vecVelocity().Length2D()); + // + // ImGui::Text("fakelag:"); + // ImGui::SameLine(); + // cursor_pos_y = ImGui::GetCursorPosY(); + + // ImGui::SetCursorPosY(cursor_pos_y + 8); + // ImGui::SliderInt("##flmao", &fakelag_choke, 0, 15); + // ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 8); + + // if (ctx.has_exploit_toggled) + // { + // ImGui::Text("exploit:"); + // + // if (ctx.exploit_allowed && ctx.ticks_allowed > 13 && ctx.main_exploit != 0) { + // ImGui::SameLine(); + + // if (ctx.main_exploit == 1) + // ImGui::Text("hide shots"); + // else if (ctx.main_exploit > 1) + // ImGui::Text("doubletap"); + // } + // else + // { + // ImGui::SameLine(); + // ImGui::TextColored(ImVec4(1.f, 0.f, 0.f, 1.f), "none"); + // } + // } + + // if (ctx.m_settings.aimbot_key != 0) + // { + // ImGui::Text("rage aimbot: "); + // ImGui::SameLine(); + // + // if (ctx.allows_aimbot) + // ImGui::Text("enabled"); + // else + // ImGui::TextColored(ImVec4(1.f, 0.f, 0.f, 1.f), "disabled"); + // + // } + + // if (ctx.allows_aimbot) + // { + // ImGui::Text("min damage override: "); + // ImGui::SameLine(); + + // if (feature::ragebot->m_damage_key) + // ImGui::Text("enabled"); + // else + // ImGui::Text("disabled"); + + // } + + // /*ImGui::Text("lagcomp:"); + // ImGui::SameLine(); + // ImGui::TextColored(ctx.breaks_lc ? ImVec4(0.f, 1.f, 0.f, 1.f) : ImVec4(1.f, 0.f, 0.f, 1.f), "%.f", ctx.last_origin_delta);*/ + // } + // } + // ImGui::End(); + // } + + // speclist(); + + // if (!feature::menu->_menu_opened) + // return; + + // ImGui::is_input_allowed = true; + + // static auto alpha = 1.f; + // static auto pos = 0.4f; + // static auto switch_p = false; + // static auto switch_category = false; + // static auto was_hovered = false; + // static auto tab_size = 150.f; + + // /* + // main.RegisterTab(&legitbot, "legit bot", "a", 480, 660, { "global", "A", "P", "e", "W", "Z" }, F::Weapons); + // main.RegisterTab(&ragebot, "rage bot", "c", 0, 623, {"aimbot", "anti-aim"}); + // main.RegisterTab(&visuals, "visuals", "d", 530, 0, { "players","other" }); + // main.RegisterTab(&misc, "miscellaneous", "f", 0, 623, {"misc", "config"}); + // main.RegisterTab(&skins, "skins", "e", 0, 623); + // main.RegisterTab(&Lists, "players", "k", 530, 660); + // */ + + // static auto t_ragebot = s_tab(("Ragebot"), "c"); + // static auto t_legitbot = s_tab(("Legitbot"), "a"); + // static auto t_visuals = s_tab(("Visuals"), "d"); + // static auto t_skins = s_tab(("Skins"), "e"); + // static auto t_misc = s_tab(("Misc"), "f"); + // static auto curtab = 0; + + // //bool pressed_return = false; + + // if (alpha < 1.f) + // init(1.f); //нічого крім меню не повинно змінювати прозорість + + // ImGui::SetNextWindowSize(ImVec2(700, 550)); + + // if (ImGui::Begin(sxor("birdie v4"), (bool*)0, ImGuiWindowFlags_NoCollapse | ImGuiColumnsFlags_NoResize | ImGuiWindowFlags_NoTitleBar/*| ImGuiWindowFlags_CoolStyle*/ | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse, 0)) + // { + // auto window = ImGui::GetCurrentWindow(); + // const auto cursorpos = ImGui::GetCursorPos(); + + // /*pos = Math::clamp(pos, -1.f, 0.f); + // ImGui::PushClipRect(window->Pos + ImVec2(window->WindowPadding.x, 40 + window->WindowPadding.y), window->Pos + ImVec2(0, 40 + window->WindowPadding.y) + ImVec2(window->Size.x - window->WindowPadding.x, window->Size.y - 40 - window->WindowPadding.y * 2.f), false); + // ImGui::SetCursorPosY(cursorpos.y + window->Size.y * pos); + // ImGui::SetCursorPosX(cursorpos.x - 500); + // ImGui::Image((void*)flag_ewropi, ImVec2(1600, 900), ImVec2(0.f, 0.f), ImVec2(1.f, 1.f), ImVec4(1.f, 1.f, 1.f, 0.15f)); + // ImGui::PopClipRect(); + + // if (fabs(pos) >= 1.f || pos == 0.f) + // switch_p = !switch_p; + + // if (switch_p) + // pos -= 0.0005f; + // else + // pos += 0.0005f; + + // ImGui::SetCursorPos(cursorpos);*/ + + // if (alpha < 1.f) //БЛЯТЬ ну вот честно не ебу зачем я поставил эту хуйню два раза LINE#308, похуй. + // init(alpha); //нічого крім меню не повинно змінювати прозорість + + // auto is_hovered = ImGui::mouse_in_pos(ImRect(window->Pos, window->Pos + ImVec2(static_cast(tab_size * 0.45f) + window->WindowPadding.x * 2.f, window->Size.y))); + + // if (is_hovered || was_hovered && ImGui::mouse_in_pos(ImRect(window->Pos, window->Pos + ImVec2(tab_size + window->WindowPadding.x * 2.f, window->Size.y)))) { + // if (pos < 1.f) + // pos += 0.08f; + + // is_hovered = true; + // } + // else { + // if (pos > 0.5f) + // pos -= 0.08f; + // } + + // pos = Math::clamp(pos, 0.5f, 1.f); + + // const auto show_names = (pos > 0.65f); + + // /*if (pos > 0.8f) + // { + // ImGui::SameLine(); + // ImGui::SetCursorPosY(cursorpos.y + window->Size.y - window->WindowPadding.y*2.f - 22.5f); + // ImGui::Text("getze.us v4"); + // }*/ + // ImGui::SetCursorPos(cursorpos); + + // ImGui::PushClipRect(window->Pos, window->Pos + ImVec2(tab_size * pos + window->WindowPadding.x * 2.f, window->Size.y), false); + // add_tab(t_ragebot, &curtab, ImVec2(tab_size * pos, static_cast(tab_size * 0.45f)), show_names); + // add_tab(t_legitbot, &curtab, ImVec2(tab_size * pos, static_cast(tab_size * 0.45f)), show_names); + // add_tab(t_visuals, &curtab, ImVec2(tab_size * pos, static_cast(tab_size * 0.45f)), show_names); + // add_tab(t_skins, &curtab, ImVec2(tab_size * pos, static_cast(tab_size * 0.45f)), show_names); + // add_tab(t_misc, &curtab, ImVec2(tab_size * pos, static_cast(tab_size * 0.45f)), show_names); + // ImGui::PopClipRect(); + + // ImGui::SetCursorPos(ImVec2(tab_size * pos + window->WindowPadding.x * 2.f, cursorpos.y)); + + // //if (switch_category) { + // // if (alpha > 0.01f) { + // // init(alpha); //оновлюють кольору + // // alpha -= 0.025f; + // // } + // // else { + // // switch_category = false; + // // category = new_category; //закінчили міняти прозорість, пора-б застосувати категорію + // // } + // //} + // //else + // //{ + // // if (alpha < 1.f) { + // // init(alpha); //оновлюють кольору + // // alpha += 0.025f; + // // } + // //} + + // alpha = Math::clamp(alpha, 0.f, 1.f); + + // static int currentCategory{ 0 }; + // static int currentWeapon{ 0 }; + + // ImGui::BeginChild(sxor("##mainshit"), ImVec2(0, window->Size.y - window->WindowPadding.y * 2.f), true, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse); + // { + // float cursor_pos_y; + + // switch (curtab) + // { + // case 0: + // ImGui::Columns(2, NULL, true); + // { + // ImGui::BeginChild("##ragebotmain"); + // { + // ImGui::Checkbox(sxor("Ragebot enabled"), &ctx.m_settings.aimbot_enabled); + // ImGui::SameLine(); + // ImGui::Bind(sxor("##ROnkey"), &ctx.m_settings.aimbot_key, ImVec2(100, 20)); + + // ImGui::Checkbox(sxor("Automatic revolver"), &ctx.m_settings.aimbot_auto_revolver); + // ImGui::Checkbox(sxor("Silent aim"), &ctx.m_settings.aimbot_silent_aim); + // ImGui::Checkbox(sxor("No Recoil/Spread"), &ctx.m_settings.aimbot_no_spread); + // ImGui::Checkbox(sxor("Automatic scope"), &ctx.m_settings.aimbot_autoscope); + // ImGui::SliderInt(sxor("Field of view"), &ctx.m_settings.aimbot_fov_limit, 0, 180); + // ImGui::Checkbox(sxor("Hitchance"), &ctx.m_settings.aimbot_hitchance); + + // ImGui::SliderInt(sxor("##hcv"), &ctx.m_settings.aimbot_hitchance_val, 0, 100); + // ImGui::Spacing(); + + // ImGui::SliderInt(sxor("Min damage"), &ctx.m_settings.aimbot_min_damage_viable, 0, 101); + // ImGui::Spacing(); + // ImGui::Checkbox(sxor("Autowall"), &ctx.m_settings.aimbot_autowall); + // ImGui::Text(sxor("Wall min damage")); + // ImGui::SliderInt(sxor("##Wallmindamage"), &ctx.m_settings.aimbot_min_damage, 0, 101); + // ImGui::Spacing(); + // ImGui::Checkbox("Position Adjustment", &ctx.m_settings.aimbot_position_adjustment); + // ImGui::Checkbox("Extended Silent Shot", &ctx.m_settings.extended_silent_shot); + // ImGui::Checkbox("Fake-Correction", &ctx.m_settings.aimbot_position_adjustment_old); + // ImGui::Checkbox("Aimbot With Knife", &ctx.m_settings.aimbot_allow_knife); + // ImGui::Checkbox("Aimbot With Zeus", &ctx.m_settings.aimbot_allow_taser); + // ImGui::Checkbox("OnShot Capsule", &ctx.m_settings.misc_visuals_hitboxes); + // ImGui::ColorPickerBox("#nigaimbox", ctx.m_settings.misc_visuals_hitboxes_color, nullptr, nullptr, nullptr); + // ImGui::Spacing(); + // ImGui::Separator(); + // ImGui::Spacing(); + + // ImGui::Columns(2, NULL, true); + // ImGui::BeginChild("##ragebothitbox"); + // { + + // ImGui::Checkbox(sxor("Scan head"), &ctx.m_settings.aimbot_hitboxes[0]); + // ImGui::Checkbox(sxor("Scan chest"), &ctx.m_settings.aimbot_hitboxes[1]); + // ImGui::Checkbox(sxor("Scan body"), &ctx.m_settings.aimbot_hitboxes[2]); + // ImGui::Checkbox(sxor("Scan arms"), &ctx.m_settings.aimbot_hitboxes[3]); + // ImGui::Checkbox(sxor("Scan legs"), &ctx.m_settings.aimbot_hitboxes[4]); + // ImGui::Checkbox(sxor("Scan feet"), &ctx.m_settings.aimbot_hitboxes[5]); + // ImGui::Separator(); + // ImGui::Spacing(); + // ImGui::Checkbox(sxor("Prefer body aim"), &ctx.m_settings.aimbot_prefer_body); } + // ImGui::EndChild(); + // ImGui::NextColumn(); + // ImGui::BeginChild("##ragebotedges"); + // { + // constexpr auto sliders_size = 135.f; + // ImGui::Text("MultiPoint"); + // ImGui::Checkbox(sxor("Head"), &ctx.m_settings.aimbot_multipoint[0]); + // if (ctx.m_settings.aimbot_multipoint[0]) + // { + // cursor_pos_y = ImGui::GetCursorPosY(); + + // ImGui::SetCursorPosY(cursor_pos_y + 8); + // ImGui::PushItemWidth(sliders_size); + // ImGui::SliderInt(sxor("##Headscale"), &ctx.m_settings.aimbot_pointscale[0], 1, 100); + // ImGui::PopItemWidth(); + // ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 8); + // ImGui::Spacing(); + // ImGui::Spacing(); + // ImGui::Spacing(); + + // } + // ImGui::Checkbox(sxor("Chest"), &ctx.m_settings.aimbot_multipoint[1]); + // if (ctx.m_settings.aimbot_multipoint[1]) + // { + // cursor_pos_y = ImGui::GetCursorPosY(); + + // ImGui::SetCursorPosY(cursor_pos_y + 8); + // ImGui::PushItemWidth(sliders_size); + // ImGui::SliderInt(sxor("##chestscale"), &ctx.m_settings.aimbot_pointscale[1], 1, 100); + // ImGui::PopItemWidth(); + // ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 8); + + // ImGui::Spacing(); + // ImGui::Spacing(); + // ImGui::Spacing(); + // } + // ImGui::Checkbox(sxor("Body"), &ctx.m_settings.aimbot_multipoint[2]); + // if (ctx.m_settings.aimbot_multipoint[2]) + // { + // cursor_pos_y = ImGui::GetCursorPosY(); + + // ImGui::SetCursorPosY(cursor_pos_y + 8); + // ImGui::PushItemWidth(sliders_size); + // ImGui::SliderInt(sxor("##bodyscale"), &ctx.m_settings.aimbot_pointscale[2], 1, 100); + // ImGui::PopItemWidth(); + // ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 8); + // + + // ImGui::Spacing(); + // ImGui::Spacing(); + // ImGui::Spacing(); + // } + // ImGui::Checkbox(sxor("Arms"), &ctx.m_settings.aimbot_multipoint[3]); + // if (ctx.m_settings.aimbot_multipoint[3]) + // { + // cursor_pos_y = ImGui::GetCursorPosY(); + + // ImGui::SetCursorPosY(cursor_pos_y + 8); + // ImGui::PushItemWidth(sliders_size); + // ImGui::SliderInt(sxor("##armsscale"), &ctx.m_settings.aimbot_pointscale[3], 1, 100); + // ImGui::PopItemWidth(); + + // ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 8); + // ImGui::Spacing(); + // ImGui::Spacing(); + // ImGui::Spacing(); + // } + // ImGui::Checkbox(sxor("Legs"), &ctx.m_settings.aimbot_multipoint[4]); + // if (ctx.m_settings.aimbot_multipoint[4]) + // { + // cursor_pos_y = ImGui::GetCursorPosY(); + + // ImGui::SetCursorPosY(cursor_pos_y + 8); + // ImGui::PushItemWidth(sliders_size); + // ImGui::SliderInt(sxor("##legsscale"), &ctx.m_settings.aimbot_pointscale[4], 1, 100); + // ImGui::PopItemWidth(); + + // ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 8); + // ImGui::Spacing(); + // ImGui::Spacing(); + // ImGui::Spacing(); + // } + // ImGui::Checkbox(sxor("Feet"), &ctx.m_settings.aimbot_multipoint[5]); + // if (ctx.m_settings.aimbot_multipoint[5]) + // { + // cursor_pos_y = ImGui::GetCursorPosY(); + + // ImGui::SetCursorPosY(cursor_pos_y + 8); + // ImGui::PushItemWidth(sliders_size); + // ImGui::SliderInt(sxor("##feetscale"), &ctx.m_settings.aimbot_pointscale[5], 1, 100); + // ImGui::PopItemWidth(); + + // ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 8); + // ImGui::Spacing(); + // ImGui::Spacing(); + // ImGui::Spacing(); + // } + // } + // ImGui::EndChild(); + // } + // ImGui::EndChild(); + // } + // ImGui::NextColumn(); + // { + // ImGui::BeginChild("##ragebotaa"); + // { + // ImGui::Checkbox(sxor("Anti-Aim"), &ctx.m_settings.anti_aim_enabled); + // ImGui::Text("Pitch"); + // ImGui::Combo("##typexAA", &ctx.m_settings.anti_aim_typex, "Off\0Down\0Up\0Zero"); + // ImGui::Text("Yaw"); + // ImGui::Combo("##typeyAA", &ctx.m_settings.anti_aim_typey, "Off\0Backwards\0Zero\0Lby Twist\0Spin\0"); + // ImGui::Text("Yaw Jitter"); + // ImGui::Combo("##YawdJitter", &ctx.m_settings.anti_aim_jittering_type, "Off\0Random\0Static\0"); + // if (ctx.m_settings.anti_aim_jittering_type != 0) + // ImGui::SliderInt("##jittering", &ctx.m_settings.anti_aim_jittering, -90, 90); + // ImGui::Text("Desync Type"); + // ImGui::Combo("##typeyFAA", &ctx.m_settings.anti_aim_typeyfake, "Off\0Static\0Jitter\0Tank\0Onetap\0"); + // if (ctx.m_settings.anti_aim_typeyfake != 0) + // ImGui::SliderInt("", &ctx.m_settings.anti_aim_fake_limit, 0, 60); + // ImGui::Text("Invert Anti-Aim"); + // ImGui::Bind("##fakesidekey", &ctx.m_settings.anti_aim_fake_switch.key, ImVec2(100, 20)); + // //ImGui::SameLine(); + // ImGui::Text("body yaw"); + // ImGui::Combo("##body yaw", &ctx.m_settings.anti_aim_typelby, "opposite\0eye yaw\0"); + // ImGui::Text("on-shot fake yaw"); + // ImGui::Combo("##onshotyaw", &ctx.m_settings.anti_aim_typeyfake_shot, "Default\0Opposite\0Cycle\0Alternative\0"); + // ImGui::Text("At Targets"); + // ImGui::Checkbox(sxor("Follow by crosshair"), &ctx.m_settings.anti_aim_at_target[0]); + // ImGui::Combo("##freestanding body yaw", &ctx.m_settings.anti_aim_freestanding_fake_type,"none\0peeking\0hiding\0"); + // ImGui::Checkbox(sxor("Swap Desync on Overlap"), &ctx.m_settings.anti_aim_automatic_side[4]); + + + // ImGui::Spacing(); + // ImGui::Separator(); + // ImGui::Spacing(); + // ImGui::Checkbox(sxor("Fakelag"), &ctx.m_settings.fake_lag_enabled); + // ImGui::Combo("##typeFakelag", &ctx.m_settings.fake_lag_type, "Maximum\0Break\0"); + // ImGui::SliderInt("value", &ctx.m_settings.fake_lag_value, 0, 16); + // ImGui::SliderInt("variance", &ctx.m_settings.fake_lag_variance, 0,100); + // ImGui::Spacing(); + // ImGui::Checkbox(sxor("Fake Lag While Shooting"), &ctx.m_settings.fake_lag_shooting); + // ImGui::Checkbox(sxor("Fake Lag On Peek"), &ctx.m_settings.fake_lag_peek); + // ImGui::Checkbox(sxor("Lag Compensation Breaker"), &ctx.m_settings.fake_lag_lag_compensation); + // ImGui::Checkbox(sxor("Desync Client Side"), &ctx.m_settings.fake_lag_special); + + // ImGui::Spacing(); + // ImGui::Separator(); + // ImGui::Spacing(); + // + // ImGui::Text("Doubletap"); + // ImGui::SameLine(); + // ImGui::Bind("##DTkey", &ctx.m_settings.aimbot_doubletap_exploit_toggle.key, ImVec2(100, 20)); + // ImGui::Combo("##dt mode", &ctx.m_settings.aimbot_doubletap_method, "Defensive\0Instant\0"); + // ImGui::SliderInt("DT Hitchance", &ctx.m_settings.aimbot_doubletap_hitchance_val, 0, 80); + // ImGui::Checkbox(sxor("Extend Teleport"), &ctx.m_settings.aimbot_extra_doubletap_options[0]); + // ImGui::Checkbox(sxor("Stop Before 2nd Shot"), &ctx.m_settings.aimbot_extra_doubletap_options[1]); + + // ImGui::Text("HideShots"); + // ImGui::SameLine(); + // ImGui::Bind("##Hideshotskey", &ctx.m_settings.aimbot_hideshots_exploit_toggle.key, ImVec2(100, 20)); + // ImGui::Spacing(); + + // ImGui::Text("Damage Override"); + // ImGui::SameLine(); + // ImGui::Bind("##DMGkey", &ctx.m_settings.aimbot_min_damage_override.key, ImVec2(100, 20)); + // ImGui::SliderInt(sxor("##Keymindamage"), &ctx.m_settings.aimbot_min_damage_override_val, 0, 101); + + // ImGui::Spacing(); + // ImGui::Separator(); + // ImGui::Spacing(); + + // ImGui::Checkbox(sxor("Quick stop"), &ctx.m_settings.aimbot_autostop); + // ImGui::Checkbox(sxor("Between shoots"), &ctx.m_settings.autostop_only_when_shooting); + // ImGui::Checkbox(sxor("Force Accuracy"), &ctx.m_settings.autostop_force_accuracy); + // ImGui::Combo("##autostop", &ctx.m_settings.autostop_type, "Slow motion\0Full Stop\0"); + + // } + // ImGui::EndChild(); + // } + // ImGui::Columns(1); + + // break; + // case 1: + // + // ImGui::PushItemWidth(110.0f); + // ImGui::PushID(0); + // ImGui::Combo("", ¤tCategory, "Global\0Pistols\0Heavy\0SMG\0Rifles\0"); + // ImGui::PopID(); + // ImGui::SameLine(); + // ImGui::PushID(1); + + // switch (currentCategory) { + // case 0: + // currentWeapon = 0; + // ImGui::NewLine(); + // break; + // case 1: { + // static int currentPistol{ 0 }; + // static constexpr const char* pistols[]{ "Global", "Glock-18", "P2000", "USP-S", "Dual Berettas", "P250", "Tec-9", "Five-Seven", "CZ-75", "Desert Eagle", "Revolver" }; + + // ImGui::Combo("", ¤tPistol, [](void* data, int idx, const char** out_text) { + // if (ctx.m_settings.aimbot[idx ? idx : 35].enabled) { + // static std::string name; + // name = pistols[idx]; + // *out_text = name.append(" *").c_str(); + // } + // else { + // *out_text = pistols[idx]; + // } + // return true; + // }, nullptr, IM_ARRAYSIZE(pistols)); + + // currentWeapon = currentPistol ? currentPistol : 35; + // break; + // } + // case 2: { + // static int currentHeavy{ 0 }; + // static constexpr const char* heavies[]{ "Global", "Nova", "XM1014", "Sawed-off", "MAG-7", "M249", "Negev" }; + + // ImGui::Combo("", ¤tHeavy, [](void* data, int idx, const char** out_text) { + // if (ctx.m_settings.aimbot[idx ? idx + 10 : 36].enabled) { + // static std::string name; + // name = heavies[idx]; + // *out_text = name.append(" *").c_str(); + // } + // else { + // *out_text = heavies[idx]; + // } + // return true; + // }, nullptr, IM_ARRAYSIZE(heavies)); + + // currentWeapon = currentHeavy ? currentHeavy + 10 : 36; + // break; + // } + // case 3: { + // static int currentSmg{ 0 }; + // static constexpr const char* smgs[]{ "Global", "Mac-10", "MP9", "MP7", "MP5-SD", "UMP-45", "P90", "PP-Bizon" }; + + // ImGui::Combo("", ¤tSmg, [](void* data, int idx, const char** out_text) { + // if (ctx.m_settings.aimbot[idx ? idx + 16 : 37].enabled) { + // static std::string name; + // name = smgs[idx]; + // *out_text = name.append(" *").c_str(); + // } + // else { + // *out_text = smgs[idx]; + // } + // return true; + // }, nullptr, IM_ARRAYSIZE(smgs)); + + // currentWeapon = currentSmg ? currentSmg + 16 : 37; + // break; + // } + // case 4: { + // static int currentRifle{ 0 }; + // static constexpr const char* rifles[]{ "Global", "Galil AR", "Famas", "AK-47", "M4A4", "M4A1-S", "SSG-08", "SG-553", "AUG", "AWP", "G3SG1", "SCAR-20" }; + + // ImGui::Combo("", ¤tRifle, [](void* data, int idx, const char** out_text) { + // if (ctx.m_settings.aimbot[idx ? idx + 23 : 38].enabled) { + // static std::string name; + // name = rifles[idx]; + // *out_text = name.append(" *").c_str(); + // } + // else { + // *out_text = rifles[idx]; + // } + // return true; + // }, nullptr, IM_ARRAYSIZE(rifles)); + + // currentWeapon = currentRifle ? currentRifle + 23 : 38; + // break; + // } + // } + // ImGui::PopID(); + // ImGui::SameLine(); + // ImGui::Checkbox("Enabled", &ctx.m_settings.aimbot[currentWeapon].enabled); + // ImGui::Separator(); + // ImGui::Columns(2, nullptr, false); + // ImGui::SetColumnOffset(1, 220.0f); + + // ImGui::Checkbox("Silent", &ctx.m_settings.aimbot[currentWeapon].silent); + // ImGui::Checkbox("Auto Delay", &ctx.m_settings.aimbot[currentWeapon].autodelay); + // ImGui::Checkbox("Friendly fire", &ctx.m_settings.aimbot[currentWeapon].friendlyFire); + // ImGui::Checkbox("Visible only", &ctx.m_settings.aimbot[currentWeapon].visibleOnly); + // ImGui::Checkbox("Scoped only", &ctx.m_settings.aimbot[currentWeapon].scopedOnly); + // ImGui::Checkbox("Ignore flash", &ctx.m_settings.aimbot[currentWeapon].ignoreFlash); + // ImGui::Checkbox("Ignore smoke", &ctx.m_settings.aimbot[currentWeapon].ignoreSmoke); + // ImGui::Combo("Bone", &ctx.m_settings.aimbot[currentWeapon].bone, "Nearest\0Best damage\0Head\0Neck\0Sternum\0Chest\0Stomach\0Pelvis\0"); + // ImGui::NextColumn(); + // ImGui::PushItemWidth(240.0f); + // ImGui::SliderFloat("Fov", &ctx.m_settings.aimbot[currentWeapon].fov, 0.0f, 20.0f, "%.2f"); + // ImGui::SliderFloat("Smooth", &ctx.m_settings.aimbot[currentWeapon].smooth, 1.0f, 100.0f, "%.2f"); + // ImGui::SliderFloat("Rcs Fov", &ctx.m_settings.aimbot[currentWeapon].rcsfov, 1.0f, 100.0f, "%.2f"); + // ImGui::SliderFloat("Silent Fov", &ctx.m_settings.aimbot[currentWeapon].silentfov, 1.0f, 100.0f, "%.2f"); + // ImGui::SliderFloat("Kill Delay", &ctx.m_settings.aimbot[currentWeapon].killdelay, 0.0f, 5.0f, "%.2f"); + // ImGui::Columns(1); + + // break; + // case 2: + // ImGui::Columns(2, NULL, true); + // { + // ImGui::BeginChild("##visualsplayers"); + // ImGui::Checkbox("Visuals enabled", &ctx.m_settings.visuals_enabled); + // ImGui::Checkbox("Dormant", &ctx.m_settings.esp_dormant); + // ImGui::Checkbox("Offscreen arrows", &ctx.m_settings.esp_offscreen); + // ImGui::ColorPickerBox("#nigarrows", ctx.m_settings.colors_esp_offscreen, nullptr, nullptr, nullptr); + // ImGui::Checkbox("Name", &ctx.m_settings.esp_name); + // ImGui::ColorPickerBox("#nigname", ctx.m_settings.colors_esp_name, nullptr, nullptr, nullptr); + // ImGui::Checkbox("Health", &ctx.m_settings.esp_health); + // ImGui::ColorPickerBox("#nighealth", ctx.m_settings.colors_esp_health, nullptr, nullptr, nullptr); + // ImGui::Checkbox("Weapon", &ctx.m_settings.esp_weapon); + // ImGui::Checkbox("Weapon ammo", &ctx.m_settings.esp_weapon); + // ImGui::ColorPickerBox("#nigammo", ctx.m_settings.colors_esp_ammo, nullptr, nullptr, nullptr); + // ImGui::Checkbox("Skeleton", &ctx.m_settings.esp_skeleton); + // ImGui::ColorPickerBox("#nigton", ctx.m_settings.colors_skeletons_enemy, nullptr, nullptr, nullptr); + + // ImGui::Checkbox("Glow ESP", &ctx.m_settings.esp_glow); + // ImGui::SameLine(); + // ImGui::Checkbox("Color based on hp", &ctx.m_settings.colors_glow_hp); + // ImGui::ColorPickerBox("#nigglow", ctx.m_settings.colors_glow_enemy, nullptr, nullptr, nullptr); + // ImGui::Spacing(); + // ImGui::Separator(); + // ImGui::Spacing(); + // ImGui::Checkbox("Penetration crosshair", &ctx.m_settings.visuals_autowall_crosshair); + // ImGui::Checkbox("Bullet impacts", &ctx.m_settings.visuals_draw_local_impacts); + // ImGui::Checkbox("Grenade Prediction", &ctx.m_settings.misc_grenade_preview); + // + // ImGui::Checkbox("Hitmarker", &ctx.m_settings.misc_visuals_indicators_2[0]); + // ImGui::SameLine(); + // ImGui::Checkbox("Hitsound", &ctx.m_settings.misc_hitsound_type); + // ImGui::Spacing(); + // ImGui::Separator(); + // ImGui::Spacing(); + // ImGui::Checkbox("Remove visual recoil", &ctx.m_settings.visuals_no_recoil); + // ImGui::Checkbox("Remove ingame post processing", &ctx.m_settings.visuals_no_postprocess); + // ImGui::Checkbox("Remove scope", &ctx.m_settings.visuals_no_scope); + // ImGui::Checkbox("Remove 1st zoom level", &ctx.m_settings.visuals_no_first_scope); + // ImGui::Checkbox("Remove smoke", &ctx.m_settings.visuals_no_smoke); + // ImGui::Checkbox("Remove flash", &ctx.m_settings.visuals_no_flash); + // ImGui::Checkbox("Override fov", &ctx.m_settings.misc_override_fov); + // ImGui::SameLine(); + // cursor_pos_y = ImGui::GetCursorPosY(); + + // ImGui::SetCursorPosY(cursor_pos_y + 8); + // ImGui::SliderInt("##oFov", &ctx.m_settings.misc_override_fov_val, -20, 60); + // ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 8); + // ImGui::EndChild(); + // } + // ImGui::NextColumn(); + // { + // ImGui::BeginChild("##visualsworld"); + // { + // // ImGui::Spacing(); + // ImGui::Checkbox("Show Weapons", &ctx.m_settings.esp_world_weapons); + // ImGui::Checkbox("Show grenades", &ctx.m_settings.esp_world_nades); + // ImGui::Checkbox("Show c4/hostage", &ctx.m_settings.esp_world_bomb); + // ImGui::Checkbox("Nightmode", &ctx.m_settings.misc_visuals_world_modulation[1]); + // ImGui::ColorPickerBox("#nigmode", ctx.m_settings.colors_world_color, nullptr, nullptr, nullptr); + // ImGui::Checkbox("Fullbright", &ctx.m_settings.misc_visuals_world_modulation[0]); + // ImGui::SliderInt("Prop alpha", &ctx.m_settings.visuals_props_alpha, 0, 100); + + // ImGui::Spacing(); + // ImGui::Separator(); + // ImGui::Spacing(); + + // ImGui::Checkbox("Local bullets tracer", &ctx.m_settings.visuals_draw_local_beams);//local_beams_color + // ImGui::ColorPickerBox("#nigtrace", ctx.m_settings.local_beams_color, nullptr, nullptr, nullptr); + // ImGui::Checkbox(sxor("Force crosshair"), &ctx.m_settings.visuals_force_crosshair); + // ImGui::Checkbox(sxor("Force Enemy On Radar"), &ctx.m_settings.misc_engine_radar); + + // ImGui::Spacing(); + // ImGui::Separator(); + // ImGui::Spacing(); + + // ImGui::Checkbox("Visible Chams", &ctx.m_settings.chams_enemy); + // ImGui::ColorPickerBox("#nigchamviable", ctx.m_settings.colors_chams_enemy_viable, nullptr, nullptr, nullptr); + // ImGui::Checkbox("Behind Wall", &ctx.m_settings.chams_walls); + // ImGui::ColorPickerBox("#nigchamshidden", ctx.m_settings.colors_chams_enemy_hidden, nullptr, nullptr, nullptr); + // ImGui::Checkbox("Local Model", &ctx.m_settings.chams_local_player); + // ImGui::ColorPickerBox("#nigchamslocal", ctx.m_settings.colors_chams_local, nullptr, nullptr, nullptr); + // ImGui::Text(sxor("Override player material")); + // ImGui::Combo("##playamaterial", &ctx.m_settings.menu_chams_type, "Flat\0Filled\0Glowing\0Model Glowing\0"); + // ImGui::Spacing(); + + // ImGui::SliderInt("Local scope alpha", &ctx.m_settings.scope_transparency, 0, 100); + + // ImGui::Spacing(); + // ImGui::Separator(); + // ImGui::Spacing(); + // ImGui::Checkbox(sxor("Spectator list"), &ctx.m_settings.visuals_extra_windows[0]); + // ImGui::Checkbox(sxor("Keybinds"), &ctx.m_settings.visuals_extra_windows[1]); + // ImGui::Spacing(); + // ImGui::Separator(); + // ImGui::Spacing(); + + // } + // ImGui::EndChild(); + // } + // ImGui::Columns(1); + + + // break; + + // case 3: + // { + // static auto selected_item = 0; + // static auto fake_wear = 1.f; + // static auto fake_seed = 0; + // static char fake_name[256] = ""; + // static auto fake_stattrak = false; + // static auto fake_stattrak_value = 0; + + // //if (ImGui::Begin("Skin changer") + // //{ + // ImGui::Page::Begin(3); + // ImGui::PushItemWidth(ImGui::GetCurrentWindow()->Size.x); + + // ImGui::ListBox(sxor("##weapons"), &selected_item, items_getter, (void*)parser::weapons.list.data(), parser::weapons.list.size(), 22); + + // ImGui::PopItemWidth(); + // ImGui::Page::Next(); + // ImGui::PushItemWidth(ImGui::GetCurrentWindow()->Size.x); + + // static bool show_all_skins = false; + // //ImGui::Checkbox("All skins", &show_all_skins); + + // static char filter_buffer[64] = ""; + // ImGui::InputText(sxor("##filter"), filter_buffer, 64); + + // // draw rarities + // static auto selected_rarity = 0; + // { + // static auto draw_rarity = [](rarity_t& rarity, int& selected_rarity, const float& alpha) { + + // bool selected = false; + // auto size = ImVec2(12, 8); + + // auto rarity_col = rarity.Color.alpha(alpha * 255); + + // ImGui::PushStyleColor(ImGuiCol_Button, selected_rarity == rarity.id ? (ImVec4)rarity_col : (ImVec4)rarity_col.malpha(0.3f)); //40 дохуя имхо + // ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)rarity_col.malpha(0.7f)); + // ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)rarity_col.malpha(0.7f)); + + // if (ImGui::Button(("##" + rarity.name).data(), size)) + // selected_rarity = rarity.id; + + // ImGui::PopStyleColor(3); + // ImGui::SameLine(/*0.f, 10.4f*/); + + // }; + + // for (auto& rarity : parser::rarities.list) { + // draw_rarity(rarity, selected_rarity, alpha); + // } + + // ImGui::NewLine(); + // } + + // auto selected_weapon = parser::weapons.list[selected_item].id; + // auto selected_skin = 0; + // /*for (auto i = 0u; i < parser::weapons.list[selected_item].skins.list.size(); i++) + // { + // auto skin = parser::weapons.list[selected_item].skins.list[i]; + // if (skin.id == cheat::settings.paint[selected_weapon]) + // selected_skin = i; + // }*/ + // auto old_skin = selected_skin; + + // if (!parser::weapons.list.empty()) + // skins_listbox(sxor("##skins"), std::string(filter_buffer), selected_rarity, &selected_skin, parser::weapons.list[selected_item].skins, 20, alpha); + + // //if (selected_skin != old_skin) { + // // ctx.m_settings.paint[selected_weapon] = parser::weapons.list[selected_item].skins.list[selected_skin].id; + // // //game::full_update(); + // //} + + // ImGui::PopItemWidth(); + // ImGui::Page::Next(); + // ImGui::PushItemWidth(ImGui::GetCurrentWindow()->Size.x); + + // ImGui::SliderFloat(sxor("wear"), &fake_wear, 0.f, 1.f); + // ImGui::Spacing(); + + // ImGui::Text(sxor("seed")); + // ImGui::InputInt(sxor("##_seed"), &fake_seed); + // ImGui::Spacing(); + + // ImGui::Checkbox(sxor("stat trak"), &fake_stattrak); + // if (fake_stattrak) { + // ImGui::InputInt(sxor("##_stattrak_value"), &fake_stattrak_value); + // } + // ImGui::Spacing(); + + // ImGui::Text(sxor("name")); + // ImGui::InputText(sxor("##_name"), fake_name, 256); + // ImGui::Spacing(); + + // static auto selected_knife = 0; + // static std::vector knife_list; + // if (knife_list.empty()) + // { + // knife_list = parser::knifes.list; + + // knife_t default_knife; + // default_knife.id = 0; + // default_knife.translated_name = L"Default"; + // knife_list.insert(knife_list.begin(), default_knife); + // } + + // if (ImGui::ListBox("##knife_changer", &selected_knife, items_getter, (void*)knife_list.data(), knife_list.size(), 6)) + // { + // auto new_id = knife_list[selected_knife].id; + // ctx.m_settings.skinchanger_knife = new_id; + // //game::full_update(); + // } + + // ImGui::PopItemWidth(); + // ImGui::Page::End(); + + // //} + // //ImGui::End(); + // }break; + // case 4: + // { + // ImGui::Columns(2, NULL, true); + // { + // ImGui::BeginChild("##misclocal"); + // { + // ImGui::Checkbox(sxor("Auto bhop"), &ctx.m_settings.misc_bhop); + + // ImGui::Checkbox(sxor("skinchanger"), &ctx.m_settings.skinchanger_enabled); + // ImGui::Combo("##slowwalkd", &ctx.m_settings.skinchanger_knife, "Favor Desyncsd\0Favor Random\0"); + // ImGui::Combo("##slowwalak", &ctx.m_settings.skinchanger_knife_skin, "Favor Desync\0Favor Random\0"); + + // ImGui::Checkbox(sxor("Auto strafe"), &ctx.m_settings.misc_autostrafer); + // ImGui::SameLine(); + // ImGui::Checkbox(sxor("WASD"), &ctx.m_settings.misc_autostrafer_wasd); + // ImGui::Spacing(); + // ImGui::Checkbox(sxor("In-game Inventory"), &ctx.m_settings.misc_unlock_inventory); + // ImGui::Checkbox(sxor("Left Hand Knife"), &ctx.m_settings.misc_knife_hand_switch); + // ImGui::Checkbox(sxor("Preserve killfeed"), &ctx.m_settings.misc_preserve_killfeed); + // ImGui::SliderInt(sxor("Aspect Ratio"), &ctx.m_settings.misc_aspect_ratio, 0, 100); + // ImGui::Spacing(); + // ImGui::Checkbox(sxor("Thirdperson"), &ctx.m_settings.visuals_tp_force); + // ImGui::SameLine(); + // ImGui::Bind("##tpkey", &ctx.m_settings.visuals_tp_key.key, ImVec2(100, 20)); + + // if (ctx.m_settings.visuals_tp_force) + // ImGui::SliderInt(sxor("##tpdistance"), &ctx.m_settings.visuals_tp_dist, 30, 300); + // ImGui::Spacing(); + // ImGui::Text(sxor("Auto peek")); + // ImGui::Bind("##apkey", &ctx.m_settings.anti_aim_autopeek_key.key, ImVec2(100, 20)); + // ImGui::Spacing(); + // ImGui::Text(sxor("Fakeduck")); + // ImGui::Bind("##fdkey", &ctx.m_settings.anti_aim_fakeduck_key.key, ImVec2(100, 20)); + // //ImGui::Text(sxor("Slowwalk Key")); + // //ImGui::Bind("##slowwalk", &ctx.m_settings._anti_aim_slowwalk_key, ImVec2(100, 20)); + // //ImGui::Text(sxor("Slowwalk")); + // //ImGui::Combo("##slowwalk", &ctx.m_settings.anti_aim_slow_walk_types, "Favor Desync\0Favor Random\0"); + // //ImGui::SliderInt("slow walk limit", &ctx.m_settings.anti_aim_slow_walk_speed, 0, 100); + // //ImGui::SliderInt("speed desync amount", &ctx.m_settings.anti_aim_slow_walk_desync, 0, 100); + // ImGui::Combo(sxor("Leg movement"), &ctx.m_settings.anti_aim_leg_movement, "Default\0Always Slide\0Never Slide\0LedSync"); + + // ImGui::Spacing(); + // ImGui::Separator(); + // ImGui::Spacing(); + + // ImGui::Checkbox(sxor("Log misses"), &ctx.m_settings.misc_notifications[2]); + // ImGui::SameLine(); + // ImGui::Checkbox(sxor("Log shots"), &ctx.m_settings.misc_notifications[3]); + // + // ImGui::Checkbox(sxor("Log damage"), &ctx.m_settings.misc_notifications[1]); + // ImGui::SameLine(); + // ImGui::Checkbox(sxor("Log purchases"), &ctx.m_settings.misc_notifications[4]); + // //ImGui::MultiCombo(sxor("notifications"), &ctx.m_settings.misc_autobuy_secondary, "bomb info\0 damage given\0miss\0shot debug\0purchases\0damage received"); + // ImGui::Spacing(); + // ImGui::Separator(); + // ImGui::Spacing(); + + // ImGui::Checkbox(sxor("Autobuy"), &ctx.m_settings.misc_autobuy_enabled); + // if (ctx.m_settings.misc_autobuy_enabled) { + // ImGui::Text(sxor("Autobuy primary")); + // ImGui::Combo(sxor("##Autoprimary"), &ctx.m_settings.misc_autobuy_primary, "none\0AK47/M4A1\0AWP\0SCAR20/G3\0SSG-08\0\0"); + // ImGui::Text(sxor("Autobuy secondary")); + // ImGui::Combo(sxor("##Autoecondary"), &ctx.m_settings.misc_autobuy_secondary, "none\0Deagle/R8\0Tec9/FiveSeven\0Dual berettas\0P250/CZ-74\0"); + // ImGui::Separator(); + // + // ImGui::Text(sxor("minimum money")); + // ImGui::SliderInt(sxor("##musor"), &ctx.m_settings.misc_autobuy_money_limit, 0, 10000); + // ImGui::Spacing(); + // ImGui::Separator(); + // ImGui::Checkbox(sxor("HE"), &ctx.m_settings.misc_autobuy_etc[4]); + // ImGui::SameLine(); + // ImGui::Checkbox(sxor("Smoke"), &ctx.m_settings.misc_autobuy_etc[3]); + // ImGui::SameLine(); + // ImGui::Checkbox(sxor("Flash"), &ctx.m_settings.misc_autobuy_etc[5]); + // ImGui::SameLine(); + // ImGui::Checkbox(sxor("Molotov"), &ctx.m_settings.misc_autobuy_etc[7]); + // ImGui::Separator(); + // ImGui::Checkbox(sxor("Armor"), &ctx.m_settings.misc_autobuy_etc[1]); + // ImGui::SameLine(); + // ImGui::Checkbox(sxor("Taser"), &ctx.m_settings.misc_autobuy_etc[0]); + // ImGui::SameLine(); + // ImGui::Checkbox(sxor("Kit"), &ctx.m_settings.misc_autobuy_etc[2]); + // } + // } + // ImGui::EndChild(); + // } + // ImGui::NextColumn(); + // { + // ImGui::BeginChild("##cfgmisc"); + // { + + // ImGui::Text(sxor("CFGS")); + // ImGui::Combo("##cfgselct", &g_settings.cur_cfg, "Legit\0Rage\0Hvh\0MM hvh\0Semi-rage\0"); + + // if (ImGui::Button(sxor("Save"))) + // feature::misc->save_cfg(); + + // if (ImGui::Button(sxor("Load"))) { + // feature::misc->load_cfg(); + // if (ctx.m_settings.skinchanger_enabled) ctx.updated_skin = true; + // } + + // ImGui::Spacing(); + // ImGui::Spacing(); + // ImGui::Spacing(); + + // if (ImGui::Button(sxor("Reset"))) + // { + // const size_t settings_size = sizeof(c_variables); + // for (int i = 0; i < settings_size; i++) + // { + // byte ¤t_byte = *reinterpret_cast(uintptr_t(&ctx.m_settings) + i); + // current_byte = 0; + // } + + // //#TODO def settings + // } + // } + // ImGui::EndChild(); + // } + // ImGui::Columns(1); + // break; + // } + // default: + // break; + // } + + // ImGui::EndChild(); + // } + + // was_hovered = is_hovered; + // } + + // if (alpha != 1.f) + // init(1.f); //нічого крім меню не повинно змінювати прозорість + + // ImGui::End(); + //} + } +} +``` + +`i_menu.hpp`: + +```hpp +#pragma once +#include "sdk.hpp" +#include "parser.hpp" + +namespace menu +{ + extern LPDIRECT3DTEXTURE9 flag_ewropi; + extern LPDIRECT3DTEXTURE9 m_tplayer_with_glow; + extern LPDIRECT3DTEXTURE9 m_tplayer_no_glow; + extern IDirect3DDevice9* m_device; + + extern int category; + extern int new_category; + + + extern void init(const float& alpha = 1.f); + + extern void skins_listbox(const char* label, std::string filter, int selected_rarity, int* current_item, skin_list_t& skins, int height_in_items, const float& alpha); + + extern void draw(IDirect3DDevice9* device); + +} +``` + +`icon_font.hpp`: + +```hpp +#pragma once + +static const unsigned int icons_font_compressed_size = 42732; +static const unsigned int icons_font_compressed[42732 / 4] = +{ + 0x0000bc57, 0x00000000, 0x80bf0000, 0x00000400, 0x00010037, 0x000d0000, 0x00030080, 0x54464650, 0x881c804d, 0xbf000013, 0x28158264, 0x4544471c, + 0x00270046, 0x200f8268, 0x2c0f823c, 0x2f534f26, 0x02130f32, 0x010000aa, 0x2c0f8258, 0x616d6360, 0xd12c2870, 0x020000a3, 0x241382b0, 0x736167de, + 0x20178270, 0x202f8210, 0x38078234, 0x796c6708, 0x37371a66, 0x05000066, 0xb6000018, 0x61656824, 0x4dc41664, 0x201b824d, 0x210382dc, 0x10826836, + 0x0def1023, 0x203b8295, 0x280f8214, 0x746d6824, 0x1489a178, 0x200f8221, 0x2c0f82b8, 0x636f6cf8, 0x9219c061, 0x040000e4, 0x280f8290, 0x78616d86, + 0x02530070, 0x201f8231, 0x2b0f8238, 0x6d616e20, 0x2406e265, 0xbb000025, 0x012d9f82, 0x736f7056, 0xcb5b6174, 0xbc0000e7, 0x20938294, 0x2ddb849d, + 0x739a1901, 0x5f69081a, 0x00f53c0f, 0x3682040b, 0xd2000025, 0x83caedeb, 0x8cd72b08, 0x00006d01, 0x2d0df2ff, 0x0f828d03, 0x02000822, 0x02830582, + 0x0000012a, 0xc0ffc003, 0x9a0d0000, 0x0d210e83, 0x8349842d, 0x2003870a, 0x2411843a, 0x002f0242, 0x21128410, 0x008f0002, 0xb407032c, 0x05009001, + 0x99020000, 0x1c82cc02, 0x07858f20, 0x00eb0125, 0x82090133, 0x21028b0f, 0x0d8b1001, 0x01220b85, 0x83840be2, 0xc0034024, 0x12824000, 0x05829382, + 0x20230285, 0x85040100, 0x01002209, 0x21088555, 0xb3820002, 0x51009a3a, 0x5d008006, 0x4f00000a, 0x57004d05, 0x4b00e605, 0x56001a0b, 0x53006609, + 0x622ac982, 0x5a001a09, 0x4d004d0b, 0x23821a0c, 0x6400b326, 0x5b009a0d, 0x24082782, 0x0000055d, 0x00b30955, 0x00e60a5a, 0x009a0a62, 0x00e6075d, + 0x00660963, 0x00660a55, 0x0066065e, 0x00330565, 0x28238256, 0x001a0659, 0x004d0861, 0x2043824f, 0x20078260, 0x36078262, 0x00800a4a, 0x00800c53, + 0x00cd0855, 0x00000253, 0x00e60254, 0x821a0258, 0x00cd2607, 0x009a0357, 0x200b8261, 0x20ab8251, 0x201f825e, 0x205b8252, 0x2c578253, 0x009a0553, + 0x004d075a, 0x0000035b, 0x29038262, 0x00e60366, 0x004d0959, 0x4382085d, 0xab820820, 0x522a5b82, 0x52004d09, 0x5100cd08, 0x01825300, 0x5400502b, + 0x76004300, 0xbe003100, 0x86e68200, 0x001c2103, 0x22051341, 0x840300d8, 0x001c2409, 0x82bc0004, 0x002a221b, 0x20098220, 0x0813820a, 0x04e02026, + 0x0ee00be0, 0x13e011e0, 0x28e024e0, 0x3de031e0, 0x66e040e0, 0xfde1f4e1, 0x04e200e2, 0x0be208e2, 0xfffffdff, 0x002a3382, 0x00e02000, 0x0de007e0, + 0x2b8210e0, 0x26e0182a, 0x3be02ae0, 0x64e03fe0, 0xf9202b82, 0x02242b82, 0x0ae207e2, 0x23082b85, 0x0520e4ff, 0x02200320, 0x00200120, 0xfb1ffc1f, + 0xf11ffa1f, 0xcd1ff01f, 0x3c1e401e, 0x391e3a1e, 0x361e371e, 0x2a209184, 0x04a35784, 0x2f820120, 0x06010026, 0x03010000, 0x01262e85, 0x00000002, + 0x008d0002, 0x00000124, 0x00400004, 0x088408e4, 0x10000800, 0x72011800, 0x8804a802, 0x6c068605, 0xe6084807, 0x0e0bd809, 0x580f7e0d, 0xec126811, + 0x62154c14, 0x021a2818, 0x8a1d081c, 0x0421f81f, 0x14244223, 0x3a27a025, 0x962ad228, 0x542f662c, 0x54341a32, 0x4036e635, 0x44383437, 0xa439f838, + 0x2e3cb03a, 0x4e3f283d, 0xa6411a40, 0x32445243, 0x6246ec44, 0x4049d647, 0xda4b924a, 0x2a50044e, 0x7e536051, 0xfe57a255, 0x305ac859, 0x125b705a, + 0x01000000, 0x02850382, 0x00000224, 0x0fa00239, 0x000a2c08, 0x03400051, 0x0040031d, 0x0018000c, 0x0038002b, 0x00520045, 0x006b005e, 0x00e50077, + 0x012e0100, 0x37160607, 0x3217013e, 0x87372716, 0x3233250c, 0x16360536, 0x27250582, 0x2e270626, 0x28058201, 0x33361415, 0x37260617, 0x262b8436, + 0x37070616, 0x84070622, 0x1617260f, 0x16272306, 0x86268222, 0x0e07210f, 0x36233082, 0x82011e17, 0x8639822c, 0x26162415, 0x8426012f, 0x226b8232, + 0x82011416, 0x32312824, 0x39303736, 0x82033e01, 0x3227243b, 0x82363331, 0x07262b5e, 0x34352634, 0x2223022e, 0x4282020e, 0x830e1721, 0x8308829e, + 0x011e21a4, 0x05820e83, 0x82141621, 0x83578263, 0x82208237, 0x3e212202, 0x82c38301, 0x8233201b, 0x32362109, 0x17213182, 0x82b88233, 0x01aa0802, + 0x0f230694, 0x0b070903, 0x0e040906, 0x1f0be301, 0x07050307, 0x050d0a09, 0x19f2fe06, 0x713f2d3c, 0x6c400b08, 0x26143625, 0x79231a1b, 0x23165787, + 0x59474764, 0x97451224, 0x1010199c, 0x0c030e0f, 0x0c071344, 0x0601110b, 0x0f050202, 0x10080208, 0x035d020d, 0x0507222a, 0x151c1505, 0x10870309, + 0x100f140c, 0x0c500f04, 0x35081b03, 0x02031719, 0x16020203, 0x35010a1c, 0x05275819, 0x52260508, 0x0318133a, 0x01010203, 0x0e19161b, 0x1d012510, + 0x41506d44, 0x04193c60, 0x07040703, 0x0c08070e, 0x020a0d09, 0x01141b0f, 0x02820103, 0x832d3808, 0x0e0d0f09, 0x0b040519, 0x2a51040b, 0x17172510, + 0x19010314, 0x07141d05, 0x39050905, 0x3e141e1c, 0x08040706, 0x062b4d07, 0x11161d08, 0xc5011126, 0x0e39271f, 0x82020109, 0x095a0801, 0x3a1d1e17, + 0x0303080e, 0x01bf0403, 0x100c3216, 0x14020642, 0x0a110401, 0x0251100d, 0x492d1d6f, 0x30640203, 0xf8028d18, 0x16050603, 0x35315f1a, 0x05970c0f, + 0x05160302, 0x04011202, 0x02d0081e, 0x0305161c, 0x0b020301, 0x021f0505, 0x10020401, 0x3842621a, 0x9b020110, 0xfb82240e, 0x21050529, 0xfe140105, + 0x821a0e85, 0x042b08cb, 0x495e3718, 0x07102110, 0x29091120, 0x0d1b0e05, 0x293d471e, 0x29514027, 0x01112115, 0x2a090707, 0x0729100c, 0x070c1c36, + 0x8205070d, 0x292b08c8, 0x09060403, 0x090a2007, 0x4b03060b, 0x171d294e, 0x0f113218, 0x01050e28, 0x21230205, 0x06043631, 0x442a0201, 0x11162512, + 0x82000a1b, 0x00023c00, 0x0626005d, 0x005b0316, 0x00de00c2, 0x012e0100, 0x23013e35, 0x2e27012e, 0x830e0701, 0x22232202, 0x26088326, 0x26270622, + 0x832a2336, 0x2205821a, 0x82062227, 0x83268217, 0x26222202, 0x210e8323, 0x23820706, 0x82012e21, 0x06072217, 0x21328316, 0x29832206, 0x47821182, + 0x1516062a, 0x1e171614, 0x06161701, 0x23825685, 0x16323322, 0x14850282, 0x87141521, 0x010e2217, 0x27298417, 0x37011e33, 0x2e33013e, 0x08820583, + 0x36230283, 0x863e3316, 0x3435220e, 0x27148536, 0x33013a33, 0x3233033a, 0x27210e86, 0x84758201, 0x22c08287, 0x82013c35, 0x20218327, 0x087e8332, + 0x14060757, 0x01010301, 0x0115040d, 0x0b0b0902, 0x0b080a13, 0x071f080a, 0x01020203, 0x0504010f, 0x070d0708, 0x11376e37, 0x03051123, 0x060c0703, + 0x162f5d2f, 0x0a0c162c, 0x3263320a, 0x0810170f, 0x14040617, 0x05220605, 0x0f050805, 0x0e060920, 0x0309040d, 0x04020802, 0x08538210, 0x05040c22, + 0x0503020a, 0x10170402, 0x0b0b2411, 0x130a0f08, 0x11251209, 0x03061b1a, 0x06020803, 0x1b10060a, 0x36084882, 0x070f0901, 0x582e070e, 0x254a242e, + 0x03031204, 0x0d050306, 0x180b0405, 0x150f2b0d, 0x150b1428, 0x050b0d0a, 0x0e140608, 0x21111b0c, 0x67332143, 0x0a346767, 0x8207040e, 0x10330823, + 0x0803fd02, 0x250d1122, 0x04090b0d, 0x11280102, 0x1c112111, 0x02070202, 0x0b140aee, 0x04020d0b, 0x030e0a04, 0x05060c03, 0x02040401, 0x0101020a, + 0x82010c04, 0x010521e9, 0x41080a82, 0x010a010f, 0x18040603, 0x1b040404, 0x0f170804, 0x0601020c, 0x02030201, 0x1308030f, 0x0a0d0807, 0x110a1309, + 0x10050507, 0x010a0f0f, 0x1c040301, 0x0e180e19, 0x0c060f06, 0x4c250d19, 0x1e3c1d26, 0x4482230b, 0x03010232, 0x240a0d02, 0x0f1d0f0b, 0x1b1f3d1f, + 0x110a112e, 0x02201283, 0x0d334782, 0x0f142d15, 0x16090928, 0x27130b02, 0x10271013, 0x8212cdfe, 0x0b052f6b, 0x13070906, 0x031a1225, 0x1f0f1331, + 0x0082000d, 0x4f000433, 0x93092500, 0x91005a03, 0x2c010c01, 0x00004a01, 0x084c4401, 0x42011e21, 0x1727081e, 0x07010e23, 0x82232606, 0x26222102, + 0x24067f42, 0x07171606, 0x24168415, 0x0f012e27, 0x84098201, 0x14152502, 0x06141716, 0x222e2c83, 0x2e012f06, 0x012e3501, 0x27263427, 0x1d422636, + 0x82058505, 0x26272131, 0x20062042, 0x82238237, 0x16362273, 0x20058217, 0x28068235, 0x17151632, 0x16333632, 0x24058232, 0x3521011f, 0x20208a17, + 0x82208333, 0x36322198, 0x82421983, 0x24a58205, 0x17010e07, 0x23738423, 0x06262726, 0x07220d82, 0x88820614, 0x85010f21, 0x821083a0, 0x1614219c, + 0x2a222283, 0x7e832301, 0x35205484, 0x35209c82, 0x37239e82, 0x42373634, 0x1b8506c9, 0x0f825982, 0x2a052722, 0x20067343, 0x41ed8207, 0x1e21050f, + 0x22188201, 0x83263637, 0x05232527, 0x23072622, 0x1721f684, 0x21868233, 0xc4833217, 0x83013f21, 0x0866821b, 0x038804ec, 0x0e050509, 0x060d0709, + 0x02010b04, 0x08030307, 0x01060201, 0x02030251, 0x0f0b1c0b, 0x351a0f1d, 0x0e1d0e1a, 0x16102017, 0x1c0a0202, 0x21131e3e, 0x15341613, 0x05080a17, + 0x04091108, 0x07030506, 0x1a401708, 0x0c1c3e1f, 0x20140101, 0x01020212, 0x09020205, 0x0e1d1001, 0x0d091008, 0x3a0a100f, 0x03030a14, 0x15081506, + 0x05020818, 0x0f040402, 0x1d0e0e19, 0x0c170c10, 0x1f040304, 0x25121f3d, 0x0d220d13, 0xd6110208, 0x06020301, 0x0e170f04, 0x0c101e0f, 0x03070c18, + 0x40803f01, 0x030e0209, 0x16020904, 0x0b03062e, 0x0104020c, 0x37160455, 0x1c361b17, 0x0c1a3821, 0x08020218, 0x451f0a05, 0x22652722, 0x08070c11, + 0x16110b0d, 0x1e173115, 0x05021d3c, 0x0809050b, 0x23130202, 0x01050212, 0x08020509, 0x260f0d21, 0x8b820d06, 0x01093708, 0x07150607, 0xfd071f19, + 0x11231133, 0x07111c13, 0x05060209, 0x060c0602, 0x0e111d0f, 0x332f0f1d, 0x08010204, 0x350d1105, 0x210d7404, 0x190d040b, 0x07030205, 0x1d821403, + 0x0f1e0f24, 0x8d82312f, 0x0d12052e, 0x03193219, 0x040a062e, 0x02010406, 0x082bb583, 0x080d190d, 0x361a0a1f, 0x8206031a, 0x015d0871, 0x03010201, + 0x140f1905, 0x020a1935, 0x0102150b, 0x0a030202, 0x190d0d05, 0x1c391c10, 0x14101a0f, 0x19111427, 0x03050e08, 0x150b0f0c, 0x0a05020a, 0x10020602, + 0x24120f1f, 0x21412012, 0x19132713, 0x07141c2c, 0x0c130a04, 0x14010606, 0x1b0d1c29, 0x0108060e, 0x06030501, 0x011b010c, 0x2f718203, 0x01010418, + 0x030d0301, 0x080f082e, 0x02010707, 0x1021a382, 0x25198219, 0x02090f06, 0x29820a02, 0x1305072c, 0x310e161b, 0x1e3c1e0b, 0x2c830809, 0x0a170a32, + 0x0d061118, 0x04190607, 0x130c040b, 0x191a0202, 0x1a289d82, 0x52231938, 0x02030b20, 0x05253b82, 0x09041014, 0x3adf8204, 0x190e0506, 0x1325140e, + 0x221e4121, 0x1425244a, 0x1b070209, 0x17090508, 0x82ba2433, 0x05082b84, 0x190c060b, 0x060b060c, 0x84820d04, 0x10170733, 0x090d180e, 0x03060710, + 0x0e0d0705, 0x140c1a0d, 0x08178306, 0x12180624, 0x0f092013, 0x02000006, 0x24005700, 0x5a03d404, 0xb7009800, 0x2e010000, 0x06262701, 0x23062223, + 0x0283012a, 0x27062223, 0x2108842e, 0x0e88032a, 0x16262722, 0x27060e43, 0x0607010e, 0x14161716, 0x820be945, 0x1415211a, 0x36261482, 0x37013e37, + 0xa7433632, 0x82352005, 0x2702880b, 0x3e373436, 0x32161701, 0x82050c49, 0x3637220b, 0x84268234, 0x33162608, 0x3233013a, 0x201a8236, 0x22268217, + 0x82353634, 0x26342835, 0x011c0127, 0x86261415, 0x36262781, 0x35013c35, 0x2a843234, 0x60086982, 0xce041506, 0x050c0c02, 0x0c04050a, 0x152a1407, + 0x03326633, 0x0503020a, 0x0c170c03, 0x696a6935, 0x13251235, 0x18070f08, 0x070c1b30, 0x06140a06, 0x0405090c, 0x4802010a, 0x0308121c, 0x06040804, + 0x120b050b, 0x0d060507, 0x132e0e0d, 0x11274d27, 0x0701082e, 0x03050203, 0x09040204, 0x02060205, 0x2b2c8201, 0x10140c11, 0x260b160c, 0x2415254b, + 0x01201c82, 0x04310082, 0x10240e09, 0x320d1e0d, 0x090f3265, 0x083a0203, 0x82288203, 0x05250817, 0x0c2c20fe, 0x0c1c381c, 0x02080b2c, 0x582c0d25, + 0x0207042b, 0x30030205, 0x01021e09, 0x02012301, 0x05010303, 0x0856820f, 0x0705132b, 0x34150c0f, 0x11211217, 0x090d222a, 0x12091016, 0x0c160c08, + 0x24122511, 0x31172549, 0x0c191018, 0x0101050f, 0x180f0105, 0x32738204, 0x1109020c, 0x12231209, 0x080a1409, 0x3814080f, 0x8205090d, 0x0130084f, + 0x16030609, 0x0c180b15, 0x0a081108, 0x15090513, 0x1f020203, 0x0303060c, 0x06060c06, 0x180b0605, 0x19311a0b, 0x150accfe, 0x0502130a, 0x071e0507, + 0x1420c582, 0x1b33f682, 0x02000009, 0x26004b00, 0x5a037305, 0xa7009400, 0x47010000, 0x8f4407af, 0x05b04405, 0x06141522, 0x27220e82, 0xd5440622, + 0x09f84105, 0x82010e21, 0x4223200b, 0x3e2b0525, 0x26223701, 0x37362627, 0x4115011c, 0x262009e6, 0x27233285, 0x8235013c, 0x45342002, 0x172809be, + 0x16171632, 0x033a3336, 0x01210284, 0x05f24133, 0x2005c145, 0x250e851e, 0x011e1706, 0x5d820517, 0x82062221, 0x08218581, 0x36343584, 0x0a730523, + 0x14281421, 0x16274f27, 0x360c162a, 0x04020302, 0x02120601, 0x13285128, 0x160b1329, 0x0b0d0a0b, 0x14091911, 0x0f080e1c, 0x02160708, 0x060d1001, + 0x7b3e060d, 0x0203013e, 0x0e0d2814, 0x2b19060d, 0x0c180b16, 0x11080f0b, 0x150b2804, 0x01060a0a, 0x1c040407, 0x060a0e07, 0x0d0d0a06, 0x0e010207, + 0x54542b02, 0x743a2a54, 0x263a7473, 0x1109254c, 0x01010308, 0x08050a02, 0x01060602, 0x56820708, 0x0101013b, 0x03fe0204, 0x11284e28, 0x2811020d, + 0x0f0d2850, 0xc0021203, 0x02034c18, 0x201a8203, 0x2c008201, 0x28131104, 0x08120814, 0x04051603, 0x327b8202, 0x07020203, 0x0d270402, 0x1522441f, + 0x32161429, 0x83130e16, 0x161423a0, 0x2d821837, 0x44202608, 0x11201122, 0x25122910, 0x0a05175b, 0x0a190605, 0x08142914, 0x0b070811, 0x01020807, + 0x0a0b0301, 0x0d090102, 0x22868203, 0x82010304, 0x04023001, 0x341b0615, 0x12107d1b, 0x100d3f09, 0x82004409, 0x00023b00, 0x0a400056, 0x004003a0, + 0x0095007d, 0x012f0100, 0x07152335, 0x020f010e, 0x02832f23, 0x0b832520, 0x27210125, 0x822f030f, 0x82272013, 0x1307350d, 0x36043f25, 0x0f011f16, + 0x17011e03, 0x023f011e, 0x3e37013e, 0x0d820682, 0x37230782, 0x84013f17, 0x241a8217, 0x2e023f17, 0x05cd4101, 0x82333521, 0x8233200f, 0x37212610, + 0x21371733, 0x29058217, 0x0527013f, 0x012b010e, 0x22822622, 0x2305c449, 0x16323733, 0x8a082782, 0x089b0a15, 0x02032e2b, 0x0d220305, 0x1e1b16b0, + 0x1b1615c8, 0x041b20fe, 0xfd070206, 0x3f660991, 0x202f1c30, 0x3a316ea2, 0x08150c31, 0xc80a0116, 0x1732434d, 0x13070e08, 0x11202214, 0x0b0b0d03, + 0x142d0d17, 0x0a0b0e04, 0x15290c16, 0x35101e0f, 0x210d1b0e, 0x2f130c09, 0x1a361c1c, 0x33223f1f, 0x472e1425, 0x0b231819, 0x0f9a0d0d, 0x16030501, + 0x01281d15, 0x12d80353, 0x242e010f, 0x130d0d13, 0xebf90505, 0x3d080d05, 0x84061009, 0x09103b00, 0x050d083d, 0xb0020506, 0x08790512, 0x080b0211, + 0x1c0e054b, 0x09060725, 0x00820205, 0x09065f08, 0x060d1357, 0x090a0a0a, 0x040c0101, 0xc3fe070a, 0x191a4a58, 0x05010811, 0x3d1b0e06, 0x1b14243e, + 0x01060607, 0x2111090a, 0x0e1f1210, 0x0e0c112c, 0x0a030301, 0x02070507, 0x2a286138, 0x37201b45, 0x1a3a5217, 0x20214120, 0x3b1e1b3a, 0x03020a1c, + 0x160f0504, 0x0e130e13, 0x0b070321, 0x8383ae0d, 0x0d052e08, 0x070f0907, 0x06010505, 0x09100605, 0x00020000, 0x08f2ff53, 0x008d03fc, 0x0028011e, + 0x0e070100, 0x0f171501, 0x23072701, 0x010e020f, 0x06914d17, 0x37013e30, 0x23272636, 0x33371725, 0x010f011f, 0x04832f23, 0x2723272b, 0x2b010e23, + 0x05012f01, 0x280a8207, 0x14072307, 0x011f0706, 0x2243831e, 0x8215011f, 0x0616223a, 0x281d820f, 0x013f3634, 0x022f013e, 0x20078226, 0x285f8227, + 0x010e010f, 0x2622030f, 0x8315822f, 0x23038319, 0x27263435, 0x20068149, 0x06f6410f, 0x02263c82, 0x27372606, 0x0282012e, 0x4e022f21, 0xff43052f, + 0x010f2205, 0x052c441f, 0x2406f441, 0x012e012f, 0x2c5e8235, 0x33013e02, 0x023f3525, 0x16233517, 0x22a48206, 0x82230723, 0x36342418, 0x83173337, + 0x32333a64, 0x35371516, 0x3f151737, 0x33173301, 0x33153335, 0x23150715, 0x33172335, 0x8450821e, 0x8b148310, 0x15172303, 0x2d842117, 0x17377608, + 0x3b013e37, 0x8b041701, 0x03040407, 0x060e1605, 0x3706081b, 0x03040105, 0x154b0609, 0x36080b20, 0x0a08032f, 0x0e13045e, 0x0505370f, 0x0a310705, + 0x1f060e0a, 0x18043105, 0x2d040501, 0xbefe0309, 0x07060811, 0x07094305, 0x09120807, 0x02030108, 0x0d010102, 0x0a08020c, 0x021c312a, 0x02050f04, + 0x02090801, 0x53140a09, 0x1a2b1061, 0x0b170c47, 0x054e6e40, 0x08258207, 0x1505063a, 0x17030c08, 0x0e0e0808, 0x1310443e, 0x0b0f0502, 0x0f110303, + 0x08132816, 0x52520902, 0x19010507, 0x0a0a190e, 0x2105040f, 0x04050232, 0x0e010504, 0x221f1a28, 0x0d0c0803, 0x0b3a0d82, 0x0c068208, 0x040b0706, + 0x010e0c23, 0x240e0202, 0x0207150d, 0x1f1b12bb, 0x7082112a, 0x27020e24, 0xae820e05, 0x070a0426, 0x07020226, 0x53080082, 0x5817150b, 0x0f10226a, + 0x0c16160d, 0x080e0937, 0x24050108, 0x26102611, 0x270f2710, 0x144e1e10, 0x09065901, 0x0a140a29, 0x0402012b, 0x01071c03, 0x0b0505f9, 0x01061706, + 0x07020e01, 0x08120a64, 0x02020806, 0x5307080b, 0x1016054d, 0x0a0701b2, 0x030a191a, 0x032a7782, 0x03030404, 0x06120802, 0x21824406, 0x24082382, + 0x1b130507, 0x113a3309, 0x08041325, 0x07090704, 0x37142d19, 0x1c06140d, 0x060a0513, 0x0b04040a, 0x116b252f, 0x085a8218, 0x04030141, 0x0b221817, + 0x02120f27, 0x0e190a14, 0x02031310, 0x05050105, 0x28040b06, 0x4f32511e, 0x0f0a1867, 0x021c1d05, 0x25361614, 0x522b2b4f, 0x28023d27, 0x05050302, + 0x17050104, 0x0b221512, 0x82130d1b, 0x042b08fb, 0x07050504, 0x3c900b11, 0x140d0e49, 0x081d1507, 0x0d080f09, 0x39010512, 0x07050606, 0x11190706, + 0x05021211, 0x03040702, 0x82010607, 0x0d0e2f60, 0x04060c0c, 0x0705016d, 0x0304010d, 0x00880415, 0x1a273c08, 0x0905040b, 0x02040206, 0x00000202, + 0x62000200, 0x2b0d8d00, 0xa400f302, 0x0000b200, 0x35012f01, 0x17373521, 0x2f331735, 0x23020f02, 0x3f363235, 0x07232701, 0x0f151715, 0x82272301, + 0x0e073211, 0x17011d01, 0x3f011f15, 0x23153302, 0x030f010e, 0x251a8223, 0x012e2721, 0x0b822123, 0x07201e84, 0x3a081e82, 0x33033f33, 0x36323717, + 0x1f333735, 0x33043f05, 0x17011e37, 0x013e023f, 0x35251533, 0x033f013e, 0x23010e17, 0x012b012e, 0x06150622, 0x33021f16, 0x37012f37, 0x3f353721, + 0x82263401, 0x23360883, 0x3e372135, 0x05273501, 0x35262223, 0x013b3634, 0x14151632, 0x04270d06, 0x3792f806, 0x0207e021, 0x4b462605, 0x0502a737, + 0x020b0301, 0x3220025f, 0x37412e64, 0xd3820618, 0x02046308, 0x1d374138, 0x03036124, 0x2d250b01, 0xfe090602, 0x0a041fc8, 0x09edfe04, 0x1e020306, + 0x060c0b67, 0x1c080303, 0x4c172325, 0x04030d28, 0x2216970c, 0x514f2b21, 0x080e1036, 0x13050901, 0x22350f22, 0x0a0d0213, 0x0e010801, 0x1d35370c, + 0x09130adf, 0x040e1203, 0x01040707, 0x2f050f06, 0x05050805, 0x6782d901, 0x0d050525, 0x83c8045a, 0xf3f63a17, 0x0e0e0d40, 0x0d0e400d, 0x0c26020d, + 0x011a050c, 0x840e0405, 0x08060503, 0x08278208, 0x0620045b, 0x03130612, 0x03040401, 0x06020203, 0x04311f05, 0x07060306, 0x03011d04, 0x08070301, + 0x1f1d1d06, 0x03070505, 0x05070302, 0x674c0509, 0x05031484, 0x08040608, 0x4a050408, 0x0f222010, 0x17060a0d, 0x03232f2b, 0x05010d0c, 0x03030f12, + 0x02501c53, 0x0f0f0305, 0x05040308, 0x267d8204, 0x230d1608, 0x82091106, 0x0304311f, 0x040e0a09, 0x06154e0d, 0x0f06100a, 0x0c0e0fe8, 0x0e220082, + 0x0082000f, 0x5a000237, 0xa7084000, 0xc4004103, 0x0000db00, 0x06161701, 0x23062217, 0x060c4a06, 0x48270721, 0x884805ac, 0x26222406, 0x44161407, + 0x272b05a9, 0x15140607, 0x1e07010e, 0x82011f01, 0x17152223, 0x078f4822, 0x27012e25, 0x4a37013e, 0xea4d0558, 0x010e2805, 0x15161423, 0x8207011e, + 0x032e2208, 0x82358227, 0x23058208, 0x012f012e, 0xd24d0684, 0x21368308, 0x2a823335, 0x3f821720, 0x021e3222, 0x3e260f83, 0x013e3501, 0x02821e17, + 0x05840320, 0x36330123, 0x05514e16, 0x08840720, 0x013a1527, 0x37163233, 0x2b88823e, 0x22212515, 0x14011d06, 0x033a3316, 0x36201383, 0x20089383, + 0x069f0823, 0x18010902, 0x26141830, 0x22432214, 0x0a172918, 0x0d0c0405, 0x29152214, 0x52292951, 0x3f168229, 0x36120d01, 0x11251215, 0x0b0a0d14, + 0x01010105, 0x0a0d0606, 0x11251104, 0x04070f08, 0x07090307, 0x45080382, 0x02250b11, 0x28180909, 0x0e261817, 0x041b120b, 0x27010602, 0x05023058, + 0x1e010304, 0x03011e3c, 0x0c1d0d09, 0x02040704, 0x01386a32, 0x150f0204, 0x14030205, 0x05081209, 0x09d0050c, 0x20140b14, 0x50502911, 0x4d822851, + 0x09025008, 0x221a4813, 0x5a2e2244, 0x2b2d5b5a, 0x552a2b55, 0x0408042b, 0x01020314, 0x1d0f0208, 0x1601010e, 0x2a13162b, 0x28502713, 0xfdeefd08, + 0x1312133f, 0xa2a25112, 0x380f52a2, 0x0d010e0b, 0x02090d04, 0x140a144a, 0x0901050a, 0x15070111, 0x82071222, 0x301627ae, 0x02070c12, 0xb6820502, + 0x0e226808, 0x04091604, 0x1009040a, 0x0a06151d, 0x03060103, 0x04020201, 0x5225050d, 0x19231722, 0x04050a05, 0x1f080902, 0x182c1214, 0x3c1d1830, + 0x2a151c1d, 0x2a555455, 0x07070c05, 0x0109031b, 0x0a040805, 0x02030f1a, 0x5a2c0103, 0x1c56202f, 0x080c150c, 0x06060810, 0x090c180d, 0x04040e17, + 0x170b0501, 0x0a19090c, 0x82010812, 0x03012456, 0x54010303, 0x06270519, 0x1c451607, 0x82142613, 0x8202206f, 0x0b0521fa, 0x23087482, 0x13149905, + 0x03131223, 0x0b430b0e, 0x02000605, 0x55004d00, 0x2903e20a, 0xc801b801, 0x06010000, 0x26222726, 0x2208084d, 0x55010e07, 0x1520058e, 0x2f080550, + 0x14152622, 0x26220722, 0x27012a27, 0x3627012e, 0x4709354d, 0x3e820527, 0x24066153, 0x1e23012a, 0x06144201, 0x2c824782, 0x29820287, 0x013e2723, + 0x20208237, 0x0b564d22, 0x26272623, 0x05754222, 0x8205e042, 0x06d74226, 0x2008be42, 0x859b8c36, 0x066f4771, 0x37263627, 0x34272636, 0x84418326, + 0x34352905, 0x32363736, 0x33363233, 0x36246b82, 0x36323716, 0x0e830282, 0x82363221, 0x05c54295, 0x17823320, 0x51013a21, 0x16220911, 0x3b853536, + 0x50010e21, 0xce8205f5, 0x3c228386, 0x50833701, 0x32331625, 0x86161716, 0x20598241, 0x883e8233, 0x841a8241, 0x825c86f2, 0x5616200e, 0x23210677, + 0x82988322, 0x20d4844a, 0x53058322, 0x3b8605ee, 0x1620a782, 0x4d829582, 0x2e200283, 0x17259289, 0x1c151416, 0x20058201, 0x21c88207, 0x7d82013a, + 0x32163322, 0xc8822686, 0x17141627, 0x05070616, 0x20968206, 0x82758236, 0x23620857, 0x0a070622, 0x244924d5, 0x0a050805, 0x31180a14, 0x07040818, + 0x15080f07, 0x1104070f, 0x200e0c02, 0x0d180d0f, 0x07021906, 0x04050a05, 0x01060409, 0x041c0602, 0x33152b15, 0x361c3367, 0x0810081c, 0x04081b09, + 0x01020308, 0x07100801, 0x031d391d, 0x10010307, 0x254b240c, 0x03022b0a, 0x05030203, 0x1b820102, 0x03011227, 0x04020808, 0x30448303, 0x07040101, + 0x0a0e0304, 0x070b170c, 0x1907070b, 0x226d8206, 0x82020902, 0x102c085a, 0x0a04111d, 0x06210807, 0x02102111, 0x0e0b0305, 0x0d220c08, 0x171a080b, + 0x2513162d, 0x0e1e0f12, 0x481f3e20, 0x42204890, 0x060c1c22, 0x02225782, 0x00850107, 0x02042b08, 0x08120102, 0x09122512, 0x07060910, 0x0f300c04, + 0x14234623, 0x130a1326, 0x021b030a, 0x1113110a, 0x29110f1e, 0x11231116, 0xee82100a, 0x1d0f0a29, 0x0d16070f, 0x820a0109, 0x25123790, 0x101f0f13, + 0x11142813, 0x27141023, 0x01040513, 0x02010701, 0x41820a33, 0x244b2424, 0x14822410, 0x8f821420, 0x09110937, 0x07020903, 0x1e0f0a03, 0x0304040f, + 0x10050e03, 0x4d271022, 0x36748226, 0x09092f0e, 0x060c0304, 0x14063f04, 0x2b151328, 0x08190815, 0x82010603, 0x2b132ded, 0x99994c07, 0x2c164d99, + 0x070e0716, 0x4608da82, 0x0a070f06, 0x07090709, 0x1327130e, 0x02204020, 0x0d06080c, 0x01150508, 0x01030706, 0x04030405, 0x07040209, 0x04020504, + 0x23060e06, 0x44222245, 0x030e0622, 0x02010103, 0x1045f90b, 0x2a13093e, 0x0f080307, 0x820c110b, 0xdd012466, 0x82030205, 0x05042b29, 0x0e1c0a04, + 0x0b0e0d08, 0x3e820413, 0x01090722, 0x40820082, 0x04010523, 0x21098202, 0xb3820701, 0x26090136, 0x760c264c, 0x050e0903, 0x120f0a02, 0x381c1224, + 0x0e1b0e1c, 0x06245782, 0x0905020e, 0x0b287882, 0x19090a16, 0x02040302, 0x35083383, 0x04080504, 0x0d010601, 0x1f412102, 0x03030b07, 0x170c0515, + 0x0103020c, 0x150e230d, 0x3611131e, 0x160b040c, 0x1a341c0c, 0x1e010e0b, 0x0c140c17, 0x12081207, 0xe0821323, 0x820b0521, 0x09032e90, 0x040a0911, + 0x01010502, 0x010b051b, 0x29508301, 0x1f0c0302, 0x09100507, 0x91821a0b, 0x0b090739, 0x04090806, 0x02041801, 0x07060708, 0x0b180905, 0x03030503, + 0x82020102, 0x01012c7f, 0x120a0734, 0x070e080a, 0x8203040c, 0x02052211, 0x28188208, 0x01020101, 0x07030a05, 0x230d8207, 0x03010404, 0x07210f82, + 0x39048204, 0x0e2e0d0d, 0x0708130a, 0x03020103, 0x06020407, 0x030d0204, 0x160b0206, 0x3a830816, 0x01040528, 0x09030d08, 0xe4820827, 0x04040130, + 0x06122011, 0x0106070e, 0x040b0303, 0x50820305, 0x13042708, 0x03160905, 0x0112108b, 0x03160a16, 0x05060502, 0x00030000, 0x0b25005d, 0x015a039f, + 0x01490139, 0x01000055, 0x56510632, 0x012a2106, 0x28052d43, 0x23012a23, 0x22232206, 0x440e8216, 0x0583057e, 0x07062624, 0x11820622, 0x20068a44, + 0x21208214, 0x32840706, 0x35212685, 0x213e840e, 0xe4540614, 0x8417200b, 0x21448914, 0x5847012e, 0x08c94405, 0x210e4b50, 0x63501415, 0x08d75506, + 0x840fff44, 0x06072550, 0x34262726, 0x33205688, 0x82052b58, 0x16322205, 0x07315837, 0x50057244, 0x37280566, 0x1e171636, 0x36141701, 0x16210883, + 0x08544436, 0x32832720, 0x86170621, 0x83032011, 0x34262417, 0x82263435, 0x3e33283b, 0x06323701, 0x83011c15, 0x06142302, 0x41841415, 0x41821620, + 0x1d823220, 0x22051723, 0x20518206, 0x456f8233, 0x25200581, 0xc1455e82, 0x1e600805, 0x108f0b01, 0x0d060804, 0x49240e1c, 0x2a552a25, 0x0d112312, + 0x0b060c18, 0x03020906, 0x0b102906, 0x16030914, 0x0b130b04, 0x0b285228, 0x06010202, 0x01020805, 0x1a010201, 0x2c592d02, 0x0a285529, 0x1d070a15, + 0x1c010d07, 0x0e061b37, 0x04010407, 0x08020206, 0x13210d05, 0x280e130a, 0x0e042650, 0x54083082, 0x050e0803, 0x16060d06, 0x11081222, 0x05070507, + 0x160c200a, 0x0a061426, 0x050b0405, 0x04030707, 0x09050408, 0x03040201, 0x0c1a0e09, 0x09132714, 0x1f10030a, 0x0c0e050d, 0x03060c06, 0x4d27051b, + 0x2b572b26, 0x1a317342, 0x0b061735, 0x030b1007, 0x03020105, 0x082f8202, 0x2d09049e, 0x351b371b, 0x356b6a6b, 0x050b180b, 0x080c0408, 0x1427140d, + 0x0b090f0b, 0x06030106, 0x080c0a1f, 0x0c0e0d0a, 0x04050609, 0x11074702, 0x1a0d1124, 0x366d360d, 0x010a120a, 0x160a0303, 0x0a0c100b, 0x27050e05, + 0x7038274e, 0x1d387070, 0x06011d3a, 0x060b0203, 0x090c170b, 0x041e0a02, 0x4f12250e, 0x2f174e9c, 0x0a480f17, 0x0717b8f8, 0x0c14090b, 0x0605490a, + 0x29151d04, 0x055dfc15, 0x7e3a0607, 0x44874540, 0xd5020301, 0x01070b49, 0x01020101, 0x0f080601, 0x1305071a, 0x02040308, 0x042ca782, 0x0a0b0204, + 0x03010404, 0x0a130909, 0x05212082, 0x27228202, 0x42030209, 0x0609060b, 0x15390f82, 0x0d250d02, 0x33132614, 0x35193162, 0x14290e17, 0x06020802, + 0x2110070e, 0x38c78210, 0x04448943, 0x07030407, 0x01030602, 0x030a0a02, 0x04040407, 0x07180303, 0x08b9820b, 0x15112030, 0x0d07162b, 0x060c0402, + 0x04091509, 0x4e260612, 0x0d260e27, 0x04070d07, 0x02020101, 0x02020402, 0x2c142849, 0x04110617, 0x120c1a08, 0x4f821125, 0x21080282, 0x01014d1c, + 0x0505031c, 0x08080407, 0x170d1309, 0x080d012a, 0x02010209, 0x14080a05, 0x01060309, 0x9f820801, 0x070f083f, 0x0102050c, 0x05050905, 0x1a05050f, + 0x0e020201, 0x0d1a0d08, 0x01030704, 0x13040303, 0x20ea8202, 0x08268204, 0x0f030332, 0x0e30a20f, 0x0e040108, 0x24022914, 0x5e332449, 0x00170b2e, + 0x00030000, 0x0a210064, 0x00600342, 0x012b0018, 0x01000091, 0x22232634, 0x26061716, 0x4205bd5d, 0x3e360689, 0x1e013701, 0x013a3301, 0x37263233, + 0x22373634, 0x010e0726, 0xbb551707, 0x06222205, 0x252e8207, 0x22230626, 0x58591526, 0x06cd5505, 0x91432620, 0x42352005, 0x162306e9, 0x4a140607, + 0x058205c1, 0x23220722, 0x4308a043, 0x2721086d, 0x07d05534, 0x15560e20, 0x82012005, 0x59268253, 0xdf480532, 0x25118208, 0x23061617, 0xe95b010e, + 0x26362108, 0x27212282, 0x82988326, 0x5433204c, 0x05820536, 0xa7829a82, 0x08844c82, 0x11832320, 0x52853620, 0x43062644, 0x2e2208f3, 0x48543501, + 0x08f6430a, 0x00481720, 0x37262209, 0x23fe843e, 0x3a37013e, 0x2006714b, 0x20778337, 0x20978236, 0x27e28215, 0x32331614, 0x16343534, 0x15233b82, + 0x82011d14, 0x26028223, 0x16171632, 0x82363736, 0x8316201a, 0x8214853e, 0x36322205, 0x84478217, 0x412f8302, 0x36210621, 0x07784833, 0x06141522, + 0x2008ad83, 0x18404d05, 0x07020e0d, 0x02070313, 0x0c0f1201, 0x0e111f09, 0x08140e1d, 0x01b70303, 0x1a0d0503, 0x0816820d, 0x0801015d, 0x0b060721, + 0x08018b04, 0x060c0501, 0x0708080e, 0x1b080414, 0x0b1f0308, 0x07110710, 0x6b6b6b36, 0x1d3b1e35, 0x03091513, 0x09020206, 0x010a050b, 0x06030101, + 0x08010c1b, 0x02020106, 0x1c09130a, 0x27081c38, 0x01020207, 0x0c040703, 0x03040111, 0x02030b01, 0x07090501, 0x820c180d, 0x075a086e, 0x070a0613, + 0x04150809, 0x02060907, 0x12070605, 0x09110d05, 0x08060506, 0x410b0d07, 0x210e273e, 0x0a042243, 0x0e080804, 0x080a1f0c, 0x09050202, 0x01030304, + 0x1e071008, 0x14091d3a, 0x05020809, 0x040b280d, 0x08110a08, 0x0b050509, 0x0a0e1b0e, 0x1e060708, 0x13261305, 0x41820f08, 0x4e27013a, 0x04200b27, + 0x0c0e2b05, 0x08040203, 0x542a1022, 0x6969352a, 0x10093569, 0x23084b82, 0x0d190d08, 0x0b1a351b, 0x130b0605, 0x0507070d, 0x0a091706, 0x1c050a14, + 0x01130404, 0x08051c03, 0x06101523, 0x1f38a982, 0x29050506, 0x5c2e2a53, 0x0509092e, 0x04040a03, 0x0a04050e, 0x05050101, 0x0a09d182, 0x2950a04f, + 0x30122a52, 0x0d190c0c, 0x0b070b04, 0x060a0b15, 0x0807041c, 0x1a321907, 0x151d3416, 0x01204120, 0x380124a0, 0x04180407, 0x0c0a1508, 0x0312151e, + 0x1d030101, 0x043d010f, 0x0b06181c, 0x04040b16, 0x81071f04, 0x0b090601, 0x04011209, 0x12020104, 0x01020710, 0x09051303, 0x01040105, 0x1a091108, + 0x09071a34, 0x0d150a05, 0x27142b15, 0x02042650, 0x06030107, 0x09120903, 0x040b1002, 0x1a0d0517, 0x2e5d2c0d, 0x02031906, 0x0b010102, 0x020b0502, + 0x0f0d0402, 0x0b06190d, 0x08050e0c, 0x06070303, 0x0c122810, 0x090e0c0d, 0x16070201, 0x3a733a18, 0x0d081008, 0x0b07092c, 0x0b350b0e, 0x07010203, + 0x18130714, 0x05120915, 0x13050b0e, 0x1c0f0303, 0x050c050f, 0x190e0709, 0x11071932, 0x0c01160e, 0x1710180b, 0x7139172f, 0x0b1f0c39, 0x080c0712, + 0x01040305, 0x04060519, 0x07050301, 0x0c0d0814, 0x0920160b, 0x820f1b07, 0x01052b88, 0x02070a05, 0x0a0a0204, 0x7b82070b, 0x04349182, 0x11030505, + 0x05112111, 0x03030110, 0x0d190d09, 0x03183119, 0x5d08a682, 0x000a1b20, 0x5b000700, 0x2d0d2600, 0xba005a03, 0xca00c500, 0xe700dc00, 0x1101ee00, + 0x25010000, 0x27013f27, 0x27010f35, 0x27071517, 0x33352315, 0x030f2735, 0x2737012f, 0x23020f23, 0x012f0507, 0x17072707, 0x2227020f, 0x15020f06, + 0x1507011f, 0x031f011e, 0x2f352307, 0x23270703, 0x16832307, 0x0e071725, 0x82040f01, 0x1327301b, 0x032f013f, 0x022f0715, 0x15010f23, 0x82231707, + 0x3507214f, 0x13244e83, 0x05011f33, 0x272c0282, 0x17373533, 0x17333537, 0x0533033f, 0x3f344782, 0x37351701, 0x05013f35, 0x031f1517, 0x3e023f33, + 0x011e1701, 0x17214982, 0x21258333, 0x94822135, 0x69822520, 0x37331730, 0x33072335, 0x25152337, 0x030f2127, 0x8c542517, 0x012f2206, 0x82a78205, + 0x82332030, 0x15012578, 0x07022f33, 0x8e821082, 0x16140722, 0x27204582, 0x20056f54, 0x20108201, 0x82108317, 0x366e087c, 0x0d012f26, 0x01a7fd29, + 0x50c1010c, 0x071c8b10, 0x5606171e, 0x06030302, 0x02010507, 0x05050211, 0x1bfe0809, 0x03180c09, 0x04020218, 0x0403030c, 0x08020601, 0x06011101, + 0x05111d05, 0x1e1506c6, 0x130e030a, 0x0506297b, 0x1d080307, 0x0904040f, 0x39020a05, 0x05050701, 0x0304a6b9, 0x2a100f09, 0x0121020b, 0x6d7d2084, + 0x7c254c02, 0x1982019c, 0x03024108, 0x0104058b, 0x01020467, 0x0c220122, 0x02222301, 0x0d0b0458, 0x0db50108, 0x03060d16, 0x091b0209, 0xe6010603, + 0x04020e05, 0x50011103, 0x04080408, 0x04050e0a, 0x128b0202, 0x4c02c14f, 0xe9fb0405, 0x57089a82, 0x59072f1f, 0x54530c07, 0x6efd5804, 0x0f88fe04, + 0x0815050c, 0x0b05a301, 0x07070807, 0x05acfa0b, 0x05040561, 0x04036304, 0x027d6f04, 0x04720504, 0x0c320ab6, 0x04010605, 0x11050c05, 0x03010909, + 0x0c160503, 0x0809020b, 0x030a7610, 0x02170401, 0x0118012d, 0x01050309, 0x34080182, 0x0b020818, 0x07020528, 0x04030414, 0x1d081203, 0x04110405, + 0x21090305, 0x07021502, 0x03020104, 0x02700508, 0x17290709, 0x3666152c, 0x45063707, 0x03224f75, 0x229f8203, 0x82113708, 0x0242084a, 0x0a6f0408, + 0x2b0c030b, 0x170c2101, 0x01081018, 0x02480205, 0x0b03180c, 0x1b1c4402, 0x1a473f4e, 0x04050504, 0x12055d01, 0x01070304, 0x0901090c, 0x8c020f02, + 0x30060805, 0x0c170d02, 0x05260155, 0xf8820209, 0x0a083708, 0x0501010e, 0x07713320, 0x01010303, 0x040a0508, 0x05010694, 0x077c0624, 0x0d1107b2, + 0x08054a03, 0x0d0d4d1f, 0x0c060281, 0x03083307, 0x11060501, 0x0610090c, 0x2b82f407, 0x03072108, 0x9a070704, 0x0205090e, 0x0c04fa02, 0x07080f09, + 0x040a080e, 0x0911080d, 0x0c080e06, 0x0f170808, 0x35081382, 0x09100f0b, 0x00150b15, 0x5d000300, 0xe3042600, 0xe7005a03, 0x0701f700, 0x1c010000, + 0x26060701, 0x15062223, 0x2a231614, 0x16222301, 0x17061617, 0x2217011e, 0xf5512326, 0x221d8205, 0x45272606, 0x262306d9, 0x49160607, 0x2f8407f1, + 0x36263283, 0x35013c35, 0x3e842634, 0x964a2620, 0x3e372208, 0x06144b01, 0x62830e20, 0x06262722, 0x2b202084, 0x41837182, 0x23061423, 0x202c8222, + 0x20238406, 0x058a4a36, 0x35200582, 0x1e247a82, 0x17303301, 0x07228783, 0x044f2206, 0x2a272705, 0x27312701, 0x98833606, 0x4605bf47, 0x32220581, + 0x265d3536, 0x86358505, 0x37262314, 0xa7652636, 0x14152305, 0xbd463306, 0x16052505, 0x36323332, 0x22268483, 0x010e0726, 0xf1820117, 0x934ad382, + 0x2e290805, 0xe3042301, 0x0a27070c, 0x0d040110, 0x0e234622, 0x0d010105, 0x01020201, 0x03112211, 0x1109041a, 0x0914090e, 0x0f182e1b, 0x08138204, + 0x150a0336, 0x1931190a, 0x100f0103, 0x0a0c1a0d, 0x06020609, 0x04060301, 0x02091108, 0x0d070603, 0x0f380c0a, 0x09050a08, 0x1604040d, 0x0f1e0f04, + 0x1b0c0c02, 0x0a110b04, 0x07264182, 0x0b08030d, 0x43820302, 0x01024208, 0x9e501d01, 0x080f084f, 0x02010303, 0x28100504, 0x12241312, 0x030d1c0e, + 0x02010115, 0x150b0910, 0x1528150a, 0x2a244824, 0x33192a53, 0x02010419, 0x1024100c, 0x05020906, 0x2f180903, 0x04070318, 0x08468305, 0x390a0644, + 0x0201110b, 0x0c170b12, 0xfe07070c, 0x192d1708, 0x06062413, 0x1d0a163b, 0x0d050e0a, 0x0809c8fd, 0x06020201, 0x0704080d, 0x11c80204, 0x04070c16, + 0x1a0b0d12, 0x04080b0e, 0x070d0608, 0x05320101, 0x8182110b, 0x07014908, 0x2d5c2d0f, 0x09091009, 0x0f030505, 0x0d1b0d03, 0x021a351a, 0x1b05390a, + 0x03111c36, 0x1203080e, 0x0f1d0e03, 0x0c254b25, 0x1b0c0b0b, 0x01060c0a, 0x09050901, 0x03030312, 0x0b0b160c, 0x07020b16, 0x02030302, 0x060f0204, + 0x273df082, 0x2c172751, 0x0e140e16, 0x010b0e05, 0x01030403, 0x0a030707, 0x02010103, 0x0c010301, 0x2b078301, 0x05120102, 0x0202090b, 0x0e020401, + 0xff82d382, 0x020d2308, 0x0e091a04, 0x2a0a151c, 0x08e90b02, 0x021d1a10, 0x29070502, 0x0133010a, 0x080f070b, 0x1a101e10, 0x156a1932, 0x00552d06, + 0x03970425, 0x0093005a, 0x010000c4, 0x2105f362, 0x904d2226, 0x012a2306, 0x96422223, 0x200b8307, 0x82178336, 0x22028208, 0x82272622, 0x26222126, + 0x49053049, 0x514208b3, 0x820e8805, 0x08da4908, 0x36161722, 0x20081852, 0x05e24837, 0x33321624, 0x1782011e, 0x2d06db42, 0x3435012e, 0x16363736, + 0x33363237, 0x05823236, 0x013e3526, 0x14060527, 0x8205fe51, 0x221e8305, 0x5117013e, 0x362108e3, 0x06234a26, 0x33362622, 0x36214b82, 0x086c8216, + 0x9604072c, 0x01010201, 0x0d160c0a, 0x34193219, 0x08043468, 0x01010103, 0x1a030502, 0x14091a35, 0x04050509, 0x3c0e1e0e, 0x1d0f3c78, 0x0082020f, + 0x030f3308, 0x04030d03, 0x19090404, 0x0612090a, 0x03031c0b, 0x2c111201, 0x050a1412, 0x0a050903, 0x160f0b16, 0x03100909, 0x1b0d1701, 0x62301b35, + 0x16320930, 0x60831905, 0x05022508, 0x030c170a, 0x0f08051c, 0x1d3c1d08, 0x08264f27, 0x0301021e, 0x15040102, 0x0f220e12, 0x141f3f1f, 0x05141427, + 0xfe307982, 0x080b019d, 0x2a160817, 0x01611916, 0x101e0c0c, 0x01376182, 0x150a0b21, 0x03190e0d, 0x08040b06, 0x0a020214, 0x1831180e, 0x82021802, + 0xde0228aa, 0x0a101e0f, 0x82060716, 0x0d24082b, 0x01030201, 0x05020d02, 0x15050507, 0x122a0f09, 0x0f104217, 0x1a0d0c0b, 0x0c190e17, 0x2019331a, + 0x3c1d2140, 0x05255083, 0x130a050b, 0x3746820a, 0x0d060d03, 0x20120c19, 0x203f2110, 0x01015708, 0x07010102, 0x0c040107, 0x56821d82, 0x04111325, + 0x82010304, 0x0d2c2800, 0xf1152b15, 0x8406170a, 0x023c080d, 0x11260303, 0x030e0e22, 0x0d042801, 0x0b06061a, 0x01090405, 0x0a060702, 0x04130e19, + 0x03130601, 0x000f210e, 0x5a000500, 0x3d092400, 0xa4015a03, 0xd501c201, 0x0702e501, 0x1e010000, 0x2805ae4e, 0x36161716, 0x17361633, 0x0677641e, + 0x010e2725, 0x4b260607, 0x272105f7, 0x2414842e, 0x16151606, 0x09b36106, 0x82260621, 0x3e372317, 0xdc4b3701, 0x23062306, 0x32820626, 0x013e2323, + 0x543b8435, 0x302306b9, 0x64230607, 0x162008c3, 0x4f09da67, 0x2e220ce1, 0xf0642301, 0x06134209, 0x20057a42, 0x684b8433, 0x49420828, 0x82788605, + 0x0740427b, 0x0e212086, 0x20088203, 0x25908635, 0x32363336, 0x1a623637, 0x08606007, 0xea820887, 0x36321722, 0x2b05ed4f, 0x15163233, 0x1415011c, + 0x26343536, 0x08833287, 0x1a82ed82, 0x33241482, 0x3233013a, 0x3622fc82, 0x20843233, 0x82363221, 0x05cb4f2f, 0x16221a87, 0x494d3c35, 0x17062205, + 0x24268216, 0x16343534, 0x215f8233, 0x26860616, 0x4a4c3282, 0x17362106, 0x50861482, 0x3e833220, 0x2006a745, 0x05554316, 0x36343722, 0x3b820882, + 0x21050d5f, 0x764d0517, 0x06322105, 0x30862a89, 0x01352624, 0x7f843614, 0x36373623, 0x05cc4526, 0x36251522, 0x4d062867, 0x252506e3, 0x1e27012e, + 0x06c54601, 0x59461620, 0x0c7d4106, 0xaf087608, 0x01090e0c, 0x09052501, 0x09040326, 0x0c1b080a, 0x020f140e, 0x07080904, 0x19050603, 0x05190606, + 0x12090e07, 0x04020205, 0x02050202, 0x140a0403, 0x04030331, 0x03050301, 0x140f040b, 0x070f0613, 0x11091008, 0x02011226, 0x0d0e190d, 0x07040e1e, + 0x02070103, 0x05010807, 0x12090103, 0x09110808, 0x08090c02, 0x23110810, 0x01140511, 0x05020302, 0x1108050b, 0x3c4e8207, 0x130b0303, 0x0f101226, + 0x1427130f, 0x06173519, 0x0f08060d, 0x03120306, 0x03040702, 0x08058207, 0x0b060230, 0x03110906, 0x06060502, 0x20110618, 0x023b0510, 0x14081205, + 0x13081529, 0x13300f0b, 0x17234c23, 0x6131152d, 0x52522931, 0x5a112952, 0x9e820403, 0x152b0236, 0x50142814, 0x4e27509f, 0x0d1f0d27, 0x100f2013, + 0x0f081321, 0x06298682, 0x090f180b, 0x0c060911, 0x205c8206, 0x37628204, 0x090a030b, 0x03020205, 0x0a05051f, 0x02040405, 0x05011e02, 0x05011002, + 0x04222182, 0xe3821101, 0x0f010226, 0x070b0202, 0x01211382, 0x2b8b8302, 0x061a0107, 0x02070c06, 0x0f020103, 0x0626e082, 0x01020e02, 0x0b820303, + 0x05050228, 0x08011a07, 0x0f821e09, 0x07022108, 0x0309060d, 0x22100208, 0x386e3710, 0x041d391c, 0x150a040a, 0x010c0307, 0x0e030101, 0x050c050e, + 0x092c3682, 0xaefd020a, 0x5655562b, 0x203f202b, 0x27084382, 0x12040904, 0x7e3f1225, 0x1830183f, 0x07060d06, 0x557cfe01, 0x0b150b0f, 0x07050d0d, + 0x170a0b1b, 0xfd4e160a, 0x160707a3, 0x3008d182, 0x06080c0c, 0x290e080f, 0x075afe0b, 0x0601070e, 0x05020101, 0x110e1b0c, 0x23111125, 0x04181212, + 0x05030402, 0x23120f03, 0x1d381c12, 0x38121b03, 0x20258215, 0x06aa4704, 0x1d0c3708, 0x0104090b, 0x0c040602, 0x0208080a, 0x0211070e, 0x01010203, + 0x07040309, 0x0e2b0703, 0x12274d27, 0x0f071224, 0x01080a07, 0x121a0703, 0x5228121b, 0x02370628, 0x66441d06, 0x10073e07, 0x060e0707, 0x22110205, + 0x041f0511, 0x0a030203, 0x274e2805, 0x0b254a25, 0x03010101, 0x334d8301, 0x0e080605, 0x172e1707, 0x0a224423, 0x110a0912, 0x03260506, 0x01222982, + 0x98830902, 0x090b4308, 0x04081a05, 0x02080312, 0x09040401, 0x240e0912, 0x07160811, 0x08030205, 0x21030912, 0x0f1f110a, 0x0d244825, 0x100c0831, + 0x05090604, 0x11081203, 0x1d0e1222, 0x060f1d1d, 0x4f251b02, 0x274d2625, 0x6a82071b, 0x030b0128, 0x0b0c0c05, 0x7182040b, 0x05140326, 0x0202200b, + 0x0220c782, 0x04208282, 0x083c0882, 0x0b160b0a, 0x02030502, 0x03030213, 0x0302020d, 0x01090401, 0x0a0a0402, 0x0d010204, 0x01232782, 0x82060703, + 0x070e2d26, 0x08030107, 0x010e0406, 0x06030202, 0x02205683, 0x03822c82, 0x02070822, 0x03243082, 0x160d0202, 0x043d1583, 0x0a030818, 0x050d0604, + 0x0204130d, 0x1b0a020c, 0x060d270c, 0x1c92fe07, 0x0f0b0e02, 0x234f8312, 0x1d108823, 0x1b266a82, 0x02050809, 0x9f82460a, 0x264b2637, 0x08041806, + 0x0e030305, 0x080f0605, 0x0918130a, 0x0b0e0811, 0x08478202, 0x030b0821, 0x00050000, 0x0aa40062, 0x01da026a, 0x011e010b, 0x0150014a, 0x01000056, + 0x3e373632, 0x59313501, 0xa243053f, 0x22232105, 0x20063245, 0x052f4a27, 0x21050b44, 0x9a512622, 0x26272805, 0x012a2736, 0x47061615, 0x06240ad7, + 0x15161415, 0x26241782, 0x26220722, 0x23204482, 0x2108b94a, 0x0e820622, 0x1a513720, 0x23058d05, 0x17011e15, 0x14213582, 0x05cb4706, 0x83087d4a, + 0x010e2208, 0x05af4715, 0x8307bc45, 0x232f822c, 0x3637011e, 0x220cdd4a, 0x44013a37, 0x3e2006b7, 0x16201a82, 0x5a053748, 0x16240617, 0x32161736, + 0x33242082, 0x36333632, 0x82066859, 0x0cc9651a, 0x06264d83, 0x37162627, 0xc65a0605, 0x36372606, 0x013a1716, 0x20788217, 0x22f18225, 0x8227010e, + 0x260621ca, 0x5106a045, 0x08820873, 0x83363221, 0x3616226d, 0x08978233, 0x32251546, 0x27063316, 0x23012a23, 0x350a1636, 0x0d09130a, 0x09080302, + 0x1e0c060c, 0x070d0610, 0x02020309, 0x0d060708, 0x356d3608, 0x2d377038, 0x2d5a5a5a, 0x2a2d592d, 0x06102a54, 0x09240203, 0x03060603, 0x0802010e, + 0x2c293782, 0x2d172c58, 0x01040616, 0x0814820a, 0x0b08162b, 0x02020a19, 0x03050302, 0x05051009, 0x02020711, 0x010c050b, 0x2b2d582c, 0x2d162c58, + 0x060d0817, 0x15070c06, 0x2709152a, 0x08008201, 0x1109034c, 0x260f0f1e, 0x0308060b, 0x09050904, 0x532a1015, 0x0a01022a, 0x1b060a15, 0x06080803, + 0x080b170b, 0x0b1e0118, 0x14112010, 0x17131529, 0x080c0804, 0x05091209, 0x23100e0d, 0x0b160b0f, 0x0e081108, 0x110a0816, 0x0f1e0f10, 0x0e83180b, + 0x0f170f2b, 0x11152c14, 0x2c131125, 0x32658214, 0x2d2c5a2d, 0x2c162d58, 0x09140917, 0x2c0a1009, 0x83595959, 0x2e1836c6, 0x02110c18, 0x0b0e0b02, + 0x1b030621, 0x0a2ff904, 0x150a0d2c, 0x08d98208, 0x1234052a, 0x08061609, 0x7a060304, 0x274f9a4f, 0x2010274f, 0x0a0d0a10, 0x08061404, 0x27140812, + 0x284f2714, 0x0a264e26, 0x0a030a14, 0x012ebe82, 0x04050d05, 0x6af90304, 0x03010201, 0x11834201, 0x02014808, 0x0402034d, 0x081d0b02, 0x06030209, + 0x09150d08, 0x060f0703, 0x0708140a, 0x03040101, 0x0e010302, 0x060d0f0d, 0x05010f03, 0x06010509, 0x05050b05, 0x01080910, 0x0b010701, 0x07030103, + 0x19011e07, 0x06110205, 0x82040804, 0x08478202, 0x06020127, 0x04010605, 0x02010305, 0x2c562c0c, 0x0a172f17, 0x0e060436, 0x0c0f0607, 0x0a081407, + 0x100e0912, 0x08150904, 0x204c8204, 0x2d2b8202, 0x150d1d0f, 0x220e142a, 0x030d0f10, 0x43820605, 0x1705052d, 0x101e1308, 0x0b132513, 0x84040427, + 0x0a152bb2, 0x0303140b, 0x05020102, 0x79820203, 0x04250b82, 0x06040202, 0x331c8306, 0x01010304, 0x16050303, 0x051f0e0b, 0x080d0904, 0x0d910102, + 0x082c1282, 0x18081005, 0x0a080101, 0x02810b16, 0x0127e584, 0x02050b07, 0x83020201, 0x04012403, 0x848c0604, 0x82002015, 0x00033700, 0x0a40005d, + 0x0144032d, 0x014a0127, 0x01000075, 0x2627011e, 0x98431716, 0x26222305, 0x0e823e37, 0x70068847, 0x954305f7, 0x06222106, 0x49080d59, 0x9e54064a, + 0x5d11820a, 0x1e5509aa, 0x552a2008, 0xd7480621, 0x22062106, 0x24066759, 0x2a272622, 0x210b8201, 0xb84b3627, 0x2e232106, 0x06242984, 0x06141514, + 0x2406b054, 0x1415011c, 0x82808216, 0x25928205, 0x37033e37, 0x6c711636, 0x21238208, 0xa4843233, 0x830b1049, 0x33362320, 0x1d82013a, 0x2b483282, + 0x25088205, 0x37343637, 0x3e852636, 0x32143722, 0x35211182, 0x20268326, 0x05866033, 0x82013e21, 0x36332229, 0x82268216, 0x06764917, 0x27363422, + 0x21051655, 0x11832636, 0x030e0523, 0x82698207, 0x26062145, 0x34213f83, 0x83668226, 0x010e273f, 0x23013a07, 0xd0830605, 0x06222325, 0x86012e27, + 0x831e206a, 0x056b4c85, 0x42497982, 0x08ca8205, 0x250a07ce, 0x03030201, 0x2c090102, 0x0e1b0d0b, 0x0101110b, 0x04020401, 0x04050201, 0x0a0c3a06, + 0x28040106, 0x1d3a1e15, 0x083a743a, 0x08030520, 0x07190504, 0x0a061208, 0x0d061301, 0x03070308, 0x0c040103, 0x11020623, 0x08110605, 0x040a0c0c, + 0x0f02030c, 0x05080403, 0x190c1a0d, 0x65331932, 0x17341733, 0x0a0e1d13, 0x19120f15, 0x09100710, 0x1b0c170c, 0x44221b36, 0x0d1b0d22, 0x09041406, + 0x0d080807, 0x16351508, 0x14376e37, 0x02040a29, 0x03050705, 0x09050e05, 0x06880c17, 0xc2dcb204, 0x1b461e14, 0x0a090a1a, 0x11120f10, 0x21441516, + 0x06071b0c, 0x06090d01, 0x050d0604, 0x03060c05, 0x0c0a0809, 0x0b2b0905, 0x10122413, 0x11070d21, 0x012c5082, 0x04071f03, 0x03040301, 0x07090806, + 0x6608ce83, 0x06061e11, 0x0c080104, 0x32306231, 0x32636463, 0x0d142813, 0x010f0e1c, 0x0e200e11, 0x0501020c, 0x05050203, 0x28120f06, 0x052a0812, + 0x08050307, 0xb911f4f8, 0x0211b9d7, 0x06020107, 0x01030e02, 0x0f050201, 0x3e214120, 0x3e7d7d7d, 0x01050604, 0x98020201, 0x100f4109, 0x1c0c101f, + 0x03020204, 0x09080204, 0x82030208, 0x134a086d, 0x0b11080a, 0x0f1a210a, 0x2d060f1e, 0x04030304, 0x02820204, 0x02030402, 0x01040901, 0x1228130e, + 0x0b0a150a, 0x09100a13, 0x072e0202, 0x0703011c, 0x05050905, 0x07010104, 0x040e1d09, 0x02010309, 0x01060202, 0x060c0a04, 0xb182050b, 0x03081737, + 0x01030508, 0x040e0304, 0x0d230404, 0x0101180a, 0x0105081b, 0x2b918202, 0x09010101, 0x040d0403, 0x09030b04, 0x46083f82, 0x190a1704, 0x0520070b, + 0x0a0a0606, 0x190c0a13, 0x031f050c, 0x110f4007, 0x28060b24, 0x45390103, 0x0308053d, 0x173b1112, 0x1c17361b, 0x0d1d1c46, 0x25080b03, 0x0d200a04, + 0x12112010, 0x160a1123, 0x05140606, 0x82020409, 0x09053da6, 0x06170101, 0x0608060a, 0x0f07060c, 0x08220a07, 0x07042305, 0x010b0a33, 0x0c060601, + 0xa3837682, 0x01172308, 0x1d040505, 0x1327130b, 0x04071308, 0x1c09010e, 0x05020502, 0x0b1b0907, 0x9d09200a, 0x3d453b05, 0xf5820307, 0x4908d982, + 0x26140921, 0x02400714, 0x137a0107, 0x0e030104, 0x0a081608, 0x0708071a, 0x09180d09, 0x02020c08, 0x3607080d, 0x04010102, 0x061b0605, 0x00081b09, + 0x00630003, 0x03720772, 0x01fe000d, 0x00240110, 0x36340100, 0x37013e37, 0x594b012e, 0x200e840c, 0x05a44c07, 0x83342621, 0x22238220, 0x82373436, + 0x013e2b02, 0x013a3533, 0x37163233, 0x05823632, 0x84089958, 0x32178308, 0x33321617, 0x23170614, 0x17163215, 0x35173236, 0x46150616, 0x322905f2, + 0x011e1736, 0x07161415, 0x07f64714, 0x15011c22, 0x2409da64, 0x15230616, 0x44118223, 0x2323083a, 0x75272622, 0xf4470595, 0x2606230b, 0x02833435, + 0x012a2722, 0x2105b375, 0x69481423, 0x20388306, 0x082b6534, 0x82372621, 0x83152018, 0x8203201b, 0x06232518, 0x22060716, 0x2908d36f, 0x3f363435, + 0x07352501, 0x5744011c, 0x051e6506, 0x82350721, 0x83368369, 0x0e280803, 0x34331501, 0xa3013726, 0x0d05021a, 0x081d0607, 0x150c160b, 0x2710142d, + 0x08110810, 0x06090f09, 0x11020910, 0x01070403, 0x42080084, 0x04040902, 0x02010203, 0x974c0808, 0x1b361b4c, 0x03061007, 0x0a060205, 0xadae5705, + 0x633157ae, 0x0c170b32, 0x03020502, 0x06020206, 0x04010105, 0x03020402, 0x0109040e, 0x17234723, 0x1e06172f, 0x82020605, 0x14082d15, 0x180b1529, + 0x3004010b, 0x0e1e0f09, 0x06373d82, 0x0a250510, 0x05050803, 0x33060411, 0x081d0c0c, 0x05204221, 0x82020309, 0x0208372c, 0x08040c06, 0x330c110c, + 0x18010104, 0x1b0d1831, 0x050b050d, 0x2d83020a, 0x82050821, 0x01082b68, 0x0f153311, 0x0d050f20, 0x73830504, 0x2a232308, 0x01040123, 0x03040504, + 0x24060d05, 0x2b0d2449, 0x260b030b, 0xc8013f05, 0x10070361, 0x051a090f, 0x4a820c02, 0x42018321, 0x032d05ff, 0x01091804, 0x32027301, 0x0b150b03, + 0x36138205, 0x08040105, 0x0a080607, 0x05040706, 0x1004050e, 0x050b0702, 0x82060c05, 0x0d06380b, 0x06090806, 0x05050d07, 0x1006050f, 0x03010101, + 0x04030403, 0x820b140b, 0x820320a6, 0x13240803, 0x07050306, 0x0d070909, 0x030e0606, 0x030a0306, 0x04080301, 0x050b0503, 0x09100901, 0x0d070d08, + 0x06030a09, 0x0220d382, 0x49080082, 0x0d080c05, 0x0904041b, 0x060b0613, 0x01050c06, 0x05050702, 0x05040a05, 0x0303050a, 0x09080104, 0x04070304, + 0x0b030508, 0x55470303, 0x07090147, 0x04040901, 0x0b030903, 0x0a580705, 0x0101837c, 0x0c060f06, 0x040a0204, 0xc7820115, 0x01021223, 0x061e4704, + 0x04080226, 0x00080b06, 0x22080082, 0x00550002, 0x0306090c, 0x01b8017a, 0x010000d1, 0x1607011e, 0x22062326, 0x07012a07, 0x14150622, 0x83161716, + 0x14272305, 0x08820716, 0x82011c21, 0x22232211, 0x22058416, 0x55343506, 0x35250624, 0x3c352634, 0x05405f01, 0x07241482, 0x2e373426, 0x79500e83, + 0x2b058505, 0x27010e07, 0x34353626, 0x012a2306, 0x22058c5c, 0x82361617, 0x5505825c, 0x8d55067b, 0x556e8206, 0x06230575, 0x5b062627, 0x362007f7, + 0x37223b82, 0xd9502206, 0x6c302006, 0x538206ae, 0x16060722, 0x23250282, 0x06230622, 0x217a8226, 0x77823e37, 0xbe433620, 0x06262109, 0x74830b82, + 0x4d822220, 0x26823620, 0xbf825382, 0x22203884, 0x20075c43, 0x83238426, 0x21658205, 0x6c503617, 0x3a332d06, 0x36223301, 0x37343615, 0x36373236, + 0x33255c86, 0x16171632, 0x06a74a32, 0x82363221, 0x3215222c, 0x22748216, 0x82013e17, 0x3217240b, 0x5c163316, 0x33200927, 0x33222084, 0x08823236, + 0x86088d4b, 0x8298849b, 0x8237206e, 0x2153826e, 0xa8601636, 0x41172005, 0x1c240564, 0x06141501, 0xda82ad82, 0x62828683, 0x82263621, 0x34372283, + 0x05575026, 0x15212c82, 0x05414414, 0x3a333625, 0x60053303, 0xaf4b0783, 0x08be5c05, 0x08379c08, 0x15220bd9, 0x48125c06, 0x74394890, 0x0f02033a, + 0x02030303, 0x10030214, 0x13010105, 0x050c0a03, 0x1301071e, 0x07020201, 0x04040e02, 0x04090904, 0x02090204, 0x0d1b0a02, 0x0106130d, 0x26021701, + 0x6206264c, 0x06020101, 0x09010402, 0x1f020803, 0x2851280c, 0x0408220b, 0x02050309, 0x2513080c, 0x0a0c0206, 0x0e060f05, 0x02040505, 0x01030503, + 0x05040503, 0x07030306, 0x16040b03, 0x0404104b, 0x0607040d, 0x0d090a11, 0x03010105, 0x05070204, 0x11032e05, 0x080a0d49, 0x821e0d12, 0x0705261a, + 0x5f2b0603, 0x087e822f, 0x030402aa, 0x0b040e03, 0x0e0a0a1a, 0x01060609, 0x1d030302, 0x28092305, 0x6034284f, 0x0e1b0e34, 0x07030902, 0x06040e05, + 0x06080a09, 0x0d09070c, 0x05110204, 0x0d070304, 0x11080e22, 0x18060b02, 0x1807143a, 0x07120705, 0x030a3706, 0x09040105, 0x08110804, 0x050c190d, + 0x0e040308, 0x080c0801, 0x01091009, 0x0f080203, 0x070d0706, 0x0f0d1704, 0x24080f1d, 0x07210202, 0x04041306, 0x0e0b0508, 0x040b0506, 0x0b0d6009, + 0x040c0625, 0x0c170102, 0x05090d0c, 0x4a250601, 0x04190625, 0x0b070404, 0x04010101, 0x1e06010b, 0x06030408, 0x412ef982, 0x86874316, 0xa0f84386, + 0x35020402, 0xda82356b, 0x020c0334, 0x11040905, 0x16080d1c, 0x10211108, 0x3503b402, 0x35821101, 0x1d012108, 0x08030b04, 0x0c0b2008, 0x24100727, + 0x126a020f, 0x07204020, 0x01102b36, 0x0308020a, 0x08040603, 0x2b08aa82, 0x0a0d0406, 0x07418141, 0x0905060f, 0x082d0a0a, 0x02022f06, 0x0d030506, + 0x04030706, 0x02050203, 0x03070106, 0x0c020101, 0x02030a02, 0x032b0782, 0x01070309, 0x0a110906, 0x82070104, 0x20112c3f, 0x21422110, 0x09102010, + 0x82110812, 0x030421e4, 0x052d5382, 0x41071008, 0x10144084, 0x0a19010e, 0x2529820c, 0x07070201, 0x1582080f, 0x16072a08, 0x05140505, 0x02050a03, + 0x20101d07, 0x0d230d0e, 0x090b0a0b, 0x0d050509, 0x0308030a, 0x01030104, 0x01020506, 0x110a0c07, 0x2b5f8202, 0x48250505, 0x0202021e, 0x0a02030d, + 0x08321882, 0x0d0c2a07, 0x240d0c27, 0x0945120e, 0x0d070206, 0xa2840601, 0x0d061134, 0x10040504, 0x04050802, 0x04020702, 0x040c0204, 0x4e820720, + 0x050e142f, 0x020a0504, 0x02010702, 0x0d0a0601, 0x245c8202, 0x03030201, 0x3b618203, 0x0b05040b, 0x0a090205, 0x07060108, 0x0c0b0908, 0x05160d07, + 0x03220f02, 0x010b0b03, 0x0b2d4582, 0x09100804, 0x0e081108, 0x02040204, 0x2303820a, 0x0e03030b, 0x0124b483, 0x0904010b, 0x07291482, 0x08060109, + 0x041e0b0c, 0x085b8249, 0x0719092c, 0x0d080308, 0x0d0d0d1b, 0x060b070a, 0x000d180c, 0x00020000, 0x09bb005e, 0x00c602e8, 0x00c500ac, 0x013c0100, + 0x26012a35, 0x7e4f2322, 0x06262108, 0x4f096f60, 0xa2540d4b, 0x231d8205, 0x15011c15, 0x5705544f, 0x37230723, 0x8237013e, 0x33302314, 0xb5433532, + 0x078e5305, 0x3c441883, 0x051c5407, 0x36261725, 0x82263233, 0x14152117, 0xde4e0882, 0x57062005, 0x33200523, 0x23077d4b, 0x17323637, 0x8305dc60, + 0x3736258d, 0x05331632, 0x98558b82, 0x16142405, 0x44362233, 0x25080622, 0x09070616, 0xcac962e8, 0x723a62ca, 0x203a7273, 0x22092142, 0x14840806, + 0x143d863f, 0x1f0f102a, 0x0e1a0e0e, 0x0282180b, 0x0f0af808, 0x2d151023, 0x14241c16, 0x04090107, 0x16070222, 0x20172c11, 0x11040815, 0x355b2007, + 0x1e270101, 0x0e140a10, 0x1d2a6a2d, 0x1f0e2544, 0x0b1d0610, 0x1d0b180a, 0x2b121d3a, 0x06040212, 0x010b150b, 0x07110501, 0x61450205, 0x3172320f, + 0x050a130a, 0x170b0403, 0x109f020b, 0x52515229, 0x154b1f29, 0x0d060906, 0x1f15151b, 0x04040809, 0xf9101e0f, 0x0e260a16, 0x11113115, 0x1601170c, + 0x0b031604, 0x22150d1d, 0x06030408, 0x36164602, 0x03060112, 0x09080c1e, 0x07090b09, 0x1007070d, 0x02160507, 0x08051303, 0x0f07060d, 0x0a110402, + 0x03010703, 0x18070c07, 0x4e221931, 0x092f1418, 0x0a15100c, 0x512f0a1b, 0x02040218, 0x182e0e01, 0x1708160e, 0x21151d12, 0x0107040a, 0x05061701, + 0x01040401, 0x0705010a, 0x08010207, 0x09061b06, 0x030b0209, 0x0d010901, 0x820f0306, 0x010c2656, 0x070f1f0f, 0x082a8215, 0x0109072c, 0x04120edc, + 0x0b0b0807, 0x3113102e, 0x02040646, 0x130a1403, 0x00000007, 0x00650002, 0x03f60526, 0x017b015f, 0x010000b4, 0x3645013e, 0x14152605, 0x033a3306, + 0x05486333, 0x35263623, 0x060a513e, 0x03421d82, 0x17302906, 0x36143516, 0x17061617, 0x2b056b56, 0x32231626, 0x16261736, 0x15011c35, 0x2705b945, + 0x22232614, 0x06010f26, 0x232c4b82, 0x0607010e, 0x2614010f, 0x27062627, 0x4607547f, 0x142106eb, 0x05135222, 0x2109fa46, 0xde4d3214, 0x068e5c08, + 0x07161422, 0x2d05ea6e, 0x2a23012a, 0x36262701, 0x35013c35, 0x5f82010e, 0x26343526, 0x013d3435, 0x23281784, 0x26151622, 0x06222722, 0xd7576e82, + 0x0bcd4209, 0x4e320621, 0x4d830553, 0x27262224, 0x8c84012e, 0x2a272624, 0x9b833501, 0x7b7f3420, 0x4d372008, 0x534e05e3, 0x221a820a, 0x5a363735, + 0x3b820818, 0x06343522, 0x60478082, 0x07f94708, 0xe2469b83, 0x36352506, 0x33363237, 0x273c4487, 0x26173616, 0x011e3336, 0x17161415, 0x3a333616, + 0x023a3301, 0x31013b16, 0x03372634, 0x26218a82, 0x58db8206, 0xff820565, 0x54825785, 0xea842720, 0x820e0721, 0x82062036, 0x16322339, 0x56832633, + 0x36341522, 0x35362282, 0x1c11fd02, 0x050d0511, 0x01010204, 0x5b5a5a2d, 0x264c252d, 0x0c820305, 0x02010231, 0x09030d02, 0x07010712, 0x04020108, + 0x82020b04, 0x03013404, 0x09040c01, 0x09020815, 0x07090101, 0x01051807, 0x83020702, 0x03033800, 0x4c26050e, 0x2f5e2f26, 0x0b020503, 0x0c092e06, + 0x0d04090f, 0x8204020c, 0x0903231c, 0x24840607, 0x13012708, 0x1b371b02, 0x090b160c, 0x03030305, 0x04090505, 0x1d0f0326, 0x1326130f, 0x29140209, + 0x02070514, 0x02050701, 0x7e820504, 0x05020227, 0x02040401, 0x3f608201, 0x03030103, 0x09040203, 0x09021306, 0x27150613, 0x13201015, 0x07060b05, + 0x02021016, 0x06020307, 0x0121ab82, 0x34ad8201, 0x110b0301, 0x07160707, 0x01030502, 0x03021008, 0x01060201, 0x209d8201, 0x27508205, 0x10080719, + 0x04070606, 0x0320b782, 0x04221282, 0xcd820304, 0x09293883, 0x02020401, 0x07060c06, 0x2571821b, 0x0a0b0102, 0x6f821105, 0x06153208, 0x2f152a15, + 0x2f5e5d5e, 0x45020101, 0x06080504, 0x180c0715, 0x0813020c, 0x01011203, 0x140e0810, 0x090e020b, 0x07030d02, 0x32090703, 0x0107393e, 0x2a738203, + 0x04010101, 0x12094403, 0x8207040b, 0x02072473, 0x83030112, 0x020123bf, 0x07820f02, 0x02020824, 0xd5820403, 0x01040332, 0x03050108, 0x020b0210, + 0x04020402, 0x0103030a, 0x05329182, 0x07100702, 0x08030704, 0x08040301, 0x0c030107, 0x1e820901, 0x4b090421, 0x01250532, 0x0f080a01, 0x2d028207, + 0x04091e09, 0x130a080c, 0x060d0609, 0xa9820602, 0x07180830, 0x0305090a, 0x200e0809, 0x2f5e2f0e, 0xd4821103, 0x1f07053b, 0x39733908, 0x05030d03, + 0x010b1a08, 0x08130c0c, 0x01200101, 0x0606020b, 0x38658205, 0x03050605, 0x0d08030a, 0x02080308, 0x09050a05, 0x020c0306, 0x0205180a, 0x203a8206, + 0x31998202, 0x07010901, 0x05090404, 0x07101b12, 0x0402080e, 0x89820301, 0x0b030936, 0x1d110f22, 0x0306040d, 0x09010d02, 0x08070a0d, 0x07060602, + 0x0426be82, 0x0805040a, 0xf2630808, 0x0a013105, 0x04090202, 0x0f081506, 0x150a0f1e, 0x02090407, 0x01333d82, 0x03020102, 0x03020601, 0x04070402, + 0x01090f03, 0x820b0101, 0x03053204, 0x0104010f, 0x05120701, 0x1408a1fe, 0x0c010204, 0x38ff8215, 0x03090904, 0x030b0a04, 0x1103030b, 0x01030103, + 0x03071b02, 0x0c050411, 0x2b608205, 0x0e040505, 0x04050401, 0x00040604, 0x02300082, 0x23005600, 0x5b03cb04, 0x8d000d00, 0x23010000, 0x26061372, + 0x3e371632, 0x43172501, 0x232507b7, 0x14152622, 0x052e5616, 0x012e0727, 0x2b010e35, 0x07445601, 0x26141722, 0x5d057a6b, 0x79430876, 0x26362406, + 0x4b362627, 0x37210585, 0x06d3441e, 0x36011f2e, 0x36323316, 0x37012e17, 0x17373634, 0x8208d455, 0x25228512, 0x1e173616, 0x0b821501, 0x17163626, + 0x08545902, 0xf3080082, 0x07112f15, 0x0853020f, 0x05060f03, 0x240e1335, 0x028a0c10, 0x1d3c1d13, 0x051d391e, 0x09120805, 0x060c1175, 0x0d07100e, + 0x091e070a, 0x17080f08, 0x2412172e, 0x07341512, 0x07071309, 0x1e0c070d, 0x0d2e020b, 0x0602040b, 0x0c0e2206, 0x200e082f, 0x22422110, 0x24472206, + 0x01204221, 0x0a0a0101, 0x040d0414, 0x08161c18, 0x10080815, 0x152c1509, 0x090a130c, 0x03040817, 0x0d122215, 0x3e020d10, 0x08300808, 0x070f0109, + 0x2c04b83c, 0x0f162c57, 0x020d0405, 0x02410b0e, 0x04060205, 0x0e0f060b, 0x3b1c0d28, 0x365f351e, 0x01010710, 0x0a050102, 0x050a0305, 0x1c190e05, + 0x371c1c45, 0x3162321c, 0x0f121e1b, 0x30141134, 0x0b1b1213, 0x060a0202, 0x01040106, 0x02090e05, 0x05030801, 0x02060404, 0x011a0504, 0x03080602, + 0x01070108, 0x03040c01, 0x01030709, 0x29081082, 0x090c0603, 0x00050203, 0x59000300, 0x8e042500, 0xce005903, 0x1e01d400, 0x34010000, 0x06262736, + 0x23263637, 0x22232606, 0x99452326, 0x06223408, 0x23013c35, 0x3635010e, 0x022a2322, 0x011c2326, 0x4f222615, 0x17250883, 0x06070616, 0x25028214, + 0x17321617, 0x64461416, 0x82148205, 0x05a94502, 0x4f141721, 0x0e250aad, 0x010e0701, 0x82028215, 0x21028244, 0xc1533614, 0x08b95f05, 0x36323325, + 0x58163233, 0xdb570556, 0x013e240c, 0x68362635, 0x172008c0, 0xae822383, 0x29823620, 0x5005c85f, 0xc082088c, 0x372c1482, 0x17163601, 0x06012622, + 0x06142726, 0x27058c4d, 0x27360607, 0x2627012e, 0x48833382, 0x1620b784, 0x37217885, 0x254b8232, 0x27303506, 0x21882326, 0x6d163621, 0x8e080558, + 0x17011c15, 0x0407011c, 0x0504038b, 0x24030209, 0x162c1608, 0x033b763b, 0x04170303, 0x0a172f18, 0x0c030611, 0x310a0901, 0x31626262, 0x14081108, + 0x060e0505, 0x01010604, 0x01050704, 0x05010102, 0x07020304, 0x23120713, 0x0107060c, 0x030b0901, 0x0b010a02, 0x03060402, 0x03070e04, 0x02030204, + 0x01060602, 0x050d3a05, 0x0f060903, 0x0d240c06, 0x0a19341a, 0x140a0a0e, 0x1712060a, 0x07080a03, 0x02010404, 0x0b040208, 0x020a0404, 0x82010702, + 0x07062b54, 0x18397139, 0x12031831, 0x5d820804, 0x060b0b36, 0x1c0e0923, 0x1c371c0e, 0x03024209, 0xfc020103, 0x01050394, 0x19395c82, 0x08070c01, + 0x1224120e, 0x10204021, 0x0a010101, 0x120d0101, 0x06160304, 0x089f820a, 0x08071228, 0x15090c12, 0x0404060a, 0x05060f02, 0x07120901, 0x0508010a, + 0x0e162d16, 0x0f040a17, 0x25030201, 0x05031204, 0x0a820a04, 0x0601012f, 0x02040619, 0x0b040c02, 0x0a050101, 0x08408301, 0x0b110c55, 0x090a150a, + 0x050a0a17, 0x06190405, 0x06071107, 0x02040103, 0x09030404, 0x0c08101c, 0x050c070a, 0x03051705, 0x18030310, 0x07110603, 0x050d1b0d, 0x1007060f, + 0x11261007, 0x05040405, 0x170b0508, 0x070f190b, 0x02030e03, 0x08070302, 0x06060301, 0x82030603, 0x040736e7, 0x080f340c, 0x0f090918, 0x0f1b0f08, + 0x0a0d190d, 0x16090a18, 0x3ba28209, 0x13080501, 0x05300205, 0x10091209, 0x04060b10, 0x36190c05, 0x1a351a19, 0x020119fd, 0x8e25de82, 0x0e010208, + 0x220a8202, 0x820b0c13, 0x0b123502, 0x05070c0a, 0x2e030209, 0x0b110f08, 0x04060c0b, 0x02120101, 0x032ed782, 0x080d0502, 0x060e200d, 0x0605010e, + 0x72820101, 0x12030828, 0x10081123, 0x00820008, 0x61000428, 0x9e052600, 0x48825a03, 0x18010b29, 0x00002d01, 0x55063401, 0x272605f7, 0x34352636, + 0xfe592336, 0x012e2405, 0x4b062623, 0x06210766, 0x310b8207, 0x26272622, 0x07300706, 0x010e2306, 0x17140607, 0xd15a012a, 0x5f062009, 0x505a05b6, + 0x21488209, 0x2d480637, 0x05a84407, 0x33361627, 0x32373632, 0x06d85616, 0xc2601620, 0x14152206, 0x49028216, 0x0585059f, 0x33210e85, 0x234d8432, + 0x26271636, 0x2005d942, 0x062b4534, 0x56012e21, 0xba5005a3, 0x05974f05, 0x34270b83, 0x32362736, 0x82013a33, 0x1c152638, 0x06141501, 0x22808207, + 0x8237011e, 0x013c21d5, 0x82052049, 0x1617275f, 0x2f343536, 0x22603e01, 0x83162005, 0x4b05201d, 0x162405bb, 0x012e0514, 0x82067445, 0x823720eb, + 0x830e20e5, 0x216d82e2, 0x8b833635, 0x16076008, 0x19980506, 0x084f0d07, 0x03030603, 0x050c0108, 0x1f0e090d, 0x0f0c0b0b, 0x480d1b0c, 0x48919091, + 0x13316231, 0x04050816, 0x06050605, 0x03070d0c, 0x05010102, 0x0e050301, 0x03090d1a, 0x03180507, 0x01010504, 0x191f0401, 0x08050916, 0x080f0305, + 0x040a0106, 0x12081307, 0x24081225, 0x82040308, 0x10062f29, 0x0a061020, 0x04020404, 0x07020102, 0x2f820e0d, 0x0802023b, 0x0409040c, 0x0a070501, + 0x0f130606, 0x0b0a1309, 0x33090912, 0x04040306, 0x25258201, 0x02030101, 0x02830403, 0x0f042208, 0x020c0707, 0x172f1709, 0x0414301a, 0x04080304, + 0x10244824, 0x0302010d, 0x3c0d2606, 0x0a040406, 0x36398207, 0x09041102, 0x0202020a, 0x20110114, 0x051b0910, 0xd9fa0606, 0x83640203, 0x82042068, + 0x05330829, 0x7c04020f, 0x05030303, 0x020c0a12, 0x01160306, 0x1f070932, 0x02070204, 0x06020bc3, 0x0104010b, 0x06081008, 0x051a0c0d, 0x09080507, + 0x11020111, 0x82050410, 0x07260836, 0x03050408, 0x0d060305, 0x08010706, 0x07070807, 0x3b060c06, 0x1d183b77, 0x160b1416, 0x081c080a, 0x05042b08, + 0xd7820213, 0x09020425, 0x83050202, 0x022408b5, 0x0a03040a, 0x052f0301, 0x0f0d1c0c, 0x1f0e101d, 0x0215060e, 0x200d0503, 0x10071e38, 0x070d0807, + 0x0d0a240d, 0x02268382, 0x060d0201, 0x545e0711, 0x06033105, 0x070f0604, 0x180f1c0f, 0x3b1c1842, 0x0f1d101e, 0x2d083482, 0x20070201, 0x07060c09, + 0x0101080f, 0x0f1d0f10, 0x201e3b1e, 0x15050c47, 0x0c230c12, 0x0b3b763c, 0x10070409, 0x02140412, 0x02090e07, 0xb0820707, 0x2a090934, 0x13092b0a, + 0x03080309, 0x04671f0a, 0x07040409, 0x97820304, 0x04110a2a, 0x0108040c, 0x21030608, 0x033d1a82, 0x0008060d, 0x00040000, 0x073e004f, 0x014303d5, + 0x01150108, 0x002b0128, 0x013e0100, 0x05274e27, 0x33033a22, 0x2a09de42, 0x011e1716, 0x15061415, 0x78270616, 0x162e0531, 0x06141706, 0x27012a23, + 0x2627012e, 0x1a821506, 0x5307ed42, 0x0e210606, 0x09074801, 0x46342621, 0x35220519, 0x0882012e, 0x34210b86, 0x52388226, 0x5b4609e5, 0x20538205, + 0x07594c22, 0x34373025, 0x82363427, 0x06232124, 0x68053b48, 0x0c4c09b3, 0x227b8205, 0x82062223, 0x0607221d, 0x078b5326, 0xcf4c0620, 0x26332105, + 0x9f829c83, 0x16222322, 0x8305ce46, 0x22062269, 0x05114307, 0x34220582, 0xd7683316, 0x3a372507, 0x36323701, 0x34294183, 0x16363726, 0x37363435, + 0x21d68201, 0xca82010e, 0x08821720, 0x832e3721, 0x140722cb, 0x05bc5a16, 0x58087c83, 0x03162601, 0x01020294, 0x2d151518, 0x8b452d5b, 0x0b468b8b, + 0x09090744, 0x0f320908, 0x0b132c14, 0x02010103, 0x18301811, 0x020b150b, 0x11030101, 0x08080a0f, 0x32030910, 0x050e0702, 0x05030905, 0x230d1916, + 0x0915090f, 0x0f051907, 0x09030508, 0x02060103, 0x03020302, 0x3c2d8204, 0x1c150e02, 0x0e09161b, 0x0f170d0a, 0x20193c22, 0x0405030d, 0x3f050103, + 0x1c381c0d, 0x2b008201, 0x0e041002, 0x01040514, 0x07010903, 0x01232e82, 0x82030b04, 0x04012fdc, 0x060e0304, 0x17336633, 0x130a133e, 0x50820616, + 0x23830120, 0x3e038608, 0x773c3d7b, 0x0704103b, 0x02060302, 0x04020601, 0x010d0f14, 0x4822471f, 0x55294890, 0x0d1b0d2a, 0x06060107, 0x04069709, + 0x100dd601, 0x061d0502, 0x0314240e, 0x117a0305, 0x0c13182d, 0x05070801, 0x110a0907, 0x0b141008, 0x02011cfe, 0x04023503, 0x06250305, 0x1229110d, + 0x02040a13, 0x0f0b0701, 0x070b0f36, 0x18301901, 0x11030a03, 0x1e0f0e08, 0x0b03060f, 0x12112211, 0x23101121, 0x10200f0f, 0x080d6315, 0x82a88305, + 0x062c08ae, 0x11090d0a, 0x04080309, 0x07050506, 0x20100714, 0x08110711, 0x12081008, 0x25131221, 0x0a300604, 0x07050e05, 0x0104020b, 0x46843b18, + 0x04282982, 0x0a030e09, 0x01070604, 0x4283b882, 0x250f0f37, 0x1e432110, 0x04040904, 0x10090408, 0x12211108, 0x05090e0a, 0x261f821a, 0x0812050a, + 0x82102011, 0x0608255b, 0x04010106, 0x67083382, 0x2e150a1c, 0x1f3f2016, 0x10060e07, 0x366c3602, 0x061f3e1f, 0x0705060c, 0x01010105, 0x11080703, + 0x0b2c0d09, 0x0a081015, 0x7afe0803, 0x0412210d, 0x120e051f, 0x02050302, 0x04171135, 0x0e140403, 0x09070d1d, 0x04070102, 0xfe0e190a, 0x00060592, + 0x00600002, 0x02db0aa5, 0x012a01da, 0x0100003d, 0x26273626, 0x34222306, 0x2605c842, 0x23012e15, 0x51171614, 0x232607c0, 0x2623012a, 0x14822706, + 0x26320582, 0x22060706, 0x23262223, 0x30370622, 0x2e172227, 0x09820701, 0x23223628, 0x22073626, 0x97491726, 0x0611430a, 0x82010e21, 0x06232108, + 0x210a2343, 0x3c82010e, 0x832a2721, 0x204b8617, 0x464e8306, 0x0f49050b, 0x49058505, 0x0e860e7f, 0x89163621, 0x0e1a5217, 0x0dc04c18, 0x86053e49, + 0x3632272c, 0x33321627, 0x22433632, 0x255f8505, 0x37361617, 0x0b43033e, 0x16362409, 0x56363427, 0x3e22062d, 0x2f823301, 0x27012e30, 0x34353632, + 0x15172726, 0x05011f26, 0xf85d1626, 0x05104405, 0x12823720, 0xd40a8608, 0x0a110c05, 0x03070a16, 0x0e0a1c06, 0x0a140a0b, 0xaa550101, 0x2a55aaaa, + 0x29152953, 0x0b170b15, 0x05070f07, 0x11050507, 0x0f200b04, 0x0b132814, 0x0f010b16, 0x05070702, 0x07173017, 0x1002014f, 0x0a020703, 0x03042108, + 0x0b1b0304, 0x08112010, 0x120a0810, 0x142a1509, 0x090a120a, 0x14060a11, 0x071e0402, 0x142c5a2c, 0x2d161428, 0x12241316, 0x02050b06, 0x0c060103, + 0x0a120906, 0x15070c07, 0x05040a1f, 0x08008201, 0x02010384, 0x02020401, 0x27090801, 0x02130510, 0x13071802, 0x13091222, 0x0b130a09, 0x050e1e0f, + 0x0c08060c, 0x07100807, 0x160a150a, 0x1a10172c, 0x08010306, 0x0809160b, 0x10090811, 0x05040d07, 0x02020a02, 0x1b0c0404, 0x1122100f, 0x140b0e14, + 0x190e1b50, 0x060a060e, 0x0e011201, 0x31180f20, 0x162c1619, 0x08060f07, 0x210f0a10, 0x182f1711, 0x5c5c5c2e, 0x366b352f, 0x0c0c170c, 0x1f0a0b1b, + 0x04040101, 0xec820708, 0x0e1a0e25, 0x83387138, 0x010a2d90, 0x03050103, 0x035ff902, 0x0f05092f, 0x02339a82, 0x080a2f05, 0x0102060c, 0x0a8e0201, + 0x02030415, 0x820a0411, 0x0f0a230c, 0xd2820301, 0x2e820120, 0x01070124, 0xd94e0303, 0x01022305, 0x12820402, 0x01070524, 0x0282010c, 0x100e2108, + 0x050e0806, 0x04030a03, 0x10090407, 0x02040409, 0x04010703, 0x01060806, 0x01010605, 0x04010107, 0x3f060041, 0x0a050102, 0x0a110914, 0x170a1309, + 0x2b16172e, 0x102d1116, 0x01030610, 0x05090603, 0x0a110603, 0x042d3f82, 0x0f06040b, 0x03080309, 0x02020604, 0x05746209, 0x19060829, 0x0109060d, + 0x82050c02, 0x08022459, 0x82230905, 0x0506360e, 0x0b0a0406, 0x01050304, 0x1a0f1d01, 0x17091005, 0x030c0309, 0x05d3470a, 0x10090622, 0x01275282, + 0x06030102, 0x82070a0d, 0x830520f0, 0x05032ac6, 0x0915050d, 0x0d070818, 0x20da8203, 0x82c48203, 0x09320890, 0x01010810, 0x9f05050a, 0x0505020b, + 0x030c0413, 0x031d0304, 0x00040408, 0x00620005, 0x03df073f, 0x001e0048, 0x005a003c, 0x005e0173, 0x16060100, 0xfc481c17, 0x15362305, 0x9f420614, + 0x1c4a1805, 0x6f052009, 0xf660052e, 0x2830820b, 0x16171614, 0x013e3736, 0x09b37e01, 0x85272621, 0x08fd6345, 0x37363224, 0x5183012a, 0x07163234, + 0x1e15010e, 0x32161701, 0x35013c35, 0x05273634, 0x0653011e, 0x26222509, 0x07062223, 0x06201e83, 0x07222782, 0x5161011c, 0x05214705, 0x06220723, + 0x08f75215, 0x8f602682, 0x08885205, 0x27062622, 0x5507414f, 0x515305dd, 0x08184a05, 0x20050a56, 0x24bd8223, 0x2223032a, 0x227e8236, 0x82263427, + 0x7a332023, 0x32210565, 0x25c38216, 0x33033a33, 0x025e2632, 0x013e2309, 0xb7821e17, 0x1420b484, 0x820ada69, 0x823e20cf, 0x820620bd, 0x25c3823e, + 0x17363237, 0x994a1416, 0x05e24308, 0x8405664a, 0x0193085c, 0x085e0533, 0x07010101, 0x0e02070f, 0x1a130301, 0x0d121a17, 0x070b1d09, 0x23100e08, + 0x0df4fe0c, 0x162b1611, 0x030b150b, 0x0e06040b, 0x040f0604, 0x0c010406, 0x19281810, 0x2602541b, 0x0c041706, 0x351a0d19, 0x274f271b, 0x060e0601, + 0x201e3c1e, 0x150a2142, 0x2c01090b, 0x0601080a, 0x03020a05, 0x01020108, 0x0c050d01, 0x060d2c01, 0x0e1f0d16, 0x05162a15, 0x0203050a, 0x01080202, + 0x03031007, 0x04020204, 0x0d030302, 0x052e1109, 0x02050103, 0x8206083c, 0x03012f87, 0x40191c1f, 0x0e1a0d20, 0x0a071006, 0x18820110, 0x03060322, + 0x56080582, 0x0b103207, 0x1105060a, 0x3d722f07, 0x0c254c25, 0x010b0c18, 0x0a140a07, 0x04183118, 0x21030409, 0x0c110501, 0x2f0f1d0f, 0x2f5e5e5e, + 0x02010120, 0x0c0e0102, 0x340f1f0f, 0x34686869, 0x1d173117, 0x5a2d1e37, 0x052d5a5a, 0x0f080303, 0x0b0a0407, 0x2004030c, 0x82010409, 0x02053100, + 0x101e0f04, 0x0d356a35, 0x12050d1a, 0x050e0b05, 0x0a23b882, 0x82180609, 0x082d821b, 0x09080b2e, 0x08120906, 0x05021b0d, 0x1b0c190c, 0x60011b34, + 0x010f240c, 0x0302010e, 0x15060112, 0x192c0a08, 0x0a0e1210, 0x06020207, 0x2a0e230e, 0x4e08df82, 0x0c060411, 0x08180806, 0x120b2013, 0x2e0a0a0b, + 0x05094001, 0x1f030206, 0x050b1b04, 0x07070106, 0x0c070c07, 0x03050b17, 0x0b0a150b, 0x0b790733, 0x02030547, 0x08020607, 0x16080b13, 0x13261308, + 0x09081508, 0x12160402, 0x020b1225, 0x82051701, 0x412324ea, 0x82151416, 0x01023bd2, 0x080c0303, 0x190d0710, 0x060f060d, 0x05010311, 0x050d060a, + 0x02024224, 0x1e820303, 0x0b0e0123, 0x3acd8208, 0x13090308, 0x03050109, 0x59150902, 0x254b2614, 0x1229532a, 0x05040306, 0x82062e04, 0x0b75085d, + 0x1b05050f, 0x14150e0b, 0x04091408, 0x04020409, 0x0e150404, 0x0d060603, 0x0304050a, 0x1007040c, 0x0a0a0401, 0x0f0a0a14, 0x01060c0a, 0x0a130906, + 0x18141c0d, 0x12041831, 0x00080000, 0x0a5a004a, 0x002603d5, 0x010c0006, 0x02fa01e7, 0x021f020d, 0x002e0228, 0x27220100, 0x16313031, 0x23062237, + 0x06253632, 0x26222326, 0x07012e07, 0x36070622, 0x06222306, 0x34118227, 0x0627012a, 0x013c0716, 0x35010e33, 0x22330634, 0x26162726, 0x26208333, + 0x012e1722, 0x82063223, 0x2617253b, 0x06222336, 0x07211d82, 0x26148334, 0x35063227, 0x8434012b, 0x010e2110, 0x21051147, 0x4f821615, 0x2005bc4d, + 0x05d14d06, 0x83343521, 0x2a072234, 0x05e64d01, 0x64821520, 0x47220621, 0x1621066e, 0x09f16d26, 0x27013e25, 0x82230626, 0x0a91436a, 0x35822320, + 0x2e209d82, 0x36201a82, 0x062cb283, 0x06141516, 0x27061627, 0x06151632, 0x2c063a4a, 0x35263427, 0x32332634, 0x36160736, 0x05705717, 0x16173027, + 0x37163435, 0x20e68236, 0x06214706, 0x82013a21, 0x16172221, 0x09e74736, 0x07260624, 0xed4d3606, 0x05c86d05, 0x16363722, 0xe0820e82, 0x08823282, + 0x16363322, 0x35844e82, 0x38820620, 0x36373322, 0x26209f83, 0x2005bf43, 0x232c8426, 0x011e1716, 0x33216882, 0x060a6e32, 0x36261722, 0x0e820282, + 0x7d821782, 0x74833320, 0x36261a82, 0x37013e37, 0x4a823236, 0x13581a83, 0x08df7e09, 0x74822220, 0x16060722, 0x2006f843, 0x875c8232, 0x8426205f, + 0x05134583, 0x07163222, 0x14203b82, 0x32202684, 0x1629f082, 0x17011e37, 0x1635013c, 0x26688436, 0x16141736, 0x82340507, 0x072622f3, 0x20b18214, + 0x23158206, 0x35362637, 0xf4821282, 0x36061722, 0x16200583, 0x35298b83, 0x15062613, 0x2e232622, 0x29748201, 0x33163207, 0x22053634, 0x65820726, + 0x05013c2b, 0x32072322, 0x01a40636, 0x05aa5c01, 0x04012f08, 0x123a0720, 0x08019a13, 0x070a0b0a, 0x0e5b050c, 0x07225324, 0x6c36138e, 0x07030136, + 0x17120501, 0x0a040904, 0x0a021706, 0x1b050802, 0x07820805, 0x0106163b, 0x020b0813, 0x110c010c, 0x0a091b05, 0x22010c04, 0x15312425, 0x05150d04, + 0x08568202, 0x03010828, 0x0502060a, 0x2e5b2e07, 0x0b030408, 0x1d050907, 0x120d1d3c, 0x05010103, 0x030f0202, 0x06030505, 0x6214040f, 0x2e82120f, + 0x040c3d08, 0x0a132214, 0x3c0e0d14, 0x16221517, 0x06132a1b, 0x090f060b, 0x1f3c0706, 0x151c391c, 0x0504144a, 0x0e0a0604, 0x0305230a, 0x02190e03, + 0x01010c09, 0x02021020, 0x09090803, 0x13120823, 0xd9081582, 0x05612121, 0x170e0c02, 0x03050626, 0x0a170709, 0x27224221, 0x42162652, 0x05130207, + 0x060c1609, 0x62140812, 0x156b0303, 0x0e040d07, 0x2d131536, 0x0401040b, 0x0e071505, 0x1d021109, 0x07080602, 0x080c230f, 0x0407050d, 0x07210a10, + 0x0f020303, 0x0302123e, 0x0d170b03, 0x092a612c, 0x05030303, 0x44230746, 0x370f061e, 0x110e0f0c, 0x050a180a, 0x02031005, 0x0e0b0309, 0x06050418, + 0x08031624, 0x0e1b0d0c, 0x17170a12, 0x34191522, 0x1e1e171a, 0x0f1b351a, 0x04040201, 0x57280f12, 0x0d1d0d27, 0x100d1d0f, 0x0219101f, 0x0f010304, + 0x253b763c, 0x06102549, 0x05030204, 0x090b2f06, 0x20010610, 0x1b050a05, 0x18254825, 0x1309182f, 0x09010912, 0x3467341c, 0x030b060d, 0x66820117, + 0x24501832, 0x0e111209, 0x02020341, 0x110511f6, 0x02061b0b, 0x13239d82, 0x8208190e, 0x7d2b0807, 0x0211192c, 0x1a122005, 0x0f120106, 0x02070c4c, + 0x0a3a0bab, 0x42010b15, 0x01030509, 0x03305e30, 0x1b0b4402, 0x0a160a04, 0x8401e9fe, 0x84a92000, 0x0d2e3305, 0x050f0505, 0x01060102, 0x08060716, + 0x0c010910, 0x18820518, 0x0d060228, 0x01020611, 0x03820401, 0x0104022d, 0x02020701, 0x060a0d07, 0x82010207, 0x0264086a, 0x17090306, 0x020a050e, + 0x050c0704, 0x0c05061a, 0x170e0b02, 0x12231105, 0x2b1b491e, 0x087e0f0a, 0x0b0d0101, 0x01010a03, 0x0302040b, 0x0a060d04, 0x17240b18, 0x12050604, + 0x20060b08, 0x1d0f1e36, 0x01031412, 0x040c020b, 0x0f10060c, 0x08071d15, 0x030c0208, 0x07030404, 0x19072205, 0x0c0a0102, 0x0a010103, 0x3729ad82, + 0x162e181b, 0x07051408, 0x352d820e, 0x18080e02, 0x09120a08, 0x1f100504, 0x020f1c22, 0x58111203, 0xa0830507, 0x091b053b, 0x1e0b0713, 0x020f050a, + 0x17191107, 0x0f041007, 0x030b034f, 0x02040310, 0x20b6830c, 0x08b38205, 0x02080245, 0x01110204, 0x21210708, 0x01160f05, 0x32010606, 0x03190309, + 0x05030705, 0x0e100801, 0x02021405, 0x08040f02, 0x0710010e, 0x12111109, 0x120b020a, 0x0b060606, 0x07010406, 0x1229110c, 0x11091209, 0x82080502, + 0x04510855, 0x01030308, 0x072a0f11, 0x040a070c, 0x06060407, 0x0d060e14, 0x08040e12, 0x071a1116, 0x0212120b, 0x05030404, 0x05020d03, 0x0514060c, + 0x01040f4a, 0x0f1f0f05, 0x0d06070e, 0x20470f21, 0x1e0c130c, 0x08500212, 0x0709310e, 0x10060901, 0x0a63010c, 0x3e628215, 0x1f050910, 0x24050108, + 0x01080241, 0x0101ba04, 0x03000000, 0x0d005300, 0x7503100a, 0x8202ee01, 0x000024b9, 0x52263601, 0x1e3006f8, 0x16342701, 0x35361617, 0x32333626, + 0x06161536, 0x332c0b82, 0x3233013a, 0x26343716, 0x33163637, 0x27054a4c, 0x16151634, 0x06363714, 0x83050145, 0x82142029, 0x063d532f, 0x79502f83, + 0x16322805, 0x35163435, 0x8335013c, 0x1532213b, 0x26055345, 0x1e173214, 0x83140701, 0x16172259, 0x2b148306, 0x2a23011e, 0x07302301, 0x36321506, + 0x07251282, 0x14152606, 0x23748316, 0x16343736, 0x8208cf72, 0x57168219, 0x07220521, 0x32833606, 0x2105094a, 0x31821406, 0x16060727, 0x23262207, + 0x266b822e, 0x26342736, 0x45342207, 0x17830561, 0x23160622, 0x02821a82, 0x2006d05c, 0x059f4926, 0x22204183, 0x20069d4d, 0x228f8717, 0x6e062223, + 0x484908ba, 0x45058205, 0x478208e8, 0x8308cf49, 0x22262208, 0x5c538407, 0x09510548, 0x012e2109, 0x8205d179, 0x22232523, 0x22262327, 0x82050441, + 0x8215208c, 0x012a24fb, 0x84262227, 0x83222032, 0x010e246e, 0x82062207, 0x4a352059, 0x3b82075c, 0xb8463520, 0x06222108, 0x20056354, 0x85538235, + 0x26342656, 0x17163637, 0x5f441832, 0x33012308, 0x324a1632, 0x51322007, 0x32240611, 0x36342734, 0x71823282, 0x37215982, 0x245f8234, 0x34060716, + 0x213b8237, 0x0c832613, 0x45141721, 0x262005e9, 0x362b3983, 0x26072726, 0x16141506, 0x82263433, 0x275608b2, 0x03093603, 0x04160204, 0x060e0e09, + 0x02100112, 0x0a010704, 0x01160309, 0x1b090302, 0x101f100b, 0x03010f02, 0x04130402, 0x0f0a150a, 0x01110102, 0x01030609, 0x02050d03, 0x20030a1c, + 0x31180a1b, 0x07100718, 0x3c0e080b, 0x62313c77, 0x15316263, 0x13031429, 0x1f820409, 0x02080133, 0x03050202, 0x04010104, 0x040c0204, 0x36010105, + 0x32558204, 0x02060c05, 0x02140301, 0x05050402, 0x4c55442e, 0x82020407, 0x10082875, 0x0f1e0e08, 0x82040903, 0x0b033217, 0x391c0b16, 0x07040d1c, + 0x1e112311, 0x0b051d3c, 0x08728205, 0x0404093f, 0x0e060909, 0x04020b06, 0x05030401, 0x05010a02, 0x02020908, 0x01070d02, 0x0d1a0d0b, 0x1d3d7b3d, + 0x1d0f1d3a, 0x042d090e, 0x02030f03, 0x0e070201, 0x1c361c07, 0x09142818, 0x01010108, 0x3f338202, 0x03090507, 0x01020401, 0x02030206, 0x07100603, + 0x04050703, 0x19030406, 0x0f1d0f06, 0x0e183016, 0x0c291f82, 0x030b0404, 0x04060804, 0x3f798201, 0x0912091e, 0x03050b09, 0x04020c0c, 0x0b0c060c, + 0x08390303, 0x21163017, 0x130c0d5b, 0x10300606, 0x01245682, 0x0a080605, 0x16230782, 0x820c170b, 0x010224a7, 0x8203052e, 0x060835ac, 0x0109050b, + 0x090b1a0a, 0x17040813, 0x0f030706, 0x23120820, 0x0b24dd82, 0x06081308, 0x05219c82, 0x224d8203, 0x82020203, 0x820520ef, 0x02073e12, 0x051b0101, + 0x3e1f3f1f, 0x39193f7c, 0x11191419, 0x02010406, 0x2c17050e, 0x14271417, 0x05fd460b, 0x0c053608, 0x20020904, 0x0a081003, 0x05030112, 0x0c2b0abf, + 0x1e010419, 0x070d0706, 0x0805090d, 0x0f01011a, 0x04088608, 0x020b1016, 0x03020902, 0x0a0f0848, 0x07040606, 0x286d8229, 0x03040509, 0x0a090106, + 0x23f88201, 0x03030110, 0x07260682, 0x01030402, 0x03820c04, 0x020d062f, 0x0b031a02, 0x3a050a15, 0x030d0302, 0x088a8201, 0x0c010120, 0x04080202, + 0x0d050306, 0x45060d1a, 0x09050103, 0x0a050505, 0x06030605, 0x1c0a0710, 0x4282050a, 0x13040f2e, 0x11010e13, 0x02010504, 0x010a0504, 0x01225582, + 0xfb820401, 0x2a010125, 0x821a0204, 0x01022244, 0x2605820d, 0x01080208, 0x82350705, 0x0a0a3355, 0x04091109, 0x03050101, 0x0601370d, 0x04080b09, + 0x36820602, 0x02040625, 0x82090103, 0x0d092429, 0x820b0d06, 0x04043c80, 0x070f0201, 0x152a1509, 0x07070b08, 0x2b150810, 0x09150915, 0x07090b06, + 0x82060205, 0x113908e8, 0x30130a39, 0x12201116, 0x10162e16, 0x01010109, 0x07140608, 0x09051105, 0x24140811, 0x041a1015, 0x110c110a, 0x240d0d6e, + 0x010e1212, 0x12090405, 0x03030909, 0x120a0d04, 0x3e2b8215, 0x03170101, 0x08020c07, 0x07010105, 0x0a0b0a08, 0x050b0c09, 0x25030302, 0x120a2106, + 0x84091827, 0x05122fc7, 0x23090d08, 0x2c162446, 0x18311916, 0x1f821405, 0x040d012c, 0x05030209, 0x03082404, 0xb5820704, 0x040a0524, 0x00820308, + 0x05060723, 0x23bd8207, 0x0a200704, 0xfe3c2d82, 0x2f080a6f, 0x02030a11, 0x0c0d0705, 0x11041109, 0x12031d0d, 0x050d040f, 0x00080e08, 0x04330082, + 0x3e005500, 0x42030f0c, 0x9d018a01, 0xb201a601, 0x4e010000, 0x032006e6, 0x68084864, 0x06200aa5, 0x2a085164, 0x23012a23, 0x34352636, 0x82262736, + 0x15142314, 0x0282011c, 0x17821483, 0x87362221, 0x07162517, 0x0e072606, 0x55076f45, 0x3225052e, 0x22060706, 0x076d4423, 0x4a05b544, 0x372205aa, + 0x38823436, 0x182e3521, 0x820c8045, 0x05455520, 0x42740882, 0x09d27e08, 0x14277782, 0x32363716, 0x61160637, 0x34200658, 0x44060b46, 0x17210894, + 0x06f95b16, 0x36323322, 0x33200b82, 0x5c05854f, 0x9770089c, 0x441a8207, 0x2621068d, 0x203b8536, 0x20b08335, 0x06594b02, 0x332a1285, 0x3316023a, + 0x3233013a, 0x76821706, 0x17061428, 0x06150622, 0x43843316, 0x05830720, 0x46831620, 0x82160621, 0x836a8417, 0x6d272049, 0x2e24055c, 0x013e2701, + 0x4f06ba56, 0x262005fc, 0x11829783, 0x3a163723, 0x25558401, 0x36333216, 0x1c823516, 0x010e0128, 0x07062223, 0xf34b2622, 0x36322306, 0x95822507, + 0x17011c25, 0x59172606, 0xdd0805b5, 0x0e331626, 0x080f0c01, 0x236e230d, 0x7979793c, 0x8686433c, 0x1e0f4386, 0x07020a0f, 0x13311210, 0x0709330d, + 0x200e0a17, 0x3970380e, 0x02040204, 0x0d0a3e06, 0x0d180d04, 0x08204221, 0x07030201, 0x0d100d37, 0x0d400605, 0x03010c09, 0x102c0604, 0x0d173014, + 0x01020e1c, 0x030e0201, 0x0b112312, 0x210e0d1c, 0x0f1f0f10, 0x0b0f1b0d, 0x0a03063f, 0x02040101, 0x3d1e0c12, 0x254a251e, 0x0a0b290d, 0x03010104, + 0x01090302, 0x040d200d, 0x0d060406, 0x13271306, 0x05031205, 0x1a110f03, 0x6a051a33, 0x0d050108, 0x3c070707, 0x0f083c79, 0x09040707, 0x05022905, + 0x05060619, 0x04070807, 0x0b160a0b, 0x01020c04, 0x05030c0c, 0x0c03030a, 0x040f0302, 0x09133a09, 0x17050a20, 0x02070401, 0x27820401, 0x0b03043e, + 0x36030602, 0x356b6c6b, 0x07031105, 0x1205050f, 0x0a0a0707, 0x7b7c7c3e, 0x3163323e, 0x2e089082, 0x04030c09, 0x0c010612, 0x04140113, 0x100d0106, + 0x22071127, 0x05060e02, 0x09082c04, 0x0b040507, 0x050c0608, 0x05040705, 0x02010d11, 0x82040203, 0x012608c0, 0x01020306, 0x6c6b6c36, 0x3e7c3e36, + 0x160b160b, 0x02aff50c, 0x0706051b, 0x031b0305, 0x07010302, 0x10090a2b, 0x53820202, 0x0a0b0531, 0x09014411, 0x050a3d03, 0x07680221, 0x820b0401, + 0x0a2808df, 0x0c0a0913, 0x05060605, 0x050a070a, 0x1d0f0907, 0x0511060e, 0x0b27050a, 0x04080f07, 0x06071107, 0x050b0513, 0x0a0c082f, 0x0b3cbb82, + 0x100c2c0c, 0x01010105, 0x01010205, 0x14050703, 0x07100909, 0x05050d07, 0x04080805, 0x0a322082, 0x07150805, 0x0504080e, 0x040a1404, 0x0705050b, + 0x2d820105, 0x0704042f, 0x170b0920, 0x284e280b, 0x12142813, 0x083f820b, 0x17031320, 0x06090b0a, 0x040c060b, 0x321a0302, 0x0306031a, 0x02020903, + 0x06180a04, 0x04061208, 0xd2820102, 0x07232808, 0x03070c06, 0x14020214, 0x060c0605, 0x0b081407, 0x11140b15, 0x01090407, 0x0d040901, 0x0e0e0d20, + 0x09100a0e, 0x82070f06, 0x2021084f, 0x0a140a04, 0x0809150a, 0x080d010d, 0x11041708, 0x0f0b0f28, 0x09050a12, 0x03020304, 0x0c081305, 0x085c820c, + 0x3d0a0121, 0x090a3a0c, 0x05060204, 0x0d0b0419, 0x09110707, 0x0402340b, 0x07040511, 0x0a0e0703, 0x820b140a, 0x130428eb, 0x15241407, 0x82112211, + 0x02013655, 0x09280908, 0x0e07fdfe, 0x04010207, 0x07021b03, 0x2f0b0104, 0x08da8209, 0x04061720, 0x0307070b, 0x05080506, 0x1516040f, 0x53000100, + 0x5408d400, 0x2001ab02, 0x2e010000, 0xef432701, 0x010e2605, 0x012b3027, 0x06227c06, 0x08820720, 0x22313023, 0x72421823, 0x8212830a, 0x562e2024, + 0x262005bf, 0x2605a674, 0x35262223, 0x84312322, 0x09624f17, 0x35012e24, 0xe2593436, 0x0e272108, 0x2207495a, 0x82070626, 0x0b13570b, 0x0714062a, + 0x22170622, 0x16143317, 0x22067849, 0x56373616, 0x1e2405dd, 0x36323301, 0x32204484, 0x69098a49, 0x35210a26, 0x821d8334, 0x6733201a, 0x16250652, + 0x36333117, 0x05464432, 0x83054e5d, 0x823e2049, 0x15162946, 0x32333616, 0x32161716, 0x32221183, 0x26843133, 0x30271189, 0x013e013b, 0x4a141617, + 0x6c44086d, 0x2e373c05, 0xe5072701, 0x33214320, 0x7b3e3367, 0x030b043e, 0x0d020101, 0x090a0803, 0x82080b09, 0x01012c08, 0x04040603, 0x0b0c0701, + 0x82031006, 0x044b081d, 0x03020507, 0x06070207, 0x01030a07, 0x06010208, 0x01040501, 0x050a0101, 0x0d090203, 0x0f090d1b, 0x060a050a, 0x04010205, + 0x02040904, 0x160a0402, 0x1e19060b, 0x43132511, 0x66334285, 0x1c3a1d32, 0x100b120c, 0x130b0e2a, 0x82030204, 0x010b245b, 0x83030109, 0x01250808, + 0x171e1d06, 0x14091027, 0x1123100b, 0x15438643, 0x1d0f152a, 0x1120100f, 0x08091109, 0x0316060d, 0x0c170b10, 0x39648205, 0x01010911, 0x10080804, + 0x06080608, 0x090e1b0e, 0x08060401, 0x0d030101, 0x98820503, 0x06060a2b, 0x04060107, 0x02090601, 0x23108201, 0x090c0605, 0x03210a82, 0x201f8207, + 0x22d78201, 0x8207020e, 0x03082310, 0x10850802, 0x2408b682, 0x0e070401, 0x1c381c06, 0x1f346a35, 0x77381e3e, 0x1d3a182c, 0x0f09f401, 0x0f0a0503, + 0x01101001, 0x1616050f, 0x3c068205, 0x030e0d04, 0x01031905, 0x0b100d18, 0x0d14030a, 0x05040a04, 0x0902010b, 0x04040305, 0x271b8202, 0x090d1007, + 0x02030c01, 0x06340183, 0x0c0a150a, 0x19050c1a, 0x03040301, 0x09113f20, 0x0402010c, 0x02387482, 0x01030701, 0x0206040f, 0x0d15080a, 0x05060e06, + 0x0223030f, 0x05090401, 0x1b2ccd82, 0x2203042a, 0x0304080e, 0x04020204, 0x0123ab82, 0x82020107, 0x010127b1, 0x3a130509, 0xd3820318, 0x1a040f24, + 0x47821933, 0x1d820820, 0x36820a20, 0x0a090437, 0x0f0f0413, 0x05020a04, 0x0a020105, 0x030a0405, 0x0304130e, 0x2da7820e, 0x05060716, 0x0a0a0f06, + 0x16050f0f, 0x0a840508, 0x0e110624, 0x9c820504, 0x08043308, 0x18142622, 0x00000008, 0x00540001, 0x0380015a, 0x00440026, 0x2e351300, 0x36343501, + 0x1733013f, 0x26270711, 0x013e3736, 0x2711013f, 0x23150715, 0x03883315, 0x1415172e, 0x22012b06, 0x37013d26, 0x23353335, 0x27200388, 0x3b363a82, + 0x0d953701, 0x1705050e, 0x1135697c, 0x04050303, 0x2e10090e, 0x00840b1b, 0x08071b27, 0x1a0808c9, 0x0800840c, 0x08081a2f, 0xc902220f, 0x0b0d022d, + 0x03020a07, 0x1a9dfea8, 0x040a0503, 0x08050904, 0x351a3d01, 0x38363519, 0x34363936, 0x0708272e, 0x2e270807, 0x270c8234, 0x19353638, 0x1e080749, + 0x5824b382, 0x73025800, 0xa620b382, 0x1e21c082, 0x09344301, 0x15160624, 0x79431614, 0x37362107, 0x4b053648, 0x2e2105eb, 0x09d14c01, 0x27062625, + 0x83072622, 0x8206202c, 0x8b33203b, 0x089b4c41, 0x4d182f8b, 0x3e2d0882, 0x16363701, 0x23343637, 0x22353622, 0x20508206, 0x07165735, 0x4c323321, + 0x16210567, 0x20748335, 0x21538232, 0x5c831415, 0x78089b86, 0x03fd0131, 0x110b0715, 0x090f0708, 0x03010709, 0x01020206, 0x0f040706, 0x010d0201, + 0x01010303, 0x06020b07, 0x05010405, 0x040a0e0c, 0x02040509, 0x09190904, 0x04061b08, 0x06080202, 0x150b060e, 0x0d1b130a, 0x08070b10, 0x21040307, + 0x2a591d17, 0x12152c14, 0x120c1224, 0x0509070a, 0x15050c07, 0x12010114, 0x10130a14, 0x0a102110, 0x0a02021e, 0x160a0308, 0x0104040a, 0x08678203, + 0x0c03025c, 0x09090907, 0x031a3319, 0x10010124, 0x04070803, 0x02060203, 0x0a040406, 0x96020e0a, 0x130f1e11, 0x2010142a, 0x101d0f0e, 0x162e5d2f, + 0x0907162c, 0x05010102, 0x08050608, 0x321a0711, 0x2a552c19, 0x04041107, 0x1d0b030d, 0x060c060f, 0x05030b04, 0x06020102, 0x07051503, 0x29830416, + 0x1005022e, 0x14260f0e, 0x241a2b18, 0x19241c49, 0x06257782, 0x04060b06, 0x382a820f, 0x08090605, 0x202a4e25, 0x120d1940, 0x06090606, 0x070d0503, + 0x010a8329, 0x2fee8204, 0x03030503, 0x05070403, 0x05020109, 0x0105050b, 0x0522b482, 0x19820303, 0x10071239, 0x00000f2b, 0x54000300, 0xa3015800, + 0x86002603, 0xcb00a900, 0x48010000, 0x2e2205cd, 0xa65f2701, 0x84272007, 0x06d9410b, 0x27063630, 0x26273626, 0x010e2322, 0x23063607, 0x434a012a, + 0x3a332205, 0x05245801, 0x06141527, 0x17010e07, 0x200e821c, 0x22118403, 0x45161716, 0x16210577, 0x086c5f35, 0x54080c42, 0x2c820573, 0x15061424, + 0xa1451614, 0x20268305, 0x4a128407, 0x7883054d, 0x83362221, 0x08ae4515, 0x14153024, 0x228e1115, 0x228d2620, 0x012b1d82, 0x020301a2, 0x07030307, + 0x82040201, 0x082f0804, 0x06030403, 0x04080401, 0x01020601, 0x09010102, 0x040b0501, 0x0c063502, 0x0d050c1a, 0x030b0904, 0x17061802, 0x0a320905, + 0x50290721, 0x821f0e2a, 0x0606261c, 0x03060404, 0x3f298202, 0x07010605, 0x07020204, 0x0d044501, 0x07122311, 0x3b1d0812, 0x1f01061e, 0x1f0d1f3e, + 0x101e100d, 0x01301595, 0x1b371ca4, 0x090c1e0e, 0x0804070a, 0x01080206, 0x072e6882, 0x10030819, 0x030d0304, 0x060a140b, 0x14820402, 0x02014c08, + 0x03090711, 0x29030202, 0x0a140a01, 0x04090b07, 0x05010103, 0x162d1715, 0x5e5e5e2f, 0x0b170b2f, 0x11020e07, 0x0b020903, 0x04010308, 0x2c0b150b, + 0x91492c59, 0x040c0449, 0x03050b05, 0x230b030b, 0x376e370c, 0x041b371b, 0x82070705, 0x11052dd8, 0x366d370a, 0x060b0599, 0x0202020d, 0x35824c82, + 0x0704072f, 0x060d0706, 0x02030603, 0x04010206, 0x20008301, 0x21218231, 0x2182030c, 0x04241083, 0x06010407, 0x45082282, 0x03060407, 0x02010601, + 0x02010203, 0x00000001, 0x00570002, 0x0361023e, 0x004d0040, 0x01000074, 0x16171606, 0x0e010f06, 0x023f0701, 0x012e012f, 0x010f012f, 0x2e270733, + 0x36013f01, 0x1e172734, 0x37021f01, 0x19832636, 0x36343722, 0x2109d969, 0xbc7f1e02, 0x011e2107, 0x01232483, 0x8537020f, 0x3307243e, 0x82020f15, + 0x8203204e, 0x081b8459, 0x3f161730, 0x013e1301, 0x3f013e37, 0x024e0202, 0x02030403, 0x11062205, 0x2405090a, 0x0e071907, 0x0a221606, 0x050d1704, + 0x040c0301, 0x0a060c04, 0x81820403, 0x17070734, 0x05010303, 0x09090105, 0x07121704, 0x0c080209, 0xd9820603, 0x07063b08, 0x0d010902, 0x020e0c0b, + 0x390b0801, 0x0716051f, 0x1f0f060c, 0x1f135301, 0xb6081f18, 0x09070602, 0x1e0e0f18, 0x0a0b1110, 0x030b08b6, 0x44020503, 0x04860205, 0x0f050509, + 0x45822808, 0x01103608, 0x05181232, 0x2f020207, 0x0e1b1c0e, 0x07170917, 0x03050d14, 0x0b1c080c, 0x0b110522, 0x1116051d, 0x0b051612, 0x09040913, + 0x06090206, 0x02051016, 0x0a0c0202, 0x2b9d820a, 0x150b0b10, 0x1119150b, 0x130e2b4f, 0x5b084082, 0x65062b01, 0x160b0f0c, 0x0600ff0c, 0x180e0c12, + 0x050e0b0a, 0x01030204, 0x19250c00, 0x6f031c1b, 0x00040001, 0x035a0061, 0x008c031d, 0x00250012, 0x007d0038, 0x07171300, 0x35231527, 0x27372707, + 0x33351737, 0x07173715, 0x07273713, 0x27152335, 0x17071707, 0x35331537, 0x05273717, 0x07261292, 0x1d062223, 0x4f461701, 0x15232c0a, 0x16141507, + 0x3632013b, 0x4627013d, 0x33250a4f, 0x17353735, 0x05684311, 0x37011f25, 0x82232711, 0x3829820b, 0x2eda1517, 0x30252d13, 0x142f2f12, 0x122d252e, + 0x16374e2d, 0x16382d35, 0x25028238, 0x3716352d, 0x1382c701, 0x22822520, 0x2f122d2a, 0x2e132d25, 0x1021a9fe, 0x220b7746, 0x460708c9, 0x3a080791, + 0x0e09102e, 0x03030504, 0x7c693511, 0x0e050517, 0x1a00020d, 0x35341a20, 0x1b1a201b, 0x35361b21, 0x011b211a, 0x1f262027, 0x2621403e, 0x20262020, + 0x261e3e40, 0x211b2b20, 0x8236351a, 0x201a241f, 0x8234351b, 0x1e33242f, 0x46490708, 0x072309b1, 0x46070808, 0x290809b1, 0xc3fe1a35, 0x04090508, + 0x03050a04, 0xa863011a, 0x070a0203, 0x2d020c0c, 0x03000000, 0x58005100, 0x2603a101, 0xa2008600, 0xcb46c400, 0x08e26a08, 0x4408a764, 0x07280a8b, + 0x2223010e, 0x36343526, 0x2106b244, 0xd7463634, 0x011c2109, 0x22051d4f, 0x44261415, 0x2684089f, 0x05830320, 0x77362621, 0x0b8305d5, 0x2322343a, + 0x36373622, 0x013a3316, 0x07363233, 0x3a37013e, 0x06161701, 0x15361617, 0x8206064f, 0x1606262d, 0x07011e17, 0x20278216, 0x27638226, 0x07010e37, + 0x013d3413, 0x0e210682, 0x200f8201, 0x206d8427, 0x08f84433, 0x83013e21, 0x014d0858, 0x0309034d, 0x03040502, 0x08010704, 0x07030303, 0x08030201, + 0x01010302, 0x04030207, 0x04060106, 0x020a0104, 0x04040503, 0x03030507, 0x2a0e1f0c, 0x21062a4f, 0x050a320b, 0x02190716, 0x05090b03, 0x190d040d, + 0x0135050d, 0x01060b03, 0x083c8208, 0x060201aa, 0x011e208a, 0x222f2201, 0x0e061e03, 0x0e25060c, 0x04032115, 0x36170e0c, 0x0f1e0f21, 0x0f1f0f97, + 0x1f0e1e0e, 0x1d061f3e, 0x11081e3b, 0x12231108, 0x1203040c, 0x030b140a, 0x1004030d, 0x07190803, 0x01050d04, 0x08060208, 0x090a0704, 0x1b0e1e0c, + 0x6d361c37, 0x05110a37, 0x07020101, 0x1b040507, 0x6e371b37, 0x0b230c37, 0x05030b03, 0x0c04050b, 0x49914904, 0x0b2c592c, 0x01040b15, 0x020b0803, + 0x02110309, 0x170b080d, 0x5e5e2f0b, 0x2d162f5e, 0x01051517, 0x09040301, 0x140a070b, 0x0329010a, 0x09030202, 0x01021107, 0x21086482, 0xd4060204, + 0x2829551c, 0x5515034c, 0x0d201116, 0x08092f06, 0x2f190e37, 0x285a2214, 0xfe0c180c, 0x008201cd, 0xd3820420, 0x0603022a, 0x070d0603, 0x07040706, + 0x4d826482, 0x02020227, 0x050b060d, 0x08008200, 0x5e001045, 0x8f03c000, 0x1000c002, 0x3f002d00, 0x61005100, 0x7d007000, 0x9b008c00, 0xb900a700, + 0xcf00c100, 0xe900dd00, 0x00000c01, 0x23263401, 0x0f062221, 0x011f1501, 0x3d363221, 0x011e3701, 0x06141115, 0x82010e07, 0x27263917, 0x1135012e, + 0x3e373634, 0x32213301, 0x27071716, 0x33351737, 0x07173707, 0x17250a82, 0x2f073523, 0x43098701, 0x1b8206c8, 0x23012f23, 0x263f8322, 0x011f011d, + 0x82023f33, 0x21098549, 0x19823501, 0x23022f22, 0x33266b84, 0x3735013f, 0x1c8a2327, 0x8d172721, 0x2735210e, 0x27202989, 0x07236590, 0x8233013f, + 0x17232148, 0x50886b82, 0x0b825f82, 0x011e1724, 0x5e82013b, 0x15052731, 0x35331533, 0x35233533, 0x1f270723, 0x6f2f3701, 0x152205b9, 0x22821614, + 0x27218082, 0x05a65607, 0x3d051e4d, 0x074a0333, 0x03cefe08, 0x06060205, 0x0832010a, 0x06053a07, 0x11060506, 0x092afd0b, 0x00840710, 0x09104108, + 0x100bd602, 0x040bd107, 0x0d020a0d, 0x040e0e04, 0x0d0a020d, 0x0d0d1304, 0x0b030e05, 0x0d0d060b, 0x030b0b06, 0x0a03060e, 0x01040327, 0x08040202, + 0x23030a27, 0x05020308, 0x03082908, 0x23290803, 0x08211982, 0x20168404, 0x86128354, 0x0a572618, 0x02020a26, 0x20058204, 0x25048904, 0x030d0dee, + 0x5e82030f, 0x6e830b20, 0xee0f0323, 0x2448820c, 0x26e42d01, 0x22a18302, 0x830a2609, 0x0609222b, 0x830e8206, 0xfe47080b, 0x1b2e5be4, 0x314e3b1b, + 0x11080b10, 0x0c221713, 0x0a0b0b0a, 0x19131e0b, 0x0f0e0513, 0x07060f08, 0x05060607, 0x7a020a10, 0x02020708, 0x030bc40b, 0x38c40707, 0xfe0a1107, + 0x070f095e, 0x07080807, 0x01090f07, 0x84110aa2, 0x829d20e8, 0x0d0d2105, 0x07270482, 0x0e0e0708, 0x820e0807, 0x83088421, 0x27188212, 0x030608fe, + 0x03040103, 0x0326de82, 0x0106350a, 0x09840205, 0x06082725, 0x83030a4e, 0x060621e3, 0x0321fa83, 0x20188203, 0x220b8408, 0x8706065e, 0x0827222f, + 0x2023885e, 0x28588e9b, 0x151514ac, 0x03162e14, 0x233e8403, 0x6108270a, 0x03214d83, 0x334e8303, 0x31312046, 0x2a7f7b24, 0x04230202, 0x0b0c0c01, + 0x1e13121c, 0x0322e382, 0xd9822604, 0x0b100523, 0x30e48309, 0x52000100, 0x5308da00, 0xa800a902, 0x3e010000, 0xa1471801, 0x4144180b, 0x012e210c, + 0x4b05ca66, 0x07250560, 0x2e27010e, 0x050c5401, 0x7c08c558, 0x1d850822, 0x35200e82, 0x36263583, 0x37263637, 0x02833634, 0x27693620, 0x850b840a, + 0x1617214d, 0x82063b4c, 0x5f3b820e, 0x172505a5, 0x14150616, 0x06384f36, 0xd66f3220, 0x06404a06, 0x14085608, 0x1c0f2010, 0x3e1a253c, 0x14281320, + 0x4a386f37, 0x1c0e4b95, 0x0313030e, 0x05020502, 0x481f0d10, 0x0a1a0a17, 0x05061004, 0x10020204, 0x01211c07, 0x0c180202, 0x17132614, 0x7139172e, + 0x3e7d3e39, 0x15122512, 0x11050917, 0x0102060a, 0x0d040101, 0x0c070402, 0x3c098205, 0x0b050301, 0x180a0512, 0x13271314, 0x393e7c3e, 0x2d163972, + 0x13271416, 0x08060a06, 0x2b458203, 0x010f1c2b, 0x0210070b, 0x02080903, 0x26083a83, 0x26130616, 0x22432213, 0x3a397339, 0x42203a74, 0x162e1621, + 0x021d391c, 0x02050105, 0x141c4624, 0x0a060a1b, 0x820d0402, 0x13470839, 0x08150d04, 0x0c191412, 0x04061130, 0x050c0303, 0x04010408, 0x200f1c28, + 0x0104110f, 0x03030603, 0x08030202, 0x06050303, 0x02010402, 0x0d081019, 0x0813060a, 0x09102010, 0x200f090b, 0x0716050a, 0x07081008, 0x820c0610, + 0x82152014, 0x0602212a, 0x09203282, 0x03233483, 0x82010306, 0x05103c00, 0x1b0f200e, 0x1802042d, 0x0b030506, 0x030a220d, 0x0c030304, 0x0a020703, + 0x82050505, 0x01240830, 0x02010501, 0x00000205, 0x53000200, 0x330a5800, 0x80012603, 0x00008d01, 0x17363201, 0x3233011e, 0x36161714, 0x260b9b4d, + 0x07061615, 0x1807010e, 0x4d0af741, 0x864108f8, 0x36343106, 0x33163437, 0x1c150632, 0x06141501, 0x33321617, 0x3e240282, 0x16323701, 0x82087a60, + 0x52232041, 0x2a230506, 0x82060701, 0x1736272c, 0x14150616, 0x44612726, 0x26222108, 0x395b2382, 0x1e272505, 0x06140701, 0x27053652, 0x23012a27, + 0x1e230622, 0x16205982, 0x22054f74, 0x4f262223, 0x0e82052f, 0x16141722, 0x87724d82, 0x52178205, 0x47820508, 0x0e231783, 0x83062301, 0x2047825f, + 0x848c8207, 0x42388202, 0xe656059d, 0x42298208, 0x6583056d, 0x0282e682, 0x4c05614e, 0xda820599, 0x9b683620, 0x08a34206, 0x4a843320, 0x2105c151, + 0x4d523233, 0x0622410a, 0xe5512620, 0x16332508, 0x013a1706, 0x84062541, 0x0cde5b35, 0x5562fb84, 0x26f28205, 0x012a0117, 0x82062207, 0x08548266, + 0xf305273e, 0x03071509, 0x02040305, 0x0a040805, 0x10090810, 0x03170409, 0x01010505, 0x0d100302, 0x16203f20, 0x1c06162b, 0x08010605, 0x0e091108, + 0x0f070f1d, 0x02060e07, 0x02011102, 0x03051801, 0x022b0582, 0x0c060317, 0x43844206, 0x821d3a1c, 0x0930081c, 0x03020202, 0x06110506, 0x2a3c783c, + 0x10092954, 0x07010608, 0x11061707, 0x08031501, 0x4421090b, 0x162a1622, 0x04021403, 0x150c080a, 0x090c0709, 0x24084282, 0x08051004, 0x070e0605, + 0x2f0b170c, 0x030b2e5c, 0x44200901, 0x12251320, 0x0101160c, 0x10070301, 0x06070501, 0x08098204, 0x0b230687, 0x06152a17, 0x0804060e, 0x01060103, + 0x11010208, 0x0d1e0e0a, 0x09081109, 0x1d110916, 0x050a050f, 0x03010902, 0x050e040b, 0x1f3e7d3e, 0x28141e3e, 0x01331613, 0x0c030405, 0x04080101, + 0x2d0c1a0c, 0x25122d59, 0x08150812, 0x0c030510, 0x05051504, 0x4c25060c, 0x0b1d0d25, 0x0812170e, 0x7b3f0813, 0x1a31183a, 0x11183219, 0x11011020, + 0x10260e06, 0x0a0f1d0f, 0x23120402, 0x13251312, 0x08010306, 0x140a0811, 0x277b820a, 0x10050502, 0x3b1f0f1e, 0x0f290382, 0x020c2210, 0x0e080310, + 0x21268208, 0xc9821008, 0x0305033b, 0x07160707, 0x02030606, 0x170d010e, 0x0ac8fe09, 0x180d0a13, 0x0e210404, 0x208c8214, 0x21b98311, 0x00820103, + 0x04050823, 0x2b548201, 0x06190503, 0x09091209, 0x03030125, 0x023aaa82, 0x07030203, 0x01020203, 0x0f0c0e02, 0x0f080f17, 0x38010408, 0x09130904, + 0x35520d03, 0x32058305, 0x0d080811, 0x03020406, 0x0d010203, 0x25080303, 0x8201030e, 0x053c0816, 0x01040101, 0x10070201, 0x08090604, 0x0a040507, + 0x140d0a15, 0x01050103, 0x294e2901, 0x04027706, 0x480f0303, 0x1a05478f, 0x080a0502, 0x02031205, 0x14060611, 0x050f0a05, 0x1123120a, 0x042aa482, + 0x0806040b, 0x01140906, 0x8282040a, 0x020b0425, 0x82193618, 0x0d0538f3, 0x05140b05, 0x04010803, 0x02030109, 0x12020204, 0x0811091b, 0x82070e05, + 0x360e820a, 0x02010201, 0x10240803, 0x2a122412, 0x070e2a54, 0x01030209, 0x82050b05, 0x1b0b2913, 0x02020205, 0x120a1922, 0xad82f782, 0x0d043222, + 0xf6820882, 0x020c2526, 0x0101010a, 0x0320e482, 0x0c270482, 0x05021803, 0x82070409, 0x030325f5, 0x05030301, 0x07320382, 0x14070913, 0x090b0106, + 0x01016efe, 0x1e031314, 0x0082000e, 0x53000239, 0xfb082600, 0x64005a03, 0x00008c00, 0x21012f01, 0x27212707, 0x82152307, 0x35430801, 0x27350727, + 0x15211523, 0x2f213523, 0x010f1502, 0x22270727, 0x16140706, 0x010f021f, 0x011e011f, 0x0f011e17, 0x07010e02, 0x010f010e, 0x13372705, 0x1f013f17, + 0x3e033f02, 0x21013f01, 0x2735013f, 0x82153335, 0x37172801, 0x21173721, 0x8227023f, 0x042f232c, 0x8143012e, 0x833f2005, 0x07330936, 0x011f1606, + 0x34012f37, 0x1f033f36, 0xf8081502, 0x46fe0708, 0xa9fe0a0a, 0x2b960a0d, 0x080a0b1c, 0xafd2fe48, 0x5c09c7fe, 0x2b131e17, 0x09081007, 0x0a050402, + 0x0b010335, 0x04130e26, 0x0a020306, 0x0a1a1014, 0x03040e09, 0x03103501, 0x161a0a49, 0x96152516, 0x023a0e17, 0x01060306, 0x07070346, 0x0d91311e, + 0x09570109, 0x05bf0106, 0xfa020409, 0x3f1d1555, 0x252a1f47, 0x02010419, 0x05080a03, 0x10170d13, 0x01010b09, 0x0a0b0605, 0x05060206, 0x0aa42311, + 0x2d030210, 0x0104091e, 0x142a0606, 0x1a010d17, 0x0605270a, 0x190d0207, 0x261c5e39, 0x05080702, 0x0603030a, 0x0d0c2115, 0x05050905, 0x291a090d, + 0x27274a23, 0x03472b52, 0x36012317, 0x03050303, 0x0505080c, 0x08058c10, 0x06310303, 0x15320618, 0x0306051a, 0x381e0d04, 0x3cecfe35, 0x02030441, + 0x091d1002, 0x120a0b14, 0x040a0609, 0x1a0c1306, 0x0d16080f, 0x1d0e0718, 0x1708120a, 0x09010124, 0x0000090e, 0x005a0003, 0x032d0526, 0x00cc005a, + 0x000d01dc, 0x32160100, 0x33013e33, 0x82023a16, 0x088c4f06, 0x16321737, 0x07141617, 0x0627012a, 0x010e0716, 0x07260623, 0x1e171636, 0x250b8201, + 0x23062207, 0x0b82031e, 0x010e1725, 0x83061407, 0x010e2411, 0x83062227, 0x012e2502, 0x27032e27, 0x1a820582, 0x83080354, 0x5726200b, 0x2c8505bc, + 0x8206c747, 0x82388217, 0x2622255c, 0x35013c27, 0x45051248, 0x3628084a, 0x06262726, 0x27362627, 0x0e821185, 0x37012e23, 0x06265226, 0x8305f779, + 0x16362ab0, 0x17011e33, 0x0517013a, 0x828a8422, 0x013e220c, 0x222d8227, 0x82062605, 0x8415209d, 0x20ac8288, 0x82648215, 0x2118824c, 0xec603634, + 0x06b05705, 0x5b845e82, 0x0227bb08, 0x1b361b4b, 0x290d1b0d, 0x29525252, 0x09040202, 0x07040913, 0x04020506, 0x072a552a, 0x2b562b07, 0x02040304, + 0x4f27060c, 0x0c140d27, 0x06020503, 0x160b070e, 0x2221120b, 0x0f061121, 0x03060305, 0x0e050101, 0x06070506, 0x10070e08, 0x06061020, 0x1e1e0f02, + 0x1c0d0f1f, 0x030a070e, 0x01010402, 0x160d1a0b, 0x2513172e, 0x0f220f12, 0x0705120f, 0x0f070814, 0x01010204, 0x06031108, 0x0502090f, 0x2f5d2f03, + 0x10040a05, 0x06030624, 0x0b150a07, 0x0b060c05, 0x0a06091b, 0x142a1213, 0x14010208, 0x01060f2a, 0x08090201, 0x01010b06, 0x08040507, 0x060c0704, + 0x0c050c05, 0x98820b18, 0x060c0622, 0x42299382, 0x72fe4284, 0x01020502, 0x08288203, 0x07030536, 0x03090101, 0x1d11e401, 0x0d040110, 0x0b080302, + 0x17100e06, 0x01080a09, 0x01020601, 0x0a09160d, 0x1e01010d, 0x1e422013, 0x01041710, 0x18070802, 0x0341030c, 0x85829182, 0x23820120, 0x03040d3b, + 0x0101030b, 0x0110230f, 0x07102211, 0x02010104, 0x02041001, 0x07050406, 0x05535b03, 0x162a1628, 0x06030403, 0x7282050c, 0x010b0124, 0x35820107, + 0x08103008, 0x5e5f5f2f, 0x2d5b2d30, 0x09091006, 0x1e0e0a12, 0x050b090f, 0x02020808, 0x07050608, 0x0f1b0508, 0x161c381c, 0x1e0f162b, 0x0908040f, + 0x82060d08, 0x012e0855, 0x07020501, 0x0d02060d, 0x18331911, 0x0e204020, 0x26150d1a, 0x0c2d1416, 0x0501050b, 0x06060712, 0x08100610, 0x0607150b, + 0x0c08090c, 0x89820205, 0x01212f84, 0x827a8201, 0x060c253b, 0x01022401, 0x2108f782, 0x03010705, 0x04060406, 0x0f02a702, 0x03050301, 0x0f0a0e08, + 0x0b050b20, 0x0f0c1709, 0x05041124, 0x63820203, 0x0a082f08, 0x20150e1b, 0x0f060706, 0x0d111d08, 0x0d0b0b1c, 0x05000002, 0x27005b00, 0x5a03e306, + 0xe600d600, 0x0601f300, 0x00003401, 0x17161401, 0x02820616, 0x16060726, 0x23061407, 0x18054b6d, 0x2108ea63, 0xec5e1406, 0x14152505, 0x010e0706, + 0x2106d974, 0x2c82012e, 0xf0423282, 0x16222106, 0x2406f342, 0x1e17010e, 0x82298501, 0x2e232211, 0x535d1801, 0x3e37250e, 0x32363701, 0x8905c244, + 0x16362905, 0x27263637, 0x3e270626, 0x33203e83, 0x2205ab6d, 0x43333236, 0x3621052c, 0x05be6916, 0x36141522, 0x24057875, 0x33013a33, 0x054c5032, + 0x3a210584, 0x20118403, 0x82508236, 0x21808208, 0x90550537, 0x32062108, 0x33211282, 0x210f8537, 0x0c833606, 0xb0481720, 0x49362006, 0x17200858, + 0x43056650, 0x8c4905b1, 0x26342606, 0x07010e23, 0x06ee571e, 0xa582ab86, 0x5008f983, 0x01021cc2, 0x07020101, 0x01040204, 0x140a0605, 0x78783d09, + 0x5c2f3c78, 0x0705102f, 0x01020a07, 0x10350804, 0x1708470d, 0x14173613, 0x1b12102d, 0x060c0107, 0x03010803, 0x15080b0b, 0x0c170c0a, 0x01010508, + 0x11020104, 0x02070805, 0x090c0102, 0x3349820c, 0x31191139, 0x0e281519, 0x08030310, 0x140a1e31, 0x081b0b0a, 0x7c085d82, 0x06060a04, 0x1d0b0508, + 0x09080e0c, 0x060c0d09, 0x0d05060c, 0x101b1605, 0x0b071b0a, 0x180d0c15, 0x07010b0e, 0x0d040804, 0x1b071018, 0x02010104, 0x06031202, 0x02090404, + 0x20090607, 0x04050308, 0x13050c05, 0x70391225, 0x090b0b38, 0x33112311, 0x33676667, 0x0d1d3a1d, 0x0e080b1c, 0x02050608, 0xfd080201, 0x092b05de, + 0x030b180c, 0x380c0216, 0x12261203, 0x083305fe, 0x01112412, 0x0805822e, 0x117d1259, 0x150a1224, 0x0712020a, 0x0d021101, 0x33080c19, 0x08c3fc04, + 0x0d0d090f, 0x08090403, 0x06040902, 0x0f110605, 0x0c021f05, 0x09050c15, 0x100f0805, 0x151a4a16, 0x01060a1b, 0x12060201, 0x0306230a, 0x161e1533, + 0x0d0a120a, 0x17060d15, 0x041d0408, 0x12211011, 0x82072108, 0x048e08c9, 0x3b1c0e11, 0x0d081013, 0x03171e0f, 0x23050a25, 0x05020e05, 0x02020603, + 0x071c0105, 0x080c170c, 0x0d0c0714, 0x0d180d0f, 0x0b08070c, 0x01150e0d, 0x01020301, 0x32181301, 0x3979401b, 0x15122412, 0x150b162d, 0x0304080a, + 0x0406040d, 0x09080302, 0x01030d08, 0x03010103, 0x01230a03, 0x050a0b01, 0x06020208, 0x08040703, 0x0c040a04, 0x02270306, 0x01080202, 0x04010609, + 0x030b0104, 0x03040d06, 0x08060605, 0x040f2802, 0x010b0202, 0x3c82040e, 0x07013208, 0x0c040202, 0x0805a1fe, 0x0e020303, 0x030e1811, 0x04050308, + 0x15230f05, 0x06030802, 0x0c180c03, 0x100b0f12, 0x13050602, 0x0d1d0b13, 0x04070713, 0x053b5811, 0x3e006234, 0x40038902, 0x6a003b00, 0x00009100, + 0x17160601, 0x14431416, 0x20088808, 0x053b4627, 0x37362623, 0x06c8471e, 0x7a3e3721, 0x37220681, 0x0b823632, 0x16071724, 0x2e85020e, 0x01202b84, + 0x08e95b18, 0x58363721, 0x34200840, 0x8205944b, 0x4b1d822e, 0x272005fd, 0x4c587082, 0x22498408, 0x83033e37, 0x0653081a, 0x83022326, 0x01010501, + 0x090a0201, 0x0a26360f, 0x180a0b13, 0x0a16090c, 0x0f070a06, 0x4a2e0c1e, 0x04062035, 0x35190804, 0x152c1b1f, 0x0909120b, 0x30150305, 0x152a1322, + 0x0a0d1c0e, 0x055e0a11, 0x242f1907, 0x060b1509, 0x1d100610, 0x0936300e, 0x82020403, 0x016e084c, 0x03120301, 0x0a15391b, 0x08060912, 0x150d1608, + 0x160c1725, 0x1d4f3207, 0x2811200d, 0x0a092f5a, 0x34471412, 0x070e1a0d, 0x0502070e, 0x0d1d0f01, 0x0b284937, 0x0a150b06, 0x020a1709, 0x112111cc, + 0x26152915, 0x723b254b, 0x0c1a0c30, 0x090b140b, 0x0705070d, 0x0a1c0603, 0x746c6029, 0x3166313e, 0x04031410, 0x1409111b, 0x0c170a0b, 0xb4823c20, + 0x08013108, 0x08050505, 0x62673364, 0x130a2759, 0x040c0407, 0x310e180b, 0x33194479, 0x070d071a, 0x01010a01, 0x0f0a010c, 0x0a120a12, 0x0d0c0508, + 0x060e0817, 0x33081182, 0x27380338, 0x1d0c1e11, 0x88431612, 0x35814741, 0x060a170c, 0x0105050a, 0x330c150b, 0x48948c7e, 0x03030603, 0x04000001, + 0x40006600, 0x40039002, 0x47002900, 0x84270b82, 0x16010000, 0x41070f06, 0x2f290582, 0x013f3501, 0x3f011e17, 0x054d4705, 0x17023f2a, 0x012e0715, + 0x0e030f27, 0x21440482, 0x3f172e06, 0x07273506, 0x050f011f, 0x3735042f, 0x202d8233, 0x2e048204, 0x013f011f, 0x33070f33, 0x1f373337, 0x631f3306, + 0x01090627, 0x87020723, 0x26120909, 0x242f3636, 0x3a09070d, 0x2519225c, 0x07050c0b, 0x1c371a12, 0x0b182632, 0x4a200d0c, 0x172a142a, 0x7005090b, + 0x0522502d, 0x252a1f07, 0x0202284e, 0x18230a0b, 0x1636541e, 0x36262622, 0x55021424, 0x1b120311, 0x1d1f2422, 0x101f344c, 0x15020406, 0x1b24162a, + 0x0c030410, 0x2b310d1a, 0x35ce041d, 0x040e1214, 0x0b090207, 0x150f121b, 0x07050f14, 0x14144c0b, 0x180b1b1b, 0xc502360e, 0x69439552, 0x162d415e, + 0x2805040c, 0x692d3b62, 0x34495c3a, 0x09100b28, 0x1d1f1907, 0x311b1f0e, 0x0a010335, 0x12050b0b, 0x30012409, 0x2207062f, 0x1205161d, 0x387d2d21, + 0x5b372d65, 0x261b0f23, 0xba635934, 0x380b262a, 0x384a5c74, 0x41161d2b, 0x3e414645, 0x070d1055, 0x14191107, 0x081b1309, 0x380d0314, 0x261d1410, + 0x03030607, 0x0c090202, 0x02050206, 0x320b0405, 0x09091044, 0x00820002, 0x59000435, 0x7d035900, 0xc4002603, 0xe400d400, 0x0000f700, 0x41010e01, + 0x27250571, 0x0e072226, 0x06894501, 0x43012e21, 0xf442050f, 0x14152505, 0x32161716, 0x42066351, 0x088508f1, 0x29861c20, 0x4e05cb49, 0x0e8f0e74, + 0x36373025, 0x4f323637, 0x96460ad4, 0x6a362007, 0x308306c9, 0x33362624, 0x23891632, 0x16206f8e, 0x8807a849, 0x06162417, 0x832e2507, 0x220721c4, + 0x37223686, 0x995d2627, 0x20808606, 0x081f8437, 0x1422274b, 0x33321633, 0x3233011e, 0x70032726, 0x0a070e05, 0x43200815, 0x15271524, 0x0f1b351b, + 0x0b050e1a, 0x02050405, 0x06030402, 0x06020402, 0x1a120303, 0x03050203, 0x05020501, 0x07030408, 0x05050202, 0x0b18220a, 0x14060d1a, 0x2e0c8201, + 0x06010101, 0x06040703, 0x1b0f050b, 0x83432f0d, 0x0701370b, 0x04080403, 0x0d0b1407, 0x0e090d1a, 0x1c391c07, 0x02020403, 0x45820102, 0x0e1c0e2b, + 0x0d132512, 0x11010209, 0x823d8204, 0x34388262, 0x15030905, 0x0503152a, 0x050d0603, 0x07010602, 0x2210070e, 0x25858211, 0x09010802, 0x4a820911, + 0x10043508, 0x0e1b0e05, 0x1b0e1e0e, 0x2d151b36, 0x0b180b15, 0x160d1a0c, 0x01071528, 0x047efe0c, 0x0e050809, 0x04040605, 0x04050804, 0x05380511, + 0x12050302, 0x030e0306, 0x032e4782, 0x03440305, 0x0f070406, 0x02040408, 0x07820208, 0x0101032d, 0x0503e301, 0x05100101, 0x82081e13, 0x288a8207, + 0x04020601, 0x03030101, 0x2bb78203, 0x08050503, 0x06130505, 0x01031205, 0x0232fd82, 0x0c030602, 0x26130d19, 0x1b402313, 0x040a160d, 0xa482090d, + 0x82040321, 0x01022f58, 0x02070104, 0x280b1509, 0x381d3e70, 0x6682061c, 0x0a070e24, 0xb8820519, 0x060d0330, 0x02172e17, 0x05060304, 0x06010201, + 0x8a82060a, 0x0f060522, 0x072f6e82, 0x04070402, 0x02020607, 0x381c0403, 0x8208031c, 0x02042401, 0x82050a04, 0x08042cd2, 0x01020203, 0x050c190c, + 0x8204040a, 0x830e827c, 0x0101253d, 0x05030502, 0x0b2d4183, 0x1f080e1f, 0x04080a06, 0x02070203, 0x2417820c, 0x03070101, 0x25038206, 0x03030805, + 0x58820902, 0x01030224, 0xe082021a, 0x0e010322, 0x083d1e82, 0x00000001, 0x005d0002, 0x02de08d7, 0x011c01aa, 0x01000032, 0x2627032e, 0x012a2322, + 0x6d028227, 0x7a490941, 0x35012205, 0x2002843c, 0x590e8334, 0x16200761, 0x43088d54, 0x0e880514, 0x86052e52, 0x0730280e, 0x010e3306, 0x85260623, + 0x2227230f, 0x0e821506, 0x7a686082, 0x20c28209, 0x07397e01, 0x23826083, 0x16060725, 0x83011c07, 0x16142169, 0x09c47518, 0x6d183a20, 0x16270890, + 0x37363233, 0x63173236, 0x0b8305c7, 0x6f491620, 0x842c8905, 0x09d46e14, 0x13692c82, 0x69448305, 0x15210643, 0x21478214, 0xdb86013b, 0x2c523620, + 0x32362306, 0x89683a33, 0x1e25220b, 0x06824a01, 0x35262223, 0x08258434, 0x1736323b, 0x6d37de08, 0x07366d6d, 0x2c16060e, 0x48904816, 0x15468e46, + 0x08051429, 0x070c0604, 0x0c102011, 0x02020e06, 0x1207020f, 0x0d061122, 0x06040506, 0x02030906, 0x10080201, 0x3d028208, 0x05070907, 0x0f080308, + 0x09100907, 0x02020302, 0x07030102, 0x08070803, 0x07081209, 0x0e82060d, 0x02020a2e, 0x03020208, 0x060e0601, 0x07091109, 0x0a2f3d82, 0x070d0505, + 0x070e170f, 0x40200814, 0x82100a20, 0x08013136, 0x02070102, 0x10040603, 0x25121021, 0x07110812, 0x072a2e82, 0x0607070f, 0x04080406, 0x16820302, + 0x02086a08, 0x07090a06, 0x06112010, 0x06020908, 0x03040301, 0x010f200f, 0x0d060105, 0x050b0404, 0x0309120a, 0x0f050210, 0x07030607, 0x05122312, + 0x0201040a, 0x0b0b0206, 0x0a050401, 0x142a1406, 0x40448945, 0x407f807f, 0x32224322, 0x341f2e60, 0x07c0fe1a, 0x05030206, 0x060c180c, 0x07050809, + 0x0b04070e, 0x09c40104, 0x08111110, 0x08008201, 0x220c0a21, 0x09042244, 0x02010305, 0x23040904, 0x0e062345, 0x0501010a, 0x0b010204, 0x02090101, + 0x82040202, 0x01043808, 0x01040302, 0x02030305, 0x01050604, 0x03050701, 0x09100102, 0x820d1c0d, 0x28fc8255, 0x02050d05, 0x0303010f, 0x244f8207, + 0x04010202, 0x2a2d8202, 0x030b0d06, 0x01060701, 0x83040303, 0x0307223d, 0x22478203, 0x82122412, 0x01052880, 0x11050c06, 0x82051122, 0x0525082e, + 0x16180504, 0x0817280f, 0x02080c04, 0x03051111, 0x00030213, 0x00020000, 0x08000153, 0x007f0253, 0x00f900e9, 0x06564b00, 0x50820e20, 0x4c022e21, + 0x062a062a, 0x06162326, 0x23012e15, 0x0582011c, 0x0614272b, 0x07012e07, 0x06072622, 0x250b8226, 0x27062615, 0x11822226, 0x0e822720, 0x4b012e21, + 0x8c7606a0, 0x0b5c6b08, 0x96451420, 0x0c4e4c09, 0x17833220, 0x0b851186, 0x57050d49, 0xb4450870, 0x011e2105, 0x2007ae42, 0x08d77d36, 0x16321726, + 0x37013e35, 0x32824188, 0x33163222, 0x08843e82, 0x37212f82, 0x4c35823e, 0x958210bd, 0x013c0522, 0x0806d042, 0x17160637, 0x0707012a, 0x305f2fea, + 0x2f1e3e1f, 0x61312f5e, 0x04306062, 0x0703040e, 0x03060302, 0x04020101, 0x02040203, 0x03060101, 0x01050103, 0x02050203, 0x05010604, 0x080a8402, + 0x0b080521, 0x160b0d18, 0x1f3e1e0c, 0x1f2b562b, 0x30181f3d, 0x162c1618, 0x1819381e, 0x0f071129, 0x83081b01, 0x0b5d0839, 0x09170905, 0x09080e08, + 0x3218080f, 0x10210f1e, 0x0a204422, 0x0c050b12, 0x152c1105, 0x080d1b0e, 0x08060911, 0x0d190b05, 0x080f2216, 0x0907060b, 0x070b0a0d, 0x02081008, + 0x05020103, 0x0f1f1005, 0x07050a05, 0x0805070f, 0x0a0f0904, 0x0c051102, 0x030e0406, 0x04020701, 0x0d070507, 0x089c8208, 0x0309034c, 0x020a0e09, + 0x05030205, 0x0a160903, 0x0d090907, 0x6b360d1a, 0x326f3934, 0x0c204122, 0x341a0b18, 0x0166fb1b, 0x0b040a05, 0x01010b16, 0x11201001, 0x180d6202, + 0x04080406, 0x02020506, 0x0a0f0801, 0x01010601, 0x01020107, 0x03820302, 0x0a85f282, 0x82010221, 0x8204201f, 0x828982f4, 0x82608206, 0x06052276, + 0x82438206, 0x04480814, 0x04090201, 0x0a070e04, 0x2b131317, 0x0d150b19, 0x02040e0c, 0x0405050e, 0x03040302, 0x03030502, 0x1f13060c, 0x01030308, + 0x07030a0b, 0x030b0101, 0x05010e0c, 0x010b0305, 0x09070308, 0x0f0b0302, 0x0a090e07, 0x0401010c, 0x0621ec83, 0x2456820d, 0x0504020a, 0x24c78202, + 0x08030406, 0x24028301, 0x01050102, 0x82768203, 0x82082014, 0x0302220a, 0x221d8201, 0x82090608, 0x04270825, 0x13180802, 0x17233814, 0x13091a32, + 0x070f0709, 0x040e0282, 0x00010407, 0x01530002, 0x02ed0708, 0x00d40078, 0x690000e1, 0x2a4e05d9, 0x06184805, 0x42052958, 0xdc4705b1, 0x21058205, + 0xf0420622, 0x26272305, 0x1a820706, 0x8505d842, 0x012e2108, 0x574f1185, 0x20208805, 0x08724f23, 0x2408e742, 0x16272206, 0x083c4c26, 0x42061521, + 0x42520adb, 0x21088208, 0x184f3632, 0x08084305, 0x220eb148, 0x82361633, 0x5a14821a, 0x29840852, 0x05830320, 0x0521aa82, 0x08486a1e, 0x17364608, + 0x813dba07, 0x0a110c40, 0x06031006, 0x180c060b, 0x0107060a, 0x080a0201, 0x0b04070e, 0x0d1a0d04, 0x1c295228, 0x170b1c39, 0x040a040c, 0x08090307, + 0x08080706, 0x04080608, 0x08050c02, 0x0b060904, 0x040a0305, 0x28138208, 0x0c050705, 0x020b0205, 0x25208207, 0x04080905, 0x01820207, 0x070e3f08, + 0x3a316131, 0x783c3a77, 0x0d190d3b, 0x08050e05, 0x22030a07, 0x05100c07, 0x060c1b0e, 0x11100106, 0x060c120a, 0x2e17060d, 0x0c130c16, 0x170b160c, + 0x7038172f, 0x0a150a38, 0x0e041105, 0x5e821216, 0x0c140b28, 0x07162814, 0x9a82070f, 0x16142308, 0x01030105, 0x04010801, 0x0b030302, 0x1e040603, + 0x13241303, 0x3a122411, 0x552a3a76, 0x31265054, 0x67822851, 0xddf82308, 0x03040507, 0x0c0c0815, 0x0e290403, 0x281aff01, 0x08010311, 0x02010705, + 0x0b060204, 0x07060409, 0xe3821507, 0x46820120, 0x04090428, 0x080b1a0e, 0x1a82060a, 0x02010934, 0x0203040c, 0x03030506, 0x03030a02, 0x0407050c, + 0x0a820803, 0x04050234, 0x06040405, 0x01020804, 0x0506010e, 0x04010505, 0x86820b05, 0x02022108, 0x08070304, 0x05030e13, 0x04010102, 0x030f0306, + 0x09210302, 0x0c1a3319, 0x1e120d17, 0x03050408, 0x08245482, 0x07050a17, 0x20830882, 0x030a0430, 0x09040201, 0x09020410, 0x050f0803, 0x0e820409, + 0x0d010134, 0x17260c06, 0x01060e07, 0x03030202, 0x08040204, 0x5c820a07, 0x01012a08, 0x150e0405, 0x4319131e, 0x050b0624, 0x0c100a96, 0x04030f06, + 0x10150d0c, 0x0000000a, 0x00520002, 0x03d30754, 0x00bf002c, 0x07a342d8, 0x2209f04a, 0x82272622, 0x06262402, 0x4e062207, 0x0b82085a, 0x42059e51, + 0x0882085e, 0x2809897f, 0x0607010e, 0x06222326, 0x4b088717, 0x1720058f, 0x21058e42, 0x17831606, 0x2108a642, 0x9a42010e, 0x05764205, 0x013e3728, + 0x35343637, 0x08833616, 0x075a3e20, 0x16172209, 0x5c1a8432, 0x43180acc, 0x3b840a60, 0x2e170325, 0x4b052701, 0x085508f9, 0x36322105, 0x3c081b83, + 0x07070616, 0x1f35169d, 0x2c3b692b, 0x4120325f, 0x172f1721, 0x01070e07, 0x2e080207, 0x040e050c, 0x260e1b0b, 0x10072857, 0x04070307, 0x07040904, + 0x170b0707, 0x3e83450b, 0x030e1d0f, 0x26258201, 0x04030b06, 0x820b0706, 0x0622080c, 0x02130806, 0x05070303, 0x0806050a, 0x0a020401, 0x02021306, + 0x06060624, 0x06050203, 0x02020f06, 0x1a820205, 0x0f045b08, 0x020f0409, 0x09050937, 0x09110805, 0x3522451d, 0x0701044b, 0x0e070207, 0x1c39160a, + 0x09040608, 0x471d0d13, 0x06060c24, 0x1e0f1b08, 0x1a101d4b, 0x0a0b0409, 0x07042f07, 0x0d060b08, 0x1c371c06, 0x41336632, 0x45233b85, 0x0415373e, + 0xe4f91220, 0x15172410, 0x17151420, 0x9d820808, 0x0f193436, 0x2c1c0f1f, 0x150e0807, 0x4d2a6201, 0x20523324, 0x070a2918, 0x042d9e82, 0x11010102, + 0x020b0a03, 0x0e0a0310, 0x32858205, 0x04010201, 0x03010601, 0x06030103, 0x222e1102, 0x82081008, 0x8302200c, 0x05053e0e, 0x03030207, 0x06030a0e, + 0x0109070a, 0x05070802, 0x01010c08, 0x01110c05, 0x0a120808, 0x21d28208, 0x2e820706, 0x1223122e, 0x060e1f10, 0x070e0712, 0x03070202, 0x1232dd82, + 0x570d0912, 0x070d0736, 0x0c031205, 0x03160917, 0xb5820102, 0x0a184508, 0x040b0d18, 0x0a1d110b, 0x0c150115, 0x23071120, 0x05130102, 0x02040a08, + 0x0f080205, 0x05050905, 0x121e2b06, 0x223e372e, 0xbe244e28, 0x02021012, 0x210d0c05, 0x172d1716, 0x01022e17, 0x1d330a05, 0x00173e1e, 0x022f0082, + 0x94005200, 0xed02d308, 0xaa019401, 0x18010000, 0x250b9e5f, 0x1e232226, 0xdc472301, 0x26222105, 0x54180b83, 0x1e2108de, 0x06dd4a01, 0x23830620, + 0x2205bf42, 0x82012a23, 0x84072023, 0x420b8523, 0x178208d7, 0x23058254, 0x23062627, 0x3f5d4a84, 0x82208305, 0x82388211, 0x26222402, 0x7e013c35, + 0x4c4b0581, 0x011c2a06, 0x15261415, 0x2e071406, 0x28508201, 0x23062207, 0x1407010e, 0x86418226, 0x43a18247, 0x74820528, 0x17823420, 0x99450620, + 0x82152005, 0x05ac4b95, 0x06211d82, 0x822c8426, 0x20028577, 0x25748226, 0x27222623, 0x24552622, 0x18072005, 0x280a1664, 0x33361617, 0x32333236, + 0x09235e16, 0x37013e24, 0x1182013e, 0x9f450288, 0x32332505, 0x26323336, 0x20072965, 0x83148616, 0x21178329, 0x1e553a17, 0x87162005, 0x37362735, + 0x1633011c, 0x02821514, 0x4d181420, 0xef82098e, 0x4b08b065, 0xc34e05a8, 0x245c8405, 0x3732013e, 0x227c833a, 0x833a2537, 0x16172380, 0x2f4c0706, + 0x08ec8205, 0x37362646, 0x1d0e9a08, 0x2952280e, 0x21407f40, 0x24132142, 0x0c010614, 0x03030607, 0x10070709, 0x0e050808, 0x05030808, 0x10080903, + 0x0c0a0508, 0x02030d08, 0x11080804, 0x0e040609, 0x05030709, 0x10090a05, 0x10060608, 0x04280b82, 0x10090904, 0x10040509, 0x4b083b82, 0x08090605, + 0x05040811, 0x070e0201, 0x01040808, 0x14090320, 0x01090409, 0x07030212, 0x05090203, 0x08020801, 0x23110810, 0x01040911, 0x01072401, 0x04020101, + 0x10070f07, 0x01061021, 0x02020803, 0x0d020201, 0x0a130902, 0x02060c06, 0x02231b82, 0x82020505, 0x0d062d00, 0x0f1d0f06, 0x02020301, 0x06020405, + 0x51082c83, 0x05070404, 0x030b0305, 0x0709130a, 0x0304070d, 0x06060705, 0x10050b05, 0x2f17101f, 0x0d190e16, 0x02010e03, 0x05010208, 0x070e0403, + 0x01030603, 0x0d040105, 0x0c170c05, 0x051c391c, 0x07070409, 0x04030308, 0x09070e08, 0x0e030911, 0x06050303, 0x83830405, 0x0501072d, 0x0c040208, + 0x1b080d18, 0x820a0204, 0x0e06236e, 0x2f820f1d, 0x06020524, 0x8e820303, 0x08040129, 0x0f1f1004, 0x82060a06, 0x033c081b, 0x10010105, 0x01100102, + 0x04090401, 0x0a203e20, 0x02040813, 0x2d592d05, 0x87878743, 0x10201043, 0xfe43944e, 0x0e1a0d62, 0x03020806, 0x0d040908, 0x070f0804, 0x05020c06, + 0x8201090c, 0x0a347882, 0x160c0714, 0x050c060c, 0x01160604, 0x0106050e, 0x0d190501, 0x01269882, 0x04160601, 0x2a820903, 0x1b06012c, 0x070d0102, + 0x18070109, 0x45821001, 0x031b0834, 0x08060f01, 0x02010101, 0x09050b04, 0x13040406, 0x36820308, 0x05070d25, 0x8207060c, 0x05083705, 0x09010101, + 0x1f0e1d0e, 0x0209203f, 0x13281309, 0x06193319, 0xad82060c, 0x060a0523, 0x201d8305, 0x22678204, 0x82020109, 0x02022227, 0x2c068204, 0x01040204, + 0x0b040106, 0x0c090501, 0x3b178303, 0x0203020b, 0x04010105, 0x04020103, 0x19060b06, 0x180d1a30, 0x040c050d, 0x05010306, 0x33851f83, 0x010c0423, + 0x21558201, 0x4e82090f, 0x04020826, 0x0308030f, 0x04205f82, 0x0c225682, 0x50820301, 0x82010121, 0x02122e74, 0x1f0f0502, 0x1122110f, 0x02040704, + 0x21028204, 0x0c820307, 0x0f1e0f22, 0x07224a82, 0x4a820305, 0x062f3082, 0x09472831, 0x06130b06, 0x040b0102, 0x4407120c, 0x512e0553, 0x5308e800, + 0x6c019702, 0x00007801, 0x41181601, 0x1e23079c, 0x520e1501, 0x41440737, 0x2e272307, 0x0b8e2701, 0x07010e24, 0x4744012a, 0x8c1a8305, 0x44222032, + 0x16210953, 0x065b5214, 0x2b472620, 0x08855206, 0x84262721, 0x06262126, 0x49052944, 0x2c8305bd, 0x36261182, 0x06263726, 0x92831415, 0x262a0583, + 0x16220736, 0x27362207, 0x26821626, 0x35221182, 0x1786012e, 0x23160624, 0x1d832606, 0x06238c83, 0x45220623, 0x8547050a, 0x200b830b, 0x0a254706, + 0x103f7118, 0x013e3722, 0x5206aa62, 0x0b8d0b81, 0x011c1723, 0x070f5315, 0x831e1521, 0xef4a182f, 0x063e4408, 0xb9543a20, 0x050b4d07, 0x10783220, + 0x084a4a0c, 0x2e373808, 0x01312701, 0x36372606, 0x06161716, 0x07370607, 0x0e0b0c76, 0x04020705, 0x05040806, 0x04061002, 0x05040308, 0x07020409, + 0x05031004, 0x05040206, 0x08050407, 0x82050c05, 0x0503270b, 0x02060308, 0x1f830102, 0x08065608, 0x07060302, 0x04030601, 0x0506060a, 0x09060404, + 0x03010203, 0x05050513, 0x01040103, 0x02050302, 0x050d0402, 0x04040606, 0x140b050f, 0x1727140a, 0x13356f35, 0x0e071326, 0x02080207, 0x04070b06, + 0x1109050b, 0x08110a09, 0x03040903, 0x0b030407, 0x03060201, 0x085c8201, 0x01040325, 0x05010601, 0x03060403, 0x03060303, 0x02030702, 0x01080805, + 0x04030406, 0x03030704, 0x04010405, 0x82030102, 0x064a080a, 0x180d060c, 0x1932190d, 0x2035733a, 0x160b213e, 0x08120e0b, 0x08080d07, 0x08060610, + 0x050d0608, 0x07102110, 0x0f0b0913, 0x0f170a06, 0x070b180b, 0x0c08060d, 0x09100706, 0x0e060d06, 0x0b050d1a, 0x050b0805, 0x180d160c, 0x35820c3c, + 0x04100c2b, 0x18181c08, 0x0f091429, 0x2ee38207, 0x090d0602, 0x0b010d05, 0x0c1a0c04, 0x82030c0c, 0x2303364d, 0x1f3e1f0a, 0x053e7e3f, 0x150c0408, + 0x040a0608, 0x03010301, 0x3f1a8211, 0x09140a06, 0x2b203f20, 0x1b0e2956, 0x050f070e, 0x11152915, 0x6f371123, 0x0f48fc37, 0x1207111a, 0x0220b482, + 0x2608da82, 0x071a0758, 0x07050a02, 0x0a040206, 0x05050806, 0x09040a03, 0x13060206, 0x03020305, 0x07040b03, 0x11060106, 0x82050405, 0x0705210b, + 0x0e305b82, 0x01030404, 0x06050d01, 0x10030108, 0x04060403, 0x25082d82, 0x04010807, 0x03070510, 0x03050903, 0x01040305, 0x05040b04, 0x10050606, + 0x01010606, 0x0a040d02, 0x0a07030e, 0x3d83030a, 0x04340f82, 0x02020309, 0x0902020a, 0x04020204, 0x01020502, 0x0b040405, 0x01228882, 0x70820302, + 0x03040224, 0x13820703, 0x0107012a, 0x08020104, 0x09090201, 0x03213382, 0x232a8201, 0x02050101, 0x05201482, 0x01200382, 0x053d0082, 0x171a0803, + 0x03091b0d, 0x08010104, 0x08140a0c, 0x0c0b130a, 0x0f080a13, 0x1a341b08, 0x2354820a, 0x1a0d0918, 0x04209082, 0x04245582, 0x0906050c, 0x03205583, + 0x013c7182, 0x07040701, 0x19090512, 0x0b160c16, 0x16082011, 0x0e070725, 0x0914060c, 0x02070503, 0x0c26f982, 0x0a150c05, 0x3a820e06, 0x0203012a, + 0x1b0c0802, 0x020d1b36, 0x01297082, 0x0a040708, 0x010b0206, 0x380d8302, 0x04030602, 0x08050c15, 0x05040204, 0x13152b16, 0x0e071224, 0x0eaffe07, + 0x21fb8220, 0x3c830608, 0x0001002b, 0x08da0053, 0x00a50253, 0x10f767d6, 0x010e072a, 0x07220607, 0x26232622, 0x82076144, 0x012a2108, 0x6c06f543, + 0x96560890, 0x11a85607, 0x480ed143, 0xe043058e, 0x2627220b, 0x08ca7336, 0x29086843, 0x33011e17, 0x1e331632, 0xdc731701, 0x4d362006, 0x3a2109c5, + 0x25178301, 0x34353616, 0x0b822726, 0x15013a24, 0x0c492214, 0x16172305, 0x2f823336, 0x37013e22, 0x5605264b, 0x97080589, 0x31373616, 0x3018f407, + 0x03080117, 0x0e050b06, 0x4121111f, 0x376f3524, 0x0b162e17, 0x160a0b17, 0x1d3a1d0a, 0x17172f17, 0x08031935, 0x01040104, 0x0d040b02, 0x240f0d1b, + 0x02090710, 0x122e2b0e, 0x07040a20, 0x08050303, 0x0a0c1a0d, 0x34180b14, 0x0c190c18, 0x0b0b1a0b, 0x240f0a18, 0x07090908, 0x07060503, 0x160b0610, + 0x0f211610, 0x08142716, 0x0b060911, 0x04070506, 0x12010108, 0x37621b0c, 0x1631632b, 0x4120172c, 0x07120721, 0x07030a04, 0x351a070f, 0x0204031a, + 0x2f058455, 0x1d142915, 0x13091d39, 0x02030109, 0x01020607, 0x112c0082, 0x07081121, 0x09040502, 0x08090304, 0x0f820582, 0x172f1836, 0x0f091409, + 0x4a240f1d, 0x31613025, 0x02244523, 0x02050227, 0x052d6582, 0x1c0e060c, 0x0c251309, 0x03050d10, 0x08008201, 0x0905022e, 0x050c0405, 0x07010306, + 0x01080301, 0x05050a05, 0x1b010110, 0x04512305, 0x05110802, 0x0707060b, 0x02070101, 0x02010302, 0x04020406, 0x013b7582, 0x1905040a, 0x0c1c0b0b, + 0x01020b05, 0x190b0703, 0x0e160202, 0x0a172f16, 0x82050815, 0x0803301a, 0x1d10230f, 0x563b1a39, 0x091c1a20, 0x43020904, 0x04240622, 0x01020101, + 0x03210483, 0x828a8201, 0x0d012479, 0x83060104, 0x0508230b, 0x14820f07, 0x03010125, 0x82030602, 0x140c218e, 0x69820582, 0x0100022c, 0x09015300, + 0x77025308, 0x994d8d01, 0x2e312308, 0xd14a2701, 0x31302105, 0x2c05474a, 0x23012a27, 0x2207012e, 0x30170706, 0x2f098231, 0x07010e27, 0x23222330, + 0x22230626, 0x22312326, 0x16271283, 0x31231714, 0x82150614, 0x2606223c, 0x26168227, 0x22151614, 0x87221526, 0x0622222f, 0x22578527, 0x8515010e, + 0x26062244, 0x25118207, 0x30151416, 0x2f820139, 0x2205b262, 0x82152322, 0x280b825c, 0x2e17011e, 0x06222301, 0x827b8415, 0x2623243b, 0x831c2322, + 0x0650473b, 0x16153024, 0xa3461415, 0x222d8207, 0x8215012a, 0x22262430, 0x82012a07, 0x1427232d, 0x48821716, 0x63842220, 0x27220627, 0x23072206, + 0x82178326, 0x82232094, 0x013e2252, 0x82708535, 0x822a8224, 0x010e21dd, 0x2720ec82, 0x05829485, 0x8405904e, 0x22ee8308, 0x84071406, 0x8223204e, + 0x226c82e7, 0x6f170616, 0x0a4b0aed, 0x5d118205, 0x36200938, 0x29082247, 0x16060706, 0x37363207, 0x56432634, 0x26272205, 0x7e268236, 0x6a4b08a8, + 0x223b8305, 0x18373616, 0x3b08f763, 0x07272622, 0x162e17ed, 0x03162f17, 0x02010306, 0x03050201, 0x070e0701, 0x010d190d, 0x04260e82, 0x0d1a0d04, + 0x0a830101, 0x01241d82, 0x050b0401, 0x07832083, 0x012a1582, 0x05030503, 0x05020717, 0x39820102, 0x01251083, 0x08040204, 0x21498204, 0x13820702, + 0x05281583, 0x0c06060c, 0x04020107, 0x02211e83, 0x2b158204, 0x09020403, 0x0401090d, 0x030a0301, 0x08245182, 0x03060403, 0x02251882, 0x03020203, + 0x831c8201, 0x0103234a, 0x22821309, 0x06212d83, 0x23518303, 0x09030407, 0x08224282, 0x9c820710, 0x04223b82, 0x27820308, 0x02202d82, 0x05240082, + 0x0a140a02, 0x6a827582, 0x1f840b20, 0x0b050135, 0x13281206, 0x11162c16, 0x743a1121, 0x2344223a, 0x82142814, 0x0e092f52, 0x14291508, 0x03031408, + 0x03080501, 0x44820703, 0x820f0621, 0x0d6608c5, 0x0a081106, 0x05030913, 0x0b1e0d05, 0x1b122412, 0x381c1b37, 0x2b572c1c, 0x0c142a15, 0x1c0f0d19, + 0x060e090e, 0x010b180d, 0x02060206, 0x09120902, 0x0a0f0601, 0x01010e05, 0x20120302, 0x0e1d0f11, 0x1b010406, 0x3e1f1c37, 0x43874320, 0x13203f1f, + 0x1f101326, 0x1c412210, 0x19041207, 0xef011934, 0x07070603, 0xe0820b10, 0x01233283, 0x82070401, 0x010123e9, 0x01820301, 0x0120c783, 0x5a820e84, + 0x05240882, 0x04080b03, 0x4a055046, 0x14820656, 0x03820220, 0x02030725, 0x84050304, 0x07022221, 0x05824302, 0x01294382, 0x010a0201, 0x01020802, + 0x82248203, 0x84128416, 0x87032004, 0x03082105, 0x1e821f83, 0x04233c82, 0x82050202, 0x8404202b, 0x832e861b, 0x23112e19, 0x01020111, 0x0609130a, + 0x07040509, 0x296a8204, 0x03030308, 0x04030301, 0xad820203, 0x01050128, 0x0202020a, 0x3b820c03, 0x02062708, 0x180c0a06, 0x0609040c, 0x070e0701, + 0x16080504, 0x0407142f, 0x040a0403, 0x0a09140a, 0x01020b0b, 0x06050402, 0x3c820b02, 0x10050323, 0x080a8209, 0x03070122, 0x0a060b02, 0x0c070a14, + 0x0f1f0e06, 0x08030301, 0x09160c02, 0x0e090b06, 0x11040d1c, 0x0b020104, 0x03246682, 0x0d0f0101, 0x01209c82, 0x27086c82, 0x200a030b, 0x0b0e0917, + 0x0a000401, 0x0d015000, 0x71025408, 0xff00f300, 0x19010c01, 0x32012501, 0x44013b01, 0x68015201, 0x51112f5d, 0x2e210838, 0x057c5401, 0x4a08085d, + 0x178406d3, 0x60222321, 0xa8660761, 0x0b90600c, 0x4607714a, 0x33260581, 0x1e151632, 0x3c841701, 0x8b05066f, 0x32372138, 0x0d7e5818, 0x9c433b85, + 0x32162105, 0x22059854, 0x52011e17, 0x4457055a, 0x43272005, 0x2c820884, 0x07163624, 0xa14e013e, 0x211d8205, 0x7e183e35, 0x551809a3, 0xde820fb5, + 0x4a053121, 0x3f200989, 0x220a954a, 0x8b25013f, 0x89172018, 0x8b37200c, 0x84022031, 0x06072217, 0x822d8536, 0x0e172608, 0x012e2701, 0x24848237, + 0x07363730, 0x05154525, 0x08056b67, 0x17163223, 0x3127032e, 0x65341908, 0x18331b33, 0x05050b06, 0x2e160705, 0x22432217, 0x1a142815, 0x1a0c1933, + 0x0814820c, 0x0b0f0729, 0x0b081007, 0x1d080508, 0x1a31190f, 0x12132714, 0x30191320, 0x67673319, 0x4a253264, 0x0d190d23, 0x040b1f0e, 0x82060408, + 0x104e0804, 0x0b110908, 0x190b140b, 0x47221a33, 0x1b371b25, 0x2f1c391d, 0x33192f5f, 0x0a160b19, 0x05030202, 0x17291804, 0x301c381c, 0x964b2f61, + 0x214b2546, 0x0409180c, 0x170b041e, 0x02040311, 0x1e060b05, 0x64302043, 0x17311732, 0x21152a16, 0x08822140, 0x162c1523, 0x25998205, 0x0504040d, + 0x02830502, 0x0408012b, 0x10021003, 0x230e090a, 0x05ab610b, 0x06090529, 0x04030907, 0x82050509, 0x0305261a, 0x01012d03, 0x3e338204, 0x33122211, + 0x2e173467, 0x18301818, 0x2318341a, 0x1c0e1940, 0x0f1d0f0d, 0x180e94f8, 0x82100713, 0x02023824, 0x190e4901, 0x03100811, 0x03020401, 0x03020102, + 0x08101a0e, 0x82020311, 0x02012a0d, 0x101a0d47, 0x03031107, 0x21268205, 0x0c83f7fd, 0x04040f23, 0x24268204, 0x1c0c3a01, 0x2302820e, 0x0d020603, + 0x31083e82, 0x030b140d, 0x08043d06, 0x03090804, 0x010f2409, 0xd2010201, 0x32030803, 0x42213263, 0x0a130a20, 0x2e060607, 0x2f5e5d5e, 0x07041502, + 0x0e18070e, 0x44820604, 0x02090425, 0x83020502, 0x04052476, 0x82030403, 0x0b0832b0, 0x01040202, 0x110b0709, 0x02110804, 0x05060101, 0x3722820f, + 0x10140b05, 0x0610180c, 0x1209070e, 0x050a050d, 0x09050c06, 0x0d080811, 0x07290282, 0x0f0c170e, 0x0d06081b, 0x2e7b8204, 0x01030206, 0x03010103, + 0x0b060210, 0x83170205, 0x03043db5, 0x1e1f0906, 0x08162110, 0x23050a0f, 0x03130c05, 0x0706020d, 0x0d191305, 0x060d1c13, 0x0421d482, 0x22348201, + 0x83030801, 0x08b5827f, 0x09030c21, 0x150e0911, 0x0309030d, 0x10020b03, 0x120c1530, 0x03070308, 0x03010a02, 0x09010107, 0x82040406, 0x01082161, + 0x2208b383, 0x01010106, 0x06020402, 0x0703060d, 0x01070202, 0x0d090201, 0x20111d1f, 0x03050211, 0x07240f6c, 0x82080804, 0x01032b93, 0x0b200e1b, + 0x05080704, 0xd0820409, 0x1f0e7c26, 0x0805050b, 0x0325c482, 0x0d050201, 0x220c861e, 0x82cc0102, 0x0404250b, 0x060a0606, 0x19381882, 0x0c0c1a0d, + 0x05030c19, 0x09200e51, 0x030b1606, 0x04020905, 0x080f0101, 0x0123b782, 0x823f0201, 0x20ba8276, 0x234f8201, 0x03010503, 0x0020c082, 0x08360082, + 0x86005400, 0xf5025408, 0x90007700, 0xcf00ac00, 0x4f013601, 0x91486b01, 0x4e032005, 0x2a2506fc, 0x012e2301, 0x07e44e23, 0x8308af4a, 0x3426241d, + 0x64362635, 0xf74a066e, 0x14062108, 0x210f1171, 0xee672636, 0x0e6f5b09, 0x2808c34e, 0x2627012e, 0x3e25011f, 0x213c8301, 0x98440616, 0x25608209, + 0x13370636, 0x8e85010e, 0x8605174b, 0x26278261, 0x0e023f06, 0x4f060701, 0x71440582, 0x821d8906, 0x07bf431a, 0x4505a644, 0x07250a01, 0x26272606, + 0x854f8534, 0x82db885b, 0x18c38808, 0x48085743, 0x1722086a, 0x9d4b1614, 0x21088408, 0x56823703, 0xbbd23120, 0x0736373f, 0x5124e803, 0x1f2b5654, + 0x150a203e, 0x0306030a, 0x06040204, 0x0904030e, 0x02070505, 0x080c8201, 0x130e0b96, 0x1c101c32, 0x14020305, 0x05010409, 0x070d1608, 0x0c080a1b, + 0x09221206, 0x0501020b, 0x0811070b, 0x1211170a, 0x0b070b29, 0x03090101, 0x03020804, 0x25070701, 0x0e1e1311, 0x02011c09, 0x100a0701, 0x0e240c04, + 0x271f3d1f, 0x8044274f, 0x0f1a0d3c, 0xfc0e0f1d, 0x0b1003ba, 0x0a08100b, 0x0802020f, 0x070e080a, 0x05040f07, 0x13090412, 0x0f0b390a, 0x060b070a, + 0x08060802, 0x16090810, 0x02030305, 0x01010202, 0x0408050d, 0x180c0204, 0x081f0c0d, 0x01010308, 0x34085982, 0x14060703, 0x0d1a0d07, 0x040d2010, + 0x170a0403, 0x1a0d0d0b, 0x5f2f6207, 0x1c371c37, 0x21214221, 0x11081d46, 0x03040608, 0x171d2108, 0x070b0e39, 0x03040903, 0x2cdc820b, 0x0f21080a, + 0x0a040b07, 0x160f0913, 0x085b8304, 0x08120724, 0x22090911, 0x07221119, 0x07061008, 0x4d070403, 0x091a0e1d, 0x0b020105, 0x02070409, 0x1c091303, + 0xbd821c38, 0x4c4e2837, 0x0a062349, 0x0498fc05, 0x100b0b0f, 0x030e0909, 0x070b0702, 0x21bc830f, 0xbc861104, 0x0c070927, 0x07080305, 0x24db8207, + 0x04030515, 0x43bc9001, 0x04220525, 0xbc8b0507, 0x820c1621, 0xe10128bc, 0x0c152018, 0x48050404, 0x02220536, 0x5a820805, 0x09026d08, 0x14091209, + 0x15140f24, 0x11160508, 0x1609140a, 0x0e091329, 0x0b190f09, 0x08091305, 0x421f0b16, 0x2c5b2c23, 0x11163619, 0x2d14101f, 0x0d2a1010, 0x090b1208, + 0x150a070e, 0x0e240f0b, 0x01011211, 0x1d090c0d, 0x0b260d0e, 0x08033012, 0x07020202, 0x09080504, 0x0b22360f, 0x0a140911, 0x1e08bb0a, 0x070d0202, + 0x0a0b3b08, 0x08040407, 0x073afb82, 0x13071d08, 0x2ffe1225, 0x090c020a, 0x10040a13, 0x050b0505, 0x080c0606, 0xea830812, 0x040a2c08, 0xb8030407, + 0x0b0b150b, 0x162e1414, 0x0b0f200f, 0x0407081a, 0x0b170b06, 0x06101d0d, 0x160d0407, 0x190c0d0b, 0x0c2f1c4a, 0x83030c06, 0x0c013070, 0x0c132f03, + 0x2a1e0d20, 0x160f0a0c, 0x82133412, 0x074708cf, 0x160b0715, 0x031d0909, 0x11051401, 0x3c1e1224, 0x172d1721, 0x11245328, 0x3e101121, 0x1225090c, + 0x12111c12, 0x15261323, 0x0f1c0914, 0x06091409, 0x0c07102e, 0x01040908, 0x05040404, 0x1505050a, 0x0413241e, 0xd5cf0409, 0x002408bc, 0x43000200, + 0x92080a01, 0x0d008602, 0x00004c01, 0x17323613, 0x07141516, 0x26272206, 0x26253435, 0x012d2627, 0x272c0482, 0x07060726, 0x14161716, 0x27222306, + 0x21860982, 0x09840a82, 0x06352623, 0x21338607, 0x08852322, 0x36833d20, 0x31833482, 0x22352624, 0x51841407, 0x35231d87, 0x87070622, 0x88308639, + 0x2a548242, 0x15060706, 0x33170723, 0x82170607, 0x25038374, 0x35373637, 0x92822326, 0x32333624, 0x0d823617, 0x16200a86, 0x262b0c82, 0x16323637, + 0x37363215, 0x82343126, 0x21bf820a, 0x08833336, 0x3b221382, 0x30823401, 0x17230882, 0x87363732, 0x16172c4b, 0x36373633, 0x3633013f, 0x82373417, + 0x2017821e, 0x82078936, 0x205382ff, 0x82068636, 0x9362836d, 0x866b870e, 0x29418e72, 0x26370517, 0x05120574, 0x04820707, 0x07063d08, 0x818290af, + 0xeffed6fe, 0x11090501, 0x0b0b0809, 0x06030101, 0x07020405, 0x0304020a, 0x0102030a, 0x03040809, 0x0a090709, 0x04090403, 0x040a0803, 0x03030904, + 0x73891e2e, 0x0506484a, 0x08214382, 0x21198206, 0x23820707, 0x0203042a, 0x0403030c, 0x0509060a, 0x2b080582, 0x040b0303, 0x040a0303, 0x06230102, + 0x0a010408, 0x020f2929, 0x1e080501, 0x0c0e0b1e, 0x080d100f, 0x05020101, 0x02020303, 0x01030404, 0x02212f82, 0x211c8201, 0x7a820301, 0x030a0222, + 0x02250783, 0x03090703, 0x20628202, 0x3a4e8305, 0x767d2f05, 0x2a235f42, 0x05090b1b, 0x08050608, 0x030b130b, 0x0a5b0103, 0x82020310, 0x010228ab, + 0x09080402, 0x8205070a, 0x08032145, 0x0121b382, 0x22068501, 0x820a0705, 0x826a8215, 0x8301200e, 0x826d8206, 0x08042623, 0x02040714, 0x20238403, + 0x21058302, 0xe0820502, 0xab820820, 0x07040122, 0x112e5182, 0xe8780107, 0x06e8012d, 0x07090606, 0xe5820507, 0x18310923, 0x37328208, 0x03211010, + 0x12060402, 0x09040101, 0x06080106, 0x03040402, 0x02010404, 0x05220082, 0x20820403, 0x04050125, 0x84040303, 0x05032f15, 0x08020301, 0x05040201, + 0x01040606, 0x17820606, 0x1a820620, 0x82050221, 0x82052088, 0x861382e8, 0x2016840e, 0x31408204, 0x3604050a, 0x0807042f, 0x0c26250c, 0x0506060e, + 0xc8820e03, 0x05040322, 0x02825e82, 0x05030122, 0x0225e882, 0x02020602, 0x2bc48204, 0x02030301, 0x01030202, 0x05030204, 0x042c4882, 0x07050204, + 0x09150404, 0x090c060c, 0x1f260c82, 0x18090c0a, 0x22820109, 0x05bf2b82, 0x11080333, 0x000ab204, 0x00010000, 0x081f0176, 0x00bf0279, 0x370c8242, + 0x07060704, 0x37363706, 0x33350536, 0x36171615, 0x17323337, 0x15161716, 0x17210382, 0x26178316, 0x27062537, 0x83352315, 0x27062403, 0x83262726, + 0x21068213, 0x01832707, 0x010f3108, 0x9c032315, 0x8a8b60fe, 0x8640323e, 0x72017080, 0x12acbc08, 0x07080406, 0x57020406, 0x523f7472, 0x4e406a4b, + 0xa897fe21, 0x054c05ca, 0x03070809, 0x4b08e682, 0x0801070c, 0x1b092517, 0x19071c08, 0x7d0207f4, 0x553e3f15, 0x285e0676, 0x04050426, 0x2e182504, + 0x04070404, 0x1e1c0202, 0x0e081611, 0x9219291f, 0x0e101321, 0x01130e09, 0x08070505, 0x04060a08, 0x1e04010b, 0x11061006, 0x06060f06, 0x022ccf82, + 0x3b013100, 0x5c027a08, 0x23000700, 0x14320f82, 0x34262206, 0x06253236, 0x04173617, 0x26371625, 0x01823337, 0x37205608, 0x23270524, 0x07160726, + 0x05060524, 0x0a100b13, 0x68fb100a, 0x5a513e3f, 0x75019101, 0x121d3719, 0x06730a3a, 0xfebb9d02, 0x0a7efdb1, 0x17361336, 0xfe85fe15, 0xb8015b77, + 0x0f0b0b0f, 0x605b660b, 0x0e0e031d, 0x11211f4d, 0x482c0605, 0x0e460d02, 0x100c1620, 0x356f8205, 0x00be0005, 0x031f088a, 0x0007001a, 0x0017000f, + 0x0068001f, 0x84852400, 0x32001623, 0x208f8416, 0x22078e26, 0x84070605, 0x14152501, 0x36373216, 0x1720018b, 0x32220d83, 0x01821617, 0x023f3233, + 0x25020104, 0x27152715, 0x06072707, 0x1617022f, 0x05bf4407, 0x07263c85, 0x3fbd0106, 0x02823f58, 0x4e046908, 0x130d0d13, 0x0f163c0d, 0x4310160f, + 0x1c13131c, 0xae84fd13, 0x19547379, 0x7c580d0e, 0x1102072b, 0x0605060a, 0x3a0c0703, 0x20232f5e, 0x36495e2f, 0x060a0d1e, 0x304b4d0a, 0x01820107, + 0x3afe316b, 0x30042d31, 0x15070605, 0x0a041746, 0x1b210d41, 0x24463411, 0x35351c2d, 0x3ef12d1c, 0x3e3e593e, 0x120d4801, 0x28130d0e, 0x10225f82, + 0x5f822916, 0x1f1c132d, 0x5a3d4029, 0x1b1e211b, 0x822c583e, 0x19390861, 0x0a1e1c10, 0x0a2c0913, 0x1a1a0405, 0x0a190133, 0x51130910, 0xfe0b0906, + 0xae7301bd, 0x2d1e2e1c, 0x02202d1f, 0x1d092007, 0x0730050d, 0x1a091013, 0x02050912, 0x04030303, 0x24008300, 0x0096000c, 0x82088301, 0x000a2205, + 0x240b8616, 0x00070002, 0x240b8631, 0x000a0003, 0x200b864f, 0x200b8204, 0x240b8670, 0x000b0005, 0x200b8693, 0x26178206, 0x000300b5, 0x82090401, + 0x82142011, 0x240b854f, 0x000e0002, 0x24178621, 0x00140003, 0x200b8639, 0x200b8204, 0x200b865a, 0x20758205, 0x200b867b, 0x2c178206, 0x0063009f, + 0x00670073, 0x005f006f, 0x220b8269, 0x826e006f, 0x63002f0f, 0x5f6f6773, 0x6e6f6369, 0x52000073, 0x20826500, 0x6c007526, 0x72006100, 0x65240e82, + 0x616c7567, 0x38a00882, 0x562020a0, 0x72205982, 0x69206e82, 0x6e267e82, 0x31002000, 0x03822e00, 0x6556002c, 0x6f697372, 0x2e31206e, 0x9ea10031, + 0x02000023, 0x08009d00, 0x00004292, 0x02000201, 0x03000301, 0x05010401, 0x07010601, 0x09010801, 0x0b010a01, 0x0d010c01, 0x0f010e01, 0x11011001, + 0x13011201, 0x15011401, 0x17011601, 0x19011801, 0x1b011a01, 0x1d011c01, 0x1f011e01, 0x21012001, 0x23012201, 0x25012401, 0x27012601, 0x29012801, + 0x2b012a01, 0x2d012c01, 0x2f012e01, 0x31013001, 0x33013201, 0x35013401, 0x37013601, 0x39013801, 0x3b013a01, 0x3d013c01, 0x3f013e01, 0x67064001, + 0x6870796c, 0x6e750731, 0x30303069, 0x45200784, 0x0f830882, 0x0f870782, 0x0f863220, 0x07863320, 0x07863420, 0x07863720, 0x07863820, 0x07863920, + 0x07864120, 0x07864220, 0x07864420, 0x07854520, 0x86303121, 0x86312007, 0x20578607, 0x20478631, 0x20478631, 0x20478631, 0x21478631, 0x2f864331, + 0x31204f86, 0x46204f87, 0x32201785, 0x32215786, 0x860f8631, 0x863220b7, 0x8632205f, 0x363221b7, 0xbf861f86, 0x77863220, 0x6f863220, 0x6f863220, + 0x6f863220, 0x6f863220, 0x6f863220, 0x6f863220, 0x85303321, 0x86332047, 0x8633206f, 0x86332037, 0x86332037, 0x86332037, 0x8634202f, 0x8636202f, + 0x35362187, 0x36203f85, 0x31218f85, 0x21178546, 0xff854631, 0x85463121, 0x4631218f, 0x31215785, 0x21578546, 0x57854631, 0x85303221, 0x3032214f, + 0x3221e785, 0x21e78530, 0x47853032, 0x85303221, 0x303221df, 0x3221df85, 0x234f8530, 0x00423032, 0x01280082, 0xffff0100, 0x01000f00, 0x0c200b82, + 0x16240382, 0x02001e00, 0x01220d82, 0x05824100, 0x11820420, 0x00000222, 0x01201d84, 0x02830782, 0xd5230784, 0x83db98a4, 0xebd22b0c, 0x0000caed, + 0x8cd70000, 0xfa056d01, 0x6789964f, +}; +``` + +`icons.hpp`: + +```hpp +#pragma once + +unsigned char icons_font[47312] = { + 0x00, 0x01, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x80, 0x00, 0x03, 0x00, 0x50, + 0x46, 0x46, 0x54, 0x4D, 0x88, 0xB5, 0x73, 0x84, 0x00, 0x00, 0xB8, 0xB4, + 0x00, 0x00, 0x00, 0x1C, 0x47, 0x44, 0x45, 0x46, 0x00, 0x27, 0x00, 0x67, + 0x00, 0x00, 0xB8, 0x8C, 0x00, 0x00, 0x00, 0x26, 0x4F, 0x53, 0x2F, 0x32, + 0x57, 0xD0, 0x74, 0xA0, 0x00, 0x00, 0x01, 0x58, 0x00, 0x00, 0x00, 0x60, + 0x63, 0x6D, 0x61, 0x70, 0x1D, 0x36, 0xDC, 0x3C, 0x00, 0x00, 0x02, 0xB8, + 0x00, 0x00, 0x01, 0x76, 0x67, 0x61, 0x73, 0x70, 0x00, 0x00, 0x00, 0x10, + 0x00, 0x00, 0xB8, 0x84, 0x00, 0x00, 0x00, 0x08, 0x67, 0x6C, 0x79, 0x66, + 0x7B, 0xC9, 0xB8, 0x17, 0x00, 0x00, 0x04, 0xB4, 0x00, 0x00, 0xB1, 0x74, + 0x68, 0x65, 0x61, 0x64, 0x1A, 0x6F, 0xB4, 0x09, 0x00, 0x00, 0x00, 0xDC, + 0x00, 0x00, 0x00, 0x36, 0x68, 0x68, 0x65, 0x61, 0x10, 0xEF, 0x0D, 0x99, + 0x00, 0x00, 0x01, 0x14, 0x00, 0x00, 0x00, 0x24, 0x68, 0x6D, 0x74, 0x78, + 0xC4, 0x0C, 0x13, 0x8D, 0x00, 0x00, 0x01, 0xB8, 0x00, 0x00, 0x00, 0xFE, + 0x6C, 0x6F, 0x63, 0x61, 0xAF, 0xB9, 0xDF, 0x20, 0x00, 0x00, 0x04, 0x30, + 0x00, 0x00, 0x00, 0x84, 0x6D, 0x61, 0x78, 0x70, 0x00, 0x52, 0x02, 0x31, + 0x00, 0x00, 0x01, 0x38, 0x00, 0x00, 0x00, 0x20, 0x6E, 0x61, 0x6D, 0x65, + 0x75, 0xEF, 0x28, 0xFB, 0x00, 0x00, 0xB6, 0x28, 0x00, 0x00, 0x01, 0xA7, + 0x70, 0x6F, 0x73, 0x74, 0x25, 0x31, 0x3E, 0x4F, 0x00, 0x00, 0xB7, 0xD0, + 0x00, 0x00, 0x00, 0xB3, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x48, 0x1C, 0x09, 0x0E, 0x5F, 0x0F, 0x3C, 0xF5, 0x00, 0x0B, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xD2, 0xEB, 0xED, 0xCA, 0x00, 0x00, 0x00, 0x00, + 0xDB, 0x37, 0x81, 0xC2, 0x00, 0x00, 0xFF, 0xC0, 0x0D, 0x2D, 0x03, 0xC0, + 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x03, 0xC0, 0xFF, 0xC0, 0x00, 0x00, 0x0D, 0x9A, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x2D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x41, 0x02, 0x2F, 0x00, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x76, + 0x01, 0x90, 0x00, 0x05, 0x00, 0x00, 0x02, 0x99, 0x02, 0xCC, 0x00, 0x00, + 0x00, 0x8F, 0x02, 0x99, 0x02, 0xCC, 0x00, 0x00, 0x01, 0xEB, 0x00, 0x33, + 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x66, 0x45, 0x64, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x76, 0x03, 0xC0, 0xFF, 0xC0, 0x00, 0x40, 0x03, 0xC0, + 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x03, 0x63, + 0x03, 0x5A, 0x00, 0x00, 0x00, 0x20, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x08, 0xCD, 0x00, 0x53, 0x09, 0x4D, 0x00, 0x5D, + 0x08, 0xCD, 0x00, 0x53, 0x08, 0x66, 0x00, 0x53, 0x08, 0x4D, 0x00, 0x52, + 0x09, 0x4D, 0x00, 0x52, 0x08, 0xCD, 0x00, 0x51, 0x08, 0xCD, 0x00, 0x53, + 0x08, 0xCD, 0x00, 0x50, 0x08, 0xCD, 0x00, 0x54, 0x06, 0x80, 0x00, 0x5D, + 0x0A, 0x00, 0x00, 0x4F, 0x05, 0x4D, 0x00, 0x57, 0x05, 0xE6, 0x00, 0x4B, + 0x05, 0x00, 0x00, 0x55, 0x05, 0x00, 0x00, 0x59, 0x09, 0x66, 0x00, 0x53, + 0x06, 0x66, 0x00, 0x65, 0x05, 0x9A, 0x00, 0x5A, 0x07, 0x4D, 0x00, 0x5B, + 0x05, 0x4D, 0x00, 0x5D, 0x09, 0xB3, 0x00, 0x5A, 0x0A, 0x9A, 0x00, 0x5D, + 0x06, 0x1A, 0x00, 0x61, 0x08, 0x4D, 0x00, 0x4F, 0x08, 0x4D, 0x00, 0x62, + 0x0C, 0x1A, 0x00, 0x5D, 0x09, 0x1A, 0x00, 0x5A, 0x0A, 0xB3, 0x00, 0x64, + 0x0D, 0x9A, 0x00, 0x5B, 0x09, 0x66, 0x00, 0x53, 0x0A, 0x80, 0x00, 0x53, + 0x0B, 0x1A, 0x00, 0x56, 0x0B, 0x4D, 0x00, 0x4D, 0x0B, 0x4D, 0x00, 0x4A, + 0x0D, 0x9A, 0x00, 0x62, 0x08, 0xCD, 0x00, 0x52, 0x08, 0xCD, 0x00, 0x53, + 0x0C, 0x80, 0x00, 0x55, 0x0A, 0xE6, 0x00, 0x62, 0x0A, 0x66, 0x00, 0x5E, + 0x07, 0xE6, 0x00, 0x63, 0x0B, 0x4D, 0x00, 0x60, 0x09, 0x66, 0x00, 0x55, + 0x0A, 0x9A, 0x00, 0x53, 0x05, 0x33, 0x00, 0x56, 0x02, 0x00, 0x00, 0x54, + 0x02, 0xE6, 0x00, 0x58, 0x02, 0x1A, 0x00, 0x54, 0x02, 0xCD, 0x00, 0x57, + 0x03, 0x9A, 0x00, 0x61, 0x02, 0x1A, 0x00, 0x51, 0x04, 0x00, 0x00, 0x5E, + 0x03, 0x00, 0x00, 0x62, 0x03, 0x00, 0x00, 0x66, 0x03, 0xE6, 0x00, 0x59, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1C, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x03, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x1C, 0x00, 0x04, 0x00, 0x54, 0x00, 0x00, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x20, 0x00, 0x39, + 0x00, 0x5B, 0x00, 0x5D, 0x00, 0x76, 0xFF, 0xFD, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x20, 0x00, 0x30, 0x00, 0x41, 0x00, 0x5D, 0x00, 0x61, + 0xFF, 0xFD, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xE4, 0xFF, 0xD5, 0xFF, 0xCE, + 0xFF, 0xCD, 0xFF, 0xCA, 0x00, 0x03, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x03, 0x00, 0x00, 0x01, 0x06, 0x00, 0x00, 0x01, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, + 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x00, 0x2A, 0x00, 0x00, 0x00, 0x2B, + 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, + 0x00, 0x10, 0x00, 0x18, 0x01, 0x4E, 0x02, 0xC2, 0x04, 0x2C, 0x05, 0x7E, + 0x06, 0xC6, 0x08, 0xF0, 0x0B, 0x16, 0x0D, 0x34, 0x0F, 0x58, 0x11, 0xB4, + 0x12, 0xEA, 0x14, 0xCA, 0x15, 0xC8, 0x16, 0xAE, 0x17, 0xC4, 0x19, 0x50, + 0x1A, 0x1C, 0x1C, 0x5A, 0x1D, 0xE6, 0x1F, 0x92, 0x20, 0xF2, 0x23, 0xB8, + 0x25, 0xBE, 0x27, 0x58, 0x28, 0xF0, 0x2A, 0xC0, 0x2C, 0x9A, 0x2D, 0xD0, + 0x2F, 0xE0, 0x31, 0x64, 0x33, 0x02, 0x35, 0xC8, 0x36, 0xA4, 0x39, 0x14, + 0x3C, 0x02, 0x3C, 0xF4, 0x3D, 0xEE, 0x3F, 0x80, 0x41, 0xBA, 0x43, 0x94, + 0x44, 0xA0, 0x46, 0x22, 0x47, 0xE6, 0x4A, 0x54, 0x4C, 0x7A, 0x4D, 0x4C, + 0x4D, 0xA6, 0x4E, 0x9A, 0x4F, 0xAA, 0x50, 0x5E, 0x51, 0x0A, 0x52, 0x16, + 0x53, 0x94, 0x54, 0x74, 0x55, 0x2E, 0x56, 0xA4, 0x57, 0x08, 0x57, 0xAA, + 0x57, 0xE8, 0x58, 0xBA, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x39, 0x02, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x39, 0x02, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x39, 0x02, 0x00, 0x01, 0x00, 0x53, 0x00, 0xDA, 0x08, 0x53, + 0x02, 0xA5, 0x00, 0xD6, 0x00, 0x00, 0x01, 0x3E, 0x01, 0x37, 0x0E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x06, 0x22, 0x07, 0x22, 0x26, 0x23, 0x26, 0x06, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x27, 0x26, 0x06, 0x27, 0x2A, 0x01, 0x23, 0x22, 0x26, + 0x27, 0x26, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x0E, 0x01, 0x23, 0x2E, 0x01, 0x27, 0x26, 0x06, 0x07, 0x0E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x06, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x27, 0x26, 0x36, 0x35, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x17, 0x1E, 0x01, + 0x33, 0x32, 0x16, 0x33, 0x1E, 0x01, 0x17, 0x32, 0x36, 0x33, 0x3A, 0x01, + 0x33, 0x32, 0x36, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, + 0x17, 0x3A, 0x01, 0x33, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x35, 0x34, 0x26, + 0x27, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x15, 0x14, 0x22, 0x23, 0x2A, 0x01, + 0x23, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x33, 0x32, 0x36, 0x33, 0x3E, 0x01, + 0x37, 0x32, 0x36, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, + 0x17, 0x16, 0x36, 0x37, 0x31, 0x07, 0xF4, 0x18, 0x30, 0x17, 0x01, 0x08, + 0x03, 0x06, 0x0B, 0x05, 0x0E, 0x1F, 0x11, 0x21, 0x41, 0x24, 0x35, 0x6F, + 0x37, 0x17, 0x2E, 0x16, 0x0B, 0x17, 0x0B, 0x0A, 0x16, 0x0A, 0x1D, 0x3A, + 0x1D, 0x17, 0x2F, 0x17, 0x17, 0x35, 0x19, 0x03, 0x08, 0x04, 0x01, 0x04, + 0x01, 0x02, 0x0B, 0x04, 0x0D, 0x1B, 0x0D, 0x0F, 0x24, 0x10, 0x07, 0x09, + 0x02, 0x0E, 0x2B, 0x2E, 0x12, 0x20, 0x0A, 0x04, 0x07, 0x03, 0x03, 0x05, + 0x08, 0x0D, 0x1A, 0x0C, 0x0A, 0x14, 0x0B, 0x18, 0x34, 0x18, 0x0C, 0x19, + 0x0C, 0x0B, 0x1A, 0x0B, 0x0B, 0x18, 0x0A, 0x0F, 0x24, 0x08, 0x09, 0x09, + 0x07, 0x03, 0x05, 0x06, 0x07, 0x10, 0x06, 0x0B, 0x16, 0x10, 0x16, 0x21, + 0x0F, 0x16, 0x27, 0x14, 0x08, 0x11, 0x09, 0x06, 0x0B, 0x06, 0x05, 0x07, + 0x04, 0x08, 0x01, 0x01, 0x12, 0x0C, 0x1B, 0x62, 0x37, 0x2B, 0x63, 0x31, + 0x16, 0x2C, 0x17, 0x20, 0x41, 0x21, 0x07, 0x12, 0x07, 0x04, 0x0A, 0x03, + 0x07, 0x0F, 0x07, 0x1A, 0x35, 0x1A, 0x03, 0x04, 0x02, 0x06, 0x0A, 0x06, + 0x07, 0x0E, 0x07, 0x15, 0x29, 0x14, 0x1D, 0x39, 0x1D, 0x09, 0x13, 0x09, + 0x01, 0x03, 0x02, 0x07, 0x06, 0x02, 0x01, 0x01, 0x01, 0x01, 0x11, 0x21, + 0x11, 0x08, 0x07, 0x02, 0x05, 0x04, 0x09, 0x04, 0x03, 0x09, 0x08, 0x04, + 0x09, 0x04, 0x11, 0x21, 0x11, 0x18, 0x2F, 0x17, 0x09, 0x14, 0x09, 0x0F, + 0x1D, 0x0F, 0x24, 0x4A, 0x25, 0x30, 0x61, 0x31, 0x23, 0x45, 0x24, 0x02, + 0x27, 0x02, 0x05, 0x02, 0x05, 0x07, 0x04, 0x05, 0x0C, 0x06, 0x0E, 0x1C, + 0x09, 0x13, 0x25, 0x0C, 0x10, 0x0D, 0x05, 0x03, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x05, 0x09, 0x05, 0x04, 0x0C, 0x05, 0x06, 0x03, 0x01, 0x07, 0x01, + 0x03, 0x08, 0x01, 0x05, 0x0A, 0x05, 0x05, 0x10, 0x01, 0x01, 0x1B, 0x05, + 0x23, 0x51, 0x04, 0x02, 0x08, 0x11, 0x05, 0x0B, 0x06, 0x07, 0x07, 0x01, + 0x01, 0x07, 0x02, 0x02, 0x03, 0x01, 0x02, 0x06, 0x04, 0x02, 0x04, 0x03, + 0x02, 0x07, 0x01, 0x0A, 0x04, 0x05, 0x19, 0x0B, 0x0B, 0x1C, 0x0C, 0x05, + 0x0B, 0x02, 0x01, 0x03, 0x07, 0x0B, 0x19, 0x02, 0x02, 0x16, 0x0E, 0x16, + 0x2F, 0x17, 0x0A, 0x15, 0x08, 0x05, 0x0A, 0x04, 0x05, 0x03, 0x08, 0x0F, + 0x23, 0x10, 0x1D, 0x39, 0x1A, 0x3B, 0x56, 0x20, 0x1A, 0x1C, 0x09, 0x04, + 0x09, 0x02, 0x03, 0x07, 0x04, 0x01, 0x03, 0x01, 0x01, 0x04, 0x01, 0x01, + 0x02, 0x01, 0x04, 0x01, 0x01, 0x02, 0x03, 0x01, 0x02, 0x05, 0x02, 0x01, + 0x01, 0x01, 0x01, 0x0D, 0x04, 0x01, 0x06, 0x01, 0x02, 0x05, 0x02, 0x08, + 0x05, 0x07, 0x0F, 0x03, 0x01, 0x02, 0x01, 0x01, 0x03, 0x02, 0x06, 0x03, + 0x05, 0x09, 0x05, 0x0C, 0x14, 0x03, 0x05, 0x09, 0x04, 0x03, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x5D, 0x00, 0xD7, 0x08, 0xDE, 0x02, 0xAA, 0x01, 0x1C, + 0x01, 0x32, 0x00, 0x00, 0x01, 0x2E, 0x03, 0x27, 0x26, 0x22, 0x23, 0x2A, + 0x01, 0x27, 0x2A, 0x01, 0x27, 0x22, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x2A, + 0x01, 0x23, 0x22, 0x06, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x35, 0x3C, + 0x01, 0x35, 0x3C, 0x01, 0x35, 0x34, 0x06, 0x23, 0x2A, 0x01, 0x15, 0x1C, + 0x01, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x16, 0x23, 0x2A, 0x01, 0x23, 0x2A, + 0x01, 0x23, 0x22, 0x06, 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x23, 0x2A, + 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x06, 0x27, 0x2E, 0x01, 0x23, 0x2A, + 0x01, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x30, 0x07, 0x06, 0x33, + 0x0E, 0x01, 0x23, 0x06, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x27, + 0x22, 0x06, 0x15, 0x0E, 0x01, 0x23, 0x22, 0x26, 0x23, 0x2E, 0x01, 0x23, + 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x27, + 0x26, 0x06, 0x23, 0x06, 0x26, 0x27, 0x26, 0x06, 0x23, 0x2A, 0x01, 0x27, + 0x22, 0x06, 0x07, 0x06, 0x16, 0x07, 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, + 0x14, 0x16, 0x17, 0x1E, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, + 0x3A, 0x01, 0x33, 0x32, 0x16, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x33, + 0x32, 0x36, 0x37, 0x36, 0x32, 0x17, 0x16, 0x14, 0x33, 0x3A, 0x01, 0x33, + 0x32, 0x36, 0x37, 0x36, 0x16, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x17, + 0x1E, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x37, + 0x36, 0x16, 0x17, 0x16, 0x36, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x16, 0x37, + 0x36, 0x32, 0x17, 0x1E, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, + 0x32, 0x14, 0x15, 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x16, 0x33, + 0x32, 0x3B, 0x01, 0x3C, 0x01, 0x35, 0x3C, 0x01, 0x35, 0x34, 0x36, 0x33, + 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x36, 0x32, 0x33, 0x3A, 0x02, 0x36, + 0x33, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x25, 0x1E, + 0x01, 0x07, 0x14, 0x06, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x26, 0x35, 0x34, + 0x36, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x17, 0x08, 0xDE, 0x37, 0x6D, + 0x6D, 0x6D, 0x36, 0x07, 0x0E, 0x06, 0x16, 0x2C, 0x16, 0x48, 0x90, 0x48, + 0x46, 0x8E, 0x46, 0x15, 0x29, 0x14, 0x05, 0x08, 0x04, 0x06, 0x0C, 0x07, + 0x11, 0x20, 0x10, 0x0C, 0x06, 0x0E, 0x02, 0x02, 0x0F, 0x02, 0x07, 0x12, + 0x22, 0x11, 0x06, 0x0D, 0x06, 0x05, 0x04, 0x06, 0x06, 0x09, 0x03, 0x02, + 0x01, 0x02, 0x08, 0x10, 0x08, 0x08, 0x10, 0x08, 0x07, 0x09, 0x07, 0x05, + 0x08, 0x03, 0x08, 0x0F, 0x07, 0x09, 0x10, 0x09, 0x02, 0x03, 0x02, 0x02, + 0x02, 0x01, 0x03, 0x07, 0x03, 0x08, 0x07, 0x08, 0x09, 0x12, 0x08, 0x07, + 0x0D, 0x06, 0x02, 0x02, 0x01, 0x0A, 0x02, 0x02, 0x08, 0x02, 0x02, 0x03, + 0x01, 0x06, 0x0E, 0x06, 0x09, 0x11, 0x09, 0x07, 0x04, 0x06, 0x06, 0x0A, + 0x05, 0x05, 0x0D, 0x07, 0x0F, 0x17, 0x0E, 0x07, 0x14, 0x08, 0x20, 0x40, + 0x20, 0x0A, 0x10, 0x02, 0x03, 0x02, 0x01, 0x08, 0x02, 0x01, 0x07, 0x02, + 0x03, 0x06, 0x04, 0x10, 0x21, 0x10, 0x12, 0x25, 0x12, 0x08, 0x11, 0x07, + 0x06, 0x0E, 0x06, 0x07, 0x0F, 0x07, 0x07, 0x06, 0x06, 0x04, 0x08, 0x04, + 0x02, 0x03, 0x10, 0x21, 0x10, 0x08, 0x02, 0x06, 0x0A, 0x09, 0x07, 0x10, + 0x20, 0x11, 0x06, 0x08, 0x09, 0x02, 0x06, 0x01, 0x03, 0x04, 0x03, 0x0F, + 0x20, 0x0F, 0x01, 0x05, 0x01, 0x06, 0x0D, 0x04, 0x04, 0x0B, 0x05, 0x0A, + 0x12, 0x09, 0x03, 0x10, 0x02, 0x05, 0x0F, 0x07, 0x06, 0x03, 0x07, 0x12, + 0x23, 0x12, 0x05, 0x0A, 0x04, 0x01, 0x02, 0x06, 0x02, 0x0B, 0x0B, 0x01, + 0x04, 0x05, 0x0A, 0x06, 0x14, 0x2A, 0x14, 0x45, 0x89, 0x44, 0x40, 0x7F, + 0x80, 0x7F, 0x40, 0x22, 0x43, 0x22, 0x32, 0x60, 0x2E, 0x1F, 0x34, 0x1A, + 0xFE, 0xC0, 0x07, 0x06, 0x02, 0x03, 0x05, 0x0C, 0x18, 0x0C, 0x06, 0x09, + 0x08, 0x05, 0x07, 0x0E, 0x07, 0x04, 0x0B, 0x04, 0x01, 0xC4, 0x09, 0x10, + 0x11, 0x11, 0x08, 0x01, 0x01, 0x01, 0x01, 0x0A, 0x0C, 0x22, 0x44, 0x22, + 0x04, 0x09, 0x05, 0x03, 0x01, 0x02, 0x04, 0x09, 0x04, 0x23, 0x45, 0x23, + 0x06, 0x0E, 0x0A, 0x01, 0x01, 0x05, 0x04, 0x02, 0x01, 0x0B, 0x01, 0x01, + 0x09, 0x02, 0x02, 0x02, 0x04, 0x01, 0x0B, 0x01, 0x04, 0x01, 0x02, 0x03, + 0x04, 0x01, 0x05, 0x03, 0x03, 0x02, 0x04, 0x06, 0x05, 0x01, 0x01, 0x07, + 0x05, 0x03, 0x02, 0x01, 0x10, 0x09, 0x0D, 0x1C, 0x0D, 0x0C, 0x18, 0x0C, + 0x07, 0x0D, 0x06, 0x05, 0x0D, 0x05, 0x02, 0x0F, 0x01, 0x03, 0x03, 0x07, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x04, 0x02, 0x02, 0x03, 0x04, 0x06, + 0x0D, 0x0B, 0x03, 0x01, 0x07, 0x06, 0x01, 0x03, 0x03, 0x04, 0x04, 0x01, + 0x02, 0x03, 0x07, 0x03, 0x03, 0x01, 0x0B, 0x01, 0x12, 0x24, 0x12, 0x07, + 0x0E, 0x07, 0x05, 0x01, 0x06, 0x0C, 0x05, 0x11, 0x22, 0x11, 0x05, 0x01, + 0x01, 0x01, 0x05, 0x04, 0x05, 0x18, 0x16, 0x0F, 0x28, 0x17, 0x08, 0x04, + 0x0C, 0x08, 0x02, 0x11, 0x11, 0x05, 0x03, 0x13, 0x02, 0x03, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x53, 0x01, 0x00, 0x08, 0x53, 0x02, 0x7F, 0x00, 0xE9, + 0x00, 0xF9, 0x00, 0x00, 0x01, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x06, 0x2E, 0x02, 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x06, 0x26, 0x23, 0x16, 0x06, 0x15, 0x2E, 0x01, 0x23, 0x1C, 0x01, 0x15, + 0x2E, 0x01, 0x27, 0x14, 0x06, 0x07, 0x2E, 0x01, 0x07, 0x22, 0x26, 0x07, + 0x06, 0x26, 0x27, 0x14, 0x06, 0x15, 0x26, 0x06, 0x27, 0x26, 0x22, 0x07, + 0x2E, 0x01, 0x27, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x06, 0x23, + 0x2A, 0x01, 0x23, 0x06, 0x22, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x14, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x32, 0x16, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x32, 0x16, 0x17, 0x1E, 0x01, 0x37, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x37, + 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x37, + 0x3E, 0x01, 0x37, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x33, 0x3A, 0x01, 0x33, + 0x32, 0x36, 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x17, + 0x32, 0x16, 0x35, 0x3E, 0x01, 0x37, 0x32, 0x16, 0x17, 0x1E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x32, 0x16, 0x33, 0x32, 0x36, 0x37, + 0x36, 0x16, 0x17, 0x32, 0x16, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x17, + 0x16, 0x32, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x0E, 0x01, 0x07, 0x05, 0x3C, 0x01, + 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x06, 0x16, 0x17, 0x2A, 0x01, + 0x07, 0x07, 0xEA, 0x2F, 0x5F, 0x30, 0x1F, 0x3E, 0x1E, 0x2F, 0x5E, 0x2F, + 0x31, 0x61, 0x62, 0x60, 0x30, 0x04, 0x0E, 0x04, 0x03, 0x07, 0x02, 0x03, + 0x06, 0x03, 0x01, 0x01, 0x02, 0x04, 0x03, 0x02, 0x04, 0x02, 0x01, 0x01, + 0x06, 0x03, 0x03, 0x01, 0x05, 0x01, 0x03, 0x02, 0x05, 0x02, 0x04, 0x06, + 0x01, 0x05, 0x02, 0x05, 0x01, 0x03, 0x02, 0x05, 0x05, 0x08, 0x0B, 0x18, + 0x0D, 0x0B, 0x16, 0x0C, 0x1E, 0x3E, 0x1F, 0x2B, 0x56, 0x2B, 0x1F, 0x3D, + 0x1F, 0x18, 0x30, 0x18, 0x16, 0x2C, 0x16, 0x1E, 0x38, 0x19, 0x18, 0x29, + 0x11, 0x07, 0x0F, 0x01, 0x1B, 0x08, 0x04, 0x02, 0x01, 0x01, 0x0B, 0x05, + 0x09, 0x17, 0x09, 0x08, 0x0E, 0x08, 0x09, 0x0F, 0x08, 0x18, 0x32, 0x1E, + 0x0F, 0x21, 0x10, 0x22, 0x44, 0x20, 0x0A, 0x12, 0x0B, 0x05, 0x0C, 0x05, + 0x11, 0x2C, 0x15, 0x0E, 0x1B, 0x0D, 0x08, 0x11, 0x09, 0x06, 0x08, 0x05, + 0x0B, 0x19, 0x0D, 0x16, 0x22, 0x0F, 0x08, 0x0B, 0x06, 0x07, 0x09, 0x0D, + 0x0A, 0x0B, 0x07, 0x08, 0x10, 0x08, 0x02, 0x03, 0x01, 0x02, 0x05, 0x05, + 0x10, 0x1F, 0x0F, 0x05, 0x0A, 0x05, 0x07, 0x0F, 0x07, 0x05, 0x08, 0x04, + 0x09, 0x0F, 0x0A, 0x02, 0x11, 0x05, 0x0C, 0x06, 0x04, 0x0E, 0x03, 0x01, + 0x07, 0x02, 0x04, 0x07, 0x05, 0x07, 0x0D, 0x08, 0x02, 0x04, 0x02, 0x03, + 0x09, 0x03, 0x09, 0x0E, 0x0A, 0x02, 0x05, 0x02, 0x03, 0x05, 0x03, 0x09, + 0x16, 0x0A, 0x07, 0x09, 0x09, 0x0D, 0x1A, 0x0D, 0x36, 0x6B, 0x34, 0x39, + 0x6F, 0x32, 0x22, 0x41, 0x20, 0x0C, 0x18, 0x0B, 0x1A, 0x34, 0x1B, 0xFB, + 0x66, 0x01, 0x05, 0x0A, 0x04, 0x0B, 0x16, 0x0B, 0x01, 0x01, 0x01, 0x10, + 0x20, 0x11, 0x02, 0x62, 0x0D, 0x18, 0x06, 0x04, 0x08, 0x04, 0x06, 0x05, + 0x02, 0x02, 0x01, 0x08, 0x0F, 0x0A, 0x01, 0x06, 0x01, 0x01, 0x07, 0x01, + 0x02, 0x01, 0x02, 0x03, 0x02, 0x01, 0x02, 0x02, 0x04, 0x03, 0x01, 0x02, + 0x01, 0x02, 0x03, 0x02, 0x02, 0x01, 0x06, 0x05, 0x02, 0x04, 0x01, 0x03, + 0x02, 0x03, 0x01, 0x02, 0x04, 0x01, 0x03, 0x05, 0x02, 0x03, 0x01, 0x07, + 0x02, 0x05, 0x06, 0x06, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, 0x04, 0x01, + 0x02, 0x09, 0x04, 0x04, 0x0E, 0x07, 0x0A, 0x17, 0x13, 0x13, 0x2B, 0x19, + 0x0B, 0x15, 0x0D, 0x0C, 0x0E, 0x04, 0x02, 0x0E, 0x05, 0x05, 0x04, 0x02, + 0x03, 0x04, 0x03, 0x02, 0x05, 0x03, 0x03, 0x0C, 0x06, 0x13, 0x1F, 0x08, + 0x03, 0x03, 0x01, 0x0B, 0x0A, 0x03, 0x07, 0x01, 0x01, 0x0B, 0x03, 0x0C, + 0x0E, 0x01, 0x05, 0x05, 0x03, 0x0B, 0x01, 0x08, 0x03, 0x07, 0x09, 0x02, + 0x03, 0x0B, 0x0F, 0x07, 0x0E, 0x09, 0x0A, 0x0C, 0x01, 0x01, 0x04, 0x07, + 0x08, 0x10, 0x08, 0x06, 0x0D, 0x06, 0x06, 0x01, 0x0A, 0x02, 0x04, 0x05, + 0x02, 0x02, 0x05, 0x02, 0x06, 0x04, 0x03, 0x08, 0x01, 0x03, 0x08, 0x01, + 0x03, 0x02, 0x01, 0x05, 0x01, 0x03, 0x05, 0x02, 0x03, 0x02, 0x02, 0x05, + 0x08, 0x01, 0x05, 0x01, 0x02, 0x03, 0x01, 0x02, 0x05, 0x02, 0x08, 0x06, + 0x09, 0x05, 0x02, 0x02, 0x04, 0x02, 0x08, 0x18, 0x13, 0x14, 0x38, 0x23, + 0x17, 0x32, 0x1A, 0x09, 0x13, 0x09, 0x07, 0x0F, 0x07, 0x82, 0x02, 0x0E, + 0x04, 0x07, 0x04, 0x01, 0x00, 0x02, 0x00, 0x53, 0x01, 0x08, 0x07, 0xED, + 0x02, 0x78, 0x00, 0xD4, 0x00, 0xE1, 0x00, 0x00, 0x01, 0x2E, 0x01, 0x27, + 0x2E, 0x01, 0x07, 0x06, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x17, 0x16, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x27, + 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, + 0x22, 0x06, 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x26, 0x06, 0x07, + 0x06, 0x26, 0x27, 0x26, 0x06, 0x27, 0x26, 0x22, 0x07, 0x06, 0x26, 0x27, + 0x26, 0x06, 0x27, 0x2E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x26, 0x06, 0x07, + 0x06, 0x26, 0x07, 0x0E, 0x01, 0x27, 0x26, 0x06, 0x07, 0x06, 0x26, 0x27, + 0x26, 0x06, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x22, 0x27, + 0x16, 0x26, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x15, + 0x06, 0x16, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x32, 0x36, 0x33, 0x32, 0x36, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x33, 0x16, 0x36, 0x37, + 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x15, 0x14, 0x36, 0x33, 0x3A, 0x01, 0x33, + 0x3A, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x03, 0x37, 0x3E, 0x01, 0x37, + 0x2E, 0x01, 0x27, 0x05, 0x1E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x26, 0x36, 0x17, 0x07, 0xBA, 0x3D, 0x81, 0x40, 0x0C, 0x11, 0x0A, + 0x06, 0x10, 0x03, 0x06, 0x0B, 0x06, 0x0C, 0x18, 0x0A, 0x06, 0x07, 0x01, + 0x01, 0x02, 0x0A, 0x08, 0x0E, 0x07, 0x04, 0x0B, 0x04, 0x0D, 0x1A, 0x0D, + 0x28, 0x52, 0x29, 0x1C, 0x39, 0x1C, 0x0B, 0x17, 0x0C, 0x04, 0x0A, 0x04, + 0x07, 0x03, 0x09, 0x08, 0x06, 0x07, 0x08, 0x08, 0x08, 0x06, 0x08, 0x04, + 0x02, 0x0C, 0x05, 0x08, 0x04, 0x09, 0x06, 0x0B, 0x05, 0x03, 0x0A, 0x04, + 0x08, 0x07, 0x08, 0x08, 0x05, 0x07, 0x05, 0x0C, 0x05, 0x02, 0x0B, 0x02, + 0x07, 0x06, 0x07, 0x08, 0x05, 0x09, 0x08, 0x04, 0x07, 0x02, 0x07, 0x02, + 0x07, 0x0E, 0x07, 0x31, 0x61, 0x31, 0x3A, 0x77, 0x3A, 0x3C, 0x78, 0x3B, + 0x0D, 0x19, 0x0D, 0x05, 0x0E, 0x05, 0x08, 0x07, 0x0A, 0x03, 0x22, 0x07, + 0x0C, 0x10, 0x05, 0x0E, 0x1B, 0x0C, 0x06, 0x06, 0x01, 0x10, 0x11, 0x0A, + 0x12, 0x0C, 0x06, 0x0D, 0x06, 0x17, 0x2E, 0x16, 0x0C, 0x13, 0x0C, 0x0C, + 0x16, 0x0B, 0x17, 0x2F, 0x17, 0x38, 0x70, 0x38, 0x0A, 0x15, 0x0A, 0x05, + 0x11, 0x04, 0x0E, 0x16, 0x12, 0x06, 0x0B, 0x05, 0x0B, 0x14, 0x0C, 0x14, + 0x28, 0x16, 0x07, 0x0F, 0x07, 0x0C, 0x18, 0x0A, 0x14, 0x16, 0x05, 0x01, + 0x03, 0x01, 0x01, 0x08, 0x01, 0x04, 0x02, 0x03, 0x03, 0x0B, 0x03, 0x06, + 0x04, 0x1E, 0x03, 0x13, 0x24, 0x13, 0x11, 0x24, 0x12, 0x3A, 0x76, 0x3A, + 0x2A, 0x55, 0x54, 0x50, 0x26, 0x31, 0x51, 0x28, 0x0D, 0x19, 0x0D, 0xF8, + 0xDD, 0x07, 0x05, 0x04, 0x03, 0x15, 0x08, 0x0C, 0x0C, 0x03, 0x04, 0x29, + 0x0E, 0x01, 0xFF, 0x1A, 0x28, 0x11, 0x03, 0x01, 0x08, 0x05, 0x07, 0x01, + 0x02, 0x04, 0x02, 0x06, 0x0B, 0x09, 0x04, 0x06, 0x07, 0x07, 0x15, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x04, 0x02, 0x04, 0x09, 0x04, 0x0E, 0x1A, 0x0B, + 0x08, 0x0A, 0x06, 0x02, 0x04, 0x02, 0x09, 0x01, 0x02, 0x0C, 0x04, 0x03, + 0x02, 0x06, 0x05, 0x03, 0x03, 0x02, 0x0A, 0x03, 0x03, 0x0C, 0x05, 0x07, + 0x04, 0x03, 0x08, 0x03, 0x02, 0x0A, 0x02, 0x05, 0x04, 0x05, 0x04, 0x04, + 0x06, 0x04, 0x08, 0x02, 0x01, 0x0E, 0x01, 0x06, 0x05, 0x05, 0x05, 0x01, + 0x04, 0x05, 0x0B, 0x03, 0x01, 0x01, 0x02, 0x02, 0x04, 0x03, 0x07, 0x08, + 0x13, 0x0E, 0x03, 0x05, 0x02, 0x01, 0x01, 0x04, 0x06, 0x03, 0x0F, 0x03, + 0x02, 0x03, 0x21, 0x09, 0x19, 0x33, 0x1A, 0x0C, 0x17, 0x0D, 0x12, 0x1E, + 0x08, 0x04, 0x05, 0x03, 0x02, 0x04, 0x02, 0x08, 0x17, 0x0A, 0x05, 0x07, + 0x03, 0x02, 0x04, 0x01, 0x04, 0x06, 0x03, 0x04, 0x0A, 0x03, 0x01, 0x02, + 0x04, 0x09, 0x10, 0x04, 0x02, 0x09, 0x03, 0x08, 0x0F, 0x05, 0x09, 0x04, + 0x03, 0x01, 0x02, 0x01, 0x01, 0x0D, 0x06, 0x0C, 0x26, 0x17, 0x07, 0x0E, + 0x06, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x02, 0x04, 0x08, 0x07, 0x0A, + 0x03, 0x01, 0x01, 0x01, 0x01, 0x05, 0x04, 0x0E, 0x15, 0x1E, 0x13, 0x19, + 0x43, 0x24, 0x06, 0x0B, 0x05, 0x96, 0x0A, 0x10, 0x0C, 0x06, 0x0F, 0x03, + 0x04, 0x0C, 0x0D, 0x15, 0x10, 0x0A, 0x00, 0x00, 0x00, 0x02, 0x00, 0x52, + 0x00, 0x54, 0x07, 0xD3, 0x03, 0x2C, 0x00, 0xBF, 0x00, 0xD8, 0x00, 0x00, + 0x01, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x27, 0x22, 0x26, 0x27, 0x22, 0x26, 0x27, 0x26, 0x06, + 0x07, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, + 0x07, 0x22, 0x06, 0x23, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x15, 0x0E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, + 0x23, 0x22, 0x06, 0x17, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x23, 0x22, 0x06, + 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x17, 0x16, 0x26, 0x07, 0x0E, 0x01, + 0x07, 0x06, 0x16, 0x17, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x15, 0x06, 0x16, 0x17, 0x1E, 0x01, + 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x34, + 0x35, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x17, 0x16, 0x36, + 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x17, 0x16, 0x32, 0x37, 0x3E, 0x01, + 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, + 0x37, 0x36, 0x26, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x03, 0x17, 0x2E, 0x01, 0x27, 0x05, 0x0E, + 0x01, 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x36, 0x37, 0x3E, + 0x01, 0x37, 0x32, 0x36, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x07, 0x07, + 0x9D, 0x16, 0x35, 0x1F, 0x2B, 0x69, 0x3B, 0x2C, 0x5F, 0x32, 0x20, 0x41, + 0x21, 0x17, 0x2F, 0x17, 0x07, 0x0E, 0x07, 0x01, 0x07, 0x02, 0x08, 0x2E, + 0x0C, 0x05, 0x0E, 0x04, 0x0B, 0x1B, 0x0E, 0x26, 0x57, 0x28, 0x07, 0x10, + 0x07, 0x03, 0x07, 0x04, 0x04, 0x09, 0x04, 0x07, 0x07, 0x07, 0x0B, 0x17, + 0x0B, 0x45, 0x83, 0x3E, 0x0F, 0x1D, 0x0E, 0x03, 0x01, 0x01, 0x07, 0x02, + 0x06, 0x0B, 0x03, 0x04, 0x06, 0x07, 0x0B, 0x0E, 0x03, 0x01, 0x06, 0x06, + 0x08, 0x13, 0x02, 0x03, 0x03, 0x07, 0x05, 0x0A, 0x05, 0x06, 0x08, 0x01, + 0x04, 0x02, 0x0A, 0x06, 0x13, 0x02, 0x02, 0x24, 0x06, 0x06, 0x06, 0x03, + 0x02, 0x05, 0x06, 0x06, 0x0F, 0x02, 0x02, 0x05, 0x02, 0x05, 0x0A, 0x05, + 0x04, 0x0F, 0x09, 0x04, 0x0F, 0x02, 0x37, 0x09, 0x05, 0x09, 0x05, 0x08, + 0x11, 0x09, 0x1D, 0x45, 0x22, 0x35, 0x4B, 0x04, 0x01, 0x07, 0x07, 0x02, + 0x07, 0x0E, 0x0A, 0x16, 0x39, 0x1C, 0x08, 0x06, 0x04, 0x09, 0x13, 0x0D, + 0x1D, 0x47, 0x24, 0x0C, 0x06, 0x06, 0x08, 0x1B, 0x0F, 0x1E, 0x4B, 0x1D, + 0x10, 0x1A, 0x09, 0x04, 0x0B, 0x0A, 0x07, 0x2F, 0x04, 0x07, 0x08, 0x0B, + 0x06, 0x0D, 0x06, 0x1C, 0x37, 0x1C, 0x32, 0x66, 0x33, 0x41, 0x85, 0x3B, + 0x23, 0x45, 0x3E, 0x37, 0x15, 0x04, 0x20, 0x12, 0xF9, 0xE4, 0x10, 0x24, + 0x17, 0x15, 0x20, 0x14, 0x15, 0x17, 0x08, 0x08, 0x04, 0x07, 0x07, 0x34, + 0x19, 0x0F, 0x1F, 0x0F, 0x1C, 0x2C, 0x07, 0x08, 0x0E, 0x15, 0x01, 0x62, + 0x2A, 0x4D, 0x24, 0x33, 0x52, 0x20, 0x18, 0x29, 0x0A, 0x07, 0x0E, 0x03, + 0x01, 0x04, 0x02, 0x01, 0x01, 0x11, 0x03, 0x0A, 0x0B, 0x02, 0x10, 0x03, + 0x0A, 0x0E, 0x05, 0x0F, 0x09, 0x04, 0x01, 0x02, 0x01, 0x04, 0x01, 0x06, + 0x01, 0x03, 0x03, 0x01, 0x03, 0x06, 0x02, 0x11, 0x2E, 0x22, 0x08, 0x10, + 0x08, 0x01, 0x03, 0x03, 0x02, 0x03, 0x01, 0x03, 0x06, 0x05, 0x05, 0x07, + 0x02, 0x03, 0x03, 0x0E, 0x0A, 0x03, 0x06, 0x0A, 0x07, 0x09, 0x01, 0x02, + 0x08, 0x07, 0x05, 0x08, 0x0C, 0x01, 0x01, 0x05, 0x0C, 0x11, 0x01, 0x08, + 0x08, 0x12, 0x0A, 0x08, 0x06, 0x06, 0x03, 0x06, 0x07, 0x08, 0x10, 0x08, + 0x12, 0x23, 0x12, 0x10, 0x1F, 0x0E, 0x06, 0x12, 0x07, 0x0E, 0x07, 0x02, + 0x02, 0x07, 0x03, 0x05, 0x0A, 0x05, 0x12, 0x12, 0x09, 0x0D, 0x57, 0x36, + 0x07, 0x0D, 0x07, 0x05, 0x12, 0x03, 0x0C, 0x17, 0x09, 0x16, 0x03, 0x02, + 0x01, 0x0B, 0x06, 0x0D, 0x18, 0x0A, 0x18, 0x0D, 0x0B, 0x04, 0x0B, 0x11, + 0x1D, 0x0A, 0x15, 0x01, 0x15, 0x0C, 0x20, 0x11, 0x07, 0x23, 0x02, 0x01, + 0x13, 0x05, 0x08, 0x0A, 0x04, 0x02, 0x05, 0x02, 0x08, 0x0F, 0x05, 0x09, + 0x05, 0x05, 0x06, 0x2B, 0x1E, 0x12, 0x2E, 0x37, 0x3E, 0x22, 0x28, 0x4E, + 0x24, 0xBE, 0x12, 0x10, 0x02, 0x02, 0x05, 0x0C, 0x0D, 0x21, 0x16, 0x17, + 0x2D, 0x17, 0x17, 0x2E, 0x02, 0x01, 0x05, 0x0A, 0x33, 0x1D, 0x1E, 0x3E, + 0x17, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x52, 0x00, 0x94, 0x08, 0xD3, + 0x02, 0xED, 0x01, 0x94, 0x01, 0xAA, 0x00, 0x00, 0x01, 0x3E, 0x01, 0x37, + 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x22, 0x23, + 0x1E, 0x01, 0x23, 0x2E, 0x01, 0x27, 0x26, 0x06, 0x23, 0x22, 0x26, 0x23, + 0x1E, 0x01, 0x23, 0x22, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x22, 0x26, 0x23, + 0x1E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x23, 0x06, 0x22, 0x23, + 0x1E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x23, 0x2A, 0x01, 0x23, + 0x1E, 0x01, 0x07, 0x22, 0x26, 0x27, 0x2E, 0x01, 0x23, 0x2A, 0x01, 0x23, + 0x1E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x23, + 0x1E, 0x01, 0x17, 0x16, 0x06, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x06, 0x23, + 0x22, 0x26, 0x23, 0x1E, 0x01, 0x07, 0x14, 0x06, 0x27, 0x2E, 0x01, 0x27, + 0x2E, 0x01, 0x27, 0x26, 0x06, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, + 0x22, 0x26, 0x35, 0x3C, 0x01, 0x27, 0x34, 0x26, 0x35, 0x34, 0x26, 0x15, + 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x26, 0x15, + 0x06, 0x14, 0x07, 0x2E, 0x01, 0x23, 0x2A, 0x01, 0x07, 0x22, 0x06, 0x23, + 0x0E, 0x01, 0x07, 0x14, 0x26, 0x23, 0x22, 0x26, 0x27, 0x26, 0x06, 0x23, + 0x22, 0x26, 0x23, 0x26, 0x22, 0x23, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x07, + 0x22, 0x26, 0x27, 0x34, 0x26, 0x23, 0x22, 0x06, 0x23, 0x2A, 0x01, 0x23, + 0x22, 0x06, 0x15, 0x06, 0x22, 0x23, 0x22, 0x26, 0x23, 0x2A, 0x01, 0x23, + 0x22, 0x06, 0x07, 0x06, 0x26, 0x27, 0x26, 0x06, 0x23, 0x22, 0x06, 0x23, + 0x22, 0x06, 0x23, 0x22, 0x06, 0x23, 0x22, 0x26, 0x27, 0x2E, 0x01, 0x23, + 0x26, 0x22, 0x27, 0x22, 0x26, 0x07, 0x0E, 0x01, 0x23, 0x2A, 0x01, 0x07, + 0x06, 0x14, 0x15, 0x14, 0x06, 0x17, 0x1E, 0x01, 0x15, 0x1C, 0x01, 0x17, + 0x16, 0x36, 0x33, 0x36, 0x32, 0x33, 0x32, 0x16, 0x17, 0x16, 0x32, 0x33, + 0x16, 0x32, 0x33, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x33, + 0x32, 0x16, 0x33, 0x32, 0x16, 0x33, 0x32, 0x16, 0x33, 0x32, 0x16, 0x37, + 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x33, 0x32, 0x36, 0x33, 0x32, 0x26, 0x37, + 0x36, 0x16, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x16, 0x37, 0x3E, 0x01, 0x17, + 0x1E, 0x01, 0x33, 0x3E, 0x01, 0x33, 0x32, 0x36, 0x33, 0x32, 0x26, 0x17, + 0x3A, 0x01, 0x17, 0x1E, 0x01, 0x33, 0x32, 0x16, 0x33, 0x32, 0x16, 0x33, + 0x32, 0x16, 0x33, 0x32, 0x36, 0x37, 0x1C, 0x01, 0x33, 0x16, 0x14, 0x15, + 0x16, 0x14, 0x15, 0x14, 0x16, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x16, 0x33, + 0x32, 0x36, 0x35, 0x3C, 0x01, 0x35, 0x34, 0x36, 0x35, 0x3C, 0x01, 0x35, + 0x3C, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x33, 0x32, 0x16, 0x17, + 0x1E, 0x01, 0x33, 0x32, 0x36, 0x33, 0x32, 0x3E, 0x01, 0x32, 0x37, 0x3A, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x25, 0x3A, 0x01, 0x33, 0x32, 0x16, 0x17, + 0x16, 0x06, 0x07, 0x06, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x26, 0x27, + 0x26, 0x36, 0x37, 0x08, 0x9A, 0x0E, 0x1D, 0x0E, 0x28, 0x52, 0x29, 0x40, + 0x7F, 0x40, 0x21, 0x42, 0x21, 0x13, 0x24, 0x14, 0x06, 0x01, 0x0C, 0x07, + 0x06, 0x03, 0x03, 0x09, 0x07, 0x07, 0x10, 0x08, 0x08, 0x05, 0x0E, 0x08, + 0x08, 0x03, 0x05, 0x03, 0x09, 0x08, 0x10, 0x08, 0x05, 0x0A, 0x0C, 0x08, + 0x0D, 0x03, 0x02, 0x04, 0x08, 0x08, 0x11, 0x09, 0x06, 0x04, 0x0E, 0x09, + 0x07, 0x03, 0x05, 0x05, 0x0A, 0x09, 0x10, 0x08, 0x06, 0x06, 0x10, 0x09, + 0x07, 0x03, 0x04, 0x04, 0x09, 0x09, 0x10, 0x09, 0x05, 0x04, 0x10, 0x07, + 0x06, 0x03, 0x05, 0x06, 0x09, 0x08, 0x11, 0x08, 0x04, 0x05, 0x01, 0x02, + 0x0E, 0x07, 0x08, 0x08, 0x04, 0x01, 0x20, 0x03, 0x09, 0x14, 0x09, 0x04, + 0x09, 0x01, 0x12, 0x02, 0x03, 0x07, 0x03, 0x02, 0x09, 0x05, 0x01, 0x08, + 0x02, 0x08, 0x10, 0x08, 0x11, 0x23, 0x11, 0x09, 0x04, 0x01, 0x01, 0x24, + 0x07, 0x01, 0x01, 0x01, 0x02, 0x04, 0x07, 0x0F, 0x07, 0x10, 0x21, 0x10, + 0x06, 0x01, 0x03, 0x08, 0x02, 0x02, 0x01, 0x02, 0x02, 0x0D, 0x02, 0x09, + 0x13, 0x0A, 0x06, 0x0C, 0x06, 0x02, 0x01, 0x01, 0x02, 0x02, 0x05, 0x05, + 0x02, 0x02, 0x02, 0x02, 0x06, 0x0D, 0x06, 0x0F, 0x1D, 0x0F, 0x01, 0x03, + 0x02, 0x02, 0x05, 0x04, 0x02, 0x06, 0x10, 0x21, 0x10, 0x06, 0x04, 0x04, + 0x07, 0x05, 0x05, 0x03, 0x0B, 0x03, 0x0A, 0x13, 0x09, 0x07, 0x0D, 0x07, + 0x04, 0x03, 0x05, 0x07, 0x06, 0x06, 0x05, 0x0B, 0x05, 0x10, 0x1F, 0x10, + 0x17, 0x2F, 0x16, 0x0E, 0x19, 0x0D, 0x03, 0x0E, 0x01, 0x02, 0x08, 0x02, + 0x01, 0x05, 0x03, 0x04, 0x0E, 0x07, 0x03, 0x06, 0x03, 0x01, 0x05, 0x01, + 0x04, 0x0D, 0x05, 0x0C, 0x17, 0x0C, 0x1C, 0x39, 0x1C, 0x05, 0x09, 0x04, + 0x07, 0x07, 0x08, 0x03, 0x03, 0x04, 0x08, 0x0E, 0x07, 0x09, 0x11, 0x09, + 0x03, 0x0E, 0x03, 0x03, 0x05, 0x06, 0x05, 0x04, 0x07, 0x10, 0x21, 0x10, + 0x07, 0x01, 0x05, 0x08, 0x02, 0x04, 0x0C, 0x18, 0x0D, 0x08, 0x1B, 0x04, + 0x02, 0x0A, 0x03, 0x02, 0x02, 0x06, 0x0E, 0x1D, 0x0F, 0x05, 0x09, 0x04, + 0x05, 0x02, 0x06, 0x03, 0x03, 0x01, 0x01, 0x02, 0x01, 0x04, 0x08, 0x04, + 0x10, 0x1F, 0x0F, 0x06, 0x0A, 0x06, 0x03, 0x02, 0x02, 0x03, 0x05, 0x01, + 0x01, 0x10, 0x02, 0x01, 0x10, 0x01, 0x01, 0x04, 0x09, 0x04, 0x20, 0x3E, + 0x20, 0x0A, 0x13, 0x08, 0x04, 0x02, 0x05, 0x2D, 0x59, 0x2D, 0x43, 0x87, + 0x87, 0x87, 0x43, 0x10, 0x20, 0x10, 0x4E, 0x94, 0x43, 0xFE, 0x62, 0x0D, + 0x1A, 0x0E, 0x06, 0x08, 0x02, 0x03, 0x08, 0x09, 0x04, 0x0D, 0x04, 0x08, + 0x0F, 0x07, 0x06, 0x0C, 0x02, 0x05, 0x0C, 0x09, 0x01, 0x82, 0x09, 0x11, + 0x09, 0x0A, 0x14, 0x07, 0x0C, 0x16, 0x0C, 0x06, 0x0C, 0x05, 0x04, 0x06, + 0x16, 0x01, 0x0E, 0x05, 0x06, 0x01, 0x01, 0x05, 0x19, 0x0D, 0x07, 0x08, + 0x03, 0x01, 0x01, 0x06, 0x16, 0x04, 0x03, 0x09, 0x07, 0x06, 0x0C, 0x01, + 0x06, 0x1B, 0x02, 0x01, 0x0D, 0x07, 0x09, 0x01, 0x07, 0x18, 0x01, 0x10, + 0x06, 0x08, 0x02, 0x08, 0x1B, 0x03, 0x01, 0x0F, 0x06, 0x08, 0x01, 0x01, + 0x01, 0x02, 0x04, 0x0B, 0x05, 0x09, 0x06, 0x04, 0x04, 0x13, 0x08, 0x03, + 0x01, 0x01, 0x05, 0x0D, 0x07, 0x05, 0x0C, 0x06, 0x07, 0x0D, 0x07, 0x05, + 0x08, 0x05, 0x01, 0x01, 0x01, 0x09, 0x0E, 0x1D, 0x0E, 0x1F, 0x3F, 0x20, + 0x09, 0x02, 0x09, 0x13, 0x28, 0x13, 0x19, 0x33, 0x19, 0x06, 0x0C, 0x06, + 0x03, 0x02, 0x02, 0x05, 0x0A, 0x06, 0x05, 0x05, 0x01, 0x01, 0x01, 0x04, + 0x06, 0x01, 0x01, 0x09, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x04, + 0x02, 0x01, 0x01, 0x04, 0x02, 0x04, 0x01, 0x06, 0x01, 0x04, 0x0B, 0x01, + 0x05, 0x09, 0x0C, 0x03, 0x01, 0x02, 0x01, 0x01, 0x0B, 0x02, 0x03, 0x02, + 0x05, 0x01, 0x01, 0x04, 0x03, 0x01, 0x02, 0x04, 0x06, 0x0B, 0x06, 0x19, + 0x30, 0x1A, 0x0D, 0x18, 0x0D, 0x05, 0x0C, 0x04, 0x06, 0x03, 0x01, 0x05, + 0x01, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x04, 0x02, 0x04, 0x04, 0x0C, + 0x01, 0x01, 0x03, 0x02, 0x02, 0x0F, 0x09, 0x06, 0x01, 0x01, 0x08, 0x02, + 0x04, 0x0F, 0x03, 0x08, 0x03, 0x06, 0x05, 0x05, 0x04, 0x01, 0x01, 0x01, + 0x0C, 0x01, 0x03, 0x01, 0x06, 0x01, 0x01, 0x01, 0x06, 0x03, 0x02, 0x12, + 0x02, 0x02, 0x05, 0x0F, 0x1F, 0x0F, 0x11, 0x22, 0x11, 0x04, 0x07, 0x04, + 0x02, 0x04, 0x04, 0x02, 0x04, 0x07, 0x03, 0x11, 0x22, 0x11, 0x0F, 0x1E, + 0x0F, 0x01, 0x05, 0x01, 0x07, 0x05, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x06, 0x31, 0x28, 0x47, 0x09, 0x06, 0x0B, 0x13, 0x06, 0x02, 0x01, + 0x0B, 0x04, 0x0C, 0x12, 0x07, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x51, + 0x00, 0xE8, 0x08, 0x53, 0x02, 0x97, 0x01, 0x6C, 0x01, 0x78, 0x00, 0x00, + 0x01, 0x16, 0x06, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x1E, 0x01, + 0x15, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x1E, 0x01, + 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x1E, 0x01, + 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x1E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x2A, 0x01, 0x07, 0x22, 0x26, 0x27, 0x2E, 0x01, + 0x27, 0x1E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x1E, 0x01, 0x07, 0x06, 0x22, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x23, 0x16, 0x14, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x26, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, + 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x22, 0x27, 0x2E, 0x01, + 0x27, 0x26, 0x06, 0x23, 0x22, 0x26, 0x27, 0x26, 0x06, 0x07, 0x06, 0x26, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x26, 0x06, 0x23, 0x36, 0x26, + 0x37, 0x26, 0x06, 0x15, 0x14, 0x06, 0x27, 0x2E, 0x01, 0x15, 0x14, 0x06, + 0x27, 0x26, 0x36, 0x07, 0x22, 0x16, 0x07, 0x22, 0x36, 0x27, 0x26, 0x16, + 0x07, 0x06, 0x26, 0x15, 0x14, 0x06, 0x35, 0x2E, 0x01, 0x15, 0x14, 0x06, + 0x27, 0x26, 0x36, 0x07, 0x06, 0x16, 0x23, 0x06, 0x26, 0x07, 0x22, 0x16, + 0x07, 0x2A, 0x01, 0x07, 0x22, 0x06, 0x23, 0x06, 0x22, 0x23, 0x2E, 0x01, + 0x27, 0x26, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x16, 0x17, 0x1E, 0x01, + 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x37, 0x3E, 0x01, 0x33, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, + 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, + 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, + 0x17, 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x15, 0x1E, 0x01, 0x33, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x37, 0x36, 0x16, 0x33, 0x32, 0x16, 0x33, 0x32, 0x16, 0x33, 0x3A, 0x01, + 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, + 0x33, 0x32, 0x36, 0x33, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x37, 0x2E, 0x01, 0x27, 0x31, 0x01, 0x06, 0x26, 0x37, 0x36, 0x16, 0x17, + 0x16, 0x06, 0x07, 0x06, 0x37, 0x07, 0x76, 0x0C, 0x0B, 0x0E, 0x05, 0x07, + 0x02, 0x04, 0x06, 0x08, 0x04, 0x05, 0x02, 0x10, 0x06, 0x04, 0x08, 0x03, + 0x04, 0x05, 0x09, 0x04, 0x02, 0x07, 0x04, 0x10, 0x03, 0x05, 0x06, 0x02, + 0x04, 0x05, 0x07, 0x04, 0x05, 0x08, 0x05, 0x0C, 0x05, 0x05, 0x06, 0x02, + 0x03, 0x05, 0x08, 0x03, 0x06, 0x02, 0x02, 0x01, 0x04, 0x05, 0x09, 0x04, + 0x06, 0x08, 0x02, 0x03, 0x06, 0x07, 0x01, 0x06, 0x03, 0x04, 0x0A, 0x06, + 0x06, 0x05, 0x04, 0x04, 0x06, 0x09, 0x03, 0x02, 0x01, 0x03, 0x13, 0x05, + 0x05, 0x05, 0x03, 0x01, 0x04, 0x01, 0x02, 0x03, 0x05, 0x02, 0x02, 0x04, + 0x0D, 0x05, 0x06, 0x06, 0x04, 0x04, 0x0F, 0x05, 0x0B, 0x14, 0x0A, 0x14, + 0x27, 0x17, 0x35, 0x6F, 0x35, 0x13, 0x26, 0x13, 0x07, 0x0E, 0x07, 0x02, + 0x08, 0x02, 0x06, 0x0B, 0x07, 0x04, 0x0B, 0x05, 0x09, 0x11, 0x09, 0x0A, + 0x11, 0x08, 0x03, 0x09, 0x04, 0x03, 0x07, 0x04, 0x03, 0x0B, 0x01, 0x02, + 0x06, 0x03, 0x01, 0x02, 0x01, 0x04, 0x03, 0x04, 0x01, 0x01, 0x06, 0x01, + 0x05, 0x03, 0x04, 0x06, 0x03, 0x03, 0x03, 0x06, 0x03, 0x02, 0x07, 0x03, + 0x02, 0x05, 0x08, 0x08, 0x01, 0x06, 0x04, 0x03, 0x04, 0x04, 0x07, 0x03, + 0x03, 0x05, 0x04, 0x01, 0x04, 0x02, 0x01, 0x03, 0x04, 0x07, 0x03, 0x06, + 0x0C, 0x06, 0x0D, 0x18, 0x0D, 0x19, 0x32, 0x19, 0x3A, 0x73, 0x35, 0x20, + 0x3E, 0x21, 0x0B, 0x16, 0x0B, 0x0E, 0x12, 0x08, 0x07, 0x0D, 0x08, 0x08, + 0x10, 0x06, 0x06, 0x08, 0x08, 0x06, 0x0D, 0x05, 0x10, 0x21, 0x10, 0x07, + 0x13, 0x09, 0x0B, 0x0F, 0x06, 0x0A, 0x17, 0x0F, 0x0B, 0x18, 0x0B, 0x07, + 0x0D, 0x06, 0x08, 0x0C, 0x06, 0x07, 0x10, 0x09, 0x06, 0x0D, 0x06, 0x0E, + 0x1A, 0x0D, 0x05, 0x0B, 0x05, 0x08, 0x0B, 0x05, 0x0C, 0x16, 0x0D, 0x18, + 0x3C, 0x0C, 0x07, 0x0D, 0x08, 0x0C, 0x10, 0x04, 0x08, 0x1C, 0x18, 0x18, + 0x29, 0x14, 0x09, 0x0F, 0x07, 0x02, 0x02, 0x01, 0x02, 0x06, 0x0D, 0x09, + 0x05, 0x0D, 0x01, 0x0B, 0x04, 0x0C, 0x1A, 0x0C, 0x0C, 0x0C, 0x03, 0x06, + 0x0D, 0x05, 0x03, 0x23, 0x0A, 0x1F, 0x3E, 0x1F, 0x3F, 0x7E, 0x3E, 0x05, + 0x08, 0x04, 0x0C, 0x15, 0x08, 0x06, 0x0A, 0x04, 0x01, 0x03, 0x01, 0x03, + 0x11, 0x03, 0x06, 0x0D, 0x06, 0x0A, 0x14, 0x09, 0x20, 0x3F, 0x20, 0x2B, + 0x56, 0x29, 0x0E, 0x1B, 0x0E, 0x07, 0x0F, 0x05, 0x15, 0x29, 0x15, 0x11, + 0x23, 0x11, 0x37, 0x6F, 0x37, 0xFC, 0x48, 0x0F, 0x1A, 0x11, 0x07, 0x12, + 0x03, 0x03, 0x05, 0x02, 0x03, 0x01, 0x02, 0x58, 0x07, 0x1A, 0x07, 0x02, + 0x0A, 0x05, 0x07, 0x06, 0x02, 0x04, 0x0A, 0x06, 0x08, 0x05, 0x05, 0x03, + 0x0A, 0x04, 0x09, 0x06, 0x02, 0x06, 0x13, 0x05, 0x03, 0x02, 0x03, 0x03, + 0x0B, 0x04, 0x07, 0x06, 0x01, 0x06, 0x11, 0x05, 0x04, 0x05, 0x03, 0x03, + 0x0B, 0x05, 0x07, 0x04, 0x01, 0x03, 0x0E, 0x04, 0x04, 0x03, 0x01, 0x01, + 0x0D, 0x05, 0x06, 0x08, 0x01, 0x03, 0x10, 0x03, 0x04, 0x06, 0x04, 0x04, + 0x09, 0x06, 0x07, 0x08, 0x01, 0x04, 0x10, 0x05, 0x07, 0x03, 0x03, 0x09, + 0x05, 0x03, 0x05, 0x03, 0x04, 0x01, 0x04, 0x0B, 0x04, 0x05, 0x06, 0x06, + 0x05, 0x10, 0x06, 0x06, 0x01, 0x01, 0x02, 0x0D, 0x04, 0x0A, 0x0E, 0x03, + 0x07, 0x0A, 0x0A, 0x03, 0x07, 0x04, 0x01, 0x03, 0x01, 0x01, 0x02, 0x04, + 0x09, 0x03, 0x02, 0x02, 0x0A, 0x02, 0x02, 0x09, 0x04, 0x02, 0x02, 0x04, + 0x02, 0x05, 0x02, 0x01, 0x05, 0x04, 0x04, 0x0B, 0x02, 0x03, 0x01, 0x01, + 0x02, 0x03, 0x02, 0x03, 0x03, 0x02, 0x04, 0x03, 0x03, 0x07, 0x02, 0x01, + 0x05, 0x01, 0x07, 0x01, 0x04, 0x01, 0x02, 0x08, 0x01, 0x02, 0x09, 0x09, + 0x01, 0x01, 0x02, 0x03, 0x01, 0x02, 0x04, 0x02, 0x01, 0x01, 0x05, 0x02, + 0x01, 0x04, 0x01, 0x05, 0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, + 0x03, 0x08, 0x1A, 0x17, 0x0D, 0x1B, 0x09, 0x03, 0x04, 0x01, 0x01, 0x08, + 0x0C, 0x0A, 0x14, 0x08, 0x0A, 0x13, 0x0B, 0x0C, 0x13, 0x0A, 0x08, 0x0F, + 0x08, 0x1B, 0x34, 0x1A, 0x0A, 0x05, 0x04, 0x04, 0x18, 0x09, 0x0D, 0x1A, + 0x09, 0x05, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x0C, 0x05, 0x06, 0x09, + 0x02, 0x01, 0x05, 0x01, 0x03, 0x04, 0x02, 0x05, 0x01, 0x01, 0x07, 0x04, + 0x07, 0x12, 0x05, 0x09, 0x19, 0x16, 0x0C, 0x16, 0x0B, 0x11, 0x20, 0x08, + 0x16, 0x25, 0x07, 0x07, 0x0E, 0x0C, 0x06, 0x14, 0x09, 0x03, 0x05, 0x07, + 0x02, 0x06, 0x02, 0x06, 0x0C, 0x05, 0x0C, 0x15, 0x0A, 0x06, 0x0E, 0x09, + 0x05, 0x03, 0x01, 0x03, 0x02, 0x02, 0x08, 0x0C, 0x1B, 0x36, 0x1B, 0x0D, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x08, 0x07, 0x04, 0x0A, 0x06, 0x02, 0x0B, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x06, 0x03, 0x04, 0x15, 0x0C, + 0x05, 0x08, 0x04, 0x02, 0x04, 0x05, 0x16, 0x2B, 0x15, 0x13, 0x24, 0x12, + 0x07, 0x0E, 0x07, 0xFE, 0xAF, 0x0E, 0x20, 0x0B, 0x04, 0x05, 0x08, 0x06, + 0x09, 0x05, 0x03, 0x01, 0x00, 0x01, 0x00, 0x53, 0x01, 0x09, 0x08, 0x53, + 0x02, 0x77, 0x01, 0x8D, 0x00, 0x00, 0x01, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x31, 0x2E, 0x01, 0x27, 0x22, 0x26, 0x27, 0x2E, 0x01, 0x23, 0x30, + 0x31, 0x27, 0x26, 0x06, 0x23, 0x22, 0x06, 0x27, 0x2A, 0x01, 0x23, 0x2E, + 0x01, 0x07, 0x22, 0x06, 0x07, 0x17, 0x30, 0x31, 0x23, 0x2E, 0x01, 0x27, + 0x0E, 0x01, 0x07, 0x30, 0x23, 0x22, 0x23, 0x26, 0x06, 0x23, 0x22, 0x26, + 0x23, 0x31, 0x22, 0x23, 0x2E, 0x01, 0x27, 0x16, 0x14, 0x17, 0x23, 0x31, + 0x14, 0x06, 0x15, 0x2E, 0x01, 0x27, 0x06, 0x26, 0x27, 0x22, 0x26, 0x23, + 0x14, 0x16, 0x15, 0x22, 0x26, 0x15, 0x22, 0x31, 0x23, 0x2E, 0x01, 0x27, + 0x0E, 0x01, 0x07, 0x22, 0x06, 0x27, 0x2E, 0x01, 0x27, 0x22, 0x26, 0x27, + 0x0E, 0x01, 0x15, 0x30, 0x31, 0x23, 0x2E, 0x01, 0x27, 0x06, 0x26, 0x07, + 0x2E, 0x01, 0x27, 0x16, 0x14, 0x15, 0x30, 0x39, 0x01, 0x22, 0x26, 0x23, + 0x2E, 0x01, 0x27, 0x0E, 0x01, 0x07, 0x22, 0x23, 0x15, 0x0E, 0x01, 0x07, + 0x2E, 0x01, 0x27, 0x1E, 0x01, 0x17, 0x2E, 0x01, 0x23, 0x22, 0x06, 0x15, + 0x2A, 0x01, 0x23, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x23, 0x26, 0x22, 0x23, + 0x1C, 0x01, 0x15, 0x30, 0x31, 0x15, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, + 0x30, 0x15, 0x16, 0x15, 0x14, 0x06, 0x23, 0x06, 0x22, 0x23, 0x2E, 0x01, + 0x27, 0x1E, 0x01, 0x17, 0x2A, 0x01, 0x15, 0x2E, 0x01, 0x23, 0x26, 0x22, + 0x07, 0x2A, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x14, 0x16, 0x17, 0x0E, 0x01, + 0x07, 0x22, 0x26, 0x07, 0x2E, 0x01, 0x27, 0x06, 0x22, 0x27, 0x06, 0x22, + 0x07, 0x23, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x15, 0x22, 0x26, 0x23, 0x2A, + 0x01, 0x23, 0x3E, 0x01, 0x35, 0x2E, 0x01, 0x27, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x14, 0x16, 0x17, 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x26, + 0x06, 0x27, 0x06, 0x26, 0x07, 0x2E, 0x01, 0x27, 0x06, 0x26, 0x07, 0x26, + 0x06, 0x07, 0x22, 0x06, 0x07, 0x06, 0x26, 0x07, 0x26, 0x06, 0x27, 0x0E, + 0x01, 0x07, 0x06, 0x14, 0x07, 0x0E, 0x01, 0x07, 0x22, 0x26, 0x23, 0x16, + 0x14, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x17, 0x1E, 0x01, 0x17, 0x16, + 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x17, 0x1E, + 0x01, 0x17, 0x1E, 0x01, 0x37, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, + 0x01, 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, + 0x06, 0x07, 0x06, 0x16, 0x07, 0x32, 0x36, 0x37, 0x34, 0x26, 0x35, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x27, 0x26, 0x36, 0x37, 0x1E, 0x01, 0x17, 0x16, + 0x36, 0x33, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x33, 0x32, + 0x16, 0x17, 0x1E, 0x01, 0x37, 0x16, 0x36, 0x37, 0x16, 0x36, 0x37, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x22, 0x26, 0x27, 0x07, 0xED, 0x17, 0x2E, + 0x16, 0x17, 0x2F, 0x16, 0x03, 0x06, 0x03, 0x01, 0x02, 0x01, 0x02, 0x05, + 0x03, 0x01, 0x07, 0x0E, 0x07, 0x0D, 0x19, 0x0D, 0x01, 0x03, 0x01, 0x02, + 0x04, 0x04, 0x0D, 0x1A, 0x0D, 0x01, 0x01, 0x01, 0x03, 0x01, 0x02, 0x06, + 0x03, 0x01, 0x01, 0x01, 0x04, 0x0B, 0x05, 0x02, 0x05, 0x03, 0x01, 0x01, + 0x04, 0x0B, 0x05, 0x01, 0x01, 0x01, 0x01, 0x03, 0x05, 0x03, 0x05, 0x17, + 0x07, 0x02, 0x05, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x04, 0x02, 0x04, 0x08, 0x04, 0x03, 0x06, 0x03, 0x02, 0x07, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x05, 0x0C, 0x06, 0x06, 0x0C, 0x07, + 0x01, 0x02, 0x04, 0x01, 0x01, 0x01, 0x01, 0x02, 0x04, 0x02, 0x01, 0x01, + 0x03, 0x04, 0x02, 0x09, 0x0D, 0x09, 0x01, 0x04, 0x01, 0x03, 0x0A, 0x03, + 0x01, 0x01, 0x04, 0x08, 0x03, 0x04, 0x06, 0x03, 0x02, 0x04, 0x02, 0x02, + 0x03, 0x02, 0x02, 0x03, 0x01, 0x03, 0x04, 0x02, 0x01, 0x02, 0x01, 0x01, + 0x03, 0x01, 0x09, 0x13, 0x09, 0x01, 0x04, 0x02, 0x01, 0x01, 0x03, 0x06, + 0x03, 0x04, 0x08, 0x04, 0x03, 0x07, 0x04, 0x03, 0x09, 0x04, 0x01, 0x01, + 0x08, 0x10, 0x07, 0x07, 0x0E, 0x07, 0x01, 0x04, 0x01, 0x04, 0x08, 0x03, + 0x01, 0x02, 0x01, 0x03, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x02, + 0x0A, 0x14, 0x0A, 0x04, 0x03, 0x06, 0x0C, 0x06, 0x06, 0x0B, 0x07, 0x07, + 0x0E, 0x07, 0x01, 0x01, 0x05, 0x0B, 0x06, 0x12, 0x28, 0x13, 0x16, 0x2C, + 0x16, 0x11, 0x21, 0x11, 0x3A, 0x74, 0x3A, 0x22, 0x44, 0x23, 0x14, 0x28, + 0x14, 0x09, 0x13, 0x09, 0x09, 0x0E, 0x08, 0x15, 0x29, 0x14, 0x08, 0x14, + 0x03, 0x03, 0x01, 0x05, 0x08, 0x03, 0x03, 0x07, 0x03, 0x01, 0x02, 0x06, + 0x0F, 0x03, 0x05, 0x03, 0x0D, 0x06, 0x11, 0x08, 0x0A, 0x13, 0x09, 0x03, + 0x05, 0x05, 0x0D, 0x1E, 0x0B, 0x12, 0x24, 0x12, 0x1B, 0x37, 0x1B, 0x1C, + 0x38, 0x1C, 0x2C, 0x57, 0x2B, 0x15, 0x2A, 0x14, 0x0C, 0x19, 0x0D, 0x0F, + 0x1C, 0x0E, 0x09, 0x0E, 0x06, 0x0D, 0x18, 0x0B, 0x01, 0x06, 0x02, 0x06, + 0x02, 0x02, 0x09, 0x12, 0x09, 0x01, 0x06, 0x0F, 0x0A, 0x05, 0x0E, 0x01, + 0x01, 0x02, 0x03, 0x12, 0x20, 0x11, 0x0F, 0x1D, 0x0E, 0x06, 0x04, 0x01, + 0x1B, 0x37, 0x1C, 0x1F, 0x3E, 0x20, 0x43, 0x87, 0x43, 0x1F, 0x3F, 0x20, + 0x13, 0x26, 0x13, 0x10, 0x1F, 0x10, 0x22, 0x41, 0x1C, 0x07, 0x12, 0x04, + 0x19, 0x34, 0x19, 0x01, 0xEF, 0x03, 0x06, 0x07, 0x07, 0x10, 0x0B, 0x02, + 0x03, 0x01, 0x01, 0x01, 0x02, 0x03, 0x01, 0x01, 0x04, 0x07, 0x01, 0x03, + 0x04, 0x01, 0x01, 0x01, 0x03, 0x01, 0x03, 0x01, 0x01, 0x02, 0x01, 0x03, + 0x01, 0x01, 0x03, 0x04, 0x01, 0x01, 0x06, 0x02, 0x02, 0x01, 0x01, 0x03, + 0x05, 0x03, 0x0B, 0x08, 0x04, 0x01, 0x02, 0x04, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, 0x01, 0x01, + 0x03, 0x07, 0x03, 0x02, 0x04, 0x03, 0x05, 0x01, 0x01, 0x03, 0x05, 0x03, + 0x02, 0x07, 0x02, 0x02, 0x01, 0x04, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x0A, 0x01, 0x02, 0x08, 0x02, 0x01, 0x03, 0x02, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x08, + 0x03, 0x02, 0x08, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x04, + 0x02, 0x02, 0x05, 0x02, 0x01, 0x03, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x11, + 0x23, 0x11, 0x01, 0x02, 0x01, 0x0A, 0x13, 0x09, 0x06, 0x09, 0x05, 0x04, + 0x07, 0x04, 0x02, 0x04, 0x03, 0x08, 0x03, 0x03, 0x03, 0x01, 0x03, 0x03, + 0x04, 0x03, 0x02, 0x07, 0x01, 0x03, 0x01, 0x05, 0x01, 0x0A, 0x02, 0x02, + 0x02, 0x03, 0x0C, 0x02, 0x01, 0x03, 0x06, 0x02, 0x06, 0x0A, 0x0C, 0x18, + 0x0C, 0x04, 0x09, 0x06, 0x01, 0x07, 0x0E, 0x07, 0x04, 0x05, 0x08, 0x16, + 0x2F, 0x14, 0x07, 0x04, 0x03, 0x04, 0x0A, 0x04, 0x0A, 0x14, 0x09, 0x0A, + 0x0B, 0x0B, 0x02, 0x01, 0x02, 0x04, 0x05, 0x06, 0x02, 0x0B, 0x01, 0x03, + 0x03, 0x03, 0x05, 0x10, 0x09, 0x05, 0x06, 0x02, 0x01, 0x07, 0x03, 0x02, + 0x0B, 0x06, 0x0A, 0x14, 0x0A, 0x07, 0x0C, 0x06, 0x0E, 0x1F, 0x0F, 0x01, + 0x03, 0x03, 0x08, 0x02, 0x0C, 0x16, 0x09, 0x06, 0x0B, 0x09, 0x0E, 0x1C, + 0x0D, 0x04, 0x11, 0x04, 0x01, 0x02, 0x0B, 0x04, 0x03, 0x02, 0x03, 0x01, + 0x01, 0x0F, 0x0D, 0x05, 0x02, 0x01, 0x01, 0x01, 0x05, 0x01, 0x0B, 0x03, + 0x0A, 0x20, 0x17, 0x09, 0x0E, 0x0B, 0x01, 0x04, 0x00, 0x0A, 0x00, 0x50, + 0x01, 0x0D, 0x08, 0x54, 0x02, 0x71, 0x00, 0xF3, 0x00, 0xFF, 0x01, 0x0C, + 0x01, 0x19, 0x01, 0x25, 0x01, 0x32, 0x01, 0x3B, 0x01, 0x44, 0x01, 0x52, + 0x01, 0x68, 0x00, 0x00, 0x01, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, + 0x01, 0x27, 0x26, 0x22, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, + 0x26, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x23, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x07, 0x0E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x23, 0x22, + 0x0E, 0x02, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x06, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x33, + 0x32, 0x16, 0x15, 0x1E, 0x01, 0x17, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, + 0x26, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x06, 0x16, 0x17, 0x1E, 0x01, 0x37, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x32, 0x33, + 0x32, 0x36, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x15, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x27, 0x16, 0x36, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x07, + 0x3E, 0x01, 0x33, 0x32, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x35, + 0x3E, 0x01, 0x17, 0x32, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x0E, 0x01, 0x07, 0x31, 0x05, 0x06, 0x26, 0x37, 0x36, + 0x16, 0x17, 0x16, 0x06, 0x07, 0x06, 0x3F, 0x01, 0x06, 0x26, 0x37, 0x36, + 0x16, 0x17, 0x16, 0x06, 0x07, 0x06, 0x3F, 0x01, 0x25, 0x06, 0x26, 0x37, + 0x36, 0x16, 0x17, 0x16, 0x06, 0x07, 0x06, 0x3F, 0x01, 0x17, 0x06, 0x26, + 0x37, 0x36, 0x16, 0x17, 0x16, 0x06, 0x07, 0x06, 0x37, 0x05, 0x06, 0x26, + 0x37, 0x36, 0x16, 0x17, 0x16, 0x06, 0x07, 0x06, 0x3F, 0x02, 0x06, 0x26, + 0x37, 0x36, 0x16, 0x07, 0x06, 0x36, 0x25, 0x06, 0x26, 0x37, 0x36, 0x16, + 0x07, 0x06, 0x36, 0x17, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x37, 0x36, 0x16, + 0x07, 0x30, 0x37, 0x36, 0x07, 0x25, 0x2E, 0x01, 0x27, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x17, 0x3A, 0x01, 0x17, 0x32, 0x16, 0x17, 0x2E, 0x03, 0x27, + 0x31, 0x08, 0x19, 0x34, 0x65, 0x33, 0x1B, 0x33, 0x18, 0x06, 0x0B, 0x05, + 0x05, 0x05, 0x07, 0x16, 0x2E, 0x17, 0x22, 0x43, 0x22, 0x15, 0x28, 0x14, + 0x1A, 0x33, 0x19, 0x0C, 0x1A, 0x0C, 0x06, 0x0B, 0x05, 0x07, 0x0F, 0x0B, + 0x07, 0x10, 0x08, 0x0B, 0x08, 0x05, 0x08, 0x1D, 0x0F, 0x19, 0x31, 0x1A, + 0x14, 0x27, 0x13, 0x12, 0x20, 0x13, 0x19, 0x30, 0x19, 0x33, 0x67, 0x67, + 0x64, 0x32, 0x25, 0x4A, 0x23, 0x0D, 0x19, 0x0D, 0x0E, 0x1F, 0x0B, 0x04, + 0x08, 0x04, 0x06, 0x0B, 0x04, 0x08, 0x10, 0x08, 0x09, 0x11, 0x0B, 0x0B, + 0x14, 0x0B, 0x19, 0x33, 0x1A, 0x22, 0x47, 0x25, 0x1B, 0x37, 0x1B, 0x1D, + 0x39, 0x1C, 0x2F, 0x5F, 0x2F, 0x19, 0x33, 0x19, 0x0B, 0x16, 0x0A, 0x02, + 0x02, 0x03, 0x05, 0x04, 0x18, 0x29, 0x17, 0x1C, 0x38, 0x1C, 0x30, 0x61, + 0x2F, 0x4B, 0x96, 0x46, 0x25, 0x4B, 0x21, 0x0C, 0x18, 0x09, 0x04, 0x1E, + 0x04, 0x0B, 0x17, 0x11, 0x03, 0x04, 0x02, 0x05, 0x0B, 0x06, 0x1E, 0x43, + 0x20, 0x30, 0x64, 0x32, 0x17, 0x31, 0x17, 0x16, 0x2A, 0x15, 0x21, 0x40, + 0x21, 0x17, 0x31, 0x17, 0x15, 0x2C, 0x16, 0x05, 0x0B, 0x05, 0x05, 0x0D, + 0x04, 0x04, 0x05, 0x02, 0x05, 0x05, 0x02, 0x05, 0x05, 0x01, 0x08, 0x04, + 0x03, 0x10, 0x02, 0x10, 0x0A, 0x09, 0x0E, 0x23, 0x0B, 0x03, 0x04, 0x02, + 0x01, 0x01, 0x01, 0x05, 0x09, 0x06, 0x07, 0x09, 0x03, 0x04, 0x09, 0x05, + 0x05, 0x08, 0x04, 0x03, 0x05, 0x03, 0x03, 0x2D, 0x01, 0x01, 0x04, 0x05, + 0x0B, 0x05, 0x11, 0x22, 0x12, 0x33, 0x67, 0x34, 0x17, 0x2E, 0x18, 0x18, + 0x30, 0x18, 0x1A, 0x34, 0x18, 0x23, 0x40, 0x19, 0x0E, 0x1C, 0x0D, 0x0F, + 0x1D, 0x0F, 0xF8, 0x94, 0x0E, 0x18, 0x13, 0x07, 0x10, 0x01, 0x01, 0x04, + 0x02, 0x02, 0x01, 0x49, 0x0E, 0x19, 0x11, 0x08, 0x10, 0x03, 0x01, 0x04, + 0x02, 0x03, 0x02, 0x01, 0x02, 0x03, 0x0E, 0x1A, 0x10, 0x08, 0x11, 0x03, + 0x02, 0x04, 0x02, 0x03, 0x01, 0x02, 0x47, 0x0D, 0x1A, 0x10, 0x07, 0x11, + 0x03, 0x03, 0x05, 0x02, 0x02, 0x01, 0xFD, 0xF7, 0x0D, 0x1A, 0x10, 0x07, + 0x0F, 0x04, 0x04, 0x04, 0x03, 0x02, 0x01, 0x01, 0x3A, 0x0C, 0x1C, 0x0E, + 0x0C, 0x1C, 0x0E, 0x03, 0x06, 0x02, 0x0D, 0x0E, 0x19, 0x11, 0x0D, 0x14, + 0x0B, 0x03, 0x06, 0x3D, 0x04, 0x08, 0x04, 0x08, 0x09, 0x03, 0x09, 0x24, + 0x0F, 0x01, 0x01, 0x02, 0x01, 0xD2, 0x03, 0x08, 0x03, 0x32, 0x63, 0x32, + 0x21, 0x42, 0x20, 0x0A, 0x13, 0x0A, 0x07, 0x06, 0x06, 0x2E, 0x5E, 0x5D, + 0x5E, 0x2F, 0x02, 0x15, 0x04, 0x07, 0x0E, 0x07, 0x18, 0x0E, 0x04, 0x06, + 0x04, 0x03, 0x02, 0x04, 0x09, 0x02, 0x02, 0x05, 0x02, 0x01, 0x04, 0x02, + 0x03, 0x05, 0x04, 0x03, 0x04, 0x03, 0x01, 0x04, 0x05, 0x08, 0x0B, 0x02, + 0x02, 0x04, 0x01, 0x09, 0x07, 0x0B, 0x11, 0x04, 0x08, 0x11, 0x02, 0x01, + 0x01, 0x06, 0x05, 0x0F, 0x02, 0x02, 0x05, 0x05, 0x0B, 0x14, 0x10, 0x0C, + 0x18, 0x10, 0x06, 0x0E, 0x07, 0x09, 0x12, 0x0D, 0x05, 0x0A, 0x05, 0x06, + 0x0C, 0x05, 0x09, 0x11, 0x08, 0x08, 0x0D, 0x08, 0x08, 0x0D, 0x07, 0x0E, + 0x17, 0x0C, 0x0F, 0x1B, 0x08, 0x06, 0x0D, 0x04, 0x04, 0x08, 0x04, 0x06, + 0x02, 0x03, 0x01, 0x03, 0x01, 0x01, 0x03, 0x10, 0x02, 0x06, 0x0B, 0x05, + 0x02, 0x17, 0x03, 0x03, 0x05, 0x02, 0x04, 0x03, 0x06, 0x09, 0x1F, 0x1E, + 0x10, 0x21, 0x16, 0x08, 0x0F, 0x0A, 0x05, 0x23, 0x05, 0x0C, 0x13, 0x03, + 0x0D, 0x02, 0x06, 0x07, 0x05, 0x13, 0x19, 0x0D, 0x13, 0x1C, 0x0D, 0x06, + 0x02, 0x02, 0x01, 0x04, 0x01, 0x02, 0x03, 0x01, 0x01, 0x08, 0x03, 0x03, + 0x04, 0x03, 0x01, 0x01, 0x01, 0x02, 0x0C, 0x03, 0x09, 0x11, 0x09, 0x0E, + 0x15, 0x0D, 0x03, 0x09, 0x03, 0x03, 0x0B, 0x02, 0x10, 0x30, 0x15, 0x0C, + 0x12, 0x08, 0x03, 0x07, 0x03, 0x02, 0x0A, 0x01, 0x03, 0x07, 0x01, 0x01, + 0x09, 0x06, 0x04, 0x04, 0x01, 0x03, 0x01, 0x08, 0x01, 0x01, 0x04, 0x02, + 0x03, 0x06, 0x01, 0x01, 0x01, 0x02, 0x04, 0x02, 0x06, 0x0D, 0x06, 0x03, + 0x07, 0x02, 0x02, 0x07, 0x01, 0x01, 0x02, 0x09, 0x0D, 0x1F, 0x1D, 0x11, + 0x20, 0x11, 0x02, 0x05, 0x03, 0x6C, 0x0F, 0x24, 0x07, 0x04, 0x08, 0x08, + 0x04, 0x08, 0x04, 0x03, 0x01, 0x1B, 0x0E, 0x20, 0x0B, 0x04, 0x07, 0x08, + 0x05, 0x09, 0x04, 0x02, 0x01, 0x01, 0x7C, 0x0E, 0x1F, 0x0B, 0x05, 0x05, + 0x08, 0x05, 0x0A, 0x05, 0x03, 0x01, 0x02, 0x05, 0x0D, 0x1E, 0x0B, 0x05, + 0x05, 0x08, 0x05, 0x0A, 0x05, 0x02, 0x01, 0xCC, 0x0D, 0x1E, 0x0B, 0x04, + 0x04, 0x06, 0x06, 0x0A, 0x06, 0x03, 0x01, 0x02, 0x19, 0x0D, 0x1A, 0x0C, + 0x0C, 0x19, 0x0C, 0x03, 0x05, 0x51, 0x0E, 0x20, 0x09, 0x06, 0x16, 0x0B, + 0x03, 0x05, 0x09, 0x02, 0x04, 0x01, 0x01, 0x0F, 0x08, 0x13, 0x19, 0x0D, + 0x01, 0x01, 0x02, 0x3F, 0x02, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x01, 0x03, 0x05, 0x01, 0x03, 0x02, 0x03, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x08, 0x00, 0x54, 0x00, 0x86, 0x08, 0x54, 0x02, 0xF5, 0x00, 0x77, + 0x00, 0x90, 0x00, 0xAC, 0x00, 0xCF, 0x01, 0x36, 0x01, 0x4F, 0x01, 0x6B, + 0x01, 0x8D, 0x00, 0x00, 0x01, 0x2E, 0x03, 0x27, 0x2E, 0x01, 0x27, 0x2E, + 0x01, 0x27, 0x2A, 0x01, 0x23, 0x2E, 0x01, 0x23, 0x26, 0x22, 0x27, 0x2E, + 0x01, 0x27, 0x26, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x34, 0x35, 0x26, 0x36, 0x37, 0x3E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x06, 0x14, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, + 0x01, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x26, 0x27, 0x2E, + 0x01, 0x27, 0x26, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x1E, + 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x2E, 0x01, 0x27, 0x26, + 0x1F, 0x01, 0x25, 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x07, + 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x36, 0x37, + 0x36, 0x06, 0x37, 0x13, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, + 0x17, 0x16, 0x06, 0x07, 0x06, 0x3F, 0x02, 0x0E, 0x01, 0x07, 0x06, 0x22, + 0x27, 0x2E, 0x01, 0x27, 0x26, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x07, 0x0E, 0x01, + 0x07, 0x30, 0x37, 0x36, 0x07, 0x25, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, + 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x26, 0x34, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x26, 0x27, + 0x2E, 0x01, 0x37, 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x14, 0x16, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x03, 0x37, 0x2E, 0x01, 0x27, 0x31, 0x25, 0x3E, + 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x07, 0x0E, 0x01, 0x27, 0x2E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x36, 0x37, 0x36, 0x06, 0x37, 0x13, + 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x07, + 0x06, 0x3F, 0x02, 0x0E, 0x01, 0x07, 0x06, 0x22, 0x27, 0x2E, 0x01, 0x27, + 0x26, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x17, 0x16, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x37, 0x36, 0x07, + 0x03, 0xE8, 0x24, 0x51, 0x54, 0x56, 0x2B, 0x1F, 0x3E, 0x20, 0x0A, 0x15, + 0x0A, 0x03, 0x06, 0x03, 0x04, 0x02, 0x04, 0x06, 0x0E, 0x03, 0x04, 0x09, + 0x05, 0x05, 0x07, 0x02, 0x01, 0x04, 0x02, 0x04, 0x0B, 0x0E, 0x13, 0x32, + 0x1C, 0x10, 0x1C, 0x05, 0x03, 0x02, 0x14, 0x09, 0x04, 0x01, 0x05, 0x08, + 0x16, 0x0D, 0x07, 0x1B, 0x0A, 0x08, 0x0C, 0x06, 0x12, 0x22, 0x09, 0x0B, + 0x02, 0x01, 0x05, 0x0B, 0x07, 0x11, 0x08, 0x0A, 0x17, 0x11, 0x12, 0x29, + 0x0B, 0x07, 0x0B, 0x01, 0x01, 0x09, 0x03, 0x04, 0x08, 0x02, 0x03, 0x01, + 0x07, 0x07, 0x25, 0x11, 0x13, 0x1E, 0x0E, 0x09, 0x1C, 0x01, 0x02, 0x01, + 0x07, 0x0A, 0x10, 0x04, 0x0C, 0x24, 0x0E, 0x1F, 0x3D, 0x1F, 0x27, 0x4F, + 0x27, 0x44, 0x80, 0x3C, 0x0D, 0x1A, 0x0F, 0x1D, 0x0F, 0x0E, 0xFC, 0xBA, + 0x03, 0x10, 0x0B, 0x0B, 0x10, 0x08, 0x0A, 0x0F, 0x02, 0x02, 0x08, 0x0A, + 0x08, 0x0E, 0x07, 0x07, 0x0F, 0x04, 0x05, 0x12, 0x04, 0x09, 0x13, 0x0A, + 0x39, 0x0B, 0x0F, 0x0A, 0x07, 0x0B, 0x06, 0x02, 0x08, 0x06, 0x08, 0x10, + 0x08, 0x09, 0x16, 0x05, 0x03, 0x03, 0x02, 0x02, 0x02, 0x01, 0x01, 0x0D, + 0x05, 0x08, 0x04, 0x04, 0x02, 0x0C, 0x18, 0x0D, 0x0C, 0x1F, 0x08, 0x08, + 0x03, 0x01, 0x01, 0x01, 0x02, 0x01, 0x03, 0x07, 0x06, 0x14, 0x07, 0x0D, + 0x1A, 0x0D, 0x10, 0x20, 0x0D, 0x04, 0x03, 0x04, 0x0A, 0x17, 0x0B, 0x0D, + 0x0D, 0x1A, 0x07, 0x62, 0x2F, 0x5F, 0x37, 0x1C, 0x37, 0x1C, 0x21, 0x42, + 0x21, 0x21, 0x46, 0x1D, 0x08, 0x11, 0x08, 0x06, 0x04, 0x03, 0x08, 0x21, + 0x1D, 0x17, 0x39, 0x0E, 0x0B, 0x07, 0x03, 0x09, 0x04, 0x03, 0x0B, 0x04, + 0x06, 0x0E, 0x0A, 0x08, 0x21, 0x0F, 0x07, 0x0B, 0x04, 0x0A, 0x13, 0x09, + 0x0F, 0x16, 0x04, 0x02, 0x02, 0x01, 0x01, 0x07, 0x12, 0x08, 0x11, 0x09, + 0x09, 0x22, 0x19, 0x11, 0x22, 0x07, 0x08, 0x10, 0x06, 0x07, 0x03, 0x04, + 0x07, 0x4D, 0x1D, 0x0E, 0x1A, 0x09, 0x05, 0x01, 0x02, 0x0B, 0x09, 0x04, + 0x07, 0x02, 0x03, 0x13, 0x09, 0x1C, 0x38, 0x1C, 0x27, 0x4F, 0x27, 0x28, + 0x4E, 0x4C, 0x49, 0x23, 0x06, 0x0A, 0x05, 0xFC, 0x98, 0x04, 0x0F, 0x0B, + 0x0B, 0x10, 0x09, 0x09, 0x0E, 0x03, 0x02, 0x07, 0x0B, 0x07, 0x0F, 0x07, + 0x07, 0x0F, 0x04, 0x04, 0x11, 0x04, 0x09, 0x13, 0x0A, 0x39, 0x0B, 0x0F, + 0x09, 0x07, 0x0C, 0x05, 0x03, 0x08, 0x07, 0x07, 0x10, 0x08, 0x0A, 0x15, + 0x05, 0x03, 0x04, 0x01, 0x02, 0x02, 0x01, 0x01, 0x0D, 0x05, 0x08, 0x04, + 0x04, 0x02, 0x0C, 0x18, 0x0D, 0x0C, 0x1F, 0x08, 0x08, 0x02, 0x02, 0x01, + 0x01, 0x02, 0x01, 0x04, 0x07, 0x05, 0x14, 0x07, 0x0D, 0x1A, 0x0D, 0x10, + 0x20, 0x0D, 0x04, 0x03, 0x04, 0x0A, 0x16, 0x0C, 0x0D, 0x0D, 0x1A, 0x01, + 0xE1, 0x18, 0x20, 0x15, 0x0C, 0x04, 0x04, 0x05, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x03, 0x02, 0x05, 0x08, 0x0F, 0x07, 0x07, 0x02, 0x09, 0x09, 0x12, + 0x09, 0x14, 0x24, 0x0F, 0x14, 0x15, 0x08, 0x05, 0x16, 0x11, 0x0A, 0x14, + 0x09, 0x16, 0x29, 0x13, 0x09, 0x0E, 0x09, 0x0F, 0x19, 0x0B, 0x05, 0x13, + 0x09, 0x08, 0x16, 0x0B, 0x1F, 0x42, 0x23, 0x2C, 0x5B, 0x2C, 0x19, 0x36, + 0x16, 0x11, 0x1F, 0x10, 0x14, 0x2D, 0x10, 0x10, 0x2A, 0x0D, 0x08, 0x12, + 0x0B, 0x09, 0x0E, 0x07, 0x0A, 0x15, 0x0B, 0x0F, 0x24, 0x0E, 0x11, 0x12, + 0x01, 0x01, 0x0D, 0x0C, 0x09, 0x1D, 0x0E, 0x0D, 0x26, 0x0B, 0x12, 0x30, + 0x03, 0x08, 0x02, 0x02, 0x02, 0x07, 0x04, 0x05, 0x08, 0x09, 0x0F, 0x36, + 0x22, 0x0B, 0x11, 0x09, 0x14, 0x0A, 0x0A, 0xBB, 0x08, 0x1E, 0x02, 0x02, + 0x0D, 0x07, 0x08, 0x3B, 0x0B, 0x0A, 0x07, 0x04, 0x04, 0x08, 0x03, 0x04, + 0x07, 0x07, 0x08, 0x1D, 0x07, 0x13, 0x25, 0x12, 0xFE, 0x2F, 0x0A, 0x02, + 0x0C, 0x09, 0x13, 0x0A, 0x04, 0x10, 0x05, 0x05, 0x0B, 0x05, 0x06, 0x06, + 0x0C, 0x08, 0x12, 0x08, 0x07, 0x0F, 0x07, 0x07, 0x0A, 0x04, 0x07, 0x04, + 0x03, 0xB8, 0x0B, 0x15, 0x0B, 0x0B, 0x14, 0x14, 0x2E, 0x16, 0x0F, 0x20, + 0x0F, 0x0B, 0x1A, 0x08, 0x07, 0x04, 0x06, 0x0B, 0x17, 0x0B, 0x0D, 0x1D, + 0x10, 0x06, 0x07, 0x04, 0x0D, 0x16, 0x0B, 0x0D, 0x0C, 0x19, 0x4A, 0x1C, + 0x2F, 0x0C, 0x06, 0x0C, 0x03, 0x03, 0x08, 0x02, 0x02, 0x01, 0x0C, 0x03, + 0x2F, 0x13, 0x0C, 0x20, 0x0D, 0x1E, 0x2A, 0x0C, 0x0A, 0x0F, 0x16, 0x12, + 0x34, 0x13, 0x09, 0x12, 0x09, 0x07, 0x15, 0x07, 0x0B, 0x16, 0x09, 0x09, + 0x1D, 0x03, 0x01, 0x14, 0x05, 0x11, 0x24, 0x12, 0x1E, 0x3C, 0x21, 0x17, + 0x2D, 0x17, 0x28, 0x53, 0x24, 0x11, 0x21, 0x11, 0x10, 0x3E, 0x0C, 0x09, + 0x25, 0x12, 0x12, 0x1C, 0x11, 0x12, 0x23, 0x13, 0x26, 0x15, 0x14, 0x09, + 0x1C, 0x0F, 0x09, 0x14, 0x09, 0x06, 0x2E, 0x10, 0x07, 0x0C, 0x08, 0x09, + 0x04, 0x01, 0x04, 0x04, 0x04, 0x05, 0x0A, 0x05, 0x05, 0x15, 0x1E, 0x24, + 0x13, 0x04, 0x09, 0x04, 0xCF, 0x08, 0x1E, 0x02, 0x02, 0x0D, 0x07, 0x08, + 0x3B, 0x0B, 0x0A, 0x07, 0x04, 0x04, 0x08, 0x03, 0x04, 0x07, 0x07, 0x08, + 0x1D, 0x07, 0x13, 0x25, 0x12, 0xFE, 0x2F, 0x0A, 0x02, 0x0C, 0x09, 0x13, + 0x0A, 0x04, 0x10, 0x05, 0x05, 0x0B, 0x05, 0x06, 0x06, 0x0C, 0x08, 0x12, + 0x08, 0x07, 0x0F, 0x07, 0x07, 0x0A, 0x04, 0x07, 0x04, 0x03, 0xB8, 0x0B, + 0x15, 0x0B, 0x0B, 0x14, 0x14, 0x2E, 0x16, 0x0F, 0x20, 0x0F, 0x0B, 0x1A, + 0x08, 0x07, 0x04, 0x06, 0x0B, 0x17, 0x0B, 0x0D, 0x1D, 0x10, 0x06, 0x07, + 0x04, 0x0D, 0x16, 0x0B, 0x0D, 0x0C, 0x19, 0x00, 0x00, 0x02, 0x00, 0x5D, + 0x00, 0x26, 0x06, 0x16, 0x03, 0x5B, 0x00, 0xC2, 0x00, 0xDE, 0x00, 0x00, + 0x01, 0x2E, 0x01, 0x35, 0x3E, 0x01, 0x23, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x23, 0x22, 0x26, 0x07, 0x0E, 0x01, + 0x07, 0x22, 0x06, 0x27, 0x26, 0x36, 0x23, 0x2A, 0x01, 0x23, 0x2E, 0x01, + 0x23, 0x2A, 0x01, 0x27, 0x22, 0x06, 0x23, 0x22, 0x26, 0x23, 0x2E, 0x01, + 0x23, 0x2E, 0x01, 0x23, 0x22, 0x26, 0x23, 0x22, 0x06, 0x23, 0x22, 0x06, + 0x07, 0x22, 0x06, 0x27, 0x2E, 0x01, 0x23, 0x22, 0x26, 0x07, 0x06, 0x16, + 0x07, 0x0E, 0x01, 0x07, 0x06, 0x22, 0x23, 0x2A, 0x01, 0x27, 0x2E, 0x01, + 0x23, 0x0E, 0x01, 0x07, 0x06, 0x16, 0x15, 0x14, 0x16, 0x17, 0x1E, 0x01, + 0x17, 0x16, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x16, + 0x33, 0x32, 0x16, 0x33, 0x32, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x06, + 0x15, 0x14, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x17, 0x14, 0x16, 0x17, 0x1E, 0x01, 0x33, 0x1E, 0x01, 0x37, 0x3E, 0x01, + 0x33, 0x2E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x37, 0x36, 0x16, 0x33, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x35, 0x34, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x33, 0x3A, 0x01, + 0x33, 0x3A, 0x03, 0x33, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x27, 0x01, 0x06, 0x22, 0x23, 0x22, 0x06, 0x27, 0x2E, 0x01, 0x27, 0x2E, + 0x01, 0x35, 0x3C, 0x01, 0x35, 0x34, 0x36, 0x33, 0x3A, 0x01, 0x33, 0x32, + 0x16, 0x15, 0x14, 0x16, 0x07, 0x06, 0x14, 0x01, 0x03, 0x01, 0x01, 0x0D, + 0x04, 0x15, 0x01, 0x02, 0x09, 0x0B, 0x0B, 0x13, 0x0A, 0x08, 0x0B, 0x0A, + 0x08, 0x1F, 0x07, 0x03, 0x02, 0x02, 0x01, 0x0F, 0x01, 0x04, 0x05, 0x08, + 0x07, 0x0D, 0x07, 0x37, 0x6E, 0x37, 0x11, 0x23, 0x11, 0x05, 0x03, 0x03, + 0x07, 0x0C, 0x06, 0x2F, 0x5D, 0x2F, 0x16, 0x2C, 0x16, 0x0C, 0x0A, 0x0A, + 0x32, 0x63, 0x32, 0x0F, 0x17, 0x10, 0x08, 0x17, 0x06, 0x04, 0x14, 0x05, + 0x06, 0x22, 0x05, 0x05, 0x08, 0x05, 0x0F, 0x20, 0x09, 0x06, 0x0E, 0x0D, + 0x04, 0x09, 0x03, 0x02, 0x08, 0x02, 0x04, 0x10, 0x03, 0x01, 0x01, 0x0C, + 0x04, 0x05, 0x0A, 0x02, 0x03, 0x05, 0x02, 0x04, 0x17, 0x10, 0x11, 0x24, + 0x0B, 0x0B, 0x08, 0x0F, 0x0A, 0x13, 0x09, 0x12, 0x25, 0x11, 0x1A, 0x1B, + 0x06, 0x03, 0x03, 0x08, 0x02, 0x06, 0x0A, 0x06, 0x10, 0x1B, 0x0C, 0x0A, + 0x0A, 0x01, 0x09, 0x0F, 0x07, 0x0E, 0x07, 0x2E, 0x58, 0x2E, 0x24, 0x4A, + 0x25, 0x04, 0x12, 0x03, 0x03, 0x06, 0x03, 0x05, 0x0D, 0x05, 0x04, 0x0B, + 0x18, 0x0D, 0x2B, 0x0F, 0x15, 0x28, 0x14, 0x0B, 0x15, 0x0A, 0x0D, 0x0B, + 0x05, 0x08, 0x06, 0x14, 0x0E, 0x0C, 0x1B, 0x11, 0x21, 0x43, 0x21, 0x33, + 0x67, 0x67, 0x67, 0x34, 0x0A, 0x0E, 0x04, 0x07, 0x0D, 0x05, 0x04, 0x10, + 0x02, 0xFD, 0x03, 0x08, 0x22, 0x11, 0x0D, 0x25, 0x0D, 0x0B, 0x09, 0x04, + 0x02, 0x01, 0x28, 0x11, 0x11, 0x21, 0x11, 0x1C, 0x02, 0x02, 0x07, 0x02, + 0xEE, 0x0A, 0x14, 0x0B, 0x0B, 0x0D, 0x02, 0x04, 0x04, 0x0A, 0x0E, 0x03, + 0x03, 0x0C, 0x06, 0x05, 0x01, 0x04, 0x04, 0x02, 0x0A, 0x02, 0x01, 0x01, + 0x04, 0x0C, 0x01, 0x01, 0x01, 0x0D, 0x05, 0x01, 0x02, 0x01, 0x01, 0x0F, + 0x01, 0x0A, 0x01, 0x03, 0x06, 0x04, 0x18, 0x04, 0x04, 0x04, 0x1B, 0x04, + 0x08, 0x17, 0x0F, 0x0C, 0x02, 0x01, 0x06, 0x01, 0x02, 0x03, 0x02, 0x0F, + 0x03, 0x08, 0x13, 0x07, 0x08, 0x0D, 0x0A, 0x09, 0x13, 0x0A, 0x11, 0x07, + 0x05, 0x05, 0x10, 0x0F, 0x0F, 0x0A, 0x01, 0x01, 0x03, 0x04, 0x1C, 0x19, + 0x0E, 0x18, 0x0E, 0x06, 0x0F, 0x06, 0x0C, 0x19, 0x0D, 0x25, 0x4C, 0x26, + 0x1D, 0x3C, 0x1E, 0x0B, 0x23, 0x02, 0x01, 0x01, 0x02, 0x01, 0x03, 0x02, + 0x0D, 0x0A, 0x24, 0x0B, 0x0F, 0x1D, 0x0F, 0x1F, 0x3D, 0x1F, 0x1B, 0x2E, + 0x11, 0x0A, 0x11, 0x02, 0x01, 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x0D, + 0x15, 0x2D, 0x14, 0x0F, 0x28, 0x09, 0x09, 0x16, 0x02, 0x0B, 0x13, 0x27, + 0x13, 0x10, 0x27, 0x10, 0xFE, 0xCD, 0x12, 0x04, 0x04, 0x04, 0x05, 0x0B, + 0x06, 0x09, 0x07, 0x13, 0x25, 0x12, 0x1A, 0x03, 0x31, 0x13, 0x0F, 0x1F, + 0x0D, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x4F, 0x00, 0x25, 0x09, 0x93, + 0x03, 0x5A, 0x00, 0x91, 0x01, 0x0C, 0x01, 0x2C, 0x01, 0x4A, 0x00, 0x00, + 0x01, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, + 0x17, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x07, 0x0E, 0x01, 0x17, 0x23, 0x0E, + 0x01, 0x07, 0x06, 0x26, 0x23, 0x06, 0x26, 0x23, 0x22, 0x26, 0x23, 0x22, + 0x26, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x16, 0x17, 0x07, 0x15, 0x0E, 0x01, + 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x0F, 0x01, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x15, 0x14, 0x16, 0x17, 0x14, 0x06, 0x07, 0x06, + 0x26, 0x23, 0x22, 0x06, 0x2F, 0x01, 0x2E, 0x01, 0x35, 0x2E, 0x01, 0x27, + 0x34, 0x26, 0x27, 0x36, 0x26, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x36, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x2E, 0x01, 0x35, 0x3E, 0x01, 0x37, + 0x36, 0x16, 0x17, 0x3E, 0x01, 0x37, 0x35, 0x36, 0x16, 0x17, 0x32, 0x16, + 0x15, 0x17, 0x32, 0x36, 0x33, 0x16, 0x32, 0x17, 0x32, 0x36, 0x1F, 0x01, + 0x21, 0x35, 0x17, 0x2E, 0x01, 0x35, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, + 0x3E, 0x01, 0x33, 0x35, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x32, 0x36, + 0x1F, 0x01, 0x21, 0x35, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x1E, + 0x01, 0x07, 0x0E, 0x01, 0x17, 0x23, 0x07, 0x06, 0x26, 0x23, 0x22, 0x26, + 0x27, 0x26, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x14, 0x06, 0x15, 0x14, 0x16, + 0x0F, 0x01, 0x15, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x14, 0x16, 0x07, 0x06, 0x26, 0x23, 0x2A, 0x01, 0x23, + 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x35, 0x3E, 0x01, 0x35, 0x2E, 0x01, + 0x27, 0x35, 0x27, 0x34, 0x26, 0x37, 0x34, 0x36, 0x37, 0x33, 0x3E, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x37, 0x3E, + 0x01, 0x33, 0x3E, 0x01, 0x27, 0x05, 0x2A, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x06, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x33, 0x3E, 0x01, 0x37, 0x36, 0x26, 0x27, 0x2E, 0x01, 0x27, + 0x23, 0x05, 0x22, 0x26, 0x07, 0x23, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x17, + 0x33, 0x17, 0x1E, 0x01, 0x17, 0x32, 0x16, 0x17, 0x3E, 0x01, 0x3F, 0x01, + 0x27, 0x2E, 0x01, 0x27, 0x2A, 0x01, 0x23, 0x04, 0x88, 0x03, 0x09, 0x05, + 0x05, 0x0E, 0x09, 0x07, 0x0D, 0x06, 0x04, 0x0B, 0x01, 0x02, 0x07, 0x03, + 0x03, 0x08, 0x01, 0x02, 0x06, 0x01, 0x51, 0x02, 0x03, 0x02, 0x0B, 0x1C, + 0x0B, 0x0F, 0x1D, 0x0F, 0x1A, 0x35, 0x1A, 0x0E, 0x1D, 0x0E, 0x17, 0x20, + 0x10, 0x16, 0x02, 0x02, 0x0A, 0x1C, 0x3E, 0x1E, 0x13, 0x21, 0x13, 0x16, + 0x34, 0x15, 0x17, 0x0A, 0x08, 0x05, 0x08, 0x11, 0x09, 0x04, 0x06, 0x05, + 0x03, 0x07, 0x08, 0x17, 0x40, 0x1A, 0x1F, 0x3E, 0x1C, 0x0C, 0x01, 0x01, + 0x14, 0x20, 0x12, 0x02, 0x02, 0x01, 0x05, 0x02, 0x02, 0x09, 0x01, 0x10, + 0x1D, 0x0E, 0x08, 0x10, 0x09, 0x0D, 0x0F, 0x10, 0x0A, 0x3A, 0x14, 0x0A, + 0x03, 0x03, 0x06, 0x15, 0x08, 0x15, 0x18, 0x08, 0x02, 0x05, 0x02, 0x04, + 0x04, 0x0F, 0x19, 0x0E, 0x0E, 0x1D, 0x10, 0x0C, 0x17, 0x0C, 0x04, 0x03, + 0x04, 0x1F, 0x3D, 0x1F, 0x12, 0x25, 0x13, 0x0D, 0x22, 0x0D, 0x08, 0x02, + 0x11, 0xD6, 0x01, 0x03, 0x02, 0x06, 0x04, 0x0F, 0x17, 0x0E, 0x0F, 0x1E, + 0x10, 0x0C, 0x18, 0x0C, 0x07, 0x03, 0x01, 0x3F, 0x80, 0x40, 0x09, 0x02, + 0x0E, 0x03, 0x04, 0x09, 0x02, 0x16, 0x2E, 0x06, 0x03, 0x0B, 0x0C, 0x02, + 0x04, 0x01, 0x55, 0x04, 0x16, 0x37, 0x17, 0x1B, 0x36, 0x1C, 0x21, 0x38, + 0x1A, 0x0C, 0x18, 0x02, 0x02, 0x08, 0x05, 0x0A, 0x1F, 0x45, 0x22, 0x27, + 0x65, 0x22, 0x11, 0x0C, 0x07, 0x08, 0x0D, 0x0B, 0x11, 0x16, 0x15, 0x31, + 0x17, 0x1E, 0x3C, 0x1D, 0x02, 0x05, 0x0B, 0x05, 0x09, 0x08, 0x02, 0x02, + 0x13, 0x23, 0x12, 0x02, 0x05, 0x01, 0x09, 0x05, 0x02, 0x08, 0x21, 0x0D, + 0x0F, 0x26, 0x06, 0x0D, 0x0A, 0x3A, 0x14, 0x09, 0x01, 0x07, 0x06, 0x15, + 0x07, 0x19, 0x1F, 0x07, 0xFD, 0x33, 0x11, 0x23, 0x11, 0x13, 0x1C, 0x11, + 0x07, 0x09, 0x02, 0x06, 0x05, 0x02, 0x06, 0x0C, 0x06, 0x0F, 0x1D, 0x11, + 0x0E, 0x1D, 0x0F, 0x2F, 0x33, 0x04, 0x02, 0x01, 0x08, 0x05, 0x11, 0x0D, + 0x35, 0x04, 0x74, 0x0D, 0x21, 0x0B, 0x04, 0x0D, 0x19, 0x05, 0x02, 0x03, + 0x07, 0x03, 0x14, 0x0F, 0x1D, 0x11, 0x0F, 0x1E, 0x0F, 0x2F, 0x31, 0x03, + 0x04, 0x09, 0x05, 0x12, 0x0D, 0x19, 0x32, 0x19, 0x03, 0x2E, 0x06, 0x0A, + 0x04, 0x06, 0x04, 0x01, 0x02, 0x03, 0x02, 0x06, 0x04, 0x08, 0x0D, 0x19, + 0x0D, 0x08, 0x1F, 0x0A, 0x1A, 0x36, 0x1A, 0x03, 0x06, 0x02, 0x05, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x03, 0x05, 0x19, 0x0F, 0x14, 0x35, 0x19, 0x0A, + 0x02, 0x0B, 0x15, 0x02, 0x01, 0x02, 0x02, 0x03, 0x0A, 0x05, 0x0D, 0x0D, + 0x19, 0x10, 0x1C, 0x39, 0x1C, 0x0F, 0x1A, 0x10, 0x14, 0x27, 0x14, 0x11, + 0x19, 0x08, 0x0E, 0x05, 0x03, 0x0C, 0x0F, 0x0B, 0x15, 0x0A, 0x02, 0x05, + 0x0A, 0x02, 0x06, 0x02, 0x10, 0x1F, 0x0F, 0x12, 0x24, 0x12, 0x20, 0x41, + 0x21, 0x13, 0x27, 0x13, 0x19, 0x2C, 0x1C, 0x14, 0x07, 0x04, 0x0A, 0x13, + 0x0C, 0x06, 0x06, 0x01, 0x14, 0x29, 0x1C, 0x0D, 0x1B, 0x0E, 0x06, 0x08, + 0x01, 0x01, 0x05, 0x03, 0x06, 0x0C, 0x01, 0x1B, 0x01, 0x03, 0x02, 0x03, + 0x02, 0x18, 0x04, 0x01, 0x01, 0x01, 0x03, 0x0D, 0x03, 0x2E, 0x08, 0x0F, + 0x08, 0x07, 0x07, 0x01, 0x02, 0x05, 0x02, 0x03, 0x10, 0x19, 0x01, 0x03, + 0x02, 0x06, 0x0F, 0x09, 0x02, 0x02, 0x0A, 0x01, 0x05, 0x03, 0x07, 0x05, + 0x13, 0x1B, 0x16, 0x0E, 0x31, 0x0B, 0x1E, 0x3C, 0x1E, 0x09, 0x08, 0x04, + 0x01, 0x01, 0x01, 0x0A, 0x17, 0x0A, 0x18, 0x11, 0x06, 0x0D, 0x07, 0x06, + 0x19, 0x04, 0x0B, 0x04, 0x0C, 0x13, 0x02, 0x02, 0x1A, 0x19, 0x14, 0x35, + 0x19, 0x1A, 0x38, 0x19, 0x23, 0x52, 0x20, 0x0B, 0x03, 0x02, 0x01, 0x03, + 0x02, 0x05, 0x14, 0x10, 0x04, 0x09, 0x04, 0x03, 0x04, 0x09, 0x06, 0x05, + 0x0E, 0x19, 0x0E, 0x14, 0x25, 0x13, 0x21, 0x41, 0x1E, 0x22, 0x4A, 0x24, + 0x25, 0x14, 0x09, 0x02, 0x07, 0x1B, 0x08, 0x05, 0x09, 0x17, 0x33, 0x24, + 0xBA, 0x01, 0x01, 0x05, 0x08, 0x05, 0x0B, 0x06, 0x0C, 0x19, 0x0C, 0x06, + 0x0B, 0x06, 0x04, 0x0D, 0x01, 0x01, 0x01, 0x07, 0x17, 0x10, 0x0E, 0x18, + 0x0D, 0x09, 0x10, 0x07, 0x06, 0x03, 0x05, 0x07, 0x0D, 0x0E, 0x0D, 0x1A, + 0x0C, 0x14, 0x06, 0x0D, 0x01, 0x01, 0x01, 0x06, 0x18, 0x12, 0x13, 0x20, + 0x09, 0x0F, 0x06, 0x00, 0x00, 0x02, 0x00, 0x57, 0x00, 0x24, 0x04, 0xD4, + 0x03, 0x5A, 0x00, 0x98, 0x00, 0xB7, 0x00, 0x00, 0x01, 0x2E, 0x01, 0x27, + 0x26, 0x06, 0x23, 0x22, 0x06, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, + 0x22, 0x06, 0x27, 0x2E, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x03, 0x23, + 0x2A, 0x01, 0x23, 0x22, 0x06, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x16, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x16, 0x17, + 0x16, 0x14, 0x15, 0x14, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x15, 0x14, 0x16, 0x17, 0x16, 0x36, 0x37, + 0x3E, 0x01, 0x37, 0x32, 0x36, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x36, 0x35, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x36, 0x34, 0x37, 0x3E, 0x01, 0x17, 0x16, 0x32, 0x37, 0x36, 0x16, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x34, 0x27, 0x2E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x36, 0x16, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x37, + 0x36, 0x16, 0x17, 0x36, 0x34, 0x37, 0x34, 0x36, 0x35, 0x3E, 0x01, 0x37, + 0x34, 0x26, 0x27, 0x01, 0x1C, 0x01, 0x15, 0x14, 0x26, 0x23, 0x2A, 0x01, + 0x23, 0x22, 0x06, 0x27, 0x26, 0x36, 0x35, 0x3C, 0x01, 0x35, 0x34, 0x32, + 0x33, 0x3A, 0x01, 0x33, 0x32, 0x16, 0x17, 0x16, 0x06, 0x15, 0x04, 0xCE, + 0x02, 0x0C, 0x0C, 0x05, 0x0A, 0x05, 0x04, 0x0C, 0x07, 0x14, 0x2A, 0x15, + 0x33, 0x66, 0x32, 0x03, 0x0A, 0x02, 0x03, 0x05, 0x03, 0x0C, 0x17, 0x0C, + 0x35, 0x69, 0x6A, 0x69, 0x35, 0x12, 0x25, 0x13, 0x08, 0x0F, 0x07, 0x18, + 0x30, 0x1B, 0x0C, 0x07, 0x06, 0x0A, 0x14, 0x06, 0x0C, 0x09, 0x05, 0x04, + 0x0A, 0x01, 0x02, 0x48, 0x1C, 0x12, 0x08, 0x03, 0x04, 0x08, 0x04, 0x06, + 0x0B, 0x05, 0x0B, 0x12, 0x07, 0x05, 0x06, 0x0D, 0x0D, 0x0E, 0x2E, 0x13, + 0x27, 0x4D, 0x27, 0x11, 0x2E, 0x08, 0x01, 0x07, 0x03, 0x02, 0x05, 0x03, + 0x04, 0x02, 0x04, 0x09, 0x05, 0x02, 0x06, 0x02, 0x01, 0x0A, 0x01, 0x02, + 0x11, 0x0C, 0x14, 0x10, 0x0C, 0x16, 0x0B, 0x26, 0x4B, 0x25, 0x15, 0x24, + 0x07, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x04, 0x09, 0x0E, 0x24, 0x10, + 0x0D, 0x1E, 0x0D, 0x32, 0x65, 0x32, 0x0F, 0x09, 0x03, 0x02, 0x3A, 0x08, + 0x03, 0x01, 0x0A, 0x01, 0x01, 0x01, 0x01, 0x05, 0xFE, 0x20, 0x2C, 0x0C, + 0x1C, 0x38, 0x1C, 0x0C, 0x2C, 0x0B, 0x08, 0x02, 0x25, 0x0D, 0x2C, 0x58, + 0x2B, 0x04, 0x07, 0x02, 0x05, 0x02, 0x03, 0x30, 0x09, 0x1E, 0x02, 0x01, + 0x01, 0x23, 0x01, 0x02, 0x03, 0x03, 0x01, 0x05, 0x0F, 0x06, 0x02, 0x01, + 0x13, 0x05, 0x07, 0x0F, 0x0C, 0x15, 0x34, 0x17, 0x12, 0x21, 0x11, 0x2A, + 0x22, 0x0D, 0x09, 0x16, 0x10, 0x09, 0x12, 0x08, 0x0C, 0x16, 0x0C, 0x11, + 0x25, 0x12, 0x24, 0x49, 0x25, 0x17, 0x31, 0x18, 0x10, 0x19, 0x0C, 0x0F, + 0x05, 0x01, 0x01, 0x05, 0x01, 0x0F, 0x18, 0x04, 0x07, 0x03, 0x02, 0x0C, + 0x02, 0x09, 0x11, 0x09, 0x12, 0x23, 0x12, 0x09, 0x14, 0x0A, 0x08, 0x0F, + 0x08, 0x14, 0x38, 0x0D, 0x09, 0x05, 0x02, 0x01, 0x01, 0x01, 0x09, 0x06, + 0x03, 0x16, 0x15, 0x0B, 0x18, 0x0C, 0x08, 0x11, 0x08, 0x0A, 0x13, 0x05, + 0x09, 0x15, 0x03, 0x02, 0x02, 0x1F, 0x0C, 0x06, 0x03, 0x03, 0x06, 0x0C, + 0x06, 0x06, 0x05, 0x06, 0x0B, 0x18, 0x0B, 0x1A, 0x31, 0x19, 0xFE, 0xCC, + 0x0A, 0x15, 0x0A, 0x13, 0x02, 0x05, 0x07, 0x05, 0x1E, 0x07, 0x0C, 0x16, + 0x0B, 0x14, 0x03, 0x04, 0x08, 0x1B, 0x09, 0x00, 0x00, 0x02, 0x00, 0x4B, + 0x00, 0x26, 0x05, 0x73, 0x03, 0x5A, 0x00, 0x94, 0x00, 0xA7, 0x00, 0x00, + 0x01, 0x14, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x23, 0x0E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x06, 0x16, 0x17, 0x1E, 0x01, 0x15, 0x14, 0x06, + 0x23, 0x0E, 0x01, 0x27, 0x22, 0x06, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x0E, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x3E, 0x01, + 0x37, 0x22, 0x26, 0x27, 0x26, 0x36, 0x37, 0x1C, 0x01, 0x15, 0x3E, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x26, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x27, 0x3C, 0x01, 0x35, 0x3C, 0x01, 0x35, 0x34, 0x26, + 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x17, 0x32, 0x16, + 0x17, 0x16, 0x36, 0x33, 0x3A, 0x03, 0x33, 0x3A, 0x03, 0x33, 0x3A, 0x01, + 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, + 0x17, 0x1E, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x06, 0x17, 0x1E, 0x01, + 0x17, 0x05, 0x2A, 0x01, 0x23, 0x22, 0x06, 0x15, 0x14, 0x06, 0x33, 0x3A, + 0x01, 0x33, 0x32, 0x36, 0x35, 0x34, 0x36, 0x23, 0x05, 0x73, 0x0A, 0x21, + 0x14, 0x28, 0x14, 0x27, 0x4F, 0x27, 0x16, 0x2A, 0x16, 0x0C, 0x36, 0x02, + 0x03, 0x02, 0x04, 0x01, 0x06, 0x12, 0x02, 0x28, 0x51, 0x28, 0x13, 0x29, + 0x13, 0x0B, 0x16, 0x0B, 0x0A, 0x0D, 0x0B, 0x11, 0x19, 0x09, 0x14, 0x1C, + 0x0E, 0x08, 0x0F, 0x08, 0x07, 0x16, 0x02, 0x01, 0x10, 0x0D, 0x06, 0x0D, + 0x06, 0x3E, 0x7B, 0x3E, 0x01, 0x03, 0x02, 0x14, 0x28, 0x0D, 0x0E, 0x0D, + 0x06, 0x19, 0x2B, 0x16, 0x0B, 0x18, 0x0C, 0x0B, 0x0F, 0x08, 0x11, 0x04, + 0x28, 0x0B, 0x15, 0x0A, 0x0A, 0x06, 0x01, 0x07, 0x04, 0x04, 0x1C, 0x07, + 0x0E, 0x0A, 0x06, 0x06, 0x0A, 0x0D, 0x0D, 0x07, 0x02, 0x01, 0x0E, 0x02, + 0x2B, 0x54, 0x54, 0x54, 0x2A, 0x3A, 0x74, 0x73, 0x74, 0x3A, 0x26, 0x4C, + 0x25, 0x09, 0x11, 0x08, 0x03, 0x01, 0x01, 0x02, 0x0A, 0x05, 0x08, 0x02, + 0x06, 0x06, 0x01, 0x08, 0x07, 0x0F, 0x08, 0x07, 0x01, 0x01, 0x01, 0x04, + 0x02, 0xFE, 0x03, 0x28, 0x4E, 0x28, 0x11, 0x0D, 0x02, 0x11, 0x28, 0x50, + 0x28, 0x0D, 0x0F, 0x03, 0x12, 0x02, 0xC0, 0x18, 0x4C, 0x03, 0x02, 0x03, + 0x01, 0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x04, 0x11, 0x13, 0x28, 0x14, + 0x08, 0x12, 0x08, 0x03, 0x16, 0x05, 0x04, 0x02, 0x01, 0x03, 0x02, 0x03, + 0x02, 0x02, 0x07, 0x02, 0x04, 0x27, 0x0D, 0x1F, 0x44, 0x22, 0x15, 0x29, + 0x14, 0x16, 0x32, 0x16, 0x0E, 0x13, 0x08, 0x0F, 0x08, 0x07, 0x14, 0x16, + 0x37, 0x18, 0x01, 0x01, 0x01, 0x20, 0x44, 0x22, 0x11, 0x20, 0x11, 0x10, + 0x29, 0x12, 0x25, 0x5B, 0x17, 0x05, 0x0A, 0x05, 0x06, 0x19, 0x0A, 0x14, + 0x29, 0x14, 0x08, 0x11, 0x08, 0x07, 0x0B, 0x07, 0x08, 0x02, 0x01, 0x01, + 0x03, 0x0B, 0x0A, 0x02, 0x01, 0x09, 0x0D, 0x03, 0x01, 0x01, 0x02, 0x04, + 0x03, 0x01, 0x03, 0x01, 0x03, 0x02, 0x04, 0x15, 0x06, 0x1B, 0x34, 0x1B, + 0x7D, 0x10, 0x12, 0x09, 0x3F, 0x0D, 0x10, 0x09, 0x44, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x55, 0x00, 0x25, 0x04, 0x97, 0x03, 0x5A, 0x00, 0x93, + 0x00, 0xC4, 0x00, 0x00, 0x01, 0x2E, 0x01, 0x27, 0x34, 0x26, 0x27, 0x26, + 0x22, 0x23, 0x2A, 0x01, 0x23, 0x06, 0x22, 0x23, 0x2A, 0x01, 0x23, 0x22, + 0x16, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, + 0x36, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, + 0x26, 0x27, 0x26, 0x22, 0x23, 0x22, 0x26, 0x07, 0x0E, 0x01, 0x07, 0x06, + 0x26, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x17, 0x1E, + 0x01, 0x17, 0x1E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, + 0x01, 0x17, 0x16, 0x36, 0x27, 0x2E, 0x01, 0x27, 0x34, 0x26, 0x27, 0x2E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x33, 0x16, 0x32, 0x33, 0x1E, + 0x01, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, + 0x01, 0x35, 0x34, 0x36, 0x37, 0x36, 0x16, 0x37, 0x32, 0x36, 0x33, 0x36, + 0x32, 0x37, 0x32, 0x36, 0x35, 0x3E, 0x01, 0x27, 0x05, 0x06, 0x14, 0x07, + 0x06, 0x26, 0x27, 0x2E, 0x01, 0x07, 0x06, 0x26, 0x35, 0x34, 0x36, 0x37, + 0x3E, 0x01, 0x17, 0x32, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x37, + 0x36, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x36, 0x33, + 0x16, 0x32, 0x33, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x07, 0x04, 0x96, 0x01, + 0x02, 0x01, 0x01, 0x0A, 0x0C, 0x16, 0x0D, 0x19, 0x32, 0x19, 0x34, 0x68, + 0x34, 0x04, 0x08, 0x03, 0x01, 0x01, 0x01, 0x02, 0x05, 0x03, 0x1A, 0x35, + 0x1A, 0x09, 0x14, 0x09, 0x05, 0x05, 0x04, 0x0E, 0x1E, 0x0E, 0x3C, 0x78, + 0x3C, 0x0F, 0x1D, 0x0F, 0x02, 0x02, 0x02, 0x02, 0x0F, 0x03, 0x03, 0x0D, + 0x03, 0x04, 0x04, 0x04, 0x09, 0x19, 0x0A, 0x09, 0x12, 0x06, 0x0B, 0x1C, + 0x03, 0x03, 0x01, 0x12, 0x11, 0x2C, 0x12, 0x14, 0x0A, 0x05, 0x03, 0x09, + 0x05, 0x0A, 0x16, 0x0B, 0x0F, 0x16, 0x09, 0x09, 0x10, 0x03, 0x01, 0x17, + 0x0D, 0x1B, 0x35, 0x1B, 0x30, 0x62, 0x30, 0x09, 0x32, 0x16, 0x05, 0x19, + 0x01, 0x02, 0x01, 0x01, 0x02, 0x05, 0x0A, 0x17, 0x0C, 0x03, 0x1C, 0x05, + 0x08, 0x0F, 0x08, 0x1D, 0x3C, 0x1D, 0x27, 0x4F, 0x26, 0x08, 0x1E, 0x02, + 0x01, 0x03, 0x02, 0x01, 0x04, 0x15, 0x12, 0x0E, 0x22, 0x0F, 0x1F, 0x3F, + 0x1F, 0x14, 0x27, 0x14, 0x14, 0x05, 0x01, 0x01, 0x01, 0xFE, 0x9D, 0x01, + 0x0B, 0x08, 0x17, 0x08, 0x16, 0x2A, 0x16, 0x19, 0x61, 0x01, 0x0C, 0x0C, + 0x1E, 0x10, 0x03, 0x03, 0x01, 0x01, 0x21, 0x0B, 0x0A, 0x15, 0x0D, 0x0E, + 0x19, 0x03, 0x06, 0x0B, 0x04, 0x08, 0x14, 0x02, 0x02, 0x0A, 0x0E, 0x18, + 0x31, 0x18, 0x02, 0x18, 0x02, 0x08, 0x03, 0x01, 0x02, 0xDE, 0x0F, 0x1E, + 0x10, 0x0A, 0x16, 0x07, 0x06, 0x01, 0x0C, 0x0C, 0x0D, 0x01, 0x02, 0x03, + 0x01, 0x02, 0x0D, 0x02, 0x05, 0x07, 0x05, 0x05, 0x15, 0x09, 0x0F, 0x2A, + 0x12, 0x17, 0x42, 0x10, 0x0F, 0x0B, 0x0C, 0x0D, 0x1A, 0x17, 0x0E, 0x19, + 0x0C, 0x1A, 0x33, 0x19, 0x20, 0x40, 0x21, 0x1D, 0x3C, 0x1E, 0x10, 0x03, + 0x03, 0x05, 0x0B, 0x05, 0x0A, 0x13, 0x0A, 0x02, 0x0A, 0x0E, 0x03, 0x0D, + 0x06, 0x0D, 0x19, 0x0C, 0x12, 0x20, 0x10, 0x21, 0x3F, 0x20, 0x08, 0x57, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x07, 0x07, 0x01, 0x04, 0x0C, 0x0A, 0x13, + 0x0A, 0x0F, 0x1E, 0x10, 0x13, 0x11, 0x04, 0x04, 0x03, 0x01, 0x01, 0x01, + 0x01, 0x2C, 0x0D, 0x15, 0x2B, 0x15, 0xF1, 0x0A, 0x17, 0x06, 0x03, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x03, 0x03, 0x26, 0x11, 0x22, 0x0E, 0x0E, 0x03, + 0x01, 0x28, 0x04, 0x0D, 0x1A, 0x06, 0x06, 0x0B, 0x05, 0x04, 0x09, 0x01, + 0x02, 0x07, 0x06, 0x0A, 0x19, 0x0E, 0x13, 0x04, 0x01, 0x06, 0x13, 0x03, + 0x0E, 0x21, 0x0F, 0x00, 0x00, 0x03, 0x00, 0x59, 0x00, 0x25, 0x04, 0x8E, + 0x03, 0x59, 0x00, 0xCE, 0x00, 0xD4, 0x01, 0x1E, 0x00, 0x00, 0x01, 0x34, + 0x36, 0x27, 0x26, 0x06, 0x37, 0x36, 0x26, 0x23, 0x06, 0x26, 0x23, 0x22, + 0x26, 0x23, 0x14, 0x16, 0x07, 0x06, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x22, + 0x06, 0x35, 0x3C, 0x01, 0x23, 0x0E, 0x01, 0x35, 0x36, 0x22, 0x23, 0x2A, + 0x02, 0x26, 0x23, 0x1C, 0x01, 0x15, 0x26, 0x22, 0x23, 0x14, 0x06, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x17, 0x16, 0x06, 0x07, 0x06, 0x14, 0x07, + 0x06, 0x14, 0x17, 0x16, 0x32, 0x17, 0x16, 0x14, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x17, 0x16, 0x06, 0x17, 0x16, 0x06, 0x15, 0x14, 0x06, 0x07, + 0x0E, 0x01, 0x17, 0x14, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x15, 0x0E, 0x01, 0x15, + 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x36, 0x17, 0x16, 0x06, 0x17, + 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x33, + 0x32, 0x36, 0x33, 0x32, 0x16, 0x35, 0x34, 0x26, 0x27, 0x2E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x35, 0x26, 0x36, 0x37, 0x3E, 0x01, 0x33, 0x3A, 0x01, 0x33, + 0x3A, 0x01, 0x17, 0x32, 0x16, 0x35, 0x34, 0x36, 0x27, 0x26, 0x36, 0x35, + 0x34, 0x26, 0x35, 0x34, 0x36, 0x37, 0x36, 0x16, 0x33, 0x3A, 0x01, 0x33, + 0x3A, 0x01, 0x33, 0x32, 0x16, 0x37, 0x36, 0x26, 0x35, 0x34, 0x26, 0x37, + 0x01, 0x36, 0x16, 0x17, 0x22, 0x26, 0x01, 0x06, 0x26, 0x27, 0x14, 0x06, + 0x23, 0x2A, 0x01, 0x23, 0x22, 0x26, 0x07, 0x06, 0x36, 0x27, 0x2E, 0x01, + 0x27, 0x26, 0x36, 0x35, 0x34, 0x36, 0x37, 0x3E, 0x01, 0x17, 0x16, 0x06, + 0x07, 0x06, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x37, 0x32, 0x36, + 0x27, 0x26, 0x06, 0x35, 0x30, 0x27, 0x26, 0x23, 0x2E, 0x01, 0x27, 0x26, + 0x36, 0x35, 0x34, 0x36, 0x37, 0x36, 0x16, 0x37, 0x36, 0x16, 0x17, 0x1E, + 0x01, 0x15, 0x1C, 0x01, 0x17, 0x1C, 0x01, 0x07, 0x04, 0x8B, 0x03, 0x04, + 0x05, 0x09, 0x02, 0x03, 0x24, 0x08, 0x16, 0x2C, 0x16, 0x3B, 0x76, 0x3B, + 0x03, 0x03, 0x03, 0x17, 0x04, 0x18, 0x2F, 0x17, 0x0A, 0x11, 0x06, 0x03, + 0x0C, 0x01, 0x09, 0x0A, 0x31, 0x62, 0x62, 0x62, 0x31, 0x08, 0x11, 0x08, + 0x14, 0x05, 0x05, 0x0E, 0x06, 0x04, 0x06, 0x01, 0x01, 0x04, 0x07, 0x05, + 0x01, 0x02, 0x01, 0x01, 0x05, 0x04, 0x03, 0x02, 0x07, 0x13, 0x07, 0x12, + 0x23, 0x0C, 0x06, 0x07, 0x01, 0x01, 0x09, 0x0B, 0x03, 0x02, 0x0A, 0x01, + 0x0B, 0x02, 0x04, 0x06, 0x03, 0x04, 0x0E, 0x07, 0x03, 0x04, 0x02, 0x03, + 0x02, 0x02, 0x06, 0x06, 0x01, 0x05, 0x3A, 0x0D, 0x05, 0x03, 0x09, 0x06, + 0x0F, 0x06, 0x0C, 0x24, 0x0D, 0x1A, 0x34, 0x19, 0x0A, 0x0E, 0x0A, 0x0A, + 0x14, 0x0A, 0x06, 0x12, 0x17, 0x03, 0x0A, 0x08, 0x07, 0x04, 0x04, 0x01, + 0x02, 0x08, 0x02, 0x04, 0x0B, 0x04, 0x04, 0x0A, 0x02, 0x02, 0x07, 0x01, + 0x05, 0x01, 0x02, 0x06, 0x07, 0x39, 0x71, 0x39, 0x18, 0x31, 0x18, 0x03, + 0x12, 0x04, 0x08, 0x04, 0x03, 0x02, 0x0B, 0x0B, 0x06, 0x23, 0x09, 0x0E, + 0x1C, 0x0E, 0x1C, 0x37, 0x1C, 0x09, 0x42, 0x02, 0x03, 0x03, 0x01, 0x02, + 0xFC, 0x94, 0x03, 0x05, 0x01, 0x03, 0x04, 0x02, 0x19, 0x01, 0x0C, 0x07, + 0x08, 0x0E, 0x12, 0x24, 0x12, 0x21, 0x40, 0x20, 0x10, 0x01, 0x01, 0x01, + 0x0A, 0x01, 0x01, 0x0D, 0x12, 0x04, 0x03, 0x16, 0x06, 0x0A, 0x06, 0x01, + 0x01, 0x12, 0x07, 0x08, 0x12, 0x0C, 0x09, 0x15, 0x0A, 0x06, 0x04, 0x04, + 0x02, 0x0F, 0x06, 0x05, 0x01, 0x09, 0x12, 0x07, 0x0A, 0x01, 0x08, 0x05, + 0x16, 0x2D, 0x16, 0x0E, 0x17, 0x0A, 0x04, 0x0F, 0x01, 0x02, 0x03, 0x25, + 0x04, 0x12, 0x03, 0x05, 0x04, 0x0A, 0x0F, 0x01, 0x02, 0x01, 0x01, 0x06, + 0x19, 0x06, 0x04, 0x02, 0x02, 0x0C, 0x04, 0x0B, 0x01, 0x01, 0x05, 0x0A, + 0x01, 0x06, 0x0A, 0x06, 0x01, 0x0C, 0x11, 0x0B, 0x0A, 0x15, 0x0A, 0x09, + 0x17, 0x0A, 0x0A, 0x05, 0x05, 0x04, 0x19, 0x06, 0x07, 0x11, 0x07, 0x06, + 0x03, 0x01, 0x04, 0x02, 0x04, 0x04, 0x03, 0x09, 0x1C, 0x10, 0x08, 0x0C, + 0x0A, 0x07, 0x0C, 0x05, 0x05, 0x17, 0x05, 0x03, 0x10, 0x03, 0x03, 0x18, + 0x03, 0x06, 0x11, 0x07, 0x0D, 0x1B, 0x0D, 0x05, 0x0F, 0x06, 0x07, 0x10, + 0x07, 0x10, 0x26, 0x11, 0x05, 0x04, 0x04, 0x05, 0x08, 0x05, 0x0B, 0x17, + 0x0B, 0x19, 0x0F, 0x07, 0x03, 0x0E, 0x03, 0x02, 0x02, 0x03, 0x07, 0x08, + 0x01, 0x03, 0x06, 0x06, 0x03, 0x06, 0x03, 0x04, 0x0B, 0x04, 0x07, 0x04, + 0x0C, 0x34, 0x0F, 0x08, 0x18, 0x09, 0x09, 0x0F, 0x08, 0x0F, 0x1B, 0x0F, + 0x0D, 0x19, 0x0D, 0x0A, 0x18, 0x0A, 0x09, 0x16, 0x09, 0x06, 0x05, 0x01, + 0x01, 0x05, 0x08, 0x13, 0x05, 0x02, 0x30, 0x05, 0x09, 0x12, 0x09, 0x10, + 0x10, 0x0B, 0x06, 0x04, 0x05, 0x0C, 0x19, 0x36, 0x19, 0x1A, 0x35, 0x1A, + 0xFD, 0x19, 0x01, 0x02, 0x01, 0x01, 0x01, 0x8E, 0x08, 0x02, 0x01, 0x0E, + 0x02, 0x01, 0x02, 0x01, 0x13, 0x0C, 0x0B, 0x13, 0x0C, 0x0B, 0x12, 0x0B, + 0x0A, 0x0C, 0x07, 0x05, 0x09, 0x02, 0x03, 0x2E, 0x08, 0x0F, 0x11, 0x0B, + 0x0B, 0x0C, 0x06, 0x04, 0x01, 0x01, 0x12, 0x02, 0x01, 0x02, 0x03, 0x03, + 0x02, 0x05, 0x0D, 0x08, 0x0D, 0x20, 0x0E, 0x06, 0x0E, 0x01, 0x05, 0x06, + 0x01, 0x01, 0x04, 0x0B, 0x04, 0x08, 0x03, 0x12, 0x23, 0x11, 0x08, 0x10, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x53, 0x00, 0x26, 0x08, 0xFB, + 0x03, 0x5A, 0x00, 0x64, 0x00, 0x8C, 0x00, 0x00, 0x01, 0x2F, 0x01, 0x21, + 0x07, 0x27, 0x21, 0x27, 0x07, 0x23, 0x15, 0x23, 0x15, 0x23, 0x35, 0x27, + 0x07, 0x35, 0x27, 0x23, 0x15, 0x21, 0x15, 0x23, 0x35, 0x21, 0x2F, 0x02, + 0x15, 0x0F, 0x01, 0x27, 0x07, 0x27, 0x22, 0x06, 0x07, 0x14, 0x16, 0x1F, + 0x02, 0x0F, 0x01, 0x1F, 0x01, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x0F, 0x02, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x0F, 0x01, 0x05, 0x27, 0x37, 0x13, 0x17, + 0x3F, 0x01, 0x1F, 0x02, 0x3F, 0x03, 0x3E, 0x01, 0x3F, 0x01, 0x21, 0x3F, + 0x01, 0x35, 0x27, 0x35, 0x33, 0x15, 0x33, 0x15, 0x33, 0x17, 0x37, 0x21, + 0x37, 0x17, 0x21, 0x3F, 0x02, 0x27, 0x01, 0x0F, 0x02, 0x2F, 0x04, 0x2E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x3F, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x06, 0x16, 0x1F, 0x01, 0x37, 0x2F, 0x01, 0x34, 0x36, 0x3F, 0x03, + 0x1F, 0x02, 0x15, 0x08, 0xF8, 0x08, 0x07, 0xFE, 0x46, 0x0A, 0x0A, 0xFE, + 0xA9, 0x0D, 0x0A, 0x96, 0x2B, 0x1C, 0x0B, 0x0A, 0x08, 0x48, 0xFE, 0xD2, + 0xAF, 0xFE, 0xC7, 0x09, 0x5C, 0x17, 0x1E, 0x13, 0x2B, 0x07, 0x10, 0x08, + 0x09, 0x02, 0x04, 0x05, 0x0A, 0x35, 0x03, 0x01, 0x0B, 0x26, 0x0E, 0x13, + 0x04, 0x06, 0x03, 0x02, 0x0A, 0x14, 0x10, 0x1A, 0x0A, 0x09, 0x0E, 0x04, + 0x03, 0x01, 0x35, 0x10, 0x03, 0x49, 0x0A, 0x1A, 0x16, 0x16, 0x25, 0x15, + 0x96, 0x17, 0x0E, 0x3A, 0x02, 0x06, 0x03, 0x06, 0x01, 0x46, 0x03, 0x07, + 0x07, 0x1E, 0x31, 0x91, 0x0D, 0x09, 0x01, 0x57, 0x09, 0x06, 0x01, 0xBF, + 0x05, 0x09, 0x04, 0x02, 0xFA, 0x55, 0x15, 0x1D, 0x3F, 0x47, 0x1F, 0x2A, + 0x25, 0x19, 0x04, 0x01, 0x02, 0x03, 0x0A, 0x08, 0x05, 0x13, 0x0D, 0x17, + 0x10, 0x09, 0x0B, 0x01, 0x01, 0x05, 0x06, 0x0B, 0x0A, 0x06, 0x02, 0x06, + 0x05, 0x11, 0x23, 0xA4, 0x0A, 0x10, 0x02, 0x03, 0x2D, 0x1E, 0x09, 0x04, + 0x01, 0x06, 0x06, 0x2A, 0x14, 0x17, 0x0D, 0x01, 0x1A, 0x0A, 0x27, 0x05, + 0x06, 0x07, 0x02, 0x0D, 0x19, 0x39, 0x5E, 0x1C, 0x26, 0x02, 0x07, 0x08, + 0x05, 0x0A, 0x03, 0x03, 0x06, 0x15, 0x21, 0x0C, 0x0D, 0x05, 0x09, 0x05, + 0x05, 0x0D, 0x09, 0x1A, 0x29, 0x23, 0x4A, 0x27, 0x27, 0x52, 0x2B, 0x47, + 0x03, 0x17, 0x23, 0x01, 0x36, 0x03, 0x03, 0x05, 0x03, 0x0C, 0x08, 0x05, + 0x05, 0x10, 0x8C, 0x05, 0x08, 0x03, 0x03, 0x31, 0x06, 0x18, 0x06, 0x32, + 0x15, 0x1A, 0x05, 0x06, 0x03, 0x04, 0x0D, 0x1E, 0x38, 0x35, 0xFE, 0xEC, + 0x3C, 0x41, 0x04, 0x03, 0x02, 0x02, 0x10, 0x1D, 0x09, 0x14, 0x0B, 0x0A, + 0x12, 0x09, 0x06, 0x0A, 0x04, 0x06, 0x13, 0x0C, 0x1A, 0x0F, 0x08, 0x16, + 0x0D, 0x18, 0x07, 0x0E, 0x1D, 0x0A, 0x12, 0x08, 0x17, 0x24, 0x01, 0x01, + 0x09, 0x0E, 0x09, 0x00, 0x00, 0x02, 0x00, 0x65, 0x00, 0x26, 0x05, 0xF6, + 0x03, 0x5F, 0x01, 0x7B, 0x01, 0xB4, 0x00, 0x00, 0x01, 0x3E, 0x01, 0x17, + 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x15, 0x14, 0x06, 0x33, 0x3A, 0x03, 0x33, + 0x3A, 0x01, 0x33, 0x32, 0x26, 0x37, 0x36, 0x26, 0x35, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x33, 0x32, 0x36, 0x17, 0x1E, 0x01, 0x15, 0x14, 0x16, 0x15, + 0x14, 0x06, 0x17, 0x30, 0x17, 0x16, 0x35, 0x14, 0x36, 0x17, 0x16, 0x06, + 0x17, 0x32, 0x16, 0x15, 0x1C, 0x01, 0x15, 0x26, 0x16, 0x23, 0x32, 0x36, + 0x17, 0x26, 0x16, 0x35, 0x1C, 0x01, 0x15, 0x16, 0x06, 0x15, 0x1C, 0x01, + 0x15, 0x14, 0x26, 0x23, 0x22, 0x26, 0x0F, 0x01, 0x06, 0x15, 0x14, 0x06, + 0x23, 0x0E, 0x01, 0x07, 0x06, 0x0F, 0x01, 0x14, 0x26, 0x27, 0x26, 0x06, + 0x27, 0x22, 0x26, 0x23, 0x22, 0x06, 0x23, 0x22, 0x06, 0x15, 0x1C, 0x01, + 0x15, 0x1C, 0x01, 0x15, 0x14, 0x22, 0x23, 0x22, 0x06, 0x07, 0x0E, 0x01, + 0x15, 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x32, + 0x17, 0x16, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x16, + 0x15, 0x1C, 0x01, 0x15, 0x14, 0x16, 0x07, 0x06, 0x26, 0x23, 0x2A, 0x01, + 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x27, 0x26, 0x36, 0x35, 0x3C, 0x01, + 0x35, 0x0E, 0x01, 0x23, 0x22, 0x26, 0x35, 0x34, 0x26, 0x35, 0x34, 0x3D, + 0x01, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x16, 0x15, 0x26, 0x22, + 0x27, 0x22, 0x06, 0x23, 0x0E, 0x01, 0x15, 0x14, 0x06, 0x07, 0x0E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x06, 0x32, 0x17, 0x1E, 0x01, 0x15, 0x1C, 0x01, + 0x07, 0x06, 0x26, 0x23, 0x22, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x22, 0x26, + 0x23, 0x22, 0x26, 0x27, 0x2A, 0x01, 0x35, 0x14, 0x26, 0x27, 0x26, 0x34, + 0x35, 0x34, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x37, 0x36, 0x26, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x37, 0x3E, 0x01, 0x35, 0x34, 0x36, 0x35, 0x37, 0x36, 0x37, 0x3E, 0x01, + 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x35, 0x34, 0x06, + 0x23, 0x22, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x35, 0x34, 0x26, 0x35, 0x3C, 0x01, 0x35, 0x34, 0x36, 0x35, 0x3C, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x35, 0x36, 0x37, 0x32, 0x36, + 0x33, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x27, 0x16, 0x36, + 0x17, 0x26, 0x36, 0x33, 0x1E, 0x01, 0x15, 0x14, 0x16, 0x17, 0x16, 0x36, + 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x02, 0x16, 0x3B, 0x01, 0x31, 0x34, 0x26, + 0x37, 0x03, 0x2E, 0x01, 0x27, 0x26, 0x06, 0x23, 0x2A, 0x01, 0x23, 0x1E, + 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x27, 0x2E, 0x01, 0x27, 0x2E, + 0x01, 0x35, 0x34, 0x26, 0x27, 0x3C, 0x01, 0x35, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x15, 0x14, 0x06, 0x15, 0x14, 0x16, 0x32, 0x16, 0x33, 0x26, 0x36, + 0x37, 0x32, 0x36, 0x15, 0x34, 0x36, 0x27, 0x2E, 0x01, 0x35, 0x02, 0xFD, + 0x11, 0x1C, 0x11, 0x05, 0x0D, 0x05, 0x04, 0x02, 0x01, 0x01, 0x2D, 0x5A, + 0x5A, 0x5B, 0x2D, 0x25, 0x4C, 0x26, 0x05, 0x03, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x02, 0x02, 0x0D, 0x03, 0x09, 0x12, 0x07, 0x01, 0x07, 0x08, 0x01, + 0x02, 0x04, 0x04, 0x0B, 0x02, 0x02, 0x04, 0x04, 0x01, 0x03, 0x01, 0x0C, + 0x04, 0x09, 0x15, 0x08, 0x02, 0x09, 0x01, 0x01, 0x09, 0x07, 0x07, 0x18, + 0x05, 0x01, 0x02, 0x07, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x0E, + 0x05, 0x26, 0x4C, 0x26, 0x2F, 0x5E, 0x2F, 0x03, 0x05, 0x02, 0x0B, 0x06, + 0x2E, 0x09, 0x0C, 0x0F, 0x09, 0x04, 0x0D, 0x0C, 0x02, 0x04, 0x02, 0x02, + 0x02, 0x03, 0x09, 0x07, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x13, + 0x02, 0x1B, 0x37, 0x1B, 0x0C, 0x16, 0x0B, 0x09, 0x05, 0x03, 0x03, 0x03, + 0x05, 0x05, 0x09, 0x04, 0x26, 0x03, 0x0F, 0x1D, 0x0F, 0x13, 0x26, 0x13, + 0x09, 0x02, 0x14, 0x29, 0x14, 0x05, 0x07, 0x02, 0x01, 0x07, 0x05, 0x02, + 0x04, 0x05, 0x03, 0x02, 0x01, 0x02, 0x02, 0x05, 0x01, 0x04, 0x04, 0x02, + 0x01, 0x05, 0x01, 0x02, 0x03, 0x01, 0x03, 0x03, 0x03, 0x02, 0x04, 0x09, + 0x06, 0x13, 0x02, 0x09, 0x13, 0x06, 0x15, 0x27, 0x15, 0x10, 0x20, 0x13, + 0x05, 0x0B, 0x06, 0x07, 0x16, 0x10, 0x02, 0x02, 0x07, 0x03, 0x02, 0x06, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x01, 0x03, 0x0B, 0x11, + 0x07, 0x07, 0x16, 0x07, 0x02, 0x05, 0x03, 0x01, 0x08, 0x10, 0x02, 0x03, + 0x01, 0x02, 0x06, 0x01, 0x01, 0x07, 0x02, 0x02, 0x05, 0x04, 0x05, 0x03, + 0x19, 0x07, 0x08, 0x10, 0x06, 0x06, 0x07, 0x04, 0x02, 0x09, 0x01, 0x03, + 0x07, 0x02, 0x02, 0x04, 0x04, 0x03, 0x02, 0x02, 0x04, 0x02, 0x01, 0x01, + 0x01, 0x09, 0x01, 0x04, 0x02, 0x02, 0x06, 0x0C, 0x06, 0x07, 0x1B, 0x02, + 0x02, 0x05, 0x02, 0x01, 0x0B, 0x0A, 0x05, 0x11, 0x03, 0x01, 0x03, 0x15, + 0x06, 0x15, 0x2A, 0x15, 0x2F, 0x5E, 0x5D, 0x5E, 0x2F, 0x01, 0x01, 0x02, + 0x45, 0x04, 0x05, 0x08, 0x06, 0x15, 0x07, 0x0C, 0x18, 0x0C, 0x02, 0x13, + 0x08, 0x03, 0x12, 0x01, 0x01, 0x10, 0x08, 0x0E, 0x14, 0x0B, 0x02, 0x0E, + 0x09, 0x02, 0x0D, 0x03, 0x07, 0x03, 0x07, 0x09, 0x32, 0x3E, 0x39, 0x07, + 0x01, 0x03, 0x03, 0x01, 0x08, 0x01, 0x01, 0x01, 0x04, 0x03, 0x44, 0x09, + 0x12, 0x0B, 0x04, 0x07, 0x05, 0x04, 0x05, 0x07, 0x02, 0x12, 0x01, 0x03, + 0x01, 0x05, 0x01, 0x02, 0x01, 0x02, 0x02, 0x0F, 0x01, 0x05, 0x01, 0x08, + 0x02, 0x02, 0x03, 0x04, 0x02, 0x05, 0x01, 0x03, 0x04, 0x01, 0x08, 0x01, + 0x05, 0x03, 0x10, 0x02, 0x0B, 0x02, 0x02, 0x04, 0x02, 0x04, 0x0A, 0x03, + 0x03, 0x01, 0x07, 0x02, 0x02, 0x05, 0x02, 0x07, 0x10, 0x07, 0x04, 0x07, + 0x03, 0x08, 0x01, 0x03, 0x04, 0x08, 0x07, 0x01, 0x03, 0x0C, 0x01, 0x09, + 0x02, 0x02, 0x04, 0x04, 0x09, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x0A, 0x08, 0x0F, 0x07, 0x08, 0x0F, 0x07, 0x09, 0x1E, 0x09, 0x04, + 0x0C, 0x08, 0x0A, 0x13, 0x09, 0x06, 0x0D, 0x06, 0x02, 0x06, 0x03, 0x01, + 0x03, 0x08, 0x18, 0x07, 0x0A, 0x09, 0x05, 0x03, 0x09, 0x08, 0x0E, 0x20, + 0x0E, 0x2F, 0x5E, 0x2F, 0x03, 0x11, 0x02, 0x01, 0x01, 0x05, 0x07, 0x1F, + 0x08, 0x39, 0x73, 0x39, 0x03, 0x0D, 0x03, 0x05, 0x08, 0x1A, 0x0B, 0x01, + 0x0C, 0x0C, 0x13, 0x08, 0x01, 0x01, 0x20, 0x01, 0x0B, 0x02, 0x06, 0x06, + 0x05, 0x07, 0x10, 0x07, 0x05, 0x06, 0x05, 0x03, 0x0A, 0x03, 0x08, 0x0D, + 0x08, 0x03, 0x08, 0x02, 0x05, 0x0A, 0x05, 0x09, 0x06, 0x03, 0x0C, 0x02, + 0x0A, 0x18, 0x05, 0x02, 0x06, 0x02, 0x01, 0x01, 0x02, 0x01, 0x05, 0x03, + 0x01, 0x09, 0x01, 0x07, 0x04, 0x04, 0x09, 0x05, 0x12, 0x1B, 0x10, 0x07, + 0x0E, 0x08, 0x02, 0x04, 0x01, 0x03, 0x02, 0x02, 0x04, 0x09, 0x03, 0x0B, + 0x22, 0x0F, 0x11, 0x1D, 0x0D, 0x04, 0x06, 0x03, 0x02, 0x0D, 0x01, 0x09, + 0x0D, 0x0A, 0x07, 0x08, 0x02, 0x06, 0x06, 0x07, 0x04, 0x0A, 0x03, 0x04, + 0x0A, 0x04, 0x05, 0x08, 0x08, 0x08, 0x02, 0x02, 0x01, 0x01, 0x0B, 0x02, + 0x01, 0x0A, 0x02, 0x02, 0x09, 0x04, 0x06, 0x15, 0x08, 0x0F, 0x1E, 0x0F, + 0x0A, 0x15, 0x07, 0x04, 0x09, 0x02, 0x01, 0x03, 0x02, 0x01, 0x02, 0x01, + 0x02, 0x03, 0x01, 0x06, 0x02, 0x03, 0x02, 0x04, 0x07, 0x04, 0x03, 0x0F, + 0x09, 0x01, 0x01, 0x01, 0x0B, 0x09, 0x01, 0x01, 0x05, 0x03, 0x0F, 0x01, + 0x04, 0x01, 0x01, 0x07, 0x12, 0x05, 0xFE, 0xA1, 0x08, 0x14, 0x04, 0x02, + 0x01, 0x0C, 0x15, 0x07, 0x03, 0x08, 0x04, 0x09, 0x09, 0x03, 0x04, 0x0A, + 0x0B, 0x03, 0x0B, 0x03, 0x03, 0x11, 0x03, 0x01, 0x03, 0x01, 0x02, 0x1B, + 0x07, 0x03, 0x11, 0x04, 0x05, 0x0C, 0x05, 0x02, 0x02, 0x01, 0x05, 0x05, + 0x04, 0x0E, 0x01, 0x04, 0x05, 0x04, 0x04, 0x06, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x03, 0x00, 0x5A, 0x00, 0x26, 0x05, 0x2D, 0x03, 0x5A, 0x00, 0xCC, + 0x00, 0xDC, 0x01, 0x0D, 0x00, 0x00, 0x01, 0x16, 0x32, 0x33, 0x3E, 0x01, + 0x33, 0x16, 0x3A, 0x02, 0x33, 0x3E, 0x01, 0x37, 0x1E, 0x01, 0x17, 0x1E, + 0x01, 0x17, 0x1E, 0x01, 0x17, 0x32, 0x16, 0x17, 0x16, 0x14, 0x07, 0x2A, + 0x01, 0x27, 0x06, 0x16, 0x07, 0x0E, 0x01, 0x23, 0x06, 0x26, 0x07, 0x36, + 0x16, 0x17, 0x1E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x22, 0x06, 0x23, 0x1E, + 0x03, 0x17, 0x1E, 0x01, 0x17, 0x0E, 0x01, 0x07, 0x14, 0x06, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x27, 0x22, 0x06, 0x27, 0x22, 0x06, 0x27, 0x2E, + 0x01, 0x27, 0x2E, 0x03, 0x27, 0x2E, 0x01, 0x27, 0x0E, 0x01, 0x07, 0x06, + 0x16, 0x15, 0x14, 0x16, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, + 0x26, 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x06, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x27, 0x0E, 0x01, 0x23, 0x22, 0x26, 0x27, 0x3C, 0x01, 0x35, 0x2E, + 0x01, 0x27, 0x26, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, + 0x01, 0x37, 0x36, 0x26, 0x27, 0x26, 0x06, 0x27, 0x26, 0x36, 0x27, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x26, 0x27, 0x2E, 0x01, 0x37, 0x26, + 0x36, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x3E, 0x01, 0x37, 0x36, + 0x16, 0x33, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x33, 0x1E, 0x01, 0x17, 0x3A, + 0x01, 0x17, 0x05, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x1E, 0x01, 0x17, + 0x3E, 0x01, 0x27, 0x36, 0x26, 0x27, 0x05, 0x26, 0x06, 0x07, 0x14, 0x06, + 0x15, 0x0E, 0x01, 0x07, 0x06, 0x16, 0x17, 0x1E, 0x01, 0x15, 0x22, 0x26, + 0x27, 0x26, 0x36, 0x27, 0x36, 0x26, 0x27, 0x34, 0x36, 0x35, 0x22, 0x06, + 0x07, 0x0E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, + 0x37, 0x36, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x02, 0x4B, 0x1B, 0x36, 0x1B, + 0x0D, 0x1B, 0x0D, 0x29, 0x52, 0x52, 0x52, 0x29, 0x02, 0x02, 0x04, 0x09, + 0x13, 0x09, 0x04, 0x07, 0x06, 0x05, 0x02, 0x04, 0x2A, 0x55, 0x2A, 0x07, + 0x07, 0x2B, 0x56, 0x2B, 0x04, 0x03, 0x04, 0x02, 0x0C, 0x06, 0x27, 0x4F, + 0x27, 0x0D, 0x14, 0x0C, 0x03, 0x05, 0x02, 0x06, 0x0E, 0x07, 0x0B, 0x16, + 0x0B, 0x12, 0x21, 0x22, 0x21, 0x11, 0x06, 0x0F, 0x05, 0x03, 0x06, 0x03, + 0x01, 0x01, 0x05, 0x0E, 0x06, 0x05, 0x07, 0x06, 0x08, 0x0E, 0x07, 0x10, + 0x20, 0x10, 0x06, 0x06, 0x02, 0x0F, 0x1E, 0x1E, 0x1F, 0x0F, 0x0D, 0x1C, + 0x0E, 0x07, 0x0A, 0x03, 0x02, 0x04, 0x01, 0x01, 0x0B, 0x1A, 0x0D, 0x16, + 0x2E, 0x17, 0x13, 0x25, 0x12, 0x0F, 0x22, 0x0F, 0x0F, 0x12, 0x05, 0x07, + 0x14, 0x08, 0x07, 0x0F, 0x04, 0x02, 0x01, 0x01, 0x08, 0x11, 0x03, 0x06, + 0x0F, 0x09, 0x02, 0x05, 0x03, 0x2F, 0x5D, 0x2F, 0x05, 0x0A, 0x04, 0x10, + 0x24, 0x06, 0x03, 0x06, 0x07, 0x0A, 0x15, 0x0B, 0x05, 0x0C, 0x06, 0x0B, + 0x1B, 0x09, 0x06, 0x0A, 0x13, 0x12, 0x2A, 0x14, 0x08, 0x02, 0x01, 0x14, + 0x2A, 0x0F, 0x06, 0x01, 0x01, 0x02, 0x09, 0x08, 0x06, 0x0B, 0x01, 0x01, + 0x07, 0x05, 0x04, 0x08, 0x04, 0x07, 0x0C, 0x06, 0x05, 0x0C, 0x05, 0x0C, + 0x18, 0x0B, 0x03, 0x04, 0x02, 0x06, 0x0C, 0x06, 0x03, 0x05, 0x02, 0x42, + 0x84, 0x42, 0xFE, 0x72, 0x02, 0x05, 0x02, 0x01, 0x03, 0x01, 0x02, 0x09, + 0x05, 0x03, 0x07, 0x01, 0x01, 0x09, 0x03, 0x01, 0xE4, 0x11, 0x1D, 0x10, + 0x01, 0x04, 0x0D, 0x02, 0x03, 0x08, 0x0B, 0x06, 0x0E, 0x10, 0x17, 0x09, + 0x0A, 0x08, 0x01, 0x01, 0x06, 0x02, 0x01, 0x0D, 0x16, 0x09, 0x0A, 0x0D, + 0x01, 0x01, 0x1E, 0x13, 0x20, 0x42, 0x1E, 0x10, 0x17, 0x04, 0x01, 0x02, + 0x08, 0x07, 0x18, 0x0C, 0x03, 0x41, 0x03, 0x02, 0x01, 0x01, 0x05, 0x0A, + 0x04, 0x01, 0x01, 0x01, 0x06, 0x0D, 0x04, 0x03, 0x0B, 0x03, 0x01, 0x01, + 0x0F, 0x23, 0x10, 0x01, 0x11, 0x22, 0x10, 0x07, 0x04, 0x01, 0x01, 0x02, + 0x01, 0x10, 0x04, 0x02, 0x06, 0x04, 0x05, 0x07, 0x03, 0x01, 0x36, 0x6C, + 0x6B, 0x6C, 0x36, 0x16, 0x2A, 0x16, 0x03, 0x04, 0x03, 0x06, 0x0C, 0x05, + 0x05, 0x02, 0x01, 0x01, 0x0B, 0x01, 0x07, 0x01, 0x01, 0x01, 0x06, 0x10, + 0x08, 0x2F, 0x5F, 0x5F, 0x5E, 0x30, 0x2D, 0x5B, 0x2D, 0x06, 0x10, 0x09, + 0x09, 0x12, 0x0A, 0x0E, 0x1E, 0x0F, 0x09, 0x0B, 0x05, 0x08, 0x08, 0x02, + 0x02, 0x08, 0x06, 0x05, 0x07, 0x08, 0x05, 0x1B, 0x0F, 0x1C, 0x38, 0x1C, + 0x16, 0x2B, 0x16, 0x0F, 0x1E, 0x0F, 0x04, 0x08, 0x09, 0x08, 0x0D, 0x06, + 0x01, 0x02, 0x01, 0x01, 0x01, 0x05, 0x02, 0x07, 0x0D, 0x06, 0x02, 0x0D, + 0x11, 0x19, 0x33, 0x18, 0x20, 0x40, 0x20, 0x0E, 0x1A, 0x0D, 0x15, 0x26, + 0x16, 0x14, 0x2D, 0x0C, 0x0B, 0x05, 0x01, 0x05, 0x12, 0x07, 0x06, 0x06, + 0x10, 0x06, 0x10, 0x08, 0x0B, 0x15, 0x07, 0x06, 0x0C, 0x09, 0x08, 0x0C, + 0x05, 0x02, 0x04, 0x01, 0x01, 0x05, 0x02, 0x07, 0x0D, 0x06, 0x01, 0x01, + 0x06, 0x0C, 0x05, 0x01, 0x01, 0x05, 0x0C, 0x06, 0x01, 0x24, 0x02, 0x01, + 0x02, 0x05, 0x02, 0x05, 0x07, 0x01, 0x03, 0x06, 0x04, 0x06, 0x04, 0x02, + 0xA7, 0x02, 0x0F, 0x01, 0x03, 0x05, 0x03, 0x08, 0x0E, 0x0A, 0x0F, 0x20, + 0x0B, 0x05, 0x0B, 0x09, 0x17, 0x0C, 0x0F, 0x24, 0x11, 0x04, 0x05, 0x03, + 0x02, 0x06, 0x02, 0x0D, 0x08, 0x0A, 0x1B, 0x0E, 0x15, 0x20, 0x06, 0x07, + 0x06, 0x0F, 0x08, 0x1D, 0x11, 0x0D, 0x1C, 0x0B, 0x0B, 0x0D, 0x02, 0x00, + 0x00, 0x05, 0x00, 0x5B, 0x00, 0x27, 0x06, 0xE3, 0x03, 0x5A, 0x00, 0xD6, + 0x00, 0xE6, 0x00, 0xF3, 0x01, 0x06, 0x01, 0x34, 0x00, 0x00, 0x01, 0x14, + 0x16, 0x17, 0x16, 0x06, 0x17, 0x16, 0x06, 0x07, 0x06, 0x16, 0x07, 0x14, + 0x06, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x03, 0x23, 0x2A, 0x01, 0x23, 0x22, + 0x06, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x14, 0x07, 0x06, 0x26, 0x07, 0x0E, + 0x01, 0x15, 0x14, 0x06, 0x07, 0x0E, 0x01, 0x23, 0x2A, 0x01, 0x27, 0x2E, + 0x01, 0x27, 0x2E, 0x01, 0x07, 0x06, 0x16, 0x17, 0x16, 0x06, 0x27, 0x2E, + 0x01, 0x07, 0x0E, 0x01, 0x07, 0x22, 0x16, 0x07, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x17, 0x1E, 0x01, 0x15, 0x14, 0x06, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x23, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, + 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, + 0x01, 0x37, 0x36, 0x32, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x37, 0x36, + 0x26, 0x27, 0x26, 0x06, 0x27, 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x33, 0x32, + 0x26, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x32, 0x33, 0x2E, 0x01, 0x27, 0x26, + 0x36, 0x37, 0x36, 0x16, 0x33, 0x32, 0x06, 0x33, 0x32, 0x16, 0x15, 0x14, + 0x36, 0x33, 0x32, 0x36, 0x17, 0x1E, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, + 0x16, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x16, 0x33, 0x3A, 0x01, 0x33, 0x3A, + 0x03, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x33, 0x3A, + 0x01, 0x17, 0x1E, 0x01, 0x37, 0x05, 0x36, 0x06, 0x23, 0x2A, 0x01, 0x23, + 0x22, 0x26, 0x07, 0x06, 0x32, 0x33, 0x3A, 0x01, 0x33, 0x37, 0x36, 0x06, + 0x23, 0x2A, 0x01, 0x23, 0x06, 0x36, 0x33, 0x3A, 0x01, 0x33, 0x17, 0x3A, + 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x27, 0x26, 0x06, 0x23, 0x2A, + 0x01, 0x23, 0x22, 0x26, 0x17, 0x01, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x06, 0x16, 0x17, 0x1E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x27, + 0x34, 0x26, 0x23, 0x0E, 0x01, 0x07, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x26, 0x27, + 0x2E, 0x01, 0x07, 0x06, 0xC2, 0x1C, 0x02, 0x01, 0x01, 0x01, 0x02, 0x07, + 0x04, 0x02, 0x04, 0x01, 0x05, 0x06, 0x0A, 0x14, 0x09, 0x3D, 0x78, 0x78, + 0x78, 0x3C, 0x2F, 0x5C, 0x2F, 0x10, 0x05, 0x07, 0x07, 0x0A, 0x02, 0x01, + 0x04, 0x08, 0x35, 0x10, 0x0D, 0x47, 0x08, 0x17, 0x13, 0x36, 0x17, 0x14, + 0x2D, 0x10, 0x12, 0x1B, 0x07, 0x01, 0x0C, 0x06, 0x03, 0x08, 0x01, 0x03, + 0x0B, 0x0B, 0x08, 0x15, 0x0A, 0x0C, 0x17, 0x0C, 0x08, 0x05, 0x01, 0x01, + 0x04, 0x01, 0x02, 0x11, 0x05, 0x08, 0x07, 0x02, 0x02, 0x01, 0x0C, 0x09, + 0x0C, 0x07, 0x04, 0x02, 0x39, 0x11, 0x19, 0x31, 0x19, 0x15, 0x28, 0x0E, + 0x10, 0x03, 0x03, 0x08, 0x31, 0x1E, 0x0A, 0x14, 0x0A, 0x0B, 0x1B, 0x08, + 0x04, 0x01, 0x05, 0x04, 0x0A, 0x06, 0x06, 0x08, 0x05, 0x0B, 0x1D, 0x0C, + 0x0E, 0x08, 0x09, 0x09, 0x0D, 0x0C, 0x06, 0x0C, 0x06, 0x05, 0x0D, 0x05, + 0x16, 0x1B, 0x10, 0x0A, 0x1B, 0x07, 0x0B, 0x15, 0x0C, 0x0D, 0x18, 0x0E, + 0x0B, 0x01, 0x07, 0x04, 0x08, 0x04, 0x0D, 0x18, 0x10, 0x07, 0x1B, 0x04, + 0x01, 0x01, 0x02, 0x02, 0x12, 0x03, 0x06, 0x04, 0x04, 0x09, 0x02, 0x07, + 0x06, 0x09, 0x20, 0x08, 0x03, 0x05, 0x04, 0x05, 0x0C, 0x05, 0x13, 0x25, + 0x12, 0x39, 0x70, 0x38, 0x0B, 0x0B, 0x09, 0x11, 0x23, 0x11, 0x33, 0x67, + 0x66, 0x67, 0x33, 0x1D, 0x3A, 0x1D, 0x0D, 0x1C, 0x0B, 0x08, 0x0E, 0x08, + 0x06, 0x05, 0x02, 0x01, 0x02, 0x08, 0xFD, 0xDE, 0x05, 0x2B, 0x09, 0x0C, + 0x18, 0x0B, 0x03, 0x16, 0x02, 0x0C, 0x38, 0x03, 0x12, 0x26, 0x12, 0xFE, + 0x05, 0x33, 0x08, 0x12, 0x24, 0x11, 0x01, 0x2E, 0x08, 0x12, 0x24, 0x12, + 0x7D, 0x11, 0x24, 0x12, 0x0A, 0x15, 0x0A, 0x02, 0x12, 0x07, 0x01, 0x11, + 0x02, 0x0D, 0x19, 0x0C, 0x08, 0x33, 0x04, 0xFC, 0xC3, 0x08, 0x0F, 0x09, + 0x0D, 0x0D, 0x03, 0x04, 0x09, 0x08, 0x02, 0x09, 0x04, 0x06, 0x05, 0x06, + 0x11, 0x0F, 0x05, 0x1F, 0x02, 0x0C, 0x15, 0x0C, 0x05, 0x09, 0x05, 0x08, + 0x0F, 0x10, 0x16, 0x4A, 0x1A, 0x15, 0x1B, 0x0A, 0x06, 0x01, 0x01, 0x02, + 0x06, 0x12, 0x0A, 0x23, 0x06, 0x03, 0x33, 0x15, 0x1E, 0x16, 0x0A, 0x12, + 0x0A, 0x0D, 0x15, 0x0D, 0x06, 0x17, 0x08, 0x04, 0x1D, 0x04, 0x11, 0x10, + 0x21, 0x12, 0x08, 0x21, 0x07, 0x0C, 0x06, 0x05, 0x04, 0x11, 0x0E, 0x1C, + 0x3B, 0x13, 0x10, 0x08, 0x0D, 0x0F, 0x1E, 0x17, 0x03, 0x25, 0x0A, 0x05, + 0x23, 0x05, 0x0E, 0x02, 0x05, 0x03, 0x06, 0x02, 0x02, 0x05, 0x01, 0x1C, + 0x07, 0x0C, 0x17, 0x0C, 0x08, 0x14, 0x07, 0x0C, 0x0D, 0x0F, 0x0D, 0x18, + 0x0D, 0x0C, 0x07, 0x08, 0x0B, 0x0D, 0x0E, 0x15, 0x01, 0x01, 0x03, 0x02, + 0x01, 0x01, 0x13, 0x18, 0x32, 0x1B, 0x40, 0x79, 0x39, 0x12, 0x24, 0x12, + 0x15, 0x2D, 0x16, 0x0B, 0x15, 0x0A, 0x08, 0x04, 0x03, 0x0D, 0x04, 0x06, + 0x04, 0x02, 0x03, 0x08, 0x09, 0x08, 0x0D, 0x03, 0x01, 0x03, 0x01, 0x01, + 0x03, 0x03, 0x0A, 0x23, 0x01, 0x01, 0x0B, 0x0A, 0x05, 0x08, 0x02, 0x02, + 0x06, 0x03, 0x07, 0x04, 0x08, 0x04, 0x0A, 0x04, 0x0C, 0x06, 0x03, 0x27, + 0x02, 0x02, 0x02, 0x08, 0x01, 0x09, 0x06, 0x01, 0x04, 0x04, 0x01, 0x0B, + 0x03, 0x06, 0x0D, 0x04, 0x03, 0x05, 0x06, 0x06, 0x08, 0x02, 0x28, 0x0F, + 0x04, 0x02, 0x02, 0x0B, 0x01, 0x0E, 0x04, 0x0D, 0x03, 0x01, 0x01, 0x07, + 0x02, 0x02, 0x04, 0x0C, 0xFE, 0xA1, 0x05, 0x08, 0x03, 0x03, 0x02, 0x0E, + 0x11, 0x18, 0x0E, 0x03, 0x08, 0x03, 0x05, 0x04, 0x05, 0x0F, 0x23, 0x15, + 0x02, 0x08, 0x03, 0x06, 0x03, 0x0C, 0x18, 0x0C, 0x12, 0x0F, 0x0B, 0x10, + 0x02, 0x06, 0x05, 0x13, 0x13, 0x0B, 0x1D, 0x0D, 0x13, 0x07, 0x07, 0x04, + 0x11, 0x0F, 0x00, 0x00, 0x00, 0x03, 0x00, 0x5D, 0x00, 0x26, 0x04, 0xE3, + 0x03, 0x5A, 0x00, 0xE7, 0x00, 0xF7, 0x01, 0x07, 0x00, 0x00, 0x01, 0x1C, + 0x01, 0x07, 0x06, 0x26, 0x23, 0x22, 0x06, 0x15, 0x14, 0x16, 0x23, 0x2A, + 0x01, 0x23, 0x22, 0x16, 0x17, 0x16, 0x06, 0x17, 0x1E, 0x01, 0x17, 0x22, + 0x26, 0x23, 0x26, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x23, 0x06, + 0x26, 0x27, 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x26, 0x07, 0x06, + 0x16, 0x15, 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x16, 0x23, 0x2A, + 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x36, 0x35, 0x3C, 0x01, 0x35, 0x34, + 0x26, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x26, 0x27, 0x26, 0x36, 0x37, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, + 0x06, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x26, 0x06, 0x23, 0x2A, + 0x01, 0x23, 0x22, 0x2B, 0x01, 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x14, + 0x06, 0x23, 0x22, 0x26, 0x27, 0x26, 0x06, 0x27, 0x2E, 0x01, 0x27, 0x26, + 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x35, 0x1E, + 0x01, 0x17, 0x1E, 0x01, 0x33, 0x30, 0x17, 0x16, 0x17, 0x16, 0x06, 0x07, + 0x06, 0x22, 0x23, 0x22, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x2A, 0x01, 0x27, + 0x31, 0x27, 0x06, 0x36, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x33, 0x3A, + 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x35, 0x36, + 0x34, 0x37, 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x33, 0x3A, + 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x26, 0x37, 0x36, 0x26, 0x37, 0x3E, + 0x01, 0x17, 0x1E, 0x01, 0x15, 0x14, 0x06, 0x33, 0x3A, 0x01, 0x33, 0x32, + 0x16, 0x17, 0x05, 0x16, 0x32, 0x33, 0x32, 0x36, 0x27, 0x26, 0x06, 0x23, + 0x22, 0x26, 0x07, 0x0E, 0x01, 0x17, 0x01, 0x22, 0x06, 0x15, 0x1C, 0x01, + 0x15, 0x1E, 0x01, 0x17, 0x3E, 0x01, 0x37, 0x2E, 0x01, 0x23, 0x04, 0xE3, + 0x0C, 0x07, 0x27, 0x0A, 0x10, 0x01, 0x04, 0x0D, 0x22, 0x46, 0x23, 0x0E, + 0x05, 0x01, 0x01, 0x0D, 0x01, 0x02, 0x02, 0x01, 0x11, 0x22, 0x11, 0x03, + 0x1A, 0x04, 0x09, 0x11, 0x0E, 0x09, 0x14, 0x09, 0x1B, 0x2E, 0x18, 0x0F, + 0x04, 0x02, 0x02, 0x01, 0x03, 0x0A, 0x15, 0x0A, 0x19, 0x31, 0x19, 0x03, + 0x01, 0x0F, 0x10, 0x0D, 0x1A, 0x0C, 0x0A, 0x09, 0x06, 0x02, 0x06, 0x01, + 0x03, 0x06, 0x04, 0x08, 0x11, 0x09, 0x02, 0x03, 0x06, 0x07, 0x0D, 0x0A, + 0x0C, 0x38, 0x0F, 0x08, 0x0A, 0x05, 0x09, 0x0D, 0x04, 0x04, 0x16, 0x04, + 0x0F, 0x1E, 0x0F, 0x02, 0x0C, 0x0C, 0x1B, 0x04, 0x0B, 0x11, 0x0A, 0x09, + 0x14, 0x09, 0x07, 0x0D, 0x03, 0x08, 0x0B, 0x02, 0x03, 0x02, 0x02, 0x01, + 0x02, 0x01, 0x01, 0x1D, 0x50, 0x9E, 0x4F, 0x08, 0x0F, 0x08, 0x03, 0x03, + 0x01, 0x02, 0x04, 0x05, 0x10, 0x28, 0x12, 0x13, 0x24, 0x12, 0x0E, 0x1C, + 0x0D, 0x03, 0x15, 0x01, 0x01, 0x02, 0x10, 0x09, 0x0B, 0x15, 0x0A, 0x15, + 0x28, 0x15, 0x24, 0x48, 0x24, 0x2A, 0x53, 0x2A, 0x19, 0x33, 0x19, 0x04, + 0x01, 0x02, 0x0C, 0x10, 0x24, 0x10, 0x06, 0x09, 0x02, 0x05, 0x03, 0x09, + 0x18, 0x2F, 0x18, 0x03, 0x07, 0x04, 0x05, 0x03, 0x02, 0x02, 0x01, 0x06, + 0x0A, 0x39, 0x0B, 0x11, 0x01, 0x02, 0x12, 0x0B, 0x17, 0x0C, 0x0C, 0x07, + 0x07, 0xFE, 0x08, 0x17, 0x2D, 0x19, 0x13, 0x24, 0x06, 0x06, 0x3B, 0x16, + 0x0A, 0x1D, 0x0A, 0x0E, 0x05, 0x0D, 0xFD, 0xC8, 0x09, 0x08, 0x01, 0x02, + 0x02, 0x06, 0x0D, 0x08, 0x04, 0x07, 0x04, 0x02, 0xC8, 0x11, 0x16, 0x0C, + 0x07, 0x04, 0x12, 0x0D, 0x0B, 0x1A, 0x0E, 0x0B, 0x08, 0x04, 0x08, 0x06, + 0x0D, 0x07, 0x01, 0x01, 0x32, 0x05, 0x0B, 0x11, 0x03, 0x03, 0x01, 0x01, + 0x07, 0x0F, 0x2D, 0x5C, 0x2D, 0x09, 0x10, 0x09, 0x09, 0x05, 0x05, 0x03, + 0x0F, 0x03, 0x0D, 0x1B, 0x0D, 0x1A, 0x35, 0x1A, 0x02, 0x0A, 0x39, 0x05, + 0x1B, 0x36, 0x1C, 0x11, 0x03, 0x0E, 0x08, 0x03, 0x12, 0x03, 0x0E, 0x1D, + 0x0F, 0x25, 0x4B, 0x25, 0x0C, 0x0B, 0x0B, 0x0C, 0x1B, 0x0A, 0x0C, 0x06, + 0x01, 0x01, 0x09, 0x05, 0x09, 0x12, 0x03, 0x03, 0x03, 0x0C, 0x16, 0x0B, + 0x0B, 0x16, 0x0B, 0x02, 0x07, 0x02, 0x03, 0x03, 0x02, 0x04, 0x02, 0x0F, + 0x06, 0x0F, 0x1E, 0x0F, 0x27, 0x51, 0x27, 0x17, 0x2C, 0x16, 0x0E, 0x14, + 0x0E, 0x05, 0x0E, 0x0B, 0x01, 0x03, 0x04, 0x03, 0x01, 0x07, 0x07, 0x03, + 0x0A, 0x03, 0x01, 0x01, 0x02, 0x01, 0x03, 0x01, 0x0C, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x02, 0x01, 0x12, 0x05, 0x0B, 0x09, 0x02, 0x02, 0x01, 0x04, + 0x02, 0x0E, 0x06, 0x09, 0x02, 0x02, 0x04, 0x05, 0x0D, 0x02, 0x04, 0x1A, + 0x09, 0x0E, 0x1C, 0x15, 0x0A, 0x2A, 0x02, 0x0B, 0xE9, 0x08, 0x10, 0x1A, + 0x1D, 0x02, 0x02, 0x05, 0x07, 0x29, 0x0A, 0x01, 0x33, 0x01, 0x0B, 0x07, + 0x0F, 0x08, 0x10, 0x1E, 0x10, 0x1A, 0x32, 0x19, 0x01, 0x02, 0x00, 0x00, + 0x00, 0x05, 0x00, 0x5A, 0x00, 0x24, 0x09, 0x3D, 0x03, 0x5A, 0x01, 0xA4, + 0x01, 0xC2, 0x01, 0xD5, 0x01, 0xE5, 0x02, 0x07, 0x00, 0x00, 0x01, 0x1E, + 0x01, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x16, 0x17, 0x16, 0x36, 0x33, 0x16, + 0x36, 0x17, 0x1E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x0E, + 0x01, 0x07, 0x06, 0x26, 0x15, 0x14, 0x06, 0x07, 0x06, 0x26, 0x27, 0x2E, + 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x16, 0x15, 0x16, 0x06, 0x15, 0x14, + 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x2E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x34, 0x36, 0x27, 0x2E, 0x01, 0x27, 0x26, + 0x06, 0x23, 0x26, 0x06, 0x07, 0x06, 0x26, 0x23, 0x3E, 0x01, 0x35, 0x0E, + 0x01, 0x07, 0x06, 0x26, 0x23, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x07, 0x30, + 0x07, 0x06, 0x23, 0x06, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x16, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, + 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, + 0x2E, 0x01, 0x23, 0x2A, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x06, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x17, + 0x1E, 0x01, 0x33, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x06, 0x16, 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x27, + 0x2E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x26, 0x27, + 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x03, 0x07, 0x0E, 0x01, 0x35, 0x34, 0x36, 0x27, 0x2E, 0x01, 0x27, + 0x26, 0x36, 0x33, 0x36, 0x32, 0x37, 0x36, 0x16, 0x33, 0x3A, 0x01, 0x33, + 0x32, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x32, 0x36, 0x17, 0x32, 0x16, 0x17, 0x16, 0x36, 0x33, 0x32, 0x16, 0x15, + 0x1C, 0x01, 0x15, 0x14, 0x36, 0x35, 0x34, 0x26, 0x37, 0x36, 0x16, 0x33, + 0x3A, 0x01, 0x33, 0x32, 0x26, 0x37, 0x36, 0x16, 0x15, 0x14, 0x06, 0x33, + 0x32, 0x16, 0x35, 0x34, 0x26, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x06, 0x15, + 0x14, 0x36, 0x33, 0x32, 0x26, 0x37, 0x36, 0x16, 0x33, 0x32, 0x36, 0x15, + 0x1C, 0x01, 0x33, 0x32, 0x16, 0x37, 0x36, 0x26, 0x33, 0x3A, 0x01, 0x33, + 0x32, 0x06, 0x15, 0x14, 0x16, 0x35, 0x3C, 0x01, 0x33, 0x3A, 0x01, 0x33, + 0x32, 0x06, 0x17, 0x16, 0x36, 0x33, 0x32, 0x34, 0x35, 0x34, 0x16, 0x33, + 0x32, 0x36, 0x17, 0x16, 0x06, 0x33, 0x32, 0x16, 0x37, 0x36, 0x26, 0x33, + 0x32, 0x36, 0x15, 0x14, 0x16, 0x33, 0x32, 0x34, 0x35, 0x34, 0x36, 0x17, + 0x16, 0x06, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x06, 0x15, 0x14, 0x32, 0x33, + 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x16, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x34, 0x36, 0x37, 0x3E, 0x01, 0x33, + 0x32, 0x36, 0x37, 0x32, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x05, 0x2A, 0x03, + 0x23, 0x2A, 0x01, 0x23, 0x32, 0x06, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, + 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x26, + 0x35, 0x01, 0x14, 0x36, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x37, 0x36, + 0x26, 0x27, 0x26, 0x06, 0x23, 0x22, 0x26, 0x15, 0x25, 0x36, 0x26, 0x23, + 0x22, 0x26, 0x07, 0x0E, 0x01, 0x17, 0x1E, 0x01, 0x33, 0x32, 0x16, 0x37, + 0x25, 0x2E, 0x01, 0x27, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x17, 0x1E, 0x01, + 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x08, 0xAF, + 0x0C, 0x0E, 0x09, 0x01, 0x01, 0x25, 0x05, 0x09, 0x26, 0x03, 0x04, 0x09, + 0x0A, 0x08, 0x1B, 0x0C, 0x0E, 0x14, 0x0F, 0x02, 0x04, 0x09, 0x08, 0x07, + 0x03, 0x06, 0x05, 0x19, 0x06, 0x06, 0x19, 0x05, 0x07, 0x0E, 0x09, 0x12, + 0x05, 0x02, 0x02, 0x04, 0x02, 0x02, 0x05, 0x02, 0x03, 0x04, 0x0A, 0x14, + 0x31, 0x03, 0x03, 0x04, 0x01, 0x03, 0x05, 0x03, 0x0B, 0x04, 0x0F, 0x14, + 0x13, 0x06, 0x0F, 0x07, 0x08, 0x10, 0x09, 0x11, 0x26, 0x12, 0x01, 0x02, + 0x0D, 0x19, 0x0E, 0x0D, 0x1E, 0x0E, 0x04, 0x07, 0x03, 0x01, 0x07, 0x02, + 0x07, 0x08, 0x01, 0x05, 0x03, 0x01, 0x09, 0x12, 0x08, 0x08, 0x11, 0x09, + 0x02, 0x0C, 0x09, 0x08, 0x10, 0x08, 0x11, 0x23, 0x11, 0x05, 0x14, 0x01, + 0x02, 0x03, 0x02, 0x05, 0x0B, 0x05, 0x08, 0x11, 0x07, 0x02, 0x04, 0x02, + 0x03, 0x03, 0x0B, 0x13, 0x26, 0x12, 0x10, 0x0F, 0x0F, 0x13, 0x27, 0x14, + 0x19, 0x35, 0x17, 0x06, 0x0D, 0x06, 0x08, 0x0F, 0x06, 0x03, 0x12, 0x03, + 0x02, 0x07, 0x04, 0x03, 0x07, 0x03, 0x02, 0x07, 0x02, 0x06, 0x0B, 0x06, + 0x09, 0x11, 0x03, 0x02, 0x05, 0x06, 0x06, 0x18, 0x06, 0x11, 0x20, 0x10, + 0x05, 0x3B, 0x02, 0x05, 0x12, 0x08, 0x14, 0x29, 0x15, 0x08, 0x13, 0x0B, + 0x0F, 0x30, 0x13, 0x23, 0x4C, 0x23, 0x17, 0x2D, 0x15, 0x31, 0x61, 0x31, + 0x29, 0x52, 0x52, 0x52, 0x29, 0x11, 0x5A, 0x03, 0x04, 0x05, 0x02, 0x03, + 0x02, 0x2B, 0x15, 0x14, 0x28, 0x14, 0x50, 0x9F, 0x50, 0x27, 0x4E, 0x27, + 0x0D, 0x1F, 0x0D, 0x13, 0x20, 0x0F, 0x10, 0x21, 0x13, 0x08, 0x0F, 0x08, + 0x08, 0x11, 0x06, 0x0B, 0x18, 0x0F, 0x09, 0x11, 0x09, 0x06, 0x0C, 0x06, + 0x03, 0x07, 0x03, 0x04, 0x07, 0x04, 0x03, 0x0B, 0x03, 0x0A, 0x09, 0x05, + 0x02, 0x02, 0x03, 0x1F, 0x05, 0x05, 0x0A, 0x05, 0x04, 0x04, 0x02, 0x02, + 0x1E, 0x01, 0x05, 0x02, 0x10, 0x01, 0x05, 0x06, 0x0C, 0x06, 0x04, 0x01, + 0x11, 0x03, 0x03, 0x04, 0x02, 0x01, 0x0F, 0x02, 0x02, 0x0B, 0x07, 0x02, + 0x10, 0x01, 0x01, 0x02, 0x02, 0x06, 0x0B, 0x06, 0x07, 0x01, 0x1A, 0x06, + 0x06, 0x0C, 0x07, 0x02, 0x03, 0x01, 0x02, 0x0F, 0x02, 0x07, 0x08, 0x06, + 0x02, 0x0E, 0x02, 0x01, 0x03, 0x03, 0x02, 0x0F, 0x02, 0x02, 0x05, 0x05, + 0x07, 0x1A, 0x01, 0x08, 0x09, 0x1E, 0x02, 0x01, 0x03, 0x02, 0x07, 0x0D, + 0x06, 0x09, 0x03, 0x08, 0x02, 0x10, 0x22, 0x10, 0x37, 0x6E, 0x38, 0x1C, + 0x39, 0x1D, 0x04, 0x0A, 0x04, 0x0A, 0x15, 0x07, 0x03, 0x0C, 0x01, 0x01, + 0x01, 0x03, 0x0E, 0x0E, 0x05, 0x0C, 0x05, 0x02, 0x0E, 0x02, 0x09, 0x0A, + 0x02, 0xFD, 0xAE, 0x2B, 0x56, 0x55, 0x56, 0x2B, 0x20, 0x3F, 0x20, 0x01, + 0x03, 0x03, 0x04, 0x09, 0x04, 0x12, 0x25, 0x12, 0x3F, 0x7E, 0x3F, 0x18, + 0x30, 0x18, 0x06, 0x0D, 0x06, 0x07, 0x01, 0xFE, 0x7C, 0x55, 0x0F, 0x0B, + 0x15, 0x0B, 0x0D, 0x0D, 0x05, 0x07, 0x1B, 0x0B, 0x0A, 0x17, 0x0A, 0x16, + 0x4E, 0xFD, 0xA3, 0x07, 0x07, 0x16, 0x0D, 0x1F, 0x0D, 0x0C, 0x0C, 0x08, + 0x06, 0x0F, 0x08, 0x0E, 0x29, 0x0B, 0xFE, 0x5A, 0x07, 0x0E, 0x07, 0x01, + 0x06, 0x01, 0x01, 0x02, 0x05, 0x0C, 0x1B, 0x0E, 0x11, 0x25, 0x11, 0x11, + 0x23, 0x12, 0x12, 0x18, 0x04, 0x02, 0x04, 0x03, 0x05, 0x03, 0x0F, 0x12, + 0x23, 0x12, 0x1C, 0x38, 0x1D, 0x03, 0x1B, 0x12, 0x38, 0x15, 0x07, 0x0E, + 0x07, 0x04, 0x0F, 0x04, 0x02, 0x02, 0x01, 0x03, 0x0A, 0x0C, 0x1D, 0x0B, + 0x09, 0x04, 0x01, 0x02, 0x06, 0x04, 0x0C, 0x0A, 0x08, 0x08, 0x02, 0x0E, + 0x07, 0x11, 0x02, 0x03, 0x02, 0x01, 0x01, 0x09, 0x03, 0x04, 0x07, 0x03, + 0x07, 0x2B, 0x0E, 0x27, 0x4D, 0x27, 0x12, 0x24, 0x12, 0x07, 0x0F, 0x07, + 0x0A, 0x08, 0x01, 0x03, 0x07, 0x1A, 0x12, 0x1B, 0x12, 0x28, 0x52, 0x28, + 0x06, 0x37, 0x02, 0x06, 0x1D, 0x03, 0x01, 0x01, 0x01, 0x01, 0x02, 0x03, + 0x03, 0x07, 0x10, 0x07, 0x07, 0x0E, 0x06, 0x05, 0x02, 0x11, 0x22, 0x11, + 0x05, 0x1F, 0x04, 0x03, 0x02, 0x03, 0x0A, 0x05, 0x28, 0x4E, 0x27, 0x25, + 0x4A, 0x25, 0x0B, 0x01, 0x01, 0x01, 0x03, 0x01, 0x02, 0x03, 0x02, 0x01, + 0x05, 0x06, 0x08, 0x0E, 0x07, 0x17, 0x2E, 0x17, 0x23, 0x44, 0x22, 0x0A, + 0x12, 0x09, 0x0A, 0x11, 0x06, 0x05, 0x26, 0x03, 0x04, 0x03, 0x02, 0x01, + 0x02, 0x09, 0x02, 0x04, 0x03, 0x05, 0x0B, 0x09, 0x05, 0x1A, 0x08, 0x04, + 0x12, 0x03, 0x08, 0x02, 0x01, 0x04, 0x04, 0x09, 0x12, 0x09, 0x0E, 0x24, + 0x11, 0x08, 0x16, 0x07, 0x05, 0x02, 0x03, 0x08, 0x12, 0x09, 0x03, 0x21, + 0x0A, 0x11, 0x1F, 0x0F, 0x25, 0x48, 0x24, 0x0D, 0x31, 0x08, 0x0C, 0x10, + 0x04, 0x06, 0x09, 0x05, 0x03, 0x12, 0x08, 0x11, 0x22, 0x12, 0x0E, 0x1D, + 0x1D, 0x1D, 0x0F, 0x06, 0x02, 0x1B, 0x25, 0x4F, 0x25, 0x26, 0x4D, 0x27, + 0x1B, 0x07, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x03, 0x05, 0x0C, 0x0C, 0x0B, + 0x0B, 0x04, 0x02, 0x03, 0x02, 0x03, 0x14, 0x05, 0x0B, 0x20, 0x02, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x01, 0x03, 0x01, 0x04, 0x02, 0x02, 0x01, 0x08, + 0x0A, 0x0B, 0x16, 0x0B, 0x02, 0x05, 0x03, 0x02, 0x13, 0x02, 0x03, 0x03, + 0x0D, 0x02, 0x02, 0x03, 0x01, 0x04, 0x09, 0x01, 0x02, 0x04, 0x0A, 0x0A, + 0x04, 0x02, 0x01, 0x0D, 0x02, 0x01, 0x01, 0x01, 0x03, 0x07, 0x06, 0x02, + 0x02, 0x01, 0x0E, 0x07, 0x07, 0x01, 0x03, 0x08, 0x06, 0x04, 0x0E, 0x01, + 0x02, 0x02, 0x03, 0x06, 0x07, 0x01, 0x01, 0x01, 0x02, 0x0D, 0x02, 0x02, + 0x02, 0x0D, 0x02, 0x08, 0x07, 0x02, 0x04, 0x09, 0x01, 0x03, 0x02, 0x02, + 0x0D, 0x16, 0x07, 0x01, 0x01, 0x01, 0x04, 0x18, 0x08, 0x03, 0x0A, 0x04, + 0x06, 0x0D, 0x05, 0x0D, 0x13, 0x04, 0x02, 0x0C, 0x02, 0x0A, 0x1B, 0x0C, + 0x27, 0x0D, 0x06, 0x07, 0xFE, 0x92, 0x1C, 0x02, 0x0E, 0x0B, 0x0F, 0x12, + 0x02, 0x01, 0x01, 0x01, 0x23, 0x88, 0x10, 0x1D, 0x02, 0x03, 0x03, 0x1B, + 0x09, 0x08, 0x05, 0x02, 0x0A, 0x46, 0x01, 0x01, 0x01, 0x26, 0x4B, 0x26, + 0x06, 0x18, 0x04, 0x08, 0x05, 0x03, 0x03, 0x0E, 0x05, 0x06, 0x0F, 0x08, + 0x0A, 0x13, 0x18, 0x09, 0x11, 0x08, 0x0E, 0x0B, 0x02, 0x03, 0x0A, 0x04, + 0x08, 0x0B, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5D, 0x00, 0x40, 0x0A, 0x2D, + 0x03, 0x44, 0x01, 0x27, 0x01, 0x4A, 0x01, 0x75, 0x00, 0x00, 0x01, 0x1E, + 0x01, 0x27, 0x26, 0x16, 0x17, 0x26, 0x06, 0x23, 0x2A, 0x01, 0x23, 0x22, + 0x26, 0x37, 0x3E, 0x01, 0x27, 0x26, 0x36, 0x37, 0x36, 0x26, 0x27, 0x26, + 0x06, 0x07, 0x06, 0x16, 0x07, 0x0E, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x2A, + 0x01, 0x23, 0x22, 0x06, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x06, 0x07, 0x22, + 0x06, 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x23, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x23, 0x2A, + 0x01, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x26, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x22, 0x07, 0x0E, + 0x01, 0x23, 0x22, 0x06, 0x23, 0x22, 0x26, 0x27, 0x2A, 0x01, 0x07, 0x0E, + 0x01, 0x27, 0x36, 0x26, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x23, 0x2E, + 0x01, 0x23, 0x22, 0x26, 0x07, 0x06, 0x14, 0x15, 0x14, 0x06, 0x17, 0x1E, + 0x01, 0x15, 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x16, 0x07, 0x06, + 0x16, 0x15, 0x14, 0x16, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x03, 0x37, 0x36, + 0x16, 0x17, 0x16, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x17, 0x1E, + 0x01, 0x33, 0x32, 0x36, 0x37, 0x36, 0x26, 0x27, 0x3E, 0x01, 0x37, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x16, + 0x36, 0x33, 0x3A, 0x01, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x17, 0x16, + 0x06, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x34, 0x37, 0x36, + 0x26, 0x37, 0x36, 0x16, 0x17, 0x16, 0x06, 0x37, 0x14, 0x32, 0x37, 0x3E, + 0x01, 0x35, 0x26, 0x36, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x03, 0x33, 0x32, + 0x16, 0x37, 0x3E, 0x01, 0x17, 0x16, 0x06, 0x33, 0x36, 0x16, 0x37, 0x36, + 0x34, 0x35, 0x26, 0x36, 0x35, 0x34, 0x36, 0x27, 0x2E, 0x01, 0x27, 0x34, + 0x36, 0x27, 0x36, 0x16, 0x33, 0x32, 0x16, 0x37, 0x36, 0x26, 0x35, 0x34, + 0x36, 0x27, 0x05, 0x0E, 0x03, 0x07, 0x3E, 0x01, 0x37, 0x36, 0x26, 0x37, + 0x06, 0x26, 0x37, 0x3E, 0x01, 0x35, 0x34, 0x26, 0x33, 0x3A, 0x01, 0x33, + 0x3A, 0x03, 0x33, 0x0E, 0x01, 0x07, 0x3A, 0x01, 0x23, 0x05, 0x06, 0x26, + 0x27, 0x2A, 0x01, 0x23, 0x22, 0x06, 0x27, 0x2E, 0x01, 0x37, 0x36, 0x26, + 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, + 0x27, 0x2E, 0x01, 0x37, 0x36, 0x16, 0x33, 0x32, 0x36, 0x17, 0x16, 0x06, + 0x15, 0x14, 0x16, 0x07, 0x0A, 0x25, 0x01, 0x02, 0x03, 0x03, 0x02, 0x01, + 0x09, 0x2C, 0x0B, 0x0D, 0x1B, 0x0E, 0x0B, 0x11, 0x01, 0x01, 0x01, 0x04, + 0x02, 0x04, 0x01, 0x02, 0x05, 0x04, 0x06, 0x3A, 0x0C, 0x0A, 0x06, 0x01, + 0x04, 0x28, 0x15, 0x1E, 0x3A, 0x1D, 0x3A, 0x74, 0x3A, 0x08, 0x20, 0x05, + 0x03, 0x08, 0x04, 0x05, 0x19, 0x07, 0x08, 0x12, 0x06, 0x0A, 0x01, 0x13, + 0x06, 0x0D, 0x08, 0x03, 0x07, 0x03, 0x03, 0x01, 0x04, 0x0C, 0x23, 0x06, + 0x02, 0x11, 0x05, 0x06, 0x11, 0x08, 0x0C, 0x0C, 0x0A, 0x04, 0x0C, 0x03, + 0x02, 0x0F, 0x03, 0x04, 0x08, 0x05, 0x0D, 0x1A, 0x0C, 0x19, 0x32, 0x19, + 0x33, 0x65, 0x33, 0x17, 0x34, 0x17, 0x13, 0x1D, 0x0E, 0x0A, 0x15, 0x0F, + 0x12, 0x19, 0x10, 0x07, 0x10, 0x09, 0x0C, 0x17, 0x0C, 0x1B, 0x36, 0x1B, + 0x22, 0x44, 0x22, 0x0D, 0x1B, 0x0D, 0x06, 0x14, 0x04, 0x09, 0x07, 0x08, + 0x08, 0x0D, 0x08, 0x15, 0x35, 0x16, 0x37, 0x6E, 0x37, 0x14, 0x29, 0x0A, + 0x04, 0x02, 0x05, 0x07, 0x05, 0x03, 0x05, 0x0E, 0x05, 0x09, 0x17, 0x0C, + 0x88, 0x06, 0x04, 0xB2, 0xDC, 0xC2, 0x14, 0x1E, 0x46, 0x1B, 0x1A, 0x0A, + 0x09, 0x0A, 0x10, 0x0F, 0x12, 0x11, 0x16, 0x15, 0x44, 0x21, 0x0C, 0x1B, + 0x07, 0x06, 0x01, 0x0D, 0x09, 0x06, 0x04, 0x06, 0x0D, 0x05, 0x05, 0x0C, + 0x06, 0x03, 0x09, 0x08, 0x0A, 0x0C, 0x05, 0x09, 0x2B, 0x0B, 0x13, 0x24, + 0x12, 0x10, 0x21, 0x0D, 0x07, 0x11, 0x09, 0x07, 0x08, 0x01, 0x03, 0x1F, + 0x07, 0x04, 0x01, 0x03, 0x04, 0x03, 0x06, 0x08, 0x09, 0x07, 0x11, 0x01, + 0x01, 0x01, 0x11, 0x1E, 0x06, 0x06, 0x04, 0x01, 0x08, 0x0C, 0x31, 0x62, + 0x30, 0x32, 0x63, 0x64, 0x63, 0x32, 0x13, 0x28, 0x14, 0x0D, 0x1C, 0x0E, + 0x0F, 0x01, 0x11, 0x0E, 0x20, 0x0E, 0x0C, 0x02, 0x01, 0x05, 0x03, 0x02, + 0x05, 0x05, 0x06, 0x0F, 0x12, 0x28, 0x12, 0x08, 0x2A, 0x05, 0x07, 0x03, + 0x05, 0x08, 0xF8, 0xF4, 0x11, 0xB9, 0xD7, 0xB9, 0x11, 0x02, 0x07, 0x01, + 0x02, 0x06, 0x02, 0x0E, 0x03, 0x01, 0x01, 0x02, 0x05, 0x0F, 0x20, 0x41, + 0x21, 0x3E, 0x7D, 0x7D, 0x7D, 0x3E, 0x04, 0x06, 0x05, 0x01, 0x01, 0x02, + 0x02, 0x98, 0x09, 0x41, 0x0F, 0x10, 0x1F, 0x10, 0x0C, 0x1C, 0x04, 0x02, + 0x02, 0x03, 0x04, 0x02, 0x08, 0x09, 0x08, 0x02, 0x03, 0x08, 0x09, 0x07, + 0x13, 0x0A, 0x08, 0x11, 0x0B, 0x0A, 0x21, 0x1A, 0x0F, 0x1E, 0x0F, 0x06, + 0x2D, 0x04, 0x03, 0x03, 0x04, 0x04, 0x02, 0x82, 0x02, 0x02, 0x04, 0x03, + 0x02, 0x01, 0x09, 0x04, 0x01, 0x0E, 0x13, 0x28, 0x12, 0x0A, 0x15, 0x0A, + 0x0B, 0x13, 0x0A, 0x10, 0x09, 0x02, 0x02, 0x2E, 0x07, 0x1C, 0x01, 0x03, + 0x07, 0x05, 0x09, 0x05, 0x05, 0x04, 0x01, 0x01, 0x07, 0x09, 0x1D, 0x0E, + 0x04, 0x09, 0x03, 0x01, 0x02, 0x02, 0x02, 0x06, 0x01, 0x04, 0x0A, 0x0C, + 0x06, 0x0B, 0x05, 0x06, 0x04, 0x01, 0x17, 0x08, 0x03, 0x08, 0x05, 0x03, + 0x01, 0x04, 0x03, 0x0E, 0x04, 0x04, 0x04, 0x23, 0x0D, 0x0A, 0x18, 0x01, + 0x01, 0x1B, 0x08, 0x05, 0x01, 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x09, 0x03, 0x04, 0x0D, 0x04, 0x04, 0x0B, 0x03, 0x09, 0x04, 0x01, 0x01, + 0x04, 0x17, 0x0A, 0x19, 0x0B, 0x07, 0x20, 0x05, 0x06, 0x06, 0x0A, 0x0A, + 0x13, 0x0A, 0x0C, 0x19, 0x0C, 0x05, 0x1F, 0x03, 0x07, 0x40, 0x0F, 0x11, + 0x24, 0x0B, 0x06, 0x28, 0x03, 0x01, 0x39, 0x45, 0x3D, 0x05, 0x08, 0x03, + 0x12, 0x11, 0x3B, 0x17, 0x1B, 0x36, 0x17, 0x1C, 0x46, 0x1C, 0x1D, 0x0D, + 0x03, 0x0B, 0x08, 0x25, 0x04, 0x0A, 0x20, 0x0D, 0x10, 0x20, 0x11, 0x12, + 0x23, 0x11, 0x0A, 0x16, 0x06, 0x06, 0x14, 0x05, 0x09, 0x04, 0x02, 0x02, + 0x01, 0x09, 0x05, 0x09, 0x01, 0x01, 0x17, 0x06, 0x0A, 0x06, 0x08, 0x06, + 0x0C, 0x06, 0x07, 0x0F, 0x07, 0x0A, 0x22, 0x08, 0x05, 0x23, 0x04, 0x07, + 0x33, 0x0A, 0x0B, 0x01, 0x01, 0x06, 0x06, 0x0C, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x17, 0x01, 0x05, 0x05, 0x04, 0x1D, 0x0B, 0x13, 0x27, + 0x13, 0x08, 0x13, 0x07, 0x04, 0x0E, 0x01, 0x09, 0x1C, 0x02, 0x05, 0x02, + 0x05, 0x07, 0x09, 0x1B, 0x0B, 0x0A, 0x20, 0x09, 0x9D, 0x05, 0x3B, 0x45, + 0x3D, 0x07, 0x03, 0x02, 0x04, 0x03, 0x05, 0x04, 0x01, 0x21, 0x09, 0x14, + 0x26, 0x14, 0x07, 0x40, 0x02, 0x07, 0x01, 0x7A, 0x13, 0x04, 0x01, 0x03, + 0x0E, 0x08, 0x16, 0x08, 0x0A, 0x1A, 0x07, 0x08, 0x07, 0x09, 0x0D, 0x18, + 0x09, 0x08, 0x0C, 0x02, 0x02, 0x0D, 0x08, 0x07, 0x36, 0x02, 0x01, 0x01, + 0x04, 0x05, 0x06, 0x1B, 0x06, 0x09, 0x1B, 0x08, 0x00, 0x04, 0x00, 0x61, + 0x00, 0x26, 0x05, 0x9E, 0x03, 0x5A, 0x01, 0x02, 0x01, 0x0B, 0x01, 0x18, + 0x01, 0x2D, 0x00, 0x00, 0x01, 0x34, 0x06, 0x23, 0x22, 0x06, 0x27, 0x2E, + 0x01, 0x27, 0x36, 0x26, 0x35, 0x34, 0x36, 0x23, 0x36, 0x26, 0x27, 0x26, + 0x06, 0x27, 0x2E, 0x01, 0x23, 0x26, 0x06, 0x23, 0x2A, 0x03, 0x23, 0x2A, + 0x01, 0x23, 0x22, 0x06, 0x07, 0x26, 0x06, 0x23, 0x22, 0x26, 0x27, 0x26, + 0x06, 0x07, 0x30, 0x07, 0x06, 0x23, 0x0E, 0x01, 0x07, 0x06, 0x14, 0x17, + 0x2A, 0x01, 0x23, 0x22, 0x26, 0x23, 0x26, 0x06, 0x07, 0x0E, 0x01, 0x07, + 0x06, 0x16, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x16, 0x33, 0x32, 0x36, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x35, 0x34, 0x36, 0x37, 0x06, 0x16, 0x17, + 0x16, 0x36, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x17, 0x1E, 0x01, 0x17, + 0x16, 0x36, 0x33, 0x32, 0x36, 0x37, 0x32, 0x16, 0x37, 0x3E, 0x01, 0x17, + 0x16, 0x06, 0x17, 0x16, 0x06, 0x15, 0x14, 0x06, 0x07, 0x0E, 0x01, 0x15, + 0x14, 0x16, 0x15, 0x14, 0x16, 0x17, 0x1E, 0x01, 0x15, 0x14, 0x16, 0x17, + 0x1E, 0x01, 0x15, 0x14, 0x16, 0x15, 0x14, 0x16, 0x17, 0x1E, 0x01, 0x33, + 0x32, 0x16, 0x33, 0x32, 0x36, 0x37, 0x36, 0x16, 0x27, 0x26, 0x36, 0x27, + 0x2E, 0x01, 0x27, 0x26, 0x34, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, + 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x37, 0x36, 0x26, 0x35, 0x34, 0x36, 0x35, + 0x3C, 0x01, 0x33, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x35, 0x34, 0x36, 0x35, + 0x34, 0x36, 0x27, 0x36, 0x32, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x16, 0x15, + 0x1C, 0x01, 0x15, 0x14, 0x06, 0x07, 0x06, 0x16, 0x17, 0x1E, 0x01, 0x37, + 0x36, 0x26, 0x35, 0x3C, 0x01, 0x35, 0x34, 0x36, 0x37, 0x3E, 0x01, 0x17, + 0x1E, 0x01, 0x17, 0x16, 0x36, 0x35, 0x34, 0x2F, 0x01, 0x3E, 0x01, 0x33, + 0x3A, 0x01, 0x33, 0x32, 0x16, 0x37, 0x36, 0x26, 0x35, 0x05, 0x3C, 0x01, + 0x35, 0x3C, 0x01, 0x35, 0x16, 0x14, 0x05, 0x2E, 0x01, 0x37, 0x1E, 0x01, + 0x17, 0x1E, 0x01, 0x17, 0x22, 0x26, 0x27, 0x37, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x23, 0x22, 0x26, 0x27, 0x2E, 0x01, 0x35, 0x36, 0x16, 0x33, 0x32, + 0x36, 0x07, 0x16, 0x06, 0x05, 0x98, 0x19, 0x07, 0x0D, 0x4F, 0x08, 0x03, + 0x06, 0x03, 0x03, 0x08, 0x01, 0x0C, 0x05, 0x0D, 0x09, 0x0E, 0x1F, 0x0B, + 0x0B, 0x0C, 0x0F, 0x0C, 0x1B, 0x0D, 0x48, 0x91, 0x90, 0x91, 0x48, 0x31, + 0x62, 0x31, 0x13, 0x16, 0x08, 0x05, 0x04, 0x05, 0x06, 0x05, 0x06, 0x0C, + 0x0D, 0x07, 0x03, 0x02, 0x01, 0x01, 0x05, 0x01, 0x03, 0x05, 0x0E, 0x1A, + 0x0D, 0x09, 0x03, 0x07, 0x05, 0x18, 0x03, 0x04, 0x05, 0x01, 0x01, 0x01, + 0x04, 0x1F, 0x19, 0x16, 0x09, 0x05, 0x08, 0x05, 0x03, 0x0F, 0x08, 0x06, + 0x01, 0x0A, 0x04, 0x07, 0x13, 0x08, 0x12, 0x25, 0x12, 0x08, 0x24, 0x08, + 0x03, 0x04, 0x03, 0x05, 0x0E, 0x06, 0x10, 0x20, 0x10, 0x06, 0x0A, 0x04, + 0x04, 0x02, 0x04, 0x02, 0x01, 0x02, 0x07, 0x0D, 0x0E, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x08, 0x0C, 0x04, 0x09, 0x04, 0x01, 0x05, 0x07, 0x0A, 0x06, + 0x06, 0x13, 0x0F, 0x09, 0x13, 0x0A, 0x0B, 0x12, 0x09, 0x09, 0x33, 0x06, + 0x03, 0x04, 0x04, 0x01, 0x04, 0x02, 0x01, 0x01, 0x01, 0x03, 0x02, 0x03, + 0x04, 0x02, 0x03, 0x04, 0x02, 0x04, 0x0F, 0x07, 0x07, 0x0C, 0x02, 0x09, + 0x17, 0x2F, 0x17, 0x1A, 0x30, 0x14, 0x04, 0x04, 0x03, 0x08, 0x04, 0x24, + 0x48, 0x24, 0x10, 0x0D, 0x01, 0x02, 0x03, 0x06, 0x26, 0x0D, 0x3C, 0x06, + 0x04, 0x04, 0x0A, 0x07, 0x0B, 0x12, 0x09, 0x02, 0x11, 0x04, 0x09, 0x0A, + 0x02, 0x02, 0x02, 0x14, 0x01, 0x11, 0x20, 0x10, 0x09, 0x1B, 0x05, 0x06, + 0x06, 0xFA, 0xD9, 0x03, 0x02, 0x64, 0x01, 0x01, 0x01, 0x02, 0x04, 0x02, + 0x03, 0x06, 0x05, 0x0F, 0x02, 0x04, 0x7C, 0x03, 0x03, 0x03, 0x05, 0x12, + 0x0A, 0x0C, 0x02, 0x06, 0x03, 0x16, 0x01, 0x32, 0x09, 0x07, 0x1F, 0x04, + 0x02, 0x07, 0x02, 0xC3, 0x0B, 0x02, 0x06, 0x0B, 0x01, 0x04, 0x01, 0x08, + 0x10, 0x08, 0x06, 0x0D, 0x0C, 0x1A, 0x05, 0x07, 0x05, 0x08, 0x09, 0x11, + 0x01, 0x02, 0x11, 0x10, 0x04, 0x05, 0x02, 0x03, 0x06, 0x07, 0x08, 0x04, + 0x05, 0x03, 0x05, 0x03, 0x06, 0x0D, 0x06, 0x07, 0x01, 0x08, 0x07, 0x08, + 0x07, 0x07, 0x06, 0x0C, 0x06, 0x3B, 0x77, 0x3B, 0x18, 0x1D, 0x16, 0x14, + 0x0B, 0x16, 0x0A, 0x08, 0x1C, 0x08, 0x08, 0x2B, 0x04, 0x05, 0x13, 0x02, + 0x04, 0x02, 0x04, 0x04, 0x02, 0x09, 0x02, 0x02, 0x05, 0x01, 0x01, 0x03, + 0x02, 0x02, 0x0A, 0x04, 0x03, 0x0A, 0x01, 0x03, 0x2F, 0x05, 0x0C, 0x1C, + 0x0D, 0x0F, 0x1D, 0x10, 0x0E, 0x1F, 0x0E, 0x06, 0x15, 0x02, 0x03, 0x05, + 0x0D, 0x20, 0x38, 0x1E, 0x07, 0x10, 0x07, 0x08, 0x0D, 0x07, 0x0D, 0x24, + 0x0A, 0x0D, 0x02, 0x06, 0x03, 0x02, 0x01, 0x02, 0x0D, 0x06, 0x11, 0x07, + 0x02, 0x01, 0x03, 0x01, 0x04, 0x02, 0x03, 0x06, 0x04, 0x06, 0x0F, 0x07, + 0x0F, 0x1C, 0x0F, 0x18, 0x42, 0x18, 0x1C, 0x3B, 0x1E, 0x10, 0x1D, 0x0F, + 0x06, 0x15, 0x02, 0x01, 0x02, 0x07, 0x20, 0x09, 0x0C, 0x06, 0x07, 0x0F, + 0x08, 0x01, 0x01, 0x10, 0x0F, 0x1D, 0x0F, 0x1E, 0x3B, 0x1E, 0x20, 0x47, + 0x0C, 0x05, 0x15, 0x12, 0x0C, 0x23, 0x0C, 0x3C, 0x76, 0x3B, 0x0B, 0x09, + 0x04, 0x07, 0x10, 0x12, 0x04, 0x14, 0x02, 0x07, 0x0E, 0x09, 0x02, 0x07, + 0x07, 0x04, 0x05, 0x02, 0x09, 0x09, 0x2A, 0x0A, 0x2B, 0x09, 0x13, 0x09, + 0x03, 0x08, 0x03, 0x0A, 0x1F, 0x67, 0x04, 0x09, 0x04, 0x04, 0x07, 0x04, + 0x03, 0x09, 0x02, 0x02, 0x0A, 0x11, 0x04, 0x0C, 0x04, 0x08, 0x01, 0x08, + 0x06, 0x03, 0x21, 0x03, 0x08, 0x03, 0x03, 0x0D, 0x06, 0x08, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x4F, 0x00, 0x3E, 0x07, 0xD5, 0x03, 0x43, 0x01, 0x08, + 0x01, 0x15, 0x01, 0x28, 0x01, 0x2B, 0x00, 0x00, 0x01, 0x3E, 0x01, 0x27, + 0x36, 0x16, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x03, 0x33, 0x32, 0x36, 0x17, + 0x1E, 0x01, 0x17, 0x16, 0x36, 0x33, 0x32, 0x16, 0x17, 0x1E, 0x01, 0x15, + 0x14, 0x06, 0x15, 0x16, 0x06, 0x27, 0x2A, 0x01, 0x23, 0x1E, 0x01, 0x17, + 0x16, 0x06, 0x17, 0x14, 0x06, 0x23, 0x2A, 0x01, 0x27, 0x2E, 0x01, 0x27, + 0x26, 0x06, 0x15, 0x14, 0x06, 0x15, 0x14, 0x16, 0x15, 0x14, 0x16, 0x17, + 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x34, 0x35, + 0x34, 0x26, 0x27, 0x2E, 0x01, 0x35, 0x2E, 0x01, 0x35, 0x34, 0x26, 0x35, + 0x34, 0x26, 0x27, 0x2E, 0x01, 0x35, 0x34, 0x26, 0x27, 0x26, 0x06, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x0E, 0x01, 0x15, + 0x1C, 0x01, 0x15, 0x14, 0x06, 0x23, 0x22, 0x16, 0x07, 0x06, 0x26, 0x23, + 0x2A, 0x01, 0x23, 0x30, 0x37, 0x34, 0x27, 0x34, 0x36, 0x27, 0x26, 0x06, + 0x23, 0x06, 0x26, 0x27, 0x26, 0x36, 0x35, 0x34, 0x36, 0x37, 0x3E, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x26, + 0x27, 0x2E, 0x01, 0x23, 0x22, 0x06, 0x23, 0x06, 0x26, 0x07, 0x06, 0x26, + 0x35, 0x3C, 0x01, 0x35, 0x3C, 0x01, 0x35, 0x34, 0x06, 0x27, 0x26, 0x06, + 0x27, 0x22, 0x26, 0x33, 0x26, 0x06, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, + 0x23, 0x22, 0x16, 0x15, 0x14, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x06, 0x22, 0x07, 0x3C, 0x01, 0x35, 0x3C, 0x01, 0x35, 0x3C, 0x01, + 0x35, 0x34, 0x16, 0x33, 0x1E, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, + 0x37, 0x3A, 0x01, 0x37, 0x32, 0x36, 0x35, 0x3C, 0x01, 0x35, 0x34, 0x26, + 0x37, 0x36, 0x16, 0x35, 0x34, 0x36, 0x37, 0x01, 0x2E, 0x01, 0x27, 0x0E, + 0x01, 0x17, 0x1E, 0x01, 0x17, 0x2E, 0x01, 0x27, 0x37, 0x2E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x14, 0x16, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x01, 0x26, 0x16, 0x03, 0x94, 0x02, 0x02, 0x01, 0x18, + 0x15, 0x15, 0x2D, 0x5B, 0x2D, 0x45, 0x8B, 0x8B, 0x8B, 0x46, 0x0B, 0x44, + 0x07, 0x09, 0x09, 0x08, 0x09, 0x32, 0x0F, 0x14, 0x2C, 0x13, 0x0B, 0x03, + 0x01, 0x01, 0x02, 0x11, 0x18, 0x30, 0x18, 0x0B, 0x15, 0x0B, 0x02, 0x01, + 0x01, 0x03, 0x11, 0x0F, 0x0A, 0x08, 0x08, 0x10, 0x09, 0x03, 0x32, 0x02, + 0x07, 0x0E, 0x05, 0x05, 0x09, 0x03, 0x05, 0x16, 0x19, 0x0D, 0x23, 0x0F, + 0x09, 0x15, 0x09, 0x07, 0x19, 0x05, 0x0F, 0x08, 0x05, 0x03, 0x09, 0x03, + 0x01, 0x06, 0x02, 0x02, 0x03, 0x02, 0x03, 0x04, 0x02, 0x01, 0x01, 0x02, + 0x0E, 0x15, 0x1C, 0x1B, 0x16, 0x09, 0x0E, 0x0A, 0x0D, 0x17, 0x0F, 0x22, + 0x3C, 0x19, 0x20, 0x0D, 0x03, 0x05, 0x04, 0x03, 0x01, 0x05, 0x3F, 0x0D, + 0x1C, 0x38, 0x1C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x10, 0x04, 0x0E, 0x14, + 0x05, 0x04, 0x01, 0x03, 0x09, 0x01, 0x07, 0x02, 0x01, 0x01, 0x01, 0x04, + 0x0B, 0x03, 0x07, 0x0E, 0x01, 0x01, 0x04, 0x04, 0x03, 0x0E, 0x06, 0x33, + 0x66, 0x33, 0x17, 0x3E, 0x13, 0x0A, 0x13, 0x16, 0x06, 0x01, 0x06, 0x02, + 0x01, 0x04, 0x01, 0x03, 0x09, 0x03, 0x3E, 0x7B, 0x3D, 0x3C, 0x77, 0x3B, + 0x10, 0x04, 0x07, 0x02, 0x03, 0x06, 0x02, 0x01, 0x06, 0x02, 0x04, 0x14, + 0x0F, 0x0D, 0x01, 0x1F, 0x47, 0x22, 0x48, 0x90, 0x48, 0x29, 0x55, 0x2A, + 0x0D, 0x1B, 0x0D, 0x07, 0x01, 0x06, 0x06, 0x09, 0x97, 0x06, 0x04, 0x01, + 0xD6, 0x0D, 0x10, 0x02, 0x05, 0x1D, 0x06, 0x0E, 0x24, 0x14, 0x03, 0x05, + 0x03, 0x7A, 0x11, 0x2D, 0x18, 0x13, 0x0C, 0x01, 0x08, 0x07, 0x05, 0x07, + 0x09, 0x0A, 0x11, 0x08, 0x10, 0x14, 0x0B, 0xFE, 0x1C, 0x01, 0x02, 0x03, + 0x35, 0x02, 0x04, 0x05, 0x03, 0x25, 0x06, 0x0D, 0x11, 0x29, 0x12, 0x13, + 0x0A, 0x04, 0x02, 0x01, 0x07, 0x0B, 0x0F, 0x36, 0x0F, 0x0B, 0x07, 0x01, + 0x19, 0x30, 0x18, 0x03, 0x0A, 0x03, 0x11, 0x08, 0x0E, 0x0F, 0x1E, 0x0F, + 0x06, 0x03, 0x0B, 0x11, 0x22, 0x11, 0x12, 0x21, 0x11, 0x10, 0x23, 0x0F, + 0x0F, 0x20, 0x10, 0x15, 0x63, 0x0D, 0x08, 0x05, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x07, 0x02, 0x06, 0x0A, 0x0D, 0x09, 0x11, 0x09, 0x03, 0x08, 0x04, + 0x06, 0x05, 0x05, 0x07, 0x14, 0x07, 0x10, 0x20, 0x11, 0x07, 0x11, 0x08, + 0x08, 0x10, 0x08, 0x12, 0x21, 0x12, 0x13, 0x25, 0x04, 0x06, 0x30, 0x0A, + 0x05, 0x0E, 0x05, 0x07, 0x0B, 0x02, 0x04, 0x01, 0x18, 0x3B, 0x84, 0x46, + 0x09, 0x11, 0x09, 0x04, 0x09, 0x0E, 0x03, 0x0A, 0x04, 0x06, 0x07, 0x01, + 0x01, 0x06, 0x02, 0x02, 0x01, 0x01, 0x01, 0x0F, 0x0F, 0x25, 0x10, 0x21, + 0x43, 0x1E, 0x04, 0x09, 0x04, 0x04, 0x08, 0x04, 0x09, 0x10, 0x08, 0x11, + 0x21, 0x12, 0x0A, 0x0E, 0x09, 0x05, 0x1A, 0x01, 0x01, 0x06, 0x0A, 0x05, + 0x12, 0x08, 0x11, 0x20, 0x10, 0x03, 0x08, 0x04, 0x08, 0x06, 0x06, 0x01, + 0x01, 0x04, 0x07, 0x01, 0x01, 0x1C, 0x0A, 0x15, 0x2E, 0x16, 0x20, 0x3F, + 0x1F, 0x07, 0x0E, 0x06, 0x10, 0x02, 0x36, 0x6C, 0x36, 0x1F, 0x3E, 0x1F, + 0x06, 0x0C, 0x06, 0x05, 0x07, 0x05, 0x01, 0x01, 0x01, 0x03, 0x07, 0x08, + 0x11, 0x09, 0x0D, 0x2C, 0x0B, 0x15, 0x10, 0x08, 0x0A, 0x03, 0x08, 0xFE, + 0x7A, 0x0D, 0x21, 0x12, 0x04, 0x1F, 0x05, 0x0E, 0x12, 0x02, 0x03, 0x05, + 0x02, 0x35, 0x11, 0x17, 0x04, 0x03, 0x04, 0x14, 0x0E, 0x1D, 0x0D, 0x07, + 0x09, 0x02, 0x01, 0x07, 0x04, 0x0A, 0x19, 0x0E, 0xFE, 0x92, 0x05, 0x06, + 0x00, 0x05, 0x00, 0x62, 0x00, 0x3F, 0x07, 0xDF, 0x03, 0x48, 0x00, 0x1E, + 0x00, 0x3C, 0x00, 0x5A, 0x00, 0x73, 0x01, 0x5E, 0x00, 0x00, 0x01, 0x06, + 0x16, 0x17, 0x1C, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x15, 0x14, + 0x06, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, + 0x01, 0x07, 0x0E, 0x01, 0x07, 0x05, 0x34, 0x26, 0x23, 0x2A, 0x01, 0x23, + 0x2A, 0x01, 0x23, 0x22, 0x26, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x06, 0x16, 0x17, 0x14, 0x16, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x01, + 0x36, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x26, 0x27, + 0x1C, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, + 0x3A, 0x01, 0x33, 0x32, 0x36, 0x37, 0x2A, 0x01, 0x15, 0x14, 0x06, 0x17, + 0x32, 0x16, 0x07, 0x0E, 0x01, 0x15, 0x1E, 0x01, 0x17, 0x16, 0x32, 0x35, + 0x3C, 0x01, 0x35, 0x34, 0x36, 0x27, 0x05, 0x1E, 0x01, 0x07, 0x06, 0x26, + 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x26, 0x23, 0x22, 0x06, + 0x07, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x1C, 0x01, + 0x07, 0x0E, 0x01, 0x23, 0x22, 0x06, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x06, + 0x07, 0x22, 0x06, 0x15, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x22, 0x06, 0x07, 0x22, 0x06, 0x27, 0x2E, 0x01, 0x37, 0x3E, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x27, 0x26, 0x06, 0x27, 0x22, 0x06, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, + 0x27, 0x26, 0x36, 0x35, 0x3C, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x23, 0x22, 0x26, 0x07, 0x0E, 0x01, 0x23, 0x2A, 0x01, + 0x23, 0x2A, 0x03, 0x23, 0x22, 0x36, 0x35, 0x3C, 0x01, 0x27, 0x34, 0x26, + 0x27, 0x26, 0x36, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x03, 0x33, 0x32, 0x16, + 0x37, 0x3E, 0x01, 0x33, 0x3A, 0x03, 0x33, 0x32, 0x26, 0x37, 0x3E, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x36, 0x34, 0x37, 0x3E, 0x01, 0x17, 0x1E, 0x01, + 0x15, 0x14, 0x16, 0x07, 0x0E, 0x01, 0x15, 0x14, 0x06, 0x33, 0x3A, 0x01, + 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x37, 0x3E, 0x01, + 0x35, 0x34, 0x06, 0x27, 0x26, 0x36, 0x35, 0x34, 0x36, 0x37, 0x32, 0x36, + 0x17, 0x16, 0x14, 0x15, 0x14, 0x16, 0x17, 0x1E, 0x01, 0x33, 0x32, 0x16, + 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x06, + 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x05, 0x5E, 0x08, 0x01, 0x01, + 0x01, 0x07, 0x0F, 0x07, 0x02, 0x0E, 0x01, 0x03, 0x13, 0x1A, 0x17, 0x1A, + 0x12, 0x0D, 0x09, 0x1D, 0x0B, 0x07, 0x08, 0x0E, 0x10, 0x23, 0x0C, 0xFE, + 0xF4, 0x0D, 0x11, 0x16, 0x2B, 0x16, 0x0B, 0x15, 0x0B, 0x03, 0x0B, 0x04, + 0x06, 0x0E, 0x04, 0x06, 0x0F, 0x04, 0x06, 0x04, 0x01, 0x0C, 0x10, 0x18, + 0x28, 0x19, 0x1B, 0x54, 0x02, 0x26, 0x06, 0x17, 0x04, 0x0C, 0x19, 0x0D, + 0x1A, 0x35, 0x1B, 0x27, 0x4F, 0x27, 0x01, 0x06, 0x0E, 0x06, 0x1E, 0x3C, + 0x1E, 0x20, 0x42, 0x21, 0x0A, 0x15, 0x0B, 0x09, 0x01, 0x2C, 0x0A, 0x08, + 0x01, 0x06, 0x05, 0x0A, 0x02, 0x03, 0x08, 0x01, 0x02, 0x01, 0x01, 0x0D, + 0x05, 0x0C, 0x01, 0x2C, 0x0D, 0x06, 0x16, 0x0D, 0x1F, 0x0E, 0x15, 0x2A, + 0x16, 0x05, 0x0A, 0x05, 0x03, 0x02, 0x02, 0x02, 0x08, 0x01, 0x07, 0x10, + 0x03, 0x03, 0x04, 0x02, 0x02, 0x04, 0x02, 0x03, 0x03, 0x0D, 0x09, 0x11, + 0x2E, 0x05, 0x03, 0x01, 0x05, 0x02, 0x3C, 0x08, 0x06, 0x0E, 0x01, 0x03, + 0x01, 0x03, 0x1F, 0x1C, 0x19, 0x40, 0x20, 0x0D, 0x1A, 0x0E, 0x06, 0x10, + 0x07, 0x0A, 0x10, 0x01, 0x01, 0x05, 0x02, 0x03, 0x06, 0x03, 0x01, 0x05, + 0x02, 0x07, 0x32, 0x10, 0x0B, 0x0A, 0x06, 0x05, 0x11, 0x07, 0x2F, 0x72, + 0x3D, 0x25, 0x4C, 0x25, 0x0C, 0x18, 0x0C, 0x0B, 0x01, 0x07, 0x0A, 0x14, + 0x0A, 0x18, 0x31, 0x18, 0x04, 0x09, 0x04, 0x03, 0x21, 0x01, 0x05, 0x11, + 0x0C, 0x0F, 0x1D, 0x0F, 0x2F, 0x5E, 0x5E, 0x5E, 0x2F, 0x20, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x0E, 0x0C, 0x0F, 0x1F, 0x0F, 0x34, 0x69, 0x68, 0x68, + 0x34, 0x17, 0x31, 0x17, 0x1D, 0x37, 0x1E, 0x2D, 0x5A, 0x5A, 0x5A, 0x2D, + 0x05, 0x03, 0x03, 0x08, 0x0F, 0x07, 0x04, 0x0A, 0x0B, 0x0C, 0x03, 0x04, + 0x20, 0x09, 0x04, 0x01, 0x01, 0x01, 0x01, 0x05, 0x02, 0x04, 0x0F, 0x1E, + 0x10, 0x35, 0x6A, 0x35, 0x0D, 0x1A, 0x0D, 0x05, 0x12, 0x05, 0x0B, 0x0E, + 0x05, 0x02, 0x01, 0x01, 0x0A, 0x09, 0x06, 0x18, 0x01, 0x01, 0x01, 0x03, + 0x03, 0x08, 0x0B, 0x08, 0x09, 0x06, 0x09, 0x12, 0x08, 0x0D, 0x1B, 0x02, + 0x05, 0x0C, 0x19, 0x0C, 0x1B, 0x34, 0x1B, 0x01, 0x60, 0x0C, 0x24, 0x0F, + 0x01, 0x0E, 0x01, 0x02, 0x03, 0x12, 0x01, 0x06, 0x15, 0x08, 0x0A, 0x2C, + 0x19, 0x10, 0x12, 0x0E, 0x0A, 0x07, 0x02, 0x02, 0x06, 0x0E, 0x23, 0x0E, + 0x2A, 0x02, 0x02, 0x02, 0x11, 0x04, 0x06, 0x0C, 0x06, 0x08, 0x18, 0x08, + 0x13, 0x20, 0x0B, 0x12, 0x0B, 0x0A, 0x0A, 0x2E, 0x01, 0x40, 0x09, 0x05, + 0x06, 0x02, 0x03, 0x1F, 0x04, 0x1B, 0x0B, 0x05, 0x06, 0x01, 0x07, 0x07, + 0x07, 0x0C, 0x07, 0x0C, 0x17, 0x0B, 0x05, 0x03, 0x0B, 0x15, 0x0A, 0x0B, + 0x33, 0x07, 0x79, 0x0B, 0x47, 0x05, 0x03, 0x02, 0x07, 0x06, 0x02, 0x08, + 0x13, 0x0B, 0x08, 0x16, 0x08, 0x13, 0x26, 0x13, 0x08, 0x15, 0x08, 0x09, + 0x02, 0x04, 0x16, 0x12, 0x25, 0x12, 0x0B, 0x02, 0x01, 0x17, 0x05, 0x0C, + 0x18, 0x0C, 0x23, 0x41, 0x16, 0x14, 0x15, 0x02, 0x02, 0x01, 0x02, 0x01, + 0x03, 0x03, 0x0C, 0x08, 0x10, 0x07, 0x0D, 0x19, 0x0D, 0x06, 0x0F, 0x06, + 0x11, 0x03, 0x01, 0x05, 0x0A, 0x06, 0x0D, 0x05, 0x24, 0x42, 0x02, 0x02, + 0x03, 0x03, 0x02, 0x02, 0x01, 0x01, 0x0E, 0x0B, 0x08, 0x05, 0x02, 0x04, + 0x08, 0x03, 0x09, 0x13, 0x09, 0x01, 0x05, 0x03, 0x02, 0x09, 0x15, 0x59, + 0x14, 0x26, 0x4B, 0x25, 0x2A, 0x53, 0x29, 0x12, 0x06, 0x03, 0x04, 0x05, + 0x04, 0x2E, 0x06, 0x13, 0x26, 0x13, 0x0B, 0x0F, 0x05, 0x05, 0x1B, 0x0B, + 0x0E, 0x15, 0x14, 0x08, 0x14, 0x09, 0x04, 0x09, 0x04, 0x02, 0x04, 0x04, + 0x04, 0x15, 0x0E, 0x03, 0x06, 0x06, 0x0D, 0x0A, 0x05, 0x04, 0x03, 0x0C, + 0x04, 0x07, 0x10, 0x01, 0x04, 0x0A, 0x0A, 0x14, 0x0A, 0x0A, 0x0F, 0x0A, + 0x0C, 0x06, 0x01, 0x06, 0x09, 0x13, 0x0A, 0x0D, 0x1C, 0x14, 0x18, 0x31, + 0x18, 0x04, 0x12, 0x00, 0x00, 0x03, 0x00, 0x5D, 0x00, 0x25, 0x0B, 0x9F, + 0x03, 0x5A, 0x01, 0x39, 0x01, 0x49, 0x01, 0x55, 0x00, 0x00, 0x01, 0x32, + 0x06, 0x15, 0x14, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x07, 0x0E, + 0x01, 0x23, 0x22, 0x06, 0x23, 0x2A, 0x01, 0x23, 0x06, 0x22, 0x23, 0x22, + 0x16, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, + 0x01, 0x27, 0x26, 0x06, 0x07, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x23, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x07, 0x14, 0x22, 0x23, 0x22, 0x06, 0x07, 0x2A, + 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x35, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x23, 0x14, 0x06, 0x07, 0x06, 0x16, 0x17, 0x1E, + 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, + 0x01, 0x27, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, + 0x26, 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x15, 0x14, 0x06, 0x27, 0x2E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x23, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, + 0x26, 0x27, 0x26, 0x34, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, + 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x03, 0x33, 0x3A, 0x01, 0x33, 0x32, + 0x16, 0x37, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x17, 0x32, 0x16, 0x17, 0x16, 0x36, 0x37, 0x36, + 0x16, 0x17, 0x1E, 0x01, 0x17, 0x14, 0x36, 0x37, 0x36, 0x16, 0x17, 0x16, + 0x36, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x2E, 0x01, 0x27, 0x3A, + 0x01, 0x33, 0x32, 0x06, 0x17, 0x16, 0x36, 0x33, 0x3A, 0x01, 0x33, 0x3A, + 0x03, 0x33, 0x3A, 0x01, 0x33, 0x26, 0x34, 0x35, 0x34, 0x26, 0x37, 0x3E, + 0x01, 0x33, 0x3E, 0x01, 0x37, 0x32, 0x06, 0x15, 0x1C, 0x01, 0x15, 0x1C, + 0x01, 0x15, 0x14, 0x06, 0x15, 0x14, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x16, + 0x36, 0x37, 0x36, 0x32, 0x37, 0x3E, 0x01, 0x17, 0x05, 0x22, 0x06, 0x17, + 0x1E, 0x01, 0x33, 0x32, 0x16, 0x37, 0x36, 0x26, 0x23, 0x2A, 0x01, 0x23, + 0x25, 0x1E, 0x01, 0x17, 0x3E, 0x01, 0x37, 0x2A, 0x01, 0x23, 0x1E, 0x01, + 0x0B, 0x8F, 0x10, 0x04, 0x08, 0x06, 0x0D, 0x1C, 0x0E, 0x24, 0x49, 0x25, + 0x2A, 0x55, 0x2A, 0x12, 0x23, 0x11, 0x0D, 0x18, 0x0C, 0x06, 0x0B, 0x06, + 0x09, 0x02, 0x03, 0x06, 0x29, 0x10, 0x0B, 0x14, 0x09, 0x03, 0x16, 0x04, + 0x0B, 0x13, 0x0B, 0x28, 0x52, 0x28, 0x0B, 0x02, 0x02, 0x01, 0x06, 0x05, + 0x08, 0x02, 0x01, 0x01, 0x02, 0x01, 0x1A, 0x02, 0x2D, 0x59, 0x2C, 0x29, + 0x55, 0x28, 0x0A, 0x15, 0x0A, 0x07, 0x1D, 0x07, 0x0D, 0x01, 0x1C, 0x37, + 0x1B, 0x06, 0x0E, 0x07, 0x04, 0x01, 0x04, 0x06, 0x02, 0x02, 0x08, 0x05, + 0x0D, 0x21, 0x13, 0x0A, 0x13, 0x0E, 0x28, 0x50, 0x26, 0x04, 0x0E, 0x06, + 0x05, 0x08, 0x03, 0x08, 0x0E, 0x05, 0x06, 0x0D, 0x06, 0x16, 0x22, 0x12, + 0x08, 0x11, 0x07, 0x05, 0x07, 0x05, 0x0A, 0x20, 0x0C, 0x16, 0x26, 0x14, + 0x06, 0x0A, 0x05, 0x04, 0x0B, 0x05, 0x07, 0x07, 0x03, 0x04, 0x08, 0x04, + 0x05, 0x09, 0x01, 0x02, 0x04, 0x03, 0x09, 0x0E, 0x1A, 0x0C, 0x14, 0x27, + 0x13, 0x09, 0x0A, 0x03, 0x10, 0x1F, 0x0D, 0x05, 0x0E, 0x0C, 0x06, 0x0C, + 0x06, 0x03, 0x1B, 0x05, 0x27, 0x4D, 0x26, 0x2B, 0x57, 0x2B, 0x42, 0x73, + 0x31, 0x1A, 0x35, 0x17, 0x06, 0x0B, 0x07, 0x10, 0x0B, 0x03, 0x05, 0x01, + 0x02, 0x03, 0x02, 0x02, 0x04, 0x03, 0x04, 0x09, 0x2D, 0x1B, 0x37, 0x1B, + 0x35, 0x6B, 0x6A, 0x6B, 0x35, 0x0B, 0x18, 0x0B, 0x05, 0x08, 0x04, 0x0C, + 0x08, 0x0D, 0x14, 0x27, 0x14, 0x0B, 0x0F, 0x09, 0x0B, 0x06, 0x01, 0x03, + 0x06, 0x1F, 0x0A, 0x0C, 0x08, 0x0A, 0x0D, 0x0E, 0x0C, 0x09, 0x06, 0x05, + 0x04, 0x02, 0x47, 0x07, 0x11, 0x24, 0x11, 0x0D, 0x1A, 0x0D, 0x36, 0x6D, + 0x36, 0x0A, 0x12, 0x0A, 0x01, 0x03, 0x03, 0x0A, 0x16, 0x0B, 0x10, 0x0C, + 0x0A, 0x05, 0x0E, 0x05, 0x27, 0x4E, 0x27, 0x38, 0x70, 0x70, 0x70, 0x38, + 0x1D, 0x3A, 0x1D, 0x01, 0x06, 0x03, 0x02, 0x0B, 0x06, 0x0B, 0x17, 0x0C, + 0x09, 0x02, 0x0A, 0x1E, 0x04, 0x0E, 0x25, 0x12, 0x4F, 0x9C, 0x4E, 0x17, + 0x2F, 0x17, 0x0F, 0x48, 0x0A, 0xF8, 0xB8, 0x17, 0x07, 0x0B, 0x09, 0x14, + 0x0C, 0x0A, 0x49, 0x05, 0x06, 0x04, 0x1D, 0x15, 0x29, 0x15, 0xFC, 0x5D, + 0x05, 0x07, 0x06, 0x3A, 0x7E, 0x40, 0x45, 0x87, 0x44, 0x01, 0x03, 0x02, + 0xD5, 0x49, 0x0B, 0x07, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x06, 0x08, + 0x0F, 0x1A, 0x07, 0x05, 0x13, 0x08, 0x03, 0x04, 0x02, 0x03, 0x05, 0x01, + 0x04, 0x04, 0x02, 0x0B, 0x0A, 0x04, 0x04, 0x01, 0x03, 0x09, 0x09, 0x13, + 0x0A, 0x01, 0x01, 0x01, 0x05, 0x02, 0x02, 0x01, 0x01, 0x09, 0x02, 0x03, + 0x42, 0x0B, 0x06, 0x09, 0x06, 0x01, 0x01, 0x01, 0x15, 0x02, 0x0D, 0x25, + 0x0D, 0x14, 0x26, 0x13, 0x33, 0x62, 0x31, 0x19, 0x35, 0x17, 0x0E, 0x29, + 0x14, 0x02, 0x08, 0x02, 0x06, 0x0E, 0x07, 0x10, 0x21, 0x10, 0x14, 0x27, + 0x14, 0x43, 0x89, 0x44, 0x04, 0x07, 0x04, 0x03, 0x07, 0x02, 0x06, 0x03, + 0x01, 0x02, 0x0A, 0x0A, 0x03, 0x07, 0x04, 0x04, 0x04, 0x03, 0x03, 0x18, + 0x07, 0x0B, 0x16, 0x0B, 0x10, 0x20, 0x11, 0x15, 0x2B, 0x16, 0x07, 0x0D, + 0x02, 0x04, 0x0C, 0x06, 0x09, 0x15, 0x09, 0x04, 0x12, 0x06, 0x26, 0x4E, + 0x27, 0x0E, 0x26, 0x0D, 0x07, 0x0D, 0x07, 0x04, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x04, 0x02, 0x02, 0x49, 0x28, 0x14, 0x2C, 0x17, 0x06, 0x11, 0x04, + 0x08, 0x1A, 0x0C, 0x12, 0x25, 0x11, 0x14, 0x27, 0x14, 0x14, 0x27, 0x14, + 0x1C, 0x4D, 0x01, 0x01, 0x1C, 0x03, 0x05, 0x05, 0x07, 0x04, 0x08, 0x08, + 0x09, 0x13, 0x0D, 0x17, 0x2A, 0x01, 0x0D, 0x08, 0x09, 0x02, 0x01, 0x02, + 0x05, 0x0A, 0x08, 0x14, 0x09, 0x03, 0x06, 0x01, 0x01, 0x08, 0x02, 0x01, + 0x01, 0x08, 0x0F, 0x07, 0x0C, 0x05, 0x02, 0x01, 0x05, 0x09, 0x05, 0x05, + 0x0F, 0x05, 0x05, 0x1A, 0x01, 0x02, 0x02, 0x0E, 0x08, 0x0D, 0x1A, 0x0D, + 0x04, 0x07, 0x03, 0x01, 0x03, 0x03, 0x04, 0x13, 0x02, 0x0B, 0x07, 0x01, + 0x04, 0x02, 0x01, 0x01, 0x03, 0x03, 0x0F, 0x0F, 0xA2, 0x30, 0x0E, 0x08, + 0x01, 0x04, 0x0E, 0x14, 0x29, 0x02, 0x24, 0x49, 0x24, 0x33, 0x5E, 0x2E, + 0x0B, 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x5A, 0x00, 0x40, 0x08, 0xA7, + 0x03, 0x41, 0x00, 0xC4, 0x00, 0xDB, 0x00, 0x00, 0x01, 0x17, 0x16, 0x06, + 0x17, 0x22, 0x06, 0x23, 0x06, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x06, + 0x07, 0x27, 0x23, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x23, 0x2A, 0x01, 0x23, + 0x2A, 0x01, 0x23, 0x22, 0x26, 0x07, 0x14, 0x16, 0x07, 0x06, 0x26, 0x27, + 0x2E, 0x01, 0x27, 0x07, 0x06, 0x14, 0x15, 0x0E, 0x01, 0x07, 0x1E, 0x01, + 0x1F, 0x01, 0x23, 0x0E, 0x01, 0x15, 0x17, 0x22, 0x26, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x37, 0x34, 0x26, 0x27, 0x26, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x23, 0x14, 0x16, 0x15, 0x1E, 0x01, 0x07, 0x0E, 0x01, 0x23, 0x2E, 0x03, + 0x27, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x23, 0x0E, 0x01, 0x07, 0x2E, 0x01, + 0x2F, 0x01, 0x0E, 0x01, 0x07, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x35, 0x33, 0x15, 0x1E, + 0x01, 0x17, 0x3E, 0x01, 0x37, 0x32, 0x1E, 0x02, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x35, 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x03, 0x17, + 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x33, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x15, 0x3A, 0x01, 0x33, + 0x32, 0x16, 0x37, 0x3E, 0x01, 0x1F, 0x01, 0x15, 0x25, 0x21, 0x22, 0x06, + 0x1D, 0x01, 0x14, 0x16, 0x33, 0x3A, 0x03, 0x33, 0x32, 0x16, 0x37, 0x36, + 0x26, 0x27, 0x2E, 0x01, 0x23, 0x08, 0x9F, 0x06, 0x02, 0x09, 0x01, 0x18, + 0x30, 0x18, 0x14, 0x26, 0x14, 0x22, 0x43, 0x22, 0x18, 0x29, 0x17, 0x0A, + 0x05, 0x04, 0x0C, 0x0D, 0x14, 0x22, 0x15, 0x29, 0x51, 0x29, 0x29, 0x52, + 0x29, 0x14, 0x26, 0x14, 0x01, 0x0D, 0x12, 0x36, 0x15, 0x12, 0x25, 0x11, + 0x14, 0x0D, 0x0A, 0x0B, 0x05, 0x01, 0x01, 0x01, 0x06, 0x06, 0x0D, 0x0A, + 0x04, 0x11, 0x25, 0x11, 0x08, 0x0F, 0x07, 0x04, 0x07, 0x03, 0x09, 0x07, + 0x07, 0x03, 0x09, 0x11, 0x0B, 0x25, 0x02, 0x09, 0x09, 0x18, 0x28, 0x17, + 0x18, 0x26, 0x0E, 0x0B, 0x12, 0x1B, 0x04, 0x02, 0x06, 0x01, 0x27, 0x58, + 0x30, 0x02, 0x05, 0x04, 0x03, 0x01, 0x1E, 0x3C, 0x1E, 0x01, 0x03, 0x09, + 0x0D, 0x1D, 0x0C, 0x04, 0x07, 0x04, 0x02, 0x32, 0x6A, 0x38, 0x01, 0x04, + 0x02, 0x0F, 0x15, 0x05, 0x02, 0x03, 0x14, 0x09, 0x12, 0x08, 0x05, 0x0C, + 0x05, 0xD0, 0x09, 0x14, 0x0B, 0x14, 0x20, 0x11, 0x29, 0x50, 0x50, 0x51, + 0x28, 0x04, 0x07, 0x03, 0x02, 0x09, 0x13, 0x48, 0x1A, 0x22, 0x44, 0x22, + 0x2E, 0x5A, 0x5A, 0x5B, 0x2D, 0x2B, 0x55, 0x2B, 0x2A, 0x55, 0x2B, 0x04, + 0x08, 0x04, 0x14, 0x03, 0x02, 0x01, 0x08, 0x02, 0x0F, 0x1D, 0x0E, 0x01, + 0x01, 0x16, 0x2B, 0x16, 0x13, 0x2A, 0x13, 0x27, 0x50, 0x28, 0x08, 0xFD, + 0xEE, 0xFD, 0x3F, 0x13, 0x12, 0x13, 0x12, 0x51, 0xA2, 0xA2, 0xA2, 0x52, + 0x0F, 0x38, 0x0B, 0x0E, 0x01, 0x0D, 0x04, 0x0D, 0x09, 0x02, 0x4A, 0x14, + 0x0A, 0x14, 0x0A, 0x05, 0x01, 0x09, 0x11, 0x01, 0x07, 0x15, 0x22, 0x12, + 0x07, 0x01, 0x01, 0x06, 0x16, 0x30, 0x12, 0x0C, 0x07, 0x02, 0x02, 0x05, + 0x06, 0x0D, 0x0A, 0x22, 0x0E, 0x04, 0x16, 0x09, 0x04, 0x0A, 0x04, 0x09, + 0x10, 0x1D, 0x15, 0x06, 0x0A, 0x03, 0x01, 0x06, 0x03, 0x01, 0x02, 0x02, + 0x04, 0x0D, 0x05, 0x25, 0x52, 0x22, 0x17, 0x23, 0x19, 0x05, 0x0A, 0x05, + 0x04, 0x02, 0x09, 0x08, 0x1F, 0x14, 0x12, 0x2C, 0x18, 0x30, 0x18, 0x1D, + 0x3C, 0x1D, 0x1C, 0x15, 0x2A, 0x55, 0x54, 0x55, 0x2A, 0x05, 0x0C, 0x07, + 0x07, 0x1B, 0x03, 0x09, 0x01, 0x05, 0x08, 0x04, 0x0A, 0x1A, 0x0F, 0x03, + 0x02, 0x03, 0x01, 0x2C, 0x5A, 0x2F, 0x20, 0x56, 0x1C, 0x0C, 0x15, 0x0C, + 0x08, 0x10, 0x08, 0x06, 0x06, 0x0D, 0x18, 0x0C, 0x09, 0x17, 0x0E, 0x04, + 0x04, 0x01, 0x05, 0x0B, 0x17, 0x0C, 0x09, 0x19, 0x0A, 0x12, 0x08, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x03, 0x03, 0x03, 0x01, 0x01, 0x03, 0x01, 0x01, + 0x03, 0x01, 0x06, 0x07, 0x16, 0x45, 0x1C, 0x13, 0x26, 0x14, 0x01, 0x06, + 0x03, 0x02, 0x05, 0x02, 0x03, 0x05, 0x0B, 0x02, 0x02, 0x04, 0x05, 0x99, + 0x14, 0x13, 0x23, 0x12, 0x13, 0x03, 0x0E, 0x0B, 0x43, 0x0B, 0x05, 0x06, + 0x00, 0x03, 0x00, 0x64, 0x00, 0x21, 0x0A, 0x42, 0x03, 0x60, 0x00, 0x18, + 0x00, 0x2B, 0x01, 0x91, 0x00, 0x00, 0x01, 0x34, 0x26, 0x23, 0x22, 0x16, + 0x17, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x0E, 0x01, 0x17, 0x1E, 0x01, + 0x33, 0x32, 0x16, 0x37, 0x3E, 0x01, 0x37, 0x01, 0x1E, 0x01, 0x33, 0x3A, + 0x01, 0x33, 0x32, 0x26, 0x37, 0x34, 0x36, 0x37, 0x22, 0x26, 0x07, 0x0E, + 0x01, 0x07, 0x17, 0x2E, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x06, 0x07, + 0x06, 0x26, 0x27, 0x26, 0x06, 0x23, 0x22, 0x26, 0x15, 0x14, 0x06, 0x07, + 0x06, 0x26, 0x23, 0x2A, 0x03, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x26, 0x27, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x35, 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, + 0x14, 0x16, 0x07, 0x06, 0x14, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x07, 0x22, 0x23, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, + 0x34, 0x36, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x36, 0x35, 0x0E, 0x01, 0x23, + 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x26, 0x07, 0x0E, 0x01, 0x27, + 0x26, 0x06, 0x07, 0x0E, 0x01, 0x17, 0x1E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x17, 0x16, 0x06, 0x23, 0x0E, 0x01, 0x2E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x26, 0x27, 0x26, + 0x06, 0x27, 0x26, 0x36, 0x37, 0x22, 0x26, 0x27, 0x2E, 0x01, 0x33, 0x2A, + 0x01, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x06, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x23, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x23, 0x2A, + 0x01, 0x23, 0x22, 0x36, 0x23, 0x22, 0x26, 0x07, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x06, 0x26, 0x27, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, + 0x26, 0x27, 0x2E, 0x01, 0x35, 0x3C, 0x01, 0x35, 0x3C, 0x01, 0x35, 0x34, + 0x26, 0x37, 0x3E, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x03, 0x33, 0x3A, + 0x01, 0x17, 0x16, 0x32, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, + 0x26, 0x37, 0x3E, 0x01, 0x33, 0x32, 0x26, 0x37, 0x3E, 0x01, 0x37, 0x3A, + 0x01, 0x33, 0x32, 0x16, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x26, 0x27, 0x26, + 0x36, 0x17, 0x1E, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x16, 0x33, 0x32, + 0x34, 0x35, 0x34, 0x16, 0x33, 0x3A, 0x01, 0x15, 0x14, 0x1D, 0x01, 0x3A, + 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x16, 0x17, 0x16, 0x36, 0x37, 0x36, + 0x16, 0x33, 0x32, 0x16, 0x37, 0x3E, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, + 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x17, 0x3E, 0x01, 0x37, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x33, 0x3A, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x1C, + 0x01, 0x15, 0x14, 0x36, 0x33, 0x32, 0x36, 0x33, 0x3A, 0x01, 0x33, 0x32, + 0x16, 0x15, 0x14, 0x06, 0x23, 0x2A, 0x01, 0x23, 0x05, 0x4D, 0x40, 0x18, + 0x0D, 0x0E, 0x02, 0x07, 0x13, 0x03, 0x07, 0x02, 0x01, 0x12, 0x0F, 0x0C, + 0x09, 0x1F, 0x11, 0x0E, 0x1D, 0x0E, 0x14, 0x08, 0x03, 0x03, 0xB7, 0x01, + 0x03, 0x05, 0x0D, 0x1A, 0x0D, 0x07, 0x02, 0x01, 0x01, 0x01, 0x08, 0x21, + 0x07, 0x06, 0x0B, 0x04, 0x8B, 0x01, 0x08, 0x01, 0x05, 0x0C, 0x06, 0x0E, + 0x08, 0x08, 0x07, 0x14, 0x04, 0x08, 0x1B, 0x08, 0x03, 0x1F, 0x0B, 0x10, + 0x07, 0x11, 0x07, 0x36, 0x6B, 0x6B, 0x6B, 0x35, 0x1E, 0x3B, 0x1D, 0x13, + 0x15, 0x09, 0x03, 0x06, 0x02, 0x02, 0x09, 0x0B, 0x05, 0x0A, 0x01, 0x01, + 0x01, 0x03, 0x06, 0x1B, 0x0C, 0x01, 0x08, 0x06, 0x01, 0x02, 0x02, 0x0A, + 0x13, 0x09, 0x1C, 0x38, 0x1C, 0x08, 0x27, 0x07, 0x02, 0x02, 0x01, 0x03, + 0x07, 0x04, 0x0C, 0x11, 0x01, 0x04, 0x03, 0x01, 0x0B, 0x03, 0x02, 0x01, + 0x05, 0x09, 0x07, 0x0D, 0x18, 0x0C, 0x0E, 0x1D, 0x0E, 0x07, 0x13, 0x06, + 0x0A, 0x07, 0x09, 0x08, 0x15, 0x04, 0x07, 0x09, 0x06, 0x02, 0x05, 0x06, + 0x07, 0x12, 0x05, 0x0D, 0x11, 0x09, 0x06, 0x05, 0x06, 0x08, 0x07, 0x0D, + 0x0B, 0x41, 0x3E, 0x27, 0x0E, 0x21, 0x43, 0x22, 0x04, 0x0A, 0x04, 0x08, + 0x08, 0x0E, 0x0C, 0x1F, 0x0A, 0x08, 0x02, 0x02, 0x05, 0x09, 0x04, 0x03, + 0x03, 0x01, 0x08, 0x10, 0x07, 0x1E, 0x3A, 0x1D, 0x09, 0x14, 0x09, 0x08, + 0x02, 0x05, 0x0D, 0x28, 0x0B, 0x04, 0x08, 0x0A, 0x11, 0x08, 0x09, 0x05, + 0x05, 0x0B, 0x0E, 0x1B, 0x0E, 0x0A, 0x08, 0x07, 0x06, 0x1E, 0x05, 0x13, + 0x26, 0x13, 0x08, 0x0F, 0x07, 0x0D, 0x0B, 0x01, 0x27, 0x4E, 0x27, 0x0B, + 0x20, 0x04, 0x05, 0x2B, 0x0E, 0x0C, 0x03, 0x02, 0x04, 0x08, 0x22, 0x10, + 0x2A, 0x54, 0x2A, 0x35, 0x69, 0x69, 0x69, 0x35, 0x09, 0x10, 0x02, 0x02, + 0x05, 0x08, 0x0D, 0x19, 0x0D, 0x1B, 0x35, 0x1A, 0x0B, 0x05, 0x06, 0x0B, + 0x13, 0x0D, 0x07, 0x07, 0x05, 0x06, 0x17, 0x09, 0x0A, 0x14, 0x0A, 0x05, + 0x1C, 0x04, 0x04, 0x13, 0x01, 0x03, 0x1C, 0x05, 0x08, 0x23, 0x15, 0x10, + 0x06, 0x01, 0x05, 0x09, 0x1F, 0x06, 0x05, 0x05, 0x29, 0x53, 0x2A, 0x2E, + 0x5C, 0x2E, 0x09, 0x09, 0x05, 0x03, 0x0A, 0x04, 0x04, 0x0E, 0x05, 0x04, + 0x0A, 0x01, 0x01, 0x05, 0x05, 0x03, 0x07, 0x04, 0x4F, 0xA0, 0x50, 0x29, + 0x52, 0x2A, 0x12, 0x30, 0x0C, 0x0C, 0x19, 0x0D, 0x04, 0x0B, 0x07, 0x0B, + 0x15, 0x0B, 0x0A, 0x06, 0x1C, 0x04, 0x07, 0x08, 0x07, 0x19, 0x32, 0x1A, + 0x16, 0x34, 0x1D, 0x15, 0x20, 0x41, 0x20, 0x01, 0xA0, 0x24, 0x01, 0x38, + 0x07, 0x04, 0x18, 0x04, 0x08, 0x15, 0x0A, 0x0C, 0x1E, 0x15, 0x12, 0x03, + 0x01, 0x01, 0x03, 0x1D, 0x0F, 0x01, 0x3D, 0x04, 0x1C, 0x18, 0x06, 0x0B, + 0x16, 0x0B, 0x04, 0x04, 0x04, 0x1F, 0x07, 0x81, 0x01, 0x06, 0x09, 0x0B, + 0x09, 0x12, 0x01, 0x04, 0x04, 0x01, 0x02, 0x12, 0x10, 0x07, 0x02, 0x01, + 0x03, 0x13, 0x05, 0x09, 0x05, 0x01, 0x04, 0x01, 0x08, 0x11, 0x09, 0x1A, + 0x34, 0x1A, 0x07, 0x09, 0x05, 0x0A, 0x15, 0x0D, 0x15, 0x2B, 0x14, 0x27, + 0x50, 0x26, 0x04, 0x02, 0x07, 0x01, 0x03, 0x06, 0x03, 0x09, 0x12, 0x09, + 0x02, 0x10, 0x0B, 0x04, 0x17, 0x05, 0x0D, 0x1A, 0x0D, 0x2C, 0x5D, 0x2E, + 0x06, 0x19, 0x03, 0x02, 0x02, 0x01, 0x01, 0x0B, 0x02, 0x05, 0x0B, 0x02, + 0x02, 0x04, 0x0D, 0x0F, 0x0D, 0x19, 0x06, 0x0B, 0x0C, 0x0E, 0x05, 0x08, + 0x03, 0x03, 0x07, 0x06, 0x10, 0x28, 0x12, 0x0C, 0x0D, 0x0C, 0x0E, 0x09, + 0x01, 0x02, 0x07, 0x16, 0x18, 0x3A, 0x73, 0x3A, 0x08, 0x10, 0x08, 0x0D, + 0x2C, 0x09, 0x07, 0x0B, 0x0E, 0x0B, 0x35, 0x0B, 0x03, 0x02, 0x01, 0x07, + 0x14, 0x07, 0x13, 0x18, 0x15, 0x09, 0x12, 0x05, 0x0E, 0x0B, 0x05, 0x13, + 0x03, 0x03, 0x0F, 0x1C, 0x0F, 0x05, 0x0C, 0x05, 0x09, 0x07, 0x0E, 0x19, + 0x32, 0x19, 0x07, 0x11, 0x0E, 0x16, 0x01, 0x0C, 0x0B, 0x18, 0x10, 0x17, + 0x2F, 0x17, 0x39, 0x71, 0x39, 0x0C, 0x1F, 0x0B, 0x12, 0x07, 0x0C, 0x08, + 0x05, 0x03, 0x04, 0x01, 0x19, 0x05, 0x06, 0x04, 0x01, 0x03, 0x05, 0x07, + 0x14, 0x08, 0x0D, 0x0C, 0x0B, 0x16, 0x20, 0x09, 0x07, 0x1B, 0x0F, 0x0D, + 0x1A, 0x0D, 0x05, 0x01, 0x05, 0x0A, 0x07, 0x02, 0x04, 0x02, 0x0A, 0x0A, + 0x0B, 0x07, 0x05, 0x08, 0x03, 0x02, 0x02, 0x01, 0x04, 0x05, 0x05, 0x03, + 0x11, 0x11, 0x21, 0x11, 0x05, 0x10, 0x01, 0x03, 0x03, 0x09, 0x0D, 0x19, + 0x0D, 0x19, 0x31, 0x18, 0x03, 0x01, 0x0B, 0x02, 0x20, 0x1B, 0x0A, 0x00, + 0x00, 0x07, 0x00, 0x5B, 0x00, 0x26, 0x0D, 0x2D, 0x03, 0x5A, 0x00, 0xBA, + 0x00, 0xC5, 0x00, 0xCA, 0x00, 0xDC, 0x00, 0xE7, 0x00, 0xEE, 0x01, 0x11, + 0x00, 0x00, 0x01, 0x25, 0x27, 0x3F, 0x01, 0x27, 0x35, 0x0F, 0x01, 0x27, + 0x17, 0x15, 0x07, 0x27, 0x15, 0x23, 0x35, 0x33, 0x35, 0x27, 0x0F, 0x03, + 0x2F, 0x01, 0x37, 0x27, 0x23, 0x0F, 0x02, 0x23, 0x07, 0x05, 0x2F, 0x01, + 0x07, 0x27, 0x07, 0x17, 0x0F, 0x02, 0x27, 0x22, 0x06, 0x0F, 0x02, 0x15, + 0x1F, 0x01, 0x07, 0x15, 0x1E, 0x01, 0x1F, 0x03, 0x07, 0x23, 0x35, 0x2F, + 0x03, 0x07, 0x27, 0x23, 0x07, 0x23, 0x22, 0x06, 0x0F, 0x02, 0x17, 0x07, + 0x0E, 0x01, 0x0F, 0x04, 0x1F, 0x01, 0x07, 0x27, 0x13, 0x3F, 0x01, 0x2F, + 0x03, 0x15, 0x07, 0x2F, 0x02, 0x23, 0x0F, 0x01, 0x15, 0x07, 0x17, 0x23, + 0x15, 0x23, 0x35, 0x07, 0x35, 0x0F, 0x03, 0x2F, 0x01, 0x13, 0x33, 0x1F, + 0x01, 0x05, 0x1F, 0x01, 0x05, 0x27, 0x33, 0x35, 0x37, 0x17, 0x37, 0x35, + 0x33, 0x17, 0x3F, 0x03, 0x33, 0x05, 0x1F, 0x03, 0x07, 0x3F, 0x01, 0x17, + 0x35, 0x37, 0x35, 0x3F, 0x01, 0x05, 0x17, 0x15, 0x1F, 0x03, 0x33, 0x3F, + 0x02, 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x1F, 0x01, 0x07, 0x17, 0x33, 0x17, + 0x37, 0x35, 0x33, 0x35, 0x21, 0x17, 0x15, 0x07, 0x25, 0x2F, 0x03, 0x07, + 0x17, 0x33, 0x37, 0x35, 0x23, 0x07, 0x33, 0x37, 0x23, 0x15, 0x25, 0x27, + 0x21, 0x0F, 0x03, 0x17, 0x25, 0x3F, 0x01, 0x3E, 0x01, 0x35, 0x34, 0x26, + 0x2F, 0x01, 0x05, 0x27, 0x23, 0x0F, 0x01, 0x1F, 0x01, 0x33, 0x3F, 0x01, + 0x2F, 0x01, 0x15, 0x33, 0x2F, 0x02, 0x07, 0x05, 0x27, 0x23, 0x07, 0x0E, + 0x01, 0x07, 0x14, 0x16, 0x1F, 0x01, 0x07, 0x27, 0x2E, 0x01, 0x35, 0x26, + 0x36, 0x3F, 0x01, 0x07, 0x0E, 0x01, 0x17, 0x14, 0x16, 0x1F, 0x01, 0x33, + 0x35, 0x37, 0x36, 0x26, 0x2F, 0x01, 0x0D, 0x29, 0xFD, 0xA7, 0x01, 0x0C, + 0x01, 0xC1, 0x50, 0x10, 0x8B, 0x1C, 0x07, 0x1E, 0x17, 0x06, 0x56, 0x02, + 0x03, 0x03, 0x06, 0x07, 0x05, 0x01, 0x02, 0x11, 0x02, 0x05, 0x05, 0x09, + 0x08, 0xFE, 0x1B, 0x09, 0x0C, 0x18, 0x03, 0x18, 0x02, 0x02, 0x04, 0x0C, + 0x03, 0x03, 0x04, 0x01, 0x06, 0x02, 0x08, 0x01, 0x11, 0x01, 0x06, 0x05, + 0x1D, 0x11, 0x05, 0xC6, 0x06, 0x15, 0x1E, 0x0A, 0x03, 0x0E, 0x13, 0x7B, + 0x29, 0x06, 0x05, 0x07, 0x03, 0x08, 0x1D, 0x0F, 0x04, 0x04, 0x09, 0x05, + 0x0A, 0x02, 0x39, 0x01, 0x07, 0x05, 0x05, 0xB9, 0xA6, 0x04, 0x03, 0x09, + 0x0F, 0x10, 0x2A, 0x0B, 0x02, 0x21, 0x01, 0x84, 0x20, 0x7D, 0x6D, 0x02, + 0x4C, 0x25, 0x7C, 0x9C, 0x01, 0x01, 0x07, 0x05, 0x02, 0x03, 0x8B, 0x05, + 0x04, 0x01, 0x67, 0x04, 0x02, 0x01, 0x22, 0x01, 0x22, 0x0C, 0x01, 0x23, + 0x22, 0x02, 0x58, 0x04, 0x0B, 0x0D, 0x08, 0x01, 0xB5, 0x0D, 0x16, 0x0D, + 0x06, 0x03, 0x09, 0x02, 0x1B, 0x09, 0x03, 0x06, 0x01, 0xE6, 0x05, 0x0E, + 0x02, 0x04, 0x03, 0x11, 0x01, 0x50, 0x08, 0x04, 0x08, 0x04, 0x0A, 0x0E, + 0x05, 0x04, 0x02, 0x02, 0x8B, 0x12, 0x4F, 0xC1, 0x02, 0x4C, 0x05, 0x04, + 0xFB, 0xE9, 0x07, 0x05, 0x01, 0x1F, 0x2F, 0x07, 0x59, 0x07, 0x0C, 0x53, + 0x54, 0x04, 0x58, 0xFD, 0x6E, 0x04, 0xFE, 0x88, 0x0F, 0x0C, 0x05, 0x15, + 0x08, 0x01, 0xA3, 0x05, 0x0B, 0x07, 0x08, 0x07, 0x07, 0x0B, 0xFA, 0xAC, + 0x05, 0x61, 0x05, 0x04, 0x05, 0x04, 0x63, 0x03, 0x04, 0x04, 0x6F, 0x7D, + 0x02, 0x04, 0x05, 0x72, 0x04, 0xB6, 0x0A, 0x32, 0x0C, 0x05, 0x06, 0x01, + 0x04, 0x05, 0x0C, 0x05, 0x11, 0x09, 0x09, 0x01, 0x03, 0x03, 0x05, 0x16, + 0x0C, 0x0B, 0x02, 0x09, 0x08, 0x10, 0x76, 0x0A, 0x03, 0x01, 0x04, 0x17, + 0x02, 0x2D, 0x01, 0x18, 0x01, 0x09, 0x03, 0x05, 0x01, 0x05, 0x01, 0x05, + 0x18, 0x08, 0x02, 0x0B, 0x28, 0x05, 0x02, 0x07, 0x14, 0x04, 0x03, 0x04, + 0x03, 0x12, 0x08, 0x1D, 0x05, 0x04, 0x11, 0x04, 0x05, 0x03, 0x09, 0x21, + 0x02, 0x15, 0x02, 0x07, 0x04, 0x01, 0x02, 0x03, 0x08, 0x05, 0x70, 0x02, + 0x09, 0x07, 0x29, 0x17, 0x2C, 0x15, 0x66, 0x36, 0x07, 0x37, 0x06, 0x45, + 0x75, 0x4F, 0x22, 0x03, 0x03, 0x04, 0x02, 0x02, 0x08, 0x37, 0x11, 0x03, + 0x01, 0x04, 0x02, 0x08, 0x04, 0x6F, 0x0A, 0x0B, 0x03, 0x0C, 0x2B, 0x01, + 0x21, 0x0C, 0x17, 0x18, 0x10, 0x08, 0x01, 0x05, 0x02, 0x48, 0x02, 0x0C, + 0x18, 0x03, 0x0B, 0x02, 0x44, 0x1C, 0x1B, 0x4E, 0x3F, 0x47, 0x1A, 0x04, + 0x05, 0x05, 0x04, 0x01, 0x5D, 0x05, 0x12, 0x04, 0x03, 0x07, 0x01, 0x0C, + 0x09, 0x01, 0x09, 0x02, 0x0F, 0x02, 0x8C, 0x05, 0x08, 0x06, 0x30, 0x02, + 0x0D, 0x17, 0x0C, 0x55, 0x01, 0x26, 0x05, 0x09, 0x02, 0x02, 0x04, 0x03, + 0x08, 0x0A, 0x0E, 0x01, 0x01, 0x05, 0x20, 0x33, 0x71, 0x07, 0x03, 0x03, + 0x01, 0x01, 0x08, 0x05, 0x0A, 0x04, 0x94, 0x06, 0x01, 0x05, 0x24, 0x06, + 0x7C, 0x07, 0xB2, 0x07, 0x11, 0x0D, 0x03, 0x4A, 0x05, 0x08, 0x1F, 0x4D, + 0x0D, 0x0D, 0x81, 0x02, 0x06, 0x0C, 0x07, 0x33, 0x08, 0x03, 0x01, 0x05, + 0x06, 0x11, 0x0C, 0x09, 0x10, 0x06, 0x07, 0xF4, 0x01, 0x01, 0x08, 0x07, + 0x03, 0x04, 0x07, 0x07, 0x9A, 0x0E, 0x09, 0x05, 0x02, 0x02, 0xFA, 0x04, + 0x0C, 0x09, 0x0F, 0x08, 0x07, 0x0E, 0x08, 0x0A, 0x04, 0x0D, 0x08, 0x11, + 0x09, 0x06, 0x0E, 0x08, 0x0C, 0x08, 0x08, 0x17, 0x0F, 0x09, 0x0F, 0x08, + 0x0B, 0x0F, 0x10, 0x09, 0x15, 0x0B, 0x15, 0x00, 0x00, 0x02, 0x00, 0x53, + 0xFF, 0xF2, 0x08, 0xFC, 0x03, 0x8D, 0x00, 0x1E, 0x01, 0x28, 0x00, 0x00, + 0x01, 0x07, 0x0E, 0x01, 0x15, 0x17, 0x0F, 0x01, 0x27, 0x07, 0x23, 0x0F, + 0x02, 0x0E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x33, 0x3E, 0x01, 0x37, 0x3E, + 0x01, 0x37, 0x36, 0x26, 0x27, 0x23, 0x25, 0x17, 0x37, 0x33, 0x1F, 0x01, + 0x0F, 0x01, 0x23, 0x2F, 0x01, 0x0F, 0x01, 0x23, 0x27, 0x23, 0x27, 0x23, + 0x0E, 0x01, 0x2B, 0x01, 0x2F, 0x01, 0x05, 0x07, 0x23, 0x27, 0x23, 0x07, + 0x23, 0x07, 0x14, 0x06, 0x07, 0x1F, 0x01, 0x1E, 0x01, 0x07, 0x0E, 0x01, + 0x1F, 0x01, 0x15, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x0F, 0x01, 0x2F, 0x01, + 0x34, 0x36, 0x3F, 0x01, 0x3E, 0x01, 0x2F, 0x02, 0x26, 0x36, 0x3F, 0x01, + 0x27, 0x07, 0x0E, 0x01, 0x0F, 0x01, 0x0E, 0x01, 0x0F, 0x03, 0x22, 0x26, + 0x2F, 0x01, 0x3E, 0x01, 0x3F, 0x01, 0x3E, 0x01, 0x3F, 0x01, 0x3E, 0x01, + 0x35, 0x34, 0x26, 0x27, 0x0F, 0x01, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x0F, + 0x01, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x0F, 0x02, 0x06, + 0x26, 0x37, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x2F, 0x02, 0x07, 0x06, + 0x26, 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x0F, 0x01, + 0x1F, 0x01, 0x14, 0x06, 0x07, 0x0E, 0x01, 0x2B, 0x01, 0x22, 0x26, 0x27, + 0x2E, 0x01, 0x2F, 0x01, 0x2E, 0x01, 0x35, 0x26, 0x36, 0x3F, 0x02, 0x3E, + 0x01, 0x33, 0x25, 0x35, 0x3F, 0x02, 0x17, 0x35, 0x23, 0x16, 0x06, 0x23, + 0x2F, 0x01, 0x23, 0x07, 0x23, 0x2E, 0x01, 0x35, 0x34, 0x36, 0x37, 0x33, + 0x17, 0x3F, 0x01, 0x3E, 0x01, 0x33, 0x32, 0x16, 0x15, 0x37, 0x35, 0x37, + 0x17, 0x15, 0x3F, 0x01, 0x33, 0x17, 0x33, 0x35, 0x33, 0x15, 0x33, 0x15, + 0x07, 0x15, 0x23, 0x35, 0x23, 0x17, 0x33, 0x1E, 0x01, 0x1F, 0x01, 0x33, + 0x35, 0x33, 0x15, 0x33, 0x35, 0x33, 0x15, 0x33, 0x35, 0x33, 0x15, 0x33, + 0x35, 0x33, 0x15, 0x33, 0x35, 0x33, 0x15, 0x33, 0x17, 0x15, 0x17, 0x21, + 0x3F, 0x01, 0x33, 0x17, 0x33, 0x37, 0x17, 0x37, 0x3E, 0x01, 0x3B, 0x01, + 0x17, 0x04, 0x8B, 0x07, 0x04, 0x04, 0x03, 0x05, 0x16, 0x0E, 0x06, 0x1B, + 0x08, 0x06, 0x37, 0x05, 0x01, 0x04, 0x03, 0x09, 0x06, 0x4B, 0x15, 0x20, + 0x0B, 0x08, 0x36, 0x2F, 0x03, 0x08, 0x0A, 0x5E, 0x04, 0x13, 0x0E, 0x0F, + 0x37, 0x05, 0x05, 0x05, 0x07, 0x31, 0x0A, 0x0A, 0x0E, 0x06, 0x1F, 0x05, + 0x31, 0x04, 0x18, 0x01, 0x05, 0x04, 0x2D, 0x09, 0x03, 0xFE, 0xBE, 0x11, + 0x08, 0x06, 0x07, 0x05, 0x43, 0x09, 0x07, 0x07, 0x08, 0x12, 0x09, 0x08, + 0x01, 0x03, 0x02, 0x02, 0x01, 0x01, 0x0D, 0x0C, 0x02, 0x08, 0x0A, 0x2A, + 0x31, 0x1C, 0x02, 0x04, 0x0F, 0x05, 0x02, 0x01, 0x08, 0x09, 0x02, 0x09, + 0x0A, 0x14, 0x53, 0x61, 0x10, 0x2B, 0x1A, 0x47, 0x0C, 0x17, 0x0B, 0x40, + 0x6E, 0x4E, 0x05, 0x07, 0x02, 0x02, 0x01, 0x06, 0x05, 0x15, 0x08, 0x0C, + 0x03, 0x17, 0x08, 0x08, 0x0E, 0x0E, 0x3E, 0x44, 0x10, 0x13, 0x02, 0x05, + 0x0F, 0x0B, 0x03, 0x03, 0x11, 0x0F, 0x16, 0x28, 0x13, 0x08, 0x02, 0x09, + 0x52, 0x52, 0x07, 0x05, 0x01, 0x19, 0x0E, 0x19, 0x0A, 0x0A, 0x0F, 0x04, + 0x05, 0x21, 0x32, 0x02, 0x05, 0x04, 0x04, 0x05, 0x01, 0x0E, 0x28, 0x1A, + 0x1F, 0x22, 0x03, 0x08, 0x0C, 0x0D, 0x05, 0x04, 0x04, 0x0B, 0x08, 0x82, + 0x06, 0x0C, 0x06, 0x07, 0x0B, 0x04, 0x23, 0x0C, 0x0E, 0x01, 0x02, 0x02, + 0x0E, 0x24, 0x0D, 0x15, 0x07, 0x02, 0xBB, 0x12, 0x1B, 0x1F, 0x2A, 0x11, + 0x01, 0x08, 0x09, 0x0E, 0x02, 0x27, 0x05, 0x0E, 0x05, 0x05, 0x05, 0x04, + 0x0A, 0x07, 0x26, 0x02, 0x02, 0x07, 0x07, 0x07, 0x07, 0x0B, 0x15, 0x17, + 0x58, 0x6A, 0x22, 0x10, 0x0F, 0x0D, 0x16, 0x16, 0x0C, 0x37, 0x09, 0x0E, + 0x08, 0x08, 0x01, 0x05, 0x24, 0x11, 0x26, 0x10, 0x26, 0x10, 0x27, 0x0F, + 0x27, 0x10, 0x1E, 0x4E, 0x14, 0x01, 0x59, 0x06, 0x09, 0x29, 0x0A, 0x14, + 0x0A, 0x2B, 0x01, 0x02, 0x04, 0x03, 0x1C, 0x07, 0x01, 0xF9, 0x05, 0x05, + 0x0B, 0x06, 0x17, 0x06, 0x01, 0x01, 0x0E, 0x02, 0x07, 0x64, 0x0A, 0x12, + 0x08, 0x06, 0x08, 0x02, 0x02, 0x0B, 0x08, 0x07, 0x53, 0x4D, 0x05, 0x16, + 0x10, 0xB2, 0x01, 0x07, 0x0A, 0x1A, 0x19, 0x0A, 0x03, 0x01, 0x02, 0x02, + 0x03, 0x04, 0x04, 0x03, 0x03, 0x02, 0x08, 0x12, 0x06, 0x06, 0x44, 0x06, + 0x08, 0x02, 0x08, 0x02, 0x02, 0x07, 0x05, 0x13, 0x1B, 0x09, 0x33, 0x3A, + 0x11, 0x25, 0x13, 0x04, 0x08, 0x04, 0x07, 0x09, 0x07, 0x19, 0x2D, 0x14, + 0x37, 0x0D, 0x14, 0x06, 0x1C, 0x13, 0x05, 0x0A, 0x06, 0x0A, 0x04, 0x04, + 0x0B, 0x2F, 0x25, 0x6B, 0x11, 0x18, 0x05, 0x0B, 0x06, 0x01, 0x03, 0x04, + 0x17, 0x18, 0x22, 0x0B, 0x27, 0x0F, 0x12, 0x02, 0x14, 0x0A, 0x19, 0x0E, + 0x10, 0x13, 0x03, 0x02, 0x05, 0x01, 0x05, 0x05, 0x06, 0x0B, 0x04, 0x28, + 0x1E, 0x51, 0x32, 0x4F, 0x67, 0x18, 0x0A, 0x0F, 0x05, 0x1D, 0x1C, 0x02, + 0x14, 0x16, 0x36, 0x25, 0x4F, 0x2B, 0x2B, 0x52, 0x27, 0x3D, 0x02, 0x28, + 0x02, 0x03, 0x05, 0x05, 0x04, 0x01, 0x05, 0x17, 0x12, 0x15, 0x22, 0x0B, + 0x1B, 0x0D, 0x13, 0x07, 0x0B, 0x04, 0x04, 0x04, 0x05, 0x05, 0x07, 0x11, + 0x0B, 0x90, 0x3C, 0x49, 0x0E, 0x0D, 0x14, 0x07, 0x15, 0x1D, 0x08, 0x09, + 0x0F, 0x08, 0x0D, 0x12, 0x05, 0x01, 0x39, 0x06, 0x06, 0x05, 0x07, 0x06, + 0x07, 0x19, 0x11, 0x11, 0x12, 0x02, 0x05, 0x02, 0x07, 0x04, 0x03, 0x07, + 0x06, 0x01, 0x13, 0x03, 0x02, 0x0E, 0x0D, 0x0C, 0x0C, 0x06, 0x04, 0x6D, + 0x01, 0x05, 0x07, 0x0D, 0x01, 0x04, 0x03, 0x15, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x27, 0x1A, 0x0B, 0x04, 0x05, 0x09, + 0x06, 0x02, 0x04, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x53, + 0x00, 0x0D, 0x0A, 0x10, 0x03, 0x75, 0x01, 0xEE, 0x02, 0x04, 0x02, 0x11, + 0x00, 0x00, 0x01, 0x36, 0x26, 0x37, 0x3E, 0x01, 0x17, 0x16, 0x06, 0x17, + 0x1E, 0x01, 0x27, 0x34, 0x16, 0x17, 0x16, 0x36, 0x35, 0x26, 0x36, 0x33, + 0x32, 0x36, 0x15, 0x16, 0x06, 0x17, 0x16, 0x36, 0x33, 0x3A, 0x01, 0x33, + 0x32, 0x16, 0x37, 0x34, 0x26, 0x37, 0x36, 0x16, 0x33, 0x16, 0x32, 0x33, + 0x32, 0x36, 0x37, 0x34, 0x16, 0x15, 0x16, 0x14, 0x37, 0x36, 0x06, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x33, 0x32, 0x36, 0x15, 0x14, 0x36, 0x33, + 0x32, 0x16, 0x37, 0x3E, 0x01, 0x17, 0x16, 0x06, 0x33, 0x3A, 0x01, 0x33, + 0x3A, 0x03, 0x33, 0x32, 0x36, 0x17, 0x32, 0x16, 0x35, 0x34, 0x16, 0x35, + 0x3C, 0x01, 0x35, 0x34, 0x26, 0x37, 0x36, 0x32, 0x15, 0x16, 0x36, 0x17, + 0x16, 0x06, 0x15, 0x14, 0x32, 0x17, 0x1E, 0x01, 0x07, 0x14, 0x06, 0x17, + 0x16, 0x36, 0x17, 0x16, 0x06, 0x15, 0x16, 0x36, 0x17, 0x1E, 0x01, 0x23, + 0x2A, 0x01, 0x23, 0x30, 0x07, 0x06, 0x15, 0x32, 0x36, 0x17, 0x16, 0x06, + 0x07, 0x06, 0x26, 0x15, 0x14, 0x16, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x37, + 0x34, 0x16, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x17, + 0x16, 0x06, 0x15, 0x14, 0x16, 0x23, 0x06, 0x26, 0x23, 0x22, 0x26, 0x07, + 0x06, 0x36, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x26, 0x07, + 0x06, 0x14, 0x07, 0x06, 0x26, 0x07, 0x06, 0x16, 0x07, 0x22, 0x26, 0x23, + 0x2E, 0x01, 0x35, 0x34, 0x36, 0x27, 0x34, 0x26, 0x07, 0x22, 0x34, 0x27, + 0x26, 0x06, 0x23, 0x26, 0x06, 0x07, 0x06, 0x16, 0x07, 0x06, 0x16, 0x23, + 0x22, 0x26, 0x23, 0x22, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, + 0x22, 0x26, 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x23, 0x2A, 0x01, 0x23, + 0x22, 0x26, 0x27, 0x26, 0x06, 0x07, 0x0E, 0x01, 0x17, 0x14, 0x06, 0x17, + 0x16, 0x36, 0x17, 0x16, 0x06, 0x23, 0x22, 0x06, 0x15, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x23, + 0x22, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, + 0x2E, 0x01, 0x27, 0x26, 0x22, 0x07, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x07, + 0x0E, 0x01, 0x15, 0x14, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x06, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x36, 0x37, 0x3E, 0x01, 0x27, + 0x2E, 0x01, 0x23, 0x22, 0x27, 0x23, 0x26, 0x22, 0x35, 0x3C, 0x01, 0x35, + 0x34, 0x26, 0x07, 0x06, 0x16, 0x15, 0x1E, 0x01, 0x07, 0x2A, 0x01, 0x27, + 0x22, 0x26, 0x07, 0x0E, 0x01, 0x15, 0x14, 0x22, 0x23, 0x22, 0x06, 0x15, + 0x0E, 0x01, 0x07, 0x22, 0x06, 0x23, 0x22, 0x26, 0x35, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x26, 0x36, 0x35, 0x22, 0x06, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x22, 0x06, 0x27, 0x26, 0x36, 0x27, + 0x2E, 0x01, 0x35, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x36, 0x37, + 0x34, 0x26, 0x37, 0x36, 0x16, 0x17, 0x32, 0x06, 0x17, 0x16, 0x36, 0x33, + 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x16, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x36, 0x32, 0x33, 0x1E, 0x01, 0x33, 0x3A, 0x01, 0x33, + 0x32, 0x34, 0x27, 0x34, 0x36, 0x35, 0x2E, 0x01, 0x07, 0x06, 0x16, 0x23, + 0x22, 0x26, 0x37, 0x34, 0x06, 0x23, 0x22, 0x16, 0x07, 0x06, 0x34, 0x37, + 0x34, 0x26, 0x37, 0x13, 0x26, 0x06, 0x23, 0x22, 0x16, 0x17, 0x14, 0x36, + 0x33, 0x3A, 0x01, 0x33, 0x32, 0x26, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x26, + 0x27, 0x07, 0x26, 0x06, 0x15, 0x14, 0x16, 0x33, 0x34, 0x26, 0x27, 0x2E, + 0x01, 0x27, 0x03, 0x36, 0x09, 0x03, 0x04, 0x02, 0x16, 0x04, 0x09, 0x0E, + 0x0E, 0x06, 0x12, 0x01, 0x10, 0x02, 0x04, 0x07, 0x01, 0x0A, 0x09, 0x03, + 0x16, 0x01, 0x02, 0x03, 0x09, 0x1B, 0x0B, 0x10, 0x1F, 0x10, 0x02, 0x0F, + 0x01, 0x03, 0x02, 0x04, 0x13, 0x04, 0x0A, 0x15, 0x0A, 0x0F, 0x02, 0x01, + 0x11, 0x01, 0x09, 0x06, 0x03, 0x01, 0x03, 0x0D, 0x05, 0x02, 0x1C, 0x0A, + 0x03, 0x20, 0x1B, 0x0A, 0x18, 0x31, 0x18, 0x07, 0x10, 0x07, 0x0B, 0x08, + 0x0E, 0x3C, 0x77, 0x3C, 0x31, 0x62, 0x63, 0x62, 0x31, 0x15, 0x29, 0x14, + 0x03, 0x13, 0x09, 0x04, 0x05, 0x02, 0x1C, 0x01, 0x08, 0x02, 0x02, 0x02, + 0x05, 0x03, 0x04, 0x01, 0x01, 0x04, 0x04, 0x02, 0x0C, 0x04, 0x05, 0x01, + 0x01, 0x36, 0x04, 0x01, 0x02, 0x03, 0x05, 0x0C, 0x06, 0x02, 0x01, 0x03, + 0x14, 0x02, 0x02, 0x04, 0x05, 0x05, 0x2E, 0x44, 0x55, 0x4C, 0x07, 0x04, + 0x02, 0x01, 0x10, 0x02, 0x08, 0x10, 0x08, 0x0E, 0x1E, 0x0F, 0x03, 0x09, + 0x04, 0x02, 0x02, 0x04, 0x03, 0x0B, 0x16, 0x0B, 0x1C, 0x39, 0x1C, 0x0D, + 0x04, 0x07, 0x11, 0x23, 0x11, 0x1E, 0x3C, 0x1D, 0x05, 0x0B, 0x05, 0x03, + 0x01, 0x03, 0x09, 0x04, 0x04, 0x09, 0x09, 0x06, 0x0E, 0x06, 0x0B, 0x02, + 0x04, 0x01, 0x04, 0x03, 0x05, 0x02, 0x0A, 0x01, 0x05, 0x08, 0x09, 0x02, + 0x02, 0x02, 0x0D, 0x07, 0x01, 0x0B, 0x0D, 0x1A, 0x0D, 0x3D, 0x7B, 0x3D, + 0x1D, 0x3A, 0x1D, 0x0F, 0x1D, 0x0E, 0x09, 0x2D, 0x04, 0x03, 0x0F, 0x03, + 0x02, 0x01, 0x02, 0x07, 0x0E, 0x07, 0x1C, 0x36, 0x1C, 0x18, 0x28, 0x14, + 0x09, 0x08, 0x01, 0x01, 0x01, 0x02, 0x04, 0x03, 0x05, 0x07, 0x05, 0x09, + 0x03, 0x01, 0x04, 0x02, 0x01, 0x06, 0x02, 0x03, 0x02, 0x03, 0x06, 0x10, + 0x07, 0x03, 0x07, 0x05, 0x04, 0x06, 0x04, 0x03, 0x19, 0x06, 0x0F, 0x1D, + 0x0F, 0x16, 0x30, 0x18, 0x0E, 0x07, 0x05, 0x09, 0x0C, 0x04, 0x04, 0x0B, + 0x03, 0x04, 0x08, 0x06, 0x04, 0x01, 0x11, 0x1E, 0x3C, 0x1E, 0x09, 0x12, + 0x09, 0x09, 0x0B, 0x05, 0x03, 0x0C, 0x0C, 0x02, 0x04, 0x0C, 0x06, 0x0C, + 0x0B, 0x03, 0x03, 0x39, 0x08, 0x17, 0x30, 0x16, 0x21, 0x5B, 0x0D, 0x0C, + 0x13, 0x06, 0x06, 0x30, 0x10, 0x01, 0x01, 0x01, 0x01, 0x05, 0x06, 0x08, + 0x0A, 0x01, 0x01, 0x01, 0x16, 0x0B, 0x17, 0x0C, 0x05, 0x0B, 0x05, 0x02, + 0x01, 0x2E, 0x05, 0x03, 0x03, 0x01, 0x03, 0x08, 0x06, 0x0B, 0x05, 0x09, + 0x01, 0x0A, 0x1A, 0x0B, 0x09, 0x13, 0x08, 0x04, 0x17, 0x06, 0x07, 0x03, + 0x0F, 0x20, 0x08, 0x12, 0x23, 0x09, 0x04, 0x02, 0x0B, 0x08, 0x13, 0x08, + 0x06, 0x02, 0x01, 0x02, 0x05, 0x03, 0x0B, 0x03, 0x03, 0x03, 0x02, 0x02, + 0x04, 0x02, 0x02, 0x05, 0x08, 0x13, 0x08, 0x07, 0x02, 0x01, 0x01, 0x1B, + 0x05, 0x1F, 0x3F, 0x1F, 0x3E, 0x7C, 0x3F, 0x19, 0x39, 0x19, 0x14, 0x19, + 0x11, 0x06, 0x04, 0x01, 0x02, 0x0E, 0x05, 0x17, 0x2C, 0x17, 0x14, 0x27, + 0x14, 0x0B, 0x01, 0x01, 0x01, 0x08, 0x01, 0x03, 0x05, 0x0C, 0x04, 0x09, + 0x02, 0x20, 0x03, 0x10, 0x08, 0x0A, 0x12, 0x01, 0x03, 0x05, 0xBF, 0x0A, + 0x2B, 0x0C, 0x19, 0x04, 0x01, 0x1E, 0x06, 0x07, 0x0D, 0x07, 0x0D, 0x09, + 0x05, 0x08, 0x1A, 0x01, 0x01, 0x0F, 0x08, 0x86, 0x08, 0x04, 0x16, 0x10, + 0x0B, 0x02, 0x02, 0x09, 0x02, 0x03, 0x48, 0x08, 0x0F, 0x0A, 0x06, 0x06, + 0x04, 0x07, 0x29, 0x02, 0x01, 0x02, 0x09, 0x05, 0x04, 0x03, 0x06, 0x01, + 0x09, 0x0A, 0x01, 0x02, 0x03, 0x02, 0x10, 0x01, 0x03, 0x03, 0x02, 0x03, + 0x02, 0x07, 0x02, 0x04, 0x03, 0x01, 0x04, 0x0C, 0x03, 0x01, 0x04, 0x06, + 0x0D, 0x02, 0x02, 0x1A, 0x03, 0x0B, 0x15, 0x0A, 0x05, 0x3A, 0x02, 0x03, + 0x0D, 0x03, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x0C, 0x02, 0x02, 0x08, + 0x04, 0x06, 0x03, 0x05, 0x0D, 0x1A, 0x0D, 0x06, 0x45, 0x03, 0x01, 0x05, + 0x09, 0x05, 0x05, 0x05, 0x0A, 0x05, 0x06, 0x03, 0x06, 0x10, 0x07, 0x0A, + 0x1C, 0x0A, 0x05, 0x03, 0x03, 0x02, 0x0F, 0x04, 0x13, 0x13, 0x0E, 0x01, + 0x11, 0x04, 0x05, 0x01, 0x02, 0x04, 0x05, 0x0A, 0x01, 0x01, 0x03, 0x03, + 0x01, 0x01, 0x04, 0x03, 0x03, 0x01, 0x01, 0x01, 0x2A, 0x04, 0x02, 0x1A, + 0x02, 0x01, 0x01, 0x02, 0x01, 0x0D, 0x02, 0x01, 0x01, 0x08, 0x02, 0x08, + 0x01, 0x05, 0x07, 0x35, 0x01, 0x02, 0x01, 0x0A, 0x0A, 0x09, 0x11, 0x09, + 0x04, 0x01, 0x01, 0x05, 0x03, 0x0D, 0x37, 0x01, 0x06, 0x09, 0x0B, 0x08, + 0x04, 0x02, 0x06, 0x01, 0x01, 0x03, 0x06, 0x04, 0x02, 0x03, 0x01, 0x09, + 0x02, 0x01, 0x01, 0x09, 0x0D, 0x06, 0x0D, 0x0B, 0x03, 0x0D, 0x03, 0x04, + 0x04, 0x01, 0x02, 0x0F, 0x07, 0x09, 0x15, 0x2A, 0x15, 0x08, 0x0B, 0x07, + 0x07, 0x10, 0x08, 0x15, 0x2B, 0x15, 0x09, 0x15, 0x09, 0x06, 0x0B, 0x09, + 0x07, 0x05, 0x02, 0x06, 0x09, 0x05, 0x08, 0x11, 0x39, 0x0A, 0x13, 0x30, + 0x16, 0x11, 0x20, 0x12, 0x16, 0x2E, 0x16, 0x10, 0x09, 0x01, 0x01, 0x01, + 0x08, 0x06, 0x14, 0x07, 0x05, 0x11, 0x05, 0x09, 0x11, 0x08, 0x14, 0x24, + 0x15, 0x10, 0x1A, 0x04, 0x0A, 0x11, 0x0C, 0x11, 0x6E, 0x0D, 0x0D, 0x24, + 0x12, 0x12, 0x0E, 0x01, 0x05, 0x04, 0x09, 0x12, 0x09, 0x09, 0x03, 0x03, + 0x04, 0x0D, 0x0A, 0x12, 0x15, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17, 0x03, + 0x07, 0x0C, 0x02, 0x08, 0x05, 0x01, 0x01, 0x07, 0x08, 0x0A, 0x0B, 0x0A, + 0x09, 0x0C, 0x0B, 0x05, 0x02, 0x03, 0x03, 0x25, 0x06, 0x21, 0x0A, 0x12, + 0x27, 0x18, 0x09, 0x0A, 0x01, 0x01, 0x03, 0x03, 0x12, 0x05, 0x08, 0x0D, + 0x09, 0x23, 0x46, 0x24, 0x16, 0x2C, 0x16, 0x19, 0x31, 0x18, 0x05, 0x14, + 0x02, 0x03, 0x03, 0x01, 0x0D, 0x04, 0x09, 0x02, 0x03, 0x05, 0x04, 0x24, + 0x08, 0x03, 0x04, 0x07, 0x06, 0x01, 0x01, 0x05, 0x0A, 0x04, 0x08, 0x03, + 0x03, 0x03, 0x03, 0x07, 0x06, 0x05, 0x07, 0x03, 0x01, 0x09, 0x04, 0x07, + 0x20, 0x0A, 0x16, 0x2C, 0x16, 0xFE, 0x6F, 0x0A, 0x08, 0x2F, 0x11, 0x0A, + 0x03, 0x02, 0x05, 0x07, 0x0D, 0x0C, 0x09, 0x11, 0x04, 0x11, 0x0D, 0x1D, + 0x03, 0x12, 0x0F, 0x04, 0x0D, 0x05, 0x08, 0x0E, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x56, 0x00, 0x40, 0x0A, 0xA0, 0x03, 0x40, 0x00, 0x7D, + 0x00, 0x95, 0x00, 0x00, 0x01, 0x2F, 0x01, 0x35, 0x23, 0x15, 0x07, 0x0E, + 0x01, 0x0F, 0x02, 0x23, 0x2F, 0x02, 0x23, 0x2F, 0x02, 0x25, 0x07, 0x0E, + 0x01, 0x0F, 0x01, 0x21, 0x27, 0x0F, 0x03, 0x2F, 0x01, 0x0F, 0x02, 0x27, + 0x07, 0x0E, 0x01, 0x07, 0x13, 0x25, 0x3F, 0x04, 0x36, 0x16, 0x1F, 0x01, + 0x0F, 0x03, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x3F, 0x02, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x3F, 0x02, 0x1E, 0x01, 0x17, 0x37, 0x3E, 0x01, 0x37, 0x17, + 0x3F, 0x01, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x3F, + 0x02, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x35, 0x33, 0x17, + 0x1E, 0x01, 0x33, 0x17, 0x3F, 0x02, 0x21, 0x37, 0x33, 0x17, 0x37, 0x21, + 0x17, 0x37, 0x33, 0x17, 0x3F, 0x01, 0x27, 0x05, 0x0E, 0x01, 0x2B, 0x01, + 0x22, 0x26, 0x27, 0x2E, 0x01, 0x35, 0x34, 0x36, 0x37, 0x3E, 0x01, 0x33, + 0x37, 0x32, 0x16, 0x17, 0x1E, 0x01, 0x15, 0x0A, 0x9B, 0x08, 0x2B, 0x2E, + 0x03, 0x02, 0x05, 0x03, 0x22, 0x0D, 0xB0, 0x16, 0x1B, 0x1E, 0xC8, 0x15, + 0x16, 0x1B, 0xFE, 0x20, 0x1B, 0x04, 0x06, 0x02, 0x07, 0xFD, 0x91, 0x09, + 0x66, 0x3F, 0x30, 0x1C, 0x2F, 0x20, 0xA2, 0x6E, 0x31, 0x3A, 0x31, 0x0C, + 0x15, 0x08, 0x16, 0x01, 0x0A, 0xC8, 0x4D, 0x43, 0x32, 0x17, 0x08, 0x0E, + 0x07, 0x13, 0x14, 0x22, 0x20, 0x11, 0x03, 0x0D, 0x0B, 0x0B, 0x17, 0x0D, + 0x2D, 0x14, 0x04, 0x0E, 0x0B, 0x0A, 0x16, 0x0C, 0x29, 0x15, 0x0F, 0x1E, + 0x10, 0x35, 0x0E, 0x1B, 0x0D, 0x21, 0x09, 0x0C, 0x13, 0x2F, 0x1C, 0x1C, + 0x36, 0x1A, 0x1F, 0x3F, 0x22, 0x33, 0x25, 0x14, 0x2E, 0x47, 0x19, 0x18, + 0x23, 0x0B, 0x0D, 0x0D, 0x9A, 0x0F, 0x01, 0x05, 0x03, 0x16, 0x15, 0x1D, + 0x28, 0x01, 0x53, 0x03, 0xD8, 0x12, 0x0F, 0x01, 0x2E, 0x24, 0x13, 0x0D, + 0x0D, 0x13, 0x05, 0x05, 0xF9, 0xEB, 0x05, 0x0D, 0x08, 0x3D, 0x09, 0x10, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x10, 0x09, 0x3D, 0x08, 0x0D, 0x05, + 0x06, 0x05, 0x02, 0xB0, 0x12, 0x05, 0x79, 0x08, 0x11, 0x02, 0x0B, 0x08, + 0x4B, 0x05, 0x0E, 0x1C, 0x25, 0x07, 0x06, 0x09, 0x05, 0x02, 0x02, 0x02, + 0x02, 0x06, 0x09, 0x57, 0x13, 0x0D, 0x06, 0x0A, 0x0A, 0x0A, 0x09, 0x01, + 0x01, 0x0C, 0x04, 0x0A, 0x07, 0xFE, 0xC3, 0x58, 0x4A, 0x1A, 0x19, 0x11, + 0x08, 0x01, 0x05, 0x06, 0x0E, 0x1B, 0x3D, 0x3E, 0x24, 0x14, 0x1B, 0x07, + 0x06, 0x06, 0x01, 0x0A, 0x09, 0x11, 0x21, 0x10, 0x12, 0x1F, 0x0E, 0x2C, + 0x11, 0x0C, 0x0E, 0x01, 0x03, 0x03, 0x0A, 0x07, 0x05, 0x07, 0x02, 0x38, + 0x61, 0x28, 0x2A, 0x45, 0x1B, 0x20, 0x37, 0x17, 0x52, 0x3A, 0x1A, 0x20, + 0x41, 0x21, 0x20, 0x3A, 0x1B, 0x1E, 0x3B, 0x1C, 0x0A, 0x02, 0x03, 0x04, + 0x05, 0x0F, 0x16, 0x13, 0x0E, 0x13, 0x0E, 0x21, 0x03, 0x07, 0x0B, 0x0D, + 0xAE, 0x06, 0x06, 0x06, 0x06, 0x05, 0x0D, 0x07, 0x09, 0x0F, 0x07, 0x05, + 0x05, 0x01, 0x06, 0x05, 0x06, 0x10, 0x09, 0x00, 0x00, 0x02, 0x00, 0x4D, + 0x00, 0x55, 0x0A, 0xE2, 0x03, 0x29, 0x01, 0xB8, 0x01, 0xC8, 0x00, 0x00, + 0x01, 0x06, 0x26, 0x27, 0x22, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, + 0x23, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x27, 0x26, 0x06, 0x07, 0x06, 0x26, + 0x15, 0x14, 0x16, 0x07, 0x06, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x26, + 0x15, 0x14, 0x22, 0x07, 0x22, 0x26, 0x27, 0x2A, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x36, 0x06, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x06, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x22, 0x26, 0x27, 0x26, 0x36, + 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x1E, 0x01, 0x17, 0x1E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x3E, 0x01, + 0x37, 0x2A, 0x01, 0x23, 0x22, 0x16, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x26, 0x22, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x23, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x3E, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x36, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, + 0x23, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x23, 0x2E, 0x01, 0x35, 0x34, 0x36, 0x37, 0x36, 0x26, 0x37, 0x36, 0x26, + 0x27, 0x34, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x34, 0x26, 0x27, 0x2E, 0x01, + 0x35, 0x34, 0x36, 0x37, 0x36, 0x32, 0x33, 0x32, 0x36, 0x33, 0x3E, 0x01, + 0x37, 0x36, 0x16, 0x37, 0x32, 0x36, 0x37, 0x32, 0x36, 0x33, 0x32, 0x36, + 0x33, 0x32, 0x36, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x33, 0x36, 0x16, 0x37, 0x3A, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, + 0x17, 0x1E, 0x01, 0x07, 0x16, 0x36, 0x35, 0x34, 0x26, 0x27, 0x2E, 0x01, + 0x35, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x23, 0x2A, 0x01, 0x27, 0x22, 0x26, + 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x3C, 0x01, 0x37, 0x34, 0x36, + 0x37, 0x36, 0x16, 0x33, 0x32, 0x16, 0x17, 0x16, 0x36, 0x17, 0x1E, 0x01, + 0x37, 0x3E, 0x01, 0x33, 0x3E, 0x01, 0x33, 0x3A, 0x01, 0x37, 0x3A, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x32, 0x16, 0x17, 0x1E, 0x01, + 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x33, 0x32, 0x16, + 0x17, 0x16, 0x14, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x23, 0x22, 0x26, + 0x27, 0x2E, 0x01, 0x07, 0x06, 0x26, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x22, + 0x07, 0x0E, 0x01, 0x07, 0x3A, 0x03, 0x33, 0x32, 0x36, 0x37, 0x3A, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x36, 0x32, 0x33, 0x32, 0x16, 0x17, 0x1E, 0x01, + 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x2E, 0x01, 0x37, 0x3E, 0x01, + 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x14, 0x15, 0x1C, 0x01, + 0x17, 0x16, 0x14, 0x07, 0x32, 0x36, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x16, + 0x33, 0x16, 0x32, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, + 0x17, 0x16, 0x14, 0x17, 0x16, 0x06, 0x07, 0x05, 0x06, 0x16, 0x33, 0x32, + 0x36, 0x37, 0x3E, 0x01, 0x07, 0x0E, 0x01, 0x23, 0x22, 0x06, 0x07, 0x0A, + 0xD5, 0x24, 0x49, 0x24, 0x05, 0x08, 0x05, 0x0A, 0x14, 0x0A, 0x18, 0x31, + 0x18, 0x08, 0x04, 0x07, 0x07, 0x0F, 0x08, 0x15, 0x0F, 0x07, 0x04, 0x11, + 0x02, 0x0C, 0x0E, 0x20, 0x0F, 0x0D, 0x18, 0x0D, 0x06, 0x19, 0x02, 0x07, + 0x05, 0x0A, 0x05, 0x04, 0x09, 0x04, 0x06, 0x01, 0x02, 0x06, 0x1C, 0x04, + 0x15, 0x2B, 0x15, 0x33, 0x67, 0x33, 0x1C, 0x36, 0x1C, 0x08, 0x10, 0x08, + 0x09, 0x1B, 0x08, 0x04, 0x08, 0x03, 0x02, 0x01, 0x01, 0x08, 0x10, 0x07, + 0x1D, 0x39, 0x1D, 0x03, 0x07, 0x03, 0x01, 0x10, 0x0C, 0x24, 0x4B, 0x25, + 0x0A, 0x2B, 0x02, 0x03, 0x03, 0x02, 0x03, 0x05, 0x02, 0x01, 0x02, 0x01, + 0x01, 0x12, 0x01, 0x03, 0x08, 0x08, 0x02, 0x04, 0x03, 0x05, 0x0A, 0x05, + 0x04, 0x01, 0x01, 0x04, 0x07, 0x04, 0x03, 0x0E, 0x0A, 0x0C, 0x17, 0x0B, + 0x07, 0x0B, 0x07, 0x07, 0x19, 0x06, 0x07, 0x0F, 0x08, 0x02, 0x09, 0x02, + 0x04, 0x06, 0x01, 0x10, 0x1D, 0x11, 0x04, 0x0A, 0x07, 0x08, 0x21, 0x06, + 0x11, 0x21, 0x10, 0x02, 0x05, 0x03, 0x0B, 0x0E, 0x08, 0x0C, 0x22, 0x0D, + 0x0B, 0x08, 0x1A, 0x17, 0x2D, 0x16, 0x13, 0x25, 0x12, 0x0F, 0x1E, 0x0E, + 0x20, 0x3E, 0x1F, 0x48, 0x90, 0x48, 0x20, 0x42, 0x22, 0x1C, 0x0C, 0x06, + 0x02, 0x01, 0x02, 0x02, 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x04, 0x02, 0x02, 0x01, 0x12, 0x08, 0x12, 0x25, 0x12, 0x09, 0x10, 0x09, + 0x06, 0x07, 0x04, 0x0C, 0x30, 0x0F, 0x23, 0x46, 0x23, 0x14, 0x26, 0x13, + 0x0A, 0x13, 0x0A, 0x03, 0x1B, 0x02, 0x0A, 0x11, 0x13, 0x11, 0x1E, 0x0F, + 0x11, 0x29, 0x16, 0x11, 0x23, 0x11, 0x0A, 0x10, 0x06, 0x07, 0x0A, 0x0A, + 0x0F, 0x1D, 0x0F, 0x07, 0x16, 0x0D, 0x09, 0x01, 0x0A, 0x03, 0x05, 0x0A, + 0x12, 0x25, 0x13, 0x0F, 0x1F, 0x10, 0x13, 0x28, 0x14, 0x11, 0x23, 0x10, + 0x14, 0x27, 0x13, 0x05, 0x04, 0x01, 0x01, 0x07, 0x01, 0x02, 0x33, 0x0A, + 0x23, 0x46, 0x23, 0x24, 0x4B, 0x24, 0x10, 0x24, 0x10, 0x14, 0x27, 0x14, + 0x11, 0x21, 0x10, 0x09, 0x11, 0x09, 0x03, 0x09, 0x02, 0x07, 0x03, 0x0A, + 0x0F, 0x1E, 0x0F, 0x04, 0x04, 0x03, 0x03, 0x0E, 0x05, 0x10, 0x22, 0x10, + 0x27, 0x4D, 0x26, 0x12, 0x25, 0x12, 0x0E, 0x2F, 0x09, 0x09, 0x04, 0x03, + 0x0C, 0x06, 0x04, 0x3F, 0x06, 0x14, 0x28, 0x13, 0x15, 0x2B, 0x15, 0x08, + 0x19, 0x08, 0x03, 0x06, 0x01, 0x04, 0x03, 0x05, 0x13, 0x2B, 0x07, 0x4C, + 0x99, 0x99, 0x99, 0x4D, 0x16, 0x2C, 0x16, 0x07, 0x0E, 0x07, 0x0A, 0x07, + 0x08, 0x06, 0x0F, 0x07, 0x0A, 0x09, 0x07, 0x09, 0x07, 0x0E, 0x13, 0x27, + 0x13, 0x20, 0x40, 0x20, 0x02, 0x0C, 0x08, 0x06, 0x0D, 0x08, 0x05, 0x15, + 0x01, 0x06, 0x07, 0x03, 0x01, 0x05, 0x04, 0x03, 0x04, 0x09, 0x02, 0x04, + 0x07, 0x04, 0x05, 0x02, 0x04, 0x06, 0x0E, 0x06, 0x23, 0x45, 0x22, 0x22, + 0x44, 0x22, 0x06, 0x0E, 0x03, 0x03, 0x01, 0x01, 0x02, 0x0B, 0xF9, 0x45, + 0x10, 0x3E, 0x09, 0x13, 0x2A, 0x07, 0x03, 0x08, 0x0F, 0x0B, 0x11, 0x0C, + 0x14, 0x28, 0x13, 0x01, 0xDD, 0x05, 0x02, 0x03, 0x05, 0x02, 0x04, 0x04, + 0x05, 0x04, 0x0A, 0x1C, 0x0E, 0x08, 0x0D, 0x0E, 0x0B, 0x13, 0x04, 0x04, + 0x09, 0x02, 0x07, 0x09, 0x01, 0x01, 0x01, 0x01, 0x02, 0x04, 0x06, 0x05, + 0x01, 0x04, 0x02, 0x01, 0x01, 0x01, 0x01, 0x07, 0x02, 0x07, 0x03, 0x01, + 0x09, 0x26, 0x4C, 0x26, 0x0C, 0x76, 0x03, 0x09, 0x0E, 0x05, 0x02, 0x0A, + 0x0F, 0x12, 0x24, 0x12, 0x1C, 0x38, 0x1C, 0x0E, 0x1B, 0x0E, 0x01, 0x01, + 0x02, 0x06, 0x0E, 0x02, 0x05, 0x09, 0x05, 0x04, 0x03, 0x0B, 0x16, 0x0A, + 0x09, 0x19, 0x02, 0x03, 0x04, 0x02, 0x02, 0x01, 0x01, 0x01, 0x04, 0x05, + 0x08, 0x04, 0x01, 0x06, 0x01, 0x0D, 0x02, 0x21, 0x41, 0x1F, 0x07, 0x0B, + 0x03, 0x03, 0x15, 0x05, 0x0C, 0x17, 0x0C, 0x02, 0x03, 0x01, 0x0D, 0x23, + 0x0E, 0x15, 0x1E, 0x13, 0x11, 0x36, 0x0C, 0x04, 0x0B, 0x16, 0x0C, 0x1C, + 0x34, 0x1A, 0x0B, 0x0E, 0x01, 0x1E, 0x17, 0x0C, 0x14, 0x0C, 0x07, 0x12, + 0x08, 0x12, 0x23, 0x13, 0x07, 0x0E, 0x07, 0x05, 0x0B, 0x05, 0x02, 0x04, + 0x03, 0x09, 0x11, 0x09, 0x0A, 0x04, 0x02, 0x05, 0x01, 0x01, 0x1B, 0x05, + 0x0B, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x03, 0x0C, 0x1F, 0x07, + 0x05, 0x10, 0x09, 0x0B, 0x1A, 0x01, 0x01, 0x01, 0x07, 0x09, 0x0B, 0x06, + 0x08, 0x09, 0x04, 0x01, 0x18, 0x04, 0x02, 0x08, 0x07, 0x06, 0x07, 0x05, + 0x09, 0x18, 0x0B, 0x03, 0x05, 0x03, 0x03, 0x02, 0x01, 0x02, 0x02, 0x03, + 0x04, 0x01, 0x01, 0x34, 0x07, 0x0A, 0x12, 0x0A, 0x08, 0x0E, 0x07, 0x0C, + 0x04, 0x03, 0x01, 0x02, 0x02, 0x05, 0x02, 0x08, 0x02, 0x01, 0x02, 0x01, + 0x01, 0x02, 0x01, 0x05, 0x0A, 0x03, 0x07, 0x07, 0x02, 0x08, 0x02, 0x04, + 0x04, 0x01, 0x03, 0x01, 0x01, 0x02, 0x07, 0x04, 0x01, 0x01, 0x02, 0x0D, + 0x0D, 0x2E, 0x0E, 0x0A, 0x13, 0x08, 0x07, 0x03, 0x01, 0x02, 0x03, 0x07, + 0x04, 0x02, 0x06, 0x04, 0x02, 0x0D, 0x03, 0x06, 0x02, 0x0B, 0x16, 0x16, + 0x08, 0x01, 0x02, 0x02, 0x05, 0x05, 0x04, 0x01, 0x08, 0x0D, 0x03, 0x09, + 0x27, 0x08, 0x06, 0x0E, 0x02, 0x01, 0x04, 0x04, 0x11, 0x20, 0x12, 0x06, + 0x0E, 0x07, 0x06, 0x01, 0x03, 0x03, 0x0B, 0x04, 0x05, 0x03, 0x02, 0x01, + 0x05, 0x04, 0x13, 0x05, 0x09, 0x16, 0x03, 0x8B, 0x10, 0x12, 0x01, 0x16, + 0x0A, 0x16, 0x03, 0x02, 0x05, 0x06, 0x05, 0x00, 0x00, 0x08, 0x00, 0x4A, + 0x00, 0x5A, 0x0A, 0xD5, 0x03, 0x26, 0x00, 0x06, 0x00, 0x0C, 0x01, 0xE7, + 0x01, 0xFA, 0x02, 0x0D, 0x02, 0x1F, 0x02, 0x28, 0x02, 0x2E, 0x00, 0x00, + 0x01, 0x22, 0x27, 0x31, 0x30, 0x31, 0x16, 0x37, 0x22, 0x06, 0x23, 0x32, + 0x36, 0x25, 0x06, 0x26, 0x23, 0x22, 0x26, 0x07, 0x2E, 0x01, 0x07, 0x22, + 0x06, 0x07, 0x36, 0x06, 0x23, 0x22, 0x06, 0x27, 0x06, 0x26, 0x23, 0x2A, + 0x01, 0x27, 0x06, 0x16, 0x07, 0x3C, 0x01, 0x33, 0x0E, 0x01, 0x35, 0x34, + 0x06, 0x33, 0x22, 0x26, 0x27, 0x16, 0x26, 0x33, 0x22, 0x06, 0x07, 0x36, + 0x22, 0x17, 0x2E, 0x01, 0x23, 0x32, 0x06, 0x37, 0x22, 0x06, 0x17, 0x26, + 0x36, 0x23, 0x22, 0x06, 0x35, 0x34, 0x06, 0x07, 0x34, 0x22, 0x17, 0x2E, + 0x01, 0x27, 0x32, 0x06, 0x35, 0x2B, 0x01, 0x34, 0x06, 0x35, 0x34, 0x06, + 0x07, 0x0E, 0x01, 0x07, 0x06, 0x16, 0x17, 0x1E, 0x01, 0x15, 0x16, 0x06, + 0x23, 0x22, 0x16, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x06, 0x17, 0x2A, 0x01, + 0x23, 0x22, 0x26, 0x35, 0x34, 0x36, 0x23, 0x22, 0x06, 0x07, 0x2A, 0x01, + 0x23, 0x0E, 0x01, 0x07, 0x06, 0x14, 0x15, 0x06, 0x16, 0x07, 0x06, 0x22, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x16, 0x26, 0x27, 0x2E, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x27, 0x26, 0x06, + 0x23, 0x2E, 0x01, 0x23, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x06, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x06, 0x27, 0x2E, 0x01, + 0x27, 0x26, 0x36, 0x23, 0x22, 0x26, 0x07, 0x06, 0x16, 0x15, 0x14, 0x06, + 0x27, 0x16, 0x06, 0x27, 0x32, 0x16, 0x15, 0x06, 0x36, 0x35, 0x3C, 0x01, + 0x35, 0x34, 0x26, 0x27, 0x34, 0x26, 0x35, 0x34, 0x26, 0x33, 0x32, 0x36, + 0x07, 0x16, 0x36, 0x17, 0x16, 0x06, 0x15, 0x1C, 0x01, 0x15, 0x30, 0x17, + 0x16, 0x35, 0x34, 0x16, 0x37, 0x36, 0x26, 0x23, 0x22, 0x06, 0x27, 0x26, + 0x36, 0x37, 0x36, 0x16, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x17, 0x16, + 0x36, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, + 0x26, 0x07, 0x06, 0x36, 0x33, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x33, 0x32, + 0x16, 0x37, 0x36, 0x26, 0x37, 0x36, 0x16, 0x33, 0x32, 0x36, 0x23, 0x22, + 0x06, 0x27, 0x26, 0x36, 0x33, 0x32, 0x36, 0x33, 0x36, 0x16, 0x17, 0x16, + 0x06, 0x33, 0x32, 0x36, 0x17, 0x16, 0x06, 0x17, 0x16, 0x36, 0x33, 0x37, + 0x36, 0x27, 0x26, 0x06, 0x23, 0x26, 0x06, 0x27, 0x26, 0x36, 0x35, 0x34, + 0x26, 0x37, 0x36, 0x16, 0x33, 0x32, 0x16, 0x17, 0x1E, 0x01, 0x35, 0x34, + 0x16, 0x33, 0x32, 0x06, 0x33, 0x32, 0x16, 0x37, 0x36, 0x26, 0x17, 0x26, + 0x36, 0x17, 0x26, 0x36, 0x33, 0x32, 0x06, 0x17, 0x1E, 0x01, 0x37, 0x36, + 0x26, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x06, 0x33, 0x32, 0x36, 0x37, 0x3E, + 0x01, 0x37, 0x36, 0x32, 0x33, 0x32, 0x36, 0x33, 0x32, 0x06, 0x17, 0x16, + 0x06, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x26, 0x23, 0x22, 0x06, 0x27, 0x2E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x22, 0x23, 0x22, 0x06, 0x07, 0x06, + 0x16, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x26, 0x37, 0x36, + 0x26, 0x37, 0x36, 0x16, 0x33, 0x32, 0x16, 0x17, 0x26, 0x16, 0x17, 0x16, + 0x06, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x16, 0x07, 0x16, + 0x06, 0x15, 0x14, 0x16, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x26, 0x33, 0x32, + 0x16, 0x37, 0x1E, 0x01, 0x17, 0x3C, 0x01, 0x35, 0x16, 0x36, 0x33, 0x3A, + 0x01, 0x33, 0x32, 0x36, 0x17, 0x14, 0x16, 0x07, 0x05, 0x34, 0x26, 0x23, + 0x22, 0x26, 0x07, 0x14, 0x06, 0x17, 0x16, 0x06, 0x33, 0x3A, 0x01, 0x37, + 0x26, 0x36, 0x35, 0x05, 0x34, 0x26, 0x07, 0x0E, 0x01, 0x17, 0x06, 0x36, + 0x07, 0x0E, 0x01, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x35, 0x13, 0x26, + 0x06, 0x15, 0x22, 0x26, 0x23, 0x2E, 0x01, 0x07, 0x06, 0x16, 0x07, 0x32, + 0x16, 0x33, 0x34, 0x36, 0x05, 0x22, 0x26, 0x07, 0x3A, 0x01, 0x33, 0x3C, + 0x01, 0x05, 0x22, 0x23, 0x07, 0x32, 0x36, 0x06, 0xA4, 0x01, 0x01, 0x01, + 0x11, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x20, 0x07, 0x3A, 0x12, 0x13, + 0x9A, 0x01, 0x08, 0x0A, 0x0B, 0x0A, 0x07, 0x0C, 0x05, 0x5B, 0x0E, 0x24, + 0x53, 0x22, 0x07, 0x8E, 0x13, 0x36, 0x6C, 0x36, 0x01, 0x03, 0x07, 0x01, + 0x05, 0x12, 0x17, 0x04, 0x09, 0x04, 0x0A, 0x06, 0x17, 0x02, 0x0A, 0x02, + 0x08, 0x05, 0x1B, 0x05, 0x08, 0x02, 0x0A, 0x02, 0x16, 0x06, 0x01, 0x13, + 0x08, 0x0B, 0x02, 0x0C, 0x01, 0x0C, 0x11, 0x05, 0x1B, 0x09, 0x0A, 0x04, + 0x0C, 0x01, 0x22, 0x25, 0x24, 0x31, 0x15, 0x04, 0x0D, 0x15, 0x05, 0x02, + 0x01, 0x01, 0x01, 0x08, 0x01, 0x03, 0x0A, 0x06, 0x02, 0x05, 0x07, 0x2E, + 0x5B, 0x2E, 0x08, 0x04, 0x03, 0x0B, 0x07, 0x09, 0x05, 0x1D, 0x3C, 0x1D, + 0x0D, 0x12, 0x03, 0x01, 0x01, 0x05, 0x02, 0x02, 0x0F, 0x03, 0x05, 0x05, + 0x03, 0x06, 0x0F, 0x04, 0x14, 0x62, 0x0F, 0x12, 0x15, 0x05, 0x02, 0x0C, + 0x04, 0x14, 0x22, 0x13, 0x0A, 0x14, 0x0D, 0x0E, 0x3C, 0x17, 0x15, 0x22, + 0x16, 0x1B, 0x2A, 0x13, 0x06, 0x0B, 0x06, 0x0F, 0x09, 0x06, 0x07, 0x3C, + 0x1F, 0x1C, 0x39, 0x1C, 0x15, 0x4A, 0x14, 0x04, 0x05, 0x04, 0x06, 0x0A, + 0x0E, 0x0A, 0x23, 0x05, 0x03, 0x03, 0x0E, 0x19, 0x02, 0x09, 0x0C, 0x01, + 0x01, 0x20, 0x10, 0x02, 0x02, 0x03, 0x08, 0x09, 0x09, 0x23, 0x08, 0x12, + 0x13, 0x05, 0x03, 0x03, 0x21, 0x21, 0x61, 0x05, 0x02, 0x0C, 0x0E, 0x17, + 0x26, 0x06, 0x05, 0x03, 0x09, 0x07, 0x17, 0x0A, 0x21, 0x42, 0x22, 0x27, + 0x52, 0x26, 0x16, 0x42, 0x07, 0x02, 0x13, 0x05, 0x09, 0x16, 0x0C, 0x06, + 0x12, 0x08, 0x14, 0x62, 0x03, 0x03, 0x6B, 0x15, 0x07, 0x0D, 0x04, 0x0E, + 0x36, 0x15, 0x13, 0x2D, 0x0B, 0x04, 0x01, 0x04, 0x05, 0x15, 0x07, 0x0E, + 0x09, 0x11, 0x02, 0x1D, 0x02, 0x06, 0x08, 0x07, 0x0F, 0x23, 0x0C, 0x08, + 0x0D, 0x05, 0x07, 0x04, 0x10, 0x0A, 0x21, 0x07, 0x03, 0x03, 0x02, 0x0F, + 0x3E, 0x12, 0x02, 0x03, 0x03, 0x0B, 0x17, 0x0D, 0x2C, 0x61, 0x2A, 0x09, + 0x03, 0x03, 0x03, 0x05, 0x46, 0x07, 0x23, 0x44, 0x1E, 0x06, 0x0F, 0x37, + 0x0C, 0x0F, 0x0E, 0x11, 0x0A, 0x18, 0x0A, 0x05, 0x05, 0x10, 0x03, 0x02, + 0x09, 0x03, 0x0B, 0x0E, 0x18, 0x04, 0x05, 0x06, 0x24, 0x16, 0x03, 0x08, + 0x0C, 0x0D, 0x1B, 0x0E, 0x12, 0x0A, 0x17, 0x17, 0x22, 0x15, 0x19, 0x34, + 0x1A, 0x17, 0x1E, 0x1E, 0x1A, 0x35, 0x1B, 0x0F, 0x01, 0x02, 0x04, 0x04, + 0x12, 0x0F, 0x28, 0x57, 0x27, 0x0D, 0x1D, 0x0D, 0x0F, 0x1D, 0x0D, 0x10, + 0x1F, 0x10, 0x19, 0x02, 0x04, 0x03, 0x01, 0x0F, 0x3C, 0x76, 0x3B, 0x25, + 0x49, 0x25, 0x10, 0x06, 0x04, 0x02, 0x03, 0x05, 0x06, 0x2F, 0x0B, 0x09, + 0x10, 0x06, 0x01, 0x20, 0x05, 0x0A, 0x05, 0x1B, 0x25, 0x48, 0x25, 0x18, + 0x2F, 0x18, 0x09, 0x13, 0x12, 0x09, 0x01, 0x09, 0x1C, 0x34, 0x67, 0x34, + 0x0D, 0x06, 0x0B, 0x03, 0x17, 0x01, 0x02, 0x09, 0x03, 0x18, 0x50, 0x24, + 0x09, 0x12, 0x11, 0x0E, 0x41, 0x03, 0x02, 0x02, 0xF6, 0x11, 0x05, 0x11, + 0x0B, 0x1B, 0x06, 0x02, 0x02, 0x03, 0x03, 0x13, 0x0E, 0x19, 0x08, 0x02, + 0x02, 0x03, 0x7D, 0x2C, 0x19, 0x11, 0x02, 0x05, 0x20, 0x12, 0x1A, 0x06, + 0x01, 0x12, 0x0F, 0x4C, 0x0C, 0x07, 0x02, 0xAB, 0x0B, 0x3A, 0x0A, 0x15, + 0x0B, 0x01, 0x42, 0x09, 0x05, 0x03, 0x01, 0x30, 0x5E, 0x30, 0x03, 0x02, + 0x44, 0x0B, 0x1B, 0x04, 0x0A, 0x16, 0x0A, 0xFE, 0xE9, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0xA9, 0x01, 0x01, 0x01, 0x01, 0x01, 0x2E, 0x0D, 0x05, + 0x05, 0x0F, 0x05, 0x02, 0x01, 0x06, 0x01, 0x16, 0x07, 0x06, 0x08, 0x10, + 0x09, 0x01, 0x0C, 0x18, 0x05, 0x01, 0x01, 0x01, 0x02, 0x06, 0x0D, 0x11, + 0x06, 0x02, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01, 0x02, 0x04, 0x01, 0x01, + 0x07, 0x02, 0x02, 0x07, 0x0D, 0x0A, 0x06, 0x07, 0x02, 0x01, 0x02, 0x02, + 0x03, 0x02, 0x06, 0x03, 0x09, 0x17, 0x0E, 0x05, 0x0A, 0x02, 0x04, 0x07, + 0x0C, 0x05, 0x1A, 0x06, 0x05, 0x0C, 0x02, 0x0B, 0x0E, 0x17, 0x05, 0x11, + 0x23, 0x12, 0x1E, 0x49, 0x1B, 0x2B, 0x0A, 0x0F, 0x7E, 0x08, 0x01, 0x01, + 0x0D, 0x0B, 0x03, 0x0A, 0x01, 0x01, 0x0B, 0x04, 0x02, 0x03, 0x04, 0x0D, + 0x06, 0x0A, 0x18, 0x0B, 0x24, 0x17, 0x04, 0x06, 0x05, 0x12, 0x08, 0x0B, + 0x06, 0x20, 0x36, 0x1E, 0x0F, 0x1D, 0x12, 0x14, 0x03, 0x01, 0x0B, 0x02, + 0x0C, 0x04, 0x0C, 0x06, 0x10, 0x0F, 0x15, 0x1D, 0x07, 0x08, 0x08, 0x02, + 0x0C, 0x03, 0x04, 0x04, 0x03, 0x07, 0x05, 0x22, 0x07, 0x19, 0x02, 0x01, + 0x0A, 0x0C, 0x03, 0x01, 0x01, 0x0A, 0x44, 0x0B, 0x1B, 0x37, 0x1B, 0x18, + 0x2E, 0x16, 0x08, 0x14, 0x05, 0x07, 0x0E, 0x01, 0x0B, 0x02, 0x02, 0x0E, + 0x08, 0x18, 0x08, 0x0A, 0x12, 0x09, 0x04, 0x05, 0x10, 0x1F, 0x22, 0x1C, + 0x0F, 0x02, 0x03, 0x12, 0x11, 0x58, 0x07, 0x05, 0x01, 0x04, 0x02, 0x01, + 0x05, 0x1B, 0x09, 0x13, 0x07, 0x0B, 0x1E, 0x0A, 0x05, 0x0F, 0x02, 0x07, + 0x11, 0x19, 0x17, 0x07, 0x10, 0x04, 0x0F, 0x4F, 0x03, 0x0B, 0x03, 0x10, + 0x03, 0x04, 0x02, 0x0C, 0x02, 0x02, 0x07, 0x0D, 0x05, 0x01, 0x02, 0x02, + 0x02, 0x08, 0x02, 0x04, 0x02, 0x11, 0x01, 0x08, 0x07, 0x21, 0x21, 0x05, + 0x0F, 0x16, 0x01, 0x06, 0x06, 0x01, 0x32, 0x09, 0x03, 0x19, 0x03, 0x05, + 0x07, 0x03, 0x05, 0x01, 0x08, 0x10, 0x0E, 0x05, 0x14, 0x02, 0x02, 0x02, + 0x0F, 0x04, 0x08, 0x0E, 0x01, 0x10, 0x07, 0x09, 0x11, 0x11, 0x12, 0x0A, + 0x02, 0x0B, 0x12, 0x06, 0x06, 0x06, 0x0B, 0x06, 0x04, 0x01, 0x07, 0x0C, + 0x11, 0x29, 0x12, 0x09, 0x12, 0x09, 0x11, 0x02, 0x05, 0x08, 0x03, 0x0B, + 0x03, 0x04, 0x08, 0x03, 0x03, 0x01, 0x11, 0x0F, 0x2A, 0x07, 0x0C, 0x07, + 0x0A, 0x04, 0x07, 0x04, 0x06, 0x06, 0x14, 0x0E, 0x06, 0x0D, 0x12, 0x0E, + 0x04, 0x08, 0x16, 0x11, 0x1A, 0x07, 0x0B, 0x12, 0x12, 0x02, 0x04, 0x04, + 0x03, 0x05, 0x03, 0x0D, 0x02, 0x05, 0x0C, 0x06, 0x14, 0x05, 0x4A, 0x0F, + 0x04, 0x01, 0x05, 0x0F, 0x1F, 0x0F, 0x0E, 0x07, 0x06, 0x0D, 0x21, 0x0F, + 0x47, 0x20, 0x0C, 0x13, 0x0C, 0x1E, 0x12, 0x02, 0x50, 0x08, 0x0E, 0x31, + 0x09, 0x07, 0x01, 0x09, 0x06, 0x10, 0x0C, 0x01, 0x63, 0x0A, 0x15, 0x04, + 0x01, 0x07, 0x10, 0x09, 0x05, 0x1F, 0x08, 0x01, 0x05, 0x24, 0x41, 0x02, + 0x08, 0x01, 0x04, 0xBA, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x62, + 0x00, 0x8D, 0x0D, 0x2B, 0x02, 0xF3, 0x00, 0xA4, 0x00, 0xB2, 0x00, 0x00, + 0x01, 0x2F, 0x01, 0x35, 0x21, 0x35, 0x37, 0x17, 0x35, 0x17, 0x33, 0x2F, + 0x02, 0x0F, 0x02, 0x23, 0x35, 0x32, 0x36, 0x3F, 0x01, 0x27, 0x23, 0x07, + 0x15, 0x17, 0x15, 0x0F, 0x01, 0x23, 0x27, 0x0F, 0x02, 0x23, 0x07, 0x0E, + 0x01, 0x1D, 0x01, 0x17, 0x15, 0x1F, 0x01, 0x3F, 0x02, 0x33, 0x15, 0x23, + 0x0E, 0x01, 0x0F, 0x03, 0x23, 0x15, 0x0F, 0x01, 0x21, 0x27, 0x2E, 0x01, + 0x23, 0x21, 0x0F, 0x03, 0x23, 0x07, 0x0E, 0x01, 0x1D, 0x01, 0x07, 0x15, + 0x1F, 0x01, 0x33, 0x3F, 0x03, 0x33, 0x17, 0x37, 0x32, 0x36, 0x35, 0x37, + 0x33, 0x1F, 0x05, 0x3F, 0x04, 0x33, 0x37, 0x1E, 0x01, 0x17, 0x3F, 0x02, + 0x3E, 0x01, 0x33, 0x15, 0x25, 0x35, 0x3E, 0x01, 0x3F, 0x03, 0x17, 0x0E, + 0x01, 0x23, 0x2E, 0x01, 0x2B, 0x01, 0x22, 0x06, 0x15, 0x06, 0x16, 0x1F, + 0x02, 0x33, 0x37, 0x2F, 0x01, 0x37, 0x21, 0x37, 0x35, 0x3F, 0x01, 0x34, + 0x26, 0x2F, 0x01, 0x35, 0x23, 0x35, 0x21, 0x37, 0x3E, 0x01, 0x35, 0x27, + 0x05, 0x23, 0x22, 0x26, 0x35, 0x34, 0x36, 0x3B, 0x01, 0x32, 0x16, 0x15, + 0x14, 0x06, 0x0D, 0x27, 0x04, 0x06, 0xF8, 0x92, 0x37, 0x21, 0xE0, 0x07, + 0x02, 0x05, 0x26, 0x46, 0x4B, 0x37, 0xA7, 0x02, 0x05, 0x01, 0x03, 0x0B, + 0x02, 0x5F, 0x02, 0x20, 0x32, 0x64, 0x2E, 0x41, 0x37, 0x18, 0x06, 0x02, + 0x02, 0x02, 0x04, 0x02, 0x38, 0x41, 0x37, 0x1D, 0x24, 0x61, 0x03, 0x03, + 0x01, 0x0B, 0x25, 0x2D, 0x02, 0x06, 0x09, 0xFE, 0xC8, 0x1F, 0x04, 0x0A, + 0x04, 0xFE, 0xED, 0x09, 0x06, 0x03, 0x02, 0x1E, 0x67, 0x0B, 0x0C, 0x06, + 0x03, 0x03, 0x08, 0x1C, 0x25, 0x23, 0x17, 0x4C, 0x28, 0x0D, 0x03, 0x04, + 0x0C, 0x97, 0x16, 0x22, 0x21, 0x2B, 0x4F, 0x51, 0x36, 0x10, 0x0E, 0x08, + 0x01, 0x09, 0x05, 0x13, 0x22, 0x0F, 0x35, 0x22, 0x13, 0x02, 0x0D, 0x0A, + 0x01, 0x08, 0x01, 0x0E, 0x0C, 0x37, 0x35, 0x1D, 0xDF, 0x0A, 0x13, 0x09, + 0x03, 0x12, 0x0E, 0x04, 0x07, 0x07, 0x04, 0x01, 0x06, 0x0F, 0x05, 0x2F, + 0x05, 0x08, 0x05, 0x05, 0x01, 0xD9, 0x06, 0x02, 0x02, 0x05, 0x05, 0x0D, + 0x5A, 0x04, 0xC8, 0x04, 0x07, 0x07, 0x04, 0xF6, 0xF3, 0x40, 0x0D, 0x0E, + 0x0E, 0x0D, 0x40, 0x0E, 0x0D, 0x0D, 0x02, 0x26, 0x0C, 0x0C, 0x05, 0x1A, + 0x01, 0x05, 0x04, 0x0E, 0x84, 0x03, 0x05, 0x06, 0x08, 0x08, 0x06, 0x02, + 0x02, 0x04, 0x20, 0x06, 0x12, 0x06, 0x13, 0x03, 0x01, 0x04, 0x04, 0x03, + 0x03, 0x02, 0x02, 0x06, 0x05, 0x1F, 0x31, 0x04, 0x06, 0x03, 0x06, 0x07, + 0x04, 0x1D, 0x01, 0x03, 0x01, 0x03, 0x07, 0x08, 0x06, 0x1D, 0x1D, 0x1F, + 0x05, 0x05, 0x07, 0x03, 0x02, 0x03, 0x07, 0x05, 0x09, 0x05, 0x4C, 0x67, + 0x84, 0x14, 0x03, 0x05, 0x08, 0x06, 0x04, 0x08, 0x08, 0x04, 0x05, 0x4A, + 0x10, 0x20, 0x22, 0x0F, 0x0D, 0x0A, 0x06, 0x17, 0x2B, 0x2F, 0x23, 0x03, + 0x0C, 0x0D, 0x01, 0x05, 0x12, 0x0F, 0x03, 0x03, 0x53, 0x1C, 0x50, 0x02, + 0x05, 0x03, 0x0F, 0x0F, 0x08, 0x03, 0x04, 0x05, 0x04, 0x04, 0x07, 0x07, + 0x08, 0x16, 0x0D, 0x23, 0x06, 0x11, 0x09, 0x03, 0x0C, 0x0D, 0x04, 0x03, + 0x09, 0x0A, 0x0E, 0x04, 0x0D, 0x4E, 0x15, 0x06, 0x0A, 0x10, 0x06, 0x0F, + 0xE8, 0x0F, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x0F, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x52, 0x00, 0xDA, 0x08, 0x53, 0x02, 0xA9, 0x00, 0xA8, + 0x00, 0x00, 0x01, 0x3E, 0x01, 0x37, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, + 0x22, 0x06, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x06, 0x07, + 0x0E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x07, 0x0E, 0x01, 0x27, + 0x2E, 0x01, 0x35, 0x34, 0x36, 0x27, 0x26, 0x06, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, + 0x26, 0x06, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x35, + 0x2E, 0x01, 0x27, 0x26, 0x36, 0x37, 0x36, 0x26, 0x37, 0x34, 0x36, 0x37, + 0x34, 0x36, 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x17, 0x16, 0x36, 0x37, 0x36, 0x26, 0x35, 0x34, 0x36, 0x17, + 0x1E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x16, 0x17, 0x1E, 0x01, 0x17, + 0x16, 0x06, 0x15, 0x14, 0x36, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, + 0x32, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x37, + 0x3E, 0x01, 0x37, 0x08, 0x14, 0x10, 0x20, 0x0F, 0x1C, 0x3C, 0x25, 0x1A, + 0x3E, 0x20, 0x13, 0x28, 0x14, 0x37, 0x6F, 0x38, 0x4A, 0x95, 0x4B, 0x0E, + 0x1C, 0x0E, 0x03, 0x13, 0x03, 0x02, 0x05, 0x02, 0x05, 0x10, 0x0D, 0x1F, + 0x48, 0x17, 0x0A, 0x1A, 0x0A, 0x04, 0x10, 0x06, 0x05, 0x04, 0x02, 0x02, + 0x10, 0x07, 0x1C, 0x21, 0x01, 0x02, 0x02, 0x18, 0x0C, 0x14, 0x26, 0x13, + 0x17, 0x2E, 0x17, 0x39, 0x71, 0x39, 0x3E, 0x7D, 0x3E, 0x12, 0x25, 0x12, + 0x15, 0x17, 0x09, 0x05, 0x11, 0x0A, 0x06, 0x02, 0x01, 0x01, 0x01, 0x04, + 0x0D, 0x02, 0x04, 0x07, 0x0C, 0x05, 0x01, 0x01, 0x01, 0x01, 0x03, 0x05, + 0x0B, 0x12, 0x05, 0x0A, 0x18, 0x14, 0x13, 0x27, 0x13, 0x3E, 0x7C, 0x3E, + 0x39, 0x72, 0x39, 0x16, 0x2D, 0x16, 0x14, 0x27, 0x13, 0x06, 0x0A, 0x06, + 0x08, 0x03, 0x01, 0x02, 0x02, 0x2B, 0x1C, 0x0F, 0x01, 0x0B, 0x07, 0x10, + 0x02, 0x03, 0x09, 0x08, 0x02, 0x06, 0x02, 0x01, 0x01, 0x16, 0x06, 0x13, + 0x26, 0x13, 0x22, 0x43, 0x22, 0x39, 0x73, 0x39, 0x3A, 0x74, 0x3A, 0x20, + 0x42, 0x21, 0x16, 0x2E, 0x16, 0x1C, 0x39, 0x1D, 0x02, 0x05, 0x01, 0x05, + 0x02, 0x24, 0x46, 0x1C, 0x14, 0x1B, 0x0A, 0x06, 0x0A, 0x02, 0x04, 0x0D, + 0x01, 0x02, 0x02, 0x13, 0x04, 0x0D, 0x15, 0x08, 0x12, 0x14, 0x19, 0x0C, + 0x30, 0x11, 0x06, 0x04, 0x03, 0x03, 0x0C, 0x05, 0x08, 0x04, 0x01, 0x04, + 0x28, 0x1C, 0x0F, 0x20, 0x0F, 0x11, 0x04, 0x01, 0x03, 0x06, 0x03, 0x03, + 0x02, 0x02, 0x03, 0x08, 0x03, 0x03, 0x05, 0x06, 0x02, 0x04, 0x01, 0x02, + 0x19, 0x10, 0x08, 0x0D, 0x0A, 0x06, 0x13, 0x08, 0x10, 0x20, 0x10, 0x09, + 0x0B, 0x09, 0x0F, 0x20, 0x0A, 0x05, 0x16, 0x07, 0x08, 0x10, 0x08, 0x07, + 0x10, 0x06, 0x0C, 0x13, 0x08, 0x10, 0x15, 0x02, 0x02, 0x03, 0x02, 0x06, + 0x06, 0x03, 0x03, 0x09, 0x03, 0x02, 0x02, 0x03, 0x03, 0x06, 0x03, 0x01, + 0x01, 0x01, 0x01, 0x10, 0x05, 0x0E, 0x20, 0x0F, 0x1B, 0x2D, 0x04, 0x02, + 0x18, 0x06, 0x05, 0x03, 0x0B, 0x0D, 0x22, 0x0A, 0x03, 0x04, 0x03, 0x03, + 0x0C, 0x03, 0x07, 0x02, 0x0A, 0x05, 0x05, 0x05, 0x02, 0x02, 0x03, 0x01, + 0x01, 0x05, 0x01, 0x02, 0x05, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x53, + 0x00, 0xD4, 0x08, 0x54, 0x02, 0xAB, 0x01, 0x20, 0x00, 0x00, 0x01, 0x2E, + 0x01, 0x27, 0x2E, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x0E, 0x01, 0x27, 0x30, + 0x2B, 0x01, 0x06, 0x26, 0x27, 0x26, 0x06, 0x23, 0x22, 0x26, 0x07, 0x06, + 0x26, 0x27, 0x30, 0x31, 0x22, 0x23, 0x14, 0x06, 0x23, 0x22, 0x26, 0x27, + 0x26, 0x06, 0x27, 0x2E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x0E, 0x01, 0x27, + 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x07, + 0x0E, 0x01, 0x23, 0x22, 0x26, 0x35, 0x22, 0x23, 0x31, 0x0E, 0x01, 0x27, + 0x2E, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x06, 0x27, 0x2E, 0x01, 0x27, + 0x2E, 0x01, 0x35, 0x36, 0x34, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x26, 0x27, + 0x2E, 0x01, 0x27, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, + 0x26, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x26, 0x06, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x14, 0x07, 0x22, 0x06, 0x17, + 0x22, 0x17, 0x33, 0x14, 0x16, 0x15, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x16, 0x36, 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x33, + 0x32, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x32, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x07, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x35, 0x34, 0x36, 0x37, 0x3E, 0x01, 0x17, + 0x1E, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x26, 0x37, 0x36, 0x16, 0x17, + 0x31, 0x33, 0x36, 0x32, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x17, 0x1E, + 0x01, 0x17, 0x16, 0x36, 0x37, 0x36, 0x16, 0x17, 0x3E, 0x01, 0x33, 0x32, + 0x16, 0x15, 0x16, 0x36, 0x33, 0x32, 0x16, 0x17, 0x16, 0x32, 0x37, 0x36, + 0x16, 0x17, 0x32, 0x33, 0x31, 0x36, 0x32, 0x17, 0x16, 0x36, 0x33, 0x32, + 0x16, 0x17, 0x16, 0x32, 0x37, 0x36, 0x16, 0x17, 0x30, 0x3B, 0x01, 0x3E, + 0x01, 0x17, 0x16, 0x14, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x2E, 0x01, 0x27, 0x07, + 0xE5, 0x20, 0x43, 0x21, 0x33, 0x67, 0x33, 0x3E, 0x7B, 0x3E, 0x04, 0x0B, + 0x03, 0x01, 0x01, 0x02, 0x0D, 0x03, 0x08, 0x0A, 0x09, 0x09, 0x0B, 0x08, + 0x02, 0x0D, 0x03, 0x01, 0x01, 0x03, 0x06, 0x04, 0x04, 0x01, 0x07, 0x0C, + 0x0B, 0x06, 0x10, 0x03, 0x04, 0x0B, 0x03, 0x04, 0x07, 0x05, 0x02, 0x03, + 0x07, 0x02, 0x07, 0x06, 0x07, 0x0A, 0x03, 0x01, 0x08, 0x02, 0x01, 0x06, + 0x01, 0x05, 0x04, 0x01, 0x01, 0x01, 0x0A, 0x05, 0x03, 0x02, 0x09, 0x0D, + 0x1B, 0x0D, 0x09, 0x0F, 0x0A, 0x05, 0x0A, 0x06, 0x05, 0x02, 0x01, 0x04, + 0x04, 0x09, 0x04, 0x02, 0x02, 0x04, 0x0A, 0x16, 0x0B, 0x06, 0x19, 0x1E, + 0x11, 0x25, 0x13, 0x43, 0x85, 0x42, 0x33, 0x66, 0x32, 0x1D, 0x3A, 0x1C, + 0x0C, 0x12, 0x0B, 0x10, 0x2A, 0x0E, 0x0B, 0x13, 0x04, 0x02, 0x03, 0x01, + 0x01, 0x03, 0x0B, 0x01, 0x09, 0x01, 0x03, 0x03, 0x01, 0x01, 0x03, 0x01, + 0x06, 0x1D, 0x1E, 0x17, 0x27, 0x10, 0x09, 0x14, 0x0B, 0x10, 0x23, 0x11, + 0x43, 0x86, 0x43, 0x15, 0x2A, 0x15, 0x0F, 0x1D, 0x0F, 0x10, 0x20, 0x11, + 0x09, 0x11, 0x09, 0x08, 0x0D, 0x06, 0x16, 0x03, 0x10, 0x0B, 0x17, 0x0C, + 0x05, 0x03, 0x02, 0x09, 0x11, 0x09, 0x01, 0x01, 0x04, 0x08, 0x08, 0x10, + 0x08, 0x06, 0x08, 0x06, 0x0E, 0x1B, 0x0E, 0x09, 0x01, 0x04, 0x06, 0x08, + 0x01, 0x01, 0x03, 0x0D, 0x03, 0x05, 0x05, 0x02, 0x03, 0x0A, 0x06, 0x06, + 0x07, 0x01, 0x06, 0x04, 0x01, 0x06, 0x09, 0x02, 0x01, 0x03, 0x05, 0x05, + 0x05, 0x06, 0x0C, 0x09, 0x06, 0x09, 0x02, 0x03, 0x07, 0x01, 0x03, 0x0D, + 0x01, 0x01, 0x01, 0x02, 0x0E, 0x02, 0x07, 0x0C, 0x09, 0x06, 0x08, 0x03, + 0x02, 0x08, 0x01, 0x03, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x0A, 0x05, 0x01, + 0x04, 0x07, 0x0E, 0x06, 0x1C, 0x38, 0x1C, 0x35, 0x6A, 0x34, 0x1F, 0x3E, + 0x1E, 0x38, 0x77, 0x2C, 0x18, 0x3A, 0x1D, 0x01, 0xF4, 0x09, 0x0F, 0x03, + 0x05, 0x0A, 0x0F, 0x01, 0x10, 0x10, 0x01, 0x0F, 0x05, 0x16, 0x16, 0x05, + 0x10, 0x01, 0x0F, 0x04, 0x0D, 0x0E, 0x03, 0x05, 0x19, 0x03, 0x01, 0x18, + 0x0D, 0x10, 0x0B, 0x0A, 0x03, 0x14, 0x0D, 0x04, 0x0A, 0x04, 0x05, 0x0B, + 0x01, 0x02, 0x09, 0x05, 0x03, 0x04, 0x04, 0x02, 0x0D, 0x0E, 0x03, 0x07, + 0x10, 0x0D, 0x09, 0x01, 0x0C, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x06, + 0x0A, 0x15, 0x0A, 0x0C, 0x1A, 0x0C, 0x05, 0x19, 0x01, 0x03, 0x04, 0x03, + 0x20, 0x3F, 0x11, 0x09, 0x0C, 0x01, 0x02, 0x04, 0x03, 0x02, 0x08, 0x02, + 0x01, 0x07, 0x03, 0x01, 0x0F, 0x04, 0x06, 0x02, 0x0A, 0x08, 0x15, 0x0D, + 0x06, 0x0E, 0x06, 0x05, 0x0F, 0x03, 0x23, 0x02, 0x01, 0x04, 0x09, 0x05, + 0x08, 0x10, 0x08, 0x1B, 0x2A, 0x04, 0x03, 0x22, 0x0E, 0x08, 0x04, 0x03, + 0x04, 0x02, 0x02, 0x04, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01, 0x02, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x09, 0x05, 0x13, 0x3A, 0x18, 0x03, 0x06, 0x04, + 0x01, 0x0F, 0x04, 0x1A, 0x33, 0x19, 0x02, 0x04, 0x03, 0x08, 0x01, 0x01, + 0x01, 0x0A, 0x02, 0x01, 0x04, 0x04, 0x09, 0x0A, 0x13, 0x04, 0x0F, 0x0F, + 0x04, 0x0A, 0x02, 0x05, 0x05, 0x01, 0x02, 0x0A, 0x05, 0x04, 0x0A, 0x03, + 0x0E, 0x13, 0x04, 0x03, 0x0E, 0x0E, 0x03, 0x05, 0x16, 0x07, 0x06, 0x05, + 0x06, 0x0F, 0x0A, 0x0A, 0x0F, 0x0F, 0x05, 0x16, 0x08, 0x05, 0x05, 0x06, + 0x0F, 0x0A, 0x0A, 0x06, 0x11, 0x0E, 0x04, 0x05, 0x03, 0x02, 0x03, 0x04, + 0x08, 0x22, 0x26, 0x14, 0x18, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x55, + 0x00, 0x3E, 0x0C, 0x0F, 0x03, 0x42, 0x01, 0x8A, 0x01, 0x9D, 0x01, 0xA6, + 0x01, 0xB2, 0x00, 0x00, 0x01, 0x34, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x2A, + 0x03, 0x23, 0x2A, 0x03, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x26, 0x35, 0x3C, + 0x01, 0x35, 0x3C, 0x01, 0x35, 0x34, 0x36, 0x27, 0x26, 0x06, 0x23, 0x22, + 0x26, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x36, + 0x26, 0x35, 0x34, 0x36, 0x27, 0x26, 0x06, 0x23, 0x22, 0x14, 0x15, 0x1C, + 0x01, 0x15, 0x1C, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, + 0x36, 0x35, 0x34, 0x36, 0x27, 0x26, 0x06, 0x23, 0x22, 0x16, 0x07, 0x06, + 0x26, 0x07, 0x0E, 0x01, 0x07, 0x14, 0x06, 0x17, 0x16, 0x36, 0x17, 0x1E, + 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x06, 0x07, 0x06, 0x22, 0x23, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x23, 0x22, 0x06, 0x27, 0x26, 0x36, 0x37, 0x36, 0x34, 0x35, 0x34, + 0x36, 0x35, 0x2E, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x22, + 0x26, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x2E, + 0x01, 0x07, 0x0E, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x2A, + 0x01, 0x07, 0x06, 0x16, 0x15, 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x1C, + 0x01, 0x15, 0x14, 0x16, 0x37, 0x36, 0x32, 0x37, 0x06, 0x16, 0x35, 0x34, + 0x26, 0x27, 0x3C, 0x01, 0x35, 0x34, 0x36, 0x33, 0x32, 0x16, 0x37, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x32, 0x17, 0x16, + 0x36, 0x35, 0x34, 0x36, 0x37, 0x3E, 0x01, 0x33, 0x32, 0x36, 0x17, 0x16, + 0x36, 0x33, 0x32, 0x16, 0x07, 0x0E, 0x01, 0x15, 0x14, 0x06, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x14, 0x15, 0x14, 0x06, 0x17, 0x1E, + 0x01, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x26, 0x27, 0x26, + 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x35, 0x1E, 0x01, 0x33, 0x3A, + 0x02, 0x36, 0x33, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x33, 0x3A, 0x02, 0x16, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x06, + 0x17, 0x14, 0x16, 0x37, 0x14, 0x06, 0x17, 0x22, 0x06, 0x15, 0x06, 0x16, + 0x33, 0x06, 0x14, 0x15, 0x14, 0x06, 0x07, 0x06, 0x14, 0x15, 0x14, 0x16, + 0x17, 0x16, 0x36, 0x37, 0x06, 0x16, 0x17, 0x22, 0x06, 0x17, 0x16, 0x36, + 0x33, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x27, 0x36, 0x26, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x27, 0x3E, 0x01, 0x35, 0x34, 0x26, 0x27, 0x2E, 0x01, + 0x35, 0x3C, 0x01, 0x35, 0x34, 0x36, 0x27, 0x26, 0x36, 0x35, 0x34, 0x36, + 0x35, 0x34, 0x26, 0x37, 0x16, 0x3A, 0x01, 0x16, 0x33, 0x3A, 0x01, 0x33, + 0x16, 0x32, 0x33, 0x36, 0x16, 0x35, 0x3C, 0x01, 0x35, 0x01, 0x0E, 0x01, + 0x23, 0x22, 0x06, 0x07, 0x22, 0x26, 0x27, 0x26, 0x36, 0x37, 0x36, 0x16, + 0x33, 0x32, 0x36, 0x07, 0x25, 0x26, 0x36, 0x37, 0x1C, 0x01, 0x17, 0x06, + 0x26, 0x17, 0x36, 0x26, 0x35, 0x3C, 0x01, 0x35, 0x26, 0x16, 0x33, 0x0E, + 0x01, 0x0C, 0x0F, 0x08, 0x0D, 0x23, 0x6E, 0x23, 0x3C, 0x79, 0x79, 0x79, + 0x3C, 0x43, 0x86, 0x86, 0x86, 0x43, 0x0F, 0x1E, 0x0F, 0x0A, 0x02, 0x07, + 0x10, 0x12, 0x31, 0x13, 0x0D, 0x33, 0x09, 0x07, 0x17, 0x0A, 0x0E, 0x20, + 0x0E, 0x38, 0x70, 0x39, 0x04, 0x02, 0x04, 0x02, 0x06, 0x3E, 0x0A, 0x0D, + 0x04, 0x0D, 0x18, 0x0D, 0x21, 0x42, 0x20, 0x08, 0x01, 0x02, 0x03, 0x07, + 0x37, 0x0D, 0x10, 0x0D, 0x05, 0x06, 0x40, 0x0D, 0x09, 0x0C, 0x01, 0x03, + 0x04, 0x06, 0x2C, 0x10, 0x14, 0x30, 0x17, 0x0D, 0x1C, 0x0E, 0x02, 0x01, + 0x01, 0x02, 0x0E, 0x03, 0x12, 0x23, 0x11, 0x0B, 0x1C, 0x0D, 0x0E, 0x21, + 0x10, 0x0F, 0x1F, 0x0F, 0x0D, 0x1B, 0x0F, 0x0B, 0x3F, 0x06, 0x03, 0x0A, + 0x01, 0x01, 0x04, 0x02, 0x12, 0x0C, 0x1E, 0x3D, 0x1E, 0x25, 0x4A, 0x25, + 0x0D, 0x29, 0x0B, 0x0A, 0x04, 0x01, 0x01, 0x03, 0x02, 0x03, 0x09, 0x01, + 0x0D, 0x20, 0x0D, 0x04, 0x06, 0x04, 0x06, 0x0D, 0x06, 0x13, 0x27, 0x13, + 0x05, 0x12, 0x03, 0x05, 0x03, 0x0F, 0x11, 0x1A, 0x33, 0x1A, 0x05, 0x6A, + 0x08, 0x01, 0x05, 0x0D, 0x07, 0x07, 0x07, 0x3C, 0x79, 0x3C, 0x08, 0x0F, + 0x07, 0x07, 0x04, 0x09, 0x05, 0x29, 0x02, 0x05, 0x19, 0x06, 0x06, 0x05, + 0x07, 0x08, 0x07, 0x04, 0x0B, 0x0A, 0x16, 0x0B, 0x04, 0x0C, 0x02, 0x01, + 0x0C, 0x0C, 0x03, 0x05, 0x0A, 0x03, 0x03, 0x0C, 0x02, 0x03, 0x0F, 0x04, + 0x09, 0x3A, 0x13, 0x09, 0x20, 0x0A, 0x05, 0x17, 0x01, 0x04, 0x07, 0x02, + 0x01, 0x04, 0x06, 0x05, 0x07, 0x04, 0x03, 0x0B, 0x02, 0x06, 0x03, 0x36, + 0x6B, 0x6C, 0x6B, 0x35, 0x05, 0x11, 0x03, 0x07, 0x0F, 0x05, 0x05, 0x12, + 0x07, 0x07, 0x0A, 0x0A, 0x3E, 0x7C, 0x7C, 0x7B, 0x3E, 0x32, 0x63, 0x31, + 0x0A, 0x01, 0x01, 0x09, 0x0C, 0x03, 0x04, 0x12, 0x06, 0x01, 0x0C, 0x13, + 0x01, 0x14, 0x04, 0x06, 0x01, 0x0D, 0x10, 0x27, 0x11, 0x07, 0x22, 0x02, + 0x0E, 0x06, 0x05, 0x04, 0x2C, 0x08, 0x09, 0x07, 0x05, 0x04, 0x0B, 0x08, + 0x06, 0x0C, 0x05, 0x05, 0x07, 0x04, 0x05, 0x11, 0x0D, 0x01, 0x02, 0x03, + 0x02, 0x04, 0x01, 0x04, 0x02, 0x01, 0x06, 0x03, 0x02, 0x01, 0x36, 0x6C, + 0x6B, 0x6C, 0x36, 0x3E, 0x7C, 0x3E, 0x0B, 0x16, 0x0B, 0x16, 0x0C, 0xF5, + 0xAF, 0x02, 0x1B, 0x05, 0x06, 0x07, 0x05, 0x03, 0x1B, 0x03, 0x02, 0x03, + 0x01, 0x07, 0x2B, 0x0A, 0x09, 0x10, 0x02, 0x02, 0x06, 0x01, 0x0C, 0x05, + 0x0B, 0x0A, 0x11, 0x44, 0x01, 0x09, 0x03, 0x3D, 0x0A, 0x05, 0x21, 0x02, + 0x68, 0x07, 0x01, 0x04, 0x0B, 0x13, 0x27, 0x13, 0x0A, 0x13, 0x09, 0x0A, + 0x0C, 0x05, 0x06, 0x06, 0x05, 0x0A, 0x07, 0x0A, 0x05, 0x07, 0x09, 0x0F, + 0x1D, 0x0E, 0x06, 0x11, 0x05, 0x0A, 0x05, 0x27, 0x0B, 0x07, 0x0F, 0x08, + 0x04, 0x07, 0x11, 0x07, 0x06, 0x13, 0x05, 0x0B, 0x05, 0x2F, 0x08, 0x0C, + 0x0A, 0x04, 0x03, 0x0B, 0x0B, 0x0C, 0x2C, 0x0C, 0x10, 0x05, 0x01, 0x01, + 0x01, 0x05, 0x02, 0x01, 0x01, 0x03, 0x07, 0x05, 0x14, 0x09, 0x09, 0x10, + 0x07, 0x07, 0x0D, 0x05, 0x05, 0x05, 0x08, 0x08, 0x04, 0x0A, 0x04, 0x03, + 0x0A, 0x05, 0x08, 0x15, 0x07, 0x0E, 0x08, 0x04, 0x05, 0x04, 0x14, 0x0A, + 0x04, 0x0B, 0x05, 0x05, 0x07, 0x05, 0x01, 0x05, 0x01, 0x01, 0x04, 0x04, + 0x07, 0x20, 0x09, 0x0B, 0x17, 0x0B, 0x28, 0x4E, 0x28, 0x13, 0x28, 0x14, + 0x12, 0x0B, 0x01, 0x01, 0x01, 0x13, 0x03, 0x17, 0x0A, 0x0B, 0x09, 0x06, + 0x0B, 0x06, 0x0C, 0x04, 0x02, 0x03, 0x1A, 0x32, 0x1A, 0x03, 0x06, 0x03, + 0x03, 0x09, 0x02, 0x02, 0x04, 0x0A, 0x18, 0x06, 0x08, 0x12, 0x06, 0x04, + 0x02, 0x01, 0x03, 0x02, 0x01, 0x23, 0x07, 0x06, 0x0C, 0x07, 0x03, 0x14, + 0x02, 0x02, 0x14, 0x05, 0x06, 0x0C, 0x06, 0x07, 0x14, 0x08, 0x0B, 0x15, + 0x0B, 0x14, 0x11, 0x07, 0x04, 0x09, 0x01, 0x01, 0x09, 0x04, 0x0D, 0x20, + 0x0D, 0x0E, 0x0E, 0x0E, 0x0A, 0x10, 0x09, 0x06, 0x0F, 0x07, 0x01, 0x01, + 0x01, 0x20, 0x04, 0x0A, 0x14, 0x0A, 0x0A, 0x15, 0x09, 0x08, 0x0D, 0x01, + 0x0D, 0x08, 0x08, 0x17, 0x04, 0x11, 0x28, 0x0F, 0x0B, 0x0F, 0x12, 0x0A, + 0x05, 0x09, 0x04, 0x03, 0x02, 0x03, 0x05, 0x13, 0x08, 0x0C, 0x0C, 0x02, + 0x02, 0x04, 0x01, 0x0A, 0x3D, 0x0C, 0x3A, 0x0A, 0x09, 0x04, 0x02, 0x06, + 0x05, 0x19, 0x04, 0x0B, 0x0D, 0x07, 0x07, 0x11, 0x09, 0x0B, 0x34, 0x02, + 0x04, 0x11, 0x05, 0x04, 0x07, 0x03, 0x07, 0x0E, 0x0A, 0x0A, 0x14, 0x0B, + 0x06, 0x13, 0x05, 0x04, 0x13, 0x07, 0x14, 0x24, 0x15, 0x11, 0x22, 0x11, + 0x01, 0x01, 0x01, 0x01, 0x02, 0x08, 0x09, 0x28, 0x09, 0xFE, 0xFD, 0x07, + 0x0E, 0x07, 0x02, 0x01, 0x04, 0x03, 0x1B, 0x02, 0x07, 0x04, 0x01, 0x0B, + 0x2F, 0x09, 0x0A, 0x04, 0x0B, 0x17, 0x06, 0x04, 0x0B, 0x07, 0x07, 0x03, + 0x06, 0x05, 0x08, 0x05, 0x0F, 0x04, 0x16, 0x15, 0x00, 0x05, 0x00, 0x62, + 0x00, 0xA4, 0x0A, 0x6A, 0x02, 0xDA, 0x01, 0x0B, 0x01, 0x1E, 0x01, 0x4A, + 0x01, 0x50, 0x01, 0x56, 0x00, 0x00, 0x01, 0x32, 0x36, 0x37, 0x3E, 0x01, + 0x35, 0x31, 0x35, 0x34, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, + 0x2E, 0x01, 0x23, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, + 0x26, 0x06, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x03, 0x23, 0x2A, 0x01, 0x23, + 0x22, 0x26, 0x07, 0x06, 0x26, 0x27, 0x26, 0x06, 0x27, 0x26, 0x36, 0x27, + 0x2A, 0x01, 0x15, 0x16, 0x06, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x23, + 0x2A, 0x01, 0x23, 0x22, 0x06, 0x15, 0x14, 0x16, 0x15, 0x26, 0x36, 0x27, + 0x26, 0x22, 0x07, 0x22, 0x26, 0x27, 0x2E, 0x01, 0x23, 0x22, 0x26, 0x23, + 0x26, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x22, 0x06, 0x27, 0x2E, 0x01, 0x37, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x15, 0x1E, 0x01, 0x17, + 0x14, 0x16, 0x15, 0x14, 0x06, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x0E, 0x01, 0x15, 0x32, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x15, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x37, 0x36, 0x26, 0x27, 0x26, 0x36, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3A, 0x01, 0x37, 0x3E, 0x01, 0x33, + 0x32, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x16, 0x36, 0x17, + 0x16, 0x32, 0x37, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x33, 0x36, 0x16, 0x33, + 0x32, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x33, 0x3A, 0x03, 0x33, + 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x37, 0x36, 0x26, 0x27, + 0x26, 0x06, 0x27, 0x26, 0x16, 0x37, 0x05, 0x06, 0x26, 0x27, 0x26, 0x22, + 0x27, 0x2E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x3A, 0x01, 0x17, 0x16, 0x06, + 0x07, 0x25, 0x22, 0x26, 0x07, 0x0E, 0x01, 0x27, 0x22, 0x26, 0x23, 0x06, + 0x26, 0x37, 0x36, 0x16, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, + 0x01, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x17, 0x1E, + 0x01, 0x17, 0x16, 0x36, 0x33, 0x1E, 0x01, 0x17, 0x15, 0x25, 0x32, 0x16, + 0x33, 0x06, 0x27, 0x23, 0x2A, 0x01, 0x23, 0x36, 0x16, 0x0A, 0x35, 0x0A, + 0x13, 0x09, 0x0D, 0x02, 0x03, 0x08, 0x09, 0x0C, 0x06, 0x0C, 0x1E, 0x10, + 0x06, 0x0D, 0x07, 0x09, 0x03, 0x02, 0x02, 0x08, 0x07, 0x06, 0x0D, 0x08, + 0x36, 0x6D, 0x35, 0x38, 0x70, 0x37, 0x2D, 0x5A, 0x5A, 0x5A, 0x2D, 0x2D, + 0x59, 0x2D, 0x2A, 0x54, 0x2A, 0x10, 0x06, 0x03, 0x02, 0x24, 0x09, 0x03, + 0x06, 0x06, 0x03, 0x0E, 0x01, 0x02, 0x08, 0x0A, 0x13, 0x09, 0x2C, 0x58, + 0x2C, 0x17, 0x2D, 0x16, 0x06, 0x04, 0x01, 0x0A, 0x03, 0x06, 0x06, 0x16, + 0x08, 0x0B, 0x19, 0x0A, 0x02, 0x02, 0x02, 0x03, 0x05, 0x03, 0x09, 0x10, + 0x05, 0x05, 0x11, 0x07, 0x02, 0x02, 0x0B, 0x05, 0x0C, 0x01, 0x2C, 0x58, + 0x2D, 0x2B, 0x58, 0x2C, 0x16, 0x2D, 0x17, 0x08, 0x0D, 0x06, 0x06, 0x0C, + 0x07, 0x15, 0x2A, 0x15, 0x09, 0x27, 0x01, 0x01, 0x01, 0x01, 0x03, 0x09, + 0x11, 0x1E, 0x0F, 0x0F, 0x26, 0x0B, 0x06, 0x08, 0x03, 0x04, 0x09, 0x05, + 0x09, 0x15, 0x10, 0x2A, 0x53, 0x2A, 0x02, 0x01, 0x0A, 0x15, 0x0A, 0x06, + 0x1B, 0x03, 0x08, 0x08, 0x06, 0x0B, 0x17, 0x0B, 0x08, 0x18, 0x01, 0x1E, + 0x0B, 0x10, 0x20, 0x11, 0x14, 0x29, 0x15, 0x13, 0x17, 0x04, 0x08, 0x0C, + 0x08, 0x09, 0x12, 0x09, 0x05, 0x0D, 0x0E, 0x10, 0x23, 0x0F, 0x0B, 0x16, + 0x0B, 0x08, 0x11, 0x08, 0x0E, 0x16, 0x08, 0x0A, 0x11, 0x10, 0x0F, 0x1E, + 0x0F, 0x0B, 0x18, 0x0B, 0x08, 0x11, 0x08, 0x0F, 0x17, 0x0F, 0x14, 0x2C, + 0x15, 0x11, 0x25, 0x11, 0x13, 0x2C, 0x14, 0x15, 0x2A, 0x15, 0x2D, 0x5A, + 0x2C, 0x2D, 0x58, 0x2D, 0x16, 0x2C, 0x17, 0x09, 0x14, 0x09, 0x09, 0x10, + 0x0A, 0x2C, 0x59, 0x59, 0x59, 0x2D, 0x2D, 0x59, 0x2D, 0x18, 0x2E, 0x18, + 0x0C, 0x11, 0x02, 0x02, 0x0B, 0x0E, 0x0B, 0x21, 0x06, 0x03, 0x1B, 0x04, + 0xF9, 0x2F, 0x0A, 0x2C, 0x0D, 0x0A, 0x15, 0x08, 0x06, 0x03, 0x02, 0x05, + 0x34, 0x12, 0x09, 0x16, 0x06, 0x08, 0x04, 0x03, 0x06, 0x7A, 0x4F, 0x9A, + 0x4F, 0x27, 0x4F, 0x27, 0x10, 0x20, 0x10, 0x0A, 0x0D, 0x0A, 0x04, 0x14, + 0x06, 0x08, 0x12, 0x08, 0x14, 0x27, 0x14, 0x27, 0x4F, 0x28, 0x26, 0x4E, + 0x26, 0x0A, 0x14, 0x0A, 0x03, 0x0A, 0x01, 0x01, 0x01, 0x01, 0x05, 0x0D, + 0x05, 0x04, 0x04, 0x03, 0xF9, 0x6A, 0x01, 0x02, 0x01, 0x03, 0x01, 0x42, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x4D, 0x03, 0x02, 0x04, 0x02, 0x0B, + 0x1D, 0x08, 0x09, 0x02, 0x03, 0x06, 0x08, 0x0D, 0x15, 0x09, 0x03, 0x07, + 0x0F, 0x06, 0x0A, 0x14, 0x08, 0x07, 0x01, 0x01, 0x04, 0x03, 0x02, 0x03, + 0x01, 0x0E, 0x0D, 0x0F, 0x0D, 0x06, 0x03, 0x0F, 0x01, 0x05, 0x09, 0x05, + 0x01, 0x06, 0x05, 0x0B, 0x05, 0x05, 0x10, 0x09, 0x08, 0x01, 0x01, 0x07, + 0x01, 0x0B, 0x03, 0x01, 0x03, 0x07, 0x07, 0x1E, 0x01, 0x19, 0x05, 0x02, + 0x11, 0x06, 0x04, 0x08, 0x04, 0x04, 0x08, 0x04, 0x02, 0x04, 0x02, 0x01, + 0x02, 0x06, 0x05, 0x06, 0x01, 0x04, 0x05, 0x03, 0x01, 0x02, 0x0C, 0x2C, + 0x56, 0x2C, 0x17, 0x2F, 0x17, 0x0A, 0x36, 0x04, 0x06, 0x0E, 0x07, 0x06, + 0x0F, 0x0C, 0x07, 0x14, 0x08, 0x0A, 0x12, 0x09, 0x0E, 0x10, 0x04, 0x09, + 0x15, 0x08, 0x04, 0x09, 0x05, 0x01, 0x02, 0x01, 0x02, 0x06, 0x0F, 0x1D, + 0x0D, 0x15, 0x2A, 0x14, 0x0E, 0x22, 0x10, 0x0F, 0x0D, 0x03, 0x05, 0x06, + 0x04, 0x04, 0x08, 0x05, 0x05, 0x17, 0x08, 0x13, 0x1E, 0x10, 0x13, 0x25, + 0x13, 0x0B, 0x27, 0x04, 0x04, 0x01, 0x01, 0x01, 0x01, 0x05, 0x15, 0x0A, + 0x0B, 0x14, 0x03, 0x03, 0x02, 0x01, 0x02, 0x05, 0x03, 0x02, 0x08, 0x01, + 0x01, 0x14, 0x03, 0x03, 0x04, 0x02, 0x02, 0x04, 0x06, 0x06, 0x01, 0x01, + 0x01, 0x01, 0x04, 0x03, 0x01, 0x01, 0x03, 0x03, 0x05, 0x16, 0x0B, 0x0E, + 0x1F, 0x05, 0x04, 0x09, 0x0D, 0x08, 0x02, 0x01, 0x91, 0x0D, 0x03, 0x01, + 0x01, 0x08, 0x05, 0x10, 0x08, 0x18, 0x01, 0x01, 0x08, 0x0A, 0x16, 0x0B, + 0x81, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x0B, 0x05, 0x02, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x04, 0x04, 0x06, 0x8C, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x5E, + 0x00, 0xBB, 0x09, 0xE8, 0x02, 0xC6, 0x00, 0xAC, 0x00, 0xC5, 0x00, 0x00, + 0x01, 0x3C, 0x01, 0x35, 0x2A, 0x01, 0x26, 0x22, 0x23, 0x2A, 0x03, 0x23, + 0x2A, 0x01, 0x23, 0x22, 0x26, 0x07, 0x26, 0x06, 0x23, 0x22, 0x26, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x27, + 0x2E, 0x01, 0x23, 0x22, 0x26, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x16, 0x15, + 0x14, 0x06, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x37, + 0x3E, 0x01, 0x37, 0x1C, 0x01, 0x15, 0x30, 0x33, 0x32, 0x35, 0x36, 0x16, + 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, + 0x17, 0x16, 0x06, 0x33, 0x3A, 0x01, 0x17, 0x26, 0x36, 0x33, 0x32, 0x26, + 0x37, 0x3E, 0x01, 0x15, 0x14, 0x36, 0x33, 0x32, 0x36, 0x17, 0x1E, 0x01, + 0x17, 0x16, 0x06, 0x33, 0x16, 0x32, 0x33, 0x36, 0x16, 0x33, 0x3A, 0x03, + 0x33, 0x32, 0x16, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x32, 0x17, 0x3C, 0x01, + 0x35, 0x3C, 0x01, 0x35, 0x26, 0x06, 0x23, 0x22, 0x36, 0x37, 0x32, 0x16, + 0x33, 0x05, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x37, 0x14, + 0x16, 0x33, 0x22, 0x36, 0x37, 0x36, 0x16, 0x33, 0x32, 0x16, 0x17, 0x16, + 0x06, 0x07, 0x09, 0xE8, 0x62, 0xC9, 0xCA, 0xCA, 0x62, 0x3A, 0x72, 0x73, + 0x72, 0x3A, 0x20, 0x42, 0x21, 0x09, 0x22, 0x06, 0x08, 0x84, 0x14, 0x3F, + 0x86, 0x3D, 0x14, 0x2A, 0x10, 0x0F, 0x1F, 0x0E, 0x0E, 0x1A, 0x0E, 0x0B, + 0x18, 0x0E, 0x0B, 0x18, 0x0A, 0x0F, 0x23, 0x10, 0x15, 0x2D, 0x16, 0x1C, + 0x24, 0x14, 0x07, 0x01, 0x09, 0x04, 0x22, 0x02, 0x07, 0x16, 0x11, 0x2C, + 0x17, 0x20, 0x15, 0x08, 0x04, 0x11, 0x07, 0x20, 0x5B, 0x35, 0x01, 0x01, + 0x27, 0x1E, 0x10, 0x0A, 0x14, 0x0E, 0x2D, 0x6A, 0x2A, 0x1D, 0x44, 0x25, + 0x0E, 0x1F, 0x10, 0x06, 0x1D, 0x0B, 0x0A, 0x18, 0x0B, 0x1D, 0x3A, 0x1D, + 0x12, 0x2B, 0x12, 0x02, 0x04, 0x06, 0x0B, 0x15, 0x0B, 0x01, 0x01, 0x05, + 0x11, 0x07, 0x05, 0x02, 0x45, 0x61, 0x0F, 0x32, 0x72, 0x31, 0x0A, 0x13, + 0x0A, 0x05, 0x03, 0x04, 0x0B, 0x17, 0x0B, 0x02, 0x9F, 0x10, 0x29, 0x52, + 0x51, 0x52, 0x29, 0x1F, 0x4B, 0x15, 0x06, 0x09, 0x06, 0x0D, 0x1B, 0x15, + 0x15, 0x1F, 0x09, 0x08, 0x04, 0x04, 0x0F, 0x1E, 0x10, 0xF9, 0x16, 0x0A, + 0x26, 0x0E, 0x15, 0x31, 0x11, 0x11, 0x0C, 0x17, 0x01, 0x16, 0x04, 0x16, + 0x03, 0x0B, 0x1D, 0x0D, 0x15, 0x22, 0x08, 0x04, 0x03, 0x06, 0x02, 0x46, + 0x16, 0x36, 0x12, 0x01, 0x06, 0x03, 0x1E, 0x0C, 0x08, 0x09, 0x09, 0x0B, + 0x09, 0x07, 0x0D, 0x07, 0x07, 0x10, 0x07, 0x05, 0x16, 0x02, 0x03, 0x13, + 0x05, 0x08, 0x0D, 0x06, 0x07, 0x0F, 0x02, 0x04, 0x11, 0x0A, 0x03, 0x07, + 0x01, 0x03, 0x07, 0x0C, 0x07, 0x18, 0x31, 0x19, 0x22, 0x4E, 0x18, 0x14, + 0x2F, 0x09, 0x0C, 0x10, 0x15, 0x0A, 0x1B, 0x0A, 0x2F, 0x51, 0x18, 0x02, + 0x04, 0x02, 0x01, 0x0E, 0x2E, 0x18, 0x0E, 0x16, 0x08, 0x17, 0x12, 0x1D, + 0x15, 0x21, 0x0A, 0x04, 0x07, 0x01, 0x01, 0x17, 0x06, 0x05, 0x01, 0x04, + 0x04, 0x01, 0x0A, 0x01, 0x05, 0x07, 0x07, 0x02, 0x01, 0x08, 0x06, 0x1B, + 0x06, 0x09, 0x09, 0x02, 0x0B, 0x03, 0x01, 0x09, 0x01, 0x0D, 0x06, 0x03, + 0x0F, 0x03, 0x13, 0x05, 0x0C, 0x01, 0x0F, 0x1F, 0x0F, 0x07, 0x15, 0x07, + 0x01, 0x01, 0x07, 0x09, 0x01, 0xDC, 0x0E, 0x12, 0x04, 0x07, 0x08, 0x0B, + 0x0B, 0x2E, 0x10, 0x13, 0x31, 0x46, 0x06, 0x04, 0x02, 0x03, 0x14, 0x0A, + 0x13, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x63, 0x00, 0x72, 0x07, 0x72, + 0x03, 0x0D, 0x00, 0xFE, 0x01, 0x10, 0x01, 0x24, 0x00, 0x00, 0x01, 0x34, + 0x36, 0x37, 0x3E, 0x01, 0x37, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, + 0x01, 0x07, 0x36, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x34, 0x37, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x34, 0x37, 0x36, 0x34, 0x37, 0x3E, + 0x01, 0x33, 0x35, 0x3A, 0x01, 0x33, 0x32, 0x16, 0x37, 0x32, 0x36, 0x33, + 0x32, 0x16, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x03, 0x33, 0x3A, 0x01, 0x33, + 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x16, 0x17, 0x16, 0x32, 0x33, + 0x14, 0x06, 0x17, 0x23, 0x15, 0x32, 0x16, 0x17, 0x36, 0x32, 0x17, 0x35, + 0x16, 0x06, 0x15, 0x3A, 0x01, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x17, + 0x1E, 0x01, 0x15, 0x14, 0x16, 0x07, 0x14, 0x06, 0x23, 0x2A, 0x01, 0x23, + 0x2A, 0x01, 0x23, 0x1C, 0x01, 0x15, 0x23, 0x06, 0x26, 0x23, 0x2A, 0x01, + 0x23, 0x22, 0x06, 0x07, 0x16, 0x06, 0x23, 0x15, 0x23, 0x1C, 0x01, 0x15, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x22, 0x23, 0x22, 0x26, + 0x27, 0x22, 0x06, 0x23, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x35, 0x34, 0x26, + 0x35, 0x34, 0x26, 0x27, 0x2A, 0x01, 0x23, 0x22, 0x06, 0x23, 0x22, 0x06, + 0x23, 0x14, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x34, 0x06, 0x23, 0x06, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x26, + 0x37, 0x23, 0x14, 0x06, 0x15, 0x14, 0x06, 0x07, 0x0E, 0x03, 0x07, 0x0E, + 0x01, 0x23, 0x06, 0x16, 0x07, 0x06, 0x22, 0x23, 0x2A, 0x01, 0x23, 0x22, + 0x06, 0x27, 0x2E, 0x01, 0x35, 0x34, 0x36, 0x3F, 0x01, 0x25, 0x35, 0x07, + 0x1C, 0x01, 0x17, 0x1E, 0x01, 0x33, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x37, + 0x34, 0x26, 0x27, 0x07, 0x35, 0x0E, 0x01, 0x07, 0x23, 0x14, 0x06, 0x15, + 0x23, 0x14, 0x06, 0x15, 0x0E, 0x01, 0x15, 0x33, 0x34, 0x26, 0x37, 0x01, + 0xA3, 0x1A, 0x02, 0x05, 0x0D, 0x07, 0x06, 0x1D, 0x08, 0x0B, 0x16, 0x0C, + 0x15, 0x2D, 0x14, 0x10, 0x27, 0x10, 0x08, 0x11, 0x08, 0x09, 0x0F, 0x09, + 0x06, 0x10, 0x09, 0x02, 0x11, 0x03, 0x04, 0x07, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x09, 0x04, 0x04, 0x03, 0x02, 0x01, 0x02, 0x08, 0x08, + 0x4C, 0x97, 0x4C, 0x1B, 0x36, 0x1B, 0x07, 0x10, 0x06, 0x03, 0x05, 0x02, + 0x06, 0x0A, 0x05, 0x57, 0xAE, 0xAD, 0xAE, 0x57, 0x31, 0x63, 0x32, 0x0B, + 0x17, 0x0C, 0x02, 0x05, 0x02, 0x03, 0x06, 0x02, 0x02, 0x06, 0x05, 0x01, + 0x01, 0x04, 0x02, 0x04, 0x02, 0x03, 0x0E, 0x04, 0x09, 0x01, 0x23, 0x47, + 0x23, 0x17, 0x2F, 0x17, 0x06, 0x1E, 0x05, 0x06, 0x02, 0x01, 0x01, 0x04, + 0x08, 0x14, 0x29, 0x15, 0x0B, 0x18, 0x0B, 0x01, 0x04, 0x30, 0x09, 0x0F, + 0x1E, 0x0E, 0x06, 0x0A, 0x05, 0x06, 0x10, 0x05, 0x25, 0x0A, 0x03, 0x08, + 0x05, 0x05, 0x11, 0x04, 0x06, 0x33, 0x0C, 0x0C, 0x1D, 0x08, 0x21, 0x42, + 0x20, 0x05, 0x09, 0x03, 0x02, 0x02, 0x01, 0x01, 0x08, 0x02, 0x06, 0x0C, + 0x04, 0x08, 0x0C, 0x11, 0x0C, 0x33, 0x04, 0x01, 0x01, 0x18, 0x31, 0x18, + 0x0D, 0x1B, 0x0D, 0x05, 0x0B, 0x05, 0x0A, 0x02, 0x03, 0x08, 0x05, 0x05, + 0x08, 0x05, 0x03, 0x06, 0x02, 0x08, 0x01, 0x11, 0x33, 0x15, 0x0F, 0x20, + 0x0F, 0x05, 0x0D, 0x04, 0x05, 0x06, 0x05, 0x01, 0x01, 0x23, 0x2A, 0x23, + 0x01, 0x04, 0x01, 0x04, 0x05, 0x04, 0x03, 0x05, 0x0D, 0x06, 0x24, 0x49, + 0x24, 0x0D, 0x2B, 0x0B, 0x03, 0x0B, 0x26, 0x05, 0x3F, 0x01, 0xC8, 0x61, + 0x03, 0x07, 0x10, 0x0F, 0x09, 0x1A, 0x05, 0x02, 0x0C, 0x04, 0x01, 0x01, + 0x83, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x04, 0x18, 0x09, + 0x01, 0x01, 0x73, 0x02, 0x32, 0x03, 0x0B, 0x15, 0x0B, 0x05, 0x03, 0x01, + 0x01, 0x05, 0x01, 0x04, 0x08, 0x07, 0x06, 0x08, 0x0A, 0x06, 0x07, 0x04, + 0x05, 0x0E, 0x05, 0x04, 0x10, 0x02, 0x07, 0x0B, 0x05, 0x05, 0x0C, 0x06, + 0x05, 0x0E, 0x05, 0x06, 0x0D, 0x06, 0x08, 0x09, 0x06, 0x07, 0x0D, 0x05, + 0x05, 0x0F, 0x05, 0x06, 0x10, 0x01, 0x01, 0x01, 0x03, 0x03, 0x04, 0x03, + 0x04, 0x0B, 0x14, 0x0B, 0x02, 0x01, 0x01, 0x03, 0x02, 0x01, 0x01, 0x13, + 0x06, 0x03, 0x05, 0x07, 0x09, 0x09, 0x07, 0x0D, 0x06, 0x06, 0x0E, 0x03, + 0x06, 0x03, 0x0A, 0x03, 0x01, 0x03, 0x08, 0x04, 0x03, 0x05, 0x0B, 0x05, + 0x01, 0x09, 0x10, 0x09, 0x08, 0x0D, 0x07, 0x0D, 0x09, 0x0A, 0x03, 0x06, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x05, 0x0C, 0x08, 0x0D, 0x1B, + 0x04, 0x04, 0x09, 0x13, 0x06, 0x0B, 0x06, 0x06, 0x0C, 0x05, 0x01, 0x02, + 0x07, 0x05, 0x05, 0x05, 0x0A, 0x04, 0x05, 0x0A, 0x05, 0x03, 0x03, 0x04, + 0x01, 0x08, 0x09, 0x04, 0x03, 0x07, 0x04, 0x08, 0x05, 0x03, 0x0B, 0x03, + 0x03, 0x47, 0x55, 0x47, 0x01, 0x09, 0x07, 0x01, 0x09, 0x04, 0x04, 0x03, + 0x09, 0x03, 0x0B, 0x05, 0x07, 0x58, 0x0A, 0x7C, 0x83, 0x01, 0x01, 0x06, + 0x0F, 0x06, 0x0C, 0x04, 0x02, 0x0A, 0x04, 0x15, 0x01, 0x01, 0x03, 0x01, + 0x12, 0x02, 0x01, 0x04, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x08, 0x04, 0x06, 0x0B, 0x08, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x60, + 0x00, 0xA5, 0x0A, 0xDB, 0x02, 0xDA, 0x01, 0x2A, 0x01, 0x3D, 0x00, 0x00, + 0x01, 0x26, 0x36, 0x27, 0x26, 0x06, 0x23, 0x22, 0x34, 0x27, 0x26, 0x06, + 0x07, 0x0E, 0x01, 0x15, 0x2E, 0x01, 0x23, 0x14, 0x16, 0x17, 0x2A, 0x03, + 0x23, 0x2A, 0x01, 0x23, 0x22, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x26, 0x06, + 0x27, 0x2E, 0x01, 0x23, 0x26, 0x06, 0x27, 0x26, 0x06, 0x07, 0x06, 0x22, + 0x23, 0x22, 0x26, 0x23, 0x22, 0x06, 0x37, 0x30, 0x27, 0x22, 0x17, 0x2E, + 0x01, 0x07, 0x22, 0x06, 0x37, 0x36, 0x22, 0x23, 0x26, 0x36, 0x07, 0x22, + 0x26, 0x17, 0x26, 0x22, 0x23, 0x14, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x23, 0x06, 0x26, 0x27, 0x26, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x23, 0x22, 0x06, 0x27, 0x2A, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x06, 0x22, 0x23, 0x22, 0x26, 0x23, 0x06, 0x26, 0x23, 0x22, + 0x06, 0x07, 0x06, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, + 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x37, 0x3E, 0x01, 0x37, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x16, + 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x26, 0x37, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, + 0x16, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x32, + 0x36, 0x27, 0x16, 0x32, 0x33, 0x32, 0x36, 0x37, 0x3A, 0x01, 0x37, 0x32, + 0x36, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x37, 0x3E, + 0x03, 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, + 0x16, 0x27, 0x34, 0x36, 0x27, 0x26, 0x36, 0x37, 0x36, 0x16, 0x33, 0x3E, + 0x01, 0x33, 0x16, 0x32, 0x33, 0x2E, 0x01, 0x27, 0x32, 0x36, 0x35, 0x34, + 0x26, 0x27, 0x17, 0x15, 0x26, 0x1F, 0x01, 0x05, 0x26, 0x16, 0x33, 0x3A, + 0x01, 0x17, 0x1E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x37, 0x26, + 0x1F, 0x01, 0x0A, 0xD4, 0x05, 0x0C, 0x11, 0x0A, 0x16, 0x0A, 0x07, 0x03, + 0x06, 0x1C, 0x0A, 0x0E, 0x0B, 0x0A, 0x14, 0x0A, 0x01, 0x01, 0x55, 0xAA, + 0xAA, 0xAA, 0x55, 0x2A, 0x53, 0x29, 0x15, 0x29, 0x15, 0x0B, 0x17, 0x0B, + 0x07, 0x0F, 0x07, 0x05, 0x07, 0x05, 0x05, 0x11, 0x04, 0x0B, 0x20, 0x0F, + 0x14, 0x28, 0x13, 0x0B, 0x16, 0x0B, 0x01, 0x0F, 0x02, 0x07, 0x07, 0x05, + 0x17, 0x30, 0x17, 0x07, 0x4F, 0x01, 0x02, 0x10, 0x03, 0x07, 0x02, 0x0A, + 0x08, 0x21, 0x04, 0x03, 0x04, 0x03, 0x1B, 0x0B, 0x10, 0x20, 0x11, 0x08, + 0x10, 0x08, 0x0A, 0x12, 0x09, 0x15, 0x2A, 0x14, 0x0A, 0x12, 0x0A, 0x09, + 0x11, 0x0A, 0x06, 0x14, 0x02, 0x04, 0x1E, 0x07, 0x2C, 0x5A, 0x2C, 0x14, + 0x28, 0x14, 0x16, 0x2D, 0x16, 0x13, 0x24, 0x12, 0x06, 0x0B, 0x05, 0x02, + 0x03, 0x01, 0x06, 0x0C, 0x06, 0x09, 0x12, 0x0A, 0x07, 0x0C, 0x07, 0x15, + 0x1F, 0x0A, 0x04, 0x05, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x02, 0x01, + 0x04, 0x02, 0x02, 0x01, 0x08, 0x09, 0x27, 0x10, 0x05, 0x13, 0x02, 0x02, + 0x18, 0x07, 0x13, 0x22, 0x12, 0x09, 0x13, 0x09, 0x0A, 0x13, 0x0B, 0x0F, + 0x1E, 0x0E, 0x05, 0x0C, 0x06, 0x08, 0x0C, 0x07, 0x08, 0x10, 0x07, 0x0A, + 0x15, 0x0A, 0x16, 0x2C, 0x17, 0x10, 0x1A, 0x06, 0x03, 0x01, 0x08, 0x0B, + 0x16, 0x09, 0x08, 0x11, 0x08, 0x09, 0x10, 0x07, 0x0D, 0x04, 0x05, 0x02, + 0x0A, 0x02, 0x02, 0x04, 0x04, 0x0C, 0x1B, 0x0F, 0x10, 0x22, 0x11, 0x14, + 0x0E, 0x0B, 0x14, 0x50, 0x1B, 0x0E, 0x19, 0x0E, 0x06, 0x0A, 0x06, 0x01, + 0x12, 0x01, 0x0E, 0x20, 0x0F, 0x18, 0x31, 0x19, 0x16, 0x2C, 0x16, 0x07, + 0x0F, 0x06, 0x08, 0x10, 0x0A, 0x0F, 0x21, 0x11, 0x17, 0x2F, 0x18, 0x2E, + 0x5C, 0x5C, 0x5C, 0x2F, 0x35, 0x6B, 0x36, 0x0C, 0x17, 0x0C, 0x0C, 0x1B, + 0x0B, 0x0A, 0x1F, 0x01, 0x01, 0x04, 0x04, 0x08, 0x07, 0x07, 0x0F, 0x07, + 0x0E, 0x1A, 0x0E, 0x38, 0x71, 0x38, 0x01, 0x01, 0x01, 0x03, 0x0A, 0x01, + 0x03, 0x01, 0x05, 0x03, 0x02, 0xF9, 0x5F, 0x03, 0x2F, 0x09, 0x05, 0x0F, + 0x02, 0x02, 0x01, 0x02, 0x05, 0x2F, 0x0A, 0x08, 0x0C, 0x06, 0x02, 0x01, + 0x01, 0x02, 0x8E, 0x0A, 0x15, 0x04, 0x03, 0x02, 0x11, 0x04, 0x0A, 0x02, + 0x01, 0x01, 0x0A, 0x0F, 0x01, 0x03, 0x02, 0x03, 0x01, 0x01, 0x01, 0x03, + 0x01, 0x01, 0x07, 0x01, 0x03, 0x03, 0x09, 0x03, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x02, 0x04, 0x01, 0x01, 0x03, 0x05, 0x07, 0x01, 0x0C, 0x01, + 0x01, 0x0C, 0x01, 0x0E, 0x10, 0x06, 0x08, 0x0E, 0x05, 0x03, 0x0A, 0x03, + 0x04, 0x07, 0x04, 0x09, 0x10, 0x09, 0x04, 0x04, 0x02, 0x03, 0x07, 0x01, + 0x04, 0x06, 0x08, 0x06, 0x01, 0x05, 0x06, 0x01, 0x01, 0x07, 0x01, 0x01, + 0x04, 0x03, 0x01, 0x02, 0x01, 0x04, 0x02, 0x02, 0x02, 0x01, 0x05, 0x0A, + 0x14, 0x09, 0x11, 0x0A, 0x09, 0x13, 0x0A, 0x17, 0x2E, 0x17, 0x16, 0x2B, + 0x16, 0x11, 0x2D, 0x10, 0x10, 0x06, 0x03, 0x01, 0x03, 0x06, 0x09, 0x05, + 0x03, 0x06, 0x11, 0x0A, 0x04, 0x07, 0x04, 0x04, 0x0B, 0x04, 0x06, 0x0F, + 0x09, 0x03, 0x08, 0x03, 0x04, 0x06, 0x02, 0x02, 0x09, 0x03, 0x04, 0x09, + 0x05, 0x09, 0x15, 0x08, 0x06, 0x19, 0x0D, 0x06, 0x09, 0x01, 0x02, 0x0C, + 0x05, 0x04, 0x02, 0x03, 0x02, 0x08, 0x05, 0x09, 0x23, 0x0D, 0x06, 0x09, + 0x06, 0x05, 0x06, 0x04, 0x0A, 0x0B, 0x04, 0x03, 0x05, 0x01, 0x01, 0x1D, + 0x0F, 0x1A, 0x05, 0x10, 0x09, 0x17, 0x09, 0x03, 0x0C, 0x03, 0x0A, 0x01, + 0x04, 0x02, 0x01, 0x01, 0x01, 0x06, 0x09, 0x10, 0x06, 0x09, 0x05, 0x01, + 0x02, 0x01, 0x03, 0x06, 0x0D, 0x0A, 0x07, 0x01, 0x01, 0x01, 0x05, 0x01, + 0x03, 0x02, 0x03, 0x03, 0x05, 0x0D, 0x05, 0x15, 0x09, 0x18, 0x08, 0x07, + 0x0D, 0x03, 0x02, 0x01, 0x01, 0x03, 0x01, 0x02, 0x04, 0x02, 0x01, 0x05, + 0x09, 0x10, 0x08, 0x01, 0x01, 0x0A, 0x05, 0x05, 0x9F, 0x0B, 0x02, 0x05, + 0x05, 0x13, 0x04, 0x0C, 0x03, 0x04, 0x03, 0x1D, 0x03, 0x08, 0x04, 0x04, + 0x00, 0x02, 0x00, 0x55, 0x00, 0x0C, 0x09, 0x06, 0x03, 0x7A, 0x01, 0xB8, + 0x01, 0xD1, 0x00, 0x00, 0x01, 0x1E, 0x01, 0x07, 0x16, 0x26, 0x23, 0x06, + 0x22, 0x07, 0x2A, 0x01, 0x07, 0x22, 0x06, 0x15, 0x14, 0x16, 0x17, 0x16, + 0x06, 0x15, 0x14, 0x16, 0x27, 0x14, 0x16, 0x07, 0x16, 0x06, 0x15, 0x1C, + 0x01, 0x15, 0x14, 0x16, 0x23, 0x22, 0x16, 0x15, 0x14, 0x16, 0x23, 0x22, + 0x06, 0x35, 0x34, 0x36, 0x35, 0x3C, 0x01, 0x35, 0x34, 0x26, 0x35, 0x34, + 0x26, 0x35, 0x3C, 0x01, 0x35, 0x34, 0x26, 0x37, 0x3E, 0x01, 0x35, 0x34, + 0x36, 0x07, 0x26, 0x34, 0x37, 0x2E, 0x01, 0x35, 0x34, 0x26, 0x15, 0x14, + 0x06, 0x07, 0x06, 0x26, 0x15, 0x14, 0x06, 0x07, 0x06, 0x26, 0x07, 0x0E, + 0x01, 0x27, 0x26, 0x36, 0x35, 0x34, 0x06, 0x23, 0x2A, 0x01, 0x23, 0x22, + 0x26, 0x15, 0x14, 0x06, 0x17, 0x16, 0x36, 0x17, 0x16, 0x06, 0x17, 0x16, + 0x36, 0x15, 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x1C, + 0x01, 0x15, 0x14, 0x06, 0x15, 0x14, 0x26, 0x23, 0x2A, 0x01, 0x23, 0x22, + 0x06, 0x27, 0x26, 0x06, 0x35, 0x3C, 0x01, 0x35, 0x3C, 0x01, 0x35, 0x34, + 0x36, 0x27, 0x26, 0x36, 0x37, 0x06, 0x22, 0x17, 0x1E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x30, 0x0F, 0x01, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x06, 0x16, 0x07, 0x06, 0x16, 0x23, 0x22, 0x06, 0x23, 0x06, + 0x26, 0x35, 0x34, 0x36, 0x37, 0x3E, 0x01, 0x35, 0x34, 0x36, 0x27, 0x2E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x06, 0x27, 0x2E, + 0x01, 0x35, 0x34, 0x06, 0x23, 0x22, 0x06, 0x27, 0x26, 0x36, 0x23, 0x22, + 0x06, 0x27, 0x26, 0x06, 0x23, 0x22, 0x16, 0x07, 0x0E, 0x01, 0x07, 0x06, + 0x22, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x2E, + 0x01, 0x35, 0x34, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x36, 0x17, 0x36, + 0x16, 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x33, 0x3A, 0x01, 0x33, 0x22, + 0x36, 0x15, 0x36, 0x34, 0x37, 0x36, 0x32, 0x37, 0x36, 0x26, 0x35, 0x34, + 0x36, 0x37, 0x3E, 0x01, 0x33, 0x32, 0x16, 0x17, 0x16, 0x32, 0x17, 0x1E, + 0x01, 0x17, 0x16, 0x36, 0x33, 0x32, 0x36, 0x17, 0x36, 0x16, 0x15, 0x32, + 0x16, 0x37, 0x3E, 0x01, 0x17, 0x3E, 0x01, 0x17, 0x36, 0x16, 0x17, 0x32, + 0x16, 0x33, 0x16, 0x36, 0x33, 0x32, 0x36, 0x33, 0x3A, 0x01, 0x33, 0x32, + 0x16, 0x33, 0x32, 0x36, 0x17, 0x36, 0x16, 0x33, 0x36, 0x32, 0x33, 0x32, + 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x27, 0x2E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x06, 0x27, 0x2E, 0x01, 0x27, 0x26, + 0x36, 0x37, 0x36, 0x16, 0x33, 0x32, 0x16, 0x17, 0x36, 0x16, 0x17, 0x1E, + 0x01, 0x17, 0x14, 0x36, 0x17, 0x16, 0x06, 0x15, 0x1C, 0x01, 0x15, 0x1C, + 0x01, 0x15, 0x14, 0x06, 0x23, 0x22, 0x06, 0x07, 0x06, 0x16, 0x33, 0x3A, + 0x01, 0x33, 0x32, 0x16, 0x37, 0x36, 0x26, 0x37, 0x36, 0x26, 0x37, 0x34, + 0x26, 0x37, 0x34, 0x36, 0x37, 0x3E, 0x01, 0x17, 0x1E, 0x01, 0x15, 0x14, + 0x36, 0x17, 0x1E, 0x01, 0x15, 0x14, 0x36, 0x33, 0x3A, 0x03, 0x33, 0x05, + 0x3E, 0x01, 0x37, 0x2A, 0x01, 0x23, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x17, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, + 0x08, 0xD9, 0x0B, 0x22, 0x15, 0x06, 0x5C, 0x12, 0x48, 0x90, 0x48, 0x39, + 0x74, 0x3A, 0x03, 0x02, 0x0F, 0x03, 0x03, 0x03, 0x02, 0x14, 0x02, 0x03, + 0x10, 0x05, 0x01, 0x01, 0x13, 0x03, 0x0A, 0x0C, 0x05, 0x1E, 0x07, 0x01, + 0x13, 0x01, 0x02, 0x02, 0x07, 0x02, 0x0E, 0x04, 0x04, 0x04, 0x09, 0x09, + 0x04, 0x04, 0x02, 0x09, 0x02, 0x02, 0x0A, 0x1B, 0x0D, 0x0D, 0x13, 0x06, + 0x01, 0x01, 0x17, 0x02, 0x26, 0x4C, 0x26, 0x06, 0x62, 0x01, 0x01, 0x02, + 0x06, 0x02, 0x04, 0x01, 0x09, 0x03, 0x08, 0x02, 0x1F, 0x0C, 0x28, 0x51, + 0x28, 0x0B, 0x22, 0x08, 0x04, 0x09, 0x03, 0x05, 0x02, 0x0C, 0x08, 0x13, + 0x25, 0x06, 0x02, 0x0C, 0x0A, 0x05, 0x0F, 0x06, 0x0E, 0x05, 0x05, 0x04, + 0x02, 0x03, 0x05, 0x03, 0x01, 0x03, 0x05, 0x04, 0x05, 0x06, 0x03, 0x03, + 0x07, 0x03, 0x0B, 0x04, 0x16, 0x4B, 0x10, 0x04, 0x04, 0x0D, 0x04, 0x07, + 0x06, 0x11, 0x0A, 0x09, 0x0D, 0x05, 0x01, 0x01, 0x03, 0x04, 0x02, 0x07, + 0x05, 0x05, 0x2E, 0x03, 0x11, 0x49, 0x0D, 0x0A, 0x08, 0x12, 0x0D, 0x1E, + 0x0D, 0x04, 0x07, 0x05, 0x07, 0x03, 0x06, 0x2B, 0x5F, 0x2F, 0x02, 0x07, + 0x02, 0x02, 0x04, 0x03, 0x03, 0x0E, 0x04, 0x0B, 0x1A, 0x0A, 0x0A, 0x0E, + 0x09, 0x06, 0x06, 0x01, 0x02, 0x03, 0x03, 0x1D, 0x05, 0x23, 0x09, 0x28, + 0x4F, 0x28, 0x34, 0x60, 0x34, 0x0E, 0x1B, 0x0E, 0x02, 0x09, 0x03, 0x07, + 0x05, 0x0E, 0x04, 0x06, 0x09, 0x0A, 0x08, 0x06, 0x0C, 0x07, 0x09, 0x0D, + 0x04, 0x02, 0x11, 0x05, 0x04, 0x03, 0x07, 0x0D, 0x22, 0x0E, 0x08, 0x11, + 0x02, 0x0B, 0x06, 0x18, 0x3A, 0x14, 0x07, 0x18, 0x05, 0x07, 0x12, 0x07, + 0x06, 0x37, 0x0A, 0x03, 0x05, 0x01, 0x04, 0x09, 0x04, 0x08, 0x11, 0x08, + 0x0D, 0x19, 0x0C, 0x05, 0x08, 0x03, 0x04, 0x0E, 0x01, 0x08, 0x0C, 0x08, + 0x09, 0x10, 0x09, 0x01, 0x03, 0x02, 0x08, 0x0F, 0x06, 0x07, 0x0D, 0x07, + 0x04, 0x17, 0x0D, 0x0F, 0x1D, 0x0F, 0x08, 0x24, 0x02, 0x02, 0x21, 0x07, + 0x06, 0x13, 0x04, 0x04, 0x08, 0x05, 0x0B, 0x0E, 0x06, 0x05, 0x0B, 0x04, + 0x09, 0x60, 0x0D, 0x0B, 0x25, 0x06, 0x0C, 0x04, 0x02, 0x01, 0x17, 0x0C, + 0x0C, 0x0D, 0x09, 0x05, 0x01, 0x06, 0x25, 0x4A, 0x25, 0x06, 0x19, 0x04, + 0x04, 0x04, 0x07, 0x0B, 0x01, 0x01, 0x01, 0x04, 0x0B, 0x01, 0x06, 0x1E, + 0x08, 0x04, 0x03, 0x06, 0x03, 0x05, 0x02, 0x41, 0x16, 0x43, 0x87, 0x86, + 0x86, 0x43, 0xF8, 0xA0, 0x02, 0x04, 0x02, 0x35, 0x6B, 0x35, 0x01, 0x03, + 0x04, 0x03, 0x0C, 0x02, 0x05, 0x09, 0x04, 0x11, 0x1C, 0x0D, 0x08, 0x16, + 0x08, 0x11, 0x21, 0x10, 0x02, 0xB4, 0x03, 0x35, 0x01, 0x11, 0x01, 0x01, + 0x01, 0x01, 0x1D, 0x04, 0x0B, 0x03, 0x08, 0x08, 0x20, 0x0B, 0x0C, 0x27, + 0x07, 0x10, 0x24, 0x0F, 0x02, 0x6A, 0x12, 0x20, 0x40, 0x20, 0x07, 0x36, + 0x2B, 0x10, 0x01, 0x0A, 0x02, 0x08, 0x03, 0x03, 0x06, 0x04, 0x08, 0x04, + 0x08, 0x11, 0x06, 0x04, 0x0D, 0x0A, 0x41, 0x81, 0x41, 0x07, 0x0F, 0x06, + 0x05, 0x09, 0x0A, 0x0A, 0x2D, 0x08, 0x06, 0x2F, 0x02, 0x02, 0x06, 0x05, + 0x03, 0x0D, 0x06, 0x07, 0x03, 0x04, 0x03, 0x02, 0x05, 0x02, 0x06, 0x01, + 0x07, 0x03, 0x01, 0x01, 0x02, 0x0C, 0x02, 0x0A, 0x03, 0x02, 0x01, 0x01, + 0x02, 0x03, 0x09, 0x03, 0x07, 0x01, 0x06, 0x09, 0x11, 0x0A, 0x04, 0x01, + 0x07, 0x04, 0x08, 0x04, 0x11, 0x20, 0x10, 0x21, 0x42, 0x21, 0x10, 0x20, + 0x10, 0x09, 0x12, 0x08, 0x11, 0x03, 0x02, 0x08, 0x04, 0x03, 0x08, 0x04, + 0x08, 0x05, 0x08, 0x10, 0x07, 0x41, 0x84, 0x40, 0x14, 0x10, 0x0E, 0x01, + 0x19, 0x0A, 0x0C, 0x0A, 0x04, 0x01, 0x01, 0x02, 0x07, 0x07, 0x0F, 0x08, + 0x08, 0x10, 0x07, 0x07, 0x16, 0x05, 0x05, 0x14, 0x05, 0x03, 0x0A, 0x05, + 0x02, 0x07, 0x1D, 0x10, 0x20, 0x0E, 0x0D, 0x23, 0x0D, 0x0B, 0x0A, 0x0B, + 0x09, 0x09, 0x05, 0x05, 0x0D, 0x0A, 0x03, 0x08, 0x03, 0x04, 0x01, 0x03, + 0x01, 0x06, 0x05, 0x02, 0x01, 0x07, 0x0C, 0x0A, 0x11, 0x02, 0x04, 0x01, + 0x07, 0x05, 0x05, 0x25, 0x48, 0x1E, 0x02, 0x02, 0x02, 0x0D, 0x03, 0x02, + 0x0A, 0x01, 0x06, 0x05, 0x08, 0x07, 0x2A, 0x0C, 0x0D, 0x27, 0x0C, 0x0D, + 0x24, 0x0E, 0x12, 0x45, 0x09, 0x06, 0x02, 0x07, 0x0D, 0x01, 0x06, 0x03, + 0x04, 0x03, 0x02, 0x05, 0x11, 0x06, 0x0D, 0x04, 0x05, 0x04, 0x10, 0x02, + 0x08, 0x05, 0x04, 0x02, 0x07, 0x02, 0x04, 0x04, 0x02, 0x0C, 0x04, 0x20, + 0x07, 0x03, 0x08, 0x03, 0x14, 0x0E, 0x05, 0x04, 0x05, 0x0A, 0x02, 0x02, + 0x07, 0x01, 0x02, 0x01, 0x06, 0x0A, 0x0D, 0x02, 0x03, 0x01, 0x06, 0x01, + 0x02, 0x03, 0x03, 0x03, 0x05, 0x02, 0x01, 0x0B, 0x04, 0x05, 0x0B, 0x05, + 0x02, 0x09, 0x0A, 0x08, 0x01, 0x06, 0x07, 0x08, 0x09, 0x0B, 0x0C, 0x07, + 0x0D, 0x16, 0x05, 0x02, 0x0F, 0x22, 0x03, 0x03, 0x0B, 0x0B, 0x01, 0x05, + 0x04, 0x02, 0x0B, 0x04, 0x08, 0x10, 0x09, 0x08, 0x11, 0x08, 0x0E, 0x04, + 0x02, 0x04, 0x02, 0x0A, 0x02, 0x04, 0x02, 0x0B, 0x03, 0x03, 0x0E, 0x0A, + 0x05, 0x02, 0x07, 0x01, 0x0B, 0x01, 0x04, 0x09, 0x04, 0x02, 0x04, 0x07, + 0x09, 0x01, 0x06, 0x08, 0x0C, 0x0B, 0x1E, 0x04, 0x49, 0x01, 0x02, 0x01, + 0x09, 0x19, 0x07, 0x08, 0x03, 0x08, 0x0D, 0x1B, 0x0D, 0x0D, 0x0D, 0x0A, + 0x07, 0x0B, 0x06, 0x0C, 0x18, 0x0D, 0x00, 0x00, 0x00, 0x02, 0x00, 0x53, + 0x00, 0x58, 0x0A, 0x33, 0x03, 0x26, 0x01, 0x80, 0x01, 0x8D, 0x00, 0x00, + 0x01, 0x32, 0x36, 0x17, 0x1E, 0x01, 0x33, 0x32, 0x14, 0x17, 0x16, 0x36, + 0x33, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, + 0x15, 0x16, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x3A, 0x01, 0x33, 0x3A, 0x01, + 0x33, 0x32, 0x36, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, + 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x34, 0x36, + 0x37, 0x34, 0x16, 0x33, 0x32, 0x06, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x06, + 0x17, 0x16, 0x32, 0x33, 0x16, 0x32, 0x33, 0x3E, 0x01, 0x37, 0x32, 0x16, + 0x37, 0x36, 0x16, 0x33, 0x32, 0x16, 0x17, 0x1E, 0x01, 0x07, 0x0E, 0x01, + 0x23, 0x2E, 0x01, 0x23, 0x2A, 0x01, 0x23, 0x2A, 0x01, 0x07, 0x06, 0x16, + 0x33, 0x32, 0x36, 0x17, 0x16, 0x06, 0x15, 0x14, 0x26, 0x27, 0x2E, 0x01, + 0x23, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x22, 0x26, 0x07, 0x0E, 0x01, + 0x07, 0x06, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x1E, 0x01, 0x07, 0x14, 0x06, + 0x27, 0x2E, 0x01, 0x23, 0x2A, 0x01, 0x27, 0x2A, 0x01, 0x23, 0x22, 0x06, + 0x23, 0x1E, 0x01, 0x15, 0x14, 0x16, 0x27, 0x26, 0x06, 0x23, 0x2A, 0x01, + 0x23, 0x22, 0x26, 0x35, 0x2E, 0x01, 0x35, 0x34, 0x36, 0x27, 0x26, 0x06, + 0x17, 0x14, 0x16, 0x07, 0x06, 0x16, 0x17, 0x14, 0x06, 0x07, 0x0E, 0x01, + 0x23, 0x22, 0x26, 0x27, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x17, 0x14, 0x16, 0x07, 0x0E, 0x01, 0x23, 0x06, 0x26, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x07, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x35, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x23, 0x22, 0x26, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x17, 0x14, 0x16, 0x17, 0x1E, 0x01, + 0x07, 0x0E, 0x01, 0x23, 0x22, 0x06, 0x23, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x07, 0x22, 0x06, 0x27, 0x2E, 0x01, 0x35, 0x3C, 0x01, 0x35, 0x3C, 0x01, + 0x35, 0x34, 0x36, 0x37, 0x36, 0x16, 0x33, 0x3A, 0x01, 0x17, 0x1E, 0x01, + 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x33, 0x3E, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x33, 0x32, 0x36, + 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x33, 0x3A, 0x01, + 0x33, 0x3A, 0x01, 0x33, 0x32, 0x26, 0x33, 0x3A, 0x01, 0x33, 0x3A, 0x01, + 0x33, 0x3A, 0x01, 0x33, 0x16, 0x06, 0x17, 0x3A, 0x01, 0x17, 0x16, 0x36, + 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x23, 0x22, 0x06, 0x27, 0x2E, 0x01, 0x37, 0x3E, 0x01, 0x27, 0x1E, 0x01, + 0x17, 0x01, 0x2A, 0x01, 0x07, 0x22, 0x06, 0x17, 0x1E, 0x01, 0x33, 0x32, + 0x36, 0x27, 0x05, 0xF3, 0x09, 0x15, 0x07, 0x03, 0x05, 0x03, 0x04, 0x02, + 0x05, 0x08, 0x04, 0x0A, 0x10, 0x08, 0x09, 0x10, 0x09, 0x04, 0x17, 0x03, + 0x05, 0x05, 0x01, 0x01, 0x02, 0x03, 0x10, 0x0D, 0x20, 0x3F, 0x20, 0x16, + 0x2B, 0x16, 0x06, 0x1C, 0x05, 0x06, 0x01, 0x08, 0x08, 0x11, 0x09, 0x0E, + 0x1D, 0x0F, 0x07, 0x0F, 0x07, 0x0E, 0x06, 0x02, 0x02, 0x11, 0x01, 0x02, + 0x01, 0x18, 0x05, 0x03, 0x01, 0x02, 0x01, 0x02, 0x17, 0x03, 0x06, 0x0C, + 0x06, 0x42, 0x84, 0x43, 0x1C, 0x3A, 0x1D, 0x07, 0x0F, 0x07, 0x09, 0x02, + 0x02, 0x02, 0x03, 0x06, 0x05, 0x11, 0x06, 0x3C, 0x78, 0x3C, 0x2A, 0x54, + 0x29, 0x09, 0x10, 0x08, 0x06, 0x01, 0x07, 0x07, 0x17, 0x06, 0x11, 0x01, + 0x15, 0x03, 0x08, 0x0B, 0x09, 0x21, 0x44, 0x22, 0x16, 0x2A, 0x16, 0x03, + 0x14, 0x02, 0x04, 0x0A, 0x08, 0x0C, 0x15, 0x09, 0x07, 0x0C, 0x09, 0x01, + 0x02, 0x01, 0x04, 0x10, 0x05, 0x08, 0x05, 0x06, 0x0E, 0x07, 0x0C, 0x17, + 0x0B, 0x2F, 0x5C, 0x2E, 0x0B, 0x03, 0x01, 0x09, 0x20, 0x44, 0x20, 0x13, + 0x25, 0x12, 0x0C, 0x16, 0x01, 0x01, 0x01, 0x03, 0x07, 0x10, 0x01, 0x05, + 0x07, 0x06, 0x04, 0x01, 0x01, 0x03, 0x06, 0x23, 0x0B, 0x17, 0x2A, 0x15, + 0x06, 0x0E, 0x06, 0x04, 0x08, 0x03, 0x01, 0x06, 0x01, 0x08, 0x02, 0x01, + 0x11, 0x0A, 0x0E, 0x1E, 0x0D, 0x09, 0x11, 0x08, 0x09, 0x16, 0x09, 0x11, + 0x1D, 0x0F, 0x05, 0x0A, 0x05, 0x02, 0x09, 0x01, 0x03, 0x0B, 0x04, 0x0E, + 0x05, 0x3E, 0x7D, 0x3E, 0x1F, 0x3E, 0x1E, 0x14, 0x28, 0x13, 0x16, 0x33, + 0x01, 0x05, 0x04, 0x03, 0x0C, 0x01, 0x01, 0x08, 0x04, 0x0C, 0x1A, 0x0C, + 0x2D, 0x59, 0x2D, 0x12, 0x25, 0x12, 0x08, 0x15, 0x08, 0x10, 0x05, 0x03, + 0x0C, 0x04, 0x15, 0x05, 0x05, 0x0C, 0x06, 0x25, 0x4C, 0x25, 0x0D, 0x1D, + 0x0B, 0x0E, 0x17, 0x12, 0x08, 0x13, 0x08, 0x3F, 0x7B, 0x3A, 0x18, 0x31, + 0x1A, 0x19, 0x32, 0x18, 0x11, 0x20, 0x10, 0x01, 0x11, 0x06, 0x0E, 0x26, + 0x10, 0x0F, 0x1D, 0x0F, 0x0A, 0x02, 0x04, 0x12, 0x23, 0x12, 0x13, 0x25, + 0x13, 0x06, 0x03, 0x01, 0x08, 0x11, 0x08, 0x0A, 0x14, 0x0A, 0x01, 0x06, + 0x01, 0x02, 0x05, 0x05, 0x10, 0x1E, 0x0F, 0x1F, 0x3B, 0x1E, 0x0F, 0x1F, + 0x0F, 0x10, 0x22, 0x0C, 0x02, 0x10, 0x03, 0x08, 0x0E, 0x08, 0x12, 0x23, + 0x12, 0x08, 0x10, 0x08, 0x05, 0x06, 0x03, 0x05, 0x03, 0x07, 0x07, 0x16, + 0x07, 0x06, 0x06, 0x03, 0x02, 0x0E, 0x01, 0x0D, 0x17, 0x09, 0xFE, 0xC8, + 0x0A, 0x13, 0x0A, 0x0D, 0x18, 0x04, 0x04, 0x21, 0x0E, 0x14, 0x05, 0x04, + 0x03, 0x11, 0x01, 0x08, 0x02, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x08, + 0x05, 0x04, 0x01, 0x03, 0x01, 0x08, 0x03, 0x05, 0x19, 0x06, 0x09, 0x12, + 0x09, 0x09, 0x25, 0x01, 0x03, 0x03, 0x03, 0x0C, 0x01, 0x02, 0x03, 0x02, + 0x03, 0x07, 0x03, 0x02, 0x02, 0x01, 0x02, 0x0E, 0x0C, 0x0F, 0x17, 0x0F, + 0x08, 0x0F, 0x08, 0x04, 0x01, 0x38, 0x04, 0x09, 0x13, 0x09, 0x03, 0x0D, + 0x02, 0x04, 0x01, 0x01, 0x01, 0x01, 0x02, 0x04, 0x01, 0x01, 0x11, 0x08, + 0x08, 0x0D, 0x06, 0x04, 0x02, 0x03, 0x03, 0x02, 0x01, 0x0D, 0x03, 0x03, + 0x08, 0x25, 0x0E, 0x03, 0x01, 0x02, 0x04, 0x01, 0x05, 0x01, 0x01, 0x04, + 0x01, 0x01, 0x02, 0x07, 0x10, 0x04, 0x06, 0x09, 0x08, 0x07, 0x05, 0x04, + 0x0A, 0x15, 0x0A, 0x0D, 0x14, 0x03, 0x01, 0x05, 0x01, 0x01, 0x29, 0x4E, + 0x29, 0x06, 0x77, 0x02, 0x04, 0x03, 0x03, 0x0F, 0x48, 0x8F, 0x47, 0x05, + 0x1A, 0x02, 0x05, 0x0A, 0x08, 0x05, 0x12, 0x03, 0x02, 0x11, 0x06, 0x06, + 0x14, 0x05, 0x0A, 0x0F, 0x05, 0x0A, 0x12, 0x23, 0x11, 0x0A, 0x13, 0x0A, + 0x04, 0x0B, 0x04, 0x06, 0x08, 0x06, 0x09, 0x14, 0x01, 0x0A, 0x04, 0x03, + 0x07, 0x03, 0x04, 0x0B, 0x02, 0x18, 0x36, 0x19, 0x08, 0x11, 0x08, 0x05, + 0x0D, 0x05, 0x0B, 0x14, 0x05, 0x03, 0x08, 0x01, 0x04, 0x09, 0x01, 0x03, + 0x02, 0x04, 0x02, 0x02, 0x12, 0x1B, 0x09, 0x11, 0x08, 0x05, 0x0E, 0x07, + 0x04, 0x02, 0x02, 0x02, 0x04, 0x02, 0x01, 0x02, 0x01, 0x02, 0x03, 0x08, + 0x24, 0x10, 0x12, 0x24, 0x12, 0x2A, 0x54, 0x2A, 0x0E, 0x07, 0x09, 0x02, + 0x03, 0x01, 0x05, 0x0B, 0x05, 0x02, 0x03, 0x08, 0x0B, 0x1B, 0x05, 0x02, + 0x02, 0x02, 0x22, 0x19, 0x0A, 0x12, 0x05, 0x04, 0x03, 0x04, 0x02, 0x03, + 0x32, 0x04, 0x0D, 0x05, 0x04, 0x03, 0x08, 0x05, 0x04, 0x25, 0x0C, 0x02, + 0x0A, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x03, 0x01, 0x02, 0x02, 0x0C, + 0x03, 0x18, 0x02, 0x05, 0x09, 0x04, 0x07, 0x07, 0x03, 0x02, 0x03, 0x03, + 0x01, 0x03, 0x03, 0x05, 0x01, 0x03, 0x03, 0x07, 0x13, 0x09, 0x07, 0x14, + 0x06, 0x01, 0x0B, 0x09, 0xFE, 0x6E, 0x01, 0x01, 0x14, 0x13, 0x03, 0x1E, + 0x0E, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x56, 0x00, 0x23, 0x04, 0xCB, + 0x03, 0x5B, 0x00, 0x0D, 0x00, 0x8D, 0x00, 0x00, 0x01, 0x23, 0x22, 0x06, + 0x1D, 0x01, 0x14, 0x16, 0x33, 0x32, 0x16, 0x37, 0x3E, 0x01, 0x25, 0x17, + 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x23, 0x22, 0x26, 0x15, + 0x14, 0x16, 0x27, 0x26, 0x06, 0x23, 0x2A, 0x01, 0x07, 0x2E, 0x01, 0x35, + 0x0E, 0x01, 0x2B, 0x01, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, + 0x17, 0x14, 0x26, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x27, 0x26, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, + 0x37, 0x36, 0x26, 0x27, 0x26, 0x36, 0x35, 0x34, 0x26, 0x37, 0x3E, 0x01, + 0x37, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x1F, 0x01, 0x36, + 0x16, 0x33, 0x32, 0x36, 0x17, 0x2E, 0x01, 0x37, 0x34, 0x36, 0x37, 0x17, + 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x32, 0x36, 0x17, + 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x17, 0x1E, 0x01, 0x15, + 0x1E, 0x01, 0x17, 0x36, 0x16, 0x17, 0x02, 0x59, 0x54, 0x08, 0x08, 0x08, + 0x08, 0x15, 0x2F, 0x11, 0x07, 0x0F, 0x02, 0x53, 0x08, 0x03, 0x0F, 0x06, + 0x05, 0x35, 0x13, 0x0E, 0x24, 0x10, 0x0C, 0x8A, 0x02, 0x13, 0x1D, 0x3C, + 0x1D, 0x1E, 0x39, 0x1D, 0x05, 0x05, 0x08, 0x12, 0x09, 0x75, 0x11, 0x0C, + 0x06, 0x0E, 0x10, 0x07, 0x0D, 0x0A, 0x07, 0x1E, 0x09, 0x08, 0x0F, 0x08, + 0x17, 0x2E, 0x17, 0x12, 0x24, 0x12, 0x15, 0x34, 0x07, 0x09, 0x13, 0x07, + 0x07, 0x0D, 0x07, 0x0C, 0x1E, 0x0B, 0x02, 0x2E, 0x0D, 0x0B, 0x04, 0x02, + 0x06, 0x06, 0x22, 0x0E, 0x0C, 0x2F, 0x08, 0x0E, 0x20, 0x10, 0x21, 0x42, + 0x22, 0x06, 0x22, 0x47, 0x24, 0x21, 0x42, 0x20, 0x01, 0x01, 0x01, 0x0A, + 0x0A, 0x14, 0x04, 0x0D, 0x04, 0x18, 0x1C, 0x16, 0x08, 0x15, 0x08, 0x08, + 0x10, 0x09, 0x15, 0x2C, 0x15, 0x0C, 0x13, 0x0A, 0x09, 0x17, 0x08, 0x04, + 0x03, 0x15, 0x22, 0x12, 0x0D, 0x10, 0x0D, 0x02, 0x3E, 0x08, 0x08, 0x30, + 0x08, 0x09, 0x01, 0x0F, 0x07, 0x3C, 0xB8, 0x04, 0x2C, 0x57, 0x2C, 0x16, + 0x0F, 0x05, 0x04, 0x0D, 0x02, 0x0E, 0x0B, 0x41, 0x02, 0x05, 0x02, 0x06, + 0x04, 0x0B, 0x06, 0x0F, 0x0E, 0x28, 0x0D, 0x1C, 0x3B, 0x1E, 0x35, 0x5F, + 0x36, 0x10, 0x07, 0x01, 0x01, 0x02, 0x01, 0x05, 0x0A, 0x05, 0x03, 0x0A, + 0x05, 0x05, 0x0E, 0x19, 0x1C, 0x45, 0x1C, 0x1C, 0x37, 0x1C, 0x32, 0x62, + 0x31, 0x1B, 0x1E, 0x12, 0x0F, 0x34, 0x11, 0x14, 0x30, 0x13, 0x12, 0x1B, + 0x0B, 0x02, 0x02, 0x0A, 0x06, 0x06, 0x01, 0x04, 0x01, 0x05, 0x0E, 0x09, + 0x02, 0x01, 0x08, 0x03, 0x05, 0x04, 0x04, 0x06, 0x02, 0x04, 0x05, 0x1A, + 0x01, 0x02, 0x06, 0x08, 0x03, 0x08, 0x01, 0x07, 0x01, 0x01, 0x0C, 0x04, + 0x03, 0x09, 0x07, 0x03, 0x01, 0x01, 0x02, 0x06, 0x03, 0x06, 0x0C, 0x09, + 0x03, 0x02, 0x05, 0x00, 0x00, 0x01, 0x00, 0x54, 0x00, 0x5A, 0x01, 0x80, + 0x03, 0x26, 0x00, 0x44, 0x00, 0x00, 0x13, 0x35, 0x2E, 0x01, 0x35, 0x34, + 0x36, 0x3F, 0x01, 0x33, 0x17, 0x11, 0x07, 0x27, 0x26, 0x36, 0x37, 0x3E, + 0x01, 0x3F, 0x01, 0x11, 0x27, 0x15, 0x07, 0x15, 0x23, 0x15, 0x33, 0x15, + 0x23, 0x15, 0x33, 0x15, 0x23, 0x15, 0x33, 0x15, 0x17, 0x15, 0x14, 0x06, + 0x2B, 0x01, 0x22, 0x26, 0x3D, 0x01, 0x37, 0x35, 0x33, 0x35, 0x23, 0x35, + 0x33, 0x35, 0x23, 0x35, 0x33, 0x35, 0x23, 0x35, 0x27, 0x35, 0x34, 0x36, + 0x3B, 0x01, 0x37, 0x95, 0x0D, 0x0E, 0x05, 0x05, 0x17, 0x7C, 0x69, 0x35, + 0x11, 0x03, 0x03, 0x05, 0x04, 0x0E, 0x09, 0x10, 0x2E, 0x1B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x1B, 0x07, 0x08, 0xC9, 0x08, 0x08, 0x1A, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1A, 0x08, 0x08, 0x0F, 0x22, 0x02, 0xC9, + 0x2D, 0x02, 0x0D, 0x0B, 0x07, 0x0A, 0x02, 0x03, 0xA8, 0xFE, 0x9D, 0x1A, + 0x03, 0x05, 0x0A, 0x04, 0x04, 0x09, 0x05, 0x08, 0x01, 0x3D, 0x1A, 0x35, + 0x19, 0x35, 0x36, 0x38, 0x36, 0x39, 0x36, 0x34, 0x2E, 0x27, 0x08, 0x07, + 0x07, 0x08, 0x27, 0x2E, 0x34, 0x36, 0x39, 0x36, 0x38, 0x36, 0x35, 0x19, + 0x49, 0x07, 0x08, 0x1E, 0x00, 0x01, 0x00, 0x58, 0x00, 0x58, 0x02, 0x73, + 0x03, 0x26, 0x00, 0xA6, 0x00, 0x00, 0x01, 0x1E, 0x01, 0x17, 0x1E, 0x01, + 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x07, 0x06, 0x16, 0x15, 0x14, 0x16, + 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x26, 0x36, 0x37, 0x36, 0x26, + 0x35, 0x34, 0x36, 0x27, 0x34, 0x26, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x06, + 0x27, 0x22, 0x26, 0x07, 0x06, 0x16, 0x15, 0x14, 0x06, 0x17, 0x1E, 0x01, + 0x33, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, + 0x37, 0x36, 0x34, 0x23, 0x22, 0x36, 0x35, 0x22, 0x06, 0x27, 0x2E, 0x01, + 0x35, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x33, 0x32, 0x36, + 0x33, 0x3A, 0x01, 0x33, 0x32, 0x16, 0x35, 0x36, 0x26, 0x35, 0x34, 0x32, + 0x33, 0x1E, 0x01, 0x15, 0x14, 0x06, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, + 0x17, 0x1E, 0x01, 0x17, 0x31, 0x01, 0xFD, 0x03, 0x15, 0x07, 0x0B, 0x11, + 0x08, 0x07, 0x0F, 0x09, 0x09, 0x07, 0x01, 0x03, 0x06, 0x02, 0x02, 0x01, + 0x06, 0x07, 0x04, 0x0F, 0x01, 0x02, 0x0D, 0x01, 0x03, 0x03, 0x01, 0x01, + 0x07, 0x0B, 0x02, 0x06, 0x05, 0x04, 0x01, 0x05, 0x0C, 0x0E, 0x0A, 0x04, + 0x09, 0x05, 0x04, 0x02, 0x04, 0x09, 0x19, 0x09, 0x08, 0x1B, 0x06, 0x04, + 0x02, 0x02, 0x08, 0x06, 0x0E, 0x06, 0x0B, 0x15, 0x0A, 0x13, 0x1B, 0x0D, + 0x10, 0x0B, 0x07, 0x08, 0x07, 0x03, 0x04, 0x21, 0x17, 0x1D, 0x59, 0x2A, + 0x14, 0x2C, 0x15, 0x12, 0x24, 0x12, 0x0C, 0x12, 0x0A, 0x07, 0x09, 0x05, + 0x07, 0x0C, 0x05, 0x15, 0x14, 0x01, 0x01, 0x12, 0x14, 0x0A, 0x13, 0x10, + 0x10, 0x21, 0x10, 0x0A, 0x1E, 0x02, 0x02, 0x0A, 0x08, 0x03, 0x0A, 0x16, + 0x0A, 0x04, 0x04, 0x01, 0x03, 0x02, 0x02, 0x01, 0x02, 0x03, 0x0C, 0x07, + 0x09, 0x09, 0x09, 0x19, 0x33, 0x1A, 0x03, 0x24, 0x01, 0x01, 0x10, 0x03, + 0x08, 0x07, 0x04, 0x03, 0x02, 0x06, 0x02, 0x06, 0x04, 0x04, 0x0A, 0x0A, + 0x0E, 0x02, 0x96, 0x11, 0x1E, 0x0F, 0x13, 0x2A, 0x14, 0x10, 0x20, 0x0E, + 0x0F, 0x1D, 0x10, 0x2F, 0x5D, 0x2E, 0x16, 0x2C, 0x16, 0x07, 0x09, 0x02, + 0x01, 0x01, 0x05, 0x08, 0x06, 0x05, 0x08, 0x11, 0x07, 0x1A, 0x32, 0x19, + 0x2C, 0x55, 0x2A, 0x07, 0x11, 0x04, 0x04, 0x0D, 0x03, 0x0B, 0x1D, 0x0F, + 0x06, 0x0C, 0x06, 0x04, 0x0B, 0x03, 0x05, 0x02, 0x01, 0x02, 0x06, 0x03, + 0x15, 0x05, 0x07, 0x16, 0x04, 0x02, 0x01, 0x01, 0x05, 0x02, 0x05, 0x10, + 0x0E, 0x0F, 0x26, 0x14, 0x18, 0x2B, 0x1A, 0x24, 0x49, 0x1C, 0x24, 0x19, + 0x0A, 0x04, 0x04, 0x06, 0x06, 0x0B, 0x06, 0x04, 0x0F, 0x06, 0x04, 0x0B, + 0x05, 0x06, 0x09, 0x08, 0x25, 0x4E, 0x2A, 0x20, 0x40, 0x19, 0x0D, 0x12, + 0x06, 0x06, 0x09, 0x06, 0x03, 0x05, 0x0D, 0x07, 0x29, 0x83, 0x0A, 0x01, + 0x04, 0x02, 0x06, 0x05, 0x03, 0x05, 0x03, 0x03, 0x03, 0x04, 0x07, 0x05, + 0x09, 0x01, 0x02, 0x05, 0x0B, 0x05, 0x05, 0x01, 0x0A, 0x08, 0x03, 0x05, + 0x03, 0x03, 0x04, 0x02, 0x06, 0x12, 0x07, 0x10, 0x2B, 0x0F, 0x00, 0x00, + 0x00, 0x03, 0x00, 0x54, 0x00, 0x58, 0x01, 0xA3, 0x03, 0x26, 0x00, 0x86, + 0x00, 0xA9, 0x00, 0xCB, 0x00, 0x00, 0x01, 0x3C, 0x01, 0x35, 0x34, 0x36, + 0x27, 0x2E, 0x01, 0x27, 0x26, 0x34, 0x35, 0x34, 0x26, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x27, 0x26, 0x34, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x36, 0x06, 0x27, 0x26, 0x36, 0x27, 0x26, 0x22, 0x23, 0x0E, 0x01, + 0x07, 0x36, 0x06, 0x23, 0x2A, 0x01, 0x23, 0x22, 0x26, 0x07, 0x0E, 0x01, + 0x33, 0x3A, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x06, 0x15, 0x14, 0x06, + 0x07, 0x0E, 0x01, 0x17, 0x1C, 0x01, 0x15, 0x1C, 0x03, 0x15, 0x1C, 0x01, + 0x15, 0x14, 0x16, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, + 0x35, 0x3C, 0x01, 0x35, 0x3C, 0x01, 0x35, 0x3C, 0x01, 0x35, 0x1E, 0x01, + 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x15, 0x1C, 0x01, + 0x15, 0x1C, 0x01, 0x15, 0x14, 0x06, 0x15, 0x14, 0x16, 0x33, 0x32, 0x36, + 0x37, 0x3E, 0x01, 0x35, 0x3C, 0x01, 0x35, 0x07, 0x1C, 0x01, 0x15, 0x14, + 0x06, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x22, + 0x36, 0x35, 0x3C, 0x01, 0x35, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x37, 0x3E, + 0x01, 0x37, 0x30, 0x15, 0x14, 0x15, 0x11, 0x1C, 0x01, 0x15, 0x14, 0x06, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x36, + 0x35, 0x3C, 0x01, 0x35, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, + 0x37, 0x1C, 0x01, 0x15, 0x01, 0xA2, 0x01, 0x03, 0x02, 0x07, 0x03, 0x03, + 0x07, 0x01, 0x02, 0x04, 0x03, 0x07, 0x01, 0x08, 0x03, 0x04, 0x03, 0x06, + 0x01, 0x04, 0x08, 0x04, 0x01, 0x06, 0x02, 0x01, 0x02, 0x01, 0x01, 0x09, + 0x01, 0x05, 0x0B, 0x04, 0x02, 0x35, 0x06, 0x0C, 0x1A, 0x0C, 0x05, 0x0D, + 0x04, 0x09, 0x0B, 0x03, 0x02, 0x18, 0x06, 0x17, 0x05, 0x09, 0x32, 0x0A, + 0x21, 0x07, 0x29, 0x50, 0x2A, 0x0E, 0x1F, 0x0B, 0x04, 0x02, 0x06, 0x06, + 0x04, 0x04, 0x06, 0x03, 0x02, 0x09, 0x01, 0x05, 0x05, 0x06, 0x01, 0x07, + 0x04, 0x02, 0x02, 0x07, 0x01, 0x45, 0x04, 0x0D, 0x11, 0x23, 0x12, 0x07, + 0x12, 0x08, 0x1D, 0x3B, 0x1E, 0x06, 0x01, 0x1F, 0x3E, 0x1F, 0x0D, 0x1F, + 0x0D, 0x10, 0x1E, 0x10, 0x04, 0x0D, 0x11, 0x23, 0x12, 0x07, 0x12, 0x08, + 0x1D, 0x3B, 0x1E, 0x06, 0x01, 0x1F, 0x3E, 0x1F, 0x0D, 0x1F, 0x0D, 0x10, + 0x1E, 0x10, 0x01, 0xA4, 0x1C, 0x37, 0x1B, 0x0E, 0x1E, 0x0C, 0x09, 0x0A, + 0x07, 0x04, 0x08, 0x06, 0x02, 0x08, 0x01, 0x05, 0x0D, 0x04, 0x07, 0x19, + 0x08, 0x03, 0x10, 0x04, 0x03, 0x0D, 0x03, 0x0B, 0x14, 0x0A, 0x06, 0x02, + 0x04, 0x02, 0x08, 0x01, 0x01, 0x02, 0x11, 0x07, 0x09, 0x03, 0x02, 0x02, + 0x03, 0x29, 0x01, 0x0A, 0x14, 0x0A, 0x07, 0x0B, 0x09, 0x04, 0x03, 0x01, + 0x01, 0x05, 0x15, 0x17, 0x2D, 0x16, 0x2F, 0x5E, 0x5E, 0x5E, 0x2F, 0x0B, + 0x17, 0x0B, 0x07, 0x0E, 0x02, 0x11, 0x03, 0x09, 0x02, 0x0B, 0x08, 0x03, + 0x01, 0x04, 0x0B, 0x15, 0x0B, 0x2C, 0x59, 0x2C, 0x49, 0x91, 0x49, 0x04, + 0x0C, 0x04, 0x05, 0x0B, 0x05, 0x03, 0x0B, 0x03, 0x0B, 0x23, 0x0C, 0x37, + 0x6E, 0x37, 0x1B, 0x37, 0x1B, 0x04, 0x05, 0x07, 0x07, 0x02, 0x01, 0x01, + 0x05, 0x11, 0x0A, 0x37, 0x6D, 0x36, 0x99, 0x05, 0x0B, 0x06, 0x0D, 0x02, + 0x02, 0x02, 0x04, 0x03, 0x01, 0x03, 0x01, 0x04, 0x07, 0x04, 0x07, 0x06, + 0x07, 0x0D, 0x06, 0x03, 0x06, 0x03, 0x02, 0x06, 0x02, 0x01, 0x04, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x31, 0x05, 0x0B, 0x06, 0x0C, 0x03, 0x02, 0x02, + 0x04, 0x02, 0x01, 0x04, 0x01, 0x04, 0x07, 0x04, 0x01, 0x06, 0x06, 0x07, + 0x0D, 0x07, 0x04, 0x06, 0x03, 0x01, 0x06, 0x01, 0x02, 0x03, 0x02, 0x01, + 0x02, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x57, 0x00, 0x3E, 0x02, 0x61, + 0x03, 0x40, 0x00, 0x4D, 0x00, 0x74, 0x00, 0x00, 0x01, 0x06, 0x16, 0x17, + 0x16, 0x06, 0x0F, 0x01, 0x0E, 0x01, 0x07, 0x3F, 0x02, 0x2F, 0x01, 0x2E, + 0x01, 0x2F, 0x01, 0x0F, 0x01, 0x33, 0x07, 0x27, 0x2E, 0x01, 0x3F, 0x01, + 0x36, 0x34, 0x27, 0x17, 0x1E, 0x01, 0x1F, 0x02, 0x37, 0x36, 0x26, 0x2F, + 0x01, 0x2E, 0x01, 0x37, 0x34, 0x36, 0x37, 0x1E, 0x01, 0x17, 0x1E, 0x01, + 0x17, 0x1E, 0x01, 0x1F, 0x02, 0x1E, 0x01, 0x37, 0x36, 0x26, 0x27, 0x26, + 0x36, 0x37, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x1F, 0x01, 0x0F, 0x02, 0x37, + 0x2F, 0x01, 0x2E, 0x01, 0x2F, 0x01, 0x07, 0x33, 0x15, 0x0F, 0x02, 0x0E, + 0x01, 0x07, 0x03, 0x06, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x16, 0x3F, 0x01, 0x13, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x3F, 0x02, 0x02, + 0x4E, 0x02, 0x03, 0x04, 0x03, 0x02, 0x05, 0x22, 0x06, 0x11, 0x0A, 0x09, + 0x05, 0x24, 0x07, 0x19, 0x07, 0x0E, 0x06, 0x16, 0x22, 0x0A, 0x04, 0x17, + 0x0D, 0x05, 0x01, 0x03, 0x0C, 0x04, 0x04, 0x0C, 0x06, 0x0A, 0x03, 0x04, + 0x01, 0x0F, 0x01, 0x07, 0x07, 0x17, 0x03, 0x03, 0x01, 0x05, 0x05, 0x01, + 0x09, 0x09, 0x04, 0x17, 0x12, 0x07, 0x09, 0x02, 0x08, 0x0C, 0x03, 0x06, + 0x02, 0x02, 0x04, 0x06, 0x07, 0x02, 0x09, 0x01, 0x0D, 0x0B, 0x0C, 0x0E, + 0x02, 0x01, 0x08, 0x0B, 0x39, 0x1F, 0x05, 0x16, 0x07, 0x0C, 0x06, 0x0F, + 0x1F, 0x01, 0x53, 0x13, 0x1F, 0x18, 0x1F, 0x08, 0xB6, 0x02, 0x06, 0x07, + 0x09, 0x18, 0x0F, 0x0E, 0x1E, 0x10, 0x11, 0x0B, 0x0A, 0xB6, 0x08, 0x0B, + 0x03, 0x03, 0x05, 0x02, 0x44, 0x05, 0x02, 0x86, 0x04, 0x09, 0x05, 0x05, + 0x0F, 0x08, 0x28, 0x07, 0x09, 0x02, 0x10, 0x01, 0x32, 0x12, 0x18, 0x05, + 0x07, 0x02, 0x02, 0x2F, 0x0E, 0x1C, 0x1B, 0x0E, 0x17, 0x09, 0x17, 0x07, + 0x14, 0x0D, 0x05, 0x03, 0x0C, 0x08, 0x1C, 0x0B, 0x22, 0x05, 0x11, 0x0B, + 0x1D, 0x05, 0x16, 0x11, 0x12, 0x16, 0x05, 0x0B, 0x13, 0x09, 0x04, 0x09, + 0x06, 0x02, 0x09, 0x06, 0x16, 0x10, 0x05, 0x02, 0x02, 0x02, 0x0C, 0x0A, + 0x0A, 0x17, 0x0D, 0x05, 0x10, 0x0B, 0x0B, 0x15, 0x0B, 0x15, 0x19, 0x11, + 0x4F, 0x2B, 0x0E, 0x13, 0x05, 0x07, 0x02, 0x01, 0x2B, 0x06, 0x65, 0x0C, + 0x0F, 0x0B, 0x16, 0x0C, 0xFF, 0x00, 0x06, 0x12, 0x0C, 0x0E, 0x18, 0x0A, + 0x0B, 0x0E, 0x05, 0x04, 0x02, 0x03, 0x01, 0x00, 0x0C, 0x25, 0x19, 0x1B, + 0x1C, 0x03, 0x6F, 0x01, 0x00, 0x04, 0x00, 0x61, 0x00, 0x5A, 0x03, 0x1D, + 0x03, 0x8C, 0x00, 0x12, 0x00, 0x25, 0x00, 0x38, 0x00, 0x7D, 0x00, 0x00, + 0x13, 0x17, 0x07, 0x27, 0x15, 0x23, 0x35, 0x07, 0x27, 0x37, 0x27, 0x37, + 0x17, 0x35, 0x33, 0x15, 0x37, 0x17, 0x07, 0x13, 0x37, 0x27, 0x07, 0x35, + 0x23, 0x15, 0x27, 0x07, 0x17, 0x07, 0x17, 0x37, 0x15, 0x33, 0x35, 0x17, + 0x37, 0x27, 0x05, 0x37, 0x27, 0x07, 0x35, 0x23, 0x15, 0x27, 0x07, 0x17, + 0x07, 0x17, 0x37, 0x15, 0x33, 0x35, 0x17, 0x37, 0x27, 0x05, 0x07, 0x23, + 0x22, 0x06, 0x1D, 0x01, 0x17, 0x15, 0x33, 0x15, 0x23, 0x15, 0x33, 0x15, + 0x23, 0x15, 0x33, 0x15, 0x23, 0x15, 0x07, 0x15, 0x14, 0x16, 0x3B, 0x01, + 0x32, 0x36, 0x3D, 0x01, 0x27, 0x35, 0x23, 0x35, 0x33, 0x35, 0x23, 0x35, + 0x33, 0x35, 0x23, 0x35, 0x33, 0x35, 0x37, 0x35, 0x17, 0x11, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x1F, 0x01, 0x37, 0x11, 0x27, 0x23, 0x07, 0x0E, + 0x01, 0x15, 0x14, 0x16, 0x17, 0x15, 0xDA, 0x2E, 0x13, 0x2D, 0x25, 0x30, + 0x12, 0x2F, 0x2F, 0x14, 0x2E, 0x25, 0x2D, 0x12, 0x2D, 0x4E, 0x37, 0x16, + 0x35, 0x2D, 0x38, 0x16, 0x38, 0x38, 0x16, 0x38, 0x2D, 0x35, 0x16, 0x37, + 0x01, 0xC7, 0x2D, 0x12, 0x2D, 0x25, 0x2E, 0x13, 0x2D, 0x2D, 0x12, 0x2F, + 0x25, 0x2D, 0x13, 0x2E, 0xFE, 0xA9, 0x21, 0x10, 0x08, 0x08, 0x1A, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1A, 0x08, 0x08, 0xC9, 0x08, 0x07, 0x1B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x1B, 0x2E, 0x10, 0x09, 0x0E, 0x04, + 0x05, 0x03, 0x03, 0x11, 0x35, 0x69, 0x7C, 0x17, 0x05, 0x05, 0x0E, 0x0D, + 0x02, 0x00, 0x1A, 0x20, 0x1A, 0x34, 0x35, 0x1B, 0x20, 0x1A, 0x1B, 0x21, + 0x1B, 0x36, 0x35, 0x1A, 0x21, 0x1B, 0x01, 0x27, 0x20, 0x26, 0x1F, 0x3E, + 0x40, 0x21, 0x26, 0x20, 0x20, 0x26, 0x20, 0x40, 0x3E, 0x1E, 0x26, 0x20, + 0x2B, 0x1B, 0x21, 0x1A, 0x35, 0x36, 0x1B, 0x21, 0x1B, 0x1A, 0x20, 0x1B, + 0x35, 0x34, 0x1A, 0x20, 0x1A, 0x33, 0x1E, 0x08, 0x07, 0x49, 0x19, 0x35, + 0x36, 0x38, 0x36, 0x39, 0x36, 0x34, 0x2E, 0x27, 0x07, 0x08, 0x08, 0x07, + 0x27, 0x2E, 0x34, 0x36, 0x39, 0x36, 0x38, 0x36, 0x35, 0x19, 0x35, 0x1A, + 0xFE, 0xC3, 0x08, 0x05, 0x09, 0x04, 0x04, 0x0A, 0x05, 0x03, 0x1A, 0x01, + 0x63, 0xA8, 0x03, 0x02, 0x0A, 0x07, 0x0C, 0x0C, 0x02, 0x2D, 0x00, 0x00, + 0x00, 0x03, 0x00, 0x51, 0x00, 0x58, 0x01, 0xA1, 0x03, 0x26, 0x00, 0x86, + 0x00, 0xA2, 0x00, 0xC4, 0x00, 0x00, 0x01, 0x1E, 0x01, 0x17, 0x1E, 0x01, + 0x17, 0x16, 0x14, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x14, 0x16, + 0x15, 0x14, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x15, 0x1C, 0x01, + 0x15, 0x1C, 0x01, 0x15, 0x14, 0x06, 0x07, 0x0E, 0x01, 0x23, 0x22, 0x26, + 0x35, 0x34, 0x36, 0x35, 0x3C, 0x01, 0x35, 0x3C, 0x01, 0x35, 0x34, 0x36, + 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x1C, 0x01, + 0x15, 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x15, 0x14, 0x26, 0x07, 0x0E, 0x01, + 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x35, 0x3C, 0x01, 0x35, 0x3C, 0x03, + 0x35, 0x3C, 0x01, 0x35, 0x26, 0x36, 0x37, 0x3E, 0x01, 0x35, 0x34, 0x36, + 0x35, 0x3C, 0x01, 0x35, 0x34, 0x22, 0x23, 0x22, 0x36, 0x37, 0x36, 0x16, + 0x33, 0x3A, 0x01, 0x33, 0x32, 0x36, 0x07, 0x3E, 0x01, 0x37, 0x3A, 0x01, + 0x17, 0x16, 0x06, 0x17, 0x16, 0x36, 0x15, 0x07, 0x0E, 0x01, 0x17, 0x1E, + 0x01, 0x17, 0x26, 0x36, 0x37, 0x06, 0x16, 0x17, 0x1E, 0x01, 0x07, 0x16, + 0x36, 0x37, 0x36, 0x26, 0x27, 0x2E, 0x01, 0x37, 0x0E, 0x01, 0x07, 0x13, + 0x34, 0x3D, 0x01, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, + 0x1C, 0x01, 0x15, 0x1C, 0x01, 0x33, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x35, 0x3C, 0x01, 0x35, 0x01, 0x4D, 0x03, + 0x09, 0x03, 0x02, 0x05, 0x04, 0x03, 0x04, 0x07, 0x01, 0x08, 0x03, 0x03, + 0x03, 0x07, 0x01, 0x02, 0x03, 0x08, 0x02, 0x03, 0x01, 0x01, 0x07, 0x02, + 0x03, 0x04, 0x06, 0x01, 0x06, 0x04, 0x04, 0x01, 0x0A, 0x02, 0x03, 0x05, + 0x04, 0x04, 0x07, 0x05, 0x03, 0x03, 0x0C, 0x1F, 0x0E, 0x2A, 0x4F, 0x2A, + 0x06, 0x21, 0x0B, 0x32, 0x0A, 0x05, 0x16, 0x07, 0x19, 0x02, 0x03, 0x0B, + 0x09, 0x05, 0x0D, 0x04, 0x0D, 0x19, 0x0D, 0x05, 0x35, 0x01, 0x03, 0x0B, + 0x06, 0x01, 0x08, 0x01, 0x02, 0x03, 0x01, 0x02, 0x06, 0x8A, 0x20, 0x1E, + 0x01, 0x01, 0x22, 0x2F, 0x22, 0x03, 0x1E, 0x06, 0x0E, 0x0C, 0x06, 0x25, + 0x0E, 0x15, 0x21, 0x03, 0x04, 0x0C, 0x0E, 0x17, 0x36, 0x21, 0x0F, 0x1E, + 0x0F, 0x97, 0x0F, 0x1F, 0x0F, 0x0E, 0x1E, 0x0E, 0x1F, 0x3E, 0x1F, 0x06, + 0x1D, 0x3B, 0x1E, 0x08, 0x11, 0x08, 0x11, 0x23, 0x12, 0x0C, 0x04, 0x03, + 0x12, 0x0A, 0x14, 0x0B, 0x03, 0x0D, 0x03, 0x04, 0x10, 0x03, 0x08, 0x19, + 0x07, 0x04, 0x0D, 0x05, 0x01, 0x08, 0x02, 0x06, 0x08, 0x04, 0x07, 0x0A, + 0x09, 0x0C, 0x1E, 0x0E, 0x1B, 0x37, 0x1C, 0x36, 0x6D, 0x37, 0x0A, 0x11, + 0x05, 0x01, 0x01, 0x02, 0x07, 0x07, 0x05, 0x04, 0x1B, 0x37, 0x1B, 0x37, + 0x6E, 0x37, 0x0C, 0x23, 0x0B, 0x03, 0x0B, 0x03, 0x05, 0x0B, 0x05, 0x04, + 0x0C, 0x04, 0x49, 0x91, 0x49, 0x2C, 0x59, 0x2C, 0x0B, 0x15, 0x0B, 0x04, + 0x01, 0x03, 0x08, 0x0B, 0x02, 0x09, 0x03, 0x11, 0x02, 0x0D, 0x08, 0x0B, + 0x17, 0x0B, 0x2F, 0x5E, 0x5E, 0x5E, 0x2F, 0x16, 0x2D, 0x17, 0x15, 0x05, + 0x01, 0x01, 0x03, 0x04, 0x09, 0x0B, 0x07, 0x0A, 0x14, 0x0A, 0x01, 0x29, + 0x03, 0x02, 0x02, 0x03, 0x09, 0x07, 0x11, 0x02, 0x01, 0x01, 0x08, 0x02, + 0x04, 0x02, 0x06, 0xD4, 0x1C, 0x55, 0x29, 0x28, 0x4C, 0x03, 0x15, 0x55, + 0x16, 0x11, 0x20, 0x0D, 0x06, 0x2F, 0x09, 0x08, 0x37, 0x0E, 0x19, 0x2F, + 0x14, 0x22, 0x5A, 0x28, 0x0C, 0x18, 0x0C, 0xFE, 0xCD, 0x01, 0x01, 0x01, + 0x01, 0x04, 0x01, 0x02, 0x06, 0x02, 0x03, 0x06, 0x03, 0x06, 0x0D, 0x07, + 0x06, 0x07, 0x04, 0x07, 0x04, 0x01, 0x03, 0x01, 0x03, 0x04, 0x02, 0x02, + 0x02, 0x0D, 0x06, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x5E, + 0x00, 0xC0, 0x03, 0x8F, 0x02, 0xC0, 0x00, 0x10, 0x00, 0x2D, 0x00, 0x3F, + 0x00, 0x51, 0x00, 0x61, 0x00, 0x70, 0x00, 0x7D, 0x00, 0x8C, 0x00, 0x9B, + 0x00, 0xA7, 0x00, 0xB9, 0x00, 0xC1, 0x00, 0xCF, 0x00, 0xDD, 0x00, 0xE9, + 0x01, 0x0C, 0x00, 0x00, 0x01, 0x34, 0x26, 0x23, 0x21, 0x22, 0x06, 0x0F, + 0x01, 0x15, 0x1F, 0x01, 0x21, 0x32, 0x36, 0x3D, 0x01, 0x37, 0x1E, 0x01, + 0x15, 0x11, 0x14, 0x06, 0x07, 0x0E, 0x01, 0x23, 0x21, 0x22, 0x26, 0x27, + 0x2E, 0x01, 0x35, 0x11, 0x34, 0x36, 0x37, 0x3E, 0x01, 0x33, 0x21, 0x32, + 0x16, 0x17, 0x07, 0x27, 0x37, 0x17, 0x35, 0x33, 0x07, 0x37, 0x17, 0x07, + 0x17, 0x07, 0x27, 0x17, 0x23, 0x35, 0x07, 0x2F, 0x01, 0x07, 0x17, 0x07, + 0x27, 0x17, 0x23, 0x35, 0x07, 0x27, 0x37, 0x27, 0x37, 0x17, 0x35, 0x33, + 0x07, 0x37, 0x17, 0x2F, 0x01, 0x23, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x1D, + 0x01, 0x1F, 0x01, 0x33, 0x3F, 0x02, 0x07, 0x0E, 0x01, 0x1D, 0x01, 0x1F, + 0x01, 0x33, 0x3F, 0x01, 0x35, 0x2F, 0x01, 0x23, 0x2F, 0x02, 0x23, 0x0F, + 0x01, 0x15, 0x1F, 0x01, 0x33, 0x3F, 0x01, 0x35, 0x37, 0x27, 0x23, 0x07, + 0x0E, 0x01, 0x1D, 0x01, 0x1F, 0x01, 0x33, 0x3F, 0x01, 0x35, 0x27, 0x17, + 0x27, 0x23, 0x07, 0x0E, 0x01, 0x1D, 0x01, 0x1F, 0x01, 0x33, 0x3F, 0x01, + 0x35, 0x27, 0x35, 0x27, 0x23, 0x0F, 0x01, 0x15, 0x1F, 0x01, 0x33, 0x3F, + 0x01, 0x35, 0x27, 0x07, 0x17, 0x07, 0x27, 0x17, 0x23, 0x35, 0x07, 0x27, + 0x37, 0x27, 0x37, 0x17, 0x35, 0x33, 0x07, 0x37, 0x07, 0x3F, 0x01, 0x33, + 0x0F, 0x01, 0x15, 0x23, 0x17, 0x23, 0x22, 0x06, 0x0F, 0x01, 0x15, 0x1F, + 0x01, 0x33, 0x3F, 0x01, 0x35, 0x2F, 0x01, 0x23, 0x0F, 0x01, 0x15, 0x17, + 0x1E, 0x01, 0x3B, 0x01, 0x3F, 0x01, 0x35, 0x27, 0x05, 0x15, 0x33, 0x15, + 0x33, 0x35, 0x33, 0x35, 0x23, 0x35, 0x23, 0x07, 0x27, 0x1F, 0x01, 0x37, + 0x2F, 0x01, 0x22, 0x06, 0x07, 0x0E, 0x01, 0x15, 0x14, 0x16, 0x17, 0x1E, + 0x01, 0x33, 0x3F, 0x01, 0x27, 0x07, 0x23, 0x22, 0x26, 0x27, 0x2E, 0x01, + 0x35, 0x34, 0x36, 0x37, 0x3E, 0x01, 0x33, 0x03, 0x4A, 0x07, 0x08, 0xFE, + 0xCE, 0x03, 0x05, 0x02, 0x06, 0x06, 0x0A, 0x01, 0x32, 0x08, 0x07, 0x3A, + 0x05, 0x06, 0x06, 0x05, 0x06, 0x11, 0x0B, 0xFD, 0x2A, 0x09, 0x10, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x10, 0x09, 0x02, 0xD6, 0x0B, 0x10, 0x07, + 0xD1, 0x0B, 0x04, 0x0D, 0x0A, 0x02, 0x0D, 0x04, 0x0E, 0x0E, 0x04, 0x0D, + 0x02, 0x0A, 0x0D, 0x04, 0x13, 0x0D, 0x0D, 0x05, 0x0E, 0x03, 0x0B, 0x0B, + 0x06, 0x0D, 0x0D, 0x06, 0x0B, 0x0B, 0x03, 0x0E, 0x06, 0x03, 0x0A, 0x27, + 0x03, 0x04, 0x01, 0x02, 0x02, 0x04, 0x08, 0x27, 0x0A, 0x03, 0x23, 0x08, + 0x03, 0x02, 0x05, 0x08, 0x29, 0x08, 0x03, 0x03, 0x08, 0x29, 0x23, 0x03, + 0x0A, 0x27, 0x08, 0x04, 0x04, 0x08, 0x27, 0x0A, 0x03, 0x54, 0x08, 0x29, + 0x08, 0x03, 0x02, 0x05, 0x08, 0x29, 0x08, 0x03, 0x03, 0x57, 0x0A, 0x26, + 0x0A, 0x02, 0x02, 0x04, 0x0A, 0x26, 0x0A, 0x04, 0x04, 0x0A, 0x26, 0x0A, + 0x04, 0x04, 0x0A, 0x26, 0x0A, 0x04, 0xEE, 0x0D, 0x0D, 0x03, 0x0F, 0x03, + 0x0A, 0x0D, 0x04, 0x0B, 0x0B, 0x04, 0x0D, 0x0A, 0x03, 0x0F, 0xEE, 0x0C, + 0x08, 0x03, 0x02, 0x01, 0x2D, 0xE4, 0x26, 0x02, 0x05, 0x02, 0x06, 0x06, + 0x09, 0x26, 0x0A, 0x04, 0x04, 0x0A, 0x26, 0x09, 0x06, 0x06, 0x02, 0x05, + 0x02, 0x26, 0x0A, 0x04, 0x04, 0xFE, 0xE4, 0x5B, 0x2E, 0x1B, 0x1B, 0x3B, + 0x4E, 0x31, 0x10, 0x0B, 0x08, 0x11, 0x13, 0x17, 0x22, 0x0C, 0x0A, 0x0B, + 0x0B, 0x0A, 0x0B, 0x1E, 0x13, 0x19, 0x13, 0x05, 0x0E, 0x0F, 0x08, 0x0F, + 0x06, 0x07, 0x07, 0x06, 0x06, 0x05, 0x10, 0x0A, 0x02, 0x7A, 0x08, 0x07, + 0x02, 0x02, 0x0B, 0xC4, 0x0B, 0x03, 0x07, 0x07, 0xC4, 0x38, 0x07, 0x11, + 0x0A, 0xFE, 0x5E, 0x09, 0x0F, 0x07, 0x07, 0x08, 0x08, 0x07, 0x07, 0x0F, + 0x09, 0x01, 0xA2, 0x0A, 0x11, 0x07, 0x07, 0x07, 0x07, 0x07, 0x9D, 0x07, + 0x07, 0x07, 0x0D, 0x0D, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x0E, 0x0E, + 0x07, 0x08, 0x0E, 0x07, 0x07, 0x08, 0x07, 0x0E, 0x0E, 0x07, 0x08, 0x07, + 0x07, 0x07, 0x07, 0x0D, 0x0D, 0x07, 0xFE, 0x08, 0x06, 0x03, 0x03, 0x01, + 0x04, 0x03, 0x27, 0x0A, 0x03, 0x03, 0x0A, 0x35, 0x06, 0x01, 0x05, 0x02, + 0x27, 0x0A, 0x03, 0x03, 0x0A, 0x27, 0x08, 0x06, 0x4E, 0x0A, 0x03, 0x03, + 0x0A, 0x27, 0x08, 0x06, 0x06, 0x08, 0x27, 0x0A, 0x03, 0x03, 0x03, 0x05, + 0x02, 0x27, 0x08, 0x06, 0x06, 0x08, 0x27, 0x0A, 0x5E, 0x06, 0x06, 0x01, + 0x04, 0x03, 0x27, 0x0A, 0x03, 0x03, 0x0A, 0x27, 0x08, 0x5E, 0x03, 0x03, + 0x0A, 0x27, 0x08, 0x06, 0x06, 0x08, 0x27, 0x9B, 0x07, 0x07, 0x08, 0x07, + 0x0E, 0x0E, 0x07, 0x08, 0x07, 0x07, 0x07, 0x07, 0x0D, 0x0D, 0x07, 0xAC, + 0x14, 0x15, 0x15, 0x14, 0x2E, 0x16, 0x03, 0x03, 0x08, 0x27, 0x0A, 0x03, + 0x03, 0x0A, 0x27, 0x08, 0x61, 0x03, 0x0A, 0x27, 0x08, 0x03, 0x03, 0x06, + 0x08, 0x27, 0x0A, 0x46, 0x20, 0x31, 0x31, 0x24, 0x7B, 0x7F, 0x2A, 0x02, + 0x02, 0x23, 0x04, 0x01, 0x0C, 0x0C, 0x0B, 0x1C, 0x12, 0x13, 0x1E, 0x0B, + 0x0B, 0x0A, 0x03, 0x04, 0x26, 0x06, 0x06, 0x05, 0x05, 0x10, 0x0B, 0x09, + 0x0F, 0x06, 0x07, 0x07, 0x00, 0x03, 0x00, 0x62, 0x00, 0x3E, 0x02, 0x89, + 0x03, 0x40, 0x00, 0x3B, 0x00, 0x6A, 0x00, 0x91, 0x00, 0x00, 0x01, 0x06, + 0x16, 0x17, 0x16, 0x14, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, + 0x01, 0x27, 0x2E, 0x03, 0x27, 0x26, 0x36, 0x37, 0x1E, 0x01, 0x37, 0x3E, + 0x01, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x1E, 0x01, 0x17, 0x1E, + 0x01, 0x37, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x17, 0x07, 0x16, 0x0E, 0x02, + 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x34, 0x36, 0x37, 0x36, 0x16, + 0x17, 0x16, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x34, 0x17, 0x1E, 0x01, + 0x17, 0x1E, 0x01, 0x37, 0x3E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x0E, 0x01, + 0x07, 0x0E, 0x01, 0x27, 0x06, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, + 0x17, 0x1E, 0x01, 0x17, 0x32, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x3E, 0x03, + 0x27, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x23, 0x02, 0x83, 0x01, 0x05, 0x01, + 0x01, 0x01, 0x02, 0x0A, 0x09, 0x0F, 0x36, 0x26, 0x0A, 0x13, 0x0B, 0x0A, + 0x18, 0x0C, 0x09, 0x16, 0x0A, 0x06, 0x0A, 0x07, 0x0F, 0x1E, 0x0C, 0x2E, + 0x4A, 0x35, 0x20, 0x06, 0x04, 0x04, 0x08, 0x19, 0x35, 0x1F, 0x1B, 0x2C, + 0x15, 0x0B, 0x12, 0x09, 0x09, 0x05, 0x03, 0x15, 0x30, 0x22, 0x13, 0x2A, + 0x15, 0x0E, 0x1C, 0x0D, 0x0A, 0x11, 0x0A, 0x5E, 0x05, 0x07, 0x19, 0x2F, + 0x24, 0x09, 0x15, 0x0B, 0x06, 0x10, 0x06, 0x10, 0x1D, 0x0E, 0x30, 0x36, + 0x09, 0x03, 0x04, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x12, 0x03, + 0x1B, 0x39, 0x15, 0x0A, 0x12, 0x09, 0x06, 0x08, 0x08, 0x16, 0x0D, 0x15, + 0x25, 0x17, 0x0C, 0x16, 0x07, 0x32, 0x4F, 0x1D, 0x0D, 0x20, 0x11, 0x28, + 0x5A, 0x2F, 0x09, 0x0A, 0x12, 0x14, 0x47, 0x34, 0x0D, 0x1A, 0x0E, 0x07, + 0x0E, 0x07, 0x02, 0x05, 0x01, 0x0F, 0x1D, 0x0D, 0x37, 0x49, 0x28, 0x0B, + 0x06, 0x0B, 0x15, 0x0A, 0x09, 0x17, 0x0A, 0x02, 0xCC, 0x11, 0x21, 0x11, + 0x15, 0x29, 0x15, 0x26, 0x4B, 0x25, 0x3B, 0x72, 0x30, 0x0C, 0x1A, 0x0C, + 0x0B, 0x14, 0x0B, 0x09, 0x0D, 0x07, 0x05, 0x07, 0x03, 0x06, 0x1C, 0x0A, + 0x29, 0x60, 0x6C, 0x74, 0x3E, 0x31, 0x66, 0x31, 0x10, 0x14, 0x03, 0x04, + 0x1B, 0x11, 0x09, 0x14, 0x0B, 0x0A, 0x17, 0x0C, 0x20, 0x3C, 0x13, 0x0B, + 0x0A, 0x01, 0x08, 0x05, 0x05, 0x05, 0x08, 0x64, 0x33, 0x67, 0x62, 0x59, + 0x27, 0x0A, 0x13, 0x07, 0x04, 0x0C, 0x04, 0x0B, 0x18, 0x0E, 0x31, 0x79, + 0x44, 0x19, 0x33, 0x1A, 0x07, 0x0D, 0x07, 0x01, 0x0A, 0x01, 0x01, 0x0C, + 0x01, 0x0A, 0x0F, 0x12, 0x0A, 0x12, 0x0A, 0x08, 0x05, 0x0C, 0x0D, 0x17, + 0x08, 0x0E, 0x06, 0x01, 0x01, 0x0C, 0x38, 0x03, 0x38, 0x27, 0x11, 0x1E, + 0x0C, 0x1D, 0x12, 0x16, 0x43, 0x88, 0x41, 0x47, 0x81, 0x35, 0x0C, 0x17, + 0x0A, 0x06, 0x0A, 0x05, 0x05, 0x01, 0x0B, 0x15, 0x0C, 0x33, 0x7E, 0x8C, + 0x94, 0x48, 0x03, 0x06, 0x03, 0x03, 0x01, 0x00, 0x00, 0x04, 0x00, 0x66, + 0x00, 0x40, 0x02, 0x90, 0x03, 0x40, 0x00, 0x29, 0x00, 0x47, 0x00, 0x66, + 0x00, 0x84, 0x00, 0x00, 0x01, 0x16, 0x06, 0x0F, 0x07, 0x27, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x2F, 0x01, 0x35, 0x3F, 0x01, 0x17, 0x1E, 0x01, 0x3F, + 0x05, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x36, 0x3F, 0x02, 0x17, 0x15, 0x07, + 0x2E, 0x01, 0x27, 0x0F, 0x03, 0x0E, 0x01, 0x27, 0x0F, 0x01, 0x17, 0x1E, + 0x01, 0x17, 0x1E, 0x01, 0x17, 0x3F, 0x06, 0x35, 0x27, 0x07, 0x1F, 0x01, + 0x0F, 0x05, 0x2F, 0x04, 0x35, 0x37, 0x33, 0x1E, 0x01, 0x3F, 0x04, 0x33, + 0x1E, 0x01, 0x1F, 0x01, 0x3F, 0x01, 0x33, 0x0F, 0x07, 0x33, 0x37, 0x33, + 0x37, 0x1F, 0x06, 0x33, 0x1F, 0x01, 0x35, 0x34, 0x26, 0x27, 0x2E, 0x01, + 0x23, 0x07, 0x02, 0x87, 0x09, 0x09, 0x12, 0x26, 0x36, 0x36, 0x2F, 0x24, + 0x0D, 0x07, 0x09, 0x3A, 0x5C, 0x22, 0x19, 0x25, 0x0B, 0x0C, 0x05, 0x07, + 0x12, 0x1A, 0x37, 0x1C, 0x32, 0x26, 0x18, 0x0B, 0x0C, 0x0D, 0x20, 0x4A, + 0x2A, 0x14, 0x2A, 0x17, 0x0B, 0x09, 0x05, 0x70, 0x2D, 0x50, 0x22, 0x05, + 0x07, 0x1F, 0x2A, 0x25, 0x4E, 0x28, 0x02, 0x02, 0x0B, 0x0A, 0x23, 0x18, + 0x1E, 0x54, 0x36, 0x16, 0x22, 0x26, 0x26, 0x36, 0x24, 0x14, 0x02, 0x55, + 0x11, 0x03, 0x12, 0x1B, 0x22, 0x24, 0x1F, 0x1D, 0x4C, 0x34, 0x1F, 0x10, + 0x06, 0x04, 0x02, 0x15, 0x2A, 0x16, 0x24, 0x1B, 0x10, 0x04, 0x03, 0x0C, + 0x1A, 0x0D, 0x31, 0x2B, 0x1D, 0x04, 0xCE, 0x35, 0x14, 0x12, 0x0E, 0x04, + 0x07, 0x02, 0x09, 0x0B, 0x1B, 0x12, 0x0F, 0x15, 0x14, 0x0F, 0x05, 0x07, + 0x0B, 0x4C, 0x14, 0x14, 0x1B, 0x1B, 0x0B, 0x18, 0x0E, 0x36, 0x02, 0xC5, + 0x52, 0x95, 0x43, 0x69, 0x5E, 0x41, 0x2D, 0x16, 0x0C, 0x04, 0x05, 0x28, + 0x62, 0x3B, 0x2D, 0x69, 0x3A, 0x5C, 0x49, 0x34, 0x28, 0x0B, 0x10, 0x09, + 0x07, 0x19, 0x1F, 0x1D, 0x0E, 0x1F, 0x1B, 0x31, 0x35, 0x03, 0x01, 0x0A, + 0x0B, 0x0B, 0x05, 0x12, 0x09, 0x24, 0x01, 0x30, 0x2F, 0x06, 0x07, 0x22, + 0x1D, 0x16, 0x05, 0x12, 0x21, 0x2D, 0x7D, 0x38, 0x65, 0x2D, 0x37, 0x5B, + 0x23, 0x0F, 0x1B, 0x26, 0x34, 0x59, 0x63, 0xBA, 0x2A, 0x26, 0x0B, 0x38, + 0x74, 0x5C, 0x4A, 0x38, 0x2B, 0x1D, 0x16, 0x41, 0x45, 0x46, 0x41, 0x3E, + 0x55, 0x10, 0x0D, 0x07, 0x07, 0x11, 0x19, 0x14, 0x09, 0x13, 0x1B, 0x08, + 0x14, 0x03, 0x0D, 0x38, 0x10, 0x14, 0x1D, 0x26, 0x07, 0x06, 0x03, 0x03, + 0x02, 0x02, 0x09, 0x0C, 0x06, 0x02, 0x05, 0x02, 0x05, 0x04, 0x0B, 0x32, + 0x44, 0x10, 0x09, 0x09, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x59, + 0x00, 0x59, 0x03, 0x7D, 0x03, 0x26, 0x00, 0xC4, 0x00, 0xD4, 0x00, 0xE4, + 0x00, 0xF7, 0x00, 0x00, 0x01, 0x0E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, + 0x01, 0x27, 0x26, 0x22, 0x07, 0x0E, 0x01, 0x07, 0x06, 0x26, 0x27, 0x2E, + 0x01, 0x27, 0x2E, 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x17, 0x1E, + 0x01, 0x17, 0x1E, 0x01, 0x15, 0x14, 0x16, 0x17, 0x16, 0x32, 0x07, 0x0E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, + 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1C, 0x01, 0x07, 0x0E, + 0x01, 0x07, 0x0E, 0x01, 0x07, 0x0E, 0x01, 0x23, 0x06, 0x26, 0x27, 0x2E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x2E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x30, 0x37, 0x36, 0x37, 0x36, 0x32, 0x17, + 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x32, 0x37, + 0x3E, 0x01, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x26, 0x07, 0x06, 0x26, 0x27, + 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, 0x26, 0x36, 0x33, 0x32, 0x16, 0x17, + 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, + 0x16, 0x36, 0x37, 0x3E, 0x01, 0x37, 0x36, 0x16, 0x17, 0x1E, 0x01, 0x17, + 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x17, 0x16, 0x06, 0x07, 0x25, 0x2E, 0x01, + 0x27, 0x2E, 0x01, 0x07, 0x22, 0x16, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, + 0x37, 0x27, 0x26, 0x06, 0x17, 0x1E, 0x01, 0x17, 0x1E, 0x01, 0x27, 0x2E, + 0x01, 0x27, 0x2E, 0x01, 0x27, 0x37, 0x2E, 0x01, 0x27, 0x2E, 0x01, 0x27, + 0x22, 0x14, 0x33, 0x16, 0x32, 0x33, 0x1E, 0x01, 0x33, 0x32, 0x26, 0x27, + 0x03, 0x70, 0x05, 0x0E, 0x07, 0x0A, 0x15, 0x08, 0x20, 0x43, 0x24, 0x15, + 0x27, 0x15, 0x1B, 0x35, 0x1B, 0x0F, 0x1A, 0x0E, 0x05, 0x0B, 0x05, 0x04, + 0x05, 0x02, 0x02, 0x04, 0x03, 0x06, 0x02, 0x04, 0x02, 0x06, 0x03, 0x03, + 0x12, 0x1A, 0x03, 0x02, 0x05, 0x03, 0x01, 0x05, 0x02, 0x05, 0x08, 0x04, + 0x03, 0x07, 0x02, 0x02, 0x05, 0x05, 0x0A, 0x22, 0x18, 0x0B, 0x1A, 0x0D, + 0x06, 0x14, 0x01, 0x02, 0x02, 0x05, 0x01, 0x01, 0x01, 0x06, 0x03, 0x07, + 0x04, 0x06, 0x0B, 0x05, 0x0F, 0x1B, 0x0D, 0x2F, 0x43, 0x06, 0x03, 0x07, + 0x04, 0x01, 0x07, 0x03, 0x04, 0x08, 0x04, 0x07, 0x14, 0x0B, 0x0D, 0x1A, + 0x0D, 0x09, 0x0E, 0x07, 0x1C, 0x39, 0x1C, 0x03, 0x04, 0x02, 0x02, 0x02, + 0x01, 0x02, 0x05, 0x03, 0x0E, 0x1C, 0x0E, 0x12, 0x25, 0x13, 0x0D, 0x09, + 0x02, 0x01, 0x11, 0x04, 0x01, 0x02, 0x02, 0x03, 0x06, 0x02, 0x06, 0x0B, + 0x05, 0x05, 0x09, 0x03, 0x15, 0x2A, 0x15, 0x03, 0x05, 0x03, 0x06, 0x0D, + 0x05, 0x02, 0x06, 0x01, 0x07, 0x0E, 0x07, 0x10, 0x22, 0x11, 0x05, 0x0B, + 0x05, 0x02, 0x08, 0x01, 0x09, 0x11, 0x09, 0x04, 0x08, 0x04, 0x04, 0x10, + 0x05, 0x0E, 0x1B, 0x0E, 0x0E, 0x1E, 0x0E, 0x1B, 0x36, 0x1B, 0x15, 0x2D, + 0x15, 0x0B, 0x18, 0x0B, 0x0C, 0x1A, 0x0D, 0x16, 0x28, 0x15, 0x07, 0x01, + 0x0C, 0xFE, 0x7E, 0x04, 0x09, 0x08, 0x05, 0x0E, 0x05, 0x06, 0x04, 0x04, + 0x04, 0x08, 0x05, 0x04, 0x11, 0x05, 0x38, 0x05, 0x02, 0x03, 0x05, 0x12, + 0x06, 0x03, 0x0E, 0x03, 0x07, 0x0E, 0x07, 0x03, 0x05, 0x03, 0x44, 0x03, + 0x06, 0x04, 0x07, 0x0F, 0x08, 0x04, 0x04, 0x02, 0x08, 0x02, 0x07, 0x0F, + 0x08, 0x03, 0x01, 0x01, 0x01, 0xE3, 0x03, 0x05, 0x01, 0x01, 0x10, 0x05, + 0x13, 0x1E, 0x08, 0x05, 0x01, 0x01, 0x09, 0x02, 0x01, 0x01, 0x06, 0x02, + 0x04, 0x01, 0x01, 0x03, 0x03, 0x03, 0x07, 0x03, 0x04, 0x03, 0x05, 0x05, + 0x08, 0x05, 0x05, 0x13, 0x06, 0x05, 0x12, 0x03, 0x01, 0x04, 0x02, 0x06, + 0x02, 0x02, 0x06, 0x03, 0x0C, 0x19, 0x0D, 0x13, 0x26, 0x13, 0x23, 0x40, + 0x1B, 0x0D, 0x16, 0x0A, 0x04, 0x0D, 0x09, 0x06, 0x0D, 0x05, 0x03, 0x04, + 0x03, 0x05, 0x03, 0x02, 0x01, 0x04, 0x01, 0x07, 0x02, 0x09, 0x15, 0x0B, + 0x28, 0x70, 0x3E, 0x1D, 0x38, 0x1C, 0x06, 0x06, 0x04, 0x07, 0x0E, 0x07, + 0x0A, 0x19, 0x05, 0x05, 0x0B, 0x05, 0x03, 0x0D, 0x06, 0x17, 0x2E, 0x17, + 0x02, 0x04, 0x03, 0x06, 0x05, 0x01, 0x02, 0x01, 0x06, 0x0A, 0x06, 0x07, + 0x0E, 0x07, 0x05, 0x06, 0x0F, 0x08, 0x05, 0x01, 0x07, 0x02, 0x04, 0x07, + 0x04, 0x07, 0x06, 0x02, 0x02, 0x03, 0x04, 0x1C, 0x38, 0x1C, 0x03, 0x08, + 0x03, 0x08, 0x03, 0x04, 0x02, 0x04, 0x0A, 0x05, 0x0B, 0x18, 0x0B, 0x04, + 0x08, 0x03, 0x02, 0x02, 0x01, 0x0C, 0x19, 0x0C, 0x05, 0x0A, 0x04, 0x04, + 0x03, 0x01, 0x04, 0x08, 0x03, 0x02, 0x05, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x05, 0x03, 0x05, 0x06, 0x07, 0x0E, 0x07, 0x0B, 0x1F, 0x0E, 0x08, + 0x1F, 0x06, 0x0A, 0x08, 0x04, 0x03, 0x02, 0x07, 0x02, 0x0C, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x07, 0x03, 0x06, 0x01, 0x07, 0x03, 0x05, 0x08, 0x03, + 0x03, 0x02, 0x09, 0x04, 0x07, 0x04, 0x02, 0x03, 0x01, 0x1A, 0x02, 0x01, + 0x01, 0x01, 0x03, 0x01, 0x0E, 0x01, 0x01, 0x02, 0x08, 0x01, 0x00, 0x00, + 0x00, 0x06, 0x00, 0x00, 0xFF, 0xC0, 0x04, 0x00, 0x03, 0xC0, 0x00, 0x17, + 0x00, 0x1F, 0x00, 0x27, 0x00, 0x2F, 0x00, 0x37, 0x00, 0x3F, 0x00, 0x00, + 0x01, 0x15, 0x23, 0x0E, 0x01, 0x07, 0x15, 0x23, 0x35, 0x2E, 0x01, 0x27, + 0x23, 0x35, 0x33, 0x3E, 0x01, 0x37, 0x35, 0x33, 0x15, 0x1E, 0x01, 0x17, + 0x23, 0x2E, 0x01, 0x27, 0x15, 0x1E, 0x01, 0x17, 0x06, 0x32, 0x36, 0x34, + 0x26, 0x22, 0x06, 0x14, 0x11, 0x0E, 0x01, 0x07, 0x33, 0x3E, 0x01, 0x37, + 0x07, 0x1E, 0x01, 0x17, 0x35, 0x2E, 0x01, 0x27, 0x17, 0x3E, 0x01, 0x37, + 0x23, 0x0E, 0x01, 0x07, 0x04, 0x00, 0x65, 0x15, 0xC0, 0x86, 0x80, 0x86, + 0xC0, 0x15, 0x65, 0x65, 0x15, 0xC0, 0x86, 0x80, 0x86, 0xC0, 0x15, 0x82, + 0x13, 0x75, 0x51, 0x29, 0x3E, 0x0E, 0xCF, 0x34, 0x26, 0x26, 0x34, 0x26, + 0x51, 0x75, 0x13, 0x64, 0x0E, 0x3E, 0x29, 0xD9, 0x13, 0x75, 0x51, 0x29, + 0x3E, 0x0E, 0xF5, 0x51, 0x75, 0x13, 0x64, 0x0E, 0x3E, 0x29, 0x02, 0x00, + 0x80, 0x86, 0xC0, 0x15, 0x65, 0x65, 0x15, 0xC0, 0x86, 0x80, 0x86, 0xC0, + 0x15, 0x65, 0x65, 0x15, 0xC0, 0x86, 0x51, 0x75, 0x13, 0x64, 0x0E, 0x3E, + 0x29, 0x80, 0x26, 0x34, 0x26, 0x26, 0x34, 0x01, 0x33, 0x13, 0x75, 0x51, + 0x29, 0x3E, 0x0E, 0xF5, 0x51, 0x75, 0x13, 0x64, 0x0E, 0x3E, 0x29, 0xD9, + 0x13, 0x75, 0x51, 0x29, 0x3E, 0x0E, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, + 0xFF, 0xC0, 0x04, 0x00, 0x03, 0xC0, 0x00, 0x07, 0x00, 0x0D, 0x00, 0x19, + 0x00, 0x25, 0x00, 0x31, 0x00, 0x3D, 0x00, 0x49, 0x00, 0x55, 0x00, 0x61, + 0x00, 0x6D, 0x00, 0x00, 0x00, 0x32, 0x16, 0x14, 0x06, 0x22, 0x26, 0x34, + 0x01, 0x32, 0x36, 0x34, 0x26, 0x23, 0x02, 0x32, 0x16, 0x1D, 0x01, 0x14, + 0x06, 0x22, 0x26, 0x3D, 0x01, 0x34, 0x12, 0x22, 0x26, 0x3D, 0x01, 0x34, + 0x36, 0x32, 0x16, 0x1D, 0x01, 0x14, 0x01, 0x32, 0x16, 0x14, 0x06, 0x2B, + 0x01, 0x22, 0x26, 0x34, 0x36, 0x33, 0x04, 0x14, 0x06, 0x2B, 0x01, 0x22, + 0x26, 0x34, 0x36, 0x3B, 0x01, 0x32, 0x01, 0x17, 0x16, 0x14, 0x06, 0x22, + 0x2F, 0x01, 0x26, 0x34, 0x36, 0x32, 0x01, 0x27, 0x26, 0x34, 0x36, 0x32, + 0x1F, 0x01, 0x16, 0x14, 0x06, 0x22, 0x25, 0x06, 0x22, 0x26, 0x34, 0x3F, + 0x01, 0x36, 0x32, 0x16, 0x14, 0x07, 0x01, 0x36, 0x32, 0x16, 0x14, 0x0F, + 0x01, 0x06, 0x22, 0x26, 0x34, 0x37, 0x01, 0x96, 0xD4, 0x96, 0x96, 0xD4, + 0x96, 0x01, 0x00, 0x42, 0x5E, 0x5E, 0x42, 0x1A, 0x34, 0x26, 0x26, 0x34, + 0x26, 0x5A, 0x34, 0x26, 0x26, 0x34, 0x26, 0x01, 0x80, 0x1A, 0x26, 0x26, + 0x1A, 0x40, 0x1A, 0x26, 0x26, 0x1A, 0xFD, 0x40, 0x26, 0x1A, 0x40, 0x1A, + 0x26, 0x26, 0x1A, 0x40, 0x1A, 0x02, 0xA3, 0x2D, 0x13, 0x26, 0x35, 0x12, + 0x2E, 0x12, 0x25, 0x35, 0xFD, 0x99, 0x2D, 0x13, 0x26, 0x35, 0x12, 0x2E, + 0x12, 0x25, 0x35, 0x02, 0x67, 0x13, 0x35, 0x25, 0x12, 0x2E, 0x12, 0x35, + 0x26, 0x13, 0xFD, 0x59, 0x13, 0x35, 0x25, 0x12, 0x2E, 0x12, 0x35, 0x26, + 0x13, 0x02, 0xC0, 0x96, 0xD4, 0x96, 0x96, 0xD4, 0xFE, 0xF6, 0x5E, 0x84, + 0x5E, 0xFE, 0x20, 0x26, 0x1A, 0x40, 0x1A, 0x26, 0x26, 0x1A, 0x40, 0x1A, + 0x02, 0xA6, 0x26, 0x1A, 0x40, 0x1A, 0x26, 0x26, 0x1A, 0x40, 0x1A, 0xFE, + 0xDA, 0x26, 0x34, 0x26, 0x26, 0x34, 0x26, 0x26, 0x34, 0x26, 0x26, 0x34, + 0x26, 0xFE, 0xDE, 0x2E, 0x12, 0x35, 0x26, 0x13, 0x2D, 0x13, 0x35, 0x25, + 0x01, 0xB2, 0x2E, 0x12, 0x35, 0x26, 0x13, 0x2D, 0x13, 0x35, 0x25, 0x12, + 0x12, 0x25, 0x35, 0x13, 0x2D, 0x13, 0x26, 0x35, 0x12, 0xFE, 0x0E, 0x12, + 0x25, 0x35, 0x13, 0x2D, 0x13, 0x26, 0x35, 0x12, 0x00, 0x03, 0x00, 0x4E, + 0xFF, 0xC2, 0x03, 0x95, 0x03, 0xBA, 0x00, 0x13, 0x00, 0x1E, 0x00, 0x22, + 0x00, 0x00, 0x37, 0x30, 0x01, 0x36, 0x37, 0x36, 0x3F, 0x01, 0x17, 0x30, + 0x07, 0x06, 0x07, 0x0E, 0x01, 0x0F, 0x01, 0x06, 0x07, 0x01, 0x27, 0x17, + 0x07, 0x30, 0x27, 0x26, 0x27, 0x2E, 0x01, 0x3D, 0x01, 0x01, 0x25, 0x17, + 0x03, 0x72, 0x01, 0x62, 0x04, 0x20, 0x10, 0x0B, 0x3F, 0x82, 0x26, 0x02, + 0x02, 0x07, 0x08, 0x02, 0x01, 0x01, 0x10, 0xFE, 0xA8, 0xD2, 0xC1, 0x12, + 0x29, 0x33, 0x26, 0x1D, 0x1E, 0x02, 0x18, 0x01, 0x00, 0x2E, 0xAC, 0x84, + 0x01, 0xC1, 0x05, 0x16, 0x0B, 0x0A, 0x3B, 0x6B, 0x33, 0x05, 0x03, 0x0A, + 0x19, 0x06, 0x07, 0x02, 0x28, 0xFE, 0x40, 0x7C, 0x98, 0x11, 0x05, 0x0C, + 0x1C, 0x15, 0x36, 0x10, 0x10, 0x02, 0x6A, 0xF5, 0x26, 0xFE, 0xC9, 0x00, + 0x00, 0x04, 0x00, 0x00, 0xFF, 0xC0, 0x04, 0x00, 0x03, 0xC0, 0x00, 0x27, + 0x00, 0x2F, 0x00, 0x7F, 0x00, 0x87, 0x00, 0x00, 0x25, 0x16, 0x1F, 0x01, + 0x15, 0x07, 0x06, 0x07, 0x17, 0x07, 0x27, 0x06, 0x0F, 0x01, 0x23, 0x27, + 0x26, 0x27, 0x07, 0x27, 0x37, 0x26, 0x2F, 0x01, 0x35, 0x37, 0x36, 0x37, + 0x27, 0x37, 0x17, 0x36, 0x3F, 0x01, 0x33, 0x17, 0x16, 0x17, 0x37, 0x17, + 0x06, 0x32, 0x36, 0x34, 0x26, 0x22, 0x06, 0x14, 0x01, 0x07, 0x06, 0x07, + 0x17, 0x07, 0x27, 0x06, 0x07, 0x17, 0x07, 0x27, 0x06, 0x07, 0x17, 0x07, + 0x27, 0x06, 0x0F, 0x01, 0x23, 0x27, 0x26, 0x27, 0x07, 0x27, 0x37, 0x26, + 0x27, 0x07, 0x27, 0x37, 0x26, 0x27, 0x07, 0x27, 0x37, 0x26, 0x2F, 0x01, + 0x35, 0x37, 0x36, 0x37, 0x27, 0x37, 0x17, 0x36, 0x37, 0x27, 0x37, 0x17, + 0x36, 0x37, 0x27, 0x37, 0x17, 0x36, 0x3F, 0x01, 0x33, 0x17, 0x16, 0x17, + 0x37, 0x17, 0x07, 0x16, 0x17, 0x37, 0x17, 0x07, 0x16, 0x17, 0x37, 0x17, + 0x07, 0x16, 0x1F, 0x01, 0x04, 0x32, 0x36, 0x34, 0x26, 0x22, 0x06, 0x14, + 0x01, 0x6C, 0x09, 0x05, 0x46, 0x46, 0x05, 0x09, 0x29, 0x2D, 0x3A, 0x10, + 0x12, 0x0C, 0x40, 0x0C, 0x12, 0x10, 0x3A, 0x2D, 0x29, 0x09, 0x05, 0x46, + 0x46, 0x05, 0x09, 0x29, 0x2D, 0x3A, 0x10, 0x12, 0x0C, 0x40, 0x0C, 0x12, + 0x10, 0x3A, 0x2D, 0xCF, 0x34, 0x26, 0x26, 0x34, 0x26, 0x03, 0x60, 0x43, + 0x02, 0x03, 0x39, 0x18, 0x43, 0x06, 0x08, 0x27, 0x2D, 0x38, 0x0A, 0x0A, + 0x0E, 0x3B, 0x25, 0x0C, 0x0C, 0x0C, 0x40, 0x0C, 0x0D, 0x0B, 0x25, 0x3B, + 0x0E, 0x0A, 0x0A, 0x38, 0x2E, 0x27, 0x07, 0x06, 0x43, 0x19, 0x3A, 0x03, + 0x02, 0x43, 0x43, 0x02, 0x03, 0x3A, 0x19, 0x43, 0x06, 0x07, 0x27, 0x2E, + 0x38, 0x09, 0x0B, 0x0E, 0x3B, 0x25, 0x0C, 0x0C, 0x0C, 0x40, 0x0C, 0x0D, + 0x0B, 0x25, 0x3B, 0x0E, 0x09, 0x0B, 0x38, 0x2D, 0x27, 0x07, 0x07, 0x43, + 0x18, 0x39, 0x03, 0x02, 0x43, 0xFE, 0x66, 0x74, 0x51, 0x51, 0x74, 0x51, + 0xEE, 0x10, 0x12, 0x0C, 0x40, 0x0C, 0x12, 0x10, 0x3A, 0x2D, 0x29, 0x09, + 0x05, 0x46, 0x46, 0x05, 0x09, 0x29, 0x2D, 0x3A, 0x10, 0x12, 0x0C, 0x40, + 0x0C, 0x12, 0x10, 0x3A, 0x2D, 0x29, 0x09, 0x05, 0x46, 0x46, 0x05, 0x09, + 0x29, 0x2D, 0xC8, 0x26, 0x34, 0x26, 0x26, 0x34, 0x01, 0xBA, 0x0C, 0x0D, + 0x0B, 0x25, 0x3B, 0x0E, 0x0A, 0x0A, 0x38, 0x2E, 0x27, 0x07, 0x06, 0x43, + 0x19, 0x3A, 0x03, 0x02, 0x43, 0x43, 0x02, 0x03, 0x3A, 0x19, 0x43, 0x06, + 0x07, 0x27, 0x2E, 0x38, 0x0A, 0x0A, 0x0E, 0x3B, 0x25, 0x0C, 0x0C, 0x0C, + 0x40, 0x0C, 0x0D, 0x0B, 0x25, 0x3B, 0x0E, 0x0A, 0x0A, 0x38, 0x2E, 0x27, + 0x07, 0x06, 0x43, 0x19, 0x3A, 0x03, 0x02, 0x43, 0x43, 0x02, 0x03, 0x3A, + 0x19, 0x43, 0x06, 0x07, 0x27, 0x2E, 0x38, 0x0A, 0x0A, 0x0E, 0x3B, 0x25, + 0x0C, 0x0C, 0x0C, 0xAB, 0x51, 0x74, 0x51, 0x51, 0x74, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0C, 0x00, 0x96, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x0A, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x07, 0x00, 0x31, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x03, 0x00, 0x25, 0x00, 0x85, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x0A, 0x00, 0xC1, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x05, 0x00, 0x0B, 0x00, 0xE4, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x06, 0x00, 0x0A, 0x01, 0x06, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x01, 0x00, 0x14, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x02, 0x00, 0x0E, 0x00, 0x21, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x03, 0x00, 0x4A, 0x00, 0x39, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x04, 0x00, 0x14, 0x00, 0xAB, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x05, 0x00, 0x16, 0x00, 0xCC, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, + 0x00, 0x06, 0x00, 0x14, 0x00, 0xF0, 0x00, 0x75, 0x00, 0x6E, 0x00, 0x64, + 0x00, 0x65, 0x00, 0x66, 0x00, 0x65, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, + 0x00, 0x64, 0x00, 0x00, 0x75, 0x6E, 0x64, 0x65, 0x66, 0x65, 0x61, 0x74, + 0x65, 0x64, 0x00, 0x00, 0x52, 0x00, 0x65, 0x00, 0x67, 0x00, 0x75, 0x00, + 0x6C, 0x00, 0x61, 0x00, 0x72, 0x00, 0x00, 0x52, 0x65, 0x67, 0x75, 0x6C, + 0x61, 0x72, 0x00, 0x00, 0x46, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x74, 0x00, + 0x46, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x67, 0x00, 0x65, 0x00, 0x20, 0x00, + 0x32, 0x00, 0x2E, 0x00, 0x30, 0x00, 0x20, 0x00, 0x3A, 0x00, 0x20, 0x00, + 0x75, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x65, 0x00, 0x66, 0x00, 0x65, 0x00, + 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x64, 0x00, 0x20, 0x00, 0x3A, 0x00, + 0x20, 0x00, 0x33, 0x00, 0x2D, 0x00, 0x33, 0x00, 0x2D, 0x00, 0x32, 0x00, + 0x30, 0x00, 0x31, 0x00, 0x37, 0x00, 0x00, 0x46, 0x6F, 0x6E, 0x74, 0x46, + 0x6F, 0x72, 0x67, 0x65, 0x20, 0x32, 0x2E, 0x30, 0x20, 0x3A, 0x20, 0x75, + 0x6E, 0x64, 0x65, 0x66, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x3A, 0x20, + 0x33, 0x2D, 0x33, 0x2D, 0x32, 0x30, 0x31, 0x37, 0x00, 0x00, 0x75, 0x00, + 0x6E, 0x00, 0x64, 0x00, 0x65, 0x00, 0x66, 0x00, 0x65, 0x00, 0x61, 0x00, + 0x74, 0x00, 0x65, 0x00, 0x64, 0x00, 0x00, 0x75, 0x6E, 0x64, 0x65, 0x66, + 0x65, 0x61, 0x74, 0x65, 0x64, 0x00, 0x00, 0x56, 0x00, 0x65, 0x00, 0x72, + 0x00, 0x73, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x31, + 0x00, 0x2E, 0x00, 0x31, 0x00, 0x00, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, + 0x6E, 0x20, 0x31, 0x2E, 0x31, 0x00, 0x00, 0x75, 0x00, 0x6E, 0x00, 0x64, + 0x00, 0x65, 0x00, 0x66, 0x00, 0x65, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, + 0x00, 0x64, 0x00, 0x00, 0x75, 0x6E, 0x64, 0x65, 0x66, 0x65, 0x61, 0x74, + 0x65, 0x64, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x41, 0x00, 0x00, 0x01, 0x02, 0x00, 0x02, 0x01, 0x03, 0x00, 0x03, + 0x00, 0x13, 0x00, 0x14, 0x00, 0x15, 0x00, 0x16, 0x00, 0x17, 0x00, 0x18, + 0x00, 0x19, 0x00, 0x1A, 0x00, 0x1B, 0x00, 0x1C, 0x00, 0x24, 0x00, 0x25, + 0x00, 0x26, 0x00, 0x27, 0x00, 0x28, 0x00, 0x29, 0x00, 0x2A, 0x00, 0x2B, + 0x00, 0x2C, 0x00, 0x2D, 0x00, 0x2E, 0x00, 0x2F, 0x00, 0x30, 0x00, 0x31, + 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00, 0x35, 0x00, 0x36, 0x00, 0x37, + 0x00, 0x38, 0x00, 0x39, 0x00, 0x3A, 0x00, 0x3B, 0x00, 0x3C, 0x00, 0x3D, + 0x00, 0x3E, 0x00, 0x40, 0x00, 0x44, 0x00, 0x45, 0x00, 0x46, 0x00, 0x47, + 0x00, 0x48, 0x00, 0x49, 0x00, 0x4A, 0x00, 0x4B, 0x00, 0x4C, 0x00, 0x4D, + 0x00, 0x4E, 0x00, 0x4F, 0x00, 0x50, 0x00, 0x51, 0x00, 0x52, 0x00, 0x53, + 0x00, 0x54, 0x00, 0x55, 0x00, 0x56, 0x00, 0x57, 0x00, 0x58, 0x00, 0x59, + 0x06, 0x67, 0x6C, 0x79, 0x70, 0x68, 0x31, 0x07, 0x75, 0x6E, 0x69, 0x30, + 0x30, 0x30, 0x31, 0x00, 0x00, 0x01, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x0F, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x16, 0x00, 0x1E, + 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0xDA, 0x92, 0x03, 0xF7, 0x00, 0x00, 0x00, 0x00, 0xD2, 0xEB, 0xED, 0xCA, + 0x00, 0x00, 0x00, 0x00, 0xDB, 0x37, 0x81, 0xC2 +}; + +``` + +`imgui/imconfig.h`: + +```h +//----------------------------------------------------------------------------- +// USER IMPLEMENTATION +// This file contains compile-time options for ImGui. +// Other options (memory allocation overrides, callbacks, etc.) can be set at runtime via the ImGuiIO structure - ImGui::GetIO(). +//----------------------------------------------------------------------------- + +#pragma once + +//---- Define assertion handler. Defaults to calling assert(). +//#define IM_ASSERT(_EXPR) MyAssert(_EXPR) + +//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows. +//#define IMGUI_API __declspec( dllexport ) +//#define IMGUI_API __declspec( dllimport ) + +//---- Don't define obsolete functions names. Consider enabling from time to time or when updating to reduce like hood of using already obsolete function/names +//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS + +//---- Include imgui_user.h at the end of imgui.h +//#define IMGUI_INCLUDE_IMGUI_USER_H + +//---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions) +//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS +//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS + +//---- Don't implement demo windows functionality (ShowDemoWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty) +//---- It is very strongly recommended to NOT disable the demo windows. Please read the comment at the top of imgui_demo.cpp to learn why. +//#define IMGUI_DISABLE_DEMO_WINDOWS + +//---- Don't implement ImFormatString(), ImFormatStringV() so you can reimplement them yourself. +//#define IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS + +//---- Pack colors to BGRA instead of RGBA (remove need to post process vertex buffer in back ends) +//#define IMGUI_USE_BGRA_PACKED_COLOR + +//---- Implement STB libraries in a namespace to avoid linkage conflicts +//#define IMGUI_STB_NAMESPACE ImGuiStb + +//---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4. +/* +#define IM_VEC2_CLASS_EXTRA \ + ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \ + operator MyVec2() const { return MyVec2(x,y); } + +#define IM_VEC4_CLASS_EXTRA \ + ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ + operator MyVec4() const { return MyVec4(x,y,z,w); } +*/ + +//---- Use 32-bit vertex indices (instead of default: 16-bit) to allow meshes with more than 64K vertices +//#define ImDrawIdx unsigned int + +//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. +//---- e.g. create variants of the ImGui::Value() helper for your low-level math types, or your own widgets/helpers. +/* +namespace ImGui +{ + void Value(const char* prefix, const MyMatrix44& v, const char* float_format = NULL); +} +*/ + + +``` + +`imgui/imgui.cpp`: + +```cpp +// dear imgui, v1.54 WIP +// (main code and documentation) + +// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code. +// Newcomers, read 'Programmer guide' below for notes on how to setup Dear ImGui in your codebase. +// Get latest version at https://github.com/ocornut/imgui +// Releases change-log at https://github.com/ocornut/imgui/releases +// Gallery (please post your screenshots/video there!): https://github.com/ocornut/imgui/issues/1269 +// Developed by Omar Cornut and every direct or indirect contributors to the GitHub. +// This library is free but I need your support to sustain development and maintenance. +// If you work for a company, please consider financial support, see Readme. For individuals: https://www.patreon.com/imgui + +/* + + Index + - MISSION STATEMENT + - END-USER GUIDE + - PROGRAMMER GUIDE (read me!) + - Read first + - How to update to a newer version of Dear ImGui + - Getting started with integrating Dear ImGui in your code/engine + - API BREAKING CHANGES (read me when you update!) + - ISSUES & TODO LIST + - FREQUENTLY ASKED QUESTIONS (FAQ), TIPS + - How can I help? + - What is ImTextureID and how do I display an image? + - I integrated Dear ImGui in my engine and the text or lines are blurry.. + - I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around.. + - How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on labels/IDs. + - How can I tell when Dear ImGui wants my mouse/keyboard inputs VS when I can pass them to my application? + - How can I load a different font than the default? + - How can I easily use icons in my application? + - How can I load multiple fonts? + - How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic? + - How can I preserve my Dear ImGui context across reloading a DLL? (loss of the global/static variables) + - How can I use the drawing facilities without an ImGui window? (using ImDrawList API) + - ISSUES & TODO-LIST + - CODE + + + MISSION STATEMENT + ================= + + - Easy to use to create code-driven and data-driven tools + - Easy to use to create ad hoc short-lived tools and long-lived, more elaborate tools + - Easy to hack and improve + - Minimize screen real-estate usage + - Minimize setup and maintenance + - Minimize state storage on user side + - Portable, minimize dependencies, run on target (consoles, phones, etc.) + - Efficient runtime and memory consumption (NB- we do allocate when "growing" content e.g. creating a window, opening a tree node + for the first time, etc. but a typical frame won't allocate anything) + + Designed for developers and content-creators, not the typical end-user! Some of the weaknesses includes: + - Doesn't look fancy, doesn't animate + - Limited layout features, intricate layouts are typically crafted in code + + + END-USER GUIDE + ============== + + - Double-click on title bar to collapse window. + - Click upper right corner to close a window, available when 'bool* p_open' is passed to ImGui::Begin(). + - Click and drag on lower right corner to resize window (double-click to auto fit window to its contents). + - Click and drag on any empty space to move window. + - TAB/SHIFT+TAB to cycle through keyboard editable fields. + - CTRL+Click on a slider or drag box to input value as text. + - Use mouse wheel to scroll. + - Text editor: + - Hold SHIFT or use mouse to select text. + - CTRL+Left/Right to word jump. + - CTRL+Shift+Left/Right to select words. + - CTRL+A our Double-Click to select all. + - CTRL+X,CTRL+C,CTRL+V to use OS clipboard/ + - CTRL+Z,CTRL+Y to undo/redo. + - ESCAPE to revert text to its original value. + - You can apply arithmetic operators +,*,/ on numerical values. Use +- to subtract (because - would set a negative value!) + - Controls are automatically adjusted for OSX to match standard OSX text editing operations. + + + PROGRAMMER GUIDE + ================ + + READ FIRST + + - Read the FAQ below this section! + - Your code creates the UI, if your code doesn't run the UI is gone! == very dynamic UI, no construction/destructions steps, less data retention + on your side, no state duplication, less sync, less bugs. + - Call and read ImGui::ShowDemoWindow() for demo code demonstrating most features. + - You can learn about immediate-mode gui principles at http://www.johno.se/book/imgui.html or watch http://mollyrocket.com/861 + + HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI + + - Overwrite all the sources files except for imconfig.h (if you have made modification to your copy of imconfig.h) + - Read the "API BREAKING CHANGES" section (below). This is where we list occasional API breaking changes. + If a function/type has been renamed / or marked obsolete, try to fix the name in your code before it is permanently removed from the public API. + If you have a problem with a missing function/symbols, search for its name in the code, there will likely be a comment about it. + Please report any issue to the GitHub page! + - Try to keep your copy of dear imgui reasonably up to date. + + GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE + + - Add the Dear ImGui source files to your projects, using your preferred build system. + It is recommended you build the .cpp files as part of your project and not as a library. + - You can later customize the imconfig.h file to tweak some compilation time behavior, such as integrating imgui types with your own maths types. + - See examples/ folder for standalone sample applications. + - You may be able to grab and copy a ready made imgui_impl_*** file from the examples/. + - When using Dear ImGui, your programming IDE is your friend: follow the declaration of variables, functions and types to find comments about them. + + - Init: retrieve the ImGuiIO structure with ImGui::GetIO() and fill the fields marked 'Settings': at minimum you need to set io.DisplaySize + (application resolution). Later on you will fill your keyboard mapping, clipboard handlers, and other advanced features but for a basic + integration you don't need to worry about it all. + - Init: call io.Fonts->GetTexDataAsRGBA32(...), it will build the font atlas texture, then load the texture pixels into graphics memory. + - Every frame: + - In your main loop as early a possible, fill the IO fields marked 'Input' (e.g. mouse position, buttons, keyboard info, etc.) + - Call ImGui::NewFrame() to begin the frame + - You can use any ImGui function you want between NewFrame() and Render() + - Call ImGui::Render() as late as you can to end the frame and finalize render data. it will call your io.RenderDrawListFn handler. + (Even if you don't render, call Render() and ignore the callback, or call EndFrame() instead. Otherwhise some features will break) + - All rendering information are stored into command-lists until ImGui::Render() is called. + - Dear ImGui never touches or knows about your GPU state. the only function that knows about GPU is the RenderDrawListFn handler that you provide. + - Effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render" phases + of your own application. + - Refer to the examples applications in the examples/ folder for instruction on how to setup your code. + - A minimal application skeleton may be: + + // Application init + ImGuiIO& io = ImGui::GetIO(); + io.DisplaySize.x = 1920.0f; + io.DisplaySize.y = 1280.0f; + io.RenderDrawListsFn = MyRenderFunction; // Setup a render function, or set to NULL and call GetDrawData() after Render() to access render data. + // TODO: Fill others settings of the io structure later. + + // Load texture atlas (there is a default font so you don't need to care about choosing a font yet) + unsigned char* pixels; + int width, height; + io.Fonts->GetTexDataAsRGBA32(pixels, &width, &height); + // TODO: At this points you've got the texture data and you need to upload that your your graphic system: + MyTexture* texture = MyEngine::CreateTextureFromMemoryPixels(pixels, width, height, TEXTURE_TYPE_RGBA) + // TODO: Store your texture pointer/identifier (whatever your engine uses) in 'io.Fonts->TexID'. This will be passed back to your via the renderer. + io.Fonts->TexID = (void*)texture; + + // Application main loop + while (true) + { + // Setup low-level inputs (e.g. on Win32, GetKeyboardState(), or write to those fields from your Windows message loop handlers, etc.) + ImGuiIO& io = ImGui::GetIO(); + io.DeltaTime = 1.0f/60.0f; + io.MousePos = mouse_pos; + io.MouseDown[0] = mouse_button_0; + io.MouseDown[1] = mouse_button_1; + + // Call NewFrame(), after this point you can use ImGui::* functions anytime + ImGui::NewFrame(); + + // Most of your application code here + MyGameUpdate(); // may use any ImGui functions, e.g. ImGui::Begin("My window"); ImGui::Text("Hello, world!"); ImGui::End(); + MyGameRender(); // may use any ImGui functions as well! + + // Render & swap video buffers + ImGui::Render(); + SwapBuffers(); + } + + - A minimal render function skeleton may be: + + void void MyRenderFunction(ImDrawData* draw_data)(ImDrawData* draw_data) + { + // TODO: Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled + // TODO: Setup viewport, orthographic projection matrix + // TODO: Setup shader: vertex { float2 pos, float2 uv, u32 color }, fragment shader sample color from 1 texture, multiply by vertex color. + for (int n = 0; n < draw_data->CmdListsCount; n++) + { + const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; // vertex buffer generated by ImGui + const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; // index buffer generated by ImGui + for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) + { + const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; + if (pcmd->UserCallback) + { + pcmd->UserCallback(cmd_list, pcmd); + } + else + { + // The texture for the draw call is specified by pcmd->TextureId. + // The vast majority of draw calls with use the imgui texture atlas, which value you have set yourself during initialization. + MyEngineBindTexture(pcmd->TextureId); + + // We are using scissoring to clip some objects. All low-level graphics API supports it. + // If your engine doesn't support scissoring yet, you will get some small glitches (some elements outside their bounds) which you can fix later. + MyEngineScissor((int)pcmd->ClipRect.x, (int)pcmd->ClipRect.y, (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y)); + + // Render 'pcmd->ElemCount/3' indexed triangles. + // By default the indices ImDrawIdx are 16-bits, you can change them to 32-bits if your engine doesn't support 16-bits indices. + MyEngineDrawIndexedTriangles(pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer, vtx_buffer); + } + idx_buffer += pcmd->ElemCount; + } + } + } + + - The examples/ folders contains many functional implementation of the pseudo-code above. + - When calling NewFrame(), the 'io.WantCaptureMouse'/'io.WantCaptureKeyboard'/'io.WantTextInput' flags are updated. + They tell you if ImGui intends to use your inputs. So for example, if 'io.WantCaptureMouse' is set you would typically want to hide + mouse inputs from the rest of your application. Read the FAQ below for more information about those flags. + + + + API BREAKING CHANGES + ==================== + + Occasionally introducing changes that are breaking the API. The breakage are generally minor and easy to fix. + Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code. + Also read releases logs https://github.com/ocornut/imgui/releases for more details. + + - 2018/01/11 (1.54) - obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete). + - 2018/01/11 (1.54) - obsoleted IsAnyWindowFocused() in favor of IsWindowFocused(ImGuiFocusedFlags_AnyWindow). Kept redirection function (will obsolete). + - 2018/01/03 (1.54) - renamed ImGuiSizeConstraintCallback to ImGuiSizeCallback, ImGuiSizeConstraintCallbackData to ImGuiSizeCallbackData. + - 2017/12/29 (1.54) - removed CalcItemRectClosestPoint() which was weird and not really used by anyone except demo code. If you need it it's easy to replicate on your side. + - 2017/12/24 (1.53) - renamed the emblematic ShowTestWindow() function to ShowDemoWindow(). Kept redirection function (will obsolete). + - 2017/12/21 (1.53) - ImDrawList: renamed style.AntiAliasedShapes to style.AntiAliasedFill for consistency and as a way to explicitly break code that manipulate those flag at runtime. You can now manipulate ImDrawList::Flags + - 2017/12/21 (1.53) - ImDrawList: removed 'bool anti_aliased = true' final parameter of ImDrawList::AddPolyline() and ImDrawList::AddConvexPolyFilled(). Prefer manipulating ImDrawList::Flags if you need to toggle them during the frame. + - 2017/12/14 (1.53) - using the ImGuiWindowFlags_NoScrollWithMouse flag on a child window forwards the mouse wheel event to the parent window, unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set. + - 2017/12/13 (1.53) - renamed GetItemsLineHeightWithSpacing() to GetFrameHeightWithSpacing(). Kept redirection function (will obsolete). + - 2017/12/13 (1.53) - obsoleted IsRootWindowFocused() in favor of using IsWindowFocused(ImGuiFocusedFlags_RootWindow). Kept redirection function (will obsolete). + - obsoleted IsRootWindowOrAnyChildFocused() in favor of using IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows). Kept redirection function (will obsolete). + - 2017/12/12 (1.53) - renamed ImGuiTreeNodeFlags_AllowOverlapMode to ImGuiTreeNodeFlags_AllowItemOverlap. Kept redirection enum (will obsolete). + - 2017/12/10 (1.53) - removed SetNextWindowContentWidth(), prefer using SetNextWindowContentSize(). Kept redirection function (will obsolete). + - 2017/11/27 (1.53) - renamed ImGuiTextBuffer::append() helper to appendf(), appendv() to appendfv(). If you copied the 'Log' demo in your code, it uses appendv() so that needs to be renamed. + - 2017/11/18 (1.53) - Style, Begin: removed ImGuiWindowFlags_ShowBorders window flag. Borders are now fully set up in the ImGuiStyle structure (see e.g. style.FrameBorderSize, style.WindowBorderSize). Use ImGui::ShowStyleEditor() to look them up. + Please note that the style system will keep evolving (hopefully stabilizing in Q1 2018), and so custom styles will probably subtly break over time. It is recommended you use the StyleColorsClassic(), StyleColorsDark(), StyleColorsLight() functions. + - 2017/11/18 (1.53) - Style: removed ImGuiCol_ComboBg in favor of combo boxes using ImGuiCol_PopupBg for consistency. + - 2017/11/18 (1.53) - Style: renamed ImGuiCol_ChildWindowBg to ImGuiCol_ChildBg. + - 2017/11/18 (1.53) - Style: renamed style.ChildWindowRounding to style.ChildRounding, ImGuiStyleVar_ChildWindowRounding to ImGuiStyleVar_ChildRounding. + - 2017/11/02 (1.53) - obsoleted IsRootWindowOrAnyChildHovered() in favor of using IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows); + - 2017/10/24 (1.52) - renamed IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS to IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS for consistency. + - 2017/10/20 (1.52) - changed IsWindowHovered() default parameters behavior to return false if an item is active in another window (e.g. click-dragging item from another window to this window). You can use the newly introduced IsWindowHovered() flags to requests this specific behavior if you need it. + - 2017/10/20 (1.52) - marked IsItemHoveredRect()/IsMouseHoveringWindow() as obsolete, in favor of using the newly introduced flags for IsItemHovered() and IsWindowHovered(). See https://github.com/ocornut/imgui/issues/1382 for details. + removed the IsItemRectHovered()/IsWindowRectHovered() names introduced in 1.51 since they were merely more consistent names for the two functions we are now obsoleting. + - 2017/10/17 (1.52) - marked the old 5-parameters version of Begin() as obsolete (still available). Use SetNextWindowSize()+Begin() instead! + - 2017/10/11 (1.52) - renamed AlignFirstTextHeightToWidgets() to AlignTextToFramePadding(). Kept inline redirection function (will obsolete). + - 2017/09/25 (1.52) - removed SetNextWindowPosCenter() because SetNextWindowPos() now has the optional pivot information to do the same and more. Kept redirection function (will obsolete). + - 2017/08/25 (1.52) - io.MousePos needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing. Previously ImVec2(-1,-1) was enough but we now accept negative mouse coordinates. In your binding if you need to support unavailable mouse, make sure to replace "io.MousePos = ImVec2(-1,-1)" with "io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX)". + - 2017/08/22 (1.51) - renamed IsItemHoveredRect() to IsItemRectHovered(). Kept inline redirection function (will obsolete). -> (1.52) use IsItemHovered(ImGuiHoveredFlags_RectOnly)! + - renamed IsMouseHoveringAnyWindow() to IsAnyWindowHovered() for consistency. Kept inline redirection function (will obsolete). + - renamed IsMouseHoveringWindow() to IsWindowRectHovered() for consistency. Kept inline redirection function (will obsolete). + - 2017/08/20 (1.51) - renamed GetStyleColName() to GetStyleColorName() for consistency. + - 2017/08/20 (1.51) - added PushStyleColor(ImGuiCol idx, ImU32 col) overload, which _might_ cause an "ambiguous call" compilation error if you are using ImColor() with implicit cast. Cast to ImU32 or ImVec4 explicily to fix. + - 2017/08/15 (1.51) - marked the weird IMGUI_ONCE_UPON_A_FRAME helper macro as obsolete. prefer using the more explicit ImGuiOnceUponAFrame. + - 2017/08/15 (1.51) - changed parameter order for BeginPopupContextWindow() from (const char*,int buttons,bool also_over_items) to (const char*,int buttons,bool also_over_items). Note that most calls relied on default parameters completely. + - 2017/08/13 (1.51) - renamed ImGuiCol_Columns*** to ImGuiCol_Separator***. Kept redirection enums (will obsolete). + - 2017/08/11 (1.51) - renamed ImGuiSetCond_*** types and flags to ImGuiCond_***. Kept redirection enums (will obsolete). + - 2017/08/09 (1.51) - removed ValueColor() helpers, they are equivalent to calling Text(label) + SameLine() + ColorButton(). + - 2017/08/08 (1.51) - removed ColorEditMode() and ImGuiColorEditMode in favor of ImGuiColorEditFlags and parameters to the various Color*() functions. The SetColorEditOptions() allows to initialize default but the user can still change them with right-click context menu. + - changed prototype of 'ColorEdit4(const char* label, float col[4], bool show_alpha = true)' to 'ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0)', where passing flags = 0x01 is a safe no-op (hello dodgy backward compatibility!). - check and run the demo window, under "Color/Picker Widgets", to understand the various new options. + - changed prototype of rarely used 'ColorButton(ImVec4 col, bool small_height = false, bool outline_border = true)' to 'ColorButton(const char* desc_id, ImVec4 col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0))' + - 2017/07/20 (1.51) - removed IsPosHoveringAnyWindow(ImVec2), which was partly broken and misleading. ASSERT + redirect user to io.WantCaptureMouse + - 2017/05/26 (1.50) - removed ImFontConfig::MergeGlyphCenterV in favor of a more multipurpose ImFontConfig::GlyphOffset. + - 2017/05/01 (1.50) - renamed ImDrawList::PathFill() (rarely used directly) to ImDrawList::PathFillConvex() for clarity. + - 2016/11/06 (1.50) - BeginChild(const char*) now applies the stack id to the provided label, consistently with other functions as it should always have been. It shouldn't affect you unless (extremely unlikely) you were appending multiple times to a same child from different locations of the stack id. If that's the case, generate an id with GetId() and use it instead of passing string to BeginChild(). + - 2016/10/15 (1.50) - avoid 'void* user_data' parameter to io.SetClipboardTextFn/io.GetClipboardTextFn pointers. We pass io.ClipboardUserData to it. + - 2016/09/25 (1.50) - style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc. + - 2016/07/30 (1.50) - SameLine(x) with x>0.0f is now relative to left of column/group if any, and not always to left of window. This was sort of always the intent and hopefully breakage should be minimal. + - 2016/05/12 (1.49) - title bar (using ImGuiCol_TitleBg/ImGuiCol_TitleBgActive colors) isn't rendered over a window background (ImGuiCol_WindowBg color) anymore. + If your TitleBg/TitleBgActive alpha was 1.0f or you are using the default theme it will not affect you. + However if your TitleBg/TitleBgActive alpha was <1.0f you need to tweak your custom theme to readjust for the fact that we don't draw a WindowBg background behind the title bar. + This helper function will convert an old TitleBg/TitleBgActive color into a new one with the same visual output, given the OLD color and the OLD WindowBg color. + ImVec4 ConvertTitleBgCol(const ImVec4& win_bg_col, const ImVec4& title_bg_col) + { + float new_a = 1.0f - ((1.0f - win_bg_col.w) * (1.0f - title_bg_col.w)), k = title_bg_col.w / new_a; + return ImVec4((win_bg_col.x * win_bg_col.w + title_bg_col.x) * k, (win_bg_col.y * win_bg_col.w + title_bg_col.y) * k, (win_bg_col.z * win_bg_col.w + title_bg_col.z) * k, new_a); + } + If this is confusing, pick the RGB value from title bar from an old screenshot and apply this as TitleBg/TitleBgActive. Or you may just create TitleBgActive from a tweaked TitleBg color. + - 2016/05/07 (1.49) - removed confusing set of GetInternalState(), GetInternalStateSize(), SetInternalState() functions. Now using CreateContext(), DestroyContext(), GetCurrentContext(), SetCurrentContext(). + - 2016/05/02 (1.49) - renamed SetNextTreeNodeOpened() to SetNextTreeNodeOpen(), no redirection. + - 2016/05/01 (1.49) - obsoleted old signature of CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false) as extra parameters were badly designed and rarely used. You can replace the "default_open = true" flag in new API with CollapsingHeader(label, ImGuiTreeNodeFlags_DefaultOpen). + - 2016/04/26 (1.49) - changed ImDrawList::PushClipRect(ImVec4 rect) to ImDraw::PushClipRect(Imvec2 min,ImVec2 max,bool intersect_with_current_clip_rect=false). Note that higher-level ImGui::PushClipRect() is preferable because it will clip at logic/widget level, whereas ImDrawList::PushClipRect() only affect your renderer. + - 2016/04/03 (1.48) - removed style.WindowFillAlphaDefault setting which was redundant. Bake default BG alpha inside style.Colors[ImGuiCol_WindowBg] and all other Bg color values. (ref github issue #337). + - 2016/04/03 (1.48) - renamed ImGuiCol_TooltipBg to ImGuiCol_PopupBg, used by popups/menus and tooltips. popups/menus were previously using ImGuiCol_WindowBg. (ref github issue #337) + - 2016/03/21 (1.48) - renamed GetWindowFont() to GetFont(), GetWindowFontSize() to GetFontSize(). Kept inline redirection function (will obsolete). + - 2016/03/02 (1.48) - InputText() completion/history/always callbacks: if you modify the text buffer manually (without using DeleteChars()/InsertChars() helper) you need to maintain the BufTextLen field. added an assert. + - 2016/01/23 (1.48) - fixed not honoring exact width passed to PushItemWidth(), previously it would add extra FramePadding.x*2 over that width. if you had manual pixel-perfect alignment in place it might affect you. + - 2015/12/27 (1.48) - fixed ImDrawList::AddRect() which used to render a rectangle 1 px too large on each axis. + - 2015/12/04 (1.47) - renamed Color() helpers to ValueColor() - dangerously named, rarely used and probably to be made obsolete. + - 2015/08/29 (1.45) - with the addition of horizontal scrollbar we made various fixes to inconsistencies with dealing with cursor position. + GetCursorPos()/SetCursorPos() functions now include the scrolled amount. It shouldn't affect the majority of users, but take note that SetCursorPosX(100.0f) puts you at +100 from the starting x position which may include scrolling, not at +100 from the window left side. + GetContentRegionMax()/GetWindowContentRegionMin()/GetWindowContentRegionMax() functions allow include the scrolled amount. Typically those were used in cases where no scrolling would happen so it may not be a problem, but watch out! + - 2015/08/29 (1.45) - renamed style.ScrollbarWidth to style.ScrollbarSize + - 2015/08/05 (1.44) - split imgui.cpp into extra files: imgui_demo.cpp imgui_draw.cpp imgui_internal.h that you need to add to your project. + - 2015/07/18 (1.44) - fixed angles in ImDrawList::PathArcTo(), PathArcToFast() (introduced in 1.43) being off by an extra PI for no justifiable reason + - 2015/07/14 (1.43) - add new ImFontAtlas::AddFont() API. For the old AddFont***, moved the 'font_no' parameter of ImFontAtlas::AddFont** functions to the ImFontConfig structure. + you need to render your textured triangles with bilinear filtering to benefit from sub-pixel positioning of text. + - 2015/07/08 (1.43) - switched rendering data to use indexed rendering. this is saving a fair amount of CPU/GPU and enables us to get anti-aliasing for a marginal cost. + this necessary change will break your rendering function! the fix should be very easy. sorry for that :( + - if you are using a vanilla copy of one of the imgui_impl_XXXX.cpp provided in the example, you just need to update your copy and you can ignore the rest. + - the signature of the io.RenderDrawListsFn handler has changed! + ImGui_XXXX_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count) + became: + ImGui_XXXX_RenderDrawLists(ImDrawData* draw_data). + argument 'cmd_lists' -> 'draw_data->CmdLists' + argument 'cmd_lists_count' -> 'draw_data->CmdListsCount' + ImDrawList 'commands' -> 'CmdBuffer' + ImDrawList 'vtx_buffer' -> 'VtxBuffer' + ImDrawList n/a -> 'IdxBuffer' (new) + ImDrawCmd 'vtx_count' -> 'ElemCount' + ImDrawCmd 'clip_rect' -> 'ClipRect' + ImDrawCmd 'user_callback' -> 'UserCallback' + ImDrawCmd 'texture_id' -> 'TextureId' + - each ImDrawList now contains both a vertex buffer and an index buffer. For each command, render ElemCount/3 triangles using indices from the index buffer. + - if you REALLY cannot render indexed primitives, you can call the draw_data->DeIndexAllBuffers() method to de-index the buffers. This is slow and a waste of CPU/GPU. Prefer using indexed rendering! + - refer to code in the examples/ folder or ask on the GitHub if you are unsure of how to upgrade. please upgrade! + - 2015/07/10 (1.43) - changed SameLine() parameters from int to float. + - 2015/07/02 (1.42) - renamed SetScrollPosHere() to SetScrollFromCursorPos(). Kept inline redirection function (will obsolete). + - 2015/07/02 (1.42) - renamed GetScrollPosY() to GetScrollY(). Necessary to reduce confusion along with other scrolling functions, because positions (e.g. cursor position) are not equivalent to scrolling amount. + - 2015/06/14 (1.41) - changed ImageButton() default bg_col parameter from (0,0,0,1) (black) to (0,0,0,0) (transparent) - makes a difference when texture have transparence + - 2015/06/14 (1.41) - changed Selectable() API from (label, selected, size) to (label, selected, flags, size). Size override should have been rarely be used. Sorry! + - 2015/05/31 (1.40) - renamed GetWindowCollapsed() to IsWindowCollapsed() for consistency. Kept inline redirection function (will obsolete). + - 2015/05/31 (1.40) - renamed IsRectClipped() to IsRectVisible() for consistency. Note that return value is opposite! Kept inline redirection function (will obsolete). + - 2015/05/27 (1.40) - removed the third 'repeat_if_held' parameter from Button() - sorry! it was rarely used and inconsistent. Use PushButtonRepeat(true) / PopButtonRepeat() to enable repeat on desired buttons. + - 2015/05/11 (1.40) - changed BeginPopup() API, takes a string identifier instead of a bool. ImGui needs to manage the open/closed state of popups. Call OpenPopup() to actually set the "open" state of a popup. BeginPopup() returns true if the popup is opened. + - 2015/05/03 (1.40) - removed style.AutoFitPadding, using style.WindowPadding makes more sense (the default values were already the same). + - 2015/04/13 (1.38) - renamed IsClipped() to IsRectClipped(). Kept inline redirection function until 1.50. + - 2015/04/09 (1.38) - renamed ImDrawList::AddArc() to ImDrawList::AddArcFast() for compatibility with future API + - 2015/04/03 (1.38) - removed ImGuiCol_CheckHovered, ImGuiCol_CheckActive, replaced with the more general ImGuiCol_FrameBgHovered, ImGuiCol_FrameBgActive. + - 2014/04/03 (1.38) - removed support for passing -FLT_MAX..+FLT_MAX as the range for a SliderFloat(). Use DragFloat() or Inputfloat() instead. + - 2015/03/17 (1.36) - renamed GetItemBoxMin()/GetItemBoxMax()/IsMouseHoveringBox() to GetItemRectMin()/GetItemRectMax()/IsMouseHoveringRect(). Kept inline redirection function until 1.50. + - 2015/03/15 (1.36) - renamed style.TreeNodeSpacing to style.IndentSpacing, ImGuiStyleVar_TreeNodeSpacing to ImGuiStyleVar_IndentSpacing + - 2015/03/13 (1.36) - renamed GetWindowIsFocused() to IsWindowFocused(). Kept inline redirection function until 1.50. + - 2015/03/08 (1.35) - renamed style.ScrollBarWidth to style.ScrollbarWidth (casing) + - 2015/02/27 (1.34) - renamed OpenNextNode(bool) to SetNextTreeNodeOpened(bool, ImGuiSetCond). Kept inline redirection function until 1.50. + - 2015/02/27 (1.34) - renamed ImGuiSetCondition_*** to ImGuiSetCond_***, and _FirstUseThisSession becomes _Once. + - 2015/02/11 (1.32) - changed text input callback ImGuiTextEditCallback return type from void-->int. reserved for future use, return 0 for now. + - 2015/02/10 (1.32) - renamed GetItemWidth() to CalcItemWidth() to clarify its evolving behavior + - 2015/02/08 (1.31) - renamed GetTextLineSpacing() to GetTextLineHeightWithSpacing() + - 2015/02/01 (1.31) - removed IO.MemReallocFn (unused) + - 2015/01/19 (1.30) - renamed ImGuiStorage::GetIntPtr()/GetFloatPtr() to GetIntRef()/GetIntRef() because Ptr was conflicting with actual pointer storage functions. + - 2015/01/11 (1.30) - big font/image API change! now loads TTF file. allow for multiple fonts. no need for a PNG loader. + (1.30) - removed GetDefaultFontData(). uses io.Fonts->GetTextureData*() API to retrieve uncompressed pixels. + this sequence: + const void* png_data; + unsigned int png_size; + ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size); + // + became: + unsigned char* pixels; + int width, height; + io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); + // + io.Fonts->TexID = (your_texture_identifier); + you now have much more flexibility to load multiple TTF fonts and manage the texture buffer for internal needs. + it is now recommended that you sample the font texture with bilinear interpolation. + (1.30) - added texture identifier in ImDrawCmd passed to your render function (we can now render images). make sure to set io.Fonts->TexID. + (1.30) - removed IO.PixelCenterOffset (unnecessary, can be handled in user projection matrix) + (1.30) - removed ImGui::IsItemFocused() in favor of ImGui::IsItemActive() which handles all widgets + - 2014/12/10 (1.18) - removed SetNewWindowDefaultPos() in favor of new generic API SetNextWindowPos(pos, ImGuiSetCondition_FirstUseEver) + - 2014/11/28 (1.17) - moved IO.Font*** options to inside the IO.Font-> structure (FontYOffset, FontTexUvForWhite, FontBaseScale, FontFallbackGlyph) + - 2014/11/26 (1.17) - reworked syntax of IMGUI_ONCE_UPON_A_FRAME helper macro to increase compiler compatibility + - 2014/11/07 (1.15) - renamed IsHovered() to IsItemHovered() + - 2014/10/02 (1.14) - renamed IMGUI_INCLUDE_IMGUI_USER_CPP to IMGUI_INCLUDE_IMGUI_USER_INL and imgui_user.cpp to imgui_user.inl (more IDE friendly) + - 2014/09/25 (1.13) - removed 'text_end' parameter from IO.SetClipboardTextFn (the string is now always zero-terminated for simplicity) + - 2014/09/24 (1.12) - renamed SetFontScale() to SetWindowFontScale() + - 2014/09/24 (1.12) - moved IM_MALLOC/IM_REALLOC/IM_FREE preprocessor defines to IO.MemAllocFn/IO.MemReallocFn/IO.MemFreeFn + - 2014/08/30 (1.09) - removed IO.FontHeight (now computed automatically) + - 2014/08/30 (1.09) - moved IMGUI_FONT_TEX_UV_FOR_WHITE preprocessor define to IO.FontTexUvForWhite + - 2014/08/28 (1.09) - changed the behavior of IO.PixelCenterOffset following various rendering fixes + + + ISSUES & TODO-LIST + ================== + See TODO.txt + + + FREQUENTLY ASKED QUESTIONS (FAQ), TIPS + ====================================== + + Q: How can I help? + A: - If you are experienced enough with Dear ImGui and with C/C++, look at the todo list and see how you want/can help! + - Become a Patron/donate! Convince your company to become a Patron or provide serious funding for development time! See http://www.patreon.com/imgui + + Q: What is ImTextureID and how do I display an image? + A: ImTextureID is a void* used to pass renderer-agnostic texture references around until it hits your render function. + Dear ImGui knows nothing about what those bits represent, it just passes them around. It is up to you to decide what you want the void* to carry! + It could be an identifier to your OpenGL texture (cast GLuint to void*), a pointer to your custom engine material (cast MyMaterial* to void*), etc. + At the end of the chain, your renderer takes this void* to cast it back into whatever it needs to select a current texture to render. + Refer to examples applications, where each renderer (in a imgui_impl_xxxx.cpp file) is treating ImTextureID as a different thing. + (c++ tip: OpenGL uses integers to identify textures. You can safely store an integer into a void*, just cast it to void*, don't take it's address!) + To display a custom image/texture within an ImGui window, you may use ImGui::Image(), ImGui::ImageButton(), ImDrawList::AddImage() functions. + Dear ImGui will generate the geometry and draw calls using the ImTextureID that you passed and which your renderer can use. + It is your responsibility to get textures uploaded to your GPU. + + Q: I integrated Dear ImGui in my engine and the text or lines are blurry.. + A: In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f). + Also make sure your orthographic projection matrix and io.DisplaySize matches your actual framebuffer dimension. + + Q: I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around.. + A: You are probably mishandling the clipping rectangles in your render function. + Rectangles provided by ImGui are defined as (x1=left,y1=top,x2=right,y2=bottom) and NOT as (x1,y1,width,height). + + Q: Can I have multiple widgets with the same label? Can I have widget without a label? + A: Yes. A primer on the use of labels/IDs in Dear ImGui.. + + - Elements that are not clickable, such as Text() items don't need an ID. + + - Interactive widgets require state to be carried over multiple frames (most typically Dear ImGui often needs to remember what is + the "active" widget). to do so they need a unique ID. unique ID are typically derived from a string label, an integer index or a pointer. + + Button("OK"); // Label = "OK", ID = hash of "OK" + Button("Cancel"); // Label = "Cancel", ID = hash of "Cancel" + + - ID are uniquely scoped within windows, tree nodes, etc. so no conflict can happen if you have two buttons called "OK" + in two different windows or in two different locations of a tree. + + - If you have a same ID twice in the same location, you'll have a conflict: + + Button("OK"); + Button("OK"); // ID collision! Both buttons will be treated as the same. + + Fear not! this is easy to solve and there are many ways to solve it! + + - When passing a label you can optionally specify extra unique ID information within string itself. + This helps solving the simpler collision cases. Use "##" to pass a complement to the ID that won't be visible to the end-user: + + Button("Play"); // Label = "Play", ID = hash of "Play" + Button("Play##foo1"); // Label = "Play", ID = hash of "Play##foo1" (different from above) + Button("Play##foo2"); // Label = "Play", ID = hash of "Play##foo2" (different from above) + + - If you want to completely hide the label, but still need an ID: + + Checkbox("##On", &b); // Label = "", ID = hash of "##On" (no label!) + + - Occasionally/rarely you might want change a label while preserving a constant ID. This allows you to animate labels. + For example you may want to include varying information in a window title bar (and windows are uniquely identified by their ID.. obviously) + Use "###" to pass a label that isn't part of ID: + + Button("Hello###ID"; // Label = "Hello", ID = hash of "ID" + Button("World###ID"; // Label = "World", ID = hash of "ID" (same as above) + + sprintf(buf, "My game (%f FPS)###MyGame"); + Begin(buf); // Variable label, ID = hash of "MyGame" + + - Use PushID() / PopID() to create scopes and avoid ID conflicts within the same Window. + This is the most convenient way of distinguishing ID if you are iterating and creating many UI elements. + You can push a pointer, a string or an integer value. Remember that ID are formed from the concatenation of everything in the ID stack! + + for (int i = 0; i < 100; i++) + { + PushID(i); + Button("Click"); // Label = "Click", ID = hash of integer + "label" (unique) + PopID(); + } + + for (int i = 0; i < 100; i++) + { + MyObject* obj = Objects[i]; + PushID(obj); + Button("Click"); // Label = "Click", ID = hash of pointer + "label" (unique) + PopID(); + } + + for (int i = 0; i < 100; i++) + { + MyObject* obj = Objects[i]; + PushID(obj->Name); + Button("Click"); // Label = "Click", ID = hash of string + "label" (unique) + PopID(); + } + + - More example showing that you can stack multiple prefixes into the ID stack: + + Button("Click"); // Label = "Click", ID = hash of "Click" + PushID("node"); + Button("Click"); // Label = "Click", ID = hash of "node" + "Click" + PushID(my_ptr); + Button("Click"); // Label = "Click", ID = hash of "node" + ptr + "Click" + PopID(); + PopID(); + + - Tree nodes implicitly creates a scope for you by calling PushID(). + + Button("Click"); // Label = "Click", ID = hash of "Click" + if (TreeNode("node")) + { + Button("Click"); // Label = "Click", ID = hash of "node" + "Click" + TreePop(); + } + + - When working with trees, ID are used to preserve the open/close state of each tree node. + Depending on your use cases you may want to use strings, indices or pointers as ID. + e.g. when displaying a single object that may change over time (dynamic 1-1 relationship), using a static string as ID will preserve your + node open/closed state when the targeted object change. + e.g. when displaying a list of objects, using indices or pointers as ID will preserve the node open/closed state differently. + experiment and see what makes more sense! + + Q: How can I tell when Dear ImGui wants my mouse/keyboard inputs VS when I can pass them to my application? + A: You can read the 'io.WantCaptureMouse'/'io.WantCaptureKeyboard'/'ioWantTextInput' flags from the ImGuiIO structure. + - When 'io.WantCaptureMouse' or 'io.WantCaptureKeyboard' flags are set you may want to discard/hide the inputs from the rest of your application. + - When 'io.WantTextInput' is set to may want to notify your OS to popup an on-screen keyboard, if available (e.g. on a mobile phone, or console OS). + Preferably read the flags after calling ImGui::NewFrame() to avoid them lagging by one frame. But reading those flags before calling NewFrame() is + also generally ok, as the bool toggles fairly rarely and you don't generally expect to interact with either Dear ImGui or your application during + the same frame when that transition occurs. Dear ImGui is tracking dragging and widget activity that may occur outside the boundary of a window, + so 'io.WantCaptureMouse' is more accurate and correct than checking if a window is hovered. + (Advanced note: text input releases focus on Return 'KeyDown', so the following Return 'KeyUp' event that your application receive will typically + have 'io.WantCaptureKeyboard=false'. Depending on your application logic it may or not be inconvenient. You might want to track which key-downs + were for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.) + + Q: How can I load a different font than the default? (default is an embedded version of ProggyClean.ttf, rendered at size 13) + A: Use the font atlas to load the TTF/OTF file you want: + + ImGuiIO& io = ImGui::GetIO(); + io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels); + io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8() + + Q: How can I easily use icons in my application? + A: The most convenient and practical way is to merge an icon font such as FontAwesome inside you main font. Then you can refer to icons within your + strings. Read 'How can I load multiple fonts?' and the file 'extra_fonts/README.txt' for instructions and useful header files. + + Q: How can I load multiple fonts? + A: Use the font atlas to pack them into a single texture: + (Read extra_fonts/README.txt and the code in ImFontAtlas for more details.) + + ImGuiIO& io = ImGui::GetIO(); + ImFont* font0 = io.Fonts->AddFontDefault(); + ImFont* font1 = io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels); + ImFont* font2 = io.Fonts->AddFontFromFileTTF("myfontfile2.ttf", size_in_pixels); + io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8() + // the first loaded font gets used by default + // use ImGui::PushFont()/ImGui::PopFont() to change the font at runtime + + // Options + ImFontConfig config; + config.OversampleH = 3; + config.OversampleV = 1; + config.GlyphOffset.y -= 2.0f; // Move everything by 2 pixels up + config.GlyphExtraSpacing.x = 1.0f; // Increase spacing between characters + io.Fonts->LoadFromFileTTF("myfontfile.ttf", size_pixels, &config); + + // Combine multiple fonts into one (e.g. for icon fonts) + ImWchar ranges[] = { 0xf000, 0xf3ff, 0 }; + ImFontConfig config; + config.MergeMode = true; + io.Fonts->AddFontDefault(); + io.Fonts->LoadFromFileTTF("fontawesome-webfont.ttf", 16.0f, &config, ranges); // Merge icon font + io.Fonts->LoadFromFileTTF("myfontfile.ttf", size_pixels, NULL, &config, io.Fonts->GetGlyphRangesJapanese()); // Merge japanese glyphs + + Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic? + A: When loading a font, pass custom Unicode ranges to specify the glyphs to load. + + // Add default Japanese ranges + io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, io.Fonts->GetGlyphRangesJapanese()); + + // Or create your own custom ranges (e.g. for a game you can feed your entire game script and only build the characters the game need) + ImVector ranges; + ImFontAtlas::GlyphRangesBuilder builder; + builder.AddText("Hello world"); // Add a string (here "Hello world" contains 7 unique characters) + builder.AddChar(0x7262); // Add a specific character + builder.AddRanges(io.Fonts->GetGlyphRangesJapanese()); // Add one of the default ranges + builder.BuildRanges(&ranges); // Build the final result (ordered ranges with all the unique characters submitted) + io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, ranges.Data); + + All your strings needs to use UTF-8 encoding. In C++11 you can encode a string literal in UTF-8 by using the u8"hello" syntax. + Specifying literal in your source code using a local code page (such as CP-923 for Japanese or CP-1251 for Cyrillic) will NOT work! + Otherwise you can convert yourself to UTF-8 or load text data from file already saved as UTF-8. + + Text input: it is up to your application to pass the right character code to io.AddInputCharacter(). The applications in examples/ are doing that. + For languages using IME, on Windows you can copy the Hwnd of your application to io.ImeWindowHandle. + The default implementation of io.ImeSetInputScreenPosFn() on Windows will set your IME position correctly. + + Q: How can I preserve my Dear ImGui context across reloading a DLL? (loss of the global/static variables) + A: Create your own context 'ctx = CreateContext()' + 'SetCurrentContext(ctx)' and your own font atlas 'ctx->GetIO().Fonts = new ImFontAtlas()' + so you don't rely on the default globals. + + Q: How can I use the drawing facilities without an ImGui window? (using ImDrawList API) + A: The easiest way is to create a dummy window. Call Begin() with NoTitleBar|NoResize|NoMove|NoScrollbar|NoSavedSettings|NoInputs flag, + zero background alpha, then retrieve the ImDrawList* via GetWindowDrawList() and draw to it in any way you like. + You can also perfectly create a standalone ImDrawList instance _but_ you need ImGui to be initialized because ImDrawList pulls from ImGui + data to retrieve the coordinates of the white pixel. + + - tip: you can call Begin() multiple times with the same name during the same frame, it will keep appending to the same window. + this is also useful to set yourself in the context of another window (to get/set other settings) + - tip: you can create widgets without a Begin()/End() block, they will go in an implicit window called "Debug". + - tip: the ImGuiOnceUponAFrame helper will allow run the block of code only once a frame. You can use it to quickly add custom UI in the middle + of a deep nested inner loop in your code. + - tip: you can call Render() multiple times (e.g for VR renders). + - tip: call and read the ShowDemoWindow() code in imgui_demo.cpp for more example of how to use ImGui! + +*/ + +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include "imgui.h" +#define IMGUI_DEFINE_MATH_OPERATORS +#include "imgui_internal.h" + +#include // toupper, isprint +#include // NULL, malloc, free, qsort, atoi +#include // vsnprintf, sscanf, printf +#include // INT_MIN, INT_MAX +#include // string +#include +#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier +#include // intptr_t +#else +#include // intptr_t +#endif + +#ifdef _MSC_VER +#pragma warning (disable: 4127) // condition expression is constant +#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff) +#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen +#endif + +// Clang warnings with -Weverything +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning : unknown warning group '-Wformat-pedantic *' // not all warnings are known by all clang versions.. so ignoring warnings triggers new warnings on some configuration. great! +#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse. +#pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok. +#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning : format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code. +#pragma clang diagnostic ignored "-Wexit-time-destructors" // warning : declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals. +#pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference it. +#pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness // +#pragma clang diagnostic ignored "-Wformat-pedantic" // warning : format specifies type 'void *' but the argument has type 'xxxx *' // unreasonable, would lead to casting every %p arg to void*. probably enabled by -pedantic. +#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int' // +#elif defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used +#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size +#pragma GCC diagnostic ignored "-Wformat" // warning: format '%p' expects argument of type 'void*', but argument 6 has type 'ImGuiWindow*' +#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function +#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value +#pragma GCC diagnostic ignored "-Wcast-qual" // warning: cast from type 'xxxx' to type 'xxxx' casts away qualifiers +#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked +#endif + +//------------------------------------------------------------------------- +// Forward Declarations +//------------------------------------------------------------------------- + +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +static bool IsKeyPressedMap(ImGuiKey key, bool repeat = true); + +static ImFont* GetDefaultFont(); +static void SetCurrentFont(ImFont* font); +static void SetCurrentWindow(ImGuiWindow* window); +static void SetWindowScrollY(ImGuiWindow* window, float new_scroll_y); +static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond); +static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond); +static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond); +static ImGuiWindow* FindHoveredWindow(ImVec2 pos); +static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags); +static void CheckStacksSize(ImGuiWindow* window, bool write); +static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window); + +static void AddDrawListToRenderList(ImVector& out_render_list, ImDrawList* draw_list); +static void AddWindowToRenderList(ImVector& out_render_list, ImGuiWindow* window); +static void AddWindowToSortedBuffer(ImVector& out_sorted_windows, ImGuiWindow* window); + +static ImGuiWindowSettings* AddWindowSettings(const char* name); + +static void LoadIniSettingsFromDisk(const char* ini_filename); +static void LoadIniSettingsFromMemory(const char* buf); +static void SaveIniSettingsToDisk(const char* ini_filename); +static void SaveIniSettingsToMemory(ImVector& out_buf); +static void MarkIniSettingsDirty(ImGuiWindow* window); + +static ImRect GetVisibleRect(); + +static void CloseInactivePopups(ImGuiWindow* ref_window); +static void ClosePopupToLevel(int remaining); +static ImGuiWindow* GetFrontMostModalRootWindow(); + +static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback, void* user_data); +static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end); +static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL, ImVec2* out_offset = NULL, bool stop_on_new_line = false); + +static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, const char* display_format, char* buf, int buf_size); +static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, int decimal_precision, char* buf, int buf_size); +static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* value1, const void* value2); +static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format); + +namespace ImGui +{ +static void UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]); +static void FocusFrontMostActiveWindow(ImGuiWindow* ignore_window); +} + +//----------------------------------------------------------------------------- +// Platform dependent default implementations +//----------------------------------------------------------------------------- + +static const char* GetClipboardTextFn_DefaultImpl(void* user_data); +static void SetClipboardTextFn_DefaultImpl(void* user_data, const char* text); +static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y); + +//----------------------------------------------------------------------------- +// Context +//----------------------------------------------------------------------------- + +// Default font atlas storage. +// New contexts always point by default to this font atlas. It can be changed by reassigning the GetIO().Fonts variable. +static ImFontAtlas GImDefaultFontAtlas; + +// Default context storage + current context pointer. +// Implicitely used by all ImGui functions. Always assumed to be != NULL. Change to a different context by calling ImGui::SetCurrentContext() +// If you are hot-reloading this code in a DLL you will lose the static/global variables. Create your own context+font atlas instead of relying on those default (see FAQ entry "How can I preserve my ImGui context across reloading a DLL?"). +// ImGui is currently not thread-safe because of this variable. If you want thread-safety to allow N threads to access N different contexts, you might work around it by: +// - Having multiple instances of the ImGui code compiled inside different namespace (easiest/safest, if you have a finite number of contexts) +// - or: Changing this variable to be TLS. You may #define GImGui in imconfig.h for further custom hackery. Future development aim to make this context pointer explicit to all calls. Also read https://github.com/ocornut/imgui/issues/586 +#ifndef GImGui +static ImGuiContext GImDefaultContext; +ImGuiContext* GImGui = &GImDefaultContext; +#endif + +//----------------------------------------------------------------------------- +// User facing structures +//----------------------------------------------------------------------------- + +namespace ImGui { + bool is_input_allowed = true; +} + +ImGuiStyle::ImGuiStyle() +{ + Alpha = 1.0f; // Global alpha applies to everything in ImGui + WindowPadding = ImVec2(8,8); // Padding within a window + WindowRounding = 7.0f; // Radius of window corners rounding. set to 0.0f to have rectangular windows + WindowBorderSize = 0.0f; // Thickness of border around windows. Generally set to 0.0f or 1.0f. Other values not well tested. + WindowMinSize = ImVec2(32,32); // Minimum window size + WindowTitleAlign = ImVec2(0.0f,0.5f);// Alignment for title bar text + ChildRounding = 0.0f; // Radius of child window corners rounding. set to 0.0f to have rectangular child windows + ChildBorderSize = 1.0f; // Thickness of border around child windows. Generally set to 0.0f or 1.0f. Other values not well tested. + PopupRounding = 0.0f; // Radius of popup window corners rounding. set to 0.0f to have rectangular child windows + PopupBorderSize = 1.0f; // Thickness of border around popup or tooltip windows. Generally set to 0.0f or 1.0f. Other values not well tested. + FramePadding = ImVec2(4,3); // Padding within a framed rectangle (used by most widgets) + FrameRounding = 0.0f; // Radius of frame corners rounding. set to 0.0f to have rectangular frames (used by most widgets). + FrameBorderSize = 0.0f; // Thickness of border around frames. Generally set to 0.0f or 1.0f. Other values not well tested. + ItemSpacing = ImVec2(8,4); // Horizontal and vertical spacing between widgets/lines + ItemInnerSpacing = ImVec2(4,4); // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label) + TouchExtraPadding = ImVec2(0,0); // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much! + IndentSpacing = 21.0f; // Horizontal spacing when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2). + ColumnsMinSpacing = 6.0f; // Minimum horizontal spacing between two columns + ScrollbarSize = 16.0f; // Width of the vertical scrollbar, Height of the horizontal scrollbar + ScrollbarRounding = 9.0f; // Radius of grab corners rounding for scrollbar + GrabMinSize = 10.0f; // Minimum width/height of a grab box for slider/scrollbar + GrabRounding = 0.0f; // Radius of grabs corners rounding. set to 0.0f to have rectangular slider grabs. + ButtonTextAlign = ImVec2(0.5f,0.5f);// Alignment of button text when button is larger than text. + DisplayWindowPadding = ImVec2(22,22); // Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows. + DisplaySafeAreaPadding = ImVec2(4,4); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows. + AntiAliasedLines = true; // Enable anti-aliasing on lines/borders. Disable if you are really short on CPU/GPU. + AntiAliasedFill = true; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.) + CurveTessellationTol = 1.25f; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. + + ImGui::StyleColorsClassic(this); +} + +// To scale your entire UI (e.g. if you want your app to use High DPI or generally be DPI aware) you may use this helper function. Scaling the fonts is done separately and is up to you. +// Important: This operation is lossy because we round all sizes to integer. If you need to change your scale multiples, call this over a freshly initialized ImGuiStyle structure rather than scaling multiple times. +void ImGuiStyle::ScaleAllSizes(float scale_factor) +{ + WindowPadding = ImFloor(WindowPadding * scale_factor); + WindowRounding = ImFloor(WindowRounding * scale_factor); + WindowMinSize = ImFloor(WindowMinSize * scale_factor); + ChildRounding = ImFloor(ChildRounding * scale_factor); + PopupRounding = ImFloor(PopupRounding * scale_factor); + FramePadding = ImFloor(FramePadding * scale_factor); + FrameRounding = ImFloor(FrameRounding * scale_factor); + ItemSpacing = ImFloor(ItemSpacing * scale_factor); + ItemInnerSpacing = ImFloor(ItemInnerSpacing * scale_factor); + TouchExtraPadding = ImFloor(TouchExtraPadding * scale_factor); + IndentSpacing = ImFloor(IndentSpacing * scale_factor); + ColumnsMinSpacing = ImFloor(ColumnsMinSpacing * scale_factor); + ScrollbarSize = ImFloor(ScrollbarSize * scale_factor); + ScrollbarRounding = ImFloor(ScrollbarRounding * scale_factor); + GrabMinSize = ImFloor(GrabMinSize * scale_factor); + GrabRounding = ImFloor(GrabRounding * scale_factor); + DisplayWindowPadding = ImFloor(DisplayWindowPadding * scale_factor); + DisplaySafeAreaPadding = ImFloor(DisplaySafeAreaPadding * scale_factor); +} + +ImGuiIO::ImGuiIO() +{ + // Most fields are initialized with zero + memset(this, 0, sizeof(*this)); + + // Settings + DisplaySize = ImVec2(-1.0f, -1.0f); + DeltaTime = 1.0f/60.0f; + IniSavingRate = 5.0f; + IniFilename = "imgui.ini"; + LogFilename = "imgui_log.txt"; + MouseDoubleClickTime = 0.30f; + MouseDoubleClickMaxDist = 6.0f; + for (int i = 0; i < ImGuiKey_COUNT; i++) + KeyMap[i] = -1; + KeyRepeatDelay = 0.250f; + KeyRepeatRate = 0.050f; + UserData = NULL; + + Fonts = &GImDefaultFontAtlas; + FontGlobalScale = 1.0f; + FontDefault = NULL; + FontAllowUserScaling = false; + DisplayFramebufferScale = ImVec2(1.0f, 1.0f); + DisplayVisibleMin = DisplayVisibleMax = ImVec2(0.0f, 0.0f); + + // Advanced/subtle behaviors +#ifdef __APPLE__ + OptMacOSXBehaviors = true; // set Mac OS X style defaults based on __APPLE__ compile time flag +#else + OptMacOSXBehaviors = false; +#endif + OptCursorBlink = true; + + // Settings (User Functions) + RenderDrawListsFn = NULL; + MemAllocFn = malloc; + MemFreeFn = free; + GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations + SetClipboardTextFn = SetClipboardTextFn_DefaultImpl; + ClipboardUserData = NULL; + ImeSetInputScreenPosFn = ImeSetInputScreenPosFn_DefaultImpl; + ImeWindowHandle = NULL; + + // Input (NB: we already have memset zero the entire structure) + MousePos = ImVec2(-FLT_MAX, -FLT_MAX); + MousePosPrev = ImVec2(-FLT_MAX, -FLT_MAX); + MouseDragThreshold = 6.0f; + for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f; + for (int i = 0; i < IM_ARRAYSIZE(KeysDownDuration); i++) KeysDownDuration[i] = KeysDownDurationPrev[i] = -1.0f; +} + +// Pass in translated ASCII characters for text input. +// - with glfw you can get those from the callback set in glfwSetCharCallback() +// - on Windows you can get those using ToAscii+keyboard state, or via the WM_CHAR message +void ImGuiIO::AddInputCharacter(ImWchar c) +{ + const int n = ImStrlenW(InputCharacters); + if (n + 1 < IM_ARRAYSIZE(InputCharacters)) + { + InputCharacters[n] = c; + InputCharacters[n+1] = '\0'; + } +} + +void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars) +{ + // We can't pass more wchars than ImGuiIO::InputCharacters[] can hold so don't convert more + const int wchars_buf_len = sizeof(ImGuiIO::InputCharacters) / sizeof(ImWchar); + ImWchar wchars[wchars_buf_len]; + ImTextStrFromUtf8(wchars, wchars_buf_len, utf8_chars, NULL); + for (int i = 0; i < wchars_buf_len && wchars[i] != 0; i++) + AddInputCharacter(wchars[i]); +} + +//----------------------------------------------------------------------------- +// HELPERS +//----------------------------------------------------------------------------- + +#define IM_F32_TO_INT8_UNBOUND(_VAL) ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f))) // Unsaturated, for display purpose +#define IM_F32_TO_INT8_SAT(_VAL) ((int)(ImSaturate(_VAL) * 255.0f + 0.5f)) // Saturated, always output 0..255 + +// Play it nice with Windows users. Notepad in 2015 still doesn't display text data with Unix-style \n. +#ifdef _WIN32 +#define IM_NEWLINE "\r\n" +#else +#define IM_NEWLINE "\n" +#endif + +ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p) +{ + ImVec2 ap = p - a; + ImVec2 ab_dir = b - a; + float ab_len = sqrtf(ab_dir.x * ab_dir.x + ab_dir.y * ab_dir.y); + ab_dir *= 1.0f / ab_len; + float dot = ap.x * ab_dir.x + ap.y * ab_dir.y; + if (dot < 0.0f) + return a; + if (dot > ab_len) + return b; + return a + ab_dir * dot; +} + +bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p) +{ + bool b1 = ((p.x - b.x) * (a.y - b.y) - (p.y - b.y) * (a.x - b.x)) < 0.0f; + bool b2 = ((p.x - c.x) * (b.y - c.y) - (p.y - c.y) * (b.x - c.x)) < 0.0f; + bool b3 = ((p.x - a.x) * (c.y - a.y) - (p.y - a.y) * (c.x - a.x)) < 0.0f; + return ((b1 == b2) && (b2 == b3)); +} + +void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w) +{ + ImVec2 v0 = b - a; + ImVec2 v1 = c - a; + ImVec2 v2 = p - a; + const float denom = v0.x * v1.y - v1.x * v0.y; + out_v = (v2.x * v1.y - v1.x * v2.y) / denom; + out_w = (v0.x * v2.y - v2.x * v0.y) / denom; + out_u = 1.0f - out_v - out_w; +} + +ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p) +{ + ImVec2 proj_ab = ImLineClosestPoint(a, b, p); + ImVec2 proj_bc = ImLineClosestPoint(b, c, p); + ImVec2 proj_ca = ImLineClosestPoint(c, a, p); + float dist2_ab = ImLengthSqr(p - proj_ab); + float dist2_bc = ImLengthSqr(p - proj_bc); + float dist2_ca = ImLengthSqr(p - proj_ca); + float m = ImMin(dist2_ab, ImMin(dist2_bc, dist2_ca)); + if (m == dist2_ab) + return proj_ab; + if (m == dist2_bc) + return proj_bc; + return proj_ca; +} + +int ImStricmp(const char* str1, const char* str2) +{ + int d; + while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; } + return d; +} + +int ImStrnicmp(const char* str1, const char* str2, size_t count) +{ + int d = 0; + while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; count--; } + return d; +} + +void ImStrncpy(char* dst, const char* src, size_t count) +{ + if (count < 1) return; + strncpy(dst, src, count); + dst[count-1] = 0; +} + +char* ImStrdup(const char *str) +{ + size_t len = strlen(str) + 1; + void* buf = ImGui::MemAlloc(len); + return (char*)memcpy(buf, (const void*)str, len); +} + +char* ImStrchrRange(const char* str, const char* str_end, char c) +{ + for ( ; str < str_end; str++) + if (*str == c) + return (char*)str; + return NULL; +} + +int ImStrlenW(const ImWchar* str) +{ + int n = 0; + while (*str++) n++; + return n; +} + +const ImWchar* ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin) // find beginning-of-line +{ + while (buf_mid_line > buf_begin && buf_mid_line[-1] != '\n') + buf_mid_line--; + return buf_mid_line; +} + +const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end) +{ + if (!needle_end) + needle_end = needle + strlen(needle); + + const char un0 = (char)toupper(*needle); + while ((!haystack_end && *haystack) || (haystack_end && haystack < haystack_end)) + { + if (toupper(*haystack) == un0) + { + const char* b = needle + 1; + for (const char* a = haystack + 1; b < needle_end; a++, b++) + if (toupper(*a) != toupper(*b)) + break; + if (b == needle_end) + return haystack; + } + haystack++; + } + return NULL; +} + +static const char* ImAtoi(const char* src, int* output) +{ + int negative = 0; + if (*src == '-') { negative = 1; src++; } + if (*src == '+') { src++; } + int v = 0; + while (*src >= '0' && *src <= '9') + v = (v * 10) + (*src++ - '0'); + *output = negative ? -v : v; + return src; +} + +// A) MSVC version appears to return -1 on overflow, whereas glibc appears to return total count (which may be >= buf_size). +// Ideally we would test for only one of those limits at runtime depending on the behavior the vsnprintf(), but trying to deduct it at compile time sounds like a pandora can of worm. +// B) When buf==NULL vsnprintf() will return the output size. +#ifndef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS +int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + int w = vsnprintf(buf, buf_size, fmt, args); + va_end(args); + if (buf == NULL) + return w; + if (w == -1 || w >= (int)buf_size) + w = (int)buf_size - 1; + buf[w] = 0; + return w; +} + +int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) +{ + int w = vsnprintf(buf, buf_size, fmt, args); + if (buf == NULL) + return w; + if (w == -1 || w >= (int)buf_size) + w = (int)buf_size - 1; + buf[w] = 0; + return w; +} +#endif // #ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS + +// Pass data_size==0 for zero-terminated strings +// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements. +ImU32 ImHash(const void* data, int data_size, ImU32 seed) +{ + static ImU32 crc32_lut[256] = { 0 }; + if (!crc32_lut[1]) + { + const ImU32 polynomial = 0xEDB88320; + for (ImU32 i = 0; i < 256; i++) + { + ImU32 crc = i; + for (ImU32 j = 0; j < 8; j++) + crc = (crc >> 1) ^ (ImU32(-int(crc & 1)) & polynomial); + crc32_lut[i] = crc; + } + } + + seed = ~seed; + ImU32 crc = seed; + const unsigned char* current = (const unsigned char*)data; + + if (data_size > 0) + { + // Known size + while (data_size--) + crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *current++]; + } + else + { + // Zero-terminated string + while (unsigned char c = *current++) + { + // We support a syntax of "label###id" where only "###id" is included in the hash, and only "label" gets displayed. + // Because this syntax is rarely used we are optimizing for the common case. + // - If we reach ### in the string we discard the hash so far and reset to the seed. + // - We don't do 'current += 2; continue;' after handling ### to keep the code smaller. + if (c == '#' && current[0] == '#' && current[1] == '#') + crc = seed; + crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c]; + } + } + return ~crc; +} + +//----------------------------------------------------------------------------- +// ImText* helpers +//----------------------------------------------------------------------------- + +// Convert UTF-8 to 32-bits character, process single character input. +// Based on stb_from_utf8() from github.com/nothings/stb/ +// We handle UTF-8 decoding error by skipping forward. +int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end) +{ + unsigned int c = (unsigned int)-1; + const unsigned char* str = (const unsigned char*)in_text; + if (!(*str & 0x80)) + { + c = (unsigned int)(*str++); + *out_char = c; + return 1; + } + if ((*str & 0xe0) == 0xc0) + { + *out_char = 0xFFFD; // will be invalid but not end of string + if (in_text_end && in_text_end - (const char*)str < 2) return 1; + if (*str < 0xc2) return 2; + c = (unsigned int)((*str++ & 0x1f) << 6); + if ((*str & 0xc0) != 0x80) return 2; + c += (*str++ & 0x3f); + *out_char = c; + return 2; + } + if ((*str & 0xf0) == 0xe0) + { + *out_char = 0xFFFD; // will be invalid but not end of string + if (in_text_end && in_text_end - (const char*)str < 3) return 1; + if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return 3; + if (*str == 0xed && str[1] > 0x9f) return 3; // str[1] < 0x80 is checked below + c = (unsigned int)((*str++ & 0x0f) << 12); + if ((*str & 0xc0) != 0x80) return 3; + c += (unsigned int)((*str++ & 0x3f) << 6); + if ((*str & 0xc0) != 0x80) return 3; + c += (*str++ & 0x3f); + *out_char = c; + return 3; + } + if ((*str & 0xf8) == 0xf0) + { + *out_char = 0xFFFD; // will be invalid but not end of string + if (in_text_end && in_text_end - (const char*)str < 4) return 1; + if (*str > 0xf4) return 4; + if (*str == 0xf0 && (str[1] < 0x90 || str[1] > 0xbf)) return 4; + if (*str == 0xf4 && str[1] > 0x8f) return 4; // str[1] < 0x80 is checked below + c = (unsigned int)((*str++ & 0x07) << 18); + if ((*str & 0xc0) != 0x80) return 4; + c += (unsigned int)((*str++ & 0x3f) << 12); + if ((*str & 0xc0) != 0x80) return 4; + c += (unsigned int)((*str++ & 0x3f) << 6); + if ((*str & 0xc0) != 0x80) return 4; + c += (*str++ & 0x3f); + // utf-8 encodings of values used in surrogate pairs are invalid + if ((c & 0xFFFFF800) == 0xD800) return 4; + *out_char = c; + return 4; + } + *out_char = 0; + return 0; +} + +int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_text_remaining) +{ + ImWchar* buf_out = buf; + ImWchar* buf_end = buf + buf_size; + while (buf_out < buf_end-1 && (!in_text_end || in_text < in_text_end) && *in_text) + { + unsigned int c; + in_text += ImTextCharFromUtf8(&c, in_text, in_text_end); + if (c == 0) + break; + if (c < 0x10000) // FIXME: Losing characters that don't fit in 2 BYTEs + *buf_out++ = (ImWchar)c; + } + *buf_out = 0; + if (in_text_remaining) + *in_text_remaining = in_text; + return (int)(buf_out - buf); +} + +int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end) +{ + int char_count = 0; + while ((!in_text_end || in_text < in_text_end) && *in_text) + { + unsigned int c; + in_text += ImTextCharFromUtf8(&c, in_text, in_text_end); + if (c == 0) + break; + if (c < 0x10000) + char_count++; + } + return char_count; +} + +// Based on stb_to_utf8() from github.com/nothings/stb/ +static inline int ImTextCharToUtf8(char* buf, int buf_size, unsigned int c) +{ + if (c < 0x80) + { + buf[0] = (char)c; + return 1; + } + if (c < 0x800) + { + if (buf_size < 2) return 0; + buf[0] = (char)(0xc0 + (c >> 6)); + buf[1] = (char)(0x80 + (c & 0x3f)); + return 2; + } + if (c >= 0xdc00 && c < 0xe000) + { + return 0; + } + if (c >= 0xd800 && c < 0xdc00) + { + if (buf_size < 4) return 0; + buf[0] = (char)(0xf0 + (c >> 18)); + buf[1] = (char)(0x80 + ((c >> 12) & 0x3f)); + buf[2] = (char)(0x80 + ((c >> 6) & 0x3f)); + buf[3] = (char)(0x80 + ((c ) & 0x3f)); + return 4; + } + //else if (c < 0x10000) + { + if (buf_size < 3) return 0; + buf[0] = (char)(0xe0 + (c >> 12)); + buf[1] = (char)(0x80 + ((c>> 6) & 0x3f)); + buf[2] = (char)(0x80 + ((c ) & 0x3f)); + return 3; + } +} + +static inline int ImTextCountUtf8BytesFromChar(unsigned int c) +{ + if (c < 0x80) return 1; + if (c < 0x800) return 2; + if (c >= 0xdc00 && c < 0xe000) return 0; + if (c >= 0xd800 && c < 0xdc00) return 4; + return 3; +} + +int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end) +{ + char* buf_out = buf; + const char* buf_end = buf + buf_size; + while (buf_out < buf_end-1 && (!in_text_end || in_text < in_text_end) && *in_text) + { + unsigned int c = (unsigned int)(*in_text++); + if (c < 0x80) + *buf_out++ = (char)c; + else + buf_out += ImTextCharToUtf8(buf_out, (int)(buf_end-buf_out-1), c); + } + *buf_out = 0; + return (int)(buf_out - buf); +} + +int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end) +{ + int BYTEs_count = 0; + while ((!in_text_end || in_text < in_text_end) && *in_text) + { + unsigned int c = (unsigned int)(*in_text++); + if (c < 0x80) + BYTEs_count++; + else + BYTEs_count += ImTextCountUtf8BytesFromChar(c); + } + return BYTEs_count; +} + +ImVec4 ImGui::ColorConvertU32ToFloat4(ImU32 in) +{ + float s = 1.0f/255.0f; + return ImVec4( + ((in >> IM_COL32_R_SHIFT) & 0xFF) * s, + ((in >> IM_COL32_G_SHIFT) & 0xFF) * s, + ((in >> IM_COL32_B_SHIFT) & 0xFF) * s, + ((in >> IM_COL32_A_SHIFT) & 0xFF) * s); +} + +ImU32 ImGui::ColorConvertFloat4ToU32(const ImVec4& in) +{ + ImU32 out; + out = ((ImU32)IM_F32_TO_INT8_SAT(in.x)) << IM_COL32_R_SHIFT; + out |= ((ImU32)IM_F32_TO_INT8_SAT(in.y)) << IM_COL32_G_SHIFT; + out |= ((ImU32)IM_F32_TO_INT8_SAT(in.z)) << IM_COL32_B_SHIFT; + out |= ((ImU32)IM_F32_TO_INT8_SAT(in.w)) << IM_COL32_A_SHIFT; + return out; +} + +ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul,float alpha_replace) +{ + ImGuiStyle& style = GImGui->Style; + ImVec4 c = style.Colors[idx]; + + if (alpha_replace > -1.f) + c.w = alpha_replace; + else + c.w *= style.Alpha * alpha_mul; + + return ColorConvertFloat4ToU32(c); +} + +ImU32 ImGui::GetColorU32(const ImVec4& col) +{ + ImGuiStyle& style = GImGui->Style; + ImVec4 c = col; + c.w *= style.Alpha; + return ColorConvertFloat4ToU32(c); +} + +const ImVec4& ImGui::GetStyleColorVec4(ImGuiCol idx) +{ + ImGuiStyle& style = GImGui->Style; + return style.Colors[idx]; +} + +ImU32 ImGui::GetColorU32(ImU32 col) +{ + float style_alpha = GImGui->Style.Alpha; + if (style_alpha >= 1.0f) + return col; + int a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT; + a = (int)(a * style_alpha); // We don't need to clamp 0..255 because Style.Alpha is in 0..1 range. + return (col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT); +} + +// Convert rgb floats ([0-1],[0-1],[0-1]) to hsv floats ([0-1],[0-1],[0-1]), from Foley & van Dam p592 +// Optimized http://lolengine.net/blog/2013/01/13/fast-rgb-to-hsv +void ImGui::ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v) +{ + float K = 0.f; + if (g < b) + { + ImSwap(g, b); + K = -1.f; + } + if (r < g) + { + ImSwap(r, g); + K = -2.f / 6.f - K; + } + + const float chroma = r - (g < b ? g : b); + out_h = fabsf(K + (g - b) / (6.f * chroma + 1e-20f)); + out_s = chroma / (r + 1e-20f); + out_v = r; +} + +// Convert hsv floats ([0-1],[0-1],[0-1]) to rgb floats ([0-1],[0-1],[0-1]), from Foley & van Dam p593 +// also http://en.wikipedia.org/wiki/HSL_and_HSV +void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b) +{ + if (s == 0.0f) + { + // gray + out_r = out_g = out_b = v; + return; + } + + h = fmodf(h, 1.0f) / (60.0f/360.0f); + int i = (int)h; + float f = h - (float)i; + float p = v * (1.0f - s); + float q = v * (1.0f - s * f); + float t = v * (1.0f - s * (1.0f - f)); + + switch (i) + { + case 0: out_r = v; out_g = t; out_b = p; break; + case 1: out_r = q; out_g = v; out_b = p; break; + case 2: out_r = p; out_g = v; out_b = t; break; + case 3: out_r = p; out_g = q; out_b = v; break; + case 4: out_r = t; out_g = p; out_b = v; break; + case 5: default: out_r = v; out_g = p; out_b = q; break; + } +} + +FILE* ImFileOpen(const char* filename, const char* mode) +{ +#if defined(_WIN32) && !defined(__CYGWIN__) + // We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames. Converting both strings from UTF-8 to wchar format (using a single allocation, because we can) + const int filename_wsize = ImTextCountCharsFromUtf8(filename, NULL) + 1; + const int mode_wsize = ImTextCountCharsFromUtf8(mode, NULL) + 1; + ImVector buf; + buf.resize(filename_wsize + mode_wsize); + ImTextStrFromUtf8(&buf[0], filename_wsize, filename, NULL); + ImTextStrFromUtf8(&buf[filename_wsize], mode_wsize, mode, NULL); + return _wfopen((wchar_t*)&buf[0], (wchar_t*)&buf[filename_wsize]); +#else + return fopen(filename, mode); +#endif +} + +// Load file content into memory +// Memory allocated with ImGui::MemAlloc(), must be freed by user using ImGui::MemFree() +void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, int* out_file_size, int padding_BYTEs) +{ + IM_ASSERT(filename && file_open_mode); + if (out_file_size) + *out_file_size = 0; + + FILE* f; + if ((f = ImFileOpen(filename, file_open_mode)) == NULL) + return NULL; + + long file_size_signed; + if (fseek(f, 0, SEEK_END) || (file_size_signed = ftell(f)) == -1 || fseek(f, 0, SEEK_SET)) + { + fclose(f); + return NULL; + } + + int file_size = (int)file_size_signed; + void* file_data = ImGui::MemAlloc(file_size + padding_BYTEs); + if (file_data == NULL) + { + fclose(f); + return NULL; + } + if (fread(file_data, 1, (size_t)file_size, f) != (size_t)file_size) + { + fclose(f); + ImGui::MemFree(file_data); + return NULL; + } + if (padding_BYTEs > 0) + memset((void *)(((char*)file_data) + file_size), 0, padding_BYTEs); + + fclose(f); + if (out_file_size) + *out_file_size = file_size; + + return file_data; +} + +//----------------------------------------------------------------------------- +// ImGuiStorage +// Helper: Key->value storage +//----------------------------------------------------------------------------- + +// std::lower_bound but without the bullshit +static ImVector::iterator LowerBound(ImVector& data, ImGuiID key) +{ + ImVector::iterator first = data.begin(); + ImVector::iterator last = data.end(); + size_t count = (size_t)(last - first); + while (count > 0) + { + size_t count2 = count >> 1; + ImVector::iterator mid = first + count2; + if (mid->key < key) + { + first = ++mid; + count -= count2 + 1; + } + else + { + count = count2; + } + } + return first; +} + +// For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once. +void ImGuiStorage::BuildSortByKey() +{ + struct StaticFunc + { + static int PairCompareByID(const void* lhs, const void* rhs) + { + // We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that. + if (((const Pair*)lhs)->key > ((const Pair*)rhs)->key) return +1; + if (((const Pair*)lhs)->key < ((const Pair*)rhs)->key) return -1; + return 0; + } + }; + if (Data.Size > 1) + qsort(Data.Data, (size_t)Data.Size, sizeof(Pair), StaticFunc::PairCompareByID); +} + +int ImGuiStorage::GetInt(ImGuiID key, int default_val) const +{ + ImVector::iterator it = LowerBound(const_cast&>(Data), key); + if (it == Data.end() || it->key != key) + return default_val; + return it->val_i; +} + +bool ImGuiStorage::GetBool(ImGuiID key, bool default_val) const +{ + return GetInt(key, default_val ? 1 : 0) != 0; +} + +float ImGuiStorage::GetFloat(ImGuiID key, float default_val) const +{ + ImVector::iterator it = LowerBound(const_cast&>(Data), key); + if (it == Data.end() || it->key != key) + return default_val; + return it->val_f; +} + +void* ImGuiStorage::GetVoidPtr(ImGuiID key) const +{ + ImVector::iterator it = LowerBound(const_cast&>(Data), key); + if (it == Data.end() || it->key != key) + return NULL; + return it->val_p; +} + +// References are only valid until a new value is added to the storage. Calling a set***() function or a Get***Ref() function invalidates the pointer. +int* ImGuiStorage::GetIntRef(ImGuiID key, int default_val) +{ + ImVector::iterator it = LowerBound(Data, key); + if (it == Data.end() || it->key != key) + it = Data.insert(it, Pair(key, default_val)); + return &it->val_i; +} + +bool* ImGuiStorage::GetBoolRef(ImGuiID key, bool default_val) +{ + return (bool*)GetIntRef(key, default_val ? 1 : 0); +} + +float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val) +{ + ImVector::iterator it = LowerBound(Data, key); + if (it == Data.end() || it->key != key) + it = Data.insert(it, Pair(key, default_val)); + return &it->val_f; +} + +void** ImGuiStorage::GetVoidPtrRef(ImGuiID key, void* default_val) +{ + ImVector::iterator it = LowerBound(Data, key); + if (it == Data.end() || it->key != key) + it = Data.insert(it, Pair(key, default_val)); + return &it->val_p; +} + +// FIXME-OPT: Need a way to reuse the result of lower_bound when doing GetInt()/SetInt() - not too bad because it only happens on explicit interaction (maximum one a frame) +void ImGuiStorage::SetInt(ImGuiID key, int val) +{ + ImVector::iterator it = LowerBound(Data, key); + if (it == Data.end() || it->key != key) + { + Data.insert(it, Pair(key, val)); + return; + } + it->val_i = val; +} + +void ImGuiStorage::SetBool(ImGuiID key, bool val) +{ + SetInt(key, val ? 1 : 0); +} + +void ImGuiStorage::SetFloat(ImGuiID key, float val) +{ + ImVector::iterator it = LowerBound(Data, key); + if (it == Data.end() || it->key != key) + { + Data.insert(it, Pair(key, val)); + return; + } + it->val_f = val; +} + +void ImGuiStorage::SetVoidPtr(ImGuiID key, void* val) +{ + ImVector::iterator it = LowerBound(Data, key); + if (it == Data.end() || it->key != key) + { + Data.insert(it, Pair(key, val)); + return; + } + it->val_p = val; +} + +void ImGuiStorage::SetAllInt(int v) +{ + for (int i = 0; i < Data.Size; i++) + Data[i].val_i = v; +} + +//----------------------------------------------------------------------------- +// ImGuiTextFilter +//----------------------------------------------------------------------------- + +// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]" +ImGuiTextFilter::ImGuiTextFilter(const char* default_filter) +{ + if (default_filter) + { + ImStrncpy(InputBuf, default_filter, IM_ARRAYSIZE(InputBuf)); + Build(); + } + else + { + InputBuf[0] = 0; + CountGrep = 0; + } +} + +bool ImGuiTextFilter::Draw(const char* label, float width) +{ + if (width != 0.0f) + ImGui::PushItemWidth(width); + bool value_changed = ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf)); + if (width != 0.0f) + ImGui::PopItemWidth(); + if (value_changed) + Build(); + return value_changed; +} + +void ImGuiTextFilter::TextRange::split(char separator, ImVector& out) +{ + out.resize(0); + const char* wb = b; + const char* we = wb; + while (we < e) + { + if (*we == separator) + { + out.push_back(TextRange(wb, we)); + wb = we + 1; + } + we++; + } + if (wb != we) + out.push_back(TextRange(wb, we)); +} + +void ImGuiTextFilter::Build() +{ + Filters.resize(0); + TextRange input_range(InputBuf, InputBuf+strlen(InputBuf)); + input_range.split(',', Filters); + + CountGrep = 0; + for (int i = 0; i != Filters.Size; i++) + { + Filters[i].trim_blanks(); + if (Filters[i].empty()) + continue; + if (Filters[i].front() != '-') + CountGrep += 1; + } +} + +bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const +{ + if (Filters.empty()) + return true; + + if (text == NULL) + text = ""; + + for (int i = 0; i != Filters.Size; i++) + { + const TextRange& f = Filters[i]; + if (f.empty()) + continue; + if (f.front() == '-') + { + // Subtract + if (ImStristr(text, text_end, f.begin()+1, f.end()) != NULL) + return false; + } + else + { + // Grep + if (ImStristr(text, text_end, f.begin(), f.end()) != NULL) + return true; + } + } + + // Implicit * grep + if (CountGrep == 0) + return true; + + return false; +} + +//----------------------------------------------------------------------------- +// ImGuiTextBuffer +//----------------------------------------------------------------------------- + +// On some platform vsnprintf() takes va_list by reference and modifies it. +// va_copy is the 'correct' way to copy a va_list but Visual Studio prior to 2013 doesn't have it. +#ifndef va_copy +#define va_copy(dest, src) (dest = src) +#endif + +// Helper: Text buffer for logging/accumulating text +void ImGuiTextBuffer::appendfv(const char* fmt, va_list args) +{ + va_list args_copy; + va_copy(args_copy, args); + + int len = ImFormatStringV(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass. + if (len <= 0) + return; + + const int write_off = Buf.Size; + const int needed_sz = write_off + len; + if (write_off + len >= Buf.Capacity) + { + int double_capacity = Buf.Capacity * 2; + Buf.reserve(needed_sz > double_capacity ? needed_sz : double_capacity); + } + + Buf.resize(needed_sz); + ImFormatStringV(&Buf[write_off - 1], len + 1, fmt, args_copy); +} + +void ImGuiTextBuffer::appendf(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + appendfv(fmt, args); + va_end(args); +} + +//----------------------------------------------------------------------------- +// ImGuiSimpleColumns (internal use only) +//----------------------------------------------------------------------------- + +ImGuiMenuColumns::ImGuiMenuColumns() +{ + Count = 0; + Spacing = Width = NextWidth = 0.0f; + memset(Pos, 0, sizeof(Pos)); + memset(NextWidths, 0, sizeof(NextWidths)); +} + +void ImGuiMenuColumns::update(int count, float spacing, bool clear) +{ + IM_ASSERT(Count <= IM_ARRAYSIZE(Pos)); + Count = count; + Width = NextWidth = 0.0f; + Spacing = spacing; + if (clear) memset(NextWidths, 0, sizeof(NextWidths)); + for (int i = 0; i < Count; i++) + { + if (i > 0 && NextWidths[i] > 0.0f) + Width += Spacing; + Pos[i] = (float)(int)Width; + Width += NextWidths[i]; + NextWidths[i] = 0.0f; + } +} + +float ImGuiMenuColumns::DeclColumns(float w0, float w1, float w2) // not using va_arg because they promote float to double +{ + NextWidth = 0.0f; + NextWidths[0] = ImMax(NextWidths[0], w0); + NextWidths[1] = ImMax(NextWidths[1], w1); + NextWidths[2] = ImMax(NextWidths[2], w2); + for (int i = 0; i < 3; i++) + NextWidth += NextWidths[i] + ((i > 0 && NextWidths[i] > 0.0f) ? Spacing : 0.0f); + return ImMax(Width, NextWidth); +} + +float ImGuiMenuColumns::CalcExtraSpace(float avail_w) +{ + return ImMax(0.0f, avail_w - Width); +} + +//----------------------------------------------------------------------------- +// ImGuiListClipper +//----------------------------------------------------------------------------- + +static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height) +{ + // set cursor position and a few other things so that SetScrollHere() and Columns() can work when seeking cursor. + // FIXME: It is problematic that we have to do that here, because custom/equivalent end-user code would stumble on the same issue. Consider moving within SetCursorXXX functions? + ImGui::SetCursorPosY(pos_y); + ImGuiWindow* window = ImGui::GetCurrentWindow(); + window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHere() can properly function after the end of our clipper usage. + window->DC.PrevLineHeight = (line_height - GImGui->Style.ItemSpacing.y); // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list. + if (window->DC.ColumnsSet) + window->DC.ColumnsSet->CellMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly +} + +// Use case A: Begin() called from constructor with items_height<0, then called again from Sync() in StepNo 1 +// Use case B: Begin() called from constructor with items_height>0 +// FIXME-LEGACY: Ideally we should remove the Begin/End functions but they are part of the legacy API we still support. This is why some of the code in Step() calling Begin() and reassign some fields, spaghetti style. +void ImGuiListClipper::Begin(int count, float items_height) +{ + StartPosY = ImGui::GetCursorPosY(); + ItemsHeight = items_height; + ItemsCount = count; + StepNo = 0; + DisplayEnd = DisplayStart = -1; + if (ItemsHeight > 0.0f) + { + ImGui::CalcListClipping(ItemsCount, ItemsHeight, &DisplayStart, &DisplayEnd); // calculate how many to clip/display + if (DisplayStart > 0) + SetCursorPosYAndSetupDummyPrevLine(StartPosY + DisplayStart * ItemsHeight, ItemsHeight); // advance cursor + StepNo = 2; + } +} + +void ImGuiListClipper::End() +{ + if (ItemsCount < 0) + return; + // In theory here we should assert that ImGui::GetCursorPosY() == StartPosY + DisplayEnd * ItemsHeight, but it feels saner to just seek at the end and not assert/crash the user. + if (ItemsCount < INT_MAX) + SetCursorPosYAndSetupDummyPrevLine(StartPosY + ItemsCount * ItemsHeight, ItemsHeight); // advance cursor + ItemsCount = -1; + StepNo = 3; +} + +bool ImGuiListClipper::Step() +{ + if (ItemsCount == 0 || ImGui::GetCurrentWindowRead()->SkipItems) + { + ItemsCount = -1; + return false; + } + if (StepNo == 0) // Step 0: the clipper let you process the first element, regardless of it being visible or not, so we can measure the element height. + { + DisplayStart = 0; + DisplayEnd = 1; + StartPosY = ImGui::GetCursorPosY(); + StepNo = 1; + return true; + } + if (StepNo == 1) // Step 1: the clipper infer height from first element, calculate the actual range of elements to display, and position the cursor before the first element. + { + if (ItemsCount == 1) { ItemsCount = -1; return false; } + float items_height = ImGui::GetCursorPosY() - StartPosY; + IM_ASSERT(items_height > 0.0f); // If this triggers, it means Item 0 hasn't moved the cursor vertically + Begin(ItemsCount-1, items_height); + DisplayStart++; + DisplayEnd++; + StepNo = 3; + return true; + } + if (StepNo == 2) // Step 2: dummy step only required if an explicit items_height was passed to constructor or Begin() and user still call Step(). Does nothing and switch to Step 3. + { + IM_ASSERT(DisplayStart >= 0 && DisplayEnd >= 0); + StepNo = 3; + return true; + } + if (StepNo == 3) // Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), advance the cursor to the end of the list and then returns 'false' to end the loop. + End(); + return false; +} + +//----------------------------------------------------------------------------- +// ImGuiWindow +//----------------------------------------------------------------------------- + +ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name) +{ + Name = ImStrdup(name); + ID = ImHash(name, 0); + IDStack.push_back(ID); + Flags = 0; + PosFloat = Pos = ImVec2(0.0f, 0.0f); + Size = SizeFull = ImVec2(0.0f, 0.0f); + SizeContents = SizeContentsExplicit = ImVec2(0.0f, 0.0f); + WindowPadding = ImVec2(0.0f, 0.0f); + WindowRounding = 0.0f; + WindowBorderSize = 0.0f; + MoveId = GetID("#MOVE"); + Scroll = ImVec2(0.0f, 0.0f); + ScrollTarget = ImVec2(FLT_MAX, FLT_MAX); + ScrollTargetCenterRatio = ImVec2(0.5f, 0.5f); + ScrollbarX = ScrollbarY = false; + ScrollbarSizes = ImVec2(0.0f, 0.0f); + Active = WasActive = false; + WriteAccessed = false; + Collapsed = false; + SkipItems = false; + Appearing = false; + CloseButton = false; + BeginOrderWithinParent = -1; + BeginOrderWithinContext = -1; + BeginCount = 0; + PopupId = 0; + AutoFitFramesX = AutoFitFramesY = -1; + AutoFitOnlyGrows = false; + AutoFitChildAxises = 0x00; + AutoPosLastDirection = ImGuiDir_None; + HiddenFrames = 0; + SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiCond_Always | ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing; + SetWindowPosVal = SetWindowPosPivot = ImVec2(FLT_MAX, FLT_MAX); + + LastFrameActive = -1; + ItemWidthDefault = 0.0f; + FontWindowScale = 1.0f; + + DrawList = IM_NEW(ImDrawList)(&context->DrawListSharedData); + DrawList->_OwnerName = Name; + ParentWindow = NULL; + RootWindow = NULL; + RootNonPopupWindow = NULL; + + FocusIdxAllCounter = FocusIdxTabCounter = -1; + FocusIdxAllRequestCurrent = FocusIdxTabRequestCurrent = INT_MAX; + FocusIdxAllRequestNext = FocusIdxTabRequestNext = INT_MAX; +} + +ImGuiWindow::~ImGuiWindow() +{ + IM_DELETE(DrawList); + IM_DELETE(Name); + for (int i = 0; i != ColumnsStorage.Size; i++) + ColumnsStorage[i].~ImGuiColumnsSet(); +} + +ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end) +{ + ImGuiID seed = IDStack.back(); + ImGuiID id = ImHash(str, str_end ? (int)(str_end - str) : 0, seed); + ImGui::KeepAliveID(id); + return id; +} + +ImGuiID ImGuiWindow::GetID(const void* ptr) +{ + ImGuiID seed = IDStack.back(); + ImGuiID id = ImHash(&ptr, sizeof(void*), seed); + ImGui::KeepAliveID(id); + return id; +} + +ImGuiID ImGuiWindow::GetIDNoKeepAlive(const char* str, const char* str_end) +{ + ImGuiID seed = IDStack.back(); + return ImHash(str, str_end ? (int)(str_end - str) : 0, seed); +} + +// This is only used in rare/specific situations to manufacture an ID out of nowhere. +ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs) +{ + ImGuiID seed = IDStack.back(); + const int r_rel[4] = { (int)(r_abs.Min.x - Pos.x), (int)(r_abs.Min.y - Pos.y), (int)(r_abs.Max.x - Pos.x), (int)(r_abs.Max.y - Pos.y) }; + ImGuiID id = ImHash(&r_rel, sizeof(r_rel), seed); + ImGui::KeepAliveID(id); + return id; +} + +//----------------------------------------------------------------------------- +// Internal API exposed in imgui_internal.h +//----------------------------------------------------------------------------- + +static void SetCurrentWindow(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + g.CurrentWindow = window; + if (window) + g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize(); +} + +void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + g.ActiveIdIsJustActivated = (g.ActiveId != id); + if (g.ActiveIdIsJustActivated) + g.ActiveIdTimer = 0.0f; + g.ActiveId = id; + g.ActiveIdAllowOverlap = false; + g.ActiveIdIsAlive |= (id != 0); + g.ActiveIdWindow = window; +} + +void ImGui::ClearActiveID() +{ + SetActiveID(0, NULL); +} + +void ImGui::SetHoveredID(ImGuiID id) +{ + ImGuiContext& g = *GImGui; + g.HoveredId = id; + g.HoveredIdAllowOverlap = false; + g.HoveredIdTimer = (id != 0 && g.HoveredIdPreviousFrame == id) ? (g.HoveredIdTimer + g.IO.DeltaTime) : 0.0f; +} + +ImGuiID ImGui::GetHoveredID() +{ + ImGuiContext& g = *GImGui; + return g.HoveredId ? g.HoveredId : g.HoveredIdPreviousFrame; +} + +void ImGui::KeepAliveID(ImGuiID id) +{ + ImGuiContext& g = *GImGui; + if (g.ActiveId == id) + g.ActiveIdIsAlive = true; +} + +static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFlags flags) +{ + // An active popup disable hovering on other windows (apart from its own children) + // FIXME-OPT: This could be cached/stored within the window. + ImGuiContext& g = *GImGui; + if (g.NavWindow) + if (ImGuiWindow* focused_root_window = g.NavWindow->RootWindow) + if (focused_root_window->WasActive && focused_root_window != window->RootWindow) + { + // For the purpose of those flags we differentiate "standard popup" from "modal popup" + // NB: The order of those two tests is important because Modal windows are also Popups. + if (focused_root_window->Flags & ImGuiWindowFlags_Modal) + return false; + if ((focused_root_window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiHoveredFlags_AllowWhenBlockedByPopup)) + return false; + } + + return true; +} + +// Advance cursor given item size for layout. +void ImGui::ItemSize(const ImVec2& size, float text_offset_y) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->SkipItems) + return; + + // Always align ourselves on pixel boundaries + const float line_height = ImMax(window->DC.CurrentLineHeight, size.y); + const float text_base_offset = ImMax(window->DC.CurrentLineTextBaseOffset, text_offset_y); + //if (g.IO.KeyAlt) window->DrawList->AddRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(size.x, line_height), IM_COL32(255,0,0,200)); // [DEBUG] + window->DC.CursorPosPrevLine = ImVec2(window->DC.CursorPos.x + size.x, window->DC.CursorPos.y); + window->DC.CursorPos = ImVec2((float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX), (float)(int)(window->DC.CursorPos.y + line_height + g.Style.ItemSpacing.y)); + window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPosPrevLine.x); + window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y - g.Style.ItemSpacing.y); + //if (g.IO.KeyAlt) window->DrawList->AddCircle(window->DC.CursorMaxPos, 3.0f, IM_COL32(255,0,0,255), 4); // [DEBUG] + + window->DC.PrevLineHeight = line_height; + window->DC.PrevLineTextBaseOffset = text_base_offset; + window->DC.CurrentLineHeight = window->DC.CurrentLineTextBaseOffset = 0.0f; + + // Horizontal layout mode + if (window->DC.LayoutType == ImGuiLayoutType_Horizontal) + SameLine(); +} + +void ImGui::ItemSize(const ImRect& bb, float text_offset_y) +{ + ItemSize(bb.GetSize(), text_offset_y); +} + +// Declare item bounding box for clipping and interaction. +// Note that the size can be different than the one provided to ItemSize(). Typically, widgets that spread over available surface +// declares their minimum size requirement to ItemSize() and then use a larger region for drawing/interaction, which is passed to ItemAdd(). +bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + const bool is_clipped = IsClippedEx(bb, id, false); + window->DC.LastItemId = id; + window->DC.LastItemRect = bb; + window->DC.LastItemRectHoveredRect = false; + if (is_clipped) + return false; + //if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG] + + // We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them) + window->DC.LastItemRectHoveredRect = IsMouseHoveringRect(bb.Min, bb.Max); + return true; +} + +// This is roughly matching the behavior of internal-facing ItemHoverable() +// - we allow hovering to be true when ActiveId==window->MoveID, so that clicking on non-interactive items such as a Text() item still returns true with IsItemHovered() +// - this should work even for non-interactive items that have no ID, so we cannot use LastItemId +bool ImGui::IsItemHovered(ImGuiHoveredFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + // Test for bounding box overlap, as updated as ItemAdd() + if (!window->DC.LastItemRectHoveredRect) + return false; + IM_ASSERT((flags & (ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows)) == 0); // Flags not supported by this function + + // Test if we are hovering the right window (our window could be behind another window) + // [2017/10/16] Reverted commit 344d48be3 and testing RootWindow instead. I believe it is correct to NOT test for RootWindow but this leaves us unable to use IsItemHovered() after EndChild() itself. + // Until a solution is found I believe reverting to the test from 2017/09/27 is safe since this was the test that has been running for a long while. + //if (g.HoveredWindow != window) + // return false; + if (g.HoveredRootWindow != window->RootWindow && !(flags & ImGuiHoveredFlags_AllowWhenOverlapped)) + return false; + + // Test if another item is active (e.g. being dragged) + if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) + if (g.ActiveId != 0 && g.ActiveId != window->DC.LastItemId && !g.ActiveIdAllowOverlap && g.ActiveId != window->MoveId) + return false; + + // Test if interactions on this window are blocked by an active popup or modal + if (!IsWindowContentHoverable(window, flags)) + return false; + + // Test if the item is disabled + if (window->DC.ItemFlags & ImGuiItemFlags_Disabled) + return false; + + // Special handling for the 1st item after Begin() which represent the title bar. When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect tht case. + if (window->DC.LastItemId == window->MoveId && window->WriteAccessed) + return false; + return true; +} + +// Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered(). +bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id) +{ + ImGuiContext& g = *GImGui; + if (g.HoveredId != 0 && g.HoveredId != id && !g.HoveredIdAllowOverlap) + return false; + + ImGuiWindow* window = g.CurrentWindow; + if (g.HoveredWindow != window) + return false; + if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap) + return false; + if (!IsMouseHoveringRect(bb.Min, bb.Max)) + return false; + if (!IsWindowContentHoverable(window, ImGuiHoveredFlags_Default)) + return false; + if (window->DC.ItemFlags & ImGuiItemFlags_Disabled) + return false; + + SetHoveredID(id); + return true; +} + +bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (!bb.Overlaps(window->ClipRect)) + if (id == 0 || id != g.ActiveId) + if (clip_even_when_logged || !g.LogEnabled) + return true; + return false; +} + +bool ImGui::FocusableItemRegister(ImGuiWindow* window, ImGuiID id, bool tab_stop) +{ + ImGuiContext& g = *GImGui; + + const bool allow_keyboard_focus = (window->DC.ItemFlags & (ImGuiItemFlags_AllowKeyboardFocus | ImGuiItemFlags_Disabled)) == ImGuiItemFlags_AllowKeyboardFocus; + window->FocusIdxAllCounter++; + if (allow_keyboard_focus) + window->FocusIdxTabCounter++; + + // Process keyboard input at this point: TAB/Shift-TAB to tab out of the currently focused item. + // Note that we can always TAB out of a widget that doesn't allow tabbing in. + if (tab_stop && (g.ActiveId == id) && window->FocusIdxAllRequestNext == INT_MAX && window->FocusIdxTabRequestNext == INT_MAX && !g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab)) + window->FocusIdxTabRequestNext = window->FocusIdxTabCounter + (g.IO.KeyShift ? (allow_keyboard_focus ? -1 : 0) : +1); // Modulo on index will be applied at the end of frame once we've got the total counter of items. + + if (window->FocusIdxAllCounter == window->FocusIdxAllRequestCurrent) + return true; + + if (allow_keyboard_focus) + if (window->FocusIdxTabCounter == window->FocusIdxTabRequestCurrent) + return true; + + return false; +} + +void ImGui::FocusableItemUnregister(ImGuiWindow* window) +{ + window->FocusIdxAllCounter--; + window->FocusIdxTabCounter--; +} + +ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_x, float default_y) +{ + ImGuiContext& g = *GImGui; + ImVec2 content_max; + if (size.x < 0.0f || size.y < 0.0f) + content_max = g.CurrentWindow->Pos + GetContentRegionMax(); + if (size.x <= 0.0f) + size.x = (size.x == 0.0f) ? default_x : ImMax(content_max.x - g.CurrentWindow->DC.CursorPos.x, 4.0f) + size.x; + if (size.y <= 0.0f) + size.y = (size.y == 0.0f) ? default_y : ImMax(content_max.y - g.CurrentWindow->DC.CursorPos.y, 4.0f) + size.y; + return size; +} + +float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x) +{ + if (wrap_pos_x < 0.0f) + return 0.0f; + + ImGuiWindow* window = GetCurrentWindowRead(); + if (wrap_pos_x == 0.0f) + wrap_pos_x = GetContentRegionMax().x + window->Pos.x; + else if (wrap_pos_x > 0.0f) + wrap_pos_x += window->Pos.x - window->Scroll.x; // wrap_pos_x is provided is window local space + + return ImMax(wrap_pos_x - pos.x, 1.0f); +} + +//----------------------------------------------------------------------------- + +void* ImGui::MemAlloc(size_t sz) +{ + GImGui->IO.MetricsAllocs++; + return GImGui->IO.MemAllocFn(sz); +} + +void ImGui::MemFree(void* ptr) +{ + if (ptr) GImGui->IO.MetricsAllocs--; + return GImGui->IO.MemFreeFn(ptr); +} + +const char* ImGui::GetClipboardText() +{ + return GImGui->IO.GetClipboardTextFn ? GImGui->IO.GetClipboardTextFn(GImGui->IO.ClipboardUserData) : ""; +} + +void ImGui::SetClipboardText(const char* text) +{ + if (GImGui->IO.SetClipboardTextFn) + GImGui->IO.SetClipboardTextFn(GImGui->IO.ClipboardUserData, text); +} + +const char* ImGui::GetVersion() +{ + return IMGUI_VERSION; +} + +// Internal state access - if you want to share ImGui state between modules (e.g. DLL) or allocate it yourself +// Note that we still point to some static data and members (such as GFontAtlas), so the state instance you end up using will point to the static data within its module +ImGuiContext* ImGui::GetCurrentContext() +{ + return GImGui; +} + +void ImGui::SetCurrentContext(ImGuiContext* ctx) +{ +#ifdef IMGUI_SET_CURRENT_CONTEXT_FUNC + IMGUI_SET_CURRENT_CONTEXT_FUNC(ctx); // For custom thread-based hackery you may want to have control over this. +#else + GImGui = ctx; +#endif +} + +ImGuiContext* ImGui::CreateContext(void* (*malloc_fn)(size_t), void (*free_fn)(void*)) +{ + if (!malloc_fn) malloc_fn = malloc; + ImGuiContext* ctx = (ImGuiContext*)malloc_fn(sizeof(ImGuiContext)); + IM_PLACEMENT_NEW(ctx) ImGuiContext(); + ctx->IO.MemAllocFn = malloc_fn; + ctx->IO.MemFreeFn = free_fn ? free_fn : free; + return ctx; +} + +void ImGui::DestroyContext(ImGuiContext* ctx) +{ + void (*free_fn)(void*) = ctx->IO.MemFreeFn; + ctx->~ImGuiContext(); + free_fn(ctx); + if (GImGui == ctx) + SetCurrentContext(NULL); +} + +ImGuiIO& ImGui::GetIO() +{ + return GImGui->IO; +} + +ImGuiStyle& ImGui::GetStyle() +{ + return GImGui->Style; +} + +// Same value as passed to your RenderDrawListsFn() function. valid after Render() and until the next call to NewFrame() +ImDrawData* ImGui::GetDrawData() +{ + return GImGui->RenderDrawData.Valid ? &GImGui->RenderDrawData : NULL; +} + +float ImGui::GetTime() +{ + return GImGui->Time; +} + +int ImGui::GetFrameCount() +{ + return GImGui->FrameCount; +} + +ImDrawList* ImGui::GetOverlayDrawList() +{ + return &GImGui->OverlayDrawList; +} + +ImDrawListSharedData* ImGui::GetDrawListSharedData() +{ + return &GImGui->DrawListSharedData; +} + +void ImGui::NewFrame() +{ + ImGuiContext& g = *GImGui; + + // Check user data + // (We pass an error message in the assert expression as a trick to get it visible to programmers who are not using a debugger, as most assert handlers display their argument) + IM_ASSERT(g.IO.DeltaTime >= 0.0f && "Need a positive DeltaTime (zero is tolerated but will cause some timing issues)"); + IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value"); + IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not created. Did you call io.Fonts->GetTexDataAsRGBA32 / GetTexDataAsAlpha8 ?"); + IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not created. Did you call io.Fonts->GetTexDataAsRGBA32 / GetTexDataAsAlpha8 ?"); + IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting"); + IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)"); + IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?"); + + // initialize on first frame + if (!g.Initialized) + initialize(); + + g.Time += g.IO.DeltaTime; + g.FrameCount += 1; + g.TooltipOverrideCount = 0; + g.WindowsActiveCount = 0; + + SetCurrentFont(GetDefaultFont()); + IM_ASSERT(g.Font->IsLoaded()); + g.DrawListSharedData.ClipRectFullscreen = ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y); + g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol; + + g.OverlayDrawList.Clear(); + g.OverlayDrawList.PushTextureID(g.IO.Fonts->TexID); + g.OverlayDrawList.PushClipRectFullScreen(); + g.OverlayDrawList.Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0); + + // Mark rendering data as invalid to prevent user who may have a handle on it to use it + g.RenderDrawData.Valid = false; + g.RenderDrawData.CmdLists = NULL; + g.RenderDrawData.CmdListsCount = g.RenderDrawData.TotalVtxCount = g.RenderDrawData.TotalIdxCount = 0; + + // Clear reference to active widget if the widget isn't alive anymore + if (!g.HoveredIdPreviousFrame) + g.HoveredIdTimer = 0.0f; + g.HoveredIdPreviousFrame = g.HoveredId; + g.HoveredId = 0; + g.HoveredIdAllowOverlap = false; + if (!g.ActiveIdIsAlive && g.ActiveIdPreviousFrame == g.ActiveId && g.ActiveId != 0) + ClearActiveID(); + if (g.ActiveId) + g.ActiveIdTimer += g.IO.DeltaTime; + g.ActiveIdPreviousFrame = g.ActiveId; + g.ActiveIdIsAlive = false; + g.ActiveIdIsJustActivated = false; + if (g.ScalarAsInputTextId && g.ActiveId != g.ScalarAsInputTextId) + g.ScalarAsInputTextId = 0; + + // Elapse drag & drop payload + if (g.DragDropActive && g.DragDropPayload.DataFrameCount + 1 < g.FrameCount) + { + ClearDragDrop(); + g.DragDropPayloadBufHeap.clear(); + memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal)); + } + g.DragDropAcceptIdPrev = g.DragDropAcceptIdCurr; + g.DragDropAcceptIdCurr = 0; + g.DragDropAcceptIdCurrRectSurface = FLT_MAX; + + // update keyboard input state + memcpy(g.IO.KeysDownDurationPrev, g.IO.KeysDownDuration, sizeof(g.IO.KeysDownDuration)); + for (int i = 0; i < IM_ARRAYSIZE(g.IO.KeysDown); i++) + g.IO.KeysDownDuration[i] = g.IO.KeysDown[i] ? (g.IO.KeysDownDuration[i] < 0.0f ? 0.0f : g.IO.KeysDownDuration[i] + g.IO.DeltaTime) : -1.0f; + + // update mouse input state + // If mouse just appeared or disappeared (usually denoted by -FLT_MAX component, but in reality we test for -256000.0f) we cancel out movement in MouseDelta + if (IsMousePosValid(&g.IO.MousePos) && IsMousePosValid(&g.IO.MousePosPrev)) + g.IO.MouseDelta = g.IO.MousePos - g.IO.MousePosPrev; + else + g.IO.MouseDelta = ImVec2(0.0f, 0.0f); + g.IO.MousePosPrev = g.IO.MousePos; + for (int i = 0; i < IM_ARRAYSIZE(g.IO.MouseDown); i++) + { + g.IO.MouseClicked[i] = g.IO.MouseDown[i] && g.IO.MouseDownDuration[i] < 0.0f; + g.IO.MouseReleased[i] = !g.IO.MouseDown[i] && g.IO.MouseDownDuration[i] >= 0.0f; + g.IO.MouseDownDurationPrev[i] = g.IO.MouseDownDuration[i]; + g.IO.MouseDownDuration[i] = g.IO.MouseDown[i] ? (g.IO.MouseDownDuration[i] < 0.0f ? 0.0f : g.IO.MouseDownDuration[i] + g.IO.DeltaTime) : -1.0f; + g.IO.MouseDoubleClicked[i] = false; + if (g.IO.MouseClicked[i]) + { + if (g.Time - g.IO.MouseClickedTime[i] < g.IO.MouseDoubleClickTime) + { + if (ImLengthSqr(g.IO.MousePos - g.IO.MouseClickedPos[i]) < g.IO.MouseDoubleClickMaxDist * g.IO.MouseDoubleClickMaxDist) + g.IO.MouseDoubleClicked[i] = true; + g.IO.MouseClickedTime[i] = -FLT_MAX; // so the third click isn't turned into a double-click + } + else + { + g.IO.MouseClickedTime[i] = g.Time; + } + g.IO.MouseClickedPos[i] = g.IO.MousePos; + g.IO.MouseDragMaxDistanceAbs[i] = ImVec2(0.0f, 0.0f); + g.IO.MouseDragMaxDistanceSqr[i] = 0.0f; + } + else if (g.IO.MouseDown[i]) + { + ImVec2 mouse_delta = g.IO.MousePos - g.IO.MouseClickedPos[i]; + g.IO.MouseDragMaxDistanceAbs[i].x = ImMax(g.IO.MouseDragMaxDistanceAbs[i].x, mouse_delta.x < 0.0f ? -mouse_delta.x : mouse_delta.x); + g.IO.MouseDragMaxDistanceAbs[i].y = ImMax(g.IO.MouseDragMaxDistanceAbs[i].y, mouse_delta.y < 0.0f ? -mouse_delta.y : mouse_delta.y); + g.IO.MouseDragMaxDistanceSqr[i] = ImMax(g.IO.MouseDragMaxDistanceSqr[i], ImLengthSqr(mouse_delta)); + } + } + + // Calculate frame-rate for the user, as a purely luxurious feature + g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx]; + g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx] = g.IO.DeltaTime; + g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame); + g.IO.Framerate = 1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame)); + + // Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering). + if (g.MovingWindowMoveId && g.MovingWindowMoveId == g.ActiveId) + { + KeepAliveID(g.ActiveId); + IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow); + IM_ASSERT(g.MovingWindow->MoveId == g.MovingWindowMoveId); + if (g.IO.MouseDown[0]) + { + ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset; + if (g.MovingWindow->RootWindow->PosFloat.x != pos.x || g.MovingWindow->RootWindow->PosFloat.y != pos.y) + MarkIniSettingsDirty(g.MovingWindow->RootWindow); + g.MovingWindow->RootWindow->PosFloat = pos; + FocusWindow(g.MovingWindow); + } + else + { + ClearActiveID(); + g.MovingWindow = NULL; + g.MovingWindowMoveId = 0; + } + } + else + { + // When clicking/dragging from a window that has the _NoMove flag, we still set the ActiveId in order to prevent hovering others. + if (g.ActiveIdWindow && g.ActiveIdWindow->MoveId == g.ActiveId) + { + KeepAliveID(g.ActiveId); + if (!g.IO.MouseDown[0]) + ClearActiveID(); + } + g.MovingWindow = NULL; + g.MovingWindowMoveId = 0; + } + + // Delay saving settings so we don't spam disk too much + if (g.SettingsDirtyTimer > 0.0f) + { + g.SettingsDirtyTimer -= g.IO.DeltaTime; + if (g.SettingsDirtyTimer <= 0.0f) + SaveIniSettingsToDisk(g.IO.IniFilename); + } + + // Find the window we are hovering + // - Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow. + // - When moving a window we can skip the search, which also conveniently bypasses the fact that window->WindowRectClipped is lagging as this point. + // - We also support the moved window toggling the NoInputs flag after moving has started in order to be able to detect windows below it, which is useful for e.g. docking mechanisms. + g.HoveredWindow = (g.MovingWindow && !(g.MovingWindow->Flags & ImGuiWindowFlags_NoInputs)) ? g.MovingWindow : FindHoveredWindow(g.IO.MousePos); + g.HoveredRootWindow = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL; + + ImGuiWindow* modal_window = GetFrontMostModalRootWindow(); + if (modal_window != NULL) + { + g.ModalWindowDarkeningRatio = ImMin(g.ModalWindowDarkeningRatio + g.IO.DeltaTime * 6.0f, 1.0f); + if (g.HoveredRootWindow && !IsWindowChildOf(g.HoveredRootWindow, modal_window)) + g.HoveredRootWindow = g.HoveredWindow = NULL; + } + else + { + g.ModalWindowDarkeningRatio = 0.0f; + } + + // update the WantCaptureMouse/WantCAptureKeyboard flags, so user can capture/discard the inputs away from the rest of their application. + // When clicking outside of a window we assume the click is owned by the application and won't request capture. We need to track click ownership. + int mouse_earliest_button_down = -1; + bool mouse_any_down = false; + for (int i = 0; i < IM_ARRAYSIZE(g.IO.MouseDown); i++) + { + if (g.IO.MouseClicked[i]) + g.IO.MouseDownOwned[i] = (g.HoveredWindow != NULL) || (!g.OpenPopupStack.empty()); + mouse_any_down |= g.IO.MouseDown[i]; + if (g.IO.MouseDown[i]) + if (mouse_earliest_button_down == -1 || g.IO.MouseClickedTime[i] < g.IO.MouseClickedTime[mouse_earliest_button_down]) + mouse_earliest_button_down = i; + } + bool mouse_avail_to_imgui = (mouse_earliest_button_down == -1) || g.IO.MouseDownOwned[mouse_earliest_button_down]; + if (g.WantCaptureMouseNextFrame != -1) + g.IO.WantCaptureMouse = (g.WantCaptureMouseNextFrame != 0); + else + g.IO.WantCaptureMouse = (mouse_avail_to_imgui && (g.HoveredWindow != NULL || mouse_any_down)) || (!g.OpenPopupStack.empty()); + if (g.WantCaptureKeyboardNextFrame != -1) + g.IO.WantCaptureKeyboard = (g.WantCaptureKeyboardNextFrame != 0); + else + g.IO.WantCaptureKeyboard = (g.ActiveId != 0) || (modal_window != NULL); + g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : 0; + g.MouseCursor = ImGuiMouseCursor_Arrow; + g.WantCaptureMouseNextFrame = g.WantCaptureKeyboardNextFrame = g.WantTextInputNextFrame = -1; + g.OsImePosRequest = ImVec2(1.0f, 1.0f); // OS Input Method Editor showing on top-left of our window by default + + // If mouse was first clicked outside of ImGui bounds we also cancel out hovering. + // FIXME: For patterns of drag and drop across OS windows, we may need to rework/remove this test (first committed 311c0ca9 on 2015/02) + bool mouse_dragging_extern_payload = g.DragDropActive && (g.DragDropSourceFlags & ImGuiDragDropFlags_SourceExtern) != 0; + if (!mouse_avail_to_imgui && !mouse_dragging_extern_payload) + g.HoveredWindow = g.HoveredRootWindow = NULL; + + // Scale & Scrolling + if (g.HoveredWindow && g.IO.MouseWheel != 0.0f && !g.HoveredWindow->Collapsed) + { + ImGuiWindow* window = g.HoveredWindow; + if (g.IO.KeyCtrl && g.IO.FontAllowUserScaling) + { + // Zoom / Scale window + const float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f); + const float scale = new_font_scale / window->FontWindowScale; + window->FontWindowScale = new_font_scale; + + const ImVec2 offset = window->Size * (1.0f - scale) * (g.IO.MousePos - window->Pos) / window->Size; + window->Pos += offset; + window->PosFloat += offset; + window->Size *= scale; + window->SizeFull *= scale; + } + else if (!g.IO.KeyCtrl) + { + // Mouse wheel Scrolling + // If a child window has the ImGuiWindowFlags_NoScrollWithMouse flag, we give a chance to scroll its parent (unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set). + ImGuiWindow* scroll_window = window; + while ((scroll_window->Flags & ImGuiWindowFlags_ChildWindow) && (scroll_window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(scroll_window->Flags & ImGuiWindowFlags_NoScrollbar) && !(scroll_window->Flags & ImGuiWindowFlags_NoInputs) && scroll_window->ParentWindow) + scroll_window = scroll_window->ParentWindow; + + if (!(scroll_window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(scroll_window->Flags & ImGuiWindowFlags_NoInputs)) + { + float scroll_amount = 5 * scroll_window->CalcFontSize(); + scroll_amount = (float)(int)ImMin(scroll_amount, (scroll_window->ContentsRegionRect.GetHeight() + scroll_window->WindowPadding.y * 2.0f) * 0.67f); + SetWindowScrollY(scroll_window, scroll_window->Scroll.y - g.IO.MouseWheel * scroll_amount); + } + } + } + + // Pressing TAB activate widget focus + if (g.ActiveId == 0 && g.NavWindow != NULL && g.NavWindow->Active && IsKeyPressedMap(ImGuiKey_Tab, false)) + g.NavWindow->FocusIdxTabRequestNext = 0; + + // Mark all windows as not visible + for (int i = 0; i != g.Windows.Size; i++) + { + ImGuiWindow* window = g.Windows[i]; + window->WasActive = window->Active; + window->Active = false; + window->WriteAccessed = false; + } + + // Closing the focused window restore focus to the first active root window in descending z-order + if (g.NavWindow && !g.NavWindow->WasActive) + FocusFrontMostActiveWindow(NULL); + + // No window should be open at the beginning of the frame. + // But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear. + g.CurrentWindowStack.resize(0); + g.CurrentPopupStack.resize(0); + CloseInactivePopups(g.NavWindow); + + // Create implicit window - we will only render it if the user has added something to it. + // We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags. + SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver); + Begin("Debug##Default"); +} + +static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name) +{ + ImGuiWindowSettings* settings = ImGui::FindWindowSettings(ImHash(name, 0)); + if (!settings) + settings = AddWindowSettings(name); + return (void*)settings; +} + +static void SettingsHandlerWindow_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line) +{ + ImGuiWindowSettings* settings = (ImGuiWindowSettings*)entry; + float x, y; + int i; + if (sscanf(line, "Pos=%f,%f", &x, &y) == 2) settings->Pos = ImVec2(x, y); + else if (sscanf(line, "Size=%f,%f", &x, &y) == 2) settings->Size = ImMax(ImVec2(x, y), GImGui->Style.WindowMinSize); + else if (sscanf(line, "Collapsed=%d", &i) == 1) settings->Collapsed = (i != 0); +} + +static void SettingsHandlerWindow_WriteAll(ImGuiContext* imgui_ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf) +{ + // Gather data from windows that were active during this session + ImGuiContext& g = *imgui_ctx; + for (int i = 0; i != g.Windows.Size; i++) + { + ImGuiWindow* window = g.Windows[i]; + if (window->Flags & ImGuiWindowFlags_NoSavedSettings) + continue; + ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID); + if (!settings) + settings = AddWindowSettings(window->Name); + settings->Pos = window->Pos; + settings->Size = window->SizeFull; + settings->Collapsed = window->Collapsed; + } + + // Write a buffer + // If a window wasn't opened in this session we preserve its settings + buf->reserve(buf->size() + g.SettingsWindows.Size * 96); // ballpark reserve + for (int i = 0; i != g.SettingsWindows.Size; i++) + { + const ImGuiWindowSettings* settings = &g.SettingsWindows[i]; + if (settings->Pos.x == FLT_MAX) + continue; + const char* name = settings->Name; + if (const char* p = strstr(name, "###")) // Skip to the "###" marker if any. We don't skip past to match the behavior of GetID() + name = p; + buf->appendf("[%s][%s]\n", handler->TypeName, name); + buf->appendf("Pos=%d,%d\n", (int)settings->Pos.x, (int)settings->Pos.y); + buf->appendf("Size=%d,%d\n", (int)settings->Size.x, (int)settings->Size.y); + buf->appendf("Collapsed=%d\n", settings->Collapsed); + buf->appendf("\n"); + } +} + +void ImGui::initialize() +{ + ImGuiContext& g = *GImGui; + g.LogClipboard = IM_NEW(ImGuiTextBuffer)(); + + // Add .ini handle for ImGuiWindow type + ImGuiSettingsHandler ini_handler; + ini_handler.TypeName = "Window"; + ini_handler.TypeHash = ImHash("Window", 0, 0); + ini_handler.ReadOpenFn = SettingsHandlerWindow_ReadOpen; + ini_handler.ReadLineFn = SettingsHandlerWindow_ReadLine; + ini_handler.WriteAllFn = SettingsHandlerWindow_WriteAll; + g.SettingsHandlers.push_front(ini_handler); + + // Load .ini file + IM_ASSERT(g.SettingsWindows.empty()); + LoadIniSettingsFromDisk(g.IO.IniFilename); + g.Initialized = true; +} + +// This function is merely here to free heap allocations. +void ImGui::Shutdown() +{ + ImGuiContext& g = *GImGui; + + // The fonts atlas can be used prior to calling NewFrame(), so we clear it even if g.Initialized is FALSE (which would happen if we never called NewFrame) + if (g.IO.Fonts) // Testing for NULL to allow user to NULLify in case of running Shutdown() on multiple contexts. Bit hacky. + g.IO.Fonts->Clear(); + + // Cleanup of other data are conditional on actually having initialize ImGui. + if (!g.Initialized) + return; + + SaveIniSettingsToDisk(g.IO.IniFilename); + + for (int i = 0; i < g.Windows.Size; i++) + IM_DELETE(g.Windows[i]); + g.Windows.clear(); + g.WindowsSortBuffer.clear(); + g.CurrentWindow = NULL; + g.CurrentWindowStack.clear(); + g.WindowsById.Clear(); + g.NavWindow = NULL; + g.HoveredWindow = NULL; + g.HoveredRootWindow = NULL; + g.ActiveIdWindow = NULL; + g.MovingWindow = NULL; + for (int i = 0; i < g.SettingsWindows.Size; i++) + IM_DELETE(g.SettingsWindows[i].Name); + g.ColorModifiers.clear(); + g.StyleModifiers.clear(); + g.FontStack.clear(); + g.OpenPopupStack.clear(); + g.CurrentPopupStack.clear(); + for (int i = 0; i < IM_ARRAYSIZE(g.RenderDrawLists); i++) + g.RenderDrawLists[i].clear(); + g.OverlayDrawList.ClearFreeMemory(); + g.PrivateClipboard.clear(); + g.InputTextState.Text.clear(); + g.InputTextState.InitialText.clear(); + g.InputTextState.TempTextBuffer.clear(); + + g.SettingsWindows.clear(); + g.SettingsHandlers.clear(); + + if (g.LogFile && g.LogFile != stdout) + { + fclose(g.LogFile); + g.LogFile = NULL; + } + if (g.LogClipboard) + IM_DELETE(g.LogClipboard); + + g.Initialized = false; +} + +ImGuiWindowSettings* ImGui::FindWindowSettings(ImGuiID id) +{ + ImGuiContext& g = *GImGui; + for (int i = 0; i != g.SettingsWindows.Size; i++) + if (g.SettingsWindows[i].Id == id) + return &g.SettingsWindows[i]; + return NULL; +} + +static ImGuiWindowSettings* AddWindowSettings(const char* name) +{ + ImGuiContext& g = *GImGui; + g.SettingsWindows.push_back(ImGuiWindowSettings()); + ImGuiWindowSettings* settings = &g.SettingsWindows.back(); + settings->Name = ImStrdup(name); + settings->Id = ImHash(name, 0); + return settings; +} + +static void LoadIniSettingsFromDisk(const char* ini_filename) +{ + if (!ini_filename) + return; + char* file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", NULL, +1); + if (!file_data) + return; + LoadIniSettingsFromMemory(file_data); + ImGui::MemFree(file_data); +} + +ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name) +{ + ImGuiContext& g = *GImGui; + const ImGuiID type_hash = ImHash(type_name, 0, 0); + for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) + if (g.SettingsHandlers[handler_n].TypeHash == type_hash) + return &g.SettingsHandlers[handler_n]; + return NULL; +} + +// Zero-tolerance, no error reporting, cheap .ini parsing +static void LoadIniSettingsFromMemory(const char* buf_readonly) +{ + // For convenience and to make the code simpler, we'll write zero terminators inside the buffer. So let's create a writable copy. + char* buf = ImStrdup(buf_readonly); + char* buf_end = buf + strlen(buf); + + ImGuiContext& g = *GImGui; + void* entry_data = NULL; + ImGuiSettingsHandler* entry_handler = NULL; + + char* line_end = NULL; + for (char* line = buf; line < buf_end; line = line_end + 1) + { + // Skip new lines markers, then find end of the line + while (*line == '\n' || *line == '\r') + line++; + line_end = line; + while (line_end < buf_end && *line_end != '\n' && *line_end != '\r') + line_end++; + line_end[0] = 0; + + if (line[0] == '[' && line_end > line && line_end[-1] == ']') + { + // Parse "[Type][Name]". Note that 'Name' can itself contains [] characters, which is acceptable with the current format and parsing code. + line_end[-1] = 0; + const char* name_end = line_end - 1; + const char* type_start = line + 1; + char* type_end = ImStrchrRange(type_start, name_end, ']'); + const char* name_start = type_end ? ImStrchrRange(type_end + 1, name_end, '[') : NULL; + if (!type_end || !name_start) + { + name_start = type_start; // Import legacy entries that have no type + type_start = "Window"; + } + else + { + *type_end = 0; // Overwrite first ']' + name_start++; // Skip second '[' + } + entry_handler = ImGui::FindSettingsHandler(type_start); + entry_data = entry_handler ? entry_handler->ReadOpenFn(&g, entry_handler, name_start) : NULL; + } + else if (entry_handler != NULL && entry_data != NULL) + { + // Let type handler parse the line + entry_handler->ReadLineFn(&g, entry_handler, entry_data, line); + } + } + ImGui::MemFree(buf); +} + +static void SaveIniSettingsToDisk(const char* ini_filename) +{ + ImGuiContext& g = *GImGui; + g.SettingsDirtyTimer = 0.0f; + if (!ini_filename) + return; + + ImVector buf; + SaveIniSettingsToMemory(buf); + + FILE* f = ImFileOpen(ini_filename, "wt"); + if (!f) + return; + fwrite(buf.Data, sizeof(char), (size_t)buf.Size, f); + fclose(f); +} + +static void SaveIniSettingsToMemory(ImVector& out_buf) +{ + ImGuiContext& g = *GImGui; + g.SettingsDirtyTimer = 0.0f; + + ImGuiTextBuffer buf; + for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) + { + ImGuiSettingsHandler* handler = &g.SettingsHandlers[handler_n]; + handler->WriteAllFn(&g, handler, &buf); + } + + buf.Buf.pop_back(); // Remove extra zero-terminator used by ImGuiTextBuffer + out_buf.swap(buf.Buf); +} + +void ImGui::MarkIniSettingsDirty() +{ + ImGuiContext& g = *GImGui; + if (g.SettingsDirtyTimer <= 0.0f) + g.SettingsDirtyTimer = g.IO.IniSavingRate; +} + +static void MarkIniSettingsDirty(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings)) + if (g.SettingsDirtyTimer <= 0.0f) + g.SettingsDirtyTimer = g.IO.IniSavingRate; +} + +// FIXME: Add a more explicit sort order in the window structure. +static int ChildWindowComparer(const void* lhs, const void* rhs) +{ + const ImGuiWindow* a = *(const ImGuiWindow**)lhs; + const ImGuiWindow* b = *(const ImGuiWindow**)rhs; + if (int d = (a->Flags & ImGuiWindowFlags_Popup) - (b->Flags & ImGuiWindowFlags_Popup)) + return d; + if (int d = (a->Flags & ImGuiWindowFlags_Tooltip) - (b->Flags & ImGuiWindowFlags_Tooltip)) + return d; + return (a->BeginOrderWithinParent - b->BeginOrderWithinParent); +} + +static void AddWindowToSortedBuffer(ImVector& out_sorted_windows, ImGuiWindow* window) +{ + out_sorted_windows.push_back(window); + if (window->Active) + { + int count = window->DC.ChildWindows.Size; + if (count > 1) + qsort(window->DC.ChildWindows.begin(), (size_t)count, sizeof(ImGuiWindow*), ChildWindowComparer); + for (int i = 0; i < count; i++) + { + ImGuiWindow* child = window->DC.ChildWindows[i]; + if (child->Active) + AddWindowToSortedBuffer(out_sorted_windows, child); + } + } +} + +static void AddDrawListToRenderList(ImVector& out_render_list, ImDrawList* draw_list) +{ + if (draw_list->CmdBuffer.empty()) + return; + + // Remove trailing command if unused + ImDrawCmd& last_cmd = draw_list->CmdBuffer.back(); + if (last_cmd.ElemCount == 0 && last_cmd.UserCallback == NULL) + { + draw_list->CmdBuffer.pop_back(); + if (draw_list->CmdBuffer.empty()) + return; + } + + // Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc. May trigger for you if you are using PrimXXX functions incorrectly. + IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size); + IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size); + IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size); + + // Check that draw_list doesn't use more vertices than indexable in a single draw call (default ImDrawIdx = unsigned short = 2 BYTEs = 64K vertices per ImDrawList = per window) + // If this assert triggers because you are drawing lots of stuff manually: + // A) Make sure you are coarse clipping, because ImDrawList let all your vertices pass. You can use thre Metrics window to inspect draw list contents. + // B) If you need/want meshes with more than 64K vertices, uncomment the '#define ImDrawIdx unsigned int' line in imconfig.h to set the index size to 4 BYTEs. + // You'll need to handle the 4-BYTEs indices to your renderer. For example, the OpenGL example code detect index size at compile-time by doing: + // glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset); + // Your own engine or render API may use different parameters or function calls to specify index sizes. 2 and 4 BYTEs indices are generally supported by most API. + // C) If for some reason you cannot use 4 BYTEs indices or don't want to, a workaround is to call BeginChild()/EndChild() before reaching the 64K limit to split your draw commands in multiple draw lists. + if (sizeof(ImDrawIdx) == 2) + IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above"); + + out_render_list.push_back(draw_list); + GImGui->IO.MetricsRenderVertices += draw_list->VtxBuffer.Size; + GImGui->IO.MetricsRenderIndices += draw_list->IdxBuffer.Size; +} + +static void AddWindowToRenderList(ImVector& out_render_list, ImGuiWindow* window) +{ + AddDrawListToRenderList(out_render_list, window->DrawList); + for (int i = 0; i < window->DC.ChildWindows.Size; i++) + { + ImGuiWindow* child = window->DC.ChildWindows[i]; + if (!child->Active) // clipped children may have been marked not active + continue; + if (child->HiddenFrames > 0) + continue; + AddWindowToRenderList(out_render_list, child); + } +} + +static void AddWindowToRenderListSelectLayer(ImGuiWindow* window) +{ + // FIXME: Generalize this with a proper layering system so e.g. user can draw in specific layers, below text, .. + ImGuiContext& g = *GImGui; + g.IO.MetricsActiveWindows++; + if (window->Flags & ImGuiWindowFlags_Popup) + AddWindowToRenderList(g.RenderDrawLists[1], window); + else if (window->Flags & ImGuiWindowFlags_Tooltip) + AddWindowToRenderList(g.RenderDrawLists[2], window); + else + AddWindowToRenderList(g.RenderDrawLists[0], window); +} + +// When using this function it is sane to ensure that float are perfectly rounded to integer values, to that e.g. (int)(max.x-min.x) in user's render produce correct result. +void ImGui::PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DrawList->PushClipRect(clip_rect_min, clip_rect_max, intersect_with_current_clip_rect); + window->ClipRect = window->DrawList->_ClipRectStack.back(); +} + +void ImGui::PopClipRect() +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DrawList->PopClipRect(); + window->ClipRect = window->DrawList->_ClipRectStack.back(); +} + +// This is normally called by Render(). You may want to call it directly if you want to avoid calling Render() but the gain will be very minimal. +void ImGui::EndFrame() +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(g.Initialized); // Forgot to call ImGui::NewFrame() + if (g.FrameCountEnded == g.FrameCount) // Don't process EndFrame() multiple times. + return; + + // Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME) + if (g.IO.ImeSetInputScreenPosFn && ImLengthSqr(g.OsImePosRequest - g.OsImePosSet) > 0.0001f) + { + g.IO.ImeSetInputScreenPosFn((int)g.OsImePosRequest.x, (int)g.OsImePosRequest.y); + g.OsImePosSet = g.OsImePosRequest; + } + + // Hide implicit "Debug" window if it hasn't been used + IM_ASSERT(g.CurrentWindowStack.Size == 1); // Mismatched Begin()/End() calls + if (g.CurrentWindow && !g.CurrentWindow->WriteAccessed) + g.CurrentWindow->Active = false; + End(); + + if (g.ActiveId == 0 && g.HoveredId == 0) + { + if (!g.NavWindow || !g.NavWindow->Appearing) // Unless we just made a window/popup appear + { + // Click to focus window and start moving (after we're done with all our widgets) + if (g.IO.MouseClicked[0]) + { + if (g.HoveredRootWindow != NULL) + { + // set ActiveId even if the _NoMove flag is set, without it dragging away from a window with _NoMove would activate hover on other windows. + FocusWindow(g.HoveredWindow); + SetActiveID(g.HoveredWindow->MoveId, g.HoveredWindow); + g.ActiveIdClickOffset = g.IO.MousePos - g.HoveredRootWindow->Pos; + if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove) && !(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoMove)) + { + g.MovingWindow = g.HoveredWindow; + g.MovingWindowMoveId = g.MovingWindow->MoveId; + } + } + else if (g.NavWindow != NULL && GetFrontMostModalRootWindow() == NULL) + { + // Clicking on void disable focus + FocusWindow(NULL); + } + } + + // With right mouse button we close popups without changing focus + // (The left mouse button path calls FocusWindow which will lead NewFrame->CloseInactivePopups to trigger) + if (g.IO.MouseClicked[1]) + { + // Find the top-most window between HoveredWindow and the front most Modal Window. + // This is where we can trim the popup stack. + ImGuiWindow* modal = GetFrontMostModalRootWindow(); + bool hovered_window_above_modal = false; + if (modal == NULL) + hovered_window_above_modal = true; + for (int i = g.Windows.Size - 1; i >= 0 && hovered_window_above_modal == false; i--) + { + ImGuiWindow* window = g.Windows[i]; + if (window == modal) + break; + if (window == g.HoveredWindow) + hovered_window_above_modal = true; + } + CloseInactivePopups(hovered_window_above_modal ? g.HoveredWindow : modal); + } + } + } + + // Sort the window list so that all child windows are after their parent + // We cannot do that on FocusWindow() because childs may not exist yet + g.WindowsSortBuffer.resize(0); + g.WindowsSortBuffer.reserve(g.Windows.Size); + for (int i = 0; i != g.Windows.Size; i++) + { + ImGuiWindow* window = g.Windows[i]; + if (window->Active && (window->Flags & ImGuiWindowFlags_ChildWindow)) // if a child is active its parent will add it + continue; + AddWindowToSortedBuffer(g.WindowsSortBuffer, window); + } + + IM_ASSERT(g.Windows.Size == g.WindowsSortBuffer.Size); // we done something wrong + g.Windows.swap(g.WindowsSortBuffer); + + // Clear Input data for next frame + g.IO.MouseWheel = 0.0f; + memset(g.IO.InputCharacters, 0, sizeof(g.IO.InputCharacters)); + + g.FrameCountEnded = g.FrameCount; +} + +void ImGui::Render() +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(g.Initialized); // Forgot to call ImGui::NewFrame() + + if (g.FrameCountEnded != g.FrameCount) + ImGui::EndFrame(); + g.FrameCountRendered = g.FrameCount; + + // Skip render altogether if alpha is 0.0 + // Note that vertex buffers have been created and are wasted, so it is best practice that you don't create windows in the first place, or consistently respond to Begin() returning false. + if (g.Style.Alpha > 0.0f) + { + // Gather windows to render + g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = g.IO.MetricsActiveWindows = 0; + for (int i = 0; i < IM_ARRAYSIZE(g.RenderDrawLists); i++) + g.RenderDrawLists[i].resize(0); + for (int i = 0; i != g.Windows.Size; i++) + { + ImGuiWindow* window = g.Windows[i]; + if (window->Active && window->HiddenFrames <= 0 && (window->Flags & (ImGuiWindowFlags_ChildWindow)) == 0) + AddWindowToRenderListSelectLayer(window); + } + + // Flatten layers + int n = g.RenderDrawLists[0].Size; + int flattened_size = n; + for (int i = 1; i < IM_ARRAYSIZE(g.RenderDrawLists); i++) + flattened_size += g.RenderDrawLists[i].Size; + g.RenderDrawLists[0].resize(flattened_size); + for (int i = 1; i < IM_ARRAYSIZE(g.RenderDrawLists); i++) + { + ImVector& layer = g.RenderDrawLists[i]; + if (layer.empty()) + continue; + memcpy(&g.RenderDrawLists[0][n], &layer[0], layer.Size * sizeof(ImDrawList*)); + n += layer.Size; + } + + // Draw software mouse cursor if requested + if (g.IO.MouseDrawCursor) + { + const ImGuiMouseCursorData& cursor_data = g.MouseCursorData[g.MouseCursor]; + const ImVec2 pos = g.IO.MousePos - cursor_data.HotOffset; + const ImVec2 size = cursor_data.Size; + const ImTextureID tex_id = g.IO.Fonts->TexID; + g.OverlayDrawList.PushTextureID(tex_id); + g.OverlayDrawList.AddImage(tex_id, pos+ImVec2(1,0), pos+ImVec2(1,0) + size, cursor_data.TexUvMin[1], cursor_data.TexUvMax[1], IM_COL32(0,0,0,48)); // Shadow + g.OverlayDrawList.AddImage(tex_id, pos+ImVec2(2,0), pos+ImVec2(2,0) + size, cursor_data.TexUvMin[1], cursor_data.TexUvMax[1], IM_COL32(0,0,0,48)); // Shadow + g.OverlayDrawList.AddImage(tex_id, pos, pos + size, cursor_data.TexUvMin[1], cursor_data.TexUvMax[1], IM_COL32(0,0,0,255)); // Black border + g.OverlayDrawList.AddImage(tex_id, pos, pos + size, cursor_data.TexUvMin[0], cursor_data.TexUvMax[0], IM_COL32(255,255,255,255)); // White fill + g.OverlayDrawList.PopTextureID(); + } + if (!g.OverlayDrawList.VtxBuffer.empty()) + AddDrawListToRenderList(g.RenderDrawLists[0], &g.OverlayDrawList); + + // Setup draw data + g.RenderDrawData.Valid = true; + g.RenderDrawData.CmdLists = (g.RenderDrawLists[0].Size > 0) ? &g.RenderDrawLists[0][0] : NULL; + g.RenderDrawData.CmdListsCount = g.RenderDrawLists[0].Size; + g.RenderDrawData.TotalVtxCount = g.IO.MetricsRenderVertices; + g.RenderDrawData.TotalIdxCount = g.IO.MetricsRenderIndices; + + // Render. If user hasn't set a callback then they may retrieve the draw data via GetDrawData() + if (g.RenderDrawData.CmdListsCount > 0 && g.IO.RenderDrawListsFn != NULL) + g.IO.RenderDrawListsFn(&g.RenderDrawData); + } +} + +static inline float SmallSquareSize() +{ + ImGuiContext& g = *GImGui; + return g.FontSize + g.Style.FramePadding.y * 2.0f; +} + +const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end) +{ + const char* text_display_end = text; + if (!text_end) + text_end = (const char*)-1; + + while (text_display_end < text_end && *text_display_end != '\0' && (text_display_end[0] != '#' || text_display_end[1] != '#')) + text_display_end++; + return text_display_end; +} + +// Pass text data straight to log (without being displayed) +void ImGui::LogText(const char* fmt, ...) +{ + ImGuiContext& g = *GImGui; + if (!g.LogEnabled) + return; + + va_list args; + va_start(args, fmt); + if (g.LogFile) + { + vfprintf(g.LogFile, fmt, args); + } + else + { + g.LogClipboard->appendfv(fmt, args); + } + va_end(args); +} + +// Internal version that takes a position to decide on newline placement and pad items according to their depth. +// We split text into individual lines to add current tree level padding +static void LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end = NULL) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + if (!text_end) + text_end = ImGui::FindRenderedTextEnd(text, text_end); + + const bool log_new_line = ref_pos && (ref_pos->y > window->DC.LogLinePosY + 1); + if (ref_pos) + window->DC.LogLinePosY = ref_pos->y; + + const char* text_remaining = text; + if (g.LogStartDepth > window->DC.TreeDepth) // Re-adjust padding if we have popped out of our starting depth + g.LogStartDepth = window->DC.TreeDepth; + const int tree_depth = (window->DC.TreeDepth - g.LogStartDepth); + for (;;) + { + // Split the string. Each new line (after a '\n') is followed by spacing corresponding to the current depth of our log entry. + const char* line_end = text_remaining; + while (line_end < text_end) + if (*line_end == '\n') + break; + else + line_end++; + if (line_end >= text_end) + line_end = NULL; + + const bool is_first_line = (text == text_remaining); + bool is_last_line = false; + if (line_end == NULL) + { + is_last_line = true; + line_end = text_end; + } + if (line_end != NULL && !(is_last_line && (line_end - text_remaining)==0)) + { + const int char_count = (int)(line_end - text_remaining); + if (log_new_line || !is_first_line) + ImGui::LogText(IM_NEWLINE "%*s%.*s", tree_depth*4, "", char_count, text_remaining); + else + ImGui::LogText(" %.*s", char_count, text_remaining); + } + + if (is_last_line) + break; + text_remaining = line_end + 1; + } +} + +// Internal ImGui functions to render text +// RenderText***() functions calls ImDrawList::AddText() calls ImBitmapFont::RenderText() +void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool hide_text_after_hash) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + // Hide anything after a '##' string + const char* text_display_end; + if (hide_text_after_hash) + { + text_display_end = FindRenderedTextEnd(text, text_end); + } + else + { + if (!text_end) + text_end = text + strlen(text); // FIXME-OPT + text_display_end = text_end; + } + + const int text_len = (int)(text_display_end - text); + if (text_len > 0) + { + window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_display_end); + if (g.LogEnabled) + LogRenderedText(&pos, text, text_display_end); + } +} + +void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + if (!text_end) + text_end = text + strlen(text); // FIXME-OPT + + const int text_len = (int)(text_end - text); + if (text_len > 0) + { + window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_end, wrap_width); + if (g.LogEnabled) + LogRenderedText(&pos, text, text_end); + } +} + +// Default clip_rect uses (pos_min,pos_max) +// Handle clipping on CPU immediately (vs typically let the GPU clip the triangles that are overlapping the clipping rectangle edges) +void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect) +{ + // Hide anything after a '##' string + const char* text_display_end = FindRenderedTextEnd(text, text_end); + const int text_len = (int)(text_display_end - text); + if (text_len == 0) + return; + + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + // Perform CPU side clipping for single clipped element to avoid using scissor state + ImVec2 pos = pos_min; + const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_display_end, false, 0.0f); + + const ImVec2* clip_min = clip_rect ? &clip_rect->Min : &pos_min; + const ImVec2* clip_max = clip_rect ? &clip_rect->Max : &pos_max; + bool need_clipping = (pos.x + text_size.x >= clip_max->x) || (pos.y + text_size.y >= clip_max->y); + if (clip_rect) // If we had no explicit clipping rectangle then pos==clip_min + need_clipping |= (pos.x < clip_min->x) || (pos.y < clip_min->y); + + // Align whole block. We should defer that to the better rendering function when we'll have support for individual line alignment. + if (align.x > 0.0f) pos.x = ImMax(pos.x, pos.x + (pos_max.x - pos.x - text_size.x) * align.x); + if (align.y > 0.0f) pos.y = ImMax(pos.y, pos.y + (pos_max.y - pos.y - text_size.y) * align.y); + + // Render + if (need_clipping) + { + ImVec4 fine_clip_rect(clip_min->x, clip_min->y, clip_max->x, clip_max->y); + window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, &fine_clip_rect); + } + else + { + window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, NULL); + } + if (g.LogEnabled) + LogRenderedText(&pos, text, text_display_end); +} + +// Render a rectangle shaped with optional rounding and borders +void ImGui::RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border, float rounding) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + window->DrawList->AddRectFilled(p_min, p_max, fill_col, rounding); + const float border_size = g.Style.FrameBorderSize; + if (border && border_size > 0.0f) + { + window->DrawList->AddRect(p_min+ImVec2(1,1), p_max+ImVec2(1,1), GetColorU32(ImGuiCol_BorderShadow), rounding, ImDrawCornerFlags_All, border_size); + window->DrawList->AddRect(p_min, p_max, GetColorU32(ImGuiCol_Border), rounding, ImDrawCornerFlags_All, border_size); + } +} + +void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + const float border_size = g.Style.FrameBorderSize; + if (border_size > 0.0f) + { + window->DrawList->AddRect(p_min+ImVec2(1,1), p_max+ImVec2(1,1), GetColorU32(ImGuiCol_BorderShadow), rounding, ImDrawCornerFlags_All, border_size); + window->DrawList->AddRect(p_min, p_max, GetColorU32(ImGuiCol_Border), rounding, ImDrawCornerFlags_All, border_size); + } +} + +// Render a triangle to denote expanded/collapsed state +void ImGui::RenderTriangle(ImVec2 p_min, ImGuiDir dir, float scale) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + const float h = g.FontSize * 1.00f; + float r = h * 0.40f * scale; + ImVec2 center = p_min + ImVec2(h * 0.50f, h * 0.50f * scale); + + ImVec2 a, b, c; + switch (dir) + { + case ImGuiDir_Up: + case ImGuiDir_Down: + if (dir == ImGuiDir_Up) r = -r; + center.y -= r * 0.25f; + a = ImVec2(0,1) * r; + b = ImVec2(-0.866f,-0.5f) * r; + c = ImVec2(+0.866f,-0.5f) * r; + break; + case ImGuiDir_Left: + case ImGuiDir_Right: + if (dir == ImGuiDir_Left) r = -r; + center.x -= r * 0.25f; + a = ImVec2(1,0) * r; + b = ImVec2(-0.500f,+0.866f) * r; + c = ImVec2(-0.500f,-0.866f) * r; + break; + case ImGuiDir_None: + case ImGuiDir_Count_: + IM_ASSERT(0); + break; + } + + window->DrawList->AddTriangleFilled(center + a, center + b, center + c, GetColorU32(ImGuiCol_Text)); +} + +void ImGui::RenderBullet(ImVec2 pos) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + window->DrawList->AddCircleFilled(pos, GImGui->FontSize*0.20f, GetColorU32(ImGuiCol_Text), 8); +} + +void ImGui::RenderCheckMark(ImVec2 pos, ImU32 col, float sz) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + float thickness = ImMax(sz / 5.0f, 1.0f); + sz -= thickness*0.5f; + pos += ImVec2(thickness*0.25f, thickness*0.25f); + + float third = sz / 3.0f; + float bx = pos.x + third; + float by = pos.y + sz - third*0.5f; + window->DrawList->PathLineTo(ImVec2(bx - third, by - third)); + window->DrawList->PathLineTo(ImVec2(bx, by)); + window->DrawList->PathLineTo(ImVec2(bx + third*2, by - third*2)); + window->DrawList->PathStroke(col, false, thickness); +} + +// Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. +// CalcTextSize("") should return ImVec2(0.0f, GImGui->FontSize) +ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width) +{ + ImGuiContext& g = *GImGui; + + const char* text_display_end; + if (hide_text_after_double_hash) + text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string + else + text_display_end = text_end; + + ImFont* font = g.Font; + const float font_size = g.FontSize; + if (text == text_display_end) + return ImVec2(0.0f, font_size); + ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL); + + // Cancel out character spacing for the last character of a line (it is baked into glyph->AdvanceX field) + const float font_scale = font_size / font->FontSize; + const float character_spacing_x = 1.0f * font_scale; + if (text_size.x > 0.0f) + text_size.x -= character_spacing_x; + text_size.x = (float)(int)(text_size.x + 0.95f); + + return text_size; +} + +// Helper to calculate coarse clipping of large list of evenly sized items. +// NB: Prefer using the ImGuiListClipper higher-level helper if you can! Read comments and instructions there on how those use this sort of pattern. +// NB: 'items_count' is only used to clamp the result, if you don't know your count you can use INT_MAX +void ImGui::CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (g.LogEnabled) + { + // If logging is active, do not perform any clipping + *out_items_display_start = 0; + *out_items_display_end = items_count; + return; + } + if (window->SkipItems) + { + *out_items_display_start = *out_items_display_end = 0; + return; + } + + const ImVec2 pos = window->DC.CursorPos; + int start = (int)((window->ClipRect.Min.y - pos.y) / items_height); + int end = (int)((window->ClipRect.Max.y - pos.y) / items_height); + start = ImClamp(start, 0, items_count); + end = ImClamp(end + 1, start, items_count); + *out_items_display_start = start; + *out_items_display_end = end; +} + +// Find window given position, search front-to-back +// FIXME: Note that we have a lag here because WindowRectClipped is updated in Begin() so windows moved by user via SetWindowPos() and not SetNextWindowPos() will have that rectangle lagging by a frame at the time FindHoveredWindow() is called, aka before the next Begin(). Moving window thankfully isn't affected. +static ImGuiWindow* FindHoveredWindow(ImVec2 pos) +{ + ImGuiContext& g = *GImGui; + for (int i = g.Windows.Size - 1; i >= 0; i--) + { + ImGuiWindow* window = g.Windows[i]; + if (!window->Active) + continue; + if (window->Flags & ImGuiWindowFlags_NoInputs) + continue; + + // Using the clipped AABB, a child window will typically be clipped by its parent (not always) + ImRect bb(window->WindowRectClipped.Min - g.Style.TouchExtraPadding, window->WindowRectClipped.Max + g.Style.TouchExtraPadding); + if (bb.Contains(pos)) + return window; + } + return NULL; +} + +// Test if mouse cursor is hovering given rectangle +// NB- Rectangle is clipped by our current clip setting +// NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding) +bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + // Clip + ImRect rect_clipped(r_min, r_max); + if (clip) + rect_clipped.ClipWith(window->ClipRect); + + // Expand for touch input + const ImRect rect_for_touch(rect_clipped.Min - g.Style.TouchExtraPadding, rect_clipped.Max + g.Style.TouchExtraPadding); + return rect_for_touch.Contains(g.IO.MousePos); +} + +static bool IsKeyPressedMap(ImGuiKey key, bool repeat) +{ + const int key_index = GImGui->IO.KeyMap[key]; + return (key_index >= 0) ? ImGui::IsKeyPressed(key_index, repeat) : false; +} + +int ImGui::GetKeyIndex(ImGuiKey imgui_key) +{ + IM_ASSERT(imgui_key >= 0 && imgui_key < ImGuiKey_COUNT); + return GImGui->IO.KeyMap[imgui_key]; +} + +// Note that imgui doesn't know the semantic of each entry of io.KeyDown[]. Use your own indices/enums according to how your backend/engine stored them into KeyDown[]! +bool ImGui::IsKeyDown(int user_key_index) +{ + if (user_key_index < 0) return false; + IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(GImGui->IO.KeysDown)); + return GImGui->IO.KeysDown[user_key_index]; +} + +int ImGui::CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate) +{ + if (t == 0.0f) + return 1; + if (t <= repeat_delay || repeat_rate <= 0.0f) + return 0; + const int count = (int)((t - repeat_delay) / repeat_rate) - (int)((t_prev - repeat_delay) / repeat_rate); + return (count > 0) ? count : 0; +} + +int ImGui::GetKeyPressedAmount(int key_index, float repeat_delay, float repeat_rate) +{ + ImGuiContext& g = *GImGui; + if (key_index < 0) return false; + IM_ASSERT(key_index >= 0 && key_index < IM_ARRAYSIZE(g.IO.KeysDown)); + const float t = g.IO.KeysDownDuration[key_index]; + return CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, repeat_delay, repeat_rate); +} + +bool ImGui::IsKeyPressed(int user_key_index, bool repeat) +{ + ImGuiContext& g = *GImGui; + if (user_key_index < 0) return false; + IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown)); + const float t = g.IO.KeysDownDuration[user_key_index]; + if (t == 0.0f) + return true; + if (repeat && t > g.IO.KeyRepeatDelay) + return GetKeyPressedAmount(user_key_index, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate) > 0; + return false; +} + +bool ImGui::IsKeyReleased(int user_key_index) +{ + ImGuiContext& g = *GImGui; + if (user_key_index < 0) return false; + IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown)); + if (g.IO.KeysDownDurationPrev[user_key_index] >= 0.0f && !g.IO.KeysDown[user_key_index]) + return true; + return false; +} + +bool ImGui::IsMouseDown(int button) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + return g.IO.MouseDown[button]; +} + +bool ImGui::IsMouseClicked(int button, bool repeat) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + const float t = g.IO.MouseDownDuration[button]; + if (t == 0.0f) + return true; + + if (repeat && t > g.IO.KeyRepeatDelay) + { + float delay = g.IO.KeyRepeatDelay, rate = g.IO.KeyRepeatRate; + if ((fmodf(t - delay, rate) > rate*0.5f) != (fmodf(t - delay - g.IO.DeltaTime, rate) > rate*0.5f)) + return true; + } + + return false; +} + +bool ImGui::IsMouseReleased(int button) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + return g.IO.MouseReleased[button]; +} + +bool ImGui::IsMouseDoubleClicked(int button) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + return g.IO.MouseDoubleClicked[button]; +} + +bool ImGui::IsMouseDragging(int button, float lock_threshold) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + if (!g.IO.MouseDown[button]) + return false; + if (lock_threshold < 0.0f) + lock_threshold = g.IO.MouseDragThreshold; + return g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold; +} + +ImVec2 ImGui::GetMousePos() +{ + return GImGui->IO.MousePos; +} + +// NB: prefer to call right after BeginPopup(). At the time Selectable/MenuItem is activated, the popup is already closed! +ImVec2 ImGui::GetMousePosOnOpeningCurrentPopup() +{ + ImGuiContext& g = *GImGui; + if (g.CurrentPopupStack.Size > 0) + return g.OpenPopupStack[g.CurrentPopupStack.Size-1].OpenMousePos; + return g.IO.MousePos; +} + +// We typically use ImVec2(-FLT_MAX,-FLT_MAX) to denote an invalid mouse position +bool ImGui::IsMousePosValid(const ImVec2* mouse_pos) +{ + if (mouse_pos == NULL) + mouse_pos = &GImGui->IO.MousePos; + const float MOUSE_INVALID = -256000.0f; + return mouse_pos->x >= MOUSE_INVALID && mouse_pos->y >= MOUSE_INVALID; +} + +ImVec2 ImGui::GetMouseDragDelta(int button, float lock_threshold) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + if (lock_threshold < 0.0f) + lock_threshold = g.IO.MouseDragThreshold; + if (g.IO.MouseDown[button]) + if (g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold) + return g.IO.MousePos - g.IO.MouseClickedPos[button]; // Assume we can only get active with left-mouse button (at the moment). + return ImVec2(0.0f, 0.0f); +} + +void ImGui::ResetMouseDragDelta(int button) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + // NB: We don't need to reset g.IO.MouseDragMaxDistanceSqr + g.IO.MouseClickedPos[button] = g.IO.MousePos; +} + +ImGuiMouseCursor ImGui::GetMouseCursor() +{ + return GImGui->MouseCursor; +} + +void ImGui::SetMouseCursor(ImGuiMouseCursor cursor_type) +{ + GImGui->MouseCursor = cursor_type; +} + +void ImGui::CaptureKeyboardFromApp(bool capture) +{ + GImGui->WantCaptureKeyboardNextFrame = capture ? 1 : 0; +} + +void ImGui::CaptureMouseFromApp(bool capture) +{ + GImGui->WantCaptureMouseNextFrame = capture ? 1 : 0; +} + +bool ImGui::IsItemActive() +{ + ImGuiContext& g = *GImGui; + if (g.ActiveId) + { + ImGuiWindow* window = g.CurrentWindow; + return g.ActiveId == window->DC.LastItemId; + } + return false; +} + +bool ImGui::IsItemClicked(int mouse_button) +{ + return IsMouseClicked(mouse_button) && IsItemHovered(ImGuiHoveredFlags_Default); +} + +bool ImGui::IsAnyItemHovered() +{ + ImGuiContext& g = *GImGui; + return g.HoveredId != 0 || g.HoveredIdPreviousFrame != 0; +} + +bool ImGui::IsAnyItemActive() +{ + return GImGui->ActiveId != 0; +} + +bool ImGui::IsItemVisible() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->ClipRect.Overlaps(window->DC.LastItemRect); +} + +// Allow last item to be overlapped by a subsequent item. Both may be activated during the same frame before the later one takes priority. +void ImGui::SetItemAllowOverlap() +{ + ImGuiContext& g = *GImGui; + if (g.HoveredId == g.CurrentWindow->DC.LastItemId) + g.HoveredIdAllowOverlap = true; + if (g.ActiveId == g.CurrentWindow->DC.LastItemId) + g.ActiveIdAllowOverlap = true; +} + +ImVec2 ImGui::GetItemRectMin() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.LastItemRect.Min; +} + +ImVec2 ImGui::GetItemRectMax() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.LastItemRect.Max; +} + +ImVec2 ImGui::GetItemRectSize() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.LastItemRect.GetSize(); +} + +static ImRect GetVisibleRect() +{ + ImGuiContext& g = *GImGui; + if (g.IO.DisplayVisibleMin.x != g.IO.DisplayVisibleMax.x && g.IO.DisplayVisibleMin.y != g.IO.DisplayVisibleMax.y) + return ImRect(g.IO.DisplayVisibleMin, g.IO.DisplayVisibleMax); + return ImRect(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y); +} + +// Not exposed publicly as BeginTooltip() because bool parameters are evil. Let's see if other needs arise first. +void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip) +{ + ImGuiContext& g = *GImGui; + char window_name[16]; + ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", g.TooltipOverrideCount); + if (override_previous_tooltip) + if (ImGuiWindow* window = FindWindowByName(window_name)) + if (window->Active) + { + // Hide previous tooltips. We can't easily "reset" the content of a window so we create a new one. + window->HiddenFrames = 1; + ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount); + } + ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize; + Begin(window_name, NULL, flags | extra_flags); +} + +void ImGui::SetTooltipV(const char* fmt, va_list args) +{ + BeginTooltipEx(0, true); + TextV(fmt, args); + EndTooltip(); +} + +void ImGui::SetTooltip(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + SetTooltipV(fmt, args); + va_end(args); +} + +void ImGui::BeginTooltip() +{ + BeginTooltipEx(0, false); +} + +void ImGui::EndTooltip() +{ + IM_ASSERT(GetCurrentWindowRead()->Flags & ImGuiWindowFlags_Tooltip); // Mismatched BeginTooltip()/EndTooltip() calls + End(); +} + +// Mark popup as open (toggle toward open state). +// Popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. +// Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). +// One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL) +void ImGui::OpenPopupEx(ImGuiID id) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* parent_window = g.CurrentWindow; + int current_stack_size = g.CurrentPopupStack.Size; + ImGuiPopupRef popup_ref; // Tagged as new ref as Window will be set back to NULL if we write this into OpenPopupStack. + popup_ref.PopupId = id; + popup_ref.Window = NULL; + popup_ref.ParentWindow = parent_window; + popup_ref.OpenFrameCount = g.FrameCount; + popup_ref.OpenParentId = parent_window->IDStack.back(); + popup_ref.OpenMousePos = g.IO.MousePos; + popup_ref.OpenPopupPos = g.IO.MousePos; // NB: In the Navigation branch OpenPopupPos doesn't use the mouse position, hence the separation here. + + if (g.OpenPopupStack.Size < current_stack_size + 1) + { + g.OpenPopupStack.push_back(popup_ref); + } + else + { + // Close child popups if any + g.OpenPopupStack.resize(current_stack_size + 1); + + // Gently handle the user mistakenly calling OpenPopup() every frame. It is a programming mistake! However, if we were to run the regular code path, the ui + // would become completely unusable because the popup will always be in hidden-while-calculating-size state _while_ claiming focus. Which would be a very confusing + // situation for the programmer. Instead, we silently allow the popup to proceed, it will keep reappearing and the programming error will be more obvious to understand. + if (g.OpenPopupStack[current_stack_size].PopupId == id && g.OpenPopupStack[current_stack_size].OpenFrameCount == g.FrameCount - 1) + g.OpenPopupStack[current_stack_size].OpenFrameCount = popup_ref.OpenFrameCount; + else + g.OpenPopupStack[current_stack_size] = popup_ref; + + // When reopening a popup we first refocus its parent, otherwise if its parent is itself a popup it would get closed by CloseInactivePopups(). + // This is equivalent to what ClosePopupToLevel() does. + //if (g.OpenPopupStack[current_stack_size].PopupId == id) + // FocusWindow(parent_window); + } +} + +void ImGui::OpenPopup(const char* str_id) +{ + ImGuiContext& g = *GImGui; + OpenPopupEx(g.CurrentWindow->GetID(str_id)); +} + +static void CloseInactivePopups(ImGuiWindow* ref_window) +{ + ImGuiContext& g = *GImGui; + if (g.OpenPopupStack.empty()) + return; + + // When popups are stacked, clicking on a lower level popups puts focus back to it and close popups above it. + // Don't close our own child popup windows. + int n = 0; + if (ref_window) + { + for (n = 0; n < g.OpenPopupStack.Size; n++) + { + ImGuiPopupRef& popup = g.OpenPopupStack[n]; + if (!popup.Window) + continue; + IM_ASSERT((popup.Window->Flags & ImGuiWindowFlags_Popup) != 0); + if (popup.Window->Flags & ImGuiWindowFlags_ChildWindow) + continue; + + // Trim the stack if popups are not direct descendant of the reference window (which is often the NavWindow) + bool has_focus = false; + for (int m = n; m < g.OpenPopupStack.Size && !has_focus; m++) + has_focus = (g.OpenPopupStack[m].Window && g.OpenPopupStack[m].Window->RootWindow == ref_window->RootWindow); + if (!has_focus) + break; + } + } + if (n < g.OpenPopupStack.Size) // This test is not required but it allows to set a convenient breakpoint on the block below + ClosePopupToLevel(n); +} + +static ImGuiWindow* GetFrontMostModalRootWindow() +{ + ImGuiContext& g = *GImGui; + for (int n = g.OpenPopupStack.Size-1; n >= 0; n--) + if (ImGuiWindow* popup = g.OpenPopupStack.Data[n].Window) + if (popup->Flags & ImGuiWindowFlags_Modal) + return popup; + return NULL; +} + +static void ClosePopupToLevel(int remaining) +{ + ImGuiContext& g = *GImGui; + if (remaining > 0) + ImGui::FocusWindow(g.OpenPopupStack[remaining-1].Window); + else + ImGui::FocusWindow(g.OpenPopupStack[0].ParentWindow); + g.OpenPopupStack.resize(remaining); +} + +void ImGui::ClosePopup(ImGuiID id) +{ + if (!IsPopupOpen(id)) + return; + ImGuiContext& g = *GImGui; + ClosePopupToLevel(g.OpenPopupStack.Size - 1); +} + +// Close the popup we have begin-ed into. +void ImGui::CloseCurrentPopup() +{ + ImGuiContext& g = *GImGui; + int popup_idx = g.CurrentPopupStack.Size - 1; + if (popup_idx < 0 || popup_idx >= g.OpenPopupStack.Size || g.CurrentPopupStack[popup_idx].PopupId != g.OpenPopupStack[popup_idx].PopupId) + return; + while (popup_idx > 0 && g.OpenPopupStack[popup_idx].Window && (g.OpenPopupStack[popup_idx].Window->Flags & ImGuiWindowFlags_ChildMenu)) + popup_idx--; + ClosePopupToLevel(popup_idx); +} + +bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags) +{ + ImGuiContext& g = *GImGui; + if (!IsPopupOpen(id)) + { + g.NextWindowData.Clear(); // We behave like Begin() and need to consume those values + return false; + } + + char name[20]; + if (extra_flags & ImGuiWindowFlags_ChildMenu) + ImFormatString(name, IM_ARRAYSIZE(name), "##Menu_%02d", g.CurrentPopupStack.Size); // Recycle windows based on depth + else + ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // Not recycling, so we can close/open during the same frame + + bool is_open = Begin(name, NULL, extra_flags | ImGuiWindowFlags_Popup); + if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display) + EndPopup(); + + return is_open; +} + +bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags) +{ + ImGuiContext& g = *GImGui; + if (g.OpenPopupStack.Size <= g.CurrentPopupStack.Size) // Early out for performance + { + g.NextWindowData.Clear(); // We behave like Begin() and need to consume those values + return false; + } + return BeginPopupEx(g.CurrentWindow->GetID(str_id), flags|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); +} + +bool ImGui::IsPopupOpen(ImGuiID id) +{ + ImGuiContext& g = *GImGui; + return g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].PopupId == id; +} + +bool ImGui::IsPopupOpen(const char* str_id) +{ + ImGuiContext& g = *GImGui; + return g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].PopupId == g.CurrentWindow->GetID(str_id); +} + +bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + const ImGuiID id = window->GetID(name); + if (!IsPopupOpen(id)) + { + g.NextWindowData.Clear(); // We behave like Begin() and need to consume those values + return false; + } + + // Center modal windows by default + if (g.NextWindowData.PosCond == 0) + SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); + + bool is_open = Begin(name, p_open, flags | ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings); + if (!is_open || (p_open && !*p_open)) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display) + { + EndPopup(); + if (is_open) + ClosePopup(id); + return false; + } + + return is_open; +} + +void ImGui::EndPopup() +{ + ImGuiContext& g = *GImGui; (void)g; + IM_ASSERT(g.CurrentWindow->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginPopup()/EndPopup() calls + IM_ASSERT(g.CurrentPopupStack.Size > 0); + End(); +} + +bool ImGui::OpenPopupOnItemClick(const char* str_id, int mouse_button) +{ + ImGuiWindow* window = GImGui->CurrentWindow; + if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) + { + ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! + IM_ASSERT(id != 0); // However, you cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) + OpenPopupEx(id); + return true; + } + return false; +} + +// This is a helper to handle the simplest case of associating one named popup to one given widget. +// You may want to handle this on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters). +// You can pass a NULL str_id to use the identifier of the last item. +bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button) +{ + ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! + IM_ASSERT(id != 0); // However, you cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) + if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) + OpenPopupEx(id); + return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); +} + +bool ImGui::BeginPopupContextWindow(const char* str_id, int mouse_button, bool also_over_items) +{ + if (!str_id) + str_id = "window_context"; + ImGuiID id = GImGui->CurrentWindow->GetID(str_id); + if (IsMouseReleased(mouse_button) && IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) + if (also_over_items || !IsAnyItemHovered()) + OpenPopupEx(id); + return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); +} + +bool ImGui::BeginPopupContextVoid(const char* str_id, int mouse_button) +{ + if (!str_id) + str_id = "void_context"; + ImGuiID id = GImGui->CurrentWindow->GetID(str_id); + if (IsMouseReleased(mouse_button) && !IsWindowHovered(ImGuiHoveredFlags_AnyWindow)) + OpenPopupEx(id); + return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); +} + +static bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* parent_window = ImGui::GetCurrentWindow(); + ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_ChildWindow; + flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag + + const ImVec2 content_avail = ImGui::GetContentRegionAvail(); + ImVec2 size = ImFloor(size_arg); + const int auto_fit_axises = ((size.x == 0.0f) ? (1 << ImGuiAxis_X) : 0x00) | ((size.y == 0.0f) ? (1 << ImGuiAxis_Y) : 0x00); + if (size.x <= 0.0f) + size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too much issues) + if (size.y <= 0.0f) + size.y = ImMax(content_avail.y + size.y, 4.0f); + + const float backup_border_size = g.Style.ChildBorderSize; + if (!border) + g.Style.ChildBorderSize = 0.0f; + flags |= extra_flags; + + char title[256]; + if (name) + ImFormatString(title, IM_ARRAYSIZE(title), "%s/%s_%08X", parent_window->Name, name, id); + else + ImFormatString(title, IM_ARRAYSIZE(title), "%s/%08X", parent_window->Name, id); + + ImGui::SetNextWindowSize(size); + bool ret = ImGui::Begin(title, NULL, flags); + ImGuiWindow* child_window = ImGui::GetCurrentWindow(); + child_window->AutoFitChildAxises = auto_fit_axises; + g.Style.ChildBorderSize = backup_border_size; + + return ret; +} + +bool ImGui::BeginGroupBox(const char* name, const ImVec2& size_arg) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + ImGuiWindowFlags flags = ImGuiWindowFlags_GroupBox | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_ChildWindow; + flags |= (window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag + + window->DC.CursorPos.y += GImGui->FontSize / 2; + const ImVec2 content_avail = ImGui::GetContentRegionAvail(); + ImVec2 size = ImFloor(size_arg); + const int auto_fit_axises = ((size.x == 0.0f) ? (1 << ImGuiAxis_X) : 0x00) | ((size.y == 0.0f) ? (1 << ImGuiAxis_Y) : 0x00); + if (size.x <= 0.0f) + size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too much issues) + if (size.y <= 0.0f) + size.y = ImMax(content_avail.y + size.y, 4.0f); + + const float backup_border_size = g.Style.ChildBorderSize; + + ImGui::SetNextWindowSize(size); + bool ret = ImGui::Begin(name, NULL, flags); + + ImGuiWindow* child_window = ImGui::GetCurrentWindow(); + child_window->AutoFitChildAxises = auto_fit_axises; + g.Style.ChildBorderSize = backup_border_size; + //window = ImGui::GetCurrentWindow(); + + //auto padding = ImGui::GetStyle().WindowPadding; + + //auto text_size = CalcTextSize(name, NULL, true); + + //if (text_size.x > 1.0f) { + // window->DrawList->PushClipRectFullScreen(); + // //window->DrawList->AddRectFilled(window->DC.CursorPos - ImVec2{ 4, 0 }, window->DC.CursorPos + (text_size + ImVec2{ 4, 0 }), GetColorU32(ImGuiCol_ChildWindowBg)); + // //RenderTextClipped(pos, pos + text_size, name, NULL, NULL, GetColorU32(ImGuiCol_Text)); + // window->DrawList->PopClipRect(); + //} + //if (!(window->Flags & ImGuiWindowFlags_ShowBorders)) + // ImGui::GetCurrentWindow()->Flags &= ~ImGuiWindowFlags_ShowBorders; + + //window->DC.CursorPos.y += 3; + + //ImGui::SetCursorPosY(window->DC.CursorPos.y + 5); + + return ret; +} + +void ImGui::EndGroupBox() +{ + EndChild(); + ImGuiWindow* window = GetCurrentWindow(); + window->DC.CursorPosPrevLine.y -= GImGui->FontSize / 2; +} + +bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + return BeginChildEx(str_id, window->GetID(str_id), size_arg, border, extra_flags); +} + +bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) +{ + return BeginChildEx(NULL, id, size_arg, border, extra_flags); +} + +void ImGui::EndChild() +{ + ImGuiWindow* window = GetCurrentWindow(); + + IM_ASSERT(window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() callss + if (window->BeginCount > 1) + { + End(); + } + else + { + // When using auto-filling child window, we don't provide full width/height to ItemSize so that it doesn't feed back into automatic size-fitting. + ImVec2 sz = GetWindowSize(); + if (window->AutoFitChildAxises & (1 << ImGuiAxis_X)) // Arbitrary minimum zero-ish child size of 4.0f causes less trouble than a 0.0f + sz.x = ImMax(4.0f, sz.x); + if (window->AutoFitChildAxises & (1 << ImGuiAxis_Y)) + sz.y = ImMax(4.0f, sz.y); + End(); + + ImGuiWindow* parent_window = GetCurrentWindow(); + ImRect bb(parent_window->DC.CursorPos, parent_window->DC.CursorPos + sz); + ItemSize(sz); + ItemAdd(bb, 0); + } +} + +// Helper to create a child window / scrolling region that looks like a normal widget frame. +bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags) +{ + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]); + PushStyleVar(ImGuiStyleVar_ChildRounding, style.FrameRounding); + PushStyleVar(ImGuiStyleVar_ChildBorderSize, style.FrameBorderSize); + PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding); + return BeginChild(id, size, true, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysUseWindowPadding | extra_flags); +} + +void ImGui::EndChildFrame() +{ + EndChild(); + PopStyleVar(3); + PopStyleColor(); +} + +// Save and compare stack sizes on Begin()/End() to detect usage errors +static void CheckStacksSize(ImGuiWindow* window, bool write) +{ + // NOT checking: DC.ItemWidth, DC.AllowKeyboardFocus, DC.ButtonRepeat, DC.TextWrapPos (per window) to allow user to conveniently push once and not pop (they are cleared on Begin) + ImGuiContext& g = *GImGui; + int* p_backup = &window->DC.StackSizesBackup[0]; + { int current = window->IDStack.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current && "PushID/PopID or TreeNode/TreePop Mismatch!"); p_backup++; } // Too few or too many PopID()/TreePop() + { int current = window->DC.GroupStack.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current && "BeginGroup/EndGroup Mismatch!"); p_backup++; } // Too few or too many EndGroup() + { int current = g.CurrentPopupStack.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current && "BeginMenu/EndMenu or BeginPopup/EndPopup Mismatch"); p_backup++;}// Too few or too many EndMenu()/EndPopup() + { int current = g.ColorModifiers.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current && "PushStyleColor/PopStyleColor Mismatch!"); p_backup++; } // Too few or too many PopStyleColor() + { int current = g.StyleModifiers.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current && "PushStyleVar/PopStyleVar Mismatch!"); p_backup++; } // Too few or too many PopStyleVar() + { int current = g.FontStack.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current && "PushFont/PopFont Mismatch!"); p_backup++; } // Too few or too many PopFont() + IM_ASSERT(p_backup == window->DC.StackSizesBackup + IM_ARRAYSIZE(window->DC.StackSizesBackup)); +} + +enum ImGuiPopupPositionPolicy +{ + ImGuiPopupPositionPolicy_Default, + ImGuiPopupPositionPolicy_ComboBox +}; + +static ImVec2 FindBestWindowPosForPopup(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy = ImGuiPopupPositionPolicy_Default) +{ + const ImGuiStyle& style = GImGui->Style; + + // r_avoid = the rectangle to avoid (e.g. for tooltip it is a rectangle around the mouse cursor which we want to avoid. for popups it's a small point around the cursor.) + // r_outer = the visible area rectangle, minus safe area padding. If our popup size won't fit because of safe area padding we ignore it. + ImVec2 safe_padding = style.DisplaySafeAreaPadding; + ImRect r_outer(GetVisibleRect()); + r_outer.Expand(ImVec2((size.x - r_outer.GetWidth() > safe_padding.x*2) ? -safe_padding.x : 0.0f, (size.y - r_outer.GetHeight() > safe_padding.y*2) ? -safe_padding.y : 0.0f)); + ImVec2 base_pos_clamped = ImClamp(ref_pos, r_outer.Min, r_outer.Max - size); + //GImGui->OverlayDrawList.AddRect(r_avoid.Min, r_avoid.Max, IM_COL32(255,0,0,255)); + //GImGui->OverlayDrawList.AddRect(r_outer.Min, r_outer.Max, IM_COL32(0,255,0,255)); + + // Combo Box policy (we want a connecting edge) + if (policy == ImGuiPopupPositionPolicy_ComboBox) + { + const ImGuiDir dir_prefered_order[ImGuiDir_Count_] = { ImGuiDir_Down, ImGuiDir_Right, ImGuiDir_Left, ImGuiDir_Up }; + for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_Count_; n++) + { + const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n]; + if (n != -1 && dir == *last_dir) // Already tried this direction? + continue; + ImVec2 pos; + if (dir == ImGuiDir_Down) pos = ImVec2(r_avoid.Min.x, r_avoid.Max.y); // Below, Toward Right (default) + if (dir == ImGuiDir_Right) pos = ImVec2(r_avoid.Min.x, r_avoid.Min.y - size.y); // Above, Toward Right + if (dir == ImGuiDir_Left) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Max.y); // Below, Toward Left + if (dir == ImGuiDir_Up) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Min.y - size.y); // Above, Toward Left + if (!r_outer.Contains(ImRect(pos, pos + size))) + continue; + *last_dir = dir; + return pos; + } + } + + // Default popup policy + const ImGuiDir dir_prefered_order[ImGuiDir_Count_] = { ImGuiDir_Right, ImGuiDir_Down, ImGuiDir_Up, ImGuiDir_Left }; + for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_Count_; n++) + { + const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n]; + if (n != -1 && dir == *last_dir) // Already tried this direction? + continue; + float avail_w = (dir == ImGuiDir_Left ? r_avoid.Min.x : r_outer.Max.x) - (dir == ImGuiDir_Right ? r_avoid.Max.x : r_outer.Min.x); + float avail_h = (dir == ImGuiDir_Up ? r_avoid.Min.y : r_outer.Max.y) - (dir == ImGuiDir_Down ? r_avoid.Max.y : r_outer.Min.y); + if (avail_w < size.x || avail_h < size.y) + continue; + ImVec2 pos; + pos.x = (dir == ImGuiDir_Left) ? r_avoid.Min.x - size.x : (dir == ImGuiDir_Right) ? r_avoid.Max.x : base_pos_clamped.x; + pos.y = (dir == ImGuiDir_Up) ? r_avoid.Min.y - size.y : (dir == ImGuiDir_Down) ? r_avoid.Max.y : base_pos_clamped.y; + *last_dir = dir; + return pos; + } + + // Fallback, try to keep within display + *last_dir = ImGuiDir_None; + ImVec2 pos = ref_pos; + pos.x = ImMax(ImMin(pos.x + size.x, r_outer.Max.x) - size.x, r_outer.Min.x); + pos.y = ImMax(ImMin(pos.y + size.y, r_outer.Max.y) - size.y, r_outer.Min.y); + return pos; +} + +static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled) +{ + window->SetWindowPosAllowFlags = enabled ? (window->SetWindowPosAllowFlags | flags) : (window->SetWindowPosAllowFlags & ~flags); + window->SetWindowSizeAllowFlags = enabled ? (window->SetWindowSizeAllowFlags | flags) : (window->SetWindowSizeAllowFlags & ~flags); + window->SetWindowCollapsedAllowFlags = enabled ? (window->SetWindowCollapsedAllowFlags | flags) : (window->SetWindowCollapsedAllowFlags & ~flags); +} + +ImGuiWindow* ImGui::FindWindowByName(const char* name) +{ + ImGuiContext& g = *GImGui; + ImGuiID id = ImHash(name, 0); + return (ImGuiWindow*)g.WindowsById.GetVoidPtr(id); +} + +static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags) +{ + ImGuiContext& g = *GImGui; + + // Create window the first time + ImGuiWindow* window = IM_NEW(ImGuiWindow)(&g, name); + window->Flags = flags; + g.WindowsById.SetVoidPtr(window->ID, window); + + // User can disable loading and saving of settings. Tooltip and child windows also don't store settings. + if (!(flags & ImGuiWindowFlags_NoSavedSettings)) + { + // Retrieve settings from .ini file + // Use SetWindowPos() or SetNextWindowPos() with the appropriate condition flag to change the initial position of a window. + window->Pos = window->PosFloat = ImVec2(60, 60); + + if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID)) + { + SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false); + window->PosFloat = settings->Pos; + window->Pos = ImFloor(window->PosFloat); + window->Collapsed = settings->Collapsed; + if (ImLengthSqr(settings->Size) > 0.00001f) + size = settings->Size; + } + } + window->Size = window->SizeFull = window->SizeFullAtLastBegin = size; + + if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0) + { + window->AutoFitFramesX = window->AutoFitFramesY = 2; + window->AutoFitOnlyGrows = false; + } + else + { + if (window->Size.x <= 0.0f) + window->AutoFitFramesX = 2; + if (window->Size.y <= 0.0f) + window->AutoFitFramesY = 2; + window->AutoFitOnlyGrows = (window->AutoFitFramesX > 0) || (window->AutoFitFramesY > 0); + } + + if (flags & ImGuiWindowFlags_NoBringToFrontOnFocus) + g.Windows.insert(g.Windows.begin(), window); // Quite slow but rare and only once + else + g.Windows.push_back(window); + return window; +} + +static ImVec2 CalcSizeAfterConstraint(ImGuiWindow* window, ImVec2 new_size) +{ + ImGuiContext& g = *GImGui; + if (g.NextWindowData.SizeConstraintCond != 0) + { + // Using -1,-1 on either X/Y axis to preserve the current size. + ImRect cr = g.NextWindowData.SizeConstraintRect; + new_size.x = (cr.Min.x >= 0 && cr.Max.x >= 0) ? ImClamp(new_size.x, cr.Min.x, cr.Max.x) : window->SizeFull.x; + new_size.y = (cr.Min.y >= 0 && cr.Max.y >= 0) ? ImClamp(new_size.y, cr.Min.y, cr.Max.y) : window->SizeFull.y; + if (g.NextWindowData.SizeCallback) + { + ImGuiSizeCallbackData data; + data.UserData = g.NextWindowData.SizeCallbackUserData; + data.Pos = window->Pos; + data.CurrentSize = window->SizeFull; + data.DesiredSize = new_size; + g.NextWindowData.SizeCallback(&data); + new_size = data.DesiredSize; + } + } + + // Minimum size + if (!(window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysAutoResize))) + { + new_size = ImMax(new_size, g.Style.WindowMinSize); + new_size.y = ImMax(new_size.y, window->TitleBarHeight() + window->MenuBarHeight() + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows + } + return new_size; +} + +static ImVec2 CalcSizeContents(ImGuiWindow* window) +{ + ImVec2 sz; + sz.x = (float)(int)((window->SizeContentsExplicit.x != 0.0f) ? window->SizeContentsExplicit.x : (window->DC.CursorMaxPos.x - window->Pos.x + window->Scroll.x)); + sz.y = (float)(int)((window->SizeContentsExplicit.y != 0.0f) ? window->SizeContentsExplicit.y : (window->DC.CursorMaxPos.y - window->Pos.y + window->Scroll.y)); + return sz + window->WindowPadding; +} + +static ImVec2 CalcSizeAutoFit(ImGuiWindow* window, const ImVec2& size_contents) +{ + ImGuiContext& g = *GImGui; + ImGuiStyle& style = g.Style; + ImGuiWindowFlags flags = window->Flags; + ImVec2 size_auto_fit; + if ((flags & ImGuiWindowFlags_Tooltip) != 0) + { + // Tooltip always resize. We keep the spacing symmetric on both axises for aesthetic purpose. + size_auto_fit = size_contents; + } + else + { + // When the window cannot fit all contents (either because of constraints, either because screen is too small): we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than DisplaySize-WindowPadding. + size_auto_fit = ImClamp(size_contents, style.WindowMinSize, ImMax(style.WindowMinSize, g.IO.DisplaySize - g.Style.DisplaySafeAreaPadding)); + ImVec2 size_auto_fit_after_constraint = CalcSizeAfterConstraint(window, size_auto_fit); + if (size_auto_fit_after_constraint.x < size_contents.x && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar)) + size_auto_fit.y += style.ScrollbarSize; + if (size_auto_fit_after_constraint.y < size_contents.y && !(flags & ImGuiWindowFlags_NoScrollbar)) + size_auto_fit.x += style.ScrollbarSize; + } + return size_auto_fit; +} + +static float GetScrollMaxX(ImGuiWindow* window) +{ + return ImMax(0.0f, window->SizeContents.x - (window->SizeFull.x - window->ScrollbarSizes.x)); +} + +static float GetScrollMaxY(ImGuiWindow* window) +{ + return ImMax(0.0f, window->SizeContents.y - (window->SizeFull.y - window->ScrollbarSizes.y)); +} + +static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window) +{ + ImVec2 scroll = window->Scroll; + float cr_x = window->ScrollTargetCenterRatio.x; + float cr_y = window->ScrollTargetCenterRatio.y; + if (window->ScrollTarget.x < FLT_MAX) + scroll.x = window->ScrollTarget.x - cr_x * (window->SizeFull.x - window->ScrollbarSizes.x); + if (window->ScrollTarget.y < FLT_MAX) + scroll.y = window->ScrollTarget.y - (1.0f - cr_y) * (window->TitleBarHeight() + window->MenuBarHeight()) - cr_y * (window->SizeFull.y - window->ScrollbarSizes.y); + scroll = ImMax(scroll, ImVec2(0.0f, 0.0f)); + if (!window->Collapsed && !window->SkipItems) + { + scroll.x = ImMin(scroll.x, GetScrollMaxX(window)); + scroll.y = ImMin(scroll.y, GetScrollMaxY(window)); + } + return scroll; +} + +static ImGuiCol GetWindowBgColorIdxFromFlags(ImGuiWindowFlags flags) +{ + if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) + return ImGuiCol_PopupBg; + if (flags & ImGuiWindowFlags_ChildWindow) + return ImGuiCol_ChildBg; + return ImGuiCol_WindowBg; +} + +static void CalcResizePosSizeFromAnyCorner(ImGuiWindow* window, const ImVec2& corner_target, const ImVec2& corner_norm, ImVec2* out_pos, ImVec2* out_size) +{ + ImVec2 pos_min = ImLerp(corner_target, window->Pos, corner_norm); // Expected window upper-left + ImVec2 pos_max = ImLerp(window->Pos + window->Size, corner_target, corner_norm); // Expected window lower-right + ImVec2 size_expected = pos_max - pos_min; + ImVec2 size_constrained = CalcSizeAfterConstraint(window, size_expected); + *out_pos = pos_min; + if (corner_norm.x == 0.0f) + out_pos->x -= (size_constrained.x - size_expected.x); + if (corner_norm.y == 0.0f) + out_pos->y -= (size_constrained.y - size_expected.y); + *out_size = size_constrained; +} + +struct ImGuiResizeGripDef +{ + ImVec2 CornerPos; + ImVec2 InnerDir; + int AngleMin12, AngleMax12; +}; + +const ImGuiResizeGripDef resize_grip_def[4] = +{ + { ImVec2(1,1), ImVec2(-1,-1), 0, 3 }, // Lower right + { ImVec2(0,1), ImVec2(+1,-1), 3, 6 }, // Lower left + { ImVec2(0,0), ImVec2(+1,+1), 6, 9 }, // Upper left + { ImVec2(1,0), ImVec2(-1,+1), 9,12 }, // Upper right +}; + +static ImRect GetBorderRect(ImGuiWindow* window, int border_n, float perp_padding, float thickness) +{ + ImRect rect = window->Rect(); + if (thickness == 0.0f) rect.Max -= ImVec2(1,1); + if (border_n == 0) return ImRect(rect.Min.x + perp_padding, rect.Min.y, rect.Max.x - perp_padding, rect.Min.y + thickness); + if (border_n == 1) return ImRect(rect.Max.x - thickness, rect.Min.y + perp_padding, rect.Max.x, rect.Max.y - perp_padding); + if (border_n == 2) return ImRect(rect.Min.x + perp_padding, rect.Max.y - thickness, rect.Max.x - perp_padding, rect.Max.y); + if (border_n == 3) return ImRect(rect.Min.x, rect.Min.y + perp_padding, rect.Min.x + thickness, rect.Max.y - perp_padding); + IM_ASSERT(0); + return ImRect(); +} + +// Handle resize for: Resize Grips, Borders, Gamepad +static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]) +{ + ImGuiContext& g = *GImGui; + ImGuiWindowFlags flags = window->Flags; + if ((flags & ImGuiWindowFlags_NoResize) || (flags & ImGuiWindowFlags_AlwaysAutoResize) || window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0) + return; + + const int resize_border_count = (flags & ImGuiWindowFlags_ResizeFromAnySide) ? 4 : 0; + const float grip_draw_size = (float)(int)ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f); + const float grip_hover_size = (float)(int)(grip_draw_size * 0.75f); + + ImVec2 pos_target(FLT_MAX, FLT_MAX); + ImVec2 size_target(FLT_MAX, FLT_MAX); + + // Manual resize grips + PushID("#RESIZE"); + for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++) + { + const ImGuiResizeGripDef& grip = resize_grip_def[resize_grip_n]; + const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, grip.CornerPos); + + // Using the FlattenChilds button flag we make the resize button accessible even if we are hovering over a child window + ImRect resize_rect(corner, corner + grip.InnerDir * grip_hover_size); + resize_rect.FixInverted(); + bool hovered, held; + ButtonBehavior(resize_rect, window->GetID((void*)(intptr_t)resize_grip_n), &hovered, &held, ImGuiButtonFlags_FlattenChildren); + if (hovered || held) + g.MouseCursor = (resize_grip_n & 1) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE; + + if (g.HoveredWindow == window && held && g.IO.MouseDoubleClicked[0] && resize_grip_n == 0) + { + // Manual auto-fit when double-clicking + size_target = CalcSizeAfterConstraint(window, size_auto_fit); + ClearActiveID(); + } + else if (held) + { + // Resize from any of the four corners + // We don't use an incremental MouseDelta but rather compute an absolute target size based on mouse position + ImVec2 corner_target = g.IO.MousePos - g.ActiveIdClickOffset + resize_rect.GetSize() * grip.CornerPos; // Corner of the window corresponding to our corner grip + CalcResizePosSizeFromAnyCorner(window, corner_target, grip.CornerPos, &pos_target, &size_target); + } + if (resize_grip_n == 0 || held || hovered) + resize_grip_col[resize_grip_n] = GetColorU32(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip); + } + for (int border_n = 0; border_n < resize_border_count; border_n++) + { + const float BORDER_SIZE = 5.0f; // FIXME: Only works _inside_ window because of HoveredWindow check. + const float BORDER_APPEAR_TIMER = 0.05f; // Reduce visual noise + bool hovered, held; + ImRect border_rect = GetBorderRect(window, border_n, grip_hover_size, BORDER_SIZE); + ButtonBehavior(border_rect, window->GetID((void*)(intptr_t)(border_n + 4)), &hovered, &held, ImGuiButtonFlags_FlattenChildren); + if ((hovered && g.HoveredIdTimer > BORDER_APPEAR_TIMER) || held) + { + g.MouseCursor = (border_n & 1) ? ImGuiMouseCursor_ResizeEW : ImGuiMouseCursor_ResizeNS; + if (held) *border_held = border_n; + } + if (held) + { + ImVec2 border_target = window->Pos; + ImVec2 border_posn; + if (border_n == 0) { border_posn = ImVec2(0, 0); border_target.y = (g.IO.MousePos.y - g.ActiveIdClickOffset.y); } + if (border_n == 1) { border_posn = ImVec2(1, 0); border_target.x = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + BORDER_SIZE); } + if (border_n == 2) { border_posn = ImVec2(0, 1); border_target.y = (g.IO.MousePos.y - g.ActiveIdClickOffset.y + BORDER_SIZE); } + if (border_n == 3) { border_posn = ImVec2(0, 0); border_target.x = (g.IO.MousePos.x - g.ActiveIdClickOffset.x); } + CalcResizePosSizeFromAnyCorner(window, border_target, border_posn, &pos_target, &size_target); + } + } + PopID(); + + // Apply back modified position/size to window + if (size_target.x != FLT_MAX) + { + window->SizeFull = size_target; + MarkIniSettingsDirty(window); + } + if (pos_target.x != FLT_MAX) + { + window->Pos = window->PosFloat = ImFloor(pos_target); + MarkIniSettingsDirty(window); + } + + window->Size = window->SizeFull; +} + +// Push a new ImGui window to add widgets to. +// - A default window called "Debug" is automatically stacked at the beginning of every frame so you can use widgets without explicitly calling a Begin/End pair. +// - Begin/End can be called multiple times during the frame with the same window name to append content. +// - The window name is used as a unique identifier to preserve window information across frames (and save rudimentary information to the .ini file). +// You can use the "##" or "###" markers to use the same label with different id, or same id with different label. See documentation at the top of this file. +// - Return false when window is collapsed, so you can early out in your code. You always need to call ImGui::End() even if false is returned. +// - Passing 'bool* p_open' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed. +bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags, bool* clicked_back) +{ + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + IM_ASSERT(name != NULL); // Window name required + IM_ASSERT(g.Initialized); // Forgot to call ImGui::NewFrame() + IM_ASSERT(g.FrameCountEnded != g.FrameCount); // Called ImGui::Render() or ImGui::EndFrame() and haven't called ImGui::NewFrame() again yet + + // Find or create + ImGuiWindow* window = FindWindowByName(name); + if (!window) + { + ImVec2 size_on_first_use = (g.NextWindowData.SizeCond != 0) ? g.NextWindowData.SizeVal : ImVec2(0.0f, 0.0f); // Any condition flag will do since we are creating a new window here. + window = CreateNewWindow(name, size_on_first_use, flags); + } + + // Automatically disable manual moving/resizing when NoInputs is set + if (flags & ImGuiWindowFlags_NoInputs) + flags |= ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize; + //if (flags & ImGuiWindowFlags_NavFlattened) + // IM_ASSERT(flags & ImGuiWindowFlags_ChildWindow); + + const int current_frame = g.FrameCount; + const bool first_begin_of_the_frame = (window->LastFrameActive != current_frame); + if (first_begin_of_the_frame) + window->Flags = (ImGuiWindowFlags)flags; + else + flags = window->Flags; + + // update the Appearing flag + bool window_just_activated_by_user = (window->LastFrameActive < current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on + const bool window_just_appearing_after_hidden_for_resize = (window->HiddenFrames == 1); + if (flags & ImGuiWindowFlags_Popup) + { + ImGuiPopupRef& popup_ref = g.OpenPopupStack[g.CurrentPopupStack.Size]; + window_just_activated_by_user |= (window->PopupId != popup_ref.PopupId); // We recycle popups so treat window as activated if popup id changed + window_just_activated_by_user |= (window != popup_ref.Window); + } + window->Appearing = (window_just_activated_by_user || window_just_appearing_after_hidden_for_resize); + window->CloseButton = (p_open != NULL); + if (window->Appearing) + SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, true); + + // Parent window is latched only on the first call to Begin() of the frame, so further append-calls can be done from a different window stack + ImGuiWindow* parent_window_in_stack = g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back(); + ImGuiWindow* parent_window = first_begin_of_the_frame ? ((flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)) ? parent_window_in_stack : NULL) : window->ParentWindow; + IM_ASSERT(parent_window != NULL || !(flags & ImGuiWindowFlags_ChildWindow)); + + // Add to stack + g.CurrentWindowStack.push_back(window); + SetCurrentWindow(window); + CheckStacksSize(window, true); + if (flags & ImGuiWindowFlags_Popup) + { + ImGuiPopupRef& popup_ref = g.OpenPopupStack[g.CurrentPopupStack.Size]; + popup_ref.Window = window; + g.CurrentPopupStack.push_back(popup_ref); + window->PopupId = popup_ref.PopupId; + } + + // Process SetNextWindow***() calls + bool window_pos_set_by_api = false; + bool window_size_x_set_by_api = false, window_size_y_set_by_api = false; + if (g.NextWindowData.PosCond) + { + window_pos_set_by_api = (window->SetWindowPosAllowFlags & g.NextWindowData.PosCond) != 0; + if (window_pos_set_by_api && ImLengthSqr(g.NextWindowData.PosPivotVal) > 0.00001f) + { + // May be processed on the next frame if this is our first frame and we are measuring size + // FIXME: Look into removing the branch so everything can go through this same code path for consistency. + window->SetWindowPosVal = g.NextWindowData.PosVal; + window->SetWindowPosPivot = g.NextWindowData.PosPivotVal; + window->SetWindowPosAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); + } + else + { + SetWindowPos(window, g.NextWindowData.PosVal, g.NextWindowData.PosCond); + } + g.NextWindowData.PosCond = 0; + } + if (g.NextWindowData.SizeCond) + { + window_size_x_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.x > 0.0f); + window_size_y_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.y > 0.0f); + SetWindowSize(window, g.NextWindowData.SizeVal, g.NextWindowData.SizeCond); + g.NextWindowData.SizeCond = 0; + } + if (g.NextWindowData.ContentSizeCond) + { + // Adjust passed "client size" to become a "window size" + window->SizeContentsExplicit = g.NextWindowData.ContentSizeVal; + window->SizeContentsExplicit.y += window->TitleBarHeight() + window->MenuBarHeight(); + g.NextWindowData.ContentSizeCond = 0; + } + else if (first_begin_of_the_frame) + { + window->SizeContentsExplicit = ImVec2(0.0f, 0.0f); + } + if (g.NextWindowData.CollapsedCond) + { + SetWindowCollapsed(window, g.NextWindowData.CollapsedVal, g.NextWindowData.CollapsedCond); + g.NextWindowData.CollapsedCond = 0; + } + if (g.NextWindowData.FocusCond) + { + SetWindowFocus(); + g.NextWindowData.FocusCond = 0; + } + if (window->Appearing) + SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false); + + // When reusing window again multiple times a frame, just append content (don't need to setup again) + if (first_begin_of_the_frame) + { + // initialize + window->ParentWindow = parent_window; + window->RootWindow = window->RootNonPopupWindow = window; + if (parent_window && (flags & ImGuiWindowFlags_ChildWindow)) + window->RootWindow = parent_window->RootWindow; + if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup))) + window->RootNonPopupWindow = parent_window->RootNonPopupWindow; + //window->RootNavWindow = window; + //while (window->RootNavWindow->Flags & ImGuiWindowFlags_NavFlattened) + // window->RootNavWindow = window->RootNavWindow->ParentWindow; + + window->Active = true; + window->BeginOrderWithinParent = 0; + window->BeginOrderWithinContext = g.WindowsActiveCount++; + window->BeginCount = 0; + window->ClipRect = ImVec4(-FLT_MAX,-FLT_MAX,+FLT_MAX,+FLT_MAX); + window->LastFrameActive = current_frame; + window->IDStack.resize(1); + + // Lock window rounding, border size and rounding so that altering the border sizes for children doesn't have side-effects. + window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding; + window->WindowBorderSize = (flags & ImGuiWindowFlags_ChildWindow && !(flags & ImGuiWindowFlags_GroupBox)) ? style.ChildBorderSize : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupBorderSize : style.WindowBorderSize; + window->WindowPadding = style.WindowPadding; + if (!(flags & ImGuiWindowFlags_GroupBox) && (flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f) + window->WindowPadding = ImVec2(0.0f, (flags & ImGuiWindowFlags_MenuBar) ? style.WindowPadding.y : 0.0f); + else if (flags & ImGuiWindowFlags_GroupBox) + window->WindowPadding.y += 4.f; + + + // Collapse window by double-clicking on title bar + // At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing + if (!(flags & ImGuiWindowFlags_NoTitleBar) && !(flags & ImGuiWindowFlags_NoCollapse)) + { + ImRect title_bar_rect = window->TitleBarRect(); + if (g.HoveredWindow == window && IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max) && g.IO.MouseDoubleClicked[0]) + { + window->Collapsed = !window->Collapsed; + MarkIniSettingsDirty(window); + FocusWindow(window); + } + } + else + { + window->Collapsed = false; + } + + // SIZE + + // update contents size from last frame for auto-fitting (unless explicitly specified) + window->SizeContents = CalcSizeContents(window); + + // Hide popup/tooltip window when re-opening while we measure size (because we recycle the windows) + if (window->HiddenFrames > 0) + window->HiddenFrames--; + if ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) != 0 && window_just_activated_by_user) + { + window->HiddenFrames = 1; + if (flags & ImGuiWindowFlags_AlwaysAutoResize) + { + if (!window_size_x_set_by_api) + window->Size.x = window->SizeFull.x = 0.f; + if (!window_size_y_set_by_api) + window->Size.y = window->SizeFull.y = 0.f; + window->SizeContents = ImVec2(0.f, 0.f); + } + } + + // Calculate auto-fit size, handle automatic resize + const ImVec2 size_auto_fit = CalcSizeAutoFit(window, window->SizeContents); + ImVec2 size_full_modified(FLT_MAX, FLT_MAX); + if (flags & ImGuiWindowFlags_AlwaysAutoResize && !window->Collapsed) + { + // Using SetNextWindowSize() overrides ImGuiWindowFlags_AlwaysAutoResize, so it can be used on tooltips/popups, etc. + if (!window_size_x_set_by_api) + window->SizeFull.x = size_full_modified.x = size_auto_fit.x; + if (!window_size_y_set_by_api) + window->SizeFull.y = size_full_modified.y = size_auto_fit.y; + } + else if (window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0) + { + // Auto-fit only grows during the first few frames + // We still process initial auto-fit on collapsed windows to get a window width, but otherwise don't honor ImGuiWindowFlags_AlwaysAutoResize when collapsed. + if (!window_size_x_set_by_api && window->AutoFitFramesX > 0) + window->SizeFull.x = size_full_modified.x = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.x, size_auto_fit.x) : size_auto_fit.x; + if (!window_size_y_set_by_api && window->AutoFitFramesY > 0) + window->SizeFull.y = size_full_modified.y = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.y, size_auto_fit.y) : size_auto_fit.y; + if (!window->Collapsed) + MarkIniSettingsDirty(window); + } + + // Apply minimum/maximum window size constraints and final size + window->SizeFull = CalcSizeAfterConstraint(window, window->SizeFull); + window->Size = window->Collapsed ? window->TitleBarRect().GetSize() : window->SizeFull; + if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup)) + { + IM_ASSERT(window_size_x_set_by_api && window_size_y_set_by_api); // Submitted by BeginChild() + window->Size = window->SizeFull; + } + + // SCROLLBAR STATUS + + // update scrollbar status (based on the Size that was effective during last frame or the auto-resized Size). + if (!window->Collapsed) + { + // When reading the current size we need to read it after size constraints have been applied + float size_x_for_scrollbars = size_full_modified.x != FLT_MAX ? window->SizeFull.x : window->SizeFullAtLastBegin.x; + float size_y_for_scrollbars = size_full_modified.y != FLT_MAX ? window->SizeFull.y : window->SizeFullAtLastBegin.y; + window->ScrollbarY = (flags & ImGuiWindowFlags_AlwaysVerticalScrollbar) || ((window->SizeContents.y > size_y_for_scrollbars) && !(flags & ImGuiWindowFlags_NoScrollbar)); + window->ScrollbarX = (flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar) || ((window->SizeContents.x > size_x_for_scrollbars - (window->ScrollbarY ? style.ScrollbarSize : 0.0f) - window->WindowPadding.x) && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar)); + if (window->ScrollbarX && !window->ScrollbarY) + window->ScrollbarY = (window->SizeContents.y > size_y_for_scrollbars + style.ScrollbarSize) && !(flags & ImGuiWindowFlags_NoScrollbar); + window->ScrollbarSizes = ImVec2(window->ScrollbarY ? style.ScrollbarSize : 0.0f, window->ScrollbarX ? style.ScrollbarSize : 0.0f); + } + + // POSITION + + // Popup latch its initial position, will position itself when it appears next frame + if (window_just_activated_by_user) + { + window->AutoPosLastDirection = ImGuiDir_None; + if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api) + window->Pos = window->PosFloat = g.CurrentPopupStack.back().OpenPopupPos; + } + + // Position child window + if (flags & ImGuiWindowFlags_ChildWindow) + { + window->BeginOrderWithinParent = parent_window->DC.ChildWindows.Size; + parent_window->DC.ChildWindows.push_back(window); + + if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api) + window->Pos = window->PosFloat = parent_window->DC.CursorPos; + } + + const bool window_pos_with_pivot = (window->SetWindowPosVal.x != FLT_MAX && window->HiddenFrames == 0); + if (window_pos_with_pivot) + { + // Position given a pivot (e.g. for centering) + SetWindowPos(window, ImMax(style.DisplaySafeAreaPadding, window->SetWindowPosVal - window->SizeFull * window->SetWindowPosPivot), 0); + } + else if (flags & ImGuiWindowFlags_ChildMenu) + { + // Child menus typically request _any_ position within the parent menu item, and then our FindBestPopupWindowPos() function will move the new menu outside the parent bounds. + // This is how we end up with child menus appearing (most-commonly) on the right of the parent menu. + IM_ASSERT(window_pos_set_by_api); + float horizontal_overlap = style.ItemSpacing.x; // We want some overlap to convey the relative depth of each popup (currently the amount of overlap it is hard-coded to style.ItemSpacing.x, may need to introduce another style value). + ImGuiWindow* parent_menu = parent_window_in_stack; + ImRect rect_to_avoid; + if (parent_menu->DC.MenuBarAppending) + rect_to_avoid = ImRect(-FLT_MAX, parent_menu->Pos.y + parent_menu->TitleBarHeight(), FLT_MAX, parent_menu->Pos.y + parent_menu->TitleBarHeight() + parent_menu->MenuBarHeight()); + else + rect_to_avoid = ImRect(parent_menu->Pos.x + horizontal_overlap, -FLT_MAX, parent_menu->Pos.x + parent_menu->Size.x - horizontal_overlap - parent_menu->ScrollbarSizes.x, FLT_MAX); + window->PosFloat = FindBestWindowPosForPopup(window->PosFloat, window->Size, &window->AutoPosLastDirection, rect_to_avoid); + } + else if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api && window_just_appearing_after_hidden_for_resize) + { + ImRect rect_to_avoid(window->PosFloat.x - 1, window->PosFloat.y - 1, window->PosFloat.x + 1, window->PosFloat.y + 1); + window->PosFloat = FindBestWindowPosForPopup(window->PosFloat, window->Size, &window->AutoPosLastDirection, rect_to_avoid); + } + + // Position tooltip (always follows mouse) + if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api) + { + ImVec2 ref_pos = g.IO.MousePos; + ImRect rect_to_avoid(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24, ref_pos.y + 24); // FIXME: Completely hard-coded. Store boxes in mouse cursor data? Scale? Center on cursor hit-point? + window->PosFloat = FindBestWindowPosForPopup(ref_pos, window->Size, &window->AutoPosLastDirection, rect_to_avoid); + if (window->AutoPosLastDirection == ImGuiDir_None) + window->PosFloat = ref_pos + ImVec2(2,2); // If there's not enough room, for tooltip we prefer avoiding the cursor at all cost even if it means that part of the tooltip won't be visible. + } + + // Clamp position so it stays visible + if (!(flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Tooltip)) + { + if (!window_pos_set_by_api && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0 && g.IO.DisplaySize.x > 0.0f && g.IO.DisplaySize.y > 0.0f) // Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing. + { + ImVec2 padding = ImMax(style.DisplayWindowPadding, style.DisplaySafeAreaPadding); + window->PosFloat = ImMax(window->PosFloat + window->Size, padding) - window->Size; + window->PosFloat = ImMin(window->PosFloat, g.IO.DisplaySize - padding); + } + } + window->Pos = ImFloor(window->PosFloat); + + // Default item width. Make it proportional to window size if window manually resizes + if (window->Size.x > 0.0f && !(flags & ImGuiWindowFlags_Tooltip) && !(flags & ImGuiWindowFlags_AlwaysAutoResize)) + window->ItemWidthDefault = (float)(int)(window->Size.x * 0.65f); + else + window->ItemWidthDefault = (float)(int)(g.FontSize * 16.0f); + + // Prepare for focus requests + window->FocusIdxAllRequestCurrent = (window->FocusIdxAllRequestNext == INT_MAX || window->FocusIdxAllCounter == -1) ? INT_MAX : (window->FocusIdxAllRequestNext + (window->FocusIdxAllCounter+1)) % (window->FocusIdxAllCounter+1); + window->FocusIdxTabRequestCurrent = (window->FocusIdxTabRequestNext == INT_MAX || window->FocusIdxTabCounter == -1) ? INT_MAX : (window->FocusIdxTabRequestNext + (window->FocusIdxTabCounter+1)) % (window->FocusIdxTabCounter+1); + window->FocusIdxAllCounter = window->FocusIdxTabCounter = -1; + window->FocusIdxAllRequestNext = window->FocusIdxTabRequestNext = INT_MAX; + + // Apply scrolling + window->Scroll = CalcNextScrollFromScrollTargetAndClamp(window); + window->ScrollTarget = ImVec2(FLT_MAX, FLT_MAX); + + // Apply focus, new windows appears in front + bool want_focus = false; + if (window_just_activated_by_user && !(flags & ImGuiWindowFlags_NoFocusOnAppearing)) + if (!(flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Tooltip)) || (flags & ImGuiWindowFlags_Popup)) + want_focus = true; + + // Handle manual resize: Resize Grips, Borders, Gamepad + int border_held = -1; + ImU32 resize_grip_col[4] = { 0 }; + const int resize_grip_count = (flags & ImGuiWindowFlags_ResizeFromAnySide) ? 2 : 1; // 4 + const float grip_draw_size = (float)(int)ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f); + if (!window->Collapsed) + UpdateManualResize(window, size_auto_fit, &border_held, resize_grip_count, &resize_grip_col[0]); + + // DRAWING + + // Setup draw list and outer clipping rectangle + window->DrawList->Clear(); + window->DrawList->Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0); + window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID); + ImRect fullscreen_rect(GetVisibleRect()); + if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup)) + PushClipRect(parent_window->ClipRect.Min, parent_window->ClipRect.Max, true); + else + PushClipRect(fullscreen_rect.Min, fullscreen_rect.Max, true); + + // Draw modal window background (darkens what is behind them) + if ((flags & ImGuiWindowFlags_Modal) != 0 && window == GetFrontMostModalRootWindow()) + window->DrawList->AddRectFilled(fullscreen_rect.Min, fullscreen_rect.Max, GetColorU32(ImGuiCol_ModalWindowDarkening, g.ModalWindowDarkeningRatio)); + + // Draw window + handle manual resize + const float window_rounding = window->WindowRounding; + const float window_border_size = window->WindowBorderSize; + ImRect title_bar_rect = window->TitleBarRect(); + const bool window_is_focused = want_focus || (g.NavWindow && window->RootNonPopupWindow == g.NavWindow->RootNonPopupWindow); + if (window->Collapsed) + { + // Title bar only + float backup_border_size = style.FrameBorderSize; + g.Style.FrameBorderSize = window->WindowBorderSize; + RenderFrame(title_bar_rect.Min, title_bar_rect.Max, GetColorU32(ImGuiCol_TitleBgCollapsed), true, window_rounding); + g.Style.FrameBorderSize = backup_border_size; + } + else + { + // Window background, Default Alpha + ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags)); + window->DrawList->AddRectFilled(window->Pos+ImVec2(0,window->TitleBarHeight()), window->Pos+window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot); + + // Title bar + if (!(flags & ImGuiWindowFlags_NoTitleBar)) { + window->DrawList->AddRectFilled(title_bar_rect.Min/* - ImVec2(0, 10)*/, title_bar_rect.Max, GetColorU32(window_is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg), window_rounding, ImDrawCornerFlags_Top); + + if (clicked_back && flags & ImGuiWindowFlags_CoolStyle) { + RenderTriangle(title_bar_rect.Min + style.FramePadding + ImVec2(2, 4), ImGuiDir_Left, 2.0f); + + //window->DrawList->AddRectFilled(title_bar_rect.Min + style.FramePadding, title_bar_rect.Min + style.FramePadding + ImVec2(20, 28), ImU32(((255 & 0xff) << 24) + ((0 & 0xff) << 16) + ((0 & 0xff) << 8) + // + (255 & 0xff)), window_rounding, ImDrawCornerFlags_Top); + + if (g.HoveredWindow == window && IsMouseHoveringRect(title_bar_rect.Min + style.FramePadding, title_bar_rect.Min + style.FramePadding + ImVec2(20, 28)) && g.IO.MouseClicked[0]) + *clicked_back = true; + } + } + + // Menu bar + if (flags & ImGuiWindowFlags_MenuBar) + { + ImRect menu_bar_rect = window->MenuBarRect(); + menu_bar_rect.ClipWith(window->Rect()); // Soft clipping, in particular child window don't have minimum size covering the menu bar so this is useful for them. + window->DrawList->AddRectFilled(menu_bar_rect.Min, menu_bar_rect.Max, GetColorU32(ImGuiCol_MenuBarBg), (flags & ImGuiWindowFlags_NoTitleBar) ? window_rounding : 0.0f, ImDrawCornerFlags_Top); + if (style.FrameBorderSize > 0.0f && menu_bar_rect.Max.y < window->Pos.y + window->Size.y) + window->DrawList->AddLine(menu_bar_rect.GetBL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_Border), style.FrameBorderSize); + } + + // Scrollbars + if (window->ScrollbarX) + Scrollbar(ImGuiLayoutType_Horizontal); + if (window->ScrollbarY) + Scrollbar(ImGuiLayoutType_Vertical); + + // Render resize grips (after their input handling so we don't have a frame of latency) + if (!(flags & ImGuiWindowFlags_NoResize)) + { + for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++) + { + const ImGuiResizeGripDef& grip = resize_grip_def[resize_grip_n]; + const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, grip.CornerPos); + window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(window_border_size, grip_draw_size) : ImVec2(grip_draw_size, window_border_size))); + window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(grip_draw_size, window_border_size) : ImVec2(window_border_size, grip_draw_size))); + window->DrawList->PathArcToFast(ImVec2(corner.x + grip.InnerDir.x * (window_rounding + window_border_size), corner.y + grip.InnerDir.y * (window_rounding + window_border_size)), window_rounding, grip.AngleMin12, grip.AngleMax12); + window->DrawList->PathFillConvex(resize_grip_col[resize_grip_n]); + } + } + + // Borders + if (window_border_size > 0.0f) + window->DrawList->AddRect(window->Pos, window->Pos+window->Size, GetColorU32(ImGuiCol_Border), window_rounding, ImDrawCornerFlags_All, window_border_size); + if (border_held != -1) + { + ImRect border = GetBorderRect(window, border_held, grip_draw_size, 0.0f); + window->DrawList->AddLine(border.Min, border.Max, GetColorU32(ImGuiCol_SeparatorActive), ImMax(1.0f, window_border_size)); + } + if (style.FrameBorderSize > 0 && !(flags & ImGuiWindowFlags_NoTitleBar)) + window->DrawList->AddLine(title_bar_rect.GetBL() + ImVec2(style.WindowBorderSize, -1), title_bar_rect.GetBR() + ImVec2(-style.WindowBorderSize,-1), GetColorU32(ImGuiCol_Border), style.FrameBorderSize); + } + + // Store a backup of SizeFull which we will use next frame to decide if we need scrollbars. + window->SizeFullAtLastBegin = window->SizeFull; + + // update ContentsRegionMax. All the variable it depends on are set above in this function. + window->ContentsRegionRect.Min.x = -window->Scroll.x + window->WindowPadding.x; + window->ContentsRegionRect.Min.y = -window->Scroll.y + window->WindowPadding.y + window->TitleBarHeight() + window->MenuBarHeight(); + window->ContentsRegionRect.Max.x = -window->Scroll.x - window->WindowPadding.x + (window->SizeContentsExplicit.x != 0.0f ? window->SizeContentsExplicit.x : (window->Size.x - window->ScrollbarSizes.x)); + window->ContentsRegionRect.Max.y = -window->Scroll.y - window->WindowPadding.y + (window->SizeContentsExplicit.y != 0.0f ? window->SizeContentsExplicit.y : (window->Size.y - window->ScrollbarSizes.y)); + + // Setup drawing context + // (NB: That term "drawing context / DC" lost its meaning a long time ago. Initially was meant to hold transient data only. Nowadays difference between window-> and window->DC-> is dubious.) + window->DC.IndentX = 0.0f + window->WindowPadding.x - window->Scroll.x; + window->DC.GroupOffsetX = 0.0f; + window->DC.ColumnsOffsetX = 0.0f; + window->DC.CursorStartPos = window->Pos + ImVec2(window->DC.IndentX + window->DC.ColumnsOffsetX, window->TitleBarHeight() + window->MenuBarHeight() + window->WindowPadding.y - window->Scroll.y); + window->DC.CursorPos = window->DC.CursorStartPos; + window->DC.CursorPosPrevLine = window->DC.CursorPos; + window->DC.CursorMaxPos = window->DC.CursorStartPos; + window->DC.CurrentLineHeight = window->DC.PrevLineHeight = 0.0f; + window->DC.CurrentLineTextBaseOffset = window->DC.PrevLineTextBaseOffset = 0.0f; + window->DC.MenuBarAppending = false; + window->DC.MenuBarOffsetX = ImMax(window->WindowPadding.x, style.ItemSpacing.x); + window->DC.LogLinePosY = window->DC.CursorPos.y - 9999.0f; + window->DC.ChildWindows.resize(0); + window->DC.LayoutType = ImGuiLayoutType_Vertical; + window->DC.ItemFlags = ImGuiItemFlags_Default_; + window->DC.ItemWidth = window->ItemWidthDefault; + window->DC.TextWrapPos = -1.0f; // disabled + window->DC.ItemFlagsStack.resize(0); + window->DC.ItemWidthStack.resize(0); + window->DC.TextWrapPosStack.resize(0); + window->DC.ColumnsSet = NULL; + window->DC.TreeDepth = 0; + window->DC.StateStorage = &window->StateStorage; + window->DC.GroupStack.resize(0); + window->MenuColumns.update(3, style.ItemSpacing.x, window_just_activated_by_user); + + if ((flags & ImGuiWindowFlags_ChildWindow) && (window->DC.ItemFlags != parent_window->DC.ItemFlags)) + { + window->DC.ItemFlags = parent_window->DC.ItemFlags; + window->DC.ItemFlagsStack.push_back(window->DC.ItemFlags); + } + + if (window->AutoFitFramesX > 0) + window->AutoFitFramesX--; + if (window->AutoFitFramesY > 0) + window->AutoFitFramesY--; + + // Apply focus (we need to call FocusWindow() AFTER setting DC.CursorStartPos so our initial navigation reference rectangle can start around there) + if (want_focus) + FocusWindow(window); + + // Title bar + if (!(flags & ImGuiWindowFlags_NoTitleBar)) + { + // Collapse button + if (!(flags & ImGuiWindowFlags_NoCollapse)) + { + RenderTriangle(window->Pos + style.FramePadding, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f); + } + + // Close button + if (p_open != NULL) + { + const float PAD = 2.0f; + const float rad = (window->TitleBarHeight() - PAD*2.0f) * 0.5f; + if (CloseButton(window->GetID("#CLOSE"), window->Rect().GetTR() + ImVec2(-PAD - rad, PAD + rad), rad)) + *p_open = false; + } + + // Title text (FIXME: refactor text alignment facilities along with RenderText helpers) + ImVec2 text_size = CalcTextSize(name, NULL, true); + ImRect text_r = title_bar_rect; + float pad_left = (flags & ImGuiWindowFlags_NoCollapse) == 0 ? (style.FramePadding.x + g.FontSize + style.ItemInnerSpacing.x) : style.FramePadding.x; + float pad_right = (p_open != NULL) ? (style.FramePadding.x + g.FontSize + style.ItemInnerSpacing.x) : style.FramePadding.x; + if (style.WindowTitleAlign.x > 0.0f) pad_right = ImLerp(pad_right, pad_left, style.WindowTitleAlign.x); + text_r.Min.x += pad_left; + text_r.Max.x -= pad_right; + ImRect clip_rect = text_r; + clip_rect.Max.x = window->Pos.x + window->Size.x - (p_open ? title_bar_rect.GetHeight() - 3 : style.FramePadding.x); // Match the size of CloseButton() + RenderTextClipped(text_r.Min, text_r.Max, name, NULL, &text_size, style.WindowTitleAlign, &clip_rect); + } + else if (flags & ImGuiWindowFlags_GroupBox) { + auto text_size = CalcTextSize(name, NULL, true); + + /*if (text_size.x > 1.0f) { + window->DrawList->AddLine(window->Pos, window->Pos + ImVec2{ g.Style.WindowPadding.x * 0.5f, 0.0f }, GetColorU32(ImGuiCol_Border)); + window->DrawList->AddLine(window->Pos + ImVec2{ g.Style.WindowPadding.x * 0.5f + text_size.x + g.Style.WindowPadding.x, 0.0f }, window->Pos + ImVec2{ window->Size.x, 0.0f }, GetColorU32(ImGuiCol_Border)); + + window->DrawList->AddLine(window->Pos, window->Pos + ImVec2{ 0.0f, window->Size.y }, GetColorU32(ImGuiCol_Border)); + + window->DrawList->AddLine(window->Pos + ImVec2{ window->Size.x, 0.0f }, window->Pos + window->Size + ImVec2{ 0.0f, 0.5f }, GetColorU32(ImGuiCol_Border)); + + window->DrawList->AddLine(window->Pos + ImVec2{ 0.0f, window->Size.y }, window->Pos + window->Size + ImVec2{ 0.5f, 0.0f }, GetColorU32(ImGuiCol_Border)); + window->DrawList->PushClipRectFullScreen(); + RenderText(window->Pos + ImVec2{ g.Style.WindowPadding.x, -text_size.y / 2 }, name, NULL, true); + window->DrawList->PopClipRect(); + } + else {*/ + + window->DrawList->AddRectFilled(window->Pos, window->Pos + ImVec2(window->Size.x, text_size.y * 1.5), GetColorU32(ImGuiCol_Border), window_rounding); + + RenderText(window->Pos + ImVec2(g.Style.WindowPadding.x, 2), name, NULL, true); + + window->DrawList->AddRect(window->Pos + ImVec2(1, 1), window->Pos + window->Size + ImVec2(1, 1), GetColorU32(ImGuiCol_BorderShadow), window_rounding); + + window->DrawList->AddRect(window->Pos, window->Pos + window->Size, GetColorU32(ImGuiCol_Border), window_rounding); + + window->DC.CursorPos.y += text_size.y * 1.5; + //} + } + + // Save clipped aabb so we can access it in constant-time in FindHoveredWindow() + window->WindowRectClipped = window->Rect(); + window->WindowRectClipped.ClipWith(window->ClipRect); + + // Pressing CTRL+C while holding on a window copy its content to the clipboard + // This works but 1. doesn't handle multiple Begin/End pairs, 2. recursing into another Begin/End pair - so we need to work that out and add better logging scope. + // Maybe we can support CTRL+C on every element? + /* + if (g.ActiveId == move_id) + if (g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_C)) + ImGui::LogToClipboard(); + */ + + // Inner rectangle + // We set this up after processing the resize grip so that our clip rectangle doesn't lag by a frame + // Note that if our window is collapsed we will end up with a null clipping rectangle which is the correct behavior. + window->InnerRect.Min.x = title_bar_rect.Min.x + window->WindowBorderSize; + window->InnerRect.Min.y = title_bar_rect.Max.y + window->MenuBarHeight() + (((flags & ImGuiWindowFlags_MenuBar) || !(flags & ImGuiWindowFlags_NoTitleBar)) ? style.FrameBorderSize : window->WindowBorderSize); + window->InnerRect.Max.x = window->Pos.x + window->Size.x - window->ScrollbarSizes.x - window->WindowBorderSize; + window->InnerRect.Max.y = window->Pos.y + window->Size.y - window->ScrollbarSizes.y - window->WindowBorderSize; + //window->DrawList->AddRect(window->InnerRect.Min, window->InnerRect.Max, IM_COL32_WHITE); + + // After Begin() we fill the last item / hovered data using the title bar data. Make that a standard behavior (to allow usage of context menus on title bar only, etc.). + window->DC.LastItemId = window->MoveId; + window->DC.LastItemRect = title_bar_rect; + window->DC.LastItemRectHoveredRect = IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false); + } + + // Inner clipping rectangle + // Force round operator last to ensure that e.g. (int)(max.x-min.x) in user's render code produce correct result. + const float border_size = window->WindowBorderSize; + ImRect clip_rect; + clip_rect.Min.x = ImFloor(0.5f + window->InnerRect.Min.x + ImMax(0.0f, ImFloor(window->WindowPadding.x*0.5f - border_size))); + clip_rect.Min.y = ImFloor(0.5f + window->InnerRect.Min.y); + clip_rect.Max.x = ImFloor(0.5f + window->InnerRect.Max.x - ImMax(0.0f, ImFloor(window->WindowPadding.x*0.5f - border_size))); + clip_rect.Max.y = ImFloor(0.5f + window->InnerRect.Max.y); + PushClipRect(clip_rect.Min, clip_rect.Max, true); + + // Clear 'accessed' flag last thing (After PushClipRect which will set the flag. We want the flag to stay false when the default "Debug" window is unused) + if (first_begin_of_the_frame) + window->WriteAccessed = false; + + window->BeginCount++; + g.NextWindowData.SizeConstraintCond = 0; + + // Child window can be out of sight and have "negative" clip windows. + // Mark them as collapsed so commands are skipped earlier (we can't manually collapse because they have no title bar). + if (flags & ImGuiWindowFlags_ChildWindow) + { + IM_ASSERT((flags & ImGuiWindowFlags_NoTitleBar) != 0); + window->Collapsed = parent_window && parent_window->Collapsed; + + if (!(flags & ImGuiWindowFlags_AlwaysAutoResize) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0) + window->Collapsed |= (window->WindowRectClipped.Min.x >= window->WindowRectClipped.Max.x || window->WindowRectClipped.Min.y >= window->WindowRectClipped.Max.y); + + // We also hide the window from rendering because we've already added its border to the command list. + // (we could perform the check earlier in the function but it is simpler at this point) + if (window->Collapsed) + window->Active = false; + } + if (style.Alpha <= 0.0f) + window->Active = false; + + // Return false if we don't intend to display anything to allow user to perform an early out optimization + window->SkipItems = (window->Collapsed || !window->Active) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0; + return !window->SkipItems; +} + +// Old Begin() API with 5 parameters, avoid calling this version directly! Use SetNextWindowSize()+Begin() instead. +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS +bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha_override, ImGuiWindowFlags flags) +{ + // Old API feature: we could pass the initial window size as a parameter, however this was very misleading because in most cases it would only affect the window when it didn't have storage in the .ini file. + if (size_on_first_use.x != 0.0f || size_on_first_use.y != 0.0f) + SetNextWindowSize(size_on_first_use, ImGuiCond_FirstUseEver); + + // Old API feature: we could override the window background alpha with a parameter. This is actually tricky to reproduce manually because: + // (1) there are multiple variants of WindowBg (popup, tooltip, etc.) and (2) you can't call PushStyleColor before Begin and PopStyleColor just after Begin() because of how CheckStackSizes() behave. + // The user-side solution is to do backup = GetStyleColorVec4(ImGuiCol_xxxBG), PushStyleColor(ImGuiCol_xxxBg), Begin, PushStyleColor(ImGuiCol_xxxBg, backup), [...], PopStyleColor(), End(); PopStyleColor() - which is super awkward. + // The alpha override was rarely used but for now we'll leave the Begin() variant around for a bit. We may either lift the constraint on CheckStackSizes() either add a SetNextWindowBgAlpha() helper that does it magically. + ImGuiContext& g = *GImGui; + const ImGuiCol bg_color_idx = GetWindowBgColorIdxFromFlags(flags); + const ImVec4 bg_color_backup = g.Style.Colors[bg_color_idx]; + if (bg_alpha_override >= 0.0f) + g.Style.Colors[bg_color_idx].w = bg_alpha_override; + + bool ret = Begin(name, p_open, flags); + + if (bg_alpha_override >= 0.0f) + g.Style.Colors[bg_color_idx] = bg_color_backup; + return ret; +} +#endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS + +void ImGui::End() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + if (window->DC.ColumnsSet != NULL) + EndColumns(); + PopClipRect(); // inner window clip rectangle + + // Stop logging + if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME: add more options for scope of logging + LogFinish(); + + // Pop + // NB: we don't clear 'window->RootWindow'. The pointer is allowed to live until the next call to Begin(). + g.CurrentWindowStack.pop_back(); + if (window->Flags & ImGuiWindowFlags_Popup) + g.CurrentPopupStack.pop_back(); + CheckStacksSize(window, false); + SetCurrentWindow(g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back()); +} + +// Vertical scrollbar +// The entire piece of code below is rather confusing because: +// - We handle absolute seeking (when first clicking outside the grab) and relative manipulation (afterward or when clicking inside the grab) +// - We store values as normalized ratio and in a form that allows the window content to change while we are holding on a scrollbar +// - We handle both horizontal and vertical scrollbars, which makes the terminology not ideal. +void ImGui::Scrollbar(ImGuiLayoutType direction) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + const bool horizontal = (direction == ImGuiLayoutType_Horizontal); + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(horizontal ? "#SCROLLX" : "#SCROLLY"); + + // Render background + bool other_scrollbar = (horizontal ? window->ScrollbarY : window->ScrollbarX); + float other_scrollbar_size_w = other_scrollbar ? style.ScrollbarSize : 0.0f; + const ImRect window_rect = window->Rect(); + const float border_size = window->WindowBorderSize; + ImRect bb = horizontal + ? ImRect(window->Pos.x + border_size, window_rect.Max.y - style.ScrollbarSize, window_rect.Max.x - other_scrollbar_size_w - border_size, window_rect.Max.y - border_size) + : ImRect(window_rect.Max.x - style.ScrollbarSize, window->Pos.y + border_size, window_rect.Max.x - border_size, window_rect.Max.y - other_scrollbar_size_w - border_size); + if (!horizontal) + bb.Min.y += window->TitleBarHeight() + ((window->Flags & ImGuiWindowFlags_MenuBar) ? window->MenuBarHeight() : 0.0f); + if (bb.GetWidth() <= 0.0f || bb.GetHeight() <= 0.0f) + return; + + int window_rounding_corners; + if (horizontal) + window_rounding_corners = ImDrawCornerFlags_BotLeft | (other_scrollbar ? 0 : ImDrawCornerFlags_BotRight); + else + window_rounding_corners = (((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) ? ImDrawCornerFlags_TopRight : 0) | (other_scrollbar ? 0 : ImDrawCornerFlags_BotRight); + window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_ScrollbarBg), window->WindowRounding, window_rounding_corners); + bb.Expand(ImVec2(-ImClamp((float)(int)((bb.Max.x - bb.Min.x - 2.0f) * 0.5f), 0.0f, 3.0f), -ImClamp((float)(int)((bb.Max.y - bb.Min.y - 2.0f) * 0.5f), 0.0f, 3.0f))); + + // V denote the main, longer axis of the scrollbar (= height for a vertical scrollbar) + float scrollbar_size_v = horizontal ? bb.GetWidth() : bb.GetHeight(); + float scroll_v = horizontal ? window->Scroll.x : window->Scroll.y; + float win_size_avail_v = (horizontal ? window->SizeFull.x : window->SizeFull.y) - other_scrollbar_size_w; + float win_size_contents_v = horizontal ? window->SizeContents.x : window->SizeContents.y; + + // Calculate the height of our grabbable box. It generally represent the amount visible (vs the total scrollable amount) + // But we maintain a minimum size in pixel to allow for the user to still aim inside. + IM_ASSERT(ImMax(win_size_contents_v, win_size_avail_v) > 0.0f); // Adding this assert to check if the ImMax(XXX,1.0f) is still needed. PLEASE CONTACT ME if this triggers. + const float win_size_v = ImMax(ImMax(win_size_contents_v, win_size_avail_v), 1.0f); + const float grab_h_pixels = ImClamp(scrollbar_size_v * (win_size_avail_v / win_size_v), style.GrabMinSize, scrollbar_size_v); + const float grab_h_norm = grab_h_pixels / scrollbar_size_v; + + // Handle input right away. None of the code of Begin() is relying on scrolling position before calling Scrollbar(). + bool held = false; + bool hovered = false; + const bool previously_held = (g.ActiveId == id); + ButtonBehavior(bb, id, &hovered, &held); + + float scroll_max = ImMax(1.0f, win_size_contents_v - win_size_avail_v); + float scroll_ratio = ImSaturate(scroll_v / scroll_max); + float grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v; + if (held && grab_h_norm < 1.0f) + { + float scrollbar_pos_v = horizontal ? bb.Min.x : bb.Min.y; + float mouse_pos_v = horizontal ? g.IO.MousePos.x : g.IO.MousePos.y; + float* click_delta_to_grab_center_v = horizontal ? &g.ScrollbarClickDeltaToGrabCenter.x : &g.ScrollbarClickDeltaToGrabCenter.y; + + // Click position in scrollbar normalized space (0.0f->1.0f) + const float clicked_v_norm = ImSaturate((mouse_pos_v - scrollbar_pos_v) / scrollbar_size_v); + SetHoveredID(id); + + bool seek_absolute = false; + if (!previously_held) + { + // On initial click calculate the distance between mouse and the center of the grab + if (clicked_v_norm >= grab_v_norm && clicked_v_norm <= grab_v_norm + grab_h_norm) + { + *click_delta_to_grab_center_v = clicked_v_norm - grab_v_norm - grab_h_norm*0.5f; + } + else + { + seek_absolute = true; + *click_delta_to_grab_center_v = 0.0f; + } + } + + // Apply scroll + // It is ok to modify Scroll here because we are being called in Begin() after the calculation of SizeContents and before setting up our starting position + const float scroll_v_norm = ImSaturate((clicked_v_norm - *click_delta_to_grab_center_v - grab_h_norm*0.5f) / (1.0f - grab_h_norm)); + scroll_v = (float)(int)(0.5f + scroll_v_norm * scroll_max);//(win_size_contents_v - win_size_v)); + if (horizontal) + window->Scroll.x = scroll_v; + else + window->Scroll.y = scroll_v; + + // update values for rendering + scroll_ratio = ImSaturate(scroll_v / scroll_max); + grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v; + + // update distance to grab now that we have seeked and saturated + if (seek_absolute) + *click_delta_to_grab_center_v = clicked_v_norm - grab_v_norm - grab_h_norm*0.5f; + } + + // Render + const ImU32 grab_col = GetColorU32(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab); + ImRect grab_rect; + if (horizontal) + grab_rect = ImRect(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm), bb.Min.y, ImMin(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm) + grab_h_pixels, window_rect.Max.x), bb.Max.y); + else + grab_rect = ImRect(bb.Min.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm), bb.Max.x, ImMin(ImLerp(bb.Min.y, bb.Max.y, grab_v_norm) + grab_h_pixels, window_rect.Max.y)); + window->DrawList->AddRectFilled(grab_rect.Min, grab_rect.Max, grab_col, style.ScrollbarRounding); +} + +void ImGui::BringWindowToFront(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + if (g.Windows.back() == window) + return; + for (int i = g.Windows.Size - 2; i >= 0; i--) // We can ignore the front most window + if (g.Windows[i] == window) + { + g.Windows.erase(g.Windows.Data + i); + g.Windows.push_back(window); + break; + } +} + +void ImGui::BringWindowToBack(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + if (g.Windows[0] == window) + return; + for (int i = 0; i < g.Windows.Size; i++) + if (g.Windows[i] == window) + { + memmove(&g.Windows[1], &g.Windows[0], (size_t)i * sizeof(ImGuiWindow*)); + g.Windows[0] = window; + break; + } +} + +// Moving window to front of display and set focus (which happens to be back of our sorted list) +void ImGui::FocusWindow(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + + // Always mark the window we passed as focused. This is used for keyboard interactions such as tabbing. + g.NavWindow = window; + + // Passing NULL allow to disable keyboard focus + if (!window) + return; + + // Move the root window to the top of the pile + if (window->RootWindow) + window = window->RootWindow; + + // Steal focus on active widgets + if (window->Flags & ImGuiWindowFlags_Popup) // FIXME: This statement should be unnecessary. Need further testing before removing it.. + if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindow != window) + ClearActiveID(); + + // Bring to front + if (!(window->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) + BringWindowToFront(window); +} + +void ImGui::FocusFrontMostActiveWindow(ImGuiWindow* ignore_window) +{ + ImGuiContext& g = *GImGui; + for (int i = g.Windows.Size - 1; i >= 0; i--) + if (g.Windows[i] != ignore_window && g.Windows[i]->WasActive && !(g.Windows[i]->Flags & ImGuiWindowFlags_ChildWindow)) + { + FocusWindow(g.Windows[i]); + return; + } +} + +void ImGui::PushItemWidth(float item_width) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.ItemWidth = (item_width == 0.0f ? window->ItemWidthDefault : item_width); + window->DC.ItemWidthStack.push_back(window->DC.ItemWidth); +} + +void ImGui::PushMultiItemsWidths(int components, float w_full) +{ + ImGuiWindow* window = GetCurrentWindow(); + const ImGuiStyle& style = GImGui->Style; + if (w_full <= 0.0f) + w_full = CalcItemWidth(); + const float w_item_one = ImMax(1.0f, (float)(int)((w_full - (style.ItemInnerSpacing.x) * (components-1)) / (float)components)); + const float w_item_last = ImMax(1.0f, (float)(int)(w_full - (w_item_one + style.ItemInnerSpacing.x) * (components-1))); + window->DC.ItemWidthStack.push_back(w_item_last); + for (int i = 0; i < components-1; i++) + window->DC.ItemWidthStack.push_back(w_item_one); + window->DC.ItemWidth = window->DC.ItemWidthStack.back(); +} + +void ImGui::PopItemWidth() +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.ItemWidthStack.pop_back(); + window->DC.ItemWidth = window->DC.ItemWidthStack.empty() ? window->ItemWidthDefault : window->DC.ItemWidthStack.back(); +} + +float ImGui::CalcItemWidth() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + float w = window->DC.ItemWidth; + if (w < 0.0f) + { + // Align to a right-side limit. We include 1 frame padding in the calculation because this is how the width is always used (we add 2 frame padding to it), but we could move that responsibility to the widget as well. + float width_to_right_edge = GetContentRegionAvail().x; + w = ImMax(1.0f, width_to_right_edge + w); + } + w = (float)(int)w; + return w; +} + +static ImFont* GetDefaultFont() +{ + ImGuiContext& g = *GImGui; + return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; +} + +static void SetCurrentFont(ImFont* font) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(font && font->IsLoaded()); // Font Atlas not created. Did you call io.Fonts->GetTexDataAsRGBA32 / GetTexDataAsAlpha8 ? + IM_ASSERT(font->Scale > 0.0f); + g.Font = font; + g.FontBaseSize = g.IO.FontGlobalScale * g.Font->FontSize * g.Font->Scale; + g.FontSize = g.CurrentWindow ? g.CurrentWindow->CalcFontSize() : 0.0f; + + ImFontAtlas* atlas = g.Font->ContainerAtlas; + g.DrawListSharedData.TexUvWhitePixel = atlas->TexUvWhitePixel; + g.DrawListSharedData.Font = g.Font; + g.DrawListSharedData.FontSize = g.FontSize; +} + +void ImGui::PushFont(ImFont* font) +{ + ImGuiContext& g = *GImGui; + if (!font) + font = GetDefaultFont(); + SetCurrentFont(font); + g.FontStack.push_back(font); + g.CurrentWindow->DrawList->PushTextureID(font->ContainerAtlas->TexID); +} + +void ImGui::PopFont() +{ + ImGuiContext& g = *GImGui; + g.CurrentWindow->DrawList->PopTextureID(); + g.FontStack.pop_back(); + SetCurrentFont(g.FontStack.empty() ? GetDefaultFont() : g.FontStack.back()); +} + +void ImGui::PushItemFlag(ImGuiItemFlags option, bool enabled) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (enabled) + window->DC.ItemFlags |= option; + else + window->DC.ItemFlags &= ~option; + window->DC.ItemFlagsStack.push_back(window->DC.ItemFlags); +} + +void ImGui::PopItemFlag() +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.ItemFlagsStack.pop_back(); + window->DC.ItemFlags = window->DC.ItemFlagsStack.empty() ? ImGuiItemFlags_Default_ : window->DC.ItemFlagsStack.back(); +} + +void ImGui::PushAllowKeyboardFocus(bool allow_keyboard_focus) +{ + PushItemFlag(ImGuiItemFlags_AllowKeyboardFocus, allow_keyboard_focus); +} + +void ImGui::PopAllowKeyboardFocus() +{ + PopItemFlag(); +} + +void ImGui::PushButtonRepeat(bool repeat) +{ + PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat); +} + +void ImGui::PopButtonRepeat() +{ + PopItemFlag(); +} + +void ImGui::PushTextWrapPos(float wrap_pos_x) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.TextWrapPos = wrap_pos_x; + window->DC.TextWrapPosStack.push_back(wrap_pos_x); +} + +void ImGui::PopTextWrapPos() +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.TextWrapPosStack.pop_back(); + window->DC.TextWrapPos = window->DC.TextWrapPosStack.empty() ? -1.0f : window->DC.TextWrapPosStack.back(); +} + +// FIXME: This may incur a round-trip (if the end user got their data from a float4) but eventually we aim to store the in-flight colors as ImU32 +void ImGui::PushStyleColor(ImGuiCol idx, ImU32 col) +{ + ImGuiContext& g = *GImGui; + ImGuiColMod backup; + backup.Col = idx; + backup.BackupValue = g.Style.Colors[idx]; + g.ColorModifiers.push_back(backup); + g.Style.Colors[idx] = ColorConvertU32ToFloat4(col); +} + +void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col) +{ + ImGuiContext& g = *GImGui; + ImGuiColMod backup; + backup.Col = idx; + backup.BackupValue = g.Style.Colors[idx]; + g.ColorModifiers.push_back(backup); + g.Style.Colors[idx] = col; +} + +void ImGui::PopStyleColor(int count) +{ + ImGuiContext& g = *GImGui; + while (count > 0) + { + ImGuiColMod& backup = g.ColorModifiers.back(); + g.Style.Colors[backup.Col] = backup.BackupValue; + g.ColorModifiers.pop_back(); + count--; + } +} + +struct ImGuiStyleVarInfo +{ + ImGuiDataType Type; + ImU32 Offset; + void* GetVarPtr(ImGuiStyle* style) const { return (void*)((unsigned char*)style + Offset); } +}; + +static const ImGuiStyleVarInfo GStyleVarInfo[ImGuiStyleVar_Count_] = +{ + { ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha + { ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding + { ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding + { ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize + { ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize + { ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildRounding) }, // ImGuiStyleVar_ChildRounding + { ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildBorderSize) }, // ImGuiStyleVar_ChildBorderSize + { ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupRounding) }, // ImGuiStyleVar_PopupRounding + { ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupBorderSize) }, // ImGuiStyleVar_PopupBorderSize + { ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding + { ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding + { ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameBorderSize) }, // ImGuiStyleVar_FrameBorderSize + { ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing + { ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing + { ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing + { ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize + { ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign +}; + +static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx) +{ + IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_Count_); + return &GStyleVarInfo[idx]; +} + +void ImGui::PushStyleVar(ImGuiStyleVar idx, float val) +{ + const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx); + if (var_info->Type == ImGuiDataType_Float) + { + ImGuiContext& g = *GImGui; + float* pvar = (float*)var_info->GetVarPtr(&g.Style); + g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar)); + *pvar = val; + return; + } + IM_ASSERT(0); // Called function with wrong-type? Variable is not a float. +} + +void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val) +{ + const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx); + if (var_info->Type == ImGuiDataType_Float2) + { + ImGuiContext& g = *GImGui; + ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&g.Style); + g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar)); + *pvar = val; + return; + } + IM_ASSERT(0); // Called function with wrong-type? Variable is not a ImVec2. +} + +void ImGui::PopStyleVar(int count) +{ + ImGuiContext& g = *GImGui; + while (count > 0) + { + ImGuiStyleMod& backup = g.StyleModifiers.back(); + const ImGuiStyleVarInfo* info = GetStyleVarInfo(backup.VarIdx); + if (info->Type == ImGuiDataType_Float) (*(float*)info->GetVarPtr(&g.Style)) = backup.BackupFloat[0]; + else if (info->Type == ImGuiDataType_Float2) (*(ImVec2*)info->GetVarPtr(&g.Style)) = ImVec2(backup.BackupFloat[0], backup.BackupFloat[1]); + else if (info->Type == ImGuiDataType_Int) (*(int*)info->GetVarPtr(&g.Style)) = backup.BackupInt[0]; + g.StyleModifiers.pop_back(); + count--; + } +} + +const char* ImGui::GetStyleColorName(ImGuiCol idx) +{ + // Create switch-case from enum with regexp: ImGuiCol_{.*}, --> case ImGuiCol_\1: return "\1"; + switch (idx) + { + case ImGuiCol_Text: return "Text"; + case ImGuiCol_TextDisabled: return "TextDisabled"; + case ImGuiCol_WindowBg: return "WindowBg"; + case ImGuiCol_ChildBg: return "ChildBg"; + case ImGuiCol_PopupBg: return "PopupBg"; + case ImGuiCol_Border: return "Border"; + case ImGuiCol_BorderShadow: return "BorderShadow"; + case ImGuiCol_FrameBg: return "FrameBg"; + case ImGuiCol_FrameBgHovered: return "FrameBgHovered"; + case ImGuiCol_FrameBgActive: return "FrameBgActive"; + case ImGuiCol_TitleBg: return "TitleBg"; + case ImGuiCol_TitleBgActive: return "TitleBgActive"; + case ImGuiCol_TitleBgCollapsed: return "TitleBgCollapsed"; + case ImGuiCol_MenuBarBg: return "MenuBarBg"; + case ImGuiCol_ScrollbarBg: return "ScrollbarBg"; + case ImGuiCol_ScrollbarGrab: return "ScrollbarGrab"; + case ImGuiCol_ScrollbarGrabHovered: return "ScrollbarGrabHovered"; + case ImGuiCol_ScrollbarGrabActive: return "ScrollbarGrabActive"; + case ImGuiCol_CheckMark: return "CheckMark"; + case ImGuiCol_SliderGrab: return "SliderGrab"; + case ImGuiCol_SliderGrabActive: return "SliderGrabActive"; + case ImGuiCol_Button: return "Button"; + case ImGuiCol_ButtonHovered: return "ButtonHovered"; + case ImGuiCol_ButtonActive: return "ButtonActive"; + case ImGuiCol_Header: return "Header"; + case ImGuiCol_HeaderHovered: return "HeaderHovered"; + case ImGuiCol_HeaderActive: return "HeaderActive"; + case ImGuiCol_Separator: return "Separator"; + case ImGuiCol_SeparatorHovered: return "SeparatorHovered"; + case ImGuiCol_SeparatorActive: return "SeparatorActive"; + case ImGuiCol_ResizeGrip: return "ResizeGrip"; + case ImGuiCol_ResizeGripHovered: return "ResizeGripHovered"; + case ImGuiCol_ResizeGripActive: return "ResizeGripActive"; + case ImGuiCol_CloseButton: return "CloseButton"; + case ImGuiCol_CloseButtonHovered: return "CloseButtonHovered"; + case ImGuiCol_CloseButtonActive: return "CloseButtonActive"; + case ImGuiCol_PlotLines: return "PlotLines"; + case ImGuiCol_PlotLinesHovered: return "PlotLinesHovered"; + case ImGuiCol_PlotHistogram: return "PlotHistogram"; + case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered"; + case ImGuiCol_TextSelectedBg: return "TextSelectedBg"; + case ImGuiCol_ModalWindowDarkening: return "ModalWindowDarkening"; + case ImGuiCol_DragDropTarget: return "DragDropTarget"; + } + IM_ASSERT(0); + return "Unknown"; +} + +bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent) +{ + if (window->RootWindow == potential_parent) + return true; + while (window != NULL) + { + if (window == potential_parent) + return true; + window = window->ParentWindow; + } + return false; +} + +bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags) +{ + IM_ASSERT((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0); // Flags not supported by this function + ImGuiContext& g = *GImGui; + + if (flags & ImGuiHoveredFlags_AnyWindow) + { + if (g.HoveredWindow == NULL) + return false; + } + else + { + switch (flags & (ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows)) + { + case ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows: + if (g.HoveredRootWindow != g.CurrentWindow->RootWindow) + return false; + break; + case ImGuiHoveredFlags_RootWindow: + if (g.HoveredWindow != g.CurrentWindow->RootWindow) + return false; + break; + case ImGuiHoveredFlags_ChildWindows: + if (g.HoveredWindow == NULL || !IsWindowChildOf(g.HoveredWindow, g.CurrentWindow)) + return false; + break; + default: + if (g.HoveredWindow != g.CurrentWindow) + return false; + break; + } + } + + if (!IsWindowContentHoverable(g.HoveredRootWindow, flags)) + return false; + if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) + if (g.ActiveId != 0 && !g.ActiveIdAllowOverlap && g.ActiveId != g.HoveredWindow->MoveId) + return false; + return true; +} + +bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(g.CurrentWindow); // Not inside a Begin()/End() + + if (flags & ImGuiFocusedFlags_AnyWindow) + return g.NavWindow != NULL; + + switch (flags & (ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows)) + { + case ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows: + return g.NavWindow && g.NavWindow->RootWindow == g.CurrentWindow->RootWindow; + case ImGuiFocusedFlags_RootWindow: + return g.NavWindow == g.CurrentWindow->RootWindow; + case ImGuiFocusedFlags_ChildWindows: + return g.NavWindow && IsWindowChildOf(g.NavWindow, g.CurrentWindow); + default: + return g.NavWindow == g.CurrentWindow; + } +} + +float ImGui::GetWindowWidth() +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->Size.x; +} + +float ImGui::GetWindowHeight() +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->Size.y; +} + +ImVec2 ImGui::GetWindowPos() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + return window->Pos; +} + +static void SetWindowScrollY(ImGuiWindow* window, float new_scroll_y) +{ + window->DC.CursorMaxPos.y += window->Scroll.y; // SizeContents is generally computed based on CursorMaxPos which is affected by scroll position, so we need to apply our change to it. + window->Scroll.y = new_scroll_y; + window->DC.CursorMaxPos.y -= window->Scroll.y; +} + +static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond) +{ + // Test condition (NB: bit 0 is always true) and clear flags for next time + if (cond && (window->SetWindowPosAllowFlags & cond) == 0) + return; + window->SetWindowPosAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); + window->SetWindowPosVal = ImVec2(FLT_MAX, FLT_MAX); + + // set + const ImVec2 old_pos = window->Pos; + window->PosFloat = pos; + window->Pos = ImFloor(pos); + window->DC.CursorPos += (window->Pos - old_pos); // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor + window->DC.CursorMaxPos += (window->Pos - old_pos); // And more importantly we need to adjust this so size calculation doesn't get affected. +} + +void ImGui::SetWindowPos(const ImVec2& pos, ImGuiCond cond) +{ + ImGuiWindow* window = GetCurrentWindowRead(); + SetWindowPos(window, pos, cond); +} + +void ImGui::SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond) +{ + if (ImGuiWindow* window = FindWindowByName(name)) + SetWindowPos(window, pos, cond); +} + +ImVec2 ImGui::GetWindowSize() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->Size; +} + +static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond) +{ + // Test condition (NB: bit 0 is always true) and clear flags for next time + if (cond && (window->SetWindowSizeAllowFlags & cond) == 0) + return; + window->SetWindowSizeAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); + + // set + if (size.x > 0.0f) + { + window->AutoFitFramesX = 0; + window->SizeFull.x = size.x; + } + else + { + window->AutoFitFramesX = 2; + window->AutoFitOnlyGrows = false; + } + if (size.y > 0.0f) + { + window->AutoFitFramesY = 0; + window->SizeFull.y = size.y; + } + else + { + window->AutoFitFramesY = 2; + window->AutoFitOnlyGrows = false; + } +} + +void ImGui::SetWindowSize(const ImVec2& size, ImGuiCond cond) +{ + SetWindowSize(GImGui->CurrentWindow, size, cond); +} + +void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond) +{ + if (ImGuiWindow* window = FindWindowByName(name)) + SetWindowSize(window, size, cond); +} + +static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond) +{ + // Test condition (NB: bit 0 is always true) and clear flags for next time + if (cond && (window->SetWindowCollapsedAllowFlags & cond) == 0) + return; + window->SetWindowCollapsedAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); + + // set + window->Collapsed = collapsed; +} + +void ImGui::SetWindowCollapsed(bool collapsed, ImGuiCond cond) +{ + SetWindowCollapsed(GImGui->CurrentWindow, collapsed, cond); +} + +bool ImGui::IsWindowCollapsed() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->Collapsed; +} + +bool ImGui::IsWindowAppearing() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->Appearing; +} + +void ImGui::SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond) +{ + if (ImGuiWindow* window = FindWindowByName(name)) + SetWindowCollapsed(window, collapsed, cond); +} + +void ImGui::SetWindowFocus() +{ + FocusWindow(GImGui->CurrentWindow); +} + +void ImGui::SetWindowFocus(const char* name) +{ + if (name) + { + if (ImGuiWindow* window = FindWindowByName(name)) + FocusWindow(window); + } + else + { + FocusWindow(NULL); + } +} + +void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pivot) +{ + ImGuiContext& g = *GImGui; + g.NextWindowData.PosVal = pos; + g.NextWindowData.PosPivotVal = pivot; + g.NextWindowData.PosCond = cond ? cond : ImGuiCond_Always; +} + +void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond) +{ + ImGuiContext& g = *GImGui; + g.NextWindowData.SizeVal = size; + g.NextWindowData.SizeCond = cond ? cond : ImGuiCond_Always; +} + +void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback, void* custom_callback_user_data) +{ + ImGuiContext& g = *GImGui; + g.NextWindowData.SizeConstraintCond = ImGuiCond_Always; + g.NextWindowData.SizeConstraintRect = ImRect(size_min, size_max); + g.NextWindowData.SizeCallback = custom_callback; + g.NextWindowData.SizeCallbackUserData = custom_callback_user_data; +} + +void ImGui::SetNextWindowContentSize(const ImVec2& size) +{ + ImGuiContext& g = *GImGui; + g.NextWindowData.ContentSizeVal = size; // In Begin() we will add the size of window decorations (title bar, menu etc.) to that to form a SizeContents value. + g.NextWindowData.ContentSizeCond = ImGuiCond_Always; +} + +void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond) +{ + ImGuiContext& g = *GImGui; + g.NextWindowData.CollapsedVal = collapsed; + g.NextWindowData.CollapsedCond = cond ? cond : ImGuiCond_Always; +} + +void ImGui::SetNextWindowFocus() +{ + ImGuiContext& g = *GImGui; + g.NextWindowData.FocusCond = ImGuiCond_Always; +} + +// In window space (not screen space!) +ImVec2 ImGui::GetContentRegionMax() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + ImVec2 mx = window->ContentsRegionRect.Max; + if (window->DC.ColumnsSet) + mx.x = GetColumnOffset(window->DC.ColumnsSet->Current + 1) - window->WindowPadding.x; + return mx; +} + +ImVec2 ImGui::GetContentRegionAvail() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return GetContentRegionMax() - (window->DC.CursorPos - window->Pos); +} + +float ImGui::GetContentRegionAvailWidth() +{ + return GetContentRegionAvail().x; +} + +// In window space (not screen space!) +ImVec2 ImGui::GetWindowContentRegionMin() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->ContentsRegionRect.Min; +} + +ImVec2 ImGui::GetWindowContentRegionMax() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->ContentsRegionRect.Max; +} + +float ImGui::GetWindowContentRegionWidth() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->ContentsRegionRect.Max.x - window->ContentsRegionRect.Min.x; +} + +float ImGui::GetTextLineHeight() +{ + ImGuiContext& g = *GImGui; + return g.FontSize; +} + +float ImGui::GetTextLineHeightWithSpacing() +{ + ImGuiContext& g = *GImGui; + return g.FontSize + g.Style.ItemSpacing.y; +} + +float ImGui::GetFrameHeight() +{ + ImGuiContext& g = *GImGui; + return g.FontSize + g.Style.FramePadding.y * 2.0f; +} + +float ImGui::GetFrameHeightWithSpacing() +{ + ImGuiContext& g = *GImGui; + return g.FontSize + g.Style.FramePadding.y * 2.0f + g.Style.ItemSpacing.y; +} + +ImDrawList* ImGui::GetWindowDrawList() +{ + ImGuiWindow* window = GetCurrentWindow(); + return window->DrawList; +} + +ImFont* ImGui::GetFont() +{ + return GImGui->Font; +} + +float ImGui::GetFontSize() +{ + return GImGui->FontSize; +} + +ImVec2 ImGui::GetFontTexUvWhitePixel() +{ + return GImGui->DrawListSharedData.TexUvWhitePixel; +} + +void ImGui::SetWindowFontScale(float scale) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + window->FontWindowScale = scale; + g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize(); +} + +// User generally sees positions in window coordinates. Internally we store CursorPos in absolute screen coordinates because it is more convenient. +// Conversion happens as we pass the value to user, but it makes our naming convention confusing because GetCursorPos() == (DC.CursorPos - window.Pos). May want to rename 'DC.CursorPos'. +ImVec2 ImGui::GetCursorPos() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.CursorPos - window->Pos + window->Scroll; +} + +float ImGui::GetCursorPosX() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.CursorPos.x - window->Pos.x + window->Scroll.x; +} + +float ImGui::GetCursorPosY() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.CursorPos.y - window->Pos.y + window->Scroll.y; +} + +void ImGui::SetCursorPos(const ImVec2& local_pos) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.CursorPos = window->Pos - window->Scroll + local_pos; + window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos); +} + +void ImGui::SetCursorPosX(float x) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + x; + window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPos.x); +} + +void ImGui::SetCursorPosY(float y) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.CursorPos.y = window->Pos.y - window->Scroll.y + y; + window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y); +} + +ImVec2 ImGui::GetCursorStartPos() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.CursorStartPos - window->Pos; +} + +ImVec2 ImGui::GetCursorScreenPos() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.CursorPos; +} + +void ImGui::SetCursorScreenPos(const ImVec2& screen_pos) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.CursorPos = screen_pos; + window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos); +} + +float ImGui::GetScrollX() +{ + return GImGui->CurrentWindow->Scroll.x; +} + +float ImGui::GetScrollY() +{ + return GImGui->CurrentWindow->Scroll.y; +} + +float ImGui::GetScrollMaxX() +{ + return GetScrollMaxX(GImGui->CurrentWindow); +} + +float ImGui::GetScrollMaxY() +{ + return GetScrollMaxY(GImGui->CurrentWindow); +} + +void ImGui::SetScrollX(float scroll_x) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->ScrollTarget.x = scroll_x; + window->ScrollTargetCenterRatio.x = 0.0f; +} + +void ImGui::SetScrollY(float scroll_y) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->ScrollTarget.y = scroll_y + window->TitleBarHeight() + window->MenuBarHeight(); // title bar height canceled out when using ScrollTargetRelY + window->ScrollTargetCenterRatio.y = 0.0f; +} + +void ImGui::SetScrollFromPosY(float pos_y, float center_y_ratio) +{ + // We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size + ImGuiWindow* window = GetCurrentWindow(); + IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f); + window->ScrollTarget.y = (float)(int)(pos_y + window->Scroll.y); + window->ScrollTargetCenterRatio.y = center_y_ratio; + + // Minor hack to to make scrolling to top/bottom of window take account of WindowPadding, it looks more right to the user this way + if (center_y_ratio <= 0.0f && window->ScrollTarget.y <= window->WindowPadding.y) + window->ScrollTarget.y = 0.0f; + else if (center_y_ratio >= 1.0f && window->ScrollTarget.y >= window->SizeContents.y - window->WindowPadding.y + GImGui->Style.ItemSpacing.y) + window->ScrollTarget.y = window->SizeContents.y; +} + +// center_y_ratio: 0.0f top of last item, 0.5f vertical center of last item, 1.0f bottom of last item. +void ImGui::SetScrollHere(float center_y_ratio) +{ + ImGuiWindow* window = GetCurrentWindow(); + float target_y = window->DC.CursorPosPrevLine.y - window->Pos.y; // Top of last item, in window space + target_y += (window->DC.PrevLineHeight * center_y_ratio) + (GImGui->Style.ItemSpacing.y * (center_y_ratio - 0.5f) * 2.0f); // Precisely aim above, in the middle or below the last line. + SetScrollFromPosY(target_y, center_y_ratio); +} + +// FIXME-NAV: This function is a placeholder for the upcoming Navigation branch + Focusing features. +// In the current branch this function will only set the scrolling, in the navigation branch it will also set your navigation cursor. +// Prefer using "SetItemDefaultFocus()" over "if (IsWindowAppearing()) SetScrollHere()" when applicable. +void ImGui::SetItemDefaultFocus() +{ + if (IsWindowAppearing()) + SetScrollHere(); +} + +void ImGui::SetKeyboardFocusHere(int offset) +{ + IM_ASSERT(offset >= -1); // -1 is allowed but not below + ImGuiWindow* window = GetCurrentWindow(); + window->FocusIdxAllRequestNext = window->FocusIdxAllCounter + 1 + offset; + window->FocusIdxTabRequestNext = INT_MAX; +} + +void ImGui::SetStateStorage(ImGuiStorage* tree) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.StateStorage = tree ? tree : &window->StateStorage; +} + +ImGuiStorage* ImGui::GetStateStorage() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.StateStorage; +} + +void ImGui::TextV(const char* fmt, va_list args) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + const char* text_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); + TextUnformatted(g.TempBuffer, text_end); +} + +void ImGui::Text(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + TextV(fmt, args); + va_end(args); +} + +void ImGui::TextColoredV(const ImVec4& col, const char* fmt, va_list args) +{ + PushStyleColor(ImGuiCol_Text, col); + TextV(fmt, args); + PopStyleColor(); +} + +void ImGui::TextColored(const ImVec4& col, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + TextColoredV(col, fmt, args); + va_end(args); +} + +void ImGui::TextDisabledV(const char* fmt, va_list args) +{ + PushStyleColor(ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled]); + TextV(fmt, args); + PopStyleColor(); +} + +void ImGui::TextDisabled(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + TextDisabledV(fmt, args); + va_end(args); +} + +void ImGui::TextWrappedV(const char* fmt, va_list args) +{ + bool need_wrap = (GImGui->CurrentWindow->DC.TextWrapPos < 0.0f); // Keep existing wrap position is one ia already set + if (need_wrap) PushTextWrapPos(0.0f); + TextV(fmt, args); + if (need_wrap) PopTextWrapPos(); +} + +void ImGui::TextWrapped(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + TextWrappedV(fmt, args); + va_end(args); +} + +void ImGui::TextUnformatted(const char* text, const char* text_end) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + IM_ASSERT(text != NULL); + const char* text_begin = text; + if (text_end == NULL) + text_end = text + strlen(text); // FIXME-OPT + + const ImVec2 text_pos(window->DC.CursorPos.x, window->DC.CursorPos.y + window->DC.CurrentLineTextBaseOffset); + const float wrap_pos_x = window->DC.TextWrapPos; + const bool wrap_enabled = wrap_pos_x >= 0.0f; + if (text_end - text > 2000 && !wrap_enabled) + { + // Long text! + // Perform manual coarse clipping to optimize for long multi-line text + // From this point we will only compute the width of lines that are visible. Optimization only available when word-wrapping is disabled. + // We also don't vertically center the text within the line full height, which is unlikely to matter because we are likely the biggest and only item on the line. + const char* line = text; + const float line_height = GetTextLineHeight(); + const ImRect clip_rect = window->ClipRect; + ImVec2 text_size(0,0); + + if (text_pos.y <= clip_rect.Max.y) + { + ImVec2 pos = text_pos; + + // Lines to skip (can't skip when logging text) + if (!g.LogEnabled) + { + int lines_skippable = (int)((clip_rect.Min.y - text_pos.y) / line_height); + if (lines_skippable > 0) + { + int lines_skipped = 0; + while (line < text_end && lines_skipped < lines_skippable) + { + const char* line_end = strchr(line, '\n'); + if (!line_end) + line_end = text_end; + line = line_end + 1; + lines_skipped++; + } + pos.y += lines_skipped * line_height; + } + } + + // Lines to render + if (line < text_end) + { + ImRect line_rect(pos, pos + ImVec2(FLT_MAX, line_height)); + while (line < text_end) + { + const char* line_end = strchr(line, '\n'); + if (IsClippedEx(line_rect, 0, false)) + break; + + const ImVec2 line_size = CalcTextSize(line, line_end, false); + text_size.x = ImMax(text_size.x, line_size.x); + RenderText(pos, line, line_end, false); + if (!line_end) + line_end = text_end; + line = line_end + 1; + line_rect.Min.y += line_height; + line_rect.Max.y += line_height; + pos.y += line_height; + } + + // Count remaining lines + int lines_skipped = 0; + while (line < text_end) + { + const char* line_end = strchr(line, '\n'); + if (!line_end) + line_end = text_end; + line = line_end + 1; + lines_skipped++; + } + pos.y += lines_skipped * line_height; + } + + text_size.y += (pos - text_pos).y; + } + + ImRect bb(text_pos, text_pos + text_size); + ItemSize(bb); + ItemAdd(bb, 0); + } + else + { + const float wrap_width = wrap_enabled ? CalcWrapWidthForPos(window->DC.CursorPos, wrap_pos_x) : 0.0f; + const ImVec2 text_size = CalcTextSize(text_begin, text_end, false, wrap_width); + + // Account of baseline offset + ImRect bb(text_pos, text_pos + text_size); + ItemSize(text_size); + if (!ItemAdd(bb, 0)) + return; + + // Render (we don't hide text after ## in this end-user function) + RenderTextWrapped(bb.Min, text_begin, text_end, wrap_width); + } +} + +void ImGui::AlignTextToFramePadding() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + window->DC.CurrentLineHeight = ImMax(window->DC.CurrentLineHeight, g.FontSize + g.Style.FramePadding.y * 2); + window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.CurrentLineTextBaseOffset, g.Style.FramePadding.y); +} + +// Add a label+text combo aligned to other label+value widgets +void ImGui::LabelTextV(const char* label, const char* fmt, va_list args) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const float w = CalcItemWidth(); + + const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImRect value_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2)); + const ImRect total_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w + (label_size.x > 0.0f ? style.ItemInnerSpacing.x : 0.0f), style.FramePadding.y*2) + label_size); + ItemSize(total_bb, style.FramePadding.y); + if (!ItemAdd(total_bb, 0)) + return; + + // Render + const char* value_text_begin = &g.TempBuffer[0]; + const char* value_text_end = value_text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); + RenderTextClipped(value_bb.Min, value_bb.Max, value_text_begin, value_text_end, NULL, ImVec2(0.0f,0.5f)); + if (label_size.x > 0.0f) + RenderText(ImVec2(value_bb.Max.x + style.ItemInnerSpacing.x, value_bb.Min.y + style.FramePadding.y), label); +} + +void ImGui::LabelText(const char* label, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + LabelTextV(label, fmt, args); + va_end(args); +} + +bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + + if (flags & ImGuiButtonFlags_Disabled) + { + if (out_hovered) *out_hovered = false; + if (out_held) *out_held = false; + if (g.ActiveId == id) ClearActiveID(); + return false; + } + + // Default behavior requires click+release on same spot + if ((flags & (ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick)) == 0) + flags |= ImGuiButtonFlags_PressedOnClickRelease; + + ImGuiWindow* backup_hovered_window = g.HoveredWindow; + if ((flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredRootWindow == window) + g.HoveredWindow = window; + + bool pressed = false; + bool hovered = ItemHoverable(bb, id); + + // Special mode for Drag and Drop where holding button pressed for a long time while dragging another item triggers the button + if ((flags & ImGuiButtonFlags_PressedOnDragDropHold) && g.DragDropActive && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoHoldToOpenOthers)) + if (IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) + { + hovered = true; + SetHoveredID(id); + if (CalcTypematicPressedRepeatAmount(g.HoveredIdTimer + 0.0001f, g.HoveredIdTimer + 0.0001f - g.IO.DeltaTime, 0.01f, 0.70f)) // FIXME: Our formula for CalcTypematicPressedRepeatAmount() is fishy + { + pressed = true; + FocusWindow(window); + } + } + + if ((flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredRootWindow == window) + g.HoveredWindow = backup_hovered_window; + + // AllowOverlap mode (rarely used) requires previous frame HoveredId to be null or to match. This allows using patterns where a later submitted widget overlaps a previous one. + if (hovered && (flags & ImGuiButtonFlags_AllowItemOverlap) && (g.HoveredIdPreviousFrame != id && g.HoveredIdPreviousFrame != 0)) + hovered = false; + + if (hovered) + { + if (!(flags & ImGuiButtonFlags_NoKeyModifiers) || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt)) + { + // | CLICKING | HOLDING with ImGuiButtonFlags_Repeat + // PressedOnClickRelease | * | .. (NOT on release) <-- MOST COMMON! (*) only if both click/release were over bounds + // PressedOnClick | | .. + // PressedOnRelease | | .. (NOT on release) + // PressedOnDoubleClick | | .. + if ((flags & ImGuiButtonFlags_PressedOnClickRelease) && g.IO.MouseClicked[0]) + { + SetActiveID(id, window); // Hold on ID + FocusWindow(window); + } + if (((flags & ImGuiButtonFlags_PressedOnClick) && g.IO.MouseClicked[0]) || ((flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDoubleClicked[0])) + { + pressed = true; + if (flags & ImGuiButtonFlags_NoHoldingActiveID) + ClearActiveID(); + else + SetActiveID(id, window); // Hold on ID + FocusWindow(window); + } + if ((flags & ImGuiButtonFlags_PressedOnRelease) && g.IO.MouseReleased[0]) + { + if (!((flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay)) // Repeat mode trumps + pressed = true; + ClearActiveID(); + } + + // 'Repeat' mode acts when held regardless of _PressedOn flags (see table above). + // Relies on repeat logic of IsMouseClicked() but we may as well do it ourselves if we end up exposing finer RepeatDelay/RepeatRate settings. + //if ((flags & ImGuiButtonFlags_Repeat) && g.ActiveId == id && g.IO.MouseDownDuration[0] > 0.0f && IsMouseClicked(0, true)) + // pressed = true; + if (flags & ImGuiButtonFlags_Repeat && g.ActiveId == id && IsMouseClicked(0, true)) + pressed = true; + } + } + + bool held = false; + if (g.ActiveId == id) + { + if (g.ActiveIdIsJustActivated) + g.ActiveIdClickOffset = g.IO.MousePos - bb.Min; + if (g.IO.MouseDown[0]) + { + held = true; + } + else + { + if (hovered && (flags & ImGuiButtonFlags_PressedOnClickRelease)) + if (!((flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay)) // Repeat mode trumps + if (!g.DragDropActive) + pressed = true; + ClearActiveID(); + } + } + + if (out_hovered) *out_hovered = hovered; + if (out_held) *out_held = held; + + return pressed; +} + +bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + const ImVec2 label_size = CalcTextSize(label, NULL, true); + + ImVec2 pos = window->DC.CursorPos; + if ((flags & ImGuiButtonFlags_AlignTextBaseLine) && style.FramePadding.y < window->DC.CurrentLineTextBaseOffset) // Try to vertically align buttons that are smaller/have no padding so that text baseline matches (bit hacky, since it shouldn't be a flag) + pos.y += window->DC.CurrentLineTextBaseOffset - style.FramePadding.y; + ImVec2 size = CalcItemSize(size_arg, label_size.x + style.FramePadding.x * 2.0f, label_size.y + style.FramePadding.y * 2.0f); + + size.y += 4.f; + + const ImRect bb(pos, pos + size); + ItemSize(bb, style.FramePadding.y); + if (!ItemAdd(bb, id)) + return false; + + if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat) + flags |= ImGuiButtonFlags_Repeat; + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); + + + + // Render + ImU32 col = GetColorU32((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); + + if (flags & ImGuiItemFlags_TabButton) + col = GetColorU32(ImGuiCol_ButtonActive); + + RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding); + RenderTextClipped(bb.Min + style.FramePadding, bb.Max - style.FramePadding, label, NULL, &label_size, style.ButtonTextAlign, &bb); + + // Automatically close popups + //if (pressed && !(flags & ImGuiButtonFlags_DontClosePopups) && (window->Flags & ImGuiWindowFlags_Popup)) + // CloseCurrentPopup(); + + return pressed; +} + +bool ImGui::Button(const char* label, const ImVec2& size_arg, bool selected) +{ + return ButtonEx(label, size_arg, (selected ? ImGuiItemFlags_TabButton : 0)); +} + +// Small buttons fits within text without additional vertical spacing. +bool ImGui::SmallButton(const char* label) +{ + ImGuiContext& g = *GImGui; + float backup_padding_y = g.Style.FramePadding.y; + g.Style.FramePadding.y = 0.0f; + bool pressed = ButtonEx(label, ImVec2(0,0), ImGuiButtonFlags_AlignTextBaseLine); + g.Style.FramePadding.y = backup_padding_y; + return pressed; +} + +// Tip: use ImGui::PushID()/PopID() to push indices or pointers in the ID stack. +// Then you can keep 'str_id' empty or the same for all your buttons (instead of creating a string based on a non-string id) +bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + const ImGuiID id = window->GetID(str_id); + ImVec2 size = CalcItemSize(size_arg, 0.0f, 0.0f); + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); + ItemSize(bb); + if (!ItemAdd(bb, id)) + return false; + + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held); + + return pressed; +} + +// Upper-right button to close a window. +bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos, float radius) +{ + ImGuiWindow* window = GetCurrentWindow(); + + const ImRect bb(pos - ImVec2(radius,radius), pos + ImVec2(radius,radius)); + + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held); + + // Render + //const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_CloseButtonActive : hovered ? ImGuiCol_CloseButtonHovered : ImGuiCol_CloseButton); + const ImVec2 center = bb.GetCenter(); + //window->DrawList->AddCircleFilled(center, ImMax(2.0f, radius), col, 12); + //window->DrawList->AddRectFilled(bb.Min, bb.Max, col);*/ + + const float cross_extent = (radius * 0.7071f) - 1.0f; + //if (hovered) + //{ + window->DrawList->AddLine(center + ImVec2(+cross_extent,+cross_extent), center + ImVec2(-cross_extent,-cross_extent), GetColorU32(ImGuiCol_Text)); + window->DrawList->AddLine(center + ImVec2(+cross_extent,-cross_extent), center + ImVec2(-cross_extent,+cross_extent), GetColorU32(ImGuiCol_Text)); + //} + + return pressed; +} + +// [Internal] +bool ImGui::ArrowButton(ImGuiID id, ImGuiDir dir, ImVec2 padding, ImGuiButtonFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->SkipItems) + return false; + + const ImGuiStyle& style = g.Style; + + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize + padding.x * 2.0f, g.FontSize + padding.y * 2.0f)); + ItemSize(bb, style.FramePadding.y); + if (!ItemAdd(bb, id)) + return false; + + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); + + const ImU32 col = GetColorU32((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); +#ifdef IMGUI_HAS_NAV + RenderNavHighlight(bb, id); +#endif + RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding); + RenderTriangle(bb.Min + padding, dir, 1.0f); + + return pressed; +} + +void ImGui::Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); + if (border_col.w > 0.0f) + bb.Max += ImVec2(2,2); + ItemSize(bb); + if (!ItemAdd(bb, 0)) + return; + + if (border_col.w > 0.0f) + { + window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(border_col), 0.0f); + window->DrawList->AddImage(user_texture_id, bb.Min+ImVec2(1,1), bb.Max-ImVec2(1,1), uv0, uv1, GetColorU32(tint_col)); + } + else + { + window->DrawList->AddImage(user_texture_id, bb.Min, bb.Max, uv0, uv1, GetColorU32(tint_col)); + } +} + +// frame_padding < 0: uses FramePadding from style (default) +// frame_padding = 0: no framing +// frame_padding > 0: set framing size +// The color used are the button colors. +bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + // Default to using texture ID as ID. User can still push string/integer prefixes. + // We could hash the size/uv to create a unique ID but that would prevent the user from animating UV. + PushID((void *)user_texture_id); + const ImGuiID id = window->GetID("#image"); + PopID(); + + const ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : style.FramePadding; + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding*2); + const ImRect image_bb(window->DC.CursorPos + padding, window->DC.CursorPos + padding + size); + ItemSize(bb); + if (!ItemAdd(bb, id)) + return false; + + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held); + + // Render + const ImU32 col = GetColorU32((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); + RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, style.FrameRounding)); + if (bg_col.w > 0.0f) + window->DrawList->AddRectFilled(image_bb.Min, image_bb.Max, GetColorU32(bg_col)); + window->DrawList->AddImage(user_texture_id, image_bb.Min, image_bb.Max, uv0, uv1, GetColorU32(tint_col)); + + return pressed; +} + +// Start logging ImGui output to TTY +void ImGui::LogToTTY(int max_depth) +{ + ImGuiContext& g = *GImGui; + if (g.LogEnabled) + return; + ImGuiWindow* window = g.CurrentWindow; + + g.LogEnabled = true; + g.LogFile = stdout; + g.LogStartDepth = window->DC.TreeDepth; + if (max_depth >= 0) + g.LogAutoExpandMaxDepth = max_depth; +} + +// Start logging ImGui output to given file +void ImGui::LogToFile(int max_depth, const char* filename) +{ + ImGuiContext& g = *GImGui; + if (g.LogEnabled) + return; + ImGuiWindow* window = g.CurrentWindow; + + if (!filename) + { + filename = g.IO.LogFilename; + if (!filename) + return; + } + + g.LogFile = ImFileOpen(filename, "ab"); + if (!g.LogFile) + { + IM_ASSERT(g.LogFile != NULL); // Consider this an error + return; + } + g.LogEnabled = true; + g.LogStartDepth = window->DC.TreeDepth; + if (max_depth >= 0) + g.LogAutoExpandMaxDepth = max_depth; +} + +// Start logging ImGui output to clipboard +void ImGui::LogToClipboard(int max_depth) +{ + ImGuiContext& g = *GImGui; + if (g.LogEnabled) + return; + ImGuiWindow* window = g.CurrentWindow; + + g.LogEnabled = true; + g.LogFile = NULL; + g.LogStartDepth = window->DC.TreeDepth; + if (max_depth >= 0) + g.LogAutoExpandMaxDepth = max_depth; +} + +void ImGui::LogFinish() +{ + ImGuiContext& g = *GImGui; + if (!g.LogEnabled) + return; + + LogText(IM_NEWLINE); + g.LogEnabled = false; + if (g.LogFile != NULL) + { + if (g.LogFile == stdout) + fflush(g.LogFile); + else + fclose(g.LogFile); + g.LogFile = NULL; + } + if (g.LogClipboard->size() > 1) + { + SetClipboardText(g.LogClipboard->begin()); + g.LogClipboard->clear(); + } +} + +// Helper to display logging buttons +void ImGui::LogButtons() +{ + ImGuiContext& g = *GImGui; + + PushID("LogButtons"); + const bool log_to_tty = Button("Log To TTY"); SameLine(); + const bool log_to_file = Button("Log To File"); SameLine(); + const bool log_to_clipboard = Button("Log To Clipboard"); SameLine(); + PushItemWidth(80.0f); + PushAllowKeyboardFocus(false); + SliderInt("Depth", &g.LogAutoExpandMaxDepth, 0, 9, NULL); + PopAllowKeyboardFocus(); + PopItemWidth(); + PopID(); + + // Start logging at the end of the function so that the buttons don't appear in the log + if (log_to_tty) + LogToTTY(g.LogAutoExpandMaxDepth); + if (log_to_file) + LogToFile(g.LogAutoExpandMaxDepth, g.IO.LogFilename); + if (log_to_clipboard) + LogToClipboard(g.LogAutoExpandMaxDepth); +} + +bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags) +{ + if (flags & ImGuiTreeNodeFlags_Leaf) + return true; + + // We only write to the tree storage if the user clicks (or explicitely use SetNextTreeNode*** functions) + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiStorage* storage = window->DC.StateStorage; + + bool is_open; + if (g.NextTreeNodeOpenCond != 0) + { + if (g.NextTreeNodeOpenCond & ImGuiCond_Always) + { + is_open = g.NextTreeNodeOpenVal; + storage->SetInt(id, is_open); + } + else + { + // We treat ImGuiCond_Once and ImGuiCond_FirstUseEver the same because tree node state are not saved persistently. + const int stored_value = storage->GetInt(id, -1); + if (stored_value == -1) + { + is_open = g.NextTreeNodeOpenVal; + storage->SetInt(id, is_open); + } + else + { + is_open = stored_value != 0; + } + } + g.NextTreeNodeOpenCond = 0; + } + else + { + is_open = storage->GetInt(id, (flags & ImGuiTreeNodeFlags_DefaultOpen) ? 1 : 0) != 0; + } + + // When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior). + // NB- If we are above max depth we still allow manually opened nodes to be logged. + if (g.LogEnabled && !(flags & ImGuiTreeNodeFlags_NoAutoOpenOnLog) && window->DC.TreeDepth < g.LogAutoExpandMaxDepth) + is_open = true; + + return is_open; +} + +bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0; + const ImVec2 padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding)) ? style.FramePadding : ImVec2(style.FramePadding.x, 0.0f); + + if (!label_end) + label_end = FindRenderedTextEnd(label); + const ImVec2 label_size = CalcTextSize(label, label_end, false); + + // We vertically grow up to current line height up the typical widget height. + const float text_base_offset_y = ImMax(padding.y, window->DC.CurrentLineTextBaseOffset); // Latch before ItemSize changes it + const float frame_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + style.FramePadding.y*2), label_size.y + padding.y*2); + ImRect bb = ImRect(window->DC.CursorPos, ImVec2(window->Pos.x + GetContentRegionMax().x, window->DC.CursorPos.y + frame_height)); + if (display_frame) + { + // Framed header expand a little outside the default padding + bb.Min.x -= (float)(int)(window->WindowPadding.x*0.5f) - 1; + bb.Max.x += (float)(int)(window->WindowPadding.x*0.5f) - 1; + } + + const float text_offset_x = (g.FontSize + (display_frame ? padding.x*3 : padding.x*2)); // Collapser arrow width + Spacing + const float text_width = g.FontSize + (label_size.x > 0.0f ? label_size.x + padding.x*2 : 0.0f); // Include collapser + ItemSize(ImVec2(text_width, frame_height), text_base_offset_y); + + // For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing + // (Ideally we'd want to add a flag for the user to specify if we want the hit test to be done up to the right side of the content or not) + const ImRect interact_bb = display_frame ? bb : ImRect(bb.Min.x, bb.Min.y, bb.Min.x + text_width + style.ItemSpacing.x*2, bb.Max.y); + bool is_open = TreeNodeBehaviorIsOpen(id, flags); + if (!ItemAdd(interact_bb, id)) + { + if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) + TreePushRawID(id); + return is_open; + } + + // Flags that affects opening behavior: + // - 0(default) ..................... single-click anywhere to open + // - OpenOnDoubleClick .............. double-click anywhere to open + // - OpenOnArrow .................... single-click on arrow to open + // - OpenOnDoubleClick|OpenOnArrow .. single-click on arrow or double-click anywhere to open + ImGuiButtonFlags button_flags = ImGuiButtonFlags_NoKeyModifiers | ((flags & ImGuiTreeNodeFlags_AllowItemOverlap) ? ImGuiButtonFlags_AllowItemOverlap : 0); + if (!(flags & ImGuiTreeNodeFlags_Leaf)) + button_flags |= ImGuiButtonFlags_PressedOnDragDropHold; + if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) + button_flags |= ImGuiButtonFlags_PressedOnDoubleClick | ((flags & ImGuiTreeNodeFlags_OpenOnArrow) ? ImGuiButtonFlags_PressedOnClickRelease : 0); + + bool hovered, held, pressed = ButtonBehavior(interact_bb, id, &hovered, &held, button_flags); + if (pressed && !(flags & ImGuiTreeNodeFlags_Leaf)) + { + bool toggled = !(flags & (ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)); + if (flags & ImGuiTreeNodeFlags_OpenOnArrow) + toggled |= IsMouseHoveringRect(interact_bb.Min, ImVec2(interact_bb.Min.x + text_offset_x, interact_bb.Max.y)); + if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) + toggled |= g.IO.MouseDoubleClicked[0]; + if (g.DragDropActive && is_open) // When using Drag and Drop "hold to open" we keep the node highlighted after opening, but never close it again. + toggled = false; + if (toggled) + { + is_open = !is_open; + window->DC.StateStorage->SetInt(id, is_open); + } + } + if (flags & ImGuiTreeNodeFlags_AllowItemOverlap) + SetItemAllowOverlap(); + + // Render + const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); + const ImVec2 text_pos = bb.Min + ImVec2(text_offset_x, text_base_offset_y); + if (display_frame) + { + // Framed type + RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding); + RenderTriangle(bb.Min + ImVec2(padding.x, text_base_offset_y), is_open ? ImGuiDir_Down : ImGuiDir_Right, 1.0f); + if (g.LogEnabled) + { + // NB: '##' is normally used to hide text (as a library-wide feature), so we need to specify the text range to make sure the ## aren't stripped out here. + const char log_prefix[] = "\n##"; + const char log_suffix[] = "##"; + LogRenderedText(&text_pos, log_prefix, log_prefix+3); + RenderTextClipped(text_pos, bb.Max, label, label_end, &label_size); + LogRenderedText(&text_pos, log_suffix+1, log_suffix+3); + } + else + { + RenderTextClipped(text_pos, bb.Max, label, label_end, &label_size); + } + } + else + { + // Unframed typed for tree nodes + if (hovered || (flags & ImGuiTreeNodeFlags_Selected)) + RenderFrame(bb.Min, bb.Max, col, false); + + if (flags & ImGuiTreeNodeFlags_Bullet) + RenderBullet(bb.Min + ImVec2(text_offset_x * 0.5f, g.FontSize*0.50f + text_base_offset_y)); + else if (!(flags & ImGuiTreeNodeFlags_Leaf)) + RenderTriangle(bb.Min + ImVec2(padding.x, g.FontSize*0.15f + text_base_offset_y), is_open ? ImGuiDir_Down : ImGuiDir_Right, 0.70f); + if (g.LogEnabled) + LogRenderedText(&text_pos, ">"); + RenderText(text_pos, label, label_end, false); + } + + if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) + TreePushRawID(id); + return is_open; +} + +// CollapsingHeader returns true when opened but do not indent nor push into the ID stack (because of the ImGuiTreeNodeFlags_NoTreePushOnOpen flag). +// This is basically the same as calling TreeNodeEx(label, ImGuiTreeNodeFlags_CollapsingHeader | ImGuiTreeNodeFlags_NoTreePushOnOpen). You can remove the _NoTreePushOnOpen flag if you want behavior closer to normal TreeNode(). +bool ImGui::CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + return TreeNodeBehavior(window->GetID(label), flags | ImGuiTreeNodeFlags_CollapsingHeader | ImGuiTreeNodeFlags_NoTreePushOnOpen, label); +} + +bool ImGui::CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + if (p_open && !*p_open) + return false; + + ImGuiID id = window->GetID(label); + bool is_open = TreeNodeBehavior(id, flags | ImGuiTreeNodeFlags_CollapsingHeader | ImGuiTreeNodeFlags_NoTreePushOnOpen | (p_open ? ImGuiTreeNodeFlags_AllowItemOverlap : 0), label); + if (p_open) + { + // Create a small overlapping close button // FIXME: We can evolve this into user accessible helpers to add extra buttons on title bars, headers, etc. + ImGuiContext& g = *GImGui; + float button_sz = g.FontSize * 0.5f; + ImGuiItemHoveredDataBackup last_item_backup; + if (CloseButton(window->GetID((void*)(intptr_t)(id+1)), ImVec2(ImMin(window->DC.LastItemRect.Max.x, window->ClipRect.Max.x) - g.Style.FramePadding.x - button_sz, window->DC.LastItemRect.Min.y + g.Style.FramePadding.y + button_sz), button_sz)) + *p_open = false; + last_item_backup.Restore(); + } + + return is_open; +} + +bool ImGui::TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + return TreeNodeBehavior(window->GetID(label), flags, label, NULL); +} + +bool ImGui::TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); + return TreeNodeBehavior(window->GetID(str_id), flags, g.TempBuffer, label_end); +} + +bool ImGui::TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); + return TreeNodeBehavior(window->GetID(ptr_id), flags, g.TempBuffer, label_end); +} + +bool ImGui::TreeNodeV(const char* str_id, const char* fmt, va_list args) +{ + return TreeNodeExV(str_id, 0, fmt, args); +} + +bool ImGui::TreeNodeV(const void* ptr_id, const char* fmt, va_list args) +{ + return TreeNodeExV(ptr_id, 0, fmt, args); +} + +bool ImGui::TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + bool is_open = TreeNodeExV(str_id, flags, fmt, args); + va_end(args); + return is_open; +} + +bool ImGui::TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + bool is_open = TreeNodeExV(ptr_id, flags, fmt, args); + va_end(args); + return is_open; +} + +bool ImGui::TreeNode(const char* str_id, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + bool is_open = TreeNodeExV(str_id, 0, fmt, args); + va_end(args); + return is_open; +} + +bool ImGui::TreeNode(const void* ptr_id, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + bool is_open = TreeNodeExV(ptr_id, 0, fmt, args); + va_end(args); + return is_open; +} + +bool ImGui::TreeNode(const char* label) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + return TreeNodeBehavior(window->GetID(label), 0, label, NULL); +} + +void ImGui::TreeAdvanceToLabelPos() +{ + ImGuiContext& g = *GImGui; + g.CurrentWindow->DC.CursorPos.x += GetTreeNodeToLabelSpacing(); +} + +// Horizontal distance preceding label when using TreeNode() or Bullet() +float ImGui::GetTreeNodeToLabelSpacing() +{ + ImGuiContext& g = *GImGui; + return g.FontSize + (g.Style.FramePadding.x * 2.0f); +} + +void ImGui::SetNextTreeNodeOpen(bool is_open, ImGuiCond cond) +{ + ImGuiContext& g = *GImGui; + if (g.CurrentWindow->SkipItems) + return; + g.NextTreeNodeOpenVal = is_open; + g.NextTreeNodeOpenCond = cond ? cond : ImGuiCond_Always; +} + +void ImGui::PushID(const char* str_id) +{ + ImGuiWindow* window = GetCurrentWindowRead(); + window->IDStack.push_back(window->GetID(str_id)); +} + +void ImGui::PushID(const char* str_id_begin, const char* str_id_end) +{ + ImGuiWindow* window = GetCurrentWindowRead(); + window->IDStack.push_back(window->GetID(str_id_begin, str_id_end)); +} + +void ImGui::PushID(const void* ptr_id) +{ + ImGuiWindow* window = GetCurrentWindowRead(); + window->IDStack.push_back(window->GetID(ptr_id)); +} + +void ImGui::PushID(int int_id) +{ + const void* ptr_id = (void*)(intptr_t)int_id; + ImGuiWindow* window = GetCurrentWindowRead(); + window->IDStack.push_back(window->GetID(ptr_id)); +} + +void ImGui::PopID() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + window->IDStack.pop_back(); +} + +ImGuiID ImGui::GetID(const char* str_id) +{ + return GImGui->CurrentWindow->GetID(str_id); +} + +ImGuiID ImGui::GetID(const char* str_id_begin, const char* str_id_end) +{ + return GImGui->CurrentWindow->GetID(str_id_begin, str_id_end); +} + +ImGuiID ImGui::GetID(const void* ptr_id) +{ + return GImGui->CurrentWindow->GetID(ptr_id); +} + +void ImGui::Bullet() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const float line_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + g.Style.FramePadding.y*2), g.FontSize); + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize, line_height)); + ItemSize(bb); + if (!ItemAdd(bb, 0)) + { + SameLine(0, style.FramePadding.x*2); + return; + } + + // Render and stay on same line + RenderBullet(bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, line_height*0.5f)); + SameLine(0, style.FramePadding.x*2); +} + +// Text with a little bullet aligned to the typical tree node. +void ImGui::BulletTextV(const char* fmt, va_list args) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + const char* text_begin = g.TempBuffer; + const char* text_end = text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); + const ImVec2 label_size = CalcTextSize(text_begin, text_end, false); + const float text_base_offset_y = ImMax(0.0f, window->DC.CurrentLineTextBaseOffset); // Latch before ItemSize changes it + const float line_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + g.Style.FramePadding.y*2), g.FontSize); + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize + (label_size.x > 0.0f ? (label_size.x + style.FramePadding.x*2) : 0.0f), ImMax(line_height, label_size.y))); // Empty text doesn't add padding + ItemSize(bb); + if (!ItemAdd(bb, 0)) + return; + + // Render + RenderBullet(bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, line_height*0.5f)); + RenderText(bb.Min+ImVec2(g.FontSize + style.FramePadding.x*2, text_base_offset_y), text_begin, text_end, false); +} + +void ImGui::BulletText(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + BulletTextV(fmt, args); + va_end(args); +} + +static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, const char* display_format, char* buf, int buf_size) +{ + if (data_type == ImGuiDataType_Int) + ImFormatString(buf, buf_size, display_format, *(int*)data_ptr); + else if (data_type == ImGuiDataType_Float) + ImFormatString(buf, buf_size, display_format, *(float*)data_ptr); +} + +static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, int decimal_precision, char* buf, int buf_size) +{ + if (data_type == ImGuiDataType_Int) + { + if (decimal_precision < 0) + ImFormatString(buf, buf_size, "%d", *(int*)data_ptr); + else + ImFormatString(buf, buf_size, "%.*d", decimal_precision, *(int*)data_ptr); + } + else if (data_type == ImGuiDataType_Float) + { + if (decimal_precision < 0) + ImFormatString(buf, buf_size, "%f", *(float*)data_ptr); // Ideally we'd have a minimum decimal precision of 1 to visually denote that it is a float, while hiding non-significant digits? + else + ImFormatString(buf, buf_size, "%.*f", decimal_precision, *(float*)data_ptr); + } +} + +static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* value1, const void* value2)// Store into value1 +{ + if (data_type == ImGuiDataType_Int) + { + if (op == '+') + *(int*)value1 = *(int*)value1 + *(const int*)value2; + else if (op == '-') + *(int*)value1 = *(int*)value1 - *(const int*)value2; + } + else if (data_type == ImGuiDataType_Float) + { + if (op == '+') + *(float*)value1 = *(float*)value1 + *(const float*)value2; + else if (op == '-') + *(float*)value1 = *(float*)value1 - *(const float*)value2; + } +} + +// User can input math operators (e.g. +100) to edit a numerical values. +static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format) +{ + while (ImCharIsSpace(*buf)) + buf++; + + // We don't support '-' op because it would conflict with inputing negative value. + // Instead you can use +-100 to subtract from an existing value + char op = buf[0]; + if (op == '+' || op == '*' || op == '/') + { + buf++; + while (ImCharIsSpace(*buf)) + buf++; + } + else + { + op = 0; + } + if (!buf[0]) + return false; + + if (data_type == ImGuiDataType_Int) + { + if (!scalar_format) + scalar_format = "%d"; + int* v = (int*)data_ptr; + const int old_v = *v; + int arg0i = *v; + if (op && sscanf(initial_value_buf, scalar_format, &arg0i) < 1) + return false; + + // Store operand in a float so we can use fractional value for multipliers (*1.1), but constant always parsed as integer so we can fit big integers (e.g. 2000000003) past float precision + float arg1f = 0.0f; + if (op == '+') { if (sscanf(buf, "%f", &arg1f) == 1) *v = (int)(arg0i + arg1f); } // Add (use "+-" to subtract) + else if (op == '*') { if (sscanf(buf, "%f", &arg1f) == 1) *v = (int)(arg0i * arg1f); } // Multiply + else if (op == '/') { if (sscanf(buf, "%f", &arg1f) == 1 && arg1f != 0.0f) *v = (int)(arg0i / arg1f); }// Divide + else { if (sscanf(buf, scalar_format, &arg0i) == 1) *v = arg0i; } // Assign constant (read as integer so big values are not lossy) + return (old_v != *v); + } + else if (data_type == ImGuiDataType_Float) + { + // For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in + scalar_format = "%f"; + float* v = (float*)data_ptr; + const float old_v = *v; + float arg0f = *v; + if (op && sscanf(initial_value_buf, scalar_format, &arg0f) < 1) + return false; + + float arg1f = 0.0f; + if (sscanf(buf, scalar_format, &arg1f) < 1) + return false; + if (op == '+') { *v = arg0f + arg1f; } // Add (use "+-" to subtract) + else if (op == '*') { *v = arg0f * arg1f; } // Multiply + else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide + else { *v = arg1f; } // Assign constant + return (old_v != *v); + } + + return false; +} + +// Create text input in place of a slider (when CTRL+Clicking on slider) +// FIXME: Logic is messy and confusing. +bool ImGui::InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label, ImGuiDataType data_type, void* data_ptr, ImGuiID id, int decimal_precision) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + + // Our replacement widget will override the focus ID (registered previously to allow for a TAB focus to happen) + // On the first frame, g.ScalarAsInputTextId == 0, then on subsequent frames it becomes == id + SetActiveID(g.ScalarAsInputTextId, window); + SetHoveredID(0); + FocusableItemUnregister(window); + + char buf[32]; + DataTypeFormatString(data_type, data_ptr, decimal_precision, buf, IM_ARRAYSIZE(buf)); + bool text_value_changed = InputTextEx(label, buf, IM_ARRAYSIZE(buf), aabb.GetSize(), ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_AutoSelectAll); + if (g.ScalarAsInputTextId == 0) // First frame we started displaying the InputText widget + { + IM_ASSERT(g.ActiveId == id); // InputText ID expected to match the Slider ID (else we'd need to store them both, which is also possible) + g.ScalarAsInputTextId = g.ActiveId; + SetHoveredID(id); + } + if (text_value_changed) + return DataTypeApplyOpFromText(buf, GImGui->InputTextState.InitialText.begin(), data_type, data_ptr, NULL); + return false; +} + +// Parse display precision back from the display format string +int ImGui::ParseFormatPrecision(const char* fmt, int default_precision) +{ + int precision = default_precision; + while ((fmt = strchr(fmt, '%')) != NULL) + { + fmt++; + if (fmt[0] == '%') { fmt++; continue; } // Ignore "%%" + while (*fmt >= '0' && *fmt <= '9') + fmt++; + if (*fmt == '.') + { + fmt = ImAtoi(fmt + 1, &precision); + if (precision < 0 || precision > 10) + precision = default_precision; + } + if (*fmt == 'e' || *fmt == 'E') // Maximum precision with scientific notation + precision = -1; + break; + } + return precision; +} + +static float GetMinimumStepAtDecimalPrecision(int decimal_precision) +{ + static const float min_steps[10] = { 1.0f, 0.1f, 0.01f, 0.001f, 0.0001f, 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, 0.000000001f }; + return (decimal_precision >= 0 && decimal_precision < 10) ? min_steps[decimal_precision] : powf(10.0f, (float)-decimal_precision); +} + +float ImGui::RoundScalar(float value, int decimal_precision) +{ + // Round past decimal precision + // So when our value is 1.99999 with a precision of 0.001 we'll end up rounding to 2.0 + // FIXME: Investigate better rounding methods + if (decimal_precision < 0) + return value; + const float min_step = GetMinimumStepAtDecimalPrecision(decimal_precision); + bool negative = value < 0.0f; + value = fabsf(value); + float remainder = fmodf(value, min_step); + if (remainder <= min_step*0.5f) + value -= remainder; + else + value += (min_step - remainder); + return negative ? -value : value; +} + +static inline float SliderBehaviorCalcRatioFromValue(float v, float v_min, float v_max, float power, float linear_zero_pos) +{ + if (v_min == v_max) + return 0.0f; + + const bool is_non_linear = (power < 1.0f-0.00001f) || (power > 1.0f+0.00001f); + const float v_clamped = (v_min < v_max) ? ImClamp(v, v_min, v_max) : ImClamp(v, v_max, v_min); + if (is_non_linear) + { + if (v_clamped < 0.0f) + { + const float f = 1.0f - (v_clamped - v_min) / (ImMin(0.0f,v_max) - v_min); + return (1.0f - powf(f, 1.0f/power)) * linear_zero_pos; + } + else + { + const float f = (v_clamped - ImMax(0.0f,v_min)) / (v_max - ImMax(0.0f,v_min)); + return linear_zero_pos + powf(f, 1.0f/power) * (1.0f - linear_zero_pos); + } + } + + // Linear slider + return (v_clamped - v_min) / (v_max - v_min); +} + +bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_min, float v_max, float power, int decimal_precision, ImGuiSliderFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + const ImGuiStyle& style = g.Style; + + // Draw frame + RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); + + const bool is_non_linear = (power < 1.0f-0.00001f) || (power > 1.0f+0.00001f); + const bool is_horizontal = (flags & ImGuiSliderFlags_Vertical) == 0; + + const float grab_padding = 0.f/*2.0f*/; + const float slider_sz = is_horizontal ? (frame_bb.GetWidth() - grab_padding * 2.0f) : (frame_bb.GetHeight() - grab_padding * 2.0f); + float grab_sz = 0.f; + //if (decimal_precision != 0) + // grab_sz = ImMin(style.GrabMinSize, slider_sz); + //else + // grab_sz = ImMin(ImMax(1.0f * (slider_sz / ((v_min < v_max ? v_max - v_min : v_min - v_max) + 1.0f)), style.GrabMinSize), slider_sz); // Integer sliders, if possible have the grab size represent 1 unit + const float slider_usable_sz = slider_sz - grab_sz; + const float slider_usable_pos_min = (is_horizontal ? frame_bb.Min.x : frame_bb.Min.y) + grab_padding + grab_sz * 0.5f; + const float slider_usable_pos_max = (is_horizontal ? frame_bb.Max.x : frame_bb.Max.y) - grab_padding - grab_sz * 0.5f; + + // For logarithmic sliders that cross over sign boundary we want the exponential increase to be symmetric around 0.0f + float linear_zero_pos = 0.0f; // 0.0->1.0f + + if (v_min * v_max < 0.0f) + { + // Different sign + const float linear_dist_min_to_0 = powf(fabsf(0.0f - v_min), 1.0f/power); + const float linear_dist_max_to_0 = powf(fabsf(v_max - 0.0f), 1.0f/power); + linear_zero_pos = linear_dist_min_to_0 / (linear_dist_min_to_0+linear_dist_max_to_0); + } + else + { + // Same sign + linear_zero_pos = v_min < 0.0f ? 1.0f : 0.0f; + } + + // Process clicking on the slider + bool value_changed = false; + if (g.ActiveId == id && ImGui::is_input_allowed) + { + bool set_new_value = false; + float clicked_t = 0.0f; + if (g.IO.MouseDown[0]) + { + const float mouse_abs_pos = is_horizontal ? g.IO.MousePos.x : g.IO.MousePos.y; + clicked_t = (slider_usable_sz > 0.0f) ? ImClamp((mouse_abs_pos - slider_usable_pos_min) / slider_usable_sz, 0.0f, 1.0f) : 0.0f; + if (!is_horizontal) + clicked_t = 1.0f - clicked_t; + set_new_value = true; + } + else + { + ClearActiveID(); + } + + if (set_new_value) + { + float new_value; + if (is_non_linear) + { + // Account for logarithmic scale on both sides of the zero + if (clicked_t < linear_zero_pos) + { + // Negative: rescale to the negative range before powering + float a = 1.0f - (clicked_t / linear_zero_pos); + a = powf(a, power); + new_value = ImLerp(ImMin(v_max,0.0f), v_min, a); + } + else + { + // Positive: rescale to the positive range before powering + float a; + if (fabsf(linear_zero_pos - 1.0f) > 1.e-6f) + a = (clicked_t - linear_zero_pos) / (1.0f - linear_zero_pos); + else + a = clicked_t; + a = powf(a, power); + new_value = ImLerp(ImMax(v_min,0.0f), v_max, a); + } + } + else + { + // Linear slider + new_value = ImLerp(v_min, v_max, clicked_t); + } + + // Round past decimal precision + new_value = RoundScalar(new_value, decimal_precision); + if (*v != new_value) + { + *v = new_value; + value_changed = true; + } + } + } + + // Draw + float grab_t = SliderBehaviorCalcRatioFromValue(*v, v_min, v_max, power, linear_zero_pos); + if (!is_horizontal) + grab_t = 1.0f - grab_t; + const float grab_pos = ImLerp(slider_usable_pos_min, slider_usable_pos_max, grab_t); + ImRect grab_bb; + if (is_horizontal) + grab_bb = ImRect(ImVec2(grab_pos - grab_sz * 0.5f, frame_bb.Min.y + grab_padding), ImVec2(grab_pos + grab_sz * 0.5f, frame_bb.Max.y - grab_padding)); + else + grab_bb = ImRect(ImVec2(frame_bb.Min.x + grab_padding, grab_pos - grab_sz * 0.5f), ImVec2(frame_bb.Max.x - grab_padding, grab_pos + grab_sz * 0.5f)); + + /*window->DrawList->AddRectFilled(frame_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding);*/ + window->DrawList->AddRectFilledMultiColor(frame_bb.Min, grab_bb.Max, GetColorU32(ImGuiCol_SliderGrabActive), GetColorU32(ImGuiCol_SliderGrabActive), GetColorU32(ImGuiCol_SliderGrab), GetColorU32(ImGuiCol_SliderGrab)); + + std::string noob = "%.1f"; + + if (decimal_precision <= 9) + noob[2] = std::to_string(decimal_precision).c_str()[0]; + + char value_buf[64]; + const char* value_buf_end = value_buf + ImFormatString(value_buf, IM_ARRAYSIZE(value_buf), noob.c_str(), *v); + + if (flags & ImGuiSliderFlags_RenderValue) + { + const ImVec2 label_size = CalcTextSize(value_buf, value_buf_end, true); + + const auto cur_clipping = window->ClipRect; + + ImGui::PopClipRect(); + + auto x_pos = grab_pos - label_size.x * 0.5f; + + if (x_pos + label_size.x > slider_usable_pos_max) + x_pos = slider_usable_pos_max - label_size.x; + + if (x_pos < frame_bb.Min.x) + x_pos = frame_bb.Min.x; + + ImVec4 *colors = (ImVec4*)style.Colors; + const auto text_color = colors[ImGuiCol_Text]; + colors[ImGuiCol_Text] = ImVec4(0.1f, 0.1f, 0.1f, text_color.w); + RenderText(ImVec2(x_pos + 1.f, frame_bb.Min.y - 1.f), value_buf, value_buf_end); + RenderText(ImVec2(x_pos - 1.f, frame_bb.Min.y - 1.f), value_buf, value_buf_end); + RenderText(ImVec2(x_pos, frame_bb.Min.y - 2.0f), value_buf, value_buf_end); + RenderText(ImVec2(x_pos, frame_bb.Min.y), value_buf, value_buf_end); + colors[ImGuiCol_Text] = text_color; + RenderText(ImVec2(x_pos, frame_bb.Min.y - 1.f), value_buf, value_buf_end); + ImGui::PushClipRect(cur_clipping.Min, cur_clipping.Max, false); + } + + return value_changed; +} + +// Use power!=1.0 for logarithmic sliders. +// Adjust display_format to decorate the value with a prefix or a suffix. +// "%.3f" 1.234 +// "%5.2f secs" 01.23 secs +// "Gold: %.0f" Gold: 1 +bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format, float power) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + const float w = CalcItemWidth(); + + const ImVec2 label_size = CalcTextSize(label, NULL, true); + + if (label_size.x > 0.0f) + Text(label); + + //window->DC.CursorPos.x += 20.f; + + const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, 5.f/*label_size.y + style.FramePadding.y*2.0f*/)); + const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); + + // NB- we don't call ItemSize() yet because we may turn into a text edit box below + if (!ItemAdd(total_bb, id)) + { + ItemSize(total_bb, style.FramePadding.y); + return false; + } + const bool hovered = ItemHoverable(frame_bb, id); + + if (!display_format) + display_format = "%.3f"; + int decimal_precision = ParseFormatPrecision(display_format, 3); + + // Tabbing or CTRL-clicking on Slider turns it into an input box + bool start_text_input = false; + const bool tab_focus_requested = FocusableItemRegister(window, id); + if (tab_focus_requested || (hovered && g.IO.MouseClicked[0] && ImGui::is_input_allowed)) + { + SetActiveID(id, window); + FocusWindow(window); + if (tab_focus_requested || g.IO.KeyCtrl) + { + // start_text_input = true; + //g.ScalarAsInputTextId = 0; + } + } + + //if (start_text_input || (g.ActiveId == id && g.ScalarAsInputTextId == id)) + // return InputScalarAsWidgetReplacement(frame_bb, label, ImGuiDataType_Float, v, id, decimal_precision); + + // Actual slider behavior + render grab + ItemSize(total_bb, style.FramePadding.y); + const bool value_changed = SliderBehavior(frame_bb/* - ImRect(ImVec2(0,0), ImVec2(0,5))*/, id, v, v_min, v_max, power, decimal_precision, ImGuiSliderFlags_RenderValue); + + // Display value using user-provided display format so user can add prefix/suffix/decorations to the value. + /*char value_buf[64]; + const char* value_buf_end = value_buf + ImFormatString(value_buf, IM_ARRAYSIZE(value_buf), display_format, *v);*/ + + //value but fuck this + //RenderTextClipped(frame_bb.Min + ImVec2(grab_pos, 0), frame_bb.Min + ImVec2(grab_pos/* + w*/, label_size.y)/*frame_bb.Max*/, value_buf, value_buf_end, NULL, ImVec2(0.5f,0.5f)); + + //if (label_size.x > 0.0f) + // RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); + + return value_changed; +} + +bool ImGui::VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* display_format, float power) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + + const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size); + const ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); + + ItemSize(bb, style.FramePadding.y); + if (!ItemAdd(frame_bb, id)) + return false; + const bool hovered = ItemHoverable(frame_bb, id); + + if (!display_format) + display_format = "%.3f"; + int decimal_precision = ParseFormatPrecision(display_format, 3); + + if (hovered && g.IO.MouseClicked[0]) + { + SetActiveID(id, window); + FocusWindow(window); + } + + // Actual slider behavior + render grab + bool value_changed = SliderBehavior(frame_bb, id, v, v_min, v_max, power, decimal_precision, ImGuiSliderFlags_Vertical); + + // Display value using user-provided display format so user can add prefix/suffix/decorations to the value. + // For the vertical slider we allow centered text to overlap the frame padding + char value_buf[64]; + char* value_buf_end = value_buf + ImFormatString(value_buf, IM_ARRAYSIZE(value_buf), display_format, *v); + RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f,0.0f)); + if (label_size.x > 0.0f) + RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); + + return value_changed; +} + +bool ImGui::SliderAngle(const char* label, float* v_rad, float v_degrees_min, float v_degrees_max) +{ + float v_deg = (*v_rad) * 360.0f / (2*IM_PI); + bool value_changed = SliderFloat(label, &v_deg, v_degrees_min, v_degrees_max, "%.0f deg", 1.0f); + *v_rad = v_deg * (2*IM_PI) / 360.0f; + return value_changed; +} + +bool ImGui::SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format) +{ + if (!display_format) + display_format = "%.0f"; + float v_f = (float)*v; + bool value_changed = SliderFloat(label, &v_f, (float)v_min, (float)v_max, display_format, 1.0f); + *v = (int)v_f; + return value_changed; +} + +bool ImGui::VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* display_format) +{ + if (!display_format) + display_format = "%.0f"; + float v_f = (float)*v; + bool value_changed = VSliderFloat(label, size, &v_f, (float)v_min, (float)v_max, display_format, 1.0f); + *v = (int)v_f; + return value_changed; +} + +// Add multiple sliders on 1 line for compact edition of multiple components +bool ImGui::SliderFloatN(const char* label, float* v, int components, float v_min, float v_max, const char* display_format, float power) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + bool value_changed = false; + BeginGroup(); + PushID(label); + PushMultiItemsWidths(components); + for (int i = 0; i < components; i++) + { + PushID(i); + value_changed |= SliderFloat("##v", &v[i], v_min, v_max, display_format, power); + SameLine(0, g.Style.ItemInnerSpacing.x); + PopID(); + PopItemWidth(); + } + PopID(); + + TextUnformatted(label, FindRenderedTextEnd(label)); + EndGroup(); + + return value_changed; +} + +bool ImGui::SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format, float power) +{ + return SliderFloatN(label, v, 2, v_min, v_max, display_format, power); +} + +bool ImGui::SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format, float power) +{ + return SliderFloatN(label, v, 3, v_min, v_max, display_format, power); +} + +bool ImGui::SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* display_format, float power) +{ + return SliderFloatN(label, v, 4, v_min, v_max, display_format, power); +} + +bool ImGui::SliderIntN(const char* label, int* v, int components, int v_min, int v_max, const char* display_format) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + bool value_changed = false; + BeginGroup(); + PushID(label); + PushMultiItemsWidths(components); + for (int i = 0; i < components; i++) + { + PushID(i); + value_changed |= SliderInt("##v", &v[i], v_min, v_max, display_format); + SameLine(0, g.Style.ItemInnerSpacing.x); + PopID(); + PopItemWidth(); + } + PopID(); + + TextUnformatted(label, FindRenderedTextEnd(label)); + EndGroup(); + + return value_changed; +} + +bool ImGui::SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* display_format) +{ + return SliderIntN(label, v, 2, v_min, v_max, display_format); +} + +bool ImGui::SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* display_format) +{ + return SliderIntN(label, v, 3, v_min, v_max, display_format); +} + +bool ImGui::SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* display_format) +{ + return SliderIntN(label, v, 4, v_min, v_max, display_format); +} + +bool ImGui::DragBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_speed, float v_min, float v_max, int decimal_precision, float power) +{ + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + // Draw frame + const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); + RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, style.FrameRounding); + + bool value_changed = false; + + // Process clicking on the drag + if (g.ActiveId == id) + { + if (g.IO.MouseDown[0]) + { + if (g.ActiveIdIsJustActivated) + { + // Lock current value on click + g.DragCurrentValue = *v; + g.DragLastMouseDelta = ImVec2(0.f, 0.f); + } + + if (v_speed == 0.0f && (v_max - v_min) != 0.0f && (v_max - v_min) < FLT_MAX) + v_speed = (v_max - v_min) * g.DragSpeedDefaultRatio; + + float v_cur = g.DragCurrentValue; + const ImVec2 mouse_drag_delta = GetMouseDragDelta(0, 1.0f); + float adjust_delta = 0.0f; + //if (g.ActiveIdSource == ImGuiInputSource_Mouse) + { + adjust_delta = mouse_drag_delta.x - g.DragLastMouseDelta.x; + if (g.IO.KeyShift && g.DragSpeedScaleFast >= 0.0f) + adjust_delta *= g.DragSpeedScaleFast; + if (g.IO.KeyAlt && g.DragSpeedScaleSlow >= 0.0f) + adjust_delta *= g.DragSpeedScaleSlow; + } + adjust_delta *= v_speed; + g.DragLastMouseDelta.x = mouse_drag_delta.x; + + if (fabsf(adjust_delta) > 0.0f) + { + if (fabsf(power - 1.0f) > 0.001f) + { + // Logarithmic curve on both side of 0.0 + float v0_abs = v_cur >= 0.0f ? v_cur : -v_cur; + float v0_sign = v_cur >= 0.0f ? 1.0f : -1.0f; + float v1 = powf(v0_abs, 1.0f / power) + (adjust_delta * v0_sign); + float v1_abs = v1 >= 0.0f ? v1 : -v1; + float v1_sign = v1 >= 0.0f ? 1.0f : -1.0f; // Crossed sign line + v_cur = powf(v1_abs, power) * v0_sign * v1_sign; // Reapply sign + } + else + { + v_cur += adjust_delta; + } + + // Clamp + if (v_min < v_max) + v_cur = ImClamp(v_cur, v_min, v_max); + g.DragCurrentValue = v_cur; + } + + // Round to user desired precision, then apply + v_cur = RoundScalar(v_cur, decimal_precision); + if (*v != v_cur) + { + *v = v_cur; + value_changed = true; + } + } + else + { + ClearActiveID(); + } + } + + return value_changed; +} + +bool ImGui::DragFloat(const char* label, float* v, float v_speed, float v_min, float v_max, const char* display_format, float power) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + const float w = CalcItemWidth(); + + const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f)); + const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding); + const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); + + // NB- we don't call ItemSize() yet because we may turn into a text edit box below + if (!ItemAdd(total_bb, id)) + { + ItemSize(total_bb, style.FramePadding.y); + return false; + } + const bool hovered = ItemHoverable(frame_bb, id); + + if (!display_format) + display_format = "%.3f"; + int decimal_precision = ParseFormatPrecision(display_format, 3); + + // Tabbing or CTRL-clicking on Drag turns it into an input box + bool start_text_input = false; + const bool tab_focus_requested = FocusableItemRegister(window, id); + if (tab_focus_requested || (hovered && (g.IO.MouseClicked[0] || g.IO.MouseDoubleClicked[0]))) + { + SetActiveID(id, window); + FocusWindow(window); + if (tab_focus_requested || g.IO.KeyCtrl || g.IO.MouseDoubleClicked[0]) + { + start_text_input = true; + g.ScalarAsInputTextId = 0; + } + } + if (start_text_input || (g.ActiveId == id && g.ScalarAsInputTextId == id)) + return InputScalarAsWidgetReplacement(frame_bb, label, ImGuiDataType_Float, v, id, decimal_precision); + + // Actual drag behavior + ItemSize(total_bb, style.FramePadding.y); + const bool value_changed = DragBehavior(frame_bb, id, v, v_speed, v_min, v_max, decimal_precision, power); + + // Display value using user-provided display format so user can add prefix/suffix/decorations to the value. + char value_buf[64]; + const char* value_buf_end = value_buf + ImFormatString(value_buf, IM_ARRAYSIZE(value_buf), display_format, *v); + RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f,0.5f)); + + if (label_size.x > 0.0f) + RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, inner_bb.Min.y), label); + + return value_changed; +} + +bool ImGui::DragFloatN(const char* label, float* v, int components, float v_speed, float v_min, float v_max, const char* display_format, float power) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + bool value_changed = false; + BeginGroup(); + PushID(label); + PushMultiItemsWidths(components); + for (int i = 0; i < components; i++) + { + PushID(i); + value_changed |= DragFloat("##v", &v[i], v_speed, v_min, v_max, display_format, power); + SameLine(0, g.Style.ItemInnerSpacing.x); + PopID(); + PopItemWidth(); + } + PopID(); + + TextUnformatted(label, FindRenderedTextEnd(label)); + EndGroup(); + + return value_changed; +} + +bool ImGui::DragFloat2(const char* label, float v[2], float v_speed, float v_min, float v_max, const char* display_format, float power) +{ + return DragFloatN(label, v, 2, v_speed, v_min, v_max, display_format, power); +} + +bool ImGui::DragFloat3(const char* label, float v[3], float v_speed, float v_min, float v_max, const char* display_format, float power) +{ + return DragFloatN(label, v, 3, v_speed, v_min, v_max, display_format, power); +} + +bool ImGui::DragFloat4(const char* label, float v[4], float v_speed, float v_min, float v_max, const char* display_format, float power) +{ + return DragFloatN(label, v, 4, v_speed, v_min, v_max, display_format, power); +} + +bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed, float v_min, float v_max, const char* display_format, const char* display_format_max, float power) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + PushID(label); + BeginGroup(); + PushMultiItemsWidths(2); + + bool value_changed = DragFloat("##min", v_current_min, v_speed, (v_min >= v_max) ? -FLT_MAX : v_min, (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max), display_format, power); + PopItemWidth(); + SameLine(0, g.Style.ItemInnerSpacing.x); + value_changed |= DragFloat("##max", v_current_max, v_speed, (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min), (v_min >= v_max) ? FLT_MAX : v_max, display_format_max ? display_format_max : display_format, power); + PopItemWidth(); + SameLine(0, g.Style.ItemInnerSpacing.x); + + TextUnformatted(label, FindRenderedTextEnd(label)); + EndGroup(); + PopID(); + + return value_changed; +} + +// NB: v_speed is float to allow adjusting the drag speed with more precision +bool ImGui::DragInt(const char* label, int* v, float v_speed, int v_min, int v_max, const char* display_format) +{ + if (!display_format) + display_format = "%.0f"; + float v_f = (float)*v; + bool value_changed = DragFloat(label, &v_f, v_speed, (float)v_min, (float)v_max, display_format); + *v = (int)v_f; + return value_changed; +} + +bool ImGui::DragIntN(const char* label, int* v, int components, float v_speed, int v_min, int v_max, const char* display_format) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + bool value_changed = false; + BeginGroup(); + PushID(label); + PushMultiItemsWidths(components); + for (int i = 0; i < components; i++) + { + PushID(i); + value_changed |= DragInt("##v", &v[i], v_speed, v_min, v_max, display_format); + SameLine(0, g.Style.ItemInnerSpacing.x); + PopID(); + PopItemWidth(); + } + PopID(); + + TextUnformatted(label, FindRenderedTextEnd(label)); + EndGroup(); + + return value_changed; +} + +bool ImGui::DragInt2(const char* label, int v[2], float v_speed, int v_min, int v_max, const char* display_format) +{ + return DragIntN(label, v, 2, v_speed, v_min, v_max, display_format); +} + +bool ImGui::DragInt3(const char* label, int v[3], float v_speed, int v_min, int v_max, const char* display_format) +{ + return DragIntN(label, v, 3, v_speed, v_min, v_max, display_format); +} + +bool ImGui::DragInt4(const char* label, int v[4], float v_speed, int v_min, int v_max, const char* display_format) +{ + return DragIntN(label, v, 4, v_speed, v_min, v_max, display_format); +} + +bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed, int v_min, int v_max, const char* display_format, const char* display_format_max) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + PushID(label); + BeginGroup(); + PushMultiItemsWidths(2); + + bool value_changed = DragInt("##min", v_current_min, v_speed, (v_min >= v_max) ? INT_MIN : v_min, (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max), display_format); + PopItemWidth(); + SameLine(0, g.Style.ItemInnerSpacing.x); + value_changed |= DragInt("##max", v_current_max, v_speed, (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min), (v_min >= v_max) ? INT_MAX : v_max, display_format_max ? display_format_max : display_format); + PopItemWidth(); + SameLine(0, g.Style.ItemInnerSpacing.x); + + TextUnformatted(label, FindRenderedTextEnd(label)); + EndGroup(); + PopID(); + + return value_changed; +} + +void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + const ImVec2 label_size = CalcTextSize(label, NULL, true); + if (graph_size.x == 0.0f) + graph_size.x = CalcItemWidth(); + if (graph_size.y == 0.0f) + graph_size.y = label_size.y + (style.FramePadding.y * 2); + + const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(graph_size.x, graph_size.y)); + const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding); + const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0)); + ItemSize(total_bb, style.FramePadding.y); + if (!ItemAdd(total_bb, 0)) + return; + const bool hovered = ItemHoverable(inner_bb, 0); + + // Determine scale from values if not specified + if (scale_min == FLT_MAX || scale_max == FLT_MAX) + { + float v_min = FLT_MAX; + float v_max = -FLT_MAX; + for (int i = 0; i < values_count; i++) + { + const float v = values_getter(data, i); + v_min = ImMin(v_min, v); + v_max = ImMax(v_max, v); + } + if (scale_min == FLT_MAX) + scale_min = v_min; + if (scale_max == FLT_MAX) + scale_max = v_max; + } + + RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); + + if (values_count > 0) + { + int res_w = ImMin((int)graph_size.x, values_count) + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0); + int item_count = values_count + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0); + + // Tooltip on hover + int v_hovered = -1; + if (hovered) + { + const float t = ImClamp((g.IO.MousePos.x - inner_bb.Min.x) / (inner_bb.Max.x - inner_bb.Min.x), 0.0f, 0.9999f); + const int v_idx = (int)(t * item_count); + IM_ASSERT(v_idx >= 0 && v_idx < values_count); + + const float v0 = values_getter(data, (v_idx + values_offset) % values_count); + const float v1 = values_getter(data, (v_idx + 1 + values_offset) % values_count); + if (plot_type == ImGuiPlotType_Lines) + SetTooltip("%d: %8.4g\n%d: %8.4g", v_idx, v0, v_idx+1, v1); + else if (plot_type == ImGuiPlotType_Histogram) + SetTooltip("%d: %8.4g", v_idx, v0); + v_hovered = v_idx; + } + + const float t_step = 1.0f / (float)res_w; + + float v0 = values_getter(data, (0 + values_offset) % values_count); + float t0 = 0.0f; + ImVec2 tp0 = ImVec2( t0, 1.0f - ImSaturate((v0 - scale_min) / (scale_max - scale_min)) ); // Point in the normalized space of our target rectangle + float histogram_zero_line_t = (scale_min * scale_max < 0.0f) ? (-scale_min / (scale_max - scale_min)) : (scale_min < 0.0f ? 0.0f : 1.0f); // Where does the zero line stands + + const ImU32 col_base = GetColorU32((plot_type == ImGuiPlotType_Lines) ? ImGuiCol_PlotLines : ImGuiCol_PlotHistogram); + const ImU32 col_hovered = GetColorU32((plot_type == ImGuiPlotType_Lines) ? ImGuiCol_PlotLinesHovered : ImGuiCol_PlotHistogramHovered); + + for (int n = 0; n < res_w; n++) + { + const float t1 = t0 + t_step; + const int v1_idx = (int)(t0 * item_count + 0.5f); + IM_ASSERT(v1_idx >= 0 && v1_idx < values_count); + const float v1 = values_getter(data, (v1_idx + values_offset + 1) % values_count); + const ImVec2 tp1 = ImVec2( t1, 1.0f - ImSaturate((v1 - scale_min) / (scale_max - scale_min)) ); + + // NB: Draw calls are merged together by the DrawList system. Still, we should render our batch are lower level to save a bit of CPU. + ImVec2 pos0 = ImLerp(inner_bb.Min, inner_bb.Max, tp0); + ImVec2 pos1 = ImLerp(inner_bb.Min, inner_bb.Max, (plot_type == ImGuiPlotType_Lines) ? tp1 : ImVec2(tp1.x, histogram_zero_line_t)); + if (plot_type == ImGuiPlotType_Lines) + { + window->DrawList->AddLine(pos0, pos1, v_hovered == v1_idx ? col_hovered : col_base); + } + else if (plot_type == ImGuiPlotType_Histogram) + { + if (pos1.x >= pos0.x + 2.0f) + pos1.x -= 1.0f; + window->DrawList->AddRectFilled(pos0, pos1, v_hovered == v1_idx ? col_hovered : col_base); + } + + t0 = t1; + tp0 = tp1; + } + } + + // Text overlay + if (overlay_text) + RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, overlay_text, NULL, NULL, ImVec2(0.5f,0.0f)); + + if (label_size.x > 0.0f) + RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, inner_bb.Min.y), label); +} + +struct ImGuiPlotArrayGetterData +{ + const float* Values; + int Stride; + + ImGuiPlotArrayGetterData(const float* values, int stride) { Values = values; Stride = stride; } +}; + +static float Plot_ArrayGetter(void* data, int idx) +{ + ImGuiPlotArrayGetterData* plot_data = (ImGuiPlotArrayGetterData*)data; + const float v = *(float*)(void*)((unsigned char*)plot_data->Values + (size_t)idx * plot_data->Stride); + return v; +} + +void ImGui::PlotLines(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, int stride) +{ + ImGuiPlotArrayGetterData data(values, stride); + PlotEx(ImGuiPlotType_Lines, label, &Plot_ArrayGetter, (void*)&data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); +} + +void ImGui::PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size) +{ + PlotEx(ImGuiPlotType_Lines, label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); +} + +void ImGui::PlotHistogram(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, int stride) +{ + ImGuiPlotArrayGetterData data(values, stride); + PlotEx(ImGuiPlotType_Histogram, label, &Plot_ArrayGetter, (void*)&data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); +} + +void ImGui::PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size) +{ + PlotEx(ImGuiPlotType_Histogram, label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); +} + +// size_arg (for each axis) < 0.0f: align to end, 0.0f: auto, > 0.0f: specified size +void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* overlay) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + ImVec2 pos = window->DC.CursorPos; + ImRect bb(pos, pos + CalcItemSize(size_arg, CalcItemWidth(), g.FontSize + style.FramePadding.y*2.0f)); + ItemSize(bb, style.FramePadding.y); + if (!ItemAdd(bb, 0)) + return; + + // Render + fraction = ImSaturate(fraction); + RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); + bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize)); + const ImVec2 fill_br = ImVec2(ImLerp(bb.Min.x, bb.Max.x, fraction), bb.Max.y); + RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), 0.0f, fraction, style.FrameRounding); + + // Default displaying the fraction as percentage string, but user can override it + char overlay_buf[32]; + if (!overlay) + { + ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%.0f%%", fraction*100+0.01f); + overlay = overlay_buf; + } + + ImVec2 overlay_size = CalcTextSize(overlay, NULL); + if (overlay_size.x > 0.0f) + RenderTextClipped(ImVec2(ImClamp(fill_br.x + style.ItemSpacing.x, bb.Min.x, bb.Max.x - overlay_size.x - style.ItemInnerSpacing.x), bb.Min.y), bb.Max, overlay, NULL, &overlay_size, ImVec2(0.0f,0.5f), &bb); +} + +std::unordered_map state = {}; +std::unordered_map size = {}; +std::unordered_map size2 = {}; + +bool ImGui::Checkbox(const char* label, bool* v) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + const ImVec2 label_size = CalcTextSize(label, NULL, true); + + const ImRect check_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(label_size.y + style.FramePadding.y * 2 - 4, label_size.y + style.FramePadding.y * 2 - 4)); // We want a square shape to we use Y twice + + ItemSize(check_bb, style.FramePadding.y); + + ImRect total_bb = check_bb; + if (label_size.x > 0) + SameLine(0, style.ItemInnerSpacing.x); + + const ImRect text_bb(window->DC.CursorPos + ImVec2(0, style.FramePadding.y - 3), window->DC.CursorPos + ImVec2(0, style.FramePadding.y) + label_size); + + if (label_size.x > 0) + { + ItemSize(ImVec2(text_bb.GetWidth(), check_bb.GetHeight()), style.FramePadding.y); + total_bb = ImRect(ImMin(check_bb.Min, text_bb.Min), ImMax(check_bb.Max, text_bb.Max)); + } + + if (!ItemAdd(total_bb, id)) + return false; + + bool hovered, held; + bool pressed = ButtonBehavior(total_bb, id, &hovered, &held); + + if (pressed) + *v = !(*v); + + auto clr = GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : /*hovered ? ImGuiCol_FrameBgHovered :*/ ImGuiCol_FrameBg); + + RenderFrame(check_bb.Min, check_bb.Max, clr, true, style.FrameRounding); + + auto fid = (int)id; + + float check_sz = ImMin(check_bb.GetWidth(), check_bb.GetHeight()); + float pad = ImMax(1.0f, (float)(int)(check_sz / 6.0f)); + + //RenderCheckMark(check_bb.Min + ImVec2(pad, pad), GetColorU32(ImGuiCol_CheckMark, 0.99f), check_bb.GetWidth() - pad * 2.0f); + + auto sizediff = check_bb.Max.x - check_bb.Min.x; + + /*auto ololo = check_bb.Max.x - check_bb.Min.x; + + if (pressed && *v == state[fid]) + state[fid] ^= 1; + + if (*v != state[fid]) + { + if (!*v) { + if (size[fid] > 0.f) + size[fid] -= ImMin(size[fid], 0.45f); + else + state[fid] = *v; + } + + if (*v) { + if (size[fid] < ololo) + size[fid] += ImMin(ololo, 0.45f); + else + state[fid] = *v; + } + }*/ + + /*if (size[fid] < (ololo - 0.35f)) + { + auto clrR = ((held && hovered) ? ImVec4(0.2862745098f, 0.2862745098f, 0.2862745098f, 1.f) : ImVec4(0.2f, 0.2f, 0.2f, 1.f)); + + window->DrawList->AddRectFilled(check_bb.Min + ImVec2(size[fid], 1), check_bb.Max - ImVec2(0, 1), ColorConvertFloat4ToU32(clrR), style.FrameRounding); + }*/ + + auto changed = *v != state[fid]; + //size[fid] + + if (changed) + { + if (*v) { + if (size[fid] < sizediff) + size[fid] += ImMin(sizediff - size[fid], 1.f); + else + state[fid] = *v; + } + else { + /*size[fid] = 0.f; + state[fid] = *v;*/ + if (size[fid] > 0.f) + size[fid] -= ImMin(size[fid], 1.5f); + else + state[fid] = *v; + } + } + else + { + if (*v) { + if (size2[fid] < sizediff) + size2[fid] += ImMin(sizediff - size2[fid], 0.6f); + } + else + size2[fid] = 0.f; + } + + if (*v || changed) + window->DrawList->AddRectFilled(check_bb.Min + ImVec2(1, 1), check_bb.Max - ImVec2(1, 1), GetColorU32(ImGuiCol_CheckMark), style.FrameRounding); + if (changed/* && *v*/) + window->DrawList->AddRectFilled(check_bb.Min + ImVec2(size[fid] * 0.5f, size[fid] * 0.5f), check_bb.Max - ImVec2(size[fid] * 0.5f, size[fid] * 0.5f), GetColorU32(ImGuiCol_WindowBg), style.FrameRounding); + + PushClipRect(check_bb.Min, check_bb.Min + ImVec2(size2[fid], check_bb.GetHeight()), false); + if (*v) + RenderCheckMark(check_bb.Min + ImVec2(pad, pad), GetColorU32(ImGuiCol_WindowBg, 0.99f), check_bb.GetWidth() - pad * 2.0f); + PopClipRect(); + + if (hovered) + window->DrawList->AddRect(check_bb.Min, check_bb.Max, GetColorU32(ImGuiCol_FrameBgHovered), style.FrameRounding); + + if (g.LogEnabled) + LogRenderedText(&text_bb.Min, *v ? "[x]" : "[ ]"); + if (label_size.x > 0.0f) + RenderText(text_bb.Min, label); + + return pressed; +} + +bool ImGui::CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value) +{ + bool v = ((*flags & flags_value) == flags_value); + bool pressed = Checkbox(label, &v); + if (pressed) + { + if (v) + *flags |= flags_value; + else + *flags &= ~flags_value; + } + + return pressed; +} + +bool ImGui::RadioButton(const char* label, bool active) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + const ImVec2 label_size = CalcTextSize(label, NULL, true); + + const ImRect check_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(label_size.y + style.FramePadding.y*2-1, label_size.y + style.FramePadding.y*2-1)); + ItemSize(check_bb, style.FramePadding.y); + + ImRect total_bb = check_bb; + if (label_size.x > 0) + SameLine(0, style.ItemInnerSpacing.x); + const ImRect text_bb(window->DC.CursorPos + ImVec2(0, style.FramePadding.y), window->DC.CursorPos + ImVec2(0, style.FramePadding.y) + label_size); + if (label_size.x > 0) + { + ItemSize(ImVec2(text_bb.GetWidth(), check_bb.GetHeight()), style.FramePadding.y); + total_bb.Add(text_bb); + } + + if (!ItemAdd(total_bb, id)) + return false; + + ImVec2 center = check_bb.GetCenter(); + center.x = (float)(int)center.x + 0.5f; + center.y = (float)(int)center.y + 0.5f; + const float radius = check_bb.GetHeight() * 0.5f; + + bool hovered, held; + bool pressed = ButtonBehavior(total_bb, id, &hovered, &held); + + window->DrawList->AddCircleFilled(center, radius, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), 16); + if (active) + { + const float check_sz = ImMin(check_bb.GetWidth(), check_bb.GetHeight()); + const float pad = ImMax(1.0f, (float)(int)(check_sz / 6.0f)); + window->DrawList->AddCircleFilled(center, radius-pad, GetColorU32(ImGuiCol_CheckMark), 16); + } + + if (style.FrameBorderSize > 0.0f) + { + window->DrawList->AddCircle(center+ImVec2(1,1), radius, GetColorU32(ImGuiCol_BorderShadow), 16, style.FrameBorderSize); + window->DrawList->AddCircle(center, radius, GetColorU32(ImGuiCol_Border), 16, style.FrameBorderSize); + } + + if (g.LogEnabled) + LogRenderedText(&text_bb.Min, active ? "(x)" : "( )"); + if (label_size.x > 0.0f) + RenderText(text_bb.Min, label); + + return pressed; +} + +bool ImGui::RadioButton(const char* label, int* v, int v_button) +{ + const bool pressed = RadioButton(label, *v == v_button); + if (pressed) + { + *v = v_button; + } + return pressed; +} + +static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end) +{ + int line_count = 0; + const char* s = text_begin; + while (char c = *s++) // We are only matching for \n so we can ignore UTF-8 decoding + if (c == '\n') + line_count++; + s--; + if (s[0] != '\n' && s[0] != '\r') + line_count++; + *out_text_end = s; + return line_count; +} + +static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining, ImVec2* out_offset, bool stop_on_new_line) +{ + ImFont* font = GImGui->Font; + const float line_height = GImGui->FontSize; + const float scale = line_height / font->FontSize; + + ImVec2 text_size = ImVec2(0,0); + float line_width = 0.0f; + + const ImWchar* s = text_begin; + while (s < text_end) + { + unsigned int c = (unsigned int)(*s++); + if (c == '\n') + { + text_size.x = ImMax(text_size.x, line_width); + text_size.y += line_height; + line_width = 0.0f; + if (stop_on_new_line) + break; + continue; + } + if (c == '\r') + continue; + + const float char_width = font->GetCharAdvance((unsigned short)c) * scale; + line_width += char_width; + } + + if (text_size.x < line_width) + text_size.x = line_width; + + if (out_offset) + *out_offset = ImVec2(line_width, text_size.y + line_height); // offset allow for the possibility of sitting after a trailing \n + + if (line_width > 0 || text_size.y == 0.0f) // whereas size.y will ignore the trailing \n + text_size.y += line_height; + + if (remaining) + *remaining = s; + + return text_size; +} + +// Wrapper for stb_textedit.h to edit text (our wrapper is for: statically sized buffer, single-line, wchar characters. InputText converts between UTF-8 and wchar) +namespace ImGuiStb +{ + +static int STB_TEXTEDIT_STRINGLEN(const STB_TEXTEDIT_STRING* obj) { return obj->CurLenW; } +static ImWchar STB_TEXTEDIT_GETCHAR(const STB_TEXTEDIT_STRING* obj, int idx) { return obj->Text[idx]; } +static float STB_TEXTEDIT_GETWIDTH(STB_TEXTEDIT_STRING* obj, int line_start_idx, int char_idx) { ImWchar c = obj->Text[line_start_idx+char_idx]; if (c == '\n') return STB_TEXTEDIT_GETWIDTH_NEWLINE; return GImGui->Font->GetCharAdvance(c) * (GImGui->FontSize / GImGui->Font->FontSize); } +static int STB_TEXTEDIT_KEYTOTEXT(int key) { return key >= 0x10000 ? 0 : key; } +static ImWchar STB_TEXTEDIT_NEWLINE = '\n'; +static void STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, STB_TEXTEDIT_STRING* obj, int line_start_idx) +{ + const ImWchar* text = obj->Text.Data; + const ImWchar* text_remaining = NULL; + const ImVec2 size = InputTextCalcTextSizeW(text + line_start_idx, text + obj->CurLenW, &text_remaining, NULL, true); + r->x0 = 0.0f; + r->x1 = size.x; + r->baseline_y_delta = size.y; + r->ymin = 0.0f; + r->ymax = size.y; + r->num_chars = (int)(text_remaining - (text + line_start_idx)); +} + +static bool is_separator(unsigned int c) { return ImCharIsSpace(c) || c==',' || c==';' || c=='(' || c==')' || c=='{' || c=='}' || c=='[' || c==']' || c=='|'; } +static int is_word_boundary_from_right(STB_TEXTEDIT_STRING* obj, int idx) { return idx > 0 ? (is_separator( obj->Text[idx-1] ) && !is_separator( obj->Text[idx] ) ) : 1; } +static int STB_TEXTEDIT_MOVEWORDLEFT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { idx--; while (idx >= 0 && !is_word_boundary_from_right(obj, idx)) idx--; return idx < 0 ? 0 : idx; } +#ifdef __APPLE__ // FIXME: Move setting to IO structure +static int is_word_boundary_from_left(STB_TEXTEDIT_STRING* obj, int idx) { return idx > 0 ? (!is_separator( obj->Text[idx-1] ) && is_separator( obj->Text[idx] ) ) : 1; } +static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { idx++; int len = obj->CurLenW; while (idx < len && !is_word_boundary_from_left(obj, idx)) idx++; return idx > len ? len : idx; } +#else +static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { idx++; int len = obj->CurLenW; while (idx < len && !is_word_boundary_from_right(obj, idx)) idx++; return idx > len ? len : idx; } +#endif +#define STB_TEXTEDIT_MOVEWORDLEFT STB_TEXTEDIT_MOVEWORDLEFT_IMPL // They need to be #define for stb_textedit.h +#define STB_TEXTEDIT_MOVEWORDRIGHT STB_TEXTEDIT_MOVEWORDRIGHT_IMPL + +static void STB_TEXTEDIT_DELETECHARS(STB_TEXTEDIT_STRING* obj, int pos, int n) +{ + ImWchar* dst = obj->Text.Data + pos; + + // We maintain our buffer length in both UTF-8 and wchar formats + obj->CurLenA -= ImTextCountUtf8BytesFromStr(dst, dst + n); + obj->CurLenW -= n; + + // Offset remaining text + const ImWchar* src = obj->Text.Data + pos + n; + while (ImWchar c = *src++) + *dst++ = c; + *dst = '\0'; +} + +static bool STB_TEXTEDIT_INSERTCHARS(STB_TEXTEDIT_STRING* obj, int pos, const ImWchar* new_text, int new_text_len) +{ + const int text_len = obj->CurLenW; + IM_ASSERT(pos <= text_len); + if (new_text_len + text_len + 1 > obj->Text.Size) + return false; + + const int new_text_len_utf8 = ImTextCountUtf8BytesFromStr(new_text, new_text + new_text_len); + if (new_text_len_utf8 + obj->CurLenA + 1 > obj->BufSizeA) + return false; + + ImWchar* text = obj->Text.Data; + if (pos != text_len) + memmove(text + pos + new_text_len, text + pos, (size_t)(text_len - pos) * sizeof(ImWchar)); + memcpy(text + pos, new_text, (size_t)new_text_len * sizeof(ImWchar)); + + obj->CurLenW += new_text_len; + obj->CurLenA += new_text_len_utf8; + obj->Text[obj->CurLenW] = '\0'; + + return true; +} + +// We don't use an enum so we can build even with conflicting symbols (if another user of stb_textedit.h leak their STB_TEXTEDIT_K_* symbols) +#define STB_TEXTEDIT_K_LEFT 0x10000 // keyboard input to move cursor left +#define STB_TEXTEDIT_K_RIGHT 0x10001 // keyboard input to move cursor right +#define STB_TEXTEDIT_K_UP 0x10002 // keyboard input to move cursor up +#define STB_TEXTEDIT_K_DOWN 0x10003 // keyboard input to move cursor down +#define STB_TEXTEDIT_K_LINESTART 0x10004 // keyboard input to move cursor to start of line +#define STB_TEXTEDIT_K_LINEEND 0x10005 // keyboard input to move cursor to end of line +#define STB_TEXTEDIT_K_TEXTSTART 0x10006 // keyboard input to move cursor to start of text +#define STB_TEXTEDIT_K_TEXTEND 0x10007 // keyboard input to move cursor to end of text +#define STB_TEXTEDIT_K_DELETE 0x10008 // keyboard input to delete selection or character under cursor +#define STB_TEXTEDIT_K_BACKSPACE 0x10009 // keyboard input to delete selection or character left of cursor +#define STB_TEXTEDIT_K_UNDO 0x1000A // keyboard input to perform undo +#define STB_TEXTEDIT_K_REDO 0x1000B // keyboard input to perform redo +#define STB_TEXTEDIT_K_WORDLEFT 0x1000C // keyboard input to move cursor left one word +#define STB_TEXTEDIT_K_WORDRIGHT 0x1000D // keyboard input to move cursor right one word +#define STB_TEXTEDIT_K_SHIFT 0x20000 + +#define STB_TEXTEDIT_IMPLEMENTATION +#include "stb_textedit.h" + +} + +void ImGuiTextEditState::OnKeyPressed(int key) +{ + stb_textedit_key(this, &StbState, key); + CursorFollow = true; + CursorAnimReset(); +} + +// Public API to manipulate UTF-8 text +// We expose UTF-8 to the user (unlike the STB_TEXTEDIT_* functions which are manipulating wchar) +// FIXME: The existence of this rarely exercised code path is a bit of a nuisance. +void ImGuiTextEditCallbackData::DeleteChars(int pos, int BYTEs_count) +{ + IM_ASSERT(pos + BYTEs_count <= BufTextLen); + char* dst = Buf + pos; + const char* src = Buf + pos + BYTEs_count; + while (char c = *src++) + *dst++ = c; + *dst = '\0'; + + if (CursorPos + BYTEs_count >= pos) + CursorPos -= BYTEs_count; + else if (CursorPos >= pos) + CursorPos = pos; + SelectionStart = SelectionEnd = CursorPos; + BufDirty = true; + BufTextLen -= BYTEs_count; +} + +void ImGuiTextEditCallbackData::InsertChars(int pos, const char* new_text, const char* new_text_end) +{ + const int new_text_len = new_text_end ? (int)(new_text_end - new_text) : (int)strlen(new_text); + if (new_text_len + BufTextLen + 1 >= BufSize) + return; + + if (BufTextLen != pos) + memmove(Buf + pos + new_text_len, Buf + pos, (size_t)(BufTextLen - pos)); + memcpy(Buf + pos, new_text, (size_t)new_text_len * sizeof(char)); + Buf[BufTextLen + new_text_len] = '\0'; + + if (CursorPos >= pos) + CursorPos += new_text_len; + SelectionStart = SelectionEnd = CursorPos; + BufDirty = true; + BufTextLen += new_text_len; +} + +// Return false to discard a character. +static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback, void* user_data) +{ + unsigned int c = *p_char; + + if (c < 128 && c != ' ' && !isprint((int)(c & 0xFF))) + { + bool pass = false; + pass |= (c == '\n' && (flags & ImGuiInputTextFlags_Multiline)); + pass |= (c == '\t' && (flags & ImGuiInputTextFlags_AllowTabInput)); + if (!pass) + return false; + } + + if (c >= 0xE000 && c <= 0xF8FF) // Filter private Unicode range. I don't imagine anybody would want to input them. GLFW on OSX seems to send private characters for special keys like arrow keys. + return false; + + if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank)) + { + if (flags & ImGuiInputTextFlags_CharsDecimal) + if (!(c >= '0' && c <= '9') && (c != '.') && (c != '-') && (c != '+') && (c != '*') && (c != '/')) + return false; + + if (flags & ImGuiInputTextFlags_CharsHexadecimal) + if (!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f') && !(c >= 'A' && c <= 'F')) + return false; + + if (flags & ImGuiInputTextFlags_CharsUppercase) + if (c >= 'a' && c <= 'z') + *p_char = (c += (unsigned int)('A'-'a')); + + if (flags & ImGuiInputTextFlags_CharsNoBlank) + if (ImCharIsSpace(c)) + return false; + } + + if (flags & ImGuiInputTextFlags_CallbackCharFilter) + { + ImGuiTextEditCallbackData callback_data; + memset(&callback_data, 0, sizeof(ImGuiTextEditCallbackData)); + callback_data.EventFlag = ImGuiInputTextFlags_CallbackCharFilter; + callback_data.EventChar = (ImWchar)c; + callback_data.Flags = flags; + callback_data.UserData = user_data; + if (callback(&callback_data) != 0) + return false; + *p_char = callback_data.EventChar; + if (!callback_data.EventChar) + return false; + } + + return true; +} + +// Edit a string of text +// NB: when active, hold on a privately held copy of the text (and apply back to 'buf'). So changing 'buf' while active has no effect. +// FIXME: Rather messy function partly because we are doing UTF8 > u16 > UTF8 conversions on the go to more easily handle stb_textedit calls. Ideally we should stay in UTF-8 all the time. See https://github.com/nothings/stb/issues/188 +bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback, void* user_data) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackHistory) && (flags & ImGuiInputTextFlags_Multiline))); // Can't use both together (they both use up/down keys) + IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackCompletion) && (flags & ImGuiInputTextFlags_AllowTabInput))); // Can't use both together (they both use tab key) + + ImGuiContext& g = *GImGui; + const ImGuiIO& io = g.IO; + const ImGuiStyle& style = g.Style; + + const bool is_multiline = (flags & ImGuiInputTextFlags_Multiline) != 0; + const bool is_editable = (flags & ImGuiInputTextFlags_ReadOnly) == 0; + const bool is_password = (flags & ImGuiInputTextFlags_Password) != 0; + const bool is_undoable = (flags & ImGuiInputTextFlags_NoUndoRedo) == 0; + + if (is_multiline) // Open group before calling GetID() because groups tracks id created during their spawn + BeginGroup(); + const ImGuiID id = window->GetID(label); + const ImVec2 label_size = CalcTextSize(label, NULL, true); + ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), (is_multiline ? GetTextLineHeight() * 8.0f : label_size.y) + style.FramePadding.y*2.0f); // Arbitrary default of 8 lines high for multi-line + const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size); + const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? (style.ItemInnerSpacing.x + label_size.x) : 0.0f, 0.0f)); + + ImGuiWindow* draw_window = window; + if (is_multiline) + { + if (!BeginChildFrame(id, frame_bb.GetSize())) + { + EndChildFrame(); + EndGroup(); + return false; + } + draw_window = GetCurrentWindow(); + size.x -= draw_window->ScrollbarSizes.x; + } + else + { + ItemSize(total_bb, style.FramePadding.y); + if (!ItemAdd(total_bb, id)) + return false; + } + const bool hovered = ItemHoverable(frame_bb, id); + if (hovered) + g.MouseCursor = ImGuiMouseCursor_TextInput; + + // Password pushes a temporary font with only a fallback glyph + if (is_password) + { + const ImFontGlyph* glyph = g.Font->FindGlyph('*'); + ImFont* password_font = &g.InputTextPasswordFont; + password_font->FontSize = g.Font->FontSize; + password_font->Scale = g.Font->Scale; + password_font->DisplayOffset = g.Font->DisplayOffset; + password_font->Ascent = g.Font->Ascent; + password_font->Descent = g.Font->Descent; + password_font->ContainerAtlas = g.Font->ContainerAtlas; + password_font->FallbackGlyph = glyph; + password_font->FallbackAdvanceX = glyph->AdvanceX; + IM_ASSERT(password_font->Glyphs.empty() && password_font->IndexAdvanceX.empty() && password_font->IndexLookup.empty()); + PushFont(password_font); + } + + // NB: we are only allowed to access 'edit_state' if we are the active widget. + ImGuiTextEditState& edit_state = g.InputTextState; + + const bool focus_requested = FocusableItemRegister(window, id, (flags & (ImGuiInputTextFlags_CallbackCompletion|ImGuiInputTextFlags_AllowTabInput)) == 0); // Using completion callback disable keyboard tabbing + const bool focus_requested_by_code = focus_requested && (window->FocusIdxAllCounter == window->FocusIdxAllRequestCurrent); + const bool focus_requested_by_tab = focus_requested && !focus_requested_by_code; + + const bool user_clicked = hovered && io.MouseClicked[0]; + const bool user_scrolled = is_multiline && g.ActiveId == 0 && edit_state.Id == id && g.ActiveIdPreviousFrame == draw_window->GetIDNoKeepAlive("#SCROLLY"); + + bool clear_active_id = false; + + bool select_all = (g.ActiveId != id) && (flags & ImGuiInputTextFlags_AutoSelectAll) != 0; + if (focus_requested || user_clicked || user_scrolled) + { + if (g.ActiveId != id) + { + // Start edition + // Take a copy of the initial buffer value (both in original UTF-8 format and converted to wchar) + // From the moment we focused we are ignoring the content of 'buf' (unless we are in read-only mode) + const int prev_len_w = edit_state.CurLenW; + edit_state.Text.resize(buf_size+1); // wchar count <= UTF-8 count. we use +1 to make sure that .Data isn't NULL so it doesn't crash. + edit_state.InitialText.resize(buf_size+1); // UTF-8. we use +1 to make sure that .Data isn't NULL so it doesn't crash. + ImStrncpy(edit_state.InitialText.Data, buf, edit_state.InitialText.Size); + const char* buf_end = NULL; + edit_state.CurLenW = ImTextStrFromUtf8(edit_state.Text.Data, edit_state.Text.Size, buf, NULL, &buf_end); + edit_state.CurLenA = (int)(buf_end - buf); // We can't get the result from ImFormatString() above because it is not UTF-8 aware. Here we'll cut off malformed UTF-8. + edit_state.CursorAnimReset(); + + // Preserve cursor position and undo/redo stack if we come back to same widget + // FIXME: We should probably compare the whole buffer to be on the safety side. Comparing buf (utf8) and edit_state.Text (wchar). + const bool recycle_state = (edit_state.Id == id) && (prev_len_w == edit_state.CurLenW); + if (recycle_state) + { + // Recycle existing cursor/selection/undo stack but clamp position + // Note a single mouse click will override the cursor/position immediately by calling stb_textedit_click handler. + edit_state.CursorClamp(); + } + else + { + edit_state.Id = id; + edit_state.ScrollX = 0.0f; + stb_textedit_initialize_state(&edit_state.StbState, !is_multiline); + if (!is_multiline && focus_requested_by_code) + select_all = true; + } + if (flags & ImGuiInputTextFlags_AlwaysInsertMode) + edit_state.StbState.insert_mode = true; + if (!is_multiline && (focus_requested_by_tab || (user_clicked && io.KeyCtrl))) + select_all = true; + } + SetActiveID(id, window); + FocusWindow(window); + } + else if (io.MouseClicked[0]) + { + // Release focus when we click outside + clear_active_id = true; + } + + bool value_changed = false; + bool enter_pressed = false; + + if (g.ActiveId == id) + { + if (!is_editable && !g.ActiveIdIsJustActivated) + { + // When read-only we always use the live data passed to the function + edit_state.Text.resize(buf_size+1); + const char* buf_end = NULL; + edit_state.CurLenW = ImTextStrFromUtf8(edit_state.Text.Data, edit_state.Text.Size, buf, NULL, &buf_end); + edit_state.CurLenA = (int)(buf_end - buf); + edit_state.CursorClamp(); + } + + edit_state.BufSizeA = buf_size; + + // Although we are active we don't prevent mouse from hovering other elements unless we are interacting right now with the widget. + // Down the line we should have a cleaner library-wide concept of Selected vs Active. + g.ActiveIdAllowOverlap = !io.MouseDown[0]; + g.WantTextInputNextFrame = 1; + + // Edit in progress + const float mouse_x = (io.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + edit_state.ScrollX; + const float mouse_y = (is_multiline ? (io.MousePos.y - draw_window->DC.CursorPos.y - style.FramePadding.y) : (g.FontSize*0.5f)); + + const bool osx_double_click_selects_words = io.OptMacOSXBehaviors; // OS X style: Double click selects by word instead of selecting whole text + if (select_all || (hovered && !osx_double_click_selects_words && io.MouseDoubleClicked[0])) + { + edit_state.SelectAll(); + edit_state.SelectedAllMouseLock = true; + } + else if (hovered && osx_double_click_selects_words && io.MouseDoubleClicked[0]) + { + // Select a word only, OS X style (by simulating keystrokes) + edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT); + edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT); + } + else if (io.MouseClicked[0] && !edit_state.SelectedAllMouseLock) + { + stb_textedit_click(&edit_state, &edit_state.StbState, mouse_x, mouse_y); + edit_state.CursorAnimReset(); + } + else if (io.MouseDown[0] && !edit_state.SelectedAllMouseLock && (io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f)) + { + stb_textedit_drag(&edit_state, &edit_state.StbState, mouse_x, mouse_y); + edit_state.CursorAnimReset(); + edit_state.CursorFollow = true; + } + if (edit_state.SelectedAllMouseLock && !io.MouseDown[0]) + edit_state.SelectedAllMouseLock = false; + + if (io.InputCharacters[0]) + { + // Process text input (before we check for Return because using some IME will effectively send a Return?) + // We ignore CTRL inputs, but need to allow CTRL+ALT as some keyboards (e.g. German) use AltGR - which is Alt+Ctrl - to input certain characters. + if (!(io.KeyCtrl && !io.KeyAlt) && is_editable) + { + for (int n = 0; n < IM_ARRAYSIZE(io.InputCharacters) && io.InputCharacters[n]; n++) + if (unsigned int c = (unsigned int)io.InputCharacters[n]) + { + // Insert character if they pass filtering + if (!InputTextFilterCharacter(&c, flags, callback, user_data)) + continue; + edit_state.OnKeyPressed((int)c); + } + } + + // Consume characters + memset(g.IO.InputCharacters, 0, sizeof(g.IO.InputCharacters)); + } + } + + bool cancel_edit = false; + if (g.ActiveId == id && !g.ActiveIdIsJustActivated && !clear_active_id) + { + // Handle key-presses + const int k_mask = (io.KeyShift ? STB_TEXTEDIT_K_SHIFT : 0); + const bool is_shortcut_key_only = (io.OptMacOSXBehaviors ? (io.KeySuper && !io.KeyCtrl) : (io.KeyCtrl && !io.KeySuper)) && !io.KeyAlt && !io.KeyShift; // OS X style: Shortcuts using Cmd/Super instead of Ctrl + const bool is_wordmove_key_down = io.OptMacOSXBehaviors ? io.KeyAlt : io.KeyCtrl; // OS X style: Text editing cursor movement using Alt instead of Ctrl + const bool is_startend_key_down = io.OptMacOSXBehaviors && io.KeySuper && !io.KeyCtrl && !io.KeyAlt; // OS X style: Line/Text Start and End using Cmd+Arrows instead of Home/End + const bool is_ctrl_key_only = io.KeyCtrl && !io.KeyShift && !io.KeyAlt && !io.KeySuper; + const bool is_shift_key_only = io.KeyShift && !io.KeyCtrl && !io.KeyAlt && !io.KeySuper; + + const bool is_cut = ((is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_X)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Delete))) && is_editable && !is_password && (!is_multiline || edit_state.HasSelection()); + const bool is_copy = ((is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_C)) || (is_ctrl_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && !is_password && (!is_multiline || edit_state.HasSelection()); + const bool is_paste = ((is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_V)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && is_editable; + + if (IsKeyPressedMap(ImGuiKey_LeftArrow)) { edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINESTART : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDLEFT : STB_TEXTEDIT_K_LEFT) | k_mask); } + else if (IsKeyPressedMap(ImGuiKey_RightArrow)) { edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINEEND : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT : STB_TEXTEDIT_K_RIGHT) | k_mask); } + else if (IsKeyPressedMap(ImGuiKey_UpArrow) && is_multiline) { if (io.KeyCtrl) SetWindowScrollY(draw_window, ImMax(draw_window->Scroll.y - g.FontSize, 0.0f)); else edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTSTART : STB_TEXTEDIT_K_UP) | k_mask); } + else if (IsKeyPressedMap(ImGuiKey_DownArrow) && is_multiline) { if (io.KeyCtrl) SetWindowScrollY(draw_window, ImMin(draw_window->Scroll.y + g.FontSize, GetScrollMaxY())); else edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTEND : STB_TEXTEDIT_K_DOWN) | k_mask); } + else if (IsKeyPressedMap(ImGuiKey_Home)) { edit_state.OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTSTART | k_mask : STB_TEXTEDIT_K_LINESTART | k_mask); } + else if (IsKeyPressedMap(ImGuiKey_End)) { edit_state.OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTEND | k_mask : STB_TEXTEDIT_K_LINEEND | k_mask); } + else if (IsKeyPressedMap(ImGuiKey_Delete) && is_editable) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_DELETE | k_mask); } + else if (IsKeyPressedMap(ImGuiKey_Backspace) && is_editable) + { + if (!edit_state.HasSelection()) + { + if (is_wordmove_key_down) edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT|STB_TEXTEDIT_K_SHIFT); + else if (io.OptMacOSXBehaviors && io.KeySuper && !io.KeyAlt && !io.KeyCtrl) edit_state.OnKeyPressed(STB_TEXTEDIT_K_LINESTART|STB_TEXTEDIT_K_SHIFT); + } + edit_state.OnKeyPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask); + } + else if (IsKeyPressedMap(ImGuiKey_Enter)) + { + bool ctrl_enter_for_new_line = (flags & ImGuiInputTextFlags_CtrlEnterForNewLine) != 0; + if (!is_multiline || (ctrl_enter_for_new_line && !io.KeyCtrl) || (!ctrl_enter_for_new_line && io.KeyCtrl)) + { + enter_pressed = clear_active_id = true; + } + else if (is_editable) + { + unsigned int c = '\n'; // Insert new line + if (InputTextFilterCharacter(&c, flags, callback, user_data)) + edit_state.OnKeyPressed((int)c); + } + } + else if ((flags & ImGuiInputTextFlags_AllowTabInput) && IsKeyPressedMap(ImGuiKey_Tab) && !io.KeyCtrl && !io.KeyShift && !io.KeyAlt && is_editable) + { + unsigned int c = '\t'; // Insert TAB + if (InputTextFilterCharacter(&c, flags, callback, user_data)) + edit_state.OnKeyPressed((int)c); + } + else if (IsKeyPressedMap(ImGuiKey_Escape)) { clear_active_id = cancel_edit = true; } + else if (is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_Z) && is_editable && is_undoable) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_UNDO); edit_state.ClearSelection(); } + else if (is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_Y) && is_editable && is_undoable) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_REDO); edit_state.ClearSelection(); } + else if (is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_A)) { edit_state.SelectAll(); edit_state.CursorFollow = true; } + else if (is_cut || is_copy) + { + // Cut, Copy + if (io.SetClipboardTextFn) + { + const int ib = edit_state.HasSelection() ? ImMin(edit_state.StbState.select_start, edit_state.StbState.select_end) : 0; + const int ie = edit_state.HasSelection() ? ImMax(edit_state.StbState.select_start, edit_state.StbState.select_end) : edit_state.CurLenW; + edit_state.TempTextBuffer.resize((ie-ib) * 4 + 1); + ImTextStrToUtf8(edit_state.TempTextBuffer.Data, edit_state.TempTextBuffer.Size, edit_state.Text.Data+ib, edit_state.Text.Data+ie); + SetClipboardText(edit_state.TempTextBuffer.Data); + } + + if (is_cut) + { + if (!edit_state.HasSelection()) + edit_state.SelectAll(); + edit_state.CursorFollow = true; + stb_textedit_cut(&edit_state, &edit_state.StbState); + } + } + else if (is_paste) + { + // Paste + if (const char* clipboard = GetClipboardText()) + { + // Filter pasted buffer + const int clipboard_len = (int)strlen(clipboard); + ImWchar* clipboard_filtered = (ImWchar*)ImGui::MemAlloc((clipboard_len+1) * sizeof(ImWchar)); + int clipboard_filtered_len = 0; + for (const char* s = clipboard; *s; ) + { + unsigned int c; + s += ImTextCharFromUtf8(&c, s, NULL); + if (c == 0) + break; + if (c >= 0x10000 || !InputTextFilterCharacter(&c, flags, callback, user_data)) + continue; + clipboard_filtered[clipboard_filtered_len++] = (ImWchar)c; + } + clipboard_filtered[clipboard_filtered_len] = 0; + if (clipboard_filtered_len > 0) // If everything was filtered, ignore the pasting operation + { + stb_textedit_paste(&edit_state, &edit_state.StbState, clipboard_filtered, clipboard_filtered_len); + edit_state.CursorFollow = true; + } + ImGui::MemFree(clipboard_filtered); + } + } + } + + if (g.ActiveId == id) + { + if (cancel_edit) + { + // Restore initial value + if (is_editable) + { + ImStrncpy(buf, edit_state.InitialText.Data, buf_size); + value_changed = true; + } + } + + // When using 'ImGuiInputTextFlags_EnterReturnsTrue' as a special case we reapply the live buffer back to the input buffer before clearing ActiveId, even though strictly speaking it wasn't modified on this frame. + // If we didn't do that, code like InputInt() with ImGuiInputTextFlags_EnterReturnsTrue would fail. Also this allows the user to use InputText() with ImGuiInputTextFlags_EnterReturnsTrue without maintaining any user-side storage. + bool apply_edit_back_to_user_buffer = !cancel_edit || (enter_pressed && (flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0); + if (apply_edit_back_to_user_buffer) + { + // Apply new value immediately - copy modified buffer back + // Note that as soon as the input box is active, the in-widget value gets priority over any underlying modification of the input buffer + // FIXME: We actually always render 'buf' when calling DrawList->AddText, making the comment above incorrect. + // FIXME-OPT: CPU waste to do this every time the widget is active, should mark dirty state from the stb_textedit callbacks. + if (is_editable) + { + edit_state.TempTextBuffer.resize(edit_state.Text.Size * 4); + ImTextStrToUtf8(edit_state.TempTextBuffer.Data, edit_state.TempTextBuffer.Size, edit_state.Text.Data, NULL); + } + + // User callback + if ((flags & (ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory | ImGuiInputTextFlags_CallbackAlways)) != 0) + { + IM_ASSERT(callback != NULL); + + // The reason we specify the usage semantic (Completion/History) is that Completion needs to disable keyboard TABBING at the moment. + ImGuiInputTextFlags event_flag = 0; + ImGuiKey event_key = ImGuiKey_COUNT; + if ((flags & ImGuiInputTextFlags_CallbackCompletion) != 0 && IsKeyPressedMap(ImGuiKey_Tab)) + { + event_flag = ImGuiInputTextFlags_CallbackCompletion; + event_key = ImGuiKey_Tab; + } + else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressedMap(ImGuiKey_UpArrow)) + { + event_flag = ImGuiInputTextFlags_CallbackHistory; + event_key = ImGuiKey_UpArrow; + } + else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressedMap(ImGuiKey_DownArrow)) + { + event_flag = ImGuiInputTextFlags_CallbackHistory; + event_key = ImGuiKey_DownArrow; + } + else if (flags & ImGuiInputTextFlags_CallbackAlways) + event_flag = ImGuiInputTextFlags_CallbackAlways; + + if (event_flag) + { + ImGuiTextEditCallbackData callback_data; + memset(&callback_data, 0, sizeof(ImGuiTextEditCallbackData)); + callback_data.EventFlag = event_flag; + callback_data.Flags = flags; + callback_data.UserData = user_data; + callback_data.ReadOnly = !is_editable; + + callback_data.EventKey = event_key; + callback_data.Buf = edit_state.TempTextBuffer.Data; + callback_data.BufTextLen = edit_state.CurLenA; + callback_data.BufSize = edit_state.BufSizeA; + callback_data.BufDirty = false; + + // We have to convert from wchar-positions to UTF-8-positions, which can be pretty slow (an incentive to ditch the ImWchar buffer, see https://github.com/nothings/stb/issues/188) + ImWchar* text = edit_state.Text.Data; + const int utf8_cursor_pos = callback_data.CursorPos = ImTextCountUtf8BytesFromStr(text, text + edit_state.StbState.cursor); + const int utf8_selection_start = callback_data.SelectionStart = ImTextCountUtf8BytesFromStr(text, text + edit_state.StbState.select_start); + const int utf8_selection_end = callback_data.SelectionEnd = ImTextCountUtf8BytesFromStr(text, text + edit_state.StbState.select_end); + + // Call user code + callback(&callback_data); + + // Read back what user may have modified + IM_ASSERT(callback_data.Buf == edit_state.TempTextBuffer.Data); // Invalid to modify those fields + IM_ASSERT(callback_data.BufSize == edit_state.BufSizeA); + IM_ASSERT(callback_data.Flags == flags); + if (callback_data.CursorPos != utf8_cursor_pos) edit_state.StbState.cursor = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.CursorPos); + if (callback_data.SelectionStart != utf8_selection_start) edit_state.StbState.select_start = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.SelectionStart); + if (callback_data.SelectionEnd != utf8_selection_end) edit_state.StbState.select_end = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.SelectionEnd); + if (callback_data.BufDirty) + { + IM_ASSERT(callback_data.BufTextLen == (int)strlen(callback_data.Buf)); // You need to maintain BufTextLen if you change the text! + edit_state.CurLenW = ImTextStrFromUtf8(edit_state.Text.Data, edit_state.Text.Size, callback_data.Buf, NULL); + edit_state.CurLenA = callback_data.BufTextLen; // Assume correct length and valid UTF-8 from user, saves us an extra strlen() + edit_state.CursorAnimReset(); + } + } + } + + // Copy back to user buffer + if (is_editable && strcmp(edit_state.TempTextBuffer.Data, buf) != 0) + { + ImStrncpy(buf, edit_state.TempTextBuffer.Data, buf_size); + value_changed = true; + } + } + } + + // Release active ID at the end of the function (so e.g. pressing Return still does a final application of the value) + if (clear_active_id && g.ActiveId == id) + ClearActiveID(); + + // Render + // Select which buffer we are going to display. When ImGuiInputTextFlags_NoLiveEdit is set 'buf' might still be the old value. We set buf to NULL to prevent accidental usage from now on. + const char* buf_display = (g.ActiveId == id && is_editable) ? edit_state.TempTextBuffer.Data : buf; buf = NULL; + + if (!is_multiline) + RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); + + const ImVec4 clip_rect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + size.x, frame_bb.Min.y + size.y); // Not using frame_bb.Max because we have adjusted size + ImVec2 render_pos = is_multiline ? draw_window->DC.CursorPos : frame_bb.Min + style.FramePadding; + ImVec2 text_size(0.f, 0.f); + const bool is_currently_scrolling = (edit_state.Id == id && is_multiline && g.ActiveId == draw_window->GetIDNoKeepAlive("#SCROLLY")); + if (g.ActiveId == id || is_currently_scrolling) + { + edit_state.CursorAnim += io.DeltaTime; + + // This is going to be messy. We need to: + // - Display the text (this alone can be more easily clipped) + // - Handle scrolling, highlight selection, display cursor (those all requires some form of 1d->2d cursor position calculation) + // - Measure text height (for scrollbar) + // We are attempting to do most of that in **one main pass** to minimize the computation cost (non-negligible for large amount of text) + 2nd pass for selection rendering (we could merge them by an extra refactoring effort) + // FIXME: This should occur on buf_display but we'd need to maintain cursor/select_start/select_end for UTF-8. + const ImWchar* text_begin = edit_state.Text.Data; + ImVec2 cursor_offset, select_start_offset; + + { + // Count lines + find lines numbers straddling 'cursor' and 'select_start' position. + const ImWchar* searches_input_ptr[2]; + searches_input_ptr[0] = text_begin + edit_state.StbState.cursor; + searches_input_ptr[1] = NULL; + int searches_remaining = 1; + int searches_result_line_number[2] = { -1, -999 }; + if (edit_state.StbState.select_start != edit_state.StbState.select_end) + { + searches_input_ptr[1] = text_begin + ImMin(edit_state.StbState.select_start, edit_state.StbState.select_end); + searches_result_line_number[1] = -1; + searches_remaining++; + } + + // Iterate all lines to find our line numbers + // In multi-line mode, we never exit the loop until all lines are counted, so add one extra to the searches_remaining counter. + searches_remaining += is_multiline ? 1 : 0; + int line_count = 0; + for (const ImWchar* s = text_begin; *s != 0; s++) + if (*s == '\n') + { + line_count++; + if (searches_result_line_number[0] == -1 && s >= searches_input_ptr[0]) { searches_result_line_number[0] = line_count; if (--searches_remaining <= 0) break; } + if (searches_result_line_number[1] == -1 && s >= searches_input_ptr[1]) { searches_result_line_number[1] = line_count; if (--searches_remaining <= 0) break; } + } + line_count++; + if (searches_result_line_number[0] == -1) searches_result_line_number[0] = line_count; + if (searches_result_line_number[1] == -1) searches_result_line_number[1] = line_count; + + // Calculate 2d position by finding the beginning of the line and measuring distance + cursor_offset.x = InputTextCalcTextSizeW(ImStrbolW(searches_input_ptr[0], text_begin), searches_input_ptr[0]).x; + cursor_offset.y = searches_result_line_number[0] * g.FontSize; + if (searches_result_line_number[1] >= 0) + { + select_start_offset.x = InputTextCalcTextSizeW(ImStrbolW(searches_input_ptr[1], text_begin), searches_input_ptr[1]).x; + select_start_offset.y = searches_result_line_number[1] * g.FontSize; + } + + // Store text height (note that we haven't calculated text width at all, see GitHub issues #383, #1224) + if (is_multiline) + text_size = ImVec2(size.x, line_count * g.FontSize); + } + + // Scroll + if (edit_state.CursorFollow) + { + // Horizontal scroll in chunks of quarter width + if (!(flags & ImGuiInputTextFlags_NoHorizontalScroll)) + { + const float scroll_increment_x = size.x * 0.25f; + if (cursor_offset.x < edit_state.ScrollX) + edit_state.ScrollX = (float)(int)ImMax(0.0f, cursor_offset.x - scroll_increment_x); + else if (cursor_offset.x - size.x >= edit_state.ScrollX) + edit_state.ScrollX = (float)(int)(cursor_offset.x - size.x + scroll_increment_x); + } + else + { + edit_state.ScrollX = 0.0f; + } + + // Vertical scroll + if (is_multiline) + { + float scroll_y = draw_window->Scroll.y; + if (cursor_offset.y - g.FontSize < scroll_y) + scroll_y = ImMax(0.0f, cursor_offset.y - g.FontSize); + else if (cursor_offset.y - size.y >= scroll_y) + scroll_y = cursor_offset.y - size.y; + draw_window->DC.CursorPos.y += (draw_window->Scroll.y - scroll_y); // To avoid a frame of lag + draw_window->Scroll.y = scroll_y; + render_pos.y = draw_window->DC.CursorPos.y; + } + } + edit_state.CursorFollow = false; + const ImVec2 render_scroll = ImVec2(edit_state.ScrollX, 0.0f); + + // Draw selection + if (edit_state.StbState.select_start != edit_state.StbState.select_end) + { + const ImWchar* text_selected_begin = text_begin + ImMin(edit_state.StbState.select_start, edit_state.StbState.select_end); + const ImWchar* text_selected_end = text_begin + ImMax(edit_state.StbState.select_start, edit_state.StbState.select_end); + + float bg_offy_up = is_multiline ? 0.0f : -1.0f; // FIXME: those offsets should be part of the style? they don't play so well with multi-line selection. + float bg_offy_dn = is_multiline ? 0.0f : 2.0f; + ImU32 bg_color = GetColorU32(ImGuiCol_TextSelectedBg); + ImVec2 rect_pos = render_pos + select_start_offset - render_scroll; + for (const ImWchar* p = text_selected_begin; p < text_selected_end; ) + { + if (rect_pos.y > clip_rect.w + g.FontSize) + break; + if (rect_pos.y < clip_rect.y) + { + while (p < text_selected_end) + if (*p++ == '\n') + break; + } + else + { + ImVec2 rect_size = InputTextCalcTextSizeW(p, text_selected_end, &p, NULL, true); + if (rect_size.x <= 0.0f) rect_size.x = (float)(int)(g.Font->GetCharAdvance((unsigned short)' ') * 0.50f); // So we can see selected empty lines + ImRect rect(rect_pos + ImVec2(0.0f, bg_offy_up - g.FontSize), rect_pos +ImVec2(rect_size.x, bg_offy_dn)); + rect.ClipWith(clip_rect); + if (rect.Overlaps(clip_rect)) + draw_window->DrawList->AddRectFilled(rect.Min, rect.Max, bg_color); + } + rect_pos.x = render_pos.x - render_scroll.x; + rect_pos.y += g.FontSize; + } + } + + draw_window->DrawList->AddText(g.Font, g.FontSize, render_pos - render_scroll, GetColorU32(ImGuiCol_Text), buf_display, buf_display + edit_state.CurLenA, 0.0f, is_multiline ? NULL : &clip_rect); + + // Draw blinking cursor + bool cursor_is_visible = (!g.IO.OptCursorBlink) || (g.InputTextState.CursorAnim <= 0.0f) || fmodf(g.InputTextState.CursorAnim, 1.20f) <= 0.80f; + ImVec2 cursor_screen_pos = render_pos + cursor_offset - render_scroll; + ImRect cursor_screen_rect(cursor_screen_pos.x, cursor_screen_pos.y-g.FontSize+0.5f, cursor_screen_pos.x+1.0f, cursor_screen_pos.y-1.5f); + if (cursor_is_visible && cursor_screen_rect.Overlaps(clip_rect)) + draw_window->DrawList->AddLine(cursor_screen_rect.Min, cursor_screen_rect.GetBL(), GetColorU32(ImGuiCol_Text)); + + // Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.) + if (is_editable) + g.OsImePosRequest = ImVec2(cursor_screen_pos.x - 1, cursor_screen_pos.y - g.FontSize); + } + else + { + // Render text only + const char* buf_end = NULL; + if (is_multiline) + text_size = ImVec2(size.x, InputTextCalcTextLenAndLineCount(buf_display, &buf_end) * g.FontSize); // We don't need width + draw_window->DrawList->AddText(g.Font, g.FontSize, render_pos, GetColorU32(ImGuiCol_Text), buf_display, buf_end, 0.0f, is_multiline ? NULL : &clip_rect); + } + + if (is_multiline) + { + Dummy(text_size + ImVec2(0.0f, g.FontSize)); // Always add room to scroll an extra line + EndChildFrame(); + EndGroup(); + } + + if (is_password) + PopFont(); + + // Log as text + if (g.LogEnabled && !is_password) + LogRenderedText(&render_pos, buf_display, NULL); + + if (label_size.x > 0) + RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); + + if ((flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0) + return enter_pressed; + else + return value_changed; +} + +bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback, void* user_data) +{ + IM_ASSERT(!(flags & ImGuiInputTextFlags_Multiline)); // call InputTextMultiline() + return InputTextEx(label, buf, (int)buf_size, ImVec2(0,0), flags, callback, user_data); +} + +bool ImGui::InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback, void* user_data) +{ + return InputTextEx(label, buf, (int)buf_size, size, flags | ImGuiInputTextFlags_Multiline, callback, user_data); +} + +// NB: scalar_format here must be a simple "%xx" format string with no prefix/suffix (unlike the Drag/Slider functions "display_format" argument) +bool ImGui::InputScalarEx(const char* label, ImGuiDataType data_type, void* data_ptr, void* step_ptr, void* step_fast_ptr, const char* scalar_format, ImGuiInputTextFlags extra_flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImVec2 label_size = CalcTextSize(label, NULL, true); + + BeginGroup(); + PushID(label); + const ImVec2 button_sz = ImVec2(GetFrameHeight(), GetFrameHeight()); + if (step_ptr) + PushItemWidth(ImMax(1.0f, CalcItemWidth() - (button_sz.x + style.ItemInnerSpacing.x)*2)); + + char buf[64]; + DataTypeFormatString(data_type, data_ptr, scalar_format, buf, IM_ARRAYSIZE(buf)); + + bool value_changed = false; + if (!(extra_flags & ImGuiInputTextFlags_CharsHexadecimal)) + extra_flags |= ImGuiInputTextFlags_CharsDecimal; + extra_flags |= ImGuiInputTextFlags_AutoSelectAll; + if (InputText("", buf, IM_ARRAYSIZE(buf), extra_flags)) // PushId(label) + "" gives us the expected ID from outside point of view + value_changed = DataTypeApplyOpFromText(buf, GImGui->InputTextState.InitialText.begin(), data_type, data_ptr, scalar_format); + + // Step buttons + if (step_ptr) + { + PopItemWidth(); + SameLine(0, style.ItemInnerSpacing.x); + if (ButtonEx("-", button_sz, ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups)) + { + DataTypeApplyOp(data_type, '-', data_ptr, g.IO.KeyCtrl && step_fast_ptr ? step_fast_ptr : step_ptr); + value_changed = true; + } + SameLine(0, style.ItemInnerSpacing.x); + if (ButtonEx("+", button_sz, ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups)) + { + DataTypeApplyOp(data_type, '+', data_ptr, g.IO.KeyCtrl && step_fast_ptr ? step_fast_ptr : step_ptr); + value_changed = true; + } + } + PopID(); + + if (label_size.x > 0) + { + SameLine(0, style.ItemInnerSpacing.x); + RenderText(ImVec2(window->DC.CursorPos.x, window->DC.CursorPos.y + style.FramePadding.y), label); + ItemSize(label_size, style.FramePadding.y); + } + EndGroup(); + + return value_changed; +} + +bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast, int decimal_precision, ImGuiInputTextFlags extra_flags) +{ + char display_format[16]; + if (decimal_precision < 0) + strcpy(display_format, "%f"); // Ideally we'd have a minimum decimal precision of 1 to visually denote that this is a float, while hiding non-significant digits? %f doesn't have a minimum of 1 + else + ImFormatString(display_format, IM_ARRAYSIZE(display_format), "%%.%df", decimal_precision); + return InputScalarEx(label, ImGuiDataType_Float, (void*)v, (void*)(step>0.0f ? &step : NULL), (void*)(step_fast>0.0f ? &step_fast : NULL), display_format, extra_flags); +} + +bool ImGui::InputInt(const char* label, int* v, int step, int step_fast, ImGuiInputTextFlags extra_flags) +{ + // Hexadecimal input provided as a convenience but the flag name is awkward. Typically you'd use InputText() to parse your own data, if you want to handle prefixes. + const char* scalar_format = (extra_flags & ImGuiInputTextFlags_CharsHexadecimal) ? "%08X" : "%d"; + return InputScalarEx(label, ImGuiDataType_Int, (void*)v, (void*)(step>0.0f ? &step : NULL), (void*)(step_fast>0.0f ? &step_fast : NULL), scalar_format, extra_flags); +} + +bool ImGui::InputFloatN(const char* label, float* v, int components, int decimal_precision, ImGuiInputTextFlags extra_flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + bool value_changed = false; + BeginGroup(); + PushID(label); + PushMultiItemsWidths(components); + for (int i = 0; i < components; i++) + { + PushID(i); + value_changed |= InputFloat("##v", &v[i], 0, 0, decimal_precision, extra_flags); + SameLine(0, g.Style.ItemInnerSpacing.x); + PopID(); + PopItemWidth(); + } + PopID(); + + TextUnformatted(label, FindRenderedTextEnd(label)); + EndGroup(); + + return value_changed; +} + +bool ImGui::InputFloat2(const char* label, float v[2], int decimal_precision, ImGuiInputTextFlags extra_flags) +{ + return InputFloatN(label, v, 2, decimal_precision, extra_flags); +} + +bool ImGui::InputFloat3(const char* label, float v[3], int decimal_precision, ImGuiInputTextFlags extra_flags) +{ + return InputFloatN(label, v, 3, decimal_precision, extra_flags); +} + +bool ImGui::InputFloat4(const char* label, float v[4], int decimal_precision, ImGuiInputTextFlags extra_flags) +{ + return InputFloatN(label, v, 4, decimal_precision, extra_flags); +} + +bool ImGui::InputIntN(const char* label, int* v, int components, ImGuiInputTextFlags extra_flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + bool value_changed = false; + BeginGroup(); + PushID(label); + PushMultiItemsWidths(components); + for (int i = 0; i < components; i++) + { + PushID(i); + value_changed |= InputInt("##v", &v[i], 0, 0, extra_flags); + SameLine(0, g.Style.ItemInnerSpacing.x); + PopID(); + PopItemWidth(); + } + PopID(); + + TextUnformatted(label, FindRenderedTextEnd(label)); + EndGroup(); + + return value_changed; +} + +bool ImGui::InputInt2(const char* label, int v[2], ImGuiInputTextFlags extra_flags) +{ + return InputIntN(label, v, 2, extra_flags); +} + +bool ImGui::InputInt3(const char* label, int v[3], ImGuiInputTextFlags extra_flags) +{ + return InputIntN(label, v, 3, extra_flags); +} + +bool ImGui::InputInt4(const char* label, int v[4], ImGuiInputTextFlags extra_flags) +{ + return InputIntN(label, v, 4, extra_flags); +} + +static float CalcMaxPopupHeightFromItemCount(int items_count) +{ + ImGuiContext& g = *GImGui; + if (items_count <= 0) + return FLT_MAX; + return (g.FontSize + g.Style.ItemSpacing.y) * items_count - g.Style.ItemSpacing.y + (g.Style.WindowPadding.y * 2); +} + +bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags) +{ + // Always consume the SetNextWindowSizeConstraint() call in our early return paths + ImGuiContext& g = *GImGui; + ImGuiCond backup_next_window_size_constraint = g.NextWindowData.SizeConstraintCond; + g.NextWindowData.SizeConstraintCond = 0; + + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + const float w = CalcItemWidth(); + + const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f)); + const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); + ItemSize(total_bb, style.FramePadding.y); + if (!ItemAdd(total_bb, id)) + return false; + + bool hovered, held; + bool pressed = ButtonBehavior(frame_bb, id, &hovered, &held); + bool popup_open = IsPopupOpen(id); + + const float arrow_size = GetFrameHeight(); + const ImRect value_bb(frame_bb.Min, frame_bb.Max - ImVec2(arrow_size, 0.0f)); + RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); + RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32(popup_open || hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING + RenderTriangle(ImVec2(frame_bb.Max.x - arrow_size + style.FramePadding.y, frame_bb.Min.y + style.FramePadding.y), ImGuiDir_Down); + if (preview_value != NULL) + RenderTextClipped(frame_bb.Min + style.FramePadding, value_bb.Max, preview_value, NULL, NULL, ImVec2(0.0f,0.0f)); + if (label_size.x > 0) + RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); + + if (pressed && !popup_open) + { + OpenPopupEx(id); + popup_open = true; + } + + if (!popup_open) + return false; + + if (backup_next_window_size_constraint) + { + g.NextWindowData.SizeConstraintCond = backup_next_window_size_constraint; + g.NextWindowData.SizeConstraintRect.Min.x = ImMax(g.NextWindowData.SizeConstraintRect.Min.x, w); + } + else + { + if ((flags & ImGuiComboFlags_HeightMask_) == 0) + flags |= ImGuiComboFlags_HeightRegular; + IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiComboFlags_HeightMask_)); // Only one + int popup_max_height_in_items = -1; + if (flags & ImGuiComboFlags_HeightRegular) popup_max_height_in_items = 8; + else if (flags & ImGuiComboFlags_HeightSmall) popup_max_height_in_items = 4; + else if (flags & ImGuiComboFlags_HeightLarge) popup_max_height_in_items = 20; + SetNextWindowSizeConstraints(ImVec2(w, 0.0f), ImVec2(FLT_MAX, CalcMaxPopupHeightFromItemCount(popup_max_height_in_items))); + } + + char name[16]; + ImFormatString(name, IM_ARRAYSIZE(name), "##Combo_%02d", g.CurrentPopupStack.Size); // Recycle windows based on depth + + // Peak into expected window size so we can position it + if (ImGuiWindow* popup_window = FindWindowByName(name)) + if (popup_window->WasActive) + { + ImVec2 size_contents = CalcSizeContents(popup_window); + ImVec2 size_expected = CalcSizeAfterConstraint(popup_window, CalcSizeAutoFit(popup_window, size_contents)); + if (flags & ImGuiComboFlags_PopupAlignLeft) + popup_window->AutoPosLastDirection = ImGuiDir_Left; + ImVec2 pos = FindBestWindowPosForPopup(frame_bb.GetBL(), size_expected, &popup_window->AutoPosLastDirection, frame_bb, ImGuiPopupPositionPolicy_ComboBox); + SetNextWindowPos(pos); + } + + ImGuiWindowFlags window_flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_Popup | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings; + if (!Begin(name, NULL, window_flags)) + { + EndPopup(); + IM_ASSERT(0); // This should never happen as we tested for IsPopupOpen() above + return false; + } + + // Horizontally align ourselves with the framed text + if (style.FramePadding.x != style.WindowPadding.x) + Indent(style.FramePadding.x - style.WindowPadding.x); + + return true; +} + +void ImGui::EndCombo() +{ + const ImGuiStyle& style = GImGui->Style; + if (style.FramePadding.x != style.WindowPadding.x) + Unindent(style.FramePadding.x - style.WindowPadding.x); + EndPopup(); +} + +// Old API, prefer using BeginCombo() nowadays if you can. +bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int popup_max_height_in_items) +{ + ImGuiContext& g = *GImGui; + + const char* preview_text = NULL; + if (*current_item >= 0 && *current_item < items_count) + items_getter(data, *current_item, &preview_text); + + // The old Combo() API exposed "popup_max_height_in_items", however the new more general BeginCombo() API doesn't, so we emulate it here. + if (popup_max_height_in_items != -1 && !g.NextWindowData.SizeConstraintCond) + { + float popup_max_height = CalcMaxPopupHeightFromItemCount(popup_max_height_in_items); + SetNextWindowSizeConstraints(ImVec2(0,0), ImVec2(FLT_MAX, popup_max_height)); + } + + if (!BeginCombo(label, preview_text, 0)) + return false; + + // Display items + // FIXME-OPT: Use clipper (but we need to disable it on the appearing frame to make sure our call to SetItemDefaultFocus() is processed) + bool value_changed = false; + for (int i = 0; i < items_count; i++) + { + const bool item_selected = (i == *current_item); + const char* item_text; + if (!items_getter(data, i, &item_text)) + continue; + + PushID((void*)(intptr_t)i); + if (Selectable(item_text, item_selected)) + { + value_changed = true; + *current_item = i; + } + if (item_selected) + SetItemDefaultFocus(); + PopID(); + } + + EndCombo(); + return value_changed; +} + +static bool Items_ArrayGetter(void* data, int idx, const char** out_text) +{ + const char* const* items = (const char* const*)data; + if (out_text) + *out_text = items[idx]; + return true; +} + +static bool Items_SingleStringGetter(void* data, int idx, const char** out_text) +{ + // FIXME-OPT: we could pre-compute the indices to fasten this. But only 1 active combo means the waste is limited. + const char* items_separated_by_zeros = (const char*)data; + int items_count = 0; + const char* p = items_separated_by_zeros; + while (*p) + { + if (idx == items_count) + break; + p += strlen(p) + 1; + items_count++; + } + if (!*p) + return false; + if (out_text) + *out_text = p; + return true; +} + +void ImGui::Tabs(const char* items, int* current_item) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + int items_count = 0; + const char* p = items; // FIXME-OPT: Avoid computing this, or at least only when combo is open + while (*p) + { + p += strlen(p) + 1; + items_count++; + } + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + auto size = (GetContentRegionMax().x - window->WindowPadding.x - items_count) / items_count; + + for (int i = 0; i < items_count; i++) + { + const char* text = NULL; + Items_SingleStringGetter((void*)items, i, &text); + if (ImGui::Button(text, ImVec2(size, 20), *current_item == i)) + *current_item = i; + + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - style.ItemSpacing.x + 1); + } + ImGui::NewLine(); +} + +// Combo box helper allowing to pass an array of strings. +bool ImGui::Combo(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items) +{ + const bool value_changed = Combo(label, current_item, Items_ArrayGetter, (void*)items, items_count, height_in_items); + return value_changed; +} + +// Combo box helper allowing to pass all items in a single string. +bool ImGui::Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items) +{ + int items_count = 0; + const char* p = items_separated_by_zeros; // FIXME-OPT: Avoid computing this, or at least only when combo is open + while (*p) + { + p += strlen(p) + 1; + items_count++; + } + bool value_changed = Combo(label, current_item, Items_SingleStringGetter, (void*)items_separated_by_zeros, items_count, height_in_items); + return value_changed; +} + +std::unordered_map selected_items; + +bool ImGui::MCombo(const char* label, std::vector items, int height_in_items, ImVec2 size) +{ + ImGuiWindow* window = GetCurrentWindow(); + ImGuiContext& g = *GImGui; + if (window->SkipItems) + return false; + + ImGuiID id = window->GetID(label); + + selected_items[id].clear(); + + float w = CalcItemWidth(); + ImGuiStyle& style = g.Style; + ImVec2 label_size = CalcTextSize(label, NULL, true); + ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f)); + ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); + + auto items_count = items.size(); + + if (items_count > 1) { + for (int i = 0; i < items_count; i++) + { + auto &item = items.at(i); + + if (!(*item.value)) + continue; + + if (i > 0 && selected_items[id].size() > 1 && *items[i - 1].value == false) + selected_items[id] += ", "; + + selected_items[id] += item.name; + + if ((i + 1) < items_count && selected_items[id].size() > 1 && *items[i + 1].value) + selected_items[id] += ", "; + /*if (CalcTextSize(selected_items.c_str()).x > 150) { + selected_items.resize(150 / 5); + selected_items += "..."; + break; + }*/ + } + } + + if (height_in_items != -1 && !g.NextWindowData.SizeConstraintCond) + { + float popup_max_height = CalcMaxPopupHeightFromItemCount(height_in_items); + SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, popup_max_height)); + } + + if (!BeginCombo(label, selected_items[id].c_str(), 0)) + return false; + + // Display items + // FIXME-OPT: Use clipper (but we need to disable it on the appearing frame to make sure our call to SetItemDefaultFocus() is processed) + bool value_changed = false; + for (int i = 0; i < items_count; i++) + { + auto &item = items.at(i); + + if (item.value == nullptr) + continue; + + PushID((void*)(intptr_t)i); + if (Selectable(item.name.c_str(), *item.value, ImGuiSelectableFlags_DontClosePopups)) + { + value_changed = true; + *item.value ^= 1; + } + + PopID(); + } + + EndCombo(); + return value_changed; +} + +// Tip: pass an empty label (e.g. "##dummy") then you can use the space to draw other text or image. +// But you need to make sure the ID is unique, e.g. enclose calls in PushID/PopID. +bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags flags, const ImVec2& size_arg) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsSet) // FIXME-OPT: Avoid if vertically clipped. + PopClipRect(); + + ImGuiID id = window->GetID(label); + ImVec2 label_size = CalcTextSize(label, NULL, true); + ImVec2 size(size_arg.x != 0.0f ? size_arg.x : label_size.x, size_arg.y != 0.0f ? size_arg.y : label_size.y); + ImVec2 pos = window->DC.CursorPos; + pos.y += window->DC.CurrentLineTextBaseOffset; + ImRect bb(pos, pos + size); + ItemSize(bb); + + // Fill horizontal space. + ImVec2 window_padding = window->WindowPadding; + float max_x = (flags & ImGuiSelectableFlags_SpanAllColumns) ? GetWindowContentRegionMax().x : GetContentRegionMax().x; + float w_draw = ImMax(label_size.x, window->Pos.x + max_x - window_padding.x - window->DC.CursorPos.x); + ImVec2 size_draw((size_arg.x != 0 && !(flags & ImGuiSelectableFlags_DrawFillAvailWidth)) ? size_arg.x : w_draw, size_arg.y != 0.0f ? size_arg.y : size.y); + ImRect bb_with_spacing(pos, pos + size_draw); + if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_DrawFillAvailWidth)) + bb_with_spacing.Max.x += window_padding.x; + + // Selectables are tightly packed together, we extend the box to cover spacing between selectable. + float spacing_L = (float)(int)(style.ItemSpacing.x * 0.5f); + float spacing_U = (float)(int)(style.ItemSpacing.y * 0.5f); + float spacing_R = style.ItemSpacing.x - spacing_L; + float spacing_D = style.ItemSpacing.y - spacing_U; + bb_with_spacing.Min.x -= spacing_L; + bb_with_spacing.Min.y -= spacing_U; + bb_with_spacing.Max.x += spacing_R; + bb_with_spacing.Max.y += spacing_D; + if (!ItemAdd(bb_with_spacing, id)) + { + if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsSet) + PushColumnClipRect(); + return false; + } + + ImGuiButtonFlags button_flags = 0; + if (flags & ImGuiSelectableFlags_Menu) button_flags |= ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_NoHoldingActiveID; + if (flags & ImGuiSelectableFlags_MenuItem) button_flags |= ImGuiButtonFlags_PressedOnRelease; + if (flags & ImGuiSelectableFlags_Disabled) button_flags |= ImGuiButtonFlags_Disabled; + if (flags & ImGuiSelectableFlags_AllowDoubleClick) button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick; + bool hovered, held; + bool pressed = ButtonBehavior(bb_with_spacing, id, &hovered, &held, button_flags); + if (flags & ImGuiSelectableFlags_Disabled) + selected = false; + + // Render + if (hovered || selected) + { + const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); + RenderFrame(bb_with_spacing.Min, bb_with_spacing.Max, col, false, 0.0f); + } + + if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsSet) + { + PushColumnClipRect(); + bb_with_spacing.Max.x -= (GetContentRegionMax().x - max_x); + } + + if (flags & ImGuiSelectableFlags_Disabled) PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]); + RenderTextClipped(bb.Min, bb_with_spacing.Max, label, NULL, &label_size, ImVec2(0.0f,0.0f)); + if (flags & ImGuiSelectableFlags_Disabled) PopStyleColor(); + + // Automatically close popups + if (pressed && (window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiSelectableFlags_DontClosePopups) && !(window->DC.ItemFlags & ImGuiItemFlags_SelectableDontClosePopup)) + CloseCurrentPopup(); + return pressed; +} + +bool ImGui::Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags, const ImVec2& size_arg) +{ + if (Selectable(label, *p_selected, flags, size_arg)) + { + *p_selected = !*p_selected; + return true; + } + return false; +} + +// Helper to calculate the size of a listbox and display a label on the right. +// Tip: To have a list filling the entire window width, PushItemWidth(-1) and pass an empty label "##empty" +bool ImGui::ListBoxHeader(const char* label, const ImVec2& size_arg) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + const ImGuiStyle& style = GetStyle(); + const ImGuiID id = GetID(label); + const ImVec2 label_size = CalcTextSize(label, NULL, true); + + // Size default to hold ~7 items. Fractional number of items helps seeing that we can scroll down/up without looking at scrollbar. + ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), GetTextLineHeightWithSpacing() * 7.4f + style.ItemSpacing.y); + ImVec2 frame_size = ImVec2(size.x, ImMax(size.y, label_size.y)); + ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size); + ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); + window->DC.LastItemRect = bb; + + BeginGroup(); + if (label_size.x > 0) + RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); + + BeginChildFrame(id, frame_bb.GetSize()); + return true; +} + +bool ImGui::ListBoxHeader(const char* label, int items_count, int height_in_items) +{ + // Size default to hold ~7 items. Fractional number of items helps seeing that we can scroll down/up without looking at scrollbar. + // However we don't add +0.40f if items_count <= height_in_items. It is slightly dodgy, because it means a dynamic list of items will make the widget resize occasionally when it crosses that size. + // I am expecting that someone will come and complain about this behavior in a remote future, then we can advise on a better solution. + if (height_in_items < 0) + height_in_items = ImMin(items_count, 7); + float height_in_items_f = height_in_items < items_count ? (height_in_items + 0.40f) : (height_in_items + 0.00f); + + // We include ItemSpacing.y so that a list sized for the exact number of items doesn't make a scrollbar appears. We could also enforce that by passing a flag to BeginChild(). + ImVec2 size; + size.x = 0.0f; + size.y = GetTextLineHeightWithSpacing() * height_in_items_f + GetStyle().ItemSpacing.y; + return ListBoxHeader(label, size); +} + +void ImGui::ListBoxFooter() +{ + ImGuiWindow* parent_window = GetCurrentWindow()->ParentWindow; + const ImRect bb = parent_window->DC.LastItemRect; + const ImGuiStyle& style = GetStyle(); + + EndChildFrame(); + + // Redeclare item size so that it includes the label (we have stored the full size in LastItemRect) + // We call SameLine() to restore DC.CurrentLine* data + SameLine(); + parent_window->DC.CursorPos = bb.Min; + ItemSize(bb, style.FramePadding.y); + EndGroup(); +} + +bool ImGui::ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_items) +{ + const bool value_changed = ListBox(label, current_item, Items_ArrayGetter, (void*)items, items_count, height_items); + return value_changed; +} + +bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int height_in_items) +{ + if (!ListBoxHeader(label, items_count, height_in_items)) + return false; + + // Assume all items have even height (= 1 line of text). If you need items of different or variable sizes you can create a custom version of ListBox() in your code without using the clipper. + bool value_changed = false; + ImGuiListClipper clipper(items_count, GetTextLineHeightWithSpacing()); // We know exactly our line height here so we pass it as a minor optimization, but generally you don't need to. + while (clipper.Step()) + for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) + { + const bool item_selected = (i == *current_item); + const char* item_text; + if (!items_getter(data, i, &item_text)) + item_text = "*Unknown item*"; + + PushID(i); + if (Selectable(item_text, item_selected)) + { + *current_item = i; + value_changed = true; + } + PopID(); + } + ListBoxFooter(); + return value_changed; +} + +bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, bool enabled) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + ImGuiStyle& style = g.Style; + ImVec2 pos = window->DC.CursorPos; + ImVec2 label_size = CalcTextSize(label, NULL, true); + + ImGuiSelectableFlags flags = ImGuiSelectableFlags_MenuItem | (enabled ? 0 : ImGuiSelectableFlags_Disabled); + bool pressed; + if (window->DC.LayoutType == ImGuiLayoutType_Horizontal) + { + // Mimic the exact layout spacing of BeginMenu() to allow MenuItem() inside a menu bar, which is a little misleading but may be useful + // Note that in this situation we render neither the shortcut neither the selected tick mark + float w = label_size.x; + window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * 0.5f); + PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing * 2.0f); + pressed = Selectable(label, false, flags, ImVec2(w, 0.0f)); + PopStyleVar(); + window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar(). + } + else + { + ImVec2 shortcut_size = shortcut ? CalcTextSize(shortcut, NULL) : ImVec2(0.0f, 0.0f); + float w = window->MenuColumns.DeclColumns(label_size.x, shortcut_size.x, (float)(int)(g.FontSize * 1.20f)); // Feedback for next frame + float extra_w = ImMax(0.0f, GetContentRegionAvail().x - w); + pressed = Selectable(label, false, flags | ImGuiSelectableFlags_DrawFillAvailWidth, ImVec2(w, 0.0f)); + if (shortcut_size.x > 0.0f) + { + PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]); + RenderText(pos + ImVec2(window->MenuColumns.Pos[1] + extra_w, 0.0f), shortcut, NULL, false); + PopStyleColor(); + } + if (selected) + RenderCheckMark(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.40f, g.FontSize * 0.134f * 0.5f), GetColorU32(enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled), g.FontSize * 0.866f); + } + return pressed; +} + +bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled) +{ + if (MenuItem(label, shortcut, p_selected ? *p_selected : false, enabled)) + { + if (p_selected) + *p_selected = !*p_selected; + return true; + } + return false; +} + +bool ImGui::BeginMainMenuBar() +{ + ImGuiContext& g = *GImGui; + SetNextWindowPos(ImVec2(0.0f, 0.0f)); + SetNextWindowSize(ImVec2(g.IO.DisplaySize.x, g.FontBaseSize + g.Style.FramePadding.y * 2.0f)); + PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); + PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0,0)); + if (!Begin("##MainMenuBar", NULL, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_MenuBar) + || !BeginMenuBar()) + { + End(); + PopStyleVar(2); + return false; + } + g.CurrentWindow->DC.MenuBarOffsetX += g.Style.DisplaySafeAreaPadding.x; + return true; +} + +void ImGui::EndMainMenuBar() +{ + EndMenuBar(); + End(); + PopStyleVar(2); +} + +bool ImGui::BeginMenuBar() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + if (!(window->Flags & ImGuiWindowFlags_MenuBar)) + return false; + + IM_ASSERT(!window->DC.MenuBarAppending); + BeginGroup(); // Save position + PushID("##menubar"); + + // We don't clip with regular window clipping rectangle as it is already set to the area below. However we clip with window full rect. + // We remove 1 worth of rounding to Max.x to that text in long menus don't tend to display over the lower-right rounded area, which looks particularly glitchy. + ImRect bar_rect = window->MenuBarRect(); + ImRect clip_rect(ImFloor(bar_rect.Min.x + 0.5f), ImFloor(bar_rect.Min.y + window->WindowBorderSize + 0.5f), ImFloor(ImMax(bar_rect.Min.x, bar_rect.Max.x - window->WindowRounding) + 0.5f), ImFloor(bar_rect.Max.y + 0.5f)); + clip_rect.ClipWith(window->WindowRectClipped); + PushClipRect(clip_rect.Min, clip_rect.Max, false); + + window->DC.CursorPos = ImVec2(bar_rect.Min.x + window->DC.MenuBarOffsetX, bar_rect.Min.y);// + g.Style.FramePadding.y); + window->DC.LayoutType = ImGuiLayoutType_Horizontal; + window->DC.MenuBarAppending = true; + AlignTextToFramePadding(); + return true; +} + +void ImGui::EndMenuBar() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + IM_ASSERT(window->Flags & ImGuiWindowFlags_MenuBar); + IM_ASSERT(window->DC.MenuBarAppending); + PopClipRect(); + PopID(); + window->DC.MenuBarOffsetX = window->DC.CursorPos.x - window->MenuBarRect().Min.x; + window->DC.GroupStack.back().AdvanceCursor = false; + EndGroup(); + window->DC.LayoutType = ImGuiLayoutType_Vertical; + window->DC.MenuBarAppending = false; +} + +bool ImGui::BeginMenu(const char* label, bool enabled) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + + ImVec2 label_size = CalcTextSize(label, NULL, true); + + bool pressed; + bool menu_is_open = IsPopupOpen(id); + bool menuset_is_open = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].OpenParentId == window->IDStack.back()); + ImGuiWindow* backed_nav_window = g.NavWindow; + if (menuset_is_open) + g.NavWindow = window; // Odd hack to allow hovering across menus of a same menu-set (otherwise we wouldn't be able to hover parent) + + // The reference position stored in popup_pos will be used by Begin() to find a suitable position for the child menu (using FindBestPopupWindowPos). + ImVec2 popup_pos, pos = window->DC.CursorPos; + if (window->DC.LayoutType == ImGuiLayoutType_Horizontal) + { + // Menu inside an horizontal menu bar + // Selectable extend their highlight by half ItemSpacing in each direction. + // For ChildMenu, the popup position will be overwritten by the call to FindBestPopupWindowPos() in Begin() + popup_pos = ImVec2(pos.x - window->WindowPadding.x, pos.y - style.FramePadding.y + window->MenuBarHeight()); + window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * 0.5f); + PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing * 2.0f); + float w = label_size.x; + pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_Menu | ImGuiSelectableFlags_DontClosePopups | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f)); + PopStyleVar(); + window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar(). + } + else + { + // Menu inside a menu + popup_pos = ImVec2(pos.x, pos.y - style.WindowPadding.y); + float w = window->MenuColumns.DeclColumns(label_size.x, 0.0f, (float)(int)(g.FontSize * 1.20f)); // Feedback to next frame + float extra_w = ImMax(0.0f, GetContentRegionAvail().x - w); + pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_Menu | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_DrawFillAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f)); + if (!enabled) PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]); + RenderTriangle(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.30f, 0.0f), ImGuiDir_Right); + if (!enabled) PopStyleColor(); + } + + const bool hovered = enabled && ItemHoverable(window->DC.LastItemRect, id); + if (menuset_is_open) + g.NavWindow = backed_nav_window; + + bool want_open = false, want_close = false; + if (window->DC.LayoutType != ImGuiLayoutType_Horizontal) // (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu)) + { + // Implement http://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown to avoid using timers, so menus feels more reactive. + bool moving_within_opened_triangle = false; + if (g.HoveredWindow == window && g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].ParentWindow == window) + { + if (ImGuiWindow* next_window = g.OpenPopupStack[g.CurrentPopupStack.Size].Window) + { + ImRect next_window_rect = next_window->Rect(); + ImVec2 ta = g.IO.MousePos - g.IO.MouseDelta; + ImVec2 tb = (window->Pos.x < next_window->Pos.x) ? next_window_rect.GetTL() : next_window_rect.GetTR(); + ImVec2 tc = (window->Pos.x < next_window->Pos.x) ? next_window_rect.GetBL() : next_window_rect.GetBR(); + float extra = ImClamp(fabsf(ta.x - tb.x) * 0.30f, 5.0f, 30.0f); // add a bit of extra slack. + ta.x += (window->Pos.x < next_window->Pos.x) ? -0.5f : +0.5f; // to avoid numerical issues + tb.y = ta.y + ImMax((tb.y - extra) - ta.y, -100.0f); // triangle is maximum 200 high to limit the slope and the bias toward large sub-menus // FIXME: Multiply by fb_scale? + tc.y = ta.y + ImMin((tc.y + extra) - ta.y, +100.0f); + moving_within_opened_triangle = ImTriangleContainsPoint(ta, tb, tc, g.IO.MousePos); + //window->DrawList->PushClipRectFullScreen(); window->DrawList->AddTriangleFilled(ta, tb, tc, moving_within_opened_triangle ? IM_COL32(0,128,0,128) : IM_COL32(128,0,0,128)); window->DrawList->PopClipRect(); // Debug + } + } + + want_close = (menu_is_open && !hovered && g.HoveredWindow == window && g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrame != id && !moving_within_opened_triangle); + want_open = (!menu_is_open && hovered && !moving_within_opened_triangle) || (!menu_is_open && hovered && pressed); + } + else + { + // Menu bar + if (menu_is_open && pressed && menuset_is_open) // Click an open menu again to close it + { + want_close = true; + want_open = menu_is_open = false; + } + else if (pressed || (hovered && menuset_is_open && !menu_is_open)) // First click to open, then hover to open others + { + want_open = true; + } + } + + if (!enabled) // explicitly close if an open menu becomes disabled, facilitate users code a lot in pattern such as 'if (BeginMenu("options", has_object)) { ..use object.. }' + want_close = true; + if (want_close && IsPopupOpen(id)) + ClosePopupToLevel(GImGui->CurrentPopupStack.Size); + + if (!menu_is_open && want_open && g.OpenPopupStack.Size > g.CurrentPopupStack.Size) + { + // Don't recycle same menu level in the same frame, first close the other menu and yield for a frame. + OpenPopup(label); + return false; + } + + menu_is_open |= want_open; + if (want_open) + OpenPopup(label); + + if (menu_is_open) + { + SetNextWindowPos(popup_pos, ImGuiCond_Always); + ImGuiWindowFlags flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ((window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu)) ? ImGuiWindowFlags_ChildMenu|ImGuiWindowFlags_ChildWindow : ImGuiWindowFlags_ChildMenu); + menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display) + } + + return menu_is_open; +} + +void ImGui::EndMenu() +{ + EndPopup(); +} + +// Note: only access 3 floats if ImGuiColorEditFlags_NoAlpha flag is set. +void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags) +{ + ImGuiContext& g = *GImGui; + + int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]); + BeginTooltipEx(0, true); + + const char* text_end = text ? FindRenderedTextEnd(text, NULL) : text; + if (text_end > text) + { + TextUnformatted(text, text_end); + Separator(); + } + + ImVec2 sz(g.FontSize * 3 + g.Style.FramePadding.y * 2, g.FontSize * 3 + g.Style.FramePadding.y * 2); + ColorButton("##preview", ImVec4(col[0], col[1], col[2], col[3]), (flags & (ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf)) | ImGuiColorEditFlags_NoTooltip, sz); + SameLine(); + if (flags & ImGuiColorEditFlags_NoAlpha) + Text("#%02X%02X%02X\nR: %d, G: %d, B: %d\n(%.3f, %.3f, %.3f)", cr, cg, cb, cr, cg, cb, col[0], col[1], col[2]); + else + Text("#%02X%02X%02X%02X\nR:%d, G:%d, B:%d, A:%d\n(%.3f, %.3f, %.3f, %.3f)", cr, cg, cb, ca, cr, cg, cb, ca, col[0], col[1], col[2], col[3]); + EndTooltip(); +} + +static inline ImU32 ImAlphaBlendColor(ImU32 col_a, ImU32 col_b) +{ + float t = ((col_b >> IM_COL32_A_SHIFT) & 0xFF) / 255.f; + int r = ImLerp((int)(col_a >> IM_COL32_R_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_R_SHIFT) & 0xFF, t); + int g = ImLerp((int)(col_a >> IM_COL32_G_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_G_SHIFT) & 0xFF, t); + int b = ImLerp((int)(col_a >> IM_COL32_B_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_B_SHIFT) & 0xFF, t); + return IM_COL32(r, g, b, 0xFF); +} + +// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that. +// I spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding alltogether. +void ImGui::RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 col, float grid_step, ImVec2 grid_off, float rounding, int rounding_corners_flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (((col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT) < 0xFF) + { + ImU32 col_bg1 = GetColorU32(ImAlphaBlendColor(IM_COL32(204,204,204,255), col)); + ImU32 col_bg2 = GetColorU32(ImAlphaBlendColor(IM_COL32(128,128,128,255), col)); + window->DrawList->AddRectFilled(p_min, p_max, col_bg1, rounding, rounding_corners_flags); + + int yi = 0; + for (float y = p_min.y + grid_off.y; y < p_max.y; y += grid_step, yi++) + { + float y1 = ImClamp(y, p_min.y, p_max.y), y2 = ImMin(y + grid_step, p_max.y); + if (y2 <= y1) + continue; + for (float x = p_min.x + grid_off.x + (yi & 1) * grid_step; x < p_max.x; x += grid_step * 2.0f) + { + float x1 = ImClamp(x, p_min.x, p_max.x), x2 = ImMin(x + grid_step, p_max.x); + if (x2 <= x1) + continue; + int rounding_corners_flags_cell = 0; + if (y1 <= p_min.y) { if (x1 <= p_min.x) rounding_corners_flags_cell |= ImDrawCornerFlags_TopLeft; if (x2 >= p_max.x) rounding_corners_flags_cell |= ImDrawCornerFlags_TopRight; } + if (y2 >= p_max.y) { if (x1 <= p_min.x) rounding_corners_flags_cell |= ImDrawCornerFlags_BotLeft; if (x2 >= p_max.x) rounding_corners_flags_cell |= ImDrawCornerFlags_BotRight; } + rounding_corners_flags_cell &= rounding_corners_flags; + window->DrawList->AddRectFilled(ImVec2(x1,y1), ImVec2(x2,y2), col_bg2, rounding_corners_flags_cell ? rounding : 0.0f, rounding_corners_flags_cell); + } + } + } + else + { + window->DrawList->AddRectFilled(p_min, p_max, col, rounding, rounding_corners_flags); + } +} + +void ImGui::SetColorEditOptions(ImGuiColorEditFlags flags) +{ + ImGuiContext& g = *GImGui; + if ((flags & ImGuiColorEditFlags__InputsMask) == 0) + flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__InputsMask; + if ((flags & ImGuiColorEditFlags__DataTypeMask) == 0) + flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__DataTypeMask; + if ((flags & ImGuiColorEditFlags__PickerMask) == 0) + flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__PickerMask; + IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__InputsMask))); // Check only 1 option is selected + IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__DataTypeMask))); // Check only 1 option is selected + IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__PickerMask))); // Check only 1 option is selected + g.ColorEditOptions = flags; +} + +// A little colored square. Return true when clicked. +// FIXME: May want to display/ignore the alpha component in the color display? Yet show it in the tooltip. +// 'desc_id' is not called 'label' because we don't display it next to the button, but only in the tooltip. +bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags, ImVec2 size) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiID id = window->GetID(desc_id); + float default_size = GetFrameHeight(); + if (size.x == 0.0f) + size.x = default_size; + if (size.y == 0.0f) + size.y = default_size; + + /*if (flags & ImGuiColorEditFlags_ColorPicker) + window->DC.CursorPos.y += 5;*/ + + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); + ItemSize(bb, (size.y >= default_size) ? g.Style.FramePadding.y : 0.0f); + + //if (!(flags & ImGuiColorEditFlags_ColorPickerSameline)) { + if (!ItemAdd(bb, id)) + return false; + //} + + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held); + + if (flags & ImGuiColorEditFlags_NoAlpha) + flags &= ~(ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf); + + ImVec4 col_without_alpha(col.x, col.y, col.z, 1.0f); + float grid_step = ImMin(size.x, size.y) / 2.99f; + float rounding = ImMin(g.Style.FrameRounding, grid_step * 0.5f); + ImRect bb_inner = bb; + float off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middle ground to reduce those artifacts. + bb_inner.Expand(off); + if ((flags & ImGuiColorEditFlags_AlphaPreviewHalf) && col.w < 1.0f) + { + float mid_x = (float)(int)((bb_inner.Min.x + bb_inner.Max.x) * 0.5f + 0.5f); + RenderColorRectWithAlphaCheckerboard(ImVec2(bb_inner.Min.x + grid_step, bb_inner.Min.y), bb_inner.Max, GetColorU32(col), grid_step, ImVec2(-grid_step + off, off), rounding, ImDrawCornerFlags_TopRight| ImDrawCornerFlags_BotRight); + window->DrawList->AddRectFilled(bb_inner.Min, ImVec2(mid_x, bb_inner.Max.y), GetColorU32(col_without_alpha), rounding, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotLeft); + } + else + { + // Because GetColorU32() multiplies by the global style Alpha and we don't want to display a checkerboard if the source code had no alpha + ImVec4 col_source = (flags & ImGuiColorEditFlags_AlphaPreview) ? col : col_without_alpha; + if (col_source.w < 1.0f) + RenderColorRectWithAlphaCheckerboard(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), grid_step, ImVec2(off, off), rounding); + else + window->DrawList->AddRectFilled(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), rounding, ImDrawCornerFlags_All); + } + if (g.Style.FrameBorderSize > 0.0f) + RenderFrameBorder(bb.Min, bb.Max, rounding); + else + window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), rounding); // Color button are often in need of some sort of border + + // Drag and Drop Source + if (g.ActiveId == id && BeginDragDropSource()) // NB: The ActiveId test is merely an optional micro-optimization + { + if (flags & ImGuiColorEditFlags_NoAlpha) + SetDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F, &col, sizeof(float) * 3, ImGuiCond_Once); + else + SetDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F, &col, sizeof(float) * 4, ImGuiCond_Once); + ColorButton(desc_id, col, flags); + SameLine(); + TextUnformatted("Color"); + EndDragDropSource(); + hovered = false; + } + + // Tooltip + if (!(flags & ImGuiColorEditFlags_NoTooltip) && hovered) + ColorTooltip(desc_id, &col.x, flags & (ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf)); + + return pressed; +} + +bool ImGui::ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags) +{ + return ColorEdit4(label, col, flags | ImGuiColorEditFlags_NoAlpha); +} + +void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags) +{ + bool allow_opt_inputs = !(flags & ImGuiColorEditFlags__InputsMask); + bool allow_opt_datatype = !(flags & ImGuiColorEditFlags__DataTypeMask); + if ((!allow_opt_inputs && !allow_opt_datatype) || !BeginPopup("context")) + return; + ImGuiContext& g = *GImGui; + ImGuiColorEditFlags opts = g.ColorEditOptions; + if (allow_opt_inputs) + { + if (RadioButton("RGB", (opts & ImGuiColorEditFlags_RGB) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__InputsMask) | ImGuiColorEditFlags_RGB; + if (RadioButton("HSV", (opts & ImGuiColorEditFlags_HSV) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__InputsMask) | ImGuiColorEditFlags_HSV; + if (RadioButton("HEX", (opts & ImGuiColorEditFlags_HEX) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__InputsMask) | ImGuiColorEditFlags_HEX; + } + if (allow_opt_datatype) + { + if (allow_opt_inputs) Separator(); + if (RadioButton("0..255", (opts & ImGuiColorEditFlags_Uint8) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__DataTypeMask) | ImGuiColorEditFlags_Uint8; + if (RadioButton("0.00..1.00", (opts & ImGuiColorEditFlags_Float) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__DataTypeMask) | ImGuiColorEditFlags_Float; + } + + if (allow_opt_inputs || allow_opt_datatype) + Separator(); + if (Button("Copy as..", ImVec2(-1,0))) + OpenPopup("Copy"); + if (BeginPopup("Copy")) + { + int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]); + char buf[64]; + ImFormatString(buf, IM_ARRAYSIZE(buf), "(%.3ff, %.3ff, %.3ff, %.3ff)", col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]); + if (Selectable(buf)) + SetClipboardText(buf); + ImFormatString(buf, IM_ARRAYSIZE(buf), "(%d,%d,%d,%d)", cr, cg, cb, ca); + if (Selectable(buf)) + SetClipboardText(buf); + if (flags & ImGuiColorEditFlags_NoAlpha) + ImFormatString(buf, IM_ARRAYSIZE(buf), "0x%02X%02X%02X", cr, cg, cb); + else + ImFormatString(buf, IM_ARRAYSIZE(buf), "0x%02X%02X%02X%02X", cr, cg, cb, ca); + if (Selectable(buf)) + SetClipboardText(buf); + EndPopup(); + } + + g.ColorEditOptions = opts; + EndPopup(); +} + +static void ColorPickerOptionsPopup(ImGuiColorEditFlags flags, const float* ref_col) +{ + bool allow_opt_picker = !(flags & ImGuiColorEditFlags__PickerMask); + bool allow_opt_alpha_bar = !(flags & ImGuiColorEditFlags_NoAlpha) && !(flags & ImGuiColorEditFlags_AlphaBar); + if ((!allow_opt_picker && !allow_opt_alpha_bar) || !ImGui::BeginPopup("context")) + return; + ImGuiContext& g = *GImGui; + if (allow_opt_picker) + { + ImVec2 picker_size(g.FontSize * 8, ImMax(g.FontSize * 8 - (ImGui::GetFrameHeight() + g.Style.ItemInnerSpacing.x), 1.0f)); // FIXME: Picker size copied from main picker function + ImGui::PushItemWidth(picker_size.x); + for (int picker_type = 0; picker_type < 2; picker_type++) + { + // Draw small/thumbnail version of each picker type (over an invisible button for selection) + if (picker_type > 0) ImGui::Separator(); + ImGui::PushID(picker_type); + ImGuiColorEditFlags picker_flags = ImGuiColorEditFlags_NoInputs|ImGuiColorEditFlags_NoOptions|ImGuiColorEditFlags_NoLabel|ImGuiColorEditFlags_NoSidePreview|(flags & ImGuiColorEditFlags_NoAlpha); + if (picker_type == 0) picker_flags |= ImGuiColorEditFlags_PickerHueBar; + if (picker_type == 1) picker_flags |= ImGuiColorEditFlags_PickerHueWheel; + ImVec2 backup_pos = ImGui::GetCursorScreenPos(); + if (ImGui::Selectable("##selectable", false, 0, picker_size)) // By default, Selectable() is closing popup + g.ColorEditOptions = (g.ColorEditOptions & ~ImGuiColorEditFlags__PickerMask) | (picker_flags & ImGuiColorEditFlags__PickerMask); + ImGui::SetCursorScreenPos(backup_pos); + ImVec4 dummy_ref_col; + memcpy(&dummy_ref_col.x, ref_col, sizeof(float) * (picker_flags & ImGuiColorEditFlags_NoAlpha ? 3 : 4)); + ImGui::ColorPicker4("##dummypicker", &dummy_ref_col.x, picker_flags); + ImGui::PopID(); + } + ImGui::PopItemWidth(); + } + if (allow_opt_alpha_bar) + { + if (allow_opt_picker) ImGui::Separator(); + ImGui::CheckboxFlags("Alpha Bar", (unsigned int*)&g.ColorEditOptions, ImGuiColorEditFlags_AlphaBar); + } + ImGui::EndPopup(); +} + +// Edit colors components (each component in 0.0f..1.0f range). +// See enum ImGuiColorEditFlags_ for available options. e.g. Only access 3 floats if ImGuiColorEditFlags_NoAlpha flag is set. +// With typical options: Left-click on colored square to open color picker. Right-click to open option menu. CTRL-Click over input fields to edit them and TAB to go to next item. +bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const float square_sz = GetFrameHeight(); + const float w_extra = (flags & ImGuiColorEditFlags_NoSmallPreview) ? 0.0f : (square_sz + style.ItemInnerSpacing.x); + const float w_items_all = CalcItemWidth() - w_extra; + const char* label_display_end = FindRenderedTextEnd(label); + + const bool alpha = (flags & ImGuiColorEditFlags_NoAlpha) == 0; + const bool hdr = (flags & ImGuiColorEditFlags_HDR) != 0; + const int components = alpha ? 4 : 3; + const ImGuiColorEditFlags flags_untouched = flags; + + BeginGroup(); + PushID(label); + + // If we're not showing any slider there's no point in doing any HSV conversions + if (flags & ImGuiColorEditFlags_NoInputs) + flags = (flags & (~ImGuiColorEditFlags__InputsMask)) | ImGuiColorEditFlags_RGB | ImGuiColorEditFlags_NoOptions; + + // Context menu: display and modify options (before defaults are applied) + if (!(flags & ImGuiColorEditFlags_NoOptions)) + ColorEditOptionsPopup(col, flags); + + // Read stored options + if (!(flags & ImGuiColorEditFlags__InputsMask)) + flags |= (g.ColorEditOptions & ImGuiColorEditFlags__InputsMask); + if (!(flags & ImGuiColorEditFlags__DataTypeMask)) + flags |= (g.ColorEditOptions & ImGuiColorEditFlags__DataTypeMask); + if (!(flags & ImGuiColorEditFlags__PickerMask)) + flags |= (g.ColorEditOptions & ImGuiColorEditFlags__PickerMask); + flags |= (g.ColorEditOptions & ~(ImGuiColorEditFlags__InputsMask | ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask)); + + // Convert to the formats we need + float f[4] = { col[0], col[1], col[2], alpha ? col[3] : 1.0f }; + if (flags & ImGuiColorEditFlags_HSV) + ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]); + int i[4] = { IM_F32_TO_INT8_UNBOUND(f[0]), IM_F32_TO_INT8_UNBOUND(f[1]), IM_F32_TO_INT8_UNBOUND(f[2]), IM_F32_TO_INT8_UNBOUND(f[3]) }; + + bool value_changed = false; + bool value_changed_as_float = false; + + if ((flags & (ImGuiColorEditFlags_RGB | ImGuiColorEditFlags_HSV)) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0) + { + // RGB/HSV 0..255 Sliders + const float w_item_one = ImMax(1.0f, (float)(int)((w_items_all - (style.ItemInnerSpacing.x) * (components-1)) / (float)components)); + const float w_item_last = ImMax(1.0f, (float)(int)(w_items_all - (w_item_one + style.ItemInnerSpacing.x) * (components-1))); + + const bool hide_prefix = (w_item_one <= CalcTextSize((flags & ImGuiColorEditFlags_Float) ? "M:0.000" : "M:000").x); + const char* ids[4] = { "##X", "##Y", "##Z", "##W" }; + const char* fmt_table_int[3][4] = + { + { "%3.0f", "%3.0f", "%3.0f", "%3.0f" }, // Short display + { "R:%3.0f", "G:%3.0f", "B:%3.0f", "A:%3.0f" }, // Long display for RGBA + { "H:%3.0f", "S:%3.0f", "V:%3.0f", "A:%3.0f" } // Long display for HSVA + }; + const char* fmt_table_float[3][4] = + { + { "%0.3f", "%0.3f", "%0.3f", "%0.3f" }, // Short display + { "R:%0.3f", "G:%0.3f", "B:%0.3f", "A:%0.3f" }, // Long display for RGBA + { "H:%0.3f", "S:%0.3f", "V:%0.3f", "A:%0.3f" } // Long display for HSVA + }; + const int fmt_idx = hide_prefix ? 0 : (flags & ImGuiColorEditFlags_HSV) ? 2 : 1; + + PushItemWidth(w_item_one); + for (int n = 0; n < components; n++) + { + if (n > 0) + SameLine(0, style.ItemInnerSpacing.x); + if (n + 1 == components) + PushItemWidth(w_item_last); + if (flags & ImGuiColorEditFlags_Float) + value_changed = value_changed_as_float = value_changed | DragFloat(ids[n], &f[n], 1.0f/255.0f, 0.0f, hdr ? 0.0f : 1.0f, fmt_table_float[fmt_idx][n]); + else + value_changed |= DragInt(ids[n], &i[n], 1.0f, 0, hdr ? 0 : 255, fmt_table_int[fmt_idx][n]); + if (!(flags & ImGuiColorEditFlags_NoOptions)) + OpenPopupOnItemClick("context"); + } + PopItemWidth(); + PopItemWidth(); + } + else if ((flags & ImGuiColorEditFlags_HEX) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0) + { + // RGB Hexadecimal Input + char buf[64]; + if (alpha) + ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X%02X", ImClamp(i[0],0,255), ImClamp(i[1],0,255), ImClamp(i[2],0,255), ImClamp(i[3],0,255)); + else + ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", ImClamp(i[0],0,255), ImClamp(i[1],0,255), ImClamp(i[2],0,255)); + PushItemWidth(w_items_all); + if (InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase)) + { + value_changed = true; + char* p = buf; + while (*p == '#' || ImCharIsSpace(*p)) + p++; + i[0] = i[1] = i[2] = i[3] = 0; + if (alpha) + sscanf(p, "%02X%02X%02X%02X", (unsigned int*)&i[0], (unsigned int*)&i[1], (unsigned int*)&i[2], (unsigned int*)&i[3]); // Treat at unsigned (%X is unsigned) + else + sscanf(p, "%02X%02X%02X", (unsigned int*)&i[0], (unsigned int*)&i[1], (unsigned int*)&i[2]); + } + if (!(flags & ImGuiColorEditFlags_NoOptions)) + OpenPopupOnItemClick("context"); + PopItemWidth(); + } + + ImGuiWindow* picker_active_window = NULL; + if (!(flags & ImGuiColorEditFlags_NoSmallPreview)) + { + if (!(flags & ImGuiColorEditFlags_NoInputs)) + SameLine(0, style.ItemInnerSpacing.x); + + const ImVec4 col_v4(col[0], col[1], col[2], alpha ? col[3] : 1.0f); + if (ColorButton("##ColorButton", col_v4, flags)) + { + if (!(flags & ImGuiColorEditFlags_NoPicker)) + { + // Store current color and open a picker + g.ColorPickerRef = col_v4; + OpenPopup("picker"); + SetNextWindowPos(window->DC.LastItemRect.GetBL() + ImVec2(-1,style.ItemSpacing.y)); + } + } + if (!(flags & ImGuiColorEditFlags_NoOptions)) + OpenPopupOnItemClick("context"); + + if (BeginPopup("picker")) + { + picker_active_window = g.CurrentWindow; + if (label != label_display_end) + { + TextUnformatted(label, label_display_end); + Separator(); + } + ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar; + ImGuiColorEditFlags picker_flags = (flags_untouched & picker_flags_to_forward) | ImGuiColorEditFlags__InputsMask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf; + PushItemWidth(square_sz * 12.0f); // Use 256 + bar sizes? + value_changed |= ColorPicker4("##picker", col, picker_flags, &g.ColorPickerRef.x); + PopItemWidth(); + EndPopup(); + } + } + + if (label != label_display_end && !(flags & ImGuiColorEditFlags_NoLabel)) + { + SameLine(0, style.ItemInnerSpacing.x); + TextUnformatted(label, label_display_end); + } + + // Convert back + if (picker_active_window == NULL) + { + if (!value_changed_as_float) + for (int n = 0; n < 4; n++) + f[n] = i[n] / 255.0f; + if (flags & ImGuiColorEditFlags_HSV) + ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]); + if (value_changed) + { + col[0] = f[0]; + col[1] = f[1]; + col[2] = f[2]; + if (alpha) + col[3] = f[3]; + } + } + + PopID(); + EndGroup(); + + // Drag and Drop Target + if (window->DC.LastItemRectHoveredRect && BeginDragDropTarget()) // NB: The LastItemRectHoveredRect test is merely an optional micro-optimization + { + if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F)) + { + memcpy((float*)col, payload->Data, sizeof(float) * 3); + value_changed = true; + } + if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F)) + { + memcpy((float*)col, payload->Data, sizeof(float) * components); + value_changed = true; + } + EndDragDropTarget(); + } + + // When picker is being actively used, use its active id so IsItemActive() will function on ColorEdit4(). + if (picker_active_window && g.ActiveId != 0 && g.ActiveIdWindow == picker_active_window) + window->DC.LastItemId = g.ActiveId; + + return value_changed; +} + +bool ImGui::ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags) +{ + float col4[4] = { col[0], col[1], col[2], 1.0f }; + if (!ColorPicker4(label, col4, flags | ImGuiColorEditFlags_NoAlpha)) + return false; + col[0] = col4[0]; col[1] = col4[1]; col[2] = col4[2]; + return true; +} + +// 'pos' is position of the arrow tip. half_sz.x is length from base to tip. half_sz.y is length on each side. +static void RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col) +{ + switch (direction) + { + case ImGuiDir_Left: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), pos, col); return; + case ImGuiDir_Right: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), pos, col); return; + case ImGuiDir_Up: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), pos, col); return; + case ImGuiDir_Down: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), pos, col); return; + case ImGuiDir_None: case ImGuiDir_Count_: break; // Fix warnings + } +} + +static void RenderArrowsForVerticalBar(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, float bar_w) +{ + RenderArrow(draw_list, ImVec2(pos.x + half_sz.x + 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Right, IM_COL32_BLACK); + RenderArrow(draw_list, ImVec2(pos.x + half_sz.x, pos.y), half_sz, ImGuiDir_Right, IM_COL32_WHITE); + RenderArrow(draw_list, ImVec2(pos.x + bar_w - half_sz.x - 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Left, IM_COL32_BLACK); + RenderArrow(draw_list, ImVec2(pos.x + bar_w - half_sz.x, pos.y), half_sz, ImGuiDir_Left, IM_COL32_WHITE); +} + +// ColorPicker +// Note: only access 3 floats if ImGuiColorEditFlags_NoAlpha flag is set. +// FIXME: we adjust the big color square height based on item width, which may cause a flickering feedback loop (if automatic height makes a vertical scrollbar appears, affecting automatic width..) +bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags, const float* ref_col) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + ImDrawList* draw_list = window->DrawList; + + ImGuiStyle& style = g.Style; + ImGuiIO& io = g.IO; + + PushID(label); + BeginGroup(); + + if (!(flags & ImGuiColorEditFlags_NoSidePreview)) + flags |= ImGuiColorEditFlags_NoSmallPreview; + + // Context menu: display and store options. + if (!(flags & ImGuiColorEditFlags_NoOptions)) + ColorPickerOptionsPopup(flags, col); + + // Read stored options + if (!(flags & ImGuiColorEditFlags__PickerMask)) + flags |= ((g.ColorEditOptions & ImGuiColorEditFlags__PickerMask) ? g.ColorEditOptions : ImGuiColorEditFlags__OptionsDefault) & ImGuiColorEditFlags__PickerMask; + IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__PickerMask))); // Check that only 1 is selected + if (!(flags & ImGuiColorEditFlags_NoOptions)) + flags |= (g.ColorEditOptions & ImGuiColorEditFlags_AlphaBar); + + // Setup + int components = (flags & ImGuiColorEditFlags_NoAlpha) ? 3 : 4; + bool alpha_bar = (flags & ImGuiColorEditFlags_AlphaBar) && !(flags & ImGuiColorEditFlags_NoAlpha); + ImVec2 picker_pos = window->DC.CursorPos; + float square_sz = GetFrameHeight(); + float bars_width = square_sz; // Arbitrary smallish width of Hue/Alpha picking bars + float sv_picker_size = ImMax(bars_width * 1, CalcItemWidth() - (alpha_bar ? 2 : 1) * (bars_width + style.ItemInnerSpacing.x)); // Saturation/Value picking box + float bar0_pos_x = picker_pos.x + sv_picker_size + style.ItemInnerSpacing.x; + float bar1_pos_x = bar0_pos_x + bars_width + style.ItemInnerSpacing.x; + float bars_triangles_half_sz = (float)(int)(bars_width * 0.20f); + + float backup_initial_col[4]; + memcpy(backup_initial_col, col, components * sizeof(float)); + + float wheel_thickness = sv_picker_size * 0.08f; + float wheel_r_outer = sv_picker_size * 0.50f; + float wheel_r_inner = wheel_r_outer - wheel_thickness; + ImVec2 wheel_center(picker_pos.x + (sv_picker_size + bars_width)*0.5f, picker_pos.y + sv_picker_size*0.5f); + + // Note: the triangle is displayed rotated with triangle_pa pointing to Hue, but most coordinates stays unrotated for logic. + float triangle_r = wheel_r_inner - (int)(sv_picker_size * 0.027f); + ImVec2 triangle_pa = ImVec2(triangle_r, 0.0f); // Hue point. + ImVec2 triangle_pb = ImVec2(triangle_r * -0.5f, triangle_r * -0.866025f); // Black point. + ImVec2 triangle_pc = ImVec2(triangle_r * -0.5f, triangle_r * +0.866025f); // White point. + + float H,S,V; + ColorConvertRGBtoHSV(col[0], col[1], col[2], H, S, V); + + bool value_changed = false, value_changed_h = false, value_changed_sv = false; + + if (flags & ImGuiColorEditFlags_PickerHueWheel) + { + // Hue wheel + SV triangle logic + InvisibleButton("hsv", ImVec2(sv_picker_size + style.ItemInnerSpacing.x + bars_width, sv_picker_size)); + if (IsItemActive()) + { + ImVec2 initial_off = g.IO.MouseClickedPos[0] - wheel_center; + ImVec2 current_off = g.IO.MousePos - wheel_center; + float initial_dist2 = ImLengthSqr(initial_off); + if (initial_dist2 >= (wheel_r_inner-1)*(wheel_r_inner-1) && initial_dist2 <= (wheel_r_outer+1)*(wheel_r_outer+1)) + { + // Interactive with Hue wheel + H = atan2f(current_off.y, current_off.x) / IM_PI*0.5f; + if (H < 0.0f) + H += 1.0f; + value_changed = value_changed_h = true; + } + float cos_hue_angle = cosf(-H * 2.0f * IM_PI); + float sin_hue_angle = sinf(-H * 2.0f * IM_PI); + if (ImTriangleContainsPoint(triangle_pa, triangle_pb, triangle_pc, ImRotate(initial_off, cos_hue_angle, sin_hue_angle))) + { + // Interacting with SV triangle + ImVec2 current_off_unrotated = ImRotate(current_off, cos_hue_angle, sin_hue_angle); + if (!ImTriangleContainsPoint(triangle_pa, triangle_pb, triangle_pc, current_off_unrotated)) + current_off_unrotated = ImTriangleClosestPoint(triangle_pa, triangle_pb, triangle_pc, current_off_unrotated); + float uu, vv, ww; + ImTriangleBarycentricCoords(triangle_pa, triangle_pb, triangle_pc, current_off_unrotated, uu, vv, ww); + V = ImClamp(1.0f - vv, 0.0001f, 1.0f); + S = ImClamp(uu / V, 0.0001f, 1.0f); + value_changed = value_changed_sv = true; + } + } + if (!(flags & ImGuiColorEditFlags_NoOptions)) + OpenPopupOnItemClick("context"); + } + else if (flags & ImGuiColorEditFlags_PickerHueBar) + { + // SV rectangle logic + InvisibleButton("sv", ImVec2(sv_picker_size, sv_picker_size)); + if (IsItemActive()) + { + S = ImSaturate((io.MousePos.x - picker_pos.x) / (sv_picker_size-1)); + V = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size-1)); + value_changed = value_changed_sv = true; + } + if (!(flags & ImGuiColorEditFlags_NoOptions)) + OpenPopupOnItemClick("context"); + + // Hue bar logic + SetCursorScreenPos(ImVec2(bar0_pos_x, picker_pos.y)); + InvisibleButton("hue", ImVec2(bars_width, sv_picker_size)); + if (IsItemActive()) + { + H = ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size-1)); + value_changed = value_changed_h = true; + } + } + + // Alpha bar logic + if (alpha_bar) + { + SetCursorScreenPos(ImVec2(bar1_pos_x, picker_pos.y)); + InvisibleButton("alpha", ImVec2(bars_width, sv_picker_size)); + if (IsItemActive()) + { + col[3] = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size-1)); + value_changed = true; + } + } + + if (!(flags & ImGuiColorEditFlags_NoSidePreview)) + { + SameLine(0, style.ItemInnerSpacing.x); + BeginGroup(); + } + + if (!(flags & ImGuiColorEditFlags_NoLabel)) + { + const char* label_display_end = FindRenderedTextEnd(label); + if (label != label_display_end) + { + if ((flags & ImGuiColorEditFlags_NoSidePreview)) + SameLine(0, style.ItemInnerSpacing.x); + TextUnformatted(label, label_display_end); + } + } + + if (!(flags & ImGuiColorEditFlags_NoSidePreview)) + { + ImVec4 col_v4(col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]); + if ((flags & ImGuiColorEditFlags_NoLabel)) + Text("Current"); + ColorButton("##current", col_v4, (flags & (ImGuiColorEditFlags_HDR|ImGuiColorEditFlags_AlphaPreview|ImGuiColorEditFlags_AlphaPreviewHalf|ImGuiColorEditFlags_NoTooltip)), ImVec2(square_sz * 3, square_sz * 2)); + if (ref_col != NULL) + { + Text("Original"); + ImVec4 ref_col_v4(ref_col[0], ref_col[1], ref_col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : ref_col[3]); + if (ColorButton("##original", ref_col_v4, (flags & (ImGuiColorEditFlags_HDR|ImGuiColorEditFlags_AlphaPreview|ImGuiColorEditFlags_AlphaPreviewHalf|ImGuiColorEditFlags_NoTooltip)), ImVec2(square_sz * 3, square_sz * 2))) + { + memcpy(col, ref_col, components * sizeof(float)); + value_changed = true; + } + } + EndGroup(); + } + + // Convert back color to RGB + if (value_changed_h || value_changed_sv) + ColorConvertHSVtoRGB(H >= 1.0f ? H - 10 * 1e-6f : H, S > 0.0f ? S : 10*1e-6f, V > 0.0f ? V : 1e-6f, col[0], col[1], col[2]); + + // R,G,B and H,S,V slider color editor + if ((flags & ImGuiColorEditFlags_NoInputs) == 0) + { + PushItemWidth((alpha_bar ? bar1_pos_x : bar0_pos_x) + bars_width - picker_pos.x); + ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoSmallPreview | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf; + ImGuiColorEditFlags sub_flags = (flags & sub_flags_to_forward) | ImGuiColorEditFlags_NoPicker; + if (flags & ImGuiColorEditFlags_RGB || (flags & ImGuiColorEditFlags__InputsMask) == 0) + value_changed |= ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_RGB); + if (flags & ImGuiColorEditFlags_HSV || (flags & ImGuiColorEditFlags__InputsMask) == 0) + value_changed |= ColorEdit4("##hsv", col, sub_flags | ImGuiColorEditFlags_HSV); + if (flags & ImGuiColorEditFlags_HEX || (flags & ImGuiColorEditFlags__InputsMask) == 0) + value_changed |= ColorEdit4("##hex", col, sub_flags | ImGuiColorEditFlags_HEX); + PopItemWidth(); + } + + // Try to cancel hue wrap (after ColorEdit), if any + if (value_changed) + { + float new_H, new_S, new_V; + ColorConvertRGBtoHSV(col[0], col[1], col[2], new_H, new_S, new_V); + if (new_H <= 0 && H > 0) + { + if (new_V <= 0 && V != new_V) + ColorConvertHSVtoRGB(H, S, new_V <= 0 ? V * 0.5f : new_V, col[0], col[1], col[2]); + else if (new_S <= 0) + ColorConvertHSVtoRGB(H, new_S <= 0 ? S * 0.5f : new_S, new_V, col[0], col[1], col[2]); + } + } + + ImVec4 hue_color_f(1, 1, 1, 1); ColorConvertHSVtoRGB(H, 1, 1, hue_color_f.x, hue_color_f.y, hue_color_f.z); + ImU32 hue_color32 = ColorConvertFloat4ToU32(hue_color_f); + ImU32 col32_no_alpha = ColorConvertFloat4ToU32(ImVec4(col[0], col[1], col[2], 1.0f)); + + const ImU32 hue_colors[6+1] = { IM_COL32(255,0,0,255), IM_COL32(255,255,0,255), IM_COL32(0,255,0,255), IM_COL32(0,255,255,255), IM_COL32(0,0,255,255), IM_COL32(255,0,255,255), IM_COL32(255,0,0,255) }; + ImVec2 sv_cursor_pos; + + if (flags & ImGuiColorEditFlags_PickerHueWheel) + { + // Render Hue Wheel + const float aeps = 1.5f / wheel_r_outer; // Half a pixel arc length in radians (2pi cancels out). + const int segment_per_arc = ImMax(4, (int)wheel_r_outer / 12); + for (int n = 0; n < 6; n++) + { + const float a0 = (n) /6.0f * 2.0f * IM_PI - aeps; + const float a1 = (n+1.0f)/6.0f * 2.0f * IM_PI + aeps; + const int vert_start_idx = draw_list->VtxBuffer.Size; + draw_list->PathArcTo(wheel_center, (wheel_r_inner + wheel_r_outer)*0.5f, a0, a1, segment_per_arc); + draw_list->PathStroke(IM_COL32_WHITE, false, wheel_thickness); + const int vert_end_idx = draw_list->VtxBuffer.Size; + + // Paint colors over existing vertices + ImVec2 gradient_p0(wheel_center.x + cosf(a0) * wheel_r_inner, wheel_center.y + sinf(a0) * wheel_r_inner); + ImVec2 gradient_p1(wheel_center.x + cosf(a1) * wheel_r_inner, wheel_center.y + sinf(a1) * wheel_r_inner); + ShadeVertsLinearColorGradientKeepAlpha(draw_list->VtxBuffer.Data + vert_start_idx, draw_list->VtxBuffer.Data + vert_end_idx, gradient_p0, gradient_p1, hue_colors[n], hue_colors[n+1]); + } + + // Render Cursor + preview on Hue Wheel + float cos_hue_angle = cosf(H * 2.0f * IM_PI); + float sin_hue_angle = sinf(H * 2.0f * IM_PI); + ImVec2 hue_cursor_pos(wheel_center.x + cos_hue_angle * (wheel_r_inner+wheel_r_outer)*0.5f, wheel_center.y + sin_hue_angle * (wheel_r_inner+wheel_r_outer)*0.5f); + float hue_cursor_rad = value_changed_h ? wheel_thickness * 0.65f : wheel_thickness * 0.55f; + int hue_cursor_segments = ImClamp((int)(hue_cursor_rad / 1.4f), 9, 32); + draw_list->AddCircleFilled(hue_cursor_pos, hue_cursor_rad, hue_color32, hue_cursor_segments); + draw_list->AddCircle(hue_cursor_pos, hue_cursor_rad+1, IM_COL32(128,128,128,255), hue_cursor_segments); + draw_list->AddCircle(hue_cursor_pos, hue_cursor_rad, IM_COL32_WHITE, hue_cursor_segments); + + // Render SV triangle (rotated according to hue) + ImVec2 tra = wheel_center + ImRotate(triangle_pa, cos_hue_angle, sin_hue_angle); + ImVec2 trb = wheel_center + ImRotate(triangle_pb, cos_hue_angle, sin_hue_angle); + ImVec2 trc = wheel_center + ImRotate(triangle_pc, cos_hue_angle, sin_hue_angle); + ImVec2 uv_white = GetFontTexUvWhitePixel(); + draw_list->PrimReserve(6, 6); + draw_list->PrimVtx(tra, uv_white, hue_color32); + draw_list->PrimVtx(trb, uv_white, hue_color32); + draw_list->PrimVtx(trc, uv_white, IM_COL32_WHITE); + draw_list->PrimVtx(tra, uv_white, IM_COL32_BLACK_TRANS); + draw_list->PrimVtx(trb, uv_white, IM_COL32_BLACK); + draw_list->PrimVtx(trc, uv_white, IM_COL32_BLACK_TRANS); + draw_list->AddTriangle(tra, trb, trc, IM_COL32(128,128,128,255), 1.5f); + sv_cursor_pos = ImLerp(ImLerp(trc, tra, ImSaturate(S)), trb, ImSaturate(1 - V)); + } + else if (flags & ImGuiColorEditFlags_PickerHueBar) + { + // Render SV Square + draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size,sv_picker_size), IM_COL32_WHITE, hue_color32, hue_color32, IM_COL32_WHITE); + draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size,sv_picker_size), IM_COL32_BLACK_TRANS, IM_COL32_BLACK_TRANS, IM_COL32_BLACK, IM_COL32_BLACK); + RenderFrameBorder(picker_pos, picker_pos + ImVec2(sv_picker_size,sv_picker_size), 0.0f); + sv_cursor_pos.x = ImClamp((float)(int)(picker_pos.x + ImSaturate(S) * sv_picker_size + 0.5f), picker_pos.x + 2, picker_pos.x + sv_picker_size - 2); // Sneakily prevent the circle to stick out too much + sv_cursor_pos.y = ImClamp((float)(int)(picker_pos.y + ImSaturate(1 - V) * sv_picker_size + 0.5f), picker_pos.y + 2, picker_pos.y + sv_picker_size - 2); + + // Render Hue Bar + for (int i = 0; i < 6; ++i) + draw_list->AddRectFilledMultiColor(ImVec2(bar0_pos_x, picker_pos.y + i * (sv_picker_size / 6)), ImVec2(bar0_pos_x + bars_width, picker_pos.y + (i + 1) * (sv_picker_size / 6)), hue_colors[i], hue_colors[i], hue_colors[i + 1], hue_colors[i + 1]); + float bar0_line_y = (float)(int)(picker_pos.y + H * sv_picker_size + 0.5f); + RenderFrameBorder(ImVec2(bar0_pos_x, picker_pos.y), ImVec2(bar0_pos_x + bars_width, picker_pos.y + sv_picker_size), 0.0f); + RenderArrowsForVerticalBar(draw_list, ImVec2(bar0_pos_x - 1, bar0_line_y), ImVec2(bars_triangles_half_sz + 1, bars_triangles_half_sz), bars_width + 2.0f); + } + + // Render cursor/preview circle (clamp S/V within 0..1 range because floating points colors may lead HSV values to be out of range) + float sv_cursor_rad = value_changed_sv ? 10.0f : 6.0f; + draw_list->AddCircleFilled(sv_cursor_pos, sv_cursor_rad, col32_no_alpha, 12); + draw_list->AddCircle(sv_cursor_pos, sv_cursor_rad+1, IM_COL32(128,128,128,255), 12); + draw_list->AddCircle(sv_cursor_pos, sv_cursor_rad, IM_COL32_WHITE, 12); + + // Render alpha bar + if (alpha_bar) + { + float alpha = ImSaturate(col[3]); + ImRect bar1_bb(bar1_pos_x, picker_pos.y, bar1_pos_x + bars_width, picker_pos.y + sv_picker_size); + RenderColorRectWithAlphaCheckerboard(bar1_bb.Min, bar1_bb.Max, IM_COL32(0,0,0,0), bar1_bb.GetWidth() / 2.0f, ImVec2(0.0f, 0.0f)); + draw_list->AddRectFilledMultiColor(bar1_bb.Min, bar1_bb.Max, col32_no_alpha, col32_no_alpha, col32_no_alpha & ~IM_COL32_A_MASK, col32_no_alpha & ~IM_COL32_A_MASK); + float bar1_line_y = (float)(int)(picker_pos.y + (1.0f - alpha) * sv_picker_size + 0.5f); + RenderFrameBorder(bar1_bb.Min, bar1_bb.Max, 0.0f); + RenderArrowsForVerticalBar(draw_list, ImVec2(bar1_pos_x - 1, bar1_line_y), ImVec2(bars_triangles_half_sz + 1, bars_triangles_half_sz), bars_width + 2.0f); + } + + EndGroup(); + PopID(); + + return value_changed && memcmp(backup_initial_col, col, components * sizeof(float)); +} + +bool ImGui::ColorPicker(const char* label, float* col, ImGuiColorEditFlags extra_flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + ImDrawList* draw_list = window->DrawList; + + ImGuiStyle& style = g.Style; + ImGuiIO& io = g.IO; + + const int EDGE_SIZE = 200; // = int( ImGui::GetWindowWidth() * 0.75f ); + const ImVec2 SV_PICKER_SIZE = ImVec2(EDGE_SIZE, EDGE_SIZE); + const float SPACING = ImGui::GetStyle().ItemInnerSpacing.x; + const float HUE_PICKER_WIDTH = 20.f; + const float CROSSHAIR_SIZE = 7.0f; + + ImColor color(col[0], col[1], col[2], col[3]); + bool value_changed = false; + + // setup + + bool alpha_bar = (extra_flags & ImGuiColorEditFlags_AlphaBar) && !(extra_flags & ImGuiColorEditFlags_NoAlpha); + + ImVec2 picker_pos = ImGui::GetCursorScreenPos(); + float square_sz = SmallSquareSize(); + float bars_width = square_sz; // Arbitrary smallish width of Hue/Alpha picking bars + //float sv_picker_size = ImMax(bars_width * 1, CalcItemWidth() - (alpha_bar ? 2 : 1) * (bars_width + style.ItemInnerSpacing.x)); // Saturation/Value picking box + float bar0_pos_x = picker_pos.x + SV_PICKER_SIZE.x + style.ItemInnerSpacing.x + 5; + float bar1_pos_x = bar0_pos_x + bars_width + style.ItemInnerSpacing.x; + float bars_triangles_half_sz = (float)(int)(bars_width * 0.20f); + + float hue, saturation, value; + ImGui::ColorConvertRGBtoHSV( + color.Value.x, color.Value.y, color.Value.z, hue, saturation, value); + ImU32 col32_no_alpha = ColorConvertFloat4ToU32(ImVec4(col[0], col[1], col[2], 1.0f)); + + // draw hue bar + + ImColor colors[] = { ImColor(255, 0, 0), + ImColor(255, 255, 0), + ImColor(0, 255, 0), + ImColor(0, 255, 255), + ImColor(0, 0, 255), + ImColor(255, 0, 255), + ImColor(255, 0, 0) }; + + for (int i = 0; i < 6; ++i) + { + draw_list->AddRectFilledMultiColor( + ImVec2(picker_pos.x + SV_PICKER_SIZE.x + SPACING, picker_pos.y + i * (SV_PICKER_SIZE.y / 6)), + ImVec2(picker_pos.x + SV_PICKER_SIZE.x + SPACING + HUE_PICKER_WIDTH, + picker_pos.y + (i + 1) * (SV_PICKER_SIZE.y / 6)), + colors[i], + colors[i], + colors[i + 1], + colors[i + 1]); + } + + draw_list->AddLine( + ImVec2(picker_pos.x + SV_PICKER_SIZE.x + SPACING - 2, picker_pos.y + hue * SV_PICKER_SIZE.y), + ImVec2(picker_pos.x + SV_PICKER_SIZE.x + SPACING + 2 + HUE_PICKER_WIDTH, picker_pos.y + hue * SV_PICKER_SIZE.y), + ImColor(255, 255, 255)); + + // draw color matrix + + { + const ImU32 c_oColorBlack = ImGui::ColorConvertFloat4ToU32(ImVec4(0.f, 0.f, 0.f, 1.f)); + const ImU32 c_oColorBlackTransparent = ImGui::ColorConvertFloat4ToU32(ImVec4(0.f, 0.f, 0.f, 0.f)); + const ImU32 c_oColorWhite = ImGui::ColorConvertFloat4ToU32(ImVec4(1.f, 1.f, 1.f, 1.f)); + + ImVec4 cHueValue(1, 1, 1, 1); + ImGui::ColorConvertHSVtoRGB(hue, 1, 1, cHueValue.x, cHueValue.y, cHueValue.z); + ImU32 oHueColor = ImGui::ColorConvertFloat4ToU32(cHueValue); + + draw_list->AddRectFilledMultiColor( + ImVec2(picker_pos.x, picker_pos.y), + ImVec2(picker_pos.x + SV_PICKER_SIZE.x, picker_pos.y + SV_PICKER_SIZE.y), + c_oColorWhite, + oHueColor, + oHueColor, + c_oColorWhite + ); + + draw_list->AddRectFilledMultiColor( + ImVec2(picker_pos.x, picker_pos.y), + ImVec2(picker_pos.x + SV_PICKER_SIZE.x, picker_pos.y + SV_PICKER_SIZE.y), + c_oColorBlackTransparent, + c_oColorBlackTransparent, + c_oColorBlack, + c_oColorBlack + ); + } + + // draw cross-hair + + float x = saturation * SV_PICKER_SIZE.x; + float y = (1 - value) * SV_PICKER_SIZE.y; + ImVec2 p(picker_pos.x + x, picker_pos.y + y); + draw_list->AddLine(ImVec2(p.x - CROSSHAIR_SIZE, p.y), ImVec2(p.x - 2, p.y), ImColor(255, 255, 255)); + draw_list->AddLine(ImVec2(p.x + CROSSHAIR_SIZE, p.y), ImVec2(p.x + 2, p.y), ImColor(255, 255, 255)); + draw_list->AddLine(ImVec2(p.x, p.y + CROSSHAIR_SIZE), ImVec2(p.x, p.y + 2), ImColor(255, 255, 255)); + draw_list->AddLine(ImVec2(p.x, p.y - CROSSHAIR_SIZE), ImVec2(p.x, p.y - 2), ImColor(255, 255, 255)); + + // color matrix logic + + ImGui::InvisibleButton("saturation_value_selector", SV_PICKER_SIZE); + + if (ImGui::IsItemActive() && ImGui::GetIO().MouseDown[0]) + { + ImVec2 mouse_pos_in_canvas = ImVec2( + ImGui::GetIO().MousePos.x - picker_pos.x, ImGui::GetIO().MousePos.y - picker_pos.y); + + /**/ if (mouse_pos_in_canvas.x < 0) mouse_pos_in_canvas.x = 0; + else if (mouse_pos_in_canvas.x >= SV_PICKER_SIZE.x - 1) mouse_pos_in_canvas.x = SV_PICKER_SIZE.x - 1; + + /**/ if (mouse_pos_in_canvas.y < 0) mouse_pos_in_canvas.y = 0; + else if (mouse_pos_in_canvas.y >= SV_PICKER_SIZE.y - 1) mouse_pos_in_canvas.y = SV_PICKER_SIZE.y - 1; + + value = 1 - (mouse_pos_in_canvas.y / (SV_PICKER_SIZE.y - 1)); + saturation = mouse_pos_in_canvas.x / (SV_PICKER_SIZE.x - 1); + value_changed = true; + } + + // hue bar logic + + ImGui::SetCursorScreenPos(ImVec2(picker_pos.x + SPACING + SV_PICKER_SIZE.x, picker_pos.y)); + ImGui::InvisibleButton("hue_selector", ImVec2(HUE_PICKER_WIDTH, SV_PICKER_SIZE.y)); + + if (ImGui::GetIO().MouseDown[0] && (ImGui::IsItemHovered() || ImGui::IsItemActive())) + { + ImVec2 mouse_pos_in_canvas = ImVec2( + ImGui::GetIO().MousePos.x - picker_pos.x, ImGui::GetIO().MousePos.y - picker_pos.y); + + /**/ if (mouse_pos_in_canvas.y < 0) mouse_pos_in_canvas.y = 0; + else if (mouse_pos_in_canvas.y >= SV_PICKER_SIZE.y - 1) mouse_pos_in_canvas.y = SV_PICKER_SIZE.y - 1; + + hue = mouse_pos_in_canvas.y / (SV_PICKER_SIZE.y - 1); + value_changed = true; + } + + // R,G,B or H,S,V color editor + + // Alpha bar logic + if (alpha_bar) + { + SetCursorScreenPos(ImVec2(bar1_pos_x, picker_pos.y)); + InvisibleButton("alpha", ImVec2(bars_width, SV_PICKER_SIZE.x)); + if (IsItemActive()) + { + color.Value.w = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (SV_PICKER_SIZE.x - 1)); + value_changed = true; + } + } + + // Render alpha bar + if (alpha_bar) + { + float alpha = ImSaturate(color.Value.w); + ImRect bar1_bb(bar1_pos_x, picker_pos.y, bar1_pos_x + bars_width, picker_pos.y + SV_PICKER_SIZE.x); + RenderColorRectWithAlphaCheckerboard(bar1_bb.Min, bar1_bb.Max, IM_COL32(0, 0, 0, 0), bar1_bb.GetWidth() / 2.0f, ImVec2(0.0f, 0.0f)); + draw_list->AddRectFilledMultiColor(bar1_bb.Min, bar1_bb.Max, col32_no_alpha, col32_no_alpha, col32_no_alpha & ~IM_COL32_A_MASK, col32_no_alpha & ~IM_COL32_A_MASK); + float bar1_line_y = (float)(int)(picker_pos.y + (1.0f - alpha) * SV_PICKER_SIZE.x + 0.5f); + RenderFrameBorder(bar1_bb.Min, bar1_bb.Max, 0.0f); + RenderArrowsForVerticalBar(draw_list, ImVec2(bar1_pos_x - 1, bar1_line_y), ImVec2(bars_triangles_half_sz + 1, bars_triangles_half_sz), bars_width + 2.0f); + } + + //color = ImColor::HSV(hue >= 1 ? hue - 10 * 1e-6 : hue, saturation > 0 ? saturation : 10 * 1e-6, value > 0 ? value : 1e-6); + col[3] = color.Value.w; + color = ImColor::HSV(hue, saturation, value); + col[0] = color.Value.x; + col[1] = color.Value.y; + col[2] = color.Value.z; + + return value_changed; +} + +// Horizontal separating line. +void ImGui::Separator() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + ImGuiContext& g = *GImGui; + + ImGuiWindowFlags flags = 0; + if ((flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical)) == 0) + flags |= (window->DC.LayoutType == ImGuiLayoutType_Horizontal) ? ImGuiSeparatorFlags_Vertical : ImGuiSeparatorFlags_Horizontal; + IM_ASSERT(ImIsPowerOfTwo((int)(flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical)))); // Check that only 1 option is selected + if (flags & ImGuiSeparatorFlags_Vertical) + { + VerticalSeparator(); + return; + } + + // Horizontal Separator + if (window->DC.ColumnsSet) + PopClipRect(); + + float x1 = window->Pos.x; + float x2 = window->Pos.x + window->Size.x; + if (!window->DC.GroupStack.empty()) + x1 += window->DC.IndentX; + + const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y+1.0f)); + ItemSize(ImVec2(0.0f, 0.0f)); // NB: we don't provide our width so that it doesn't get feed back into AutoFit, we don't provide height to not alter layout. + if (!ItemAdd(bb, 0)) + { + if (window->DC.ColumnsSet) + PushColumnClipRect(); + return; + } + + window->DrawList->AddLine(bb.Min, ImVec2(bb.Max.x,bb.Min.y), GetColorU32(ImGuiCol_Separator)); + + if (g.LogEnabled) + LogRenderedText(NULL, IM_NEWLINE "--------------------------------"); + + if (window->DC.ColumnsSet) + { + PushColumnClipRect(); + window->DC.ColumnsSet->CellMinY = window->DC.CursorPos.y; + } +} + +void ImGui::VerticalSeparator() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + ImGuiContext& g = *GImGui; + + float y1 = window->DC.CursorPos.y; + float y2 = window->DC.CursorPos.y + window->DC.CurrentLineHeight; + const ImRect bb(ImVec2(window->DC.CursorPos.x, y1), ImVec2(window->DC.CursorPos.x + 1.0f, y2)); + ItemSize(ImVec2(bb.GetWidth(), 0.0f)); + if (!ItemAdd(bb, 0)) + return; + + window->DrawList->AddLine(ImVec2(bb.Min.x, bb.Min.y), ImVec2(bb.Min.x, bb.Max.y), GetColorU32(ImGuiCol_Separator)); + if (g.LogEnabled) + LogText(" |"); +} + +bool ImGui::SplitterBehavior(ImGuiID id, const ImRect& bb, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + const ImGuiItemFlags item_flags_backup = window->DC.ItemFlags; +#ifdef IMGUI_HAS_NAV + window->DC.ItemFlags |= ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus; +#endif + bool add = ItemAdd(bb, id); + window->DC.ItemFlags = item_flags_backup; + if (!add) + return false; + + bool hovered, held; + ImRect bb_interact = bb; + bb_interact.Expand(axis == ImGuiAxis_Y ? ImVec2(0.0f, hover_extend) : ImVec2(hover_extend, 0.0f)); + ButtonBehavior(bb_interact, id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_AllowItemOverlap); + if (g.ActiveId != id) + SetItemAllowOverlap(); + + if (held || (g.HoveredId == id && g.HoveredIdPreviousFrame == id)) + SetMouseCursor(axis == ImGuiAxis_Y ? ImGuiMouseCursor_ResizeNS : ImGuiMouseCursor_ResizeEW); + + ImRect bb_render = bb; + if (held) + { + ImVec2 mouse_delta_2d = g.IO.MousePos - g.ActiveIdClickOffset - bb_interact.Min; + float mouse_delta = (axis == ImGuiAxis_Y) ? mouse_delta_2d.y : mouse_delta_2d.x; + + // Minimum pane size + if (mouse_delta < min_size1 - *size1) + mouse_delta = min_size1 - *size1; + if (mouse_delta > *size2 - min_size2) + mouse_delta = *size2 - min_size2; + + // Apply resize + *size1 += mouse_delta; + *size2 -= mouse_delta; + bb_render.Translate((axis == ImGuiAxis_X) ? ImVec2(mouse_delta, 0.0f) : ImVec2(0.0f, mouse_delta)); + } + + // Render + const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : hovered ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator); + window->DrawList->AddRectFilled(bb_render.Min, bb_render.Max, col, g.Style.FrameRounding); + + return held; +} + +void ImGui::Spacing() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + ItemSize(ImVec2(0,0)); +} + +void ImGui::Dummy(const ImVec2& size) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); + ItemSize(bb); + ItemAdd(bb, 0); +} + +bool ImGui::IsRectVisible(const ImVec2& size) +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->ClipRect.Overlaps(ImRect(window->DC.CursorPos, window->DC.CursorPos + size)); +} + +bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max) +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->ClipRect.Overlaps(ImRect(rect_min, rect_max)); +} + +// Lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.) +void ImGui::BeginGroup() +{ + ImGuiWindow* window = GetCurrentWindow(); + + window->DC.GroupStack.resize(window->DC.GroupStack.Size + 1); + ImGuiGroupData& group_data = window->DC.GroupStack.back(); + group_data.BackupCursorPos = window->DC.CursorPos; + group_data.BackupCursorMaxPos = window->DC.CursorMaxPos; + group_data.BackupIndentX = window->DC.IndentX; + group_data.BackupGroupOffsetX = window->DC.GroupOffsetX; + group_data.BackupCurrentLineHeight = window->DC.CurrentLineHeight; + group_data.BackupCurrentLineTextBaseOffset = window->DC.CurrentLineTextBaseOffset; + group_data.BackupLogLinePosY = window->DC.LogLinePosY; + group_data.BackupActiveIdIsAlive = GImGui->ActiveIdIsAlive; + group_data.AdvanceCursor = true; + + window->DC.GroupOffsetX = window->DC.CursorPos.x - window->Pos.x - window->DC.ColumnsOffsetX; + window->DC.IndentX = window->DC.GroupOffsetX; + window->DC.CursorMaxPos = window->DC.CursorPos; + window->DC.CurrentLineHeight = 0.0f; + window->DC.LogLinePosY = window->DC.CursorPos.y - 9999.0f; +} + +void ImGui::EndGroup() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + + IM_ASSERT(!window->DC.GroupStack.empty()); // Mismatched BeginGroup()/EndGroup() calls + + ImGuiGroupData& group_data = window->DC.GroupStack.back(); + + ImRect group_bb(group_data.BackupCursorPos, window->DC.CursorMaxPos); + group_bb.Max = ImMax(group_bb.Min, group_bb.Max); + + window->DC.CursorPos = group_data.BackupCursorPos; + window->DC.CursorMaxPos = ImMax(group_data.BackupCursorMaxPos, window->DC.CursorMaxPos); + window->DC.CurrentLineHeight = group_data.BackupCurrentLineHeight; + window->DC.CurrentLineTextBaseOffset = group_data.BackupCurrentLineTextBaseOffset; + window->DC.IndentX = group_data.BackupIndentX; + window->DC.GroupOffsetX = group_data.BackupGroupOffsetX; + window->DC.LogLinePosY = window->DC.CursorPos.y - 9999.0f; + + if (group_data.AdvanceCursor) + { + window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrentLineTextBaseOffset); // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now. + ItemSize(group_bb.GetSize(), group_data.BackupCurrentLineTextBaseOffset); + ItemAdd(group_bb, 0); + } + + // If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive() will be functional on the entire group. + // It would be be neater if we replaced window.DC.LastItemId by e.g. 'bool LastItemIsActive', but if you search for LastItemId you'll notice it is only used in that context. + const bool active_id_within_group = (!group_data.BackupActiveIdIsAlive && g.ActiveIdIsAlive && g.ActiveId && g.ActiveIdWindow->RootWindow == window->RootWindow); + if (active_id_within_group) + window->DC.LastItemId = g.ActiveId; + window->DC.LastItemRect = group_bb; + + window->DC.GroupStack.pop_back(); + + //window->DrawList->AddRect(group_bb.Min, group_bb.Max, IM_COL32(255,0,255,255)); // [Debug] +} + +// Gets back to previous line and continue with horizontal layout +// pos_x == 0 : follow right after previous item +// pos_x != 0 : align to specified x position (relative to window/group left) +// spacing_w < 0 : use default spacing if pos_x == 0, no spacing if pos_x != 0 +// spacing_w >= 0 : enforce spacing amount +void ImGui::SameLine(float pos_x, float spacing_w) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + if (pos_x != 0.0f) + { + if (spacing_w < 0.0f) spacing_w = 0.0f; + window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + pos_x + spacing_w + window->DC.GroupOffsetX + window->DC.ColumnsOffsetX; + window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y; + } + else + { + if (spacing_w < 0.0f) spacing_w = g.Style.ItemSpacing.x; + window->DC.CursorPos.x = window->DC.CursorPosPrevLine.x + spacing_w; + window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y; + } + window->DC.CurrentLineHeight = window->DC.PrevLineHeight; + window->DC.CurrentLineTextBaseOffset = window->DC.PrevLineTextBaseOffset; +} + +void ImGui::NewLine() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + const ImGuiLayoutType backup_layout_type = window->DC.LayoutType; + window->DC.LayoutType = ImGuiLayoutType_Vertical; + if (window->DC.CurrentLineHeight > 0.0f) // In the event that we are on a line with items that is smaller that FontSize high, we will preserve its height. + ItemSize(ImVec2(0,0)); + else + ItemSize(ImVec2(0.0f, g.FontSize)); + window->DC.LayoutType = backup_layout_type; +} + +void ImGui::NextColumn() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems || window->DC.ColumnsSet == NULL) + return; + + ImGuiContext& g = *GImGui; + PopItemWidth(); + PopClipRect(); + + ImGuiColumnsSet* columns = window->DC.ColumnsSet; + columns->CellMaxY = ImMax(columns->CellMaxY, window->DC.CursorPos.y); + if (++columns->Current < columns->Count) + { + // Columns 1+ cancel out IndentX + window->DC.ColumnsOffsetX = GetColumnOffset(columns->Current) - window->DC.IndentX + g.Style.ItemSpacing.x; + window->DrawList->ChannelsSetCurrent(columns->Current); + } + else + { + window->DC.ColumnsOffsetX = 0.0f; + window->DrawList->ChannelsSetCurrent(0); + columns->Current = 0; + columns->CellMinY = columns->CellMaxY; + } + window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX); + window->DC.CursorPos.y = columns->CellMinY; + window->DC.CurrentLineHeight = 0.0f; + window->DC.CurrentLineTextBaseOffset = 0.0f; + + PushColumnClipRect(); + PushItemWidth(GetColumnWidth() * 0.65f); // FIXME: Move on columns setup +} + +int ImGui::GetColumnIndex() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.ColumnsSet ? window->DC.ColumnsSet->Current : 0; +} + +int ImGui::GetColumnsCount() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.ColumnsSet ? window->DC.ColumnsSet->Count : 1; +} + +static float OffsetNormToPixels(const ImGuiColumnsSet* columns, float offset_norm) +{ + return offset_norm * (columns->MaxX - columns->MinX); +} + +static float PixelsToOffsetNorm(const ImGuiColumnsSet* columns, float offset) +{ + return offset / (columns->MaxX - columns->MinX); +} + +static inline float GetColumnsRectHalfWidth() { return 4.0f; } + +static float GetDraggedColumnOffset(ImGuiColumnsSet* columns, int column_index) +{ + // Active (dragged) column always follow mouse. The reason we need this is that dragging a column to the right edge of an auto-resizing + // window creates a feedback loop because we store normalized positions. So while dragging we enforce absolute positioning. + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + IM_ASSERT(column_index > 0); // We cannot drag column 0. If you get this assert you may have a conflict between the ID of your columns and another widgets. + IM_ASSERT(g.ActiveId == columns->ID + ImGuiID(column_index)); + + float x = g.IO.MousePos.x - g.ActiveIdClickOffset.x + GetColumnsRectHalfWidth() - window->Pos.x; + x = ImMax(x, ImGui::GetColumnOffset(column_index - 1) + g.Style.ColumnsMinSpacing); + if ((columns->Flags & ImGuiColumnsFlags_NoPreserveWidths)) + x = ImMin(x, ImGui::GetColumnOffset(column_index + 1) - g.Style.ColumnsMinSpacing); + + return x; +} + +float ImGui::GetColumnOffset(int column_index) +{ + ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiColumnsSet* columns = window->DC.ColumnsSet; + IM_ASSERT(columns != NULL); + + if (column_index < 0) + column_index = columns->Current; + IM_ASSERT(column_index < columns->Columns.Size); + + /* + if (g.ActiveId) + { + ImGuiContext& g = *GImGui; + const ImGuiID column_id = columns->ColumnsSetId + ImGuiID(column_index); + if (g.ActiveId == column_id) + return GetDraggedColumnOffset(columns, column_index); + } + */ + + const float t = columns->Columns[column_index].OffsetNorm; + const float x_offset = ImLerp(columns->MinX, columns->MaxX, t); + return x_offset; +} + +static float GetColumnWidthEx(ImGuiColumnsSet* columns, int column_index, bool before_resize = false) +{ + if (column_index < 0) + column_index = columns->Current; + + float offset_norm; + if (before_resize) + offset_norm = columns->Columns[column_index + 1].OffsetNormBeforeResize - columns->Columns[column_index].OffsetNormBeforeResize; + else + offset_norm = columns->Columns[column_index + 1].OffsetNorm - columns->Columns[column_index].OffsetNorm; + return OffsetNormToPixels(columns, offset_norm); +} + +float ImGui::GetColumnWidth(int column_index) +{ + ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiColumnsSet* columns = window->DC.ColumnsSet; + IM_ASSERT(columns != NULL); + + if (column_index < 0) + column_index = columns->Current; + return OffsetNormToPixels(columns, columns->Columns[column_index + 1].OffsetNorm - columns->Columns[column_index].OffsetNorm); +} + +void ImGui::SetColumnOffset(int column_index, float offset) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiColumnsSet* columns = window->DC.ColumnsSet; + IM_ASSERT(columns != NULL); + + if (column_index < 0) + column_index = columns->Current; + IM_ASSERT(column_index < columns->Columns.Size); + + const bool preserve_width = !(columns->Flags & ImGuiColumnsFlags_NoPreserveWidths) && (column_index < columns->Count-1); + const float width = preserve_width ? GetColumnWidthEx(columns, column_index, columns->IsBeingResized) : 0.0f; + + if (!(columns->Flags & ImGuiColumnsFlags_NoForceWithinWindow)) + offset = ImMin(offset, columns->MaxX - g.Style.ColumnsMinSpacing * (columns->Count - column_index)); + columns->Columns[column_index].OffsetNorm = PixelsToOffsetNorm(columns, offset - columns->MinX); + + if (preserve_width) + SetColumnOffset(column_index + 1, offset + ImMax(g.Style.ColumnsMinSpacing, width)); +} + +void ImGui::SetColumnWidth(int column_index, float width) +{ + ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiColumnsSet* columns = window->DC.ColumnsSet; + IM_ASSERT(columns != NULL); + + if (column_index < 0) + column_index = columns->Current; + SetColumnOffset(column_index + 1, GetColumnOffset(column_index) + width); +} + +void ImGui::PushColumnClipRect(int column_index) +{ + ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiColumnsSet* columns = window->DC.ColumnsSet; + if (column_index < 0) + column_index = columns->Current; + + PushClipRect(columns->Columns[column_index].ClipRect.Min, columns->Columns[column_index].ClipRect.Max, false); +} + +static ImGuiColumnsSet* FindOrAddColumnsSet(ImGuiWindow* window, ImGuiID id) +{ + for (int n = 0; n < window->ColumnsStorage.Size; n++) + if (window->ColumnsStorage[n].ID == id) + return &window->ColumnsStorage[n]; + + window->ColumnsStorage.push_back(ImGuiColumnsSet()); + ImGuiColumnsSet* columns = &window->ColumnsStorage.back(); + columns->ID = id; + return columns; +} + +void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + + IM_ASSERT(columns_count > 1); + IM_ASSERT(window->DC.ColumnsSet == NULL); // Nested columns are currently not supported + + // Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget. + // In addition, when an identifier isn't explicitly provided we include the number of columns in the hash to make it uniquer. + PushID(0x11223347 + (str_id ? 0 : columns_count)); + ImGuiID id = window->GetID(str_id ? str_id : "columns"); + PopID(); + + // Acquire storage for the columns set + ImGuiColumnsSet* columns = FindOrAddColumnsSet(window, id); + IM_ASSERT(columns->ID == id); + columns->Current = 0; + columns->Count = columns_count; + columns->Flags = flags; + window->DC.ColumnsSet = columns; + + // set state for first column + const float content_region_width = (window->SizeContentsExplicit.x != 0.0f) ? (window->SizeContentsExplicit.x) : (window->Size.x -window->ScrollbarSizes.x); + columns->MinX = window->DC.IndentX - g.Style.ItemSpacing.x; // Lock our horizontal range + //column->MaxX = content_region_width - window->Scroll.x - ((window->Flags & ImGuiWindowFlags_NoScrollbar) ? 0 : g.Style.ScrollbarSize);// - window->WindowPadding().x; + columns->MaxX = content_region_width - window->Scroll.x; + columns->StartPosY = window->DC.CursorPos.y; + columns->StartMaxPosX = window->DC.CursorMaxPos.x; + columns->CellMinY = columns->CellMaxY = window->DC.CursorPos.y; + window->DC.ColumnsOffsetX = 0.0f; + window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX); + + // Clear data if columns count changed + if (columns->Columns.Size != 0 && columns->Columns.Size != columns_count + 1) + columns->Columns.resize(0); + + // initialize defaults + columns->IsFirstFrame = (columns->Columns.Size == 0); + if (columns->Columns.Size == 0) + { + columns->Columns.reserve(columns_count + 1); + for (int n = 0; n < columns_count + 1; n++) + { + ImGuiColumnData column; + column.OffsetNorm = n / (float)columns_count; + columns->Columns.push_back(column); + } + } + + for (int n = 0; n < columns_count + 1; n++) + { + // Clamp position + ImGuiColumnData* column = &columns->Columns[n]; + float t = column->OffsetNorm; + if (!(columns->Flags & ImGuiColumnsFlags_NoForceWithinWindow)) + t = ImMin(t, PixelsToOffsetNorm(columns, (columns->MaxX - columns->MinX) - g.Style.ColumnsMinSpacing * (columns->Count - n))); + column->OffsetNorm = t; + + if (n == columns_count) + continue; + + // Compute clipping rectangle + float clip_x1 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(n) - 1.0f); + float clip_x2 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(n + 1) - 1.0f); + column->ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX); + column->ClipRect.ClipWith(window->ClipRect); + } + + window->DrawList->ChannelsSplit(columns->Count); + PushColumnClipRect(); + PushItemWidth(GetColumnWidth() * 0.65f); +} + +void ImGui::EndColumns() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + ImGuiColumnsSet* columns = window->DC.ColumnsSet; + IM_ASSERT(columns != NULL); + + PopItemWidth(); + PopClipRect(); + window->DrawList->ChannelsMerge(); + + columns->CellMaxY = ImMax(columns->CellMaxY, window->DC.CursorPos.y); + window->DC.CursorPos.y = columns->CellMaxY; + if (!(columns->Flags & ImGuiColumnsFlags_GrowParentContentsSize)) + window->DC.CursorMaxPos.x = ImMax(columns->StartMaxPosX, columns->MaxX); // Restore cursor max pos, as columns don't grow parent + + // Draw columns borders and handle resize + bool is_being_resized = false; + if (!(columns->Flags & ImGuiColumnsFlags_NoBorder) && !window->SkipItems) + { + const float y1 = columns->StartPosY; + const float y2 = window->DC.CursorPos.y; + int dragging_column = -1; + for (int n = 1; n < columns->Count; n++) + { + float x = window->Pos.x + GetColumnOffset(n); + const ImGuiID column_id = columns->ID + ImGuiID(n); + const float column_hw = GetColumnsRectHalfWidth(); // Half-width for interaction + const ImRect column_rect(ImVec2(x - column_hw, y1), ImVec2(x + column_hw, y2)); + KeepAliveID(column_id); + if (IsClippedEx(column_rect, column_id, false)) + continue; + + bool hovered = false, held = false; + if (!(columns->Flags & ImGuiColumnsFlags_NoResize)) + { + ButtonBehavior(column_rect, column_id, &hovered, &held); + if (hovered || held) + g.MouseCursor = ImGuiMouseCursor_ResizeEW; + if (held && !(columns->Columns[n].Flags & ImGuiColumnsFlags_NoResize)) + dragging_column = n; + } + + // Draw column (we clip the Y boundaries CPU side because very long triangles are mishandled by some GPU drivers.) + const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : hovered ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator); + const float xi = (float)(int)x; + window->DrawList->AddLine(ImVec2(xi, ImMax(y1 + 1.0f, window->ClipRect.Min.y)), ImVec2(xi, ImMin(y2, window->ClipRect.Max.y)), col); + } + + // Apply dragging after drawing the column lines, so our rendered lines are in sync with how items were displayed during the frame. + if (dragging_column != -1) + { + if (!columns->IsBeingResized) + for (int n = 0; n < columns->Count + 1; n++) + columns->Columns[n].OffsetNormBeforeResize = columns->Columns[n].OffsetNorm; + columns->IsBeingResized = is_being_resized = true; + float x = GetDraggedColumnOffset(columns, dragging_column); + SetColumnOffset(dragging_column, x); + } + } + columns->IsBeingResized = is_being_resized; + + window->DC.ColumnsSet = NULL; + window->DC.ColumnsOffsetX = 0.0f; + window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX); +} + +// [2017/12: This is currently the only public API, while we are working on making BeginColumns/EndColumns user-facing] +void ImGui::Columns(int columns_count, const char* id, bool border) +{ + ImGuiWindow* window = GetCurrentWindow(); + IM_ASSERT(columns_count >= 1); + if (window->DC.ColumnsSet != NULL && window->DC.ColumnsSet->Count != columns_count) + EndColumns(); + + ImGuiColumnsFlags flags = (border ? 0 : ImGuiColumnsFlags_NoBorder); + //flags |= ImGuiColumnsFlags_NoPreserveWidths; // NB: Legacy behavior + if (columns_count != 1) + BeginColumns(id, columns_count, flags); +} + +void ImGui::Indent(float indent_w) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + window->DC.IndentX += (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing; + window->DC.CursorPos.x = window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX; +} + +void ImGui::Unindent(float indent_w) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + window->DC.IndentX -= (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing; + window->DC.CursorPos.x = window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX; +} + +void ImGui::TreePush(const char* str_id) +{ + ImGuiWindow* window = GetCurrentWindow(); + Indent(); + window->DC.TreeDepth++; + PushID(str_id ? str_id : "#TreePush"); +} + +void ImGui::TreePush(const void* ptr_id) +{ + ImGuiWindow* window = GetCurrentWindow(); + Indent(); + window->DC.TreeDepth++; + PushID(ptr_id ? ptr_id : (const void*)"#TreePush"); +} + +void ImGui::TreePushRawID(ImGuiID id) +{ + ImGuiWindow* window = GetCurrentWindow(); + Indent(); + window->DC.TreeDepth++; + window->IDStack.push_back(id); +} + +void ImGui::TreePop() +{ + ImGuiWindow* window = GetCurrentWindow(); + Unindent(); + window->DC.TreeDepth--; + PopID(); +} + +void ImGui::Value(const char* prefix, bool b) +{ + Text("%s: %s", prefix, (b ? "true" : "false")); +} + +void ImGui::Value(const char* prefix, int v) +{ + Text("%s: %d", prefix, v); +} + +void ImGui::Value(const char* prefix, unsigned int v) +{ + Text("%s: %d", prefix, v); +} + +void ImGui::Value(const char* prefix, float v, const char* float_format) +{ + if (float_format) + { + char fmt[64]; + ImFormatString(fmt, IM_ARRAYSIZE(fmt), "%%s: %s", float_format); + Text(fmt, prefix, v); + } + else + { + Text("%s: %.3f", prefix, v); + } +} + +//----------------------------------------------------------------------------- +// DRAG AND DROP +//----------------------------------------------------------------------------- + +void ImGui::ClearDragDrop() +{ + ImGuiContext& g = *GImGui; + g.DragDropActive = false; + g.DragDropPayload.Clear(); + g.DragDropAcceptIdCurr = g.DragDropAcceptIdPrev = 0; + g.DragDropAcceptIdCurrRectSurface = FLT_MAX; + g.DragDropAcceptFrameCount = -1; +} + +// Call when current ID is active. +// When this returns true you need to: a) call SetDragDropPayload() exactly once, b) you may render the payload visual/description, c) call EndDragDropSource() +bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags, int mouse_button) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + bool source_drag_active = false; + ImGuiID source_id = 0; + ImGuiID source_parent_id = 0; + if (!(flags & ImGuiDragDropFlags_SourceExtern)) + { + source_id = window->DC.LastItemId; + if (source_id != 0 && g.ActiveId != source_id) // Early out for most common case + return false; + if (g.IO.MouseDown[mouse_button] == false) + return false; + + if (source_id == 0) + { + // If you want to use BeginDragDropSource() on an item with no unique identifier for interaction, such as Text() or Image(), you need to: + // A) Read the explanation below, B) Use the ImGuiDragDropFlags_SourceAllowNullID flag, C) Swallow your programmer pride. + if (!(flags & ImGuiDragDropFlags_SourceAllowNullID)) + { + IM_ASSERT(0); + return false; + } + + // Magic fallback (=somehow reprehensible) to handle items with no assigned ID, e.g. Text(), Image() + // We build a throwaway ID based on current ID stack + relative AABB of items in window. + // THE IDENTIFIER WON'T SURVIVE ANY REPOSITIONING OF THE WIDGET, so if your widget moves your dragging operation will be canceled. + // We don't need to maintain/call ClearActiveID() as releasing the button will early out this function and trigger !ActiveIdIsAlive. + bool is_hovered = window->DC.LastItemRectHoveredRect; + if (!is_hovered && (g.ActiveId == 0 || g.ActiveIdWindow != window)) + return false; + source_id = window->DC.LastItemId = window->GetIDFromRectangle(window->DC.LastItemRect); + if (is_hovered) + SetHoveredID(source_id); + if (is_hovered && g.IO.MouseClicked[mouse_button]) + { + SetActiveID(source_id, window); + FocusWindow(window); + } + if (g.ActiveId == source_id) // Allow the underlying widget to display/return hovered during the mouse release frame, else we would get a flicker. + g.ActiveIdAllowOverlap = is_hovered; + } + if (g.ActiveId != source_id) + return false; + source_parent_id = window->IDStack.back(); + source_drag_active = IsMouseDragging(mouse_button); + } + else + { + window = NULL; + source_id = ImHash("#SourceExtern", 0); + source_drag_active = true; + } + + if (source_drag_active) + { + if (!g.DragDropActive) + { + IM_ASSERT(source_id != 0); + ClearDragDrop(); + ImGuiPayload& payload = g.DragDropPayload; + payload.SourceId = source_id; + payload.SourceParentId = source_parent_id; + g.DragDropActive = true; + g.DragDropSourceFlags = flags; + g.DragDropMouseButton = mouse_button; + } + + if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip)) + { + // FIXME-DRAG + //SetNextWindowPos(g.IO.MousePos - g.ActiveIdClickOffset - g.Style.WindowPadding); + //PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.60f); // This is better but e.g ColorButton with checkboard has issue with transparent colors :( + SetNextWindowPos(g.IO.MousePos); + PushStyleColor(ImGuiCol_PopupBg, GetStyleColorVec4(ImGuiCol_PopupBg) * ImVec4(1.0f, 1.0f, 1.0f, 0.6f)); + BeginTooltipEx(ImGuiWindowFlags_NoInputs); + } + + if (!(flags & ImGuiDragDropFlags_SourceNoDisableHover) && !(flags & ImGuiDragDropFlags_SourceExtern)) + window->DC.LastItemRectHoveredRect = false; + + return true; + } + return false; +} + +void ImGui::EndDragDropSource() +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(g.DragDropActive); + + if (!(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip)) + { + EndTooltip(); + PopStyleColor(); + //PopStyleVar(); + } + + // Discard the drag if have not called SetDragDropPayload() + if (g.DragDropPayload.DataFrameCount == -1) + ClearDragDrop(); +} + +// Use 'cond' to choose to submit payload on drag start or every frame +bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_size, ImGuiCond cond) +{ + ImGuiContext& g = *GImGui; + ImGuiPayload& payload = g.DragDropPayload; + if (cond == 0) + cond = ImGuiCond_Always; + + IM_ASSERT(type != NULL); + IM_ASSERT(strlen(type) < IM_ARRAYSIZE(payload.DataType)); // Payload type can be at most 8 characters longs + IM_ASSERT((data != NULL && data_size > 0) || (data == NULL && data_size == 0)); + IM_ASSERT(cond == ImGuiCond_Always || cond == ImGuiCond_Once); + IM_ASSERT(payload.SourceId != 0); // Not called between BeginDragDropSource() and EndDragDropSource() + + if (cond == ImGuiCond_Always || payload.DataFrameCount == -1) + { + // Copy payload + ImStrncpy(payload.DataType, type, IM_ARRAYSIZE(payload.DataType)); + g.DragDropPayloadBufHeap.resize(0); + if (data_size > sizeof(g.DragDropPayloadBufLocal)) + { + // Store in heap + g.DragDropPayloadBufHeap.resize((int)data_size); + payload.Data = g.DragDropPayloadBufHeap.Data; + memcpy((void*)payload.Data, data, data_size); + } + else if (data_size > 0) + { + // Store locally + memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal)); + payload.Data = g.DragDropPayloadBufLocal; + memcpy((void*)payload.Data, data, data_size); + } + else + { + payload.Data = NULL; + } + payload.DataSize = (int)data_size; + } + payload.DataFrameCount = g.FrameCount; + + return (g.DragDropAcceptFrameCount == g.FrameCount) || (g.DragDropAcceptFrameCount == g.FrameCount - 1); +} + +bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id) +{ + ImGuiContext& g = *GImGui; + if (!g.DragDropActive) + return false; + + ImGuiWindow* window = g.CurrentWindow; + if (g.HoveredWindow == NULL || window->RootWindow != g.HoveredWindow->RootWindow) + return false; + IM_ASSERT(id != 0); + if (!IsMouseHoveringRect(bb.Min, bb.Max) || (id == g.DragDropPayload.SourceId)) + return false; + + g.DragDropTargetRect = bb; + g.DragDropTargetId = id; + return true; +} + +// We don't use BeginDragDropTargetCustom() and duplicate its code because: +// 1) we use LastItemRectHoveredRect which handles items that pushes a temporarily clip rectangle in their code. Calling BeginDragDropTargetCustom(LastItemRect) would not handle them. +// 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can. +// Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case) +bool ImGui::BeginDragDropTarget() +{ + ImGuiContext& g = *GImGui; + if (!g.DragDropActive) + return false; + + ImGuiWindow* window = g.CurrentWindow; + if (!window->DC.LastItemRectHoveredRect) + return false; + if (g.HoveredWindow == NULL || window->RootWindow != g.HoveredWindow->RootWindow) + return false; + + ImGuiID id = window->DC.LastItemId; + if (id == 0) + id = window->GetIDFromRectangle(window->DC.LastItemRect); + if (g.DragDropPayload.SourceId == id) + return false; + + g.DragDropTargetRect = window->DC.LastItemRect; + g.DragDropTargetId = id; + return true; +} + +bool ImGui::IsDragDropPayloadBeingAccepted() +{ + ImGuiContext& g = *GImGui; + return g.DragDropActive && g.DragDropAcceptIdPrev != 0; +} + +const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiPayload& payload = g.DragDropPayload; + IM_ASSERT(g.DragDropActive); // Not called between BeginDragDropTarget() and EndDragDropTarget() ? + IM_ASSERT(payload.DataFrameCount != -1); // Forgot to call EndDragDropTarget() ? + if (type != NULL && !payload.IsDataType(type)) + return NULL; + + // Accept smallest drag target bounding box, this allows us to nest drag targets conveniently without ordering constraints. + // NB: We currently accept NULL id as target. However, overlapping targets requires a unique ID to function! + const bool was_accepted_previously = (g.DragDropAcceptIdPrev == g.DragDropTargetId); + ImRect r = g.DragDropTargetRect; + float r_surface = r.GetWidth() * r.GetHeight(); + if (r_surface < g.DragDropAcceptIdCurrRectSurface) + { + g.DragDropAcceptIdCurr = g.DragDropTargetId; + g.DragDropAcceptIdCurrRectSurface = r_surface; + } + + // Render default drop visuals + payload.Preview = was_accepted_previously; + flags |= (g.DragDropSourceFlags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect); // Source can also inhibit the preview (useful for external sources that lives for 1 frame) + if (!(flags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect) && payload.Preview) + { + // FIXME-DRAG: Settle on a proper default visuals for drop target. + r.Expand(3.5f); + bool push_clip_rect = !window->ClipRect.Contains(r); + if (push_clip_rect) window->DrawList->PushClipRectFullScreen(); + window->DrawList->AddRect(r.Min, r.Max, GetColorU32(ImGuiCol_DragDropTarget), 0.0f, ~0, 2.0f); + if (push_clip_rect) window->DrawList->PopClipRect(); + } + + g.DragDropAcceptFrameCount = g.FrameCount; + payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting os window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased() + if (!payload.Delivery && !(flags & ImGuiDragDropFlags_AcceptBeforeDelivery)) + return NULL; + + return &payload; +} + +// We don't really use/need this now, but added it for the sake of consistency and because we might need it later. +void ImGui::EndDragDropTarget() +{ + ImGuiContext& g = *GImGui; (void)g; + IM_ASSERT(g.DragDropActive); +} + +//----------------------------------------------------------------------------- +// PLATFORM DEPENDENT HELPERS +//----------------------------------------------------------------------------- + +#if defined(_WIN32) && !defined(_WINDOWS_) && (!defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) || !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)) +#undef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#include +#endif + +// Win32 API clipboard implementation +#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) + +#ifdef _MSC_VER +#pragma comment(lib, "user32") +#endif + +static const char* GetClipboardTextFn_DefaultImpl(void*) +{ + static ImVector buf_local; + buf_local.clear(); + if (!OpenClipboard(NULL)) + return NULL; + HANDLE wbuf_handle = GetClipboardData(CF_UNICODETEXT); + if (wbuf_handle == NULL) + { + CloseClipboard(); + return NULL; + } + if (ImWchar* wbuf_global = (ImWchar*)GlobalLock(wbuf_handle)) + { + int buf_len = ImTextCountUtf8BytesFromStr(wbuf_global, NULL) + 1; + buf_local.resize(buf_len); + ImTextStrToUtf8(buf_local.Data, buf_len, wbuf_global, NULL); + } + GlobalUnlock(wbuf_handle); + CloseClipboard(); + return buf_local.Data; +} + +static void SetClipboardTextFn_DefaultImpl(void*, const char* text) +{ + if (!OpenClipboard(NULL)) + return; + const int wbuf_length = ImTextCountCharsFromUtf8(text, NULL) + 1; + HGLOBAL wbuf_handle = GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length * sizeof(ImWchar)); + if (wbuf_handle == NULL) + { + CloseClipboard(); + return; + } + ImWchar* wbuf_global = (ImWchar*)GlobalLock(wbuf_handle); + ImTextStrFromUtf8(wbuf_global, wbuf_length, text, NULL); + GlobalUnlock(wbuf_handle); + EmptyClipboard(); + SetClipboardData(CF_UNICODETEXT, wbuf_handle); + CloseClipboard(); +} + +#else + +// Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers +static const char* GetClipboardTextFn_DefaultImpl(void*) +{ + ImGuiContext& g = *GImGui; + return g.PrivateClipboard.empty() ? NULL : g.PrivateClipboard.begin(); +} + +// Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers +static void SetClipboardTextFn_DefaultImpl(void*, const char* text) +{ + ImGuiContext& g = *GImGui; + g.PrivateClipboard.clear(); + const char* text_end = text + strlen(text); + g.PrivateClipboard.resize((int)(text_end - text) + 1); + memcpy(&g.PrivateClipboard[0], text, (size_t)(text_end - text)); + g.PrivateClipboard[(int)(text_end - text)] = 0; +} + +#endif + +// Win32 API IME support (for Asian languages, etc.) +#if defined(_WIN32) && !defined(__GNUC__) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS) + +#include +#ifdef _MSC_VER +#pragma comment(lib, "imm32") +#endif + +static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y) +{ + // Notify OS Input Method Editor of text input position + if (HWND hwnd = (HWND)GImGui->IO.ImeWindowHandle) + if (HIMC himc = ImmGetContext(hwnd)) + { + COMPOSITIONFORM cf; + cf.ptCurrentPos.x = x; + cf.ptCurrentPos.y = y; + cf.dwStyle = CFS_FORCE_POSITION; + ImmSetCompositionWindow(himc, &cf); + } +} + +#else + +static void ImeSetInputScreenPosFn_DefaultImpl(int, int) {} + +#endif + +//----------------------------------------------------------------------------- +// HELP +//----------------------------------------------------------------------------- + +void ImGui::ShowMetricsWindow(bool* p_open) +{ + if (ImGui::Begin("ImGui Metrics", p_open)) + { + ImGui::Text("Dear ImGui %s", ImGui::GetVersion()); + ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); + ImGui::Text("%d vertices, %d indices (%d triangles)", ImGui::GetIO().MetricsRenderVertices, ImGui::GetIO().MetricsRenderIndices, ImGui::GetIO().MetricsRenderIndices / 3); + ImGui::Text("%d allocations", ImGui::GetIO().MetricsAllocs); + static bool show_clip_rects = true; + ImGui::Checkbox("Show clipping rectangles when hovering an ImDrawCmd", &show_clip_rects); + ImGui::Separator(); + + struct Funcs + { + static void NodeDrawList(ImDrawList* draw_list, const char* label) + { + bool node_open = ImGui::TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, draw_list->CmdBuffer.Size); + if (draw_list == ImGui::GetWindowDrawList()) + { + ImGui::SameLine(); + ImGui::TextColored(ImColor(255,100,100), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered) + if (node_open) ImGui::TreePop(); + return; + } + if (!node_open) + return; + + ImDrawList* overlay_draw_list = &GImGui->OverlayDrawList; // Render additional visuals into the top-most draw list + int elem_offset = 0; + for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.begin(); pcmd < draw_list->CmdBuffer.end(); elem_offset += pcmd->ElemCount, pcmd++) + { + if (pcmd->UserCallback == NULL && pcmd->ElemCount == 0) + continue; + if (pcmd->UserCallback) + { + ImGui::BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData); + continue; + } + ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; + bool pcmd_node_open = ImGui::TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "Draw %-4d %s vtx, tex = %p, clip_rect = (%.0f,%.0f)..(%.0f,%.0f)", pcmd->ElemCount, draw_list->IdxBuffer.Size > 0 ? "indexed" : "non-indexed", pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); + if (show_clip_rects && ImGui::IsItemHovered()) + { + ImRect clip_rect = pcmd->ClipRect; + ImRect vtxs_rect; + for (int i = elem_offset; i < elem_offset + (int)pcmd->ElemCount; i++) + vtxs_rect.Add(draw_list->VtxBuffer[idx_buffer ? idx_buffer[i] : i].pos); + clip_rect.Floor(); overlay_draw_list->AddRect(clip_rect.Min, clip_rect.Max, IM_COL32(255,255,0,255)); + vtxs_rect.Floor(); overlay_draw_list->AddRect(vtxs_rect.Min, vtxs_rect.Max, IM_COL32(255,0,255,255)); + } + if (!pcmd_node_open) + continue; + + // Display individual triangles/vertices. Hover on to get the corresponding triangle highlighted. + ImGuiListClipper clipper(pcmd->ElemCount/3); // Manually coarse clip our print out of individual vertices to save CPU, only items that may be visible. + while (clipper.Step()) + for (int prim = clipper.DisplayStart, vtx_i = elem_offset + clipper.DisplayStart*3; prim < clipper.DisplayEnd; prim++) + { + char buf[300]; + char *buf_p = buf, *buf_end = buf + IM_ARRAYSIZE(buf); + ImVec2 triangles_pos[3]; + for (int n = 0; n < 3; n++, vtx_i++) + { + ImDrawVert& v = draw_list->VtxBuffer[idx_buffer ? idx_buffer[vtx_i] : vtx_i]; + triangles_pos[n] = v.pos; + buf_p += ImFormatString(buf_p, (int)(buf_end - buf_p), "%s %04d { pos = (%8.2f,%8.2f), uv = (%.6f,%.6f), col = %08X }\n", (n == 0) ? "vtx" : " ", vtx_i, v.pos.x, v.pos.y, v.uv.x, v.uv.y, v.col); + } + ImGui::Selectable(buf, false); + if (ImGui::IsItemHovered()) + { + ImDrawListFlags backup_flags = overlay_draw_list->Flags; + overlay_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines at is more readable for very large and thin triangles. + overlay_draw_list->AddPolyline(triangles_pos, 3, IM_COL32(255,255,0,255), true, 1.0f); + overlay_draw_list->Flags = backup_flags; + } + } + ImGui::TreePop(); + } + ImGui::TreePop(); + } + + static void NodeWindows(ImVector& windows, const char* label) + { + if (!ImGui::TreeNode(label, "%s (%d)", label, windows.Size)) + return; + for (int i = 0; i < windows.Size; i++) + Funcs::NodeWindow(windows[i], "Window"); + ImGui::TreePop(); + } + + static void NodeWindow(ImGuiWindow* window, const char* label) + { + if (!ImGui::TreeNode(window, "%s '%s', %d @ 0x%p", label, window->Name, window->Active || window->WasActive, window)) + return; + NodeDrawList(window->DrawList, "DrawList"); + ImGui::BulletText("Pos: (%.1f,%.1f), Size: (%.1f,%.1f), SizeContents (%.1f,%.1f)", window->Pos.x, window->Pos.y, window->Size.x, window->Size.y, window->SizeContents.x, window->SizeContents.y); + if (ImGui::IsItemHovered()) + GImGui->OverlayDrawList.AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255,255,0,255)); + ImGui::BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f)", window->Scroll.x, GetScrollMaxX(window), window->Scroll.y, GetScrollMaxY(window)); + ImGui::BulletText("Active: %d, WriteAccessed: %d", window->Active, window->WriteAccessed); + if (window->RootWindow != window) NodeWindow(window->RootWindow, "RootWindow"); + if (window->DC.ChildWindows.Size > 0) NodeWindows(window->DC.ChildWindows, "ChildWindows"); + ImGui::BulletText("Storage: %d BYTEs", window->StateStorage.Data.Size * (int)sizeof(ImGuiStorage::Pair)); + ImGui::TreePop(); + } + }; + + ImGuiContext& g = *GImGui; // Access private state + Funcs::NodeWindows(g.Windows, "Windows"); + if (ImGui::TreeNode("DrawList", "Active DrawLists (%d)", g.RenderDrawLists[0].Size)) + { + for (int layer = 0; layer < IM_ARRAYSIZE(g.RenderDrawLists); layer++) + for (int i = 0; i < g.RenderDrawLists[layer].Size; i++) + Funcs::NodeDrawList(g.RenderDrawLists[0][i], "DrawList"); + ImGui::TreePop(); + } + if (ImGui::TreeNode("Popups", "Open Popups Stack (%d)", g.OpenPopupStack.Size)) + { + for (int i = 0; i < g.OpenPopupStack.Size; i++) + { + ImGuiWindow* window = g.OpenPopupStack[i].Window; + ImGui::BulletText("PopupID: %08x, Window: '%s'%s%s", g.OpenPopupStack[i].PopupId, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? " ChildWindow" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? " ChildMenu" : ""); + } + ImGui::TreePop(); + } + if (ImGui::TreeNode("Basic state")) + { + ImGui::Text("HoveredWindow: '%s'", g.HoveredWindow ? g.HoveredWindow->Name : "NULL"); + ImGui::Text("HoveredRootWindow: '%s'", g.HoveredRootWindow ? g.HoveredRootWindow->Name : "NULL"); + ImGui::Text("HoveredId: 0x%08X/0x%08X (%.2f sec)", g.HoveredId, g.HoveredIdPreviousFrame, g.HoveredIdTimer); // Data is "in-flight" so depending on when the Metrics window is called we may see current frame information or not + ImGui::Text("ActiveId: 0x%08X/0x%08X (%.2f sec)", g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdTimer); + ImGui::Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL"); + ImGui::Text("NavWindow: '%s'", g.NavWindow ? g.NavWindow->Name : "NULL"); + ImGui::Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d BYTEs)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize); + ImGui::TreePop(); + } + } + ImGui::End(); +} + +//----------------------------------------------------------------------------- + +// Include imgui_user.inl at the end of imgui.cpp to access private data/functions that aren't exposed. +// Prefer just including imgui_internal.h from your code rather than using this define. If a declaration is missing from imgui_internal.h add it or request it on the github. +#ifdef IMGUI_INCLUDE_IMGUI_USER_INL +#include "imgui_user.inl" +#endif + +//----------------------------------------------------------------------------- + +``` + +`imgui/imgui.h`: + +```h +// dear imgui, v1.54 WIP +// (headers) + +// See imgui.cpp file for documentation. +// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code. +// Read 'Programmer guide' in imgui.cpp for notes on how to setup ImGui in your codebase. +// Get latest version at https://github.com/ocornut/imgui + +#pragma once + +#if !defined(IMGUI_DISABLE_INCLUDE_IMCONFIG_H) || defined(IMGUI_INCLUDE_IMCONFIG_H) +#include "imconfig.h" // User-editable configuration file +#endif +#include // FLT_MAX +#include // va_list +#include // ptrdiff_t, NULL +#include // strstr +#include // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp +#include // std::vector +#include + +#define IMGUI_VERSION "1.54 WIP" + +// Define attributes of all API symbols declarations, e.g. for DLL under Windows. +#ifndef IMGUI_API +#define IMGUI_API +#endif + +// Define assertion handler. +#ifndef IM_ASSERT +#include +#define IM_ASSERT(_EXPR) assert(_EXPR) +#endif + +// Helpers +// Some compilers support applying printf-style warnings to user functions. +#if defined(__clang__) || defined(__GNUC__) +#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1))) +#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0))) +#else +#define IM_FMTARGS(FMT) +#define IM_FMTLIST(FMT) +#endif +#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR))) +#define IM_OFFSETOF(_TYPE,_MEMBER) ((size_t)&(((_TYPE*)0)->_MEMBER)) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in modern C++. + +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wold-style-cast" +#endif + +// Forward declarations +struct ImDrawChannel; // Temporary storage for outputting drawing commands out of order, used by ImDrawList::ChannelsSplit() +struct ImDrawCmd; // A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call) +struct ImDrawData; // All draw command lists required to render the frame +struct ImDrawList; // A single draw command list (generally one per window) +struct ImDrawListSharedData; // Data shared among multiple draw lists (typically owned by parent ImGui context, but you may create one yourself) +struct ImDrawVert; // A single vertex (20 BYTEs by default, override layout with IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT) +struct ImFont; // Runtime data for a single font within a parent ImFontAtlas +struct ImFontAtlas; // Runtime data for multiple fonts, bake multiple fonts into a single texture, TTF/OTF font loader +struct ImFontConfig; // Configuration data when adding a font or merging fonts +struct ImColor; // Helper functions to create a color that can be converted to either u32 or float4 +struct ImGuiIO; // Main configuration and I/O between your application and ImGui +struct ImGuiOnceUponAFrame; // Simple helper for running a block of code not more than once a frame, used by IMGUI_ONCE_UPON_A_FRAME macro +struct ImGuiStorage; // Simple custom key value storage +struct ImGuiStyle; // Runtime data for styling/colors +struct ImGuiTextFilter; // Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]" +struct ImGuiTextBuffer; // Text buffer for logging/accumulating text +struct ImGuiTextEditCallbackData; // Shared state of ImGui::InputText() when using custom ImGuiTextEditCallback (rare/advanced use) +struct ImGuiSizeCallbackData; // Structure used to constraint window size in custom ways when using custom ImGuiSizeCallback (rare/advanced use) +struct ImGuiListClipper; // Helper to manually clip large list of items +struct ImGuiPayload; // User data payload for drag and drop operations +struct ImGuiContext; // ImGui context (opaque) + +// Typedefs and Enumerations (declared as int for compatibility and to not pollute the top of this file) +typedef unsigned int ImU32; // 32-bit unsigned integer (typically used to store packed colors) +typedef unsigned int ImGuiID; // unique ID used by widgets (typically hashed from a stack of string) +typedef unsigned short ImWchar; // character for keyboard input/display +typedef void* ImTextureID; // user data to identify a texture (this is whatever to you want it to be! read the FAQ about ImTextureID in imgui.cpp) +typedef void* ImShaderID; +typedef int ImGuiCol; // enum: a color identifier for styling // enum ImGuiCol_ +typedef int ImGuiCond; // enum: a condition for set*() // enum ImGuiCond_ +typedef int ImGuiKey; // enum: a key identifier (ImGui-side enum) // enum ImGuiKey_ +typedef int ImGuiMouseCursor; // enum: a mouse cursor identifier // enum ImGuiMouseCursor_ +typedef int ImGuiStyleVar; // enum: a variable identifier for styling // enum ImGuiStyleVar_ +typedef int ImDrawCornerFlags; // flags: for ImDrawList::AddRect*() etc. // enum ImDrawCornerFlags_ +typedef int ImDrawListFlags; // flags: for ImDrawList // enum ImDrawListFlags_ +typedef int ImGuiColorEditFlags; // flags: for ColorEdit*(), ColorPicker*() // enum ImGuiColorEditFlags_ +typedef int ImGuiColumnsFlags; // flags: for *Columns*() // enum ImGuiColumnsFlags_ +typedef int ImGuiDragDropFlags; // flags: for *DragDrop*() // enum ImGuiDragDropFlags_ +typedef int ImGuiComboFlags; // flags: for BeginCombo() // enum ImGuiComboFlags_ +typedef int ImGuiFocusedFlags; // flags: for IsWindowFocused() // enum ImGuiFocusedFlags_ +typedef int ImGuiHoveredFlags; // flags: for IsItemHovered() etc. // enum ImGuiHoveredFlags_ +typedef int ImGuiInputTextFlags; // flags: for InputText*() // enum ImGuiInputTextFlags_ +typedef int ImGuiSelectableFlags; // flags: for Selectable() // enum ImGuiSelectableFlags_ +typedef int ImGuiTreeNodeFlags; // flags: for TreeNode*(),CollapsingHeader()// enum ImGuiTreeNodeFlags_ +typedef int ImGuiWindowFlags; // flags: for Begin*() // enum ImGuiWindowFlags_ +typedef int (*ImGuiTextEditCallback)(ImGuiTextEditCallbackData *data); +typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data); +#if defined(_MSC_VER) && !defined(__clang__) +typedef unsigned __int64 ImU64; // 64-bit unsigned integer +#else +typedef unsigned long long ImU64; // 64-bit unsigned integer +#endif + +// Others helpers at bottom of the file: +// class ImVector<> // Lightweight std::vector like class. +// IMGUI_ONCE_UPON_A_FRAME // Execute a block of code once per frame only (convenient for creating UI within deep-nested code that runs multiple times) + +struct ImVec2 +{ + float x, y; + ImVec2() { x = y = 0.0f; } + ImVec2(float _x, float _y) { x = _x; y = _y; } +#ifdef IM_VEC2_CLASS_EXTRA // Define constructor and implicit cast operators in imconfig.h to convert back<>forth from your math types and ImVec2. + IM_VEC2_CLASS_EXTRA +#endif +}; + +struct ImVec4 +{ + float x, y, z, w; + ImVec4() { x = y = z = w = 0.0f; } + ImVec4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; } +#ifdef IM_VEC4_CLASS_EXTRA // Define constructor and implicit cast operators in imconfig.h to convert back<>forth from your math types and ImVec4. + IM_VEC4_CLASS_EXTRA +#endif +}; + +struct IMGUI_API ImGui_MultiSelectable +{ + std::string name; + bool* value; + + ImGui_MultiSelectable(const std::string& name_, bool *value_) + { + name = name_; + value = value_; + } +}; + +// ImGui end-user API +// In a namespace so that user can add extra functions in a separate file (e.g. Value() helpers for your vector or common types) +namespace ImGui +{ + extern bool is_input_allowed; + + // Main + IMGUI_API ImGuiIO& GetIO(); + IMGUI_API ImGuiStyle& GetStyle(); + IMGUI_API ImDrawData* GetDrawData(); // same value as passed to your io.RenderDrawListsFn() function. valid after Render() and until the next call to NewFrame() + IMGUI_API void NewFrame(); // start a new ImGui frame, you can submit any command from this point until Render()/EndFrame(). + IMGUI_API void Render(); // ends the ImGui frame, finalize the draw data, then call your io.RenderDrawListsFn() function if set. + IMGUI_API bool ColorPicker(const char * label, float * col, ImGuiColorEditFlags extra_flags); + IMGUI_API void EndFrame(); // ends the ImGui frame. automatically called by Render(), so most likely don't need to ever call that yourself directly. If you don't need to render you may call EndFrame() but you'll have wasted CPU already. If you don't need to render, better to not create any imgui windows instead! + IMGUI_API void Shutdown(); + + // Demo, Debug, Informations + IMGUI_API void ShowDemoWindow(bool* p_open = NULL); // create demo/test window (previously called ShowTestWindow). demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application! + IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create metrics window. display ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc. + IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style) + IMGUI_API bool ShowStyleSelector(const char* label); + IMGUI_API void ShowFontSelector(const char* label); + IMGUI_API void ShowUserGuide(); // add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls). + + // Window + IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0, bool* return_shit = 0); // push window to the stack and start appending to it. see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_open' creates a widget on the upper-right to close the window (which sets your bool to false). + IMGUI_API void End(); + IMGUI_API bool BeginGroupBox(const char * name = "", const ImVec2 & size_arg = ImVec2(0,0)); + IMGUI_API void EndGroupBox(); + // finish appending to current window, pop it off the window stack. + IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // begin a scrolling region. size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). size>0.0f: fixed size. each axis can use a different mode, e.g. ImVec2(0,400). + IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // " + IMGUI_API void EndChild(); + IMGUI_API ImVec2 GetContentRegionMax(); // current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates + IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos() + IMGUI_API float GetContentRegionAvailWidth(); // + IMGUI_API ImVec2 GetWindowContentRegionMin(); // content boundaries min (roughly (0,0)-Scroll), in window coordinates + IMGUI_API ImVec2 GetWindowContentRegionMax(); // content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates + IMGUI_API float GetWindowContentRegionWidth(); // + IMGUI_API ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives + IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList api) + IMGUI_API ImVec2 GetWindowSize(); // get current window size + IMGUI_API float GetWindowWidth(); + IMGUI_API float GetWindowHeight(); + IMGUI_API bool IsWindowCollapsed(); + IMGUI_API bool IsWindowAppearing(); + IMGUI_API void SetWindowFontScale(float scale); // per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows + + IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0,0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc. + IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin() + IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Use callback to apply non-trivial programmatic constraints. + IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ enforce the range of scrollbars). not including window decorations (title bar, menu bar, etc.). set an axis to 0.0f to leave it automatic. call before Begin() + IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // set next window collapsed state. call before Begin() + IMGUI_API void SetNextWindowFocus(); // set next window to be focused / front-most. call before Begin() + IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects. + IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects. + IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed(). + IMGUI_API void SetWindowFocus(); // (not recommended) set current window to be focused / front-most. prefer using SetNextWindowFocus(). + IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond = 0); // set named window position. + IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis. + IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond = 0); // set named window collapsed state + IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / front-most. use NULL to remove focus. + + IMGUI_API float GetScrollX(); // get scrolling amount [0..GetScrollMaxX()] + IMGUI_API float GetScrollY(); // get scrolling amount [0..GetScrollMaxY()] + IMGUI_API float GetScrollMaxX(); // get maximum scrolling amount ~~ ContentSize.X - WindowSize.X + IMGUI_API float GetScrollMaxY(); // get maximum scrolling amount ~~ ContentSize.Y - WindowSize.Y + IMGUI_API void SetScrollX(float scroll_x); // set scrolling amount [0..GetScrollMaxX()] + IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()] + IMGUI_API void SetScrollHere(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead. + IMGUI_API void SetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position valid. use GetCursorPos() or GetCursorStartPos()+offset to get valid positions. + IMGUI_API void SetStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it) + IMGUI_API ImGuiStorage* GetStateStorage(); + + // Parameters stacks (shared) + IMGUI_API void PushFont(ImFont* font); // use NULL as a shortcut to push default font + IMGUI_API void PopFont(); + IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col); + IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4& col); + IMGUI_API void PopStyleColor(int count = 1); + IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val); + IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val); + IMGUI_API void PopStyleVar(int count = 1); + IMGUI_API const ImVec4& GetStyleColorVec4(ImGuiCol idx); // retrieve style color as stored in ImGuiStyle structure. use to feed back into PushStyleColor(), otherwhise use GetColorU32() to get style color + style alpha. + IMGUI_API ImFont* GetFont(); // get current font + IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied + IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API + IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul = 1.0f, float alpha_replace = -1.f); // retrieve given style color with style alpha applied and optional extra alpha multiplier + IMGUI_API ImU32 GetColorU32(const ImVec4& col); // retrieve given color with style alpha applied + IMGUI_API ImU32 GetColorU32(ImU32 col); // retrieve given color with style alpha applied + + // Parameters stacks (current window) + IMGUI_API void PushItemWidth(float item_width); // width of items for the common item+label case, pixels. 0.0f = default to ~2/3 of windows width, >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -1.0f always align width to the right side) + IMGUI_API void PopItemWidth(); + IMGUI_API float CalcItemWidth(); // width of item given pushed settings and current cursor position + IMGUI_API void PushTextWrapPos(float wrap_pos_x = 0.0f); // word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space + IMGUI_API void PopTextWrapPos(); + IMGUI_API void PushAllowKeyboardFocus(bool allow_keyboard_focus); // allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets + IMGUI_API void PopAllowKeyboardFocus(); + IMGUI_API void PushButtonRepeat(bool repeat); // in 'repeat' mode, Button*() functions return repeated true in a typematic manner (using io.KeyRepeatDelay/io.KeyRepeatRate setting). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame. + IMGUI_API void PopButtonRepeat(); + + // Cursor / Layout + IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator. + IMGUI_API void SameLine(float pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally + IMGUI_API void NewLine(); // undo a SameLine() + IMGUI_API void Spacing(); // add vertical spacing + IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size + IMGUI_API void Indent(float indent_w = 0.0f); // move content position toward the right, by style.IndentSpacing or indent_w if != 0 + IMGUI_API void Unindent(float indent_w = 0.0f); // move content position back to the left, by style.IndentSpacing or indent_w if != 0 + IMGUI_API void BeginGroup(); // lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.) + IMGUI_API void EndGroup(); + IMGUI_API ImVec2 GetCursorPos(); // cursor position is relative to window position + IMGUI_API float GetCursorPosX(); // " + IMGUI_API float GetCursorPosY(); // " + IMGUI_API void SetCursorPos(const ImVec2& local_pos); // " + IMGUI_API void SetCursorPosX(float x); // " + IMGUI_API void SetCursorPosY(float y); // " + IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position + IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API) + IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates [0..io.DisplaySize] + IMGUI_API void AlignTextToFramePadding(); // vertically align/lower upcoming text to FramePadding.y so that it will aligns to upcoming widgets (call if you have text on a line before regular widgets) + IMGUI_API float GetTextLineHeight(); // ~ FontSize + IMGUI_API float GetTextLineHeightWithSpacing(); // ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text) + IMGUI_API float GetFrameHeight(); // ~ FontSize + style.FramePadding.y * 2 + IMGUI_API float GetFrameHeightWithSpacing(); // ~ FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets) + + // Columns + // You can also use SameLine(pos_x) for simplified columns. The columns API is still work-in-progress and rather lacking. + IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true); + IMGUI_API void NextColumn(); // next column, defaults to current row or next row if the current row is finished + IMGUI_API int GetColumnIndex(); // get current column index + IMGUI_API float GetColumnWidth(int column_index = -1); // get column width (in pixels). pass -1 to use current column + IMGUI_API void SetColumnWidth(int column_index, float width); // set column width (in pixels). pass -1 to use current column + IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetColumnsCount() inclusive. column 0 is typically 0.0f + IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column + IMGUI_API int GetColumnsCount(); + + // ID scopes + // If you are creating widgets in a loop you most likely want to push a unique identifier (e.g. object pointer, loop index) so ImGui can differentiate them. + // You can also use the "##foobar" syntax within widget label to distinguish them from each others. Read "A primer on the use of labels/IDs" in the FAQ for more details. + IMGUI_API void PushID(const char* str_id); // push identifier into the ID stack. IDs are hash of the entire stack! + IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end); + IMGUI_API void PushID(const void* ptr_id); + IMGUI_API void PushID(int int_id); + IMGUI_API void PopID(); + IMGUI_API ImGuiID GetID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself + IMGUI_API ImGuiID GetID(const char* str_id_begin, const char* str_id_end); + IMGUI_API ImGuiID GetID(const void* ptr_id); + + // Widgets: Text + IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text. + IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); // simple formatted text + IMGUI_API void TextV(const char* fmt, va_list args) IM_FMTLIST(1); + IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_FMTARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor(); + IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args) IM_FMTLIST(2); + IMGUI_API void TextDisabled(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor(); + IMGUI_API void TextDisabledV(const char* fmt, va_list args) IM_FMTLIST(1); + IMGUI_API void TextWrapped(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize(). + IMGUI_API void TextWrappedV(const char* fmt, va_list args) IM_FMTLIST(1); + IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_FMTARGS(2); // display text+label aligned the same way as value+label widgets + IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args) IM_FMTLIST(2); + IMGUI_API void BulletText(const char* fmt, ...) IM_FMTARGS(1); // shortcut for Bullet()+Text() + IMGUI_API void BulletTextV(const char* fmt, va_list args) IM_FMTLIST(1); + IMGUI_API void Bullet(); // draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses + + // Widgets: Main + IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0), bool selected = false); // button + IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text + IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size); // button behavior without the visuals, useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.) + IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0)); + IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding + IMGUI_API bool Checkbox(const char* label, bool* v); + IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value); + IMGUI_API bool RadioButton(const char* label, bool active); + IMGUI_API bool RadioButton(const char* label, int* v, int v_button); + IMGUI_API void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), int stride = sizeof(float)); + IMGUI_API void PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0)); + IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), int stride = sizeof(float)); + IMGUI_API void PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0)); + IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-1,0), const char* overlay = NULL); + + IMGUI_API void Tabs(const char* items, int* current_item); + + // Widgets: Combo Box + // The new BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it. + // The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. + IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0); + IMGUI_API void EndCombo(); + IMGUI_API bool Combo(const char* label, int* current_item, const char* const items[], int items_count, int popup_max_height_in_items = -1); + IMGUI_API bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_max_height_in_items = -1); // Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0" + bool MCombo(const char * label, std::vector items, int height_in_items = -1, ImVec2 size = ImVec2(0, 0)); + IMGUI_API bool Combo(const char* label, int* current_item, bool(*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_max_height_in_items = -1); + + // Widgets: Drags (tip: ctrl+click on a drag box to input with keyboard. manually input values aren't clamped, can go off-bounds) + // For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x + IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); // If v_min >= v_max we have no bound + IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); + IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); + IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); + IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", const char* display_format_max = NULL, float power = 1.0f); + IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f"); // If v_min >= v_max we have no bound + IMGUI_API bool DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f"); + IMGUI_API bool DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f"); + IMGUI_API bool DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f"); + IMGUI_API bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f", const char* display_format_max = NULL); + + // Widgets: Input with Keyboard + IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL); + IMGUI_API bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0,0), ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL); + IMGUI_API bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0); + IMGUI_API bool InputFloat2(const char* label, float v[2], int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0); + IMGUI_API bool InputFloat3(const char* label, float v[3], int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0); + IMGUI_API bool InputFloat4(const char* label, float v[4], int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0); + IMGUI_API bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags extra_flags = 0); + IMGUI_API bool InputInt2(const char* label, int v[2], ImGuiInputTextFlags extra_flags = 0); + IMGUI_API bool InputInt3(const char* label, int v[3], ImGuiInputTextFlags extra_flags = 0); + IMGUI_API bool InputInt4(const char* label, int v[4], ImGuiInputTextFlags extra_flags = 0); + + // Widgets: Sliders (tip: ctrl+click on a slider to input with keyboard. manually input values aren't clamped, can go off-bounds) + IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); // adjust display_format to decorate the value with a prefix or a suffix for in-slider labels or unit display. Use power!=1.0 for logarithmic sliders + IMGUI_API bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); + IMGUI_API bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); + IMGUI_API bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); + IMGUI_API bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f); + IMGUI_API bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f"); + IMGUI_API bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* display_format = "%.0f"); + IMGUI_API bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* display_format = "%.0f"); + IMGUI_API bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* display_format = "%.0f"); + IMGUI_API bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); + IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* display_format = "%.0f"); + + // Widgets: Color Editor/Picker (tip: the ColorEdit* functions have a little colored preview square that can be left-clicked to open a picker, and right-clicked to open an option menu.) + // Note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can the pass the address of a first float element out of a contiguous structure, e.g. &myvector.x + IMGUI_API bool ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags = 0); + IMGUI_API bool ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0); + IMGUI_API bool ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags = 0); + IMGUI_API bool ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags = 0, const float* ref_col = NULL); + IMGUI_API bool ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0)); // display a colored square/button, hover for details, return true when pressed. + IMGUI_API void SetColorEditOptions(ImGuiColorEditFlags flags); // initialize current options (generally on application startup) if you want to select a default format, picker type, etc. User will be able to change many settings, unless you pass the _NoOptions flag to your calls. + + // Widgets: Trees + IMGUI_API bool TreeNode(const char* label); // if returning 'true' the node is open and the tree id is pushed into the id stack. user is responsible for calling TreePop(). + IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...) IM_FMTARGS(2); // read the FAQ about why and how to use ID. to align arbitrary text at the same level as a TreeNode() you can use Bullet(). + IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_FMTARGS(2); // " + IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args) IM_FMTLIST(2); + IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args) IM_FMTLIST(2); + IMGUI_API bool TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags = 0); + IMGUI_API bool TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3); + IMGUI_API bool TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3); + IMGUI_API bool TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3); + IMGUI_API bool TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3); + IMGUI_API void TreePush(const char* str_id); // ~ Indent()+PushId(). Already called by TreeNode() when returning true, but you can call Push/Pop yourself for layout purpose + IMGUI_API void TreePush(const void* ptr_id = NULL); // " + IMGUI_API void TreePop(); // ~ Unindent()+PopId() + IMGUI_API void TreeAdvanceToLabelPos(); // advance cursor x position by GetTreeNodeToLabelSpacing() + IMGUI_API float GetTreeNodeToLabelSpacing(); // horizontal distance preceding label when using TreeNode*() or Bullet() == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode + IMGUI_API void SetNextTreeNodeOpen(bool is_open, ImGuiCond cond = 0); // set next TreeNode/CollapsingHeader open state. + IMGUI_API bool CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags = 0); // if returning 'true' the header is open. doesn't indent nor push on ID stack. user doesn't have to call TreePop(). + IMGUI_API bool CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags = 0); // when 'p_open' isn't NULL, display an additional small close button on upper right of the header + + // Widgets: Selectable / Lists + IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height + IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper. + IMGUI_API bool ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items = -1); + IMGUI_API bool ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1); + IMGUI_API bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0,0)); // use if you want to reimplement ListBox() will custom data or interactions. make sure to call ListBoxFooter() afterwards. + IMGUI_API bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1); // " + IMGUI_API void ListBoxFooter(); // terminate the scrolling region + + // Widgets: Value() Helpers. Output single value in "name: value" format (tip: freely declare more in your code to handle your types. you can add functions to the ImGui namespace) + IMGUI_API void Value(const char* prefix, bool b); + IMGUI_API void Value(const char* prefix, int v); + IMGUI_API void Value(const char* prefix, unsigned int v); + IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL); + + // Tooltips + IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); // set text tooltip under mouse-cursor, typically use with ImGui::IsItemHovered(). overidde any previous call to SetTooltip(). + IMGUI_API void SetTooltipV(const char* fmt, va_list args) IM_FMTLIST(1); + IMGUI_API void BeginTooltip(); // begin/append a tooltip window. to create full-featured tooltip (with any kind of contents). + IMGUI_API void EndTooltip(); + + // Menus + IMGUI_API bool BeginMainMenuBar(); // create and append to a full screen menu-bar. only call EndMainMenuBar() if this returns true! + IMGUI_API void EndMainMenuBar(); + IMGUI_API bool BeginMenuBar(); // append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set on parent window). only call EndMenuBar() if this returns true! + IMGUI_API void EndMenuBar(); + IMGUI_API bool BeginMenu(const char* label, bool enabled = true); // create a sub-menu entry. only call EndMenu() if this returns true! + IMGUI_API void EndMenu(); + IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment + IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL + + // Popups + IMGUI_API void OpenPopup(const char* str_id); // call to mark popup as open (don't call every frame!). popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. By default, Selectable()/MenuItem() are calling CloseCurrentPopup(). Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). + IMGUI_API bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returned true! + IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp! + IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, int mouse_button = 1, bool also_over_items = true); // helper to open and begin popup when clicked on current window. + IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked in void (where there are no imgui windows). + IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // modal dialog (regular window with title bar, block interactions behind the modal window, can't close the modal window by clicking outside) + IMGUI_API void EndPopup(); + IMGUI_API bool OpenPopupOnItemClick(const char* str_id = NULL, int mouse_button = 1); // helper to open popup when clicked on last item. return true when just opened. + IMGUI_API bool IsPopupOpen(const char* str_id); // return true if the popup is open + IMGUI_API void CloseCurrentPopup(); // close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup. + + // Logging/Capture: all text output from interface is captured to tty/file/clipboard. By default, tree nodes are automatically opened during logging. + IMGUI_API void LogToTTY(int max_depth = -1); // start logging to tty + IMGUI_API void LogToFile(int max_depth = -1, const char* filename = NULL); // start logging to file + IMGUI_API void LogToClipboard(int max_depth = -1); // start logging to OS clipboard + IMGUI_API void LogFinish(); // stop logging (close file, etc.) + IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard + IMGUI_API void LogText(const char* fmt, ...) IM_FMTARGS(1); // pass text data straight to log (without being displayed) + + // Drag and Drop + // [BETA API] Missing Demo code. API may evolve. + IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0, int mouse_button = 0); // call when the current item is active. If this return true, you can call SetDragDropPayload() + EndDragDropSource() + IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t size, ImGuiCond cond = 0);// type is a user defined string of maximum 8 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui. + IMGUI_API void EndDragDropSource(); + IMGUI_API bool BeginDragDropTarget(); // call after submitting an item that may receive an item. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget() + IMGUI_API const ImGuiPayload* AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags = 0); // accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released. + IMGUI_API void EndDragDropTarget(); + + // Clipping + IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect); + IMGUI_API void PopClipRect(); + + // Styles + IMGUI_API void StyleColorsClassic(ImGuiStyle* dst = NULL); + IMGUI_API void StyleColorsDark(ImGuiStyle* dst = NULL); + IMGUI_API void StyleColorsLight(ImGuiStyle* dst = NULL); + + // Focus + // (FIXME: Those functions will be reworked after we merge the navigation branch + have a pass at focusing/tabbing features.) + // (Prefer using "SetItemDefaultFocus()" over "if (IsWindowAppearing()) SetScrollHere()" when applicable, to make your code more forward compatible when navigation branch is merged) + IMGUI_API void SetItemDefaultFocus(); // make last item the default focused item of a window (WIP navigation branch only). Pleaase use instead of SetScrollHere(). + IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use -1 to access previous widget. + + // Utilities + IMGUI_API bool IsItemHovered(ImGuiHoveredFlags flags = 0); // is the last item hovered? (and usable, aka not blocked by a popup, etc.). See ImGuiHoveredFlags for more options. + IMGUI_API bool IsItemActive(); // is the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false) + IMGUI_API bool IsItemClicked(int mouse_button = 0); // is the last item clicked? (e.g. button/node just clicked on) + IMGUI_API bool IsItemVisible(); // is the last item visible? (aka not out of sight due to clipping/scrolling.) + IMGUI_API bool IsAnyItemHovered(); + IMGUI_API bool IsAnyItemActive(); + IMGUI_API ImVec2 GetItemRectMin(); // get bounding rectangle of last item, in screen space + IMGUI_API ImVec2 GetItemRectMax(); // " + IMGUI_API ImVec2 GetItemRectSize(); // get size of last item, in screen space + IMGUI_API void SetItemAllowOverlap(); // allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area. + IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags = 0); // is current window focused? or its root/child, depending on flags. see flags for options. + IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags = 0); // is current window hovered (and typically: not blocked by a popup/modal)? see flags for options. + IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped. + IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side. + IMGUI_API float GetTime(); + IMGUI_API int GetFrameCount(); + IMGUI_API ImDrawList* GetOverlayDrawList(); // this draw list will be the last rendered one, useful to quickly draw overlays shapes/text + IMGUI_API ImDrawListSharedData* GetDrawListSharedData(); + IMGUI_API const char* GetStyleColorName(ImGuiCol idx); + IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f); + IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can. + + IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags = 0); // helper to create a child window / scrolling region that looks like a normal widget frame + IMGUI_API void EndChildFrame(); + + IMGUI_API ImVec4 ColorConvertU32ToFloat4(ImU32 in); + IMGUI_API ImU32 ColorConvertFloat4ToU32(const ImVec4& in); + IMGUI_API void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v); + IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b); + + // Inputs + IMGUI_API int GetKeyIndex(ImGuiKey imgui_key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key] + IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index]. note that imgui doesn't know the semantic of each entry of io.KeyDown[]. Use your own indices/enums according to how your backend/engine stored them into KeyDown[]! + IMGUI_API bool IsKeyPressed(int user_key_index, bool repeat = true); // was key pressed (went from !Down to Down). if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate + IMGUI_API bool IsKeyReleased(int user_key_index); // was key released (went from Down to !Down).. + IMGUI_API int GetKeyPressedAmount(int key_index, float repeat_delay, float rate); // uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate + IMGUI_API bool IsMouseDown(int button); // is mouse button held + IMGUI_API bool IsMouseClicked(int button, bool repeat = false); // did mouse button clicked (went from !Down to Down) + IMGUI_API bool IsMouseDoubleClicked(int button); // did mouse button double-clicked. a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime. + IMGUI_API bool IsMouseReleased(int button); // did mouse button released (went from Down to !Down) + IMGUI_API bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); // is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold + IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true); // is mouse hovering given bounding rect (in screen space). clipped by current clipping settings. disregarding of consideration of focus/window ordering/blocked by a popup. + IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // + IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls + IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve backup of mouse positioning at the time of opening popup we have BeginPopup() into + IMGUI_API ImVec2 GetMouseDragDelta(int button = 0, float lock_threshold = -1.0f); // dragging amount since clicking. if lock_threshold < -1.0f uses io.MouseDraggingThreshold + IMGUI_API void ResetMouseDragDelta(int button = 0); // + IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired cursor type, reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you + IMGUI_API void SetMouseCursor(ImGuiMouseCursor type); // set desired cursor type + IMGUI_API void CaptureKeyboardFromApp(bool capture = true); // manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application handle). e.g. force capture keyboard when your widget is being hovered. + IMGUI_API void CaptureMouseFromApp(bool capture = true); // manually override io.WantCaptureMouse flag next frame (said flag is entirely left for your application handle). + + // Helpers functions to access functions pointers in ImGui::GetIO() + IMGUI_API void* MemAlloc(size_t sz); + IMGUI_API void MemFree(void* ptr); + IMGUI_API const char* GetClipboardText(); + IMGUI_API void SetClipboardText(const char* text); + + // Internal context access - if you want to use multiple context, share context between modules (e.g. DLL). There is a default context created and active by default. + // All contexts share a same ImFontAtlas by default. If you want different font atlas, you can new() them and overwrite the GetIO().Fonts variable of an ImGui context. + IMGUI_API const char* GetVersion(); + IMGUI_API ImGuiContext* CreateContext(void* (*malloc_fn)(size_t) = NULL, void (*free_fn)(void*) = NULL); + IMGUI_API void DestroyContext(ImGuiContext* ctx); + IMGUI_API ImGuiContext* GetCurrentContext(); + IMGUI_API void SetCurrentContext(ImGuiContext* ctx); + +} // namespace ImGui + +// Flags for ImGui::Begin() +enum ImGuiWindowFlags_ +{ + ImGuiWindowFlags_NoTitleBar = 1 << 0, // Disable title-bar + ImGuiWindowFlags_NoResize = 1 << 1, // Disable user resizing with the lower-right grip + ImGuiWindowFlags_NoMove = 1 << 2, // Disable user moving the window + ImGuiWindowFlags_NoScrollbar = 1 << 3, // Disable scrollbars (window can still scroll with mouse or programatically) + ImGuiWindowFlags_NoScrollWithMouse = 1 << 4, // Disable user vertically scrolling with mouse wheel. On child window, mouse wheel will be forwarded to the parent unless NoScrollbar is also set. + ImGuiWindowFlags_NoCollapse = 1 << 5, // Disable user collapsing window by double-clicking on it + ImGuiWindowFlags_AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame + ImGuiWindowFlags_ShowBorders = 1 << 7, // Show borders around windows and items (OBSOLETE! Use e.g. style.FrameBorderSize=1.0f to enable borders). + ImGuiWindowFlags_NoSavedSettings = 1 << 8, // Never load/save settings in .ini file + ImGuiWindowFlags_NoInputs = 1 << 9, // Disable catching mouse or keyboard inputs, hovering test with pass through. + ImGuiWindowFlags_MenuBar = 1 << 10, // Has a menu-bar + ImGuiWindowFlags_HorizontalScrollbar = 1 << 11, // Allow horizontal scrollbar to appear (off by default). You may use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section. + ImGuiWindowFlags_NoFocusOnAppearing = 1 << 12, // Disable taking focus when transitioning from hidden to visible state + ImGuiWindowFlags_NoBringToFrontOnFocus = 1 << 13, // Disable bringing window to front when taking focus (e.g. clicking on it or programatically giving it focus) + ImGuiWindowFlags_AlwaysVerticalScrollbar= 1 << 14, // Always show vertical scrollbar (even if ContentSize.y < Size.y) + ImGuiWindowFlags_AlwaysHorizontalScrollbar=1<< 15, // Always show horizontal scrollbar (even if ContentSize.x < Size.x) + ImGuiWindowFlags_AlwaysUseWindowPadding = 1 << 16, // Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient) + ImGuiWindowFlags_ResizeFromAnySide = 1 << 17, // (WIP) Enable resize from any corners and borders. Your back-end needs to honor the different values of io.MouseCursor set by imgui. + + // [Internal] + ImGuiWindowFlags_ChildWindow = 1 << 24, // Don't use! For internal use by BeginChild() + ImGuiWindowFlags_Tooltip = 1 << 25, // Don't use! For internal use by BeginTooltip() + ImGuiWindowFlags_Popup = 1 << 26, // Don't use! For internal use by BeginPopup() + ImGuiWindowFlags_Modal = 1 << 27, // Don't use! For internal use by BeginPopupModal() + ImGuiWindowFlags_ChildMenu = 1 << 28, // Don't use! For internal use by BeginMenu() + ImGuiWindowFlags_CoolStyle = 1 << 29, + ImGuiWindowFlags_GroupBox = 1 << 30 // Don't use! For internal use by BeginGroupBox() +}; + +// Flags for ImGui::InputText() +enum ImGuiInputTextFlags_ +{ + ImGuiInputTextFlags_CharsDecimal = 1 << 0, // Allow 0123456789.+-*/ + ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef + ImGuiInputTextFlags_CharsUppercase = 1 << 2, // Turn a..z into A..Z + ImGuiInputTextFlags_CharsNoBlank = 1 << 3, // Filter out spaces, tabs + ImGuiInputTextFlags_AutoSelectAll = 1 << 4, // Select entire text when first taking mouse focus + ImGuiInputTextFlags_EnterReturnsTrue = 1 << 5, // Return 'true' when Enter is pressed (as opposed to when the value was modified) + ImGuiInputTextFlags_CallbackCompletion = 1 << 6, // Call user function on pressing TAB (for completion handling) + ImGuiInputTextFlags_CallbackHistory = 1 << 7, // Call user function on pressing Up/Down arrows (for history handling) + ImGuiInputTextFlags_CallbackAlways = 1 << 8, // Call user function every time. User code may query cursor position, modify text buffer. + ImGuiInputTextFlags_CallbackCharFilter = 1 << 9, // Call user function to filter character. Modify data->EventChar to replace/filter input, or return 1 to discard character. + ImGuiInputTextFlags_AllowTabInput = 1 << 10, // Pressing TAB input a '\t' character into the text field + ImGuiInputTextFlags_CtrlEnterForNewLine = 1 << 11, // In multi-line mode, unfocus with Enter, add new line with Ctrl+Enter (default is opposite: unfocus with Ctrl+Enter, add line with Enter). + ImGuiInputTextFlags_NoHorizontalScroll = 1 << 12, // Disable following the cursor horizontally + ImGuiInputTextFlags_AlwaysInsertMode = 1 << 13, // Insert mode + ImGuiInputTextFlags_ReadOnly = 1 << 14, // Read-only mode + ImGuiInputTextFlags_Password = 1 << 15, // Password mode, display all characters as '*' + ImGuiInputTextFlags_NoUndoRedo = 1 << 16, // Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID(). + // [Internal] + ImGuiInputTextFlags_Multiline = 1 << 20 // For internal use by InputTextMultiline() +}; + +// Flags for ImGui::TreeNodeEx(), ImGui::CollapsingHeader*() +enum ImGuiTreeNodeFlags_ +{ + ImGuiTreeNodeFlags_Selected = 1 << 0, // Draw as selected + ImGuiTreeNodeFlags_Framed = 1 << 1, // Full colored frame (e.g. for CollapsingHeader) + ImGuiTreeNodeFlags_AllowItemOverlap = 1 << 2, // Hit testing to allow subsequent widgets to overlap this one + ImGuiTreeNodeFlags_NoTreePushOnOpen = 1 << 3, // Don't do a TreePush() when open (e.g. for CollapsingHeader) = no extra indent nor pushing on ID stack + ImGuiTreeNodeFlags_NoAutoOpenOnLog = 1 << 4, // Don't automatically and temporarily open node when Logging is active (by default logging will automatically open tree nodes) + ImGuiTreeNodeFlags_DefaultOpen = 1 << 5, // Default node to be open + ImGuiTreeNodeFlags_OpenOnDoubleClick = 1 << 6, // Need double-click to open node + ImGuiTreeNodeFlags_OpenOnArrow = 1 << 7, // Only open when clicking on the arrow part. If ImGuiTreeNodeFlags_OpenOnDoubleClick is also set, single-click arrow or double-click all box to open. + ImGuiTreeNodeFlags_Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes). + ImGuiTreeNodeFlags_Bullet = 1 << 9, // Display a bullet instead of arrow + ImGuiTreeNodeFlags_FramePadding = 1 << 10, // Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding(). + //ImGuITreeNodeFlags_SpanAllAvailWidth = 1 << 11, // FIXME: TODO: Extend hit box horizontally even if not framed + //ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 12, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible + ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoAutoOpenOnLog + + // Obsolete names (will be removed) +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + , ImGuiTreeNodeFlags_AllowOverlapMode = ImGuiTreeNodeFlags_AllowItemOverlap +#endif +}; + +// Flags for ImGui::Selectable() +enum ImGuiSelectableFlags_ +{ + ImGuiSelectableFlags_DontClosePopups = 1 << 0, // Clicking this don't close parent popup window + ImGuiSelectableFlags_SpanAllColumns = 1 << 1, // Selectable frame can span all columns (text will still fit in current column) + ImGuiSelectableFlags_AllowDoubleClick = 1 << 2 // Generate press events on double clicks too +}; + +// Flags for ImGui::BeginCombo() +enum ImGuiComboFlags_ +{ + ImGuiComboFlags_PopupAlignLeft = 1 << 0, // Align the popup toward the left by default + ImGuiComboFlags_HeightSmall = 1 << 1, // Max ~4 items visible. Tip: If you want your combo popup to be a specific size you can use SetNextWindowSizeConstraints() prior to calling BeginCombo() + ImGuiComboFlags_HeightRegular = 1 << 2, // Max ~8 items visible (default) + ImGuiComboFlags_HeightLarge = 1 << 3, // Max ~20 items visible + ImGuiComboFlags_HeightLargest = 1 << 4, // As many fitting items as possible + ImGuiComboFlags_HeightMask_ = ImGuiComboFlags_HeightSmall | ImGuiComboFlags_HeightRegular | ImGuiComboFlags_HeightLarge | ImGuiComboFlags_HeightLargest +}; + +// Flags for ImGui::IsWindowFocused() +enum ImGuiFocusedFlags_ +{ + ImGuiFocusedFlags_ChildWindows = 1 << 0, // IsWindowFocused(): Return true if any children of the window is focused + ImGuiFocusedFlags_RootWindow = 1 << 1, // IsWindowFocused(): Test from root window (top most parent of the current hierarchy) + ImGuiFocusedFlags_AnyWindow = 1 << 2, // IsWindowFocused(): Return true if any window is focused + ImGuiFocusedFlags_RootAndChildWindows = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows +}; + +// Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered() +enum ImGuiHoveredFlags_ +{ + ImGuiHoveredFlags_Default = 0, // Return true if directly over the item/window, not obstructed by another window, not obstructed by an active popup or modal blocking inputs under them. + ImGuiHoveredFlags_ChildWindows = 1 << 0, // IsWindowHovered() only: Return true if any children of the window is hovered + ImGuiHoveredFlags_RootWindow = 1 << 1, // IsWindowHovered() only: Test from root window (top most parent of the current hierarchy) + ImGuiHoveredFlags_AnyWindow = 1 << 2, // IsWindowHovered() only: Return true if any window is hovered + ImGuiHoveredFlags_AllowWhenBlockedByPopup = 1 << 3, // Return true even if a popup window is normally blocking access to this item/window + //ImGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 4, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet. + ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 5, // Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns. + ImGuiHoveredFlags_AllowWhenOverlapped = 1 << 6, // Return true even if the position is overlapped by another window + ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped, + ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows +}; + +// Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload() +enum ImGuiDragDropFlags_ +{ + // BeginDragDropSource() flags + ImGuiDragDropFlags_SourceNoPreviewTooltip = 1 << 0, // By default, a successful call to BeginDragDropSource opens a tooltip so you can display a preview or description of the source contents. This flag disable this behavior. + ImGuiDragDropFlags_SourceNoDisableHover = 1 << 1, // By default, when dragging we clear data so that IsItemHovered() will return true, to avoid subsequent user code submitting tooltips. This flag disable this behavior so you can still call IsItemHovered() on the source item. + ImGuiDragDropFlags_SourceNoHoldToOpenOthers = 1 << 2, // Disable the behavior that allows to open tree nodes and collapsing header by holding over them while dragging a source item. + ImGuiDragDropFlags_SourceAllowNullID = 1 << 3, // Allow items such as Text(), Image() that have no unique identifier to be used as drag source, by manufacturing a temporary identifier based on their window-relative position. This is extremely unusual within the dear imgui ecosystem and so we made it explicit. + ImGuiDragDropFlags_SourceExtern = 1 << 4, // External source (from outside of imgui), won't attempt to read current item/window info. Will always return true. Only one Extern source can be active simultaneously. + // AcceptDragDropPayload() flags + ImGuiDragDropFlags_AcceptBeforeDelivery = 1 << 10, // AcceptDragDropPayload() will returns true even before the mouse button is released. You can then call IsDelivery() to test if the payload needs to be delivered. + ImGuiDragDropFlags_AcceptNoDrawDefaultRect = 1 << 11, // Do not draw the default highlight rectangle when hovering over target. + ImGuiDragDropFlags_AcceptPeekOnly = ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect // For peeking ahead and inspecting the payload before delivery. +}; + +// Standard Drag and Drop payload types. You can define you own payload types using 8-characters long strings. Types starting with '_' are defined by Dear ImGui. +#define IMGUI_PAYLOAD_TYPE_COLOR_3F "_COL3F" // float[3] // Standard type for colors, without alpha. User code may use this type. +#define IMGUI_PAYLOAD_TYPE_COLOR_4F "_COL4F" // float[4] // Standard type for colors. User code may use this type. + +// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array +enum ImGuiKey_ +{ + ImGuiKey_Tab, // for tabbing through fields + ImGuiKey_LeftArrow, // for text edit + ImGuiKey_RightArrow,// for text edit + ImGuiKey_UpArrow, // for text edit + ImGuiKey_DownArrow, // for text edit + ImGuiKey_PageUp, + ImGuiKey_PageDown, + ImGuiKey_Home, // for text edit + ImGuiKey_End, // for text edit + ImGuiKey_Insert, // for text edit + ImGuiKey_Delete, // for text edit + ImGuiKey_Backspace, // for text edit + ImGuiKey_Enter, // for text edit + ImGuiKey_Escape, // for text edit + ImGuiKey_A, // for text edit CTRL+A: select all + ImGuiKey_C, // for text edit CTRL+C: copy + ImGuiKey_V, // for text edit CTRL+V: paste + ImGuiKey_X, // for text edit CTRL+X: cut + ImGuiKey_Y, // for text edit CTRL+Y: redo + ImGuiKey_Z, // for text edit CTRL+Z: undo + ImGuiKey_COUNT +}; + +// Enumeration for PushStyleColor() / PopStyleColor() +enum ImGuiCol_ +{ + ImGuiCol_Text, + ImGuiCol_TextDisabled, + ImGuiCol_WindowBg, // Background of normal windows + ImGuiCol_ChildBg, // Background of child windows + ImGuiCol_PopupBg, // Background of popups, menus, tooltips windows + ImGuiCol_Border, + ImGuiCol_BorderShadow, + ImGuiCol_FrameBg, // Background of checkbox, radio button, plot, slider, text input + ImGuiCol_FrameBgHovered, + ImGuiCol_FrameBgActive, + ImGuiCol_TitleBg, + ImGuiCol_TitleBgActive, + ImGuiCol_TitleBgCollapsed, + ImGuiCol_MenuBarBg, + ImGuiCol_ScrollbarBg, + ImGuiCol_ScrollbarGrab, + ImGuiCol_ScrollbarGrabHovered, + ImGuiCol_ScrollbarGrabActive, + ImGuiCol_CheckMark, + ImGuiCol_SliderGrab, + ImGuiCol_SliderGrabActive, + ImGuiCol_Button, + ImGuiCol_ButtonHovered, + ImGuiCol_ButtonActive, + ImGuiCol_Header, + ImGuiCol_HeaderHovered, + ImGuiCol_HeaderActive, + ImGuiCol_Separator, + ImGuiCol_SeparatorHovered, + ImGuiCol_SeparatorActive, + ImGuiCol_ResizeGrip, + ImGuiCol_ResizeGripHovered, + ImGuiCol_ResizeGripActive, + ImGuiCol_CloseButton, + ImGuiCol_CloseButtonHovered, + ImGuiCol_CloseButtonActive, + ImGuiCol_PlotLines, + ImGuiCol_PlotLinesHovered, + ImGuiCol_PlotHistogram, + ImGuiCol_PlotHistogramHovered, + ImGuiCol_TextSelectedBg, + ImGuiCol_ModalWindowDarkening, // darken entire screen when a modal window is active + ImGuiCol_DragDropTarget, + ImGuiCol_Tab, + ImGuiCol_TabHovered, + ImGuiCol_TabActive, + ImGuiCol_TabText, + ImGuiCol_TabTextActive, + ImGuiCol_TabSelected, + ImGuiCol_COUNT + + // Obsolete names (will be removed) +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + //, ImGuiCol_ComboBg = ImGuiCol_PopupBg // ComboBg has been merged with PopupBg, so a redirect isn't accurate. + , ImGuiCol_ChildWindowBg = ImGuiCol_ChildBg, ImGuiCol_Column = ImGuiCol_Separator, ImGuiCol_ColumnHovered = ImGuiCol_SeparatorHovered, ImGuiCol_ColumnActive = ImGuiCol_SeparatorActive +#endif +}; + +// Enumeration for PushStyleVar() / PopStyleVar() to temporarily modify the ImGuiStyle structure. +// NB: the enum only refers to fields of ImGuiStyle which makes sense to be pushed/popped inside UI code. During initialization, feel free to just poke into ImGuiStyle directly. +// NB: if changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type. +enum ImGuiStyleVar_ +{ + // Enum name ......................// Member in ImGuiStyle structure (see ImGuiStyle for descriptions) + ImGuiStyleVar_Alpha, // float Alpha + ImGuiStyleVar_WindowPadding, // ImVec2 WindowPadding + ImGuiStyleVar_WindowRounding, // float WindowRounding + ImGuiStyleVar_WindowBorderSize, // float WindowBorderSize + ImGuiStyleVar_WindowMinSize, // ImVec2 WindowMinSize + ImGuiStyleVar_ChildRounding, // float ChildRounding + ImGuiStyleVar_ChildBorderSize, // float ChildBorderSize + ImGuiStyleVar_PopupRounding, // float PopupRounding + ImGuiStyleVar_PopupBorderSize, // float PopupBorderSize + ImGuiStyleVar_FramePadding, // ImVec2 FramePadding + ImGuiStyleVar_FrameRounding, // float FrameRounding + ImGuiStyleVar_FrameBorderSize, // float FrameBorderSize + ImGuiStyleVar_ItemSpacing, // ImVec2 ItemSpacing + ImGuiStyleVar_ItemInnerSpacing, // ImVec2 ItemInnerSpacing + ImGuiStyleVar_IndentSpacing, // float IndentSpacing + ImGuiStyleVar_GrabMinSize, // float GrabMinSize + ImGuiStyleVar_ButtonTextAlign, // ImVec2 ButtonTextAlign + ImGuiStyleVar_Count_ + + // Obsolete names (will be removed) +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + , ImGuiStyleVar_ChildWindowRounding = ImGuiStyleVar_ChildRounding +#endif +}; + +// Enumeration for ColorEdit3() / ColorEdit4() / ColorPicker3() / ColorPicker4() / ColorButton() +enum ImGuiColorEditFlags_ +{ + ImGuiColorEditFlags_NoAlpha = 1 << 1, // // ColorEdit, ColorPicker, ColorButton: ignore Alpha component (read 3 components from the input pointer). + ImGuiColorEditFlags_NoPicker = 1 << 2, // // ColorEdit: disable picker when clicking on colored square. + ImGuiColorEditFlags_NoOptions = 1 << 3, // // ColorEdit: disable toggling options menu when right-clicking on inputs/small preview. + ImGuiColorEditFlags_NoSmallPreview = 1 << 4, // // ColorEdit, ColorPicker: disable colored square preview next to the inputs. (e.g. to show only the inputs) + ImGuiColorEditFlags_NoInputs = 1 << 5, // // ColorEdit, ColorPicker: disable inputs sliders/text widgets (e.g. to show only the small preview colored square). + ImGuiColorEditFlags_NoTooltip = 1 << 6, // // ColorEdit, ColorPicker, ColorButton: disable tooltip when hovering the preview. + ImGuiColorEditFlags_NoLabel = 1 << 7, // // ColorEdit, ColorPicker: disable display of inline text label (the label is still forwarded to the tooltip and picker). + ImGuiColorEditFlags_NoSidePreview = 1 << 8, // // ColorPicker: disable bigger color preview on right side of the picker, use small colored square preview instead. + // User Options (right-click on widget to change some of them). You can set application defaults using SetColorEditOptions(). The idea is that you probably don't want to override them in most of your calls, let the user choose and/or call SetColorEditOptions() during startup. + ImGuiColorEditFlags_AlphaBar = 1 << 9, // // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker. + ImGuiColorEditFlags_AlphaPreview = 1 << 10, // // ColorEdit, ColorPicker, ColorButton: display preview as a transparent color over a checkerboard, instead of opaque. + ImGuiColorEditFlags_AlphaPreviewHalf= 1 << 11, // // ColorEdit, ColorPicker, ColorButton: display half opaque / half checkerboard, instead of opaque. + ImGuiColorEditFlags_HDR = 1 << 12, // // (WIP) ColorEdit: Currently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use ImGuiColorEditFlags_Float flag as well). + ImGuiColorEditFlags_RGB = 1 << 13, // [Inputs] // ColorEdit: choose one among RGB/HSV/HEX. ColorPicker: choose any combination using RGB/HSV/HEX. + ImGuiColorEditFlags_HSV = 1 << 14, // [Inputs] // " + ImGuiColorEditFlags_HEX = 1 << 15, // [Inputs] // " + ImGuiColorEditFlags_Uint8 = 1 << 16, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0..255. + ImGuiColorEditFlags_Float = 1 << 17, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0.0f..1.0f floats instead of 0..255 integers. No round-trip of value via integers. + ImGuiColorEditFlags_PickerHueBar = 1 << 18, // [PickerMode] // ColorPicker: bar for Hue, rectangle for Sat/Value. + ImGuiColorEditFlags_PickerHueWheel = 1 << 19, // [PickerMode] // ColorPicker: wheel for Hue, triangle for Sat/Value. + ImGuiColorEditFlags_ColorPicker = 1 << 20, + ImGuiColorEditFlags_ColorPickerSameline = 1 << 21, + // Internals/Masks + ImGuiColorEditFlags__InputsMask = ImGuiColorEditFlags_RGB|ImGuiColorEditFlags_HSV|ImGuiColorEditFlags_HEX, + ImGuiColorEditFlags__DataTypeMask = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_Float, + ImGuiColorEditFlags__PickerMask = ImGuiColorEditFlags_PickerHueWheel|ImGuiColorEditFlags_PickerHueBar, + ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_RGB|ImGuiColorEditFlags_PickerHueBar // Change application default using SetColorEditOptions() +}; + +// Enumeration for GetMouseCursor() +enum ImGuiMouseCursor_ +{ + ImGuiMouseCursor_None = -1, + ImGuiMouseCursor_Arrow = 0, + ImGuiMouseCursor_TextInput, // When hovering over InputText, etc. + ImGuiMouseCursor_Move, // Unused + ImGuiMouseCursor_ResizeNS, // When hovering over an horizontal border + ImGuiMouseCursor_ResizeEW, // When hovering over a vertical border or a column + ImGuiMouseCursor_ResizeNESW, // When hovering over the bottom-left corner of a window + ImGuiMouseCursor_ResizeNWSE, // When hovering over the bottom-right corner of a window + ImGuiMouseCursor_Count_ +}; + +// Condition for ImGui::SetWindow***(), SetNextWindow***(), SetNextTreeNode***() functions +// All those functions treat 0 as a shortcut to ImGuiCond_Always. From the point of view of the user use this as an enum (don't combine multiple values into flags). +enum ImGuiCond_ +{ + ImGuiCond_Always = 1 << 0, // set the variable + ImGuiCond_Once = 1 << 1, // set the variable once per runtime session (only the first call with succeed) + ImGuiCond_FirstUseEver = 1 << 2, // set the variable if the window has no saved data (if doesn't exist in the .ini file) + ImGuiCond_Appearing = 1 << 3 // set the variable if the window is appearing after being hidden/inactive (or the first time) + + // Obsolete names (will be removed) +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + , ImGuiSetCond_Always = ImGuiCond_Always, ImGuiSetCond_Once = ImGuiCond_Once, ImGuiSetCond_FirstUseEver = ImGuiCond_FirstUseEver, ImGuiSetCond_Appearing = ImGuiCond_Appearing +#endif +}; + +struct ImGuiStyle +{ + float Alpha; // Global alpha applies to everything in ImGui + ImVec2 WindowPadding; // Padding within a window + float WindowRounding; // Radius of window corners rounding. set to 0.0f to have rectangular windows + float WindowBorderSize; // Thickness of border around windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly) + ImVec2 WindowMinSize; // Minimum window size + ImVec2 WindowTitleAlign; // Alignment for title bar text. Defaults to (0.0f,0.5f) for left-aligned,vertically centered. + float ChildRounding; // Radius of child window corners rounding. set to 0.0f to have rectangular windows. + float ChildBorderSize; // Thickness of border around child windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly) + float PopupRounding; // Radius of popup window corners rounding. + float PopupBorderSize; // Thickness of border around popup windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly) + ImVec2 FramePadding; // Padding within a framed rectangle (used by most widgets) + float FrameRounding; // Radius of frame corners rounding. set to 0.0f to have rectangular frame (used by most widgets). + float FrameBorderSize; // Thickness of border around frames. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly) + ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines + ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label) + ImVec2 TouchExtraPadding; // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much! + float IndentSpacing; // Horizontal indentation when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2). + float ColumnsMinSpacing; // Minimum horizontal spacing between two columns + float ScrollbarSize; // Width of the vertical scrollbar, Height of the horizontal scrollbar + float ScrollbarRounding; // Radius of grab corners for scrollbar + float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar. + float GrabRounding; // Radius of grabs corners rounding. set to 0.0f to have rectangular slider grabs. + ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f,0.5f) for horizontally+vertically centered. + ImVec2 DisplayWindowPadding; // Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows. + ImVec2 DisplaySafeAreaPadding; // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows. + bool AntiAliasedLines; // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU. + bool AntiAliasedFill; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.) + float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. + ImVec4 Colors[ImGuiCol_COUNT]; + + IMGUI_API ImGuiStyle(); + IMGUI_API void ScaleAllSizes(float scale_factor); +}; + +// This is where your app communicate with ImGui. Access via ImGui::GetIO(). +// Read 'Programmer guide' section in .cpp file for general usage. +struct ImGuiIO +{ + //------------------------------------------------------------------ + // Settings (fill once) // Default value: + //------------------------------------------------------------------ + + ImVec2 DisplaySize; // // Display size, in pixels. For clamping windows positions. + float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds. + float IniSavingRate; // = 5.0f // Maximum time between saving positions/sizes to .ini file, in seconds. + const char* IniFilename; // = "imgui.ini" // Path to .ini file. NULL to disable .ini saving. + const char* LogFilename; // = "imgui_log.txt" // Path to .log file (default parameter to ImGui::LogToFile when no file is specified). + float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds. + float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels. + float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging + int KeyMap[ImGuiKey_COUNT]; // // Map of indices into the KeysDown[512] entries array + float KeyRepeatDelay; // = 0.250f // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.). + float KeyRepeatRate; // = 0.050f // When holding a key/button, rate at which it repeats, in seconds. + void* UserData; // = NULL // Store your own data for retrieval by callbacks. + + ImFontAtlas* Fonts; // // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array. + float FontGlobalScale; // = 1.0f // Global scale all fonts + bool FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel. + ImFont* FontDefault; // = NULL // Font to use on NewFrame(). Use NULL to uses Fonts->Fonts[0]. + ImVec2 DisplayFramebufferScale; // = (1.0f,1.0f) // For retina display or other situations where window coordinates are different from framebuffer coordinates. User storage only, presently not used by ImGui. + ImVec2 DisplayVisibleMin; // (0.0f,0.0f) // If you use DisplaySize as a virtual space larger than your screen, set DisplayVisibleMin/Max to the visible area. + ImVec2 DisplayVisibleMax; // (0.0f,0.0f) // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize + + // Advanced/subtle behaviors + bool OptMacOSXBehaviors; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl + bool OptCursorBlink; // = true // Enable blinking cursor, for users who consider it annoying. + + //------------------------------------------------------------------ + // Settings (User Functions) + //------------------------------------------------------------------ + + // Rendering function, will be called in Render(). + // Alternatively you can keep this to NULL and call GetDrawData() after Render() to get the same pointer. + // See example applications if you are unsure of how to implement this. + void (*RenderDrawListsFn)(ImDrawData* data); + + // Optional: access OS clipboard + // (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures) + const char* (*GetClipboardTextFn)(void* user_data); + void (*SetClipboardTextFn)(void* user_data, const char* text); + void* ClipboardUserData; + + // Optional: override memory allocations. MemFreeFn() may be called with a NULL pointer. + // (default to posix malloc/free) + void* (*MemAllocFn)(size_t sz); + void (*MemFreeFn)(void* ptr); + + // Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME in Windows) + // (default to use native imm32 api on Windows) + void (*ImeSetInputScreenPosFn)(int x, int y); + void* ImeWindowHandle; // (Windows) set this to your HWND to get automatic IME cursor positioning. + + //------------------------------------------------------------------ + // Input - Fill before calling NewFrame() + //------------------------------------------------------------------ + + ImVec2 MousePos; // Mouse position, in pixels. set to ImVec2(-FLT_MAX,-FLT_MAX) if mouse is unavailable (on another screen, etc.) + bool MouseDown[5]; // Mouse buttons: left, right, middle + extras. ImGui itself mostly only uses left button (BeginPopupContext** are using right button). Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API. + float MouseWheel; // Mouse wheel: 1 unit scrolls about 5 lines text. + bool MouseDrawCursor; // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). + bool KeyCtrl; // Keyboard modifier pressed: Control + bool KeyShift; // Keyboard modifier pressed: Shift + bool KeyAlt; // Keyboard modifier pressed: Alt + bool KeySuper; // Keyboard modifier pressed: Cmd/Super/Windows + bool KeysDown[512]; // Keyboard keys that are pressed (in whatever storage order you naturally have access to keyboard data) + ImWchar InputCharacters[16+1]; // List of characters input (translated by user from keypress+keyboard state). Fill using AddInputCharacter() helper. + + // Functions + IMGUI_API void AddInputCharacter(ImWchar c); // Add new character into InputCharacters[] + IMGUI_API void AddInputCharactersUTF8(const char* utf8_chars); // Add new characters into InputCharacters[] from an UTF-8 string + inline void ClearInputCharacters() { InputCharacters[0] = 0; } // Clear the text input buffer manually + + //------------------------------------------------------------------ + // Output - Retrieve after calling NewFrame() + //------------------------------------------------------------------ + + bool WantCaptureMouse; // When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. This is set by ImGui when it wants to use your mouse (e.g. unclicked mouse is hovering a window, or a widget is active). + bool WantCaptureKeyboard; // When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. This is set by ImGui when it wants to use your keyboard inputs. + bool WantTextInput; // Mobile/console: when io.WantTextInput is true, you may display an on-screen keyboard. This is set by ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active). + bool WantMoveMouse; // [BETA-NAV] MousePos has been altered, back-end should reposition mouse on next frame. set only when 'NavMovesMouse=true'. + float Framerate; // Application framerate estimation, in frame per second. Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames + int MetricsAllocs; // Number of active memory allocations + int MetricsRenderVertices; // Vertices output during last call to Render() + int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3 + int MetricsActiveWindows; // Number of visible root windows (exclude child windows) + ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are invalid (-FLT_MAX,-FLT_MAX), so a disappearing/reappearing mouse won't have a huge delta. + + //------------------------------------------------------------------ + // [Internal] ImGui will maintain those fields. Forward compatibility not guaranteed! + //------------------------------------------------------------------ + + ImVec2 MousePosPrev; // Previous mouse position temporary storage (nb: not for public use, set to MousePos in NewFrame()) + ImVec2 MouseClickedPos[5]; // Position at time of clicking + float MouseClickedTime[5]; // Time of last click (used to figure out double-click) + bool MouseClicked[5]; // Mouse button went from !Down to Down + bool MouseDoubleClicked[5]; // Has mouse button been double-clicked? + bool MouseReleased[5]; // Mouse button went from Down to !Down + bool MouseDownOwned[5]; // Track if button was clicked inside a window. We don't request mouse capture from the application if click started outside ImGui bounds. + float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked) + float MouseDownDurationPrev[5]; // Previous time the mouse button has been down + ImVec2 MouseDragMaxDistanceAbs[5]; // Maximum distance, absolute, on each axis, of how much mouse has traveled from the clicking point + float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point + float KeysDownDuration[512]; // Duration the keyboard key has been down (0.0f == just pressed) + float KeysDownDurationPrev[512]; // Previous duration the key has been down + + IMGUI_API ImGuiIO(); +}; + +//----------------------------------------------------------------------------- +// Obsolete functions (Will be removed! Read 'API BREAKING CHANGES' section in imgui.cpp for details) +//----------------------------------------------------------------------------- + +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS +namespace ImGui +{ + // OBSOLETED in 1.54 (from Dec 2017) + static inline bool IsAnyWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_AnyWindow); } + static inline bool IsAnyWindowHovered() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); } + static inline ImVec2 CalcItemRectClosestPoint(const ImVec2& pos, bool on_edge = false, float outward = 0.f) { (void)on_edge; (void)outward; IM_ASSERT(0); return pos; } + // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017) + static inline void ShowTestWindow() { return ShowDemoWindow(); } + static inline bool IsRootWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootWindow); } + static inline bool IsRootWindowOrAnyChildFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); } + static inline void SetNextWindowContentWidth(float w) { SetNextWindowContentSize(ImVec2(w, 0.0f)); } + // OBSOLETED in 1.52 (between Aug 2017 and Oct 2017) + bool Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha_override = -1.0f, ImGuiWindowFlags flags = 0); // Use SetNextWindowSize() instead if you want to set a window size. + static inline bool IsRootWindowOrAnyChildHovered() { return IsItemHovered(ImGuiHoveredFlags_RootAndChildWindows); } + static inline void AlignFirstTextHeightToWidgets() { AlignTextToFramePadding(); } + static inline void SetNextWindowPosCenter(ImGuiCond c=0) { ImGuiIO& io = GetIO(); SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), c, ImVec2(0.5f, 0.5f)); } + // OBSOLETED in 1.51 (between Jun 2017 and Aug 2017) + static inline bool IsItemHoveredRect() { return IsItemHovered(ImGuiHoveredFlags_RectOnly); } + static inline bool IsPosHoveringAnyWindow(const ImVec2&) { IM_ASSERT(0); return false; } // This was misleading and partly broken. You probably want to use the ImGui::GetIO().WantCaptureMouse flag instead. + static inline bool IsMouseHoveringAnyWindow() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); } + static inline bool IsMouseHoveringWindow() { return IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem); } + // OBSOLETED IN 1.49 (between Apr 2016 and May 2016) + static inline bool CollapsingHeader(const char* label, const char* str_id, bool framed = true, bool default_open = false) { (void)str_id; (void)framed; ImGuiTreeNodeFlags default_open_flags = 1 << 5; return CollapsingHeader(label, (default_open ? default_open_flags : 0)); } +} +#endif + +//----------------------------------------------------------------------------- +// Helpers +//----------------------------------------------------------------------------- + +// Lightweight std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug). +// Our implementation does NOT call C++ constructors/destructors. This is intentional and we do not require it. Do not use this class as a straight std::vector replacement in your code! +template +class ImVector +{ +public: + int Size; + int Capacity; + T* Data; + + typedef T value_type; + typedef value_type* iterator; + typedef const value_type* const_iterator; + + inline ImVector() { Size = Capacity = 0; Data = NULL; } + inline ~ImVector() { if (Data) ImGui::MemFree(Data); } + + inline bool empty() const { return Size == 0; } + inline int size() const { return Size; } + inline int capacity() const { return Capacity; } + + inline value_type& operator[](int i) { IM_ASSERT(i < Size); return Data[i]; } + inline const value_type& operator[](int i) const { IM_ASSERT(i < Size); return Data[i]; } + + inline void clear() { if (Data) { Size = Capacity = 0; ImGui::MemFree(Data); Data = NULL; } } + inline iterator begin() { return Data; } + inline const_iterator begin() const { return Data; } + inline iterator end() { return Data + Size; } + inline const_iterator end() const { return Data + Size; } + inline value_type& front() { IM_ASSERT(Size > 0); return Data[0]; } + inline const value_type& front() const { IM_ASSERT(Size > 0); return Data[0]; } + inline value_type& back() { IM_ASSERT(Size > 0); return Data[Size - 1]; } + inline const value_type& back() const { IM_ASSERT(Size > 0); return Data[Size - 1]; } + inline void swap(ImVector& rhs) { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; } + + inline int _grow_capacity(int sz) const { int new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > sz ? new_capacity : sz; } + + inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; } + inline void resize(int new_size, const T& v){ if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) Data[n] = v; Size = new_size; } + inline void reserve(int new_capacity) + { + if (new_capacity <= Capacity) + return; + T* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(T)); + if (Data) + memcpy(new_data, Data, (size_t)Size * sizeof(T)); + ImGui::MemFree(Data); + Data = new_data; + Capacity = new_capacity; + } + + inline void push_back(const value_type& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); Data[Size++] = v; } + inline void pop_back() { IM_ASSERT(Size > 0); Size--; } + inline void push_front(const value_type& v) { if (Size == 0) push_back(v); else insert(Data, v); } + + inline iterator erase(const_iterator it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(value_type)); Size--; return Data + off; } + inline iterator insert(const_iterator it, const value_type& v) { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(value_type)); Data[off] = v; Size++; return Data + off; } + inline bool contains(const value_type& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; } +}; + +// Helper: execute a block of code at maximum once a frame. Convenient if you want to quickly create an UI within deep-nested code that runs multiple times every frame. +// Usage: +// static ImGuiOnceUponAFrame oaf; +// if (oaf) +// ImGui::Text("This will be called only once per frame"); +struct ImGuiOnceUponAFrame +{ + ImGuiOnceUponAFrame() { RefFrame = -1; } + mutable int RefFrame; + operator bool() const { int current_frame = ImGui::GetFrameCount(); if (RefFrame == current_frame) return false; RefFrame = current_frame; return true; } +}; + +// Helper macro for ImGuiOnceUponAFrame. Attention: The macro expands into 2 statement so make sure you don't use it within e.g. an if() statement without curly braces. +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS // Will obsolete +#define IMGUI_ONCE_UPON_A_FRAME static ImGuiOnceUponAFrame imgui_oaf; if (imgui_oaf) +#endif + +// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]" +struct ImGuiTextFilter +{ + struct TextRange + { + const char* b; + const char* e; + + TextRange() { b = e = NULL; } + TextRange(const char* _b, const char* _e) { b = _b; e = _e; } + const char* begin() const { return b; } + const char* end() const { return e; } + bool empty() const { return b == e; } + char front() const { return *b; } + static bool is_blank(char c) { return c == ' ' || c == '\t'; } + void trim_blanks() { while (b < e && is_blank(*b)) b++; while (e > b && is_blank(*(e-1))) e--; } + IMGUI_API void split(char separator, ImVector& out); + }; + + char InputBuf[256]; + ImVector Filters; + int CountGrep; + + IMGUI_API ImGuiTextFilter(const char* default_filter = ""); + IMGUI_API bool Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build + IMGUI_API bool PassFilter(const char* text, const char* text_end = NULL) const; + IMGUI_API void Build(); + void Clear() { InputBuf[0] = 0; Build(); } + bool IsActive() const { return !Filters.empty(); } +}; + +// Helper: Text buffer for logging/accumulating text +struct ImGuiTextBuffer +{ + ImVector Buf; + + ImGuiTextBuffer() { Buf.push_back(0); } + inline char operator[](int i) { return Buf.Data[i]; } + const char* begin() const { return &Buf.front(); } + const char* end() const { return &Buf.back(); } // Buf is zero-terminated, so end() will point on the zero-terminator + int size() const { return Buf.Size - 1; } + bool empty() { return Buf.Size <= 1; } + void clear() { Buf.clear(); Buf.push_back(0); } + void reserve(int capacity) { Buf.reserve(capacity); } + const char* c_str() const { return Buf.Data; } + IMGUI_API void appendf(const char* fmt, ...) IM_FMTARGS(2); + IMGUI_API void appendfv(const char* fmt, va_list args) IM_FMTLIST(2); +}; + +// Helper: Simple Key->value storage +// Typically you don't have to worry about this since a storage is held within each Window. +// We use it to e.g. store collapse state for a tree (Int 0/1), store color edit options. +// This is optimized for efficient reading (dichotomy into a contiguous buffer), rare writing (typically tied to user interactions) +// You can use it as custom user storage for temporary values. Declare your own storage if, for example: +// - You want to manipulate the open/close state of a particular sub-tree in your interface (tree node uses Int 0/1 to store their state). +// - You want to store custom debug data easily without adding or editing structures in your code (probably not efficient, but convenient) +// Types are NOT stored, so it is up to you to make sure your Key don't collide with different types. +struct ImGuiStorage +{ + struct Pair + { + ImGuiID key; + union { int val_i; float val_f; void* val_p; }; + Pair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; } + Pair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; } + Pair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; } + }; + ImVector Data; + + // - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N) + // - set***() functions find pair, insertion on demand if missing. + // - Sorted insertion is costly, paid once. A typical frame shouldn't need to insert any new pair. + void Clear() { Data.clear(); } + IMGUI_API int GetInt(ImGuiID key, int default_val = 0) const; + IMGUI_API void SetInt(ImGuiID key, int val); + IMGUI_API bool GetBool(ImGuiID key, bool default_val = false) const; + IMGUI_API void SetBool(ImGuiID key, bool val); + IMGUI_API float GetFloat(ImGuiID key, float default_val = 0.0f) const; + IMGUI_API void SetFloat(ImGuiID key, float val); + IMGUI_API void* GetVoidPtr(ImGuiID key) const; // default_val is NULL + IMGUI_API void SetVoidPtr(ImGuiID key, void* val); + + // - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+set. + // - References are only valid until a new value is added to the storage. Calling a set***() function or a Get***Ref() function invalidates the pointer. + // - A typical use case where this is convenient for quick hacking (e.g. add storage during a live Edit&Continue session if you can't modify existing struct) + // float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar; + IMGUI_API int* GetIntRef(ImGuiID key, int default_val = 0); + IMGUI_API bool* GetBoolRef(ImGuiID key, bool default_val = false); + IMGUI_API float* GetFloatRef(ImGuiID key, float default_val = 0.0f); + IMGUI_API void** GetVoidPtrRef(ImGuiID key, void* default_val = NULL); + + // Use on your own storage if you know only integer are being stored (open/close all tree nodes) + IMGUI_API void SetAllInt(int val); + + // For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once. + IMGUI_API void BuildSortByKey(); +}; + +// Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used and the corresponding callback is triggered. +struct ImGuiTextEditCallbackData +{ + ImGuiInputTextFlags EventFlag; // One of ImGuiInputTextFlags_Callback* // Read-only + ImGuiInputTextFlags Flags; // What user passed to InputText() // Read-only + void* UserData; // What user passed to InputText() // Read-only + bool ReadOnly; // Read-only mode // Read-only + + // CharFilter event: + ImWchar EventChar; // Character input // Read-write (replace character or set to zero) + + // Completion,History,Always events: + // If you modify the buffer contents make sure you update 'BufTextLen' and set 'BufDirty' to true. + ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only + char* Buf; // Current text buffer // Read-write (pointed data only, can't replace the actual pointer) + int BufTextLen; // Current text length in BYTEs // Read-write + int BufSize; // Maximum text length in BYTEs // Read-only + bool BufDirty; // set if you modify Buf/BufTextLen!! // Write + int CursorPos; // // Read-write + int SelectionStart; // // Read-write (== to SelectionEnd when no selection) + int SelectionEnd; // // Read-write + + // NB: Helper functions for text manipulation. Calling those function loses selection. + IMGUI_API void DeleteChars(int pos, int BYTEs_count); + IMGUI_API void InsertChars(int pos, const char* text, const char* text_end = NULL); + bool HasSelection() const { return SelectionStart != SelectionEnd; } +}; + +// Resizing callback data to apply custom constraint. As enabled by SetNextWindowSizeConstraints(). Callback is called during the next Begin(). +// NB: For basic min/max size constraint on each axis you don't need to use the callback! The SetNextWindowSizeConstraints() parameters are enough. +struct ImGuiSizeCallbackData +{ + void* UserData; // Read-only. What user passed to SetNextWindowSizeConstraints() + ImVec2 Pos; // Read-only. Window position, for reference. + ImVec2 CurrentSize; // Read-only. Current window size. + ImVec2 DesiredSize; // Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing. +}; + +// Data payload for Drag and Drop operations +struct ImGuiPayload +{ + // Members + const void* Data; // Data (copied and owned by dear imgui) + int DataSize; // Data size + + // [Internal] + ImGuiID SourceId; // Source item id + ImGuiID SourceParentId; // Source parent id (if available) + int DataFrameCount; // Data timestamp + char DataType[8 + 1]; // Data type tag (short user-supplied string) + bool Preview; // set when AcceptDragDropPayload() was called and mouse has been hovering the target item (nb: handle overlapping drag targets) + bool Delivery; // set when AcceptDragDropPayload() was called and mouse button is released over the target item. + + ImGuiPayload() { Clear(); } + void Clear() { SourceId = SourceParentId = 0; Data = NULL; DataSize = 0; memset(DataType, 0, sizeof(DataType)); DataFrameCount = -1; Preview = Delivery = false; } + bool IsDataType(const char* type) const { return DataFrameCount != -1 && strcmp(type, DataType) == 0; } + bool IsPreview() const { return Preview; } + bool IsDelivery() const { return Delivery; } +}; + +// Helpers macros to generate 32-bits encoded colors +#ifdef IMGUI_USE_BGRA_PACKED_COLOR +#define IM_COL32_R_SHIFT 16 +#define IM_COL32_G_SHIFT 8 +#define IM_COL32_B_SHIFT 0 +#define IM_COL32_A_SHIFT 24 +#define IM_COL32_A_MASK 0xFF000000 +#else +#define IM_COL32_R_SHIFT 0 +#define IM_COL32_G_SHIFT 8 +#define IM_COL32_B_SHIFT 16 +#define IM_COL32_A_SHIFT 24 +#define IM_COL32_A_MASK 0xFF000000 +#endif +#define IM_COL32(R,G,B,A) (((ImU32)(A)<>IM_COL32_R_SHIFT)&0xFF) * sc; Value.y = (float)((rgba>>IM_COL32_G_SHIFT)&0xFF) * sc; Value.z = (float)((rgba>>IM_COL32_B_SHIFT)&0xFF) * sc; Value.w = (float)((rgba>>IM_COL32_A_SHIFT)&0xFF) * sc; } + ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; } + ImColor(const ImVec4& col) { Value = col; } + inline operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); } + inline operator ImVec4() const { return Value; } + + // FIXME-OBSOLETE: May need to obsolete/cleanup those helpers. + inline void SetHSV(float h, float s, float v, float a = 1.0f){ ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; } + static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r,g,b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r,g,b,a); } +}; + +// Helper: Manually clip large list of items. +// If you are submitting lots of evenly spaced items and you have a random access to the list, you can perform coarse clipping based on visibility to save yourself from processing those items at all. +// The clipper calculates the range of visible items and advance the cursor to compensate for the non-visible items we have skipped. +// ImGui already clip items based on their bounds but it needs to measure text size to do so. Coarse clipping before submission makes this cost and your own data fetching/submission cost null. +// Usage: +// ImGuiListClipper clipper(1000); // we have 1000 elements, evenly spaced. +// while (clipper.Step()) +// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) +// ImGui::Text("line number %d", i); +// - Step 0: the clipper let you process the first element, regardless of it being visible or not, so we can measure the element height (step skipped if we passed a known height as second arg to constructor). +// - Step 1: the clipper infer height from first element, calculate the actual range of elements to display, and position the cursor before the first element. +// - (Step 2: dummy step only required if an explicit items_height was passed to constructor or Begin() and user call Step(). Does nothing and switch to Step 3.) +// - Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), advance the cursor to the end of the list and then returns 'false' to end the loop. +struct ImGuiListClipper +{ + float StartPosY; + float ItemsHeight; + int ItemsCount, StepNo, DisplayStart, DisplayEnd; + + // items_count: Use -1 to ignore (you can call Begin later). Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step). + // items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing(). + // If you don't specify an items_height, you NEED to call Step(). If you specify items_height you may call the old Begin()/End() api directly, but prefer calling Step(). + ImGuiListClipper(int items_count = -1, float items_height = -1.0f) { Begin(items_count, items_height); } // NB: Begin() initialize every fields (as we allow user to call Begin/End multiple times on a same instance if they want). + ~ImGuiListClipper() { IM_ASSERT(ItemsCount == -1); } // Assert if user forgot to call End() or Step() until false. + + IMGUI_API bool Step(); // Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items. + IMGUI_API void Begin(int items_count, float items_height = -1.0f); // Automatically called by constructor if you passed 'items_count' or by Step() in Step 1. + IMGUI_API void End(); // Automatically called on the last call of Step() that returns false. +}; + +//----------------------------------------------------------------------------- +// Draw List +// Hold a series of drawing commands. The user provides a renderer for ImDrawData which essentially contains an array of ImDrawList. +//----------------------------------------------------------------------------- + +// Draw callbacks for advanced uses. +// NB- You most likely do NOT need to use draw callbacks just to create your own widget or customized UI rendering (you can poke into the draw list for that) +// Draw callback may be useful for example, A) Change your GPU render state, B) render a complex 3D scene inside a UI element (without an intermediate texture/render target), etc. +// The expected behavior from your rendering function is 'if (cmd.UserCallback != NULL) cmd.UserCallback(parent_list, cmd); else RenderTriangles()' +typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd); + +// Typically, 1 command = 1 GPU draw call (unless command is a callback) +struct ImDrawCmd +{ + unsigned int ElemCount; // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[]. + ImVec4 ClipRect; // Clipping rectangle (x1, y1, x2, y2) + ImTextureID TextureId; // User-provided texture ID. set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas. + ImShaderID ShaderID; + ImDrawCallback UserCallback; // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally. + void* UserCallbackData; // The draw callback code can access this. + + ImDrawCmd() { ElemCount = 0; ClipRect.x = ClipRect.y = ClipRect.z = ClipRect.w = 0.0f; TextureId = NULL; ShaderID = NULL; UserCallback = NULL; UserCallbackData = NULL; } +}; + +// Vertex index (override with '#define ImDrawIdx unsigned int' inside in imconfig.h) +#ifndef ImDrawIdx +typedef unsigned short ImDrawIdx; +#endif + +// Vertex layout +#ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT +struct ImDrawVert +{ + ImVec2 pos; + ImVec2 uv; + ImU32 col; +}; +#else +// You can override the vertex format layout by defining IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT in imconfig.h +// The code expect ImVec2 pos (8 BYTEs), ImVec2 uv (8 BYTEs), ImU32 col (4 BYTEs), but you can re-order them or add other fields as needed to simplify integration in your engine. +// The type has to be described within the macro (you can either declare the struct or use a typedef) +// NOTE: IMGUI DOESN'T CLEAR THE STRUCTURE AND DOESN'T CALL A CONSTRUCTOR SO ANY CUSTOM FIELD WILL BE UNINITIALIZED. IF YOU ADD EXTRA FIELDS (SUCH AS A 'Z' COORDINATES) YOU WILL NEED TO CLEAR THEM DURING RENDER OR TO IGNORE THEM. +IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT; +#endif + +// Draw channels are used by the Columns API to "split" the render list into different channels while building, so items of each column can be batched together. +// You can also use them to simulate drawing layers and submit primitives in a different order than how they will be rendered. +struct ImDrawChannel +{ + ImVector CmdBuffer; + ImVector IdxBuffer; +}; + +enum ImDrawCornerFlags_ +{ + ImDrawCornerFlags_TopLeft = 1 << 0, // 0x1 + ImDrawCornerFlags_TopRight = 1 << 1, // 0x2 + ImDrawCornerFlags_BotLeft = 1 << 2, // 0x4 + ImDrawCornerFlags_BotRight = 1 << 3, // 0x8 + ImDrawCornerFlags_Top = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_TopRight, // 0x3 + ImDrawCornerFlags_Bot = ImDrawCornerFlags_BotLeft | ImDrawCornerFlags_BotRight, // 0xC + ImDrawCornerFlags_Left = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_BotLeft, // 0x5 + ImDrawCornerFlags_Right = ImDrawCornerFlags_TopRight | ImDrawCornerFlags_BotRight, // 0xA + ImDrawCornerFlags_All = 0xF // In your function calls you may use ~0 (= all bits sets) instead of ImDrawCornerFlags_All, as a convenience +}; + +enum ImDrawListFlags_ +{ + ImDrawListFlags_AntiAliasedLines = 1 << 0, + ImDrawListFlags_AntiAliasedFill = 1 << 1 +}; + +// Draw command list +// This is the low-level list of polygons that ImGui functions are filling. At the end of the frame, all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering. +// Each ImGui window contains its own ImDrawList. You can use ImGui::GetWindowDrawList() to access the current window draw list and draw custom primitives. +// You can interleave normal ImGui:: calls and adding primitives to the current draw list. +// All positions are generally in pixel coordinates (top-left at (0,0), bottom-right at io.DisplaySize), however you are totally free to apply whatever transformation matrix to want to the data (if you apply such transformation you'll want to apply it to ClipRect as well) +// Important: Primitives are always added to the list and not culled (culling is done at higher-level by ImGui:: functions), if you use this API a lot consider coarse culling your drawn objects. +struct ImDrawList +{ + // This is what you have to render + ImVector CmdBuffer; // Draw commands. Typically 1 command = 1 GPU draw call, unless the command is a callback. + ImVector IdxBuffer; // Index buffer. Each command consume ImDrawCmd::ElemCount of those + ImVector VtxBuffer; // Vertex buffer. + + // [Internal, used while building lists] + ImDrawListFlags Flags; // Flags, you may poke into these to adjust anti-aliasing settings per-primitive. + const ImDrawListSharedData* _Data; // Pointer to shared draw data (you can use ImGui::GetDrawListSharedData() to get the one from current ImGui context) + const char* _OwnerName; // Pointer to owner window's name for debugging + unsigned int _VtxCurrentIdx; // [Internal] == VtxBuffer.Size + ImDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much) + ImDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much) + ImVector _ClipRectStack; // [Internal] + ImVector _TextureIdStack; // [Internal] + ImVector _ShaderIdStack; // [Internal] + ImVector _Path; // [Internal] current path building + int _ChannelsCurrent; // [Internal] current channel number (0) + int _ChannelsCount; // [Internal] number of active channels (1+) + ImVector _Channels; // [Internal] draw channels for columns API (not resized down so _ChannelsCount may be smaller than _Channels.Size) + + ImDrawList(const ImDrawListSharedData* shared_data) { _Data = shared_data; _OwnerName = NULL; Clear(); } + ~ImDrawList() { ClearFreeMemory(); } + IMGUI_API void PushClipRect(ImVec2 clip_rect_min, ImVec2 clip_rect_max, bool intersect_with_current_clip_rect = false); // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling) + IMGUI_API void PushClipRectFullScreen(); + IMGUI_API void PopClipRect(); + IMGUI_API void PushTextureID(const ImTextureID& texture_id); + IMGUI_API void PushShaderID(const ImShaderID& shader_id); + IMGUI_API void PopTextureID(); + IMGUI_API void PopShaderID(); + inline ImVec2 GetClipRectMin() const { const ImVec4& cr = _ClipRectStack.back(); return ImVec2(cr.x, cr.y); } + inline ImVec2 GetClipRectMax() const { const ImVec4& cr = _ClipRectStack.back(); return ImVec2(cr.z, cr.w); } + + // Primitives + IMGUI_API void AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness = 1.0f); + IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners_flags = ImDrawCornerFlags_All, float thickness = 1.0f); // a: upper-left, b: lower-right, rounding_corners_flags: 4-bits corresponding to which corner to round + IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners_flags = ImDrawCornerFlags_All); // a: upper-left, b: lower-right + IMGUI_API void AddRectFilledMultiColor(const ImVec2& a, const ImVec2& b, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left); + IMGUI_API void AddQuad(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col, float thickness = 1.0f); + IMGUI_API void AddQuadFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col); + IMGUI_API void AddTriangle(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col, float thickness = 1.0f); + IMGUI_API void AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col); + IMGUI_API void AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12, float thickness = 1.0f); + IMGUI_API void AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12); + IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL); + IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL); + IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a = ImVec2(0,0), const ImVec2& uv_b = ImVec2(1,1), ImU32 col = 0xFFFFFFFF); + IMGUI_API void AddImageQuad(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a = ImVec2(0,0), const ImVec2& uv_b = ImVec2(1,0), const ImVec2& uv_c = ImVec2(1,1), const ImVec2& uv_d = ImVec2(0,1), ImU32 col = 0xFFFFFFFF); + IMGUI_API void AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col, float rounding, int rounding_corners = ImDrawCornerFlags_All); + IMGUI_API void AddPolyline(const ImVec2* points, const int num_points, ImU32 col, bool closed, float thickness); + IMGUI_API void AddConvexPolyFilled(const ImVec2* points, const int num_points, ImU32 col); + IMGUI_API void AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments = 0); + + // Stateful path API, add points then finish with PathFill() or PathStroke() + inline void PathClear() { _Path.resize(0); } + inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); } + inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path[_Path.Size-1], &pos, 8) != 0) _Path.push_back(pos); } + inline void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); PathClear(); } + inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); PathClear(); } + IMGUI_API void PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments = 10); + IMGUI_API void PathArcToFast(const ImVec2& centre, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle + IMGUI_API void PathBezierCurveTo(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, int num_segments = 0); + IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, int rounding_corners_flags = ImDrawCornerFlags_All); + + // Channels + // - Use to simulate layers. By switching channels to can render out-of-order (e.g. submit foreground primitives before background primitives) + // - Use to minimize draw calls (e.g. if going back-and-forth between multiple non-overlapping clipping rectangles, prefer to append into separate channels then merge at the end) + IMGUI_API void ChannelsSplit(int channels_count); + IMGUI_API void ChannelsMerge(); + IMGUI_API void ChannelsSetCurrent(int channel_index); + + // Advanced + IMGUI_API void AddCallback(ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'UserCallback' in ImDrawCmd and call the function instead of rendering triangles. + IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible + + // Internal helpers + // NB: all primitives needs to be reserved via PrimReserve() beforehand! + IMGUI_API void Clear(); + IMGUI_API void ClearFreeMemory(); + IMGUI_API void PrimReserve(int idx_count, int vtx_count); + IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col); // Axis aligned rectangle (composed of two triangles) + IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col); + IMGUI_API void PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col); + inline void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col){ _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; } + inline void PrimWriteIdx(ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; } + inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } + IMGUI_API void UpdateClipRect(); + IMGUI_API void UpdateTextureID(); + IMGUI_API void UpdateShaderID(); +}; + +// All draw data to render an ImGui frame +struct ImDrawData +{ + bool Valid; // Only valid after Render() is called and before the next NewFrame() is called. + ImDrawList** CmdLists; + int CmdListsCount; + int TotalVtxCount; // For convenience, sum of all cmd_lists vtx_buffer.Size + int TotalIdxCount; // For convenience, sum of all cmd_lists idx_buffer.Size + + // Functions + ImDrawData() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; } + IMGUI_API void DeIndexAllBuffers(); // For backward compatibility or convenience: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering! + IMGUI_API void ScaleClipRects(const ImVec2& sc); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution. +}; + +struct ImFontConfig +{ + void* FontData; // // TTF/OTF data + int FontDataSize; // // TTF/OTF data size + bool FontDataOwnedByAtlas; // true // TTF/OTF data ownership taken by the container ImFontAtlas (will delete memory itself). + int FontNo; // 0 // Index of font within TTF/OTF file + float SizePixels; // // Size in pixels for rasterizer. + int OversampleH, OversampleV; // 3, 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis. + bool PixelSnapH; // false // Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1. + ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs. Only X axis is supported for now. + ImVec2 GlyphOffset; // 0, 0 // Offset all glyphs from this font input. + const ImWchar* GlyphRanges; // NULL // Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE. + bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs). You may want to use GlyphOffset.y when merge font of different heights. + unsigned int RasterizerFlags; // 0x00 // Settings for custom font rasterizer (e.g. ImGuiFreeType). Leave as zero if you aren't using one. + float RasterizerMultiply; // 1.0f // Brighten (>1.0f) or darken (<1.0f) font output. Brightening small fonts may be a good workaround to make them more readable. + + // [Internal] + char Name[32]; // Name (strictly to ease debugging) + ImFont* DstFont; + + IMGUI_API ImFontConfig(); +}; + +struct ImFontGlyph +{ + ImWchar Codepoint; // 0x0000..0xFFFF + float AdvanceX; // Distance to next character (= data from font + ImFontConfig::GlyphExtraSpacing.x baked in) + float X0, Y0, X1, Y1; // Glyph corners + float U0, V0, U1, V1; // Texture coordinates +}; + +// Load and rasterize multiple TTF/OTF fonts into a same texture. +// Sharing a texture for multiple fonts allows us to reduce the number of draw calls during rendering. +// We also add custom graphic data into the texture that serves for ImGui. +// 1. (Optional) Call AddFont*** functions. If you don't call any, the default font will be loaded for you. +// 2. Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data. +// 3. Upload the pixels data into a texture within your graphics system. +// 4. Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture. This value will be passed back to you during rendering to identify the texture. +// IMPORTANT: If you pass a 'glyph_ranges' array to AddFont*** functions, you need to make sure that your array persist up until the ImFont is build (when calling GetTextData*** or Build()). We only copy the pointer, not the data. +struct ImFontAtlas +{ + IMGUI_API ImFontAtlas(); + IMGUI_API ~ImFontAtlas(); + IMGUI_API ImFont* AddFont(const ImFontConfig* font_cfg); + IMGUI_API ImFont* AddFontDefault(const ImFontConfig* font_cfg = NULL); + IMGUI_API ImFont* AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); + IMGUI_API ImFont* AddFontFromMemoryTTF(void* font_data, int font_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after Build(). set font_cfg->FontDataOwnedByAtlas to false to keep ownership. + IMGUI_API ImFont* AddFontFromMemoryCompressedTTF(const void* compressed_font_data, int compressed_font_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp. + IMGUI_API ImFont* AddFontFromMemoryCompressedBase85TTF(const char* compressed_font_data_base85, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 parameter. + IMGUI_API void ClearTexData(); // Clear the CPU-side texture data. Saves RAM once the texture has been copied to graphics memory. + IMGUI_API void ClearInputData(); // Clear the input TTF data (inc sizes, glyph ranges) + IMGUI_API void ClearFonts(); // Clear the ImGui-side font data (glyphs storage, UV coordinates) + IMGUI_API void Clear(); // Clear all + + // Build atlas, retrieve pixel data. + // User is in charge of copying the pixels into graphics memory (e.g. create a texture with your engine). Then store your texture handle with SetTexID(). + // RGBA32 format is provided for convenience and compatibility, but note that unless you use CustomRect to draw color data, the RGB pixels emitted from Fonts will all be white (~75% of waste). + // Pitch = Width * BytesPerPixels + IMGUI_API bool Build(); // Build pixels data. This is called automatically for you by the GetTexData*** functions. + IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_BYTEs_per_pixel = NULL); // 1 BYTE per-pixel + IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_BYTEs_per_pixel = NULL); // 4 BYTEs-per-pixel + void SetTexID(ImTextureID id) { TexID = id; } + + //------------------------------------------- + // Glyph Ranges + //------------------------------------------- + + // Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list) + // NB: Make sure that your string are UTF-8 and NOT in your local code page. In C++11, you can create UTF-8 string literal using the u8"Hello world" syntax. See FAQ for details. + IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin + IMGUI_API const ImWchar* GetGlyphRangesKorean(); // Default + Korean characters + IMGUI_API const ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs + IMGUI_API const ImWchar* GetGlyphRangesChinese(); // Default + Japanese + full set of about 21000 CJK Unified Ideographs + IMGUI_API const ImWchar* GetGlyphRangesCyrillic(); // Default + about 400 Cyrillic characters + IMGUI_API const ImWchar* GetGlyphRangesThai(); // Default + Thai characters + + // Helpers to build glyph ranges from text data. Feed your application strings/characters to it then call BuildRanges(). + struct GlyphRangesBuilder + { + ImVector UsedChars; // Store 1-bit per Unicode code point (0=unused, 1=used) + GlyphRangesBuilder() { UsedChars.resize(0x10000 / 8); memset(UsedChars.Data, 0, 0x10000 / 8); } + bool GetBit(int n) { return (UsedChars[n >> 3] & (1 << (n & 7))) != 0; } + void SetBit(int n) { UsedChars[n >> 3] |= 1 << (n & 7); } // set bit 'c' in the array + void AddChar(ImWchar c) { SetBit(c); } // Add character + IMGUI_API void AddText(const char* text, const char* text_end = NULL); // Add string (each character of the UTF-8 string are added) + IMGUI_API void AddRanges(const ImWchar* ranges); // Add ranges, e.g. builder.AddRanges(ImFontAtlas::GetGlyphRangesDefault) to force add all of ASCII/Latin+Ext + IMGUI_API void BuildRanges(ImVector* out_ranges); // Output new ranges + }; + + //------------------------------------------- + // Custom Rectangles/Glyphs API + //------------------------------------------- + + // You can request arbitrary rectangles to be packed into the atlas, for your own purposes. After calling Build(), you can query the rectangle position and render your pixels. + // You can also request your rectangles to be mapped as font glyph (given a font + Unicode point), so you can render e.g. custom colorful icons and use them as regular glyphs. + struct CustomRect + { + unsigned int ID; // Input // User ID. Use <0x10000 to map into a font glyph, >=0x10000 for other/internal/custom texture data. + unsigned short Width, Height; // Input // Desired rectangle dimension + unsigned short X, Y; // Output // Packed position in Atlas + float GlyphAdvanceX; // Input // For custom font glyphs only (ID<0x10000): glyph xadvance + ImVec2 GlyphOffset; // Input // For custom font glyphs only (ID<0x10000): glyph display offset + ImFont* Font; // Input // For custom font glyphs only (ID<0x10000): target font + CustomRect() { ID = 0xFFFFFFFF; Width = Height = 0; X = Y = 0xFFFF; GlyphAdvanceX = 0.0f; GlyphOffset = ImVec2(0,0); Font = NULL; } + bool IsPacked() const { return X != 0xFFFF; } + }; + + IMGUI_API int AddCustomRectRegular(unsigned int id, int width, int height); // Id needs to be >= 0x10000. Id >= 0x80000000 are reserved for ImGui and ImDrawList + IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0,0)); // Id needs to be < 0x10000 to register a rectangle to map into a specific font. + IMGUI_API void CalcCustomRectUV(const CustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max); + const CustomRect* GetCustomRectByIndex(int index) const { if (index < 0) return NULL; return &CustomRects[index]; } + + //------------------------------------------- + // Members + //------------------------------------------- + + ImTextureID TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It is passed back to you during rendering via the ImDrawCmd structure. + int TexDesiredWidth; // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height. + int TexGlyphPadding; // Padding between glyphs within texture in pixels. Defaults to 1. + + // [Internal] + // NB: Access texture data via GetTexData*() calls! Which will setup a default font for you. + unsigned char* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight + unsigned int* TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4 + int TexWidth; // Texture width calculated during Build(). + int TexHeight; // Texture height calculated during Build(). + ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel + ImVector Fonts; // Hold all the fonts returned by AddFont*. Fonts[0] is the default font upon calling ImGui::NewFrame(), use ImGui::PushFont()/PopFont() to change the current font. + ImVector CustomRects; // Rectangles for packing custom texture data into the atlas. + ImVector ConfigData; // Internal data + int CustomRectIds[1]; // Identifiers of custom texture rectangle used by ImFontAtlas/ImDrawList +}; + +// Font runtime data and rendering +// ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32(). +struct ImFont +{ + // Members: Hot ~62/78 BYTEs + float FontSize; // // Height of characters, set during loading (don't change after loading) + float Scale; // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale() + ImVec2 DisplayOffset; // = (0.f,1.f) // Offset font rendering by xx pixels + ImVector Glyphs; // // All glyphs. + ImVector IndexAdvanceX; // // Sparse. Glyphs->AdvanceX in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI). + ImVector IndexLookup; // // Sparse. Index glyphs by Unicode code-point. + const ImFontGlyph* FallbackGlyph; // == FindGlyph(FontFallbackChar) + float FallbackAdvanceX; // == FallbackGlyph->AdvanceX + ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar() + + // Members: Cold ~18/26 BYTEs + short ConfigDataCount; // ~ 1 // Number of ImFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one ImFont. + ImFontConfig* ConfigData; // // Pointer within ContainerAtlas->ConfigData + ImFontAtlas* ContainerAtlas; // // What we has been loaded into + float Ascent, Descent; // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize] + int MetricsTotalSurface;// // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs) + + // Methods + IMGUI_API ImFont(); + IMGUI_API ~ImFont(); + IMGUI_API void ClearOutputData(); + IMGUI_API void BuildLookupTable(); + IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c) const; + IMGUI_API void SetFallbackChar(ImWchar c); + float GetCharAdvance(ImWchar c) const { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; } + bool IsLoaded() const { return ContainerAtlas != NULL; } + const char* GetDebugName() const { return ConfigData ? ConfigData->Name : ""; } + + // 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable. + // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable. + IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8 + IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const; + IMGUI_API void RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, unsigned short c) const; + IMGUI_API void RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false) const; + + // [Internal] + IMGUI_API void GrowIndex(int new_size); + IMGUI_API void AddGlyph(ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x); + IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built. + +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + typedef ImFontGlyph Glyph; // OBSOLETE 1.52+ +#endif +}; + +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + +// Include imgui_user.h at the end of imgui.h (convenient for user to only explicitly include vanilla imgui.h) +#ifdef IMGUI_INCLUDE_IMGUI_USER_H +#include "imgui_user.h" +#endif + +``` + +`imgui/imgui_demo.cpp`: + +```cpp +// dear imgui, v1.54 WIP +// (demo code) + +// Message to the person tempted to delete this file when integrating ImGui into their code base: +// Don't do it! Do NOT remove this file from your project! It is useful reference code that you and other users will want to refer to. +// Everything in this file will be stripped out by the linker if you don't call ImGui::ShowDemoWindow(). +// During development, you can call ImGui::ShowDemoWindow() in your code to learn about various features of ImGui. Have it wired in a debug menu! +// Removing this file from your project is hindering access to documentation for everyone in your team, likely leading you to poorer usage of the library. +// Note that you can #define IMGUI_DISABLE_DEMO_WINDOWS in imconfig.h for the same effect. +// If you want to link core ImGui in your final builds but not those demo windows, #define IMGUI_DISABLE_DEMO_WINDOWS in imconfig.h and those functions will be empty. +// In other situation, when you have ImGui available you probably want this to be available for reference and execution. +// Thank you, +// -Your beloved friend, imgui_demo.cpp (that you won't delete) + +// Message to beginner C/C++ programmers. About the meaning of 'static': in this demo code, we frequently we use 'static' variables inside functions. +// We do this as a way to gather code and data in the same place, just to make the demo code faster to read, faster to write, and use less code. +// A static variable persist across calls, so it is essentially like a global variable but declared inside the scope of the function. +// It also happens to be a convenient way of storing simple UI related information as long as your function doesn't need to be reentrant or used in threads. +// This might be a pattern you occasionally want to use in your code, but most of the real data you would be editing is likely to be stored outside your function. + +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include "imgui.h" +#include // toupper, isprint +#include // sqrtf, powf, cosf, sinf, floorf, ceilf +#include // vsnprintf, sscanf, printf +#include // NULL, malloc, free, atoi +#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier +#include // intptr_t +#else +#include // intptr_t +#endif + +#ifdef _MSC_VER +#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen +#define snprintf _snprintf +#endif +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse. +#pragma clang diagnostic ignored "-Wdeprecated-declarations" // warning : 'xx' is deprecated: The POSIX name for this item.. // for strdup used in demo code (so user can copy & paste the code) +#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int' +#pragma clang diagnostic ignored "-Wformat-security" // warning : warning: format string is not a string literal +#pragma clang diagnostic ignored "-Wexit-time-destructors" // warning : declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals. +#if __has_warning("-Wreserved-id-macro") +#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning : macro name is a reserved identifier // +#endif +#elif defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size +#pragma GCC diagnostic ignored "-Wformat-security" // warning : format string is not a string literal (potentially insecure) +#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function +#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value +#if (__GNUC__ >= 6) +#pragma GCC diagnostic ignored "-Wmisleading-indentation" // warning: this 'if' clause does not guard this statement // GCC 6.0+ only. See #883 on GitHub. +#endif +#endif + +// Play it nice with Windows users. Notepad in 2017 still doesn't display text data with Unix-style \n. +#ifdef _WIN32 +#define IM_NEWLINE "\r\n" +#else +#define IM_NEWLINE "\n" +#endif + +#define IM_MAX(_A,_B) (((_A) >= (_B)) ? (_A) : (_B)) + +//----------------------------------------------------------------------------- +// DEMO CODE +//----------------------------------------------------------------------------- + +#if !defined(IMGUI_DISABLE_OBSOLETE_FUNCTIONS) && defined(IMGUI_DISABLE_TEST_WINDOWS) && !defined(IMGUI_DISABLE_DEMO_WINDOWS) // Obsolete name since 1.53, TEST->DEMO +#define IMGUI_DISABLE_DEMO_WINDOWS +#endif + +#if !defined(IMGUI_DISABLE_DEMO_WINDOWS) + +static void ShowExampleAppConsole(bool* p_open); +static void ShowExampleAppLog(bool* p_open); +static void ShowExampleAppLayout(bool* p_open); +static void ShowExampleAppPropertyEditor(bool* p_open); +static void ShowExampleAppLongText(bool* p_open); +static void ShowExampleAppAutoResize(bool* p_open); +static void ShowExampleAppConstrainedResize(bool* p_open); +static void ShowExampleAppFixedOverlay(bool* p_open); +static void ShowExampleAppWindowTitles(bool* p_open); +static void ShowExampleAppCustomRendering(bool* p_open); +static void ShowExampleAppMainMenuBar(); +static void ShowExampleMenuFile(); + +static void ShowHelpMarker(const char* desc) +{ + ImGui::TextDisabled("(?)"); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::PushTextWrapPos(450.0f); + ImGui::TextUnformatted(desc); + ImGui::PopTextWrapPos(); + ImGui::EndTooltip(); + } +} + +void ImGui::ShowUserGuide() +{ + ImGui::BulletText("Double-click on title bar to collapse window."); + ImGui::BulletText("Click and drag on lower right corner to resize window\n(double-click to auto fit window to its contents)."); + ImGui::BulletText("Click and drag on any empty space to move window."); + ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields."); + ImGui::BulletText("CTRL+Click on a slider or drag box to input value as text."); + if (ImGui::GetIO().FontAllowUserScaling) + ImGui::BulletText("CTRL+Mouse Wheel to zoom window contents."); + ImGui::BulletText("Mouse Wheel to scroll."); + ImGui::BulletText("While editing text:\n"); + ImGui::Indent(); + ImGui::BulletText("Hold SHIFT or use mouse to select text."); + ImGui::BulletText("CTRL+Left/Right to word jump."); + ImGui::BulletText("CTRL+A or double-click to select all."); + ImGui::BulletText("CTRL+X,CTRL+C,CTRL+V to use clipboard."); + ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo."); + ImGui::BulletText("ESCAPE to revert."); + ImGui::BulletText("You can apply arithmetic operators +,*,/ on numerical values.\nUse +- to subtract."); + ImGui::Unindent(); +} + +// Demonstrate most ImGui features (big function!) +void ImGui::ShowDemoWindow(bool* p_open) +{ + // Examples apps + static bool show_app_main_menu_bar = false; + static bool show_app_console = false; + static bool show_app_log = false; + static bool show_app_layout = false; + static bool show_app_property_editor = false; + static bool show_app_long_text = false; + static bool show_app_auto_resize = false; + static bool show_app_constrained_resize = false; + static bool show_app_fixed_overlay = false; + static bool show_app_window_titles = false; + static bool show_app_custom_rendering = false; + static bool show_app_style_editor = false; + + static bool show_app_metrics = false; + static bool show_app_about = false; + + if (show_app_main_menu_bar) ShowExampleAppMainMenuBar(); + if (show_app_console) ShowExampleAppConsole(&show_app_console); + if (show_app_log) ShowExampleAppLog(&show_app_log); + if (show_app_layout) ShowExampleAppLayout(&show_app_layout); + if (show_app_property_editor) ShowExampleAppPropertyEditor(&show_app_property_editor); + if (show_app_long_text) ShowExampleAppLongText(&show_app_long_text); + if (show_app_auto_resize) ShowExampleAppAutoResize(&show_app_auto_resize); + if (show_app_constrained_resize) ShowExampleAppConstrainedResize(&show_app_constrained_resize); + if (show_app_fixed_overlay) ShowExampleAppFixedOverlay(&show_app_fixed_overlay); + if (show_app_window_titles) ShowExampleAppWindowTitles(&show_app_window_titles); + if (show_app_custom_rendering) ShowExampleAppCustomRendering(&show_app_custom_rendering); + + if (show_app_metrics) { ImGui::ShowMetricsWindow(&show_app_metrics); } + if (show_app_style_editor) { ImGui::Begin("Style Editor", &show_app_style_editor); ImGui::ShowStyleEditor(); ImGui::End(); } + if (show_app_about) + { + ImGui::Begin("About Dear ImGui", &show_app_about, ImGuiWindowFlags_AlwaysAutoResize); + ImGui::Text("Dear ImGui, %s", ImGui::GetVersion()); + ImGui::Separator(); + ImGui::Text("By Omar Cornut and all dear imgui contributors."); + ImGui::Text("Dear ImGui is licensed under the MIT License, see LICENSE for more information."); + ImGui::End(); + } + + static bool no_titlebar = false; + static bool no_scrollbar = false; + static bool no_menu = false; + static bool no_move = false; + static bool no_resize = false; + static bool no_collapse = false; + static bool no_close = false; + + // Demonstrate the various window flags. Typically you would just use the default. + ImGuiWindowFlags window_flags = 0; + if (no_titlebar) window_flags |= ImGuiWindowFlags_NoTitleBar; + if (no_scrollbar) window_flags |= ImGuiWindowFlags_NoScrollbar; + if (!no_menu) window_flags |= ImGuiWindowFlags_MenuBar; + if (no_move) window_flags |= ImGuiWindowFlags_NoMove; + if (no_resize) window_flags |= ImGuiWindowFlags_NoResize; + if (no_collapse) window_flags |= ImGuiWindowFlags_NoCollapse; + if (no_close) p_open = NULL; // Don't pass our bool* to Begin + + ImGui::SetNextWindowSize(ImVec2(550,680), ImGuiCond_FirstUseEver); + if (!ImGui::Begin("ImGui Demo", p_open, window_flags)) + { + // Early out if the window is collapsed, as an optimization. + ImGui::End(); + return; + } + + //ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.65f); // 2/3 of the space for widget and 1/3 for labels + ImGui::PushItemWidth(-140); // Right align, keep 140 pixels for labels + + ImGui::Text("dear imgui says hello. (%s)", IMGUI_VERSION); + + // Menu + if (ImGui::BeginMenuBar()) + { + if (ImGui::BeginMenu("Menu")) + { + ShowExampleMenuFile(); + ImGui::EndMenu(); + } + if (ImGui::BeginMenu("Examples")) + { + ImGui::MenuItem("Main menu bar", NULL, &show_app_main_menu_bar); + ImGui::MenuItem("Console", NULL, &show_app_console); + ImGui::MenuItem("Log", NULL, &show_app_log); + ImGui::MenuItem("Simple layout", NULL, &show_app_layout); + ImGui::MenuItem("Property editor", NULL, &show_app_property_editor); + ImGui::MenuItem("Long text display", NULL, &show_app_long_text); + ImGui::MenuItem("Auto-resizing window", NULL, &show_app_auto_resize); + ImGui::MenuItem("Constrained-resizing window", NULL, &show_app_constrained_resize); + ImGui::MenuItem("Simple overlay", NULL, &show_app_fixed_overlay); + ImGui::MenuItem("Manipulating window titles", NULL, &show_app_window_titles); + ImGui::MenuItem("Custom rendering", NULL, &show_app_custom_rendering); + ImGui::EndMenu(); + } + if (ImGui::BeginMenu("Help")) + { + ImGui::MenuItem("Metrics", NULL, &show_app_metrics); + ImGui::MenuItem("Style Editor", NULL, &show_app_style_editor); + ImGui::MenuItem("About Dear ImGui", NULL, &show_app_about); + ImGui::EndMenu(); + } + ImGui::EndMenuBar(); + } + + ImGui::Spacing(); + if (ImGui::CollapsingHeader("Help")) + { + ImGui::TextWrapped("This window is being created by the ShowDemoWindow() function. Please refer to the code in imgui_demo.cpp for reference.\n\n"); + ImGui::Text("USER GUIDE:"); + ImGui::ShowUserGuide(); + } + + if (ImGui::CollapsingHeader("Window options")) + { + ImGui::Checkbox("No titlebar", &no_titlebar); ImGui::SameLine(150); + ImGui::Checkbox("No scrollbar", &no_scrollbar); ImGui::SameLine(300); + ImGui::Checkbox("No menu", &no_menu); + ImGui::Checkbox("No move", &no_move); ImGui::SameLine(150); + ImGui::Checkbox("No resize", &no_resize); ImGui::SameLine(300); + ImGui::Checkbox("No collapse", &no_collapse); + ImGui::Checkbox("No close", &no_close); + + if (ImGui::TreeNode("Style")) + { + ImGui::ShowStyleEditor(); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Capture/Logging")) + { + ImGui::TextWrapped("The logging API redirects all text output so you can easily capture the content of a window or a block. Tree nodes can be automatically expanded. You can also call ImGui::LogText() to output directly to the log without a visual output."); + ImGui::LogButtons(); + ImGui::TreePop(); + } + } + + if (ImGui::CollapsingHeader("Widgets")) + { + if (ImGui::TreeNode("Basic")) + { + static int clicked = 0; + if (ImGui::Button("Button")) + clicked++; + if (clicked & 1) + { + ImGui::SameLine(); + ImGui::Text("Thanks for clicking me!"); + } + + static bool check = true; + ImGui::Checkbox("checkbox", &check); + + static int e = 0; + ImGui::RadioButton("radio a", &e, 0); ImGui::SameLine(); + ImGui::RadioButton("radio b", &e, 1); ImGui::SameLine(); + ImGui::RadioButton("radio c", &e, 2); + + // Color buttons, demonstrate using PushID() to add unique identifier in the ID stack, and changing style. + for (int i = 0; i < 7; i++) + { + if (i > 0) ImGui::SameLine(); + ImGui::PushID(i); + ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(i/7.0f, 0.6f, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(i/7.0f, 0.7f, 0.7f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(i/7.0f, 0.8f, 0.8f)); + ImGui::Button("Click"); + ImGui::PopStyleColor(3); + ImGui::PopID(); + } + + ImGui::Text("Hover over me"); + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("I am a tooltip"); + + ImGui::SameLine(); + ImGui::Text("- or me"); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("I am a fancy tooltip"); + static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f }; + ImGui::PlotLines("Curve", arr, IM_ARRAYSIZE(arr)); + ImGui::EndTooltip(); + } + + // Testing ImGuiOnceUponAFrame helper. + //static ImGuiOnceUponAFrame once; + //for (int i = 0; i < 5; i++) + // if (once) + // ImGui::Text("This will be displayed only once."); + + ImGui::Separator(); + + ImGui::LabelText("label", "Value"); + + { + // Simplified one-liner Combo() API, using values packed in a single constant string + static int current_item_1 = 1; + ImGui::Combo("combo", ¤t_item_1, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0"); + //ImGui::Combo("combo w/ array of char*", ¤t_item_2_idx, items, IM_ARRAYSIZE(items)); // Combo using proper array. You can also pass a callback to retrieve array value, no need to create/copy an array just for that. + + // General BeginCombo() API, you have full control over your selection data and display type + const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO", "PPPP", "QQQQQQQQQQ", "RRR", "SSSS" }; + static const char* current_item_2 = NULL; + if (ImGui::BeginCombo("combo 2", current_item_2)) // The second parameter is the label previewed before opening the combo. + { + for (int n = 0; n < IM_ARRAYSIZE(items); n++) + { + bool is_selected = (current_item_2 == items[n]); // You can store your selection however you want, outside or inside your objects + if (ImGui::Selectable(items[n], is_selected)) + current_item_2 = items[n]; + if (is_selected) + ImGui::SetItemDefaultFocus(); // set the initial focus when opening the combo (scrolling + for keyboard navigation support in the upcoming navigation branch) + } + ImGui::EndCombo(); + } + } + + { + static char str0[128] = "Hello, world!"; + static int i0=123; + static float f0=0.001f; + ImGui::InputText("input text", str0, IM_ARRAYSIZE(str0)); + ImGui::SameLine(); ShowHelpMarker("Hold SHIFT or use mouse to select text.\n" "CTRL+Left/Right to word jump.\n" "CTRL+A or double-click to select all.\n" "CTRL+X,CTRL+C,CTRL+V clipboard.\n" "CTRL+Z,CTRL+Y undo/redo.\n" "ESCAPE to revert.\n"); + + ImGui::InputInt("input int", &i0); + ImGui::SameLine(); ShowHelpMarker("You can apply arithmetic operators +,*,/ on numerical values.\n e.g. [ 100 ], input \'*2\', result becomes [ 200 ]\nUse +- to subtract.\n"); + + ImGui::InputFloat("input float", &f0, 0.01f, 1.0f); + + static float vec4a[4] = { 0.10f, 0.20f, 0.30f, 0.44f }; + ImGui::InputFloat3("input float3", vec4a); + } + + { + static int i1=50, i2=42; + ImGui::DragInt("drag int", &i1, 1); + ImGui::SameLine(); ShowHelpMarker("Click and drag to edit value.\nHold SHIFT/ALT for faster/slower edit.\nDouble-click or CTRL+click to input value."); + + ImGui::DragInt("drag int 0..100", &i2, 1, 0, 100, "%.0f%%"); + + static float f1=1.00f, f2=0.0067f; + ImGui::DragFloat("drag float", &f1, 0.005f); + ImGui::DragFloat("drag small float", &f2, 0.0001f, 0.0f, 0.0f, "%.06f ns"); + } + + { + static int i1=0; + ImGui::SliderInt("slider int", &i1, -1, 3); + ImGui::SameLine(); ShowHelpMarker("CTRL+click to input value."); + + static float f1=0.123f, f2=0.0f; + ImGui::SliderFloat("slider float", &f1, 0.0f, 1.0f, "ratio = %.3f"); + ImGui::SliderFloat("slider log float", &f2, -10.0f, 10.0f, "%.4f", 3.0f); + static float angle = 0.0f; + ImGui::SliderAngle("slider angle", &angle); + } + + static float col1[3] = { 1.0f,0.0f,0.2f }; + static float col2[4] = { 0.4f,0.7f,0.0f,0.5f }; + ImGui::ColorEdit3("color 1", col1); + ImGui::SameLine(); ShowHelpMarker("Click on the colored square to open a color picker.\nRight-click on the colored square to show options.\nCTRL+click on individual component to input value.\n"); + + ImGui::ColorEdit4("color 2", col2); + + const char* listbox_items[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" }; + static int listbox_item_current = 1; + ImGui::ListBox("listbox\n(single select)", &listbox_item_current, listbox_items, IM_ARRAYSIZE(listbox_items), 4); + + //static int listbox_item_current2 = 2; + //ImGui::PushItemWidth(-1); + //ImGui::ListBox("##listbox2", &listbox_item_current2, listbox_items, IM_ARRAYSIZE(listbox_items), 4); + //ImGui::PopItemWidth(); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Trees")) + { + if (ImGui::TreeNode("Basic trees")) + { + for (int i = 0; i < 5; i++) + if (ImGui::TreeNode((void*)(intptr_t)i, "Child %d", i)) + { + ImGui::Text("blah blah"); + ImGui::SameLine(); + if (ImGui::SmallButton("button")) { }; + ImGui::TreePop(); + } + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Advanced, with Selectable nodes")) + { + ShowHelpMarker("This is a more standard looking tree with selectable nodes.\nClick to select, CTRL+Click to toggle, click on arrows or double-click to open."); + static bool align_label_with_current_x_position = false; + ImGui::Checkbox("Align label with current X position)", &align_label_with_current_x_position); + ImGui::Text("Hello!"); + if (align_label_with_current_x_position) + ImGui::Unindent(ImGui::GetTreeNodeToLabelSpacing()); + + static int selection_mask = (1 << 2); // Dumb representation of what may be user-side selection state. You may carry selection state inside or outside your objects in whatever format you see fit. + int node_clicked = -1; // Temporary storage of what node we have clicked to process selection at the end of the loop. May be a pointer to your own node type, etc. + ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, ImGui::GetFontSize()*3); // Increase spacing to differentiate leaves from expanded contents. + for (int i = 0; i < 6; i++) + { + // Disable the default open on single-click behavior and pass in Selected flag according to our selection state. + ImGuiTreeNodeFlags node_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ((selection_mask & (1 << i)) ? ImGuiTreeNodeFlags_Selected : 0); + if (i < 3) + { + // Node + bool node_open = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Node %d", i); + if (ImGui::IsItemClicked()) + node_clicked = i; + if (node_open) + { + ImGui::Text("Blah blah\nBlah Blah"); + ImGui::TreePop(); + } + } + else + { + // Leaf: The only reason we have a TreeNode at all is to allow selection of the leaf. Otherwise we can use BulletText() or TreeAdvanceToLabelPos()+Text(). + node_flags |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen; // ImGuiTreeNodeFlags_Bullet + ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Leaf %d", i); + if (ImGui::IsItemClicked()) + node_clicked = i; + } + } + if (node_clicked != -1) + { + // update selection state. Process outside of tree loop to avoid visual inconsistencies during the clicking-frame. + if (ImGui::GetIO().KeyCtrl) + selection_mask ^= (1 << node_clicked); // CTRL+click to toggle + else //if (!(selection_mask & (1 << node_clicked))) // Depending on selection behavior you want, this commented bit preserve selection when clicking on item that is part of the selection + selection_mask = (1 << node_clicked); // Click to single-select + } + ImGui::PopStyleVar(); + if (align_label_with_current_x_position) + ImGui::Indent(ImGui::GetTreeNodeToLabelSpacing()); + ImGui::TreePop(); + } + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Collapsing Headers")) + { + static bool closable_group = true; + ImGui::Checkbox("Enable extra group", &closable_group); + if (ImGui::CollapsingHeader("Header")) + { + ImGui::Text("IsItemHovered: %d", IsItemHovered()); + for (int i = 0; i < 5; i++) + ImGui::Text("Some content %d", i); + } + if (ImGui::CollapsingHeader("Header with a close button", &closable_group)) + { + ImGui::Text("IsItemHovered: %d", IsItemHovered()); + for (int i = 0; i < 5; i++) + ImGui::Text("More content %d", i); + } + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Bullets")) + { + ImGui::BulletText("Bullet point 1"); + ImGui::BulletText("Bullet point 2\nOn multiple lines"); + ImGui::Bullet(); ImGui::Text("Bullet point 3 (two calls)"); + ImGui::Bullet(); ImGui::SmallButton("Button"); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Text")) + { + if (ImGui::TreeNode("Colored Text")) + { + // Using shortcut. You can use PushStyleColor()/PopStyleColor() for more flexibility. + ImGui::TextColored(ImVec4(1.0f,0.0f,1.0f,1.0f), "Pink"); + ImGui::TextColored(ImVec4(1.0f,1.0f,0.0f,1.0f), "Yellow"); + ImGui::TextDisabled("Disabled"); + ImGui::SameLine(); ShowHelpMarker("The TextDisabled color is stored in ImGuiStyle."); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Word Wrapping")) + { + // Using shortcut. You can use PushTextWrapPos()/PopTextWrapPos() for more flexibility. + ImGui::TextWrapped("This text should automatically wrap on the edge of the window. The current implementation for text wrapping follows simple rules suitable for English and possibly other languages."); + ImGui::Spacing(); + + static float wrap_width = 200.0f; + ImGui::SliderFloat("Wrap width", &wrap_width, -20, 600, "%.0f"); + + ImGui::Text("Test paragraph 1:"); + ImVec2 pos = ImGui::GetCursorScreenPos(); + ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(pos.x + wrap_width, pos.y), ImVec2(pos.x + wrap_width + 10, pos.y + ImGui::GetTextLineHeight()), IM_COL32(255,0,255,255)); + ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + wrap_width); + ImGui::Text("The lazy dog is a good dog. This paragraph is made to fit within %.0f pixels. Testing a 1 character word. The quick brown fox jumps over the lazy dog.", wrap_width); + ImGui::GetWindowDrawList()->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(255,255,0,255)); + ImGui::PopTextWrapPos(); + + ImGui::Text("Test paragraph 2:"); + pos = ImGui::GetCursorScreenPos(); + ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(pos.x + wrap_width, pos.y), ImVec2(pos.x + wrap_width + 10, pos.y + ImGui::GetTextLineHeight()), IM_COL32(255,0,255,255)); + ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + wrap_width); + ImGui::Text("aaaaaaaa bbbbbbbb, c cccccccc,dddddddd. d eeeeeeee ffffffff. gggggggg!hhhhhhhh"); + ImGui::GetWindowDrawList()->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(255,255,0,255)); + ImGui::PopTextWrapPos(); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("UTF-8 Text")) + { + // UTF-8 test with Japanese characters + // (needs a suitable font, try Arial Unicode or M+ fonts http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/index-en.html) + // - From C++11 you can use the u8"my text" syntax to encode literal strings as UTF-8 + // - For earlier compiler, you may be able to encode your sources as UTF-8 (e.g. Visual Studio save your file as 'UTF-8 without signature') + // - HOWEVER, FOR THIS DEMO FILE, BECAUSE WE WANT TO SUPPORT COMPILER, WE ARE *NOT* INCLUDING RAW UTF-8 CHARACTERS IN THIS SOURCE FILE. + // Instead we are encoding a few string with hexadecimal constants. Don't do this in your application! + // Note that characters values are preserved even by InputText() if the font cannot be displayed, so you can safely copy & paste garbled characters into another application. + ImGui::TextWrapped("CJK text will only appears if the font was loaded with the appropriate CJK character ranges. Call io.Font->LoadFromFileTTF() manually to load extra character ranges."); + ImGui::Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)"); + ImGui::Text("Kanjis: \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e (nihongo)"); + static char buf[32] = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e"; // "nihongo" + ImGui::InputText("UTF-8 input", buf, IM_ARRAYSIZE(buf)); + ImGui::TreePop(); + } + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Images")) + { + ImGui::TextWrapped("Below we are displaying the font texture (which is the only texture we have access to in this demo). Use the 'ImTextureID' type as storage to pass pointers or identifier to your own texture data. Hover the texture for a zoomed view!"); + ImGuiIO& io = ImGui::GetIO(); + + // Here we are grabbing the font texture because that's the only one we have access to inside the demo code. + // Remember that ImTextureID is just storage for whatever you want it to be, it is essentially a value that will be passed to the render function inside the ImDrawCmd structure. + // If you use one of the default imgui_impl_XXXX.cpp renderer, they all have comments at the top of their file to specify what they expect to be stored in ImTextureID. + // (for example, the imgui_impl_dx11.cpp renderer expect a 'ID3D11ShaderResourceView*' pointer. The imgui_impl_glfw_gl3.cpp renderer expect a GLuint OpenGL texture identifier etc.) + // If you decided that ImTextureID = MyEngineTexture*, then you can pass your MyEngineTexture* pointers to ImGui::Image(), and gather width/height through your own functions, etc. + // Using ShowMetricsWindow() as a "debugger" to inspect the draw data that are being passed to your render will help you debug issues if you are confused about this. + // Consider using the lower-level ImDrawList::AddImage() API, via ImGui::GetWindowDrawList()->AddImage(). + ImTextureID my_tex_id = io.Fonts->TexID; + float my_tex_w = (float)io.Fonts->TexWidth; + float my_tex_h = (float)io.Fonts->TexHeight; + + ImGui::Text("%.0fx%.0f", my_tex_w, my_tex_h); + ImVec2 pos = ImGui::GetCursorScreenPos(); + ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), ImVec2(0,0), ImVec2(1,1), ImColor(255,255,255,255), ImColor(255,255,255,128)); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + float focus_sz = 32.0f; + float focus_x = io.MousePos.x - pos.x - focus_sz * 0.5f; if (focus_x < 0.0f) focus_x = 0.0f; else if (focus_x > my_tex_w - focus_sz) focus_x = my_tex_w - focus_sz; + float focus_y = io.MousePos.y - pos.y - focus_sz * 0.5f; if (focus_y < 0.0f) focus_y = 0.0f; else if (focus_y > my_tex_h - focus_sz) focus_y = my_tex_h - focus_sz; + ImGui::Text("Min: (%.2f, %.2f)", focus_x, focus_y); + ImGui::Text("Max: (%.2f, %.2f)", focus_x + focus_sz, focus_y + focus_sz); + ImVec2 uv0 = ImVec2((focus_x) / my_tex_w, (focus_y) / my_tex_h); + ImVec2 uv1 = ImVec2((focus_x + focus_sz) / my_tex_w, (focus_y + focus_sz) / my_tex_h); + ImGui::Image(my_tex_id, ImVec2(128,128), uv0, uv1, ImColor(255,255,255,255), ImColor(255,255,255,128)); + ImGui::EndTooltip(); + } + ImGui::TextWrapped("And now some textured buttons.."); + static int pressed_count = 0; + for (int i = 0; i < 8; i++) + { + ImGui::PushID(i); + int frame_padding = -1 + i; // -1 = uses default padding + if (ImGui::ImageButton(my_tex_id, ImVec2(32,32), ImVec2(0,0), ImVec2(32.0f/my_tex_w,32/my_tex_h), frame_padding, ImColor(0,0,0,255))) + pressed_count += 1; + ImGui::PopID(); + ImGui::SameLine(); + } + ImGui::NewLine(); + ImGui::Text("Pressed %d times.", pressed_count); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Selectables")) + { + // Selectable() has 2 overloads: + // - The one taking "bool selected" as a read-only selection information. When Selectable() has been clicked is returns true and you can alter selection state accordingly. + // - The one taking "bool* p_selected" as a read-write selection information (convenient in some cases) + // The earlier is more flexible, as in real application your selection may be stored in a different manner (in flags within objects, as an external list, etc). + if (ImGui::TreeNode("Basic")) + { + static bool selection[5] = { false, true, false, false, false }; + ImGui::Selectable("1. I am selectable", &selection[0]); + ImGui::Selectable("2. I am selectable", &selection[1]); + ImGui::Text("3. I am not selectable"); + ImGui::Selectable("4. I am selectable", &selection[3]); + if (ImGui::Selectable("5. I am double clickable", selection[4], ImGuiSelectableFlags_AllowDoubleClick)) + if (ImGui::IsMouseDoubleClicked(0)) + selection[4] = !selection[4]; + ImGui::TreePop(); + } + if (ImGui::TreeNode("Selection State: Single Selection")) + { + static int selected = -1; + for (int n = 0; n < 5; n++) + { + char buf[32]; + sprintf(buf, "Object %d", n); + if (ImGui::Selectable(buf, selected == n)) + selected = n; + } + ImGui::TreePop(); + } + if (ImGui::TreeNode("Selection State: Multiple Selection")) + { + ShowHelpMarker("Hold CTRL and click to select multiple items."); + static bool selection[5] = { false, false, false, false, false }; + for (int n = 0; n < 5; n++) + { + char buf[32]; + sprintf(buf, "Object %d", n); + if (ImGui::Selectable(buf, selection[n])) + { + if (!ImGui::GetIO().KeyCtrl) // Clear selection when CTRL is not held + memset(selection, 0, sizeof(selection)); + selection[n] ^= 1; + } + } + ImGui::TreePop(); + } + if (ImGui::TreeNode("Rendering more text into the same line")) + { + // Using the Selectable() override that takes "bool* p_selected" parameter and toggle your booleans automatically. + static bool selected[3] = { false, false, false }; + ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(300); ImGui::Text(" 2,345 BYTEs"); + ImGui::Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(300); ImGui::Text("12,345 BYTEs"); + ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(300); ImGui::Text(" 2,345 BYTEs"); + ImGui::TreePop(); + } + if (ImGui::TreeNode("In columns")) + { + ImGui::Columns(3, NULL, false); + static bool selected[16] = { 0 }; + for (int i = 0; i < 16; i++) + { + char label[32]; sprintf(label, "Item %d", i); + if (ImGui::Selectable(label, &selected[i])) {} + ImGui::NextColumn(); + } + ImGui::Columns(1); + ImGui::TreePop(); + } + if (ImGui::TreeNode("Grid")) + { + static bool selected[16] = { true, false, false, false, false, true, false, false, false, false, true, false, false, false, false, true }; + for (int i = 0; i < 16; i++) + { + ImGui::PushID(i); + if (ImGui::Selectable("Sailor", &selected[i], 0, ImVec2(50,50))) + { + int x = i % 4, y = i / 4; + if (x > 0) selected[i - 1] ^= 1; + if (x < 3) selected[i + 1] ^= 1; + if (y > 0) selected[i - 4] ^= 1; + if (y < 3) selected[i + 4] ^= 1; + } + if ((i % 4) < 3) ImGui::SameLine(); + ImGui::PopID(); + } + ImGui::TreePop(); + } + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Filtered Text Input")) + { + static char buf1[64] = ""; ImGui::InputText("default", buf1, 64); + static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal); + static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase); + static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase); + static char buf5[64] = ""; ImGui::InputText("no blank", buf5, 64, ImGuiInputTextFlags_CharsNoBlank); + struct TextFilters { static int FilterImGuiLetters(ImGuiTextEditCallbackData* data) { if (data->EventChar < 256 && strchr("imgui", (char)data->EventChar)) return 0; return 1; } }; + static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters); + + ImGui::Text("Password input"); + static char bufpass[64] = "password123"; + ImGui::InputText("password", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank); + ImGui::SameLine(); ShowHelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n"); + ImGui::InputText("password (clear)", bufpass, 64, ImGuiInputTextFlags_CharsNoBlank); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Multi-line Text Input")) + { + static bool read_only = false; + static char text[1024*16] = + "/*\n" + " The Pentium F00F bug, shorthand for F0 0F C7 C8,\n" + " the hexadecimal encoding of one offending instruction,\n" + " more formally, the invalid operand with locked CMPXCHG8B\n" + " instruction bug, is a design flaw in the majority of\n" + " Intel Pentium, Pentium MMX, and Pentium OverDrive\n" + " processors (all in the P5 microarchitecture).\n" + "*/\n\n" + "label:\n" + "\tlock cmpxchg8b eax\n"; + + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0)); + ImGui::Checkbox("Read-only", &read_only); + ImGui::PopStyleVar(); + ImGui::InputTextMultiline("##source", text, IM_ARRAYSIZE(text), ImVec2(-1.0f, ImGui::GetTextLineHeight() * 16), ImGuiInputTextFlags_AllowTabInput | (read_only ? ImGuiInputTextFlags_ReadOnly : 0)); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Plots widgets")) + { + static bool animate = true; + ImGui::Checkbox("Animate", &animate); + + static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f }; + ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr)); + + // Create a dummy array of contiguous float values to plot + // Tip: If your float aren't contiguous but part of a structure, you can pass a pointer to your first float and the sizeof() of your structure in the Stride parameter. + static float values[90] = { 0 }; + static int values_offset = 0; + static float refresh_time = 0.0f; + if (!animate || refresh_time == 0.0f) + refresh_time = ImGui::GetTime(); + while (refresh_time < ImGui::GetTime()) // Create dummy data at fixed 60 hz rate for the demo + { + static float phase = 0.0f; + values[values_offset] = cosf(phase); + values_offset = (values_offset+1) % IM_ARRAYSIZE(values); + phase += 0.10f*values_offset; + refresh_time += 1.0f/60.0f; + } + ImGui::PlotLines("Lines", values, IM_ARRAYSIZE(values), values_offset, "avg 0.0", -1.0f, 1.0f, ImVec2(0,80)); + ImGui::PlotHistogram("Histogram", arr, IM_ARRAYSIZE(arr), 0, NULL, 0.0f, 1.0f, ImVec2(0,80)); + + // Use functions to generate output + // FIXME: This is rather awkward because current plot API only pass in indices. We probably want an API passing floats and user provide sample rate/count. + struct Funcs + { + static float Sin(void*, int i) { return sinf(i * 0.1f); } + static float Saw(void*, int i) { return (i & 1) ? 1.0f : -1.0f; } + }; + static int func_type = 0, display_count = 70; + ImGui::Separator(); + ImGui::PushItemWidth(100); ImGui::Combo("func", &func_type, "Sin\0Saw\0"); ImGui::PopItemWidth(); + ImGui::SameLine(); + ImGui::SliderInt("Sample count", &display_count, 1, 400); + float (*func)(void*, int) = (func_type == 0) ? Funcs::Sin : Funcs::Saw; + ImGui::PlotLines("Lines", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0,80)); + ImGui::PlotHistogram("Histogram", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0,80)); + ImGui::Separator(); + + // Animate a simple progress bar + static float progress = 0.0f, progress_dir = 1.0f; + if (animate) + { + progress += progress_dir * 0.4f * ImGui::GetIO().DeltaTime; + if (progress >= +1.1f) { progress = +1.1f; progress_dir *= -1.0f; } + if (progress <= -0.1f) { progress = -0.1f; progress_dir *= -1.0f; } + } + + // Typically we would use ImVec2(-1.0f,0.0f) to use all available width, or ImVec2(width,0.0f) for a specified width. ImVec2(0.0f,0.0f) uses ItemWidth. + ImGui::ProgressBar(progress, ImVec2(0.0f,0.0f)); + ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); + ImGui::Text("Progress Bar"); + + float progress_saturated = (progress < 0.0f) ? 0.0f : (progress > 1.0f) ? 1.0f : progress; + char buf[32]; + sprintf(buf, "%d/%d", (int)(progress_saturated*1753), 1753); + ImGui::ProgressBar(progress, ImVec2(0.f,0.f), buf); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Color/Picker Widgets")) + { + static ImVec4 color = ImColor(114, 144, 154, 200); + + static bool alpha_preview = true; + static bool alpha_half_preview = false; + static bool options_menu = true; + static bool hdr = false; + ImGui::Checkbox("With Alpha Preview", &alpha_preview); + ImGui::Checkbox("With Half Alpha Preview", &alpha_half_preview); + ImGui::Checkbox("With Options Menu", &options_menu); ImGui::SameLine(); ShowHelpMarker("Right-click on the individual color widget to show options."); + ImGui::Checkbox("With HDR", &hdr); ImGui::SameLine(); ShowHelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets."); + int misc_flags = (hdr ? ImGuiColorEditFlags_HDR : 0) | (alpha_half_preview ? ImGuiColorEditFlags_AlphaPreviewHalf : (alpha_preview ? ImGuiColorEditFlags_AlphaPreview : 0)) | (options_menu ? 0 : ImGuiColorEditFlags_NoOptions); + + ImGui::Text("Color widget:"); + ImGui::SameLine(); ShowHelpMarker("Click on the colored square to open a color picker.\nCTRL+click on individual component to input value.\n"); + ImGui::ColorEdit3("MyColor##1", (float*)&color, misc_flags); + + ImGui::Text("Color widget HSV with Alpha:"); + ImGui::ColorEdit4("MyColor##2", (float*)&color, ImGuiColorEditFlags_HSV | misc_flags); + + ImGui::Text("Color widget with Float Display:"); + ImGui::ColorEdit4("MyColor##2f", (float*)&color, ImGuiColorEditFlags_Float | misc_flags); + + ImGui::Text("Color button with Picker:"); + ImGui::SameLine(); ShowHelpMarker("With the ImGuiColorEditFlags_NoInputs flag you can hide all the slider/text inputs.\nWith the ImGuiColorEditFlags_NoLabel flag you can pass a non-empty label which will only be used for the tooltip and picker popup."); + ImGui::ColorEdit4("MyColor##3", (float*)&color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | misc_flags); + + ImGui::Text("Color button with Custom Picker Popup:"); + + // Generate a dummy palette + static bool saved_palette_inited = false; + static ImVec4 saved_palette[32]; + if (!saved_palette_inited) + for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++) + { + ImGui::ColorConvertHSVtoRGB(n / 31.0f, 0.8f, 0.8f, saved_palette[n].x, saved_palette[n].y, saved_palette[n].z); + saved_palette[n].w = 1.0f; // Alpha + } + saved_palette_inited = true; + + static ImVec4 backup_color; + bool open_popup = ImGui::ColorButton("MyColor##3b", color, misc_flags); + ImGui::SameLine(); + open_popup |= ImGui::Button("Palette"); + if (open_popup) + { + ImGui::OpenPopup("mypicker"); + backup_color = color; + } + if (ImGui::BeginPopup("mypicker")) + { + // FIXME: Adding a drag and drop example here would be perfect! + ImGui::Text("MY CUSTOM COLOR PICKER WITH AN AMAZING PALETTE!"); + ImGui::Separator(); + ImGui::ColorPicker4("##picker", (float*)&color, misc_flags | ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_NoSmallPreview); + ImGui::SameLine(); + ImGui::BeginGroup(); + ImGui::Text("Current"); + ImGui::ColorButton("##current", color, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(60,40)); + ImGui::Text("Previous"); + if (ImGui::ColorButton("##previous", backup_color, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(60,40))) + color = backup_color; + ImGui::Separator(); + ImGui::Text("Palette"); + for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++) + { + ImGui::PushID(n); + if ((n % 8) != 0) + ImGui::SameLine(0.0f, ImGui::GetStyle().ItemSpacing.y); + if (ImGui::ColorButton("##palette", saved_palette[n], ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoTooltip, ImVec2(20,20))) + color = ImVec4(saved_palette[n].x, saved_palette[n].y, saved_palette[n].z, color.w); // Preserve alpha! + + if (ImGui::BeginDragDropTarget()) + { + if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F)) + memcpy((float*)&saved_palette[n], payload->Data, sizeof(float) * 3); + if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F)) + memcpy((float*)&saved_palette[n], payload->Data, sizeof(float) * 4); + EndDragDropTarget(); + } + + ImGui::PopID(); + } + ImGui::EndGroup(); + ImGui::EndPopup(); + } + + ImGui::Text("Color button only:"); + ImGui::ColorButton("MyColor##3c", *(ImVec4*)&color, misc_flags, ImVec2(80,80)); + + ImGui::Text("Color picker:"); + static bool alpha = true; + static bool alpha_bar = true; + static bool side_preview = true; + static bool ref_color = false; + static ImVec4 ref_color_v(1.0f,0.0f,1.0f,0.5f); + static int inputs_mode = 2; + static int picker_mode = 0; + ImGui::Checkbox("With Alpha", &alpha); + ImGui::Checkbox("With Alpha Bar", &alpha_bar); + ImGui::Checkbox("With Side Preview", &side_preview); + if (side_preview) + { + ImGui::SameLine(); + ImGui::Checkbox("With Ref Color", &ref_color); + if (ref_color) + { + ImGui::SameLine(); + ImGui::ColorEdit4("##RefColor", &ref_color_v.x, ImGuiColorEditFlags_NoInputs | misc_flags); + } + } + ImGui::Combo("Inputs Mode", &inputs_mode, "All Inputs\0No Inputs\0RGB Input\0HSV Input\0HEX Input\0"); + ImGui::Combo("Picker Mode", &picker_mode, "Auto/Current\0Hue bar + SV rect\0Hue wheel + SV triangle\0"); + ImGui::SameLine(); ShowHelpMarker("User can right-click the picker to change mode."); + ImGuiColorEditFlags flags = misc_flags; + if (!alpha) flags |= ImGuiColorEditFlags_NoAlpha; // This is by default if you call ColorPicker3() instead of ColorPicker4() + if (alpha_bar) flags |= ImGuiColorEditFlags_AlphaBar; + if (!side_preview) flags |= ImGuiColorEditFlags_NoSidePreview; + if (picker_mode == 1) flags |= ImGuiColorEditFlags_PickerHueBar; + if (picker_mode == 2) flags |= ImGuiColorEditFlags_PickerHueWheel; + if (inputs_mode == 1) flags |= ImGuiColorEditFlags_NoInputs; + if (inputs_mode == 2) flags |= ImGuiColorEditFlags_RGB; + if (inputs_mode == 3) flags |= ImGuiColorEditFlags_HSV; + if (inputs_mode == 4) flags |= ImGuiColorEditFlags_HEX; + ImGui::ColorPicker4("MyColor##4", (float*)&color, flags, ref_color ? &ref_color_v.x : NULL); + + ImGui::Text("Programmatically set defaults/options:"); + ImGui::SameLine(); ShowHelpMarker("SetColorEditOptions() is designed to allow you to set boot-time default.\nWe don't have Push/Pop functions because you can force options on a per-widget basis if needed, and the user can change non-forced ones with the options menu.\nWe don't have a getter to avoid encouraging you to persistently save values that aren't forward-compatible."); + if (ImGui::Button("Uint8 + HSV")) + ImGui::SetColorEditOptions(ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_HSV); + ImGui::SameLine(); + if (ImGui::Button("Float + HDR")) + ImGui::SetColorEditOptions(ImGuiColorEditFlags_Float | ImGuiColorEditFlags_RGB); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Range Widgets")) + { + static float begin = 10, end = 90; + static int begin_i = 100, end_i = 1000; + ImGui::DragFloatRange2("range", &begin, &end, 0.25f, 0.0f, 100.0f, "Min: %.1f %%", "Max: %.1f %%"); + ImGui::DragIntRange2("range int (no bounds)", &begin_i, &end_i, 5, 0, 0, "Min: %.0f units", "Max: %.0f units"); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Multi-component Widgets")) + { + static float vec4f[4] = { 0.10f, 0.20f, 0.30f, 0.44f }; + static int vec4i[4] = { 1, 5, 100, 255 }; + + ImGui::InputFloat2("input float2", vec4f); + ImGui::DragFloat2("drag float2", vec4f, 0.01f, 0.0f, 1.0f); + ImGui::SliderFloat2("slider float2", vec4f, 0.0f, 1.0f); + ImGui::DragInt2("drag int2", vec4i, 1, 0, 255); + ImGui::InputInt2("input int2", vec4i); + ImGui::SliderInt2("slider int2", vec4i, 0, 255); + ImGui::Spacing(); + + ImGui::InputFloat3("input float3", vec4f); + ImGui::DragFloat3("drag float3", vec4f, 0.01f, 0.0f, 1.0f); + ImGui::SliderFloat3("slider float3", vec4f, 0.0f, 1.0f); + ImGui::DragInt3("drag int3", vec4i, 1, 0, 255); + ImGui::InputInt3("input int3", vec4i); + ImGui::SliderInt3("slider int3", vec4i, 0, 255); + ImGui::Spacing(); + + ImGui::InputFloat4("input float4", vec4f); + ImGui::DragFloat4("drag float4", vec4f, 0.01f, 0.0f, 1.0f); + ImGui::SliderFloat4("slider float4", vec4f, 0.0f, 1.0f); + ImGui::InputInt4("input int4", vec4i); + ImGui::DragInt4("drag int4", vec4i, 1, 0, 255); + ImGui::SliderInt4("slider int4", vec4i, 0, 255); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Vertical Sliders")) + { + const float spacing = 4; + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(spacing, spacing)); + + static int int_value = 0; + ImGui::VSliderInt("##int", ImVec2(18,160), &int_value, 0, 5); + ImGui::SameLine(); + + static float values[7] = { 0.0f, 0.60f, 0.35f, 0.9f, 0.70f, 0.20f, 0.0f }; + ImGui::PushID("set1"); + for (int i = 0; i < 7; i++) + { + if (i > 0) ImGui::SameLine(); + ImGui::PushID(i); + ImGui::PushStyleColor(ImGuiCol_FrameBg, (ImVec4)ImColor::HSV(i/7.0f, 0.5f, 0.5f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, (ImVec4)ImColor::HSV(i/7.0f, 0.6f, 0.5f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, (ImVec4)ImColor::HSV(i/7.0f, 0.7f, 0.5f)); + ImGui::PushStyleColor(ImGuiCol_SliderGrab, (ImVec4)ImColor::HSV(i/7.0f, 0.9f, 0.9f)); + ImGui::VSliderFloat("##v", ImVec2(18,160), &values[i], 0.0f, 1.0f, ""); + if (ImGui::IsItemActive() || ImGui::IsItemHovered()) + ImGui::SetTooltip("%.3f", values[i]); + ImGui::PopStyleColor(4); + ImGui::PopID(); + } + ImGui::PopID(); + + ImGui::SameLine(); + ImGui::PushID("set2"); + static float values2[4] = { 0.20f, 0.80f, 0.40f, 0.25f }; + const int rows = 3; + const ImVec2 small_slider_size(18, (160.0f-(rows-1)*spacing)/rows); + for (int nx = 0; nx < 4; nx++) + { + if (nx > 0) ImGui::SameLine(); + ImGui::BeginGroup(); + for (int ny = 0; ny < rows; ny++) + { + ImGui::PushID(nx*rows+ny); + ImGui::VSliderFloat("##v", small_slider_size, &values2[nx], 0.0f, 1.0f, ""); + if (ImGui::IsItemActive() || ImGui::IsItemHovered()) + ImGui::SetTooltip("%.3f", values2[nx]); + ImGui::PopID(); + } + ImGui::EndGroup(); + } + ImGui::PopID(); + + ImGui::SameLine(); + ImGui::PushID("set3"); + for (int i = 0; i < 4; i++) + { + if (i > 0) ImGui::SameLine(); + ImGui::PushID(i); + ImGui::PushStyleVar(ImGuiStyleVar_GrabMinSize, 40); + ImGui::VSliderFloat("##v", ImVec2(40,160), &values[i], 0.0f, 1.0f, "%.2f\nsec"); + ImGui::PopStyleVar(); + ImGui::PopID(); + } + ImGui::PopID(); + ImGui::PopStyleVar(); + ImGui::TreePop(); + } + } + + if (ImGui::CollapsingHeader("Layout")) + { + if (ImGui::TreeNode("Child regions")) + { + static bool disable_mouse_wheel = false; + ImGui::Checkbox("Disable Mouse Wheel", &disable_mouse_wheel); + + ImGui::Text("Without border"); + static int line = 50; + bool goto_line = ImGui::Button("Goto"); + ImGui::SameLine(); + ImGui::PushItemWidth(100); + goto_line |= ImGui::InputInt("##Line", &line, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue); + ImGui::PopItemWidth(); + + // Child 1: no border, enable horizontal scrollbar + { + ImGui::BeginChild("Child1", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f, 300), false, ImGuiWindowFlags_HorizontalScrollbar | (disable_mouse_wheel ? ImGuiWindowFlags_NoScrollWithMouse : 0)); + for (int i = 0; i < 100; i++) + { + ImGui::Text("%04d: scrollable region", i); + if (goto_line && line == i) + ImGui::SetScrollHere(); + } + if (goto_line && line >= 100) + ImGui::SetScrollHere(); + ImGui::EndChild(); + } + + ImGui::SameLine(); + + // Child 2: rounded border + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::BeginChild("Child2", ImVec2(0,300), true, (disable_mouse_wheel ? ImGuiWindowFlags_NoScrollWithMouse : 0)); + ImGui::Text("With border"); + ImGui::Columns(2); + for (int i = 0; i < 100; i++) + { + if (i == 50) + ImGui::NextColumn(); + char buf[32]; + sprintf(buf, "%08x", i*5731); + ImGui::Button(buf, ImVec2(-1.0f, 0.0f)); + } + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Widgets Width")) + { + static float f = 0.0f; + ImGui::Text("PushItemWidth(100)"); + ImGui::SameLine(); ShowHelpMarker("Fixed width."); + ImGui::PushItemWidth(100); + ImGui::DragFloat("float##1", &f); + ImGui::PopItemWidth(); + + ImGui::Text("PushItemWidth(GetWindowWidth() * 0.5f)"); + ImGui::SameLine(); ShowHelpMarker("Half of window width."); + ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.5f); + ImGui::DragFloat("float##2", &f); + ImGui::PopItemWidth(); + + ImGui::Text("PushItemWidth(GetContentRegionAvailWidth() * 0.5f)"); + ImGui::SameLine(); ShowHelpMarker("Half of available width.\n(~ right-cursor_pos)\n(works within a column set)"); + ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() * 0.5f); + ImGui::DragFloat("float##3", &f); + ImGui::PopItemWidth(); + + ImGui::Text("PushItemWidth(-100)"); + ImGui::SameLine(); ShowHelpMarker("Align to right edge minus 100"); + ImGui::PushItemWidth(-100); + ImGui::DragFloat("float##4", &f); + ImGui::PopItemWidth(); + + ImGui::Text("PushItemWidth(-1)"); + ImGui::SameLine(); ShowHelpMarker("Align to right edge"); + ImGui::PushItemWidth(-1); + ImGui::DragFloat("float##5", &f); + ImGui::PopItemWidth(); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Basic Horizontal Layout")) + { + ImGui::TextWrapped("(Use ImGui::SameLine() to keep adding items to the right of the preceding item)"); + + // Text + ImGui::Text("Two items: Hello"); ImGui::SameLine(); + ImGui::TextColored(ImVec4(1,1,0,1), "Sailor"); + + // Adjust spacing + ImGui::Text("More spacing: Hello"); ImGui::SameLine(0, 20); + ImGui::TextColored(ImVec4(1,1,0,1), "Sailor"); + + // Button + ImGui::AlignTextToFramePadding(); + ImGui::Text("Normal buttons"); ImGui::SameLine(); + ImGui::Button("Banana"); ImGui::SameLine(); + ImGui::Button("Apple"); ImGui::SameLine(); + ImGui::Button("Corniflower"); + + // Button + ImGui::Text("Small buttons"); ImGui::SameLine(); + ImGui::SmallButton("Like this one"); ImGui::SameLine(); + ImGui::Text("can fit within a text block."); + + // Aligned to arbitrary position. Easy/cheap column. + ImGui::Text("Aligned"); + ImGui::SameLine(150); ImGui::Text("x=150"); + ImGui::SameLine(300); ImGui::Text("x=300"); + ImGui::Text("Aligned"); + ImGui::SameLine(150); ImGui::SmallButton("x=150"); + ImGui::SameLine(300); ImGui::SmallButton("x=300"); + + // Checkbox + static bool c1=false,c2=false,c3=false,c4=false; + ImGui::Checkbox("My", &c1); ImGui::SameLine(); + ImGui::Checkbox("Tailor", &c2); ImGui::SameLine(); + ImGui::Checkbox("Is", &c3); ImGui::SameLine(); + ImGui::Checkbox("Rich", &c4); + + // Various + static float f0=1.0f, f1=2.0f, f2=3.0f; + ImGui::PushItemWidth(80); + const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD" }; + static int item = -1; + ImGui::Combo("Combo", &item, items, IM_ARRAYSIZE(items)); ImGui::SameLine(); + ImGui::SliderFloat("X", &f0, 0.0f,5.0f); ImGui::SameLine(); + ImGui::SliderFloat("Y", &f1, 0.0f,5.0f); ImGui::SameLine(); + ImGui::SliderFloat("Z", &f2, 0.0f,5.0f); + ImGui::PopItemWidth(); + + ImGui::PushItemWidth(80); + ImGui::Text("Lists:"); + static int selection[4] = { 0, 1, 2, 3 }; + for (int i = 0; i < 4; i++) + { + if (i > 0) ImGui::SameLine(); + ImGui::PushID(i); + ImGui::ListBox("", &selection[i], items, IM_ARRAYSIZE(items)); + ImGui::PopID(); + //if (ImGui::IsItemHovered()) ImGui::SetTooltip("ListBox %d hovered", i); + } + ImGui::PopItemWidth(); + + // Dummy + ImVec2 sz(30,30); + ImGui::Button("A", sz); ImGui::SameLine(); + ImGui::Dummy(sz); ImGui::SameLine(); + ImGui::Button("B", sz); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Groups")) + { + ImGui::TextWrapped("(Using ImGui::BeginGroup()/EndGroup() to layout items. BeginGroup() basically locks the horizontal position. EndGroup() bundles the whole group so that you can use functions such as IsItemHovered() on it.)"); + ImGui::BeginGroup(); + { + ImGui::BeginGroup(); + ImGui::Button("AAA"); + ImGui::SameLine(); + ImGui::Button("BBB"); + ImGui::SameLine(); + ImGui::BeginGroup(); + ImGui::Button("CCC"); + ImGui::Button("DDD"); + ImGui::EndGroup(); + ImGui::SameLine(); + ImGui::Button("EEE"); + ImGui::EndGroup(); + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("First group hovered"); + } + // Capture the group size and create widgets using the same size + ImVec2 size = ImGui::GetItemRectSize(); + const float values[5] = { 0.5f, 0.20f, 0.80f, 0.60f, 0.25f }; + ImGui::PlotHistogram("##values", values, IM_ARRAYSIZE(values), 0, NULL, 0.0f, 1.0f, size); + + ImGui::Button("ACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x)*0.5f,size.y)); + ImGui::SameLine(); + ImGui::Button("REACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x)*0.5f,size.y)); + ImGui::EndGroup(); + ImGui::SameLine(); + + ImGui::Button("LEVERAGE\nBUZZWORD", size); + ImGui::SameLine(); + + ImGui::ListBoxHeader("List", size); + ImGui::Selectable("Selected", true); + ImGui::Selectable("Not Selected", false); + ImGui::ListBoxFooter(); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Text Baseline Alignment")) + { + ImGui::TextWrapped("(This is testing the vertical alignment that occurs on text to keep it at the same baseline as widgets. Lines only composed of text or \"small\" widgets fit in less vertical spaces than lines with normal widgets)"); + + ImGui::Text("One\nTwo\nThree"); ImGui::SameLine(); + ImGui::Text("Hello\nWorld"); ImGui::SameLine(); + ImGui::Text("Banana"); + + ImGui::Text("Banana"); ImGui::SameLine(); + ImGui::Text("Hello\nWorld"); ImGui::SameLine(); + ImGui::Text("One\nTwo\nThree"); + + ImGui::Button("HOP##1"); ImGui::SameLine(); + ImGui::Text("Banana"); ImGui::SameLine(); + ImGui::Text("Hello\nWorld"); ImGui::SameLine(); + ImGui::Text("Banana"); + + ImGui::Button("HOP##2"); ImGui::SameLine(); + ImGui::Text("Hello\nWorld"); ImGui::SameLine(); + ImGui::Text("Banana"); + + ImGui::Button("TEST##1"); ImGui::SameLine(); + ImGui::Text("TEST"); ImGui::SameLine(); + ImGui::SmallButton("TEST##2"); + + ImGui::AlignTextToFramePadding(); // If your line starts with text, call this to align it to upcoming widgets. + ImGui::Text("Text aligned to Widget"); ImGui::SameLine(); + ImGui::Button("Widget##1"); ImGui::SameLine(); + ImGui::Text("Widget"); ImGui::SameLine(); + ImGui::SmallButton("Widget##2"); ImGui::SameLine(); + ImGui::Button("Widget##3"); + + // Tree + const float spacing = ImGui::GetStyle().ItemInnerSpacing.x; + ImGui::Button("Button##1"); + ImGui::SameLine(0.0f, spacing); + if (ImGui::TreeNode("Node##1")) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data + + ImGui::AlignTextToFramePadding(); // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. Otherwise you can use SmallButton (smaller fit). + bool node_open = ImGui::TreeNode("Node##2"); // Common mistake to avoid: if we want to SameLine after TreeNode we need to do it before we add child content. + ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##2"); + if (node_open) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data + + // Bullet + ImGui::Button("Button##3"); + ImGui::SameLine(0.0f, spacing); + ImGui::BulletText("Bullet text"); + + ImGui::AlignTextToFramePadding(); + ImGui::BulletText("Node"); + ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##4"); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Scrolling")) + { + ImGui::TextWrapped("(Use SetScrollHere() or SetScrollFromPosY() to scroll to a given position.)"); + static bool track = true; + static int track_line = 50, scroll_to_px = 200; + ImGui::Checkbox("Track", &track); + ImGui::PushItemWidth(100); + ImGui::SameLine(130); track |= ImGui::DragInt("##line", &track_line, 0.25f, 0, 99, "Line = %.0f"); + bool scroll_to = ImGui::Button("Scroll To Pos"); + ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "Y = %.0f px"); + ImGui::PopItemWidth(); + if (scroll_to) track = false; + + for (int i = 0; i < 5; i++) + { + if (i > 0) ImGui::SameLine(); + ImGui::BeginGroup(); + ImGui::Text("%s", i == 0 ? "Top" : i == 1 ? "25%" : i == 2 ? "Center" : i == 3 ? "75%" : "Bottom"); + ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(ImGui::GetWindowWidth() * 0.17f, 200.0f), true); + if (scroll_to) + ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_px, i * 0.25f); + for (int line = 0; line < 100; line++) + { + if (track && line == track_line) + { + ImGui::TextColored(ImColor(255,255,0), "Line %d", line); + ImGui::SetScrollHere(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom + } + else + { + ImGui::Text("Line %d", line); + } + } + float scroll_y = ImGui::GetScrollY(), scroll_max_y = ImGui::GetScrollMaxY(); + ImGui::EndChild(); + ImGui::Text("%.0f/%0.f", scroll_y, scroll_max_y); + ImGui::EndGroup(); + } + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Horizontal Scrolling")) + { + ImGui::Bullet(); ImGui::TextWrapped("Horizontal scrolling for a window has to be enabled explicitly via the ImGuiWindowFlags_HorizontalScrollbar flag."); + ImGui::Bullet(); ImGui::TextWrapped("You may want to explicitly specify content width by calling SetNextWindowContentWidth() before Begin()."); + static int lines = 7; + ImGui::SliderInt("Lines", &lines, 1, 15); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 1.0f)); + ImGui::BeginChild("scrolling", ImVec2(0, ImGui::GetFrameHeightWithSpacing()*7 + 30), true, ImGuiWindowFlags_HorizontalScrollbar); + for (int line = 0; line < lines; line++) + { + // Display random stuff (for the sake of this trivial demo we are using basic Button+SameLine. If you want to create your own time line for a real application you may be better off + // manipulating the cursor position yourself, aka using SetCursorPos/SetCursorScreenPos to position the widgets yourself. You may also want to use the lower-level ImDrawList API) + int num_buttons = 10 + ((line & 1) ? line * 9 : line * 3); + for (int n = 0; n < num_buttons; n++) + { + if (n > 0) ImGui::SameLine(); + ImGui::PushID(n + line * 1000); + char num_buf[16]; + sprintf(num_buf, "%d", n); + const char* label = (!(n%15)) ? "FizzBuzz" : (!(n%3)) ? "Fizz" : (!(n%5)) ? "Buzz" : num_buf; + float hue = n*0.05f; + ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(hue, 0.6f, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(hue, 0.7f, 0.7f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(hue, 0.8f, 0.8f)); + ImGui::Button(label, ImVec2(40.0f + sinf((float)(line + n)) * 20.0f, 0.0f)); + ImGui::PopStyleColor(3); + ImGui::PopID(); + } + } + float scroll_x = ImGui::GetScrollX(), scroll_max_x = ImGui::GetScrollMaxX(); + ImGui::EndChild(); + ImGui::PopStyleVar(2); + float scroll_x_delta = 0.0f; + ImGui::SmallButton("<<"); if (ImGui::IsItemActive()) scroll_x_delta = -ImGui::GetIO().DeltaTime * 1000.0f; ImGui::SameLine(); + ImGui::Text("Scroll from code"); ImGui::SameLine(); + ImGui::SmallButton(">>"); if (ImGui::IsItemActive()) scroll_x_delta = +ImGui::GetIO().DeltaTime * 1000.0f; ImGui::SameLine(); + ImGui::Text("%.0f/%.0f", scroll_x, scroll_max_x); + if (scroll_x_delta != 0.0f) + { + ImGui::BeginChild("scrolling"); // Demonstrate a trick: you can use Begin to set yourself in the context of another window (here we are already out of your child window) + ImGui::SetScrollX(ImGui::GetScrollX() + scroll_x_delta); + ImGui::End(); + } + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Clipping")) + { + static ImVec2 size(100, 100), offset(50, 20); + ImGui::TextWrapped("On a per-widget basis we are occasionally clipping text CPU-side if it won't fit in its frame. Otherwise we are doing coarser clipping + passing a scissor rectangle to the renderer. The system is designed to try minimizing both execution and CPU/GPU rendering cost."); + ImGui::DragFloat2("size", (float*)&size, 0.5f, 0.0f, 200.0f, "%.0f"); + ImGui::TextWrapped("(Click and drag)"); + ImVec2 pos = ImGui::GetCursorScreenPos(); + ImVec4 clip_rect(pos.x, pos.y, pos.x+size.x, pos.y+size.y); + ImGui::InvisibleButton("##dummy", size); + if (ImGui::IsItemActive() && ImGui::IsMouseDragging()) { offset.x += ImGui::GetIO().MouseDelta.x; offset.y += ImGui::GetIO().MouseDelta.y; } + ImGui::GetWindowDrawList()->AddRectFilled(pos, ImVec2(pos.x+size.x,pos.y+size.y), IM_COL32(90,90,120,255)); + ImGui::GetWindowDrawList()->AddText(ImGui::GetFont(), ImGui::GetFontSize()*2.0f, ImVec2(pos.x+offset.x,pos.y+offset.y), IM_COL32(255,255,255,255), "Line 1 hello\nLine 2 clip me!", NULL, 0.0f, &clip_rect); + ImGui::TreePop(); + } + } + + if (ImGui::CollapsingHeader("Popups & Modal windows")) + { + if (ImGui::TreeNode("Popups")) + { + ImGui::TextWrapped("When a popup is active, it inhibits interacting with windows that are behind the popup. Clicking outside the popup closes it."); + + static int selected_fish = -1; + const char* names[] = { "Bream", "Haddock", "Mackerel", "Pollock", "Tilefish" }; + static bool toggles[] = { true, false, false, false, false }; + + // Simple selection popup + // (If you want to show the current selection inside the Button itself, you may want to build a string using the "###" operator to preserve a constant ID with a variable label) + if (ImGui::Button("Select..")) + ImGui::OpenPopup("select"); + ImGui::SameLine(); + ImGui::TextUnformatted(selected_fish == -1 ? "" : names[selected_fish]); + if (ImGui::BeginPopup("select")) + { + ImGui::Text("Aquarium"); + ImGui::Separator(); + for (int i = 0; i < IM_ARRAYSIZE(names); i++) + if (ImGui::Selectable(names[i])) + selected_fish = i; + ImGui::EndPopup(); + } + + // Showing a menu with toggles + if (ImGui::Button("Toggle..")) + ImGui::OpenPopup("toggle"); + if (ImGui::BeginPopup("toggle")) + { + for (int i = 0; i < IM_ARRAYSIZE(names); i++) + ImGui::MenuItem(names[i], "", &toggles[i]); + if (ImGui::BeginMenu("Sub-menu")) + { + ImGui::MenuItem("Click me"); + ImGui::EndMenu(); + } + + ImGui::Separator(); + ImGui::Text("Tooltip here"); + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("I am a tooltip over a popup"); + + if (ImGui::Button("Stacked Popup")) + ImGui::OpenPopup("another popup"); + if (ImGui::BeginPopup("another popup")) + { + for (int i = 0; i < IM_ARRAYSIZE(names); i++) + ImGui::MenuItem(names[i], "", &toggles[i]); + if (ImGui::BeginMenu("Sub-menu")) + { + ImGui::MenuItem("Click me"); + ImGui::EndMenu(); + } + ImGui::EndPopup(); + } + ImGui::EndPopup(); + } + + if (ImGui::Button("Popup Menu..")) + ImGui::OpenPopup("FilePopup"); + if (ImGui::BeginPopup("FilePopup")) + { + ShowExampleMenuFile(); + ImGui::EndPopup(); + } + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Context menus")) + { + // BeginPopupContextItem() is a helper to provide common/simple popup behavior of essentially doing: + // if (IsItemHovered() && IsMouseClicked(0)) + // OpenPopup(id); + // return BeginPopup(id); + // For more advanced uses you may want to replicate and cuztomize this code. This the comments inside BeginPopupContextItem() implementation. + static float value = 0.5f; + ImGui::Text("Value = %.3f (<-- right-click here)", value); + if (ImGui::BeginPopupContextItem("item context menu")) + { + if (ImGui::Selectable("set to zero")) value = 0.0f; + if (ImGui::Selectable("set to PI")) value = 3.1415f; + ImGui::PushItemWidth(-1); + ImGui::DragFloat("##Value", &value, 0.1f, 0.0f, 0.0f); + ImGui::PopItemWidth(); + ImGui::EndPopup(); + } + + static char name[32] = "Label1"; + char buf[64]; sprintf(buf, "Button: %s###Button", name); // ### operator override ID ignoring the preceding label + ImGui::Button(buf); + if (ImGui::BeginPopupContextItem()) // When used after an item that has an ID (here the Button), we can skip providing an ID to BeginPopupContextItem(). + { + ImGui::Text("Edit name:"); + ImGui::InputText("##edit", name, IM_ARRAYSIZE(name)); + if (ImGui::Button("Close")) + ImGui::CloseCurrentPopup(); + ImGui::EndPopup(); + } + ImGui::SameLine(); ImGui::Text("(<-- right-click here)"); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Modals")) + { + ImGui::TextWrapped("Modal windows are like popups but the user cannot close them by clicking outside the window."); + + if (ImGui::Button("Delete..")) + ImGui::OpenPopup("Delete?"); + if (ImGui::BeginPopupModal("Delete?", NULL, ImGuiWindowFlags_AlwaysAutoResize)) + { + ImGui::Text("All those beautiful files will be deleted.\nThis operation cannot be undone!\n\n"); + ImGui::Separator(); + + //static int dummy_i = 0; + //ImGui::Combo("Combo", &dummy_i, "Delete\0Delete harder\0"); + + static bool dont_ask_me_next_time = false; + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0)); + ImGui::Checkbox("Don't ask me next time", &dont_ask_me_next_time); + ImGui::PopStyleVar(); + + if (ImGui::Button("OK", ImVec2(120,0))) { ImGui::CloseCurrentPopup(); } + ImGui::SameLine(); + if (ImGui::Button("Cancel", ImVec2(120,0))) { ImGui::CloseCurrentPopup(); } + ImGui::EndPopup(); + } + + if (ImGui::Button("Stacked modals..")) + ImGui::OpenPopup("Stacked 1"); + if (ImGui::BeginPopupModal("Stacked 1")) + { + ImGui::Text("Hello from Stacked The First\nUsing style.Colors[ImGuiCol_ModalWindowDarkening] for darkening."); + static int item = 1; + ImGui::Combo("Combo", &item, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0"); + static float color[4] = { 0.4f,0.7f,0.0f,0.5f }; + ImGui::ColorEdit4("color", color); // This is to test behavior of stacked regular popups over a modal + + if (ImGui::Button("Add another modal..")) + ImGui::OpenPopup("Stacked 2"); + if (ImGui::BeginPopupModal("Stacked 2")) + { + ImGui::Text("Hello from Stacked The Second!"); + if (ImGui::Button("Close")) + ImGui::CloseCurrentPopup(); + ImGui::EndPopup(); + } + + if (ImGui::Button("Close")) + ImGui::CloseCurrentPopup(); + ImGui::EndPopup(); + } + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Menus inside a regular window")) + { + ImGui::TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!"); + ImGui::Separator(); + // NB: As a quirk in this very specific example, we want to differentiate the parent of this menu from the parent of the various popup menus above. + // To do so we are encloding the items in a PushID()/PopID() block to make them two different menusets. If we don't, opening any popup above and hovering our menu here + // would open it. This is because once a menu is active, we allow to switch to a sibling menu by just hovering on it, which is the desired behavior for regular menus. + ImGui::PushID("foo"); + ImGui::MenuItem("Menu item", "CTRL+M"); + if (ImGui::BeginMenu("Menu inside a regular window")) + { + ShowExampleMenuFile(); + ImGui::EndMenu(); + } + ImGui::PopID(); + ImGui::Separator(); + ImGui::TreePop(); + } + } + + if (ImGui::CollapsingHeader("Columns")) + { + ImGui::PushID("Columns"); + + // Basic columns + if (ImGui::TreeNode("Basic")) + { + ImGui::Text("Without border:"); + ImGui::Columns(3, "mycolumns3", false); // 3-ways, no border + ImGui::Separator(); + for (int n = 0; n < 14; n++) + { + char label[32]; + sprintf(label, "Item %d", n); + if (ImGui::Selectable(label)) {} + //if (ImGui::Button(label, ImVec2(-1,0))) {} + ImGui::NextColumn(); + } + ImGui::Columns(1); + ImGui::Separator(); + + ImGui::Text("With border:"); + ImGui::Columns(4, "mycolumns"); // 4-ways, with border + ImGui::Separator(); + ImGui::Text("ID"); ImGui::NextColumn(); + ImGui::Text("Name"); ImGui::NextColumn(); + ImGui::Text("Path"); ImGui::NextColumn(); + ImGui::Text("Hovered"); ImGui::NextColumn(); + ImGui::Separator(); + const char* names[3] = { "One", "Two", "Three" }; + const char* paths[3] = { "/path/one", "/path/two", "/path/three" }; + static int selected = -1; + for (int i = 0; i < 3; i++) + { + char label[32]; + sprintf(label, "%04d", i); + if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns)) + selected = i; + bool hovered = ImGui::IsItemHovered(); + ImGui::NextColumn(); + ImGui::Text(names[i]); ImGui::NextColumn(); + ImGui::Text(paths[i]); ImGui::NextColumn(); + ImGui::Text("%d", hovered); ImGui::NextColumn(); + } + ImGui::Columns(1); + ImGui::Separator(); + ImGui::TreePop(); + } + + // Create multiple items in a same cell before switching to next column + if (ImGui::TreeNode("Mixed items")) + { + ImGui::Columns(3, "mixed"); + ImGui::Separator(); + + ImGui::Text("Hello"); + ImGui::Button("Banana"); + ImGui::NextColumn(); + + ImGui::Text("ImGui"); + ImGui::Button("Apple"); + static float foo = 1.0f; + ImGui::InputFloat("red", &foo, 0.05f, 0, 3); + ImGui::Text("An extra line here."); + ImGui::NextColumn(); + + ImGui::Text("Sailor"); + ImGui::Button("Corniflower"); + static float bar = 1.0f; + ImGui::InputFloat("blue", &bar, 0.05f, 0, 3); + ImGui::NextColumn(); + + if (ImGui::CollapsingHeader("Category A")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn(); + if (ImGui::CollapsingHeader("Category B")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn(); + if (ImGui::CollapsingHeader("Category C")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn(); + ImGui::Columns(1); + ImGui::Separator(); + ImGui::TreePop(); + } + + // Word wrapping + if (ImGui::TreeNode("Word-wrapping")) + { + ImGui::Columns(2, "word-wrapping"); + ImGui::Separator(); + ImGui::TextWrapped("The quick brown fox jumps over the lazy dog."); + ImGui::TextWrapped("Hello Left"); + ImGui::NextColumn(); + ImGui::TextWrapped("The quick brown fox jumps over the lazy dog."); + ImGui::TextWrapped("Hello Right"); + ImGui::Columns(1); + ImGui::Separator(); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Borders")) + { + // NB: Future columns API should allow automatic horizontal borders. + static bool h_borders = true; + static bool v_borders = true; + ImGui::Checkbox("horizontal", &h_borders); + ImGui::SameLine(); + ImGui::Checkbox("vertical", &v_borders); + ImGui::Columns(4, NULL, v_borders); + for (int i = 0; i < 4*3; i++) + { + if (h_borders && ImGui::GetColumnIndex() == 0) + ImGui::Separator(); + ImGui::Text("%c%c%c", 'a'+i, 'a'+i, 'a'+i); + ImGui::Text("Width %.2f\nOffset %.2f", ImGui::GetColumnWidth(), ImGui::GetColumnOffset()); + ImGui::NextColumn(); + } + ImGui::Columns(1); + if (h_borders) + ImGui::Separator(); + ImGui::TreePop(); + } + + // Scrolling columns + /* + if (ImGui::TreeNode("Vertical Scrolling")) + { + ImGui::BeginChild("##header", ImVec2(0, ImGui::GetTextLineHeightWithSpacing()+ImGui::GetStyle().ItemSpacing.y)); + ImGui::Columns(3); + ImGui::Text("ID"); ImGui::NextColumn(); + ImGui::Text("Name"); ImGui::NextColumn(); + ImGui::Text("Path"); ImGui::NextColumn(); + ImGui::Columns(1); + ImGui::Separator(); + ImGui::EndChild(); + ImGui::BeginChild("##scrollingregion", ImVec2(0, 60)); + ImGui::Columns(3); + for (int i = 0; i < 10; i++) + { + ImGui::Text("%04d", i); ImGui::NextColumn(); + ImGui::Text("Foobar"); ImGui::NextColumn(); + ImGui::Text("/path/foobar/%04d/", i); ImGui::NextColumn(); + } + ImGui::Columns(1); + ImGui::EndChild(); + ImGui::TreePop(); + } + */ + + if (ImGui::TreeNode("Horizontal Scrolling")) + { + ImGui::SetNextWindowContentSize(ImVec2(1500.0f, 0.0f)); + ImGui::BeginChild("##ScrollingRegion", ImVec2(0, ImGui::GetFontSize() * 20), false, ImGuiWindowFlags_HorizontalScrollbar); + ImGui::Columns(10); + int ITEMS_COUNT = 2000; + ImGuiListClipper clipper(ITEMS_COUNT); // Also demonstrate using the clipper for large list + while (clipper.Step()) + { + for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) + for (int j = 0; j < 10; j++) + { + ImGui::Text("Line %d Column %d...", i, j); + ImGui::NextColumn(); + } + } + ImGui::Columns(1); + ImGui::EndChild(); + ImGui::TreePop(); + } + + bool node_open = ImGui::TreeNode("Tree within single cell"); + ImGui::SameLine(); ShowHelpMarker("NB: Tree node must be poped before ending the cell. There's no storage of state per-cell."); + if (node_open) + { + ImGui::Columns(2, "tree items"); + ImGui::Separator(); + if (ImGui::TreeNode("Hello")) { ImGui::BulletText("Sailor"); ImGui::TreePop(); } ImGui::NextColumn(); + if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Marin"); ImGui::TreePop(); } ImGui::NextColumn(); + ImGui::Columns(1); + ImGui::Separator(); + ImGui::TreePop(); + } + ImGui::PopID(); + } + + if (ImGui::CollapsingHeader("Filtering")) + { + static ImGuiTextFilter filter; + ImGui::Text("Filter usage:\n" + " \"\" display all lines\n" + " \"xxx\" display lines containing \"xxx\"\n" + " \"xxx,yyy\" display lines containing \"xxx\" or \"yyy\"\n" + " \"-xxx\" hide lines containing \"xxx\""); + filter.Draw(); + const char* lines[] = { "aaa1.c", "bbb1.c", "ccc1.c", "aaa2.cpp", "bbb2.cpp", "ccc2.cpp", "abc.h", "hello, world" }; + for (int i = 0; i < IM_ARRAYSIZE(lines); i++) + if (filter.PassFilter(lines[i])) + ImGui::BulletText("%s", lines[i]); + } + + if (ImGui::CollapsingHeader("Inputs & Focus")) + { + ImGuiIO& io = ImGui::GetIO(); + ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor); + ImGui::SameLine(); ShowHelpMarker("Request ImGui to render a mouse cursor for you in software. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something)."); + + ImGui::Text("WantCaptureMouse: %d", io.WantCaptureMouse); + ImGui::Text("WantCaptureKeyboard: %d", io.WantCaptureKeyboard); + ImGui::Text("WantTextInput: %d", io.WantTextInput); + ImGui::Text("WantMoveMouse: %d", io.WantMoveMouse); + + if (ImGui::TreeNode("Keyboard & Mouse State")) + { + if (ImGui::IsMousePosValid()) + ImGui::Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y); + else + ImGui::Text("Mouse pos: "); + ImGui::Text("Mouse down:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (io.MouseDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]); } + ImGui::Text("Mouse clicked:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); } + ImGui::Text("Mouse dbl-clicked:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseDoubleClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); } + ImGui::Text("Mouse released:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseReleased(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); } + ImGui::Text("Mouse wheel: %.1f", io.MouseWheel); + + ImGui::Text("Keys down:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (io.KeysDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("%d (%.02f secs)", i, io.KeysDownDuration[i]); } + ImGui::Text("Keys pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyPressed(i)) { ImGui::SameLine(); ImGui::Text("%d", i); } + ImGui::Text("Keys release:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyReleased(i)) { ImGui::SameLine(); ImGui::Text("%d", i); } + ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : ""); + + + ImGui::Button("Hovering me sets the\nkeyboard capture flag"); + if (ImGui::IsItemHovered()) + ImGui::CaptureKeyboardFromApp(true); + ImGui::SameLine(); + ImGui::Button("Holding me clears the\nthe keyboard capture flag"); + if (ImGui::IsItemActive()) + ImGui::CaptureKeyboardFromApp(false); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Tabbing")) + { + ImGui::Text("Use TAB/SHIFT+TAB to cycle through keyboard editable fields."); + static char buf[32] = "dummy"; + ImGui::InputText("1", buf, IM_ARRAYSIZE(buf)); + ImGui::InputText("2", buf, IM_ARRAYSIZE(buf)); + ImGui::InputText("3", buf, IM_ARRAYSIZE(buf)); + ImGui::PushAllowKeyboardFocus(false); + ImGui::InputText("4 (tab skip)", buf, IM_ARRAYSIZE(buf)); + //ImGui::SameLine(); ShowHelperMarker("Use ImGui::PushAllowKeyboardFocus(bool)\nto disable tabbing through certain widgets."); + ImGui::PopAllowKeyboardFocus(); + ImGui::InputText("5", buf, IM_ARRAYSIZE(buf)); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Focus from code")) + { + bool focus_1 = ImGui::Button("Focus on 1"); ImGui::SameLine(); + bool focus_2 = ImGui::Button("Focus on 2"); ImGui::SameLine(); + bool focus_3 = ImGui::Button("Focus on 3"); + int has_focus = 0; + static char buf[128] = "click on a button to set focus"; + + if (focus_1) ImGui::SetKeyboardFocusHere(); + ImGui::InputText("1", buf, IM_ARRAYSIZE(buf)); + if (ImGui::IsItemActive()) has_focus = 1; + + if (focus_2) ImGui::SetKeyboardFocusHere(); + ImGui::InputText("2", buf, IM_ARRAYSIZE(buf)); + if (ImGui::IsItemActive()) has_focus = 2; + + ImGui::PushAllowKeyboardFocus(false); + if (focus_3) ImGui::SetKeyboardFocusHere(); + ImGui::InputText("3 (tab skip)", buf, IM_ARRAYSIZE(buf)); + if (ImGui::IsItemActive()) has_focus = 3; + ImGui::PopAllowKeyboardFocus(); + + if (has_focus) + ImGui::Text("Item with focus: %d", has_focus); + else + ImGui::Text("Item with focus: "); + ImGui::TextWrapped("Cursor & selection are preserved when refocusing last used item in code."); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Focused & Hovered Test")) + { + static bool embed_all_inside_a_child_window = false; + ImGui::Checkbox("Embed everything inside a child window (for additional testing)", &embed_all_inside_a_child_window); + if (embed_all_inside_a_child_window) + ImGui::BeginChild("embeddingchild", ImVec2(0, ImGui::GetFontSize() * 25), true); + + // Testing IsWindowFocused() function with its various flags (note that the flags can be combined) + ImGui::BulletText( + "IsWindowFocused() = %d\n" + "IsWindowFocused(_ChildWindows) = %d\n" + "IsWindowFocused(_ChildWindows|_RootWindow) = %d\n" + "IsWindowFocused(_RootWindow) = %d\n" + "IsWindowFocused(_AnyWindow) = %d\n", + ImGui::IsWindowFocused(), + ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows), + ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow), + ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow), + ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow)); + + // Testing IsWindowHovered() function with its various flags (note that the flags can be combined) + ImGui::BulletText( + "IsWindowHovered() = %d\n" + "IsWindowHovered(_AllowWhenBlockedByPopup) = %d\n" + "IsWindowHovered(_AllowWhenBlockedByActiveItem) = %d\n" + "IsWindowHovered(_ChildWindows) = %d\n" + "IsWindowHovered(_ChildWindows|_RootWindow) = %d\n" + "IsWindowHovered(_RootWindow) = %d\n" + "IsWindowHovered(_AnyWindow) = %d\n", + ImGui::IsWindowHovered(), + ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup), + ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem), + ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows), + ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow), + ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow), + ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow)); + + // Testing IsItemHovered() function (because BulletText is an item itself and that would affect the output of IsItemHovered, we pass all lines in a single items to shorten the code) + ImGui::Button("ITEM"); + ImGui::BulletText( + "IsItemHovered() = %d\n" + "IsItemHovered(_AllowWhenBlockedByPopup) = %d\n" + "IsItemHovered(_AllowWhenBlockedByActiveItem) = %d\n" + "IsItemHovered(_AllowWhenOverlapped) = %d\n" + "IsItemhovered(_RectOnly) = %d\n", + ImGui::IsItemHovered(), + ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup), + ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem), + ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenOverlapped), + ImGui::IsItemHovered(ImGuiHoveredFlags_RectOnly)); + + ImGui::BeginChild("child", ImVec2(0,50), true); + ImGui::Text("This is another child window for testing IsWindowHovered() flags."); + ImGui::EndChild(); + + if (embed_all_inside_a_child_window) + EndChild(); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Dragging")) + { + ImGui::TextWrapped("You can use ImGui::GetMouseDragDelta(0) to query for the dragged amount on any widget."); + for (int button = 0; button < 3; button++) + ImGui::Text("IsMouseDragging(%d):\n w/ default threshold: %d,\n w/ zero threshold: %d\n w/ large threshold: %d", + button, ImGui::IsMouseDragging(button), ImGui::IsMouseDragging(button, 0.0f), ImGui::IsMouseDragging(button, 20.0f)); + ImGui::Button("Drag Me"); + if (ImGui::IsItemActive()) + { + // Draw a line between the button and the mouse cursor + ImDrawList* draw_list = ImGui::GetWindowDrawList(); + draw_list->PushClipRectFullScreen(); + draw_list->AddLine(io.MouseClickedPos[0], io.MousePos, ImGui::GetColorU32(ImGuiCol_Button), 4.0f); + draw_list->PopClipRect(); + + // Drag operations gets "unlocked" when the mouse has moved past a certain threshold (the default threshold is stored in io.MouseDragThreshold) + // You can request a lower or higher threshold using the second parameter of IsMouseDragging() and GetMouseDragDelta() + ImVec2 value_raw = ImGui::GetMouseDragDelta(0, 0.0f); + ImVec2 value_with_lock_threshold = ImGui::GetMouseDragDelta(0); + ImVec2 mouse_delta = io.MouseDelta; + ImGui::SameLine(); ImGui::Text("Raw (%.1f, %.1f), WithLockThresold (%.1f, %.1f), MouseDelta (%.1f, %.1f)", value_raw.x, value_raw.y, value_with_lock_threshold.x, value_with_lock_threshold.y, mouse_delta.x, mouse_delta.y); + } + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Mouse cursors")) + { + const char* mouse_cursors_names[] = { "Arrow", "TextInput", "Move", "ResizeNS", "ResizeEW", "ResizeNESW", "ResizeNWSE" }; + IM_ASSERT(IM_ARRAYSIZE(mouse_cursors_names) == ImGuiMouseCursor_Count_); + + ImGui::Text("Current mouse cursor = %d: %s", ImGui::GetMouseCursor(), mouse_cursors_names[ImGui::GetMouseCursor()]); + ImGui::Text("Hover to see mouse cursors:"); + ImGui::SameLine(); ShowHelpMarker("Your application can render a different mouse cursor based on what ImGui::GetMouseCursor() returns. If software cursor rendering (io.MouseDrawCursor) is set ImGui will draw the right cursor for you, otherwise your backend needs to handle it."); + for (int i = 0; i < ImGuiMouseCursor_Count_; i++) + { + char label[32]; + sprintf(label, "Mouse cursor %d: %s", i, mouse_cursors_names[i]); + ImGui::Bullet(); ImGui::Selectable(label, false); + if (ImGui::IsItemHovered()) + ImGui::SetMouseCursor(i); + } + ImGui::TreePop(); + } + } + + ImGui::End(); +} + +// Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options. +// Here we use the simplified Combo() api that packs items into a single literal string. Useful for quick combo boxes where the choices are known locally. +bool ImGui::ShowStyleSelector(const char* label) +{ + static int style_idx = 0; + if (ImGui::Combo(label, &style_idx, "Classic\0Dark\0Light\0")) + { + switch (style_idx) + { + case 0: ImGui::StyleColorsClassic(); break; + case 1: ImGui::StyleColorsDark(); break; + case 2: ImGui::StyleColorsLight(); break; + } + return true; + } + return false; +} + +// Demo helper function to select among loaded fonts. +// Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one. +void ImGui::ShowFontSelector(const char* label) +{ + ImGuiIO& io = ImGui::GetIO(); + ImFont* font_current = ImGui::GetFont(); + if (ImGui::BeginCombo(label, font_current->GetDebugName())) + { + for (int n = 0; n < io.Fonts->Fonts.Size; n++) + if (ImGui::Selectable(io.Fonts->Fonts[n]->GetDebugName(), io.Fonts->Fonts[n] == font_current)) + io.FontDefault = io.Fonts->Fonts[n]; + ImGui::EndCombo(); + } + ImGui::SameLine(); + ShowHelpMarker( + "- Load additional fonts with io.Fonts->AddFontFromFileTTF().\n" + "- The font atlas is built when calling io.Fonts->GetTexDataAsXXXX() or io.Fonts->Build().\n" + "- Read FAQ and documentation in extra_fonts/ for more details.\n" + "- If you need to add/remove fonts at runtime (e.g. for DPI change), do it before calling NewFrame()."); +} + +void ImGui::ShowStyleEditor(ImGuiStyle* ref) +{ + // You can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it compares to an internally stored reference) + ImGuiStyle& style = ImGui::GetStyle(); + static ImGuiStyle ref_saved_style; + + // Default to using internal storage as reference + static bool init = true; + if (init && ref == NULL) + ref_saved_style = style; + init = false; + if (ref == NULL) + ref = &ref_saved_style; + + ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.50f); + + if (ImGui::ShowStyleSelector("Colors##Selector")) + ref_saved_style = style; + ImGui::ShowFontSelector("Fonts##Selector"); + + // Simplified Settings + if (ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f")) + style.GrabRounding = style.FrameRounding; // Make GrabRounding always the same value as FrameRounding + { bool window_border = (style.WindowBorderSize > 0.0f); if (ImGui::Checkbox("WindowBorder", &window_border)) style.WindowBorderSize = window_border ? 1.0f : 0.0f; } + ImGui::SameLine(); + { bool frame_border = (style.FrameBorderSize > 0.0f); if (ImGui::Checkbox("FrameBorder", &frame_border)) style.FrameBorderSize = frame_border ? 1.0f : 0.0f; } + ImGui::SameLine(); + { bool popup_border = (style.PopupBorderSize > 0.0f); if (ImGui::Checkbox("PopupBorder", &popup_border)) style.PopupBorderSize = popup_border ? 1.0f : 0.0f; } + + // Save/Revert button + if (ImGui::Button("Save Ref")) + *ref = ref_saved_style = style; + ImGui::SameLine(); + if (ImGui::Button("Revert Ref")) + style = *ref; + ImGui::SameLine(); + ShowHelpMarker("Save/Revert in local non-persistent storage. Default Colors definition are not affected. Use \"Export Colors\" below to save them somewhere."); + + if (ImGui::TreeNode("Rendering")) + { + ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines); ImGui::SameLine(); ShowHelpMarker("When disabling anti-aliasing lines, you'll probably want to disable borders in your style as well."); + ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill); + ImGui::PushItemWidth(100); + ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, NULL, 2.0f); + if (style.CurveTessellationTol < 0.0f) style.CurveTessellationTol = 0.10f; + ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero. + ImGui::PopItemWidth(); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Settings")) + { + ImGui::SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 16.0f, "%.0f"); + ImGui::SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2("ItemSpacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f"); + ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f"); + ImGui::SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f"); + ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f"); + ImGui::Text("BorderSize"); + ImGui::SliderFloat("WindowBorderSize", &style.WindowBorderSize, 0.0f, 1.0f, "%.0f"); + ImGui::SliderFloat("ChildBorderSize", &style.ChildBorderSize, 0.0f, 1.0f, "%.0f"); + ImGui::SliderFloat("PopupBorderSize", &style.PopupBorderSize, 0.0f, 1.0f, "%.0f"); + ImGui::SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f, "%.0f"); + ImGui::Text("Rounding"); + ImGui::SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 14.0f, "%.0f"); + ImGui::SliderFloat("ChildRounding", &style.ChildRounding, 0.0f, 16.0f, "%.0f"); + ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f"); + ImGui::Text("Alignment"); + ImGui::SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f"); + ImGui::SliderFloat2("ButtonTextAlign", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f"); ImGui::SameLine(); ShowHelpMarker("Alignment applies when a button is larger than its text content."); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Colors")) + { + static int output_dest = 0; + static bool output_only_modified = true; + if (ImGui::Button("Export Unsaved")) + { + if (output_dest == 0) + ImGui::LogToClipboard(); + else + ImGui::LogToTTY(); + ImGui::LogText("ImVec4* colors = ImGui::GetStyle().Colors;" IM_NEWLINE); + for (int i = 0; i < ImGuiCol_COUNT; i++) + { + const ImVec4& col = style.Colors[i]; + const char* name = ImGui::GetStyleColorName(i); + if (!output_only_modified || memcmp(&col, &ref->Colors[i], sizeof(ImVec4)) != 0) + ImGui::LogText("colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 23-(int)strlen(name), "", col.x, col.y, col.z, col.w); + } + ImGui::LogFinish(); + } + ImGui::SameLine(); ImGui::PushItemWidth(120); ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0"); ImGui::PopItemWidth(); + ImGui::SameLine(); ImGui::Checkbox("Only Modified Colors", &output_only_modified); + + ImGui::Text("Tip: Left-click on colored square to open color picker,\nRight-click to open edit options menu."); + + static ImGuiTextFilter filter; + filter.Draw("Filter colors", 200); + + static ImGuiColorEditFlags alpha_flags = 0; + ImGui::RadioButton("Opaque", &alpha_flags, 0); ImGui::SameLine(); + ImGui::RadioButton("Alpha", &alpha_flags, ImGuiColorEditFlags_AlphaPreview); ImGui::SameLine(); + ImGui::RadioButton("Both", &alpha_flags, ImGuiColorEditFlags_AlphaPreviewHalf); + + ImGui::BeginChild("#colors", ImVec2(0, 300), true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar); + ImGui::PushItemWidth(-160); + for (int i = 0; i < ImGuiCol_COUNT; i++) + { + const char* name = ImGui::GetStyleColorName(i); + if (!filter.PassFilter(name)) + continue; + ImGui::PushID(i); + ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags); + if (memcmp(&style.Colors[i], &ref->Colors[i], sizeof(ImVec4)) != 0) + { + // Tips: in a real user application, you may want to merge and use an icon font into the main font, so instead of "Save"/"Revert" you'd use icons. + // Read the FAQ and extra_fonts/README.txt about using icon fonts. It's really easy and super convenient! + ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Save")) ref->Colors[i] = style.Colors[i]; + ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Revert")) style.Colors[i] = ref->Colors[i]; + } + ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); + ImGui::TextUnformatted(name); + ImGui::PopID(); + } + ImGui::PopItemWidth(); + ImGui::EndChild(); + + ImGui::TreePop(); + } + + bool fonts_opened = ImGui::TreeNode("Fonts", "Fonts (%d)", ImGui::GetIO().Fonts->Fonts.Size); + if (fonts_opened) + { + ImFontAtlas* atlas = ImGui::GetIO().Fonts; + if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight)) + { + ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0,0), ImVec2(1,1), ImColor(255,255,255,255), ImColor(255,255,255,128)); + ImGui::TreePop(); + } + ImGui::PushItemWidth(100); + for (int i = 0; i < atlas->Fonts.Size; i++) + { + ImFont* font = atlas->Fonts[i]; + ImGui::PushID(font); + bool font_details_opened = ImGui::TreeNode(font, "Font %d: \'%s\', %.2f px, %d glyphs", i, font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size); + ImGui::SameLine(); if (ImGui::SmallButton("set as default")) ImGui::GetIO().FontDefault = font; + if (font_details_opened) + { + ImGui::PushFont(font); + ImGui::Text("The quick brown fox jumps over the lazy dog"); + ImGui::PopFont(); + ImGui::DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); // Scale only this font + ImGui::SameLine(); ShowHelpMarker("Note than the default embedded font is NOT meant to be scaled.\n\nFont are currently rendered into bitmaps at a given size at the time of building the atlas. You may oversample them to get some flexibility with scaling. You can also render at multiple sizes and select which one to use at runtime.\n\n(Glimmer of hope: the atlas system should hopefully be rewritten in the future to make scaling more natural and automatic.)"); + ImGui::Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent); + ImGui::Text("Fallback character: '%c' (%d)", font->FallbackChar, font->FallbackChar); + ImGui::Text("Texture surface: %d pixels (approx) ~ %dx%d", font->MetricsTotalSurface, (int)sqrtf((float)font->MetricsTotalSurface), (int)sqrtf((float)font->MetricsTotalSurface)); + for (int config_i = 0; config_i < font->ConfigDataCount; config_i++) + { + ImFontConfig* cfg = &font->ConfigData[config_i]; + ImGui::BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d", config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH); + } + if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size)) + { + // Display all glyphs of the fonts in separate pages of 256 characters + const ImFontGlyph* glyph_fallback = font->FallbackGlyph; // Forcefully/dodgily make FindGlyph() return NULL on fallback, which isn't the default behavior. + font->FallbackGlyph = NULL; + for (int base = 0; base < 0x10000; base += 256) + { + int count = 0; + for (int n = 0; n < 256; n++) + count += font->FindGlyph((ImWchar)(base + n)) ? 1 : 0; + if (count > 0 && ImGui::TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base+255, count, count > 1 ? "glyphs" : "glyph")) + { + float cell_spacing = style.ItemSpacing.y; + ImVec2 cell_size(font->FontSize * 1, font->FontSize * 1); + ImVec2 base_pos = ImGui::GetCursorScreenPos(); + ImDrawList* draw_list = ImGui::GetWindowDrawList(); + for (int n = 0; n < 256; n++) + { + ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size.x + cell_spacing), base_pos.y + (n / 16) * (cell_size.y + cell_spacing)); + ImVec2 cell_p2(cell_p1.x + cell_size.x, cell_p1.y + cell_size.y); + const ImFontGlyph* glyph = font->FindGlyph((ImWchar)(base+n));; + draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255,255,255,100) : IM_COL32(255,255,255,50)); + font->RenderChar(draw_list, cell_size.x, cell_p1, ImGui::GetColorU32(ImGuiCol_Text), (ImWchar)(base+n)); // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions available to generate a string. + if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2)) + { + ImGui::BeginTooltip(); + ImGui::Text("Codepoint: U+%04X", base+n); + ImGui::Separator(); + ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX); + ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1); + ImGui::Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1); + ImGui::EndTooltip(); + } + } + ImGui::Dummy(ImVec2((cell_size.x + cell_spacing) * 16, (cell_size.y + cell_spacing) * 16)); + ImGui::TreePop(); + } + } + font->FallbackGlyph = glyph_fallback; + ImGui::TreePop(); + } + ImGui::TreePop(); + } + ImGui::PopID(); + } + static float window_scale = 1.0f; + ImGui::DragFloat("this window scale", &window_scale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale only this window + ImGui::DragFloat("global scale", &ImGui::GetIO().FontGlobalScale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale everything + ImGui::PopItemWidth(); + ImGui::SetWindowFontScale(window_scale); + ImGui::TreePop(); + } + + ImGui::PopItemWidth(); +} + +// Demonstrate creating a fullscreen menu bar and populating it. +static void ShowExampleAppMainMenuBar() +{ + if (ImGui::BeginMainMenuBar()) + { + if (ImGui::BeginMenu("File")) + { + ShowExampleMenuFile(); + ImGui::EndMenu(); + } + if (ImGui::BeginMenu("Edit")) + { + if (ImGui::MenuItem("Undo", "CTRL+Z")) {} + if (ImGui::MenuItem("Redo", "CTRL+Y", false, false)) {} // Disabled item + ImGui::Separator(); + if (ImGui::MenuItem("Cut", "CTRL+X")) {} + if (ImGui::MenuItem("Copy", "CTRL+C")) {} + if (ImGui::MenuItem("Paste", "CTRL+V")) {} + ImGui::EndMenu(); + } + ImGui::EndMainMenuBar(); + } +} + +static void ShowExampleMenuFile() +{ + ImGui::MenuItem("(dummy menu)", NULL, false, false); + if (ImGui::MenuItem("New")) {} + if (ImGui::MenuItem("Open", "Ctrl+O")) {} + if (ImGui::BeginMenu("Open Recent")) + { + ImGui::MenuItem("fish_hat.c"); + ImGui::MenuItem("fish_hat.inl"); + ImGui::MenuItem("fish_hat.h"); + if (ImGui::BeginMenu("More..")) + { + ImGui::MenuItem("Hello"); + ImGui::MenuItem("Sailor"); + if (ImGui::BeginMenu("Recurse..")) + { + ShowExampleMenuFile(); + ImGui::EndMenu(); + } + ImGui::EndMenu(); + } + ImGui::EndMenu(); + } + if (ImGui::MenuItem("Save", "Ctrl+S")) {} + if (ImGui::MenuItem("Save As..")) {} + ImGui::Separator(); + if (ImGui::BeginMenu("Options")) + { + static bool enabled = true; + ImGui::MenuItem("Enabled", "", &enabled); + ImGui::BeginChild("child", ImVec2(0, 60), true); + for (int i = 0; i < 10; i++) + ImGui::Text("Scrolling Text %d", i); + ImGui::EndChild(); + static float f = 0.5f; + static int n = 0; + static bool b = true; + ImGui::SliderFloat("Value", &f, 0.0f, 1.0f); + ImGui::InputFloat("Input", &f, 0.1f); + ImGui::Combo("Combo", &n, "Yes\0No\0Maybe\0\0"); + ImGui::Checkbox("Check", &b); + ImGui::EndMenu(); + } + if (ImGui::BeginMenu("Colors")) + { + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0)); + for (int i = 0; i < ImGuiCol_COUNT; i++) + { + const char* name = ImGui::GetStyleColorName((ImGuiCol)i); + ImGui::ColorButton(name, ImGui::GetStyleColorVec4((ImGuiCol)i)); + ImGui::SameLine(); + ImGui::MenuItem(name); + } + ImGui::PopStyleVar(); + ImGui::EndMenu(); + } + if (ImGui::BeginMenu("Disabled", false)) // Disabled + { + IM_ASSERT(0); + } + if (ImGui::MenuItem("Checked", NULL, true)) {} + if (ImGui::MenuItem("Quit", "Alt+F4")) {} +} + +// Demonstrate creating a window which gets auto-resized according to its content. +static void ShowExampleAppAutoResize(bool* p_open) +{ + if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize)) + { + ImGui::End(); + return; + } + + static int lines = 10; + ImGui::Text("Window will resize every-frame to the size of its content.\nNote that you probably don't want to query the window size to\noutput your content because that would create a feedback loop."); + ImGui::SliderInt("Number of lines", &lines, 1, 20); + for (int i = 0; i < lines; i++) + ImGui::Text("%*sThis is line %d", i*4, "", i); // Pad with space to extend size horizontally + ImGui::End(); +} + +// Demonstrate creating a window with custom resize constraints. +static void ShowExampleAppConstrainedResize(bool* p_open) +{ + struct CustomConstraints // Helper functions to demonstrate programmatic constraints + { + static void Square(ImGuiSizeCallbackData* data) { data->DesiredSize = ImVec2(IM_MAX(data->DesiredSize.x, data->DesiredSize.y), IM_MAX(data->DesiredSize.x, data->DesiredSize.y)); } + static void Step(ImGuiSizeCallbackData* data) { float step = (float)(int)(intptr_t)data->UserData; data->DesiredSize = ImVec2((int)(data->DesiredSize.x / step + 0.5f) * step, (int)(data->DesiredSize.y / step + 0.5f) * step); } + }; + + static bool auto_resize = false; + static int type = 0; + static int display_lines = 10; + if (type == 0) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 0), ImVec2(-1, FLT_MAX)); // Vertical only + if (type == 1) ImGui::SetNextWindowSizeConstraints(ImVec2(0, -1), ImVec2(FLT_MAX, -1)); // Horizontal only + if (type == 2) ImGui::SetNextWindowSizeConstraints(ImVec2(100, 100), ImVec2(FLT_MAX, FLT_MAX)); // Width > 100, Height > 100 + if (type == 3) ImGui::SetNextWindowSizeConstraints(ImVec2(400, -1), ImVec2(500, -1)); // Width 400-500 + if (type == 4) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 400), ImVec2(-1, 500)); // Height 400-500 + if (type == 5) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Square); // Always Square + if (type == 6) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Step, (void*)100);// Fixed Step + + ImGuiWindowFlags flags = auto_resize ? ImGuiWindowFlags_AlwaysAutoResize : 0; + if (ImGui::Begin("Example: Constrained Resize", p_open, flags)) + { + const char* desc[] = + { + "Resize vertical only", + "Resize horizontal only", + "Width > 100, Height > 100", + "Width 400-500", + "Height 400-500", + "Custom: Always Square", + "Custom: Fixed Steps (100)", + }; + if (ImGui::Button("200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine(); + if (ImGui::Button("500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine(); + if (ImGui::Button("800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); } + ImGui::PushItemWidth(200); + ImGui::Combo("Constraint", &type, desc, IM_ARRAYSIZE(desc)); + ImGui::DragInt("Lines", &display_lines, 0.2f, 1, 100); + ImGui::PopItemWidth(); + ImGui::Checkbox("Auto-resize", &auto_resize); + for (int i = 0; i < display_lines; i++) + ImGui::Text("%*sHello, sailor! Making this line long enough for the example.", i * 4, ""); + } + ImGui::End(); +} + +// Demonstrate creating a simple static window with no decoration + a context-menu to choose which corner of the screen to use. +static void ShowExampleAppFixedOverlay(bool* p_open) +{ + const float DISTANCE = 10.0f; + static int corner = 0; + ImVec2 window_pos = ImVec2((corner & 1) ? ImGui::GetIO().DisplaySize.x - DISTANCE : DISTANCE, (corner & 2) ? ImGui::GetIO().DisplaySize.y - DISTANCE : DISTANCE); + ImVec2 window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f); + ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot); + ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); // Transparent background + if (ImGui::Begin("Example: Fixed Overlay", p_open, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoSavedSettings)) + { + ImGui::Text("Simple overlay\nin the corner of the screen.\n(right-click to change position)"); + ImGui::Separator(); + ImGui::Text("Mouse Position: (%.1f,%.1f)", ImGui::GetIO().MousePos.x, ImGui::GetIO().MousePos.y); + if (ImGui::BeginPopupContextWindow()) + { + if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0; + if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1; + if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2; + if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3; + if (p_open && ImGui::MenuItem("Close")) *p_open = false; + ImGui::EndPopup(); + } + ImGui::End(); + } + ImGui::PopStyleColor(); +} + +// Demonstrate using "##" and "###" in identifiers to manipulate ID generation. +// This apply to regular items as well. Read FAQ section "How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on the purpose of labels/IDs." for details. +static void ShowExampleAppWindowTitles(bool*) +{ + // By default, Windows are uniquely identified by their title. + // You can use the "##" and "###" markers to manipulate the display/ID. + + // Using "##" to display same title but have unique identifier. + ImGui::SetNextWindowPos(ImVec2(100,100), ImGuiCond_FirstUseEver); + ImGui::Begin("Same title as another window##1"); + ImGui::Text("This is window 1.\nMy title is the same as window 2, but my identifier is unique."); + ImGui::End(); + + ImGui::SetNextWindowPos(ImVec2(100,200), ImGuiCond_FirstUseEver); + ImGui::Begin("Same title as another window##2"); + ImGui::Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique."); + ImGui::End(); + + // Using "###" to display a changing title but keep a static identifier "AnimatedTitle" + char buf[128]; + sprintf(buf, "Animated title %c %d###AnimatedTitle", "|/-\\"[(int)(ImGui::GetTime()/0.25f)&3], ImGui::GetFrameCount()); + ImGui::SetNextWindowPos(ImVec2(100,300), ImGuiCond_FirstUseEver); + ImGui::Begin(buf); + ImGui::Text("This window has a changing title."); + ImGui::End(); +} + +// Demonstrate using the low-level ImDrawList to draw custom shapes. +static void ShowExampleAppCustomRendering(bool* p_open) +{ + ImGui::SetNextWindowSize(ImVec2(350,560), ImGuiCond_FirstUseEver); + if (!ImGui::Begin("Example: Custom rendering", p_open)) + { + ImGui::End(); + return; + } + + // Tip: If you do a lot of custom rendering, you probably want to use your own geometrical types and benefit of overloaded operators, etc. + // Define IM_VEC2_CLASS_EXTRA in imconfig.h to create implicit conversions between your types and ImVec2/ImVec4. + // ImGui defines overloaded operators but they are internal to imgui.cpp and not exposed outside (to avoid messing with your types) + // In this example we are not using the maths operators! + ImDrawList* draw_list = ImGui::GetWindowDrawList(); + + // Primitives + ImGui::Text("Primitives"); + static float sz = 36.0f; + static ImVec4 col = ImVec4(1.0f,1.0f,0.4f,1.0f); + ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f"); + ImGui::ColorEdit3("Color", &col.x); + { + const ImVec2 p = ImGui::GetCursorScreenPos(); + const ImU32 col32 = ImColor(col); + float x = p.x + 4.0f, y = p.y + 4.0f, spacing = 8.0f; + for (int n = 0; n < 2; n++) + { + float thickness = (n == 0) ? 1.0f : 4.0f; + draw_list->AddCircle(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 20, thickness); x += sz+spacing; + draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 0.0f, ImDrawCornerFlags_All, thickness); x += sz+spacing; + draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_All, thickness); x += sz+spacing; + draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotRight, thickness); x += sz+spacing; + draw_list->AddTriangle(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32, thickness); x += sz+spacing; + draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y ), col32, thickness); x += sz+spacing; + draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, thickness); x += sz+spacing; + draw_list->AddLine(ImVec2(x, y), ImVec2(x, y+sz), col32, thickness); x += spacing; + draw_list->AddBezierCurve(ImVec2(x, y), ImVec2(x+sz*1.3f,y+sz*0.3f), ImVec2(x+sz-sz*1.3f,y+sz-sz*0.3f), ImVec2(x+sz, y+sz), col32, thickness); + x = p.x + 4; + y += sz+spacing; + } + draw_list->AddCircleFilled(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 32); x += sz+spacing; + draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32); x += sz+spacing; + draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f); x += sz+spacing; + draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotRight); x += sz+spacing; + draw_list->AddTriangleFilled(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32); x += sz+spacing; + draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x+sz, y+sz), IM_COL32(0,0,0,255), IM_COL32(255,0,0,255), IM_COL32(255,255,0,255), IM_COL32(0,255,0,255)); + ImGui::Dummy(ImVec2((sz+spacing)*8, (sz+spacing)*3)); + } + ImGui::Separator(); + { + static ImVector points; + static bool adding_line = false; + ImGui::Text("Canvas example"); + if (ImGui::Button("Clear")) points.clear(); + if (points.Size >= 2) { ImGui::SameLine(); if (ImGui::Button("Undo")) { points.pop_back(); points.pop_back(); } } + ImGui::Text("Left-click and drag to add lines,\nRight-click to undo"); + + // Here we are using InvisibleButton() as a convenience to 1) advance the cursor and 2) allows us to use IsItemHovered() + // However you can draw directly and poll mouse/keyboard by yourself. You can manipulate the cursor using GetCursorPos() and SetCursorPos(). + // If you only use the ImDrawList API, you can notify the owner window of its extends by using SetCursorPos(max). + ImVec2 canvas_pos = ImGui::GetCursorScreenPos(); // ImDrawList API uses screen coordinates! + ImVec2 canvas_size = ImGui::GetContentRegionAvail(); // Resize canvas to what's available + if (canvas_size.x < 50.0f) canvas_size.x = 50.0f; + if (canvas_size.y < 50.0f) canvas_size.y = 50.0f; + draw_list->AddRectFilledMultiColor(canvas_pos, ImVec2(canvas_pos.x + canvas_size.x, canvas_pos.y + canvas_size.y), IM_COL32(50,50,50,255), IM_COL32(50,50,60,255), IM_COL32(60,60,70,255), IM_COL32(50,50,60,255)); + draw_list->AddRect(canvas_pos, ImVec2(canvas_pos.x + canvas_size.x, canvas_pos.y + canvas_size.y), IM_COL32(255,255,255,255)); + + bool adding_preview = false; + ImGui::InvisibleButton("canvas", canvas_size); + ImVec2 mouse_pos_in_canvas = ImVec2(ImGui::GetIO().MousePos.x - canvas_pos.x, ImGui::GetIO().MousePos.y - canvas_pos.y); + if (adding_line) + { + adding_preview = true; + points.push_back(mouse_pos_in_canvas); + if (!ImGui::IsMouseDown(0)) + adding_line = adding_preview = false; + } + if (ImGui::IsItemHovered()) + { + if (!adding_line && ImGui::IsMouseClicked(0)) + { + points.push_back(mouse_pos_in_canvas); + adding_line = true; + } + if (ImGui::IsMouseClicked(1) && !points.empty()) + { + adding_line = adding_preview = false; + points.pop_back(); + points.pop_back(); + } + } + draw_list->PushClipRect(canvas_pos, ImVec2(canvas_pos.x+canvas_size.x, canvas_pos.y+canvas_size.y), true); // clip lines within the canvas (if we resize it, etc.) + for (int i = 0; i < points.Size - 1; i += 2) + draw_list->AddLine(ImVec2(canvas_pos.x + points[i].x, canvas_pos.y + points[i].y), ImVec2(canvas_pos.x + points[i+1].x, canvas_pos.y + points[i+1].y), IM_COL32(255,255,0,255), 2.0f); + draw_list->PopClipRect(); + if (adding_preview) + points.pop_back(); + } + ImGui::End(); +} + +// Demonstrating creating a simple console window, with scrolling, filtering, completion and history. +// For the console example, here we are using a more C++ like approach of declaring a class to hold the data and the functions. +struct ExampleAppConsole +{ + char InputBuf[256]; + ImVector Items; + bool ScrollToBottom; + ImVector History; + int HistoryPos; // -1: new line, 0..History.Size-1 browsing history. + ImVector Commands; + + ExampleAppConsole() + { + ClearLog(); + memset(InputBuf, 0, sizeof(InputBuf)); + HistoryPos = -1; + Commands.push_back("HELP"); + Commands.push_back("HISTORY"); + Commands.push_back("CLEAR"); + Commands.push_back("CLASSIFY"); // "classify" is here to provide an example of "C"+[tab] completing to "CL" and displaying matches. + AddLog("Welcome to ImGui!"); + } + ~ExampleAppConsole() + { + ClearLog(); + for (int i = 0; i < History.Size; i++) + free(History[i]); + } + + // Portable helpers + static int Stricmp(const char* str1, const char* str2) { int d; while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; } return d; } + static int Strnicmp(const char* str1, const char* str2, int n) { int d = 0; while (n > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; n--; } return d; } + static char* Strdup(const char *str) { size_t len = strlen(str) + 1; void* buff = malloc(len); return (char*)memcpy(buff, (const void*)str, len); } + + void ClearLog() + { + for (int i = 0; i < Items.Size; i++) + free(Items[i]); + Items.clear(); + ScrollToBottom = true; + } + + void AddLog(const char* fmt, ...) IM_FMTARGS(2) + { + // FIXME-OPT + char buf[1024]; + va_list args; + va_start(args, fmt); + vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args); + buf[IM_ARRAYSIZE(buf)-1] = 0; + va_end(args); + Items.push_back(Strdup(buf)); + ScrollToBottom = true; + } + + void Draw(const char* title, bool* p_open) + { + ImGui::SetNextWindowSize(ImVec2(520,600), ImGuiCond_FirstUseEver); + if (!ImGui::Begin(title, p_open)) + { + ImGui::End(); + return; + } + + // As a specific feature guaranteed by the library, after calling Begin() the last Item represent the title bar. So e.g. IsItemHovered() will return true when hovering the title bar. + // Here we create a context menu only available from the title bar. + if (ImGui::BeginPopupContextItem()) + { + if (ImGui::MenuItem("Close")) + *p_open = false; + ImGui::EndPopup(); + } + + ImGui::TextWrapped("This example implements a console with basic coloring, completion and history. A more elaborate implementation may want to store entries along with extra data such as timestamp, emitter, etc."); + ImGui::TextWrapped("Enter 'HELP' for help, press TAB to use text completion."); + + // TODO: display items starting from the bottom + + if (ImGui::SmallButton("Add Dummy Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } ImGui::SameLine(); + if (ImGui::SmallButton("Add Dummy Error")) { AddLog("[error] something went wrong"); } ImGui::SameLine(); + if (ImGui::SmallButton("Clear")) { ClearLog(); } ImGui::SameLine(); + bool copy_to_clipboard = ImGui::SmallButton("Copy"); ImGui::SameLine(); + if (ImGui::SmallButton("Scroll to bottom")) ScrollToBottom = true; + //static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); } + + ImGui::Separator(); + + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0)); + static ImGuiTextFilter filter; + filter.Draw("Filter (\"incl,-excl\") (\"error\")", 180); + ImGui::PopStyleVar(); + ImGui::Separator(); + + const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); // 1 separator, 1 input text + ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), false, ImGuiWindowFlags_HorizontalScrollbar); // Leave room for 1 separator + 1 InputText + if (ImGui::BeginPopupContextWindow()) + { + if (ImGui::Selectable("Clear")) ClearLog(); + ImGui::EndPopup(); + } + + // Display every line as a separate entry so we can change their color or add custom widgets. If you only want raw text you can use ImGui::TextUnformatted(log.begin(), log.end()); + // NB- if you have thousands of entries this approach may be too inefficient and may require user-side clipping to only process visible items. + // You can seek and display only the lines that are visible using the ImGuiListClipper helper, if your elements are evenly spaced and you have cheap random access to the elements. + // To use the clipper we could replace the 'for (int i = 0; i < Items.Size; i++)' loop with: + // ImGuiListClipper clipper(Items.Size); + // while (clipper.Step()) + // for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) + // However take note that you can not use this code as is if a filter is active because it breaks the 'cheap random-access' property. We would need random-access on the post-filtered list. + // A typical application wanting coarse clipping and filtering may want to pre-compute an array of indices that passed the filtering test, recomputing this array when user changes the filter, + // and appending newly elements as they are inserted. This is left as a task to the user until we can manage to improve this example code! + // If your items are of variable size you may want to implement code similar to what ImGuiListClipper does. Or split your data into fixed height items to allow random-seeking into your list. + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4,1)); // Tighten spacing + if (copy_to_clipboard) + ImGui::LogToClipboard(); + ImVec4 col_default_text = ImGui::GetStyleColorVec4(ImGuiCol_Text); + for (int i = 0; i < Items.Size; i++) + { + const char* item = Items[i]; + if (!filter.PassFilter(item)) + continue; + ImVec4 col = col_default_text; + if (strstr(item, "[error]")) col = ImColor(1.0f,0.4f,0.4f,1.0f); + else if (strncmp(item, "# ", 2) == 0) col = ImColor(1.0f,0.78f,0.58f,1.0f); + ImGui::PushStyleColor(ImGuiCol_Text, col); + ImGui::TextUnformatted(item); + ImGui::PopStyleColor(); + } + if (copy_to_clipboard) + ImGui::LogFinish(); + if (ScrollToBottom) + ImGui::SetScrollHere(); + ScrollToBottom = false; + ImGui::PopStyleVar(); + ImGui::EndChild(); + ImGui::Separator(); + + // Command-line + if (ImGui::InputText("Input", InputBuf, IM_ARRAYSIZE(InputBuf), ImGuiInputTextFlags_EnterReturnsTrue|ImGuiInputTextFlags_CallbackCompletion|ImGuiInputTextFlags_CallbackHistory, &TextEditCallbackStub, (void*)this)) + { + char* input_end = InputBuf+strlen(InputBuf); + while (input_end > InputBuf && input_end[-1] == ' ') { input_end--; } *input_end = 0; + if (InputBuf[0]) + ExecCommand(InputBuf); + strcpy(InputBuf, ""); + } + + // Demonstrate keeping auto focus on the input box + if (ImGui::IsItemHovered() || (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) && !ImGui::IsAnyItemActive() && !ImGui::IsMouseClicked(0))) + ImGui::SetKeyboardFocusHere(-1); // Auto focus previous widget + + ImGui::End(); + } + + void ExecCommand(const char* command_line) + { + AddLog("# %s\n", command_line); + + // Insert into history. First find match and delete it so it can be pushed to the back. This isn't trying to be smart or optimal. + HistoryPos = -1; + for (int i = History.Size-1; i >= 0; i--) + if (Stricmp(History[i], command_line) == 0) + { + free(History[i]); + History.erase(History.begin() + i); + break; + } + History.push_back(Strdup(command_line)); + + // Process command + if (Stricmp(command_line, "CLEAR") == 0) + { + ClearLog(); + } + else if (Stricmp(command_line, "HELP") == 0) + { + AddLog("Commands:"); + for (int i = 0; i < Commands.Size; i++) + AddLog("- %s", Commands[i]); + } + else if (Stricmp(command_line, "HISTORY") == 0) + { + int first = History.Size - 10; + for (int i = first > 0 ? first : 0; i < History.Size; i++) + AddLog("%3d: %s\n", i, History[i]); + } + else + { + AddLog("Unknown command: '%s'\n", command_line); + } + } + + static int TextEditCallbackStub(ImGuiTextEditCallbackData* data) // In C++11 you are better off using lambdas for this sort of forwarding callbacks + { + ExampleAppConsole* console = (ExampleAppConsole*)data->UserData; + return console->TextEditCallback(data); + } + + int TextEditCallback(ImGuiTextEditCallbackData* data) + { + //AddLog("cursor: %d, selection: %d-%d", data->CursorPos, data->SelectionStart, data->SelectionEnd); + switch (data->EventFlag) + { + case ImGuiInputTextFlags_CallbackCompletion: + { + // Example of TEXT COMPLETION + + // Locate beginning of current word + const char* word_end = data->Buf + data->CursorPos; + const char* word_start = word_end; + while (word_start > data->Buf) + { + const char c = word_start[-1]; + if (c == ' ' || c == '\t' || c == ',' || c == ';') + break; + word_start--; + } + + // Build a list of candidates + ImVector candidates; + for (int i = 0; i < Commands.Size; i++) + if (Strnicmp(Commands[i], word_start, (int)(word_end-word_start)) == 0) + candidates.push_back(Commands[i]); + + if (candidates.Size == 0) + { + // No match + AddLog("No match for \"%.*s\"!\n", (int)(word_end-word_start), word_start); + } + else if (candidates.Size == 1) + { + // Single match. Delete the beginning of the word and replace it entirely so we've got nice casing + data->DeleteChars((int)(word_start-data->Buf), (int)(word_end-word_start)); + data->InsertChars(data->CursorPos, candidates[0]); + data->InsertChars(data->CursorPos, " "); + } + else + { + // Multiple matches. Complete as much as we can, so inputing "C" will complete to "CL" and display "CLEAR" and "CLASSIFY" + int match_len = (int)(word_end - word_start); + for (;;) + { + int c = 0; + bool all_candidates_matches = true; + for (int i = 0; i < candidates.Size && all_candidates_matches; i++) + if (i == 0) + c = toupper(candidates[i][match_len]); + else if (c == 0 || c != toupper(candidates[i][match_len])) + all_candidates_matches = false; + if (!all_candidates_matches) + break; + match_len++; + } + + if (match_len > 0) + { + data->DeleteChars((int)(word_start - data->Buf), (int)(word_end-word_start)); + data->InsertChars(data->CursorPos, candidates[0], candidates[0] + match_len); + } + + // List matches + AddLog("Possible matches:\n"); + for (int i = 0; i < candidates.Size; i++) + AddLog("- %s\n", candidates[i]); + } + + break; + } + case ImGuiInputTextFlags_CallbackHistory: + { + // Example of HISTORY + const int prev_history_pos = HistoryPos; + if (data->EventKey == ImGuiKey_UpArrow) + { + if (HistoryPos == -1) + HistoryPos = History.Size - 1; + else if (HistoryPos > 0) + HistoryPos--; + } + else if (data->EventKey == ImGuiKey_DownArrow) + { + if (HistoryPos != -1) + if (++HistoryPos >= History.Size) + HistoryPos = -1; + } + + // A better implementation would preserve the data on the current input line along with cursor position. + if (prev_history_pos != HistoryPos) + { + data->CursorPos = data->SelectionStart = data->SelectionEnd = data->BufTextLen = (int)snprintf(data->Buf, (size_t)data->BufSize, "%s", (HistoryPos >= 0) ? History[HistoryPos] : ""); + data->BufDirty = true; + } + } + } + return 0; + } +}; + +static void ShowExampleAppConsole(bool* p_open) +{ + static ExampleAppConsole console; + console.Draw("Example: Console", p_open); +} + +// Usage: +// static ExampleAppLog my_log; +// my_log.AddLog("Hello %d world\n", 123); +// my_log.Draw("title"); +struct ExampleAppLog +{ + ImGuiTextBuffer Buf; + ImGuiTextFilter Filter; + ImVector LineOffsets; // Index to lines offset + bool ScrollToBottom; + + void Clear() { Buf.clear(); LineOffsets.clear(); } + + void AddLog(const char* fmt, ...) IM_FMTARGS(2) + { + int old_size = Buf.size(); + va_list args; + va_start(args, fmt); + Buf.appendfv(fmt, args); + va_end(args); + for (int new_size = Buf.size(); old_size < new_size; old_size++) + if (Buf[old_size] == '\n') + LineOffsets.push_back(old_size); + ScrollToBottom = true; + } + + void Draw(const char* title, bool* p_open = NULL) + { + ImGui::SetNextWindowSize(ImVec2(500,400), ImGuiCond_FirstUseEver); + ImGui::Begin(title, p_open); + if (ImGui::Button("Clear")) Clear(); + ImGui::SameLine(); + bool copy = ImGui::Button("Copy"); + ImGui::SameLine(); + Filter.Draw("Filter", -100.0f); + ImGui::Separator(); + ImGui::BeginChild("scrolling", ImVec2(0,0), false, ImGuiWindowFlags_HorizontalScrollbar); + if (copy) ImGui::LogToClipboard(); + + if (Filter.IsActive()) + { + const char* buf_begin = Buf.begin(); + const char* line = buf_begin; + for (int line_no = 0; line != NULL; line_no++) + { + const char* line_end = (line_no < LineOffsets.Size) ? buf_begin + LineOffsets[line_no] : NULL; + if (Filter.PassFilter(line, line_end)) + ImGui::TextUnformatted(line, line_end); + line = line_end && line_end[1] ? line_end + 1 : NULL; + } + } + else + { + ImGui::TextUnformatted(Buf.begin()); + } + + if (ScrollToBottom) + ImGui::SetScrollHere(1.0f); + ScrollToBottom = false; + ImGui::EndChild(); + ImGui::End(); + } +}; + +// Demonstrate creating a simple log window with basic filtering. +static void ShowExampleAppLog(bool* p_open) +{ + static ExampleAppLog log; + + // Demo: add random items (unless Ctrl is held) + static float last_time = -1.0f; + float time = ImGui::GetTime(); + if (time - last_time >= 0.20f && !ImGui::GetIO().KeyCtrl) + { + const char* random_words[] = { "system", "info", "warning", "error", "fatal", "notice", "log" }; + log.AddLog("[%s] Hello, time is %.1f, frame count is %d\n", random_words[rand() % IM_ARRAYSIZE(random_words)], time, ImGui::GetFrameCount()); + last_time = time; + } + + log.Draw("Example: Log", p_open); +} + +// Demonstrate create a window with multiple child windows. +static void ShowExampleAppLayout(bool* p_open) +{ + ImGui::SetNextWindowSize(ImVec2(500, 440), ImGuiCond_FirstUseEver); + if (ImGui::Begin("Example: Layout", p_open, ImGuiWindowFlags_MenuBar)) + { + if (ImGui::BeginMenuBar()) + { + if (ImGui::BeginMenu("File")) + { + if (ImGui::MenuItem("Close")) *p_open = false; + ImGui::EndMenu(); + } + ImGui::EndMenuBar(); + } + + // left + static int selected = 0; + ImGui::BeginChild("left pane", ImVec2(150, 0), true); + for (int i = 0; i < 100; i++) + { + char label[128]; + sprintf(label, "MyObject %d", i); + if (ImGui::Selectable(label, selected == i)) + selected = i; + } + ImGui::EndChild(); + ImGui::SameLine(); + + // right + ImGui::BeginGroup(); + ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us + ImGui::Text("MyObject: %d", selected); + ImGui::Separator(); + ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "); + ImGui::EndChild(); + if (ImGui::Button("Revert")) {} + ImGui::SameLine(); + if (ImGui::Button("Save")) {} + ImGui::EndGroup(); + } + ImGui::End(); +} + +// Demonstrate create a simple property editor. +static void ShowExampleAppPropertyEditor(bool* p_open) +{ + ImGui::SetNextWindowSize(ImVec2(430,450), ImGuiCond_FirstUseEver); + if (!ImGui::Begin("Example: Property editor", p_open)) + { + ImGui::End(); + return; + } + + ShowHelpMarker("This example shows how you may implement a property editor using two columns.\nAll objects/fields data are dummies here.\nRemember that in many simple cases, you can use ImGui::SameLine(xxx) to position\nyour cursor horizontally instead of using the Columns() API."); + + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2,2)); + ImGui::Columns(2); + ImGui::Separator(); + + struct funcs + { + static void ShowDummyObject(const char* prefix, int uid) + { + ImGui::PushID(uid); // Use object uid as identifier. Most commonly you could also use the object pointer as a base ID. + ImGui::AlignTextToFramePadding(); // Text and Tree nodes are less high than regular widgets, here we add vertical spacing to make the tree lines equal high. + bool node_open = ImGui::TreeNode("Object", "%s_%u", prefix, uid); + ImGui::NextColumn(); + ImGui::AlignTextToFramePadding(); + ImGui::Text("my sailor is rich"); + ImGui::NextColumn(); + if (node_open) + { + static float dummy_members[8] = { 0.0f,0.0f,1.0f,3.1416f,100.0f,999.0f }; + for (int i = 0; i < 8; i++) + { + ImGui::PushID(i); // Use field index as identifier. + if (i < 2) + { + ShowDummyObject("Child", 424242); + } + else + { + ImGui::AlignTextToFramePadding(); + // Here we use a Selectable (instead of Text) to highlight on hover + //ImGui::Text("Field_%d", i); + char label[32]; + sprintf(label, "Field_%d", i); + ImGui::Bullet(); + ImGui::Selectable(label); + ImGui::NextColumn(); + ImGui::PushItemWidth(-1); + if (i >= 5) + ImGui::InputFloat("##value", &dummy_members[i], 1.0f); + else + ImGui::DragFloat("##value", &dummy_members[i], 0.01f); + ImGui::PopItemWidth(); + ImGui::NextColumn(); + } + ImGui::PopID(); + } + ImGui::TreePop(); + } + ImGui::PopID(); + } + }; + + // Iterate dummy objects with dummy members (all the same data) + for (int obj_i = 0; obj_i < 3; obj_i++) + funcs::ShowDummyObject("Object", obj_i); + + ImGui::Columns(1); + ImGui::Separator(); + ImGui::PopStyleVar(); + ImGui::End(); +} + +// Demonstrate/test rendering huge amount of text, and the incidence of clipping. +static void ShowExampleAppLongText(bool* p_open) +{ + ImGui::SetNextWindowSize(ImVec2(520,600), ImGuiCond_FirstUseEver); + if (!ImGui::Begin("Example: Long text display", p_open)) + { + ImGui::End(); + return; + } + + static int test_type = 0; + static ImGuiTextBuffer log; + static int lines = 0; + ImGui::Text("Printing unusually long amount of text."); + ImGui::Combo("Test type", &test_type, "Single call to TextUnformatted()\0Multiple calls to Text(), clipped manually\0Multiple calls to Text(), not clipped (slow)\0"); + ImGui::Text("Buffer contents: %d lines, %d BYTEs", lines, log.size()); + if (ImGui::Button("Clear")) { log.clear(); lines = 0; } + ImGui::SameLine(); + if (ImGui::Button("Add 1000 lines")) + { + for (int i = 0; i < 1000; i++) + log.appendf("%i The quick brown fox jumps over the lazy dog\n", lines+i); + lines += 1000; + } + ImGui::BeginChild("Log"); + switch (test_type) + { + case 0: + // Single call to TextUnformatted() with a big buffer + ImGui::TextUnformatted(log.begin(), log.end()); + break; + case 1: + { + // Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper. + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0)); + ImGuiListClipper clipper(lines); + while (clipper.Step()) + for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) + ImGui::Text("%i The quick brown fox jumps over the lazy dog", i); + ImGui::PopStyleVar(); + break; + } + case 2: + // Multiple calls to Text(), not clipped (slow) + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0)); + for (int i = 0; i < lines; i++) + ImGui::Text("%i The quick brown fox jumps over the lazy dog", i); + ImGui::PopStyleVar(); + break; + } + ImGui::EndChild(); + ImGui::End(); +} + +// End of Demo code +#else + +void ImGui::ShowDemoWindow(bool*) {} +void ImGui::ShowUserGuide() {} +void ImGui::ShowStyleEditor(ImGuiStyle*) {} + +#endif + +``` + +`imgui/imgui_draw.cpp`: + +```cpp +// dear imgui, v1.54 WIP +// (drawing and font code) + +// Contains implementation for +// - Default styles +// - ImDrawList +// - ImDrawData +// - ImFontAtlas +// - ImFont +// - Default font data + +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include "imgui.h" +#define IMGUI_DEFINE_MATH_OPERATORS +#include "imgui_internal.h" + +#include // vsnprintf, sscanf, printf +#if !defined(alloca) +#ifdef _WIN32 +#include // alloca +#if !defined(alloca) +#define alloca _alloca // for clang with MS Codegen +#endif +#elif defined(__GLIBC__) || defined(__sun) +#include // alloca +#else +#include // alloca +#endif +#endif + +#ifdef _MSC_VER +#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff) +#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen +#define snprintf _snprintf +#endif + +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse. +#pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants ok. +#pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference it. +#pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness // +#if __has_warning("-Wcomma") +#pragma clang diagnostic ignored "-Wcomma" // warning : possible misuse of comma operator here // +#endif +#if __has_warning("-Wreserved-id-macro") +#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning : macro name is a reserved identifier // +#endif +#if __has_warning("-Wdouble-promotion") +#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function +#endif +#elif defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used +#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function +#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value +#pragma GCC diagnostic ignored "-Wcast-qual" // warning: cast from type 'xxxx' to type 'xxxx' casts away qualifiers +#endif + +//------------------------------------------------------------------------- +// STB libraries implementation +//------------------------------------------------------------------------- + +//#define IMGUI_STB_NAMESPACE ImGuiStb +//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION +//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION + +#ifdef IMGUI_STB_NAMESPACE +namespace IMGUI_STB_NAMESPACE +{ +#endif + +#ifdef _MSC_VER +#pragma warning (push) +#pragma warning (disable: 4456) // declaration of 'xx' hides previous local declaration +#endif + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-function" +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wimplicit-fallthrough" +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtype-limits" // warning: comparison is always true due to limited range of data type [-Wtype-limits] +#endif + +#define STBRP_ASSERT(x) IM_ASSERT(x) +#ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION +#define STBRP_STATIC +#define STB_RECT_PACK_IMPLEMENTATION +#endif +#include "stb_rect_pack.h" + +#define STBTT_malloc(x,u) ((void)(u), ImGui::MemAlloc(x)) +#define STBTT_free(x,u) ((void)(u), ImGui::MemFree(x)) +#define STBTT_assert(x) IM_ASSERT(x) +#ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION +#define STBTT_STATIC +#define STB_TRUETYPE_IMPLEMENTATION +#else +#define STBTT_DEF extern +#endif +#include "stb_truetype.h" + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#ifdef _MSC_VER +#pragma warning (pop) +#endif + +#ifdef IMGUI_STB_NAMESPACE +} // namespace ImGuiStb +using namespace IMGUI_STB_NAMESPACE; +#endif + +//----------------------------------------------------------------------------- +// Style functions +//----------------------------------------------------------------------------- + +void ImGui::StyleColorsClassic(ImGuiStyle* dst) +{ + ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); + ImVec4* colors = style->Colors; + + colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); + colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); + colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.70f); + colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_PopupBg] = ImVec4(0.11f, 0.11f, 0.14f, 0.92f); + colors[ImGuiCol_Border] = ImVec4(0.50f, 0.50f, 0.50f, 0.50f); + colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_FrameBg] = ImVec4(0.43f, 0.43f, 0.43f, 0.39f); + colors[ImGuiCol_FrameBgHovered] = ImVec4(0.47f, 0.47f, 0.69f, 0.40f); + colors[ImGuiCol_FrameBgActive] = ImVec4(0.42f, 0.41f, 0.64f, 0.69f); + colors[ImGuiCol_TitleBg] = ImVec4(0.27f, 0.27f, 0.54f, 0.83f); + colors[ImGuiCol_TitleBgActive] = ImVec4(0.32f, 0.32f, 0.63f, 0.87f); + colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.40f, 0.40f, 0.80f, 0.20f); + colors[ImGuiCol_MenuBarBg] = ImVec4(0.40f, 0.40f, 0.55f, 0.80f); + colors[ImGuiCol_ScrollbarBg] = ImVec4(0.20f, 0.25f, 0.30f, 0.60f); + colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.40f, 0.80f, 0.30f); + colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.40f, 0.80f, 0.40f); + colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.41f, 0.39f, 0.80f, 0.60f); + colors[ImGuiCol_CheckMark] = ImVec4(0.90f, 0.90f, 0.90f, 0.50f); + colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f); + colors[ImGuiCol_SliderGrabActive] = ImVec4(0.41f, 0.39f, 0.80f, 0.60f); + colors[ImGuiCol_Button] = ImVec4(0.35f, 0.40f, 0.61f, 0.62f); + colors[ImGuiCol_ButtonHovered] = ImVec4(0.40f, 0.48f, 0.71f, 0.79f); + colors[ImGuiCol_ButtonActive] = ImVec4(0.46f, 0.54f, 0.80f, 1.00f); + colors[ImGuiCol_Header] = ImVec4(0.40f, 0.40f, 0.90f, 0.45f); + colors[ImGuiCol_HeaderHovered] = ImVec4(0.45f, 0.45f, 0.90f, 0.80f); + colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.53f, 0.87f, 0.80f); + colors[ImGuiCol_Separator] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); + colors[ImGuiCol_SeparatorHovered] = ImVec4(0.60f, 0.60f, 0.70f, 1.00f); + colors[ImGuiCol_SeparatorActive] = ImVec4(0.70f, 0.70f, 0.90f, 1.00f); + colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.16f); + colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.78f, 0.82f, 1.00f, 0.60f); + colors[ImGuiCol_ResizeGripActive] = ImVec4(0.78f, 0.82f, 1.00f, 0.90f); + colors[ImGuiCol_CloseButton] = ImVec4(0.50f, 0.50f, 0.90f, 0.50f); + colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.70f, 0.70f, 0.90f, 0.60f); + colors[ImGuiCol_CloseButtonActive] = ImVec4(0.70f, 0.70f, 0.70f, 1.00f); + colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); + colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); + colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); + colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); + colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f); + colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); + colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); +} + +void ImGui::StyleColorsDark(ImGuiStyle* dst) +{ + ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); + ImVec4* colors = style->Colors; + + colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); + colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); + colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f); + colors[ImGuiCol_ChildBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.00f); + colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); + colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); + colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.29f, 0.48f, 0.54f); + colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); + colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f); + colors[ImGuiCol_TitleBgActive] = ImVec4(0.16f, 0.29f, 0.48f, 1.00f); + colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); + colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f); + colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f); + colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f); + colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f); + colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); + colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_SliderGrab] = ImVec4(0.24f, 0.52f, 0.88f, 1.00f); + colors[ImGuiCol_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); + colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); + colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f); + colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); + colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_Separator] = colors[ImGuiCol_Border];//ImVec4(0.61f, 0.61f, 0.61f, 1.00f); + colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f); + colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f); + colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.25f); + colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); + colors[ImGuiCol_CloseButton] = ImVec4(0.41f, 0.41f, 0.41f, 0.50f); + colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f); + colors[ImGuiCol_CloseButtonActive] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f); + colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); + colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); + colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); + colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); + colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); + colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); + colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); +} + +// Those light colors are better suited with a thicker font than the default one + FrameBorder +void ImGui::StyleColorsLight(ImGuiStyle* dst) +{ + ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); + ImVec4* colors = style->Colors; + + colors[ImGuiCol_Text] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); + colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); + //colors[ImGuiCol_TextHovered] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); + //colors[ImGuiCol_TextActive] = ImVec4(1.00f, 1.00f, 0.00f, 1.00f); + colors[ImGuiCol_WindowBg] = ImVec4(0.94f, 0.94f, 0.94f, 1.00f); + colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_PopupBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.98f); + colors[ImGuiCol_Border] = ImVec4(0.00f, 0.00f, 0.00f, 0.30f); + colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_FrameBg] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); + colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); + colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + colors[ImGuiCol_TitleBg] = ImVec4(0.96f, 0.96f, 0.96f, 1.00f); + colors[ImGuiCol_TitleBgActive] = ImVec4(0.82f, 0.82f, 0.82f, 1.00f); + colors[ImGuiCol_TitleBgCollapsed] = ImVec4(1.00f, 1.00f, 1.00f, 0.51f); + colors[ImGuiCol_MenuBarBg] = ImVec4(0.86f, 0.86f, 0.86f, 1.00f); + colors[ImGuiCol_ScrollbarBg] = ImVec4(0.98f, 0.98f, 0.98f, 0.53f); + colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.69f, 0.69f, 0.69f, 0.80f); + colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.49f, 0.49f, 0.49f, 0.80f); + colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.49f, 0.49f, 0.49f, 1.00f); + colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_SliderGrab] = ImVec4(0.26f, 0.59f, 0.98f, 0.78f); + colors[ImGuiCol_SliderGrabActive] = ImVec4(0.46f, 0.54f, 0.80f, 0.60f); + colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); + colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); + colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f); + colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); + colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_Separator] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f); + colors[ImGuiCol_SeparatorHovered] = ImVec4(0.14f, 0.44f, 0.80f, 0.78f); + colors[ImGuiCol_SeparatorActive] = ImVec4(0.14f, 0.44f, 0.80f, 1.00f); + colors[ImGuiCol_ResizeGrip] = ImVec4(0.80f, 0.80f, 0.80f, 0.56f); + colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); + colors[ImGuiCol_CloseButton] = ImVec4(0.59f, 0.59f, 0.59f, 0.50f); + colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f); + colors[ImGuiCol_CloseButtonActive] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f); + colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f); + colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); + colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); + colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.45f, 0.00f, 1.00f); + colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); + colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); + colors[ImGuiCol_DragDropTarget] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); +} + +//----------------------------------------------------------------------------- +// ImDrawListData +//----------------------------------------------------------------------------- + +ImDrawListSharedData::ImDrawListSharedData() +{ + Font = NULL; + FontSize = 0.0f; + CurveTessellationTol = 0.0f; + ClipRectFullscreen = ImVec4(-8192.0f, -8192.0f, +8192.0f, +8192.0f); + + // Const data + for (int i = 0; i < IM_ARRAYSIZE(CircleVtx12); i++) + { + const float a = ((float)i * 2 * IM_PI) / (float)IM_ARRAYSIZE(CircleVtx12); + CircleVtx12[i] = ImVec2(cosf(a), sinf(a)); + } +} + +//----------------------------------------------------------------------------- +// ImDrawList +//----------------------------------------------------------------------------- + +void ImDrawList::Clear() +{ + CmdBuffer.resize(0); + IdxBuffer.resize(0); + VtxBuffer.resize(0); + Flags = ImDrawListFlags_AntiAliasedLines | ImDrawListFlags_AntiAliasedFill; + _VtxCurrentIdx = 0; + _VtxWritePtr = NULL; + _IdxWritePtr = NULL; + _ClipRectStack.resize(0); + _TextureIdStack.resize(0); + _ShaderIdStack.resize(0); + _Path.resize(0); + _ChannelsCurrent = 0; + _ChannelsCount = 1; + // NB: Do not clear channels so our allocations are re-used after the first frame. +} + +void ImDrawList::ClearFreeMemory() +{ + CmdBuffer.clear(); + IdxBuffer.clear(); + VtxBuffer.clear(); + _VtxCurrentIdx = 0; + _VtxWritePtr = NULL; + _IdxWritePtr = NULL; + _ClipRectStack.clear(); + _ShaderIdStack.clear(); + _TextureIdStack.clear(); + _Path.clear(); + _ChannelsCurrent = 0; + _ChannelsCount = 1; + for (int i = 0; i < _Channels.Size; i++) + { + if (i == 0) memset(&_Channels[0], 0, sizeof(_Channels[0])); // channel 0 is a copy of CmdBuffer/IdxBuffer, don't destruct again + _Channels[i].CmdBuffer.clear(); + _Channels[i].IdxBuffer.clear(); + } + _Channels.clear(); +} + +// Using macros because C++ is a terrible language, we want guaranteed inline, no code in header, and no overhead in Debug builds +#define GetCurrentClipRect() (_ClipRectStack.Size ? _ClipRectStack.Data[_ClipRectStack.Size-1] : _Data->ClipRectFullscreen) +#define GetCurrentTextureId() (_TextureIdStack.Size ? _TextureIdStack.Data[_TextureIdStack.Size-1] : NULL) +#define GetCurrentShaderId() (_ShaderIdStack.Size ? _ShaderIdStack.Data[_ShaderIdStack.Size-1] : NULL) + +void ImDrawList::AddDrawCmd() +{ + ImDrawCmd draw_cmd; + draw_cmd.ClipRect = GetCurrentClipRect(); + draw_cmd.TextureId = GetCurrentTextureId(); + + IM_ASSERT(draw_cmd.ClipRect.x <= draw_cmd.ClipRect.z && draw_cmd.ClipRect.y <= draw_cmd.ClipRect.w); + CmdBuffer.push_back(draw_cmd); +} + +void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data) +{ + ImDrawCmd* current_cmd = CmdBuffer.Size ? &CmdBuffer.back() : NULL; + if (!current_cmd || current_cmd->ElemCount != 0 || current_cmd->UserCallback != NULL) + { + AddDrawCmd(); + current_cmd = &CmdBuffer.back(); + } + current_cmd->UserCallback = callback; + current_cmd->UserCallbackData = callback_data; + + AddDrawCmd(); // Force a new command after us (see comment below) +} + +// Our scheme may appears a bit unusual, basically we want the most-common calls AddLine AddRect etc. to not have to perform any check so we always have a command ready in the stack. +// The cost of figuring out if a new command has to be added or if we can merge is paid in those update** functions only. +void ImDrawList::UpdateClipRect() +{ + // If current command is used with different settings we need to add a new command + const ImVec4 curr_clip_rect = GetCurrentClipRect(); + ImDrawCmd* curr_cmd = CmdBuffer.Size > 0 ? &CmdBuffer.Data[CmdBuffer.Size-1] : NULL; + if (!curr_cmd || (curr_cmd->ElemCount != 0 && memcmp(&curr_cmd->ClipRect, &curr_clip_rect, sizeof(ImVec4)) != 0) || curr_cmd->UserCallback != NULL) + { + AddDrawCmd(); + return; + } + + // Try to merge with previous command if it matches, else use current command + ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL; + if (curr_cmd->ElemCount == 0 && prev_cmd && memcmp(&prev_cmd->ClipRect, &curr_clip_rect, sizeof(ImVec4)) == 0 && prev_cmd->TextureId == GetCurrentTextureId() && prev_cmd->UserCallback == NULL) + CmdBuffer.pop_back(); + else + curr_cmd->ClipRect = curr_clip_rect; +} + +void ImDrawList::UpdateTextureID() +{ + // If current command is used with different settings we need to add a new command + const ImTextureID curr_texture_id = GetCurrentTextureId(); + ImDrawCmd* curr_cmd = CmdBuffer.Size ? &CmdBuffer.back() : NULL; + if (!curr_cmd || (curr_cmd->ElemCount != 0 && curr_cmd->TextureId != curr_texture_id) || curr_cmd->UserCallback != NULL) + { + AddDrawCmd(); + return; + } + + // Try to merge with previous command if it matches, else use current command + ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL; + if (curr_cmd->ElemCount == 0 && prev_cmd && prev_cmd->TextureId == curr_texture_id && memcmp(&prev_cmd->ClipRect, &GetCurrentClipRect(), sizeof(ImVec4)) == 0 && prev_cmd->UserCallback == NULL) + CmdBuffer.pop_back(); + else + curr_cmd->TextureId = curr_texture_id; +} + +void ImDrawList::UpdateShaderID() +{ + // If current command is used with different settings we need to add a new command + const ImTextureID curr_shader_id = GetCurrentShaderId(); + ImDrawCmd* curr_cmd = CmdBuffer.Size ? &CmdBuffer.back() : NULL; + if (!curr_cmd || (curr_cmd->ElemCount != 0 && curr_cmd->ShaderID != curr_shader_id) || curr_cmd->UserCallback != NULL) + { + AddDrawCmd(); + return; + } + + // Try to merge with previous command if it matches, else use current command + ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL; + if (curr_cmd->ElemCount == 0 && prev_cmd && prev_cmd->ShaderID == curr_shader_id && memcmp(&prev_cmd->ClipRect, &GetCurrentClipRect(), sizeof(ImVec4)) == 0 && prev_cmd->UserCallback == NULL) + CmdBuffer.pop_back(); + else + curr_cmd->ShaderID = curr_shader_id; +} + +#undef GetCurrentClipRect +#undef GetCurrentTextureId +#undef GetCurrentShaderId + +// Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling) +void ImDrawList::PushClipRect(ImVec2 cr_min, ImVec2 cr_max, bool intersect_with_current_clip_rect) +{ + ImVec4 cr(cr_min.x, cr_min.y, cr_max.x, cr_max.y); + if (intersect_with_current_clip_rect && _ClipRectStack.Size) + { + ImVec4 current = _ClipRectStack.Data[_ClipRectStack.Size-1]; + if (cr.x < current.x) cr.x = current.x; + if (cr.y < current.y) cr.y = current.y; + if (cr.z > current.z) cr.z = current.z; + if (cr.w > current.w) cr.w = current.w; + } + cr.z = ImMax(cr.x, cr.z); + cr.w = ImMax(cr.y, cr.w); + + _ClipRectStack.push_back(cr); + UpdateClipRect(); +} + +void ImDrawList::PushClipRectFullScreen() +{ + PushClipRect(ImVec2(_Data->ClipRectFullscreen.x, _Data->ClipRectFullscreen.y), ImVec2(_Data->ClipRectFullscreen.z, _Data->ClipRectFullscreen.w)); +} + +void ImDrawList::PopClipRect() +{ + IM_ASSERT(_ClipRectStack.Size > 0); + _ClipRectStack.pop_back(); + UpdateClipRect(); +} + +void ImDrawList::PushTextureID(const ImTextureID& texture_id) +{ + _TextureIdStack.push_back(texture_id); + UpdateTextureID(); +} + +void ImDrawList::PushShaderID(const ImShaderID& shader_id) +{ + _ShaderIdStack.push_back(shader_id); + UpdateShaderID(); +} + +void ImDrawList::PopTextureID() +{ + IM_ASSERT(_TextureIdStack.Size > 0); + _TextureIdStack.pop_back(); + UpdateTextureID(); +} + +void ImDrawList::PopShaderID() +{ + IM_ASSERT(_ShaderIdStack.Size > 0); + _ShaderIdStack.pop_back(); + UpdateShaderID(); +} + +void ImDrawList::ChannelsSplit(int channels_count) +{ + IM_ASSERT(_ChannelsCurrent == 0 && _ChannelsCount == 1); + int old_channels_count = _Channels.Size; + if (old_channels_count < channels_count) + _Channels.resize(channels_count); + _ChannelsCount = channels_count; + + // _Channels[] (24/32 BYTEs each) hold storage that we'll swap with this->_CmdBuffer/_IdxBuffer + // The content of _Channels[0] at this point doesn't matter. We clear it to make state tidy in a debugger but we don't strictly need to. + // When we switch to the next channel, we'll copy _CmdBuffer/_IdxBuffer into _Channels[0] and then _Channels[1] into _CmdBuffer/_IdxBuffer + memset(&_Channels[0], 0, sizeof(ImDrawChannel)); + for (int i = 1; i < channels_count; i++) + { + if (i >= old_channels_count) + { + IM_PLACEMENT_NEW(&_Channels[i]) ImDrawChannel(); + } + else + { + _Channels[i].CmdBuffer.resize(0); + _Channels[i].IdxBuffer.resize(0); + } + if (_Channels[i].CmdBuffer.Size == 0) + { + ImDrawCmd draw_cmd; + draw_cmd.ClipRect = _ClipRectStack.back(); + draw_cmd.TextureId = _TextureIdStack.back(); + _Channels[i].CmdBuffer.push_back(draw_cmd); + } + } +} + +void ImDrawList::ChannelsMerge() +{ + // Note that we never use or rely on channels.Size because it is merely a buffer that we never shrink back to 0 to keep all sub-buffers ready for use. + if (_ChannelsCount <= 1) + return; + + ChannelsSetCurrent(0); + if (CmdBuffer.Size && CmdBuffer.back().ElemCount == 0) + CmdBuffer.pop_back(); + + int new_cmd_buffer_count = 0, new_idx_buffer_count = 0; + for (int i = 1; i < _ChannelsCount; i++) + { + ImDrawChannel& ch = _Channels[i]; + if (ch.CmdBuffer.Size && ch.CmdBuffer.back().ElemCount == 0) + ch.CmdBuffer.pop_back(); + new_cmd_buffer_count += ch.CmdBuffer.Size; + new_idx_buffer_count += ch.IdxBuffer.Size; + } + CmdBuffer.resize(CmdBuffer.Size + new_cmd_buffer_count); + IdxBuffer.resize(IdxBuffer.Size + new_idx_buffer_count); + + ImDrawCmd* cmd_write = CmdBuffer.Data + CmdBuffer.Size - new_cmd_buffer_count; + _IdxWritePtr = IdxBuffer.Data + IdxBuffer.Size - new_idx_buffer_count; + for (int i = 1; i < _ChannelsCount; i++) + { + ImDrawChannel& ch = _Channels[i]; + if (int sz = ch.CmdBuffer.Size) { memcpy(cmd_write, ch.CmdBuffer.Data, sz * sizeof(ImDrawCmd)); cmd_write += sz; } + if (int sz = ch.IdxBuffer.Size) { memcpy(_IdxWritePtr, ch.IdxBuffer.Data, sz * sizeof(ImDrawIdx)); _IdxWritePtr += sz; } + } + UpdateClipRect(); // We call this instead of AddDrawCmd(), so that empty channels won't produce an extra draw call. + _ChannelsCount = 1; +} + +void ImDrawList::ChannelsSetCurrent(int idx) +{ + IM_ASSERT(idx < _ChannelsCount); + if (_ChannelsCurrent == idx) return; + memcpy(&_Channels.Data[_ChannelsCurrent].CmdBuffer, &CmdBuffer, sizeof(CmdBuffer)); // copy 12 BYTEs, four times + memcpy(&_Channels.Data[_ChannelsCurrent].IdxBuffer, &IdxBuffer, sizeof(IdxBuffer)); + _ChannelsCurrent = idx; + memcpy(&CmdBuffer, &_Channels.Data[_ChannelsCurrent].CmdBuffer, sizeof(CmdBuffer)); + memcpy(&IdxBuffer, &_Channels.Data[_ChannelsCurrent].IdxBuffer, sizeof(IdxBuffer)); + _IdxWritePtr = IdxBuffer.Data + IdxBuffer.Size; +} + +// NB: this can be called with negative count for removing primitives (as long as the result does not underflow) +void ImDrawList::PrimReserve(int idx_count, int vtx_count) +{ + ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size-1]; + draw_cmd.ElemCount += idx_count; + + int vtx_buffer_old_size = VtxBuffer.Size; + VtxBuffer.resize(vtx_buffer_old_size + vtx_count); + _VtxWritePtr = VtxBuffer.Data + vtx_buffer_old_size; + + int idx_buffer_old_size = IdxBuffer.Size; + IdxBuffer.resize(idx_buffer_old_size + idx_count); + _IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size; +} + +// Fully unrolled with inline call to keep our debug builds decently fast. +void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col) +{ + ImVec2 b(c.x, a.y), d(a.x, c.y), uv(_Data->TexUvWhitePixel); + ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx; + _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2); + _IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3); + _VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; + _VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col; + _VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col; + _VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col; + _VtxWritePtr += 4; + _VtxCurrentIdx += 4; + _IdxWritePtr += 6; +} + +void ImDrawList::PrimRectUV(const ImVec2& a, const ImVec2& c, const ImVec2& uv_a, const ImVec2& uv_c, ImU32 col) +{ + ImVec2 b(c.x, a.y), d(a.x, c.y), uv_b(uv_c.x, uv_a.y), uv_d(uv_a.x, uv_c.y); + ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx; + _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2); + _IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3); + _VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv_a; _VtxWritePtr[0].col = col; + _VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv_b; _VtxWritePtr[1].col = col; + _VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv_c; _VtxWritePtr[2].col = col; + _VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv_d; _VtxWritePtr[3].col = col; + _VtxWritePtr += 4; + _VtxCurrentIdx += 4; + _IdxWritePtr += 6; +} + +void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col) +{ + ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx; + _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2); + _IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3); + _VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv_a; _VtxWritePtr[0].col = col; + _VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv_b; _VtxWritePtr[1].col = col; + _VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv_c; _VtxWritePtr[2].col = col; + _VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv_d; _VtxWritePtr[3].col = col; + _VtxWritePtr += 4; + _VtxCurrentIdx += 4; + _IdxWritePtr += 6; +} + +// TODO: Thickness anti-aliased lines cap are missing their AA fringe. +void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 col, bool closed, float thickness) +{ + if (points_count < 2) + return; + + const ImVec2 uv = _Data->TexUvWhitePixel; + + int count = points_count; + if (!closed) + count = points_count-1; + + const bool thick_line = thickness > 1.0f; + if (Flags & ImDrawListFlags_AntiAliasedLines) + { + // Anti-aliased stroke + const float AA_SIZE = 1.0f; + const ImU32 col_trans = col & ~IM_COL32_A_MASK; + + const int idx_count = thick_line ? count*18 : count*12; + const int vtx_count = thick_line ? points_count*4 : points_count*3; + PrimReserve(idx_count, vtx_count); + + // Temporary buffer + ImVec2* temp_normals = (ImVec2*)alloca(points_count * (thick_line ? 5 : 3) * sizeof(ImVec2)); + ImVec2* temp_points = temp_normals + points_count; + + for (int i1 = 0; i1 < count; i1++) + { + const int i2 = (i1+1) == points_count ? 0 : i1+1; + ImVec2 diff = points[i2] - points[i1]; + diff *= ImInvLength(diff, 1.0f); + temp_normals[i1].x = diff.y; + temp_normals[i1].y = -diff.x; + } + if (!closed) + temp_normals[points_count-1] = temp_normals[points_count-2]; + + if (!thick_line) + { + if (!closed) + { + temp_points[0] = points[0] + temp_normals[0] * AA_SIZE; + temp_points[1] = points[0] - temp_normals[0] * AA_SIZE; + temp_points[(points_count-1)*2+0] = points[points_count-1] + temp_normals[points_count-1] * AA_SIZE; + temp_points[(points_count-1)*2+1] = points[points_count-1] - temp_normals[points_count-1] * AA_SIZE; + } + + // FIXME-OPT: Merge the different loops, possibly remove the temporary buffer. + unsigned int idx1 = _VtxCurrentIdx; + for (int i1 = 0; i1 < count; i1++) + { + const int i2 = (i1+1) == points_count ? 0 : i1+1; + unsigned int idx2 = (i1+1) == points_count ? _VtxCurrentIdx : idx1+3; + + // Average normals + ImVec2 dm = (temp_normals[i1] + temp_normals[i2]) * 0.5f; + float dmr2 = dm.x*dm.x + dm.y*dm.y; + if (dmr2 > 0.000001f) + { + float scale = 1.0f / dmr2; + if (scale > 100.0f) scale = 100.0f; + dm *= scale; + } + dm *= AA_SIZE; + temp_points[i2*2+0] = points[i2] + dm; + temp_points[i2*2+1] = points[i2] - dm; + + // Add indexes + _IdxWritePtr[0] = (ImDrawIdx)(idx2+0); _IdxWritePtr[1] = (ImDrawIdx)(idx1+0); _IdxWritePtr[2] = (ImDrawIdx)(idx1+2); + _IdxWritePtr[3] = (ImDrawIdx)(idx1+2); _IdxWritePtr[4] = (ImDrawIdx)(idx2+2); _IdxWritePtr[5] = (ImDrawIdx)(idx2+0); + _IdxWritePtr[6] = (ImDrawIdx)(idx2+1); _IdxWritePtr[7] = (ImDrawIdx)(idx1+1); _IdxWritePtr[8] = (ImDrawIdx)(idx1+0); + _IdxWritePtr[9] = (ImDrawIdx)(idx1+0); _IdxWritePtr[10]= (ImDrawIdx)(idx2+0); _IdxWritePtr[11]= (ImDrawIdx)(idx2+1); + _IdxWritePtr += 12; + + idx1 = idx2; + } + + // Add vertexes + for (int i = 0; i < points_count; i++) + { + _VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; + _VtxWritePtr[1].pos = temp_points[i*2+0]; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col_trans; + _VtxWritePtr[2].pos = temp_points[i*2+1]; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col_trans; + _VtxWritePtr += 3; + } + } + else + { + const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f; + if (!closed) + { + temp_points[0] = points[0] + temp_normals[0] * (half_inner_thickness + AA_SIZE); + temp_points[1] = points[0] + temp_normals[0] * (half_inner_thickness); + temp_points[2] = points[0] - temp_normals[0] * (half_inner_thickness); + temp_points[3] = points[0] - temp_normals[0] * (half_inner_thickness + AA_SIZE); + temp_points[(points_count-1)*4+0] = points[points_count-1] + temp_normals[points_count-1] * (half_inner_thickness + AA_SIZE); + temp_points[(points_count-1)*4+1] = points[points_count-1] + temp_normals[points_count-1] * (half_inner_thickness); + temp_points[(points_count-1)*4+2] = points[points_count-1] - temp_normals[points_count-1] * (half_inner_thickness); + temp_points[(points_count-1)*4+3] = points[points_count-1] - temp_normals[points_count-1] * (half_inner_thickness + AA_SIZE); + } + + // FIXME-OPT: Merge the different loops, possibly remove the temporary buffer. + unsigned int idx1 = _VtxCurrentIdx; + for (int i1 = 0; i1 < count; i1++) + { + const int i2 = (i1+1) == points_count ? 0 : i1+1; + unsigned int idx2 = (i1+1) == points_count ? _VtxCurrentIdx : idx1+4; + + // Average normals + ImVec2 dm = (temp_normals[i1] + temp_normals[i2]) * 0.5f; + float dmr2 = dm.x*dm.x + dm.y*dm.y; + if (dmr2 > 0.000001f) + { + float scale = 1.0f / dmr2; + if (scale > 100.0f) scale = 100.0f; + dm *= scale; + } + ImVec2 dm_out = dm * (half_inner_thickness + AA_SIZE); + ImVec2 dm_in = dm * half_inner_thickness; + temp_points[i2*4+0] = points[i2] + dm_out; + temp_points[i2*4+1] = points[i2] + dm_in; + temp_points[i2*4+2] = points[i2] - dm_in; + temp_points[i2*4+3] = points[i2] - dm_out; + + // Add indexes + _IdxWritePtr[0] = (ImDrawIdx)(idx2+1); _IdxWritePtr[1] = (ImDrawIdx)(idx1+1); _IdxWritePtr[2] = (ImDrawIdx)(idx1+2); + _IdxWritePtr[3] = (ImDrawIdx)(idx1+2); _IdxWritePtr[4] = (ImDrawIdx)(idx2+2); _IdxWritePtr[5] = (ImDrawIdx)(idx2+1); + _IdxWritePtr[6] = (ImDrawIdx)(idx2+1); _IdxWritePtr[7] = (ImDrawIdx)(idx1+1); _IdxWritePtr[8] = (ImDrawIdx)(idx1+0); + _IdxWritePtr[9] = (ImDrawIdx)(idx1+0); _IdxWritePtr[10] = (ImDrawIdx)(idx2+0); _IdxWritePtr[11] = (ImDrawIdx)(idx2+1); + _IdxWritePtr[12] = (ImDrawIdx)(idx2+2); _IdxWritePtr[13] = (ImDrawIdx)(idx1+2); _IdxWritePtr[14] = (ImDrawIdx)(idx1+3); + _IdxWritePtr[15] = (ImDrawIdx)(idx1+3); _IdxWritePtr[16] = (ImDrawIdx)(idx2+3); _IdxWritePtr[17] = (ImDrawIdx)(idx2+2); + _IdxWritePtr += 18; + + idx1 = idx2; + } + + // Add vertexes + for (int i = 0; i < points_count; i++) + { + _VtxWritePtr[0].pos = temp_points[i*4+0]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col_trans; + _VtxWritePtr[1].pos = temp_points[i*4+1]; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col; + _VtxWritePtr[2].pos = temp_points[i*4+2]; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col; + _VtxWritePtr[3].pos = temp_points[i*4+3]; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col_trans; + _VtxWritePtr += 4; + } + } + _VtxCurrentIdx += (ImDrawIdx)vtx_count; + } + else + { + // Non Anti-aliased Stroke + const int idx_count = count*6; + const int vtx_count = count*4; // FIXME-OPT: Not sharing edges + PrimReserve(idx_count, vtx_count); + + for (int i1 = 0; i1 < count; i1++) + { + const int i2 = (i1+1) == points_count ? 0 : i1+1; + const ImVec2& p1 = points[i1]; + const ImVec2& p2 = points[i2]; + ImVec2 diff = p2 - p1; + diff *= ImInvLength(diff, 1.0f); + + const float dx = diff.x * (thickness * 0.5f); + const float dy = diff.y * (thickness * 0.5f); + _VtxWritePtr[0].pos.x = p1.x + dy; _VtxWritePtr[0].pos.y = p1.y - dx; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; + _VtxWritePtr[1].pos.x = p2.x + dy; _VtxWritePtr[1].pos.y = p2.y - dx; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col; + _VtxWritePtr[2].pos.x = p2.x - dy; _VtxWritePtr[2].pos.y = p2.y + dx; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col; + _VtxWritePtr[3].pos.x = p1.x - dy; _VtxWritePtr[3].pos.y = p1.y + dx; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col; + _VtxWritePtr += 4; + + _IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+2); + _IdxWritePtr[3] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[4] = (ImDrawIdx)(_VtxCurrentIdx+2); _IdxWritePtr[5] = (ImDrawIdx)(_VtxCurrentIdx+3); + _IdxWritePtr += 6; + _VtxCurrentIdx += 4; + } + } +} + +void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, ImU32 col) +{ + const ImVec2 uv = _Data->TexUvWhitePixel; + + if (Flags & ImDrawListFlags_AntiAliasedFill) + { + // Anti-aliased Fill + const float AA_SIZE = 1.0f; + const ImU32 col_trans = col & ~IM_COL32_A_MASK; + const int idx_count = (points_count-2)*3 + points_count*6; + const int vtx_count = (points_count*2); + PrimReserve(idx_count, vtx_count); + + // Add indexes for fill + unsigned int vtx_inner_idx = _VtxCurrentIdx; + unsigned int vtx_outer_idx = _VtxCurrentIdx+1; + for (int i = 2; i < points_count; i++) + { + _IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx+((i-1)<<1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_inner_idx+(i<<1)); + _IdxWritePtr += 3; + } + + // Compute normals + ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2)); + for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) + { + const ImVec2& p0 = points[i0]; + const ImVec2& p1 = points[i1]; + ImVec2 diff = p1 - p0; + diff *= ImInvLength(diff, 1.0f); + temp_normals[i0].x = diff.y; + temp_normals[i0].y = -diff.x; + } + + for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) + { + // Average normals + const ImVec2& n0 = temp_normals[i0]; + const ImVec2& n1 = temp_normals[i1]; + ImVec2 dm = (n0 + n1) * 0.5f; + float dmr2 = dm.x*dm.x + dm.y*dm.y; + if (dmr2 > 0.000001f) + { + float scale = 1.0f / dmr2; + if (scale > 100.0f) scale = 100.0f; + dm *= scale; + } + dm *= AA_SIZE * 0.5f; + + // Add vertices + _VtxWritePtr[0].pos = (points[i1] - dm); _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; // Inner + _VtxWritePtr[1].pos = (points[i1] + dm); _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col_trans; // Outer + _VtxWritePtr += 2; + + // Add indexes for fringes + _IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx+(i1<<1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx+(i0<<1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_outer_idx+(i0<<1)); + _IdxWritePtr[3] = (ImDrawIdx)(vtx_outer_idx+(i0<<1)); _IdxWritePtr[4] = (ImDrawIdx)(vtx_outer_idx+(i1<<1)); _IdxWritePtr[5] = (ImDrawIdx)(vtx_inner_idx+(i1<<1)); + _IdxWritePtr += 6; + } + _VtxCurrentIdx += (ImDrawIdx)vtx_count; + } + else + { + // Non Anti-aliased Fill + const int idx_count = (points_count-2)*3; + const int vtx_count = points_count; + PrimReserve(idx_count, vtx_count); + for (int i = 0; i < vtx_count; i++) + { + _VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; + _VtxWritePtr++; + } + for (int i = 2; i < points_count; i++) + { + _IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+i-1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+i); + _IdxWritePtr += 3; + } + _VtxCurrentIdx += (ImDrawIdx)vtx_count; + } +} + +void ImDrawList::PathArcToFast(const ImVec2& centre, float radius, int a_min_of_12, int a_max_of_12) +{ + if (radius == 0.0f || a_min_of_12 > a_max_of_12) + { + _Path.push_back(centre); + return; + } + _Path.reserve(_Path.Size + (a_max_of_12 - a_min_of_12 + 1)); + for (int a = a_min_of_12; a <= a_max_of_12; a++) + { + const ImVec2& c = _Data->CircleVtx12[a % IM_ARRAYSIZE(_Data->CircleVtx12)]; + _Path.push_back(ImVec2(centre.x + c.x * radius, centre.y + c.y * radius)); + } +} + +void ImDrawList::PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments) +{ + if (radius == 0.0f) + { + _Path.push_back(centre); + return; + } + _Path.reserve(_Path.Size + (num_segments + 1)); + for (int i = 0; i <= num_segments; i++) + { + const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min); + _Path.push_back(ImVec2(centre.x + cosf(a) * radius, centre.y + sinf(a) * radius)); + } +} + +static void PathBezierToCasteljau(ImVector* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level) +{ + float dx = x4 - x1; + float dy = y4 - y1; + float d2 = ((x2 - x4) * dy - (y2 - y4) * dx); + float d3 = ((x3 - x4) * dy - (y3 - y4) * dx); + d2 = (d2 >= 0) ? d2 : -d2; + d3 = (d3 >= 0) ? d3 : -d3; + if ((d2+d3) * (d2+d3) < tess_tol * (dx*dx + dy*dy)) + { + path->push_back(ImVec2(x4, y4)); + } + else if (level < 10) + { + float x12 = (x1+x2)*0.5f, y12 = (y1+y2)*0.5f; + float x23 = (x2+x3)*0.5f, y23 = (y2+y3)*0.5f; + float x34 = (x3+x4)*0.5f, y34 = (y3+y4)*0.5f; + float x123 = (x12+x23)*0.5f, y123 = (y12+y23)*0.5f; + float x234 = (x23+x34)*0.5f, y234 = (y23+y34)*0.5f; + float x1234 = (x123+x234)*0.5f, y1234 = (y123+y234)*0.5f; + + PathBezierToCasteljau(path, x1,y1, x12,y12, x123,y123, x1234,y1234, tess_tol, level+1); + PathBezierToCasteljau(path, x1234,y1234, x234,y234, x34,y34, x4,y4, tess_tol, level+1); + } +} + +void ImDrawList::PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments) +{ + ImVec2 p1 = _Path.back(); + if (num_segments == 0) + { + // Auto-tessellated + PathBezierToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, _Data->CurveTessellationTol, 0); + } + else + { + float t_step = 1.0f / (float)num_segments; + for (int i_step = 1; i_step <= num_segments; i_step++) + { + float t = t_step * i_step; + float u = 1.0f - t; + float w1 = u*u*u; + float w2 = 3*u*u*t; + float w3 = 3*u*t*t; + float w4 = t*t*t; + _Path.push_back(ImVec2(w1*p1.x + w2*p2.x + w3*p3.x + w4*p4.x, w1*p1.y + w2*p2.y + w3*p3.y + w4*p4.y)); + } + } +} + +void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, int rounding_corners) +{ + rounding = ImMin(rounding, fabsf(b.x - a.x) * ( ((rounding_corners & ImDrawCornerFlags_Top) == ImDrawCornerFlags_Top) || ((rounding_corners & ImDrawCornerFlags_Bot) == ImDrawCornerFlags_Bot) ? 0.5f : 1.0f ) - 1.0f); + rounding = ImMin(rounding, fabsf(b.y - a.y) * ( ((rounding_corners & ImDrawCornerFlags_Left) == ImDrawCornerFlags_Left) || ((rounding_corners & ImDrawCornerFlags_Right) == ImDrawCornerFlags_Right) ? 0.5f : 1.0f ) - 1.0f); + + if (rounding <= 0.0f || rounding_corners == 0) + { + PathLineTo(a); + PathLineTo(ImVec2(b.x, a.y)); + PathLineTo(b); + PathLineTo(ImVec2(a.x, b.y)); + } + else + { + const float rounding_tl = (rounding_corners & ImDrawCornerFlags_TopLeft) ? rounding : 0.0f; + const float rounding_tr = (rounding_corners & ImDrawCornerFlags_TopRight) ? rounding : 0.0f; + const float rounding_br = (rounding_corners & ImDrawCornerFlags_BotRight) ? rounding : 0.0f; + const float rounding_bl = (rounding_corners & ImDrawCornerFlags_BotLeft) ? rounding : 0.0f; + PathArcToFast(ImVec2(a.x + rounding_tl, a.y + rounding_tl), rounding_tl, 6, 9); + PathArcToFast(ImVec2(b.x - rounding_tr, a.y + rounding_tr), rounding_tr, 9, 12); + PathArcToFast(ImVec2(b.x - rounding_br, b.y - rounding_br), rounding_br, 0, 3); + PathArcToFast(ImVec2(a.x + rounding_bl, b.y - rounding_bl), rounding_bl, 3, 6); + } +} + +void ImDrawList::AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + PathLineTo(a + ImVec2(0.5f,0.5f)); + PathLineTo(b + ImVec2(0.5f,0.5f)); + PathStroke(col, false, thickness); +} + +// a: upper-left, b: lower-right. we don't render 1 px sized rectangles properly. +void ImDrawList::AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, int rounding_corners_flags, float thickness) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + PathRect(a + ImVec2(0.5f,0.5f), b - ImVec2(0.5f,0.5f), rounding, rounding_corners_flags); + PathStroke(col, true, thickness); +} + +void ImDrawList::AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, int rounding_corners_flags) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + if (rounding > 0.0f) + { + PathRect(a, b, rounding, rounding_corners_flags); + PathFillConvex(col); + } + else + { + PrimReserve(6, 4); + PrimRect(a, b, col); + } +} + +void ImDrawList::AddRectFilledMultiColor(const ImVec2& a, const ImVec2& c, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left) +{ + if (((col_upr_left | col_upr_right | col_bot_right | col_bot_left) & IM_COL32_A_MASK) == 0) + return; + + const ImVec2 uv = _Data->TexUvWhitePixel; + PrimReserve(6, 4); + PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2)); + PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+3)); + PrimWriteVtx(a, uv, col_upr_left); + PrimWriteVtx(ImVec2(c.x, a.y), uv, col_upr_right); + PrimWriteVtx(c, uv, col_bot_right); + PrimWriteVtx(ImVec2(a.x, c.y), uv, col_bot_left); +} + +void ImDrawList::AddQuad(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col, float thickness) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + PathLineTo(a); + PathLineTo(b); + PathLineTo(c); + PathLineTo(d); + PathStroke(col, true, thickness); +} + +void ImDrawList::AddQuadFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + PathLineTo(a); + PathLineTo(b); + PathLineTo(c); + PathLineTo(d); + PathFillConvex(col); +} + +void ImDrawList::AddTriangle(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col, float thickness) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + PathLineTo(a); + PathLineTo(b); + PathLineTo(c); + PathStroke(col, true, thickness); +} + +void ImDrawList::AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + PathLineTo(a); + PathLineTo(b); + PathLineTo(c); + PathFillConvex(col); +} + +void ImDrawList::AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments, float thickness) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + const float a_max = IM_PI*2.0f * ((float)num_segments - 1.0f) / (float)num_segments; + PathArcTo(centre, radius-0.5f, 0.0f, a_max, num_segments); + PathStroke(col, true, thickness); +} + +void ImDrawList::AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + const float a_max = IM_PI*2.0f * ((float)num_segments - 1.0f) / (float)num_segments; + PathArcTo(centre, radius, 0.0f, a_max, num_segments); + PathFillConvex(col); +} + +void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + PathLineTo(pos0); + PathBezierCurveTo(cp0, cp1, pos1, num_segments); + PathStroke(col, false, thickness); +} + +void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + if (text_end == NULL) + text_end = text_begin + strlen(text_begin); + if (text_begin == text_end) + return; + + // Pull default font/size from the shared ImDrawListSharedData instance + if (font == NULL) + font = _Data->Font; + if (font_size == 0.0f) + font_size = _Data->FontSize; + + IM_ASSERT(font->ContainerAtlas->TexID == _TextureIdStack.back()); // Use high-level ImGui::PushFont() or low-level ImDrawList::PushTextureId() to change font. + + ImVec4 clip_rect = _ClipRectStack.back(); + if (cpu_fine_clip_rect) + { + clip_rect.x = ImMax(clip_rect.x, cpu_fine_clip_rect->x); + clip_rect.y = ImMax(clip_rect.y, cpu_fine_clip_rect->y); + clip_rect.z = ImMin(clip_rect.z, cpu_fine_clip_rect->z); + clip_rect.w = ImMin(clip_rect.w, cpu_fine_clip_rect->w); + } + font->RenderText(this, font_size, pos, col, clip_rect, text_begin, text_end, wrap_width, cpu_fine_clip_rect != NULL); +} + +void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end) +{ + AddText(NULL, 0.0f, pos, col, text_begin, text_end); +} + +void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back(); + if (push_texture_id) + PushTextureID(user_texture_id); + + PrimReserve(6, 4); + PrimRectUV(a, b, uv_a, uv_b, col); + + if (push_texture_id) + PopTextureID(); +} + +void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back(); + if (push_texture_id) + PushTextureID(user_texture_id); + + PrimReserve(6, 4); + PrimQuadUV(a, b, c, d, uv_a, uv_b, uv_c, uv_d, col); + + if (push_texture_id) + PopTextureID(); +} + +void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col, float rounding, int rounding_corners) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + if (rounding <= 0.0f || (rounding_corners & ImDrawCornerFlags_All) == 0) + { + AddImage(user_texture_id, a, b, uv_a, uv_b, col); + return; + } + + const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back(); + if (push_texture_id) + PushTextureID(user_texture_id); + + int vert_start_idx = VtxBuffer.Size; + PathRect(a, b, rounding, rounding_corners); + PathFillConvex(col); + int vert_end_idx = VtxBuffer.Size; + ImGui::ShadeVertsLinearUV(VtxBuffer.Data + vert_start_idx, VtxBuffer.Data + vert_end_idx, a, b, uv_a, uv_b, true); + + if (push_texture_id) + PopTextureID(); +} + +//----------------------------------------------------------------------------- +// ImDrawData +//----------------------------------------------------------------------------- + +// For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering! +void ImDrawData::DeIndexAllBuffers() +{ + ImVector new_vtx_buffer; + TotalVtxCount = TotalIdxCount = 0; + for (int i = 0; i < CmdListsCount; i++) + { + ImDrawList* cmd_list = CmdLists[i]; + if (cmd_list->IdxBuffer.empty()) + continue; + new_vtx_buffer.resize(cmd_list->IdxBuffer.Size); + for (int j = 0; j < cmd_list->IdxBuffer.Size; j++) + new_vtx_buffer[j] = cmd_list->VtxBuffer[cmd_list->IdxBuffer[j]]; + cmd_list->VtxBuffer.swap(new_vtx_buffer); + cmd_list->IdxBuffer.resize(0); + TotalVtxCount += cmd_list->VtxBuffer.Size; + } +} + +// Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution. +void ImDrawData::ScaleClipRects(const ImVec2& scale) +{ + for (int i = 0; i < CmdListsCount; i++) + { + ImDrawList* cmd_list = CmdLists[i]; + for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) + { + ImDrawCmd* cmd = &cmd_list->CmdBuffer[cmd_i]; + cmd->ClipRect = ImVec4(cmd->ClipRect.x * scale.x, cmd->ClipRect.y * scale.y, cmd->ClipRect.z * scale.x, cmd->ClipRect.w * scale.y); + } + } +} + +//----------------------------------------------------------------------------- +// Shade functions +//----------------------------------------------------------------------------- + +// Generic linear color gradient, write to RGB fields, leave A untouched. +void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawVert* vert_start, ImDrawVert* vert_end, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1) +{ + ImVec2 gradient_extent = gradient_p1 - gradient_p0; + float gradient_inv_length2 = 1.0f / ImLengthSqr(gradient_extent); + for (ImDrawVert* vert = vert_start; vert < vert_end; vert++) + { + float d = ImDot(vert->pos - gradient_p0, gradient_extent); + float t = ImClamp(d * gradient_inv_length2, 0.0f, 1.0f); + int r = ImLerp((int)(col0 >> IM_COL32_R_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_R_SHIFT) & 0xFF, t); + int g = ImLerp((int)(col0 >> IM_COL32_G_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_G_SHIFT) & 0xFF, t); + int b = ImLerp((int)(col0 >> IM_COL32_B_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_B_SHIFT) & 0xFF, t); + vert->col = (r << IM_COL32_R_SHIFT) | (g << IM_COL32_G_SHIFT) | (b << IM_COL32_B_SHIFT) | (vert->col & IM_COL32_A_MASK); + } +} + +// Scan and shade backward from the end of given vertices. Assume vertices are text only (= vert_start..vert_end going left to right) so we can break as soon as we are out the gradient bounds. +void ImGui::ShadeVertsLinearAlphaGradientForLeftToRightText(ImDrawVert* vert_start, ImDrawVert* vert_end, float gradient_p0_x, float gradient_p1_x) +{ + float gradient_extent_x = gradient_p1_x - gradient_p0_x; + float gradient_inv_length2 = 1.0f / (gradient_extent_x * gradient_extent_x); + int full_alpha_count = 0; + for (ImDrawVert* vert = vert_end - 1; vert >= vert_start; vert--) + { + float d = (vert->pos.x - gradient_p0_x) * (gradient_extent_x); + float alpha_mul = 1.0f - ImClamp(d * gradient_inv_length2, 0.0f, 1.0f); + if (alpha_mul >= 1.0f && ++full_alpha_count > 2) + return; // Early out + int a = (int)(((vert->col >> IM_COL32_A_SHIFT) & 0xFF) * alpha_mul); + vert->col = (vert->col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT); + } +} + +// Distribute UV over (a, b) rectangle +void ImGui::ShadeVertsLinearUV(ImDrawVert* vert_start, ImDrawVert* vert_end, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp) +{ + const ImVec2 size = b - a; + const ImVec2 uv_size = uv_b - uv_a; + const ImVec2 scale = ImVec2( + size.x != 0.0f ? (uv_size.x / size.x) : 0.0f, + size.y != 0.0f ? (uv_size.y / size.y) : 0.0f); + + if (clamp) + { + const ImVec2 min = ImMin(uv_a, uv_b); + const ImVec2 max = ImMax(uv_a, uv_b); + + for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex) + vertex->uv = ImClamp(uv_a + ImMul(ImVec2(vertex->pos.x, vertex->pos.y) - a, scale), min, max); + } + else + { + for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex) + vertex->uv = uv_a + ImMul(ImVec2(vertex->pos.x, vertex->pos.y) - a, scale); + } +} + +//----------------------------------------------------------------------------- +// ImFontConfig +//----------------------------------------------------------------------------- + +ImFontConfig::ImFontConfig() +{ + FontData = NULL; + FontDataSize = 0; + FontDataOwnedByAtlas = true; + FontNo = 0; + SizePixels = 0.0f; + OversampleH = 3; + OversampleV = 1; + PixelSnapH = false; + GlyphExtraSpacing = ImVec2(0.0f, 0.0f); + GlyphOffset = ImVec2(0.0f, 0.0f); + GlyphRanges = NULL; + MergeMode = false; + RasterizerFlags = 0x00; + RasterizerMultiply = 1.0f; + memset(Name, 0, sizeof(Name)); + DstFont = NULL; +} + +//----------------------------------------------------------------------------- +// ImFontAtlas +//----------------------------------------------------------------------------- + +// A work of art lies ahead! (. = white layer, X = black layer, others are blank) +// The white texels on the top left are the ones we'll use everywhere in ImGui to render filled shapes. +const int FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF = 90; +const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27; +const unsigned int FONT_ATLAS_DEFAULT_TEX_DATA_ID = 0x80000000; +static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * FONT_ATLAS_DEFAULT_TEX_DATA_H + 1] = +{ + "..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX" + "..- -X.....X- X.X - X.X -X.....X - X.....X" + "--- -XXX.XXX- X...X - X...X -X....X - X....X" + "X - X.X - X.....X - X.....X -X...X - X...X" + "XX - X.X -X.......X- X.......X -X..X.X - X.X..X" + "X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X" + "X..X - X.X - X.X - X.X -XX X.X - X.X XX" + "X...X - X.X - X.X - XX X.X XX - X.X - X.X " + "X....X - X.X - X.X - X.X X.X X.X - X.X - X.X " + "X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X " + "X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X " + "X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X " + "X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X " + "X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X " + "X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X " + "X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X " + "X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX " + "X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------" + "X.X X..X - -X.......X- X.......X - XX XX - " + "XX X..X - - X.....X - X.....X - X.X X.X - " + " X..X - X...X - X...X - X..X X..X - " + " XX - X.X - X.X - X...XXXXXXXXXXXXX...X - " + "------------ - X - X -X.....................X- " + " ----------------------------------- X...XXXXXXXXXXXXX...X - " + " - X..X X..X - " + " - X.X X.X - " + " - XX XX - " +}; + +static const ImVec2 FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[ImGuiMouseCursor_Count_][3] = +{ + // Pos ........ Size ......... Offset ...... + { ImVec2(0,3), ImVec2(12,19), ImVec2( 0, 0) }, // ImGuiMouseCursor_Arrow + { ImVec2(13,0), ImVec2(7,16), ImVec2( 4, 8) }, // ImGuiMouseCursor_TextInput + { ImVec2(31,0), ImVec2(23,23), ImVec2(11,11) }, // ImGuiMouseCursor_Move + { ImVec2(21,0), ImVec2( 9,23), ImVec2( 5,11) }, // ImGuiMouseCursor_ResizeNS + { ImVec2(55,18),ImVec2(23, 9), ImVec2(11, 5) }, // ImGuiMouseCursor_ResizeEW + { ImVec2(73,0), ImVec2(17,17), ImVec2( 9, 9) }, // ImGuiMouseCursor_ResizeNESW + { ImVec2(55,0), ImVec2(17,17), ImVec2( 9, 9) }, // ImGuiMouseCursor_ResizeNWSE +}; + + +ImFontAtlas::ImFontAtlas() +{ + TexID = NULL; + TexDesiredWidth = 0; + TexGlyphPadding = 1; + TexPixelsAlpha8 = NULL; + TexPixelsRGBA32 = NULL; + TexWidth = TexHeight = 0; + TexUvWhitePixel = ImVec2(0, 0); + for (int n = 0; n < IM_ARRAYSIZE(CustomRectIds); n++) + CustomRectIds[n] = -1; +} + +ImFontAtlas::~ImFontAtlas() +{ + Clear(); +} + +void ImFontAtlas::ClearInputData() +{ + for (int i = 0; i < ConfigData.Size; i++) + if (ConfigData[i].FontData && ConfigData[i].FontDataOwnedByAtlas) + { + //ImGui::MemFree(ConfigData[i].FontData); + ConfigData[i].FontData = NULL; + } + + // When clearing this we lose access to the font name and other information used to build the font. + for (int i = 0; i < Fonts.Size; i++) + if (Fonts[i]->ConfigData >= ConfigData.Data && Fonts[i]->ConfigData < ConfigData.Data + ConfigData.Size) + { + Fonts[i]->ConfigData = NULL; + Fonts[i]->ConfigDataCount = 0; + } + ConfigData.clear(); + CustomRects.clear(); + for (int n = 0; n < IM_ARRAYSIZE(CustomRectIds); n++) + CustomRectIds[n] = -1; +} + +void ImFontAtlas::ClearTexData() +{ + if (TexPixelsAlpha8) + ImGui::MemFree(TexPixelsAlpha8); + if (TexPixelsRGBA32) + ImGui::MemFree(TexPixelsRGBA32); + TexPixelsAlpha8 = NULL; + TexPixelsRGBA32 = NULL; +} + +void ImFontAtlas::ClearFonts() +{ + for (int i = 0; i < Fonts.Size; i++) + IM_DELETE(Fonts[i]); + Fonts.clear(); +} + +void ImFontAtlas::Clear() +{ + ClearInputData(); + ClearTexData(); + ClearFonts(); +} + +void ImFontAtlas::GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_BYTEs_per_pixel) +{ + // Build atlas on demand + if (TexPixelsAlpha8 == NULL) + { + if (ConfigData.empty()) + AddFontDefault(); + Build(); + } + + *out_pixels = TexPixelsAlpha8; + if (out_width) *out_width = TexWidth; + if (out_height) *out_height = TexHeight; + if (out_BYTEs_per_pixel) *out_BYTEs_per_pixel = 1; +} + +void ImFontAtlas::GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_BYTEs_per_pixel) +{ + // Convert to RGBA32 format on demand + // Although it is likely to be the most commonly used format, our font rendering is 1 channel / 8 bpp + if (!TexPixelsRGBA32) + { + unsigned char* pixels = NULL; + GetTexDataAsAlpha8(&pixels, NULL, NULL); + if (pixels) + { + TexPixelsRGBA32 = (unsigned int*)ImGui::MemAlloc((size_t)(TexWidth * TexHeight * 4)); + const unsigned char* src = pixels; + unsigned int* dst = TexPixelsRGBA32; + for (int n = TexWidth * TexHeight; n > 0; n--) + *dst++ = IM_COL32(255, 255, 255, (unsigned int)(*src++)); + } + } + + *out_pixels = (unsigned char*)TexPixelsRGBA32; + if (out_width) *out_width = TexWidth; + if (out_height) *out_height = TexHeight; + if (out_BYTEs_per_pixel) *out_BYTEs_per_pixel = 4; +} + +ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg) +{ + IM_ASSERT(font_cfg->FontData != NULL && font_cfg->FontDataSize > 0); + IM_ASSERT(font_cfg->SizePixels > 0.0f); + + // Create new font + if (!font_cfg->MergeMode) + Fonts.push_back(IM_NEW(ImFont)); + else + IM_ASSERT(!Fonts.empty()); // When using MergeMode make sure that a font has already been added before. You can use ImGui::GetIO().Fonts->AddFontDefault() to add the default imgui font. + + ConfigData.push_back(*font_cfg); + ImFontConfig& new_font_cfg = ConfigData.back(); + if (!new_font_cfg.DstFont) + new_font_cfg.DstFont = Fonts.back(); + if (!new_font_cfg.FontDataOwnedByAtlas) + { + new_font_cfg.FontData = ImGui::MemAlloc(new_font_cfg.FontDataSize); + new_font_cfg.FontDataOwnedByAtlas = true; + memcpy(new_font_cfg.FontData, font_cfg->FontData, (size_t)new_font_cfg.FontDataSize); + } + + // Invalidate texture + ClearTexData(); + return new_font_cfg.DstFont; +} + +// Default font TTF is compressed with stb_compress then base85 encoded (see extra_fonts/binary_to_compressed_c.cpp for encoder) +static unsigned int stb_decompress_length(unsigned char *input); +static unsigned int stb_decompress(unsigned char *output, unsigned char *i, unsigned int length); +static const char* GetDefaultCompressedFontDataTTFBase85(); +static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; } +static void Decode85(const unsigned char* src, unsigned char* dst) +{ + while (*src) + { + unsigned int tmp = Decode85Byte(src[0]) + 85*(Decode85Byte(src[1]) + 85*(Decode85Byte(src[2]) + 85*(Decode85Byte(src[3]) + 85*Decode85Byte(src[4])))); + dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianness. + src += 5; + dst += 4; + } +} + + +static const unsigned int verdana_compressed_size = 141828; +static const unsigned int verdana_compressed_data[141828 / 4] = +{ + 0x0000bc57, 0x00000000, 0x18df0200, 0x00000400, 0x00010025, 0x82160000, 0x00043e04, 0x49534460, 0x3c176547, 0xc7020011, 0x1700009c, 0x4544477c, + 0x03260046, 0xc60200bc, 0x282582b0, 0x4f50471e, 0x0e370753, 0x200f823c, 0x280f82d0, 0x55534738, 0xe824e442, 0x202f8226, 0x3c0f8208, 0x53544c94, + 0xe494df48, 0x1100006d, 0x03000024, 0x2f534fbb, 0x7b537232, 0x0100001c, 0x271f82e8, 0x4d445660, 0x7cf17458, 0x21081f82, 0x0000e014, 0x6d63e005, + 0x197d7061, 0x00004d4e, 0x00008c8e, 0x76637607, 0xa24c2074, 0x00000241, 0x3382bc9b, 0x70669838, 0xcea46d67, 0x0000516d, 0x00000496, 0x6167ba02, + 0x17007073, 0x7f820900, 0x00a02b08, 0x67100000, 0x1966796c, 0x009ad935, 0x00c4a400, 0x688eeb01, 0x0a786d64, 0x00ecc839, 0x00c01a00, 0x68cc7300, + 0xd9646165, 0xdc82595c, 0x826c0121, 0x6836212f, 0x0f271082, 0x00a70b27, 0x82a40100, 0x6824280f, 0xee78746d, 0x824386f4, 0x00483f5b, 0x6bdc0e00, + 0x756e7265, 0x00537ebf, 0x00549002, 0x6c960c00, 0x0f61636f, 0x00158735, 0x0f829d00, 0x6d700729, 0x06707861, 0x82dd0237, 0x82c8203f, 0x6e202b3f, + 0xce656d61, 0x00aab906, 0x73829c02, 0x708f093c, 0xb674736f, 0x00379301, 0x007ca602, 0x70232000, 0x08706572, 0x0040ef70, 0x8f829800, 0x00fc0223, + 0x2e358201, 0x411f0505, 0x5fff09d5, 0x00f53c0f, 0x8300081b, 0x7eaa2300, 0x07832944, 0xc491c82b, 0xfd86fbc0, 0x08930b93, 0x820f8268, 0x830582e7, + 0x23378202, 0x52fe0b08, 0x2c209382, 0x71221f82, 0x4984930b, 0x03861983, 0x83b70321, 0x36058211, 0x00070078, 0x0005006b, 0x00100002, 0x0056002f, + 0x010a0200, 0x820300c8, 0x0402241d, 0x82900111, 0x05082819, 0x0033059a, 0x85250100, 0xa0033907, 0xa7027800, 0x0b020008, 0x05030406, 0x04020404, + 0xff0600a1, 0x5b200040, 0x10205a82, 0x00250382, 0x2020534d, 0x2f108200, 0x1e06fdff, 0xca0059fe, 0xae010b08, 0x9f010020, 0x04231b83, 0x82d1055d, + 0x200e8207, 0x24928608, 0x0000d002, 0x3f038202, 0x23012603, 0xa800ac03, 0xc3008c06, 0x9b001605, 0x95009c08, 0x7300d005, 0xa4002602, 0xb500a203, + 0x93200382, 0xa7201782, 0xd2241f82, 0x9300e902, 0x99200f82, 0xfd240782, 0xe2ffa203, 0x89241782, 0x16011605, 0xa1200782, 0xa7200382, 0x4d200382, + 0xbb200382, 0x00211785, 0x2007829a, 0x2403827a, 0x01a20371, 0x2037825a, 0x204382e6, 0x3a0382fe, 0x018c06f5, 0x005d040c, 0x000008a0, 0x007805b0, + 0x007c051a, 0x009605c8, 0x822a0673, 0x000f2807, 0x009904c8, 0x823406c8, 0x0003300f, 0x005e03c8, 0x00a30389, 0x008b052c, 0x827404cd, 0x82be2017, + 0x82fc2023, 0x004c2407, 0x85d30473, 0x90052107, 0x782a1382, 0xee048600, 0xdb050000, 0x5383b200, 0x00e9072b, 0x007b055c, 0x00ec0444, 0x20078206, + 0x207f827e, 0x200382ef, 0x20038246, 0x248382ab, 0xff1605ba, 0x2cbb82fc, 0x00ce0454, 0x00fc0468, 0x002b04b9, 0x26078269, 0x00c4046c, 0x82d0026a, + 0x00fc3237, 0x0010056c, 0x003202b9, 0xffc102af, 0x00bc04c2, 0x240b82c1, 0x00c807bb, 0x231783b9, 0x6a00db04, 0x27823784, 0x846a0321, 0x036e243f, + 0x823e0027, 0x82b1201b, 0x823d202b, 0x82562063, 0x823c2007, 0x043d2c03, 0x055d0034, 0x03ad0014, 0x827a01a2, 0x82bb2007, 0x84bb201b, 0x82fb83f7, + 0x820520f7, 0x850520f3, 0x837020d3, 0x209384bf, 0x8f9782ce, 0x20a38303, 0x8a7782c4, 0x24938203, 0xff3202a0, 0x200382eb, 0x200b82f5, 0x839b8805, + 0x82038a9f, 0x8cb12017, 0x00162a03, 0x005604bb, 0x0016059a, 0x06af419f, 0x5d04ac22, 0x162adb82, 0xf6048900, 0x0008b900, 0x03839f00, 0x00d0072b, + 0x021605aa, 0x0116051d, 0x28b7825a, 0x00e007f5, 0x004c060e, 0x201b8273, 0x200f82a1, 0x05d341d7, 0x820c0121, 0x056c2443, 0x82be0022, 0x05952307, + 0xe38300d1, 0xa9059024, 0x0f827100, 0x57828a20, 0x03829720, 0x2b827920, 0xa4076b22, 0xdb22d782, 0x0f825d00, 0x26037124, 0x13822301, 0x0382d220, + 0x16058624, 0x0782dcff, 0x3b82f320, 0x28053224, 0x0382a600, 0x0f82ae20, 0x2741b220, 0x26738407, 0x0778008f, 0x826a00da, 0x82992053, 0x0399307f, + 0x03edffac, 0x029600ac, 0x02edff26, 0x86a00026, 0x04ac2b4b, 0x043d00bc, 0x020600ec, 0xdf83ffe4, 0xa2030024, 0x0382ba00, 0x0005c226, 0x02054400, + 0xfb820382, 0x00e90223, 0x203782fd, 0x244382f6, 0x002c0cf6, 0x22678495, 0x88c8000f, 0x230b8207, 0x89005e03, 0x5d200382, 0x7e200382, 0x89200382, + 0x03878383, 0x00db0523, 0x270387b2, 0xbb003202, 0x36011605, 0xed209782, 0x18200782, 0x13240382, 0x21021605, 0x2d200782, 0x61200382, 0x56200382, + 0x9f200382, 0x32280382, 0x18007e04, 0x18004602, 0x86386782, 0x6e002b04, 0x7e007b05, 0x5d003404, 0x7a01a203, 0x0e003406, 0x6a00e504, 0xc384bb83, + 0xc800d826, 0xb900fc04, 0xdc26d782, 0x23018c06, 0x03835604, 0x04cf0025, 0x82cf0056, 0x86ab20ff, 0x828c2003, 0x823c2077, 0x8273203b, 0x836c202b, + 0x225b88a7, 0x82730096, 0x05692163, 0x1f830786, 0xff160523, 0x82fb83fc, 0x041a2423, 0x876800ce, 0x2a062107, 0x2e22fb82, 0x47826c00, 0x82050e21, + 0xc40423fb, 0x07876a00, 0x00740423, 0x20e382c8, 0x220784ab, 0x83bb005e, 0xab032107, 0xfc20f382, 0x10233382, 0x8605b900, 0x4c062107, 0xdb206f82, + 0x90243782, 0x6a03c800, 0x07851782, 0x8f879220, 0x00ee0427, 0x00270300, 0x2707873e, 0xb200db05, 0xb1001005, 0x0b410788, 0x07134106, 0x43880421, + 0x062105df, 0x069b438d, 0x6a00dd30, 0x6d001a04, 0x6a000b05, 0x0a00f803, 0xbf825206, 0x0429cf82, 0x042301ff, 0x099a005d, 0x082f824f, 0x8900f722, + 0xaf00e904, 0x0000d805, 0xd500e402, 0xd5007504, 0x95009c08, 0x0f009602, 0x9200d504, 0x8300d602, 0x0b820383, 0x0782b120, 0x07417020, 0x0e2b4108, + 0x870f0341, 0x0767410f, 0x03200790, 0x23050b41, 0x20000306, 0x1328d382, 0x2c005e03, 0xf2ff3202, 0x5f200782, 0xfc200782, 0x80240782, 0x01003202, + 0x89200782, 0x8e220782, 0x1f82a303, 0xc2ffc12a, 0xcd008b05, 0xc100bc04, 0x67410384, 0x41052005, 0x5741074f, 0x0e5f410f, 0x57411b20, 0x104f410f, + 0xb200db24, 0x5f410b05, 0x27078206, 0x5c00e907, 0x56008c06, 0x23075f42, 0xb9006702, 0x0727ff87, 0x070e00e0, 0x866800a4, 0x035d2463, 0x875a01a2, + 0x88078f2f, 0xff262e3f, 0xff1605ed, 0x001605d0, 0x00be0589, 0x078f42b1, 0x8a200782, 0x99240382, 0x6100b001, 0x2105ff42, 0x07821202, 0x6b820020, + 0x0206072e, 0xf6060000, 0x51040000, 0x0c070000, 0x07200b82, 0x43260782, 0x32020000, 0x0b46cbff, 0x00a02b08, 0x000f051a, 0x007b05c8, 0x0346067e, + 0x8b052806, 0x7c05cd00, 0x45061a00, 0x052306ff, 0x83720031, 0x211f83ab, 0x2b82d304, 0x76006124, 0x5782ee04, 0x2c05ef45, 0x00f70644, 0x008c06b3, + 0x005e036c, 0x3caf847e, 0x046c00fc, 0x056d001a, 0x02b90010, 0x05a00032, 0x04b1000d, 0x04b900f6, 0x033d00bc, 0x05eb45a9, 0x00fe0423, 0x201b8289, + 0x201382bb, 0x220382c1, 0x851e053d, 0x0604291f, 0xdb046800, 0x00056a00, 0x10220f82, 0x3b846900, 0x3000b82a, 0xb0009306, 0x71008206, 0x05203382, + 0x23831384, 0x13835782, 0x0625bf83, 0x04ffff57, 0x229b8288, 0x8273009b, 0x828620db, 0x8289208b, 0x037e2903, 0x082c00a3, 0x081200f2, 0x0623b782, + 0x83ffff8b, 0x83a383db, 0x080341cb, 0xc8007c22, 0xf7223b84, 0x4b830a00, 0x00c9072b, 0x00ed0420, 0x00010651, 0x830383c8, 0xe0052533, 0xbe061200, + 0x03200f82, 0x82062743, 0x82042007, 0x96052353, 0x0b417300, 0x8d062107, 0x7b24af82, 0x17064400, 0xb2288782, 0x3e088e00, 0x5c08c800, 0x44242f82, + 0x5d070000, 0x72201382, 0x9c240382, 0x46086100, 0xa6240782, 0xce042c00, 0xea28eb82, 0xc2047400, 0xc503b900, 0xf932ef82, 0xc4040900, 0x62066a00, + 0x32043400, 0x1f054100, 0x0383b900, 0x00bc0429, 0x00f704c1, 0x8292051d, 0x8219200f, 0x83fb8327, 0x82fc2007, 0x4346200b, 0x2382059f, 0xba063d24, + 0x07826f00, 0x28053c22, 0xd8281782, 0x02078e00, 0x1a07b900, 0x20243382, 0x5b060a00, 0x91201382, 0x60240382, 0xb6065300, 0xcc220782, 0x6b834300, + 0x00100523, 0x2a7b8413, 0x046a0060, 0x026e002b, 0x82af0032, 0x02052803, 0x07c2ffc1, 0x821d0050, 0x83b92003, 0x08a74123, 0x88227783, 0x3383c800, + 0x00000825, 0x826009cb, 0x261383cb, 0x04190156, 0x82ef0056, 0x82e62003, 0x86b32003, 0x82f32007, 0x00c52107, 0x0621008e, 0x05bb4474, 0x000d062b, + 0x004705b2, 0xfd0000b1, 0x24038244, 0xfc000017, 0x2007827c, 0x06df4509, 0x07850320, 0x82250121, 0x8a422007, 0x200f8203, 0x20238602, 0x83178b01, + 0x4536200b, 0x0f8d0f6b, 0x8de3ff21, 0x4500200f, 0x17a80893, 0x440eaf45, 0x292412bb, 0xfcffc404, 0xc82c1792, 0x6a00c404, 0x89005e03, 0xab003202, + 0xaf240786, 0x73000a06, 0x04301783, 0x030e0088, 0x071300c5, 0x062000c9, 0x05340062, 0x8706ab44, 0x03062107, 0x24066741, 0x040600ec, 0x057347bc, + 0x05230783, 0x8244007b, 0x053c2807, 0x048e00b2, 0x828e00d8, 0x05c82407, 0x87b90010, 0x08c74457, 0x17821382, 0x1605002b, 0xac039900, 0x7504edff, + 0x240b8300, 0x00960566, 0x33038373, 0xb900c807, 0x3400fc05, 0xc8005509, 0x5c00e907, 0x9700ae06, 0x343c7b82, 0x0000ee04, 0x29000008, 0x05002b04, + 0x4800d304, 0xf5008c06, 0xc8007c05, 0xbe005604, 0x100ed641, 0x40020e00, 0x9507ab42, 0xe5ff2107, 0x00211795, 0x084f446a, 0x96075744, 0x0fb34707, + 0x9f077f44, 0x08234a07, 0x880e7b43, 0x00fc3617, 0xfc00006c, 0x0016050b, 0x0007098a, 0xffab056e, 0x02ab05e9, 0x8703857e, 0xe9ff2d0b, 0x25000004, + 0x73003406, 0x1a007805, 0x2e220382, 0x0b849605, 0x2b048624, 0xa7496e00, 0x32023307, 0xe902a400, 0x0106c400, 0x1f05c800, 0x0000b900, 0x038271fd, + 0x8009af30, 0x52087300, 0xde076a00, 0x82067300, 0x6b827200, 0x4c06de26, 0xef047300, 0x07271382, 0x83051b00, 0x86071400, 0x82178407, 0x48072093, + 0x05210683, 0x2347836c, 0x250686fb, 0x2c2e6f82, 0x73083d00, 0x00075c00, 0x92035600, 0x0383ab00, 0x00210223, 0x2d0387b2, 0x4c011605, 0x5a01a203, + 0xc8004204, 0x8b822602, 0x062f0382, 0x05a40203, 0x01360219, 0x07000068, 0x8279006c, 0x0036387b, 0x01b70300, 0x301c1c01, 0x0e0b0e0e, 0x01010a01, + 0x0f010e0e, 0x880b0101, 0x3d118300, 0x320c0b0e, 0x2319100e, 0x740f0e15, 0x242d0e0a, 0x0d0d0d0e, 0x1d2c320e, 0x111c2e32, 0x0084011c, 0x21081082, + 0x0d1c0d0d, 0x0e01b40b, 0x100b11b4, 0x112a0d0d, 0x100a0b11, 0x01110a0f, 0x3201010e, 0x0e231032, 0x36821d0d, 0x3d830282, 0x82b40d21, 0x100b2100, + 0x69840083, 0x74827082, 0x01234984, 0x820d330e, 0x010e2285, 0x200e8310, 0x2504820b, 0x300b100e, 0x0982010e, 0x82272721, 0x010d2249, 0x830a821c, + 0x82012016, 0x8432845c, 0x2332250f, 0x74232332, 0x62820082, 0x1d1d1d23, 0x841984b4, 0xd70a2a04, 0x111c1132, 0x1101100e, 0x84a6820a, 0x29048212, + 0x32740d0e, 0x100e1011, 0x9f820d0e, 0x0d320d3c, 0x23100d19, 0x2d0d230d, 0x2d322db4, 0x0e0b0e01, 0x0e100d0b, 0x322a0e2a, 0x01822c11, 0x1d0b1d23, + 0x3beb820b, 0x130d1011, 0x1812260d, 0x0d011011, 0x110a0a01, 0x0a24010e, 0x01011912, 0x0d320119, 0x40834a83, 0x0e0d2322, 0x0f250184, 0x740b0f0b, + 0x200185b4, 0x21d0830a, 0x5585b42d, 0x55842982, 0x1d275383, 0x2e181d49, 0x820a1110, 0x0e33263f, 0x2e01100d, 0x82018310, 0x82ee830f, 0x822e20a4, + 0x0e323803, 0x0c16101c, 0x0e32b427, 0x0f1c2301, 0x240a0e74, 0x0f0d300e, 0x822c1e0d, 0x143308d4, 0x120d1174, 0x0b0bb40b, 0x0d0b0d0f, 0x130a0db4, + 0x1010010a, 0x100c0b01, 0x100bb410, 0x0a23100b, 0x74320d10, 0x0e0c0a74, 0x11110e01, 0x100e0e32, 0x83112301, 0x2412228b, 0x0842820f, 0x112c1030, + 0x222d1c13, 0x2d1f1111, 0x10010d0e, 0x010a240d, 0x12300d0d, 0x010b1010, 0x1010101d, 0x0a110f0d, 0x0d270f17, 0x110c3211, 0x0a0d0e0c, 0x45820b0d, + 0x01b4b42b, 0x0b0b0e0a, 0x0a10100a, 0x05a24101, 0x23065041, 0x2028102d, 0x88097341, 0x0d322109, 0x2a410195, 0x23058905, 0xb474b474, 0x30205084, + 0x11293a85, 0x1c01010f, 0x22012201, 0x200f820b, 0x2092830f, 0x26088224, 0x2e2e0301, 0x922c0101, 0x86124067, 0x8b100d21, 0x102d2101, 0x1d250187, + 0x280b1d0b, 0x21018720, 0x01850a11, 0x0b010d22, 0xbc83d584, 0x0132322a, 0x112c1132, 0x100e01b4, 0x0d24cb8c, 0x2e102e0d, 0x1d211184, 0x2206841d, + 0x820a0120, 0x0b082207, 0x21008200, 0x12840001, 0x000c002f, 0x00ff08f8, 0xff080008, 0x000900fe, 0x2005820a, 0x2205840a, 0x820b000b, 0x000c220b, + 0x2805820c, 0xff0d000d, 0x000e00fd, 0x2205820e, 0x820f000f, 0x84102005, 0x00112205, 0x280b8211, 0xff120012, 0x001300fc, 0x22058213, 0x82150014, + 0x84152005, 0x00162205, 0x280b8216, 0xff170017, 0x001800fb, 0x22058218, 0x821a0019, 0x001a2205, 0x2005821b, 0x2805841b, 0xff1c001c, 0x001d00fa, + 0x2205821d, 0x821e001e, 0x001f2205, 0x20058220, 0x28058420, 0xff210021, 0x002200f9, 0x22058222, 0x82230023, 0x00242205, 0x22058225, 0x82260025, + 0x82262005, 0x00f82a05, 0xff270027, 0x002800f8, 0x22058228, 0x82290029, 0x002a2205, 0x2005822b, 0x2a05822b, 0x002c00f7, 0x00f7ff2c, 0x822d002d, + 0x002e2205, 0x2205822e, 0x8230002f, 0x00302605, 0x00f6ff31, 0x22058431, 0x82320032, 0x0033220b, 0x22058233, 0x82340034, 0x00352605, 0x00f5ff36, + 0x22058436, 0x82370037, 0x0038220b, 0x22058238, 0x82390039, 0x003a2805, 0x00f4ff3b, 0x823c003b, 0x003c2205, 0x2005823d, 0x2205843d, 0x823e003e, + 0x003f280b, 0x00f3ff3f, 0x82410040, 0x84412005, 0x00422205, 0x220b8242, 0x82430043, 0x00442805, 0x00f2ff44, 0x82460045, 0x00462205, 0x20058247, + 0x22058447, 0x82480048, 0x0049280b, 0x00f1ff49, 0x824a004a, 0x004b2205, 0x2205824c, 0x824d004c, 0x844d2005, 0x004e2805, 0x00f0ff4e, 0x824f004f, + 0x00502205, 0x22058251, 0x82520051, 0x82522005, 0x00ef2a05, 0xff530053, 0x005400ef, 0x22058254, 0x82550055, 0x00562205, 0x26058257, 0xff580057, + 0x845800ee, 0x00592205, 0x220b8259, 0x825a005a, 0x005b2205, 0x2605825c, 0xff5d005c, 0x845d00ec, 0x005e2205, 0x220b825e, 0x825f005f, 0x00602205, + 0x26058260, 0xff620061, 0x846200eb, 0x00632205, 0x220b8263, 0x82640064, 0x00652205, 0x28058265, 0xff670066, 0x006700ea, 0x20058268, 0x22058468, + 0x82690069, 0x006a220b, 0x2805826a, 0xff6b006b, 0x006c00e9, 0x2005826d, 0x2205846d, 0x826e006e, 0x006f220b, 0x2805826f, 0xff700070, 0x007100e8, + 0x20058272, 0x22058472, 0x82730073, 0x0074220b, 0x28058274, 0xff750075, 0x007600e7, 0x22058276, 0x82780077, 0x84782005, 0x00792205, 0x280b8279, + 0xff7a007a, 0x007b00e6, 0x2205827b, 0x827d007c, 0x847d2005, 0x007e2205, 0x280b827e, 0xff7f007f, 0x008000e5, 0x22058280, 0x82820081, 0x00822205, + 0x20058283, 0x28058483, 0xff840084, 0x008500e4, 0x22058285, 0x82860086, 0x00872205, 0x20058288, 0x28058488, 0xff890089, 0x008a00e3, 0x2205828a, + 0x828b008b, 0x008c2205, 0x2205828d, 0x828e008d, 0x828e2005, 0x00e22a05, 0xff8f008f, 0x009000e2, 0x22058290, 0x82910091, 0x00922205, 0x20058293, + 0x2a058293, 0x009400e1, 0x00e1ff94, 0x82950095, 0x00962205, 0x22058296, 0x82980097, 0x00982605, 0x00e0ff99, 0x22058499, 0x829b009a, 0x849b200b, + 0x009c2205, 0x260b829c, 0xff9e009d, 0x849e00df, 0x009f2205, 0x200b82a0, 0x220584a0, 0x82a100a1, 0x00a2280b, 0x00deffa3, 0x82a400a3, 0x84a42005, + 0x00a52205, 0x200b82a6, 0x280584a6, 0xffa700a7, 0x00a800dd, 0x200582a9, 0x220584a9, 0x82ab00aa, 0x84ab200b, 0x00ac2805, 0x00dcffac, 0x82ae00ad, + 0x00ae2205, 0x220582af, 0x82b000af, 0x84b02005, 0x00b12805, 0x00dbffb1, 0x82b200b2, 0x00b32205, 0x220582b4, 0x82b500b4, 0x00b52205, 0x200582b6, + 0x2a0582b6, 0x00b700da, 0x00daffb7, 0x82b900b8, 0x00b92205, 0x220582ba, 0x82bb00ba, 0x82bb2005, 0x00d92a05, 0xffbc00bc, 0x00bd00d9, 0x220582bd, + 0x82bf00be, 0x00bf2205, 0x260582c0, 0xffc100c0, 0x84c100d8, 0x00c22205, 0x220b82c2, 0x82c400c3, 0x00c42205, 0x200582c5, 0x2a0582c5, 0x00c600d7, + 0x00d7ffc6, 0x82c700c7, 0x00c82205, 0x220582c8, 0x82ca00c9, 0x00ca2805, 0x00d6ffcb, 0x82cc00cb, 0x84cc2005, 0x00cd2205, 0x220b82cd, 0x82cf00ce, + 0x00cf2605, 0x00d5ffd0, 0x220584d0, 0x82d100d1, 0x00d2220b, 0x220582d2, 0x82d300d3, 0x00d42305, 0x0382ffd5, 0xd6220584, 0x0b82d700, 0x0584d720, + 0xd800d822, 0xd9280b82, 0xd3ffda00, 0xdb00da00, 0xdb220582, 0x0582dc00, 0x0584dc20, 0xdd00dd22, 0xde280b82, 0xd2ffde00, 0xe000df00, 0xe0200582, + 0xe1220584, 0x0b82e200, 0x0584e220, 0xe300e328, 0xe400d1ff, 0x0582e500, 0xe600e522, 0xe6220582, 0x0582e700, 0x0584e720, 0xe800e828, 0xe900d0ff, + 0x0582e900, 0xeb00ea22, 0xeb200582, 0xec220584, 0x0b82ec00, 0xed00ed28, 0xee00cfff, 0x0582ee00, 0xf000ef22, 0xf0220582, 0x0582f100, 0xf200f122, + 0xf2200582, 0xce2a0582, 0xf300f300, 0xf400ceff, 0x0582f400, 0xf600f522, 0xf6220582, 0x0582f700, 0x0582f720, 0xf800cd2a, 0xcdfff800, 0xf900f900, + 0xfa220582, 0x0582fb00, 0xfc00fb28, 0xfc00ccff, 0x0582fd00, 0xfe00fd22, 0xfe200582, 0xff220584, 0x0b82ff00, 0x1f00003a, 0xbc030000, 0x00090e09, + 0x05050303, 0x070b0707, 0x07040403, 0x03050307, 0x07200582, 0x11830086, 0x0a06072a, 0x08080708, 0x08080607, 0x06292782, 0x07090809, 0x07070709, + 0x22078208, 0x82040707, 0x85062021, 0x06032700, 0x06030306, 0x0d830903, 0x04060428, 0x06070606, 0x01820506, 0x3f822982, 0x85080921, 0x20058425, + 0x89008203, 0x0507290e, 0x05060707, 0x09090607, 0x07253b82, 0x0709090a, 0x203a8207, 0x23048206, 0x07050507, 0x05201382, 0x06218d84, 0x21498206, + 0x7d820a09, 0x02040423, 0x231d8302, 0x04040603, 0x03231582, 0x820e0402, 0x82072061, 0x0505212d, 0x08244482, 0x06030808, 0x03220089, 0x19820607, + 0x82060821, 0x20538206, 0x23228405, 0x05060806, 0x0682d082, 0x0820b482, 0x03820682, 0x06201f83, 0x0621c082, 0x240c8204, 0x07060906, 0x84018204, + 0x250f8305, 0x05070507, 0xd2850906, 0xd8820920, 0x20820b20, 0x0b050325, 0x82030503, 0x84418502, 0x844b8560, 0x82052005, 0x82038519, 0x03062136, + 0x57845585, 0x32855582, 0x52820820, 0x1a830720, 0x0621f582, 0x20da8204, 0x21fc8207, 0xab820206, 0x092dc782, 0x06060602, 0x06090808, 0x03090809, + 0x275d8208, 0x07050807, 0x07080908, 0x06250282, 0x09070707, 0x20c38209, 0x22b28205, 0x82050506, 0x202c82c6, 0x25078206, 0x09050605, 0x0c820307, + 0x82070721, 0x05072563, 0x0a0a0505, 0x07222c82, 0x41830708, 0x50820920, 0x45833982, 0x22821082, 0x08214582, 0x20558209, 0x25318207, 0x07060604, + 0x00820605, 0x03820720, 0x4c820620, 0x0521ac82, 0x821d8209, 0x241e8586, 0x09030303, 0x22688409, 0x820b0905, 0x225d8276, 0x82000505, 0x20578200, + 0x20068206, 0x8a1b8300, 0x8fe58703, 0x41072007, 0x0588058d, 0x05030529, 0x05050703, 0x82070904, 0x82052075, 0x8305201d, 0x82038207, 0x22928390, + 0x82050407, 0x07092855, 0x0608090b, 0x82050906, 0x83758421, 0x8b034071, 0x95060921, 0x87fe8d01, 0x000623fc, 0x2b410a07, 0x21cf8205, 0x16820606, + 0x03030429, 0x00000608, 0x8209090b, 0x4206200c, 0x07200630, 0x06312782, 0x0404080a, 0x06020202, 0x03020504, 0x08020607, 0x33f68207, 0x000a0f0a, + 0x05040404, 0x070b0708, 0x07050503, 0x04050408, 0x20052a43, 0x28008307, 0x08080505, 0x070a0608, 0x22058207, 0x82080806, 0x09062220, 0x20018207, + 0x82118208, 0x07072231, 0x82218205, 0x05072c76, 0x07040707, 0x07030307, 0x82070b03, 0x06042200, 0x207d8204, 0x21998207, 0x2b830605, 0x09070622, + 0x51840682, 0x03200483, 0x5f840082, 0x05200485, 0x2c05bb43, 0x060a0a0a, 0x090a0806, 0x0808080a, 0x823e8206, 0x275d8231, 0x0406070a, 0x08070808, + 0x10824c82, 0x0a0b0926, 0x05050a07, 0x2282e382, 0x0506042a, 0x07060605, 0x0f050304, 0x06202e82, 0xbb430d82, 0x05062117, 0x07205184, 0x0520c283, + 0x08206783, 0x0624b182, 0x05080508, 0xd9425d82, 0x21208405, 0x01820306, 0x82070521, 0x07092500, 0x04080408, 0x04225682, 0x7d830407, 0x09226084, + 0x37820709, 0x82090521, 0x090c296a, 0x06040706, 0x0406030b, 0x0720eb83, 0x89424a83, 0x852c8305, 0x0abb4303, 0x06070723, 0x83558503, 0x82072057, + 0x2222853a, 0x850b0708, 0x0a0a261a, 0x0b050709, 0x82018307, 0x0706222a, 0x22a48207, 0x8206020a, 0x090726dd, 0x09090906, 0x203d8203, 0x22658206, + 0x82090707, 0x054b4102, 0x05090922, 0x1a838e83, 0x03200882, 0x06205582, 0x2f821084, 0x09211383, 0x06bb4306, 0x820b0b21, 0x8302822f, 0x0dbb4320, + 0x4d820920, 0x09281d82, 0x070a0807, 0x05060707, 0x05207782, 0x04826884, 0x05050723, 0x256b8206, 0x070a0906, 0x4a820608, 0x05070728, 0x03030606, + 0x14830903, 0x0a212b82, 0x4321820c, 0x072309bb, 0x82000708, 0x0ebb4300, 0x9105df41, 0x0eba4305, 0x03050724, 0x65820305, 0x080a0522, 0x8205b442, + 0x8222858c, 0x2017827b, 0x247b8306, 0x070a0707, 0x2420830c, 0x0806050a, 0x95bb4307, 0x94090721, 0x09134201, 0x83074a42, 0x000723e6, 0x1a410b07, + 0x08052105, 0x062e0783, 0x04030407, 0x00000708, 0x080a0a0c, 0x69430806, 0x32228305, 0x0b060800, 0x03040409, 0x05060303, 0x08030305, 0x82090206, + 0x0b003125, 0x04000b11, 0x09050404, 0x03080c07, 0x09070505, 0x2e0fbb43, 0x06090909, 0x0908080a, 0x09060709, 0x82050508, 0x82082051, 0x8208209f, + 0x0b082183, 0x05230482, 0x85090505, 0x04072577, 0x04030707, 0x2106bb43, 0x0d820605, 0x06211882, 0x82528207, 0x0807213d, 0x2007bb43, 0x12bb4306, + 0x03821383, 0x0b0b0b26, 0x0b090707, 0x6d820182, 0x32840720, 0x09060626, 0x0406070b, 0x3f830f82, 0x49820920, 0x070b0c23, 0x82c0830b, 0x23718212, + 0x07070505, 0x0521f182, 0x0f774711, 0x46092e42, 0xa58505f0, 0x09090725, 0x83060606, 0x07092167, 0x0621ca83, 0x20768209, 0x823b8304, 0x24c684d3, + 0x06030603, 0x21108505, 0x01820508, 0x64820620, 0x08242084, 0x06060806, 0x2e05b742, 0x07070905, 0x070a0d06, 0x0c060408, 0x82040704, 0x07082202, + 0x434a8409, 0x0922079e, 0x01820807, 0x8208bb43, 0x82072040, 0x83128286, 0x43558566, 0x4c8208bb, 0x07080327, 0x07090b0b, 0x82fa8305, 0x03072407, + 0x82080707, 0x020b21a4, 0xf2824f82, 0x090a0626, 0x08080309, 0x3a823182, 0x82090821, 0x8208206c, 0x08072718, 0x07050909, 0x2d830607, 0x08820720, + 0xbf840320, 0x10820720, 0x0320e582, 0x6b820c82, 0x08090628, 0x0d050505, 0x3d82090c, 0x06200282, 0x07206782, 0x43820782, 0x45820920, 0x07840720, + 0x090c0b26, 0x0b09070a, 0x05245283, 0x06090708, 0x24083941, 0x09070506, 0x25118207, 0x0709080a, 0x16820a07, 0xc4820520, 0x0a040323, 0x2268840b, + 0x470d0b05, 0x0622059d, 0x00820006, 0x06822983, 0xa6430020, 0x0db4420e, 0x268e0d89, 0x2405bb43, 0x0b050607, 0x84238509, 0x417c82df, 0x0d820589, + 0x07060527, 0x080b0808, 0x2420830d, 0x0907060b, 0x83758408, 0x8b034071, 0x2015b943, 0x85c88609, 0x890820da, 0x070022fb, 0x0698410c, 0x07830920, + 0x2208bb43, 0x830b0b0d, 0x080a2549, 0x0709080a, 0x00330a82, 0x0a0c0708, 0x03030505, 0x06050703, 0x07080303, 0x82070a02, 0x120c34f6, 0x0404000c, + 0x080a0605, 0x0503090d, 0x04090805, 0x83050405, 0x24038548, 0x09090505, 0x25618309, 0x07080909, 0x20820909, 0x090a0722, 0x0d825383, 0x430d0821, + 0x0a2105bb, 0x2a008208, 0x04080806, 0x04030808, 0x820b0307, 0x0508260d, 0x07080507, 0x29a5820b, 0x0a080508, 0x08090808, 0x9e840a09, 0x06080823, + 0x82008208, 0x82032085, 0x4b028706, 0x07290555, 0x080c0c0c, 0x0a0c0908, 0x05f74a0c, 0xe7826782, 0x080b0a24, 0x0a820507, 0x0a283f83, 0x0d0a0808, + 0x060c080d, 0x092ec082, 0x0407070a, 0x08050508, 0x03040808, 0x4a841206, 0x00820520, 0x0a0a0a23, 0x05ea4209, 0x08221284, 0xeb820708, 0x07434283, + 0x820a2005, 0x20678306, 0x23988209, 0x09060907, 0x7682b785, 0x9f840920, 0x07030725, 0x82060704, 0x0a0822ae, 0x24218208, 0x07070805, 0x207e8205, + 0x201c8208, 0x828c8507, 0x830720c0, 0x0a0e260d, 0x07040907, 0x06bb430d, 0x4a850820, 0x00820820, 0x03853c83, 0x210cbb43, 0x55850307, 0x07205784, + 0x11835385, 0x830b0d21, 0x0c0827c7, 0x05080a0b, 0x01830b0d, 0xb1820720, 0x82090821, 0x030c21a4, 0x0a244f84, 0x0b090b06, 0x08210a84, 0x22ee8209, + 0x8208090a, 0x248c8202, 0x050a0b08, 0x208e8207, 0x820b8203, 0x82e684c6, 0x08062307, 0x2e840b07, 0x82080b21, 0x050826a2, 0x0d0d0505, 0x22e0820a, + 0x82080808, 0x070d22b8, 0x21758209, 0x4282090a, 0x08070929, 0x0909080b, 0x82090e0d, 0x830c2006, 0x0806231e, 0x03820b08, 0x82070721, 0x0808250c, + 0x0b070706, 0x0b223182, 0x2983080c, 0x06271382, 0x03030708, 0x820b0b04, 0x0708246f, 0x420e0c06, 0x00200785, 0x0a240082, 0x00080908, 0x08200082, + 0x052500b5, 0x09030503, 0x22548207, 0x4407080a, 0x0721089b, 0x827e8209, 0x82072003, 0x83062053, 0x090c2904, 0x080a0c0e, 0x07060c07, 0x6c820582, + 0x21900240, 0x0195080a, 0x83091342, 0x07bc4309, 0x08000824, 0x0084090e, 0x7c420620, 0x05072905, 0x08090403, 0x0c0e0000, 0x0924e682, 0x0b080b07, + 0x0d344f82, 0x0900080b, 0x050b0d08, 0x03030305, 0x03060508, 0x02080903, 0x00261382, 0x0d140d00, 0x00820500, 0x0d080a2c, 0x06060309, 0x07050909, + 0x7f410605, 0x22118309, 0x820d0709, 0x825d8271, 0x0806241c, 0x83090b07, 0x8209209f, 0x820d2000, 0x06062303, 0x2e860b06, 0xbb430520, 0x2044820c, + 0x056f440b, 0x42090b21, 0x5589052e, 0xbb430820, 0x0d082814, 0x08080d0d, 0x830a0c09, 0x2b2c8257, 0x08090b09, 0x0b0b0707, 0x09050708, 0x092bc682, + 0x090b0808, 0x0d0e0a09, 0x83060d08, 0x080b25c0, 0x06080509, 0x08266682, 0x14060305, 0x1f820809, 0x2216bb43, 0x4d090709, 0x5d8205e2, 0x07070b23, + 0x22678307, 0x82050809, 0x82348316, 0x84068208, 0x0808213f, 0x820fbb43, 0x09062223, 0x841c8306, 0x0b0a2144, 0x08212282, 0x2a058307, 0x0a080b0f, + 0x040e0705, 0x87050508, 0x41e08541, 0xbb4309a7, 0x04062207, 0x43758208, 0x55840abb, 0x0d207486, 0x0427e582, 0x0b0c0809, 0x4306080a, 0x092205bb, + 0xa8820308, 0x0d20a482, 0x08200782, 0x0623f282, 0x840c0a0b, 0x8209203d, 0x820920f1, 0x820a202f, 0x09092863, 0x050b0b09, 0x84070809, 0x0806212d, + 0x08200683, 0x02830d82, 0x260abb43, 0x06050509, 0x820b0d0f, 0x82092046, 0x080a221d, 0x2309820d, 0x090b0a08, 0x07834285, 0x0a0e0d26, 0x0d09080c, + 0xb341bc83, 0x82098205, 0x2105822b, 0xbb430807, 0x430f820a, 0x0c2005bb, 0x07232a84, 0x430f0d06, 0x09200ebb, 0x4212bb43, 0x0d890db4, 0x250fe143, + 0x03050305, 0x5482080a, 0xe1440a20, 0x09092205, 0x061f4108, 0x0a080a22, 0x07209a84, 0x0d21b882, 0x22ca820a, 0x820d0809, 0x07092198, 0x03406d83, + 0x15b9438f, 0xca850a20, 0x00880920, 0x08240f85, 0x0f080008, 0x07211385, 0x2c07830a, 0x03060907, 0x00080905, 0x0d0e0f00, 0x3bf6820b, 0x090b090b, + 0x0b0d080a, 0x080a0009, 0x06060b0e, 0x08030303, 0x03030706, 0x0c02080a, 0x00352582, 0x000e150e, 0x06060505, 0x0a0f090b, 0x09060604, 0x0507050b, + 0x20648806, 0x2e188209, 0x0e080b0b, 0x0b0a0a0a, 0x0a0b0809, 0x820a0605, 0x820b2005, 0x090a2403, 0x820f0a0a, 0x82062004, 0x09092e21, 0x09070908, + 0x09090508, 0x03080503, 0x2c3d830d, 0x09060806, 0x08090b08, 0x09060908, 0x243d820b, 0x0a0b0a09, 0x20008408, 0x82058307, 0x89032085, 0x08092164, + 0x03820b82, 0x0e0e0e26, 0x0e0b0909, 0x0b230182, 0x8309090b, 0x24408232, 0x08090d0b, 0x210f8206, 0x1b820a0b, 0x0f278682, 0x060e090e, 0x82040406, + 0x05092196, 0x09289f82, 0x04050909, 0x090a1506, 0x05201f82, 0x0b210082, 0x8a6f830b, 0x8208205d, 0x820a20eb, 0x82092042, 0x8209204c, 0x08082135, + 0x0b296783, 0x080a0509, 0x070a070a, 0x82088409, 0x820b20ab, 0x08082686, 0x08040803, 0x234c8306, 0x060a090b, 0xc0830182, 0x2d820f84, 0x82080821, + 0x2ee98287, 0x09090b07, 0x080c1008, 0x0f08050a, 0x82050805, 0x204a8602, 0x4a428308, 0x428305f8, 0x8208bb43, 0x8559826a, 0x82578455, 0x830d8355, + 0x0b0f2d03, 0x0a040809, 0x0b0d0e08, 0x0b0f0609, 0x0f820183, 0x0a090922, 0x0e20a482, 0x0a29c583, 0x0c070c0b, 0x0a030c0b, 0x2a2d820a, 0x0a0a050a, + 0x0b090a0b, 0x8209080a, 0x0b0b2322, 0x8e820905, 0x0b820320, 0x09090629, 0x09080803, 0x82090708, 0x20a68210, 0x82138203, 0x0a082788, 0x0605050a, + 0x33840f10, 0xa5820a20, 0x090f0924, 0x43830b0b, 0x0a234282, 0x820b0909, 0x0e0d274d, 0x0a0a0d0b, 0x3d840a0e, 0x820b0821, 0x09082141, 0x09201a82, + 0x082f4c82, 0x080a090b, 0x0b090c0b, 0x080c0808, 0x82070908, 0x050324c4, 0x84090d0d, 0x100e2169, 0x2205e143, 0x82000808, 0x820b2000, 0x2106824b, + 0x008d0900, 0x821ccc42, 0x07cd4371, 0x05030529, 0x08080b03, 0x830b0e07, 0x090b2131, 0xc2460082, 0x847b8205, 0x0806220d, 0x27a48309, 0x0a0c0e10, + 0x08070e09, 0x6d832682, 0x218f0340, 0x0195090b, 0x0a090a25, 0x870a0b09, 0x08c24401, 0x10090023, 0x2100840a, 0x06830b07, 0x0609082b, 0x090b0503, + 0x0f110000, 0x2647830e, 0x0a0c0a0c, 0x820f090b, 0x2e058211, 0x0406060c, 0x06090404, 0x0b040407, 0x820d0209, 0x0f003525, 0x05000f17, 0x0c070605, + 0x040b100a, 0x0c0a0707, 0x07050705, 0x04844f84, 0x0c07072e, 0x0f080c0c, 0x0b0b0a0a, 0x0b0c0909, 0x08261a82, 0x090c0b0d, 0x8b830a0c, 0x92820f20, + 0x21820720, 0x8e820c82, 0x09050937, 0x09050309, 0x0a090f03, 0x08060909, 0x0d090906, 0x0a090909, 0x82808207, 0x0c0b2281, 0x05d5410b, 0x06830820, + 0x00820320, 0x60840920, 0x0a230d83, 0x820a0a08, 0x0f092703, 0x0a0a0f0f, 0x01820f0c, 0x820c0c21, 0x2832825a, 0x0c08080a, 0x06080a0e, 0x20c6820c, + 0x821b820b, 0x0f102402, 0x82070f0a, 0x0c0c27c0, 0x0a050909, 0x62820707, 0x07040523, 0x08bb4317, 0x0b23af82, 0x89030b0b, 0x030821c2, 0x07205b83, + 0xcc827e85, 0x83080821, 0x820c2067, 0x0b08213c, 0x09220182, 0x5941050a, 0x82092006, 0x03082500, 0x07080408, 0x43053841, 0x0f8309bb, 0x0c226084, + 0x4c82090d, 0x0a0b072e, 0x0d110809, 0x08050b08, 0x05090510, 0x0a210282, 0x844a8409, 0x090c21e1, 0x0b230183, 0x43090b09, 0x072607bb, 0x09090a05, + 0x55850308, 0x440a0c21, 0xe4410511, 0x0f082306, 0x8a82090d, 0x0e0f0927, 0x0f070a0c, 0x2501830d, 0x0a040909, 0xa4820b0a, 0xc5840f20, 0x070d0b25, + 0x820d0b0d, 0x090b2a0a, 0x0a050b0a, 0x0a0b0d0a, 0x2a0a820c, 0x0d0a0909, 0x0909050c, 0x82030908, 0x09072176, 0x09260684, 0x080a0a08, 0x2e820909, + 0x090a0923, 0x2c88820d, 0x05050a0b, 0x0c111107, 0x0a0b0a0a, 0x29a5820a, 0x0b090f09, 0x0d0b0a0b, 0xd3840c0b, 0x0b0a0d2b, 0x0c100f0b, 0x100b0a0e, + 0x2145850a, 0x0782080d, 0x0a243c82, 0x07080909, 0x46824282, 0x0c0a0e25, 0x820d0809, 0x05bb4316, 0x840e0e21, 0x0f0722e6, 0x0bbb4312, 0x0c0a0c24, + 0x0082000a, 0x028c6582, 0xa7444a84, 0x43078907, 0x092b0de1, 0x05030509, 0x09090b03, 0x410c0f07, 0x8485058c, 0x37052341, 0x0a0a090c, 0x0a08070a, + 0x0b0f0a0a, 0x0a0d0f12, 0x09080f09, 0x00080a0c, 0x21920040, 0x01950a0c, 0x8507fa41, 0x23fc881d, 0x0b110a00, 0x08210084, 0x0cbb430c, 0x0f101222, + 0x09262982, 0x0a0d0a0d, 0xf182090c, 0x0a0c0033, 0x07070d10, 0x0a040404, 0x04040807, 0x0e030a0b, 0x33fd820a, 0x00101810, 0x07060606, 0x0c110a0d, + 0x0a070704, 0x0607060d, 0x240cbb43, 0x090d0d0d, 0x2a608210, 0x0c090a0c, 0x0b07070c, 0x820c0d09, 0x0a0b2453, 0x830b0c0a, 0x07072178, 0x0a2e3a82, + 0x0a080a0a, 0x0a0a060a, 0x05090605, 0x00820a0f, 0x07090623, 0x07bb430a, 0x3d820d20, 0x0d0c0a22, 0x28849e84, 0x05222782, 0xe2410505, 0x4609200a, + 0x10260554, 0x0a0a1010, 0x0182100d, 0x820d0d21, 0x0d0c2a11, 0x09090a0b, 0x090a0f0d, 0x830f8206, 0x2449823f, 0x0a10110d, 0x82c68310, 0x060b2296, + 0x28b1820a, 0x04060a0a, 0x0a0b1807, 0x050a590b, 0x0c22af82, 0x5d8a0c0c, 0x0a03092a, 0x07090b09, 0x090b0a0c, 0x0d235d82, 0x83090909, 0x0a0c2167, + 0x0b23a082, 0x82080b08, 0x213b833e, 0x9f840a0c, 0x82050921, 0x252b8201, 0x0a0d0a0c, 0x6082060b, 0x27820920, 0x0b200f84, 0x09204482, 0x0a208782, + 0x0d321182, 0x13090a0a, 0x060c0b0e, 0x0a051109, 0x060a0606, 0x4a850a0b, 0x00820a20, 0x2109bd41, 0x01860507, 0x090b0625, 0x83050909, 0x840d2018, + 0x87438357, 0x0d112d26, 0x0b05090b, 0x0d0f100a, 0x0d11070a, 0x0b250183, 0x0a0a0409, 0x21a4820b, 0x4e820310, 0x0e0c0b29, 0x0e0c0e09, 0x820b0b05, + 0x070c2464, 0x820d0b0b, 0x20cc829b, 0x2209820a, 0x820b070d, 0x0a05364a, 0x0a07090a, 0x0909050a, 0x0a08090a, 0x090a080a, 0x0a050d0d, 0x2969820a, + 0x0a0b090d, 0x12070707, 0x3d820d12, 0x09290282, 0x0a110a0c, 0x0c0b0c0c, 0x2001820d, 0x06c3430a, 0x0d100f27, 0x110b0b0e, 0x05c4410b, 0x0a090d22, + 0x0b205282, 0x54820c82, 0x0d830920, 0x0a0e0d26, 0x0d09090c, 0x08281182, 0x05050909, 0x0a0f0f06, 0x10216984, 0x82078213, 0x090922d7, 0x23008200, + 0x0b0d0a0d, 0x00200682, 0x820cb843, 0x086c46c6, 0x83097646, 0x25268e09, 0x0705070a, 0xbe820c05, 0x420d1021, 0x0b2305e6, 0x82090a09, 0x823d8209, + 0x820a20ed, 0x09072100, 0x1022f082, 0x2082130c, 0x08100a22, 0x75846c82, 0x03407183, 0x0a0d218b, 0x0c210195, 0x21c6820a, 0x01860d0b, 0x82059244, + 0x0a0022e2, 0x05984112, 0x820c0821, 0x090a2c07, 0x0605070a, 0x00000a0c, 0x83101113, 0x0b0e2d47, 0x0a0d0b0e, 0x000b0d11, 0x0e110a0c, 0x2606bb43, + 0x0c040409, 0x820f030a, 0x11003525, 0x0600111a, 0x0e080706, 0x050c120b, 0x0e0b0808, 0x08060806, 0x35088067, 0x0e08080b, 0x11090e0e, 0x0d0c0c0c, + 0x0d0d0a0b, 0x090c0808, 0x57820d0e, 0x8d820c20, 0x82110c21, 0x82082004, 0x0b0b2221, 0x288e820a, 0x0b0b060a, 0x050a0605, 0x2a0d8211, 0x0709070b, + 0x0a0e0a0b, 0x820b090a, 0x213d8252, 0xbb430d0b, 0x0a092107, 0x05200082, 0x0b200082, 0x0a210782, 0x226a840a, 0x820b0b09, 0x110b2940, 0x0b0b1111, + 0x110d110e, 0x11827382, 0x0c0e0c2d, 0x0e09090b, 0x07090a10, 0x820b0e0e, 0x2c03820c, 0x11120d0c, 0x0808110b, 0x0e0e0505, 0x8271820a, 0x0b0b27b1, + 0x1a080506, 0xfe820b0c, 0x08208c82, 0x8906bb43, 0x050a27c2, 0x090c090c, 0x6e830d08, 0x0e0e0b25, 0x83090909, 0x0b0d2167, 0x1883ca82, 0x59413e82, + 0x0b0a2407, 0x8205090a, 0x0d082201, 0x2201820b, 0x82070c0a, 0x05bb4301, 0x2b835c82, 0x0e0d0a26, 0x0b080a0b, 0x0b2b1f82, 0x0a0f1409, 0x1209060c, + 0x82060a06, 0x82418202, 0x059e4263, 0x40833c84, 0x05080b22, 0x06220186, 0x59820a0c, 0x0a211884, 0x8257830d, 0x83b08355, 0x0e112203, 0x27a1820a, + 0x0d10110a, 0x0e11080a, 0x0f820183, 0x0c0b0b22, 0x1121a482, 0x29c58204, 0x090f0d0c, 0x05100d0f, 0x2d820c0c, 0x0c080d24, 0x47820e0c, 0x0b0a0d2e, + 0x0f0c0a0a, 0x0b0a080e, 0x0b050b08, 0x0b229483, 0x14820a05, 0x0b0a092d, 0x0e0a0b09, 0x0a0b050e, 0x820b0e0b, 0x080c296b, 0x13130808, 0x0d0a0c0e, + 0x0a2b4082, 0x0a110b0d, 0x0d0c0d0d, 0x820d0d0e, 0x0a0a311b, 0x0c0d0c0e, 0x100d1212, 0x0c120c0c, 0x080a0a0a, 0x08213a82, 0x203a820b, 0x2203820c, + 0x8308090b, 0x0f0a28ac, 0x0a0e0b0f, 0x820a0e09, 0x0909266a, 0x10060505, 0x827b8210, 0x14112371, 0x0085090b, 0x410bbb43, 0x09840977, 0x20158646, + 0x10d1430c, 0x08050824, 0x80820d05, 0xa9821120, 0xa6820c20, 0x82080445, 0x29ec82c3, 0x09080b0b, 0x110c0c0b, 0x2083140d, 0x82091121, 0xadbb43b8, + 0x430c0b21, 0x0d2108b9, 0x83dc830b, 0x000b2403, 0x840c130b, 0x0d092100, 0x092c0683, 0x0605070a, 0x00000b0d, 0x0e111214, 0x0f25f882, 0x0d0c0f0c, + 0x32f1820b, 0x120b0d00, 0x0508080f, 0x080b0505, 0x0d050509, 0x8210030b, 0x12003425, 0x0600121b, 0x0f080706, 0x050d130b, 0x0f0b0808, 0x43070807, + 0x0f310cbb, 0x120a0f0f, 0x0e0d0c0c, 0x0e0e0a0b, 0x0a0c0808, 0x2b0a820f, 0x0b0c0d0e, 0x0c120c0d, 0x08080c0b, 0x7a433a82, 0x0b062705, 0x0b06050b, + 0x0d821205, 0x07276282, 0x0b0f0b0b, 0x820b090b, 0x223d8252, 0x450e0d0b, 0x1e8307fb, 0x05208582, 0x200ae541, 0x820b820a, 0x12122103, 0x0f233b82, + 0x82120e12, 0x21ec8373, 0xe6820d0f, 0x0b110f28, 0x0f0f070a, 0xde820f0b, 0x0c0c0f27, 0x0b12130e, 0x82c68312, 0x070b2212, 0x25b1820b, 0x05070b0b, + 0xbb431b08, 0x0e0e2508, 0x0d0d0d0e, 0xbb435d8a, 0x840e2006, 0x0f0f246f, 0x830a0a0a, 0x0b0e2567, 0x0d090c08, 0x3e820182, 0x0e213b83, 0x2120840c, + 0x0182050a, 0x0b0d0829, 0x0b0e0b0d, 0x820d080d, 0x20648223, 0x250f8307, 0x090c090c, 0x24820e0a, 0x090b0922, 0x0a2a0582, 0x0d0b1015, 0x06130a07, + 0x0282060b, 0x850b0c21, 0x2163834a, 0x01870b0e, 0x230abb43, 0x050a0b0b, 0x0e205585, 0x0c225782, 0x53840b09, 0x12281183, 0x050b0b0f, 0x11120b0c, + 0x12219182, 0x8201830f, 0x0b0b220f, 0x21a4820d, 0x4f820412, 0x100e0c33, 0x100e100a, 0x0d0c0c05, 0x080e0c0b, 0x0d0f0c0c, 0x2b86820c, 0x0c0b0b0c, + 0x0b080e10, 0x050b090b, 0x08822582, 0x0920f284, 0x0b221083, 0x0c830f0f, 0x0e0b0f3c, 0x080c0d0a, 0x14140808, 0x0e0b0c0f, 0x0a0c0c0c, 0x0b120b0d, + 0x0d0c0e0e, 0x42820e0f, 0x820b0d21, 0x0d0e2814, 0x110e1313, 0x82130d0c, 0x820b200d, 0x090e2245, 0x835a820c, 0x0a0b330c, 0x0b0f0b09, 0x10100b0c, + 0x0a0a0e0c, 0x0b0b0b0f, 0xbb430a08, 0x230b8206, 0x1512080a, 0x20078442, 0x82008200, 0x820b20d6, 0x43002006, 0x40820fbb, 0x8b07a544, 0x26268e07, + 0x0805080b, 0x820b0e05, 0x830e2054, 0x840e2025, 0x05ee421e, 0x840b0e21, 0x0a082c0d, 0x120d0d0b, 0x0f12150d, 0x82120b0c, 0x0a0c2198, 0x03406d83, + 0x09fb418f, 0xcf45098d, 0x88098309, 0x0b0023fc, 0x00840d14, 0x0c0e093b, 0x090c0d0c, 0x0705070b, 0x00000c0e, 0x0f121315, 0x100b0e0b, 0x0e0c100c, + 0x24f1820b, 0x130c0e00, 0x06bb4310, 0x05050a27, 0x11030b0e, 0x35fa820b, 0x00131d13, 0x09070707, 0x0e140c10, 0x0c090905, 0x07090710, 0x00880c09, + 0x2005604a, 0x37608213, 0x0f0b0c0f, 0x0d09080e, 0x0f0e100b, 0x0d0d0f0b, 0x130d0e0c, 0x090d0c0d, 0x0c2e2182, 0x0a0c0b0c, 0x0c070b0c, 0x0b07060c, + 0x3c831206, 0x070a0829, 0x0b100b0c, 0x820c0a0b, 0x830d2052, 0x0e0f212d, 0x0a20b285, 0x06200683, 0x63880082, 0x3c820c20, 0x132b0384, 0x0c0c1313, + 0x130f1310, 0x82101010, 0x100e2b1d, 0x0a0a0c0d, 0x0a0c1210, 0xc6821007, 0x1b820e20, 0x0f0d0d30, 0x130c1314, 0x05050909, 0x0c0b1010, 0xb1820c07, + 0x070c0c26, 0x0d1d0905, 0x0c21fb82, 0x26008208, 0x0e0f0f0f, 0x89060e0e, 0x060b2a5d, 0x0a0d0a0d, 0x0c0c0f09, 0x2341820b, 0x0a0a0a10, 0x0f226783, + 0x1683080c, 0x820a0d21, 0x0b0d263e, 0x0c0f0b0d, 0x221f820f, 0x82060b0b, 0x0e092301, 0x0e820e0c, 0x82080d21, 0x820a2001, 0x83072064, 0x232d830f, + 0x0c100f0b, 0x0920ac82, 0x0a2d4b82, 0x0e0c1116, 0x06140b07, 0x0b07070b, 0x20418207, 0x204a820a, 0x2042830b, 0x203a820f, 0x2140820f, 0x3a650c0e, + 0x820d2009, 0x850620f4, 0x0c0f2155, 0x0d835585, 0x13220383, 0xa1820c10, 0x12130b27, 0x13090c0f, 0x25018310, 0x0c050b0c, 0xa4820e0c, 0x0c04132f, + 0x0e0d0c0c, 0x0e110a11, 0x0d0d0611, 0x230b820d, 0x100d0d08, 0x0e229b82, 0x19820d0b, 0x080f1123, 0x2d8e820c, 0x0b0c0c06, 0x060c0c09, 0x0b0c0b0b, + 0x10820c0a, 0x0f100b23, 0x82398206, 0x0d0b2b88, 0x0908080d, 0x0d101515, 0x40820e0c, 0x0c0e0b2b, 0x0e0e0c12, 0x0e100e0d, 0x2b42840f, 0x0e0e0d10, + 0x110f1414, 0x0d140d0d, 0x09233d82, 0x820f0b0c, 0x0c0b2241, 0x243e820d, 0x0b090a0c, 0x26678210, 0x0f0c1111, 0x82100a0b, 0x0a09255d, 0x0706060a, + 0x0b820f82, 0x13090b24, 0x40460c16, 0x82002006, 0x820f2000, 0x210682f1, 0x008d0c00, 0x890db442, 0x0fcf430d, 0x08060829, 0x0b0b0e06, 0x830f1209, + 0x0c0e2123, 0x0d221f83, 0x54820e0b, 0x0f0b0e23, 0x3000820c, 0x0d0c0b09, 0x160e120d, 0x0c0d1013, 0x100b0a13, 0x94bb430d, 0x9105fb41, 0x83c88405, + 0x880384cc, 0x0c0023fc, 0x00840d15, 0x0d0f0a22, 0x0a2b0082, 0x0706070c, 0x00000c0e, 0x83131417, 0x0d112543, 0x0c0f0d11, 0x0032f182, 0x11140c0f, + 0x05050808, 0x0a090c05, 0x0c0e0505, 0x25821203, 0x1e140035, 0x07070014, 0x0d100908, 0x09050f16, 0x07100d09, 0x84090709, 0x3d04844f, 0x10100909, + 0x0e140b10, 0x0d0f0e0e, 0x080f100c, 0x110b0e09, 0x100c100f, 0x0f0c0e0e, 0x9282140e, 0x21820920, 0x0c0d0d2e, 0x0c0c0a0c, 0x060d0c07, 0x13060c07, + 0x62820d82, 0x2f820820, 0x0b0c0c23, 0x2752820d, 0x0d0e0e0e, 0x0c0f100f, 0x0a200084, 0x06200583, 0x0d200082, 0x65840e84, 0x05820b20, 0x0c0d0b2b, + 0x0d141414, 0x1013100d, 0x82738214, 0x100f2f11, 0x0b0b0d0e, 0x0b0c1310, 0x0d101008, 0x1b820f10, 0x100e0e26, 0x140d1415, 0x8205bb43, 0x820d2071, + 0x0d0d2bb1, 0x1e090507, 0x0d0e0d0e, 0x0082080d, 0x0f233b82, 0x89060f0f, 0x060b27c2, 0x0b0e0a0e, 0x6e841009, 0x0b21cc82, 0x2267830b, 0x82080c10, + 0x0e0a2516, 0x070d0c0a, 0x0c27c682, 0x0d100d0f, 0x430c0d0c, 0x0f2105bb, 0x220e820d, 0x82090e0c, 0x0c0a2401, 0x83080c08, 0x0b0e220f, 0x828c820e, + 0x0d0a2245, 0x2d2a820a, 0x0c11170b, 0x160b070f, 0x07070c06, 0x4182070c, 0x0a0e0a22, 0x0d224083, 0x0184100c, 0xbb433283, 0x0c0e2109, 0x55855982, + 0x0e0c1023, 0x84758209, 0x20118353, 0x28528214, 0x130c0e06, 0x090c1013, 0x83fa8214, 0x0d05230f, 0xa4820e0d, 0x82041421, 0x0f0e31c5, 0x0f120b11, + 0x0e0e0612, 0x0f0e0d0e, 0x110e0e08, 0x0f209b82, 0x0c31aa82, 0x0810110e, 0x0d0a0c0c, 0x0c0c0d06, 0x060c0d09, 0x2314820c, 0x0a0d0c0a, 0x10338282, + 0x0d0c0d06, 0x0b100d10, 0x08080e0e, 0x10161609, 0x820f0c0e, 0x0f0b2640, 0x0f0c130d, 0x3152820f, 0x0c0f100f, 0x100c0c0e, 0x150e0f0e, 0x0e121015, + 0x0d82150e, 0x82090c21, 0x0d0a2111, 0x0e204e82, 0x0c243e82, 0x110c0a0b, 0x2206534b, 0x82110b0b, 0x0b09275d, 0x0706060a, 0x20821212, 0x090b0d25, + 0x450d1714, 0x0b21058d, 0x23008200, 0x0d0f0c11, 0x00210682, 0x42008d0d, 0x0d890db4, 0x89052a41, 0x06082805, 0x0c0f0608, 0x8213090b, 0x82ab82a9, + 0x820c2061, 0x0c0e279f, 0x0c0f0d0e, 0x53820c10, 0x0d0b092d, 0x0f130e0e, 0x0e111417, 0x820a140c, 0x837584b8, 0x8b034071, 0x8705fb41, 0x0c112105, + 0x84540187, 0x20058705, 0x2300870c, 0x0e170d00, 0x0a210084, 0x08068310, 0x080c0a2b, 0x0d0f0706, 0x15180000, 0x100d1014, 0x120e120c, 0x140c100e, + 0x0f000e10, 0x0912150d, 0x05050509, 0x050b090d, 0x040d0f05, 0x35258213, 0x15201500, 0x08070700, 0x170d110a, 0x0a0a060f, 0x0a08110d, 0x7f410a08, + 0x0a210809, 0x1111110a, 0x0e0e150b, 0x0c0d100f, 0x0a081010, 0x10120c0f, 0x0f110d11, 0x0e0f0d0e, 0x0e0d0e15, 0x8321820a, 0x0d0b2a2e, 0x0d0d070d, + 0x060c0706, 0x290e8314, 0x0d080b09, 0x0c0c110c, 0x52820d0b, 0x0f0e0e26, 0x0f11100d, 0x28825585, 0x06212782, 0x0a5d4306, 0x13830d20, 0x15280382, + 0x0d0d1515, 0x15111411, 0x2c827382, 0x32820f20, 0x110b0b27, 0x080b0d14, 0x33728411, 0x0e0e110e, 0x0d151611, 0x060a0a15, 0x0c111106, 0x0a0d080d, + 0x0823ab83, 0x43200a06, 0x3b8208bb, 0x2a0dbb43, 0x0b0e060c, 0x100a0b0e, 0x820c0d0d, 0x0b11235d, 0x67830b0b, 0x080d1025, 0x820f0b0e, 0x820d2001, + 0x0e0d2408, 0x820e100d, 0x23228220, 0x0c060c06, 0x10272b82, 0x0f0d110d, 0x4b090f09, 0xbb430539, 0x820c2007, 0x2eac8287, 0x0d0d110a, 0x0d12180b, + 0x170c080f, 0x82070d07, 0x0d0e2102, 0xb5824a85, 0x74740d20, 0x07bb4309, 0x0f070a26, 0x060c0c0c, 0xc7821883, 0x55835782, 0x2207c841, 0x820d1115, + 0x140d26a1, 0x0a0d1114, 0x84fa8215, 0x0d0d220f, 0x2fa4820f, 0x0d0d0415, 0x12100e0d, 0x1310130b, 0x0f0e0e06, 0x08270b82, 0x10120e0f, 0x8210110e, + 0x0e0d25b1, 0x0d081112, 0x06208e82, 0x0a28b682, 0x0c060d0d, 0x0b0c0d0c, 0xa6821083, 0xc1821382, 0x0c112b08, 0x08080e0f, 0x1117170a, 0x0e100d0f, + 0x100c0e0e, 0x100d140d, 0x120f0f10, 0x0d101110, 0x110d0d0f, 0x160f100e, 0x0e131016, 0x0d82160f, 0x820a0c21, 0x20418211, 0x821a830c, 0x0c0a3848, + 0x0d0e0c12, 0x110d1312, 0x0d120b0c, 0x0b0a0d0d, 0x0706060b, 0x830d1313, 0x150a2269, 0x0bbb4319, 0xf7821220, 0x8213bb43, 0x920e20a8, 0x0de14303, + 0x080d0d2e, 0x10060806, 0x140a0c0d, 0x0f0c0f11, 0x0d27a682, 0x0e0c0d0c, 0x820d0f0c, 0x82c782b7, 0x820a202d, 0x140f2994, 0x12151910, 0x0b150d0f, + 0xbb43b882, 0x056c5494, 0x12210587, 0x8501870d, 0x071942c8, 0x2308b244, 0x0f180d00, 0x0b310084, 0x0f0e0e10, 0x080d0b0e, 0x0d100806, 0x16190000, + 0x38438315, 0x0e120e12, 0x11150d11, 0x0e10000e, 0x09091216, 0x0d060606, 0x06060b0a, 0x06bb4310, 0x16211635, 0x09080800, 0x180e120a, 0x0a0a0610, + 0x0a08120e, 0x880e0a08, 0x0a0a2600, 0x0c121212, 0x2a608216, 0x110d0e11, 0x0f0a0a11, 0x8210130c, 0x0f0f2957, 0x160f100e, 0x0a0f0e0f, 0x0e2e2182, + 0x0b0e0d0e, 0x0e080d0e, 0x0d08060e, 0x0d821506, 0x0b090e24, 0xb9820e09, 0x0e0c0d22, 0x3d825282, 0x11100e23, 0x0ebb4310, 0x0f840e20, 0x0c2f6984, + 0x0c0e0e0e, 0x16160e0e, 0x120e0e15, 0x82161115, 0x0e0e2e73, 0x1012100e, 0x120c0c0e, 0x090c0d15, 0x20c68212, 0x321b8210, 0x18110f0f, 0x0a160e16, + 0x1206060a, 0x080e0d12, 0x820a0a0e, 0x06082428, 0x820f210a, 0x280d82fb, 0x11110a0a, 0x10101011, 0x28c18806, 0x0f060c0e, 0x0a0c0f0b, 0x05ee4211, + 0x0c0c122a, 0x1616160c, 0x0a0e110e, 0x27054d5d, 0x0f080e0e, 0x110d0f0d, 0x21821182, 0x0c060c29, 0x100a0c07, 0x430e100e, 0x0f2505bb, 0x0e090e0b, + 0x3c0f8309, 0x0c0f0c0f, 0x0e12110c, 0x0b0e0b0d, 0x0c0e0e11, 0x100e131a, 0x07180c08, 0x0d08080d, 0x23418208, 0x0e0b0f0b, 0x0e204082, 0x74524984, + 0x0a062106, 0x1f820185, 0x060c0d22, 0x57845585, 0x53850b20, 0x16201183, 0x07295282, 0x15150d0f, 0x160a0d11, 0x22018312, 0x82060d0e, 0x2fa482fc, + 0x0e0e0516, 0x13110f0e, 0x1411130c, 0x0f0f0f06, 0x0a230b82, 0x82130f0f, 0x8244829b, 0x12132119, 0x0b21fd82, 0x202d820e, 0x2108820d, 0x7e820d06, + 0x0e0d0b28, 0x120d0e0b, 0x8b820612, 0x110e122e, 0x0a0f0f0c, 0x18190a0a, 0x110e0f12, 0x0c2b4082, 0x0e150e10, 0x100f1111, 0x84111113, 0x0f122b42, + 0x17171011, 0x0f0f1411, 0x3d821017, 0x3a820a20, 0x820e0c21, 0x820f203a, 0x0c0e2e03, 0x0d130d0b, 0x14130d0e, 0x0c0d110e, 0x285d8212, 0x060b0c0a, + 0x14140806, 0x240b820e, 0x1a160a0c, 0x063f460e, 0x00820020, 0x110d1223, 0x2106820f, 0x008d0e00, 0x890d7046, 0x0fcf430d, 0x0a060a23, 0x22658206, + 0x4112150a, 0x1f83058c, 0x100d0f24, 0x7b82100d, 0x820d1121, 0x0c0a3153, 0x150f0f0e, 0x12161a10, 0x0b160e0f, 0x0c0f120d, 0x03406d83, 0x17bb438f, + 0x820e1021, 0x110f21c8, 0xfc880186, 0x190e0023, 0x22008410, 0x820f110b, 0x0e0b3500, 0x11080609, 0x1a00000e, 0x0e121617, 0x0f130e11, 0x0e110f13, + 0x0033f182, 0x13170e11, 0x06060a0a, 0x0c0a0e06, 0x0e110606, 0x820e1404, 0x231734fa, 0x08080017, 0x0f130b09, 0x0a061119, 0x08130f0a, 0x820a080a, + 0x26028647, 0x13130a0a, 0x82170d13, 0x0f123360, 0x0a11120d, 0x130d100a, 0x120e1211, 0x110e1010, 0x92821710, 0x21820a20, 0x0e0f0f2e, 0x0e0e0c0e, + 0x060f0e08, 0x16060e08, 0x62820d82, 0x0e0f0923, 0x20168213, 0x2752820f, 0x0f101010, 0x0e111211, 0x2008a743, 0x2085820e, 0x21268306, 0x67840e0e, + 0x05820c20, 0x0e0f0d2b, 0x0f161717, 0x1216130f, 0x82738217, 0x13112b11, 0x0d0d0f10, 0x0d0e1613, 0xc6821309, 0x132dde82, 0x19121010, 0x0b170f17, + 0x1306060b, 0x2d718213, 0x0e0a0a0f, 0x06080f0e, 0x0f10230b, 0x0d820f10, 0x120a0a28, 0x11111212, 0xc2890611, 0x10060d27, 0x0a0c100c, 0x2b7d8412, + 0x0c0c1313, 0x1717170c, 0x0a0e120f, 0x10211683, 0x823e820c, 0x120e30c6, 0x0e0f120f, 0x060d0e0f, 0x0b0d070d, 0x82110f11, 0x0a102120, 0x0c240182, + 0x090e090e, 0x2d830f83, 0x84120d21, 0x120b21d2, 0x1b2c2882, 0x08110e14, 0x0e07190d, 0x080e0808, 0x63824182, 0x40820f20, 0x120e0f22, 0x32830184, + 0x2106b943, 0x1f820a06, 0x55855982, 0x850e1221, 0x07c84155, 0x0e131728, 0x0e10070e, 0x91821616, 0x83131721, 0x0e0e2101, 0x1120bd82, 0x1721a482, + 0x29c58205, 0x0c141110, 0x06151114, 0xe2821010, 0x100a1124, 0x9b821310, 0x69821120, 0x14100e23, 0x2afd8213, 0x0f060f0c, 0x0f0b0e0e, 0x820e060e, + 0x0e0c2714, 0x0e0f0c0e, 0x13821313, 0x0f130f2f, 0x10100d12, 0x1a0a0a0a, 0x0e101319, 0x3b408211, 0x160f110d, 0x1011110e, 0x12111311, 0x0e100e11, + 0x1210130e, 0x12181810, 0x18101015, 0x0e260d82, 0x120e0e0b, 0x4e820f0c, 0x0e0f1028, 0x0b0c0e0f, 0x0682130e, 0x82141421, 0x130d2c47, 0x0b0f0e0e, + 0x06060c0d, 0x82151508, 0x0d0f2520, 0x0f1b170b, 0x200abb43, 0x20608213, 0x20008200, 0x20008d0f, 0x93658210, 0x052a4103, 0x0a290589, 0x11060a06, + 0x160b0d0e, 0x05e64212, 0x00820e20, 0x0f243784, 0x0e120e11, 0x0b285382, 0x10100f0d, 0x171b1116, 0x1721ca82, 0x43b8820c, 0xfb4194bb, 0x21058705, + 0x01870e13, 0x820f1121, 0x11102101, 0x08430186, 0x23058205, 0x101a0f00, 0x0c220084, 0x00821012, 0x090e0c35, 0x0f110806, 0x181b0000, 0x120f1317, + 0x1410140e, 0x820e1210, 0x120032f1, 0x0a14180f, 0x0606060a, 0x060c0a0f, 0x040f1106, 0x35258215, 0x18251800, 0x09080800, 0x1a0f140b, 0x0b0b0611, + 0x0b09140f, 0x7f410b09, 0x051c4e09, 0x1010182e, 0x0e0f1311, 0x0b0a1213, 0x12140d11, 0x11299182, 0x10120f10, 0x100f1018, 0x2f21820b, 0x0f0e0f0f, + 0x080e0f0d, 0x08060f0f, 0x0f17060e, 0x0a290082, 0x0e0f090d, 0x0d0e0e14, 0x2552820f, 0x0f111010, 0x3c431312, 0x0d0e2105, 0xbb43b382, 0x22658905, + 0x820f0f0d, 0x180f2240, 0x263b8218, 0x18131714, 0x82141414, 0x14112a11, 0x0d0d0f11, 0x0d0f1714, 0x820f8209, 0x140f3b0c, 0x1a131010, 0x0b180f18, + 0x1406060b, 0x090f0e14, 0x0f0b0b0f, 0x06090f0f, 0xbb43250b, 0x13132508, 0x12121213, 0x250dbb43, 0x0b0d100d, 0xa5820f13, 0x14140f2f, 0x180d0d0d, + 0x130f1818, 0x0d100a0f, 0x82018211, 0x0e10263e, 0x10130e10, 0x09bb4313, 0x120f1222, 0x11222082, 0x2382110a, 0x09206482, 0x10200f83, 0x0e274482, + 0x0f0f1413, 0x820c0f0c, 0x1c0d2d4b, 0x09120f15, 0x0f081a0d, 0x090f0909, 0x42051e46, 0x1320058a, 0x13203a82, 0x12214082, 0x07bb430f, 0x11080b26, + 0x060d0e0e, 0x13215585, 0x8355850f, 0x2d03830d, 0x0e0f1418, 0x170e1007, 0x0b0f1317, 0x01831418, 0x820e0f21, 0x821120bd, 0x05182fa4, 0x100f0f0f, + 0x150d1512, 0x10061612, 0x0b821110, 0x10110a29, 0x13101214, 0x82100e12, 0x14152319, 0x8e820f0a, 0x0e292d82, 0x060f0f0b, 0x0e0f0e0e, 0x2210830c, + 0x8214140e, 0x140f3d13, 0x110e130f, 0x0b0a0a10, 0x11141a1b, 0x1010120f, 0x0f120e10, 0x12120f17, 0x12141211, 0x112e4282, 0x10140f0f, 0x19191112, + 0x11101613, 0x3d821119, 0x0e0f0b28, 0x0f0f0d13, 0x1a820f0e, 0x0d0f0f2a, 0x0e140e0c, 0x15150f0f, 0x0d214782, 0x285d8214, 0x060d0d0b, 0x16160806, + 0x230b820f, 0x1c180b0e, 0x2106054d, 0x0082000d, 0x60821320, 0x283ebb43, 0x0b0e0e12, 0x0e111317, 0x82a68211, 0x06aa4683, 0x130e1223, 0x05bb430f, + 0x17111125, 0x82181c12, 0x0d1824ca, 0x8410140e, 0x40718375, 0xfb418b03, 0x21059105, 0x01820f12, 0x86121021, 0x08b24401, 0x1b0f0023, 0x08008411, + 0x10130c31, 0x0d101110, 0x0906090f, 0x00000f12, 0x1418191d, 0x150f130f, 0x13111511, 0x1014180f, 0x19101200, 0x060b0b15, 0x0b0f0606, 0x1206060d, + 0x8216040f, 0x1b003525, 0x0a001b29, 0x160c0b0a, 0x07141d11, 0x16110c0c, 0x0c0a0c0a, 0x04844f84, 0x0c0c2108, 0x0f161616, 0x1313121b, 0x15101115, + 0x130c0b14, 0x1514170f, 0x12131510, 0x1b121411, 0x0c131113, 0x112e2182, 0x0e111011, 0x110a1011, 0x10090711, 0x0d821a07, 0x0e0c112a, 0x1610110b, + 0x110e1010, 0x12275282, 0x14111312, 0x84101415, 0x830e2000, 0x82072005, 0x84112000, 0x2065840e, 0x8205820f, 0x1b1b2803, 0x1611111a, 0x821b151b, + 0x2f118273, 0x11131614, 0x1a160f0f, 0x160b0f10, 0x14161116, 0x12301b82, 0x1b1d1512, 0x0c0c1b11, 0x16160707, 0x110a1110, 0x112bb182, 0x0c070a11, + 0x12111229, 0x4e0b1111, 0x142305cc, 0x89071414, 0x070f28c2, 0x0e130e12, 0x8211150c, 0x16112c70, 0x0f0f0f16, 0x111b1b1b, 0x830b1115, 0x0e132116, + 0x12243e82, 0x15101210, 0x10381182, 0x070f1011, 0x0c0f080f, 0x11141114, 0x0c131015, 0x0e120c13, 0x0b110b11, 0x13200f83, 0x0f274482, 0x10111615, + 0x820d110e, 0x1f0f2f4b, 0x0a141118, 0x10091d0f, 0x0a100a0a, 0x1e831012, 0x83055745, 0x82152049, 0x11142340, 0x0185070b, 0x13090c23, 0x85598210, + 0x20578355, 0x83558212, 0x2003830d, 0x2952821b, 0x1b101208, 0x0c10151a, 0x0183161b, 0x82101121, 0x821320bd, 0x061b21a4, 0x2208c582, 0x0f181412, + 0x07191418, 0x11131312, 0x130b1413, 0x12141713, 0x12101415, 0x18131111, 0x11110b16, 0x8207110e, 0x110c25d9, 0x10100711, 0x10209c82, 0x10231082, + 0x82071616, 0x11162e8b, 0x12130f15, 0x1e0c0b0b, 0x1113161e, 0x2a408214, 0x1a11140f, 0x13141411, 0x82141714, 0x11132e42, 0x15131611, 0x151c1c13, + 0x1c131219, 0x223d8213, 0x4710110d, 0x10260797, 0x0d0e1111, 0x14821710, 0x82181821, 0x170f2147, 0x0d285d82, 0x07070e0f, 0x11191909, 0x0f250b82, + 0x11201b0d, 0x2000850f, 0x23008200, 0x12141016, 0x00210682, 0x20008d11, 0x08b04212, 0x2a41098d, 0x2f058905, 0x070b070b, 0x0d0f1014, 0x1013161a, + 0x11141013, 0x09831983, 0x1021b782, 0x328b8215, 0x110f0c11, 0x141a1313, 0x13171b20, 0x100e1b11, 0x830f1316, 0x8f03406d, 0xac821520, 0x16210389, + 0x21018710, 0x01821114, 0x86141221, 0x23f68801, 0x131e1100, 0x31080084, 0x1212150e, 0x110e1213, 0x140a070b, 0x20000011, 0x11161b1c, 0x13181115, + 0x11151318, 0x0012161b, 0x181d1115, 0x07070c0c, 0x0e0c1107, 0x11140707, 0x25821905, 0x2c1d0033, 0x0a0a001d, 0x12180d0b, 0x0d08151f, 0x0b18120d, + 0x055b5c0d, 0x00841220, 0x180d0d3d, 0x1d101818, 0x16141414, 0x16161112, 0x10140d0d, 0x11171618, 0x12141417, 0x821d1415, 0x820d208c, 0x12122f21, + 0x120f1211, 0x12120a11, 0x09110a09, 0x0082121c, 0x0b0f0c29, 0x11181112, 0x82120f11, 0x233d8252, 0x15171612, 0x2005d541, 0x2006830f, 0x84008209, + 0x2804855f, 0x12121210, 0x1d121210, 0x233b821d, 0x1d171d18, 0xca827382, 0x18152308, 0x10101215, 0x10121c18, 0x1218180b, 0x13131518, 0x17141418, + 0x1d121c1f, 0x08080d0d, 0x12111818, 0xb182120a, 0x0b121229, 0x142c0d08, 0x82121412, 0x0d0d280d, 0x15171717, 0x85091515, 0x27058358, 0x0f140910, + 0x160d0f14, 0x1220a583, 0x1028cc82, 0x1d1d1d10, 0x0d121612, 0x14211683, 0x263e820f, 0x11141114, 0x82161316, 0x101122c5, 0x82018209, 0x1216252b, + 0x0c141217, 0x0f280182, 0x0b120b12, 0x12151215, 0x10232d83, 0x82121817, 0x170e21e9, 0x222cae82, 0x0a151219, 0x12091f10, 0x0a120a0a, 0x0f204182, + 0x11204a82, 0xb44e4283, 0x21058305, 0x0186090d, 0x59821f82, 0x17201283, 0x55825785, 0x03835383, 0x12181d2d, 0x11140911, 0x12171c1d, 0x83181d0d, + 0x11122501, 0x15121208, 0x1d2fa482, 0x12121206, 0x10191614, 0x091a161a, 0x82141414, 0x140d290b, 0x13161814, 0x14111617, 0x19231982, 0x82120d18, + 0x20eb828e, 0x25088211, 0x13111109, 0x10830f11, 0x18181122, 0x123d1382, 0x10171218, 0x0d0d1414, 0x1820200d, 0x14161214, 0x16101414, 0x16121c12, + 0x18151416, 0x37428516, 0x15161418, 0x1b171e1e, 0x141e1414, 0x0e111211, 0x0f171112, 0x12111313, 0x123b5d82, 0x110e0f12, 0x12131118, 0x17131a19, + 0x11181011, 0x100e1211, 0x0a09090f, 0x82121b1b, 0x0e10250b, 0x1012221d, 0x00200085, 0x17230082, 0x82131612, 0x82002006, 0x21028bb1, 0x01951114, + 0x6d821220, 0x0d29038b, 0x16090d09, 0x1c0e1011, 0x212f8317, 0x1b831216, 0x15111428, 0x16121512, 0x50831711, 0x12100d31, 0x161c1414, 0x14181d22, + 0x110f1d12, 0x83101418, 0x8f03406d, 0x95121721, 0x21c88401, 0x01861613, 0x0023f888, 0x84152112, 0x160f2200, 0x2c008214, 0x090b120f, 0x0013160b, + 0x1d1e2200, 0x25498218, 0x14191419, 0xf1821217, 0x13160033, 0x0d0d191f, 0x12080808, 0x08080f0d, 0x1b051216, 0x34fa8212, 0x00203120, 0x0f0d0b0b, + 0x1722141a, 0x140f0f09, 0x0c0f0c1a, 0x8647820f, 0x0f210802, 0x1a1a1a0f, 0x16162011, 0x12141916, 0x0f0d1819, 0x181b1216, 0x16191319, 0x16171416, + 0x16141620, 0x2e21820f, 0x14131414, 0x0b131411, 0x0b091414, 0x821f0913, 0x0e142a0d, 0x13140d11, 0x1113131a, 0x82528214, 0x1814243d, 0x84131719, + 0x13112100, 0x09200082, 0x14200082, 0x67840e84, 0x05821120, 0x20280382, 0x14141f20, 0x20191f1a, 0x14357382, 0x1a171415, 0x11111417, 0x11131f1a, + 0x141a1a0d, 0x1515171a, 0x2d86821a, 0x20141f22, 0x09090f0f, 0x14131a1a, 0xb182140c, 0x0c141425, 0x82310f09, 0x1414228a, 0x2600820d, 0x17191919, + 0x89091717, 0x091227c2, 0x11161116, 0xa582190f, 0x82141321, 0x111128cc, 0x14202020, 0x830d1419, 0x82162016, 0x160c2d76, 0x19131613, 0x13141915, + 0x09121314, 0x0f280182, 0x14181418, 0x0e161319, 0x11280182, 0x0d140d14, 0x14171417, 0x12272d83, 0x13141a19, 0x82101410, 0x25112d4b, 0x0c17141c, + 0x130a2212, 0x0b130b0b, 0x11204182, 0x40824a82, 0x19131422, 0x19205b82, 0x18214082, 0x06b94314, 0x0b0f0924, 0x59821316, 0x57845585, 0x53835582, + 0x20200383, 0x0a295282, 0x1f1f1316, 0x200f1319, 0x2101831a, 0xbd821314, 0xa4821720, 0x1407202e, 0x18161414, 0x181c111c, 0x1616091d, 0x182a8382, + 0x1b16160d, 0x18191518, 0x19821613, 0x0d1a1c26, 0x14101414, 0x13262d82, 0x0914140f, 0x9c821313, 0x10821320, 0x1a1a1323, 0x3ccc8209, 0x1219141a, + 0x0d0d1616, 0x1a23240f, 0x16181416, 0x18121616, 0x18141f14, 0x1b181618, 0x2b428518, 0x1718161a, 0x1d192121, 0x17211616, 0x0f223d82, 0x97471314, + 0x82162005, 0x1114243e, 0x471b1310, 0x12210797, 0x285d821b, 0x0911120f, 0x1d1d0b09, 0x250b8214, 0x26200f12, 0x00851114, 0x00820020, 0x18131a23, + 0x21068215, 0x008d1400, 0x8f07ae42, 0x825f8207, 0x2905896f, 0x090d090d, 0x0f121318, 0x29831a1f, 0x83141821, 0x13162919, 0x14171317, 0x13191318, + 0x0f315382, 0x16161412, 0x2025181f, 0x2014161b, 0x161a1311, 0x406d8311, 0x19208f03, 0x0389ac82, 0x87131a21, 0x14172101, 0x1521c882, 0x88018618, + 0x140023f6, 0x00841724, 0x16191022, 0x2b080082, 0x090d1411, 0x0014180c, 0x1f212600, 0x1419141a, 0x161c161c, 0x1a201419, 0x15190016, 0x0e0e1c22, + 0x14090909, 0x0909110f, 0x1e061418, 0x00362582, 0x00213221, 0x0f0d0c0c, 0x1824151b, 0x150f0f09, 0x0c0f0c1b, 0x0088150f, 0x1b0f0f26, 0x21121b1b, + 0x192e6082, 0x191a1315, 0x12170f0d, 0x141a191c, 0x8b82171a, 0x82211721, 0x820f2092, 0x15152e21, 0x15111514, 0x15150c14, 0x09140b09, 0x2a0d8220, + 0x0d110e15, 0x141b1415, 0x82151114, 0x17172652, 0x1a191517, 0x05d54118, 0x06831120, 0x09218582, 0x840f8415, 0x82122069, 0x15122b05, 0x20212114, + 0x201b1515, 0x7382211a, 0x182f1182, 0x1215171b, 0x14201b12, 0x1b1b0d12, 0x82181b15, 0x17172b1b, 0x1520231a, 0x090f0f21, 0x5d821b09, 0x82150c21, + 0x15152bb1, 0x320f090c, 0x15171517, 0x00820d15, 0x1a1a1a26, 0x09181818, 0x1528c188, 0x11170913, 0x1a0f1117, 0x152c6e83, 0x12121b1b, 0x21212112, + 0x0d151a15, 0x17211683, 0x823e8211, 0x191421c6, 0x142a1182, 0x09121415, 0x0f120a12, 0x0e821519, 0x0e171422, 0x11280182, 0x0d140d14, 0x15181518, + 0x13232d83, 0x82151b1a, 0x1a1031d2, 0x26121515, 0x0c18141d, 0x140b2412, 0x0c140c0c, 0x63824182, 0x40821520, 0x1a141522, 0x1a204982, 0x19214082, + 0x09bb4315, 0x82141721, 0x20558559, 0x8257831a, 0x07c84155, 0x141b212d, 0x14170a14, 0x141a2020, 0x831b210f, 0x14142501, 0x18151509, 0x212fa482, + 0x15151507, 0x121d1917, 0x091e191d, 0x82171717, 0x170d230b, 0x9b821c17, 0x16141935, 0x1d171414, 0x15140d1b, 0x15091511, 0x150f1414, 0x82140915, + 0x8311207e, 0x1b132210, 0x2f13821b, 0x1a151b15, 0x0d171713, 0x24250f0d, 0x1914171b, 0x133b4082, 0x14201519, 0x18171919, 0x191a191c, 0x14141714, + 0x1819171b, 0x1e1a2222, 0x82221716, 0x1014210d, 0x1122bd82, 0x5a821515, 0x15141527, 0x14101215, 0x2152821c, 0x47821d1d, 0x821c1221, 0x1210275d, + 0x0b090911, 0x20821e1e, 0x10131526, 0x12152721, 0x00200085, 0x1b230082, 0x82161914, 0x82002006, 0x44028bb1, 0x078f07a1, 0x89052a41, 0x090d2905, + 0x1419090d, 0x1a201013, 0x20058c41, 0x28008214, 0x14181417, 0x14191518, 0x2e8b821a, 0x15120f15, 0x19201717, 0x171c2127, 0x82112114, 0x831220b8, + 0x8f03406d, 0xac821a20, 0x1b210389, 0x21018714, 0xc8821518, 0x86191621, 0x84db8201, 0x00152402, 0x84172515, 0x1a112100, 0x2b080683, 0x090d1411, + 0x0015190c, 0x20222700, 0x141a151b, 0x171d171d, 0x1b21151a, 0x15190016, 0x0f0f1d23, 0x15090909, 0x0909120f, 0x1f061519, 0x00362582, 0x00253825, + 0x110f0d0d, 0x1b28181e, 0x1811110a, 0x0d110d1e, 0x00881811, 0x11112108, 0x141e1e1e, 0x1a191925, 0x1d15171d, 0x1a11101c, 0x1d1c1f15, 0x191a1d16, + 0x25191b17, 0x11191719, 0x27082182, 0x17161818, 0x0d161713, 0x0d0a1717, 0x17240a16, 0x10171716, 0x16170f13, 0x1316161e, 0x1e171117, 0x171a1919, + 0x161b1d1c, 0x13200084, 0x0a200583, 0x17200082, 0x17200e84, 0x18210082, 0x2b6f8214, 0x25171814, 0x18182425, 0x251d241e, 0x11827382, 0x1a1e1b2f, + 0x1e141418, 0x0f141623, 0x1e181e1e, 0x391b821b, 0x281d1919, 0x11251824, 0x1e0a0a11, 0x0d17161e, 0x17111118, 0x0a0d1817, 0x8a823811, 0x10171722, + 0x1d260082, 0x1b1b1d1d, 0xc1880a1b, 0x0a151829, 0x13191319, 0x82171d11, 0x1e172f70, 0x1414141e, 0x18252525, 0x1910171d, 0x01821a13, 0x19393e82, + 0x1d161916, 0x16171d18, 0x0a151617, 0x11150b15, 0x171c171c, 0x101a161d, 0x2723821a, 0x0f170f17, 0x171b171b, 0x15234483, 0x82171e1d, 0x1d1233e9, + 0x2b141718, 0x0d1b1720, 0x160c2815, 0x0d160d0d, 0x4a841619, 0x17234082, 0x83171d16, 0x821c2001, 0x0a102142, 0x11230185, 0x82161a0d, 0x83558559, + 0x13192157, 0x57835385, 0x171e252d, 0x16190b16, 0x161d2324, 0x831e2511, 0x16172101, 0x1b20bd82, 0x2521a482, 0x3dc58208, 0x14201c19, 0x0a221c21, + 0x171a1919, 0x1a101c19, 0x181c1f19, 0x19161c1d, 0x20191717, 0x8e83101e, 0xd9820a20, 0x17171129, 0x1816160a, 0x82161316, 0x1623089f, 0x170a1e1e, + 0x171e1716, 0x191a151d, 0x29111010, 0x171a1e29, 0x1919191c, 0x24171c15, 0x1a1c1c17, 0x821c1f1b, 0x171a3d42, 0x1c191e17, 0x1d27261a, 0x261a1922, + 0x1617161a, 0x1e161711, 0x16181813, 0x16181a17, 0x1222e282, 0x52821f16, 0x1821203b, 0x1f14151d, 0x11171616, 0x0a0a1314, 0x1722220d, 0x15181616, + 0x182b2511, 0x20008514, 0x23008200, 0x181c161e, 0x00200682, 0x028bb182, 0x8f07ae42, 0x829e8207, 0x2c05896f, 0x0a100a10, 0x1115161c, 0x161a1e24, + 0x834a821a, 0x82192019, 0x37b78209, 0x17161d16, 0x15111817, 0x241a1a18, 0x1f252b1c, 0x1325171a, 0x14191e16, 0x03406d83, 0x821d208f, 0x210389ac, + 0x0187161e, 0x1b171b25, 0x87181c17, 0x23f68801, 0x1a2a1800, 0x31080084, 0x19191d13, 0x1713191a, 0x1c0d0a0f, 0x2c000018, 0x181e2426, 0x1921171d, + 0x171d1921, 0x00191e25, 0x2027181c, 0x0a0a1111, 0x1411180a, 0x181c0a0a, 0x25822207, 0x402a0036, 0x0f0f002a, 0x1b221311, 0x130b1f2d, 0x0f221b13, + 0x1b130f13, 0x13340088, 0x22222213, 0x1d1d2a17, 0x181b201d, 0x13122021, 0x1f23171d, 0x1d295382, 0x1d1f1a1d, 0x1d1a1d2a, 0x2e218213, 0x1a191b1b, + 0x0f191a16, 0x0e0c1b1a, 0x82290c19, 0x121a2a0d, 0x191b1116, 0x16191922, 0x8252821b, 0x1f1b243d, 0x84191f21, 0x83162000, 0x820c2005, 0x841b2000, + 0x2069840e, 0x2b058217, 0x2a1a1b17, 0x1b1b292a, 0x2a212a22, 0x11827382, 0x1e221f2f, 0x2217171b, 0x11171928, 0x221b2222, 0x3f1b821f, 0x2d211d1d, + 0x132a1b29, 0x220b0b13, 0x0f1a1922, 0x1a13131b, 0x0b0f1b1a, 0x1b1d4013, 0x121b1b1d, 0x23055447, 0x0c1f1f1f, 0x1b2dc188, 0x161d0c18, 0x2113161d, + 0x19191a1a, 0x28cc821a, 0x2a2a1717, 0x1a211b2a, 0x05644112, 0x1d2c3e82, 0x20191d19, 0x191b211b, 0x0c17191b, 0x13280182, 0x1b1f1b1f, 0x121d1921, + 0x16240182, 0x111a111a, 0x2d830f83, 0x22211823, 0x31e9821a, 0x1a1b2115, 0x1a253117, 0x2d170f1f, 0x0f0f190e, 0x41820f19, 0x40836382, 0x21191b23, + 0x2501831a, 0x1b201b20, 0x01850c12, 0x1d0e1323, 0x85598219, 0x82578455, 0x820d8355, 0x2a1a2e03, 0x0d191a22, 0x282a191d, 0x2a131921, 0x25018322, + 0x1b0b191a, 0xa4821e1b, 0x1b092a2f, 0x201d1b1b, 0x20251725, 0x1d1d0c26, 0x230b821e, 0x231d1d12, 0x20289b82, 0x1a1a1c19, 0x1222251d, 0x1b298e82, + 0x191a1b0c, 0x0c1a1b13, 0x08bf8219, 0x1a191547, 0x23191b15, 0x191b0c22, 0x211b221b, 0x121d1d18, 0x2e2f1312, 0x201a1d22, 0x181d1d1d, 0x1a291b1f, + 0x1f1d2020, 0x20212023, 0x1a1a1d19, 0x1e201d22, 0x27212c2b, 0x1e2b1d1d, 0x14191a19, 0x1622191a, 0x1a191b1b, 0x293e821d, 0x1915161a, 0x191b1923, + 0x47822525, 0x1923172d, 0x17141b19, 0x0e0c0c16, 0x821b2626, 0x1418250b, 0x171b312a, 0x00200085, 0x22230082, 0x821c2019, 0x82002006, 0x21028bb1, + 0x0195191d, 0x89052a41, 0x0c122905, 0x19200c12, 0x22291418, 0x20058c41, 0x3e8d821a, 0x191e191d, 0x19201b1e, 0x1b1b1921, 0x1b17131b, 0x1f291d1d, + 0x1d232a31, 0x19162a1a, 0x83171d22, 0x8f03406d, 0xac822120, 0x22210389, 0x25018719, 0x1b1f1b1f, 0x01871c20, 0x0384dc83, 0x2f1b0023, 0x2200841e, + 0x821d2115, 0x162b0800, 0x0f0c111a, 0x00001b20, 0x22292c32, 0x251a211b, 0x211d251d, 0x1c222a1a, 0x2c1b2000, 0x0b131325, 0x131b0b0b, 0x200b0b16, + 0x8227071b, 0x2e003525, 0x10002e46, 0x26151210, 0x0c21321d, 0x261d1515, 0x15111511, 0x02864782, 0x2615153d, 0x2e192626, 0x2320201f, 0x23241a1d, + 0x1a201512, 0x1c242227, 0x1c1f2024, 0x822d1f22, 0x8215208c, 0x1d1d2e21, 0x1d181d1c, 0x1d1d101b, 0x0c1b100c, 0x2a0d822d, 0x1218141d, 0x1b261b1d, + 0x821d181b, 0x1f1f2752, 0x24221d20, 0x00841c22, 0x821b1821, 0x820c2000, 0x841d2000, 0x2067840e, 0x82058219, 0x2e2e2803, 0x261d1d2d, 0x822e242e, + 0x1d260873, 0x26211d1e, 0x19191d21, 0x191c2c26, 0x1d262612, 0x1e1e2126, 0x241f1f26, 0x2e1d2d31, 0x0c0c1515, 0x1c1b2626, 0xb1821d11, 0x111d1d2b, + 0x1f46150c, 0x1d1d1f1d, 0x26008212, 0x22242424, 0x890c2222, 0x0c1a2cc2, 0x1820181f, 0x1c1c2415, 0x821d1c1b, 0x191928cc, 0x1d2e2e2e, 0x83121d24, + 0x18202116, 0x20083e82, 0x1c1f1c1f, 0x1d241e23, 0x1a1b1d1b, 0x1a0e1a0c, 0x221d2215, 0x201c241d, 0x1f142014, 0x1c121c18, 0x200f8312, 0x3a448220, + 0x1d26241a, 0x171d181c, 0x191d1d24, 0x221c2836, 0x0f321a11, 0x1c10101c, 0x831c1f10, 0x2240831e, 0x82241b1d, 0x1d24225b, 0x43018223, 0x122505b9, + 0x2010150c, 0x8559821b, 0x83578355, 0x830d8355, 0x262d2d03, 0x1f0e1b1c, 0x242c2e1c, 0x262d151c, 0x1c210183, 0x20bd821b, 0x21a48221, 0xc5820a2e, + 0x231f2108, 0x23291928, 0x201f0c2a, 0x23201d20, 0x27202012, 0x23241e22, 0x1c1c1f1c, 0x12262820, 0x1d181d1c, 0x23082d82, 0x1d1d151b, 0x1d1b1b0c, + 0x1d1c171b, 0x261b1d17, 0x1c1d0c25, 0x241d251d, 0x121f201a, 0x33331512, 0x231c2026, 0x1a2a4082, 0x1c2d1d22, 0x22202323, 0x42822327, 0x1c1c202d, + 0x21232026, 0x2a24302f, 0x8230201f, 0x161b260d, 0x18251b1d, 0x20c6821d, 0x3a3e8220, 0x1b17191d, 0x1c1e1b27, 0x251d2928, 0x1c27191a, 0x19161d1b, + 0x100c0c18, 0x821d2a2a, 0x161a2569, 0x191d362e, 0x00200085, 0x25230082, 0x821e231c, 0x82002006, 0x20028bb1, 0x93a8821f, 0x052a4103, 0x12320589, + 0x230c120c, 0x2d161a1b, 0x201b2025, 0x1c1d231b, 0x07821c1b, 0x211c2133, 0x241b231d, 0x1d1d1d1c, 0x201d1a15, 0x36222d20, 0x21ca822d, 0xb882182e, + 0x6d831920, 0x218f0340, 0x018b1c24, 0x871c2521, 0x1d222501, 0x1e231d22, 0xdc830187, 0x1d240383, 0x21341d00, 0x31080084, 0x1f1f2417, 0x1c181f20, + 0x23110c12, 0x3700001d, 0x1d252d30, 0x20281c24, 0x1d242028, 0x001f262d, 0x28311e23, 0x0c0c1515, 0x18151d0c, 0x1d230c0c, 0x25822b08, 0x4c320036, + 0x12120032, 0x20291714, 0x170d2436, 0x12292017, 0x20171217, 0x21080088, 0x29291717, 0x22321b29, 0x20272322, 0x1526271d, 0x2a1c2317, 0x271e2725, + 0x251f2223, 0x1f223122, 0x21821722, 0x1e20202e, 0x1e1f1a1f, 0x0f201f12, 0x310f1e11, 0x1f2a0d82, 0x20141a15, 0x1e1e291e, 0x5282201a, 0x20243d82, + 0x1e252725, 0x1a200084, 0x0f200583, 0x20200082, 0x69840e84, 0x05821b20, 0x1f201b2b, 0x20313232, 0x27322920, 0x82738232, 0x29242f11, 0x1b1b2023, + 0x1b1e3029, 0x20292914, 0x1b822429, 0x27222232, 0x32203135, 0x0d0d1717, 0x1f1e2929, 0x17172012, 0x1229f482, 0x224c170d, 0x20202220, 0x26008215, + 0x25272727, 0x880f2525, 0x1c202dc1, 0x221a220f, 0x1f27171a, 0x1f1e1e1f, 0x1b2bcc82, 0x3232321b, 0x151f2720, 0x82231a22, 0x201f2f01, 0x221e2212, + 0x2720271e, 0x1e201e20, 0x01820f1c, 0x20251729, 0x1e272025, 0x82231523, 0x141f2323, 0x0f83141f, 0x1c234483, 0x821f2927, 0x281930d2, 0x3a1b1f20, + 0x12251f2c, 0x1e10361c, 0x821e1212, 0x834a8341, 0x1e202340, 0x01831f27, 0x26202625, 0x850f1520, 0x11172301, 0x59821e23, 0x57835585, 0x851a2221, + 0x20118353, 0x29528231, 0x321e220f, 0x171e2730, 0x01832931, 0x0d1e1f25, 0x82242020, 0x0b3221a4, 0x2231c582, 0x2c1b2c26, 0x220f2d26, 0x22202322, + 0x22231526, 0x359b822a, 0x1f221e26, 0x292c221f, 0x1a1f1f15, 0x1f200f20, 0x1f20171e, 0xbf821e0f, 0x1f1e1928, 0x291e2019, 0x8b820f29, 0x20293b08, + 0x22231c28, 0x38171515, 0x1f232937, 0x22222226, 0x3120251c, 0x2326261f, 0x27262a25, 0x1f231e26, 0x2622291f, 0x27343424, 0x3423222e, 0x1e1f1e23, + 0x281e1f18, 0x1e20201a, 0x3e82231f, 0x191b1f24, 0x52822a1e, 0x202c2c32, 0x2a1b1d28, 0x18201e1e, 0x0f0f1a1b, 0x202e2e11, 0x1c240b82, 0x203b3218, + 0x20066147, 0x23008200, 0x21261e28, 0x00200682, 0x028bb182, 0x951e2221, 0x052a4101, 0x152e0589, 0x260f150f, 0x31181c1e, 0x231e2328, 0xd182261e, + 0x39821f20, 0x241e243c, 0x271e2620, 0x2020201e, 0x23201c17, 0x3a253123, 0x1f232a31, 0x291e1a32, 0x6d831b22, 0x208f0340, 0x89ac8227, 0x1e282103, + 0x25250187, 0x26202520, 0x21018721, 0x01861e1f, 0x38200023, 0x08008423, 0x22271931, 0x1a222322, 0x120f141f, 0x00002026, 0x2931343b, 0x2c1f2720, + 0x27222c22, 0x2229311f, 0x35202600, 0x0d16162c, 0x17200d0d, 0x260d0d1b, 0x822e0920, 0x36003625, 0x13003652, 0x2c191513, 0x0f273a22, 0x2c221919, + 0x19141914, 0x08008822, 0x2c191921, 0x361d2c2c, 0x2a262525, 0x292a1f22, 0x1e251917, 0x212b282e, 0x2125262b, 0x25352528, 0x82192521, 0x22223c21, + 0x221c2220, 0x22221320, 0x0f20130f, 0x22212235, 0x151c1722, 0x202c2022, 0x82221c20, 0x243d8252, 0x282b2822, 0x20008420, 0x2005831c, 0x2100820f, + 0x00832122, 0x1d206984, 0x1d2b0582, 0x36362122, 0x2c222235, 0x82362b36, 0x2bca8273, 0x22262c27, 0x342c1d1d, 0x2c151d21, 0x2734c682, 0x252c2323, + 0x353a2b25, 0x19193622, 0x2c2c0f0f, 0x22142120, 0x2228b182, 0x190f1422, 0x25222552, 0x17297582, 0x2b2b1717, 0x2828282b, 0x3cc1880f, 0x250f1e22, + 0x191c251c, 0x2021212a, 0x2c2c2221, 0x361d1d1d, 0x2a223636, 0x1c251722, 0x82018226, 0x2025393e, 0x232a2025, 0x2220222a, 0x1e0f1e20, 0x28191e10, + 0x2b222822, 0x26172621, 0x21232382, 0x83152115, 0x3a44830f, 0x222c2b1f, 0x1b221c21, 0x1d22222b, 0x27212f3f, 0x113a1e14, 0x21131321, 0x84202513, + 0x2140824a, 0xf84a2022, 0x22292505, 0x0f172229, 0x19200185, 0x59821f82, 0x57835585, 0x851c2521, 0x2d118353, 0x20212c35, 0x36202510, 0x19212b34, + 0x01832c35, 0x82202121, 0x822720bd, 0x0b362fa4, 0x25222222, 0x301d2f29, 0x250f3129, 0x0b822625, 0x25172708, 0x23282e25, 0x2421292b, 0x2f252121, + 0x2221172c, 0x220f221c, 0x22192021, 0x20200f22, 0x211b2023, 0x20221b22, 0x13822c2c, 0x222c223d, 0x25261f2b, 0x3c191717, 0x21252c3c, 0x25252529, + 0x3522281f, 0x25292921, 0x82292e28, 0x21262f42, 0x29252c21, 0x2a383826, 0x38262532, 0x45832026, 0x1c2b2029, 0x22202323, 0x82212226, 0x201b38e2, + 0x2123202d, 0x2b23302f, 0x202d1e1f, 0x1e192220, 0x130f0f1c, 0x82223131, 0x191f240b, 0x47223f36, 0x00200661, 0x2c230082, 0x82242921, 0x22002106, + 0x2521008d, 0x21019520, 0x018d2022, 0x170f1729, 0x1f20290f, 0x832b3519, 0x2229242f, 0x42212021, 0x222305ee, 0x822b2029, 0x2b7b828b, 0x35262622, + 0x2d353f28, 0x1c362125, 0x1d20b882, 0x03406d83, 0x212b218f, 0x2c21018b, 0x25018721, 0x22282228, 0x01872429, 0x0383dc83, 0x22002224, 0x0084263d, + 0x2a1b3208, 0x25262525, 0x0f15211c, 0x00232914, 0x35384000, 0x212b222c, 0x252f252f, 0x2c35222b, 0x23290025, 0x18182f39, 0x220e0e0e, 0x0f0f1d19, + 0x320a2229, 0x35fa8222, 0x003a583a, 0x1b171414, 0x2a3e252f, 0x251a1a10, 0x151a152f, 0x0088251a, 0x1a1a2108, 0x202f2f2f, 0x2928283a, 0x2d21252d, + 0x281a182c, 0x2e2b3120, 0x28282e23, 0x39282a24, 0x1a282428, 0x252e2182, 0x1e242325, 0x24142324, 0x22140f25, 0x0d82380f, 0x1e19242a, 0x2f222517, + 0x251e2222, 0x28275282, 0x2b252928, 0x84232a2e, 0x831e2000, 0x820f2005, 0x84252000, 0x2069840e, 0x2b05821f, 0x3a242520, 0x2525393a, 0x3a2e392f, + 0x11827382, 0x292f2a2b, 0x2f202025, 0x17202337, 0x82c6822f, 0x2f2008de, 0x3e2e2828, 0x1b3a2539, 0x2f10101b, 0x1524222f, 0x241a1a25, 0x10152524, + 0x2528581b, 0x18252528, 0x2e260082, 0x2a2a2e2e, 0xc1880f2a, 0x0f21253c, 0x1e281e28, 0x24232d1a, 0x2f242322, 0x1f1f1f2f, 0x253a3a3a, 0x2818242d, + 0x0182291e, 0x28383e82, 0x2d232823, 0x23252d26, 0x0f202325, 0x1b201120, 0x252b252b, 0x1928232e, 0x1e280182, 0x17241724, 0x252a252a, 0x213a4483, + 0x2324302e, 0x2e1d251e, 0x43202425, 0x152a2433, 0x23133e20, 0x15231515, 0x4a832328, 0x40822520, 0x2d232523, 0x25018324, 0x252c252c, 0x01850f18, + 0x28141a26, 0x0f202222, 0x57845585, 0x53835582, 0x392d0383, 0x1122242f, 0x37392328, 0x391a232e, 0x2501832f, 0x25102224, 0xa4822a25, 0x250c3a2f, + 0x2c282525, 0x2c331f32, 0x28280f35, 0x080b8229, 0x28281828, 0x2e262b31, 0x2427232c, 0x2f332824, 0x1e242418, 0x24250f25, 0x24251b22, 0x2522220f, + 0x24231d22, 0x3022251d, 0x8b820f2f, 0x2e252f3c, 0x18282921, 0x40411a18, 0x2c24282f, 0x21282828, 0x2438252b, 0x2b282c2c, 0x42822c31, 0x24292808, + 0x2c283024, 0x2d3d3c29, 0x3c292735, 0x23242329, 0x2e23241b, 0x2225251e, 0x23252824, 0x1d1f2425, 0x25223122, 0x82333323, 0x31202d47, 0x1b252323, + 0x0f0f1e20, 0x25353514, 0x21256982, 0x25443a1b, 0x2000851f, 0x23008200, 0x262c232f, 0x00200682, 0x028bb182, 0x95232821, 0x052a4101, 0x18320589, + 0x2c0f180f, 0x381b2123, 0x2822282e, 0x24252c22, 0x07822422, 0x29232927, 0x2e232c25, 0x31518223, 0x2925201b, 0x442b3829, 0x24283039, 0x2f231e3a, + 0x6d831f28, 0x208f0340, 0x89ac822e, 0x232f2103, 0x2a250187, 0x2c252a25, 0x83018726, 0x230384dc, 0x29412500, 0x31080084, 0x28282d1d, 0x241e2829, + 0x2c150f17, 0x45000025, 0x252f393c, 0x2833242e, 0x242e2833, 0x00272f39, 0x333d262d, 0x0f0f1a1a, 0x1f1a250f, 0x252c1010, 0x2582360a, 0x66430036, + 0x18180043, 0x2b371f1a, 0x1e123148, 0x18372b1e, 0x2b1e181e, 0x21080088, 0x37371e1e, 0x2e432537, 0x2a342f2e, 0x1d323427, 0x38252e1e, 0x35283532, + 0x31292e2f, 0x292e422e, 0x21821e2e, 0x282b2b3c, 0x282a232a, 0x122a2a18, 0x41122817, 0x2a2a292a, 0x2a1a231d, 0x28283728, 0x52822b23, 0x2a243d82, + 0x28313532, 0x23200084, 0x12200583, 0x2a200082, 0x2a20b584, 0x2b210082, 0x2b6f8224, 0x432a2b25, 0x2b2b4143, 0x43354337, 0x11827382, 0x2f37312f, + 0x3725252b, 0x1a252940, 0x372b3737, 0x3c1b8231, 0x48352e2e, 0x1f432b42, 0x3712121f, 0x18292837, 0x2a1e1e2b, 0x12182b2a, 0x2a2e661f, 0x2975822e, + 0x351d1d1d, 0x31313535, 0xc1881231, 0x12262b3c, 0x232e232e, 0x2929341e, 0x372a2928, 0x24242437, 0x2b434343, 0x2e1d2a34, 0x01822f23, 0x2e243e82, + 0x34282e28, 0x28311182, 0x1225282a, 0x1f251425, 0x2a322a32, 0x1d2f2935, 0x2723822f, 0x1a291a29, 0x2a312a31, 0x263a4483, 0x292a3735, 0x35212a22, + 0x4e252a2b, 0x1831293a, 0x28164825, 0x18281818, 0x4a84282e, 0x2a234082, 0x832a3428, 0x21428301, 0x0185121d, 0x2e171e23, 0x85598228, 0x21578355, + 0x5385232e, 0x422d5783, 0x14282937, 0x4043282e, 0x421e2935, 0x21018337, 0xbd822829, 0xa4823020, 0x820e4321, 0x2e2e08c5, 0x3b243a32, 0x2e123d32, + 0x2e2a2f2e, 0x2e2e1d32, 0x352b3238, 0x292d2832, 0x373a2e29, 0x222a291d, 0x2a2a122a, 0x2a2a1f28, 0x2b282812, 0x10832228, 0x37372824, 0xeb822a12, + 0x26352a3b, 0x1d1d2e2f, 0x374a4b1e, 0x2e32292e, 0x32262e2e, 0x3229412a, 0x38312e32, 0x08428232, 0x29292f39, 0x30332e37, 0x3e344645, 0x2f452f2e, + 0x20282928, 0x2335282a, 0x2a282b2b, 0x2b292b2f, 0x2821242a, 0x292b2838, 0x352b3b3b, 0x28382526, 0x25202a28, 0x17121223, 0x822a3d3d, 0x20262569, + 0x242b4f43, 0x00200085, 0x36230082, 0x822c3329, 0x2b002106, 0x2e21008d, 0x21019528, 0x018d282a, 0x1d121d29, 0x26283312, 0x83354120, 0x2b32222f, + 0x3e8d8229, 0x2930282e, 0x28332a30, 0x2a2a2935, 0x2b251f2b, 0x32412f2f, 0x2e38424e, 0x28234329, 0x83242e37, 0x8f03406d, 0x8b293521, 0x29362101, + 0x31250187, 0x332a312a, 0x8301872c, 0x240383dc, 0x4c2b002a, 0x0800842f, 0x2e342231, 0x232e2f2e, 0x18121a29, 0x00002b32, 0x37424650, 0x3b29352b, + 0x352e3b2e, 0x2d37422a, 0x472b3300, 0x121e1e3b, 0x1e2b1212, 0x32121224, 0x823e0c2b, 0x4b003625, 0x1a004b72, 0x3d221e1a, 0x14375130, 0x3d302222, + 0x221b221b, 0x08008830, 0x3d222221, 0x4b293d3d, 0x3a343333, 0x383a2b2f, 0x2a34221f, 0x2d3b383f, 0x2e33343b, 0x334a3337, 0x8222332e, 0x30303c21, + 0x2f272f2d, 0x2f2f1a2d, 0x152c1a15, 0x2f2e2f49, 0x1e27202f, 0x2c3d2c2f, 0x8230272c, 0x243d8252, 0x373b382f, 0x2000842d, 0x20058327, 0x21008215, + 0x00832e2f, 0x3021ba83, 0x2b6f8229, 0x4b2f3029, 0x3030494b, 0x4b3b4a3d, 0x11827382, 0x353d372f, 0x3d292930, 0x1e292e48, 0x3d303d3d, 0x3f1b8237, + 0x503b3333, 0x224b304a, 0x3d141422, 0x1b2e2c3d, 0x2f222230, 0x141b302f, 0x2f337222, 0x1f2f2f33, 0x3b260082, 0x37373b3b, 0xc1881537, 0x152a302d, + 0x27332733, 0x2e2e3a22, 0x822f2d2c, 0x29292bcc, 0x304b4b4b, 0x331f2f3a, 0x01823427, 0x24083e82, 0x2d332d33, 0x2f3a313a, 0x2a2d2f2d, 0x2a162a15, + 0x382f3822, 0x342e3b2f, 0x33203420, 0x2e1e2e27, 0x372f371e, 0x3a44832f, 0x2f3d3b2a, 0x252f262e, 0x292f303b, 0x372e4157, 0x18512a1b, 0x2d1b1b2d, + 0x842d331b, 0x2340824a, 0x2f3a2d2f, 0x42830183, 0x85151f21, 0x1a222601, 0x2a2c2c34, 0x83558515, 0x83558357, 0x2d038353, 0x2c2e3d4a, 0x4a2d3317, + 0x222e3b48, 0x01833d4a, 0x142c2e25, 0x82363030, 0x104b21a4, 0x2e08c582, 0x28413833, 0x15443942, 0x2f353333, 0x341f3833, 0x31383f33, 0x322d383b, + 0x41332e2e, 0x2f2e1f3d, 0x2f152f26, 0x2f222c2f, 0x2c2c152f, 0x83262c30, 0x2c230810, 0x2f153d3e, 0x2f3d2f2e, 0x33352a3b, 0x54221f1f, 0x2e343d53, + 0x33333338, 0x492f382a, 0x3438382e, 0x82383f37, 0x34420842, 0x333d2e2e, 0x4e4d3539, 0x3533453b, 0x2e2d354e, 0x2d2f232d, 0x3030273c, 0x30342f2c, + 0x282f302e, 0x2c3f2c25, 0x43422d30, 0x292b3c30, 0x2f2d2d3f, 0x15272923, 0x45451a15, 0x302c2c2f, 0x584b232a, 0x00852930, 0x00820020, 0x392e3d23, + 0x20068231, 0x8bb18200, 0x2d332102, 0x2f210195, 0x08018d2d, 0x1f151f32, 0x2a2d3915, 0x343c4923, 0x382c342c, 0x2e2c2e30, 0x352c332c, 0x392f352d, + 0x2f2e3b2d, 0x2a22302f, 0x49343430, 0x3f4a5738, 0x274b2e34, 0x29333d2d, 0x03406d83, 0x2e3b218f, 0x3d21018b, 0x2501872e, 0x2f372f37, 0x01873139, + 0x0383dc83, 0x30002f24, 0x00843555, 0x3a263108, 0x33343333, 0x151e2e27, 0x0030381b, 0x4a4e5900, 0x2e3b303d, 0x34423442, 0x3d4a2f3b, 0x303a0033, + 0x2121424f, 0x30141414, 0x14142822, 0x460d3038, 0x00352582, 0x00537e53, 0x26211d1d, 0x3c593544, 0x35262616, 0x1e261e44, 0x844f8426, 0x26210804, + 0x44444426, 0x3939532d, 0x3034403a, 0x26223e40, 0x3e462e3a, 0x3a413241, 0x393d3339, 0x39333952, 0x2e218226, 0x34323535, 0x1d31342b, 0x1d183534, + 0x82511831, 0x23342a0d, 0x3135212b, 0x2c313144, 0x82528235, 0x3e34243d, 0x84323d41, 0x312b2100, 0x18200082, 0x35200082, 0x65840e84, 0x05822d20, + 0x33352d2b, 0x35515353, 0x41524435, 0x82738253, 0x3c320811, 0x2d353b44, 0x324f442d, 0x4444212d, 0x363c4435, 0x39394436, 0x35515941, 0x16262653, + 0x31444416, 0x26351e33, 0x35343426, 0x7e26161e, 0x34393439, 0x00822234, 0x41414126, 0x183d3d3d, 0x2f2cc289, 0x392b3918, 0x3340262c, 0x34323133, + 0x2d2bcc82, 0x5353532d, 0x22344035, 0x823a2b39, 0x083e8201, 0x39323943, 0x40364032, 0x31343134, 0x192e182e, 0x353e262e, 0x3241353e, 0x233a233a, + 0x21332b39, 0x353d2133, 0x2c39353d, 0x412f2c39, 0x2b323444, 0x35422934, 0x48612d34, 0x2e1e3d33, 0x1d321b59, 0x391d321d, 0x824a8432, 0x31342340, + 0x01833440, 0x22214283, 0x23018518, 0x313a1d26, 0x55855982, 0x55835783, 0x03825383, 0x4452342e, 0x39193133, 0x414f5232, 0x44522632, 0x33250183, + 0x35351631, 0x21a4823c, 0xc5821253, 0x3e395608, 0x3f492d48, 0x3939184b, 0x3e39343a, 0x46393a22, 0x3e41363e, 0x33333832, 0x22444839, 0x352b3433, + 0x31333418, 0x18343526, 0x31353131, 0x2a34322a, 0x44443134, 0x34323418, 0x2f423444, 0x2222393a, 0x445c5d26, 0x393e333a, 0x3e2f3939, 0x3e335134, + 0x463d3a3e, 0x0842823e, 0x33333a42, 0x3b3f3944, 0x4c415756, 0x3b563a39, 0x27313332, 0x2c423134, 0x34313535, 0x3532353a, 0x31292c34, 0x32363146, + 0x42354a49, 0x32462d2f, 0x2d273531, 0x1d18182b, 0x31354c4c, 0x272f3531, 0x2d356153, 0x00200085, 0x43230082, 0x82373f32, 0x82002006, 0x21028bb1, + 0x01953239, 0x8d313421, 0x18223d01, 0x313f1822, 0x4251272f, 0x313a313a, 0x3133353e, 0x31393133, 0x353b323b, 0x3241313f, 0x26315182, 0x3a3a352e, + 0x52613e51, 0x53333a45, 0x3944322b, 0x406d832d, 0x41218f03, 0x21018b32, 0x01873243, 0x3d353d25, 0x87373f35, 0x83dc8301, 0x00342403, 0x843b5e35, + 0x2a310800, 0x3a393940, 0x21332b39, 0x353e1e18, 0x56630000, 0x41354452, 0x49394933, 0x52344139, 0x40003844, 0x25495836, 0x16161625, 0x162c2635, + 0x0f353e16, 0x3625824d, 0x5c8c5c00, 0x24202000, 0x633a4b2a, 0x2a2a1943, 0x2a214b3a, 0x883a2a21, 0x2a210800, 0x4b4b4b2a, 0x3f3f5c32, 0x353a4740, + 0x2a274547, 0x454e3340, 0x40483748, 0x3f43393f, 0x3f393f5b, 0x3c21822a, 0x39373a3a, 0x20373930, 0x20183a39, 0x3a591836, 0x27393938, 0x363a2430, + 0x3036364b, 0x2752823a, 0x3a403f3f, 0x37434845, 0x30200084, 0x18200583, 0x3a210082, 0x84008338, 0x82322069, 0x3a322b05, 0x5a5c5c39, 0x5b4b3a3a, + 0x73825c48, 0x3b3a2608, 0x414b433a, 0x4b32323a, 0x24323858, 0x4b3a4b4b, 0x4b3b3b43, 0x62483f3f, 0x2a5c3a5a, 0x4b19192a, 0x2139364b, 0x2bb1823a, + 0x19213a3a, 0x3a3f8c2a, 0x273a3a3f, 0x48260082, 0x43434848, 0xc1881843, 0x18343a2d, 0x303f303f, 0x3938472a, 0x82393836, 0x32322bcc, 0x3a5c5c5c, + 0x3f273947, 0x01824030, 0x213a393c, 0x373f373f, 0x3a473c47, 0x33373a37, 0x331b3318, 0x453a452a, 0x4038483a, 0x23824027, 0x39243927, 0x433a4324, + 0x3744833a, 0x394b4834, 0x2e3a2f38, 0x32393a49, 0x4338506b, 0x1e633321, 0x38212138, 0x4a834182, 0x3a234083, 0x83394737, 0x21428301, 0x01851827, + 0x40202a26, 0x18333636, 0x57835585, 0x85303f21, 0x2d578353, 0x36394b5b, 0x5b373f1c, 0x2a384858, 0x01834b5b, 0x19363925, 0x82423a3a, 0x135c21a4, + 0x5608c582, 0x3250453f, 0x18544551, 0x3a413f3f, 0x4027453f, 0x3c454e3f, 0x3e374548, 0x503f3939, 0x3939274b, 0x3a183a2f, 0x3a2a3639, 0x36361839, + 0x382e363b, 0x363a2f3a, 0x3a184b4c, 0x3a4b3a38, 0x3f403449, 0x672a2727, 0x39404b65, 0x3f3f3f45, 0x5a3a4534, 0x40454539, 0x82454e44, 0x40390842, + 0x3f4b3939, 0x605f4246, 0x413f5548, 0x3937415f, 0x37392b37, 0x3b3b3049, 0x3b403936, 0x31393b38, 0x364d362e, 0x5251383b, 0x3235493b, 0x3a37374d, + 0x1830322b, 0x54542018, 0x2569823a, 0x6c5c2b34, 0x0085323b, 0x00820020, 0x46384a23, 0x2006823d, 0x8bb18200, 0x09b04202, 0x2a41098d, 0x08058905, + 0x27182732, 0x34374518, 0x40495a2b, 0x45364036, 0x3936393b, 0x42363f36, 0x453a4238, 0x3a384837, 0x332a3a3a, 0x5940403a, 0x4d5b6b45, 0x305c3940, + 0x323f4b37, 0x03406d83, 0x3848218f, 0x4a21018b, 0x25018738, 0x3a433a43, 0x01873d46, 0x0384dc83, 0x683a0023, 0x08008441, 0x3f472e32, 0x303f403f, + 0x21182439, 0x00003b45, 0x4b5a606d, 0x5139483a, 0x483f513f, 0x3e4b5b39, 0x613b4700, 0x18292951, 0x2a3a1818, 0x45191931, 0x3a55103b, 0x6435fa82, + 0x23006498, 0x522e2723, 0x1b496c40, 0x52402d2d, 0x2d242d24, 0x08008840, 0x522d2d21, 0x64375252, 0x4d464544, 0x4b4e393f, 0x38452d2a, 0x3c4f4b54, + 0x3e44464f, 0x45634449, 0x822d453e, 0x40270821, 0x343e3c40, 0x3e233c3e, 0x3b221b3f, 0x3d3f611b, 0x342b3e3e, 0x523b3f27, 0x3f353b3b, 0x44523f2d, + 0x4b3f4644, 0x843c494f, 0x83342000, 0x821b2005, 0x3d3f2100, 0x3f200083, 0x40210082, 0x2b6f8236, 0x643e4037, 0x40406264, 0x644f6352, 0x11827382, + 0x4752492f, 0x52373740, 0x27373d60, 0x52405252, 0x321b8249, 0x6b4f4444, 0x2e644062, 0x521b1b2e, 0x243e3b52, 0x822d2d40, 0x1b2429f4, 0x3f44982e, + 0x2a3f3f44, 0x4f260082, 0x49494f4f, 0xc1881b49, 0x1b38403c, 0x35453444, 0x3e3d4e2d, 0x523e3d3b, 0x36363652, 0x40646464, 0x442a3e4e, 0x01824634, + 0x403e4608, 0x443c4424, 0x4e414d3c, 0x3c3f3c3f, 0x1e381b38, 0x3f4b2e38, 0x3d4f3f4b, 0x2b462b46, 0x273e3444, 0x3f49273e, 0x35453f49, 0x4f393545, + 0x333d3e52, 0x404f323f, 0x5774373e, 0x3824493d, 0x233c206c, 0x44233c23, 0x834a833c, 0x3c3f2340, 0x01833e4e, 0x2a214283, 0x2601851b, 0x3b45222d, + 0x851b383b, 0x83578355, 0x83538355, 0x52632d03, 0x441e3b3e, 0x4f60633c, 0x52632d3d, 0x3e210183, 0x20bd823b, 0x21a48248, 0xc5821564, 0x4b445608, + 0x4b583657, 0x45441b5b, 0x4b453f46, 0x5445452a, 0x4b4f414b, 0x3e3e433c, 0x2a525745, 0x3f333e3e, 0x3b3e3f1b, 0x1b3e3f2e, 0x3b403b3b, 0x333f3d32, + 0x51523b3f, 0x3f3d3f1b, 0x394f3f51, 0x2a2a4446, 0x526e702d, 0x444b3e45, 0x4b394545, 0x4b3e613f, 0x5449454b, 0x0842824b, 0x3e3e4639, 0x474c4552, + 0x5c4e6967, 0x47674644, 0x2f3b3d3c, 0x34503c3e, 0x3e3b4040, 0x403d4046, 0x3b32353e, 0x3d403b54, 0x4f405958, 0x3c543739, 0x372f3f3c, 0x221b1b34, + 0x823f5b5b, 0x2f392569, 0x36407564, 0x00200085, 0x51230082, 0x82424c3d, 0x82002006, 0x21028bb1, 0x01953c44, 0x89052a41, 0x1b2a3205, 0x3c4b1b2a, + 0x50612f39, 0x3b453b45, 0x3b3e404b, 0x3c07823e, 0x3f473d47, 0x3d4f3c4b, 0x2e403f3f, 0x46464038, 0x63754b61, 0x643e4554, 0x45523c34, 0x406d8336, + 0x4f218f03, 0x21018b3d, 0x01873d51, 0x493f4925, 0x87424c3f, 0x84dc8301, 0x40002303, 0x00844771, 0x4e323108, 0x44464444, 0x1b273e34, 0x00404b24, + 0x62687700, 0x3e4f4051, 0x45584558, 0x52633e4f, 0x414d0044, 0x2d2d586a, 0x401b1b1b, 0x1b1b352d, 0x5d12404b, 0xfc832582, 0x01000222, 0x00230683, + 0x83030014, 0x1a012609, 0x06010000, 0x82148600, 0x02022507, 0x00020000, 0xe608008d, 0x03000001, 0x07060504, 0x0b0a0908, 0x0f0e0d0c, 0x13121110, + 0x17161514, 0x1b1a1918, 0x1f1e1d1c, 0x23222120, 0x27262524, 0x2b2a2928, 0x2f2e2d2c, 0x33323130, 0x37363534, 0x3b3a3938, 0x3f3e3d3c, 0x43424140, + 0x47464544, 0x4b4a4948, 0x4f4e4d4c, 0x53525150, 0x57565554, 0x5b5a5958, 0x5f5e5d5c, 0x62006160, 0x66656463, 0x6a696867, 0x6e6d6c6b, 0x7271706f, + 0x76757473, 0x7a797877, 0x7e7d7c7b, 0x8281807f, 0x86858483, 0x8a898887, 0x8e8d8c8b, 0x9291908f, 0x96959493, 0x9a999897, 0x9e9d9c00, 0xa2a1a09f, + 0xa6a5a4a3, 0xaaa9a8a7, 0xadac03ab, 0xb1b0afae, 0xb5b4b3b2, 0xb9b8b7b6, 0xbdbcbbba, 0xc1c0bfbe, 0xc5c4c300, 0xc9c8c7c6, 0xcdcccbca, 0x00d0cfce, + 0xd4d3d2d1, 0x00d7d6d5, 0xdcdbdad9, 0x00dfdedd, 0x825c0604, 0xcad008f4, 0x06008000, 0x7e004a00, 0x8f017f01, 0xa1019201, 0xff01b001, 0x59021b02, + 0xc902c702, 0x0103dd02, 0x09030303, 0x33032303, 0x7e034703, 0x8c038a03, 0xce03a103, 0x4f040d04, 0x79045f04, 0x87047d04, 0x97049304, 0xa3049d04, + 0xb304a904, 0xd904bf04, 0x1d05e904, 0x80056405, 0x851e3f0e, 0xcb1e9e1e, 0xf91ef11e, 0x22201520, 0x30202620, 0x3a203420, 0x3e203c20, 0x75204420, + 0x7f207820, 0xb820b520, 0x0521f020, 0x16211321, 0x22212021, 0x2e212621, 0x02225e21, 0x0f220622, 0x15221222, 0x1e221a22, 0x48222b22, 0x65226122, + 0x02250025, 0x10250c25, 0x18251425, 0xab25a125, 0xcf25ca25, 0x6a26e625, 0x732c6d2c, 0x8ca71fa7, 0xe6ff02fb, 0xfffffdff, 0x2022d382, 0xcb84a000, + 0xaf01a026, 0x1802fa01, 0xc620cb82, 0xd822cb82, 0xcb8c0003, 0xcb828420, 0xa3038e2c, 0x0e040104, 0x78045104, 0xcb827c04, 0x96049032, 0xa2049a04, + 0xae04a804, 0xd804b804, 0x1a05e804, 0x8020cb86, 0xa028cb82, 0xf21ecc1e, 0x17201220, 0x2f24cb82, 0x39203220, 0x7422cb86, 0xcb827720, 0xcb92a020, + 0xcb865b20, 0xcb821120, 0xcb861920, 0x64226022, 0xaa20cb8e, 0x7128cb8a, 0x88a71ba7, 0xe5ff01fb, 0xff21cb83, 0x08cd82e3, 0x14fffa20, 0x9900a600, + 0x71018aff, 0x00003100, 0x00000ffe, 0x78004cff, 0x28ff41ff, 0x4b005e00, 0x1382a0fc, 0x21068565, 0x1b82d8fd, 0x19ff1b30, 0x000010ff, 0xf5fdf7fd, + 0xf0fef1fd, 0x0b82e7fd, 0xb9fdc732, 0x3ffd84fe, 0x77f424fd, 0x04e50be3, 0x80e4bde3, 0x02825982, 0x8285e021, 0x002e0804, 0xf9e084e0, 0x77e056e1, + 0xc9e1cae1, 0x0000b7e0, 0xb3e2fee2, 0x2be038e0, 0x5de223e1, 0x79df6adf, 0x3ce068e0, 0xa2de96de, 0x00008bde, 0x0382a6de, 0x71de7424, 0x07825fde, + 0x7ede3025, 0x83de7dde, 0xde6e3e0d, 0xdb9edb6b, 0xdbeeda96, 0xdd5ddb73, 0xd737d71a, 0x5c8d5c34, 0x00be0525, 0x00b80300, 0x20658201, 0x8a0382c8, + 0x78022402, 0x82020000, 0x2a128a03, 0x00740200, 0x027e0200, 0x82fa02a4, 0x83c38235, 0x2603211b, 0x03850583, 0x85220321, 0x2b058d07, 0x2a031c03, + 0x00003003, 0x46034403, 0x3c20198e, 0x0d8b0f8d, 0x004c0324, 0x03820300, 0x03211383, 0x9f058348, 0x3c898603, 0x00a30003, 0x03850084, 0x0096007c, + 0x008600e6, 0x008b008e, 0x00a9009d, 0x001000a4, 0x0be8828a, 0x9300833e, 0xf100f000, 0x97008d00, 0x01018800, 0xef00dc00, 0xaa009e00, 0xf200f300, + 0xa200f400, 0xc800ac00, 0xad00c600, 0x63006200, 0x64009000, 0x6500ca00, 0xc900c700, 0xcb00ce00, 0xcd00cc00, 0x6600e700, 0xcf00d100, 0xae00d000, + 0xee006700, 0xd4009100, 0xd300d200, 0xe9006800, 0x8900eb00, 0x69006a00, 0x6d006b00, 0x6e006c00, 0x6f00a000, 0x70007100, 0x73007200, 0x74007500, + 0x77007600, 0x7800e800, 0x79007a00, 0x7d007b00, 0xb7007c00, 0x7f00a100, 0x80007e00, 0xea008100, 0xb900ec00, 0x45014401, 0x03010201, 0x05010401, + 0xfc00fb00, 0x47014601, 0x49014801, 0xfe00fd00, 0x07010601, 0xff000801, 0x4b014a01, 0x4d014c01, 0x4f014e01, 0x0a010901, 0x0c010b01, 0x51015001, + 0xf700f600, 0x53015201, 0x55015401, 0x57015601, 0x59015801, 0x5b015a01, 0x5d015c01, 0x5f015e01, 0x61016001, 0xd500f800, 0x39013801, 0x63016201, + 0x65016401, 0x0d016601, 0x67010e01, 0x0f016801, 0x11011001, 0xe0001201, 0x1301e100, 0x69011401, 0x15016a01, 0x3a011601, 0x6c016b01, 0x6e016d01, + 0x70016f01, 0x18011701, 0xb000af00, 0x1a011901, 0x72017101, 0x1c011b01, 0x1e011d01, 0x74017301, 0xfa00f900, 0xe300e200, 0x20011f01, 0x22012101, + 0x76017501, 0x78017701, 0x7a017901, 0x7c017b01, 0x24012301, 0x26012501, 0x7e017d01, 0x80017f01, 0x82018101, 0x2701ba00, 0x29012801, 0xe4002a01, + 0x8301e500, 0xdf00d600, 0xda00d900, 0xde00db00, 0xdd00d700, 0x9e019d01, 0x8a019f01, 0xa101a001, 0xa401a201, 0xa601a501, 0xa801a701, 0xa9012b01, + 0xab01aa01, 0x2c01ac01, 0xae01ad01, 0xb001af01, 0xb201b101, 0xb401b301, 0xb601b501, 0xb801b701, 0xb9012d01, 0xbb01ba01, 0xbd01bc01, 0xbf01be01, + 0xc101c001, 0x2e01c201, 0xc401c301, 0x30012f01, 0xc601c501, 0xc801c701, 0xca01c901, 0xcc01cb01, 0xce01cd01, 0xcf013a02, 0x3101d001, 0xd1013201, + 0xd2013301, 0xd401d301, 0xd601d501, 0xd801d701, 0xda01d901, 0xdc01db01, 0xde01dd01, 0xe001df01, 0xe201e101, 0xe401e301, 0x8f03e501, 0x29022802, + 0x2b022a02, 0x2d022c02, 0x2f022e02, 0x31023002, 0x33023202, 0x34029003, 0x36023502, 0x8b023702, 0x9b028c02, 0x9d029c02, 0x9a039e02, 0x9c039b03, + 0x91019d03, 0x74039201, 0x76037503, 0x78037703, 0xa5027903, 0xb200b100, 0x34013802, 0xb600b500, 0x9301c300, 0xb400b300, 0xa602c400, 0xc1008200, + 0xb4038700, 0x3b01c500, 0xa7023c01, 0xa902a802, 0xf500aa02, 0xab029501, 0x3701ac02, 0xae02ad02, 0x7a03af02, 0xb002bc00, 0xb202b102, 0xb402b302, + 0x86038503, 0x88038703, 0xed009900, 0xa500c200, 0xb5028f00, 0xae029600, 0x15400000, 0x36375455, 0x2d2e2f32, 0x1f25262c, 0x11121314, 0x04050c0d, + 0xb0202c02, 0x23452503, 0x68612345, 0x6845208a, 0x44238a20, 0x2c2d4460, 0x4558524b, 0x21211b44, 0x202c2d59, 0x442d1682, 0x6001b020, 0x46b04520, + 0x8a186876, 0x26208345, 0xb02b12b0, 0x83452502, 0xb06a2403, 0x82608b40, 0x44232808, 0x2d212121, 0x8913b02c, 0xffb82319, 0x1a8a8cc0, 0xb069203d, + 0x00b06140, 0x2cb1208b, 0xb88c8ac0, 0x60620010, 0x23640c2b, 0x585c6164, 0x826103b0, 0x00b1216b, 0x68218c82, 0x820d8254, 0x270a825a, 0xb0206860, + 0x44232504, 0x1b200484, 0xa286a982, 0x45220982, 0x05826068, 0x82442321, 0x82179435, 0x43092888, 0xc0218758, 0x8212b01b, 0xb0452507, 0x47b02b11, + 0x47294982, 0x031be47a, 0x6918458a, 0x270e8320, 0x20878a8a, 0x5851a0b0, 0x21211d8b, 0x232382b0, 0x18595959, 0x080c0641, 0x46234624, 0x468a8a60, + 0x8a462023, 0xb8618a60, 0x236280ff, 0x8a231020, 0x8a4b4bb1, 0x20604570, 0x585000b0, 0x178201b0, 0x1b8bba30, 0x598c46b0, 0x686010b0, 0x2c2d3a01, + 0x9d824520, 0x58524626, 0x11211b3f, 0x2122aa82, 0xef820c21, 0x40b88b2b, 0x2c2d6200, 0x5180b021, 0x2c0f8558, 0x1b620020, 0x2f4000b2, 0x02b0592b, + 0x20198360, 0x211987c0, 0x19835515, 0x19878020, 0x60223e88, 0xe2822123, 0x58431325, 0x82021b03, 0x534b2a58, 0x5a514b23, 0x8a452058, 0x06b74160, + 0x38201186, 0x0805c541, 0x0002b121, 0x0123b142, 0x40b15188, 0x5a538801, 0x0010b958, 0x54882000, 0x0102b258, 0x42604302, 0x8224b159, 0xb958251b, + 0x40000020, 0x02201584, 0x14831583, 0x20202283, 0x00240c83, 0x524b014b, 0x08202f82, 0x1b252f84, 0x000040b9, 0x202a8480, 0x84108404, 0xb863230f, + 0x13840001, 0x13822485, 0x63000124, 0x138502b8, 0x27871020, 0x13820220, 0x13850420, 0x13844020, 0x00825920, 0x0223cc82, 0x8b585443, 0x08b982b5, + 0x5921212b, 0xb900002d, 0xc0ff5400, 0x29b21e40, 0xb2103632, 0xb240b220, 0xb270b250, 0xb2a0b280, 0xb2d0b2b0, 0xc00ab2e0, 0x02b2f0b2, 0x082282b8, + 0x17b57032, 0x441f3618, 0x1f560f01, 0x554f0256, 0x6f02555f, 0x549f0154, 0x510254af, 0x52041753, 0x53041653, 0x4a041552, 0x46045249, 0x47043749, + 0x48043249, 0x49380382, 0x3c043935, 0x3d04323f, 0x3e043d3f, 0x4304213f, 0x42041d3f, 0x4104523f, 0x40200382, 0x29080382, 0x0432353f, 0x04643332, + 0x04343533, 0x04543435, 0x041e3534, 0x34e034d0, 0xb80334f0, 0xb4b3eeff, 0xb8364825, 0xb4b3e0ff, 0x07822310, 0x0d40ee2e, 0x360f09b4, 0x04481ab4, + 0xb386b376, 0xf0229682, 0x2184b3b3, 0x40fab208, 0x2409b3ff, 0x4814b336, 0x13888904, 0x706c7004, 0x9c0f0278, 0x40029edf, 0x3619169d, 0x1b169c40, + 0x17974036, 0x96403619, 0x86361b17, 0x0f1f1385, 0x0f850f84, 0x0f8f0f8e, 0x1f841f90, 0x2f8f1f8e, 0x8085808e, 0x90918f88, 0x90879085, 0x82400f88, + 0x0f361009, 0x02721f72, 0x0c097140, 0x016d0f36, 0x2001c820, 0xc63f01c7, 0x2002c6ef, 0x02c540c5, 0x00016200, 0x02621062, 0x61a06140, 0x015b0f02, + 0x0411142d, 0x0425142c, 0x0439142b, 0x0413142a, 0x04151429, 0x041e141f, 0x04432021, 0x043c1420, 0x04451ac9, 0x04471b1a, 0x043c1a1b, 0x0432141a, + 0x20278215, 0x24ae8213, 0x041a1412, 0x3b038211, 0x40011470, 0x36434114, 0x1f2a0e0f, 0x0d010600, 0x0c1f4bc3, 0x0a1f4bc2, 0x091f4bc0, 0x57080382, + 0x1f4bbc05, 0x1f4bbd04, 0x1f4bb903, 0x1f4bba02, 0x1f4bb601, 0x1f4bb700, 0x1f2ac2c3, 0x1f2abfc0, 0xbc5640bd, 0xb9ba1f21, 0xb6b71f21, 0xc3c21f21, + 0xc0bf0dc4, 0xbdbc0dc1, 0xbab90cbe, 0xb7b60cbb, 0xbc100cb8, 0x4002bc80, 0x02b980b9, 0xb63fb60f, 0xb67fb64f, 0x2fb60f04, 0x6f200a82, 0x27080a82, + 0xb6cfb6bf, 0x0a08b6ff, 0x0c043709, 0x0405020d, 0x02020302, 0x50020001, 0x01b80105, 0x12b001ff, 0x544b004b, 0x0113b042, 0x53390782, 0x3209b142, + 0x64b04b2b, 0x8d854252, 0x96b01d8d, 0xb058524b, 0xb8591d80, 0x2a238208, 0xb001b058, 0xb0598e01, 0x86534b08, 0x05f05c0a, 0x73747323, 0x0df85c73, + 0xb02c0d85, 0x06b04503, 0xb0616845, 0x73442306, 0x0e200c83, 0x0e270c83, 0x0eb04423, 0x830fb045, 0x230f2a0b, 0xb0012b44, 0xb0684514, 0x90098214, + 0x87732044, 0x732b2100, 0x54830182, 0x28846885, 0x93750021, 0x088b8373, 0x732b7431, 0x062b2b74, 0x0514061e, 0x04d105f0, 0x035d047c, 0x001000dd, + 0xffe7ff00, 0xfe78fee1, 0x0359fe64, 0x001f0094, 0x00960000, 0x00b900aa, 0x82ce00c6, 0x2202850b, 0x84c200bc, 0x00762608, 0x00c000b2, 0x870b84cb, + 0x00812a04, 0x00a60094, 0x00da00cc, 0x271287ef, 0x9e009800, 0xb000ab00, 0x08830f88, 0x15849020, 0xa900a42a, 0xb300ae00, 0xc300ba00, 0x88221482, + 0x15829100, 0xac00a522, 0x02870b82, 0x87006f2c, 0x9b008f00, 0xd300a000, 0x14861d01, 0x1402c323, 0x36818501, 0x020c00e9, 0x017301d1, 0x001a008e, + 0x0044002c, 0x0073005c, 0x8286007e, 0x01c82297, 0x2013824c, 0x2013823d, 0x24158250, 0x00780072, 0x22158292, 0x86c800b9, 0x2a068b43, 0x0056003d, + 0x006a005d, 0x82b1006e, 0x84c120e9, 0x002a261a, 0x0054003d, 0x83158264, 0x2d128413, 0x7a007100, 0xa1008900, 0xbb00a700, 0x0b826f00, 0xaf828720, + 0x1a859a20, 0x8128058c, 0x21022102, 0xe5007400, 0xca244d82, 0xc6029501, 0xa730d182, 0x14068500, 0x00000a00, 0x1f00d105, 0x5d040000, 0x00390583, + 0x00e1ff00, 0xff64fe00, 0x030000f5, 0x02f40262, 0x009102a2, 0x006a02af, 0x214f824c, 0x0185001f, 0x00647a0c, 0x0121018d, 0x037c02dd, 0x03720359, + 0x042304c6, 0x04c80493, 0x051005f2, 0x0557052c, 0x063a06d9, 0x089207de, 0x09ad0820, 0x0a89094e, 0x0bfb0a63, 0x0b5d0b21, 0x0cd10ba2, 0x0d800c17, + 0x0ee30d65, 0x0f370fbd, 0x102910c9, 0x1131118d, 0x120112b9, 0x13f5125e, 0x1401143f, 0x154d15ad, 0x17a516ef, 0x18331858, 0x19161980, 0x1af81972, + 0x1bfc1a79, 0x1b751b3f, 0x1ce21ba0, 0x1c301c1a, 0x1e521d50, 0x1fa01e11, 0x20ef1f55, 0x225b2179, 0x237f221a, 0x23a92312, 0x251925f4, 0x277b26d2, + 0x28fa2741, 0x296f2979, 0x2ba62af4, 0x2c9c2b02, 0x2c892c2b, 0x2d2a2dcb, 0x2ead2d45, 0x2e262e0c, 0x2f8d2fda, 0x2fb32fa0, 0x2fe52fcc, 0x300930f7, + 0x3036301b, 0x315b3048, 0x31333121, 0x31573145, 0x3180316d, 0x32f63193, 0x326d325b, 0x3291327f, 0x32b932a3, 0x32dd32cb, 0x330133ef, 0x33533318, + 0x3431348d, 0x35a335c0, 0x36fb35c3, 0x387837be, 0x3876381e, 0x39bd3897, 0x3ac43928, 0x3b2c3ba0, 0x3cba3b6c, 0x3d743c09, 0x3d883d09, 0x3e553efa, + 0x3f053fa8, 0x40bb3f7a, 0x42974174, 0x42c44259, 0x430f43eb, 0x44cb434c, 0x448e4450, 0x452f45df, 0x456c4559, 0x4692457f, 0x47134738, 0x4743472d, + 0x47c14782, 0x480d48e6, 0x488e4849, 0x48bf48a5, 0x499a49dd, 0x4af149c5, 0x4b604bae, 0x4bcd4bb5, 0x4d324cf3, 0x4d194d06, 0x4d3f4d2c, 0x4d664d53, + 0x4d8c4d79, 0x4db94da6, 0x4ddf4dcc, 0x4e054ef2, 0x4e2b4e18, 0x4ea14e71, 0x4f004fe8, 0x4f5a4f46, 0x50d74fa3, 0x5044500f, 0x51e55075, 0x515d514a, + 0x5182516f, 0x52bc5194, 0x53055371, 0x532a5318, 0x547d54d1, 0x55ce549a, 0x55545502, 0x56f355d2, 0x56435617, 0x56bf56b3, 0x57e456d1, 0x59ff58f4, + 0x59245912, 0x5a495937, 0x5a205a09, 0x5a4b5a38, 0x5c005b5d, 0x5c155c02, 0x5de25cda, 0x5e425e87, 0x5e675e55, 0x5f9f5e7a, 0x5f715f09, 0x602e60d2, + 0x60536041, 0x60786066, 0x609f608c, 0x60c560b2, 0x60eb60d8, 0x611061fe, 0x624d628f, 0x63fe6260, 0x635a6347, 0x6381636e, 0x63a76394, 0x64cc63ba, + 0x65c3641d, 0x66006660, 0x676067bc, 0x683968e7, 0x69f968d5, 0x6a616915, 0x6aae6a81, 0x6b846bc7, 0x6ce66ba7, 0x6d2a6d9f, 0x6d6c6d52, 0x6ebe6d93, + 0x6e296e17, 0x6e4c6e3a, 0x6e736e61, 0x6e9a6e88, 0x6ebd6eab, 0x6ee36ed1, 0x6f066ff4, 0x6f2d6f1b, 0x71167042, 0x711b7109, 0x72f87135, 0x734c73b8, + 0x743f74dd, 0x75047595, 0x76e57570, 0x7782766b, 0x772b7714, 0x78cc7741, 0x78c97851, 0x79f578df, 0x7a867ac0, 0x7aa97a98, 0x7acc7abb, 0x7b8d7be8, + 0x7bb37b9f, 0x7c957cff, 0x7cb87ca7, 0x7cdb7cca, 0x7dfe7ced, 0x7e967ed3, 0x7eba7ea8, 0x7fdd7ecc, 0x8121803a, 0x81868170, 0x81af8198, 0x81db81c4, + 0x82ff81ed, 0x82238211, 0x825c8240, 0x828a8273, 0x83c882b2, 0x83b8834c, 0x840184d4, 0x845a842e, 0x84b3847f, 0x850785cc, 0x8552851d, 0x85bd8586, + 0x863886fc, 0x86f08674, 0x870087f8, 0x874a8742, 0x875a8752, 0x876a8762, 0x87bb87b3, 0x880788c3, 0x8897880f, 0x8931899f, 0x89418939, 0x8a078a49, + 0x8bdd8abe, 0x8b168b01, 0x8b488b31, 0x8c798b60, 0x8dfc8c73, 0x8f468e9b, 0x8f218f19, 0x904b90ec, 0x91f690ee, 0x92d091c8, 0x930e9375, 0x943294b9, + 0x95e695f6, 0x960a96ee, 0x9630961f, 0x975b9642, 0x971a9702, 0x97aa97a2, 0x97d197b2, 0x99ac98d9, 0x9a0a9a7c, 0x9bc19a1f, 0x9b559b4d, 0x9cf99bf1, + 0x9cef9c49, 0x9ecd9df7, 0x9f209f7b, 0xa1aca0f1, 0xa131a129, 0xa141a139, 0xa1d1a1c9, 0xa2e1a1d9, 0xa2f4a257, 0xa49ba3fc, 0xa58da418, 0xa69ea513, + 0xa7dea654, 0xa844a873, 0xa9f7a8ef, 0xaa87aab8, 0xab66abd9, 0xac27ac6e, 0xae77addd, 0xafdfae3c, 0xb043b07c, 0xb1d7b0cf, 0xb15fb157, 0xb224b2d6, + 0xb2f1b22c, 0xb49eb3f9, 0xb5cdb444, 0xb6f5b561, 0xb73fb7bb, 0xb999b8c3, 0xba53b93d, 0xba44ba33, 0xbac0bab8, 0xbad0bac8, 0xbcbabbd8, 0xbd52bd92, + 0xbef6bd6c, 0xbfffbe8f, 0xc087bf71, 0xc105c185, 0xc17ac129, 0xc230c2f6, 0xc3c9c295, 0x0801874b, 0xc40dc4e3, 0xc66ec5b3, 0xc67bc635, 0xc69ac691, + 0xc7e4c6a3, 0xc89bc723, 0xc842c804, 0xc9e7c87f, 0xca9ec950, 0xca5eca12, 0xcb2ccbaf, 0xcc25ccb1, 0xcc4ccc37, 0xcc7ccc66, 0xcca8cc92, 0xccd4ccbe, + 0xcd02cdec, 0xcd2acd14, 0xcd66cd47, 0xcd8dcd78, 0xcdb4cd9f, 0xcddbcdc6, 0xce02ceed, 0xce3ece22, 0xce62ce50, 0xce96ce7d, 0xcebdceac, 0xcee7ced5, + 0xcf11cfff, 0xcf3dcf27, 0xcf61cf4f, 0xcf9bcf81, 0xcfc5cfb3, 0xd0e9cfd7, 0xd1dad06f, 0xd23cd10b, 0xd3c7d216, 0xd4c6d350, 0xd516d55f, 0xd586d54e, + 0xd596d58e, 0xd65fd6f6, 0xd741d7e3, 0xd8f0d799, 0xd834d82c, 0xd844d83c, 0xd9ffd8a9, 0xd98cd94b, 0xdae5d9a6, 0xdbcdda42, 0xdc65dcd5, 0xdda1ddfc, + 0xdfb8deb4, 0xdf6edf0b, 0xe1dde0ce, 0xe20ee27b, 0xe3d8e23b, 0x0100106f, 0xce082801, 0xe393e381, 0xe3c6e3b1, 0xe4fbe3e2, 0xe425e413, 0xe456e43d, + 0xe487e46e, 0xe4c1e4a7, 0xe5e9e4d8, 0xe518e503, 0xe540e52e, 0xe56de556, 0xe591e57f, 0xe5b5e5a3, 0xe5dde5cb, 0xe60ce6f4, 0xe63fe627, 0xe667e655, + 0xe68ae679, 0xe6aee69c, 0xe6dfe6c9, 0xe707e7f1, 0xe735e720, 0xe85ce74b, 0xe834e82b, 0xe975e9b1, 0xe99fe98b, 0xe9d3e9b9, 0xea07eaed, 0xebc9ea44, + 0xec25ec52, 0xecbbecaf, 0xecd3ecc7, 0xedf4ecde, 0xed2ded1b, 0xed62ed3e, 0xeef5ed86, 0xef1aef55, 0xf019f0e5, 0xf143f1b8, 0xf220f2b5, 0xf238f22c, + 0xf248f240, 0xf258f250, 0xf3d2f2c9, 0xf366f32c, 0xf418f4bf, 0xf456f437, 0xf494f475, 0xf4b6f49d, 0xf4e1f4be, 0xf5fff4f7, 0x8229f514, 0xf5892e01, + 0x010200c7, 0x07000000, 0x00000600, 0x25068203, 0x0206b714, 0x03830004, 0xddcd2f24, 0x048300cd, 0x21303126, 0x25112111, 0x01200482, 0xfa242582, + 0xfb000580, 0x00200783, 0x00200882, 0x23203d82, 0x03220482, 0x3d84d105, 0x40612208, 0x02030318, 0x05550702, 0x01090f08, 0x0c045d00, 0x55020c0c, + 0x5d032b04, 0xddffb805, 0x021010b4, 0x23088255, 0x0f0fb4ec, 0xfa230884, 0x840d0db4, 0xb4d82308, 0x08840b0b, 0x0a40ec2f, 0x55020909, 0x051f050f, + 0x5d2f0502, 0x0800832b, 0x2bfde42f, 0x3f005de4, 0x3f2f33ed, 0x03013031, 0x23130323, 0x03023335, 0xd61caa1a, 0xd105cccc, 0x3704c9fb, 0x00d32ffa, + 0x03a80002, 0x060403d1, 0x3d898414, 0x02154026, 0x07030606, 0x40090f01, 0x2c030209, 0x01004000, 0x072c0400, 0x5d33ed2f, 0x4e82ed2f, 0x2f333c23, + 0x204e853c, 0x25528223, 0x842b0403, 0x0382a82b, 0xfd140625, 0x834302bd, 0x25d68203, 0x0000c300, 0xdb82c905, 0x001b8108, 0x40b1001f, 0x56214071, + 0x70057409, 0x7b137b09, 0x7b177b16, 0x090a081a, 0x0f161d1e, 0x15670115, 0x0c1e1501, 0x1413100f, 0x0807140b, 0x00171c1f, 0x18680118, 0x051e1801, + 0x061a0102, 0x19620619, 0x0b706214, 0x11030b01, 0x0319110b, 0x1b000d04, 0x0d1b1b01, 0x1d011a17, 0x13b51004, 0x0905021e, 0x0fb50c04, 0x18130f07, + 0x14000b04, 0x0f031401, 0x020b4f0b, 0x3f00080b, 0x125d3f5d, 0xed2f3917, 0x01230385, 0x842f332f, 0x2f2f290f, 0xe42fe45d, 0xc0873031, 0xfd220082, + 0x0582715d, 0x87c0c023, 0x2a0d8b10, 0x21015d01, 0x21152103, 0x84132303, 0x21352303, 0x03822113, 0x21033323, 0x20038213, 0x2d1b8205, 0xb3fec905, + 0xfe34015c, 0x688168a9, 0x0483f2fe, 0x4d01d62c, 0x01ccfe5c, 0x69816957, 0x04830e01, 0x35fe2a30, 0x015eeefe, 0xfea40312, 0x5bfe8788, 0x0383a501, + 0x78018727, 0xfea60187, 0x0803835a, 0x84fe85b3, 0x9b000300, 0x880497fe, 0x2c002806, 0x3a003300, 0x8d40bc00, 0x167e087d, 0x20761970, 0x367a2c70, + 0x01160e06, 0x12161b2b, 0x350d232b, 0x3c163c0d, 0x432b3524, 0x4c164a0d, 0x5a2b4324, 0x53205308, 0x6b355a33, 0x65206508, 0x6a2b6329, 0x173a6430, + 0x0b09401d, 0x2e381d37, 0x221d2211, 0x181b4726, 0x27122d31, 0x03003437, 0x1e7f060a, 0x0a051e01, 0x050a4711, 0x1f3c0f06, 0x2121023c, 0x7f203403, + 0x31000100, 0x06181820, 0x094f093f, 0x11000902, 0x261e1b2d, 0x1e030637, 0x40063009, 0x03067006, 0x335d2f06, 0x323917ed, 0x39125d2f, 0x5d2fed2f, + 0x270682ed, 0x332f005d, 0x2f2fed33, 0x173d1382, 0x3333ed39, 0x3939112f, 0x30312b2f, 0x14015d5d, 0x23110706, 0x27012e11, 0x011e3335, 0x83028217, + 0x012e280b, 0x37363435, 0x82113311, 0x2315210f, 0x08831c82, 0x011e1409, 0x010e1125, 0x01161415, 0x11272634, 0x8804013e, 0x8476c4f2, 0x131055e8, + 0x8b342e62, 0x1d44284f, 0xd1e98ea3, 0x48d46576, 0x85a34b0e, 0x951a461e, 0x6bd4fda3, 0x00026c92, 0x81788475, 0xcd9b7c01, 0x0196fe13, 0x27310165, + 0x11350ec6, 0x01032113, 0x080f08b1, 0x9479a529, 0x100111cc, 0x2c02f2fe, 0x472ec41d, 0x0551fe09, 0x9c200511, 0x089d01e8, 0x5c5b5a65, 0x575e58fe, + 0x0c62fe19, 0x00050062, 0x08e3ff95, 0x00ed0507, 0x000f000b, 0x0027001b, 0x409c0033, 0x06080972, 0x0618090a, 0x18350f1a, 0x180a1708, 0x291a1718, + 0x290a2608, 0x461a2618, 0x400f480d, 0x580d5635, 0x130e680f, 0x25761f79, 0x31762b79, 0x2f512504, 0x02034f03, 0x511f0303, 0x030f0209, 0x512b080e, + 0x19401920, 0x31191902, 0x4f0a1351, 0x020e400c, 0x2a2e0e0c, 0x16011600, 0x0c2a2816, 0x100f060e, 0x10021040, 0x000f2a1c, 0x22000001, 0x2f06102a, + 0x2f33ed33, 0x5d2fed5d, 0x85393912, 0x432f2009, 0x5d2405b0, 0x3f3f3fed, 0x5d341184, 0x5d013031, 0x23061401, 0x34352622, 0x16323336, 0x09230125, + 0x012b0f8b, 0x22232634, 0x16141506, 0x8b363233, 0x7403320b, 0xbab6b2bd, 0xbab5b2be, 0xf4fcb302, 0x020c03a5, 0x830c8385, 0xbbfa2b14, 0x58666459, + 0x59646658, 0x09889304, 0xdae0342e, 0xdae0dfda, 0x2ffac0dc, 0xccfbd105, 0xdd200982, 0x012a1182, 0x8888acb8, 0x8787adad, 0x088617fe, 0x0300c808, + 0xe1ff7300, 0xf0051306, 0x18000b00, 0xe1004500, 0x0f096f40, 0x0c3c0f19, 0x1d301530, 0x3d3e2d35, 0x1d471a4f, 0x1c79444f, 0x60256a0b, 0x76057b3f, + 0x760f7b08, 0x70257a1d, 0x093f703e, 0x2a060805, 0x08143706, 0x2a141d16, 0x3f153714, 0x1d2a0c29, 0x08303726, 0x08400a30, 0x0c490a40, 0x1c4f1441, + 0x20461d43, 0x2d41214c, 0x08513c41, 0x255b0d59, 0x08660569, 0x1d600f6b, 0x160c3f1e, 0x1923201d, 0xc0ffb803, 0x17123b40, 0x19aa0337, 0x3e092c0d, + 0x02352305, 0x0a233f16, 0x0d2c081e, 0x002f033e, 0x14063814, 0x450c3f2f, 0x2f1d2013, 0x261a0438, 0x1e011e00, 0x0d14451e, 0x1a1a011a, 0x73261513, + 0xedf61046, 0x835d2f33, 0x12112b03, 0x12113917, 0xed2f3939, 0x0a82ed2f, 0x3f3f0024, 0x07823fed, 0x2f2bed22, 0x02821482, 0x5d303125, 0x415d015d, + 0x17280856, 0x01133636, 0x06070606, 0x34076f41, 0x07061415, 0x06272301, 0x24222306, 0x37363435, 0x26373636, 0x22088526, 0x83163233, 0x202d821d, + 0x08158201, 0x352636a4, 0x58711803, 0x834f745c, 0xfec26562, 0x1f3e1f22, 0x9dab241c, 0x6b01b75d, 0x7a013c32, 0xf073e5f6, 0xedfed07f, 0x68232334, + 0x35616e35, 0x61a13235, 0x1d18d6ad, 0x015e7620, 0x010e0e73, 0xa7040102, 0x597b6d5f, 0x234f744b, 0x0100fd87, 0x2a310fd2, 0x92456e27, 0xae025bb3, + 0x6df06060, 0x8ee090fe, 0x5cc5f371, 0x532f3186, 0x6f92481f, 0x30327943, 0x2c86af3c, 0x5a312c6f, 0x2896fe20, 0x8a383460, 0x00010030, 0x01d103a4, + 0x00140682, 0x40150003, 0x0302020a, 0x01050f01, 0x2f032c00, 0x3f005ded, 0xd6452f33, 0x82012405, 0x452b882b, 0x318205ce, 0x64feb524, 0x31820f03, + 0x00153108, 0x09434056, 0x19070901, 0x28071901, 0x4f052803, 0x48034801, 0x5f074f05, 0x6f075f01, 0x7f076f01, 0x78027801, 0x12077f06, 0x0c010107, + 0x0801047a, 0x002a6f83, 0x0d0c0c0f, 0x0c0f5502, 0x05820909, 0x88041f2c, 0xedf41016, 0x2f332b2b, 0x71823c5d, 0x70823f20, 0x015d2f08, 0x11022623, + 0x33371210, 0x07060615, 0x14150206, 0x16161712, 0xe50f0317, 0xb1c4c4b1, 0x3f9351e5, 0x3e494b3c, 0xfe4d9a3c, 0xe001cb64, 0x01822d01, 0x0acbe031, + 0x7b7fbf49, 0xaba4d8fe, 0x7b80e4fe, 0x820045c7, 0xfe9324a7, 0x84ed0264, 0x6a3f08a7, 0x03063940, 0x03151306, 0x01261315, 0x13260326, 0x01471526, + 0x13400340, 0x03501547, 0x03601350, 0x00791360, 0x03700276, 0x14761370, 0x04011215, 0x0100750c, 0x01043f12, 0xb80b0404, 0x83b4f4ff, 0x210883b0, + 0xb4830f40, 0x001f0b2d, 0x020f0f0c, 0x17920055, 0x8f2bf610, 0x021036bb, 0x36352307, 0x12363736, 0x27023435, 0x35272626, 0x02121633, 0x29b882ed, + 0x3e3b9b4d, 0x3f3d4a49, 0xc8825193, 0xfe3c0239, 0xcb20fed3, 0x7bc7450a, 0xab1c0180, 0x7b2801a4, 0x0a49bf7f, 0x8220fecb, 0x02a724b9, 0x82710476, + 0x001132b9, 0x4f094090, 0x40110113, 0x08371009, 0x40c0ffb8, 0x08088258, 0x5b025b2e, 0x540b5405, 0x6b026b0e, 0x640b6405, 0x7b027b0e, 0x730b7305, + 0x06010c0e, 0x0e0b0a0f, 0x02051108, 0x4f060c06, 0x02045004, 0x0c0f0a04, 0x2208cd82, 0x1f130f01, 0x11000213, 0x0110400d, 0x0c070810, 0x0901094f, + 0x03020e10, 0x060b0504, 0x7009280d, 0x450c010c, 0x392b0ad8, 0x39125d2f, 0x3f005d39, 0x82335d33, 0x124f0816, 0x332f3917, 0x3031332f, 0x2b2b015d, + 0x2507015d, 0x05132313, 0x37012d27, 0x03330305, 0x04051725, 0x96fe4071, 0xfe058106, 0x7d014197, 0x014183fe, 0x0781066a, 0xfe406b01, 0x6e770384, + 0x0198fed5, 0xcf6ed668, 0x01d56ecf, 0xd499fe67, 0x8200cd6e, 0xd23408df, 0xba051b00, 0x0b00fd04, 0x23403900, 0x0401ac03, 0x0aac0854, 0x0701070f, + 0x30010d40, 0x020d400d, 0x800aab00, 0x2a010101, 0x4007ab05, 0x2f040104, 0xfde43c5d, 0x5d220382, 0x0a84005d, 0x31e43c3d, 0x11210130, 0x35211123, + 0x11331121, 0xfdba0521, 0xdffda6df, 0x02a62102, 0x833c0221, 0x02a02408, 0x82dffd21, 0x93320869, 0x3f028efe, 0x03001d01, 0x26403500, 0x012a011a, + 0x0035022b, 0x00450239, 0x00550248, 0x00640259, 0x03c50074, 0x0302020c, 0x00000456, 0x021a0204, 0xf2820202, 0x10002f25, 0x822f32f4, 0x095d3163, + 0x02132301, 0x92e6fe3f, 0xfd1d01ae, 0x008f0271, 0x99265382, 0x09033102, 0x5382e602, 0x1440203e, 0x020f4201, 0x050f0201, 0x054f004f, 0x055f005f, + 0x02000005, 0x5d2f332f, 0xed5d2f00, 0xa0824082, 0xfd090328, 0x02700290, 0x3b83b531, 0x0482fd20, 0x8f84ec20, 0x02b6203d, 0x00080156, 0xffb8012d, + 0x0f0a40e8, 0x2f55020f, 0x02013f01, 0x2b5d2f01, 0x823f00ed, 0x2321273b, 0xec013311, 0x2d82efef, 0xe2ff0128, 0x5c03d0fe, 0x73821406, 0x2540363f, + 0x05000103, 0x25011601, 0x49003801, 0x56014400, 0x77016701, 0x0a018601, 0x03021201, 0x828d822f, 0x238484a3, 0x5d2f3f00, 0x87248382, 0xc0875ded, + 0x012dc882, 0x33fd5c03, 0x06ca02ad, 0x07bcf814, 0x08a78244, 0xff890040, 0x058f04e1, 0x000b00ef, 0x40870023, 0x39013622, 0x3b0c340b, 0x34183b12, + 0x4901451e, 0x4b0c440b, 0x44184b12, 0x49150c1e, 0x49210209, 0xb80f0a03, 0x0cb6f4ff, 0x0f55020c, 0xffb80021, 0xb583b4f0, 0xf4280882, 0x0b0b1b40, + 0x18005502, 0x00291a83, 0x250f259e, 0x1b02251f, 0x220d830c, 0x8206211b, 0x13402128, 0x06272983, 0x02090910, 0x830c0655, 0x98062a2b, 0x2bf61024, + 0x2bed2b2b, 0x8207865d, 0x37f583f3, 0x0210015d, 0x11022021, 0x20211210, 0x36360112, 0x27263435, 0x22232626, 0x08066145, 0x16161777, 0x04363233, + 0xf8fefb8f, 0xfaf7f4fe, 0x0c010901, 0x23f9fef7, 0x23241919, 0x7b5e5f79, 0x16192224, 0x64792124, 0xe9027c5e, 0x89fe6ffe, 0x8a017c01, 0x7b018d01, + 0xb5fc7ffe, 0x989adb51, 0x4e4d4ee0, 0xee4a4f4e, 0x53d29c8e, 0x004e524e, 0x16010100, 0x3c040000, 0x0f00d605, 0x35408800, 0x06064605, 0x030e030c, + 0x0f080148, 0x02111f11, 0x0f1f0205, 0x0c0f0f01, 0x3bcc840e, 0x0c0c0d0e, 0x200e5506, 0x6f033f02, 0x03037003, 0x10100c03, 0xb8035502, 0x0b40e0ff, + 0x0321e083, 0x82e08316, 0x40f4220f, 0x23e4831d, 0x0c0c1e03, 0x06221f82, 0x05820d0d, 0x0d0d1026, 0x10035506, 0x03214183, 0x84f9822f, 0x5d450802, + 0x2b2bed33, 0x5d2f3239, 0x005d332f, 0x3f32fd3f, 0x31ed2f33, 0x35212130, 0x35211121, 0x36373632, 0x11333736, 0xfc3c0421, 0xfe3601da, 0x25903fca, + 0x9b04352e, 0x03983001, 0x141588e6, 0xfa414d19, 0x000100c2, 0x08c182a1, 0xf0059158, 0xe1002000, 0x1f505140, 0x05021f60, 0x16110603, 0x24111503, + 0x38053b11, 0x3f0e350d, 0x391e3f1d, 0x48054b1f, 0x4f0e450d, 0x491e4f1d, 0x5d035f1f, 0x5b055d04, 0x5f115609, 0x5d1b5e19, 0x5f1d5f1c, 0x64036a1e, + 0x62116506, 0x701e6f15, 0x7f117402, 0x7f1c7f1a, 0xcd82251e, 0x83b4e821, 0xb80225b4, 0x3f40e8ff, 0x002e0983, 0x2d0f100f, 0x301c2f08, 0x060f400f, + 0xe383400f, 0xdd820582, 0x0b0f0f38, 0x0202134a, 0x08014a1f, 0x2108021f, 0x0f0f0c16, 0x0c165502, 0x05820909, 0x0b0b0422, 0xb8240582, 0x1940f4ff, + 0x16213083, 0x33498316, 0x9e201616, 0x1f220f22, 0x10100222, 0x10219902, 0x5d2f32f6, 0x2b200483, 0xed2f0083, 0x3f003912, 0xed3f32fd, 0x2b2b2f33, + 0x8230315d, 0x5d013704, 0x36352121, 0x36363736, 0x23263435, 0x23070622, 0x33363635, 0x55470432, 0x06a60806, 0x04210706, 0x6910fc91, 0x8ec05bd3, + 0xd45b8999, 0xed470a65, 0x0401e56f, 0x69272a2b, 0x63e46b4b, 0x5ad12103, 0xdbba59b4, 0x4083747f, 0x3a23d242, 0x9355bddd, 0x49783e42, 0x0054c569, + 0xffa70001, 0x057c04e1, 0x003d00f0, 0x0b8e40b8, 0x1a2f050b, 0x292f150b, 0x292f260b, 0x350b3c3c, 0x34223114, 0x450b4a2f, 0x43224314, 0x5901562f, + 0x550b5905, 0x660b6a2f, 0x783c6a2f, 0x742f760b, 0x1a3c7b35, 0x3a443a34, 0x1e3a3b02, 0x2d011f49, 0x2d022d11, 0x1f4a292d, 0x0f023109, 0x020d1f0d, + 0x4a110d0d, 0x21230a09, 0xff830c37, 0x0d043739, 0x3755020d, 0x060c0c06, 0x2e1e3755, 0x2e032116, 0x04373a1e, 0x831a030c, 0x8203201d, 0x06280823, + 0x3fa00355, 0x3f1f3f0f, 0x3e9a0c02, 0x105de610, 0x112b2be6, 0xed103917, 0x2b2f2f2f, 0x00ed2b2b, 0x2f33ed3f, 0x39123f5d, 0x2f290683, 0x5d3939fd, + 0x015d3031, 0x06614816, 0x26222329, 0x16333527, 0x41323316, 0x2725062d, 0x23232626, 0x430e8235, 0x3c410950, 0x17162105, 0x9e083385, 0x04161615, + 0x4a3e300e, 0x79cb4b43, 0x0f4df07c, 0x3f6be655, 0x2d2e2c8e, 0x802d2d33, 0x98465a4a, 0x2b292eb5, 0xd65f3e62, 0xed470a5f, 0x43a66d6f, 0x77af4a48, + 0xcd027c30, 0x6667822b, 0x43463faa, 0x38d1233b, 0x2c292a4a, 0x6950516a, 0xa6171f1e, 0x51367a7f, 0x44141a1a, 0x3b23d13e, 0x88302c28, 0x18b97c5b, + 0x0033080e, 0x004d0002, 0x05b30400, 0x000a00d1, 0x40e0000d, 0x140d0421, 0x340d240d, 0x700d440d, 0x180c060d, 0x55060c0c, 0x06480d0c, 0x060c0706, + 0x490d0907, 0xffb80501, 0x831940c0, 0x05053c16, 0x03030703, 0x4f0a3f08, 0x0f0a020a, 0x020f1f0f, 0xb8040c07, 0x0cb4f4ff, 0x8255020c, 0x40f32208, + 0x3426830e, 0x090a2004, 0x064f060d, 0xffb80101, 0x0b0b40e4, 0x0155020b, 0x8222830a, 0x05264f0f, 0xee220882, 0x2b833240, 0x0f010132, 0x3f061f06, + 0x26060306, 0x55021010, 0x0f0f0206, 0x18210582, 0x09a84409, 0x39830c20, 0x96840620, 0xb7430620, 0x335d2106, 0xa2080884, 0x3339125d, 0x2b2bed33, + 0x2f5d3939, 0x3f3f005d, 0x2b2f3912, 0x1232fd3c, 0x30313939, 0xfd108701, 0x012bc004, 0x1123015d, 0x35211123, 0x33113301, 0x04011121, 0xfdc0ddb3, + 0xb8d10237, 0xfd63fedd, 0xfea301bf, 0xe6a3015d, 0x72fc4803, 0x60fda002, 0x00010000, 0x04e1ffbb, 0x00d10585, 0x4097002a, 0x1a080a3d, 0x3d082b08, + 0x3d113508, 0x44084b16, 0x54085a11, 0x7a086a29, 0x1d1d0c08, 0x250f491a, 0x2540251f, 0x4a212503, 0x021e0625, 0x0a1f0a0f, 0x0e0a0a02, 0x200a064a, + 0x1d4f2022, 0xffb81d01, 0x832e40ec, 0x161d21fb, 0x1d27c183, 0x020d0d0e, 0x83101d55, 0x141d27f4, 0x1d200021, 0x18840009, 0x2c9f002a, 0x2c1f2c0f, + 0x2b9b0902, 0x24056542, 0x10393911, 0x21e085ed, 0x65422fed, 0x5d2f2d09, 0x312f32fd, 0x14015d30, 0x06060706, 0x08145f42, 0x070622a6, 0x21152111, + 0x33363611, 0x16171632, 0x4c850416, 0x83c74842, 0x0e4ee27a, 0x476adc52, 0x2d2c3485, 0x95342f35, 0x3ba3585c, 0x41fd8003, 0x79215a2b, 0x58504cb6, + 0xbe68d901, 0x334b4641, 0x4934d324, 0x782b3228, 0x206a4d4f, 0x0c181f26, 0xfeafff02, 0x29040474, 0x00ae3734, 0xff890002, 0x05a704e1, 0x002200ed, + 0x40950037, 0x160d0638, 0x3325390d, 0x49373331, 0x43314225, 0x56015f37, 0x5020500d, 0x75216521, 0x031a0e31, 0x131d4929, 0x1d4a1713, 0x35020f03, + 0x1a0a0349, 0x23122f2c, 0x09120021, 0xeeffb800, 0x2809b646, 0x020b0b0b, 0x0c0c0055, 0x2605820c, 0x40ecffb8, 0x820d0d0f, 0x399c3c09, 0x391f390f, + 0x09212f02, 0xb6f4ffb8, 0x55020f0f, 0x10389809, 0x5ded2bf6, 0x822be610, 0x11320800, 0x2fed1039, 0x00393912, 0x123fed3f, 0x2f32fd39, 0x3912ed2f, + 0x015d3031, 0x22230014, 0x02262726, 0x37123435, 0x32332436, 0x23151716, 0x22232626, 0x11410700, 0x46072007, 0xa00814cd, 0xd9d5fea7, 0x5645b46e, + 0x585d555d, 0x3bb91601, 0x1c0a2950, 0xffd73b71, 0xa3541500, 0x4c915f6b, 0x37cb5958, 0x3d702e3f, 0x024d9255, 0x2e394102, 0xa6913f6b, 0xfee3e301, + 0x534344e1, 0xc6c11201, 0x71773201, 0xbf0d0a7f, 0xf3fe1b0f, 0x233533e5, 0x8dba3d35, 0x202d7a5d, 0x162a2814, 0xb79e1f29, 0xb1292c35, 0x9a000100, + 0x95040000, 0x0600d105, 0x32404f00, 0x020a0109, 0x01480124, 0x0258024b, 0x03070379, 0x20010001, 0x00030202, 0x4a030200, 0x08020305, 0x081f080f, + 0x0303027b, 0x04020200, 0x273c820f, 0x332f0400, 0x39125d2f, 0x4808f882, 0x3f3f005d, 0x2f3911fd, 0x87013031, 0xc087ed10, 0x01015d01, 0x35210123, + 0xfd950421, 0xcd02d65e, 0xfb03b0fc, 0x0efbf204, 0x00af2205, 0xff7a0003, 0x059c04de, 0x001900f3, 0x01370028, 0x2600b908, 0x0db4f4ff, 0x2555020f, + 0x200886b8, 0x20088724, 0x20088723, 0x21088222, 0x24837640, 0x2b2d6008, 0x22331534, 0x33342734, 0x22411544, 0x33452744, 0x195b1550, 0x1f5a1b5a, + 0x2b5f2254, 0x315f2c59, 0x37543354, 0x0e620860, 0x19621262, 0x27602360, 0x12760e76, 0x12862c7b, 0xa902061d, 0x022fa626, 0x2f0a1626, 0x471d0304, + 0x48350210, 0x201a0a03, 0x13011300, 0x0a2f0013, 0x0021290d, 0x43202616, 0x9d200604, 0x2205f341, 0x830d2120, 0x0f0b217a, 0x0d369f82, 0x0621320d, + 0xf6103897, 0x2b2f33ed, 0xe4105ded, 0x3939112b, 0x0482ed10, 0x33113108, 0x00ed712f, 0xed3fed3f, 0x5d391712, 0x40585443, 0x892c591e, 0x2c29022c, + 0x2f350332, 0x23362f29, 0x23562345, 0x26992364, 0x23201a06, 0x111d2603, 0x04842783, 0x30315922, 0x22058953, 0x4e001401, 0x35250620, 0x34352626, + 0x06c54624, 0x16161524, 0xbd4f3403, 0x16172c06, 0x36361716, 0x27263413, 0x4e272626, 0x9c08075f, 0xd3fe9c04, 0xe1fef2e4, 0x73788390, 0xdfd51401, + 0x7a7e0a01, 0xa5ed948c, 0x51a17e80, 0x428b2552, 0x511f4c63, 0x5d702f76, 0x8fba6d5a, 0x9f01af92, 0xfa00ffc1, 0x3bc97cc3, 0x72984006, 0xa5d6e0a8, + 0x0637c365, 0x4f02b03c, 0x66787f6b, 0x12296948, 0x8e42133a, 0x6f5c73fd, 0x22261638, 0x876aa831, 0x020096b0, 0xe3ff7100, 0xef058f04, 0x37002200, + 0x39408400, 0x04190408, 0x253c0429, 0x2e352b3c, 0x2b4c254c, 0x04582e43, 0x185d175f, 0x01701b52, 0x110f257b, 0x1449321d, 0x06144929, 0x0681441d, + 0x09113535, 0x09002123, 0xffb8001a, 0x0f2340f4, 0x0055020f, 0x820c0c10, 0x419e2005, 0x2c290565, 0x09101a21, 0x1a550209, 0x25158304, 0x1038961a, + 0x5d432bf6, 0x39112f06, 0x392fed10, 0xfd3f0039, 0x123f2f32, 0x5a43ed39, 0x07022308, 0x74440406, 0x37122109, 0x2a058244, 0x34352626, 0x16323300, + 0x43121617, 0x1521085a, 0x460e8214, 0x830806f8, 0x5a598f04, 0xb9eefe5b, 0x0a245c34, 0xdd416a1d, 0xa45d14fb, 0x4b955c61, 0x2c015958, 0x45b86cd8, + 0x40ca5c55, 0x3f6c2f38, 0x4036a790, 0x4e426c2d, 0x030146a0, 0xfec34203, 0x7c7270c2, 0x0fbf0c0b, 0xe909011b, 0x34243038, 0xe483bc3d, 0x43431e01, + 0xa4fbfe53, 0x2d34bc9b, 0x5fa3b427, 0x151f2d78, 0x2915282a, 0x5a010200, 0x49020000, 0x03005d04, 0x25000700, 0x56011640, 0x56060502, 0x00070805, + 0x0001062d, 0x0035e983, 0x2f010101, 0xfd3c2b5d, 0xed3f003c, 0x3031ed3f, 0x33112301, 0x22038211, 0x82ef4902, 0x40032700, 0xa3fb1d01, 0x46821d01, + 0xfee60025, 0x8692028e, 0x4c21084b, 0x050a3740, 0x051a060a, 0x052a061a, 0x0435062b, 0x04450639, 0x04550648, 0x04640659, 0x07c50474, 0x2e6a840f, + 0x08560706, 0x043f0606, 0x0402044f, 0x852d0004, 0x32fd216c, 0x8408c84c, 0x835d2070, 0x01132372, 0x72831323, 0xe6fe4924, 0x7583ae92, 0x4cc0fc21, + 0xfe3a07d5, 0x80054d00, 0x0600cb04, 0x73b45f00, 0x002c0105, 0x40e2ffb8, 0x37180a26, 0x04831e03, 0x2f001f3b, 0x0f030200, 0x40000100, 0x08300108, + 0x04020840, 0x00000105, 0x01500140, 0x27da8202, 0x39122f33, 0x005d5d39, 0x5d327382, 0x312b2b2f, 0x58534b30, 0x04050b40, 0x03020354, 0x35825406, + 0xfd108722, 0x44080282, 0x0159c005, 0x3501255d, 0x01011501, 0x7efb8005, 0x72fc8204, 0x024d8e03, 0x01027c01, 0xfe75feb4, 0x02000075, 0x6a01f500, + 0xae039705, 0x07000300, 0x20403500, 0x01065405, 0x020f0654, 0x09400201, 0x40093001, 0x22798309, 0x8240002f, 0x207e8229, 0x207c8401, 0x217d885d, + 0x764d2fed, 0x21112906, 0x97052135, 0xa2045efb, 0x032a0383, 0xbcfda00e, 0x010000a0, 0xe7820c01, 0xe7848e20, 0x7cb46126, 0x012c0103, 0x2820e783, + 0x0520e282, 0x052ae783, 0x012f011f, 0x010f0502, 0xe7870101, 0x82050321, 0x012f26e7, 0x01400130, 0x2ae99803, 0x05540403, 0x54020605, 0x8a000101, + 0x820120e9, 0x350282e9, 0x7efb8e05, 0x72fc8e03, 0x4e028204, 0x01b4fffd, 0xb48b018b, 0xbf82fffd, 0x45089082, 0xef05ed03, 0x20001c00, 0x47406900, + 0x221f220f, 0x35031424, 0x4f024f18, 0x44054f03, 0x54055c18, 0x69046918, 0x74186410, 0x0c1c7418, 0x01097008, 0x1e1a0609, 0x34121616, 0x1f08021a, + 0x20081e55, 0x061f1f2b, 0x17827f1f, 0x09150f25, 0x82002017, 0x451720aa, 0xed3805a8, 0x33ed5d2f, 0x3f00ed2f, 0xfd3f33ed, 0x12112f32, 0x2f5d3939, + 0x015d3031, 0x2306c147, 0x11231507, 0x08114a4b, 0x2301163c, 0xed033335, 0x92383946, 0x9741b352, 0x99403a30, 0x38c16c79, 0x60d7460a, 0x75fef9d7, + 0x7304cccc, 0x393b9962, 0x01e12f64, 0x2d582531, 0x71566f34, 0xcc23446f, 0xfad12b1b, 0xd182d3e2, 0xffb0ca08, 0x054e071e, 0x004200ef, 0x40d6004f, + 0x0f0206a2, 0x0a050b04, 0x0e1b0f09, 0x0f3f0f1c, 0x1f021640, 0x1f051c04, 0x141c1f1b, 0x1f271422, 0x25411f3f, 0x2c042c02, 0x2f1b2f05, 0x2022241c, + 0x2f3f2f27, 0x44404741, 0x1d485648, 0x2705050a, 0x096e4959, 0x1a690d65, 0x27652168, 0x41663f66, 0x1b7b1674, 0x39742770, 0x120f3b74, 0x12081105, + 0x140e5247, 0x371b1540, 0x4d040414, 0x2d2d0853, 0x080e512a, 0x511e313d, 0x0f023d31, 0x052d012d, 0x2d124311, 0x3f124a14, 0x0f0b010b, 0x02512051, + 0x0b142918, 0x20000f37, 0x03007f00, 0x29240000, 0x10506b37, 0x2f33edf6, 0x3939125d, 0x5d2f5ded, 0xfd332fed, 0x5d2f3232, 0xed333f00, 0x0580552f, + 0x1e822f20, 0x822bcd21, 0x410e8205, 0x023e073e, 0x06272107, 0x26222306, 0x33123435, 0x35171632, 0x36331133, 0x02343536, 0x23242627, 0xb2520422, + 0x33042507, 0x15373632, 0x24202883, 0x260a1448, 0x12161704, 0x55261101, 0xb10809a1, 0x4b514e07, 0x4a1b48fe, 0xc9a85888, 0x7049abf6, 0x2af39f41, + 0x58585b2b, 0xa0a5fcfe, 0x605ff7fe, 0x635f686d, 0x569d0a01, 0xa86154b7, 0xc2feba59, 0x86807372, 0x3e017474, 0x3401c4b5, 0xfd716a6a, 0x39643f8f, + 0x7b749281, 0x97028643, 0x6bfcfe8b, 0xfe403c74, 0x0e01e3e4, 0xfc302121, 0x59e14bb6, 0x600c01a4, 0x62746760, 0x9aeffe62, 0x61effea5, 0x18166765, + 0x7f0f158e, 0x42017372, 0x3f01b9c3, 0x7c867575, 0xc5fe7070, 0x060240fe, 0xa6b4191d, 0x003ea7a3, 0x1a000200, 0x5e050000, 0x0700d105, 0xc4000a00, + 0x010940b3, 0xf8ffb805, 0x060c0cb4, 0x08870655, 0xffb80725, 0x837640f4, 0x064a2e12, 0x09020745, 0x02080a09, 0x01010187, 0x08348214, 0x030a0944, + 0x04010487, 0x06050514, 0x0773067c, 0x0a340302, 0x02101040, 0x0d400a55, 0x3055020d, 0x700a400a, 0x090a030a, 0x0103060a, 0x0501057a, 0x010c0f08, + 0x03090706, 0x24000c05, 0x42003900, 0x6a005a00, 0x47827400, 0x0c6e0022, 0x34081a82, 0x052b050a, 0x054d0536, 0x05650555, 0x0507057b, 0xe6100b64, + 0xf6105d5d, 0x17125d2f, 0x3f005d39, 0x393f3c5d, 0x2b5d2f39, 0x3031ed2b, 0x10875d01, 0xc0c05dfd, 0x220685c0, 0x8201c008, 0x2b2e0817, 0x23215d00, + 0x23032103, 0x01132101, 0xd35e0501, 0x927cfd92, 0x011e02c9, 0xfbfe7c08, 0x9f01fafe, 0xd10561fe, 0xdb0278fc, 0x030025fd, 0xfb82c800, 0xfb822b20, + 0x00153608, 0x01330024, 0x0512400d, 0x270c150c, 0x5602550c, 0x06197f15, 0x342c1112, 0xc0ffb81e, 0x0f0f1440, 0x1e1e5502, 0x08341d07, 0x07342d03, + 0x12151608, 0xffb80f2c, 0x05734cf4, 0x0c200f25, 0x8255020c, 0x40f2220f, 0x25f3831c, 0x0d0d260f, 0x15835506, 0x0f2d0582, 0x00152507, 0x0210100c, + 0xffb80055, 0x07914ae6, 0x83b4e821, 0x21118232, 0x3183b4f2, 0xe4200882, 0x06200882, 0xe8242383, 0x0c0c1640, 0x712b0982, 0x40350f35, 0x2c1e0235, + 0x830e0714, 0xb807283e, 0x0bb4fcff, 0x8255020b, 0x50da2008, 0x07230586, 0x84090908, 0x84ee200f, 0x2018824e, 0x824e84ea, 0x84f12008, 0x2008834e, + 0x254d83b6, 0x10346c07, 0x00862bf6, 0x5d32fd22, 0xed230c87, 0x842f3912, 0x39122115, 0x8206e748, 0x39ed230f, 0x78583139, 0x06072705, 0x11212306, + 0x3a4e3221, 0x3401270a, 0x26262726, 0x15822323, 0x36373622, 0x8406b448, 0x080e8324, 0x542b05c1, 0x9bc95447, 0xb901f0fd, 0x524aa2a3, 0x975a6c4a, + 0x24b3feae, 0x63862f28, 0x5d0001ec, 0x272f2f6e, 0x3047367f, 0xc9fe6289, 0xa6820601, 0x01343835, 0x37aa6fca, 0xd1053842, 0x872b2618, 0x2d956a5e, + 0x02cb1f08, 0x174a3604, 0x52fe0d1b, 0x5f1e1e13, 0x6a5a9afd, 0xfd0f1925, 0x27241bd6, 0x01000064, 0xe5ff7300, 0xec054605, 0x6f002a00, 0x01055640, + 0x1406090d, 0x091b0116, 0x15251514, 0x14431536, 0x0a58085b, 0x105b0e58, 0x0360285b, 0x02701461, 0x14700f76, 0x1a161613, 0x2a021234, 0x0634262a, + 0x7100160a, 0x012c0f2c, 0x2c1f2c0f, 0x2c3f2c2f, 0x20052c6f, 0x0b140c15, 0x0c55020b, 0x8209091c, 0x2b683005, 0x2b2bf610, 0x105d5ded, 0x3f003cf6, + 0x832f33ed, 0x30312503, 0x06255d01, 0x4305114d, 0xfa4b0be5, 0x0cb65207, 0x33377d08, 0x59374605, 0x568f3d48, 0x62f7fea2, 0x62686c60, 0xa40d015f, + 0x0f92ef78, 0x718af27b, 0x4d4547b5, 0xbb464355, 0x6dfa8f68, 0x2a186c0e, 0x5b1b1317, 0x25015f61, 0x2201b8c2, 0x3a666164, 0x5e67eb49, 0xe54b4d49, + 0x47e29d96, 0x6262474a, 0xc8000200, 0xb2050000, 0x0e00d105, 0xbc001d00, 0x12392340, 0x02691249, 0x16040d68, 0x17030834, 0x76080734, 0x150f0100, + 0x10100a00, 0x06005502, 0x0023ca83, 0x4ce2ffb8, 0xb42008fe, 0x1182d683, 0x42b4ea21, 0xf4330675, 0x0d0d1940, 0x74005506, 0x2f1f0f1f, 0x601f401f, + 0x4217041f, 0x1e204566, 0x20096642, 0x096542ed, 0x49005d21, 0x5d23060c, 0x42021401, 0x04200754, 0x0809cb49, 0x33112381, 0x36373632, 0xb1b20536, + 0xcdfb6693, 0x740188fe, 0x590101da, 0x7acfaa98, 0x8ac65879, 0xd58fbaba, 0x026f6f59, 0xb6fecbe7, 0x05383f5b, 0x5f373fd1, 0xafd6c4fe, 0x273245f0, + 0x392a83fb, 0x0000e847, 0x00c80001, 0x059d0400, 0x000b00d1, 0x3509b790, 0x06100600, 0xffb80602, 0x0f2440c0, 0x0655020f, 0x35050106, 0x350a0302, + 0x00040801, 0x00080108, 0x0d0f0d73, 0x14090601, 0x10100e01, 0x43015502, 0x0882075c, 0x23065c43, 0x09090801, 0x5c431884, 0x43188205, 0x0882055c, + 0x0db4e924, 0x3383060d, 0x0cb6e923, 0x2108820c, 0x5c430c6c, 0x5d3c210e, 0x2c05fe49, 0x2b2f3912, 0x3031ed71, 0x21112121, 0x29038615, 0x2bfc9d04, + 0xf1fcd503, 0x03830f03, 0xb0d10527, 0xfdb068fe, 0x20bf86d7, 0x23bf827f, 0xb29b0009, 0xba83ab82, 0xba831520, 0x07020235, 0x03083501, 0x03000807, + 0x03020b4f, 0xffb80003, 0x831a40d4, 0x64002881, 0x010b0f0b, 0x83010502, 0x41052085, 0xe02034c0, 0x0723ca84, 0x84ecffb8, 0x6c0722ca, 0x2cca8a0a, + 0x105d322b, 0x2f322bf4, 0x3f3f005d, 0x82cb83ed, 0x850120ca, 0x112334c6, 0xfd7f0421, 0xfd87020f, 0xb703c679, 0x5cfe2105, 0x8233fdb0, 0x08c782bc, + 0xe3ff735a, 0xec05a205, 0xca002400, 0x01073b40, 0x0e060609, 0x0e13061d, 0x0e350e21, 0x0e410149, 0x06650e51, 0x0e630b65, 0x1c740e74, 0x4035220f, + 0x23230123, 0x1010030c, 0x020c3417, 0x0a03341d, 0x22010976, 0x10092210, 0xfeffb821, 0x09091340, 0x6c215502, 0x10100400, 0x10005502, 0x2006d942, + 0x07d942f6, 0xd942e420, 0x84fa2010, 0xb80035cf, 0x2340fbff, 0x55060c0c, 0x0f267500, 0x02264026, 0x1209151a, 0x09213d83, 0x2851831c, 0x0d0d0c09, + 0x68095506, 0x42ec8425, 0x2b2309a8, 0x82332bed, 0x25f083e7, 0x33ed3fed, 0x0c82112f, 0xf4835d20, 0x06255d3b, 0x24222304, 0x35022627, 0x32210010, + 0x23151704, 0x26272626, 0x00222326, 0x08108311, 0x11373650, 0x05213521, 0xdffe7aa2, 0xdefeae87, 0x01706766, 0x7f6c01a1, 0x12990901, 0x4539761f, + 0xfefa6faf, 0x013001dd, 0x48bf6006, 0x530271fe, 0x6053386e, 0x23016160, 0x016501c3, 0xeb493d9d, 0x1f1a4e18, 0xfebffe29, 0xfedffeee, 0x011e26bf, + 0x0f42ae6d, 0x05260805, 0x00d1053b, 0xb2e2000b, 0xb8083503, 0x1640c0ff, 0x55020f0f, 0x08100800, 0x05080802, 0x0103070a, 0x02090805, 0x1a820d14, + 0x1982f682, 0xfaffb824, 0x6a4610b4, 0xb4f42105, 0x20062c41, 0x052b46e6, 0x44080021, 0x40230704, 0x820d0d24, 0x0c12222b, 0x2805820c, 0x060d0d0f, + 0x0c130055, 0x2f05820c, 0x0d0f0d78, 0x0d500d40, 0x14030803, 0xd2ffb805, 0x08824a84, 0x82057646, 0x06194308, 0x09227482, 0x0f825502, 0x82051043, + 0x05224308, 0x4f830884, 0xb6200883, 0x05205283, 0x6c101943, 0xfd36085f, 0x3c3f0032, 0x39123c3f, 0xed2b712f, 0x23213031, 0x23112111, 0x05823311, + 0x05333a08, 0x19fdc63b, 0xe702c6c6, 0xfdd902c6, 0xfdd10527, 0x004802b8, 0x00890001, 0x05d50200, 0x000b00d1, 0x09234065, 0x03063204, 0x0132030a, + 0x0a6d0d08, 0x0a5a0b08, 0x02050314, 0x06a7575a, 0x0b0b0c2b, 0xb8035502, 0x0fb4deff, 0x4208840f, 0x11820527, 0x83b4fe21, 0x230882f5, 0x0d0db6ee, + 0x6d201a82, 0x2308b943, 0xfd1032f4, 0xe6240382, 0x32fd3f00, 0x312b0282, 0x21210130, 0x23113335, 0x82152135, 0xd5023096, 0xc3c3b4fd, 0xc3c34c02, + 0x98a10498, 0x825ffb98, 0xff2c248f, 0x82ea02eb, 0x00153c8f, 0x6a144071, 0x02017c01, 0x03153312, 0x340b0707, 0x13130903, 0xb8001412, 0x41b4e2ff, + 0xfa20068d, 0x11828984, 0xb142ee20, 0x05324107, 0xda221182, 0x8f411940, 0x0d0d2705, 0x02005506, 0x05820c0c, 0x0f177729, 0x65060117, 0x45e61016, + 0x2b230843, 0x4f2f33ed, 0xed25052c, 0x015d3031, 0x0f985314, 0x21112808, 0xea022135, 0xa030c9ef, 0x78290b36, 0x1a6d5c3f, 0xc5fe0f1b, 0x83010102, + 0x0c11d4c4, 0x2a1e0eb9, 0x4c742827, 0x829e6503, 0x00cd24b9, 0x82750500, 0x0b5508b9, 0x7f40f900, 0x01560919, 0x0503095c, 0x38092809, 0x68094a09, + 0xd8098a09, 0x010f0709, 0x011e090a, 0x012a0219, 0x0139092b, 0x0b350939, 0x09490149, 0x015c0b45, 0x00720b65, 0x02100879, 0x01880302, 0x010201c8, + 0x000b00b3, 0x02b30908, 0x0a030a0b, 0x08010a84, 0x06984202, 0x03020b2e, 0x0d0f0a0a, 0x00300020, 0x50040040, 0x6e2f7682, 0x010d400d, 0x09080308, + 0x03550209, 0x640e0514, 0x5e4206d9, 0x08554218, 0x21086742, 0x5e42b4f2, 0x42f22006, 0x2b27125e, 0xf6105d32, 0x53325d5d, 0x3c2205b1, 0x9f553c3f, + 0x5d3d0805, 0xc0c01087, 0x0418fd7a, 0x108701c0, 0x185dfd7a, 0x5d01c008, 0x21217271, 0x23110701, 0x01113311, 0x75050133, 0xb3fdfffe, 0x02c6c694, + 0x67fdf0d3, 0xfe9e9702, 0xfcd10507, 0xfd0903f7, 0x05874344, 0x05760433, 0x000500d1, 0x0302b675, 0x08013504, 0xe8ffb800, 0x05334340, 0x0f070025, + 0x46040107, 0xea203d45, 0x0122cc84, 0x7a45066c, 0x5ded2d09, 0x2b2f3311, 0x3fed3f00, 0x21213031, 0x212ba582, 0x52fc7604, 0x05e802c6, 0x85dffad1, + 0xf6052193, 0x3f089382, 0x4049010c, 0x010a565b, 0x05380238, 0x026f0a36, 0x056f0360, 0x027f0a60, 0x057f0370, 0x550b0a70, 0x5a0a5609, 0x0364030b, + 0x09750374, 0x020a0503, 0x02060903, 0x40040200, 0x55021010, 0x09094004, 0x0d2b0583, 0x0055020d, 0x44041004, 0x82045404, 0x0b073900, 0x07010309, + 0x0b0a0908, 0xb8020503, 0x0d40faff, 0x55020f0f, 0x1e001402, 0x2406cb42, 0x0b4d40f4, 0x2032820b, 0x2117830c, 0x44831000, 0x0c0a0023, 0x2011820c, + 0x284a841a, 0x060d0d18, 0x0c0c0055, 0x2a05820c, 0x0e0f0e78, 0x0e500e1f, 0x830c0503, 0x82052027, 0x55022315, 0x1b830405, 0x07130523, 0x31d74a10, + 0x83b4ea21, 0xb807245d, 0x4ab6eeff, 0x0d2005d7, 0x210a3441, 0x645c2b2b, 0x26088206, 0x2bed2b2b, 0x44391711, 0x5d200764, 0x432a1282, 0x34b45854, + 0x02046a04, 0x0a82595d, 0x64b23d08, 0x595d0104, 0x31391712, 0x725d0130, 0x21725d00, 0x23011123, 0x11231101, 0x21010121, 0xfec6f605, 0x65fe7662, + 0x010e01b9, 0x0180018d, 0xfc030513, 0xfa690397, 0xfcd105fd, 0x003d03c3, 0x08068341, 0xd1053847, 0x2b010900, 0x070c4040, 0x0734071f, 0x07510745, + 0x07710761, 0x01067607, 0x0602010f, 0x0615011f, 0x06440634, 0x016b0653, 0x017f0660, 0x0c0b0670, 0x02060401, 0x0655015a, 0x01070202, 0x01030608, + 0x01060804, 0x21d08202, 0xcc4bb4f8, 0xb4f42506, 0x55020c0c, 0xfa201182, 0x1324e285, 0xf4ffb800, 0x2810d645, 0x0f4540e2, 0x0055020f, 0x20358308, + 0x05cc4500, 0x0d0d2622, 0x0c261182, 0x55060d0d, 0x7f410a00, 0x0f0b2605, 0x020b400b, 0x21258402, 0x58830c02, 0x83060221, 0x13022819, 0x10101004, + 0x48045502, 0x088207f8, 0x2006de45, 0x822c8404, 0x057f430f, 0xea210882, 0x825883b4, 0x057f4308, 0x7d410882, 0x48042005, 0xed200b2d, 0x200d7d41, + 0x210e82fd, 0x7f413911, 0x31392a07, 0x71720130, 0x5d005d5d, 0x06624121, 0x33114f08, 0xfdf53805, 0x3301b93e, 0x05b98402, 0x05ccfa34, 0x0440fbd1, + 0x000200c0, 0x05e1ff73, 0x00f005da, 0x00230017, 0x042240be, 0x0b060400, 0x17120b0c, 0x19061700, 0x5712190c, 0x53055701, 0x580b5f07, 0x5f11580d, + 0x10175313, 0xf0ffb815, 0xcc831840, 0xd2840920, 0x7909762d, 0x341b0215, 0x34210215, 0x82180a09, 0x83b620df, 0x151822f0, 0x82ea8703, 0xb4e62508, + 0x55020909, 0xe2230882, 0x840c0cb4, 0x40f02208, 0x2ee48334, 0x0f257303, 0x250f0125, 0x253f251f, 0x83041e03, 0x151e2939, 0x0b0b120f, 0x160f5502, + 0x0f213383, 0x20308306, 0x2119840f, 0xdb5e680f, 0xed2b2305, 0xa8455d2b, 0x2bed2906, 0x3fed3f00, 0x2b2b5ded, 0x5d24f182, 0x15121601, 0x4805f04a, + 0x2e58053b, 0x10132207, 0x05394800, 0x32335008, 0x5b1e0500, 0x5c596361, 0xfe9da1fb, 0x615a5aff, 0x01585c60, 0xffa09a05, 0xe1fcfe47, 0x01fdfee3, + 0x01dede08, 0x64260507, 0xb8b8defe, 0x6561ddfe, 0x63636866, 0xb6b92001, 0x62672101, 0x61fd6968, 0x3b012201, 0xdefec5fe, 0xc9fedbfe, 0x4c003701, + 0x3108052b, 0xd1059604, 0x1f001000, 0x3040dc00, 0x1d3d143a, 0x1d4b144b, 0x0f540e50, 0x19070f65, 0x10070034, 0x07070207, 0x0a341809, 0x0f080903, + 0x02211f21, 0xa6451511, 0x00702505, 0xffb80004, 0x22083a48, 0x830b40f8, 0x083759f2, 0x0db4f025, 0x8255020d, 0x82e82021, 0x83062008, 0x4eea2008, + 0x6f3006ac, 0x3f210f21, 0x07190221, 0x100e0914, 0x09550210, 0x82076b41, 0x06564208, 0x83080921, 0x420f824b, 0x08820556, 0x82055642, 0x824e8508, + 0xb6e52808, 0x55060c0c, 0x4b206c09, 0xf4210d4f, 0x2100842b, 0x884aed5d, 0x05934907, 0x2206a05a, 0x4e231123, 0x195606a2, 0x4c232006, 0x9308064d, + 0x3e459604, 0xc6a0d24d, 0x869401c6, 0x5d5548ba, 0x303736ce, 0xa7c45e7b, 0x2f2f9678, 0x630f0427, 0x4d4d3ea9, 0xd105d5fd, 0xaa39302d, 0x24724d87, + 0xadfd1b1f, 0x6a302f2b, 0x73000200, 0xf80577fe, 0x2500f005, 0xc5003100, 0x0c0b4740, 0x1804120b, 0x0c191d04, 0x18151219, 0x0b5c1d16, 0x11590d59, + 0x1753135c, 0x1d571957, 0x55102074, 0x751f651f, 0x042d741d, 0x35212525, 0x34290b03, 0x7609061e, 0x02157909, 0x342f0215, 0x131e0a09, 0x73330006, + 0xfcffb826, 0x2b05b85c, 0x001b1526, 0x031d0609, 0xffb81b0f, 0x82058a42, 0x058a4208, 0xf0340882, 0x0d0d2840, 0x731b5502, 0x01330f33, 0x331f330f, + 0x2c03333f, 0x420d8442, 0x3223067e, 0x4e2bf610, 0xe62005a9, 0x11340782, 0x10323917, 0x2fe62bed, 0x3f00ed2f, 0x125d3fed, 0x3fed3939, 0x2706cb5b, + 0x0606015d, 0x27262223, 0x270fa452, 0x12161716, 0x07021015, 0x2105405e, 0x98420333, 0x3cf8290b, 0xd3ae3d75, 0x152d1809, 0x2c0d9a42, 0xdf615b59, + 0x846404bc, 0x1b187129, 0x0ba642ec, 0x0f93fe27, 0x04b2bf0d, 0x0ca24203, 0xfe64612f, 0xeffeb8de, 0x724b8afe, 0x030a197e, 0x0eb0429f, 0x2005db4e, + 0x06af4298, 0x40fb3508, 0x1d010853, 0x3a012d01, 0x451d3901, 0x4814480f, 0x56015a1d, 0x6f14590f, 0x60026901, 0x7e0b650a, 0x110b7501, 0x00b30102, + 0x07100010, 0x4002341a, 0x55020d0d, 0x28080583, 0x02405506, 0x05020201, 0x03073418, 0x0f080501, 0x40211f21, 0x15110321, 0x0d010d0f, 0x40f8ffb8, + 0x0209091d, 0x0c1c0d55, 0x2805820c, 0x060d0d0c, 0x0c180d55, 0x2a05820c, 0x0020100d, 0xffb80001, 0x831640ea, 0x19002315, 0x17830903, 0x00140322, + 0x2133a048, 0x3c83b6f1, 0xc0420520, 0xfd32270a, 0x2b2f322b, 0x6751395d, 0xed5d2805, 0x3c3f005d, 0x5212ed3f, 0x123005c3, 0x01303139, 0xfd7a1087, + 0x5d01c018, 0x21012121, 0x2308ca42, 0x07061415, 0x2005105a, 0x081c4f23, 0xfe983908, 0xfe0efeff, 0xa101c6e9, 0x5148b487, 0x618ea25b, 0x762b342d, + 0x5ec8e950, 0x2b2d318c, 0xb0fd5002, 0x2d23d105, 0xa1779b33, 0xa30137d9, 0x1d226340, 0x21cefd17, 0x006d2a2d, 0x862de182, 0x0205e5ff, 0x3000ec05, + 0x00b92001, 0x0650462f, 0x59462d20, 0x822e2007, 0x92402708, 0x55021010, 0x05830e18, 0x05841720, 0x05841620, 0x830c1521, 0x0a142111, 0x4c080583, + 0x1f03090b, 0x081b2300, 0x08291f14, 0x1f241828, 0x08392f24, 0x13381036, 0x2a361f35, 0x1045084a, 0x1f451349, 0x2a44274a, 0x1b550258, 0x2d551f55, + 0x1b66196b, 0x2b661f65, 0x167b2f60, 0x20701f70, 0x2d742a74, 0x09231286, 0x37100e40, 0x08048308, 0x00020625, 0x04281a11, 0x2121061d, 0x021d3425, + 0x340e0a0a, 0x28210a06, 0x09161a15, 0x1a550209, 0x40f0ffb8, 0x820d0d0c, 0x15112609, 0x091a2100, 0x072f4300, 0xf0310882, 0x0c0c0f40, 0x74005502, + 0x70320f32, 0x6a090232, 0x05d65e31, 0x2405bd5b, 0xed2b2b2f, 0x08bd512f, 0x12112308, 0x54433917, 0x58154058, 0x68285711, 0x79286711, 0x89287611, + 0x97288611, 0x0a289911, 0x3031595d, 0xae5b2b2b, 0x2b2b2205, 0x0657442b, 0x27242226, 0x04163335, 0x20084961, 0x07be5b27, 0x23151724, 0x776b2426, + 0x16172205, 0x08028216, 0x51020559, 0x96d55049, 0x85fffea1, 0x2801710e, 0x61cdb882, 0x62af4b63, 0x3c01bfc6, 0x06019df3, 0xfe550e65, 0xc19f91eb, + 0xec407960, 0x01a8a652, 0x3baa57a9, 0x3b3c4840, 0x8a665ef8, 0x1a5e6373, 0x2a141a14, 0xefbba3cb, 0x48ea2c3c, 0x5d68845f, 0x280e1c6a, 0x00b22c15, + 0x82000100, 0x043e0800, 0x00d105ee, 0x40730007, 0x35040119, 0x08030306, 0x091f090f, 0x0003094f, 0x0902015b, 0x01550209, 0xffb80414, 0x0d0a40f6, + 0x0455020d, 0x01054f5b, 0xeaffb805, 0x10100b40, 0x08055502, 0x05820b0b, 0xb4200f82, 0x18822983, 0x0cb4f223, 0x0dba4d0c, 0x1182ff20, 0x05550623, + 0x82f7822f, 0xf45d2202, 0x0538702b, 0x2c06024d, 0x21112311, 0xee042135, 0xfdc6ecfd, 0x258982ec, 0x05dffa21, 0x9983b021, 0xe1ffb224, 0x99822905, + 0xcc001d3f, 0x12231b40, 0x033d1823, 0x034c093d, 0x1377094c, 0x1c081777, 0x3415030d, 0x141b0a06, 0x0a9b4e1f, 0x924ef820, 0x40ea2807, 0x020f0f11, + 0x830c0055, 0x60002095, 0xb824059c, 0x1d40f2ff, 0x0020c383, 0xbf48c982, 0x1f762e08, 0x1f1f1f0f, 0x0f031f40, 0xffb80c14, 0x21d685dc, 0xd683040c, + 0xda4e0f82, 0x840c2006, 0x200f8247, 0x82dd84f6, 0x05a84608, 0xf4250882, 0x060d0db4, 0x22088355, 0x820c0cb6, 0x526b2008, 0x6463149f, 0x3c3f2105, + 0x250cf460, 0x11352626, 0x625c1133, 0x080e820a, 0x47290535, 0x89ce4d51, 0x5147d08c, 0x2721c647, 0x6b6a972c, 0x21272d96, 0xa25602c6, 0x464c50f1, + 0xe852484a, 0xfc7b03a9, 0x398c797b, 0x42414241, 0x036d9339, 0x5701008a, 0x49080861, 0x408c0006, 0x48014766, 0x04050202, 0x57060705, 0x03068606, + 0x00001406, 0x04070501, 0x04860457, 0x03140403, 0x01080302, 0x024b0144, 0x01730258, 0x0006027c, 0x03750205, 0x02030301, 0x4a004508, 0x01020203, + 0x24000403, 0x35573a00, 0x00062606, 0x080f086e, 0x3f028201, 0x032b030b, 0x03550335, 0x037b0365, 0x07640306, 0x5d5de610, 0x5df6105d, 0x5d393911, + 0x5d3f3f00, 0x08080b4d, 0xc05dfd22, 0x5dfd1087, 0x5d01c008, 0x01210101, 0x05010133, 0xfee2fd5e, 0xd4e2fdf8, 0xd301d301, 0x2ffad105, 0xe2220382, + 0xb7821e05, 0x005c7208, 0x058d0700, 0x000c00d1, 0x47aa40c9, 0x79036703, 0x010d0303, 0x0404020b, 0x08050502, 0x01170b0c, 0x05180319, 0x0b190819, + 0x08290329, 0x023b0b29, 0x04320339, 0x093c0834, 0x0b3a0a33, 0x0444024b, 0x094c0844, 0x0b4b0a43, 0x025a0155, 0x055a0455, 0x09590757, 0x01650a55, + 0x0465026a, 0x096a056a, 0x027f0a65, 0x08730470, 0x0a72097c, 0x0c2e0b7c, 0x25758214, 0x05061407, 0xf4820306, 0x09094025, 0x84095502, 0x002f0805, + 0x02090003, 0x030b0805, 0x02060c09, 0x08020306, 0x0634003b, 0x0644004b, 0x0675007a, 0x0e720006, 0x0e3f0e1f, 0x0e7f0e5f, 0x0d670604, 0x825dee10, + 0x29f582fe, 0x5d391712, 0x315d2b2b, 0xaa5b0130, 0x5d012205, 0x23f48200, 0x23010123, 0xfa82f783, 0xfe8d0735, 0xc7fedf7d, 0xfedacefe, 0x3901cb76, + 0x01c93401, 0x82370137, 0x042f2eff, 0x052cfbd4, 0x042afbd1, 0x041efbd6, 0x089582e2, 0x00004441, 0xd1053805, 0xc2000b00, 0x01759740, 0x0a02077a, + 0x1a0a0504, 0x2c0a1504, 0x370a2304, 0x42044d09, 0x5f03580a, 0x57055804, 0x570a5009, 0x6d03680b, 0x67056804, 0x670a6009, 0x73047b0b, 0x830b170a, + 0x140937db, 0x03080708, 0x02010214, 0x06061405, 0x07040507, 0x060b0a01, 0xd1820802, 0x0d0f4608, 0x16020601, 0x36022602, 0x05024702, 0x08190809, + 0x08390829, 0x02050848, 0x040a0708, 0x02060401, 0x0016000d, 0x00360026, 0x00500047, 0x0d660006, 0x19060908, 0x39062906, 0x5f064806, 0x66060606, + 0x5df6100c, 0x27038332, 0x2f391711, 0x5d5d5d2f, 0x84050241, 0x87ed22fe, 0x28028610, 0x5d015d00, 0x01230209, 0x08028201, 0x0101332b, 0xfefd3805, + 0xfee50102, 0xd860fe6a, 0x05fe0702, 0x019101e4, 0xfdd1059a, 0x020ffd20, 0x029bfd65, 0xfde902e8, 0x005d02a3, 0x08728201, 0xe6040031, 0x0800d105, + 0x5c40d400, 0x042c012c, 0x07350728, 0x04400140, 0x07500740, 0x07700468, 0x1906160a, 0x28062708, 0x59065608, 0x6a066508, 0x83080808, 0x140627f3, + 0x02050405, 0x03820d00, 0x0400012c, 0x04030700, 0x04080701, 0xf3830502, 0x0a1f0a2d, 0x0a7f0a4f, 0x015b0004, 0x44040107, 0x375108ce, 0x0b824c05, + 0x0fb4fe25, 0x8255020f, 0xb4e82111, 0x08822583, 0x8205e343, 0xb4fa2408, 0x83060d0d, 0x40fa241a, 0x820c0c0c, 0x4f5b2509, 0x02057f05, 0x23099f52, + 0xf45d2b2f, 0x2505de44, 0x392bed2b, 0x1741e410, 0x315d2406, 0x415d0130, 0x18420516, 0x11430805, 0x33011123, 0xe6040101, 0xfdc6f4fd, 0x9701dbf2, + 0xd1059b01, 0x73fdbcfc, 0x59037802, 0x9a0266fd, 0x00010000, 0x0500007e, 0x00d10508, 0x40590009, 0x08070336, 0x08130806, 0x08360826, 0x08560846, + 0x82760866, 0xb32a08f3, 0x07030202, 0x06350307, 0x08020203, 0x04080135, 0x07020308, 0x09020407, 0x0b0f0b73, 0x0a690201, 0x105de610, 0x393911e6, + 0x0382122f, 0x2205d351, 0x822f32fd, 0x874b088d, 0x5ded7a10, 0x21c08718, 0x21013521, 0x01152135, 0xfb080521, 0xfc910376, 0xfc520491, 0xb8b00366, + 0xb3b06904, 0x010092fb, 0x78feef00, 0x1406f702, 0x45000700, 0x52052040, 0x52060102, 0x00030b01, 0x0c0c0600, 0x0655020d, 0x8209090c, 0x011f2305, + 0x0d820d1a, 0xffb80128, 0x0c0cb4de, 0x08825502, 0x0bb4ee23, 0x2208820b, 0x6e2b2b2f, 0xa56005ce, 0x11212308, 0x03821521, 0xfdf70230, 0xfe0802f8, + 0xfe5a01a6, 0x8f9c0778, 0x6b8282f9, 0xd0fe4624, 0x6b82c003, 0x3a00033f, 0x01032840, 0x19010a02, 0x38012a01, 0x59014b01, 0x78016801, 0x09018901, + 0x03001201, 0x272a822f, 0x00000103, 0x02700260, 0x6c065b6d, 0x012d0a95, 0x03330123, 0x33fdadc0, 0x07d0feb0, 0x242a8244, 0x0278feab, 0x27c184b3, + 0x0409405d, 0x03010752, 0xb823c183, 0x83b4f2ff, 0xb80324c1, 0x83b6f4ff, 0x1f0325c4, 0xf6ffb800, 0x2207fd4e, 0x831140f0, 0x040021d1, 0x0021ce83, + 0x82cb830e, 0xb7fa211e, 0x00262983, 0x2f010500, 0xc846333c, 0x2bed2105, 0x2605874d, 0x21013031, 0x82112135, 0xb3022303, 0xd582f8fd, 0xdd82a620, + 0x068f7825, 0x82008f7e, 0x02ba2d83, 0x05d205aa, 0x000600d1, 0x3b344047, 0x2408a082, 0x0345014b, 0x0350015f, 0x0360016f, 0x0370017f, 0x7b02690a, + 0x02010202, 0x1f030f05, 0x5f033f03, 0x05036f03, 0x2d028203, 0x4f000000, 0x04000200, 0x2f5d332f, 0x565e3f00, 0x30312705, 0x015d015d, 0xe9830923, + 0xc6d20532, 0x3afe39fe, 0x7e4d02c5, 0x7302ac02, 0x27038bfd, 0xff2f6f82, 0x05d4fefc, 0x004cff1a, 0xb6110003, 0x82025001, 0x2f0225b1, 0x002f3311, + 0x3207c960, 0xe2fa1a05, 0xd4fe1e05, 0x01010078, 0x02160554, 0x828c06fa, 0x4024312b, 0x59014816, 0x79026902, 0x03500402, 0x03700360, 0x01240082, + 0x2f020000, 0x7c823a83, 0x7882e482, 0x0233012b, 0xeffe95fa, 0x011605f3, 0x3e9b8276, 0x04e1ff68, 0x0078041d, 0x01330026, 0x0c594069, 0x1923040a, + 0x0423150a, 0x0c0c122b, 0x842c5506, 0x842d2005, 0x59410805, 0x5c1e510e, 0x600e692c, 0x7b2d6f1d, 0x70147a0a, 0x0a2c7b1d, 0x3d280802, 0x11401130, + 0x20111102, 0x011c4f08, 0x3f181c1c, 0x41310420, 0x08010a08, 0x1d011d0f, 0x40352711, 0x55020909, 0xf4ffb802, 0x210888b4, 0x11850c0c, 0x2c05154e, + 0x1d001a02, 0x1006000b, 0x00550210, 0x088d5612, 0x2005fa47, 0x22338318, 0x4e0d1a00, 0xfc21054f, 0x213983b4, 0x5f6db800, 0x82062005, 0x82a4832e, + 0x40f4240f, 0x82090915, 0x05a6560f, 0x0f35912d, 0x3f351f35, 0xb82e0335, 0x83b4f8ff, 0x2808823b, 0x0f0d40f4, 0x2e55060f, 0x27328308, 0xb80b1b2e, + 0x3740faff, 0x0b217383, 0x2173830c, 0x2783080b, 0x831c0b21, 0x0c0b216f, 0x06200b84, 0x0b216c83, 0x20588316, 0x250b820b, 0x0a0b5506, 0x05820d0d, + 0x235d8520, 0x502b200a, 0xe62005ce, 0x2408af56, 0x1039112b, 0x200d83fd, 0x060f5932, 0x33ed3f2f, 0x12115d2f, 0xed5d2f39, 0x30313912, 0x251b825d, + 0x23215d01, 0x235c0635, 0x05097405, 0x6b372421, 0x03211485, 0x0a487411, 0x1d049908, 0x285519bb, 0x97527a2f, 0x66656dd2, 0x2da41e01, 0x3d70282a, + 0x0a61b64a, 0x7665d037, 0x423f40af, 0x44e956bb, 0x77746451, 0x1177a463, 0x1f17123d, 0x9d7f9bc8, 0x08202d2d, 0x1854401d, 0x25271017, 0x27240fbf, + 0x6c922e2f, 0x37011dfe, 0x17131405, 0x61605561, 0x0002004d, 0x04e1ffb9, 0x00140690, 0x01200013, 0x34294012, 0x3b0f3502, 0x44203015, 0x4b0f4502, + 0x57204015, 0x7f126712, 0x0c1c7b08, 0x1706090e, 0x0c041142, 0x06401e01, 0x14080b0a, 0xb4f4ffb8, 0x55060c0c, 0xb6260883, 0x55020c0c, 0x05701b14, + 0xb4f0210b, 0x2806cc41, 0x0d0b40f4, 0x0055020d, 0x8223830e, 0xb4ec2521, 0x55060909, 0x3e850882, 0xf3240882, 0x0d0d2940, 0x90301282, 0x3f221f22, + 0x1b0e0222, 0x09090c09, 0x0c095502, 0x09213183, 0x832e8308, 0x55062c0b, 0xb80c1a09, 0x10b4deff, 0x82550210, 0x58e22008, 0xd84905b3, 0xb4ee2108, + 0x18826783, 0x0b40f622, 0x0c213983, 0x82398306, 0x84f0200f, 0x210882a7, 0x6783b6ef, 0x21880c23, 0x09e65e10, 0x2105ad41, 0xfc45105d, 0x002b2409, + 0x82ed3f3f, 0x39122102, 0x4105c669, 0x272a06aa, 0x33112307, 0x33363611, 0x93671232, 0x07920805, 0x33161611, 0x90043632, 0xaa47434f, 0x458e5f66, + 0x4fbcb00c, 0xe5c66fb2, 0x529384c2, 0x735048a8, 0x02b19c49, 0x4ce08c37, 0x262d4f4f, 0xfd140634, 0xfe5341d4, 0xc8e6fed0, 0xfd3847cf, 0xcd1c2480, + 0x00010000, 0x03e7ff69, 0x007704f3, 0x40b50021, 0x4f230f4c, 0x012b0223, 0x162a0e22, 0x013a1824, 0x163a0e35, 0x01491835, 0x0e440a4f, 0x1841164f, + 0x0e550159, 0x0e650169, 0x0e73017a, 0x14101013, 0x21040c3f, 0x033f1a21, 0x40230f09, 0x55021010, 0xf6834023, 0x20088851, 0x076841de, 0x2e40de22, + 0x0024f783, 0x0617238d, 0x17292183, 0x0d08091b, 0x0955020d, 0x230d8308, 0x0b0b0c09, 0x16220b82, 0x05820909, 0x09090629, 0xb8095506, 0x83b6f8ff, + 0x85092231, 0x07294122, 0x862bed21, 0x0bec5e09, 0x5d015d23, 0x08796725, 0x33001022, 0x2208e26a, 0x67141506, 0x42080672, 0xf3033337, 0x795fa95e, + 0x504948ca, 0x60f72d01, 0x560a4db9, 0xb9a057b7, 0x7639a4b5, 0x1548292f, 0x322d460a, 0xdc484847, 0x01120193, 0xd1273638, 0xd0d74843, 0x181ed9ca, + 0x00112f15, 0xff6c0002, 0x424304e1, 0x2608069b, 0x3c254002, 0x381c301a, 0x421a4f20, 0x5820481c, 0x70066806, 0x01120910, 0x18051102, 0x01040e41, + 0x05421e08, 0x4414110a, 0x0d34166b, 0x55060c0c, 0x40221a02, 0x55020f0f, 0xf6ffb800, 0x10102340, 0x08200982, 0x0021fc83, 0x0a694c10, 0x0c0c2a22, + 0x0a211782, 0x0574440d, 0x2d40ee28, 0x55060f0f, 0x3f830f00, 0x61440020, 0x42922005, 0x1b2105a7, 0x2129830c, 0x1983101b, 0x081b1b23, 0x25498318, + 0xfeffb808, 0x4d832b40, 0x090c0827, 0x08550209, 0x84058410, 0x04082129, 0x08205383, 0x06250b82, 0x0d080855, 0x2005820d, 0x0a894285, 0x9756ed20, + 0x2b2b280c, 0x2b2b2bfd, 0x42003232, 0x3f22078a, 0x38443031, 0x22232f05, 0x36341102, 0x33363637, 0x11171632, 0x3c640333, 0x0472080b, 0xb051bc43, + 0x51ebc867, 0x61b54445, 0xbc4b8858, 0x47784cbc, 0x9688b09e, 0x4675a450, 0x0134014e, 0x4ede8e11, 0x2725504c, 0xfffae401, 0x1a228102, 0xcfc7cadc, + 0x02000047, 0xe6ff6a00, 0x7c046004, 0x1f001800, 0x2740c800, 0x0d2b0426, 0x0d3b0430, 0x04431e3c, 0x1e4b0d4b, 0x16500d5a, 0x17600d6a, 0x1e7a0d78, + 0x1f3c010e, 0x3d1c0f1f, 0xb80b0415, 0x8b6fe8ff, 0x0b0b2905, 0x090f3f07, 0x40210c0c, 0x212bef83, 0x020c0c40, 0xffb81955, 0x840d40f6, 0x001a2209, + 0x08546020, 0xf9834420, 0x218f002c, 0x211f210f, 0x1f03213f, 0x1a830c01, 0x0c0a012f, 0x0155060c, 0x0b18121b, 0x1255020b, 0x21468310, 0x19830812, + 0x0d041223, 0x8411820d, 0x0212211f, 0x12213c83, 0x08fa5385, 0x5e2bfd21, 0x2b25057e, 0x2b2b2bed, 0x05ca4f33, 0xed3f2b2b, 0xed2f3912, 0x015d3031, + 0x08994d21, 0x15336808, 0x20230606, 0x00101100, 0x15123233, 0x23262627, 0x04070622, 0x3ec9fc60, 0x568f3436, 0x0a31e772, 0xfe6dc65f, 0x01c8feea, + 0xf5e2f42b, 0x969301b7, 0x020cb397, 0x3199671b, 0x2c5b3030, 0x013628cd, 0x0115012d, 0xfe420112, 0x942af3f8, 0x0084b2a2, 0x00440001, 0x06120300, + 0x0018001e, 0x1a6740c7, 0x020f0f40, 0x83401a55, 0x082108ac, 0x75143914, 0x00000305, 0x00153f04, 0x083e0e0b, 0x080d0511, 0x09400900, 0x090f0902, + 0x0b08000e, 0x0568460c, 0x0b27de83, 0x06090906, 0x830c0b55, 0x010b23fe, 0x0b820d0d, 0x110f1a30, 0x0d400e00, 0x160e3710, 0x55021010, 0x5983200e, + 0x33840e20, 0xffb80e22, 0x2106dd44, 0x69832e0e, 0xee280f82, 0x0f0f0b40, 0x120e5506, 0x0f824783, 0x0d40fb22, 0x0e214b83, 0x224b8320, 0x4419890e, + 0x2b2609eb, 0x3232322b, 0x00832bfd, 0x122f322c, 0x5d2f2f39, 0x333f3f00, 0xfe5332fd, 0x01810805, 0x012b2b5d, 0x23262623, 0x15150622, 0x11211521, + 0x35231123, 0x36343533, 0x17163233, 0x1f0a1203, 0x6d792664, 0xb3fe5301, 0xc67f7fbc, 0x2a653fbb, 0x13095e05, 0x9e268c6b, 0xbf0341fc, 0xd5c7259e, + 0x0200080c, 0x59fe6c00, 0x7c044304, 0x30002300, 0x2d402f01, 0x2a3e133d, 0x303a2c32, 0x134b0944, 0x2c422a4c, 0x015b304b, 0x165a055d, 0x056c016a, + 0x057c166a, 0x22112070, 0x15211205, 0x041e4028, 0x07055007, 0x40210883, 0x36d4831b, 0x400b0707, 0x412e0d03, 0x060f0715, 0x24210601, 0x0f0f4032, + 0x48125502, 0x0884074e, 0x850c0c21, 0x42402011, 0x1a290521, 0x00180600, 0x40f6ffb8, 0x22df4351, 0xdb431a20, 0x1f322711, 0x02323f32, 0x5683082b, + 0x0c0c2b34, 0x2b55060c, 0x0b10181b, 0x1855020b, 0x40feffb8, 0x80820f25, 0x09161823, 0x820f8209, 0x2205821d, 0x850d0d06, 0x5506220b, 0x820b8218, + 0x31852105, 0x230b4d46, 0x2be4105d, 0x1e480087, 0x3fed330d, 0x2b2f33ed, 0x12ed3f2b, 0x313f3939, 0x10255d30, 0xa8732100, 0x0635220d, 0x0cee4306, + 0xee433720, 0xfe73080f, 0x59f4fefe, 0x2e0a52a9, 0x7e6064c8, 0x551e2323, 0xebc8789b, 0xba414651, 0x4983615c, 0x4bbcb00c, 0xb29b4081, 0xa5529984, + 0xfee4fe7f, 0xc01719f6, 0x292e3512, 0x66446e27, 0x21014344, 0xd1900701, 0x274f474c, 0xd6fc3028, 0x1d226102, 0xc2bcc6d0, 0x0001003f, 0x040000b9, + 0x0014065f, 0x40330116, 0x16150313, 0x03157515, 0x42080d10, 0x010e0413, 0x45080d01, 0xf8251461, 0x060909b4, 0x201a8355, 0x056945b6, 0xffb80028, + 0x1010b4ea, 0x08825502, 0x1140fc24, 0x09820b0b, 0x66450420, 0xffb8220a, 0x843282fc, 0x48fe201e, 0x22200621, 0x24062344, 0x0f0fb4e0, 0x22378306, + 0x833440fa, 0x0d002155, 0xf2515283, 0x18912706, 0x1860181f, 0x43431002, 0x4308200c, 0x1a210a43, 0x0723480d, 0xe0200882, 0x25052348, 0x09090c0d, + 0x0f825502, 0x0db4ee23, 0x5208840d, 0x11820505, 0x3e43ea20, 0x840d2005, 0x210f8242, 0x6c83b4f1, 0xb6270883, 0x55060d0d, 0x4317880d, 0xfd210a40, + 0x2100822b, 0x118a5d32, 0xed2b2b22, 0x2b251282, 0x3f3c3f00, 0x05e2493f, 0x11232122, 0x2105fd66, 0x3b5e0622, 0x365c0805, 0x16323336, 0xbc5f0415, + 0x5e191812, 0x4da84d4b, 0xbc58bcbc, 0x02beb563, 0x26874d7c, 0x3b4c292a, 0x1406befc, 0x5249cdfd, 0x0000cdda, 0x00af0002, 0x05830100, 0x000300db, + 0x40a30007, 0x02440113, 0x370d0b40, 0x05060302, 0x097f0805, 0x00920901, 0x40fcffb8, 0x020c0c2c, 0x04600055, 0x0421d884, 0x250d830c, 0x09090604, + 0x0b835506, 0x1a2c0582, 0x0f0f0201, 0x60015502, 0x0501057f, 0x82071041, 0x06104108, 0x37840520, 0x10410f82, 0x41088205, 0x08820510, 0x83b4fc21, + 0x28088246, 0x0c0cb6ff, 0x88055506, 0x23ee8808, 0xfd2be45d, 0x2208ed83, 0x5de62be4, 0x3f3f3f00, 0x3031ed2b, 0x35230101, 0x11230333, 0xd4830133, + 0xbcbc0cd4, 0xfac31805, 0x825d0425, 0xc2ff25c9, 0x150259fe, 0x1929c984, 0x2340d100, 0x051c050a, 0x34ce8802, 0x05193e16, 0x400f0b0b, 0x174f0d07, + 0x0a7f1701, 0x60010a01, 0x07d84316, 0x84540882, 0x85088205, 0x2008828f, 0x218f84f4, 0xff841a16, 0xff851820, 0x70170a2e, 0x0e190119, 0x55021010, + 0x0b0b0c19, 0xb8220582, 0xf341deff, 0x08192305, 0x0f840909, 0x0b40e422, 0x02200984, 0x19223283, 0x4d69ffb8, 0x22088205, 0x831340ec, 0x071921ea, + 0x1928e783, 0x060d0d05, 0x1b921955, 0xe982ed88, 0x32325d22, 0x2f22f287, 0xf3822f5d, 0x2f32fd24, 0xf784ed3f, 0xf7845d20, 0x08116161, 0x21352362, + 0xd4d41502, 0x28a8c80c, 0x1c0a2c83, 0x58482d5f, 0xe90d1616, 0x1805a501, 0xc40afac3, 0xb30c10c8, 0x28281c0b, 0x03517128, 0x00009e84, 0x00c10001, + 0x06af0400, 0x000b0014, 0x284440fa, 0xdb01d802, 0x01090309, 0x011f0d0f, 0x0d1f021d, 0x0d2f012d, 0x0b400b30, 0x02690b54, 0x020c017a, 0x1a010302, + 0x37082a82, 0x02b40908, 0x0a030a0b, 0x0a050208, 0x01010705, 0x020b0805, 0x0a700a60, 0x000a0a02, 0x40f4ffb8, 0x060f0f28, 0x0d000055, 0x0d400d20, + 0x0c030802, 0x55020909, 0x0c0c0c03, 0x04200582, 0x0b83f383, 0x03550623, 0x0b1a421a, 0x3741e220, 0x081a4205, 0x42081142, 0xe6200823, 0x20052b43, + 0x82428405, 0xb4f7253a, 0x55060c0c, 0xb6220883, 0x08820d0d, 0x28638920, 0x482b2008, 0x2b2905bf, 0x33115d32, 0x2f332b2f, 0x05e45d5d, 0x39123f22, + 0x2305cc58, 0xf57ac0c0, 0x27056c61, 0x01c008fd, 0x2321715d, 0x08096861, 0xf8af0433, 0xbc7a40fe, 0xed1f02bc, 0xe901f9fd, 0x068bfe74, 0x021afc14, + 0x00fcfd2f, 0x00bb0001, 0x06770100, 0x00030014, 0x0227407d, 0x7f080101, 0x92050105, 0x4ae08400, 0x082006f9, 0x0b83e083, 0x00550627, 0x01017f1a, + 0x07fe4201, 0xfe420882, 0x84012006, 0x850f822f, 0x470882da, 0x01200655, 0x0f82da84, 0x83b6f821, 0x88012245, 0x080e4204, 0x82fd5d21, 0x05f842d4, + 0x0130312a, 0x33112321, 0xbcbc7701, 0x31458a82, 0x07390805, 0x007c0417, 0x40c8012b, 0x0324034b, 0x13241329, 0x44204429, 0x072ab726, 0x250125b6, + 0x081c1d1f, 0x22284217, 0x01051d04, 0x40081c10, 0x2d1f012d, 0x2d402d30, 0x2d702d50, 0x33bc9905, 0xc0ffb82d, 0x0f0f1740, 0x402d5502, 0x55020c0c, + 0x10101801, 0x08220582, 0x05820b0b, 0xeaffb823, 0x821a83b4, 0x40f424ac, 0x82090911, 0x84302012, 0x0d1c2124, 0x2005cf51, 0x211e82f2, 0x1e825506, + 0x2b40f022, 0x0222cc84, 0x0f820d0d, 0x25106126, 0x0c0f1c0b, 0x0f213083, 0x2130830c, 0x1d83080f, 0x06270b83, 0x101a0f55, 0x57f6ffb8, 0x10200541, + 0x0f826784, 0x8957d220, 0x26102105, 0x10222d83, 0x5e820d0a, 0xf8201582, 0x08845e84, 0x08823f83, 0x0cb4fb25, 0x8255060c, 0x40ff2208, 0x226a8321, + 0x841a1f10, 0x841a2066, 0x841a2066, 0x240b8366, 0x1a1a5506, 0x0794411c, 0xe6200882, 0x20057842, 0x822c841c, 0x0578420f, 0x9d410882, 0x42088305, + 0x1c210578, 0x8269830a, 0x84fc200f, 0x21088369, 0x69830e40, 0x1f611c2a, 0x80104010, 0x2f100310, 0x4208c553, 0x10200781, 0x20087d47, 0x220983fd, + 0x47393911, 0x0f83089d, 0x0483ed20, 0x005d5d2c, 0x3f3c3c3f, 0x32fd3c3f, 0x3b7b1211, 0x0bc64505, 0x15161623, 0x0ed54511, 0x36361526, 0x17163233, + 0x152d0584, 0x0dbc1707, 0x51561715, 0x034f9e4f, 0x080a8504, 0x4d9b4d34, 0xaf58bcbc, 0x279f7263, 0xb86bbc72, 0x487c02af, 0x2c2b2886, 0x3d173d4f, + 0x0235fd1e, 0x28854a7c, 0x3b4c2b2b, 0x5d04befc, 0x6052497c, 0xdf556055, 0x494200c8, 0x5f042705, 0x16007c04, 0x7b472901, 0x4705200f, 0x1720367b, + 0x250a7b47, 0x02090908, 0x68470055, 0xb4fe2107, 0x2606e54c, 0x0f1140e0, 0x4755060f, 0xb8260c68, 0x2840f8ff, 0x15820909, 0x23097247, 0x55020c0c, + 0x47067847, 0xb4221972, 0x6b470f0f, 0x058f4f0e, 0x47088447, 0x71473f72, 0x059b411f, 0x081d7147, 0x7c5d0434, 0xcdda5249, 0x6a000200, 0x7104e1ff, + 0x0b007c04, 0xfa001700, 0x0e3b1a40, 0x14341034, 0x0e4b163b, 0x14441044, 0x0f08164b, 0x1504093f, 0x0c0a033f, 0x7d63ffb8, 0x25088205, 0x0c0cb4f4, + 0x08825502, 0x6c4bf220, 0x1b0c2305, 0x11834019, 0x6fb80021, 0xa552067e, 0x10102105, 0x08064118, 0xdaffb824, 0xd5480fb4, 0xb4ee2205, 0x05005109, + 0x4582f620, 0xe7480620, 0x0d3d2205, 0x3209820d, 0x190f1990, 0x193f191f, 0x1204196f, 0x02090904, 0x830c1255, 0x27058355, 0x1b125506, 0x0b0b1606, + 0x20088e7c, 0x23198308, 0x0d0d0406, 0xb8241182, 0x1940feff, 0x06215d83, 0x255a8310, 0x0c0c0406, 0x1b835506, 0x85210582, 0x08c14418, 0xae522b20, + 0x08fb5005, 0x00200e83, 0x5f08736d, 0xdf500ad4, 0x05c34f05, 0x71042008, 0xedebe8fe, 0x1701e9fe, 0x1801ebed, 0x9997aac2, 0x9698aaa9, 0xfe2e02ab, + 0x01c4feef, 0x8211013c, 0x3d320801, 0xeffec3fe, 0xd9d3d3d9, 0x00d7d9d2, 0xfeb90002, 0x04900464, 0x0013007c, 0x40220120, 0x39023225, 0x43203215, + 0x42154902, 0x67125620, 0x7c087e12, 0x4d520a1c, 0x1e052607, 0x0b090640, 0x064d520c, 0x82550221, 0xb6f62108, 0x4d52be83, 0x23f18306, 0xd0ffb800, + 0x20074a4a, 0x052b44f0, 0x41120021, 0xcc47066e, 0x41218205, 0xf6201155, 0x201c5652, 0x2756520c, 0x22058d44, 0x52ffb80c, 0x714d085f, 0x245f5206, + 0x21053049, 0x60523232, 0xed2b2209, 0x1761522b, 0x11231124, 0x61521533, 0x4e3e0813, 0x64b34247, 0xbc498d57, 0x6abb4bbc, 0x8ac2e1ca, 0x4ba4518f, + 0x9d497350, 0x883c02b0, 0x514a4ee1, 0x2cfe2826, 0x3f75f905, 0xfecffe55, 0x46c8caec, 0x2487fd39, 0x0200d41a, 0x64fe6c00, 0x8b414304, 0x07260806, + 0x033b2b40, 0x1c301a3d, 0x034c203a, 0x1c461a4b, 0x1070204a, 0x02051209, 0x40180411, 0x0c01040e, 0x0905421e, 0x23511411, 0x28e54b05, 0x24274951, + 0x095940fa, 0x24495109, 0x0b0b1428, 0x06085502, 0x05820909, 0x3f511220, 0x830e2010, 0x08082345, 0x45510c0c, 0x07cb5319, 0x51060246, 0x01220f46, + 0x574d1123, 0xbc36081f, 0xc764ac57, 0x424453ed, 0x8b5a63b2, 0xbcb00c48, 0xa346784e, 0x529389aa, 0x0264fea4, 0x01494b1a, 0x900e0133, 0x50494bdd, + 0xfc302728, 0x237802bf, 0xc4c2dd1c, 0xc14547d3, 0x72033c06, 0x12005d04, 0x1440bc00, 0x0d100d00, 0x0c030d20, 0x00000f09, 0x0f0a4304, 0x73080905, + 0xc4630be1, 0x00002a06, 0x70144014, 0x070c0214, 0x27ee830c, 0x0c0c0c07, 0x06075502, 0x0b83e883, 0x07550625, 0x54b8091a, 0x088206f8, 0x0343e020, + 0x84092005, 0x420f822c, 0x088205a1, 0x1140ee2e, 0x55020d0d, 0x0f0f2409, 0x0a095506, 0x15823f83, 0x0cb4f823, 0x250e820c, 0xb6f9ffb8, 0x08820d0d, + 0x4c138821, 0x113111d1, 0x2b2b2f33, 0x3c3f3f00, 0x112f32fd, 0x30313912, 0x060a505d, 0x93420720, 0x16210808, 0x0a720317, 0x57364f2a, 0xbcbc4ba2, + 0x3159ab70, 0x90032c2c, 0x3d4d090a, 0x5d04e7fc, 0x054b5aa5, 0x08fd8307, 0xe5ff6e60, 0x7804d703, 0x53013300, 0x02065740, 0x02151b09, 0x09261b19, + 0x0932242a, 0x0942243c, 0x055e244c, 0x2153165d, 0x32542f56, 0x166c056f, 0x2f642060, 0x7a143265, 0x74117f05, 0x74287920, 0x88018a2b, 0x871a850d, + 0x9a019428, 0x0e000b1b, 0x1e042918, 0x01228003, 0x0b0b4022, 0x22225502, 0x27503e26, 0x0c402105, 0x07340f83, 0x033e0b07, 0xb80e2109, 0x2b40faff, + 0x55020909, 0x0c0c0c29, 0x06250585, 0x351b2955, 0x210d8340, 0x19831018, 0x840a1821, 0x09082b0b, 0x18550609, 0xb5f6ffb8, 0x08820c0c, 0xca453982, + 0x21088305, 0x13830b40, 0x001b0e29, 0x00071821, 0x56eaffb8, 0xc64e07c0, 0x4cf42008, 0x00210548, 0x067b4414, 0x41087244, 0x33820561, 0x2740f836, + 0x55060d0d, 0x0f358e00, 0x3f351f35, 0x7f355f35, 0x16070535, 0x1620ab84, 0x07217a83, 0x2863831a, 0x10348607, 0x2b2b2be6, 0x4805845d, 0xed220795, + 0x975a2b2b, 0x522b2008, 0x332b08ca, 0x115d2b2f, 0x31391712, 0x6d015d30, 0x35250ed1, 0x27262734, 0x18028326, 0x2108504c, 0xc1511517, 0x17142406, + 0x82161716, 0x17920802, 0xfdd70316, 0x46cf7cdb, 0x64da590a, 0x26268c7c, 0x3581286c, 0x3a397b93, 0x646bad38, 0x480a44cd, 0x8e6763ce, 0x345e2a2b, + 0x47832b81, 0x99420147, 0xd3233bc4, 0x56504f43, 0x18222242, 0x270e1809, 0x7a456e97, 0x31372f30, 0x4935c923, 0x23454e4f, 0x180c1623, 0x4a491e0a, + 0x3e000100, 0xfd02eaff, 0x1b009e05, 0x4240b200, 0x051a050c, 0x0b03052b, 0x0d3e0710, 0x1b050a0b, 0x033f171b, 0x7f1d4f09, 0x000e021d, 0x0d081d8c, + 0x09090c10, 0x0c105502, 0x05820c0c, 0x09090423, 0x820b8406, 0x0a1a3505, 0x0d400708, 0xb8073710, 0x1140deff, 0x55021010, 0x0f0f2007, 0x30840582, + 0xde421582, 0x42088205, 0x072606de, 0x060f0f1c, 0x43840755, 0xf1201582, 0x23058247, 0x0d0d1707, 0x88211582, 0x0def521c, 0x822bfd21, 0x2f322400, + 0x4d32f610, 0x332606bd, 0x2f32fd33, 0xb8563031, 0x11352a06, 0x11333523, 0x15211133, 0x09c56121, 0x02335008, 0x317d35fd, 0x7f7fb2ab, 0xfe8401bc, + 0x1618087c, 0x642e4f4d, 0x0e0a0a16, 0x02cbb812, 0x41019e52, 0xfe9ebffe, 0x2b635803, 0x091b2528, 0x00010000, 0x04e1ffb1, 0x005d0457, 0x401b0116, + 0x19060b14, 0x03077a07, 0x09150502, 0x05421105, 0x5608010a, 0xf6201594, 0x28123251, 0x101d40ee, 0x00550210, 0x0ab66b08, 0x2005ad49, 0x06aa4902, + 0x4648ea20, 0x40f62207, 0x0a1c5133, 0xfd830e20, 0x51920021, 0x1b51051c, 0xb8082419, 0x83b4e2ff, 0x4b088261, 0xa8560676, 0xffb82106, 0x82056741, + 0x05534718, 0xf1200882, 0x2105764b, 0x68830808, 0xb4240f83, 0x55060c0c, 0xf5210882, 0x216e83b6, 0x1b518708, 0x2bed210b, 0x460ddb6b, 0x002706f9, + 0x3fed3f3f, 0x5639123c, 0x326309be, 0x114f080d, 0xbc570433, 0xb069ae5f, 0x1a10bcc4, 0x4952561b, 0x7cbc4bad, 0xd0d7504b, 0x84fdd502, 0x2c2b7955, + 0x033b4c28, 0x00010042, 0x0400003d, 0x005d047f, 0x408d0006, 0x29042641, 0x39043606, 0x49044606, 0x05290606, 0x05400539, 0x05600551, 0x821a0605, + 0x04580829, 0x0302031a, 0x03270028, 0x03370038, 0x0347004a, 0x027a0175, 0x02050008, 0x03010375, 0x02080205, 0xb8000301, 0x2440c0ff, 0x0c371009, + 0x6a001c00, 0x04007a00, 0x0f088d00, 0x03030108, 0x03650313, 0x03040375, 0x020b0b1c, 0x07820355, 0x5d2be610, 0x5df4105d, 0x3939112b, 0x080d2363, + 0xfd108723, 0x5d015d00, 0x01230101, 0x04010133, 0xbd3cfe7f, 0x01cc3ffe, 0x0457015a, 0x04a3fb5d, 0x0387fc5d, 0x328d8279, 0x06000056, 0x005d0436, + 0xb9f2000c, 0xf2ff0800, 0x820909b4, 0xffb82258, 0x064d44f2, 0x0c0c0c2a, 0xb8065506, 0x8740f4ff, 0x3e080983, 0x031d030d, 0x022a012c, 0x04250329, + 0x08240526, 0x01340b2b, 0x0144053b, 0x0157054b, 0x05590458, 0x026d0b57, 0x08640462, 0x0a64096a, 0x01790b6b, 0x0472027d, 0x097b0874, 0x0b7a0a73, + 0x821a0c1e, 0x1a072970, 0x00060506, 0x02091009, 0x82051663, 0x060a2305, 0x17630555, 0x02052b07, 0x1f060f08, 0x03062f06, 0xe3831a00, 0x83260021, + 0x8e002a76, 0x3f0e100e, 0x030e6f0e, 0x218b8200, 0x1983b4e0, 0x776a0882, 0x24088205, 0x090d40fa, 0x20a78209, 0x20ad8418, 0x06506f83, 0x105d3225, + 0x612b2be6, 0x4463062a, 0x2b2b280d, 0x2b012b00, 0x83230101, 0x33270802, 0x01330113, 0xfe360613, 0xe1feaedd, 0xfeade3fe, 0x01cdc4da, 0x1e019b17, + 0xfb5d04c2, 0xfc5d03a3, 0xfc5d04a3, 0x8361039f, 0x82002003, 0x3c7008c2, 0x80040000, 0x0b005d04, 0x8c40e100, 0x011b0b09, 0x07140314, 0x0327091b, + 0x003c0727, 0x0334013b, 0x06340434, 0x093b0734, 0x004c0a3d, 0x0344014b, 0x06440444, 0x094b0744, 0x015a0a4d, 0x055a0355, 0x095a0755, 0x016f0b55, + 0x05690360, 0x096f0760, 0x0f230b66, 0x3f080002, 0x4f083002, 0x7d084002, 0x08087002, 0x0b0a1a09, 0x061a070a, 0x1a010605, 0x03346982, 0x0405041a, + 0x0b050201, 0x04060908, 0x0675047a, 0x04050602, 0x01350b82, 0x010d0206, 0x0b080205, 0x000a0404, 0x40c0ffb8, 0x37100922, 0x08a48206, 0x0f0d8d32, + 0x0d0f010d, 0x0d400d1f, 0x06040d5f, 0x04010402, 0x020b0b16, 0x0c820455, 0x5d2bf610, 0x105d5d32, 0x322b5df6, 0x5d391711, 0x3f005d2f, 0x17125d3f, + 0x6305fc50, 0x21220d66, 0x65630123, 0x33240806, 0xed800401, 0xc1fec3fe, 0xfeb401db, 0x3b01ed50, 0xfedc3c01, 0xfead0149, 0x022d0253, 0x015afe30, + 0x00dafda6, 0x2f087882, 0x0464fe3d, 0x005d047f, 0x408c0007, 0x34060441, 0x50064406, 0x70066006, 0x03090606, 0x03190507, 0x01460517, 0x00580349, + 0x03790157, 0x1a070209, 0x05393282, 0x0403041a, 0x04460049, 0x02030002, 0x0c020504, 0x01016802, 0x03030201, 0x08d28804, 0x1c000c20, 0x6a004a00, + 0x05007a00, 0x0f098d00, 0x04030109, 0x04450413, 0x04750465, 0x08820405, 0xcf85e410, 0xcd82ce84, 0x83391221, 0x655d20cc, 0xc0200533, 0x21051b63, + 0x09431323, 0x74fd3605, 0x43fed0c9, 0x015701cc, 0xfa5d045a, 0x04d20107, 0x03c4fc27, 0x24bb833c, 0x0300005d, 0x08bb82e3, 0x56000923, 0x08153a40, + 0x0835033a, 0x0845034a, 0x0854035c, 0x037f0860, 0x070a0870, 0x063e0307, 0x08020205, 0x0a15633e, 0x1f0b8e34, 0x5f0b3f0b, 0x7f0b6f0b, 0x8402050b, + 0x5de6100a, 0x1d63e410, 0x635d2013, 0x03340916, 0x027afce3, 0x0383fd8b, 0x0272fd67, 0x35038b9f, 0xc8fc869d, 0xad288383, 0x590478fe, 0x25001406, + 0x41088382, 0x3a1d2f38, 0x56074a07, 0x75236723, 0x1d3a0623, 0x1d021d4a, 0x3f53091c, 0x020a4f0a, 0x14010a0a, 0x24011251, 0x140b0151, 0x0040000f, + 0x19090002, 0x000e1f20, 0x01054009, 0x335d2f05, 0x3cfd3c33, 0xc5792f2f, 0xfd5d3609, 0x315d3939, 0x015d0130, 0x3d262223, 0x2b263401, 0x32333501, + 0x2e098236, 0x15013b36, 0x1d062223, 0x07061401, 0x82011e15, 0x16350807, 0x5904013b, 0xa6dfb396, 0xab3333ab, 0x96b3dfa6, 0x9a7b8872, 0x7b9a8989, + 0x78fe7288, 0xa995bcc7, 0xa9bf9cbf, 0x8ac7bc95, 0x8baf8c7e, 0x371837bd, 0x8caf8bbd, 0x25bd827e, 0x78fe7a01, 0xbd822802, 0x1b000339, 0x050f0f40, + 0x0202054f, 0x000b0101, 0x01014f1f, 0xed5d2f01, 0x853f3f00, 0x33112982, 0xaeae2802, 0x9c0778fe, 0x00213582, 0x20f382bb, 0x08f38467, 0x29406943, + 0x02351221, 0x02401231, 0x0c7a1240, 0x00121306, 0x4f253f53, 0x25250225, 0x1c511b09, 0x09510a01, 0x09001b0b, 0x17000901, 0xfaffb80e, 0x0d0d0f40, + 0x1f0e5502, 0x00090505, 0x2001204f, 0xfaffb820, 0x2c1283b5, 0xd6102720, 0x335d2f2b, 0xfd103c33, 0x1007412b, 0x22338385, 0x14151506, 0x35232306, + 0x35363233, 0x37363435, 0x82262635, 0x84262007, 0x82162011, 0x3316241b, 0x41670433, 0x16410f00, 0xf8012105, 0x08120041, 0xbcc78a50, 0x00bfa995, + 0x01bb0001, 0x03d1058b, 0x001f009f, 0x06424056, 0x09090603, 0x19190913, 0x150a1708, 0x3b1a1918, 0x4b183408, 0x5a184408, 0x550a5a03, 0x5b1b540d, + 0x6e05601d, 0x75186114, 0x75147a04, 0x1c0f1718, 0x540c0654, 0x1f161f06, 0x4a82002a, 0x002a0f2c, 0xed332f10, 0x00ed5d2f, 0x0782332f, 0x8433ed21, + 0x010e29bc, 0x23010e07, 0x2e272622, 0x062c0582, 0x013e2307, 0x33013e37, 0x1e171632, 0x3d080582, 0xd1053736, 0x2e2d2902, 0x925e6482, 0x325c6654, + 0xa709645e, 0x2b2c2902, 0x935d608a, 0x3d665055, 0x03036167, 0x4bc0639f, 0x664f584d, 0xc4af407d, 0x4a4dbd64, 0x62684d5b, 0x00a9ca5b, 0xeb69ffff, + 0x50072505, 0x24003602, 0x24088182, 0x008e0017, 0x0075012f, 0x0313401a, 0x11301120, 0x11701140, 0x02051180, 0x060e1100, 0x2b012507, 0x00355d35, + 0x08338503, 0x00010839, 0x001e0012, 0x40f40021, 0x40202b44, 0x55185a20, 0x551e501a, 0x65186920, 0x091e651a, 0x0d170b18, 0x1246064a, 0x12560659, + 0x03770278, 0x21202008, 0x0187021f, 0x82140101, 0x20270837, 0x04870321, 0x05140401, 0x067b0605, 0x16021274, 0xffb80c51, 0x0d6f40c0, 0x030c3710, + 0x10402134, 0x21550210, 0x830d0d40, 0x092f0805, 0x70550209, 0x21210121, 0x04120620, 0x011c0005, 0x0501031c, 0x4f111308, 0x600f500f, 0x190f030f, + 0x5f094011, 0x03096f09, 0x01230f09, 0x820f0906, 0xab411824, 0x82232011, 0x050a211b, 0x0eab4118, 0x41182220, 0x2f220bab, 0x0282ed5d, 0x3c3f0030, + 0x17125d3f, 0x2b5d2f39, 0x2fed2b2b, 0x4118ed2b, 0x411814b6, 0x262108b3, 0x05955c26, 0xfe6e1520, 0x05646d05, 0x3233cb08, 0x01011336, 0x94d35e05, + 0xc99480fd, 0x6b590702, 0xcb9392cc, 0x722c5969, 0x73725656, 0x36725655, 0xfdfefefe, 0x61fe9f01, 0x9f2c7f05, 0xc2c28f66, 0x2aa3648f, 0x73562f01, + 0x73565574, 0x02f1fb73, 0x0035fdcb, 0x73000100, 0x460559fe, 0x4100ec05, 0x7b40a500, 0x2b03200a, 0x2b15201c, 0x2b220b25, 0x0b330234, 0x02432b34, + 0x2b450b43, 0x21581f5d, 0x275a2558, 0x02613f5e, 0x02702b60, 0x2b702676, 0x1b0b0b16, 0x2d2d020b, 0x02293431, 0x411d061a, 0x1d343d41, 0x1410100a, + 0x0f0d0c32, 0x002a170f, 0x20091009, 0x09090309, 0x7143231d, 0x4371002c, 0x0f01430f, 0x2f431f43, 0x6f433f43, 0x15370543, 0x0b0b1423, 0x1c235502, + 0x05820909, 0x10426831, 0xed2b2bf6, 0xf4105d5d, 0x3912e43c, 0x795d2f39, 0x332109da, 0x2010822f, 0x210f823f, 0x81613031, 0x06072605, 0x16160706, + 0x0c8c5815, 0x71343521, 0x1e4c13c7, 0x20308206, 0x091a5f15, 0x37460539, 0x1a0b4859, 0xbb030212, 0x2d772693, 0x325b1a09, 0x0202626a, 0x18122b13, + 0x33249840, 0x13030903, 0xaca21733, 0x0aa20c0e, 0x1356501c, 0x0202142d, 0x1daa4018, 0xffff2508, 0x0000c800, 0x01089d04, 0x28003602, 0x17010000, + 0x1e008d00, 0x0b007501, 0x0d0001b6, 0x2503020d, 0x00352b01, 0x05232585, 0x82c80738, 0x84312025, 0x00d72225, 0x2325868c, 0x09050a17, 0x70262587, + 0xd705e1ff, 0x25825007, 0x83fd3221, 0x008e224b, 0x31258296, 0x03114018, 0x29302900, 0x29702950, 0x29000204, 0x56840f24, 0x82355d21, 0x82b22057, + 0x84292031, 0x84382031, 0x008e2257, 0x2f318562, 0x20241002, 0x60244024, 0x00010424, 0x1d0d1e24, 0x82057d43, 0xff682631, 0x061d04e1, 0x2063828c, + 0x24318244, 0xe38d0016, 0x25ad8200, 0x37360002, 0x8787261d, 0x4321238f, 0x232385e8, 0x231d3735, 0xd6212397, 0x212385e0, 0x478e3438, 0x88db0521, + 0x828e206b, 0x401e3423, 0x390f0316, 0x02023970, 0x39103900, 0x39403920, 0x85390004, 0x355d2133, 0x7d85d384, 0x35885320, 0x85e2d721, 0x34412359, + 0x7d8c251d, 0x88b10721, 0xd3db2923, 0xb70d0000, 0x3a000203, 0x35214a85, 0x08dc8235, 0xfe690064, 0x04f30359, 0x00380077, 0x0f4f40e8, 0x023a4f3a, + 0x072a012a, 0x2d2a2526, 0x013b2f25, 0x25350739, 0x2f342d3b, 0x214f014b, 0x2d4f2540, 0x01592f40, 0x016c2553, 0x017a2566, 0x0b152575, 0x02081b08, + 0x3f2b2727, 0x03170423, 0x3138381a, 0x0d091a3f, 0x093d110d, 0x140c0c0d, 0xffb8062a, 0x1010b4d8, 0x08825502, 0x0fb4e423, 0x2308840f, 0x0d0db4e0, + 0xec240884, 0x0c0c4740, 0x06250982, 0x3a26201a, 0x20268340, 0x0bd2643a, 0x2e3a8d23, 0x2b1f8306, 0x0c201b2e, 0x55020b0b, 0x09090620, 0x10200582, + 0x08200584, 0x20214383, 0x221f8308, 0x4e398520, 0xb5640604, 0x113c2106, 0x43065973, 0x44431543, 0x17414306, 0x26272624, 0xdd643526, 0x4d213419, + 0xb705031d, 0x2d742592, 0x32581a09, 0x02036268, 0x64191d10, 0x0f331aef, 0x3913091f, 0x0eaca21c, 0x1a0aa00c, 0x2e16584e, 0x65040214, 0xff2d1601, + 0xff6a00ff, 0x066004e6, 0x0036028c, 0x05774248, 0xd541fd20, 0x21222305, 0xd5411812, 0x20238f07, 0x21238643, 0x23992021, 0x85f9d621, 0x20242347, + 0x478c0012, 0x88db0521, 0x828e206b, 0x40142b23, 0x2530030d, 0x02022560, 0x2a862500, 0x82355d21, 0x00a02497, 0x84460200, 0x82d52097, 0x00172597, + 0x0083fe8d, 0x01235183, 0x43050500, 0xff2108bf, 0x201b82eb, 0x22258a91, 0x8f97fe43, 0x02002325, 0x4b82f5ff, 0x063c2508, 0x0006008c, 0x4093000a, + 0x74017a3a, 0x74057a03, 0x01020406, 0x03050503, 0x08080509, 0x0c7f0400, 0x920c0001, 0x230c1f53, 0x060c0c0c, 0x25072553, 0x087f041a, 0x23530801, + 0x53088207, 0xdc4e0623, 0x05bc5508, 0xe54e1882, 0xb6fc2808, 0x55060909, 0x690b8808, 0x2b2505b1, 0xfd325d2b, 0x2a00822b, 0x2f5d33e4, 0x3f3f002f, + 0x4a2f332f, 0x260806e3, 0x03032301, 0x03331323, 0x02331123, 0x8e8f973c, 0x13e3b293, 0x1105bcbc, 0xf5fe0b01, 0x74f97b01, 0x00005d04, 0x82050003, + 0x052d21c5, 0x0805b75f, 0x97000b22, 0x01023d40, 0x04604407, 0x050a0401, 0x1a010809, 0x0001007f, 0x05701a04, 0x0d7f0501, 0x920d0001, 0xc4829986, + 0x08550222, 0x0821ca84, 0x24908406, 0x097f051a, 0x1bee5301, 0xf753ca85, 0x21ca850b, 0x7e5d8809, 0x47ca8a08, 0x3f2c0660, 0x39ed5d2f, 0x01303139, + 0x05333523, 0x13200382, 0x2d27cc83, 0x95febdbd, 0x82b5bdbd, 0xc31825cc, 0x25fac3c3, 0xff21c982, 0x06ff61ff, 0x3602532b, 0x00005100, 0xd7001601, + 0x05d94107, 0x0e172423, 0x092b4215, 0x7104e124, 0x23828c06, 0x23845220, 0x6d448d20, 0x19192206, 0x0a4f4206, 0x4320238d, 0xd62023a2, 0x1c212386, + 0x21478e18, 0x6b88db05, 0x23828e20, 0x0d40142b, 0x501d3003, 0x0002021d, 0x212a861d, 0xbb82355d, 0x83ff6a21, 0x85bb8373, 0x07054597, 0x4f8a2520, + 0x2382b120, 0xbb845720, 0xbb855820, 0xdf85ee20, 0x10181923, 0x8fdf8712, 0x02432123, 0x18232385, 0x97160918, 0xf8d62123, 0x1b212385, 0x84238e17, + 0x316b85bb, 0x0000fd8e, 0x020f4016, 0x1c501c30, 0x01031c60, 0x2c861c00, 0x355d4608, 0xbb000100, 0x5b048700, 0x0b001406, 0x26403c00, 0x000b0a07, + 0x05060401, 0x080606aa, 0x0f010803, 0x020d1f0d, 0x04026300, 0x0a090807, 0x28020601, 0x03706305, 0x5d2f0301, 0x3917ede6, 0x005de610, 0x39122f3f, + 0x380b822f, 0x25013031, 0x05132313, 0x33030535, 0x5b042503, 0x84056dfe, 0x016dfe05, 0x3b068293, 0x0a049301, 0x0378fc05, 0x05810588, 0x72fe8e01, + 0x02000005, 0xcc029a00, 0xec05bc03, 0x23087582, 0x40280017, 0x650f6a18, 0x750f7a15, 0x54150415, 0x540f0303, 0x2a0c0209, 0x2a120000, 0x33ed2f06, + 0x3f00ed2f, 0x5d200583, 0x14236382, 0x49222306, 0x07200688, 0x0a616218, 0xbc032308, 0xe8a9a9e8, 0xe7aaa9e8, 0x666686a5, 0x66638986, 0xa85c0486, + 0xa8a9e7e8, 0x66a8e8e8, 0x68668b8b, 0x73828c89, 0xfe9f5f08, 0x05600497, 0x001c00c3, 0x40cf0023, 0x3f0a3c54, 0x4b223020, 0x40204f0a, 0x53015a22, + 0x64016c11, 0x76017911, 0x761f7911, 0x1e1d0e23, 0x133f0d18, 0x1302134f, 0x47170d13, 0x0f030c06, 0x1c200505, 0x1c401c30, 0x47181c03, 0x0f03051c, + 0x02251f25, 0x20210013, 0x10102009, 0x18095502, 0x05820f0f, 0xecffb825, 0x840d0cb4, 0x40e03308, 0x020b0b18, 0x01092f55, 0x0c1d0009, 0x0304180f, + 0x19820908, 0x091e0326, 0xd0ffb806, 0x23078746, 0x0d1740fc, 0x06271582, 0x020c0c0a, 0x83200655, 0x08062331, 0x0b820909, 0x28059755, 0x172bed33, + 0x5d2f3239, 0x2300822b, 0x5d3c2fed, 0x2e052e4c, 0x123f2f5d, 0x33ed3939, 0x2f5d2f33, 0x54393911, 0xb208055a, 0x11231107, 0x34350026, 0x33113700, + 0x17161611, 0x26262315, 0x36361127, 0x11053337, 0x14150606, 0x47600416, 0xe37668b4, 0x0b01fbfe, 0xba6876dd, 0xae370b41, 0x33ad7873, 0x8727fe0b, + 0x1e4a98a2, 0x9dfe032f, 0x01156701, 0x01f2fa20, 0x6301162b, 0x2c03a1fe, 0x522ccb1f, 0x0ab9fc09, 0x03852955, 0xbdd21442, 0x0100d2b5, 0x00008900, + 0xee058b04, 0xba002100, 0x1d205c40, 0x1d321534, 0x151e0303, 0x411e251e, 0x5b0e530e, 0x730e6316, 0x090e7302, 0x4605181b, 0x081f080f, 0x0803084f, + 0x49141010, 0x020c0108, 0x014a2002, 0x1f230f08, 0x021f0223, 0x830e1b18, 0x201b3ff4, 0x06190508, 0x1905060f, 0x2002040f, 0x02004000, 0x0e020000, + 0x55020f0f, 0xf2ffb802, 0x23831140, 0x091c0223, 0x230f8209, 0x060f0f14, 0xe4231583, 0x840d0db4, 0x57f22008, 0x0223053f, 0x82090918, 0x0531410f, + 0x182b2b21, 0x31085567, 0x2bfd332f, 0x5d391132, 0x32fd3f00, 0xed39123f, 0x91442f33, 0x015d2e06, 0x3521215d, 0x23353636, 0x34113335, 0x0b446c12, + 0x21113d08, 0x14152115, 0x21150706, 0xfefb8b04, 0xb0b06776, 0x9869cdfd, 0x983e0a40, 0x018b8c56, 0x7c61fe9f, 0xcf450362, 0x8ab9bd20, 0x01c83601, + 0xce112201, 0x90a5302a, 0x3d8addfe, 0x0b39bb7e, 0x8e08bc82, 0x047ffeac, 0x00ef0568, 0x00610043, 0x057f40a9, 0x14270a05, 0x3e271d05, 0x4d423020, + 0x43204f10, 0x5c424032, 0x51165e10, 0x6e096332, 0x632b6a10, 0x05521132, 0x255f205f, 0x2d5b275f, 0x4250395b, 0x206a1f6b, 0x40653d65, 0x097c4261, + 0x2b74107c, 0x7b103174, 0x025f7450, 0x505f0718, 0x2f063a29, 0x3733330d, 0x11022f3f, 0x0f3f1511, 0x020d1f0d, 0x5f1b180d, 0x33075604, 0x26501b3a, + 0x1a471129, 0x07332911, 0x00102204, 0x56000001, 0x822f221a, 0x125d27f4, 0x2fed3917, 0x0483392f, 0x05821220, 0x5d2f0026, 0x3f2f32fd, 0x11200382, + 0x5d201982, 0x08915118, 0x011e1522, 0x814ef983, 0x33353705, 0x3233011e, 0x26343536, 0x27012e27, 0x35262726, 0x35373634, 0x0683012e, 0x2305934e, + 0x012e2315, 0x2805074d, 0x17011e17, 0x03161716, 0x841d823e, 0x2331822e, 0x0e07010e, 0x16204e82, 0x1e821b83, 0x013ecb08, 0x63766804, 0x41425861, + 0x577cc248, 0x4f0a5ca7, 0xa2866cb4, 0x90292d27, 0x5352d652, 0x54656672, 0xc7404340, 0x5ba85780, 0x79bd3a0a, 0x2b2ba97f, 0xc85b842b, 0x1cf7595a, + 0x1c1d211e, 0x5d272c4e, 0x163e1246, 0x1d1f2618, 0x262c511b, 0x42144360, 0xa26a5902, 0x912e0737, 0x328a4d5a, 0x1f1b3638, 0x613225c2, 0x19413857, + 0x34142517, 0x62815151, 0x300739a9, 0x83515992, 0x1c3a3234, 0x3c1bc21d, 0x4739575c, 0x15251717, 0xfe4f4f2e, 0x3a4121ab, 0x18174633, 0x150b0c1f, + 0x182d0914, 0x3231561a, 0x20171846, 0x13180a0b, 0x00002f0b, 0x01b90001, 0x04a40321, 0x000b000b, 0x0303b713, 0x06000009, 0xf6100c88, 0x2f002f32, + 0x88442f33, 0xa4032b0d, 0xdb9a9adc, 0xdc9a9adb, 0x07849602, 0x82dbdb21, 0x8930083f, 0x520495fe, 0x0d00d105, 0x24403b00, 0x08610853, 0x050f0102, + 0x064f0501, 0x02060601, 0x0f030caa, 0x020f1f0f, 0x04042905, 0x0d0f2902, 0x090d0d01, 0x5d275782, 0xed2f33ed, 0x823f005d, 0x2f5d2906, 0x30313c5d, + 0x1123015d, 0x2e3f0183, 0x24343501, 0x52042133, 0xce95d694, 0xf30401fc, 0x95fed201, 0x46f9ba06, 0xf805bc03, 0x82e8cfcc, 0xb951086f, 0x8d04e8ff, + 0x36001e06, 0x4140e600, 0x2e152e05, 0x342c132e, 0x34391339, 0x0e493637, 0x21533646, 0x1b7b2166, 0x1433340c, 0x3c1e153d, 0x002d0315, 0x3d0b0707, + 0x08260903, 0x34301b18, 0x060c1400, 0x0602061c, 0x06001b11, 0x25033014, 0xf6ffb800, 0x06fb57b4, 0x1640f633, 0x55020b0b, 0x25389000, 0x020c0c0c, + 0x090c2555, 0x21058209, 0xf848261a, 0x25088207, 0x0f0fb4e0, 0x08825502, 0x82052648, 0x06da6408, 0x2c842620, 0xe8200f82, 0x06202182, 0xeb202183, + 0x08845782, 0x4259fc20, 0x06262305, 0x0f820909, 0x4b378821, 0x2b20063d, 0xed230082, 0x18102b2b, 0x27086a5e, 0x39122f5d, 0x3f00ed2f, 0x098e5718, + 0x31393928, 0x015d0130, 0x57180014, 0x3628098c, 0x35363637, 0x35232634, 0x2a05b042, 0x22232626, 0x06060706, 0x6e231115, 0x6b0808b6, 0x07061415, + 0x04161615, 0xdbf1fe8d, 0x0a24732c, 0x4a38632a, 0x1f23216e, 0x9a9dc6d3, 0x581b1e16, 0x285c393d, 0x48bc2d25, 0x5eb33c40, 0x718ee5b7, 0xe101bea4, + 0x0fddfed6, 0x1218a50d, 0x7f34313a, 0x96a9a64c, 0x42238177, 0x1d231d1f, 0x5f842427, 0x3804c1fb, 0x3a3eb77c, 0x7097ae3b, 0x250920b2, 0x040000df, + 0x2eff9f00, 0xf0056107, 0x0805d546, 0x0037006e, 0x7c7a40ad, 0x70117c0d, 0x7a177013, 0x7327741a, 0x1a0d0736, 0x1a1e2304, 0x28142312, 0x10230e2c, + 0x162c1422, 0x23241821, 0x2336193f, 0x22471949, 0x0e6b1852, 0x14641064, 0x196a166b, 0x2a191a15, 0x29182818, 0x2825252a, 0x2a1b3118, 0x1d101d00, + 0x18031d4f, 0x90011d00, 0x0c1d011d, 0x00061dad, 0x06ad1200, 0x31aa1a28, 0x40191e31, 0x22081382, 0x151eaa30, 0x091e1d50, 0x500f0303, 0x3f000209, + 0x122f33ed, 0x2fed3939, 0x3c5d2fed, 0xed2f3912, 0x842f0139, 0x260f8212, 0xfd5d3371, 0x82392f3c, 0x10873014, 0x3031c0fd, 0x5d005d01, 0x21001001, + 0x84110020, 0x8a032005, 0x23072a0b, 0x23112301, 0x16322111, 0x05214417, 0x26343734, 0x2b012e27, 0x32331101, 0x013e3736, 0x05fe6107, 0x01829afe, + 0xfb010524, 0x01826601, 0xfe74fb25, 0x82cafe49, 0x01492401, 0x823601b7, 0xc0b73e01, 0xa2b5fedf, 0x5e3801a5, 0x3b3f3b7a, 0x1c206371, 0x35461f21, + 0x5a3e7f95, 0x02191f1d, 0x833a8b8f, 0x2231824a, 0x8444febc, 0x44200841, 0x0182bc01, 0x039dfe63, 0x221f1093, 0x81614961, 0x3824fd26, 0xfe0a1112, + 0x191713cb, 0x0300003c, 0x240c7341, 0x40960033, 0x0771416d, 0x72197924, 0x65410623, 0x18333707, 0x2a332433, 0x18442e33, 0x2a442441, 0x18542e44, + 0x2a542454, 0x6f412e54, 0x18623207, 0x24641d6a, 0x187f2517, 0x2a2c1801, 0xad0c1e18, 0x055e411e, 0x20331037, 0x33330233, 0x1f1b522f, 0x02252f25, + 0x52292525, 0x1b501521, 0x10644121, 0x2f32fd24, 0x04832f5d, 0x24086441, 0x5d2fed33, 0x1d5a413c, 0x010e0528, 0x35242223, 0x82460034, 0x07504505, + 0x36323324, 0x56413337, 0x72fe3922, 0xe34e9f56, 0x0d01f8fe, 0x3eac59de, 0x59a93610, 0x94999f8e, 0x10489d53, 0x081f5441, 0x2727574c, 0x01e1eaf6, + 0xb51c3002, 0xa5ab4628, 0x343aae9f, 0xaa000200, 0xf1061103, 0x0e00d105, 0x5f001600, 0x047b2340, 0x067a0578, 0x79020603, 0x0c0b010c, 0x0403010d, + 0x15080806, 0x13101212, 0x0d031550, 0x370f0b28, 0xc4ffb80b, 0x08821140, 0x28023608, 0x28070000, 0x10ae0f09, 0x13ae1428, 0xe4fde42f, 0x2f33ed2f, + 0x002b2bed, 0x333cfd3f, 0x3917122f, 0x5854435d, 0x6d045db4, 0x595d0204, 0x5d003031, 0x23112301, 0x27018203, 0x33112311, 0x0533011b, 0x36080e82, + 0x21352311, 0x147cf106, 0x19ef4fed, 0xbfbfee7b, 0xe502fce3, 0x4902e57f, 0x69021103, 0xca013dfe, 0xc00290fd, 0x7e0182fe, 0x02b5fd75, 0x0100754b, + 0x16051d02, 0x7806c303, 0x4727068b, 0x66005601, 0x78007600, 0x0937198b, 0x03132301, 0x95effec3, 0xfe8c06b3, 0x0076018a, 0x055a0102, 0x4dbe0318, + 0x26340641, 0x06021540, 0x05600144, 0x14000501, 0x0101010f, 0x00011404, 0x29057657, 0xed5d2fed, 0x3c5d2f00, 0xce4c3cfd, 0x03510809, 0xfec7c7be, + 0x05c7c763, 0xc3c3c318, 0x00010000, 0x051b00f5, 0x00fd0497, 0x40880013, 0x01121654, 0x07080b0c, 0x110e0304, 0x0d020112, 0x02900280, 0x02b002a0, + 0x03290204, 0x0d030c03, 0x04120103, 0x0e110753, 0x070d5308, 0x0b010b0f, 0x30011540, 0x257f8215, 0x0b080704, 0x17821201, 0x09262282, 0x04100d03, + 0x12492f06, 0x06402505, 0x5d2f0601, 0x2407da48, 0x5d391712, 0x2590825d, 0x39ed3333, 0x03822f39, 0x7b2f3221, 0xfd2305a7, 0x82c0875d, 0x82102000, + 0xc0c02b03, 0x21015d01, 0x21132303, 0x03842135, 0x03333e08, 0x03211521, 0xfd970521, 0x689968a0, 0xda0157fe, 0x02d2fd54, 0x6999695e, 0x24feab01, + 0x012f0253, 0x01b1fe6a, 0x0c019c4f, 0xfe4f019c, 0xf4fe9cb1, 0x00020000, 0x0700000e, 0x00d1056d, 0x08d7820f, 0x2f40ea36, 0x060b0304, 0x051b041b, + 0x052b042a, 0x044a063b, 0x064d054a, 0x120b124d, 0x14040313, 0x75060505, 0x02067c05, 0x060e100a, 0x55020c0c, 0xb801140e, 0x0bb4f6ff, 0x25053a6a, + 0x0f0fb4f4, 0x11825506, 0x0b40ea24, 0x09820d0d, 0x0c0c0a22, 0xec200f84, 0x2a05e75b, 0x06731501, 0x040b0801, 0x6dffb800, 0x0020063e, 0x2007f560, + 0x078d46d6, 0x40e72208, 0x020f0f1b, 0x101c0055, 0x40550210, 0x00000100, 0x0501050f, 0x34031464, 0x0a350d13, 0x40c0ffb8, 0x081f8313, 0x130a0a23, + 0x12350805, 0x0e030634, 0x08050135, 0xed3c3f00, 0x12eded3f, 0x2b2f3939, 0x30ed2fed, 0x5df61001, 0x05534b32, 0x39172b23, 0x05374ae6, 0x392bed37, + 0x5d303139, 0xc0fd1087, 0x5d01c0c0, 0x21112121, 0x21012303, 0x06807c15, 0x23110133, 0xfc6d0703, 0xd4f4fd50, 0x055202cf, 0x0213fd0d, 0x270383ed, + 0xefdb50fc, 0xd4fd2c02, 0x072f5318, 0x23027f08, 0xa7fd5902, 0x73000300, 0xda056eff, 0x1d004b06, 0x37002a00, 0x7640fe00, 0x0b000302, 0x120c0d0a, + 0x1c051a0f, 0x0d190311, 0x1a1f121f, 0x02551c15, 0x085a0454, 0x11590d59, 0x1750135b, 0x2a791c55, 0x03090b14, 0x1f1b0618, 0x110b1f0a, 0x261b1618, + 0x752f2709, 0x7f097f03, 0x7f0b7f0a, 0x7012790c, 0x70197018, 0x131b701a, 0x2f2a0206, 0x32042e1e, 0x090c3421, 0x06041b18, 0x34320215, 0x13840a06, + 0x152b2723, 0x21148400, 0x1d68000f, 0xb4e6250a, 0x55020909, 0xe2231182, 0x840c0cb4, 0x070b6408, 0x0f39732c, 0x390f0139, 0x393f391f, 0x47182703, + 0x06200dd0, 0x0f252a83, 0xf6103868, 0x051b562b, 0x0782e420, 0x17112b25, 0x82ed1039, 0x3f002704, 0x17123fed, 0x0a82fd39, 0x58544337, 0x510ab04b, + 0x06094058, 0x161a0f0a, 0x0a1a031a, 0x595d2e2e, 0x065e4a59, 0x77070221, 0x072605b5, 0x02261323, 0x62183435, 0x3725079e, 0x12160333, 0x08b04701, + 0x17161428, 0x27263401, 0xca771601, 0x05ec0806, 0x5c5963da, 0xc973a1fb, 0xcd849f4f, 0x5c606d65, 0x9a050158, 0x8e52c276, 0x6f65bc84, 0x90396ffe, + 0x42b46e59, 0x3a3b4540, 0x3a3c5c03, 0x913c68fd, 0x3eb76e59, 0xe8024243, 0x61ddfeb8, 0x373a6665, 0x642601e4, 0xb6c42c01, 0x62672101, 0xc9373768, + 0xfe64f4fe, 0x2e3a01d7, 0x4c4e4d2d, 0xe08c93e5, 0x8bb8014c, 0x43fc4be4, 0x4c502e2d, 0x0000e152, 0x00a10003, 0x045f079d, 0x0017007c, 0x00350026, + 0x05544072, 0x15310816, 0x292f1926, 0x3b2c2623, 0x4b1c4434, 0x56025134, 0x5f0a5f07, 0x51135a0e, 0x55185916, 0x6d026330, 0x6916630a, 0x64246c23, + 0x182d642c, 0xaf33af21, 0x0f120603, 0xaf2a0909, 0x0f15af1b, 0x3074187b, 0x002a2702, 0x000c1830, 0x2a1e3799, 0x1036990c, 0xe410edf6, 0x10393911, + 0x2f005ded, 0x33eded3c, 0x3939122f, 0xd9480782, 0x23022a05, 0x0e272622, 0x02222301, 0x059c4c35, 0x33013e25, 0x46051232, 0x3e2c0b1d, 0x26342501, + 0x07062223, 0x1e07010e, 0x30081d82, 0xf55f0736, 0x45de85cf, 0xbf8fd34f, 0x86cafae2, 0xd54f44de, 0xfce2bf8d, 0x60b83f68, 0x777f9c8a, 0x22397c6e, + 0x800c0325, 0x4a815876, 0x3c13331e, 0x081582bb, 0xef97023f, 0x9299f5fe, 0x0f019497, 0x0c01eed6, 0x9596919a, 0x7594f1fe, 0x859aa775, 0x395e61a6, + 0xa5860147, 0x67307847, 0xa677732c, 0xd7000100, 0xb505b300, 0x0f00b605, 0x29404500, 0x0f54030e, 0x08008201, 0x54040d27, 0x070aac08, 0x0111400c, + 0x11401130, 0x0aab0002, 0x0d010d80, 0x0501042a, 0x044007ab, 0x5d2f0401, 0x103cf43c, 0x220582fd, 0x823c5d5d, 0xfde42bea, 0x5d2f323c, 0x30313cfd, + 0xff7e2125, 0x06096305, 0xb505212b, 0x1c0222fb, 0x1c02e4fd, 0x080685a6, 0x019eb332, 0x21029ea6, 0xfe9edffd, 0x0002005a, 0x050000fe, 0x00710580, + 0x000a0006, 0x2c0b4063, 0x02290126, 0x02390136, 0xffb80004, 0x0b2440e2, 0x1e033718, 0x09330482, 0x03030854, 0x010c4000, 0x0c400c30, 0x09040502, + 0x1801040a, 0x450c2460, 0x33280539, 0x2bed2f2f, 0x5d30312b, 0x19256018, 0x01350126, 0x11010115, 0x0529a682, 0x047efb80, 0x0387fc82, 0x29078379, + 0xe3012f01, 0xb7e3017c, 0x018296fe, 0x00a01a26, 0x0c010200, 0x8e209b82, 0x65209b86, 0x00289b83, 0x00360629, 0x01040639, 0x26209b83, 0x05209682, + 0x05229b86, 0x9b880105, 0x9b850320, 0x0cd85f18, 0x5f189d93, 0x9d8214d9, 0x9d840282, 0x7efb8e28, 0x87fc7903, 0x9d838204, 0xfe12032d, 0x6a01b71d, + 0xfeb76a01, 0x8272fc1d, 0x0001389d, 0x0400006c, 0x00d105a7, 0x407f0018, 0x17161743, 0x15141618, 0x82151414, 0x150c2e03, 0x170c0e12, 0x17010018, + 0x00141801, 0x31028201, 0x0001004f, 0x09010804, 0x0c0f1406, 0x0f510c09, 0x15821006, 0x02132008, 0x10100551, 0x00180b15, 0x0b031516, 0x3f3f0008, + 0x11c0d0c0, 0xc02f3912, 0x3912c0fd, 0x82dd1039, 0x83012007, 0xddc4300c, 0x875dd6c0, 0xc100102b, 0x107d0587, 0x821801c4, 0x10c6261a, 0x2b1087c4, + 0x250e8208, 0x01013031, 0x01862115, 0x21352322, 0x01300186, 0x04010133, 0x0140fea7, 0x018efe74, 0xbc8efe72, 0x0e820685, 0x01d43d2f, 0x0550014c, + 0x2fb6fcd1, 0xba8a8a8a, 0x260482ba, 0xfd4a032f, 0x8293026d, 0xbe2508a5, 0x640464fe, 0x15005d04, 0x1140e100, 0x14050208, 0x4210050b, 0x08000905, + 0x02010c0a, 0xf4ffb813, 0x020909b4, 0x22088355, 0x820c0cb6, 0x001a2c08, 0x40e6ffb8, 0x0210100b, 0x441e0055, 0xfa2006ff, 0x21075746, 0x286db4e2, + 0x40e92f06, 0x0609091c, 0x17920055, 0x1760171f, 0xf0680d02, 0x830c2006, 0x1a092330, 0x1169b80a, 0x28088206, 0x0f0b40e0, 0x0a55020f, 0x8266830c, + 0x05b36b0f, 0xee200882, 0x08825484, 0x5484f120, 0x06211186, 0x20088255, 0x05f44cf3, 0x830a0a21, 0x880a2263, 0x0af44c16, 0x2b2bfd24, 0x25705d3c, + 0x230b8206, 0x3f003939, 0x2506c564, 0x21303139, 0x3d452723, 0x23112305, 0x027e3311, 0x37810805, 0x64043311, 0x813b0ab2, 0x427f565b, 0x9b20bcbc, + 0x36855d5b, 0x4a4176bc, 0xf3fd4046, 0xbafcf905, 0x3c435227, 0x00004003, 0xff950002, 0x057904e0, 0x002200ef, 0x40660031, 0x15021548, 0x292e161b, + 0x311b2404, 0x411b350a, 0x561b430a, 0x561a550a, 0x5620501f, 0x661a642a, 0x632a641e, 0x701b752e, 0x060f142e, 0x0c0c3f26, 0x19191d06, 0x021d3f15, + 0x0a063f2c, 0x29230f1a, 0x091a1412, 0x14290000, 0x064b4c09, 0x39391126, 0xed3f002f, 0x23054e50, 0x12ed2f39, 0x5d29af82, 0x07021401, 0x2223010e, + 0x06da4a26, 0x35013e22, 0x2105ae44, 0x3c503523, 0x011e2205, 0x0dce4403, 0x79049508, 0xcb55524e, 0x01f3c071, 0x9f5aca0d, 0x9e02024f, 0x4eb74e98, + 0x60c9510b, 0x2a3ecd89, 0x983ccb1d, 0x87a88d48, 0x22a38070, 0x45030b06, 0x7b98fea4, 0xcbfd627c, 0x342101e4, 0x1a3b1a41, 0x373fcad9, 0x6d2d2cc2, + 0xfece567c, 0xb6362fc4, 0xc29991aa, 0x005021be, 0xbb000100, 0x590543ff, 0x0c00d105, 0x6a40a900, 0x080f0301, 0x038b0b45, 0x0bd303d9, 0x01080106, + 0x32032b0b, 0x5d0b3208, 0x600a6603, 0x0203080b, 0x08090803, 0x040304b3, 0x0b0a0b03, 0x030202b3, 0x03251192, 0x0a010a61, 0x08238207, 0x040a072f, + 0x020c0c02, 0x0a0a0903, 0x0901096b, 0x04020204, 0x0b040903, 0x03053508, 0x000b3501, 0xed3fed2f, 0x2f391711, 0x335d2f2f, 0x0139122f, 0x8705822f, + 0x30312d0e, 0xed7a1087, 0x8701c087, 0x0887ed10, 0x0d8b0683, 0x715d2d08, 0x09352105, 0x15213501, 0x01150121, 0xfb590521, 0xfda10262, 0xfc6d0469, + 0xfd880285, 0xbdb40366, 0x029c02bf, 0xfdb0bc77, 0x73fd48a7, 0x9024e383, 0xfc053fff, 0x0b3ae382, 0x12408700, 0x00050703, 0x020a3509, 0x097f0070, + 0x00140402, 0xffb8015a, 0x7b49b4f2, 0x40de2a06, 0x060d0d1d, 0x0c080155, 0x3405820c, 0x0609091a, 0x7f016f55, 0x01010201, 0x0914050d, 0xffb8085a, + 0x822a84e0, 0xb4e72108, 0x08822983, 0x83b4f621, 0x2208822c, 0x830c40e6, 0x08002730, 0x08700860, 0x41490803, 0xede42305, 0x09873311, 0x3f005d29, + 0x2f3c3cfd, 0x4e30313c, 0x11350531, 0x35231123, 0xc8fc0521, 0xc6b0fdc6, 0x056c05c8, 0x051cfa23, 0x300383e4, 0x000100ae, 0x05000071, 0x005d0441, + 0x4077000b, 0x26b5840d, 0x04050a3e, 0x82b0001a, 0x84ee20b0, 0x20088285, 0x828584fa, 0x40dc2208, 0x20b38412, 0x83828306, 0x091a22ae, 0x439382b0, + 0x088205b9, 0x554afa20, 0x0b082105, 0xee21ac86, 0x222883b7, 0x8b010810, 0x822b20a7, 0xede42100, 0x412ca595, 0x3cfebcca, 0xd004cabc, 0x41fcbf03, + 0x9e200385, 0x2708a582, 0x0459fe8a, 0x001e0690, 0x40520021, 0x04000018, 0x11001e40, 0x0d401511, 0x1f230f0d, 0x10000223, 0x101a0900, 0xedffb819, + 0x0882b084, 0x8785d820, 0x831c1921, 0x780f8287, 0x1921054b, 0x2479822f, 0x32fd332b, 0x07d2772f, 0x312f0a82, 0x26230130, 0x07222326, 0x14111506, + 0x7b230607, 0x35080888, 0x11353637, 0x33363734, 0x04171632, 0x73200a90, 0x35348120, 0x34bc6968, 0x210a316d, 0x3581226c, 0xbd686834, 0x0536663a, + 0x3d150857, 0x9dfb953d, 0x0b6e6dce, 0x0c84b20a, 0xcc630423, 0x080c826f, 0x02000052, 0x13029700, 0xf005b003, 0x30002300, 0x37405700, 0x21060a0a, + 0x2116091b, 0x2125092e, 0x0e602955, 0x0e702960, 0x020b2970, 0x11522508, 0x1c082011, 0x2053181c, 0x2e010102, 0x1d060853, 0x2a022511, 0x2b000b1d, + 0x2f0b002a, 0x122fed33, 0x3232fd39, 0x43051e6c, 0x01250ce7, 0x3523015d, 0x06b4620e, 0x20051954, 0x05315437, 0x06222323, 0x06eb4307, 0x85031521, + 0x15560822, 0x32331614, 0xaab00336, 0x2d2c311c, 0xaf804951, 0xef4e4d5d, 0x22212488, 0xa8543057, 0xb82d0e27, 0xaabed94d, 0x4036b745, 0x525e5b4e, + 0x5e2a0283, 0x14132514, 0x6a84aa15, 0x1f242487, 0x40351206, 0x300a1213, 0x200dac0e, 0x74fe9fa9, 0x0f1004f5, 0x4c444d12, 0xe983434c, 0xe9827920, + 0x7751e420, 0x31220806, 0x015d2040, 0x0752055d, 0x6a040b52, 0x0215650f, 0x0209530f, 0x06035315, 0x00402a0c, 0x2a120001, 0x79630600, 0xed3f2a06, + 0x315ded3f, 0x14015d30, 0x076a4902, 0x56581220, 0xe427080c, 0xedc9c1f4, 0xf4c1c9ed, 0x7a7887b6, 0x787a8686, 0xeb010487, 0x0901fdfe, 0x0a01e5e5, + 0xacebfcfe, 0xaaaaaeac, 0x8200abad, 0x006b2456, 0x82210600, 0x27410881, 0x4940f100, 0x0d090909, 0x0d1a091a, 0x0d2c092c, 0x05300334, 0x13341130, + 0x13460346, 0x1d641a6a, 0x246a2164, 0x14251910, 0x0b160402, 0x26021f34, 0x16013518, 0x02122508, 0x02101016, 0x0f0c0255, 0x2105830f, 0x05820d0c, + 0x14121927, 0xb4f4ffb8, 0x8417820f, 0x82148308, 0x40f82e08, 0x0209090c, 0x15081455, 0x271c1402, 0x21228222, 0x35831140, 0x0d2e2222, 0x22253582, + 0x020c0c1a, 0x22158355, 0x840b0bb4, 0x69e02008, 0x222905f3, 0x150e2922, 0xffb81c17, 0x825184ea, 0x05a74608, 0xf6200882, 0x21056457, 0x3183041c, + 0x83081c21, 0x2f1c225d, 0x2300832b, 0x3311edc4, 0x12230986, 0x83ed3939, 0x3104850a, 0xfd3c3f00, 0x12ed3f3c, 0x30313917, 0x1121215d, 0x73183636, + 0xe4610811, 0x11172805, 0x35213521, 0x52350226, 0x20080547, 0x15070214, 0xfd210621, 0x2d8443a4, 0xe2f8382f, 0x2f3af8e2, 0xfd447f2f, 0xa8b401a4, + 0x017201d9, 0x08018236, 0xa8d972cb, 0x8501b401, 0x3a375a27, 0xfdc87099, 0x9e6ec8fd, 0x27573938, 0x7cae7bfe, 0xcc320158, 0x5a011601, 0xeafea6fe, + 0x58cefecc, 0x0003007c, 0x07e3ff68, 0x007c043f, 0x00430039, 0x40530152, 0x0b190b73, 0x26191c1d, 0x360d2004, 0x380d3204, 0x4241343d, 0x4a0d4204, + 0x5241423d, 0x5537520d, 0x610d634b, 0x134b6537, 0x2a4b1d16, 0x2e622e51, 0x137e0d7b, 0x247d1e7c, 0x38732e73, 0x470b4b7c, 0x70213c01, 0x12430143, + 0x30033343, 0x363d4018, 0x282c2c04, 0x0b04303f, 0x0f3f070b, 0x1841500a, 0x013a430a, 0x1244471a, 0x00043321, 0x012d0f47, 0x3a0c0c2d, 0x40f6ffb8, + 0x020c0c0e, 0x001a3a55, 0x10100c47, 0xb8475502, 0x0fb4ecff, 0x2308840f, 0x0d0db4e0, 0xec200884, 0x47232485, 0x820b0b0a, 0x1b2d260f, 0xf8ffb800, + 0x822d83b4, 0x84ee2008, 0x2208822d, 0x830b40d6, 0x4a45182e, 0x41f22008, 0x002605b7, 0x5440548f, 0x31824d01, 0x1e83b720, 0x001b4d28, 0xfaffb81b, + 0x3e831f40, 0x830c1b21, 0x1c1b2750, 0x55020909, 0x1e83141b, 0x83061b21, 0x851b228d, 0x06594853, 0x2bed3226, 0x2be4105d, 0x11220083, 0x07843939, + 0x2bed1031, 0x5d2f2f33, 0x3917122f, 0x3911fd2f, 0x18ed3f00, 0x22074964, 0x8311ed3f, 0x335d2314, 0xb44d32fd, 0x63212005, 0x152009af, 0x20057f48, + 0x43481806, 0x3636281f, 0x15123233, 0x82262627, 0x22232702, 0x26030706, 0x48183526, 0xaf080a52, 0xcdfc3f07, 0x8e34373c, 0x42d56f56, 0x6dd54e0c, + 0x154ceda6, 0x943f325c, 0x6cd39673, 0x24015f65, 0x28292ea2, 0xb34f3c70, 0xce370d5a, 0x39d39f65, 0xd97dca45, 0x2505b6fb, 0x4f6d2220, 0x9119b485, + 0xc0691514, 0x74614f52, 0x02c16376, 0x34a2722f, 0x34532d30, 0x683b23cd, 0x1c501367, 0x98c22f24, 0x272a997c, 0x413d031c, 0x11171755, 0x0fbf242a, + 0x525b5d26, 0xfb00ff68, 0x2566443e, 0x8c962c27, 0x84356bfe, 0x1509034b, 0x5f535b14, 0x0300565c, 0x6cff5d00, 0xd9047104, 0x21001700, 0xef002b00, + 0x08003f40, 0x190a140f, 0x00042629, 0x02250018, 0x09210484, 0x3e068314, 0x2b321d3d, 0x2b421d4d, 0x21020607, 0x04251826, 0x063e1b29, 0x04151209, + 0x29040f03, 0x840a033e, 0x221e2913, 0xb4f8ffb8, 0x55020909, 0xf4240882, 0x0c0c1440, 0x1b230982, 0x82060900, 0x7b0c2027, 0xae77054f, 0x103f250d, + 0x00550210, 0x2c05587e, 0x2d0f2d90, 0x2d3f2d1f, 0x1e042d6f, 0x21438304, 0x3f830c1e, 0x0c1b1e29, 0x020b0b16, 0x83180c55, 0x080c2113, 0x0c231383, + 0x820d0d04, 0x2c852111, 0x2105e641, 0xe5412bed, 0x17112307, 0x0d821039, 0x2a12994f, 0xb558510c, 0x13391308, 0x4f2e1302, 0x5d2d0594, 0x015d015d, + 0x22230010, 0x23072726, 0x086e6213, 0x07333727, 0x26251616, 0x06d95926, 0x08098d4f, 0xfe7104a7, 0x8f54ebe8, 0xab6e853b, 0x1701534b, 0x368e57ed, + 0x4c9b6f74, 0x25bcfe54, 0xaa9b3763, 0x44022322, 0x40fe2223, 0x963b5f27, 0xfe2e02ae, 0x2ac4feef, 0x0001c627, 0x0193e24d, 0x2c3d0111, 0x4ce7ac23, + 0x1d1ddce0, 0x9461d2dc, 0x612b0136, 0x61fd3698, 0x00d91e1f, 0x71000200, 0xbe03e2ff, 0x0300d105, 0x6d002000, 0x220f4c40, 0x1302221f, 0x3a1e231e, + 0x4b143a05, 0x400d4005, 0x430f400e, 0x52055c16, 0x65056f0f, 0x7a1a650e, 0x10097a05, 0x01137f12, 0x12071013, 0x03035501, 0x341c2020, 0x2b020a07, + 0x1f100303, 0x2f168270, 0x04200a13, 0x15190401, 0x332f0a04, 0x125d2fed, 0x2905c966, 0xfd3f00ed, 0xed3f2f32, 0x6c181233, 0x23230987, 0x4a133335, + 0x362806a7, 0x37013e37, 0x0e113335, 0x0806b85a, 0x3632333b, 0xc8023337, 0x53f6cccc, 0xf9d770ba, 0x9d3a3b45, 0x9e3cb344, 0x9944362e, 0x39c56779, + 0xd3fe040a, 0x281e57fa, 0x9662abd1, 0x29653e3e, 0x21cffee1, 0x7c2f2861, 0x426f714e, 0x21d58225, 0x04822301, 0xd5840320, 0x27000727, 0x07071740, + 0x38a98200, 0x090f0805, 0x035d0401, 0x0f5d052b, 0x02022002, 0xe45d2f02, 0x005de4fd, 0x2096823f, 0x055a542f, 0x1323132b, 0xccf90133, 0x1ae00acc, + 0x326383aa, 0x0037042f, 0x00d20001, 0x02b00539, 0x000500fa, 0x82184029, 0x0f542159, 0x402ae182, 0x07300107, 0x01020740, 0x2282402a, 0x2f040028, + 0xed5d2f33, 0xdf5b5d5d, 0x30313205, 0x21112325, 0xb0052135, 0x04cdfbab, 0x210239de, 0x082482a0, 0x69ff8629, 0xfc06c906, 0x4a000800, 0x07152c40, + 0x07440733, 0x07040772, 0x14060807, 0x02030203, 0x29080907, 0x69085908, 0x82080408, 0x0101352c, 0x51030400, 0x08070606, 0x2f000802, 0x3939122f, + 0x2f01ed2f, 0x8d086582, 0x10873031, 0xc0c05ddd, 0x08fd1087, 0x095d00c0, 0x23012301, 0x01092135, 0x90fcc906, 0xed80fe66, 0x39018901, 0xfc06da02, + 0xe1036df8, 0x06cbfc8b, 0xff01005c, 0x0537ffdc, 0x00ef0500, 0x4077002b, 0x000b074d, 0x27082e1f, 0x2e0f270c, 0x35252921, 0x400f300d, 0x590f410e, + 0x66076622, 0x0b0c0e0c, 0x1d200708, 0x1d22211e, 0x1f2d0f22, 0x2009022d, 0x09221d20, 0x16001604, 0x461e080b, 0x12282121, 0x49040000, 0x16160228, + 0x1200491a, 0xcf5c1201, 0x22a1820b, 0x82303939, 0x17122ba4, 0x5d2f2f39, 0xc0c01087, 0x0382fdc0, 0x01303124, 0xb05c015d, 0x010f2605, 0x03211521, + 0x06b5480e, 0x5c352721, 0x372505e8, 0x33352313, 0x08706b37, 0x00058608, 0x29721d0a, 0x2a237e79, 0xa3fe4101, 0x405c1d67, 0x295c9841, 0x210a3450, + 0x817f2c5e, 0xf5d96723, 0x3e5c1a2a, 0x3a57993e, 0x2905344f, 0xa0771a0a, 0x16fe8ac2, 0x3534b086, 0xb409072a, 0xa780140e, 0xc68aea01, 0x3333a87b, + 0x00080a2c, 0x00f30002, 0x049805ca, 0x00190050, 0x406d0033, 0x06010a49, 0x080e0506, 0x061b0a13, 0x08280520, 0x52045b2d, 0x521e5b11, 0x640b682b, + 0x740b7932, 0x27271032, 0x1a1d5430, 0x08038223, 0x012a002e, 0x160d0d2a, 0x09000354, 0x00032a54, 0x00291910, 0x1a293300, 0x260d290c, 0x2f271a29, + 0xed3ced33, 0x2f33ed2f, 0x332f00ed, 0x2fed3333, 0x2f210b83, 0x2309875d, 0x015d3031, 0x6c0e516c, 0xf942094e, 0x096b6c05, 0xae081989, 0xb6149705, + 0x388c4d9e, 0x4b2c6841, 0x179b1c54, 0x8e489fb3, 0x2d6b3d3b, 0x9e13594c, 0x48a3ae19, 0x80273990, 0x14564e2e, 0x9eb7139d, 0x233a8a4d, 0x544b367c, + 0xc250041b, 0x342d4bc6, 0xb67c6037, 0x302e4ac4, 0xfd7d6d3b, 0x4bc3b8fc, 0x6e4c1f2d, 0x4ac8c07c, 0x634f1c2e, 0x0002007a, 0x05000032, 0x00d1059e, + 0x00060003, 0x4831404f, 0x02034702, 0x056a055a, 0x1a040502, 0x06030000, 0x0201011a, 0x03360239, 0x0364026b, 0x0375027b, 0x05030206, 0x08000003, + 0x02010501, 0x01540603, 0x3fed2f00, 0x2f013912, 0x172f3311, 0x30315d39, 0x82fd1087, 0x04220802, 0x015d00c0, 0x0101295d, 0x05020921, 0x0294fa9e, + 0x01080132, 0xfe50fe27, 0xfad10551, 0xfb7b04d7, 0x7b820085, 0xa200a639, 0x76047a04, 0x0d000600, 0x10405900, 0x0c730573, 0x0c400402, 0x830b3710, + 0xb8062404, 0x82b3c0ff, 0x820d200c, 0x1b402107, 0x03200882, 0x073ba482, 0x04070a0a, 0x01010005, 0x0b0c0000, 0x01074008, 0x2f080707, 0x125d2f33, + 0x82333939, 0x20068207, 0x24068500, 0x30312f2f, 0x2700822b, 0x01255d01, 0x09150135, 0x0684af82, 0x7a042908, 0x1002f0fd, 0x65019bfe, 0xdafd52fe, + 0x8dfe2602, 0x01bf7301, 0xa20155a3, 0xfeeffebc, 0xbe01d9ef, 0xc4bd0159, 0xdafedafe, 0xae20a183, 0x8220a182, 0x5726a186, 0x037c1040, 0xa18a0a7c, + 0xa1860220, 0x07820920, 0x821a4021, 0x080c2ba1, 0x0505080c, 0x01030401, 0xa1820040, 0x0b0a0123, 0x82a18208, 0x2f3321a0, 0xa7869982, 0x3921a083, + 0x229f8939, 0x82350109, 0x839f8302, 0x82042706, 0x7301dafd, 0x99828dfe, 0xf0fd3c22, 0x2308a582, 0x0210029b, 0xc442fe60, 0x26012601, 0x5743fec4, + 0x01bc5dfe, 0xbc110111, 0x03005efe, 0x0000b200, 0xdf00da05, 0x073d0982, 0x25000b00, 0x01051440, 0x0a040602, 0x00080955, 0x0401012b, 0x0805052b, + 0xed2f092b, 0x27028433, 0x17ed3f00, 0x21303139, 0x2006ff65, 0x24078305, 0xfdccccda, 0x200385d2, 0x200083df, 0x06996eff, 0x02010824, 0x996e0036, + 0x00432d05, 0x00750164, 0x0002b60b, 0x00050e0c, 0x2007f964, 0x2279821a, 0x88c8075e, 0x00d72225, 0x21258633, 0x25890b18, 0xe1ff7324, 0x2584da05, + 0x00003228, 0xd7001701, 0x25868b00, 0x6b243121, 0x5608058c, 0x00020000, 0x08000078, 0x00d1051c, 0x00250016, 0x001a40d0, 0x3022001c, 0x4022301c, + 0x7222401c, 0x720a7204, 0x721d741c, 0x35140b23, 0xc0ffb811, 0x0f0f2340, 0x11115502, 0x10341801, 0x17030d35, 0x01351534, 0x04141108, 0x55020c0c, + 0x04171414, 0x55021010, 0x49ffb817, 0x088205c7, 0xc749f620, 0x12172105, 0x0f822083, 0x0bb4fa23, 0x2421840b, 0x0f0fb4f6, 0x202a8306, 0x822183ef, + 0x0c112209, 0x240f840c, 0x092440fb, 0x2b098209, 0x03120e17, 0x27730007, 0x1207151f, 0x07273383, 0x02090916, 0x83060755, 0x68072e48, 0x2bf61026, + 0x10ed2b2b, 0x391711e6, 0x8509822f, 0x2bfd2502, 0xed3f0032, 0x6e05dd58, 0x212406c4, 0x27242221, 0x21066357, 0xc0583336, 0x11052308, 0x6e182223, + 0x08340a0b, 0xc4cefb1c, 0x9167fdfe, 0x4f98aeb3, 0x2e04e8f9, 0xfb0205fd, 0x86080383, 0x927a40fc, 0x81745fb5, 0xd05b6d71, 0x5b413692, 0xd7cf4601, + 0x33603c01, 0x68feb044, 0x04d7fdb0, 0x36207904, 0xababf842, 0x283944ee, 0x00030000, 0x07e1ff6a, 0x007c0476, 0x002b0024, 0x400c0137, 0x20042657, + 0x3004320d, 0x3b29320d, 0x3230322e, 0x40363b34, 0x400d4004, 0x402e4d29, 0x4d344030, 0x530d5336, 0x5c165c14, 0x531c531a, 0x620d6222, 0x7022621c, + 0x1b22720d, 0x122b3c01, 0x0f032b1e, 0x04213d28, 0x4b1b3f2f, 0x352c0678, 0x1e0a153f, 0x1a012b12, 0xf0ffb82c, 0x2505bd53, 0x0c0c1e2c, 0x0f825502, + 0x0b40fc32, 0x55020b0b, 0x2c012c7f, 0xb8250c0c, 0x1040f8ff, 0x252b1983, 0x182c001a, 0x0f0f0800, 0x82005502, 0x08eb5814, 0x2c83b420, 0xe4241182, + 0x09093340, 0x8f261b82, 0x01393f39, 0x0b830432, 0x830c3221, 0x1b322338, 0x23831618, 0x83181821, 0x08182113, 0x18271383, 0x020d0d04, 0x58851855, + 0x2b2005ff, 0x200a6949, 0x06484b39, 0x2b2b2b25, 0x4b3932fd, 0x3f290947, 0x391712ed, 0x3031ed2f, 0x0b4e1801, 0x6f222010, 0x0021051e, 0x05d96b11, + 0x23082b4b, 0x07062223, 0x080b784e, 0xfc76077d, 0x34343cdc, 0xcd6d528d, 0xbf620c46, 0x4ae8a869, 0xe983d145, 0x1701effe, 0x44c88ce3, 0xe18fd747, + 0x9103b7ec, 0x10af8b8d, 0x9993a4b8, 0x9292a7a0, 0x681b02a5, 0x2f313198, 0x2acd384f, 0x6f687a34, 0x013c0178, 0x01150111, 0x6a727939, 0xeff4fe81, + 0xa49b9b2a, 0xd5d77d92, 0xd7d4cce0, 0x000100d5, 0x043c0299, 0x00dc027d, 0x40180003, 0x0254010c, 0x0f050000, 0x02051f05, 0x185d2f02, 0x290bf855, + 0x1cfc7d04, 0x3c02e403, 0x338500a0, 0x84670721, 0xb6112133, 0x56183285, 0x07250d25, 0x0632f967, 0x282c83ce, 0x03edff02, 0x061603e5, 0x315f8214, + 0xb5520007, 0x100d1802, 0xffb80137, 0x0c09b3e8, 0x07820037, 0x09094025, 0x83063710, 0x86052015, 0x82042015, 0x13402107, 0x012e1582, 0x05010500, + 0x01060205, 0x0202b100, 0x0268b104, 0x333c2107, 0x42054c5f, 0x012405f6, 0x03330123, 0x16250383, 0xf0f1fe86, 0x2c0483ef, 0x2f02e503, 0x2f02d1fd, + 0x00020000, 0x207d8296, 0x277d86bf, 0x0400b950, 0x0e40e8ff, 0x05218182, 0x217e8218, 0x64821806, 0x20208384, 0x01201282, 0x02201283, 0x77851283, + 0x86070321, 0x06002b77, 0x5d2f0601, 0xed2f33ed, 0x7b8d3f00, 0x23010924, 0x03822313, 0xfebf0326, 0xa4a586f1, 0x06210483, 0x85798314, 0x8301207d, + 0x860121fb, 0x2e207d84, 0x0d20f992, 0x0123e384, 0x83020101, 0x255e8369, 0x312f5d33, 0xd8820130, 0xd1820120, 0x8a860125, 0x83f4f1fe, 0x010023cc, + 0x0782a000, 0x49843920, 0x00b92f27, 0x40e8ff00, 0x82b28e1a, 0x82032046, 0x02002346, 0xac820201, 0x883f0021, 0x25a4834a, 0xf1fe3902, 0x9b85a58a, + 0x0300002a, 0x0700d200, 0x1105ba05, 0x07310982, 0x41000b00, 0x0b002940, 0x08560b01, 0x075404ac, 0x2448820f, 0x0fac0256, 0x00871807, 0xab043c09, + 0x052d0b00, 0x0a4001ab, 0x5d2f0a01, 0x3cfde43c, 0x005d5de4, 0xedf45d2f, 0x82fd105d, 0x27b28204, 0x01331123, 0x01213521, 0x22080782, 0xeeeebd03, + 0x18fbfd01, 0x03fee804, 0xfe03eeee, 0x2bfd1301, 0x012bfda0, 0x00020013, 0x05c8ffac, 0x845405e0, 0x40573b77, 0x4704483b, 0x57045806, 0x67046806, + 0x70047f06, 0x057f0806, 0x07020770, 0xc9820005, 0x03300339, 0x03900360, 0x00b20304, 0x60023002, 0x04029002, 0x0120b202, 0x82020604, 0x02530847, + 0x332f1901, 0x2f2f1833, 0x00393912, 0xfe191a2f, 0x115dee5d, 0x30313917, 0x095d015d, 0xfde00507, 0x0266fd66, 0xfebd019a, 0x0143fe43, 0xfd8e02bd, + 0x02c6023a, 0x013afdc6, 0xfe23fedd, 0xffff0023, 0x64fe3d00, 0xdb057f04, 0x5c003602, 0x16010000, 0x6bdd8e00, 0x10250519, 0x700e600e, 0x237f820e, + 0x00040b0e, 0x26087f71, 0x04000006, 0x825007e6, 0x003c342d, 0x00170100, 0x01edff8e, 0x40190075, 0x0e000213, 0x84500e40, 0x01052b33, 0x05090e00, + 0x352b2500, 0x2482355d, 0x009aff27, 0x054b0300, 0x2ceb82d1, 0x3811401d, 0x68034803, 0x69016500, 0x2b268203, 0x02000003, 0x002f332f, 0x30312f3f, + 0x012daf82, 0x4b030123, 0x03a5f4fc, 0xfad1050c, 0x0831822f, 0x0000019c, 0xca04e5ff, 0x3300ec05, 0x9340da00, 0x02010458, 0x03012fb5, 0x02011db8, + 0x18471837, 0x18671857, 0x18e71877, 0x010718f7, 0x004a003a, 0x006a005a, 0x00fa007a, 0x062c0306, 0x09982950, 0x0f230901, 0x12f72050, 0x18120801, + 0x58122812, 0x12000412, 0x18150312, 0x19011927, 0x15341d19, 0x33280002, 0x33330101, 0x0a03342f, 0x02012027, 0x2c292023, 0x120f0004, 0x26040609, + 0x182a080c, 0x032a282a, 0x21212a00, 0x7100180c, 0x07341035, 0x15263407, 0x0b0b160c, 0x200c5502, 0x05820909, 0x1034683c, 0xed2b2bf4, 0x102f3912, + 0x3cf6103c, 0xc42f3911, 0x12115d5f, 0x17113917, 0xb5665f39, 0x5d5f2905, 0x33ed3f33, 0x11335d2f, 0x5f262582, 0xfd3c5d5d, 0x0483dd3c, 0x855d5f21, + 0x30312201, 0x05037f5f, 0x2303002a, 0x26263337, 0x37363435, 0x12210882, 0x05fd6200, 0x2326262e, 0x21070422, 0x06062107, 0x17161415, 0x16330882, + 0x36323304, 0xca043337, 0xf37eb96c, 0x863183fe, 0x82024b2c, 0x77610800, 0x013a5d2c, 0xbf8df374, 0xc6501054, 0x00ff9d7c, 0x2cdb0130, 0x03023cfe, + 0x7c010202, 0x31c4fe2c, 0x9d960801, 0x3e0f44b2, 0x2e012633, 0x15760401, 0x341a162f, 0x01017618, 0x2d292801, 0xcf3d41d1, 0x341876b1, 0x152e171a, + 0x3fd1b676, 0x0001003d, 0x02ac00ba, 0x006c04e0, 0x402c0006, 0x01057209, 0x070e4a04, 0x0c0c402d, 0x03033710, 0x01050400, 0x49010000, 0x312309ef, + 0x492b2b30, 0x022108e8, 0x07d749e0, 0xb401ac2a, 0xc7b30159, 0xe7fee7fe, 0xc2205582, 0xe8205582, 0x7d215587, 0x23558503, 0xc0ffb802, 0x05205584, + 0x03206682, 0x9e495593, 0xe8022106, 0x08079749, 0xfe600247, 0x1901c74c, 0xfec71901, 0x0200004d, 0x00004400, 0x1e065304, 0x1e000300, 0x21401c01, + 0x103a100b, 0x1a741a60, 0x02440104, 0x19151503, 0x0700113f, 0x0d1d3e0a, 0x08090505, 0x6001140b, 0xf4ffb805, 0x020c0cb4, 0x20088255, 0x053c54f6, + 0x001a052f, 0x0a140460, 0xeeffb804, 0x021010b4, 0x24088255, 0x0f1d40d0, 0x2209820f, 0x820d0d0a, 0x832a2005, 0x0a04232f, 0x0b820b0b, 0x09090a22, + 0xec272184, 0x0f0f0b40, 0x82045506, 0x26058221, 0x40f0ffb8, 0x8209091f, 0x20922209, 0x0c23711d, 0x0d0b1a24, 0x5583160a, 0x5724245b, 0x2a820537, + 0x1840ee2a, 0x55060d0d, 0x0c0c280a, 0x07200582, 0x0a285a83, 0x37100d40, 0x101f890a, 0x083e4818, 0x322b2b24, 0x0482fd32, 0x08c44218, 0x112b2b25, + 0x82e41039, 0x2fe42912, 0x3c3f002f, 0x32fd333f, 0x2a05e54f, 0x5d013031, 0x33352301, 0x18112303, 0x760d5654, 0x5a08068e, 0x04211515, 0x11d0d053, + 0xbcf9fdbc, 0xb7c87f7f, 0x0a29653e, 0x79226a1c, 0x05c9026a, 0x25fac318, 0x3efcc203, 0x319ebf03, 0x070dcfc1, 0x6b1408aa, 0x0100288c, 0x00004400, + 0x1e064704, 0x12011a00, 0x076c1940, 0x1902077a, 0x051a191a, 0x0c00163e, 0x12093e0f, 0x080e0105, 0x41010a10, 0x0882076f, 0x0a40f62c, 0x55020909, + 0x0a001a01, 0x6d41000f, 0x41088207, 0x0029066d, 0x020d0d0a, 0x0c2a0055, 0x2205820c, 0x830b0b0a, 0x822f8305, 0x066d4121, 0x06212183, 0x410f8255, + 0x0025066d, 0x0c091c92, 0x2023830c, 0x2e00820c, 0x1a0c5502, 0x160f1210, 0x55021010, 0x5cffb80f, 0x0f200692, 0x0f821f84, 0x8205925c, 0x05ea5508, + 0x6d410882, 0x24088205, 0x0d0db4ec, 0x20338306, 0x055659f0, 0x09080f23, 0x250f8209, 0x37100d40, 0x5018890f, 0x70410c8f, 0x2bed2213, 0x096e412b, + 0x3333ed2a, 0x30312f2f, 0x1123215d, 0x18053652, 0x0810c955, 0x4704375a, 0x358b2bbc, 0x490185a2, 0x7fbcbdfe, 0x45dee97f, 0x05bc2c90, 0x6c0c086d, + 0xfc9e2c8c, 0x9ebf0341, 0x0ed1bf31, 0x00000804, 0x00bb0001, 0x065b047c, 0x00130014, 0x0b394057, 0x11100f0e, 0xaa090608, 0x1312070a, 0x06040100, + 0x0a06aa05, 0x0c030c06, 0x1f150f01, 0x63100215, 0x2b059c70, 0x0e0d0c0b, 0x0a011211, 0x09032802, 0x2807a270, 0xed103cf6, 0xe6103917, 0x05a570e6, + 0x822f3921, 0x2003830d, 0x08aa7031, 0x3505112a, 0x03330305, 0x11251525, 0x700bb270, 0x088308b6, 0x05fb012b, 0x84017cfe, 0x01058105, 0x220483a2, + 0x827cfe84, 0x5efe2206, 0x32a98205, 0x01ff01fd, 0x001a03ec, 0x40160003, 0x0156020c, 0x182d0008, 0x2307408d, 0xed3f00ed, 0x22062047, 0x82efefec, + 0x001b2a27, 0xfef6ff01, 0x018f01ec, 0x202f821b, 0x05cd472e, 0xcd471920, 0x030f2f0d, 0x031f0101, 0xb1000301, 0x00ed2f02, 0xcc475d2f, 0x8f012d0c, + 0xa58af1fe, 0xd1fd1b01, 0x02002f02, 0x03214b83, 0x224b841f, 0x48510007, 0x212018e1, 0x002b608d, 0x05050105, 0x1f070f03, 0x49070207, 0x2f210c5d, + 0x16e2485d, 0xe2481f20, 0x84798508, 0x0756087d, 0xe3ff9500, 0xed05930b, 0x0f000b00, 0x27001b00, 0x3f003300, 0xc6004b00, 0x08099040, 0x18090a06, + 0x3c081a06, 0x08183e07, 0x18180a17, 0x3c191a17, 0x08293e16, 0x18290a26, 0x3c281a26, 0x0d463e25, 0x0d560f48, 0x0e680f58, 0x761f7917, 0x762b7925, + 0x76437931, 0x94180649, 0x2e0810b9, 0x3d512b43, 0x19401920, 0x49191902, 0x13375131, 0x400c4f0a, 0x0e0c020e, 0x3a002a46, 0x2a403a01, 0x0134003a, + 0x002a2e34, 0x34160116, 0x182a2816, 0x2621cb94, 0xed5d2f33, 0x82335d2f, 0x2fed2703, 0x3f005d2f, 0xf684fd3c, 0x3f3cfd25, 0x83ed3f3f, 0x315d241c, + 0x185d0130, 0x2033d794, 0x17997225, 0xb2bd742b, 0xb2bebab6, 0xb302bab5, 0xef9418fc, 0x833e2022, 0x2b32832a, 0x666459b2, 0x64665858, 0xe0340459, + 0x25029518, 0xdae0ae24, 0x2b83dddc, 0x8888ac27, 0x8787adad, 0x12594f00, 0x2800d623, 0x05594f01, 0x334f0f20, 0x0f177b0a, 0x2600d622, 0x01252584, + 0x020c1000, 0x0c7f4f03, 0x220aa54f, 0x84f8ff8d, 0x00022325, 0x7f4f0c0c, 0x234b8409, 0x36025007, 0x2206637b, 0x8250008e, 0xb70d2525, 0x11000102, + 0x657b4c86, 0x0c8b7b07, 0x3c004322, 0x8b7b4d84, 0x0089240d, 0x84d50200, 0x002c2873, 0x00170100, 0x8812ff8d, 0x7b042025, 0x5d24088b, 0x08030000, + 0xd622258a, 0xbf8827ff, 0x7e202589, 0xe2204b82, 0x4b859984, 0x24ff8e22, 0x192e2582, 0x00021340, 0x50104010, 0x70106010, 0xf2820510, 0x32820d20, + 0x5d352b22, 0x7f8fa584, 0x3eff4322, 0x73247f92, 0xda05e1ff, 0x73507f84, 0x008d2205, 0x23258478, 0x25250002, 0x22067350, 0x8f00ffff, 0x00d62225, + 0x2025868f, 0x07995028, 0x43222592, 0x4b92aa00, 0x7182b220, 0x71842920, 0x17413820, 0x6e002105, 0x01232584, 0x7c1f2000, 0x00200540, 0x8a07717c, + 0x00d62225, 0x2025865b, 0x06667c22, 0x71872593, 0x1f000122, 0x00234b87, 0x82bb0001, 0x04772b67, 0x0003005d, 0x02274074, 0x55180105, 0x0c281203, + 0x55060c0c, 0x09090600, 0x2c035518, 0x0c0cb429, 0xb8015502, 0x83b6fcff, 0xfc541838, 0xfb54180a, 0x2321270c, 0x77013311, 0x8182bcbc, 0x01013008, + 0x03110536, 0x008c06e1, 0x403a0006, 0x56055927, 0x66056906, 0x73057a06, 0x02010606, 0x60055003, 0x03057005, 0x03600505, 0x00500301, 0x82700060, + 0x051a57b3, 0x5d2f0025, 0x795d2f33, 0x0b340860, 0x33132301, 0xb99fe103, 0xe3e49bb8, 0x00011105, 0x7b0100ff, 0x2508e682, 0x1d05ed00, 0x53062c04, + 0x39001900, 0x02392340, 0x02490e35, 0x19040e45, 0x5209190d, 0x101f100f, 0x52161002, 0x5e830d10, 0x00281929, 0x0d00280c, 0x45ed332f, 0x078205af, + 0x47ed5d21, 0x7555050c, 0x04360819, 0x6f840b2c, 0x2f295c36, 0x34342741, 0x8e088304, 0x2a5d3267, 0x3321492f, 0x53060339, 0x25279a98, 0x4c5a2b2b, + 0x24279a97, 0x465c2929, 0x18010100, 0xfe033705, 0xc582d105, 0x09401429, 0x01105302, 0x4c000101, 0x2f310549, 0x3031ed5d, 0x21352101, 0x1afdfe03, + 0x3705e602, 0x08bd829a, 0x0513012e, 0x0602040e, 0x000d008c, 0x653a4056, 0x750c6508, 0x040c7508, 0x6006500d, 0x03067006, 0xaa0a0606, 0xf0034009, + 0x90d10203, 0x0203e003, 0x8b270484, 0x89010300, 0x82010350, 0x03592502, 0x07002a0d, 0x2a06235f, 0x5e2f00ed, 0x5d5e7271, 0x82715d5e, 0x21d98204, + 0x50563c5d, 0x06365709, 0x0a020438, 0xc5a9a9c5, 0x6b0ca609, 0x0e6b595b, 0xd6a88c06, 0x7884a8d6, 0x8b828478, 0x05210227, 0x05f50218, 0x28bb82db, + 0x4402b50e, 0x01150001, 0x8353822f, 0x352329b5, 0xd4f50233, 0xc31805d4, 0x2f08cc82, 0x09052d01, 0xb107e903, 0x17000b00, 0x2e404500, 0x0009510f, + 0x02093009, 0x01093031, 0x09600950, 0x09030970, 0x03511509, 0x0020290c, 0x00020030, 0x602b0482, 0x00d00300, 0x12000001, 0x832f0629, 0x72712198, + 0x33265883, 0x5e725d2f, 0x60835e71, 0x08179045, 0x92cce922, 0x92ccce90, 0x7591cb93, 0x76755858, 0x06755857, 0xc5c68f5e, 0xc4c48f90, 0x7677568f, + 0x76765757, 0x0127b982, 0x0359fe61, 0x82140070, 0x40243901, 0x1b020b15, 0x39012b01, 0x07120401, 0x03530b07, 0x002a0e0d, 0x332f0600, 0x3f28cb82, + 0x2f2f32fd, 0x055d3031, 0x4b586e84, 0x34352807, 0x1e332726, 0x7d700301, 0x06250aa2, 0x06029903, 0x08827d59, 0x491d2308, 0x00341319, 0x05560102, + 0x06770416, 0x0003008c, 0xb5420007, 0x04450045, 0xffb80002, 0x100eb3e8, 0x07820437, 0x82194021, 0x50072608, 0x70036003, 0x22008203, 0x839f0105, + 0x040223f4, 0x7f820402, 0x822f3321, 0x005d2383, 0xf682332f, 0x30313326, 0x5d2b2b01, 0x26079b50, 0xfefe7704, 0x83b0a98b, 0x8c062504, 0x76018afe, + 0xd7830383, 0x5ffe9f26, 0x0a007c03, 0x0e2cd785, 0x2b041e04, 0x04043b04, 0x1014140a, 0x0022d782, 0x1c612a0d, 0x87002005, 0x05c642d7, 0x36343526, + 0x010e3337, 0x0805c061, 0x03333723, 0x2a4b347c, 0x060da98b, 0x5306069b, 0x1151245a, 0x0e79fe08, 0x268f9e0c, 0x3c1b1a3e, 0x1b4e521e, 0x24698308, + 0x03110532, 0x07a543dd, 0x5901542f, 0x6b016402, 0x7b017402, 0x05060602, 0x23d18802, 0x02010260, 0x2008a543, 0x43cf8503, 0x032d0ba5, 0x1b330323, + 0xe4dd0301, 0xb99fe4e3, 0x26cb82b8, 0xff7b0185, 0x82000100, 0x00410861, 0x04000018, 0x00d10580, 0x40a6000d, 0x4b0b3b2e, 0x7a0a5a0a, 0x0b02040a, + 0x09040805, 0x01090903, 0x350c0306, 0x030a0801, 0x0f00000a, 0x08010f0f, 0x0305140b, 0x10100a02, 0xb8025502, 0x0bb4fcff, 0x2008840b, 0x05c767da, + 0x09080223, 0x230f8409, 0x0c0cb4ee, 0xea230884, 0x840d0db4, 0xb4e82408, 0x83060f0f, 0x82ec2033, 0x20088411, 0x842382ea, 0xb6fa2308, 0x08820909, + 0x4c0e6c21, 0x322c0ea2, 0x2f33115d, 0x002f2f39, 0x123fed3f, 0x28610782, 0x07270808, 0x33113735, 0x01150111, 0x80042111, 0xbaba52fc, 0xfe5d01c6, + 0x02e802a3, 0x95a39817, 0x78fd1a03, 0xfea31b01, 0x8607fee8, 0x022908df, 0x00140636, 0x4099000b, 0x5905492f, 0x03056905, 0x07040206, 0x0b040a01, + 0x0b0b0505, 0x03010803, 0x0d050008, 0x010a0092, 0x21bd830c, 0xba830c01, 0x051a0125, 0x68b80407, 0x088206a8, 0x2006154c, 0x82228404, 0x050c4c0f, + 0xf6220882, 0x2f830d40, 0x83140421, 0x880424de, 0x53f4100c, 0xf14b055c, 0xe6322105, 0xbd83be83, 0x822f3321, 0x54432dbe, 0x2005b558, 0x0b37100d, + 0xb2e0ffb8, 0x2b2a0782, 0x3031592b, 0x1107015d, 0xd4851123, 0x02372508, 0xadbcb536, 0x03b5bcad, 0x17fd917a, 0x9f8d6002, 0xfd18038a, 0xffff9471, + 0xe5ff8600, 0x01080205, 0x36003602, 0x1724d882, 0x4d00df00, 0x22068946, 0x571a3134, 0x6e2a08e1, 0xd703e5ff, 0x36028c06, 0x25825600, 0xdf00162c, + 0x0b0000ae, 0x370001b6, 0x23881834, 0x00007e23, 0x05eb4705, 0x49863d20, 0x49863220, 0x020a0d23, 0x07ab4806, 0x00005d24, 0x4984e303, 0x01200982, + 0x94204982, 0x0d224985, 0x2385050a, 0x18020021, 0x080ad348, 0x29000723, 0x090f1640, 0x0102094f, 0x05060106, 0x0b050102, 0x011f0400, 0x0501054f, + 0xfd3c5d2f, 0x3f3f003c, 0x053f5912, 0x015d0122, 0x07358d18, 0x82ae2821, 0xf6022c00, 0x64f81e03, 0x00001e03, 0x820e0002, 0xbc340899, 0x1200d105, + 0xef002500, 0x16382740, 0x02661648, 0x1b041168, 0x0b3c081e, 0x341a070b, 0x341f030c, 0x00760807, 0x071d1d01, 0x02001513, 0x55020b0b, 0xdeffb800, + 0x21070062, 0xfa4db4f0, 0xb4e62306, 0x1a840c0c, 0x2740fc24, 0x09820d0d, 0x0f27742c, 0x60274027, 0x1b090327, 0x1b83041e, 0x83081e21, 0x141e2d2a, + 0x0a07090b, 0x55021010, 0xdaffb807, 0x08824684, 0x8205b642, 0x84ee2008, 0x57088246, 0x07200627, 0x0f823484, 0x8205cf42, 0x18f62008, 0x82088b87, + 0x8306202a, 0xb6fd2345, 0x08820909, 0x6c586c20, 0x050e4205, 0x2106724f, 0xe3425d2f, 0x12ed2806, 0x005d2f39, 0x833fed3f, 0x39fd2208, 0x05416539, + 0x0606072e, 0x23112123, 0x21113335, 0x16170432, 0x070c8f18, 0x11232a08, 0x11211521, 0x37363233, 0xbc053636, 0xfb6693b1, 0xc488fecd, 0xda7401c4, + 0x98580201, 0x797acfaa, 0xbc8ac658, 0x97fe6901, 0x4a8518bc, 0xe402250c, 0x3f5e028f, 0x094d8518, 0x8f4cfe28, 0x392ac6fd, 0x5918e847, 0x5708073d, + 0x1f001e06, 0x84003100, 0x0d195b40, 0x01320d29, 0x2b392034, 0x01452d36, 0x20440d4c, 0x2d442b4a, 0x2d542b5a, 0x1e74056f, 0x0c102174, 0x093f2903, + 0x1d1a120f, 0x10101b04, 0x1b160309, 0x4f163f1b, 0x02160216, 0x0a033e2f, 0x1d1a111c, 0x1100031c, 0x260c0f12, 0x2f161f05, 0x23371782, 0x00091613, + 0x142c0900, 0x11ed2f06, 0x39122f33, 0x175d2fed, 0x43171239, 0x5d2706cf, 0x12112f33, 0x832f3939, 0x06ed6a10, 0x23001024, 0xea6a0022, 0x012e2506, + 0x37270527, 0x352b0582, 0x17011e21, 0x16071737, 0x7b3e0112, 0x54610618, 0x336e0805, 0x71043632, 0xe5f1e4fe, 0x1201ebfe, 0x569b6cca, 0xfe578720, + 0x54ed42f8, 0x27015d90, 0xd2256223, 0xa699ba42, 0x3431defe, 0xa54b0203, 0xa9a99356, 0x027b428f, 0xfebcfe7d, 0xf50e01a8, 0x350801e2, 0x4ad67035, + 0x438e61a2, 0x19102f51, 0x61801a43, 0x9bfe936d, 0xa93b8afd, 0x1e372096, 0x98af2b2d, 0x002caeb4, 0x0600ffff, 0xe6040000, 0xbf540108, 0xff8d2208, + 0x062b43e4, 0x4b0a0b21, 0x3d2609b1, 0x7f0464fe, 0x13558c06, 0xdd8d2108, 0x21052b43, 0x0a55090a, 0x00002405, 0x82c80002, 0x96270849, 0x1200d105, + 0xe2002100, 0x1f392640, 0x11551f49, 0x11801080, 0x00341b05, 0x1a070107, 0x010c2034, 0x09070c0c, 0x7d09030a, 0x132605de, 0xffb80015, 0xe342b4ee, + 0x40f82806, 0x0209090b, 0x420c0055, 0x230806d8, 0x0d2140f0, 0x2055020d, 0x40003000, 0x04007000, 0x0f236f00, 0x02233f23, 0x14071b0c, 0x100e0900, + 0x09550210, 0x8207a245, 0x06a24508, 0x7b180920, 0x056a19a8, 0x182a8205, 0x2408b17b, 0x0c0cb4e4, 0x23458306, 0x0909b6f2, 0x6c210882, 0x0ca24522, + 0x3232fd25, 0x7ff6105d, 0x5d200556, 0x2106e043, 0x5149ed5d, 0x015d3305, 0x06070614, 0x11232306, 0x11331123, 0x17163233, 0x7b181616, 0x370810c1, + 0xdb4e3c46, 0xc6c6c697, 0x43c285cd, 0x34ce5e53, 0x5a803038, 0x9877a7c4, 0x03292c2f, 0x39a95c13, 0xbefe484b, 0xf2fed105, 0xaa352c2d, 0x236b487d, + 0xcdfd191e, 0x66292d29, 0x07ab5a18, 0x00140627, 0x00200013, 0xab5a18ec, 0x1e01351e, 0x0b090640, 0xffb8140c, 0x0c0cb6f4, 0x1b145502, 0xf0ffb800, + 0x18075741, 0x2719a25a, 0x0d0d1d40, 0x90005502, 0x14de6c18, 0x1cd26c18, 0x22053452, 0x46ffb80c, 0x08840527, 0x060f0f23, 0x46088255, 0x088305ff, + 0x0c0d4023, 0x2212820c, 0x82090906, 0x21882105, 0x180dc76e, 0x2009795a, 0x755a18ed, 0xd76c181b, 0x474e2314, 0x5a18b342, 0x07262075, 0x3fd4fdb0, + 0x5a18fe55, 0x26080c76, 0xdc000100, 0xb0053c02, 0x0300dc02, 0x11401e00, 0x020f5400, 0x05400201, 0x40053001, 0x00000205, 0x2f332f01, 0x41005d5d, + 0x212805e1, 0xb0052135, 0xd4042cfb, 0x0805d95a, 0x00230126, 0x04690569, 0x000b00af, 0xd7174026, 0x0208d802, 0xd70102a7, 0x020bd805, 0x05010ba8, + 0x02940284, 0x2f190202, 0x28083d82, 0x5d013031, 0x715d0071, 0x01090725, 0x37010927, 0x01170109, 0xfe6f6905, 0x6f4cfe4c, 0x48feb801, 0x01b4016f, + 0x48fe6fb4, 0x210d8cd8, 0x2182b801, 0x36088282, 0x36022301, 0xd5059203, 0x2e000f00, 0x50051840, 0x030c0606, 0x01aa030e, 0x0205050e, 0x0e0c0f0f, + 0x0310022a, 0x5d2f0301, 0x3239ed33, 0x2f332f2f, 0x32fd3f00, 0x4b2f333f, 0x270805e5, 0x35231133, 0x3e373632, 0x11333701, 0xfd920333, 0x2df2ea99, + 0x2c251e6c, 0x02dd8703, 0x38027a36, 0x100c0d70, 0xdbfc282c, 0x00216782, 0x086782cf, 0xef05c73d, 0x45001d00, 0x15242d40, 0x15361825, 0x104c1835, + 0x106d105e, 0x19661865, 0x1875107d, 0x0b0f0f0b, 0x02021352, 0x0e01521c, 0x021c0000, 0x10162a08, 0x2f021016, 0x2f2f3333, 0x863912ed, 0x33ed227c, + 0x22f2832f, 0x82352101, 0x013e2177, 0x080dc46f, 0x0614153c, 0x07010e07, 0xfdc70321, 0x33a76408, 0x5a6b4a83, 0x0d30ac59, 0xb457af47, 0x377361bb, + 0x2002429b, 0x3e9c3602, 0x6767296e, 0x3d4c4554, 0x231ab41f, 0x97637d9d, 0x29662b5a, 0xa3820100, 0x030f5908, 0x00f005bc, 0x4077002e, 0x39032a16, + 0x4a0c4503, 0x5c0c541f, 0x64086b1f, 0x74087d23, 0xb8270a23, 0x3940c0ff, 0x2c370e0b, 0x0f52152b, 0x160f0116, 0x164f161f, 0x16cf165f, 0x160616ff, + 0x521d2121, 0x02250616, 0x520e0a0a, 0x2a1a0f06, 0x11221628, 0x2816222a, 0x1009042c, 0x00225e82, 0x2c792f09, 0x2fed2105, 0x0021d082, 0x18c9823f, + 0x28070242, 0x3939ed71, 0x5d2b3031, 0x22bf8401, 0x4b262223, 0x2b250ab7, 0x32333501, 0x08e79136, 0x011e1586, 0x3842bc03, 0x5e599439, 0x290e4aa5, + 0x85645dc3, 0x808f7076, 0x68636b70, 0x0e2cc34d, 0xaf5aad4a, 0x5f596ec1, 0x4b310383, 0x21232271, 0x24b31c1e, 0x554b473b, 0x444d8d3c, 0x243e473d, + 0x88231bb2, 0x1a72596a, 0x006f1108, 0xab00ffff, 0xa3070000, 0x3600d505, 0x00923b02, 0xbb003700, 0x00003702, 0x3c021701, 0xc3fd0404, 0x15402000, + 0x02080e02, 0x600e400e, 0x0b01020e, 0x0b5b0b2b, 0x0b7f0b6b, 0x35115d04, 0x00220282, 0x4186353f, 0x41924120, 0x84033e22, 0x26304182, 0x02031940, + 0x02030810, 0x5f0e1f0e, 0x030e7f0e, 0x35204590, 0x47834682, 0x89828c20, 0xed05792a, 0x3d022600, 0x270000a6, 0x91208982, 0x07248982, 0xbc033e02, + 0x36264782, 0x02032640, 0x03820836, 0x3036103e, 0x03367f36, 0x31003101, 0x314b3134, 0x316b315f, 0x0006317b, 0x3f090009, 0x03094f09, 0x05829a85, + 0x30085784, 0x3c000100, 0x74040000, 0x1100d105, 0x46409f00, 0x51090f0c, 0x063f062f, 0x0b060602, 0x054f3402, 0x10050501, 0x1034010b, 0x01032003, + 0x03030808, 0x3830822f, 0x010e1300, 0x0c0c0a05, 0x0a55020c, 0x0b0e0f14, 0x020f0f08, 0x0d160b55, 0x2005820d, 0x2715831e, 0xeeffb80b, 0x0b0b1740, + 0x0a280f82, 0x55060f0f, 0x0d0d140b, 0x0c210583, 0x2e05820c, 0x40f8ffb8, 0x0609090a, 0x3f0b2f55, 0x700b020b, 0x2b20058f, 0x332c0082, 0x322bfd33, + 0x33112f32, 0x2f335d2f, 0x2105b748, 0x0782122f, 0x0484ed20, 0x31393926, 0x11210130, 0x20072361, 0x05bf4823, 0x74043808, 0x8a023efd, 0x4a0176fd, + 0xb6c0b6fe, 0x058203b6, 0xab55fe26, 0xfe8beffe, 0x8b3401cc, 0xff001204, 0xff7300ff, 0x08a205e3, 0x00360201, 0x0000002a, 0x00d90017, 0x827501cf, + 0xfe6c2617, 0x06430459, 0x3117828c, 0x0100004a, 0xfed90016, 0xb60b0000, 0x31370002, 0x9d4a231a, 0x00892607, 0x07d50200, 0x20238250, 0x2423822c, + 0xffda0017, 0x06974724, 0x520c0d21, 0x003906af, 0xfe860001, 0x05020559, 0x014700ec, 0x4600b94f, 0x10b4f4ff, 0x44550210, 0x200886b8, 0x21088245, + 0x1283b540, 0x830e2f21, 0x842e2005, 0x842d2005, 0x0c2c2105, 0x2b211183, 0x0805830a, 0x0a0b0b5c, 0x0036001f, 0x1b0b1b3a, 0x2f36131f, 0x291f2a0b, + 0x2436242f, 0x390b3f46, 0x3927341f, 0x3436342a, 0x441f4841, 0x432a4827, 0x443e4b36, 0x5a035f41, 0x57325205, 0x6b445536, 0x6a046f02, 0x64326430, + 0x60426636, 0x7a057946, 0x7036702d, 0x75417537, 0x2b298644, 0x100e4020, 0x04831f37, 0x1a020635, 0x31280006, 0x1d34063f, 0x343c3838, 0x21210234, + 0x821d3425, 0x53143f7b, 0x0f0f0d0c, 0x14092a17, 0x55020f0f, 0x153f3709, 0x09091631, 0xb8315502, 0x0f40f0ff, 0x09820d0d, 0x0015282b, 0x091d3731, + 0xb8002004, 0x089c7aff, 0x0c311c82, 0x0055020c, 0x490f4974, 0x20024970, 0xe610486a, 0x0f42185d, 0x2b2b2509, 0x2b2f2fed, 0x0b544d18, 0x0c823f20, + 0xa14c1120, 0x15403705, 0x3f572858, 0x3f672868, 0x3f762879, 0x3f862889, 0x3f992897, 0x7f185d0a, 0x50181346, 0x7f181abd, 0x2c352a5d, 0x03033e68, + 0x74259ab3, 0x521a092d, 0x03626838, 0x15251402, 0x6f7f18a1, 0x3723362a, 0x192c1611, 0x0c0eb19d, 0x4e1c0aa2, 0x12291858, 0x3b3c0201, 0x817f18f8, + 0x6e6a0821, 0xd70359fe, 0x4a007804, 0x59404101, 0x0c092008, 0x04020937, 0x17021932, 0x2b202432, 0x3a20343b, 0x4b20433b, 0x5c1c5a3b, 0x5337522d, + 0x6b495246, 0x622d6b1c, 0x62466237, 0x7c1c7c49, 0x79377428, 0x8b42743f, 0x85248801, 0x1d3f8731, 0x25000317, 0x3506402f, 0x0b40391a, 0x8055020b, + 0x39390139, 0x04353e3d, 0xc0ffb81e, 0x12831540, 0x221e1e31, 0x0d091a3e, 0x0953110d, 0x140c0c0d, 0x5cb8062a, 0x0883063b, 0x2505424f, 0x0d0c1206, + 0x0f825502, 0x09b6f823, 0x26088209, 0xffb82538, 0x832040fa, 0x0c40280b, 0x55020c0c, 0x824c1b40, 0x55022308, 0x1383102f, 0x830a2f21, 0x822f2013, + 0x6ff42024, 0x2528051f, 0x382f001b, 0x1d04061a, 0x16095f18, 0x35832120, 0x83140021, 0x8e002f35, 0x1f4c0f4c, 0x5f4c3f4c, 0x054c7f4c, 0xa183161d, + 0x4b861d26, 0x5d2be610, 0x2d051a5c, 0x10391711, 0x2b2f2bed, 0x2bed2b2b, 0x07832f2b, 0x270c3342, 0x33ed3f2b, 0x112b5d2f, 0x2305974f, 0x0614012b, + 0x28180e42, 0x33352726, 0x32331616, 0xfa5e1836, 0x6f7f2227, 0x9b4f1802, 0x2815230d, 0x5f187c17, 0x6b26280c, 0x36132aa3, 0x4f18a21a, 0x182407aa, + 0x02020f2d, 0x271e5f18, 0x00ffff33, 0x05e5ff73, 0x02010846, 0x00260036, 0x00170100, 0x0819568d, 0x0c2c2d22, 0x08494d18, 0xe7ff6926, 0x8c06f303, + 0x46202582, 0x16232582, 0x4bce8d00, 0x242305f3, 0x440f0923, 0x498f07a5, 0xa800df22, 0x2106a544, 0x4d182b2e, 0x498f0993, 0x85f6df21, 0x22252149, + 0x4d084986, 0x6c000200, 0xfb04e1ff, 0x1b001406, 0x04012800, 0x053b3a40, 0x223c0c38, 0x283e2432, 0x0c4a054b, 0x2445224e, 0x0859284f, 0x12700869, + 0x5114010d, 0x1017171a, 0x04130118, 0x10412007, 0x26080304, 0x160a0742, 0x16018800, 0x041c1317, 0xd479ffb8, 0x42088305, 0x04290532, 0x402a1a1a, + 0x55020f0f, 0x5e751801, 0x08012308, 0x0f820b0b, 0x15841020, 0x09090c22, 0x2a220b82, 0x05820c0c, 0x0d0d0a22, 0xe8202784, 0x2005c75e, 0x200f8201, + 0x20378306, 0x05f279ec, 0x2a920129, 0x2a3f2a1f, 0x830c2302, 0x1b23242d, 0x83180a01, 0xb80a2548, 0x1940feff, 0x0a214c83, 0x464c831c, 0x042006a2, + 0x0a224c83, 0xf94a2985, 0xed322106, 0x0be08b18, 0x322b2b23, 0x3f0382fd, 0x10323232, 0x3f002fe4, 0xed3f3fed, 0x3f393912, 0x3c2f3912, 0x30313cfd, + 0x1123015d, 0x06063523, 0x0c667118, 0x82213521, 0x15332201, 0x98991833, 0x044e080c, 0x4dbcb8fb, 0xedc66ead, 0xb6444452, 0x4c865960, 0x6b0195fe, + 0x8cfeb8bc, 0x9c49734f, 0x509787b2, 0xfbf404a4, 0x5242750c, 0x11012e01, 0x4c4ddb8e, 0xce27244f, 0xfb9a9a86, 0x22790299, 0xc3ccd618, 0x010047cd, + 0x8406fcff, 0xfc061a05, 0x7b180300, 0x272c14dd, 0xfa1a0521, 0x1e0505e7, 0x00788406, 0x5a2fd55c, 0xd92a1263, 0x75013100, 0x02b60b00, 0x635a1100, + 0xff68210a, 0x0dcb5418, 0x00d6d922, 0xa1082384, 0x260b343a, 0x352b0125, 0x00020000, 0x065ffe1a, 0x00d1052b, 0x001e001b, 0x0f9c40d6, 0x2e051f05, + 0x40053e05, 0x0608701d, 0x0e4a1c38, 0x0e590f45, 0x1d050f57, 0x0a1c1d1e, 0x09870977, 0x10140902, 0x1e1d100f, 0x870c770b, 0x140c020c, 0x570e0d0d, + 0x7d0f580e, 0x040f730e, 0x401e340b, 0x55021010, 0x0d0d401e, 0x1e305502, 0x1e701e40, 0x1e091e03, 0x0e0d031d, 0x171b1b03, 0x100d0353, 0x0d010d7a, + 0x14000008, 0x200f062a, 0x1d0f0e01, 0x0c0d0406, 0x39102410, 0x5a104210, 0x74106a10, 0x10100710, 0x1b82206e, 0x0d0a2a08, 0x0d360d2b, 0x0d550d4d, + 0x0d7c0d65, 0x1f640d07, 0x5d5de610, 0x5d2ff410, 0x5d391712, 0x2f33ed2f, 0x3c5d3f00, 0x2f32fd3f, 0x1810823f, 0x3519049a, 0x06015d00, 0x26222306, + 0x37363435, 0x23032103, 0x23012101, 0x56550606, 0x02093807, 0x4b342b06, 0x1ea98b2a, 0x7cfd7906, 0x1e02c992, 0x1e020801, 0x55070661, 0x6b080563, + 0xfbfe91fd, 0x79fefafe, 0x909d0c0e, 0x01156a40, 0x0561fe54, 0x1b2ffad1, 0x4e521b35, 0x3103081b, 0x25fddb02, 0x00020000, 0x055ffe68, 0x0078042e, + 0x0147003a, 0x0b5d4033, 0x1a2b0511, 0x2a2b1612, 0x5f224405, 0x65405425, 0x62256c16, 0x7b127b40, 0x70257f1d, 0x040c0f3f, 0x0539041b, 0x16691659, + 0x363a3a05, 0x0a0d0353, 0x303d3c10, 0x0805745d, 0x24102821, 0x283f2024, 0x10414504, 0x0809300a, 0x2a330000, 0x01250f06, 0x3b190625, 0x09094049, + 0x43095502, 0x08830790, 0x0c164023, 0x2d12820c, 0x13252f1a, 0x1010062f, 0x122f5502, 0x05820b0b, 0xe6ffb822, 0x2105a076, 0x3383182f, 0x0d1a2f23, + 0x2115840d, 0x2f83b4fc, 0xffb82f28, 0x0f0fb4ec, 0x08825506, 0x0f40f224, 0x09820909, 0x0f49912d, 0x3f491f49, 0xb8420349, 0x83b6f8ff, 0x1b42272e, + 0xfaffb813, 0x56832540, 0x830c1321, 0x08132156, 0x13211783, 0x2152831c, 0x0b840c13, 0x4f830620, 0x48851322, 0x20069243, 0x09fa742b, 0x2b2b2b26, + 0xfd103911, 0x32230682, 0x412f3232, 0x3c2206b0, 0x9518ed3f, 0x12220949, 0x8a183f39, 0x35240d8f, 0x35373634, 0x2320ed74, 0x11151616, 0x210ac141, + 0x31841101, 0x2a05d041, 0x4b342e05, 0x0da98b2a, 0x18551904, 0x201c437d, 0x07e0411d, 0x5634fe2b, 0x645144e9, 0xa4637774, 0x054f57fe, 0x77133b22, + 0x1c567d18, 0x0afd2b08, 0x521e321b, 0x01081b4e, 0x053701fb, 0x61171314, 0x4d616055, 0xc800ffff, 0xb2050000, 0x36020108, 0x00002700, 0xdf001701, + 0x93432800, 0x1e212206, 0x05e14508, 0x00030029, 0x06e1ff6c, 0x82140627, 0x17470809, 0x0f012400, 0xff0000b9, 0x0e3c40c0, 0x18013710, 0x02370d09, + 0x37100918, 0x1e3d073d, 0x243b2034, 0x1e4f074d, 0x244b2045, 0x0a6a0a5a, 0x020b1470, 0x01160302, 0x1c090615, 0x05041241, 0x09422208, 0x0200000a, + 0x42061816, 0x0883070f, 0x0c0cb735, 0x1a065502, 0xffb80402, 0x101740fa, 0x04550210, 0x820f0f10, 0x0d062205, 0x2005820d, 0x821e8322, 0x05cb501b, + 0x23520883, 0x0a042505, 0x55060f0f, 0xdc230f82, 0x840d0db4, 0xb4e82308, 0x08840c0c, 0x1a40f624, 0x09820909, 0x3f261f26, 0x0c1f0226, 0x1f294083, + 0x180c041b, 0x55020b0b, 0x08a6450c, 0x631c0c21, 0x04200a1d, 0x0c226b83, 0xa6452585, 0x093b6d0a, 0xfd332b28, 0x32322b2b, 0xa345332f, 0x33332e0a, + 0x5d30312f, 0x2b2b2b01, 0x13230301, 0x10a64501, 0x18331121, 0x270cfc7a, 0x7ffa2706, 0xbcfdfe98, 0x17017b18, 0xfe140627, 0xf9f90107, 0x097b18ec, + 0xffff211b, 0x08073b56, 0x00160245, 0x000000e7, 0xfec80001, 0x05cd045f, 0x002000d1, 0x0c0c40e3, 0x2d041c04, 0x04043d04, 0xb80f3512, 0x2040c0ff, + 0x55020f0f, 0x0f100f00, 0x090f0f02, 0x030b350e, 0x09163513, 0x1c202008, 0x000d0353, 0x49002a19, 0x08200a90, 0x0f84fe83, 0x0c0c1b3b, 0x06065502, + 0x0a03100c, 0x0f227314, 0x130f0122, 0x0e0a1414, 0x55021010, 0x073c560a, 0x3c560882, 0x56088205, 0x0882053c, 0x23063c56, 0x0909080a, 0xe6242a84, + 0x060f0fb4, 0x0c523383, 0x23218205, 0x0c0cb4e2, 0xf6231184, 0x820909b6, 0x216c2108, 0x20074858, 0x2300822b, 0x5d32fd32, 0x2908b36e, 0x002fed33, + 0x2f32fd3f, 0x3d563c3f, 0x2b712405, 0x453031ed, 0x21200a14, 0x21088a4d, 0x57431521, 0xcd042c0a, 0x8b2a4b34, 0xfd060ba9, 0x18d503c7, 0x2007a09a, + 0x083743fe, 0x0c0e7927, 0x33248f9e, 0x8247181d, 0x45b02007, 0x5e080613, 0x00020000, 0x045ffe6a, 0x007c0460, 0x0033002c, 0x0d4540d7, 0x261e1a1e, + 0x2b0d2904, 0x3a04341e, 0x3b1e3c0d, 0x4b044432, 0x59324b0d, 0x6c2a500d, 0x792b600d, 0x1232780d, 0x53151919, 0x3c010d1d, 0x30233333, 0x0f04293d, + 0x070b0b23, 0x1209233f, 0x0f0e202a, 0x2055020f, 0x40f8ffb8, 0x820b0b1d, 0x090e2209, 0x26058209, 0x0c1a1a20, 0x8340350c, 0x40352b0b, 0x55020c0c, + 0xf6ffb82d, 0x09843a40, 0x20001a22, 0x002a0783, 0x350f358f, 0x353f351f, 0xa4593303, 0x261b2206, 0x21428318, 0x36831026, 0x83082621, 0x04262824, + 0x55020d0d, 0x42348526, 0xfd3005ad, 0x105d322b, 0x2bed2bf4, 0x2f332b2b, 0x2f33113c, 0xed2d0882, 0x33ed3f00, 0x3f39122f, 0x2f3912ed, 0x07b344ed, + 0x200da779, 0x09524607, 0x2405b579, 0x37363435, 0x867c1826, 0x9b4a241b, 0x46030251, 0x34290565, 0xa98b2a4b, 0xfef80406, 0x947c18eb, 0x311f3a15, + 0x12301409, 0x081b4e52, 0x9e0c0e9f, 0x1232188f, 0x012a0112, 0x01120104, 0xa57c1842, 0x057f4407, 0x2a0cdd61, 0x012200df, 0xb60b0075, 0x620f0001, + 0x6a240a51, 0x6004e6ff, 0x0a675a18, 0x48fddf21, 0x23210513, 0x1f5a1820, 0x00c83209, 0x08760400, 0x00360201, 0x0100002f, 0xfe8d0017, 0x214986c0, + 0x9b620708, 0x00ab2409, 0x84510200, 0x864f2025, 0x828e2025, 0xb52f2f25, 0x03700270, 0xffb80302, 0x0c09b3c0, 0x07820237, 0x82114021, 0x04012908, + 0x049f044f, 0x06000102, 0x07365a18, 0x35115d25, 0x825d2b2b, 0x84002044, 0x0639086f, 0x00050014, 0x40a50009, 0x0b0c0716, 0x0808370d, 0x03020109, + 0x08013504, 0x0f0b0000, 0xb806010b, 0x1540eaff, 0x0837100e, 0x37100b0c, 0x04080606, 0x0e010814, 0x55021010, 0x07b45601, 0xb4560882, 0x08012306, + 0x18840909, 0x11ad9d18, 0x0fb4e424, 0x3383060f, 0x0db4ea23, 0x2308840d, 0x0c0cb4e6, 0xf8230884, 0x820909b6, 0x186c2008, 0x260af49c, 0xed322b2b, + 0x822f332f, 0x441120a7, 0x2c0806b0, 0x30312f33, 0x21212b01, 0x21113311, 0x13230303, 0x52fc7604, 0xc3e802c6, 0x05987ffa, 0x05dffad1, 0x0107fe64, + 0x000200f9, 0x030000bb, 0x27d38254, 0x00070003, 0x010d40a6, 0x0228d383, 0x01060302, 0xb8000805, 0x2320ca82, 0x0220ca82, 0x0025ca83, 0x1f020f00, + 0x21008202, 0xb4830c04, 0x0c0c0427, 0x0455020c, 0xce79181a, 0x05e97230, 0xffb80523, 0x82d884e8, 0x56ec2008, 0x05210530, 0x20d68304, 0xde791805, + 0x20ce820a, 0x21d982fd, 0xd9835d2f, 0x3f3f0023, 0x20d48533, 0x25ce8201, 0x33112303, 0xcc825403, 0xbcbcfc22, 0x82074745, 0x410220c5, 0x053005a3, + 0x000500d1, 0x40950009, 0x2f560722, 0x08080108, 0x2406a241, 0x07072d06, 0x05a74101, 0x41140421, 0xe0443395, 0xb8012205, 0x05e044ff, 0x80460882, + 0x41088205, 0xed281495, 0x2f33115d, 0xed2f3912, 0x2306eb5d, 0x3031ed5d, 0x82069341, 0x069341c0, 0xe9e99c2b, 0xdffad105, 0x0b015701, 0x06914100, + 0xcb826220, 0x0700033b, 0x24409100, 0x06065605, 0x01010201, 0x6f2d0708, 0x02067006, 0x0c000606, 0x092f5909, 0x29507818, 0x0c0cb424, 0xb1845502, + 0x88065942, 0x068041c3, 0x09100126, 0x01550609, 0x250d8041, 0x332b2bed, 0xbf825d2f, 0xc6833f20, 0xb782bd82, 0x03830120, 0xbcbc772d, 0xe7e7eb01, + 0xf4fb1406, 0x43000901, 0x052305d7, 0x18010838, 0x64081b61, 0x012307e9, 0x180b0c00, 0x26091b61, 0x040000b9, 0x828c065f, 0x4e512025, 0x0029055d, + 0xb60b0000, 0x18190001, 0xc75a180e, 0x00c82208, 0x22498c00, 0x5da200df, 0x499908c7, 0x851cdf21, 0x171a2749, 0x0125020e, 0x9383352b, 0x220f5765, + 0x828c00dd, 0xb70d2649, 0x29000203, 0x057e6526, 0x6a212784, 0x195c18ff, 0xd8dd230d, 0x25840000, 0x061a1d23, 0x844c8300, 0x20978325, 0x20e18498, + 0x05494435, 0x84f6ff21, 0x00022597, 0x0b062122, 0xe1827387, 0x84720321, 0x865520e1, 0x86382025, 0x131523e3, 0x6218120a, 0x4b8b0b49, 0x0a00df22, + 0x23214b86, 0x224b8920, 0x8c000092, 0xffdf224b, 0x234b8660, 0x030a1316, 0x415f4b87, 0x008d220f, 0x254b8414, 0x32330001, 0x25871f1a, 0x200f415f, + 0x06f75e8d, 0x06353623, 0x08238432, 0x00010040, 0x0459fe00, 0x00d105ee, 0x40a5001b, 0x1c070c2f, 0x3c072c07, 0x0c0c0407, 0x0d085310, 0x1a351801, + 0x08160203, 0x2a130b0b, 0x1f1d0f05, 0x031d4f1d, 0x01055b00, 0x02090902, 0x18140155, 0xdd76ffb8, 0x10182506, 0x55060f0f, 0xfc230f82, 0x840c0cb4, + 0xb6fa2308, 0x08820909, 0x18195b21, 0x2008e491, 0x21468219, 0x0f835502, 0x3e83b420, 0xf2200882, 0x11852c82, 0x0d0db728, 0x194f5502, 0xa9551901, + 0x2bf42106, 0xfd230082, 0x4be4322b, 0x3323069c, 0x4632fd3f, 0x112008dd, 0x13256118, 0x2111232a, 0xee042135, 0x0903ecfd, 0x240a6563, 0xfd320305, + 0x25de82ec, 0x1404fb21, 0x45512248, 0x361e2608, 0xb0210517, 0x3bfd8200, 0x0259fe3e, 0x009e05fd, 0x40ef0030, 0x0d080c30, 0x1e08191a, 0x2f082b1a, + 0x07083c1a, 0x3505dc52, 0x3e1c2520, 0x051f2022, 0x30181703, 0x183f2c30, 0x7f324f09, 0xf2520232, 0xb4ea2606, 0x5502100f, 0x20e38206, 0x82c183b4, + 0x52f42008, 0x062c05e0, 0x03062318, 0x328c001c, 0x0c25221d, 0x2530ee83, 0x020c0c0c, 0x1f1a2555, 0xffb81c1d, 0x101140de, 0x1c263782, 0x020f0f20, + 0x1f841c55, 0x14737a18, 0x82057b44, 0x05fc4a1a, 0xee200882, 0x2d059e6d, 0x0909021c, 0x1c4f5506, 0x1c021c7f, 0xb85c3188, 0x832b2006, 0x32322600, + 0x322b2bfd, 0x0862492f, 0x2f33ed2e, 0xfd3f005d, 0x39122f32, 0x33333f39, 0x47410882, 0x06252106, 0x2215e352, 0x18262223, 0x24179170, 0x02101c0c, + 0x66621804, 0xab14210c, 0x11a17018, 0x03070325, 0x41182c12, 0x1724086b, 0xcbb7102f, 0x11b17018, 0x00ffff22, 0x042f0082, 0x020108ee, 0x00370036, + 0x00170100, 0x42eeffdf, 0x0b2306c3, 0x42070608, 0x3608059f, 0xff3e0002, 0x077a03ea, 0x001b0005, 0x40d4001f, 0x1c040b51, 0x2a042a04, 0x3a1e2a1d, + 0x4a1e3a1d, 0x551e4a1d, 0x691c641c, 0x791c741e, 0x1f1f0e1e, 0x07100b1e, 0x180d1e3e, 0x2d09fd71, 0x02217f21, 0x1e1e1c1c, 0x8c000e10, 0x72180821, + 0x1a230d02, 0x1800080a, 0x2422f271, 0x020d0db4, 0x24278255, 0x0f0fb4e2, 0x055b6106, 0x840d0d21, 0x41ec2008, 0x0720058d, 0x26058d41, 0x02077f07, + 0x41208807, 0x8e410d8d, 0x32f62406, 0x412f3911, 0x3f26078a, 0xfd333333, 0x0f822f32, 0x01303124, 0x0350255d, 0x23112605, 0x33113335, 0x05721811, + 0x0313230d, 0x72181323, 0x7d231609, 0x18987ffa, 0x25150d72, 0x11fe5206, 0xcb69ef01, 0x00163d11, 0x005063db, 0x025b4079, 0x21000901, 0x50214001, + 0x0321a021, 0x012110ef, 0xbd012190, 0x50341182, 0x02218021, 0x4021108b, 0x03217021, 0x21c021b0, 0x900321f0, 0x02210682, 0x2a058359, 0x100321e0, + 0x90216021, 0x82310321, 0x21e0252b, 0x1f210f01, 0x34832a82, 0x02210523, 0xab661801, 0x00352608, 0x72715d11, 0x8302825e, 0x725d2206, 0x2302835e, + 0x35355e71, 0xb12d9183, 0x5704e1ff, 0x3602b107, 0x00005800, 0x24918201, 0x0d000000, 0x233d82b7, 0x1609171d, 0x6a087545, 0xdd240fcf, 0x75017800, + 0x24202785, 0x8806846a, 0x1881204d, 0x210a4561, 0x4d870add, 0x4d8a1820, 0x220f2364, 0x4207008d, 0x0d200767, 0x2206ff63, 0x6400ffff, 0x17240d23, + 0x68ff8d00, 0x20067745, 0x84258a0b, 0x5007214b, 0x3d20bf82, 0x1724bf82, 0x3900da00, 0x64094361, 0x05210d6f, 0x642582db, 0xda21056f, 0x05a74692, + 0x6f640b20, 0x01240808, 0x0000c800, 0xd1058a04, 0x81000500, 0x01030e40, 0x00030435, 0x070f0700, 0x03140201, 0xb4d2ffb8, 0x55021010, 0xfc230882, + 0x840b0bb4, 0x063e4a08, 0x09080323, 0x4d0f8409, 0x21820599, 0x8205474a, 0xb4d82408, 0x83060f0f, 0x05e44733, 0xa8481182, 0x45088205, 0x0322058c, + 0x985f066c, 0xed2b220a, 0x05384a5d, 0x30312f33, 0x23112101, 0x8a042111, 0x03c604fd, 0xfa2105c2, 0x209782df, 0x05a16c03, 0x00f00530, 0x00230017, + 0x40bd0027, 0x04000422, 0x9e180b06, 0x272020e1, 0x0921ba83, 0x3b058310, 0x26603525, 0x09262601, 0x15790976, 0x15341b02, 0x09342102, 0x2726270a, + 0x15180f26, 0xec59dc8b, 0x23118205, 0x0c0cb4e2, 0xf024de84, 0x0d0d2840, 0x732e0982, 0x01290f29, 0x291f290f, 0x1e03293f, 0x9e180f15, 0x682111df, + 0x22d38428, 0x845d5ded, 0xed2b3107, 0x2f393912, 0xed3f002f, 0x125ded3f, 0xed5d2f39, 0x29e09e18, 0x35210323, 0xe49e1821, 0xfdac2423, 0x1873028d, + 0x0828e99e, 0xb3060135, 0x69000300, 0x2406f0ff, 0x1d00e105, 0x37002a00, 0x1c408700, 0x322c1824, 0x2b062515, 0x09150932, 0x08031608, 0x32251e2a, + 0x0f6a0065, 0x00151e04, 0x56faffb8, 0x00370562, 0x000f1532, 0x18152b07, 0x14070425, 0x0c0c100f, 0x080f5502, 0x59f6ffb8, 0x0825055f, 0x020d0d0a, + 0x240f8255, 0x0a1140f1, 0x2d09820a, 0x1f383908, 0x6f393f39, 0x04399039, 0xfd82115d, 0x2b2b2b37, 0x17ed2bc4, 0x2fc41039, 0xed2b2fed, 0x3f2f005d, + 0x2f393912, 0x2e0385ed, 0x14013031, 0x06060706, 0x35231507, 0x77272626, 0x3626057f, 0x33353736, 0xe3621615, 0x11272109, 0x36211282, 0x09cb5236, + 0x16176b08, 0x59240616, 0x8af4554f, 0x57f686c5, 0x4c56594f, 0xc595f351, 0x4b4ff694, 0x3b40ce57, 0x5e6a8e3a, 0x4241329a, 0x8e6a8efd, 0x43413a3a, + 0x029b3140, 0x49d98cf3, 0xa6035d4f, 0x525a03a6, 0x888cd84a, 0x5e514ccc, 0x039b9b04, 0xd0494e62, 0x39a6637f, 0xfc023438, 0x2f390286, 0xacfeae3c, + 0x36017a03, 0x61aa3737, 0x2d3ab670, 0x2d58003c, 0x04433106, 0x0013007c, 0x40d90020, 0x2a032a16, 0x301a3c20, 0x0c838d18, 0xb8100a2b, 0x1540c0ff, + 0x1237100b, 0x8a8d1805, 0x0cb6271b, 0x0255020c, 0x1b58001a, 0x18002008, 0x261f7a8d, 0x0f0b40ec, 0x7555060f, 0xec240875, 0x09092f40, 0x92280f82, + 0x3f221f22, 0x101b0222, 0x1b2b5183, 0x0b16081b, 0x0855020b, 0x82090918, 0x83062005, 0x02082313, 0x0b820d0d, 0x0a638520, 0x0d0e5806, 0x2b2bfd24, + 0x07583232, 0x30312409, 0x52215d2b, 0x35201059, 0x200d5952, 0x568d1804, 0x2c4d0825, 0xb6fc3427, 0x1f227c02, 0xcfc7cadc, 0x02000047, 0xe1ff6a00, + 0x14067304, 0x28001900, 0x2940f200, 0x20051c03, 0x15261517, 0x0e3a0a3b, 0x213e1c3a, 0x0e490a4c, 0x214f1c4a, 0x0e6b1753, 0x207a0e7b, 0x3611217b, + 0x02264626, 0xe0ffb81d, 0x83cf83b4, 0x40210808, 0x371c121d, 0x110a181d, 0x1d171d37, 0x130f050c, 0x2601103e, 0x110a033f, 0x0c1d0011, 0xffb81a0f, + 0x832a84f8, 0x10402108, 0x1a26fe83, 0x0f14001b, 0x8018402a, 0x4121118f, 0xe0481810, 0x0f2a2d0a, 0x3f2a1f2a, 0x042a6f2a, 0x04230f0f, 0x6c596c83, + 0x18062007, 0x59176680, 0xa34c0761, 0xe4102205, 0x05cb552b, 0x11220e82, 0xcf443939, 0xfd3f2605, 0x33333f32, 0x3718822f, 0x5d30315d, 0x23001001, + 0x34110022, 0x36363736, 0x27262637, 0x21152135, 0x5509de42, 0xb9080a9f, 0xebfe7304, 0xebfef1ee, 0xb4454056, 0x66b44c5c, 0xcffd2a03, 0x965dde44, + 0x6e6ec276, 0x3f429142, 0x999caa55, 0xfe2702a6, 0x01cafef0, 0x8d06012f, 0x524840c5, 0x48873f11, 0x2e0a9eb3, 0xfb88549c, 0x56e487a4, 0x32353008, + 0xd0c97fae, 0x000100d3, 0x03e6ff6d, 0x007804ee, 0x4098003d, 0x26122643, 0x493b363b, 0x59184401, 0x6a185401, 0x640b6f01, 0x7a017918, 0x7918740b, + 0x0f357422, 0x2b3f2c0c, 0x1a16032b, 0x163e1e1a, 0x393d3d04, 0x1909033f, 0x0c09402b, 0x1b242b37, 0x2b0c1010, 0x00090419, 0x40c0ffb8, 0x37140928, + 0x7f3f0000, 0x023f803f, 0x0c0c1033, 0x1b335502, 0x07830809, 0x0b180929, 0x0955020b, 0x82090918, 0x3e862305, 0xfe82f610, 0x5d2bed33, 0x2b2f3311, + 0x2f391712, 0x2f2b2fed, 0x33ed3f00, 0x07e2562f, 0x3139ed23, 0x06794830, 0x2006f843, 0x07ff4335, 0x2d097c7b, 0x06060706, 0x17161415, 0x33331616, + 0x42182315, 0x67080b2d, 0x33373632, 0xce6bee03, 0x46a44f73, 0x79715745, 0x415f6c5b, 0x624fa240, 0x420d5aa4, 0x4e2d64c3, 0x3833232a, 0x35682d30, + 0x643e9e6f, 0x3431292a, 0x38652529, 0x0d47e866, 0x202a3040, 0x5e7f2728, 0x07269060, 0x595c8418, 0x20212275, 0x33cf1c21, 0x0f140b38, 0x443d2c43, + 0xa6030e0f, 0x4a111109, 0x154a353b, 0x3e481413, 0x0805bf42, 0x040f0532, 0x0011007c, 0x40a7001d, 0x35153a16, 0x45154a1b, 0x3f0e041b, 0x3e15050d, + 0x3f1b0409, 0xb80f0a03, 0x0b40c0ff, 0x0e370d0b, 0x0f0c090e, 0xb8120603, 0x82069142, 0xb6f42708, 0x55020c0c, 0x4b181b12, 0x3b260d68, 0x55021010, + 0x1a831a00, 0x1f90002f, 0x1f6f1f1f, 0x09041802, 0x18550209, 0x2013830c, 0xe8821818, 0x1e852119, 0x0a644b18, 0x2b2bf42f, 0x2b2bed2b, 0x33391712, + 0x3f002b2f, 0x220183ed, 0x4230315d, 0x102d0674, 0x16323300, 0x21152117, 0x34071616, 0x0bec6926, 0xe9e75408, 0x01ecfef1, 0x6a37ed1a, 0xfee0011d, + 0xc2443ee0, 0xa4a19aa4, 0xa8989ca7, 0xe7fe2e02, 0x3c01ccfe, 0x13011101, 0x09163b01, 0x7fc249a5, 0xcde0d6d7, 0x00d7dad1, 0x0a000100, 0xee030000, + 0x07005d04, 0x1e407d00, 0x3f040103, 0x00400506, 0x0002054f, 0x84020005, 0x0c0221b9, 0x0226c583, 0xb803051a, 0x4548eaff, 0xb4f42507, 0x55020f0f, + 0xe8231182, 0x840d0db4, 0x40f32408, 0x820c0b22, 0x362d8409, 0x0f0f0603, 0x03a05506, 0x030203b0, 0x0f080903, 0x4f093f09, 0x46097009, 0x5d200543, + 0x0282e282, 0x2bfd3325, 0x4c2f322b, 0xe182064b, 0x11214408, 0x35211123, 0xfeee0321, 0x6cfebc6c, 0xb803e403, 0xb80348fc, 0x020000a5, 0x64fe6800, + 0x7a04ea05, 0x24001d00, 0x1640b800, 0x0f741535, 0x09102102, 0x3e21370c, 0x050f041a, 0x17770322, 0xffb81701, 0x820f40f0, 0x3e173813, 0x0c050906, + 0x1e7a1475, 0xffb81102, 0x0d1c40c0, 0x11113710, 0x84041722, 0x067852cd, 0x12051a2c, 0x55021010, 0xf8ffb805, 0xc1831140, 0x1d840520, 0x0b040523, + 0x2215840b, 0x832640f4, 0x050527f5, 0x001b1e0c, 0xd8820c0a, 0x003a2008, 0x268f0001, 0x261f260f, 0x2660264f, 0x01260f04, 0x850c1b14, 0xedf61025, + 0xf4105d5d, 0x47ed2b5d, 0x2b32051d, 0x2b2bed2b, 0x2f333939, 0x3f005d2b, 0x5d2bed3f, 0x06833939, 0x20053744, 0x47e28205, 0x12330617, 0x06153337, + 0x16141502, 0x36361117, 0x03002033, 0x82232634, 0x05720809, 0xfea9feea, 0xdd82bbf3, 0x765e5551, 0x9488e585, 0x4b21bde1, 0x01300127, 0xc1e0c35d, + 0x4002d3ce, 0xc4fefdfe, 0x0172fe0f, 0x4551068e, 0x9f86c44a, 0x118a1201, 0xa7f6fe63, 0x0306e6bd, 0xfe0102e8, 0xb8fbfed5, 0x0ab2fcdb, 0x020000e8, + 0x59fefcff, 0xaeff1a05, 0x07000300, 0x0f402000, 0x01015002, 0x05500608, 0x0000040d, 0x2f020509, 0x2f331133, 0xe9550033, 0x30312605, 0x21352105, + 0x25038211, 0xe2fa1a05, 0x03831e05, 0xfe78ca32, 0xff0078ab, 0x002301ff, 0x05dc0300, 0x003600d1, 0x23083982, 0x04001701, 0x0000d901, 0x14401e00, + 0x0d200203, 0x0d6f0d5f, 0x00010d03, 0x05100500, 0x0503057f, 0x35355d2f, 0x00380383, 0x029a0001, 0x05c6032a, 0x001600f0, 0x1400b94d, 0x09b3e0ff, + 0xb815370c, 0x28080785, 0xf8ffb813, 0x1b171740, 0x13100137, 0x53080d0d, 0x030e0213, 0x00002a01, 0x2a0b1018, 0xc0ffb80d, 0x370a09b3, 0xfd2b2f0d, + 0x08a48232, 0x3f00ed54, 0x2f33ed3f, 0x2b333912, 0x012b3031, 0x1123012b, 0x2e272634, 0x06222301, 0x11231107, 0x013e1533, 0x15163233, 0x0eacc603, + 0x404d1615, 0xab418d41, 0x54a24bab, 0x2a02a69a, 0x6a461502, 0x43232424, 0x0345fd32, 0x453e68ab, 0x0200abb9, 0xe5ffc800, 0xcf82ca08, 0x004e2708, + 0x4035015d, 0x04180b21, 0x2e01194d, 0x554d2018, 0x66186a31, 0x794d6531, 0x79487513, 0x0d5a7352, 0x100e2005, 0xb2823d37, 0x82314021, 0x112d0808, + 0x04461a00, 0x403f033b, 0x3f370d0b, 0x3b3e433f, 0x3501354f, 0x371e353b, 0x24343e21, 0x2c033431, 0x29503457, 0x2b292901, 0x032c3456, 0x21c48207, + 0x29825740, 0x0e07073c, 0x2009033e, 0x4a4f3a2b, 0x3437024f, 0x20201a1f, 0x0606331a, 0x1d381a46, 0x01821a3e, 0x1a112008, 0x0f5f0000, 0x134f015f, + 0x0d083322, 0x3355020d, 0x020c0c12, 0x7f335f55, 0x33330233, 0x830c2a57, 0x0c2a2f0d, 0x55020909, 0x0e2b132a, 0x55021010, 0x5e72b82b, 0x4b088206, + 0x2b2106c7, 0x82208308, 0x05be4b0f, 0xea210882, 0x234c83b7, 0x2b012b70, 0x25060351, 0x2b2bfd2b, 0x0c833332, 0x5ded393c, 0xed2f3311, 0x2f2f3333, + 0xed393912, 0x12112f33, 0x39ed2f39, 0x2f005d39, 0x0e823f2f, 0x663f2b21, 0x122105be, 0x82168417, 0x825d2027, 0x622f202d, 0x2b2206ce, 0xc27a5d2b, + 0x35272505, 0x17161633, 0x2106bb62, 0xf2492726, 0x11232108, 0x06200182, 0x2009e26c, 0x27248332, 0x33353317, 0x36362115, 0x210a0d46, 0x18841415, + 0x01161623, 0x213d8334, 0xc76f2323, 0x08c90806, 0x6abee2ca, 0x17093dba, 0x61352d47, 0x43796645, 0x37622a55, 0x120f6e7e, 0x0c7cb5dd, 0xcc4d2f3b, + 0xf4bc30a0, 0x4748b486, 0xb5780a58, 0x73247f01, 0x3eb55531, 0x5bb14009, 0x563b7259, 0x722e642e, 0x365efa84, 0x57832f37, 0x9678112e, 0x01272f2f, + 0x3cc29b42, 0x3113d322, 0x4c1e1a16, 0x1644485a, 0x2610130b, 0x44256e95, 0x034efc26, 0x2f7945b2, 0xd5fd4d4d, 0x302dd105, 0xdc64932f, 0x301812dc, + 0x4935c924, 0x48464f4e, 0x0c180c17, 0x4f028e1e, 0x1f24754d, 0x2da3fd1d, 0x006d302f, 0x8900ffff, 0x3e06ebff, 0x3600d105, 0x00002c00, 0x2d001701, + 0x00005403, 0x0b403f00, 0x0101230f, 0x10100f21, 0xb8215502, 0x0fb4eeff, 0x2308840f, 0x0d0db4de, 0xfe240884, 0x0c0c1140, 0x1e220982, 0x05820b0b, + 0x09091022, 0x01210582, 0x050e452f, 0x835d3521, 0xfeaf2659, 0x053d0459, 0x205982db, 0x2259844c, 0x8228024d, 0x40183659, 0x60235011, 0x03237f23, + 0x0c500203, 0x0c7f0c60, 0x5d2f0c03, 0x21328235, 0x00820002, 0x27053c08, 0x16001406, 0x1f011a00, 0xff1700b9, 0x0d4540e8, 0x18183710, 0x19370c09, + 0x37100918, 0x15161503, 0x18031575, 0x10011718, 0x1342080d, 0x01050e04, 0x1717080d, 0x19011940, 0x830c0b10, 0x0c0b2190, 0x0b308a83, 0x0d30191a, + 0x0d700d50, 0x0dcf0daf, 0xffb80d05, 0x82051168, 0x84dc2008, 0x6d0882c9, 0x088205b1, 0xc985d220, 0x83080d21, 0x1e0d2538, 0x55060f0f, 0xe6241582, + 0x0c0c0d40, 0x1c220982, 0x05820909, 0xb8020d23, 0x059053ff, 0xf6220882, 0x46460d40, 0x04002705, 0x55021010, 0xa782b800, 0x0f0f1122, 0x2e220982, + 0x05820d0d, 0x87831c20, 0xf8241582, 0x0b0b0b40, 0x0e200f82, 0x0f822d83, 0x2f4bf020, 0xb6f0210e, 0x00225b83, 0x784e1c91, 0x2bed230a, 0x745d332b, + 0x465d2008, 0x5d2b0557, 0x3f002f33, 0xed3f3f3c, 0x5d3f3912, 0x21220871, 0x68421123, 0x07374405, 0x3336362c, 0x01151632, 0x05132301, 0x9218bc27, + 0xfc260ec9, 0x8af1fe72, 0x921802a5, 0x240809cf, 0x497c5d04, 0x03cdda52, 0x02d1fd3f, 0x0001002f, 0x026603d5, 0x00d10587, 0xb9270003, 0xe8ff0000, + 0x100d1440, 0xee471837, 0x0301280a, 0x02b10003, 0x8400ed2f, 0x2b012480, 0x82092b2b, 0x87022e68, 0xc288d6fe, 0x95fdd105, 0x00006b02, 0x21458302, + 0x45841804, 0x18000721, 0x2f274948, 0x01010046, 0x07030505, 0x3fb10403, 0x06060106, 0x33226684, 0x6a825d2f, 0x2f333c26, 0x0130313c, 0x83066347, + 0x88212070, 0x81022174, 0x7e847a89, 0x00042608, 0x08e3ff95, 0x00ed0507, 0x001f001b, 0x0037002b, 0x470c40ca, 0x561f481d, 0x681f591d, 0xb80b051e, + 0x1640e0ff, 0x20d5820e, 0x37048220, 0x071c1d1f, 0x021d171d, 0x1e1e291d, 0xffb8291f, 0x091240f4, 0x0c23370b, 0x4f2e0482, 0x7a1b400d, 0x0435752f, + 0xe8ffb817, 0x2c824a40, 0x82181121, 0x1f430804, 0x171b1b03, 0x4f032f51, 0x0d030203, 0x51110d03, 0x512f0209, 0x29402920, 0x35292902, 0x1e0a2351, + 0x011e4008, 0x2a321e1c, 0x26012600, 0x1c2a2c26, 0x2020061e, 0x01390f39, 0x0100200d, 0x2a140000, 0x82ed2f06, 0x5d3323d6, 0xa7443311, 0xed5d2406, + 0x465d2f2f, 0x5d25050d, 0x33ed3fed, 0x820e8233, 0x2b3f2222, 0x82f1822b, 0x10872af7, 0xc0875ded, 0x012b2b00, 0x0859785d, 0x21057044, 0x2e49012e, + 0x33372508, 0x09230109, 0x490b857f, 0x20080b4c, 0x931e2d03, 0xddd9c04e, 0x3f7f41bc, 0x39733c0e, 0x717b7f6d, 0x0e257a49, 0xf4fcf502, 0x020c03a5, + 0x10417f8a, 0x12be023a, 0xc9d2e632, 0xad2121f2, 0x9c953332, 0x23429896, 0x2ffa6802, 0xccfbd105, 0x080f327f, 0x0f000254, 0x8602e8ff, 0x1b00d305, + 0x91002b00, 0x1d530d40, 0x1c701d62, 0x0b181603, 0xb8053711, 0x3740f0ff, 0x00370f0b, 0x1c0b011a, 0x051b1b05, 0x0f121216, 0x25091652, 0x47030550, + 0x12120108, 0x4008291f, 0x2f371411, 0x1c080108, 0x001a001b, 0x2a0b0308, 0x8a591e01, 0x0c0b2811, 0x0155060c, 0x82090906, 0xffb82605, 0x1410b3c0, + 0x06674437, 0x3317ed28, 0x2f32332f, 0xc6552b5d, 0x08a16205, 0x2b391739, 0x5d30312b, 0x34113713, 0x16323336, 0x07021415, 0x33161411, 0x5d373632, + 0x352506e2, 0x36361307, 0x083e4335, 0x06066408, 0x7bb10f15, 0x787c606f, 0x1a1b1da5, 0x71376944, 0x4f6b5c39, 0x0d2f62f8, 0x0f190a0d, 0x0b06190f, + 0xeba6010c, 0x99e2c701, 0xfe5c6d82, 0x61fee6f7, 0x4a212b59, 0x722b2ca2, 0x0262e17f, 0x3780a92b, 0x0c11301e, 0x150e0c0d, 0x0200586e, 0x00009200, + 0xb0034204, 0x07000300, 0x15402500, 0x0101cb07, 0x8503cb05, 0x03002f06, 0x03300310, 0x5d2f0303, 0xed2f33ed, 0x05832f00, 0x13303131, 0x13211121, + 0x92112111, 0x50fcb003, 0x8318034c, 0x64033006, 0x1803e8fc, 0x00010000, 0x02bd0183, 0x828c0352, 0x4017384f, 0x0302020b, 0x02000000, 0x02020230, + 0x2f335d2f, 0x2f332f00, 0x82013031, 0x5202293b, 0x8c0331fe, 0xcf0131fe, 0x338a1e82, 0x23000728, 0xcb061340, 0x83820202, 0x00cb0425, 0x87cb0600, + 0x83818b3d, 0x82052041, 0x25458385, 0xc9fe8301, 0x4b853701, 0xc9fe4c22, 0xb1338182, 0x22048800, 0x0b00f903, 0x14402100, 0x030f0909, 0x824f032f, + 0x060629c4, 0x00900000, 0x000300a0, 0x8f828a85, 0x343acb82, 0x00323300, 0x23001415, 0x01b10022, 0x01b6b702, 0xb6fefe02, 0x02fefeb7, 0x0a83b740, + 0xfeb6b725, 0x830201fe, 0x017026a3, 0x036602aa, 0x335582a0, 0x40650017, 0x2310060b, 0x10063726, 0x00371a17, 0xb3f0ffb8, 0x07830c82, 0x82154021, + 0xcb122710, 0xcb0c0606, 0x1c830900, 0x0b100925, 0x8303370e, 0x83188221, 0x13402107, 0x15241082, 0x0f0303cb, 0x20272182, 0x60093009, 0x41090409, + 0x2b20055f, 0x63410082, 0x27088205, 0x0130312b, 0x14151632, 0x20065366, 0x71d71817, 0x34353207, 0x686b0126, 0x68689393, 0x49699293, 0x48486766, + 0x83958267, 0x2903830e, 0x4948674c, 0x48496666, 0xbd670067, 0x3c072207, 0x7b511802, 0x00d83007, 0x006b0131, 0x0002b60a, 0x07060b0c, 0x82352b25, + 0xff682623, 0x051d04e1, 0x282382d1, 0x01000044, 0xd9d80016, 0x23218400, 0x261d3736, 0x2b6a2185, 0x00d6240f, 0x827501a9, 0x00012523, 0x150f2b2f, + 0x296a2385, 0xf4d6350f, 0x40110000, 0x2640010c, 0x00022650, 0x0f062226, 0x355d2b25, 0x4d849383, 0x6a500721, 0xda2208c3, 0x4d86a800, 0x4d8d2c20, + 0x6adb0521, 0xda2108c1, 0x274d85f5, 0x24302420, 0x25240002, 0xc8244d89, 0x9d040000, 0x2820e184, 0x1724bd82, 0x3300d800, 0x0125e184, 0x020f0e00, + 0x249b8503, 0x04e6ff6a, 0x20e18460, 0x82238248, 0x85f720e1, 0x232223e1, 0x21850012, 0x08214584, 0x856f8201, 0x00d92245, 0x21938640, 0x458c0c12, + 0x828c0621, 0x2f458523, 0x0000fed9, 0x020a400f, 0x00012670, 0x15152026, 0x4b84df87, 0x0a234318, 0x4f00da22, 0x918f4b86, 0x09177b18, 0x8800da21, + 0x85182091, 0x0c817091, 0x00170125, 0x86d000d6, 0x25292345, 0x23850f07, 0x310f8d70, 0x0000fbd6, 0x020c4011, 0x35403530, 0x31350002, 0x7341231a, + 0x05e32209, 0x289384a2, 0x0100002a, 0x00da0017, 0x214d86ce, 0x4d8c2827, 0x93830520, 0x4105db70, 0x02280673, 0x33603350, 0x34330002, 0x00374d86, + 0xfe730001, 0x05a20559, 0x003800ec, 0x092040f7, 0x070e0606, 0x18061d26, 0x321669bd, 0xe0ffb82c, 0x0c092340, 0x36323237, 0x280d2e53, 0x18352203, + 0x2c107abd, 0x2a003131, 0xe6ffb82b, 0x020f0fb4, 0x76088355, 0x2b3905de, 0x02090912, 0x1f2b0f55, 0x762b022b, 0x10220109, 0x272b0422, 0x21100904, + 0xa1bd18b8, 0x04252909, 0x55021010, 0x0b0b1025, 0xb8220582, 0x4284f6ff, 0xffb82524, 0x3b83b4e4, 0xea240882, 0x0c0c1d40, 0x75251b82, 0x403a0f3a, + 0x8fbd183a, 0x3968270f, 0x2b2bf410, 0xd2645ded, 0x2bed2b06, 0x39171233, 0x2f5d2f2f, 0x16822b5d, 0x20058861, 0x05a04bed, 0x68ed5d21, 0x012f0745, + 0x34055d2b, 0x24222726, 0x35022627, 0x18210010, 0x201796bd, 0x12925b11, 0x03820333, 0xe0fead02, 0x01706766, 0x7f6c01a1, 0x12990901, 0xa8bd181f, + 0xd45a2412, 0x5b03015e, 0x6b2b0a9a, 0x5f0f2b15, 0x23016160, 0x186501c3, 0x2716b9bd, 0x462981fd, 0x16250e0f, 0x2207a95b, 0x42000300, 0x0035061f, + 0x00300023, 0x403f0134, 0x34322443, 0x20330232, 0x3d37100d, 0x459f1813, 0x342f3e20, 0x344f343f, 0x33343403, 0x05221e33, 0x28152112, 0x07041e40, + 0x40c0ffb8, 0x020d0d26, 0x489f1855, 0x31313609, 0x33603350, 0x00333302, 0x01060f18, 0x36242106, 0x020f0f40, 0x539f1855, 0x0a40230c, 0x12820c0c, + 0x06001a23, 0x3aaf5518, 0x1b40ee30, 0x55060909, 0x1f369200, 0x02363f36, 0x5483082b, 0x0c4c9f18, 0x79831920, 0x9f181820, 0x8521114c, 0xbf7f1835, + 0x3d9f1808, 0x32322812, 0x12115d2f, 0x415d2f39, 0x2b3108f1, 0x3912ed3f, 0x33113f39, 0x5d2f332f, 0x015d3031, 0x4b9f182b, 0x03133231, 0x43040123, + 0xf4fefefe, 0x0a52a959, 0x6064c82e, 0x4f9f187e, 0xb334291b, 0x7f1101f3, 0xf6fee4fe, 0x23549f18, 0xfe8e053c, 0x0076018a, 0xc800ffff, 0x3b050000, + 0x36020108, 0x00002b00, 0xd6001701, 0xdb437600, 0x0c102306, 0x29440b06, 0x00b92405, 0x845f0400, 0x864b2023, 0x82222023, 0x401a3323, 0x1b4f0112, + 0x1b9f1b6f, 0x26111b03, 0x171b0001, 0x2f820808, 0x5d2b0027, 0x00020035, 0x08578220, 0xd105e325, 0x17001300, 0x0eb73901, 0x04160112, 0xb80b5208, + 0x0f40c0ff, 0x55020f0f, 0x0f0c400b, 0x0c0b0b37, 0x83173505, 0x831c2013, 0x17003713, 0x17021710, 0x0317100b, 0x030c0704, 0x12000007, 0x0303150f, + 0x20821914, 0x0d0db42b, 0xb8025502, 0x10b4faff, 0x23088410, 0x0b0bb4f4, 0xe6200884, 0x0ea14118, 0x0b40ea22, 0x12222b84, 0x1f840c0c, 0x2940f62a, + 0x55060f0f, 0x0d0d0a02, 0x0c210583, 0x2105830c, 0x05820909, 0x0f197832, 0x50194019, 0x09090319, 0x03160e0b, 0xb8071406, 0x82066a5b, 0x18fc2008, + 0x7f17b4c6, 0xe6211141, 0x826083b4, 0x82ec2033, 0x550621a5, 0x66830884, 0x6a5b0882, 0x6c072205, 0x0c6a5b18, 0x33391722, 0x4e082f7f, 0xed200540, + 0x00271283, 0x17123f2f, 0x52712f39, 0x1382068e, 0x01303126, 0x11231123, 0x07a24e18, 0x15332808, 0x15333521, 0x21350133, 0xa8e30515, 0xc619fdc6, + 0x02c6a8a8, 0xfea8c6e7, 0x0419fd92, 0x02abfb55, 0x0427fdd9, 0x82f08c55, 0xfe2f0800, 0x00cccca8, 0x00130001, 0x065f0400, 0x011e0014, 0x031c4024, + 0x751d161d, 0x1417031d, 0x1111510e, 0x080d1812, 0x12041b42, 0x080d0101, 0x6b020f15, 0x0883079c, 0x18091959, 0x23086992, 0x0b1140fc, 0x2a30a118, + 0xf94de420, 0x0d082c06, 0x0055060d, 0x40ecffb8, 0x82090921, 0x20912a09, 0x2060201f, 0x17151402, 0x06b74e03, 0x2b05c34e, 0x0d0f111a, 0xb4deffb8, + 0x55021010, 0xe0200882, 0x2305d341, 0x09090c0d, 0xba4e0f84, 0xb4f62308, 0x11860c0c, 0x4106b64e, 0x33820573, 0xbf4eec20, 0x830a2006, 0x880d2168, + 0x0b165018, 0xfd323227, 0x32172b2b, 0x0c84415d, 0x2f2b2b22, 0x5108654e, 0x31220540, 0x644e5d30, 0x3523290e, 0x15333533, 0x11211521, 0x20056c4e, + 0x32a11804, 0xa6a6290a, 0xfe4101bc, 0x63bc58bf, 0x0c38a118, 0xf4042708, 0x869a9a86, 0x5249edfe, 0x0200cdda, 0x00002c00, 0xc8073303, 0x25000b00, + 0x00b9b500, 0x40d0ff1b, 0x37100b4a, 0x0482300e, 0x0c0c3b08, 0x1c0f5215, 0x1c021c1f, 0x22191c19, 0x010f7052, 0x04090f0f, 0x0a030632, 0x08013203, + 0x0c0f2825, 0x0c020c1f, 0x0c192818, 0x0b086d27, 0x05140a5a, 0x03195a02, 0x0210100c, 0xc2180355, 0x0843232b, 0x14032205, 0x05085e0f, 0x09b6fc28, + 0x03550609, 0xad46266d, 0x2b2b3306, 0x32ed322b, 0xe432edfd, 0x2fed2f33, 0x3f00ed5d, 0x028232ed, 0x0a823320, 0x23079a4d, 0x2b2b3031, 0x0b4fc218, + 0x0606132f, 0x27262223, 0x22232626, 0x36230706, 0x05fd7e36, 0x36323324, 0xc2180237, 0x71080869, 0x667d075e, 0x2d265334, 0x2d30203c, 0x7e038802, + 0x28513368, 0x2e1d432a, 0x04980131, 0xfb9898a1, 0x9830075f, 0x2b262497, 0x884b5b2a, 0x282524a6, 0x00475b29, 0x00f2ff02, 0x06410200, 0x0003003c, + 0x40c5001d, 0x73067c50, 0x04040213, 0x4014aa0d, 0x14370c09, 0x1a111411, 0x020707aa, 0x1d080105, 0x091204ad, 0x0455020d, 0x370f0940, 0x11ad1004, + 0x0d820d2a, 0x091a112c, 0x1155020c, 0x1f011f7f, 0x1e670492, 0x1811200d, 0x2028709f, 0x061f67b4, 0x2205d961, 0x64ffb801, 0x4a1805be, 0xec570a7e, + 0x822b2006, 0x325d2b00, 0x322b2bfd, 0x2b2f5ded, 0x0383ed2b, 0x3f3f0022, 0x23069453, 0x2f33ed2b, 0x22054a42, 0x41141333, 0x1522092f, 0x2f413423, + 0x35330809, 0xbcbc7701, 0x285067ca, 0x2d201e3a, 0x70212317, 0x322f4e68, 0x162c2120, 0x5d042124, 0x8281df01, 0x2223201a, 0x82814145, 0x22231f1b, + 0x00003e48, 0x825f0002, 0x07ff2e04, 0x000b003c, 0x408b000f, 0x0d530e15, 0x092c420d, 0x3f0f2f3d, 0x0e0f020f, 0x40c0ffb8, 0x370d0b1f, 0x6d110f0e, + 0x5a0b080a, 0x0503140a, 0x420e5a02, 0x0d2d2b33, 0x55020d0d, 0x0f0f0e03, 0x6d035506, 0x08314310, 0x32f43224, 0x0382fd10, 0x2f33e629, 0x005d2f2b, + 0x8232fd3f, 0x21f08202, 0x1f423031, 0x3521220c, 0x09094221, 0x60fd2a24, 0xf441a002, 0x0a062606, 0xff02009a, 0x20c382fc, 0x062f5136, 0x27408436, + 0x01015302, 0x7f050506, 0x02027000, 0x097f0200, 0x00920901, 0x200d5c6a, 0x395d6a02, 0xa418fc20, 0x3227112c, 0x322b2bfd, 0x822f5de6, 0x7f2f20c0, + 0x2e080839, 0x11230321, 0xfd360233, 0xbf3a02c6, 0x3705bcbc, 0x042ffa9a, 0x0002005d, 0x02000080, 0x00d307df, 0x0019000b, 0x0c1f408f, 0x12011270, + 0x43aa1612, 0x19350ba2, 0x0b400c29, 0x130c370e, 0xffb81229, 0x0b1d40c0, 0x0c12370f, 0x08ab431b, 0x77411220, 0x0db6272a, 0x0355020d, 0x9b431a6d, + 0x08994307, 0x2fed2b23, 0x099a432b, 0x2f33ed24, 0x7341335d, 0x06142c0e, 0x35262223, 0x33161433, 0x41353632, 0x0a29097d, 0x97999c93, 0x494d459e, + 0x06824148, 0xa83b0729, 0x86a8cfcf, 0x828a6e72, 0x820120dd, 0x06303fdd, 0x000d0068, 0x409a0011, 0x06060015, 0x0303500a, 0x0d0f0510, 0x0b400029, + 0x07003710, 0xd3850629, 0x06371032, 0x1301137f, 0x0c0e0092, 0x55020909, 0x0c0c0c0e, 0x1a250582, 0x010f7f06, 0x07b2450f, 0x54180882, 0xee210f5d, + 0x18d183b4, 0x6b0b6654, 0x118205f7, 0x22059941, 0x4212880f, 0x4c43085d, 0x5de62105, 0x0282ea82, 0x3f2f0024, 0xe9822f33, 0xe751e882, 0x08dc8606, + 0x11230334, 0x8b300233, 0x928e8a8c, 0x44414541, 0x06bcbc27, 0xbec09a68, 0x626b7a9c, 0x0498f983, 0x0001005d, 0x035ffe89, 0x00d1051c, 0x408d0020, + 0x09201c37, 0x2443370c, 0x010c3107, 0x13171708, 0x180d1b53, 0x1e2a1018, 0x22020b1e, 0x410a2243, 0x40202aa9, 0x700c2143, 0x204309cd, 0x12112207, + 0x23bc8339, 0x32fd3f00, 0xfd21c782, 0x2b078232, 0x212b3031, 0x11333523, 0x15213523, 0xbc70c282, 0x08836f0b, 0xeb740137, 0x4c02c3c3, 0x06c2c3c3, + 0x21584209, 0x24091341, 0x9a872251, 0x06bc4109, 0x1c982108, 0x50512629, 0x0a9e0b13, 0x228ca00b, 0x00020035, 0x025ffe8e, 0x00db0546, 0x001b0003, + 0x081c40b3, 0x3a08eb83, 0x0753171b, 0x0244010d, 0x370d0b40, 0x050e0302, 0x0404110d, 0xb80a2a14, 0x0c40c0ff, 0x0a37170b, 0x1d7f0e0a, 0x00921d01, + 0x40fcffb8, 0x020c0c1a, 0x0f600055, 0x0209090c, 0x830c0f55, 0x1a0f270d, 0x0e7f6001, 0xd6410e01, 0x41088207, 0xfb4106d6, 0xffb82106, 0x8205d641, + 0x05894718, 0x0f230884, 0x8255060f, 0x05d64108, 0x1c880e22, 0x2909d641, 0x2b2bfde4, 0x5de62be4, 0x947d3311, 0x332f2505, 0xed2b3f3f, 0x23051141, + 0x33352301, 0x25054f46, 0x37363435, 0x2a753311, 0xd483230c, 0xff82c3d4, 0x259c8527, 0x063cbc08, 0x05104107, 0x18052408, 0x0a99f8c3, 0x3f8e9e0b, + 0x0b04196f, 0x361aa3fb, 0x1350511b, 0x00ffff0b, 0x03ebff2c, 0x0201084d, 0x4a2d0036, 0xff28059f, 0x0075016c, 0x1a01b114, 0x3508fa83, 0x370e0b09, + 0x04161a00, 0x2b2b2515, 0xff020035, 0x0259fec2, 0x008c06af, 0x001c0015, 0x0a2940c5, 0x02011c01, 0x1b651b55, 0x18031b75, 0x1b1b1a16, 0x3e121a1a, + 0xa04c0515, 0x1a1a2a05, 0x1301134f, 0x0601067f, 0x0b904c16, 0x1740f222, 0x2d05904c, 0x03160613, 0x10100e15, 0x0c155502, 0x05820b0b, 0xdeffb822, + 0x2305bc48, 0x09090815, 0xe4200f84, 0x2105ba74, 0x31830215, 0xffb81526, 0x0d0db4f2, 0xec251884, 0x060f0fb4, 0x23118255, 0x0c0cb4f6, 0xe42e0884, + 0x09090a40, 0x15705506, 0x1e921501, 0xbd18f410, 0x2b2908da, 0xed32172b, 0x2f2f2b2b, 0x05634c5d, 0x2f32fd2c, 0x2f33ed3f, 0x39122f33, 0x4e185d39, + 0x2f080b60, 0x32331616, 0x36363736, 0x35231135, 0x03233721, 0x33132303, 0xa8c80902, 0x0a2c8328, 0x482d5f1c, 0x0d161658, 0xa6a501e9, 0x9bb8b99f, + 0xc41be3e4, 0x0dfca718, 0x01b42708, 0x0100ff00, 0xffff007b, 0x59fecd00, 0xd1057505, 0x2e003602, 0x16010000, 0x00fbdc00, 0x01b11500, 0xecffb81a, + 0xbf830a40, 0x0c1a0026, 0x2b250005, 0x2605656d, 0x0459fec1, 0x821406af, 0x824e202d, 0x0017302d, 0x007cffdc, 0x40110000, 0x1a30010c, 0x83021a40, + 0x250a242b, 0x82355d2b, 0x0021081c, 0x040000c1, 0x005d04af, 0x40e1000b, 0xd802285b, 0x0309db01, 0x0d0f0109, 0x021d011f, 0x012d0d1f, 0x5da8182f, + 0x01053221, 0x020b0805, 0x0a700a60, 0x000a0a02, 0x0d200d00, 0x53a81840, 0x181a200f, 0x242e47a8, 0x060f0fb4, 0x23338255, 0x0d0db4f6, 0x4e4a0885, + 0x06937005, 0x4c188920, 0x2b2708fe, 0x2bfd2b2b, 0x4d5d322b, 0xa81805da, 0x2e083c44, 0xd1fd5d04, 0xfcfd2f02, 0x00010000, 0x0459fec8, 0x00d10576, + 0x40b7001a, 0x09200c1d, 0x1111370c, 0x0d0d5315, 0x35040302, 0x10080107, 0x752a1810, 0xf222088f, 0x18821c40, 0x0e0a552f, 0x55020b0b, 0x05010a0a, + 0x1c0f1c05, 0x47cf7001, 0x4c086572, 0x012205bb, 0x2f4a1b6c, 0x2b2b2209, 0x05ce57ed, 0xdf502f20, 0xed3c2907, 0x32fd3f3f, 0x2b30312f, 0x2105d570, + 0x8e6d2115, 0xbf022812, 0x02c609fe, 0x6ce3fee8, 0x06270c2f, 0xdffad105, 0x6c2f12b0, 0x2d08091c, 0x01003e1e, 0x59fe0500, 0x1406e901, 0xa3001800, + 0x200a2e40, 0x0f370c09, 0x0b53130f, 0x0401020d, 0x0e0e0801, 0x16162a08, 0x011a7f01, 0x2948921a, 0x30e5490d, 0x28058e46, 0xfcffb801, 0x060d0db4, + 0x13ee4955, 0xf98a1920, 0x2bfd5d28, 0x125de42b, 0xed822f39, 0x2f3f0022, 0x2324f588, 0x33113311, 0x4e08f392, 0xbc8e4901, 0xae05016c, 0x28642585, + 0x284e1809, 0x0601525e, 0x1200fa14, 0xaca22437, 0x0ba00c0c, 0x15574f17, 0xffff0033, 0x59fec800, 0xd1053805, 0x31003602, 0x16010000, 0x00fedc00, + 0x0e401300, 0x30162001, 0x03164016, 0x040a1600, 0x542b2500, 0xb92605fb, 0x5f0459fe, 0x3b717c04, 0x8bdc2108, 0x002a2b85, 0x20231023, 0x23000323, + 0x2b850d17, 0x83055142, 0x00540857, 0x40480116, 0x6107001f, 0xa1077107, 0x070c0407, 0x071b0c0b, 0x07460736, 0x07650754, 0x01b00775, 0x070a07b0, + 0x40c0ffb8, 0x37110b43, 0x0f010676, 0x1f060201, 0x26061501, 0x34013601, 0x44014606, 0x53015606, 0x79066006, 0x0e067001, 0x5a010604, 0x02065501, + 0x2f069b42, 0x06080407, 0x04010a03, 0x10100108, 0x0201060a, 0x0c0eca18, 0x0c0cb627, 0x13075502, 0x078a5c0a, 0x0b230884, 0x8255020b, 0x40e22408, + 0x820f0f33, 0x09082209, 0x20058209, 0x23298312, 0x0d0d260a, 0x78270b82, 0x40180f18, 0x84020218, 0x0c022119, 0x02251983, 0x10100413, 0xf3c91810, + 0xb4e4212f, 0x2906297a, 0x0d0db4ec, 0xb8045506, 0x9182ecff, 0x6c210882, 0x0ad54117, 0x2b2bed22, 0x2307bc53, 0x2b2bfd2b, 0x29053566, 0x333f002f, + 0x123c3f33, 0xda423939, 0x014b0805, 0x5d5d7172, 0x715d2b00, 0x11013504, 0x01211123, 0x14113311, 0x26222306, 0x16333527, 0x04323316, 0xb901fd80, + 0x84023301, 0x27b4ceb9, 0x160b2551, 0x947f1e3a, 0xfa3e058a, 0xfbd105cc, 0xfa6004a0, 0x08d1bf18, 0x0a05a806, 0x41000100, 0x200806c1, 0x18012600, + 0x15031c40, 0x1516190c, 0x10041575, 0x1342080d, 0x0d050e04, 0x221e1e08, 0x1d0d1a53, 0x138f4f1d, 0xffb81722, 0x82058f4f, 0x059e5008, 0xf8280882, + 0x0f0f1740, 0x0c175502, 0x08220584, 0x0b820909, 0x0c0c2222, 0xb8220582, 0xfa82feff, 0x8e4f0884, 0x04172506, 0x55060d0d, 0xec243482, 0x09091c40, + 0x91260982, 0x60281f28, 0x495e0228, 0x0c894f0e, 0x22103d5e, 0x830b40f6, 0x089b4f5e, 0x2182f020, 0x82550621, 0x17894f33, 0x6f412720, 0x2bfd220a, + 0x10864f2b, 0x492f3321, 0x3f29052b, 0x3912ed3f, 0x045d3031, 0x14e85d35, 0x240c7241, 0x03363736, 0x0ef35da3, 0x27b4cc39, 0x160b264e, 0x614c1a3c, + 0x56251617, 0x874d4b02, 0x4c292a26, 0x5dbefc3b, 0xfd2b06fc, 0x07ccbf0f, 0x0a05a806, 0x58262626, 0xe13a0549, 0x4607da05, 0x32003602, 0x17010000, + 0x9b00d800, 0x0a007501, 0x260002b6, 0xfb570f27, 0x04e12408, 0x82d10571, 0x82522023, 0x00162423, 0x8400e3d8, 0x1b1a2721, 0x2b250006, 0x5918ff35, + 0xd92211b9, 0x45869c00, 0x8c242a21, 0x8c062145, 0xd9214588, 0x214585e4, 0x4587181e, 0x59fec824, 0x67849805, 0x67843520, 0x00f6dc27, 0x02b11f00, + 0x07714924, 0x402e0883, 0x0209090a, 0x20240055, 0x2b250d05, 0x28832b2b, 0x1b003208, 0x720359fe, 0x27005d04, 0x2d40d700, 0x0d100d00, 0x21030d20, + 0x370c0920, 0x130f090c, 0x0a431713, 0x091c050f, 0x02262608, 0x250d2253, 0x052a1f25, 0x051a650c, 0xb8130922, 0x82063057, 0x46f02008, 0x13290550, + 0x29402913, 0x0c022970, 0x2824841b, 0x0c0c0c1b, 0x1a1b5502, 0x070e4a09, 0x0e4a0882, 0x84092006, 0x4a0f8220, 0x08820505, 0x8205174a, 0x050e4208, + 0x0d231a84, 0x8355060d, 0x05494708, 0xbd820920, 0x88210f82, 0x0f0e4228, 0x2f33112a, 0x39112b2b, 0x32fd2b2f, 0x22060942, 0x823c3f2f, 0x1211260b, + 0x2b303139, 0x08a1625d, 0x33112323, 0x05725015, 0x50231521, 0x78450581, 0x4e3c370c, 0x01525e28, 0x70bca602, 0x2c3159ab, 0x4f2a0a2c, 0x4ba25736, + 0x82450184, 0x17fa3406, 0x3315574f, 0xa55d0423, 0x07054b5a, 0x4d090ac1, 0x45fbfc3d, 0x0021078d, 0x855418ff, 0x00d62311, 0xa55a014a, 0x31352205, + 0x06eb411a, 0x54186e20, 0xd62d0e83, 0x0f0000af, 0x7f010a40, 0x38000138, 0x25258334, 0x0000355d, 0x00820001, 0xee042a08, 0x0f00d105, 0x26405d00, + 0x32000a0d, 0x090f0303, 0x03063504, 0x1f110f0f, 0x03114f11, 0x080b020b, 0x000d095b, 0x04021409, 0x06a84414, 0x0cb4fa29, 0x0455060c, 0x4afcffb8, + 0x04320505, 0x01054f5b, 0xf45d2f05, 0x322b2b2b, 0x103939ed, 0xb94e33e4, 0x32fd2105, 0x2107af52, 0xf6652101, 0x21152305, 0x03822111, 0x1402233d, + 0x4c01b4fe, 0xee04ecfd, 0x4c01ecfd, 0x02c6b4fe, 0xae018fe4, 0x52feb0b0, 0x821cfd8f, 0x3e480897, 0xfd02eaff, 0x23009e05, 0x2140c200, 0x0d092004, + 0x07151837, 0x0e0a0a51, 0x0b140f03, 0x0e0f113e, 0x1f232305, 0x4f09033f, 0x02257f25, 0xc0ffb816, 0x0b092840, 0x07161637, 0x258c0013, 0x0c070909, + 0x15110e0a, 0x090c1804, 0x26091a69, 0x40070c1a, 0x7337100d, 0x40272238, 0x020d0d11, 0x83220755, 0x140723ee, 0x29550d0d, 0x83b62005, 0x880722f4, + 0x08344c24, 0x2b24ec83, 0x2f39172b, 0x1026e482, 0x391132f6, 0xa5182b2f, 0x11200b28, 0x2b20fb87, 0x23062973, 0x33352335, 0x220a2d73, 0x64211521, + 0x33230599, 0x18373632, 0x2c0937a5, 0x01bc7f7f, 0x017cfe84, 0x08d3fe2d, 0x3da51818, 0xa82b080b, 0x9e240186, 0xbffe4101, 0x86dcfe9e, 0x2b635853, + 0x091b2528, 0x00ffff00, 0x05e1ffb2, 0x02c80729, 0x00380036, 0x00170100, 0x426100d7, 0x2b23060f, 0x431d0d1e, 0xb12605fb, 0x5704e1ff, 0x23825306, + 0x23825820, 0xd700162d, 0x0a000006, 0x240001b6, 0x85160917, 0x20458521, 0x22458846, 0x866300d8, 0x21202145, 0x0521458c, 0x214588d1, 0x458501d8, + 0x8c1a1921, 0xab5d1845, 0x88d9200a, 0x8e242045, 0x888c208b, 0x86d92045, 0x851d2045, 0x004f088b, 0xfeb20001, 0x0529055f, 0x013400d1, 0x232e4010, + 0x3d182312, 0x39213d09, 0x4c094c22, 0x77224b21, 0x0a177713, 0x0c092033, 0x2a2e2e37, 0x1c0d3253, 0x030d0624, 0x0a063415, 0x2a272f2f, 0xe0ffb800, + 0x09090d40, 0x06005502, 0x0c032300, 0x5736141b, 0x1e280793, 0xb4f8ffb8, 0x55020b0b, 0xea240882, 0x0f0f1140, 0x0c200982, 0x1e232983, 0x840c0c16, + 0x05ef4c15, 0xf0201e82, 0x062f1e83, 0x36761e55, 0x361f360f, 0x0f033640, 0x18b80c14, 0x25321dc9, 0x0f0fb4ec, 0x3a825506, 0x8205ac4b, 0xb4f02308, + 0x11840c0c, 0x2205b34a, 0x44356b0c, 0x2b210a64, 0x09f855ed, 0x1712ed23, 0x058a4e39, 0x3fed3f22, 0x2708e047, 0x34055d2b, 0x06223736, 0x1805db54, + 0x20113fc9, 0x05187111, 0x260f397f, 0x05051403, 0x180f1909, 0x261056c9, 0x682d5147, 0x7f05043d, 0x8c2a0832, 0x271a74a8, 0x48490116, 0xc918e852, + 0x4e081066, 0xf1a285fc, 0x103b2c50, 0x52173c14, 0x9f081b4e, 0x009f0c0e, 0xfeb10001, 0x0467055f, 0x012a005d, 0x0b224009, 0x7a071906, 0x20270307, + 0x02370c09, 0x05091505, 0x0a054211, 0x22220801, 0x0d26531e, 0x2a1b2323, 0xc0ffb829, 0x371009b6, 0x48142929, 0xee241636, 0x10102940, 0x220e2448, + 0x820c0c26, 0x0d062211, 0x2605820d, 0x060f0f1e, 0x48081755, 0x1b22081d, 0x0f820909, 0x1f2c9226, 0x022c602c, 0x240da857, 0xe2ffb808, 0xafa718b4, + 0x05134828, 0xec203382, 0x21050446, 0x59830808, 0x2b870822, 0x49099f41, 0x5b4d0b82, 0x41322005, 0xfd2706a1, 0x3f3f2f32, 0x463c3fed, 0x04270507, + 0x06063537, 0x41262223, 0x36500c9e, 0x074c510d, 0x06950322, 0x0ebfa718, 0x42181e20, 0x3426070e, 0xa88c2a4b, 0xa7181d1d, 0xfb2411cf, 0x1b351ba3, + 0x39068241, 0x00248da0, 0x5c00ffff, 0x8d070000, 0x36020108, 0x00003a00, 0xd6001701, 0xbb436901, 0x0d112106, 0x2607b747, 0x06000056, 0x828c0636, + 0x855a2023, 0xbb002223, 0x05bd4300, 0x57182389, 0xd6220f69, 0x4786eeff, 0x05090d22, 0x18065946, 0x210f6757, 0x4585ddd6, 0x04080c22, 0x00392183, + 0x00b90001, 0x06080300, 0x0010001e, 0x0019407f, 0x0d3f0400, 0x00080900, 0xb5991800, 0x091a290c, 0xb4d6ffb8, 0x55021010, 0x231cab47, 0x0d0d0b40, + 0x14232282, 0x83060f0f, 0x05a44128, 0xec303182, 0x0c0c0c40, 0x096f5506, 0x0902097f, 0xf6101189, 0x25088050, 0x332b2bed, 0xf44c002f, 0x47012006, + 0x1522057e, 0x6f642311, 0x17240805, 0x1f0a0803, 0x67792664, 0x3fbfc2bc, 0x5e052a65, 0x8c6b1309, 0x82047dfb, 0x080cdac2, 0x1a000400, 0x5e050000, + 0x122eaa82, 0x21001e00, 0x4d012500, 0x202b9240, 0xa2182037, 0x0a250f2b, 0x0d170b18, 0x2ba2184a, 0x37400810, 0x02018701, 0x12001401, 0x03212000, + 0x04870437, 0x05140402, 0x06060605, 0x06261209, 0x06371229, 0x06461238, 0x12581249, 0x1275067a, 0x0c24240b, 0x25012570, 0x0ca05116, 0x06020cf0, + 0x3f0c160c, 0x04240882, 0x2134030c, 0x0a4da218, 0x210f6e08, 0x21022170, 0x12062021, 0x1c200504, 0x0c021c40, 0xc0ffb81c, 0x39396c40, 0x701c5037, + 0x011c021c, 0x40240805, 0x0f37100e, 0x02242f24, 0x40242222, 0x24370d09, 0x0f0f2913, 0x0f4f0f2f, 0x0f9f0f8f, 0x29190f05, 0x09200900, 0x09800940, + 0x09050990, 0x0601270f, 0x24120f09, 0x000c0505, 0x003a0024, 0x005a0042, 0x0074006a, 0x6e000007, 0x081c8227, 0x2b050a20, 0x4d053505, 0x65055505, + 0x07057b05, 0x10266405, 0x105d5de6, 0x125d2fe6, 0x2f5d3917, 0x0283ed5d, 0x2f332b27, 0x3f002b5d, 0x2005823c, 0x82178333, 0x822b2007, 0x82722018, + 0x39122203, 0x82a2182f, 0x34272129, 0x25095e70, 0x07020913, 0xa2183723, 0xd4080785, 0x3931f801, 0xa07373a1, 0x472a3039, 0x49483939, 0x7d483838, + 0xfdfefefe, 0x95f31d02, 0xfe9f0195, 0x1f570561, 0x906d4065, 0x65406d90, 0x4b36c41f, 0x4b39374a, 0x0266fc4c, 0x0535fdcb, 0x00cdcdb7, 0x68000400, + 0x1d04e1ff, 0x32003307, 0x4b003f00, 0xb3014f00, 0x190a0cb5, 0xb830020a, 0x5c40c0ff, 0x59370e0b, 0x5c21510e, 0x630e6938, 0x7b396f21, 0x74147a0a, + 0x0a387b20, 0x3d340802, 0x11401130, 0x49111102, 0x4e4f4f08, 0x06aa434e, 0x9f291629, 0x40290329, 0x29370d0b, 0x4923012f, 0x1f011f4f, 0x41181f29, + 0x413d0449, 0x08010a08, 0x100d404e, 0x4e4c4c37, 0x370c0940, 0x40264e4e, 0x40e7ffb8, 0x02090914, 0x2c294055, 0x020d0d10, 0x3f2c2f55, 0x2c2c022c, + 0x20188226, 0x2a1783b6, 0xb8462926, 0x0fb4ecff, 0x8255020f, 0xb4f02108, 0x08822383, 0x1940e222, 0x7f281d83, 0x02468f46, 0x0f004646, 0x11236682, + 0x83405134, 0x0c2e4513, 0x0c164034, 0x0255020c, 0x0b1f001a, 0x10100600, 0x12005502, 0x05820b0b, 0xe6ffb822, 0x2105d746, 0x33831800, 0x831a0021, + 0xb8002457, 0x83b4fcff, 0x4608822f, 0x002906d7, 0x060d0d0a, 0x0c060055, 0x05f25c0c, 0xf15cb720, 0x3a512605, 0x40f8ffb8, 0x2a34830e, 0x511f510f, + 0x3a03513f, 0x18b80b1b, 0x2107a47f, 0x63830c0b, 0x831c0b21, 0x140b2159, 0x0b202483, 0x02244082, 0x50850b55, 0x24061149, 0x102b5ded, 0x05255ee6, + 0x4a180583, 0x2f2308aa, 0x6239125d, 0x2b210567, 0x21078233, 0x0e822bed, 0x2b230982, 0x693f3f00, 0x1f82055c, 0x2f391127, 0x33ed5d2b, 0x0982622f, + 0x21058b60, 0x4a182321, 0x062b19bd, 0x35230706, 0x26373636, 0x68343526, 0x0626054d, 0x15161607, 0x1d751103, 0x4203200a, 0x03250b60, 0x1d041323, + 0xc74a18bb, 0x292e390d, 0x3a3f6d29, 0x50312a69, 0x69230a13, 0x9f251c31, 0x2e9e7373, 0xbb877d23, 0x08c54a18, 0x80424320, 0xf3952307, 0x4a189595, + 0x413c0ec9, 0x11181756, 0x1d0d0b14, 0x1409bf07, 0x2e531e08, 0x6d90906d, 0x221f5b33, 0x1dfe9aaa, 0x0acc4a18, 0x2c043508, 0x374a4b36, 0x024d4c39, + 0x01eefe62, 0x00ffff12, 0x0700000e, 0x0201086d, 0x00900036, 0x00170100, 0x01de018d, 0x40110075, 0x160f020c, 0x0002164f, 0x07061416, 0x26074d51, + 0x07e3ff68, 0x828c063f, 0x86a0202b, 0x00692a2b, 0xb60a0000, 0x54550003, 0x0697451b, 0x6eff7324, 0x4f84da05, 0x23859120, 0x82780021, 0x40132e4f, + 0x3a30030e, 0x3a603a40, 0x3b3a0003, 0x089f510f, 0x6cff5d24, 0x51847104, 0x2d82a120, 0x8d001624, 0x7b8300e2, 0x2e300329, 0x00022e40, 0x850c2f2e, + 0x01003629, 0x40035a01, 0x5d044902, 0x14000300, 0x56010a40, 0x2d030502, 0xa6731800, 0x31ed2e07, 0x11230130, 0xef490233, 0x014003ef, 0x1289461d, + 0x73014322, 0x20064146, 0x18894610, 0xc3004322, 0x0121cd84, 0x46238900, 0x8d200fd1, 0x2108d146, 0xd146100f, 0x008d2217, 0x894786bf, 0x21478423, + 0x19475007, 0x018e2208, 0x368f826c, 0x1302b120, 0x40c0ffb8, 0x37100d12, 0x0101130f, 0x135f1300, 0x84130002, 0x355d2459, 0x82352b5d, 0x005626c9, + 0x05360600, 0x082f47db, 0x5d848e20, 0x39861e20, 0x39881020, 0x378c3c82, 0x220f4347, 0x570a0043, 0x0a2005e1, 0x09207183, 0x00263782, 0x00050a0a, + 0x65842b25, 0x340f4d47, 0x0000ff43, 0x01104015, 0x0b300b20, 0x0b700b60, 0x090b0004, 0x078b4104, 0x03edff31, 0x068601e4, 0x00030013, 0x0300b932, + 0x82b7e4ff, 0x0101284d, 0xb8000103, 0x82b3aeff, 0x2b07820b, 0x0a0940e8, 0x0000370c, 0x0201027f, 0x078d4618, 0x088b4618, 0x86010128, 0x0f01f4a5, + 0x5b6e1306, 0xd0ff2705, 0x16058506, 0x4f82fd06, 0x01b61127, 0x00000250, 0x09771805, 0x0577080d, 0x05bafa16, 0x78850646, 0x89000100, 0x8b040000, + 0x2800ee05, 0x63409300, 0x12531241, 0x12631a5b, 0x12730273, 0x03b62490, 0x230924b6, 0x00510520, 0x20081008, 0x08080308, 0x51091c1f, 0x0c1f0c0f, + 0x0c4f0c3f, 0x14140c04, 0x010c4918, 0x28020210, 0x0f08014a, 0x022a1f2a, 0x1c022723, 0x0c05201f, 0x1d5f2108, 0x1d7f1d6f, 0x060a1d03, 0x1d080613, + 0x20020413, 0x82004000, 0x2f022889, 0x125d2f33, 0x832f3917, 0x2f332707, 0x32fd3333, 0x9d183911, 0x23821002, 0x3939ed2f, 0x295d3031, 0x013e3501, + 0x33352337, 0x21038335, 0x8d6d1234, 0x011d230a, 0x01841521, 0x07010e2f, 0x8b042115, 0x6267fefb, 0xa4a49d0e, 0x109d18a3, 0xfe6c3e0b, 0xfe6d0193, + 0x5a700f8f, 0x1bcf4503, 0x8c867b81, 0x01c8a786, 0xce112201, 0x90a5302a, 0x240e8294, 0x0b2c9f65, 0x08998200, 0xe6ffb151, 0x32051105, 0x22001800, + 0x13405f00, 0x1c390d38, 0x0d581c49, 0x217a216a, 0x0b100c06, 0xb807370d, 0x2a40f0ff, 0x19370a09, 0x260f291f, 0x790f6915, 0x3201050f, 0x1f0f2222, + 0x0b0b1532, 0x090f3307, 0x13190c0c, 0x00010026, 0x01222400, 0x822f1214, 0x2fc783d9, 0x3f002f33, 0x2f2f33ed, 0x2f3912ed, 0x2b2b5ded, 0x013bd582, + 0x17161421, 0x3233011e, 0x15333736, 0x2023010e, 0x00101100, 0x11003221, 0x74012e27, 0x4d080698, 0x66fc1105, 0xa33a3c42, 0x59ea7a60, 0x7fc0820d, + 0xadfec9fe, 0x13014201, 0xbe0c01ff, 0x28292602, 0xd59f5a87, 0x8478020d, 0x3b3c3eb5, 0x36d54856, 0x015b0137, 0x013a0141, 0xfecdfe76, 0x91542ae9, + 0xd43a3333, 0xffff00b1, 0xe1ffab00, 0x5b188307, 0x413c1289, 0xc6fdf203, 0x0c401600, 0x10020304, 0x400b010a, 0x020b7f0b, 0x0035115d, 0x3535353f, + 0x8c203782, 0xa4363782, 0x3600ed05, 0x00a63d02, 0xbb003700, 0x00009102, 0x41021701, 0x37821304, 0x26403822, 0x36213782, 0x3504820a, 0x20390039, + 0x80394039, 0x0539ff39, 0x31003101, 0x317b315b, 0x5b180003, 0x59881179, 0x59848a20, 0x5982da20, 0x97a43f21, 0x83322059, 0x00353359, 0x40352035, + 0xff358035, 0x2d010535, 0x2d5b2d00, 0x599c2d7b, 0x59829920, 0x83056f21, 0x86402059, 0x853120b3, 0xde0321b3, 0x3622b382, 0xae822440, 0x59830e20, + 0x116f113b, 0x11ff1180, 0x2b090103, 0x44093b09, 0x7f095b09, 0x04000509, 0x043f0400, 0x2b5c1802, 0x08b18509, 0x00010023, 0x0159fe61, 0x008800fa, + 0xb92c0003, 0xe8ff0200, 0x100d1740, 0x09180337, 0x1800370c, 0x0f371009, 0x08008201, 0x020d0021, 0x332f0002, 0x333f002f, 0x30315d2f, 0x2b2b2b01, + 0x0133011b, 0xfef4a561, 0x0259fef1, 0x82d1fd2f, 0xb769188a, 0x02012866, 0x030c0512, 0x828c0605, 0x40142eb1, 0x02030309, 0x03102d00, 0x5d2f0301, + 0x06be6eed, 0x03230336, 0x91310503, 0xfe8c0631, 0x00800180, 0x00010300, 0x18040c05, 0x28083184, 0x000b0007, 0x0615403f, 0x09af0a05, 0x00000209, + 0x062b0702, 0x370a0940, 0x0b2b0a06, 0x40c0ffb8, 0x370b090c, 0x2d00060b, 0x2252850b, 0x5f32fd33, 0x33210735, 0x0817522f, 0x01246082, 0x05333523, + 0x022c0382, 0x318031fd, 0xbfbffd01, 0xbfbfa7fd, 0x2a087085, 0xc3c38cfe, 0xffff00c3, 0x00000700, 0xd1055e05, 0x24003602, 0x17010000, 0xf5fd9d01, + 0x120045ff, 0x0e020a40, 0x1f0e0203, 0x420e4f0e, 0x2b820693, 0x2b820020, 0xd1059028, 0x28003700, 0x2d86f300, 0x2d82ee20, 0x404d2608, 0x030f010c, + 0x1110110f, 0x01031140, 0xecffb80c, 0x0c0b1640, 0x0c1f5502, 0x01000c01, 0x02100f06, 0x0d160155, 0x2405820d, 0xb4e2ffb8, 0x2f19820c, 0xf0ffb801, + 0x020b0bb7, 0x01014055, 0x2b5d2f01, 0x35200082, 0x35240682, 0x353f005d, 0x00249583, 0x2e060000, 0x2b206984, 0x4b20698c, 0x20206986, 0x4f83698a, + 0x05266984, 0x020f0f0a, 0x69840555, 0x69820520, 0x830e4021, 0x2805211a, 0x05226784, 0x67950501, 0x84c80321, 0x8c2c2067, 0x40522267, 0x20d18222, + 0x22568401, 0x82100602, 0x840220c0, 0x1a02275c, 0x55020d0d, 0x58832202, 0xe7830220, 0x5c831920, 0x093a0223, 0x25ca8209, 0x0f020102, 0x99821f11, + 0x60115024, 0x016c0511, 0x20d88505, 0x2fd68235, 0x0000ffff, 0x9906e1ff, 0x3700f005, 0xbf003200, 0x2c0a3f41, 0x02154061, 0x290f0327, 0x27270201, + 0x29ce8428, 0x00010127, 0xffb80f0f, 0x7b83b4e0, 0xe4210882, 0x82db83b4, 0x40f02208, 0x2182830b, 0x2783380f, 0x95670f82, 0x080f2106, 0x00278283, + 0x700f100f, 0x4a5d030f, 0x1125052b, 0x2b5d3535, 0x0c534111, 0xeb840120, 0x1b013c22, 0x5c367d8a, 0x09011140, 0x1f0e0f03, 0x030e2f0e, 0x01091f01, + 0xb8040009, 0x7984f2ff, 0xf6200882, 0x2105f94a, 0x76830a04, 0x83120421, 0x21158276, 0xf883b4e4, 0xf0220882, 0x79830c40, 0x40041f27, 0x03047004, + 0x05634104, 0x352b2b24, 0x78845d2f, 0x21053542, 0xf583d706, 0x00bb0123, 0x24778ab7, 0x0116405b, 0x2570822b, 0x002b012b, 0xe783221c, 0x83261c21, + 0xb81c21e4, 0x82066260, 0x40fa2208, 0x21708325, 0x6d83041c, 0xe3851c20, 0x1c101c33, 0x1c031c20, 0x2d202d0f, 0x2d602d50, 0x2d8f2d70, 0x096c4106, + 0x355d112e, 0x00353f00, 0xcbff0400, 0x67020000, 0x08084f43, 0xb6000f2c, 0x090a1140, 0x0c0caf0f, 0x06070706, 0x01050206, 0xb80a2a0b, 0x1740f4ff, + 0x55020d0c, 0x0f09400a, 0x040a0a37, 0x2a0e0004, 0x11830c0f, 0xffb80f25, 0x821f40c0, 0x0f0f2a15, 0x7f010707, 0x92110111, 0x26ea8400, 0x0c0c0c00, + 0x18005502, 0x2831744d, 0x0c0cb6f8, 0x88015506, 0x06d64b10, 0xfd5d2b22, 0x21064d5d, 0x08822f33, 0x2f331122, 0x00220784, 0x09833f2f, 0x2407c843, + 0x33112321, 0x0acc4313, 0xbc770137, 0x543804bc, 0xabb00138, 0xab0ffeab, 0x025d04ab, 0x0180fe2f, 0x08d14380, 0x43001a21, 0x162405d1, 0x00002400, + 0x2b06dd6b, 0x02d1052b, 0x00250016, 0x00020000, 0x862c1f83, 0x0300d105, 0x58000600, 0x05493c40, 0x0d5a8518, 0x1a001532, 0x2a002501, 0x4a004501, + 0x44024b01, 0x56025903, 0x086a8518, 0x03020e25, 0x18000305, 0x29236a85, 0x21010129, 0x86050209, 0x851894fa, 0x93851168, 0x849d0421, 0x84282093, + 0x827e20a3, 0x840820b3, 0x883d200f, 0x843b20b3, 0x842b200f, 0x8289200f, 0x84d520b8, 0x842c200f, 0x82cd200f, 0x8475202f, 0x822e200f, 0x840120d3, + 0x826220d3, 0x000635d3, 0x094e406c, 0x58023902, 0x01780302, 0x02020377, 0x14010203, 0x0236e882, 0x04041403, 0x46054905, 0x73057c06, 0x03050406, + 0x24000504, 0xa44f3900, 0x0f08230b, 0x02820108, 0x040a2208, 0x0436042b, 0x0455044d, 0x047b0465, 0x5d2f0407, 0x33115d5d, 0x2f005d2f, 0x0130313f, + 0xfd10875d, 0x3d0382c0, 0x5d01c008, 0x23215d00, 0x01230109, 0xd5620533, 0x2cfe2cfe, 0xf02c02cb, 0xfbfa0505, 0xe185d105, 0x84f60521, 0x883020a1, + 0x843820d1, 0x8231200f, 0x000326b1, 0x04000072, 0x08b182bf, 0x07000324, 0x51000b00, 0x063505b2, 0x40c0ffb8, 0x020f0f15, 0x09060655, 0x03023501, + 0x0809350a, 0x13094005, 0x19830437, 0x08831620, 0x05052708, 0x04020304, 0x0d720809, 0x0d1f0d0f, 0x0c680902, 0x105de610, 0x391711e4, 0x2b2b2f2f, + 0x3fed3f00, 0x2f3912ed, 0xa982ed2b, 0x21352123, 0x20038203, 0x2b038213, 0xb3fbbf04, 0xfc344d04, 0x34e5031b, 0x05280983, 0x08fdb021, 0xb077fcb0, + 0x2507bb5a, 0x1602f005, 0x97823200, 0x0b6e0120, 0x2d978205, 0x40eb0007, 0x06350309, 0x01050103, 0xea550914, 0x6d002007, 0x0882077e, 0x4fb4f421, + 0x0b20081b, 0x0020b583, 0x22059e43, 0x44eaffb8, 0x002505a2, 0x020c0c12, 0x22288255, 0x182340fc, 0x280a3345, 0x060c0c0a, 0x090a0055, 0x2c058209, + 0x090f0978, 0x09500940, 0x05140403, 0x06786db8, 0xfc200882, 0xed185984, 0xa86924b6, 0x522a8205, 0x088405c1, 0x08826083, 0x22050856, 0x6b086c05, + 0x08560cf3, 0x822b2009, 0x00ed2800, 0xed3f332f, 0x6d213031, 0x212e0561, 0xfdc63b05, 0x7304c619, 0xdffa2105, 0x3d43d105, 0x96043106, 0x1602d105, + 0x00003300, 0x76000100, 0x00050000, 0x53081a82, 0x40eb000c, 0x09040947, 0x540b4508, 0x6409640b, 0x930b660a, 0x960a9309, 0xa309a40b, 0x0d0ba70a, + 0x0b060806, 0x0b160816, 0x08270328, 0x0b340a34, 0x0b430a43, 0x0b550359, 0x0b760b67, 0x0499038b, 0x04b80899, 0x04eb08b8, 0x0b1508eb, 0xb3c0ffb8, + 0x0a372925, 0x09200786, 0x08200786, 0x40240782, 0x37292630, 0x0f649618, 0x64020327, 0x02028d04, 0x2f178304, 0x0801350b, 0x04030535, 0xb009a003, + 0x0309d009, 0x403f3c83, 0x371e1923, 0x09200910, 0x09720960, 0x09e009d0, 0x03070906, 0x08090b04, 0x00020607, 0x82001000, 0x020e2304, 0x074c112f, + 0x2b5d3507, 0x002f3371, 0xed2fed3f, 0x31391711, 0x10015d30, 0xc087ed87, 0x08230483, 0x822b01c0, 0x5d2c0800, 0x35012971, 0x21350109, 0x15012115, + 0x00052101, 0x6c0276fb, 0x4804a8fd, 0x4a02c0fc, 0x9a038afd, 0x025802b8, 0xfeb0b30e, 0xa3fd1a06, 0x3105f145, 0xd105ee04, 0x37001602, 0xffff0000, + 0x00000600, 0x0f84e604, 0x0f843c20, 0x00004423, 0x050b4305, 0x003b2308, 0x00010000, 0x060000b3, 0x00d10544, 0x40070123, 0x25152559, 0x061b021e, + 0x18011875, 0x48093834, 0xd3826f09, 0x09221931, 0x03100803, 0x23142208, 0x020c0c02, 0x84112355, 0x14112606, 0x10082310, 0x220f8210, 0x820f0f20, + 0x0d062205, 0x2005820d, 0x22218417, 0x820b0b2a, 0x0918220b, 0x25058209, 0x07181b07, 0xd3461014, 0x21088207, 0x2f83b4e0, 0xf7210882, 0x823283b4, + 0xb4e72108, 0x08823583, 0x83b4d421, 0x21088238, 0x3b83b5e4, 0xb8081022, 0x8206715f, 0x42f62008, 0x082105d8, 0x822b8312, 0x84f0200f, 0x2208822b, + 0x831b40e4, 0x08803c2c, 0x08b008a0, 0x50252003, 0x03257025, 0x24250808, 0x253f250f, 0x12115d02, 0x475d2f39, 0xc4200594, 0x23059a47, 0x103939ed, + 0x2f260a86, 0x2b2f2bed, 0xf86f00ed, 0xed5d3105, 0x3139395d, 0x14015d30, 0x06060706, 0x11231107, 0x2805947f, 0x14113311, 0x16161716, 0x20088217, + 0x05dd6536, 0x06336d08, 0x504d5144, 0x9ac597e1, 0x514e4be2, 0x35343bc6, 0x61c5629a, 0x3638359c, 0x9d8e03c6, 0x464543d7, 0x01befe0a, 0x42480b42, + 0x029cd645, 0x6da6fd43, 0x2f2d2c8e, 0xfce40307, 0x2e2d081c, 0x02718531, 0x0100005a, 0x00006c00, 0xf0052006, 0xed002700, 0x195b1240, 0x1a6c255b, + 0x21641d64, 0x1a79246c, 0x21082479, 0xb3c0ffb8, 0x1d370b09, 0x40210782, 0x2608823b, 0x0d0c4014, 0x84025502, 0x02302a05, 0x02401430, 0x19041440, + 0xad941825, 0x100c2210, 0x22268210, 0x18141219, 0x26298594, 0x02090917, 0x18222255, 0x2407df4b, 0x29a02990, 0x91941804, 0x5d5d2533, 0x2b2f3311, + 0xc4250083, 0xed393912, 0x053d6b2f, 0x3cfd3c32, 0x1712ed3f, 0x2b2b5d39, 0x2b2b3031, 0x1121215d, 0x20054841, 0x06285534, 0x16161728, 0x35211117, + 0x92753521, 0x20230805, 0x02141100, 0x06211507, 0x3cc0fd20, 0x342d2c77, 0xfedcdcfe, 0x762d2d34, 0x01c0fd3c, 0x01cb9d9a, 0x82310177, 0x77340801, + 0x9a019dcb, 0x58268301, 0x6a9f3b39, 0xcef9f9ce, 0x393b9f6a, 0x7dfe2658, 0x015a7cae, 0x1401c238, 0xa2fe5e01, 0xfec2ecfe, 0xff7c5ac8, 0x007e00ff, + 0x07e20200, 0x09d96718, 0x24ff8e28, 0x24007501, 0x7a180e40, 0x10340c63, 0x40f4ffb8, 0x020d0b0a, 0x0d100055, 0x2b250904, 0x355d352b, 0x18074743, + 0x20106f84, 0x183d832e, 0x240a6f84, 0xeeffb80e, 0x833c83b4, 0x60402008, 0x0e230530, 0x82000509, 0x3b478646, 0x04e1ff6c, 0x028c0643, 0x002e0136, + 0x01160100, 0x0000e29d, 0x020d4012, 0x09091424, 0x24227382, 0x45510821, 0xff6d2407, 0x84ee03e6, 0x85302029, 0x00cc3129, 0x09401e00, 0x50414001, + 0x03417041, 0xdeffb841, 0x41266186, 0x2519123e, 0xa7842b2b, 0x64feb924, 0x35845f04, 0x3585c620, 0x00001d22, 0x20053968, 0x232d86d6, 0x160e171a, + 0x35212d82, 0x20d58200, 0x202382a0, 0x212d8393, 0x1d4ad500, 0x8efe2b05, 0x16000000, 0xb80701b1, 0x2f86f2ff, 0x02040725, 0x51012503, 0xb12405d9, + 0x5c04e2ff, 0xd1205d84, 0x9e295d84, 0x190000fb, 0x010203b3, 0x212f8422, 0xc2820c0c, 0x071f2223, 0x255f8317, 0x00003535, 0x8f830002, 0x068d2208, + 0x00180014, 0x404f0137, 0x0d20163e, 0x0f073710, 0x26431b4a, 0x26563743, 0x2e062979, 0x370f0d20, 0x20168333, 0x08048305, 0x20151624, 0x01215f3e, + 0x2b032121, 0x35010c3e, 0x08090340, 0x0f12150c, 0x28200120, 0xffb8121b, 0x1010b4ec, 0x08825502, 0x76b4ee21, 0xe42406a5, 0x0d0d1540, 0x14211282, + 0x237c820b, 0x09091212, 0x12270b82, 0xb8190820, 0x83b6f8ff, 0x1b19220c, 0x07955900, 0xf4200882, 0x08823684, 0x56b4f821, 0xd0210647, 0x82b584b4, + 0x47b420bf, 0xf8220653, 0x38831a40, 0x39900026, 0x3201391f, 0x0d3e8318, 0x73b80821, 0x08820626, 0x18068d61, 0x5d1a52b4, 0x2a82052a, 0x2008885b, + 0x06885bf6, 0x09090627, 0x88085506, 0x0a1f4738, 0x9c63fd20, 0x2bed240b, 0x43393912, 0xed240549, 0x39125d2f, 0x35055656, 0x5d2f3912, 0x313939ed, + 0x2b2b2b30, 0x012b015d, 0x22230014, 0x085a2726, 0x16162708, 0x07061415, 0x71181615, 0x35250810, 0x37363233, 0x316d1836, 0x06062507, 0x16161115, + 0x86081282, 0xf3fe8d04, 0x3fb04fcd, 0x5adffdbc, 0x44393b95, 0xbc9f7f8b, 0x3b3a45c2, 0x24244992, 0x2e278242, 0x496d8a2d, 0x1e202168, 0x95489642, + 0xcabc01a1, 0x2a2cf8fe, 0xd20524fe, 0x2e2bfee0, 0x7f5b8a2b, 0x1a1125bd, 0x6f5997c7, 0xa016201f, 0x62221e1d, 0x35747055, 0x3e752c2c, 0x1f26a2fc, + 0x0001009d, 0x0464fe3d, 0x005d047f, 0xb9e00008, 0xf6ff0700, 0x020d0ab4, 0xffb80755, 0x0e4a40e0, 0x75550211, 0x06070107, 0x821a0807, 0x07340829, + 0x05041a06, 0x0c030505, 0x001a000a, 0x004a002a, 0x00690059, 0x00070075, 0x05150505, 0x05450525, 0x05660556, 0x05070573, 0x0c010100, 0x55020c0c, + 0x09090a01, 0x1a2f0582, 0xffb80405, 0x100b40fa, 0x04550210, 0x820f0f0c, 0x07b94c05, 0x2b831885, 0x4d0e0421, 0xf2200627, 0x2105026c, 0x8a660604, + 0x08ea6106, 0x1440f636, 0x55060909, 0x04a00490, 0x0a040402, 0x4f0a1f09, 0x030a5f0a, 0x57053446, 0xc43008f4, 0x102b2bed, 0x2f5d2fc4, 0x3f3f005d, + 0x87013031, 0x0806854a, 0x2b5d0027, 0x1101012b, 0x33011123, 0x7f040101, 0xfebc37fe, 0x5701cc43, 0x5d045a01, 0x2cfedbfb, 0x2504d401, 0x3c03c4fc, + 0x08e78200, 0x64fe6c3e, 0x1406d603, 0xaf002f00, 0x00461d40, 0x28650057, 0x2078117f, 0x1d06217d, 0x011b3e1a, 0x070f3f2d, 0x191a1a0c, 0xb8071c12, + 0x0c40e0ff, 0x00370c09, 0x1c070107, 0x03b40b07, 0xb4eaffb8, 0x08665218, 0x1182d083, 0x83055c59, 0x21402f08, 0x55021010, 0x0f310303, 0x02313f31, + 0x29830423, 0x07b74d18, 0x83181221, 0xb812252e, 0x1340e2ff, 0x12291783, 0x020c0c08, 0x0d041255, 0x2105820d, 0x7a423085, 0x45db8205, 0xed3507b3, + 0x5d2f3333, 0x39122f2b, 0x3f002f39, 0xed3fed2f, 0x5d303139, 0x05544225, 0x42352321, 0x23340546, 0x34352622, 0x36363712, 0x35213537, 0x06061521, + 0x15020607, 0x08051e47, 0x3316166b, 0x03163233, 0x5a1c209a, 0x4c5ab343, 0xe5912f3d, 0x4b4e5cde, 0x34fe6cc5, 0xe575e802, 0x0672595a, 0x27310a0c, + 0x56387924, 0x284b6647, 0xa954285b, 0x774f0e3f, 0xe84c3945, 0x00018ce5, 0x5ecd7077, 0x4e879e09, 0xfe7578ce, 0x48228fe8, 0x184b2628, 0x00340516, + 0xb9000100, 0x5f0464fe, 0x16007c04, 0x14400b01, 0x15161503, 0x7fd81873, 0x01052408, 0x5a080d0c, 0xb6200c47, 0x0222e483, 0x3b48001a, 0x20088207, + 0x09d943fc, 0x0f0f1726, 0x0c005502, 0x200a334b, 0x06fe4322, 0x8205ad67, 0x77e6202d, 0x0420063c, 0x21083c77, 0xd018091c, 0x1a2018f5, 0x212dad67, + 0x3777b4ee, 0x4417201e, 0x2b201710, 0xed240082, 0x3f002b2b, 0xed270082, 0x30313912, 0x6723015d, 0x247714a8, 0x58bc290b, 0xbeb563bc, 0x180464fe, + 0x080f8c67, 0x00030020, 0x04e1ff89, 0x00140675, 0x00240017, 0xb9040131, 0xd6ff2f00, 0x370d0ab3, 0xd6ffb829, 0x08821d40, 0x0b2a2125, 0x831b370d, + 0x66230804, 0x3e26012c, 0x241f240f, 0x06242402, 0xb8123e1e, 0x1c40e8ff, 0x55020d0c, 0x124a123a, 0x2c011202, 0x8318063e, 0x06352b0e, 0x06020645, + 0xb818250a, 0xe982fbff, 0x82550221, 0xb4f82308, 0x08840909, 0x0cb6f423, 0x2408820c, 0xffb8001a, 0x181384fc, 0x210d044e, 0x50181034, 0x0029098c, + 0x3f331f33, 0x26240233, 0x213b8304, 0x38830c26, 0x0c1a2629, 0x020b0b0c, 0x83140c55, 0x000c2113, 0x0c221383, 0xc745ffb8, 0x21088405, 0x1d820f0f, + 0xf4ffb824, 0x4a830a40, 0x900c8025, 0x180c020c, 0x420bbe49, 0xfd2907e7, 0x322b2b2b, 0x2b5d3f00, 0x270383ed, 0x5d2f3912, 0x30315ded, 0x2b201482, + 0x6205fa49, 0x342c0687, 0x36363712, 0x17163233, 0x26071216, 0x23077577, 0x05070606, 0x09d16118, 0x36365a08, 0x242e7504, 0x9898d23a, 0x2d253ad2, + 0xd339262d, 0x39d39797, 0x04bd2e25, 0x6c292031, 0x296c4f4f, 0x02042f22, 0x2e8efd72, 0x4f702824, 0x2428704f, 0xbe00032e, 0x898754fd, 0xfd548789, + 0x0701aebe, 0x8a8a8253, 0xfafe5482, 0x36d68f54, 0x46393946, 0xa18fd537, 0x453ee98e, 0x3002823e, 0xffff00e9, 0x0000bb00, 0x5d047701, 0xd5001602, + 0x080a8200, 0x00c100b4, 0x04a80400, 0x0118005f, 0x063b4042, 0x16020601, 0x45182618, 0x66185618, 0x021c0718, 0x0269013a, 0x0197027a, 0x18a602a6, + 0x020802c7, 0x01c60302, 0x01018601, 0x18001a01, 0x01080900, 0x080108f9, 0x09030a0b, 0xffb80901, 0x100b40ee, 0xb4093718, 0x03171802, 0xffb80317, + 0x103a40c0, 0x7f550210, 0x18090103, 0x05030208, 0x10100c01, 0x050c3f14, 0x01050506, 0x172a171a, 0x17801736, 0x150517a4, 0x77172517, 0xe9179417, + 0x0617f917, 0x02181709, 0x0f0f0501, 0xf0ffb800, 0x0e091d40, 0x1a000037, 0x1a1f1a0f, 0x08031a3f, 0x09090c03, 0x0c035502, 0x05820c0c, 0x20371070, + 0xa46018e4, 0x19892115, 0x2d0d2743, 0x33115d3c, 0x2f332b2f, 0x715d3917, 0x1e6e2f00, 0x12112105, 0x2b320d82, 0x87013031, 0x7ac0c010, 0x18712bf5, + 0xc004c0c0, 0x0f827271, 0x715dfd37, 0x5d01c008, 0x01232171, 0x11231107, 0x36011133, 0x16323336, 0x07d96833, 0x04036d08, 0x3dfef8a8, 0x01bcbc70, + 0x3f7f4880, 0x0b073c1c, 0x2f0d2f10, 0x01fb1d4d, 0x84fe6de9, 0xdafd5d04, 0x384fa101, 0x0202a602, 0xf1fe212f, 0x3d000100, 0x7f040000, 0x07001406, + 0x1f409400, 0x110f2202, 0x18025502, 0x55020b0a, 0x02050405, 0x01060302, 0x0000071a, 0x041a0302, 0xb8050504, 0x1c40f0ff, 0x2b37100c, 0x20042600, + 0x04050307, 0x3f081f83, 0x68060800, 0x05070107, 0x00040306, 0x40c0ffb8, 0x37100926, 0x001c000c, 0x005a004b, 0x0079006a, 0x098d0006, 0x0301090f, + 0x44041304, 0x65045504, 0x06047604, 0x10088204, 0x105d5de6, 0x112b5df6, 0x2f33ea82, 0x173f3f00, 0x01303139, 0x10872b5d, 0x8710c0fd, 0x8208c0fd, + 0x00013f01, 0x23212b2b, 0x01230101, 0x7f043303, 0xfeb8fecd, 0xd101c497, 0x3d03d3d7, 0x2004c3fc, 0x5f45f401, 0x04652e06, 0x0015005d, 0x121b40ff, + 0x370d0b20, 0x18048303, 0x2036b7a7, 0x05a94dfe, 0x09040025, 0x82550209, 0x45e820cc, 0x0620064f, 0x2f084f45, 0x0609091e, 0x17920055, 0x1760171f, + 0x0d031790, 0x2606cf6a, 0x020c0c0c, 0x181a0955, 0x222dc7a7, 0x180fb4f2, 0x640ef266, 0x0a2106eb, 0x1865830a, 0x2013c7a7, 0x06d947f6, 0x2b2bfd26, + 0x3f003939, 0x09c9a718, 0x212b2b27, 0x06063523, 0x05534923, 0x2c493320, 0x37270805, 0x65043311, 0x4e874aba, 0xbc54784b, 0x5b9e20bc, 0xbc36885d, + 0x363d4e76, 0x05f3fd50, 0x27bafcf9, 0x033c4352, 0x42ffff40, 0x5e080503, 0x16025d04, 0x00005900, 0x68000100, 0x110464fe, 0x46001406, 0x4140dc00, + 0x060f020f, 0x0e1b0e09, 0x28241e24, 0x1e361534, 0x28442836, 0x2d563c47, 0x17693c56, 0x190f1779, 0x323f3318, 0x21240c32, 0x3f01223d, 0x0c030c3f, + 0x32321c19, 0x12212123, 0x141c1b2b, 0x5502100f, 0xe8ffb81c, 0x840d0db4, 0xb4f42308, 0x08840c0c, 0x0bb4ea23, 0x2308840b, 0x0909b5f8, 0x04300882, + 0x40d6ffb8, 0x370c090e, 0xb4080404, 0x80121c23, 0xb8248582, 0x2940c0ff, 0x00241282, 0x043a4800, 0x3a212583, 0x233d830c, 0x06121b3a, 0x23480783, + 0x83182006, 0x85123319, 0x2bf41047, 0x2bed2b2b, 0x2f33112b, 0x39125d2b, 0x0782ed39, 0x12822f20, 0x122c1482, 0x332f2f39, 0x0039122f, 0x3fed2f3f, + 0x2209036b, 0x6014055d, 0x352305b1, 0x45232634, 0x36290739, 0x37363637, 0x35262635, 0x25068234, 0x15213523, 0x54182221, 0x0e8d0cbe, 0x16328708, + 0x04161617, 0xb4425b11, 0x2e3a4b5c, 0x3fb98c8c, 0x30324542, 0x7d4c892c, 0xe45a5796, 0x00ff3803, 0x2d306d44, 0x2d334136, 0xfeaa5076, 0x2f6942d9, + 0x404b332b, 0x1c5a993f, 0x1f216744, 0xa8556022, 0x784f0e3f, 0x364e3744, 0x58973c39, 0x3135844e, 0x1c0b1345, 0x875368a5, 0x9e9a063a, 0x6620221d, + 0x1a624f43, 0x28a51617, 0x3b6a2527, 0x19197266, 0x23252f07, 0xffff005f, 0xe1ff6a00, 0x7c047104, 0x52001602, 0xad4c0000, 0x94210806, 0x11007c04, + 0xe1001e00, 0x173a1840, 0x174a1e35, 0x0d561e43, 0x15030605, 0x1c040f3e, 0x08090340, 0xc854180c, 0xf07b180d, 0x0d212723, 0x3a55020d, 0x62824a00, + 0x1f209027, 0x02206f20, 0x19574c19, 0x0b40e226, 0x55020f0f, 0x2108574c, 0xf350b4f6, 0x05e56d06, 0xffb80828, 0x0f0fb4e4, 0x574c5506, 0x06f4420b, + 0x090a0823, 0x21188209, 0xe0671f88, 0x4c2b2009, 0x03510657, 0x2bed2305, 0xa9543f00, 0x30312405, 0x4c10015d, 0x3725093f, 0x32333636, 0x06596200, + 0x0805f942, 0xfe94047f, 0xa341deeb, 0x4247bc48, 0xf366bb3e, 0xa0c20001, 0x498d9e92, 0xb0a24b77, 0xfefe4102, 0x2b24abfe, 0x22042bfe, 0x3e42b97b, + 0xfedafe42, 0xc0ccdadf, 0x226dfeb6, 0x0000de1d, 0xfe690001, 0x04fa0364, 0x00290077, 0x0c1240b5, 0x20060c02, 0x36232513, 0x40233614, 0x081f7a23, + 0xe0ffb817, 0x100e1440, 0x4f193f37, 0x19190219, 0x04153f1d, 0x3f260c03, 0xffb8040b, 0x0c09b7d6, 0x18180437, 0x21df8204, 0xfa84b6f8, 0xc24db420, + 0x40e02414, 0x640d0d36, 0x0c220827, 0x0b820909, 0x202b0023, 0x23328306, 0x08121b20, 0xf34a1c83, 0x0b0c2606, 0x1255020b, 0x05e54216, 0x1c412a20, + 0x2bed2105, 0x3207ab50, 0x33332bed, 0x002b2f2f, 0x3f3fed2f, 0x5d2f33ed, 0x422b3031, 0x102513d6, 0x16322100, 0x06234617, 0x0805f44a, 0x3233336a, + 0x5efa0316, 0x4d56b13e, 0x755c2d3c, 0x53494bc6, 0x03013701, 0x0c43a054, 0xa6449d5e, 0x323239bd, 0x73644b81, 0xaa57608e, 0x794b0e3b, 0x3c4f3647, + 0x92d04243, 0x44010e01, 0x3ed31b25, 0x70c1ee32, 0x272c2d8e, 0x01000099, 0xe2ffb100, 0x5d045c04, 0x08011700, 0x050716b5, 0xb8033e0f, 0x0b40f0ff, + 0x55021010, 0x0f0e1003, 0x0f830582, 0xc3831220, 0x56030931, 0x79036603, 0x05038803, 0xb8150a03, 0x78b4f4ff, 0x634906ec, 0x1a152705, 0xeaffb800, + 0x3a831d40, 0x4a040021, 0x26280aeb, 0x55020c0c, 0x0d0d0200, 0xb8220582, 0xe84ae4ff, 0x09192a10, 0x00550609, 0x191f1991, 0x0d934501, 0xffb80622, + 0x8205766a, 0x42e62008, 0x0621059e, 0x8273830c, 0x059e420f, 0xf2210882, 0x825883b4, 0x05f64e08, 0x0d230884, 0x8355060d, 0x05f64e08, 0x830a0621, + 0x87062160, 0x0b8f4318, 0x182bed21, 0x820b9d73, 0x3f00270d, 0x2b2b2b5d, 0x7f7c3fed, 0x07815309, 0x32335208, 0x36363736, 0x04331135, 0xdfe2f45c, + 0x2014bcf6, 0x565c6b1f, 0x151d1e73, 0xda9701bc, 0x02ded7db, 0x5d7ffdc6, 0x2b2b2e78, 0x7b2c2c2c, 0x0081025a, 0xfe300001, 0x04880464, 0x000b005d, + 0x2a4940b3, 0x39082502, 0x4b083402, 0x79084402, 0x09100702, 0xf1cf181a, 0x02260811, 0x0a080b05, 0x0a060600, 0x4a060504, 0x6a064504, 0x7a066504, + 0x08067704, 0x05060c04, 0x02050b08, 0x000a0404, 0x1d5cffb8, 0x33088305, 0x100a1640, 0x0d000037, 0x06010d2f, 0x0b0b1604, 0x20045502, 0x04271182, + 0xc42b2b2f, 0x8333115d, 0x17122706, 0x3f3f0039, 0xcf18115d, 0x4b3910ef, 0x14405853, 0x070a030b, 0x0a030200, 0x04080106, 0x05000709, 0x01060904, + 0x2500820f, 0x015d0059, 0x02830123, 0x01332908, 0x04013301, 0xa6fed588, 0x01cba2fe, 0xd54ffebc, 0x53014f01, 0xfe4ffecb, 0xfd6b0264, 0x02020395, + 0x02a8fdf7, 0x0011fd58, 0xb03bf182, 0xe30564fe, 0x23005d04, 0x19401401, 0x1826061b, 0x18021875, 0x4909393d, 0x55090209, 0x052305cc, 0x74220c08, + 0x0882079e, 0x0cb4f225, 0x8255020c, 0x40f62408, 0x82090921, 0x3f1a2809, 0x02237f23, 0x830c1123, 0x0a112117, 0x11231383, 0x550e101a, 0xe62906b7, + 0x020d0db4, 0xffb81055, 0x058a74ee, 0x70103029, 0x23100210, 0x5cf4ffb8, 0x232105ad, 0x211f8318, 0x3c830023, 0xf6241582, 0x0b0b1840, 0x84060856, + 0x84072050, 0x1a072350, 0x45410810, 0x20088207, 0x213b85d8, 0x3b830a08, 0x27840820, 0xec221582, 0x7c831c40, 0xc0089029, 0x25500208, 0x55022560, + 0x012805d7, 0x251f250f, 0x5d03253f, 0x220cdd55, 0x552b2bed, 0x2f2107d9, 0x05c6465d, 0x825d2f21, 0x002b2614, 0x17123f3f, 0x230b8239, 0x3139395d, + 0x07665f18, 0x081cde55, 0x60e30582, 0x73c8524f, 0x53c773bb, 0x4bbc5f50, 0x43863834, 0x388643bb, 0x01bc443b, 0x35a872be, 0xfe053737, 0x06980168, + 0xa7363934, 0xfd9f0272, 0x2387719c, 0x03041e26, 0x0539fcc7, 0x7b28271c, 0x00640278, 0xff710001, 0x041106e2, 0x013d005d, 0x362d4026, 0x4432361f, + 0x5532441f, 0x6832551f, 0x690f6804, 0x7d37691a, 0x0c377d1a, 0x09283b28, 0x05160603, 0x3e300d21, 0x403a0a06, 0x18370e0c, 0xb3c0ffb8, 0x362c0782, + 0x40f4ffb8, 0x020c0c17, 0x001b3655, 0x24060e74, 0x0c00131b, 0x06574909, 0x2009d54e, 0x2d24830b, 0x0f0f1a00, 0xb8005502, 0x1940eeff, 0x09821010, + 0x09293a25, 0x830c290a, 0x8429201a, 0x1a292833, 0xffb81318, 0x831140f2, 0x16132740, 0x55020b0b, 0x1e830e13, 0xf4241582, 0x0d0d1240, 0x20200f82, + 0x13214383, 0x253f8312, 0xffb82813, 0x0983b4e6, 0xde200882, 0x21059f41, 0x25830e28, 0x83002821, 0x22158235, 0x831640f0, 0x2890304b, 0x28c028a0, + 0x3f282803, 0x3f3f1f3e, 0x513f6f3f, 0x6a570b41, 0x41c42006, 0x0e85069e, 0x2bed2f22, 0x2b2b0282, 0xed3f002b, 0x123f3939, 0x572f3917, 0x23240878, + 0x23272622, 0x25058449, 0x34352626, 0x59183712, 0x162107ec, 0x05ff4316, 0x33113726, 0x17161611, 0x08086b7d, 0x27023483, 0x12163335, 0x332f1106, + 0x60739d37, 0x270625a2, 0xa3716694, 0x722f3333, 0x9f87e490, 0x5d1a1e10, 0x14473347, 0xba061d16, 0x18151c09, 0x5e463a39, 0x9d16191b, 0x7290e489, + 0xc160f701, 0x6359504b, 0x5d624443, 0x61bf4c4c, 0xa71501aa, 0xccfe6c11, 0x3f7142b7, 0x11194937, 0x020f2c12, 0x11b8fd48, 0x1613112c, 0x7a373947, + 0x3401b641, 0xfea7116d, 0xffff00eb, 0x00000500, 0xdb052d02, 0x77001602, 0x240f8300, 0x04e2ffb1, 0x3c0f825c, 0x00d10136, 0x00160100, 0x0000fb8e, + 0x020a4020, 0x1d501d30, 0x01031d60, 0xf2ffb81d, 0x05595640, 0x55181d21, 0x5d210522, 0x07834835, 0x028c0625, 0x56520036, 0x1b290c11, 0x02090908, + 0x181b0055, 0x07115606, 0x200f7d55, 0x2261829d, 0x8201b60a, 0x834e8322, 0xff71244b, 0x831106e2, 0xd401214b, 0x17284b82, 0xb6009d01, 0x0a000000, + 0x41222382, 0x4682133e, 0x4e182383, 0x8e2d0fe1, 0x75015000, 0x02b21800, 0xffb81101, 0x20a182ee, 0x21758210, 0xf4550c11, 0x00352206, 0x08a38201, + 0x07060031, 0x2500d105, 0x2b40d900, 0x24762465, 0x1f341602, 0x1a1e061f, 0x09031b35, 0x2f180635, 0x4f073f07, 0x04077f07, 0x59170707, 0x150f010f, + 0x83101600, 0xffb82444, 0x460db4d6, 0xee24056b, 0x0b0b0b40, 0x10205782, 0xb838d384, 0x1940c0ff, 0x00370d09, 0x270f2700, 0x1d1f1a01, 0x1f1d1d01, + 0x1a181417, 0x18233683, 0x42f2ffb8, 0x1821056d, 0x253d8308, 0x0c0c1a18, 0x15825502, 0x0c40ee22, 0x18214383, 0x2043830c, 0x2010821a, 0x05d172f6, + 0x0d0a1829, 0x1855060d, 0x820c0c0a, 0xffb82505, 0x0909b4f6, 0x2f210882, 0x2000822b, 0x82038233, 0x32fd2502, 0x2f5d2f32, 0x27089b58, 0x39125ded, + 0x2f005d2f, 0x4208c84a, 0x2321097c, 0x08325535, 0x26275408, 0x11212326, 0x35211123, 0x11211521, 0x17163221, 0x07061616, 0xaf574953, 0x5b5d6e8a, + 0x34382f78, 0x95323531, 0xc6ebfe83, 0x680452fe, 0x53010cfe, 0x4c55bf98, 0x6ccc0149, 0x30453ab1, 0x282210b1, 0x734b4e6f, 0xfd132223, 0xb0210522, + 0x2468feb0, 0x5eae3b42, 0x2808059d, 0xed078a04, 0xeb013602, 0x17010000, 0x35008d00, 0x15006101, 0x30011040, 0x60084008, 0x04087008, 0x04070800, + 0x5d2b2505, 0x08208235, 0xff730023, 0x053905e5, 0x002a00ec, 0x3a0c408a, 0x581c491c, 0x79067605, 0xb811050c, 0x0b40e0ff, 0x0137100a, 0x3f048220, + 0xb81d3420, 0x4340c0ff, 0x55020f0f, 0x030f1d1d, 0x34262a2a, 0x13130903, 0x020f3417, 0x00131e1e, 0x39057a5c, 0x012c0f2c, 0x2c1f2c0f, 0x2c3f2c2f, + 0x6c201d04, 0x0b0b1209, 0x16095502, 0x05820909, 0x0c0c0622, 0x68300582, 0x2bf6102b, 0x32fd2b2b, 0x33115d5d, 0x33335d2f, 0x2105c167, 0xc56ced3f, + 0xed2b2c05, 0x2b2b3031, 0x0606255d, 0x18242223, 0x2107c9a2, 0x18493324, 0x06072509, 0x15210706, 0x08092351, 0x3905334d, 0xa991ec63, 0x6161eefe, + 0x5f626969, 0x8ca91201, 0x4e105ff6, 0xae6d8df9, 0x0f584648, 0xc2fc3403, 0xc44a4758, 0x50f78a70, 0x35274110, 0x01636368, 0x01afb720, 0x6c62661f, + 0x40df2734, 0x3b3b3a52, 0x8bad72ad, 0x494846d9, 0x7800434a, 0x05250729, 0x001602ec, 0x149f6036, 0x263de759, 0x02ebff2c, 0x82d105ea, 0x2d48085d, + 0x02000000, 0xfdff1200, 0xd105a208, 0x3d000e00, 0x46b3e300, 0xb830010c, 0x0ab3acff, 0xb81e3710, 0x1e40c0ff, 0x07370e0b, 0x16373734, 0x03353518, + 0x352c2828, 0x16340824, 0x16140837, 0x0210100e, 0xffb81655, 0x0f0fb4f2, 0x35470884, 0x23118205, 0x0c0cb4e6, 0x017f1184, 0x24118205, 0x0d0db4e8, + 0x242c8306, 0x0c1c40ec, 0x2209820c, 0x82090914, 0x35162605, 0x0a0f1500, 0x3a47820f, 0x0d0b0c0f, 0xb80f5502, 0x0c40f4ff, 0x0f37110e, 0x3f2f3f71, + 0x35131801, 0x4af8ffb8, 0x3522051f, 0x20820d19, 0xee220f82, 0x5d831040, 0x09123530, 0x00550209, 0x35350135, 0x2f332f28, 0x00822b5d, 0x415ded21, + 0x112005d7, 0x82065658, 0x32fd2d12, 0x2fed2f00, 0x3f2f32fd, 0x2f3912ed, 0x2205d841, 0x42263401, 0x213005f8, 0x36373632, 0x06143736, 0x23060607, + 0x06211121, 0x02200882, 0x02820b82, 0x26222323, 0x057b7d23, 0x12242282, 0x37123613, 0x08071f43, 0x32d307b4, 0x83903735, 0x0f01ecfe, 0x38368f85, + 0x4755cf34, 0xfd98c054, 0x03f0fdee, 0x2508030b, 0x2f491d1d, 0x15446530, 0x0a0e0c3c, 0x40240f1e, 0x0e434716, 0x03040b05, 0x98520191, 0x494c55c0, + 0x724bc901, 0xfd102523, 0x27251acb, 0xb06c5569, 0x05384237, 0x55d97121, 0x59ecfed6, 0x2c2b6b5a, 0x01c00326, 0x47171602, 0x2d014601, 0x87440162, + 0x4223b8fd, 0x0200ae3b, 0x0000c800, 0xd1058308, 0x27000e00, 0x21401f01, 0x34071e17, 0x1f162121, 0x3408031b, 0x0f561a16, 0x081f2001, 0x02090906, + 0x00140855, 0x02166f16, 0xf0ffb816, 0x10101140, 0x10165502, 0x05820f0f, 0x0d0d0822, 0xb8220582, 0x6f47eaff, 0x0c162305, 0x0f820b0b, 0x32830c20, + 0x0f0a1625, 0x8255060f, 0x05ee7631, 0xa6410883, 0x410a2006, 0x192505a6, 0x160f1500, 0x214b820f, 0xa641160f, 0x0e0d2e08, 0x710f3711, 0x01294029, + 0x1a14191d, 0x065e61b8, 0xfc210882, 0x825983b4, 0x4bda2008, 0x1a210545, 0x20638308, 0x2079821a, 0x828283b4, 0xb4ee2508, 0x55020c0c, 0xe2210882, + 0x827883b4, 0x82ec2008, 0x8306201a, 0x4bec2011, 0x1a200545, 0x1a247884, 0xf610286c, 0x2208a358, 0x4132fd2b, 0x2b2611df, 0x2bed5d2b, 0xe9443939, + 0x68332005, 0xe141089d, 0x23112517, 0x21113311, 0x32260383, 0x16161716, 0xcb41b407, 0xc6652516, 0xc69b02c6, 0x2919b241, 0x22fdde02, 0xb8fdd105, + 0x9f414802, 0x012f0806, 0x0000ffff, 0xd105fd05, 0xbe001d00, 0x0e002640, 0x17581748, 0x0f620e60, 0x0f700e70, 0x1a010807, 0x010b0b35, 0x04350307, + 0x13011303, 0x5b191214, 0xf22a06e2, 0x0b0b3240, 0x04125502, 0x05820f0f, 0x09091222, 0x06200582, 0x2105b450, 0x0b820d0d, 0x5f1f122f, 0x02067f06, + 0x07060306, 0x01031400, 0x2036831a, 0x083c4601, 0x83080121, 0x1a012124, 0x15823083, 0x1a40ee22, 0x01214c83, 0x2c46830c, 0x0c0c1401, 0x10015506, + 0x55060909, 0x0805697f, 0x00822b20, 0x32fd3324, 0x29462f32, 0xed2b2409, 0x50332f00, 0x122506ed, 0x5d303139, 0x070f4621, 0x33363629, 0x16171632, + 0x57111516, 0x02210a86, 0x060b4673, 0xf65f3708, 0x3daa6567, 0x16c6453d, 0x6479201e, 0x0566c36a, 0xfeb0b021, 0x32331f2d, 0x73a33435, 0x8c0111fe, + 0x2e2b8c4a, 0xff222631, 0x00cd00ff, 0x07750500, 0x013602ed, 0x0f4600f2, 0x3c3f0805, 0x10006101, 0x70010a40, 0x23000123, 0x25000521, 0x355d2b01, + 0x06000200, 0xe604f9ff, 0x1a008f07, 0xb9002800, 0xff1900b9, 0x0a5e40ec, 0x29550211, 0x46013803, 0x04145519, 0x181a1919, 0x83161714, 0x1a193301, + 0x00010013, 0x1a181716, 0x07000501, 0x350f0b0b, 0x77751b07, 0x753a0806, 0xaa250125, 0x1e011e0f, 0x2803001e, 0x1a221b1a, 0x21012170, 0x7000211b, + 0x360a010a, 0x65015601, 0x04017601, 0x03010a16, 0xffb80017, 0x091440e0, 0x00003710, 0x012a502a, 0x0a82402a, 0x83201721, 0x2b2f2104, 0x08cf6618, + 0x5d2f5d2d, 0x2f393911, 0xed2fed5d, 0x82333f00, 0x825d2007, 0x2f332f04, 0x112f32ed, 0x01391712, 0xc0fd1087, 0x0683c008, 0x31c0082a, 0x2b5d0030, + 0x06060101, 0x20054444, 0x08444427, 0x37373627, 0x01013301, 0x05f74903, 0xdb493320, 0x04710805, 0x22cafde6, 0x6134365d, 0x1072282d, 0x2d460f0e, + 0x201c4814, 0xfd24163f, 0xb301dbd6, 0x05218601, 0xc9a8a8c9, 0x6002b605, 0x025f5f5e, 0x1bfbd105, 0x191b624c, 0xb9010811, 0x0b060902, 0x4f32340c, + 0x92fc4f04, 0xbe016e03, 0xa6a8a8a6, 0x71626370, 0x00010000, 0x05affec8, 0x00d1053b, 0x40e9000b, 0x03020611, 0x00093404, 0x0c0c090b, 0x0955020c, + 0x22ef8213, 0x830a40fe, 0x0000250b, 0x07140602, 0x82077165, 0xb4f42508, 0x55020b0b, 0xe6240882, 0x0f0f1740, 0x08220982, 0x05820909, 0x0d0d2a22, + 0x12200582, 0x1b823283, 0x1b40fa2a, 0x55060f0f, 0x0d0d0a07, 0x0c210583, 0x2905820c, 0x0d400d78, 0x03020d70, 0x06440214, 0x44088207, 0x08820506, + 0x20060644, 0x824d8402, 0xb4ea210f, 0x08825083, 0x82050644, 0xb4e42108, 0x08825283, 0x83050644, 0x83b62008, 0x6c022258, 0x0aff430c, 0x2006dd45, + 0x6600842b, 0x2b2b0587, 0x332f2f00, 0x31333fed, 0x43212130, 0x113907d8, 0xfea40223, 0xe702c624, 0xbb24fec6, 0xdbfad105, 0x2ffa2505, 0xffffaffe, + 0x0cb96800, 0x08055145, 0x052c0521, 0x001200d1, 0x40c60021, 0x0111631b, 0x0c0c341a, 0x08350b07, 0x07341b03, 0x130a0a08, 0x49020015, 0xee2006e5, + 0x0224a282, 0xffb80055, 0x82050150, 0xb4da2108, 0x08936018, 0x0b0b1331, 0x00565502, 0x23710001, 0x2340230f, 0x181b0c02, 0x2649e853, 0x0c0cb6ee, + 0x18075506, 0x220c3e90, 0x185d32fd, 0x2207ba49, 0x672f33ed, 0xed200796, 0x2109e249, 0xcf491121, 0x45072009, 0x05210d0b, 0x05af462c, 0xe503e42c, + 0x5c01e1fc, 0x4c55c098, 0x0545cf49, 0x01e22905, 0x368f8519, 0xcd013438, 0x28059646, 0x68feb0d1, 0xae3b4223, 0x0ab14672, 0x2d11f169, 0x00c80001, + 0x058a0400, 0x000500d1, 0x7018407f, 0x6c4f3c59, 0x4e521805, 0x050d4208, 0xffb80328, 0x0c0cb4e4, 0x70185506, 0x02263657, 0xaffe0a00, 0x9f829e05, + 0x000d2408, 0x40fe0013, 0x1a12091b, 0x03114a12, 0x030a3410, 0x3407130c, 0x10050103, 0x020c0c0a, 0x0a131055, 0x48f4ffb8, 0x0a25056d, 0x020d0d14, + 0x230f8255, 0x0b0e40ec, 0x0a231b82, 0x8209090c, 0x070a280f, 0xf8ffb80e, 0x820c0d40, 0x140e2c1c, 0x10100a0c, 0xb80c5502, 0x83b4feff, 0x23088210, + 0x0b0bb4f4, 0xf4211184, 0x252f83b6, 0xb8010c0c, 0x2e82f2ff, 0x01214182, 0x114b4213, 0x22088f5d, 0x832340ec, 0x060e7881, 0x3b831c20, 0x0100202b, + 0x13150000, 0x04070713, 0x221b830e, 0x82051304, 0x0fb4219d, 0x08827182, 0x7184f620, 0x2b2f0529, 0x392bed2b, 0x4911ed2f, 0x0e850600, 0x00822b20, + 0x8405ac77, 0x2f003508, 0x32fd2f33, 0x31ed3f32, 0x23015d30, 0x23112111, 0x12363311, 0x2f080782, 0x21112133, 0x05070202, 0xe4fbbc9e, 0x9b8278bc, + 0xfe8d7203, 0x0e0efead, 0xaffe7694, 0xabfe5501, 0x02d60102, 0xfa9a01b1, 0xfe7504df, 0xbfaffd9b, 0x6b06fb41, 0xa2820959, 0x00203f08, 0x05a80700, + 0x013700d1, 0x092e4000, 0x29331833, 0x401d4033, 0x54354124, 0x7524541d, 0x731d7118, 0x13270b24, 0x1a353333, 0x0e0c0e13, 0x09160102, 0x13013710, + 0x07003700, 0xeaffb808, 0x0e825440, 0x13085d08, 0x270a0909, 0x2c031a1f, 0x07373222, 0x330e0c0a, 0x022c0735, 0x04352d14, 0x21150209, 0x00032c05, + 0x37200a2f, 0x37500a5f, 0x37600a6f, 0x012c2c06, 0x33270237, 0xc5000635, 0x0c040422, 0x0455020c, 0x15150514, 0x0c070a08, 0x09061a0e, 0xb8051fc5, + 0x1740f4ff, 0x55021010, 0x0b0b0e05, 0x16220582, 0x05820f0f, 0x09090822, 0xff480582, 0x0e052308, 0x0f820d0d, 0x38390529, 0x393f3910, 0x187f395f, + 0x2c09c270, 0x332b2b2b, 0x323917f4, 0x2bfd102f, 0x29088432, 0x3f2f005d, 0x32fd3917, 0x0582122f, 0xf1451120, 0xc02b2205, 0x831f8287, 0x28078204, + 0x5d003031, 0x23012321, 0x25018211, 0x26012301, 0x02842726, 0x35232322, 0x67054247, 0x37280b5b, 0x33333636, 0x06222315, 0x0805694a, 0xa807073a, + 0x69f4fdf2, 0xf4fd6bc4, 0x585102e6, 0x25132068, 0x3c531b1c, 0xb2a7473c, 0x0f1e0b3d, 0xc4568f2c, 0x122e915c, 0xb53c091d, 0x423c47a5, 0x251d1e4b, + 0x3e7d2a13, 0x57fda902, 0x54080384, 0x699c3afe, 0x1b1c573d, 0xad7fb118, 0x6924581e, 0x9d020866, 0x630661fd, 0x19552c70, 0x17b180ac, 0x3a5b1b1c, + 0x00278785, 0xff510001, 0x058504e5, 0x004000ec, 0x541440a2, 0x673b5801, 0x7f3b6901, 0x700c7f0b, 0x74327031, 0xb8320938, 0x4640e0ff, 0x0b37100b, + 0x08048220, 0x1d3d3e21, 0x09202034, 0x01307034, 0x34293030, 0x0d100234, 0x0d020d7f, 0x0934110d, 0x0b1e3d0a, 0x8317370d, 0x6c232b04, 0x0b0b143a, + 0x0c3a5502, 0x05820d0d, 0x3d1e1e2a, 0x170c033a, 0xffb80315, 0x08277418, 0x0a40f822, 0x032e2183, 0x31314273, 0x2f332f0c, 0x2b2bf610, 0x526c12ed, + 0x2bed2805, 0xed3f002b, 0x845d2f33, 0x79431804, 0x5d2b2209, 0x05946101, 0x47052d47, 0x35200944, 0x2305cd44, 0x32333523, 0x0c6e6218, 0x35230722, + 0x6408ae48, 0x6b080520, 0x3f301604, 0xe650465b, 0x4afb9385, 0x71f9630f, 0x3634a848, 0x33333c31, 0xb3c95991, 0x2e35d2ad, 0x4e4c6f2d, 0x64303b84, + 0xf84b0d17, 0x4bb17b7e, 0x7da3524e, 0xcd027634, 0x6966812a, 0x44443caa, 0x3bde1e37, 0x2d292a4b, 0x654f456f, 0xa91b1e1f, 0x5236787f, 0x1e151818, + 0x0d341114, 0x273620db, 0x5a88302c, 0x0f1bb07f, 0x00002f09, 0x0805d76c, 0xd1053940, 0x1e010900, 0x020b2340, 0x07190704, 0x15070703, 0x53025b07, + 0x62026c07, 0x70027f07, 0xc8087607, 0xe702e602, 0x0d07f607, 0xe8ffb807, 0x0f0b1640, 0x0c100237, 0x0607370f, 0x03040201, 0x02820308, 0x02070824, + 0x4f60ffb8, 0x20088205, 0x053b44fa, 0x10060227, 0x02550210, 0xef141914, 0x561f2016, 0x12280afe, 0x55020c0c, 0x0d0d2600, 0x78260582, 0x400b0f0b, + 0x6b82020b, 0x0f204782, 0x07214182, 0xe74a1814, 0xb4e62133, 0x10e74a18, 0x0c0cb42b, 0xb8045506, 0x09b6f6ff, 0x18088209, 0x200d2680, 0x09ec56ed, + 0x2b2bfd26, 0x3939112b, 0x08059d54, 0x312b2b23, 0x21715d30, 0x23011123, 0x01113311, 0xc5390533, 0xc5c81cfd, 0x04d1db02, 0x0557fba9, 0x0469fbd1, + 0x06954797, 0x8f07392a, 0x17000900, 0x32404d01, 0x2d214b41, 0x70100f0a, 0x10100210, 0x0d0faa14, 0x5a410d01, 0x41252005, 0x172f115a, 0x600a501a, + 0x110a020a, 0x100a101a, 0x41030400, 0x19244c69, 0x1940190f, 0x18636941, 0x410de65b, 0xed200969, 0x28056941, 0x39391211, 0x5d2fed2f, 0x077241ed, + 0x0b823320, 0x33200382, 0x4a0d7a41, 0x88410d84, 0x4ab52009, 0x96410c6f, 0x0d5f4a09, 0x1d71cd20, 0x00260805, 0x400b0120, 0x1f010983, 0x27012901, + 0x37013a20, 0x47014b20, 0x65015c20, 0x76206700, 0x0d207400, 0x0d0a201f, 0x04830c37, 0x03020236, 0x01c80188, 0x00b30102, 0x661e0020, 0x021b861b, + 0x0d12131b, 0x3f080182, 0x15041e1b, 0x2f320220, 0x08080108, 0x35160700, 0x03070315, 0x120d0005, 0x05201e1b, 0x01154f04, 0x220f1515, 0x00300020, + 0x50040040, 0x6e000100, 0x01224022, 0x09080408, 0x04550209, 0x100e0514, 0x6f050e47, 0x844418d1, 0xb8052205, 0x05744aff, 0xe8250882, 0x060f0fb4, + 0x0cd16f55, 0x0c0cb622, 0x6c211182, 0x0c6f6121, 0x105d3238, 0x325d5df6, 0x17125d2f, 0x2f2f0039, 0x11ed3f3f, 0x5d2f3912, 0xf04b39fd, 0xc05d2f06, + 0x87013031, 0x5dfd7a10, 0x01c00818, 0xfe452b2b, 0x6b332007, 0x372205f7, 0xe7453636, 0x053b080f, 0xa3fdfe75, 0x33c6c687, 0x4e28285a, 0x12230d1e, + 0x4fb4b945, 0x1f4e4553, 0x34172b1d, 0xa7025a6b, 0xd10559fd, 0x120164fd, 0x3e551719, 0xa62d521b, 0x1d19b186, 0x843b581a, 0x82002e7c, 0x122a08fa, + 0x1805fdff, 0x2100d105, 0x00b98a00, 0xb3acff1b, 0x09371009, 0x40c0ffb8, 0x370e0b16, 0x03203503, 0x17131301, 0x14010f35, 0xb34a0c00, 0x4af62006, + 0xf62207b3, 0xa2540db4, 0x40de2705, 0x020c0c1f, 0xa2540055, 0x23782405, 0x6201238f, 0x132206bc, 0x23831e20, 0xffb82023, 0x057344ec, 0x0916202e, + 0x20550209, 0x332f1220, 0x2b2b2b2f, 0x2e09d443, 0xfd2f00ed, 0x3f2f2f32, 0x2b3031ed, 0x5123212b, 0x05241f35, 0xe6fdc618, 0x201c1951, 0x1cff509b, + 0x72054d54, 0x3b2010eb, 0x240abd73, 0x05e1ff73, 0xb96372da, 0x42055f45, 0xb4240c91, 0x55060c0c, 0x5f451182, 0x4c637205, 0x00ffff2f, 0x05e5ff73, + 0x02ec0546, 0x00260016, 0x0f4f7100, 0x4f010021, 0x05250583, 0x001a00d1, 0x05814f8a, 0x814f4020, 0x0300212a, 0x241c634f, 0x011c501c, 0x17634f1c, + 0x2f3f0023, 0x32524ffd, 0x4f1e444f, 0x00201936, 0x3b277b18, 0x0c0c122e, 0x000f5502, 0x18152b07, 0x14070425, 0x30277b18, 0x3917ed24, 0x587bc410, + 0x005d2505, 0x39123f2f, 0xab277b18, 0x00ffff23, 0x0e657344, 0xfec82408, 0x05be05af, 0x010b00d1, 0x06124010, 0x080b0302, 0x08013504, 0x0a081405, + 0x55021010, 0xfcffb808, 0x840d0db4, 0x054d5f08, 0x230be072, 0x0909b4f6, 0xe22a1a84, 0x0d0d1a40, 0x14085506, 0x05820c0c, 0x09090622, 0x082c0582, + 0x400d1300, 0x0a370b09, 0xb4f8ffb8, 0x08824b83, 0x0fb4dc25, 0x8255020f, 0xa9561808, 0x0c162207, 0x220f820c, 0x820b0b08, 0x4d122005, 0x0d2405ab, + 0xb8011404, 0x82069654, 0x05234608, 0x8f500882, 0x08012106, 0x0f822683, 0x82051a46, 0x052c4608, 0x91430882, 0x20088205, 0x21b282e2, 0x08825506, + 0x83b4ec21, 0x75088290, 0x012005f5, 0x220c9850, 0x1811ed2b, 0x20086070, 0x097a56ed, 0x3f00ed25, 0x502f32fd, 0x43080c9c, 0x05231133, 0xc6c6fb02, + 0x8dc6dd02, 0xfad105bc, 0xfa2305dd, 0x0001fedd, 0x008e0001, 0x05ea0400, 0x001900d1, 0x351a40a6, 0x54114511, 0x74096c11, 0x0c020516, 0x05053514, + 0x030c1800, 0x14011700, 0xe6ffb800, 0x2705d455, 0x0f0f0600, 0x0a005502, 0x2006d845, 0x053a4fee, 0x0b0e0023, 0x2415820b, 0x40dcffb8, 0x2add830d, + 0x0f1b7800, 0x140d011b, 0x7bffb80c, 0x08820570, 0x1140f622, 0x0c273a83, 0x020c0c06, 0x4e100c55, 0xda2006b0, 0x0c283085, 0x06090914, 0x1a6a0c55, + 0x51070b47, 0xfd220974, 0xcc820032, 0x2f391222, 0x22059a6b, 0x4b112321, 0x2622059b, 0xbc603526, 0x112d080b, 0xc6ea0433, 0x6364dd81, 0x473f3fac, + 0x232314c6, 0xd6716b72, 0x7602c652, 0x35312a28, 0x0172a435, 0x5767fefc, 0x2f2f3079, 0xb1021e28, 0x05394b00, 0x82760721, 0x000b30f9, 0x0a1140ba, + 0x08030206, 0x09013404, 0x46060014, 0xaf8507c5, 0x84100021, 0x830420ea, 0xb80025b5, 0x0c40e7ff, 0xc62ae084, 0x04051408, 0xffb80114, 0xd583b4fe, + 0xf8210882, 0x822883b4, 0x46fc2008, 0x012105c8, 0x24288312, 0xb805c601, 0x05ea5dff, 0xda200882, 0x08822c84, 0x474ff220, 0xffb82705, 0x0b0bb4f8, + 0x11825502, 0x3b5ef620, 0x05052e05, 0x0d1f0c0d, 0x0d500d3f, 0x5d040d70, 0x20f68211, 0x2000832b, 0x220483f4, 0x84fd10ed, 0xed2b2707, 0x32fd2f00, + 0x7e52333f, 0x0733230d, 0xef82f976, 0x02c62e24, 0x7e52c62e, 0x05db2206, 0x23e98425, 0x0308affe, 0x0f24e982, 0x2340d300, 0x0c20e983, 0x0f24ea83, + 0x0800130d, 0x00207c83, 0x0024a884, 0x0c140900, 0xab41fb84, 0x20fb840a, 0x82fb840c, 0x20fb8615, 0x20fbb50c, 0x5ffb99f8, 0x052b0637, 0x1f101105, + 0x50113f11, 0x99117011, 0x2f3329fb, 0x00ed2b2b, 0x32fd2f2f, 0x2a110241, 0x23113311, 0x81f94707, 0x832e02c6, 0xbc8d2102, 0x26090841, 0x03fedbfa, + 0x82000200, 0x05230800, 0x00d105f4, 0x0021000e, 0x071340a4, 0x161b1b34, 0x03193518, 0x56163408, 0x081b010f, 0xffb81614, 0x5a10b4ee, 0xf8200561, + 0x21054858, 0xc2581e16, 0x05a84306, 0xf23a2182, 0x0b0b1540, 0x0e165502, 0x55020909, 0x167f164f, 0x19161602, 0xb80f1500, 0x3b84e8ff, 0xe0210882, + 0x823483b4, 0x43d02008, 0xc97e0522, 0x2c0f8205, 0x0e0a40f4, 0x710f3711, 0x01230f23, 0x2c671819, 0x11fd2208, 0x084f6d39, 0x005d3223, 0x05f17a2f, + 0x3031ed22, 0x2018345a, 0x07185a35, 0x58250521, 0xfe23154c, 0x58600266, 0x05221949, 0x4258b021, 0x00260806, 0x00c80003, 0x05950600, 0x000e00d1, + 0x0023001f, 0x441640f2, 0x3407010d, 0x17161919, 0x16340803, 0x56210322, 0xde84010f, 0x7fb4ec21, 0xda2106af, 0x064c7eb4, 0x83b3f421, 0xffb835cd, + 0x0c3d40c0, 0x0f0f3710, 0x0a201421, 0x55021010, 0x0b0b0020, 0x2f830583, 0x09002023, 0x220b8209, 0x820d0d19, 0x0c0e2205, 0x2005820c, 0x2a118420, + 0x250f2578, 0x19022570, 0x45161408, 0x08820731, 0x82053145, 0x06314508, 0x83081621, 0x450f822c, 0x08820531, 0x20088841, 0x218f82e2, 0x11825506, + 0x82053145, 0xb6ec2308, 0x11820c0c, 0x4b246c21, 0x57180b55, 0xfd230a99, 0x822b2f32, 0x5ded2700, 0x2f3f2f00, 0x9c5b3fed, 0x415d2005, 0x33211765, + 0x059c5e11, 0x11230125, 0x41530433, 0xae591567, 0xc6732208, 0x13655bc6, 0x6741d120, 0xc5fd2405, 0x4e00d105, 0x22200667, 0x22066b41, 0x411040a8, + 0x63410966, 0x41f62007, 0xee200763, 0x2b086341, 0x110e0f40, 0x21710f37, 0x2140210f, 0x463a2d41, 0x1622055f, 0xe154ffb8, 0x0a2d4105, 0x2d412020, + 0x5ded2212, 0x08204100, 0x411f1f41, 0x7d5c201b, 0x06174112, 0x0100003a, 0xe5ff6100, 0xec052905, 0xa4002a00, 0x1c3a0a40, 0x06641c49, 0x26040676, + 0x3907855f, 0x100a200b, 0x19341837, 0x40c0ffb8, 0x020f0f20, 0x28191955, 0x20242409, 0x17522834, 0x06092e05, 0x56031603, 0x241a0303, 0xb8031417, + 0x053f42ff, 0xd6230882, 0x190909b4, 0x240d5424, 0x0d1d40f2, 0x2012820d, 0x0cad5f73, 0x2418242f, 0x1f0c0f18, 0x2f0c020c, 0x2f33335d, 0x6385182f, + 0x39112308, 0x8018005d, 0x2b310b4d, 0x2b3031ed, 0x16015d2b, 0x02141512, 0x23040607, 0x295b1822, 0x37362707, 0x21353636, 0x7e532135, 0x6b222005, + 0x9a0805b7, 0x04043233, 0x69686061, 0xeffe6663, 0x57fe8da3, 0x8df75110, 0x4844cc7b, 0x03d3fc49, 0x475c0e23, 0x8966b447, 0x5d1157f0, 0x01ac85fe, + 0x602c050f, 0xacc2e4fe, 0x6a67dffe, 0xdb25366b, 0x4b574d41, 0xad80c950, 0x3939af77, 0xdc434d37, 0x00603527, 0xc8000200, 0xd307e1ff, 0x0b00f005, + 0x27011e00, 0x14783240, 0x06030901, 0x1a161509, 0x5916561c, 0x7616791c, 0x340c081c, 0x14131e13, 0x34031c03, 0x03100216, 0x091c3409, 0x0619130f, + 0x09080c15, 0x0c550209, 0x40f6ffb8, 0x820b0b2b, 0x0c142209, 0x2205820c, 0x820d0d04, 0x0f252205, 0x3705820f, 0x0210101a, 0x3f0c1855, 0x6f0c580c, + 0x0c0c040c, 0x1915000f, 0xb4d0ffb8, 0x08822e83, 0x82054e41, 0xb4e22108, 0x08823a83, 0x1740e722, 0x19213e83, 0x213e8314, 0x3e830419, 0x20731926, + 0x0f140e12, 0x8207ce43, 0x058e4108, 0xce430882, 0x08094506, 0x2245ea20, 0x05ce4307, 0xce432182, 0x42088205, 0x088305a0, 0x2705975d, 0x09090a0f, + 0x6c0f5506, 0x0c12bb18, 0x4232fd21, 0xed2107b5, 0x083d4512, 0x002c0a82, 0x3fed3f2f, 0x1712ed3f, 0x5ded2f39, 0x32078b6b, 0x00101100, 0x01003233, + 0x11231123, 0x12331133, 0x83202100, 0x08058212, 0xfe05072a, 0xfedddbff, 0xdc0301fe, 0xfb0101db, 0xc6c6f079, 0x6a0124f9, 0x3f011301, 0x90fe6c01, + 0xccfec5fe, 0xe80291fe, 0x35012801, 0x69080982, 0xfedbfed7, 0x013601c9, 0x0530fd0e, 0x01acfdd1, 0xfe46012d, 0xfe95fe63, 0x0166fe93, 0x02000089, + 0x00002c00, 0xd105de04, 0x1f001000, 0x0c40e900, 0x06350328, 0x075a1c47, 0x04051759, 0x40e8ffb8, 0x3710092e, 0x05130403, 0x0f060605, 0x40033411, + 0x55020d0d, 0x03010340, 0x34120003, 0x0500030f, 0x12091519, 0x55020f0f, 0x19831609, 0x32820920, 0x0c0cb422, 0xb8260e82, 0x1240f0ff, 0x09820b0b, + 0x03060429, 0x055f0409, 0x49120501, 0x1c840c98, 0x830c0021, 0xb800233b, 0x9777ddff, 0x0c002105, 0x0f824583, 0x82058868, 0x63f62008, 0x002905d8, + 0x060d0d0a, 0x0c0a0055, 0x2605820c, 0x40f6ffb8, 0x8209090e, 0x21782809, 0x2140210f, 0x18032160, 0x240c4f40, 0x5d2f32fd, 0x05604a17, 0x2f00ed22, + 0x0805d260, 0xed2b5d21, 0x30313912, 0xfd108701, 0x5d002bc0, 0x21112321, 0x26012301, 0x36343526, 0x33363637, 0x6e110321, 0x50080c89, 0xfec6de04, + 0xee43febf, 0xa596de01, 0xbe474e5f, 0xc6ea0173, 0x6856d2fe, 0x25342e2b, 0x56822d29, 0xb0fd5002, 0xd5336e02, 0x37a572b3, 0x24fd2832, 0x1d163202, + 0x5043701f, 0x1e2c296a, 0x00ffff00, 0x04e1ff68, 0x0278041d, 0x00440016, 0x00020000, 0x080f8274, 0x1d067c44, 0x39002700, 0x1640ce00, 0x04351f0c, + 0x3930293d, 0x294b0440, 0x12653940, 0x33731275, 0xffb8330a, 0x0b1d40c0, 0x0622370d, 0x2500412b, 0x25022510, 0x41190625, 0x3f370018, 0x31220a06, + 0x280c1818, 0xd66bffb8, 0x1b282305, 0x776ab803, 0x45088206, 0x08840581, 0x020d0d23, 0x23088255, 0x0c0cb4d4, 0xaf490884, 0x24118205, 0x092f40f8, + 0x28128209, 0x3b1f3b90, 0x3b023b3f, 0x21208340, 0x05841231, 0x080c1b22, 0x0c270783, 0x020b0b18, 0x83220c55, 0x860c2727, 0x2bf6103a, 0x926b2b2b, + 0x2bed260b, 0x122f3912, 0x07475b39, 0x12ed5d33, 0x2b303139, 0x1616015d, 0x23001415, 0x26272622, 0x054d4102, 0x36363722, 0x15210283, 0x07ba5706, + 0x33363627, 0x34131632, 0xab841826, 0x03b1080e, 0xfe4846ee, 0xb66cdbd4, 0x0e4f5040, 0x354d1419, 0x4fc2eb48, 0x81423688, 0x30cf8040, 0x4b083535, + 0xae5e65b3, 0x5792b20f, 0x030248a0, 0x6c2e353a, 0x03aa973e, 0x86c746b8, 0x49b6fefa, 0x21015f4c, 0x6c9b4bd0, 0x4935ac5d, 0x09071159, 0x0804ad04, + 0x313e0b06, 0x364dab35, 0x22fe3e49, 0x2e37b7b9, 0xae1c4319, 0x2d3640d8, 0x000300da, 0x040000b9, 0x005d0453, 0x00240015, 0x40fc0033, 0x05030a0c, + 0x15031a14, 0x05237614, 0xd6ffb80c, 0x0c092040, 0x2c111237, 0x011e4f3c, 0x1d071e1e, 0x2d05083d, 0x1608073d, 0x0f2c121b, 0x02101006, 0xffb80f55, + 0x07ea46f0, 0x4240e624, 0x12820d0d, 0x0b0b1222, 0x0c220582, 0x05820909, 0x25070f2b, 0x0f08001b, 0x0055020f, 0x211c8308, 0x1c830200, 0x0d10002d, + 0x90003710, 0x01350f35, 0x83082c1e, 0x0c2c2928, 0x55020c0c, 0xb8071a2c, 0x82063f7c, 0x84e02008, 0x21088258, 0x3a83b4ee, 0xf6200882, 0x70058649, + 0xb822061a, 0x2182ecff, 0x82550621, 0x05394818, 0xf6230882, 0x820c0cb6, 0x34882111, 0x0cb11819, 0x105d3224, 0x00822bf4, 0x8a4bed20, 0x39122207, + 0x07b141ed, 0x307c7120, 0x765d2005, 0x904906db, 0x06297c07, 0x80180320, 0x13200d3d, 0x71080e8d, 0x39415304, 0xfe7b9740, 0x7db00132, 0x3b3f387f, + 0x81634a5e, 0x2a201ffd, 0xebc44d69, 0x2624474a, 0x3d243b1d, 0xf14e5826, 0x2c7970b2, 0x52012b2c, 0x2f2a7e51, 0x115d042a, 0x486a211d, 0x0a227a53, + 0x7d018918, 0x15103a24, 0x0bcefe05, 0xfe411816, 0x1d453742, 0x93fe0712, 0x4819190f, 0xb9000100, 0xbb030000, 0x05005d04, 0x1a408300, 0x05043f01, + 0x15827003, 0x18070021, 0x200d3c85, 0x07324103, 0x32410882, 0x41088205, 0x08820532, 0x76063241, 0x3241066c, 0x5d188207, 0xec200820, 0x28059d45, + 0x09091403, 0x88035506, 0x09394106, 0xe9722b20, 0x005d3705, 0x31ed3f2f, 0x11210130, 0x03211123, 0xbcbafdbb, 0xb8030203, 0x998248fc, 0x09000226, + 0xaf04f4fe, 0x20080982, 0x0013000d, 0x3b2240cd, 0x02124a12, 0x3e100501, 0x130c050a, 0x10033e07, 0x020c0c0c, 0x0ac91055, 0x05574f10, 0xb80e0722, + 0x82069278, 0x05a87308, 0xb6200883, 0x0e241d83, 0xffb80c1a, 0x8305df4f, 0x05e34408, 0x0d0a0c29, 0x0c55060d, 0x820c0c0a, 0x21be8205, 0xa6830940, + 0x010c0c27, 0xffb800c9, 0x056b60e0, 0x70100021, 0x084d0ae7, 0xb8200805, 0x1240c0ff, 0x00370e0b, 0x152f1500, 0x1302153f, 0x0407071a, 0xed2f05c9, + 0x5ded2f39, 0x2b2f3311, 0x6f4f0083, 0x23e68207, 0x2f39122b, 0x0028ee82, 0x3232fd2f, 0x332fed3f, 0x0813ee5c, 0x0702065d, 0xfcafaf04, 0x7579afb8, + 0x87be0273, 0xaffebdfe, 0xfe53800d, 0xfe0f01f4, 0xc1ac01f1, 0x0301f901, 0x1f0343fc, 0x8662fefb, 0x00ffff00, 0x04e6ff6a, 0x027c0460, 0x00480016, + 0x00010000, 0x06000034, 0x005d0432, 0x40d80031, 0x3a0e3a12, 0x4a0e4a2d, 0x5f0c5f2d, 0x6f0c6f2f, 0x8226082f, 0x09b324cd, 0x8215370b, 0x1a402107, + 0x24260882, 0x2f2d2db4, 0xf85cb417, 0x821a2009, 0x05f85c39, 0x095e5d08, 0x1a083710, 0x240a0909, 0x2903171c, 0x07313c1f, 0x2f0e0c0a, 0x0229072d, + 0x043f2a11, 0x1d120209, 0x00052905, 0x31210a2e, 0x31510a5e, 0x31600a6f, 0x31700a7f, 0x01292908, 0x2d240231, 0xc700062f, 0x051a041f, 0x0a081212, + 0x170e0c07, 0x1cc70906, 0x32330505, 0x333f3310, 0x336f334f, 0x5c05b54d, 0xc35c07c4, 0x09c65629, 0x5c012321, 0xc25c06c5, 0x32320822, 0x5b9afee3, + 0x8afe51ba, 0x31af01d9, 0x4a1b1f4b, 0x7c453554, 0x1b092d96, 0x4067210a, 0x216940ba, 0x2c081b0b, 0x35457d94, 0x1c194b55, 0xfe012d4d, 0x038302fe, + 0x49024208, 0x5561601a, 0x7d64a242, 0x4c17431a, 0xe401043f, 0x40041cfe, 0x1942194b, 0x46a2667b, 0x19635951, 0x41000100, 0xc203e6ff, 0x3d007804, + 0x26b7bb00, 0x7d127534, 0xb82f033c, 0x2f40e0ff, 0x0837100d, 0x08048220, 0x3f1b3b39, 0x1cbf1caf, 0x061c1c02, 0x902d3f31, 0x032da02d, 0x3e292d2d, + 0x0a200431, 0x0a020a30, 0x063f0e0a, 0x232e1c09, 0x40f4ffb8, 0x020c0c0e, 0x371b2355, 0x3b371c2e, 0x83140904, 0x830d2012, 0x1b142112, 0x2108ae47, + 0x8c18b4de, 0xf03c0f42, 0x09091740, 0x90005502, 0x803f7f3f, 0x0980023f, 0x09020990, 0x370f0b40, 0x5d2b2f09, 0x29069d47, 0x17122bed, 0x2bed2f39, + 0xcc5c2f2f, 0xed5d220e, 0x05a84a39, 0x0e641420, 0x0bc95c11, 0x5c363721, 0xc95c0acc, 0x03640810, 0x444457c2, 0xd27452a4, 0xe2490d66, 0x276a326a, + 0x2a31322a, 0xa3307429, 0x28812871, 0x24303d34, 0x66235b25, 0x530d43c5, 0x9b4e5fbe, 0x6d544243, 0x017a675c, 0x28825e39, 0x2e2c2427, 0x134640ce, + 0x3a431815, 0x1212483c, 0x0d06a208, 0x2f443e11, 0x0c11113d, 0x1bcf3437, 0x22221c22, 0x85585675, 0x8919071d, 0x0805ab44, 0x04660427, 0x0109005d, + 0x0b134007, 0x02070402, 0x0301030d, 0x37100b38, 0x100e3802, 0xffb80737, 0x0c1640f2, 0x02550211, 0x2005830e, 0x05b55c07, 0x08030523, 0xca831808, + 0xb6f8230b, 0x22820909, 0xb8001a24, 0x4c61e0ff, 0x20002105, 0x200f7f7e, 0xbc7518ea, 0x091c2f10, 0x00550609, 0x0b1f0b92, 0x03020b60, 0x31830c07, + 0x21062346, 0x1d45041a, 0x45088207, 0x0882051d, 0x82051d45, 0x061d4508, 0x830c0421, 0x210f8276, 0xae5cb4f0, 0x051d4510, 0x830a0421, 0x88042263, + 0x0d1d450a, 0x465d3921, 0x2b250558, 0x2b2bfd2b, 0x07375b39, 0x2b303123, 0x0bac5c2b, 0x66042608, 0xaab7fdba, 0xb04302ba, 0xb9fc4703, 0xc5fc5d04, + 0x00003b03, 0x00b90002, 0x06660400, 0x00090015, 0x40360117, 0x1135411d, 0x100f0a2f, 0x14101001, 0x070d0d50, 0x40f2ffb8, 0x133f412b, 0x1fc91734, + 0x020a2f0a, 0x00c9110a, 0x20101010, 0x0a100310, 0x54410410, 0x7ae62030, 0x54411084, 0x1f192406, 0x41196019, 0x18205e54, 0x21105441, 0x00842bf6, + 0x2b2bfd24, 0x3b671239, 0x0b955c05, 0x945ced20, 0x0d644105, 0x410d965c, 0x6b2d0972, 0xa9a9b105, 0x01ab05b1, 0x5a59585b, 0x09804101, 0xb8012c08, + 0x94a6a694, 0x6b5c5e69, 0xc1000100, 0xa9040000, 0x1a005d04, 0x4d40ef00, 0x0e092001, 0x27021b37, 0x320e361a, 0x051a3516, 0x821a0102, 0x1b0a3318, + 0x020f2b0f, 0x1816b40f, 0x180f0a16, 0x1a120416, 0x795c3c02, 0x3f133106, 0x05070512, 0x56080501, 0x9600961a, 0xb600b61a, 0x1a203482, 0x12262383, + 0xc0ffb800, 0x4f821b40, 0x1c000027, 0x1c1f1c0f, 0x3cf67d02, 0x48087f5c, 0x052205ef, 0xef48ffb8, 0x89052205, 0x0eef481b, 0x2208ee7d, 0x5c3c3f00, + 0x7120107e, 0x24057e5c, 0x5d01c0fd, 0x0678622b, 0x6c113321, 0x5e6205ce, 0x0442080b, 0x30fef6a9, 0x5dbcbc66, 0x1b0e2872, 0x929c340d, 0x594f5356, + 0x32592824, 0x00fe0002, 0x1efe5d04, 0x3d1b4a43, 0xa270711c, 0x5d5e5443, 0x00010018, 0x04feff1d, 0x005d043e, 0xb9cf0021, 0xacff1b00, 0x655c0db3, + 0x820e2006, 0x3e023208, 0x13000521, 0x0f3f1713, 0xf4ffb801, 0x020c0cb4, 0x43088255, 0x012505f0, 0xffb8001a, 0x057763f2, 0x0b0c0029, 0x0055020b, + 0x820f0f0e, 0x090c2205, 0x21058209, 0xa256ffb8, 0x0d0d2108, 0xec200f84, 0x2406ae42, 0x060d0d0a, 0x203b8255, 0x844f82f6, 0x40ec2208, 0x050c4410, + 0x0c032323, 0x2a2b820c, 0xb8201a03, 0x10b4dcff, 0x82550210, 0x40ee2208, 0x21568312, 0x62830e20, 0x30202027, 0x20200220, 0x06006e12, 0xd76fed20, + 0x852b2005, 0x2bed2300, 0xaa5c002b, 0x06bb4b12, 0x26222326, 0x32333523, 0x08077073, 0x3736365d, 0xbc3e0421, 0x06035ffe, 0x1a200703, 0x22223b18, + 0x41113153, 0x1e080a0a, 0x1233180a, 0x040a3e33, 0x01030307, 0x9a53bf03, 0x42c7a73e, 0x1e1f4d3e, 0x02a4021e, 0xee32130e, 0x66e152e1, 0xb9000100, + 0xd9040000, 0x0c005d04, 0x13405501, 0x0b3a0935, 0x044a0345, 0x047f0370, 0x41400b06, 0x10200744, 0x34080882, 0x057b027b, 0x0a030a79, 0x370b092a, + 0xecffb80a, 0x11102440, 0x0a055502, 0x04090302, 0x37100e40, 0x0f0d2004, 0x01043f37, 0x0b070404, 0x07010509, 0x030b0a09, 0xfe431805, 0x066f4117, + 0x410b734e, 0xf220076f, 0x2105684b, 0x6f410e00, 0x40f6221f, 0x056f4121, 0x0e0f0e29, 0x05020e20, 0x820f0f04, 0x0c0c228f, 0x2105830d, 0x05820909, + 0x291fd24b, 0x020c0cb4, 0xffb80755, 0x2e83b4f0, 0xd44b0882, 0x05a14a08, 0x200ad44b, 0x09e4420d, 0x792bed21, 0x2b210c16, 0x3710822b, 0x00391711, + 0x333f332f, 0x5d2f3912, 0x17122b2b, 0x30312b39, 0x015d2b00, 0x2a082982, 0x01112321, 0x23110123, 0x01013311, 0xbad90433, 0xfe8ceafe, 0x01e3b0ec, + 0xe7260130, 0xc2fd7203, 0x8efc3e02, 0x8ffd5d04, 0x41007102, 0x6034068d, 0x0b005d04, 0x0d40ea00, 0x08083f03, 0x05070a05, 0x09080501, 0x25184941, + 0x02101011, 0xfc840055, 0x46220021, 0xac420fb0, 0x42062007, 0xec2106ac, 0x065b4540, 0x0d1f0d28, 0x08020d60, 0x31830c03, 0x1806a14b, 0x460c0842, + 0x052205b0, 0xb046ffb8, 0x46088205, 0x052206b0, 0x9066090c, 0x052c4105, 0x460cff5d, 0x052705b0, 0x0609090a, 0x6b880555, 0xe97c0b04, 0x05e14206, + 0x0d832b20, 0x413f0021, 0x5018052f, 0x33380966, 0x33112111, 0xfdbc6004, 0x02bcbcd1, 0xf701bc2f, 0x5d0409fe, 0xc4013cfe, 0x42100d7e, 0x603205b5, + 0x07005d04, 0x03b6dc00, 0x0005063f, 0xffb80105, 0x9a83b4f4, 0xb6200883, 0x0125d683, 0xffb8001a, 0x06775aea, 0x23262041, 0x091b40f0, 0x0029bc82, + 0x091f0992, 0x04020960, 0x4748830c, 0x1f4106a3, 0x05d0472e, 0x201a1f41, 0x0d7b4608, 0x25069449, 0xed2b2b2b, 0x51182b2b, 0x15410e80, 0x03440805, + 0xfcbb03a7, 0xff5d0445, 0xfeb900ff, 0x04900464, 0x0016027c, 0x00000053, 0xff6a0001, 0x04fd03e7, 0x00210077, 0x0f674084, 0x5f234f23, 0x012b0323, + 0x162a0e22, 0x013a1824, 0x163a0e35, 0x01491835, 0x0e440a4f, 0x1f9d2619, 0x0024f083, 0x06172300, 0x17290883, 0x0d08091b, 0x0955020d, 0x230d8308, + 0x0b0b0c09, 0x21089274, 0xbe852285, 0x112bed26, 0x3c2b2f33, 0x2308e754, 0x015d3031, 0x24058374, 0x26262726, 0x0f997d35, 0x0805c375, 0x0333373b, + 0x52a573fd, 0x4949cc7a, 0x01280151, 0x4ebb6101, 0x55b55d0b, 0xa8b6b7a7, 0x2630753b, 0x460b1051, 0x48472936, 0x0193dc48, 0x363f010b, 0x4447d127, + 0xdcc7c7e0, 0x3513181e, 0x21ed820d, 0x9318000a, 0x762307dd, 0x18031e40, 0x223bdd93, 0x180c0b1c, 0x2007dd93, 0xd79318a0, 0x1833201b, 0x2125d693, + 0x4b18ffff, 0x02240761, 0x005c0016, 0x3108a682, 0x64fe6f00, 0x14064b06, 0x30002300, 0xcf003d00, 0x22561040, 0x1b011d01, 0x04090c1e, 0x3f352706, + 0xffb81821, 0x0e1c40f0, 0x0418370f, 0x0f3f2e3b, 0x0a821006, 0x0b090633, 0x3624390c, 0x46244938, 0xb8240438, 0x2c40f4ff, 0x2fa7820c, 0x10001b24, + 0x55020f0f, 0x3109c800, 0x042b1e1b, 0x29061b6f, 0x0209090c, 0x0c1a0955, 0x24830c38, 0x121b3822, 0xb6205182, 0x12252783, 0xffb80cc8, 0x050043f6, + 0x39840c20, 0x0d020c23, 0x06c4550d, 0x0b0b183a, 0x0c805502, 0x0c020c90, 0x0f3e3f0c, 0x3f3f1f3f, 0x803f503f, 0x115d053f, 0x2c05c544, 0x2bfd2b2b, + 0xed102bed, 0x39172b2b, 0x270a8310, 0x3f3f005d, 0x32fd332b, 0x12240484, 0x313f3917, 0x07915118, 0x26222324, 0x585d1127, 0xf0261905, 0x3611240c, + 0x19323336, 0x080d8229, 0x261105a0, 0x06222326, 0x33161415, 0x4b063632, 0xa23e3f4c, 0x27634359, 0x544f3dba, 0x3f4ef0c1, 0x3c52a53d, 0x2eba3163, + 0xe2c63f7c, 0x378888c1, 0x3f2f3f4a, 0xfd9b8d3a, 0x31502776, 0x878fa187, 0x4c025b35, 0x4a4ae595, 0xfe132e4e, 0x1ecd0133, 0x012e0123, 0x4bdd8d0d, + 0x1e254d49, 0x1ffee101, 0xd5fe281b, 0xdebfecfe, 0x17fd1912, 0xaad91916, 0x1912e902, 0xe0c3d2ce, 0x00ffff1d, 0x0400003c, 0x025d0480, 0x005b0016, + 0x00010000, 0x04f4feb9, 0x005d04de, 0x401b010b, 0x05020609, 0x3f04080b, 0x46440501, 0x32088307, 0x0c0c0d40, 0x1a055502, 0x0f0f0808, 0xb8085502, + 0x83b4feff, 0x21088210, 0x1460b4fa, 0xb4f42306, 0x1a840b0b, 0x805df420, 0x0a082905, 0x55060d0d, 0x0c0c0608, 0xb8220582, 0x3450f6ff, 0x08082705, + 0xb80ac900, 0xf746ecff, 0x240a2105, 0x0a214583, 0x0af55f12, 0xc0ffb828, 0x0d091f40, 0x3e820a37, 0x0e094027, 0xaf0d8f37, 0x0e7d440d, 0x4e4c0120, + 0x45088207, 0x0882059d, 0x82059d45, 0x069d4508, 0x090c0125, 0x82550209, 0x05af490f, 0x210b0b60, 0x9383b6e2, 0x96450120, 0x2bed230b, 0x41185d2b, + 0xa155096a, 0x442b2005, 0x04600780, 0x2f043412, 0x02bc8afc, 0xaf87bc26, 0x45fc5d04, 0x45fcbb03, 0x600052fe, 0x1f3d0605, 0x16005d04, 0x16400101, + 0x061c060c, 0x0e75062c, 0x11090204, 0x0005053f, 0x00050915, 0x49888214, 0xf6200878, 0x2b05b35f, 0x0a001a01, 0x55021010, 0xe6ffb800, 0x2105285d, + 0xf3471a00, 0x40fa2406, 0x180c0c11, 0x20083e42, 0x06894918, 0x7949f220, 0x460c2006, 0x192008cc, 0x2505ab45, 0x01183f18, 0x31830c0a, 0x830a0a21, + 0x1a0a222b, 0x07386009, 0x8d550882, 0x22088205, 0x831140fe, 0x0609215f, 0x09252983, 0x020b0b0e, 0x831e8455, 0x96711832, 0x0c10260d, 0x0955060c, + 0x245d841e, 0x02091009, 0x075b5d09, 0x820e8155, 0x2bfd220e, 0x1560602b, 0x5d603520, 0x1f24080e, 0x62a65bbc, 0x10bcbeb4, 0x545e1a1a, 0xbc3ca245, + 0x221cad01, 0x9601a7b1, 0x6540cafe, 0x1b262425, 0x001d0212, 0x32050148, 0x5d044906, 0xe2000b00, 0x060a0a40, 0x04080502, 0x8208013f, 0x053f419f, + 0xf8200882, 0x20053f41, 0x093f4109, 0x3f41f620, 0x41042006, 0xf222063f, 0xc94a2a40, 0x23da8305, 0x0c08ca00, 0x0821f183, 0x230d8308, 0x04051a08, + 0x04200e84, 0x04260e84, 0xffb8011a, 0x9f75b4f0, 0x40fc2206, 0x2541830b, 0x0b0b1401, 0x18835502, 0x3283b620, 0x05ca0125, 0x84eaffb8, 0x22088223, + 0x832240f2, 0x0e052123, 0x05215383, 0x2b298300, 0x05a00580, 0x0d050502, 0x200d0f0c, 0x200a7960, 0x0979605d, 0x102b2b26, 0xf42b2bfd, 0x2b251083, + 0x002b2bed, 0x127f603f, 0xfa490626, 0xae01bc70, 0x5d420283, 0xbb032207, 0x05a74300, 0x04d00638, 0x000f005d, 0x0a1040ef, 0x0c050206, 0x013f0408, + 0xc90d0e08, 0x17410000, 0x08e07014, 0x21061741, 0xf544040c, 0x06174106, 0x830e0c21, 0x410c20d6, 0x24204f17, 0x05216583, 0x0b17410a, 0xa0059030, + 0x05050305, 0x110f1011, 0x113f111f, 0xe152116f, 0x19194105, 0xed2f3925, 0x603f2f00, 0x0623179b, 0x4198fa21, 0x82430622, 0x06864309, 0x0a00023a, + 0xc4040000, 0x0e005d04, 0xba002100, 0x010d75b5, 0xb81b3d07, 0x1440c0ff, 0x4f389783, 0x021b9f1b, 0x18161b1b, 0x0805193f, 0xb80f163d, 0x1f40f0ff, + 0x1b370b09, 0x280d1c42, 0x10100a16, 0x1e165502, 0x051a7b0f, 0x60b4f221, 0xfe2006ba, 0x2305954b, 0x0b0b0a16, 0xb8221e82, 0x1f5ae2ff, 0x1c162105, + 0x25118179, 0x060c0c1a, 0x81791655, 0x0f1b3008, 0x230f238f, 0x232f231f, 0x5d2f1903, 0x7afdf610, 0x2b260ae5, 0x2b2bfd2b, 0xae602b32, 0x2b5d2507, + 0x5d3031ed, 0x21062b5e, 0x2a481123, 0x05835206, 0x21112124, 0x12822135, 0x17163f08, 0x02041616, 0x6b2a2823, 0x64acb064, 0x2529286e, 0x423841c2, + 0x55fe7696, 0x0402b8fe, 0x458b7ef4, 0x57013a3a, 0x19184d33, 0x1184fe0a, 0x3a471a18, 0x32298451, 0xa5b8032a, 0x331a4dfe, 0x7958862b, 0xa2052305, + 0xad605d04, 0x17012d05, 0x230520b5, 0xb8193d07, 0x1540c0ff, 0x2408ed83, 0x199f194f, 0x16191902, 0x3d080517, 0x01007916, 0xf0ffb80f, 0x0b090f40, + 0x501b0037, 0x700f600f, 0x0f0f030f, 0x07474e23, 0x8e430883, 0x1a232b05, 0x0b0b0e22, 0xb8225502, 0x8e43eeff, 0x26222305, 0x0f840c0c, 0x5643fe20, + 0x19222305, 0x0f840909, 0x82055e7c, 0x053b4e28, 0x20313184, 0x55060909, 0x0f259222, 0x40253025, 0x04257025, 0x06984119, 0xb5430c20, 0x45162005, + 0x088207fd, 0x8205fd45, 0x05fd4508, 0x48830882, 0x82550221, 0xb4ec2108, 0x26109041, 0x060c0cb6, 0x60881655, 0x8b4b09d0, 0x832b200d, 0x5d2f230e, + 0xae5f2bed, 0x2b5d2407, 0x623f2fed, 0x86410838, 0x41332010, 0x13250684, 0x03231133, 0x13884169, 0x8541bc20, 0xbcbb2205, 0x128841bc, 0x415d0421, + 0x02230587, 0x52a3fbb1, 0x35200687, 0x21068b41, 0x8641b2a0, 0x091d2d20, 0x1b00370b, 0x0f218f0f, 0x02212f21, 0x20352241, 0x072241e4, 0x200fc560, + 0x09c56088, 0x41062241, 0x12410c14, 0x73032821, 0x6b2a2823, 0x42b6ba64, 0x4b220b97, 0x9442febc, 0x070b4117, 0x0001003e, 0x03e7ff53, 0x007704f6, + 0xb59c0021, 0x04420432, 0xffb81002, 0x0b0940d6, 0x2a15370d, 0x1d200482, 0x22250d83, 0x0837100b, 0x3e04822a, 0x13133d12, 0x1b1b1f06, 0x041f3e17, + 0x0a010a9f, 0x063e0e0a, 0x111c1409, 0xffb8031a, 0x5c0db4f4, 0x98480572, 0x22118205, 0x5c2240e8, 0x23300569, 0x0d094023, 0x132f1c37, 0x134f133f, + 0x131c1303, 0x2b061456, 0x09370c09, 0x335d2b2f, 0x2f5d2f33, 0x22058950, 0x563911ed, 0x11200911, 0x2005e362, 0x2700822b, 0x1616015d, 0x21001015, + 0x250ab660, 0x26213521, 0xb0602326, 0x16500808, 0x50495d03, 0xfcfec9fe, 0x0d43bf66, 0x9d6dc63c, 0xccfd0cc4, 0xbe143302, 0x57b45b8e, 0x67c23f0d, + 0xed03c87c, 0xfe90d246, 0x30b8feea, 0x492fce1b, 0x9e97bac0, 0xce433d9f, 0x00443a19, 0xb9000200, 0x4c06e1ff, 0x0b007c04, 0x44011e00, 0x0c1809b6, + 0xe822cc85, 0x09833140, 0x35033a2a, 0x45034a09, 0x3e0c0409, 0x3506a360, 0x1004163f, 0x1c3f0905, 0x19130f0a, 0x0c0c0606, 0x1a065502, 0xdf76200c, + 0x43fc2006, 0x0c210587, 0x06fe450c, 0x83b4ea21, 0xb80c3c20, 0x1340fcff, 0x55020b0b, 0x09090c0c, 0x0c2f5502, 0x0f0c0c01, 0xb8191b00, 0x83b4f6ff, + 0x25088239, 0x0f0fb4e6, 0x08825502, 0x83b4fc21, 0x6011843b, 0xd62106b3, 0x06ce60b4, 0x1c40f822, 0x19283e83, 0x202f2090, 0x1202203f, 0x0d058618, + 0xaf430f20, 0x01861807, 0x216f8324, 0xb8605506, 0xb48b1819, 0x0cbf430c, 0x220bba60, 0x6039122b, 0x2b250cbb, 0x0130312b, 0x096e4b34, 0xbc602520, + 0x36630806, 0x00323324, 0x23001011, 0x8a050022, 0xa19993a6, 0xa79292a8, 0xbce8d3fc, 0x0119edbc, 0x01e7c711, 0xebf2fe12, 0x02f5fede, 0xdfd5d72e, + 0xd5d7d4cd, 0x0406fea2, 0xe73bfe5d, 0xfec4fefd, 0xfef1feee, 0x002001c2, 0x00430002, 0x04130400, 0x0010005d, 0xb3de001f, 0x04011c72, 0x40e8ffb8, + 0x3710093c, 0x60b40403, 0x2e0805a0, 0x0003033c, 0x050f3d12, 0x09090500, 0x19020919, 0x020c0c0c, 0x701b1955, 0x04090109, 0x04090306, 0x051a050a, + 0x055a054a, 0x05900580, 0x4f120506, 0x40210cc3, 0x06c44f13, 0x10100a28, 0x14005502, 0x05820b0b, 0xeaffb822, 0x2205d441, 0x53090000, 0x9946059f, + 0x1e002106, 0x2608fb48, 0x060f0f0b, 0x530e0055, 0xf6240f9f, 0x09090a40, 0x92241882, 0x01210f21, 0x210d9f60, 0xa1602b2b, 0x05054505, 0x2005a060, + 0x099e60ed, 0x215d0124, 0x595a1123, 0x099e6005, 0x080c3b5f, 0xbc13043a, 0xdda6fedd, 0x86917801, 0x9c3c3d50, 0xbcae015c, 0x28444ded, 0x24172527, + 0x01416a25, 0x0145febb, 0x86a528cd, 0x26277c59, 0x01f2fd1b, 0x16160a78, 0x44372c4b, 0xff151d1e, 0x3206ad5b, 0x3602db05, 0x00004800, 0x8e001601, + 0x140000f9, 0x19030d40, 0x3d10cb0f, 0x13000100, 0x62046dfe, 0x35001406, 0x30402101, 0x261e1c05, 0x0559281e, 0x1d720569, 0x8e181706, 0x2f340dbb, + 0x012a2a3e, 0x0f150d2a, 0x2e6f2e5f, 0x2e032e7f, 0xb8000d2e, 0x83062151, 0x0cb62808, 0x0055020c, 0x49b8211a, 0x088206d9, 0x1140fc2a, 0x55020b0b, + 0x0f0f0421, 0x0c220582, 0x05820909, 0xfcffb823, 0x240886b4, 0x0d2740fe, 0x2012820d, 0x26398322, 0x1f379121, 0x18376037, 0x2342af8e, 0x0f0fb4ec, + 0x1c257f18, 0x26513620, 0xaf8e180a, 0x2bed3210, 0x2f39122b, 0x002f2f5d, 0xed5d2f2f, 0x12ed3f3f, 0x270f8239, 0x313939ed, 0x26005d30, 0x094ff118, + 0x11231123, 0xb28e1823, 0x1725080d, 0x14151614, 0x02060706, 0x23060607, 0x35272222, 0x13363233, 0x03353636, 0x010101a5, 0x591a1913, 0x4cac5046, + 0xcb8e18bc, 0xc1230807, 0x03bbb162, 0x03010203, 0xb9464754, 0x2a18176a, 0x099cbb44, 0x06020101, 0x80502b4b, 0x4d292b29, 0x18befc3a, 0x3809e08e, + 0x6b2fc9de, 0x3a703a4b, 0x50fffeb0, 0x9e024e50, 0x225001f6, 0xff002e4b, 0x05575fff, 0x02820639, 0x000b0236, 0x00160100, 0x00f69a8d, 0x0001b60a, + 0x05040709, 0x51352b25, 0x042f05c9, 0x0077040a, 0xb57c0021, 0x0a4b0a3b, 0x46b81b02, 0x16250609, 0x370d0b2a, 0x250d830e, 0x37100b40, 0x04822a01, + 0x3d192008, 0x0c031818, 0x3e141010, 0x2121040c, 0x09033e1d, 0x18301820, 0x18031840, 0x03101817, 0x458e001a, 0x1a2b05f3, 0x0b0c091a, 0x0955020d, + 0x8209091c, 0x05ba5105, 0x102bed27, 0x391711e6, 0x0da2662f, 0x3031ed23, 0x5100822b, 0x550817c1, 0x21152107, 0x32331616, 0x04333736, 0x7b9f4e0a, + 0x4c4cd17d, 0x012b0152, 0x45bb680d, 0x65c2400c, 0x0219c78f, 0x0ac1fd3c, 0xbd6ca4c4, 0x20300c3e, 0x49484729, 0x050192dc, 0x20364501, 0x9c4e32cb, + 0xc8b297a1, 0xff003244, 0xff6e00ff, 0x04d703e5, 0x00160278, 0x0f830056, 0x0000af26, 0xdb058301, 0x4c200f82, 0x49180f84, 0xff250ec3, 0x0259fec2, + 0x351f8415, 0x0000004d, 0xff1d0002, 0x04f406fe, 0x000e005d, 0xb909013d, 0xf3573000, 0xb81e2a05, 0x0db5c0ff, 0x3d073710, 0x22098237, 0x820d1c40, + 0x374f31f5, 0x3702379f, 0x3e181637, 0x28280535, 0x09243f2c, 0x2409d749, 0x370b0913, 0x29781837, 0xb8162b0d, 0x0b40f6ff, 0x55021010, 0xfd4a0e16, + 0x40ee2406, 0x820c0c1d, 0x0b06220f, 0x2205820b, 0x8209090e, 0x0f142805, 0x1655060f, 0x820d0d06, 0xffb82505, 0x0c0cb4e2, 0xec200884, 0x2a056544, + 0x00351616, 0xffb80f1b, 0x832d40f4, 0x0f892a39, 0x3f8f0f01, 0x18013f0f, 0x210e830c, 0x42830818, 0x20c9182e, 0x02353035, 0x0f0f2235, 0x0c355502, + 0x35245b83, 0xb6eeffb8, 0x35221b83, 0xc0742835, 0xed5d2805, 0x105d2b2b, 0x4b2b5df4, 0xfd270c37, 0x2b322b2b, 0x182f005d, 0x27092246, 0x31ed2b5d, + 0x002b2b30, 0x4b079e5d, 0x3720053d, 0x63083c4b, 0x062108fb, 0x12425806, 0x2106d349, 0xcf493206, 0x4be7200a, 0x5b580757, 0x05ed491e, 0x37200122, + 0x2009744b, 0x05734b81, 0x4a167458, 0x00200500, 0x4105fd49, 0x272b06c3, 0x17b43101, 0x213d071e, 0x68c0ffb8, 0x4f2b0514, 0x02219f21, 0x1c162121, + 0x4b1a0520, 0x26250a88, 0x21370b09, 0x0e1b4b1e, 0x10100a28, 0x24165502, 0x05820f0f, 0xb3411620, 0x50f62006, 0x16230543, 0x820b0b0c, 0x4b1a2015, + 0x19710f16, 0xb8162205, 0x08b041ff, 0xb0411a20, 0x41212006, 0x292808b0, 0x292f290f, 0x1d03294f, 0x2706b746, 0x0209090c, 0x1a1a1955, 0x8207da47, + 0x058a4b08, 0x8a4b0882, 0x20088205, 0x05294df6, 0x2c841a20, 0x88510f82, 0x5b088205, 0x08820538, 0x0d40ee2a, 0x55060c0c, 0x0909041a, 0x88210582, + 0x0cbf7728, 0x5d322b27, 0x2b5df610, 0x0b254ded, 0x2b2bed24, 0xee413939, 0x06625805, 0x3939ed22, 0x21198e4a, 0x46181121, 0x3325072d, 0x16171632, + 0x0cd54116, 0x25082e4d, 0xbcbcf3fd, 0xab4b0d02, 0x12a84b06, 0xfd100229, 0xfe5d04f0, 0x41b3014d, 0x012107af, 0x33951800, 0x11215e76, 0x4e339518, + 0x19a98518, 0x09090825, 0x490d5506, 0x83460c7e, 0x2b2b2510, 0x2b2bed2b, 0x60339518, 0x5effff21, 0x2d08052b, 0x36028206, 0x00001202, 0x8d001601, + 0x1b00f6f9, 0xb81d01b1, 0x0f40c0ff, 0x55021009, 0x1d401d00, 0x1c1d0002, 0x2b251106, 0x00352b5d, 0x8f560200, 0x06250805, 0x00070015, 0x40bd0015, + 0x3406044c, 0x50064406, 0x70066006, 0x03090606, 0x03190507, 0x01460517, 0x00580349, 0x83221957, 0x0f083b13, 0x0e0e010e, 0x0b0b5012, 0x04020300, + 0x150c0205, 0x0b4008c9, 0x0f08370e, 0x76830ec9, 0x0b821120, 0x0e080e2d, 0x01680204, 0x03020101, 0x83000403, 0x22220815, 0x0c371009, 0x4a001c00, + 0x7a006a00, 0x8d000500, 0x01170f17, 0x04130403, 0x04650445, 0x04050475, 0x5b181682, 0x11220c1f, 0x52763939, 0x3f002705, 0x3939123f, 0x675f2f33, + 0x5d012406, 0x82fd1087, 0xc0280802, 0x5d005d01, 0x13230109, 0x01093301, 0x23010e13, 0x33272622, 0x3233011e, 0x7f043736, 0xd0c974fd, 0x01cc43fe, + 0x085a0157, 0x2b0c715f, 0x07fa5d04, 0x2704d201, 0x3c03c4fc, 0x080c735f, 0xf4feb92a, 0x5d046004, 0x02010b00, 0x060a0f40, 0x01032005, 0x003e0803, + 0xc9020805, 0xf8ffb803, 0x10100f40, 0x033f5502, 0x037f034f, 0x05200082, 0x260b6452, 0x0909b6f4, 0x5a095502, 0xec21325a, 0x065a5a40, 0x23067b5b, + 0x020c0c0c, 0x07495818, 0x184f5a5a, 0x200c7f46, 0x096e7d2b, 0x2f492b20, 0xed2b2706, 0xed333f00, 0xe5755d2f, 0x11232306, 0x7d5b1121, 0xfe410806, + 0x83feae84, 0xbc2f02bc, 0x0c01f4fe, 0x44fc5d04, 0x0000bc03, 0x00c80001, 0x078a0400, 0x0007006b, 0x0600b9b9, 0x1340c0ff, 0x0637100d, 0x03350006, + 0x13050203, 0x10100c06, 0xb8065502, 0x0fb4f2ff, 0x4508840f, 0x1184050e, 0x840b0b21, 0x40f02411, 0x8209090a, 0x09062409, 0x18021401, 0x452d6f47, + 0x02210551, 0x6d471814, 0x45e6200f, 0x02200548, 0x06225882, 0x6c180255, 0x69670ed1, 0x2f002a08, 0x2f33ed3f, 0x0130312b, 0x2fe78511, 0x03c68e01, + 0x2105ba08, 0xd105dffa, 0xb6fd9a01, 0xb926df83, 0xbb030000, 0xdf82ce05, 0xdf85bd20, 0x840e0d21, 0x033f25df, 0xc9050205, 0xf020c782, 0x21054659, + 0xe0840c06, 0x0c0c1222, 0xce6bd484, 0x201e8205, 0x050c4eee, 0x0106702a, 0x0f090606, 0x0c010109, 0x8d572183, 0x821a2006, 0xb4de25ef, 0x55021010, + 0xe4210882, 0x824183b4, 0x055b5308, 0xf6200882, 0x0c22df86, 0x21840909, 0x1805114b, 0x20125648, 0x0a315c87, 0x2b2bed23, 0x21e2825d, 0x00832b5d, + 0xe391ed20, 0x02bc7524, 0x2a69ae54, 0x71012305, 0xe383eafd, 0x3c02cb33, 0xdc023507, 0x11000300, 0x025401b6, 0x01050000, 0x0842822f, 0xed2f006a, + 0x21013031, 0x35072135, 0x6a0696f9, 0x00a03c02, 0x00c80004, 0x05b90800, 0x000900ed, 0x00210015, 0x40800125, 0x1807083e, 0x49013a07, 0x46064401, + 0x54015807, 0x6f075606, 0x7f066001, 0x0d067001, 0x13060d09, 0x13160d19, 0x1f75197a, 0x3f532506, 0x02224f22, 0x401f2222, 0x1f371412, 0x010d3051, + 0xb8190d0d, 0x2440c0ff, 0x193f0f82, 0x02021351, 0x04070803, 0x01030601, 0x230f2200, 0x23222302, 0xc91c0a22, 0x000a1010, 0x18020106, 0x240c298d, + 0x020c0cb4, 0x24118255, 0x0f1f40fe, 0x2009820f, 0x06315813, 0x0b0b0a26, 0x08005502, 0x00211383, 0x0ea76110, 0x180d0a21, 0x200d4259, 0x06074e0e, + 0x2d40e230, 0x55060c0c, 0x16040000, 0x270a0ac9, 0x37830802, 0x830c0221, 0x04022161, 0x02213383, 0x214f8304, 0x42181302, 0xd8532b6b, 0x1a042805, + 0x55060f0f, 0x47ffb804, 0x088205e2, 0x20054574, 0x0fdc1804, 0x2bed210c, 0x11220082, 0x096c2f33, 0x210e8208, 0x4018fd2b, 0x178308ff, 0x2f2f392f, + 0x3f2f005d, 0x3f391712, 0x2f332bed, 0x3b04855d, 0x0130315d, 0x0123215d, 0x21112311, 0x01331101, 0x22230614, 0x36343526, 0x07163233, 0x080add4f, + 0x15210145, 0xf5ff0421, 0x01b472fd, 0xb4500233, 0xb2bdba03, 0xb2bebab6, 0x58b2bab5, 0x57576765, 0xfe586567, 0xfeb80162, 0xfa340548, 0xfbd105cc, + 0xfec00440, 0xdadae063, 0xdcdae0df, 0x8888acdd, 0x8787adad, 0x609ee8fd, 0x5b5f0a83, 0x590a2047, 0x5b5f08af, 0x01003ca2, 0x35021901, 0xd5058f02, + 0x21000800, 0x50031140, 0x03070404, 0x07030e01, 0x82032a00, 0x2f013f1c, 0x39ed335d, 0x3f3f002f, 0x31ed2f33, 0x11230130, 0x36323523, 0x8f023337, + 0x7e66d1a5, 0x3b828909, 0x75a93a08, 0x0000562c, 0x02ef0001, 0x059f033d, 0x001d00ed, 0x1100b943, 0x2540e0ff, 0x0f37100d, 0x13520b0f, 0x511c0202, + 0x00000e01, 0x2a08011c, 0x16361626, 0x16761666, 0x160f1604, 0x3d60860f, 0x5d2f2f33, 0x333912ed, 0xfd3f002f, 0x33ed3f32, 0x2b30312f, 0x3e352101, + 0x013e3701, 0x6e533435, 0x3e3f0806, 0x16323301, 0x07061415, 0x2107010e, 0x50fd9f03, 0x6d27865b, 0x464c5840, 0x410f298f, 0xa99d4d97, 0x8d316a52, + 0x02f20137, 0x6845943d, 0x526d6725, 0x203c4a46, 0x9e221bb3, 0x5e945d7a, 0x82296a2b, 0x02e624a1, 0x8273031c, 0x002e34a1, 0x6c0f4074, 0x7e226c09, + 0x04227e09, 0x1f5a0c55, 0x82b82602, 0x0b3b30b0, 0x2003370e, 0x2c370d0b, 0x0f51152b, 0x180f0116, 0x280f49d8, 0x25061651, 0x0e0a0a02, 0x49d81851, + 0x00002e0e, 0x2f332f09, 0xed391712, 0xed2f2f2f, 0x18c28300, 0x230e45d8, 0x5d015d2b, 0x2f48d818, 0x3c734d08, 0x4f7b3530, 0x11418f52, 0x544f9a25, + 0x8c5b646e, 0x525f577d, 0x25994257, 0x4f964011, 0x4d61aa98, 0x3a037550, 0x25227047, 0xaf1c1e20, 0x48493b23, 0x4c8b3b53, 0x3e473c42, 0x221baf23, + 0x7157628c, 0x6d10081a, 0xb3000200, 0xbd033d02, 0x2408f782, 0x000d000a, 0x6d1e403a, 0x02067e06, 0x0d010906, 0x050c0551, 0x03020703, 0x0b07000e, + 0x00092a04, 0x0101060d, 0x26c88306, 0xfd333339, 0x482f3939, 0x2f26059d, 0x323939ed, 0xbf823031, 0x15232808, 0x35213523, 0x33113301, 0x03011121, + 0xfe96a3bd, 0x95d2012f, 0xfecbfea3, 0xdc19039f, 0x1b02b9dc, 0x9001b1fd, 0x410070fe, 0x7538066b, 0x2a00da05, 0x17404800, 0x087f086f, 0x1a1d1d02, + 0x06252551, 0x031e5121, 0x31054241, 0xeaffb800, 0x0c090f40, 0x29211f37, 0x091e1f1e, 0x47412a14, 0x12ed2105, 0xed227b82, 0x47412b2f, 0x250d8205, + 0x2f32fd2f, 0x3f413031, 0x051e4211, 0x2e275c08, 0x06222301, 0x15211107, 0x013e1521, 0x17163233, 0x7503011e, 0x88302f32, 0x3c954e57, 0x4e922510, + 0x1d1c522c, 0x1e1d1f17, 0x6c3b3559, 0xfe550226, 0x0e311448, 0x37347654, 0x4563033c, 0x332b2a7a, 0x149f1a1c, 0x1d1c1736, 0x392a2743, 0x0e111514, + 0x8bf00106, 0x170202cf, 0x826f2422, 0x02f324c9, 0x82a50335, 0x063508c9, 0x25404100, 0x03010156, 0x2a010001, 0x63030202, 0x02007300, 0x51030000, + 0x0e020305, 0x10020003, 0x02371009, 0x00000402, 0x2f332f04, 0x2b2f3912, 0x3f003912, 0x08ba843f, 0x875d0170, 0xc087ed10, 0x01095d01, 0x35210123, + 0xfea50321, 0xf001b92a, 0xb202edfd, 0xe7fc4e05, 0x008b1a03, 0x02c50003, 0x0591031b, 0x001900ee, 0x00370028, 0x0f42405d, 0x1f150f0b, 0x2a151f0b, + 0x39042a02, 0x49043902, 0x0a2b582b, 0x251f250f, 0x10361026, 0x26092f04, 0x1d030416, 0x35021051, 0x1a0f0351, 0x2a20132a, 0x092a290d, 0x0416130d, + 0xb6827006, 0x2a32002d, 0x33ed2f06, 0x17125d2f, 0x822fed39, 0x3f002401, 0x82ed3fed, 0x415d200c, 0x5445054a, 0x35372305, 0x8318012e, 0x152409de, + 0x3403011e, 0x2c064055, 0x17011e17, 0x3413013e, 0x012e2726, 0xd5e51827, 0x03730807, 0xa79bcb91, 0x52595ebf, 0x9590b946, 0x615250b5, 0x4f57be5b, + 0x2d305d46, 0x392e4817, 0x42371826, 0x3a2a5817, 0x51507638, 0x7935036d, 0x4f789fa1, 0x29042678, 0x8d6a4764, 0x7d3f6887, 0x6b270423, 0x48336401, + 0x3d26363f, 0x0b1f0a14, 0x79fe4f25, 0x0a1e3b32, 0x5d200f1c, 0x4e5f4a30, 0x73000200, 0x8b06e1ff, 0x2800f005, 0xd6003400, 0x011878b3, 0x48ffb815, + 0x0931068a, 0x02101010, 0x09181555, 0x0955020a, 0x40e8ffb8, 0x3009830a, 0x15790976, 0xffb81b02, 0x092f40c0, 0x691b3710, 0x08f9824f, 0x03022324, + 0x090a091a, 0x091a1505, 0x095a1515, 0x2c061555, 0x32021534, 0x220a0934, 0x1526291e, 0x0f03001b, 0xf8781529, 0xb4e6230b, 0xf8780909, 0x40f0240d, + 0x820d0d2d, 0x0f363112, 0x80361f36, 0xbf369036, 0x0636cf36, 0x2f01360f, 0x146cbe18, 0xf610352a, 0xed2b2b2b, 0xd6105d5d, 0x2b360782, 0x391712ed, + 0x00c4fdd4, 0xed3fed3f, 0x3939125d, 0xed5ddd3f, 0x19835d2b, 0x5d303127, 0x15161601, 0x05855314, 0x0db55818, 0x17161622, 0x21055f6e, 0x22833335, + 0x01069808, 0x22230010, 0x00101100, 0x05003233, 0x631a1fa1, 0xa1fb5c59, 0x5afffe9d, 0x5c60615a, 0x9a050158, 0x1859ffa0, 0x434f1419, 0x0da00c16, + 0xf9fe780b, 0xe3e1fcfe, 0x0801fdfe, 0x0701dede, 0xa6584904, 0xddfeb863, 0x68666561, 0x20016363, 0x2101b6b9, 0x69686267, 0x21211b61, 0x24444004, + 0x2f09175b, 0x826c3246, 0x22018dfe, 0xc5fe3b01, 0xdbfedefe, 0x3701c9fe, 0x6a000200, 0xc304e1ff, 0x1d008405, 0xc9002900, 0x201a0c40, 0x27370c09, + 0x020d0c18, 0xffb82155, 0x832c40e8, 0x3a2d0809, 0x4a273521, 0x04274521, 0x0d691b15, 0x21030005, 0x2704093f, 0x140a033f, 0x09182910, 0x06031b0c, + 0x0c0c402b, 0xb81e5502, 0x09b4f8ff, 0x21088409, 0x1184b6f4, 0x6b181b20, 0x3f260d6b, 0x55021010, 0x1a831800, 0x2b90002d, 0x2b1f2b0f, 0x2b6f2b3f, + 0x83042404, 0x0c242135, 0x24291783, 0x0b16061b, 0x0655020b, 0x21138318, 0x13830806, 0x0d040622, 0x06258f82, 0xf6102a85, 0x0ba4602b, 0x0c82ed20, + 0x39171223, 0x067c41dc, 0x3f39122a, 0x2b5dcdfd, 0x2b30312b, 0x260a4d41, 0x32331716, 0x7a343536, 0x1524058b, 0x16070614, 0x080c5848, 0xfe71042c, + 0xfeedebe8, 0xed1701e9, 0x5d2b6033, 0x0c164a5a, 0x730b0da0, 0xc248456c, 0xa99997aa, 0xab9698aa, 0xeffe2e02, 0x3c01c4fe, 0x01821101, 0x100f3d24, + 0x50414741, 0x6a4b0806, 0xd94d1480, 0xd3d3d98b, 0xd7d9d2d9, 0xb2000100, 0x7506e1ff, 0x2b00f806, 0x2940f300, 0x0f09202a, 0x6a2b2537, 0x030d031c, + 0x06391526, 0x15760649, 0x06341504, 0x2920240a, 0x2801280f, 0x0200141b, 0x55021010, 0xeaffb800, 0x840f0fb4, 0x56f82008, 0x002105a4, 0x21fb830c, + 0xfb831600, 0xf2221e82, 0xff832c40, 0x0f0a0029, 0x0055060f, 0x830d0d14, 0x0c0c2105, 0x0a220582, 0x05820909, 0x2d0f2d2f, 0x2d6f2d40, 0x2d902d7f, + 0x0c140f05, 0x5b8f18b8, 0x05a25932, 0xf6213a82, 0x835e83b4, 0x83b62008, 0x6b0c2261, 0x0573412c, 0x2205894b, 0x18de105d, 0x2e09f957, 0xfd5dd4ed, + 0xed3f00c4, 0xfd3f3f5d, 0x183031c4, 0x620dc46c, 0x36230b1f, 0x41113536, 0x23380d83, 0x51472905, 0x8c89ce4d, 0x475147d0, 0x2c2721c6, 0x966b6a97, + 0xd821272d, 0x28067e41, 0x5602a0ac, 0x4c50f1a2, 0xa3581946, 0x087f4114, 0x84833608, 0x00010000, 0x05e1ffb1, 0x008405a5, 0x40200125, 0x19060b23, + 0x03077a07, 0x10092023, 0x6a241e37, 0x05020515, 0x42110509, 0x1d010a05, 0x210f2919, 0x02142101, 0x062858b8, 0x40280883, 0x020c0c0a, 0x401a0255, + 0xb8264782, 0x2340eeff, 0x7b4b1010, 0x09082208, 0x180b8209, 0x410bba64, 0xb8240580, 0x0b40ecff, 0x3c0a8441, 0x40faffb8, 0x06090925, 0x0f270055, + 0x02276f27, 0x2790275f, 0x27c027a0, 0x0b0527ef, 0x2143830c, 0x64830c0b, 0x181a0b21, 0x182f438f, 0x211d6b67, 0x99412687, 0x2b2b230b, 0x8e44715d, + 0x832b2005, 0xed712f00, 0xd4322b2b, 0x00c4fd5d, 0x3fed3f2f, 0xa1413912, 0x215d2705, 0x06063523, 0x44182223, 0x1f430f1c, 0x2323330c, 0x5fbc5704, + 0xc4b069ae, 0x1b1a10bc, 0xad495256, 0x9641d04b, 0x418f1809, 0x0d8d4111, 0x44fd4608, 0x7dfe1105, 0x16008c06, 0x29404200, 0x030103bf, 0x0c050606, + 0x05601450, 0xad040501, 0x05d005c0, 0x09400502, 0x0505370d, 0x11400911, 0x29093714, 0x0001000f, 0x5ddd2f11, 0x39122bed, 0xed5d2b2f, 0xd45d2f00, + 0x2c0a82ed, 0x30315dc5, 0x07061401, 0x36352315, 0x08174a36, 0x36364308, 0xfe163233, 0x6e42427d, 0x2126302f, 0x0318251f, 0x51264913, 0x40f80566, + 0x7944154e, 0x1827270c, 0x69090927, 0x00560c06, 0x17fd0100, 0xebfd82fe, 0x030045ff, 0x09401300, 0x028f4401, 0x15000201, 0x62832f01, 0x5c82ed20, + 0x33352331, 0xd4d4ebfd, 0xffc382fe, 0x057cfcff, 0x8222fe16, 0x00172ab7, 0x0028fb43, 0xfdffff00, 0x20118209, 0x2c1184af, 0x00ecfa8d, 0x01020000, + 0x05110536, 0x2f118214, 0x000a0006, 0x0600b94d, 0x1040f0ff, 0x0537100e, 0x082c0483, 0x08070102, 0xb8050304, 0x1140c0ff, 0x05211483, 0x27fc8260, + 0x07700760, 0x00090702, 0xb5201582, 0x2d481482, 0xd62b2305, 0xe5825dcd, 0x2b2f3326, 0x2f391712, 0x2e088882, 0x23012b2b, 0x1323010b, 0x23032133, + 0x9fe10313, 0xe49bb8b9, 0xda1702e3, 0x11057c81, 0x00ff0001, 0xf6fe7b01, 0x00000a01, 0x05030002, 0x86e10311, 0x914a2081, 0x09082181, 0x18208186, + 0x00298188, 0x097f096f, 0x04070902, 0x23128240, 0x332f0400, 0x2f207d83, 0x01237e95, 0x87330323, 0x61fe247e, 0x8cdfda81, 0x29ff847e, 0x5207c004, + 0x1d000600, 0x7d858e00, 0xff871220, 0x010abf29, 0x0c0d0d0a, 0x821b5013, 0x0b4021eb, 0x1b251682, 0x0c01020c, 0x05114103, 0x8f882a20, 0xad0b2008, + 0x0cd00cc0, 0x09400c02, 0x0c0c3710, 0x11401018, 0x29103714, 0x0701070f, 0x100c4018, 0x83001837, 0x0e09303e, 0x00003710, 0x04010460, 0x2f335d2f, + 0x422bd42b, 0x38410c1e, 0x2bd42106, 0x41082642, 0x25200840, 0x4c053042, 0xd4870f48, 0x42c30121, 0x60411038, 0x42322006, 0x0228113f, 0x11052501, + 0xde07f303, 0x2022ef82, 0xef856400, 0xef872020, 0x52100735, 0x171f170f, 0x170317a0, 0x0a521d14, 0x37110d40, 0x4102010a, 0x20260fff, 0x13000729, + 0xd4831429, 0x7f41b420, 0x2fed2308, 0x8041edd6, 0x39392506, 0x3ced2bd6, 0x3c20dd82, 0x540b0642, 0xe94a0603, 0x4a232005, 0x332307e5, 0x87373632, + 0x06f639c8, 0x49355f86, 0x193a181c, 0x8c05222b, 0x365f8705, 0x3b161c49, 0x04242a19, 0x0807b241, 0x89520152, 0x16192990, 0x88473e2d, 0x14192a91, + 0x00473e2e, 0x42010200, 0xd503e704, 0x0d00fb06, 0x3c001100, 0x10112540, 0x371a0f40, 0x06100010, 0x033faa0a, 0x0e600301, 0x0e020e70, 0x102a0d10, + 0x001f000f, 0x0003008f, 0x2f062a07, 0x395dd4ed, 0x5dcd2fed, 0xed26b382, 0x2f3939cd, 0xac82cd2b, 0x2205a74f, 0x82161433, 0x35220896, 0x13230337, + 0x98b2d503, 0x55a2b297, 0x5e555352, 0x067c81da, 0xbcbca346, 0x64647ca3, 0xf6feb57c, 0x7b910a01, 0x400f1022, 0x0f227b82, 0x7b860f00, 0x7f106f29, + 0x0e100210, 0xad0e2a0d, 0x2307237b, 0x7b8a3303, 0xda815223, 0x207b89df, 0x21798955, 0xf5821e07, 0x63002435, 0x14114040, 0x0f1a1314, 0x13220122, + 0x371a0940, 0x86130013, 0x82122081, 0x3710340f, 0x1f001313, 0x1f201f10, 0x28171f03, 0x0e600e50, 0x95030e70, 0xed5d2794, 0x2f395dcd, 0x1641cd2b, + 0x5dd42608, 0x2f3912cd, 0x0f1c41c5, 0x93422720, 0x092f4116, 0x37371230, 0x2228275c, 0x141e1c19, 0x213c1002, 0xc0895742, 0x43345b3b, 0x0a653812, + 0x1d192021, 0x06570708, 0x0000450a, 0x04250102, 0x07f303e7, 0x08cf82de, 0x58002723, 0x170e1040, 0x1f1e0f52, 0x1b1e021e, 0x11205224, 0xffb81101, + 0x092540c0, 0x0011370c, 0x06700660, 0x25dd8602, 0x061b291a, 0xca822927, 0x250e5e41, 0x10edd4ed, 0xc483edd6, 0x395ddd25, 0x42712bd6, 0xe141088e, + 0x1a92420c, 0xc020c789, 0x89189542, 0x980121d0, 0x2e119742, 0x05090201, 0x06420311, 0x0016008c, 0x46354052, 0x502c0835, 0x70146014, 0x09140314, + 0xc7010590, 0x200d4146, 0x1d414610, 0x5e5d5e24, 0x45465dd4, 0x1014440e, 0x0c444220, 0x12454610, 0x01024108, 0x03540636, 0x000108e1, 0x00200006, + 0x074a407d, 0x02021702, 0x20501d14, 0x100a010a, 0x176f0750, 0x70170f01, 0x01170217, 0x0d400502, 0x09053711, 0x03900320, 0x03b003a0, 0x03105904, + 0x03c00320, 0xd0340282, 0xd0310203, 0x0203e003, 0x0f010350, 0x02037003, 0x07282003, 0x3209e944, 0x00142813, 0xd6332f04, 0xd62b2fed, 0x5d2f00ed, + 0x835e7271, 0xcd5e2402, 0x8239392b, 0xed3c2f0d, 0x3ced71dd, 0x015d3031, 0x23072723, 0x8b413337, 0xe140081a, 0xa5aeafa9, 0x0becbbf8, 0x49255070, + 0x143e1b1c, 0x8606281d, 0x27526f0a, 0x30222143, 0x052b1b1a, 0x59595406, 0x520001ad, 0x0d0d196b, 0x4e2d201a, 0x1010176f, 0x002a2316, 0x42010200, + 0xd5034806, 0x3408e782, 0x0011000d, 0x503e405a, 0x02106010, 0x03ff500a, 0x01035f01, 0x067f0003, 0x100f0601, 0x6f02109f, 0x0210ff10, 0x01116f10, + 0x1170110f, 0x0e591102, 0x0e720e69, 0x1b344403, 0x5ddd712a, 0x3c5dd471, 0xed7271dd, 0x1805d347, 0x200ab8aa, 0x3bd08237, 0x9eabd503, 0x4ba2ac9e, + 0x4f4d5a5d, 0x076881c6, 0x99985838, 0x59583057, 0xd8d8c92f, 0x6426978e, 0x0e503340, 0x978f0e60, 0x0e9f0e29, 0xff0e6f02, 0x880e020e, 0x10562b97, + 0x107d1066, 0x0d0e1003, 0x415a0e2a, 0x370d2105, 0x20105944, 0x06d6442b, 0x0723a19b, 0x8a332723, 0x815623a1, 0xa189dfc6, 0x41d80f21, 0x243b0d39, + 0x62408e00, 0x13141411, 0x01226f1a, 0x2270220f, 0x133f2202, 0x1302134f, 0x44151140, 0x503a0569, 0x01039009, 0x590103b0, 0x31010370, 0x033f030f, + 0x03cf0370, 0x13120304, 0x21820940, 0x1f501327, 0x1f701f60, 0x05824403, 0x401f3029, 0x171f051f, 0x44010ec0, 0xcd231681, 0x44715dcd, 0x5e250682, + 0x715d5e71, 0x059f455e, 0x5d2f7123, 0x2d8a4471, 0x30088041, 0x4d2e2e2e, 0x151c1f23, 0x020e1a19, 0x361b320e, 0x30eb894a, 0x0f382b61, 0x1e09542f, + 0x08161718, 0x08054905, 0x0c9b4139, 0x00272108, 0x1b114092, 0x11df5024, 0x170e1101, 0x011e6f50, 0x1e011e0f, 0x40c0ffb8, 0x37100d52, 0x0a06001e, + 0xb023f983, 0x82f00203, 0x032031fb, 0x03400330, 0x03d003c0, 0x600603e0, 0x02037003, 0x02230b83, 0x8203a031, 0x03503420, 0x0f0203e0, 0xcf033f03, + 0x1a030303, 0x061b1b28, 0x440e2827, 0x3c2312b7, 0x8210ed10, 0x052f4303, 0x72715d22, 0x3226ff85, 0x715d2b2f, 0x31433ced, 0x47ac1805, 0x5b37200d, + 0x5647055a, 0xaed52a13, 0xa2af9b9b, 0x6b3c3c6c, 0x183a43a2, 0x5406072a, 0x2e57676a, 0xfb2e2828, 0x2e103e43, 0x06360102, 0x08100568, 0x00060001, + 0x4888001d, 0x1a20052b, 0x200e1b49, 0x3d0f8240, 0x0f50130c, 0xb81b011b, 0x3a40c0ff, 0x1b37100d, 0x0f030201, 0x02057005, 0x030f0505, 0x1c490301, + 0x00502719, 0x00700060, 0x15491803, 0x5dd42109, 0x230e1449, 0x3939125d, 0xed26fc82, 0x2f392bc4, 0x4f485dc5, 0x07272506, 0x05331323, 0x4a168146, + 0x13200769, 0x260f0845, 0xcece6806, 0x49444901, 0xff261013, 0xfe1a00ff, 0x8e180582, 0x02310a3b, 0x0036054b, 0xb60a0000, 0x0e0d0002, 0x2b250005, + 0x32238235, 0x0482fe68, 0x0278041d, 0x00440036, 0x02170100, 0x8292044b, 0x400f2a23, 0x367f020a, 0x37360001, 0x2227820b, 0x1800355d, 0x2107fd61, + 0x29820108, 0x29842420, 0x2f005637, 0x1a007501, 0x50021240, 0x1002011c, 0x701c401c, 0x1c00031c, 0x8259830b, 0x845d2031, 0xe1ff255d, 0x8c061d04, + 0x4a205d88, 0x112b5d84, 0x5f020c40, 0x02457f45, 0x8e34451d, 0xed07215f, 0x4e205f88, 0x612b5f82, 0x0b401100, 0x0f400203, 0x860f0001, 0x208b8458, + 0x20578268, 0x285788f4, 0xe04e0216, 0x40130000, 0x2529820d, 0x02385038, 0x56863829, 0x578ab789, 0x57894f20, 0x578e0f20, 0x8ce3ff21, 0x021622af, + 0x41579f4f, 0x1628080f, 0x002f5c02, 0x11401700, 0x0f278382, 0x0fb00fa0, 0x91040fc0, 0x07a022b3, 0x060b4152, 0x50021622, 0x57205baa, 0x0c235b82, + 0x860203b7, 0x41352051, 0x0721085b, 0x204f88de, 0x234f9b51, 0x5e0582fe, 0x29070341, 0xd6003700, 0x61012f00, 0x11421701, 0x82182006, 0x140025b5, + 0x25000515, 0x420c6941, 0x6941091f, 0x36002407, 0x42e0d600, 0x1e2a0925, 0x7f031640, 0x3d00013d, 0x3a830b3e, 0x210c7a41, 0xa3835d2b, 0x00001a24, + 0x23415e05, 0x8758200a, 0x0b1121c7, 0x2b206d82, 0x0621c789, 0x20c788fb, 0x41c78252, 0x3a2305f5, 0x413a2901, 0x4d8a10c9, 0x4da25920, 0x4da85320, + 0x4d975a20, 0x881e0721, 0xa854209b, 0x985b204d, 0x09b1414d, 0x4d995520, 0x4182fe21, 0x00270937, 0x00d90037, 0x4175012f, 0x1d3008af, 0x50021340, + 0x03110111, 0x051c1b00, 0x00022500, 0x23064d41, 0x1100352b, 0x2205ab43, 0x4382fe68, 0x00240977, 0xddd90036, 0x2a09b541, 0x03114018, 0x0001447f, + 0x820b4544, 0x0661413b, 0xaf413520, 0x82c82005, 0x059d2737, 0x003602d1, 0x31840028, 0x003a052b, 0xb60a0000, 0x0f0e0001, 0x06314401, 0x23826a20, + 0x7c046022, 0x48202382, 0x1b202386, 0x02252384, 0x1223221f, 0x05554418, 0x0000c826, 0x01089d04, 0x563c4788, 0x75012600, 0x14401c00, 0x011d5001, + 0x201d0001, 0x601d501d, 0x1d00041d, 0x2503020c, 0x00227a82, 0x7f6a355d, 0x8c062107, 0x4a225988, 0x5982cb04, 0x02b41832, 0x3101316f, 0x40c0ffb8, + 0x37110a09, 0x12203132, 0xaf868982, 0x07216783, 0x216787c8, 0x6784d700, 0x0b401225, 0x82195001, 0x84192067, 0x8b35205e, 0x6a53205d, 0xd72108dd, + 0x22d983f9, 0x842d0002, 0x827f834f, 0x3a0521b5, 0x4e20b58a, 0x162b4d84, 0x01020d40, 0x02011050, 0x85100001, 0x8650834f, 0x0d0521af, 0x1622af88, + 0x51824e02, 0x03b70c25, 0x85241e02, 0x20238352, 0x0e094129, 0x539d4f20, 0xfffcff22, 0x0c53e118, 0x924f0221, 0x20a78353, 0x26a78836, 0x265c0216, + 0x83130000, 0x101024a5, 0x86021020, 0x355d23a5, 0x53410035, 0x07b92206, 0x21f58752, 0x4f825002, 0x03252b82, 0x20240002, 0x86a98724, 0x0db5412b, + 0x57021622, 0x0c215782, 0x86f78ab7, 0x0760224f, 0x204f88de, 0x219f9351, 0xfd4182fe, 0x37002309, 0xf383d600, 0x02170137, 0x003a054b, 0x401d0000, + 0x50100113, 0x00020110, 0x03021615, 0x08554125, 0x00352b24, 0xb385115d, 0x60203f82, 0x24075741, 0xd6003600, 0x058b42f9, 0x3d821b20, 0x0e401429, + 0x2a291e03, 0x41250012, 0x2b210866, 0x2b978235, 0x02000089, 0x020108d5, 0x002c0036, 0x562c2d83, 0x750124ff, 0x0e401600, 0x01115001, 0x00240383, + 0x09041011, 0x20096b42, 0x202582ab, 0x206384e4, 0x222f84d5, 0x8267034a, 0xb60a255d, 0x08090001, 0x53859582, 0x0282fe25, 0x88d105d5, 0x044b2253, + 0x080d432e, 0x77834b83, 0x82feaf26, 0xdb058301, 0x4c202382, 0x4b224784, 0x23849803, 0x0a000223, 0x5947840b, 0x8d08053b, 0xec059805, 0x21001800, + 0x66409900, 0x14011726, 0x16250117, 0x01161701, 0x10261016, 0x010d0802, 0x2a01061b, 0x03240105, 0x01021401, 0x53012054, 0x1776011c, 0x01136701, + 0x5b010d69, 0x0d49010d, 0x01067901, 0x7901066a, 0x026c0102, 0x15190b01, 0x151a2300, 0x351a0a13, 0x36011377, 0x56134613, 0x12130313, 0x0a120a15, + 0x340f1e12, 0x341e0215, 0x3f000a04, 0x11ed3fed, 0x2f2f3939, 0x5d391211, 0x2f01ed5d, 0xd610edc6, 0x303132ed, 0x00895d00, 0x0a8a0120, 0x0607102a, + 0x26272021, 0x21352627, 0x79080482, 0x23072023, 0x20213635, 0x21031617, 0x33161716, 0x05363732, 0xfeae9d98, 0xb0d0feb8, 0x04182773, 0x8074184e, + 0xb6e5fec4, 0x0501db11, 0xa4b15401, 0x0677fcce, 0xe5e47764, 0xe8026376, 0xe6ceadfe, 0x83d085cb, 0x897cbff8, 0xda5cdc8c, 0xf281feca, 0x96b4b497, + 0x6a000200, 0x6004e6ff, 0x18007c04, 0x6d001e00, 0x1d4b4540, 0x011d3801, 0x26011035, 0x0c490110, 0x380c2801, 0xe782020c, 0x1b0a193e, 0x00010010, + 0x141a1a20, 0x0901090f, 0x14673c1a, 0x46021477, 0x02145614, 0x9f161314, 0x132b1282, 0x0e1c1309, 0x1c04163f, 0x8909043d, 0x875d20ea, 0x835d20eb, + 0x855d20ec, 0x20e386ed, 0x20df8301, 0x29dd8222, 0x27342135, 0x07222326, 0xe0820706, 0x20334208, 0x12210300, 0x04363221, 0xfe938b60, 0x747be8ff, + 0x69743703, 0x79725eb0, 0xb3df0a41, 0x37011701, 0x0280fdbf, 0xba8f2801, 0xfafe3a02, 0x848baca2, 0x6ac766ec, 0x3a282560, 0xd4fe5ecd, 0xcafe67fe, + 0x08a882a8, 0x00000e3d, 0xd1058a04, 0x2d000d00, 0x0f001640, 0x14020405, 0x0507090b, 0x020b3c08, 0x35010702, 0x0807030c, 0xed3f3f00, 0xc02f3911, + 0x2f01c0fd, 0xcdfdc0ce, 0x31c610c0, 0x11210130, 0x6e211521, 0x113a0513, 0xfd8a0421, 0xfe710104, 0xbabac68f, 0x2105c203, 0xfd8f52fe, 0x8fe4021c, + 0x61825e02, 0x00001326, 0x5d04bb03, 0x1a20618a, 0x51206184, 0x3f226184, 0x61a4050c, 0xfdbb0338, 0xfe4101ba, 0xa6a6bcbf, 0xb8030203, 0xfe869dfe, + 0x86cf0131, 0x61820802, 0xaffe2024, 0xc382ab07, 0x0136c408, 0x43a84009, 0x0a25010a, 0x17020a35, 0x034c010a, 0x01033b01, 0x71010318, 0x34520134, + 0x45023462, 0x34360134, 0x01037f01, 0x5e01036d, 0x03340103, 0x35140304, 0x35351434, 0x14023534, 0x01266936, 0x54013276, 0x26320132, 0x052d0304, + 0x7e071422, 0x0c5d010c, 0x39020c6d, 0x020c490c, 0x52010a70, 0x020a620a, 0x0a090a0c, 0x140c0b14, 0x660c0b0b, 0x0e79011b, 0x010e5b01, 0x03091b0e, + 0x0b071f15, 0x04320715, 0x2226352d, 0x1f1b202c, 0x15090e16, 0x34201635, 0x090c2204, 0x0934221f, 0x07080804, 0x0b0a0320, 0x03353507, 0x00010807, + 0xedd03f2f, 0x3fc0d010, 0xc02f3912, 0x11c5fdc0, 0x39121139, 0x86edd010, 0x39112107, 0x01310982, 0x10c6dc2f, 0x391711c0, 0x875d5d5d, 0x7d872b10, + 0x051142c4, 0xfd101824, 0x1584dcc0, 0x33edd622, 0x5d23188b, 0x4330315d, 0x01220517, 0x68181123, 0x27210a94, 0x26018326, 0x33352323, 0x84161732, + 0x33112601, 0x36373611, 0x27028237, 0x15333336, 0x06072223, 0x01250182, 0xbcab0733, 0x92681839, 0x9e2a0809, 0x26141d42, 0x3c3c2a41, 0x5559ad47, + 0x5327113b, 0x54c7c4be, 0x3a170d14, 0x47aa5b57, 0x2937743c, 0x01a4412c, 0xaffe89d2, 0x68185101, 0xa6080994, 0x245ed768, 0xb10c1342, 0x34a74144, + 0x0212c566, 0x0d61fd9d, 0x432730cc, 0xb14543a4, 0xcc8a2633, 0x00a4fd67, 0xfe340001, 0x043e06f4, 0x0031005d, 0x627840c5, 0x022f722f, 0x46012f55, + 0x2f37012f, 0x7d0c6d01, 0x0c5a020c, 0x010a7301, 0x36010a62, 0x560a460a, 0x036d030a, 0x2f02037d, 0x1a030403, 0x30142f30, 0x02302f30, 0x232d311a, + 0x05280304, 0x0c071a1f, 0x1a0a090a, 0x0b140c0b, 0x18090b0c, 0x1c13030e, 0x042d2f07, 0x1f233f28, 0x1c181d27, 0x090e0c14, 0x1d143f13, 0x093f1f1c, + 0x07080804, 0x0b0a051d, 0x413f3007, 0xc0251283, 0x11edd010, 0x05874139, 0x83391121, 0x2f012c0a, 0x3917dcd0, 0x872b87d6, 0x4101c47d, 0x72410675, + 0x30312108, 0x410b8344, 0x2324106f, 0x32333523, 0x200c6c41, 0x0c6a4136, 0xaf3e0623, 0x3d4d1840, 0x67250809, 0x28231b34, 0x80453553, 0x1a142b94, + 0x8fba8e3a, 0x2a141a3b, 0x35457f94, 0x1a242952, 0x38016531, 0x01f4fe82, 0x404d180c, 0x36890809, 0x241f54a5, 0x397869a2, 0x0109863b, 0x091cfee4, + 0x78393b86, 0x2024a269, 0xfe389d53, 0x01000053, 0xaffecd00, 0xd1057705, 0xa3002100, 0x1f516940, 0x1f711f61, 0x010f4803, 0x7a010c29, 0x04690104, + 0x01037d01, 0x036b035b, 0x01033902, 0x03011f34, 0x141f201f, 0x04140304, 0x20560304, 0x7a212001, 0x10690110, 0x01105a01, 0x1b051004, 0x163f051b, + 0x14021601, 0x21202110, 0x21502130, 0x0a232104, 0x10071405, 0x1b350a15, 0x2531821f, 0x08153f16, 0xd6422003, 0xd03f2609, 0x2f3911ed, 0x05c24239, + 0x10c0fd27, 0xc6ed5dd6, 0x2711825d, 0x5d393912, 0x33115d5d, 0x4208cc42, 0x5d2107ad, 0x08af425d, 0x20059742, 0x0d984236, 0x0706a508, 0x77053301, + 0xa3fd44bc, 0xa2c6c687, 0x111d2862, 0x615d4431, 0x77534fb0, 0x2f352a3b, 0x0264382e, 0xaffe9c19, 0xa7025101, 0xd10559fd, 0x6b0364fd, 0x77233d2b, + 0xb14442a6, 0x77862736, 0xfd33493b, 0x0001009f, 0x04f4fec1, 0x005d04ac, 0x408d001c, 0x011a5358, 0x36011a42, 0x1a24011a, 0x010f1801, 0x1a721a62, + 0x04031a02, 0x1a1b1a03, 0x1a1b1b14, 0x1b011b54, 0x0118261c, 0x03040e18, 0x1a021305, 0x1c601c40, 0x011c3102, 0x1c201c10, 0x0a1e1c02, 0x1a071a05, + 0x3f130418, 0x08120a0e, 0x04043f0a, 0x1b050807, 0x26095342, 0x2f39123f, 0x42d010ed, 0xfd230744, 0x82d610c0, 0xc6ed24f8, 0x92391711, 0x20fb8afe, + 0x42f78332, 0x33080c26, 0x4aafac04, 0xbc6630fe, 0x044bacbc, 0x87a33832, 0x2f525356, 0x70432229, 0xfe968601, 0x020c01f4, 0x0400fe00, 0x8d1efe5d, + 0x677a6d07, 0x502126a2, 0x51fe369d, 0x6718eb82, 0x4a0807a9, 0x40c10023, 0x01234678, 0x25012337, 0x23020123, 0x01215601, 0x69011288, 0x018a0112, + 0x01017d01, 0x2a01016e, 0x02013a01, 0x76010119, 0x1f39011f, 0x011f2401, 0x1f011f0b, 0x01145b02, 0x14391409, 0x101a1402, 0x23002301, 0x82010214, + 0x02300802, 0x01040f0e, 0x1a060404, 0x060b2500, 0x1f230814, 0x14351a05, 0x0b030d10, 0x0e0e0919, 0x05350b09, 0x04040502, 0x08050501, 0x01000309, + 0x3f000808, 0x2d05df44, 0x122f3912, 0x11ed1039, 0xd0102f39, 0x59431711, 0xc0fd2406, 0x82c6d610, 0xc05d2212, 0x055f43dd, 0x3911c025, 0x82125d5d, + 0x09c54403, 0x6705cb44, 0x232705b8, 0x33112311, 0x84373611, 0x101f4204, 0xfe75052d, 0x6e8610fe, 0x2c42c6c6, 0x42233286, 0x2d24101e, 0x7b01fffe, + 0x27051b42, 0x6a010c01, 0x4831e6fe, 0x210c1f42, 0x196e0100, 0x04630805, 0x011e005d, 0x84b1400f, 0x1e56011e, 0x011d1401, 0x7e011288, 0x015c0101, + 0x01013b01, 0x1901012a, 0x021c0101, 0x5b011299, 0x124a0112, 0x12180301, 0x12021238, 0xbe021017, 0x1ead011e, 0x011e9c01, 0x1e8b1e7b, 0x011e0e02, + 0x011edf02, 0x25011e68, 0x1603011e, 0x1e05011e, 0x0101b201, 0x0101a002, 0x82010194, 0x1a01291c, 0x00141e00, 0x0d021e00, 0x21054f41, 0x80829017, + 0x0b202e08, 0x08801a06, 0x08020890, 0x1e011e59, 0x3f17051c, 0x44011052, 0x10640110, 0x0d021074, 0x09160b10, 0x0b090e0e, 0x025b053f, 0x027b026b, + 0x086a4103, 0x6a410520, 0x415d2010, 0x3931076b, 0x71715d39, 0x393911ed, 0x5d2f0171, 0xd610c0fd, 0x0571415d, 0x3446cd20, 0x71712706, 0x5d5d715f, + 0x03825d5f, 0x00837120, 0x11c01023, 0x210e8439, 0x9a433912, 0x215d2609, 0x23150123, 0x057f4111, 0x11373225, 0x18361533, 0x2107e068, 0x01820607, + 0xf6a9042d, 0x6b86bbfe, 0x2f3cbcbc, 0x42330986, 0x67230ba2, 0x427401db, 0x0f25059e, 0x11e75a01, 0x07a1426e, 0x2208ec82, 0x05affec8, 0x00d105c7, + 0x4035000f, 0x0f14021b, 0x14040b0e, 0x050a110e, 0x350b0714, 0x0c070505, 0x440e0308, 0xc0260a4f, 0xed2f3912, 0xc1822f01, 0x0382d420, 0x31eddd24, + 0x8e830130, 0x94822120, 0x11332308, 0x11331121, 0xbcc70533, 0xc619fd96, 0xc6e702c6, 0x01affe8c, 0xfdd90251, 0xfdd10527, 0xfa4802b8, 0x6f8200dd, + 0xf4feb926, 0x5d04e604, 0x1a206f86, 0x1a206f83, 0x1a236f83, 0x843f0b07, 0x0e05216f, 0x890abe43, 0x96dc206f, 0xe604306f, 0xd1fd93af, 0x2f02bcbc, + 0xf4fe86bc, 0x18010c01, 0x21086a49, 0x981845fc, 0x3d2b1399, 0x7f0464fe, 0x16025d04, 0x8300c401, 0x0006248f, 0x82e60400, 0x102b08ff, 0x48407b00, + 0x60010f70, 0x0f50010f, 0x010f4001, 0x20010f30, 0x0f10010f, 0x0f100f01, 0x0014100e, 0x00001401, 0x0e0e0f01, 0x820c0d14, 0x090d3a02, 0x0004080c, + 0x08140501, 0x023c0508, 0x030c010f, 0x070b0b0d, 0x0e00100d, 0x05a9490d, 0xd0c02008, 0x391211c0, 0x3917122f, 0x01c0fdc0, 0xcdd0fd2f, 0xccd010cc, + 0x7d2b87dd, 0x1887c410, 0x82082b10, 0x09484b07, 0x15010122, 0x0805c549, 0x2135212d, 0x01330135, 0xfde60401, 0xfe7001f4, 0x96fec690, 0xf2fd6a01, + 0x019701db, 0xfcd1059b, 0xfe8a59bc, 0x8aaa0156, 0xfd590344, 0x189a0266, 0x080a0593, 0x90000e38, 0x0e7b5740, 0x010c7401, 0x64010e6b, 0x0e5b010c, + 0x010c5401, 0x44010e4b, 0x0d70010c, 0x010d6001, 0x40010d50, 0x0d20010d, 0x0d0c0d01, 0x0b1a0c0e, 0x0b0b140a, 0xd1820d0a, 0x013cdb85, 0x1a040200, + 0x07090a0b, 0x013d0407, 0x0a0a0b0d, 0x000e0b06, 0x06050b0c, 0x3f3f000c, 0xcd85ce87, 0xccc0cd28, 0xc0cccdfd, 0xcd931087, 0x21088c47, 0xd3880101, + 0x7f2cd284, 0x650137fe, 0xfebc9bfe, 0xfe5901a7, 0x3005e470, 0xdbfb5d04, 0x01b6fe8a, 0x25048a4a, 0x3c03c4fc, 0x36d18200, 0x05affe44, 0x00d10548, + 0x40be000f, 0x010b4883, 0x07480738, 0x4a054702, 0x3a080645, 0x0d0f1402, 0x0e09050c, 0x09060b0a, 0x060b070e, 0x0c040308, 0x72030805, 0x09630109, + 0x01095401, 0x16010925, 0x037e0109, 0x6d035d01, 0x032b0203, 0x01031a01, 0x03080309, 0x82090e14, 0x0e200802, 0x05630553, 0x16030573, 0x02052605, + 0x5b010b7d, 0x020b6b0b, 0x0b290b19, 0x060b0502, 0x050c140b, 0x0c310282, 0x0b080611, 0x0308090c, 0x0503350e, 0x00010806, 0x20fd822f, 0x240382ed, + 0xc62f01c0, 0x06834810, 0x00835d20, 0x0c8b1820, 0x0f201083, 0x18220082, 0xb243eddd, 0x23012206, 0x58851811, 0x3301250a, 0x3abc4805, 0x0dcb7819, + 0xfdd92d08, 0x888a01fe, 0x5101affe, 0x9bfd6502, 0xe902e802, 0x5d02a3fd, 0xbdfd20fd, 0x3c000100, 0x8604f4fe, 0x0f005d04, 0x47407200, 0x0e0f1a02, + 0x0324f793, 0x1a090e09, 0x0820dd82, 0xc283ae82, 0xc2841a20, 0x200c1028, 0x600c400c, 0xcb87040c, 0x3f0e0522, 0x5d20cb93, 0x2105f045, 0x8644c618, + 0x23bd8205, 0x1018010f, 0x2107d643, 0xbe820101, 0x01013322, 0x2b080283, 0x44af8604, 0xc1fec3fe, 0xfeb401db, 0x3b01ed50, 0xfedc3c01, 0x833a0149, + 0x0c01f4fe, 0x53fead01, 0x30022d02, 0xa6015afe, 0x6bfedafd, 0x0a4b6718, 0x001b2a08, 0x762e4057, 0x0b690112, 0x14170401, 0x19100606, 0x1d001402, + 0x0d001410, 0x15150d01, 0x190e1a14, 0x09341417, 0x09020407, 0x24018206, 0x01030e01, 0x06986a08, 0x112f3408, 0x10333333, 0x103232ed, 0x2f3911c0, + 0xed5d2f01, 0xc0fdde10, 0xc02f3912, 0x3031c0dd, 0x23215d5d, 0x11070611, 0x23221123, 0x35262722, 0x14113311, 0x82171617, 0x36320806, 0x04331137, + 0x7ea1c6ea, 0xd5130a86, 0x37c68679, 0x9a86b044, 0x7602c685, 0xd7fe1332, 0x71661c01, 0xfefc01da, 0x5c4bb567, 0xfe7e0102, 0x02310f88, 0xaf8600b1, + 0x5d041f35, 0x55001b00, 0x10772e40, 0x12150401, 0x190e0606, 0x820f1a02, 0x0e1d311c, 0x100b001a, 0x140b020b, 0x0c1a1214, 0x3f121519, 0x0122b086, + 0xaf89050c, 0xad8dae82, 0xae8a5d20, 0x1526ad84, 0x23223523, 0xab8b1120, 0x2c08ad84, 0x5270bc1f, 0xfe110a86, 0x2f2abc8e, 0x24118678, 0x01bc3855, + 0xc80e23ad, 0x015801bb, 0x8fcafe96, 0x0107423b, 0x02d6fe2f, 0x02110e06, 0x08ad831d, 0x0000c839, 0xd1052405, 0x35001300, 0x12671d40, 0x01117701, + 0x02010458, 0x0d150014, 0x080a1408, 0x0f0d3406, 0x030b0a0f, 0x00080a01, 0x123fc03f, 0xed332f39, 0xfd2f0132, 0x42de10c0, 0x8d82059a, 0x2105bf4e, + 0x8c822311, 0x33243508, 0x15161732, 0x37c62405, 0xbfdabb45, 0x0801c6c6, 0x8679d5ba, 0x4bb59901, 0x4ffd465e, 0x8afdd105, 0xda716652, 0x00ffff00, + 0x040000b9, 0x0214065f, 0x004b0016, 0x732a0f83, 0x9805e1ff, 0x1602ec05, 0x0f848902, 0x8206994f, 0x008a230f, 0xe8180000, 0x3b08094d, 0x0016000d, + 0x4053001f, 0x011e1934, 0x55011a16, 0x14160114, 0x01135601, 0x5a011159, 0x10190110, 0x010d7501, 0x0e01077a, 0x21001517, 0x06151816, 0x1818340e, + 0x0a34121c, 0x03341c02, 0x21078550, 0xc182ed2f, 0xde10c524, 0x1047c5fd, 0x015d290a, 0x20210010, 0x37101100, 0x20056650, 0x06954f26, 0x6f500520, + 0xda410808, 0xc2fe8afe, 0x8cfec1fe, 0x4201b5bc, 0xbcb93f01, 0x826b13d2, 0x6b81e3e1, 0xfcc40313, 0x7f73103b, 0x727fe1e1, 0x92fee802, 0x990167fe, + 0x6c016e01, 0xcecacad2, 0x82dbf3fe, 0xdb829d9d, 0x9a8ae8b3, 0x08ca829a, 0x6a000326, 0x7104e1ff, 0x0f007c04, 0x1b001400, 0x2a404500, 0x46011b49, + 0x13460118, 0x01114901, 0x001b1510, 0x1b16141d, 0x2d053348, 0x16903f10, 0x1a161601, 0x040c3f12, 0x5a503f1a, 0x5d2f2108, 0x5d21c082, 0x27c18afd, + 0x06071001, 0x26272223, 0x3328bd83, 0x07161732, 0x03202102, 0x2b08b985, 0x7f710420, 0x8afbfa8a, 0xfb8a7f7f, 0xc57e8afb, 0xfedefe1c, 0x7e021bdc, + 0x490c81fd, 0x24019853, 0xfffe2e02, 0x9eadad9f, 0x02010201, 0x9f290782, 0xfe6101b7, 0x5d9e909f, 0x0561476b, 0x10056422, 0x3808ab82, 0x40470019, + 0x01067928, 0x01010668, 0x15181a03, 0x1b181400, 0x901a0a0f, 0x0a0c010c, 0x110f4208, 0x15050d04, 0x080c173e, 0x013e0318, 0xfd3f000c, 0xedd03fc0, + 0xed333f3f, 0x05a24832, 0xddc0de2f, 0xcdfd10c0, 0x5d5d3031, 0x33352101, 0x09314211, 0x36153b08, 0x11112033, 0x11231533, 0xfd100533, 0x332ab1e2, + 0xbcb0928f, 0x01bcbbbc, 0xb1b1b173, 0x039864fe, 0x5345b580, 0x04befc87, 0xfe9b7c5d, 0x98c3fd59, 0x0100fcfe, 0x64fe0000, 0x97825f04, 0x00152808, + 0x7922403c, 0x04680104, 0x001a0101, 0x090b1117, 0x0e900c1a, 0x06080e01, 0x04131142, 0x0e09050f, 0x010c0c3e, 0x833f0008, 0x228f8692, 0x42cdfdcd, + 0xbc4207bd, 0x15332109, 0x33209783, 0x04228e84, 0x8684bc5f, 0xd2fdb923, 0x218984b9, 0x83837c02, 0x98bafb25, 0x83610598, 0x82002085, 0x02992c81, + 0x027d043c, 0x000300dc, 0x740c4018, 0x0f270536, 0x02051f05, 0x745d2f02, 0x04330b3c, 0x031cfc7d, 0xa03c02e4, 0xff020000, 0x03e403ed, 0x8213061a, + 0x074a0833, 0x35404f00, 0x05270517, 0x17030537, 0x37012701, 0x05720301, 0x50054001, 0x03056005, 0x04b10605, 0x72b10003, 0x01400101, 0x01600150, + 0x07020103, 0x0401044f, 0x04030205, 0xc03f0000, 0x2f01c0de, 0xcdd6cd5d, 0xcdfd5d5d, 0x0682fd10, 0x5d303128, 0x2303015d, 0x03822101, 0xa51a0327, + 0xfe0f01f4, 0x60ae18f6, 0xd1fd2409, 0x82002f02, 0x03002673, 0x05720466, 0x087d84d1, 0x7d000b32, 0x0b095340, 0x6e010a7f, 0x0a3f010a, 0x0a5f0a4f, + 0x08700a03, 0x01086101, 0x08500840, 0x05060802, 0x01040607, 0x01007003, 0x30010061, 0x50004000, 0x21083782, 0x6e01027f, 0x024f0102, 0x0202025f, + 0x61010470, 0x04300104, 0x04500440, 0x09060403, 0x03080502, 0x9d820307, 0xc0ddc022, 0xdd249f82, 0xd65d5d5d, 0x9d820382, 0x39395d27, 0x39391211, + 0x260e8910, 0x01013031, 0x86231323, 0x72042603, 0xc288d6fe, 0x2004836f, 0x25048371, 0x95fdd105, 0x03876b02, 0x00007e08, 0x00660001, 0x059f0400, + 0x002200f0, 0xc56e40ab, 0x16370116, 0x16b71647, 0x0112b903, 0x12481238, 0x010fc802, 0x0cb60ca6, 0x010c9702, 0x54010875, 0x02086408, 0x5c01046b, + 0x03790104, 0x1d0c0c01, 0x1d20221b, 0x0202181a, 0x24221f14, 0x1d061a14, 0x20023f18, 0x76010c87, 0x0c65010c, 0x560c4601, 0x0c34020c, 0x0d0a0c01, + 0x3f19100d, 0x0120901c, 0x1c201c20, 0x0a3f1021, 0x013f2102, 0x0acc5308, 0x11ed1024, 0xca4c2f39, 0x105d2305, 0xe482fdc0, 0xde10ed26, 0x2f3912c6, + 0x10210b82, 0x541b82c0, 0x5d3b0dcb, 0x26112121, 0x34352627, 0x32333637, 0x26231517, 0x06072223, 0x16171415, 0x19211117, 0x08082395, 0x87fd9fa8, + 0x726c75df, 0x9c9ddb7a, 0x9f9f900b, 0x52474754, 0xfe79029b, 0xfed1010d, 0x01f3012f, 0x859002f0, 0x958be6e3, 0x8085a256, 0x67a2a66d, 0x8d010376, + 0x78ebfe78, 0x030088fe, 0x52ff7300, 0x96068205, 0x2e002800, 0x57013700, 0x3266dd40, 0x01321701, 0x72013105, 0x2d66012d, 0x012c0701, 0x5b012079, + 0x10770120, 0x010f1701, 0x1701067c, 0x02016701, 0x01010703, 0x222f371c, 0x19231b23, 0x24252b2c, 0x011a761a, 0x1a671a57, 0x301a2002, 0x031a401a, + 0x79011a04, 0x23580123, 0x2f022368, 0x4f233f23, 0x230b0323, 0x2d821a01, 0x24ab3c08, 0x1a24141a, 0x2e170024, 0x16282729, 0x09081428, 0x0001070a, + 0x01157615, 0x15671557, 0x30152002, 0x03154015, 0x79011504, 0x28580128, 0x2f022868, 0x4f283f28, 0x0f020328, 0x82150128, 0xab400830, 0x00141500, + 0x0e030015, 0x1b0f1639, 0x15351b01, 0x1e011e00, 0x0307292b, 0x0127252f, 0x04220403, 0x0022342f, 0x22232428, 0x151b1a02, 0x120e1216, 0x2c2e370d, + 0x1c340a08, 0x12141719, 0x333f000a, 0xfd210082, 0x29008232, 0x103911c4, 0xc0d0c0dc, 0x0482dd3f, 0xc4fd1025, 0x82391711, 0x2f012902, 0x5dd4ed5d, + 0xd0d610cc, 0x21074949, 0x00855d5f, 0xc4c48729, 0x05c40ec4, 0x8310c4c4, 0x01c42409, 0x48dc1018, 0x1e8505ab, 0x845d5d21, 0x231c8516, 0x5d013031, + 0x1e843787, 0x16030138, 0x26231517, 0x33320127, 0x15333720, 0x23060706, 0x23072722, 0x04822637, 0x1126132d, 0x25363710, 0x16073337, 0x82033717, + 0x17162223, 0x08208213, 0x150607ac, 0x82051714, 0x0f210e6b, 0x5ffe3333, 0x1c01080a, 0x92460eda, 0x2e2f9092, 0x5245ad3a, 0x86ad5e44, 0x01bccabf, + 0x46b0413c, 0x94544e50, 0x5dfe524b, 0x46655837, 0x274cc137, 0xfe960649, 0xeb1007ea, 0xc6fb212b, 0x3821e8c4, 0xb497042e, 0x01f32817, 0x6e01ca5d, + 0xc0ce7001, 0x0cb5aa07, 0x80feda19, 0xc1fb0b1c, 0x9104222f, 0xe14e1609, 0x90c39574, 0x00010000, 0x05e5ff73, 0x00ec0546, 0x4099002b, 0x0118075e, + 0x55011406, 0x15590117, 0x01145a01, 0x78010a65, 0x06190106, 0x1a271d01, 0x21161a1a, 0x162d000e, 0x00180814, 0x38820901, 0x70042e08, 0x2b2b012b, + 0x25222728, 0x0e361f3f, 0x17020e46, 0x020e270e, 0x0e010e06, 0x7f0f6f0c, 0x0f0f020f, 0x1f1d2112, 0x12281c1c, 0x1a020c34, 0x05cd5728, 0x3f563220, + 0x32322c05, 0x5d2f3911, 0x5d5d3912, 0x89ed105d, 0x2f012b0c, 0xc0d610ed, 0x2f3912c0, 0x1643c0fd, 0x5d012808, 0x0706255d, 0x46202306, 0x213105a7, + 0x23150532, 0x07222126, 0x17101106, 0x33111716, 0x09284315, 0x24115008, 0x46053337, 0x90929246, 0xccbeb1fe, 0x4d01c3ca, 0x0f0601f3, 0xe3f4feeb, + 0x4a98928a, 0xa7cdbc6a, 0x500a4b3e, 0x01aa9a5f, 0x6c0ed718, 0xbc2e3821, 0x017c01ca, 0x83c7ce70, 0x9f96c5eb, 0xdbfed9fe, 0x02244fa1, 0x0ca5a5ab, + 0xfe8a13c1, 0x82c2027b, 0xb94108e6, 0x170738ff, 0x29004405, 0x6a40ad00, 0x3d010e7c, 0x020e5d0e, 0x10232203, 0x24250a23, 0x770f670f, 0x0f43020f, + 0x0f100101, 0x02020f20, 0x6d010f00, 0x4c030123, 0x1f010123, 0x02232f23, 0x01230f02, 0x082a820f, 0x0f24ab4c, 0x0f242414, 0x10201010, 0x10031030, + 0x1b1d0d10, 0x240d1a1a, 0x1a000c24, 0x111a0c01, 0x273f060d, 0x17232420, 0x1d04203f, 0x1a100f05, 0x00080d01, 0xdcc0c03f, 0xed3f3fc0, 0xd010c0de, + 0xc42f01ed, 0x12eddefd, 0xdc102f39, 0x0682c0ed, 0x21083553, 0x01835d5f, 0x87240485, 0x10c4c40e, 0x31250482, 0x5d5f0030, 0x08a4465d, 0x0707062a, + 0x03112311, 0x27260123, 0x82059c48, 0x0534410d, 0x33134108, 0x20333607, 0xbc170711, 0x50902e22, 0x502d1a4e, 0x01a9f4bc, 0x0d03029c, 0x85522a51, + 0xbbbcbcb0, 0xae55dfaf, 0x5d536dac, 0x7c026701, 0x275740b6, 0xfda91c0d, 0xfd400130, 0x3e7203f8, 0x15298221, 0x08066147, 0x7401ac3f, 0x59fe20e8, + 0x34000500, 0xd0050000, 0x1b00d105, 0x22001f00, 0x29002500, 0x6540ba00, 0x4b012345, 0x121c0121, 0x23251f1e, 0x26042311, 0x03212027, 0x66115621, + 0x03110211, 0x23140321, 0x08028411, 0x18021432, 0x02151a00, 0x07090d2b, 0x14052821, 0x65070b10, 0x23540123, 0x15212301, 0x08251114, 0x3c050104, + 0x1a1f2629, 0x1216200b, 0x273c220f, 0x0b0c191e, 0x07390182, 0x02031110, 0x08070603, 0xd0c03f00, 0x11c03fc0, 0x2f2f3939, 0xc0c0c010, 0x200382fd, + 0x860883c0, 0xc0d02709, 0x5d5d2f2f, 0x19842f01, 0xc0de1022, 0xc0200282, 0xfd210582, 0x06d443c0, 0x8505c843, 0x42012005, 0x0120057d, 0x0120ad82, + 0x2807d858, 0x11333523, 0x11211321, 0x05764833, 0x0c822120, 0x11030133, 0x25233501, 0x05112303, 0xfef598d0, 0xb943fefb, 0x3b008294, 0x01dd3301, + 0x9898b9a7, 0xfeaffe98, 0x55fe89ae, 0x74fe028a, 0xdf89defe, 0x14feec01, 0xa0270385, 0x01a00401, 0x835ffea1, 0xfea02403, 0x820401fc, 0x83a42003, + 0xe1fc2205, 0x081b82db, 0xfffcfe25, 0xffc800ff, 0x050109e5, 0x003600d1, 0x01000035, 0x05560017, 0x0000002a, 0x0002b60b, 0x00002626, 0x822b0125, + 0x00072616, 0x0700005c, 0x0825828d, 0x23001f2d, 0x29002600, 0x31002d00, 0x48013400, 0x1b68af40, 0x01095701, 0x19171410, 0x3433302f, 0x120f3418, + 0x0e171613, 0x1834180e, 0x820e1714, 0x34173402, 0x1a2e3132, 0x0c1b341b, 0x25262c2d, 0x0d250d1b, 0x821b3414, 0x34483902, 0x27253401, 0x1f1e2023, + 0x22281f29, 0x291c1d21, 0x2a2b241c, 0x0a250a0b, 0x142d0982, 0x25140a25, 0x04010a25, 0x00090805, 0x08218209, 0x09001439, 0x09000014, 0x46000307, + 0x25290129, 0x17181625, 0x0e34291b, 0x27283233, 0x0f080b0c, 0x2d30313c, 0x0522232a, 0x1e242612, 0x01191a1d, 0x2e2f3c16, 0x20212b2c, 0x82121304, + 0x1b0e2a01, 0x1b1c001f, 0x0d0a0903, 0x07bd410e, 0x11c0d023, 0x07c04112, 0xc441c020, 0x20078207, 0x8b038210, 0x2f24820f, 0x12c0d010, 0x2f190139, + 0x195ddd18, 0xc0d618dd, 0x21053f4e, 0x0082c487, 0x10188726, 0xc47d872b, 0x450a9f45, 0xdd2008c2, 0x20056f4e, 0x20258210, 0x241486c4, 0x87dd1019, + 0x202f8e18, 0x495d8201, 0x3329051e, 0x33032315, 0x23032115, 0x23038403, 0x23033335, 0x33230382, 0x83132113, 0x82032003, 0x27012606, 0x17230107, + 0x83218201, 0x074a080d, 0x8d071723, 0x439a7072, 0x7af9fedd, 0x80fe77df, 0xfe7cda74, 0x9e45e3f2, 0x6fcb7474, 0xc96d9101, 0x6d94016d, 0x41bcfe95, + 0x2f2cfec2, 0x7209022e, 0x41f7fe39, 0xfe5d40ae, 0x28be42bf, 0xd105376d, 0xfea049fe, 0x2afea0fc, 0x0383d601, 0x0401a027, 0xfeb701a0, 0x2e038549, + 0xfcfea9fd, 0xbabaa401, 0x01e7bcfd, 0x42040187, 0x3b080539, 0x0200dba0, 0x00009700, 0xf2041b06, 0x1f000f00, 0x22403d00, 0x14681458, 0x0f031478, + 0x1a1f0d1a, 0x1a1a0811, 0x081a0618, 0x07100710, 0x0e3f1708, 0x183f081b, 0x3f000805, 0xc02fedc0, 0x26055b5d, 0xdefd2f01, 0x82de10ed, 0x35f38204, + 0x06071401, 0x33112123, 0x37322111, 0x33113536, 0x34112301, 0x11822627, 0x11822320, 0x16176108, 0x721b0615, 0xdafde46b, 0x9f7501ad, 0xfead3a3f, + 0x403aad63, 0xad8bfe9e, 0x6ae52602, 0xf2bf0172, 0xfe02636a, 0x3e43c6fd, 0xfd2d0380, 0x81390102, 0xd2fb433d, 0x6a63f204, 0x010000f2, 0x00003400, + 0xd1057505, 0x83001100, 0x11074440, 0x010e1401, 0x47010e83, 0x0d0e010e, 0x0b0e0b0c, 0x0e0d140c, 0x0c2d0282, 0x11100d0c, 0x11020100, 0x00140102, + 0x38028211, 0x13000101, 0x02110b0e, 0x04060814, 0x080b090d, 0x0505023c, 0x00030904, 0x20c58304, 0x074a493f, 0xce2f0130, 0xc032fdc0, 0x32d61032, + 0x0587c100, 0x0583102b, 0xc4107d26, 0xd418c001, 0x3129118d, 0x5d5d0130, 0x21215d71, 0x06b45c01, 0x11332508, 0x21013301, 0x75052115, 0x1ffdfffe, + 0xc69999c6, 0xfdf0d302, 0xfdff0220, 0xfd980204, 0xa0980268, 0x67fd9902, 0xa0200383, 0x0024c582, 0xee040000, 0x3d08c582, 0x40700017, 0x0e11123f, + 0x0d700d30, 0x0d900d80, 0x030b0d04, 0x083f0704, 0x088f087f, 0x0804089f, 0x0a000206, 0x0f131514, 0x0d090c0b, 0x0e060f08, 0x11051007, 0x12021304, + 0x35140103, 0x38820316, 0x820b0d21, 0xddde2bc0, 0xfd3fcdde, 0x3911dcc0, 0x0382dd39, 0x0382de20, 0x0382cd20, 0xc02f012e, 0xcefdccc0, 0x5ddec0c0, + 0x10c0d0c0, 0xb7820584, 0x37112125, 0x82150715, 0x23b98203, 0x35373507, 0x11280382, 0x04213521, 0xf8ecfdee, 0xc6210082, 0x210082fb, 0x9e82ecfd, + 0xaefe2126, 0x9fc2a1c2, 0xfe270382, 0xc5530112, 0x829fc5a1, 0x01b20803, 0x0500b0ed, 0x6afe2900, 0xb606e507, 0x39001400, 0x5b004900, 0xdc006600, + 0x56758140, 0x01566601, 0x69014d69, 0x024c794c, 0x29014c3a, 0x3974014c, 0x01394501, 0x55011766, 0x17460117, 0x17170701, 0x2c330217, 0x3528032a, + 0x03504e38, 0x7f523636, 0x154a014a, 0x07420642, 0x0d0c0c0a, 0x68003a42, 0x5c015c18, 0x541d2826, 0x50612152, 0x70526052, 0x2e520352, 0x3536282f, + 0x2f2f2e33, 0x33382c4e, 0x24265403, 0x1d241958, 0x635e195c, 0x0d42191f, 0x463e1146, 0x08190406, 0x000a070c, 0x3f33332f, 0xdedd32d4, 0x393912cd, + 0xdeddd010, 0xcd393911, 0x0582cd10, 0xcd333f25, 0x822f3332, 0x0132270b, 0xcd32ce2f, 0x2183dc5d, 0x5d222482, 0x2d82d610, 0x332f3222, 0x102b2482, + 0x125dcddc, 0x39172f39, 0x56171233, 0x20080baf, 0x015d5d5d, 0x23060714, 0x06032722, 0x37362307, 0x36373613, 0x16173233, 0x02071001, 0x26272221, + 0x211a8227, 0x12833435, 0x12373628, 0x04373637, 0x21822707, 0x17240882, 0x01040706, 0x2205704e, 0x60141506, 0x0f83053a, 0x07062727, 0x07020306, + 0x22118316, 0x7a013613, 0x420905cd, 0x36373233, 0x5357e507, 0x4b566c8a, 0x16c6250c, 0x591e8024, 0x52817f5e, 0x87d0fd57, 0x71bafea7, 0x5b414168, + 0x4f6fc1a1, 0x1d1f3d50, 0x5c3a3045, 0x138ee3fe, 0xd5ae463e, 0x4232d847, 0x010c026a, 0x492d279b, 0x2f2d314a, 0x2e464732, 0x479efd29, 0x443cd657, + 0x3c404629, 0x584c5228, 0xfc5f7ae8, 0x2d40427b, 0x1f487141, 0x881f0108, 0xfe4d4c4f, 0x254639a0, 0x7e220262, 0x4c48524f, 0xa0fed301, 0x47dcfeed, + 0xb8b23536, 0xac266a4e, 0x9553018c, 0x50106db7, 0x34151f3c, 0x1c964d01, 0xfb258542, 0x423a4c63, 0x494c3b41, 0x3c43423d, 0x7ffda002, 0xca570e9c, + 0xfebdfe7a, 0x40228ed7, 0xd9170138, 0x3e2ca8fe, 0x1245642d, 0x00020000, 0x0359fe05, 0x001e06f2, 0x00300027, 0x496040a0, 0x02187918, 0x2c002f25, + 0x16161111, 0x12122815, 0x0f141515, 0x1b1b0c18, 0x211b282c, 0x1b0c0600, 0x13703200, 0x70141301, 0x022f802f, 0x18012f64, 0x3f2a162f, 0x1f11250f, + 0x01127f00, 0x124e123e, 0x2f121f02, 0x15120212, 0x01167013, 0x16611641, 0x01162202, 0x16011610, 0x08131411, 0x00043f0a, 0xc03fed2f, 0x825dcdd6, + 0xdd102100, 0x3f350683, 0xed393912, 0x5d393911, 0xcd2f015d, 0xfdd6105d, 0xfdd010cc, 0x281183de, 0x2f193911, 0x12112f33, 0x09058539, 0x30313901, + 0x0706055d, 0x27222306, 0x33163335, 0x27343732, 0x27070603, 0x17012307, 0x26033736, 0x36373635, 0x14112033, 0x13070607, 0x23340316, 0x17140722, + 0xf2033613, 0x8a535901, 0x5d0a5f62, 0x06018c41, 0x857a7385, 0x2201c469, 0xa7883081, 0x52590107, 0x47100184, 0x0dc24e3a, 0x01715cb4, 0xb0686105, + 0x133e4376, 0x17741bb2, 0xced70116, 0x02c5dec6, 0xff53f20b, 0x301a5f02, 0xfe414881, 0xaed685f5, 0x3135fd9d, 0x76818205, 0xaefe1224, 0x000400f4, + 0x04000048, 0x00d105cc, 0x0025001e, 0x0031002c, 0x2b554090, 0x022d3b2d, 0x2d012d19, 0x1f2b282b, 0x1f021f3b, 0x001b1526, 0x97191d17, 0x16850116, + 0x01167601, 0x03011665, 0x16571647, 0x1b011602, 0x06252a33, 0x1008142f, 0x0a0e080c, 0x30350508, 0x2a2e0109, 0x1f0c0f1d, 0x0c02020c, 0x25290d19, + 0x35241016, 0x08080311, 0xfd3f3f00, 0x83c0c0dd, 0x5d5f2102, 0xde310784, 0xde2f01ed, 0xc0d010c0, 0xc0c0fd10, 0x32dc10c0, 0x058f4c32, 0xdc323228, + 0x32ed10c0, 0x1082325d, 0x30315d29, 0x07062301, 0x44232306, 0x2e0805f6, 0x33352335, 0x17322111, 0x15331716, 0x14151623, 0x26013307, 0x23232627, + 0x27340515, 0x36211521, 0x33152107, 0x63cc0432, 0x9f6abc50, 0x8280c6c6, 0x014c0800, 0x6e8bfd94, 0x02385129, 0xc6fe3d07, 0x613b6c38, 0x043a02c4, + 0x3102cafd, 0x0bfe4509, 0x4003f1a7, 0xfd2745a9, 0x784003d5, 0x1501788c, 0x786f495d, 0x292e1d18, 0x18460401, 0x20b26b0d, 0xa0288c1a, 0x0300006c, + 0x9800f500, 0x80049705, 0x34065150, 0x04114025, 0x050d0800, 0x54090901, 0x5403050b, 0x05540701, 0x05904600, 0xcb82d382, 0xc0c0d622, 0x2123b882, + 0x86112135, 0x97052503, 0xa2045efb, 0x03240387, 0xbcfda0e0, 0x78080283, 0xc8000500, 0x2b0538ff, 0x18009906, 0x25002100, 0x34003000, 0x53408b00, + 0x69011b78, 0x1754011b, 0x56021764, 0x10070114, 0x01026601, 0x15010257, 0x0d1e1316, 0x22142c04, 0x3110070a, 0x90318001, 0x31310231, 0x00152633, + 0x130f1519, 0x36001301, 0x08143325, 0x221e1516, 0x33332c35, 0x35231d31, 0x03090b0d, 0x0635312d, 0x00080804, 0xedcec53f, 0x33ce3f32, 0x391132ed, + 0x2c05822f, 0x2f013939, 0xd610c0fd, 0x10ed5dd4, 0x211282ed, 0xbc48715d, 0x39122106, 0x26098d44, 0x06071401, 0x84231507, 0x153323c8, 0x01821716, + 0x07141532, 0x01161615, 0x27262734, 0x36373611, 0x11231105, 0x0e890c84, 0x2b05da08, 0xaee68e9b, 0xa6015afe, 0xcb2138ae, 0x99c62547, 0x4cb3feac, + 0x27884630, 0xe090fe13, 0x317dcf02, 0x91381843, 0x11fe6c44, 0xd7ca01e0, 0xc90a6f79, 0xc8d105c8, 0x1e0503cc, 0xc95e4482, 0xcb1f0863, 0x2c6b0402, + 0x61fe061c, 0xad2e6016, 0x52feae01, 0x41a848fe, 0x0203071a, 0x2f0bddfd, 0x2a02894a, 0x0300d6fd, 0x6affbe00, 0x2e049903, 0x2c002500, 0x8a003300, + 0x19225740, 0x16263104, 0x2b0d0d07, 0x8f1d2a2d, 0xaf009f00, 0x00710300, 0x60005001, 0x002f0200, 0x2b350001, 0x1280092a, 0x1d341201, 0x1d021d44, + 0x2f1e1f19, 0x261e021e, 0x04310e22, 0x51272132, 0x3b191617, 0x02094b09, 0x0a000709, 0x0a200a10, 0x320d0a03, 0x07040551, 0x333f0009, 0xc432fdcd, + 0x5d39115d, 0x2209832f, 0x84391711, 0x2f01270c, 0x10edc45d, 0x00825dd6, 0x11edc428, 0xc0c02f39, 0x0382ddc0, 0x41303121, 0x26250734, 0x16333527, + 0x071a5117, 0x41353721, 0x152f0540, 0x11272623, 0x25161716, 0x06070611, 0x41011415, 0x6b080548, 0x4e6a9903, 0x93a17679, 0xbfa08c08, 0x4e60333e, + 0x403e7682, 0x72083a54, 0xe4311c92, 0x243059fe, 0x2b95013b, 0x0190481d, 0x3c528006, 0x05787e10, 0x0f69b04a, 0x4c262301, 0x50795c3f, 0x787b1041, + 0x1e140f04, 0xfe1254a9, 0x340a05e2, 0x0804015c, 0x62422114, 0x1f3ea6fe, 0xf8fe1115, 0xffff0017, 0x82fe7300, 0xf005da05, 0x32003602, 0x22052f67, + 0x6900a505, 0x26210587, 0x8bd11827, 0x82fe2508, 0x7c047104, 0x52202382, 0x04212385, 0x232386e2, 0x00061b1a, 0x2605616a, 0x05e1ff73, 0x880108da, + 0x00562c47, 0x00750196, 0x020b4022, 0x82013450, 0x34702e03, 0xffb83402, 0x090940c0, 0x3400370b, 0x6a5a8324, 0xe1240a67, 0x8c067104, 0x4a225f88, + 0xf36eb004, 0x1d702506, 0x1c1d0001, 0x476b6383, 0x20658f05, 0x3265844e, 0x0314401e, 0x01285002, 0x28200203, 0x28802850, 0x84280003, 0x355d2360, + 0x03820035, 0x00ffff27, 0x04e1ff6a, 0x226188f6, 0x824e0216, 0x401932c0, 0x00020313, 0x501c201c, 0xb01c801c, 0x1c00051c, 0x20688518, 0x05071935, + 0x4f022112, 0x16226984, 0x69860d40, 0x61876286, 0x82e5ff21, 0x22c38961, 0x824f0216, 0xb70c2161, 0x55846083, 0x82353521, 0x22bd8f85, 0x8296005c, + 0x401522e7, 0x86b8930f, 0x07a222b5, 0x06174152, 0x50021622, 0x5720b5b0, 0x712261a2, 0x6188de07, 0x61a15120, 0x4182fe21, 0x002509e7, 0x00d60037, + 0x06096d96, 0xcb82a520, 0x13401d2f, 0x01285002, 0x2d000328, 0x25030f2e, 0x07254102, 0x2209096d, 0x4182fe6a, 0x002a09eb, 0xe2d60036, 0x02170100, + 0x7882044b, 0x40140029, 0x2100030e, 0x82000622, 0x058c4138, 0x412b3521, 0x06280637, 0x0201088b, 0x00460236, 0x00252d82, 0x0178008d, 0x2a2d8275, + 0x3650020d, 0x02023660, 0x82363600, 0x1863826c, 0x22089b9d, 0x828c06c3, 0x8247202d, 0x0016222d, 0x255a828d, 0x0002b60a, 0xab422b2b, 0x224f8c0a, + 0x71aa0043, 0x4f840739, 0x70365023, 0x20548736, 0x08ad6c5d, 0x8b04e121, 0x82432055, 0x40112755, 0x2b50020c, 0x5b872b60, 0x8b08a342, 0x5602235d, + 0x5d828f00, 0x0b40122a, 0x013a5002, 0x393a0002, 0x1724ab98, 0xba044a02, 0x21065943, 0xad8c2e2f, 0x88c80721, 0x00d722fd, 0x204f878b, 0x214f8242, + 0x4f903542, 0xfb885320, 0x00c4d733, 0x10401500, 0x20371002, 0x50374037, 0x37000437, 0x0a4d432a, 0x0682fe25, 0x87f0058b, 0x4b022159, 0x2108fb43, + 0xfb433837, 0x05c3220b, 0x41518684, 0x0a2507a9, 0x2c0002b6, 0x2aa1872d, 0x0582feb2, 0x02d10529, 0x44380036, 0x0521051f, 0x24c58462, 0x21200001, + 0x061f440c, 0x82feb126, 0x5d045704, 0x58202382, 0x04212385, 0x232386d1, 0x16091a19, 0x26054344, 0x05e1ffb2, 0x88010829, 0x00562247, 0x27e98562, + 0x01235001, 0x22230001, 0x002c4c84, 0xffff355d, 0xe1ffb100, 0x8c065704, 0x4a224f88, 0x4f86c704, 0x8a1b1c21, 0x7506214f, 0x02214f83, 0x06374248, + 0x37427c20, 0x50012905, 0x022e602e, 0x2d2e0001, 0x0521518d, 0x215183a5, 0x37424902, 0x00ee3305, 0x10401800, 0x01286001, 0x40283001, 0x28000228, + 0xcd820929, 0x82071142, 0x425d8cad, 0x1c2a0545, 0x50011440, 0x022d602d, 0x05824001, 0x032d8024, 0x64842d00, 0xb7823587, 0x4321658c, 0x2b658602, + 0x50010127, 0x02276027, 0x08272700, 0x02206599, 0x250a1341, 0x00010131, 0xc1983031, 0x41021721, 0x2b210913, 0x2353832a, 0x00ffff35, 0x0723b584, + 0x413602be, 0xd72b0613, 0x6b016200, 0x01b60a00, 0x412c3900, 0xff2108ab, 0x20a382e1, 0x41238253, 0xd7220509, 0x218400fd, 0x88263321, 0x82fe2545, + 0xf8067506, 0x02214587, 0x08f1414b, 0x0d2f2e22, 0x2309f141, 0x8405a505, 0x17224586, 0xf1414b02, 0x29282108, 0x063e4787, 0xe6040000, 0x36020108, + 0x00003c00, 0x43001701, 0x7501e4ff, 0x0a401b00, 0x600a5001, 0x0582020a, 0xffb80129, 0x0a0ab4d3, 0x46250104, 0x0020052e, 0x3d26c382, 0x7f0464fe, + 0x35828c06, 0x35825c20, 0x43001634, 0x130000dd, 0x096001b5, 0xb8020970, 0x09b4ddff, 0x41410409, 0x262b8205, 0x0482fe06, 0x87d105e6, 0x21858261, + 0xcd8500f6, 0x83090a21, 0x87352054, 0x5d04214f, 0xa9824f86, 0x82dc0521, 0x40123123, 0x0f0a010d, 0x4f0a2f0a, 0x7f0a6f0a, 0x115d050a, 0x0853b818, + 0x0223b189, 0x82ecff56, 0x401831b1, 0x0e500110, 0x0ec00101, 0x00020ed0, 0x02030d0e, 0xad90ae86, 0x4a021724, 0xdd46b504, 0x50012605, 0x0d00010d, + 0x25ab8a0c, 0xe6040000, 0x0d41c807, 0x84d72008, 0x40122d5b, 0x1650010b, 0x16000101, 0x25000509, 0x4107e544, 0x53200503, 0x21080341, 0xd585ddd7, + 0x83081521, 0x00353c4f, 0xfe6c0003, 0x06fb04bd, 0x001b0014, 0x012c0028, 0x3b424013, 0x3c0c3805, 0x19243222, 0x0812271c, 0x2bb52a2e, 0x1a511401, + 0x18101717, 0x07041301, 0x04104120, 0x42260803, 0x2b2c0a07, 0x0a012b2c, 0x16880016, 0x041c1317, 0xb4f4ffb8, 0x55020909, 0x40230883, 0x820c0c0e, + 0x1a1a2f09, 0x0f0f402e, 0xb8015502, 0x2340f6ff, 0x09821010, 0x0b0b0822, 0x10200582, 0x0c201584, 0x01212e83, 0x232a832a, 0x0d0d0a01, 0xec2a2784, + 0x0f0f0b40, 0x06015506, 0x05820d0d, 0xecffb826, 0x09091c40, 0x92260982, 0x3f2e1f2e, 0xb518022e, 0x0122070a, 0x4883180a, 0xffb80a25, 0x831940fe, + 0x820a204c, 0x55022326, 0x4c830c0a, 0x83040a21, 0x850a254c, 0x2bf6102d, 0x32230083, 0x865d2bed, 0x210f870a, 0x0082322b, 0x532fed21, 0x003d0585, + 0x3f3fed3f, 0x393912ed, 0x2f39123f, 0x2f3cfd3c, 0x5d3031ed, 0x23112301, 0x23060635, 0x9b6a1822, 0x2135210a, 0x33230182, 0x18013315, 0x200b8e6a, + 0x2a148213, 0xbcb8fb04, 0xc66ead4d, 0x194452ed, 0x27163a1c, 0x03b4fcea, 0xfbf4044c, 0x1d3f1c19, 0xe2fd4808, 0xffff0086, 0x1d050bfc, 0x53064aff, + 0xd7001700, 0x00001efb, 0x8a000200, 0x90049100, 0x23009804, 0x67002f00, 0x02063740, 0x080b292d, 0x1a1d2302, 0x17081114, 0x052f0206, 0x29270501, + 0x01170f05, 0x1f310f17, 0x89240231, 0x200e371d, 0x2a200120, 0x0e0f2029, 0x5d2f0e01, 0x5d2fed33, 0xed391712, 0x0b85005d, 0x5854432a, 0xb005a0b4, + 0x595d0205, 0x0e831683, 0x83278c23, 0x240e822d, 0x07013031, 0x3cff8327, 0x27072726, 0x35262637, 0x27373634, 0x36361737, 0x17163233, 0x16071737, + 0x06141516, 0x1ad11807, 0x0425080b, 0x2cec6e90, 0x572e344a, 0xe96dec24, 0x1a161817, 0x24eb6fea, 0x582c2d57, 0xeb71ea25, 0x17191818, 0x494b6965, + 0x0803836b, 0x6e010128, 0x19161aea, 0xea71ec17, 0x342b5925, 0x6eed2b49, 0x181917eb, 0xed6dea17, 0x2d305326, 0x49a92458, 0x4a4b6e70, 0xf9826d6f, + 0x016eb608, 0x054e0859, 0x000c00ec, 0x40e20034, 0x580b2895, 0x780b680b, 0x0977040b, 0x66095601, 0x09270209, 0x09470937, 0x65345503, 0x20690234, + 0x01205a01, 0x77010a82, 0x2113010a, 0x030d2f1b, 0x0503040a, 0x021a000b, 0x071a0509, 0x0d1b1927, 0x33013176, 0x27761731, 0x01276401, 0x27552745, + 0x34272402, 0x25270227, 0x281f280f, 0x79282802, 0x1d28011d, 0x111f1d01, 0x02253e2b, 0x79090b02, 0x136b0113, 0x5a134a01, 0x132b0213, 0x1302133b, + 0x10140011, 0x14140214, 0x07113e17, 0x0404030a, 0x05070109, 0x3f000309, 0x12c0dc33, 0x33c02f39, 0x32edd410, 0x39125d2f, 0x2300825d, 0x3f32c010, + 0x8805e14f, 0x39113412, 0x2f015d39, 0xfddec4ed, 0x33eddc32, 0x10391712, 0x5ac4fddc, 0x01200701, 0x5d223382, 0x71182301, 0x01200af8, 0x2805d251, + 0x33163335, 0x27343520, 0x20018226, 0x12315d24, 0x4e080424, 0x7218feba, 0x24080a20, 0x809b89fb, 0x0abcd5bd, 0x0801d5c2, 0x4a5b2538, 0x73f2fe94, + 0xa3d2d67a, 0x5fceab0a, 0x4bb35541, 0x01110195, 0x45721874, 0xfc39080d, 0x4e5eb1e5, 0xa692d35e, 0x1418264c, 0xe448210e, 0x5466608f, 0x291f7ec9, + 0x0e2a7755, 0x01003f20, 0x1602e9ff, 0xc502c105, 0x11000300, 0x010500b5, 0x00010304, 0x1001cd2f, 0x051971c6, 0x05213534, 0x0528fac1, 0xaf1602d8, + 0x7e020100, 0x2d0393fd, 0x2b824807, 0x02b30d3a, 0x00020300, 0x2f012f2f, 0x013031cd, 0x02113311, 0x93fdaf7e, 0x4bf6b509, 0x05212785, 0x295382c2, + 0xb6130005, 0x02050701, 0x2a820503, 0x2b83cd20, 0x15315584, 0x11231121, 0x6bfdc205, 0xafc502af, 0x32057dfb, 0x82878300, 0x872c205b, 0x03062533, + 0x00030400, 0x33888882, 0x82352121, 0x7d022634, 0x43036cfd, 0x218c82af, 0x3382cefa, 0x827e0221, 0x82c220bb, 0x2167838f, 0x96820705, 0xcd209284, + 0x67849382, 0x21219582, 0x21978215, 0x27829502, 0x7dfb3223, 0x236784af, 0x2c031602, 0x01243386, 0x05030006, 0x2f203682, 0x67839b89, 0x2c033326, + 0x9402bdfc, 0x04216783, 0x37338283, 0xdbff2500, 0x5305db03, 0x1c001e00, 0x0a090b40, 0x1e1e1911, 0x110a161c, 0xdd24a082, 0x32cd2fce, 0xdd3d6f82, + 0x3031cdde, 0x17323301, 0x16161716, 0x35231515, 0x26272634, 0x14112323, 0x22230606, 0x05a15326, 0xe6015408, 0x4f37ac26, 0x63342d3c, 0x59493839, + 0x5c9c401c, 0x7b987f6d, 0x5305604e, 0x2a39140e, 0x2b676699, 0x20195f44, 0x8779bdfc, 0x69647b51, 0x00002e8f, 0xff730002, 0x06a20552, 0x002b0096, + 0x405a0035, 0x22211631, 0x15060405, 0x33341306, 0x14070408, 0x82071514, 0x0e3c0801, 0x001a6c27, 0x152f3775, 0x2136680e, 0x2911342c, 0x162a2a35, + 0x24330211, 0x00030834, 0x32ed332f, 0x2f39333f, 0x32ed10ed, 0xedf61001, 0xed32f610, 0x2f393912, 0x1133112f, 0x32391712, 0x31250483, 0x04062530, + 0x05df5d23, 0x0229b682, 0x21001035, 0x33371732, 0x23cc8207, 0x26231517, 0x272f1382, 0x32331603, 0x23113736, 0x22012135, 0x82101100, 0x137708e7, + 0x7aa20526, 0x4a87dffe, 0x25802044, 0x67509e3f, 0x01a10170, 0x241a1a6c, 0x29292780, 0x1f129985, 0x6b483976, 0x60332ff9, 0x019548bf, 0xfabcfd59, + 0x5198ddfe, 0x6e18f571, 0x9a095338, 0x484a0eb1, 0xc3230161, 0x9d016501, 0x06b9ab01, 0xeb491e0a, 0x231a4e18, 0x0660fb16, 0x6d011e26, 0xfe5602ae, + 0xfeeefebf, 0x2856a1df, 0x00019204, 0x001a0003, 0x055e0500, 0x821700d1, 0x001e3a09, 0x0b5340a2, 0x09060507, 0x050e0d0a, 0x1d1e030e, 0x040e191a, + 0x05140419, 0x3602820e, 0x16121905, 0x17141310, 0x02000f00, 0x19181c1b, 0x0119010f, 0x820f0014, 0x19003e02, 0x02061719, 0x141b3403, 0x181d1e09, + 0x341a0d10, 0x1d0a131c, 0x0e0f051d, 0x04000103, 0x07c55905, 0x2f391222, 0x2106fe50, 0x0886de10, 0x19012f23, 0x0666592f, 0x210b7b59, 0x7d59c0d0, + 0x33168b08, 0x31c0d010, 0x03232130, 0x13230321, 0x37333523, 0x13213521, 0x3e080182, 0x33172115, 0x03012315, 0x21270103, 0xd35e0507, 0x927cfd92, + 0xd59797c9, 0x01edfe3e, 0x0801cd51, 0xfe5101cd, 0x97d53eed, 0x8c8c7cfe, 0xfe3d9101, 0x9f013d6f, 0x9f0161fe, 0x02aaaaaa, 0x82ccfd34, 0x01b50806, + 0xfe8701fe, 0xaaacfe79, 0x000100aa, 0x05e5ff2e, 0x00ec054a, 0x40f1003d, 0x6631569c, 0x105a0231, 0x01054601, 0x3c323c22, 0x013b3202, 0x30013b20, + 0x39240139, 0x3c3b3901, 0x3d320303, 0x011d2b34, 0x03191b1d, 0x15222012, 0x320c3336, 0x01151e3f, 0x172c1503, 0x3b891214, 0x3bb93ba9, 0x013b7b03, + 0x5a013b69, 0x3b49013b, 0x3c393b01, 0x2c751d36, 0x012c6701, 0x2c012c56, 0x012b7f2e, 0x3420332b, 0x19861976, 0x01194502, 0x1bb71b97, 0x171b1902, + 0x693c171d, 0x0c58010c, 0x010c4901, 0x0c010c3b, 0x700b600e, 0x140b020b, 0x3c3c3401, 0x2e342607, 0x0e340702, 0x064d620a, 0xc0fd2f25, 0x45115dce, + 0xdd220642, 0x09833911, 0x10211288, 0x391085c0, 0x2f015d5d, 0xedc43333, 0x10c0de32, 0x3333c4d4, 0x171132ed, 0xc0de5d39, 0x06821211, 0x00825d20, + 0x21055545, 0xd5562101, 0x37242e06, 0x21041533, 0x35262720, 0x35233734, 0x05fc5633, 0x21352124, 0xfc563536, 0x23072e06, 0x32213635, 0x15071617, + 0x06231533, 0x08018307, 0x4a052169, 0x8705fffb, 0x018b9767, 0xfe0e6b25, 0xfee5fef4, 0x019aa9ee, 0xd54a7749, 0x222bfe80, 0xeb039ffc, 0x86607a02, + 0x5e918686, 0x1901ef0e, 0x03a19df4, 0x21168961, 0xcf69c561, 0xc7011e03, 0x42881f1b, 0xf8596b33, 0xc07c8877, 0x7eaa130b, 0x0a341738, 0x0f13aa0d, + 0x2a333f7a, 0x68ea502d, 0x0fba7977, 0x67232caa, 0x43291029, 0x463806c1, 0x1c009606, 0x92002700, 0x0d095c40, 0x0a020d19, 0x02091a09, 0x56012665, + 0x39080282, 0x225a0125, 0x69215901, 0x04120221, 0x070f1e18, 0x14241d1d, 0x15242900, 0x0114460b, 0x16011437, 0x02142614, 0x157f1214, 0x1e151501, + 0x0f103418, 0x00490212, 0x01003801, 0x5d830019, 0x1c700432, 0x1d1c1c01, 0x06073419, 0x3f000a04, 0x32ed33cd, 0x22079446, 0x89cd333f, 0x0599600c, + 0x5e391221, 0x9946053e, 0x0625320a, 0x15070607, 0x27243523, 0x37101126, 0x33352536, 0x05f96115, 0x37361125, 0x83110533, 0x062e081d, 0x16171015, + 0x92464605, 0xfe76757d, 0xcacca9e2, 0x761c01ad, 0xd40fefdb, 0x0ec4f8e7, 0x4051c0fd, 0x98274cc1, 0x38216c74, 0x95940627, 0x9260a812, 0xb13b0805, + 0x0aabac14, 0x12b1eb78, 0xb01251fb, 0x07ad04c1, 0x74e14e1a, 0xa1dbfe95, 0x00ffff7b, 0x0559fe86, 0x02ec0502, 0x00360026, 0x03070000, 0x0034018e, + 0x00ffff00, 0x0359fe6e, 0x827804d7, 0x85562017, 0x97002117, 0x00261784, 0xee0459fe, 0x1782d105, 0x17863720, 0x1784e820, 0x59fe3e26, 0x9e05fd02, + 0x57201782, 0x06231782, 0x83208e03, 0x00a42645, 0x074a0200, 0x351582cc, 0x0100004c, 0xfe8d0007, 0x00400187, 0x020a4012, 0x5e02020a, 0x117a080a, + 0xde102605, 0x00010034, 0x364182c4, 0x008dff05, 0xb5320003, 0x10091003, 0xffb80137, 0x111540f0, 0x82693715, 0x003a081d, 0x00031001, 0x40030280, + 0x03370c09, 0x2f2f0002, 0x2f18012b, 0x5e5fcd1a, 0x5d30315d, 0x03052b2b, 0x05021323, 0x736492af, 0x3401ccfe, 0xc800ffff, 0x39050000, 0x36020108, + 0x7982f001, 0x4300172f, 0x75019600, 0x01b60a00, 0x050a0b00, 0x05ef4e09, 0x0000b92a, 0x8c066604, 0x10023602, 0x2005c74c, 0x05c34b1e, 0x00292186, + 0xfe71fd02, 0xff8f0252, 0x329382ba, 0x40200007, 0x0603070f, 0x06400502, 0x02400180, 0x82020250, 0xcd5d2d85, 0xcd1ade1a, 0x2f332f01, 0x05303133, + 0x25065456, 0xe2fa8f02, 0x03831e05, 0xfe78be25, 0x82007898, 0x82af2047, 0xb0512047, 0x56512047, 0x47860798, 0x00033008, 0x0964fe73, 0x00f00580, + 0x00280014, 0x403c0030, 0x2d2d2e1f, 0x03031515, 0x32292930, 0x2f0d151f, 0x30322c2c, 0x0c2b052d, 0x0212341a, 0x43083424, 0x3f2305ee, 0x8211333f, + 0x2f012301, 0xa78211ed, 0xed2f3922, 0x8608ad84, 0x15121601, 0x06060214, 0x26262223, 0x12343502, 0x32333636, 0x2e341316, 0x0e222302, 0x1e141502, + 0x3e323302, 0x23010102, 0x01330113, 0x4e710401, 0xda9b5553, 0x9ada8786, 0xdb995154, 0x20d9898a, 0x598e6436, 0x35648f5a, 0x588f6437, 0x36648e59, + 0xbafd3c05, 0x73febbc8, 0x012901ca, 0x64260528, 0xbbb9dffe, 0x66c5dffe, 0x2001c667, 0x1f01b4ba, 0xfd696cc9, 0x9ae29061, 0xe19b5051, 0x9ae19291, + 0xe299504f, 0x18fa0602, 0x2f080760, 0x6a000300, 0x520864fe, 0x13007c04, 0x27001f00, 0x253ddd83, 0x1b142424, 0x20270000, 0x1b1a2920, 0x2323260a, + 0x05242729, 0x3f170c22, 0x3f1d040f, 0x21dd9c05, 0xc8820e14, 0xd8822e20, 0xc8823e20, 0x07021e22, 0x072c5618, 0x36323322, 0x0d3bd488, 0x6aac7942, + 0x417aac6b, 0x6aad7942, 0x4279ac6a, 0x81808fc2, 0x7f828e8f, 0x8a070590, 0x2e022acc, 0x5299da88, 0x88da9952, 0x2a078489, 0xd3d988db, 0xd8d3d9d3, + 0x8a0303d7, 0x3abf82be, 0x07e5ff73, 0x0068086c, 0x0064004a, 0x405d0070, 0x1a556330, 0x6f706d56, 0x82566f6b, 0x0a200801, 0x1e41152d, 0x6a6b0a15, + 0x6f6e196a, 0x3c52646f, 0x3c635b5b, 0x19326455, 0x020f3c34, 0x34232528, 0x3237d084, 0xed333f32, 0xed32d432, 0x11ed2f32, 0x11cd2f33, 0x01cd2f39, + 0x482fed2f, 0x102a0729, 0xed10cddd, 0x253031c4, 0xb941030e, 0x1517230c, 0x11822e23, 0x2507ba41, 0x33163337, 0xfe823e32, 0x2705cf41, 0x36352307, + 0x16323336, 0x0808f341, 0x13022ef9, 0x23042e22, 0x23070622, 0x3233033e, 0x3333041e, 0x0e140515, 0x36350702, 0x33352335, 0x4922ef03, 0x74416956, + 0x3f4e8cc3, 0x4e6dad76, 0x1e083e7d, 0x25403a39, 0x2848623a, 0x447c5f39, 0x930993bf, 0x5f7c44bf, 0x62482839, 0x3a40253a, 0x3e081e39, 0xad724e7d, + 0x8c4e3b75, 0x674174c3, 0x37d04a56, 0x363a4657, 0x33301f36, 0x2c068507, 0x32315644, 0x39343d4a, 0xfea12c42, 0x463019cc, 0xbf5f5d2e, 0x28351e77, + 0x01bf5d17, 0x01b6c422, 0x1269c71f, 0x2319df14, 0x964b0a16, 0xe29f98e3, 0xc4c44492, 0x9fe29244, 0x4b96e398, 0x1a231609, 0x691214df, 0xb6e1fec7, + 0xbfdefec4, 0x3528175d, 0x1e14fd06, 0x4b141e23, 0x45694641, 0x211e1323, 0xbe8f131e, 0x1f364729, 0x5b0c5602, 0x0003009a, 0x06e2ff72, 0x00f40611, + 0x006b0051, 0x405f0077, 0x1a5c6b31, 0x7677745d, 0x825d7672, 0x19260801, 0x052e1a42, 0x7172191a, 0x76753d71, 0x3c596b76, 0x3c6a6262, 0x0a6b6b5c, + 0x33143f3d, 0x47004c04, 0x000a293e, 0x8a41ed3f, 0x2f332205, 0x208b4133, 0x22116941, 0x4215021e, 0x27250681, 0x23030e23, 0x07894222, 0xa7411620, + 0x023e250e, 0x031e3337, 0x081c8b41, 0x4a66044b, 0x1e13335c, 0x1b2e4c36, 0x1728292c, 0x3d5a3007, 0x2d5d8f63, 0x6fa06732, 0x3c4b5932, 0x3a160616, + 0x6f335648, 0x363267a0, 0x3d578c63, 0x1707305a, 0x1b2c2928, 0x1e364c2e, 0x495d3313, 0x39425035, 0x391c111c, 0x38025142, 0x1e924156, 0x49832108, + 0x69509977, 0x07366b9e, 0xbc0c130d, 0x974f0f0b, 0xda8b8bda, 0x2a184f96, 0x39212139, 0x964f182a, 0x973a0f83, 0xbc0b0f4f, 0x070d130c, 0x699e6b36, + 0x49779950, 0x2d4e3b21, 0x213b4e2d, 0x95415f05, 0x0128081b, 0x1d05de00, 0x34061004, 0x1b001900, 0x0a190c40, 0x3c070b1a, 0x3c171010, 0x2f00000a, + 0x2f32ed32, 0xed2f01ed, 0x013031c4, 0x21109842, 0x4c426603, 0x22052117, 0x44087190, 0x73000200, 0x4c069dff, 0x4300f005, 0x56005100, 0x05442d40, + 0x3a154f0e, 0x0c3a1435, 0x3a471500, 0x24474724, 0x2e0e033a, 0x0c0c1c15, 0x3f344a0e, 0x3429333f, 0x34334421, 0x11330717, 0x000a1705, 0xedd4333f, + 0x218d8310, 0x91833912, 0x2f2f332f, 0x391712ed, 0x102f2f2f, 0x391211ed, 0x21058239, 0xa4823939, 0x020e1431, 0x32331607, 0x3337023e, 0x23060615, + 0x83272622, 0x45242005, 0x2428054a, 0x17163233, 0x26262315, 0x24094b45, 0x35032e37, 0x058b4434, 0x36360124, 0x1a863437, 0x05165d08, 0x634626da, + 0x196d613e, 0x1627272a, 0x365c330a, 0x365bc35b, 0xff9d3e74, 0x5f62b400, 0xa20001b2, 0x09336e3b, 0x713b6136, 0x45437eb4, 0x1f6fb47e, 0x2e41281e, + 0x9071441a, 0x72924c4c, 0x6d4efe46, 0x665f0176, 0x18314a33, 0x61ab0258, 0x2e7893ac, 0x0c080425, 0x080ab108, 0x11113531, 0x24097b45, 0x17bd0e0b, + 0x07794514, 0x2d037108, 0x5796826e, 0x3270b482, 0xfdaf672a, 0xa5f5429e, 0x4f2a9388, 0xe795456f, 0x00020000, 0x0491ff6a, 0x007c04db, 0x00410036, + 0x0332405d, 0x1b3c093f, 0x092a0f2d, 0x371b002d, 0x37371f2d, 0x0a032d1f, 0x08171b27, 0x3f39090a, 0x32013210, 0x3f242a32, 0x2a3f041c, 0x3f05123f, + 0x12030c0c, 0x333f000a, 0x10ed2f33, 0xed3f32ed, 0x5d2f3912, 0x2f2f01ed, 0x44410f82, 0x07062814, 0x36323316, 0x41153337, 0x28430841, 0x6126200b, + 0x16230512, 0x41262617, 0x4f08073b, 0x22233407, 0x16141506, 0x04363617, 0x3f5b6585, 0x1c44224b, 0x5e4c400a, 0x3b1d49ad, 0x8cc67b21, 0xc48a4b4b, + 0x2e653779, 0x39592f0a, 0x95a1b09f, 0x5836302c, 0x743d3d73, 0x7ec2365a, 0x33313e3f, 0xe3014f48, 0x1445d483, 0x0caa0a0a, 0x07062f2e, 0x0807d545, + 0xc10e0c4a, 0xd9d31b1e, 0x420bd6c9, 0x886267a7, 0x52262757, 0x62b75d84, 0x3a9a5861, 0x00009d2a, 0xff1b0002, 0x059506e5, 0x002f00ec, 0x4038003a, + 0x1507301d, 0x311b1b2b, 0x31201328, 0x1b051115, 0x302b3507, 0x340c0030, 0x34360a16, 0x3f232c82, 0x5ded3fed, 0x012705cd, 0x2fed332f, 0x823912ed, + 0x31322c06, 0x16320130, 0x15151216, 0x85031e21, 0x030e30f5, 0x26242223, 0x032e2702, 0x37363435, 0x84061533, 0x033e23da, 0xcb452101, 0x046b0805, + 0xacf39603, 0x09aafb5d, 0x6db88952, 0x0e64f792, 0x887d7336, 0xfbfe9e4c, 0x4b086fbe, 0x05335b7d, 0x0907be06, 0x650f564c, 0xcffee4a7, 0x470d7d03, + 0x60609a71, 0x0546719c, 0xfec764ec, 0x861fc8d4, 0x694588cb, 0x331ee35b, 0xb3591526, 0x03b10a01, 0x4f754e29, 0x0b1e391c, 0x401a3117, 0xf398054e, + 0x72fd5aaa, 0x417db372, 0x82b37d43, 0xff142ab6, 0x041f05e6, 0x002c007c, 0x3be38333, 0x251a0133, 0x2d191313, 0x212c0c1a, 0x0113191a, 0x3333253c, + 0x293d3007, 0x0f3f0704, 0x85057b47, 0x2f0122d7, 0x85de82ed, 0x24e382ef, 0x17161421, 0x07d64116, 0x20230629, 0x26032627, 0x89022e27, 0x178908e1, + 0x37361716, 0x12323336, 0x26262715, 0x07062223, 0xc9fc1f05, 0x8f34363e, 0x31e77256, 0x6dc65f0a, 0x999ceafe, 0x362f3603, 0x05042c4e, 0x21080599, + 0x701b4920, 0xf5e2f496, 0x969301b7, 0x020cb397, 0x3199671b, 0x2c5b3030, 0x963628cd, 0x030c0194, 0x603f100d, 0x192d1742, 0x14281309, 0x031e2036, + 0xfea179b7, 0x942af3f8, 0xff84b2a2, 0xfe1b00ff, 0x059506af, 0x032602ec, 0x0000009a, 0x01b20307, 0xff000005, 0xfe1400ff, 0x82ed83f4, 0x849b2017, + 0x00b32217, 0x291784ac, 0x0577fe73, 0x02f005f8, 0x094b0006, 0xfe6c2605, 0x04430464, 0x200f827c, 0x201f8454, 0x2244825c, 0x82d1058d, 0x843a200f, + 0x0056260f, 0x04360600, 0x200f825d, 0x0847825a, 0xb900012e, 0x1b05e6ff, 0x3a00f005, 0x23404200, 0x15301835, 0x0a0a181b, 0x25031b18, 0x00001514, + 0x2514243c, 0x18331735, 0x341e1118, 0x1125022b, 0x2705f447, 0x12ed3f2f, 0x39ed2f39, 0x2805a249, 0x391711ed, 0xed2f2f2f, 0x06674411, 0x2e222330, + 0x33352702, 0x3233031e, 0x26343536, 0x06853523, 0x020e2226, 0x11231115, 0x08065444, 0x0e1415aa, 0x1e150702, 0x481b0503, 0x1871b883, 0x22393430, + 0x36371f0d, 0x7f89223a, 0x97a0c9cf, 0x76489b8f, 0x49c62f56, 0x697fc88b, 0x1f4982b2, 0x48304f38, 0x012b5173, 0x70b583c0, 0x0b070332, 0x160fc907, + 0x8d9d070f, 0x729c8b8e, 0x1c74757d, 0xfb5f7b48, 0x771804f7, 0x2f3b75b1, 0x3b5f8d5e, 0x14394c61, 0x5c3f1309, 0xffff007b, 0x6d0486fb, 0x0b0850ff, + 0x0d000700, 0xf701dffa, 0x73000200, 0x5d05e5ff, 0x1a00ec05, 0x29002f00, 0x12151540, 0x2014142a, 0x12150715, 0x11341b03, 0x3425020c, 0x000a0016, + 0x3fed323f, 0x2f3fed33, 0x2f3be582, 0x313232ed, 0x2e220530, 0x12343504, 0x32332436, 0x3517021e, 0x35231133, 0x8303030e, 0x067e4ad7, 0x1137cd08, + 0xfc02032e, 0x7890a456, 0xae583057, 0x40ad0501, 0x224b5768, 0x5931c6c6, 0x77146d5f, 0x4d417db7, 0x4563b084, 0x294a5466, 0x62544c29, 0x7d552b1b, + 0xa979cca6, 0x7bd72401, 0x1a2d2112, 0x662ffa5f, 0x0e1f3123, 0xa2595e05, 0xdd9289e2, 0x1f114a94, 0xce031a2c, 0x101c291a, 0x3d000100, 0x54050000, + 0x16007804, 0x10402300, 0x08111100, 0x08091415, 0x540e1316, 0x05140405, 0xed3f3f00, 0x2f01332f, 0x12332f33, 0x31331139, 0x033e0130, 0x17163233, + 0x23032e23, 0x01070622, 0x01330123, 0x3e1e3a03, 0x72355749, 0x029b0671, 0x151d1209, 0xfe2a422c, 0x3ffebde9, 0x035a01cc, 0x4d77533d, 0x127d7b24, + 0x6e0e1821, 0x0407fd72, 0x0087fc5d, 0x34087382, 0x0800005c, 0x00eb059b, 0x404e001a, 0x110f0027, 0x18191a10, 0x17131412, 0x17121a0f, 0x0f1a1217, + 0x08091504, 0x15161c08, 0x03151218, 0x111a1417, 0x0205540c, 0x24898300, 0x333f332f, 0x208e8233, 0x22908311, 0x822f3917, 0x33112200, 0x89028733, + 0x0550439e, 0xa1849e82, 0x3c08a482, 0x30128b06, 0x6c3e5d45, 0x02a0077b, 0x352f2b24, 0xdcc2fe14, 0xcefedafe, 0xcb76feda, 0x34013901, 0x042d01c9, + 0x496b46cc, 0x2b8a7c25, 0xfb4b543c, 0xfbd40453, 0xfbd1052c, 0xfbd6042a, 0x28b1821e, 0x07000056, 0x00780428, 0x08b1831c, 0x011c0b29, 0x08090a00, + 0x07030402, 0x07020a1c, 0x1c0a0207, 0x13140504, 0x05061e13, 0x04105217, 0x05050208, 0x010a0407, 0x84332f00, 0xed3f21af, 0x2122b19a, 0xa3830323, + 0x33011324, 0x5b411313, 0x052f4706, 0x04073c08, 0xfef7adea, 0xdafeade3, 0x1701cdc4, 0x13a5f89b, 0x42593c29, 0x96047566, 0x19252502, 0x0d171d23, + 0xa3fc5d03, 0x9ffc5d04, 0x9bfc6103, 0x73414402, 0x82763256, 0x381f2f34, 0x82002d4b, 0xab3a08b1, 0xe7023503, 0x0900d105, 0x00b40e00, 0x03060101, + 0x01cd3f00, 0x3031cd2f, 0x07112301, 0x01330127, 0x18022707, 0x0106c99e, 0x1c01041c, 0x3503c906, 0x08304101, 0x7dfe8301, 0x3d8e3008, 0x03080923, + 0x213d8908, 0xaf821737, 0x17373e08, 0x18023311, 0xe4fe06c9, 0x06e4fe04, 0x90049ec9, 0x7dfe0830, 0x30088301, 0x02004101, 0xac03b200, 0xb2066e01, + 0x07000300, 0x00b71500, 0x01050304, 0x00030507, 0xceddd62f, 0xcd332f01, 0x37848232, 0x13032303, 0x01333523, 0x1c861a6e, 0x06ababb4, 0x010afeb2, + 0xb1fafcf6, 0x07233d90, 0x82020403, 0x0002233e, 0x3d89c42f, 0x26083982, 0x13331303, 0xabab6601, 0x1a861cb4, 0xfcb10106, 0xfef601fa, 0x00ffff0a, + 0x019401b2, 0x029a046e, 0x00ab0307, 0x82e8fd00, 0xfe4c37fa, 0xffca0359, 0x0006008d, 0x0400b40f, 0x00058004, 0x01cd1a2f, 0x8582c42f, 0x27232208, + 0x33132307, 0x9fa2ca03, 0xe3ce9e9f, 0xb9b959fe, 0xffff3401, 0x00005a01, 0x5d044902, 0x1d000602, 0x270a8200, 0x6a01c800, 0xae037a03, 0x1e2fcf84, + 0x07000e40, 0x54050601, 0x54010606, 0x8201020f, 0xed5d2298, 0x05234933, 0x56653320, 0x7a032509, 0xb2024efd, 0x032f0383, 0xbcfda00e, 0x000100a0, + 0x013d03a4, 0x82140682, 0xb50f2d45, 0x02032c00, 0x3f000103, 0xed2f01cd, 0x2a050d41, 0x72368201, 0xfd140636, 0x82d70229, 0x03a422c5, 0x822b83d1, + 0x820a2081, 0x02012681, 0x03affea4, 0x2909825f, 0xb5110003, 0x02034000, 0xc4850380, 0x31cd1a36, 0x23112130, 0xbb5f0311, 0x5101affe, 0x36020100, + 0xe402f4fe, 0x0230299a, 0xf4feaee4, 0x03000c01, 0x1efe7900, 0x0206f306, 0x202f0982, 0x44002400, 0x1a002040, 0x0a191901, 0x820a0412, 0x24222d01, + 0x010fef22, 0x0712070f, 0x07020119, 0x21330182, 0x2f002123, 0x3939122f, 0xd6102f2f, 0x103911cd, 0x87015dc6, 0x11c63f0f, 0xc6332f39, 0x25303132, + 0x01331523, 0x22232634, 0x33150706, 0x32333636, 0x06141516, 0x0d830607, 0x36357c08, 0x36363736, 0xeb030309, 0x3c01a3a3, 0xac4dacc7, 0x9a2d0838, + 0x337b6057, 0x3479262f, 0x2c75428f, 0x8ffe382e, 0x3d03c3fc, 0xa9263d03, 0xa7898f03, 0x1ca31622, 0x455b5836, 0x46242a58, 0x26b4f41e, 0x7b2f2d50, + 0xf20360fb, 0x0efcf203, 0x00020000, 0x04000036, 0x00d105e0, 0x000b0007, 0x052f404a, 0x0b060620, 0x03100300, 0x03900380, 0x030503a0, 0x0d0f0d03, + 0x08020d1f, 0x821f000f, 0x0004302d, 0x10010049, 0x01010201, 0x09490806, 0x46000603, 0x5d3a056d, 0x2f0132ed, 0x115d325d, 0x335d2f33, 0x31ed2f39, + 0x21351330, 0x23112115, 0x07820111, 0xaa043636, 0xfec00bfe, 0x04aa040b, 0xfba5a501, 0x010104ff, 0x00a5a52b, 0x01340083, 0x920c0000, 0x16020100, + 0x0900000c, 0x04008400, 0x9cffb400, 0xb6200582, 0x0a220582, 0x05842400, 0x05829020, 0x17820f20, 0x0f002e28, 0x2effb600, 0x17821000, 0x0582ce20, + 0xe2ff2c22, 0x2d200582, 0x10241d82, 0xecff3600, 0x37220b82, 0x05826aff, 0x83ff3921, 0x843a201d, 0xff3b2205, 0x221182b0, 0x8274ff3c, 0x843d2005, + 0x8444202f, 0xff592229, 0x201182d8, 0x200b845a, 0x2029845b, 0x2011845c, 0x2005845d, 0x20118490, 0x2a1d82a0, 0xff0f0011, 0x0011007e, 0x8260ff10, + 0xffb12205, 0x20058288, 0x200584b2, 0x208982b4, 0x228f8411, 0x82b2001d, 0x8224205f, 0x00ce2223, 0x20898224, 0x200582f6, 0x23238237, 0xff380024, + 0x39220b83, 0x1182c4ff, 0x24228f83, 0x8f823c00, 0x57002422, 0x24225982, 0x1d845800, 0x6b825920, 0x5a002422, 0x24229b82, 0x0b845c00, 0x0584b120, + 0x0584b220, 0x0584b320, 0x4d84b420, 0x0b84b520, 0x0b82b620, 0x95822520, 0x2500ec22, 0x0a20c182, 0x11200582, 0x25224d82, 0x65823700, 0xab002522, + 0xb1210b84, 0x20178300, 0x200582b2, 0x27958426, 0xffaf0026, 0x002600e7, 0x26205983, 0xce22ad82, 0x41822700, 0x11200583, 0x27205382, 0x0b833b82, + 0x3b823a20, 0x3b002722, 0x27209582, 0xec20a782, 0x3d202382, 0xab201184, 0x29282382, 0xd4fe0f00, 0x11002900, 0x1d200584, 0x29226b82, 0x05841e00, + 0x3c002228, 0x24002900, 0x05829cff, 0x1e003722, 0x44200582, 0x48200b84, 0x52203584, 0x90220584, 0x178292ff, 0x1784a020, 0x1184a120, 0x4784ab20, + 0x0b82b020, 0xa1822c20, 0x2c00e222, 0x05839b82, 0xe2ffb224, 0xdd842d00, 0x83002d21, 0x822d20d7, 0x82f62059, 0x82902011, 0x842d2095, 0x002e22dd, + 0x224d8210, 0x8232002e, 0x002e229b, 0x28838244, 0xff48002e, 0x002e00ba, 0x20058452, 0x24538258, 0xff59002e, 0x201182b0, 0x2011845a, 0x200b845c, + 0x202f8491, 0x202f84a0, 0x201784a1, 0x201184af, 0x200b84b0, 0x205384b1, 0x260582b2, 0xff0a002f, 0x822f0088, 0x82602065, 0x82262005, 0x002f2223, + 0x2205842a, 0x8264002d, 0x24778311, 0xff37002f, 0x200b8256, 0x202f8439, 0x23d7823a, 0xff3c002f, 0x59202f83, 0x5c201184, 0x64200584, 0x77833584, + 0x83002f21, 0x822f206b, 0x202383e3, 0x202984b2, 0x200584b4, 0x200582b6, 0x22ef8232, 0x823200e2, 0x200583ef, 0x22bf8237, 0x823b0032, 0x823220ef, + 0x82ec2053, 0x823d2017, 0x82322047, 0x00e226fb, 0xfe0f0033, 0x200582d4, 0x20058411, 0x24298224, 0x003c0033, 0x20118214, 0x200b8444, 0x20058448, + 0x20058452, 0x22d78290, 0x84a00033, 0x84a1200b, 0x84ab2005, 0x82b02035, 0x8434200b, 0x84342071, 0x84342071, 0x82352059, 0x009c22ef, 0x20d78235, + 0x200582c4, 0x2471823c, 0xff440035, 0x830b82d8, 0x00352153, 0x35225383, 0x17845800, 0xc9ff5c22, 0x59831782, 0x83003521, 0x00352359, 0x3583ffb0, + 0x83ffb121, 0x84b22041, 0x82b42005, 0x0035227d, 0x200582b6, 0x226b8236, 0x823600ec, 0x2005836b, 0x24418224, 0xff360036, 0x221182ea, 0x82e2ff59, + 0x845a2005, 0x845c2011, 0x8490200b, 0x82ab200b, 0x82372005, 0x00de22e9, 0x20958237, 0x2105826a, 0x0b83fe11, 0x38ff1d22, 0x1e200b82, 0x22200584, + 0x3724f782, 0x88ff2400, 0x26201182, 0x3722a782, 0x05842a00, 0xdd823220, 0x5f823720, 0x1782f420, 0x7d823720, 0xc5823720, 0x0b821020, 0x24ff4622, + 0x48200582, 0x4a220584, 0x0b822eff, 0x0b845220, 0x4d845520, 0x4cff5622, 0x58201182, 0x59200b84, 0x5a200584, 0x5c200584, 0x5d220584, 0x1d8256ff, + 0x5f846420, 0x7eff9022, 0x91200b82, 0xa0216584, 0x205983ff, 0x204784a1, 0x20a184ab, 0x201784af, 0x211184b0, 0xb983ffb1, 0x0582b220, 0x0f003822, + 0x3822d182, 0x05841100, 0xf6ff2425, 0x83003800, 0x003821e9, 0x3920e983, 0x3920e984, 0xce23e982, 0x83003900, 0x003924e9, 0x82b0ff1d, 0x841e200b, + 0xff242205, 0x220b82c4, 0x829cff44, 0x84482005, 0x84522005, 0x84582005, 0xff5c2217, 0x201782bf, 0x22e98290, 0x84a00039, 0x84a12017, 0x228f8305, + 0x84b00039, 0x82b1200b, 0x00392295, 0x200582b2, 0x206b843a, 0x206b843a, 0x228f823a, 0x843a0024, 0x003a216b, 0x3a226b83, 0x23842400, 0x3a216b83, + 0x216b8300, 0x6b83003a, 0x55003a24, 0x2982c4ff, 0x3a227183, 0x71825c00, 0x90003a22, 0x71831184, 0x83003a21, 0x823a2071, 0x204d83cb, 0x217182b0, + 0x7183003a, 0x71843a20, 0x6b823b20, 0x3b00b024, 0xf5822600, 0x2a003b22, 0x32200584, 0x44200584, 0x3b206b82, 0xc4206582, 0x52201d82, 0x3b244d82, + 0xe2ff5800, 0x5c200b82, 0x3b22f582, 0x23846400, 0x05849120, 0x2984a020, 0x2384a120, 0x1184af20, 0x0b84b020, 0x2984b120, 0x0582b220, 0xd7843c20, + 0x6b823c20, 0x3c007426, 0xdefe1100, 0x1d220582, 0x058238ff, 0x05841e20, 0x23842420, 0xecff3222, 0x44211182, 0x222383ff, 0x8288ff47, 0xff48220b, + 0x2005827e, 0x2005844a, 0x22b98250, 0x8451003c, 0x84522005, 0x84532011, 0x8454200b, 0x8455200b, 0xff56220b, 0x202f8292, 0x20058458, 0x20118459, + 0x20598490, 0x20598491, 0x205984a0, 0x202f84a1, 0x208384ab, 0x201784af, 0x201184b0, 0x201d84b1, 0x200582b2, 0x24a7823d, 0x003d00c4, 0x221d8226, + 0x842a003d, 0x229b8305, 0x823d003d, 0x003d22dd, 0x22ef8244, 0x8248003d, 0x003d22e3, 0x22058452, 0x82d8ff5a, 0xff5c222f, 0x200582bf, 0x832f8464, + 0x003d2271, 0x202984a0, 0x832384a1, 0x003d226b, 0x200b84b0, 0x201784b1, 0x2a0582b2, 0xff590044, 0x004400f0, 0x82f6ff5a, 0x825c2005, 0x0045280b, + 0x00e2ff0f, 0x82110045, 0x00452447, 0x82fbff5c, 0x82ab200b, 0x8246200b, 0x00ec2495, 0x82370046, 0x00462241, 0x201184b1, 0x200582b2, 0x24118248, + 0x00490074, 0x22f98205, 0x840a0049, 0x000c2205, 0x22118264, 0x8232000d, 0x820f2005, 0x824920dd, 0x82ce203b, 0xff11220b, 0x22058288, 0x826e0022, + 0x843f2005, 0x84402023, 0x825c2005, 0x0049227d, 0x200b8460, 0x832384ab, 0x004921a1, 0x4922a183, 0x4784b400, 0x0582b620, 0xad824b20, 0x4b00ec22, + 0x4b20ad84, 0xec229b82, 0x59824e00, 0x05829c20, 0x83ff4821, 0x8452200b, 0x84a12005, 0x84b02005, 0xffb12105, 0xb2201d83, 0x50200582, 0x50203b84, + 0x50203b84, 0x51203b84, 0x51201184, 0x51201184, 0x52201184, 0x5220fb84, 0x5220fb84, 0xf1241d82, 0x5b005200, 0x52204782, 0x0b831d82, 0x0b82ab20, + 0x23845320, 0x23845320, 0x17825320, 0x5300fb23, 0x26178300, 0xfe0f0055, 0x825500de, 0x82ec208f, 0x84112005, 0xff44220b, 0x220b82dc, 0x82d8ffa0, + 0x84ab2005, 0x82b12011, 0x82552041, 0x222383d7, 0x821e00b4, 0x82b62017, 0x82572005, 0x00d82235, 0x204d8257, 0x200582f6, 0x202f82b1, 0x83238257, + 0x00b42211, 0x20118214, 0x200582b6, 0x22778259, 0x8459004c, 0x82592029, 0x200b837d, 0x24298244, 0xff480059, 0x201782ee, 0x20058452, 0x201184a0, + 0x210b84a1, 0x2383ffab, 0xf1ffb022, 0x53831d82, 0x53845920, 0x47825a20, 0x5a00ba22, 0x5a20a784, 0x0b834782, 0x95824420, 0xa0005a22, 0xab210584, + 0x831183ff, 0x845a20a7, 0x825b20a7, 0x00ce2429, 0x8246005b, 0x005b241d, 0x82f6ff47, 0xff48220b, 0x200582e8, 0x200b844a, 0x200b8452, 0x201d846f, + 0x200b84a1, 0x210b84b0, 0x3583ffb1, 0x0582b220, 0x71825c20, 0x5c004222, 0x5c20b984, 0x0b837182, 0x5c20b983, 0xee205382, 0x47201782, 0x5c204782, + 0x5c21c584, 0x21538300, 0xcb83005c, 0x54005c22, 0x6f201784, 0x5c20cb82, 0xd8209b82, 0xd7832982, 0x83005c21, 0x005c21d7, 0x5c21d783, 0x20d78300, + 0x20d7845c, 0x20d1845d, 0x2253825d, 0x845d00f6, 0x825d20a7, 0x82f42053, 0x824a200b, 0x825d2047, 0x830b8353, 0x005d2253, 0x2111846f, 0x1183ffa1, + 0x5d20e983, 0x6420e984, 0x6426e984, 0xe7ffaf00, 0x59826400, 0x0582ce20, 0x6f20bf83, 0x6f205984, 0xec221182, 0x29846f00, 0xd1829120, 0x9100e222, + 0x0583cb82, 0xe3823720, 0x3b009122, 0x91225382, 0xfb823c00, 0x3d009122, 0xab240584, 0xa100e2ff, 0xa1202984, 0xec202982, 0x59220b82, 0x0582f1ff, + 0x1d825b20, 0x5c00a122, 0xab200b84, 0xab280b82, 0x2effb400, 0xb600ab00, 0xb1220582, 0x4d822400, 0x2c00b122, 0xb1283b82, 0x9cff2d00, 0x3600b100, + 0xb1242382, 0x6aff3700, 0x39200b82, 0x3a201d84, 0x3b220584, 0x1182b0ff, 0x74ff3c22, 0x3d200582, 0xb1227d82, 0x29844400, 0xd8ff5922, 0x5a201182, + 0x5b200b84, 0x5c202984, 0x5d201184, 0x90200584, 0xa0201184, 0xb2201d82, 0xb2206b84, 0xb2206b84, 0xb2206b84, 0xb2206b84, 0xb2216b84, 0x216b8300, + 0x6b8300b2, 0xdd82b220, 0xb200b022, 0x7420dd82, 0x6b830582, 0x6b84b220, 0x8300b221, 0x00b2216b, 0xb2216b83, 0x206b8300, 0x20d782b2, 0x832382d8, + 0x00b2216b, 0xb2216b83, 0x206b8300, 0x226b82b3, 0x82b3009c, 0x009c2411, 0x820f00b4, 0x00b422e9, 0x20058411, 0x24e38224, 0x003700b4, 0x2217826e, + 0x82640039, 0x003a2205, 0x2005823c, 0x2211843c, 0x82baff56, 0x0057220b, 0x20058228, 0x20298490, 0x203582ab, 0x204d84b5, 0x204d84b5, 0x204d84b6, + 0x204d84b6, 0x201784b6, 0x214d84b6, 0x4d8300b6, 0x8300b621, 0x82b6204d, 0x006e2351, 0x4d8300b6, 0x8300b621, 0x86b6204d, 0x204d833b, 0x22ef82c3, + 0x82c3002e, 0x200583ef, 0x2265823a, 0x823c00c3, 0x84c42065, 0x84c42017, 0x00c42117, 0xc4201783, 0x00201784, 0x2e240082, 0x01002e02, 0x02830782, + 0x04823220, 0x01240b85, 0x32000700, 0x02201786, 0x39200b82, 0x03200b86, 0x40201582, 0x04200b86, 0x0524238a, 0x5a000c00, 0x06201786, 0x0724178a, + 0x72003b00, 0x09241786, 0xad000e00, 0x0d240b86, 0xbb004c01, 0x0e300b86, 0x07022a00, 0x01000300, 0x02000304, 0x31020c00, 0x05200b84, 0x10220b82, + 0x0b843d02, 0x17840620, 0x0b844d20, 0x17840720, 0x0b845920, 0x0b840820, 0x0b846920, 0xbb820920, 0x79026422, 0x01240b86, 0xdd020e00, 0x02200b86, + 0xeb200b82, 0x03240b86, 0xf9026400, 0x04200b86, 0x0524238a, 0x2d031800, 0x06201786, 0x0724178a, 0x5d037600, 0x09241786, 0xd3031c00, 0x0d240b86, + 0xef039802, 0x0e240b86, 0x87065400, 0x0a200b84, 0x0b20bf8a, 0x10220b82, 0x1784db06, 0x178a0c20, 0x0b830e20, 0x8f850620, 0x0b821020, 0xf7060e22, + 0x13202384, 0x12220b82, 0x0b840507, 0x2f8a1420, 0x0b821520, 0x17071022, 0x16201784, 0x1920178a, 0x0e220b82, 0x17842707, 0x23841b20, 0x0b843520, + 0x238a1d20, 0x0b8a1f20, 0x2f842420, 0x23844520, 0x0b842d20, 0x0b835320, 0xb38a0820, 0x5f8a0820, 0x178a0c20, 0x850c0c21, 0xa93f0847, 0x31303220, + 0x694d2030, 0x736f7263, 0x2074666f, 0x70726f43, 0x7461726f, 0x2e6e6f69, 0x6c6c4120, 0x67695220, 0x20737468, 0x65736552, 0x64657672, 0x7265562e, + 0x616e6164, 0x75676552, 0x8872616c, 0x863a2038, 0x84288217, 0x200f8318, 0x26448273, 0x302e3520, 0x88282033, 0x87292027, 0x73693427, 0x74206120, + 0x65646172, 0x6b72616d, 0x20666f20, 0x8a656874, 0x72672488, 0x8370756f, 0x6f632c16, 0x6e61706d, 0x2e736569, 0x8274614d, 0x20773223, 0x74726143, + 0x6f597265, 0x616d2075, 0x73752079, 0x823a8265, 0x6f66334e, 0x6120746e, 0x65702073, 0x74696d72, 0x20646574, 0x54847962, 0x4c554527, 0x6f662041, + 0x2f0c8472, 0x646f7270, 0x20746375, 0x77206e69, 0x68636968, 0x43823b8a, 0x636e6925, 0x8264756c, 0x6f74273a, 0x73696420, 0x60826c70, 0x646e6126, + 0x69727020, 0x63205c82, 0x65246182, 0x202e746e, 0x6f2b7b87, 0x20796c6e, 0x20296928, 0x83626d65, 0x87682034, 0x865d8286, 0x8491942c, 0x6964302e, + 0x7220676e, 0x72747365, 0x69746369, 0x82736e6f, 0x827d8693, 0x8774203e, 0x203b214b, 0x28218083, 0x28658269, 0x706d6574, 0x7261726f, 0x27758269, + 0x6e776f64, 0x64616f6c, 0xb382bf8a, 0xa9856120, 0x20726522, 0x6f22ee82, 0x08836874, 0x7074752c, 0x64207475, 0x63697665, 0x23822065, 0x6c656823, + 0x2bd08e70, 0x70747468, 0x772f2f3a, 0x6d2e7777, 0x30070a42, 0x6d6f632e, 0x7079742f, 0x6172676f, 0x2f796870, 0x2dfc8266, 0x4e002f73, 0x72006f00, + 0x61006d00, 0x09826c00, 0x7900622c, 0x65000d01, 0x6e006a00, 0x0382e900, 0x53221b89, 0x23827400, 0x64006e22, 0x722a0582, 0x9a036400, 0xbd03b103, + 0x0382bf03, 0xba03b92e, 0xa900ac03, 0x32002000, 0x31003000, 0x20260382, 0x69004d00, 0x57826300, 0x73006f22, 0x66205582, 0x20223b82, 0x69844300, + 0x05847020, 0x11826120, 0x09826920, 0x2e006e22, 0x41203782, 0x6c207b82, 0x52200782, 0x67223582, 0x1b826800, 0x0d847320, 0x3d826520, 0x45826520, + 0x91827620, 0x29826420, 0x07825620, 0x87847b82, 0x52006122, 0x67220d82, 0x3b827500, 0x23826120, 0x3a217191, 0x202f8d00, 0x87318e20, 0x8273201f, + 0x826f2075, 0x002022eb, 0x22638235, 0x82330030, 0x9228207b, 0x902920c1, 0x8269204f, 0x8220209f, 0x8220208d, 0x827220b1, 0x82642007, 0x826d2091, + 0x00722207, 0x2243826b, 0x8266006f, 0x82742005, 0x826520cf, 0x229f9107, 0x82670020, 0x826f20b7, 0x887020c1, 0x0063262d, 0x006d006f, 0x20438270, + 0x8395826e, 0x822e20ff, 0x82612089, 0x2047855f, 0x20298277, 0x20618443, 0x226b8274, 0x82590072, 0x8275202f, 0x826d2013, 0x82792013, 0x82752007, + 0x836d8391, 0x209d852d, 0x20218266, 0x833f826e, 0x827320a7, 0x84702021, 0x826d2037, 0x8274205d, 0x00652215, 0x21138264, 0x3b830062, 0x20286185, + 0x55004500, 0x41004c00, 0x3b831782, 0xc38a7220, 0xaf847020, 0x75006424, 0x51846300, 0x6e006922, 0x77201d82, 0x6920e182, 0x68201182, 0x778f2986, + 0x2b830f85, 0x6c006322, 0x64203b82, 0x75838182, 0x99827420, 0x7f822020, 0x70201f83, 0x61201982, 0x61208584, 0x1d835382, 0x6b827020, 0x74203383, + 0x63205582, 0x6520c386, 0x74221b82, 0x11822e00, 0x6f20f78f, 0x6c201982, 0x28203f84, 0x2920d982, 0x65242182, 0x62006d00, 0x68206988, 0xfd831582, + 0x85090d41, 0x41598dbb, 0x5d892923, 0x59826420, 0x67006e22, 0x72207182, 0x73226d82, 0xb7847400, 0xdf426320, 0x91758308, 0x417d85fb, 0x3b2011a5, + 0x01414782, 0x21c98307, 0xcb830069, 0x59827420, 0x43006d21, 0x72230739, 0x85006900, 0x006424eb, 0x8477006f, 0x006f23f9, 0x53410061, 0x41e99105, + 0x61200567, 0x53415982, 0x82652009, 0x822020a5, 0x8272203d, 0x826f2015, 0x826820ab, 0x200b8561, 0x210d8275, 0x05830070, 0x51822020, 0x76006522, + 0x63206d82, 0x20201d82, 0x6f201782, 0x29832d82, 0x70006c22, 0x20214d8c, 0x0d474100, 0x68002e22, 0x74202d82, 0x3a222582, 0x01822f00, 0x83007721, + 0x002e2201, 0x1015446d, 0x39842e20, 0x23826d20, 0x79007422, 0x6720e184, 0x61209982, 0x68200982, 0x2f210f82, 0x07af4100, 0x21827320, 0x2009a944, + 0x20ff8261, 0x08b94469, 0x0d82e120, 0x6c201b89, 0xab44ab82, 0x8261200b, 0x4464204f, 0x6e2c0ce5, 0x1e047900, 0x4b043104, 0x3d044704, 0x39200582, + 0x6e20498c, 0x4e223f82, 0xf7826100, 0xff826120, 0x6f006e24, 0x41824100, 0x75007224, 0xd3826e00, 0x00006124, 0x00840002, 0x004cff23, 0x8e088478, + 0xb7032104, 0x01201082, 0x7a082582, 0x00040003, 0x00060005, 0x00080007, 0x000a0009, 0x000c000b, 0x000e000d, 0x0010000f, 0x00120011, 0x00140013, + 0x00160015, 0x00180017, 0x001a0019, 0x001c001b, 0x001e001d, 0x0020001f, 0x00220021, 0x00240023, 0x00260025, 0x00280027, 0x002a0029, 0x002c002b, + 0x002e002d, 0x0030002f, 0x00320031, 0x00340033, 0x00360035, 0x00380037, 0x003a0039, 0x003c003b, 0x003e003d, 0x8240003f, 0x004236b2, 0x00440043, + 0x00460045, 0x00480047, 0x004a0049, 0x004c004b, 0x08ea824d, 0x50004f22, 0x52005100, 0x54005300, 0x56005500, 0x58005700, 0x5a005900, 0x5c005b00, + 0x5e005d00, 0x60005f00, 0x6222fe82, 0xfe826300, 0x0065ae0e, 0x00670066, 0x00690068, 0x006b006a, 0x006d006c, 0x006f006e, 0x00710070, 0x00730072, + 0x00750074, 0x00770076, 0x00790078, 0x007b007a, 0x007d007c, 0x007f007e, 0x00810080, 0x00830082, 0x00850084, 0x00870086, 0x00890088, 0x008b008a, + 0x008d008c, 0x008f008e, 0x00910090, 0x00930092, 0x00950094, 0x00020196, 0x00990098, 0x0003019a, 0x009d009c, 0x0004019e, 0x00a100a0, 0x00a300a2, + 0x00a500a4, 0x01a700a6, 0x00a90005, 0x00ab00aa, 0x00ae00ad, 0x00b000af, 0x00b200b1, 0x00b400b3, 0x00b600b5, 0x00b800b7, 0x00ba00b9, 0x01bc00bb, + 0x00be0006, 0x010701bf, 0x01c20008, 0x00c40009, 0x00c600c5, 0x00c800c7, 0x00ca00c9, 0x00cc00cb, 0x00ce00cd, 0x00d000cf, 0x00d300d1, 0x00d500d4, + 0x00d700d6, 0x01d900d8, 0x00db000a, 0x00dd00dc, 0x00df00de, 0x00e100e0, 0x00e300e2, 0x00e500e4, 0x00e700e6, 0x00e900e8, 0x00eb00ea, 0x00ed00ec, + 0x00ef00ee, 0x010b01f0, 0x000d010c, 0x00f500f4, 0x00f700f6, 0x00f900f8, 0x00fb00fa, 0x00fd00fc, 0x01ff00fe, 0x00010100, 0x01c300da, 0x010f010e, + 0x01110110, 0x01130112, 0x01150114, 0x01170116, 0x01190118, 0x011b011a, 0x011d011c, 0x011f011e, 0x01210120, 0x01230122, 0x01250124, 0x01270126, + 0x01290128, 0x012b012a, 0x012d012c, 0x012f012e, 0x01310130, 0x01330132, 0x01350134, 0x01370136, 0x01390138, 0x013b013a, 0x013d013c, 0x013f013e, + 0x01410140, 0x01430142, 0x01450144, 0x01470146, 0x01490148, 0x014b014a, 0x014d014c, 0x014f014e, 0x01510150, 0x01530152, 0x01550154, 0x01570156, + 0x01590158, 0x015b015a, 0x015d015c, 0x015f015e, 0x01610160, 0x01630162, 0x01650164, 0x01670166, 0x01690168, 0x016b016a, 0x016d016c, 0x016f016e, + 0x01710170, 0x01730172, 0x01750174, 0x01770176, 0x01790178, 0x017b017a, 0x017d017c, 0x017f017e, 0x01810180, 0x01830182, 0x01850184, 0x01870186, + 0x01890188, 0x018b018a, 0x018d018c, 0x018f018e, 0x01910190, 0x01930192, 0x01950194, 0x01970196, 0x01990198, 0x019b019a, 0x019d019c, 0x019f019e, + 0x01a101a0, 0x01a301a2, 0x01a501a4, 0x01a701a6, 0x01a901a8, 0x01ab01aa, 0x01ad01ac, 0x01af01ae, 0x01b101b0, 0x01b301b2, 0x01a800b4, 0x01b601b5, + 0x01b801b7, 0x01ba01b9, 0x01bc01bb, 0x01be01bd, 0x01c001bf, 0x01c201c1, 0x01c401c3, 0x019f00c5, 0x01c701c6, 0x01c901c8, 0x01cb01ca, 0x01cd01cc, + 0x01cf01ce, 0x01d101d0, 0x01d301d2, 0x019700d4, 0x01d601d5, 0x01d801d7, 0x01da01d9, 0x01dc01db, 0x01de01dd, 0x01e001df, 0x01e201e1, 0x01e401e3, + 0x01e601e5, 0x01e801e7, 0x01ea01e9, 0x01ec01eb, 0x01ee01ed, 0x01f001ef, 0x01f201f1, 0x01f401f3, 0x01f601f5, 0x01f801f7, 0x01fa01f9, 0x01fc01fb, + 0x01fe01fd, 0x020002ff, 0x02020201, 0x02040203, 0x02060205, 0x02080207, 0x020a0209, 0x020c020b, 0x020e020d, 0x0210020f, 0x02120211, 0x02140213, + 0x02160215, 0x02180217, 0x021a0219, 0x021c021b, 0x021e021d, 0x0220021f, 0x02220221, 0x02240223, 0x02260225, 0x02280227, 0x022a0229, 0x022c022b, + 0x022e022d, 0x0230022f, 0x02320231, 0x02340233, 0x02360235, 0x02380237, 0x023a0239, 0x023c023b, 0x023e023d, 0x0240023f, 0x00420241, 0x0243029b, + 0x02450244, 0x02470246, 0x02490248, 0x024b024a, 0x024d024c, 0x024f024e, 0x02510250, 0x02530252, 0x02550254, 0x02570256, 0x02590258, 0x025b025a, + 0x025d025c, 0x025f025e, 0x02610260, 0x02630262, 0x02650264, 0x02670266, 0x02690268, 0x026b026a, 0x026d026c, 0x026f026e, 0x02710270, 0x02730272, + 0x02750274, 0x02770276, 0x02790278, 0x027b027a, 0x027d027c, 0x027f027e, 0x02810280, 0x02830282, 0x02850284, 0x02870286, 0x02890288, 0x028b028a, + 0x028d028c, 0x028f028e, 0x02910290, 0x02930292, 0x02950294, 0x02970296, 0x02990298, 0x029b029a, 0x029d029c, 0x029f029e, 0x02a102a0, 0x02a302a2, + 0x02a502a4, 0x02a702a6, 0x02a902a8, 0x02ab02aa, 0x02ad02ac, 0x02af02ae, 0x02b102b0, 0x02b302b2, 0x02b502b4, 0x02b702b6, 0x02b902b8, 0x02bb02ba, + 0x02bd02bc, 0x02bf02be, 0x02c102c0, 0x02c302c2, 0x02c502c4, 0x02c702c6, 0x02c902c8, 0x02cb02ca, 0x02cd02cc, 0x02cf02ce, 0x02d102d0, 0x02d302d2, + 0x02d502d4, 0x02d702d6, 0x02d902d8, 0x02db02da, 0x02dd02dc, 0x02df02de, 0x02e102e0, 0x02e302e2, 0x02e502e4, 0x02e702e6, 0x02e902e8, 0x02eb02ea, + 0x02ed02ec, 0x02ef02ee, 0x02f102f0, 0x02f302f2, 0x02f502f4, 0x02f702f6, 0x02f902f8, 0x02fb02fa, 0x02fd02fc, 0x03ff02fe, 0x03010300, 0x03030302, + 0x03050304, 0x03070306, 0x03090308, 0x030b030a, 0x030d030c, 0x030f030e, 0x03110310, 0x03130312, 0x03150314, 0x03170316, 0x03190318, 0x031b031a, + 0x031d031c, 0x031f031e, 0x03210320, 0x03230322, 0x03250324, 0x03270326, 0x03290328, 0x032b032a, 0x032d032c, 0x032f032e, 0x03310330, 0x03330332, + 0x03350334, 0x03370336, 0x03390338, 0x033b033a, 0x033d033c, 0x033f033e, 0x03410340, 0x03430342, 0x03450344, 0x03470346, 0x03490348, 0x034b034a, + 0x034d034c, 0x034f034e, 0x03510350, 0x03530352, 0x03550354, 0x03570356, 0x03590358, 0x035b035a, 0x035d035c, 0x035f035e, 0x03610360, 0x03630362, + 0x03650364, 0x03670366, 0x03690368, 0x036b036a, 0x036d036c, 0x036f036e, 0x03710370, 0x03730372, 0x03750374, 0x03770376, 0x03790378, 0x037b037a, + 0x037d037c, 0x037f037e, 0x03810380, 0x00830382, 0x038403bd, 0x03860385, 0x03880387, 0x038a0389, 0x038c038b, 0x038e038d, 0x0390038f, 0x03920391, + 0x03940393, 0x03960395, 0x03980397, 0x039a0399, 0x039c039b, 0x039e039d, 0x03a0039f, 0x03a203a1, 0x03a403a3, 0x03a603a5, 0x03a803a7, 0x03aa03a9, + 0x03ac03ab, 0x03ae03ad, 0x03b003af, 0x03b203b1, 0x03b403b3, 0x03b603b5, 0x03b803b7, 0x03ba03b9, 0x03bc03bb, 0x6e7507bd, 0x42303069, 0x69700335, + 0x230b8331, 0x36323132, 0x32270784, 0x45043630, 0x836f7275, 0x4246220c, 0x821c8430, 0x85322007, 0x3931211c, 0x32213884, 0x21078543, 0x07874230, + 0x50821f84, 0x41063329, 0x76657262, 0x84610665, 0x41072906, 0x6e6f676f, 0x61076b65, 0x06280785, 0x72616344, 0x64066e6f, 0x44270685, 0x616f7263, + 0x85450774, 0x6507211c, 0x06210785, 0x201d8545, 0x27068565, 0x7563614c, 0x6c066574, 0x4c200685, 0x6c201485, 0x04260684, 0x746f644c, 0x04826c04, + 0x854e0621, 0x856e201e, 0x844e2006, 0x6e06211e, 0x0d2f0684, 0x6e75684f, 0x75726167, 0x75616c6d, 0x8b6f0d74, 0x5206210d, 0x72203085, 0x52200685, + 0x06213084, 0x20068572, 0x20148553, 0x84068473, 0x363121f8, 0x3124e885, 0x54063336, 0x74202485, 0x05270684, 0x6e697255, 0x83750567, 0x550d2105, + 0x75206f8c, 0x5a206f8c, 0x06214c84, 0x2106847a, 0xba825a0a, 0x63636127, 0x0a746e65, 0x080a887a, 0x61470546, 0x05616d6d, 0x74656854, 0x68500361, + 0x6c610569, 0x05616870, 0x746c6564, 0x70650761, 0x6f6c6973, 0x6973056e, 0x03616d67, 0x03756174, 0x0d696870, 0x65646e75, 0x6f637372, 0x62646572, + 0x7865096c, 0x6d616c63, 0xb3830982, 0x37303227, 0x65700646, 0x084c8273, 0x4a490229, 0x0b6a6902, 0x6f70616e, 0x6f727473, 0x06656870, 0x756e696d, + 0x73066574, 0x6e6f6365, 0x66610964, 0x31366969, 0x87383432, 0x39382409, 0x82324806, 0x06332641, 0x35383148, 0x21068534, 0x0d843135, 0x0a333336, + 0x6e65706f, 0x6c6c7562, 0x41077465, 0x7263616d, 0x61076e6f, 0x0b2d0785, 0x72696343, 0x666d7563, 0x0b78656c, 0x210b8963, 0xe688430a, 0x88630a21, + 0x4507210a, 0x07213585, 0x28078565, 0x72624506, 0x06657665, 0x21068465, 0x2888450a, 0x88650a21, 0x470b210a, 0x0b215589, 0x210b8967, 0x2d89470a, + 0x0a886720, 0x2005bd41, 0x06bd4132, 0x0b333223, 0x21318948, 0x0b89680b, 0x62480426, 0x68047261, 0x06280482, 0x6c697449, 0x69066564, 0x07210684, + 0x21998549, 0x07856907, 0x84490621, 0x6906219a, 0x07210684, 0x05b94249, 0x85690721, 0x4a0b2107, 0x0b215189, 0x2a0b896a, 0x65634b08, 0x6c6c6964, + 0x866b0861, 0x6b0c2e08, 0x65657267, 0x6e616c6e, 0x08636964, 0x2115864c, 0x08876c08, 0x08874e20, 0x08866e20, 0x6e450329, 0x6e650367, 0x854f0767, + 0x6f072188, 0x06210785, 0x2189844f, 0x06846f06, 0x86520821, 0x7208212e, 0x0b210886, 0x21868953, 0x0b89730b, 0x82540421, 0x740421eb, 0x06210482, + 0x21e98455, 0x06847506, 0x85550721, 0x75072157, 0x06210785, 0x21588455, 0x06847506, 0x85550721, 0x750721e8, 0x0b210785, 0x21518957, 0x0b8a770b, + 0x0b8a5920, 0x0b897920, 0x6f6c052b, 0x0a73676e, 0x6e697241, 0x05094367, 0x0a886120, 0x45410722, 0x07221284, 0x07846561, 0x734f0b26, 0x6873616c, + 0x6f200b85, 0x09320b89, 0x746f6e61, 0x69656c65, 0x67570661, 0x65766172, 0x06857706, 0x2a845720, 0x84770621, 0x57092b06, 0x72656964, 0x73697365, + 0x09877709, 0x85590621, 0x84792028, 0x710d2206, 0x27478275, 0x65766572, 0x64657372, 0x3f053243, 0x6c044533, 0x09617269, 0x69747365, 0x6574616d, + 0x6e6f0964, 0x67696565, 0x0c687468, 0x65726874, 0x73240b86, 0x7669660b, 0x0c210b87, 0x20428273, 0x2024856e, 0x23468373, 0x34303046, 0x35270786, + 0x6e6f7405, 0x870d736f, 0x250d8481, 0x706c410a, 0x0a846168, 0x43450c21, 0x0c8405d6, 0x74450822, 0x09221585, 0x09866f49, 0x6d4f0c27, 0x6f726369, + 0x211f846e, 0x2c8a550c, 0x6d4f0a24, 0x2e856765, 0x82691121, 0x20618c2e, 0x25618405, 0x74654204, 0x61860761, 0x825a0421, 0x8203200c, 0x83042061, + 0x4b05365c, 0x61707061, 0x6d614c06, 0x02616462, 0x4e02754d, 0x69580275, 0x316d8607, 0x03695002, 0x056f6852, 0x6d676953, 0x61540361, 0x79860775, + 0x68430328, 0x73500369, 0x43830c69, 0x0f207187, 0x0f871c86, 0x89610a21, 0x06b544de, 0x8082de85, 0x09200884, 0x0984af83, 0x85751421, 0x21bc8cd1, + 0x28826204, 0x61670527, 0x04616d6d, 0x200a827a, 0x22038203, 0x82687405, 0x83042005, 0x6b052138, 0x6c20ba84, 0x6e26ba85, 0x69780275, 0x25416f07, + 0x72032505, 0x73066f68, 0x3121b483, 0x21598607, 0xb1826303, 0x05266482, 0x67656d6f, 0x29410c61, 0x8e0f200b, 0x860c207c, 0x20998445, 0x841c860c, + 0x840a200c, 0x290a843c, 0x69666109, 0x30303169, 0x09873332, 0x88313521, 0x88322009, 0x201d8909, 0x20138834, 0x20098835, 0x20098836, 0x45098837, + 0x5982057a, 0x87393521, 0x30362113, 0x63880988, 0x63873620, 0x88343121, 0x8831204f, 0x88312045, 0x88312045, 0x88322045, 0x88322045, 0x88322045, + 0x883220a9, 0x8832209f, 0x8832204f, 0x8832209f, 0x88322059, 0x88322059, 0x88332059, 0x88332059, 0x88332059, 0x41332059, 0x33200803, 0x33206388, + 0x33206388, 0x33206388, 0x33206388, 0x33206388, 0x34206388, 0x34206388, 0x34206388, 0x34206388, 0x34206388, 0x17416388, 0x88342009, 0x88342063, + 0x06e24663, 0x30303123, 0x20638834, 0x20958836, 0x20318836, 0x20318836, 0x20958836, 0x20318836, 0x20958837, 0x208b8837, 0x208b8837, 0x208b8837, + 0x20598837, 0x20598837, 0x20598837, 0x20598837, 0x20598837, 0x20598838, 0x20ef8838, 0x20638838, 0x20638838, 0x20638838, 0x20638838, 0x20638838, + 0x20638838, 0x20638838, 0x20638838, 0x20638839, 0x20638839, 0x20638839, 0x20638839, 0x20638839, 0x20638839, 0x20638839, 0x20638839, 0x87458937, + 0x30312163, 0x31216387, 0x211d8730, 0xbb423031, 0x87302008, 0x30312163, 0x31216387, 0x21638730, 0x63873031, 0x87303121, 0x30312163, 0x3121c787, + 0x20638830, 0x89638831, 0x893520b3, 0x223185db, 0x86323030, 0x31362c3b, 0x09323533, 0x70796c67, 0x82352068, 0x210987b3, 0x09840832, 0x33373522, + 0x21050346, 0x07863437, 0x07863520, 0x07863720, 0x28873820, 0x39200888, 0x38211186, 0x28088730, 0x684f0531, 0x056e726f, 0x2005846f, 0x20058455, + 0x36058375, 0x6f6f680d, 0x6f62616b, 0x6f636576, 0x640c626d, 0x6562746f, 0x83776f6c, 0x6709230c, 0x16856172, 0x63610924, 0x20847475, 0x39204f86, + 0x39215887, 0x87118731, 0x333921ae, 0x34201187, 0x35200887, 0x36200887, 0x37200887, 0xb2870887, 0xb2863920, 0x30303622, 0x36221a85, 0x08873130, + 0x36215986, 0x20598630, 0x05c64636, 0x41453127, 0x6e750730, 0x20078269, 0x20078631, 0x20078632, 0x20078633, 0x20078634, 0x20078635, 0x20078636, + 0x20078637, 0x20078638, 0x20078639, 0x20078641, 0x20078642, 0x20078643, 0x20078644, 0x20078645, 0x21078546, 0x07863042, 0x07863120, 0x42207f86, + 0x42207f86, 0x42207f86, 0x42207f86, 0x42207f86, 0x42207f86, 0x42207f86, 0x42207f86, 0x42207f86, 0x42207f86, 0x42207f86, 0x42207f86, 0x42207f86, + 0x43217f86, 0x21778530, 0x07863143, 0x43207f86, 0x43207f86, 0x43207f86, 0x43207f86, 0x43207f86, 0x43207f86, 0x3d4d7f86, 0x45312205, 0x207f8643, + 0x227f8443, 0x84383130, 0x32302267, 0x229f8435, 0x84393430, 0x8407825f, 0x8407825f, 0x8407824f, 0x8407824f, 0x8507823f, 0x3934213f, 0x0f82bf84, + 0x3022bf84, 0x3f864134, 0x3f864120, 0xcf844120, 0x67851782, 0x4f413420, 0x34302305, 0xcf833142, 0x2f860782, 0x82054f41, 0x82af840f, 0x418f8607, + 0x0f82052f, 0x44206f86, 0x23055a43, 0x34383031, 0x45209986, 0x45203186, 0x35223185, 0x59843436, 0x3038352d, 0x6769660a, 0x64657275, 0x43687361, + 0x31200546, 0x32228484, 0x22843330, 0x41303231, 0x6f630d30, 0x6d6e6f6c, 0x74656e6f, 0x85797261, 0x82c28525, 0x8635201d, 0x8268840f, 0x8268840f, + 0x05054407, 0x36373523, 0x84198733, 0x841982fc, 0x860782ec, 0x2fec8567, 0x31423032, 0x7571650b, 0x6c617669, 0x65636e65, 0x30225583, 0x23843345, + 0x3645463c, 0x65720439, 0x73046873, 0x036e6968, 0x09766174, 0x62756f64, 0x6176656c, 0x03820676, 0x646f7922, 0x09821086, 0x65670622, 0x09202a83, + 0x73370682, 0x69796168, 0x656e0d6d, 0x65687377, 0x736c6571, 0x0a6e6769, 0x83766176, 0x6f642b45, 0x69660d74, 0x6b6c616e, 0x1d826661, 0x0e617622, + 0x712d0d87, 0x74616d61, 0x616c0a73, 0x6864656d, 0x2006826f, 0x220a8910, 0x82676164, 0x61072386, 0x5982746c, 0x830b6e21, 0x204c8648, 0x210b840a, + 0x57826e69, 0x12841120, 0x09842984, 0x10746f22, 0x2284118a, 0xe4820920, 0x61706626, 0x0a686174, 0x72850983, 0x6d281484, 0x71697061, 0x74656209, + 0x0b256a85, 0x656d6967, 0x220b866c, 0x876c6164, 0x68082217, 0x20148565, 0x85cf8209, 0x7a0b2109, 0x0b859383, 0x87740921, 0x79092328, 0x1385646f, + 0x0e85e088, 0xf8820920, 0x0b200985, 0x0b85df84, 0x656d0923, 0x2209866d, 0x856e756e, 0x730c2609, 0x6b656d61, 0x410c8568, 0x70200534, 0x08207d86, + 0x0b250887, 0x64617374, 0x23228569, 0x666f7109, 0x0a230985, 0x86736572, 0x410a2037, 0x08230902, 0x84766174, 0x7608251f, 0x6f687661, 0x07207d82, + 0x7227ef82, 0x07656661, 0x8366616b, 0x70062207, 0x20068365, 0x20ef8209, 0x339c8466, 0x72657a12, 0x6469776f, 0x6f6e6874, 0x696f6a6e, 0x0f72656e, + 0x0f861288, 0x66656c2f, 0x726f7474, 0x74686769, 0x6b72616d, 0x2109840f, 0x16836f74, 0x09280f83, 0x69696661, 0x38333735, 0x22051b43, 0x46343735, + 0x098306e4, 0x8305c646, 0x07b64209, 0x46343421, 0x138205a8, 0x8306404a, 0x05204709, 0x20470983, 0x47098305, 0x09830520, 0x83052047, 0x05204709, + 0x59880983, 0x77873520, 0xca473320, 0x478b8206, 0x09830616, 0x33204587, 0x8306ca47, 0x20458713, 0x06ca4733, 0x45891383, 0xca47a988, 0x20bd8306, + 0x87e58831, 0x36342109, 0x36220985, 0x32493133, 0x87d18306, 0x4935203b, 0x352206a0, 0x044a3537, 0x481d8206, 0x36220656, 0x1d863832, 0x9f850983, + 0xe5850983, 0x32343622, 0x83062141, 0x21638709, 0xc7883539, 0x2b413820, 0x861d8305, 0x38322209, 0x82278538, 0x0656486d, 0xb449d182, 0x49098206, + 0x098306b4, 0xbe49c788, 0x41138306, 0x33200771, 0x2206be49, 0x49333735, 0x098206be, 0x22062849, 0x48343735, 0x098206ec, 0x22069e4b, 0x41323235, + 0x3520087b, 0x2206ba48, 0x86393236, 0x41098313, 0x13820667, 0x2007ad41, 0x06ec4835, 0x3820ef82, 0x83052b41, 0x831d8509, 0x07854109, 0x00493520, + 0x41458206, 0x45820767, 0x39203187, 0x37218187, 0x07e24835, 0x4c393221, 0x35220620, 0x8f413537, 0x413b8306, 0x32210635, 0x20778633, 0x86098235, + 0x893b8295, 0x2081874f, 0x06124b39, 0x27883b83, 0x99413520, 0x203b8205, 0x234f8536, 0x35373336, 0x83053541, 0x86138909, 0x3733224f, 0x421d8836, + 0xdb820675, 0x22064941, 0x89383336, 0x06f84bb3, 0xd2491382, 0x20778206, 0x07d54134, 0xbc4b3920, 0x871d8306, 0x4d38204f, 0x1382067e, 0x8206c04c, + 0x06704c09, 0x0c4c0982, 0x426d8206, 0x32220725, 0x3b863838, 0x6b420982, 0x85382008, 0x202783d1, 0x05894836, 0x86434321, 0x86442007, 0x86452007, + 0x85462007, 0x30442107, 0x31200786, 0x32200786, 0x33200786, 0x34200786, 0x35200786, 0x57860786, 0x86374421, 0x8638200f, 0x86392007, 0x86412007, + 0x86422007, 0x207f8607, 0x207f8644, 0x207f8644, 0x217f8644, 0x27853045, 0x86314521, 0x207f8607, 0x207f8645, 0x207f8645, 0x207f8645, 0x207f8645, + 0x477f8645, 0x312105a7, 0x05a74745, 0x7f860782, 0x7f864520, 0x7f864520, 0x7f864520, 0x7f864520, 0x7f864520, 0x7f864620, 0x344a4620, 0x38382106, + 0x2106344a, 0x81863838, 0x81864620, 0x81864620, 0x81864620, 0x81864620, 0x01414620, 0x39463006, 0x6e6f6404, 0x69740967, 0x6365646c, 0x83626d6f, + 0x313222d0, 0x22608432, 0x87303532, 0x82e08407, 0x2298840f, 0x86313532, 0x84312017, 0x2c0f8266, 0x756d0b38, 0x61636973, 0x746f6e6c, 0x21438465, + 0x33854230, 0xce483020, 0x30322105, 0x82051e4a, 0x0c352207, 0x29698253, 0x6361616d, 0x746e6563, 0x0c8a730c, 0x30233983, 0x86413132, 0x0c422e07, + 0x74746f64, 0x61696465, 0x65747563, 0x22288f0b, 0x84443034, 0x35342128, 0x33210785, 0x22fd8433, 0x84343330, 0x343022e5, 0x82e58437, 0x85392007, + 0x84372027, 0x850f82be, 0x3834212f, 0x41202786, 0x41202786, 0x894a2786, 0x34302105, 0x8205894a, 0x85452007, 0x05894a3f, 0x86353021, 0x313522a0, + 0x21178442, 0x57853135, 0x84313521, 0x45312257, 0x212f8439, 0xa7413032, 0x43322205, 0x23178436, 0x31374332, 0x07822f83, 0x20051a41, 0x05eb4c43, + 0x85374121, 0x84078247, 0x84078247, 0x8407822f, 0x20078247, 0x22378346, 0x84383741, 0x840782a7, 0x200782a7, 0x84178641, 0x330f8287, 0x62411043, + 0x7361686b, 0x7365645f, 0x646e6563, 0x61107265, 0x8184108e, 0x84323021, 0x46462251, 0x24698446, 0x38423032, 0x2e008200, 0x00080003, 0x00100002, + 0x00ffff01, 0x82010003, 0x820c2011, 0x82162003, 0x83022003, 0xb603210d, 0x04200582, 0x19830d82, 0x01000022, 0x0a2a0982, 0x36003400, 0x616c0100, + 0x3b826e74, 0x02001032, 0x2048544c, 0x4f521600, 0x1c00204d, 0xffff0000, 0x058c2382, 0x37850f82, 0x52003822, 0x1e203796, 0x6984378a, 0x00ffff23, + 0x26018201, 0x636f6c02, 0x840e006c, 0x84142005, 0x831d8347, 0x00022403, 0x840e0006, 0x8301208f, 0x221b84bd, 0x82020026, 0x59042013, 0x0d8207d3, + 0xf9000224, 0xb682fa00, 0x20011f22, 0x08240d84, 0x8d030100, 0x74205984, 0x63833184, 0x00231e82, 0x82661700, 0x8261830f, 0x5e173406, 0x5a178230, + 0x862a0906, 0x0df78648, 0xa0020701, 0x824b1782, 0x47240812, 0x31010102, 0x0609300b, 0x030e2b05, 0x00051a02, 0x0a066130, 0x0401062b, 0x02378201, + 0x53a00401, 0x2c305130, 0x1c26118a, 0x1c801ea2, 0x01843c00, 0x62004f2c, 0x6f007300, 0x65006c00, 0x03827400, 0x82003e21, 0x21302101, 0x32084c8a, + 0xd3c81404, 0x0b2d60ba, 0x9efe9907, 0xe8e2e0ab, 0x967c40a4, 0x82a0ef2e, 0x82303112, 0x82306004, 0x03a04c03, 0x02020102, 0x11ab2e0a, 0x5cff50dc, + 0x87c0cb9d, 0x821d203d, 0x31703d8a, 0x0629302b, 0x0b045503, 0x6f432213, 0x69727970, 0x20746867, 0x20296328, 0x37393931, 0x240e6869, 0x301e312e, + 0x202c851c, 0x14826915, 0x30213123, 0x221f831f, 0x89181303, 0x6f52361f, 0x4120746f, 0x6f687475, 0x79746972, 0x0d171e30, 0x38303730, 0x28008232, + 0x32303133, 0x310d175a, 0x200e8232, 0x27148235, 0x5a303030, 0x0b317930, 0x9182a082, 0x02130628, 0x13315355, 0x51831130, 0x0a130830, 0x68736157, + 0x74676e69, 0x10316e6f, 0x14830e30, 0x07130729, 0x6d646552, 0x87646e6f, 0x130a2198, 0x23229896, 0x98852130, 0x98891a20, 0x646f4328, 0x69532065, + 0x55826e67, 0x43502029, 0x01823041, 0x410d3022, 0x012808c0, 0x03000501, 0x000f0182, 0x28091782, 0x0182020a, 0x79b70001, 0xb35dd67d, 0x34a83945, + 0xf9da31ac, 0x77493525, 0x9e1ffbc0, 0xef7145c7, 0xd4e846d1, 0x4c6bc38c, 0x99f46252, 0xd84dc302, 0x242f6c49, 0xcebf653e, 0x480bb723, 0xdd757fb7, + 0x8faabd45, 0x25c5500e, 0xe7a0f22b, 0xd11f230d, 0x62fa2441, 0x4519cf99, 0x1f4a93a5, 0x2fb3cd99, 0x2d4ac322, 0x15d96f7c, 0x398c3b1e, 0xbddd3910, + 0x3b66f429, 0xff32012d, 0xa64827fe, 0x87016cb5, 0xb2bafb9c, 0xf9827f63, 0x8481a05c, 0xf2b08e85, 0xcfa394b8, 0x8550a638, 0x4e872717, 0x00f630dd, + 0xf9c6f43d, 0x86be813d, 0xa7396ced, 0xb4f6342e, 0x7d0aaf2e, 0x66789162, 0x0d73989c, 0xc4f2af86, 0x4fb920f3, 0xcb638d12, 0x4532d92c, 0x4abbee19, + 0x53503b96, 0x5166ce18, 0x87adaa79, 0x9f3e56c8, 0x6e885082, 0xc135b105, 0x52bd247b, 0x4e993d66, 0x337e2bcc, 0x0647846e, 0x4ad09ed1, 0x866e0286, + 0x87c0a400, 0x030253df, 0xa3010001, 0x8130fa81, 0x061330f7, 0x251d5503, 0x0a300c04, 0x062b0806, 0x07050501, 0x81300303, 0x3b1583a2, 0x9a810401, + 0x80978130, 0x70d05b10, 0x9e7269ef, 0x147e5123, 0xff8e4db2, 0x3072a1cb, 0x32706f42, 0xc1000f82, 0x3c3c8b00, 0x3ed11188, 0xdfec63f6, 0x830f3040, + 0x011327a3, 0x0504ff01, 0x06820330, 0x831d3021, 0x040e3a10, 0xcc140416, 0x0076ce1d, 0xf1af5b70, 0x9a4ec4da, 0xa32e4451, 0x30f06344, 0x261e830b, + 0x0304040f, 0x43860102, 0x0c090a3a, 0x01018203, 0xaeab7b00, 0xf2264a7e, 0x744ebcce, 0x742758a2, 0x86b3752a, 0x944cabfd, 0xe94d0078, 0xdc18ebca, + 0xa20ec569, 0x4302f37c, 0xcc87cac6, 0xc2cc53f8, 0x6f56bd9f, 0xa94463f0, 0x96ee0044, 0x1cd59ac8, 0x199f0bb8, 0xdad7940d, 0x7d29ad1e, 0x73a6edef, + 0x39de8fac, 0x6a983d8e, 0xd26d38bc, 0xfd23af88, 0x69d6e9df, 0xbd889109, 0xbb00e1fe, 0x7cf7f334, 0x2e1210f9, 0x9629eb05, 0x286b4293, 0x8f38b771, + 0xc90d07e0, 0xbdcd685d, 0x666b4180, 0xbbb7bba8, 0xf2ca348e, 0x7a7c1003, 0x42e0d2f5, 0xe1fe7bdf, 0xf6feace1, 0xb30dd5df, 0xe392d670, 0xa238b64f, + 0x3dd42d7c, 0x620b34db, 0x819f0237, 0xf689236a, 0xb08f635c, 0xd739bb5a, 0x84558c60, 0x3bf5331a, 0x0c82a098, 0xb38b5fa2, 0xa5a1b72c, 0x20daabcb, + 0x1930bfb6, 0x0d142085, 0xf452bc2a, 0x305ee041, 0x692892e3, 0xe270c187, 0xceaba7f3, 0x76724280, 0x0482300e, 0x0382307a, 0x06634462, 0xcf016124, + 0x0083003e, 0x47430f20, 0x0505220b, 0x7bd54300, 0x0d171e35, 0x32313930, 0x32323730, 0x39323034, 0x310d175a, 0x88333031, 0x8130220e, 0x54714483, + 0x0b300d22, 0x24052a45, 0x504f4d04, 0x07a04452, 0xa0440320, 0x207b4416, 0x30bdff08, 0x7245fb89, 0x9e6b53a8, 0x23004f89, 0x1dd4bec0, 0x4059b13d, + 0x9173f338, 0x96e62682, 0xd9530012, 0x3c0e821c, 0xbdbb1dce, 0x978d42f7, 0x1a38fcd4, 0xe3f9b9e4, 0x0361d3ec, 0xd6d3a0bf, 0x465c4d75, 0xf05eeda9, + 0x5b69e2d2, 0xb3ea731a, 0xcd048d1c, 0x64a04429, 0x981e2f59, 0xabc76e5d, 0x65823918, 0xabbca7c4, 0xea198875, 0x26149787, 0x76267fb3, 0x3938d4a4, + 0x26b3e384, 0x2bf918d5, 0x16c9d2e9, 0xf221545a, 0x86878d97, 0x49f4fe29, 0xf88be62c, 0xcd7d3f04, 0x869296cd, 0xe203710d, 0x420cfed0, 0xb8d7ff35, + 0x458edd3f, 0xd7f67d0a, 0xf05bad4b, 0x771d7276, 0x35897d23, 0xb25d1cc4, 0x474b0350, 0x55a7076d, 0x80069888, 0x54ad81a6, 0xd681d84e, 0xc042bffa, + 0x0d55be31, 0x4953d599, 0xe5eb3012, 0x5e7c88a5, 0x145a7ac4, 0x37b40887, 0x32eba069, 0xeb088c24, 0xba14d4f9, 0xeacdfce0, 0x7b4415a4, 0x30f82306, + 0x7b44f581, 0x09c54315, 0x78382508, 0x1bc87305, 0x925f9b32, 0x89af5586, 0xb199c6ba, 0x0e308e74, 0x1d550306, 0xff01010f, 0x02030404, 0x1f308007, + 0x23250f83, 0x16301804, 0x15f64380, 0x20834420, 0x3d041f2c, 0x39303b30, 0x35a037a0, 0x756e3386, 0x72632206, 0x0e756e6c, 0x696b7023, 0x2015822f, + 0x06ab6f2f, 0x432f7327, 0x41435053, 0x2112822e, 0x1d454830, 0x01012707, 0x3a303c04, 0x0f873830, 0x86023023, 0x18c66e2c, 0x65225084, 0x49897472, + 0x50437420, 0x030c090e, 0x00010182, 0xab830328, 0xfef10d13, 0x76426f11, 0xb8ab43d8, 0x24fa42c6, 0x75ae3465, 0x8e3071b0, 0xfa83b696, 0xcdfee472, + 0x703ae737, 0x0e205198, 0xc9b471ba, 0x8ae4d5f4, 0x737028e8, 0xc2e1edd5, 0x56f1ee7b, 0x82805a34, 0x72d710eb, 0x4e12ea03, 0x8c0dddec, 0x0c4f447b, + 0x6efd7561, 0xcedd079c, 0x0d185a2b, 0xfd60b039, 0xaa04ffda, 0xfad8a302, 0xbdbba38e, 0x3b546ac1, 0x2ce45f31, 0x4df1cb6e, 0x1ef21c2a, 0xaf867b76, + 0xb1d687c6, 0xccaced2a, 0x9fe4c00e, 0xe8cfe87f, 0x82547284, 0xc82a6e18, 0x1ab4959e, 0x936fc11e, 0xc1a662db, 0xc9ad6b4b, 0xe3923ded, 0x7aab2fb2, + 0x6a673977, 0x9d827b00, 0x63de1003, 0x42264995, 0xc12295de, 0x14d00b87, 0x73dc5fa3, 0x1e367232, 0xc529c8ff, 0x664f5224, 0x1d1dc948, 0x3926c5a9, + 0xa74e5069, 0x6c06c2ec, 0xf11b722e, 0x246dda21, 0x15818048, 0xcc9f7c40, 0x4f4a3874, 0x9d048230, 0x85038230, 0x30057d44, 0x990b6a10, 0x2500c04f, + 0x45db11ab, 0x677a581f, 0x0e3241a2, 0x34717b46, 0x0d171e30, 0x39303630, 0x31303631, 0x37343430, 0x310d175a, 0x480e8239, 0x542872eb, 0x73656d69, + 0x706d6174, 0x0827eb48, 0x6e37dcff, 0x42c8affb, 0xc818714a, 0x533e48ce, 0x14abfac0, 0xbb322cba, 0xc8524f12, 0x333eed83, 0x923149d9, 0x6491b628, + 0x84501fe0, 0xd14bc2ba, 0xeff8057f, 0xc78bbe75, 0x69aed5a8, 0x27786670, 0xb7b6e866, 0xcdb985ef, 0x12fdaaee, 0x22590ba4, 0x40cf2f29, 0x1b0456d9, + 0x646db576, 0xdb544a6d, 0xbfdef1dd, 0x80c7839f, 0x024c7fdf, 0xc0f59437, 0x1e56089e, 0xd9cd4768, 0x2f5c76c0, 0x0425b67d, 0x6a5b56b4, 0x80ff631c, + 0xd5ee3c7c, 0x394d2504, 0x5d077477, 0x86d85cc2, 0xc9752c37, 0x391eea0e, 0xfe767c09, 0x7a6e6c9d, 0x8f3eece0, 0x0e719e97, 0x184f2a5f, 0x9e326062, + 0x2b4e83d2, 0x45685c22, 0x842fde8b, 0xf9b25010, 0x6c8d1ab5, 0x139b25ee, 0xd710cbf8, 0x82f40e85, 0xc6367376, 0xcca27a95, 0x05ec0660, 0xb73386b0, + 0x845b94f8, 0x85588441, 0x1fb06e94, 0x6fcc482c, 0x6ae0439c, 0x8e267fe8, 0x056f446b, 0x28018226, 0x24018230, 0x20137144, 0xa5ed4808, 0x09061022, + 0x26066b4c, 0x03040115, 0x48000102, 0x6f350aee, 0x973f4ee8, 0x4bab34b9, 0x9cbc8f86, 0x413bacea, 0x30d0c643, 0x2f308819, 0x0c040214, 0x53000a1e, + 0x62007500, 0x41004300, 0x490d0949, 0x394b1046, 0x050f090a, 0x82030005, 0x94000101, 0xc231114d, 0x11bb507c, 0x0761a18e, 0x708c0e01, 0x73ef8d45, + 0x093fbd54, 0xb8ff2d05, 0x1c855351, 0xb79139ed, 0xde0b56a3, 0x1b3bb68c, 0xa7acfbd1, 0x51b1b7c9, 0x086f1b21, 0x036b7e69, 0xed4622a2, 0x7c6db46c, + 0xd346b822, 0x0f8df384, 0x368a07be, 0xe97eebc1, 0x9f455d70, 0xceccd292, 0xe1c08edd, 0x7ccd2abf, 0x32aec9ec, 0xcbb987d5, 0xd136c463, 0x76bf2118, + 0xb39a3bde, 0x219e731b, 0xb4b4d888, 0xf48c5412, 0x4a65c29c, 0x9c26289a, 0x3b0f8a60, 0x786513c7, 0xadcfbb48, 0xb04f3a83, 0x30de5862, 0x1d39e9e9, + 0xdaf289e3, 0x13f98139, 0x80648c21, 0x96040663, 0x43029af2, 0x88467b2f, 0xd902ffba, 0xde4af965, 0x937403da, 0x0c6e05b3, 0x28dc9dcc, 0xf1487c61, + 0x21119c17, 0x871c0238, 0x96c506ac, 0x40e5b832, 0xbd3d53c6, 0xe8de89a9, 0xf48d3766, 0xcc9c9622, 0x515477b0, 0x4472d63a, 0x30f623b2, 0x30aa0482, + 0x44920382, 0x0a2505a0, 0x30a20561, 0x20008300, 0x0f9a4408, 0x4469f44c, 0x1e331008, 0x38300d17, 0x35323730, 0x31303931, 0x175a3531, 0x8533310d, + 0x8331200e, 0x8130220e, 0x631e49b3, 0x25302722, 0x08052d49, 0x436e1e22, 0x65687069, 0x53442072, 0x53452045, 0x35383a4e, 0x332d3344, 0x2d433530, + 0x46434235, 0x23302531, 0x2005c84d, 0x09c84d1c, 0x2d2dd383, 0x6d617453, 0x65532070, 0x63697672, 0x204e4965, 0x04f0ff08, 0xc096b22d, 0x2567811a, + 0xb36226b1, 0x30ce4b13, 0x3812c0ba, 0x346581fc, 0xb236c407, 0x07f66824, 0x9707c004, 0x7bf1b7f4, 0x462c621e, 0x51a44bd9, 0x6cd3b734, 0xb43b5aed, + 0x3d47a183, 0x352e0811, 0xc2e6456b, 0x66028c3c, 0x6918a902, 0x27ed4aeb, 0x773cee2c, 0x70d4a45b, 0x84574b99, 0x2dafd010, 0xe61d89f8, 0xe7b429ea, + 0x62069ecf, 0xc25472a7, 0x3fcfc63b, 0x58b0e1b8, 0xa5e56c10, 0x75c2c3d7, 0x85f4bd37, 0x28e881e1, 0xf2f11bd8, 0xa382f1ae, 0xa203d7d6, 0xfb84159f, + 0xe1abfa3d, 0xa0c832b6, 0xe6f36402, 0x71261aff, 0x158a5308, 0x2783f202, 0x71824976, 0x32adefa7, 0x6cd7c678, 0x65224f16, 0x464d6297, 0xaf23ff2f, + 0x70a6ec85, 0xdacb03bd, 0xc50532d8, 0xb640902b, 0x862cd59e, 0x13cbb76c, 0xc68d7d32, 0x2f17ae7e, 0xbb66fc32, 0x5545b01d, 0x2dfaadf8, 0x29678367, + 0x5ad28493, 0x4e4923a1, 0x0939490b, 0xf697e833, 0xf18ceff7, 0x59e369e6, 0x98f74e68, 0x9bdd7a8a, 0x0c29492e, 0x49143144, 0x74243b29, 0x61637073, + 0x87442949, 0x45742049, 0xff4915ac, 0xc006210c, 0x090e8043, 0x01820312, 0x3f0d0001, 0x3c915f77, 0xa435a5be, 0x840505db, 0xeff2561f, 0x08c7a699, + 0xcdb32f8d, 0x86d5713f, 0xdd1f777c, 0xbdb217eb, 0x99f9e37c, 0x48450af2, 0x69bb14ad, 0x673ef22c, 0xeef25462, 0x9211277f, 0xd9ceec39, 0xf7884e87, + 0x7b234760, 0x08401527, 0x310dbf9f, 0x35d88204, 0x009c0cb6, 0x78aa8bd3, 0x88b5c561, 0x363e9d41, 0x27a458dc, 0xbdda3a9b, 0xa6145d06, 0xc14c0fb2, + 0xf28b3c8e, 0x66f89962, 0x1cf3d5ed, 0xdb32b028, 0xbc0931ca, 0x466822fb, 0x73d3fa4c, 0x8e29e722, 0x56fb0022, 0x81ae06bf, 0x34ba15a0, 0x1f8e28f9, + 0xa105624a, 0x4781f589, 0x08910de9, 0x8f3b58d7, 0x69096b1e, 0x7c48c0a9, 0x5f3f8255, 0x9c433800, 0xd83fcc06, 0x734fbf2f, 0xbafd3d09, 0xecc7f45e, + 0x6164c237, 0x3dd44da0, 0xb05bcc70, 0xd4c18113, 0xbd1a31a3, 0xd296d664, 0x5b2a3f7a, 0x3c095346, 0x3ff903cd, 0x89cc0059, 0x82316153, 0x82309b04, + 0x01029704, 0x87813001, 0x217ab24d, 0x484e0a02, 0x0937530a, 0xc681a024, 0x9e511930, 0x03092308, 0x35530c31, 0x3004220a, 0x230d8a1c, 0x300e310b, + 0x15221d8b, 0x38892330, 0x1631043a, 0x10021404, 0x50f422d5, 0xc18a6364, 0x49b42004, 0x0ec9cfcf, 0x6630101e, 0x0c28428a, 0x56305831, 0x2a802ca0, + 0x20122a79, 0x15ec7920, 0x8026a123, 0x18d34b24, 0x20099a7a, 0x0e645220, 0x82040b09, 0x05a60001, 0xa66e03f7, 0xc72c3268, 0x3ca63a84, 0x40c1e9f8, + 0xebdf5a55, 0x08c4f225, 0xb1a4d8a6, 0x05ec49c4, 0x157a23cb, 0x0405d31b, 0x157fca99, 0x88950e99, 0x177e5ab6, 0xc675a793, 0xca21f1df, 0x3cb92201, + 0xb5b336e4, 0xbaa664af, 0x304833ef, 0xf5e8137e, 0x33469d84, 0x8f35cc30, 0x0ae35e2a, 0x55c86bf2, 0xcc69a8c9, 0xa5d1efd4, 0xbf527a8d, 0x1352fe36, + 0x45bb7fe1, 0xdca4687c, 0x00bf1c80, 0xaf3ebf7f, 0xabac3d30, 0x9f8d9052, 0x70f3671f, 0x008cc15d, 0x4d1065d0, 0x48dd9de4, 0x1fb714ab, 0x97a956a2, + 0xaed4c3d0, 0xc7af8996, 0x53009c51, 0x5bfe6252, 0x40251abe, 0x5b98f7ae, 0x5f35a502, 0x32adb11e, 0x6b694088, 0xdd334163, 0x148a3b0e, 0x623af508, + 0x9efe8fb9, 0xf199fa84, 0xf594a177, 0x4cc77cc3, 0xc89e25c2, 0xaef10777, 0x5fb1a9e1, 0xca618963, 0x9cbd417d, 0xd612a6db, 0x76b886ea, 0x82a162e3, + 0x82301f02, 0xa5411b02, 0x31062409, 0x820c0282, 0x42082012, 0x2247708e, 0x4702200f, 0x07200bb8, 0x2306c655, 0x18305da0, 0x0322ac89, 0x0c880b31, + 0x30010723, 0x320c881c, 0x0f310509, 0x30310d17, 0x39313830, 0x33323130, 0x425a3435, 0x9233108a, 0x00ae5565, 0xe65c0104, 0x552e5c18, 0x57f65da5, + 0x44171a39, 0x05090e9f, 0x00018204, 0x8a6a3a22, 0xed717123, 0x74ef44b5, 0x65122e5e, 0x5faeadec, 0x20970064, 0x8cabd8be, 0x842fe2dc, 0xda9a608c, + 0x6788d252, 0xee4d2c36, 0x0212fba7, 0xe99869ce, 0x885f630f, 0x4cae55c3, 0x90270bf5, 0x685e1225, 0x939fd545, 0x2fd94cf4, 0xd9b5a4e9, 0x01f3976d, + 0xf13f0585, 0x5ed1f2fb, 0x9fcdec90, 0xd06585a4, 0x6e1fdcc2, 0xb0373f03, 0x805816ce, 0x63217077, 0xc7f32279, 0xf2f04c87, 0xbb2ef55f, 0xd999c845, + 0xfb407090, 0xa9e37e03, 0xc441eeec, 0x635383f9, 0x69a1277e, 0xf6d0fe4a, 0xacdd8b6c, 0xa386bb27, 0xb8737615, 0x8ba24694, 0xfe267d79, 0x1248ce35, + 0x60db449a, 0x375aad16, 0x0726e047, 0x43ccb951, 0xba19a96b, 0x26caecdf, 0x9461736c, 0x44661591, 0xd1737d7b, 0x41612337, 0xdeeda3a2, 0x11f7d0b4, + 0xa0b66df8, 0xff3c9a51, 0x323f5018, 0xc9ec56a8, 0xd3986a22, 0x49d547bb, 0xa3fe0c84, 0xfa050000, 0x04986851, +}; + +// Load embedded ProggyClean.ttf at size 13, disable oversampling +ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template) +{ + ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); + if (!font_cfg_template) + { + font_cfg.OversampleH = font_cfg.OversampleV = 1; + font_cfg.PixelSnapH = true; + } + if (font_cfg.Name[0] == '\0') strcpy(font_cfg.Name, ""); + if (font_cfg.SizePixels <= 0.0f) font_cfg.SizePixels = 13.0f; + + //const char* ttf_compressed_base85 = GetDefaultCompressedFontDataTTFBase85(); + ImFont* font = AddFontFromMemoryCompressedTTF(verdana_compressed_data, verdana_compressed_size, 13.0f, &font_cfg, GetGlyphRangesCyrillic()); + return font; +} + +ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) +{ + int data_size = 0; + void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0); + if (!data) + { + IM_ASSERT(0); // Could not load file. + return NULL; + } + ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); + if (font_cfg.Name[0] == '\0') + { + // Store a short copy of filename into into the font name for convenience + const char* p; + for (p = filename + strlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {} + snprintf(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "%s, %.0fpx", p, size_pixels); + } + return AddFontFromMemoryTTF(data, data_size, size_pixels, &font_cfg, glyph_ranges); +} + +// NB: Transfer ownership of 'ttf_data' to ImFontAtlas, unless font_cfg_template->FontDataOwnedByAtlas == false. Owned TTF buffer will be deleted after Build(). +ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) +{ + ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); + IM_ASSERT(font_cfg.FontData == NULL); + font_cfg.FontData = ttf_data; + font_cfg.FontDataSize = ttf_size; + font_cfg.SizePixels = size_pixels; + if (glyph_ranges) + font_cfg.GlyphRanges = glyph_ranges; + return AddFont(&font_cfg); +} + +ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) +{ + const unsigned int buf_decompressed_size = stb_decompress_length((unsigned char*)compressed_ttf_data); + unsigned char* buf_decompressed_data = (unsigned char *)ImGui::MemAlloc(buf_decompressed_size); + stb_decompress(buf_decompressed_data, (unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size); + + ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); + IM_ASSERT(font_cfg.FontData == NULL); + font_cfg.FontDataOwnedByAtlas = true; + return AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, size_pixels, &font_cfg, glyph_ranges); +} + +ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges) +{ + int compressed_ttf_size = (((int)strlen(compressed_ttf_data_base85) + 4) / 5) * 4; + void* compressed_ttf = ImGui::MemAlloc((size_t)compressed_ttf_size); + Decode85((const unsigned char*)compressed_ttf_data_base85, (unsigned char*)compressed_ttf); + ImFont* font = AddFontFromMemoryCompressedTTF(compressed_ttf, compressed_ttf_size, size_pixels, font_cfg, glyph_ranges); + ImGui::MemFree(compressed_ttf); + return font; +} + +int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height) +{ + IM_ASSERT(id >= 0x10000); + IM_ASSERT(width > 0 && width <= 0xFFFF); + IM_ASSERT(height > 0 && height <= 0xFFFF); + CustomRect r; + r.ID = id; + r.Width = (unsigned short)width; + r.Height = (unsigned short)height; + CustomRects.push_back(r); + return CustomRects.Size - 1; // Return index +} + +int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset) +{ + IM_ASSERT(font != NULL); + IM_ASSERT(width > 0 && width <= 0xFFFF); + IM_ASSERT(height > 0 && height <= 0xFFFF); + CustomRect r; + r.ID = id; + r.Width = (unsigned short)width; + r.Height = (unsigned short)height; + r.GlyphAdvanceX = advance_x; + r.GlyphOffset = offset; + r.Font = font; + CustomRects.push_back(r); + return CustomRects.Size - 1; // Return index +} + +void ImFontAtlas::CalcCustomRectUV(const CustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max) +{ + IM_ASSERT(TexWidth > 0 && TexHeight > 0); // Font atlas needs to be built before we can calculate UV coordinates + IM_ASSERT(rect->IsPacked()); // Make sure the rectangle has been packed + *out_uv_min = ImVec2((float)rect->X / TexWidth, (float)rect->Y / TexHeight); + *out_uv_max = ImVec2((float)(rect->X + rect->Width) / TexWidth, (float)(rect->Y + rect->Height) / TexHeight); +} + +bool ImFontAtlas::Build() +{ + return ImFontAtlasBuildWithStbTruetype(this); +} + +void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_brighten_factor) +{ + for (unsigned int i = 0; i < 256; i++) + { + unsigned int value = (unsigned int)(i * in_brighten_factor); + out_table[i] = value > 255 ? 255 : (value & 0xFF); + } +} + +void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride) +{ + unsigned char* data = pixels + x + y * stride; + for (int j = h; j > 0; j--, data += stride) + for (int i = 0; i < w; i++) + data[i] = table[data[i]]; +} + +bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas) +{ + IM_ASSERT(atlas->ConfigData.Size > 0); + + ImFontAtlasBuildRegisterDefaultCustomRects(atlas); + + atlas->TexID = NULL; + atlas->TexWidth = atlas->TexHeight = 0; + atlas->TexUvWhitePixel = ImVec2(0, 0); + atlas->ClearTexData(); + + // Count glyphs/ranges + int total_glyphs_count = 0; + int total_ranges_count = 0; + for (int input_i = 0; input_i < atlas->ConfigData.Size; input_i++) + { + ImFontConfig& cfg = atlas->ConfigData[input_i]; + if (!cfg.GlyphRanges) + cfg.GlyphRanges = atlas->GetGlyphRangesDefault(); + for (const ImWchar* in_range = cfg.GlyphRanges; in_range[0] && in_range[1]; in_range += 2, total_ranges_count++) + total_glyphs_count += (in_range[1] - in_range[0]) + 1; + } + + // We need a width for the skyline algorithm. Using a dumb heuristic here to decide of width. User can override TexDesiredWidth and TexGlyphPadding if they wish. + // Width doesn't really matter much, but some API/GPU have texture size limitations and increasing width can decrease height. + atlas->TexWidth = (atlas->TexDesiredWidth > 0) ? atlas->TexDesiredWidth : (total_glyphs_count > 4000) ? 4096 : (total_glyphs_count > 2000) ? 2048 : (total_glyphs_count > 1000) ? 1024 : 512; + atlas->TexHeight = 0; + + // Start packing + const int max_tex_height = 1024*32; + stbtt_pack_context spc = {}; + stbtt_PackBegin(&spc, NULL, atlas->TexWidth, max_tex_height, 0, atlas->TexGlyphPadding, NULL); + stbtt_PackSetOversampling(&spc, 1, 1); + + // Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values). + ImFontAtlasBuildPackCustomRects(atlas, spc.pack_info); + + // initialize font information (so we can error without any cleanup) + struct ImFontTempBuildData + { + stbtt_fontinfo FontInfo; + stbrp_rect* Rects; + int RectsCount; + stbtt_pack_range* Ranges; + int RangesCount; + }; + ImFontTempBuildData* tmp_array = (ImFontTempBuildData*)ImGui::MemAlloc((size_t)atlas->ConfigData.Size * sizeof(ImFontTempBuildData)); + for (int input_i = 0; input_i < atlas->ConfigData.Size; input_i++) + { + ImFontConfig& cfg = atlas->ConfigData[input_i]; + ImFontTempBuildData& tmp = tmp_array[input_i]; + IM_ASSERT(cfg.DstFont && (!cfg.DstFont->IsLoaded() || cfg.DstFont->ContainerAtlas == atlas)); + + const int font_offset = stbtt_GetFontOffsetForIndex((unsigned char*)cfg.FontData, cfg.FontNo); + IM_ASSERT(font_offset >= 0); + if (!stbtt_InitFont(&tmp.FontInfo, (unsigned char*)cfg.FontData, font_offset)) + { + atlas->TexWidth = atlas->TexHeight = 0; // Reset output on failure + ImGui::MemFree(tmp_array); + return false; + } + } + + // Allocate packing character data and flag packed characters buffer as non-packed (x0=y0=x1=y1=0) + int buf_packedchars_n = 0, buf_rects_n = 0, buf_ranges_n = 0; + stbtt_packedchar* buf_packedchars = (stbtt_packedchar*)ImGui::MemAlloc(total_glyphs_count * sizeof(stbtt_packedchar)); + stbrp_rect* buf_rects = (stbrp_rect*)ImGui::MemAlloc(total_glyphs_count * sizeof(stbrp_rect)); + stbtt_pack_range* buf_ranges = (stbtt_pack_range*)ImGui::MemAlloc(total_ranges_count * sizeof(stbtt_pack_range)); + memset(buf_packedchars, 0, total_glyphs_count * sizeof(stbtt_packedchar)); + memset(buf_rects, 0, total_glyphs_count * sizeof(stbrp_rect)); // Unnecessary but let's clear this for the sake of sanity. + memset(buf_ranges, 0, total_ranges_count * sizeof(stbtt_pack_range)); + + // First font pass: pack all glyphs (no rendering at this point, we are working with rectangles in an infinitely tall texture at this point) + for (int input_i = 0; input_i < atlas->ConfigData.Size; input_i++) + { + ImFontConfig& cfg = atlas->ConfigData[input_i]; + ImFontTempBuildData& tmp = tmp_array[input_i]; + + // Setup ranges + int font_glyphs_count = 0; + int font_ranges_count = 0; + for (const ImWchar* in_range = cfg.GlyphRanges; in_range[0] && in_range[1]; in_range += 2, font_ranges_count++) + font_glyphs_count += (in_range[1] - in_range[0]) + 1; + tmp.Ranges = buf_ranges + buf_ranges_n; + tmp.RangesCount = font_ranges_count; + buf_ranges_n += font_ranges_count; + for (int i = 0; i < font_ranges_count; i++) + { + const ImWchar* in_range = &cfg.GlyphRanges[i * 2]; + stbtt_pack_range& range = tmp.Ranges[i]; + range.font_size = cfg.SizePixels; + range.first_unicode_codepoint_in_range = in_range[0]; + range.num_chars = (in_range[1] - in_range[0]) + 1; + range.chardata_for_range = buf_packedchars + buf_packedchars_n; + buf_packedchars_n += range.num_chars; + } + + // Pack + tmp.Rects = buf_rects + buf_rects_n; + tmp.RectsCount = font_glyphs_count; + buf_rects_n += font_glyphs_count; + stbtt_PackSetOversampling(&spc, cfg.OversampleH, cfg.OversampleV); + int n = stbtt_PackFontRangesGatherRects(&spc, &tmp.FontInfo, tmp.Ranges, tmp.RangesCount, tmp.Rects); + IM_ASSERT(n == font_glyphs_count); + stbrp_pack_rects((stbrp_context*)spc.pack_info, tmp.Rects, n); + + // Extend texture height + for (int i = 0; i < n; i++) + if (tmp.Rects[i].was_packed) + atlas->TexHeight = ImMax(atlas->TexHeight, tmp.Rects[i].y + tmp.Rects[i].h); + } + IM_ASSERT(buf_rects_n == total_glyphs_count); + IM_ASSERT(buf_packedchars_n == total_glyphs_count); + IM_ASSERT(buf_ranges_n == total_ranges_count); + + // Create texture + atlas->TexHeight = ImUpperPowerOfTwo(atlas->TexHeight); + atlas->TexPixelsAlpha8 = (unsigned char*)ImGui::MemAlloc(atlas->TexWidth * atlas->TexHeight); + memset(atlas->TexPixelsAlpha8, 0, atlas->TexWidth * atlas->TexHeight); + spc.pixels = atlas->TexPixelsAlpha8; + spc.height = atlas->TexHeight; + + // Second pass: render font characters + for (int input_i = 0; input_i < atlas->ConfigData.Size; input_i++) + { + ImFontConfig& cfg = atlas->ConfigData[input_i]; + ImFontTempBuildData& tmp = tmp_array[input_i]; + stbtt_PackSetOversampling(&spc, cfg.OversampleH, cfg.OversampleV); + stbtt_PackFontRangesRenderIntoRects(&spc, &tmp.FontInfo, tmp.Ranges, tmp.RangesCount, tmp.Rects); + if (cfg.RasterizerMultiply != 1.0f) + { + unsigned char multiply_table[256]; + ImFontAtlasBuildMultiplyCalcLookupTable(multiply_table, cfg.RasterizerMultiply); + for (const stbrp_rect* r = tmp.Rects; r != tmp.Rects + tmp.RectsCount; r++) + if (r->was_packed) + ImFontAtlasBuildMultiplyRectAlpha8(multiply_table, spc.pixels, r->x, r->y, r->w, r->h, spc.stride_in_BYTEs); + } + tmp.Rects = NULL; + } + + // End packing + stbtt_PackEnd(&spc); + ImGui::MemFree(buf_rects); + buf_rects = NULL; + + // Third pass: setup ImFont and glyphs for runtime + for (int input_i = 0; input_i < atlas->ConfigData.Size; input_i++) + { + ImFontConfig& cfg = atlas->ConfigData[input_i]; + ImFontTempBuildData& tmp = tmp_array[input_i]; + ImFont* dst_font = cfg.DstFont; // We can have multiple input fonts writing into a same destination font (when using MergeMode=true) + + const float font_scale = stbtt_ScaleForPixelHeight(&tmp.FontInfo, cfg.SizePixels); + int unscaled_ascent, unscaled_descent, unscaled_line_gap; + stbtt_GetFontVMetrics(&tmp.FontInfo, &unscaled_ascent, &unscaled_descent, &unscaled_line_gap); + + const float ascent = unscaled_ascent * font_scale; + const float descent = unscaled_descent * font_scale; + ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent); + const float off_x = cfg.GlyphOffset.x; + const float off_y = cfg.GlyphOffset.y + (float)(int)(dst_font->Ascent + 0.5f); + + for (int i = 0; i < tmp.RangesCount; i++) + { + stbtt_pack_range& range = tmp.Ranges[i]; + for (int char_idx = 0; char_idx < range.num_chars; char_idx += 1) + { + const stbtt_packedchar& pc = range.chardata_for_range[char_idx]; + if (!pc.x0 && !pc.x1 && !pc.y0 && !pc.y1) + continue; + + const int codepoint = range.first_unicode_codepoint_in_range + char_idx; + if (cfg.MergeMode && dst_font->FindGlyph((unsigned short)codepoint)) + continue; + + stbtt_aligned_quad q; + float dummy_x = 0.0f, dummy_y = 0.0f; + stbtt_GetPackedQuad(range.chardata_for_range, atlas->TexWidth, atlas->TexHeight, char_idx, &dummy_x, &dummy_y, &q, 0); + dst_font->AddGlyph((ImWchar)codepoint, q.x0 + off_x, q.y0 + off_y, q.x1 + off_x, q.y1 + off_y, q.s0, q.t0, q.s1, q.t1, pc.xadvance); + } + } + } + + // Cleanup temporaries + ImGui::MemFree(buf_packedchars); + ImGui::MemFree(buf_ranges); + ImGui::MemFree(tmp_array); + + ImFontAtlasBuildFinish(atlas); + + return true; +} + +void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas) +{ + if (atlas->CustomRectIds[0] < 0) + atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_ID, FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF*2+1, FONT_ATLAS_DEFAULT_TEX_DATA_H); +} + +void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent) +{ + if (!font_config->MergeMode) + { + font->ClearOutputData(); + font->FontSize = font_config->SizePixels; + font->ConfigData = font_config; + font->ContainerAtlas = atlas; + font->Ascent = ascent; + font->Descent = descent; + } + font->ConfigDataCount++; +} + +void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* pack_context_opaque) +{ + stbrp_context* pack_context = (stbrp_context*)pack_context_opaque; + + ImVector& user_rects = atlas->CustomRects; + IM_ASSERT(user_rects.Size >= 1); // We expect at least the default custom rects to be registered, else something went wrong. + + ImVector pack_rects; + pack_rects.resize(user_rects.Size); + memset(pack_rects.Data, 0, sizeof(stbrp_rect) * user_rects.Size); + for (int i = 0; i < user_rects.Size; i++) + { + pack_rects[i].w = user_rects[i].Width; + pack_rects[i].h = user_rects[i].Height; + } + stbrp_pack_rects(pack_context, &pack_rects[0], pack_rects.Size); + for (int i = 0; i < pack_rects.Size; i++) + if (pack_rects[i].was_packed) + { + user_rects[i].X = pack_rects[i].x; + user_rects[i].Y = pack_rects[i].y; + IM_ASSERT(pack_rects[i].w == user_rects[i].Width && pack_rects[i].h == user_rects[i].Height); + atlas->TexHeight = ImMax(atlas->TexHeight, pack_rects[i].y + pack_rects[i].h); + } +} + +static void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas) +{ + IM_ASSERT(atlas->CustomRectIds[0] >= 0); + ImFontAtlas::CustomRect& r = atlas->CustomRects[atlas->CustomRectIds[0]]; + IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID); + IM_ASSERT(r.Width == FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF*2+1); + IM_ASSERT(r.Height == FONT_ATLAS_DEFAULT_TEX_DATA_H); + IM_ASSERT(r.IsPacked()); + IM_ASSERT(atlas->TexPixelsAlpha8 != NULL); + + // Render/copy pixels + for (int y = 0, n = 0; y < FONT_ATLAS_DEFAULT_TEX_DATA_H; y++) + for (int x = 0; x < FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF; x++, n++) + { + const int offset0 = (int)(r.X + x) + (int)(r.Y + y) * atlas->TexWidth; + const int offset1 = offset0 + FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF + 1; + atlas->TexPixelsAlpha8[offset0] = FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[n] == '.' ? 0xFF : 0x00; + atlas->TexPixelsAlpha8[offset1] = FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[n] == 'X' ? 0xFF : 0x00; + } + const ImVec2 tex_uv_scale(1.0f / atlas->TexWidth, 1.0f / atlas->TexHeight); + atlas->TexUvWhitePixel = ImVec2((r.X + 0.5f) * tex_uv_scale.x, (r.Y + 0.5f) * tex_uv_scale.y); + + // Setup mouse cursors + for (int type = 0; type < ImGuiMouseCursor_Count_; type++) + { + ImGuiMouseCursorData& cursor_data = GImGui->MouseCursorData[type]; + ImVec2 pos = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[type][0] + ImVec2((float)r.X, (float)r.Y); + const ImVec2 size = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[type][1]; + cursor_data.Type = type; + cursor_data.Size = size; + cursor_data.HotOffset = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[type][2]; + cursor_data.TexUvMin[0] = (pos) * tex_uv_scale; + cursor_data.TexUvMax[0] = (pos + size) * tex_uv_scale; + pos.x += FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF + 1; + cursor_data.TexUvMin[1] = (pos) * tex_uv_scale; + cursor_data.TexUvMax[1] = (pos + size) * tex_uv_scale; + } +} + +void ImFontAtlasBuildFinish(ImFontAtlas* atlas) +{ + // Render into our custom data block + ImFontAtlasBuildRenderDefaultTexData(atlas); + + // Register custom rectangle glyphs + for (int i = 0; i < atlas->CustomRects.Size; i++) + { + const ImFontAtlas::CustomRect& r = atlas->CustomRects[i]; + if (r.Font == NULL || r.ID > 0x10000) + continue; + + IM_ASSERT(r.Font->ContainerAtlas == atlas); + ImVec2 uv0, uv1; + atlas->CalcCustomRectUV(&r, &uv0, &uv1); + r.Font->AddGlyph((ImWchar)r.ID, r.GlyphOffset.x, r.GlyphOffset.y, r.GlyphOffset.x + r.Width, r.GlyphOffset.y + r.Height, uv0.x, uv0.y, uv1.x, uv1.y, r.GlyphAdvanceX); + } + + // Build all fonts lookup tables + for (int i = 0; i < atlas->Fonts.Size; i++) + atlas->Fonts[i]->BuildLookupTable(); +} + +// Retrieve list of range (2 int per range, values are inclusive) +const ImWchar* ImFontAtlas::GetGlyphRangesDefault() +{ + static const ImWchar ranges[] = + { + 0x0020, 0x00FF, // Basic Latin + Latin Supplement + 0, + }; + return &ranges[0]; +} + +const ImWchar* ImFontAtlas::GetGlyphRangesKorean() +{ + static const ImWchar ranges[] = + { + 0x0020, 0x00FF, // Basic Latin + Latin Supplement + 0x3131, 0x3163, // Korean alphabets + 0xAC00, 0xD79D, // Korean characters + 0, + }; + return &ranges[0]; +} + +const ImWchar* ImFontAtlas::GetGlyphRangesChinese() +{ + static const ImWchar ranges[] = + { + 0x0020, 0x00FF, // Basic Latin + Latin Supplement + 0x3000, 0x30FF, // Punctuations, Hiragana, Katakana + 0x31F0, 0x31FF, // Katakana Phonetic Extensions + 0xFF00, 0xFFEF, // Half-width characters + 0x4e00, 0x9FAF, // CJK Ideograms + 0, + }; + return &ranges[0]; +} + +const ImWchar* ImFontAtlas::GetGlyphRangesJapanese() +{ + // Store the 1946 ideograms code points as successive offsets from the initial unicode codepoint 0x4E00. Each offset has an implicit +1. + // This encoding is designed to helps us reduce the source code size. + // FIXME: Source a list of the revised 2136 joyo kanji list from 2010 and rebuild this. + // The current list was sourced from http://theinstructionlimit.com/author/renaudbedardrenaudbedard/page/3 + // Note that you may use ImFontAtlas::GlyphRangesBuilder to create your own ranges, by merging existing ranges or adding new characters. + static const short offsets_from_0x4E00[] = + { + -1,0,1,3,0,0,0,0,1,0,5,1,1,0,7,4,6,10,0,1,9,9,7,1,3,19,1,10,7,1,0,1,0,5,1,0,6,4,2,6,0,0,12,6,8,0,3,5,0,1,0,9,0,0,8,1,1,3,4,5,13,0,0,8,2,17, + 4,3,1,1,9,6,0,0,0,2,1,3,2,22,1,9,11,1,13,1,3,12,0,5,9,2,0,6,12,5,3,12,4,1,2,16,1,1,4,6,5,3,0,6,13,15,5,12,8,14,0,0,6,15,3,6,0,18,8,1,6,14,1, + 5,4,12,24,3,13,12,10,24,0,0,0,1,0,1,1,2,9,10,2,2,0,0,3,3,1,0,3,8,0,3,2,4,4,1,6,11,10,14,6,15,3,4,15,1,0,0,5,2,2,0,0,1,6,5,5,6,0,3,6,5,0,0,1,0, + 11,2,2,8,4,7,0,10,0,1,2,17,19,3,0,2,5,0,6,2,4,4,6,1,1,11,2,0,3,1,2,1,2,10,7,6,3,16,0,8,24,0,0,3,1,1,3,0,1,6,0,0,0,2,0,1,5,15,0,1,0,0,2,11,19, + 1,4,19,7,6,5,1,0,0,0,0,5,1,0,1,9,0,0,5,0,2,0,1,0,3,0,11,3,0,2,0,0,0,0,0,9,3,6,4,12,0,14,0,0,29,10,8,0,14,37,13,0,31,16,19,0,8,30,1,20,8,3,48, + 21,1,0,12,0,10,44,34,42,54,11,18,82,0,2,1,2,12,1,0,6,2,17,2,12,7,0,7,17,4,2,6,24,23,8,23,39,2,16,23,1,0,5,1,2,15,14,5,6,2,11,0,8,6,2,2,2,14, + 20,4,15,3,4,11,10,10,2,5,2,1,30,2,1,0,0,22,5,5,0,3,1,5,4,1,0,0,2,2,21,1,5,1,2,16,2,1,3,4,0,8,4,0,0,5,14,11,2,16,1,13,1,7,0,22,15,3,1,22,7,14, + 22,19,11,24,18,46,10,20,64,45,3,2,0,4,5,0,1,4,25,1,0,0,2,10,0,0,0,1,0,1,2,0,0,9,1,2,0,0,0,2,5,2,1,1,5,5,8,1,1,1,5,1,4,9,1,3,0,1,0,1,1,2,0,0, + 2,0,1,8,22,8,1,0,0,0,0,4,2,1,0,9,8,5,0,9,1,30,24,2,6,4,39,0,14,5,16,6,26,179,0,2,1,1,0,0,0,5,2,9,6,0,2,5,16,7,5,1,1,0,2,4,4,7,15,13,14,0,0, + 3,0,1,0,0,0,2,1,6,4,5,1,4,9,0,3,1,8,0,0,10,5,0,43,0,2,6,8,4,0,2,0,0,9,6,0,9,3,1,6,20,14,6,1,4,0,7,2,3,0,2,0,5,0,3,1,0,3,9,7,0,3,4,0,4,9,1,6,0, + 9,0,0,2,3,10,9,28,3,6,2,4,1,2,32,4,1,18,2,0,3,1,5,30,10,0,2,2,2,0,7,9,8,11,10,11,7,2,13,7,5,10,0,3,40,2,0,1,6,12,0,4,5,1,5,11,11,21,4,8,3,7, + 8,8,33,5,23,0,0,19,8,8,2,3,0,6,1,1,1,5,1,27,4,2,5,0,3,5,6,3,1,0,3,1,12,5,3,3,2,0,7,7,2,1,0,4,0,1,1,2,0,10,10,6,2,5,9,7,5,15,15,21,6,11,5,20, + 4,3,5,5,2,5,0,2,1,0,1,7,28,0,9,0,5,12,5,5,18,30,0,12,3,3,21,16,25,32,9,3,14,11,24,5,66,9,1,2,0,5,9,1,5,1,8,0,8,3,3,0,1,15,1,4,8,1,2,7,0,7,2, + 8,3,7,5,3,7,10,2,1,0,0,2,25,0,6,4,0,10,0,4,2,4,1,12,5,38,4,0,4,1,10,5,9,4,0,14,4,2,5,18,20,21,1,3,0,5,0,7,0,3,7,1,3,1,1,8,1,0,0,0,3,2,5,2,11, + 6,0,13,1,3,9,1,12,0,16,6,2,1,0,2,1,12,6,13,11,2,0,28,1,7,8,14,13,8,13,0,2,0,5,4,8,10,2,37,42,19,6,6,7,4,14,11,18,14,80,7,6,0,4,72,12,36,27, + 7,7,0,14,17,19,164,27,0,5,10,7,3,13,6,14,0,2,2,5,3,0,6,13,0,0,10,29,0,4,0,3,13,0,3,1,6,51,1,5,28,2,0,8,0,20,2,4,0,25,2,10,13,10,0,16,4,0,1,0, + 2,1,7,0,1,8,11,0,0,1,2,7,2,23,11,6,6,4,16,2,2,2,0,22,9,3,3,5,2,0,15,16,21,2,9,20,15,15,5,3,9,1,0,0,1,7,7,5,4,2,2,2,38,24,14,0,0,15,5,6,24,14, + 5,5,11,0,21,12,0,3,8,4,11,1,8,0,11,27,7,2,4,9,21,59,0,1,39,3,60,62,3,0,12,11,0,3,30,11,0,13,88,4,15,5,28,13,1,4,48,17,17,4,28,32,46,0,16,0, + 18,11,1,8,6,38,11,2,6,11,38,2,0,45,3,11,2,7,8,4,30,14,17,2,1,1,65,18,12,16,4,2,45,123,12,56,33,1,4,3,4,7,0,0,0,3,2,0,16,4,2,4,2,0,7,4,5,2,26, + 2,25,6,11,6,1,16,2,6,17,77,15,3,35,0,1,0,5,1,0,38,16,6,3,12,3,3,3,0,9,3,1,3,5,2,9,0,18,0,25,1,3,32,1,72,46,6,2,7,1,3,14,17,0,28,1,40,13,0,20, + 15,40,6,38,24,12,43,1,1,9,0,12,6,0,6,2,4,19,3,7,1,48,0,9,5,0,5,6,9,6,10,15,2,11,19,3,9,2,0,1,10,1,27,8,1,3,6,1,14,0,26,0,27,16,3,4,9,6,2,23, + 9,10,5,25,2,1,6,1,1,48,15,9,15,14,3,4,26,60,29,13,37,21,1,6,4,0,2,11,22,23,16,16,2,2,1,3,0,5,1,6,4,0,0,4,0,0,8,3,0,2,5,0,7,1,7,3,13,2,4,10, + 3,0,2,31,0,18,3,0,12,10,4,1,0,7,5,7,0,5,4,12,2,22,10,4,2,15,2,8,9,0,23,2,197,51,3,1,1,4,13,4,3,21,4,19,3,10,5,40,0,4,1,1,10,4,1,27,34,7,21, + 2,17,2,9,6,4,2,3,0,4,2,7,8,2,5,1,15,21,3,4,4,2,2,17,22,1,5,22,4,26,7,0,32,1,11,42,15,4,1,2,5,0,19,3,1,8,6,0,10,1,9,2,13,30,8,2,24,17,19,1,4, + 4,25,13,0,10,16,11,39,18,8,5,30,82,1,6,8,18,77,11,13,20,75,11,112,78,33,3,0,0,60,17,84,9,1,1,12,30,10,49,5,32,158,178,5,5,6,3,3,1,3,1,4,7,6, + 19,31,21,0,2,9,5,6,27,4,9,8,1,76,18,12,1,4,0,3,3,6,3,12,2,8,30,16,2,25,1,5,5,4,3,0,6,10,2,3,1,0,5,1,19,3,0,8,1,5,2,6,0,0,0,19,1,2,0,5,1,2,5, + 1,3,7,0,4,12,7,3,10,22,0,9,5,1,0,2,20,1,1,3,23,30,3,9,9,1,4,191,14,3,15,6,8,50,0,1,0,0,4,0,0,1,0,2,4,2,0,2,3,0,2,0,2,2,8,7,0,1,1,1,3,3,17,11, + 91,1,9,3,2,13,4,24,15,41,3,13,3,1,20,4,125,29,30,1,0,4,12,2,21,4,5,5,19,11,0,13,11,86,2,18,0,7,1,8,8,2,2,22,1,2,6,5,2,0,1,2,8,0,2,0,5,2,1,0, + 2,10,2,0,5,9,2,1,2,0,1,0,4,0,0,10,2,5,3,0,6,1,0,1,4,4,33,3,13,17,3,18,6,4,7,1,5,78,0,4,1,13,7,1,8,1,0,35,27,15,3,0,0,0,1,11,5,41,38,15,22,6, + 14,14,2,1,11,6,20,63,5,8,27,7,11,2,2,40,58,23,50,54,56,293,8,8,1,5,1,14,0,1,12,37,89,8,8,8,2,10,6,0,0,0,4,5,2,1,0,1,1,2,7,0,3,3,0,4,6,0,3,2, + 19,3,8,0,0,0,4,4,16,0,4,1,5,1,3,0,3,4,6,2,17,10,10,31,6,4,3,6,10,126,7,3,2,2,0,9,0,0,5,20,13,0,15,0,6,0,2,5,8,64,50,3,2,12,2,9,0,0,11,8,20, + 109,2,18,23,0,0,9,61,3,0,28,41,77,27,19,17,81,5,2,14,5,83,57,252,14,154,263,14,20,8,13,6,57,39,38, + }; + static ImWchar base_ranges[] = + { + 0x0020, 0x00FF, // Basic Latin + Latin Supplement + 0x3000, 0x30FF, // Punctuations, Hiragana, Katakana + 0x31F0, 0x31FF, // Katakana Phonetic Extensions + 0xFF00, 0xFFEF, // Half-width characters + }; + static bool full_ranges_unpacked = false; + static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(offsets_from_0x4E00)*2 + 1]; + if (!full_ranges_unpacked) + { + // Unpack + int codepoint = 0x4e00; + memcpy(full_ranges, base_ranges, sizeof(base_ranges)); + ImWchar* dst = full_ranges + IM_ARRAYSIZE(base_ranges);; + for (int n = 0; n < IM_ARRAYSIZE(offsets_from_0x4E00); n++, dst += 2) + dst[0] = dst[1] = (ImWchar)(codepoint += (offsets_from_0x4E00[n] + 1)); + dst[0] = 0; + full_ranges_unpacked = true; + } + return &full_ranges[0]; +} + +const ImWchar* ImFontAtlas::GetGlyphRangesCyrillic() +{ + static const ImWchar ranges[] = + { + 0x0020, 0x00FF, // Basic Latin + Latin Supplement + 0x0400, 0x052F, // Cyrillic + Cyrillic Supplement + 0x2DE0, 0x2DFF, // Cyrillic Extended-A + 0xA640, 0xA69F, // Cyrillic Extended-B + 0, + }; + return &ranges[0]; +} + +const ImWchar* ImFontAtlas::GetGlyphRangesThai() +{ + static const ImWchar ranges[] = + { + 0x0020, 0x00FF, // Basic Latin + 0x2010, 0x205E, // Punctuations + 0x0E00, 0x0E7F, // Thai + 0, + }; + return &ranges[0]; +} + +//----------------------------------------------------------------------------- +// ImFontAtlas::GlyphRangesBuilder +//----------------------------------------------------------------------------- + +void ImFontAtlas::GlyphRangesBuilder::AddText(const char* text, const char* text_end) +{ + while (text_end ? (text < text_end) : *text) + { + unsigned int c = 0; + int c_len = ImTextCharFromUtf8(&c, text, text_end); + text += c_len; + if (c_len == 0) + break; + if (c < 0x10000) + AddChar((ImWchar)c); + } +} + +void ImFontAtlas::GlyphRangesBuilder::AddRanges(const ImWchar* ranges) +{ + for (; ranges[0]; ranges += 2) + for (ImWchar c = ranges[0]; c <= ranges[1]; c++) + AddChar(c); +} + +void ImFontAtlas::GlyphRangesBuilder::BuildRanges(ImVector* out_ranges) +{ + for (int n = 0; n < 0x10000; n++) + if (GetBit(n)) + { + out_ranges->push_back((ImWchar)n); + while (n < 0x10000 && GetBit(n + 1)) + n++; + out_ranges->push_back((ImWchar)n); + } + out_ranges->push_back(0); +} + +//----------------------------------------------------------------------------- +// ImFont +//----------------------------------------------------------------------------- + +ImFont::ImFont() +{ + Scale = 1.0f; + FallbackChar = (ImWchar)'?'; + DisplayOffset = ImVec2(0.0f, 1.0f); + ClearOutputData(); +} + +ImFont::~ImFont() +{ + // Invalidate active font so that the user gets a clear crash instead of a dangling pointer. + // If you want to delete fonts you need to do it between Render() and NewFrame(). + // FIXME-CLEANUP + /* + ImGuiContext& g = *GImGui; + if (g.Font == this) + g.Font = NULL; + */ + ClearOutputData(); +} + +void ImFont::ClearOutputData() +{ + FontSize = 0.0f; + Glyphs.clear(); + IndexAdvanceX.clear(); + IndexLookup.clear(); + FallbackGlyph = NULL; + FallbackAdvanceX = 0.0f; + ConfigDataCount = 0; + ConfigData = NULL; + ContainerAtlas = NULL; + Ascent = Descent = 0.0f; + MetricsTotalSurface = 0; +} + +void ImFont::BuildLookupTable() +{ + int max_codepoint = 0; + for (int i = 0; i != Glyphs.Size; i++) + max_codepoint = ImMax(max_codepoint, (int)Glyphs[i].Codepoint); + + IM_ASSERT(Glyphs.Size < 0xFFFF); // -1 is reserved + IndexAdvanceX.clear(); + IndexLookup.clear(); + GrowIndex(max_codepoint + 1); + for (int i = 0; i < Glyphs.Size; i++) + { + int codepoint = (int)Glyphs[i].Codepoint; + IndexAdvanceX[codepoint] = Glyphs[i].AdvanceX; + IndexLookup[codepoint] = (unsigned short)i; + } + + // Create a glyph to handle TAB + // FIXME: Needs proper TAB handling but it needs to be contextualized (or we could arbitrary say that each string starts at "column 0" ?) + if (FindGlyph((unsigned short)' ')) + { + if (Glyphs.back().Codepoint != '\t') // So we can call this function multiple times + Glyphs.resize(Glyphs.Size + 1); + ImFontGlyph& tab_glyph = Glyphs.back(); + tab_glyph = *FindGlyph((unsigned short)' '); + tab_glyph.Codepoint = '\t'; + tab_glyph.AdvanceX *= 4; + IndexAdvanceX[(int)tab_glyph.Codepoint] = (float)tab_glyph.AdvanceX; + IndexLookup[(int)tab_glyph.Codepoint] = (unsigned short)(Glyphs.Size-1); + } + + FallbackGlyph = NULL; + FallbackGlyph = FindGlyph(FallbackChar); + FallbackAdvanceX = FallbackGlyph ? FallbackGlyph->AdvanceX : 0.0f; + for (int i = 0; i < max_codepoint + 1; i++) + if (IndexAdvanceX[i] < 0.0f) + IndexAdvanceX[i] = FallbackAdvanceX; +} + +void ImFont::SetFallbackChar(ImWchar c) +{ + FallbackChar = c; + BuildLookupTable(); +} + +void ImFont::GrowIndex(int new_size) +{ + IM_ASSERT(IndexAdvanceX.Size == IndexLookup.Size); + if (new_size <= IndexLookup.Size) + return; + IndexAdvanceX.resize(new_size, -1.0f); + IndexLookup.resize(new_size, (unsigned short)-1); +} + +void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x) +{ + Glyphs.resize(Glyphs.Size + 1); + ImFontGlyph& glyph = Glyphs.back(); + glyph.Codepoint = (ImWchar)codepoint; + glyph.X0 = x0; + glyph.Y0 = y0; + glyph.X1 = x1; + glyph.Y1 = y1; + glyph.U0 = u0; + glyph.V0 = v0; + glyph.U1 = u1; + glyph.V1 = v1; + glyph.AdvanceX = advance_x + ConfigData->GlyphExtraSpacing.x; // Bake spacing into AdvanceX + + if (ConfigData->PixelSnapH) + glyph.AdvanceX = (float)(int)(glyph.AdvanceX + 0.5f); + + // Compute rough surface usage metrics (+1 to account for average padding, +0.99 to round) + MetricsTotalSurface += (int)((glyph.U1 - glyph.U0) * ContainerAtlas->TexWidth + 1.99f) * (int)((glyph.V1 - glyph.V0) * ContainerAtlas->TexHeight + 1.99f); +} + +void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst) +{ + IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function. + int index_size = IndexLookup.Size; + + if (dst < index_size && IndexLookup.Data[dst] == (unsigned short)-1 && !overwrite_dst) // 'dst' already exists + return; + if (src >= index_size && dst >= index_size) // both 'dst' and 'src' don't exist -> no-op + return; + + GrowIndex(dst + 1); + IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : (unsigned short)-1; + IndexAdvanceX[dst] = (src < index_size) ? IndexAdvanceX.Data[src] : 1.0f; +} + +const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const +{ + if (c < IndexLookup.Size) + { + const unsigned short i = IndexLookup[c]; + if (i != (unsigned short)-1) + return &Glyphs.Data[i]; + } + return FallbackGlyph; +} + +const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const +{ + // Simple word-wrapping for English, not full-featured. Please submit failing cases! + // FIXME: Much possible improvements (don't cut things like "word !", "word!!!" but cut within "word,,,,", more sensible support for punctuations, support for Unicode punctuations, etc.) + + // For references, possible wrap point marked with ^ + // "aaa bbb, ccc,ddd. eee fff. ggg!" + // ^ ^ ^ ^ ^__ ^ ^ + + // List of hardcoded separators: .,;!?'" + + // Skip extra blanks after a line returns (that includes not counting them in width computation) + // e.g. "Hello world" --> "Hello" "World" + + // Cut words that cannot possibly fit within one line. + // e.g.: "The tropical fish" with ~5 characters worth of width --> "The tr" "opical" "fish" + + float line_width = 0.0f; + float word_width = 0.0f; + float blank_width = 0.0f; + wrap_width /= scale; // We work with unscaled widths to avoid scaling every characters + + const char* word_end = text; + const char* prev_word_end = NULL; + bool inside_word = true; + + const char* s = text; + while (s < text_end) + { + unsigned int c = (unsigned int)*s; + const char* next_s; + if (c < 0x80) + next_s = s + 1; + else + next_s = s + ImTextCharFromUtf8(&c, s, text_end); + if (c == 0) + break; + + if (c < 32) + { + if (c == '\n') + { + line_width = word_width = blank_width = 0.0f; + inside_word = true; + s = next_s; + continue; + } + if (c == '\r') + { + s = next_s; + continue; + } + } + + const float char_width = ((int)c < IndexAdvanceX.Size ? IndexAdvanceX[(int)c] : FallbackAdvanceX); + if (ImCharIsSpace(c)) + { + if (inside_word) + { + line_width += blank_width; + blank_width = 0.0f; + word_end = s; + } + blank_width += char_width; + inside_word = false; + } + else + { + word_width += char_width; + if (inside_word) + { + word_end = next_s; + } + else + { + prev_word_end = word_end; + line_width += word_width + blank_width; + word_width = blank_width = 0.0f; + } + + // Allow wrapping after punctuation. + inside_word = !(c == '.' || c == ',' || c == ';' || c == '!' || c == '?' || c == '\"'); + } + + // We ignore blank width at the end of the line (they can be skipped) + if (line_width + word_width >= wrap_width) + { + // Words that cannot possibly fit within an entire line will be cut anywhere. + if (word_width < wrap_width) + s = prev_word_end ? prev_word_end : word_end; + break; + } + + s = next_s; + } + + return s; +} + +ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end, const char** remaining) const +{ + if (!text_end) + text_end = text_begin + strlen(text_begin); // FIXME-OPT: Need to avoid this. + + const float line_height = size; + const float scale = size / FontSize; + + ImVec2 text_size = ImVec2(0,0); + float line_width = 0.0f; + + const bool word_wrap_enabled = (wrap_width > 0.0f); + const char* word_wrap_eol = NULL; + + const char* s = text_begin; + while (s < text_end) + { + if (word_wrap_enabled) + { + // Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature. + if (!word_wrap_eol) + { + word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - line_width); + if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity. + word_wrap_eol++; // +1 may not be a character start point in UTF-8 but it's ok because we use s >= word_wrap_eol below + } + + if (s >= word_wrap_eol) + { + if (text_size.x < line_width) + text_size.x = line_width; + text_size.y += line_height; + line_width = 0.0f; + word_wrap_eol = NULL; + + // Wrapping skips upcoming blanks + while (s < text_end) + { + const char c = *s; + if (ImCharIsSpace(c)) { s++; } else if (c == '\n') { s++; break; } else { break; } + } + continue; + } + } + + // Decode and advance source + const char* prev_s = s; + unsigned int c = (unsigned int)*s; + if (c < 0x80) + { + s += 1; + } + else + { + s += ImTextCharFromUtf8(&c, s, text_end); + if (c == 0) // Malformed UTF-8? + break; + } + + if (c < 32) + { + if (c == '\n') + { + text_size.x = ImMax(text_size.x, line_width); + text_size.y += line_height; + line_width = 0.0f; + continue; + } + if (c == '\r') + continue; + } + + const float char_width = ((int)c < IndexAdvanceX.Size ? IndexAdvanceX[(int)c] : FallbackAdvanceX) * scale; + if (line_width + char_width >= max_width) + { + s = prev_s; + break; + } + + line_width += char_width; + } + + if (text_size.x < line_width) + text_size.x = line_width; + + if (line_width > 0 || text_size.y == 0.0f) + text_size.y += line_height; + + if (remaining) + *remaining = s; + + return text_size; +} + +void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, unsigned short c) const +{ + if (c == ' ' || c == '\t' || c == '\n' || c == '\r') // Match behavior of RenderText(), those 4 codepoints are hard-coded. + return; + if (const ImFontGlyph* glyph = FindGlyph(c)) + { + float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f; + pos.x = (float)(int)pos.x + DisplayOffset.x; + pos.y = (float)(int)pos.y + DisplayOffset.y; + draw_list->PrimReserve(6, 4); + draw_list->PrimRectUV(ImVec2(pos.x + glyph->X0 * scale, pos.y + glyph->Y0 * scale), ImVec2(pos.x + glyph->X1 * scale, pos.y + glyph->Y1 * scale), ImVec2(glyph->U0, glyph->V0), ImVec2(glyph->U1, glyph->V1), col); + } +} + +void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, bool cpu_fine_clip) const +{ + if (!text_end) + text_end = text_begin + strlen(text_begin); // ImGui functions generally already provides a valid text_end, so this is merely to handle direct calls. + + // Align to be pixel perfect + pos.x = (float)(int)pos.x + DisplayOffset.x; + pos.y = (float)(int)pos.y + DisplayOffset.y; + float x = pos.x; + float y = pos.y; + if (y > clip_rect.w) + return; + + const float scale = size / FontSize; + const float line_height = FontSize * scale; + const bool word_wrap_enabled = (wrap_width > 0.0f); + const char* word_wrap_eol = NULL; + + // Skip non-visible lines + const char* s = text_begin; + if (!word_wrap_enabled && y + line_height < clip_rect.y) + while (s < text_end && *s != '\n') // Fast-forward to next line + s++; + + // Reserve vertices for remaining worse case (over-reserving is useful and easily amortized) + const int vtx_count_max = (int)(text_end - s) * 4; + const int idx_count_max = (int)(text_end - s) * 6; + const int idx_expected_size = draw_list->IdxBuffer.Size + idx_count_max; + draw_list->PrimReserve(idx_count_max, vtx_count_max); + + ImDrawVert* vtx_write = draw_list->_VtxWritePtr; + ImDrawIdx* idx_write = draw_list->_IdxWritePtr; + unsigned int vtx_current_idx = draw_list->_VtxCurrentIdx; + + while (s < text_end) + { + if (word_wrap_enabled) + { + // Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature. + if (!word_wrap_eol) + { + word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - (x - pos.x)); + if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity. + word_wrap_eol++; // +1 may not be a character start point in UTF-8 but it's ok because we use s >= word_wrap_eol below + } + + if (s >= word_wrap_eol) + { + x = pos.x; + y += line_height; + word_wrap_eol = NULL; + + // Wrapping skips upcoming blanks + while (s < text_end) + { + const char c = *s; + if (ImCharIsSpace(c)) { s++; } else if (c == '\n') { s++; break; } else { break; } + } + continue; + } + } + + // Decode and advance source + unsigned int c = (unsigned int)*s; + if (c < 0x80) + { + s += 1; + } + else + { + s += ImTextCharFromUtf8(&c, s, text_end); + if (c == 0) // Malformed UTF-8? + break; + } + + if (c < 32) + { + if (c == '\n') + { + x = pos.x; + y += line_height; + + if (y > clip_rect.w) + break; + if (!word_wrap_enabled && y + line_height < clip_rect.y) + while (s < text_end && *s != '\n') // Fast-forward to next line + s++; + continue; + } + if (c == '\r') + continue; + } + + float char_width = 0.0f; + if (const ImFontGlyph* glyph = FindGlyph((unsigned short)c)) + { + char_width = glyph->AdvanceX * scale; + + // Arbitrarily assume that both space and tabs are empty glyphs as an optimization + if (c != ' ' && c != '\t') + { + // We don't do a second finer clipping test on the Y axis as we've already skipped anything before clip_rect.y and exit once we pass clip_rect.w + float x1 = x + glyph->X0 * scale; + float x2 = x + glyph->X1 * scale; + float y1 = y + glyph->Y0 * scale; + float y2 = y + glyph->Y1 * scale; + if (x1 <= clip_rect.z && x2 >= clip_rect.x) + { + // Render a character + float u1 = glyph->U0; + float v1 = glyph->V0; + float u2 = glyph->U1; + float v2 = glyph->V1; + + // CPU side clipping used to fit text in their frame when the frame is too small. Only does clipping for axis aligned quads. + if (cpu_fine_clip) + { + if (x1 < clip_rect.x) + { + u1 = u1 + (1.0f - (x2 - clip_rect.x) / (x2 - x1)) * (u2 - u1); + x1 = clip_rect.x; + } + if (y1 < clip_rect.y) + { + v1 = v1 + (1.0f - (y2 - clip_rect.y) / (y2 - y1)) * (v2 - v1); + y1 = clip_rect.y; + } + if (x2 > clip_rect.z) + { + u2 = u1 + ((clip_rect.z - x1) / (x2 - x1)) * (u2 - u1); + x2 = clip_rect.z; + } + if (y2 > clip_rect.w) + { + v2 = v1 + ((clip_rect.w - y1) / (y2 - y1)) * (v2 - v1); + y2 = clip_rect.w; + } + if (y1 >= y2) + { + x += char_width; + continue; + } + } + + // We are NOT calling PrimRectUV() here because non-inlined causes too much overhead in a debug builds. Inlined here: + { + idx_write[0] = (ImDrawIdx)(vtx_current_idx); idx_write[1] = (ImDrawIdx)(vtx_current_idx+1); idx_write[2] = (ImDrawIdx)(vtx_current_idx+2); + idx_write[3] = (ImDrawIdx)(vtx_current_idx); idx_write[4] = (ImDrawIdx)(vtx_current_idx+2); idx_write[5] = (ImDrawIdx)(vtx_current_idx+3); + vtx_write[0].pos.x = x1; vtx_write[0].pos.y = y1; vtx_write[0].col = col; vtx_write[0].uv.x = u1; vtx_write[0].uv.y = v1; + vtx_write[1].pos.x = x2; vtx_write[1].pos.y = y1; vtx_write[1].col = col; vtx_write[1].uv.x = u2; vtx_write[1].uv.y = v1; + vtx_write[2].pos.x = x2; vtx_write[2].pos.y = y2; vtx_write[2].col = col; vtx_write[2].uv.x = u2; vtx_write[2].uv.y = v2; + vtx_write[3].pos.x = x1; vtx_write[3].pos.y = y2; vtx_write[3].col = col; vtx_write[3].uv.x = u1; vtx_write[3].uv.y = v2; + vtx_write += 4; + vtx_current_idx += 4; + idx_write += 6; + } + } + } + } + + x += char_width; + } + + // Give back unused vertices + draw_list->VtxBuffer.resize((int)(vtx_write - draw_list->VtxBuffer.Data)); + draw_list->IdxBuffer.resize((int)(idx_write - draw_list->IdxBuffer.Data)); + draw_list->CmdBuffer[draw_list->CmdBuffer.Size-1].ElemCount -= (idx_expected_size - draw_list->IdxBuffer.Size); + draw_list->_VtxWritePtr = vtx_write; + draw_list->_IdxWritePtr = idx_write; + draw_list->_VtxCurrentIdx = (unsigned int)draw_list->VtxBuffer.Size; +} + +//----------------------------------------------------------------------------- +// Internals Drawing Helpers +//----------------------------------------------------------------------------- + +static inline float ImAcos01(float x) +{ + if (x <= 0.0f) return IM_PI * 0.5f; + if (x >= 1.0f) return 0.0f; + return acosf(x); + //return (-0.69813170079773212f * x * x - 0.87266462599716477f) * x + 1.5707963267948966f; // Cheap approximation, may be enough for what we do. +} + +// FIXME: Cleanup and move code to ImDrawList. +void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding) +{ + if (x_end_norm == x_start_norm) + return; + if (x_start_norm > x_end_norm) + ImSwap(x_start_norm, x_end_norm); + + ImVec2 p0 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_start_norm), rect.Min.y); + ImVec2 p1 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_end_norm), rect.Max.y); + if (rounding == 0.0f) + { + draw_list->AddRectFilled(p0, p1, col, 0.0f); + return; + } + + rounding = ImClamp(ImMin((rect.Max.x - rect.Min.x) * 0.5f, (rect.Max.y - rect.Min.y) * 0.5f) - 1.0f, 0.0f, rounding); + const float inv_rounding = 1.0f / rounding; + const float arc0_b = ImAcos01(1.0f - (p0.x - rect.Min.x) * inv_rounding); + const float arc0_e = ImAcos01(1.0f - (p1.x - rect.Min.x) * inv_rounding); + const float x0 = ImMax(p0.x, rect.Min.x + rounding); + if (arc0_b == arc0_e) + { + draw_list->PathLineTo(ImVec2(x0, p1.y)); + draw_list->PathLineTo(ImVec2(x0, p0.y)); + } + else if (arc0_b == 0.0f && arc0_e == IM_PI*0.5f) + { + draw_list->PathArcToFast(ImVec2(x0, p1.y - rounding), rounding, 3, 6); // BL + draw_list->PathArcToFast(ImVec2(x0, p0.y + rounding), rounding, 6, 9); // TR + } + else + { + draw_list->PathArcTo(ImVec2(x0, p1.y - rounding), rounding, IM_PI - arc0_e, IM_PI - arc0_b, 3); // BL + draw_list->PathArcTo(ImVec2(x0, p0.y + rounding), rounding, IM_PI + arc0_b, IM_PI + arc0_e, 3); // TR + } + if (p1.x > rect.Min.x + rounding) + { + const float arc1_b = ImAcos01(1.0f - (rect.Max.x - p1.x) * inv_rounding); + const float arc1_e = ImAcos01(1.0f - (rect.Max.x - p0.x) * inv_rounding); + const float x1 = ImMin(p1.x, rect.Max.x - rounding); + if (arc1_b == arc1_e) + { + draw_list->PathLineTo(ImVec2(x1, p0.y)); + draw_list->PathLineTo(ImVec2(x1, p1.y)); + } + else if (arc1_b == 0.0f && arc1_e == IM_PI*0.5f) + { + draw_list->PathArcToFast(ImVec2(x1, p0.y + rounding), rounding, 9, 12); // TR + draw_list->PathArcToFast(ImVec2(x1, p1.y - rounding), rounding, 0, 3); // BR + } + else + { + draw_list->PathArcTo(ImVec2(x1, p0.y + rounding), rounding, -arc1_e, -arc1_b, 3); // TR + draw_list->PathArcTo(ImVec2(x1, p1.y - rounding), rounding, +arc1_b, +arc1_e, 3); // BR + } + } + draw_list->PathFillConvex(col); +} + +//----------------------------------------------------------------------------- +// DEFAULT FONT DATA +//----------------------------------------------------------------------------- +// Compressed with stb_compress() then converted to a C array. +// Use the program in extra_fonts/binary_to_compressed_c.cpp to create the array from a TTF file. +// Decompression from stb.h (public domain) by Sean Barrett https://github.com/nothings/stb/blob/master/stb.h +//----------------------------------------------------------------------------- + +static unsigned int stb_decompress_length(unsigned char *input) +{ + return (input[8] << 24) + (input[9] << 16) + (input[10] << 8) + input[11]; +} + +static unsigned char *stb__barrier, *stb__barrier2, *stb__barrier3, *stb__barrier4; +static unsigned char *stb__dout; +static void stb__match(unsigned char *data, unsigned int length) +{ + // INVERSE of memmove... write each BYTE before copying the next... + IM_ASSERT (stb__dout + length <= stb__barrier); + if (stb__dout + length > stb__barrier) { stb__dout += length; return; } + if (data < stb__barrier4) { stb__dout = stb__barrier+1; return; } + while (length--) *stb__dout++ = *data++; +} + +static void stb__lit(unsigned char *data, unsigned int length) +{ + IM_ASSERT (stb__dout + length <= stb__barrier); + if (stb__dout + length > stb__barrier) { stb__dout += length; return; } + if (data < stb__barrier2) { stb__dout = stb__barrier+1; return; } + memcpy(stb__dout, data, length); + stb__dout += length; +} + +#define stb__in2(x) ((i[x] << 8) + i[(x)+1]) +#define stb__in3(x) ((i[x] << 16) + stb__in2((x)+1)) +#define stb__in4(x) ((i[x] << 24) + stb__in3((x)+1)) + +static unsigned char *stb_decompress_token(unsigned char *i) +{ + if (*i >= 0x20) { // use fewer if's for cases that expand small + if (*i >= 0x80) stb__match(stb__dout-i[1]-1, i[0] - 0x80 + 1), i += 2; + else if (*i >= 0x40) stb__match(stb__dout-(stb__in2(0) - 0x4000 + 1), i[2]+1), i += 3; + else /* *i >= 0x20 */ stb__lit(i+1, i[0] - 0x20 + 1), i += 1 + (i[0] - 0x20 + 1); + } else { // more ifs for cases that expand large, since overhead is amortized + if (*i >= 0x18) stb__match(stb__dout-(stb__in3(0) - 0x180000 + 1), i[3]+1), i += 4; + else if (*i >= 0x10) stb__match(stb__dout-(stb__in3(0) - 0x100000 + 1), stb__in2(3)+1), i += 5; + else if (*i >= 0x08) stb__lit(i+2, stb__in2(0) - 0x0800 + 1), i += 2 + (stb__in2(0) - 0x0800 + 1); + else if (*i == 0x07) stb__lit(i+3, stb__in2(1) + 1), i += 3 + (stb__in2(1) + 1); + else if (*i == 0x06) stb__match(stb__dout-(stb__in3(1)+1), i[4]+1), i += 5; + else if (*i == 0x04) stb__match(stb__dout-(stb__in3(1)+1), stb__in2(4)+1), i += 6; + } + return i; +} + +static unsigned int stb_adler32(unsigned int adler32, unsigned char *buffer, unsigned int buflen) +{ + const unsigned long ADLER_MOD = 65521; + unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16; + unsigned long blocklen, i; + + blocklen = buflen % 5552; + while (buflen) { + for (i=0; i + 7 < blocklen; i += 8) { + s1 += buffer[0], s2 += s1; + s1 += buffer[1], s2 += s1; + s1 += buffer[2], s2 += s1; + s1 += buffer[3], s2 += s1; + s1 += buffer[4], s2 += s1; + s1 += buffer[5], s2 += s1; + s1 += buffer[6], s2 += s1; + s1 += buffer[7], s2 += s1; + + buffer += 8; + } + + for (; i < blocklen; ++i) + s1 += *buffer++, s2 += s1; + + s1 %= ADLER_MOD, s2 %= ADLER_MOD; + buflen -= blocklen; + blocklen = 5552; + } + return (unsigned int)(s2 << 16) + (unsigned int)s1; +} + +static unsigned int stb_decompress(unsigned char *output, unsigned char *i, unsigned int length) +{ + unsigned int olen; + if (stb__in4(0) != 0x57bC0000) return 0; + if (stb__in4(4) != 0) return 0; // error! stream is > 4GB + olen = stb_decompress_length(i); + stb__barrier2 = i; + stb__barrier3 = i+length; + stb__barrier = output + olen; + stb__barrier4 = output; + i += 16; + + stb__dout = output; + for (;;) { + unsigned char *old_i = i; + i = stb_decompress_token(i); + if (i == old_i) { + if (*i == 0x05 && i[1] == 0xfa) { + IM_ASSERT(stb__dout == output + olen); + if (stb__dout != output + olen) return 0; + if (stb_adler32(1, output, olen) != (unsigned int) stb__in4(2)) + return 0; + return olen; + } else { + IM_ASSERT(0); /* NOTREACHED */ + return 0; + } + } + IM_ASSERT(stb__dout <= output + olen); + if (stb__dout > output + olen) + return 0; + } +} + +//----------------------------------------------------------------------------- +// ProggyClean.ttf +// Copyright (c) 2004, 2005 Tristan Grimmer +// MIT license (see License.txt in http://www.upperbounds.net/download/ProggyClean.ttf.zip) +// Download and more information at http://upperbounds.net +//----------------------------------------------------------------------------- +// File: 'ProggyClean.ttf' (41208 BYTEs) +// Exported using binary_to_compressed_c.cpp +//----------------------------------------------------------------------------- +static const char proggy_clean_ttf_compressed_data_base85[11980 + 1] = +"7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/" +"2*>]b(MC;$jPfY.;h^`IWM9Qo#t'X#(v#Y9w0#1D$CIf;W'#pWUPXOuxXuU(H9M(1=Ke$$'5F%)]0^#0X@U.a$FBjVQTSDgEKnIS7EM9>ZY9w0#L;>>#Mx&4Mvt//L[MkA#W@lK.N'[0#7RL_&#w+F%HtG9M#XL`N&.,GM4Pg;--VsM.M0rJfLH2eTM`*oJMHRC`N" +"kfimM2J,W-jXS:)r0wK#@Fge$U>`w'N7G#$#fB#$E^$#:9:hk+eOe--6x)F7*E%?76%^GMHePW-Z5l'&GiF#$956:rS?dA#fiK:)Yr+`�j@'DbG&#^$PG.Ll+DNa&VZ>1i%h1S9u5o@YaaW$e+bROPOpxTO7Stwi1::iB1q)C_=dV26J;2,]7op$]uQr@_V7$q^%lQwtuHY]=DX,n3L#0PHDO4f9>dC@O>HBuKPpP*E,N+b3L#lpR/MrTEH.IAQk.a>D[.e;mc." +"x]Ip.PH^'/aqUO/$1WxLoW0[iLAw=4h(9.`G" +"CRUxHPeR`5Mjol(dUWxZa(>STrPkrJiWx`5U7F#.g*jrohGg`cg:lSTvEY/EV_7H4Q9[Z%cnv;JQYZ5q.l7Zeas:HOIZOB?Ggv:[7MI2k).'2($5FNP&EQ(,)" +"U]W]+fh18.vsai00);D3@4ku5P?DP8aJt+;qUM]=+b'8@;mViBKx0DE[-auGl8:PJ&Dj+M6OC]O^((##]`0i)drT;-7X`=-H3[igUnPG-NZlo.#k@h#=Ork$m>a>$-?Tm$UV(?#P6YY#" +"'/###xe7q.73rI3*pP/$1>s9)W,JrM7SN]'/4C#v$U`0#V.[0>xQsH$fEmPMgY2u7Kh(G%siIfLSoS+MK2eTM$=5,M8p`A.;_R%#u[K#$x4AG8.kK/HSB==-'Ie/QTtG?-.*^N-4B/ZM" +"_3YlQC7(p7q)&](`6_c)$/*JL(L-^(]$wIM`dPtOdGA,U3:w2M-0+WomX2u7lqM2iEumMTcsF?-aT=Z-97UEnXglEn1K-bnEO`gu" +"Ft(c%=;Am_Qs@jLooI&NX;]0#j4#F14;gl8-GQpgwhrq8'=l_f-b49'UOqkLu7-##oDY2L(te+Mch&gLYtJ,MEtJfLh'x'M=$CS-ZZ%P]8bZ>#S?YY#%Q&q'3^Fw&?D)UDNrocM3A76/" +"/oL?#h7gl85[qW/NDOk%16ij;+:1a'iNIdb-ou8.P*w,v5#EI$TWS>Pot-R*H'-SEpA:g)f+O$%%`kA#G=8RMmG1&O`>to8bC]T&$,n.LoO>29sp3dt-52U%VM#q7'DHpg+#Z9%H[Ket`e;)f#Km8&+DC$I46>#Kr]]u-[=99tts1.qb#q72g1WJO81q+eN'03'eM>&1XxY-caEnO" +"j%2n8)),?ILR5^.Ibn<-X-Mq7[a82Lq:F&#ce+S9wsCK*x`569E8ew'He]h:sI[2LM$[guka3ZRd6:t%IG:;$%YiJ:Nq=?eAw;/:nnDq0(CYcMpG)qLN4$##&J-XTt,%OVU4)S1+R-#dg0/Nn?Ku1^0f$B*P:Rowwm-`0PKjYDDM'3]d39VZHEl4,.j']Pk-M.h^&:0FACm$maq-&sgw0t7/6(^xtk%" +"LuH88Fj-ekm>GA#_>568x6(OFRl-IZp`&b,_P'$MhLbxfc$mj`,O;&%W2m`Zh:/)Uetw:aJ%]K9h:TcF]u_-Sj9,VK3M.*'&0D[Ca]J9gp8,kAW]" +"%(?A%R$f<->Zts'^kn=-^@c4%-pY6qI%J%1IGxfLU9CP8cbPlXv);C=b),<2mOvP8up,UVf3839acAWAW-W?#ao/^#%KYo8fRULNd2.>%m]UK:n%r$'sw]J;5pAoO_#2mO3n,'=H5(et" +"Hg*`+RLgv>=4U8guD$I%D:W>-r5V*%j*W:Kvej.Lp$'?;++O'>()jLR-^u68PHm8ZFWe+ej8h:9r6L*0//c&iH&R8pRbA#Kjm%upV1g:" +"a_#Ur7FuA#(tRh#.Y5K+@?3<-8m0$PEn;J:rh6?I6uG<-`wMU'ircp0LaE_OtlMb&1#6T.#FDKu#1Lw%u%+GM+X'e?YLfjM[VO0MbuFp7;>Q&#WIo)0@F%q7c#4XAXN-U&VBpqB>0ie&jhZ[?iLR@@_AvA-iQC(=ksRZRVp7`.=+NpBC%rh&3]R:8XDmE5^V8O(x<-+k?'(^](H.aREZSi,#1:[IXaZFOm<-ui#qUq2$##Ri;u75OK#(RtaW-K-F`S+cF]uN`-KMQ%rP/Xri.LRcB##=YL3BgM/3M" +"D?@f&1'BW-)Ju#bmmWCMkk&#TR`C,5d>g)F;t,4:@_l8G/5h4vUd%&%950:VXD'QdWoY-F$BtUwmfe$YqL'8(PWX(" +"P?^@Po3$##`MSs?DWBZ/S>+4%>fX,VWv/w'KD`LP5IbH;rTV>n3cEK8U#bX]l-/V+^lj3;vlMb&[5YQ8#pekX9JP3XUC72L,,?+Ni&co7ApnO*5NK,((W-i:$,kp'UDAO(G0Sq7MVjJs" +"bIu)'Z,*[>br5fX^:FPAWr-m2KgLQ_nN6'8uTGT5g)uLv:873UpTLgH+#FgpH'_o1780Ph8KmxQJ8#H72L4@768@Tm&Q" +"h4CB/5OvmA&,Q&QbUoi$a_%3M01H)4x7I^&KQVgtFnV+;[Pc>[m4k//,]1?#`VY[Jr*3&&slRfLiVZJ:]?=K3Sw=[$=uRB?3xk48@aege0jT6'N#(q%.O=?2S]u*(m<-" +"V8J'(1)G][68hW$5'q[GC&5j`TE?m'esFGNRM)j,ffZ?-qx8;->g4t*:CIP/[Qap7/9'#(1sao7w-.qNUdkJ)tCF&#B^;xGvn2r9FEPFFFcL@.iFNkTve$m%#QvQS8U@)2Z+3K:AKM5i" +"sZ88+dKQ)W6>J%CL`.d*(B`-n8D9oK-XV1q['-5k'cAZ69e;D_?$ZPP&s^+7])$*$#@QYi9,5P r+$%CE=68>K8r0=dSC%%(@p7" +".m7jilQ02'0-VWAgTlGW'b)Tq7VT9q^*^$$.:&N@@" +"$&)WHtPm*5_rO0&e%K&#-30j(E4#'Zb.o/(Tpm$>K'f@[PvFl,hfINTNU6u'0pao7%XUp9]5.>%h`8_=VYbxuel.NTSsJfLacFu3B'lQSu/m6-Oqem8T+oE--$0a/k]uj9EwsG>%veR*" +"hv^BFpQj:K'#SJ,sB-'#](j.Lg92rTw-*n%@/;39rrJF,l#qV%OrtBeC6/,;qB3ebNW[?,Hqj2L.1NP&GjUR=1D8QaS3Up&@*9wP?+lo7b?@%'k4`p0Z$22%K3+iCZj?XJN4Nm&+YF]u" +"@-W$U%VEQ/,,>>#)D#%8cY#YZ?=,`Wdxu/ae&#" +"w6)R89tI#6@s'(6Bf7a&?S=^ZI_kS&ai`&=tE72L_D,;^R)7[$so8lKN%5/$(vdfq7+ebA#" +"u1p]ovUKW&Y%q]'>$1@-[xfn$7ZTp7mM,G,Ko7a&Gu%G[RMxJs[0MM%wci.LFDK)(%:_i2B5CsR8&9Z&#=mPEnm0f`<&c)QL5uJ#%u%lJj+D-r;BoFDoS97h5g)E#o:&S4weDF,9^Hoe`h*L+_a*NrLW-1pG_&2UdB8" +"6e%B/:=>)N4xeW.*wft-;$'58-ESqr#U`'6AQ]m&6/`Z>#S?YY#Vc;r7U2&326d=w&H####?TZ`*4?&.MK?LP8Vxg>$[QXc%QJv92.(Db*B)gb*BM9dM*hJMAo*c&#" +"b0v=Pjer]$gG&JXDf->'StvU7505l9$AFvgYRI^&<^b68?j#q9QX4SM'RO#&sL1IM.rJfLUAj221]d##DW=m83u5;'bYx,*Sl0hL(W;;$doB&O/TQ:(Z^xBdLjLV#*8U_72Lh+2Q8Cj0i:6hp&$C/:p(HK>T8Y[gHQ4`4)'$Ab(Nof%V'8hL&#SfD07&6D@M.*J:;$-rv29'M]8qMv-tLp,'886iaC=Hb*YJoKJ,(j%K=H`K.v9HggqBIiZu'QvBT.#=)0ukruV&.)3=(^1`o*Pj4<-#MJ+gLq9-##@HuZPN0]u:h7.T..G:;$/Usj(T7`Q8tT72LnYl<-qx8;-HV7Q-&Xdx%1a,hC=0u+HlsV>nuIQL-5" +"_>@kXQtMacfD.m-VAb8;IReM3$wf0''hra*so568'Ip&vRs849'MRYSp%:t:h5qSgwpEr$B>Q,;s(C#$)`svQuF$##-D,##,g68@2[T;.XSdN9Qe)rpt._K-#5wF)sP'##p#C0c%-Gb%" +"hd+<-j'Ai*x&&HMkT]C'OSl##5RG[JXaHN;d'uA#x._U;.`PU@(Z3dt4r152@:v,'R.Sj'w#0<-;kPI)FfJ&#AYJ&#//)>-k=m=*XnK$>=)72L]0I%>.G690a:$##<,);?;72#?x9+d;" +"^V'9;jY@;)br#q^YQpx:X#Te$Z^'=-=bGhLf:D6&bNwZ9-ZD#n^9HhLMr5G;']d&6'wYmTFmLq9wI>P(9mI[>kC-ekLC/R&CH+s'B;K-M6$EB%is00:" +"+A4[7xks.LrNk0&E)wILYF@2L'0Nb$+pv<(2.768/FrY&h$^3i&@+G%JT'<-,v`3;_)I9M^AE]CN?Cl2AZg+%4iTpT3$U4O]GKx'm9)b@p7YsvK3w^YR-" +"CdQ*:Ir<($u&)#(&?L9Rg3H)4fiEp^iI9O8KnTj,]H?D*r7'M;PwZ9K0E^k&-cpI;.p/6_vwoFMV<->#%Xi.LxVnrU(4&8/P+:hLSKj$#U%]49t'I:rgMi'FL@a:0Y-uA[39',(vbma*" +"hU%<-SRF`Tt:542R_VV$p@[p8DV[A,?1839FWdFTi1O*H&#(AL8[_P%.M>v^-))qOT*F5Cq0`Ye%+$B6i:7@0IXSsDiWP,##P`%/L-" +"S(qw%sf/@%#B6;/U7K]uZbi^Oc^2n%t<)'mEVE''n`WnJra$^TKvX5B>;_aSEK',(hwa0:i4G?.Bci.(X[?b*($,=-n<.Q%`(X=?+@Am*Js0&=3bh8K]mL69=Lb,OcZV/);TTm8VI;?%OtJ<(b4mq7M6:u?KRdFl*:xP?Yb.5)%w_I?7uk5JC+FS(m#i'k.'a0i)9<7b'fs'59hq$*5Uhv##pi^8+hIEBF`nvo`;'l0.^S1<-wUK2/Coh58KKhLj" +"M=SO*rfO`+qC`W-On.=AJ56>>i2@2LH6A:&5q`?9I3@@'04&p2/LVa*T-4<-i3;M9UvZd+N7>b*eIwg:CC)c<>nO&#$(>.Z-I&J(Q0Hd5Q%7Co-b`-cP)hI;*_F]u`Rb[.j8_Q/<&>uu+VsH$sM9TA%?)(vmJ80),P7E>)tjD%2L=-t#fK[%`v=Q8WlA2);Sa" +">gXm8YB`1d@K#n]76-a$U,mF%Ul:#/'xoFM9QX-$.QN'>" +"[%$Z$uF6pA6Ki2O5:8w*vP1<-1`[G,)-m#>0`P&#eb#.3i)rtB61(o'$?X3B2Qft^ae_5tKL9MUe9b*sLEQ95C&`=G?@Mj=wh*'3E>=-<)Gt*Iw)'QG:`@I" +"wOf7&]1i'S01B+Ev/Nac#9S;=;YQpg_6U`*kVY39xK,[/6Aj7:'1Bm-_1EYfa1+o&o4hp7KN_Q(OlIo@S%;jVdn0'1h19w,WQhLI)3S#f$2(eb,jr*b;3Vw]*7NH%$c4Vs,eD9>XW8?N]o+(*pgC%/72LV-uW%iewS8W6m2rtCpo'RS1R84=@paTKt)>=%&1[)*vp'u+x,VrwN;&]kuO9JDbg=pO$J*.jVe;u'm0dr9l,<*wMK*Oe=g8lV_KEBFkO'oU]^=[-792#ok,)" +"i]lR8qQ2oA8wcRCZ^7w/Njh;?.stX?Q1>S1q4Bn$)K1<-rGdO'$Wr.Lc.CG)$/*JL4tNR/,SVO3,aUw'DJN:)Ss;wGn9A32ijw%FL+Z0Fn.U9;reSq)bmI32U==5ALuG&#Vf1398/pVo" +"1*c-(aY168o<`JsSbk-,1N;$>0:OUas(3:8Z972LSfF8eb=c-;>SPw7.6hn3m`9^Xkn(r.qS[0;T%&Qc=+STRxX'q1BNk3&*eu2;&8q$&x>Q#Q7^Tf+6<(d%ZVmj2bDi%.3L2n+4W'$P" +"iDDG)g,r%+?,$@?uou5tSe2aN_AQU*'IAO" +"URQ##V^Fv-XFbGM7Fl(N<3DhLGF%q.1rC$#:T__&Pi68%0xi_&[qFJ(77j_&JWoF.V735&T,[R*:xFR*K5>>#`bW-?4Ne_&6Ne_&6Ne_&n`kr-#GJcM6X;uM6X;uM(.a..^2TkL%oR(#" +";u.T%fAr%4tJ8&><1=GHZ_+m9/#H1F^R#SC#*N=BA9(D?v[UiFY>>^8p,KKF.W]L29uLkLlu/+4T" +"w$)F./^n3+rlo+DB;5sIYGNk+i1t-69Jg--0pao7Sm#K)pdHW&;LuDNH@H>#/X-TI(;P>#,Gc>#0Su>#4`1?#8lC?#xL$#B.`$#F:r$#JF.%#NR@%#R_R%#Vke%#Zww%#_-4^Rh%Sflr-k'MS.o?.5/sWel/wpEM0%3'/1)K^f1-d>G21&v(35>V`39V7A4=onx4" +"A1OY5EI0;6Ibgr6M$HS7Q<)58C5w,;WoA*#[%T*#`1g*#d=#+#hI5+#lUG+#pbY+#tnl+#x$),#&1;,#*=M,#.I`,#2Ur,#6b.-#;w[H#iQtA#m^0B#qjBB#uvTB##-hB#'9$C#+E6C#" +"/QHC#3^ZC#7jmC#;v)D#?,)4kMYD4lVu`4m`:&5niUA5@(A5BA1]PBB:xlBCC=2CDLXMCEUtiCf&0g2'tN?PGT4CPGT4CPGT4CPGT4CPGT4CPGT4CPGT4CP" +"GT4CPGT4CPGT4CPGT4CPGT4CPGT4CP-qekC`.9kEg^+F$kwViFJTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5o,^<-28ZI'O?;xp" +"O?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xp;7q-#lLYI:xvD=#"; + +static const char* GetDefaultCompressedFontDataTTFBase85() +{ + return proggy_clean_ttf_compressed_data_base85; +} + +``` + +`imgui/imgui_impl_dx9.cpp`: + +```cpp +// ImGui Win32 + DirectX9 binding +// In this binding, ImTextureID is used to store a 'LPDIRECT3DTEXTURE9' texture identifier. Read the FAQ about ImTextureID in imgui.cpp. + +// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. +// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). +// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// https://github.com/ocornut/imgui + +#include "imgui.h" +#include "imgui_impl_dx9.h" + +// directx +#include +#define DIRECTINPUT_VERSION 0x0800 +#include + +// Data +static HWND g_hWnd = 0; +static INT64 g_Time = 0; +static INT64 g_TicksPerSecond = 0; +static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; +static LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL; +static LPDIRECT3DINDEXBUFFER9 g_pIB = NULL; +static LPDIRECT3DTEXTURE9 g_FontTexture = NULL; +static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000; + +struct CUSTOMVERTEX +{ + float pos[3]; + D3DCOLOR col; + float uv[2]; +}; +#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) + +// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure) +// If text or lines are blurry when integrating ImGui in your engine: +// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f) +void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data) +{ + // Avoid rendering when minimized + ImGuiIO& io = ImGui::GetIO(); + if (io.DisplaySize.x <= 0.0f || io.DisplaySize.y <= 0.0f) + return; + + // Create and grow buffers if needed + if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount) + { + if (g_pVB) { g_pVB->Release(); g_pVB = NULL; } + g_VertexBufferSize = draw_data->TotalVtxCount + 5000; + if (g_pd3dDevice->CreateVertexBuffer(g_VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0) + return; + } + if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount) + { + if (g_pIB) { g_pIB->Release(); g_pIB = NULL; } + g_IndexBufferSize = draw_data->TotalIdxCount + 10000; + if (g_pd3dDevice->CreateIndexBuffer(g_IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &g_pIB, NULL) < 0) + return; + } + + // Backup the DX9 state + IDirect3DStateBlock9* d3d9_state_block = NULL; + if (g_pd3dDevice->CreateStateBlock(D3DSBT_PIXELSTATE, &d3d9_state_block) < 0) + return; + + // Copy and convert all vertices into a single contiguous buffer + CUSTOMVERTEX* vtx_dst; + ImDrawIdx* idx_dst; + if (g_pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0) + return; + if (g_pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0) + return; + for (int n = 0; n < draw_data->CmdListsCount; n++) + { + const ImDrawList* cmd_list = draw_data->CmdLists[n]; + const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data; + for (int i = 0; i < cmd_list->VtxBuffer.Size; i++) + { + vtx_dst->pos[0] = vtx_src->pos.x; + vtx_dst->pos[1] = vtx_src->pos.y; + vtx_dst->pos[2] = 0.0f; + vtx_dst->col = (vtx_src->col & 0xFF00FF00) | ((vtx_src->col & 0xFF0000)>>16) | ((vtx_src->col & 0xFF) << 16); // RGBA --> ARGB for DirectX9 + vtx_dst->uv[0] = vtx_src->uv.x; + vtx_dst->uv[1] = vtx_src->uv.y; + vtx_dst++; + vtx_src++; + } + memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); + idx_dst += cmd_list->IdxBuffer.Size; + } + g_pVB->Unlock(); + g_pIB->Unlock(); + g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX)); + g_pd3dDevice->SetIndices(g_pIB); + g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX); + + // Setup viewport + D3DVIEWPORT9 vp; + vp.X = vp.Y = 0; + vp.Width = (DWORD)io.DisplaySize.x; + vp.Height = (DWORD)io.DisplaySize.y; + vp.MinZ = 0.0f; + vp.MaxZ = 1.0f; + g_pd3dDevice->SetViewport(&vp); + + // Setup render state: fixed-pipeline, alpha-blending, no face culling, no depth testing + g_pd3dDevice->SetPixelShader(NULL); + g_pd3dDevice->SetVertexShader(NULL); + g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); + g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, false); + g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, false); + g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true); + g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, false); + g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); + g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, true); + g_pd3dDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0xFFFFFFFF); + g_pd3dDevice->SetRenderState(D3DRS_SRGBWRITEENABLE, false); + g_pd3dDevice->SetSamplerState(NULL, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP); + g_pd3dDevice->SetSamplerState(NULL, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP); + g_pd3dDevice->SetSamplerState(NULL, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP); + g_pd3dDevice->SetSamplerState(NULL, D3DSAMP_SRGBTEXTURE, NULL); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); + g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); + g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); + + // Setup orthographic projection matrix + // Being agnostic of whether or can be used, we aren't relying on D3DXMatrixIdentity()/D3DXMatrixOrthoOffCenterLH() or directx::XMMatrixIdentity()/directx::XMMatrixOrthographicOffCenterLH() + { + const float L = 0.5f, R = io.DisplaySize.x+0.5f, T = 0.5f, B = io.DisplaySize.y+0.5f; + D3DMATRIX mat_identity = { { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } }; + D3DMATRIX mat_projection = + { + 2.0f/(R-L), 0.0f, 0.0f, 0.0f, + 0.0f, 2.0f/(T-B), 0.0f, 0.0f, + 0.0f, 0.0f, 0.5f, 0.0f, + (L+R)/(L-R), (T+B)/(B-T), 0.5f, 1.0f, + }; + g_pd3dDevice->SetTransform(D3DTS_WORLD, &mat_identity); + g_pd3dDevice->SetTransform(D3DTS_VIEW, &mat_identity); + g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat_projection); + } + + // Render command lists + int vtx_offset = 0; + int idx_offset = 0; + for (int n = 0; n < draw_data->CmdListsCount; n++) + { + const ImDrawList* cmd_list = draw_data->CmdLists[n]; + for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) + { + const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; + if (pcmd->UserCallback) + { + pcmd->UserCallback(cmd_list, pcmd); + } + else + { + const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w }; + g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId); + //g_pd3dDevice->SetPixelShader((LPDIRECT3DPIXELSHADER9)pcmd->ShaderID); + g_pd3dDevice->SetScissorRect(&r); + g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3); + } + idx_offset += pcmd->ElemCount; + } + vtx_offset += cmd_list->VtxBuffer.Size; + } + + // Restore the DX9 state + d3d9_state_block->Apply(); + d3d9_state_block->Release(); +} + +static bool IsAnyMouseButtonDown() +{ + ImGuiIO& io = ImGui::GetIO(); + for (int n = 0; n < IM_ARRAYSIZE(io.MouseDown); n++) + if (io.MouseDown[n]) + return true; + return false; +} + +// Process Win32 mouse/keyboard inputs. +// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. +// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. +// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. +// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. +// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinations when dragging mouse outside of our window bounds. +// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag. +IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + ImGuiIO& io = ImGui::GetIO(); + switch (msg) + { + case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: + case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: + case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK: + { + int button = 0; + if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) button = 0; + if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) button = 1; + if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) button = 2; + if (!IsAnyMouseButtonDown() && GetCapture() == NULL) + SetCapture(hwnd); + io.MouseDown[button] = true; + return 1; + } + case WM_LBUTTONUP: + case WM_RBUTTONUP: + case WM_MBUTTONUP: + { + int button = 0; + if (msg == WM_LBUTTONUP) button = 0; + if (msg == WM_RBUTTONUP) button = 1; + if (msg == WM_MBUTTONUP) button = 2; + io.MouseDown[button] = false; + if (!IsAnyMouseButtonDown() && GetCapture() == hwnd) + ReleaseCapture(); + return 1; + } + case WM_MOUSEWHEEL: + io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f; + return 1; + case WM_MOUSEMOVE: + io.MousePos.x = (signed short)(lParam); + io.MousePos.y = (signed short)(lParam >> 16); + return 1; + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + if (wParam < 256) + io.KeysDown[wParam] = 1; + return 1; + case WM_KEYUP: + case WM_SYSKEYUP: + if (wParam < 256) + io.KeysDown[wParam] = 0; + return 1; + case WM_CHAR: + // You can also use ToAscii()+GetKeyboardState() to retrieve characters. + wchar_t wch; + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (char*)&wParam, 1, &wch, 1); + io.AddInputCharacter(wch); + /*if (wParam > 0 && wParam < 0x10000) + io.AddInputCharacter((unsigned short)wParam);*/ + return 1; + } + return 0; +} + +bool ImGui_ImplDX9_Init(void* hwnd, IDirect3DDevice9* device) +{ + g_hWnd = (HWND)hwnd; + g_pd3dDevice = device; + + if (!QueryPerformanceFrequency((LARGE_INTEGER *)&g_TicksPerSecond)) + return false; + if (!QueryPerformanceCounter((LARGE_INTEGER *)&g_Time)) + return false; + + ImGuiIO& io = ImGui::GetIO(); + io.KeyMap[ImGuiKey_Tab] = VK_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime. + io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT; + io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT; + io.KeyMap[ImGuiKey_UpArrow] = VK_UP; + io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN; + io.KeyMap[ImGuiKey_PageUp] = VK_PRIOR; + io.KeyMap[ImGuiKey_PageDown] = VK_NEXT; + io.KeyMap[ImGuiKey_Home] = VK_HOME; + io.KeyMap[ImGuiKey_End] = VK_END; + io.KeyMap[ImGuiKey_Insert] = VK_INSERT; + io.KeyMap[ImGuiKey_Delete] = VK_DELETE; + io.KeyMap[ImGuiKey_Backspace] = VK_BACK; + io.KeyMap[ImGuiKey_Enter] = VK_RETURN; + io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE; + io.KeyMap[ImGuiKey_A] = 'A'; + io.KeyMap[ImGuiKey_C] = 'C'; + io.KeyMap[ImGuiKey_V] = 'V'; + io.KeyMap[ImGuiKey_X] = 'X'; + io.KeyMap[ImGuiKey_Y] = 'Y'; + io.KeyMap[ImGuiKey_Z] = 'Z'; + + io.RenderDrawListsFn = ImGui_ImplDX9_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer. + io.ImeWindowHandle = g_hWnd; + + return true; +} + +void ImGui_ImplDX9_Shutdown() +{ + ImGui_ImplDX9_InvalidateDeviceObjects(); + ImGui::Shutdown(); + g_pd3dDevice = NULL; + g_hWnd = 0; +} + +static bool ImGui_ImplDX9_CreateFontsTexture() +{ + // Build texture atlas + ImGuiIO& io = ImGui::GetIO(); + unsigned char* pixels; + int width, height, BYTEs_per_pixel; + io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &BYTEs_per_pixel); + + // Upload texture to graphics system + g_FontTexture = NULL; + if (g_pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_FontTexture, NULL) < 0) + return false; + D3DLOCKED_RECT tex_locked_rect; + if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) + return false; + for (int y = 0; y < height; y++) + memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * BYTEs_per_pixel) * y, (width * BYTEs_per_pixel)); + g_FontTexture->UnlockRect(0); + + // Store our identifier + io.Fonts->TexID = (void *)g_FontTexture; + + return true; +} + +bool ImGui_ImplDX9_CreateDeviceObjects() +{ + if (!g_pd3dDevice) + return false; + if (!ImGui_ImplDX9_CreateFontsTexture()) + return false; + return true; +} + +void ImGui_ImplDX9_InvalidateDeviceObjects() +{ + if (!g_pd3dDevice) + return; + if (g_pVB) + { + g_pVB->Release(); + g_pVB = NULL; + } + if (g_pIB) + { + g_pIB->Release(); + g_pIB = NULL; + } + + // At this point note that we set ImGui::GetIO().Fonts->TexID to be == g_FontTexture, so clear both. + ImGuiIO& io = ImGui::GetIO(); + IM_ASSERT(g_FontTexture == io.Fonts->TexID); + if (g_FontTexture) + g_FontTexture->Release(); + g_FontTexture = NULL; + io.Fonts->TexID = NULL; +} + +void ImGui_ImplDX9_NewFrame() +{ + if (!g_FontTexture) + ImGui_ImplDX9_CreateDeviceObjects(); + + ImGuiIO& io = ImGui::GetIO(); + + // Setup display size (every frame to accommodate for window resizing) + RECT rect; + GetClientRect(g_hWnd, &rect); + io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top)); + + // Setup time step + INT64 current_time; + QueryPerformanceCounter((LARGE_INTEGER *)¤t_time); + io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond; + g_Time = current_time; + + // Read keyboard modifiers inputs + io.KeyCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0; + io.KeyShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0; + io.KeyAlt = (GetKeyState(VK_MENU) & 0x8000) != 0; + io.KeySuper = false; + // io.KeysDown : filled by WM_KEYDOWN/WM_KEYUP events + // io.MousePos : filled by WM_MOUSEMOVE events + // io.MouseDown : filled by WM_*BUTTON* events + // io.MouseWheel : filled by WM_MOUSEWHEEL events + + // set OS mouse position if requested last frame by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation) + if (io.WantMoveMouse) + { + POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y }; + ClientToScreen(g_hWnd, &pos); + SetCursorPos(pos.x, pos.y); + } + + // Hide OS mouse cursor if ImGui is drawing it + if (io.MouseDrawCursor) + SetCursor(NULL); + + // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application. + ImGui::NewFrame(); +} + +``` + +`imgui/imgui_impl_dx9.h`: + +```h +// ImGui Win32 + DirectX9 binding +// In this binding, ImTextureID is used to store a 'LPDIRECT3DTEXTURE9' texture identifier. Read the FAQ about ImTextureID in imgui.cpp. + +// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. +// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). +// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// https://github.com/ocornut/imgui + +struct IDirect3DDevice9; + +IMGUI_API bool ImGui_ImplDX9_Init(void* hwnd, IDirect3DDevice9* device); +IMGUI_API void ImGui_ImplDX9_Shutdown(); +IMGUI_API void ImGui_ImplDX9_NewFrame(); + +// Use if you want to reset your rendering device without losing ImGui state. +IMGUI_API void ImGui_ImplDX9_InvalidateDeviceObjects(); +IMGUI_API bool ImGui_ImplDX9_CreateDeviceObjects(); +IMGUI_API void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data); + +// Handler for Win32 messages, update mouse/keyboard data. +// You may or not need this for your implementation, but it can serve as reference for handling inputs. +// Commented out to avoid dragging dependencies on types. You can copy the extern declaration in your code. +/* +IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +*/ + +``` + +`imgui/imgui_internal.h`: + +```h +// dear imgui, v1.54 WIP +// (internals) + +// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility! +// set: +// #define IMGUI_DEFINE_MATH_OPERATORS +// To implement maths operators for ImVec2 (disabled by default to not collide with using IM_VEC2_CLASS_EXTRA along with your own math types+operators) + +#pragma once + +#ifndef IMGUI_VERSION +#error Must include imgui.h before imgui_internal.h +#endif + +#include // FILE* +#include // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf + +#ifdef _MSC_VER +#pragma warning (push) +#pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport) +#endif + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-function" // for stb_textedit.h +#pragma clang diagnostic ignored "-Wmissing-prototypes" // for stb_textedit.h +#pragma clang diagnostic ignored "-Wold-style-cast" +#endif + +//----------------------------------------------------------------------------- +// Forward Declarations +//----------------------------------------------------------------------------- + +struct ImRect; +struct ImGuiColMod; +struct ImGuiStyleMod; +struct ImGuiGroupData; +struct ImGuiMenuColumns; +struct ImGuiDrawContext; +struct ImGuiTextEditState; +struct ImGuiMouseCursorData; +struct ImGuiPopupRef; +struct ImGuiWindow; +struct ImGuiWindowSettings; + +typedef int ImGuiLayoutType; // enum: horizontal or vertical // enum ImGuiLayoutType_ +typedef int ImGuiButtonFlags; // flags: for ButtonEx(), ButtonBehavior() // enum ImGuiButtonFlags_ +typedef int ImGuiItemFlags; // flags: for PushItemFlag() // enum ImGuiItemFlags_ +typedef int ImGuiSeparatorFlags; // flags: for Separator() - internal // enum ImGuiSeparatorFlags_ +typedef int ImGuiSliderFlags; // flags: for SliderBehavior() // enum ImGuiSliderFlags_ + +//------------------------------------------------------------------------- +// STB libraries +//------------------------------------------------------------------------- + +namespace ImGuiStb +{ + +#undef STB_TEXTEDIT_STRING +#undef STB_TEXTEDIT_CHARTYPE +#define STB_TEXTEDIT_STRING ImGuiTextEditState +#define STB_TEXTEDIT_CHARTYPE ImWchar +#define STB_TEXTEDIT_GETWIDTH_NEWLINE -1.0f +#include "stb_textedit.h" + +} // namespace ImGuiStb + +//----------------------------------------------------------------------------- +// Context +//----------------------------------------------------------------------------- + +#ifndef GImGui +extern IMGUI_API ImGuiContext* GImGui; // Current implicit ImGui context pointer +#endif + +//----------------------------------------------------------------------------- +// Helpers +//----------------------------------------------------------------------------- + +#define IM_PI 3.14159265358979323846f + +// Helpers: UTF-8 <> wchar +IMGUI_API int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 BYTEs count +IMGUI_API int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // return input UTF-8 BYTEs count +IMGUI_API int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 BYTEs count +IMGUI_API int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end); // return number of UTF-8 code-points (NOT BYTEs count) +IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of BYTEs to express string as UTF-8 code-points + +// Helpers: Misc +IMGUI_API ImU32 ImHash(const void* data, int data_size, ImU32 seed = 0); // Pass data_size==0 for zero-terminated strings +IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, int* out_file_size = NULL, int padding_BYTEs = 0); +IMGUI_API FILE* ImFileOpen(const char* filename, const char* file_open_mode); +static inline bool ImCharIsSpace(int c) { return c == ' ' || c == '\t' || c == 0x3000; } +static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; } +static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; } + +// Helpers: Geometry +IMGUI_API ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p); +IMGUI_API bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p); +IMGUI_API ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p); +IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w); + +// Helpers: String +IMGUI_API int ImStricmp(const char* str1, const char* str2); +IMGUI_API int ImStrnicmp(const char* str1, const char* str2, size_t count); +IMGUI_API void ImStrncpy(char* dst, const char* src, size_t count); +IMGUI_API char* ImStrdup(const char* str); +IMGUI_API char* ImStrchrRange(const char* str_begin, const char* str_end, char c); +IMGUI_API int ImStrlenW(const ImWchar* str); +IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line +IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end); +IMGUI_API int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3); +IMGUI_API int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3); + +// Helpers: Math +// We are keeping those not leaking to the user by default, in the case the user has implicit cast operators between ImVec2 and its own types (when IM_VEC2_CLASS_EXTRA is defined) +#ifdef IMGUI_DEFINE_MATH_OPERATORS +static inline ImVec2 operator*(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x*rhs, lhs.y*rhs); } +static inline ImVec2 operator/(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x/rhs, lhs.y/rhs); } +static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); } +static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x-rhs.x, lhs.y-rhs.y); } +static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x*rhs.x, lhs.y*rhs.y); } +static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x/rhs.x, lhs.y/rhs.y); } +static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; } +static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; } +static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; } +static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; } +static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z, lhs.w+rhs.w); } +static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x-rhs.x, lhs.y-rhs.y, lhs.z-rhs.z, lhs.w-rhs.w); } +static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z, lhs.w*rhs.w); } +#endif + +static inline int ImMin(int lhs, int rhs) { return lhs < rhs ? lhs : rhs; } +static inline int ImMax(int lhs, int rhs) { return lhs >= rhs ? lhs : rhs; } +static inline float ImMin(float lhs, float rhs) { return lhs < rhs ? lhs : rhs; } +static inline float ImMax(float lhs, float rhs) { return lhs >= rhs ? lhs : rhs; } +static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); } +static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); } +static inline int ImClamp(int v, int mn, int mx) { return (v < mn) ? mn : (v > mx) ? mx : v; } +static inline float ImClamp(float v, float mn, float mx) { return (v < mn) ? mn : (v > mx) ? mx : v; } +static inline ImVec2 ImClamp(const ImVec2& f, const ImVec2& mn, ImVec2 mx) { return ImVec2(ImClamp(f.x,mn.x,mx.x), ImClamp(f.y,mn.y,mx.y)); } +static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; } +static inline void ImSwap(int& a, int& b) { int tmp = a; a = b; b = tmp; } +static inline void ImSwap(float& a, float& b) { float tmp = a; a = b; b = tmp; } +static inline int ImLerp(int a, int b, float t) { return (int)(a + (b - a) * t); } +static inline float ImLerp(float a, float b, float t) { return a + (b - a) * t; } +static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); } +static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); } +static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); } +static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; } +static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; } +static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / sqrtf(d); return fail_value; } +static inline float ImFloor(float f) { return (float)(int)f; } +static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)v.x, (float)(int)v.y); } +static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; } +static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); } +static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; } +static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); } + +// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax. +// Defining a custom placement new() with a dummy parameter allows us to bypass including which on some platforms complains when user has disabled exceptions. +struct ImNewPlacementDummy {}; +inline void* operator new(size_t, ImNewPlacementDummy, void* ptr) { return ptr; } +inline void operator delete(void*, ImNewPlacementDummy, void*) {} // This is only required so we can use the symetrical new() +#define IM_PLACEMENT_NEW(_PTR) new(ImNewPlacementDummy(), _PTR) +#define IM_NEW(_TYPE) new(ImNewPlacementDummy(), ImGui::MemAlloc(sizeof(_TYPE))) _TYPE +template void IM_DELETE(T*& p) { if (p) { p->~T(); ImGui::MemFree(p); p = NULL; } } + +//----------------------------------------------------------------------------- +// Types +//----------------------------------------------------------------------------- + +// Internal Drag and Drop payload types. String starting with '_' are reserved for Dear ImGui. +#define IMGUI_PAYLOAD_TYPE_DOCKABLE "_IMDOCK" // ImGuiWindow* // [Internal] Docking/tabs + +enum ImGuiButtonFlags_ +{ + ImGuiButtonFlags_Repeat = 1 << 0, // hold to repeat + ImGuiButtonFlags_PressedOnClickRelease = 1 << 1, // return true on click + release on same item [DEFAULT if no PressedOn* flag is set] + ImGuiButtonFlags_PressedOnClick = 1 << 2, // return true on click (default requires click+release) + ImGuiButtonFlags_PressedOnRelease = 1 << 3, // return true on release (default requires click+release) + ImGuiButtonFlags_PressedOnDoubleClick = 1 << 4, // return true on double-click (default requires click+release) + ImGuiButtonFlags_FlattenChildren = 1 << 5, // allow interactions even if a child window is overlapping + ImGuiButtonFlags_AllowItemOverlap = 1 << 6, // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap() + ImGuiButtonFlags_DontClosePopups = 1 << 7, // disable automatically closing parent popup on press // [UNUSED] + ImGuiButtonFlags_Disabled = 1 << 8, // disable interactions + ImGuiButtonFlags_AlignTextBaseLine = 1 << 9, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine + ImGuiButtonFlags_NoKeyModifiers = 1 << 10, // disable interaction if a key modifier is held + ImGuiButtonFlags_NoHoldingActiveID = 1 << 11, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only) + ImGuiButtonFlags_PressedOnDragDropHold = 1 << 12 // press when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers) +}; + +enum ImGuiSliderFlags_ +{ + ImGuiSliderFlags_Vertical = 1 << 0, + ImGuiSliderFlags_RenderValue = 1 << 1 +}; + +enum ImGuiColumnsFlags_ +{ + // Default: 0 + ImGuiColumnsFlags_NoBorder = 1 << 0, // Disable column dividers + ImGuiColumnsFlags_NoResize = 1 << 1, // Disable resizing columns when clicking on the dividers + ImGuiColumnsFlags_NoPreserveWidths = 1 << 2, // Disable column width preservation when adjusting columns + ImGuiColumnsFlags_NoForceWithinWindow = 1 << 3, // Disable forcing columns to fit within window + ImGuiColumnsFlags_GrowParentContentsSize= 1 << 4 // (WIP) Restore pre-1.51 behavior of extending the parent window contents size but _without affecting the columns width at all_. Will eventually remove. +}; + +enum ImGuiSelectableFlagsPrivate_ +{ + // NB: need to be in sync with last value of ImGuiSelectableFlags_ + ImGuiSelectableFlags_Menu = 1 << 3, // -> PressedOnClick + ImGuiSelectableFlags_MenuItem = 1 << 4, // -> PressedOnRelease + ImGuiSelectableFlags_Disabled = 1 << 5, + ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 6 +}; + +enum ImGuiSeparatorFlags_ +{ + ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar + ImGuiSeparatorFlags_Vertical = 1 << 1 +}; + +// FIXME: this is in development, not exposed/functional as a generic feature yet. +enum ImGuiLayoutType_ +{ + ImGuiLayoutType_Vertical, + ImGuiLayoutType_Horizontal +}; + +enum ImGuiAxis +{ + ImGuiAxis_None = -1, + ImGuiAxis_X = 0, + ImGuiAxis_Y = 1 +}; + +enum ImGuiPlotType +{ + ImGuiPlotType_Lines, + ImGuiPlotType_Histogram +}; + +enum ImGuiDataType +{ + ImGuiDataType_Int, + ImGuiDataType_Float, + ImGuiDataType_Float2 +}; + +enum ImGuiDir +{ + ImGuiDir_None = -1, + ImGuiDir_Left = 0, + ImGuiDir_Right = 1, + ImGuiDir_Up = 2, + ImGuiDir_Down = 3, + ImGuiDir_Count_ +}; + +// 2D axis aligned bounding-box +// NB: we can't rely on ImVec2 math operators being available here +struct IMGUI_API ImRect +{ + ImVec2 Min; // Upper-left + ImVec2 Max; // Lower-right + + ImRect() : Min(FLT_MAX,FLT_MAX), Max(-FLT_MAX,-FLT_MAX) {} + ImRect(const ImVec2& min, const ImVec2& max) : Min(min), Max(max) {} + ImRect(const ImVec4& v) : Min(v.x, v.y), Max(v.z, v.w) {} + ImRect(float x1, float y1, float x2, float y2) : Min(x1, y1), Max(x2, y2) {} + + ImVec2 GetCenter() const { return ImVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); } + ImVec2 GetSize() const { return ImVec2(Max.x - Min.x, Max.y - Min.y); } + float GetWidth() const { return Max.x - Min.x; } + float GetHeight() const { return Max.y - Min.y; } + ImVec2 GetTL() const { return Min; } // Top-left + ImVec2 GetTR() const { return ImVec2(Max.x, Min.y); } // Top-right + ImVec2 GetBL() const { return ImVec2(Min.x, Max.y); } // Bottom-left + ImVec2 GetBR() const { return Max; } // Bottom-right + bool Contains(const ImVec2& p) const { return p.x >= Min.x && p.y >= Min.y && p.x < Max.x && p.y < Max.y; } + bool Contains(const ImRect& r) const { return r.Min.x >= Min.x && r.Min.y >= Min.y && r.Max.x < Max.x && r.Max.y < Max.y; } + bool Overlaps(const ImRect& r) const { return r.Min.y < Max.y && r.Max.y > Min.y && r.Min.x < Max.x && r.Max.x > Min.x; } + void Add(const ImVec2& p) { if (Min.x > p.x) Min.x = p.x; if (Min.y > p.y) Min.y = p.y; if (Max.x < p.x) Max.x = p.x; if (Max.y < p.y) Max.y = p.y; } + void Add(const ImRect& r) { if (Min.x > r.Min.x) Min.x = r.Min.x; if (Min.y > r.Min.y) Min.y = r.Min.y; if (Max.x < r.Max.x) Max.x = r.Max.x; if (Max.y < r.Max.y) Max.y = r.Max.y; } + void Expand(const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; } + void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; } + void Translate(const ImVec2& v) { Min.x += v.x; Min.y += v.y; Max.x += v.x; Max.y += v.y; } + void ClipWith(const ImRect& r) { Min = ImMax(Min, r.Min); Max = ImMin(Max, r.Max); } // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display. + void ClipWithFull(const ImRect& r) { Min = ImClamp(Min, r.Min, r.Max); Max = ImClamp(Max, r.Min, r.Max); } // Full version, ensure both points are fully clipped. + void Floor() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; } + void FixInverted() { if (Min.x > Max.x) ImSwap(Min.x, Max.x); if (Min.y > Max.y) ImSwap(Min.y, Max.y); } + bool IsFinite() const { return Min.x != FLT_MAX; } +}; + +// Stacked color modifier, backup of modified data so we can restore it +struct ImGuiColMod +{ + ImGuiCol Col; + ImVec4 BackupValue; +}; + +// Stacked style modifier, backup of modified data so we can restore it. Data type inferred from the variable. +struct ImGuiStyleMod +{ + ImGuiStyleVar VarIdx; + union { int BackupInt[2]; float BackupFloat[2]; }; + ImGuiStyleMod(ImGuiStyleVar idx, int v) { VarIdx = idx; BackupInt[0] = v; } + ImGuiStyleMod(ImGuiStyleVar idx, float v) { VarIdx = idx; BackupFloat[0] = v; } + ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; } +}; + +// Stacked data for BeginGroup()/EndGroup() +struct ImGuiGroupData +{ + ImVec2 BackupCursorPos; + ImVec2 BackupCursorMaxPos; + float BackupIndentX; + float BackupGroupOffsetX; + float BackupCurrentLineHeight; + float BackupCurrentLineTextBaseOffset; + float BackupLogLinePosY; + bool BackupActiveIdIsAlive; + bool AdvanceCursor; +}; + +// Simple column measurement currently used for MenuItem() only. This is very short-sighted/throw-away code and NOT a generic helper. +struct IMGUI_API ImGuiMenuColumns +{ + int Count; + float Spacing; + float Width, NextWidth; + float Pos[4], NextWidths[4]; + + ImGuiMenuColumns(); + void update(int count, float spacing, bool clear); + float DeclColumns(float w0, float w1, float w2); + float CalcExtraSpace(float avail_w); +}; + +// Internal state of the currently focused/edited text input box +struct IMGUI_API ImGuiTextEditState +{ + ImGuiID Id; // widget id owning the text state + ImVector Text; // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer. + ImVector InitialText; // backup of end-user buffer at the time of focus (in UTF-8, unaltered) + ImVector TempTextBuffer; + int CurLenA, CurLenW; // we need to maintain our buffer length in both UTF-8 and wchar format. + int BufSizeA; // end-user buffer size + float ScrollX; + ImGuiStb::STB_TexteditState StbState; + float CursorAnim; + bool CursorFollow; + bool SelectedAllMouseLock; + + ImGuiTextEditState() { memset(this, 0, sizeof(*this)); } + void CursorAnimReset() { CursorAnim = -0.30f; } // After a user-input the cursor stays on for a while without blinking + void CursorClamp() { StbState.cursor = ImMin(StbState.cursor, CurLenW); StbState.select_start = ImMin(StbState.select_start, CurLenW); StbState.select_end = ImMin(StbState.select_end, CurLenW); } + bool HasSelection() const { return StbState.select_start != StbState.select_end; } + void ClearSelection() { StbState.select_start = StbState.select_end = StbState.cursor; } + void SelectAll() { StbState.select_start = 0; StbState.select_end = CurLenW; StbState.cursor = StbState.select_end; StbState.has_preferred_x = false; } + void OnKeyPressed(int key); +}; + +// Data saved in imgui.ini file +struct ImGuiWindowSettings +{ + char* Name; + ImGuiID Id; + ImVec2 Pos; + ImVec2 Size; + bool Collapsed; + + ImGuiWindowSettings() { Name = NULL; Id = 0; Pos = Size = ImVec2(0,0); Collapsed = false; } +}; + +struct ImGuiSettingsHandler +{ + const char* TypeName; // Short description stored in .ini file. Disallowed characters: '[' ']' + ImGuiID TypeHash; // == ImHash(TypeName, 0, 0) + void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name); + void (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); + void (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf); + void* UserData; + + ImGuiSettingsHandler() { memset(this, 0, sizeof(*this)); } +}; + +// Mouse cursor data (used when io.MouseDrawCursor is set) +struct ImGuiMouseCursorData +{ + ImGuiMouseCursor Type; + ImVec2 HotOffset; + ImVec2 Size; + ImVec2 TexUvMin[2]; + ImVec2 TexUvMax[2]; +}; + +// Storage for current popup stack +struct ImGuiPopupRef +{ + ImGuiID PopupId; // set on OpenPopup() + ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup() + ImGuiWindow* ParentWindow; // set on OpenPopup() + int OpenFrameCount; // set on OpenPopup() + ImGuiID OpenParentId; // set on OpenPopup(), we need this to differenciate multiple menu sets from each others (e.g. inside menu bar vs loose menu items) + ImVec2 OpenPopupPos; // set on OpenPopup(), preferred popup position (typically == OpenMousePos when using mouse) + ImVec2 OpenMousePos; // set on OpenPopup(), copy of mouse position at the time of opening popup +}; + +struct ImGuiColumnData +{ + float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right) + float OffsetNormBeforeResize; + ImGuiColumnsFlags Flags; // Not exposed + ImRect ClipRect; + + ImGuiColumnData() { OffsetNorm = OffsetNormBeforeResize = 0.0f; Flags = 0; } +}; + +struct ImGuiColumnsSet +{ + ImGuiID ID; + ImGuiColumnsFlags Flags; + bool IsFirstFrame; + bool IsBeingResized; + int Current; + int Count; + float MinX, MaxX; + float StartPosY; + float StartMaxPosX; // Backup of CursorMaxPos + float CellMinY, CellMaxY; + ImVector Columns; + + ImGuiColumnsSet() { Clear(); } + void Clear() + { + ID = 0; + Flags = 0; + IsFirstFrame = false; + IsBeingResized = false; + Current = 0; + Count = 1; + MinX = MaxX = 0.0f; + StartPosY = 0.0f; + StartMaxPosX = 0.0f; + CellMinY = CellMaxY = 0.0f; + Columns.clear(); + } +}; + +struct ImDrawListSharedData +{ + ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas + ImFont* Font; // Current/default font (optional, for simplified AddText overload) + float FontSize; // Current/default font size (optional, for simplified AddText overload) + float CurveTessellationTol; + ImVec4 ClipRectFullscreen; // Value for PushClipRectFullscreen() + + // Const data + // FIXME: Bake rounded corners fill/borders in atlas + ImVec2 CircleVtx12[12]; + + ImDrawListSharedData(); +}; + +// Storage for SetNexWindow** functions +struct ImGuiNextWindowData +{ + ImGuiCond PosCond; + ImGuiCond SizeCond; + ImGuiCond ContentSizeCond; + ImGuiCond CollapsedCond; + ImGuiCond SizeConstraintCond; + ImGuiCond FocusCond; + ImVec2 PosVal; + ImVec2 PosPivotVal; + ImVec2 SizeVal; + ImVec2 ContentSizeVal; + bool CollapsedVal; + ImRect SizeConstraintRect; // Valid if 'SetNextWindowSizeConstraint' is true + ImGuiSizeCallback SizeCallback; + void* SizeCallbackUserData; + + ImGuiNextWindowData() + { + PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = 0; + PosVal = PosPivotVal = SizeVal = ImVec2(0.0f, 0.0f); + ContentSizeVal = ImVec2(0.0f, 0.0f); + CollapsedVal = false; + SizeConstraintRect = ImRect(); + SizeCallback = NULL; + SizeCallbackUserData = NULL; + } + + void Clear() + { + PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = 0; + } +}; + +// Main state for ImGui +struct ImGuiContext +{ + bool Initialized; + ImGuiIO IO; + ImGuiStyle Style; + ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back() + float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window. + float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height. + ImDrawListSharedData DrawListSharedData; + + float Time; + int FrameCount; + int FrameCountEnded; + int FrameCountRendered; + ImVector Windows; + ImVector WindowsSortBuffer; + ImVector CurrentWindowStack; + ImGuiStorage WindowsById; + int WindowsActiveCount; + ImGuiWindow* CurrentWindow; // Being drawn into + ImGuiWindow* NavWindow; // Nav/focused window for navigation + ImGuiWindow* HoveredWindow; // Will catch mouse inputs + ImGuiWindow* HoveredRootWindow; // Will catch mouse inputs (for focus/move only) + ImGuiID HoveredId; // Hovered widget + bool HoveredIdAllowOverlap; + ImGuiID HoveredIdPreviousFrame; + float HoveredIdTimer; + ImGuiID ActiveId; // Active widget + ImGuiID ActiveIdPreviousFrame; + float ActiveIdTimer; + bool ActiveIdIsAlive; // Active widget has been seen this frame + bool ActiveIdIsJustActivated; // set at the time of activation for one frame + bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always) + ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior) + ImGuiWindow* ActiveIdWindow; + ImGuiWindow* MovingWindow; // Track the child window we clicked on to move a window. + ImGuiID MovingWindowMoveId; // == MovingWindow->MoveId + ImVector ColorModifiers; // Stack for PushStyleColor()/PopStyleColor() + ImVector StyleModifiers; // Stack for PushStyleVar()/PopStyleVar() + ImVector FontStack; // Stack for PushFont()/PopFont() + ImVector OpenPopupStack; // Which popups are open (persistent) + ImVector CurrentPopupStack; // Which level of BeginPopup() we are in (reset every frame) + ImGuiNextWindowData NextWindowData; // Storage for SetNextWindow** functions + bool NextTreeNodeOpenVal; // Storage for SetNextTreeNode** functions + ImGuiCond NextTreeNodeOpenCond; + + // Render + ImDrawData RenderDrawData; // Main ImDrawData instance to pass render information to the user + ImVector RenderDrawLists[3]; + float ModalWindowDarkeningRatio; + ImDrawList OverlayDrawList; // Optional software render of mouse cursors, if io.MouseDrawCursor is set + a few debug overlays + ImGuiMouseCursor MouseCursor; + ImGuiMouseCursorData MouseCursorData[ImGuiMouseCursor_Count_]; + + // Drag and Drop + bool DragDropActive; + ImGuiDragDropFlags DragDropSourceFlags; + int DragDropMouseButton; + ImGuiPayload DragDropPayload; + ImRect DragDropTargetRect; + ImGuiID DragDropTargetId; + float DragDropAcceptIdCurrRectSurface; + ImGuiID DragDropAcceptIdCurr; // Target item id (set at the time of accepting the payload) + ImGuiID DragDropAcceptIdPrev; // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets) + int DragDropAcceptFrameCount; // Last time a target expressed a desire to accept the source + ImVector DragDropPayloadBufHeap; // We don't expose the ImVector<> directly + unsigned char DragDropPayloadBufLocal[8]; + + // Widget state + ImGuiTextEditState InputTextState; + ImFont InputTextPasswordFont; + ImGuiID ScalarAsInputTextId; // Temporary text input when CTRL+clicking on a slider, etc. + ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets + ImVec4 ColorPickerRef; + float DragCurrentValue; // Currently dragged value, always float, not rounded by end-user precision settings + ImVec2 DragLastMouseDelta; + float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio + float DragSpeedScaleSlow; + float DragSpeedScaleFast; + ImVec2 ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage? + int TooltipOverrideCount; + ImVector PrivateClipboard; // If no custom clipboard handler is defined + ImVec2 OsImePosRequest, OsImePosSet; // Cursor position request & last passed to the OS Input Method Editor + + // Settings + float SettingsDirtyTimer; // Save .ini Settings on disk when time reaches zero + ImVector SettingsWindows; // .ini settings for ImGuiWindow + ImVector SettingsHandlers; // List of .ini settings handlers + + // Logging + bool LogEnabled; + FILE* LogFile; // If != NULL log to stdout/ file + ImGuiTextBuffer* LogClipboard; // Else log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators. + int LogStartDepth; + int LogAutoExpandMaxDepth; + + // Misc + float FramerateSecPerFrame[120]; // calculate estimate of framerate for user + int FramerateSecPerFrameIdx; + float FramerateSecPerFrameAccum; + int WantCaptureMouseNextFrame; // explicit capture via CaptureInputs() sets those flags + int WantCaptureKeyboardNextFrame; + int WantTextInputNextFrame; + char TempBuffer[1024*3+1]; // temporary text buffer + + ImGuiContext() : OverlayDrawList(NULL) + { + Initialized = false; + Font = NULL; + FontSize = FontBaseSize = 0.0f; + + Time = 0.0f; + FrameCount = 0; + FrameCountEnded = FrameCountRendered = -1; + WindowsActiveCount = 0; + CurrentWindow = NULL; + NavWindow = NULL; + HoveredWindow = NULL; + HoveredRootWindow = NULL; + HoveredId = 0; + HoveredIdAllowOverlap = false; + HoveredIdPreviousFrame = 0; + HoveredIdTimer = 0.0f; + ActiveId = 0; + ActiveIdPreviousFrame = 0; + ActiveIdTimer = 0.0f; + ActiveIdIsAlive = false; + ActiveIdIsJustActivated = false; + ActiveIdAllowOverlap = false; + ActiveIdClickOffset = ImVec2(-1,-1); + ActiveIdWindow = NULL; + MovingWindow = NULL; + MovingWindowMoveId = 0; + NextTreeNodeOpenVal = false; + NextTreeNodeOpenCond = 0; + + ModalWindowDarkeningRatio = 0.0f; + OverlayDrawList._Data = &DrawListSharedData; + OverlayDrawList._OwnerName = "##Overlay"; // Give it a name for debugging + MouseCursor = ImGuiMouseCursor_Arrow; + memset(MouseCursorData, 0, sizeof(MouseCursorData)); + + DragDropActive = false; + DragDropSourceFlags = 0; + DragDropMouseButton = -1; + DragDropTargetId = 0; + DragDropAcceptIdCurrRectSurface = 0.0f; + DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0; + DragDropAcceptFrameCount = -1; + memset(DragDropPayloadBufLocal, 0, sizeof(DragDropPayloadBufLocal)); + + ScalarAsInputTextId = 0; + ColorEditOptions = ImGuiColorEditFlags__OptionsDefault; + DragCurrentValue = 0.0f; + DragLastMouseDelta = ImVec2(0.0f, 0.0f); + DragSpeedDefaultRatio = 1.0f / 100.0f; + DragSpeedScaleSlow = 1.0f / 100.0f; + DragSpeedScaleFast = 10.0f; + ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f); + TooltipOverrideCount = 0; + OsImePosRequest = OsImePosSet = ImVec2(-1.0f, -1.0f); + + SettingsDirtyTimer = 0.0f; + + LogEnabled = false; + LogFile = NULL; + LogClipboard = NULL; + LogStartDepth = 0; + LogAutoExpandMaxDepth = 2; + + memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame)); + FramerateSecPerFrameIdx = 0; + FramerateSecPerFrameAccum = 0.0f; + WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1; + memset(TempBuffer, 0, sizeof(TempBuffer)); + } +}; + +// Transient per-window flags, reset at the beginning of the frame. For child window, inherited from parent on first Begin(). +enum ImGuiItemFlags_ +{ + ImGuiItemFlags_AllowKeyboardFocus = 1 << 0, // true + ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings. + ImGuiItemFlags_Disabled = 1 << 2, // false // FIXME-WIP: Disable interactions but doesn't affect visuals. Should be: grey out and disable interactions with widgets that affect data + view widgets (WIP) + //ImGuiItemFlags_NoNav = 1 << 3, // false + //ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false + ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // MenuItem/Selectable() automatically closes current Popup window + ImGuiItemFlags_TabButton = 1 << 6, // false + ImGuiItemFlags_Default_ = ImGuiItemFlags_AllowKeyboardFocus +}; + +// Transient per-window data, reset at the beginning of the frame +// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiDrawContext is quite tenuous and could be reconsidered. +struct IMGUI_API ImGuiDrawContext +{ + ImVec2 CursorPos; + ImVec2 CursorPosPrevLine; + ImVec2 CursorStartPos; + ImVec2 CursorMaxPos; // Used to implicitly calculate the size of our contents, always growing during the frame. Turned into window->SizeContents at the beginning of next frame + float CurrentLineHeight; + float CurrentLineTextBaseOffset; + float PrevLineHeight; + float PrevLineTextBaseOffset; + float LogLinePosY; + int TreeDepth; + ImGuiID LastItemId; + ImRect LastItemRect; + bool LastItemRectHoveredRect; + bool MenuBarAppending; + float MenuBarOffsetX; + ImVector ChildWindows; + ImGuiStorage* StateStorage; + ImGuiLayoutType LayoutType; + + // We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings. + ImGuiItemFlags ItemFlags; // == ItemFlagsStack.back() [empty == ImGuiItemFlags_Default] + float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window + float TextWrapPos; // == TextWrapPosStack.back() [empty == -1.0f] + ImVectorItemFlagsStack; + ImVector ItemWidthStack; + ImVector TextWrapPosStack; + ImVectorGroupStack; + int StackSizesBackup[6]; // Store size of various stacks for asserting + + float IndentX; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.) + float GroupOffsetX; + float ColumnsOffsetX; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API. + ImGuiColumnsSet* ColumnsSet; // Current columns set + + ImGuiDrawContext() + { + CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f); + CurrentLineHeight = PrevLineHeight = 0.0f; + CurrentLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f; + LogLinePosY = -1.0f; + TreeDepth = 0; + LastItemId = 0; + LastItemRect = ImRect(); + LastItemRectHoveredRect = false; + MenuBarAppending = false; + MenuBarOffsetX = 0.0f; + StateStorage = NULL; + LayoutType = ImGuiLayoutType_Vertical; + ItemWidth = 0.0f; + ItemFlags = ImGuiItemFlags_Default_; + TextWrapPos = -1.0f; + memset(StackSizesBackup, 0, sizeof(StackSizesBackup)); + + IndentX = 0.0f; + GroupOffsetX = 0.0f; + ColumnsOffsetX = 0.0f; + ColumnsSet = NULL; + } +}; + +// Windows data +struct IMGUI_API ImGuiWindow +{ + char* Name; + ImGuiID ID; // == ImHash(Name) + ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_ + ImVec2 PosFloat; + ImVec2 Pos; // Position rounded-up to nearest pixel + ImVec2 Size; // Current size (==SizeFull or collapsed title bar size) + ImVec2 SizeFull; // Size when non collapsed + ImVec2 SizeFullAtLastBegin; // Copy of SizeFull at the end of Begin. This is the reference value we'll use on the next frame to decide if we need scrollbars. + ImVec2 SizeContents; // Size of contents (== extents reach of the drawing cursor) from previous frame. Include decoration, window title, border, menu, etc. + ImVec2 SizeContentsExplicit; // Size of contents explicitly set by the user via SetNextWindowContentSize() + ImRect ContentsRegionRect; // Maximum visible content position in window coordinates. ~~ (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis + ImVec2 WindowPadding; // Window padding at the time of begin. + float WindowRounding; // Window rounding at the time of begin. + float WindowBorderSize; // Window border size at the time of begin. + ImGuiID MoveId; // == window->GetID("#MOVE") + ImVec2 Scroll; + ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change) + ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered + bool ScrollbarX, ScrollbarY; + ImVec2 ScrollbarSizes; + bool Active; // set to true on Begin(), unless Collapsed + bool WasActive; + bool WriteAccessed; // set to true when any widget access the current window + bool Collapsed; // set when collapsing window to become only title-bar + bool SkipItems; // set when items can safely be all clipped (e.g. window not visible or collapsed) + bool Appearing; // set during the frame where the window is appearing (or re-appearing) + bool CloseButton; // set when the window has a close button (p_open != NULL) + int BeginOrderWithinParent; // Order within immediate parent window, if we are a child window. Otherwise 0. + int BeginOrderWithinContext; // Order within entire imgui context. This is mostly used for debugging submission order related issues. + int BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs) + ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling) + int AutoFitFramesX, AutoFitFramesY; + bool AutoFitOnlyGrows; + int AutoFitChildAxises; + ImGuiDir AutoPosLastDirection; + int HiddenFrames; + ImGuiCond SetWindowPosAllowFlags; // store condition flags for next SetWindowPos() call. + ImGuiCond SetWindowSizeAllowFlags; // store condition flags for next SetWindowSize() call. + ImGuiCond SetWindowCollapsedAllowFlags; // store condition flags for next SetWindowCollapsed() call. + ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size) + ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0,0) when positioning from top-left corner; ImVec2(0.5f,0.5f) for centering; ImVec2(1,1) for bottom right. + + ImGuiDrawContext DC; // Temporary per-window data, reset at the beginning of the frame + ImVector IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack + ImRect ClipRect; // = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2. + ImRect WindowRectClipped; // = WindowRect just after setup in Begin(). == window->Rect() for root window. + ImRect InnerRect; + int LastFrameActive; + float ItemWidthDefault; + ImGuiMenuColumns MenuColumns; // Simplified columns storage for menu items + ImGuiStorage StateStorage; + ImVector ColumnsStorage; + float FontWindowScale; // Scale multiplier per-window + ImDrawList* DrawList; + ImGuiWindow* ParentWindow; // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL. + ImGuiWindow* RootWindow; // Generally point to ourself. If we are a child window, this is pointing to the first non-child parent window. + ImGuiWindow* RootNonPopupWindow; // Generally point to ourself. Used to display TitleBgActive color and for selecting which window to use for NavWindowing + + // Navigation / Focus + int FocusIdxAllCounter; // Start at -1 and increase as assigned via FocusItemRegister() + int FocusIdxTabCounter; // (same, but only count widgets which you can Tab through) + int FocusIdxAllRequestCurrent; // Item being requested for focus + int FocusIdxTabRequestCurrent; // Tab-able item being requested for focus + int FocusIdxAllRequestNext; // Item being requested for focus, for next update (relies on layout to be stable between the frame pressing TAB and the next frame) + int FocusIdxTabRequestNext; // " + +public: + ImGuiWindow(ImGuiContext* context, const char* name); + ~ImGuiWindow(); + + ImGuiID GetID(const char* str, const char* str_end = NULL); + ImGuiID GetID(const void* ptr); + ImGuiID GetIDNoKeepAlive(const char* str, const char* str_end = NULL); + ImGuiID GetIDFromRectangle(const ImRect& r_abs); + + // We don't use g.FontSize because the window may be != g.CurrentWidow. + ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x+Size.x, Pos.y+Size.y); } + float CalcFontSize() const { return GImGui->FontBaseSize * FontWindowScale; } + float TitleBarHeight() const { return (Flags & ImGuiWindowFlags_CoolStyle) ? 40.f : ((Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f); } + ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); } + float MenuBarHeight() const { return (Flags & ImGuiWindowFlags_MenuBar) ? CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f : 0.0f; } + ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); } +}; + +// Backup and restore just enough data to be able to use IsItemHovered() on item A after another B in the same window has overwritten the data. +struct ImGuiItemHoveredDataBackup +{ + ImGuiID LastItemId; + ImRect LastItemRect; + bool LastItemRectHoveredRect; + + ImGuiItemHoveredDataBackup() { Backup(); } + void Backup() { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemRect = window->DC.LastItemRect; LastItemRectHoveredRect = window->DC.LastItemRectHoveredRect; } + void Restore() const { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemRect = LastItemRect; window->DC.LastItemRectHoveredRect = LastItemRectHoveredRect; } +}; + +//----------------------------------------------------------------------------- +// Internal API +// No guarantee of forward compatibility here. +//----------------------------------------------------------------------------- + +namespace ImGui +{ + // We should always have a CurrentWindow in the stack (there is an implicit "Debug" window) + // If this ever crash because g.CurrentWindow is NULL it means that either + // - ImGui::NewFrame() has never been called, which is illegal. + // - You are calling ImGui functions after ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal. + inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; } + inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; } + IMGUI_API ImGuiWindow* FindWindowByName(const char* name); + IMGUI_API void FocusWindow(ImGuiWindow* window); + IMGUI_API void BringWindowToFront(ImGuiWindow* window); + IMGUI_API void BringWindowToBack(ImGuiWindow* window); + IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent); + + IMGUI_API void initialize(); + + IMGUI_API void MarkIniSettingsDirty(); + IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name); + IMGUI_API ImGuiWindowSettings* FindWindowSettings(ImGuiID id); + + IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window); + IMGUI_API void ClearActiveID(); + IMGUI_API void SetHoveredID(ImGuiID id); + IMGUI_API ImGuiID GetHoveredID(); + IMGUI_API void KeepAliveID(ImGuiID id); + + IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f); + IMGUI_API void ItemSize(const ImRect& bb, float text_offset_y = 0.0f); + IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id); + IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id); + IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged); + IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id, bool tab_stop = true); // Return true if focus is requested + IMGUI_API void FocusableItemUnregister(ImGuiWindow* window); + IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_x, float default_y); + IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x); + IMGUI_API void PushMultiItemsWidths(int components, float width_full = 0.0f); + IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled); + IMGUI_API void PopItemFlag(); + + IMGUI_API void OpenPopupEx(ImGuiID id); + IMGUI_API void ClosePopup(ImGuiID id); + IMGUI_API bool IsPopupOpen(ImGuiID id); + IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags); + IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip = true); + + IMGUI_API int CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate); + + IMGUI_API void Scrollbar(ImGuiLayoutType direction); + IMGUI_API void VerticalSeparator(); // Vertical separator, for menu bars (use current line height). not exposed because it is misleading what it doesn't have an effect on regular layout. + IMGUI_API bool SplitterBehavior(ImGuiID id, const ImRect& bb, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend = 0.0f); + + IMGUI_API bool BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id); + IMGUI_API void ClearDragDrop(); + IMGUI_API bool IsDragDropPayloadBeingAccepted(); + + // FIXME-WIP: New Columns API + IMGUI_API void BeginColumns(const char* str_id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns(). + IMGUI_API void EndColumns(); // close columns + IMGUI_API void PushColumnClipRect(int column_index = -1); + + // NB: All position are in absolute pixels coordinates (never using window coordinates internally) + // AVOID USING OUTSIDE OF IMGUI.CPP! NOT FOR PUBLIC CONSUMPTION. THOSE FUNCTIONS ARE A MESS. THEIR SIGNATURE AND BEHAVIOR WILL CHANGE, THEY NEED TO BE REFACTORED INTO SOMETHING DECENT. + IMGUI_API void RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true); + IMGUI_API void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width); + IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0,0), const ImRect* clip_rect = NULL); + IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f); + IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f); + IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0); + IMGUI_API void RenderTriangle(ImVec2 pos, ImGuiDir dir, float scale = 1.0f); + IMGUI_API void RenderBullet(ImVec2 pos); + IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col, float sz); + IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding); + IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text. + + IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0); + IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0,0), ImGuiButtonFlags flags = 0); + IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos, float radius); + IMGUI_API bool ArrowButton(ImGuiID id, ImGuiDir dir, ImVec2 padding, ImGuiButtonFlags flags = 0); + + IMGUI_API bool SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_min, float v_max, float power, int decimal_precision, ImGuiSliderFlags flags = 0); + IMGUI_API bool SliderFloatN(const char* label, float* v, int components, float v_min, float v_max, const char* display_format, float power); + IMGUI_API bool SliderIntN(const char* label, int* v, int components, int v_min, int v_max, const char* display_format); + + IMGUI_API bool DragBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_speed, float v_min, float v_max, int decimal_precision, float power); + IMGUI_API bool DragFloatN(const char* label, float* v, int components, float v_speed, float v_min, float v_max, const char* display_format, float power); + IMGUI_API bool DragIntN(const char* label, int* v, int components, float v_speed, int v_min, int v_max, const char* display_format); + + IMGUI_API bool InputTextEx(const char* label, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback = NULL, void* user_data = NULL); + IMGUI_API bool InputFloatN(const char* label, float* v, int components, int decimal_precision, ImGuiInputTextFlags extra_flags); + IMGUI_API bool InputIntN(const char* label, int* v, int components, ImGuiInputTextFlags extra_flags); + IMGUI_API bool InputScalarEx(const char* label, ImGuiDataType data_type, void* data_ptr, void* step_ptr, void* step_fast_ptr, const char* scalar_format, ImGuiInputTextFlags extra_flags); + IMGUI_API bool InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label, ImGuiDataType data_type, void* data_ptr, ImGuiID id, int decimal_precision); + + IMGUI_API void ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags); + IMGUI_API void ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags); + + IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL); + IMGUI_API bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextTreeNodeOpened() data, if any. May return true when logging + IMGUI_API void TreePushRawID(ImGuiID id); + + IMGUI_API void PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size); + + IMGUI_API int ParseFormatPrecision(const char* fmt, int default_value); + IMGUI_API float RoundScalar(float value, int decimal_precision); + + // Shade functions + IMGUI_API void ShadeVertsLinearColorGradientKeepAlpha(ImDrawVert* vert_start, ImDrawVert* vert_end, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1); + IMGUI_API void ShadeVertsLinearAlphaGradientForLeftToRightText(ImDrawVert* vert_start, ImDrawVert* vert_end, float gradient_p0_x, float gradient_p1_x); + IMGUI_API void ShadeVertsLinearUV(ImDrawVert* vert_start, ImDrawVert* vert_end, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp); + +} // namespace ImGui + +// ImFontAtlas internals +IMGUI_API bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas); +IMGUI_API void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas); +IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent); +IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* spc); +IMGUI_API void ImFontAtlasBuildFinish(ImFontAtlas* atlas); +IMGUI_API void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor); +IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride); + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#ifdef _MSC_VER +#pragma warning (pop) +#endif + +``` + +`imgui/stb_rect_pack.h`: + +```h +// stb_rect_pack.h - v0.10 - public domain - rectangle packing +// Sean Barrett 2014 +// +// Useful for e.g. packing rectangular textures into an atlas. +// Does not do rotation. +// +// Not necessarily the awesomest packing method, but better than +// the totally naive one in stb_truetype (which is primarily what +// this is meant to replace). +// +// Has only had a few tests run, may have issues. +// +// More docs to come. +// +// No memory allocations; uses qsort() and assert() from stdlib. +// Can override those by defining STBRP_SORT and STBRP_ASSERT. +// +// This library currently uses the Skyline Bottom-Left algorithm. +// +// Please note: better rectangle packers are welcome! Please +// implement them to the same API, but with a different init +// function. +// +// Credits +// +// Library +// Sean Barrett +// Minor features +// Martins Mozeiko +// Bugfixes / warning fixes +// Jeremy Jaussaud +// +// Version history: +// +// 0.10 (2016-10-25) remove cast-away-const to avoid warnings +// 0.09 (2016-08-27) fix compiler warnings +// 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0) +// 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0) +// 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort +// 0.05: added STBRP_ASSERT to allow replacing assert +// 0.04: fixed minor bug in STBRP_LARGE_RECTS support +// 0.01: initial release +// +// LICENSE +// +// This software is dual-licensed to the public domain and under the following +// license: you are granted a perpetual, irrevocable license to copy, modify, +// publish, and distribute this file as you see fit. + +////////////////////////////////////////////////////////////////////////////// +// +// INCLUDE SECTION +// + +#ifndef STB_INCLUDE_STB_RECT_PACK_H +#define STB_INCLUDE_STB_RECT_PACK_H + +#define STB_RECT_PACK_VERSION 1 + +#ifdef STBRP_STATIC +#define STBRP_DEF static +#else +#define STBRP_DEF extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct stbrp_context stbrp_context; +typedef struct stbrp_node stbrp_node; +typedef struct stbrp_rect stbrp_rect; + +#ifdef STBRP_LARGE_RECTS +typedef int stbrp_coord; +#else +typedef unsigned short stbrp_coord; +#endif + +STBRP_DEF void stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects); +// Assign packed locations to rectangles. The rectangles are of type +// 'stbrp_rect' defined below, stored in the array 'rects', and there +// are 'num_rects' many of them. +// +// Rectangles which are successfully packed have the 'was_packed' flag +// set to a non-zero value and 'x' and 'y' store the minimum location +// on each axis (i.e. bottom-left in cartesian coordinates, top-left +// if you imagine y increasing downwards). Rectangles which do not fit +// have the 'was_packed' flag set to 0. +// +// You should not try to access the 'rects' array from another thread +// while this function is running, as the function temporarily reorders +// the array while it executes. +// +// To pack into another rectangle, you need to call stbrp_init_target +// again. To continue packing into the same rectangle, you can call +// this function again. Calling this multiple times with multiple rect +// arrays will probably produce worse packing results than calling it +// a single time with the full rectangle array, but the option is +// available. + +struct stbrp_rect +{ + // reserved for your use: + int id; + + // input: + stbrp_coord w, h; + + // output: + stbrp_coord x, y; + int was_packed; // non-zero if valid packing + +}; // 16 BYTEs, nominally + + +STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); +// initialize a rectangle packer to: +// pack a rectangle that is 'width' by 'height' in dimensions +// using temporary storage provided by the array 'nodes', which is 'num_nodes' long +// +// You must call this function every time you start packing into a new target. +// +// There is no "shutdown" function. The 'nodes' memory must stay valid for +// the following stbrp_pack_rects() call (or calls), but can be freed after +// the call (or calls) finish. +// +// Note: to guarantee best results, either: +// 1. make sure 'num_nodes' >= 'width' +// or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1' +// +// If you don't do either of the above things, widths will be quantized to multiples +// of small integers to guarantee the algorithm doesn't run out of temporary storage. +// +// If you do #2, then the non-quantized algorithm will be used, but the algorithm +// may run out of temporary storage and be unable to pack some rectangles. + +STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem); +// Optionally call this function after init but before doing any packing to +// change the handling of the out-of-temp-memory scenario, described above. +// If you call init again, this will be reset to the default (false). + + +STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic); +// Optionally select which packing heuristic the library should use. Different +// heuristics will produce better/worse results for different data sets. +// If you call init again, this will be reset to the default. + +enum +{ + STBRP_HEURISTIC_Skyline_default=0, + STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, + STBRP_HEURISTIC_Skyline_BF_sortHeight +}; + + +////////////////////////////////////////////////////////////////////////////// +// +// the details of the following structures don't matter to you, but they must +// be visible so you can handle the memory allocations for them + +struct stbrp_node +{ + stbrp_coord x,y; + stbrp_node *next; +}; + +struct stbrp_context +{ + int width; + int height; + int align; + int init_mode; + int heuristic; + int num_nodes; + stbrp_node *active_head; + stbrp_node *free_head; + stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' +}; + +#ifdef __cplusplus +} +#endif + +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// IMPLEMENTATION SECTION +// + +#ifdef STB_RECT_PACK_IMPLEMENTATION +#ifndef STBRP_SORT +#include +#define STBRP_SORT qsort +#endif + +#ifndef STBRP_ASSERT +#include +#define STBRP_ASSERT assert +#endif + +#ifdef _MSC_VER +#define STBRP__NOTUSED(v) (void)(v) +#else +#define STBRP__NOTUSED(v) (void)sizeof(v) +#endif + +enum +{ + STBRP__INIT_skyline = 1 +}; + +STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) +{ + switch (context->init_mode) { + case STBRP__INIT_skyline: + STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); + context->heuristic = heuristic; + break; + default: + STBRP_ASSERT(0); + } +} + +STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) +{ + if (allow_out_of_mem) + // if it's ok to run out of memory, then don't bother aligning them; + // this gives better packing, but may fail due to OOM (even though + // the rectangles easily fit). @TODO a smarter approach would be to only + // quantize once we've hit OOM, then we could get rid of this parameter. + context->align = 1; + else { + // if it's not ok to run out of memory, then quantize the widths + // so that num_nodes is always enough nodes. + // + // I.e. num_nodes * align >= width + // align >= width / num_nodes + // align = ceil(width/num_nodes) + + context->align = (context->width + context->num_nodes-1) / context->num_nodes; + } +} + +STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) +{ + int i; +#ifndef STBRP_LARGE_RECTS + STBRP_ASSERT(width <= 0xffff && height <= 0xffff); +#endif + + for (i=0; i < num_nodes-1; ++i) + nodes[i].next = &nodes[i+1]; + nodes[i].next = NULL; + context->init_mode = STBRP__INIT_skyline; + context->heuristic = STBRP_HEURISTIC_Skyline_default; + context->free_head = &nodes[0]; + context->active_head = &context->extra[0]; + context->width = width; + context->height = height; + context->num_nodes = num_nodes; + stbrp_setup_allow_out_of_mem(context, 0); + + // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) + context->extra[0].x = 0; + context->extra[0].y = 0; + context->extra[0].next = &context->extra[1]; + context->extra[1].x = (stbrp_coord) width; +#ifdef STBRP_LARGE_RECTS + context->extra[1].y = (1<<30); +#else + context->extra[1].y = 65535; +#endif + context->extra[1].next = NULL; +} + +// find minimum y position if it starts at x1 +static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) +{ + stbrp_node *node = first; + int x1 = x0 + width; + int min_y, visited_width, waste_area; + + STBRP__NOTUSED(c); + + STBRP_ASSERT(first->x <= x0); + + #if 0 + // skip in case we're past the node + while (node->next->x <= x0) + ++node; + #else + STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency + #endif + + STBRP_ASSERT(node->x <= x0); + + min_y = 0; + waste_area = 0; + visited_width = 0; + while (node->x < x1) { + if (node->y > min_y) { + // raise min_y higher. + // we've accounted for all waste up to min_y, + // but we'll now add more waste for everything we've visted + waste_area += visited_width * (node->y - min_y); + min_y = node->y; + // the first time through, visited_width might be reduced + if (node->x < x0) + visited_width += node->next->x - x0; + else + visited_width += node->next->x - node->x; + } else { + // add waste area + int under_width = node->next->x - node->x; + if (under_width + visited_width > width) + under_width = width - visited_width; + waste_area += under_width * (min_y - node->y); + visited_width += under_width; + } + node = node->next; + } + + *pwaste = waste_area; + return min_y; +} + +typedef struct +{ + int x,y; + stbrp_node **prev_link; +} stbrp__findresult; + +static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) +{ + int best_waste = (1<<30), best_x, best_y = (1 << 30); + stbrp__findresult fr; + stbrp_node **prev, *node, *tail, **best = NULL; + + // align to multiple of c->align + width = (width + c->align - 1); + width -= width % c->align; + STBRP_ASSERT(width % c->align == 0); + + node = c->active_head; + prev = &c->active_head; + while (node->x + width <= c->width) { + int y,waste; + y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); + if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL + // bottom left + if (y < best_y) { + best_y = y; + best = prev; + } + } else { + // best-fit + if (y + height <= c->height) { + // can only use it if it first vertically + if (y < best_y || (y == best_y && waste < best_waste)) { + best_y = y; + best_waste = waste; + best = prev; + } + } + } + prev = &node->next; + node = node->next; + } + + best_x = (best == NULL) ? 0 : (*best)->x; + + // if doing best-fit (BF), we also have to try aligning right edge to each node position + // + // e.g, if fitting + // + // ____________________ + // |____________________| + // + // into + // + // | | + // | ____________| + // |____________| + // + // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned + // + // This makes BF take about 2x the time + + if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { + tail = c->active_head; + node = c->active_head; + prev = &c->active_head; + // find first node that's admissible + while (tail->x < width) + tail = tail->next; + while (tail) { + int xpos = tail->x - width; + int y,waste; + STBRP_ASSERT(xpos >= 0); + // find the left position that matches this + while (node->next->x <= xpos) { + prev = &node->next; + node = node->next; + } + STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); + y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); + if (y + height < c->height) { + if (y <= best_y) { + if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { + best_x = xpos; + STBRP_ASSERT(y <= best_y); + best_y = y; + best_waste = waste; + best = prev; + } + } + } + tail = tail->next; + } + } + + fr.prev_link = best; + fr.x = best_x; + fr.y = best_y; + return fr; +} + +static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) +{ + // find best position according to heuristic + stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); + stbrp_node *node, *cur; + + // bail if: + // 1. it failed + // 2. the best node doesn't fit (we don't always check this) + // 3. we're out of memory + if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { + res.prev_link = NULL; + return res; + } + + // on success, create new node + node = context->free_head; + node->x = (stbrp_coord) res.x; + node->y = (stbrp_coord) (res.y + height); + + context->free_head = node->next; + + // insert the new node into the right starting point, and + // let 'cur' point to the remaining nodes needing to be + // stiched back in + + cur = *res.prev_link; + if (cur->x < res.x) { + // preserve the existing one, so start testing with the next one + stbrp_node *next = cur->next; + cur->next = node; + cur = next; + } else { + *res.prev_link = node; + } + + // from here, traverse cur and free the nodes, until we get to one + // that shouldn't be freed + while (cur->next && cur->next->x <= res.x + width) { + stbrp_node *next = cur->next; + // move the current node to the free list + cur->next = context->free_head; + context->free_head = cur; + cur = next; + } + + // stitch the list back in + node->next = cur; + + if (cur->x < res.x + width) + cur->x = (stbrp_coord) (res.x + width); + +#ifdef _DEBUG + cur = context->active_head; + while (cur->x < context->width) { + STBRP_ASSERT(cur->x < cur->next->x); + cur = cur->next; + } + STBRP_ASSERT(cur->next == NULL); + + { + stbrp_node *L1 = NULL, *L2 = NULL; + int count=0; + cur = context->active_head; + while (cur) { + L1 = cur; + cur = cur->next; + ++count; + } + cur = context->free_head; + while (cur) { + L2 = cur; + cur = cur->next; + ++count; + } + STBRP_ASSERT(count == context->num_nodes+2); + } +#endif + + return res; +} + +static int rect_height_compare(const void *a, const void *b) +{ + const stbrp_rect *p = (const stbrp_rect *) a; + const stbrp_rect *q = (const stbrp_rect *) b; + if (p->h > q->h) + return -1; + if (p->h < q->h) + return 1; + return (p->w > q->w) ? -1 : (p->w < q->w); +} + +static int rect_width_compare(const void *a, const void *b) +{ + const stbrp_rect *p = (const stbrp_rect *) a; + const stbrp_rect *q = (const stbrp_rect *) b; + if (p->w > q->w) + return -1; + if (p->w < q->w) + return 1; + return (p->h > q->h) ? -1 : (p->h < q->h); +} + +static int rect_original_order(const void *a, const void *b) +{ + const stbrp_rect *p = (const stbrp_rect *) a; + const stbrp_rect *q = (const stbrp_rect *) b; + return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); +} + +#ifdef STBRP_LARGE_RECTS +#define STBRP__MAXVAL 0xffffffff +#else +#define STBRP__MAXVAL 0xffff +#endif + +STBRP_DEF void stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) +{ + int i; + + // we use the 'was_packed' field internally to allow sorting/unsorting + for (i=0; i < num_rects; ++i) { + rects[i].was_packed = i; + #ifndef STBRP_LARGE_RECTS + STBRP_ASSERT(rects[i].w <= 0xffff && rects[i].h <= 0xffff); + #endif + } + + // sort according to heuristic + STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); + + for (i=0; i < num_rects; ++i) { + if (rects[i].w == 0 || rects[i].h == 0) { + rects[i].x = rects[i].y = 0; // empty rect needs no space + } else { + stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); + if (fr.prev_link) { + rects[i].x = (stbrp_coord) fr.x; + rects[i].y = (stbrp_coord) fr.y; + } else { + rects[i].x = rects[i].y = STBRP__MAXVAL; + } + } + } + + // unsort + STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); + + // set was_packed flags + for (i=0; i < num_rects; ++i) + rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); +} +#endif + +``` + +`imgui/stb_textedit.h`: + +```h +// [ImGui] this is a slightly modified version of stb_truetype.h 1.9. Those changes would need to be pushed into nothings/sb +// [ImGui] - fixed linestart handler when over last character of multi-line buffer + simplified existing code (#588, #815) +// [ImGui] - fixed a state corruption/crash bug in stb_text_redo and stb_textedit_discard_redo (#715) +// [ImGui] - fixed a crash bug in stb_textedit_discard_redo (#681) +// [ImGui] - fixed some minor warnings + +// stb_textedit.h - v1.9 - public domain - Sean Barrett +// Development of this library was sponsored by RAD Game Tools +// +// This C header file implements the guts of a multi-line text-editing +// widget; you implement display, word-wrapping, and low-level string +// insertion/deletion, and stb_textedit will map user inputs into +// insertions & deletions, plus updates to the cursor position, +// selection state, and undo state. +// +// It is intended for use in games and other systems that need to build +// their own custom widgets and which do not have heavy text-editing +// requirements (this library is not recommended for use for editing large +// texts, as its performance does not scale and it has limited undo). +// +// Non-trivial behaviors are modelled after Windows text controls. +// +// +// LICENSE +// +// This software is dual-licensed to the public domain and under the following +// license: you are granted a perpetual, irrevocable license to copy, modify, +// publish, and distribute this file as you see fit. +// +// +// DEPENDENCIES +// +// Uses the C runtime function 'memmove', which you can override +// by defining STB_TEXTEDIT_memmove before the implementation. +// Uses no other functions. Performs no runtime allocations. +// +// +// VERSION HISTORY +// +// 1.9 (2016-08-27) customizable move-by-word +// 1.8 (2016-04-02) better keyboard handling when mouse button is down +// 1.7 (2015-09-13) change y range handling in case baseline is non-0 +// 1.6 (2015-04-15) allow STB_TEXTEDIT_memmove +// 1.5 (2014-09-10) add support for secondary keys for OS X +// 1.4 (2014-08-17) fix signed/unsigned warnings +// 1.3 (2014-06-19) fix mouse clicking to round to nearest char boundary +// 1.2 (2014-05-27) fix some RAD types that had crept into the new code +// 1.1 (2013-12-15) move-by-word (requires STB_TEXTEDIT_IS_SPACE ) +// 1.0 (2012-07-26) improve documentation, initial public release +// 0.3 (2012-02-24) bugfixes, single-line mode; insert mode +// 0.2 (2011-11-28) fixes to undo/redo +// 0.1 (2010-07-08) initial version +// +// ADDITIONAL CONTRIBUTORS +// +// Ulf Winklemann: move-by-word in 1.1 +// Fabian Giesen: secondary key inputs in 1.5 +// Martins Mozeiko: STB_TEXTEDIT_memmove +// +// Bugfixes: +// Scott Graham +// Daniel Keller +// Omar Cornut +// +// USAGE +// +// This file behaves differently depending on what symbols you define +// before including it. +// +// +// Header-file mode: +// +// If you do not define STB_TEXTEDIT_IMPLEMENTATION before including this, +// it will operate in "header file" mode. In this mode, it declares a +// single public symbol, STB_TexteditState, which encapsulates the current +// state of a text widget (except for the string, which you will store +// separately). +// +// To compile in this mode, you must define STB_TEXTEDIT_CHARTYPE to a +// primitive type that defines a single character (e.g. char, wchar_t, etc). +// +// To save space or increase undo-ability, you can optionally define the +// following things that are used by the undo system: +// +// STB_TEXTEDIT_POSITIONTYPE small int type encoding a valid cursor position +// STB_TEXTEDIT_UNDOSTATECOUNT the number of undo states to allow +// STB_TEXTEDIT_UNDOCHARCOUNT the number of characters to store in the undo buffer +// +// If you don't define these, they are set to permissive types and +// moderate sizes. The undo system does no memory allocations, so +// it grows STB_TexteditState by the worst-case storage which is (in BYTEs): +// +// [4 + sizeof(STB_TEXTEDIT_POSITIONTYPE)] * STB_TEXTEDIT_UNDOSTATE_COUNT +// + sizeof(STB_TEXTEDIT_CHARTYPE) * STB_TEXTEDIT_UNDOCHAR_COUNT +// +// +// Implementation mode: +// +// If you define STB_TEXTEDIT_IMPLEMENTATION before including this, it +// will compile the implementation of the text edit widget, depending +// on a large number of symbols which must be defined before the include. +// +// The implementation is defined only as static functions. You will then +// need to provide your own APIs in the same file which will access the +// static functions. +// +// The basic concept is that you provide a "string" object which +// behaves like an array of characters. stb_textedit uses indices to +// refer to positions in the string, implicitly representing positions +// in the displayed textedit. This is true for both plain text and +// rich text; even with rich text stb_truetype interacts with your +// code as if there was an array of all the displayed characters. +// +// Symbols that must be the same in header-file and implementation mode: +// +// STB_TEXTEDIT_CHARTYPE the character type +// STB_TEXTEDIT_POSITIONTYPE small type that a valid cursor position +// STB_TEXTEDIT_UNDOSTATECOUNT the number of undo states to allow +// STB_TEXTEDIT_UNDOCHARCOUNT the number of characters to store in the undo buffer +// +// Symbols you must define for implementation mode: +// +// STB_TEXTEDIT_STRING the type of object representing a string being edited, +// typically this is a wrapper object with other data you need +// +// STB_TEXTEDIT_STRINGLEN(obj) the length of the string (ideally O(1)) +// STB_TEXTEDIT_LAYOUTROW(&r,obj,n) returns the results of laying out a line of characters +// starting from character #n (see discussion below) +// STB_TEXTEDIT_GETWIDTH(obj,n,i) returns the pixel delta from the xpos of the i'th character +// to the xpos of the i+1'th char for a line of characters +// starting at character #n (i.e. accounts for kerning +// with previous char) +// STB_TEXTEDIT_KEYTOTEXT(k) maps a keyboard input to an insertable character +// (return type is int, -1 means not valid to insert) +// STB_TEXTEDIT_GETCHAR(obj,i) returns the i'th character of obj, 0-based +// STB_TEXTEDIT_NEWLINE the character returned by _GETCHAR() we recognize +// as manually wordwrapping for end-of-line positioning +// +// STB_TEXTEDIT_DELETECHARS(obj,i,n) delete n characters starting at i +// STB_TEXTEDIT_INSERTCHARS(obj,i,c*,n) insert n characters at i (pointed to by STB_TEXTEDIT_CHARTYPE*) +// +// STB_TEXTEDIT_K_SHIFT a power of two that is or'd in to a keyboard input to represent the shift key +// +// STB_TEXTEDIT_K_LEFT keyboard input to move cursor left +// STB_TEXTEDIT_K_RIGHT keyboard input to move cursor right +// STB_TEXTEDIT_K_UP keyboard input to move cursor up +// STB_TEXTEDIT_K_DOWN keyboard input to move cursor down +// STB_TEXTEDIT_K_LINESTART keyboard input to move cursor to start of line // e.g. HOME +// STB_TEXTEDIT_K_LINEEND keyboard input to move cursor to end of line // e.g. END +// STB_TEXTEDIT_K_TEXTSTART keyboard input to move cursor to start of text // e.g. ctrl-HOME +// STB_TEXTEDIT_K_TEXTEND keyboard input to move cursor to end of text // e.g. ctrl-END +// STB_TEXTEDIT_K_DELETE keyboard input to delete selection or character under cursor +// STB_TEXTEDIT_K_BACKSPACE keyboard input to delete selection or character left of cursor +// STB_TEXTEDIT_K_UNDO keyboard input to perform undo +// STB_TEXTEDIT_K_REDO keyboard input to perform redo +// +// Optional: +// STB_TEXTEDIT_K_INSERT keyboard input to toggle insert mode +// STB_TEXTEDIT_IS_SPACE(ch) true if character is whitespace (e.g. 'isspace'), +// required for default WORDLEFT/WORDRIGHT handlers +// STB_TEXTEDIT_MOVEWORDLEFT(obj,i) custom handler for WORDLEFT, returns index to move cursor to +// STB_TEXTEDIT_MOVEWORDRIGHT(obj,i) custom handler for WORDRIGHT, returns index to move cursor to +// STB_TEXTEDIT_K_WORDLEFT keyboard input to move cursor left one word // e.g. ctrl-LEFT +// STB_TEXTEDIT_K_WORDRIGHT keyboard input to move cursor right one word // e.g. ctrl-RIGHT +// STB_TEXTEDIT_K_LINESTART2 secondary keyboard input to move cursor to start of line +// STB_TEXTEDIT_K_LINEEND2 secondary keyboard input to move cursor to end of line +// STB_TEXTEDIT_K_TEXTSTART2 secondary keyboard input to move cursor to start of text +// STB_TEXTEDIT_K_TEXTEND2 secondary keyboard input to move cursor to end of text +// +// Todo: +// STB_TEXTEDIT_K_PGUP keyboard input to move cursor up a page +// STB_TEXTEDIT_K_PGDOWN keyboard input to move cursor down a page +// +// Keyboard input must be encoded as a single integer value; e.g. a character code +// and some bitflags that represent shift states. to simplify the interface, SHIFT must +// be a bitflag, so we can test the shifted state of cursor movements to allow selection, +// i.e. (STB_TEXTED_K_RIGHT|STB_TEXTEDIT_K_SHIFT) should be shifted right-arrow. +// +// You can encode other things, such as CONTROL or ALT, in additional bits, and +// then test for their presence in e.g. STB_TEXTEDIT_K_WORDLEFT. For example, +// my Windows implementations add an additional CONTROL bit, and an additional KEYDOWN +// bit. Then all of the STB_TEXTEDIT_K_ values bitwise-or in the KEYDOWN bit, +// and I pass both WM_KEYDOWN and WM_CHAR events to the "key" function in the +// API below. The control keys will only match WM_KEYDOWN events because of the +// keydown bit I add, and STB_TEXTEDIT_KEYTOTEXT only tests for the KEYDOWN +// bit so it only decodes WM_CHAR events. +// +// STB_TEXTEDIT_LAYOUTROW returns information about the shape of one displayed +// row of characters assuming they start on the i'th character--the width and +// the height and the number of characters consumed. This allows this library +// to traverse the entire layout incrementally. You need to compute word-wrapping +// here. +// +// Each textfield keeps its own insert mode state, which is not how normal +// applications work. To keep an app-wide insert mode, update/copy the +// "insert_mode" field of STB_TexteditState before/after calling API functions. +// +// API +// +// void stb_textedit_initialize_state(STB_TexteditState *state, int is_single_line) +// +// void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) +// void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) +// int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) +// int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE *text, int len) +// void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int key) +// +// Each of these functions potentially updates the string and updates the +// state. +// +// initialize_state: +// set the textedit state to a known good default state when initially +// constructing the textedit. +// +// click: +// call this with the mouse x,y on a mouse down; it will update the cursor +// and reset the selection start/end to the cursor point. the x,y must +// be relative to the text widget, with (0,0) being the top left. +// +// drag: +// call this with the mouse x,y on a mouse drag/up; it will update the +// cursor and the selection end point +// +// cut: +// call this to delete the current selection; returns true if there was +// one. you should FIRST copy the current selection to the system paste buffer. +// (To copy, just copy the current selection out of the string yourself.) +// +// paste: +// call this to paste text at the current cursor point or over the current +// selection if there is one. +// +// key: +// call this for keyboard inputs sent to the textfield. you can use it +// for "key down" events or for "translated" key events. if you need to +// do both (as in Win32), or distinguish Unicode characters from control +// inputs, set a high bit to distinguish the two; then you can define the +// various definitions like STB_TEXTEDIT_K_LEFT have the is-key-event bit +// set, and make STB_TEXTEDIT_KEYTOCHAR check that the is-key-event bit is +// clear. +// +// When rendering, you can read the cursor position and selection state from +// the STB_TexteditState. +// +// +// Notes: +// +// This is designed to be usable in IMGUI, so it allows for the possibility of +// running in an IMGUI that has NOT cached the multi-line layout. For this +// reason, it provides an interface that is compatible with computing the +// layout incrementally--we try to make sure we make as few passes through +// as possible. (For example, to locate the mouse pointer in the text, we +// could define functions that return the X and Y positions of characters +// and binary search Y and then X, but if we're doing dynamic layout this +// will run the layout algorithm many times, so instead we manually search +// forward in one pass. Similar logic applies to e.g. up-arrow and +// down-arrow movement.) +// +// If it's run in a widget that *has* cached the layout, then this is less +// efficient, but it's not horrible on modern computers. But you wouldn't +// want to edit million-line files with it. + + +//////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////// +//// +//// Header-file mode +//// +//// + +#ifndef INCLUDE_STB_TEXTEDIT_H +#define INCLUDE_STB_TEXTEDIT_H + +//////////////////////////////////////////////////////////////////////// +// +// STB_TexteditState +// +// Definition of STB_TexteditState which you should store +// per-textfield; it includes cursor position, selection state, +// and undo state. +// + +#ifndef STB_TEXTEDIT_UNDOSTATECOUNT +#define STB_TEXTEDIT_UNDOSTATECOUNT 99 +#endif +#ifndef STB_TEXTEDIT_UNDOCHARCOUNT +#define STB_TEXTEDIT_UNDOCHARCOUNT 999 +#endif +#ifndef STB_TEXTEDIT_CHARTYPE +#define STB_TEXTEDIT_CHARTYPE int +#endif +#ifndef STB_TEXTEDIT_POSITIONTYPE +#define STB_TEXTEDIT_POSITIONTYPE int +#endif + +typedef struct +{ + // private data + STB_TEXTEDIT_POSITIONTYPE where; + short insert_length; + short delete_length; + short char_storage; +} StbUndoRecord; + +typedef struct +{ + // private data + StbUndoRecord undo_rec [STB_TEXTEDIT_UNDOSTATECOUNT]; + STB_TEXTEDIT_CHARTYPE undo_char[STB_TEXTEDIT_UNDOCHARCOUNT]; + short undo_point, redo_point; + short undo_char_point, redo_char_point; +} StbUndoState; + +typedef struct +{ + ///////////////////// + // + // public data + // + + int cursor; + // position of the text cursor within the string + + int select_start; // selection start point + int select_end; + // selection start and end point in characters; if equal, no selection. + // note that start may be less than or greater than end (e.g. when + // dragging the mouse, start is where the initial click was, and you + // can drag in either direction) + + unsigned char insert_mode; + // each textfield keeps its own insert mode state. to keep an app-wide + // insert mode, copy this value in/out of the app state + + ///////////////////// + // + // private data + // + unsigned char cursor_at_end_of_line; // not implemented yet + unsigned char initialized; + unsigned char has_preferred_x; + unsigned char single_line; + unsigned char padding1, padding2, padding3; + float preferred_x; // this determines where the cursor up/down tries to seek to along x + StbUndoState undostate; +} STB_TexteditState; + + +//////////////////////////////////////////////////////////////////////// +// +// StbTexteditRow +// +// Result of layout query, used by stb_textedit to determine where +// the text in each row is. + +// result of layout query +typedef struct +{ + float x0,x1; // starting x location, end x location (allows for align=right, etc) + float baseline_y_delta; // position of baseline relative to previous row's baseline + float ymin,ymax; // height of row above and below baseline + int num_chars; +} StbTexteditRow; +#endif //INCLUDE_STB_TEXTEDIT_H + + +//////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////// +//// +//// Implementation mode +//// +//// + + +// implementation isn't include-guarded, since it might have indirectly +// included just the "header" portion +#ifdef STB_TEXTEDIT_IMPLEMENTATION + +#ifndef STB_TEXTEDIT_memmove +#include +#define STB_TEXTEDIT_memmove memmove +#endif + + +///////////////////////////////////////////////////////////////////////////// +// +// Mouse input handling +// + +// traverse the layout to locate the nearest character to a display position +static int stb_text_locate_coord(STB_TEXTEDIT_STRING *str, float x, float y) +{ + StbTexteditRow r; + int n = STB_TEXTEDIT_STRINGLEN(str); + float base_y = 0, prev_x; + int i=0, k; + + r.x0 = r.x1 = 0; + r.ymin = r.ymax = 0; + r.num_chars = 0; + + // search rows to find one that straddles 'y' + while (i < n) { + STB_TEXTEDIT_LAYOUTROW(&r, str, i); + if (r.num_chars <= 0) + return n; + + if (i==0 && y < base_y + r.ymin) + return 0; + + if (y < base_y + r.ymax) + break; + + i += r.num_chars; + base_y += r.baseline_y_delta; + } + + // below all text, return 'after' last character + if (i >= n) + return n; + + // check if it's before the beginning of the line + if (x < r.x0) + return i; + + // check if it's before the end of the line + if (x < r.x1) { + // search characters in row for one that straddles 'x' + prev_x = r.x0; + for (k=0; k < r.num_chars; ++k) { + float w = STB_TEXTEDIT_GETWIDTH(str, i, k); + if (x < prev_x+w) { + if (x < prev_x+w/2) + return k+i; + else + return k+i+1; + } + prev_x += w; + } + // shouldn't happen, but if it does, fall through to end-of-line case + } + + // if the last character is a newline, return that. otherwise return 'after' the last character + if (STB_TEXTEDIT_GETCHAR(str, i+r.num_chars-1) == STB_TEXTEDIT_NEWLINE) + return i+r.num_chars-1; + else + return i+r.num_chars; +} + +// API click: on mouse down, move the cursor to the clicked location, and reset the selection +static void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) +{ + state->cursor = stb_text_locate_coord(str, x, y); + state->select_start = state->cursor; + state->select_end = state->cursor; + state->has_preferred_x = 0; +} + +// API drag: on mouse drag, move the cursor and selection endpoint to the clicked location +static void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) +{ + int p = stb_text_locate_coord(str, x, y); + if (state->select_start == state->select_end) + state->select_start = state->cursor; + state->cursor = state->select_end = p; +} + +///////////////////////////////////////////////////////////////////////////// +// +// Keyboard input handling +// + +// forward declarations +static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state); +static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state); +static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length); +static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length); +static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length); + +typedef struct +{ + float x,y; // position of n'th character + float height; // height of line + int first_char, length; // first char of row, and length + int prev_first; // first char of previous row +} StbFindState; + +// find the x/y location of a character, and remember info about the previous row in +// case we get a move-up event (for page up, we'll have to rescan) +static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *str, int n, int single_line) +{ + StbTexteditRow r; + int prev_start = 0; + int z = STB_TEXTEDIT_STRINGLEN(str); + int i=0, first; + + if (n == z) { + // if it's at the end, then find the last line -- simpler than trying to + // explicitly handle this case in the regular code + if (single_line) { + STB_TEXTEDIT_LAYOUTROW(&r, str, 0); + find->y = 0; + find->first_char = 0; + find->length = z; + find->height = r.ymax - r.ymin; + find->x = r.x1; + } else { + find->y = 0; + find->x = 0; + find->height = 1; + while (i < z) { + STB_TEXTEDIT_LAYOUTROW(&r, str, i); + prev_start = i; + i += r.num_chars; + } + find->first_char = i; + find->length = 0; + find->prev_first = prev_start; + } + return; + } + + // search rows to find the one that straddles character n + find->y = 0; + + for(;;) { + STB_TEXTEDIT_LAYOUTROW(&r, str, i); + if (n < i + r.num_chars) + break; + prev_start = i; + i += r.num_chars; + find->y += r.baseline_y_delta; + } + + find->first_char = first = i; + find->length = r.num_chars; + find->height = r.ymax - r.ymin; + find->prev_first = prev_start; + + // now scan to find xpos + find->x = r.x0; + i = 0; + for (i=0; first+i < n; ++i) + find->x += STB_TEXTEDIT_GETWIDTH(str, first, i); +} + +#define STB_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end) + +// make the selection/cursor state valid if client altered the string +static void stb_textedit_clamp(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) +{ + int n = STB_TEXTEDIT_STRINGLEN(str); + if (STB_TEXT_HAS_SELECTION(state)) { + if (state->select_start > n) state->select_start = n; + if (state->select_end > n) state->select_end = n; + // if clamping forced them to be equal, move the cursor to match + if (state->select_start == state->select_end) + state->cursor = state->select_start; + } + if (state->cursor > n) state->cursor = n; +} + +// delete characters while updating undo +static void stb_textedit_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int len) +{ + stb_text_makeundo_delete(str, state, where, len); + STB_TEXTEDIT_DELETECHARS(str, where, len); + state->has_preferred_x = 0; +} + +// delete the section +static void stb_textedit_delete_selection(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) +{ + stb_textedit_clamp(str, state); + if (STB_TEXT_HAS_SELECTION(state)) { + if (state->select_start < state->select_end) { + stb_textedit_delete(str, state, state->select_start, state->select_end - state->select_start); + state->select_end = state->cursor = state->select_start; + } else { + stb_textedit_delete(str, state, state->select_end, state->select_start - state->select_end); + state->select_start = state->cursor = state->select_end; + } + state->has_preferred_x = 0; + } +} + +// canoncialize the selection so start <= end +static void stb_textedit_sortselection(STB_TexteditState *state) +{ + if (state->select_end < state->select_start) { + int temp = state->select_end; + state->select_end = state->select_start; + state->select_start = temp; + } +} + +// move cursor to first character of selection +static void stb_textedit_move_to_first(STB_TexteditState *state) +{ + if (STB_TEXT_HAS_SELECTION(state)) { + stb_textedit_sortselection(state); + state->cursor = state->select_start; + state->select_end = state->select_start; + state->has_preferred_x = 0; + } +} + +// move cursor to last character of selection +static void stb_textedit_move_to_last(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) +{ + if (STB_TEXT_HAS_SELECTION(state)) { + stb_textedit_sortselection(state); + stb_textedit_clamp(str, state); + state->cursor = state->select_end; + state->select_start = state->select_end; + state->has_preferred_x = 0; + } +} + +#ifdef STB_TEXTEDIT_IS_SPACE +static int is_word_boundary( STB_TEXTEDIT_STRING *str, int idx ) +{ + return idx > 0 ? (STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str,idx-1) ) && !STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str, idx) ) ) : 1; +} + +#ifndef STB_TEXTEDIT_MOVEWORDLEFT +static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *str, int c ) +{ + --c; // always move at least one character + while( c >= 0 && !is_word_boundary( str, c ) ) + --c; + + if( c < 0 ) + c = 0; + + return c; +} +#define STB_TEXTEDIT_MOVEWORDLEFT stb_textedit_move_to_word_previous +#endif + +#ifndef STB_TEXTEDIT_MOVEWORDRIGHT +static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *str, int c ) +{ + const int len = STB_TEXTEDIT_STRINGLEN(str); + ++c; // always move at least one character + while( c < len && !is_word_boundary( str, c ) ) + ++c; + + if( c > len ) + c = len; + + return c; +} +#define STB_TEXTEDIT_MOVEWORDRIGHT stb_textedit_move_to_word_next +#endif + +#endif + +// update selection and cursor to match each other +static void stb_textedit_prep_selection_at_cursor(STB_TexteditState *state) +{ + if (!STB_TEXT_HAS_SELECTION(state)) + state->select_start = state->select_end = state->cursor; + else + state->cursor = state->select_end; +} + +// API cut: delete selection +static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) +{ + if (STB_TEXT_HAS_SELECTION(state)) { + stb_textedit_delete_selection(str,state); // implicity clamps + state->has_preferred_x = 0; + return 1; + } + return 0; +} + +// API paste: replace existing selection with passed-in text +static int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE const *ctext, int len) +{ + STB_TEXTEDIT_CHARTYPE *text = (STB_TEXTEDIT_CHARTYPE *) ctext; + // if there's a selection, the paste should delete it + stb_textedit_clamp(str, state); + stb_textedit_delete_selection(str,state); + // try to insert the characters + if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, len)) { + stb_text_makeundo_insert(state, state->cursor, len); + state->cursor += len; + state->has_preferred_x = 0; + return 1; + } + // remove the undo since we didn't actually insert the characters + if (state->undostate.undo_point) + --state->undostate.undo_point; + return 0; +} + +// API key: process a keyboard input +static void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int key) +{ +retry: + switch (key) { + default: { + int c = STB_TEXTEDIT_KEYTOTEXT(key); + if (c > 0) { + STB_TEXTEDIT_CHARTYPE ch = (STB_TEXTEDIT_CHARTYPE) c; + + // can't add newline in single-line mode + if (c == '\n' && state->single_line) + break; + + if (state->insert_mode && !STB_TEXT_HAS_SELECTION(state) && state->cursor < STB_TEXTEDIT_STRINGLEN(str)) { + stb_text_makeundo_replace(str, state, state->cursor, 1, 1); + STB_TEXTEDIT_DELETECHARS(str, state->cursor, 1); + if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { + ++state->cursor; + state->has_preferred_x = 0; + } + } else { + stb_textedit_delete_selection(str,state); // implicity clamps + if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { + stb_text_makeundo_insert(state, state->cursor, 1); + ++state->cursor; + state->has_preferred_x = 0; + } + } + } + break; + } + +#ifdef STB_TEXTEDIT_K_INSERT + case STB_TEXTEDIT_K_INSERT: + state->insert_mode = !state->insert_mode; + break; +#endif + + case STB_TEXTEDIT_K_UNDO: + stb_text_undo(str, state); + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_REDO: + stb_text_redo(str, state); + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_LEFT: + // if currently there's a selection, move cursor to start of selection + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_first(state); + else + if (state->cursor > 0) + --state->cursor; + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_RIGHT: + // if currently there's a selection, move cursor to end of selection + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_last(str, state); + else + ++state->cursor; + stb_textedit_clamp(str, state); + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_LEFT | STB_TEXTEDIT_K_SHIFT: + stb_textedit_clamp(str, state); + stb_textedit_prep_selection_at_cursor(state); + // move selection left + if (state->select_end > 0) + --state->select_end; + state->cursor = state->select_end; + state->has_preferred_x = 0; + break; + +#ifdef STB_TEXTEDIT_MOVEWORDLEFT + case STB_TEXTEDIT_K_WORDLEFT: + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_first(state); + else { + state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); + stb_textedit_clamp( str, state ); + } + break; + + case STB_TEXTEDIT_K_WORDLEFT | STB_TEXTEDIT_K_SHIFT: + if( !STB_TEXT_HAS_SELECTION( state ) ) + stb_textedit_prep_selection_at_cursor(state); + + state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); + state->select_end = state->cursor; + + stb_textedit_clamp( str, state ); + break; +#endif + +#ifdef STB_TEXTEDIT_MOVEWORDRIGHT + case STB_TEXTEDIT_K_WORDRIGHT: + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_last(str, state); + else { + state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); + stb_textedit_clamp( str, state ); + } + break; + + case STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT: + if( !STB_TEXT_HAS_SELECTION( state ) ) + stb_textedit_prep_selection_at_cursor(state); + + state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); + state->select_end = state->cursor; + + stb_textedit_clamp( str, state ); + break; +#endif + + case STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_SHIFT: + stb_textedit_prep_selection_at_cursor(state); + // move selection right + ++state->select_end; + stb_textedit_clamp(str, state); + state->cursor = state->select_end; + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_DOWN: + case STB_TEXTEDIT_K_DOWN | STB_TEXTEDIT_K_SHIFT: { + StbFindState find; + StbTexteditRow row; + int i, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; + + if (state->single_line) { + // on windows, up&down in single-line behave like left&right + key = STB_TEXTEDIT_K_RIGHT | (key & STB_TEXTEDIT_K_SHIFT); + goto retry; + } + + if (sel) + stb_textedit_prep_selection_at_cursor(state); + else if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_last(str,state); + + // compute current position of cursor point + stb_textedit_clamp(str, state); + stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); + + // now find character position down a row + if (find.length) { + float goal_x = state->has_preferred_x ? state->preferred_x : find.x; + float x; + int start = find.first_char + find.length; + state->cursor = start; + STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); + x = row.x0; + for (i=0; i < row.num_chars; ++i) { + float dx = STB_TEXTEDIT_GETWIDTH(str, start, i); + #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE + if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) + break; + #endif + x += dx; + if (x > goal_x) + break; + ++state->cursor; + } + stb_textedit_clamp(str, state); + + state->has_preferred_x = 1; + state->preferred_x = goal_x; + + if (sel) + state->select_end = state->cursor; + } + break; + } + + case STB_TEXTEDIT_K_UP: + case STB_TEXTEDIT_K_UP | STB_TEXTEDIT_K_SHIFT: { + StbFindState find; + StbTexteditRow row; + int i, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; + + if (state->single_line) { + // on windows, up&down become left&right + key = STB_TEXTEDIT_K_LEFT | (key & STB_TEXTEDIT_K_SHIFT); + goto retry; + } + + if (sel) + stb_textedit_prep_selection_at_cursor(state); + else if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_first(state); + + // compute current position of cursor point + stb_textedit_clamp(str, state); + stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); + + // can only go up if there's a previous row + if (find.prev_first != find.first_char) { + // now find character position up a row + float goal_x = state->has_preferred_x ? state->preferred_x : find.x; + float x; + state->cursor = find.prev_first; + STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); + x = row.x0; + for (i=0; i < row.num_chars; ++i) { + float dx = STB_TEXTEDIT_GETWIDTH(str, find.prev_first, i); + #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE + if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) + break; + #endif + x += dx; + if (x > goal_x) + break; + ++state->cursor; + } + stb_textedit_clamp(str, state); + + state->has_preferred_x = 1; + state->preferred_x = goal_x; + + if (sel) + state->select_end = state->cursor; + } + break; + } + + case STB_TEXTEDIT_K_DELETE: + case STB_TEXTEDIT_K_DELETE | STB_TEXTEDIT_K_SHIFT: + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_delete_selection(str, state); + else { + int n = STB_TEXTEDIT_STRINGLEN(str); + if (state->cursor < n) + stb_textedit_delete(str, state, state->cursor, 1); + } + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_BACKSPACE: + case STB_TEXTEDIT_K_BACKSPACE | STB_TEXTEDIT_K_SHIFT: + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_delete_selection(str, state); + else { + stb_textedit_clamp(str, state); + if (state->cursor > 0) { + stb_textedit_delete(str, state, state->cursor-1, 1); + --state->cursor; + } + } + state->has_preferred_x = 0; + break; + +#ifdef STB_TEXTEDIT_K_TEXTSTART2 + case STB_TEXTEDIT_K_TEXTSTART2: +#endif + case STB_TEXTEDIT_K_TEXTSTART: + state->cursor = state->select_start = state->select_end = 0; + state->has_preferred_x = 0; + break; + +#ifdef STB_TEXTEDIT_K_TEXTEND2 + case STB_TEXTEDIT_K_TEXTEND2: +#endif + case STB_TEXTEDIT_K_TEXTEND: + state->cursor = STB_TEXTEDIT_STRINGLEN(str); + state->select_start = state->select_end = 0; + state->has_preferred_x = 0; + break; + +#ifdef STB_TEXTEDIT_K_TEXTSTART2 + case STB_TEXTEDIT_K_TEXTSTART2 | STB_TEXTEDIT_K_SHIFT: +#endif + case STB_TEXTEDIT_K_TEXTSTART | STB_TEXTEDIT_K_SHIFT: + stb_textedit_prep_selection_at_cursor(state); + state->cursor = state->select_end = 0; + state->has_preferred_x = 0; + break; + +#ifdef STB_TEXTEDIT_K_TEXTEND2 + case STB_TEXTEDIT_K_TEXTEND2 | STB_TEXTEDIT_K_SHIFT: +#endif + case STB_TEXTEDIT_K_TEXTEND | STB_TEXTEDIT_K_SHIFT: + stb_textedit_prep_selection_at_cursor(state); + state->cursor = state->select_end = STB_TEXTEDIT_STRINGLEN(str); + state->has_preferred_x = 0; + break; + + +#ifdef STB_TEXTEDIT_K_LINESTART2 + case STB_TEXTEDIT_K_LINESTART2: +#endif + case STB_TEXTEDIT_K_LINESTART: + stb_textedit_clamp(str, state); + stb_textedit_move_to_first(state); + if (state->single_line) + state->cursor = 0; + else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) + --state->cursor; + state->has_preferred_x = 0; + break; + +#ifdef STB_TEXTEDIT_K_LINEEND2 + case STB_TEXTEDIT_K_LINEEND2: +#endif + case STB_TEXTEDIT_K_LINEEND: { + int n = STB_TEXTEDIT_STRINGLEN(str); + stb_textedit_clamp(str, state); + stb_textedit_move_to_first(state); + if (state->single_line) + state->cursor = n; + else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) + ++state->cursor; + state->has_preferred_x = 0; + break; + } + +#ifdef STB_TEXTEDIT_K_LINESTART2 + case STB_TEXTEDIT_K_LINESTART2 | STB_TEXTEDIT_K_SHIFT: +#endif + case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT: + stb_textedit_clamp(str, state); + stb_textedit_prep_selection_at_cursor(state); + if (state->single_line) + state->cursor = 0; + else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) + --state->cursor; + state->select_end = state->cursor; + state->has_preferred_x = 0; + break; + +#ifdef STB_TEXTEDIT_K_LINEEND2 + case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT: +#endif + case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: { + int n = STB_TEXTEDIT_STRINGLEN(str); + stb_textedit_clamp(str, state); + stb_textedit_prep_selection_at_cursor(state); + if (state->single_line) + state->cursor = n; + else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) + ++state->cursor; + state->select_end = state->cursor; + state->has_preferred_x = 0; + break; + } + +// @TODO: +// STB_TEXTEDIT_K_PGUP - move cursor up a page +// STB_TEXTEDIT_K_PGDOWN - move cursor down a page + } +} + +///////////////////////////////////////////////////////////////////////////// +// +// Undo processing +// +// @OPTIMIZE: the undo/redo buffer should be circular + +static void stb_textedit_flush_redo(StbUndoState *state) +{ + state->redo_point = STB_TEXTEDIT_UNDOSTATECOUNT; + state->redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT; +} + +// discard the oldest entry in the undo list +static void stb_textedit_discard_undo(StbUndoState *state) +{ + if (state->undo_point > 0) { + // if the 0th undo state has characters, clean those up + if (state->undo_rec[0].char_storage >= 0) { + int n = state->undo_rec[0].insert_length, i; + // delete n characters from all other records + state->undo_char_point = state->undo_char_point - (short) n; // vsnet05 + STB_TEXTEDIT_memmove(state->undo_char, state->undo_char + n, (size_t) ((size_t)state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE))); + for (i=0; i < state->undo_point; ++i) + if (state->undo_rec[i].char_storage >= 0) + state->undo_rec[i].char_storage = state->undo_rec[i].char_storage - (short) n; // vsnet05 // @OPTIMIZE: get rid of char_storage and infer it + } + --state->undo_point; + STB_TEXTEDIT_memmove(state->undo_rec, state->undo_rec+1, (size_t) ((size_t)state->undo_point*sizeof(state->undo_rec[0]))); + } +} + +// discard the oldest entry in the redo list--it's bad if this +// ever happens, but because undo & redo have to store the actual +// characters in different cases, the redo character buffer can +// fill up even though the undo buffer didn't +static void stb_textedit_discard_redo(StbUndoState *state) +{ + int k = STB_TEXTEDIT_UNDOSTATECOUNT-1; + + if (state->redo_point <= k) { + // if the k'th undo state has characters, clean those up + if (state->undo_rec[k].char_storage >= 0) { + int n = state->undo_rec[k].insert_length, i; + // delete n characters from all other records + state->redo_char_point = state->redo_char_point + (short) n; // vsnet05 + STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((size_t)(STB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE))); + for (i=state->redo_point; i < k; ++i) + if (state->undo_rec[i].char_storage >= 0) + state->undo_rec[i].char_storage = state->undo_rec[i].char_storage + (short) n; // vsnet05 + } + STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point, state->undo_rec + state->redo_point-1, (size_t) ((size_t)(STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0]))); + ++state->redo_point; + } +} + +static StbUndoRecord *stb_text_create_undo_record(StbUndoState *state, int numchars) +{ + // any time we create a new undo record, we discard redo + stb_textedit_flush_redo(state); + + // if we have no free records, we have to make room, by sliding the + // existing records down + if (state->undo_point == STB_TEXTEDIT_UNDOSTATECOUNT) + stb_textedit_discard_undo(state); + + // if the characters to store won't possibly fit in the buffer, we can't undo + if (numchars > STB_TEXTEDIT_UNDOCHARCOUNT) { + state->undo_point = 0; + state->undo_char_point = 0; + return NULL; + } + + // if we don't have enough free characters in the buffer, we have to make room + while (state->undo_char_point + numchars > STB_TEXTEDIT_UNDOCHARCOUNT) + stb_textedit_discard_undo(state); + + return &state->undo_rec[state->undo_point++]; +} + +static STB_TEXTEDIT_CHARTYPE *stb_text_createundo(StbUndoState *state, int pos, int insert_len, int delete_len) +{ + StbUndoRecord *r = stb_text_create_undo_record(state, insert_len); + if (r == NULL) + return NULL; + + r->where = pos; + r->insert_length = (short) insert_len; + r->delete_length = (short) delete_len; + + if (insert_len == 0) { + r->char_storage = -1; + return NULL; + } else { + r->char_storage = state->undo_char_point; + state->undo_char_point = state->undo_char_point + (short) insert_len; + return &state->undo_char[r->char_storage]; + } +} + +static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) +{ + StbUndoState *s = &state->undostate; + StbUndoRecord u, *r; + if (s->undo_point == 0) + return; + + // we need to do two things: apply the undo record, and create a redo record + u = s->undo_rec[s->undo_point-1]; + r = &s->undo_rec[s->redo_point-1]; + r->char_storage = -1; + + r->insert_length = u.delete_length; + r->delete_length = u.insert_length; + r->where = u.where; + + if (u.delete_length) { + // if the undo record says to delete characters, then the redo record will + // need to re-insert the characters that get deleted, so we need to store + // them. + + // there are three cases: + // there's enough room to store the characters + // characters stored for *redoing* don't leave room for redo + // characters stored for *undoing* don't leave room for redo + // if the last is true, we have to bail + + if (s->undo_char_point + u.delete_length >= STB_TEXTEDIT_UNDOCHARCOUNT) { + // the undo records take up too much character space; there's no space to store the redo characters + r->insert_length = 0; + } else { + int i; + + // there's definitely room to store the characters eventually + while (s->undo_char_point + u.delete_length > s->redo_char_point) { + // there's currently not enough room, so discard a redo record + stb_textedit_discard_redo(s); + // should never happen: + if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT) + return; + } + r = &s->undo_rec[s->redo_point-1]; + + r->char_storage = s->redo_char_point - u.delete_length; + s->redo_char_point = s->redo_char_point - (short) u.delete_length; + + // now save the characters + for (i=0; i < u.delete_length; ++i) + s->undo_char[r->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u.where + i); + } + + // now we can carry out the deletion + STB_TEXTEDIT_DELETECHARS(str, u.where, u.delete_length); + } + + // check type of recorded action: + if (u.insert_length) { + // easy case: was a deletion, so we need to insert n characters + STB_TEXTEDIT_INSERTCHARS(str, u.where, &s->undo_char[u.char_storage], u.insert_length); + s->undo_char_point -= u.insert_length; + } + + state->cursor = u.where + u.insert_length; + + s->undo_point--; + s->redo_point--; +} + +static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) +{ + StbUndoState *s = &state->undostate; + StbUndoRecord *u, r; + if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT) + return; + + // we need to do two things: apply the redo record, and create an undo record + u = &s->undo_rec[s->undo_point]; + r = s->undo_rec[s->redo_point]; + + // we KNOW there must be room for the undo record, because the redo record + // was derived from an undo record + + u->delete_length = r.insert_length; + u->insert_length = r.delete_length; + u->where = r.where; + u->char_storage = -1; + + if (r.delete_length) { + // the redo record requires us to delete characters, so the undo record + // needs to store the characters + + if (s->undo_char_point + u->insert_length > s->redo_char_point) { + u->insert_length = 0; + u->delete_length = 0; + } else { + int i; + u->char_storage = s->undo_char_point; + s->undo_char_point = s->undo_char_point + u->insert_length; + + // now save the characters + for (i=0; i < u->insert_length; ++i) + s->undo_char[u->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u->where + i); + } + + STB_TEXTEDIT_DELETECHARS(str, r.where, r.delete_length); + } + + if (r.insert_length) { + // easy case: need to insert n characters + STB_TEXTEDIT_INSERTCHARS(str, r.where, &s->undo_char[r.char_storage], r.insert_length); + s->redo_char_point += r.insert_length; + } + + state->cursor = r.where + r.insert_length; + + s->undo_point++; + s->redo_point++; +} + +static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length) +{ + stb_text_createundo(&state->undostate, where, 0, length); +} + +static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length) +{ + int i; + STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, length, 0); + if (p) { + for (i=0; i < length; ++i) + p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); + } +} + +static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length) +{ + int i; + STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, old_length, new_length); + if (p) { + for (i=0; i < old_length; ++i) + p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); + } +} + +// reset the state to default +static void stb_textedit_clear_state(STB_TexteditState *state, int is_single_line) +{ + state->undostate.undo_point = 0; + state->undostate.undo_char_point = 0; + state->undostate.redo_point = STB_TEXTEDIT_UNDOSTATECOUNT; + state->undostate.redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT; + state->select_end = state->select_start = 0; + state->cursor = 0; + state->has_preferred_x = 0; + state->preferred_x = 0; + state->cursor_at_end_of_line = 0; + state->initialized = 1; + state->single_line = (unsigned char) is_single_line; + state->insert_mode = 0; +} + +// API initialize +static void stb_textedit_initialize_state(STB_TexteditState *state, int is_single_line) +{ + stb_textedit_clear_state(state, is_single_line); +} +#endif//STB_TEXTEDIT_IMPLEMENTATION + +``` + +`imgui/stb_truetype.h`: + +```h +// stb_truetype.h - v1.14 - public domain +// authored from 2009-2016 by Sean Barrett / RAD Game Tools +// +// This library processes TrueType files: +// parse files +// extract glyph metrics +// extract glyph shapes +// render glyphs to one-channel bitmaps with antialiasing (box filter) +// +// Todo: +// non-MS cmaps +// crashproof on bad data +// hinting? (no longer patented) +// cleartype-style AA? +// optimize: use simple memory allocator for intermediates +// optimize: build edge-list directly from curves +// optimize: rasterize directly from curves? +// +// ADDITIONAL CONTRIBUTORS +// +// Mikko Mononen: compound shape support, more cmap formats +// Tor Andersson: kerning, subpixel rendering +// Dougall Johnson: OpenType / Type 2 font handling +// +// Misc other: +// Ryan Gordon +// Simon Glass +// github:IntellectualKitty +// +// Bug/warning reports/fixes: +// "Zer" on mollyrocket (with fix) +// Cass Everitt +// stoiko (Haemimont Games) +// Brian Hook +// Walter van Niftrik +// David Gow +// David Given +// Ivan-Assen Ivanov +// Anthony Pesch +// Johan Duparc +// Hou Qiming +// Fabian "ryg" Giesen +// Martins Mozeiko +// Cap Petschulat +// Omar Cornut +// github:aloucks +// Peter LaValle +// Sergey Popov +// Giumo X. Clanjor +// Higor Euripedes +// Thomas Fields +// Derek Vinyard +// +// VERSION HISTORY +// +// 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts, num-fonts-in-TTC function +// 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual +// 1.11 (2016-04-02) fix unused-variable warning +// 1.10 (2016-04-02) user-defined fabs(); rare memory leak; remove duplicate typedef +// 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use allocation userdata properly +// 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges +// 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; +// variant PackFontRanges to pack and render in separate phases; +// fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); +// fixed an assert() bug in the new rasterizer +// replace assert() with STBTT_assert() in new rasterizer +// +// Full history can be found at the end of this file. +// +// LICENSE +// +// This software is dual-licensed to the public domain and under the following +// license: you are granted a perpetual, irrevocable license to copy, modify, +// publish, and distribute this file as you see fit. +// +// USAGE +// +// Include this file in whatever places neeed to refer to it. In ONE C/C++ +// file, write: +// #define STB_TRUETYPE_IMPLEMENTATION +// before the #include of this file. This expands out the actual +// implementation into that C/C++ file. +// +// To make the implementation private to the file that generates the implementation, +// #define STBTT_STATIC +// +// Simple 3D API (don't ship this, but it's fine for tools and quick start) +// stbtt_BakeFontBitmap() -- bake a font to a bitmap for use as texture +// stbtt_GetBakedQuad() -- compute quad to draw for a given char +// +// Improved 3D API (more shippable): +// #include "stb_rect_pack.h" -- optional, but you really want it +// stbtt_PackBegin() +// stbtt_PackSetOversample() -- for improved quality on small fonts +// stbtt_PackFontRanges() -- pack and renders +// stbtt_PackEnd() +// stbtt_GetPackedQuad() +// +// "Load" a font file from a memory buffer (you have to keep the buffer loaded) +// stbtt_InitFont() +// stbtt_GetFontOffsetForIndex() -- indexing for TTC font collections +// stbtt_GetNumberOfFonts() -- number of fonts for TTC font collections +// +// Render a unicode codepoint to a bitmap +// stbtt_GetCodepointBitmap() -- allocates and returns a bitmap +// stbtt_MakeCodepointBitmap() -- renders into bitmap you provide +// stbtt_GetCodepointBitmapBox() -- how big the bitmap must be +// +// Character advance/positioning +// stbtt_GetCodepointHMetrics() +// stbtt_GetFontVMetrics() +// stbtt_GetCodepointKernAdvance() +// +// Starting with version 1.06, the rasterizer was replaced with a new, +// faster and generally-more-precise rasterizer. The new rasterizer more +// accurately measures pixel coverage for anti-aliasing, except in the case +// where multiple shapes overlap, in which case it overestimates the AA pixel +// coverage. Thus, anti-aliasing of intersecting shapes may look wrong. If +// this turns out to be a problem, you can re-enable the old rasterizer with +// #define STBTT_RASTERIZER_VERSION 1 +// which will incur about a 15% speed hit. +// +// ADDITIONAL DOCUMENTATION +// +// Immediately after this block comment are a series of sample programs. +// +// After the sample programs is the "header file" section. This section +// includes documentation for each API function. +// +// Some important concepts to understand to use this library: +// +// Codepoint +// Characters are defined by unicode codepoints, e.g. 65 is +// uppercase A, 231 is lowercase c with a cedilla, 0x7e30 is +// the hiragana for "ma". +// +// Glyph +// A visual character shape (every codepoint is rendered as +// some glyph) +// +// Glyph index +// A font-specific integer ID representing a glyph +// +// Baseline +// Glyph shapes are defined relative to a baseline, which is the +// bottom of uppercase characters. Characters extend both above +// and below the baseline. +// +// Current Point +// As you draw text to the screen, you keep track of a "current point" +// which is the origin of each character. The current point's vertical +// position is the baseline. Even "baked fonts" use this model. +// +// Vertical Font Metrics +// The vertical qualities of the font, used to vertically position +// and space the characters. See docs for stbtt_GetFontVMetrics. +// +// Font Size in Pixels or Points +// The preferred interface for specifying font sizes in stb_truetype +// is to specify how tall the font's vertical extent should be in pixels. +// If that sounds good enough, skip the next paragraph. +// +// Most font APIs instead use "points", which are a common typographic +// measurement for describing font size, defined as 72 points per inch. +// stb_truetype provides a point API for compatibility. However, true +// "per inch" conventions don't make much sense on computer displays +// since they different monitors have different number of pixels per +// inch. For example, Windows traditionally uses a convention that +// there are 96 pixels per inch, thus making 'inch' measurements have +// nothing to do with inches, and thus effectively defining a point to +// be 1.333 pixels. Additionally, the TrueType font data provides +// an explicit scale factor to scale a given font's glyphs to points, +// but the author has observed that this scale factor is often wrong +// for non-commercial fonts, thus making fonts scaled in points +// according to the TrueType spec incoherently sized in practice. +// +// ADVANCED USAGE +// +// Quality: +// +// - Use the functions with Subpixel at the end to allow your characters +// to have subpixel positioning. Since the font is anti-aliased, not +// hinted, this is very import for quality. (This is not possible with +// baked fonts.) +// +// - Kerning is now supported, and if you're supporting subpixel rendering +// then kerning is worth using to give your text a polished look. +// +// Performance: +// +// - Convert Unicode codepoints to glyph indexes and operate on the glyphs; +// if you don't do this, stb_truetype is forced to do the conversion on +// every call. +// +// - There are a lot of memory allocations. We should modify it to take +// a temp buffer and allocate from the temp buffer (without freeing), +// should help performance a lot. +// +// NOTES +// +// The system uses the raw data found in the .ttf file without changing it +// and without building auxiliary data structures. This is a bit inefficient +// on little-endian systems (the data is big-endian), but assuming you're +// caching the bitmaps or glyph shapes this shouldn't be a big deal. +// +// It appears to be very hard to programmatically determine what font a +// given file is in a general way. I provide an API for this, but I don't +// recommend it. +// +// +// SOURCE STATISTICS (based on v0.6c, 2050 LOC) +// +// Documentation & header file 520 LOC \___ 660 LOC documentation +// Sample code 140 LOC / +// Truetype parsing 620 LOC ---- 620 LOC TrueType +// Software rasterization 240 LOC \ . +// Curve tesselation 120 LOC \__ 550 LOC Bitmap creation +// Bitmap management 100 LOC / +// Baked bitmap interface 70 LOC / +// Font name matching & access 150 LOC ---- 150 +// C runtime library abstraction 60 LOC ---- 60 +// +// +// PERFORMANCE MEASUREMENTS FOR 1.06: +// +// 32-bit 64-bit +// Previous release: 8.83 s 7.68 s +// Pool allocations: 7.72 s 6.34 s +// Inline sort : 6.54 s 5.65 s +// New rasterizer : 5.63 s 5.00 s + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +//// +//// SAMPLE PROGRAMS +//// +// +// Incomplete text-in-3d-api example, which draws quads properly aligned to be lossless +// +#if 0 +#define STB_TRUETYPE_IMPLEMENTATION // force following include to generate implementation +#include "stb_truetype.h" + +unsigned char ttf_buffer[1<<20]; +unsigned char temp_bitmap[512*512]; + +stbtt_bakedchar cdata[96]; // ASCII 32..126 is 95 glyphs +GLuint ftex; + +void my_stbtt_initfont(void) +{ + fread(ttf_buffer, 1, 1<<20, fopen("c:/windows/fonts/times.ttf", "rb")); + stbtt_BakeFontBitmap(ttf_buffer,0, 32.0, temp_bitmap,512,512, 32,96, cdata); // no guarantee this fits! + // can free ttf_buffer at this point + glGenTextures(1, &ftex); + glBindTexture(GL_TEXTURE_2D, ftex); + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 512,512, 0, GL_ALPHA, GL_UNSIGNED_BYTE, temp_bitmap); + // can free temp_bitmap at this point + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); +} + +void my_stbtt_print(float x, float y, char *text) +{ + // assume orthographic projection with units = screen pixels, origin at top left + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, ftex); + glBegin(GL_QUADS); + while (*text) { + if (*text >= 32 && *text < 128) { + stbtt_aligned_quad q; + stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9 + glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y0); + glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y0); + glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y1); + glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y1); + } + ++text; + } + glEnd(); +} +#endif +// +// +////////////////////////////////////////////////////////////////////////////// +// +// Complete program (this compiles): get a single bitmap, print as ASCII art +// +#if 0 +#include +#define STB_TRUETYPE_IMPLEMENTATION // force following include to generate implementation +#include "stb_truetype.h" + +char ttf_buffer[1<<25]; + +int main(int argc, char **argv) +{ + stbtt_fontinfo font; + unsigned char *bitmap; + int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 'a'), s = (argc > 2 ? atoi(argv[2]) : 20); + + fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/arialbd.ttf", "rb")); + + stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0)); + bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0); + + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) + putchar(" .:ioVM@"[bitmap[j*w+i]>>5]); + putchar('\n'); + } + return 0; +} +#endif +// +// Output: +// +// .ii. +// @@@@@@. +// V@Mio@@o +// :i. V@V +// :oM@@M +// :@@@MM@M +// @@o o@M +// :@@. M@M +// @@@o@@@@ +// :M@@V:@@. +// +////////////////////////////////////////////////////////////////////////////// +// +// Complete program: print "Hello World!" banner, with bugs +// +#if 0 +char buffer[24<<20]; +unsigned char screen[20][79]; + +int main(int arg, char **argv) +{ + stbtt_fontinfo font; + int i,j,ascent,baseline,ch=0; + float scale, xpos=2; // leave a little padding in case the character extends left + char *text = "Heljo World!"; // intentionally misspelled to show 'lj' brokenness + + fread(buffer, 1, 1000000, fopen("c:/windows/fonts/arialbd.ttf", "rb")); + stbtt_InitFont(&font, buffer, 0); + + scale = stbtt_ScaleForPixelHeight(&font, 15); + stbtt_GetFontVMetrics(&font, &ascent,0,0); + baseline = (int) (ascent*scale); + + while (text[ch]) { + int advance,lsb,x0,y0,x1,y1; + float x_shift = xpos - (float) floor(xpos); + stbtt_GetCodepointHMetrics(&font, text[ch], &advance, &lsb); + stbtt_GetCodepointBitmapBoxSubpixel(&font, text[ch], scale,scale,x_shift,0, &x0,&y0,&x1,&y1); + stbtt_MakeCodepointBitmapSubpixel(&font, &screen[baseline + y0][(int) xpos + x0], x1-x0,y1-y0, 79, scale,scale,x_shift,0, text[ch]); + // note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong + // because this API is really for baking character bitmaps into textures. if you want to render + // a sequence of characters, you really need to render each bitmap to a temp buffer, then + // "alpha blend" that into the working buffer + xpos += (advance * scale); + if (text[ch+1]) + xpos += scale*stbtt_GetCodepointKernAdvance(&font, text[ch],text[ch+1]); + ++ch; + } + + for (j=0; j < 20; ++j) { + for (i=0; i < 78; ++i) + putchar(" .:ioVM@"[screen[j][i]>>5]); + putchar('\n'); + } + + return 0; +} +#endif + + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +//// +//// INTEGRATION WITH YOUR CODEBASE +//// +//// The following sections allow you to supply alternate definitions +//// of C library functions used by stb_truetype. + +#ifdef STB_TRUETYPE_IMPLEMENTATION + // #define your own (u)stbtt_int8/16/32 before including to override this + #ifndef stbtt_uint8 + typedef unsigned char stbtt_uint8; + typedef signed char stbtt_int8; + typedef unsigned short stbtt_uint16; + typedef signed short stbtt_int16; + typedef unsigned int stbtt_uint32; + typedef signed int stbtt_int32; + #endif + + typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1]; + typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1]; + + // #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h + #ifndef STBTT_ifloor + #include + #define STBTT_ifloor(x) ((int) floor(x)) + #define STBTT_iceil(x) ((int) ceil(x)) + #endif + + #ifndef STBTT_sqrt + #include + #define STBTT_sqrt(x) sqrt(x) + #endif + + #ifndef STBTT_fabs + #include + #define STBTT_fabs(x) fabs(x) + #endif + + // #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h + #ifndef STBTT_malloc + #include + #define STBTT_malloc(x,u) ((void)(u),malloc(x)) + #define STBTT_free(x,u) ((void)(u),free(x)) + #endif + + #ifndef STBTT_assert + #include + #define STBTT_assert(x) assert(x) + #endif + + #ifndef STBTT_strlen + #include + #define STBTT_strlen(x) strlen(x) + #endif + + #ifndef STBTT_memcpy + #include + #define STBTT_memcpy memcpy + #define STBTT_memset memset + #endif +#endif + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +//// +//// INTERFACE +//// +//// + +#ifndef __STB_INCLUDE_STB_TRUETYPE_H__ +#define __STB_INCLUDE_STB_TRUETYPE_H__ + +#ifdef STBTT_STATIC +#define STBTT_DEF static +#else +#define STBTT_DEF extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// private structure +typedef struct +{ + unsigned char *data; + int cursor; + int size; +} stbtt__buf; + +////////////////////////////////////////////////////////////////////////////// +// +// TEXTURE BAKING API +// +// If you use this API, you only have to call two functions ever. +// + +typedef struct +{ + unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap + float xoff,yoff,xadvance; +} stbtt_bakedchar; + +STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) + float pixel_height, // height of font in pixels + unsigned char *pixels, int pw, int ph, // bitmap to be filled in + int first_char, int num_chars, // characters to bake + stbtt_bakedchar *chardata); // you allocate this, it's num_chars long +// if return is positive, the first unused row of the bitmap +// if return is negative, returns the negative of the number of characters that fit +// if return is 0, no characters fit and no rows were used +// This uses a very crappy packing. + +typedef struct +{ + float x0,y0,s0,t0; // top-left + float x1,y1,s1,t1; // bottom-right +} stbtt_aligned_quad; + +STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, // same data as above + int char_index, // character to display + float *xpos, float *ypos, // pointers to current position in screen pixel space + stbtt_aligned_quad *q, // output: quad to draw + int opengl_fillrule); // true if opengl fill rule; false if DX9 or earlier +// Call GetBakedQuad with char_index = 'character - first_char', and it +// creates the quad you need to draw and advances the current position. +// +// The coordinate system used assumes y increases downwards. +// +// Characters will extend both above and below the current position; +// see discussion of "BASELINE" above. +// +// It's inefficient; you might want to c&p it and optimize it. + + + +////////////////////////////////////////////////////////////////////////////// +// +// NEW TEXTURE BAKING API +// +// This provides options for packing multiple fonts into one atlas, not +// perfectly but better than nothing. + +typedef struct +{ + unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap + float xoff,yoff,xadvance; + float xoff2,yoff2; +} stbtt_packedchar; + +typedef struct stbtt_pack_context stbtt_pack_context; +typedef struct stbtt_fontinfo stbtt_fontinfo; +#ifndef STB_RECT_PACK_VERSION +typedef struct stbrp_rect stbrp_rect; +#endif + +STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_BYTEs, int padding, void *alloc_context); +// Initializes a packing context stored in the passed-in stbtt_pack_context. +// Future calls using this context will pack characters into the bitmap passed +// in here: a 1-channel bitmap that is width * height. stride_in_BYTEs is +// the distance from one row to the next (or 0 to mean they are packed tightly +// together). "padding" is the amount of padding to leave between each +// character (normally you want '1' for bitmaps you'll use as textures with +// bilinear filtering). +// +// Returns 0 on failure, 1 on success. + +STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc); +// Cleans up the packing context and frees all memory. + +#define STBTT_POINT_SIZE(x) (-(x)) + +STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size, + int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range); +// Creates character bitmaps from the font_index'th font found in fontdata (use +// font_index=0 if you don't know what that is). It creates num_chars_in_range +// bitmaps for characters with unicode values starting at first_unicode_char_in_range +// and increasing. Data for how to render them is stored in chardata_for_range; +// pass these to stbtt_GetPackedQuad to get back renderable quads. +// +// font_size is the full height of the character from ascender to descender, +// as computed by stbtt_ScaleForPixelHeight. To use a point size as computed +// by stbtt_ScaleForMappingEmToPixels, wrap the point size in STBTT_POINT_SIZE() +// and pass that result as 'font_size': +// ..., 20 , ... // font max minus min y is 20 pixels tall +// ..., STBTT_POINT_SIZE(20), ... // 'M' is 20 pixels tall + +typedef struct +{ + float font_size; + int first_unicode_codepoint_in_range; // if non-zero, then the chars are continuous, and this is the first codepoint + int *array_of_unicode_codepoints; // if non-zero, then this is an array of unicode codepoints + int num_chars; + stbtt_packedchar *chardata_for_range; // output + unsigned char h_oversample, v_oversample; // don't set these, they're used internally +} stbtt_pack_range; + +STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges); +// Creates character bitmaps from multiple ranges of characters stored in +// ranges. This will usually create a better-packed bitmap than multiple +// calls to stbtt_PackFontRange. Note that you can call this multiple +// times within a single PackBegin/PackEnd. + +STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample); +// Oversampling a font increases the quality by allowing higher-quality subpixel +// positioning, and is especially valuable at smaller text sizes. +// +// This function sets the amount of oversampling for all following calls to +// stbtt_PackFontRange(s) or stbtt_PackFontRangesGatherRects for a given +// pack context. The default (no oversampling) is achieved by h_oversample=1 +// and v_oversample=1. The total number of pixels required is +// h_oversample*v_oversample larger than the default; for example, 2x2 +// oversampling requires 4x the storage of 1x1. For best results, render +// oversampled textures with bilinear filtering. Look at the readme in +// stb/tests/oversample for information about oversampled fonts +// +// To use with PackFontRangesGather etc., you must set it before calls +// call to PackFontRangesGatherRects. + +STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, // same data as above + int char_index, // character to display + float *xpos, float *ypos, // pointers to current position in screen pixel space + stbtt_aligned_quad *q, // output: quad to draw + int align_to_integer); + +STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); +STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects); +STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); +// Calling these functions in sequence is roughly equivalent to calling +// stbtt_PackFontRanges(). If you more control over the packing of multiple +// fonts, or if you want to pack custom data into a font texture, take a look +// at the source to of stbtt_PackFontRanges() and create a custom version +// using these functions, e.g. call GatherRects multiple times, +// building up a single array of rects, then call PackRects once, +// then call RenderIntoRects repeatedly. This may result in a +// better packing than calling PackFontRanges multiple times +// (or it may not). + +// this is an opaque structure that you shouldn't mess with which holds +// all the context needed from PackBegin to PackEnd. +struct stbtt_pack_context { + void *user_allocator_context; + void *pack_info; + int width; + int height; + int stride_in_BYTEs; + int padding; + unsigned int h_oversample, v_oversample; + unsigned char *pixels; + void *nodes; +}; + +////////////////////////////////////////////////////////////////////////////// +// +// FONT LOADING +// +// + +STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data); +// This function will determine the number of fonts in a font file. TrueType +// collection (.ttc) files may contain multiple fonts, while TrueType font +// (.ttf) files only contain one font. The number of fonts can be used for +// indexing with the previous function where the index is between zero and one +// less than the total fonts. If an error occurs, -1 is returned. + +STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index); +// Each .ttf/.ttc file may have more than one font. Each font has a sequential +// index number starting from 0. Call this function to get the font offset for +// a given index; it returns -1 if the index is out of range. A regular .ttf +// file will only define one font and it always be at offset 0, so it will +// return '0' for index 0, and -1 for all other indices. + +// The following structure is defined publically so you can declare one on +// the stack or as a global or etc, but you should treat it as opaque. +struct stbtt_fontinfo +{ + void * userdata; + unsigned char * data; // pointer to .ttf file + int fontstart; // offset of start of font + + int numGlyphs; // number of glyphs, needed for range checking + + int loca,head,glyf,hhea,hmtx,kern; // table locations as offset from start of .ttf + int index_map; // a cmap mapping for our chosen character encoding + int indexToLocFormat; // format needed to map from glyph index to glyph + + stbtt__buf cff; // cff font data + stbtt__buf charstrings; // the charstring index + stbtt__buf gsubrs; // global charstring subroutines index + stbtt__buf subrs; // private charstring subroutines index + stbtt__buf fontdicts; // array of font dicts + stbtt__buf fdselect; // map from glyph to fontdict +}; + +STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset); +// Given an offset into the file that defines a font, this function builds +// the necessary cached info for the rest of the system. You must allocate +// the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't +// need to do anything special to free it, because the contents are pure +// value data with no additional data structures. Returns 0 on failure. + + +////////////////////////////////////////////////////////////////////////////// +// +// CHARACTER TO GLYPH-INDEX CONVERSIOn + +STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint); +// If you're going to perform multiple operations on the same character +// and you want a speed-up, call this function with the character you're +// going to process, then use glyph-based functions instead of the +// codepoint-based functions. + + +////////////////////////////////////////////////////////////////////////////// +// +// CHARACTER PROPERTIES +// + +STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels); +// computes a scale factor to produce a font whose "height" is 'pixels' tall. +// Height is measured as the distance from the highest ascender to the lowest +// descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics +// and computing: +// scale = pixels / (ascent - descent) +// so if you prefer to measure height by the ascent only, use a similar calculation. + +STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels); +// computes a scale factor to produce a font whose EM size is mapped to +// 'pixels' tall. This is probably what traditional APIs compute, but +// I'm not positive. + +STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap); +// ascent is the coordinate above the baseline the font extends; descent +// is the coordinate below the baseline the font extends (i.e. it is typically negative) +// lineGap is the spacing between one row's descent and the next row's ascent... +// so you should advance the vertical position by "*ascent - *descent + *lineGap" +// these are expressed in unscaled coordinates, so you must multiply by +// the scale factor for a given size + +STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1); +// the bounding box around all possible characters + +STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing); +// leftSideBearing is the offset from the current horizontal position to the left edge of the character +// advanceWidth is the offset from the current horizontal position to the next horizontal position +// these are expressed in unscaled coordinates + +STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2); +// an additional amount to add to the 'advance' value between ch1 and ch2 + +STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1); +// Gets the bounding box of the visible part of the glyph, in unscaled coordinates + +STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing); +STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2); +STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); +// as above, but takes one or more glyph indices for greater efficiency + + +////////////////////////////////////////////////////////////////////////////// +// +// GLYPH SHAPES (you probably don't need these, but they have to go before +// the bitmaps for C declaration-order reasons) +// + +#ifndef STBTT_vmove // you can predefine these to use different values (but why?) + enum { + STBTT_vmove=1, + STBTT_vline, + STBTT_vcurve, + STBTT_vcubic + }; +#endif + +#ifndef stbtt_vertex // you can predefine this to use different values + // (we share this with other code at RAD) + #define stbtt_vertex_type short // can't use stbtt_int16 because that's not visible in the header file + typedef struct + { + stbtt_vertex_type x,y,cx,cy,cx1,cy1; + unsigned char type,padding; + } stbtt_vertex; +#endif + +STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index); +// returns non-zero if nothing is drawn for this glyph + +STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices); +STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices); +// returns # of vertices and fills *vertices with the pointer to them +// these are expressed in "unscaled" coordinates +// +// The shape is a series of countours. Each one starts with +// a STBTT_moveto, then consists of a series of mixed +// STBTT_lineto and STBTT_curveto segments. A lineto +// draws a line from previous endpoint to its x,y; a curveto +// draws a quadratic bezier from previous endpoint to +// its x,y, using cx,cy as the bezier control point. + +STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices); +// frees the data allocated above + +////////////////////////////////////////////////////////////////////////////// +// +// BITMAP RENDERING +// + +STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata); +// frees the bitmap allocated below + +STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff); +// allocates a large-enough single-channel 8bpp bitmap and renders the +// specified character/glyph at the specified scale into it, with +// antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque). +// *width & *height are filled out with the width & height of the bitmap, +// which is stored left-to-right, top-to-bottom. +// +// xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap + +STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff); +// the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel +// shift for the character + +STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint); +// the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap +// in the form of 'output', with row spacing of 'out_stride' BYTEs. the bitmap +// is clipped to out_w/out_h BYTEs. Call stbtt_GetCodepointBitmapBox to get the +// width and height and positioning info for it first. + +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint); +// same as stbtt_MakeCodepointBitmap, but you can specify a subpixel +// shift for the character + +STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); +// get the bbox of the bitmap centered around the glyph origin; so the +// bitmap width is ix1-ix0, height is iy1-iy0, and location to place +// the bitmap top left is (leftSideBearing*scale,iy0). +// (Note that the bitmap uses y-increases-down, but the shape uses +// y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.) + +STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); +// same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel +// shift for the character + +// the following functions are equivalent to the above functions, but operate +// on glyph indices instead of Unicode codepoints (for efficiency) +STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff); +STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff); +STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph); +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph); +STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); +STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); + + +// @TODO: don't expose this structure +typedef struct +{ + int w,h,stride; + unsigned char *pixels; +} stbtt__bitmap; + +// rasterize a shape with quadratic beziers into a bitmap +STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, // 1-channel bitmap to draw into + float flatness_in_pixels, // allowable error of curve in pixels + stbtt_vertex *vertices, // array of vertices defining shape + int num_verts, // number of vertices in above array + float scale_x, float scale_y, // scale applied to input vertices + float shift_x, float shift_y, // translation applied to input vertices + int x_off, int y_off, // another translation applied to input + int invert, // if non-zero, vertically flip shape + void *userdata); // context for to STBTT_MALLOC + +////////////////////////////////////////////////////////////////////////////// +// +// Finding the right font... +// +// You should really just solve this offline, keep your own tables +// of what font is what, and don't try to get it out of the .ttf file. +// That's because getting it out of the .ttf file is really hard, because +// the names in the file can appear in many possible encodings, in many +// possible languages, and e.g. if you need a case-insensitive comparison, +// the details of that depend on the encoding & language in a complex way +// (actually underspecified in truetype, but also gigantic). +// +// But you can use the provided functions in two possible ways: +// stbtt_FindMatchingFont() will use *case-sensitive* comparisons on +// unicode-encoded names to try to find the font you want; +// you can run this before calling stbtt_InitFont() +// +// stbtt_GetFontNameString() lets you get any of the various strings +// from the file yourself and do your own comparisons on them. +// You have to have called stbtt_InitFont() first. + + +STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags); +// returns the offset (not index) of the font that matches, or -1 if none +// if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold". +// if you use any other flag, use a font name like "Arial"; this checks +// the 'macStyle' header field; i don't know if fonts set this consistently +#define STBTT_MACSTYLE_DONTCARE 0 +#define STBTT_MACSTYLE_BOLD 1 +#define STBTT_MACSTYLE_ITALIC 2 +#define STBTT_MACSTYLE_UNDERSCORE 4 +#define STBTT_MACSTYLE_NONE 8 // <= not same as 0, this makes us check the bitfield is 0 + +STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2); +// returns 1/0 whether the first string interpreted as utf8 is identical to +// the second string interpreted as big-endian utf16... useful for strings from next func + +STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID); +// returns the string (which may be big-endian double BYTE, e.g. for unicode) +// and puts the length in BYTEs in *length. +// +// some of the values for the IDs are below; for more see the truetype spec: +// http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html +// http://www.microsoft.com/typography/otspec/name.htm + +enum { // platformID + STBTT_PLATFORM_ID_UNICODE =0, + STBTT_PLATFORM_ID_MAC =1, + STBTT_PLATFORM_ID_ISO =2, + STBTT_PLATFORM_ID_MICROSOFT =3 +}; + +enum { // encodingID for STBTT_PLATFORM_ID_UNICODE + STBTT_UNICODE_EID_UNICODE_1_0 =0, + STBTT_UNICODE_EID_UNICODE_1_1 =1, + STBTT_UNICODE_EID_ISO_10646 =2, + STBTT_UNICODE_EID_UNICODE_2_0_BMP=3, + STBTT_UNICODE_EID_UNICODE_2_0_FULL=4 +}; + +enum { // encodingID for STBTT_PLATFORM_ID_MICROSOFT + STBTT_MS_EID_SYMBOL =0, + STBTT_MS_EID_UNICODE_BMP =1, + STBTT_MS_EID_SHIFTJIS =2, + STBTT_MS_EID_UNICODE_FULL =10 +}; + +enum { // encodingID for STBTT_PLATFORM_ID_MAC; same as Script Manager codes + STBTT_MAC_EID_ROMAN =0, STBTT_MAC_EID_ARABIC =4, + STBTT_MAC_EID_JAPANESE =1, STBTT_MAC_EID_HEBREW =5, + STBTT_MAC_EID_CHINESE_TRAD =2, STBTT_MAC_EID_GREEK =6, + STBTT_MAC_EID_KOREAN =3, STBTT_MAC_EID_RUSSIAN =7 +}; + +enum { // languageID for STBTT_PLATFORM_ID_MICROSOFT; same as LCID... + // problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs + STBTT_MS_LANG_ENGLISH =0x0409, STBTT_MS_LANG_ITALIAN =0x0410, + STBTT_MS_LANG_CHINESE =0x0804, STBTT_MS_LANG_JAPANESE =0x0411, + STBTT_MS_LANG_DUTCH =0x0413, STBTT_MS_LANG_KOREAN =0x0412, + STBTT_MS_LANG_FRENCH =0x040c, STBTT_MS_LANG_RUSSIAN =0x0419, + STBTT_MS_LANG_GERMAN =0x0407, STBTT_MS_LANG_SPANISH =0x0409, + STBTT_MS_LANG_HEBREW =0x040d, STBTT_MS_LANG_SWEDISH =0x041D +}; + +enum { // languageID for STBTT_PLATFORM_ID_MAC + STBTT_MAC_LANG_ENGLISH =0 , STBTT_MAC_LANG_JAPANESE =11, + STBTT_MAC_LANG_ARABIC =12, STBTT_MAC_LANG_KOREAN =23, + STBTT_MAC_LANG_DUTCH =4 , STBTT_MAC_LANG_RUSSIAN =32, + STBTT_MAC_LANG_FRENCH =1 , STBTT_MAC_LANG_SPANISH =6 , + STBTT_MAC_LANG_GERMAN =2 , STBTT_MAC_LANG_SWEDISH =5 , + STBTT_MAC_LANG_HEBREW =10, STBTT_MAC_LANG_CHINESE_SIMPLIFIED =33, + STBTT_MAC_LANG_ITALIAN =3 , STBTT_MAC_LANG_CHINESE_TRAD =19 +}; + +#ifdef __cplusplus +} +#endif + +#endif // __STB_INCLUDE_STB_TRUETYPE_H__ + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +//// +//// IMPLEMENTATION +//// +//// + +#ifdef STB_TRUETYPE_IMPLEMENTATION + +#ifndef STBTT_MAX_OVERSAMPLE +#define STBTT_MAX_OVERSAMPLE 8 +#endif + +#if STBTT_MAX_OVERSAMPLE > 255 +#error "STBTT_MAX_OVERSAMPLE cannot be > 255" +#endif + +typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERSAMPLE-1)) == 0 ? 1 : -1]; + +#ifndef STBTT_RASTERIZER_VERSION +#define STBTT_RASTERIZER_VERSION 2 +#endif + +#ifdef _MSC_VER +#define STBTT__NOTUSED(v) (void)(v) +#else +#define STBTT__NOTUSED(v) (void)sizeof(v) +#endif + +////////////////////////////////////////////////////////////////////////// +// +// stbtt__buf helpers to parse data from file +// + +static stbtt_uint8 stbtt__buf_get8(stbtt__buf *b) +{ + if (b->cursor >= b->size) + return 0; + return b->data[b->cursor++]; +} + +static stbtt_uint8 stbtt__buf_peek8(stbtt__buf *b) +{ + if (b->cursor >= b->size) + return 0; + return b->data[b->cursor]; +} + +static void stbtt__buf_seek(stbtt__buf *b, int o) +{ + STBTT_assert(!(o > b->size || o < 0)); + b->cursor = (o > b->size || o < 0) ? b->size : o; +} + +static void stbtt__buf_skip(stbtt__buf *b, int o) +{ + stbtt__buf_seek(b, b->cursor + o); +} + +static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n) +{ + stbtt_uint32 v = 0; + int i; + STBTT_assert(n >= 1 && n <= 4); + for (i = 0; i < n; i++) + v = (v << 8) | stbtt__buf_get8(b); + return v; +} + +static stbtt__buf stbtt__new_buf(const void *p, size_t size) +{ + stbtt__buf r; + STBTT_assert(size < 0x40000000); + r.data = (stbtt_uint8*) p; + r.size = (int) size; + r.cursor = 0; + return r; +} + +#define stbtt__buf_get16(b) stbtt__buf_get((b), 2) +#define stbtt__buf_get32(b) stbtt__buf_get((b), 4) + +static stbtt__buf stbtt__buf_range(const stbtt__buf *b, int o, int s) +{ + stbtt__buf r = stbtt__new_buf(NULL, 0); + if (o < 0 || s < 0 || o > b->size || s > b->size - o) return r; + r.data = b->data + o; + r.size = s; + return r; +} + +static stbtt__buf stbtt__cff_get_index(stbtt__buf *b) +{ + int count, start, offsize; + start = b->cursor; + count = stbtt__buf_get16(b); + if (count) { + offsize = stbtt__buf_get8(b); + STBTT_assert(offsize >= 1 && offsize <= 4); + stbtt__buf_skip(b, offsize * count); + stbtt__buf_skip(b, stbtt__buf_get(b, offsize) - 1); + } + return stbtt__buf_range(b, start, b->cursor - start); +} + +static stbtt_uint32 stbtt__cff_int(stbtt__buf *b) +{ + int b0 = stbtt__buf_get8(b); + if (b0 >= 32 && b0 <= 246) return b0 - 139; + else if (b0 >= 247 && b0 <= 250) return (b0 - 247)*256 + stbtt__buf_get8(b) + 108; + else if (b0 >= 251 && b0 <= 254) return -(b0 - 251)*256 - stbtt__buf_get8(b) - 108; + else if (b0 == 28) return stbtt__buf_get16(b); + else if (b0 == 29) return stbtt__buf_get32(b); + STBTT_assert(0); + return 0; +} + +static void stbtt__cff_skip_operand(stbtt__buf *b) { + int v, b0 = stbtt__buf_peek8(b); + STBTT_assert(b0 >= 28); + if (b0 == 30) { + stbtt__buf_skip(b, 1); + while (b->cursor < b->size) { + v = stbtt__buf_get8(b); + if ((v & 0xF) == 0xF || (v >> 4) == 0xF) + break; + } + } else { + stbtt__cff_int(b); + } +} + +static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key) +{ + stbtt__buf_seek(b, 0); + while (b->cursor < b->size) { + int start = b->cursor, end, op; + while (stbtt__buf_peek8(b) >= 28) + stbtt__cff_skip_operand(b); + end = b->cursor; + op = stbtt__buf_get8(b); + if (op == 12) op = stbtt__buf_get8(b) | 0x100; + if (op == key) return stbtt__buf_range(b, start, end-start); + } + return stbtt__buf_range(b, 0, 0); +} + +static void stbtt__dict_get_ints(stbtt__buf *b, int key, int outcount, stbtt_uint32 *out) +{ + int i; + stbtt__buf operands = stbtt__dict_get(b, key); + for (i = 0; i < outcount && operands.cursor < operands.size; i++) + out[i] = stbtt__cff_int(&operands); +} + +static int stbtt__cff_index_count(stbtt__buf *b) +{ + stbtt__buf_seek(b, 0); + return stbtt__buf_get16(b); +} + +static stbtt__buf stbtt__cff_index_get(stbtt__buf b, int i) +{ + int count, offsize, start, end; + stbtt__buf_seek(&b, 0); + count = stbtt__buf_get16(&b); + offsize = stbtt__buf_get8(&b); + STBTT_assert(i >= 0 && i < count); + STBTT_assert(offsize >= 1 && offsize <= 4); + stbtt__buf_skip(&b, i*offsize); + start = stbtt__buf_get(&b, offsize); + end = stbtt__buf_get(&b, offsize); + return stbtt__buf_range(&b, 2+(count+1)*offsize+start, end - start); +} + +////////////////////////////////////////////////////////////////////////// +// +// accessors to parse data from file +// + +// on platforms that don't allow misaligned reads, if we want to allow +// truetype fonts that aren't padded to alignment, define ALLOW_UNALIGNED_TRUETYPE + +#define ttBYTE(p) (* (stbtt_uint8 *) (p)) +#define ttCHAR(p) (* (stbtt_int8 *) (p)) +#define ttFixed(p) ttLONG(p) + +static stbtt_uint16 ttUSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } +static stbtt_int16 ttSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } +static stbtt_uint32 ttULONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } +static stbtt_int32 ttLONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } + +#define stbtt_tag4(p,c0,c1,c2,c3) ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3)) +#define stbtt_tag(p,str) stbtt_tag4(p,str[0],str[1],str[2],str[3]) + +static int stbtt__isfont(stbtt_uint8 *font) +{ + // check the version number + if (stbtt_tag4(font, '1',0,0,0)) return 1; // TrueType 1 + if (stbtt_tag(font, "typ1")) return 1; // TrueType with type 1 font -- we don't support this! + if (stbtt_tag(font, "OTTO")) return 1; // OpenType with CFF + if (stbtt_tag4(font, 0,1,0,0)) return 1; // OpenType 1.0 + if (stbtt_tag(font, "true")) return 1; // Apple specification for TrueType fonts + return 0; +} + +// @OPTIMIZE: binary search +static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, const char *tag) +{ + stbtt_int32 num_tables = ttUSHORT(data+fontstart+4); + stbtt_uint32 tabledir = fontstart + 12; + stbtt_int32 i; + for (i=0; i < num_tables; ++i) { + stbtt_uint32 loc = tabledir + 16*i; + if (stbtt_tag(data+loc+0, tag)) + return ttULONG(data+loc+8); + } + return 0; +} + +static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, int index) +{ + // if it's just a font, there's only one valid index + if (stbtt__isfont(font_collection)) + return index == 0 ? 0 : -1; + + // check if it's a TTC + if (stbtt_tag(font_collection, "ttcf")) { + // version 1? + if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { + stbtt_int32 n = ttLONG(font_collection+8); + if (index >= n) + return -1; + return ttULONG(font_collection+12+index*4); + } + } + return -1; +} + +static int stbtt_GetNumberOfFonts_internal(unsigned char *font_collection) +{ + // if it's just a font, there's only one valid font + if (stbtt__isfont(font_collection)) + return 1; + + // check if it's a TTC + if (stbtt_tag(font_collection, "ttcf")) { + // version 1? + if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { + return ttLONG(font_collection+8); + } + } + return 0; +} + +static stbtt__buf stbtt__get_subrs(stbtt__buf cff, stbtt__buf fontdict) +{ + stbtt_uint32 subrsoff = 0, private_loc[2] = { 0, 0 }; + stbtt__buf pdict; + stbtt__dict_get_ints(&fontdict, 18, 2, private_loc); + if (!private_loc[1] || !private_loc[0]) return stbtt__new_buf(NULL, 0); + pdict = stbtt__buf_range(&cff, private_loc[1], private_loc[0]); + stbtt__dict_get_ints(&pdict, 19, 1, &subrsoff); + if (!subrsoff) return stbtt__new_buf(NULL, 0); + stbtt__buf_seek(&cff, private_loc[1]+subrsoff); + return stbtt__cff_get_index(&cff); +} + +static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart) +{ + stbtt_uint32 cmap, t; + stbtt_int32 i,numTables; + + info->data = data; + info->fontstart = fontstart; + info->cff = stbtt__new_buf(NULL, 0); + + cmap = stbtt__find_table(data, fontstart, "cmap"); // required + info->loca = stbtt__find_table(data, fontstart, "loca"); // required + info->head = stbtt__find_table(data, fontstart, "head"); // required + info->glyf = stbtt__find_table(data, fontstart, "glyf"); // required + info->hhea = stbtt__find_table(data, fontstart, "hhea"); // required + info->hmtx = stbtt__find_table(data, fontstart, "hmtx"); // required + info->kern = stbtt__find_table(data, fontstart, "kern"); // not required + + if (!cmap || !info->head || !info->hhea || !info->hmtx) + return 0; + if (info->glyf) { + // required for truetype + if (!info->loca) return 0; + } else { + // initialization for CFF / Type2 fonts (OTF) + stbtt__buf b, topdict, topdictidx; + stbtt_uint32 cstype = 2, charstrings = 0, fdarrayoff = 0, fdselectoff = 0; + stbtt_uint32 cff; + + cff = stbtt__find_table(data, fontstart, "CFF "); + if (!cff) return 0; + + info->fontdicts = stbtt__new_buf(NULL, 0); + info->fdselect = stbtt__new_buf(NULL, 0); + + // @TODO this should use size from table (not 512MB) + info->cff = stbtt__new_buf(data+cff, 512*1024*1024); + b = info->cff; + + // read the header + stbtt__buf_skip(&b, 2); + stbtt__buf_seek(&b, stbtt__buf_get8(&b)); // hdrsize + + // @TODO the name INDEX could list multiple fonts, + // but we just use the first one. + stbtt__cff_get_index(&b); // name INDEX + topdictidx = stbtt__cff_get_index(&b); + topdict = stbtt__cff_index_get(topdictidx, 0); + stbtt__cff_get_index(&b); // string INDEX + info->gsubrs = stbtt__cff_get_index(&b); + + stbtt__dict_get_ints(&topdict, 17, 1, &charstrings); + stbtt__dict_get_ints(&topdict, 0x100 | 6, 1, &cstype); + stbtt__dict_get_ints(&topdict, 0x100 | 36, 1, &fdarrayoff); + stbtt__dict_get_ints(&topdict, 0x100 | 37, 1, &fdselectoff); + info->subrs = stbtt__get_subrs(b, topdict); + + // we only support Type 2 charstrings + if (cstype != 2) return 0; + if (charstrings == 0) return 0; + + if (fdarrayoff) { + // looks like a CID font + if (!fdselectoff) return 0; + stbtt__buf_seek(&b, fdarrayoff); + info->fontdicts = stbtt__cff_get_index(&b); + info->fdselect = stbtt__buf_range(&b, fdselectoff, b.size-fdselectoff); + } + + stbtt__buf_seek(&b, charstrings); + info->charstrings = stbtt__cff_get_index(&b); + } + + t = stbtt__find_table(data, fontstart, "maxp"); + if (t) + info->numGlyphs = ttUSHORT(data+t+4); + else + info->numGlyphs = 0xffff; + + // find a cmap encoding table we understand *now* to avoid searching + // later. (todo: could make this installable) + // the same regardless of glyph. + numTables = ttUSHORT(data + cmap + 2); + info->index_map = 0; + for (i=0; i < numTables; ++i) { + stbtt_uint32 encoding_record = cmap + 4 + 8 * i; + // find an encoding we understand: + switch(ttUSHORT(data+encoding_record)) { + case STBTT_PLATFORM_ID_MICROSOFT: + switch (ttUSHORT(data+encoding_record+2)) { + case STBTT_MS_EID_UNICODE_BMP: + case STBTT_MS_EID_UNICODE_FULL: + // MS/Unicode + info->index_map = cmap + ttULONG(data+encoding_record+4); + break; + } + break; + case STBTT_PLATFORM_ID_UNICODE: + // Mac/iOS has these + // all the encodingIDs are unicode, so we don't bother to check it + info->index_map = cmap + ttULONG(data+encoding_record+4); + break; + } + } + if (info->index_map == 0) + return 0; + + info->indexToLocFormat = ttUSHORT(data+info->head + 50); + return 1; +} + +STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint) +{ + stbtt_uint8 *data = info->data; + stbtt_uint32 index_map = info->index_map; + + stbtt_uint16 format = ttUSHORT(data + index_map + 0); + if (format == 0) { // apple BYTE encoding + stbtt_int32 BYTEs = ttUSHORT(data + index_map + 2); + if (unicode_codepoint < BYTEs-6) + return ttBYTE(data + index_map + 6 + unicode_codepoint); + return 0; + } else if (format == 6) { + stbtt_uint32 first = ttUSHORT(data + index_map + 6); + stbtt_uint32 count = ttUSHORT(data + index_map + 8); + if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count) + return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2); + return 0; + } else if (format == 2) { + STBTT_assert(0); // @TODO: high-BYTE mapping for japanese/chinese/korean + return 0; + } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges + stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1; + stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1; + stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10); + stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1; + + // do a binary search of the segments + stbtt_uint32 endCount = index_map + 14; + stbtt_uint32 search = endCount; + + if (unicode_codepoint > 0xffff) + return 0; + + // they lie from endCount .. endCount + segCount + // but searchRange is the nearest power of two, so... + if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2)) + search += rangeShift*2; + + // now decrement to bias correctly to find smallest + search -= 2; + while (entrySelector) { + stbtt_uint16 end; + searchRange >>= 1; + end = ttUSHORT(data + search + searchRange*2); + if (unicode_codepoint > end) + search += searchRange*2; + --entrySelector; + } + search += 2; + + { + stbtt_uint16 offset, start; + stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1); + + STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2*item)); + start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item); + if (unicode_codepoint < start) + return 0; + + offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item); + if (offset == 0) + return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item)); + + return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item); + } + } else if (format == 12 || format == 13) { + stbtt_uint32 ngroups = ttULONG(data+index_map+12); + stbtt_int32 low,high; + low = 0; high = (stbtt_int32)ngroups; + // Binary search the right group. + while (low < high) { + stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high + stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12); + stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4); + if ((stbtt_uint32) unicode_codepoint < start_char) + high = mid; + else if ((stbtt_uint32) unicode_codepoint > end_char) + low = mid+1; + else { + stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8); + if (format == 12) + return start_glyph + unicode_codepoint-start_char; + else // format == 13 + return start_glyph; + } + } + return 0; // not found + } + // @TODO + STBTT_assert(0); + return 0; +} + +STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices) +{ + return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices); +} + +static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy) +{ + v->type = type; + v->x = (stbtt_int16) x; + v->y = (stbtt_int16) y; + v->cx = (stbtt_int16) cx; + v->cy = (stbtt_int16) cy; +} + +static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) +{ + int g1,g2; + + STBTT_assert(!info->cff.size); + + if (glyph_index >= info->numGlyphs) return -1; // glyph index out of range + if (info->indexToLocFormat >= 2) return -1; // unknown index->glyph map format + + if (info->indexToLocFormat == 0) { + g1 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2) * 2; + g2 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2; + } else { + g1 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4); + g2 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4 + 4); + } + + return g1==g2 ? -1 : g1; // if length is 0, return -1 +} + +static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); + +STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) +{ + if (info->cff.size) { + stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1); + } else { + int g = stbtt__GetGlyfOffset(info, glyph_index); + if (g < 0) return 0; + + if (x0) *x0 = ttSHORT(info->data + g + 2); + if (y0) *y0 = ttSHORT(info->data + g + 4); + if (x1) *x1 = ttSHORT(info->data + g + 6); + if (y1) *y1 = ttSHORT(info->data + g + 8); + } + return 1; +} + +STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1) +{ + return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1); +} + +STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index) +{ + stbtt_int16 numberOfContours; + int g; + if (info->cff.size) + return stbtt__GetGlyphInfoT2(info, glyph_index, NULL, NULL, NULL, NULL) == 0; + g = stbtt__GetGlyfOffset(info, glyph_index); + if (g < 0) return 1; + numberOfContours = ttSHORT(info->data + g); + return numberOfContours == 0; +} + +static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_off, int start_off, + stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy) +{ + if (start_off) { + if (was_off) + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy); + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, sx,sy,scx,scy); + } else { + if (was_off) + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve,sx,sy,cx,cy); + else + stbtt_setvertex(&vertices[num_vertices++], STBTT_vline,sx,sy,0,0); + } + return num_vertices; +} + +static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +{ + stbtt_int16 numberOfContours; + stbtt_uint8 *endPtsOfContours; + stbtt_uint8 *data = info->data; + stbtt_vertex *vertices=0; + int num_vertices=0; + int g = stbtt__GetGlyfOffset(info, glyph_index); + + *pvertices = NULL; + + if (g < 0) return 0; + + numberOfContours = ttSHORT(data + g); + + if (numberOfContours > 0) { + stbtt_uint8 flags=0,flagcount; + stbtt_int32 ins, i,j=0,m,n, next_move, was_off=0, off, start_off=0; + stbtt_int32 x,y,cx,cy,sx,sy, scx,scy; + stbtt_uint8 *points; + endPtsOfContours = (data + g + 10); + ins = ttUSHORT(data + g + 10 + numberOfContours * 2); + points = data + g + 10 + numberOfContours * 2 + 2 + ins; + + n = 1+ttUSHORT(endPtsOfContours + numberOfContours*2-2); + + m = n + 2*numberOfContours; // a loose bound on how many vertices we might need + vertices = (stbtt_vertex *) STBTT_malloc(m * sizeof(vertices[0]), info->userdata); + if (vertices == 0) + return 0; + + next_move = 0; + flagcount=0; + + // in first pass, we load uninterpreted data into the allocated array + // above, shifted to the end of the array so we won't overwrite it when + // we create our final data starting from the front + + off = m - n; // starting offset for uninterpreted data, regardless of how m ends up being calculated + + // first load flags + + for (i=0; i < n; ++i) { + if (flagcount == 0) { + flags = *points++; + if (flags & 8) + flagcount = *points++; + } else + --flagcount; + vertices[off+i].type = flags; + } + + // now load x coordinates + x=0; + for (i=0; i < n; ++i) { + flags = vertices[off+i].type; + if (flags & 2) { + stbtt_int16 dx = *points++; + x += (flags & 16) ? dx : -dx; // ??? + } else { + if (!(flags & 16)) { + x = x + (stbtt_int16) (points[0]*256 + points[1]); + points += 2; + } + } + vertices[off+i].x = (stbtt_int16) x; + } + + // now load y coordinates + y=0; + for (i=0; i < n; ++i) { + flags = vertices[off+i].type; + if (flags & 4) { + stbtt_int16 dy = *points++; + y += (flags & 32) ? dy : -dy; // ??? + } else { + if (!(flags & 32)) { + y = y + (stbtt_int16) (points[0]*256 + points[1]); + points += 2; + } + } + vertices[off+i].y = (stbtt_int16) y; + } + + // now convert them to our format + num_vertices=0; + sx = sy = cx = cy = scx = scy = 0; + for (i=0; i < n; ++i) { + flags = vertices[off+i].type; + x = (stbtt_int16) vertices[off+i].x; + y = (stbtt_int16) vertices[off+i].y; + + if (next_move == i) { + if (i != 0) + num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); + + // now start the new one + start_off = !(flags & 1); + if (start_off) { + // if we start off with an off-curve point, then when we need to find a point on the curve + // where we can start, and we need to save some state for when we wraparound. + scx = x; + scy = y; + if (!(vertices[off+i+1].type & 1)) { + // next point is also a curve point, so interpolate an on-point curve + sx = (x + (stbtt_int32) vertices[off+i+1].x) >> 1; + sy = (y + (stbtt_int32) vertices[off+i+1].y) >> 1; + } else { + // otherwise just use the next point as our start point + sx = (stbtt_int32) vertices[off+i+1].x; + sy = (stbtt_int32) vertices[off+i+1].y; + ++i; // we're using point i+1 as the starting point, so skip it + } + } else { + sx = x; + sy = y; + } + stbtt_setvertex(&vertices[num_vertices++], STBTT_vmove,sx,sy,0,0); + was_off = 0; + next_move = 1 + ttUSHORT(endPtsOfContours+j*2); + ++j; + } else { + if (!(flags & 1)) { // if it's a curve + if (was_off) // two off-curve control points in a row means interpolate an on-curve midpoint + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy); + cx = x; + cy = y; + was_off = 1; + } else { + if (was_off) + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, x,y, cx, cy); + else + stbtt_setvertex(&vertices[num_vertices++], STBTT_vline, x,y,0,0); + was_off = 0; + } + } + } + num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); + } else if (numberOfContours == -1) { + // Compound shapes. + int more = 1; + stbtt_uint8 *comp = data + g + 10; + num_vertices = 0; + vertices = 0; + while (more) { + stbtt_uint16 flags, gidx; + int comp_num_verts = 0, i; + stbtt_vertex *comp_verts = 0, *tmp = 0; + float mtx[6] = {1,0,0,1,0,0}, m, n; + + flags = ttSHORT(comp); comp+=2; + gidx = ttSHORT(comp); comp+=2; + + if (flags & 2) { // XY values + if (flags & 1) { // shorts + mtx[4] = ttSHORT(comp); comp+=2; + mtx[5] = ttSHORT(comp); comp+=2; + } else { + mtx[4] = ttCHAR(comp); comp+=1; + mtx[5] = ttCHAR(comp); comp+=1; + } + } + else { + // @TODO handle matching point + STBTT_assert(0); + } + if (flags & (1<<3)) { // WE_HAVE_A_SCALE + mtx[0] = mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[1] = mtx[2] = 0; + } else if (flags & (1<<6)) { // WE_HAVE_AN_X_AND_YSCALE + mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[1] = mtx[2] = 0; + mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; + } else if (flags & (1<<7)) { // WE_HAVE_A_TWO_BY_TWO + mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[1] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[2] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; + } + + // Find transformation scales. + m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]); + n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]); + + // Get indexed glyph. + comp_num_verts = stbtt_GetGlyphShape(info, gidx, &comp_verts); + if (comp_num_verts > 0) { + // Transform vertices. + for (i = 0; i < comp_num_verts; ++i) { + stbtt_vertex* v = &comp_verts[i]; + stbtt_vertex_type x,y; + x=v->x; y=v->y; + v->x = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); + v->y = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); + x=v->cx; y=v->cy; + v->cx = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); + v->cy = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); + } + // Append vertices. + tmp = (stbtt_vertex*)STBTT_malloc((num_vertices+comp_num_verts)*sizeof(stbtt_vertex), info->userdata); + if (!tmp) { + if (vertices) STBTT_free(vertices, info->userdata); + if (comp_verts) STBTT_free(comp_verts, info->userdata); + return 0; + } + if (num_vertices > 0) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex)); + STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex)); + if (vertices) STBTT_free(vertices, info->userdata); + vertices = tmp; + STBTT_free(comp_verts, info->userdata); + num_vertices += comp_num_verts; + } + // More components ? + more = flags & (1<<5); + } + } else if (numberOfContours < 0) { + // @TODO other compound variations? + STBTT_assert(0); + } else { + // numberOfCounters == 0, do nothing + } + + *pvertices = vertices; + return num_vertices; +} + +typedef struct +{ + int bounds; + int started; + float first_x, first_y; + float x, y; + stbtt_int32 min_x, max_x, min_y, max_y; + + stbtt_vertex *pvertices; + int num_vertices; +} stbtt__csctx; + +#define STBTT__CSCTX_INIT(bounds) {bounds,0, 0,0, 0,0, 0,0,0,0, NULL, 0} + +static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y) +{ + if (x > c->max_x || !c->started) c->max_x = x; + if (y > c->max_y || !c->started) c->max_y = y; + if (x < c->min_x || !c->started) c->min_x = x; + if (y < c->min_y || !c->started) c->min_y = y; + c->started = 1; +} + +static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy, stbtt_int32 cx1, stbtt_int32 cy1) +{ + if (c->bounds) { + stbtt__track_vertex(c, x, y); + if (type == STBTT_vcubic) { + stbtt__track_vertex(c, cx, cy); + stbtt__track_vertex(c, cx1, cy1); + } + } else { + stbtt_setvertex(&c->pvertices[c->num_vertices], type, x, y, cx, cy); + c->pvertices[c->num_vertices].cx1 = (stbtt_int16) cx1; + c->pvertices[c->num_vertices].cy1 = (stbtt_int16) cy1; + } + c->num_vertices++; +} + +static void stbtt__csctx_close_shape(stbtt__csctx *ctx) +{ + if (ctx->first_x != ctx->x || ctx->first_y != ctx->y) + stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0); +} + +static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy) +{ + stbtt__csctx_close_shape(ctx); + ctx->first_x = ctx->x = ctx->x + dx; + ctx->first_y = ctx->y = ctx->y + dy; + stbtt__csctx_v(ctx, STBTT_vmove, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); +} + +static void stbtt__csctx_rline_to(stbtt__csctx *ctx, float dx, float dy) +{ + ctx->x += dx; + ctx->y += dy; + stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); +} + +static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3) +{ + float cx1 = ctx->x + dx1; + float cy1 = ctx->y + dy1; + float cx2 = cx1 + dx2; + float cy2 = cy1 + dy2; + ctx->x = cx2 + dx3; + ctx->y = cy2 + dy3; + stbtt__csctx_v(ctx, STBTT_vcubic, (int)ctx->x, (int)ctx->y, (int)cx1, (int)cy1, (int)cx2, (int)cy2); +} + +static stbtt__buf stbtt__get_subr(stbtt__buf idx, int n) +{ + int count = stbtt__cff_index_count(&idx); + int bias = 107; + if (count >= 33900) + bias = 32768; + else if (count >= 1240) + bias = 1131; + n += bias; + if (n < 0 || n >= count) + return stbtt__new_buf(NULL, 0); + return stbtt__cff_index_get(idx, n); +} + +static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int glyph_index) +{ + stbtt__buf fdselect = info->fdselect; + int nranges, start, end, v, fmt, fdselector = -1, i; + + stbtt__buf_seek(&fdselect, 0); + fmt = stbtt__buf_get8(&fdselect); + if (fmt == 0) { + // untested + stbtt__buf_skip(&fdselect, glyph_index); + fdselector = stbtt__buf_get8(&fdselect); + } else if (fmt == 3) { + nranges = stbtt__buf_get16(&fdselect); + start = stbtt__buf_get16(&fdselect); + for (i = 0; i < nranges; i++) { + v = stbtt__buf_get8(&fdselect); + end = stbtt__buf_get16(&fdselect); + if (glyph_index >= start && glyph_index < end) { + fdselector = v; + break; + } + start = end; + } + } + if (fdselector == -1) stbtt__new_buf(NULL, 0); + return stbtt__get_subrs(info->cff, stbtt__cff_index_get(info->fontdicts, fdselector)); +} + +static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, stbtt__csctx *c) +{ + int in_header = 1, maskbits = 0, subr_stack_height = 0, sp = 0, v, i, b0; + int has_subrs = 0, clear_stack; + float s[48]; + stbtt__buf subr_stack[10], subrs = info->subrs, b; + float f; + +#define STBTT__CSERR(s) (0) + + // this currently ignores the initial width value, which isn't needed if we have hmtx + b = stbtt__cff_index_get(info->charstrings, glyph_index); + while (b.cursor < b.size) { + i = 0; + clear_stack = 1; + b0 = stbtt__buf_get8(&b); + switch (b0) { + // @TODO implement hinting + case 0x13: // hintmask + case 0x14: // cntrmask + if (in_header) + maskbits += (sp / 2); // implicit "vstem" + in_header = 0; + stbtt__buf_skip(&b, (maskbits + 7) / 8); + break; + + case 0x01: // hstem + case 0x03: // vstem + case 0x12: // hstemhm + case 0x17: // vstemhm + maskbits += (sp / 2); + break; + + case 0x15: // rmoveto + in_header = 0; + if (sp < 2) return STBTT__CSERR("rmoveto stack"); + stbtt__csctx_rmove_to(c, s[sp-2], s[sp-1]); + break; + case 0x04: // vmoveto + in_header = 0; + if (sp < 1) return STBTT__CSERR("vmoveto stack"); + stbtt__csctx_rmove_to(c, 0, s[sp-1]); + break; + case 0x16: // hmoveto + in_header = 0; + if (sp < 1) return STBTT__CSERR("hmoveto stack"); + stbtt__csctx_rmove_to(c, s[sp-1], 0); + break; + + case 0x05: // rlineto + if (sp < 2) return STBTT__CSERR("rlineto stack"); + for (; i + 1 < sp; i += 2) + stbtt__csctx_rline_to(c, s[i], s[i+1]); + break; + + // hlineto/vlineto and vhcurveto/hvcurveto alternate horizontal and vertical + // starting from a different place. + + case 0x07: // vlineto + if (sp < 1) return STBTT__CSERR("vlineto stack"); + goto vlineto; + case 0x06: // hlineto + if (sp < 1) return STBTT__CSERR("hlineto stack"); + for (;;) { + if (i >= sp) break; + stbtt__csctx_rline_to(c, s[i], 0); + i++; + vlineto: + if (i >= sp) break; + stbtt__csctx_rline_to(c, 0, s[i]); + i++; + } + break; + + case 0x1F: // hvcurveto + if (sp < 4) return STBTT__CSERR("hvcurveto stack"); + goto hvcurveto; + case 0x1E: // vhcurveto + if (sp < 4) return STBTT__CSERR("vhcurveto stack"); + for (;;) { + if (i + 3 >= sp) break; + stbtt__csctx_rccurve_to(c, 0, s[i], s[i+1], s[i+2], s[i+3], (sp - i == 5) ? s[i + 4] : 0.0f); + i += 4; + hvcurveto: + if (i + 3 >= sp) break; + stbtt__csctx_rccurve_to(c, s[i], 0, s[i+1], s[i+2], (sp - i == 5) ? s[i+4] : 0.0f, s[i+3]); + i += 4; + } + break; + + case 0x08: // rrcurveto + if (sp < 6) return STBTT__CSERR("rcurveline stack"); + for (; i + 5 < sp; i += 6) + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + break; + + case 0x18: // rcurveline + if (sp < 8) return STBTT__CSERR("rcurveline stack"); + for (; i + 5 < sp - 2; i += 6) + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + if (i + 1 >= sp) return STBTT__CSERR("rcurveline stack"); + stbtt__csctx_rline_to(c, s[i], s[i+1]); + break; + + case 0x19: // rlinecurve + if (sp < 8) return STBTT__CSERR("rlinecurve stack"); + for (; i + 1 < sp - 6; i += 2) + stbtt__csctx_rline_to(c, s[i], s[i+1]); + if (i + 5 >= sp) return STBTT__CSERR("rlinecurve stack"); + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + break; + + case 0x1A: // vvcurveto + case 0x1B: // hhcurveto + if (sp < 4) return STBTT__CSERR("(vv|hh)curveto stack"); + f = 0.0; + if (sp & 1) { f = s[i]; i++; } + for (; i + 3 < sp; i += 4) { + if (b0 == 0x1B) + stbtt__csctx_rccurve_to(c, s[i], f, s[i+1], s[i+2], s[i+3], 0.0); + else + stbtt__csctx_rccurve_to(c, f, s[i], s[i+1], s[i+2], 0.0, s[i+3]); + f = 0.0; + } + break; + + case 0x0A: // callsubr + if (!has_subrs) { + if (info->fdselect.size) + subrs = stbtt__cid_get_glyph_subrs(info, glyph_index); + has_subrs = 1; + } + // fallthrough + case 0x1D: // callgsubr + if (sp < 1) return STBTT__CSERR("call(g|)subr stack"); + v = (int) s[--sp]; + if (subr_stack_height >= 10) return STBTT__CSERR("recursion limit"); + subr_stack[subr_stack_height++] = b; + b = stbtt__get_subr(b0 == 0x0A ? subrs : info->gsubrs, v); + if (b.size == 0) return STBTT__CSERR("subr not found"); + b.cursor = 0; + clear_stack = 0; + break; + + case 0x0B: // return + if (subr_stack_height <= 0) return STBTT__CSERR("return outside subr"); + b = subr_stack[--subr_stack_height]; + clear_stack = 0; + break; + + case 0x0E: // endchar + stbtt__csctx_close_shape(c); + return 1; + + case 0x0C: { // two-BYTE escape + float dx1, dx2, dx3, dx4, dx5, dx6, dy1, dy2, dy3, dy4, dy5, dy6; + float dx, dy; + int b1 = stbtt__buf_get8(&b); + switch (b1) { + // @TODO These "flex" implementations ignore the flex-depth and resolution, + // and always draw beziers. + case 0x22: // hflex + if (sp < 7) return STBTT__CSERR("hflex stack"); + dx1 = s[0]; + dx2 = s[1]; + dy2 = s[2]; + dx3 = s[3]; + dx4 = s[4]; + dx5 = s[5]; + dx6 = s[6]; + stbtt__csctx_rccurve_to(c, dx1, 0, dx2, dy2, dx3, 0); + stbtt__csctx_rccurve_to(c, dx4, 0, dx5, -dy2, dx6, 0); + break; + + case 0x23: // flex + if (sp < 13) return STBTT__CSERR("flex stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dy3 = s[5]; + dx4 = s[6]; + dy4 = s[7]; + dx5 = s[8]; + dy5 = s[9]; + dx6 = s[10]; + dy6 = s[11]; + //fd is s[12] + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); + stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); + break; + + case 0x24: // hflex1 + if (sp < 9) return STBTT__CSERR("hflex1 stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dx4 = s[5]; + dx5 = s[6]; + dy5 = s[7]; + dx6 = s[8]; + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, 0); + stbtt__csctx_rccurve_to(c, dx4, 0, dx5, dy5, dx6, -(dy1+dy2+dy5)); + break; + + case 0x25: // flex1 + if (sp < 11) return STBTT__CSERR("flex1 stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dy3 = s[5]; + dx4 = s[6]; + dy4 = s[7]; + dx5 = s[8]; + dy5 = s[9]; + dx6 = dy6 = s[10]; + dx = dx1+dx2+dx3+dx4+dx5; + dy = dy1+dy2+dy3+dy4+dy5; + if (STBTT_fabs(dx) > STBTT_fabs(dy)) + dy6 = -dy; + else + dx6 = -dx; + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); + stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); + break; + + default: + return STBTT__CSERR("unimplemented"); + } + } break; + + default: + if (b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254)) + return STBTT__CSERR("reserved operator"); + + // push immediate + if (b0 == 255) { + f = (float)stbtt__buf_get32(&b) / 0x10000; + } else { + stbtt__buf_skip(&b, -1); + f = (float)(stbtt_int16)stbtt__cff_int(&b); + } + if (sp >= 48) return STBTT__CSERR("push stack overflow"); + s[sp++] = f; + clear_stack = 0; + break; + } + if (clear_stack) sp = 0; + } + return STBTT__CSERR("no endchar"); + +#undef STBTT__CSERR +} + +static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +{ + // runs the charstring twice, once to count and once to output (to avoid realloc) + stbtt__csctx count_ctx = STBTT__CSCTX_INIT(1); + stbtt__csctx output_ctx = STBTT__CSCTX_INIT(0); + if (stbtt__run_charstring(info, glyph_index, &count_ctx)) { + *pvertices = (stbtt_vertex*)STBTT_malloc(count_ctx.num_vertices*sizeof(stbtt_vertex), info->userdata); + output_ctx.pvertices = *pvertices; + if (stbtt__run_charstring(info, glyph_index, &output_ctx)) { + STBTT_assert(output_ctx.num_vertices == count_ctx.num_vertices); + return output_ctx.num_vertices; + } + } + *pvertices = NULL; + return 0; +} + +static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) +{ + stbtt__csctx c = STBTT__CSCTX_INIT(1); + int r = stbtt__run_charstring(info, glyph_index, &c); + if (x0) { + *x0 = r ? c.min_x : 0; + *y0 = r ? c.min_y : 0; + *x1 = r ? c.max_x : 0; + *y1 = r ? c.max_y : 0; + } + return r ? c.num_vertices : 0; +} + +STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +{ + if (!info->cff.size) + return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices); + else + return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices); +} + +STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing) +{ + stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34); + if (glyph_index < numOfLongHorMetrics) { + if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*glyph_index); + if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*glyph_index + 2); + } else { + if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1)); + if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics)); + } +} + +STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) +{ + stbtt_uint8 *data = info->data + info->kern; + stbtt_uint32 needle, straw; + int l, r, m; + + // we only look at the first table. it must be 'horizontal' and format 0. + if (!info->kern) + return 0; + if (ttUSHORT(data+2) < 1) // number of tables, need at least 1 + return 0; + if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format + return 0; + + l = 0; + r = ttUSHORT(data+10) - 1; + needle = glyph1 << 16 | glyph2; + while (l <= r) { + m = (l + r) >> 1; + straw = ttULONG(data+18+(m*6)); // note: unaligned read + if (needle < straw) + r = m - 1; + else if (needle > straw) + l = m + 1; + else + return ttSHORT(data+22+(m*6)); + } + return 0; +} + +STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2) +{ + if (!info->kern) // if no kerning table, don't waste time looking up both codepoint->glyphs + return 0; + return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2)); +} + +STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing) +{ + stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing); +} + +STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap) +{ + if (ascent ) *ascent = ttSHORT(info->data+info->hhea + 4); + if (descent) *descent = ttSHORT(info->data+info->hhea + 6); + if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8); +} + +STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1) +{ + *x0 = ttSHORT(info->data + info->head + 36); + *y0 = ttSHORT(info->data + info->head + 38); + *x1 = ttSHORT(info->data + info->head + 40); + *y1 = ttSHORT(info->data + info->head + 42); +} + +STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height) +{ + int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6); + return (float) height / fheight; +} + +STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels) +{ + int unitsPerEm = ttUSHORT(info->data + info->head + 18); + return pixels / unitsPerEm; +} + +STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v) +{ + STBTT_free(v, info->userdata); +} + +////////////////////////////////////////////////////////////////////////////// +// +// antialiasing software rasterizer +// + +STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + int x0=0,y0=0,x1,y1; // =0 suppresses compiler warning + if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) { + // e.g. space character + if (ix0) *ix0 = 0; + if (iy0) *iy0 = 0; + if (ix1) *ix1 = 0; + if (iy1) *iy1 = 0; + } else { + // move to integral bboxes (treating pixels as little squares, what pixels get touched)? + if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x); + if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y); + if (ix1) *ix1 = STBTT_iceil ( x1 * scale_x + shift_x); + if (iy1) *iy1 = STBTT_iceil (-y0 * scale_y + shift_y); + } +} + +STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1); +} + +STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1); +} + +STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1); +} + +////////////////////////////////////////////////////////////////////////////// +// +// Rasterizer + +typedef struct stbtt__hheap_chunk +{ + struct stbtt__hheap_chunk *next; +} stbtt__hheap_chunk; + +typedef struct stbtt__hheap +{ + struct stbtt__hheap_chunk *head; + void *first_free; + int num_remaining_in_head_chunk; +} stbtt__hheap; + +static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata) +{ + if (hh->first_free) { + void *p = hh->first_free; + hh->first_free = * (void **) p; + return p; + } else { + if (hh->num_remaining_in_head_chunk == 0) { + int count = (size < 32 ? 2000 : size < 128 ? 800 : 100); + stbtt__hheap_chunk *c = (stbtt__hheap_chunk *) STBTT_malloc(sizeof(stbtt__hheap_chunk) + size * count, userdata); + if (c == NULL) + return NULL; + c->next = hh->head; + hh->head = c; + hh->num_remaining_in_head_chunk = count; + } + --hh->num_remaining_in_head_chunk; + return (char *) (hh->head) + size * hh->num_remaining_in_head_chunk; + } +} + +static void stbtt__hheap_free(stbtt__hheap *hh, void *p) +{ + *(void **) p = hh->first_free; + hh->first_free = p; +} + +static void stbtt__hheap_cleanup(stbtt__hheap *hh, void *userdata) +{ + stbtt__hheap_chunk *c = hh->head; + while (c) { + stbtt__hheap_chunk *n = c->next; + STBTT_free(c, userdata); + c = n; + } +} + +typedef struct stbtt__edge { + float x0,y0, x1,y1; + int invert; +} stbtt__edge; + + +typedef struct stbtt__active_edge +{ + struct stbtt__active_edge *next; + #if STBTT_RASTERIZER_VERSION==1 + int x,dx; + float ey; + int direction; + #elif STBTT_RASTERIZER_VERSION==2 + float fx,fdx,fdy; + float direction; + float sy; + float ey; + #else + #error "Unrecognized value of STBTT_RASTERIZER_VERSION" + #endif +} stbtt__active_edge; + +#if STBTT_RASTERIZER_VERSION == 1 +#define STBTT_FIXSHIFT 10 +#define STBTT_FIX (1 << STBTT_FIXSHIFT) +#define STBTT_FIXMASK (STBTT_FIX-1) + +static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) +{ + stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); + float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); + STBTT_assert(z != NULL); + if (!z) return z; + + // round dx down to avoid overshooting + if (dxdy < 0) + z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy); + else + z->dx = STBTT_ifloor(STBTT_FIX * dxdy); + + z->x = STBTT_ifloor(STBTT_FIX * e->x0 + z->dx * (start_point - e->y0)); // use z->dx so when we offset later it's by the same amount + z->x -= off_x * STBTT_FIX; + + z->ey = e->y1; + z->next = 0; + z->direction = e->invert ? 1 : -1; + return z; +} +#elif STBTT_RASTERIZER_VERSION == 2 +static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) +{ + stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); + float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); + STBTT_assert(z != NULL); + //STBTT_assert(e->y0 <= start_point); + if (!z) return z; + z->fdx = dxdy; + z->fdy = dxdy != 0.0f ? (1.0f/dxdy) : 0.0f; + z->fx = e->x0 + dxdy * (start_point - e->y0); + z->fx -= off_x; + z->direction = e->invert ? 1.0f : -1.0f; + z->sy = e->y0; + z->ey = e->y1; + z->next = 0; + return z; +} +#else +#error "Unrecognized value of STBTT_RASTERIZER_VERSION" +#endif + +#if STBTT_RASTERIZER_VERSION == 1 +// note: this routine clips fills that extend off the edges... ideally this +// wouldn't happen, but it could happen if the truetype glyph bounding boxes +// are wrong, or if the user supplies a too-small bitmap +static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__active_edge *e, int max_weight) +{ + // non-zero winding fill + int x0=0, w=0; + + while (e) { + if (w == 0) { + // if we're currently at zero, we need to record the edge start point + x0 = e->x; w += e->direction; + } else { + int x1 = e->x; w += e->direction; + // if we went to zero, we need to draw + if (w == 0) { + int i = x0 >> STBTT_FIXSHIFT; + int j = x1 >> STBTT_FIXSHIFT; + + if (i < len && j >= 0) { + if (i == j) { + // x0,x1 are the same pixel, so compute combined coverage + scanline[i] = scanline[i] + (stbtt_uint8) ((x1 - x0) * max_weight >> STBTT_FIXSHIFT); + } else { + if (i >= 0) // add antialiasing for x0 + scanline[i] = scanline[i] + (stbtt_uint8) (((STBTT_FIX - (x0 & STBTT_FIXMASK)) * max_weight) >> STBTT_FIXSHIFT); + else + i = -1; // clip + + if (j < len) // add antialiasing for x1 + scanline[j] = scanline[j] + (stbtt_uint8) (((x1 & STBTT_FIXMASK) * max_weight) >> STBTT_FIXSHIFT); + else + j = len; // clip + + for (++i; i < j; ++i) // fill pixels between x0 and x1 + scanline[i] = scanline[i] + (stbtt_uint8) max_weight; + } + } + } + } + + e = e->next; + } +} + +static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) +{ + stbtt__hheap hh = { 0, 0, 0 }; + stbtt__active_edge *active = NULL; + int y,j=0; + int max_weight = (255 / vsubsample); // weight per vertical scanline + int s; // vertical subsample index + unsigned char scanline_data[512], *scanline; + + if (result->w > 512) + scanline = (unsigned char *) STBTT_malloc(result->w, userdata); + else + scanline = scanline_data; + + y = off_y * vsubsample; + e[n].y0 = (off_y + result->h) * (float) vsubsample + 1; + + while (j < result->h) { + STBTT_memset(scanline, 0, result->w); + for (s=0; s < vsubsample; ++s) { + // find center of pixel for this scanline + float scan_y = y + 0.5f; + stbtt__active_edge **step = &active; + + // update all active edges; + // remove all active edges that terminate before the center of this scanline + while (*step) { + stbtt__active_edge * z = *step; + if (z->ey <= scan_y) { + *step = z->next; // delete from list + STBTT_assert(z->direction); + z->direction = 0; + stbtt__hheap_free(&hh, z); + } else { + z->x += z->dx; // advance to position for current scanline + step = &((*step)->next); // advance through list + } + } + + // resort the list if needed + for(;;) { + int changed=0; + step = &active; + while (*step && (*step)->next) { + if ((*step)->x > (*step)->next->x) { + stbtt__active_edge *t = *step; + stbtt__active_edge *q = t->next; + + t->next = q->next; + q->next = t; + *step = q; + changed = 1; + } + step = &(*step)->next; + } + if (!changed) break; + } + + // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline + while (e->y0 <= scan_y) { + if (e->y1 > scan_y) { + stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y, userdata); + if (z != NULL) { + // find insertion point + if (active == NULL) + active = z; + else if (z->x < active->x) { + // insert at front + z->next = active; + active = z; + } else { + // find thing to insert AFTER + stbtt__active_edge *p = active; + while (p->next && p->next->x < z->x) + p = p->next; + // at this point, p->next->x is NOT < z->x + z->next = p->next; + p->next = z; + } + } + } + ++e; + } + + // now process all active edges in XOR fashion + if (active) + stbtt__fill_active_edges(scanline, result->w, active, max_weight); + + ++y; + } + STBTT_memcpy(result->pixels + j * result->stride, scanline, result->w); + ++j; + } + + stbtt__hheap_cleanup(&hh, userdata); + + if (scanline != scanline_data) + STBTT_free(scanline, userdata); +} + +#elif STBTT_RASTERIZER_VERSION == 2 + +// the edge passed in here does not cross the vertical line at x or the vertical line at x+1 +// (i.e. it has already been clipped to those) +static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edge *e, float x0, float y0, float x1, float y1) +{ + if (y0 == y1) return; + STBTT_assert(y0 < y1); + STBTT_assert(e->sy <= e->ey); + if (y0 > e->ey) return; + if (y1 < e->sy) return; + if (y0 < e->sy) { + x0 += (x1-x0) * (e->sy - y0) / (y1-y0); + y0 = e->sy; + } + if (y1 > e->ey) { + x1 += (x1-x0) * (e->ey - y1) / (y1-y0); + y1 = e->ey; + } + + if (x0 == x) + STBTT_assert(x1 <= x+1); + else if (x0 == x+1) + STBTT_assert(x1 >= x); + else if (x0 <= x) + STBTT_assert(x1 <= x); + else if (x0 >= x+1) + STBTT_assert(x1 >= x+1); + else + STBTT_assert(x1 >= x && x1 <= x+1); + + if (x0 <= x && x1 <= x) + scanline[x] += e->direction * (y1-y0); + else if (x0 >= x+1 && x1 >= x+1) + ; + else { + STBTT_assert(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1); + scanline[x] += e->direction * (y1-y0) * (1-((x0-x)+(x1-x))/2); // coverage = 1 - average x position + } +} + +static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, int len, stbtt__active_edge *e, float y_top) +{ + float y_bottom = y_top+1; + + while (e) { + // brute force every pixel + + // compute intersection points with top & bottom + STBTT_assert(e->ey >= y_top); + + if (e->fdx == 0) { + float x0 = e->fx; + if (x0 < len) { + if (x0 >= 0) { + stbtt__handle_clipped_edge(scanline,(int) x0,e, x0,y_top, x0,y_bottom); + stbtt__handle_clipped_edge(scanline_fill-1,(int) x0+1,e, x0,y_top, x0,y_bottom); + } else { + stbtt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom); + } + } + } else { + float x0 = e->fx; + float dx = e->fdx; + float xb = x0 + dx; + float x_top, x_bottom; + float sy0,sy1; + float dy = e->fdy; + STBTT_assert(e->sy <= y_bottom && e->ey >= y_top); + + // compute endpoints of line segment clipped to this scanline (if the + // line segment starts on this scanline. x0 is the intersection of the + // line with y_top, but that may be off the line segment. + if (e->sy > y_top) { + x_top = x0 + dx * (e->sy - y_top); + sy0 = e->sy; + } else { + x_top = x0; + sy0 = y_top; + } + if (e->ey < y_bottom) { + x_bottom = x0 + dx * (e->ey - y_top); + sy1 = e->ey; + } else { + x_bottom = xb; + sy1 = y_bottom; + } + + if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len) { + // from here on, we don't have to range check x values + + if ((int) x_top == (int) x_bottom) { + float height; + // simple case, only spans one pixel + int x = (int) x_top; + height = sy1 - sy0; + STBTT_assert(x >= 0 && x < len); + scanline[x] += e->direction * (1-((x_top - x) + (x_bottom-x))/2) * height; + scanline_fill[x] += e->direction * height; // everything right of this pixel is filled + } else { + int x,x1,x2; + float y_crossing, step, sign, area; + // covers 2+ pixels + if (x_top > x_bottom) { + // flip scanline vertically; signed area is the same + float t; + sy0 = y_bottom - (sy0 - y_top); + sy1 = y_bottom - (sy1 - y_top); + t = sy0, sy0 = sy1, sy1 = t; + t = x_bottom, x_bottom = x_top, x_top = t; + dx = -dx; + dy = -dy; + t = x0, x0 = xb, xb = t; + } + + x1 = (int) x_top; + x2 = (int) x_bottom; + // compute intersection with y axis at x1+1 + y_crossing = (x1+1 - x0) * dy + y_top; + + sign = e->direction; + // area of the rectangle covered from y0..y_crossing + area = sign * (y_crossing-sy0); + // area of the triangle (x_top,y0), (x+1,y0), (x+1,y_crossing) + scanline[x1] += area * (1-((x_top - x1)+(x1+1-x1))/2); + + step = sign * dy; + for (x = x1+1; x < x2; ++x) { + scanline[x] += area + step/2; + area += step; + } + y_crossing += dy * (x2 - (x1+1)); + + STBTT_assert(STBTT_fabs(area) <= 1.01f); + + scanline[x2] += area + sign * (1-((x2-x2)+(x_bottom-x2))/2) * (sy1-y_crossing); + + scanline_fill[x2] += sign * (sy1-sy0); + } + } else { + // if edge goes outside of box we're drawing, we require + // clipping logic. since this does not match the intended use + // of this library, we use a different, very slow brute + // force implementation + int x; + for (x=0; x < len; ++x) { + // cases: + // + // there can be up to two intersections with the pixel. any intersection + // with left or right edges can be handled by splitting into two (or three) + // regions. intersections with top & bottom do not necessitate case-wise logic. + // + // the old way of doing this found the intersections with the left & right edges, + // then used some simple logic to produce up to three segments in sorted order + // from top-to-bottom. however, this had a problem: if an x edge was epsilon + // across the x border, then the corresponding y position might not be distinct + // from the other y segment, and it might ignored as an empty segment. to avoid + // that, we need to explicitly produce segments based on x positions. + + // rename variables to clear pairs + float y0 = y_top; + float x1 = (float) (x); + float x2 = (float) (x+1); + float x3 = xb; + float y3 = y_bottom; + float y1,y2; + + // x = e->x + e->dx * (y-y_top) + // (y-y_top) = (x - e->x) / e->dx + // y = (x - e->x) / e->dx + y_top + y1 = (x - x0) / dx + y_top; + y2 = (x+1 - x0) / dx + y_top; + + if (x0 < x1 && x3 > x2) { // three segments descending down-right + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); + } else if (x3 < x1 && x0 > x2) { // three segments descending down-left + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); + } else if (x0 < x1 && x3 > x1) { // two segments across x, down-right + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); + } else if (x3 < x1 && x0 > x1) { // two segments across x, down-left + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); + } else if (x0 < x2 && x3 > x2) { // two segments across x+1, down-right + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); + } else if (x3 < x2 && x0 > x2) { // two segments across x+1, down-left + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); + } else { // one segment + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x3,y3); + } + } + } + } + e = e->next; + } +} + +// directly AA rasterize edges w/o supersampling +static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) +{ + stbtt__hheap hh = { 0, 0, 0 }; + stbtt__active_edge *active = NULL; + int y,j=0, i; + float scanline_data[129], *scanline, *scanline2; + + STBTT__NOTUSED(vsubsample); + + if (result->w > 64) + scanline = (float *) STBTT_malloc((result->w*2+1) * sizeof(float), userdata); + else + scanline = scanline_data; + + scanline2 = scanline + result->w; + + y = off_y; + e[n].y0 = (float) (off_y + result->h) + 1; + + while (j < result->h) { + // find center of pixel for this scanline + float scan_y_top = y + 0.0f; + float scan_y_bottom = y + 1.0f; + stbtt__active_edge **step = &active; + + STBTT_memset(scanline , 0, result->w*sizeof(scanline[0])); + STBTT_memset(scanline2, 0, (result->w+1)*sizeof(scanline[0])); + + // update all active edges; + // remove all active edges that terminate before the top of this scanline + while (*step) { + stbtt__active_edge * z = *step; + if (z->ey <= scan_y_top) { + *step = z->next; // delete from list + STBTT_assert(z->direction); + z->direction = 0; + stbtt__hheap_free(&hh, z); + } else { + step = &((*step)->next); // advance through list + } + } + + // insert all edges that start before the bottom of this scanline + while (e->y0 <= scan_y_bottom) { + if (e->y0 != e->y1) { + stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata); + if (z != NULL) { + STBTT_assert(z->ey >= scan_y_top); + // insert at front + z->next = active; + active = z; + } + } + ++e; + } + + // now process all active edges + if (active) + stbtt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top); + + { + float sum = 0; + for (i=0; i < result->w; ++i) { + float k; + int m; + sum += scanline2[i]; + k = scanline[i] + sum; + k = (float) STBTT_fabs(k)*255 + 0.5f; + m = (int) k; + if (m > 255) m = 255; + result->pixels[j*result->stride + i] = (unsigned char) m; + } + } + // advance all the edges + step = &active; + while (*step) { + stbtt__active_edge *z = *step; + z->fx += z->fdx; // advance to position for current scanline + step = &((*step)->next); // advance through list + } + + ++y; + ++j; + } + + stbtt__hheap_cleanup(&hh, userdata); + + if (scanline != scanline_data) + STBTT_free(scanline, userdata); +} +#else +#error "Unrecognized value of STBTT_RASTERIZER_VERSION" +#endif + +#define STBTT__COMPARE(a,b) ((a)->y0 < (b)->y0) + +static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n) +{ + int i,j; + for (i=1; i < n; ++i) { + stbtt__edge t = p[i], *a = &t; + j = i; + while (j > 0) { + stbtt__edge *b = &p[j-1]; + int c = STBTT__COMPARE(a,b); + if (!c) break; + p[j] = p[j-1]; + --j; + } + if (i != j) + p[j] = t; + } +} + +static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n) +{ + /* threshhold for transitioning to insertion sort */ + while (n > 12) { + stbtt__edge t; + int c01,c12,c,m,i,j; + + /* compute median of three */ + m = n >> 1; + c01 = STBTT__COMPARE(&p[0],&p[m]); + c12 = STBTT__COMPARE(&p[m],&p[n-1]); + /* if 0 >= mid >= end, or 0 < mid < end, then use mid */ + if (c01 != c12) { + /* otherwise, we'll need to swap something else to middle */ + int z; + c = STBTT__COMPARE(&p[0],&p[n-1]); + /* 0>mid && midn => n; 0 0 */ + /* 0n: 0>n => 0; 0 n */ + z = (c == c12) ? 0 : n-1; + t = p[z]; + p[z] = p[m]; + p[m] = t; + } + /* now p[m] is the median-of-three */ + /* swap it to the beginning so it won't move around */ + t = p[0]; + p[0] = p[m]; + p[m] = t; + + /* partition loop */ + i=1; + j=n-1; + for(;;) { + /* handling of equality is crucial here */ + /* for sentinels & efficiency with duplicates */ + for (;;++i) { + if (!STBTT__COMPARE(&p[i], &p[0])) break; + } + for (;;--j) { + if (!STBTT__COMPARE(&p[0], &p[j])) break; + } + /* make sure we haven't crossed */ + if (i >= j) break; + t = p[i]; + p[i] = p[j]; + p[j] = t; + + ++i; + --j; + } + /* recurse on smaller side, iterate on larger */ + if (j < (n-i)) { + stbtt__sort_edges_quicksort(p,j); + p = p+i; + n = n-i; + } else { + stbtt__sort_edges_quicksort(p+i, n-i); + n = j; + } + } +} + +static void stbtt__sort_edges(stbtt__edge *p, int n) +{ + stbtt__sort_edges_quicksort(p, n); + stbtt__sort_edges_ins_sort(p, n); +} + +typedef struct +{ + float x,y; +} stbtt__point; + +static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, int windings, float scale_x, float scale_y, float shift_x, float shift_y, int off_x, int off_y, int invert, void *userdata) +{ + float y_scale_inv = invert ? -scale_y : scale_y; + stbtt__edge *e; + int n,i,j,k,m; +#if STBTT_RASTERIZER_VERSION == 1 + int vsubsample = result->h < 8 ? 15 : 5; +#elif STBTT_RASTERIZER_VERSION == 2 + int vsubsample = 1; +#else + #error "Unrecognized value of STBTT_RASTERIZER_VERSION" +#endif + // vsubsample should divide 255 evenly; otherwise we won't reach full opacity + + // now we have to blow out the windings into explicit edge lists + n = 0; + for (i=0; i < windings; ++i) + n += wcount[i]; + + e = (stbtt__edge *) STBTT_malloc(sizeof(*e) * (n+1), userdata); // add an extra one as a sentinel + if (e == 0) return; + n = 0; + + m=0; + for (i=0; i < windings; ++i) { + stbtt__point *p = pts + m; + m += wcount[i]; + j = wcount[i]-1; + for (k=0; k < wcount[i]; j=k++) { + int a=k,b=j; + // skip the edge if horizontal + if (p[j].y == p[k].y) + continue; + // add edge from j to k to the list + e[n].invert = 0; + if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) { + e[n].invert = 1; + a=j,b=k; + } + e[n].x0 = p[a].x * scale_x + shift_x; + e[n].y0 = (p[a].y * y_scale_inv + shift_y) * vsubsample; + e[n].x1 = p[b].x * scale_x + shift_x; + e[n].y1 = (p[b].y * y_scale_inv + shift_y) * vsubsample; + ++n; + } + } + + // now sort the edges by their highest point (should snap to integer, and then by x) + //STBTT_sort(e, n, sizeof(e[0]), stbtt__edge_compare); + stbtt__sort_edges(e, n); + + // now, traverse the scanlines and find the intersections on each scanline, use xor winding rule + stbtt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, userdata); + + STBTT_free(e, userdata); +} + +static void stbtt__add_point(stbtt__point *points, int n, float x, float y) +{ + if (!points) return; // during first pass, it's unallocated + points[n].x = x; + points[n].y = y; +} + +// tesselate until threshhold p is happy... @TODO warped to compensate for non-linear stretching +static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n) +{ + // midpoint + float mx = (x0 + 2*x1 + x2)/4; + float my = (y0 + 2*y1 + y2)/4; + // versus directly drawn line + float dx = (x0+x2)/2 - mx; + float dy = (y0+y2)/2 - my; + if (n > 16) // 65536 segments on one curve better be enough! + return 1; + if (dx*dx+dy*dy > objspace_flatness_squared) { // half-pixel error allowed... need to be smaller if AA + stbtt__tesselate_curve(points, num_points, x0,y0, (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1); + stbtt__tesselate_curve(points, num_points, mx,my, (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1); + } else { + stbtt__add_point(points, *num_points,x2,y2); + *num_points = *num_points+1; + } + return 1; +} + +static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float objspace_flatness_squared, int n) +{ + // @TODO this "flatness" calculation is just made-up nonsense that seems to work well enough + float dx0 = x1-x0; + float dy0 = y1-y0; + float dx1 = x2-x1; + float dy1 = y2-y1; + float dx2 = x3-x2; + float dy2 = y3-y2; + float dx = x3-x0; + float dy = y3-y0; + float longlen = (float) (STBTT_sqrt(dx0*dx0+dy0*dy0)+STBTT_sqrt(dx1*dx1+dy1*dy1)+STBTT_sqrt(dx2*dx2+dy2*dy2)); + float shortlen = (float) STBTT_sqrt(dx*dx+dy*dy); + float flatness_squared = longlen*longlen-shortlen*shortlen; + + if (n > 16) // 65536 segments on one curve better be enough! + return; + + if (flatness_squared > objspace_flatness_squared) { + float x01 = (x0+x1)/2; + float y01 = (y0+y1)/2; + float x12 = (x1+x2)/2; + float y12 = (y1+y2)/2; + float x23 = (x2+x3)/2; + float y23 = (y2+y3)/2; + + float xa = (x01+x12)/2; + float ya = (y01+y12)/2; + float xb = (x12+x23)/2; + float yb = (y12+y23)/2; + + float mx = (xa+xb)/2; + float my = (ya+yb)/2; + + stbtt__tesselate_cubic(points, num_points, x0,y0, x01,y01, xa,ya, mx,my, objspace_flatness_squared,n+1); + stbtt__tesselate_cubic(points, num_points, mx,my, xb,yb, x23,y23, x3,y3, objspace_flatness_squared,n+1); + } else { + stbtt__add_point(points, *num_points,x3,y3); + *num_points = *num_points+1; + } +} + +// returns number of contours +static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata) +{ + stbtt__point *points=0; + int num_points=0; + + float objspace_flatness_squared = objspace_flatness * objspace_flatness; + int i,n=0,start=0, pass; + + // count how many "moves" there are to get the contour count + for (i=0; i < num_verts; ++i) + if (vertices[i].type == STBTT_vmove) + ++n; + + *num_contours = n; + if (n == 0) return 0; + + *contour_lengths = (int *) STBTT_malloc(sizeof(**contour_lengths) * n, userdata); + + if (*contour_lengths == 0) { + *num_contours = 0; + return 0; + } + + // make two passes through the points so we don't need to realloc + for (pass=0; pass < 2; ++pass) { + float x=0,y=0; + if (pass == 1) { + points = (stbtt__point *) STBTT_malloc(num_points * sizeof(points[0]), userdata); + if (points == NULL) goto error; + } + num_points = 0; + n= -1; + for (i=0; i < num_verts; ++i) { + switch (vertices[i].type) { + case STBTT_vmove: + // start the next contour + if (n >= 0) + (*contour_lengths)[n] = num_points - start; + ++n; + start = num_points; + + x = vertices[i].x, y = vertices[i].y; + stbtt__add_point(points, num_points++, x,y); + break; + case STBTT_vline: + x = vertices[i].x, y = vertices[i].y; + stbtt__add_point(points, num_points++, x, y); + break; + case STBTT_vcurve: + stbtt__tesselate_curve(points, &num_points, x,y, + vertices[i].cx, vertices[i].cy, + vertices[i].x, vertices[i].y, + objspace_flatness_squared, 0); + x = vertices[i].x, y = vertices[i].y; + break; + case STBTT_vcubic: + stbtt__tesselate_cubic(points, &num_points, x,y, + vertices[i].cx, vertices[i].cy, + vertices[i].cx1, vertices[i].cy1, + vertices[i].x, vertices[i].y, + objspace_flatness_squared, 0); + x = vertices[i].x, y = vertices[i].y; + break; + } + } + (*contour_lengths)[n] = num_points - start; + } + + return points; +error: + STBTT_free(points, userdata); + STBTT_free(*contour_lengths, userdata); + *contour_lengths = 0; + *num_contours = 0; + return NULL; +} + +STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata) +{ + float scale = scale_x > scale_y ? scale_y : scale_x; + int winding_count, *winding_lengths; + stbtt__point *windings = stbtt_FlattenCurves(vertices, num_verts, flatness_in_pixels / scale, &winding_lengths, &winding_count, userdata); + if (windings) { + stbtt__rasterize(result, windings, winding_lengths, winding_count, scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, userdata); + STBTT_free(winding_lengths, userdata); + STBTT_free(windings, userdata); + } +} + +STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata) +{ + STBTT_free(bitmap, userdata); +} + +STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff) +{ + int ix0,iy0,ix1,iy1; + stbtt__bitmap gbm; + stbtt_vertex *vertices; + int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); + + if (scale_x == 0) scale_x = scale_y; + if (scale_y == 0) { + if (scale_x == 0) { + STBTT_free(vertices, info->userdata); + return NULL; + } + scale_y = scale_x; + } + + stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,&ix1,&iy1); + + // now we get the size + gbm.w = (ix1 - ix0); + gbm.h = (iy1 - iy0); + gbm.pixels = NULL; // in case we error + + if (width ) *width = gbm.w; + if (height) *height = gbm.h; + if (xoff ) *xoff = ix0; + if (yoff ) *yoff = iy0; + + if (gbm.w && gbm.h) { + gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata); + if (gbm.pixels) { + gbm.stride = gbm.w; + + stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0, iy0, 1, info->userdata); + } + } + STBTT_free(vertices, info->userdata); + return gbm.pixels; +} + +STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff); +} + +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph) +{ + int ix0,iy0; + stbtt_vertex *vertices; + int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); + stbtt__bitmap gbm; + + stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0); + gbm.pixels = output; + gbm.w = out_w; + gbm.h = out_h; + gbm.stride = out_stride; + + if (gbm.w && gbm.h) + stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0,iy0, 1, info->userdata); + + STBTT_free(vertices, info->userdata); +} + +STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph) +{ + stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph); +} + +STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff); +} + +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint) +{ + stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint)); +} + +STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff); +} + +STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint) +{ + stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint); +} + +////////////////////////////////////////////////////////////////////////////// +// +// bitmap baking +// +// This is SUPER-CRAPPY packing to keep source code small + +static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) + float pixel_height, // height of font in pixels + unsigned char *pixels, int pw, int ph, // bitmap to be filled in + int first_char, int num_chars, // characters to bake + stbtt_bakedchar *chardata) +{ + float scale; + int x,y,bottom_y, i; + stbtt_fontinfo f; + f.userdata = NULL; + if (!stbtt_InitFont(&f, data, offset)) + return -1; + STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels + x=y=1; + bottom_y = 1; + + scale = stbtt_ScaleForPixelHeight(&f, pixel_height); + + for (i=0; i < num_chars; ++i) { + int advance, lsb, x0,y0,x1,y1,gw,gh; + int g = stbtt_FindGlyphIndex(&f, first_char + i); + stbtt_GetGlyphHMetrics(&f, g, &advance, &lsb); + stbtt_GetGlyphBitmapBox(&f, g, scale,scale, &x0,&y0,&x1,&y1); + gw = x1-x0; + gh = y1-y0; + if (x + gw + 1 >= pw) + y = bottom_y, x = 1; // advance to next row + if (y + gh + 1 >= ph) // check if it fits vertically AFTER potentially moving to next row + return -i; + STBTT_assert(x+gw < pw); + STBTT_assert(y+gh < ph); + stbtt_MakeGlyphBitmap(&f, pixels+x+y*pw, gw,gh,pw, scale,scale, g); + chardata[i].x0 = (stbtt_int16) x; + chardata[i].y0 = (stbtt_int16) y; + chardata[i].x1 = (stbtt_int16) (x + gw); + chardata[i].y1 = (stbtt_int16) (y + gh); + chardata[i].xadvance = scale * advance; + chardata[i].xoff = (float) x0; + chardata[i].yoff = (float) y0; + x = x + gw + 1; + if (y+gh+1 > bottom_y) + bottom_y = y+gh+1; + } + return bottom_y; +} + +STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) +{ + float d3d_bias = opengl_fillrule ? 0 : -0.5f; + float ipw = 1.0f / pw, iph = 1.0f / ph; + stbtt_bakedchar *b = chardata + char_index; + int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f); + int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f); + + q->x0 = round_x + d3d_bias; + q->y0 = round_y + d3d_bias; + q->x1 = round_x + b->x1 - b->x0 + d3d_bias; + q->y1 = round_y + b->y1 - b->y0 + d3d_bias; + + q->s0 = b->x0 * ipw; + q->t0 = b->y0 * iph; + q->s1 = b->x1 * ipw; + q->t1 = b->y1 * iph; + + *xpos += b->xadvance; +} + +////////////////////////////////////////////////////////////////////////////// +// +// rectangle packing replacement routines if you don't have stb_rect_pack.h +// + +#ifndef STB_RECT_PACK_VERSION + +typedef int stbrp_coord; + +//////////////////////////////////////////////////////////////////////////////////// +// // +// // +// COMPILER WARNING ?!?!? // +// // +// // +// if you get a compile warning due to these symbols being defined more than // +// once, move #include "stb_rect_pack.h" before #include "stb_truetype.h" // +// // +//////////////////////////////////////////////////////////////////////////////////// + +typedef struct +{ + int width,height; + int x,y,bottom_y; +} stbrp_context; + +typedef struct +{ + unsigned char x; +} stbrp_node; + +struct stbrp_rect +{ + stbrp_coord x,y; + int id,w,h,was_packed; +}; + +static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes) +{ + con->width = pw; + con->height = ph; + con->x = 0; + con->y = 0; + con->bottom_y = 0; + STBTT__NOTUSED(nodes); + STBTT__NOTUSED(num_nodes); +} + +static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects) +{ + int i; + for (i=0; i < num_rects; ++i) { + if (con->x + rects[i].w > con->width) { + con->x = 0; + con->y = con->bottom_y; + } + if (con->y + rects[i].h > con->height) + break; + rects[i].x = con->x; + rects[i].y = con->y; + rects[i].was_packed = 1; + con->x += rects[i].w; + if (con->y + rects[i].h > con->bottom_y) + con->bottom_y = con->y + rects[i].h; + } + for ( ; i < num_rects; ++i) + rects[i].was_packed = 0; +} +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// bitmap baking +// +// This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If +// stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy. + +STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_BYTEs, int padding, void *alloc_context) +{ + stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context) ,alloc_context); + int num_nodes = pw - padding; + stbrp_node *nodes = (stbrp_node *) STBTT_malloc(sizeof(*nodes ) * num_nodes,alloc_context); + + if (context == NULL || nodes == NULL) { + if (context != NULL) STBTT_free(context, alloc_context); + if (nodes != NULL) STBTT_free(nodes , alloc_context); + return 0; + } + + spc->user_allocator_context = alloc_context; + spc->width = pw; + spc->height = ph; + spc->pixels = pixels; + spc->pack_info = context; + spc->nodes = nodes; + spc->padding = padding; + spc->stride_in_BYTEs = stride_in_BYTEs != 0 ? stride_in_BYTEs : pw; + spc->h_oversample = 1; + spc->v_oversample = 1; + + stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes); + + if (pixels) + STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels + + return 1; +} + +STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc) +{ + STBTT_free(spc->nodes , spc->user_allocator_context); + STBTT_free(spc->pack_info, spc->user_allocator_context); +} + +STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample) +{ + STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE); + STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE); + if (h_oversample <= STBTT_MAX_OVERSAMPLE) + spc->h_oversample = h_oversample; + if (v_oversample <= STBTT_MAX_OVERSAMPLE) + spc->v_oversample = v_oversample; +} + +#define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1) + +static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_BYTEs, unsigned int kernel_width) +{ + unsigned char buffer[STBTT_MAX_OVERSAMPLE]; + int safe_w = w - kernel_width; + int j; + STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze + for (j=0; j < h; ++j) { + int i; + unsigned int total; + STBTT_memset(buffer, 0, kernel_width); + + total = 0; + + // make kernel_width a constant in common cases so compiler can optimize out the divide + switch (kernel_width) { + case 2: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 2); + } + break; + case 3: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 3); + } + break; + case 4: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 4); + } + break; + case 5: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 5); + } + break; + default: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / kernel_width); + } + break; + } + + for (; i < w; ++i) { + STBTT_assert(pixels[i] == 0); + total -= buffer[i & STBTT__OVER_MASK]; + pixels[i] = (unsigned char) (total / kernel_width); + } + + pixels += stride_in_BYTEs; + } +} + +static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_BYTEs, unsigned int kernel_width) +{ + unsigned char buffer[STBTT_MAX_OVERSAMPLE]; + int safe_h = h - kernel_width; + int j; + STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze + for (j=0; j < w; ++j) { + int i; + unsigned int total; + STBTT_memset(buffer, 0, kernel_width); + + total = 0; + + // make kernel_width a constant in common cases so compiler can optimize out the divide + switch (kernel_width) { + case 2: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_BYTEs] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_BYTEs]; + pixels[i*stride_in_BYTEs] = (unsigned char) (total / 2); + } + break; + case 3: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_BYTEs] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_BYTEs]; + pixels[i*stride_in_BYTEs] = (unsigned char) (total / 3); + } + break; + case 4: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_BYTEs] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_BYTEs]; + pixels[i*stride_in_BYTEs] = (unsigned char) (total / 4); + } + break; + case 5: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_BYTEs] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_BYTEs]; + pixels[i*stride_in_BYTEs] = (unsigned char) (total / 5); + } + break; + default: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_BYTEs] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_BYTEs]; + pixels[i*stride_in_BYTEs] = (unsigned char) (total / kernel_width); + } + break; + } + + for (; i < h; ++i) { + STBTT_assert(pixels[i*stride_in_BYTEs] == 0); + total -= buffer[i & STBTT__OVER_MASK]; + pixels[i*stride_in_BYTEs] = (unsigned char) (total / kernel_width); + } + + pixels += 1; + } +} + +static float stbtt__oversample_shift(int oversample) +{ + if (!oversample) + return 0.0f; + + // The prefilter is a box filter of width "oversample", + // which shifts phase by (oversample - 1)/2 pixels in + // oversampled space. We want to shift in the opposite + // direction to counter this. + return (float)-(oversample - 1) / (2.0f * (float)oversample); +} + +// rects array must be big enough to accommodate all characters in the given ranges +STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) +{ + int i,j,k; + + k=0; + for (i=0; i < num_ranges; ++i) { + float fh = ranges[i].font_size; + float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); + ranges[i].h_oversample = (unsigned char) spc->h_oversample; + ranges[i].v_oversample = (unsigned char) spc->v_oversample; + for (j=0; j < ranges[i].num_chars; ++j) { + int x0,y0,x1,y1; + int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; + int glyph = stbtt_FindGlyphIndex(info, codepoint); + stbtt_GetGlyphBitmapBoxSubpixel(info,glyph, + scale * spc->h_oversample, + scale * spc->v_oversample, + 0,0, + &x0,&y0,&x1,&y1); + rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1); + rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1); + ++k; + } + } + + return k; +} + +// rects array must be big enough to accommodate all characters in the given ranges +STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) +{ + int i,j,k, return_value = 1; + + // save current values + int old_h_over = spc->h_oversample; + int old_v_over = spc->v_oversample; + + k = 0; + for (i=0; i < num_ranges; ++i) { + float fh = ranges[i].font_size; + float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); + float recip_h,recip_v,sub_x,sub_y; + spc->h_oversample = ranges[i].h_oversample; + spc->v_oversample = ranges[i].v_oversample; + recip_h = 1.0f / spc->h_oversample; + recip_v = 1.0f / spc->v_oversample; + sub_x = stbtt__oversample_shift(spc->h_oversample); + sub_y = stbtt__oversample_shift(spc->v_oversample); + for (j=0; j < ranges[i].num_chars; ++j) { + stbrp_rect *r = &rects[k]; + if (r->was_packed) { + stbtt_packedchar *bc = &ranges[i].chardata_for_range[j]; + int advance, lsb, x0,y0,x1,y1; + int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; + int glyph = stbtt_FindGlyphIndex(info, codepoint); + stbrp_coord pad = (stbrp_coord) spc->padding; + + // pad on left and top + r->x += pad; + r->y += pad; + r->w -= pad; + r->h -= pad; + stbtt_GetGlyphHMetrics(info, glyph, &advance, &lsb); + stbtt_GetGlyphBitmapBox(info, glyph, + scale * spc->h_oversample, + scale * spc->v_oversample, + &x0,&y0,&x1,&y1); + stbtt_MakeGlyphBitmapSubpixel(info, + spc->pixels + r->x + r->y*spc->stride_in_BYTEs, + r->w - spc->h_oversample+1, + r->h - spc->v_oversample+1, + spc->stride_in_BYTEs, + scale * spc->h_oversample, + scale * spc->v_oversample, + 0,0, + glyph); + + if (spc->h_oversample > 1) + stbtt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_BYTEs, + r->w, r->h, spc->stride_in_BYTEs, + spc->h_oversample); + + if (spc->v_oversample > 1) + stbtt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_BYTEs, + r->w, r->h, spc->stride_in_BYTEs, + spc->v_oversample); + + bc->x0 = (stbtt_int16) r->x; + bc->y0 = (stbtt_int16) r->y; + bc->x1 = (stbtt_int16) (r->x + r->w); + bc->y1 = (stbtt_int16) (r->y + r->h); + bc->xadvance = scale * advance; + bc->xoff = (float) x0 * recip_h + sub_x; + bc->yoff = (float) y0 * recip_v + sub_y; + bc->xoff2 = (x0 + r->w) * recip_h + sub_x; + bc->yoff2 = (y0 + r->h) * recip_v + sub_y; + } else { + return_value = 0; // if any fail, report failure + } + + ++k; + } + } + + // restore original values + spc->h_oversample = old_h_over; + spc->v_oversample = old_v_over; + + return return_value; +} + +STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects) +{ + stbrp_pack_rects((stbrp_context *) spc->pack_info, rects, num_rects); +} + +STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges) +{ + stbtt_fontinfo info; + int i,j,n, return_value = 1; + //stbrp_context *context = (stbrp_context *) spc->pack_info; + stbrp_rect *rects; + + // flag all characters as NOT packed + for (i=0; i < num_ranges; ++i) + for (j=0; j < ranges[i].num_chars; ++j) + ranges[i].chardata_for_range[j].x0 = + ranges[i].chardata_for_range[j].y0 = + ranges[i].chardata_for_range[j].x1 = + ranges[i].chardata_for_range[j].y1 = 0; + + n = 0; + for (i=0; i < num_ranges; ++i) + n += ranges[i].num_chars; + + rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context); + if (rects == NULL) + return 0; + + info.userdata = spc->user_allocator_context; + stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata,font_index)); + + n = stbtt_PackFontRangesGatherRects(spc, &info, ranges, num_ranges, rects); + + stbtt_PackFontRangesPackRects(spc, rects, n); + + return_value = stbtt_PackFontRangesRenderIntoRects(spc, &info, ranges, num_ranges, rects); + + STBTT_free(rects, spc->user_allocator_context); + return return_value; +} + +STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size, + int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range) +{ + stbtt_pack_range range; + range.first_unicode_codepoint_in_range = first_unicode_codepoint_in_range; + range.array_of_unicode_codepoints = NULL; + range.num_chars = num_chars_in_range; + range.chardata_for_range = chardata_for_range; + range.font_size = font_size; + return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1); +} + +STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer) +{ + float ipw = 1.0f / pw, iph = 1.0f / ph; + stbtt_packedchar *b = chardata + char_index; + + if (align_to_integer) { + float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f); + float y = (float) STBTT_ifloor((*ypos + b->yoff) + 0.5f); + q->x0 = x; + q->y0 = y; + q->x1 = x + b->xoff2 - b->xoff; + q->y1 = y + b->yoff2 - b->yoff; + } else { + q->x0 = *xpos + b->xoff; + q->y0 = *ypos + b->yoff; + q->x1 = *xpos + b->xoff2; + q->y1 = *ypos + b->yoff2; + } + + q->s0 = b->x0 * ipw; + q->t0 = b->y0 * iph; + q->s1 = b->x1 * ipw; + q->t1 = b->y1 * iph; + + *xpos += b->xadvance; +} + + +////////////////////////////////////////////////////////////////////////////// +// +// font name matching -- recommended not to use this +// + +// check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string +static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2) +{ + stbtt_int32 i=0; + + // convert utf16 to utf8 and compare the results while converting + while (len2) { + stbtt_uint16 ch = s2[0]*256 + s2[1]; + if (ch < 0x80) { + if (i >= len1) return -1; + if (s1[i++] != ch) return -1; + } else if (ch < 0x800) { + if (i+1 >= len1) return -1; + if (s1[i++] != 0xc0 + (ch >> 6)) return -1; + if (s1[i++] != 0x80 + (ch & 0x3f)) return -1; + } else if (ch >= 0xd800 && ch < 0xdc00) { + stbtt_uint32 c; + stbtt_uint16 ch2 = s2[2]*256 + s2[3]; + if (i+3 >= len1) return -1; + c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000; + if (s1[i++] != 0xf0 + (c >> 18)) return -1; + if (s1[i++] != 0x80 + ((c >> 12) & 0x3f)) return -1; + if (s1[i++] != 0x80 + ((c >> 6) & 0x3f)) return -1; + if (s1[i++] != 0x80 + ((c ) & 0x3f)) return -1; + s2 += 2; // plus another 2 below + len2 -= 2; + } else if (ch >= 0xdc00 && ch < 0xe000) { + return -1; + } else { + if (i+2 >= len1) return -1; + if (s1[i++] != 0xe0 + (ch >> 12)) return -1; + if (s1[i++] != 0x80 + ((ch >> 6) & 0x3f)) return -1; + if (s1[i++] != 0x80 + ((ch ) & 0x3f)) return -1; + } + s2 += 2; + len2 -= 2; + } + return i; +} + +static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2) +{ + return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2); +} + +// returns results in whatever encoding you request... but note that 2-BYTE encodings +// will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare +STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID) +{ + stbtt_int32 i,count,stringOffset; + stbtt_uint8 *fc = font->data; + stbtt_uint32 offset = font->fontstart; + stbtt_uint32 nm = stbtt__find_table(fc, offset, "name"); + if (!nm) return NULL; + + count = ttUSHORT(fc+nm+2); + stringOffset = nm + ttUSHORT(fc+nm+4); + for (i=0; i < count; ++i) { + stbtt_uint32 loc = nm + 6 + 12 * i; + if (platformID == ttUSHORT(fc+loc+0) && encodingID == ttUSHORT(fc+loc+2) + && languageID == ttUSHORT(fc+loc+4) && nameID == ttUSHORT(fc+loc+6)) { + *length = ttUSHORT(fc+loc+8); + return (const char *) (fc+stringOffset+ttUSHORT(fc+loc+10)); + } + } + return NULL; +} + +static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 nlen, stbtt_int32 target_id, stbtt_int32 next_id) +{ + stbtt_int32 i; + stbtt_int32 count = ttUSHORT(fc+nm+2); + stbtt_int32 stringOffset = nm + ttUSHORT(fc+nm+4); + + for (i=0; i < count; ++i) { + stbtt_uint32 loc = nm + 6 + 12 * i; + stbtt_int32 id = ttUSHORT(fc+loc+6); + if (id == target_id) { + // find the encoding + stbtt_int32 platform = ttUSHORT(fc+loc+0), encoding = ttUSHORT(fc+loc+2), language = ttUSHORT(fc+loc+4); + + // is this a Unicode encoding? + if (platform == 0 || (platform == 3 && encoding == 1) || (platform == 3 && encoding == 10)) { + stbtt_int32 slen = ttUSHORT(fc+loc+8); + stbtt_int32 off = ttUSHORT(fc+loc+10); + + // check if there's a prefix match + stbtt_int32 matchlen = stbtt__CompareUTF8toUTF16_bigendian_prefix(name, nlen, fc+stringOffset+off,slen); + if (matchlen >= 0) { + // check for target_id+1 immediately following, with same encoding & language + if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) { + slen = ttUSHORT(fc+loc+12+8); + off = ttUSHORT(fc+loc+12+10); + if (slen == 0) { + if (matchlen == nlen) + return 1; + } else if (matchlen < nlen && name[matchlen] == ' ') { + ++matchlen; + if (stbtt_CompareUTF8toUTF16_bigendian_internal((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen)) + return 1; + } + } else { + // if nothing immediately following + if (matchlen == nlen) + return 1; + } + } + } + + // @TODO handle other encodings + } + } + return 0; +} + +static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *name, stbtt_int32 flags) +{ + stbtt_int32 nlen = (stbtt_int32) STBTT_strlen((char *) name); + stbtt_uint32 nm,hd; + if (!stbtt__isfont(fc+offset)) return 0; + + // check italics/bold/underline flags in macStyle... + if (flags) { + hd = stbtt__find_table(fc, offset, "head"); + if ((ttUSHORT(fc+hd+44) & 7) != (flags & 7)) return 0; + } + + nm = stbtt__find_table(fc, offset, "name"); + if (!nm) return 0; + + if (flags) { + // if we checked the macStyle flags, then just check the family and ignore the subfamily + if (stbtt__matchpair(fc, nm, name, nlen, 16, -1)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 1, -1)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; + } else { + if (stbtt__matchpair(fc, nm, name, nlen, 16, 17)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 1, 2)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; + } + + return 0; +} + +static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, stbtt_int32 flags) +{ + stbtt_int32 i; + for (i=0;;++i) { + stbtt_int32 off = stbtt_GetFontOffsetForIndex(font_collection, i); + if (off < 0) return off; + if (stbtt__matches((stbtt_uint8 *) font_collection, off, (stbtt_uint8*) name_utf8, flags)) + return off; + } +} + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-qual" +#endif + +STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, + float pixel_height, unsigned char *pixels, int pw, int ph, + int first_char, int num_chars, stbtt_bakedchar *chardata) +{ + return stbtt_BakeFontBitmap_internal((unsigned char *) data, offset, pixel_height, pixels, pw, ph, first_char, num_chars, chardata); +} + +STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index) +{ + return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index); +} + +STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data) +{ + return stbtt_GetNumberOfFonts_internal((unsigned char *) data); +} + +STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset) +{ + return stbtt_InitFont_internal(info, (unsigned char *) data, offset); +} + +STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags) +{ + return stbtt_FindMatchingFont_internal((unsigned char *) fontdata, (char *) name, flags); +} + +STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) +{ + return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2); +} + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + +#endif // STB_TRUETYPE_IMPLEMENTATION + + +// FULL VERSION HISTORY +// +// 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual +// 1.11 (2016-04-02) fix unused-variable warning +// 1.10 (2016-04-02) allow user-defined fabs() replacement +// fix memory leak if fontsize=0.0 +// fix warning from duplicate typedef +// 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use alloc userdata for PackFontRanges +// 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges +// 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; +// allow PackFontRanges to pack and render in separate phases; +// fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); +// fixed an assert() bug in the new rasterizer +// replace assert() with STBTT_assert() in new rasterizer +// 1.06 (2015-07-14) performance improvements (~35% faster on x86 and x64 on test machine) +// also more precise AA rasterizer, except if shapes overlap +// remove need for STBTT_sort +// 1.05 (2015-04-15) fix misplaced definitions for STBTT_STATIC +// 1.04 (2015-04-15) typo in example +// 1.03 (2015-04-12) STBTT_STATIC, fix memory leak in new packing, various fixes +// 1.02 (2014-12-10) fix various warnings & compile issues w/ stb_rect_pack, C++ +// 1.01 (2014-12-08) fix subpixel position when oversampling to exactly match +// non-oversampled; STBTT_POINT_SIZE for packed case only +// 1.00 (2014-12-06) add new PackBegin etc. API, w/ support for oversampling +// 0.99 (2014-09-18) fix multiple bugs with subpixel rendering (ryg) +// 0.9 (2014-08-07) support certain mac/iOS fonts without an MS platformID +// 0.8b (2014-07-07) fix a warning +// 0.8 (2014-05-25) fix a few more warnings +// 0.7 (2013-09-25) bugfix: subpixel glyph bug fixed in 0.5 had come back +// 0.6c (2012-07-24) improve documentation +// 0.6b (2012-07-20) fix a few more warnings +// 0.6 (2012-07-17) fix warnings; added stbtt_ScaleForMappingEmToPixels, +// stbtt_GetFontBoundingBox, stbtt_IsGlyphEmpty +// 0.5 (2011-12-09) bugfixes: +// subpixel glyph renderer computed wrong bounding box +// first vertex of shape can be off-curve (FreeSans) +// 0.4b (2011-12-03) fixed an error in the font baking example +// 0.4 (2011-12-01) kerning, subpixel rendering (tor) +// bugfixes for: +// codepoint-to-glyph conversion using table fmt=12 +// codepoint-to-glyph conversion using table fmt=4 +// stbtt_GetBakedQuad with non-square texture (Zer) +// updated Hello World! sample to use kerning and subpixel +// fixed some warnings +// 0.3 (2009-06-24) cmap fmt=12, compound shapes (MM) +// userdata, malloc-from-userdata, non-zero fill (stb) +// 0.2 (2009-03-11) Fix unsigned/signed char warnings +// 0.1 (2009-03-09) First public release +// + +``` + +`imgui_extension.cpp`: + +```cpp +#include "horizon.hpp" +#include "imgui_extension.hpp" + +ImVec2 operator/(ImVec2 v, int i) { return ImVec2(v.x / i, v.y / i); } +ImVec2 operator+(ImVec2 v1, ImVec2 v2) { return ImVec2(v1.x + v2.x, v1.y + v2.y); } +ImVec2 operator-(ImVec2 v1, ImVec2 v2) { return ImVec2(v1.x - v2.x, v1.y - v2.y); } +bool operator==(ImVec2 v1, ImVec2 v2) { return v1.x == v2.x && v1.y == v2.y; } +bool operator!=(ImVec2 v1, ImVec2 v2) { return v1 != v2; } + +namespace ImGui +{ + namespace Center + { + int start_idx = 0; + ImDrawList* draw_list = nullptr; + + void Start(ImDrawList* draw_list) + { + if (!draw_list) + draw_list = ImGui::GetWindowDrawList(); + + ImGui::Center::start_idx = draw_list->VtxBuffer.Size; + ImGui::Center::draw_list = draw_list; + } + + void CenterX() + { + auto item_width = ImGui::CalcItemWidth(); + auto window_width = ImGui::GetWindowWidth(); + + auto& buf = draw_list->VtxBuffer; + for (int i = start_idx; i < buf.Size; i++) + buf[i].pos.x += (window_width / 2.f) - (item_width / 2.f); + + start_idx = draw_list->VtxBuffer.Size; + } + + void End() + { + start_idx = 0; + draw_list = nullptr; + } + } + + namespace Rotation + { + int start_idx = 0; + ImDrawList* draw_list = nullptr; + + void Start(ImDrawList* draw_list) + { + if (!draw_list) + draw_list = ImGui::GetWindowDrawList(); + + ImGui::Rotation::start_idx = draw_list->VtxBuffer.Size; + ImGui::Rotation::draw_list = draw_list; + } + + void Rotate(float rad, ImVec2 center) + { + auto s = sin(rad); + auto c = cos(rad); + center = ImRotate(center, c, s) - center; + + auto& buf = draw_list->VtxBuffer; + for (int i = start_idx; i < buf.Size; i++) + buf[i].pos = ImRotate(buf[i].pos, c, s) - center; + } + + void End() + { + start_idx = 0; + draw_list = nullptr; + } + } + + namespace Page + { + size_t count = 0; + size_t page = 0; + float width = 0; + + void Begin(size_t size) + { + page = 0; + count = size; + width = ImGui::GetWindowSize().x; + width /= count; + width -= (ImGui::GetStyle().FramePadding.x * (count - 1)); + ImGui::BeginChild("page_start", ImVec2(width, 0)); + } + + void Next() + { + //assert(count > 0); + + char buffer[128] = ""; + sprintf(buffer, "page_%d", page); + page++; + + ImGui::EndChild(); + ImGui::SameLine(); + ImGui::BeginChild(buffer, ImVec2(width, 0)); + } + + void End() + { + ImGui::EndChild(); + count = 0; + width = 0; + page = 0; + } + } +} +``` + +`imgui_extension.hpp`: + +```hpp +#pragma once + +extern ImVec2 operator / (ImVec2 v, int i); +extern ImVec2 operator + (ImVec2 v1, ImVec2 v2); +extern ImVec2 operator - (ImVec2 v1, ImVec2 v2); +extern bool operator == (ImVec2 v1, ImVec2 v2); +extern bool operator != (ImVec2 v1, ImVec2 v2); + +namespace ImGui +{ + namespace Center + { + extern int start_idx; + extern ImDrawList* draw_list; + + extern void Start(ImDrawList* draw_list = nullptr); + + extern void CenterX(); + + extern void End(); + } + + namespace Rotation + { + extern int start_idx; + extern ImDrawList* draw_list; + + extern void Start(ImDrawList* draw_list = nullptr); + + extern void Rotate(float rad, ImVec2 center); + + extern void End(); + } + + namespace Page + { + extern size_t count; + extern size_t page; + extern float width; + + extern void Begin(size_t size = 2); + + extern void Next(); + + extern void End(); + } +} +``` + +`include/luajit-2.0.5/COPYRIGHT`: + +``` +=============================================================================== +LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ + +Copyright (C) 2005-2017 Mike Pall. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +[ MIT license: http://www.opensource.org/licenses/mit-license.php ] + +=============================================================================== +[ LuaJIT includes code from Lua 5.1/5.2, which has this license statement: ] + +Copyright (C) 1994-2012 Lua.org, PUC-Rio. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +=============================================================================== +[ LuaJIT includes code from dlmalloc, which has this license statement: ] + +This is a version (aka dlmalloc) of malloc/free/realloc written by +Doug Lea and released to the public domain, as explained at +http://creativecommons.org/licenses/publicdomain + +=============================================================================== + +``` + +`include/luajit-2.0.5/Makefile`: + +``` +############################################################################## +# LuaJIT top level Makefile for installation. Requires GNU Make. +# +# Please read doc/install.html before changing any variables! +# +# Suitable for POSIX platforms (Linux, *BSD, OSX etc.). +# Note: src/Makefile has many more configurable options. +# +# ##### This Makefile is NOT useful for Windows! ##### +# For MSVC, please follow the instructions given in src/msvcbuild.bat. +# For MinGW and Cygwin, cd to src and run make with the Makefile there. +# +# Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +############################################################################## + +MAJVER= 2 +MINVER= 0 +RELVER= 5 +VERSION= $(MAJVER).$(MINVER).$(RELVER) +ABIVER= 5.1 + +############################################################################## +# +# Change the installation path as needed. This automatically adjusts +# the paths in src/luaconf.h, too. Note: PREFIX must be an absolute path! +# +export PREFIX= /usr/local +export MULTILIB= lib +############################################################################## + +DPREFIX= $(DESTDIR)$(PREFIX) +INSTALL_BIN= $(DPREFIX)/bin +INSTALL_LIB= $(DPREFIX)/$(MULTILIB) +INSTALL_SHARE= $(DPREFIX)/share +INSTALL_INC= $(DPREFIX)/include/luajit-$(MAJVER).$(MINVER) + +INSTALL_LJLIBD= $(INSTALL_SHARE)/luajit-$(VERSION) +INSTALL_JITLIB= $(INSTALL_LJLIBD)/jit +INSTALL_LMODD= $(INSTALL_SHARE)/lua +INSTALL_LMOD= $(INSTALL_LMODD)/$(ABIVER) +INSTALL_CMODD= $(INSTALL_LIB)/lua +INSTALL_CMOD= $(INSTALL_CMODD)/$(ABIVER) +INSTALL_MAN= $(INSTALL_SHARE)/man/man1 +INSTALL_PKGCONFIG= $(INSTALL_LIB)/pkgconfig + +INSTALL_TNAME= luajit-$(VERSION) +INSTALL_TSYMNAME= luajit +INSTALL_ANAME= libluajit-$(ABIVER).a +INSTALL_SOSHORT1= libluajit-$(ABIVER).so +INSTALL_SOSHORT2= libluajit-$(ABIVER).so.$(MAJVER) +INSTALL_SONAME= $(INSTALL_SOSHORT2).$(MINVER).$(RELVER) +INSTALL_DYLIBSHORT1= libluajit-$(ABIVER).dylib +INSTALL_DYLIBSHORT2= libluajit-$(ABIVER).$(MAJVER).dylib +INSTALL_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).$(MINVER).$(RELVER).dylib +INSTALL_PCNAME= luajit.pc + +INSTALL_STATIC= $(INSTALL_LIB)/$(INSTALL_ANAME) +INSTALL_DYN= $(INSTALL_LIB)/$(INSTALL_SONAME) +INSTALL_SHORT1= $(INSTALL_LIB)/$(INSTALL_SOSHORT1) +INSTALL_SHORT2= $(INSTALL_LIB)/$(INSTALL_SOSHORT2) +INSTALL_T= $(INSTALL_BIN)/$(INSTALL_TNAME) +INSTALL_TSYM= $(INSTALL_BIN)/$(INSTALL_TSYMNAME) +INSTALL_PC= $(INSTALL_PKGCONFIG)/$(INSTALL_PCNAME) + +INSTALL_DIRS= $(INSTALL_BIN) $(INSTALL_LIB) $(INSTALL_INC) $(INSTALL_MAN) \ + $(INSTALL_PKGCONFIG) $(INSTALL_JITLIB) $(INSTALL_LMOD) $(INSTALL_CMOD) +UNINSTALL_DIRS= $(INSTALL_JITLIB) $(INSTALL_LJLIBD) $(INSTALL_INC) \ + $(INSTALL_LMOD) $(INSTALL_LMODD) $(INSTALL_CMOD) $(INSTALL_CMODD) + +RM= rm -f +MKDIR= mkdir -p +RMDIR= rmdir 2>/dev/null +SYMLINK= ln -sf +INSTALL_X= install -m 0755 +INSTALL_F= install -m 0644 +UNINSTALL= $(RM) +LDCONFIG= ldconfig -n +SED_PC= sed -e "s|^prefix=.*|prefix=$(PREFIX)|" \ + -e "s|^multilib=.*|multilib=$(MULTILIB)|" + +FILE_T= luajit +FILE_A= libluajit.a +FILE_SO= libluajit.so +FILE_MAN= luajit.1 +FILE_PC= luajit.pc +FILES_INC= lua.h lualib.h lauxlib.h luaconf.h lua.hpp luajit.h +FILES_JITLIB= bc.lua v.lua dump.lua dis_x86.lua dis_x64.lua dis_arm.lua \ + dis_ppc.lua dis_mips.lua dis_mipsel.lua bcsave.lua vmdef.lua + +ifeq (,$(findstring Windows,$(OS))) + HOST_SYS:= $(shell uname -s) +else + HOST_SYS= Windows +endif +TARGET_SYS?= $(HOST_SYS) + +ifeq (Darwin,$(TARGET_SYS)) + INSTALL_SONAME= $(INSTALL_DYLIBNAME) + INSTALL_SOSHORT1= $(INSTALL_DYLIBSHORT1) + INSTALL_SOSHORT2= $(INSTALL_DYLIBSHORT2) + LDCONFIG= : +endif + +############################################################################## + +INSTALL_DEP= src/luajit + +default all $(INSTALL_DEP): + @echo "==== Building LuaJIT $(VERSION) ====" + $(MAKE) -C src + @echo "==== Successfully built LuaJIT $(VERSION) ====" + +install: $(INSTALL_DEP) + @echo "==== Installing LuaJIT $(VERSION) to $(PREFIX) ====" + $(MKDIR) $(INSTALL_DIRS) + cd src && $(INSTALL_X) $(FILE_T) $(INSTALL_T) + cd src && test -f $(FILE_A) && $(INSTALL_F) $(FILE_A) $(INSTALL_STATIC) || : + $(RM) $(INSTALL_TSYM) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) + cd src && test -f $(FILE_SO) && \ + $(INSTALL_X) $(FILE_SO) $(INSTALL_DYN) && \ + $(LDCONFIG) $(INSTALL_LIB) && \ + $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT1) && \ + $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT2) || : + cd etc && $(INSTALL_F) $(FILE_MAN) $(INSTALL_MAN) + cd etc && $(SED_PC) $(FILE_PC) > $(FILE_PC).tmp && \ + $(INSTALL_F) $(FILE_PC).tmp $(INSTALL_PC) && \ + $(RM) $(FILE_PC).tmp + cd src && $(INSTALL_F) $(FILES_INC) $(INSTALL_INC) + cd src/jit && $(INSTALL_F) $(FILES_JITLIB) $(INSTALL_JITLIB) + $(SYMLINK) $(INSTALL_TNAME) $(INSTALL_TSYM) + @echo "==== Successfully installed LuaJIT $(VERSION) to $(PREFIX) ====" + +uninstall: + @echo "==== Uninstalling LuaJIT $(VERSION) from $(PREFIX) ====" + $(UNINSTALL) $(INSTALL_TSYM) $(INSTALL_T) $(INSTALL_STATIC) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) $(INSTALL_MAN)/$(FILE_MAN) $(INSTALL_PC) + for file in $(FILES_JITLIB); do \ + $(UNINSTALL) $(INSTALL_JITLIB)/$$file; \ + done + for file in $(FILES_INC); do \ + $(UNINSTALL) $(INSTALL_INC)/$$file; \ + done + $(LDCONFIG) $(INSTALL_LIB) + $(RMDIR) $(UNINSTALL_DIRS) || : + @echo "==== Successfully uninstalled LuaJIT $(VERSION) from $(PREFIX) ====" + +############################################################################## + +amalg: + @echo "Building LuaJIT $(VERSION)" + $(MAKE) -C src amalg + +clean: + $(MAKE) -C src clean + +.PHONY: all install amalg clean + +############################################################################## + +``` + +`include/luajit-2.0.5/README`: + +``` +README for LuaJIT 2.0.5 +----------------------- + +LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language. + +Project Homepage: http://luajit.org/ + +LuaJIT is Copyright (C) 2005-2017 Mike Pall. +LuaJIT is free software, released under the MIT license. +See full Copyright Notice in the COPYRIGHT file or in luajit.h. + +Documentation for LuaJIT is available in HTML format. +Please point your favorite browser to: + + doc/luajit.html + + +``` + +`include/luajit-2.0.5/doc/bluequad-print.css`: + +```css +/* Copyright (C) 2004-2017 Mike Pall. + * + * You are welcome to use the general ideas of this design for your own sites. + * But please do not steal the stylesheet, the layout or the color scheme. + */ +body { + font-family: serif; + font-size: 11pt; + margin: 0 3em; + padding: 0; + border: none; +} +a:link, a:visited, a:hover, a:active { + text-decoration: none; + background: transparent; + color: #0000ff; +} +h1, h2, h3 { + font-family: sans-serif; + font-weight: bold; + text-align: left; + margin: 0.5em 0; + padding: 0; +} +h1 { + font-size: 200%; +} +h2 { + font-size: 150%; +} +h3 { + font-size: 125%; +} +p { + margin: 0 0 0.5em 0; + padding: 0; +} +ul, ol { + margin: 0.5em 0; + padding: 0 0 0 2em; +} +ul { + list-style: outside square; +} +ol { + list-style: outside decimal; +} +li { + margin: 0; + padding: 0; +} +dl { + margin: 1em 0; + padding: 1em; + border: 1px solid black; +} +dt { + font-weight: bold; + margin: 0; + padding: 0; +} +dt sup { + float: right; + margin-left: 1em; +} +dd { + margin: 0.5em 0 0 2em; + padding: 0; +} +table { + table-layout: fixed; + width: 100%; + margin: 1em 0; + padding: 0; + border: 1px solid black; + border-spacing: 0; + border-collapse: collapse; +} +tr { + margin: 0; + padding: 0; + border: none; +} +td { + text-align: left; + margin: 0; + padding: 0.2em 0.5em; + border-top: 1px solid black; + border-bottom: 1px solid black; +} +tr.separate td { + border-top: double; +} +tt, pre, code, kbd, samp { + font-family: monospace; + font-size: 75%; +} +kbd { + font-weight: bolder; +} +blockquote, pre { + margin: 1em 2em; + padding: 0; +} +img { + border: none; + vertical-align: baseline; + margin: 0; + padding: 0; +} +img.left { + float: left; + margin: 0.5em 1em 0.5em 0; +} +img.right { + float: right; + margin: 0.5em 0 0.5em 1em; +} +.flush { + clear: both; + visibility: hidden; +} +.hide, .noprint, #nav { + display: none !important; +} +.pagebreak { + page-break-before: always; +} +#site { + text-align: right; + font-family: sans-serif; + font-weight: bold; + margin: 0 1em; + border-bottom: 1pt solid black; +} +#site a { + font-size: 1.2em; +} +#site a:link, #site a:visited { + text-decoration: none; + font-weight: bold; + background: transparent; + color: #ffffff; +} +#logo { + color: #ff8000; +} +#head { + clear: both; + margin: 0 1em; +} +#main { + line-height: 1.3; + text-align: justify; + margin: 1em; +} +#foot { + clear: both; + font-size: 80%; + text-align: center; + margin: 0 1.25em; + padding: 0.5em 0 0 0; + border-top: 1pt solid black; + page-break-before: avoid; + page-break-after: avoid; +} + +``` + +`include/luajit-2.0.5/doc/bluequad.css`: + +```css +/* Copyright (C) 2004-2017 Mike Pall. + * + * You are welcome to use the general ideas of this design for your own sites. + * But please do not steal the stylesheet, the layout or the color scheme. + */ +/* colorscheme: + * + * site | head #4162bf/white | #6078bf/#e6ecff + * ------+------ ----------------+------------------- + * nav | main #bfcfff | #e6ecff/black + * + * nav: hiback loback #c5d5ff #b9c9f9 + * hiborder loborder #e6ecff #97a7d7 + * link hover #2142bf #ff0000 + * + * link: link visited hover #2142bf #8122bf #ff0000 + * + * main: boxback boxborder #f0f4ff #bfcfff + */ +body { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10pt; + margin: 0; + padding: 0; + border: none; + background: #e0e0e0; + color: #000000; +} +a:link { + text-decoration: none; + background: transparent; + color: #2142bf; +} +a:visited { + text-decoration: none; + background: transparent; + color: #8122bf; +} +a:hover, a:active { + text-decoration: underline; + background: transparent; + color: #ff0000; +} +h1, h2, h3 { + font-weight: bold; + text-align: left; + margin: 0.5em 0; + padding: 0; + background: transparent; +} +h1 { + font-size: 200%; + line-height: 3em; /* really 6em relative to body, match #site span */ + margin: 0; +} +h2 { + font-size: 150%; + color: #606060; +} +h3 { + font-size: 125%; + color: #404040; +} +p { + max-width: 600px; + margin: 0 0 0.5em 0; + padding: 0; +} +b { + color: #404040; +} +ul, ol { + max-width: 600px; + margin: 0.5em 0; + padding: 0 0 0 2em; +} +ul { + list-style: outside square; +} +ol { + list-style: outside decimal; +} +li { + margin: 0; + padding: 0; +} +dl { + max-width: 600px; + margin: 1em 0; + padding: 1em; + border: 1px solid #bfcfff; + background: #f0f4ff; +} +dt { + font-weight: bold; + margin: 0; + padding: 0; +} +dt sup { + float: right; + margin-left: 1em; + color: #808080; +} +dt a:visited { + text-decoration: none; + color: #2142bf; +} +dt a:hover, dt a:active { + text-decoration: none; + color: #ff0000; +} +dd { + margin: 0.5em 0 0 2em; + padding: 0; +} +div.tablewrap { /* for IE *sigh* */ + max-width: 600px; +} +table { + table-layout: fixed; + border-spacing: 0; + border-collapse: collapse; + max-width: 600px; + width: 100%; + margin: 1em 0; + padding: 0; + border: 1px solid #bfcfff; +} +tr { + margin: 0; + padding: 0; + border: none; +} +tr.odd { + background: #f0f4ff; +} +tr.separate td { + border-top: 1px solid #bfcfff; +} +td { + text-align: left; + margin: 0; + padding: 0.2em 0.5em; + border: none; +} +tt, code, kbd, samp { + font-family: Courier New, Courier, monospace; + line-height: 1.2; + font-size: 110%; +} +kbd { + font-weight: bolder; +} +blockquote, pre { + max-width: 600px; + margin: 1em 2em; + padding: 0; +} +pre { + line-height: 1.1; +} +pre.code { + line-height: 1.4; + margin: 0.5em 0 1em 0.5em; + padding: 0.5em 1em; + border: 1px solid #bfcfff; + background: #f0f4ff; +} +pre.mark { + padding-left: 2em; +} +span.codemark { + position:absolute; + left: 16em; + color: #4040c0; +} +span.mark { + color: #4040c0; + font-family: Courier New, Courier, monospace; + line-height: 1.1; +} +img { + border: none; + vertical-align: baseline; + margin: 0; + padding: 0; +} +img.left { + float: left; + margin: 0.5em 1em 0.5em 0; +} +img.right { + float: right; + margin: 0.5em 0 0.5em 1em; +} +.indent { + padding-left: 1em; +} +.flush { + clear: both; + visibility: hidden; +} +.hide, .noscreen { + display: none !important; +} +.ext { + color: #ff8000; +} +.new { + font-size: 6pt; + vertical-align: middle; + background: #ff8000; + color: #ffffff; +} +#site { + clear: both; + float: left; + width: 13em; + text-align: center; + font-weight: bold; + margin: 0; + padding: 0; + background: transparent; + color: #ffffff; +} +#site a { + font-size: 200%; +} +#site a:link, #site a:visited { + text-decoration: none; + font-weight: bold; + background: transparent; + color: #ffffff; +} +#site span { + line-height: 3em; /* really 6em relative to body, match h1 */ +} +#logo { + color: #ffb380; +} +#head { + margin: 0; + padding: 0 0 0 2em; + border-left: solid 13em #4162bf; + border-right: solid 3em #6078bf; + background: #6078bf; + color: #e6ecff; +} +#nav { + clear: both; + float: left; + overflow: hidden; + text-align: left; + line-height: 1.5; + width: 13em; + padding-top: 1em; + background: transparent; +} +#nav ul { + list-style: none outside; + margin: 0; + padding: 0; +} +#nav li { + margin: 0; + padding: 0; +} +#nav a { + display: block; + text-decoration: none; + font-weight: bold; + margin: 0; + padding: 2px 1em; + border-top: 1px solid transparent; + border-bottom: 1px solid transparent; + background: transparent; + color: #2142bf; +} +#nav a:hover, #nav a:active { + text-decoration: none; + border-top: 1px solid #97a7d7; + border-bottom: 1px solid #e6ecff; + background: #b9c9f9; + color: #ff0000; +} +#nav a.current, #nav a.current:hover, #nav a.current:active { + border-top: 1px solid #e6ecff; + border-bottom: 1px solid #97a7d7; + background: #c5d5ff; + color: #2142bf; +} +#nav ul ul a { + padding: 0 1em 0 1.7em; +} +#nav ul ul ul a { + padding: 0 0.5em 0 2.4em; +} +#main { + line-height: 1.5; + text-align: left; + margin: 0; + padding: 1em 2em; + border-left: solid 13em #bfcfff; + border-right: solid 3em #e6ecff; + background: #e6ecff; +} +#foot { + clear: both; + font-size: 80%; + text-align: center; + margin: 0; + padding: 0.5em; + background: #6078bf; + color: #ffffff; +} +#foot a:link, #foot a:visited { + text-decoration: underline; + background: transparent; + color: #ffffff; +} +#foot a:hover, #foot a:active { + text-decoration: underline; + background: transparent; + color: #bfcfff; +} + +``` + +`include/luajit-2.0.5/doc/changes.html`: + +```html + + + +LuaJIT Change History + + + + + + + + + + + + +
+

+This is a list of changes between the released versions of LuaJIT.
+The current stable version is LuaJIT 2.0.5.
+

+

+Please check the +» Online Change History +to see whether newer versions are available. +

+ +
+

LuaJIT 2.0.5 — 2017-05-01

+
    +
  • Add workaround for MSVC 2015 stdio changes.
  • +
  • Limit mcode alloc probing, depending on the available pool size.
  • +
  • Fix overly restrictive range calculation in mcode allocation.
  • +
  • Fix out-of-scope goto handling in parser.
  • +
  • Remove internal __mode = "K" and replace with safe check.
  • +
  • Add "proto" field to jit.util.funcinfo().
  • +
  • Fix GC step size calculation.
  • +
  • Initialize uv->immutable for upvalues of loaded chunks.
  • +
  • Fix for cdata vs. non-cdata arithmetics/comparisons.
  • +
  • Drop leftover regs in 'for' iterator assignment, too.
  • +
  • Fix PHI remarking in SINK pass.
  • +
  • Don't try to record outermost pcall() return to lower frame.
  • +
  • Add guard for obscure aliasing between open upvalues and SSA slots.
  • +
  • Remove assumption that lj_math_random_step() doesn't clobber FPRs.
  • +
  • Fix handling of non-numeric strings in arithmetic coercions.
  • +
  • Fix recording of select(n, ...) with off-trace varargs
  • +
  • Fix install for cross-builds.
  • +
  • Don't allocate unused 2nd result register in JIT compiler backend.
  • +
  • Drop marks from replayed instructions when sinking.
  • +
  • Fix unsinking check.
  • +
  • Properly handle OOM in trace_save().
  • +
  • Limit number of arguments given to io.lines() and fp:lines().
  • +
  • Fix narrowing of TOBIT.
  • +
  • OSX: Fix build with recent XCode.
  • +
  • x86/x64: Don't spill an explicit REF_BASE in the IR.
  • +
  • x86/x64: Fix instruction length decoder.
  • +
  • x86/x64: Search for exit jumps with instruction length decoder.
  • +
  • ARM: Fix BLX encoding for Thumb interworking calls.
  • +
  • MIPS: Don't use RID_GP as a scratch register.
  • +
  • MIPS: Fix emitted code for U32 to float conversion.
  • +
  • MIPS: Backport workaround for compact unwind tables.
  • +
  • MIPS: Fix cross-endian jit.bcsave.
  • +
  • MIPS: Fix BC_ISNEXT fallback path.
  • +
  • MIPS: Fix use of ffgccheck delay slots in interpreter.
  • +
  • FFI: Fix FOLD rules for int64_t comparisons.
  • +
  • FFI: Fix SPLIT pass for CONV i64.u64.
  • +
  • FFI: Fix ipairs() recording.
  • +
  • FFI: Don't propagate qualifiers into subtypes of complex.
  • +
+ +

LuaJIT 2.0.4 — 2015-05-14

+
    +
  • Fix stack check in narrowing optimization.
  • +
  • Fix Lua/C API typecheck error for special indexes.
  • +
  • Fix string to number conversion.
  • +
  • Fix lexer error for chunks without tokens.
  • +
  • Don't compile IR_RETF after CALLT to ff with-side effects.
  • +
  • Fix BC_UCLO/BC_JMP join optimization in Lua parser.
  • +
  • Fix corner case in string to number conversion.
  • +
  • Gracefully handle lua_error() for a suspended coroutine.
  • +
  • Avoid error messages when building with Clang.
  • +
  • Fix snapshot #0 handling for traces with a stack check on entry.
  • +
  • Fix fused constant loads under high register pressure.
  • +
  • Invalidate backpropagation cache after DCE.
  • +
  • Fix ABC elimination.
  • +
  • Fix debug info for main chunk of stripped bytecode.
  • +
  • Fix FOLD rule for string.sub(s, ...) == k.
  • +
  • Fix FOLD rule for STRREF of SNEW.
  • +
  • Fix frame traversal while searching for error function.
  • +
  • Prevent GC estimate miscalculation due to buffer growth.
  • +
  • Prevent adding side traces for stack checks.
  • +
  • Fix top slot calculation for snapshots with continuations.
  • +
  • Fix check for reuse of SCEV results in FORL.
  • +
  • Add PS Vita port.
  • +
  • Fix compatibility issues with Illumos.
  • +
  • Fix DragonFly build (unsupported).
  • +
  • OpenBSD/x86: Better executable memory allocation for W^X mode.
  • +
  • x86: Fix argument checks for ipairs() iterator.
  • +
  • x86: lj_math_random_step() clobbers XMM regs on OSX Clang.
  • +
  • x86: Fix code generation for unused result of math.random().
  • +
  • x64: Allow building with LUAJIT_USE_SYSMALLOC and LUAJIT_USE_VALGRIND.
  • +
  • x86/x64: Fix argument check for bit shifts.
  • +
  • x86/x64: Fix code generation for fused test/arith ops.
  • +
  • ARM: Fix write barrier check in BC_USETS.
  • +
  • PPC: Fix red zone overflow in machine code generation.
  • +
  • PPC: Don't use mcrxr on PPE.
  • +
  • Various archs: Fix excess stack growth in interpreter.
  • +
  • FFI: Fix FOLD rule for TOBIT + CONV num.u32.
  • +
  • FFI: Prevent DSE across ffi.string().
  • +
  • FFI: No meta fallback when indexing pointer to incomplete struct.
  • +
  • FFI: Fix initialization of unions of subtypes.
  • +
  • FFI: Fix cdata vs. non-cdata arithmetic and comparisons.
  • +
  • FFI: Fix __index/__newindex metamethod resolution for ctypes.
  • +
  • FFI: Fix compilation of reference field access.
  • +
  • FFI: Fix frame traversal for backtraces with FFI callbacks.
  • +
  • FFI: Fix recording of indexing a struct pointer ctype object itself.
  • +
  • FFI: Allow non-scalar cdata to be compared for equality by address.
  • +
  • FFI: Fix pseudo type conversions for type punning.
  • +
+ +

LuaJIT 2.0.3 — 2014-03-12

+
    +
  • Add PS4 port.
  • +
  • Add support for multilib distro builds.
  • +
  • Fix OSX build.
  • +
  • Fix MinGW build.
  • +
  • Fix Xbox 360 build.
  • +
  • Improve ULOAD forwarding for open upvalues.
  • +
  • Fix GC steps threshold handling when called by JIT-compiled code.
  • +
  • Fix argument checks for math.deg() and math.rad().
  • +
  • Fix jit.flush(func|true).
  • +
  • Respect jit.off(func) when returning to a function, too.
  • +
  • Fix compilation of string.byte(s, nil, n).
  • +
  • Fix line number for relocated bytecode after closure fixup
  • +
  • Fix frame traversal for backtraces.
  • +
  • Fix ABC elimination.
  • +
  • Fix handling of redundant PHIs.
  • +
  • Fix snapshot restore for exit to function header.
  • +
  • Fix type punning alias analysis for constified pointers
  • +
  • Fix call unroll checks in the presence of metamethod frames.
  • +
  • Fix initial maxslot for down-recursive traces.
  • +
  • Prevent BASE register coalescing if parent uses IR_RETF.
  • +
  • Don't purge modified function from stack slots in BC_RET.
  • +
  • Fix recording of BC_VARG.
  • +
  • Don't access dangling reference to reallocated IR.
  • +
  • Fix frame depth display for bytecode dump in -jdump.
  • +
  • ARM: Fix register allocation when rematerializing FPRs.
  • +
  • x64: Fix store to upvalue for lightuserdata values.
  • +
  • FFI: Add missing GC steps for callback argument conversions.
  • +
  • FFI: Properly unload loaded DLLs.
  • +
  • FFI: Fix argument checks for ffi.string().
  • +
  • FFI/x64: Fix passing of vector arguments to calls.
  • +
  • FFI: Rehash finalizer table after GC cycle, if needed.
  • +
  • FFI: Fix cts->L for cdata unsinking in snapshot restore.
  • +
+ +

LuaJIT 2.0.2 — 2013-06-03

+
    +
  • Fix memory access check for fast string interning.
  • +
  • Fix MSVC intrinsics for older versions.
  • +
  • Add missing GC steps for io.* functions.
  • +
  • Fix spurious red zone overflows in machine code generation.
  • +
  • Fix jump-range constrained mcode allocation.
  • +
  • Inhibit DSE for implicit loads via calls.
  • +
  • Fix builtin string to number conversion for overflow digits.
  • +
  • Fix optional argument handling while recording builtins.
  • +
  • Fix optional argument handling in table.concat().
  • +
  • Add partial support for building with MingW64 GCC 4.8-SEH.
  • +
  • Add missing PHI barrier to string.sub(str, a, b) == kstr FOLD rule.
  • +
  • Fix compatibility issues with Illumos.
  • +
  • ARM: Fix cache flush/sync for exit stubs of JIT-compiled code.
  • +
  • MIPS: Fix cache flush/sync for JIT-compiled code jump area.
  • +
  • PPC: Add plt suffix for external calls from assembler code.
  • +
  • FFI: Fix snapshot substitution in SPLIT pass.
  • +
  • FFI/x86: Fix register allocation for 64 bit comparisons.
  • +
  • FFI: Fix tailcall in lowest frame to C function with bool result.
  • +
  • FFI: Ignore long type specifier in ffi.istype().
  • +
  • FFI: Fix calling conventions for 32 bit OSX and iOS simulator (struct returns).
  • +
  • FFI: Fix calling conventions for ARM hard-float EABI (nested structs).
  • +
  • FFI: Improve error messages for arithmetic and comparison operators.
  • +
  • FFI: Insert no-op type conversion for pointer to integer cast.
  • +
  • FFI: Fix unroll limit for ffi.fill().
  • +
  • FFI: Must sink XBAR together with XSTOREs.
  • +
  • FFI: Preserve intermediate string for const char * conversion.
  • +
+ +

LuaJIT 2.0.1 — 2013-02-19

+
    +
  • Don't clear frame for out-of-memory error.
  • +
  • Leave hook when resume catches error thrown from hook.
  • +
  • Add missing GC steps for template table creation.
  • +
  • Fix discharge order of comparisons in Lua parser.
  • +
  • Improve buffer handling for io.read().
  • +
  • OSX: Add support for Mach-O object files to -b option.
  • +
  • Fix PS3 port.
  • +
  • Fix/enable Xbox 360 port.
  • +
  • x86/x64: Always mark ref for shift count as non-weak.
  • +
  • x64: Don't fuse implicitly 32-to-64 extended operands.
  • +
  • ARM: Fix armhf call argument handling.
  • +
  • ARM: Fix code generation for integer math.min/math.max.
  • +
  • PPC/e500: Fix lj_vm_floor() for Inf/NaN.
  • +
  • FFI: Change priority of table initializer variants for structs.
  • +
  • FFI: Fix code generation for bool call result check on x86/x64.
  • +
  • FFI: Load FFI library on-demand for bytecode with cdata literals.
  • +
  • FFI: Fix handling of qualified transparent structs/unions.
  • +
+ +

LuaJIT 2.0.0 — 2012-11-08

+
    +
  • Correctness and completeness: +
      +
    • Fix Android/x86 build.
    • +
    • Fix recording of equality comparisons with __eq metamethods.
    • +
    • Fix detection of immutable upvalues.
    • +
    • Replace error with PANIC for callbacks from JIT-compiled code.
    • +
    • Fix builtin string to number conversion for INT_MIN.
    • +
    • Don't create unneeded array part for template tables.
    • +
    • Fix CONV.num.int sinking.
    • +
    • Don't propagate implicitly widened number to index metamethods.
    • +
    • ARM: Fix ordered comparisons of number vs. non-number.
    • +
    • FFI: Fix code generation for replay of sunk float fields.
    • +
    • FFI: Fix signedness of bool.
    • +
    • FFI: Fix recording of bool call result check on x86/x64.
    • +
    • FFI: Fix stack-adjustment for __thiscall callbacks.
    • +
  • +
+ +

LuaJIT 2.0.0-beta11 — 2012-10-16

+
    +
  • New features: +
      +
    • Use ARM VFP instructions, if available (build-time detection).
    • +
    • Add support for ARM hard-float EABI (armhf).
    • +
    • Add PS3 port.
    • +
    • Add many features from Lua 5.2, e.g. goto/labels. + Refer to this list.
    • +
    • FFI: Add parameterized C types.
    • +
    • FFI: Add support for copy constructors.
    • +
    • FFI: Equality comparisons never raise an error (treat as unequal instead).
    • +
    • FFI: Box all accessed or returned enums.
    • +
    • FFI: Check for __new metamethod when calling a constructor.
    • +
    • FFI: Handle __pairs/__ipairs metamethods for cdata objects.
    • +
    • FFI: Convert io.* file handle to FILE * pointer (but as a void *).
    • +
    • FFI: Detect and support type punning through unions.
    • +
    • FFI: Improve various error messages.
    • +
  • +
  • Build-system reorganization: +
      +
    • Reorganize directory layout:
      + lib/*src/jit/*
      + src/buildvm_*.dascsrc/vm_*.dasc
      + src/buildvm_*.h → removed
      + src/buildvm*src/host/*
    • +
    • Add minified Lua interpreter plus Lua BitOp (minilua) to run DynASM.
    • +
    • Change DynASM bit operations to use Lua BitOp
    • +
    • Translate only vm_*.dasc for detected target architecture.
    • +
    • Improve target detection for msvcbuild.bat.
    • +
    • Fix build issues on Cygwin and MinGW with optional MSys.
    • +
    • Handle cross-compiles with FPU/no-FPU or hard-fp/soft-fp ABI mismatch.
    • +
    • Remove some library functions for no-JIT/no-FFI builds.
    • +
    • Add uninstall target to top-level Makefile.
    • +
  • +
  • Correctness and completeness: +
      +
    • Preserve snapshot #0 PC for all traces.
    • +
    • Fix argument checks for coroutine.create().
    • +
    • Command line prints version and JIT status to stdout, not stderr.
    • +
    • Fix userdata __gc separations at Lua state close.
    • +
    • Fix TDUP to HLOAD forwarding for LJ_DUALNUM builds.
    • +
    • Fix buffer check in bytecode writer.
    • +
    • Make os.date() thread-safe.
    • +
    • Add missing declarations for MSVC intrinsics.
    • +
    • Fix dispatch table modifications for return hooks.
    • +
    • Workaround for MSVC conversion bug (doubleuint32_tint32_t).
    • +
    • Fix FOLD rule (i-j)-i => 0-j.
    • +
    • Never use DWARF unwinder on Windows.
    • +
    • Fix shrinking of direct mapped blocks in builtin allocator.
    • +
    • Limit recursion depth in string.match() et al.
    • +
    • Fix late despecialization of ITERN after loop has been entered.
    • +
    • Fix 'f' and 'L' options for debug.getinfo() and lua_getinfo().
    • +
    • Fix package.searchpath().
    • +
    • OSX: Change dylib names to be consistent with other platforms.
    • +
    • Android: Workaround for broken sprintf("%g", -0.0).
    • +
    • x86: Remove support for ancient CPUs without CMOV (before Pentium Pro).
    • +
    • x86: Fix register allocation for calls returning register pair.
    • +
    • x86/x64: Fix fusion of unsigned byte comparisons with swapped operands.
    • +
    • ARM: Fix tonumber() argument check.
    • +
    • ARM: Fix modulo operator and math.floor()/math.ceil() for inf/nan.
    • +
    • ARM: Invoke SPLIT pass for leftover IR_TOBIT.
    • +
    • ARM: Fix BASE register coalescing.
    • +
    • PPC: Fix interpreter state setup in callbacks.
    • +
    • PPC: Fix string.sub() range check.
    • +
    • MIPS: Support generation of MIPS/MIPSEL bytecode object files.
    • +
    • MIPS: Fix calls to floor()/ceil()/trunc().
    • +
    • ARM/PPC: Detect more target architecture variants.
    • +
    • ARM/PPC/e500/MIPS: Fix tailcalls from fast functions, esp. tostring().
    • +
    • ARM/PPC/MIPS: Fix rematerialization of FP constants.
    • +
    • FFI: Don't call FreeLibrary() on our own EXE/DLL.
    • +
    • FFI: Resolve metamethods for constructors, too.
    • +
    • FFI: Properly disable callbacks on iOS (would require executable memory).
    • +
    • FFI: Fix cdecl string parsing during recording.
    • +
    • FFI: Show address pointed to for tostring(ref), too.
    • +
    • FFI: Fix alignment of C call argument/return structure.
    • +
    • FFI: Initialize all fields of standard types.
    • +
    • FFI: Fix callback handling when new C types are declared in callback.
    • +
    • FFI: Fix recording of constructors for pointers.
    • +
    • FFI: Always resolve metamethods for pointers to structs.
    • +
    • FFI: Correctly propagate alignment when interning nested types.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • Add allocation sinking and store sinking optimization.
    • +
    • Constify immutable upvalues.
    • +
    • Add builtin string to integer or FP number conversion. Improves cross-platform consistency and correctness.
    • +
    • Create string hash slots in template tables for non-const values, too. Avoids later table resizes.
    • +
    • Eliminate HREFK guard for template table references.
    • +
    • Add various new FOLD rules.
    • +
    • Don't use stack unwinding for lua_yield() (slow on x64).
    • +
    • ARM, PPC, MIPS: Improve XLOAD operand fusion and register hinting.
    • +
    • PPC, MIPS: Compile math.sqrt() to sqrt instruction, if available.
    • +
    • FFI: Fold KPTR + constant offset in SPLIT pass.
    • +
    • FFI: Optimize/inline ffi.copy() and ffi.fill().
    • +
    • FFI: Compile and optimize array/struct copies.
    • +
    • FFI: Compile ffi.typeof(cdata|ctype), ffi.sizeof(), ffi.alignof(), ffi.offsetof() and ffi.gc().
    • +
  • +
+ +

LuaJIT 2.0.0-beta10 — 2012-05-09

+
    +
  • New features: +
      +
    • The MIPS of LuaJIT is complete. It requires a CPU conforming to the +MIPS32 R1 architecture with hardware FPU. O32 hard-fp ABI, +little-endian or big-endian.
    • +
    • Auto-detect target arch via cross-compiler. No need for +TARGET=arch anymore.
    • +
    • Make DynASM compatible with Lua 5.2.
    • +
    • From Lua 5.2: Try __tostring metamethod on non-string error +messages..
    • +
  • +
  • Correctness and completeness: +
      +
    • Fix parsing of hex literals with exponents.
    • +
    • Fix bytecode dump for certain number constants.
    • +
    • Fix argument type in error message for relative arguments.
    • +
    • Fix argument error handling on Lua stacks without a frame.
    • +
    • Add missing mcode limit check in assembler backend.
    • +
    • Fix compilation on OpenBSD.
    • +
    • Avoid recursive GC steps after GC-triggered trace exit.
    • +
    • Replace <unwind.h> definitions with our own.
    • +
    • Fix OSX build issues. Bump minimum required OSX version to 10.4.
    • +
    • Fix discharge order of comparisons in Lua parser.
    • +
    • Ensure running __gc of userdata created in __gc +at state close.
    • +
    • Limit number of userdata __gc separations at state close.
    • +
    • Fix bytecode JMP slot range when optimizing +and/or with constant LHS.
    • +
    • Fix DSE of USTORE.
    • +
    • Make lua_concat() work from C hook with partial frame.
    • +
    • Add required PHIs for implicit conversions, e.g. via XREF +forwarding.
    • +
    • Add more comparison variants to Valgrind suppressions file.
    • +
    • Disable loading bytecode with an extra header (BOM or #!).
    • +
    • Fix PHI stack slot syncing.
    • +
    • ARM: Reorder type/value tests to silence Valgrind.
    • +
    • ARM: Fix register allocation for ldrd-optimized +HREFK.
    • +
    • ARM: Fix conditional branch fixup for OBAR.
    • +
    • ARM: Invoke SPLIT pass for double args in FFI call.
    • +
    • ARM: Handle all CALL* ops with double results in +SPLIT pass.
    • +
    • ARM: Fix rejoin of POW in SPLIT pass.
    • +
    • ARM: Fix compilation of math.sinh, math.cosh, +math.tanh.
    • +
    • ARM, PPC: Avoid pointless arg clearing in BC_IFUNCF.
    • +
    • PPC: Fix resume after yield from hook.
    • +
    • PPC: Fix argument checking for rawget().
    • +
    • PPC: Fix fusion of floating-point XLOAD/XSTORE.
    • +
    • PPC: Fix HREFK code generation for huge tables.
    • +
    • PPC: Use builtin D-Cache/I-Cache sync code.
    • +
  • +
  • FFI library: +
      +
    • Ignore empty statements in ffi.cdef().
    • +
    • Ignore number parsing errors while skipping definitions.
    • +
    • Don't touch frame in callbacks with tailcalls to fast functions.
    • +
    • Fix library unloading on POSIX systems.
    • +
    • Finalize cdata before userdata when closing the state.
    • +
    • Change ffi.load() library name resolution for Cygwin.
    • +
    • Fix resolving of function name redirects on Windows/x86.
    • +
    • Fix symbol resolving error messages on Windows.
    • +
    • Fix blacklisting of C functions calling callbacks.
    • +
    • Fix result type of pointer difference.
    • +
    • Use correct PC in FFI metamethod error message.
    • +
    • Allow 'typedef _Bool int BOOL;' for the Windows API.
    • +
    • Don't record test for bool result of call, if ignored.
    • +
  • +
+ +

LuaJIT 2.0.0-beta9 — 2011-12-14

+
    +
  • New features: +
      +
    • PPC port of LuaJIT is complete. Default is the dual-number port +(usually faster). Single-number port selectable via src/Makefile +at build time.
    • +
    • Add FFI callback support.
    • +
    • Extend -b to generate .c, .h or .obj/.o +files with embedded bytecode.
    • +
    • Allow loading embedded bytecode with require().
    • +
    • From Lua 5.2: Change to '\z' escape. Reject undefined escape +sequences.
    • +
  • +
  • Correctness and completeness: +
      +
    • Fix OSX 10.7 build. Fix install_name and versioning on OSX.
    • +
    • Fix iOS build.
    • +
    • Install dis_arm.lua, too.
    • +
    • Mark installed shared library as executable.
    • +
    • Add debug option to msvcbuild.bat and improve error handling.
    • +
    • Fix data-flow analysis for iterators.
    • +
    • Fix forced unwinding triggered by external unwinder.
    • +
    • Record missing for loop slot loads (return to lower frame).
    • +
    • Always use ANSI variants of Windows system functions.
    • +
    • Fix GC barrier for multi-result table constructor (TSETM).
    • +
    • Fix/add various FOLD rules.
    • +
    • Add potential PHI for number conversions due to type instability.
    • +
    • Do not eliminate PHIs only referenced from other PHIs.
    • +
    • Correctly anchor implicit number to string conversions in Lua/C API.
    • +
    • Fix various stack limit checks.
    • +
    • x64: Use thread-safe exceptions for external unwinding (GCC platforms).
    • +
    • x64: Fix result type of cdata index conversions.
    • +
    • x64: Fix math.random() and bit.bswap() code generation.
    • +
    • x64: Fix lightuserdata comparisons.
    • +
    • x64: Always extend stack-passed arguments to pointer size.
    • +
    • ARM: Many fixes to code generation backend.
    • +
    • PPC/e500: Fix dispatch for binop metamethods.
    • +
    • PPC/e500: Save/restore condition registers when entering/leaving the VM.
    • +
    • PPC/e500: Fix write barrier in stores of strings to upvalues.
    • +
  • +
  • FFI library: +
      +
    • Fix C comment parsing.
    • +
    • Fix snapshot optimization for cdata comparisons.
    • +
    • Fix recording of const/enum lookups in namespaces.
    • +
    • Fix call argument and return handling for I8/U8/I16/U16 types.
    • +
    • Fix unfused loads of float fields.
    • +
    • Fix ffi.string() recording.
    • +
    • Save GetLastError() around ffi.load() and symbol +resolving, too.
    • +
    • Improve ld script detection in ffi.load().
    • +
    • Record loads/stores to external variables in namespaces.
    • +
    • Compile calls to stdcall, fastcall and vararg functions.
    • +
    • Treat function ctypes like pointers in comparisons.
    • +
    • Resolve __call metamethod for pointers, too.
    • +
    • Record C function calls with bool return values.
    • +
    • Record ffi.errno().
    • +
    • x86: Fix number to uint32_t conversion rounding.
    • +
    • x86: Fix 64 bit arithmetic in assembler backend.
    • +
    • x64: Fix struct-by-value calling conventions.
    • +
    • ARM: Ensure invocation of SPLIT pass for float conversions.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • Display trace types with -jv and -jdump.
    • +
    • Record isolated calls. But prefer recording loops over calls.
    • +
    • Specialize to prototype for non-monomorphic functions. Solves the +trace-explosion problem for closure-heavy programming styles.
    • +
    • Always generate a portable vmdef.lua. Easier for distros.
    • +
  • +
+ +

LuaJIT 2.0.0-beta8 — 2011-06-23

+
    +
  • New features: +
      +
    • Soft-float ARM port of LuaJIT is complete.
    • +
    • Add support for bytecode loading/saving and -b command line +option.
    • +
    • From Lua 5.2: __len metamethod for tables +(disabled by default).
    • +
  • +
  • Correctness and completeness: +
      +
    • ARM: Misc. fixes for interpreter.
    • +
    • x86/x64: Fix bit.* argument checking in interpreter.
    • +
    • Catch early out-of-memory in memory allocator initialization.
    • +
    • Fix data-flow analysis for paths leading to an upvalue close.
    • +
    • Fix check for missing arguments in string.format().
    • +
    • Fix Solaris/x86 build (note: not a supported target).
    • +
    • Fix recording of loops with instable directions in side traces.
    • +
    • x86/x64: Fix fusion of comparisons with u8/u16 +XLOAD.
    • +
    • x86/x64: Fix register allocation for variable shifts.
    • +
  • +
  • FFI library: +
      +
    • Add ffi.errno(). Save errno/GetLastError() +around allocations etc.
    • +
    • Fix __gc for VLA/VLS cdata objects.
    • +
    • Fix recording of casts from 32 bit cdata pointers to integers.
    • +
    • tonumber(cdata) returns nil for non-numbers.
    • +
    • Show address pointed to for tostring(pointer).
    • +
    • Print NULL pointers as "cdata<... *>: NULL".
    • +
    • Support __tostring metamethod for pointers to structs, too.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • More tuning for loop unrolling heuristics.
    • +
    • Flatten and compress in-memory debug info (saves ~70%).
    • +
  • +
+ +

LuaJIT 2.0.0-beta7 — 2011-05-05

+
    +
  • New features: +
      +
    • ARM port of the LuaJIT interpreter is complete.
    • +
    • FFI library: Add ffi.gc(), ffi.metatype(), +ffi.istype().
    • +
    • FFI library: Resolve ld script redirection in ffi.load().
    • +
    • From Lua 5.2: package.searchpath(), fp:read("*L"), +load(string).
    • +
    • From Lua 5.2, disabled by default: empty statement, +table.unpack(), modified coroutine.running().
    • +
  • +
  • Correctness and completeness: +
      +
    • FFI library: numerous fixes.
    • +
    • Fix type mismatches in store-to-load forwarding.
    • +
    • Fix error handling within metamethods.
    • +
    • Fix table.maxn().
    • +
    • Improve accuracy of x^-k on x64.
    • +
    • Fix code generation for Intel Atom in x64 mode.
    • +
    • Fix narrowing of POW.
    • +
    • Fix recording of retried fast functions.
    • +
    • Fix code generation for bit.bnot() and multiplies.
    • +
    • Fix error location within cpcall frames.
    • +
    • Add workaround for old libgcc unwind bug.
    • +
    • Fix lua_yield() and getmetatable(lightuserdata) on x64.
    • +
    • Misc. fixes for PPC/e500 interpreter.
    • +
    • Fix stack slot updates for down-recursion.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • Add dual-number mode (int/double) for the VM. Enabled for ARM.
    • +
    • Improve narrowing of arithmetic operators and for loops.
    • +
    • Tune loop unrolling heuristics and increase trace recorder limits.
    • +
    • Eliminate dead slots in snapshots using bytecode data-flow analysis.
    • +
    • Avoid phantom stores to proxy tables.
    • +
    • Optimize lookups in empty proxy tables.
    • +
    • Improve bytecode optimization of and/or operators.
    • +
  • +
+ +

LuaJIT 2.0.0-beta6 — 2011-02-11

+
    +
  • New features: +
      +
    • PowerPC/e500v2 port of the LuaJIT interpreter is complete.
    • +
    • Various minor features from Lua 5.2: Hex escapes in literals, +'\*' escape, reversible string.format("%q",s), +"%g" pattern, table.sort checks callbacks, +os.exit(status|true|false[,close]).
    • +
    • Lua 5.2 __pairs and __ipairs metamethods +(disabled by default).
    • +
    • Initial release of the FFI library.
    • +
  • +
  • Correctness and completeness: +
      +
    • Fix string.format() for non-finite numbers.
    • +
    • Fix memory leak when compiled to use the built-in allocator.
    • +
    • x86/x64: Fix unnecessary resize in TSETM bytecode.
    • +
    • Fix various GC issues with traces and jit.flush().
    • +
    • x64: Fix fusion of indexes for array references.
    • +
    • x86/x64: Fix stack overflow handling for coroutine results.
    • +
    • Enable low-2GB memory allocation on FreeBSD/x64.
    • +
    • Fix collectgarbage("count") result if more than 2GB is in use.
    • +
    • Fix parsing of hex floats.
    • +
    • x86/x64: Fix loop branch inversion with trailing +HREF+NE/EQ.
    • +
    • Add jit.os string.
    • +
    • coroutine.create() permits running C functions, too.
    • +
    • Fix OSX build to work with newer ld64 versions.
    • +
    • Fix bytecode optimization of and/or operators.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • Emit specialized bytecode for pairs()/next().
    • +
    • Improve bytecode coalescing of nil constants.
    • +
    • Compile calls to vararg functions.
    • +
    • Compile select().
    • +
    • Improve alias analysis, esp. for loads from allocations.
    • +
    • Tuning of various compiler heuristics.
    • +
    • Refactor and extend IR conversion instructions.
    • +
    • x86/x64: Various backend enhancements related to the FFI.
    • +
    • Add SPLIT pass to split 64 bit IR instructions for 32 bit CPUs.
    • +
  • +
+ +

LuaJIT 2.0.0-beta5 — 2010-08-24

+
    +
  • Correctness and completeness: +
      +
    • Fix trace exit dispatch to function headers.
    • +
    • Fix Windows and OSX builds with LUAJIT_DISABLE_JIT.
    • +
    • Reorganize and fix placement of generated machine code on x64.
    • +
    • Fix TNEW in x64 interpreter.
    • +
    • Do not eliminate PHIs for values only referenced from side exits.
    • +
    • OS-independent canonicalization of strings for non-finite numbers.
    • +
    • Fix string.char() range check on x64.
    • +
    • Fix tostring() resolving within print().
    • +
    • Fix error handling for next().
    • +
    • Fix passing of constant arguments to external calls on x64.
    • +
    • Fix interpreter argument check for two-argument SSE math functions.
    • +
    • Fix C frame chain corruption caused by lua_cpcall().
    • +
    • Fix return from pcall() within active hook.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • Replace on-trace GC frame syncing with interpreter exit.
    • +
    • Improve hash lookup specialization by not removing dead keys during GC.
    • +
    • Turn traces into true GC objects.
    • +
    • Avoid starting a GC cycle immediately after library init.
    • +
    • Add weak guards to improve dead-code elimination.
    • +
    • Speed up string interning.
    • +
  • +
+ +

LuaJIT 2.0.0-beta4 — 2010-03-28

+
    +
  • Correctness and completeness: +
      +
    • Fix precondition for on-trace creation of table keys.
    • +
    • Fix {f()} on x64 when table is resized.
    • +
    • Fix folding of ordered comparisons with same references.
    • +
    • Fix snapshot restores for multi-result bytecodes.
    • +
    • Fix potential hang when recording bytecode with nested closures.
    • +
    • Fix recording of getmetatable(), tonumber() and bad argument types.
    • +
    • Fix SLOAD fusion across returns to lower frames.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • Add array bounds check elimination. -Oabc is enabled by default.
    • +
    • More tuning for x64, e.g. smaller table objects.
    • +
  • +
+ +

LuaJIT 2.0.0-beta3 — 2010-03-07

+
    +
  • LuaJIT x64 port: +
      +
    • Port integrated memory allocator to Linux/x64, Windows/x64 and OSX/x64.
    • +
    • Port interpreter and JIT compiler to x64.
    • +
    • Port DynASM to x64.
    • +
    • Many 32/64 bit cleanups in the VM.
    • +
    • Allow building the interpreter with either x87 or SSE2 arithmetics.
    • +
    • Add external unwinding and C++ exception interop (default on x64).
    • +
  • +
  • Correctness and completeness: +
      +
    • Fix constructor bytecode generation for certain conditional values.
    • +
    • Fix some cases of ordered string comparisons.
    • +
    • Fix lua_tocfunction().
    • +
    • Fix cutoff register in JMP bytecode for some conditional expressions.
    • +
    • Fix PHI marking algorithm for references from variant slots.
    • +
    • Fix package.cpath for non-default PREFIX.
    • +
    • Fix DWARF2 frame unwind information for interpreter on OSX.
    • +
    • Drive the GC forward on string allocations in the parser.
    • +
    • Implement call/return hooks (zero-cost if disabled).
    • +
    • Implement yield from C hooks.
    • +
    • Disable JIT compiler on older non-SSE2 CPUs instead of aborting.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • Compile recursive code (tail-, up- and down-recursion).
    • +
    • Improve heuristics for bytecode penalties and blacklisting.
    • +
    • Split CALL/FUNC recording and clean up fast function call semantics.
    • +
    • Major redesign of internal function call handling.
    • +
    • Improve FOR loop const specialization and integerness checks.
    • +
    • Switch to pre-initialized stacks. Avoid frame-clearing.
    • +
    • Colocation of prototypes and related data: bytecode, constants, debug info.
    • +
    • Cleanup parser and streamline bytecode generation.
    • +
    • Add support for weak IR references to register allocator.
    • +
    • Switch to compressed, extensible snapshots.
    • +
    • Compile returns to frames below the start frame.
    • +
    • Improve alias analysis of upvalues using a disambiguation hash value.
    • +
    • Compile floor/ceil/trunc to SSE2 helper calls or SSE4.1 instructions.
    • +
    • Add generic C call handling to IR and backend.
    • +
    • Improve KNUM fuse vs. load heuristics.
    • +
    • Compile various io.*() functions.
    • +
    • Compile math.sinh(), math.cosh(), math.tanh() +and math.random().
    • +
  • +
+ +

LuaJIT 2.0.0-beta2 — 2009-11-09

+
    +
  • Reorganize build system. Build static+shared library on POSIX.
  • +
  • Allow C++ exception conversion on all platforms +using a wrapper function.
  • +
  • Automatically catch C++ exceptions and rethrow Lua error +(DWARF2 only).
  • +
  • Check for the correct x87 FPU precision at strategic points.
  • +
  • Always use wrappers for libm functions.
  • +
  • Resurrect metamethod name strings before copying them.
  • +
  • Mark current trace, even if compiler is idle.
  • +
  • Ensure FILE metatable is created only once.
  • +
  • Fix type comparisons when different integer types are involved.
  • +
  • Fix getmetatable() recording.
  • +
  • Fix TDUP with dead keys in template table.
  • +
  • jit.flush(tr) returns status. +Prevent manual flush of a trace that's still linked.
  • +
  • Improve register allocation heuristics for invariant references.
  • +
  • Compile the push/pop variants of table.insert() and +table.remove().
  • +
  • Compatibility with MSVC link /debug.
  • +
  • Fix lua_iscfunction().
  • +
  • Fix math.random() when compiled with -fpic (OSX).
  • +
  • Fix table.maxn().
  • +
  • Bump MACOSX_DEPLOYMENT_TARGET to 10.4
  • +
  • luaL_check*() and luaL_opt*() now support +negative arguments, too.
    +This matches the behavior of Lua 5.1, but not the specification.
  • +
+ +

LuaJIT 2.0.0-beta1 — 2009-10-31

+
    +
  • This is the first public release of LuaJIT 2.0.
  • +
  • The whole VM has been rewritten from the ground up, so there's +no point in listing differences over earlier versions.
  • +
+
+ +
+

LuaJIT 1.1.8 — 2012-04-16

+ + +

LuaJIT 1.1.7 — 2011-05-05

+ + +

LuaJIT 1.1.6 — 2010-03-28

+
    +
  • Added fixes for the +» currently known bugs in Lua 5.1.4.
  • +
  • Removed wrong GC check in jit_createstate(). +Thanks to Tim Mensch.
  • +
  • Fixed bad assertions while compiling table.insert() and +table.remove().
  • +
+ +

LuaJIT 1.1.5 — 2008-10-25

+ + +

LuaJIT 1.1.4 — 2008-02-05

+
    +
  • Merged with Lua 5.1.3. Fixes all +» known bugs in Lua 5.1.2.
  • +
  • Fixed possible (but unlikely) stack corruption while compiling +k^x expressions.
  • +
  • Fixed DynASM template for cmpss instruction.
  • +
+ +

LuaJIT 1.1.3 — 2007-05-24

+
    +
  • Merged with Lua 5.1.2. Fixes all +» known bugs in Lua 5.1.1.
  • +
  • Merged pending Lua 5.1.x fixes: "return -nil" bug, spurious count hook call.
  • +
  • Remove a (sometimes) wrong assertion in luaJIT_findpc().
  • +
  • DynASM now allows labels for displacements and .aword.
  • +
  • Fix some compiler warnings for DynASM glue (internal API change).
  • +
  • Correct naming for SSSE3 (temporarily known as SSE4) in DynASM and x86 disassembler.
  • +
  • The loadable debug modules now handle redirection to stdout +(e.g. -j trace=-).
  • +
+ +

LuaJIT 1.1.2 — 2006-06-24

+
    +
  • Fix MSVC inline assembly: use only local variables with +lua_number2int().
  • +
  • Fix "attempt to call a thread value" bug on Mac OS X: +make values of consts used as lightuserdata keys unique +to avoid joining by the compiler/linker.
  • +
+ +

LuaJIT 1.1.1 — 2006-06-20

+
    +
  • Merged with Lua 5.1.1. Fixes all +» known bugs in Lua 5.1.
  • +
  • Enforce (dynamic) linker error for EXE/DLL version mismatches.
  • +
  • Minor changes to DynASM: faster pre-processing, smaller encoding +for some immediates.
  • +
+

+This release is in sync with Coco 1.1.1 (see the +» Coco Change History). +

+ +

LuaJIT 1.1.0 — 2006-03-13

+
    +
  • Merged with Lua 5.1 (final).
  • + +
  • New JIT call frame setup: +
      +
    • The C stack is kept 16 byte aligned (faster). +Mandatory for Mac OS X on Intel, too.
    • +
    • Faster calling conventions for internal C helper functions.
    • +
    • Better instruction scheduling for function prologue, OP_CALL and +OP_RETURN.
    • +
  • + +
  • Miscellaneous optimizations: +
      +
    • Faster loads of FP constants. Remove narrow-to-wide store-to-load +forwarding stalls.
    • +
    • Use (scalar) SSE2 ops (if the CPU supports it) to speed up slot moves +and FP to integer conversions.
    • +
    • Optimized the two-argument form of OP_CONCAT (a..b).
    • +
    • Inlined OP_MOD (a%b). +With better accuracy than the C variant, too.
    • +
    • Inlined OP_POW (a^b). Unroll x^k or +use k^x = 2^(log2(k)*x) or call pow().
    • +
  • + +
  • Changes in the optimizer: +
      +
    • Improved hinting for table keys derived from table values +(t1[t2[x]]).
    • +
    • Lookup hinting now works with arbitrary object types and +supports index chains, too.
    • +
    • Generate type hints for arithmetic and comparison operators, +OP_LEN, OP_CONCAT and OP_FORPREP.
    • +
    • Remove several hint definitions in favour of a generic COMBINE hint.
    • +
    • Complete rewrite of jit.opt_inline module +(ex jit.opt_lib).
    • +
  • + +
  • Use adaptive deoptimization: +
      +
    • If runtime verification of a contract fails, the affected +instruction is recompiled and patched on-the-fly. +Regular programs will trigger deoptimization only occasionally.
    • +
    • This avoids generating code for uncommon fallback cases +most of the time. Generated code is up to 30% smaller compared to +LuaJIT 1.0.3.
    • +
    • Deoptimization is used for many opcodes and contracts: +
        +
      • OP_CALL, OP_TAILCALL: type mismatch for callable.
      • +
      • Inlined calls: closure mismatch, parameter number and type mismatches.
      • +
      • OP_GETTABLE, OP_SETTABLE: table or key type and range mismatches.
      • +
      • All arithmetic and comparison operators, OP_LEN, OP_CONCAT, +OP_FORPREP: operand type and range mismatches.
      • +
    • +
    • Complete redesign of the debug and traceback info +(bytecode ↔ mcode) to support deoptimization. +Much more flexible and needs only 50% of the space.
    • +
    • The modules jit.trace, jit.dumphints and +jit.dump handle deoptimization.
    • +
  • + +
  • Inlined many popular library functions +(for commonly used arguments only): +
      +
    • Most math.* functions (the 18 most used ones) +[2x-10x faster].
    • +
    • string.len, string.sub and string.char +[2x-10x faster].
    • +
    • table.insert, table.remove and table.getn +[3x-5x faster].
    • +
    • coroutine.yield and coroutine.resume +[3x-5x faster].
    • +
    • pairs, ipairs and the corresponding iterators +[8x-15x faster].
    • +
  • + +
  • Changes in the core and loadable modules and the stand-alone executable: +
      +
    • Added jit.version, jit.version_num +and jit.arch.
    • +
    • Reorganized some internal API functions (jit.util.*mcode*).
    • +
    • The -j dump output now shows JSUB names, too.
    • +
    • New x86 disassembler module written in pure Lua. No dependency +on ndisasm anymore. Flexible API, very compact (500 lines) +and complete (x87, MMX, SSE, SSE2, SSE3, SSSE3, privileged instructions).
    • +
    • luajit -v prints the LuaJIT version and copyright +on a separate line.
    • +
  • + +
  • Added SSE, SSE2, SSE3 and SSSE3 support to DynASM.
  • +
  • Miscellaneous doc changes. Added a section about +embedding LuaJIT.
  • +
+

+This release is in sync with Coco 1.1.0 (see the +» Coco Change History). +

+
+ +
+

LuaJIT 1.0.3 — 2005-09-08

+
    +
  • Even more docs.
  • +
  • Unified closure checks in jit.*.
  • +
  • Fixed some range checks in jit.util.*.
  • +
  • Fixed __newindex call originating from jit_settable_str().
  • +
  • Merged with Lua 5.1 alpha (including early bug fixes).
  • +
+

+This is the first public release of LuaJIT. +

+ +

LuaJIT 1.0.2 — 2005-09-02

+
    +
  • Add support for flushing the Valgrind translation cache
    +(MYCFLAGS= -DUSE_VALGRIND).
  • +
  • Add support for freeing executable mcode memory to the mmap()-based +variant for POSIX systems.
  • +
  • Reorganized the C function signature handling in +jit.opt_lib.
  • +
  • Changed to index-based hints for inlining C functions. +Still no support in the backend for inlining.
  • +
  • Hardcode HEAP_CREATE_ENABLE_EXECUTE value if undefined.
  • +
  • Misc. changes to the jit.* modules.
  • +
  • Misc. changes to the Makefiles.
  • +
  • Lots of new docs.
  • +
  • Complete doc reorg.
  • +
+

+Not released because Lua 5.1 alpha came out today. +

+ +

LuaJIT 1.0.1 — 2005-08-31

+
    +
  • Missing GC step in OP_CONCAT.
  • +
  • Fix result handling for C –> JIT calls.
  • +
  • Detect CPU feature bits.
  • +
  • Encode conditional moves (fucomip) only when supported.
  • +
  • Add fallback instructions for FP compares.
  • +
  • Add support for LUA_COMPAT_VARARG. Still disabled by default.
  • +
  • MSVC needs a specific place for the CALLBACK attribute +(David Burgess).
  • +
  • Misc. doc updates.
  • +
+

+Interim non-public release. +Special thanks to Adam D. Moss for reporting most of the bugs. +

+ +

LuaJIT 1.0.0 — 2005-08-29

+

+This is the initial non-public release of LuaJIT. +

+
+
+
+ + + + +``` + +`include/luajit-2.0.5/doc/contact.html`: + +```html + + + +Contact + + + + + + + + +
+Lua +
+ + +
+

+If you want to report bugs, propose fixes or suggest enhancements, +please use the +GitHub issue tracker. +

+

+Please send general questions to the +» LuaJIT mailing list. +

+

+You can also send any questions you have directly to me: +

+ + + + + +

Copyright

+

+All documentation is +Copyright © 2005-2017 Mike Pall. +

+ + +
+
+ + + + +``` + +`include/luajit-2.0.5/doc/ext_c_api.html`: + +```html + + + +Lua/C API Extensions + + + + + + + + +
+Lua +
+ + +
+

+LuaJIT adds some extensions to the standard Lua/C API. The LuaJIT include +directory must be in the compiler search path (-Ipath) +to be able to include the required header for C code: +

+
+#include "luajit.h"
+
+

+Or for C++ code: +

+
+#include "lua.hpp"
+
+ +

luaJIT_setmode(L, idx, mode) +— Control VM

+

+This is a C API extension to allow control of the VM from C code. The +full prototype of LuaJIT_setmode is: +

+
+LUA_API int luaJIT_setmode(lua_State *L, int idx, int mode);
+
+

+The returned status is either success (1) or failure (0). +The second argument is either 0 or a stack index (similar to the +other Lua/C API functions). +

+

+The third argument specifies the mode, which is 'or'ed with a flag. +The flag can be LUAJIT_MODE_OFF to turn a feature on, +LUAJIT_MODE_ON to turn a feature off, or +LUAJIT_MODE_FLUSH to flush cached code. +

+

+The following modes are defined: +

+ +

luaJIT_setmode(L, 0, LUAJIT_MODE_ENGINE|flag)

+

+Turn the whole JIT compiler on or off or flush the whole cache of compiled code. +

+ +

luaJIT_setmode(L, idx, LUAJIT_MODE_FUNC|flag)
+luaJIT_setmode(L, idx, LUAJIT_MODE_ALLFUNC|flag)
+luaJIT_setmode(L, idx, LUAJIT_MODE_ALLSUBFUNC|flag)

+

+This sets the mode for the function at the stack index idx or +the parent of the calling function (idx = 0). It either +enables JIT compilation for a function, disables it and flushes any +already compiled code or only flushes already compiled code. This +applies recursively to all sub-functions of the function with +LUAJIT_MODE_ALLFUNC or only to the sub-functions with +LUAJIT_MODE_ALLSUBFUNC. +

+ +

luaJIT_setmode(L, trace,
+  LUAJIT_MODE_TRACE|LUAJIT_MODE_FLUSH)

+

+Flushes the specified root trace and all of its side traces from the cache. +The code for the trace will be retained as long as there are any other +traces which link to it. +

+ +

luaJIT_setmode(L, idx, LUAJIT_MODE_WRAPCFUNC|flag)

+

+This mode defines a wrapper function for calls to C functions. If +called with LUAJIT_MODE_ON, the stack index at idx +must be a lightuserdata object holding a pointer to the wrapper +function. From now on all C functions are called through the wrapper +function. If called with LUAJIT_MODE_OFF this mode is turned +off and all C functions are directly called. +

+

+The wrapper function can be used for debugging purposes or to catch +and convert foreign exceptions. But please read the section on +C++ exception interoperability +first. Recommended usage can be seen in this C++ code excerpt: +

+
+#include <exception>
+#include "lua.hpp"
+
+// Catch C++ exceptions and convert them to Lua error messages.
+// Customize as needed for your own exception classes.
+static int wrap_exceptions(lua_State *L, lua_CFunction f)
+{
+  try {
+    return f(L);  // Call wrapped function and return result.
+  } catch (const char *s) {  // Catch and convert exceptions.
+    lua_pushstring(L, s);
+  } catch (std::exception& e) {
+    lua_pushstring(L, e.what());
+  } catch (...) {
+    lua_pushliteral(L, "caught (...)");
+  }
+  return lua_error(L);  // Rethrow as a Lua error.
+}
+
+static int myinit(lua_State *L)
+{
+  ...
+  // Define wrapper function and enable it.
+  lua_pushlightuserdata(L, (void *)wrap_exceptions);
+  luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC|LUAJIT_MODE_ON);
+  lua_pop(L, 1);
+  ...
+}
+
+

+Note that you can only define a single global wrapper function, +so be careful when using this mechanism from multiple C++ modules. +Also note that this mechanism is not without overhead. +

+
+
+ + + + +``` + +`include/luajit-2.0.5/doc/ext_ffi.html`: + +```html + + + +FFI Library + + + + + + + + +
+Lua +
+ + +
+

+ +The FFI library allows calling external C functions and +using C data structures from pure Lua code. + +

+

+ +The FFI library largely obviates the need to write tedious manual +Lua/C bindings in C. No need to learn a separate binding language +— it parses plain C declarations! These can be +cut-n-pasted from C header files or reference manuals. It's up to +the task of binding large libraries without the need for dealing with +fragile binding generators. + +

+

+The FFI library is tightly integrated into LuaJIT (it's not available +as a separate module). The code generated by the JIT-compiler for +accesses to C data structures from Lua code is on par with the +code a C compiler would generate. Calls to C functions can +be inlined in JIT-compiled code, unlike calls to functions bound via +the classic Lua/C API. +

+

+This page gives a short introduction to the usage of the FFI library. +Please use the FFI sub-topics in the navigation bar to learn more. +

+ +

Motivating Example: Calling External C Functions

+

+It's really easy to call an external C library function: +

+
+①
+②
+
+
+③local ffi = require("ffi")
+ffi.cdef[[
+int printf(const char *fmt, ...);
+]]
+ffi.C.printf("Hello %s!", "world")
+
+

+So, let's pick that apart: +

+

+ Load the FFI library. +

+

+ Add a C declaration +for the function. The part inside the double-brackets (in green) is +just standard C syntax. +

+

+ Call the named +C function — Yes, it's that simple! +

+

+Actually, what goes on behind the scenes is far from simple: makes use of the standard +C library namespace ffi.C. Indexing this namespace with +a symbol name ("printf") automatically binds it to the +standard C library. The result is a special kind of object which, +when called, runs the printf function. The arguments passed +to this function are automatically converted from Lua objects to the +corresponding C types. +

+

+Ok, so maybe the use of printf() wasn't such a spectacular +example. You could have done that with io.write() and +string.format(), too. But you get the idea ... +

+

+So here's something to pop up a message box on Windows: +

+
+local ffi = require("ffi")
+ffi.cdef[[
+int MessageBoxA(void *w, const char *txt, const char *cap, int type);
+]]
+ffi.C.MessageBoxA(nil, "Hello world!", "Test", 0)
+
+

+Bing! Again, that was far too easy, no? +

+

+Compare this with the effort required to bind that function using the +classic Lua/C API: create an extra C file, add a C function +that retrieves and checks the argument types passed from Lua and calls +the actual C function, add a list of module functions and their +names, add a luaopen_* function and register all module +functions, compile and link it into a shared library (DLL), move it to +the proper path, add Lua code that loads the module aaaand ... finally +call the binding function. Phew! +

+ +

Motivating Example: Using C Data Structures

+

+The FFI library allows you to create and access C data +structures. Of course the main use for this is for interfacing with +C functions. But they can be used stand-alone, too. +

+

+Lua is built upon high-level data types. They are flexible, extensible +and dynamic. That's why we all love Lua so much. Alas, this can be +inefficient for certain tasks, where you'd really want a low-level +data type. E.g. a large array of a fixed structure needs to be +implemented with a big table holding lots of tiny tables. This imposes +both a substantial memory overhead as well as a performance overhead. +

+

+Here's a sketch of a library that operates on color images plus a +simple benchmark. First, the plain Lua version: +

+
+local floor = math.floor
+
+local function image_ramp_green(n)
+  local img = {}
+  local f = 255/(n-1)
+  for i=1,n do
+    img[i] = { red = 0, green = floor((i-1)*f), blue = 0, alpha = 255 }
+  end
+  return img
+end
+
+local function image_to_grey(img, n)
+  for i=1,n do
+    local y = floor(0.3*img[i].red + 0.59*img[i].green + 0.11*img[i].blue)
+    img[i].red = y; img[i].green = y; img[i].blue = y
+  end
+end
+
+local N = 400*400
+local img = image_ramp_green(N)
+for i=1,1000 do
+  image_to_grey(img, N)
+end
+
+

+This creates a table with 160.000 pixels, each of which is a table +holding four number values in the range of 0-255. First an image with +a green ramp is created (1D for simplicity), then the image is +converted to greyscale 1000 times. Yes, that's silly, but I was in +need of a simple example ... +

+

+And here's the FFI version. The modified parts have been marked in +bold: +

+
+①
+
+
+
+
+
+②
+
+③
+④
+
+
+
+
+
+
+③
+⑤local ffi = require("ffi")
+ffi.cdef[[
+typedef struct { uint8_t red, green, blue, alpha; } rgba_pixel;
+]]
+
+local function image_ramp_green(n)
+  local img = ffi.new("rgba_pixel[?]", n)
+  local f = 255/(n-1)
+  for i=0,n-1 do
+    img[i].green = i*f
+    img[i].alpha = 255
+  end
+  return img
+end
+
+local function image_to_grey(img, n)
+  for i=0,n-1 do
+    local y = 0.3*img[i].red + 0.59*img[i].green + 0.11*img[i].blue
+    img[i].red = y; img[i].green = y; img[i].blue = y
+  end
+end
+
+local N = 400*400
+local img = image_ramp_green(N)
+for i=1,1000 do
+  image_to_grey(img, N)
+end
+
+

+Ok, so that wasn't too difficult: +

+

+ First, load the FFI +library and declare the low-level data type. Here we choose a +struct which holds four byte fields, one for each component +of a 4x8 bit RGBA pixel. +

+

+ Creating the data +structure with ffi.new() is straightforward — the +'?' is a placeholder for the number of elements of a +variable-length array. +

+

+ C arrays are +zero-based, so the indexes have to run from 0 to +n-1. One might want to allocate one more element instead to +simplify converting legacy code. +

+

+ Since ffi.new() +zero-fills the array by default, we only need to set the green and the +alpha fields. +

+

+ The calls to +math.floor() can be omitted here, because floating-point +numbers are already truncated towards zero when converting them to an +integer. This happens implicitly when the number is stored in the +fields of each pixel. +

+

+Now let's have a look at the impact of the changes: first, memory +consumption for the image is down from 22 Megabytes to +640 Kilobytes (400*400*4 bytes). That's a factor of 35x less! So, +yes, tables do have a noticeable overhead. BTW: The original program +would consume 40 Megabytes in plain Lua (on x64). +

+

+Next, performance: the pure Lua version runs in 9.57 seconds (52.9 +seconds with the Lua interpreter) and the FFI version runs in 0.48 +seconds on my machine (YMMV). That's a factor of 20x faster (110x +faster than the Lua interpreter). +

+

+The avid reader may notice that converting the pure Lua version over +to use array indexes for the colors ([1] instead of +.red, [2] instead of .green etc.) ought to +be more compact and faster. This is certainly true (by a factor of +~1.7x). Switching to a struct-of-arrays would help, too. +

+

+However the resulting code would be less idiomatic and rather +error-prone. And it still doesn't get even close to the performance of +the FFI version of the code. Also, high-level data structures cannot +be easily passed to other C functions, especially I/O functions, +without undue conversion penalties. +

+
+
+ + + + +``` + +`include/luajit-2.0.5/doc/ext_ffi_api.html`: + +```html + + + +ffi.* API Functions + + + + + + + + + +
+Lua +
+ + +
+

+This page describes the API functions provided by the FFI library in +detail. It's recommended to read through the +introduction and the +FFI tutorial first. +

+ +

Glossary

+
    +
  • cdecl — An abstract C type declaration (a Lua +string).
  • +
  • ctype — A C type object. This is a special kind of +cdata returned by ffi.typeof(). It serves as a +cdata constructor when called.
  • +
  • cdata — A C data object. It holds a value of the +corresponding ctype.
  • +
  • ct — A C type specification which can be used for +most of the API functions. Either a cdecl, a ctype or a +cdata serving as a template type.
  • +
  • cb — A callback object. This is a C data object +holding a special function pointer. Calling this function from +C code runs an associated Lua function.
  • +
  • VLA — A variable-length array is declared with a +? instead of the number of elements, e.g. "int[?]". +The number of elements (nelem) must be given when it's +created.
  • +
  • VLS — A variable-length struct is a struct C +type where the last element is a VLA. The same rules for +declaration and creation apply.
  • +
+ +

Declaring and Accessing External Symbols

+

+External symbols must be declared first and can then be accessed by +indexing a C library +namespace, which automatically binds the symbol to a specific +library. +

+ +

ffi.cdef(def)

+

+Adds multiple C declarations for types or external symbols (named +variables or functions). def must be a Lua string. It's +recommended to use the syntactic sugar for string arguments as +follows: +

+
+ffi.cdef[[
+typedef struct foo { int a, b; } foo_t;  // Declare a struct and typedef.
+int dofoo(foo_t *f, int n);  /* Declare an external C function. */
+]]
+
+

+The contents of the string (the part in green above) must be a +sequence of +C declarations, +separated by semicolons. The trailing semicolon for a single +declaration may be omitted. +

+

+Please note that external symbols are only declared, but they +are not bound to any specific address, yet. Binding is +achieved with C library namespaces (see below). +

+

+C declarations are not passed through a C pre-processor, +yet. No pre-processor tokens are allowed, except for +#pragma pack. Replace #define in existing +C header files with enum, static const +or typedef and/or pass the files through an external +C pre-processor (once). Be careful not to include unneeded or +redundant declarations from unrelated header files. +

+ +

ffi.C

+

+This is the default C library namespace — note the +uppercase 'C'. It binds to the default set of symbols or +libraries on the target system. These are more or less the same as a +C compiler would offer by default, without specifying extra link +libraries. +

+

+On POSIX systems, this binds to symbols in the default or global +namespace. This includes all exported symbols from the executable and +any libraries loaded into the global namespace. This includes at least +libc, libm, libdl (on Linux), +libgcc (if compiled with GCC), as well as any exported +symbols from the Lua/C API provided by LuaJIT itself. +

+

+On Windows systems, this binds to symbols exported from the +*.exe, the lua51.dll (i.e. the Lua/C API +provided by LuaJIT itself), the C runtime library LuaJIT was linked +with (msvcrt*.dll), kernel32.dll, +user32.dll and gdi32.dll. +

+ +

clib = ffi.load(name [,global])

+

+This loads the dynamic library given by name and returns +a new C library namespace which binds to its symbols. On POSIX +systems, if global is true, the library symbols are +loaded into the global namespace, too. +

+

+If name is a path, the library is loaded from this path. +Otherwise name is canonicalized in a system-dependent way and +searched in the default search path for dynamic libraries: +

+

+On POSIX systems, if the name contains no dot, the extension +.so is appended. Also, the lib prefix is prepended +if necessary. So ffi.load("z") looks for "libz.so" +in the default shared library search path. +

+

+On Windows systems, if the name contains no dot, the extension +.dll is appended. So ffi.load("ws2_32") looks for +"ws2_32.dll" in the default DLL search path. +

+ +

Creating cdata Objects

+

+The following API functions create cdata objects (type() +returns "cdata"). All created cdata objects are +garbage collected. +

+ +

cdata = ffi.new(ct [,nelem] [,init...])
+cdata = ctype([nelem,] [init...])

+

+Creates a cdata object for the given ct. VLA/VLS types +require the nelem argument. The second syntax uses a ctype as +a constructor and is otherwise fully equivalent. +

+

+The cdata object is initialized according to the +rules for initializers, +using the optional init arguments. Excess initializers cause +an error. +

+

+Performance notice: if you want to create many objects of one kind, +parse the cdecl only once and get its ctype with +ffi.typeof(). Then use the ctype as a constructor repeatedly. +

+

+Please note that an anonymous struct declaration implicitly +creates a new and distinguished ctype every time you use it for +ffi.new(). This is probably not what you want, +especially if you create more than one cdata object. Different anonymous +structs are not considered assignment-compatible by the +C standard, even though they may have the same fields! Also, they +are considered different types by the JIT-compiler, which may cause an +excessive number of traces. It's strongly suggested to either declare +a named struct or typedef with ffi.cdef() +or to create a single ctype object for an anonymous struct +with ffi.typeof(). +

+ +

ctype = ffi.typeof(ct)

+

+Creates a ctype object for the given ct. +

+

+This function is especially useful to parse a cdecl only once and then +use the resulting ctype object as a constructor. +

+ +

cdata = ffi.cast(ct, init)

+

+Creates a scalar cdata object for the given ct. The cdata +object is initialized with init using the "cast" variant of +the C type conversion +rules. +

+

+This functions is mainly useful to override the pointer compatibility +checks or to convert pointers to addresses or vice versa. +

+ +

ctype = ffi.metatype(ct, metatable)

+

+Creates a ctype object for the given ct and associates it with +a metatable. Only struct/union types, complex numbers +and vectors are allowed. Other types may be wrapped in a +struct, if needed. +

+

+The association with a metatable is permanent and cannot be changed +afterwards. Neither the contents of the metatable nor the +contents of an __index table (if any) may be modified +afterwards. The associated metatable automatically applies to all uses +of this type, no matter how the objects are created or where they +originate from. Note that pre-defined operations on types have +precedence (e.g. declared field names cannot be overriden). +

+

+All standard Lua metamethods are implemented. These are called directly, +without shortcuts and on any mix of types. For binary operations, the +left operand is checked first for a valid ctype metamethod. The +__gc metamethod only applies to struct/union +types and performs an implicit ffi.gc() +call during creation of an instance. +

+ +

cdata = ffi.gc(cdata, finalizer)

+

+Associates a finalizer with a pointer or aggregate cdata object. The +cdata object is returned unchanged. +

+

+This function allows safe integration of unmanaged resources into the +automatic memory management of the LuaJIT garbage collector. Typical +usage: +

+
+local p = ffi.gc(ffi.C.malloc(n), ffi.C.free)
+...
+p = nil -- Last reference to p is gone.
+-- GC will eventually run finalizer: ffi.C.free(p)
+
+

+A cdata finalizer works like the __gc metamethod for userdata +objects: when the last reference to a cdata object is gone, the +associated finalizer is called with the cdata object as an argument. The +finalizer can be a Lua function or a cdata function or cdata function +pointer. An existing finalizer can be removed by setting a nil +finalizer, e.g. right before explicitly deleting a resource: +

+
+ffi.C.free(ffi.gc(p, nil)) -- Manually free the memory.
+
+ +

C Type Information

+

+The following API functions return information about C types. +They are most useful for inspecting cdata objects. +

+ +

size = ffi.sizeof(ct [,nelem])

+

+Returns the size of ct in bytes. Returns nil if +the size is not known (e.g. for "void" or function types). +Requires nelem for VLA/VLS types, except for cdata objects. +

+ +

align = ffi.alignof(ct)

+

+Returns the minimum required alignment for ct in bytes. +

+ +

ofs [,bpos,bsize] = ffi.offsetof(ct, field)

+

+Returns the offset (in bytes) of field relative to the start +of ct, which must be a struct. Additionally returns +the position and the field size (in bits) for bit fields. +

+ +

status = ffi.istype(ct, obj)

+

+Returns true if obj has the C type given by +ct. Returns false otherwise. +

+

+C type qualifiers (const etc.) are ignored. Pointers are +checked with the standard pointer compatibility rules, but without any +special treatment for void *. If ct specifies a +struct/union, then a pointer to this type is accepted, +too. Otherwise the types must match exactly. +

+

+Note: this function accepts all kinds of Lua objects for the +obj argument, but always returns false for non-cdata +objects. +

+ +

Utility Functions

+ +

err = ffi.errno([newerr])

+

+Returns the error number set by the last C function call which +indicated an error condition. If the optional newerr argument +is present, the error number is set to the new value and the previous +value is returned. +

+

+This function offers a portable and OS-independent way to get and set the +error number. Note that only some C functions set the error +number. And it's only significant if the function actually indicated an +error condition (e.g. with a return value of -1 or +NULL). Otherwise, it may or may not contain any previously set +value. +

+

+You're advised to call this function only when needed and as close as +possible after the return of the related C function. The +errno value is preserved across hooks, memory allocations, +invocations of the JIT compiler and other internal VM activity. The same +applies to the value returned by GetLastError() on Windows, but +you need to declare and call it yourself. +

+ +

str = ffi.string(ptr [,len])

+

+Creates an interned Lua string from the data pointed to by +ptr. +

+

+If the optional argument len is missing, ptr is +converted to a "char *" and the data is assumed to be +zero-terminated. The length of the string is computed with +strlen(). +

+

+Otherwise ptr is converted to a "void *" and +len gives the length of the data. The data may contain +embedded zeros and need not be byte-oriented (though this may cause +endianess issues). +

+

+This function is mainly useful to convert (temporary) +"const char *" pointers returned by +C functions to Lua strings and store them or pass them to other +functions expecting a Lua string. The Lua string is an (interned) copy +of the data and bears no relation to the original data area anymore. +Lua strings are 8 bit clean and may be used to hold arbitrary, +non-character data. +

+

+Performance notice: it's faster to pass the length of the string, if +it's known. E.g. when the length is returned by a C call like +sprintf(). +

+ +

ffi.copy(dst, src, len)
+ffi.copy(dst, str)

+

+Copies the data pointed to by src to dst. +dst is converted to a "void *" and src +is converted to a "const void *". +

+

+In the first syntax, len gives the number of bytes to copy. +Caveat: if src is a Lua string, then len must not +exceed #src+1. +

+

+In the second syntax, the source of the copy must be a Lua string. All +bytes of the string plus a zero-terminator are copied to +dst (i.e. #src+1 bytes). +

+

+Performance notice: ffi.copy() may be used as a faster +(inlinable) replacement for the C library functions +memcpy(), strcpy() and strncpy(). +

+ +

ffi.fill(dst, len [,c])

+

+Fills the data pointed to by dst with len constant +bytes, given by c. If c is omitted, the data is +zero-filled. +

+

+Performance notice: ffi.fill() may be used as a faster +(inlinable) replacement for the C library function +memset(dst, c, len). Please note the different +order of arguments! +

+ +

Target-specific Information

+ +

status = ffi.abi(param)

+

+Returns true if param (a Lua string) applies for the +target ABI (Application Binary Interface). Returns false +otherwise. The following parameters are currently defined: +

+ + + + + + + + + + + + + + + + + + + + + + + +
ParameterDescription
32bit32 bit architecture
64bit64 bit architecture
leLittle-endian architecture
beBig-endian architecture
fpuTarget has a hardware FPU
softfpsoftfp calling conventions
hardfphardfp calling conventions
eabiEABI variant of the standard ABI
winWindows variant of the standard ABI
+ +

ffi.os

+

+Contains the target OS name. Same contents as +jit.os. +

+ +

ffi.arch

+

+Contains the target architecture name. Same contents as +jit.arch. +

+ +

Methods for Callbacks

+

+The C types for callbacks +have some extra methods: +

+ +

cb:free()

+

+Free the resources associated with a callback. The associated Lua +function is unanchored and may be garbage collected. The callback +function pointer is no longer valid and must not be called anymore +(it may be reused by a subsequently created callback). +

+ +

cb:set(func)

+

+Associate a new Lua function with a callback. The C type of the +callback and the callback function pointer are unchanged. +

+

+This method is useful to dynamically switch the receiver of callbacks +without creating a new callback each time and registering it again (e.g. +with a GUI library). +

+ +

Extended Standard Library Functions

+

+The following standard library functions have been extended to work +with cdata objects: +

+ +

n = tonumber(cdata)

+

+Converts a number cdata object to a double and returns it as +a Lua number. This is particularly useful for boxed 64 bit +integer values. Caveat: this conversion may incur a precision loss. +

+ +

s = tostring(cdata)

+

+Returns a string representation of the value of 64 bit integers +("nnnLL" or "nnnULL") or +complex numbers ("re±imi"). Otherwise +returns a string representation of the C type of a ctype object +("ctype<type>") or a cdata object +("cdata<type>: address"), unless you +override it with a __tostring metamethod (see +ffi.metatype()). +

+ +

iter, obj, start = pairs(cdata)
+iter, obj, start = ipairs(cdata)

+

+Calls the __pairs or __ipairs metamethod of the +corresponding ctype. +

+ +

Extensions to the Lua Parser

+

+The parser for Lua source code treats numeric literals with the +suffixes LL or ULL as signed or unsigned 64 bit +integers. Case doesn't matter, but uppercase is recommended for +readability. It handles both decimal (42LL) and hexadecimal +(0x2aLL) literals. +

+

+The imaginary part of complex numbers can be specified by suffixing +number literals with i or I, e.g. 12.5i. +Caveat: you'll need to use 1i to get an imaginary part with +the value one, since i itself still refers to a variable +named i. +

+
+
+ + + + +``` + +`include/luajit-2.0.5/doc/ext_ffi_semantics.html`: + +```html + + + +FFI Semantics + + + + + + + + + +
+Lua +
+ + +
+

+This page describes the detailed semantics underlying the FFI library +and its interaction with both Lua and C code. +

+

+Given that the FFI library is designed to interface with C code +and that declarations can be written in plain C syntax, it +closely follows the C language semantics, wherever possible. +Some minor concessions are needed for smoother interoperation with Lua +language semantics. +

+

+Please don't be overwhelmed by the contents of this page — this +is a reference and you may need to consult it, if in doubt. It doesn't +hurt to skim this page, but most of the semantics "just work" as you'd +expect them to work. It should be straightforward to write +applications using the LuaJIT FFI for developers with a C or C++ +background. +

+ +

C Language Support

+

+The FFI library has a built-in C parser with a minimal memory +footprint. It's used by the ffi.* library +functions to declare C types or external symbols. +

+

+It's only purpose is to parse C declarations, as found e.g. in +C header files. Although it does evaluate constant expressions, +it's not a C compiler. The body of inline +C function definitions is simply ignored. +

+

+Also, this is not a validating C parser. It expects and +accepts correctly formed C declarations, but it may choose to +ignore bad declarations or show rather generic error messages. If in +doubt, please check the input against your favorite C compiler. +

+

+The C parser complies to the C99 language standard plus +the following extensions: +

+
    + +
  • The '\e' escape in character and string literals.
  • + +
  • The C99/C++ boolean type, declared with the keywords bool +or _Bool.
  • + +
  • Complex numbers, declared with the keywords complex or +_Complex.
  • + +
  • Two complex number types: complex (aka +complex double) and complex float.
  • + +
  • Vector types, declared with the GCC mode or +vector_size attribute.
  • + +
  • Unnamed ('transparent') struct/union fields +inside a struct/union.
  • + +
  • Incomplete enum declarations, handled like incomplete +struct declarations.
  • + +
  • Unnamed enum fields inside a +struct/union. This is similar to a scoped C++ +enum, except that declared constants are visible in the +global namespace, too.
  • + +
  • Scoped static const declarations inside a +struct/union (from C++).
  • + +
  • Zero-length arrays ([0]), empty +struct/union, variable-length arrays (VLA, +[?]) and variable-length structs (VLS, with a trailing +VLA).
  • + +
  • C++ reference types (int &x).
  • + +
  • Alternate GCC keywords with '__', e.g. +__const__.
  • + +
  • GCC __attribute__ with the following attributes: +aligned, packed, mode, +vector_size, cdecl, fastcall, +stdcall, thiscall.
  • + +
  • The GCC __extension__ keyword and the GCC +__alignof__ operator.
  • + +
  • GCC __asm__("symname") symbol name redirection for +function declarations.
  • + +
  • MSVC keywords for fixed-length types: __int8, +__int16, __int32 and __int64.
  • + +
  • MSVC __cdecl, __fastcall, __stdcall, +__thiscall, __ptr32, __ptr64, +__declspec(align(n)) and #pragma pack.
  • + +
  • All other GCC/MSVC-specific attributes are ignored.
  • + +
+

+The following C types are pre-defined by the C parser (like +a typedef, except re-declarations will be ignored): +

+
    + +
  • Vararg handling: va_list, __builtin_va_list, +__gnuc_va_list.
  • + +
  • From <stddef.h>: ptrdiff_t, +size_t, wchar_t.
  • + +
  • From <stdint.h>: int8_t, int16_t, +int32_t, int64_t, uint8_t, +uint16_t, uint32_t, uint64_t, +intptr_t, uintptr_t.
  • + +
+

+You're encouraged to use these types in preference to +compiler-specific extensions or target-dependent standard types. +E.g. char differs in signedness and long differs in +size, depending on the target architecture and platform ABI. +

+

+The following C features are not supported: +

+
    + +
  • A declaration must always have a type specifier; it doesn't +default to an int type.
  • + +
  • Old-style empty function declarations (K&R) are not allowed. +All C functions must have a proper prototype declaration. A +function declared without parameters (int foo();) is +treated as a function taking zero arguments, like in C++.
  • + +
  • The long double C type is parsed correctly, but +there's no support for the related conversions, accesses or arithmetic +operations.
  • + +
  • Wide character strings and character literals are not +supported.
  • + +
  • See below for features that are currently +not implemented.
  • + +
+ +

C Type Conversion Rules

+ +

Conversions from C types to Lua objects

+

+These conversion rules apply for read accesses to +C types: indexing pointers, arrays or +struct/union types; reading external variables or +constant values; retrieving return values from C calls: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
InputConversionOutput
int8_t, int16_tsign-ext int32_tdoublenumber
uint8_t, uint16_tzero-ext int32_tdoublenumber
int32_t, uint32_tdoublenumber
int64_t, uint64_tboxed value64 bit int cdata
double, floatdoublenumber
bool0 → false, otherwise trueboolean
enumboxed valueenum cdata
Complex numberboxed valuecomplex cdata
Vectorboxed valuevector cdata
Pointerboxed valuepointer cdata
Arrayboxed referencereference cdata
struct/unionboxed referencereference cdata
+

+Bitfields are treated like their underlying type. +

+

+Reference types are dereferenced before a conversion can take +place — the conversion is applied to the C type pointed to +by the reference. +

+ +

Conversions from Lua objects to C types

+

+These conversion rules apply for write accesses to +C types: indexing pointers, arrays or +struct/union types; initializing cdata objects; +casts to C types; writing to external variables; passing +arguments to C calls: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
InputConversionOutput
numberdouble
booleanfalse → 0, true → 1bool
nilNULL(void *)
lightuserdatalightuserdata address →(void *)
userdatauserdata payload →(void *)
io.* fileget FILE * handle →(void *)
stringmatch against enum constantenum
stringcopy string data + zero-byteint8_t[], uint8_t[]
stringstring data →const char[]
functioncreate callbackC function type
tabletable initializerArray
tabletable initializerstruct/union
cdatacdata payload →C type
+

+If the result type of this conversion doesn't match the +C type of the destination, the +conversion rules between C types +are applied. +

+

+Reference types are immutable after initialization ("no re-seating of +references"). For initialization purposes or when passing values to +reference parameters, they are treated like pointers. Note that unlike +in C++, there's no way to implement automatic reference generation of +variables under the Lua language semantics. If you want to call a +function with a reference parameter, you need to explicitly pass a +one-element array. +

+ +

Conversions between C types

+

+These conversion rules are more or less the same as the standard +C conversion rules. Some rules only apply to casts, or require +pointer or type compatibility: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
InputConversionOutput
Signed integernarrow or sign-extendInteger
Unsigned integernarrow or zero-extendInteger
Integerrounddouble, float
double, floattrunc int32_tnarrow(u)int8_t, (u)int16_t
double, floattrunc(u)int32_t, (u)int64_t
double, floatroundfloat, double
Numbern == 0 → 0, otherwise 1bool
boolfalse → 0, true → 1Number
Complex numberconvert real partNumber
Numberconvert real part, imag = 0Complex number
Complex numberconvert real and imag partComplex number
Numberconvert scalar and replicateVector
Vectorcopy (same size)Vector
struct/uniontake base address (compat)Pointer
Arraytake base address (compat)Pointer
Functiontake function addressFunction pointer
Numberconvert via uintptr_t (cast)Pointer
Pointerconvert address (compat/cast)Pointer
Pointerconvert address (cast)Integer
Arrayconvert base address (cast)Integer
Arraycopy (compat)Array
struct/unioncopy (identical type)struct/union
+

+Bitfields or enum types are treated like their underlying +type. +

+

+Conversions not listed above will raise an error. E.g. it's not +possible to convert a pointer to a complex number or vice versa. +

+ +

Conversions for vararg C function arguments

+

+The following default conversion rules apply when passing Lua objects +to the variable argument part of vararg C functions: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
InputConversionOutput
numberdouble
booleanfalse → 0, true → 1bool
nilNULL(void *)
userdatauserdata payload →(void *)
lightuserdatalightuserdata address →(void *)
stringstring data →const char *
float cdatadouble
Array cdatatake base addressElement pointer
struct/union cdatatake base addressstruct/union pointer
Function cdatatake function addressFunction pointer
Any other cdatano conversionC type
+

+To pass a Lua object, other than a cdata object, as a specific type, +you need to override the conversion rules: create a temporary cdata +object with a constructor or a cast and initialize it with the value +to pass: +

+

+Assuming x is a Lua number, here's how to pass it as an +integer to a vararg function: +

+
+ffi.cdef[[
+int printf(const char *fmt, ...);
+]]
+ffi.C.printf("integer value: %d\n", ffi.new("int", x))
+
+

+If you don't do this, the default Lua number → double +conversion rule applies. A vararg C function expecting an integer +will see a garbled or uninitialized value. +

+ +

Initializers

+

+Creating a cdata object with +ffi.new() or the +equivalent constructor syntax always initializes its contents, too. +Different rules apply, depending on the number of optional +initializers and the C types involved: +

+
    +
  • If no initializers are given, the object is filled with zero bytes.
  • + +
  • Scalar types (numbers and pointers) accept a single initializer. +The Lua object is converted to the scalar +C type.
  • + +
  • Valarrays (complex numbers and vectors) are treated like scalars +when a single initializer is given. Otherwise they are treated like +regular arrays.
  • + +
  • Aggregate types (arrays and structs) accept either a single cdata +initializer of the same type (copy constructor), a single +table initializer, or a flat list of +initializers.
  • + +
  • The elements of an array are initialized, starting at index zero. +If a single initializer is given for an array, it's repeated for all +remaining elements. This doesn't happen if two or more initializers +are given: all remaining uninitialized elements are filled with zero +bytes.
  • + +
  • Byte arrays may also be initialized with a Lua string. This copies +the whole string plus a terminating zero-byte. The copy stops early only +if the array has a known, fixed size.
  • + +
  • The fields of a struct are initialized in the order of +their declaration. Uninitialized fields are filled with zero +bytes.
  • + +
  • Only the first field of a union can be initialized with a +flat initializer.
  • + +
  • Elements or fields which are aggregates themselves are initialized +with a single initializer, but this may be a table +initializer or a compatible aggregate.
  • + +
  • Excess initializers cause an error.
  • + +
+ +

Table Initializers

+

+The following rules apply if a Lua table is used to initialize an +Array or a struct/union: +

+
    + +
  • If the table index [0] is non-nil, then the +table is assumed to be zero-based. Otherwise it's assumed to be +one-based.
  • + +
  • Array elements, starting at index zero, are initialized one-by-one +with the consecutive table elements, starting at either index +[0] or [1]. This process stops at the first +nil table element.
  • + +
  • If exactly one array element was initialized, it's repeated for +all the remaining elements. Otherwise all remaining uninitialized +elements are filled with zero bytes.
  • + +
  • The above logic only applies to arrays with a known fixed size. +A VLA is only initialized with the element(s) given in the table. +Depending on the use case, you may need to explicitly add a +NULL or 0 terminator to a VLA.
  • + +
  • A struct/union can be initialized in the +order of the declaration of its fields. Each field is initialized with +consecutive table elements, starting at either index [0] +or [1]. This process stops at the first nil table +element.
  • + +
  • Otherwise, if neither index [0] nor [1] is present, +a struct/union is initialized by looking up each field +name (as a string key) in the table. Each non-nil value is +used to initialize the corresponding field.
  • + +
  • Uninitialized fields of a struct are filled with zero +bytes, except for the trailing VLA of a VLS.
  • + +
  • Initialization of a union stops after one field has been +initialized. If no field has been initialized, the union is +filled with zero bytes.
  • + +
  • Elements or fields which are aggregates themselves are initialized +with a single initializer, but this may be a nested table +initializer (or a compatible aggregate).
  • + +
  • Excess initializers for an array cause an error. Excess +initializers for a struct/union are ignored. +Unrelated table entries are ignored, too.
  • + +
+

+Example: +

+
+local ffi = require("ffi")
+
+ffi.cdef[[
+struct foo { int a, b; };
+union bar { int i; double d; };
+struct nested { int x; struct foo y; };
+]]
+
+ffi.new("int[3]", {})            --> 0, 0, 0
+ffi.new("int[3]", {1})           --> 1, 1, 1
+ffi.new("int[3]", {1,2})         --> 1, 2, 0
+ffi.new("int[3]", {1,2,3})       --> 1, 2, 3
+ffi.new("int[3]", {[0]=1})       --> 1, 1, 1
+ffi.new("int[3]", {[0]=1,2})     --> 1, 2, 0
+ffi.new("int[3]", {[0]=1,2,3})   --> 1, 2, 3
+ffi.new("int[3]", {[0]=1,2,3,4}) --> error: too many initializers
+
+ffi.new("struct foo", {})            --> a = 0, b = 0
+ffi.new("struct foo", {1})           --> a = 1, b = 0
+ffi.new("struct foo", {1,2})         --> a = 1, b = 2
+ffi.new("struct foo", {[0]=1,2})     --> a = 1, b = 2
+ffi.new("struct foo", {b=2})         --> a = 0, b = 2
+ffi.new("struct foo", {a=1,b=2,c=3}) --> a = 1, b = 2  'c' is ignored
+
+ffi.new("union bar", {})        --> i = 0, d = 0.0
+ffi.new("union bar", {1})       --> i = 1, d = ?
+ffi.new("union bar", {[0]=1,2}) --> i = 1, d = ?    '2' is ignored
+ffi.new("union bar", {d=2})     --> i = ?, d = 2.0
+
+ffi.new("struct nested", {1,{2,3}})     --> x = 1, y.a = 2, y.b = 3
+ffi.new("struct nested", {x=1,y={2,3}}) --> x = 1, y.a = 2, y.b = 3
+
+ +

Operations on cdata Objects

+

+All of the standard Lua operators can be applied to cdata objects or a +mix of a cdata object and another Lua object. The following list shows +the pre-defined operations. +

+

+Reference types are dereferenced before performing each of +the operations below — the operation is applied to the +C type pointed to by the reference. +

+

+The pre-defined operations are always tried first before deferring to a +metamethod or index table (if any) for the corresponding ctype (except +for __new). An error is raised if the metamethod lookup or +index table lookup fails. +

+ +

Indexing a cdata object

+
    + +
  • Indexing a pointer/array: a cdata pointer/array can be +indexed by a cdata number or a Lua number. The element address is +computed as the base address plus the number value multiplied by the +element size in bytes. A read access loads the element value and +converts it to a Lua object. A write +access converts a Lua object to the element +type and stores the converted value to the element. An error is +raised if the element size is undefined or a write access to a +constant element is attempted.
  • + +
  • Dereferencing a struct/union field: a +cdata struct/union or a pointer to a +struct/union can be dereferenced by a string key, +giving the field name. The field address is computed as the base +address plus the relative offset of the field. A read access loads the +field value and converts it to a Lua +object. A write access converts a Lua +object to the field type and stores the converted value to the +field. An error is raised if a write access to a constant +struct/union or a constant field is attempted. +Scoped enum constants or static constants are treated like a constant +field.
  • + +
  • Indexing a complex number: a complex number can be indexed +either by a cdata number or a Lua number with the values 0 or 1, or by +the strings "re" or "im". A read access loads the +real part ([0], .re) or the imaginary part +([1], .im) part of a complex number and +converts it to a Lua number. The +sub-parts of a complex number are immutable — assigning to an +index of a complex number raises an error. Accessing out-of-bound +indexes returns unspecified results, but is guaranteed not to trigger +memory access violations.
  • + +
  • Indexing a vector: a vector is treated like an array for +indexing purposes, except the vector elements are immutable — +assigning to an index of a vector raises an error.
  • + +
+

+A ctype object can be indexed with a string key, too. The only +pre-defined operation is reading scoped constants of +struct/union types. All other accesses defer +to the corresponding metamethods or index tables (if any). +

+

+Note: since there's (deliberately) no address-of operator, a cdata +object holding a value type is effectively immutable after +initialization. The JIT compiler benefits from this fact when applying +certain optimizations. +

+

+As a consequence, the elements of complex numbers and +vectors are immutable. But the elements of an aggregate holding these +types may be modified of course. I.e. you cannot assign to +foo.c.im, but you can assign a (newly created) complex number +to foo.c. +

+

+The JIT compiler implements strict aliasing rules: accesses to different +types do not alias, except for differences in signedness (this +applies even to char pointers, unlike C99). Type punning +through unions is explicitly detected and allowed. +

+ +

Calling a cdata object

+
    + +
  • Constructor: a ctype object can be called and used as a +constructor. This is equivalent +to ffi.new(ct, ...), unless a __new metamethod is +defined. The __new metamethod is called with the ctype object +plus any other arguments passed to the contructor. Note that you have to +use ffi.new inside of it, since calling ct(...) would +cause infinite recursion.
  • + +
  • C function call: a cdata function or cdata function +pointer can be called. The passed arguments are +converted to the C types of the +parameters given by the function declaration. Arguments passed to the +variable argument part of vararg C function use +special conversion rules. This +C function is called and the return value (if any) is +converted to a Lua object.
    +On Windows/x86 systems, __stdcall functions are automatically +detected and a function declared as __cdecl (the default) is +silently fixed up after the first call.
  • + +
+ +

Arithmetic on cdata objects

+
    + +
  • Pointer arithmetic: a cdata pointer/array and a cdata +number or a Lua number can be added or subtracted. The number must be +on the right hand side for a subtraction. The result is a pointer of +the same type with an address plus or minus the number value +multiplied by the element size in bytes. An error is raised if the +element size is undefined.
  • + +
  • Pointer difference: two compatible cdata pointers/arrays +can be subtracted. The result is the difference between their +addresses, divided by the element size in bytes. An error is raised if +the element size is undefined or zero.
  • + +
  • 64 bit integer arithmetic: the standard arithmetic +operators (+ - * / % ^ and unary +minus) can be applied to two cdata numbers, or a cdata number and a +Lua number. If one of them is an uint64_t, the other side is +converted to an uint64_t and an unsigned arithmetic operation +is performed. Otherwise both sides are converted to an +int64_t and a signed arithmetic operation is performed. The +result is a boxed 64 bit cdata object.
    + +If one of the operands is an enum and the other operand is a +string, the string is converted to the value of a matching enum +constant before the above conversion.
    + +These rules ensure that 64 bit integers are "sticky". Any +expression involving at least one 64 bit integer operand results +in another one. The undefined cases for the division, modulo and power +operators return 2LL ^ 63 or +2ULL ^ 63.
    + +You'll have to explicitly convert a 64 bit integer to a Lua +number (e.g. for regular floating-point calculations) with +tonumber(). But note this may incur a precision loss.
  • + +
+ +

Comparisons of cdata objects

+
    + +
  • Pointer comparison: two compatible cdata pointers/arrays +can be compared. The result is the same as an unsigned comparison of +their addresses. nil is treated like a NULL pointer, +which is compatible with any other pointer type.
  • + +
  • 64 bit integer comparison: two cdata numbers, or a +cdata number and a Lua number can be compared with each other. If one +of them is an uint64_t, the other side is converted to an +uint64_t and an unsigned comparison is performed. Otherwise +both sides are converted to an int64_t and a signed +comparison is performed.
    + +If one of the operands is an enum and the other operand is a +string, the string is converted to the value of a matching enum +constant before the above conversion.
    + +
  • Comparisons for equality/inequality never raise an error. +Even incompatible pointers can be compared for equality by address. Any +other incompatible comparison (also with non-cdata objects) treats the +two sides as unequal.
  • + +
+ +

cdata objects as table keys

+

+Lua tables may be indexed by cdata objects, but this doesn't provide +any useful semantics — cdata objects are unsuitable as table +keys! +

+

+A cdata object is treated like any other garbage-collected object and +is hashed and compared by its address for table indexing. Since +there's no interning for cdata value types, the same value may be +boxed in different cdata objects with different addresses. Thus +t[1LL+1LL] and t[2LL] usually do not point to +the same hash slot and they certainly do not point to the same +hash slot as t[2]. +

+

+It would seriously drive up implementation complexity and slow down +the common case, if one were to add extra handling for by-value +hashing and comparisons to Lua tables. Given the ubiquity of their use +inside the VM, this is not acceptable. +

+

+There are three viable alternatives, if you really need to use cdata +objects as keys: +

+
    + +
  • If you can get by with the precision of Lua numbers +(52 bits), then use tonumber() on a cdata number or +combine multiple fields of a cdata aggregate to a Lua number. Then use +the resulting Lua number as a key when indexing tables.
    +One obvious benefit: t[tonumber(2LL)] does point to +the same slot as t[2].
  • + +
  • Otherwise use either tostring() on 64 bit integers +or complex numbers or combine multiple fields of a cdata aggregate to +a Lua string (e.g. with +ffi.string()). Then +use the resulting Lua string as a key when indexing tables.
  • + +
  • Create your own specialized hash table implementation using the +C types provided by the FFI library, just like you would in +C code. Ultimately this may give much better performance than the +other alternatives or what a generic by-value hash table could +possibly provide.
  • + +
+ +

Parameterized Types

+

+To facilitate some abstractions, the two functions +ffi.typeof and +ffi.cdef support +parameterized types in C declarations. Note: none of the other API +functions taking a cdecl allow this. +

+

+Any place you can write a typedef name, an +identifier or a number in a declaration, you can write +$ (the dollar sign) instead. These placeholders are replaced in +order of appearance with the arguments following the cdecl string: +

+
+-- Declare a struct with a parameterized field type and name:
+ffi.cdef([[
+typedef struct { $ $; } foo_t;
+]], type1, name1)
+
+-- Anonymous struct with dynamic names:
+local bar_t = ffi.typeof("struct { int $, $; }", name1, name2)
+-- Derived pointer type:
+local bar_ptr_t = ffi.typeof("$ *", bar_t)
+
+-- Parameterized dimensions work even where a VLA won't work:
+local matrix_t = ffi.typeof("uint8_t[$][$]", width, height)
+
+

+Caveat: this is not simple text substitution! A passed ctype or +cdata object is treated like the underlying type, a passed string is +considered an identifier and a number is considered a number. You must +not mix this up: e.g. passing "int" as a string doesn't work in +place of a type, you'd need to use ffi.typeof("int") instead. +

+

+The main use for parameterized types are libraries implementing abstract +data types +(» example), +similar to what can be achieved with C++ template metaprogramming. +Another use case are derived types of anonymous structs, which avoids +pollution of the global struct namespace. +

+

+Please note that parameterized types are a nice tool and indispensable +for certain use cases. But you'll want to use them sparingly in regular +code, e.g. when all types are actually fixed. +

+ +

Garbage Collection of cdata Objects

+

+All explicitly (ffi.new(), ffi.cast() etc.) or +implicitly (accessors) created cdata objects are garbage collected. +You need to ensure to retain valid references to cdata objects +somewhere on a Lua stack, an upvalue or in a Lua table while they are +still in use. Once the last reference to a cdata object is gone, the +garbage collector will automatically free the memory used by it (at +the end of the next GC cycle). +

+

+Please note that pointers themselves are cdata objects, however they +are not followed by the garbage collector. So e.g. if you +assign a cdata array to a pointer, you must keep the cdata object +holding the array alive as long as the pointer is still in use: +

+
+ffi.cdef[[
+typedef struct { int *a; } foo_t;
+]]
+
+local s = ffi.new("foo_t", ffi.new("int[10]")) -- WRONG!
+
+local a = ffi.new("int[10]") -- OK
+local s = ffi.new("foo_t", a)
+-- Now do something with 's', but keep 'a' alive until you're done.
+
+

+Similar rules apply for Lua strings which are implicitly converted to +"const char *": the string object itself must be +referenced somewhere or it'll be garbage collected eventually. The +pointer will then point to stale data, which may have already been +overwritten. Note that string literals are automatically kept +alive as long as the function containing it (actually its prototype) +is not garbage collected. +

+

+Objects which are passed as an argument to an external C function +are kept alive until the call returns. So it's generally safe to +create temporary cdata objects in argument lists. This is a common +idiom for passing specific C types to +vararg functions. +

+

+Memory areas returned by C functions (e.g. from malloc()) +must be manually managed, of course (or use +ffi.gc()). Pointers to +cdata objects are indistinguishable from pointers returned by C +functions (which is one of the reasons why the GC cannot follow them). +

+ +

Callbacks

+

+The LuaJIT FFI automatically generates special callback functions +whenever a Lua function is converted to a C function pointer. This +associates the generated callback function pointer with the C type +of the function pointer and the Lua function object (closure). +

+

+This can happen implicitly due to the usual conversions, e.g. when +passing a Lua function to a function pointer argument. Or you can use +ffi.cast() to explicitly cast a Lua function to a +C function pointer. +

+

+Currently only certain C function types can be used as callback +functions. Neither C vararg functions nor functions with +pass-by-value aggregate argument or result types are supported. There +are no restrictions for the kind of Lua functions that can be called +from the callback — no checks for the proper number of arguments +are made. The return value of the Lua function will be converted to the +result type and an error will be thrown for invalid conversions. +

+

+It's allowed to throw errors across a callback invocation, but it's not +advisable in general. Do this only if you know the C function, that +called the callback, copes with the forced stack unwinding and doesn't +leak resources. +

+

+One thing that's not allowed, is to let an FFI call into a C function +get JIT-compiled, which in turn calls a callback, calling into Lua again. +Usually this attempt is caught by the interpreter first and the +C function is blacklisted for compilation. +

+

+However, this heuristic may fail under specific circumstances: e.g. a +message polling function might not run Lua callbacks right away and the call +gets JIT-compiled. If it later happens to call back into Lua (e.g. a rarely +invoked error callback), you'll get a VM PANIC with the message +"bad callback". Then you'll need to manually turn off +JIT-compilation with +jit.off() for the +surrounding Lua function that invokes such a message polling function (or +similar). +

+ +

Callback resource handling

+

+Callbacks take up resources — you can only have a limited number +of them at the same time (500 - 1000, depending on the +architecture). The associated Lua functions are anchored to prevent +garbage collection, too. +

+

+Callbacks due to implicit conversions are permanent! There is no +way to guess their lifetime, since the C side might store the +function pointer for later use (typical for GUI toolkits). The associated +resources cannot be reclaimed until termination: +

+
+ffi.cdef[[
+typedef int (__stdcall *WNDENUMPROC)(void *hwnd, intptr_t l);
+int EnumWindows(WNDENUMPROC func, intptr_t l);
+]]
+
+-- Implicit conversion to a callback via function pointer argument.
+local count = 0
+ffi.C.EnumWindows(function(hwnd, l)
+  count = count + 1
+  return true
+end, 0)
+-- The callback is permanent and its resources cannot be reclaimed!
+-- Ok, so this may not be a problem, if you do this only once.
+
+

+Note: this example shows that you must properly declare +__stdcall callbacks on Windows/x86 systems. The calling +convention cannot be automatically detected, unlike for +__stdcall calls to Windows functions. +

+

+For some use cases it's necessary to free up the resources or to +dynamically redirect callbacks. Use an explicit cast to a +C function pointer and keep the resulting cdata object. Then use +the cb:free() +or cb:set() methods +on the cdata object: +

+
+-- Explicitly convert to a callback via cast.
+local count = 0
+local cb = ffi.cast("WNDENUMPROC", function(hwnd, l)
+  count = count + 1
+  return true
+end)
+
+-- Pass it to a C function.
+ffi.C.EnumWindows(cb, 0)
+-- EnumWindows doesn't need the callback after it returns, so free it.
+
+cb:free()
+-- The callback function pointer is no longer valid and its resources
+-- will be reclaimed. The created Lua closure will be garbage collected.
+
+ +

Callback performance

+

+Callbacks are slow! First, the C to Lua transition itself +has an unavoidable cost, similar to a lua_call() or +lua_pcall(). Argument and result marshalling add to that cost. +And finally, neither the C compiler nor LuaJIT can inline or +optimize across the language barrier and hoist repeated computations out +of a callback function. +

+

+Do not use callbacks for performance-sensitive work: e.g. consider a +numerical integration routine which takes a user-defined function to +integrate over. It's a bad idea to call a user-defined Lua function from +C code millions of times. The callback overhead will be absolutely +detrimental for performance. +

+

+It's considerably faster to write the numerical integration routine +itself in Lua — the JIT compiler will be able to inline the +user-defined function and optimize it together with its calling context, +with very competitive performance. +

+

+As a general guideline: use callbacks only when you must, because +of existing C APIs. E.g. callback performance is irrelevant for a +GUI application, which waits for user input most of the time, anyway. +

+

+For new designs avoid push-style APIs: a C function repeatedly +calling a callback for each result. Instead use pull-style APIs: +call a C function repeatedly to get a new result. Calls from Lua +to C via the FFI are much faster than the other way round. Most well-designed +libraries already use pull-style APIs (read/write, get/put). +

+ +

C Library Namespaces

+

+A C library namespace is a special kind of object which allows +access to the symbols contained in shared libraries or the default +symbol namespace. The default +ffi.C namespace is +automatically created when the FFI library is loaded. C library +namespaces for specific shared libraries may be created with the +ffi.load() API +function. +

+

+Indexing a C library namespace object with a symbol name (a Lua +string) automatically binds it to the library. First the symbol type +is resolved — it must have been declared with +ffi.cdef. Then the +symbol address is resolved by searching for the symbol name in the +associated shared libraries or the default symbol namespace. Finally, +the resulting binding between the symbol name, the symbol type and its +address is cached. Missing symbol declarations or nonexistent symbol +names cause an error. +

+

+This is what happens on a read access for the different kinds of +symbols: +

+
    + +
  • External functions: a cdata object with the type of the function +and its address is returned.
  • + +
  • External variables: the symbol address is dereferenced and the +loaded value is converted to a Lua object +and returned.
  • + +
  • Constant values (static const or enum +constants): the constant is converted to a +Lua object and returned.
  • + +
+

+This is what happens on a write access: +

+
    + +
  • External variables: the value to be written is +converted to the C type of the +variable and then stored at the symbol address.
  • + +
  • Writing to constant variables or to any other symbol type causes +an error, like any other attempted write to a constant location.
  • + +
+

+C library namespaces themselves are garbage collected objects. If +the last reference to the namespace object is gone, the garbage +collector will eventually release the shared library reference and +remove all memory associated with the namespace. Since this may +trigger the removal of the shared library from the memory of the +running process, it's generally not safe to use function +cdata objects obtained from a library if the namespace object may be +unreferenced. +

+

+Performance notice: the JIT compiler specializes to the identity of +namespace objects and to the strings used to index it. This +effectively turns function cdata objects into constants. It's not +useful and actually counter-productive to explicitly cache these +function objects, e.g. local strlen = ffi.C.strlen. OTOH it +is useful to cache the namespace itself, e.g. local C = +ffi.C. +

+ +

No Hand-holding!

+

+The FFI library has been designed as a low-level library. The +goal is to interface with C code and C data types with a +minimum of overhead. This means you can do anything you can do +from C: access all memory, overwrite anything in memory, call +machine code at any memory address and so on. +

+

+The FFI library provides no memory safety, unlike regular Lua +code. It will happily allow you to dereference a NULL +pointer, to access arrays out of bounds or to misdeclare +C functions. If you make a mistake, your application might crash, +just like equivalent C code would. +

+

+This behavior is inevitable, since the goal is to provide full +interoperability with C code. Adding extra safety measures, like +bounds checks, would be futile. There's no way to detect +misdeclarations of C functions, since shared libraries only +provide symbol names, but no type information. Likewise there's no way +to infer the valid range of indexes for a returned pointer. +

+

+Again: the FFI library is a low-level library. This implies it needs +to be used with care, but it's flexibility and performance often +outweigh this concern. If you're a C or C++ developer, it'll be easy +to apply your existing knowledge. OTOH writing code for the FFI +library is not for the faint of heart and probably shouldn't be the +first exercise for someone with little experience in Lua, C or C++. +

+

+As a corollary of the above, the FFI library is not safe for use by +untrusted Lua code. If you're sandboxing untrusted Lua code, you +definitely don't want to give this code access to the FFI library or +to any cdata object (except 64 bit integers or complex +numbers). Any properly engineered Lua sandbox needs to provide safety +wrappers for many of the standard Lua library functions — +similar wrappers need to be written for high-level operations on FFI +data types, too. +

+ +

Current Status

+

+The initial release of the FFI library has some limitations and is +missing some features. Most of these will be fixed in future releases. +

+

+C language support is +currently incomplete: +

+
    +
  • C declarations are not passed through a C pre-processor, +yet.
  • +
  • The C parser is able to evaluate most constant expressions +commonly found in C header files. However it doesn't handle the +full range of C expression semantics and may fail for some +obscure constructs.
  • +
  • static const declarations only work for integer types +up to 32 bits. Neither declaring string constants nor +floating-point constants is supported.
  • +
  • Packed struct bitfields that cross container boundaries +are not implemented.
  • +
  • Native vector types may be defined with the GCC mode or +vector_size attribute. But no operations other than loading, +storing and initializing them are supported, yet.
  • +
  • The volatile type qualifier is currently ignored by +compiled code.
  • +
  • ffi.cdef silently +ignores most re-declarations. Note: avoid re-declarations which do not +conform to C99. The implementation will eventually be changed to +perform strict checks.
  • +
+

+The JIT compiler already handles a large subset of all FFI operations. +It automatically falls back to the interpreter for unimplemented +operations (you can check for this with the +-jv command line option). +The following operations are currently not compiled and may exhibit +suboptimal performance, especially when used in inner loops: +

+
    +
  • Bitfield accesses and initializations.
  • +
  • Vector operations.
  • +
  • Table initializers.
  • +
  • Initialization of nested struct/union types.
  • +
  • Allocations of variable-length arrays or structs.
  • +
  • Allocations of C types with a size > 128 bytes or an +alignment > 8 bytes.
  • +
  • Conversions from lightuserdata to void *.
  • +
  • Pointer differences for element sizes that are not a power of +two.
  • +
  • Calls to C functions with aggregates passed or returned by +value.
  • +
  • Calls to ctype metamethods which are not plain functions.
  • +
  • ctype __newindex tables and non-string lookups in ctype +__index tables.
  • +
  • tostring() for cdata types.
  • +
  • Calls to ffi.cdef(), ffi.load() and +ffi.metatype().
  • +
+

+Other missing features: +

+
    +
  • Bit operations for 64 bit types.
  • +
  • Arithmetic for complex numbers.
  • +
  • Passing structs by value to vararg C functions.
  • +
  • C++ exception interoperability +does not extend to C functions called via the FFI, if the call is +compiled.
  • +
+
+
+ + + + +``` + +`include/luajit-2.0.5/doc/ext_ffi_tutorial.html`: + +```html + + + +FFI Tutorial + + + + + + + + + +
+Lua +
+ + +
+

+This page is intended to give you an overview of the features of the FFI +library by presenting a few use cases and guidelines. +

+

+This page makes no attempt to explain all of the FFI library, though. +You'll want to have a look at the ffi.* API +function reference and the FFI +semantics to learn more. +

+ +

Loading the FFI Library

+

+The FFI library is built into LuaJIT by default, but it's not loaded +and initialized by default. The suggested way to use the FFI library +is to add the following to the start of every Lua file that needs one +of its functions: +

+
+local ffi = require("ffi")
+
+

+Please note this doesn't define an ffi variable in the table +of globals — you really need to use the local variable. The +require function ensures the library is only loaded once. +

+

+Note: If you want to experiment with the FFI from the interactive prompt +of the command line executable, omit the local, as it doesn't +preserve local variables across lines. +

+ +

Accessing Standard System Functions

+

+The following code explains how to access standard system functions. +We slowly print two lines of dots by sleeping for 10 milliseconds +after each dot: +

+
+ 
+①
+
+
+
+
+
+②
+③
+④
+
+
+
+⑤
+
+
+
+
+
+⑥local ffi = require("ffi")
+ffi.cdef[[
+void Sleep(int ms);
+int poll(struct pollfd *fds, unsigned long nfds, int timeout);
+]]
+
+local sleep
+if ffi.os == "Windows" then
+  function sleep(s)
+    ffi.C.Sleep(s*1000)
+  end
+else
+  function sleep(s)
+    ffi.C.poll(nil, 0, s*1000)
+  end
+end
+
+for i=1,160 do
+  io.write("."); io.flush()
+  sleep(0.01)
+end
+io.write("\n")
+
+

+Here's the step-by-step explanation: +

+

+ This defines the +C library functions we're going to use. The part inside the +double-brackets (in green) is just standard C syntax. You can +usually get this info from the C header files or the +documentation provided by each C library or C compiler. +

+

+ The difficulty we're +facing here, is that there are different standards to choose from. +Windows has a simple Sleep() function. On other systems there +are a variety of functions available to achieve sub-second sleeps, but +with no clear consensus. Thankfully poll() can be used for +this task, too, and it's present on most non-Windows systems. The +check for ffi.os makes sure we use the Windows-specific +function only on Windows systems. +

+

+ Here we're wrapping the +call to the C function in a Lua function. This isn't strictly +necessary, but it's helpful to deal with system-specific issues only +in one part of the code. The way we're wrapping it ensures the check +for the OS is only done during initialization and not for every call. +

+

+ A more subtle point is +that we defined our sleep() function (for the sake of this +example) as taking the number of seconds, but accepting fractional +seconds. Multiplying this by 1000 gets us milliseconds, but that still +leaves it a Lua number, which is a floating-point value. Alas, the +Sleep() function only accepts an integer value. Luckily for +us, the FFI library automatically performs the conversion when calling +the function (truncating the FP value towards zero, like in C). +

+

+Some readers will notice that Sleep() is part of +KERNEL32.DLL and is also a stdcall function. So how +can this possibly work? The FFI library provides the ffi.C +default C library namespace, which allows calling functions from +the default set of libraries, like a C compiler would. Also, the +FFI library automatically detects stdcall functions, so you +don't need to declare them as such. +

+

+ The poll() +function takes a couple more arguments we're not going to use. You can +simply use nil to pass a NULL pointer and 0 +for the nfds parameter. Please note that the +number 0 does not convert to a pointer value, +unlike in C++. You really have to pass pointers to pointer arguments +and numbers to number arguments. +

+

+The page on FFI semantics has all +of the gory details about +conversions between Lua +objects and C types. For the most part you don't have to deal +with this, as it's performed automatically and it's carefully designed +to bridge the semantic differences between Lua and C. +

+

+ Now that we have defined +our own sleep() function, we can just call it from plain Lua +code. That wasn't so bad, huh? Turning these boring animated dots into +a fascinating best-selling game is left as an exercise for the reader. +:-) +

+ +

Accessing the zlib Compression Library

+

+The following code shows how to access the zlib compression library from Lua code. +We'll define two convenience wrapper functions that take a string and +compress or uncompress it to another string: +

+
+ 
+①
+
+
+
+
+
+
+②
+
+
+③
+
+④
+
+
+⑤
+
+
+⑥
+
+
+
+
+
+
+
+⑦local ffi = require("ffi")
+ffi.cdef[[
+unsigned long compressBound(unsigned long sourceLen);
+int compress2(uint8_t *dest, unsigned long *destLen,
+	      const uint8_t *source, unsigned long sourceLen, int level);
+int uncompress(uint8_t *dest, unsigned long *destLen,
+	       const uint8_t *source, unsigned long sourceLen);
+]]
+local zlib = ffi.load(ffi.os == "Windows" and "zlib1" or "z")
+
+local function compress(txt)
+  local n = zlib.compressBound(#txt)
+  local buf = ffi.new("uint8_t[?]", n)
+  local buflen = ffi.new("unsigned long[1]", n)
+  local res = zlib.compress2(buf, buflen, txt, #txt, 9)
+  assert(res == 0)
+  return ffi.string(buf, buflen[0])
+end
+
+local function uncompress(comp, n)
+  local buf = ffi.new("uint8_t[?]", n)
+  local buflen = ffi.new("unsigned long[1]", n)
+  local res = zlib.uncompress(buf, buflen, comp, #comp)
+  assert(res == 0)
+  return ffi.string(buf, buflen[0])
+end
+
+-- Simple test code.
+local txt = string.rep("abcd", 1000)
+print("Uncompressed size: ", #txt)
+local c = compress(txt)
+print("Compressed size: ", #c)
+local txt2 = uncompress(c, #txt)
+assert(txt2 == txt)
+
+

+Here's the step-by-step explanation: +

+

+ This defines some of the +C functions provided by zlib. For the sake of this example, some +type indirections have been reduced and it uses the pre-defined +fixed-size integer types, while still adhering to the zlib API/ABI. +

+

+ This loads the zlib shared +library. On POSIX systems it's named libz.so and usually +comes pre-installed. Since ffi.load() automatically adds any +missing standard prefixes/suffixes, we can simply load the +"z" library. On Windows it's named zlib1.dll and +you'll have to download it first from the +» zlib site. The check for +ffi.os makes sure we pass the right name to +ffi.load(). +

+

+ First, the maximum size of +the compression buffer is obtained by calling the +zlib.compressBound function with the length of the +uncompressed string. The next line allocates a byte buffer of this +size. The [?] in the type specification indicates a +variable-length array (VLA). The actual number of elements of this +array is given as the 2nd argument to ffi.new(). +

+

+ This may look strange at +first, but have a look at the declaration of the compress2 +function from zlib: the destination length is defined as a pointer! +This is because you pass in the maximum buffer size and get back the +actual length that was used. +

+

+In C you'd pass in the address of a local variable +(&buflen). But since there's no address-of operator in +Lua, we'll just pass in a one-element array. Conveniently it can be +initialized with the maximum buffer size in one step. Calling the +actual zlib.compress2 function is then straightforward. +

+

+ We want to return the +compressed data as a Lua string, so we'll use ffi.string(). +It needs a pointer to the start of the data and the actual length. The +length has been returned in the buflen array, so we'll just +get it from there. +

+

+Note that since the function returns now, the buf and +buflen variables will eventually be garbage collected. This +is fine, because ffi.string() has copied the contents to a +newly created (interned) Lua string. If you plan to call this function +lots of times, consider reusing the buffers and/or handing back the +results in buffers instead of strings. This will reduce the overhead +for garbage collection and string interning. +

+

+ The uncompress +functions does the exact opposite of the compress function. +The compressed data doesn't include the size of the original string, +so this needs to be passed in. Otherwise no surprises here. +

+

+ The code, that makes use +of the functions we just defined, is just plain Lua code. It doesn't +need to know anything about the LuaJIT FFI — the convenience +wrapper functions completely hide it. +

+

+One major advantage of the LuaJIT FFI is that you are now able to +write those wrappers in Lua. And at a fraction of the time it +would cost you to create an extra C module using the Lua/C API. +Many of the simpler C functions can probably be used directly +from your Lua code, without any wrappers. +

+

+Side note: the zlib API uses the long type for passing +lengths and sizes around. But all those zlib functions actually only +deal with 32 bit values. This is an unfortunate choice for a +public API, but may be explained by zlib's history — we'll just +have to deal with it. +

+

+First, you should know that a long is a 64 bit type e.g. +on POSIX/x64 systems, but a 32 bit type on Windows/x64 and on +32 bit systems. Thus a long result can be either a plain +Lua number or a boxed 64 bit integer cdata object, depending on +the target system. +

+

+Ok, so the ffi.* functions generally accept cdata objects +wherever you'd want to use a number. That's why we get a away with +passing n to ffi.string() above. But other Lua +library functions or modules don't know how to deal with this. So for +maximum portability one needs to use tonumber() on returned +long results before passing them on. Otherwise the +application might work on some systems, but would fail in a POSIX/x64 +environment. +

+ +

Defining Metamethods for a C Type

+

+The following code explains how to define metamethods for a C type. +We define a simple point type and add some operations to it: +

+
+ 
+①
+
+
+
+②
+
+③
+
+④
+
+
+
+⑤
+
+⑥local ffi = require("ffi")
+ffi.cdef[[
+typedef struct { double x, y; } point_t;
+]]
+
+local point
+local mt = {
+  __add = function(a, b) return point(a.x+b.x, a.y+b.y) end,
+  __len = function(a) return math.sqrt(a.x*a.x + a.y*a.y) end,
+  __index = {
+    area = function(a) return a.x*a.x + a.y*a.y end,
+  },
+}
+point = ffi.metatype("point_t", mt)
+
+local a = point(3, 4)
+print(a.x, a.y)  --> 3  4
+print(#a)        --> 5
+print(a:area())  --> 25
+local b = a + point(0.5, 8)
+print(#b)        --> 12.5
+
+

+Here's the step-by-step explanation: +

+

+ This defines the C type for a +two-dimensional point object. +

+

+ We have to declare the variable +holding the point constructor first, because it's used inside of a +metamethod. +

+

+ Let's define an __add +metamethod which adds the coordinates of two points and creates a new +point object. For simplicity, this function assumes that both arguments +are points. But it could be any mix of objects, if at least one operand +is of the required type (e.g. adding a point plus a number or vice +versa). Our __len metamethod returns the distance of a point to +the origin. +

+

+ If we run out of operators, we can +define named methods, too. Here the __index table defines an +area function. For custom indexing needs, one might want to +define __index and __newindex functions instead. +

+

+ This associates the metamethods with +our C type. This only needs to be done once. For convenience, a +constructor is returned by +ffi.metatype(). +We're not required to use it, though. The original C type can still +be used e.g. to create an array of points. The metamethods automatically +apply to any and all uses of this type. +

+

+Please note that the association with a metatable is permanent and +the metatable must not be modified afterwards! Ditto for the +__index table. +

+

+ Here are some simple usage examples +for the point type and their expected results. The pre-defined +operations (such as a.x) can be freely mixed with the newly +defined metamethods. Note that area is a method and must be +called with the Lua syntax for methods: a:area(), not +a.area(). +

+

+The C type metamethod mechanism is most useful when used in +conjunction with C libraries that are written in an object-oriented +style. Creators return a pointer to a new instance and methods take an +instance pointer as the first argument. Sometimes you can just point +__index to the library namespace and __gc to the +destructor and you're done. But often enough you'll want to add +convenience wrappers, e.g. to return actual Lua strings or when +returning multiple values. +

+

+Some C libraries only declare instance pointers as an opaque +void * type. In this case you can use a fake type for all +declarations, e.g. a pointer to a named (incomplete) struct will do: +typedef struct foo_type *foo_handle. The C side doesn't +know what you declare with the LuaJIT FFI, but as long as the underlying +types are compatible, everything still works. +

+ +

Translating C Idioms

+

+Here's a list of common C idioms and their translation to the +LuaJIT FFI: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdiomC codeLua code
Pointer dereference
int *p;
x = *p;
*p = y;
x = p[0]
p[0] = y
Pointer indexing
int i, *p;
x = p[i];
p[i+1] = y;
x = p[i]
p[i+1] = y
Array indexing
int i, a[];
x = a[i];
a[i+1] = y;
x = a[i]
a[i+1] = y
struct/union dereference
struct foo s;
x = s.field;
s.field = y;
x = s.field
s.field = y
struct/union pointer deref.
struct foo *sp;
x = sp->field;
sp->field = y;
x = s.field
s.field = y
Pointer arithmetic
int i, *p;
x = p + i;
y = p - i;
x = p + i
y = p - i
Pointer difference
int *p1, *p2;
x = p1 - p2;x = p1 - p2
Array element pointer
int i, a[];
x = &a[i];x = a+i
Cast pointer to address
int *p;
x = (intptr_t)p;x = tonumber(
 ffi.cast("intptr_t",
          p))
Functions with outargs
void foo(int *inoutlen);
int len = x;
foo(&len);
y = len;
local len =
  ffi.new("int[1]", x)
foo(len)
y = len[0]
Vararg conversions
int printf(char *fmt, ...);
printf("%g", 1.0);
printf("%d", 1);
 
printf("%g", 1);
printf("%d",
  ffi.new("int", 1))
+ +

To Cache or Not to Cache

+

+It's a common Lua idiom to cache library functions in local variables +or upvalues, e.g.: +

+
+local byte, char = string.byte, string.char
+local function foo(x)
+  return char(byte(x)+1)
+end
+
+

+This replaces several hash-table lookups with a (faster) direct use of +a local or an upvalue. This is less important with LuaJIT, since the +JIT compiler optimizes hash-table lookups a lot and is even able to +hoist most of them out of the inner loops. It can't eliminate +all of them, though, and it saves some typing for often-used +functions. So there's still a place for this, even with LuaJIT. +

+

+The situation is a bit different with C function calls via the +FFI library. The JIT compiler has special logic to eliminate all +of the lookup overhead for functions resolved from a +C library namespace! +Thus it's not helpful and actually counter-productive to cache +individual C functions like this: +

+
+local funca, funcb = ffi.C.funca, ffi.C.funcb -- Not helpful!
+local function foo(x, n)
+  for i=1,n do funcb(funca(x, i), 1) end
+end
+
+

+This turns them into indirect calls and generates bigger and slower +machine code. Instead you'll want to cache the namespace itself and +rely on the JIT compiler to eliminate the lookups: +

+
+local C = ffi.C          -- Instead use this!
+local function foo(x, n)
+  for i=1,n do C.funcb(C.funca(x, i), 1) end
+end
+
+

+This generates both shorter and faster code. So don't cache +C functions, but do cache namespaces! Most often the +namespace is already in a local variable at an outer scope, e.g. from +local lib = ffi.load(...). Note that copying +it to a local variable in the function scope is unnecessary. +

+
+
+ + + + +``` + +`include/luajit-2.0.5/doc/ext_jit.html`: + +```html + + + +jit.* Library + + + + + + + + +
+Lua +
+ + +
+

+The functions in this built-in module control the behavior of the JIT +compiler engine. Note that JIT-compilation is fully automatic — +you probably won't need to use any of the following functions unless +you have special needs. +

+ +

jit.on()
+jit.off()

+

+Turns the whole JIT compiler on (default) or off. +

+

+These functions are typically used with the command line options +-j on or -j off. +

+ +

jit.flush()

+

+Flushes the whole cache of compiled code. +

+ +

jit.on(func|true [,true|false])
+jit.off(func|true [,true|false])
+jit.flush(func|true [,true|false])

+

+jit.on enables JIT compilation for a Lua function (this is +the default). +

+

+jit.off disables JIT compilation for a Lua function and +flushes any already compiled code from the code cache. +

+

+jit.flush flushes the code, but doesn't affect the +enable/disable status. +

+

+The current function, i.e. the Lua function calling this library +function, can also be specified by passing true as the first +argument. +

+

+If the second argument is true, JIT compilation is also +enabled, disabled or flushed recursively for all sub-functions of a +function. With false only the sub-functions are affected. +

+

+The jit.on and jit.off functions only set a flag +which is checked when the function is about to be compiled. They do +not trigger immediate compilation. +

+

+Typical usage is jit.off(true, true) in the main chunk +of a module to turn off JIT compilation for the whole module for +debugging purposes. +

+ +

jit.flush(tr)

+

+Flushes the root trace, specified by its number, and all of its side +traces from the cache. The code for the trace will be retained as long +as there are any other traces which link to it. +

+ +

status, ... = jit.status()

+

+Returns the current status of the JIT compiler. The first result is +either true or false if the JIT compiler is turned +on or off. The remaining results are strings for CPU-specific features +and enabled optimizations. +

+ +

jit.version

+

+Contains the LuaJIT version string. +

+ +

jit.version_num

+

+Contains the version number of the LuaJIT core. Version xx.yy.zz +is represented by the decimal number xxyyzz. +

+ +

jit.os

+

+Contains the target OS name: +"Windows", "Linux", "OSX", "BSD", "POSIX" or "Other". +

+ +

jit.arch

+

+Contains the target architecture name: +"x86", "x64", "arm", "ppc", "ppcspe", or "mips". +

+ +

jit.opt.* — JIT compiler optimization control

+

+This sub-module provides the backend for the -O command line +option. +

+

+You can also use it programmatically, e.g.: +

+
+jit.opt.start(2) -- same as -O2
+jit.opt.start("-dce")
+jit.opt.start("hotloop=10", "hotexit=2")
+
+

+Unlike in LuaJIT 1.x, the module is built-in and +optimization is turned on by default! +It's no longer necessary to run require("jit.opt").start(), +which was one of the ways to enable optimization. +

+ +

jit.util.* — JIT compiler introspection

+

+This sub-module holds functions to introspect the bytecode, generated +traces, the IR and the generated machine code. The functionality +provided by this module is still in flux and therefore undocumented. +

+

+The debug modules -jbc, -jv and -jdump make +extensive use of these functions. Please check out their source code, +if you want to know more. +

+
+
+ + + + +``` + +`include/luajit-2.0.5/doc/extensions.html`: + +```html + + + +Extensions + + + + + + + + + +
+Lua +
+ + +
+

+LuaJIT is fully upwards-compatible with Lua 5.1. It supports all +» standard Lua +library functions and the full set of +» Lua/C API +functions. +

+

+LuaJIT is also fully ABI-compatible to Lua 5.1 at the linker/dynamic +loader level. This means you can compile a C module against the +standard Lua headers and load the same shared library from either Lua +or LuaJIT. +

+

+LuaJIT extends the standard Lua VM with new functionality and adds +several extension modules. Please note this page is only about +functional enhancements and not about performance enhancements, +such as the optimized VM, the faster interpreter or the JIT compiler. +

+ +

Extensions Modules

+

+LuaJIT comes with several built-in extension modules: +

+ +

bit.* — Bitwise operations

+

+LuaJIT supports all bitwise operations as defined by +» Lua BitOp: +

+
+bit.tobit  bit.tohex  bit.bnot    bit.band bit.bor  bit.bxor
+bit.lshift bit.rshift bit.arshift bit.rol  bit.ror  bit.bswap
+
+

+This module is a LuaJIT built-in — you don't need to download or +install Lua BitOp. The Lua BitOp site has full documentation for all +» Lua BitOp API functions. +

+

+Please make sure to require the module before using any of +its functions: +

+
+local bit = require("bit")
+
+

+An already installed Lua BitOp module is ignored by LuaJIT. +This way you can use bit operations from both Lua and LuaJIT on a +shared installation. +

+ +

ffi.* — FFI library

+

+The FFI library allows calling external +C functions and the use of C data structures from pure Lua +code. +

+ +

jit.* — JIT compiler control

+

+The functions in this module +control the behavior of the JIT compiler engine. +

+ +

C API extensions

+

+LuaJIT adds some +extra functions to the Lua/C API. +

+ +

Enhanced Standard Library Functions

+ +

xpcall(f, err [,args...]) passes arguments

+

+Unlike the standard implementation in Lua 5.1, xpcall() +passes any arguments after the error function to the function +which is called in a protected context. +

+ +

loadfile() etc. handle UTF-8 source code

+

+Non-ASCII characters are handled transparently by the Lua source code parser. +This allows the use of UTF-8 characters in identifiers and strings. +A UTF-8 BOM is skipped at the start of the source code. +

+ +

tostring() etc. canonicalize NaN and ±Inf

+

+All number-to-string conversions consistently convert non-finite numbers +to the same strings on all platforms. NaN results in "nan", +positive infinity results in "inf" and negative infinity results +in "-inf". +

+ +

tonumber() etc. use builtin string to number conversion

+

+All string-to-number conversions consistently convert integer and +floating-point inputs in decimal and hexadecimal on all platforms. +strtod() is not used anymore, which avoids numerous +problems with poor C library implementations. The builtin conversion +function provides full precision according to the IEEE-754 standard, it +works independently of the current locale and it supports hex floating-point +numbers (e.g. 0x1.5p-3). +

+ +

string.dump(f [,strip]) generates portable bytecode

+

+An extra argument has been added to string.dump(). If set to +true, 'stripped' bytecode without debug information is +generated. This speeds up later bytecode loading and reduces memory +usage. See also the +-b command line option. +

+

+The generated bytecode is portable and can be loaded on any architecture +that LuaJIT supports, independent of word size or endianess. However the +bytecode compatibility versions must match. Bytecode stays compatible +for dot releases (x.y.0 → x.y.1), but may change with major or +minor releases (2.0 → 2.1) or between any beta release. Foreign +bytecode (e.g. from Lua 5.1) is incompatible and cannot be loaded. +

+ +

Enhanced PRNG for math.random()

+

+LuaJIT uses a Tausworthe PRNG with period 2^223 to implement +math.random() and math.randomseed(). The quality of +the PRNG results is much superior compared to the standard Lua +implementation which uses the platform-specific ANSI rand(). +

+

+The PRNG generates the same sequences from the same seeds on all +platforms and makes use of all bits in the seed argument. +math.random() without arguments generates 52 pseudo-random bits +for every call. The result is uniformly distributed between 0.0 and 1.0. +It's correctly scaled up and rounded for math.random(n [,m]) to +preserve uniformity. +

+ +

io.* functions handle 64 bit file offsets

+

+The file I/O functions in the standard io.* library handle +64 bit file offsets. In particular this means it's possible +to open files larger than 2 Gigabytes and to reposition or obtain +the current file position for offsets beyond 2 GB +(fp:seek() method). +

+ +

debug.* functions identify metamethods

+

+debug.getinfo() and lua_getinfo() also return information +about invoked metamethods. The namewhat field is set to +"metamethod" and the name field has the name of +the corresponding metamethod (e.g. "__index"). +

+ +

Fully Resumable VM

+

+The LuaJIT VM is fully resumable. This means you can yield from a +coroutine even across contexts, where this would not possible with +the standard Lua 5.1 VM: e.g. you can yield across pcall() +and xpcall(), across iterators and across metamethods. +

+ +

Extensions from Lua 5.2

+

+LuaJIT supports some language and library extensions from Lua 5.2. +Features that are unlikely to break existing code are unconditionally +enabled: +

+
    +
  • goto and ::labels::.
  • +
  • Hex escapes '\x3F' and '\*' escape in strings.
  • +
  • load(string|reader [, chunkname [,mode [,env]]]).
  • +
  • loadstring() is an alias for load().
  • +
  • loadfile(filename [,mode [,env]]).
  • +
  • math.log(x [,base]).
  • +
  • string.rep(s, n [,sep]).
  • +
  • string.format(): %q reversible. +%s checks __tostring. +%a and "%A added.
  • +
  • String matching pattern %g added.
  • +
  • io.read("*L").
  • +
  • io.lines() and file:lines() process +io.read() options.
  • +
  • os.exit(status|true|false [,close]).
  • +
  • package.searchpath(name, path [, sep [, rep]]).
  • +
  • package.loadlib(name, "*").
  • +
  • debug.getinfo() returns nparams and isvararg +for option "u".
  • +
  • debug.getlocal() accepts function instead of level.
  • +
  • debug.getlocal() and debug.setlocal() accept negative +indexes for varargs.
  • +
  • debug.getupvalue() and debug.setupvalue() handle +C functions.
  • +
  • debug.upvalueid() and debug.upvaluejoin().
  • +
  • Command line option -E.
  • +
  • Command line checks __tostring for errors.
  • +
+

+Other features are only enabled, if LuaJIT is built with +-DLUAJIT_ENABLE_LUA52COMPAT: +

+
    +
  • goto is a keyword and not a valid variable name anymore.
  • +
  • break can be placed anywhere. Empty statements (;;) +are allowed.
  • +
  • __lt, __le are invoked for mixed types.
  • +
  • __len for tables. rawlen() library function.
  • +
  • pairs() and ipairs() check for __pairs and +__ipairs.
  • +
  • coroutine.running() returns two results.
  • +
  • table.pack() and table.unpack() +(same as unpack()).
  • +
  • io.write() and file:write() return file handle +instead of true.
  • +
  • os.execute() and pipe:close() return detailed +exit status.
  • +
  • debug.setmetatable() returns object.
  • +
  • debug.getuservalue() and debug.setuservalue().
  • +
  • Remove math.mod(), string.gfind().
  • +
+

+Note: this provides only partial compatibility with Lua 5.2 at the +language and Lua library level. LuaJIT is API+ABI-compatible with +Lua 5.1, which prevents implementing features that would otherwise +break the Lua/C API and ABI (e.g. _ENV). +

+ +

C++ Exception Interoperability

+

+LuaJIT has built-in support for interoperating with C++ exceptions. +The available range of features depends on the target platform and +the toolchain used to compile LuaJIT: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PlatformCompilerInteroperability
POSIX/x64, DWARF2 unwindingGCC 4.3+Full
Other platforms, DWARF2 unwindingGCCLimited
Windows/x64MSVC or WinSDKFull
Windows/x86AnyNo
Other platformsOther compilersNo
+

+Full interoperability means: +

+
    +
  • C++ exceptions can be caught on the Lua side with pcall(), +lua_pcall() etc.
  • +
  • C++ exceptions will be converted to the generic Lua error +"C++ exception", unless you use the +C call wrapper feature.
  • +
  • It's safe to throw C++ exceptions across non-protected Lua frames +on the C stack. The contents of the C++ exception object +pass through unmodified.
  • +
  • Lua errors can be caught on the C++ side with catch(...). +The corresponding Lua error message can be retrieved from the Lua stack.
  • +
  • Throwing Lua errors across C++ frames is safe. C++ destructors +will be called.
  • +
+

+Limited interoperability means: +

+
    +
  • C++ exceptions can be caught on the Lua side with pcall(), +lua_pcall() etc.
  • +
  • C++ exceptions will be converted to the generic Lua error +"C++ exception", unless you use the +C call wrapper feature.
  • +
  • C++ exceptions will be caught by non-protected Lua frames and +are rethrown as a generic Lua error. The C++ exception object will +be destroyed.
  • +
  • Lua errors cannot be caught on the C++ side.
  • +
  • Throwing Lua errors across C++ frames will not call +C++ destructors.
  • +
+ +

+No interoperability means: +

+
    +
  • It's not safe to throw C++ exceptions across Lua frames.
  • +
  • C++ exceptions cannot be caught on the Lua side.
  • +
  • Lua errors cannot be caught on the C++ side.
  • +
  • Throwing Lua errors across C++ frames will not call +C++ destructors.
  • +
  • Additionally, on Windows/x86 with SEH-based C++ exceptions: +it's not safe to throw a Lua error across any frames containing +a C++ function with any try/catch construct or using variables with +(implicit) destructors. This also applies to any functions which may be +inlined in such a function. It doesn't matter whether lua_error() +is called inside or outside of a try/catch or whether any object actually +needs to be destroyed: the SEH chain is corrupted and this will eventually +lead to the termination of the process.
  • +
+
+
+ + + + +``` + +`include/luajit-2.0.5/doc/faq.html`: + +```html + + + +Frequently Asked Questions (FAQ) + + + + + + + + + +
+Lua +
+ + +
+
+
Q: Where can I learn more about LuaJIT and Lua?
+
+ +
+ +
+
Q: Where can I learn more about the compiler technology used by LuaJIT?
+
+I'm planning to write more documentation about the internals of LuaJIT. +In the meantime, please use the following Google Scholar searches +to find relevant papers:
+Search for: » Trace Compiler
+Search for: » JIT Compiler
+Search for: » Dynamic Language Optimizations
+Search for: » SSA Form
+Search for: » Linear Scan Register Allocation
+Here is a list of the » innovative features in LuaJIT.
+And, you know, reading the source is of course the only way to enlightenment. :-) +
+
+ +
+
Q: Why do I get this error: "attempt to index global 'arg' (a nil value)"?
+Q: My vararg functions fail after switching to LuaJIT!
+
LuaJIT is compatible to the Lua 5.1 language standard. It doesn't +support the implicit arg parameter for old-style vararg +functions from Lua 5.0.
Please convert your code to the +» Lua 5.1 +vararg syntax.
+
+ +
+
Q: Why do I get this error: "bad FPU precision"?
+
Q: I get weird behavior after initializing Direct3D.
+
Q: Some FPU operations crash after I load a Delphi DLL.
+
+
+ +DirectX/Direct3D (up to version 9) sets the x87 FPU to single-precision +mode by default. This violates the Windows ABI and interferes with the +operation of many programs — LuaJIT is affected, too. Please make +sure you always use the D3DCREATE_FPU_PRESERVE flag when +initializing Direct3D.
+ +Direct3D version 10 or higher do not show this behavior anymore. +Consider testing your application with older versions, too.
+ +Similarly, the Borland/Delphi runtime modifies the FPU control word and +enables FP exceptions. Of course this violates the Windows ABI, too. +Please check the Delphi docs for the Set8087CW method. + +
+ +
+
Q: Sometimes Ctrl-C fails to stop my Lua program. Why?
+
The interrupt signal handler sets a Lua debug hook. But this is +currently ignored by compiled code (this will eventually be fixed). If +your program is running in a tight loop and never falls back to the +interpreter, the debug hook never runs and can't throw the +"interrupted!" error.
In the meantime you have to press Ctrl-C +twice to get stop your program. That's similar to when it's stuck +running inside a C function under the Lua interpreter.
+
+ +
+
Q: Why doesn't my favorite power-patch for Lua apply against LuaJIT?
+
Because it's a completely redesigned VM and has very little code +in common with Lua anymore. Also, if the patch introduces changes to +the Lua semantics, these would need to be reflected everywhere in the +VM, from the interpreter up to all stages of the compiler.
Please +use only standard Lua language constructs. For many common needs you +can use source transformations or use wrapper or proxy functions. +The compiler will happily optimize away such indirections.
+
+ +
+
Q: Lua runs everywhere. Why doesn't LuaJIT support my CPU?
+
Because it's a compiler — it needs to generate native +machine code. This means the code generator must be ported to each +architecture. And the fast interpreter is written in assembler and +must be ported, too. This is quite an undertaking.
+The install documentation shows the supported +architectures. Other architectures will follow based on sufficient user +demand and/or sponsoring.
+
+ +
+
Q: When will feature X be added? When will the next version be released?
+
When it's ready.
+C'mon, it's open source — I'm doing it on my own time and you're +getting it for free. You can either contribute a patch or sponsor +the development of certain features, if they are important to you. +
+
+
+
+ + + + +``` + +`include/luajit-2.0.5/doc/install.html`: + +```html + + + +Installation + + + + + + + + + +
+Lua +
+ + +
+

+LuaJIT is only distributed as a source package. This page explains +how to build and install LuaJIT with different operating systems +and C compilers. +

+

+For the impatient (on POSIX systems): +

+
+make && sudo make install
+
+

+LuaJIT currently builds out-of-the box on most systems. +Here's the compatibility matrix for the supported combinations of +operating systems, CPUs and compilers: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CPU / OSLinux or
Android
*BSD, OtherOSX 10.4+ or
iOS 3.0+
Windows
XP/Vista/7
x86 (32 bit)GCC 4.x+
GCC 3.4
GCC 4.x+
GCC 3.4
XCode 5.0+
Clang
MSVC, MSVC/EE
WinSDK
MinGW, Cygwin
x64 (64 bit)GCC 4.x+ORBIS (PS4)XCode 5.0+
Clang
MSVC + SDK v7.0
WinSDK v7.0
ARMv5+
ARM9E+
GCC 4.2+GCC 4.2+
PSP2 (PS VITA)
XCode 5.0+
Clang
 
PPCGCC 4.3+GCC 4.3+
GCC 4.1 (PS3)
 XEDK (Xbox 360)
PPC/e500v2GCC 4.3+GCC 4.3+  
MIPSGCC 4.3+GCC 4.3+  
+ +

Configuring LuaJIT

+

+The standard configuration should work fine for most installations. +Usually there is no need to tweak the settings. The following files +hold all user-configurable settings: +

+
    +
  • src/luaconf.h sets some configuration variables.
  • +
  • Makefile has settings for installing LuaJIT (POSIX +only).
  • +
  • src/Makefile has settings for compiling LuaJIT +under POSIX, MinGW or Cygwin.
  • +
  • src/msvcbuild.bat has settings for compiling LuaJIT with +MSVC or WinSDK.
  • +
+

+Please read the instructions given in these files, before changing +any settings. +

+ +

POSIX Systems (Linux, OSX, *BSD etc.)

+

Prerequisites

+

+Depending on your distribution, you may need to install a package for +GCC, the development headers and/or a complete SDK. E.g. on a current +Debian/Ubuntu, install libc6-dev with the package manager. +

+

+Download the current source package of LuaJIT (pick the .tar.gz), +if you haven't already done so. Move it to a directory of your choice, +open a terminal window and change to this directory. Now unpack the archive +and change to the newly created directory: +

+
+tar zxf LuaJIT-2.0.5.tar.gz
+cd LuaJIT-2.0.5
+

Building LuaJIT

+

+The supplied Makefiles try to auto-detect the settings needed for your +operating system and your compiler. They need to be run with GNU Make, +which is probably the default on your system, anyway. Simply run: +

+
+make
+
+

+This always builds a native x86, x64 or PPC binary, depending on the host OS +you're running this command on. Check the section on +cross-compilation for more options. +

+

+By default, modules are only searched under the prefix /usr/local. +You can add an extra prefix to the search paths by appending the +PREFIX option, e.g.: +

+
+make PREFIX=/home/myself/lj2
+
+

+Note for OSX: if the MACOSX_DEPLOYMENT_TARGET environment +variable is not set, then it's forced to 10.4. +

+

Installing LuaJIT

+

+The top-level Makefile installs LuaJIT by default under +/usr/local, i.e. the executable ends up in +/usr/local/bin and so on. You need root privileges +to write to this path. So, assuming sudo is installed on your system, +run the following command and enter your sudo password: +

+
+sudo make install
+
+

+Otherwise specify the directory prefix as an absolute path, e.g.: +

+
+make install PREFIX=/home/myself/lj2
+
+

+Obviously the prefixes given during build and installation need to be the same. +

+ +

Windows Systems

+

Prerequisites

+

+Either install one of the open source SDKs +(» MinGW or +» Cygwin), which come with a modified +GCC plus the required development headers. +

+

+Or install Microsoft's Visual C++ (MSVC). The freely downloadable +» Express Edition +works just fine, but only contains an x86 compiler. +

+

+The freely downloadable +» Windows SDK +only comes with command line tools, but this is all you need to build LuaJIT. +It contains x86 and x64 compilers. +

+

+Next, download the source package and unpack it using an archive manager +(e.g. the Windows Explorer) to a directory of your choice. +

+

Building with MSVC

+

+Open a "Visual Studio .NET Command Prompt", cd to the +directory where you've unpacked the sources and run these commands: +

+
+cd src
+msvcbuild
+
+

+Then follow the installation instructions below. +

+

Building with the Windows SDK

+

+Open a "Windows SDK Command Shell" and select the x86 compiler: +

+
+setenv /release /x86
+
+

+Or select the x64 compiler: +

+
+setenv /release /x64
+
+

+Then cd to the directory where you've unpacked the sources +and run these commands: +

+
+cd src
+msvcbuild
+
+

+Then follow the installation instructions below. +

+

Building with MinGW or Cygwin

+

+Open a command prompt window and make sure the MinGW or Cygwin programs +are in your path. Then cd to the directory where +you've unpacked the sources and run this command for MinGW: +

+
+mingw32-make
+
+

+Or this command for Cygwin: +

+
+make
+
+

+Then follow the installation instructions below. +

+

Installing LuaJIT

+

+Copy luajit.exe and lua51.dll (built in the src +directory) to a newly created directory (any location is ok). +Add lua and lua\jit directories below it and copy +all Lua files from the src\jit directory of the distribution +to the latter directory. +

+

+There are no hardcoded +absolute path names — all modules are loaded relative to the +directory where luajit.exe is installed +(see src/luaconf.h). +

+ +

Cross-compiling LuaJIT

+

+The GNU Makefile-based build system allows cross-compiling on any host +for any supported target, as long as both architectures have the same +pointer size. If you want to cross-compile to any 32 bit target on an +x64 OS, you need to install the multilib development package (e.g. +libc6-dev-i386 on Debian/Ubuntu) and build a 32 bit host part +(HOST_CC="gcc -m32"). +

+

+You need to specify TARGET_SYS whenever the host OS and the +target OS differ, or you'll get assembler or linker errors. E.g. if +you're compiling on a Windows or OSX host for embedded Linux or Android, +you need to add TARGET_SYS=Linux to the examples below. For a +minimal target OS, you may need to disable the built-in allocator in +src/Makefile and use TARGET_SYS=Other. Don't forget to +specify the same TARGET_SYS for the install step, too. +

+

+The examples below only show some popular targets — please check +the comments in src/Makefile for more details. +

+
+# Cross-compile to a 32 bit binary on a multilib x64 OS
+make CC="gcc -m32"
+
+# Cross-compile on Debian/Ubuntu for Windows (mingw32 package)
+make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows
+
+

+The CROSS prefix allows specifying a standard GNU cross-compile +toolchain (Binutils, GCC and a matching libc). The prefix may vary +depending on the --target the toolchain was built for (note the +CROSS prefix has a trailing "-"). The examples below +use the canonical toolchain triplets for Linux. +

+

+Since there's often no easy way to detect CPU features at runtime, it's +important to compile with the proper CPU or architecture settings. You +can specify these when building the toolchain yourself. Or add +-mcpu=... or -march=... to TARGET_CFLAGS. For +ARM it's important to have the correct -mfloat-abi=... setting, +too. Otherwise LuaJIT may not run at the full performance of your target +CPU. +

+
+# ARM soft-float
+make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
+     TARGET_CFLAGS="-mfloat-abi=soft"
+
+# ARM soft-float ABI with VFP (example for Cortex-A8)
+make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
+     TARGET_CFLAGS="-mcpu=cortex-a8 -mfloat-abi=softfp"
+
+# ARM hard-float ABI with VFP (armhf, requires recent toolchain)
+make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf-
+
+# PPC
+make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
+# PPC/e500v2 (fast interpreter only)
+make HOST_CC="gcc -m32" CROSS=powerpc-e500v2-linux-gnuspe-
+
+# MIPS big-endian
+make HOST_CC="gcc -m32" CROSS=mips-linux-
+# MIPS little-endian
+make HOST_CC="gcc -m32" CROSS=mipsel-linux-
+
+

+You can cross-compile for Android using the » Android NDK. +The environment variables need to match the install locations and the +desired target platform. E.g. Android 4.0 corresponds to ABI level 14. +For details check the folder docs in the NDK directory. +

+

+Only a few common variations for the different CPUs, ABIs and platforms +are listed. Please use your own judgement for which combination you want +to build/deploy or which lowest common denominator you want to pick: +

+
+# Android/ARM, armeabi (ARMv5TE soft-float), Android 2.2+ (Froyo)
+NDK=/opt/android/ndk
+NDKABI=8
+NDKVER=$NDK/toolchains/arm-linux-androideabi-4.6
+NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi-
+NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
+make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"
+
+# Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.0+ (ICS)
+NDK=/opt/android/ndk
+NDKABI=14
+NDKVER=$NDK/toolchains/arm-linux-androideabi-4.6
+NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi-
+NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
+NDKARCH="-march=armv7-a -mfloat-abi=softfp -Wl,--fix-cortex-a8"
+make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF $NDKARCH"
+
+# Android/MIPS, mips (MIPS32R1 hard-float), Android 4.0+ (ICS)
+NDK=/opt/android/ndk
+NDKABI=14
+NDKVER=$NDK/toolchains/mipsel-linux-android-4.6
+NDKP=$NDKVER/prebuilt/linux-x86/bin/mipsel-linux-android-
+NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-mips"
+make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"
+
+# Android/x86, x86 (i686 SSE3), Android 4.0+ (ICS)
+NDK=/opt/android/ndk
+NDKABI=14
+NDKVER=$NDK/toolchains/x86-4.6
+NDKP=$NDKVER/prebuilt/linux-x86/bin/i686-linux-android-
+NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-x86"
+make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"
+
+

+You can cross-compile for iOS 3.0+ (iPhone/iPad) using the » iOS SDK: +

+

+Note: the JIT compiler is disabled for iOS, because regular iOS Apps +are not allowed to generate code at runtime. You'll only get the performance +of the LuaJIT interpreter on iOS. This is still faster than plain Lua, but +much slower than the JIT compiler. Please complain to Apple, not me. +Or use Android. :-p +

+
+ISDKP=$(xcrun --sdk iphoneos --show-sdk-path)
+ICC=$(xcrun --sdk iphoneos --find clang)
+ISDKF="-arch armv7 -isysroot $ISDKP"
+make DEFAULT_CC=clang HOST_CC="clang -m32 -arch i386" \
+     CROSS="$(dirname $ICC)/" TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS
+
+ +

Cross-compiling for consoles

+

+Building LuaJIT for consoles requires both a supported host compiler +(x86 or x64) and a cross-compiler (to PPC or ARM) from the official +console SDK. +

+

+Due to restrictions on consoles, the JIT compiler is disabled and only +the fast interpreter is built. This is still faster than plain Lua, +but much slower than the JIT compiler. The FFI is disabled, too, since +it's not very useful in such an environment. +

+

+The following commands build a static library libluajit.a, +which can be linked against your game, just like the Lua library. +

+

+To cross-compile for PS3 from a Linux host (requires +32 bit GCC, i.e. multilib Linux/x64) or a Windows host (requires +32 bit MinGW), run this command: +

+
+make HOST_CC="gcc -m32" CROSS=ppu-lv2-
+
+

+To cross-compile for PS4 from a Windows host, +open a "Visual Studio .NET Command Prompt" (64 bit host compiler), +cd to the directory where you've unpacked the sources and +run the following commands: +

+
+cd src
+ps4build
+
+

+To cross-compile for PS Vita from a Windows host, +open a "Visual Studio .NET Command Prompt" (32 bit host compiler), +cd to the directory where you've unpacked the sources and +run the following commands: +

+
+cd src
+psvitabuild
+
+

+To cross-compile for Xbox 360 from a Windows host, +open a "Visual Studio .NET Command Prompt" (32 bit host compiler), +cd to the directory where you've unpacked the sources and run +the following commands: +

+
+cd src
+xedkbuild
+
+ +

Embedding LuaJIT

+

+LuaJIT is API-compatible with Lua 5.1. If you've already embedded Lua +into your application, you probably don't need to do anything to switch +to LuaJIT, except link with a different library: +

+
    +
  • It's strongly suggested to build LuaJIT separately using the supplied +build system. Please do not attempt to integrate the individual +source files into your build tree. You'll most likely get the internal build +dependencies wrong or mess up the compiler flags. Treat LuaJIT like any +other external library and link your application with either the dynamic +or static library, depending on your needs.
  • +
  • If you want to load C modules compiled for plain Lua +with require(), you need to make sure the public symbols +(e.g. lua_pushnumber) are exported, too: +
    • On POSIX systems you can either link to the shared library +or link the static library into your application. In the latter case +you'll need to export all public symbols from your main executable +(e.g. -Wl,-E on Linux) and add the external dependencies +(e.g. -lm -ldl on Linux).
    • +
    • Since Windows symbols are bound to a specific DLL name, you need to +link to the lua51.dll created by the LuaJIT build (do not rename +the DLL). You may link LuaJIT statically on Windows only if you don't +intend to load Lua/C modules at runtime. +
    +
  • +
  • +If you're building a 64 bit application on OSX which links directly or +indirectly against LuaJIT, you need to link your main executable +with these flags: +
    +-pagezero_size 10000 -image_base 100000000
    +
    +Also, it's recommended to rebase all (self-compiled) shared libraries +which are loaded at runtime on OSX/x64 (e.g. C extension modules for Lua). +See: man rebase +
  • +
+

Additional hints for initializing LuaJIT using the C API functions:

+
    +
  • Here's a +» simple example +for embedding Lua or LuaJIT into your application.
  • +
  • Make sure you use luaL_newstate. Avoid using +lua_newstate, since this uses the (slower) default memory +allocator from your system (no support for this on x64).
  • +
  • Make sure you use luaL_openlibs and not the old Lua 5.0 style +of calling luaopen_base etc. directly.
  • +
  • To change or extend the list of standard libraries to load, copy +src/lib_init.c to your project and modify it accordingly. +Make sure the jit library is loaded or the JIT compiler +will not be activated.
  • +
  • The bit.* module for bitwise operations +is already built-in. There's no need to statically link +» Lua BitOp to your application.
  • +
+ +

Hints for Distribution Maintainers

+

+The LuaJIT build system has extra provisions for the needs of most +POSIX-based distributions. If you're a package maintainer for +a distribution, please make use of these features and +avoid patching, subverting, autotoolizing or messing up the build system +in unspeakable ways. +

+

+There should be absolutely no need to patch luaconf.h or any +of the Makefiles. And please do not hand-pick files for your packages — +simply use whatever make install creates. There's a reason +for all of the files and directories it creates. +

+

+The build system uses GNU make and auto-detects most settings based on +the host you're building it on. This should work fine for native builds, +even when sandboxed. You may need to pass some of the following flags to +both the make and the make install command lines +for a regular distribution build: +

+
    +
  • PREFIX overrides the installation path and should usually +be set to /usr. Setting this also changes the module paths and +the paths needed to locate the shared library.
  • +
  • DESTDIR is an absolute path which allows you to install +to a shadow tree instead of the root tree of the build system.
  • +
  • MULTILIB sets the architecture-specific library path component +for multilib systems. The default is lib.
  • +
  • Have a look at the top-level Makefile and src/Makefile +for additional variables to tweak. The following variables may be +overridden, but it's not recommended, except for special needs +like cross-builds: +BUILDMODE, CC, HOST_CC, STATIC_CC, DYNAMIC_CC, CFLAGS, HOST_CFLAGS, +TARGET_CFLAGS, LDFLAGS, HOST_LDFLAGS, TARGET_LDFLAGS, TARGET_SHLDFLAGS, +TARGET_FLAGS, LIBS, HOST_LIBS, TARGET_LIBS, CROSS, HOST_SYS, TARGET_SYS +
  • +
+

+The build system has a special target for an amalgamated build, i.e. +make amalg. This compiles the LuaJIT core as one huge C file +and allows GCC to generate faster and shorter code. Alas, this requires +lots of memory during the build. This may be a problem for some users, +that's why it's not enabled by default. But it shouldn't be a problem for +most build farms. It's recommended that binary distributions use this +target for their LuaJIT builds. +

+

+The tl;dr version of the above: +

+
+make amalg PREFIX=/usr && \
+make install PREFIX=/usr DESTDIR=/tmp/buildroot
+
+

+Finally, if you encounter any difficulties, please +contact me first, instead of releasing a broken +package onto unsuspecting users. Because they'll usually gonna complain +to me (the upstream) and not you (the package maintainer), anyway. +

+
+
+ + + + +``` + +`include/luajit-2.0.5/doc/luajit.html`: + +```html + + + +LuaJIT + + + + + + + + + + +
+Lua +
+ + +
+

+LuaJIT is a Just-In-Time Compiler (JIT) for the +» Lua programming language. +Lua is a powerful, dynamic and light-weight programming language. +It may be embedded or used as a general-purpose, stand-alone language. +

+

+LuaJIT is Copyright © 2005-2017 Mike Pall, released under the +» MIT open source license. +

+

+

+ +

Compatibility

+ + +
WindowsLinuxBSDOSXPOSIX
+ + +
EmbeddedAndroidiOS
+ + +
PS3PS4PS VitaXbox 360
+ + +
GCCCLANG
LLVM
MSVC
+ + +
x86x64ARMPPCe500MIPS
+ + +
Lua 5.1
API+ABI
+ JIT+ BitOp+ FFIDrop-in
DLL/.so
+ +

Overview

+ + + + + + + + + +
3x
-  100x
115 KB
VM
90 KB
JIT
63 KLOC
C
24 KLOC
ASM
11 KLOC
Lua
+

+LuaJIT has been successfully used as a scripting middleware in +games, appliances, network and graphics apps, numerical simulations, +trading platforms and many other specialty applications. It scales from +embedded devices, smartphones, desktops up to server farms. It combines +high flexibility with » high performance +and an unmatched low memory footprint. +

+

+LuaJIT has been in continuous development since 2005. It's widely +considered to be one of the fastest dynamic language +implementations. It has outperformed other dynamic languages on many +cross-language benchmarks since its first release — often by a +substantial margin. +

+

+For LuaJIT 2.0, the whole VM has been rewritten from the ground up +and relentlessly optimized for performance. It combines a high-speed +interpreter, written in assembler, with a state-of-the-art JIT +compiler. +

+

+An innovative trace compiler is integrated with advanced, +SSA-based optimizations and highly tuned code generation backends. +A substantial reduction of the overhead associated with dynamic languages +allows it to break into the performance range traditionally reserved for +offline, static language compilers. +

+ +

More ...

+

+Please select a sub-topic in the navigation bar to learn more about LuaJIT. +

+
+
+ + + + +``` + +`include/luajit-2.0.5/doc/running.html`: + +```html + + + +Running LuaJIT + + + + + + + + + +
+Lua +
+ + +
+

+LuaJIT has only a single stand-alone executable, called luajit on +POSIX systems or luajit.exe on Windows. It can be used to run simple +Lua statements or whole Lua applications from the command line. It has an +interactive mode, too. +

+ +

Command Line Options

+

+The luajit stand-alone executable is just a slightly modified +version of the regular lua stand-alone executable. +It supports the same basic options, too. luajit -h +prints a short list of the available options. Please have a look at the +» Lua manual +for details. +

+

+LuaJIT has some additional options: +

+ +

-b[options] input output

+

+This option saves or lists bytecode. The following additional options +are accepted: +

+
    +
  • -l — Only list bytecode.
  • +
  • -s — Strip debug info (this is the default).
  • +
  • -g — Keep debug info.
  • +
  • -n name — Set module name (default: auto-detect from input name)
  • +
  • -t type — Set output file type (default: auto-detect from output name).
  • +
  • -a arch — Override architecture for object files (default: native).
  • +
  • -o os — Override OS for object files (default: native).
  • +
  • -e chunk — Use chunk string as input.
  • +
  • - (a single minus sign) — Use stdin as input and/or stdout as output.
  • +
+

+The output file type is auto-detected from the extension of the output +file name: +

+
    +
  • c — C source file, exported bytecode data.
  • +
  • h — C header file, static bytecode data.
  • +
  • obj or o — Object file, exported bytecode data +(OS- and architecture-specific).
  • +
  • raw or any other extension — Raw bytecode file (portable). +
+

+Notes: +

+
    +
  • See also string.dump() +for information on bytecode portability and compatibility.
  • +
  • A file in raw bytecode format is auto-detected and can be loaded like +any Lua source file. E.g. directly from the command line or with +loadfile(), dofile() etc.
  • +
  • To statically embed the bytecode of a module in your application, +generate an object file and just link it with your application.
  • +
  • On most ELF-based systems (e.g. Linux) you need to explicitly export the +global symbols when linking your application, e.g. with: -Wl,-E
  • +
  • require() tries to load embedded bytecode data from exported +symbols (in *.exe or lua51.dll on Windows) and from +shared libraries in package.cpath.
  • +
+

+Typical usage examples: +

+
+luajit -b test.lua test.out                 # Save bytecode to test.out
+luajit -bg test.lua test.out                # Keep debug info
+luajit -be "print('hello world')" test.out  # Save cmdline script
+
+luajit -bl test.lua                         # List to stdout
+luajit -bl test.lua test.txt                # List to test.txt
+luajit -ble "print('hello world')"          # List cmdline script
+
+luajit -b test.lua test.obj                 # Generate object file
+# Link test.obj with your application and load it with require("test")
+
+ +

-j cmd[=arg[,arg...]]

+

+This option performs a LuaJIT control command or activates one of the +loadable extension modules. The command is first looked up in the +jit.* library. If no matching function is found, a module +named jit.<cmd> is loaded and the start() +function of the module is called with the specified arguments (if +any). The space between -j and cmd is optional. +

+

+Here are the available LuaJIT control commands: +

+
    +
  • -jon — Turns the JIT compiler on (default).
  • +
  • -joff — Turns the JIT compiler off (only use the interpreter).
  • +
  • -jflush — Flushes the whole cache of compiled code.
  • +
  • -jv — Shows verbose information about the progress of the JIT compiler.
  • +
  • -jdump — Dumps the code and structures used in various compiler stages.
  • +
+

+The -jv and -jdump commands are extension modules +written in Lua. They are mainly used for debugging the JIT compiler +itself. For a description of their options and output format, please +read the comment block at the start of their source. +They can be found in the lib directory of the source +distribution or installed under the jit directory. By default +this is /usr/local/share/luajit-2.0.5/jit on POSIX +systems. +

+ +

-O[level]
+-O[+]flag   -O-flag
+-Oparam=value

+

+This options allows fine-tuned control of the optimizations used by +the JIT compiler. This is mainly intended for debugging LuaJIT itself. +Please note that the JIT compiler is extremely fast (we are talking +about the microsecond to millisecond range). Disabling optimizations +doesn't have any visible impact on its overhead, but usually generates +code that runs slower. +

+

+The first form sets an optimization level — this enables a +specific mix of optimization flags. -O0 turns off all +optimizations and higher numbers enable more optimizations. Omitting +the level (i.e. just -O) sets the default optimization level, +which is -O3 in the current version. +

+

+The second form adds or removes individual optimization flags. +The third form sets a parameter for the VM or the JIT compiler +to a specific value. +

+

+You can either use this option multiple times (like -Ocse +-O-dce -Ohotloop=10) or separate several settings with a comma +(like -O+cse,-dce,hotloop=10). The settings are applied from +left to right and later settings override earlier ones. You can freely +mix the three forms, but note that setting an optimization level +overrides all earlier flags. +

+

+Here are the available flags and at what optimization levels they +are enabled: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Flag-O1-O2-O3 
foldConstant Folding, Simplifications and Reassociation
cseCommon-Subexpression Elimination
dceDead-Code Elimination
narrow Narrowing of numbers to integers
loop Loop Optimizations (code hoisting)
fwd  Load Forwarding (L2L) and Store Forwarding (S2L)
dse  Dead-Store Elimination
abc  Array Bounds Check Elimination
sink  Allocation/Store Sinking
fuse  Fusion of operands into instructions
+

+Here are the parameters and their default settings: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterDefault 
maxtrace1000Max. number of traces in the cache
maxrecord4000Max. number of recorded IR instructions
maxirconst500Max. number of IR constants of a trace
maxside100Max. number of side traces of a root trace
maxsnap500Max. number of snapshots for a trace
hotloop56Number of iterations to detect a hot loop or hot call
hotexit10Number of taken exits to start a side trace
tryside4Number of attempts to compile a side trace
instunroll4Max. unroll factor for instable loops
loopunroll15Max. unroll factor for loop ops in side traces
callunroll3Max. unroll factor for pseudo-recursive calls
recunroll2Min. unroll factor for true recursion
sizemcode32Size of each machine code area in KBytes (Windows: 64K)
maxmcode512Max. total size of all machine code areas in KBytes
+
+
+ + + + +``` + +`include/luajit-2.0.5/doc/status.html`: + +```html + + + +Status + + + + + + + + + +
+Lua +
+ + +
+

+LuaJIT 2.0 is the current +stable branch. This branch is in +feature-freeze — new features will only be added to LuaJIT 2.1. +

+ +

Current Status

+

+LuaJIT ought to run all Lua 5.1-compatible source code just fine. +It's considered a serious bug if the VM crashes or produces unexpected +results — please report this. +

+

+Known incompatibilities and issues in LuaJIT 2.0: +

+
    +
  • +There are some differences in implementation-defined behavior. +These either have a good reason, are arbitrary design choices +or are due to quirks in the VM. The latter cases may get fixed if a +demonstrable need is shown. +
  • +
  • +The Lua debug API is missing a couple of features (return +hooks for non-Lua functions) and shows slightly different behavior +in LuaJIT (no per-coroutine hooks, no tail call counting). +
  • +
  • +Currently some out-of-memory errors from on-trace code are not +handled correctly. The error may fall through an on-trace +pcall or it may be passed on to the function set with +lua_atpanic on x64. This issue will be fixed with the new +garbage collector. +
  • +
+
+
+ + + + +``` + +`include/luajit-2.0.5/dynasm/dasm_arm.h`: + +```h +/* +** DynASM ARM encoding engine. +** Copyright (C) 2005-2017 Mike Pall. All rights reserved. +** Released under the MIT license. See dynasm.lua for full copyright notice. +*/ + +#include +#include +#include +#include + +#define DASM_ARCH "arm" + +#ifndef DASM_EXTERN +#define DASM_EXTERN(a,b,c,d) 0 +#endif + +/* Action definitions. */ +enum { + DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT, + /* The following actions need a buffer position. */ + DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG, + /* The following actions also have an argument. */ + DASM_REL_PC, DASM_LABEL_PC, + DASM_IMM, DASM_IMM12, DASM_IMM16, DASM_IMML8, DASM_IMML12, DASM_IMMV8, + DASM__MAX +}; + +/* Maximum number of section buffer positions for a single dasm_put() call. */ +#define DASM_MAXSECPOS 25 + +/* DynASM encoder status codes. Action list offset or number are or'ed in. */ +#define DASM_S_OK 0x00000000 +#define DASM_S_NOMEM 0x01000000 +#define DASM_S_PHASE 0x02000000 +#define DASM_S_MATCH_SEC 0x03000000 +#define DASM_S_RANGE_I 0x11000000 +#define DASM_S_RANGE_SEC 0x12000000 +#define DASM_S_RANGE_LG 0x13000000 +#define DASM_S_RANGE_PC 0x14000000 +#define DASM_S_RANGE_REL 0x15000000 +#define DASM_S_UNDEF_LG 0x21000000 +#define DASM_S_UNDEF_PC 0x22000000 + +/* Macros to convert positions (8 bit section + 24 bit index). */ +#define DASM_POS2IDX(pos) ((pos)&0x00ffffff) +#define DASM_POS2BIAS(pos) ((pos)&0xff000000) +#define DASM_SEC2POS(sec) ((sec)<<24) +#define DASM_POS2SEC(pos) ((pos)>>24) +#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) + +/* Action list type. */ +typedef const unsigned int *dasm_ActList; + +/* Per-section structure. */ +typedef struct dasm_Section { + int *rbuf; /* Biased buffer pointer (negative section bias). */ + int *buf; /* True buffer pointer. */ + size_t bsize; /* Buffer size in bytes. */ + int pos; /* Biased buffer position. */ + int epos; /* End of biased buffer position - max single put. */ + int ofs; /* Byte offset into section. */ +} dasm_Section; + +/* Core structure holding the DynASM encoding state. */ +struct dasm_State { + size_t psize; /* Allocated size of this structure. */ + dasm_ActList actionlist; /* Current actionlist pointer. */ + int *lglabels; /* Local/global chain/pos ptrs. */ + size_t lgsize; + int *pclabels; /* PC label chains/pos ptrs. */ + size_t pcsize; + void **globals; /* Array of globals (bias -10). */ + dasm_Section *section; /* Pointer to active section. */ + size_t codesize; /* Total size of all code sections. */ + int maxsection; /* 0 <= sectionidx < maxsection. */ + int status; /* Status code. */ + dasm_Section sections[1]; /* All sections. Alloc-extended. */ +}; + +/* The size of the core structure depends on the max. number of sections. */ +#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) + + +/* Initialize DynASM state. */ +void dasm_init(Dst_DECL, int maxsection) +{ + dasm_State *D; + size_t psz = 0; + int i; + Dst_REF = NULL; + DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); + D = Dst_REF; + D->psize = psz; + D->lglabels = NULL; + D->lgsize = 0; + D->pclabels = NULL; + D->pcsize = 0; + D->globals = NULL; + D->maxsection = maxsection; + for (i = 0; i < maxsection; i++) { + D->sections[i].buf = NULL; /* Need this for pass3. */ + D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); + D->sections[i].bsize = 0; + D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ + } +} + +/* Free DynASM state. */ +void dasm_free(Dst_DECL) +{ + dasm_State *D = Dst_REF; + int i; + for (i = 0; i < D->maxsection; i++) + if (D->sections[i].buf) + DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); + if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); + if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); + DASM_M_FREE(Dst, D, D->psize); +} + +/* Setup global label array. Must be called before dasm_setup(). */ +void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) +{ + dasm_State *D = Dst_REF; + D->globals = gl - 10; /* Negative bias to compensate for locals. */ + DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); +} + +/* Grow PC label array. Can be called after dasm_setup(), too. */ +void dasm_growpc(Dst_DECL, unsigned int maxpc) +{ + dasm_State *D = Dst_REF; + size_t osz = D->pcsize; + DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); + memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); +} + +/* Setup encoder. */ +void dasm_setup(Dst_DECL, const void *actionlist) +{ + dasm_State *D = Dst_REF; + int i; + D->actionlist = (dasm_ActList)actionlist; + D->status = DASM_S_OK; + D->section = &D->sections[0]; + memset((void *)D->lglabels, 0, D->lgsize); + if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); + for (i = 0; i < D->maxsection; i++) { + D->sections[i].pos = DASM_SEC2POS(i); + D->sections[i].ofs = 0; + } +} + + +#ifdef DASM_CHECKS +#define CK(x, st) \ + do { if (!(x)) { \ + D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0) +#define CKPL(kind, st) \ + do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ + D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0) +#else +#define CK(x, st) ((void)0) +#define CKPL(kind, st) ((void)0) +#endif + +static int dasm_imm12(unsigned int n) +{ + int i; + for (i = 0; i < 16; i++, n = (n << 2) | (n >> 30)) + if (n <= 255) return (int)(n + (i << 8)); + return -1; +} + +/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ +void dasm_put(Dst_DECL, int start, ...) +{ + va_list ap; + dasm_State *D = Dst_REF; + dasm_ActList p = D->actionlist + start; + dasm_Section *sec = D->section; + int pos = sec->pos, ofs = sec->ofs; + int *b; + + if (pos >= sec->epos) { + DASM_M_GROW(Dst, int, sec->buf, sec->bsize, + sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); + sec->rbuf = sec->buf - DASM_POS2BIAS(pos); + sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); + } + + b = sec->rbuf; + b[pos++] = start; + + va_start(ap, start); + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16); + if (action >= DASM__MAX) { + ofs += 4; + } else { + int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0; + switch (action) { + case DASM_STOP: goto stop; + case DASM_SECTION: + n = (ins & 255); CK(n < D->maxsection, RANGE_SEC); + D->section = &D->sections[n]; goto stop; + case DASM_ESC: p++; ofs += 4; break; + case DASM_REL_EXT: break; + case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break; + case DASM_REL_LG: + n = (ins & 2047) - 10; pl = D->lglabels + n; + /* Bkwd rel or global. */ + if (n >= 0) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; } + pl += 10; n = *pl; + if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ + goto linkrel; + case DASM_REL_PC: + pl = D->pclabels + n; CKPL(pc, PC); + putrel: + n = *pl; + if (n < 0) { /* Label exists. Get label pos and store it. */ + b[pos] = -n; + } else { + linkrel: + b[pos] = n; /* Else link to rel chain, anchored at label. */ + *pl = pos; + } + pos++; + break; + case DASM_LABEL_LG: + pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel; + case DASM_LABEL_PC: + pl = D->pclabels + n; CKPL(pc, PC); + putlabel: + n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; + } + *pl = -pos; /* Label exists now. */ + b[pos++] = ofs; /* Store pass1 offset estimate. */ + break; + case DASM_IMM: + case DASM_IMM16: +#ifdef DASM_CHECKS + CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I); + if ((ins & 0x8000)) + CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I); + else + CK((n>>((ins>>5)&31)) == 0, RANGE_I); +#endif + b[pos++] = n; + break; + case DASM_IMMV8: + CK((n & 3) == 0, RANGE_I); + n >>= 2; + case DASM_IMML8: + case DASM_IMML12: + CK(n >= 0 ? ((n>>((ins>>5)&31)) == 0) : + (((-n)>>((ins>>5)&31)) == 0), RANGE_I); + b[pos++] = n; + break; + case DASM_IMM12: + CK(dasm_imm12((unsigned int)n) != -1, RANGE_I); + b[pos++] = n; + break; + } + } + } +stop: + va_end(ap); + sec->pos = pos; + sec->ofs = ofs; +} +#undef CK + +/* Pass 2: Link sections, shrink aligns, fix label offsets. */ +int dasm_link(Dst_DECL, size_t *szp) +{ + dasm_State *D = Dst_REF; + int secnum; + int ofs = 0; + +#ifdef DASM_CHECKS + *szp = 0; + if (D->status != DASM_S_OK) return D->status; + { + int pc; + for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) + if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; + } +#endif + + { /* Handle globals not defined in this translation unit. */ + int idx; + for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { + int n = D->lglabels[idx]; + /* Undefined label: Collapse rel chain and replace with marker (< 0). */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } + } + } + + /* Combine all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->rbuf; + int pos = DASM_SEC2POS(secnum); + int lastpos = sec->pos; + + while (pos != lastpos) { + dasm_ActList p = D->actionlist + b[pos++]; + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16); + switch (action) { + case DASM_STOP: case DASM_SECTION: goto stop; + case DASM_ESC: p++; break; + case DASM_REL_EXT: break; + case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break; + case DASM_REL_LG: case DASM_REL_PC: pos++; break; + case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; + case DASM_IMM: case DASM_IMM12: case DASM_IMM16: + case DASM_IMML8: case DASM_IMML12: case DASM_IMMV8: pos++; break; + } + } + stop: (void)0; + } + ofs += sec->ofs; /* Next section starts right after current section. */ + } + + D->codesize = ofs; /* Total size of all code sections */ + *szp = ofs; + return DASM_S_OK; +} + +#ifdef DASM_CHECKS +#define CK(x, st) \ + do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0) +#else +#define CK(x, st) ((void)0) +#endif + +/* Pass 3: Encode sections. */ +int dasm_encode(Dst_DECL, void *buffer) +{ + dasm_State *D = Dst_REF; + char *base = (char *)buffer; + unsigned int *cp = (unsigned int *)buffer; + int secnum; + + /* Encode all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->buf; + int *endb = sec->rbuf + sec->pos; + + while (b != endb) { + dasm_ActList p = D->actionlist + *b++; + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16); + int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0; + switch (action) { + case DASM_STOP: case DASM_SECTION: goto stop; + case DASM_ESC: *cp++ = *p++; break; + case DASM_REL_EXT: + n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins&2047), !(ins&2048)); + goto patchrel; + case DASM_ALIGN: + ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0xe1a00000; + break; + case DASM_REL_LG: + CK(n >= 0, UNDEF_LG); + case DASM_REL_PC: + CK(n >= 0, UNDEF_PC); + n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base) - 4; + patchrel: + if ((ins & 0x800) == 0) { + CK((n & 3) == 0 && ((n+0x02000000) >> 26) == 0, RANGE_REL); + cp[-1] |= ((n >> 2) & 0x00ffffff); + } else if ((ins & 0x1000)) { + CK((n & 3) == 0 && -256 <= n && n <= 256, RANGE_REL); + goto patchimml8; + } else if ((ins & 0x2000) == 0) { + CK((n & 3) == 0 && -4096 <= n && n <= 4096, RANGE_REL); + goto patchimml; + } else { + CK((n & 3) == 0 && -1020 <= n && n <= 1020, RANGE_REL); + n >>= 2; + goto patchimml; + } + break; + case DASM_LABEL_LG: + ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); + break; + case DASM_LABEL_PC: break; + case DASM_IMM: + cp[-1] |= ((n>>((ins>>10)&31)) & ((1<<((ins>>5)&31))-1)) << (ins&31); + break; + case DASM_IMM12: + cp[-1] |= dasm_imm12((unsigned int)n); + break; + case DASM_IMM16: + cp[-1] |= ((n & 0xf000) << 4) | (n & 0x0fff); + break; + case DASM_IMML8: patchimml8: + cp[-1] |= n >= 0 ? (0x00800000 | (n & 0x0f) | ((n & 0xf0) << 4)) : + ((-n & 0x0f) | ((-n & 0xf0) << 4)); + break; + case DASM_IMML12: case DASM_IMMV8: patchimml: + cp[-1] |= n >= 0 ? (0x00800000 | n) : (-n); + break; + default: *cp++ = ins; break; + } + } + stop: (void)0; + } + } + + if (base + D->codesize != (char *)cp) /* Check for phase errors. */ + return DASM_S_PHASE; + return DASM_S_OK; +} +#undef CK + +/* Get PC label offset. */ +int dasm_getpclabel(Dst_DECL, unsigned int pc) +{ + dasm_State *D = Dst_REF; + if (pc*sizeof(int) < D->pcsize) { + int pos = D->pclabels[pc]; + if (pos < 0) return *DASM_POS2PTR(D, -pos); + if (pos > 0) return -1; /* Undefined. */ + } + return -2; /* Unused or out of range. */ +} + +#ifdef DASM_CHECKS +/* Optional sanity checker to call between isolated encoding steps. */ +int dasm_checkstep(Dst_DECL, int secmatch) +{ + dasm_State *D = Dst_REF; + if (D->status == DASM_S_OK) { + int i; + for (i = 1; i <= 9; i++) { + if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; } + D->lglabels[i] = 0; + } + } + if (D->status == DASM_S_OK && secmatch >= 0 && + D->section != &D->sections[secmatch]) + D->status = DASM_S_MATCH_SEC|(D->section-D->sections); + return D->status; +} +#endif + + +``` + +`include/luajit-2.0.5/dynasm/dasm_arm.lua`: + +```lua +------------------------------------------------------------------------------ +-- DynASM ARM module. +-- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- See dynasm.lua for full copyright notice. +------------------------------------------------------------------------------ + +-- Module information: +local _info = { + arch = "arm", + description = "DynASM ARM module", + version = "1.3.0", + vernum = 10300, + release = "2011-05-05", + author = "Mike Pall", + license = "MIT", +} + +-- Exported glue functions for the arch-specific module. +local _M = { _info = _info } + +-- Cache library functions. +local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs +local assert, setmetatable, rawget = assert, setmetatable, rawget +local _s = string +local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char +local match, gmatch, gsub = _s.match, _s.gmatch, _s.gsub +local concat, sort, insert = table.concat, table.sort, table.insert +local bit = bit or require("bit") +local band, shl, shr, sar = bit.band, bit.lshift, bit.rshift, bit.arshift +local ror, tohex = bit.ror, bit.tohex + +-- Inherited tables and callbacks. +local g_opt, g_arch +local wline, werror, wfatal, wwarn + +-- Action name list. +-- CHECK: Keep this in sync with the C code! +local action_names = { + "STOP", "SECTION", "ESC", "REL_EXT", + "ALIGN", "REL_LG", "LABEL_LG", + "REL_PC", "LABEL_PC", "IMM", "IMM12", "IMM16", "IMML8", "IMML12", "IMMV8", +} + +-- Maximum number of section buffer positions for dasm_put(). +-- CHECK: Keep this in sync with the C code! +local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. + +-- Action name -> action number. +local map_action = {} +for n,name in ipairs(action_names) do + map_action[name] = n-1 +end + +-- Action list buffer. +local actlist = {} + +-- Argument list for next dasm_put(). Start with offset 0 into action list. +local actargs = { 0 } + +-- Current number of section buffer positions for dasm_put(). +local secpos = 1 + +------------------------------------------------------------------------------ + +-- Dump action names and numbers. +local function dumpactions(out) + out:write("DynASM encoding engine action codes:\n") + for n,name in ipairs(action_names) do + local num = map_action[name] + out:write(format(" %-10s %02X %d\n", name, num, num)) + end + out:write("\n") +end + +-- Write action list buffer as a huge static C array. +local function writeactions(out, name) + local nn = #actlist + if nn == 0 then nn = 1; actlist[0] = map_action.STOP end + out:write("static const unsigned int ", name, "[", nn, "] = {\n") + for i = 1,nn-1 do + assert(out:write("0x", tohex(actlist[i]), ",\n")) + end + assert(out:write("0x", tohex(actlist[nn]), "\n};\n\n")) +end + +------------------------------------------------------------------------------ + +-- Add word to action list. +local function wputxw(n) + assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") + actlist[#actlist+1] = n +end + +-- Add action to list with optional arg. Advance buffer pos, too. +local function waction(action, val, a, num) + local w = assert(map_action[action], "bad action name `"..action.."'") + wputxw(w * 0x10000 + (val or 0)) + if a then actargs[#actargs+1] = a end + if a or num then secpos = secpos + (num or 1) end +end + +-- Flush action list (intervening C code or buffer pos overflow). +local function wflush(term) + if #actlist == actargs[1] then return end -- Nothing to flush. + if not term then waction("STOP") end -- Terminate action list. + wline(format("dasm_put(Dst, %s);", concat(actargs, ", ")), true) + actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). + secpos = 1 -- The actionlist offset occupies a buffer position, too. +end + +-- Put escaped word. +local function wputw(n) + if n <= 0x000fffff then waction("ESC") end + wputxw(n) +end + +-- Reserve position for word. +local function wpos() + local pos = #actlist+1 + actlist[pos] = "" + return pos +end + +-- Store word to reserved position. +local function wputpos(pos, n) + assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") + if n <= 0x000fffff then + insert(actlist, pos+1, n) + n = map_action.ESC * 0x10000 + end + actlist[pos] = n +end + +------------------------------------------------------------------------------ + +-- Global label name -> global label number. With auto assignment on 1st use. +local next_global = 20 +local map_global = setmetatable({}, { __index = function(t, name) + if not match(name, "^[%a_][%w_]*$") then werror("bad global label") end + local n = next_global + if n > 2047 then werror("too many global labels") end + next_global = n + 1 + t[name] = n + return n +end}) + +-- Dump global labels. +local function dumpglobals(out, lvl) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("Global labels:\n") + for i=20,next_global-1 do + out:write(format(" %s\n", t[i])) + end + out:write("\n") +end + +-- Write global label enum. +local function writeglobals(out, prefix) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("enum {\n") + for i=20,next_global-1 do + out:write(" ", prefix, t[i], ",\n") + end + out:write(" ", prefix, "_MAX\n};\n") +end + +-- Write global label names. +local function writeglobalnames(out, name) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("static const char *const ", name, "[] = {\n") + for i=20,next_global-1 do + out:write(" \"", t[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Extern label name -> extern label number. With auto assignment on 1st use. +local next_extern = 0 +local map_extern_ = {} +local map_extern = setmetatable({}, { __index = function(t, name) + -- No restrictions on the name for now. + local n = next_extern + if n > 2047 then werror("too many extern labels") end + next_extern = n + 1 + t[name] = n + map_extern_[n] = name + return n +end}) + +-- Dump extern labels. +local function dumpexterns(out, lvl) + out:write("Extern labels:\n") + for i=0,next_extern-1 do + out:write(format(" %s\n", map_extern_[i])) + end + out:write("\n") +end + +-- Write extern label names. +local function writeexternnames(out, name) + out:write("static const char *const ", name, "[] = {\n") + for i=0,next_extern-1 do + out:write(" \"", map_extern_[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Arch-specific maps. + +-- Ext. register name -> int. name. +local map_archdef = { sp = "r13", lr = "r14", pc = "r15", } + +-- Int. register name -> ext. name. +local map_reg_rev = { r13 = "sp", r14 = "lr", r15 = "pc", } + +local map_type = {} -- Type name -> { ctype, reg } +local ctypenum = 0 -- Type number (for Dt... macros). + +-- Reverse defines for registers. +function _M.revdef(s) + return map_reg_rev[s] or s +end + +local map_shift = { lsl = 0, lsr = 1, asr = 2, ror = 3, } + +local map_cond = { + eq = 0, ne = 1, cs = 2, cc = 3, mi = 4, pl = 5, vs = 6, vc = 7, + hi = 8, ls = 9, ge = 10, lt = 11, gt = 12, le = 13, al = 14, + hs = 2, lo = 3, +} + +------------------------------------------------------------------------------ + +-- Template strings for ARM instructions. +local map_op = { + -- Basic data processing instructions. + and_3 = "e0000000DNPs", + eor_3 = "e0200000DNPs", + sub_3 = "e0400000DNPs", + rsb_3 = "e0600000DNPs", + add_3 = "e0800000DNPs", + adc_3 = "e0a00000DNPs", + sbc_3 = "e0c00000DNPs", + rsc_3 = "e0e00000DNPs", + tst_2 = "e1100000NP", + teq_2 = "e1300000NP", + cmp_2 = "e1500000NP", + cmn_2 = "e1700000NP", + orr_3 = "e1800000DNPs", + mov_2 = "e1a00000DPs", + bic_3 = "e1c00000DNPs", + mvn_2 = "e1e00000DPs", + + and_4 = "e0000000DNMps", + eor_4 = "e0200000DNMps", + sub_4 = "e0400000DNMps", + rsb_4 = "e0600000DNMps", + add_4 = "e0800000DNMps", + adc_4 = "e0a00000DNMps", + sbc_4 = "e0c00000DNMps", + rsc_4 = "e0e00000DNMps", + tst_3 = "e1100000NMp", + teq_3 = "e1300000NMp", + cmp_3 = "e1500000NMp", + cmn_3 = "e1700000NMp", + orr_4 = "e1800000DNMps", + mov_3 = "e1a00000DMps", + bic_4 = "e1c00000DNMps", + mvn_3 = "e1e00000DMps", + + lsl_3 = "e1a00000DMws", + lsr_3 = "e1a00020DMws", + asr_3 = "e1a00040DMws", + ror_3 = "e1a00060DMws", + rrx_2 = "e1a00060DMs", + + -- Multiply and multiply-accumulate. + mul_3 = "e0000090NMSs", + mla_4 = "e0200090NMSDs", + umaal_4 = "e0400090DNMSs", -- v6 + mls_4 = "e0600090DNMSs", -- v6T2 + umull_4 = "e0800090DNMSs", + umlal_4 = "e0a00090DNMSs", + smull_4 = "e0c00090DNMSs", + smlal_4 = "e0e00090DNMSs", + + -- Halfword multiply and multiply-accumulate. + smlabb_4 = "e1000080NMSD", -- v5TE + smlatb_4 = "e10000a0NMSD", -- v5TE + smlabt_4 = "e10000c0NMSD", -- v5TE + smlatt_4 = "e10000e0NMSD", -- v5TE + smlawb_4 = "e1200080NMSD", -- v5TE + smulwb_3 = "e12000a0NMS", -- v5TE + smlawt_4 = "e12000c0NMSD", -- v5TE + smulwt_3 = "e12000e0NMS", -- v5TE + smlalbb_4 = "e1400080NMSD", -- v5TE + smlaltb_4 = "e14000a0NMSD", -- v5TE + smlalbt_4 = "e14000c0NMSD", -- v5TE + smlaltt_4 = "e14000e0NMSD", -- v5TE + smulbb_3 = "e1600080NMS", -- v5TE + smultb_3 = "e16000a0NMS", -- v5TE + smulbt_3 = "e16000c0NMS", -- v5TE + smultt_3 = "e16000e0NMS", -- v5TE + + -- Miscellaneous data processing instructions. + clz_2 = "e16f0f10DM", -- v5T + rev_2 = "e6bf0f30DM", -- v6 + rev16_2 = "e6bf0fb0DM", -- v6 + revsh_2 = "e6ff0fb0DM", -- v6 + sel_3 = "e6800fb0DNM", -- v6 + usad8_3 = "e780f010NMS", -- v6 + usada8_4 = "e7800010NMSD", -- v6 + rbit_2 = "e6ff0f30DM", -- v6T2 + movw_2 = "e3000000DW", -- v6T2 + movt_2 = "e3400000DW", -- v6T2 + -- Note: the X encodes width-1, not width. + sbfx_4 = "e7a00050DMvX", -- v6T2 + ubfx_4 = "e7e00050DMvX", -- v6T2 + -- Note: the X encodes the msb field, not the width. + bfc_3 = "e7c0001fDvX", -- v6T2 + bfi_4 = "e7c00010DMvX", -- v6T2 + + -- Packing and unpacking instructions. + pkhbt_3 = "e6800010DNM", pkhbt_4 = "e6800010DNMv", -- v6 + pkhtb_3 = "e6800050DNM", pkhtb_4 = "e6800050DNMv", -- v6 + sxtab_3 = "e6a00070DNM", sxtab_4 = "e6a00070DNMv", -- v6 + sxtab16_3 = "e6800070DNM", sxtab16_4 = "e6800070DNMv", -- v6 + sxtah_3 = "e6b00070DNM", sxtah_4 = "e6b00070DNMv", -- v6 + sxtb_2 = "e6af0070DM", sxtb_3 = "e6af0070DMv", -- v6 + sxtb16_2 = "e68f0070DM", sxtb16_3 = "e68f0070DMv", -- v6 + sxth_2 = "e6bf0070DM", sxth_3 = "e6bf0070DMv", -- v6 + uxtab_3 = "e6e00070DNM", uxtab_4 = "e6e00070DNMv", -- v6 + uxtab16_3 = "e6c00070DNM", uxtab16_4 = "e6c00070DNMv", -- v6 + uxtah_3 = "e6f00070DNM", uxtah_4 = "e6f00070DNMv", -- v6 + uxtb_2 = "e6ef0070DM", uxtb_3 = "e6ef0070DMv", -- v6 + uxtb16_2 = "e6cf0070DM", uxtb16_3 = "e6cf0070DMv", -- v6 + uxth_2 = "e6ff0070DM", uxth_3 = "e6ff0070DMv", -- v6 + + -- Saturating instructions. + qadd_3 = "e1000050DMN", -- v5TE + qsub_3 = "e1200050DMN", -- v5TE + qdadd_3 = "e1400050DMN", -- v5TE + qdsub_3 = "e1600050DMN", -- v5TE + -- Note: the X for ssat* encodes sat_imm-1, not sat_imm. + ssat_3 = "e6a00010DXM", ssat_4 = "e6a00010DXMp", -- v6 + usat_3 = "e6e00010DXM", usat_4 = "e6e00010DXMp", -- v6 + ssat16_3 = "e6a00f30DXM", -- v6 + usat16_3 = "e6e00f30DXM", -- v6 + + -- Parallel addition and subtraction. + sadd16_3 = "e6100f10DNM", -- v6 + sasx_3 = "e6100f30DNM", -- v6 + ssax_3 = "e6100f50DNM", -- v6 + ssub16_3 = "e6100f70DNM", -- v6 + sadd8_3 = "e6100f90DNM", -- v6 + ssub8_3 = "e6100ff0DNM", -- v6 + qadd16_3 = "e6200f10DNM", -- v6 + qasx_3 = "e6200f30DNM", -- v6 + qsax_3 = "e6200f50DNM", -- v6 + qsub16_3 = "e6200f70DNM", -- v6 + qadd8_3 = "e6200f90DNM", -- v6 + qsub8_3 = "e6200ff0DNM", -- v6 + shadd16_3 = "e6300f10DNM", -- v6 + shasx_3 = "e6300f30DNM", -- v6 + shsax_3 = "e6300f50DNM", -- v6 + shsub16_3 = "e6300f70DNM", -- v6 + shadd8_3 = "e6300f90DNM", -- v6 + shsub8_3 = "e6300ff0DNM", -- v6 + uadd16_3 = "e6500f10DNM", -- v6 + uasx_3 = "e6500f30DNM", -- v6 + usax_3 = "e6500f50DNM", -- v6 + usub16_3 = "e6500f70DNM", -- v6 + uadd8_3 = "e6500f90DNM", -- v6 + usub8_3 = "e6500ff0DNM", -- v6 + uqadd16_3 = "e6600f10DNM", -- v6 + uqasx_3 = "e6600f30DNM", -- v6 + uqsax_3 = "e6600f50DNM", -- v6 + uqsub16_3 = "e6600f70DNM", -- v6 + uqadd8_3 = "e6600f90DNM", -- v6 + uqsub8_3 = "e6600ff0DNM", -- v6 + uhadd16_3 = "e6700f10DNM", -- v6 + uhasx_3 = "e6700f30DNM", -- v6 + uhsax_3 = "e6700f50DNM", -- v6 + uhsub16_3 = "e6700f70DNM", -- v6 + uhadd8_3 = "e6700f90DNM", -- v6 + uhsub8_3 = "e6700ff0DNM", -- v6 + + -- Load/store instructions. + str_2 = "e4000000DL", str_3 = "e4000000DL", str_4 = "e4000000DL", + strb_2 = "e4400000DL", strb_3 = "e4400000DL", strb_4 = "e4400000DL", + ldr_2 = "e4100000DL", ldr_3 = "e4100000DL", ldr_4 = "e4100000DL", + ldrb_2 = "e4500000DL", ldrb_3 = "e4500000DL", ldrb_4 = "e4500000DL", + strh_2 = "e00000b0DL", strh_3 = "e00000b0DL", + ldrh_2 = "e01000b0DL", ldrh_3 = "e01000b0DL", + ldrd_2 = "e00000d0DL", ldrd_3 = "e00000d0DL", -- v5TE + ldrsb_2 = "e01000d0DL", ldrsb_3 = "e01000d0DL", + strd_2 = "e00000f0DL", strd_3 = "e00000f0DL", -- v5TE + ldrsh_2 = "e01000f0DL", ldrsh_3 = "e01000f0DL", + + ldm_2 = "e8900000oR", ldmia_2 = "e8900000oR", ldmfd_2 = "e8900000oR", + ldmda_2 = "e8100000oR", ldmfa_2 = "e8100000oR", + ldmdb_2 = "e9100000oR", ldmea_2 = "e9100000oR", + ldmib_2 = "e9900000oR", ldmed_2 = "e9900000oR", + stm_2 = "e8800000oR", stmia_2 = "e8800000oR", stmfd_2 = "e8800000oR", + stmda_2 = "e8000000oR", stmfa_2 = "e8000000oR", + stmdb_2 = "e9000000oR", stmea_2 = "e9000000oR", + stmib_2 = "e9800000oR", stmed_2 = "e9800000oR", + pop_1 = "e8bd0000R", push_1 = "e92d0000R", + + -- Branch instructions. + b_1 = "ea000000B", + bl_1 = "eb000000B", + blx_1 = "e12fff30C", + bx_1 = "e12fff10M", + + -- Miscellaneous instructions. + nop_0 = "e1a00000", + mrs_1 = "e10f0000D", + bkpt_1 = "e1200070K", -- v5T + svc_1 = "ef000000T", swi_1 = "ef000000T", + ud_0 = "e7f001f0", + + -- VFP instructions. + ["vadd.f32_3"] = "ee300a00dnm", + ["vadd.f64_3"] = "ee300b00Gdnm", + ["vsub.f32_3"] = "ee300a40dnm", + ["vsub.f64_3"] = "ee300b40Gdnm", + ["vmul.f32_3"] = "ee200a00dnm", + ["vmul.f64_3"] = "ee200b00Gdnm", + ["vnmul.f32_3"] = "ee200a40dnm", + ["vnmul.f64_3"] = "ee200b40Gdnm", + ["vmla.f32_3"] = "ee000a00dnm", + ["vmla.f64_3"] = "ee000b00Gdnm", + ["vmls.f32_3"] = "ee000a40dnm", + ["vmls.f64_3"] = "ee000b40Gdnm", + ["vnmla.f32_3"] = "ee100a40dnm", + ["vnmla.f64_3"] = "ee100b40Gdnm", + ["vnmls.f32_3"] = "ee100a00dnm", + ["vnmls.f64_3"] = "ee100b00Gdnm", + ["vdiv.f32_3"] = "ee800a00dnm", + ["vdiv.f64_3"] = "ee800b00Gdnm", + + ["vabs.f32_2"] = "eeb00ac0dm", + ["vabs.f64_2"] = "eeb00bc0Gdm", + ["vneg.f32_2"] = "eeb10a40dm", + ["vneg.f64_2"] = "eeb10b40Gdm", + ["vsqrt.f32_2"] = "eeb10ac0dm", + ["vsqrt.f64_2"] = "eeb10bc0Gdm", + ["vcmp.f32_2"] = "eeb40a40dm", + ["vcmp.f64_2"] = "eeb40b40Gdm", + ["vcmpe.f32_2"] = "eeb40ac0dm", + ["vcmpe.f64_2"] = "eeb40bc0Gdm", + ["vcmpz.f32_1"] = "eeb50a40d", + ["vcmpz.f64_1"] = "eeb50b40Gd", + ["vcmpze.f32_1"] = "eeb50ac0d", + ["vcmpze.f64_1"] = "eeb50bc0Gd", + + vldr_2 = "ed100a00dl|ed100b00Gdl", + vstr_2 = "ed000a00dl|ed000b00Gdl", + vldm_2 = "ec900a00or", + vldmia_2 = "ec900a00or", + vldmdb_2 = "ed100a00or", + vpop_1 = "ecbd0a00r", + vstm_2 = "ec800a00or", + vstmia_2 = "ec800a00or", + vstmdb_2 = "ed000a00or", + vpush_1 = "ed2d0a00r", + + ["vmov.f32_2"] = "eeb00a40dm|eeb00a00dY", -- #imm is VFPv3 only + ["vmov.f64_2"] = "eeb00b40Gdm|eeb00b00GdY", -- #imm is VFPv3 only + vmov_2 = "ee100a10Dn|ee000a10nD", + vmov_3 = "ec500a10DNm|ec400a10mDN|ec500b10GDNm|ec400b10GmDN", + + vmrs_0 = "eef1fa10", + vmrs_1 = "eef10a10D", + vmsr_1 = "eee10a10D", + + ["vcvt.s32.f32_2"] = "eebd0ac0dm", + ["vcvt.s32.f64_2"] = "eebd0bc0dGm", + ["vcvt.u32.f32_2"] = "eebc0ac0dm", + ["vcvt.u32.f64_2"] = "eebc0bc0dGm", + ["vcvtr.s32.f32_2"] = "eebd0a40dm", + ["vcvtr.s32.f64_2"] = "eebd0b40dGm", + ["vcvtr.u32.f32_2"] = "eebc0a40dm", + ["vcvtr.u32.f64_2"] = "eebc0b40dGm", + ["vcvt.f32.s32_2"] = "eeb80ac0dm", + ["vcvt.f64.s32_2"] = "eeb80bc0GdFm", + ["vcvt.f32.u32_2"] = "eeb80a40dm", + ["vcvt.f64.u32_2"] = "eeb80b40GdFm", + ["vcvt.f32.f64_2"] = "eeb70bc0dGm", + ["vcvt.f64.f32_2"] = "eeb70ac0GdFm", + + -- VFPv4 only: + ["vfma.f32_3"] = "eea00a00dnm", + ["vfma.f64_3"] = "eea00b00Gdnm", + ["vfms.f32_3"] = "eea00a40dnm", + ["vfms.f64_3"] = "eea00b40Gdnm", + ["vfnma.f32_3"] = "ee900a40dnm", + ["vfnma.f64_3"] = "ee900b40Gdnm", + ["vfnms.f32_3"] = "ee900a00dnm", + ["vfnms.f64_3"] = "ee900b00Gdnm", + + -- NYI: Advanced SIMD instructions. + + -- NYI: I have no need for these instructions right now: + -- swp, swpb, strex, ldrex, strexd, ldrexd, strexb, ldrexb, strexh, ldrexh + -- msr, nopv6, yield, wfe, wfi, sev, dbg, bxj, smc, srs, rfe + -- cps, setend, pli, pld, pldw, clrex, dsb, dmb, isb + -- stc, ldc, mcr, mcr2, mrc, mrc2, mcrr, mcrr2, mrrc, mrrc2, cdp, cdp2 +} + +-- Add mnemonics for "s" variants. +do + local t = {} + for k,v in pairs(map_op) do + if sub(v, -1) == "s" then + local v2 = sub(v, 1, 2)..char(byte(v, 3)+1)..sub(v, 4, -2) + t[sub(k, 1, -3).."s"..sub(k, -2)] = v2 + end + end + for k,v in pairs(t) do + map_op[k] = v + end +end + +------------------------------------------------------------------------------ + +local function parse_gpr(expr) + local tname, ovreg = match(expr, "^([%w_]+):(r1?[0-9])$") + local tp = map_type[tname or expr] + if tp then + local reg = ovreg or tp.reg + if not reg then + werror("type `"..(tname or expr).."' needs a register override") + end + expr = reg + end + local r = match(expr, "^r(1?[0-9])$") + if r then + r = tonumber(r) + if r <= 15 then return r, tp end + end + werror("bad register name `"..expr.."'") +end + +local function parse_gpr_pm(expr) + local pm, expr2 = match(expr, "^([+-]?)(.*)$") + return parse_gpr(expr2), (pm == "-") +end + +local function parse_vr(expr, tp) + local t, r = match(expr, "^([sd])([0-9]+)$") + if t == tp then + r = tonumber(r) + if r <= 31 then + if t == "s" then return shr(r, 1), band(r, 1) end + return band(r, 15), shr(r, 4) + end + end + werror("bad register name `"..expr.."'") +end + +local function parse_reglist(reglist) + reglist = match(reglist, "^{%s*([^}]*)}$") + if not reglist then werror("register list expected") end + local rr = 0 + for p in gmatch(reglist..",", "%s*([^,]*),") do + local rbit = shl(1, parse_gpr(gsub(p, "%s+$", ""))) + if band(rr, rbit) ~= 0 then + werror("duplicate register `"..p.."'") + end + rr = rr + rbit + end + return rr +end + +local function parse_vrlist(reglist) + local ta, ra, tb, rb = match(reglist, + "^{%s*([sd])([0-9]+)%s*%-%s*([sd])([0-9]+)%s*}$") + ra, rb = tonumber(ra), tonumber(rb) + if ta and ta == tb and ra and rb and ra <= 31 and rb <= 31 and ra <= rb then + local nr = rb+1 - ra + if ta == "s" then + return shl(shr(ra,1),12)+shl(band(ra,1),22) + nr + else + return shl(band(ra,15),12)+shl(shr(ra,4),22) + nr*2 + 0x100 + end + end + werror("register list expected") +end + +local function parse_imm(imm, bits, shift, scale, signed) + imm = match(imm, "^#(.*)$") + if not imm then werror("expected immediate operand") end + local n = tonumber(imm) + if n then + local m = sar(n, scale) + if shl(m, scale) == n then + if signed then + local s = sar(m, bits-1) + if s == 0 then return shl(m, shift) + elseif s == -1 then return shl(m + shl(1, bits), shift) end + else + if sar(m, bits) == 0 then return shl(m, shift) end + end + end + werror("out of range immediate `"..imm.."'") + else + waction("IMM", (signed and 32768 or 0)+scale*1024+bits*32+shift, imm) + return 0 + end +end + +local function parse_imm12(imm) + local n = tonumber(imm) + if n then + local m = band(n) + for i=0,-15,-1 do + if shr(m, 8) == 0 then return m + shl(band(i, 15), 8) end + m = ror(m, 2) + end + werror("out of range immediate `"..imm.."'") + else + waction("IMM12", 0, imm) + return 0 + end +end + +local function parse_imm16(imm) + imm = match(imm, "^#(.*)$") + if not imm then werror("expected immediate operand") end + local n = tonumber(imm) + if n then + if shr(n, 16) == 0 then return band(n, 0x0fff) + shl(band(n, 0xf000), 4) end + werror("out of range immediate `"..imm.."'") + else + waction("IMM16", 32*16, imm) + return 0 + end +end + +local function parse_imm_load(imm, ext) + local n = tonumber(imm) + if n then + if ext then + if n >= -255 and n <= 255 then + local up = 0x00800000 + if n < 0 then n = -n; up = 0 end + return shl(band(n, 0xf0), 4) + band(n, 0x0f) + up + end + else + if n >= -4095 and n <= 4095 then + if n >= 0 then return n+0x00800000 end + return -n + end + end + werror("out of range immediate `"..imm.."'") + else + waction(ext and "IMML8" or "IMML12", 32768 + shl(ext and 8 or 12, 5), imm) + return 0 + end +end + +local function parse_shift(shift, gprok) + if shift == "rrx" then + return 3 * 32 + else + local s, s2 = match(shift, "^(%S+)%s*(.*)$") + s = map_shift[s] + if not s then werror("expected shift operand") end + if sub(s2, 1, 1) == "#" then + return parse_imm(s2, 5, 7, 0, false) + shl(s, 5) + else + if not gprok then werror("expected immediate shift operand") end + return shl(parse_gpr(s2), 8) + shl(s, 5) + 16 + end + end +end + +local function parse_label(label, def) + local prefix = sub(label, 1, 2) + -- =>label (pc label reference) + if prefix == "=>" then + return "PC", 0, sub(label, 3) + end + -- ->name (global label reference) + if prefix == "->" then + return "LG", map_global[sub(label, 3)] + end + if def then + -- [1-9] (local label definition) + if match(label, "^[1-9]$") then + return "LG", 10+tonumber(label) + end + else + -- [<>][1-9] (local label reference) + local dir, lnum = match(label, "^([<>])([1-9])$") + if dir then -- Fwd: 1-9, Bkwd: 11-19. + return "LG", lnum + (dir == ">" and 0 or 10) + end + -- extern label (extern label reference) + local extname = match(label, "^extern%s+(%S+)$") + if extname then + return "EXT", map_extern[extname] + end + end + werror("bad label `"..label.."'") +end + +local function parse_load(params, nparams, n, op) + local oplo = band(op, 255) + local ext, ldrd = (oplo ~= 0), (oplo == 208) + local d + if (ldrd or oplo == 240) then + d = band(shr(op, 12), 15) + if band(d, 1) ~= 0 then werror("odd destination register") end + end + local pn = params[n] + local p1, wb = match(pn, "^%[%s*(.-)%s*%](!?)$") + local p2 = params[n+1] + if not p1 then + if not p2 then + if match(pn, "^[<>=%-]") or match(pn, "^extern%s+") then + local mode, n, s = parse_label(pn, false) + waction("REL_"..mode, n + (ext and 0x1800 or 0x0800), s, 1) + return op + 15 * 65536 + 0x01000000 + (ext and 0x00400000 or 0) + end + local reg, tailr = match(pn, "^([%w_:]+)%s*(.*)$") + if reg and tailr ~= "" then + local d, tp = parse_gpr(reg) + if tp then + waction(ext and "IMML8" or "IMML12", 32768 + 32*(ext and 8 or 12), + format(tp.ctypefmt, tailr)) + return op + shl(d, 16) + 0x01000000 + (ext and 0x00400000 or 0) + end + end + end + werror("expected address operand") + end + if wb == "!" then op = op + 0x00200000 end + if p2 then + if wb == "!" then werror("bad use of '!'") end + local p3 = params[n+2] + op = op + shl(parse_gpr(p1), 16) + local imm = match(p2, "^#(.*)$") + if imm then + local m = parse_imm_load(imm, ext) + if p3 then werror("too many parameters") end + op = op + m + (ext and 0x00400000 or 0) + else + local m, neg = parse_gpr_pm(p2) + if ldrd and (m == d or m-1 == d) then werror("register conflict") end + op = op + m + (neg and 0 or 0x00800000) + (ext and 0 or 0x02000000) + if p3 then op = op + parse_shift(p3) end + end + else + local p1a, p2 = match(p1, "^([^,%s]*)%s*(.*)$") + op = op + shl(parse_gpr(p1a), 16) + 0x01000000 + if p2 ~= "" then + local imm = match(p2, "^,%s*#(.*)$") + if imm then + local m = parse_imm_load(imm, ext) + op = op + m + (ext and 0x00400000 or 0) + else + local p2a, p3 = match(p2, "^,%s*([^,%s]*)%s*,?%s*(.*)$") + local m, neg = parse_gpr_pm(p2a) + if ldrd and (m == d or m-1 == d) then werror("register conflict") end + op = op + m + (neg and 0 or 0x00800000) + (ext and 0 or 0x02000000) + if p3 ~= "" then + if ext then werror("too many parameters") end + op = op + parse_shift(p3) + end + end + else + if wb == "!" then werror("bad use of '!'") end + op = op + (ext and 0x00c00000 or 0x00800000) + end + end + return op +end + +local function parse_vload(q) + local reg, imm = match(q, "^%[%s*([^,%s]*)%s*(.*)%]$") + if reg then + local d = shl(parse_gpr(reg), 16) + if imm == "" then return d end + imm = match(imm, "^,%s*#(.*)$") + if imm then + local n = tonumber(imm) + if n then + if n >= -1020 and n <= 1020 and n%4 == 0 then + return d + (n >= 0 and n/4+0x00800000 or -n/4) + end + werror("out of range immediate `"..imm.."'") + else + waction("IMMV8", 32768 + 32*8, imm) + return d + end + end + else + if match(q, "^[<>=%-]") or match(q, "^extern%s+") then + local mode, n, s = parse_label(q, false) + waction("REL_"..mode, n + 0x2800, s, 1) + return 15 * 65536 + end + local reg, tailr = match(q, "^([%w_:]+)%s*(.*)$") + if reg and tailr ~= "" then + local d, tp = parse_gpr(reg) + if tp then + waction("IMMV8", 32768 + 32*8, format(tp.ctypefmt, tailr)) + return shl(d, 16) + end + end + end + werror("expected address operand") +end + +------------------------------------------------------------------------------ + +-- Handle opcodes defined with template strings. +local function parse_template(params, template, nparams, pos) + local op = tonumber(sub(template, 1, 8), 16) + local n = 1 + local vr = "s" + + -- Process each character. + for p in gmatch(sub(template, 9), ".") do + local q = params[n] + if p == "D" then + op = op + shl(parse_gpr(q), 12); n = n + 1 + elseif p == "N" then + op = op + shl(parse_gpr(q), 16); n = n + 1 + elseif p == "S" then + op = op + shl(parse_gpr(q), 8); n = n + 1 + elseif p == "M" then + op = op + parse_gpr(q); n = n + 1 + elseif p == "d" then + local r,h = parse_vr(q, vr); op = op+shl(r,12)+shl(h,22); n = n + 1 + elseif p == "n" then + local r,h = parse_vr(q, vr); op = op+shl(r,16)+shl(h,7); n = n + 1 + elseif p == "m" then + local r,h = parse_vr(q, vr); op = op+r+shl(h,5); n = n + 1 + elseif p == "P" then + local imm = match(q, "^#(.*)$") + if imm then + op = op + parse_imm12(imm) + 0x02000000 + else + op = op + parse_gpr(q) + end + n = n + 1 + elseif p == "p" then + op = op + parse_shift(q, true); n = n + 1 + elseif p == "L" then + op = parse_load(params, nparams, n, op) + elseif p == "l" then + op = op + parse_vload(q) + elseif p == "B" then + local mode, n, s = parse_label(q, false) + waction("REL_"..mode, n, s, 1) + elseif p == "C" then -- blx gpr vs. blx label. + if match(q, "^([%w_]+):(r1?[0-9])$") or match(q, "^r(1?[0-9])$") then + op = op + parse_gpr(q) + else + if op < 0xe0000000 then werror("unconditional instruction") end + local mode, n, s = parse_label(q, false) + waction("REL_"..mode, n, s, 1) + op = 0xfa000000 + end + elseif p == "F" then + vr = "s" + elseif p == "G" then + vr = "d" + elseif p == "o" then + local r, wb = match(q, "^([^!]*)(!?)$") + op = op + shl(parse_gpr(r), 16) + (wb == "!" and 0x00200000 or 0) + n = n + 1 + elseif p == "R" then + op = op + parse_reglist(q); n = n + 1 + elseif p == "r" then + op = op + parse_vrlist(q); n = n + 1 + elseif p == "W" then + op = op + parse_imm16(q); n = n + 1 + elseif p == "v" then + op = op + parse_imm(q, 5, 7, 0, false); n = n + 1 + elseif p == "w" then + local imm = match(q, "^#(.*)$") + if imm then + op = op + parse_imm(q, 5, 7, 0, false); n = n + 1 + else + op = op + shl(parse_gpr(q), 8) + 16 + end + elseif p == "X" then + op = op + parse_imm(q, 5, 16, 0, false); n = n + 1 + elseif p == "Y" then + local imm = tonumber(match(q, "^#(.*)$")); n = n + 1 + if not imm or shr(imm, 8) ~= 0 then + werror("bad immediate operand") + end + op = op + shl(band(imm, 0xf0), 12) + band(imm, 0x0f) + elseif p == "K" then + local imm = tonumber(match(q, "^#(.*)$")); n = n + 1 + if not imm or shr(imm, 16) ~= 0 then + werror("bad immediate operand") + end + op = op + shl(band(imm, 0xfff0), 4) + band(imm, 0x000f) + elseif p == "T" then + op = op + parse_imm(q, 24, 0, 0, false); n = n + 1 + elseif p == "s" then + -- Ignored. + else + assert(false) + end + end + wputpos(pos, op) +end + +map_op[".template__"] = function(params, template, nparams) + if not params then return template:gsub("%x%x%x%x%x%x%x%x", "") end + + -- Limit number of section buffer positions used by a single dasm_put(). + -- A single opcode needs a maximum of 3 positions. + if secpos+3 > maxsecpos then wflush() end + local pos = wpos() + local lpos, apos, spos = #actlist, #actargs, secpos + + local ok, err + for t in gmatch(template, "[^|]+") do + ok, err = pcall(parse_template, params, t, nparams, pos) + if ok then return end + secpos = spos + actlist[lpos+1] = nil + actlist[lpos+2] = nil + actlist[lpos+3] = nil + actargs[apos+1] = nil + actargs[apos+2] = nil + actargs[apos+3] = nil + end + error(err, 0) +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcode to mark the position where the action list is to be emitted. +map_op[".actionlist_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeactions(out, name) end) +end + +-- Pseudo-opcode to mark the position where the global enum is to be emitted. +map_op[".globals_1"] = function(params) + if not params then return "prefix" end + local prefix = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobals(out, prefix) end) +end + +-- Pseudo-opcode to mark the position where the global names are to be emitted. +map_op[".globalnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobalnames(out, name) end) +end + +-- Pseudo-opcode to mark the position where the extern names are to be emitted. +map_op[".externnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeexternnames(out, name) end) +end + +------------------------------------------------------------------------------ + +-- Label pseudo-opcode (converted from trailing colon form). +map_op[".label_1"] = function(params) + if not params then return "[1-9] | ->global | =>pcexpr" end + if secpos+1 > maxsecpos then wflush() end + local mode, n, s = parse_label(params[1], true) + if mode == "EXT" then werror("bad label definition") end + waction("LABEL_"..mode, n, s, 1) +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcodes for data storage. +map_op[".long_*"] = function(params) + if not params then return "imm..." end + for _,p in ipairs(params) do + local n = tonumber(p) + if not n then werror("bad immediate `"..p.."'") end + if n < 0 then n = n + 2^32 end + wputw(n) + if secpos+2 > maxsecpos then wflush() end + end +end + +-- Alignment pseudo-opcode. +map_op[".align_1"] = function(params) + if not params then return "numpow2" end + if secpos+1 > maxsecpos then wflush() end + local align = tonumber(params[1]) + if align then + local x = align + -- Must be a power of 2 in the range (2 ... 256). + for i=1,8 do + x = x / 2 + if x == 1 then + waction("ALIGN", align-1, nil, 1) -- Action byte is 2**n-1. + return + end + end + end + werror("bad alignment") +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcode for (primitive) type definitions (map to C types). +map_op[".type_3"] = function(params, nparams) + if not params then + return nparams == 2 and "name, ctype" or "name, ctype, reg" + end + local name, ctype, reg = params[1], params[2], params[3] + if not match(name, "^[%a_][%w_]*$") then + werror("bad type name `"..name.."'") + end + local tp = map_type[name] + if tp then + werror("duplicate type `"..name.."'") + end + -- Add #type to defines. A bit unclean to put it in map_archdef. + map_archdef["#"..name] = "sizeof("..ctype..")" + -- Add new type and emit shortcut define. + local num = ctypenum + 1 + map_type[name] = { + ctype = ctype, + ctypefmt = format("Dt%X(%%s)", num), + reg = reg, + } + wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) + ctypenum = num +end +map_op[".type_2"] = map_op[".type_3"] + +-- Dump type definitions. +local function dumptypes(out, lvl) + local t = {} + for name in pairs(map_type) do t[#t+1] = name end + sort(t) + out:write("Type definitions:\n") + for _,name in ipairs(t) do + local tp = map_type[name] + local reg = tp.reg or "" + out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) + end + out:write("\n") +end + +------------------------------------------------------------------------------ + +-- Set the current section. +function _M.section(num) + waction("SECTION", num) + wflush(true) -- SECTION is a terminal action. +end + +------------------------------------------------------------------------------ + +-- Dump architecture description. +function _M.dumparch(out) + out:write(format("DynASM %s version %s, released %s\n\n", + _info.arch, _info.version, _info.release)) + dumpactions(out) +end + +-- Dump all user defined elements. +function _M.dumpdef(out, lvl) + dumptypes(out, lvl) + dumpglobals(out, lvl) + dumpexterns(out, lvl) +end + +------------------------------------------------------------------------------ + +-- Pass callbacks from/to the DynASM core. +function _M.passcb(wl, we, wf, ww) + wline, werror, wfatal, wwarn = wl, we, wf, ww + return wflush +end + +-- Setup the arch-specific module. +function _M.setup(arch, opt) + g_arch, g_opt = arch, opt +end + +-- Merge the core maps and the arch-specific maps. +function _M.mergemaps(map_coreop, map_def) + setmetatable(map_op, { __index = function(t, k) + local v = map_coreop[k] + if v then return v end + local k1, cc, k2 = match(k, "^(.-)(..)([._].*)$") + local cv = map_cond[cc] + if cv then + local v = rawget(t, k1..k2) + if type(v) == "string" then + local scv = format("%x", cv) + return gsub(scv..sub(v, 2), "|e", "|"..scv) + end + end + end }) + setmetatable(map_def, { __index = map_archdef }) + return map_op, map_def +end + +return _M + +------------------------------------------------------------------------------ + + +``` + +`include/luajit-2.0.5/dynasm/dasm_mips.h`: + +```h +/* +** DynASM MIPS encoding engine. +** Copyright (C) 2005-2017 Mike Pall. All rights reserved. +** Released under the MIT license. See dynasm.lua for full copyright notice. +*/ + +#include +#include +#include +#include + +#define DASM_ARCH "mips" + +#ifndef DASM_EXTERN +#define DASM_EXTERN(a,b,c,d) 0 +#endif + +/* Action definitions. */ +enum { + DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT, + /* The following actions need a buffer position. */ + DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG, + /* The following actions also have an argument. */ + DASM_REL_PC, DASM_LABEL_PC, DASM_IMM, + DASM__MAX +}; + +/* Maximum number of section buffer positions for a single dasm_put() call. */ +#define DASM_MAXSECPOS 25 + +/* DynASM encoder status codes. Action list offset or number are or'ed in. */ +#define DASM_S_OK 0x00000000 +#define DASM_S_NOMEM 0x01000000 +#define DASM_S_PHASE 0x02000000 +#define DASM_S_MATCH_SEC 0x03000000 +#define DASM_S_RANGE_I 0x11000000 +#define DASM_S_RANGE_SEC 0x12000000 +#define DASM_S_RANGE_LG 0x13000000 +#define DASM_S_RANGE_PC 0x14000000 +#define DASM_S_RANGE_REL 0x15000000 +#define DASM_S_UNDEF_LG 0x21000000 +#define DASM_S_UNDEF_PC 0x22000000 + +/* Macros to convert positions (8 bit section + 24 bit index). */ +#define DASM_POS2IDX(pos) ((pos)&0x00ffffff) +#define DASM_POS2BIAS(pos) ((pos)&0xff000000) +#define DASM_SEC2POS(sec) ((sec)<<24) +#define DASM_POS2SEC(pos) ((pos)>>24) +#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) + +/* Action list type. */ +typedef const unsigned int *dasm_ActList; + +/* Per-section structure. */ +typedef struct dasm_Section { + int *rbuf; /* Biased buffer pointer (negative section bias). */ + int *buf; /* True buffer pointer. */ + size_t bsize; /* Buffer size in bytes. */ + int pos; /* Biased buffer position. */ + int epos; /* End of biased buffer position - max single put. */ + int ofs; /* Byte offset into section. */ +} dasm_Section; + +/* Core structure holding the DynASM encoding state. */ +struct dasm_State { + size_t psize; /* Allocated size of this structure. */ + dasm_ActList actionlist; /* Current actionlist pointer. */ + int *lglabels; /* Local/global chain/pos ptrs. */ + size_t lgsize; + int *pclabels; /* PC label chains/pos ptrs. */ + size_t pcsize; + void **globals; /* Array of globals (bias -10). */ + dasm_Section *section; /* Pointer to active section. */ + size_t codesize; /* Total size of all code sections. */ + int maxsection; /* 0 <= sectionidx < maxsection. */ + int status; /* Status code. */ + dasm_Section sections[1]; /* All sections. Alloc-extended. */ +}; + +/* The size of the core structure depends on the max. number of sections. */ +#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) + + +/* Initialize DynASM state. */ +void dasm_init(Dst_DECL, int maxsection) +{ + dasm_State *D; + size_t psz = 0; + int i; + Dst_REF = NULL; + DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); + D = Dst_REF; + D->psize = psz; + D->lglabels = NULL; + D->lgsize = 0; + D->pclabels = NULL; + D->pcsize = 0; + D->globals = NULL; + D->maxsection = maxsection; + for (i = 0; i < maxsection; i++) { + D->sections[i].buf = NULL; /* Need this for pass3. */ + D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); + D->sections[i].bsize = 0; + D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ + } +} + +/* Free DynASM state. */ +void dasm_free(Dst_DECL) +{ + dasm_State *D = Dst_REF; + int i; + for (i = 0; i < D->maxsection; i++) + if (D->sections[i].buf) + DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); + if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); + if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); + DASM_M_FREE(Dst, D, D->psize); +} + +/* Setup global label array. Must be called before dasm_setup(). */ +void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) +{ + dasm_State *D = Dst_REF; + D->globals = gl - 10; /* Negative bias to compensate for locals. */ + DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); +} + +/* Grow PC label array. Can be called after dasm_setup(), too. */ +void dasm_growpc(Dst_DECL, unsigned int maxpc) +{ + dasm_State *D = Dst_REF; + size_t osz = D->pcsize; + DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); + memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); +} + +/* Setup encoder. */ +void dasm_setup(Dst_DECL, const void *actionlist) +{ + dasm_State *D = Dst_REF; + int i; + D->actionlist = (dasm_ActList)actionlist; + D->status = DASM_S_OK; + D->section = &D->sections[0]; + memset((void *)D->lglabels, 0, D->lgsize); + if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); + for (i = 0; i < D->maxsection; i++) { + D->sections[i].pos = DASM_SEC2POS(i); + D->sections[i].ofs = 0; + } +} + + +#ifdef DASM_CHECKS +#define CK(x, st) \ + do { if (!(x)) { \ + D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0) +#define CKPL(kind, st) \ + do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ + D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0) +#else +#define CK(x, st) ((void)0) +#define CKPL(kind, st) ((void)0) +#endif + +/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ +void dasm_put(Dst_DECL, int start, ...) +{ + va_list ap; + dasm_State *D = Dst_REF; + dasm_ActList p = D->actionlist + start; + dasm_Section *sec = D->section; + int pos = sec->pos, ofs = sec->ofs; + int *b; + + if (pos >= sec->epos) { + DASM_M_GROW(Dst, int, sec->buf, sec->bsize, + sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); + sec->rbuf = sec->buf - DASM_POS2BIAS(pos); + sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); + } + + b = sec->rbuf; + b[pos++] = start; + + va_start(ap, start); + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16) - 0xff00; + if (action >= DASM__MAX) { + ofs += 4; + } else { + int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0; + switch (action) { + case DASM_STOP: goto stop; + case DASM_SECTION: + n = (ins & 255); CK(n < D->maxsection, RANGE_SEC); + D->section = &D->sections[n]; goto stop; + case DASM_ESC: p++; ofs += 4; break; + case DASM_REL_EXT: break; + case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break; + case DASM_REL_LG: + n = (ins & 2047) - 10; pl = D->lglabels + n; + /* Bkwd rel or global. */ + if (n >= 0) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; } + pl += 10; n = *pl; + if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ + goto linkrel; + case DASM_REL_PC: + pl = D->pclabels + n; CKPL(pc, PC); + putrel: + n = *pl; + if (n < 0) { /* Label exists. Get label pos and store it. */ + b[pos] = -n; + } else { + linkrel: + b[pos] = n; /* Else link to rel chain, anchored at label. */ + *pl = pos; + } + pos++; + break; + case DASM_LABEL_LG: + pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel; + case DASM_LABEL_PC: + pl = D->pclabels + n; CKPL(pc, PC); + putlabel: + n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; + } + *pl = -pos; /* Label exists now. */ + b[pos++] = ofs; /* Store pass1 offset estimate. */ + break; + case DASM_IMM: +#ifdef DASM_CHECKS + CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I); +#endif + n >>= ((ins>>10)&31); +#ifdef DASM_CHECKS + if (ins & 0x8000) + CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I); + else + CK((n>>((ins>>5)&31)) == 0, RANGE_I); +#endif + b[pos++] = n; + break; + } + } + } +stop: + va_end(ap); + sec->pos = pos; + sec->ofs = ofs; +} +#undef CK + +/* Pass 2: Link sections, shrink aligns, fix label offsets. */ +int dasm_link(Dst_DECL, size_t *szp) +{ + dasm_State *D = Dst_REF; + int secnum; + int ofs = 0; + +#ifdef DASM_CHECKS + *szp = 0; + if (D->status != DASM_S_OK) return D->status; + { + int pc; + for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) + if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; + } +#endif + + { /* Handle globals not defined in this translation unit. */ + int idx; + for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { + int n = D->lglabels[idx]; + /* Undefined label: Collapse rel chain and replace with marker (< 0). */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } + } + } + + /* Combine all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->rbuf; + int pos = DASM_SEC2POS(secnum); + int lastpos = sec->pos; + + while (pos != lastpos) { + dasm_ActList p = D->actionlist + b[pos++]; + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16) - 0xff00; + switch (action) { + case DASM_STOP: case DASM_SECTION: goto stop; + case DASM_ESC: p++; break; + case DASM_REL_EXT: break; + case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break; + case DASM_REL_LG: case DASM_REL_PC: pos++; break; + case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; + case DASM_IMM: pos++; break; + } + } + stop: (void)0; + } + ofs += sec->ofs; /* Next section starts right after current section. */ + } + + D->codesize = ofs; /* Total size of all code sections */ + *szp = ofs; + return DASM_S_OK; +} + +#ifdef DASM_CHECKS +#define CK(x, st) \ + do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0) +#else +#define CK(x, st) ((void)0) +#endif + +/* Pass 3: Encode sections. */ +int dasm_encode(Dst_DECL, void *buffer) +{ + dasm_State *D = Dst_REF; + char *base = (char *)buffer; + unsigned int *cp = (unsigned int *)buffer; + int secnum; + + /* Encode all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->buf; + int *endb = sec->rbuf + sec->pos; + + while (b != endb) { + dasm_ActList p = D->actionlist + *b++; + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16) - 0xff00; + int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0; + switch (action) { + case DASM_STOP: case DASM_SECTION: goto stop; + case DASM_ESC: *cp++ = *p++; break; + case DASM_REL_EXT: + n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins & 2047), 1); + goto patchrel; + case DASM_ALIGN: + ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0x60000000; + break; + case DASM_REL_LG: + CK(n >= 0, UNDEF_LG); + case DASM_REL_PC: + CK(n >= 0, UNDEF_PC); + n = *DASM_POS2PTR(D, n); + if (ins & 2048) + n = n - (int)((char *)cp - base); + else + n = (n + (int)base) & 0x0fffffff; + patchrel: + CK((n & 3) == 0 && + ((n + ((ins & 2048) ? 0x00020000 : 0)) >> + ((ins & 2048) ? 18 : 28)) == 0, RANGE_REL); + cp[-1] |= ((n>>2) & ((ins & 2048) ? 0x0000ffff: 0x03ffffff)); + break; + case DASM_LABEL_LG: + ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); + break; + case DASM_LABEL_PC: break; + case DASM_IMM: + cp[-1] |= (n & ((1<<((ins>>5)&31))-1)) << (ins&31); + break; + default: *cp++ = ins; break; + } + } + stop: (void)0; + } + } + + if (base + D->codesize != (char *)cp) /* Check for phase errors. */ + return DASM_S_PHASE; + return DASM_S_OK; +} +#undef CK + +/* Get PC label offset. */ +int dasm_getpclabel(Dst_DECL, unsigned int pc) +{ + dasm_State *D = Dst_REF; + if (pc*sizeof(int) < D->pcsize) { + int pos = D->pclabels[pc]; + if (pos < 0) return *DASM_POS2PTR(D, -pos); + if (pos > 0) return -1; /* Undefined. */ + } + return -2; /* Unused or out of range. */ +} + +#ifdef DASM_CHECKS +/* Optional sanity checker to call between isolated encoding steps. */ +int dasm_checkstep(Dst_DECL, int secmatch) +{ + dasm_State *D = Dst_REF; + if (D->status == DASM_S_OK) { + int i; + for (i = 1; i <= 9; i++) { + if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; } + D->lglabels[i] = 0; + } + } + if (D->status == DASM_S_OK && secmatch >= 0 && + D->section != &D->sections[secmatch]) + D->status = DASM_S_MATCH_SEC|(D->section-D->sections); + return D->status; +} +#endif + + +``` + +`include/luajit-2.0.5/dynasm/dasm_mips.lua`: + +```lua +------------------------------------------------------------------------------ +-- DynASM MIPS module. +-- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- See dynasm.lua for full copyright notice. +------------------------------------------------------------------------------ + +-- Module information: +local _info = { + arch = "mips", + description = "DynASM MIPS module", + version = "1.3.0", + vernum = 10300, + release = "2012-01-23", + author = "Mike Pall", + license = "MIT", +} + +-- Exported glue functions for the arch-specific module. +local _M = { _info = _info } + +-- Cache library functions. +local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs +local assert, setmetatable = assert, setmetatable +local _s = string +local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char +local match, gmatch = _s.match, _s.gmatch +local concat, sort = table.concat, table.sort +local bit = bit or require("bit") +local band, shl, sar, tohex = bit.band, bit.lshift, bit.arshift, bit.tohex + +-- Inherited tables and callbacks. +local g_opt, g_arch +local wline, werror, wfatal, wwarn + +-- Action name list. +-- CHECK: Keep this in sync with the C code! +local action_names = { + "STOP", "SECTION", "ESC", "REL_EXT", + "ALIGN", "REL_LG", "LABEL_LG", + "REL_PC", "LABEL_PC", "IMM", +} + +-- Maximum number of section buffer positions for dasm_put(). +-- CHECK: Keep this in sync with the C code! +local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. + +-- Action name -> action number. +local map_action = {} +for n,name in ipairs(action_names) do + map_action[name] = n-1 +end + +-- Action list buffer. +local actlist = {} + +-- Argument list for next dasm_put(). Start with offset 0 into action list. +local actargs = { 0 } + +-- Current number of section buffer positions for dasm_put(). +local secpos = 1 + +------------------------------------------------------------------------------ + +-- Dump action names and numbers. +local function dumpactions(out) + out:write("DynASM encoding engine action codes:\n") + for n,name in ipairs(action_names) do + local num = map_action[name] + out:write(format(" %-10s %02X %d\n", name, num, num)) + end + out:write("\n") +end + +-- Write action list buffer as a huge static C array. +local function writeactions(out, name) + local nn = #actlist + if nn == 0 then nn = 1; actlist[0] = map_action.STOP end + out:write("static const unsigned int ", name, "[", nn, "] = {\n") + for i = 1,nn-1 do + assert(out:write("0x", tohex(actlist[i]), ",\n")) + end + assert(out:write("0x", tohex(actlist[nn]), "\n};\n\n")) +end + +------------------------------------------------------------------------------ + +-- Add word to action list. +local function wputxw(n) + assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") + actlist[#actlist+1] = n +end + +-- Add action to list with optional arg. Advance buffer pos, too. +local function waction(action, val, a, num) + local w = assert(map_action[action], "bad action name `"..action.."'") + wputxw(0xff000000 + w * 0x10000 + (val or 0)) + if a then actargs[#actargs+1] = a end + if a or num then secpos = secpos + (num or 1) end +end + +-- Flush action list (intervening C code or buffer pos overflow). +local function wflush(term) + if #actlist == actargs[1] then return end -- Nothing to flush. + if not term then waction("STOP") end -- Terminate action list. + wline(format("dasm_put(Dst, %s);", concat(actargs, ", ")), true) + actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). + secpos = 1 -- The actionlist offset occupies a buffer position, too. +end + +-- Put escaped word. +local function wputw(n) + if n >= 0xff000000 then waction("ESC") end + wputxw(n) +end + +-- Reserve position for word. +local function wpos() + local pos = #actlist+1 + actlist[pos] = "" + return pos +end + +-- Store word to reserved position. +local function wputpos(pos, n) + assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") + actlist[pos] = n +end + +------------------------------------------------------------------------------ + +-- Global label name -> global label number. With auto assignment on 1st use. +local next_global = 20 +local map_global = setmetatable({}, { __index = function(t, name) + if not match(name, "^[%a_][%w_]*$") then werror("bad global label") end + local n = next_global + if n > 2047 then werror("too many global labels") end + next_global = n + 1 + t[name] = n + return n +end}) + +-- Dump global labels. +local function dumpglobals(out, lvl) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("Global labels:\n") + for i=20,next_global-1 do + out:write(format(" %s\n", t[i])) + end + out:write("\n") +end + +-- Write global label enum. +local function writeglobals(out, prefix) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("enum {\n") + for i=20,next_global-1 do + out:write(" ", prefix, t[i], ",\n") + end + out:write(" ", prefix, "_MAX\n};\n") +end + +-- Write global label names. +local function writeglobalnames(out, name) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("static const char *const ", name, "[] = {\n") + for i=20,next_global-1 do + out:write(" \"", t[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Extern label name -> extern label number. With auto assignment on 1st use. +local next_extern = 0 +local map_extern_ = {} +local map_extern = setmetatable({}, { __index = function(t, name) + -- No restrictions on the name for now. + local n = next_extern + if n > 2047 then werror("too many extern labels") end + next_extern = n + 1 + t[name] = n + map_extern_[n] = name + return n +end}) + +-- Dump extern labels. +local function dumpexterns(out, lvl) + out:write("Extern labels:\n") + for i=0,next_extern-1 do + out:write(format(" %s\n", map_extern_[i])) + end + out:write("\n") +end + +-- Write extern label names. +local function writeexternnames(out, name) + out:write("static const char *const ", name, "[] = {\n") + for i=0,next_extern-1 do + out:write(" \"", map_extern_[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Arch-specific maps. +local map_archdef = { sp="r29", ra="r31" } -- Ext. register name -> int. name. + +local map_type = {} -- Type name -> { ctype, reg } +local ctypenum = 0 -- Type number (for Dt... macros). + +-- Reverse defines for registers. +function _M.revdef(s) + if s == "r29" then return "sp" + elseif s == "r31" then return "ra" end + return s +end + +------------------------------------------------------------------------------ + +-- Template strings for MIPS instructions. +local map_op = { + -- First-level opcodes. + j_1 = "08000000J", + jal_1 = "0c000000J", + b_1 = "10000000B", + beqz_2 = "10000000SB", + beq_3 = "10000000STB", + bnez_2 = "14000000SB", + bne_3 = "14000000STB", + blez_2 = "18000000SB", + bgtz_2 = "1c000000SB", + addi_3 = "20000000TSI", + li_2 = "24000000TI", + addiu_3 = "24000000TSI", + slti_3 = "28000000TSI", + sltiu_3 = "2c000000TSI", + andi_3 = "30000000TSU", + lu_2 = "34000000TU", + ori_3 = "34000000TSU", + xori_3 = "38000000TSU", + lui_2 = "3c000000TU", + beqzl_2 = "50000000SB", + beql_3 = "50000000STB", + bnezl_2 = "54000000SB", + bnel_3 = "54000000STB", + blezl_2 = "58000000SB", + bgtzl_2 = "5c000000SB", + lb_2 = "80000000TO", + lh_2 = "84000000TO", + lwl_2 = "88000000TO", + lw_2 = "8c000000TO", + lbu_2 = "90000000TO", + lhu_2 = "94000000TO", + lwr_2 = "98000000TO", + sb_2 = "a0000000TO", + sh_2 = "a4000000TO", + swl_2 = "a8000000TO", + sw_2 = "ac000000TO", + swr_2 = "b8000000TO", + cache_2 = "bc000000NO", + ll_2 = "c0000000TO", + lwc1_2 = "c4000000HO", + pref_2 = "cc000000NO", + ldc1_2 = "d4000000HO", + sc_2 = "e0000000TO", + swc1_2 = "e4000000HO", + sdc1_2 = "f4000000HO", + + -- Opcode SPECIAL. + nop_0 = "00000000", + sll_3 = "00000000DTA", + movf_2 = "00000001DS", + movf_3 = "00000001DSC", + movt_2 = "00010001DS", + movt_3 = "00010001DSC", + srl_3 = "00000002DTA", + rotr_3 = "00200002DTA", + sra_3 = "00000003DTA", + sllv_3 = "00000004DTS", + srlv_3 = "00000006DTS", + rotrv_3 = "00000046DTS", + srav_3 = "00000007DTS", + jr_1 = "00000008S", + jalr_1 = "0000f809S", + jalr_2 = "00000009DS", + movz_3 = "0000000aDST", + movn_3 = "0000000bDST", + syscall_0 = "0000000c", + syscall_1 = "0000000cY", + break_0 = "0000000d", + break_1 = "0000000dY", + sync_0 = "0000000f", + mfhi_1 = "00000010D", + mthi_1 = "00000011S", + mflo_1 = "00000012D", + mtlo_1 = "00000013S", + mult_2 = "00000018ST", + multu_2 = "00000019ST", + div_2 = "0000001aST", + divu_2 = "0000001bST", + add_3 = "00000020DST", + move_2 = "00000021DS", + addu_3 = "00000021DST", + sub_3 = "00000022DST", + negu_2 = "00000023DT", + subu_3 = "00000023DST", + and_3 = "00000024DST", + or_3 = "00000025DST", + xor_3 = "00000026DST", + not_2 = "00000027DS", + nor_3 = "00000027DST", + slt_3 = "0000002aDST", + sltu_3 = "0000002bDST", + tge_2 = "00000030ST", + tge_3 = "00000030STZ", + tgeu_2 = "00000031ST", + tgeu_3 = "00000031STZ", + tlt_2 = "00000032ST", + tlt_3 = "00000032STZ", + tltu_2 = "00000033ST", + tltu_3 = "00000033STZ", + teq_2 = "00000034ST", + teq_3 = "00000034STZ", + tne_2 = "00000036ST", + tne_3 = "00000036STZ", + + -- Opcode REGIMM. + bltz_2 = "04000000SB", + bgez_2 = "04010000SB", + bltzl_2 = "04020000SB", + bgezl_2 = "04030000SB", + tgei_2 = "04080000SI", + tgeiu_2 = "04090000SI", + tlti_2 = "040a0000SI", + tltiu_2 = "040b0000SI", + teqi_2 = "040c0000SI", + tnei_2 = "040e0000SI", + bltzal_2 = "04100000SB", + bal_1 = "04110000B", + bgezal_2 = "04110000SB", + bltzall_2 = "04120000SB", + bgezall_2 = "04130000SB", + synci_1 = "041f0000O", + + -- Opcode SPECIAL2. + madd_2 = "70000000ST", + maddu_2 = "70000001ST", + mul_3 = "70000002DST", + msub_2 = "70000004ST", + msubu_2 = "70000005ST", + clz_2 = "70000020DS=", + clo_2 = "70000021DS=", + sdbbp_0 = "7000003f", + sdbbp_1 = "7000003fY", + + -- Opcode SPECIAL3. + ext_4 = "7c000000TSAM", -- Note: last arg is msbd = size-1 + ins_4 = "7c000004TSAM", -- Note: last arg is msb = pos+size-1 + wsbh_2 = "7c0000a0DT", + seb_2 = "7c000420DT", + seh_2 = "7c000620DT", + rdhwr_2 = "7c00003bTD", + + -- Opcode COP0. + mfc0_2 = "40000000TD", + mfc0_3 = "40000000TDW", + mtc0_2 = "40800000TD", + mtc0_3 = "40800000TDW", + rdpgpr_2 = "41400000DT", + di_0 = "41606000", + di_1 = "41606000T", + ei_0 = "41606020", + ei_1 = "41606020T", + wrpgpr_2 = "41c00000DT", + tlbr_0 = "42000001", + tlbwi_0 = "42000002", + tlbwr_0 = "42000006", + tlbp_0 = "42000008", + eret_0 = "42000018", + deret_0 = "4200001f", + wait_0 = "42000020", + + -- Opcode COP1. + mfc1_2 = "44000000TG", + cfc1_2 = "44400000TG", + mfhc1_2 = "44600000TG", + mtc1_2 = "44800000TG", + ctc1_2 = "44c00000TG", + mthc1_2 = "44e00000TG", + + bc1f_1 = "45000000B", + bc1f_2 = "45000000CB", + bc1t_1 = "45010000B", + bc1t_2 = "45010000CB", + bc1fl_1 = "45020000B", + bc1fl_2 = "45020000CB", + bc1tl_1 = "45030000B", + bc1tl_2 = "45030000CB", + + ["add.s_3"] = "46000000FGH", + ["sub.s_3"] = "46000001FGH", + ["mul.s_3"] = "46000002FGH", + ["div.s_3"] = "46000003FGH", + ["sqrt.s_2"] = "46000004FG", + ["abs.s_2"] = "46000005FG", + ["mov.s_2"] = "46000006FG", + ["neg.s_2"] = "46000007FG", + ["round.l.s_2"] = "46000008FG", + ["trunc.l.s_2"] = "46000009FG", + ["ceil.l.s_2"] = "4600000aFG", + ["floor.l.s_2"] = "4600000bFG", + ["round.w.s_2"] = "4600000cFG", + ["trunc.w.s_2"] = "4600000dFG", + ["ceil.w.s_2"] = "4600000eFG", + ["floor.w.s_2"] = "4600000fFG", + ["movf.s_2"] = "46000011FG", + ["movf.s_3"] = "46000011FGC", + ["movt.s_2"] = "46010011FG", + ["movt.s_3"] = "46010011FGC", + ["movz.s_3"] = "46000012FGT", + ["movn.s_3"] = "46000013FGT", + ["recip.s_2"] = "46000015FG", + ["rsqrt.s_2"] = "46000016FG", + ["cvt.d.s_2"] = "46000021FG", + ["cvt.w.s_2"] = "46000024FG", + ["cvt.l.s_2"] = "46000025FG", + ["cvt.ps.s_3"] = "46000026FGH", + ["c.f.s_2"] = "46000030GH", + ["c.f.s_3"] = "46000030VGH", + ["c.un.s_2"] = "46000031GH", + ["c.un.s_3"] = "46000031VGH", + ["c.eq.s_2"] = "46000032GH", + ["c.eq.s_3"] = "46000032VGH", + ["c.ueq.s_2"] = "46000033GH", + ["c.ueq.s_3"] = "46000033VGH", + ["c.olt.s_2"] = "46000034GH", + ["c.olt.s_3"] = "46000034VGH", + ["c.ult.s_2"] = "46000035GH", + ["c.ult.s_3"] = "46000035VGH", + ["c.ole.s_2"] = "46000036GH", + ["c.ole.s_3"] = "46000036VGH", + ["c.ule.s_2"] = "46000037GH", + ["c.ule.s_3"] = "46000037VGH", + ["c.sf.s_2"] = "46000038GH", + ["c.sf.s_3"] = "46000038VGH", + ["c.ngle.s_2"] = "46000039GH", + ["c.ngle.s_3"] = "46000039VGH", + ["c.seq.s_2"] = "4600003aGH", + ["c.seq.s_3"] = "4600003aVGH", + ["c.ngl.s_2"] = "4600003bGH", + ["c.ngl.s_3"] = "4600003bVGH", + ["c.lt.s_2"] = "4600003cGH", + ["c.lt.s_3"] = "4600003cVGH", + ["c.nge.s_2"] = "4600003dGH", + ["c.nge.s_3"] = "4600003dVGH", + ["c.le.s_2"] = "4600003eGH", + ["c.le.s_3"] = "4600003eVGH", + ["c.ngt.s_2"] = "4600003fGH", + ["c.ngt.s_3"] = "4600003fVGH", + + ["add.d_3"] = "46200000FGH", + ["sub.d_3"] = "46200001FGH", + ["mul.d_3"] = "46200002FGH", + ["div.d_3"] = "46200003FGH", + ["sqrt.d_2"] = "46200004FG", + ["abs.d_2"] = "46200005FG", + ["mov.d_2"] = "46200006FG", + ["neg.d_2"] = "46200007FG", + ["round.l.d_2"] = "46200008FG", + ["trunc.l.d_2"] = "46200009FG", + ["ceil.l.d_2"] = "4620000aFG", + ["floor.l.d_2"] = "4620000bFG", + ["round.w.d_2"] = "4620000cFG", + ["trunc.w.d_2"] = "4620000dFG", + ["ceil.w.d_2"] = "4620000eFG", + ["floor.w.d_2"] = "4620000fFG", + ["movf.d_2"] = "46200011FG", + ["movf.d_3"] = "46200011FGC", + ["movt.d_2"] = "46210011FG", + ["movt.d_3"] = "46210011FGC", + ["movz.d_3"] = "46200012FGT", + ["movn.d_3"] = "46200013FGT", + ["recip.d_2"] = "46200015FG", + ["rsqrt.d_2"] = "46200016FG", + ["cvt.s.d_2"] = "46200020FG", + ["cvt.w.d_2"] = "46200024FG", + ["cvt.l.d_2"] = "46200025FG", + ["c.f.d_2"] = "46200030GH", + ["c.f.d_3"] = "46200030VGH", + ["c.un.d_2"] = "46200031GH", + ["c.un.d_3"] = "46200031VGH", + ["c.eq.d_2"] = "46200032GH", + ["c.eq.d_3"] = "46200032VGH", + ["c.ueq.d_2"] = "46200033GH", + ["c.ueq.d_3"] = "46200033VGH", + ["c.olt.d_2"] = "46200034GH", + ["c.olt.d_3"] = "46200034VGH", + ["c.ult.d_2"] = "46200035GH", + ["c.ult.d_3"] = "46200035VGH", + ["c.ole.d_2"] = "46200036GH", + ["c.ole.d_3"] = "46200036VGH", + ["c.ule.d_2"] = "46200037GH", + ["c.ule.d_3"] = "46200037VGH", + ["c.sf.d_2"] = "46200038GH", + ["c.sf.d_3"] = "46200038VGH", + ["c.ngle.d_2"] = "46200039GH", + ["c.ngle.d_3"] = "46200039VGH", + ["c.seq.d_2"] = "4620003aGH", + ["c.seq.d_3"] = "4620003aVGH", + ["c.ngl.d_2"] = "4620003bGH", + ["c.ngl.d_3"] = "4620003bVGH", + ["c.lt.d_2"] = "4620003cGH", + ["c.lt.d_3"] = "4620003cVGH", + ["c.nge.d_2"] = "4620003dGH", + ["c.nge.d_3"] = "4620003dVGH", + ["c.le.d_2"] = "4620003eGH", + ["c.le.d_3"] = "4620003eVGH", + ["c.ngt.d_2"] = "4620003fGH", + ["c.ngt.d_3"] = "4620003fVGH", + + ["add.ps_3"] = "46c00000FGH", + ["sub.ps_3"] = "46c00001FGH", + ["mul.ps_3"] = "46c00002FGH", + ["abs.ps_2"] = "46c00005FG", + ["mov.ps_2"] = "46c00006FG", + ["neg.ps_2"] = "46c00007FG", + ["movf.ps_2"] = "46c00011FG", + ["movf.ps_3"] = "46c00011FGC", + ["movt.ps_2"] = "46c10011FG", + ["movt.ps_3"] = "46c10011FGC", + ["movz.ps_3"] = "46c00012FGT", + ["movn.ps_3"] = "46c00013FGT", + ["cvt.s.pu_2"] = "46c00020FG", + ["cvt.s.pl_2"] = "46c00028FG", + ["pll.ps_3"] = "46c0002cFGH", + ["plu.ps_3"] = "46c0002dFGH", + ["pul.ps_3"] = "46c0002eFGH", + ["puu.ps_3"] = "46c0002fFGH", + ["c.f.ps_2"] = "46c00030GH", + ["c.f.ps_3"] = "46c00030VGH", + ["c.un.ps_2"] = "46c00031GH", + ["c.un.ps_3"] = "46c00031VGH", + ["c.eq.ps_2"] = "46c00032GH", + ["c.eq.ps_3"] = "46c00032VGH", + ["c.ueq.ps_2"] = "46c00033GH", + ["c.ueq.ps_3"] = "46c00033VGH", + ["c.olt.ps_2"] = "46c00034GH", + ["c.olt.ps_3"] = "46c00034VGH", + ["c.ult.ps_2"] = "46c00035GH", + ["c.ult.ps_3"] = "46c00035VGH", + ["c.ole.ps_2"] = "46c00036GH", + ["c.ole.ps_3"] = "46c00036VGH", + ["c.ule.ps_2"] = "46c00037GH", + ["c.ule.ps_3"] = "46c00037VGH", + ["c.sf.ps_2"] = "46c00038GH", + ["c.sf.ps_3"] = "46c00038VGH", + ["c.ngle.ps_2"] = "46c00039GH", + ["c.ngle.ps_3"] = "46c00039VGH", + ["c.seq.ps_2"] = "46c0003aGH", + ["c.seq.ps_3"] = "46c0003aVGH", + ["c.ngl.ps_2"] = "46c0003bGH", + ["c.ngl.ps_3"] = "46c0003bVGH", + ["c.lt.ps_2"] = "46c0003cGH", + ["c.lt.ps_3"] = "46c0003cVGH", + ["c.nge.ps_2"] = "46c0003dGH", + ["c.nge.ps_3"] = "46c0003dVGH", + ["c.le.ps_2"] = "46c0003eGH", + ["c.le.ps_3"] = "46c0003eVGH", + ["c.ngt.ps_2"] = "46c0003fGH", + ["c.ngt.ps_3"] = "46c0003fVGH", + + ["cvt.s.w_2"] = "46800020FG", + ["cvt.d.w_2"] = "46800021FG", + + ["cvt.s.l_2"] = "46a00020FG", + ["cvt.d.l_2"] = "46a00021FG", + + -- Opcode COP1X. + lwxc1_2 = "4c000000FX", + ldxc1_2 = "4c000001FX", + luxc1_2 = "4c000005FX", + swxc1_2 = "4c000008FX", + sdxc1_2 = "4c000009FX", + suxc1_2 = "4c00000dFX", + prefx_2 = "4c00000fMX", + ["alnv.ps_4"] = "4c00001eFGHS", + ["madd.s_4"] = "4c000020FRGH", + ["madd.d_4"] = "4c000021FRGH", + ["madd.ps_4"] = "4c000026FRGH", + ["msub.s_4"] = "4c000028FRGH", + ["msub.d_4"] = "4c000029FRGH", + ["msub.ps_4"] = "4c00002eFRGH", + ["nmadd.s_4"] = "4c000030FRGH", + ["nmadd.d_4"] = "4c000031FRGH", + ["nmadd.ps_4"] = "4c000036FRGH", + ["nmsub.s_4"] = "4c000038FRGH", + ["nmsub.d_4"] = "4c000039FRGH", + ["nmsub.ps_4"] = "4c00003eFRGH", +} + +------------------------------------------------------------------------------ + +local function parse_gpr(expr) + local tname, ovreg = match(expr, "^([%w_]+):(r[1-3]?[0-9])$") + local tp = map_type[tname or expr] + if tp then + local reg = ovreg or tp.reg + if not reg then + werror("type `"..(tname or expr).."' needs a register override") + end + expr = reg + end + local r = match(expr, "^r([1-3]?[0-9])$") + if r then + r = tonumber(r) + if r <= 31 then return r, tp end + end + werror("bad register name `"..expr.."'") +end + +local function parse_fpr(expr) + local r = match(expr, "^f([1-3]?[0-9])$") + if r then + r = tonumber(r) + if r <= 31 then return r end + end + werror("bad register name `"..expr.."'") +end + +local function parse_imm(imm, bits, shift, scale, signed) + local n = tonumber(imm) + if n then + local m = sar(n, scale) + if shl(m, scale) == n then + if signed then + local s = sar(m, bits-1) + if s == 0 then return shl(m, shift) + elseif s == -1 then return shl(m + shl(1, bits), shift) end + else + if sar(m, bits) == 0 then return shl(m, shift) end + end + end + werror("out of range immediate `"..imm.."'") + elseif match(imm, "^[rf]([1-3]?[0-9])$") or + match(imm, "^([%w_]+):([rf][1-3]?[0-9])$") then + werror("expected immediate operand, got register") + else + waction("IMM", (signed and 32768 or 0)+scale*1024+bits*32+shift, imm) + return 0 + end +end + +local function parse_disp(disp) + local imm, reg = match(disp, "^(.*)%(([%w_:]+)%)$") + if imm then + local r = shl(parse_gpr(reg), 21) + local extname = match(imm, "^extern%s+(%S+)$") + if extname then + waction("REL_EXT", map_extern[extname], nil, 1) + return r + else + return r + parse_imm(imm, 16, 0, 0, true) + end + end + local reg, tailr = match(disp, "^([%w_:]+)%s*(.*)$") + if reg and tailr ~= "" then + local r, tp = parse_gpr(reg) + if tp then + waction("IMM", 32768+16*32, format(tp.ctypefmt, tailr)) + return shl(r, 21) + end + end + werror("bad displacement `"..disp.."'") +end + +local function parse_index(idx) + local rt, rs = match(idx, "^(.*)%(([%w_:]+)%)$") + if rt then + rt = parse_gpr(rt) + rs = parse_gpr(rs) + return shl(rt, 16) + shl(rs, 21) + end + werror("bad index `"..idx.."'") +end + +local function parse_label(label, def) + local prefix = sub(label, 1, 2) + -- =>label (pc label reference) + if prefix == "=>" then + return "PC", 0, sub(label, 3) + end + -- ->name (global label reference) + if prefix == "->" then + return "LG", map_global[sub(label, 3)] + end + if def then + -- [1-9] (local label definition) + if match(label, "^[1-9]$") then + return "LG", 10+tonumber(label) + end + else + -- [<>][1-9] (local label reference) + local dir, lnum = match(label, "^([<>])([1-9])$") + if dir then -- Fwd: 1-9, Bkwd: 11-19. + return "LG", lnum + (dir == ">" and 0 or 10) + end + -- extern label (extern label reference) + local extname = match(label, "^extern%s+(%S+)$") + if extname then + return "EXT", map_extern[extname] + end + end + werror("bad label `"..label.."'") +end + +------------------------------------------------------------------------------ + +-- Handle opcodes defined with template strings. +map_op[".template__"] = function(params, template, nparams) + if not params then return sub(template, 9) end + local op = tonumber(sub(template, 1, 8), 16) + local n = 1 + + -- Limit number of section buffer positions used by a single dasm_put(). + -- A single opcode needs a maximum of 2 positions (ins/ext). + if secpos+2 > maxsecpos then wflush() end + local pos = wpos() + + -- Process each character. + for p in gmatch(sub(template, 9), ".") do + if p == "D" then + op = op + shl(parse_gpr(params[n]), 11); n = n + 1 + elseif p == "T" then + op = op + shl(parse_gpr(params[n]), 16); n = n + 1 + elseif p == "S" then + op = op + shl(parse_gpr(params[n]), 21); n = n + 1 + elseif p == "F" then + op = op + shl(parse_fpr(params[n]), 6); n = n + 1 + elseif p == "G" then + op = op + shl(parse_fpr(params[n]), 11); n = n + 1 + elseif p == "H" then + op = op + shl(parse_fpr(params[n]), 16); n = n + 1 + elseif p == "R" then + op = op + shl(parse_fpr(params[n]), 21); n = n + 1 + elseif p == "I" then + op = op + parse_imm(params[n], 16, 0, 0, true); n = n + 1 + elseif p == "U" then + op = op + parse_imm(params[n], 16, 0, 0, false); n = n + 1 + elseif p == "O" then + op = op + parse_disp(params[n]); n = n + 1 + elseif p == "X" then + op = op + parse_index(params[n]); n = n + 1 + elseif p == "B" or p == "J" then + local mode, n, s = parse_label(params[n], false) + if p == "B" then n = n + 2048 end + waction("REL_"..mode, n, s, 1) + n = n + 1 + elseif p == "A" then + op = op + parse_imm(params[n], 5, 6, 0, false); n = n + 1 + elseif p == "M" then + op = op + parse_imm(params[n], 5, 11, 0, false); n = n + 1 + elseif p == "N" then + op = op + parse_imm(params[n], 5, 16, 0, false); n = n + 1 + elseif p == "C" then + op = op + parse_imm(params[n], 3, 18, 0, false); n = n + 1 + elseif p == "V" then + op = op + parse_imm(params[n], 3, 8, 0, false); n = n + 1 + elseif p == "W" then + op = op + parse_imm(params[n], 3, 0, 0, false); n = n + 1 + elseif p == "Y" then + op = op + parse_imm(params[n], 20, 6, 0, false); n = n + 1 + elseif p == "Z" then + op = op + parse_imm(params[n], 10, 6, 0, false); n = n + 1 + elseif p == "=" then + op = op + shl(band(op, 0xf800), 5) -- Copy D to T for clz, clo. + else + assert(false) + end + end + wputpos(pos, op) +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcode to mark the position where the action list is to be emitted. +map_op[".actionlist_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeactions(out, name) end) +end + +-- Pseudo-opcode to mark the position where the global enum is to be emitted. +map_op[".globals_1"] = function(params) + if not params then return "prefix" end + local prefix = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobals(out, prefix) end) +end + +-- Pseudo-opcode to mark the position where the global names are to be emitted. +map_op[".globalnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobalnames(out, name) end) +end + +-- Pseudo-opcode to mark the position where the extern names are to be emitted. +map_op[".externnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeexternnames(out, name) end) +end + +------------------------------------------------------------------------------ + +-- Label pseudo-opcode (converted from trailing colon form). +map_op[".label_1"] = function(params) + if not params then return "[1-9] | ->global | =>pcexpr" end + if secpos+1 > maxsecpos then wflush() end + local mode, n, s = parse_label(params[1], true) + if mode == "EXT" then werror("bad label definition") end + waction("LABEL_"..mode, n, s, 1) +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcodes for data storage. +map_op[".long_*"] = function(params) + if not params then return "imm..." end + for _,p in ipairs(params) do + local n = tonumber(p) + if not n then werror("bad immediate `"..p.."'") end + if n < 0 then n = n + 2^32 end + wputw(n) + if secpos+2 > maxsecpos then wflush() end + end +end + +-- Alignment pseudo-opcode. +map_op[".align_1"] = function(params) + if not params then return "numpow2" end + if secpos+1 > maxsecpos then wflush() end + local align = tonumber(params[1]) + if align then + local x = align + -- Must be a power of 2 in the range (2 ... 256). + for i=1,8 do + x = x / 2 + if x == 1 then + waction("ALIGN", align-1, nil, 1) -- Action byte is 2**n-1. + return + end + end + end + werror("bad alignment") +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcode for (primitive) type definitions (map to C types). +map_op[".type_3"] = function(params, nparams) + if not params then + return nparams == 2 and "name, ctype" or "name, ctype, reg" + end + local name, ctype, reg = params[1], params[2], params[3] + if not match(name, "^[%a_][%w_]*$") then + werror("bad type name `"..name.."'") + end + local tp = map_type[name] + if tp then + werror("duplicate type `"..name.."'") + end + -- Add #type to defines. A bit unclean to put it in map_archdef. + map_archdef["#"..name] = "sizeof("..ctype..")" + -- Add new type and emit shortcut define. + local num = ctypenum + 1 + map_type[name] = { + ctype = ctype, + ctypefmt = format("Dt%X(%%s)", num), + reg = reg, + } + wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) + ctypenum = num +end +map_op[".type_2"] = map_op[".type_3"] + +-- Dump type definitions. +local function dumptypes(out, lvl) + local t = {} + for name in pairs(map_type) do t[#t+1] = name end + sort(t) + out:write("Type definitions:\n") + for _,name in ipairs(t) do + local tp = map_type[name] + local reg = tp.reg or "" + out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) + end + out:write("\n") +end + +------------------------------------------------------------------------------ + +-- Set the current section. +function _M.section(num) + waction("SECTION", num) + wflush(true) -- SECTION is a terminal action. +end + +------------------------------------------------------------------------------ + +-- Dump architecture description. +function _M.dumparch(out) + out:write(format("DynASM %s version %s, released %s\n\n", + _info.arch, _info.version, _info.release)) + dumpactions(out) +end + +-- Dump all user defined elements. +function _M.dumpdef(out, lvl) + dumptypes(out, lvl) + dumpglobals(out, lvl) + dumpexterns(out, lvl) +end + +------------------------------------------------------------------------------ + +-- Pass callbacks from/to the DynASM core. +function _M.passcb(wl, we, wf, ww) + wline, werror, wfatal, wwarn = wl, we, wf, ww + return wflush +end + +-- Setup the arch-specific module. +function _M.setup(arch, opt) + g_arch, g_opt = arch, opt +end + +-- Merge the core maps and the arch-specific maps. +function _M.mergemaps(map_coreop, map_def) + setmetatable(map_op, { __index = map_coreop }) + setmetatable(map_def, { __index = map_archdef }) + return map_op, map_def +end + +return _M + +------------------------------------------------------------------------------ + + +``` + +`include/luajit-2.0.5/dynasm/dasm_ppc.h`: + +```h +/* +** DynASM PPC encoding engine. +** Copyright (C) 2005-2017 Mike Pall. All rights reserved. +** Released under the MIT license. See dynasm.lua for full copyright notice. +*/ + +#include +#include +#include +#include + +#define DASM_ARCH "ppc" + +#ifndef DASM_EXTERN +#define DASM_EXTERN(a,b,c,d) 0 +#endif + +/* Action definitions. */ +enum { + DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT, + /* The following actions need a buffer position. */ + DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG, + /* The following actions also have an argument. */ + DASM_REL_PC, DASM_LABEL_PC, DASM_IMM, + DASM__MAX +}; + +/* Maximum number of section buffer positions for a single dasm_put() call. */ +#define DASM_MAXSECPOS 25 + +/* DynASM encoder status codes. Action list offset or number are or'ed in. */ +#define DASM_S_OK 0x00000000 +#define DASM_S_NOMEM 0x01000000 +#define DASM_S_PHASE 0x02000000 +#define DASM_S_MATCH_SEC 0x03000000 +#define DASM_S_RANGE_I 0x11000000 +#define DASM_S_RANGE_SEC 0x12000000 +#define DASM_S_RANGE_LG 0x13000000 +#define DASM_S_RANGE_PC 0x14000000 +#define DASM_S_RANGE_REL 0x15000000 +#define DASM_S_UNDEF_LG 0x21000000 +#define DASM_S_UNDEF_PC 0x22000000 + +/* Macros to convert positions (8 bit section + 24 bit index). */ +#define DASM_POS2IDX(pos) ((pos)&0x00ffffff) +#define DASM_POS2BIAS(pos) ((pos)&0xff000000) +#define DASM_SEC2POS(sec) ((sec)<<24) +#define DASM_POS2SEC(pos) ((pos)>>24) +#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) + +/* Action list type. */ +typedef const unsigned int *dasm_ActList; + +/* Per-section structure. */ +typedef struct dasm_Section { + int *rbuf; /* Biased buffer pointer (negative section bias). */ + int *buf; /* True buffer pointer. */ + size_t bsize; /* Buffer size in bytes. */ + int pos; /* Biased buffer position. */ + int epos; /* End of biased buffer position - max single put. */ + int ofs; /* Byte offset into section. */ +} dasm_Section; + +/* Core structure holding the DynASM encoding state. */ +struct dasm_State { + size_t psize; /* Allocated size of this structure. */ + dasm_ActList actionlist; /* Current actionlist pointer. */ + int *lglabels; /* Local/global chain/pos ptrs. */ + size_t lgsize; + int *pclabels; /* PC label chains/pos ptrs. */ + size_t pcsize; + void **globals; /* Array of globals (bias -10). */ + dasm_Section *section; /* Pointer to active section. */ + size_t codesize; /* Total size of all code sections. */ + int maxsection; /* 0 <= sectionidx < maxsection. */ + int status; /* Status code. */ + dasm_Section sections[1]; /* All sections. Alloc-extended. */ +}; + +/* The size of the core structure depends on the max. number of sections. */ +#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) + + +/* Initialize DynASM state. */ +void dasm_init(Dst_DECL, int maxsection) +{ + dasm_State *D; + size_t psz = 0; + int i; + Dst_REF = NULL; + DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); + D = Dst_REF; + D->psize = psz; + D->lglabels = NULL; + D->lgsize = 0; + D->pclabels = NULL; + D->pcsize = 0; + D->globals = NULL; + D->maxsection = maxsection; + for (i = 0; i < maxsection; i++) { + D->sections[i].buf = NULL; /* Need this for pass3. */ + D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); + D->sections[i].bsize = 0; + D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ + } +} + +/* Free DynASM state. */ +void dasm_free(Dst_DECL) +{ + dasm_State *D = Dst_REF; + int i; + for (i = 0; i < D->maxsection; i++) + if (D->sections[i].buf) + DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); + if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); + if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); + DASM_M_FREE(Dst, D, D->psize); +} + +/* Setup global label array. Must be called before dasm_setup(). */ +void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) +{ + dasm_State *D = Dst_REF; + D->globals = gl - 10; /* Negative bias to compensate for locals. */ + DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); +} + +/* Grow PC label array. Can be called after dasm_setup(), too. */ +void dasm_growpc(Dst_DECL, unsigned int maxpc) +{ + dasm_State *D = Dst_REF; + size_t osz = D->pcsize; + DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); + memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); +} + +/* Setup encoder. */ +void dasm_setup(Dst_DECL, const void *actionlist) +{ + dasm_State *D = Dst_REF; + int i; + D->actionlist = (dasm_ActList)actionlist; + D->status = DASM_S_OK; + D->section = &D->sections[0]; + memset((void *)D->lglabels, 0, D->lgsize); + if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); + for (i = 0; i < D->maxsection; i++) { + D->sections[i].pos = DASM_SEC2POS(i); + D->sections[i].ofs = 0; + } +} + + +#ifdef DASM_CHECKS +#define CK(x, st) \ + do { if (!(x)) { \ + D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0) +#define CKPL(kind, st) \ + do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ + D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0) +#else +#define CK(x, st) ((void)0) +#define CKPL(kind, st) ((void)0) +#endif + +/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ +void dasm_put(Dst_DECL, int start, ...) +{ + va_list ap; + dasm_State *D = Dst_REF; + dasm_ActList p = D->actionlist + start; + dasm_Section *sec = D->section; + int pos = sec->pos, ofs = sec->ofs; + int *b; + + if (pos >= sec->epos) { + DASM_M_GROW(Dst, int, sec->buf, sec->bsize, + sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); + sec->rbuf = sec->buf - DASM_POS2BIAS(pos); + sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); + } + + b = sec->rbuf; + b[pos++] = start; + + va_start(ap, start); + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16); + if (action >= DASM__MAX) { + ofs += 4; + } else { + int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0; + switch (action) { + case DASM_STOP: goto stop; + case DASM_SECTION: + n = (ins & 255); CK(n < D->maxsection, RANGE_SEC); + D->section = &D->sections[n]; goto stop; + case DASM_ESC: p++; ofs += 4; break; + case DASM_REL_EXT: break; + case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break; + case DASM_REL_LG: + n = (ins & 2047) - 10; pl = D->lglabels + n; + /* Bkwd rel or global. */ + if (n >= 0) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; } + pl += 10; n = *pl; + if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ + goto linkrel; + case DASM_REL_PC: + pl = D->pclabels + n; CKPL(pc, PC); + putrel: + n = *pl; + if (n < 0) { /* Label exists. Get label pos and store it. */ + b[pos] = -n; + } else { + linkrel: + b[pos] = n; /* Else link to rel chain, anchored at label. */ + *pl = pos; + } + pos++; + break; + case DASM_LABEL_LG: + pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel; + case DASM_LABEL_PC: + pl = D->pclabels + n; CKPL(pc, PC); + putlabel: + n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; + } + *pl = -pos; /* Label exists now. */ + b[pos++] = ofs; /* Store pass1 offset estimate. */ + break; + case DASM_IMM: +#ifdef DASM_CHECKS + CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I); +#endif + n >>= ((ins>>10)&31); +#ifdef DASM_CHECKS + if (ins & 0x8000) + CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I); + else + CK((n>>((ins>>5)&31)) == 0, RANGE_I); +#endif + b[pos++] = n; + break; + } + } + } +stop: + va_end(ap); + sec->pos = pos; + sec->ofs = ofs; +} +#undef CK + +/* Pass 2: Link sections, shrink aligns, fix label offsets. */ +int dasm_link(Dst_DECL, size_t *szp) +{ + dasm_State *D = Dst_REF; + int secnum; + int ofs = 0; + +#ifdef DASM_CHECKS + *szp = 0; + if (D->status != DASM_S_OK) return D->status; + { + int pc; + for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) + if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; + } +#endif + + { /* Handle globals not defined in this translation unit. */ + int idx; + for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { + int n = D->lglabels[idx]; + /* Undefined label: Collapse rel chain and replace with marker (< 0). */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } + } + } + + /* Combine all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->rbuf; + int pos = DASM_SEC2POS(secnum); + int lastpos = sec->pos; + + while (pos != lastpos) { + dasm_ActList p = D->actionlist + b[pos++]; + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16); + switch (action) { + case DASM_STOP: case DASM_SECTION: goto stop; + case DASM_ESC: p++; break; + case DASM_REL_EXT: break; + case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break; + case DASM_REL_LG: case DASM_REL_PC: pos++; break; + case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; + case DASM_IMM: pos++; break; + } + } + stop: (void)0; + } + ofs += sec->ofs; /* Next section starts right after current section. */ + } + + D->codesize = ofs; /* Total size of all code sections */ + *szp = ofs; + return DASM_S_OK; +} + +#ifdef DASM_CHECKS +#define CK(x, st) \ + do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0) +#else +#define CK(x, st) ((void)0) +#endif + +/* Pass 3: Encode sections. */ +int dasm_encode(Dst_DECL, void *buffer) +{ + dasm_State *D = Dst_REF; + char *base = (char *)buffer; + unsigned int *cp = (unsigned int *)buffer; + int secnum; + + /* Encode all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->buf; + int *endb = sec->rbuf + sec->pos; + + while (b != endb) { + dasm_ActList p = D->actionlist + *b++; + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16); + int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0; + switch (action) { + case DASM_STOP: case DASM_SECTION: goto stop; + case DASM_ESC: *cp++ = *p++; break; + case DASM_REL_EXT: + n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins & 2047), 1) - 4; + goto patchrel; + case DASM_ALIGN: + ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0x60000000; + break; + case DASM_REL_LG: + CK(n >= 0, UNDEF_LG); + case DASM_REL_PC: + CK(n >= 0, UNDEF_PC); + n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base); + patchrel: + CK((n & 3) == 0 && + (((n+4) + ((ins & 2048) ? 0x00008000 : 0x02000000)) >> + ((ins & 2048) ? 16 : 26)) == 0, RANGE_REL); + cp[-1] |= ((n+4) & ((ins & 2048) ? 0x0000fffc: 0x03fffffc)); + break; + case DASM_LABEL_LG: + ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); + break; + case DASM_LABEL_PC: break; + case DASM_IMM: + cp[-1] |= (n & ((1<<((ins>>5)&31))-1)) << (ins&31); + break; + default: *cp++ = ins; break; + } + } + stop: (void)0; + } + } + + if (base + D->codesize != (char *)cp) /* Check for phase errors. */ + return DASM_S_PHASE; + return DASM_S_OK; +} +#undef CK + +/* Get PC label offset. */ +int dasm_getpclabel(Dst_DECL, unsigned int pc) +{ + dasm_State *D = Dst_REF; + if (pc*sizeof(int) < D->pcsize) { + int pos = D->pclabels[pc]; + if (pos < 0) return *DASM_POS2PTR(D, -pos); + if (pos > 0) return -1; /* Undefined. */ + } + return -2; /* Unused or out of range. */ +} + +#ifdef DASM_CHECKS +/* Optional sanity checker to call between isolated encoding steps. */ +int dasm_checkstep(Dst_DECL, int secmatch) +{ + dasm_State *D = Dst_REF; + if (D->status == DASM_S_OK) { + int i; + for (i = 1; i <= 9; i++) { + if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; } + D->lglabels[i] = 0; + } + } + if (D->status == DASM_S_OK && secmatch >= 0 && + D->section != &D->sections[secmatch]) + D->status = DASM_S_MATCH_SEC|(D->section-D->sections); + return D->status; +} +#endif + + +``` + +`include/luajit-2.0.5/dynasm/dasm_ppc.lua`: + +```lua +------------------------------------------------------------------------------ +-- DynASM PPC module. +-- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- See dynasm.lua for full copyright notice. +------------------------------------------------------------------------------ + +-- Module information: +local _info = { + arch = "ppc", + description = "DynASM PPC module", + version = "1.3.0", + vernum = 10300, + release = "2011-05-05", + author = "Mike Pall", + license = "MIT", +} + +-- Exported glue functions for the arch-specific module. +local _M = { _info = _info } + +-- Cache library functions. +local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs +local assert, setmetatable = assert, setmetatable +local _s = string +local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char +local match, gmatch = _s.match, _s.gmatch +local concat, sort = table.concat, table.sort +local bit = bit or require("bit") +local band, shl, shr, sar = bit.band, bit.lshift, bit.rshift, bit.arshift +local tohex = bit.tohex + +-- Inherited tables and callbacks. +local g_opt, g_arch +local wline, werror, wfatal, wwarn + +-- Action name list. +-- CHECK: Keep this in sync with the C code! +local action_names = { + "STOP", "SECTION", "ESC", "REL_EXT", + "ALIGN", "REL_LG", "LABEL_LG", + "REL_PC", "LABEL_PC", "IMM", +} + +-- Maximum number of section buffer positions for dasm_put(). +-- CHECK: Keep this in sync with the C code! +local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. + +-- Action name -> action number. +local map_action = {} +for n,name in ipairs(action_names) do + map_action[name] = n-1 +end + +-- Action list buffer. +local actlist = {} + +-- Argument list for next dasm_put(). Start with offset 0 into action list. +local actargs = { 0 } + +-- Current number of section buffer positions for dasm_put(). +local secpos = 1 + +------------------------------------------------------------------------------ + +-- Dump action names and numbers. +local function dumpactions(out) + out:write("DynASM encoding engine action codes:\n") + for n,name in ipairs(action_names) do + local num = map_action[name] + out:write(format(" %-10s %02X %d\n", name, num, num)) + end + out:write("\n") +end + +-- Write action list buffer as a huge static C array. +local function writeactions(out, name) + local nn = #actlist + if nn == 0 then nn = 1; actlist[0] = map_action.STOP end + out:write("static const unsigned int ", name, "[", nn, "] = {\n") + for i = 1,nn-1 do + assert(out:write("0x", tohex(actlist[i]), ",\n")) + end + assert(out:write("0x", tohex(actlist[nn]), "\n};\n\n")) +end + +------------------------------------------------------------------------------ + +-- Add word to action list. +local function wputxw(n) + assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") + actlist[#actlist+1] = n +end + +-- Add action to list with optional arg. Advance buffer pos, too. +local function waction(action, val, a, num) + local w = assert(map_action[action], "bad action name `"..action.."'") + wputxw(w * 0x10000 + (val or 0)) + if a then actargs[#actargs+1] = a end + if a or num then secpos = secpos + (num or 1) end +end + +-- Flush action list (intervening C code or buffer pos overflow). +local function wflush(term) + if #actlist == actargs[1] then return end -- Nothing to flush. + if not term then waction("STOP") end -- Terminate action list. + wline(format("dasm_put(Dst, %s);", concat(actargs, ", ")), true) + actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). + secpos = 1 -- The actionlist offset occupies a buffer position, too. +end + +-- Put escaped word. +local function wputw(n) + if n <= 0xffffff then waction("ESC") end + wputxw(n) +end + +-- Reserve position for word. +local function wpos() + local pos = #actlist+1 + actlist[pos] = "" + return pos +end + +-- Store word to reserved position. +local function wputpos(pos, n) + assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") + actlist[pos] = n +end + +------------------------------------------------------------------------------ + +-- Global label name -> global label number. With auto assignment on 1st use. +local next_global = 20 +local map_global = setmetatable({}, { __index = function(t, name) + if not match(name, "^[%a_][%w_]*$") then werror("bad global label") end + local n = next_global + if n > 2047 then werror("too many global labels") end + next_global = n + 1 + t[name] = n + return n +end}) + +-- Dump global labels. +local function dumpglobals(out, lvl) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("Global labels:\n") + for i=20,next_global-1 do + out:write(format(" %s\n", t[i])) + end + out:write("\n") +end + +-- Write global label enum. +local function writeglobals(out, prefix) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("enum {\n") + for i=20,next_global-1 do + out:write(" ", prefix, t[i], ",\n") + end + out:write(" ", prefix, "_MAX\n};\n") +end + +-- Write global label names. +local function writeglobalnames(out, name) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("static const char *const ", name, "[] = {\n") + for i=20,next_global-1 do + out:write(" \"", t[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Extern label name -> extern label number. With auto assignment on 1st use. +local next_extern = 0 +local map_extern_ = {} +local map_extern = setmetatable({}, { __index = function(t, name) + -- No restrictions on the name for now. + local n = next_extern + if n > 2047 then werror("too many extern labels") end + next_extern = n + 1 + t[name] = n + map_extern_[n] = name + return n +end}) + +-- Dump extern labels. +local function dumpexterns(out, lvl) + out:write("Extern labels:\n") + for i=0,next_extern-1 do + out:write(format(" %s\n", map_extern_[i])) + end + out:write("\n") +end + +-- Write extern label names. +local function writeexternnames(out, name) + out:write("static const char *const ", name, "[] = {\n") + for i=0,next_extern-1 do + out:write(" \"", map_extern_[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Arch-specific maps. +local map_archdef = { sp = "r1" } -- Ext. register name -> int. name. + +local map_type = {} -- Type name -> { ctype, reg } +local ctypenum = 0 -- Type number (for Dt... macros). + +-- Reverse defines for registers. +function _M.revdef(s) + if s == "r1" then return "sp" end + return s +end + +local map_cond = { + lt = 0, gt = 1, eq = 2, so = 3, + ge = 4, le = 5, ne = 6, ns = 7, +} + +------------------------------------------------------------------------------ + +-- Template strings for PPC instructions. +local map_op = { + tdi_3 = "08000000ARI", + twi_3 = "0c000000ARI", + mulli_3 = "1c000000RRI", + subfic_3 = "20000000RRI", + cmplwi_3 = "28000000XRU", + cmplwi_2 = "28000000-RU", + cmpldi_3 = "28200000XRU", + cmpldi_2 = "28200000-RU", + cmpwi_3 = "2c000000XRI", + cmpwi_2 = "2c000000-RI", + cmpdi_3 = "2c200000XRI", + cmpdi_2 = "2c200000-RI", + addic_3 = "30000000RRI", + ["addic._3"] = "34000000RRI", + addi_3 = "38000000RR0I", + li_2 = "38000000RI", + la_2 = "38000000RD", + addis_3 = "3c000000RR0I", + lis_2 = "3c000000RI", + lus_2 = "3c000000RU", + bc_3 = "40000000AAK", + bcl_3 = "40000001AAK", + bdnz_1 = "42000000K", + bdz_1 = "42400000K", + sc_0 = "44000000", + b_1 = "48000000J", + bl_1 = "48000001J", + rlwimi_5 = "50000000RR~AAA.", + rlwinm_5 = "54000000RR~AAA.", + rlwnm_5 = "5c000000RR~RAA.", + ori_3 = "60000000RR~U", + nop_0 = "60000000", + oris_3 = "64000000RR~U", + xori_3 = "68000000RR~U", + xoris_3 = "6c000000RR~U", + ["andi._3"] = "70000000RR~U", + ["andis._3"] = "74000000RR~U", + lwz_2 = "80000000RD", + lwzu_2 = "84000000RD", + lbz_2 = "88000000RD", + lbzu_2 = "8c000000RD", + stw_2 = "90000000RD", + stwu_2 = "94000000RD", + stb_2 = "98000000RD", + stbu_2 = "9c000000RD", + lhz_2 = "a0000000RD", + lhzu_2 = "a4000000RD", + lha_2 = "a8000000RD", + lhau_2 = "ac000000RD", + sth_2 = "b0000000RD", + sthu_2 = "b4000000RD", + lmw_2 = "b8000000RD", + stmw_2 = "bc000000RD", + lfs_2 = "c0000000FD", + lfsu_2 = "c4000000FD", + lfd_2 = "c8000000FD", + lfdu_2 = "cc000000FD", + stfs_2 = "d0000000FD", + stfsu_2 = "d4000000FD", + stfd_2 = "d8000000FD", + stfdu_2 = "dc000000FD", + ld_2 = "e8000000RD", -- NYI: displacement must be divisible by 4. + ldu_2 = "e8000001RD", + lwa_2 = "e8000002RD", + std_2 = "f8000000RD", + stdu_2 = "f8000001RD", + + -- Primary opcode 19: + mcrf_2 = "4c000000XX", + isync_0 = "4c00012c", + crnor_3 = "4c000042CCC", + crnot_2 = "4c000042CC=", + crandc_3 = "4c000102CCC", + crxor_3 = "4c000182CCC", + crclr_1 = "4c000182C==", + crnand_3 = "4c0001c2CCC", + crand_3 = "4c000202CCC", + creqv_3 = "4c000242CCC", + crset_1 = "4c000242C==", + crorc_3 = "4c000342CCC", + cror_3 = "4c000382CCC", + crmove_2 = "4c000382CC=", + bclr_2 = "4c000020AA", + bclrl_2 = "4c000021AA", + bcctr_2 = "4c000420AA", + bcctrl_2 = "4c000421AA", + blr_0 = "4e800020", + blrl_0 = "4e800021", + bctr_0 = "4e800420", + bctrl_0 = "4e800421", + + -- Primary opcode 31: + cmpw_3 = "7c000000XRR", + cmpw_2 = "7c000000-RR", + cmpd_3 = "7c200000XRR", + cmpd_2 = "7c200000-RR", + tw_3 = "7c000008ARR", + subfc_3 = "7c000010RRR.", + subc_3 = "7c000010RRR~.", + mulhdu_3 = "7c000012RRR.", + addc_3 = "7c000014RRR.", + mulhwu_3 = "7c000016RRR.", + isel_4 = "7c00001eRRRC", + isellt_3 = "7c00001eRRR", + iselgt_3 = "7c00005eRRR", + iseleq_3 = "7c00009eRRR", + mfcr_1 = "7c000026R", + mfocrf_2 = "7c100026RG", + mtcrf_2 = "7c000120GR", + mtocrf_2 = "7c100120GR", + lwarx_3 = "7c000028RR0R", + ldx_3 = "7c00002aRR0R", + lwzx_3 = "7c00002eRR0R", + slw_3 = "7c000030RR~R.", + cntlzw_2 = "7c000034RR~", + sld_3 = "7c000036RR~R.", + and_3 = "7c000038RR~R.", + cmplw_3 = "7c000040XRR", + cmplw_2 = "7c000040-RR", + cmpld_3 = "7c200040XRR", + cmpld_2 = "7c200040-RR", + subf_3 = "7c000050RRR.", + sub_3 = "7c000050RRR~.", + ldux_3 = "7c00006aRR0R", + dcbst_2 = "7c00006c-RR", + lwzux_3 = "7c00006eRR0R", + cntlzd_2 = "7c000074RR~", + andc_3 = "7c000078RR~R.", + td_3 = "7c000088ARR", + mulhd_3 = "7c000092RRR.", + mulhw_3 = "7c000096RRR.", + ldarx_3 = "7c0000a8RR0R", + dcbf_2 = "7c0000ac-RR", + lbzx_3 = "7c0000aeRR0R", + neg_2 = "7c0000d0RR.", + lbzux_3 = "7c0000eeRR0R", + popcntb_2 = "7c0000f4RR~", + not_2 = "7c0000f8RR~%.", + nor_3 = "7c0000f8RR~R.", + subfe_3 = "7c000110RRR.", + sube_3 = "7c000110RRR~.", + adde_3 = "7c000114RRR.", + stdx_3 = "7c00012aRR0R", + stwcx_3 = "7c00012cRR0R.", + stwx_3 = "7c00012eRR0R", + prtyw_2 = "7c000134RR~", + stdux_3 = "7c00016aRR0R", + stwux_3 = "7c00016eRR0R", + prtyd_2 = "7c000174RR~", + subfze_2 = "7c000190RR.", + addze_2 = "7c000194RR.", + stdcx_3 = "7c0001acRR0R.", + stbx_3 = "7c0001aeRR0R", + subfme_2 = "7c0001d0RR.", + mulld_3 = "7c0001d2RRR.", + addme_2 = "7c0001d4RR.", + mullw_3 = "7c0001d6RRR.", + dcbtst_2 = "7c0001ec-RR", + stbux_3 = "7c0001eeRR0R", + add_3 = "7c000214RRR.", + dcbt_2 = "7c00022c-RR", + lhzx_3 = "7c00022eRR0R", + eqv_3 = "7c000238RR~R.", + eciwx_3 = "7c00026cRR0R", + lhzux_3 = "7c00026eRR0R", + xor_3 = "7c000278RR~R.", + mfspefscr_1 = "7c0082a6R", + mfxer_1 = "7c0102a6R", + mflr_1 = "7c0802a6R", + mfctr_1 = "7c0902a6R", + lwax_3 = "7c0002aaRR0R", + lhax_3 = "7c0002aeRR0R", + mftb_1 = "7c0c42e6R", + mftbu_1 = "7c0d42e6R", + lwaux_3 = "7c0002eaRR0R", + lhaux_3 = "7c0002eeRR0R", + sthx_3 = "7c00032eRR0R", + orc_3 = "7c000338RR~R.", + ecowx_3 = "7c00036cRR0R", + sthux_3 = "7c00036eRR0R", + or_3 = "7c000378RR~R.", + mr_2 = "7c000378RR~%.", + divdu_3 = "7c000392RRR.", + divwu_3 = "7c000396RRR.", + mtspefscr_1 = "7c0083a6R", + mtxer_1 = "7c0103a6R", + mtlr_1 = "7c0803a6R", + mtctr_1 = "7c0903a6R", + dcbi_2 = "7c0003ac-RR", + nand_3 = "7c0003b8RR~R.", + divd_3 = "7c0003d2RRR.", + divw_3 = "7c0003d6RRR.", + cmpb_3 = "7c0003f8RR~R.", + mcrxr_1 = "7c000400X", + subfco_3 = "7c000410RRR.", + subco_3 = "7c000410RRR~.", + addco_3 = "7c000414RRR.", + ldbrx_3 = "7c000428RR0R", + lswx_3 = "7c00042aRR0R", + lwbrx_3 = "7c00042cRR0R", + lfsx_3 = "7c00042eFR0R", + srw_3 = "7c000430RR~R.", + srd_3 = "7c000436RR~R.", + subfo_3 = "7c000450RRR.", + subo_3 = "7c000450RRR~.", + lfsux_3 = "7c00046eFR0R", + lswi_3 = "7c0004aaRR0A", + sync_0 = "7c0004ac", + lwsync_0 = "7c2004ac", + ptesync_0 = "7c4004ac", + lfdx_3 = "7c0004aeFR0R", + nego_2 = "7c0004d0RR.", + lfdux_3 = "7c0004eeFR0R", + subfeo_3 = "7c000510RRR.", + subeo_3 = "7c000510RRR~.", + addeo_3 = "7c000514RRR.", + stdbrx_3 = "7c000528RR0R", + stswx_3 = "7c00052aRR0R", + stwbrx_3 = "7c00052cRR0R", + stfsx_3 = "7c00052eFR0R", + stfsux_3 = "7c00056eFR0R", + subfzeo_2 = "7c000590RR.", + addzeo_2 = "7c000594RR.", + stswi_3 = "7c0005aaRR0A", + stfdx_3 = "7c0005aeFR0R", + subfmeo_2 = "7c0005d0RR.", + mulldo_3 = "7c0005d2RRR.", + addmeo_2 = "7c0005d4RR.", + mullwo_3 = "7c0005d6RRR.", + dcba_2 = "7c0005ec-RR", + stfdux_3 = "7c0005eeFR0R", + addo_3 = "7c000614RRR.", + lhbrx_3 = "7c00062cRR0R", + sraw_3 = "7c000630RR~R.", + srad_3 = "7c000634RR~R.", + srawi_3 = "7c000670RR~A.", + sradi_3 = "7c000674RR~H.", + eieio_0 = "7c0006ac", + lfiwax_3 = "7c0006aeFR0R", + sthbrx_3 = "7c00072cRR0R", + extsh_2 = "7c000734RR~.", + extsb_2 = "7c000774RR~.", + divduo_3 = "7c000792RRR.", + divwou_3 = "7c000796RRR.", + icbi_2 = "7c0007ac-RR", + stfiwx_3 = "7c0007aeFR0R", + extsw_2 = "7c0007b4RR~.", + divdo_3 = "7c0007d2RRR.", + divwo_3 = "7c0007d6RRR.", + dcbz_2 = "7c0007ec-RR", + + -- Primary opcode 30: + rldicl_4 = "78000000RR~HM.", + rldicr_4 = "78000004RR~HM.", + rldic_4 = "78000008RR~HM.", + rldimi_4 = "7800000cRR~HM.", + rldcl_4 = "78000010RR~RM.", + rldcr_4 = "78000012RR~RM.", + + -- Primary opcode 59: + fdivs_3 = "ec000024FFF.", + fsubs_3 = "ec000028FFF.", + fadds_3 = "ec00002aFFF.", + fsqrts_2 = "ec00002cF-F.", + fres_2 = "ec000030F-F.", + fmuls_3 = "ec000032FF-F.", + frsqrtes_2 = "ec000034F-F.", + fmsubs_4 = "ec000038FFFF~.", + fmadds_4 = "ec00003aFFFF~.", + fnmsubs_4 = "ec00003cFFFF~.", + fnmadds_4 = "ec00003eFFFF~.", + + -- Primary opcode 63: + fdiv_3 = "fc000024FFF.", + fsub_3 = "fc000028FFF.", + fadd_3 = "fc00002aFFF.", + fsqrt_2 = "fc00002cF-F.", + fsel_4 = "fc00002eFFFF~.", + fre_2 = "fc000030F-F.", + fmul_3 = "fc000032FF-F.", + frsqrte_2 = "fc000034F-F.", + fmsub_4 = "fc000038FFFF~.", + fmadd_4 = "fc00003aFFFF~.", + fnmsub_4 = "fc00003cFFFF~.", + fnmadd_4 = "fc00003eFFFF~.", + fcmpu_3 = "fc000000XFF", + fcpsgn_3 = "fc000010FFF.", + fcmpo_3 = "fc000040XFF", + mtfsb1_1 = "fc00004cA", + fneg_2 = "fc000050F-F.", + mcrfs_2 = "fc000080XX", + mtfsb0_1 = "fc00008cA", + fmr_2 = "fc000090F-F.", + frsp_2 = "fc000018F-F.", + fctiw_2 = "fc00001cF-F.", + fctiwz_2 = "fc00001eF-F.", + mtfsfi_2 = "fc00010cAA", -- NYI: upshift. + fnabs_2 = "fc000110F-F.", + fabs_2 = "fc000210F-F.", + frin_2 = "fc000310F-F.", + friz_2 = "fc000350F-F.", + frip_2 = "fc000390F-F.", + frim_2 = "fc0003d0F-F.", + mffs_1 = "fc00048eF.", + -- NYI: mtfsf, mtfsb0, mtfsb1. + fctid_2 = "fc00065cF-F.", + fctidz_2 = "fc00065eF-F.", + fcfid_2 = "fc00069cF-F.", + + -- Primary opcode 4, SPE APU extension: + evaddw_3 = "10000200RRR", + evaddiw_3 = "10000202RAR~", + evsubw_3 = "10000204RRR~", + evsubiw_3 = "10000206RAR~", + evabs_2 = "10000208RR", + evneg_2 = "10000209RR", + evextsb_2 = "1000020aRR", + evextsh_2 = "1000020bRR", + evrndw_2 = "1000020cRR", + evcntlzw_2 = "1000020dRR", + evcntlsw_2 = "1000020eRR", + brinc_3 = "1000020fRRR", + evand_3 = "10000211RRR", + evandc_3 = "10000212RRR", + evxor_3 = "10000216RRR", + evor_3 = "10000217RRR", + evmr_2 = "10000217RR=", + evnor_3 = "10000218RRR", + evnot_2 = "10000218RR=", + eveqv_3 = "10000219RRR", + evorc_3 = "1000021bRRR", + evnand_3 = "1000021eRRR", + evsrwu_3 = "10000220RRR", + evsrws_3 = "10000221RRR", + evsrwiu_3 = "10000222RRA", + evsrwis_3 = "10000223RRA", + evslw_3 = "10000224RRR", + evslwi_3 = "10000226RRA", + evrlw_3 = "10000228RRR", + evsplati_2 = "10000229RS", + evrlwi_3 = "1000022aRRA", + evsplatfi_2 = "1000022bRS", + evmergehi_3 = "1000022cRRR", + evmergelo_3 = "1000022dRRR", + evcmpgtu_3 = "10000230XRR", + evcmpgtu_2 = "10000230-RR", + evcmpgts_3 = "10000231XRR", + evcmpgts_2 = "10000231-RR", + evcmpltu_3 = "10000232XRR", + evcmpltu_2 = "10000232-RR", + evcmplts_3 = "10000233XRR", + evcmplts_2 = "10000233-RR", + evcmpeq_3 = "10000234XRR", + evcmpeq_2 = "10000234-RR", + evsel_4 = "10000278RRRW", + evsel_3 = "10000278RRR", + evfsadd_3 = "10000280RRR", + evfssub_3 = "10000281RRR", + evfsabs_2 = "10000284RR", + evfsnabs_2 = "10000285RR", + evfsneg_2 = "10000286RR", + evfsmul_3 = "10000288RRR", + evfsdiv_3 = "10000289RRR", + evfscmpgt_3 = "1000028cXRR", + evfscmpgt_2 = "1000028c-RR", + evfscmplt_3 = "1000028dXRR", + evfscmplt_2 = "1000028d-RR", + evfscmpeq_3 = "1000028eXRR", + evfscmpeq_2 = "1000028e-RR", + evfscfui_2 = "10000290R-R", + evfscfsi_2 = "10000291R-R", + evfscfuf_2 = "10000292R-R", + evfscfsf_2 = "10000293R-R", + evfsctui_2 = "10000294R-R", + evfsctsi_2 = "10000295R-R", + evfsctuf_2 = "10000296R-R", + evfsctsf_2 = "10000297R-R", + evfsctuiz_2 = "10000298R-R", + evfsctsiz_2 = "1000029aR-R", + evfststgt_3 = "1000029cXRR", + evfststgt_2 = "1000029c-RR", + evfststlt_3 = "1000029dXRR", + evfststlt_2 = "1000029d-RR", + evfststeq_3 = "1000029eXRR", + evfststeq_2 = "1000029e-RR", + efsadd_3 = "100002c0RRR", + efssub_3 = "100002c1RRR", + efsabs_2 = "100002c4RR", + efsnabs_2 = "100002c5RR", + efsneg_2 = "100002c6RR", + efsmul_3 = "100002c8RRR", + efsdiv_3 = "100002c9RRR", + efscmpgt_3 = "100002ccXRR", + efscmpgt_2 = "100002cc-RR", + efscmplt_3 = "100002cdXRR", + efscmplt_2 = "100002cd-RR", + efscmpeq_3 = "100002ceXRR", + efscmpeq_2 = "100002ce-RR", + efscfd_2 = "100002cfR-R", + efscfui_2 = "100002d0R-R", + efscfsi_2 = "100002d1R-R", + efscfuf_2 = "100002d2R-R", + efscfsf_2 = "100002d3R-R", + efsctui_2 = "100002d4R-R", + efsctsi_2 = "100002d5R-R", + efsctuf_2 = "100002d6R-R", + efsctsf_2 = "100002d7R-R", + efsctuiz_2 = "100002d8R-R", + efsctsiz_2 = "100002daR-R", + efststgt_3 = "100002dcXRR", + efststgt_2 = "100002dc-RR", + efststlt_3 = "100002ddXRR", + efststlt_2 = "100002dd-RR", + efststeq_3 = "100002deXRR", + efststeq_2 = "100002de-RR", + efdadd_3 = "100002e0RRR", + efdsub_3 = "100002e1RRR", + efdcfuid_2 = "100002e2R-R", + efdcfsid_2 = "100002e3R-R", + efdabs_2 = "100002e4RR", + efdnabs_2 = "100002e5RR", + efdneg_2 = "100002e6RR", + efdmul_3 = "100002e8RRR", + efddiv_3 = "100002e9RRR", + efdctuidz_2 = "100002eaR-R", + efdctsidz_2 = "100002ebR-R", + efdcmpgt_3 = "100002ecXRR", + efdcmpgt_2 = "100002ec-RR", + efdcmplt_3 = "100002edXRR", + efdcmplt_2 = "100002ed-RR", + efdcmpeq_3 = "100002eeXRR", + efdcmpeq_2 = "100002ee-RR", + efdcfs_2 = "100002efR-R", + efdcfui_2 = "100002f0R-R", + efdcfsi_2 = "100002f1R-R", + efdcfuf_2 = "100002f2R-R", + efdcfsf_2 = "100002f3R-R", + efdctui_2 = "100002f4R-R", + efdctsi_2 = "100002f5R-R", + efdctuf_2 = "100002f6R-R", + efdctsf_2 = "100002f7R-R", + efdctuiz_2 = "100002f8R-R", + efdctsiz_2 = "100002faR-R", + efdtstgt_3 = "100002fcXRR", + efdtstgt_2 = "100002fc-RR", + efdtstlt_3 = "100002fdXRR", + efdtstlt_2 = "100002fd-RR", + efdtsteq_3 = "100002feXRR", + efdtsteq_2 = "100002fe-RR", + evlddx_3 = "10000300RR0R", + evldd_2 = "10000301R8", + evldwx_3 = "10000302RR0R", + evldw_2 = "10000303R8", + evldhx_3 = "10000304RR0R", + evldh_2 = "10000305R8", + evlwhex_3 = "10000310RR0R", + evlwhe_2 = "10000311R4", + evlwhoux_3 = "10000314RR0R", + evlwhou_2 = "10000315R4", + evlwhosx_3 = "10000316RR0R", + evlwhos_2 = "10000317R4", + evstddx_3 = "10000320RR0R", + evstdd_2 = "10000321R8", + evstdwx_3 = "10000322RR0R", + evstdw_2 = "10000323R8", + evstdhx_3 = "10000324RR0R", + evstdh_2 = "10000325R8", + evstwhex_3 = "10000330RR0R", + evstwhe_2 = "10000331R4", + evstwhox_3 = "10000334RR0R", + evstwho_2 = "10000335R4", + evstwwex_3 = "10000338RR0R", + evstwwe_2 = "10000339R4", + evstwwox_3 = "1000033cRR0R", + evstwwo_2 = "1000033dR4", + evmhessf_3 = "10000403RRR", + evmhossf_3 = "10000407RRR", + evmheumi_3 = "10000408RRR", + evmhesmi_3 = "10000409RRR", + evmhesmf_3 = "1000040bRRR", + evmhoumi_3 = "1000040cRRR", + evmhosmi_3 = "1000040dRRR", + evmhosmf_3 = "1000040fRRR", + evmhessfa_3 = "10000423RRR", + evmhossfa_3 = "10000427RRR", + evmheumia_3 = "10000428RRR", + evmhesmia_3 = "10000429RRR", + evmhesmfa_3 = "1000042bRRR", + evmhoumia_3 = "1000042cRRR", + evmhosmia_3 = "1000042dRRR", + evmhosmfa_3 = "1000042fRRR", + evmwhssf_3 = "10000447RRR", + evmwlumi_3 = "10000448RRR", + evmwhumi_3 = "1000044cRRR", + evmwhsmi_3 = "1000044dRRR", + evmwhsmf_3 = "1000044fRRR", + evmwssf_3 = "10000453RRR", + evmwumi_3 = "10000458RRR", + evmwsmi_3 = "10000459RRR", + evmwsmf_3 = "1000045bRRR", + evmwhssfa_3 = "10000467RRR", + evmwlumia_3 = "10000468RRR", + evmwhumia_3 = "1000046cRRR", + evmwhsmia_3 = "1000046dRRR", + evmwhsmfa_3 = "1000046fRRR", + evmwssfa_3 = "10000473RRR", + evmwumia_3 = "10000478RRR", + evmwsmia_3 = "10000479RRR", + evmwsmfa_3 = "1000047bRRR", + evmra_2 = "100004c4RR", + evdivws_3 = "100004c6RRR", + evdivwu_3 = "100004c7RRR", + evmwssfaa_3 = "10000553RRR", + evmwumiaa_3 = "10000558RRR", + evmwsmiaa_3 = "10000559RRR", + evmwsmfaa_3 = "1000055bRRR", + evmwssfan_3 = "100005d3RRR", + evmwumian_3 = "100005d8RRR", + evmwsmian_3 = "100005d9RRR", + evmwsmfan_3 = "100005dbRRR", + evmergehilo_3 = "1000022eRRR", + evmergelohi_3 = "1000022fRRR", + evlhhesplatx_3 = "10000308RR0R", + evlhhesplat_2 = "10000309R2", + evlhhousplatx_3 = "1000030cRR0R", + evlhhousplat_2 = "1000030dR2", + evlhhossplatx_3 = "1000030eRR0R", + evlhhossplat_2 = "1000030fR2", + evlwwsplatx_3 = "10000318RR0R", + evlwwsplat_2 = "10000319R4", + evlwhsplatx_3 = "1000031cRR0R", + evlwhsplat_2 = "1000031dR4", + evaddusiaaw_2 = "100004c0RR", + evaddssiaaw_2 = "100004c1RR", + evsubfusiaaw_2 = "100004c2RR", + evsubfssiaaw_2 = "100004c3RR", + evaddumiaaw_2 = "100004c8RR", + evaddsmiaaw_2 = "100004c9RR", + evsubfumiaaw_2 = "100004caRR", + evsubfsmiaaw_2 = "100004cbRR", + evmheusiaaw_3 = "10000500RRR", + evmhessiaaw_3 = "10000501RRR", + evmhessfaaw_3 = "10000503RRR", + evmhousiaaw_3 = "10000504RRR", + evmhossiaaw_3 = "10000505RRR", + evmhossfaaw_3 = "10000507RRR", + evmheumiaaw_3 = "10000508RRR", + evmhesmiaaw_3 = "10000509RRR", + evmhesmfaaw_3 = "1000050bRRR", + evmhoumiaaw_3 = "1000050cRRR", + evmhosmiaaw_3 = "1000050dRRR", + evmhosmfaaw_3 = "1000050fRRR", + evmhegumiaa_3 = "10000528RRR", + evmhegsmiaa_3 = "10000529RRR", + evmhegsmfaa_3 = "1000052bRRR", + evmhogumiaa_3 = "1000052cRRR", + evmhogsmiaa_3 = "1000052dRRR", + evmhogsmfaa_3 = "1000052fRRR", + evmwlusiaaw_3 = "10000540RRR", + evmwlssiaaw_3 = "10000541RRR", + evmwlumiaaw_3 = "10000548RRR", + evmwlsmiaaw_3 = "10000549RRR", + evmheusianw_3 = "10000580RRR", + evmhessianw_3 = "10000581RRR", + evmhessfanw_3 = "10000583RRR", + evmhousianw_3 = "10000584RRR", + evmhossianw_3 = "10000585RRR", + evmhossfanw_3 = "10000587RRR", + evmheumianw_3 = "10000588RRR", + evmhesmianw_3 = "10000589RRR", + evmhesmfanw_3 = "1000058bRRR", + evmhoumianw_3 = "1000058cRRR", + evmhosmianw_3 = "1000058dRRR", + evmhosmfanw_3 = "1000058fRRR", + evmhegumian_3 = "100005a8RRR", + evmhegsmian_3 = "100005a9RRR", + evmhegsmfan_3 = "100005abRRR", + evmhogumian_3 = "100005acRRR", + evmhogsmian_3 = "100005adRRR", + evmhogsmfan_3 = "100005afRRR", + evmwlusianw_3 = "100005c0RRR", + evmwlssianw_3 = "100005c1RRR", + evmwlumianw_3 = "100005c8RRR", + evmwlsmianw_3 = "100005c9RRR", + + -- NYI: Book E instructions. +} + +-- Add mnemonics for "." variants. +do + local t = {} + for k,v in pairs(map_op) do + if sub(v, -1) == "." then + local v2 = sub(v, 1, 7)..char(byte(v, 8)+1)..sub(v, 9, -2) + t[sub(k, 1, -3).."."..sub(k, -2)] = v2 + end + end + for k,v in pairs(t) do + map_op[k] = v + end +end + +-- Add more branch mnemonics. +for cond,c in pairs(map_cond) do + local b1 = "b"..cond + local c1 = shl(band(c, 3), 16) + (c < 4 and 0x01000000 or 0) + -- bX[l] + map_op[b1.."_1"] = tohex(0x40800000 + c1).."K" + map_op[b1.."y_1"] = tohex(0x40a00000 + c1).."K" + map_op[b1.."l_1"] = tohex(0x40800001 + c1).."K" + map_op[b1.."_2"] = tohex(0x40800000 + c1).."-XK" + map_op[b1.."y_2"] = tohex(0x40a00000 + c1).."-XK" + map_op[b1.."l_2"] = tohex(0x40800001 + c1).."-XK" + -- bXlr[l] + map_op[b1.."lr_0"] = tohex(0x4c800020 + c1) + map_op[b1.."lrl_0"] = tohex(0x4c800021 + c1) + map_op[b1.."ctr_0"] = tohex(0x4c800420 + c1) + map_op[b1.."ctrl_0"] = tohex(0x4c800421 + c1) + -- bXctr[l] + map_op[b1.."lr_1"] = tohex(0x4c800020 + c1).."-X" + map_op[b1.."lrl_1"] = tohex(0x4c800021 + c1).."-X" + map_op[b1.."ctr_1"] = tohex(0x4c800420 + c1).."-X" + map_op[b1.."ctrl_1"] = tohex(0x4c800421 + c1).."-X" +end + +------------------------------------------------------------------------------ + +local function parse_gpr(expr) + local tname, ovreg = match(expr, "^([%w_]+):(r[1-3]?[0-9])$") + local tp = map_type[tname or expr] + if tp then + local reg = ovreg or tp.reg + if not reg then + werror("type `"..(tname or expr).."' needs a register override") + end + expr = reg + end + local r = match(expr, "^r([1-3]?[0-9])$") + if r then + r = tonumber(r) + if r <= 31 then return r, tp end + end + werror("bad register name `"..expr.."'") +end + +local function parse_fpr(expr) + local r = match(expr, "^f([1-3]?[0-9])$") + if r then + r = tonumber(r) + if r <= 31 then return r end + end + werror("bad register name `"..expr.."'") +end + +local function parse_cr(expr) + local r = match(expr, "^cr([0-7])$") + if r then return tonumber(r) end + werror("bad condition register name `"..expr.."'") +end + +local function parse_cond(expr) + local r, cond = match(expr, "^4%*cr([0-7])%+(%w%w)$") + if r then + r = tonumber(r) + local c = map_cond[cond] + if c and c < 4 then return r*4+c end + end + werror("bad condition bit name `"..expr.."'") +end + +local function parse_imm(imm, bits, shift, scale, signed) + local n = tonumber(imm) + if n then + local m = sar(n, scale) + if shl(m, scale) == n then + if signed then + local s = sar(m, bits-1) + if s == 0 then return shl(m, shift) + elseif s == -1 then return shl(m + shl(1, bits), shift) end + else + if sar(m, bits) == 0 then return shl(m, shift) end + end + end + werror("out of range immediate `"..imm.."'") + elseif match(imm, "^r([1-3]?[0-9])$") or + match(imm, "^([%w_]+):(r[1-3]?[0-9])$") then + werror("expected immediate operand, got register") + else + waction("IMM", (signed and 32768 or 0)+scale*1024+bits*32+shift, imm) + return 0 + end +end + +local function parse_shiftmask(imm, isshift) + local n = tonumber(imm) + if n then + if shr(n, 6) == 0 then + local lsb = band(imm, 31) + local msb = imm - lsb + return isshift and (shl(lsb, 11)+shr(msb, 4)) or (shl(lsb, 6)+msb) + end + werror("out of range immediate `"..imm.."'") + elseif match(imm, "^r([1-3]?[0-9])$") or + match(imm, "^([%w_]+):(r[1-3]?[0-9])$") then + werror("expected immediate operand, got register") + else + werror("NYI: parameterized 64 bit shift/mask") + end +end + +local function parse_disp(disp) + local imm, reg = match(disp, "^(.*)%(([%w_:]+)%)$") + if imm then + local r = parse_gpr(reg) + if r == 0 then werror("cannot use r0 in displacement") end + return shl(r, 16) + parse_imm(imm, 16, 0, 0, true) + end + local reg, tailr = match(disp, "^([%w_:]+)%s*(.*)$") + if reg and tailr ~= "" then + local r, tp = parse_gpr(reg) + if r == 0 then werror("cannot use r0 in displacement") end + if tp then + waction("IMM", 32768+16*32, format(tp.ctypefmt, tailr)) + return shl(r, 16) + end + end + werror("bad displacement `"..disp.."'") +end + +local function parse_u5disp(disp, scale) + local imm, reg = match(disp, "^(.*)%(([%w_:]+)%)$") + if imm then + local r = parse_gpr(reg) + if r == 0 then werror("cannot use r0 in displacement") end + return shl(r, 16) + parse_imm(imm, 5, 11, scale, false) + end + local reg, tailr = match(disp, "^([%w_:]+)%s*(.*)$") + if reg and tailr ~= "" then + local r, tp = parse_gpr(reg) + if r == 0 then werror("cannot use r0 in displacement") end + if tp then + waction("IMM", scale*1024+5*32+11, format(tp.ctypefmt, tailr)) + return shl(r, 16) + end + end + werror("bad displacement `"..disp.."'") +end + +local function parse_label(label, def) + local prefix = sub(label, 1, 2) + -- =>label (pc label reference) + if prefix == "=>" then + return "PC", 0, sub(label, 3) + end + -- ->name (global label reference) + if prefix == "->" then + return "LG", map_global[sub(label, 3)] + end + if def then + -- [1-9] (local label definition) + if match(label, "^[1-9]$") then + return "LG", 10+tonumber(label) + end + else + -- [<>][1-9] (local label reference) + local dir, lnum = match(label, "^([<>])([1-9])$") + if dir then -- Fwd: 1-9, Bkwd: 11-19. + return "LG", lnum + (dir == ">" and 0 or 10) + end + -- extern label (extern label reference) + local extname = match(label, "^extern%s+(%S+)$") + if extname then + return "EXT", map_extern[extname] + end + end + werror("bad label `"..label.."'") +end + +------------------------------------------------------------------------------ + +-- Handle opcodes defined with template strings. +map_op[".template__"] = function(params, template, nparams) + if not params then return sub(template, 9) end + local op = tonumber(sub(template, 1, 8), 16) + local n, rs = 1, 26 + + -- Limit number of section buffer positions used by a single dasm_put(). + -- A single opcode needs a maximum of 3 positions (rlwinm). + if secpos+3 > maxsecpos then wflush() end + local pos = wpos() + + -- Process each character. + for p in gmatch(sub(template, 9), ".") do + if p == "R" then + rs = rs - 5; op = op + shl(parse_gpr(params[n]), rs); n = n + 1 + elseif p == "F" then + rs = rs - 5; op = op + shl(parse_fpr(params[n]), rs); n = n + 1 + elseif p == "A" then + rs = rs - 5; op = op + parse_imm(params[n], 5, rs, 0, false); n = n + 1 + elseif p == "S" then + rs = rs - 5; op = op + parse_imm(params[n], 5, rs, 0, true); n = n + 1 + elseif p == "I" then + op = op + parse_imm(params[n], 16, 0, 0, true); n = n + 1 + elseif p == "U" then + op = op + parse_imm(params[n], 16, 0, 0, false); n = n + 1 + elseif p == "D" then + op = op + parse_disp(params[n]); n = n + 1 + elseif p == "2" then + op = op + parse_u5disp(params[n], 1); n = n + 1 + elseif p == "4" then + op = op + parse_u5disp(params[n], 2); n = n + 1 + elseif p == "8" then + op = op + parse_u5disp(params[n], 3); n = n + 1 + elseif p == "C" then + rs = rs - 5; op = op + shl(parse_cond(params[n]), rs); n = n + 1 + elseif p == "X" then + rs = rs - 5; op = op + shl(parse_cr(params[n]), rs+2); n = n + 1 + elseif p == "W" then + op = op + parse_cr(params[n]); n = n + 1 + elseif p == "G" then + op = op + parse_imm(params[n], 8, 12, 0, false); n = n + 1 + elseif p == "H" then + op = op + parse_shiftmask(params[n], true); n = n + 1 + elseif p == "M" then + op = op + parse_shiftmask(params[n], false); n = n + 1 + elseif p == "J" or p == "K" then + local mode, n, s = parse_label(params[n], false) + if p == "K" then n = n + 2048 end + waction("REL_"..mode, n, s, 1) + n = n + 1 + elseif p == "0" then + if band(shr(op, rs), 31) == 0 then werror("cannot use r0") end + elseif p == "=" or p == "%" then + local t = band(shr(op, p == "%" and rs+5 or rs), 31) + rs = rs - 5 + op = op + shl(t, rs) + elseif p == "~" then + local mm = shl(31, rs) + local lo = band(op, mm) + local hi = band(op, shl(mm, 5)) + op = op - lo - hi + shl(lo, 5) + shr(hi, 5) + elseif p == "-" then + rs = rs - 5 + elseif p == "." then + -- Ignored. + else + assert(false) + end + end + wputpos(pos, op) +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcode to mark the position where the action list is to be emitted. +map_op[".actionlist_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeactions(out, name) end) +end + +-- Pseudo-opcode to mark the position where the global enum is to be emitted. +map_op[".globals_1"] = function(params) + if not params then return "prefix" end + local prefix = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobals(out, prefix) end) +end + +-- Pseudo-opcode to mark the position where the global names are to be emitted. +map_op[".globalnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobalnames(out, name) end) +end + +-- Pseudo-opcode to mark the position where the extern names are to be emitted. +map_op[".externnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeexternnames(out, name) end) +end + +------------------------------------------------------------------------------ + +-- Label pseudo-opcode (converted from trailing colon form). +map_op[".label_1"] = function(params) + if not params then return "[1-9] | ->global | =>pcexpr" end + if secpos+1 > maxsecpos then wflush() end + local mode, n, s = parse_label(params[1], true) + if mode == "EXT" then werror("bad label definition") end + waction("LABEL_"..mode, n, s, 1) +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcodes for data storage. +map_op[".long_*"] = function(params) + if not params then return "imm..." end + for _,p in ipairs(params) do + local n = tonumber(p) + if not n then werror("bad immediate `"..p.."'") end + if n < 0 then n = n + 2^32 end + wputw(n) + if secpos+2 > maxsecpos then wflush() end + end +end + +-- Alignment pseudo-opcode. +map_op[".align_1"] = function(params) + if not params then return "numpow2" end + if secpos+1 > maxsecpos then wflush() end + local align = tonumber(params[1]) + if align then + local x = align + -- Must be a power of 2 in the range (2 ... 256). + for i=1,8 do + x = x / 2 + if x == 1 then + waction("ALIGN", align-1, nil, 1) -- Action byte is 2**n-1. + return + end + end + end + werror("bad alignment") +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcode for (primitive) type definitions (map to C types). +map_op[".type_3"] = function(params, nparams) + if not params then + return nparams == 2 and "name, ctype" or "name, ctype, reg" + end + local name, ctype, reg = params[1], params[2], params[3] + if not match(name, "^[%a_][%w_]*$") then + werror("bad type name `"..name.."'") + end + local tp = map_type[name] + if tp then + werror("duplicate type `"..name.."'") + end + -- Add #type to defines. A bit unclean to put it in map_archdef. + map_archdef["#"..name] = "sizeof("..ctype..")" + -- Add new type and emit shortcut define. + local num = ctypenum + 1 + map_type[name] = { + ctype = ctype, + ctypefmt = format("Dt%X(%%s)", num), + reg = reg, + } + wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) + ctypenum = num +end +map_op[".type_2"] = map_op[".type_3"] + +-- Dump type definitions. +local function dumptypes(out, lvl) + local t = {} + for name in pairs(map_type) do t[#t+1] = name end + sort(t) + out:write("Type definitions:\n") + for _,name in ipairs(t) do + local tp = map_type[name] + local reg = tp.reg or "" + out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) + end + out:write("\n") +end + +------------------------------------------------------------------------------ + +-- Set the current section. +function _M.section(num) + waction("SECTION", num) + wflush(true) -- SECTION is a terminal action. +end + +------------------------------------------------------------------------------ + +-- Dump architecture description. +function _M.dumparch(out) + out:write(format("DynASM %s version %s, released %s\n\n", + _info.arch, _info.version, _info.release)) + dumpactions(out) +end + +-- Dump all user defined elements. +function _M.dumpdef(out, lvl) + dumptypes(out, lvl) + dumpglobals(out, lvl) + dumpexterns(out, lvl) +end + +------------------------------------------------------------------------------ + +-- Pass callbacks from/to the DynASM core. +function _M.passcb(wl, we, wf, ww) + wline, werror, wfatal, wwarn = wl, we, wf, ww + return wflush +end + +-- Setup the arch-specific module. +function _M.setup(arch, opt) + g_arch, g_opt = arch, opt +end + +-- Merge the core maps and the arch-specific maps. +function _M.mergemaps(map_coreop, map_def) + setmetatable(map_op, { __index = map_coreop }) + setmetatable(map_def, { __index = map_archdef }) + return map_op, map_def +end + +return _M + +------------------------------------------------------------------------------ + + +``` + +`include/luajit-2.0.5/dynasm/dasm_proto.h`: + +```h +/* +** DynASM encoding engine prototypes. +** Copyright (C) 2005-2017 Mike Pall. All rights reserved. +** Released under the MIT license. See dynasm.lua for full copyright notice. +*/ + +#ifndef _DASM_PROTO_H +#define _DASM_PROTO_H + +#include +#include + +#define DASM_IDENT "DynASM 1.3.0" +#define DASM_VERSION 10300 /* 1.3.0 */ + +#ifndef Dst_DECL +#define Dst_DECL dasm_State **Dst +#endif + +#ifndef Dst_REF +#define Dst_REF (*Dst) +#endif + +#ifndef DASM_FDEF +#define DASM_FDEF extern +#endif + +#ifndef DASM_M_GROW +#define DASM_M_GROW(ctx, t, p, sz, need) \ + do { \ + size_t _sz = (sz), _need = (need); \ + if (_sz < _need) { \ + if (_sz < 16) _sz = 16; \ + while (_sz < _need) _sz += _sz; \ + (p) = (t *)realloc((p), _sz); \ + if ((p) == NULL) exit(1); \ + (sz) = _sz; \ + } \ + } while(0) +#endif + +#ifndef DASM_M_FREE +#define DASM_M_FREE(ctx, p, sz) free(p) +#endif + +/* Internal DynASM encoder state. */ +typedef struct dasm_State dasm_State; + + +/* Initialize and free DynASM state. */ +DASM_FDEF void dasm_init(Dst_DECL, int maxsection); +DASM_FDEF void dasm_free(Dst_DECL); + +/* Setup global array. Must be called before dasm_setup(). */ +DASM_FDEF void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl); + +/* Grow PC label array. Can be called after dasm_setup(), too. */ +DASM_FDEF void dasm_growpc(Dst_DECL, unsigned int maxpc); + +/* Setup encoder. */ +DASM_FDEF void dasm_setup(Dst_DECL, const void *actionlist); + +/* Feed encoder with actions. Calls are generated by pre-processor. */ +DASM_FDEF void dasm_put(Dst_DECL, int start, ...); + +/* Link sections and return the resulting size. */ +DASM_FDEF int dasm_link(Dst_DECL, size_t *szp); + +/* Encode sections into buffer. */ +DASM_FDEF int dasm_encode(Dst_DECL, void *buffer); + +/* Get PC label offset. */ +DASM_FDEF int dasm_getpclabel(Dst_DECL, unsigned int pc); + +#ifdef DASM_CHECKS +/* Optional sanity checker to call between isolated encoding steps. */ +DASM_FDEF int dasm_checkstep(Dst_DECL, int secmatch); +#else +#define dasm_checkstep(a, b) 0 +#endif + + +#endif /* _DASM_PROTO_H */ + +``` + +`include/luajit-2.0.5/dynasm/dasm_x64.lua`: + +```lua +------------------------------------------------------------------------------ +-- DynASM x64 module. +-- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- See dynasm.lua for full copyright notice. +------------------------------------------------------------------------------ +-- This module just sets 64 bit mode for the combined x86/x64 module. +-- All the interesting stuff is there. +------------------------------------------------------------------------------ + +x64 = true -- Using a global is an ugly, but effective solution. +return require("dasm_x86") + +``` + +`include/luajit-2.0.5/dynasm/dasm_x86.h`: + +```h +/* +** DynASM x86 encoding engine. +** Copyright (C) 2005-2017 Mike Pall. All rights reserved. +** Released under the MIT license. See dynasm.lua for full copyright notice. +*/ + +#include +#include +#include +#include + +#define DASM_ARCH "x86" + +#ifndef DASM_EXTERN +#define DASM_EXTERN(a,b,c,d) 0 +#endif + +/* Action definitions. DASM_STOP must be 255. */ +enum { + DASM_DISP = 233, + DASM_IMM_S, DASM_IMM_B, DASM_IMM_W, DASM_IMM_D, DASM_IMM_WB, DASM_IMM_DB, + DASM_VREG, DASM_SPACE, DASM_SETLABEL, DASM_REL_A, DASM_REL_LG, DASM_REL_PC, + DASM_IMM_LG, DASM_IMM_PC, DASM_LABEL_LG, DASM_LABEL_PC, DASM_ALIGN, + DASM_EXTERN, DASM_ESC, DASM_MARK, DASM_SECTION, DASM_STOP +}; + +/* Maximum number of section buffer positions for a single dasm_put() call. */ +#define DASM_MAXSECPOS 25 + +/* DynASM encoder status codes. Action list offset or number are or'ed in. */ +#define DASM_S_OK 0x00000000 +#define DASM_S_NOMEM 0x01000000 +#define DASM_S_PHASE 0x02000000 +#define DASM_S_MATCH_SEC 0x03000000 +#define DASM_S_RANGE_I 0x11000000 +#define DASM_S_RANGE_SEC 0x12000000 +#define DASM_S_RANGE_LG 0x13000000 +#define DASM_S_RANGE_PC 0x14000000 +#define DASM_S_RANGE_VREG 0x15000000 +#define DASM_S_UNDEF_L 0x21000000 +#define DASM_S_UNDEF_PC 0x22000000 + +/* Macros to convert positions (8 bit section + 24 bit index). */ +#define DASM_POS2IDX(pos) ((pos)&0x00ffffff) +#define DASM_POS2BIAS(pos) ((pos)&0xff000000) +#define DASM_SEC2POS(sec) ((sec)<<24) +#define DASM_POS2SEC(pos) ((pos)>>24) +#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) + +/* Action list type. */ +typedef const unsigned char *dasm_ActList; + +/* Per-section structure. */ +typedef struct dasm_Section { + int *rbuf; /* Biased buffer pointer (negative section bias). */ + int *buf; /* True buffer pointer. */ + size_t bsize; /* Buffer size in bytes. */ + int pos; /* Biased buffer position. */ + int epos; /* End of biased buffer position - max single put. */ + int ofs; /* Byte offset into section. */ +} dasm_Section; + +/* Core structure holding the DynASM encoding state. */ +struct dasm_State { + size_t psize; /* Allocated size of this structure. */ + dasm_ActList actionlist; /* Current actionlist pointer. */ + int *lglabels; /* Local/global chain/pos ptrs. */ + size_t lgsize; + int *pclabels; /* PC label chains/pos ptrs. */ + size_t pcsize; + void **globals; /* Array of globals (bias -10). */ + dasm_Section *section; /* Pointer to active section. */ + size_t codesize; /* Total size of all code sections. */ + int maxsection; /* 0 <= sectionidx < maxsection. */ + int status; /* Status code. */ + dasm_Section sections[1]; /* All sections. Alloc-extended. */ +}; + +/* The size of the core structure depends on the max. number of sections. */ +#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) + + +/* Initialize DynASM state. */ +void dasm_init(Dst_DECL, int maxsection) +{ + dasm_State *D; + size_t psz = 0; + int i; + Dst_REF = NULL; + DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); + D = Dst_REF; + D->psize = psz; + D->lglabels = NULL; + D->lgsize = 0; + D->pclabels = NULL; + D->pcsize = 0; + D->globals = NULL; + D->maxsection = maxsection; + for (i = 0; i < maxsection; i++) { + D->sections[i].buf = NULL; /* Need this for pass3. */ + D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); + D->sections[i].bsize = 0; + D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ + } +} + +/* Free DynASM state. */ +void dasm_free(Dst_DECL) +{ + dasm_State *D = Dst_REF; + int i; + for (i = 0; i < D->maxsection; i++) + if (D->sections[i].buf) + DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); + if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); + if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); + DASM_M_FREE(Dst, D, D->psize); +} + +/* Setup global label array. Must be called before dasm_setup(). */ +void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) +{ + dasm_State *D = Dst_REF; + D->globals = gl - 10; /* Negative bias to compensate for locals. */ + DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); +} + +/* Grow PC label array. Can be called after dasm_setup(), too. */ +void dasm_growpc(Dst_DECL, unsigned int maxpc) +{ + dasm_State *D = Dst_REF; + size_t osz = D->pcsize; + DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); + memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); +} + +/* Setup encoder. */ +void dasm_setup(Dst_DECL, const void *actionlist) +{ + dasm_State *D = Dst_REF; + int i; + D->actionlist = (dasm_ActList)actionlist; + D->status = DASM_S_OK; + D->section = &D->sections[0]; + memset((void *)D->lglabels, 0, D->lgsize); + if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); + for (i = 0; i < D->maxsection; i++) { + D->sections[i].pos = DASM_SEC2POS(i); + D->sections[i].ofs = 0; + } +} + + +#ifdef DASM_CHECKS +#define CK(x, st) \ + do { if (!(x)) { \ + D->status = DASM_S_##st|(int)(p-D->actionlist-1); return; } } while (0) +#define CKPL(kind, st) \ + do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ + D->status=DASM_S_RANGE_##st|(int)(p-D->actionlist-1); return; } } while (0) +#else +#define CK(x, st) ((void)0) +#define CKPL(kind, st) ((void)0) +#endif + +/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ +void dasm_put(Dst_DECL, int start, ...) +{ + va_list ap; + dasm_State *D = Dst_REF; + dasm_ActList p = D->actionlist + start; + dasm_Section *sec = D->section; + int pos = sec->pos, ofs = sec->ofs, mrm = 4; + int *b; + + if (pos >= sec->epos) { + DASM_M_GROW(Dst, int, sec->buf, sec->bsize, + sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); + sec->rbuf = sec->buf - DASM_POS2BIAS(pos); + sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); + } + + b = sec->rbuf; + b[pos++] = start; + + va_start(ap, start); + while (1) { + int action = *p++; + if (action < DASM_DISP) { + ofs++; + } else if (action <= DASM_REL_A) { + int n = va_arg(ap, int); + b[pos++] = n; + switch (action) { + case DASM_DISP: + if (n == 0) { if ((mrm&7) == 4) mrm = p[-2]; if ((mrm&7) != 5) break; } + case DASM_IMM_DB: if (((n+128)&-256) == 0) goto ob; + case DASM_REL_A: /* Assumes ptrdiff_t is int. !x64 */ + case DASM_IMM_D: ofs += 4; break; + case DASM_IMM_S: CK(((n+128)&-256) == 0, RANGE_I); goto ob; + case DASM_IMM_B: CK((n&-256) == 0, RANGE_I); ob: ofs++; break; + case DASM_IMM_WB: if (((n+128)&-256) == 0) goto ob; + case DASM_IMM_W: CK((n&-65536) == 0, RANGE_I); ofs += 2; break; + case DASM_SPACE: p++; ofs += n; break; + case DASM_SETLABEL: b[pos-2] = -0x40000000; break; /* Neg. label ofs. */ + case DASM_VREG: CK((n&-8) == 0 && (n != 4 || (*p&1) == 0), RANGE_VREG); + if (*p++ == 1 && *p == DASM_DISP) mrm = n; + continue; + } + mrm = 4; + } else { + int *pl, n; + switch (action) { + case DASM_REL_LG: + case DASM_IMM_LG: + n = *p++; pl = D->lglabels + n; + /* Bkwd rel or global. */ + if (n <= 246) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; } + pl -= 246; n = *pl; + if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ + goto linkrel; + case DASM_REL_PC: + case DASM_IMM_PC: pl = D->pclabels + va_arg(ap, int); CKPL(pc, PC); + putrel: + n = *pl; + if (n < 0) { /* Label exists. Get label pos and store it. */ + b[pos] = -n; + } else { + linkrel: + b[pos] = n; /* Else link to rel chain, anchored at label. */ + *pl = pos; + } + pos++; + ofs += 4; /* Maximum offset needed. */ + if (action == DASM_REL_LG || action == DASM_REL_PC) + b[pos++] = ofs; /* Store pass1 offset estimate. */ + break; + case DASM_LABEL_LG: pl = D->lglabels + *p++; CKPL(lg, LG); goto putlabel; + case DASM_LABEL_PC: pl = D->pclabels + va_arg(ap, int); CKPL(pc, PC); + putlabel: + n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; } + *pl = -pos; /* Label exists now. */ + b[pos++] = ofs; /* Store pass1 offset estimate. */ + break; + case DASM_ALIGN: + ofs += *p++; /* Maximum alignment needed (arg is 2**n-1). */ + b[pos++] = ofs; /* Store pass1 offset estimate. */ + break; + case DASM_EXTERN: p += 2; ofs += 4; break; + case DASM_ESC: p++; ofs++; break; + case DASM_MARK: mrm = p[-2]; break; + case DASM_SECTION: + n = *p; CK(n < D->maxsection, RANGE_SEC); D->section = &D->sections[n]; + case DASM_STOP: goto stop; + } + } + } +stop: + va_end(ap); + sec->pos = pos; + sec->ofs = ofs; +} +#undef CK + +/* Pass 2: Link sections, shrink branches/aligns, fix label offsets. */ +int dasm_link(Dst_DECL, size_t *szp) +{ + dasm_State *D = Dst_REF; + int secnum; + int ofs = 0; + +#ifdef DASM_CHECKS + *szp = 0; + if (D->status != DASM_S_OK) return D->status; + { + int pc; + for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) + if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; + } +#endif + + { /* Handle globals not defined in this translation unit. */ + int idx; + for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) { + int n = D->lglabels[idx]; + /* Undefined label: Collapse rel chain and replace with marker (< 0). */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } + } + } + + /* Combine all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->rbuf; + int pos = DASM_SEC2POS(secnum); + int lastpos = sec->pos; + + while (pos != lastpos) { + dasm_ActList p = D->actionlist + b[pos++]; + while (1) { + int op, action = *p++; + switch (action) { + case DASM_REL_LG: p++; op = p[-3]; goto rel_pc; + case DASM_REL_PC: op = p[-2]; rel_pc: { + int shrink = op == 0xe9 ? 3 : ((op&0xf0) == 0x80 ? 4 : 0); + if (shrink) { /* Shrinkable branch opcode? */ + int lofs, lpos = b[pos]; + if (lpos < 0) goto noshrink; /* Ext global? */ + lofs = *DASM_POS2PTR(D, lpos); + if (lpos > pos) { /* Fwd label: add cumulative section offsets. */ + int i; + for (i = secnum; i < DASM_POS2SEC(lpos); i++) + lofs += D->sections[i].ofs; + } else { + lofs -= ofs; /* Bkwd label: unfix offset. */ + } + lofs -= b[pos+1]; /* Short branch ok? */ + if (lofs >= -128-shrink && lofs <= 127) ofs -= shrink; /* Yes. */ + else { noshrink: shrink = 0; } /* No, cannot shrink op. */ + } + b[pos+1] = shrink; + pos += 2; + break; + } + case DASM_SPACE: case DASM_IMM_LG: case DASM_VREG: p++; + case DASM_DISP: case DASM_IMM_S: case DASM_IMM_B: case DASM_IMM_W: + case DASM_IMM_D: case DASM_IMM_WB: case DASM_IMM_DB: + case DASM_SETLABEL: case DASM_REL_A: case DASM_IMM_PC: pos++; break; + case DASM_LABEL_LG: p++; + case DASM_LABEL_PC: b[pos++] += ofs; break; /* Fix label offset. */ + case DASM_ALIGN: ofs -= (b[pos++]+ofs)&*p++; break; /* Adjust ofs. */ + case DASM_EXTERN: p += 2; break; + case DASM_ESC: p++; break; + case DASM_MARK: break; + case DASM_SECTION: case DASM_STOP: goto stop; + } + } + stop: (void)0; + } + ofs += sec->ofs; /* Next section starts right after current section. */ + } + + D->codesize = ofs; /* Total size of all code sections */ + *szp = ofs; + return DASM_S_OK; +} + +#define dasmb(x) *cp++ = (unsigned char)(x) +#ifndef DASM_ALIGNED_WRITES +#define dasmw(x) \ + do { *((unsigned short *)cp) = (unsigned short)(x); cp+=2; } while (0) +#define dasmd(x) \ + do { *((unsigned int *)cp) = (unsigned int)(x); cp+=4; } while (0) +#else +#define dasmw(x) do { dasmb(x); dasmb((x)>>8); } while (0) +#define dasmd(x) do { dasmw(x); dasmw((x)>>16); } while (0) +#endif + +/* Pass 3: Encode sections. */ +int dasm_encode(Dst_DECL, void *buffer) +{ + dasm_State *D = Dst_REF; + unsigned char *base = (unsigned char *)buffer; + unsigned char *cp = base; + int secnum; + + /* Encode all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->buf; + int *endb = sec->rbuf + sec->pos; + + while (b != endb) { + dasm_ActList p = D->actionlist + *b++; + unsigned char *mark = NULL; + while (1) { + int action = *p++; + int n = (action >= DASM_DISP && action <= DASM_ALIGN) ? *b++ : 0; + switch (action) { + case DASM_DISP: if (!mark) mark = cp; { + unsigned char *mm = mark; + if (*p != DASM_IMM_DB && *p != DASM_IMM_WB) mark = NULL; + if (n == 0) { int mrm = mm[-1]&7; if (mrm == 4) mrm = mm[0]&7; + if (mrm != 5) { mm[-1] -= 0x80; break; } } + if (((n+128) & -256) != 0) goto wd; else mm[-1] -= 0x40; + } + case DASM_IMM_S: case DASM_IMM_B: wb: dasmb(n); break; + case DASM_IMM_DB: if (((n+128)&-256) == 0) { + db: if (!mark) mark = cp; mark[-2] += 2; mark = NULL; goto wb; + } else mark = NULL; + case DASM_IMM_D: wd: dasmd(n); break; + case DASM_IMM_WB: if (((n+128)&-256) == 0) goto db; else mark = NULL; + case DASM_IMM_W: dasmw(n); break; + case DASM_VREG: { int t = *p++; if (t >= 2) n<<=3; cp[-1] |= n; break; } + case DASM_REL_LG: p++; if (n >= 0) goto rel_pc; + b++; n = (int)(ptrdiff_t)D->globals[-n]; + case DASM_REL_A: rel_a: n -= (int)(ptrdiff_t)(cp+4); goto wd; /* !x64 */ + case DASM_REL_PC: rel_pc: { + int shrink = *b++; + int *pb = DASM_POS2PTR(D, n); if (*pb < 0) { n = pb[1]; goto rel_a; } + n = *pb - ((int)(cp-base) + 4-shrink); + if (shrink == 0) goto wd; + if (shrink == 4) { cp--; cp[-1] = *cp-0x10; } else cp[-1] = 0xeb; + goto wb; + } + case DASM_IMM_LG: + p++; if (n < 0) { n = (int)(ptrdiff_t)D->globals[-n]; goto wd; } + case DASM_IMM_PC: { + int *pb = DASM_POS2PTR(D, n); + n = *pb < 0 ? pb[1] : (*pb + (int)(ptrdiff_t)base); + goto wd; + } + case DASM_LABEL_LG: { + int idx = *p++; + if (idx >= 10) + D->globals[idx] = (void *)(base + (*p == DASM_SETLABEL ? *b : n)); + break; + } + case DASM_LABEL_PC: case DASM_SETLABEL: break; + case DASM_SPACE: { int fill = *p++; while (n--) *cp++ = fill; break; } + case DASM_ALIGN: + n = *p++; + while (((cp-base) & n)) *cp++ = 0x90; /* nop */ + break; + case DASM_EXTERN: n = DASM_EXTERN(Dst, cp, p[1], *p); p += 2; goto wd; + case DASM_MARK: mark = cp; break; + case DASM_ESC: action = *p++; + default: *cp++ = action; break; + case DASM_SECTION: case DASM_STOP: goto stop; + } + } + stop: (void)0; + } + } + + if (base + D->codesize != cp) /* Check for phase errors. */ + return DASM_S_PHASE; + return DASM_S_OK; +} + +/* Get PC label offset. */ +int dasm_getpclabel(Dst_DECL, unsigned int pc) +{ + dasm_State *D = Dst_REF; + if (pc*sizeof(int) < D->pcsize) { + int pos = D->pclabels[pc]; + if (pos < 0) return *DASM_POS2PTR(D, -pos); + if (pos > 0) return -1; /* Undefined. */ + } + return -2; /* Unused or out of range. */ +} + +#ifdef DASM_CHECKS +/* Optional sanity checker to call between isolated encoding steps. */ +int dasm_checkstep(Dst_DECL, int secmatch) +{ + dasm_State *D = Dst_REF; + if (D->status == DASM_S_OK) { + int i; + for (i = 1; i <= 9; i++) { + if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_L|i; break; } + D->lglabels[i] = 0; + } + } + if (D->status == DASM_S_OK && secmatch >= 0 && + D->section != &D->sections[secmatch]) + D->status = DASM_S_MATCH_SEC|(int)(D->section-D->sections); + return D->status; +} +#endif + + +``` + +`include/luajit-2.0.5/dynasm/dasm_x86.lua`: + +```lua +------------------------------------------------------------------------------ +-- DynASM x86/x64 module. +-- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- See dynasm.lua for full copyright notice. +------------------------------------------------------------------------------ + +local x64 = x64 + +-- Module information: +local _info = { + arch = x64 and "x64" or "x86", + description = "DynASM x86/x64 module", + version = "1.3.0", + vernum = 10300, + release = "2011-05-05", + author = "Mike Pall", + license = "MIT", +} + +-- Exported glue functions for the arch-specific module. +local _M = { _info = _info } + +-- Cache library functions. +local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs +local assert, unpack, setmetatable = assert, unpack or table.unpack, setmetatable +local _s = string +local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char +local find, match, gmatch, gsub = _s.find, _s.match, _s.gmatch, _s.gsub +local concat, sort = table.concat, table.sort +local bit = bit or require("bit") +local band, shl, shr = bit.band, bit.lshift, bit.rshift + +-- Inherited tables and callbacks. +local g_opt, g_arch +local wline, werror, wfatal, wwarn + +-- Action name list. +-- CHECK: Keep this in sync with the C code! +local action_names = { + -- int arg, 1 buffer pos: + "DISP", "IMM_S", "IMM_B", "IMM_W", "IMM_D", "IMM_WB", "IMM_DB", + -- action arg (1 byte), int arg, 1 buffer pos (reg/num): + "VREG", "SPACE", -- !x64: VREG support NYI. + -- ptrdiff_t arg, 1 buffer pos (address): !x64 + "SETLABEL", "REL_A", + -- action arg (1 byte) or int arg, 2 buffer pos (link, offset): + "REL_LG", "REL_PC", + -- action arg (1 byte) or int arg, 1 buffer pos (link): + "IMM_LG", "IMM_PC", + -- action arg (1 byte) or int arg, 1 buffer pos (offset): + "LABEL_LG", "LABEL_PC", + -- action arg (1 byte), 1 buffer pos (offset): + "ALIGN", + -- action args (2 bytes), no buffer pos. + "EXTERN", + -- action arg (1 byte), no buffer pos. + "ESC", + -- no action arg, no buffer pos. + "MARK", + -- action arg (1 byte), no buffer pos, terminal action: + "SECTION", + -- no args, no buffer pos, terminal action: + "STOP" +} + +-- Maximum number of section buffer positions for dasm_put(). +-- CHECK: Keep this in sync with the C code! +local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. + +-- Action name -> action number (dynamically generated below). +local map_action = {} +-- First action number. Everything below does not need to be escaped. +local actfirst = 256-#action_names + +-- Action list buffer and string (only used to remove dupes). +local actlist = {} +local actstr = "" + +-- Argument list for next dasm_put(). Start with offset 0 into action list. +local actargs = { 0 } + +-- Current number of section buffer positions for dasm_put(). +local secpos = 1 + +------------------------------------------------------------------------------ + +-- Compute action numbers for action names. +for n,name in ipairs(action_names) do + local num = actfirst + n - 1 + map_action[name] = num +end + +-- Dump action names and numbers. +local function dumpactions(out) + out:write("DynASM encoding engine action codes:\n") + for n,name in ipairs(action_names) do + local num = map_action[name] + out:write(format(" %-10s %02X %d\n", name, num, num)) + end + out:write("\n") +end + +-- Write action list buffer as a huge static C array. +local function writeactions(out, name) + local nn = #actlist + local last = actlist[nn] or 255 + actlist[nn] = nil -- Remove last byte. + if nn == 0 then nn = 1 end + out:write("static const unsigned char ", name, "[", nn, "] = {\n") + local s = " " + for n,b in ipairs(actlist) do + s = s..b.."," + if #s >= 75 then + assert(out:write(s, "\n")) + s = " " + end + end + out:write(s, last, "\n};\n\n") -- Add last byte back. +end + +------------------------------------------------------------------------------ + +-- Add byte to action list. +local function wputxb(n) + assert(n >= 0 and n <= 255 and n % 1 == 0, "byte out of range") + actlist[#actlist+1] = n +end + +-- Add action to list with optional arg. Advance buffer pos, too. +local function waction(action, a, num) + wputxb(assert(map_action[action], "bad action name `"..action.."'")) + if a then actargs[#actargs+1] = a end + if a or num then secpos = secpos + (num or 1) end +end + +-- Add call to embedded DynASM C code. +local function wcall(func, args) + wline(format("dasm_%s(Dst, %s);", func, concat(args, ", ")), true) +end + +-- Delete duplicate action list chunks. A tad slow, but so what. +local function dedupechunk(offset) + local al, as = actlist, actstr + local chunk = char(unpack(al, offset+1, #al)) + local orig = find(as, chunk, 1, true) + if orig then + actargs[1] = orig-1 -- Replace with original offset. + for i=offset+1,#al do al[i] = nil end -- Kill dupe. + else + actstr = as..chunk + end +end + +-- Flush action list (intervening C code or buffer pos overflow). +local function wflush(term) + local offset = actargs[1] + if #actlist == offset then return end -- Nothing to flush. + if not term then waction("STOP") end -- Terminate action list. + dedupechunk(offset) + wcall("put", actargs) -- Add call to dasm_put(). + actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). + secpos = 1 -- The actionlist offset occupies a buffer position, too. +end + +-- Put escaped byte. +local function wputb(n) + if n >= actfirst then waction("ESC") end -- Need to escape byte. + wputxb(n) +end + +------------------------------------------------------------------------------ + +-- Global label name -> global label number. With auto assignment on 1st use. +local next_global = 10 +local map_global = setmetatable({}, { __index = function(t, name) + if not match(name, "^[%a_][%w_@]*$") then werror("bad global label") end + local n = next_global + if n > 246 then werror("too many global labels") end + next_global = n + 1 + t[name] = n + return n +end}) + +-- Dump global labels. +local function dumpglobals(out, lvl) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("Global labels:\n") + for i=10,next_global-1 do + out:write(format(" %s\n", t[i])) + end + out:write("\n") +end + +-- Write global label enum. +local function writeglobals(out, prefix) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("enum {\n") + for i=10,next_global-1 do + out:write(" ", prefix, gsub(t[i], "@.*", ""), ",\n") + end + out:write(" ", prefix, "_MAX\n};\n") +end + +-- Write global label names. +local function writeglobalnames(out, name) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("static const char *const ", name, "[] = {\n") + for i=10,next_global-1 do + out:write(" \"", t[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Extern label name -> extern label number. With auto assignment on 1st use. +local next_extern = -1 +local map_extern = setmetatable({}, { __index = function(t, name) + -- No restrictions on the name for now. + local n = next_extern + if n < -256 then werror("too many extern labels") end + next_extern = n - 1 + t[name] = n + return n +end}) + +-- Dump extern labels. +local function dumpexterns(out, lvl) + local t = {} + for name, n in pairs(map_extern) do t[-n] = name end + out:write("Extern labels:\n") + for i=1,-next_extern-1 do + out:write(format(" %s\n", t[i])) + end + out:write("\n") +end + +-- Write extern label names. +local function writeexternnames(out, name) + local t = {} + for name, n in pairs(map_extern) do t[-n] = name end + out:write("static const char *const ", name, "[] = {\n") + for i=1,-next_extern-1 do + out:write(" \"", t[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Arch-specific maps. +local map_archdef = {} -- Ext. register name -> int. name. +local map_reg_rev = {} -- Int. register name -> ext. name. +local map_reg_num = {} -- Int. register name -> register number. +local map_reg_opsize = {} -- Int. register name -> operand size. +local map_reg_valid_base = {} -- Int. register name -> valid base register? +local map_reg_valid_index = {} -- Int. register name -> valid index register? +local map_reg_needrex = {} -- Int. register name -> need rex vs. no rex. +local reg_list = {} -- Canonical list of int. register names. + +local map_type = {} -- Type name -> { ctype, reg } +local ctypenum = 0 -- Type number (for _PTx macros). + +local addrsize = x64 and "q" or "d" -- Size for address operands. + +-- Helper functions to fill register maps. +local function mkrmap(sz, cl, names) + local cname = format("@%s", sz) + reg_list[#reg_list+1] = cname + map_archdef[cl] = cname + map_reg_rev[cname] = cl + map_reg_num[cname] = -1 + map_reg_opsize[cname] = sz + if sz == addrsize or sz == "d" then + map_reg_valid_base[cname] = true + map_reg_valid_index[cname] = true + end + if names then + for n,name in ipairs(names) do + local iname = format("@%s%x", sz, n-1) + reg_list[#reg_list+1] = iname + map_archdef[name] = iname + map_reg_rev[iname] = name + map_reg_num[iname] = n-1 + map_reg_opsize[iname] = sz + if sz == "b" and n > 4 then map_reg_needrex[iname] = false end + if sz == addrsize or sz == "d" then + map_reg_valid_base[iname] = true + map_reg_valid_index[iname] = true + end + end + end + for i=0,(x64 and sz ~= "f") and 15 or 7 do + local needrex = sz == "b" and i > 3 + local iname = format("@%s%x%s", sz, i, needrex and "R" or "") + if needrex then map_reg_needrex[iname] = true end + local name + if sz == "o" then name = format("xmm%d", i) + elseif sz == "f" then name = format("st%d", i) + else name = format("r%d%s", i, sz == addrsize and "" or sz) end + map_archdef[name] = iname + if not map_reg_rev[iname] then + reg_list[#reg_list+1] = iname + map_reg_rev[iname] = name + map_reg_num[iname] = i + map_reg_opsize[iname] = sz + if sz == addrsize or sz == "d" then + map_reg_valid_base[iname] = true + map_reg_valid_index[iname] = true + end + end + end + reg_list[#reg_list+1] = "" +end + +-- Integer registers (qword, dword, word and byte sized). +if x64 then + mkrmap("q", "Rq", {"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi"}) +end +mkrmap("d", "Rd", {"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"}) +mkrmap("w", "Rw", {"ax", "cx", "dx", "bx", "sp", "bp", "si", "di"}) +mkrmap("b", "Rb", {"al", "cl", "dl", "bl", "ah", "ch", "dh", "bh"}) +map_reg_valid_index[map_archdef.esp] = false +if x64 then map_reg_valid_index[map_archdef.rsp] = false end +map_archdef["Ra"] = "@"..addrsize + +-- FP registers (internally tword sized, but use "f" as operand size). +mkrmap("f", "Rf") + +-- SSE registers (oword sized, but qword and dword accessible). +mkrmap("o", "xmm") + +-- Operand size prefixes to codes. +local map_opsize = { + byte = "b", word = "w", dword = "d", qword = "q", oword = "o", tword = "t", + aword = addrsize, +} + +-- Operand size code to number. +local map_opsizenum = { + b = 1, w = 2, d = 4, q = 8, o = 16, t = 10, +} + +-- Operand size code to name. +local map_opsizename = { + b = "byte", w = "word", d = "dword", q = "qword", o = "oword", t = "tword", + f = "fpword", +} + +-- Valid index register scale factors. +local map_xsc = { + ["1"] = 0, ["2"] = 1, ["4"] = 2, ["8"] = 3, +} + +-- Condition codes. +local map_cc = { + o = 0, no = 1, b = 2, nb = 3, e = 4, ne = 5, be = 6, nbe = 7, + s = 8, ns = 9, p = 10, np = 11, l = 12, nl = 13, le = 14, nle = 15, + c = 2, nae = 2, nc = 3, ae = 3, z = 4, nz = 5, na = 6, a = 7, + pe = 10, po = 11, nge = 12, ge = 13, ng = 14, g = 15, +} + + +-- Reverse defines for registers. +function _M.revdef(s) + return gsub(s, "@%w+", map_reg_rev) +end + +-- Dump register names and numbers +local function dumpregs(out) + out:write("Register names, sizes and internal numbers:\n") + for _,reg in ipairs(reg_list) do + if reg == "" then + out:write("\n") + else + local name = map_reg_rev[reg] + local num = map_reg_num[reg] + local opsize = map_opsizename[map_reg_opsize[reg]] + out:write(format(" %-5s %-8s %s\n", name, opsize, + num < 0 and "(variable)" or num)) + end + end +end + +------------------------------------------------------------------------------ + +-- Put action for label arg (IMM_LG, IMM_PC, REL_LG, REL_PC). +local function wputlabel(aprefix, imm, num) + if type(imm) == "number" then + if imm < 0 then + waction("EXTERN") + wputxb(aprefix == "IMM_" and 0 or 1) + imm = -imm-1 + else + waction(aprefix.."LG", nil, num); + end + wputxb(imm) + else + waction(aprefix.."PC", imm, num) + end +end + +-- Put signed byte or arg. +local function wputsbarg(n) + if type(n) == "number" then + if n < -128 or n > 127 then + werror("signed immediate byte out of range") + end + if n < 0 then n = n + 256 end + wputb(n) + else waction("IMM_S", n) end +end + +-- Put unsigned byte or arg. +local function wputbarg(n) + if type(n) == "number" then + if n < 0 or n > 255 then + werror("unsigned immediate byte out of range") + end + wputb(n) + else waction("IMM_B", n) end +end + +-- Put unsigned word or arg. +local function wputwarg(n) + if type(n) == "number" then + if shr(n, 16) ~= 0 then + werror("unsigned immediate word out of range") + end + wputb(band(n, 255)); wputb(shr(n, 8)); + else waction("IMM_W", n) end +end + +-- Put signed or unsigned dword or arg. +local function wputdarg(n) + local tn = type(n) + if tn == "number" then + wputb(band(n, 255)) + wputb(band(shr(n, 8), 255)) + wputb(band(shr(n, 16), 255)) + wputb(shr(n, 24)) + elseif tn == "table" then + wputlabel("IMM_", n[1], 1) + else + waction("IMM_D", n) + end +end + +-- Put operand-size dependent number or arg (defaults to dword). +local function wputszarg(sz, n) + if not sz or sz == "d" or sz == "q" then wputdarg(n) + elseif sz == "w" then wputwarg(n) + elseif sz == "b" then wputbarg(n) + elseif sz == "s" then wputsbarg(n) + else werror("bad operand size") end +end + +-- Put multi-byte opcode with operand-size dependent modifications. +local function wputop(sz, op, rex) + local r + if rex ~= 0 and not x64 then werror("bad operand size") end + if sz == "w" then wputb(102) end + -- Needs >32 bit numbers, but only for crc32 eax, word [ebx] + if op >= 4294967296 then r = op%4294967296 wputb((op-r)/4294967296) op = r end + if op >= 16777216 then wputb(shr(op, 24)); op = band(op, 0xffffff) end + if op >= 65536 then + if rex ~= 0 then + local opc3 = band(op, 0xffff00) + if opc3 == 0x0f3a00 or opc3 == 0x0f3800 then + wputb(64 + band(rex, 15)); rex = 0 + end + end + wputb(shr(op, 16)); op = band(op, 0xffff) + end + if op >= 256 then + local b = shr(op, 8) + if b == 15 and rex ~= 0 then wputb(64 + band(rex, 15)); rex = 0 end + wputb(b) + op = band(op, 255) + end + if rex ~= 0 then wputb(64 + band(rex, 15)) end + if sz == "b" then op = op - 1 end + wputb(op) +end + +-- Put ModRM or SIB formatted byte. +local function wputmodrm(m, s, rm, vs, vrm) + assert(m < 4 and s < 16 and rm < 16, "bad modrm operands") + wputb(shl(m, 6) + shl(band(s, 7), 3) + band(rm, 7)) +end + +-- Put ModRM/SIB plus optional displacement. +local function wputmrmsib(t, imark, s, vsreg) + local vreg, vxreg + local reg, xreg = t.reg, t.xreg + if reg and reg < 0 then reg = 0; vreg = t.vreg end + if xreg and xreg < 0 then xreg = 0; vxreg = t.vxreg end + if s < 0 then s = 0 end + + -- Register mode. + if sub(t.mode, 1, 1) == "r" then + wputmodrm(3, s, reg) + if vsreg then waction("VREG", vsreg); wputxb(2) end + if vreg then waction("VREG", vreg); wputxb(0) end + return + end + + local disp = t.disp + local tdisp = type(disp) + -- No base register? + if not reg then + local riprel = false + if xreg then + -- Indexed mode with index register only. + -- [xreg*xsc+disp] -> (0, s, esp) (xsc, xreg, ebp) + wputmodrm(0, s, 4) + if imark == "I" then waction("MARK") end + if vsreg then waction("VREG", vsreg); wputxb(2) end + wputmodrm(t.xsc, xreg, 5) + if vxreg then waction("VREG", vxreg); wputxb(3) end + else + -- Pure 32 bit displacement. + if x64 and tdisp ~= "table" then + wputmodrm(0, s, 4) -- [disp] -> (0, s, esp) (0, esp, ebp) + if imark == "I" then waction("MARK") end + wputmodrm(0, 4, 5) + else + riprel = x64 + wputmodrm(0, s, 5) -- [disp|rip-label] -> (0, s, ebp) + if imark == "I" then waction("MARK") end + end + if vsreg then waction("VREG", vsreg); wputxb(2) end + end + if riprel then -- Emit rip-relative displacement. + if match("UWSiI", imark) then + werror("NYI: rip-relative displacement followed by immediate") + end + -- The previous byte in the action buffer cannot be 0xe9 or 0x80-0x8f. + wputlabel("REL_", disp[1], 2) + else + wputdarg(disp) + end + return + end + + local m + if tdisp == "number" then -- Check displacement size at assembly time. + if disp == 0 and band(reg, 7) ~= 5 then -- [ebp] -> [ebp+0] (in SIB, too) + if not vreg then m = 0 end -- Force DISP to allow [Rd(5)] -> [ebp+0] + elseif disp >= -128 and disp <= 127 then m = 1 + else m = 2 end + elseif tdisp == "table" then + m = 2 + end + + -- Index register present or esp as base register: need SIB encoding. + if xreg or band(reg, 7) == 4 then + wputmodrm(m or 2, s, 4) -- ModRM. + if m == nil or imark == "I" then waction("MARK") end + if vsreg then waction("VREG", vsreg); wputxb(2) end + wputmodrm(t.xsc or 0, xreg or 4, reg) -- SIB. + if vxreg then waction("VREG", vxreg); wputxb(3) end + if vreg then waction("VREG", vreg); wputxb(1) end + else + wputmodrm(m or 2, s, reg) -- ModRM. + if (imark == "I" and (m == 1 or m == 2)) or + (m == nil and (vsreg or vreg)) then waction("MARK") end + if vsreg then waction("VREG", vsreg); wputxb(2) end + if vreg then waction("VREG", vreg); wputxb(1) end + end + + -- Put displacement. + if m == 1 then wputsbarg(disp) + elseif m == 2 then wputdarg(disp) + elseif m == nil then waction("DISP", disp) end +end + +------------------------------------------------------------------------------ + +-- Return human-readable operand mode string. +local function opmodestr(op, args) + local m = {} + for i=1,#args do + local a = args[i] + m[#m+1] = sub(a.mode, 1, 1)..(a.opsize or "?") + end + return op.." "..concat(m, ",") +end + +-- Convert number to valid integer or nil. +local function toint(expr) + local n = tonumber(expr) + if n then + if n % 1 ~= 0 or n < -2147483648 or n > 4294967295 then + werror("bad integer number `"..expr.."'") + end + return n + end +end + +-- Parse immediate expression. +local function immexpr(expr) + -- &expr (pointer) + if sub(expr, 1, 1) == "&" then + return "iPJ", format("(ptrdiff_t)(%s)", sub(expr,2)) + end + + local prefix = sub(expr, 1, 2) + -- =>expr (pc label reference) + if prefix == "=>" then + return "iJ", sub(expr, 3) + end + -- ->name (global label reference) + if prefix == "->" then + return "iJ", map_global[sub(expr, 3)] + end + + -- [<>][1-9] (local label reference) + local dir, lnum = match(expr, "^([<>])([1-9])$") + if dir then -- Fwd: 247-255, Bkwd: 1-9. + return "iJ", lnum + (dir == ">" and 246 or 0) + end + + local extname = match(expr, "^extern%s+(%S+)$") + if extname then + return "iJ", map_extern[extname] + end + + -- expr (interpreted as immediate) + return "iI", expr +end + +-- Parse displacement expression: +-num, +-expr, +-opsize*num +local function dispexpr(expr) + local disp = expr == "" and 0 or toint(expr) + if disp then return disp end + local c, dispt = match(expr, "^([+-])%s*(.+)$") + if c == "+" then + expr = dispt + elseif not c then + werror("bad displacement expression `"..expr.."'") + end + local opsize, tailops = match(dispt, "^(%w+)%s*%*%s*(.+)$") + local ops, imm = map_opsize[opsize], toint(tailops) + if ops and imm then + if c == "-" then imm = -imm end + return imm*map_opsizenum[ops] + end + local mode, iexpr = immexpr(dispt) + if mode == "iJ" then + if c == "-" then werror("cannot invert label reference") end + return { iexpr } + end + return expr -- Need to return original signed expression. +end + +-- Parse register or type expression. +local function rtexpr(expr) + if not expr then return end + local tname, ovreg = match(expr, "^([%w_]+):(@[%w_]+)$") + local tp = map_type[tname or expr] + if tp then + local reg = ovreg or tp.reg + local rnum = map_reg_num[reg] + if not rnum then + werror("type `"..(tname or expr).."' needs a register override") + end + if not map_reg_valid_base[reg] then + werror("bad base register override `"..(map_reg_rev[reg] or reg).."'") + end + return reg, rnum, tp + end + return expr, map_reg_num[expr] +end + +-- Parse operand and return { mode, opsize, reg, xreg, xsc, disp, imm }. +local function parseoperand(param) + local t = {} + + local expr = param + local opsize, tailops = match(param, "^(%w+)%s*(.+)$") + if opsize then + t.opsize = map_opsize[opsize] + if t.opsize then expr = tailops end + end + + local br = match(expr, "^%[%s*(.-)%s*%]$") + repeat + if br then + t.mode = "xm" + + -- [disp] + t.disp = toint(br) + if t.disp then + t.mode = x64 and "xm" or "xmO" + break + end + + -- [reg...] + local tp + local reg, tailr = match(br, "^([@%w_:]+)%s*(.*)$") + reg, t.reg, tp = rtexpr(reg) + if not t.reg then + -- [expr] + t.mode = x64 and "xm" or "xmO" + t.disp = dispexpr("+"..br) + break + end + + if t.reg == -1 then + t.vreg, tailr = match(tailr, "^(%b())(.*)$") + if not t.vreg then werror("bad variable register expression") end + end + + -- [xreg*xsc] or [xreg*xsc+-disp] or [xreg*xsc+-expr] + local xsc, tailsc = match(tailr, "^%*%s*([1248])%s*(.*)$") + if xsc then + if not map_reg_valid_index[reg] then + werror("bad index register `"..map_reg_rev[reg].."'") + end + t.xsc = map_xsc[xsc] + t.xreg = t.reg + t.vxreg = t.vreg + t.reg = nil + t.vreg = nil + t.disp = dispexpr(tailsc) + break + end + if not map_reg_valid_base[reg] then + werror("bad base register `"..map_reg_rev[reg].."'") + end + + -- [reg] or [reg+-disp] + t.disp = toint(tailr) or (tailr == "" and 0) + if t.disp then break end + + -- [reg+xreg...] + local xreg, tailx = match(tailr, "^+%s*([@%w_:]+)%s*(.*)$") + xreg, t.xreg, tp = rtexpr(xreg) + if not t.xreg then + -- [reg+-expr] + t.disp = dispexpr(tailr) + break + end + if not map_reg_valid_index[xreg] then + werror("bad index register `"..map_reg_rev[xreg].."'") + end + + if t.xreg == -1 then + t.vxreg, tailx = match(tailx, "^(%b())(.*)$") + if not t.vxreg then werror("bad variable register expression") end + end + + -- [reg+xreg*xsc...] + local xsc, tailsc = match(tailx, "^%*%s*([1248])%s*(.*)$") + if xsc then + t.xsc = map_xsc[xsc] + tailx = tailsc + end + + -- [...] or [...+-disp] or [...+-expr] + t.disp = dispexpr(tailx) + else + -- imm or opsize*imm + local imm = toint(expr) + if not imm and sub(expr, 1, 1) == "*" and t.opsize then + imm = toint(sub(expr, 2)) + if imm then + imm = imm * map_opsizenum[t.opsize] + t.opsize = nil + end + end + if imm then + if t.opsize then werror("bad operand size override") end + local m = "i" + if imm == 1 then m = m.."1" end + if imm >= 4294967168 and imm <= 4294967295 then imm = imm-4294967296 end + if imm >= -128 and imm <= 127 then m = m.."S" end + t.imm = imm + t.mode = m + break + end + + local tp + local reg, tailr = match(expr, "^([@%w_:]+)%s*(.*)$") + reg, t.reg, tp = rtexpr(reg) + if t.reg then + if t.reg == -1 then + t.vreg, tailr = match(tailr, "^(%b())(.*)$") + if not t.vreg then werror("bad variable register expression") end + end + -- reg + if tailr == "" then + if t.opsize then werror("bad operand size override") end + t.opsize = map_reg_opsize[reg] + if t.opsize == "f" then + t.mode = t.reg == 0 and "fF" or "f" + else + if reg == "@w4" or (x64 and reg == "@d4") then + wwarn("bad idea, try again with `"..(x64 and "rsp'" or "esp'")) + end + t.mode = t.reg == 0 and "rmR" or (reg == "@b1" and "rmC" or "rm") + end + t.needrex = map_reg_needrex[reg] + break + end + + -- type[idx], type[idx].field, type->field -> [reg+offset_expr] + if not tp then werror("bad operand `"..param.."'") end + t.mode = "xm" + t.disp = format(tp.ctypefmt, tailr) + else + t.mode, t.imm = immexpr(expr) + if sub(t.mode, -1) == "J" then + if t.opsize and t.opsize ~= addrsize then + werror("bad operand size override") + end + t.opsize = addrsize + end + end + end + until true + return t +end + +------------------------------------------------------------------------------ +-- x86 Template String Description +-- =============================== +-- +-- Each template string is a list of [match:]pattern pairs, +-- separated by "|". The first match wins. No match means a +-- bad or unsupported combination of operand modes or sizes. +-- +-- The match part and the ":" is omitted if the operation has +-- no operands. Otherwise the first N characters are matched +-- against the mode strings of each of the N operands. +-- +-- The mode string for each operand type is (see parseoperand()): +-- Integer register: "rm", +"R" for eax, ax, al, +"C" for cl +-- FP register: "f", +"F" for st0 +-- Index operand: "xm", +"O" for [disp] (pure offset) +-- Immediate: "i", +"S" for signed 8 bit, +"1" for 1, +-- +"I" for arg, +"P" for pointer +-- Any: +"J" for valid jump targets +-- +-- So a match character "m" (mixed) matches both an integer register +-- and an index operand (to be encoded with the ModRM/SIB scheme). +-- But "r" matches only a register and "x" only an index operand +-- (e.g. for FP memory access operations). +-- +-- The operand size match string starts right after the mode match +-- characters and ends before the ":". "dwb" or "qdwb" is assumed, if empty. +-- The effective data size of the operation is matched against this list. +-- +-- If only the regular "b", "w", "d", "q", "t" operand sizes are +-- present, then all operands must be the same size. Unspecified sizes +-- are ignored, but at least one operand must have a size or the pattern +-- won't match (use the "byte", "word", "dword", "qword", "tword" +-- operand size overrides. E.g.: mov dword [eax], 1). +-- +-- If the list has a "1" or "2" prefix, the operand size is taken +-- from the respective operand and any other operand sizes are ignored. +-- If the list contains only ".", all operand sizes are ignored. +-- If the list has a "/" prefix, the concatenated (mixed) operand sizes +-- are compared to the match. +-- +-- E.g. "rrdw" matches for either two dword registers or two word +-- registers. "Fx2dq" matches an st0 operand plus an index operand +-- pointing to a dword (float) or qword (double). +-- +-- Every character after the ":" is part of the pattern string: +-- Hex chars are accumulated to form the opcode (left to right). +-- "n" disables the standard opcode mods +-- (otherwise: -1 for "b", o16 prefix for "w", rex.w for "q") +-- "X" Force REX.W. +-- "r"/"R" adds the reg. number from the 1st/2nd operand to the opcode. +-- "m"/"M" generates ModRM/SIB from the 1st/2nd operand. +-- The spare 3 bits are either filled with the last hex digit or +-- the result from a previous "r"/"R". The opcode is restored. +-- +-- All of the following characters force a flush of the opcode: +-- "o"/"O" stores a pure 32 bit disp (offset) from the 1st/2nd operand. +-- "S" stores a signed 8 bit immediate from the last operand. +-- "U" stores an unsigned 8 bit immediate from the last operand. +-- "W" stores an unsigned 16 bit immediate from the last operand. +-- "i" stores an operand sized immediate from the last operand. +-- "I" dito, but generates an action code to optionally modify +-- the opcode (+2) for a signed 8 bit immediate. +-- "J" generates one of the REL action codes from the last operand. +-- +------------------------------------------------------------------------------ + +-- Template strings for x86 instructions. Ordered by first opcode byte. +-- Unimplemented opcodes (deliberate omissions) are marked with *. +local map_op = { + -- 00-05: add... + -- 06: *push es + -- 07: *pop es + -- 08-0D: or... + -- 0E: *push cs + -- 0F: two byte opcode prefix + -- 10-15: adc... + -- 16: *push ss + -- 17: *pop ss + -- 18-1D: sbb... + -- 1E: *push ds + -- 1F: *pop ds + -- 20-25: and... + es_0 = "26", + -- 27: *daa + -- 28-2D: sub... + cs_0 = "2E", + -- 2F: *das + -- 30-35: xor... + ss_0 = "36", + -- 37: *aaa + -- 38-3D: cmp... + ds_0 = "3E", + -- 3F: *aas + inc_1 = x64 and "m:FF0m" or "rdw:40r|m:FF0m", + dec_1 = x64 and "m:FF1m" or "rdw:48r|m:FF1m", + push_1 = (x64 and "rq:n50r|rw:50r|mq:nFF6m|mw:FF6m" or + "rdw:50r|mdw:FF6m").."|S.:6AS|ib:n6Ai|i.:68i", + pop_1 = x64 and "rq:n58r|rw:58r|mq:n8F0m|mw:8F0m" or "rdw:58r|mdw:8F0m", + -- 60: *pusha, *pushad, *pushaw + -- 61: *popa, *popad, *popaw + -- 62: *bound rdw,x + -- 63: x86: *arpl mw,rw + movsxd_2 = x64 and "rm/qd:63rM", + fs_0 = "64", + gs_0 = "65", + o16_0 = "66", + a16_0 = not x64 and "67" or nil, + a32_0 = x64 and "67", + -- 68: push idw + -- 69: imul rdw,mdw,idw + -- 6A: push ib + -- 6B: imul rdw,mdw,S + -- 6C: *insb + -- 6D: *insd, *insw + -- 6E: *outsb + -- 6F: *outsd, *outsw + -- 70-7F: jcc lb + -- 80: add... mb,i + -- 81: add... mdw,i + -- 82: *undefined + -- 83: add... mdw,S + test_2 = "mr:85Rm|rm:85rM|Ri:A9ri|mi:F70mi", + -- 86: xchg rb,mb + -- 87: xchg rdw,mdw + -- 88: mov mb,r + -- 89: mov mdw,r + -- 8A: mov r,mb + -- 8B: mov r,mdw + -- 8C: *mov mdw,seg + lea_2 = "rx1dq:8DrM", + -- 8E: *mov seg,mdw + -- 8F: pop mdw + nop_0 = "90", + xchg_2 = "Rrqdw:90R|rRqdw:90r|rm:87rM|mr:87Rm", + cbw_0 = "6698", + cwde_0 = "98", + cdqe_0 = "4898", + cwd_0 = "6699", + cdq_0 = "99", + cqo_0 = "4899", + -- 9A: *call iw:idw + wait_0 = "9B", + fwait_0 = "9B", + pushf_0 = "9C", + pushfd_0 = not x64 and "9C", + pushfq_0 = x64 and "9C", + popf_0 = "9D", + popfd_0 = not x64 and "9D", + popfq_0 = x64 and "9D", + sahf_0 = "9E", + lahf_0 = "9F", + mov_2 = "OR:A3o|RO:A1O|mr:89Rm|rm:8BrM|rib:nB0ri|ridw:B8ri|mi:C70mi", + movsb_0 = "A4", + movsw_0 = "66A5", + movsd_0 = "A5", + cmpsb_0 = "A6", + cmpsw_0 = "66A7", + cmpsd_0 = "A7", + -- A8: test Rb,i + -- A9: test Rdw,i + stosb_0 = "AA", + stosw_0 = "66AB", + stosd_0 = "AB", + lodsb_0 = "AC", + lodsw_0 = "66AD", + lodsd_0 = "AD", + scasb_0 = "AE", + scasw_0 = "66AF", + scasd_0 = "AF", + -- B0-B7: mov rb,i + -- B8-BF: mov rdw,i + -- C0: rol... mb,i + -- C1: rol... mdw,i + ret_1 = "i.:nC2W", + ret_0 = "C3", + -- C4: *les rdw,mq + -- C5: *lds rdw,mq + -- C6: mov mb,i + -- C7: mov mdw,i + -- C8: *enter iw,ib + leave_0 = "C9", + -- CA: *retf iw + -- CB: *retf + int3_0 = "CC", + int_1 = "i.:nCDU", + into_0 = "CE", + -- CF: *iret + -- D0: rol... mb,1 + -- D1: rol... mdw,1 + -- D2: rol... mb,cl + -- D3: rol... mb,cl + -- D4: *aam ib + -- D5: *aad ib + -- D6: *salc + -- D7: *xlat + -- D8-DF: floating point ops + -- E0: *loopne + -- E1: *loope + -- E2: *loop + -- E3: *jcxz, *jecxz + -- E4: *in Rb,ib + -- E5: *in Rdw,ib + -- E6: *out ib,Rb + -- E7: *out ib,Rdw + call_1 = x64 and "mq:nFF2m|J.:E8nJ" or "md:FF2m|J.:E8J", + jmp_1 = x64 and "mq:nFF4m|J.:E9nJ" or "md:FF4m|J.:E9J", -- short: EB + -- EA: *jmp iw:idw + -- EB: jmp ib + -- EC: *in Rb,dx + -- ED: *in Rdw,dx + -- EE: *out dx,Rb + -- EF: *out dx,Rdw + lock_0 = "F0", + int1_0 = "F1", + repne_0 = "F2", + repnz_0 = "F2", + rep_0 = "F3", + repe_0 = "F3", + repz_0 = "F3", + -- F4: *hlt + cmc_0 = "F5", + -- F6: test... mb,i; div... mb + -- F7: test... mdw,i; div... mdw + clc_0 = "F8", + stc_0 = "F9", + -- FA: *cli + cld_0 = "FC", + std_0 = "FD", + -- FE: inc... mb + -- FF: inc... mdw + + -- misc ops + not_1 = "m:F72m", + neg_1 = "m:F73m", + mul_1 = "m:F74m", + imul_1 = "m:F75m", + div_1 = "m:F76m", + idiv_1 = "m:F77m", + + imul_2 = "rmqdw:0FAFrM|rIqdw:69rmI|rSqdw:6BrmS|riqdw:69rmi", + imul_3 = "rmIqdw:69rMI|rmSqdw:6BrMS|rmiqdw:69rMi", + + movzx_2 = "rm/db:0FB6rM|rm/qb:|rm/wb:0FB6rM|rm/dw:0FB7rM|rm/qw:", + movsx_2 = "rm/db:0FBErM|rm/qb:|rm/wb:0FBErM|rm/dw:0FBFrM|rm/qw:", + + bswap_1 = "rqd:0FC8r", + bsf_2 = "rmqdw:0FBCrM", + bsr_2 = "rmqdw:0FBDrM", + bt_2 = "mrqdw:0FA3Rm|miqdw:0FBA4mU", + btc_2 = "mrqdw:0FBBRm|miqdw:0FBA7mU", + btr_2 = "mrqdw:0FB3Rm|miqdw:0FBA6mU", + bts_2 = "mrqdw:0FABRm|miqdw:0FBA5mU", + + shld_3 = "mriqdw:0FA4RmU|mrC/qq:0FA5Rm|mrC/dd:|mrC/ww:", + shrd_3 = "mriqdw:0FACRmU|mrC/qq:0FADRm|mrC/dd:|mrC/ww:", + + rdtsc_0 = "0F31", -- P1+ + rdpmc_0 = "0F33", -- P6+ + cpuid_0 = "0FA2", -- P1+ + + -- floating point ops + fst_1 = "ff:DDD0r|xd:D92m|xq:nDD2m", + fstp_1 = "ff:DDD8r|xd:D93m|xq:nDD3m|xt:DB7m", + fld_1 = "ff:D9C0r|xd:D90m|xq:nDD0m|xt:DB5m", + + fpop_0 = "DDD8", -- Alias for fstp st0. + + fist_1 = "xw:nDF2m|xd:DB2m", + fistp_1 = "xw:nDF3m|xd:DB3m|xq:nDF7m", + fild_1 = "xw:nDF0m|xd:DB0m|xq:nDF5m", + + fxch_0 = "D9C9", + fxch_1 = "ff:D9C8r", + fxch_2 = "fFf:D9C8r|Fff:D9C8R", + + fucom_1 = "ff:DDE0r", + fucom_2 = "Fff:DDE0R", + fucomp_1 = "ff:DDE8r", + fucomp_2 = "Fff:DDE8R", + fucomi_1 = "ff:DBE8r", -- P6+ + fucomi_2 = "Fff:DBE8R", -- P6+ + fucomip_1 = "ff:DFE8r", -- P6+ + fucomip_2 = "Fff:DFE8R", -- P6+ + fcomi_1 = "ff:DBF0r", -- P6+ + fcomi_2 = "Fff:DBF0R", -- P6+ + fcomip_1 = "ff:DFF0r", -- P6+ + fcomip_2 = "Fff:DFF0R", -- P6+ + fucompp_0 = "DAE9", + fcompp_0 = "DED9", + + fldenv_1 = "x.:D94m", + fnstenv_1 = "x.:D96m", + fstenv_1 = "x.:9BD96m", + fldcw_1 = "xw:nD95m", + fstcw_1 = "xw:n9BD97m", + fnstcw_1 = "xw:nD97m", + fstsw_1 = "Rw:n9BDFE0|xw:n9BDD7m", + fnstsw_1 = "Rw:nDFE0|xw:nDD7m", + fclex_0 = "9BDBE2", + fnclex_0 = "DBE2", + + fnop_0 = "D9D0", + -- D9D1-D9DF: unassigned + + fchs_0 = "D9E0", + fabs_0 = "D9E1", + -- D9E2: unassigned + -- D9E3: unassigned + ftst_0 = "D9E4", + fxam_0 = "D9E5", + -- D9E6: unassigned + -- D9E7: unassigned + fld1_0 = "D9E8", + fldl2t_0 = "D9E9", + fldl2e_0 = "D9EA", + fldpi_0 = "D9EB", + fldlg2_0 = "D9EC", + fldln2_0 = "D9ED", + fldz_0 = "D9EE", + -- D9EF: unassigned + + f2xm1_0 = "D9F0", + fyl2x_0 = "D9F1", + fptan_0 = "D9F2", + fpatan_0 = "D9F3", + fxtract_0 = "D9F4", + fprem1_0 = "D9F5", + fdecstp_0 = "D9F6", + fincstp_0 = "D9F7", + fprem_0 = "D9F8", + fyl2xp1_0 = "D9F9", + fsqrt_0 = "D9FA", + fsincos_0 = "D9FB", + frndint_0 = "D9FC", + fscale_0 = "D9FD", + fsin_0 = "D9FE", + fcos_0 = "D9FF", + + -- SSE, SSE2 + andnpd_2 = "rmo:660F55rM", + andnps_2 = "rmo:0F55rM", + andpd_2 = "rmo:660F54rM", + andps_2 = "rmo:0F54rM", + clflush_1 = "x.:0FAE7m", + cmppd_3 = "rmio:660FC2rMU", + cmpps_3 = "rmio:0FC2rMU", + cmpsd_3 = "rrio:F20FC2rMU|rxi/oq:", + cmpss_3 = "rrio:F30FC2rMU|rxi/od:", + comisd_2 = "rro:660F2FrM|rx/oq:", + comiss_2 = "rro:0F2FrM|rx/od:", + cvtdq2pd_2 = "rro:F30FE6rM|rx/oq:", + cvtdq2ps_2 = "rmo:0F5BrM", + cvtpd2dq_2 = "rmo:F20FE6rM", + cvtpd2ps_2 = "rmo:660F5ArM", + cvtpi2pd_2 = "rx/oq:660F2ArM", + cvtpi2ps_2 = "rx/oq:0F2ArM", + cvtps2dq_2 = "rmo:660F5BrM", + cvtps2pd_2 = "rro:0F5ArM|rx/oq:", + cvtsd2si_2 = "rr/do:F20F2DrM|rr/qo:|rx/dq:|rxq:", + cvtsd2ss_2 = "rro:F20F5ArM|rx/oq:", + cvtsi2sd_2 = "rm/od:F20F2ArM|rm/oq:F20F2ArXM", + cvtsi2ss_2 = "rm/od:F30F2ArM|rm/oq:F30F2ArXM", + cvtss2sd_2 = "rro:F30F5ArM|rx/od:", + cvtss2si_2 = "rr/do:F30F2DrM|rr/qo:|rxd:|rx/qd:", + cvttpd2dq_2 = "rmo:660FE6rM", + cvttps2dq_2 = "rmo:F30F5BrM", + cvttsd2si_2 = "rr/do:F20F2CrM|rr/qo:|rx/dq:|rxq:", + cvttss2si_2 = "rr/do:F30F2CrM|rr/qo:|rxd:|rx/qd:", + fxsave_1 = "x.:0FAE0m", + fxrstor_1 = "x.:0FAE1m", + ldmxcsr_1 = "xd:0FAE2m", + lfence_0 = "0FAEE8", + maskmovdqu_2 = "rro:660FF7rM", + mfence_0 = "0FAEF0", + movapd_2 = "rmo:660F28rM|mro:660F29Rm", + movaps_2 = "rmo:0F28rM|mro:0F29Rm", + movd_2 = "rm/od:660F6ErM|rm/oq:660F6ErXM|mr/do:660F7ERm|mr/qo:", + movdqa_2 = "rmo:660F6FrM|mro:660F7FRm", + movdqu_2 = "rmo:F30F6FrM|mro:F30F7FRm", + movhlps_2 = "rro:0F12rM", + movhpd_2 = "rx/oq:660F16rM|xr/qo:n660F17Rm", + movhps_2 = "rx/oq:0F16rM|xr/qo:n0F17Rm", + movlhps_2 = "rro:0F16rM", + movlpd_2 = "rx/oq:660F12rM|xr/qo:n660F13Rm", + movlps_2 = "rx/oq:0F12rM|xr/qo:n0F13Rm", + movmskpd_2 = "rr/do:660F50rM", + movmskps_2 = "rr/do:0F50rM", + movntdq_2 = "xro:660FE7Rm", + movnti_2 = "xrqd:0FC3Rm", + movntpd_2 = "xro:660F2BRm", + movntps_2 = "xro:0F2BRm", + movq_2 = "rro:F30F7ErM|rx/oq:|xr/qo:n660FD6Rm", + movsd_2 = "rro:F20F10rM|rx/oq:|xr/qo:nF20F11Rm", + movss_2 = "rro:F30F10rM|rx/od:|xr/do:F30F11Rm", + movupd_2 = "rmo:660F10rM|mro:660F11Rm", + movups_2 = "rmo:0F10rM|mro:0F11Rm", + orpd_2 = "rmo:660F56rM", + orps_2 = "rmo:0F56rM", + packssdw_2 = "rmo:660F6BrM", + packsswb_2 = "rmo:660F63rM", + packuswb_2 = "rmo:660F67rM", + paddb_2 = "rmo:660FFCrM", + paddd_2 = "rmo:660FFErM", + paddq_2 = "rmo:660FD4rM", + paddsb_2 = "rmo:660FECrM", + paddsw_2 = "rmo:660FEDrM", + paddusb_2 = "rmo:660FDCrM", + paddusw_2 = "rmo:660FDDrM", + paddw_2 = "rmo:660FFDrM", + pand_2 = "rmo:660FDBrM", + pandn_2 = "rmo:660FDFrM", + pause_0 = "F390", + pavgb_2 = "rmo:660FE0rM", + pavgw_2 = "rmo:660FE3rM", + pcmpeqb_2 = "rmo:660F74rM", + pcmpeqd_2 = "rmo:660F76rM", + pcmpeqw_2 = "rmo:660F75rM", + pcmpgtb_2 = "rmo:660F64rM", + pcmpgtd_2 = "rmo:660F66rM", + pcmpgtw_2 = "rmo:660F65rM", + pextrw_3 = "rri/do:660FC5rMU|xri/wo:660F3A15nRmU", -- Mem op: SSE4.1 only. + pinsrw_3 = "rri/od:660FC4rMU|rxi/ow:", + pmaddwd_2 = "rmo:660FF5rM", + pmaxsw_2 = "rmo:660FEErM", + pmaxub_2 = "rmo:660FDErM", + pminsw_2 = "rmo:660FEArM", + pminub_2 = "rmo:660FDArM", + pmovmskb_2 = "rr/do:660FD7rM", + pmulhuw_2 = "rmo:660FE4rM", + pmulhw_2 = "rmo:660FE5rM", + pmullw_2 = "rmo:660FD5rM", + pmuludq_2 = "rmo:660FF4rM", + por_2 = "rmo:660FEBrM", + prefetchnta_1 = "xb:n0F180m", + prefetcht0_1 = "xb:n0F181m", + prefetcht1_1 = "xb:n0F182m", + prefetcht2_1 = "xb:n0F183m", + psadbw_2 = "rmo:660FF6rM", + pshufd_3 = "rmio:660F70rMU", + pshufhw_3 = "rmio:F30F70rMU", + pshuflw_3 = "rmio:F20F70rMU", + pslld_2 = "rmo:660FF2rM|rio:660F726mU", + pslldq_2 = "rio:660F737mU", + psllq_2 = "rmo:660FF3rM|rio:660F736mU", + psllw_2 = "rmo:660FF1rM|rio:660F716mU", + psrad_2 = "rmo:660FE2rM|rio:660F724mU", + psraw_2 = "rmo:660FE1rM|rio:660F714mU", + psrld_2 = "rmo:660FD2rM|rio:660F722mU", + psrldq_2 = "rio:660F733mU", + psrlq_2 = "rmo:660FD3rM|rio:660F732mU", + psrlw_2 = "rmo:660FD1rM|rio:660F712mU", + psubb_2 = "rmo:660FF8rM", + psubd_2 = "rmo:660FFArM", + psubq_2 = "rmo:660FFBrM", + psubsb_2 = "rmo:660FE8rM", + psubsw_2 = "rmo:660FE9rM", + psubusb_2 = "rmo:660FD8rM", + psubusw_2 = "rmo:660FD9rM", + psubw_2 = "rmo:660FF9rM", + punpckhbw_2 = "rmo:660F68rM", + punpckhdq_2 = "rmo:660F6ArM", + punpckhqdq_2 = "rmo:660F6DrM", + punpckhwd_2 = "rmo:660F69rM", + punpcklbw_2 = "rmo:660F60rM", + punpckldq_2 = "rmo:660F62rM", + punpcklqdq_2 = "rmo:660F6CrM", + punpcklwd_2 = "rmo:660F61rM", + pxor_2 = "rmo:660FEFrM", + rcpps_2 = "rmo:0F53rM", + rcpss_2 = "rro:F30F53rM|rx/od:", + rsqrtps_2 = "rmo:0F52rM", + rsqrtss_2 = "rmo:F30F52rM", + sfence_0 = "0FAEF8", + shufpd_3 = "rmio:660FC6rMU", + shufps_3 = "rmio:0FC6rMU", + stmxcsr_1 = "xd:0FAE3m", + ucomisd_2 = "rro:660F2ErM|rx/oq:", + ucomiss_2 = "rro:0F2ErM|rx/od:", + unpckhpd_2 = "rmo:660F15rM", + unpckhps_2 = "rmo:0F15rM", + unpcklpd_2 = "rmo:660F14rM", + unpcklps_2 = "rmo:0F14rM", + xorpd_2 = "rmo:660F57rM", + xorps_2 = "rmo:0F57rM", + + -- SSE3 ops + fisttp_1 = "xw:nDF1m|xd:DB1m|xq:nDD1m", + addsubpd_2 = "rmo:660FD0rM", + addsubps_2 = "rmo:F20FD0rM", + haddpd_2 = "rmo:660F7CrM", + haddps_2 = "rmo:F20F7CrM", + hsubpd_2 = "rmo:660F7DrM", + hsubps_2 = "rmo:F20F7DrM", + lddqu_2 = "rxo:F20FF0rM", + movddup_2 = "rmo:F20F12rM", + movshdup_2 = "rmo:F30F16rM", + movsldup_2 = "rmo:F30F12rM", + + -- SSSE3 ops + pabsb_2 = "rmo:660F381CrM", + pabsd_2 = "rmo:660F381ErM", + pabsw_2 = "rmo:660F381DrM", + palignr_3 = "rmio:660F3A0FrMU", + phaddd_2 = "rmo:660F3802rM", + phaddsw_2 = "rmo:660F3803rM", + phaddw_2 = "rmo:660F3801rM", + phsubd_2 = "rmo:660F3806rM", + phsubsw_2 = "rmo:660F3807rM", + phsubw_2 = "rmo:660F3805rM", + pmaddubsw_2 = "rmo:660F3804rM", + pmulhrsw_2 = "rmo:660F380BrM", + pshufb_2 = "rmo:660F3800rM", + psignb_2 = "rmo:660F3808rM", + psignd_2 = "rmo:660F380ArM", + psignw_2 = "rmo:660F3809rM", + + -- SSE4.1 ops + blendpd_3 = "rmio:660F3A0DrMU", + blendps_3 = "rmio:660F3A0CrMU", + blendvpd_3 = "rmRo:660F3815rM", + blendvps_3 = "rmRo:660F3814rM", + dppd_3 = "rmio:660F3A41rMU", + dpps_3 = "rmio:660F3A40rMU", + extractps_3 = "mri/do:660F3A17RmU|rri/qo:660F3A17RXmU", + insertps_3 = "rrio:660F3A41rMU|rxi/od:", + movntdqa_2 = "rxo:660F382ArM", + mpsadbw_3 = "rmio:660F3A42rMU", + packusdw_2 = "rmo:660F382BrM", + pblendvb_3 = "rmRo:660F3810rM", + pblendw_3 = "rmio:660F3A0ErMU", + pcmpeqq_2 = "rmo:660F3829rM", + pextrb_3 = "rri/do:660F3A14nRmU|rri/qo:|xri/bo:", + pextrd_3 = "mri/do:660F3A16RmU", + pextrq_3 = "mri/qo:660F3A16RmU", + -- pextrw is SSE2, mem operand is SSE4.1 only + phminposuw_2 = "rmo:660F3841rM", + pinsrb_3 = "rri/od:660F3A20nrMU|rxi/ob:", + pinsrd_3 = "rmi/od:660F3A22rMU", + pinsrq_3 = "rmi/oq:660F3A22rXMU", + pmaxsb_2 = "rmo:660F383CrM", + pmaxsd_2 = "rmo:660F383DrM", + pmaxud_2 = "rmo:660F383FrM", + pmaxuw_2 = "rmo:660F383ErM", + pminsb_2 = "rmo:660F3838rM", + pminsd_2 = "rmo:660F3839rM", + pminud_2 = "rmo:660F383BrM", + pminuw_2 = "rmo:660F383ArM", + pmovsxbd_2 = "rro:660F3821rM|rx/od:", + pmovsxbq_2 = "rro:660F3822rM|rx/ow:", + pmovsxbw_2 = "rro:660F3820rM|rx/oq:", + pmovsxdq_2 = "rro:660F3825rM|rx/oq:", + pmovsxwd_2 = "rro:660F3823rM|rx/oq:", + pmovsxwq_2 = "rro:660F3824rM|rx/od:", + pmovzxbd_2 = "rro:660F3831rM|rx/od:", + pmovzxbq_2 = "rro:660F3832rM|rx/ow:", + pmovzxbw_2 = "rro:660F3830rM|rx/oq:", + pmovzxdq_2 = "rro:660F3835rM|rx/oq:", + pmovzxwd_2 = "rro:660F3833rM|rx/oq:", + pmovzxwq_2 = "rro:660F3834rM|rx/od:", + pmuldq_2 = "rmo:660F3828rM", + pmulld_2 = "rmo:660F3840rM", + ptest_2 = "rmo:660F3817rM", + roundpd_3 = "rmio:660F3A09rMU", + roundps_3 = "rmio:660F3A08rMU", + roundsd_3 = "rrio:660F3A0BrMU|rxi/oq:", + roundss_3 = "rrio:660F3A0ArMU|rxi/od:", + + -- SSE4.2 ops + crc32_2 = "rmqd:F20F38F1rM|rm/dw:66F20F38F1rM|rm/db:F20F38F0rM|rm/qb:", + pcmpestri_3 = "rmio:660F3A61rMU", + pcmpestrm_3 = "rmio:660F3A60rMU", + pcmpgtq_2 = "rmo:660F3837rM", + pcmpistri_3 = "rmio:660F3A63rMU", + pcmpistrm_3 = "rmio:660F3A62rMU", + popcnt_2 = "rmqdw:F30FB8rM", + + -- SSE4a + extrq_2 = "rro:660F79rM", + extrq_3 = "riio:660F780mUU", + insertq_2 = "rro:F20F79rM", + insertq_4 = "rriio:F20F78rMUU", + lzcnt_2 = "rmqdw:F30FBDrM", + movntsd_2 = "xr/qo:nF20F2BRm", + movntss_2 = "xr/do:F30F2BRm", + -- popcnt is also in SSE4.2 +} + +------------------------------------------------------------------------------ + +-- Arithmetic ops. +for name,n in pairs{ add = 0, ["or"] = 1, adc = 2, sbb = 3, + ["and"] = 4, sub = 5, xor = 6, cmp = 7 } do + local n8 = shl(n, 3) + map_op[name.."_2"] = format( + "mr:%02XRm|rm:%02XrM|mI1qdw:81%XmI|mS1qdw:83%XmS|Ri1qdwb:%02Xri|mi1qdwb:81%Xmi", + 1+n8, 3+n8, n, n, 5+n8, n) +end + +-- Shift ops. +for name,n in pairs{ rol = 0, ror = 1, rcl = 2, rcr = 3, + shl = 4, shr = 5, sar = 7, sal = 4 } do + map_op[name.."_2"] = format("m1:D1%Xm|mC1qdwb:D3%Xm|mi:C1%XmU", n, n, n) +end + +-- Conditional ops. +for cc,n in pairs(map_cc) do + map_op["j"..cc.."_1"] = format("J.:n0F8%XJ", n) -- short: 7%X + map_op["set"..cc.."_1"] = format("mb:n0F9%X2m", n) + map_op["cmov"..cc.."_2"] = format("rmqdw:0F4%XrM", n) -- P6+ +end + +-- FP arithmetic ops. +for name,n in pairs{ add = 0, mul = 1, com = 2, comp = 3, + sub = 4, subr = 5, div = 6, divr = 7 } do + local nc = 0xc0 + shl(n, 3) + local nr = nc + (n < 4 and 0 or (n % 2 == 0 and 8 or -8)) + local fn = "f"..name + map_op[fn.."_1"] = format("ff:D8%02Xr|xd:D8%Xm|xq:nDC%Xm", nc, n, n) + if n == 2 or n == 3 then + map_op[fn.."_2"] = format("Fff:D8%02XR|Fx2d:D8%XM|Fx2q:nDC%XM", nc, n, n) + else + map_op[fn.."_2"] = format("Fff:D8%02XR|fFf:DC%02Xr|Fx2d:D8%XM|Fx2q:nDC%XM", nc, nr, n, n) + map_op[fn.."p_1"] = format("ff:DE%02Xr", nr) + map_op[fn.."p_2"] = format("fFf:DE%02Xr", nr) + end + map_op["fi"..name.."_1"] = format("xd:DA%Xm|xw:nDE%Xm", n, n) +end + +-- FP conditional moves. +for cc,n in pairs{ b=0, e=1, be=2, u=3, nb=4, ne=5, nbe=6, nu=7 } do + local nc = 0xdac0 + shl(band(n, 3), 3) + shl(band(n, 4), 6) + map_op["fcmov"..cc.."_1"] = format("ff:%04Xr", nc) -- P6+ + map_op["fcmov"..cc.."_2"] = format("Fff:%04XR", nc) -- P6+ +end + +-- SSE FP arithmetic ops. +for name,n in pairs{ sqrt = 1, add = 8, mul = 9, + sub = 12, min = 13, div = 14, max = 15 } do + map_op[name.."ps_2"] = format("rmo:0F5%XrM", n) + map_op[name.."ss_2"] = format("rro:F30F5%XrM|rx/od:", n) + map_op[name.."pd_2"] = format("rmo:660F5%XrM", n) + map_op[name.."sd_2"] = format("rro:F20F5%XrM|rx/oq:", n) +end + +------------------------------------------------------------------------------ + +-- Process pattern string. +local function dopattern(pat, args, sz, op, needrex) + local digit, addin + local opcode = 0 + local szov = sz + local narg = 1 + local rex = 0 + + -- Limit number of section buffer positions used by a single dasm_put(). + -- A single opcode needs a maximum of 5 positions. + if secpos+5 > maxsecpos then wflush() end + + -- Process each character. + for c in gmatch(pat.."|", ".") do + if match(c, "%x") then -- Hex digit. + digit = byte(c) - 48 + if digit > 48 then digit = digit - 39 + elseif digit > 16 then digit = digit - 7 end + opcode = opcode*16 + digit + addin = nil + elseif c == "n" then -- Disable operand size mods for opcode. + szov = nil + elseif c == "X" then -- Force REX.W. + rex = 8 + elseif c == "r" then -- Merge 1st operand regno. into opcode. + addin = args[1]; opcode = opcode + (addin.reg % 8) + if narg < 2 then narg = 2 end + elseif c == "R" then -- Merge 2nd operand regno. into opcode. + addin = args[2]; opcode = opcode + (addin.reg % 8) + narg = 3 + elseif c == "m" or c == "M" then -- Encode ModRM/SIB. + local s + if addin then + s = addin.reg + opcode = opcode - band(s, 7) -- Undo regno opcode merge. + else + s = band(opcode, 15) -- Undo last digit. + opcode = shr(opcode, 4) + end + local nn = c == "m" and 1 or 2 + local t = args[nn] + if narg <= nn then narg = nn + 1 end + if szov == "q" and rex == 0 then rex = rex + 8 end + if t.reg and t.reg > 7 then rex = rex + 1 end + if t.xreg and t.xreg > 7 then rex = rex + 2 end + if s > 7 then rex = rex + 4 end + if needrex then rex = rex + 16 end + wputop(szov, opcode, rex); opcode = nil + local imark = sub(pat, -1) -- Force a mark (ugly). + -- Put ModRM/SIB with regno/last digit as spare. + wputmrmsib(t, imark, s, addin and addin.vreg) + addin = nil + else + if opcode then -- Flush opcode. + if szov == "q" and rex == 0 then rex = rex + 8 end + if needrex then rex = rex + 16 end + if addin and addin.reg == -1 then + wputop(szov, opcode - 7, rex) + waction("VREG", addin.vreg); wputxb(0) + else + if addin and addin.reg > 7 then rex = rex + 1 end + wputop(szov, opcode, rex) + end + opcode = nil + end + if c == "|" then break end + if c == "o" then -- Offset (pure 32 bit displacement). + wputdarg(args[1].disp); if narg < 2 then narg = 2 end + elseif c == "O" then + wputdarg(args[2].disp); narg = 3 + else + -- Anything else is an immediate operand. + local a = args[narg] + narg = narg + 1 + local mode, imm = a.mode, a.imm + if mode == "iJ" and not match("iIJ", c) then + werror("bad operand size for label") + end + if c == "S" then + wputsbarg(imm) + elseif c == "U" then + wputbarg(imm) + elseif c == "W" then + wputwarg(imm) + elseif c == "i" or c == "I" then + if mode == "iJ" then + wputlabel("IMM_", imm, 1) + elseif mode == "iI" and c == "I" then + waction(sz == "w" and "IMM_WB" or "IMM_DB", imm) + else + wputszarg(sz, imm) + end + elseif c == "J" then + if mode == "iPJ" then + waction("REL_A", imm) -- !x64 (secpos) + else + wputlabel("REL_", imm, 2) + end + else + werror("bad char `"..c.."' in pattern `"..pat.."' for `"..op.."'") + end + end + end + end +end + +------------------------------------------------------------------------------ + +-- Mapping of operand modes to short names. Suppress output with '#'. +local map_modename = { + r = "reg", R = "eax", C = "cl", x = "mem", m = "mrm", i = "imm", + f = "stx", F = "st0", J = "lbl", ["1"] = "1", + I = "#", S = "#", O = "#", +} + +-- Return a table/string showing all possible operand modes. +local function templatehelp(template, nparams) + if nparams == 0 then return "" end + local t = {} + for tm in gmatch(template, "[^%|]+") do + local s = map_modename[sub(tm, 1, 1)] + s = s..gsub(sub(tm, 2, nparams), ".", function(c) + return ", "..map_modename[c] + end) + if not match(s, "#") then t[#t+1] = s end + end + return t +end + +-- Match operand modes against mode match part of template. +local function matchtm(tm, args) + for i=1,#args do + if not match(args[i].mode, sub(tm, i, i)) then return end + end + return true +end + +-- Handle opcodes defined with template strings. +map_op[".template__"] = function(params, template, nparams) + if not params then return templatehelp(template, nparams) end + local args = {} + + -- Zero-operand opcodes have no match part. + if #params == 0 then + dopattern(template, args, "d", params.op, nil) + return + end + + -- Determine common operand size (coerce undefined size) or flag as mixed. + local sz, szmix, needrex + for i,p in ipairs(params) do + args[i] = parseoperand(p) + local nsz = args[i].opsize + if nsz then + if sz and sz ~= nsz then szmix = true else sz = nsz end + end + local nrex = args[i].needrex + if nrex ~= nil then + if needrex == nil then + needrex = nrex + elseif needrex ~= nrex then + werror("bad mix of byte-addressable registers") + end + end + end + + -- Try all match:pattern pairs (separated by '|'). + local gotmatch, lastpat + for tm in gmatch(template, "[^%|]+") do + -- Split off size match (starts after mode match) and pattern string. + local szm, pat = match(tm, "^(.-):(.*)$", #args+1) + if pat == "" then pat = lastpat else lastpat = pat end + if matchtm(tm, args) then + local prefix = sub(szm, 1, 1) + if prefix == "/" then -- Match both operand sizes. + if args[1].opsize == sub(szm, 2, 2) and + args[2].opsize == sub(szm, 3, 3) then + dopattern(pat, args, sz, params.op, needrex) -- Process pattern. + return + end + else -- Match common operand size. + local szp = sz + if szm == "" then szm = x64 and "qdwb" or "dwb" end -- Default sizes. + if prefix == "1" then szp = args[1].opsize; szmix = nil + elseif prefix == "2" then szp = args[2].opsize; szmix = nil end + if not szmix and (prefix == "." or match(szm, szp or "#")) then + dopattern(pat, args, szp, params.op, needrex) -- Process pattern. + return + end + end + gotmatch = true + end + end + + local msg = "bad operand mode" + if gotmatch then + if szmix then + msg = "mixed operand size" + else + msg = sz and "bad operand size" or "missing operand size" + end + end + + werror(msg.." in `"..opmodestr(params.op, args).."'") +end + +------------------------------------------------------------------------------ + +-- x64-specific opcode for 64 bit immediates and displacements. +if x64 then + function map_op.mov64_2(params) + if not params then return { "reg, imm", "reg, [disp]", "[disp], reg" } end + if secpos+2 > maxsecpos then wflush() end + local opcode, op64, sz, rex, vreg + local op64 = match(params[1], "^%[%s*(.-)%s*%]$") + if op64 then + local a = parseoperand(params[2]) + if a.mode ~= "rmR" then werror("bad operand mode") end + sz = a.opsize + rex = sz == "q" and 8 or 0 + opcode = 0xa3 + else + op64 = match(params[2], "^%[%s*(.-)%s*%]$") + local a = parseoperand(params[1]) + if op64 then + if a.mode ~= "rmR" then werror("bad operand mode") end + sz = a.opsize + rex = sz == "q" and 8 or 0 + opcode = 0xa1 + else + if sub(a.mode, 1, 1) ~= "r" or a.opsize ~= "q" then + werror("bad operand mode") + end + op64 = params[2] + if a.reg == -1 then + vreg = a.vreg + opcode = 0xb8 + else + opcode = 0xb8 + band(a.reg, 7) + end + rex = a.reg > 7 and 9 or 8 + end + end + wputop(sz, opcode, rex) + if vreg then waction("VREG", vreg); wputxb(0) end + waction("IMM_D", format("(unsigned int)(%s)", op64)) + waction("IMM_D", format("(unsigned int)((%s)>>32)", op64)) + end +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcodes for data storage. +local function op_data(params) + if not params then return "imm..." end + local sz = sub(params.op, 2, 2) + if sz == "a" then sz = addrsize end + for _,p in ipairs(params) do + local a = parseoperand(p) + if sub(a.mode, 1, 1) ~= "i" or (a.opsize and a.opsize ~= sz) then + werror("bad mode or size in `"..p.."'") + end + if a.mode == "iJ" then + wputlabel("IMM_", a.imm, 1) + else + wputszarg(sz, a.imm) + end + if secpos+2 > maxsecpos then wflush() end + end +end + +map_op[".byte_*"] = op_data +map_op[".sbyte_*"] = op_data +map_op[".word_*"] = op_data +map_op[".dword_*"] = op_data +map_op[".aword_*"] = op_data + +------------------------------------------------------------------------------ + +-- Pseudo-opcode to mark the position where the action list is to be emitted. +map_op[".actionlist_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeactions(out, name) end) +end + +-- Pseudo-opcode to mark the position where the global enum is to be emitted. +map_op[".globals_1"] = function(params) + if not params then return "prefix" end + local prefix = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobals(out, prefix) end) +end + +-- Pseudo-opcode to mark the position where the global names are to be emitted. +map_op[".globalnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobalnames(out, name) end) +end + +-- Pseudo-opcode to mark the position where the extern names are to be emitted. +map_op[".externnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeexternnames(out, name) end) +end + +------------------------------------------------------------------------------ + +-- Label pseudo-opcode (converted from trailing colon form). +map_op[".label_2"] = function(params) + if not params then return "[1-9] | ->global | =>pcexpr [, addr]" end + if secpos+2 > maxsecpos then wflush() end + local a = parseoperand(params[1]) + local mode, imm = a.mode, a.imm + if type(imm) == "number" and (mode == "iJ" or (imm >= 1 and imm <= 9)) then + -- Local label (1: ... 9:) or global label (->global:). + waction("LABEL_LG", nil, 1) + wputxb(imm) + elseif mode == "iJ" then + -- PC label (=>pcexpr:). + waction("LABEL_PC", imm) + else + werror("bad label definition") + end + -- SETLABEL must immediately follow LABEL_LG/LABEL_PC. + local addr = params[2] + if addr then + local a = parseoperand(addr) + if a.mode == "iPJ" then + waction("SETLABEL", a.imm) + else + werror("bad label assignment") + end + end +end +map_op[".label_1"] = map_op[".label_2"] + +------------------------------------------------------------------------------ + +-- Alignment pseudo-opcode. +map_op[".align_1"] = function(params) + if not params then return "numpow2" end + if secpos+1 > maxsecpos then wflush() end + local align = tonumber(params[1]) or map_opsizenum[map_opsize[params[1]]] + if align then + local x = align + -- Must be a power of 2 in the range (2 ... 256). + for i=1,8 do + x = x / 2 + if x == 1 then + waction("ALIGN", nil, 1) + wputxb(align-1) -- Action byte is 2**n-1. + return + end + end + end + werror("bad alignment") +end + +-- Spacing pseudo-opcode. +map_op[".space_2"] = function(params) + if not params then return "num [, filler]" end + if secpos+1 > maxsecpos then wflush() end + waction("SPACE", params[1]) + local fill = params[2] + if fill then + fill = tonumber(fill) + if not fill or fill < 0 or fill > 255 then werror("bad filler") end + end + wputxb(fill or 0) +end +map_op[".space_1"] = map_op[".space_2"] + +------------------------------------------------------------------------------ + +-- Pseudo-opcode for (primitive) type definitions (map to C types). +map_op[".type_3"] = function(params, nparams) + if not params then + return nparams == 2 and "name, ctype" or "name, ctype, reg" + end + local name, ctype, reg = params[1], params[2], params[3] + if not match(name, "^[%a_][%w_]*$") then + werror("bad type name `"..name.."'") + end + local tp = map_type[name] + if tp then + werror("duplicate type `"..name.."'") + end + if reg and not map_reg_valid_base[reg] then + werror("bad base register `"..(map_reg_rev[reg] or reg).."'") + end + -- Add #type to defines. A bit unclean to put it in map_archdef. + map_archdef["#"..name] = "sizeof("..ctype..")" + -- Add new type and emit shortcut define. + local num = ctypenum + 1 + map_type[name] = { + ctype = ctype, + ctypefmt = format("Dt%X(%%s)", num), + reg = reg, + } + wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) + ctypenum = num +end +map_op[".type_2"] = map_op[".type_3"] + +-- Dump type definitions. +local function dumptypes(out, lvl) + local t = {} + for name in pairs(map_type) do t[#t+1] = name end + sort(t) + out:write("Type definitions:\n") + for _,name in ipairs(t) do + local tp = map_type[name] + local reg = tp.reg and map_reg_rev[tp.reg] or "" + out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) + end + out:write("\n") +end + +------------------------------------------------------------------------------ + +-- Set the current section. +function _M.section(num) + waction("SECTION") + wputxb(num) + wflush(true) -- SECTION is a terminal action. +end + +------------------------------------------------------------------------------ + +-- Dump architecture description. +function _M.dumparch(out) + out:write(format("DynASM %s version %s, released %s\n\n", + _info.arch, _info.version, _info.release)) + dumpregs(out) + dumpactions(out) +end + +-- Dump all user defined elements. +function _M.dumpdef(out, lvl) + dumptypes(out, lvl) + dumpglobals(out, lvl) + dumpexterns(out, lvl) +end + +------------------------------------------------------------------------------ + +-- Pass callbacks from/to the DynASM core. +function _M.passcb(wl, we, wf, ww) + wline, werror, wfatal, wwarn = wl, we, wf, ww + return wflush +end + +-- Setup the arch-specific module. +function _M.setup(arch, opt) + g_arch, g_opt = arch, opt +end + +-- Merge the core maps and the arch-specific maps. +function _M.mergemaps(map_coreop, map_def) + setmetatable(map_op, { __index = map_coreop }) + setmetatable(map_def, { __index = map_archdef }) + return map_op, map_def +end + +return _M + +------------------------------------------------------------------------------ + + +``` + +`include/luajit-2.0.5/dynasm/dynasm.lua`: + +```lua +------------------------------------------------------------------------------ +-- DynASM. A dynamic assembler for code generation engines. +-- Originally designed and implemented for LuaJIT. +-- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- See below for full copyright notice. +------------------------------------------------------------------------------ + +-- Application information. +local _info = { + name = "DynASM", + description = "A dynamic assembler for code generation engines", + version = "1.3.0", + vernum = 10300, + release = "2011-05-05", + author = "Mike Pall", + url = "http://luajit.org/dynasm.html", + license = "MIT", + copyright = [[ +Copyright (C) 2005-2017 Mike Pall. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +[ MIT license: http://www.opensource.org/licenses/mit-license.php ] +]], +} + +-- Cache library functions. +local type, pairs, ipairs = type, pairs, ipairs +local pcall, error, assert = pcall, error, assert +local _s = string +local sub, match, gmatch, gsub = _s.sub, _s.match, _s.gmatch, _s.gsub +local format, rep, upper = _s.format, _s.rep, _s.upper +local _t = table +local insert, remove, concat, sort = _t.insert, _t.remove, _t.concat, _t.sort +local exit = os.exit +local io = io +local stdin, stdout, stderr = io.stdin, io.stdout, io.stderr + +------------------------------------------------------------------------------ + +-- Program options. +local g_opt = {} + +-- Global state for current file. +local g_fname, g_curline, g_indent, g_lineno, g_synclineno, g_arch +local g_errcount = 0 + +-- Write buffer for output file. +local g_wbuffer, g_capbuffer + +------------------------------------------------------------------------------ + +-- Write an output line (or callback function) to the buffer. +local function wline(line, needindent) + local buf = g_capbuffer or g_wbuffer + buf[#buf+1] = needindent and g_indent..line or line + g_synclineno = g_synclineno + 1 +end + +-- Write assembler line as a comment, if requestd. +local function wcomment(aline) + if g_opt.comment then + wline(g_opt.comment..aline..g_opt.endcomment, true) + end +end + +-- Resync CPP line numbers. +local function wsync() + if g_synclineno ~= g_lineno and g_opt.cpp then + wline("#line "..g_lineno..' "'..g_fname..'"') + g_synclineno = g_lineno + end +end + +-- Dummy action flush function. Replaced with arch-specific function later. +local function wflush(term) +end + +-- Dump all buffered output lines. +local function wdumplines(out, buf) + for _,line in ipairs(buf) do + if type(line) == "string" then + assert(out:write(line, "\n")) + else + -- Special callback to dynamically insert lines after end of processing. + line(out) + end + end +end + +------------------------------------------------------------------------------ + +-- Emit an error. Processing continues with next statement. +local function werror(msg) + error(format("%s:%s: error: %s:\n%s", g_fname, g_lineno, msg, g_curline), 0) +end + +-- Emit a fatal error. Processing stops. +local function wfatal(msg) + g_errcount = "fatal" + werror(msg) +end + +-- Print a warning. Processing continues. +local function wwarn(msg) + stderr:write(format("%s:%s: warning: %s:\n%s\n", + g_fname, g_lineno, msg, g_curline)) +end + +-- Print caught error message. But suppress excessive errors. +local function wprinterr(...) + if type(g_errcount) == "number" then + -- Regular error. + g_errcount = g_errcount + 1 + if g_errcount < 21 then -- Seems to be a reasonable limit. + stderr:write(...) + elseif g_errcount == 21 then + stderr:write(g_fname, + ":*: warning: too many errors (suppressed further messages).\n") + end + else + -- Fatal error. + stderr:write(...) + return true -- Stop processing. + end +end + +------------------------------------------------------------------------------ + +-- Map holding all option handlers. +local opt_map = {} +local opt_current + +-- Print error and exit with error status. +local function opterror(...) + stderr:write("dynasm.lua: ERROR: ", ...) + stderr:write("\n") + exit(1) +end + +-- Get option parameter. +local function optparam(args) + local argn = args.argn + local p = args[argn] + if not p then + opterror("missing parameter for option `", opt_current, "'.") + end + args.argn = argn + 1 + return p +end + +------------------------------------------------------------------------------ + +-- Core pseudo-opcodes. +local map_coreop = {} +-- Dummy opcode map. Replaced by arch-specific map. +local map_op = {} + +-- Forward declarations. +local dostmt +local readfile + +------------------------------------------------------------------------------ + +-- Map for defines (initially empty, chains to arch-specific map). +local map_def = {} + +-- Pseudo-opcode to define a substitution. +map_coreop[".define_2"] = function(params, nparams) + if not params then return nparams == 1 and "name" or "name, subst" end + local name, def = params[1], params[2] or "1" + if not match(name, "^[%a_][%w_]*$") then werror("bad or duplicate define") end + map_def[name] = def +end +map_coreop[".define_1"] = map_coreop[".define_2"] + +-- Define a substitution on the command line. +function opt_map.D(args) + local namesubst = optparam(args) + local name, subst = match(namesubst, "^([%a_][%w_]*)=(.*)$") + if name then + map_def[name] = subst + elseif match(namesubst, "^[%a_][%w_]*$") then + map_def[namesubst] = "1" + else + opterror("bad define") + end +end + +-- Undefine a substitution on the command line. +function opt_map.U(args) + local name = optparam(args) + if match(name, "^[%a_][%w_]*$") then + map_def[name] = nil + else + opterror("bad define") + end +end + +-- Helper for definesubst. +local gotsubst + +local function definesubst_one(word) + local subst = map_def[word] + if subst then gotsubst = word; return subst else return word end +end + +-- Iteratively substitute defines. +local function definesubst(stmt) + -- Limit number of iterations. + for i=1,100 do + gotsubst = false + stmt = gsub(stmt, "#?[%w_]+", definesubst_one) + if not gotsubst then break end + end + if gotsubst then wfatal("recursive define involving `"..gotsubst.."'") end + return stmt +end + +-- Dump all defines. +local function dumpdefines(out, lvl) + local t = {} + for name in pairs(map_def) do + t[#t+1] = name + end + sort(t) + out:write("Defines:\n") + for _,name in ipairs(t) do + local subst = map_def[name] + if g_arch then subst = g_arch.revdef(subst) end + out:write(format(" %-20s %s\n", name, subst)) + end + out:write("\n") +end + +------------------------------------------------------------------------------ + +-- Support variables for conditional assembly. +local condlevel = 0 +local condstack = {} + +-- Evaluate condition with a Lua expression. Substitutions already performed. +local function cond_eval(cond) + local func, err + if setfenv then + func, err = loadstring("return "..cond, "=expr") + else + -- No globals. All unknown identifiers evaluate to nil. + func, err = load("return "..cond, "=expr", "t", {}) + end + if func then + if setfenv then + setfenv(func, {}) -- No globals. All unknown identifiers evaluate to nil. + end + local ok, res = pcall(func) + if ok then + if res == 0 then return false end -- Oh well. + return not not res + end + err = res + end + wfatal("bad condition: "..err) +end + +-- Skip statements until next conditional pseudo-opcode at the same level. +local function stmtskip() + local dostmt_save = dostmt + local lvl = 0 + dostmt = function(stmt) + local op = match(stmt, "^%s*(%S+)") + if op == ".if" then + lvl = lvl + 1 + elseif lvl ~= 0 then + if op == ".endif" then lvl = lvl - 1 end + elseif op == ".elif" or op == ".else" or op == ".endif" then + dostmt = dostmt_save + dostmt(stmt) + end + end +end + +-- Pseudo-opcodes for conditional assembly. +map_coreop[".if_1"] = function(params) + if not params then return "condition" end + local lvl = condlevel + 1 + local res = cond_eval(params[1]) + condlevel = lvl + condstack[lvl] = res + if not res then stmtskip() end +end + +map_coreop[".elif_1"] = function(params) + if not params then return "condition" end + if condlevel == 0 then wfatal(".elif without .if") end + local lvl = condlevel + local res = condstack[lvl] + if res then + if res == "else" then wfatal(".elif after .else") end + else + res = cond_eval(params[1]) + if res then + condstack[lvl] = res + return + end + end + stmtskip() +end + +map_coreop[".else_0"] = function(params) + if condlevel == 0 then wfatal(".else without .if") end + local lvl = condlevel + local res = condstack[lvl] + condstack[lvl] = "else" + if res then + if res == "else" then wfatal(".else after .else") end + stmtskip() + end +end + +map_coreop[".endif_0"] = function(params) + local lvl = condlevel + if lvl == 0 then wfatal(".endif without .if") end + condlevel = lvl - 1 +end + +-- Check for unfinished conditionals. +local function checkconds() + if g_errcount ~= "fatal" and condlevel ~= 0 then + wprinterr(g_fname, ":*: error: unbalanced conditional\n") + end +end + +------------------------------------------------------------------------------ + +-- Search for a file in the given path and open it for reading. +local function pathopen(path, name) + local dirsep = package and match(package.path, "\\") and "\\" or "/" + for _,p in ipairs(path) do + local fullname = p == "" and name or p..dirsep..name + local fin = io.open(fullname, "r") + if fin then + g_fname = fullname + return fin + end + end +end + +-- Include a file. +map_coreop[".include_1"] = function(params) + if not params then return "filename" end + local name = params[1] + -- Save state. Ugly, I know. but upvalues are fast. + local gf, gl, gcl, gi = g_fname, g_lineno, g_curline, g_indent + -- Read the included file. + local fatal = readfile(pathopen(g_opt.include, name) or + wfatal("include file `"..name.."' not found")) + -- Restore state. + g_synclineno = -1 + g_fname, g_lineno, g_curline, g_indent = gf, gl, gcl, gi + if fatal then wfatal("in include file") end +end + +-- Make .include and conditionals initially available, too. +map_op[".include_1"] = map_coreop[".include_1"] +map_op[".if_1"] = map_coreop[".if_1"] +map_op[".elif_1"] = map_coreop[".elif_1"] +map_op[".else_0"] = map_coreop[".else_0"] +map_op[".endif_0"] = map_coreop[".endif_0"] + +------------------------------------------------------------------------------ + +-- Support variables for macros. +local mac_capture, mac_lineno, mac_name +local mac_active = {} +local mac_list = {} + +-- Pseudo-opcode to define a macro. +map_coreop[".macro_*"] = function(mparams) + if not mparams then return "name [, params...]" end + -- Split off and validate macro name. + local name = remove(mparams, 1) + if not name then werror("missing macro name") end + if not (match(name, "^[%a_][%w_%.]*$") or match(name, "^%.[%w_%.]*$")) then + wfatal("bad macro name `"..name.."'") + end + -- Validate macro parameter names. + local mdup = {} + for _,mp in ipairs(mparams) do + if not match(mp, "^[%a_][%w_]*$") then + wfatal("bad macro parameter name `"..mp.."'") + end + if mdup[mp] then wfatal("duplicate macro parameter name `"..mp.."'") end + mdup[mp] = true + end + -- Check for duplicate or recursive macro definitions. + local opname = name.."_"..#mparams + if map_op[opname] or map_op[name.."_*"] then + wfatal("duplicate macro `"..name.."' ("..#mparams.." parameters)") + end + if mac_capture then wfatal("recursive macro definition") end + + -- Enable statement capture. + local lines = {} + mac_lineno = g_lineno + mac_name = name + mac_capture = function(stmt) -- Statement capture function. + -- Stop macro definition with .endmacro pseudo-opcode. + if not match(stmt, "^%s*.endmacro%s*$") then + lines[#lines+1] = stmt + return + end + mac_capture = nil + mac_lineno = nil + mac_name = nil + mac_list[#mac_list+1] = opname + -- Add macro-op definition. + map_op[opname] = function(params) + if not params then return mparams, lines end + -- Protect against recursive macro invocation. + if mac_active[opname] then wfatal("recursive macro invocation") end + mac_active[opname] = true + -- Setup substitution map. + local subst = {} + for i,mp in ipairs(mparams) do subst[mp] = params[i] end + local mcom + if g_opt.maccomment and g_opt.comment then + mcom = " MACRO "..name.." ("..#mparams..")" + wcomment("{"..mcom) + end + -- Loop through all captured statements + for _,stmt in ipairs(lines) do + -- Substitute macro parameters. + local st = gsub(stmt, "[%w_]+", subst) + st = definesubst(st) + st = gsub(st, "%s*%.%.%s*", "") -- Token paste a..b. + if mcom and sub(st, 1, 1) ~= "|" then wcomment(st) end + -- Emit statement. Use a protected call for better diagnostics. + local ok, err = pcall(dostmt, st) + if not ok then + -- Add the captured statement to the error. + wprinterr(err, "\n", g_indent, "| ", stmt, + "\t[MACRO ", name, " (", #mparams, ")]\n") + end + end + if mcom then wcomment("}"..mcom) end + mac_active[opname] = nil + end + end +end + +-- An .endmacro pseudo-opcode outside of a macro definition is an error. +map_coreop[".endmacro_0"] = function(params) + wfatal(".endmacro without .macro") +end + +-- Dump all macros and their contents (with -PP only). +local function dumpmacros(out, lvl) + sort(mac_list) + out:write("Macros:\n") + for _,opname in ipairs(mac_list) do + local name = sub(opname, 1, -3) + local params, lines = map_op[opname]() + out:write(format(" %-20s %s\n", name, concat(params, ", "))) + if lvl > 1 then + for _,line in ipairs(lines) do + out:write(" |", line, "\n") + end + out:write("\n") + end + end + out:write("\n") +end + +-- Check for unfinished macro definitions. +local function checkmacros() + if mac_capture then + wprinterr(g_fname, ":", mac_lineno, + ": error: unfinished .macro `", mac_name ,"'\n") + end +end + +------------------------------------------------------------------------------ + +-- Support variables for captures. +local cap_lineno, cap_name +local cap_buffers = {} +local cap_used = {} + +-- Start a capture. +map_coreop[".capture_1"] = function(params) + if not params then return "name" end + wflush() + local name = params[1] + if not match(name, "^[%a_][%w_]*$") then + wfatal("bad capture name `"..name.."'") + end + if cap_name then + wfatal("already capturing to `"..cap_name.."' since line "..cap_lineno) + end + cap_name = name + cap_lineno = g_lineno + -- Create or continue a capture buffer and start the output line capture. + local buf = cap_buffers[name] + if not buf then buf = {}; cap_buffers[name] = buf end + g_capbuffer = buf + g_synclineno = 0 +end + +-- Stop a capture. +map_coreop[".endcapture_0"] = function(params) + wflush() + if not cap_name then wfatal(".endcapture without a valid .capture") end + cap_name = nil + cap_lineno = nil + g_capbuffer = nil + g_synclineno = 0 +end + +-- Dump a capture buffer. +map_coreop[".dumpcapture_1"] = function(params) + if not params then return "name" end + wflush() + local name = params[1] + if not match(name, "^[%a_][%w_]*$") then + wfatal("bad capture name `"..name.."'") + end + cap_used[name] = true + wline(function(out) + local buf = cap_buffers[name] + if buf then wdumplines(out, buf) end + end) + g_synclineno = 0 +end + +-- Dump all captures and their buffers (with -PP only). +local function dumpcaptures(out, lvl) + out:write("Captures:\n") + for name,buf in pairs(cap_buffers) do + out:write(format(" %-20s %4s)\n", name, "("..#buf)) + if lvl > 1 then + local bar = rep("=", 76) + out:write(" ", bar, "\n") + for _,line in ipairs(buf) do + out:write(" ", line, "\n") + end + out:write(" ", bar, "\n\n") + end + end + out:write("\n") +end + +-- Check for unfinished or unused captures. +local function checkcaptures() + if cap_name then + wprinterr(g_fname, ":", cap_lineno, + ": error: unfinished .capture `", cap_name,"'\n") + return + end + for name in pairs(cap_buffers) do + if not cap_used[name] then + wprinterr(g_fname, ":*: error: missing .dumpcapture ", name ,"\n") + end + end +end + +------------------------------------------------------------------------------ + +-- Sections names. +local map_sections = {} + +-- Pseudo-opcode to define code sections. +-- TODO: Data sections, BSS sections. Needs extra C code and API. +map_coreop[".section_*"] = function(params) + if not params then return "name..." end + if #map_sections > 0 then werror("duplicate section definition") end + wflush() + for sn,name in ipairs(params) do + local opname = "."..name.."_0" + if not match(name, "^[%a][%w_]*$") or + map_op[opname] or map_op["."..name.."_*"] then + werror("bad section name `"..name.."'") + end + map_sections[#map_sections+1] = name + wline(format("#define DASM_SECTION_%s\t%d", upper(name), sn-1)) + map_op[opname] = function(params) g_arch.section(sn-1) end + end + wline(format("#define DASM_MAXSECTION\t\t%d", #map_sections)) +end + +-- Dump all sections. +local function dumpsections(out, lvl) + out:write("Sections:\n") + for _,name in ipairs(map_sections) do + out:write(format(" %s\n", name)) + end + out:write("\n") +end + +------------------------------------------------------------------------------ + +-- Replacement for customized Lua, which lacks the package library. +local prefix = "" +if not require then + function require(name) + local fp = assert(io.open(prefix..name..".lua")) + local s = fp:read("*a") + assert(fp:close()) + return assert(loadstring(s, "@"..name..".lua"))() + end +end + +-- Load architecture-specific module. +local function loadarch(arch) + if not match(arch, "^[%w_]+$") then return "bad arch name" end + local ok, m_arch = pcall(require, "dasm_"..arch) + if not ok then return "cannot load module: "..m_arch end + g_arch = m_arch + wflush = m_arch.passcb(wline, werror, wfatal, wwarn) + m_arch.setup(arch, g_opt) + map_op, map_def = m_arch.mergemaps(map_coreop, map_def) +end + +-- Dump architecture description. +function opt_map.dumparch(args) + local name = optparam(args) + if not g_arch then + local err = loadarch(name) + if err then opterror(err) end + end + + local t = {} + for name in pairs(map_coreop) do t[#t+1] = name end + for name in pairs(map_op) do t[#t+1] = name end + sort(t) + + local out = stdout + local _arch = g_arch._info + out:write(format("%s version %s, released %s, %s\n", + _info.name, _info.version, _info.release, _info.url)) + g_arch.dumparch(out) + + local pseudo = true + out:write("Pseudo-Opcodes:\n") + for _,sname in ipairs(t) do + local name, nparam = match(sname, "^(.+)_([0-9%*])$") + if name then + if pseudo and sub(name, 1, 1) ~= "." then + out:write("\nOpcodes:\n") + pseudo = false + end + local f = map_op[sname] + local s + if nparam ~= "*" then nparam = nparam + 0 end + if nparam == 0 then + s = "" + elseif type(f) == "string" then + s = map_op[".template__"](nil, f, nparam) + else + s = f(nil, nparam) + end + if type(s) == "table" then + for _,s2 in ipairs(s) do + out:write(format(" %-12s %s\n", name, s2)) + end + else + out:write(format(" %-12s %s\n", name, s)) + end + end + end + out:write("\n") + exit(0) +end + +-- Pseudo-opcode to set the architecture. +-- Only initially available (map_op is replaced when called). +map_op[".arch_1"] = function(params) + if not params then return "name" end + local err = loadarch(params[1]) + if err then wfatal(err) end + wline(format("#if DASM_VERSION != %d", _info.vernum)) + wline('#error "Version mismatch between DynASM and included encoding engine"') + wline("#endif") +end + +-- Dummy .arch pseudo-opcode to improve the error report. +map_coreop[".arch_1"] = function(params) + if not params then return "name" end + wfatal("duplicate .arch statement") +end + +------------------------------------------------------------------------------ + +-- Dummy pseudo-opcode. Don't confuse '.nop' with 'nop'. +map_coreop[".nop_*"] = function(params) + if not params then return "[ignored...]" end +end + +-- Pseudo-opcodes to raise errors. +map_coreop[".error_1"] = function(params) + if not params then return "message" end + werror(params[1]) +end + +map_coreop[".fatal_1"] = function(params) + if not params then return "message" end + wfatal(params[1]) +end + +-- Dump all user defined elements. +local function dumpdef(out) + local lvl = g_opt.dumpdef + if lvl == 0 then return end + dumpsections(out, lvl) + dumpdefines(out, lvl) + if g_arch then g_arch.dumpdef(out, lvl) end + dumpmacros(out, lvl) + dumpcaptures(out, lvl) +end + +------------------------------------------------------------------------------ + +-- Helper for splitstmt. +local splitlvl + +local function splitstmt_one(c) + if c == "(" then + splitlvl = ")"..splitlvl + elseif c == "[" then + splitlvl = "]"..splitlvl + elseif c == "{" then + splitlvl = "}"..splitlvl + elseif c == ")" or c == "]" or c == "}" then + if sub(splitlvl, 1, 1) ~= c then werror("unbalanced (), [] or {}") end + splitlvl = sub(splitlvl, 2) + elseif splitlvl == "" then + return " \0 " + end + return c +end + +-- Split statement into (pseudo-)opcode and params. +local function splitstmt(stmt) + -- Convert label with trailing-colon into .label statement. + local label = match(stmt, "^%s*(.+):%s*$") + if label then return ".label", {label} end + + -- Split at commas and equal signs, but obey parentheses and brackets. + splitlvl = "" + stmt = gsub(stmt, "[,%(%)%[%]{}]", splitstmt_one) + if splitlvl ~= "" then werror("unbalanced () or []") end + + -- Split off opcode. + local op, other = match(stmt, "^%s*([^%s%z]+)%s*(.*)$") + if not op then werror("bad statement syntax") end + + -- Split parameters. + local params = {} + for p in gmatch(other, "%s*(%Z+)%z?") do + params[#params+1] = gsub(p, "%s+$", "") + end + if #params > 16 then werror("too many parameters") end + + params.op = op + return op, params +end + +-- Process a single statement. +dostmt = function(stmt) + -- Ignore empty statements. + if match(stmt, "^%s*$") then return end + + -- Capture macro defs before substitution. + if mac_capture then return mac_capture(stmt) end + stmt = definesubst(stmt) + + -- Emit C code without parsing the line. + if sub(stmt, 1, 1) == "|" then + local tail = sub(stmt, 2) + wflush() + if sub(tail, 1, 2) == "//" then wcomment(tail) else wline(tail, true) end + return + end + + -- Split into (pseudo-)opcode and params. + local op, params = splitstmt(stmt) + + -- Get opcode handler (matching # of parameters or generic handler). + local f = map_op[op.."_"..#params] or map_op[op.."_*"] + if not f then + if not g_arch then wfatal("first statement must be .arch") end + -- Improve error report. + for i=0,9 do + if map_op[op.."_"..i] then + werror("wrong number of parameters for `"..op.."'") + end + end + werror("unknown statement `"..op.."'") + end + + -- Call opcode handler or special handler for template strings. + if type(f) == "string" then + map_op[".template__"](params, f) + else + f(params) + end +end + +-- Process a single line. +local function doline(line) + if g_opt.flushline then wflush() end + + -- Assembler line? + local indent, aline = match(line, "^(%s*)%|(.*)$") + if not aline then + -- No, plain C code line, need to flush first. + wflush() + wsync() + wline(line, false) + return + end + + g_indent = indent -- Remember current line indentation. + + -- Emit C code (even from macros). Avoids echo and line parsing. + if sub(aline, 1, 1) == "|" then + if not mac_capture then + wsync() + elseif g_opt.comment then + wsync() + wcomment(aline) + end + dostmt(aline) + return + end + + -- Echo assembler line as a comment. + if g_opt.comment then + wsync() + wcomment(aline) + end + + -- Strip assembler comments. + aline = gsub(aline, "//.*$", "") + + -- Split line into statements at semicolons. + if match(aline, ";") then + for stmt in gmatch(aline, "[^;]+") do dostmt(stmt) end + else + dostmt(aline) + end +end + +------------------------------------------------------------------------------ + +-- Write DynASM header. +local function dasmhead(out) + out:write(format([[ +/* +** This file has been pre-processed with DynASM. +** %s +** DynASM version %s, DynASM %s version %s +** DO NOT EDIT! The original file is in "%s". +*/ + +]], _info.url, + _info.version, g_arch._info.arch, g_arch._info.version, + g_fname)) +end + +-- Read input file. +readfile = function(fin) + g_indent = "" + g_lineno = 0 + g_synclineno = -1 + + -- Process all lines. + for line in fin:lines() do + g_lineno = g_lineno + 1 + g_curline = line + local ok, err = pcall(doline, line) + if not ok and wprinterr(err, "\n") then return true end + end + wflush() + + -- Close input file. + assert(fin == stdin or fin:close()) +end + +-- Write output file. +local function writefile(outfile) + local fout + + -- Open output file. + if outfile == nil or outfile == "-" then + fout = stdout + else + fout = assert(io.open(outfile, "w")) + end + + -- Write all buffered lines + wdumplines(fout, g_wbuffer) + + -- Close output file. + assert(fout == stdout or fout:close()) + + -- Optionally dump definitions. + dumpdef(fout == stdout and stderr or stdout) +end + +-- Translate an input file to an output file. +local function translate(infile, outfile) + g_wbuffer = {} + g_indent = "" + g_lineno = 0 + g_synclineno = -1 + + -- Put header. + wline(dasmhead) + + -- Read input file. + local fin + if infile == "-" then + g_fname = "(stdin)" + fin = stdin + else + g_fname = infile + fin = assert(io.open(infile, "r")) + end + readfile(fin) + + -- Check for errors. + if not g_arch then + wprinterr(g_fname, ":*: error: missing .arch directive\n") + end + checkconds() + checkmacros() + checkcaptures() + + if g_errcount ~= 0 then + stderr:write(g_fname, ":*: info: ", g_errcount, " error", + (type(g_errcount) == "number" and g_errcount > 1) and "s" or "", + " in input file -- no output file generated.\n") + dumpdef(stderr) + exit(1) + end + + -- Write output file. + writefile(outfile) +end + +------------------------------------------------------------------------------ + +-- Print help text. +function opt_map.help() + stdout:write("DynASM -- ", _info.description, ".\n") + stdout:write("DynASM ", _info.version, " ", _info.release, " ", _info.url, "\n") + stdout:write[[ + +Usage: dynasm [OPTION]... INFILE.dasc|- + + -h, --help Display this help text. + -V, --version Display version and copyright information. + + -o, --outfile FILE Output file name (default is stdout). + -I, --include DIR Add directory to the include search path. + + -c, --ccomment Use /* */ comments for assembler lines. + -C, --cppcomment Use // comments for assembler lines (default). + -N, --nocomment Suppress assembler lines in output. + -M, --maccomment Show macro expansions as comments (default off). + + -L, --nolineno Suppress CPP line number information in output. + -F, --flushline Flush action list for every line. + + -D NAME[=SUBST] Define a substitution. + -U NAME Undefine a substitution. + + -P, --dumpdef Dump defines, macros, etc. Repeat for more output. + -A, --dumparch ARCH Load architecture ARCH and dump description. +]] + exit(0) +end + +-- Print version information. +function opt_map.version() + stdout:write(format("%s version %s, released %s\n%s\n\n%s", + _info.name, _info.version, _info.release, _info.url, _info.copyright)) + exit(0) +end + +-- Misc. options. +function opt_map.outfile(args) g_opt.outfile = optparam(args) end +function opt_map.include(args) insert(g_opt.include, 1, optparam(args)) end +function opt_map.ccomment() g_opt.comment = "/*|"; g_opt.endcomment = " */" end +function opt_map.cppcomment() g_opt.comment = "//|"; g_opt.endcomment = "" end +function opt_map.nocomment() g_opt.comment = false end +function opt_map.maccomment() g_opt.maccomment = true end +function opt_map.nolineno() g_opt.cpp = false end +function opt_map.flushline() g_opt.flushline = true end +function opt_map.dumpdef() g_opt.dumpdef = g_opt.dumpdef + 1 end + +------------------------------------------------------------------------------ + +-- Short aliases for long options. +local opt_alias = { + h = "help", ["?"] = "help", V = "version", + o = "outfile", I = "include", + c = "ccomment", C = "cppcomment", N = "nocomment", M = "maccomment", + L = "nolineno", F = "flushline", + P = "dumpdef", A = "dumparch", +} + +-- Parse single option. +local function parseopt(opt, args) + opt_current = #opt == 1 and "-"..opt or "--"..opt + local f = opt_map[opt] or opt_map[opt_alias[opt]] + if not f then + opterror("unrecognized option `", opt_current, "'. Try `--help'.\n") + end + f(args) +end + +-- Parse arguments. +local function parseargs(args) + -- Default options. + g_opt.comment = "//|" + g_opt.endcomment = "" + g_opt.cpp = true + g_opt.dumpdef = 0 + g_opt.include = { "" } + + -- Process all option arguments. + args.argn = 1 + repeat + local a = args[args.argn] + if not a then break end + local lopt, opt = match(a, "^%-(%-?)(.+)") + if not opt then break end + args.argn = args.argn + 1 + if lopt == "" then + -- Loop through short options. + for o in gmatch(opt, ".") do parseopt(o, args) end + else + -- Long option. + parseopt(opt, args) + end + until false + + -- Check for proper number of arguments. + local nargs = #args - args.argn + 1 + if nargs ~= 1 then + if nargs == 0 then + if g_opt.dumpdef > 0 then return dumpdef(stdout) end + end + opt_map.help() + end + + -- Translate a single input file to a single output file + -- TODO: Handle multiple files? + translate(args[args.argn], g_opt.outfile) +end + +------------------------------------------------------------------------------ + +-- Add the directory dynasm.lua resides in to the Lua module search path. +local arg = arg +if arg and arg[0] then + prefix = match(arg[0], "^(.*[/\\])") + if package and prefix then package.path = prefix.."?.lua;"..package.path end +end + +-- Start DynASM. +parseargs{...} + +------------------------------------------------------------------------------ + + +``` + +`include/luajit-2.0.5/etc/luajit.1`: + +```1 +.TH luajit 1 "" "" "LuaJIT documentation" +.SH NAME +luajit \- Just-In-Time Compiler for the Lua Language +\fB +.SH SYNOPSIS +.B luajit +[\fIoptions\fR]... [\fIscript\fR [\fIargs\fR]...] +.SH "WEB SITE" +.IR http://luajit.org +.SH DESCRIPTION +.PP +This is the command-line program to run Lua programs with \fBLuaJIT\fR. +.PP +\fBLuaJIT\fR is a just-in-time (JIT) compiler for the Lua language. +The virtual machine (VM) is based on a fast interpreter combined with +a trace compiler. It can significantly improve the performance of Lua programs. +.PP +\fBLuaJIT\fR is API\- and ABI-compatible with the VM of the standard +Lua\ 5.1 interpreter. When embedding the VM into an application, +the built library can be used as a drop-in replacement. +.SH OPTIONS +.TP +.BI "\-e " chunk +Run the given chunk of Lua code. +.TP +.BI "\-l " library +Load the named library, just like \fBrequire("\fR\fIlibrary\fR\fB")\fR. +.TP +.BI "\-b " ... +Save or list bytecode. Run without arguments to get help on options. +.TP +.BI "\-j " command +Perform LuaJIT control command (optional space after \fB\-j\fR). +.TP +.BI "\-O" [opt] +Control LuaJIT optimizations. +.TP +.B "\-i" +Run in interactive mode. +.TP +.B "\-v" +Show \fBLuaJIT\fR version. +.TP +.B "\-E" +Ignore environment variables. +.TP +.B "\-\-" +Stop processing options. +.TP +.B "\-" +Read script from stdin instead. +.PP +After all options are processed, the given \fIscript\fR is run. +The arguments are passed in the global \fIarg\fR table. +.PP +Interactive mode is only entered, if no \fIscript\fR and no \fB\-e\fR +option is given. Interactive mode can be left with EOF (\fICtrl\-Z\fB). +.SH EXAMPLES +.TP +luajit hello.lua world + +Prints "Hello world", assuming \fIhello.lua\fR contains: +.br + print("Hello", arg[1]) +.TP +luajit \-e "local x=0; for i=1,1e9 do x=x+i end; print(x)" + +Calculates the sum of the numbers from 1 to 1000000000. +.br +And finishes in a reasonable amount of time, too. +.TP +luajit \-jv \-e "for i=1,10 do for j=1,10 do for k=1,100 do end end end" + +Runs some nested loops and shows the resulting traces. +.SH COPYRIGHT +.PP +\fBLuaJIT\fR is Copyright \(co 2005-2017 Mike Pall. +.br +\fBLuaJIT\fR is open source software, released under the MIT license. +.SH SEE ALSO +.PP +More details in the provided HTML docs or at: +.IR http://luajit.org +.br +More about the Lua language can be found at: +.IR http://lua.org/docs.html +.PP +lua(1) + +``` + +`include/luajit-2.0.5/etc/luajit.pc`: + +```pc +# Package information for LuaJIT to be used by pkg-config. +majver=2 +minver=0 +relver=5 +version=${majver}.${minver}.${relver} +abiver=5.1 + +prefix=/usr/local +multilib=lib +exec_prefix=${prefix} +libdir=${exec_prefix}/${multilib} +libname=luajit-${abiver} +includedir=${prefix}/include/luajit-${majver}.${minver} + +INSTALL_LMOD=${prefix}/share/lua/${abiver} +INSTALL_CMOD=${prefix}/${multilib}/lua/${abiver} + +Name: LuaJIT +Description: Just-in-time compiler for Lua +URL: http://luajit.org +Version: ${version} +Requires: +Libs: -L${libdir} -l${libname} +Libs.private: -Wl,-E -lm -ldl +Cflags: -I${includedir} + +``` + +`include/luajit-2.0.5/src/Makefile`: + +``` +############################################################################## +# LuaJIT Makefile. Requires GNU Make. +# +# Please read doc/install.html before changing any variables! +# +# Suitable for POSIX platforms (Linux, *BSD, OSX etc.). +# Also works with MinGW and Cygwin on Windows. +# Please check msvcbuild.bat for building with MSVC on Windows. +# +# Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +############################################################################## + +MAJVER= 2 +MINVER= 0 +RELVER= 5 +ABIVER= 5.1 +NODOTABIVER= 51 + +############################################################################## +############################# COMPILER OPTIONS ############################# +############################################################################## +# These options mainly affect the speed of the JIT compiler itself, not the +# speed of the JIT-compiled code. Turn any of the optional settings on by +# removing the '#' in front of them. Make sure you force a full recompile +# with "make clean", followed by "make" if you change any options. +# +DEFAULT_CC = gcc +# +# LuaJIT builds as a native 32 or 64 bit binary by default. +CC= $(DEFAULT_CC) +# +# Use this if you want to force a 32 bit build on a 64 bit multilib OS. +#CC= $(DEFAULT_CC) -m32 +# +# Since the assembler part does NOT maintain a frame pointer, it's pointless +# to slow down the C part by not omitting it. Debugging, tracebacks and +# unwinding are not affected -- the assembler part has frame unwind +# information and GCC emits it where needed (x64) or with -g (see CCDEBUG). +CCOPT= -O2 -fomit-frame-pointer +# Use this if you want to generate a smaller binary (but it's slower): +#CCOPT= -Os -fomit-frame-pointer +# Note: it's no longer recommended to use -O3 with GCC 4.x. +# The I-Cache bloat usually outweighs the benefits from aggressive inlining. +# +# Target-specific compiler options: +# +# x86 only: it's recommended to compile at least for i686. Better yet, +# compile for an architecture that has SSE2, too (-msse -msse2). +# +# x86/x64 only: For GCC 4.2 or higher and if you don't intend to distribute +# the binaries to a different machine you could also use: -march=native +# +CCOPT_x86= -march=i686 +CCOPT_x64= +CCOPT_arm= +CCOPT_ppc= +CCOPT_ppcspe= +CCOPT_mips= +# +CCDEBUG= +# Uncomment the next line to generate debug information: +#CCDEBUG= -g +# +CCWARN= -Wall +# Uncomment the next line to enable more warnings: +#CCWARN+= -Wextra -Wdeclaration-after-statement -Wredundant-decls -Wshadow -Wpointer-arith +# +############################################################################## + +############################################################################## +################################ BUILD MODE ################################ +############################################################################## +# The default build mode is mixed mode on POSIX. On Windows this is the same +# as dynamic mode. +# +# Mixed mode creates a static + dynamic library and a statically linked luajit. +BUILDMODE= mixed +# +# Static mode creates a static library and a statically linked luajit. +#BUILDMODE= static +# +# Dynamic mode creates a dynamic library and a dynamically linked luajit. +# Note: this executable will only run when the library is installed! +#BUILDMODE= dynamic +# +############################################################################## + +############################################################################## +################################# FEATURES ################################# +############################################################################## +# Enable/disable these features as needed, but make sure you force a full +# recompile with "make clean", followed by "make". +XCFLAGS= +# +# Permanently disable the FFI extension to reduce the size of the LuaJIT +# executable. But please consider that the FFI library is compiled-in, +# but NOT loaded by default. It only allocates any memory, if you actually +# make use of it. +#XCFLAGS+= -DLUAJIT_DISABLE_FFI +# +# Features from Lua 5.2 that are unlikely to break existing code are +# enabled by default. Some other features that *might* break some existing +# code (e.g. __pairs or os.execute() return values) can be enabled here. +# Note: this does not provide full compatibility with Lua 5.2 at this time. +#XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT +# +# Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter. +#XCFLAGS+= -DLUAJIT_DISABLE_JIT +# +# Some architectures (e.g. PPC) can use either single-number (1) or +# dual-number (2) mode. Uncomment one of these lines to override the +# default mode. Please see LJ_ARCH_NUMMODE in lj_arch.h for details. +#XCFLAGS+= -DLUAJIT_NUMMODE=1 +#XCFLAGS+= -DLUAJIT_NUMMODE=2 +# +############################################################################## + +############################################################################## +############################ DEBUGGING SUPPORT ############################# +############################################################################## +# Enable these options as needed, but make sure you force a full recompile +# with "make clean", followed by "make". +# Note that most of these are NOT suitable for benchmarking or release mode! +# +# Use the system provided memory allocator (realloc) instead of the +# bundled memory allocator. This is slower, but sometimes helpful for +# debugging. This option cannot be enabled on x64, since realloc usually +# doesn't return addresses in the right address range. +# OTOH this option is mandatory for Valgrind's memcheck tool on x64 and +# the only way to get useful results from it for all other architectures. +#XCFLAGS+= -DLUAJIT_USE_SYSMALLOC +# +# This define is required to run LuaJIT under Valgrind. The Valgrind +# header files must be installed. You should enable debug information, too. +# Use --suppressions=lj.supp to avoid some false positives. +#XCFLAGS+= -DLUAJIT_USE_VALGRIND +# +# This is the client for the GDB JIT API. GDB 7.0 or higher is required +# to make use of it. See lj_gdbjit.c for details. Enabling this causes +# a non-negligible overhead, even when not running under GDB. +#XCFLAGS+= -DLUAJIT_USE_GDBJIT +# +# Turn on assertions for the Lua/C API to debug problems with lua_* calls. +# This is rather slow -- use only while developing C libraries/embeddings. +#XCFLAGS+= -DLUA_USE_APICHECK +# +# Turn on assertions for the whole LuaJIT VM. This significantly slows down +# everything. Use only if you suspect a problem with LuaJIT itself. +#XCFLAGS+= -DLUA_USE_ASSERT +# +############################################################################## +# You probably don't need to change anything below this line! +############################################################################## + +############################################################################## +# Host system detection. +############################################################################## + +ifeq (Windows,$(findstring Windows,$(OS))$(MSYSTEM)$(TERM)) + HOST_SYS= Windows + HOST_RM= del +else + HOST_SYS:= $(shell uname -s) + ifneq (,$(findstring MINGW,$(HOST_SYS))) + HOST_SYS= Windows + HOST_MSYS= mingw + endif + ifneq (,$(findstring CYGWIN,$(HOST_SYS))) + HOST_SYS= Windows + HOST_MSYS= cygwin + endif +endif + +############################################################################## +# Flags and options for host and target. +############################################################################## + +# You can override the following variables at the make command line: +# CC HOST_CC STATIC_CC DYNAMIC_CC +# CFLAGS HOST_CFLAGS TARGET_CFLAGS +# LDFLAGS HOST_LDFLAGS TARGET_LDFLAGS TARGET_SHLDFLAGS +# LIBS HOST_LIBS TARGET_LIBS +# CROSS HOST_SYS TARGET_SYS TARGET_FLAGS +# +# Cross-compilation examples: +# make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows +# make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu- + +CCOPTIONS= $(CCDEBUG) $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS) +LDOPTIONS= $(CCDEBUG) $(LDFLAGS) + +HOST_CC= $(CC) +HOST_RM= rm -f +# If left blank, minilua is built and used. You can supply an installed +# copy of (plain) Lua 5.1 or 5.2, plus Lua BitOp. E.g. with: HOST_LUA=lua +HOST_LUA= + +HOST_XCFLAGS= -I. +HOST_XLDFLAGS= +HOST_XLIBS= +HOST_ACFLAGS= $(CCOPTIONS) $(HOST_XCFLAGS) $(TARGET_ARCH) $(HOST_CFLAGS) +HOST_ALDFLAGS= $(LDOPTIONS) $(HOST_XLDFLAGS) $(HOST_LDFLAGS) +HOST_ALIBS= $(HOST_XLIBS) $(LIBS) $(HOST_LIBS) + +STATIC_CC = $(CROSS)$(CC) +DYNAMIC_CC = $(CROSS)$(CC) -fPIC +TARGET_CC= $(STATIC_CC) +TARGET_STCC= $(STATIC_CC) +TARGET_DYNCC= $(DYNAMIC_CC) +TARGET_LD= $(CROSS)$(CC) +TARGET_AR= $(CROSS)ar rcus 2>/dev/null +TARGET_STRIP= $(CROSS)strip + +TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib) +TARGET_SONAME= libluajit-$(ABIVER).so.$(MAJVER) +TARGET_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).dylib +TARGET_DYLIBPATH= $(TARGET_LIBPATH)/$(TARGET_DYLIBNAME) +TARGET_DLLNAME= lua$(NODOTABIVER).dll +TARGET_XSHLDFLAGS= -shared -fPIC -Wl,-soname,$(TARGET_SONAME) +TARGET_DYNXLDOPTS= + +TARGET_LFSFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE +TARGET_XCFLAGS= $(TARGET_LFSFLAGS) -U_FORTIFY_SOURCE +TARGET_XLDFLAGS= +TARGET_XLIBS= -lm +TARGET_TCFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS) +TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS) +TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS) +TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS) +TARGET_ALIBS= $(TARGET_XLIBS) $(LIBS) $(TARGET_LIBS) + +TARGET_TESTARCH=$(shell $(TARGET_CC) $(TARGET_TCFLAGS) -E lj_arch.h -dM) +ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH))) + TARGET_LJARCH= x64 +else +ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH))) + TARGET_LJARCH= x86 +else +ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH))) + TARGET_LJARCH= arm +else +ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH))) + TARGET_LJARCH= ppc +else +ifneq (,$(findstring LJ_TARGET_PPCSPE ,$(TARGET_TESTARCH))) + TARGET_LJARCH= ppcspe +else +ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH))) + ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH))) + TARGET_ARCH= -D__MIPSEL__=1 + endif + TARGET_LJARCH= mips +else + $(error Unsupported target architecture) +endif +endif +endif +endif +endif +endif + +ifneq (,$(findstring LJ_TARGET_PS3 1,$(TARGET_TESTARCH))) + TARGET_SYS= PS3 + TARGET_ARCH+= -D__CELLOS_LV2__ + TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC +endif + +TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH)) +TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH)) + +ifneq (,$(PREFIX)) +ifneq (/usr/local,$(PREFIX)) + TARGET_XCFLAGS+= -DLUA_ROOT=\"$(PREFIX)\" + ifneq (/usr,$(PREFIX)) + TARGET_DYNXLDOPTS= -Wl,-rpath,$(TARGET_LIBPATH) + endif +endif +endif +ifneq (,$(MULTILIB)) + TARGET_XCFLAGS+= -DLUA_MULTILIB=\"$(MULTILIB)\" +endif +ifneq (,$(LMULTILIB)) + TARGET_XCFLAGS+= -DLUA_LMULTILIB=\"$(LMULTILIB)\" +endif + +############################################################################## +# Target system detection. +############################################################################## + +TARGET_SYS?= $(HOST_SYS) +ifeq (Windows,$(TARGET_SYS)) + TARGET_STRIP+= --strip-unneeded + TARGET_XSHLDFLAGS= -shared + TARGET_DYNXLDOPTS= +else +ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1)) + TARGET_XCFLAGS+= -fno-stack-protector +endif +ifeq (Darwin,$(TARGET_SYS)) + ifeq (,$(MACOSX_DEPLOYMENT_TARGET)) + export MACOSX_DEPLOYMENT_TARGET=10.4 + endif + TARGET_STRIP+= -x + TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC + TARGET_DYNXLDOPTS= + TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) + ifeq (x64,$(TARGET_LJARCH)) + TARGET_XLDFLAGS+= -pagezero_size 10000 -image_base 100000000 + TARGET_XSHLDFLAGS+= -image_base 7fff04c4a000 + endif +else +ifeq (iOS,$(TARGET_SYS)) + TARGET_STRIP+= -x + TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC + TARGET_DYNXLDOPTS= + TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) +else + ifneq (SunOS,$(TARGET_SYS)) + ifneq (PS3,$(TARGET_SYS)) + TARGET_XLDFLAGS+= -Wl,-E + endif + endif + ifeq (Linux,$(TARGET_SYS)) + TARGET_XLIBS+= -ldl + endif + ifeq (GNU/kFreeBSD,$(TARGET_SYS)) + TARGET_XLIBS+= -ldl + endif +endif +endif +endif + +ifneq ($(HOST_SYS),$(TARGET_SYS)) + ifeq (Windows,$(TARGET_SYS)) + HOST_XCFLAGS+= -malign-double -DLUAJIT_OS=LUAJIT_OS_WINDOWS + else + ifeq (Linux,$(TARGET_SYS)) + HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_LINUX + else + ifeq (Darwin,$(TARGET_SYS)) + HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX + else + ifeq (iOS,$(TARGET_SYS)) + HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX + else + HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OTHER + endif + endif + endif + endif +endif + +ifneq (,$(CCDEBUG)) + TARGET_STRIP= @: +endif + +############################################################################## +# Files and pathnames. +############################################################################## + +MINILUA_O= host/minilua.o +MINILUA_LIBS= -lm +MINILUA_T= host/minilua +MINILUA_X= $(MINILUA_T) + +ifeq (,$(HOST_LUA)) + HOST_LUA= $(MINILUA_X) + DASM_DEP= $(MINILUA_T) +endif + +DASM_DIR= ../dynasm +DASM= $(HOST_LUA) $(DASM_DIR)/dynasm.lua +DASM_XFLAGS= +DASM_AFLAGS= +DASM_ARCH= $(TARGET_LJARCH) + +ifneq (,$(findstring LJ_ARCH_BITS 64,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D P64 +endif +ifneq (,$(findstring LJ_HASJIT 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D JIT +endif +ifneq (,$(findstring LJ_HASFFI 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D FFI +endif +ifneq (,$(findstring LJ_DUALNUM 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D DUALNUM +endif +ifneq (,$(findstring LJ_ARCH_HASFPU 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D FPU + TARGET_ARCH+= -DLJ_ARCH_HASFPU=1 +else + TARGET_ARCH+= -DLJ_ARCH_HASFPU=0 +endif +ifeq (,$(findstring LJ_ABI_SOFTFP 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D HFABI + TARGET_ARCH+= -DLJ_ABI_SOFTFP=0 +else + TARGET_ARCH+= -DLJ_ABI_SOFTFP=1 +endif +ifneq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D NO_UNWIND + TARGET_ARCH+= -DLUAJIT_NO_UNWIND +endif +DASM_AFLAGS+= -D VER=$(subst LJ_ARCH_VERSION_,,$(filter LJ_ARCH_VERSION_%,$(subst LJ_ARCH_VERSION ,LJ_ARCH_VERSION_,$(TARGET_TESTARCH)))) +ifeq (Windows,$(TARGET_SYS)) + DASM_AFLAGS+= -D WIN +endif +ifeq (x86,$(TARGET_LJARCH)) + ifneq (,$(findstring __SSE2__ 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D SSE + endif +else +ifeq (x64,$(TARGET_LJARCH)) + DASM_ARCH= x86 +else +ifeq (arm,$(TARGET_LJARCH)) + ifeq (iOS,$(TARGET_SYS)) + DASM_AFLAGS+= -D IOS + endif +else +ifeq (ppc,$(TARGET_LJARCH)) + ifneq (,$(findstring LJ_ARCH_SQRT 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D SQRT + endif + ifneq (,$(findstring LJ_ARCH_ROUND 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D ROUND + endif + ifneq (,$(findstring LJ_ARCH_PPC64 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D GPR64 + endif + ifeq (PS3,$(TARGET_SYS)) + DASM_AFLAGS+= -D PPE -D TOC + endif +endif +endif +endif +endif + +DASM_FLAGS= $(DASM_XFLAGS) $(DASM_AFLAGS) +DASM_DASC= vm_$(DASM_ARCH).dasc + +BUILDVM_O= host/buildvm.o host/buildvm_asm.o host/buildvm_peobj.o \ + host/buildvm_lib.o host/buildvm_fold.o +BUILDVM_T= host/buildvm +BUILDVM_X= $(BUILDVM_T) + +HOST_O= $(MINILUA_O) $(BUILDVM_O) +HOST_T= $(MINILUA_T) $(BUILDVM_T) + +LJVM_S= lj_vm.s +LJVM_O= lj_vm.o +LJVM_BOUT= $(LJVM_S) +LJVM_MODE= elfasm + +LJLIB_O= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \ + lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o +LJLIB_C= $(LJLIB_O:.o=.c) + +LJCORE_O= lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o \ + lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \ + lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o lj_strscan.o \ + lj_api.o lj_lex.o lj_parse.o lj_bcread.o lj_bcwrite.o lj_load.o \ + lj_ir.o lj_opt_mem.o lj_opt_fold.o lj_opt_narrow.o \ + lj_opt_dce.o lj_opt_loop.o lj_opt_split.o lj_opt_sink.o \ + lj_mcode.o lj_snap.o lj_record.o lj_crecord.o lj_ffrecord.o \ + lj_asm.o lj_trace.o lj_gdbjit.o \ + lj_ctype.o lj_cdata.o lj_cconv.o lj_ccall.o lj_ccallback.o \ + lj_carith.o lj_clib.o lj_cparse.o \ + lj_lib.o lj_alloc.o lib_aux.o \ + $(LJLIB_O) lib_init.o + +LJVMCORE_O= $(LJVM_O) $(LJCORE_O) +LJVMCORE_DYNO= $(LJVMCORE_O:.o=_dyn.o) + +LIB_VMDEF= jit/vmdef.lua +LIB_VMDEFP= $(LIB_VMDEF) + +LUAJIT_O= luajit.o +LUAJIT_A= libluajit.a +LUAJIT_SO= libluajit.so +LUAJIT_T= luajit + +ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(HOST_T) +ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \ + host/buildvm_arch.h +ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP) +WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk +ALL_RM= $(ALL_T) $(ALL_GEN) *.o host/*.o $(WIN_RM) + +############################################################################## +# Build mode handling. +############################################################################## + +# Mixed mode defaults. +TARGET_O= $(LUAJIT_A) +TARGET_T= $(LUAJIT_T) $(LUAJIT_SO) +TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO) + +ifeq (Windows,$(TARGET_SYS)) + TARGET_DYNCC= $(STATIC_CC) + LJVM_MODE= peobj + LJVM_BOUT= $(LJVM_O) + LUAJIT_T= luajit.exe + ifeq (cygwin,$(HOST_MSYS)) + LUAJIT_SO= cyg$(TARGET_DLLNAME) + else + LUAJIT_SO= $(TARGET_DLLNAME) + endif + # Mixed mode is not supported on Windows. And static mode doesn't work well. + # C modules cannot be loaded, because they bind to lua51.dll. + ifneq (static,$(BUILDMODE)) + BUILDMODE= dynamic + TARGET_XCFLAGS+= -DLUA_BUILD_AS_DLL + endif +endif +ifeq (Darwin,$(TARGET_SYS)) + LJVM_MODE= machasm +endif +ifeq (iOS,$(TARGET_SYS)) + LJVM_MODE= machasm +endif +ifeq (SunOS,$(TARGET_SYS)) + BUILDMODE= static +endif +ifeq (PS3,$(TARGET_SYS)) + BUILDMODE= static +endif + +ifeq (Windows,$(HOST_SYS)) + MINILUA_T= host/minilua.exe + BUILDVM_T= host/buildvm.exe + ifeq (,$(HOST_MSYS)) + MINILUA_X= host\minilua + BUILDVM_X= host\buildvm + ALL_RM:= $(subst /,\,$(ALL_RM)) + endif +endif + +ifeq (static,$(BUILDMODE)) + TARGET_DYNCC= @: + TARGET_T= $(LUAJIT_T) + TARGET_DEP= $(LIB_VMDEF) +else +ifeq (dynamic,$(BUILDMODE)) + ifneq (Windows,$(TARGET_SYS)) + TARGET_CC= $(DYNAMIC_CC) + endif + TARGET_DYNCC= @: + LJVMCORE_DYNO= $(LJVMCORE_O) + TARGET_O= $(LUAJIT_SO) + TARGET_XLDFLAGS+= $(TARGET_DYNXLDOPTS) +else +ifeq (Darwin,$(TARGET_SYS)) + TARGET_DYNCC= @: + LJVMCORE_DYNO= $(LJVMCORE_O) +endif +ifeq (iOS,$(TARGET_SYS)) + TARGET_DYNCC= @: + LJVMCORE_DYNO= $(LJVMCORE_O) +endif +endif +endif + +Q= @ +E= @echo +#Q= +#E= @: + +############################################################################## +# Make targets. +############################################################################## + +default all: $(TARGET_T) + +amalg: + @grep "^[+|]" ljamalg.c + $(MAKE) all "LJCORE_O=ljamalg.o" + +clean: + $(HOST_RM) $(ALL_RM) + +depend: + @for file in $(ALL_HDRGEN); do \ + test -f $$file || touch $$file; \ + done + @$(HOST_CC) $(HOST_ACFLAGS) -MM *.c host/*.c | \ + sed -e "s| [^ ]*/dasm_\S*\.h||g" \ + -e "s|^\([^l ]\)|host/\1|" \ + -e "s| lj_target_\S*\.h| lj_target_*.h|g" \ + -e "s| lj_emit_\S*\.h| lj_emit_*.h|g" \ + -e "s| lj_asm_\S*\.h| lj_asm_*.h|g" >Makefile.dep + @for file in $(ALL_HDRGEN); do \ + test -s $$file || $(HOST_RM) $$file; \ + done + +.PHONY: default all amalg clean depend + +############################################################################## +# Rules for generated files. +############################################################################## + +$(MINILUA_T): $(MINILUA_O) + $(E) "HOSTLINK $@" + $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS) + +host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP) + $(E) "DYNASM $@" + $(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC) + +host/buildvm.o: $(DASM_DIR)/dasm_*.h + +$(BUILDVM_T): $(BUILDVM_O) + $(E) "HOSTLINK $@" + $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(BUILDVM_O) $(HOST_ALIBS) + +$(LJVM_BOUT): $(BUILDVM_T) + $(E) "BUILDVM $@" + $(Q)$(BUILDVM_X) -m $(LJVM_MODE) -o $@ + +lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C) + $(E) "BUILDVM $@" + $(Q)$(BUILDVM_X) -m bcdef -o $@ $(LJLIB_C) + +lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C) + $(E) "BUILDVM $@" + $(Q)$(BUILDVM_X) -m ffdef -o $@ $(LJLIB_C) + +lj_libdef.h: $(BUILDVM_T) $(LJLIB_C) + $(E) "BUILDVM $@" + $(Q)$(BUILDVM_X) -m libdef -o $@ $(LJLIB_C) + +lj_recdef.h: $(BUILDVM_T) $(LJLIB_C) + $(E) "BUILDVM $@" + $(Q)$(BUILDVM_X) -m recdef -o $@ $(LJLIB_C) + +$(LIB_VMDEF): $(BUILDVM_T) $(LJLIB_C) + $(E) "BUILDVM $@" + $(Q)$(BUILDVM_X) -m vmdef -o $(LIB_VMDEFP) $(LJLIB_C) + +lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c + $(E) "BUILDVM $@" + $(Q)$(BUILDVM_X) -m folddef -o $@ lj_opt_fold.c + +############################################################################## +# Object file rules. +############################################################################## + +%.o: %.c + $(E) "CC $@" + $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $< + $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $< + +%.o: %.s + $(E) "ASM $@" + $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $< + $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $< + +$(LUAJIT_O): + $(E) "CC $@" + $(Q)$(TARGET_STCC) $(TARGET_ACFLAGS) -c -o $@ $< + +$(HOST_O): %.o: %.c + $(E) "HOSTCC $@" + $(Q)$(HOST_CC) $(HOST_ACFLAGS) -c -o $@ $< + +include Makefile.dep + +############################################################################## +# Target file rules. +############################################################################## + +$(LUAJIT_A): $(LJVMCORE_O) + $(E) "AR $@" + $(Q)$(TARGET_AR) $@ $(LJVMCORE_O) + +# The dependency on _O, but linking with _DYNO is intentional. +$(LUAJIT_SO): $(LJVMCORE_O) + $(E) "DYNLINK $@" + $(Q)$(TARGET_LD) $(TARGET_ASHLDFLAGS) -o $@ $(LJVMCORE_DYNO) $(TARGET_ALIBS) + $(Q)$(TARGET_STRIP) $@ + +$(LUAJIT_T): $(TARGET_O) $(LUAJIT_O) $(TARGET_DEP) + $(E) "LINK $@" + $(Q)$(TARGET_LD) $(TARGET_ALDFLAGS) -o $@ $(LUAJIT_O) $(TARGET_O) $(TARGET_ALIBS) + $(Q)$(TARGET_STRIP) $@ + $(E) "OK Successfully built LuaJIT" + +############################################################################## + +``` + +`include/luajit-2.0.5/src/Makefile.dep`: + +```dep +lib_aux.o: lib_aux.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \ + lj_arch.h lj_err.h lj_errmsg.h lj_state.h lj_trace.h lj_jit.h lj_ir.h \ + lj_dispatch.h lj_bc.h lj_traceerr.h lj_lib.h lj_alloc.h +lib_base.o: lib_base.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ + lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h \ + lj_tab.h lj_meta.h lj_state.h lj_ctype.h lj_cconv.h lj_bc.h lj_ff.h \ + lj_ffdef.h lj_dispatch.h lj_jit.h lj_ir.h lj_char.h lj_strscan.h \ + lj_lib.h lj_libdef.h +lib_bit.o: lib_bit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ + lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_lib.h lj_libdef.h +lib_debug.o: lib_debug.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ + lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_lib.h \ + lj_libdef.h +lib_ffi.o: lib_ffi.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ + lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h \ + lj_ctype.h lj_cparse.h lj_cdata.h lj_cconv.h lj_carith.h lj_ccall.h \ + lj_ccallback.h lj_clib.h lj_ff.h lj_ffdef.h lj_lib.h lj_libdef.h +lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h +lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ + lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_state.h lj_ff.h \ + lj_ffdef.h lj_lib.h lj_libdef.h +lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h \ + lj_obj.h lj_def.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \ + lj_bc.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_target.h \ + lj_target_*.h lj_dispatch.h lj_vm.h lj_vmevent.h lj_lib.h luajit.h \ + lj_libdef.h +lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ + lj_def.h lj_arch.h lj_lib.h lj_vm.h lj_libdef.h +lib_os.o: lib_os.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ + lj_arch.h lj_err.h lj_errmsg.h lj_lib.h lj_libdef.h +lib_package.o: lib_package.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ + lj_def.h lj_arch.h lj_err.h lj_errmsg.h lj_lib.h +lib_string.o: lib_string.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ + lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h \ + lj_meta.h lj_state.h lj_ff.h lj_ffdef.h lj_bcdump.h lj_lex.h lj_char.h \ + lj_lib.h lj_libdef.h +lib_table.o: lib_table.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ + lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_lib.h \ + lj_libdef.h +lj_alloc.o: lj_alloc.c lj_def.h lua.h luaconf.h lj_arch.h lj_alloc.h +lj_api.o: lj_api.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_func.h lj_udata.h \ + lj_meta.h lj_state.h lj_bc.h lj_frame.h lj_trace.h lj_jit.h lj_ir.h \ + lj_dispatch.h lj_traceerr.h lj_vm.h lj_strscan.h +lj_asm.o: lj_asm.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ctype.h lj_ir.h lj_jit.h \ + lj_ircall.h lj_iropt.h lj_mcode.h lj_trace.h lj_dispatch.h lj_traceerr.h \ + lj_snap.h lj_asm.h lj_vm.h lj_target.h lj_target_*.h lj_emit_*.h \ + lj_asm_*.h +lj_bc.o: lj_bc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_bc.h \ + lj_bcdef.h +lj_bcread.o: lj_bcread.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_bc.h lj_ctype.h \ + lj_cdata.h lualib.h lj_lex.h lj_bcdump.h lj_state.h +lj_bcwrite.o: lj_bcwrite.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_str.h lj_bc.h lj_ctype.h lj_dispatch.h lj_jit.h lj_ir.h \ + lj_bcdump.h lj_lex.h lj_err.h lj_errmsg.h lj_vm.h +lj_carith.o: lj_carith.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_meta.h lj_ctype.h lj_cconv.h \ + lj_cdata.h lj_carith.h +lj_ccall.o: lj_ccall.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cconv.h \ + lj_cdata.h lj_ccall.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h \ + lj_traceerr.h +lj_ccallback.o: lj_ccallback.c lj_obj.h lua.h luaconf.h lj_def.h \ + lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_state.h lj_frame.h \ + lj_bc.h lj_ctype.h lj_cconv.h lj_ccall.h lj_ccallback.h lj_target.h \ + lj_target_*.h lj_mcode.h lj_jit.h lj_ir.h lj_trace.h lj_dispatch.h \ + lj_traceerr.h lj_vm.h +lj_cconv.o: lj_cconv.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_err.h lj_errmsg.h lj_tab.h lj_ctype.h lj_gc.h lj_cdata.h lj_cconv.h \ + lj_ccallback.h +lj_cdata.o: lj_cdata.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cconv.h \ + lj_cdata.h +lj_char.o: lj_char.c lj_char.h lj_def.h lua.h luaconf.h +lj_clib.o: lj_clib.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_err.h lj_errmsg.h lj_tab.h lj_str.h lj_udata.h lj_ctype.h lj_cconv.h \ + lj_cdata.h lj_clib.h +lj_cparse.o: lj_cparse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_ctype.h lj_cparse.h lj_frame.h \ + lj_bc.h lj_vm.h lj_char.h lj_strscan.h +lj_crecord.o: lj_crecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ctype.h \ + lj_gc.h lj_cdata.h lj_cparse.h lj_cconv.h lj_clib.h lj_ccall.h lj_ff.h \ + lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ + lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_snap.h \ + lj_crecord.h +lj_ctype.o: lj_ctype.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_ccallback.h +lj_debug.o: lj_debug.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_state.h lj_frame.h \ + lj_bc.h lj_vm.h lj_jit.h lj_ir.h +lj_dispatch.o: lj_dispatch.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_err.h lj_errmsg.h lj_func.h lj_str.h lj_tab.h lj_meta.h lj_debug.h \ + lj_state.h lj_frame.h lj_bc.h lj_ff.h lj_ffdef.h lj_jit.h lj_ir.h \ + lj_ccallback.h lj_ctype.h lj_gc.h lj_trace.h lj_dispatch.h lj_traceerr.h \ + lj_vm.h luajit.h +lj_err.o: lj_err.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_err.h \ + lj_errmsg.h lj_debug.h lj_str.h lj_func.h lj_state.h lj_frame.h lj_bc.h \ + lj_ff.h lj_ffdef.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \ + lj_traceerr.h lj_vm.h +lj_ffrecord.o: lj_ffrecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ff.h \ + lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ + lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_crecord.h \ + lj_vm.h lj_strscan.h lj_recdef.h +lj_func.o: lj_func.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_func.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h \ + lj_traceerr.h lj_vm.h +lj_gc.o: lj_gc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_udata.h lj_meta.h \ + lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cdata.h lj_trace.h lj_jit.h \ + lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h +lj_gdbjit.o: lj_gdbjit.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_frame.h lj_bc.h lj_jit.h \ + lj_ir.h lj_dispatch.h +lj_ir.o: lj_ir.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ + lj_dispatch.h lj_bc.h lj_traceerr.h lj_ctype.h lj_cdata.h lj_carith.h \ + lj_vm.h lj_strscan.h lj_lib.h +lj_lex.o: lj_lex.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cdata.h lualib.h \ + lj_state.h lj_lex.h lj_parse.h lj_char.h lj_strscan.h +lj_lib.o: lj_lib.c lauxlib.h lua.h luaconf.h lj_obj.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_bc.h \ + lj_dispatch.h lj_jit.h lj_ir.h lj_vm.h lj_strscan.h lj_lib.h +lj_load.o: lj_load.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \ + lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_func.h lj_frame.h \ + lj_bc.h lj_vm.h lj_lex.h lj_bcdump.h lj_parse.h +lj_mcode.o: lj_mcode.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_jit.h lj_ir.h lj_mcode.h lj_trace.h \ + lj_dispatch.h lj_bc.h lj_traceerr.h lj_vm.h +lj_meta.o: lj_meta.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \ + lj_vm.h lj_strscan.h +lj_obj.o: lj_obj.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h +lj_opt_dce.o: lj_opt_dce.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_ir.h lj_jit.h lj_iropt.h +lj_opt_fold.o: lj_opt_fold.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ + lj_bc.h lj_traceerr.h lj_ctype.h lj_gc.h lj_carith.h lj_vm.h \ + lj_strscan.h lj_folddef.h +lj_opt_loop.o: lj_opt_loop.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h \ + lj_dispatch.h lj_bc.h lj_traceerr.h lj_snap.h lj_vm.h +lj_opt_mem.o: lj_opt_mem.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_tab.h lj_ir.h lj_jit.h lj_iropt.h +lj_opt_narrow.o: lj_opt_narrow.c lj_obj.h lua.h luaconf.h lj_def.h \ + lj_arch.h lj_bc.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ + lj_traceerr.h lj_vm.h lj_strscan.h +lj_opt_sink.o: lj_opt_sink.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_ir.h lj_jit.h lj_iropt.h lj_target.h lj_target_*.h +lj_opt_split.o: lj_opt_split.c lj_obj.h lua.h luaconf.h lj_def.h \ + lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_ircall.h \ + lj_iropt.h lj_vm.h +lj_parse.o: lj_parse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_func.h \ + lj_state.h lj_bc.h lj_ctype.h lj_lex.h lj_parse.h lj_vm.h lj_vmevent.h +lj_record.o: lj_record.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \ + lj_ctype.h lj_gc.h lj_ff.h lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h \ + lj_iropt.h lj_trace.h lj_dispatch.h lj_traceerr.h lj_record.h \ + lj_ffrecord.h lj_snap.h lj_vm.h +lj_snap.o: lj_snap.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_tab.h lj_state.h lj_frame.h lj_bc.h lj_ir.h lj_jit.h lj_iropt.h \ + lj_trace.h lj_dispatch.h lj_traceerr.h lj_snap.h lj_target.h \ + lj_target_*.h lj_ctype.h lj_cdata.h +lj_state.o: lj_state.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_meta.h \ + lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_trace.h lj_jit.h lj_ir.h \ + lj_dispatch.h lj_traceerr.h lj_vm.h lj_lex.h lj_alloc.h +lj_str.o: lj_str.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_err.h lj_errmsg.h lj_str.h lj_state.h lj_char.h +lj_strscan.o: lj_strscan.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_char.h lj_strscan.h +lj_tab.o: lj_tab.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_err.h lj_errmsg.h lj_tab.h +lj_trace.o: lj_trace.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_frame.h lj_bc.h \ + lj_state.h lj_ir.h lj_jit.h lj_iropt.h lj_mcode.h lj_trace.h \ + lj_dispatch.h lj_traceerr.h lj_snap.h lj_gdbjit.h lj_record.h lj_asm.h \ + lj_vm.h lj_vmevent.h lj_target.h lj_target_*.h +lj_udata.o: lj_udata.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_udata.h +lj_vmevent.o: lj_vmevent.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_str.h lj_tab.h lj_state.h lj_dispatch.h lj_bc.h lj_jit.h lj_ir.h \ + lj_vm.h lj_vmevent.h +lj_vmmath.o: lj_vmmath.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_ir.h lj_vm.h +ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_gc.c lj_obj.h lj_def.h \ + lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h \ + lj_udata.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cdata.h \ + lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h lj_err.c \ + lj_debug.h lj_ff.h lj_ffdef.h lj_char.c lj_char.h lj_bc.c lj_bcdef.h \ + lj_obj.c lj_str.c lj_tab.c lj_func.c lj_udata.c lj_meta.c lj_strscan.h \ + lj_debug.c lj_state.c lj_lex.h lj_alloc.h lj_dispatch.c lj_ccallback.h \ + luajit.h lj_vmevent.c lj_vmevent.h lj_vmmath.c lj_strscan.c lj_api.c \ + lj_lex.c lualib.h lj_parse.h lj_parse.c lj_bcread.c lj_bcdump.h \ + lj_bcwrite.c lj_load.c lj_ctype.c lj_cdata.c lj_cconv.h lj_cconv.c \ + lj_ccall.c lj_ccall.h lj_ccallback.c lj_target.h lj_target_*.h \ + lj_mcode.h lj_carith.c lj_carith.h lj_clib.c lj_clib.h lj_cparse.c \ + lj_cparse.h lj_lib.c lj_lib.h lj_ir.c lj_ircall.h lj_iropt.h \ + lj_opt_mem.c lj_opt_fold.c lj_folddef.h lj_opt_narrow.c lj_opt_dce.c \ + lj_opt_loop.c lj_snap.h lj_opt_split.c lj_opt_sink.c lj_mcode.c \ + lj_snap.c lj_record.c lj_record.h lj_ffrecord.h lj_crecord.c \ + lj_crecord.h lj_ffrecord.c lj_recdef.h lj_asm.c lj_asm.h lj_emit_*.h \ + lj_asm_*.h lj_trace.c lj_gdbjit.h lj_gdbjit.c lj_alloc.c lib_aux.c \ + lib_base.c lj_libdef.h lib_math.c lib_string.c lib_table.c lib_io.c \ + lib_os.c lib_package.c lib_debug.c lib_bit.c lib_jit.c lib_ffi.c \ + lib_init.c +luajit.o: luajit.c lua.h luaconf.h lauxlib.h lualib.h luajit.h lj_arch.h +host/buildvm.o: host/buildvm.c host/buildvm.h lj_def.h lua.h luaconf.h \ + lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_gc.h lj_obj.h lj_bc.h lj_ir.h \ + lj_ircall.h lj_ir.h lj_jit.h lj_frame.h lj_bc.h lj_dispatch.h lj_ctype.h \ + lj_gc.h lj_ccall.h lj_ctype.h luajit.h \ + host/buildvm_arch.h lj_traceerr.h +host/buildvm_asm.o: host/buildvm_asm.c host/buildvm.h lj_def.h lua.h luaconf.h \ + lj_arch.h lj_bc.h lj_def.h lj_arch.h +host/buildvm_fold.o: host/buildvm_fold.c host/buildvm.h lj_def.h lua.h \ + luaconf.h lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_ir.h lj_obj.h +host/buildvm_lib.o: host/buildvm_lib.c host/buildvm.h lj_def.h lua.h luaconf.h \ + lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_lib.h lj_obj.h +host/buildvm_peobj.o: host/buildvm_peobj.c host/buildvm.h lj_def.h lua.h \ + luaconf.h lj_arch.h lj_bc.h lj_def.h lj_arch.h +host/minilua.o: host/minilua.c + +``` + +`include/luajit-2.0.5/src/compile.cmd`: + +```cmd +luajit.exe -b script.lua compiled.ljbc + +``` + +`include/luajit-2.0.5/src/host/README`: + +``` +The files in this directory are only used during the build process of LuaJIT. +For cross-compilation, they must be executed on the host, not on the target. + +These files should NOT be installed! + +``` + +`include/luajit-2.0.5/src/host/buildvm.c`: + +```c +/* +** LuaJIT VM builder. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** This is a tool to build the hand-tuned assembler code required for +** LuaJIT's bytecode interpreter. It supports a variety of output formats +** to feed different toolchains (see usage() below). +** +** This tool is not particularly optimized because it's only used while +** _building_ LuaJIT. There's no point in distributing or installing it. +** Only the object code generated by this tool is linked into LuaJIT. +** +** Caveat: some memory is not free'd, error handling is lazy. +** It's a one-shot tool -- any effort fixing this would be wasted. +*/ + +#include "buildvm.h" +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_bc.h" +#include "lj_ir.h" +#include "lj_ircall.h" +#include "lj_frame.h" +#include "lj_dispatch.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#include "lj_ccall.h" +#endif +#include "luajit.h" + +#if defined(_WIN32) +#include +#include +#endif + +/* ------------------------------------------------------------------------ */ + +/* DynASM glue definitions. */ +#define Dst ctx +#define Dst_DECL BuildCtx *ctx +#define Dst_REF (ctx->D) +#define DASM_CHECKS 1 + +#include "../dynasm/dasm_proto.h" + +/* Glue macros for DynASM. */ +static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type); + +#define DASM_EXTERN(ctx, addr, idx, type) \ + collect_reloc(ctx, addr, idx, type) + +/* ------------------------------------------------------------------------ */ + +/* Avoid trouble if cross-compiling for an x86 target. Speed doesn't matter. */ +#define DASM_ALIGNED_WRITES 1 + +/* Embed architecture-specific DynASM encoder. */ +#if LJ_TARGET_X86ORX64 +#include "../dynasm/dasm_x86.h" +#elif LJ_TARGET_ARM +#include "../dynasm/dasm_arm.h" +#elif LJ_TARGET_PPC +#include "../dynasm/dasm_ppc.h" +#elif LJ_TARGET_PPCSPE +#include "../dynasm/dasm_ppc.h" +#elif LJ_TARGET_MIPS +#include "../dynasm/dasm_mips.h" +#else +#error "No support for this architecture (yet)" +#endif + +/* Embed generated architecture-specific backend. */ +#include "buildvm_arch.h" + +/* ------------------------------------------------------------------------ */ + +void owrite(BuildCtx *ctx, const void *ptr, size_t sz) +{ + if (fwrite(ptr, 1, sz, ctx->fp) != sz) { + fprintf(stderr, "Error: cannot write to output file: %s\n", + strerror(errno)); + exit(1); + } +} + +/* ------------------------------------------------------------------------ */ + +/* Emit code as raw bytes. Only used for DynASM debugging. */ +static void emit_raw(BuildCtx *ctx) +{ + owrite(ctx, ctx->code, ctx->codesz); +} + +/* -- Build machine code -------------------------------------------------- */ + +static const char *sym_decorate(BuildCtx *ctx, + const char *prefix, const char *suffix) +{ + char name[256]; + char *p; +#if LJ_64 + const char *symprefix = ctx->mode == BUILD_machasm ? "_" : ""; +#elif LJ_TARGET_XBOX360 + const char *symprefix = ""; +#else + const char *symprefix = ctx->mode != BUILD_elfasm ? "_" : ""; +#endif + sprintf(name, "%s%s%s", symprefix, prefix, suffix); + p = strchr(name, '@'); + if (p) { +#if LJ_TARGET_X86ORX64 + if (!LJ_64 && (ctx->mode == BUILD_coffasm || ctx->mode == BUILD_peobj)) + name[0] = '@'; + else + *p = '\0'; +#elif (LJ_TARGET_PPC || LJ_TARGET_PPCSPE) && !LJ_TARGET_CONSOLE + /* Keep @plt. */ +#else + *p = '\0'; +#endif + } + p = (char *)malloc(strlen(name)+1); /* MSVC doesn't like strdup. */ + strcpy(p, name); + return p; +} + +#define NRELOCSYM (sizeof(extnames)/sizeof(extnames[0])-1) + +static int relocmap[NRELOCSYM]; + +/* Collect external relocations. */ +static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type) +{ + if (ctx->nreloc >= BUILD_MAX_RELOC) { + fprintf(stderr, "Error: too many relocations, increase BUILD_MAX_RELOC.\n"); + exit(1); + } + if (relocmap[idx] < 0) { + relocmap[idx] = ctx->nrelocsym; + ctx->relocsym[ctx->nrelocsym] = sym_decorate(ctx, "", extnames[idx]); + ctx->nrelocsym++; + } + ctx->reloc[ctx->nreloc].ofs = (int32_t)(addr - ctx->code); + ctx->reloc[ctx->nreloc].sym = relocmap[idx]; + ctx->reloc[ctx->nreloc].type = type; + ctx->nreloc++; +#if LJ_TARGET_XBOX360 + return (int)(ctx->code - addr) + 4; /* Encode symbol offset of .text. */ +#else + return 0; /* Encode symbol offset of 0. */ +#endif +} + +/* Naive insertion sort. Performance doesn't matter here. */ +static void sym_insert(BuildCtx *ctx, int32_t ofs, + const char *prefix, const char *suffix) +{ + ptrdiff_t i = ctx->nsym++; + while (i > 0) { + if (ctx->sym[i-1].ofs <= ofs) + break; + ctx->sym[i] = ctx->sym[i-1]; + i--; + } + ctx->sym[i].ofs = ofs; + ctx->sym[i].name = sym_decorate(ctx, prefix, suffix); +} + +/* Build the machine code. */ +static int build_code(BuildCtx *ctx) +{ + int status; + int i; + + /* Initialize DynASM structures. */ + ctx->nglob = GLOB__MAX; + ctx->glob = (void **)malloc(ctx->nglob*sizeof(void *)); + memset(ctx->glob, 0, ctx->nglob*sizeof(void *)); + ctx->nreloc = 0; + + ctx->globnames = globnames; + ctx->relocsym = (const char **)malloc(NRELOCSYM*sizeof(const char *)); + ctx->nrelocsym = 0; + for (i = 0; i < (int)NRELOCSYM; i++) relocmap[i] = -1; + + ctx->dasm_ident = DASM_IDENT; + ctx->dasm_arch = DASM_ARCH; + + dasm_init(Dst, DASM_MAXSECTION); + dasm_setupglobal(Dst, ctx->glob, ctx->nglob); + dasm_setup(Dst, build_actionlist); + + /* Call arch-specific backend to emit the code. */ + ctx->npc = build_backend(ctx); + + /* Finalize the code. */ + (void)dasm_checkstep(Dst, -1); + if ((status = dasm_link(Dst, &ctx->codesz))) return status; + ctx->code = (uint8_t *)malloc(ctx->codesz); + if ((status = dasm_encode(Dst, (void *)ctx->code))) return status; + + /* Allocate symbol table and bytecode offsets. */ + ctx->beginsym = sym_decorate(ctx, "", LABEL_PREFIX "vm_asm_begin"); + ctx->sym = (BuildSym *)malloc((ctx->npc+ctx->nglob+1)*sizeof(BuildSym)); + ctx->nsym = 0; + ctx->bc_ofs = (int32_t *)malloc(ctx->npc*sizeof(int32_t)); + + /* Collect the opcodes (PC labels). */ + for (i = 0; i < ctx->npc; i++) { + int32_t ofs = dasm_getpclabel(Dst, i); + if (ofs < 0) return 0x22000000|i; + ctx->bc_ofs[i] = ofs; + if ((LJ_HASJIT || + !(i == BC_JFORI || i == BC_JFORL || i == BC_JITERL || i == BC_JLOOP || + i == BC_IFORL || i == BC_IITERL || i == BC_ILOOP)) && + (LJ_HASFFI || i != BC_KCDATA)) + sym_insert(ctx, ofs, LABEL_PREFIX_BC, bc_names[i]); + } + + /* Collect the globals (named labels). */ + for (i = 0; i < ctx->nglob; i++) { + const char *gl = globnames[i]; + int len = (int)strlen(gl); + if (!ctx->glob[i]) { + fprintf(stderr, "Error: undefined global %s\n", gl); + exit(2); + } + /* Skip the _Z symbols. */ + if (!(len >= 2 && gl[len-2] == '_' && gl[len-1] == 'Z')) + sym_insert(ctx, (int32_t)((uint8_t *)(ctx->glob[i]) - ctx->code), + LABEL_PREFIX, globnames[i]); + } + + /* Close the address range. */ + sym_insert(ctx, (int32_t)ctx->codesz, "", ""); + ctx->nsym--; + + dasm_free(Dst); + + return 0; +} + +/* -- Generate VM enums --------------------------------------------------- */ + +const char *const bc_names[] = { +#define BCNAME(name, ma, mb, mc, mt) #name, +BCDEF(BCNAME) +#undef BCNAME + NULL +}; + +const char *const ir_names[] = { +#define IRNAME(name, m, m1, m2) #name, +IRDEF(IRNAME) +#undef IRNAME + NULL +}; + +const char *const irt_names[] = { +#define IRTNAME(name, size) #name, +IRTDEF(IRTNAME) +#undef IRTNAME + NULL +}; + +const char *const irfpm_names[] = { +#define FPMNAME(name) #name, +IRFPMDEF(FPMNAME) +#undef FPMNAME + NULL +}; + +const char *const irfield_names[] = { +#define FLNAME(name, ofs) #name, +IRFLDEF(FLNAME) +#undef FLNAME + NULL +}; + +const char *const ircall_names[] = { +#define IRCALLNAME(cond, name, nargs, kind, type, flags) #name, +IRCALLDEF(IRCALLNAME) +#undef IRCALLNAME + NULL +}; + +static const char *const trace_errors[] = { +#define TREDEF(name, msg) msg, +#include "lj_traceerr.h" + NULL +}; + +static const char *lower(char *buf, const char *s) +{ + char *p = buf; + while (*s) { + *p++ = (*s >= 'A' && *s <= 'Z') ? *s+0x20 : *s; + s++; + } + *p = '\0'; + return buf; +} + +/* Emit C source code for bytecode-related definitions. */ +static void emit_bcdef(BuildCtx *ctx) +{ + int i; + fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n"); + fprintf(ctx->fp, "LJ_DATADEF const uint16_t lj_bc_ofs[] = {\n"); + for (i = 0; i < ctx->npc; i++) { + if (i != 0) + fprintf(ctx->fp, ",\n"); + fprintf(ctx->fp, "%d", ctx->bc_ofs[i]); + } +} + +/* Emit VM definitions as Lua code for debug modules. */ +static void emit_vmdef(BuildCtx *ctx) +{ + char buf[80]; + int i; + fprintf(ctx->fp, "-- This is a generated file. DO NOT EDIT!\n\n"); + fprintf(ctx->fp, "module(...)\n\n"); + + fprintf(ctx->fp, "bcnames = \""); + for (i = 0; bc_names[i]; i++) fprintf(ctx->fp, "%-6s", bc_names[i]); + fprintf(ctx->fp, "\"\n\n"); + + fprintf(ctx->fp, "irnames = \""); + for (i = 0; ir_names[i]; i++) fprintf(ctx->fp, "%-6s", ir_names[i]); + fprintf(ctx->fp, "\"\n\n"); + + fprintf(ctx->fp, "irfpm = { [0]="); + for (i = 0; irfpm_names[i]; i++) + fprintf(ctx->fp, "\"%s\", ", lower(buf, irfpm_names[i])); + fprintf(ctx->fp, "}\n\n"); + + fprintf(ctx->fp, "irfield = { [0]="); + for (i = 0; irfield_names[i]; i++) { + char *p; + lower(buf, irfield_names[i]); + p = strchr(buf, '_'); + if (p) *p = '.'; + fprintf(ctx->fp, "\"%s\", ", buf); + } + fprintf(ctx->fp, "}\n\n"); + + fprintf(ctx->fp, "ircall = {\n[0]="); + for (i = 0; ircall_names[i]; i++) + fprintf(ctx->fp, "\"%s\",\n", ircall_names[i]); + fprintf(ctx->fp, "}\n\n"); + + fprintf(ctx->fp, "traceerr = {\n[0]="); + for (i = 0; trace_errors[i]; i++) + fprintf(ctx->fp, "\"%s\",\n", trace_errors[i]); + fprintf(ctx->fp, "}\n\n"); +} + +/* -- Argument parsing ---------------------------------------------------- */ + +/* Build mode names. */ +static const char *const modenames[] = { +#define BUILDNAME(name) #name, +BUILDDEF(BUILDNAME) +#undef BUILDNAME + NULL +}; + +/* Print usage information and exit. */ +static void usage(void) +{ + int i; + fprintf(stderr, LUAJIT_VERSION " VM builder.\n"); + fprintf(stderr, LUAJIT_COPYRIGHT ", " LUAJIT_URL "\n"); + fprintf(stderr, "Target architecture: " LJ_ARCH_NAME "\n\n"); + fprintf(stderr, "Usage: buildvm -m mode [-o outfile] [infiles...]\n\n"); + fprintf(stderr, "Available modes:\n"); + for (i = 0; i < BUILD__MAX; i++) + fprintf(stderr, " %s\n", modenames[i]); + exit(1); +} + +/* Parse the output mode name. */ +static BuildMode parsemode(const char *mode) +{ + int i; + for (i = 0; modenames[i]; i++) + if (!strcmp(mode, modenames[i])) + return (BuildMode)i; + usage(); + return (BuildMode)-1; +} + +/* Parse arguments. */ +static void parseargs(BuildCtx *ctx, char **argv) +{ + const char *a; + int i; + ctx->mode = (BuildMode)-1; + ctx->outname = "-"; + for (i = 1; (a = argv[i]) != NULL; i++) { + if (a[0] != '-') + break; + switch (a[1]) { + case '-': + if (a[2]) goto err; + i++; + goto ok; + case '\0': + goto ok; + case 'm': + i++; + if (a[2] || argv[i] == NULL) goto err; + ctx->mode = parsemode(argv[i]); + break; + case 'o': + i++; + if (a[2] || argv[i] == NULL) goto err; + ctx->outname = argv[i]; + break; + default: err: + usage(); + break; + } + } +ok: + ctx->args = argv+i; + if (ctx->mode == (BuildMode)-1) goto err; +} + +int main(int argc, char **argv) +{ + BuildCtx ctx_; + BuildCtx *ctx = &ctx_; + int status, binmode; + + if (sizeof(void *) != 4*LJ_32+8*LJ_64) { + fprintf(stderr,"Error: pointer size mismatch in cross-build.\n"); + fprintf(stderr,"Try: make HOST_CC=\"gcc -m32\" CROSS=...\n\n"); + return 1; + } + + UNUSED(argc); + parseargs(ctx, argv); + + if ((status = build_code(ctx))) { + fprintf(stderr,"Error: DASM error %08x\n", status); + return 1; + } + + switch (ctx->mode) { + case BUILD_peobj: + case BUILD_raw: + binmode = 1; + break; + default: + binmode = 0; + break; + } + + if (ctx->outname[0] == '-' && ctx->outname[1] == '\0') { + ctx->fp = stdout; +#if defined(_WIN32) + if (binmode) + _setmode(_fileno(stdout), _O_BINARY); /* Yuck. */ +#endif + } else if (!(ctx->fp = fopen(ctx->outname, binmode ? "wb" : "w"))) { + fprintf(stderr, "Error: cannot open output file '%s': %s\n", + ctx->outname, strerror(errno)); + exit(1); + } + + switch (ctx->mode) { + case BUILD_elfasm: + case BUILD_coffasm: + case BUILD_machasm: + emit_asm(ctx); + emit_asm_debug(ctx); + break; + case BUILD_peobj: + emit_peobj(ctx); + break; + case BUILD_raw: + emit_raw(ctx); + break; + case BUILD_bcdef: + emit_bcdef(ctx); + emit_lib(ctx); + break; + case BUILD_vmdef: + emit_vmdef(ctx); + emit_lib(ctx); + break; + case BUILD_ffdef: + case BUILD_libdef: + case BUILD_recdef: + emit_lib(ctx); + break; + case BUILD_folddef: + emit_fold(ctx); + break; + default: + break; + } + + fflush(ctx->fp); + if (ferror(ctx->fp)) { + fprintf(stderr, "Error: cannot write to output file: %s\n", + strerror(errno)); + exit(1); + } + fclose(ctx->fp); + + return 0; +} + + +``` + +`include/luajit-2.0.5/src/host/buildvm.h`: + +```h +/* +** LuaJIT VM builder. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _BUILDVM_H +#define _BUILDVM_H + +#include +#include +#include +#include +#include + +#include "lj_def.h" +#include "lj_arch.h" + +/* Hardcoded limits. Increase as needed. */ +#define BUILD_MAX_RELOC 200 /* Max. number of relocations. */ +#define BUILD_MAX_FOLD 4096 /* Max. number of fold rules. */ + +/* Prefix for scanned library definitions. */ +#define LIBDEF_PREFIX "LJLIB_" + +/* Prefix for scanned fold definitions. */ +#define FOLDDEF_PREFIX "LJFOLD" + +/* Prefixes for generated labels. */ +#define LABEL_PREFIX "lj_" +#define LABEL_PREFIX_BC LABEL_PREFIX "BC_" +#define LABEL_PREFIX_FF LABEL_PREFIX "ff_" +#define LABEL_PREFIX_CF LABEL_PREFIX "cf_" +#define LABEL_PREFIX_FFH LABEL_PREFIX "ffh_" +#define LABEL_PREFIX_LIBCF LABEL_PREFIX "lib_cf_" +#define LABEL_PREFIX_LIBINIT LABEL_PREFIX "lib_init_" + +/* Forward declaration. */ +struct dasm_State; + +/* Build modes. */ +#define BUILDDEF(_) \ + _(elfasm) _(coffasm) _(machasm) _(peobj) _(raw) \ + _(bcdef) _(ffdef) _(libdef) _(recdef) _(vmdef) \ + _(folddef) + +typedef enum { +#define BUILDENUM(name) BUILD_##name, +BUILDDEF(BUILDENUM) +#undef BUILDENUM + BUILD__MAX +} BuildMode; + +/* Code relocation. */ +typedef struct BuildReloc { + int32_t ofs; + int sym; + int type; +} BuildReloc; + +typedef struct BuildSym { + const char *name; + int32_t ofs; +} BuildSym; + +/* Build context structure. */ +typedef struct BuildCtx { + /* DynASM state pointer. Should be first member. */ + struct dasm_State *D; + /* Parsed command line. */ + BuildMode mode; + FILE *fp; + const char *outname; + char **args; + /* Code and symbols generated by DynASM. */ + uint8_t *code; + size_t codesz; + int npc, nglob, nsym, nreloc, nrelocsym; + void **glob; + BuildSym *sym; + const char **relocsym; + int32_t *bc_ofs; + const char *beginsym; + /* Strings generated by DynASM. */ + const char *const *globnames; + const char *dasm_ident; + const char *dasm_arch; + /* Relocations. */ + BuildReloc reloc[BUILD_MAX_RELOC]; +} BuildCtx; + +extern void owrite(BuildCtx *ctx, const void *ptr, size_t sz); +extern void emit_asm(BuildCtx *ctx); +extern void emit_peobj(BuildCtx *ctx); +extern void emit_lib(BuildCtx *ctx); +extern void emit_fold(BuildCtx *ctx); + +extern const char *const bc_names[]; +extern const char *const ir_names[]; +extern const char *const irt_names[]; +extern const char *const irfpm_names[]; +extern const char *const irfield_names[]; +extern const char *const ircall_names[]; + +#endif + +``` + +`include/luajit-2.0.5/src/host/buildvm_asm.c`: + +```c +/* +** LuaJIT VM builder: Assembler source code emitter. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "buildvm.h" +#include "lj_bc.h" + +/* ------------------------------------------------------------------------ */ + +#if LJ_TARGET_X86ORX64 +/* Emit bytes piecewise as assembler text. */ +static void emit_asm_bytes(BuildCtx *ctx, uint8_t *p, int n) +{ + int i; + for (i = 0; i < n; i++) { + if ((i & 15) == 0) + fprintf(ctx->fp, "\t.byte %d", p[i]); + else + fprintf(ctx->fp, ",%d", p[i]); + if ((i & 15) == 15) putc('\n', ctx->fp); + } + if ((n & 15) != 0) putc('\n', ctx->fp); +} + +/* Emit relocation */ +static void emit_asm_reloc(BuildCtx *ctx, int type, const char *sym) +{ + switch (ctx->mode) { + case BUILD_elfasm: + if (type) + fprintf(ctx->fp, "\t.long %s-.-4\n", sym); + else + fprintf(ctx->fp, "\t.long %s\n", sym); + break; + case BUILD_coffasm: + fprintf(ctx->fp, "\t.def %s; .scl 3; .type 32; .endef\n", sym); + if (type) + fprintf(ctx->fp, "\t.long %s-.-4\n", sym); + else + fprintf(ctx->fp, "\t.long %s\n", sym); + break; + default: /* BUILD_machasm for relative relocations handled below. */ + fprintf(ctx->fp, "\t.long %s\n", sym); + break; + } +} + +static const char *const jccnames[] = { + "jo", "jno", "jb", "jnb", "jz", "jnz", "jbe", "ja", + "js", "jns", "jpe", "jpo", "jl", "jge", "jle", "jg" +}; + +/* Emit relocation for the incredibly stupid OSX assembler. */ +static void emit_asm_reloc_mach(BuildCtx *ctx, uint8_t *cp, int n, + const char *sym) +{ + const char *opname = NULL; + if (--n < 0) goto err; + if (cp[n] == 0xe8) { + opname = "call"; + } else if (cp[n] == 0xe9) { + opname = "jmp"; + } else if (cp[n] >= 0x80 && cp[n] <= 0x8f && n > 0 && cp[n-1] == 0x0f) { + opname = jccnames[cp[n]-0x80]; + n--; + } else { +err: + fprintf(stderr, "Error: unsupported opcode for %s symbol relocation.\n", + sym); + exit(1); + } + emit_asm_bytes(ctx, cp, n); + fprintf(ctx->fp, "\t%s %s\n", opname, sym); +} +#else +/* Emit words piecewise as assembler text. */ +static void emit_asm_words(BuildCtx *ctx, uint8_t *p, int n) +{ + int i; + for (i = 0; i < n; i += 4) { + if ((i & 15) == 0) + fprintf(ctx->fp, "\t.long 0x%08x", *(uint32_t *)(p+i)); + else + fprintf(ctx->fp, ",0x%08x", *(uint32_t *)(p+i)); + if ((i & 15) == 12) putc('\n', ctx->fp); + } + if ((n & 15) != 0) putc('\n', ctx->fp); +} + +/* Emit relocation as part of an instruction. */ +static void emit_asm_wordreloc(BuildCtx *ctx, uint8_t *p, int n, + const char *sym) +{ + uint32_t ins; + emit_asm_words(ctx, p, n-4); + ins = *(uint32_t *)(p+n-4); +#if LJ_TARGET_ARM + if ((ins & 0xff000000u) == 0xfa000000u) { + fprintf(ctx->fp, "\tblx %s\n", sym); + } else if ((ins & 0x0e000000u) == 0x0a000000u) { + fprintf(ctx->fp, "\t%s%.2s %s\n", (ins & 0x01000000u) ? "bl" : "b", + &"eqnecsccmiplvsvchilsgeltgtle"[2*(ins >> 28)], sym); + } else { + fprintf(stderr, + "Error: unsupported opcode %08x for %s symbol relocation.\n", + ins, sym); + exit(1); + } +#elif LJ_TARGET_PPC || LJ_TARGET_PPCSPE +#if LJ_TARGET_PS3 +#define TOCPREFIX "." +#else +#define TOCPREFIX "" +#endif + if ((ins >> 26) == 16) { + fprintf(ctx->fp, "\t%s %d, %d, " TOCPREFIX "%s\n", + (ins & 1) ? "bcl" : "bc", (ins >> 21) & 31, (ins >> 16) & 31, sym); + } else if ((ins >> 26) == 18) { + fprintf(ctx->fp, "\t%s " TOCPREFIX "%s\n", (ins & 1) ? "bl" : "b", sym); + } else { + fprintf(stderr, + "Error: unsupported opcode %08x for %s symbol relocation.\n", + ins, sym); + exit(1); + } +#elif LJ_TARGET_MIPS + fprintf(stderr, + "Error: unsupported opcode %08x for %s symbol relocation.\n", + ins, sym); + exit(1); +#else +#error "missing relocation support for this architecture" +#endif +} +#endif + +#if LJ_TARGET_ARM +#define ELFASM_PX "%%" +#else +#define ELFASM_PX "@" +#endif + +/* Emit an assembler label. */ +static void emit_asm_label(BuildCtx *ctx, const char *name, int size, int isfunc) +{ + switch (ctx->mode) { + case BUILD_elfasm: +#if LJ_TARGET_PS3 + if (!strncmp(name, "lj_vm_", 6) && + strcmp(name, ctx->beginsym) && + !strstr(name, "hook")) { + fprintf(ctx->fp, + "\n\t.globl %s\n" + "\t.section \".opd\",\"aw\"\n" + "%s:\n" + "\t.long .%s,.TOC.@tocbase32\n" + "\t.size %s,8\n" + "\t.previous\n" + "\t.globl .%s\n" + "\t.hidden .%s\n" + "\t.type .%s, " ELFASM_PX "function\n" + "\t.size .%s, %d\n" + ".%s:\n", + name, name, name, name, name, name, name, name, size, name); + break; + } +#endif + fprintf(ctx->fp, + "\n\t.globl %s\n" + "\t.hidden %s\n" + "\t.type %s, " ELFASM_PX "%s\n" + "\t.size %s, %d\n" + "%s:\n", + name, name, name, isfunc ? "function" : "object", name, size, name); + break; + case BUILD_coffasm: + fprintf(ctx->fp, "\n\t.globl %s\n", name); + if (isfunc) + fprintf(ctx->fp, "\t.def %s; .scl 3; .type 32; .endef\n", name); + fprintf(ctx->fp, "%s:\n", name); + break; + case BUILD_machasm: + fprintf(ctx->fp, + "\n\t.private_extern %s\n" + "\t.no_dead_strip %s\n" + "%s:\n", name, name, name); + break; + default: + break; + } +} + +/* Emit alignment. */ +static void emit_asm_align(BuildCtx *ctx, int bits) +{ + switch (ctx->mode) { + case BUILD_elfasm: + case BUILD_coffasm: + fprintf(ctx->fp, "\t.p2align %d\n", bits); + break; + case BUILD_machasm: + fprintf(ctx->fp, "\t.align %d\n", bits); + break; + default: + break; + } +} + +/* ------------------------------------------------------------------------ */ + +/* Emit assembler source code. */ +void emit_asm(BuildCtx *ctx) +{ + int i, rel; + + fprintf(ctx->fp, "\t.file \"buildvm_%s.dasc\"\n", ctx->dasm_arch); + fprintf(ctx->fp, "\t.text\n"); + emit_asm_align(ctx, 4); + +#if LJ_TARGET_PS3 + emit_asm_label(ctx, ctx->beginsym, ctx->codesz, 0); +#else + emit_asm_label(ctx, ctx->beginsym, 0, 0); +#endif + if (ctx->mode != BUILD_machasm) + fprintf(ctx->fp, ".Lbegin:\n"); + +#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND + /* This should really be moved into buildvm_arm.dasc. */ + fprintf(ctx->fp, + ".fnstart\n" + ".save {r4, r5, r6, r7, r8, r9, r10, r11, lr}\n" + ".pad #28\n"); +#endif +#if LJ_TARGET_MIPS + fprintf(ctx->fp, ".set nomips16\n.abicalls\n.set noreorder\n.set nomacro\n"); +#endif + + for (i = rel = 0; i < ctx->nsym; i++) { + int32_t ofs = ctx->sym[i].ofs; + int32_t next = ctx->sym[i+1].ofs; +#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND && LJ_HASFFI + if (!strcmp(ctx->sym[i].name, "lj_vm_ffi_call")) + fprintf(ctx->fp, + ".globl lj_err_unwind_arm\n" + ".personality lj_err_unwind_arm\n" + ".fnend\n" + ".fnstart\n" + ".save {r4, r5, r11, lr}\n" + ".setfp r11, sp\n"); +#endif + emit_asm_label(ctx, ctx->sym[i].name, next - ofs, 1); + while (rel < ctx->nreloc && ctx->reloc[rel].ofs <= next) { + BuildReloc *r = &ctx->reloc[rel]; + int n = r->ofs - ofs; +#if LJ_TARGET_X86ORX64 + if (ctx->mode == BUILD_machasm && r->type != 0) { + emit_asm_reloc_mach(ctx, ctx->code+ofs, n, ctx->relocsym[r->sym]); + } else { + emit_asm_bytes(ctx, ctx->code+ofs, n); + emit_asm_reloc(ctx, r->type, ctx->relocsym[r->sym]); + } + ofs += n+4; +#else + emit_asm_wordreloc(ctx, ctx->code+ofs, n, ctx->relocsym[r->sym]); + ofs += n; +#endif + rel++; + } +#if LJ_TARGET_X86ORX64 + emit_asm_bytes(ctx, ctx->code+ofs, next-ofs); +#else + emit_asm_words(ctx, ctx->code+ofs, next-ofs); +#endif + } + +#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND + fprintf(ctx->fp, +#if !LJ_HASFFI + ".globl lj_err_unwind_arm\n" + ".personality lj_err_unwind_arm\n" +#endif + ".fnend\n"); +#endif + + fprintf(ctx->fp, "\n"); + switch (ctx->mode) { + case BUILD_elfasm: +#if !(LJ_TARGET_PS3 || LJ_TARGET_PSVITA) + fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\"," ELFASM_PX "progbits\n"); +#endif +#if LJ_TARGET_PPCSPE + /* Soft-float ABI + SPE. */ + fprintf(ctx->fp, "\t.gnu_attribute 4, 2\n\t.gnu_attribute 8, 3\n"); +#elif LJ_TARGET_PPC && !LJ_TARGET_PS3 + /* Hard-float ABI. */ + fprintf(ctx->fp, "\t.gnu_attribute 4, 1\n"); +#endif + /* fallthrough */ + case BUILD_coffasm: + fprintf(ctx->fp, "\t.ident \"%s\"\n", ctx->dasm_ident); + break; + case BUILD_machasm: + fprintf(ctx->fp, + "\t.cstring\n" + "\t.ascii \"%s\\0\"\n", ctx->dasm_ident); + break; + default: + break; + } + fprintf(ctx->fp, "\n"); +} + + +``` + +`include/luajit-2.0.5/src/host/buildvm_fold.c`: + +```c +/* +** LuaJIT VM builder: IR folding hash table generator. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "buildvm.h" +#include "lj_obj.h" +#include "lj_ir.h" + +/* Context for the folding hash table generator. */ +static int lineno; +static uint32_t funcidx; +static uint32_t foldkeys[BUILD_MAX_FOLD]; +static uint32_t nkeys; + +/* Try to fill the hash table with keys using the hash parameters. */ +static int tryhash(uint32_t *htab, uint32_t sz, uint32_t r, int dorol) +{ + uint32_t i; + if (dorol && ((r & 31) == 0 || (r>>5) == 0)) + return 0; /* Avoid zero rotates. */ + memset(htab, 0xff, (sz+1)*sizeof(uint32_t)); + for (i = 0; i < nkeys; i++) { + uint32_t key = foldkeys[i]; + uint32_t k = key & 0xffffff; + uint32_t h = (dorol ? lj_rol(lj_rol(k, r>>5) - k, r&31) : + (((k << (r>>5)) - k) << (r&31))) % sz; + if (htab[h] != 0xffffffff) { /* Collision on primary slot. */ + if (htab[h+1] != 0xffffffff) { /* Collision on secondary slot. */ + /* Try to move the colliding key, if possible. */ + if (h < sz-1 && htab[h+2] == 0xffffffff) { + uint32_t k2 = htab[h+1] & 0xffffff; + uint32_t h2 = (dorol ? lj_rol(lj_rol(k2, r>>5) - k2, r&31) : + (((k2 << (r>>5)) - k2) << (r&31))) % sz; + if (h2 != h+1) return 0; /* Cannot resolve collision. */ + htab[h+2] = htab[h+1]; /* Move colliding key to secondary slot. */ + } else { + return 0; /* Collision. */ + } + } + htab[h+1] = key; + } else { + htab[h] = key; + } + } + return 1; /* Success, all keys could be stored. */ +} + +/* Print the generated hash table. */ +static void printhash(BuildCtx *ctx, uint32_t *htab, uint32_t sz) +{ + uint32_t i; + fprintf(ctx->fp, "static const uint32_t fold_hash[%d] = {\n0x%08x", + sz+1, htab[0]); + for (i = 1; i < sz+1; i++) + fprintf(ctx->fp, ",\n0x%08x", htab[i]); + fprintf(ctx->fp, "\n};\n\n"); +} + +/* Exhaustive search for the shortest semi-perfect hash table. */ +static void makehash(BuildCtx *ctx) +{ + uint32_t htab[BUILD_MAX_FOLD*2+1]; + uint32_t sz, r; + /* Search for the smallest hash table with an odd size. */ + for (sz = (nkeys|1); sz < BUILD_MAX_FOLD*2; sz += 2) { + /* First try all shift hash combinations. */ + for (r = 0; r < 32*32; r++) { + if (tryhash(htab, sz, r, 0)) { + printhash(ctx, htab, sz); + fprintf(ctx->fp, + "#define fold_hashkey(k)\t(((((k)<<%u)-(k))<<%u)%%%u)\n\n", + r>>5, r&31, sz); + return; + } + } + /* Then try all rotate hash combinations. */ + for (r = 0; r < 32*32; r++) { + if (tryhash(htab, sz, r, 1)) { + printhash(ctx, htab, sz); + fprintf(ctx->fp, + "#define fold_hashkey(k)\t(lj_rol(lj_rol((k),%u)-(k),%u)%%%u)\n\n", + r>>5, r&31, sz); + return; + } + } + } + fprintf(stderr, "Error: search for perfect hash failed\n"); + exit(1); +} + +/* Parse one token of a fold rule. */ +static uint32_t nexttoken(char **pp, int allowlit, int allowany) +{ + char *p = *pp; + if (p) { + uint32_t i; + char *q = strchr(p, ' '); + if (q) *q++ = '\0'; + *pp = q; + if (allowlit && !strncmp(p, "IRFPM_", 6)) { + for (i = 0; irfpm_names[i]; i++) + if (!strcmp(irfpm_names[i], p+6)) + return i; + } else if (allowlit && !strncmp(p, "IRFL_", 5)) { + for (i = 0; irfield_names[i]; i++) + if (!strcmp(irfield_names[i], p+5)) + return i; + } else if (allowlit && !strncmp(p, "IRCALL_", 7)) { + for (i = 0; ircall_names[i]; i++) + if (!strcmp(ircall_names[i], p+7)) + return i; + } else if (allowlit && !strncmp(p, "IRCONV_", 7)) { + for (i = 0; irt_names[i]; i++) { + const char *r = strchr(p+7, '_'); + if (r && !strncmp(irt_names[i], p+7, r-(p+7))) { + uint32_t j; + for (j = 0; irt_names[j]; j++) + if (!strcmp(irt_names[j], r+1)) + return (i << 5) + j; + } + } + } else if (allowlit && *p >= '0' && *p <= '9') { + for (i = 0; *p >= '0' && *p <= '9'; p++) + i = i*10 + (*p - '0'); + if (*p == '\0') + return i; + } else if (allowany && !strcmp("any", p)) { + return allowany; + } else { + for (i = 0; ir_names[i]; i++) + if (!strcmp(ir_names[i], p)) + return i; + } + fprintf(stderr, "Error: bad fold definition token \"%s\" at line %d\n", p, lineno); + exit(1); + } + return 0; +} + +/* Parse a fold rule. */ +static void foldrule(char *p) +{ + uint32_t op = nexttoken(&p, 0, 0); + uint32_t left = nexttoken(&p, 0, 0x7f); + uint32_t right = nexttoken(&p, 1, 0x3ff); + uint32_t key = (funcidx << 24) | (op << 17) | (left << 10) | right; + uint32_t i; + if (nkeys >= BUILD_MAX_FOLD) { + fprintf(stderr, "Error: too many fold rules, increase BUILD_MAX_FOLD.\n"); + exit(1); + } + /* Simple insertion sort to detect duplicates. */ + for (i = nkeys; i > 0; i--) { + if ((foldkeys[i-1]&0xffffff) < (key & 0xffffff)) + break; + if ((foldkeys[i-1]&0xffffff) == (key & 0xffffff)) { + fprintf(stderr, "Error: duplicate fold definition at line %d\n", lineno); + exit(1); + } + foldkeys[i] = foldkeys[i-1]; + } + foldkeys[i] = key; + nkeys++; +} + +/* Emit C source code for IR folding hash table. */ +void emit_fold(BuildCtx *ctx) +{ + char buf[256]; /* We don't care about analyzing lines longer than that. */ + const char *fname = ctx->args[0]; + FILE *fp; + + if (fname == NULL) { + fprintf(stderr, "Error: missing input filename\n"); + exit(1); + } + + if (fname[0] == '-' && fname[1] == '\0') { + fp = stdin; + } else { + fp = fopen(fname, "r"); + if (!fp) { + fprintf(stderr, "Error: cannot open input file '%s': %s\n", + fname, strerror(errno)); + exit(1); + } + } + + fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n"); + fprintf(ctx->fp, "static const FoldFunc fold_func[] = {\n"); + + lineno = 0; + funcidx = 0; + nkeys = 0; + while (fgets(buf, sizeof(buf), fp) != NULL) { + lineno++; + /* The prefix must be at the start of a line, otherwise it's ignored. */ + if (!strncmp(buf, FOLDDEF_PREFIX, sizeof(FOLDDEF_PREFIX)-1)) { + char *p = buf+sizeof(FOLDDEF_PREFIX)-1; + char *q = strchr(p, ')'); + if (p[0] == '(' && q) { + p++; + *q = '\0'; + foldrule(p); + } else if ((p[0] == 'F' || p[0] == 'X') && p[1] == '(' && q) { + p += 2; + *q = '\0'; + if (funcidx) + fprintf(ctx->fp, ",\n"); + if (p[-2] == 'X') + fprintf(ctx->fp, " %s", p); + else + fprintf(ctx->fp, " fold_%s", p); + funcidx++; + } else { + buf[strlen(buf)-1] = '\0'; + fprintf(stderr, "Error: unknown fold definition tag %s%s at line %d\n", + FOLDDEF_PREFIX, p, lineno); + exit(1); + } + } + } + fclose(fp); + fprintf(ctx->fp, "\n};\n\n"); + + makehash(ctx); +} + + +``` + +`include/luajit-2.0.5/src/host/buildvm_lib.c`: + +```c +/* +** LuaJIT VM builder: library definition compiler. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "buildvm.h" +#include "lj_obj.h" +#include "lj_lib.h" + +/* Context for library definitions. */ +static uint8_t obuf[8192]; +static uint8_t *optr; +static char modname[80]; +static size_t modnamelen; +static char funcname[80]; +static int modstate, regfunc; +static int ffid, recffid, ffasmfunc; + +enum { + REGFUNC_OK, + REGFUNC_NOREG, + REGFUNC_NOREGUV +}; + +static void libdef_name(const char *p, int kind) +{ + size_t n = strlen(p); + if (kind != LIBINIT_STRING) { + if (n > modnamelen && p[modnamelen] == '_' && + !strncmp(p, modname, modnamelen)) { + p += modnamelen+1; + n -= modnamelen+1; + } + } + if (n > LIBINIT_MAXSTR) { + fprintf(stderr, "Error: string too long: '%s'\n", p); + exit(1); + } + if (optr+1+n+2 > obuf+sizeof(obuf)) { /* +2 for caller. */ + fprintf(stderr, "Error: output buffer overflow\n"); + exit(1); + } + *optr++ = (uint8_t)(n | kind); + memcpy(optr, p, n); + optr += n; +} + +static void libdef_endmodule(BuildCtx *ctx) +{ + if (modstate != 0) { + char line[80]; + const uint8_t *p; + int n; + if (modstate == 1) + fprintf(ctx->fp, " (lua_CFunction)0"); + fprintf(ctx->fp, "\n};\n"); + fprintf(ctx->fp, "static const uint8_t %s%s[] = {\n", + LABEL_PREFIX_LIBINIT, modname); + line[0] = '\0'; + for (n = 0, p = obuf; p < optr; p++) { + n += sprintf(line+n, "%d,", *p); + if (n >= 75) { + fprintf(ctx->fp, "%s\n", line); + n = 0; + line[0] = '\0'; + } + } + fprintf(ctx->fp, "%s%d\n};\n#endif\n\n", line, LIBINIT_END); + } +} + +static void libdef_module(BuildCtx *ctx, char *p, int arg) +{ + UNUSED(arg); + if (ctx->mode == BUILD_libdef) { + libdef_endmodule(ctx); + optr = obuf; + *optr++ = (uint8_t)ffid; + *optr++ = (uint8_t)ffasmfunc; + *optr++ = 0; /* Hash table size. */ + modstate = 1; + fprintf(ctx->fp, "#ifdef %sMODULE_%s\n", LIBDEF_PREFIX, p); + fprintf(ctx->fp, "#undef %sMODULE_%s\n", LIBDEF_PREFIX, p); + fprintf(ctx->fp, "static const lua_CFunction %s%s[] = {\n", + LABEL_PREFIX_LIBCF, p); + } + modnamelen = strlen(p); + if (modnamelen > sizeof(modname)-1) { + fprintf(stderr, "Error: module name too long: '%s'\n", p); + exit(1); + } + strcpy(modname, p); +} + +static int find_ffofs(BuildCtx *ctx, const char *name) +{ + int i; + for (i = 0; i < ctx->nglob; i++) { + const char *gl = ctx->globnames[i]; + if (gl[0] == 'f' && gl[1] == 'f' && gl[2] == '_' && !strcmp(gl+3, name)) { + return (int)((uint8_t *)ctx->glob[i] - ctx->code); + } + } + fprintf(stderr, "Error: undefined fast function %s%s\n", + LABEL_PREFIX_FF, name); + exit(1); +} + +static void libdef_func(BuildCtx *ctx, char *p, int arg) +{ + if (arg != LIBINIT_CF) + ffasmfunc++; + if (ctx->mode == BUILD_libdef) { + if (modstate == 0) { + fprintf(stderr, "Error: no module for function definition %s\n", p); + exit(1); + } + if (regfunc == REGFUNC_NOREG) { + if (optr+1 > obuf+sizeof(obuf)) { + fprintf(stderr, "Error: output buffer overflow\n"); + exit(1); + } + *optr++ = LIBINIT_FFID; + } else { + if (arg != LIBINIT_ASM_) { + if (modstate != 1) fprintf(ctx->fp, ",\n"); + modstate = 2; + fprintf(ctx->fp, " %s%s", arg ? LABEL_PREFIX_FFH : LABEL_PREFIX_CF, p); + } + if (regfunc != REGFUNC_NOREGUV) obuf[2]++; /* Bump hash table size. */ + libdef_name(regfunc == REGFUNC_NOREGUV ? "" : p, arg); + } + } else if (ctx->mode == BUILD_ffdef) { + fprintf(ctx->fp, "FFDEF(%s)\n", p); + } else if (ctx->mode == BUILD_recdef) { + if (strlen(p) > sizeof(funcname)-1) { + fprintf(stderr, "Error: function name too long: '%s'\n", p); + exit(1); + } + strcpy(funcname, p); + } else if (ctx->mode == BUILD_vmdef) { + int i; + for (i = 1; p[i] && modname[i-1]; i++) + if (p[i] == '_') p[i] = '.'; + fprintf(ctx->fp, "\"%s\",\n", p); + } else if (ctx->mode == BUILD_bcdef) { + if (arg != LIBINIT_CF) + fprintf(ctx->fp, ",\n%d", find_ffofs(ctx, p)); + } + ffid++; + regfunc = REGFUNC_OK; +} + +static uint32_t find_rec(char *name) +{ + char *p = (char *)obuf; + uint32_t n; + for (n = 2; *p; n++) { + if (strcmp(p, name) == 0) + return n; + p += strlen(p)+1; + } + if (p+strlen(name)+1 >= (char *)obuf+sizeof(obuf)) { + fprintf(stderr, "Error: output buffer overflow\n"); + exit(1); + } + strcpy(p, name); + return n; +} + +static void libdef_rec(BuildCtx *ctx, char *p, int arg) +{ + UNUSED(arg); + if (ctx->mode == BUILD_recdef) { + char *q; + uint32_t n; + for (; recffid+1 < ffid; recffid++) + fprintf(ctx->fp, ",\n0"); + recffid = ffid; + if (*p == '.') p = funcname; + q = strchr(p, ' '); + if (q) *q++ = '\0'; + n = find_rec(p); + if (q) + fprintf(ctx->fp, ",\n0x%02x00+(%s)", n, q); + else + fprintf(ctx->fp, ",\n0x%02x00", n); + } +} + +static void memcpy_endian(void *dst, void *src, size_t n) +{ + union { uint8_t b; uint32_t u; } host_endian; + host_endian.u = 1; + if (host_endian.b == LJ_ENDIAN_SELECT(1, 0)) { + memcpy(dst, src, n); + } else { + size_t i; + for (i = 0; i < n; i++) + ((uint8_t *)dst)[i] = ((uint8_t *)src)[n-i-1]; + } +} + +static void libdef_push(BuildCtx *ctx, char *p, int arg) +{ + UNUSED(arg); + if (ctx->mode == BUILD_libdef) { + int len = (int)strlen(p); + if (*p == '"') { + if (len > 1 && p[len-1] == '"') { + p[len-1] = '\0'; + libdef_name(p+1, LIBINIT_STRING); + return; + } + } else if (*p >= '0' && *p <= '9') { + char *ep; + double d = strtod(p, &ep); + if (*ep == '\0') { + if (optr+1+sizeof(double) > obuf+sizeof(obuf)) { + fprintf(stderr, "Error: output buffer overflow\n"); + exit(1); + } + *optr++ = LIBINIT_NUMBER; + memcpy_endian(optr, &d, sizeof(double)); + optr += sizeof(double); + return; + } + } else if (!strcmp(p, "lastcl")) { + if (optr+1 > obuf+sizeof(obuf)) { + fprintf(stderr, "Error: output buffer overflow\n"); + exit(1); + } + *optr++ = LIBINIT_LASTCL; + return; + } else if (len > 4 && !strncmp(p, "top-", 4)) { + if (optr+2 > obuf+sizeof(obuf)) { + fprintf(stderr, "Error: output buffer overflow\n"); + exit(1); + } + *optr++ = LIBINIT_COPY; + *optr++ = (uint8_t)atoi(p+4); + return; + } + fprintf(stderr, "Error: bad value for %sPUSH(%s)\n", LIBDEF_PREFIX, p); + exit(1); + } +} + +static void libdef_set(BuildCtx *ctx, char *p, int arg) +{ + UNUSED(arg); + if (ctx->mode == BUILD_libdef) { + if (p[0] == '!' && p[1] == '\0') p[0] = '\0'; /* Set env. */ + libdef_name(p, LIBINIT_STRING); + *optr++ = LIBINIT_SET; + obuf[2]++; /* Bump hash table size. */ + } +} + +static void libdef_regfunc(BuildCtx *ctx, char *p, int arg) +{ + UNUSED(ctx); UNUSED(p); + regfunc = arg; +} + +typedef void (*LibDefFunc)(BuildCtx *ctx, char *p, int arg); + +typedef struct LibDefHandler { + const char *suffix; + const char *stop; + const LibDefFunc func; + const int arg; +} LibDefHandler; + +static const LibDefHandler libdef_handlers[] = { + { "MODULE_", " \t\r\n", libdef_module, 0 }, + { "CF(", ")", libdef_func, LIBINIT_CF }, + { "ASM(", ")", libdef_func, LIBINIT_ASM }, + { "ASM_(", ")", libdef_func, LIBINIT_ASM_ }, + { "REC(", ")", libdef_rec, 0 }, + { "PUSH(", ")", libdef_push, 0 }, + { "SET(", ")", libdef_set, 0 }, + { "NOREGUV", NULL, libdef_regfunc, REGFUNC_NOREGUV }, + { "NOREG", NULL, libdef_regfunc, REGFUNC_NOREG }, + { NULL, NULL, (LibDefFunc)0, 0 } +}; + +/* Emit C source code for library function definitions. */ +void emit_lib(BuildCtx *ctx) +{ + const char *fname; + + if (ctx->mode == BUILD_ffdef || ctx->mode == BUILD_libdef || + ctx->mode == BUILD_recdef) + fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n"); + else if (ctx->mode == BUILD_vmdef) + fprintf(ctx->fp, "ffnames = {\n[0]=\"Lua\",\n\"C\",\n"); + if (ctx->mode == BUILD_recdef) + fprintf(ctx->fp, "static const uint16_t recff_idmap[] = {\n0,\n0x0100"); + recffid = ffid = FF_C+1; + ffasmfunc = 0; + + while ((fname = *ctx->args++)) { + char buf[256]; /* We don't care about analyzing lines longer than that. */ + FILE *fp; + if (fname[0] == '-' && fname[1] == '\0') { + fp = stdin; + } else { + fp = fopen(fname, "r"); + if (!fp) { + fprintf(stderr, "Error: cannot open input file '%s': %s\n", + fname, strerror(errno)); + exit(1); + } + } + modstate = 0; + regfunc = REGFUNC_OK; + while (fgets(buf, sizeof(buf), fp) != NULL) { + char *p; + /* Simplistic pre-processor. Only handles top-level #if/#endif. */ + if (buf[0] == '#' && buf[1] == 'i' && buf[2] == 'f') { + int ok = 1; + if (!strcmp(buf, "#if LJ_52\n")) + ok = LJ_52; + else if (!strcmp(buf, "#if LJ_HASJIT\n")) + ok = LJ_HASJIT; + else if (!strcmp(buf, "#if LJ_HASFFI\n")) + ok = LJ_HASFFI; + if (!ok) { + int lvl = 1; + while (fgets(buf, sizeof(buf), fp) != NULL) { + if (buf[0] == '#' && buf[1] == 'e' && buf[2] == 'n') { + if (--lvl == 0) break; + } else if (buf[0] == '#' && buf[1] == 'i' && buf[2] == 'f') { + lvl++; + } + } + continue; + } + } + for (p = buf; (p = strstr(p, LIBDEF_PREFIX)) != NULL; ) { + const LibDefHandler *ldh; + p += sizeof(LIBDEF_PREFIX)-1; + for (ldh = libdef_handlers; ldh->suffix != NULL; ldh++) { + size_t n, len = strlen(ldh->suffix); + if (!strncmp(p, ldh->suffix, len)) { + p += len; + n = ldh->stop ? strcspn(p, ldh->stop) : 0; + if (!p[n]) break; + p[n] = '\0'; + ldh->func(ctx, p, ldh->arg); + p += n+1; + break; + } + } + if (ldh->suffix == NULL) { + buf[strlen(buf)-1] = '\0'; + fprintf(stderr, "Error: unknown library definition tag %s%s\n", + LIBDEF_PREFIX, p); + exit(1); + } + } + } + fclose(fp); + if (ctx->mode == BUILD_libdef) { + libdef_endmodule(ctx); + } + } + + if (ctx->mode == BUILD_ffdef) { + fprintf(ctx->fp, "\n#undef FFDEF\n\n"); + fprintf(ctx->fp, + "#ifndef FF_NUM_ASMFUNC\n#define FF_NUM_ASMFUNC %d\n#endif\n\n", + ffasmfunc); + } else if (ctx->mode == BUILD_vmdef) { + fprintf(ctx->fp, "}\n\n"); + } else if (ctx->mode == BUILD_bcdef) { + int i; + fprintf(ctx->fp, "\n};\n\n"); + fprintf(ctx->fp, "LJ_DATADEF const uint16_t lj_bc_mode[] = {\n"); + fprintf(ctx->fp, "BCDEF(BCMODE)\n"); + for (i = ffasmfunc-1; i > 0; i--) + fprintf(ctx->fp, "BCMODE_FF,\n"); + fprintf(ctx->fp, "BCMODE_FF\n};\n\n"); + } else if (ctx->mode == BUILD_recdef) { + char *p = (char *)obuf; + fprintf(ctx->fp, "\n};\n\n"); + fprintf(ctx->fp, "static const RecordFunc recff_func[] = {\n" + "recff_nyi,\n" + "recff_c"); + while (*p) { + fprintf(ctx->fp, ",\nrecff_%s", p); + p += strlen(p)+1; + } + fprintf(ctx->fp, "\n};\n\n"); + } +} + + +``` + +`include/luajit-2.0.5/src/host/buildvm_peobj.c`: + +```c +/* +** LuaJIT VM builder: PE object emitter. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Only used for building on Windows, since we cannot assume the presence +** of a suitable assembler. The host and target byte order must match. +*/ + +#include "buildvm.h" +#include "lj_bc.h" + +#if LJ_TARGET_X86ORX64 || LJ_TARGET_PPC + +/* Context for PE object emitter. */ +static char *strtab; +static size_t strtabofs; + +/* -- PE object definitions ----------------------------------------------- */ + +/* PE header. */ +typedef struct PEheader { + uint16_t arch; + uint16_t nsects; + uint32_t time; + uint32_t symtabofs; + uint32_t nsyms; + uint16_t opthdrsz; + uint16_t flags; +} PEheader; + +/* PE section. */ +typedef struct PEsection { + char name[8]; + uint32_t vsize; + uint32_t vaddr; + uint32_t size; + uint32_t ofs; + uint32_t relocofs; + uint32_t lineofs; + uint16_t nreloc; + uint16_t nline; + uint32_t flags; +} PEsection; + +/* PE relocation. */ +typedef struct PEreloc { + uint32_t vaddr; + uint32_t symidx; + uint16_t type; +} PEreloc; + +/* Cannot use sizeof, because it pads up to the max. alignment. */ +#define PEOBJ_RELOC_SIZE (4+4+2) + +/* PE symbol table entry. */ +typedef struct PEsym { + union { + char name[8]; + uint32_t nameref[2]; + } n; + uint32_t value; + int16_t sect; + uint16_t type; + uint8_t scl; + uint8_t naux; +} PEsym; + +/* PE symbol table auxiliary entry for a section. */ +typedef struct PEsymaux { + uint32_t size; + uint16_t nreloc; + uint16_t nline; + uint32_t cksum; + uint16_t assoc; + uint8_t comdatsel; + uint8_t unused[3]; +} PEsymaux; + +/* Cannot use sizeof, because it pads up to the max. alignment. */ +#define PEOBJ_SYM_SIZE (8+4+2+2+1+1) + +/* PE object CPU specific defines. */ +#if LJ_TARGET_X86 +#define PEOBJ_ARCH_TARGET 0x014c +#define PEOBJ_RELOC_REL32 0x14 /* MS: REL32, GNU: DISP32. */ +#define PEOBJ_RELOC_DIR32 0x06 +#define PEOBJ_RELOC_OFS 0 +#define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */ +#elif LJ_TARGET_X64 +#define PEOBJ_ARCH_TARGET 0x8664 +#define PEOBJ_RELOC_REL32 0x04 /* MS: REL32, GNU: DISP32. */ +#define PEOBJ_RELOC_DIR32 0x02 +#define PEOBJ_RELOC_ADDR32NB 0x03 +#define PEOBJ_RELOC_OFS 0 +#define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */ +#elif LJ_TARGET_PPC +#define PEOBJ_ARCH_TARGET 0x01f2 +#define PEOBJ_RELOC_REL32 0x06 +#define PEOBJ_RELOC_DIR32 0x02 +#define PEOBJ_RELOC_OFS (-4) +#define PEOBJ_TEXT_FLAGS 0x60400020 /* 60=r+x, 40=align8, 20=code. */ +#endif + +/* Section numbers (0-based). */ +enum { + PEOBJ_SECT_ABS = -2, + PEOBJ_SECT_UNDEF = -1, + PEOBJ_SECT_TEXT, +#if LJ_TARGET_X64 + PEOBJ_SECT_PDATA, + PEOBJ_SECT_XDATA, +#endif + PEOBJ_SECT_RDATA_Z, + PEOBJ_NSECTIONS +}; + +/* Symbol types. */ +#define PEOBJ_TYPE_NULL 0 +#define PEOBJ_TYPE_FUNC 0x20 + +/* Symbol storage class. */ +#define PEOBJ_SCL_EXTERN 2 +#define PEOBJ_SCL_STATIC 3 + +/* -- PE object emitter --------------------------------------------------- */ + +/* Emit PE object symbol. */ +static void emit_peobj_sym(BuildCtx *ctx, const char *name, uint32_t value, + int sect, int type, int scl) +{ + PEsym sym; + size_t len = strlen(name); + if (!strtab) { /* Pass 1: only calculate string table length. */ + if (len > 8) strtabofs += len+1; + return; + } + if (len <= 8) { + memcpy(sym.n.name, name, len); + memset(sym.n.name+len, 0, 8-len); + } else { + sym.n.nameref[0] = 0; + sym.n.nameref[1] = (uint32_t)strtabofs; + memcpy(strtab + strtabofs, name, len); + strtab[strtabofs+len] = 0; + strtabofs += len+1; + } + sym.value = value; + sym.sect = (int16_t)(sect+1); /* 1-based section number. */ + sym.type = (uint16_t)type; + sym.scl = (uint8_t)scl; + sym.naux = 0; + owrite(ctx, &sym, PEOBJ_SYM_SIZE); +} + +/* Emit PE object section symbol. */ +static void emit_peobj_sym_sect(BuildCtx *ctx, PEsection *pesect, int sect) +{ + PEsym sym; + PEsymaux aux; + if (!strtab) return; /* Pass 1: no output. */ + memcpy(sym.n.name, pesect[sect].name, 8); + sym.value = 0; + sym.sect = (int16_t)(sect+1); /* 1-based section number. */ + sym.type = PEOBJ_TYPE_NULL; + sym.scl = PEOBJ_SCL_STATIC; + sym.naux = 1; + owrite(ctx, &sym, PEOBJ_SYM_SIZE); + memset(&aux, 0, sizeof(PEsymaux)); + aux.size = pesect[sect].size; + aux.nreloc = pesect[sect].nreloc; + owrite(ctx, &aux, PEOBJ_SYM_SIZE); +} + +/* Emit Windows PE object file. */ +void emit_peobj(BuildCtx *ctx) +{ + PEheader pehdr; + PEsection pesect[PEOBJ_NSECTIONS]; + uint32_t sofs; + int i, nrsym; + union { uint8_t b; uint32_t u; } host_endian; + + sofs = sizeof(PEheader) + PEOBJ_NSECTIONS*sizeof(PEsection); + + /* Fill in PE sections. */ + memset(&pesect, 0, PEOBJ_NSECTIONS*sizeof(PEsection)); + memcpy(pesect[PEOBJ_SECT_TEXT].name, ".text", sizeof(".text")-1); + pesect[PEOBJ_SECT_TEXT].ofs = sofs; + sofs += (pesect[PEOBJ_SECT_TEXT].size = (uint32_t)ctx->codesz); + pesect[PEOBJ_SECT_TEXT].relocofs = sofs; + sofs += (pesect[PEOBJ_SECT_TEXT].nreloc = (uint16_t)ctx->nreloc) * PEOBJ_RELOC_SIZE; + /* Flags: 60 = read+execute, 50 = align16, 20 = code. */ + pesect[PEOBJ_SECT_TEXT].flags = PEOBJ_TEXT_FLAGS; + +#if LJ_TARGET_X64 + memcpy(pesect[PEOBJ_SECT_PDATA].name, ".pdata", sizeof(".pdata")-1); + pesect[PEOBJ_SECT_PDATA].ofs = sofs; + sofs += (pesect[PEOBJ_SECT_PDATA].size = 6*4); + pesect[PEOBJ_SECT_PDATA].relocofs = sofs; + sofs += (pesect[PEOBJ_SECT_PDATA].nreloc = 6) * PEOBJ_RELOC_SIZE; + /* Flags: 40 = read, 30 = align4, 40 = initialized data. */ + pesect[PEOBJ_SECT_PDATA].flags = 0x40300040; + + memcpy(pesect[PEOBJ_SECT_XDATA].name, ".xdata", sizeof(".xdata")-1); + pesect[PEOBJ_SECT_XDATA].ofs = sofs; + sofs += (pesect[PEOBJ_SECT_XDATA].size = 8*2+4+6*2); /* See below. */ + pesect[PEOBJ_SECT_XDATA].relocofs = sofs; + sofs += (pesect[PEOBJ_SECT_XDATA].nreloc = 1) * PEOBJ_RELOC_SIZE; + /* Flags: 40 = read, 30 = align4, 40 = initialized data. */ + pesect[PEOBJ_SECT_XDATA].flags = 0x40300040; +#endif + + memcpy(pesect[PEOBJ_SECT_RDATA_Z].name, ".rdata$Z", sizeof(".rdata$Z")-1); + pesect[PEOBJ_SECT_RDATA_Z].ofs = sofs; + sofs += (pesect[PEOBJ_SECT_RDATA_Z].size = (uint32_t)strlen(ctx->dasm_ident)+1); + /* Flags: 40 = read, 30 = align4, 40 = initialized data. */ + pesect[PEOBJ_SECT_RDATA_Z].flags = 0x40300040; + + /* Fill in PE header. */ + pehdr.arch = PEOBJ_ARCH_TARGET; + pehdr.nsects = PEOBJ_NSECTIONS; + pehdr.time = 0; /* Timestamp is optional. */ + pehdr.symtabofs = sofs; + pehdr.opthdrsz = 0; + pehdr.flags = 0; + + /* Compute the size of the symbol table: + ** @feat.00 + nsections*2 + ** + asm_start + nsym + ** + nrsym + */ + nrsym = ctx->nrelocsym; + pehdr.nsyms = 1+PEOBJ_NSECTIONS*2 + 1+ctx->nsym + nrsym; +#if LJ_TARGET_X64 + pehdr.nsyms += 1; /* Symbol for lj_err_unwind_win64. */ +#endif + + /* Write PE object header and all sections. */ + owrite(ctx, &pehdr, sizeof(PEheader)); + owrite(ctx, &pesect, sizeof(PEsection)*PEOBJ_NSECTIONS); + + /* Write .text section. */ + host_endian.u = 1; + if (host_endian.b != LJ_ENDIAN_SELECT(1, 0)) { +#if LJ_TARGET_PPC + uint32_t *p = (uint32_t *)ctx->code; + int n = (int)(ctx->codesz >> 2); + for (i = 0; i < n; i++, p++) + *p = lj_bswap(*p); /* Byteswap .text section. */ +#else + fprintf(stderr, "Error: different byte order for host and target\n"); + exit(1); +#endif + } + owrite(ctx, ctx->code, ctx->codesz); + for (i = 0; i < ctx->nreloc; i++) { + PEreloc reloc; + reloc.vaddr = (uint32_t)ctx->reloc[i].ofs + PEOBJ_RELOC_OFS; + reloc.symidx = 1+2+ctx->reloc[i].sym; /* Reloc syms are after .text sym. */ + reloc.type = ctx->reloc[i].type ? PEOBJ_RELOC_REL32 : PEOBJ_RELOC_DIR32; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + } + +#if LJ_TARGET_X64 + { /* Write .pdata section. */ + uint32_t fcofs = (uint32_t)ctx->sym[ctx->nsym-1].ofs; + uint32_t pdata[3]; /* Start of .text, end of .text and .xdata. */ + PEreloc reloc; + pdata[0] = 0; pdata[1] = fcofs; pdata[2] = 0; + owrite(ctx, &pdata, sizeof(pdata)); + pdata[0] = fcofs; pdata[1] = (uint32_t)ctx->codesz; pdata[2] = 20; + owrite(ctx, &pdata, sizeof(pdata)); + reloc.vaddr = 0; reloc.symidx = 1+2+nrsym+2+2+1; + reloc.type = PEOBJ_RELOC_ADDR32NB; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + reloc.vaddr = 4; reloc.symidx = 1+2+nrsym+2+2+1; + reloc.type = PEOBJ_RELOC_ADDR32NB; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + reloc.vaddr = 8; reloc.symidx = 1+2+nrsym+2; + reloc.type = PEOBJ_RELOC_ADDR32NB; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + reloc.vaddr = 12; reloc.symidx = 1+2+nrsym+2+2+1; + reloc.type = PEOBJ_RELOC_ADDR32NB; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + reloc.vaddr = 16; reloc.symidx = 1+2+nrsym+2+2+1; + reloc.type = PEOBJ_RELOC_ADDR32NB; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + reloc.vaddr = 20; reloc.symidx = 1+2+nrsym+2; + reloc.type = PEOBJ_RELOC_ADDR32NB; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + } + { /* Write .xdata section. */ + uint16_t xdata[8+2+6]; + PEreloc reloc; + xdata[0] = 0x01|0x08|0x10; /* Ver. 1, uhandler/ehandler, prolog size 0. */ + xdata[1] = 0x0005; /* Number of unwind codes, no frame pointer. */ + xdata[2] = 0x4200; /* Stack offset 4*8+8 = aword*5. */ + xdata[3] = 0x3000; /* Push rbx. */ + xdata[4] = 0x6000; /* Push rsi. */ + xdata[5] = 0x7000; /* Push rdi. */ + xdata[6] = 0x5000; /* Push rbp. */ + xdata[7] = 0; /* Alignment. */ + xdata[8] = xdata[9] = 0; /* Relocated address of exception handler. */ + xdata[10] = 0x01; /* Ver. 1, no handler, prolog size 0. */ + xdata[11] = 0x1504; /* Number of unwind codes, fp = rbp, fpofs = 16. */ + xdata[12] = 0x0300; /* set_fpreg. */ + xdata[13] = 0x0200; /* stack offset 0*8+8 = aword*1. */ + xdata[14] = 0x3000; /* Push rbx. */ + xdata[15] = 0x5000; /* Push rbp. */ + owrite(ctx, &xdata, sizeof(xdata)); + reloc.vaddr = 2*8; reloc.symidx = 1+2+nrsym+2+2; + reloc.type = PEOBJ_RELOC_ADDR32NB; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + } +#endif + + /* Write .rdata$Z section. */ + owrite(ctx, ctx->dasm_ident, strlen(ctx->dasm_ident)+1); + + /* Write symbol table. */ + strtab = NULL; /* 1st pass: collect string sizes. */ + for (;;) { + strtabofs = 4; + /* Mark as SafeSEH compliant. */ + emit_peobj_sym(ctx, "@feat.00", 1, + PEOBJ_SECT_ABS, PEOBJ_TYPE_NULL, PEOBJ_SCL_STATIC); + + emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_TEXT); + for (i = 0; i < nrsym; i++) + emit_peobj_sym(ctx, ctx->relocsym[i], 0, + PEOBJ_SECT_UNDEF, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN); + +#if LJ_TARGET_X64 + emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_PDATA); + emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_XDATA); + emit_peobj_sym(ctx, "lj_err_unwind_win64", 0, + PEOBJ_SECT_UNDEF, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN); +#endif + + emit_peobj_sym(ctx, ctx->beginsym, 0, + PEOBJ_SECT_TEXT, PEOBJ_TYPE_NULL, PEOBJ_SCL_EXTERN); + for (i = 0; i < ctx->nsym; i++) + emit_peobj_sym(ctx, ctx->sym[i].name, (uint32_t)ctx->sym[i].ofs, + PEOBJ_SECT_TEXT, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN); + + emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_RDATA_Z); + + if (strtab) + break; + /* 2nd pass: alloc strtab, write syms and copy strings. */ + strtab = (char *)malloc(strtabofs); + *(uint32_t *)strtab = (uint32_t)strtabofs; + } + + /* Write string table. */ + owrite(ctx, strtab, strtabofs); +} + +#else + +void emit_peobj(BuildCtx *ctx) +{ + UNUSED(ctx); + fprintf(stderr, "Error: no PE object support for this target\n"); + exit(1); +} + +#endif + +``` + +`include/luajit-2.0.5/src/host/genminilua.lua`: + +```lua +---------------------------------------------------------------------------- +-- Lua script to generate a customized, minified version of Lua. +-- The resulting 'minilua' is used for the build process of LuaJIT. +---------------------------------------------------------------------------- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- + +local sub, match, gsub = string.sub, string.match, string.gsub + +local LUA_VERSION = "5.1.5" +local LUA_SOURCE + +local function usage() + io.stderr:write("Usage: ", arg and arg[0] or "genminilua", + " lua-", LUA_VERSION, "-source-dir\n") + os.exit(1) +end + +local function find_sources() + LUA_SOURCE = arg and arg[1] + if not LUA_SOURCE then usage() end + if sub(LUA_SOURCE, -1) ~= "/" then LUA_SOURCE = LUA_SOURCE.."/" end + local fp = io.open(LUA_SOURCE .. "lua.h") + if not fp then + LUA_SOURCE = LUA_SOURCE.."src/" + fp = io.open(LUA_SOURCE .. "lua.h") + if not fp then usage() end + end + local all = fp:read("*a") + fp:close() + if not match(all, 'LUA_RELEASE%s*"Lua '..LUA_VERSION..'"') then + io.stderr:write("Error: version mismatch\n") + usage() + end +end + +local LUA_FILES = { +"lmem.c", "lobject.c", "ltm.c", "lfunc.c", "ldo.c", "lstring.c", "ltable.c", +"lgc.c", "lstate.c", "ldebug.c", "lzio.c", "lopcodes.c", +"llex.c", "lcode.c", "lparser.c", "lvm.c", "lapi.c", "lauxlib.c", +"lbaselib.c", "ltablib.c", "liolib.c", "loslib.c", "lstrlib.c", "linit.c", +} + +local REMOVE_LIB = {} +gsub([[ +collectgarbage dofile gcinfo getfenv getmetatable load print rawequal rawset +select tostring xpcall +foreach foreachi getn maxn setn +popen tmpfile seek setvbuf __tostring +clock date difftime execute getenv rename setlocale time tmpname +dump gfind len reverse +LUA_LOADLIBNAME LUA_MATHLIBNAME LUA_DBLIBNAME +]], "%S+", function(name) + REMOVE_LIB[name] = true +end) + +local REMOVE_EXTINC = { [""] = true, [""] = true, } + +local CUSTOM_MAIN = [[ +typedef unsigned int UB; +static UB barg(lua_State *L,int idx){ +union{lua_Number n;U64 b;}bn; +bn.n=lua_tonumber(L,idx)+6755399441055744.0; +if (bn.n==0.0&&!lua_isnumber(L,idx))luaL_typerror(L,idx,"number"); +return(UB)bn.b; +} +#define BRET(b) lua_pushnumber(L,(lua_Number)(int)(b));return 1; +static int tobit(lua_State *L){ +BRET(barg(L,1))} +static int bnot(lua_State *L){ +BRET(~barg(L,1))} +static int band(lua_State *L){ +int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b&=barg(L,i);BRET(b)} +static int bor(lua_State *L){ +int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b|=barg(L,i);BRET(b)} +static int bxor(lua_State *L){ +int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b^=barg(L,i);BRET(b)} +static int lshift(lua_State *L){ +UB b=barg(L,1),n=barg(L,2)&31;BRET(b<>n)} +static int arshift(lua_State *L){ +UB b=barg(L,1),n=barg(L,2)&31;BRET((int)b>>n)} +static int rol(lua_State *L){ +UB b=barg(L,1),n=barg(L,2)&31;BRET((b<>(32-n)))} +static int ror(lua_State *L){ +UB b=barg(L,1),n=barg(L,2)&31;BRET((b>>n)|(b<<(32-n)))} +static int bswap(lua_State *L){ +UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)} +static int tohex(lua_State *L){ +UB b=barg(L,1); +int n=lua_isnone(L,2)?8:(int)barg(L,2); +const char *hexdigits="0123456789abcdef"; +char buf[8]; +int i; +if(n<0){n=-n;hexdigits="0123456789ABCDEF";} +if(n>8)n=8; +for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;} +lua_pushlstring(L,buf,(size_t)n); +return 1; +} +static const struct luaL_Reg bitlib[] = { +{"tobit",tobit}, +{"bnot",bnot}, +{"band",band}, +{"bor",bor}, +{"bxor",bxor}, +{"lshift",lshift}, +{"rshift",rshift}, +{"arshift",arshift}, +{"rol",rol}, +{"ror",ror}, +{"bswap",bswap}, +{"tohex",tohex}, +{NULL,NULL} +}; +int main(int argc, char **argv){ + lua_State *L = luaL_newstate(); + int i; + luaL_openlibs(L); + luaL_register(L, "bit", bitlib); + if (argc < 2) return sizeof(void *); + lua_createtable(L, 0, 1); + lua_pushstring(L, argv[1]); + lua_rawseti(L, -2, 0); + lua_setglobal(L, "arg"); + if (luaL_loadfile(L, argv[1])) + goto err; + for (i = 2; i < argc; i++) + lua_pushstring(L, argv[i]); + if (lua_pcall(L, argc - 2, 0, 0)) { + err: + fprintf(stderr, "Error: %s\n", lua_tostring(L, -1)); + return 1; + } + lua_close(L); + return 0; +} +]] + +local function read_sources() + local t = {} + for i, name in ipairs(LUA_FILES) do + local fp = assert(io.open(LUA_SOURCE..name, "r")) + t[i] = fp:read("*a") + assert(fp:close()) + end + t[#t+1] = CUSTOM_MAIN + return table.concat(t) +end + +local includes = {} + +local function merge_includes(src) + return gsub(src, '#include%s*"([^"]*)"%s*\n', function(name) + if includes[name] then return "" end + includes[name] = true + local fp = assert(io.open(LUA_SOURCE..name, "r")) + local inc = fp:read("*a") + assert(fp:close()) + inc = gsub(inc, "#ifndef%s+%w+_h\n#define%s+%w+_h\n", "") + inc = gsub(inc, "#endif%s*$", "") + return merge_includes(inc) + end) +end + +local function get_license(src) + return match(src, "/%*+\n%* Copyright %(.-%*/\n") +end + +local function fold_lines(src) + return gsub(src, "\\\n", " ") +end + +local strings = {} + +local function save_str(str) + local n = #strings+1 + strings[n] = str + return "\1"..n.."\2" +end + +local function save_strings(src) + src = gsub(src, '"[^"\n]*"', save_str) + return gsub(src, "'[^'\n]*'", save_str) +end + +local function restore_strings(src) + return gsub(src, "\1(%d+)\2", function(numstr) + return strings[tonumber(numstr)] + end) +end + +local function def_istrue(def) + return def == "INT_MAX > 2147483640L" or + def == "LUAI_BITSINT >= 32" or + def == "SIZE_Bx < LUAI_BITSINT-1" or + def == "cast" or + def == "defined(LUA_CORE)" or + def == "MINSTRTABSIZE" or + def == "LUA_MINBUFFER" or + def == "HARDSTACKTESTS" or + def == "UNUSED" +end + +local head, defs = {[[ +#ifdef _MSC_VER +typedef unsigned __int64 U64; +#else +typedef unsigned long long U64; +#endif +int _CRT_glob = 0; +]]}, {} + +local function preprocess(src) + local t = { match(src, "^(.-)#") } + local lvl, on, oldon = 0, true, {} + for pp, def, txt in string.gmatch(src, "#(%w+) *([^\n]*)\n([^#]*)") do + if pp == "if" or pp == "ifdef" or pp == "ifndef" then + lvl = lvl + 1 + oldon[lvl] = on + on = def_istrue(def) + elseif pp == "else" then + if oldon[lvl] then + if on == false then on = true else on = false end + end + elseif pp == "elif" then + if oldon[lvl] then + on = def_istrue(def) + end + elseif pp == "endif" then + on = oldon[lvl] + lvl = lvl - 1 + elseif on then + if pp == "include" then + if not head[def] and not REMOVE_EXTINC[def] then + head[def] = true + head[#head+1] = "#include "..def.."\n" + end + elseif pp == "define" then + local k, sp, v = match(def, "([%w_]+)(%s*)(.*)") + if k and not (sp == "" and sub(v, 1, 1) == "(") then + defs[k] = gsub(v, "%a[%w_]*", function(tok) + return defs[tok] or tok + end) + else + t[#t+1] = "#define "..def.."\n" + end + elseif pp ~= "undef" then + error("unexpected directive: "..pp.." "..def) + end + end + if on then t[#t+1] = txt end + end + return gsub(table.concat(t), "%a[%w_]*", function(tok) + return defs[tok] or tok + end) +end + +local function merge_header(src, license) + local hdr = string.format([[ +/* This is a heavily customized and minimized copy of Lua %s. */ +/* It's only used to build LuaJIT. It does NOT have all standard functions! */ +]], LUA_VERSION) + return hdr..license..table.concat(head)..src +end + +local function strip_unused1(src) + return gsub(src, '( {"?([%w_]+)"?,%s+%a[%w_]*},\n)', function(line, func) + return REMOVE_LIB[func] and "" or line + end) +end + +local function strip_unused2(src) + return gsub(src, "Symbolic Execution.-}=", "") +end + +local function strip_unused3(src) + src = gsub(src, "extern", "static") + src = gsub(src, "\nstatic([^\n]-)%(([^)]*)%)%(", "\nstatic%1 %2(") + src = gsub(src, "#define lua_assert[^\n]*\n", "") + src = gsub(src, "lua_assert%b();?", "") + src = gsub(src, "default:\n}", "default:;\n}") + src = gsub(src, "lua_lock%b();", "") + src = gsub(src, "lua_unlock%b();", "") + src = gsub(src, "luai_threadyield%b();", "") + src = gsub(src, "luai_userstateopen%b();", "{}") + src = gsub(src, "luai_userstate%w+%b();", "") + src = gsub(src, "%(%(c==.*luaY_parser%)", "luaY_parser") + src = gsub(src, "trydecpoint%(ls,seminfo%)", + "luaX_lexerror(ls,\"malformed number\",TK_NUMBER)") + src = gsub(src, "int c=luaZ_lookahead%b();", "") + src = gsub(src, "luaL_register%(L,[^,]*,co_funcs%);\nreturn 2;", + "return 1;") + src = gsub(src, "getfuncname%b():", "NULL:") + src = gsub(src, "getobjname%b():", "NULL:") + src = gsub(src, "if%([^\n]*hookmask[^\n]*%)\n[^\n]*\n", "") + src = gsub(src, "if%([^\n]*hookmask[^\n]*%)%b{}\n", "") + src = gsub(src, "if%([^\n]*hookmask[^\n]*&&\n[^\n]*%b{}\n", "") + src = gsub(src, "(twoto%b()%()", "%1(size_t)") + src = gsub(src, "i +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +typedef enum{ +TM_INDEX, +TM_NEWINDEX, +TM_GC, +TM_MODE, +TM_EQ, +TM_ADD, +TM_SUB, +TM_MUL, +TM_DIV, +TM_MOD, +TM_POW, +TM_UNM, +TM_LEN, +TM_LT, +TM_LE, +TM_CONCAT, +TM_CALL, +TM_N +}TMS; +enum OpMode{iABC,iABx,iAsBx}; +typedef enum{ +OP_MOVE, +OP_LOADK, +OP_LOADBOOL, +OP_LOADNIL, +OP_GETUPVAL, +OP_GETGLOBAL, +OP_GETTABLE, +OP_SETGLOBAL, +OP_SETUPVAL, +OP_SETTABLE, +OP_NEWTABLE, +OP_SELF, +OP_ADD, +OP_SUB, +OP_MUL, +OP_DIV, +OP_MOD, +OP_POW, +OP_UNM, +OP_NOT, +OP_LEN, +OP_CONCAT, +OP_JMP, +OP_EQ, +OP_LT, +OP_LE, +OP_TEST, +OP_TESTSET, +OP_CALL, +OP_TAILCALL, +OP_RETURN, +OP_FORLOOP, +OP_FORPREP, +OP_TFORLOOP, +OP_SETLIST, +OP_CLOSE, +OP_CLOSURE, +OP_VARARG +}OpCode; +enum OpArgMask{ +OpArgN, +OpArgU, +OpArgR, +OpArgK +}; +typedef enum{ +VVOID, +VNIL, +VTRUE, +VFALSE, +VK, +VKNUM, +VLOCAL, +VUPVAL, +VGLOBAL, +VINDEXED, +VJMP, +VRELOCABLE, +VNONRELOC, +VCALL, +VVARARG +}expkind; +enum RESERVED{ +TK_AND=257,TK_BREAK, +TK_DO,TK_ELSE,TK_ELSEIF,TK_END,TK_FALSE,TK_FOR,TK_FUNCTION, +TK_IF,TK_IN,TK_LOCAL,TK_NIL,TK_NOT,TK_OR,TK_REPEAT, +TK_RETURN,TK_THEN,TK_TRUE,TK_UNTIL,TK_WHILE, +TK_CONCAT,TK_DOTS,TK_EQ,TK_GE,TK_LE,TK_NE,TK_NUMBER, +TK_NAME,TK_STRING,TK_EOS +}; +typedef enum BinOpr{ +OPR_ADD,OPR_SUB,OPR_MUL,OPR_DIV,OPR_MOD,OPR_POW, +OPR_CONCAT, +OPR_NE,OPR_EQ, +OPR_LT,OPR_LE,OPR_GT,OPR_GE, +OPR_AND,OPR_OR, +OPR_NOBINOPR +}BinOpr; +typedef enum UnOpr{OPR_MINUS,OPR_NOT,OPR_LEN,OPR_NOUNOPR}UnOpr; +#define LUA_QL(x)"'"x"'" +#define luai_apicheck(L,o){(void)L;} +#define lua_number2str(s,n)sprintf((s),"%.14g",(n)) +#define lua_str2number(s,p)strtod((s),(p)) +#define luai_numadd(a,b)((a)+(b)) +#define luai_numsub(a,b)((a)-(b)) +#define luai_nummul(a,b)((a)*(b)) +#define luai_numdiv(a,b)((a)/(b)) +#define luai_nummod(a,b)((a)-floor((a)/(b))*(b)) +#define luai_numpow(a,b)(pow(a,b)) +#define luai_numunm(a)(-(a)) +#define luai_numeq(a,b)((a)==(b)) +#define luai_numlt(a,b)((a)<(b)) +#define luai_numle(a,b)((a)<=(b)) +#define luai_numisnan(a)(!luai_numeq((a),(a))) +#define lua_number2int(i,d)((i)=(int)(d)) +#define lua_number2integer(i,d)((i)=(lua_Integer)(d)) +#define LUAI_THROW(L,c)longjmp((c)->b,1) +#define LUAI_TRY(L,c,a)if(setjmp((c)->b)==0){a} +#define lua_pclose(L,file)((void)((void)L,file),0) +#define lua_upvalueindex(i)((-10002)-(i)) +typedef struct lua_State lua_State; +typedef int(*lua_CFunction)(lua_State*L); +typedef const char*(*lua_Reader)(lua_State*L,void*ud,size_t*sz); +typedef void*(*lua_Alloc)(void*ud,void*ptr,size_t osize,size_t nsize); +typedef double lua_Number; +typedef ptrdiff_t lua_Integer; +static void lua_settop(lua_State*L,int idx); +static int lua_type(lua_State*L,int idx); +static const char* lua_tolstring(lua_State*L,int idx,size_t*len); +static size_t lua_objlen(lua_State*L,int idx); +static void lua_pushlstring(lua_State*L,const char*s,size_t l); +static void lua_pushcclosure(lua_State*L,lua_CFunction fn,int n); +static void lua_createtable(lua_State*L,int narr,int nrec); +static void lua_setfield(lua_State*L,int idx,const char*k); +#define lua_pop(L,n)lua_settop(L,-(n)-1) +#define lua_newtable(L)lua_createtable(L,0,0) +#define lua_pushcfunction(L,f)lua_pushcclosure(L,(f),0) +#define lua_strlen(L,i)lua_objlen(L,(i)) +#define lua_isfunction(L,n)(lua_type(L,(n))==6) +#define lua_istable(L,n)(lua_type(L,(n))==5) +#define lua_isnil(L,n)(lua_type(L,(n))==0) +#define lua_isboolean(L,n)(lua_type(L,(n))==1) +#define lua_isnone(L,n)(lua_type(L,(n))==(-1)) +#define lua_isnoneornil(L,n)(lua_type(L,(n))<=0) +#define lua_pushliteral(L,s)lua_pushlstring(L,""s,(sizeof(s)/sizeof(char))-1) +#define lua_setglobal(L,s)lua_setfield(L,(-10002),(s)) +#define lua_tostring(L,i)lua_tolstring(L,(i),NULL) +typedef struct lua_Debug lua_Debug; +typedef void(*lua_Hook)(lua_State*L,lua_Debug*ar); +struct lua_Debug{ +int event; +const char*name; +const char*namewhat; +const char*what; +const char*source; +int currentline; +int nups; +int linedefined; +int lastlinedefined; +char short_src[60]; +int i_ci; +}; +typedef unsigned int lu_int32; +typedef size_t lu_mem; +typedef ptrdiff_t l_mem; +typedef unsigned char lu_byte; +#define IntPoint(p)((unsigned int)(lu_mem)(p)) +typedef union{double u;void*s;long l;}L_Umaxalign; +typedef double l_uacNumber; +#define check_exp(c,e)(e) +#define UNUSED(x)((void)(x)) +#define cast(t,exp)((t)(exp)) +#define cast_byte(i)cast(lu_byte,(i)) +#define cast_num(i)cast(lua_Number,(i)) +#define cast_int(i)cast(int,(i)) +typedef lu_int32 Instruction; +#define condhardstacktests(x)((void)0) +typedef union GCObject GCObject; +typedef struct GCheader{ +GCObject*next;lu_byte tt;lu_byte marked; +}GCheader; +typedef union{ +GCObject*gc; +void*p; +lua_Number n; +int b; +}Value; +typedef struct lua_TValue{ +Value value;int tt; +}TValue; +#define ttisnil(o)(ttype(o)==0) +#define ttisnumber(o)(ttype(o)==3) +#define ttisstring(o)(ttype(o)==4) +#define ttistable(o)(ttype(o)==5) +#define ttisfunction(o)(ttype(o)==6) +#define ttisboolean(o)(ttype(o)==1) +#define ttisuserdata(o)(ttype(o)==7) +#define ttisthread(o)(ttype(o)==8) +#define ttislightuserdata(o)(ttype(o)==2) +#define ttype(o)((o)->tt) +#define gcvalue(o)check_exp(iscollectable(o),(o)->value.gc) +#define pvalue(o)check_exp(ttislightuserdata(o),(o)->value.p) +#define nvalue(o)check_exp(ttisnumber(o),(o)->value.n) +#define rawtsvalue(o)check_exp(ttisstring(o),&(o)->value.gc->ts) +#define tsvalue(o)(&rawtsvalue(o)->tsv) +#define rawuvalue(o)check_exp(ttisuserdata(o),&(o)->value.gc->u) +#define uvalue(o)(&rawuvalue(o)->uv) +#define clvalue(o)check_exp(ttisfunction(o),&(o)->value.gc->cl) +#define hvalue(o)check_exp(ttistable(o),&(o)->value.gc->h) +#define bvalue(o)check_exp(ttisboolean(o),(o)->value.b) +#define thvalue(o)check_exp(ttisthread(o),&(o)->value.gc->th) +#define l_isfalse(o)(ttisnil(o)||(ttisboolean(o)&&bvalue(o)==0)) +#define checkconsistency(obj) +#define checkliveness(g,obj) +#define setnilvalue(obj)((obj)->tt=0) +#define setnvalue(obj,x){TValue*i_o=(obj);i_o->value.n=(x);i_o->tt=3;} +#define setbvalue(obj,x){TValue*i_o=(obj);i_o->value.b=(x);i_o->tt=1;} +#define setsvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=4;checkliveness(G(L),i_o);} +#define setuvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=7;checkliveness(G(L),i_o);} +#define setthvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=8;checkliveness(G(L),i_o);} +#define setclvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=6;checkliveness(G(L),i_o);} +#define sethvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=5;checkliveness(G(L),i_o);} +#define setptvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=(8+1);checkliveness(G(L),i_o);} +#define setobj(L,obj1,obj2){const TValue*o2=(obj2);TValue*o1=(obj1);o1->value=o2->value;o1->tt=o2->tt;checkliveness(G(L),o1);} +#define setttype(obj,tt)(ttype(obj)=(tt)) +#define iscollectable(o)(ttype(o)>=4) +typedef TValue*StkId; +typedef union TString{ +L_Umaxalign dummy; +struct{ +GCObject*next;lu_byte tt;lu_byte marked; +lu_byte reserved; +unsigned int hash; +size_t len; +}tsv; +}TString; +#define getstr(ts)cast(const char*,(ts)+1) +#define svalue(o)getstr(rawtsvalue(o)) +typedef union Udata{ +L_Umaxalign dummy; +struct{ +GCObject*next;lu_byte tt;lu_byte marked; +struct Table*metatable; +struct Table*env; +size_t len; +}uv; +}Udata; +typedef struct Proto{ +GCObject*next;lu_byte tt;lu_byte marked; +TValue*k; +Instruction*code; +struct Proto**p; +int*lineinfo; +struct LocVar*locvars; +TString**upvalues; +TString*source; +int sizeupvalues; +int sizek; +int sizecode; +int sizelineinfo; +int sizep; +int sizelocvars; +int linedefined; +int lastlinedefined; +GCObject*gclist; +lu_byte nups; +lu_byte numparams; +lu_byte is_vararg; +lu_byte maxstacksize; +}Proto; +typedef struct LocVar{ +TString*varname; +int startpc; +int endpc; +}LocVar; +typedef struct UpVal{ +GCObject*next;lu_byte tt;lu_byte marked; +TValue*v; +union{ +TValue value; +struct{ +struct UpVal*prev; +struct UpVal*next; +}l; +}u; +}UpVal; +typedef struct CClosure{ +GCObject*next;lu_byte tt;lu_byte marked;lu_byte isC;lu_byte nupvalues;GCObject*gclist;struct Table*env; +lua_CFunction f; +TValue upvalue[1]; +}CClosure; +typedef struct LClosure{ +GCObject*next;lu_byte tt;lu_byte marked;lu_byte isC;lu_byte nupvalues;GCObject*gclist;struct Table*env; +struct Proto*p; +UpVal*upvals[1]; +}LClosure; +typedef union Closure{ +CClosure c; +LClosure l; +}Closure; +#define iscfunction(o)(ttype(o)==6&&clvalue(o)->c.isC) +typedef union TKey{ +struct{ +Value value;int tt; +struct Node*next; +}nk; +TValue tvk; +}TKey; +typedef struct Node{ +TValue i_val; +TKey i_key; +}Node; +typedef struct Table{ +GCObject*next;lu_byte tt;lu_byte marked; +lu_byte flags; +lu_byte lsizenode; +struct Table*metatable; +TValue*array; +Node*node; +Node*lastfree; +GCObject*gclist; +int sizearray; +}Table; +#define lmod(s,size)(check_exp((size&(size-1))==0,(cast(int,(s)&((size)-1))))) +#define twoto(x)((size_t)1<<(x)) +#define sizenode(t)(twoto((t)->lsizenode)) +static const TValue luaO_nilobject_; +#define ceillog2(x)(luaO_log2((x)-1)+1) +static int luaO_log2(unsigned int x); +#define gfasttm(g,et,e)((et)==NULL?NULL:((et)->flags&(1u<<(e)))?NULL:luaT_gettm(et,e,(g)->tmname[e])) +#define fasttm(l,et,e)gfasttm(G(l),et,e) +static const TValue*luaT_gettm(Table*events,TMS event,TString*ename); +#define luaM_reallocv(L,b,on,n,e)((cast(size_t,(n)+1)<=((size_t)(~(size_t)0)-2)/(e))?luaM_realloc_(L,(b),(on)*(e),(n)*(e)):luaM_toobig(L)) +#define luaM_freemem(L,b,s)luaM_realloc_(L,(b),(s),0) +#define luaM_free(L,b)luaM_realloc_(L,(b),sizeof(*(b)),0) +#define luaM_freearray(L,b,n,t)luaM_reallocv(L,(b),n,0,sizeof(t)) +#define luaM_malloc(L,t)luaM_realloc_(L,NULL,0,(t)) +#define luaM_new(L,t)cast(t*,luaM_malloc(L,sizeof(t))) +#define luaM_newvector(L,n,t)cast(t*,luaM_reallocv(L,NULL,0,n,sizeof(t))) +#define luaM_growvector(L,v,nelems,size,t,limit,e)if((nelems)+1>(size))((v)=cast(t*,luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) +#define luaM_reallocvector(L,v,oldn,n,t)((v)=cast(t*,luaM_reallocv(L,v,oldn,n,sizeof(t)))) +static void*luaM_realloc_(lua_State*L,void*block,size_t oldsize, +size_t size); +static void*luaM_toobig(lua_State*L); +static void*luaM_growaux_(lua_State*L,void*block,int*size, +size_t size_elem,int limit, +const char*errormsg); +typedef struct Zio ZIO; +#define char2int(c)cast(int,cast(unsigned char,(c))) +#define zgetc(z)(((z)->n--)>0?char2int(*(z)->p++):luaZ_fill(z)) +typedef struct Mbuffer{ +char*buffer; +size_t n; +size_t buffsize; +}Mbuffer; +#define luaZ_initbuffer(L,buff)((buff)->buffer=NULL,(buff)->buffsize=0) +#define luaZ_buffer(buff)((buff)->buffer) +#define luaZ_sizebuffer(buff)((buff)->buffsize) +#define luaZ_bufflen(buff)((buff)->n) +#define luaZ_resetbuffer(buff)((buff)->n=0) +#define luaZ_resizebuffer(L,buff,size)(luaM_reallocvector(L,(buff)->buffer,(buff)->buffsize,size,char),(buff)->buffsize=size) +#define luaZ_freebuffer(L,buff)luaZ_resizebuffer(L,buff,0) +struct Zio{ +size_t n; +const char*p; +lua_Reader reader; +void*data; +lua_State*L; +}; +static int luaZ_fill(ZIO*z); +struct lua_longjmp; +#define gt(L)(&L->l_gt) +#define registry(L)(&G(L)->l_registry) +typedef struct stringtable{ +GCObject**hash; +lu_int32 nuse; +int size; +}stringtable; +typedef struct CallInfo{ +StkId base; +StkId func; +StkId top; +const Instruction*savedpc; +int nresults; +int tailcalls; +}CallInfo; +#define curr_func(L)(clvalue(L->ci->func)) +#define ci_func(ci)(clvalue((ci)->func)) +#define f_isLua(ci)(!ci_func(ci)->c.isC) +#define isLua(ci)(ttisfunction((ci)->func)&&f_isLua(ci)) +typedef struct global_State{ +stringtable strt; +lua_Alloc frealloc; +void*ud; +lu_byte currentwhite; +lu_byte gcstate; +int sweepstrgc; +GCObject*rootgc; +GCObject**sweepgc; +GCObject*gray; +GCObject*grayagain; +GCObject*weak; +GCObject*tmudata; +Mbuffer buff; +lu_mem GCthreshold; +lu_mem totalbytes; +lu_mem estimate; +lu_mem gcdept; +int gcpause; +int gcstepmul; +lua_CFunction panic; +TValue l_registry; +struct lua_State*mainthread; +UpVal uvhead; +struct Table*mt[(8+1)]; +TString*tmname[TM_N]; +}global_State; +struct lua_State{ +GCObject*next;lu_byte tt;lu_byte marked; +lu_byte status; +StkId top; +StkId base; +global_State*l_G; +CallInfo*ci; +const Instruction*savedpc; +StkId stack_last; +StkId stack; +CallInfo*end_ci; +CallInfo*base_ci; +int stacksize; +int size_ci; +unsigned short nCcalls; +unsigned short baseCcalls; +lu_byte hookmask; +lu_byte allowhook; +int basehookcount; +int hookcount; +lua_Hook hook; +TValue l_gt; +TValue env; +GCObject*openupval; +GCObject*gclist; +struct lua_longjmp*errorJmp; +ptrdiff_t errfunc; +}; +#define G(L)(L->l_G) +union GCObject{ +GCheader gch; +union TString ts; +union Udata u; +union Closure cl; +struct Table h; +struct Proto p; +struct UpVal uv; +struct lua_State th; +}; +#define rawgco2ts(o)check_exp((o)->gch.tt==4,&((o)->ts)) +#define gco2ts(o)(&rawgco2ts(o)->tsv) +#define rawgco2u(o)check_exp((o)->gch.tt==7,&((o)->u)) +#define gco2u(o)(&rawgco2u(o)->uv) +#define gco2cl(o)check_exp((o)->gch.tt==6,&((o)->cl)) +#define gco2h(o)check_exp((o)->gch.tt==5,&((o)->h)) +#define gco2p(o)check_exp((o)->gch.tt==(8+1),&((o)->p)) +#define gco2uv(o)check_exp((o)->gch.tt==(8+2),&((o)->uv)) +#define ngcotouv(o)check_exp((o)==NULL||(o)->gch.tt==(8+2),&((o)->uv)) +#define gco2th(o)check_exp((o)->gch.tt==8,&((o)->th)) +#define obj2gco(v)(cast(GCObject*,(v))) +static void luaE_freethread(lua_State*L,lua_State*L1); +#define pcRel(pc,p)(cast(int,(pc)-(p)->code)-1) +#define getline_(f,pc)(((f)->lineinfo)?(f)->lineinfo[pc]:0) +#define resethookcount(L)(L->hookcount=L->basehookcount) +static void luaG_typeerror(lua_State*L,const TValue*o, +const char*opname); +static void luaG_runerror(lua_State*L,const char*fmt,...); +#define luaD_checkstack(L,n)if((char*)L->stack_last-(char*)L->top<=(n)*(int)sizeof(TValue))luaD_growstack(L,n);else condhardstacktests(luaD_reallocstack(L,L->stacksize-5-1)); +#define incr_top(L){luaD_checkstack(L,1);L->top++;} +#define savestack(L,p)((char*)(p)-(char*)L->stack) +#define restorestack(L,n)((TValue*)((char*)L->stack+(n))) +#define saveci(L,p)((char*)(p)-(char*)L->base_ci) +#define restoreci(L,n)((CallInfo*)((char*)L->base_ci+(n))) +typedef void(*Pfunc)(lua_State*L,void*ud); +static int luaD_poscall(lua_State*L,StkId firstResult); +static void luaD_reallocCI(lua_State*L,int newsize); +static void luaD_reallocstack(lua_State*L,int newsize); +static void luaD_growstack(lua_State*L,int n); +static void luaD_throw(lua_State*L,int errcode); +static void*luaM_growaux_(lua_State*L,void*block,int*size,size_t size_elems, +int limit,const char*errormsg){ +void*newblock; +int newsize; +if(*size>=limit/2){ +if(*size>=limit) +luaG_runerror(L,errormsg); +newsize=limit; +} +else{ +newsize=(*size)*2; +if(newsize<4) +newsize=4; +} +newblock=luaM_reallocv(L,block,*size,newsize,size_elems); +*size=newsize; +return newblock; +} +static void*luaM_toobig(lua_State*L){ +luaG_runerror(L,"memory allocation error: block too big"); +return NULL; +} +static void*luaM_realloc_(lua_State*L,void*block,size_t osize,size_t nsize){ +global_State*g=G(L); +block=(*g->frealloc)(g->ud,block,osize,nsize); +if(block==NULL&&nsize>0) +luaD_throw(L,4); +g->totalbytes=(g->totalbytes-osize)+nsize; +return block; +} +#define resetbits(x,m)((x)&=cast(lu_byte,~(m))) +#define setbits(x,m)((x)|=(m)) +#define testbits(x,m)((x)&(m)) +#define bitmask(b)(1<<(b)) +#define bit2mask(b1,b2)(bitmask(b1)|bitmask(b2)) +#define l_setbit(x,b)setbits(x,bitmask(b)) +#define resetbit(x,b)resetbits(x,bitmask(b)) +#define testbit(x,b)testbits(x,bitmask(b)) +#define set2bits(x,b1,b2)setbits(x,(bit2mask(b1,b2))) +#define reset2bits(x,b1,b2)resetbits(x,(bit2mask(b1,b2))) +#define test2bits(x,b1,b2)testbits(x,(bit2mask(b1,b2))) +#define iswhite(x)test2bits((x)->gch.marked,0,1) +#define isblack(x)testbit((x)->gch.marked,2) +#define isgray(x)(!isblack(x)&&!iswhite(x)) +#define otherwhite(g)(g->currentwhite^bit2mask(0,1)) +#define isdead(g,v)((v)->gch.marked&otherwhite(g)&bit2mask(0,1)) +#define changewhite(x)((x)->gch.marked^=bit2mask(0,1)) +#define gray2black(x)l_setbit((x)->gch.marked,2) +#define valiswhite(x)(iscollectable(x)&&iswhite(gcvalue(x))) +#define luaC_white(g)cast(lu_byte,(g)->currentwhite&bit2mask(0,1)) +#define luaC_checkGC(L){condhardstacktests(luaD_reallocstack(L,L->stacksize-5-1));if(G(L)->totalbytes>=G(L)->GCthreshold)luaC_step(L);} +#define luaC_barrier(L,p,v){if(valiswhite(v)&&isblack(obj2gco(p)))luaC_barrierf(L,obj2gco(p),gcvalue(v));} +#define luaC_barriert(L,t,v){if(valiswhite(v)&&isblack(obj2gco(t)))luaC_barrierback(L,t);} +#define luaC_objbarrier(L,p,o){if(iswhite(obj2gco(o))&&isblack(obj2gco(p)))luaC_barrierf(L,obj2gco(p),obj2gco(o));} +#define luaC_objbarriert(L,t,o){if(iswhite(obj2gco(o))&&isblack(obj2gco(t)))luaC_barrierback(L,t);} +static void luaC_step(lua_State*L); +static void luaC_link(lua_State*L,GCObject*o,lu_byte tt); +static void luaC_linkupval(lua_State*L,UpVal*uv); +static void luaC_barrierf(lua_State*L,GCObject*o,GCObject*v); +static void luaC_barrierback(lua_State*L,Table*t); +#define sizestring(s)(sizeof(union TString)+((s)->len+1)*sizeof(char)) +#define sizeudata(u)(sizeof(union Udata)+(u)->len) +#define luaS_new(L,s)(luaS_newlstr(L,s,strlen(s))) +#define luaS_newliteral(L,s)(luaS_newlstr(L,""s,(sizeof(s)/sizeof(char))-1)) +#define luaS_fix(s)l_setbit((s)->tsv.marked,5) +static TString*luaS_newlstr(lua_State*L,const char*str,size_t l); +#define tostring(L,o)((ttype(o)==4)||(luaV_tostring(L,o))) +#define tonumber(o,n)(ttype(o)==3||(((o)=luaV_tonumber(o,n))!=NULL)) +#define equalobj(L,o1,o2)(ttype(o1)==ttype(o2)&&luaV_equalval(L,o1,o2)) +static int luaV_equalval(lua_State*L,const TValue*t1,const TValue*t2); +static const TValue*luaV_tonumber(const TValue*obj,TValue*n); +static int luaV_tostring(lua_State*L,StkId obj); +static void luaV_execute(lua_State*L,int nexeccalls); +static void luaV_concat(lua_State*L,int total,int last); +static const TValue luaO_nilobject_={{NULL},0}; +static int luaO_int2fb(unsigned int x){ +int e=0; +while(x>=16){ +x=(x+1)>>1; +e++; +} +if(x<8)return x; +else return((e+1)<<3)|(cast_int(x)-8); +} +static int luaO_fb2int(int x){ +int e=(x>>3)&31; +if(e==0)return x; +else return((x&7)+8)<<(e-1); +} +static int luaO_log2(unsigned int x){ +static const lu_byte log_2[256]={ +0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, +6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, +7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, +7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, +8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, +8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, +8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, +8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 +}; +int l=-1; +while(x>=256){l+=8;x>>=8;} +return l+log_2[x]; +} +static int luaO_rawequalObj(const TValue*t1,const TValue*t2){ +if(ttype(t1)!=ttype(t2))return 0; +else switch(ttype(t1)){ +case 0: +return 1; +case 3: +return luai_numeq(nvalue(t1),nvalue(t2)); +case 1: +return bvalue(t1)==bvalue(t2); +case 2: +return pvalue(t1)==pvalue(t2); +default: +return gcvalue(t1)==gcvalue(t2); +} +} +static int luaO_str2d(const char*s,lua_Number*result){ +char*endptr; +*result=lua_str2number(s,&endptr); +if(endptr==s)return 0; +if(*endptr=='x'||*endptr=='X') +*result=cast_num(strtoul(s,&endptr,16)); +if(*endptr=='\0')return 1; +while(isspace(cast(unsigned char,*endptr)))endptr++; +if(*endptr!='\0')return 0; +return 1; +} +static void pushstr(lua_State*L,const char*str){ +setsvalue(L,L->top,luaS_new(L,str)); +incr_top(L); +} +static const char*luaO_pushvfstring(lua_State*L,const char*fmt,va_list argp){ +int n=1; +pushstr(L,""); +for(;;){ +const char*e=strchr(fmt,'%'); +if(e==NULL)break; +setsvalue(L,L->top,luaS_newlstr(L,fmt,e-fmt)); +incr_top(L); +switch(*(e+1)){ +case's':{ +const char*s=va_arg(argp,char*); +if(s==NULL)s="(null)"; +pushstr(L,s); +break; +} +case'c':{ +char buff[2]; +buff[0]=cast(char,va_arg(argp,int)); +buff[1]='\0'; +pushstr(L,buff); +break; +} +case'd':{ +setnvalue(L->top,cast_num(va_arg(argp,int))); +incr_top(L); +break; +} +case'f':{ +setnvalue(L->top,cast_num(va_arg(argp,l_uacNumber))); +incr_top(L); +break; +} +case'p':{ +char buff[4*sizeof(void*)+8]; +sprintf(buff,"%p",va_arg(argp,void*)); +pushstr(L,buff); +break; +} +case'%':{ +pushstr(L,"%"); +break; +} +default:{ +char buff[3]; +buff[0]='%'; +buff[1]=*(e+1); +buff[2]='\0'; +pushstr(L,buff); +break; +} +} +n+=2; +fmt=e+2; +} +pushstr(L,fmt); +luaV_concat(L,n+1,cast_int(L->top-L->base)-1); +L->top-=n; +return svalue(L->top-1); +} +static const char*luaO_pushfstring(lua_State*L,const char*fmt,...){ +const char*msg; +va_list argp; +va_start(argp,fmt); +msg=luaO_pushvfstring(L,fmt,argp); +va_end(argp); +return msg; +} +static void luaO_chunkid(char*out,const char*source,size_t bufflen){ +if(*source=='='){ +strncpy(out,source+1,bufflen); +out[bufflen-1]='\0'; +} +else{ +if(*source=='@'){ +size_t l; +source++; +bufflen-=sizeof(" '...' "); +l=strlen(source); +strcpy(out,""); +if(l>bufflen){ +source+=(l-bufflen); +strcat(out,"..."); +} +strcat(out,source); +} +else{ +size_t len=strcspn(source,"\n\r"); +bufflen-=sizeof(" [string \"...\"] "); +if(len>bufflen)len=bufflen; +strcpy(out,"[string \""); +if(source[len]!='\0'){ +strncat(out,source,len); +strcat(out,"..."); +} +else +strcat(out,source); +strcat(out,"\"]"); +} +} +} +#define gnode(t,i)(&(t)->node[i]) +#define gkey(n)(&(n)->i_key.nk) +#define gval(n)(&(n)->i_val) +#define gnext(n)((n)->i_key.nk.next) +#define key2tval(n)(&(n)->i_key.tvk) +static TValue*luaH_setnum(lua_State*L,Table*t,int key); +static const TValue*luaH_getstr(Table*t,TString*key); +static TValue*luaH_set(lua_State*L,Table*t,const TValue*key); +static const char*const luaT_typenames[]={ +"nil","boolean","userdata","number", +"string","table","function","userdata","thread", +"proto","upval" +}; +static void luaT_init(lua_State*L){ +static const char*const luaT_eventname[]={ +"__index","__newindex", +"__gc","__mode","__eq", +"__add","__sub","__mul","__div","__mod", +"__pow","__unm","__len","__lt","__le", +"__concat","__call" +}; +int i; +for(i=0;itmname[i]=luaS_new(L,luaT_eventname[i]); +luaS_fix(G(L)->tmname[i]); +} +} +static const TValue*luaT_gettm(Table*events,TMS event,TString*ename){ +const TValue*tm=luaH_getstr(events,ename); +if(ttisnil(tm)){ +events->flags|=cast_byte(1u<metatable; +break; +case 7: +mt=uvalue(o)->metatable; +break; +default: +mt=G(L)->mt[ttype(o)]; +} +return(mt?luaH_getstr(mt,G(L)->tmname[event]):(&luaO_nilobject_)); +} +#define sizeCclosure(n)(cast(int,sizeof(CClosure))+cast(int,sizeof(TValue)*((n)-1))) +#define sizeLclosure(n)(cast(int,sizeof(LClosure))+cast(int,sizeof(TValue*)*((n)-1))) +static Closure*luaF_newCclosure(lua_State*L,int nelems,Table*e){ +Closure*c=cast(Closure*,luaM_malloc(L,sizeCclosure(nelems))); +luaC_link(L,obj2gco(c),6); +c->c.isC=1; +c->c.env=e; +c->c.nupvalues=cast_byte(nelems); +return c; +} +static Closure*luaF_newLclosure(lua_State*L,int nelems,Table*e){ +Closure*c=cast(Closure*,luaM_malloc(L,sizeLclosure(nelems))); +luaC_link(L,obj2gco(c),6); +c->l.isC=0; +c->l.env=e; +c->l.nupvalues=cast_byte(nelems); +while(nelems--)c->l.upvals[nelems]=NULL; +return c; +} +static UpVal*luaF_newupval(lua_State*L){ +UpVal*uv=luaM_new(L,UpVal); +luaC_link(L,obj2gco(uv),(8+2)); +uv->v=&uv->u.value; +setnilvalue(uv->v); +return uv; +} +static UpVal*luaF_findupval(lua_State*L,StkId level){ +global_State*g=G(L); +GCObject**pp=&L->openupval; +UpVal*p; +UpVal*uv; +while(*pp!=NULL&&(p=ngcotouv(*pp))->v>=level){ +if(p->v==level){ +if(isdead(g,obj2gco(p))) +changewhite(obj2gco(p)); +return p; +} +pp=&p->next; +} +uv=luaM_new(L,UpVal); +uv->tt=(8+2); +uv->marked=luaC_white(g); +uv->v=level; +uv->next=*pp; +*pp=obj2gco(uv); +uv->u.l.prev=&g->uvhead; +uv->u.l.next=g->uvhead.u.l.next; +uv->u.l.next->u.l.prev=uv; +g->uvhead.u.l.next=uv; +return uv; +} +static void unlinkupval(UpVal*uv){ +uv->u.l.next->u.l.prev=uv->u.l.prev; +uv->u.l.prev->u.l.next=uv->u.l.next; +} +static void luaF_freeupval(lua_State*L,UpVal*uv){ +if(uv->v!=&uv->u.value) +unlinkupval(uv); +luaM_free(L,uv); +} +static void luaF_close(lua_State*L,StkId level){ +UpVal*uv; +global_State*g=G(L); +while(L->openupval!=NULL&&(uv=ngcotouv(L->openupval))->v>=level){ +GCObject*o=obj2gco(uv); +L->openupval=uv->next; +if(isdead(g,o)) +luaF_freeupval(L,uv); +else{ +unlinkupval(uv); +setobj(L,&uv->u.value,uv->v); +uv->v=&uv->u.value; +luaC_linkupval(L,uv); +} +} +} +static Proto*luaF_newproto(lua_State*L){ +Proto*f=luaM_new(L,Proto); +luaC_link(L,obj2gco(f),(8+1)); +f->k=NULL; +f->sizek=0; +f->p=NULL; +f->sizep=0; +f->code=NULL; +f->sizecode=0; +f->sizelineinfo=0; +f->sizeupvalues=0; +f->nups=0; +f->upvalues=NULL; +f->numparams=0; +f->is_vararg=0; +f->maxstacksize=0; +f->lineinfo=NULL; +f->sizelocvars=0; +f->locvars=NULL; +f->linedefined=0; +f->lastlinedefined=0; +f->source=NULL; +return f; +} +static void luaF_freeproto(lua_State*L,Proto*f){ +luaM_freearray(L,f->code,f->sizecode,Instruction); +luaM_freearray(L,f->p,f->sizep,Proto*); +luaM_freearray(L,f->k,f->sizek,TValue); +luaM_freearray(L,f->lineinfo,f->sizelineinfo,int); +luaM_freearray(L,f->locvars,f->sizelocvars,struct LocVar); +luaM_freearray(L,f->upvalues,f->sizeupvalues,TString*); +luaM_free(L,f); +} +static void luaF_freeclosure(lua_State*L,Closure*c){ +int size=(c->c.isC)?sizeCclosure(c->c.nupvalues): +sizeLclosure(c->l.nupvalues); +luaM_freemem(L,c,size); +} +#define MASK1(n,p)((~((~(Instruction)0)<>0)&MASK1(6,0))) +#define SET_OPCODE(i,o)((i)=(((i)&MASK0(6,0))|((cast(Instruction,o)<<0)&MASK1(6,0)))) +#define GETARG_A(i)(cast(int,((i)>>(0+6))&MASK1(8,0))) +#define SETARG_A(i,u)((i)=(((i)&MASK0(8,(0+6)))|((cast(Instruction,u)<<(0+6))&MASK1(8,(0+6))))) +#define GETARG_B(i)(cast(int,((i)>>(((0+6)+8)+9))&MASK1(9,0))) +#define SETARG_B(i,b)((i)=(((i)&MASK0(9,(((0+6)+8)+9)))|((cast(Instruction,b)<<(((0+6)+8)+9))&MASK1(9,(((0+6)+8)+9))))) +#define GETARG_C(i)(cast(int,((i)>>((0+6)+8))&MASK1(9,0))) +#define SETARG_C(i,b)((i)=(((i)&MASK0(9,((0+6)+8)))|((cast(Instruction,b)<<((0+6)+8))&MASK1(9,((0+6)+8))))) +#define GETARG_Bx(i)(cast(int,((i)>>((0+6)+8))&MASK1((9+9),0))) +#define SETARG_Bx(i,b)((i)=(((i)&MASK0((9+9),((0+6)+8)))|((cast(Instruction,b)<<((0+6)+8))&MASK1((9+9),((0+6)+8))))) +#define GETARG_sBx(i)(GETARG_Bx(i)-(((1<<(9+9))-1)>>1)) +#define SETARG_sBx(i,b)SETARG_Bx((i),cast(unsigned int,(b)+(((1<<(9+9))-1)>>1))) +#define CREATE_ABC(o,a,b,c)((cast(Instruction,o)<<0)|(cast(Instruction,a)<<(0+6))|(cast(Instruction,b)<<(((0+6)+8)+9))|(cast(Instruction,c)<<((0+6)+8))) +#define CREATE_ABx(o,a,bc)((cast(Instruction,o)<<0)|(cast(Instruction,a)<<(0+6))|(cast(Instruction,bc)<<((0+6)+8))) +#define ISK(x)((x)&(1<<(9-1))) +#define INDEXK(r)((int)(r)&~(1<<(9-1))) +#define RKASK(x)((x)|(1<<(9-1))) +static const lu_byte luaP_opmodes[(cast(int,OP_VARARG)+1)]; +#define getBMode(m)(cast(enum OpArgMask,(luaP_opmodes[m]>>4)&3)) +#define getCMode(m)(cast(enum OpArgMask,(luaP_opmodes[m]>>2)&3)) +#define testTMode(m)(luaP_opmodes[m]&(1<<7)) +typedef struct expdesc{ +expkind k; +union{ +struct{int info,aux;}s; +lua_Number nval; +}u; +int t; +int f; +}expdesc; +typedef struct upvaldesc{ +lu_byte k; +lu_byte info; +}upvaldesc; +struct BlockCnt; +typedef struct FuncState{ +Proto*f; +Table*h; +struct FuncState*prev; +struct LexState*ls; +struct lua_State*L; +struct BlockCnt*bl; +int pc; +int lasttarget; +int jpc; +int freereg; +int nk; +int np; +short nlocvars; +lu_byte nactvar; +upvaldesc upvalues[60]; +unsigned short actvar[200]; +}FuncState; +static Proto*luaY_parser(lua_State*L,ZIO*z,Mbuffer*buff, +const char*name); +struct lua_longjmp{ +struct lua_longjmp*previous; +jmp_buf b; +volatile int status; +}; +static void luaD_seterrorobj(lua_State*L,int errcode,StkId oldtop){ +switch(errcode){ +case 4:{ +setsvalue(L,oldtop,luaS_newliteral(L,"not enough memory")); +break; +} +case 5:{ +setsvalue(L,oldtop,luaS_newliteral(L,"error in error handling")); +break; +} +case 3: +case 2:{ +setobj(L,oldtop,L->top-1); +break; +} +} +L->top=oldtop+1; +} +static void restore_stack_limit(lua_State*L){ +if(L->size_ci>20000){ +int inuse=cast_int(L->ci-L->base_ci); +if(inuse+1<20000) +luaD_reallocCI(L,20000); +} +} +static void resetstack(lua_State*L,int status){ +L->ci=L->base_ci; +L->base=L->ci->base; +luaF_close(L,L->base); +luaD_seterrorobj(L,status,L->base); +L->nCcalls=L->baseCcalls; +L->allowhook=1; +restore_stack_limit(L); +L->errfunc=0; +L->errorJmp=NULL; +} +static void luaD_throw(lua_State*L,int errcode){ +if(L->errorJmp){ +L->errorJmp->status=errcode; +LUAI_THROW(L,L->errorJmp); +} +else{ +L->status=cast_byte(errcode); +if(G(L)->panic){ +resetstack(L,errcode); +G(L)->panic(L); +} +exit(EXIT_FAILURE); +} +} +static int luaD_rawrunprotected(lua_State*L,Pfunc f,void*ud){ +struct lua_longjmp lj; +lj.status=0; +lj.previous=L->errorJmp; +L->errorJmp=&lj; +LUAI_TRY(L,&lj, +(*f)(L,ud); +); +L->errorJmp=lj.previous; +return lj.status; +} +static void correctstack(lua_State*L,TValue*oldstack){ +CallInfo*ci; +GCObject*up; +L->top=(L->top-oldstack)+L->stack; +for(up=L->openupval;up!=NULL;up=up->gch.next) +gco2uv(up)->v=(gco2uv(up)->v-oldstack)+L->stack; +for(ci=L->base_ci;ci<=L->ci;ci++){ +ci->top=(ci->top-oldstack)+L->stack; +ci->base=(ci->base-oldstack)+L->stack; +ci->func=(ci->func-oldstack)+L->stack; +} +L->base=(L->base-oldstack)+L->stack; +} +static void luaD_reallocstack(lua_State*L,int newsize){ +TValue*oldstack=L->stack; +int realsize=newsize+1+5; +luaM_reallocvector(L,L->stack,L->stacksize,realsize,TValue); +L->stacksize=realsize; +L->stack_last=L->stack+newsize; +correctstack(L,oldstack); +} +static void luaD_reallocCI(lua_State*L,int newsize){ +CallInfo*oldci=L->base_ci; +luaM_reallocvector(L,L->base_ci,L->size_ci,newsize,CallInfo); +L->size_ci=newsize; +L->ci=(L->ci-oldci)+L->base_ci; +L->end_ci=L->base_ci+L->size_ci-1; +} +static void luaD_growstack(lua_State*L,int n){ +if(n<=L->stacksize) +luaD_reallocstack(L,2*L->stacksize); +else +luaD_reallocstack(L,L->stacksize+n); +} +static CallInfo*growCI(lua_State*L){ +if(L->size_ci>20000) +luaD_throw(L,5); +else{ +luaD_reallocCI(L,2*L->size_ci); +if(L->size_ci>20000) +luaG_runerror(L,"stack overflow"); +} +return++L->ci; +} +static StkId adjust_varargs(lua_State*L,Proto*p,int actual){ +int i; +int nfixargs=p->numparams; +Table*htab=NULL; +StkId base,fixed; +for(;actualtop++); +fixed=L->top-actual; +base=L->top; +for(i=0;itop++,fixed+i); +setnilvalue(fixed+i); +} +if(htab){ +sethvalue(L,L->top++,htab); +} +return base; +} +static StkId tryfuncTM(lua_State*L,StkId func){ +const TValue*tm=luaT_gettmbyobj(L,func,TM_CALL); +StkId p; +ptrdiff_t funcr=savestack(L,func); +if(!ttisfunction(tm)) +luaG_typeerror(L,func,"call"); +for(p=L->top;p>func;p--)setobj(L,p,p-1); +incr_top(L); +func=restorestack(L,funcr); +setobj(L,func,tm); +return func; +} +#define inc_ci(L)((L->ci==L->end_ci)?growCI(L):(condhardstacktests(luaD_reallocCI(L,L->size_ci)),++L->ci)) +static int luaD_precall(lua_State*L,StkId func,int nresults){ +LClosure*cl; +ptrdiff_t funcr; +if(!ttisfunction(func)) +func=tryfuncTM(L,func); +funcr=savestack(L,func); +cl=&clvalue(func)->l; +L->ci->savedpc=L->savedpc; +if(!cl->isC){ +CallInfo*ci; +StkId st,base; +Proto*p=cl->p; +luaD_checkstack(L,p->maxstacksize); +func=restorestack(L,funcr); +if(!p->is_vararg){ +base=func+1; +if(L->top>base+p->numparams) +L->top=base+p->numparams; +} +else{ +int nargs=cast_int(L->top-func)-1; +base=adjust_varargs(L,p,nargs); +func=restorestack(L,funcr); +} +ci=inc_ci(L); +ci->func=func; +L->base=ci->base=base; +ci->top=L->base+p->maxstacksize; +L->savedpc=p->code; +ci->tailcalls=0; +ci->nresults=nresults; +for(st=L->top;sttop;st++) +setnilvalue(st); +L->top=ci->top; +return 0; +} +else{ +CallInfo*ci; +int n; +luaD_checkstack(L,20); +ci=inc_ci(L); +ci->func=restorestack(L,funcr); +L->base=ci->base=ci->func+1; +ci->top=L->top+20; +ci->nresults=nresults; +n=(*curr_func(L)->c.f)(L); +if(n<0) +return 2; +else{ +luaD_poscall(L,L->top-n); +return 1; +} +} +} +static int luaD_poscall(lua_State*L,StkId firstResult){ +StkId res; +int wanted,i; +CallInfo*ci; +ci=L->ci--; +res=ci->func; +wanted=ci->nresults; +L->base=(ci-1)->base; +L->savedpc=(ci-1)->savedpc; +for(i=wanted;i!=0&&firstResulttop;i--) +setobj(L,res++,firstResult++); +while(i-->0) +setnilvalue(res++); +L->top=res; +return(wanted-(-1)); +} +static void luaD_call(lua_State*L,StkId func,int nResults){ +if(++L->nCcalls>=200){ +if(L->nCcalls==200) +luaG_runerror(L,"C stack overflow"); +else if(L->nCcalls>=(200+(200>>3))) +luaD_throw(L,5); +} +if(luaD_precall(L,func,nResults)==0) +luaV_execute(L,1); +L->nCcalls--; +luaC_checkGC(L); +} +static int luaD_pcall(lua_State*L,Pfunc func,void*u, +ptrdiff_t old_top,ptrdiff_t ef){ +int status; +unsigned short oldnCcalls=L->nCcalls; +ptrdiff_t old_ci=saveci(L,L->ci); +lu_byte old_allowhooks=L->allowhook; +ptrdiff_t old_errfunc=L->errfunc; +L->errfunc=ef; +status=luaD_rawrunprotected(L,func,u); +if(status!=0){ +StkId oldtop=restorestack(L,old_top); +luaF_close(L,oldtop); +luaD_seterrorobj(L,status,oldtop); +L->nCcalls=oldnCcalls; +L->ci=restoreci(L,old_ci); +L->base=L->ci->base; +L->savedpc=L->ci->savedpc; +L->allowhook=old_allowhooks; +restore_stack_limit(L); +} +L->errfunc=old_errfunc; +return status; +} +struct SParser{ +ZIO*z; +Mbuffer buff; +const char*name; +}; +static void f_parser(lua_State*L,void*ud){ +int i; +Proto*tf; +Closure*cl; +struct SParser*p=cast(struct SParser*,ud); +luaC_checkGC(L); +tf=luaY_parser(L,p->z, +&p->buff,p->name); +cl=luaF_newLclosure(L,tf->nups,hvalue(gt(L))); +cl->l.p=tf; +for(i=0;inups;i++) +cl->l.upvals[i]=luaF_newupval(L); +setclvalue(L,L->top,cl); +incr_top(L); +} +static int luaD_protectedparser(lua_State*L,ZIO*z,const char*name){ +struct SParser p; +int status; +p.z=z;p.name=name; +luaZ_initbuffer(L,&p.buff); +status=luaD_pcall(L,f_parser,&p,savestack(L,L->top),L->errfunc); +luaZ_freebuffer(L,&p.buff); +return status; +} +static void luaS_resize(lua_State*L,int newsize){ +GCObject**newhash; +stringtable*tb; +int i; +if(G(L)->gcstate==2) +return; +newhash=luaM_newvector(L,newsize,GCObject*); +tb=&G(L)->strt; +for(i=0;isize;i++){ +GCObject*p=tb->hash[i]; +while(p){ +GCObject*next=p->gch.next; +unsigned int h=gco2ts(p)->hash; +int h1=lmod(h,newsize); +p->gch.next=newhash[h1]; +newhash[h1]=p; +p=next; +} +} +luaM_freearray(L,tb->hash,tb->size,TString*); +tb->size=newsize; +tb->hash=newhash; +} +static TString*newlstr(lua_State*L,const char*str,size_t l, +unsigned int h){ +TString*ts; +stringtable*tb; +if(l+1>(((size_t)(~(size_t)0)-2)-sizeof(TString))/sizeof(char)) +luaM_toobig(L); +ts=cast(TString*,luaM_malloc(L,(l+1)*sizeof(char)+sizeof(TString))); +ts->tsv.len=l; +ts->tsv.hash=h; +ts->tsv.marked=luaC_white(G(L)); +ts->tsv.tt=4; +ts->tsv.reserved=0; +memcpy(ts+1,str,l*sizeof(char)); +((char*)(ts+1))[l]='\0'; +tb=&G(L)->strt; +h=lmod(h,tb->size); +ts->tsv.next=tb->hash[h]; +tb->hash[h]=obj2gco(ts); +tb->nuse++; +if(tb->nuse>cast(lu_int32,tb->size)&&tb->size<=(INT_MAX-2)/2) +luaS_resize(L,tb->size*2); +return ts; +} +static TString*luaS_newlstr(lua_State*L,const char*str,size_t l){ +GCObject*o; +unsigned int h=cast(unsigned int,l); +size_t step=(l>>5)+1; +size_t l1; +for(l1=l;l1>=step;l1-=step) +h=h^((h<<5)+(h>>2)+cast(unsigned char,str[l1-1])); +for(o=G(L)->strt.hash[lmod(h,G(L)->strt.size)]; +o!=NULL; +o=o->gch.next){ +TString*ts=rawgco2ts(o); +if(ts->tsv.len==l&&(memcmp(str,getstr(ts),l)==0)){ +if(isdead(G(L),o))changewhite(o); +return ts; +} +} +return newlstr(L,str,l,h); +} +static Udata*luaS_newudata(lua_State*L,size_t s,Table*e){ +Udata*u; +if(s>((size_t)(~(size_t)0)-2)-sizeof(Udata)) +luaM_toobig(L); +u=cast(Udata*,luaM_malloc(L,s+sizeof(Udata))); +u->uv.marked=luaC_white(G(L)); +u->uv.tt=7; +u->uv.len=s; +u->uv.metatable=NULL; +u->uv.env=e; +u->uv.next=G(L)->mainthread->next; +G(L)->mainthread->next=obj2gco(u); +return u; +} +#define hashpow2(t,n)(gnode(t,lmod((n),sizenode(t)))) +#define hashstr(t,str)hashpow2(t,(str)->tsv.hash) +#define hashboolean(t,p)hashpow2(t,p) +#define hashmod(t,n)(gnode(t,((n)%((sizenode(t)-1)|1)))) +#define hashpointer(t,p)hashmod(t,IntPoint(p)) +static const Node dummynode_={ +{{NULL},0}, +{{{NULL},0,NULL}} +}; +static Node*hashnum(const Table*t,lua_Number n){ +unsigned int a[cast_int(sizeof(lua_Number)/sizeof(int))]; +int i; +if(luai_numeq(n,0)) +return gnode(t,0); +memcpy(a,&n,sizeof(a)); +for(i=1;isizearray) +return i-1; +else{ +Node*n=mainposition(t,key); +do{ +if(luaO_rawequalObj(key2tval(n),key)|| +(ttype(gkey(n))==(8+3)&&iscollectable(key)&& +gcvalue(gkey(n))==gcvalue(key))){ +i=cast_int(n-gnode(t,0)); +return i+t->sizearray; +} +else n=gnext(n); +}while(n); +luaG_runerror(L,"invalid key to "LUA_QL("next")); +return 0; +} +} +static int luaH_next(lua_State*L,Table*t,StkId key){ +int i=findindex(L,t,key); +for(i++;isizearray;i++){ +if(!ttisnil(&t->array[i])){ +setnvalue(key,cast_num(i+1)); +setobj(L,key+1,&t->array[i]); +return 1; +} +} +for(i-=t->sizearray;i<(int)sizenode(t);i++){ +if(!ttisnil(gval(gnode(t,i)))){ +setobj(L,key,key2tval(gnode(t,i))); +setobj(L,key+1,gval(gnode(t,i))); +return 1; +} +} +return 0; +} +static int computesizes(int nums[],int*narray){ +int i; +int twotoi; +int a=0; +int na=0; +int n=0; +for(i=0,twotoi=1;twotoi/2<*narray;i++,twotoi*=2){ +if(nums[i]>0){ +a+=nums[i]; +if(a>twotoi/2){ +n=twotoi; +na=a; +} +} +if(a==*narray)break; +} +*narray=n; +return na; +} +static int countint(const TValue*key,int*nums){ +int k=arrayindex(key); +if(0t->sizearray){ +lim=t->sizearray; +if(i>lim) +break; +} +for(;i<=lim;i++){ +if(!ttisnil(&t->array[i-1])) +lc++; +} +nums[lg]+=lc; +ause+=lc; +} +return ause; +} +static int numusehash(const Table*t,int*nums,int*pnasize){ +int totaluse=0; +int ause=0; +int i=sizenode(t); +while(i--){ +Node*n=&t->node[i]; +if(!ttisnil(gval(n))){ +ause+=countint(key2tval(n),nums); +totaluse++; +} +} +*pnasize+=ause; +return totaluse; +} +static void setarrayvector(lua_State*L,Table*t,int size){ +int i; +luaM_reallocvector(L,t->array,t->sizearray,size,TValue); +for(i=t->sizearray;iarray[i]); +t->sizearray=size; +} +static void setnodevector(lua_State*L,Table*t,int size){ +int lsize; +if(size==0){ +t->node=cast(Node*,(&dummynode_)); +lsize=0; +} +else{ +int i; +lsize=ceillog2(size); +if(lsize>(32-2)) +luaG_runerror(L,"table overflow"); +size=twoto(lsize); +t->node=luaM_newvector(L,size,Node); +for(i=0;ilsizenode=cast_byte(lsize); +t->lastfree=gnode(t,size); +} +static void resize(lua_State*L,Table*t,int nasize,int nhsize){ +int i; +int oldasize=t->sizearray; +int oldhsize=t->lsizenode; +Node*nold=t->node; +if(nasize>oldasize) +setarrayvector(L,t,nasize); +setnodevector(L,t,nhsize); +if(nasizesizearray=nasize; +for(i=nasize;iarray[i])) +setobj(L,luaH_setnum(L,t,i+1),&t->array[i]); +} +luaM_reallocvector(L,t->array,oldasize,nasize,TValue); +} +for(i=twoto(oldhsize)-1;i>=0;i--){ +Node*old=nold+i; +if(!ttisnil(gval(old))) +setobj(L,luaH_set(L,t,key2tval(old)),gval(old)); +} +if(nold!=(&dummynode_)) +luaM_freearray(L,nold,twoto(oldhsize),Node); +} +static void luaH_resizearray(lua_State*L,Table*t,int nasize){ +int nsize=(t->node==(&dummynode_))?0:sizenode(t); +resize(L,t,nasize,nsize); +} +static void rehash(lua_State*L,Table*t,const TValue*ek){ +int nasize,na; +int nums[(32-2)+1]; +int i; +int totaluse; +for(i=0;i<=(32-2);i++)nums[i]=0; +nasize=numusearray(t,nums); +totaluse=nasize; +totaluse+=numusehash(t,nums,&nasize); +nasize+=countint(ek,nums); +totaluse++; +na=computesizes(nums,&nasize); +resize(L,t,nasize,totaluse-na); +} +static Table*luaH_new(lua_State*L,int narray,int nhash){ +Table*t=luaM_new(L,Table); +luaC_link(L,obj2gco(t),5); +t->metatable=NULL; +t->flags=cast_byte(~0); +t->array=NULL; +t->sizearray=0; +t->lsizenode=0; +t->node=cast(Node*,(&dummynode_)); +setarrayvector(L,t,narray); +setnodevector(L,t,nhash); +return t; +} +static void luaH_free(lua_State*L,Table*t){ +if(t->node!=(&dummynode_)) +luaM_freearray(L,t->node,sizenode(t),Node); +luaM_freearray(L,t->array,t->sizearray,TValue); +luaM_free(L,t); +} +static Node*getfreepos(Table*t){ +while(t->lastfree-->t->node){ +if(ttisnil(gkey(t->lastfree))) +return t->lastfree; +} +return NULL; +} +static TValue*newkey(lua_State*L,Table*t,const TValue*key){ +Node*mp=mainposition(t,key); +if(!ttisnil(gval(mp))||mp==(&dummynode_)){ +Node*othern; +Node*n=getfreepos(t); +if(n==NULL){ +rehash(L,t,key); +return luaH_set(L,t,key); +} +othern=mainposition(t,key2tval(mp)); +if(othern!=mp){ +while(gnext(othern)!=mp)othern=gnext(othern); +gnext(othern)=n; +*n=*mp; +gnext(mp)=NULL; +setnilvalue(gval(mp)); +} +else{ +gnext(n)=gnext(mp); +gnext(mp)=n; +mp=n; +} +} +gkey(mp)->value=key->value;gkey(mp)->tt=key->tt; +luaC_barriert(L,t,key); +return gval(mp); +} +static const TValue*luaH_getnum(Table*t,int key){ +if(cast(unsigned int,key)-1sizearray)) +return&t->array[key-1]; +else{ +lua_Number nk=cast_num(key); +Node*n=hashnum(t,nk); +do{ +if(ttisnumber(gkey(n))&&luai_numeq(nvalue(gkey(n)),nk)) +return gval(n); +else n=gnext(n); +}while(n); +return(&luaO_nilobject_); +} +} +static const TValue*luaH_getstr(Table*t,TString*key){ +Node*n=hashstr(t,key); +do{ +if(ttisstring(gkey(n))&&rawtsvalue(gkey(n))==key) +return gval(n); +else n=gnext(n); +}while(n); +return(&luaO_nilobject_); +} +static const TValue*luaH_get(Table*t,const TValue*key){ +switch(ttype(key)){ +case 0:return(&luaO_nilobject_); +case 4:return luaH_getstr(t,rawtsvalue(key)); +case 3:{ +int k; +lua_Number n=nvalue(key); +lua_number2int(k,n); +if(luai_numeq(cast_num(k),nvalue(key))) +return luaH_getnum(t,k); +} +default:{ +Node*n=mainposition(t,key); +do{ +if(luaO_rawequalObj(key2tval(n),key)) +return gval(n); +else n=gnext(n); +}while(n); +return(&luaO_nilobject_); +} +} +} +static TValue*luaH_set(lua_State*L,Table*t,const TValue*key){ +const TValue*p=luaH_get(t,key); +t->flags=0; +if(p!=(&luaO_nilobject_)) +return cast(TValue*,p); +else{ +if(ttisnil(key))luaG_runerror(L,"table index is nil"); +else if(ttisnumber(key)&&luai_numisnan(nvalue(key))) +luaG_runerror(L,"table index is NaN"); +return newkey(L,t,key); +} +} +static TValue*luaH_setnum(lua_State*L,Table*t,int key){ +const TValue*p=luaH_getnum(t,key); +if(p!=(&luaO_nilobject_)) +return cast(TValue*,p); +else{ +TValue k; +setnvalue(&k,cast_num(key)); +return newkey(L,t,&k); +} +} +static TValue*luaH_setstr(lua_State*L,Table*t,TString*key){ +const TValue*p=luaH_getstr(t,key); +if(p!=(&luaO_nilobject_)) +return cast(TValue*,p); +else{ +TValue k; +setsvalue(L,&k,key); +return newkey(L,t,&k); +} +} +static int unbound_search(Table*t,unsigned int j){ +unsigned int i=j; +j++; +while(!ttisnil(luaH_getnum(t,j))){ +i=j; +j*=2; +if(j>cast(unsigned int,(INT_MAX-2))){ +i=1; +while(!ttisnil(luaH_getnum(t,i)))i++; +return i-1; +} +} +while(j-i>1){ +unsigned int m=(i+j)/2; +if(ttisnil(luaH_getnum(t,m)))j=m; +else i=m; +} +return i; +} +static int luaH_getn(Table*t){ +unsigned int j=t->sizearray; +if(j>0&&ttisnil(&t->array[j-1])){ +unsigned int i=0; +while(j-i>1){ +unsigned int m=(i+j)/2; +if(ttisnil(&t->array[m-1]))j=m; +else i=m; +} +return i; +} +else if(t->node==(&dummynode_)) +return j; +else return unbound_search(t,j); +} +#define makewhite(g,x)((x)->gch.marked=cast_byte(((x)->gch.marked&cast_byte(~(bitmask(2)|bit2mask(0,1))))|luaC_white(g))) +#define white2gray(x)reset2bits((x)->gch.marked,0,1) +#define black2gray(x)resetbit((x)->gch.marked,2) +#define stringmark(s)reset2bits((s)->tsv.marked,0,1) +#define isfinalized(u)testbit((u)->marked,3) +#define markfinalized(u)l_setbit((u)->marked,3) +#define markvalue(g,o){checkconsistency(o);if(iscollectable(o)&&iswhite(gcvalue(o)))reallymarkobject(g,gcvalue(o));} +#define markobject(g,t){if(iswhite(obj2gco(t)))reallymarkobject(g,obj2gco(t));} +#define setthreshold(g)(g->GCthreshold=(g->estimate/100)*g->gcpause) +static void removeentry(Node*n){ +if(iscollectable(gkey(n))) +setttype(gkey(n),(8+3)); +} +static void reallymarkobject(global_State*g,GCObject*o){ +white2gray(o); +switch(o->gch.tt){ +case 4:{ +return; +} +case 7:{ +Table*mt=gco2u(o)->metatable; +gray2black(o); +if(mt)markobject(g,mt); +markobject(g,gco2u(o)->env); +return; +} +case(8+2):{ +UpVal*uv=gco2uv(o); +markvalue(g,uv->v); +if(uv->v==&uv->u.value) +gray2black(o); +return; +} +case 6:{ +gco2cl(o)->c.gclist=g->gray; +g->gray=o; +break; +} +case 5:{ +gco2h(o)->gclist=g->gray; +g->gray=o; +break; +} +case 8:{ +gco2th(o)->gclist=g->gray; +g->gray=o; +break; +} +case(8+1):{ +gco2p(o)->gclist=g->gray; +g->gray=o; +break; +} +default:; +} +} +static void marktmu(global_State*g){ +GCObject*u=g->tmudata; +if(u){ +do{ +u=u->gch.next; +makewhite(g,u); +reallymarkobject(g,u); +}while(u!=g->tmudata); +} +} +static size_t luaC_separateudata(lua_State*L,int all){ +global_State*g=G(L); +size_t deadmem=0; +GCObject**p=&g->mainthread->next; +GCObject*curr; +while((curr=*p)!=NULL){ +if(!(iswhite(curr)||all)||isfinalized(gco2u(curr))) +p=&curr->gch.next; +else if(fasttm(L,gco2u(curr)->metatable,TM_GC)==NULL){ +markfinalized(gco2u(curr)); +p=&curr->gch.next; +} +else{ +deadmem+=sizeudata(gco2u(curr)); +markfinalized(gco2u(curr)); +*p=curr->gch.next; +if(g->tmudata==NULL) +g->tmudata=curr->gch.next=curr; +else{ +curr->gch.next=g->tmudata->gch.next; +g->tmudata->gch.next=curr; +g->tmudata=curr; +} +} +} +return deadmem; +} +static int traversetable(global_State*g,Table*h){ +int i; +int weakkey=0; +int weakvalue=0; +const TValue*mode; +if(h->metatable) +markobject(g,h->metatable); +mode=gfasttm(g,h->metatable,TM_MODE); +if(mode&&ttisstring(mode)){ +weakkey=(strchr(svalue(mode),'k')!=NULL); +weakvalue=(strchr(svalue(mode),'v')!=NULL); +if(weakkey||weakvalue){ +h->marked&=~(bitmask(3)|bitmask(4)); +h->marked|=cast_byte((weakkey<<3)| +(weakvalue<<4)); +h->gclist=g->weak; +g->weak=obj2gco(h); +} +} +if(weakkey&&weakvalue)return 1; +if(!weakvalue){ +i=h->sizearray; +while(i--) +markvalue(g,&h->array[i]); +} +i=sizenode(h); +while(i--){ +Node*n=gnode(h,i); +if(ttisnil(gval(n))) +removeentry(n); +else{ +if(!weakkey)markvalue(g,gkey(n)); +if(!weakvalue)markvalue(g,gval(n)); +} +} +return weakkey||weakvalue; +} +static void traverseproto(global_State*g,Proto*f){ +int i; +if(f->source)stringmark(f->source); +for(i=0;isizek;i++) +markvalue(g,&f->k[i]); +for(i=0;isizeupvalues;i++){ +if(f->upvalues[i]) +stringmark(f->upvalues[i]); +} +for(i=0;isizep;i++){ +if(f->p[i]) +markobject(g,f->p[i]); +} +for(i=0;isizelocvars;i++){ +if(f->locvars[i].varname) +stringmark(f->locvars[i].varname); +} +} +static void traverseclosure(global_State*g,Closure*cl){ +markobject(g,cl->c.env); +if(cl->c.isC){ +int i; +for(i=0;ic.nupvalues;i++) +markvalue(g,&cl->c.upvalue[i]); +} +else{ +int i; +markobject(g,cl->l.p); +for(i=0;il.nupvalues;i++) +markobject(g,cl->l.upvals[i]); +} +} +static void checkstacksizes(lua_State*L,StkId max){ +int ci_used=cast_int(L->ci-L->base_ci); +int s_used=cast_int(max-L->stack); +if(L->size_ci>20000) +return; +if(4*ci_usedsize_ci&&2*8size_ci) +luaD_reallocCI(L,L->size_ci/2); +condhardstacktests(luaD_reallocCI(L,ci_used+1)); +if(4*s_usedstacksize&& +2*((2*20)+5)stacksize) +luaD_reallocstack(L,L->stacksize/2); +condhardstacktests(luaD_reallocstack(L,s_used)); +} +static void traversestack(global_State*g,lua_State*l){ +StkId o,lim; +CallInfo*ci; +markvalue(g,gt(l)); +lim=l->top; +for(ci=l->base_ci;ci<=l->ci;ci++){ +if(limtop)lim=ci->top; +} +for(o=l->stack;otop;o++) +markvalue(g,o); +for(;o<=lim;o++) +setnilvalue(o); +checkstacksizes(l,lim); +} +static l_mem propagatemark(global_State*g){ +GCObject*o=g->gray; +gray2black(o); +switch(o->gch.tt){ +case 5:{ +Table*h=gco2h(o); +g->gray=h->gclist; +if(traversetable(g,h)) +black2gray(o); +return sizeof(Table)+sizeof(TValue)*h->sizearray+ +sizeof(Node)*sizenode(h); +} +case 6:{ +Closure*cl=gco2cl(o); +g->gray=cl->c.gclist; +traverseclosure(g,cl); +return(cl->c.isC)?sizeCclosure(cl->c.nupvalues): +sizeLclosure(cl->l.nupvalues); +} +case 8:{ +lua_State*th=gco2th(o); +g->gray=th->gclist; +th->gclist=g->grayagain; +g->grayagain=o; +black2gray(o); +traversestack(g,th); +return sizeof(lua_State)+sizeof(TValue)*th->stacksize+ +sizeof(CallInfo)*th->size_ci; +} +case(8+1):{ +Proto*p=gco2p(o); +g->gray=p->gclist; +traverseproto(g,p); +return sizeof(Proto)+sizeof(Instruction)*p->sizecode+ +sizeof(Proto*)*p->sizep+ +sizeof(TValue)*p->sizek+ +sizeof(int)*p->sizelineinfo+ +sizeof(LocVar)*p->sizelocvars+ +sizeof(TString*)*p->sizeupvalues; +} +default:return 0; +} +} +static size_t propagateall(global_State*g){ +size_t m=0; +while(g->gray)m+=propagatemark(g); +return m; +} +static int iscleared(const TValue*o,int iskey){ +if(!iscollectable(o))return 0; +if(ttisstring(o)){ +stringmark(rawtsvalue(o)); +return 0; +} +return iswhite(gcvalue(o))|| +(ttisuserdata(o)&&(!iskey&&isfinalized(uvalue(o)))); +} +static void cleartable(GCObject*l){ +while(l){ +Table*h=gco2h(l); +int i=h->sizearray; +if(testbit(h->marked,4)){ +while(i--){ +TValue*o=&h->array[i]; +if(iscleared(o,0)) +setnilvalue(o); +} +} +i=sizenode(h); +while(i--){ +Node*n=gnode(h,i); +if(!ttisnil(gval(n))&& +(iscleared(key2tval(n),1)||iscleared(gval(n),0))){ +setnilvalue(gval(n)); +removeentry(n); +} +} +l=h->gclist; +} +} +static void freeobj(lua_State*L,GCObject*o){ +switch(o->gch.tt){ +case(8+1):luaF_freeproto(L,gco2p(o));break; +case 6:luaF_freeclosure(L,gco2cl(o));break; +case(8+2):luaF_freeupval(L,gco2uv(o));break; +case 5:luaH_free(L,gco2h(o));break; +case 8:{ +luaE_freethread(L,gco2th(o)); +break; +} +case 4:{ +G(L)->strt.nuse--; +luaM_freemem(L,o,sizestring(gco2ts(o))); +break; +} +case 7:{ +luaM_freemem(L,o,sizeudata(gco2u(o))); +break; +} +default:; +} +} +#define sweepwholelist(L,p)sweeplist(L,p,((lu_mem)(~(lu_mem)0)-2)) +static GCObject**sweeplist(lua_State*L,GCObject**p,lu_mem count){ +GCObject*curr; +global_State*g=G(L); +int deadmask=otherwhite(g); +while((curr=*p)!=NULL&&count-->0){ +if(curr->gch.tt==8) +sweepwholelist(L,&gco2th(curr)->openupval); +if((curr->gch.marked^bit2mask(0,1))&deadmask){ +makewhite(g,curr); +p=&curr->gch.next; +} +else{ +*p=curr->gch.next; +if(curr==g->rootgc) +g->rootgc=curr->gch.next; +freeobj(L,curr); +} +} +return p; +} +static void checkSizes(lua_State*L){ +global_State*g=G(L); +if(g->strt.nusestrt.size/4)&& +g->strt.size>32*2) +luaS_resize(L,g->strt.size/2); +if(luaZ_sizebuffer(&g->buff)>32*2){ +size_t newsize=luaZ_sizebuffer(&g->buff)/2; +luaZ_resizebuffer(L,&g->buff,newsize); +} +} +static void GCTM(lua_State*L){ +global_State*g=G(L); +GCObject*o=g->tmudata->gch.next; +Udata*udata=rawgco2u(o); +const TValue*tm; +if(o==g->tmudata) +g->tmudata=NULL; +else +g->tmudata->gch.next=udata->uv.next; +udata->uv.next=g->mainthread->next; +g->mainthread->next=o; +makewhite(g,o); +tm=fasttm(L,udata->uv.metatable,TM_GC); +if(tm!=NULL){ +lu_byte oldah=L->allowhook; +lu_mem oldt=g->GCthreshold; +L->allowhook=0; +g->GCthreshold=2*g->totalbytes; +setobj(L,L->top,tm); +setuvalue(L,L->top+1,udata); +L->top+=2; +luaD_call(L,L->top-2,0); +L->allowhook=oldah; +g->GCthreshold=oldt; +} +} +static void luaC_callGCTM(lua_State*L){ +while(G(L)->tmudata) +GCTM(L); +} +static void luaC_freeall(lua_State*L){ +global_State*g=G(L); +int i; +g->currentwhite=bit2mask(0,1)|bitmask(6); +sweepwholelist(L,&g->rootgc); +for(i=0;istrt.size;i++) +sweepwholelist(L,&g->strt.hash[i]); +} +static void markmt(global_State*g){ +int i; +for(i=0;i<(8+1);i++) +if(g->mt[i])markobject(g,g->mt[i]); +} +static void markroot(lua_State*L){ +global_State*g=G(L); +g->gray=NULL; +g->grayagain=NULL; +g->weak=NULL; +markobject(g,g->mainthread); +markvalue(g,gt(g->mainthread)); +markvalue(g,registry(L)); +markmt(g); +g->gcstate=1; +} +static void remarkupvals(global_State*g){ +UpVal*uv; +for(uv=g->uvhead.u.l.next;uv!=&g->uvhead;uv=uv->u.l.next){ +if(isgray(obj2gco(uv))) +markvalue(g,uv->v); +} +} +static void atomic(lua_State*L){ +global_State*g=G(L); +size_t udsize; +remarkupvals(g); +propagateall(g); +g->gray=g->weak; +g->weak=NULL; +markobject(g,L); +markmt(g); +propagateall(g); +g->gray=g->grayagain; +g->grayagain=NULL; +propagateall(g); +udsize=luaC_separateudata(L,0); +marktmu(g); +udsize+=propagateall(g); +cleartable(g->weak); +g->currentwhite=cast_byte(otherwhite(g)); +g->sweepstrgc=0; +g->sweepgc=&g->rootgc; +g->gcstate=2; +g->estimate=g->totalbytes-udsize; +} +static l_mem singlestep(lua_State*L){ +global_State*g=G(L); +switch(g->gcstate){ +case 0:{ +markroot(L); +return 0; +} +case 1:{ +if(g->gray) +return propagatemark(g); +else{ +atomic(L); +return 0; +} +} +case 2:{ +lu_mem old=g->totalbytes; +sweepwholelist(L,&g->strt.hash[g->sweepstrgc++]); +if(g->sweepstrgc>=g->strt.size) +g->gcstate=3; +g->estimate-=old-g->totalbytes; +return 10; +} +case 3:{ +lu_mem old=g->totalbytes; +g->sweepgc=sweeplist(L,g->sweepgc,40); +if(*g->sweepgc==NULL){ +checkSizes(L); +g->gcstate=4; +} +g->estimate-=old-g->totalbytes; +return 40*10; +} +case 4:{ +if(g->tmudata){ +GCTM(L); +if(g->estimate>100) +g->estimate-=100; +return 100; +} +else{ +g->gcstate=0; +g->gcdept=0; +return 0; +} +} +default:return 0; +} +} +static void luaC_step(lua_State*L){ +global_State*g=G(L); +l_mem lim=(1024u/100)*g->gcstepmul; +if(lim==0) +lim=(((lu_mem)(~(lu_mem)0)-2)-1)/2; +g->gcdept+=g->totalbytes-g->GCthreshold; +do{ +lim-=singlestep(L); +if(g->gcstate==0) +break; +}while(lim>0); +if(g->gcstate!=0){ +if(g->gcdept<1024u) +g->GCthreshold=g->totalbytes+1024u; +else{ +g->gcdept-=1024u; +g->GCthreshold=g->totalbytes; +} +} +else{ +setthreshold(g); +} +} +static void luaC_barrierf(lua_State*L,GCObject*o,GCObject*v){ +global_State*g=G(L); +if(g->gcstate==1) +reallymarkobject(g,v); +else +makewhite(g,o); +} +static void luaC_barrierback(lua_State*L,Table*t){ +global_State*g=G(L); +GCObject*o=obj2gco(t); +black2gray(o); +t->gclist=g->grayagain; +g->grayagain=o; +} +static void luaC_link(lua_State*L,GCObject*o,lu_byte tt){ +global_State*g=G(L); +o->gch.next=g->rootgc; +g->rootgc=o; +o->gch.marked=luaC_white(g); +o->gch.tt=tt; +} +static void luaC_linkupval(lua_State*L,UpVal*uv){ +global_State*g=G(L); +GCObject*o=obj2gco(uv); +o->gch.next=g->rootgc; +g->rootgc=o; +if(isgray(o)){ +if(g->gcstate==1){ +gray2black(o); +luaC_barrier(L,uv,uv->v); +} +else{ +makewhite(g,o); +} +} +} +typedef union{ +lua_Number r; +TString*ts; +}SemInfo; +typedef struct Token{ +int token; +SemInfo seminfo; +}Token; +typedef struct LexState{ +int current; +int linenumber; +int lastline; +Token t; +Token lookahead; +struct FuncState*fs; +struct lua_State*L; +ZIO*z; +Mbuffer*buff; +TString*source; +char decpoint; +}LexState; +static void luaX_init(lua_State*L); +static void luaX_lexerror(LexState*ls,const char*msg,int token); +#define state_size(x)(sizeof(x)+0) +#define fromstate(l)(cast(lu_byte*,(l))-0) +#define tostate(l)(cast(lua_State*,cast(lu_byte*,l)+0)) +typedef struct LG{ +lua_State l; +global_State g; +}LG; +static void stack_init(lua_State*L1,lua_State*L){ +L1->base_ci=luaM_newvector(L,8,CallInfo); +L1->ci=L1->base_ci; +L1->size_ci=8; +L1->end_ci=L1->base_ci+L1->size_ci-1; +L1->stack=luaM_newvector(L,(2*20)+5,TValue); +L1->stacksize=(2*20)+5; +L1->top=L1->stack; +L1->stack_last=L1->stack+(L1->stacksize-5)-1; +L1->ci->func=L1->top; +setnilvalue(L1->top++); +L1->base=L1->ci->base=L1->top; +L1->ci->top=L1->top+20; +} +static void freestack(lua_State*L,lua_State*L1){ +luaM_freearray(L,L1->base_ci,L1->size_ci,CallInfo); +luaM_freearray(L,L1->stack,L1->stacksize,TValue); +} +static void f_luaopen(lua_State*L,void*ud){ +global_State*g=G(L); +UNUSED(ud); +stack_init(L,L); +sethvalue(L,gt(L),luaH_new(L,0,2)); +sethvalue(L,registry(L),luaH_new(L,0,2)); +luaS_resize(L,32); +luaT_init(L); +luaX_init(L); +luaS_fix(luaS_newliteral(L,"not enough memory")); +g->GCthreshold=4*g->totalbytes; +} +static void preinit_state(lua_State*L,global_State*g){ +G(L)=g; +L->stack=NULL; +L->stacksize=0; +L->errorJmp=NULL; +L->hook=NULL; +L->hookmask=0; +L->basehookcount=0; +L->allowhook=1; +resethookcount(L); +L->openupval=NULL; +L->size_ci=0; +L->nCcalls=L->baseCcalls=0; +L->status=0; +L->base_ci=L->ci=NULL; +L->savedpc=NULL; +L->errfunc=0; +setnilvalue(gt(L)); +} +static void close_state(lua_State*L){ +global_State*g=G(L); +luaF_close(L,L->stack); +luaC_freeall(L); +luaM_freearray(L,G(L)->strt.hash,G(L)->strt.size,TString*); +luaZ_freebuffer(L,&g->buff); +freestack(L,L); +(*g->frealloc)(g->ud,fromstate(L),state_size(LG),0); +} +static void luaE_freethread(lua_State*L,lua_State*L1){ +luaF_close(L1,L1->stack); +freestack(L,L1); +luaM_freemem(L,fromstate(L1),state_size(lua_State)); +} +static lua_State*lua_newstate(lua_Alloc f,void*ud){ +int i; +lua_State*L; +global_State*g; +void*l=(*f)(ud,NULL,0,state_size(LG)); +if(l==NULL)return NULL; +L=tostate(l); +g=&((LG*)L)->g; +L->next=NULL; +L->tt=8; +g->currentwhite=bit2mask(0,5); +L->marked=luaC_white(g); +set2bits(L->marked,5,6); +preinit_state(L,g); +g->frealloc=f; +g->ud=ud; +g->mainthread=L; +g->uvhead.u.l.prev=&g->uvhead; +g->uvhead.u.l.next=&g->uvhead; +g->GCthreshold=0; +g->strt.size=0; +g->strt.nuse=0; +g->strt.hash=NULL; +setnilvalue(registry(L)); +luaZ_initbuffer(L,&g->buff); +g->panic=NULL; +g->gcstate=0; +g->rootgc=obj2gco(L); +g->sweepstrgc=0; +g->sweepgc=&g->rootgc; +g->gray=NULL; +g->grayagain=NULL; +g->weak=NULL; +g->tmudata=NULL; +g->totalbytes=sizeof(LG); +g->gcpause=200; +g->gcstepmul=200; +g->gcdept=0; +for(i=0;i<(8+1);i++)g->mt[i]=NULL; +if(luaD_rawrunprotected(L,f_luaopen,NULL)!=0){ +close_state(L); +L=NULL; +} +else +{} +return L; +} +static void callallgcTM(lua_State*L,void*ud){ +UNUSED(ud); +luaC_callGCTM(L); +} +static void lua_close(lua_State*L){ +L=G(L)->mainthread; +luaF_close(L,L->stack); +luaC_separateudata(L,1); +L->errfunc=0; +do{ +L->ci=L->base_ci; +L->base=L->top=L->ci->base; +L->nCcalls=L->baseCcalls=0; +}while(luaD_rawrunprotected(L,callallgcTM,NULL)!=0); +close_state(L); +} +#define getcode(fs,e)((fs)->f->code[(e)->u.s.info]) +#define luaK_codeAsBx(fs,o,A,sBx)luaK_codeABx(fs,o,A,(sBx)+(((1<<(9+9))-1)>>1)) +#define luaK_setmultret(fs,e)luaK_setreturns(fs,e,(-1)) +static int luaK_codeABx(FuncState*fs,OpCode o,int A,unsigned int Bx); +static int luaK_codeABC(FuncState*fs,OpCode o,int A,int B,int C); +static void luaK_setreturns(FuncState*fs,expdesc*e,int nresults); +static void luaK_patchtohere(FuncState*fs,int list); +static void luaK_concat(FuncState*fs,int*l1,int l2); +static int currentpc(lua_State*L,CallInfo*ci){ +if(!isLua(ci))return-1; +if(ci==L->ci) +ci->savedpc=L->savedpc; +return pcRel(ci->savedpc,ci_func(ci)->l.p); +} +static int currentline(lua_State*L,CallInfo*ci){ +int pc=currentpc(L,ci); +if(pc<0) +return-1; +else +return getline_(ci_func(ci)->l.p,pc); +} +static int lua_getstack(lua_State*L,int level,lua_Debug*ar){ +int status; +CallInfo*ci; +for(ci=L->ci;level>0&&ci>L->base_ci;ci--){ +level--; +if(f_isLua(ci)) +level-=ci->tailcalls; +} +if(level==0&&ci>L->base_ci){ +status=1; +ar->i_ci=cast_int(ci-L->base_ci); +} +else if(level<0){ +status=1; +ar->i_ci=0; +} +else status=0; +return status; +} +static Proto*getluaproto(CallInfo*ci){ +return(isLua(ci)?ci_func(ci)->l.p:NULL); +} +static void funcinfo(lua_Debug*ar,Closure*cl){ +if(cl->c.isC){ +ar->source="=[C]"; +ar->linedefined=-1; +ar->lastlinedefined=-1; +ar->what="C"; +} +else{ +ar->source=getstr(cl->l.p->source); +ar->linedefined=cl->l.p->linedefined; +ar->lastlinedefined=cl->l.p->lastlinedefined; +ar->what=(ar->linedefined==0)?"main":"Lua"; +} +luaO_chunkid(ar->short_src,ar->source,60); +} +static void info_tailcall(lua_Debug*ar){ +ar->name=ar->namewhat=""; +ar->what="tail"; +ar->lastlinedefined=ar->linedefined=ar->currentline=-1; +ar->source="=(tail call)"; +luaO_chunkid(ar->short_src,ar->source,60); +ar->nups=0; +} +static void collectvalidlines(lua_State*L,Closure*f){ +if(f==NULL||f->c.isC){ +setnilvalue(L->top); +} +else{ +Table*t=luaH_new(L,0,0); +int*lineinfo=f->l.p->lineinfo; +int i; +for(i=0;il.p->sizelineinfo;i++) +setbvalue(luaH_setnum(L,t,lineinfo[i]),1); +sethvalue(L,L->top,t); +} +incr_top(L); +} +static int auxgetinfo(lua_State*L,const char*what,lua_Debug*ar, +Closure*f,CallInfo*ci){ +int status=1; +if(f==NULL){ +info_tailcall(ar); +return status; +} +for(;*what;what++){ +switch(*what){ +case'S':{ +funcinfo(ar,f); +break; +} +case'l':{ +ar->currentline=(ci)?currentline(L,ci):-1; +break; +} +case'u':{ +ar->nups=f->c.nupvalues; +break; +} +case'n':{ +ar->namewhat=(ci)?NULL:NULL; +if(ar->namewhat==NULL){ +ar->namewhat=""; +ar->name=NULL; +} +break; +} +case'L': +case'f': +break; +default:status=0; +} +} +return status; +} +static int lua_getinfo(lua_State*L,const char*what,lua_Debug*ar){ +int status; +Closure*f=NULL; +CallInfo*ci=NULL; +if(*what=='>'){ +StkId func=L->top-1; +luai_apicheck(L,ttisfunction(func)); +what++; +f=clvalue(func); +L->top--; +} +else if(ar->i_ci!=0){ +ci=L->base_ci+ar->i_ci; +f=clvalue(ci->func); +} +status=auxgetinfo(L,what,ar,f,ci); +if(strchr(what,'f')){ +if(f==NULL)setnilvalue(L->top); +else setclvalue(L,L->top,f); +incr_top(L); +} +if(strchr(what,'L')) +collectvalidlines(L,f); +return status; +} +static int isinstack(CallInfo*ci,const TValue*o){ +StkId p; +for(p=ci->base;ptop;p++) +if(o==p)return 1; +return 0; +} +static void luaG_typeerror(lua_State*L,const TValue*o,const char*op){ +const char*name=NULL; +const char*t=luaT_typenames[ttype(o)]; +const char*kind=(isinstack(L->ci,o))? +NULL: +NULL; +if(kind) +luaG_runerror(L,"attempt to %s %s "LUA_QL("%s")" (a %s value)", +op,kind,name,t); +else +luaG_runerror(L,"attempt to %s a %s value",op,t); +} +static void luaG_concaterror(lua_State*L,StkId p1,StkId p2){ +if(ttisstring(p1)||ttisnumber(p1))p1=p2; +luaG_typeerror(L,p1,"concatenate"); +} +static void luaG_aritherror(lua_State*L,const TValue*p1,const TValue*p2){ +TValue temp; +if(luaV_tonumber(p1,&temp)==NULL) +p2=p1; +luaG_typeerror(L,p2,"perform arithmetic on"); +} +static int luaG_ordererror(lua_State*L,const TValue*p1,const TValue*p2){ +const char*t1=luaT_typenames[ttype(p1)]; +const char*t2=luaT_typenames[ttype(p2)]; +if(t1[2]==t2[2]) +luaG_runerror(L,"attempt to compare two %s values",t1); +else +luaG_runerror(L,"attempt to compare %s with %s",t1,t2); +return 0; +} +static void addinfo(lua_State*L,const char*msg){ +CallInfo*ci=L->ci; +if(isLua(ci)){ +char buff[60]; +int line=currentline(L,ci); +luaO_chunkid(buff,getstr(getluaproto(ci)->source),60); +luaO_pushfstring(L,"%s:%d: %s",buff,line,msg); +} +} +static void luaG_errormsg(lua_State*L){ +if(L->errfunc!=0){ +StkId errfunc=restorestack(L,L->errfunc); +if(!ttisfunction(errfunc))luaD_throw(L,5); +setobj(L,L->top,L->top-1); +setobj(L,L->top-1,errfunc); +incr_top(L); +luaD_call(L,L->top-2,1); +} +luaD_throw(L,2); +} +static void luaG_runerror(lua_State*L,const char*fmt,...){ +va_list argp; +va_start(argp,fmt); +addinfo(L,luaO_pushvfstring(L,fmt,argp)); +va_end(argp); +luaG_errormsg(L); +} +static int luaZ_fill(ZIO*z){ +size_t size; +lua_State*L=z->L; +const char*buff; +buff=z->reader(L,z->data,&size); +if(buff==NULL||size==0)return(-1); +z->n=size-1; +z->p=buff; +return char2int(*(z->p++)); +} +static void luaZ_init(lua_State*L,ZIO*z,lua_Reader reader,void*data){ +z->L=L; +z->reader=reader; +z->data=data; +z->n=0; +z->p=NULL; +} +static char*luaZ_openspace(lua_State*L,Mbuffer*buff,size_t n){ +if(n>buff->buffsize){ +if(n<32)n=32; +luaZ_resizebuffer(L,buff,n); +} +return buff->buffer; +} +#define opmode(t,a,b,c,m)(((t)<<7)|((a)<<6)|((b)<<4)|((c)<<2)|(m)) +static const lu_byte luaP_opmodes[(cast(int,OP_VARARG)+1)]={ +opmode(0,1,OpArgR,OpArgN,iABC) +,opmode(0,1,OpArgK,OpArgN,iABx) +,opmode(0,1,OpArgU,OpArgU,iABC) +,opmode(0,1,OpArgR,OpArgN,iABC) +,opmode(0,1,OpArgU,OpArgN,iABC) +,opmode(0,1,OpArgK,OpArgN,iABx) +,opmode(0,1,OpArgR,OpArgK,iABC) +,opmode(0,0,OpArgK,OpArgN,iABx) +,opmode(0,0,OpArgU,OpArgN,iABC) +,opmode(0,0,OpArgK,OpArgK,iABC) +,opmode(0,1,OpArgU,OpArgU,iABC) +,opmode(0,1,OpArgR,OpArgK,iABC) +,opmode(0,1,OpArgK,OpArgK,iABC) +,opmode(0,1,OpArgK,OpArgK,iABC) +,opmode(0,1,OpArgK,OpArgK,iABC) +,opmode(0,1,OpArgK,OpArgK,iABC) +,opmode(0,1,OpArgK,OpArgK,iABC) +,opmode(0,1,OpArgK,OpArgK,iABC) +,opmode(0,1,OpArgR,OpArgN,iABC) +,opmode(0,1,OpArgR,OpArgN,iABC) +,opmode(0,1,OpArgR,OpArgN,iABC) +,opmode(0,1,OpArgR,OpArgR,iABC) +,opmode(0,0,OpArgR,OpArgN,iAsBx) +,opmode(1,0,OpArgK,OpArgK,iABC) +,opmode(1,0,OpArgK,OpArgK,iABC) +,opmode(1,0,OpArgK,OpArgK,iABC) +,opmode(1,1,OpArgR,OpArgU,iABC) +,opmode(1,1,OpArgR,OpArgU,iABC) +,opmode(0,1,OpArgU,OpArgU,iABC) +,opmode(0,1,OpArgU,OpArgU,iABC) +,opmode(0,0,OpArgU,OpArgN,iABC) +,opmode(0,1,OpArgR,OpArgN,iAsBx) +,opmode(0,1,OpArgR,OpArgN,iAsBx) +,opmode(1,0,OpArgN,OpArgU,iABC) +,opmode(0,0,OpArgU,OpArgU,iABC) +,opmode(0,0,OpArgN,OpArgN,iABC) +,opmode(0,1,OpArgU,OpArgN,iABx) +,opmode(0,1,OpArgU,OpArgN,iABC) +}; +#define next(ls)(ls->current=zgetc(ls->z)) +#define currIsNewline(ls)(ls->current=='\n'||ls->current=='\r') +static const char*const luaX_tokens[]={ +"and","break","do","else","elseif", +"end","false","for","function","if", +"in","local","nil","not","or","repeat", +"return","then","true","until","while", +"..","...","==",">=","<=","~=", +"","","","", +NULL +}; +#define save_and_next(ls)(save(ls,ls->current),next(ls)) +static void save(LexState*ls,int c){ +Mbuffer*b=ls->buff; +if(b->n+1>b->buffsize){ +size_t newsize; +if(b->buffsize>=((size_t)(~(size_t)0)-2)/2) +luaX_lexerror(ls,"lexical element too long",0); +newsize=b->buffsize*2; +luaZ_resizebuffer(ls->L,b,newsize); +} +b->buffer[b->n++]=cast(char,c); +} +static void luaX_init(lua_State*L){ +int i; +for(i=0;i<(cast(int,TK_WHILE-257+1));i++){ +TString*ts=luaS_new(L,luaX_tokens[i]); +luaS_fix(ts); +ts->tsv.reserved=cast_byte(i+1); +} +} +static const char*luaX_token2str(LexState*ls,int token){ +if(token<257){ +return(iscntrl(token))?luaO_pushfstring(ls->L,"char(%d)",token): +luaO_pushfstring(ls->L,"%c",token); +} +else +return luaX_tokens[token-257]; +} +static const char*txtToken(LexState*ls,int token){ +switch(token){ +case TK_NAME: +case TK_STRING: +case TK_NUMBER: +save(ls,'\0'); +return luaZ_buffer(ls->buff); +default: +return luaX_token2str(ls,token); +} +} +static void luaX_lexerror(LexState*ls,const char*msg,int token){ +char buff[80]; +luaO_chunkid(buff,getstr(ls->source),80); +msg=luaO_pushfstring(ls->L,"%s:%d: %s",buff,ls->linenumber,msg); +if(token) +luaO_pushfstring(ls->L,"%s near "LUA_QL("%s"),msg,txtToken(ls,token)); +luaD_throw(ls->L,3); +} +static void luaX_syntaxerror(LexState*ls,const char*msg){ +luaX_lexerror(ls,msg,ls->t.token); +} +static TString*luaX_newstring(LexState*ls,const char*str,size_t l){ +lua_State*L=ls->L; +TString*ts=luaS_newlstr(L,str,l); +TValue*o=luaH_setstr(L,ls->fs->h,ts); +if(ttisnil(o)){ +setbvalue(o,1); +luaC_checkGC(L); +} +return ts; +} +static void inclinenumber(LexState*ls){ +int old=ls->current; +next(ls); +if(currIsNewline(ls)&&ls->current!=old) +next(ls); +if(++ls->linenumber>=(INT_MAX-2)) +luaX_syntaxerror(ls,"chunk has too many lines"); +} +static void luaX_setinput(lua_State*L,LexState*ls,ZIO*z,TString*source){ +ls->decpoint='.'; +ls->L=L; +ls->lookahead.token=TK_EOS; +ls->z=z; +ls->fs=NULL; +ls->linenumber=1; +ls->lastline=1; +ls->source=source; +luaZ_resizebuffer(ls->L,ls->buff,32); +next(ls); +} +static int check_next(LexState*ls,const char*set){ +if(!strchr(set,ls->current)) +return 0; +save_and_next(ls); +return 1; +} +static void buffreplace(LexState*ls,char from,char to){ +size_t n=luaZ_bufflen(ls->buff); +char*p=luaZ_buffer(ls->buff); +while(n--) +if(p[n]==from)p[n]=to; +} +static void read_numeral(LexState*ls,SemInfo*seminfo){ +do{ +save_and_next(ls); +}while(isdigit(ls->current)||ls->current=='.'); +if(check_next(ls,"Ee")) +check_next(ls,"+-"); +while(isalnum(ls->current)||ls->current=='_') +save_and_next(ls); +save(ls,'\0'); +buffreplace(ls,'.',ls->decpoint); +if(!luaO_str2d(luaZ_buffer(ls->buff),&seminfo->r)) +luaX_lexerror(ls,"malformed number",TK_NUMBER); +} +static int skip_sep(LexState*ls){ +int count=0; +int s=ls->current; +save_and_next(ls); +while(ls->current=='='){ +save_and_next(ls); +count++; +} +return(ls->current==s)?count:(-count)-1; +} +static void read_long_string(LexState*ls,SemInfo*seminfo,int sep){ +int cont=0; +(void)(cont); +save_and_next(ls); +if(currIsNewline(ls)) +inclinenumber(ls); +for(;;){ +switch(ls->current){ +case(-1): +luaX_lexerror(ls,(seminfo)?"unfinished long string": +"unfinished long comment",TK_EOS); +break; +case']':{ +if(skip_sep(ls)==sep){ +save_and_next(ls); +goto endloop; +} +break; +} +case'\n': +case'\r':{ +save(ls,'\n'); +inclinenumber(ls); +if(!seminfo)luaZ_resetbuffer(ls->buff); +break; +} +default:{ +if(seminfo)save_and_next(ls); +else next(ls); +} +} +}endloop: +if(seminfo) +seminfo->ts=luaX_newstring(ls,luaZ_buffer(ls->buff)+(2+sep), +luaZ_bufflen(ls->buff)-2*(2+sep)); +} +static void read_string(LexState*ls,int del,SemInfo*seminfo){ +save_and_next(ls); +while(ls->current!=del){ +switch(ls->current){ +case(-1): +luaX_lexerror(ls,"unfinished string",TK_EOS); +continue; +case'\n': +case'\r': +luaX_lexerror(ls,"unfinished string",TK_STRING); +continue; +case'\\':{ +int c; +next(ls); +switch(ls->current){ +case'a':c='\a';break; +case'b':c='\b';break; +case'f':c='\f';break; +case'n':c='\n';break; +case'r':c='\r';break; +case't':c='\t';break; +case'v':c='\v';break; +case'\n': +case'\r':save(ls,'\n');inclinenumber(ls);continue; +case(-1):continue; +default:{ +if(!isdigit(ls->current)) +save_and_next(ls); +else{ +int i=0; +c=0; +do{ +c=10*c+(ls->current-'0'); +next(ls); +}while(++i<3&&isdigit(ls->current)); +if(c>UCHAR_MAX) +luaX_lexerror(ls,"escape sequence too large",TK_STRING); +save(ls,c); +} +continue; +} +} +save(ls,c); +next(ls); +continue; +} +default: +save_and_next(ls); +} +} +save_and_next(ls); +seminfo->ts=luaX_newstring(ls,luaZ_buffer(ls->buff)+1, +luaZ_bufflen(ls->buff)-2); +} +static int llex(LexState*ls,SemInfo*seminfo){ +luaZ_resetbuffer(ls->buff); +for(;;){ +switch(ls->current){ +case'\n': +case'\r':{ +inclinenumber(ls); +continue; +} +case'-':{ +next(ls); +if(ls->current!='-')return'-'; +next(ls); +if(ls->current=='['){ +int sep=skip_sep(ls); +luaZ_resetbuffer(ls->buff); +if(sep>=0){ +read_long_string(ls,NULL,sep); +luaZ_resetbuffer(ls->buff); +continue; +} +} +while(!currIsNewline(ls)&&ls->current!=(-1)) +next(ls); +continue; +} +case'[':{ +int sep=skip_sep(ls); +if(sep>=0){ +read_long_string(ls,seminfo,sep); +return TK_STRING; +} +else if(sep==-1)return'['; +else luaX_lexerror(ls,"invalid long string delimiter",TK_STRING); +} +case'=':{ +next(ls); +if(ls->current!='=')return'='; +else{next(ls);return TK_EQ;} +} +case'<':{ +next(ls); +if(ls->current!='=')return'<'; +else{next(ls);return TK_LE;} +} +case'>':{ +next(ls); +if(ls->current!='=')return'>'; +else{next(ls);return TK_GE;} +} +case'~':{ +next(ls); +if(ls->current!='=')return'~'; +else{next(ls);return TK_NE;} +} +case'"': +case'\'':{ +read_string(ls,ls->current,seminfo); +return TK_STRING; +} +case'.':{ +save_and_next(ls); +if(check_next(ls,".")){ +if(check_next(ls,".")) +return TK_DOTS; +else return TK_CONCAT; +} +else if(!isdigit(ls->current))return'.'; +else{ +read_numeral(ls,seminfo); +return TK_NUMBER; +} +} +case(-1):{ +return TK_EOS; +} +default:{ +if(isspace(ls->current)){ +next(ls); +continue; +} +else if(isdigit(ls->current)){ +read_numeral(ls,seminfo); +return TK_NUMBER; +} +else if(isalpha(ls->current)||ls->current=='_'){ +TString*ts; +do{ +save_and_next(ls); +}while(isalnum(ls->current)||ls->current=='_'); +ts=luaX_newstring(ls,luaZ_buffer(ls->buff), +luaZ_bufflen(ls->buff)); +if(ts->tsv.reserved>0) +return ts->tsv.reserved-1+257; +else{ +seminfo->ts=ts; +return TK_NAME; +} +} +else{ +int c=ls->current; +next(ls); +return c; +} +} +} +} +} +static void luaX_next(LexState*ls){ +ls->lastline=ls->linenumber; +if(ls->lookahead.token!=TK_EOS){ +ls->t=ls->lookahead; +ls->lookahead.token=TK_EOS; +} +else +ls->t.token=llex(ls,&ls->t.seminfo); +} +static void luaX_lookahead(LexState*ls){ +ls->lookahead.token=llex(ls,&ls->lookahead.seminfo); +} +#define hasjumps(e)((e)->t!=(e)->f) +static int isnumeral(expdesc*e){ +return(e->k==VKNUM&&e->t==(-1)&&e->f==(-1)); +} +static void luaK_nil(FuncState*fs,int from,int n){ +Instruction*previous; +if(fs->pc>fs->lasttarget){ +if(fs->pc==0){ +if(from>=fs->nactvar) +return; +} +else{ +previous=&fs->f->code[fs->pc-1]; +if(GET_OPCODE(*previous)==OP_LOADNIL){ +int pfrom=GETARG_A(*previous); +int pto=GETARG_B(*previous); +if(pfrom<=from&&from<=pto+1){ +if(from+n-1>pto) +SETARG_B(*previous,from+n-1); +return; +} +} +} +} +luaK_codeABC(fs,OP_LOADNIL,from,from+n-1,0); +} +static int luaK_jump(FuncState*fs){ +int jpc=fs->jpc; +int j; +fs->jpc=(-1); +j=luaK_codeAsBx(fs,OP_JMP,0,(-1)); +luaK_concat(fs,&j,jpc); +return j; +} +static void luaK_ret(FuncState*fs,int first,int nret){ +luaK_codeABC(fs,OP_RETURN,first,nret+1,0); +} +static int condjump(FuncState*fs,OpCode op,int A,int B,int C){ +luaK_codeABC(fs,op,A,B,C); +return luaK_jump(fs); +} +static void fixjump(FuncState*fs,int pc,int dest){ +Instruction*jmp=&fs->f->code[pc]; +int offset=dest-(pc+1); +if(abs(offset)>(((1<<(9+9))-1)>>1)) +luaX_syntaxerror(fs->ls,"control structure too long"); +SETARG_sBx(*jmp,offset); +} +static int luaK_getlabel(FuncState*fs){ +fs->lasttarget=fs->pc; +return fs->pc; +} +static int getjump(FuncState*fs,int pc){ +int offset=GETARG_sBx(fs->f->code[pc]); +if(offset==(-1)) +return(-1); +else +return(pc+1)+offset; +} +static Instruction*getjumpcontrol(FuncState*fs,int pc){ +Instruction*pi=&fs->f->code[pc]; +if(pc>=1&&testTMode(GET_OPCODE(*(pi-1)))) +return pi-1; +else +return pi; +} +static int need_value(FuncState*fs,int list){ +for(;list!=(-1);list=getjump(fs,list)){ +Instruction i=*getjumpcontrol(fs,list); +if(GET_OPCODE(i)!=OP_TESTSET)return 1; +} +return 0; +} +static int patchtestreg(FuncState*fs,int node,int reg){ +Instruction*i=getjumpcontrol(fs,node); +if(GET_OPCODE(*i)!=OP_TESTSET) +return 0; +if(reg!=((1<<8)-1)&®!=GETARG_B(*i)) +SETARG_A(*i,reg); +else +*i=CREATE_ABC(OP_TEST,GETARG_B(*i),0,GETARG_C(*i)); +return 1; +} +static void removevalues(FuncState*fs,int list){ +for(;list!=(-1);list=getjump(fs,list)) +patchtestreg(fs,list,((1<<8)-1)); +} +static void patchlistaux(FuncState*fs,int list,int vtarget,int reg, +int dtarget){ +while(list!=(-1)){ +int next=getjump(fs,list); +if(patchtestreg(fs,list,reg)) +fixjump(fs,list,vtarget); +else +fixjump(fs,list,dtarget); +list=next; +} +} +static void dischargejpc(FuncState*fs){ +patchlistaux(fs,fs->jpc,fs->pc,((1<<8)-1),fs->pc); +fs->jpc=(-1); +} +static void luaK_patchlist(FuncState*fs,int list,int target){ +if(target==fs->pc) +luaK_patchtohere(fs,list); +else{ +patchlistaux(fs,list,target,((1<<8)-1),target); +} +} +static void luaK_patchtohere(FuncState*fs,int list){ +luaK_getlabel(fs); +luaK_concat(fs,&fs->jpc,list); +} +static void luaK_concat(FuncState*fs,int*l1,int l2){ +if(l2==(-1))return; +else if(*l1==(-1)) +*l1=l2; +else{ +int list=*l1; +int next; +while((next=getjump(fs,list))!=(-1)) +list=next; +fixjump(fs,list,l2); +} +} +static void luaK_checkstack(FuncState*fs,int n){ +int newstack=fs->freereg+n; +if(newstack>fs->f->maxstacksize){ +if(newstack>=250) +luaX_syntaxerror(fs->ls,"function or expression too complex"); +fs->f->maxstacksize=cast_byte(newstack); +} +} +static void luaK_reserveregs(FuncState*fs,int n){ +luaK_checkstack(fs,n); +fs->freereg+=n; +} +static void freereg(FuncState*fs,int reg){ +if(!ISK(reg)&®>=fs->nactvar){ +fs->freereg--; +} +} +static void freeexp(FuncState*fs,expdesc*e){ +if(e->k==VNONRELOC) +freereg(fs,e->u.s.info); +} +static int addk(FuncState*fs,TValue*k,TValue*v){ +lua_State*L=fs->L; +TValue*idx=luaH_set(L,fs->h,k); +Proto*f=fs->f; +int oldsize=f->sizek; +if(ttisnumber(idx)){ +return cast_int(nvalue(idx)); +} +else{ +setnvalue(idx,cast_num(fs->nk)); +luaM_growvector(L,f->k,fs->nk,f->sizek,TValue, +((1<<(9+9))-1),"constant table overflow"); +while(oldsizesizek)setnilvalue(&f->k[oldsize++]); +setobj(L,&f->k[fs->nk],v); +luaC_barrier(L,f,v); +return fs->nk++; +} +} +static int luaK_stringK(FuncState*fs,TString*s){ +TValue o; +setsvalue(fs->L,&o,s); +return addk(fs,&o,&o); +} +static int luaK_numberK(FuncState*fs,lua_Number r){ +TValue o; +setnvalue(&o,r); +return addk(fs,&o,&o); +} +static int boolK(FuncState*fs,int b){ +TValue o; +setbvalue(&o,b); +return addk(fs,&o,&o); +} +static int nilK(FuncState*fs){ +TValue k,v; +setnilvalue(&v); +sethvalue(fs->L,&k,fs->h); +return addk(fs,&k,&v); +} +static void luaK_setreturns(FuncState*fs,expdesc*e,int nresults){ +if(e->k==VCALL){ +SETARG_C(getcode(fs,e),nresults+1); +} +else if(e->k==VVARARG){ +SETARG_B(getcode(fs,e),nresults+1); +SETARG_A(getcode(fs,e),fs->freereg); +luaK_reserveregs(fs,1); +} +} +static void luaK_setoneret(FuncState*fs,expdesc*e){ +if(e->k==VCALL){ +e->k=VNONRELOC; +e->u.s.info=GETARG_A(getcode(fs,e)); +} +else if(e->k==VVARARG){ +SETARG_B(getcode(fs,e),2); +e->k=VRELOCABLE; +} +} +static void luaK_dischargevars(FuncState*fs,expdesc*e){ +switch(e->k){ +case VLOCAL:{ +e->k=VNONRELOC; +break; +} +case VUPVAL:{ +e->u.s.info=luaK_codeABC(fs,OP_GETUPVAL,0,e->u.s.info,0); +e->k=VRELOCABLE; +break; +} +case VGLOBAL:{ +e->u.s.info=luaK_codeABx(fs,OP_GETGLOBAL,0,e->u.s.info); +e->k=VRELOCABLE; +break; +} +case VINDEXED:{ +freereg(fs,e->u.s.aux); +freereg(fs,e->u.s.info); +e->u.s.info=luaK_codeABC(fs,OP_GETTABLE,0,e->u.s.info,e->u.s.aux); +e->k=VRELOCABLE; +break; +} +case VVARARG: +case VCALL:{ +luaK_setoneret(fs,e); +break; +} +default:break; +} +} +static int code_label(FuncState*fs,int A,int b,int jump){ +luaK_getlabel(fs); +return luaK_codeABC(fs,OP_LOADBOOL,A,b,jump); +} +static void discharge2reg(FuncState*fs,expdesc*e,int reg){ +luaK_dischargevars(fs,e); +switch(e->k){ +case VNIL:{ +luaK_nil(fs,reg,1); +break; +} +case VFALSE:case VTRUE:{ +luaK_codeABC(fs,OP_LOADBOOL,reg,e->k==VTRUE,0); +break; +} +case VK:{ +luaK_codeABx(fs,OP_LOADK,reg,e->u.s.info); +break; +} +case VKNUM:{ +luaK_codeABx(fs,OP_LOADK,reg,luaK_numberK(fs,e->u.nval)); +break; +} +case VRELOCABLE:{ +Instruction*pc=&getcode(fs,e); +SETARG_A(*pc,reg); +break; +} +case VNONRELOC:{ +if(reg!=e->u.s.info) +luaK_codeABC(fs,OP_MOVE,reg,e->u.s.info,0); +break; +} +default:{ +return; +} +} +e->u.s.info=reg; +e->k=VNONRELOC; +} +static void discharge2anyreg(FuncState*fs,expdesc*e){ +if(e->k!=VNONRELOC){ +luaK_reserveregs(fs,1); +discharge2reg(fs,e,fs->freereg-1); +} +} +static void exp2reg(FuncState*fs,expdesc*e,int reg){ +discharge2reg(fs,e,reg); +if(e->k==VJMP) +luaK_concat(fs,&e->t,e->u.s.info); +if(hasjumps(e)){ +int final; +int p_f=(-1); +int p_t=(-1); +if(need_value(fs,e->t)||need_value(fs,e->f)){ +int fj=(e->k==VJMP)?(-1):luaK_jump(fs); +p_f=code_label(fs,reg,0,1); +p_t=code_label(fs,reg,1,0); +luaK_patchtohere(fs,fj); +} +final=luaK_getlabel(fs); +patchlistaux(fs,e->f,final,reg,p_f); +patchlistaux(fs,e->t,final,reg,p_t); +} +e->f=e->t=(-1); +e->u.s.info=reg; +e->k=VNONRELOC; +} +static void luaK_exp2nextreg(FuncState*fs,expdesc*e){ +luaK_dischargevars(fs,e); +freeexp(fs,e); +luaK_reserveregs(fs,1); +exp2reg(fs,e,fs->freereg-1); +} +static int luaK_exp2anyreg(FuncState*fs,expdesc*e){ +luaK_dischargevars(fs,e); +if(e->k==VNONRELOC){ +if(!hasjumps(e))return e->u.s.info; +if(e->u.s.info>=fs->nactvar){ +exp2reg(fs,e,e->u.s.info); +return e->u.s.info; +} +} +luaK_exp2nextreg(fs,e); +return e->u.s.info; +} +static void luaK_exp2val(FuncState*fs,expdesc*e){ +if(hasjumps(e)) +luaK_exp2anyreg(fs,e); +else +luaK_dischargevars(fs,e); +} +static int luaK_exp2RK(FuncState*fs,expdesc*e){ +luaK_exp2val(fs,e); +switch(e->k){ +case VKNUM: +case VTRUE: +case VFALSE: +case VNIL:{ +if(fs->nk<=((1<<(9-1))-1)){ +e->u.s.info=(e->k==VNIL)?nilK(fs): +(e->k==VKNUM)?luaK_numberK(fs,e->u.nval): +boolK(fs,(e->k==VTRUE)); +e->k=VK; +return RKASK(e->u.s.info); +} +else break; +} +case VK:{ +if(e->u.s.info<=((1<<(9-1))-1)) +return RKASK(e->u.s.info); +else break; +} +default:break; +} +return luaK_exp2anyreg(fs,e); +} +static void luaK_storevar(FuncState*fs,expdesc*var,expdesc*ex){ +switch(var->k){ +case VLOCAL:{ +freeexp(fs,ex); +exp2reg(fs,ex,var->u.s.info); +return; +} +case VUPVAL:{ +int e=luaK_exp2anyreg(fs,ex); +luaK_codeABC(fs,OP_SETUPVAL,e,var->u.s.info,0); +break; +} +case VGLOBAL:{ +int e=luaK_exp2anyreg(fs,ex); +luaK_codeABx(fs,OP_SETGLOBAL,e,var->u.s.info); +break; +} +case VINDEXED:{ +int e=luaK_exp2RK(fs,ex); +luaK_codeABC(fs,OP_SETTABLE,var->u.s.info,var->u.s.aux,e); +break; +} +default:{ +break; +} +} +freeexp(fs,ex); +} +static void luaK_self(FuncState*fs,expdesc*e,expdesc*key){ +int func; +luaK_exp2anyreg(fs,e); +freeexp(fs,e); +func=fs->freereg; +luaK_reserveregs(fs,2); +luaK_codeABC(fs,OP_SELF,func,e->u.s.info,luaK_exp2RK(fs,key)); +freeexp(fs,key); +e->u.s.info=func; +e->k=VNONRELOC; +} +static void invertjump(FuncState*fs,expdesc*e){ +Instruction*pc=getjumpcontrol(fs,e->u.s.info); +SETARG_A(*pc,!(GETARG_A(*pc))); +} +static int jumponcond(FuncState*fs,expdesc*e,int cond){ +if(e->k==VRELOCABLE){ +Instruction ie=getcode(fs,e); +if(GET_OPCODE(ie)==OP_NOT){ +fs->pc--; +return condjump(fs,OP_TEST,GETARG_B(ie),0,!cond); +} +} +discharge2anyreg(fs,e); +freeexp(fs,e); +return condjump(fs,OP_TESTSET,((1<<8)-1),e->u.s.info,cond); +} +static void luaK_goiftrue(FuncState*fs,expdesc*e){ +int pc; +luaK_dischargevars(fs,e); +switch(e->k){ +case VK:case VKNUM:case VTRUE:{ +pc=(-1); +break; +} +case VJMP:{ +invertjump(fs,e); +pc=e->u.s.info; +break; +} +default:{ +pc=jumponcond(fs,e,0); +break; +} +} +luaK_concat(fs,&e->f,pc); +luaK_patchtohere(fs,e->t); +e->t=(-1); +} +static void luaK_goiffalse(FuncState*fs,expdesc*e){ +int pc; +luaK_dischargevars(fs,e); +switch(e->k){ +case VNIL:case VFALSE:{ +pc=(-1); +break; +} +case VJMP:{ +pc=e->u.s.info; +break; +} +default:{ +pc=jumponcond(fs,e,1); +break; +} +} +luaK_concat(fs,&e->t,pc); +luaK_patchtohere(fs,e->f); +e->f=(-1); +} +static void codenot(FuncState*fs,expdesc*e){ +luaK_dischargevars(fs,e); +switch(e->k){ +case VNIL:case VFALSE:{ +e->k=VTRUE; +break; +} +case VK:case VKNUM:case VTRUE:{ +e->k=VFALSE; +break; +} +case VJMP:{ +invertjump(fs,e); +break; +} +case VRELOCABLE: +case VNONRELOC:{ +discharge2anyreg(fs,e); +freeexp(fs,e); +e->u.s.info=luaK_codeABC(fs,OP_NOT,0,e->u.s.info,0); +e->k=VRELOCABLE; +break; +} +default:{ +break; +} +} +{int temp=e->f;e->f=e->t;e->t=temp;} +removevalues(fs,e->f); +removevalues(fs,e->t); +} +static void luaK_indexed(FuncState*fs,expdesc*t,expdesc*k){ +t->u.s.aux=luaK_exp2RK(fs,k); +t->k=VINDEXED; +} +static int constfolding(OpCode op,expdesc*e1,expdesc*e2){ +lua_Number v1,v2,r; +if(!isnumeral(e1)||!isnumeral(e2))return 0; +v1=e1->u.nval; +v2=e2->u.nval; +switch(op){ +case OP_ADD:r=luai_numadd(v1,v2);break; +case OP_SUB:r=luai_numsub(v1,v2);break; +case OP_MUL:r=luai_nummul(v1,v2);break; +case OP_DIV: +if(v2==0)return 0; +r=luai_numdiv(v1,v2);break; +case OP_MOD: +if(v2==0)return 0; +r=luai_nummod(v1,v2);break; +case OP_POW:r=luai_numpow(v1,v2);break; +case OP_UNM:r=luai_numunm(v1);break; +case OP_LEN:return 0; +default:r=0;break; +} +if(luai_numisnan(r))return 0; +e1->u.nval=r; +return 1; +} +static void codearith(FuncState*fs,OpCode op,expdesc*e1,expdesc*e2){ +if(constfolding(op,e1,e2)) +return; +else{ +int o2=(op!=OP_UNM&&op!=OP_LEN)?luaK_exp2RK(fs,e2):0; +int o1=luaK_exp2RK(fs,e1); +if(o1>o2){ +freeexp(fs,e1); +freeexp(fs,e2); +} +else{ +freeexp(fs,e2); +freeexp(fs,e1); +} +e1->u.s.info=luaK_codeABC(fs,op,0,o1,o2); +e1->k=VRELOCABLE; +} +} +static void codecomp(FuncState*fs,OpCode op,int cond,expdesc*e1, +expdesc*e2){ +int o1=luaK_exp2RK(fs,e1); +int o2=luaK_exp2RK(fs,e2); +freeexp(fs,e2); +freeexp(fs,e1); +if(cond==0&&op!=OP_EQ){ +int temp; +temp=o1;o1=o2;o2=temp; +cond=1; +} +e1->u.s.info=condjump(fs,op,cond,o1,o2); +e1->k=VJMP; +} +static void luaK_prefix(FuncState*fs,UnOpr op,expdesc*e){ +expdesc e2; +e2.t=e2.f=(-1);e2.k=VKNUM;e2.u.nval=0; +switch(op){ +case OPR_MINUS:{ +if(!isnumeral(e)) +luaK_exp2anyreg(fs,e); +codearith(fs,OP_UNM,e,&e2); +break; +} +case OPR_NOT:codenot(fs,e);break; +case OPR_LEN:{ +luaK_exp2anyreg(fs,e); +codearith(fs,OP_LEN,e,&e2); +break; +} +default:; +} +} +static void luaK_infix(FuncState*fs,BinOpr op,expdesc*v){ +switch(op){ +case OPR_AND:{ +luaK_goiftrue(fs,v); +break; +} +case OPR_OR:{ +luaK_goiffalse(fs,v); +break; +} +case OPR_CONCAT:{ +luaK_exp2nextreg(fs,v); +break; +} +case OPR_ADD:case OPR_SUB:case OPR_MUL:case OPR_DIV: +case OPR_MOD:case OPR_POW:{ +if(!isnumeral(v))luaK_exp2RK(fs,v); +break; +} +default:{ +luaK_exp2RK(fs,v); +break; +} +} +} +static void luaK_posfix(FuncState*fs,BinOpr op,expdesc*e1,expdesc*e2){ +switch(op){ +case OPR_AND:{ +luaK_dischargevars(fs,e2); +luaK_concat(fs,&e2->f,e1->f); +*e1=*e2; +break; +} +case OPR_OR:{ +luaK_dischargevars(fs,e2); +luaK_concat(fs,&e2->t,e1->t); +*e1=*e2; +break; +} +case OPR_CONCAT:{ +luaK_exp2val(fs,e2); +if(e2->k==VRELOCABLE&&GET_OPCODE(getcode(fs,e2))==OP_CONCAT){ +freeexp(fs,e1); +SETARG_B(getcode(fs,e2),e1->u.s.info); +e1->k=VRELOCABLE;e1->u.s.info=e2->u.s.info; +} +else{ +luaK_exp2nextreg(fs,e2); +codearith(fs,OP_CONCAT,e1,e2); +} +break; +} +case OPR_ADD:codearith(fs,OP_ADD,e1,e2);break; +case OPR_SUB:codearith(fs,OP_SUB,e1,e2);break; +case OPR_MUL:codearith(fs,OP_MUL,e1,e2);break; +case OPR_DIV:codearith(fs,OP_DIV,e1,e2);break; +case OPR_MOD:codearith(fs,OP_MOD,e1,e2);break; +case OPR_POW:codearith(fs,OP_POW,e1,e2);break; +case OPR_EQ:codecomp(fs,OP_EQ,1,e1,e2);break; +case OPR_NE:codecomp(fs,OP_EQ,0,e1,e2);break; +case OPR_LT:codecomp(fs,OP_LT,1,e1,e2);break; +case OPR_LE:codecomp(fs,OP_LE,1,e1,e2);break; +case OPR_GT:codecomp(fs,OP_LT,0,e1,e2);break; +case OPR_GE:codecomp(fs,OP_LE,0,e1,e2);break; +default:; +} +} +static void luaK_fixline(FuncState*fs,int line){ +fs->f->lineinfo[fs->pc-1]=line; +} +static int luaK_code(FuncState*fs,Instruction i,int line){ +Proto*f=fs->f; +dischargejpc(fs); +luaM_growvector(fs->L,f->code,fs->pc,f->sizecode,Instruction, +(INT_MAX-2),"code size overflow"); +f->code[fs->pc]=i; +luaM_growvector(fs->L,f->lineinfo,fs->pc,f->sizelineinfo,int, +(INT_MAX-2),"code size overflow"); +f->lineinfo[fs->pc]=line; +return fs->pc++; +} +static int luaK_codeABC(FuncState*fs,OpCode o,int a,int b,int c){ +return luaK_code(fs,CREATE_ABC(o,a,b,c),fs->ls->lastline); +} +static int luaK_codeABx(FuncState*fs,OpCode o,int a,unsigned int bc){ +return luaK_code(fs,CREATE_ABx(o,a,bc),fs->ls->lastline); +} +static void luaK_setlist(FuncState*fs,int base,int nelems,int tostore){ +int c=(nelems-1)/50+1; +int b=(tostore==(-1))?0:tostore; +if(c<=((1<<9)-1)) +luaK_codeABC(fs,OP_SETLIST,base,b,c); +else{ +luaK_codeABC(fs,OP_SETLIST,base,b,0); +luaK_code(fs,cast(Instruction,c),fs->ls->lastline); +} +fs->freereg=base+1; +} +#define hasmultret(k)((k)==VCALL||(k)==VVARARG) +#define getlocvar(fs,i)((fs)->f->locvars[(fs)->actvar[i]]) +#define luaY_checklimit(fs,v,l,m)if((v)>(l))errorlimit(fs,l,m) +typedef struct BlockCnt{ +struct BlockCnt*previous; +int breaklist; +lu_byte nactvar; +lu_byte upval; +lu_byte isbreakable; +}BlockCnt; +static void chunk(LexState*ls); +static void expr(LexState*ls,expdesc*v); +static void anchor_token(LexState*ls){ +if(ls->t.token==TK_NAME||ls->t.token==TK_STRING){ +TString*ts=ls->t.seminfo.ts; +luaX_newstring(ls,getstr(ts),ts->tsv.len); +} +} +static void error_expected(LexState*ls,int token){ +luaX_syntaxerror(ls, +luaO_pushfstring(ls->L,LUA_QL("%s")" expected",luaX_token2str(ls,token))); +} +static void errorlimit(FuncState*fs,int limit,const char*what){ +const char*msg=(fs->f->linedefined==0)? +luaO_pushfstring(fs->L,"main function has more than %d %s",limit,what): +luaO_pushfstring(fs->L,"function at line %d has more than %d %s", +fs->f->linedefined,limit,what); +luaX_lexerror(fs->ls,msg,0); +} +static int testnext(LexState*ls,int c){ +if(ls->t.token==c){ +luaX_next(ls); +return 1; +} +else return 0; +} +static void check(LexState*ls,int c){ +if(ls->t.token!=c) +error_expected(ls,c); +} +static void checknext(LexState*ls,int c){ +check(ls,c); +luaX_next(ls); +} +#define check_condition(ls,c,msg){if(!(c))luaX_syntaxerror(ls,msg);} +static void check_match(LexState*ls,int what,int who,int where){ +if(!testnext(ls,what)){ +if(where==ls->linenumber) +error_expected(ls,what); +else{ +luaX_syntaxerror(ls,luaO_pushfstring(ls->L, +LUA_QL("%s")" expected (to close "LUA_QL("%s")" at line %d)", +luaX_token2str(ls,what),luaX_token2str(ls,who),where)); +} +} +} +static TString*str_checkname(LexState*ls){ +TString*ts; +check(ls,TK_NAME); +ts=ls->t.seminfo.ts; +luaX_next(ls); +return ts; +} +static void init_exp(expdesc*e,expkind k,int i){ +e->f=e->t=(-1); +e->k=k; +e->u.s.info=i; +} +static void codestring(LexState*ls,expdesc*e,TString*s){ +init_exp(e,VK,luaK_stringK(ls->fs,s)); +} +static void checkname(LexState*ls,expdesc*e){ +codestring(ls,e,str_checkname(ls)); +} +static int registerlocalvar(LexState*ls,TString*varname){ +FuncState*fs=ls->fs; +Proto*f=fs->f; +int oldsize=f->sizelocvars; +luaM_growvector(ls->L,f->locvars,fs->nlocvars,f->sizelocvars, +LocVar,SHRT_MAX,"too many local variables"); +while(oldsizesizelocvars)f->locvars[oldsize++].varname=NULL; +f->locvars[fs->nlocvars].varname=varname; +luaC_objbarrier(ls->L,f,varname); +return fs->nlocvars++; +} +#define new_localvarliteral(ls,v,n)new_localvar(ls,luaX_newstring(ls,""v,(sizeof(v)/sizeof(char))-1),n) +static void new_localvar(LexState*ls,TString*name,int n){ +FuncState*fs=ls->fs; +luaY_checklimit(fs,fs->nactvar+n+1,200,"local variables"); +fs->actvar[fs->nactvar+n]=cast(unsigned short,registerlocalvar(ls,name)); +} +static void adjustlocalvars(LexState*ls,int nvars){ +FuncState*fs=ls->fs; +fs->nactvar=cast_byte(fs->nactvar+nvars); +for(;nvars;nvars--){ +getlocvar(fs,fs->nactvar-nvars).startpc=fs->pc; +} +} +static void removevars(LexState*ls,int tolevel){ +FuncState*fs=ls->fs; +while(fs->nactvar>tolevel) +getlocvar(fs,--fs->nactvar).endpc=fs->pc; +} +static int indexupvalue(FuncState*fs,TString*name,expdesc*v){ +int i; +Proto*f=fs->f; +int oldsize=f->sizeupvalues; +for(i=0;inups;i++){ +if(fs->upvalues[i].k==v->k&&fs->upvalues[i].info==v->u.s.info){ +return i; +} +} +luaY_checklimit(fs,f->nups+1,60,"upvalues"); +luaM_growvector(fs->L,f->upvalues,f->nups,f->sizeupvalues, +TString*,(INT_MAX-2),""); +while(oldsizesizeupvalues)f->upvalues[oldsize++]=NULL; +f->upvalues[f->nups]=name; +luaC_objbarrier(fs->L,f,name); +fs->upvalues[f->nups].k=cast_byte(v->k); +fs->upvalues[f->nups].info=cast_byte(v->u.s.info); +return f->nups++; +} +static int searchvar(FuncState*fs,TString*n){ +int i; +for(i=fs->nactvar-1;i>=0;i--){ +if(n==getlocvar(fs,i).varname) +return i; +} +return-1; +} +static void markupval(FuncState*fs,int level){ +BlockCnt*bl=fs->bl; +while(bl&&bl->nactvar>level)bl=bl->previous; +if(bl)bl->upval=1; +} +static int singlevaraux(FuncState*fs,TString*n,expdesc*var,int base){ +if(fs==NULL){ +init_exp(var,VGLOBAL,((1<<8)-1)); +return VGLOBAL; +} +else{ +int v=searchvar(fs,n); +if(v>=0){ +init_exp(var,VLOCAL,v); +if(!base) +markupval(fs,v); +return VLOCAL; +} +else{ +if(singlevaraux(fs->prev,n,var,0)==VGLOBAL) +return VGLOBAL; +var->u.s.info=indexupvalue(fs,n,var); +var->k=VUPVAL; +return VUPVAL; +} +} +} +static void singlevar(LexState*ls,expdesc*var){ +TString*varname=str_checkname(ls); +FuncState*fs=ls->fs; +if(singlevaraux(fs,varname,var,1)==VGLOBAL) +var->u.s.info=luaK_stringK(fs,varname); +} +static void adjust_assign(LexState*ls,int nvars,int nexps,expdesc*e){ +FuncState*fs=ls->fs; +int extra=nvars-nexps; +if(hasmultret(e->k)){ +extra++; +if(extra<0)extra=0; +luaK_setreturns(fs,e,extra); +if(extra>1)luaK_reserveregs(fs,extra-1); +} +else{ +if(e->k!=VVOID)luaK_exp2nextreg(fs,e); +if(extra>0){ +int reg=fs->freereg; +luaK_reserveregs(fs,extra); +luaK_nil(fs,reg,extra); +} +} +} +static void enterlevel(LexState*ls){ +if(++ls->L->nCcalls>200) +luaX_lexerror(ls,"chunk has too many syntax levels",0); +} +#define leavelevel(ls)((ls)->L->nCcalls--) +static void enterblock(FuncState*fs,BlockCnt*bl,lu_byte isbreakable){ +bl->breaklist=(-1); +bl->isbreakable=isbreakable; +bl->nactvar=fs->nactvar; +bl->upval=0; +bl->previous=fs->bl; +fs->bl=bl; +} +static void leaveblock(FuncState*fs){ +BlockCnt*bl=fs->bl; +fs->bl=bl->previous; +removevars(fs->ls,bl->nactvar); +if(bl->upval) +luaK_codeABC(fs,OP_CLOSE,bl->nactvar,0,0); +fs->freereg=fs->nactvar; +luaK_patchtohere(fs,bl->breaklist); +} +static void pushclosure(LexState*ls,FuncState*func,expdesc*v){ +FuncState*fs=ls->fs; +Proto*f=fs->f; +int oldsize=f->sizep; +int i; +luaM_growvector(ls->L,f->p,fs->np,f->sizep,Proto*, +((1<<(9+9))-1),"constant table overflow"); +while(oldsizesizep)f->p[oldsize++]=NULL; +f->p[fs->np++]=func->f; +luaC_objbarrier(ls->L,f,func->f); +init_exp(v,VRELOCABLE,luaK_codeABx(fs,OP_CLOSURE,0,fs->np-1)); +for(i=0;if->nups;i++){ +OpCode o=(func->upvalues[i].k==VLOCAL)?OP_MOVE:OP_GETUPVAL; +luaK_codeABC(fs,o,0,func->upvalues[i].info,0); +} +} +static void open_func(LexState*ls,FuncState*fs){ +lua_State*L=ls->L; +Proto*f=luaF_newproto(L); +fs->f=f; +fs->prev=ls->fs; +fs->ls=ls; +fs->L=L; +ls->fs=fs; +fs->pc=0; +fs->lasttarget=-1; +fs->jpc=(-1); +fs->freereg=0; +fs->nk=0; +fs->np=0; +fs->nlocvars=0; +fs->nactvar=0; +fs->bl=NULL; +f->source=ls->source; +f->maxstacksize=2; +fs->h=luaH_new(L,0,0); +sethvalue(L,L->top,fs->h); +incr_top(L); +setptvalue(L,L->top,f); +incr_top(L); +} +static void close_func(LexState*ls){ +lua_State*L=ls->L; +FuncState*fs=ls->fs; +Proto*f=fs->f; +removevars(ls,0); +luaK_ret(fs,0,0); +luaM_reallocvector(L,f->code,f->sizecode,fs->pc,Instruction); +f->sizecode=fs->pc; +luaM_reallocvector(L,f->lineinfo,f->sizelineinfo,fs->pc,int); +f->sizelineinfo=fs->pc; +luaM_reallocvector(L,f->k,f->sizek,fs->nk,TValue); +f->sizek=fs->nk; +luaM_reallocvector(L,f->p,f->sizep,fs->np,Proto*); +f->sizep=fs->np; +luaM_reallocvector(L,f->locvars,f->sizelocvars,fs->nlocvars,LocVar); +f->sizelocvars=fs->nlocvars; +luaM_reallocvector(L,f->upvalues,f->sizeupvalues,f->nups,TString*); +f->sizeupvalues=f->nups; +ls->fs=fs->prev; +if(fs)anchor_token(ls); +L->top-=2; +} +static Proto*luaY_parser(lua_State*L,ZIO*z,Mbuffer*buff,const char*name){ +struct LexState lexstate; +struct FuncState funcstate; +lexstate.buff=buff; +luaX_setinput(L,&lexstate,z,luaS_new(L,name)); +open_func(&lexstate,&funcstate); +funcstate.f->is_vararg=2; +luaX_next(&lexstate); +chunk(&lexstate); +check(&lexstate,TK_EOS); +close_func(&lexstate); +return funcstate.f; +} +static void field(LexState*ls,expdesc*v){ +FuncState*fs=ls->fs; +expdesc key; +luaK_exp2anyreg(fs,v); +luaX_next(ls); +checkname(ls,&key); +luaK_indexed(fs,v,&key); +} +static void yindex(LexState*ls,expdesc*v){ +luaX_next(ls); +expr(ls,v); +luaK_exp2val(ls->fs,v); +checknext(ls,']'); +} +struct ConsControl{ +expdesc v; +expdesc*t; +int nh; +int na; +int tostore; +}; +static void recfield(LexState*ls,struct ConsControl*cc){ +FuncState*fs=ls->fs; +int reg=ls->fs->freereg; +expdesc key,val; +int rkkey; +if(ls->t.token==TK_NAME){ +luaY_checklimit(fs,cc->nh,(INT_MAX-2),"items in a constructor"); +checkname(ls,&key); +} +else +yindex(ls,&key); +cc->nh++; +checknext(ls,'='); +rkkey=luaK_exp2RK(fs,&key); +expr(ls,&val); +luaK_codeABC(fs,OP_SETTABLE,cc->t->u.s.info,rkkey,luaK_exp2RK(fs,&val)); +fs->freereg=reg; +} +static void closelistfield(FuncState*fs,struct ConsControl*cc){ +if(cc->v.k==VVOID)return; +luaK_exp2nextreg(fs,&cc->v); +cc->v.k=VVOID; +if(cc->tostore==50){ +luaK_setlist(fs,cc->t->u.s.info,cc->na,cc->tostore); +cc->tostore=0; +} +} +static void lastlistfield(FuncState*fs,struct ConsControl*cc){ +if(cc->tostore==0)return; +if(hasmultret(cc->v.k)){ +luaK_setmultret(fs,&cc->v); +luaK_setlist(fs,cc->t->u.s.info,cc->na,(-1)); +cc->na--; +} +else{ +if(cc->v.k!=VVOID) +luaK_exp2nextreg(fs,&cc->v); +luaK_setlist(fs,cc->t->u.s.info,cc->na,cc->tostore); +} +} +static void listfield(LexState*ls,struct ConsControl*cc){ +expr(ls,&cc->v); +luaY_checklimit(ls->fs,cc->na,(INT_MAX-2),"items in a constructor"); +cc->na++; +cc->tostore++; +} +static void constructor(LexState*ls,expdesc*t){ +FuncState*fs=ls->fs; +int line=ls->linenumber; +int pc=luaK_codeABC(fs,OP_NEWTABLE,0,0,0); +struct ConsControl cc; +cc.na=cc.nh=cc.tostore=0; +cc.t=t; +init_exp(t,VRELOCABLE,pc); +init_exp(&cc.v,VVOID,0); +luaK_exp2nextreg(ls->fs,t); +checknext(ls,'{'); +do{ +if(ls->t.token=='}')break; +closelistfield(fs,&cc); +switch(ls->t.token){ +case TK_NAME:{ +luaX_lookahead(ls); +if(ls->lookahead.token!='=') +listfield(ls,&cc); +else +recfield(ls,&cc); +break; +} +case'[':{ +recfield(ls,&cc); +break; +} +default:{ +listfield(ls,&cc); +break; +} +} +}while(testnext(ls,',')||testnext(ls,';')); +check_match(ls,'}','{',line); +lastlistfield(fs,&cc); +SETARG_B(fs->f->code[pc],luaO_int2fb(cc.na)); +SETARG_C(fs->f->code[pc],luaO_int2fb(cc.nh)); +} +static void parlist(LexState*ls){ +FuncState*fs=ls->fs; +Proto*f=fs->f; +int nparams=0; +f->is_vararg=0; +if(ls->t.token!=')'){ +do{ +switch(ls->t.token){ +case TK_NAME:{ +new_localvar(ls,str_checkname(ls),nparams++); +break; +} +case TK_DOTS:{ +luaX_next(ls); +f->is_vararg|=2; +break; +} +default:luaX_syntaxerror(ls," or "LUA_QL("...")" expected"); +} +}while(!f->is_vararg&&testnext(ls,',')); +} +adjustlocalvars(ls,nparams); +f->numparams=cast_byte(fs->nactvar-(f->is_vararg&1)); +luaK_reserveregs(fs,fs->nactvar); +} +static void body(LexState*ls,expdesc*e,int needself,int line){ +FuncState new_fs; +open_func(ls,&new_fs); +new_fs.f->linedefined=line; +checknext(ls,'('); +if(needself){ +new_localvarliteral(ls,"self",0); +adjustlocalvars(ls,1); +} +parlist(ls); +checknext(ls,')'); +chunk(ls); +new_fs.f->lastlinedefined=ls->linenumber; +check_match(ls,TK_END,TK_FUNCTION,line); +close_func(ls); +pushclosure(ls,&new_fs,e); +} +static int explist1(LexState*ls,expdesc*v){ +int n=1; +expr(ls,v); +while(testnext(ls,',')){ +luaK_exp2nextreg(ls->fs,v); +expr(ls,v); +n++; +} +return n; +} +static void funcargs(LexState*ls,expdesc*f){ +FuncState*fs=ls->fs; +expdesc args; +int base,nparams; +int line=ls->linenumber; +switch(ls->t.token){ +case'(':{ +if(line!=ls->lastline) +luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)"); +luaX_next(ls); +if(ls->t.token==')') +args.k=VVOID; +else{ +explist1(ls,&args); +luaK_setmultret(fs,&args); +} +check_match(ls,')','(',line); +break; +} +case'{':{ +constructor(ls,&args); +break; +} +case TK_STRING:{ +codestring(ls,&args,ls->t.seminfo.ts); +luaX_next(ls); +break; +} +default:{ +luaX_syntaxerror(ls,"function arguments expected"); +return; +} +} +base=f->u.s.info; +if(hasmultret(args.k)) +nparams=(-1); +else{ +if(args.k!=VVOID) +luaK_exp2nextreg(fs,&args); +nparams=fs->freereg-(base+1); +} +init_exp(f,VCALL,luaK_codeABC(fs,OP_CALL,base,nparams+1,2)); +luaK_fixline(fs,line); +fs->freereg=base+1; +} +static void prefixexp(LexState*ls,expdesc*v){ +switch(ls->t.token){ +case'(':{ +int line=ls->linenumber; +luaX_next(ls); +expr(ls,v); +check_match(ls,')','(',line); +luaK_dischargevars(ls->fs,v); +return; +} +case TK_NAME:{ +singlevar(ls,v); +return; +} +default:{ +luaX_syntaxerror(ls,"unexpected symbol"); +return; +} +} +} +static void primaryexp(LexState*ls,expdesc*v){ +FuncState*fs=ls->fs; +prefixexp(ls,v); +for(;;){ +switch(ls->t.token){ +case'.':{ +field(ls,v); +break; +} +case'[':{ +expdesc key; +luaK_exp2anyreg(fs,v); +yindex(ls,&key); +luaK_indexed(fs,v,&key); +break; +} +case':':{ +expdesc key; +luaX_next(ls); +checkname(ls,&key); +luaK_self(fs,v,&key); +funcargs(ls,v); +break; +} +case'(':case TK_STRING:case'{':{ +luaK_exp2nextreg(fs,v); +funcargs(ls,v); +break; +} +default:return; +} +} +} +static void simpleexp(LexState*ls,expdesc*v){ +switch(ls->t.token){ +case TK_NUMBER:{ +init_exp(v,VKNUM,0); +v->u.nval=ls->t.seminfo.r; +break; +} +case TK_STRING:{ +codestring(ls,v,ls->t.seminfo.ts); +break; +} +case TK_NIL:{ +init_exp(v,VNIL,0); +break; +} +case TK_TRUE:{ +init_exp(v,VTRUE,0); +break; +} +case TK_FALSE:{ +init_exp(v,VFALSE,0); +break; +} +case TK_DOTS:{ +FuncState*fs=ls->fs; +check_condition(ls,fs->f->is_vararg, +"cannot use "LUA_QL("...")" outside a vararg function"); +fs->f->is_vararg&=~4; +init_exp(v,VVARARG,luaK_codeABC(fs,OP_VARARG,0,1,0)); +break; +} +case'{':{ +constructor(ls,v); +return; +} +case TK_FUNCTION:{ +luaX_next(ls); +body(ls,v,0,ls->linenumber); +return; +} +default:{ +primaryexp(ls,v); +return; +} +} +luaX_next(ls); +} +static UnOpr getunopr(int op){ +switch(op){ +case TK_NOT:return OPR_NOT; +case'-':return OPR_MINUS; +case'#':return OPR_LEN; +default:return OPR_NOUNOPR; +} +} +static BinOpr getbinopr(int op){ +switch(op){ +case'+':return OPR_ADD; +case'-':return OPR_SUB; +case'*':return OPR_MUL; +case'/':return OPR_DIV; +case'%':return OPR_MOD; +case'^':return OPR_POW; +case TK_CONCAT:return OPR_CONCAT; +case TK_NE:return OPR_NE; +case TK_EQ:return OPR_EQ; +case'<':return OPR_LT; +case TK_LE:return OPR_LE; +case'>':return OPR_GT; +case TK_GE:return OPR_GE; +case TK_AND:return OPR_AND; +case TK_OR:return OPR_OR; +default:return OPR_NOBINOPR; +} +} +static const struct{ +lu_byte left; +lu_byte right; +}priority[]={ +{6,6},{6,6},{7,7},{7,7},{7,7}, +{10,9},{5,4}, +{3,3},{3,3}, +{3,3},{3,3},{3,3},{3,3}, +{2,2},{1,1} +}; +static BinOpr subexpr(LexState*ls,expdesc*v,unsigned int limit){ +BinOpr op; +UnOpr uop; +enterlevel(ls); +uop=getunopr(ls->t.token); +if(uop!=OPR_NOUNOPR){ +luaX_next(ls); +subexpr(ls,v,8); +luaK_prefix(ls->fs,uop,v); +} +else simpleexp(ls,v); +op=getbinopr(ls->t.token); +while(op!=OPR_NOBINOPR&&priority[op].left>limit){ +expdesc v2; +BinOpr nextop; +luaX_next(ls); +luaK_infix(ls->fs,op,v); +nextop=subexpr(ls,&v2,priority[op].right); +luaK_posfix(ls->fs,op,v,&v2); +op=nextop; +} +leavelevel(ls); +return op; +} +static void expr(LexState*ls,expdesc*v){ +subexpr(ls,v,0); +} +static int block_follow(int token){ +switch(token){ +case TK_ELSE:case TK_ELSEIF:case TK_END: +case TK_UNTIL:case TK_EOS: +return 1; +default:return 0; +} +} +static void block(LexState*ls){ +FuncState*fs=ls->fs; +BlockCnt bl; +enterblock(fs,&bl,0); +chunk(ls); +leaveblock(fs); +} +struct LHS_assign{ +struct LHS_assign*prev; +expdesc v; +}; +static void check_conflict(LexState*ls,struct LHS_assign*lh,expdesc*v){ +FuncState*fs=ls->fs; +int extra=fs->freereg; +int conflict=0; +for(;lh;lh=lh->prev){ +if(lh->v.k==VINDEXED){ +if(lh->v.u.s.info==v->u.s.info){ +conflict=1; +lh->v.u.s.info=extra; +} +if(lh->v.u.s.aux==v->u.s.info){ +conflict=1; +lh->v.u.s.aux=extra; +} +} +} +if(conflict){ +luaK_codeABC(fs,OP_MOVE,fs->freereg,v->u.s.info,0); +luaK_reserveregs(fs,1); +} +} +static void assignment(LexState*ls,struct LHS_assign*lh,int nvars){ +expdesc e; +check_condition(ls,VLOCAL<=lh->v.k&&lh->v.k<=VINDEXED, +"syntax error"); +if(testnext(ls,',')){ +struct LHS_assign nv; +nv.prev=lh; +primaryexp(ls,&nv.v); +if(nv.v.k==VLOCAL) +check_conflict(ls,lh,&nv.v); +luaY_checklimit(ls->fs,nvars,200-ls->L->nCcalls, +"variables in assignment"); +assignment(ls,&nv,nvars+1); +} +else{ +int nexps; +checknext(ls,'='); +nexps=explist1(ls,&e); +if(nexps!=nvars){ +adjust_assign(ls,nvars,nexps,&e); +if(nexps>nvars) +ls->fs->freereg-=nexps-nvars; +} +else{ +luaK_setoneret(ls->fs,&e); +luaK_storevar(ls->fs,&lh->v,&e); +return; +} +} +init_exp(&e,VNONRELOC,ls->fs->freereg-1); +luaK_storevar(ls->fs,&lh->v,&e); +} +static int cond(LexState*ls){ +expdesc v; +expr(ls,&v); +if(v.k==VNIL)v.k=VFALSE; +luaK_goiftrue(ls->fs,&v); +return v.f; +} +static void breakstat(LexState*ls){ +FuncState*fs=ls->fs; +BlockCnt*bl=fs->bl; +int upval=0; +while(bl&&!bl->isbreakable){ +upval|=bl->upval; +bl=bl->previous; +} +if(!bl) +luaX_syntaxerror(ls,"no loop to break"); +if(upval) +luaK_codeABC(fs,OP_CLOSE,bl->nactvar,0,0); +luaK_concat(fs,&bl->breaklist,luaK_jump(fs)); +} +static void whilestat(LexState*ls,int line){ +FuncState*fs=ls->fs; +int whileinit; +int condexit; +BlockCnt bl; +luaX_next(ls); +whileinit=luaK_getlabel(fs); +condexit=cond(ls); +enterblock(fs,&bl,1); +checknext(ls,TK_DO); +block(ls); +luaK_patchlist(fs,luaK_jump(fs),whileinit); +check_match(ls,TK_END,TK_WHILE,line); +leaveblock(fs); +luaK_patchtohere(fs,condexit); +} +static void repeatstat(LexState*ls,int line){ +int condexit; +FuncState*fs=ls->fs; +int repeat_init=luaK_getlabel(fs); +BlockCnt bl1,bl2; +enterblock(fs,&bl1,1); +enterblock(fs,&bl2,0); +luaX_next(ls); +chunk(ls); +check_match(ls,TK_UNTIL,TK_REPEAT,line); +condexit=cond(ls); +if(!bl2.upval){ +leaveblock(fs); +luaK_patchlist(ls->fs,condexit,repeat_init); +} +else{ +breakstat(ls); +luaK_patchtohere(ls->fs,condexit); +leaveblock(fs); +luaK_patchlist(ls->fs,luaK_jump(fs),repeat_init); +} +leaveblock(fs); +} +static int exp1(LexState*ls){ +expdesc e; +int k; +expr(ls,&e); +k=e.k; +luaK_exp2nextreg(ls->fs,&e); +return k; +} +static void forbody(LexState*ls,int base,int line,int nvars,int isnum){ +BlockCnt bl; +FuncState*fs=ls->fs; +int prep,endfor; +adjustlocalvars(ls,3); +checknext(ls,TK_DO); +prep=isnum?luaK_codeAsBx(fs,OP_FORPREP,base,(-1)):luaK_jump(fs); +enterblock(fs,&bl,0); +adjustlocalvars(ls,nvars); +luaK_reserveregs(fs,nvars); +block(ls); +leaveblock(fs); +luaK_patchtohere(fs,prep); +endfor=(isnum)?luaK_codeAsBx(fs,OP_FORLOOP,base,(-1)): +luaK_codeABC(fs,OP_TFORLOOP,base,0,nvars); +luaK_fixline(fs,line); +luaK_patchlist(fs,(isnum?endfor:luaK_jump(fs)),prep+1); +} +static void fornum(LexState*ls,TString*varname,int line){ +FuncState*fs=ls->fs; +int base=fs->freereg; +new_localvarliteral(ls,"(for index)",0); +new_localvarliteral(ls,"(for limit)",1); +new_localvarliteral(ls,"(for step)",2); +new_localvar(ls,varname,3); +checknext(ls,'='); +exp1(ls); +checknext(ls,','); +exp1(ls); +if(testnext(ls,',')) +exp1(ls); +else{ +luaK_codeABx(fs,OP_LOADK,fs->freereg,luaK_numberK(fs,1)); +luaK_reserveregs(fs,1); +} +forbody(ls,base,line,1,1); +} +static void forlist(LexState*ls,TString*indexname){ +FuncState*fs=ls->fs; +expdesc e; +int nvars=0; +int line; +int base=fs->freereg; +new_localvarliteral(ls,"(for generator)",nvars++); +new_localvarliteral(ls,"(for state)",nvars++); +new_localvarliteral(ls,"(for control)",nvars++); +new_localvar(ls,indexname,nvars++); +while(testnext(ls,',')) +new_localvar(ls,str_checkname(ls),nvars++); +checknext(ls,TK_IN); +line=ls->linenumber; +adjust_assign(ls,3,explist1(ls,&e),&e); +luaK_checkstack(fs,3); +forbody(ls,base,line,nvars-3,0); +} +static void forstat(LexState*ls,int line){ +FuncState*fs=ls->fs; +TString*varname; +BlockCnt bl; +enterblock(fs,&bl,1); +luaX_next(ls); +varname=str_checkname(ls); +switch(ls->t.token){ +case'=':fornum(ls,varname,line);break; +case',':case TK_IN:forlist(ls,varname);break; +default:luaX_syntaxerror(ls,LUA_QL("=")" or "LUA_QL("in")" expected"); +} +check_match(ls,TK_END,TK_FOR,line); +leaveblock(fs); +} +static int test_then_block(LexState*ls){ +int condexit; +luaX_next(ls); +condexit=cond(ls); +checknext(ls,TK_THEN); +block(ls); +return condexit; +} +static void ifstat(LexState*ls,int line){ +FuncState*fs=ls->fs; +int flist; +int escapelist=(-1); +flist=test_then_block(ls); +while(ls->t.token==TK_ELSEIF){ +luaK_concat(fs,&escapelist,luaK_jump(fs)); +luaK_patchtohere(fs,flist); +flist=test_then_block(ls); +} +if(ls->t.token==TK_ELSE){ +luaK_concat(fs,&escapelist,luaK_jump(fs)); +luaK_patchtohere(fs,flist); +luaX_next(ls); +block(ls); +} +else +luaK_concat(fs,&escapelist,flist); +luaK_patchtohere(fs,escapelist); +check_match(ls,TK_END,TK_IF,line); +} +static void localfunc(LexState*ls){ +expdesc v,b; +FuncState*fs=ls->fs; +new_localvar(ls,str_checkname(ls),0); +init_exp(&v,VLOCAL,fs->freereg); +luaK_reserveregs(fs,1); +adjustlocalvars(ls,1); +body(ls,&b,0,ls->linenumber); +luaK_storevar(fs,&v,&b); +getlocvar(fs,fs->nactvar-1).startpc=fs->pc; +} +static void localstat(LexState*ls){ +int nvars=0; +int nexps; +expdesc e; +do{ +new_localvar(ls,str_checkname(ls),nvars++); +}while(testnext(ls,',')); +if(testnext(ls,'=')) +nexps=explist1(ls,&e); +else{ +e.k=VVOID; +nexps=0; +} +adjust_assign(ls,nvars,nexps,&e); +adjustlocalvars(ls,nvars); +} +static int funcname(LexState*ls,expdesc*v){ +int needself=0; +singlevar(ls,v); +while(ls->t.token=='.') +field(ls,v); +if(ls->t.token==':'){ +needself=1; +field(ls,v); +} +return needself; +} +static void funcstat(LexState*ls,int line){ +int needself; +expdesc v,b; +luaX_next(ls); +needself=funcname(ls,&v); +body(ls,&b,needself,line); +luaK_storevar(ls->fs,&v,&b); +luaK_fixline(ls->fs,line); +} +static void exprstat(LexState*ls){ +FuncState*fs=ls->fs; +struct LHS_assign v; +primaryexp(ls,&v.v); +if(v.v.k==VCALL) +SETARG_C(getcode(fs,&v.v),1); +else{ +v.prev=NULL; +assignment(ls,&v,1); +} +} +static void retstat(LexState*ls){ +FuncState*fs=ls->fs; +expdesc e; +int first,nret; +luaX_next(ls); +if(block_follow(ls->t.token)||ls->t.token==';') +first=nret=0; +else{ +nret=explist1(ls,&e); +if(hasmultret(e.k)){ +luaK_setmultret(fs,&e); +if(e.k==VCALL&&nret==1){ +SET_OPCODE(getcode(fs,&e),OP_TAILCALL); +} +first=fs->nactvar; +nret=(-1); +} +else{ +if(nret==1) +first=luaK_exp2anyreg(fs,&e); +else{ +luaK_exp2nextreg(fs,&e); +first=fs->nactvar; +} +} +} +luaK_ret(fs,first,nret); +} +static int statement(LexState*ls){ +int line=ls->linenumber; +switch(ls->t.token){ +case TK_IF:{ +ifstat(ls,line); +return 0; +} +case TK_WHILE:{ +whilestat(ls,line); +return 0; +} +case TK_DO:{ +luaX_next(ls); +block(ls); +check_match(ls,TK_END,TK_DO,line); +return 0; +} +case TK_FOR:{ +forstat(ls,line); +return 0; +} +case TK_REPEAT:{ +repeatstat(ls,line); +return 0; +} +case TK_FUNCTION:{ +funcstat(ls,line); +return 0; +} +case TK_LOCAL:{ +luaX_next(ls); +if(testnext(ls,TK_FUNCTION)) +localfunc(ls); +else +localstat(ls); +return 0; +} +case TK_RETURN:{ +retstat(ls); +return 1; +} +case TK_BREAK:{ +luaX_next(ls); +breakstat(ls); +return 1; +} +default:{ +exprstat(ls); +return 0; +} +} +} +static void chunk(LexState*ls){ +int islast=0; +enterlevel(ls); +while(!islast&&!block_follow(ls->t.token)){ +islast=statement(ls); +testnext(ls,';'); +ls->fs->freereg=ls->fs->nactvar; +} +leavelevel(ls); +} +static const TValue*luaV_tonumber(const TValue*obj,TValue*n){ +lua_Number num; +if(ttisnumber(obj))return obj; +if(ttisstring(obj)&&luaO_str2d(svalue(obj),&num)){ +setnvalue(n,num); +return n; +} +else +return NULL; +} +static int luaV_tostring(lua_State*L,StkId obj){ +if(!ttisnumber(obj)) +return 0; +else{ +char s[32]; +lua_Number n=nvalue(obj); +lua_number2str(s,n); +setsvalue(L,obj,luaS_new(L,s)); +return 1; +} +} +static void callTMres(lua_State*L,StkId res,const TValue*f, +const TValue*p1,const TValue*p2){ +ptrdiff_t result=savestack(L,res); +setobj(L,L->top,f); +setobj(L,L->top+1,p1); +setobj(L,L->top+2,p2); +luaD_checkstack(L,3); +L->top+=3; +luaD_call(L,L->top-3,1); +res=restorestack(L,result); +L->top--; +setobj(L,res,L->top); +} +static void callTM(lua_State*L,const TValue*f,const TValue*p1, +const TValue*p2,const TValue*p3){ +setobj(L,L->top,f); +setobj(L,L->top+1,p1); +setobj(L,L->top+2,p2); +setobj(L,L->top+3,p3); +luaD_checkstack(L,4); +L->top+=4; +luaD_call(L,L->top-4,0); +} +static void luaV_gettable(lua_State*L,const TValue*t,TValue*key,StkId val){ +int loop; +for(loop=0;loop<100;loop++){ +const TValue*tm; +if(ttistable(t)){ +Table*h=hvalue(t); +const TValue*res=luaH_get(h,key); +if(!ttisnil(res)|| +(tm=fasttm(L,h->metatable,TM_INDEX))==NULL){ +setobj(L,val,res); +return; +} +} +else if(ttisnil(tm=luaT_gettmbyobj(L,t,TM_INDEX))) +luaG_typeerror(L,t,"index"); +if(ttisfunction(tm)){ +callTMres(L,val,tm,t,key); +return; +} +t=tm; +} +luaG_runerror(L,"loop in gettable"); +} +static void luaV_settable(lua_State*L,const TValue*t,TValue*key,StkId val){ +int loop; +TValue temp; +for(loop=0;loop<100;loop++){ +const TValue*tm; +if(ttistable(t)){ +Table*h=hvalue(t); +TValue*oldval=luaH_set(L,h,key); +if(!ttisnil(oldval)|| +(tm=fasttm(L,h->metatable,TM_NEWINDEX))==NULL){ +setobj(L,oldval,val); +h->flags=0; +luaC_barriert(L,h,val); +return; +} +} +else if(ttisnil(tm=luaT_gettmbyobj(L,t,TM_NEWINDEX))) +luaG_typeerror(L,t,"index"); +if(ttisfunction(tm)){ +callTM(L,tm,t,key,val); +return; +} +setobj(L,&temp,tm); +t=&temp; +} +luaG_runerror(L,"loop in settable"); +} +static int call_binTM(lua_State*L,const TValue*p1,const TValue*p2, +StkId res,TMS event){ +const TValue*tm=luaT_gettmbyobj(L,p1,event); +if(ttisnil(tm)) +tm=luaT_gettmbyobj(L,p2,event); +if(ttisnil(tm))return 0; +callTMres(L,res,tm,p1,p2); +return 1; +} +static const TValue*get_compTM(lua_State*L,Table*mt1,Table*mt2, +TMS event){ +const TValue*tm1=fasttm(L,mt1,event); +const TValue*tm2; +if(tm1==NULL)return NULL; +if(mt1==mt2)return tm1; +tm2=fasttm(L,mt2,event); +if(tm2==NULL)return NULL; +if(luaO_rawequalObj(tm1,tm2)) +return tm1; +return NULL; +} +static int call_orderTM(lua_State*L,const TValue*p1,const TValue*p2, +TMS event){ +const TValue*tm1=luaT_gettmbyobj(L,p1,event); +const TValue*tm2; +if(ttisnil(tm1))return-1; +tm2=luaT_gettmbyobj(L,p2,event); +if(!luaO_rawequalObj(tm1,tm2)) +return-1; +callTMres(L,L->top,tm1,p1,p2); +return!l_isfalse(L->top); +} +static int l_strcmp(const TString*ls,const TString*rs){ +const char*l=getstr(ls); +size_t ll=ls->tsv.len; +const char*r=getstr(rs); +size_t lr=rs->tsv.len; +for(;;){ +int temp=strcoll(l,r); +if(temp!=0)return temp; +else{ +size_t len=strlen(l); +if(len==lr) +return(len==ll)?0:1; +else if(len==ll) +return-1; +len++; +l+=len;ll-=len;r+=len;lr-=len; +} +} +} +static int luaV_lessthan(lua_State*L,const TValue*l,const TValue*r){ +int res; +if(ttype(l)!=ttype(r)) +return luaG_ordererror(L,l,r); +else if(ttisnumber(l)) +return luai_numlt(nvalue(l),nvalue(r)); +else if(ttisstring(l)) +return l_strcmp(rawtsvalue(l),rawtsvalue(r))<0; +else if((res=call_orderTM(L,l,r,TM_LT))!=-1) +return res; +return luaG_ordererror(L,l,r); +} +static int lessequal(lua_State*L,const TValue*l,const TValue*r){ +int res; +if(ttype(l)!=ttype(r)) +return luaG_ordererror(L,l,r); +else if(ttisnumber(l)) +return luai_numle(nvalue(l),nvalue(r)); +else if(ttisstring(l)) +return l_strcmp(rawtsvalue(l),rawtsvalue(r))<=0; +else if((res=call_orderTM(L,l,r,TM_LE))!=-1) +return res; +else if((res=call_orderTM(L,r,l,TM_LT))!=-1) +return!res; +return luaG_ordererror(L,l,r); +} +static int luaV_equalval(lua_State*L,const TValue*t1,const TValue*t2){ +const TValue*tm; +switch(ttype(t1)){ +case 0:return 1; +case 3:return luai_numeq(nvalue(t1),nvalue(t2)); +case 1:return bvalue(t1)==bvalue(t2); +case 2:return pvalue(t1)==pvalue(t2); +case 7:{ +if(uvalue(t1)==uvalue(t2))return 1; +tm=get_compTM(L,uvalue(t1)->metatable,uvalue(t2)->metatable, +TM_EQ); +break; +} +case 5:{ +if(hvalue(t1)==hvalue(t2))return 1; +tm=get_compTM(L,hvalue(t1)->metatable,hvalue(t2)->metatable,TM_EQ); +break; +} +default:return gcvalue(t1)==gcvalue(t2); +} +if(tm==NULL)return 0; +callTMres(L,L->top,tm,t1,t2); +return!l_isfalse(L->top); +} +static void luaV_concat(lua_State*L,int total,int last){ +do{ +StkId top=L->base+last+1; +int n=2; +if(!(ttisstring(top-2)||ttisnumber(top-2))||!tostring(L,top-1)){ +if(!call_binTM(L,top-2,top-1,top-2,TM_CONCAT)) +luaG_concaterror(L,top-2,top-1); +}else if(tsvalue(top-1)->len==0) +(void)tostring(L,top-2); +else{ +size_t tl=tsvalue(top-1)->len; +char*buffer; +int i; +for(n=1;nlen; +if(l>=((size_t)(~(size_t)0)-2)-tl)luaG_runerror(L,"string length overflow"); +tl+=l; +} +buffer=luaZ_openspace(L,&G(L)->buff,tl); +tl=0; +for(i=n;i>0;i--){ +size_t l=tsvalue(top-i)->len; +memcpy(buffer+tl,svalue(top-i),l); +tl+=l; +} +setsvalue(L,top-n,luaS_newlstr(L,buffer,tl)); +} +total-=n-1; +last-=n-1; +}while(total>1); +} +static void Arith(lua_State*L,StkId ra,const TValue*rb, +const TValue*rc,TMS op){ +TValue tempb,tempc; +const TValue*b,*c; +if((b=luaV_tonumber(rb,&tempb))!=NULL&& +(c=luaV_tonumber(rc,&tempc))!=NULL){ +lua_Number nb=nvalue(b),nc=nvalue(c); +switch(op){ +case TM_ADD:setnvalue(ra,luai_numadd(nb,nc));break; +case TM_SUB:setnvalue(ra,luai_numsub(nb,nc));break; +case TM_MUL:setnvalue(ra,luai_nummul(nb,nc));break; +case TM_DIV:setnvalue(ra,luai_numdiv(nb,nc));break; +case TM_MOD:setnvalue(ra,luai_nummod(nb,nc));break; +case TM_POW:setnvalue(ra,luai_numpow(nb,nc));break; +case TM_UNM:setnvalue(ra,luai_numunm(nb));break; +default:break; +} +} +else if(!call_binTM(L,rb,rc,ra,op)) +luaG_aritherror(L,rb,rc); +} +#define runtime_check(L,c){if(!(c))break;} +#define RA(i)(base+GETARG_A(i)) +#define RB(i)check_exp(getBMode(GET_OPCODE(i))==OpArgR,base+GETARG_B(i)) +#define RKB(i)check_exp(getBMode(GET_OPCODE(i))==OpArgK,ISK(GETARG_B(i))?k+INDEXK(GETARG_B(i)):base+GETARG_B(i)) +#define RKC(i)check_exp(getCMode(GET_OPCODE(i))==OpArgK,ISK(GETARG_C(i))?k+INDEXK(GETARG_C(i)):base+GETARG_C(i)) +#define KBx(i)check_exp(getBMode(GET_OPCODE(i))==OpArgK,k+GETARG_Bx(i)) +#define dojump(L,pc,i){(pc)+=(i);} +#define Protect(x){L->savedpc=pc;{x;};base=L->base;} +#define arith_op(op,tm){TValue*rb=RKB(i);TValue*rc=RKC(i);if(ttisnumber(rb)&&ttisnumber(rc)){lua_Number nb=nvalue(rb),nc=nvalue(rc);setnvalue(ra,op(nb,nc));}else Protect(Arith(L,ra,rb,rc,tm));} +static void luaV_execute(lua_State*L,int nexeccalls){ +LClosure*cl; +StkId base; +TValue*k; +const Instruction*pc; +reentry: +pc=L->savedpc; +cl=&clvalue(L->ci->func)->l; +base=L->base; +k=cl->p->k; +for(;;){ +const Instruction i=*pc++; +StkId ra; +ra=RA(i); +switch(GET_OPCODE(i)){ +case OP_MOVE:{ +setobj(L,ra,RB(i)); +continue; +} +case OP_LOADK:{ +setobj(L,ra,KBx(i)); +continue; +} +case OP_LOADBOOL:{ +setbvalue(ra,GETARG_B(i)); +if(GETARG_C(i))pc++; +continue; +} +case OP_LOADNIL:{ +TValue*rb=RB(i); +do{ +setnilvalue(rb--); +}while(rb>=ra); +continue; +} +case OP_GETUPVAL:{ +int b=GETARG_B(i); +setobj(L,ra,cl->upvals[b]->v); +continue; +} +case OP_GETGLOBAL:{ +TValue g; +TValue*rb=KBx(i); +sethvalue(L,&g,cl->env); +Protect(luaV_gettable(L,&g,rb,ra)); +continue; +} +case OP_GETTABLE:{ +Protect(luaV_gettable(L,RB(i),RKC(i),ra)); +continue; +} +case OP_SETGLOBAL:{ +TValue g; +sethvalue(L,&g,cl->env); +Protect(luaV_settable(L,&g,KBx(i),ra)); +continue; +} +case OP_SETUPVAL:{ +UpVal*uv=cl->upvals[GETARG_B(i)]; +setobj(L,uv->v,ra); +luaC_barrier(L,uv,ra); +continue; +} +case OP_SETTABLE:{ +Protect(luaV_settable(L,ra,RKB(i),RKC(i))); +continue; +} +case OP_NEWTABLE:{ +int b=GETARG_B(i); +int c=GETARG_C(i); +sethvalue(L,ra,luaH_new(L,luaO_fb2int(b),luaO_fb2int(c))); +Protect(luaC_checkGC(L)); +continue; +} +case OP_SELF:{ +StkId rb=RB(i); +setobj(L,ra+1,rb); +Protect(luaV_gettable(L,rb,RKC(i),ra)); +continue; +} +case OP_ADD:{ +arith_op(luai_numadd,TM_ADD); +continue; +} +case OP_SUB:{ +arith_op(luai_numsub,TM_SUB); +continue; +} +case OP_MUL:{ +arith_op(luai_nummul,TM_MUL); +continue; +} +case OP_DIV:{ +arith_op(luai_numdiv,TM_DIV); +continue; +} +case OP_MOD:{ +arith_op(luai_nummod,TM_MOD); +continue; +} +case OP_POW:{ +arith_op(luai_numpow,TM_POW); +continue; +} +case OP_UNM:{ +TValue*rb=RB(i); +if(ttisnumber(rb)){ +lua_Number nb=nvalue(rb); +setnvalue(ra,luai_numunm(nb)); +} +else{ +Protect(Arith(L,ra,rb,rb,TM_UNM)); +} +continue; +} +case OP_NOT:{ +int res=l_isfalse(RB(i)); +setbvalue(ra,res); +continue; +} +case OP_LEN:{ +const TValue*rb=RB(i); +switch(ttype(rb)){ +case 5:{ +setnvalue(ra,cast_num(luaH_getn(hvalue(rb)))); +break; +} +case 4:{ +setnvalue(ra,cast_num(tsvalue(rb)->len)); +break; +} +default:{ +Protect( +if(!call_binTM(L,rb,(&luaO_nilobject_),ra,TM_LEN)) +luaG_typeerror(L,rb,"get length of"); +) +} +} +continue; +} +case OP_CONCAT:{ +int b=GETARG_B(i); +int c=GETARG_C(i); +Protect(luaV_concat(L,c-b+1,c);luaC_checkGC(L)); +setobj(L,RA(i),base+b); +continue; +} +case OP_JMP:{ +dojump(L,pc,GETARG_sBx(i)); +continue; +} +case OP_EQ:{ +TValue*rb=RKB(i); +TValue*rc=RKC(i); +Protect( +if(equalobj(L,rb,rc)==GETARG_A(i)) +dojump(L,pc,GETARG_sBx(*pc)); +) +pc++; +continue; +} +case OP_LT:{ +Protect( +if(luaV_lessthan(L,RKB(i),RKC(i))==GETARG_A(i)) +dojump(L,pc,GETARG_sBx(*pc)); +) +pc++; +continue; +} +case OP_LE:{ +Protect( +if(lessequal(L,RKB(i),RKC(i))==GETARG_A(i)) +dojump(L,pc,GETARG_sBx(*pc)); +) +pc++; +continue; +} +case OP_TEST:{ +if(l_isfalse(ra)!=GETARG_C(i)) +dojump(L,pc,GETARG_sBx(*pc)); +pc++; +continue; +} +case OP_TESTSET:{ +TValue*rb=RB(i); +if(l_isfalse(rb)!=GETARG_C(i)){ +setobj(L,ra,rb); +dojump(L,pc,GETARG_sBx(*pc)); +} +pc++; +continue; +} +case OP_CALL:{ +int b=GETARG_B(i); +int nresults=GETARG_C(i)-1; +if(b!=0)L->top=ra+b; +L->savedpc=pc; +switch(luaD_precall(L,ra,nresults)){ +case 0:{ +nexeccalls++; +goto reentry; +} +case 1:{ +if(nresults>=0)L->top=L->ci->top; +base=L->base; +continue; +} +default:{ +return; +} +} +} +case OP_TAILCALL:{ +int b=GETARG_B(i); +if(b!=0)L->top=ra+b; +L->savedpc=pc; +switch(luaD_precall(L,ra,(-1))){ +case 0:{ +CallInfo*ci=L->ci-1; +int aux; +StkId func=ci->func; +StkId pfunc=(ci+1)->func; +if(L->openupval)luaF_close(L,ci->base); +L->base=ci->base=ci->func+((ci+1)->base-pfunc); +for(aux=0;pfunc+auxtop;aux++) +setobj(L,func+aux,pfunc+aux); +ci->top=L->top=func+aux; +ci->savedpc=L->savedpc; +ci->tailcalls++; +L->ci--; +goto reentry; +} +case 1:{ +base=L->base; +continue; +} +default:{ +return; +} +} +} +case OP_RETURN:{ +int b=GETARG_B(i); +if(b!=0)L->top=ra+b-1; +if(L->openupval)luaF_close(L,base); +L->savedpc=pc; +b=luaD_poscall(L,ra); +if(--nexeccalls==0) +return; +else{ +if(b)L->top=L->ci->top; +goto reentry; +} +} +case OP_FORLOOP:{ +lua_Number step=nvalue(ra+2); +lua_Number idx=luai_numadd(nvalue(ra),step); +lua_Number limit=nvalue(ra+1); +if(luai_numlt(0,step)?luai_numle(idx,limit) +:luai_numle(limit,idx)){ +dojump(L,pc,GETARG_sBx(i)); +setnvalue(ra,idx); +setnvalue(ra+3,idx); +} +continue; +} +case OP_FORPREP:{ +const TValue*init=ra; +const TValue*plimit=ra+1; +const TValue*pstep=ra+2; +L->savedpc=pc; +if(!tonumber(init,ra)) +luaG_runerror(L,LUA_QL("for")" initial value must be a number"); +else if(!tonumber(plimit,ra+1)) +luaG_runerror(L,LUA_QL("for")" limit must be a number"); +else if(!tonumber(pstep,ra+2)) +luaG_runerror(L,LUA_QL("for")" step must be a number"); +setnvalue(ra,luai_numsub(nvalue(ra),nvalue(pstep))); +dojump(L,pc,GETARG_sBx(i)); +continue; +} +case OP_TFORLOOP:{ +StkId cb=ra+3; +setobj(L,cb+2,ra+2); +setobj(L,cb+1,ra+1); +setobj(L,cb,ra); +L->top=cb+3; +Protect(luaD_call(L,cb,GETARG_C(i))); +L->top=L->ci->top; +cb=RA(i)+3; +if(!ttisnil(cb)){ +setobj(L,cb-1,cb); +dojump(L,pc,GETARG_sBx(*pc)); +} +pc++; +continue; +} +case OP_SETLIST:{ +int n=GETARG_B(i); +int c=GETARG_C(i); +int last; +Table*h; +if(n==0){ +n=cast_int(L->top-ra)-1; +L->top=L->ci->top; +} +if(c==0)c=cast_int(*pc++); +runtime_check(L,ttistable(ra)); +h=hvalue(ra); +last=((c-1)*50)+n; +if(last>h->sizearray) +luaH_resizearray(L,h,last); +for(;n>0;n--){ +TValue*val=ra+n; +setobj(L,luaH_setnum(L,h,last--),val); +luaC_barriert(L,h,val); +} +continue; +} +case OP_CLOSE:{ +luaF_close(L,ra); +continue; +} +case OP_CLOSURE:{ +Proto*p; +Closure*ncl; +int nup,j; +p=cl->p->p[GETARG_Bx(i)]; +nup=p->nups; +ncl=luaF_newLclosure(L,nup,cl->env); +ncl->l.p=p; +for(j=0;jl.upvals[j]=cl->upvals[GETARG_B(*pc)]; +else{ +ncl->l.upvals[j]=luaF_findupval(L,base+GETARG_B(*pc)); +} +} +setclvalue(L,ra,ncl); +Protect(luaC_checkGC(L)); +continue; +} +case OP_VARARG:{ +int b=GETARG_B(i)-1; +int j; +CallInfo*ci=L->ci; +int n=cast_int(ci->base-ci->func)-cl->p->numparams-1; +if(b==(-1)){ +Protect(luaD_checkstack(L,n)); +ra=RA(i); +b=n; +L->top=ra+n; +} +for(j=0;jbase-n+j); +} +else{ +setnilvalue(ra+j); +} +} +continue; +} +} +} +} +#define api_checknelems(L,n)luai_apicheck(L,(n)<=(L->top-L->base)) +#define api_checkvalidindex(L,i)luai_apicheck(L,(i)!=(&luaO_nilobject_)) +#define api_incr_top(L){luai_apicheck(L,L->topci->top);L->top++;} +static TValue*index2adr(lua_State*L,int idx){ +if(idx>0){ +TValue*o=L->base+(idx-1); +luai_apicheck(L,idx<=L->ci->top-L->base); +if(o>=L->top)return cast(TValue*,(&luaO_nilobject_)); +else return o; +} +else if(idx>(-10000)){ +luai_apicheck(L,idx!=0&&-idx<=L->top-L->base); +return L->top+idx; +} +else switch(idx){ +case(-10000):return registry(L); +case(-10001):{ +Closure*func=curr_func(L); +sethvalue(L,&L->env,func->c.env); +return&L->env; +} +case(-10002):return gt(L); +default:{ +Closure*func=curr_func(L); +idx=(-10002)-idx; +return(idx<=func->c.nupvalues) +?&func->c.upvalue[idx-1] +:cast(TValue*,(&luaO_nilobject_)); +} +} +} +static Table*getcurrenv(lua_State*L){ +if(L->ci==L->base_ci) +return hvalue(gt(L)); +else{ +Closure*func=curr_func(L); +return func->c.env; +} +} +static int lua_checkstack(lua_State*L,int size){ +int res=1; +if(size>8000||(L->top-L->base+size)>8000) +res=0; +else if(size>0){ +luaD_checkstack(L,size); +if(L->ci->toptop+size) +L->ci->top=L->top+size; +} +return res; +} +static lua_CFunction lua_atpanic(lua_State*L,lua_CFunction panicf){ +lua_CFunction old; +old=G(L)->panic; +G(L)->panic=panicf; +return old; +} +static int lua_gettop(lua_State*L){ +return cast_int(L->top-L->base); +} +static void lua_settop(lua_State*L,int idx){ +if(idx>=0){ +luai_apicheck(L,idx<=L->stack_last-L->base); +while(L->topbase+idx) +setnilvalue(L->top++); +L->top=L->base+idx; +} +else{ +luai_apicheck(L,-(idx+1)<=(L->top-L->base)); +L->top+=idx+1; +} +} +static void lua_remove(lua_State*L,int idx){ +StkId p; +p=index2adr(L,idx); +api_checkvalidindex(L,p); +while(++ptop)setobj(L,p-1,p); +L->top--; +} +static void lua_insert(lua_State*L,int idx){ +StkId p; +StkId q; +p=index2adr(L,idx); +api_checkvalidindex(L,p); +for(q=L->top;q>p;q--)setobj(L,q,q-1); +setobj(L,p,L->top); +} +static void lua_replace(lua_State*L,int idx){ +StkId o; +if(idx==(-10001)&&L->ci==L->base_ci) +luaG_runerror(L,"no calling environment"); +api_checknelems(L,1); +o=index2adr(L,idx); +api_checkvalidindex(L,o); +if(idx==(-10001)){ +Closure*func=curr_func(L); +luai_apicheck(L,ttistable(L->top-1)); +func->c.env=hvalue(L->top-1); +luaC_barrier(L,func,L->top-1); +} +else{ +setobj(L,o,L->top-1); +if(idx<(-10002)) +luaC_barrier(L,curr_func(L),L->top-1); +} +L->top--; +} +static void lua_pushvalue(lua_State*L,int idx){ +setobj(L,L->top,index2adr(L,idx)); +api_incr_top(L); +} +static int lua_type(lua_State*L,int idx){ +StkId o=index2adr(L,idx); +return(o==(&luaO_nilobject_))?(-1):ttype(o); +} +static const char*lua_typename(lua_State*L,int t){ +UNUSED(L); +return(t==(-1))?"no value":luaT_typenames[t]; +} +static int lua_iscfunction(lua_State*L,int idx){ +StkId o=index2adr(L,idx); +return iscfunction(o); +} +static int lua_isnumber(lua_State*L,int idx){ +TValue n; +const TValue*o=index2adr(L,idx); +return tonumber(o,&n); +} +static int lua_isstring(lua_State*L,int idx){ +int t=lua_type(L,idx); +return(t==4||t==3); +} +static int lua_rawequal(lua_State*L,int index1,int index2){ +StkId o1=index2adr(L,index1); +StkId o2=index2adr(L,index2); +return(o1==(&luaO_nilobject_)||o2==(&luaO_nilobject_))?0 +:luaO_rawequalObj(o1,o2); +} +static int lua_lessthan(lua_State*L,int index1,int index2){ +StkId o1,o2; +int i; +o1=index2adr(L,index1); +o2=index2adr(L,index2); +i=(o1==(&luaO_nilobject_)||o2==(&luaO_nilobject_))?0 +:luaV_lessthan(L,o1,o2); +return i; +} +static lua_Number lua_tonumber(lua_State*L,int idx){ +TValue n; +const TValue*o=index2adr(L,idx); +if(tonumber(o,&n)) +return nvalue(o); +else +return 0; +} +static lua_Integer lua_tointeger(lua_State*L,int idx){ +TValue n; +const TValue*o=index2adr(L,idx); +if(tonumber(o,&n)){ +lua_Integer res; +lua_Number num=nvalue(o); +lua_number2integer(res,num); +return res; +} +else +return 0; +} +static int lua_toboolean(lua_State*L,int idx){ +const TValue*o=index2adr(L,idx); +return!l_isfalse(o); +} +static const char*lua_tolstring(lua_State*L,int idx,size_t*len){ +StkId o=index2adr(L,idx); +if(!ttisstring(o)){ +if(!luaV_tostring(L,o)){ +if(len!=NULL)*len=0; +return NULL; +} +luaC_checkGC(L); +o=index2adr(L,idx); +} +if(len!=NULL)*len=tsvalue(o)->len; +return svalue(o); +} +static size_t lua_objlen(lua_State*L,int idx){ +StkId o=index2adr(L,idx); +switch(ttype(o)){ +case 4:return tsvalue(o)->len; +case 7:return uvalue(o)->len; +case 5:return luaH_getn(hvalue(o)); +case 3:{ +size_t l; +l=(luaV_tostring(L,o)?tsvalue(o)->len:0); +return l; +} +default:return 0; +} +} +static lua_CFunction lua_tocfunction(lua_State*L,int idx){ +StkId o=index2adr(L,idx); +return(!iscfunction(o))?NULL:clvalue(o)->c.f; +} +static void*lua_touserdata(lua_State*L,int idx){ +StkId o=index2adr(L,idx); +switch(ttype(o)){ +case 7:return(rawuvalue(o)+1); +case 2:return pvalue(o); +default:return NULL; +} +} +static void lua_pushnil(lua_State*L){ +setnilvalue(L->top); +api_incr_top(L); +} +static void lua_pushnumber(lua_State*L,lua_Number n){ +setnvalue(L->top,n); +api_incr_top(L); +} +static void lua_pushinteger(lua_State*L,lua_Integer n){ +setnvalue(L->top,cast_num(n)); +api_incr_top(L); +} +static void lua_pushlstring(lua_State*L,const char*s,size_t len){ +luaC_checkGC(L); +setsvalue(L,L->top,luaS_newlstr(L,s,len)); +api_incr_top(L); +} +static void lua_pushstring(lua_State*L,const char*s){ +if(s==NULL) +lua_pushnil(L); +else +lua_pushlstring(L,s,strlen(s)); +} +static const char*lua_pushvfstring(lua_State*L,const char*fmt, +va_list argp){ +const char*ret; +luaC_checkGC(L); +ret=luaO_pushvfstring(L,fmt,argp); +return ret; +} +static const char*lua_pushfstring(lua_State*L,const char*fmt,...){ +const char*ret; +va_list argp; +luaC_checkGC(L); +va_start(argp,fmt); +ret=luaO_pushvfstring(L,fmt,argp); +va_end(argp); +return ret; +} +static void lua_pushcclosure(lua_State*L,lua_CFunction fn,int n){ +Closure*cl; +luaC_checkGC(L); +api_checknelems(L,n); +cl=luaF_newCclosure(L,n,getcurrenv(L)); +cl->c.f=fn; +L->top-=n; +while(n--) +setobj(L,&cl->c.upvalue[n],L->top+n); +setclvalue(L,L->top,cl); +api_incr_top(L); +} +static void lua_pushboolean(lua_State*L,int b){ +setbvalue(L->top,(b!=0)); +api_incr_top(L); +} +static int lua_pushthread(lua_State*L){ +setthvalue(L,L->top,L); +api_incr_top(L); +return(G(L)->mainthread==L); +} +static void lua_gettable(lua_State*L,int idx){ +StkId t; +t=index2adr(L,idx); +api_checkvalidindex(L,t); +luaV_gettable(L,t,L->top-1,L->top-1); +} +static void lua_getfield(lua_State*L,int idx,const char*k){ +StkId t; +TValue key; +t=index2adr(L,idx); +api_checkvalidindex(L,t); +setsvalue(L,&key,luaS_new(L,k)); +luaV_gettable(L,t,&key,L->top); +api_incr_top(L); +} +static void lua_rawget(lua_State*L,int idx){ +StkId t; +t=index2adr(L,idx); +luai_apicheck(L,ttistable(t)); +setobj(L,L->top-1,luaH_get(hvalue(t),L->top-1)); +} +static void lua_rawgeti(lua_State*L,int idx,int n){ +StkId o; +o=index2adr(L,idx); +luai_apicheck(L,ttistable(o)); +setobj(L,L->top,luaH_getnum(hvalue(o),n)); +api_incr_top(L); +} +static void lua_createtable(lua_State*L,int narray,int nrec){ +luaC_checkGC(L); +sethvalue(L,L->top,luaH_new(L,narray,nrec)); +api_incr_top(L); +} +static int lua_getmetatable(lua_State*L,int objindex){ +const TValue*obj; +Table*mt=NULL; +int res; +obj=index2adr(L,objindex); +switch(ttype(obj)){ +case 5: +mt=hvalue(obj)->metatable; +break; +case 7: +mt=uvalue(obj)->metatable; +break; +default: +mt=G(L)->mt[ttype(obj)]; +break; +} +if(mt==NULL) +res=0; +else{ +sethvalue(L,L->top,mt); +api_incr_top(L); +res=1; +} +return res; +} +static void lua_getfenv(lua_State*L,int idx){ +StkId o; +o=index2adr(L,idx); +api_checkvalidindex(L,o); +switch(ttype(o)){ +case 6: +sethvalue(L,L->top,clvalue(o)->c.env); +break; +case 7: +sethvalue(L,L->top,uvalue(o)->env); +break; +case 8: +setobj(L,L->top,gt(thvalue(o))); +break; +default: +setnilvalue(L->top); +break; +} +api_incr_top(L); +} +static void lua_settable(lua_State*L,int idx){ +StkId t; +api_checknelems(L,2); +t=index2adr(L,idx); +api_checkvalidindex(L,t); +luaV_settable(L,t,L->top-2,L->top-1); +L->top-=2; +} +static void lua_setfield(lua_State*L,int idx,const char*k){ +StkId t; +TValue key; +api_checknelems(L,1); +t=index2adr(L,idx); +api_checkvalidindex(L,t); +setsvalue(L,&key,luaS_new(L,k)); +luaV_settable(L,t,&key,L->top-1); +L->top--; +} +static void lua_rawset(lua_State*L,int idx){ +StkId t; +api_checknelems(L,2); +t=index2adr(L,idx); +luai_apicheck(L,ttistable(t)); +setobj(L,luaH_set(L,hvalue(t),L->top-2),L->top-1); +luaC_barriert(L,hvalue(t),L->top-1); +L->top-=2; +} +static void lua_rawseti(lua_State*L,int idx,int n){ +StkId o; +api_checknelems(L,1); +o=index2adr(L,idx); +luai_apicheck(L,ttistable(o)); +setobj(L,luaH_setnum(L,hvalue(o),n),L->top-1); +luaC_barriert(L,hvalue(o),L->top-1); +L->top--; +} +static int lua_setmetatable(lua_State*L,int objindex){ +TValue*obj; +Table*mt; +api_checknelems(L,1); +obj=index2adr(L,objindex); +api_checkvalidindex(L,obj); +if(ttisnil(L->top-1)) +mt=NULL; +else{ +luai_apicheck(L,ttistable(L->top-1)); +mt=hvalue(L->top-1); +} +switch(ttype(obj)){ +case 5:{ +hvalue(obj)->metatable=mt; +if(mt) +luaC_objbarriert(L,hvalue(obj),mt); +break; +} +case 7:{ +uvalue(obj)->metatable=mt; +if(mt) +luaC_objbarrier(L,rawuvalue(obj),mt); +break; +} +default:{ +G(L)->mt[ttype(obj)]=mt; +break; +} +} +L->top--; +return 1; +} +static int lua_setfenv(lua_State*L,int idx){ +StkId o; +int res=1; +api_checknelems(L,1); +o=index2adr(L,idx); +api_checkvalidindex(L,o); +luai_apicheck(L,ttistable(L->top-1)); +switch(ttype(o)){ +case 6: +clvalue(o)->c.env=hvalue(L->top-1); +break; +case 7: +uvalue(o)->env=hvalue(L->top-1); +break; +case 8: +sethvalue(L,gt(thvalue(o)),hvalue(L->top-1)); +break; +default: +res=0; +break; +} +if(res)luaC_objbarrier(L,gcvalue(o),hvalue(L->top-1)); +L->top--; +return res; +} +#define adjustresults(L,nres){if(nres==(-1)&&L->top>=L->ci->top)L->ci->top=L->top;} +#define checkresults(L,na,nr)luai_apicheck(L,(nr)==(-1)||(L->ci->top-L->top>=(nr)-(na))) +static void lua_call(lua_State*L,int nargs,int nresults){ +StkId func; +api_checknelems(L,nargs+1); +checkresults(L,nargs,nresults); +func=L->top-(nargs+1); +luaD_call(L,func,nresults); +adjustresults(L,nresults); +} +struct CallS{ +StkId func; +int nresults; +}; +static void f_call(lua_State*L,void*ud){ +struct CallS*c=cast(struct CallS*,ud); +luaD_call(L,c->func,c->nresults); +} +static int lua_pcall(lua_State*L,int nargs,int nresults,int errfunc){ +struct CallS c; +int status; +ptrdiff_t func; +api_checknelems(L,nargs+1); +checkresults(L,nargs,nresults); +if(errfunc==0) +func=0; +else{ +StkId o=index2adr(L,errfunc); +api_checkvalidindex(L,o); +func=savestack(L,o); +} +c.func=L->top-(nargs+1); +c.nresults=nresults; +status=luaD_pcall(L,f_call,&c,savestack(L,c.func),func); +adjustresults(L,nresults); +return status; +} +static int lua_load(lua_State*L,lua_Reader reader,void*data, +const char*chunkname){ +ZIO z; +int status; +if(!chunkname)chunkname="?"; +luaZ_init(L,&z,reader,data); +status=luaD_protectedparser(L,&z,chunkname); +return status; +} +static int lua_error(lua_State*L){ +api_checknelems(L,1); +luaG_errormsg(L); +return 0; +} +static int lua_next(lua_State*L,int idx){ +StkId t; +int more; +t=index2adr(L,idx); +luai_apicheck(L,ttistable(t)); +more=luaH_next(L,hvalue(t),L->top-1); +if(more){ +api_incr_top(L); +} +else +L->top-=1; +return more; +} +static void lua_concat(lua_State*L,int n){ +api_checknelems(L,n); +if(n>=2){ +luaC_checkGC(L); +luaV_concat(L,n,cast_int(L->top-L->base)-1); +L->top-=(n-1); +} +else if(n==0){ +setsvalue(L,L->top,luaS_newlstr(L,"",0)); +api_incr_top(L); +} +} +static void*lua_newuserdata(lua_State*L,size_t size){ +Udata*u; +luaC_checkGC(L); +u=luaS_newudata(L,size,getcurrenv(L)); +setuvalue(L,L->top,u); +api_incr_top(L); +return u+1; +} +#define luaL_getn(L,i)((int)lua_objlen(L,i)) +#define luaL_setn(L,i,j)((void)0) +typedef struct luaL_Reg{ +const char*name; +lua_CFunction func; +}luaL_Reg; +static void luaI_openlib(lua_State*L,const char*libname, +const luaL_Reg*l,int nup); +static int luaL_argerror(lua_State*L,int numarg,const char*extramsg); +static const char* luaL_checklstring(lua_State*L,int numArg, +size_t*l); +static const char* luaL_optlstring(lua_State*L,int numArg, +const char*def,size_t*l); +static lua_Integer luaL_checkinteger(lua_State*L,int numArg); +static lua_Integer luaL_optinteger(lua_State*L,int nArg, +lua_Integer def); +static int luaL_error(lua_State*L,const char*fmt,...); +static const char* luaL_findtable(lua_State*L,int idx, +const char*fname,int szhint); +#define luaL_argcheck(L,cond,numarg,extramsg)((void)((cond)||luaL_argerror(L,(numarg),(extramsg)))) +#define luaL_checkstring(L,n)(luaL_checklstring(L,(n),NULL)) +#define luaL_optstring(L,n,d)(luaL_optlstring(L,(n),(d),NULL)) +#define luaL_checkint(L,n)((int)luaL_checkinteger(L,(n))) +#define luaL_optint(L,n,d)((int)luaL_optinteger(L,(n),(d))) +#define luaL_typename(L,i)lua_typename(L,lua_type(L,(i))) +#define luaL_getmetatable(L,n)(lua_getfield(L,(-10000),(n))) +#define luaL_opt(L,f,n,d)(lua_isnoneornil(L,(n))?(d):f(L,(n))) +typedef struct luaL_Buffer{ +char*p; +int lvl; +lua_State*L; +char buffer[BUFSIZ]; +}luaL_Buffer; +#define luaL_addchar(B,c)((void)((B)->p<((B)->buffer+BUFSIZ)||luaL_prepbuffer(B)),(*(B)->p++=(char)(c))) +#define luaL_addsize(B,n)((B)->p+=(n)) +static char* luaL_prepbuffer(luaL_Buffer*B); +static int luaL_argerror(lua_State*L,int narg,const char*extramsg){ +lua_Debug ar; +if(!lua_getstack(L,0,&ar)) +return luaL_error(L,"bad argument #%d (%s)",narg,extramsg); +lua_getinfo(L,"n",&ar); +if(strcmp(ar.namewhat,"method")==0){ +narg--; +if(narg==0) +return luaL_error(L,"calling "LUA_QL("%s")" on bad self (%s)", +ar.name,extramsg); +} +if(ar.name==NULL) +ar.name="?"; +return luaL_error(L,"bad argument #%d to "LUA_QL("%s")" (%s)", +narg,ar.name,extramsg); +} +static int luaL_typerror(lua_State*L,int narg,const char*tname){ +const char*msg=lua_pushfstring(L,"%s expected, got %s", +tname,luaL_typename(L,narg)); +return luaL_argerror(L,narg,msg); +} +static void tag_error(lua_State*L,int narg,int tag){ +luaL_typerror(L,narg,lua_typename(L,tag)); +} +static void luaL_where(lua_State*L,int level){ +lua_Debug ar; +if(lua_getstack(L,level,&ar)){ +lua_getinfo(L,"Sl",&ar); +if(ar.currentline>0){ +lua_pushfstring(L,"%s:%d: ",ar.short_src,ar.currentline); +return; +} +} +lua_pushliteral(L,""); +} +static int luaL_error(lua_State*L,const char*fmt,...){ +va_list argp; +va_start(argp,fmt); +luaL_where(L,1); +lua_pushvfstring(L,fmt,argp); +va_end(argp); +lua_concat(L,2); +return lua_error(L); +} +static int luaL_newmetatable(lua_State*L,const char*tname){ +lua_getfield(L,(-10000),tname); +if(!lua_isnil(L,-1)) +return 0; +lua_pop(L,1); +lua_newtable(L); +lua_pushvalue(L,-1); +lua_setfield(L,(-10000),tname); +return 1; +} +static void*luaL_checkudata(lua_State*L,int ud,const char*tname){ +void*p=lua_touserdata(L,ud); +if(p!=NULL){ +if(lua_getmetatable(L,ud)){ +lua_getfield(L,(-10000),tname); +if(lua_rawequal(L,-1,-2)){ +lua_pop(L,2); +return p; +} +} +} +luaL_typerror(L,ud,tname); +return NULL; +} +static void luaL_checkstack(lua_State*L,int space,const char*mes){ +if(!lua_checkstack(L,space)) +luaL_error(L,"stack overflow (%s)",mes); +} +static void luaL_checktype(lua_State*L,int narg,int t){ +if(lua_type(L,narg)!=t) +tag_error(L,narg,t); +} +static void luaL_checkany(lua_State*L,int narg){ +if(lua_type(L,narg)==(-1)) +luaL_argerror(L,narg,"value expected"); +} +static const char*luaL_checklstring(lua_State*L,int narg,size_t*len){ +const char*s=lua_tolstring(L,narg,len); +if(!s)tag_error(L,narg,4); +return s; +} +static const char*luaL_optlstring(lua_State*L,int narg, +const char*def,size_t*len){ +if(lua_isnoneornil(L,narg)){ +if(len) +*len=(def?strlen(def):0); +return def; +} +else return luaL_checklstring(L,narg,len); +} +static lua_Number luaL_checknumber(lua_State*L,int narg){ +lua_Number d=lua_tonumber(L,narg); +if(d==0&&!lua_isnumber(L,narg)) +tag_error(L,narg,3); +return d; +} +static lua_Integer luaL_checkinteger(lua_State*L,int narg){ +lua_Integer d=lua_tointeger(L,narg); +if(d==0&&!lua_isnumber(L,narg)) +tag_error(L,narg,3); +return d; +} +static lua_Integer luaL_optinteger(lua_State*L,int narg, +lua_Integer def){ +return luaL_opt(L,luaL_checkinteger,narg,def); +} +static int luaL_getmetafield(lua_State*L,int obj,const char*event){ +if(!lua_getmetatable(L,obj)) +return 0; +lua_pushstring(L,event); +lua_rawget(L,-2); +if(lua_isnil(L,-1)){ +lua_pop(L,2); +return 0; +} +else{ +lua_remove(L,-2); +return 1; +} +} +static void luaL_register(lua_State*L,const char*libname, +const luaL_Reg*l){ +luaI_openlib(L,libname,l,0); +} +static int libsize(const luaL_Reg*l){ +int size=0; +for(;l->name;l++)size++; +return size; +} +static void luaI_openlib(lua_State*L,const char*libname, +const luaL_Reg*l,int nup){ +if(libname){ +int size=libsize(l); +luaL_findtable(L,(-10000),"_LOADED",1); +lua_getfield(L,-1,libname); +if(!lua_istable(L,-1)){ +lua_pop(L,1); +if(luaL_findtable(L,(-10002),libname,size)!=NULL) +luaL_error(L,"name conflict for module "LUA_QL("%s"),libname); +lua_pushvalue(L,-1); +lua_setfield(L,-3,libname); +} +lua_remove(L,-2); +lua_insert(L,-(nup+1)); +} +for(;l->name;l++){ +int i; +for(i=0;ifunc,nup); +lua_setfield(L,-(nup+2),l->name); +} +lua_pop(L,nup); +} +static const char*luaL_findtable(lua_State*L,int idx, +const char*fname,int szhint){ +const char*e; +lua_pushvalue(L,idx); +do{ +e=strchr(fname,'.'); +if(e==NULL)e=fname+strlen(fname); +lua_pushlstring(L,fname,e-fname); +lua_rawget(L,-2); +if(lua_isnil(L,-1)){ +lua_pop(L,1); +lua_createtable(L,0,(*e=='.'?1:szhint)); +lua_pushlstring(L,fname,e-fname); +lua_pushvalue(L,-2); +lua_settable(L,-4); +} +else if(!lua_istable(L,-1)){ +lua_pop(L,2); +return fname; +} +lua_remove(L,-2); +fname=e+1; +}while(*e=='.'); +return NULL; +} +#define bufflen(B)((B)->p-(B)->buffer) +#define bufffree(B)((size_t)(BUFSIZ-bufflen(B))) +static int emptybuffer(luaL_Buffer*B){ +size_t l=bufflen(B); +if(l==0)return 0; +else{ +lua_pushlstring(B->L,B->buffer,l); +B->p=B->buffer; +B->lvl++; +return 1; +} +} +static void adjuststack(luaL_Buffer*B){ +if(B->lvl>1){ +lua_State*L=B->L; +int toget=1; +size_t toplen=lua_strlen(L,-1); +do{ +size_t l=lua_strlen(L,-(toget+1)); +if(B->lvl-toget+1>=(20/2)||toplen>l){ +toplen+=l; +toget++; +} +else break; +}while(togetlvl); +lua_concat(L,toget); +B->lvl=B->lvl-toget+1; +} +} +static char*luaL_prepbuffer(luaL_Buffer*B){ +if(emptybuffer(B)) +adjuststack(B); +return B->buffer; +} +static void luaL_addlstring(luaL_Buffer*B,const char*s,size_t l){ +while(l--) +luaL_addchar(B,*s++); +} +static void luaL_pushresult(luaL_Buffer*B){ +emptybuffer(B); +lua_concat(B->L,B->lvl); +B->lvl=1; +} +static void luaL_addvalue(luaL_Buffer*B){ +lua_State*L=B->L; +size_t vl; +const char*s=lua_tolstring(L,-1,&vl); +if(vl<=bufffree(B)){ +memcpy(B->p,s,vl); +B->p+=vl; +lua_pop(L,1); +} +else{ +if(emptybuffer(B)) +lua_insert(L,-2); +B->lvl++; +adjuststack(B); +} +} +static void luaL_buffinit(lua_State*L,luaL_Buffer*B){ +B->L=L; +B->p=B->buffer; +B->lvl=0; +} +typedef struct LoadF{ +int extraline; +FILE*f; +char buff[BUFSIZ]; +}LoadF; +static const char*getF(lua_State*L,void*ud,size_t*size){ +LoadF*lf=(LoadF*)ud; +(void)L; +if(lf->extraline){ +lf->extraline=0; +*size=1; +return"\n"; +} +if(feof(lf->f))return NULL; +*size=fread(lf->buff,1,sizeof(lf->buff),lf->f); +return(*size>0)?lf->buff:NULL; +} +static int errfile(lua_State*L,const char*what,int fnameindex){ +const char*serr=strerror(errno); +const char*filename=lua_tostring(L,fnameindex)+1; +lua_pushfstring(L,"cannot %s %s: %s",what,filename,serr); +lua_remove(L,fnameindex); +return(5+1); +} +static int luaL_loadfile(lua_State*L,const char*filename){ +LoadF lf; +int status,readstatus; +int c; +int fnameindex=lua_gettop(L)+1; +lf.extraline=0; +if(filename==NULL){ +lua_pushliteral(L,"=stdin"); +lf.f=stdin; +} +else{ +lua_pushfstring(L,"@%s",filename); +lf.f=fopen(filename,"r"); +if(lf.f==NULL)return errfile(L,"open",fnameindex); +} +c=getc(lf.f); +if(c=='#'){ +lf.extraline=1; +while((c=getc(lf.f))!=EOF&&c!='\n'); +if(c=='\n')c=getc(lf.f); +} +if(c=="\033Lua"[0]&&filename){ +lf.f=freopen(filename,"rb",lf.f); +if(lf.f==NULL)return errfile(L,"reopen",fnameindex); +while((c=getc(lf.f))!=EOF&&c!="\033Lua"[0]); +lf.extraline=0; +} +ungetc(c,lf.f); +status=lua_load(L,getF,&lf,lua_tostring(L,-1)); +readstatus=ferror(lf.f); +if(filename)fclose(lf.f); +if(readstatus){ +lua_settop(L,fnameindex); +return errfile(L,"read",fnameindex); +} +lua_remove(L,fnameindex); +return status; +} +typedef struct LoadS{ +const char*s; +size_t size; +}LoadS; +static const char*getS(lua_State*L,void*ud,size_t*size){ +LoadS*ls=(LoadS*)ud; +(void)L; +if(ls->size==0)return NULL; +*size=ls->size; +ls->size=0; +return ls->s; +} +static int luaL_loadbuffer(lua_State*L,const char*buff,size_t size, +const char*name){ +LoadS ls; +ls.s=buff; +ls.size=size; +return lua_load(L,getS,&ls,name); +} +static void*l_alloc(void*ud,void*ptr,size_t osize,size_t nsize){ +(void)ud; +(void)osize; +if(nsize==0){ +free(ptr); +return NULL; +} +else +return realloc(ptr,nsize); +} +static int panic(lua_State*L){ +(void)L; +fprintf(stderr,"PANIC: unprotected error in call to Lua API (%s)\n", +lua_tostring(L,-1)); +return 0; +} +static lua_State*luaL_newstate(void){ +lua_State*L=lua_newstate(l_alloc,NULL); +if(L)lua_atpanic(L,&panic); +return L; +} +static int luaB_tonumber(lua_State*L){ +int base=luaL_optint(L,2,10); +if(base==10){ +luaL_checkany(L,1); +if(lua_isnumber(L,1)){ +lua_pushnumber(L,lua_tonumber(L,1)); +return 1; +} +} +else{ +const char*s1=luaL_checkstring(L,1); +char*s2; +unsigned long n; +luaL_argcheck(L,2<=base&&base<=36,2,"base out of range"); +n=strtoul(s1,&s2,base); +if(s1!=s2){ +while(isspace((unsigned char)(*s2)))s2++; +if(*s2=='\0'){ +lua_pushnumber(L,(lua_Number)n); +return 1; +} +} +} +lua_pushnil(L); +return 1; +} +static int luaB_error(lua_State*L){ +int level=luaL_optint(L,2,1); +lua_settop(L,1); +if(lua_isstring(L,1)&&level>0){ +luaL_where(L,level); +lua_pushvalue(L,1); +lua_concat(L,2); +} +return lua_error(L); +} +static int luaB_setmetatable(lua_State*L){ +int t=lua_type(L,2); +luaL_checktype(L,1,5); +luaL_argcheck(L,t==0||t==5,2, +"nil or table expected"); +if(luaL_getmetafield(L,1,"__metatable")) +luaL_error(L,"cannot change a protected metatable"); +lua_settop(L,2); +lua_setmetatable(L,1); +return 1; +} +static void getfunc(lua_State*L,int opt){ +if(lua_isfunction(L,1))lua_pushvalue(L,1); +else{ +lua_Debug ar; +int level=opt?luaL_optint(L,1,1):luaL_checkint(L,1); +luaL_argcheck(L,level>=0,1,"level must be non-negative"); +if(lua_getstack(L,level,&ar)==0) +luaL_argerror(L,1,"invalid level"); +lua_getinfo(L,"f",&ar); +if(lua_isnil(L,-1)) +luaL_error(L,"no function environment for tail call at level %d", +level); +} +} +static int luaB_setfenv(lua_State*L){ +luaL_checktype(L,2,5); +getfunc(L,0); +lua_pushvalue(L,2); +if(lua_isnumber(L,1)&&lua_tonumber(L,1)==0){ +lua_pushthread(L); +lua_insert(L,-2); +lua_setfenv(L,-2); +return 0; +} +else if(lua_iscfunction(L,-2)||lua_setfenv(L,-2)==0) +luaL_error(L, +LUA_QL("setfenv")" cannot change environment of given object"); +return 1; +} +static int luaB_rawget(lua_State*L){ +luaL_checktype(L,1,5); +luaL_checkany(L,2); +lua_settop(L,2); +lua_rawget(L,1); +return 1; +} +static int luaB_type(lua_State*L){ +luaL_checkany(L,1); +lua_pushstring(L,luaL_typename(L,1)); +return 1; +} +static int luaB_next(lua_State*L){ +luaL_checktype(L,1,5); +lua_settop(L,2); +if(lua_next(L,1)) +return 2; +else{ +lua_pushnil(L); +return 1; +} +} +static int luaB_pairs(lua_State*L){ +luaL_checktype(L,1,5); +lua_pushvalue(L,lua_upvalueindex(1)); +lua_pushvalue(L,1); +lua_pushnil(L); +return 3; +} +static int ipairsaux(lua_State*L){ +int i=luaL_checkint(L,2); +luaL_checktype(L,1,5); +i++; +lua_pushinteger(L,i); +lua_rawgeti(L,1,i); +return(lua_isnil(L,-1))?0:2; +} +static int luaB_ipairs(lua_State*L){ +luaL_checktype(L,1,5); +lua_pushvalue(L,lua_upvalueindex(1)); +lua_pushvalue(L,1); +lua_pushinteger(L,0); +return 3; +} +static int load_aux(lua_State*L,int status){ +if(status==0) +return 1; +else{ +lua_pushnil(L); +lua_insert(L,-2); +return 2; +} +} +static int luaB_loadstring(lua_State*L){ +size_t l; +const char*s=luaL_checklstring(L,1,&l); +const char*chunkname=luaL_optstring(L,2,s); +return load_aux(L,luaL_loadbuffer(L,s,l,chunkname)); +} +static int luaB_loadfile(lua_State*L){ +const char*fname=luaL_optstring(L,1,NULL); +return load_aux(L,luaL_loadfile(L,fname)); +} +static int luaB_assert(lua_State*L){ +luaL_checkany(L,1); +if(!lua_toboolean(L,1)) +return luaL_error(L,"%s",luaL_optstring(L,2,"assertion failed!")); +return lua_gettop(L); +} +static int luaB_unpack(lua_State*L){ +int i,e,n; +luaL_checktype(L,1,5); +i=luaL_optint(L,2,1); +e=luaL_opt(L,luaL_checkint,3,luaL_getn(L,1)); +if(i>e)return 0; +n=e-i+1; +if(n<=0||!lua_checkstack(L,n)) +return luaL_error(L,"too many results to unpack"); +lua_rawgeti(L,1,i); +while(i++e)e=pos; +for(i=e;i>pos;i--){ +lua_rawgeti(L,1,i-1); +lua_rawseti(L,1,i); +} +break; +} +default:{ +return luaL_error(L,"wrong number of arguments to "LUA_QL("insert")); +} +} +luaL_setn(L,1,e); +lua_rawseti(L,1,pos); +return 0; +} +static int tremove(lua_State*L){ +int e=aux_getn(L,1); +int pos=luaL_optint(L,2,e); +if(!(1<=pos&&pos<=e)) +return 0; +luaL_setn(L,1,e-1); +lua_rawgeti(L,1,pos); +for(;posu)luaL_error(L,"invalid order function for sorting"); +lua_pop(L,1); +} +while(lua_rawgeti(L,1,--j),sort_comp(L,-3,-1)){ +if(j0); +} +l=strlen(p); +if(l==0||p[l-1]!='\n') +luaL_addsize(&b,l); +else{ +luaL_addsize(&b,l-1); +luaL_pushresult(&b); +return 1; +} +} +} +static int read_chars(lua_State*L,FILE*f,size_t n){ +size_t rlen; +size_t nr; +luaL_Buffer b; +luaL_buffinit(L,&b); +rlen=BUFSIZ; +do{ +char*p=luaL_prepbuffer(&b); +if(rlen>n)rlen=n; +nr=fread(p,sizeof(char),rlen,f); +luaL_addsize(&b,nr); +n-=nr; +}while(n>0&&nr==rlen); +luaL_pushresult(&b); +return(n==0||lua_objlen(L,-1)>0); +} +static int g_read(lua_State*L,FILE*f,int first){ +int nargs=lua_gettop(L)-1; +int success; +int n; +clearerr(f); +if(nargs==0){ +success=read_line(L,f); +n=first+1; +} +else{ +luaL_checkstack(L,nargs+20,"too many arguments"); +success=1; +for(n=first;nargs--&&success;n++){ +if(lua_type(L,n)==3){ +size_t l=(size_t)lua_tointeger(L,n); +success=(l==0)?test_eof(L,f):read_chars(L,f,l); +} +else{ +const char*p=lua_tostring(L,n); +luaL_argcheck(L,p&&p[0]=='*',n,"invalid option"); +switch(p[1]){ +case'n': +success=read_number(L,f); +break; +case'l': +success=read_line(L,f); +break; +case'a': +read_chars(L,f,~((size_t)0)); +success=1; +break; +default: +return luaL_argerror(L,n,"invalid format"); +} +} +} +} +if(ferror(f)) +return pushresult(L,0,NULL); +if(!success){ +lua_pop(L,1); +lua_pushnil(L); +} +return n-first; +} +static int io_read(lua_State*L){ +return g_read(L,getiofile(L,1),1); +} +static int f_read(lua_State*L){ +return g_read(L,tofile(L),2); +} +static int io_readline(lua_State*L){ +FILE*f=*(FILE**)lua_touserdata(L,lua_upvalueindex(1)); +int sucess; +if(f==NULL) +luaL_error(L,"file is already closed"); +sucess=read_line(L,f); +if(ferror(f)) +return luaL_error(L,"%s",strerror(errno)); +if(sucess)return 1; +else{ +if(lua_toboolean(L,lua_upvalueindex(2))){ +lua_settop(L,0); +lua_pushvalue(L,lua_upvalueindex(1)); +aux_close(L); +} +return 0; +} +} +static int g_write(lua_State*L,FILE*f,int arg){ +int nargs=lua_gettop(L)-1; +int status=1; +for(;nargs--;arg++){ +if(lua_type(L,arg)==3){ +status=status&& +fprintf(f,"%.14g",lua_tonumber(L,arg))>0; +} +else{ +size_t l; +const char*s=luaL_checklstring(L,arg,&l); +status=status&&(fwrite(s,sizeof(char),l,f)==l); +} +} +return pushresult(L,status,NULL); +} +static int io_write(lua_State*L){ +return g_write(L,getiofile(L,2),1); +} +static int f_write(lua_State*L){ +return g_write(L,tofile(L),2); +} +static int io_flush(lua_State*L){ +return pushresult(L,fflush(getiofile(L,2))==0,NULL); +} +static int f_flush(lua_State*L){ +return pushresult(L,fflush(tofile(L))==0,NULL); +} +static const luaL_Reg iolib[]={ +{"close",io_close}, +{"flush",io_flush}, +{"input",io_input}, +{"lines",io_lines}, +{"open",io_open}, +{"output",io_output}, +{"read",io_read}, +{"type",io_type}, +{"write",io_write}, +{NULL,NULL} +}; +static const luaL_Reg flib[]={ +{"close",io_close}, +{"flush",f_flush}, +{"lines",f_lines}, +{"read",f_read}, +{"write",f_write}, +{"__gc",io_gc}, +{NULL,NULL} +}; +static void createmeta(lua_State*L){ +luaL_newmetatable(L,"FILE*"); +lua_pushvalue(L,-1); +lua_setfield(L,-2,"__index"); +luaL_register(L,NULL,flib); +} +static void createstdfile(lua_State*L,FILE*f,int k,const char*fname){ +*newfile(L)=f; +if(k>0){ +lua_pushvalue(L,-1); +lua_rawseti(L,(-10001),k); +} +lua_pushvalue(L,-2); +lua_setfenv(L,-2); +lua_setfield(L,-3,fname); +} +static void newfenv(lua_State*L,lua_CFunction cls){ +lua_createtable(L,0,1); +lua_pushcfunction(L,cls); +lua_setfield(L,-2,"__close"); +} +static int luaopen_io(lua_State*L){ +createmeta(L); +newfenv(L,io_fclose); +lua_replace(L,(-10001)); +luaL_register(L,"io",iolib); +newfenv(L,io_noclose); +createstdfile(L,stdin,1,"stdin"); +createstdfile(L,stdout,2,"stdout"); +createstdfile(L,stderr,0,"stderr"); +lua_pop(L,1); +lua_getfield(L,-1,"popen"); +newfenv(L,io_pclose); +lua_setfenv(L,-2); +lua_pop(L,1); +return 1; +} +static int os_pushresult(lua_State*L,int i,const char*filename){ +int en=errno; +if(i){ +lua_pushboolean(L,1); +return 1; +} +else{ +lua_pushnil(L); +lua_pushfstring(L,"%s: %s",filename,strerror(en)); +lua_pushinteger(L,en); +return 3; +} +} +static int os_remove(lua_State*L){ +const char*filename=luaL_checkstring(L,1); +return os_pushresult(L,remove(filename)==0,filename); +} +static int os_exit(lua_State*L){ +exit(luaL_optint(L,1,EXIT_SUCCESS)); +} +static const luaL_Reg syslib[]={ +{"exit",os_exit}, +{"remove",os_remove}, +{NULL,NULL} +}; +static int luaopen_os(lua_State*L){ +luaL_register(L,"os",syslib); +return 1; +} +#define uchar(c)((unsigned char)(c)) +static ptrdiff_t posrelat(ptrdiff_t pos,size_t len){ +if(pos<0)pos+=(ptrdiff_t)len+1; +return(pos>=0)?pos:0; +} +static int str_sub(lua_State*L){ +size_t l; +const char*s=luaL_checklstring(L,1,&l); +ptrdiff_t start=posrelat(luaL_checkinteger(L,2),l); +ptrdiff_t end=posrelat(luaL_optinteger(L,3,-1),l); +if(start<1)start=1; +if(end>(ptrdiff_t)l)end=(ptrdiff_t)l; +if(start<=end) +lua_pushlstring(L,s+start-1,end-start+1); +else lua_pushliteral(L,""); +return 1; +} +static int str_lower(lua_State*L){ +size_t l; +size_t i; +luaL_Buffer b; +const char*s=luaL_checklstring(L,1,&l); +luaL_buffinit(L,&b); +for(i=0;i0) +luaL_addlstring(&b,s,l); +luaL_pushresult(&b); +return 1; +} +static int str_byte(lua_State*L){ +size_t l; +const char*s=luaL_checklstring(L,1,&l); +ptrdiff_t posi=posrelat(luaL_optinteger(L,2,1),l); +ptrdiff_t pose=posrelat(luaL_optinteger(L,3,posi),l); +int n,i; +if(posi<=0)posi=1; +if((size_t)pose>l)pose=l; +if(posi>pose)return 0; +n=(int)(pose-posi+1); +if(posi+n<=pose) +luaL_error(L,"string slice too long"); +luaL_checkstack(L,n,"string slice too long"); +for(i=0;i=ms->level||ms->capture[l].len==(-1)) +return luaL_error(ms->L,"invalid capture index"); +return l; +} +static int capture_to_close(MatchState*ms){ +int level=ms->level; +for(level--;level>=0;level--) +if(ms->capture[level].len==(-1))return level; +return luaL_error(ms->L,"invalid pattern capture"); +} +static const char*classend(MatchState*ms,const char*p){ +switch(*p++){ +case'%':{ +if(*p=='\0') +luaL_error(ms->L,"malformed pattern (ends with "LUA_QL("%%")")"); +return p+1; +} +case'[':{ +if(*p=='^')p++; +do{ +if(*p=='\0') +luaL_error(ms->L,"malformed pattern (missing "LUA_QL("]")")"); +if(*(p++)=='%'&&*p!='\0') +p++; +}while(*p!=']'); +return p+1; +} +default:{ +return p; +} +} +} +static int match_class(int c,int cl){ +int res; +switch(tolower(cl)){ +case'a':res=isalpha(c);break; +case'c':res=iscntrl(c);break; +case'd':res=isdigit(c);break; +case'l':res=islower(c);break; +case'p':res=ispunct(c);break; +case's':res=isspace(c);break; +case'u':res=isupper(c);break; +case'w':res=isalnum(c);break; +case'x':res=isxdigit(c);break; +case'z':res=(c==0);break; +default:return(cl==c); +} +return(islower(cl)?res:!res); +} +static int matchbracketclass(int c,const char*p,const char*ec){ +int sig=1; +if(*(p+1)=='^'){ +sig=0; +p++; +} +while(++pL,"unbalanced pattern"); +if(*s!=*p)return NULL; +else{ +int b=*p; +int e=*(p+1); +int cont=1; +while(++ssrc_end){ +if(*s==e){ +if(--cont==0)return s+1; +} +else if(*s==b)cont++; +} +} +return NULL; +} +static const char*max_expand(MatchState*ms,const char*s, +const char*p,const char*ep){ +ptrdiff_t i=0; +while((s+i)src_end&&singlematch(uchar(*(s+i)),p,ep)) +i++; +while(i>=0){ +const char*res=match(ms,(s+i),ep+1); +if(res)return res; +i--; +} +return NULL; +} +static const char*min_expand(MatchState*ms,const char*s, +const char*p,const char*ep){ +for(;;){ +const char*res=match(ms,s,ep+1); +if(res!=NULL) +return res; +else if(ssrc_end&&singlematch(uchar(*s),p,ep)) +s++; +else return NULL; +} +} +static const char*start_capture(MatchState*ms,const char*s, +const char*p,int what){ +const char*res; +int level=ms->level; +if(level>=32)luaL_error(ms->L,"too many captures"); +ms->capture[level].init=s; +ms->capture[level].len=what; +ms->level=level+1; +if((res=match(ms,s,p))==NULL) +ms->level--; +return res; +} +static const char*end_capture(MatchState*ms,const char*s, +const char*p){ +int l=capture_to_close(ms); +const char*res; +ms->capture[l].len=s-ms->capture[l].init; +if((res=match(ms,s,p))==NULL) +ms->capture[l].len=(-1); +return res; +} +static const char*match_capture(MatchState*ms,const char*s,int l){ +size_t len; +l=check_capture(ms,l); +len=ms->capture[l].len; +if((size_t)(ms->src_end-s)>=len&& +memcmp(ms->capture[l].init,s,len)==0) +return s+len; +else return NULL; +} +static const char*match(MatchState*ms,const char*s,const char*p){ +init: +switch(*p){ +case'(':{ +if(*(p+1)==')') +return start_capture(ms,s,p+2,(-2)); +else +return start_capture(ms,s,p+1,(-1)); +} +case')':{ +return end_capture(ms,s,p+1); +} +case'%':{ +switch(*(p+1)){ +case'b':{ +s=matchbalance(ms,s,p+2); +if(s==NULL)return NULL; +p+=4;goto init; +} +case'f':{ +const char*ep;char previous; +p+=2; +if(*p!='[') +luaL_error(ms->L,"missing "LUA_QL("[")" after " +LUA_QL("%%f")" in pattern"); +ep=classend(ms,p); +previous=(s==ms->src_init)?'\0':*(s-1); +if(matchbracketclass(uchar(previous),p,ep-1)|| +!matchbracketclass(uchar(*s),p,ep-1))return NULL; +p=ep;goto init; +} +default:{ +if(isdigit(uchar(*(p+1)))){ +s=match_capture(ms,s,uchar(*(p+1))); +if(s==NULL)return NULL; +p+=2;goto init; +} +goto dflt; +} +} +} +case'\0':{ +return s; +} +case'$':{ +if(*(p+1)=='\0') +return(s==ms->src_end)?s:NULL; +else goto dflt; +} +default:dflt:{ +const char*ep=classend(ms,p); +int m=ssrc_end&&singlematch(uchar(*s),p,ep); +switch(*ep){ +case'?':{ +const char*res; +if(m&&((res=match(ms,s+1,ep+1))!=NULL)) +return res; +p=ep+1;goto init; +} +case'*':{ +return max_expand(ms,s,p,ep); +} +case'+':{ +return(m?max_expand(ms,s+1,p,ep):NULL); +} +case'-':{ +return min_expand(ms,s,p,ep); +} +default:{ +if(!m)return NULL; +s++;p=ep;goto init; +} +} +} +} +} +static const char*lmemfind(const char*s1,size_t l1, +const char*s2,size_t l2){ +if(l2==0)return s1; +else if(l2>l1)return NULL; +else{ +const char*init; +l2--; +l1=l1-l2; +while(l1>0&&(init=(const char*)memchr(s1,*s2,l1))!=NULL){ +init++; +if(memcmp(init,s2+1,l2)==0) +return init-1; +else{ +l1-=init-s1; +s1=init; +} +} +return NULL; +} +} +static void push_onecapture(MatchState*ms,int i,const char*s, +const char*e){ +if(i>=ms->level){ +if(i==0) +lua_pushlstring(ms->L,s,e-s); +else +luaL_error(ms->L,"invalid capture index"); +} +else{ +ptrdiff_t l=ms->capture[i].len; +if(l==(-1))luaL_error(ms->L,"unfinished capture"); +if(l==(-2)) +lua_pushinteger(ms->L,ms->capture[i].init-ms->src_init+1); +else +lua_pushlstring(ms->L,ms->capture[i].init,l); +} +} +static int push_captures(MatchState*ms,const char*s,const char*e){ +int i; +int nlevels=(ms->level==0&&s)?1:ms->level; +luaL_checkstack(ms->L,nlevels,"too many captures"); +for(i=0;il1)init=(ptrdiff_t)l1; +if(find&&(lua_toboolean(L,4)|| +strpbrk(p,"^$*+?.([%-")==NULL)){ +const char*s2=lmemfind(s+init,l1-init,p,l2); +if(s2){ +lua_pushinteger(L,s2-s+1); +lua_pushinteger(L,s2-s+l2); +return 2; +} +} +else{ +MatchState ms; +int anchor=(*p=='^')?(p++,1):0; +const char*s1=s+init; +ms.L=L; +ms.src_init=s; +ms.src_end=s+l1; +do{ +const char*res; +ms.level=0; +if((res=match(&ms,s1,p))!=NULL){ +if(find){ +lua_pushinteger(L,s1-s+1); +lua_pushinteger(L,res-s); +return push_captures(&ms,NULL,0)+2; +} +else +return push_captures(&ms,s1,res); +} +}while(s1++L,3,&l); +for(i=0;iL; +switch(lua_type(L,3)){ +case 3: +case 4:{ +add_s(ms,b,s,e); +return; +} +case 6:{ +int n; +lua_pushvalue(L,3); +n=push_captures(ms,s,e); +lua_call(L,n,1); +break; +} +case 5:{ +push_onecapture(ms,0,s,e); +lua_gettable(L,3); +break; +} +} +if(!lua_toboolean(L,-1)){ +lua_pop(L,1); +lua_pushlstring(L,s,e-s); +} +else if(!lua_isstring(L,-1)) +luaL_error(L,"invalid replacement value (a %s)",luaL_typename(L,-1)); +luaL_addvalue(b); +} +static int str_gsub(lua_State*L){ +size_t srcl; +const char*src=luaL_checklstring(L,1,&srcl); +const char*p=luaL_checkstring(L,2); +int tr=lua_type(L,3); +int max_s=luaL_optint(L,4,srcl+1); +int anchor=(*p=='^')?(p++,1):0; +int n=0; +MatchState ms; +luaL_Buffer b; +luaL_argcheck(L,tr==3||tr==4|| +tr==6||tr==5,3, +"string/function/table expected"); +luaL_buffinit(L,&b); +ms.L=L; +ms.src_init=src; +ms.src_end=src+srcl; +while(nsrc) +src=e; +else if(src=sizeof("-+ #0")) +luaL_error(L,"invalid format (repeated flags)"); +if(isdigit(uchar(*p)))p++; +if(isdigit(uchar(*p)))p++; +if(*p=='.'){ +p++; +if(isdigit(uchar(*p)))p++; +if(isdigit(uchar(*p)))p++; +} +if(isdigit(uchar(*p))) +luaL_error(L,"invalid format (width or precision too long)"); +*(form++)='%'; +strncpy(form,strfrmt,p-strfrmt+1); +form+=p-strfrmt+1; +*form='\0'; +return p; +} +static void addintlen(char*form){ +size_t l=strlen(form); +char spec=form[l-1]; +strcpy(form+l-1,"l"); +form[l+sizeof("l")-2]=spec; +form[l+sizeof("l")-1]='\0'; +} +static int str_format(lua_State*L){ +int top=lua_gettop(L); +int arg=1; +size_t sfl; +const char*strfrmt=luaL_checklstring(L,arg,&sfl); +const char*strfrmt_end=strfrmt+sfl; +luaL_Buffer b; +luaL_buffinit(L,&b); +while(strfrmttop) +luaL_argerror(L,arg,"no value"); +strfrmt=scanformat(L,strfrmt,form); +switch(*strfrmt++){ +case'c':{ +sprintf(buff,form,(int)luaL_checknumber(L,arg)); +break; +} +case'd':case'i':{ +addintlen(form); +sprintf(buff,form,(long)luaL_checknumber(L,arg)); +break; +} +case'o':case'u':case'x':case'X':{ +addintlen(form); +sprintf(buff,form,(unsigned long)luaL_checknumber(L,arg)); +break; +} +case'e':case'E':case'f': +case'g':case'G':{ +sprintf(buff,form,(double)luaL_checknumber(L,arg)); +break; +} +case'q':{ +addquoted(L,&b,arg); +continue; +} +case's':{ +size_t l; +const char*s=luaL_checklstring(L,arg,&l); +if(!strchr(form,'.')&&l>=100){ +lua_pushvalue(L,arg); +luaL_addvalue(&b); +continue; +} +else{ +sprintf(buff,form,s); +break; +} +} +default:{ +return luaL_error(L,"invalid option "LUA_QL("%%%c")" to " +LUA_QL("format"),*(strfrmt-1)); +} +} +luaL_addlstring(&b,buff,strlen(buff)); +} +} +luaL_pushresult(&b); +return 1; +} +static const luaL_Reg strlib[]={ +{"byte",str_byte}, +{"char",str_char}, +{"find",str_find}, +{"format",str_format}, +{"gmatch",gmatch}, +{"gsub",str_gsub}, +{"lower",str_lower}, +{"match",str_match}, +{"rep",str_rep}, +{"sub",str_sub}, +{"upper",str_upper}, +{NULL,NULL} +}; +static void createmetatable(lua_State*L){ +lua_createtable(L,0,1); +lua_pushliteral(L,""); +lua_pushvalue(L,-2); +lua_setmetatable(L,-2); +lua_pop(L,1); +lua_pushvalue(L,-2); +lua_setfield(L,-2,"__index"); +lua_pop(L,1); +} +static int luaopen_string(lua_State*L){ +luaL_register(L,"string",strlib); +createmetatable(L); +return 1; +} +static const luaL_Reg lualibs[]={ +{"",luaopen_base}, +{"table",luaopen_table}, +{"io",luaopen_io}, +{"os",luaopen_os}, +{"string",luaopen_string}, +{NULL,NULL} +}; +static void luaL_openlibs(lua_State*L){ +const luaL_Reg*lib=lualibs; +for(;lib->func;lib++){ +lua_pushcfunction(L,lib->func); +lua_pushstring(L,lib->name); +lua_call(L,1,0); +} +} +typedef unsigned int UB; +static UB barg(lua_State*L,int idx){ +union{lua_Number n;U64 b;}bn; +bn.n=lua_tonumber(L,idx)+6755399441055744.0; +if(bn.n==0.0&&!lua_isnumber(L,idx))luaL_typerror(L,idx,"number"); +return(UB)bn.b; +} +#define BRET(b)lua_pushnumber(L,(lua_Number)(int)(b));return 1; +static int tobit(lua_State*L){ +BRET(barg(L,1))} +static int bnot(lua_State*L){ +BRET(~barg(L,1))} +static int band(lua_State*L){ +int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b&=barg(L,i);BRET(b)} +static int bor(lua_State*L){ +int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b|=barg(L,i);BRET(b)} +static int bxor(lua_State*L){ +int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b^=barg(L,i);BRET(b)} +static int lshift(lua_State*L){ +UB b=barg(L,1),n=barg(L,2)&31;BRET(b<>n)} +static int arshift(lua_State*L){ +UB b=barg(L,1),n=barg(L,2)&31;BRET((int)b>>n)} +static int rol(lua_State*L){ +UB b=barg(L,1),n=barg(L,2)&31;BRET((b<>(32-n)))} +static int ror(lua_State*L){ +UB b=barg(L,1),n=barg(L,2)&31;BRET((b>>n)|(b<<(32-n)))} +static int bswap(lua_State*L){ +UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)} +static int tohex(lua_State*L){ +UB b=barg(L,1); +int n=lua_isnone(L,2)?8:(int)barg(L,2); +const char*hexdigits="0123456789abcdef"; +char buf[8]; +int i; +if(n<0){n=-n;hexdigits="0123456789ABCDEF";} +if(n>8)n=8; +for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;} +lua_pushlstring(L,buf,(size_t)n); +return 1; +} +static const struct luaL_Reg bitlib[]={ +{"tobit",tobit}, +{"bnot",bnot}, +{"band",band}, +{"bor",bor}, +{"bxor",bxor}, +{"lshift",lshift}, +{"rshift",rshift}, +{"arshift",arshift}, +{"rol",rol}, +{"ror",ror}, +{"bswap",bswap}, +{"tohex",tohex}, +{NULL,NULL} +}; +int main(int argc,char**argv){ +lua_State*L=luaL_newstate(); +int i; +luaL_openlibs(L); +luaL_register(L,"bit",bitlib); +if(argc<2)return sizeof(void*); +lua_createtable(L,0,1); +lua_pushstring(L,argv[1]); +lua_rawseti(L,-2,0); +lua_setglobal(L,"arg"); +if(luaL_loadfile(L,argv[1])) +goto err; +for(i=2;i -- BYTECODE -- [...] +-- print(bc.line(foo, 2)) --> 0002 KSTR 1 1 ; "hello" +-- +-- local out = { +-- -- Do something with each line: +-- write = function(t, ...) io.write(...) end, +-- close = function(t) end, +-- flush = function(t) end, +-- } +-- bc.dump(foo, out) +-- +------------------------------------------------------------------------------ + +-- Cache some library functions and objects. +local jit = require("jit") +assert(jit.version_num == 20005, "LuaJIT core/library version mismatch") +local jutil = require("jit.util") +local vmdef = require("jit.vmdef") +local bit = require("bit") +local sub, gsub, format = string.sub, string.gsub, string.format +local byte, band, shr = string.byte, bit.band, bit.rshift +local funcinfo, funcbc, funck = jutil.funcinfo, jutil.funcbc, jutil.funck +local funcuvname = jutil.funcuvname +local bcnames = vmdef.bcnames +local stdout, stderr = io.stdout, io.stderr + +------------------------------------------------------------------------------ + +local function ctlsub(c) + if c == "\n" then return "\\n" + elseif c == "\r" then return "\\r" + elseif c == "\t" then return "\\t" + else return format("\\%03d", byte(c)) + end +end + +-- Return one bytecode line. +local function bcline(func, pc, prefix) + local ins, m = funcbc(func, pc) + if not ins then return end + local ma, mb, mc = band(m, 7), band(m, 15*8), band(m, 15*128) + local a = band(shr(ins, 8), 0xff) + local oidx = 6*band(ins, 0xff) + local op = sub(bcnames, oidx+1, oidx+6) + local s = format("%04d %s %-6s %3s ", + pc, prefix or " ", op, ma == 0 and "" or a) + local d = shr(ins, 16) + if mc == 13*128 then -- BCMjump + return format("%s=> %04d\n", s, pc+d-0x7fff) + end + if mb ~= 0 then + d = band(d, 0xff) + elseif mc == 0 then + return s.."\n" + end + local kc + if mc == 10*128 then -- BCMstr + kc = funck(func, -d-1) + kc = format(#kc > 40 and '"%.40s"~' or '"%s"', gsub(kc, "%c", ctlsub)) + elseif mc == 9*128 then -- BCMnum + kc = funck(func, d) + if op == "TSETM " then kc = kc - 2^52 end + elseif mc == 12*128 then -- BCMfunc + local fi = funcinfo(funck(func, -d-1)) + if fi.ffid then + kc = vmdef.ffnames[fi.ffid] + else + kc = fi.loc + end + elseif mc == 5*128 then -- BCMuv + kc = funcuvname(func, d) + end + if ma == 5 then -- BCMuv + local ka = funcuvname(func, a) + if kc then kc = ka.." ; "..kc else kc = ka end + end + if mb ~= 0 then + local b = shr(ins, 24) + if kc then return format("%s%3d %3d ; %s\n", s, b, d, kc) end + return format("%s%3d %3d\n", s, b, d) + end + if kc then return format("%s%3d ; %s\n", s, d, kc) end + if mc == 7*128 and d > 32767 then d = d - 65536 end -- BCMlits + return format("%s%3d\n", s, d) +end + +-- Collect branch targets of a function. +local function bctargets(func) + local target = {} + for pc=1,1000000000 do + local ins, m = funcbc(func, pc) + if not ins then break end + if band(m, 15*128) == 13*128 then target[pc+shr(ins, 16)-0x7fff] = true end + end + return target +end + +-- Dump bytecode instructions of a function. +local function bcdump(func, out, all) + if not out then out = stdout end + local fi = funcinfo(func) + if all and fi.children then + for n=-1,-1000000000,-1 do + local k = funck(func, n) + if not k then break end + if type(k) == "proto" then bcdump(k, out, true) end + end + end + out:write(format("-- BYTECODE -- %s-%d\n", fi.loc, fi.lastlinedefined)) + local target = bctargets(func) + for pc=1,1000000000 do + local s = bcline(func, pc, target[pc] and "=>") + if not s then break end + out:write(s) + end + out:write("\n") + out:flush() +end + +------------------------------------------------------------------------------ + +-- Active flag and output file handle. +local active, out + +-- List handler. +local function h_list(func) + return bcdump(func, out) +end + +-- Detach list handler. +local function bclistoff() + if active then + active = false + jit.attach(h_list) + if out and out ~= stdout and out ~= stderr then out:close() end + out = nil + end +end + +-- Open the output file and attach list handler. +local function bcliston(outfile) + if active then bclistoff() end + if not outfile then outfile = os.getenv("LUAJIT_LISTFILE") end + if outfile then + out = outfile == "-" and stdout or assert(io.open(outfile, "w")) + else + out = stderr + end + jit.attach(h_list, "bc") + active = true +end + +-- Public module functions. +module(...) + +line = bcline +dump = bcdump +targets = bctargets + +on = bcliston +off = bclistoff +start = bcliston -- For -j command line option. + + +``` + +`include/luajit-2.0.5/src/jit/bcsave.lua`: + +```lua +---------------------------------------------------------------------------- +-- LuaJIT module to save/list bytecode. +-- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- +-- This module saves or lists the bytecode for an input file. +-- It's run by the -b command line option. +-- +------------------------------------------------------------------------------ + +local jit = require("jit") +assert(jit.version_num == 20005, "LuaJIT core/library version mismatch") +local bit = require("bit") + +-- Symbol name prefix for LuaJIT bytecode. +local LJBC_PREFIX = "luaJIT_BC_" + +------------------------------------------------------------------------------ + +local function usage() + io.stderr:write[[ +Save LuaJIT bytecode: luajit -b[options] input output + -l Only list bytecode. + -s Strip debug info (default). + -g Keep debug info. + -n name Set module name (default: auto-detect from input name). + -t type Set output file type (default: auto-detect from output name). + -a arch Override architecture for object files (default: native). + -o os Override OS for object files (default: native). + -e chunk Use chunk string as input. + -- Stop handling options. + - Use stdin as input and/or stdout as output. + +File types: c h obj o raw (default) +]] + os.exit(1) +end + +local function check(ok, ...) + if ok then return ok, ... end + io.stderr:write("luajit: ", ...) + io.stderr:write("\n") + os.exit(1) +end + +local function readfile(input) + if type(input) == "function" then return input end + if input == "-" then input = nil end + return check(loadfile(input)) +end + +local function savefile(name, mode) + if name == "-" then return io.stdout end + return check(io.open(name, mode)) +end + +------------------------------------------------------------------------------ + +local map_type = { + raw = "raw", c = "c", h = "h", o = "obj", obj = "obj", +} + +local map_arch = { + x86 = true, x64 = true, arm = true, ppc = true, ppcspe = true, + mips = true, mipsel = true, +} + +local map_os = { + linux = true, windows = true, osx = true, freebsd = true, netbsd = true, + openbsd = true, dragonfly = true, solaris = true, +} + +local function checkarg(str, map, err) + str = string.lower(str) + local s = check(map[str], "unknown ", err) + return s == true and str or s +end + +local function detecttype(str) + local ext = string.match(string.lower(str), "%.(%a+)$") + return map_type[ext] or "raw" +end + +local function checkmodname(str) + check(string.match(str, "^[%w_.%-]+$"), "bad module name") + return string.gsub(str, "[%.%-]", "_") +end + +local function detectmodname(str) + if type(str) == "string" then + local tail = string.match(str, "[^/\\]+$") + if tail then str = tail end + local head = string.match(str, "^(.*)%.[^.]*$") + if head then str = head end + str = string.match(str, "^[%w_.%-]+") + else + str = nil + end + check(str, "cannot derive module name, use -n name") + return string.gsub(str, "[%.%-]", "_") +end + +------------------------------------------------------------------------------ + +local function bcsave_tail(fp, output, s) + local ok, err = fp:write(s) + if ok and output ~= "-" then ok, err = fp:close() end + check(ok, "cannot write ", output, ": ", err) +end + +local function bcsave_raw(output, s) + local fp = savefile(output, "wb") + bcsave_tail(fp, output, s) +end + +local function bcsave_c(ctx, output, s) + local fp = savefile(output, "w") + if ctx.type == "c" then + fp:write(string.format([[ +#ifdef _cplusplus +extern "C" +#endif +#ifdef _WIN32 +__declspec(dllexport) +#endif +const char %s%s[] = { +]], LJBC_PREFIX, ctx.modname)) + else + fp:write(string.format([[ +#define %s%s_SIZE %d +static const char %s%s[] = { +]], LJBC_PREFIX, ctx.modname, #s, LJBC_PREFIX, ctx.modname)) + end + local t, n, m = {}, 0, 0 + for i=1,#s do + local b = tostring(string.byte(s, i)) + m = m + #b + 1 + if m > 78 then + fp:write(table.concat(t, ",", 1, n), ",\n") + n, m = 0, #b + 1 + end + n = n + 1 + t[n] = b + end + bcsave_tail(fp, output, table.concat(t, ",", 1, n).."\n};\n") +end + +local function bcsave_elfobj(ctx, output, s, ffi) + ffi.cdef[[ +typedef struct { + uint8_t emagic[4], eclass, eendian, eversion, eosabi, eabiversion, epad[7]; + uint16_t type, machine; + uint32_t version; + uint32_t entry, phofs, shofs; + uint32_t flags; + uint16_t ehsize, phentsize, phnum, shentsize, shnum, shstridx; +} ELF32header; +typedef struct { + uint8_t emagic[4], eclass, eendian, eversion, eosabi, eabiversion, epad[7]; + uint16_t type, machine; + uint32_t version; + uint64_t entry, phofs, shofs; + uint32_t flags; + uint16_t ehsize, phentsize, phnum, shentsize, shnum, shstridx; +} ELF64header; +typedef struct { + uint32_t name, type, flags, addr, ofs, size, link, info, align, entsize; +} ELF32sectheader; +typedef struct { + uint32_t name, type; + uint64_t flags, addr, ofs, size; + uint32_t link, info; + uint64_t align, entsize; +} ELF64sectheader; +typedef struct { + uint32_t name, value, size; + uint8_t info, other; + uint16_t sectidx; +} ELF32symbol; +typedef struct { + uint32_t name; + uint8_t info, other; + uint16_t sectidx; + uint64_t value, size; +} ELF64symbol; +typedef struct { + ELF32header hdr; + ELF32sectheader sect[6]; + ELF32symbol sym[2]; + uint8_t space[4096]; +} ELF32obj; +typedef struct { + ELF64header hdr; + ELF64sectheader sect[6]; + ELF64symbol sym[2]; + uint8_t space[4096]; +} ELF64obj; +]] + local symname = LJBC_PREFIX..ctx.modname + local is64, isbe = false, false + if ctx.arch == "x64" then + is64 = true + elseif ctx.arch == "ppc" or ctx.arch == "ppcspe" or ctx.arch == "mips" then + isbe = true + end + + -- Handle different host/target endianess. + local function f32(x) return x end + local f16, fofs = f32, f32 + if ffi.abi("be") ~= isbe then + f32 = bit.bswap + function f16(x) return bit.rshift(bit.bswap(x), 16) end + if is64 then + local two32 = ffi.cast("int64_t", 2^32) + function fofs(x) return bit.bswap(x)*two32 end + else + fofs = f32 + end + end + + -- Create ELF object and fill in header. + local o = ffi.new(is64 and "ELF64obj" or "ELF32obj") + local hdr = o.hdr + if ctx.os == "bsd" or ctx.os == "other" then -- Determine native hdr.eosabi. + local bf = assert(io.open("/bin/ls", "rb")) + local bs = bf:read(9) + bf:close() + ffi.copy(o, bs, 9) + check(hdr.emagic[0] == 127, "no support for writing native object files") + else + hdr.emagic = "\127ELF" + hdr.eosabi = ({ freebsd=9, netbsd=2, openbsd=12, solaris=6 })[ctx.os] or 0 + end + hdr.eclass = is64 and 2 or 1 + hdr.eendian = isbe and 2 or 1 + hdr.eversion = 1 + hdr.type = f16(1) + hdr.machine = f16(({ x86=3, x64=62, arm=40, ppc=20, ppcspe=20, mips=8, mipsel=8 })[ctx.arch]) + if ctx.arch == "mips" or ctx.arch == "mipsel" then + hdr.flags = f32(0x50001006) + end + hdr.version = f32(1) + hdr.shofs = fofs(ffi.offsetof(o, "sect")) + hdr.ehsize = f16(ffi.sizeof(hdr)) + hdr.shentsize = f16(ffi.sizeof(o.sect[0])) + hdr.shnum = f16(6) + hdr.shstridx = f16(2) + + -- Fill in sections and symbols. + local sofs, ofs = ffi.offsetof(o, "space"), 1 + for i,name in ipairs{ + ".symtab", ".shstrtab", ".strtab", ".rodata", ".note.GNU-stack", + } do + local sect = o.sect[i] + sect.align = fofs(1) + sect.name = f32(ofs) + ffi.copy(o.space+ofs, name) + ofs = ofs + #name+1 + end + o.sect[1].type = f32(2) -- .symtab + o.sect[1].link = f32(3) + o.sect[1].info = f32(1) + o.sect[1].align = fofs(8) + o.sect[1].ofs = fofs(ffi.offsetof(o, "sym")) + o.sect[1].entsize = fofs(ffi.sizeof(o.sym[0])) + o.sect[1].size = fofs(ffi.sizeof(o.sym)) + o.sym[1].name = f32(1) + o.sym[1].sectidx = f16(4) + o.sym[1].size = fofs(#s) + o.sym[1].info = 17 + o.sect[2].type = f32(3) -- .shstrtab + o.sect[2].ofs = fofs(sofs) + o.sect[2].size = fofs(ofs) + o.sect[3].type = f32(3) -- .strtab + o.sect[3].ofs = fofs(sofs + ofs) + o.sect[3].size = fofs(#symname+1) + ffi.copy(o.space+ofs+1, symname) + ofs = ofs + #symname + 2 + o.sect[4].type = f32(1) -- .rodata + o.sect[4].flags = fofs(2) + o.sect[4].ofs = fofs(sofs + ofs) + o.sect[4].size = fofs(#s) + o.sect[5].type = f32(1) -- .note.GNU-stack + o.sect[5].ofs = fofs(sofs + ofs + #s) + + -- Write ELF object file. + local fp = savefile(output, "wb") + fp:write(ffi.string(o, ffi.sizeof(o)-4096+ofs)) + bcsave_tail(fp, output, s) +end + +local function bcsave_peobj(ctx, output, s, ffi) + ffi.cdef[[ +typedef struct { + uint16_t arch, nsects; + uint32_t time, symtabofs, nsyms; + uint16_t opthdrsz, flags; +} PEheader; +typedef struct { + char name[8]; + uint32_t vsize, vaddr, size, ofs, relocofs, lineofs; + uint16_t nreloc, nline; + uint32_t flags; +} PEsection; +typedef struct __attribute((packed)) { + union { + char name[8]; + uint32_t nameref[2]; + }; + uint32_t value; + int16_t sect; + uint16_t type; + uint8_t scl, naux; +} PEsym; +typedef struct __attribute((packed)) { + uint32_t size; + uint16_t nreloc, nline; + uint32_t cksum; + uint16_t assoc; + uint8_t comdatsel, unused[3]; +} PEsymaux; +typedef struct { + PEheader hdr; + PEsection sect[2]; + // Must be an even number of symbol structs. + PEsym sym0; + PEsymaux sym0aux; + PEsym sym1; + PEsymaux sym1aux; + PEsym sym2; + PEsym sym3; + uint32_t strtabsize; + uint8_t space[4096]; +} PEobj; +]] + local symname = LJBC_PREFIX..ctx.modname + local is64 = false + if ctx.arch == "x86" then + symname = "_"..symname + elseif ctx.arch == "x64" then + is64 = true + end + local symexport = " /EXPORT:"..symname..",DATA " + + -- The file format is always little-endian. Swap if the host is big-endian. + local function f32(x) return x end + local f16 = f32 + if ffi.abi("be") then + f32 = bit.bswap + function f16(x) return bit.rshift(bit.bswap(x), 16) end + end + + -- Create PE object and fill in header. + local o = ffi.new("PEobj") + local hdr = o.hdr + hdr.arch = f16(({ x86=0x14c, x64=0x8664, arm=0x1c0, ppc=0x1f2, mips=0x366, mipsel=0x366 })[ctx.arch]) + hdr.nsects = f16(2) + hdr.symtabofs = f32(ffi.offsetof(o, "sym0")) + hdr.nsyms = f32(6) + + -- Fill in sections and symbols. + o.sect[0].name = ".drectve" + o.sect[0].size = f32(#symexport) + o.sect[0].flags = f32(0x00100a00) + o.sym0.sect = f16(1) + o.sym0.scl = 3 + o.sym0.name = ".drectve" + o.sym0.naux = 1 + o.sym0aux.size = f32(#symexport) + o.sect[1].name = ".rdata" + o.sect[1].size = f32(#s) + o.sect[1].flags = f32(0x40300040) + o.sym1.sect = f16(2) + o.sym1.scl = 3 + o.sym1.name = ".rdata" + o.sym1.naux = 1 + o.sym1aux.size = f32(#s) + o.sym2.sect = f16(2) + o.sym2.scl = 2 + o.sym2.nameref[1] = f32(4) + o.sym3.sect = f16(-1) + o.sym3.scl = 2 + o.sym3.value = f32(1) + o.sym3.name = "@feat.00" -- Mark as SafeSEH compliant. + ffi.copy(o.space, symname) + local ofs = #symname + 1 + o.strtabsize = f32(ofs + 4) + o.sect[0].ofs = f32(ffi.offsetof(o, "space") + ofs) + ffi.copy(o.space + ofs, symexport) + ofs = ofs + #symexport + o.sect[1].ofs = f32(ffi.offsetof(o, "space") + ofs) + + -- Write PE object file. + local fp = savefile(output, "wb") + fp:write(ffi.string(o, ffi.sizeof(o)-4096+ofs)) + bcsave_tail(fp, output, s) +end + +local function bcsave_machobj(ctx, output, s, ffi) + ffi.cdef[[ +typedef struct +{ + uint32_t magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags; +} mach_header; +typedef struct +{ + mach_header; uint32_t reserved; +} mach_header_64; +typedef struct { + uint32_t cmd, cmdsize; + char segname[16]; + uint32_t vmaddr, vmsize, fileoff, filesize; + uint32_t maxprot, initprot, nsects, flags; +} mach_segment_command; +typedef struct { + uint32_t cmd, cmdsize; + char segname[16]; + uint64_t vmaddr, vmsize, fileoff, filesize; + uint32_t maxprot, initprot, nsects, flags; +} mach_segment_command_64; +typedef struct { + char sectname[16], segname[16]; + uint32_t addr, size; + uint32_t offset, align, reloff, nreloc, flags; + uint32_t reserved1, reserved2; +} mach_section; +typedef struct { + char sectname[16], segname[16]; + uint64_t addr, size; + uint32_t offset, align, reloff, nreloc, flags; + uint32_t reserved1, reserved2, reserved3; +} mach_section_64; +typedef struct { + uint32_t cmd, cmdsize, symoff, nsyms, stroff, strsize; +} mach_symtab_command; +typedef struct { + int32_t strx; + uint8_t type, sect; + int16_t desc; + uint32_t value; +} mach_nlist; +typedef struct { + uint32_t strx; + uint8_t type, sect; + uint16_t desc; + uint64_t value; +} mach_nlist_64; +typedef struct +{ + uint32_t magic, nfat_arch; +} mach_fat_header; +typedef struct +{ + uint32_t cputype, cpusubtype, offset, size, align; +} mach_fat_arch; +typedef struct { + struct { + mach_header hdr; + mach_segment_command seg; + mach_section sec; + mach_symtab_command sym; + } arch[1]; + mach_nlist sym_entry; + uint8_t space[4096]; +} mach_obj; +typedef struct { + struct { + mach_header_64 hdr; + mach_segment_command_64 seg; + mach_section_64 sec; + mach_symtab_command sym; + } arch[1]; + mach_nlist_64 sym_entry; + uint8_t space[4096]; +} mach_obj_64; +typedef struct { + mach_fat_header fat; + mach_fat_arch fat_arch[4]; + struct { + mach_header hdr; + mach_segment_command seg; + mach_section sec; + mach_symtab_command sym; + } arch[4]; + mach_nlist sym_entry; + uint8_t space[4096]; +} mach_fat_obj; +]] + local symname = '_'..LJBC_PREFIX..ctx.modname + local isfat, is64, align, mobj = false, false, 4, "mach_obj" + if ctx.arch == "x64" then + is64, align, mobj = true, 8, "mach_obj_64" + elseif ctx.arch == "arm" then + isfat, mobj = true, "mach_fat_obj" + else + check(ctx.arch == "x86", "unsupported architecture for OSX") + end + local function aligned(v, a) return bit.band(v+a-1, -a) end + local be32 = bit.bswap -- Mach-O FAT is BE, supported archs are LE. + + -- Create Mach-O object and fill in header. + local o = ffi.new(mobj) + local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, align) + local cputype = ({ x86={7}, x64={0x01000007}, arm={7,12,12,12} })[ctx.arch] + local cpusubtype = ({ x86={3}, x64={3}, arm={3,6,9,11} })[ctx.arch] + if isfat then + o.fat.magic = be32(0xcafebabe) + o.fat.nfat_arch = be32(#cpusubtype) + end + + -- Fill in sections and symbols. + for i=0,#cpusubtype-1 do + local ofs = 0 + if isfat then + local a = o.fat_arch[i] + a.cputype = be32(cputype[i+1]) + a.cpusubtype = be32(cpusubtype[i+1]) + -- Subsequent slices overlap each other to share data. + ofs = ffi.offsetof(o, "arch") + i*ffi.sizeof(o.arch[0]) + a.offset = be32(ofs) + a.size = be32(mach_size-ofs+#s) + end + local a = o.arch[i] + a.hdr.magic = is64 and 0xfeedfacf or 0xfeedface + a.hdr.cputype = cputype[i+1] + a.hdr.cpusubtype = cpusubtype[i+1] + a.hdr.filetype = 1 + a.hdr.ncmds = 2 + a.hdr.sizeofcmds = ffi.sizeof(a.seg)+ffi.sizeof(a.sec)+ffi.sizeof(a.sym) + a.seg.cmd = is64 and 0x19 or 0x1 + a.seg.cmdsize = ffi.sizeof(a.seg)+ffi.sizeof(a.sec) + a.seg.vmsize = #s + a.seg.fileoff = mach_size-ofs + a.seg.filesize = #s + a.seg.maxprot = 1 + a.seg.initprot = 1 + a.seg.nsects = 1 + ffi.copy(a.sec.sectname, "__data") + ffi.copy(a.sec.segname, "__DATA") + a.sec.size = #s + a.sec.offset = mach_size-ofs + a.sym.cmd = 2 + a.sym.cmdsize = ffi.sizeof(a.sym) + a.sym.symoff = ffi.offsetof(o, "sym_entry")-ofs + a.sym.nsyms = 1 + a.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry)-ofs + a.sym.strsize = aligned(#symname+2, align) + end + o.sym_entry.type = 0xf + o.sym_entry.sect = 1 + o.sym_entry.strx = 1 + ffi.copy(o.space+1, symname) + + -- Write Macho-O object file. + local fp = savefile(output, "wb") + fp:write(ffi.string(o, mach_size)) + bcsave_tail(fp, output, s) +end + +local function bcsave_obj(ctx, output, s) + local ok, ffi = pcall(require, "ffi") + check(ok, "FFI library required to write this file type") + if ctx.os == "windows" then + return bcsave_peobj(ctx, output, s, ffi) + elseif ctx.os == "osx" then + return bcsave_machobj(ctx, output, s, ffi) + else + return bcsave_elfobj(ctx, output, s, ffi) + end +end + +------------------------------------------------------------------------------ + +local function bclist(input, output) + local f = readfile(input) + require("jit.bc").dump(f, savefile(output, "w"), true) +end + +local function bcsave(ctx, input, output) + local f = readfile(input) + local s = string.dump(f, ctx.strip) + local t = ctx.type + if not t then + t = detecttype(output) + ctx.type = t + end + if t == "raw" then + bcsave_raw(output, s) + else + if not ctx.modname then ctx.modname = detectmodname(input) end + if t == "obj" then + bcsave_obj(ctx, output, s) + else + bcsave_c(ctx, output, s) + end + end +end + +local function docmd(...) + local arg = {...} + local n = 1 + local list = false + local ctx = { + strip = true, arch = jit.arch, os = string.lower(jit.os), + type = false, modname = false, + } + while n <= #arg do + local a = arg[n] + if type(a) == "string" and string.sub(a, 1, 1) == "-" and a ~= "-" then + table.remove(arg, n) + if a == "--" then break end + for m=2,#a do + local opt = string.sub(a, m, m) + if opt == "l" then + list = true + elseif opt == "s" then + ctx.strip = true + elseif opt == "g" then + ctx.strip = false + else + if arg[n] == nil or m ~= #a then usage() end + if opt == "e" then + if n ~= 1 then usage() end + arg[1] = check(loadstring(arg[1])) + elseif opt == "n" then + ctx.modname = checkmodname(table.remove(arg, n)) + elseif opt == "t" then + ctx.type = checkarg(table.remove(arg, n), map_type, "file type") + elseif opt == "a" then + ctx.arch = checkarg(table.remove(arg, n), map_arch, "architecture") + elseif opt == "o" then + ctx.os = checkarg(table.remove(arg, n), map_os, "OS name") + else + usage() + end + end + end + else + n = n + 1 + end + end + if list then + if #arg == 0 or #arg > 2 then usage() end + bclist(arg[1], arg[2] or "-") + else + if #arg ~= 2 then usage() end + bcsave(ctx, arg[1], arg[2]) + end +end + +------------------------------------------------------------------------------ + +-- Public module functions. +module(...) + +start = docmd -- Process -b command line option. + + +``` + +`include/luajit-2.0.5/src/jit/dis_arm.lua`: + +```lua +---------------------------------------------------------------------------- +-- LuaJIT ARM disassembler module. +-- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- This is a helper module used by the LuaJIT machine code dumper module. +-- +-- It disassembles most user-mode ARMv7 instructions +-- NYI: Advanced SIMD and VFP instructions. +------------------------------------------------------------------------------ + +local type = type +local sub, byte, format = string.sub, string.byte, string.format +local match, gmatch = string.match, string.gmatch +local concat = table.concat +local bit = require("bit") +local band, bor, ror, tohex = bit.band, bit.bor, bit.ror, bit.tohex +local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift + +------------------------------------------------------------------------------ +-- Opcode maps +------------------------------------------------------------------------------ + +local map_loadc = { + shift = 8, mask = 15, + [10] = { + shift = 20, mask = 1, + [0] = { + shift = 23, mask = 3, + [0] = "vmovFmDN", "vstmFNdr", + _ = { + shift = 21, mask = 1, + [0] = "vstrFdl", + { shift = 16, mask = 15, [13] = "vpushFdr", _ = "vstmdbFNdr", } + }, + }, + { + shift = 23, mask = 3, + [0] = "vmovFDNm", + { shift = 16, mask = 15, [13] = "vpopFdr", _ = "vldmFNdr", }, + _ = { + shift = 21, mask = 1, + [0] = "vldrFdl", "vldmdbFNdr", + }, + }, + }, + [11] = { + shift = 20, mask = 1, + [0] = { + shift = 23, mask = 3, + [0] = "vmovGmDN", "vstmGNdr", + _ = { + shift = 21, mask = 1, + [0] = "vstrGdl", + { shift = 16, mask = 15, [13] = "vpushGdr", _ = "vstmdbGNdr", } + }, + }, + { + shift = 23, mask = 3, + [0] = "vmovGDNm", + { shift = 16, mask = 15, [13] = "vpopGdr", _ = "vldmGNdr", }, + _ = { + shift = 21, mask = 1, + [0] = "vldrGdl", "vldmdbGNdr", + }, + }, + }, + _ = { + shift = 0, mask = 0 -- NYI ldc, mcrr, mrrc. + }, +} + +local map_vfps = { + shift = 6, mask = 0x2c001, + [0] = "vmlaF.dnm", "vmlsF.dnm", + [0x04000] = "vnmlsF.dnm", [0x04001] = "vnmlaF.dnm", + [0x08000] = "vmulF.dnm", [0x08001] = "vnmulF.dnm", + [0x0c000] = "vaddF.dnm", [0x0c001] = "vsubF.dnm", + [0x20000] = "vdivF.dnm", + [0x24000] = "vfnmsF.dnm", [0x24001] = "vfnmaF.dnm", + [0x28000] = "vfmaF.dnm", [0x28001] = "vfmsF.dnm", + [0x2c000] = "vmovF.dY", + [0x2c001] = { + shift = 7, mask = 0x1e01, + [0] = "vmovF.dm", "vabsF.dm", + [0x0200] = "vnegF.dm", [0x0201] = "vsqrtF.dm", + [0x0800] = "vcmpF.dm", [0x0801] = "vcmpeF.dm", + [0x0a00] = "vcmpzF.d", [0x0a01] = "vcmpzeF.d", + [0x0e01] = "vcvtG.dF.m", + [0x1000] = "vcvt.f32.u32Fdm", [0x1001] = "vcvt.f32.s32Fdm", + [0x1800] = "vcvtr.u32F.dm", [0x1801] = "vcvt.u32F.dm", + [0x1a00] = "vcvtr.s32F.dm", [0x1a01] = "vcvt.s32F.dm", + }, +} + +local map_vfpd = { + shift = 6, mask = 0x2c001, + [0] = "vmlaG.dnm", "vmlsG.dnm", + [0x04000] = "vnmlsG.dnm", [0x04001] = "vnmlaG.dnm", + [0x08000] = "vmulG.dnm", [0x08001] = "vnmulG.dnm", + [0x0c000] = "vaddG.dnm", [0x0c001] = "vsubG.dnm", + [0x20000] = "vdivG.dnm", + [0x24000] = "vfnmsG.dnm", [0x24001] = "vfnmaG.dnm", + [0x28000] = "vfmaG.dnm", [0x28001] = "vfmsG.dnm", + [0x2c000] = "vmovG.dY", + [0x2c001] = { + shift = 7, mask = 0x1e01, + [0] = "vmovG.dm", "vabsG.dm", + [0x0200] = "vnegG.dm", [0x0201] = "vsqrtG.dm", + [0x0800] = "vcmpG.dm", [0x0801] = "vcmpeG.dm", + [0x0a00] = "vcmpzG.d", [0x0a01] = "vcmpzeG.d", + [0x0e01] = "vcvtF.dG.m", + [0x1000] = "vcvt.f64.u32GdFm", [0x1001] = "vcvt.f64.s32GdFm", + [0x1800] = "vcvtr.u32FdG.m", [0x1801] = "vcvt.u32FdG.m", + [0x1a00] = "vcvtr.s32FdG.m", [0x1a01] = "vcvt.s32FdG.m", + }, +} + +local map_datac = { + shift = 24, mask = 1, + [0] = { + shift = 4, mask = 1, + [0] = { + shift = 8, mask = 15, + [10] = map_vfps, + [11] = map_vfpd, + -- NYI cdp, mcr, mrc. + }, + { + shift = 8, mask = 15, + [10] = { + shift = 20, mask = 15, + [0] = "vmovFnD", "vmovFDn", + [14] = "vmsrD", + [15] = { shift = 12, mask = 15, [15] = "vmrs", _ = "vmrsD", }, + }, + }, + }, + "svcT", +} + +local map_loadcu = { + shift = 0, mask = 0, -- NYI unconditional CP load/store. +} + +local map_datacu = { + shift = 0, mask = 0, -- NYI unconditional CP data. +} + +local map_simddata = { + shift = 0, mask = 0, -- NYI SIMD data. +} + +local map_simdload = { + shift = 0, mask = 0, -- NYI SIMD load/store, preload. +} + +local map_preload = { + shift = 0, mask = 0, -- NYI preload. +} + +local map_media = { + shift = 20, mask = 31, + [0] = false, + { --01 + shift = 5, mask = 7, + [0] = "sadd16DNM", "sasxDNM", "ssaxDNM", "ssub16DNM", + "sadd8DNM", false, false, "ssub8DNM", + }, + { --02 + shift = 5, mask = 7, + [0] = "qadd16DNM", "qasxDNM", "qsaxDNM", "qsub16DNM", + "qadd8DNM", false, false, "qsub8DNM", + }, + { --03 + shift = 5, mask = 7, + [0] = "shadd16DNM", "shasxDNM", "shsaxDNM", "shsub16DNM", + "shadd8DNM", false, false, "shsub8DNM", + }, + false, + { --05 + shift = 5, mask = 7, + [0] = "uadd16DNM", "uasxDNM", "usaxDNM", "usub16DNM", + "uadd8DNM", false, false, "usub8DNM", + }, + { --06 + shift = 5, mask = 7, + [0] = "uqadd16DNM", "uqasxDNM", "uqsaxDNM", "uqsub16DNM", + "uqadd8DNM", false, false, "uqsub8DNM", + }, + { --07 + shift = 5, mask = 7, + [0] = "uhadd16DNM", "uhasxDNM", "uhsaxDNM", "uhsub16DNM", + "uhadd8DNM", false, false, "uhsub8DNM", + }, + { --08 + shift = 5, mask = 7, + [0] = "pkhbtDNMU", false, "pkhtbDNMU", + { shift = 16, mask = 15, [15] = "sxtb16DMU", _ = "sxtab16DNMU", }, + "pkhbtDNMU", "selDNM", "pkhtbDNMU", + }, + false, + { --0a + shift = 5, mask = 7, + [0] = "ssatDxMu", "ssat16DxM", "ssatDxMu", + { shift = 16, mask = 15, [15] = "sxtbDMU", _ = "sxtabDNMU", }, + "ssatDxMu", false, "ssatDxMu", + }, + { --0b + shift = 5, mask = 7, + [0] = "ssatDxMu", "revDM", "ssatDxMu", + { shift = 16, mask = 15, [15] = "sxthDMU", _ = "sxtahDNMU", }, + "ssatDxMu", "rev16DM", "ssatDxMu", + }, + { --0c + shift = 5, mask = 7, + [3] = { shift = 16, mask = 15, [15] = "uxtb16DMU", _ = "uxtab16DNMU", }, + }, + false, + { --0e + shift = 5, mask = 7, + [0] = "usatDwMu", "usat16DwM", "usatDwMu", + { shift = 16, mask = 15, [15] = "uxtbDMU", _ = "uxtabDNMU", }, + "usatDwMu", false, "usatDwMu", + }, + { --0f + shift = 5, mask = 7, + [0] = "usatDwMu", "rbitDM", "usatDwMu", + { shift = 16, mask = 15, [15] = "uxthDMU", _ = "uxtahDNMU", }, + "usatDwMu", "revshDM", "usatDwMu", + }, + { --10 + shift = 12, mask = 15, + [15] = { + shift = 5, mask = 7, + "smuadNMS", "smuadxNMS", "smusdNMS", "smusdxNMS", + }, + _ = { + shift = 5, mask = 7, + [0] = "smladNMSD", "smladxNMSD", "smlsdNMSD", "smlsdxNMSD", + }, + }, + false, false, false, + { --14 + shift = 5, mask = 7, + [0] = "smlaldDNMS", "smlaldxDNMS", "smlsldDNMS", "smlsldxDNMS", + }, + { --15 + shift = 5, mask = 7, + [0] = { shift = 12, mask = 15, [15] = "smmulNMS", _ = "smmlaNMSD", }, + { shift = 12, mask = 15, [15] = "smmulrNMS", _ = "smmlarNMSD", }, + false, false, false, false, + "smmlsNMSD", "smmlsrNMSD", + }, + false, false, + { --18 + shift = 5, mask = 7, + [0] = { shift = 12, mask = 15, [15] = "usad8NMS", _ = "usada8NMSD", }, + }, + false, + { --1a + shift = 5, mask = 3, [2] = "sbfxDMvw", + }, + { --1b + shift = 5, mask = 3, [2] = "sbfxDMvw", + }, + { --1c + shift = 5, mask = 3, + [0] = { shift = 0, mask = 15, [15] = "bfcDvX", _ = "bfiDMvX", }, + }, + { --1d + shift = 5, mask = 3, + [0] = { shift = 0, mask = 15, [15] = "bfcDvX", _ = "bfiDMvX", }, + }, + { --1e + shift = 5, mask = 3, [2] = "ubfxDMvw", + }, + { --1f + shift = 5, mask = 3, [2] = "ubfxDMvw", + }, +} + +local map_load = { + shift = 21, mask = 9, + { + shift = 20, mask = 5, + [0] = "strtDL", "ldrtDL", [4] = "strbtDL", [5] = "ldrbtDL", + }, + _ = { + shift = 20, mask = 5, + [0] = "strDL", "ldrDL", [4] = "strbDL", [5] = "ldrbDL", + } +} + +local map_load1 = { + shift = 4, mask = 1, + [0] = map_load, map_media, +} + +local map_loadm = { + shift = 20, mask = 1, + [0] = { + shift = 23, mask = 3, + [0] = "stmdaNR", "stmNR", + { shift = 16, mask = 63, [45] = "pushR", _ = "stmdbNR", }, "stmibNR", + }, + { + shift = 23, mask = 3, + [0] = "ldmdaNR", { shift = 16, mask = 63, [61] = "popR", _ = "ldmNR", }, + "ldmdbNR", "ldmibNR", + }, +} + +local map_data = { + shift = 21, mask = 15, + [0] = "andDNPs", "eorDNPs", "subDNPs", "rsbDNPs", + "addDNPs", "adcDNPs", "sbcDNPs", "rscDNPs", + "tstNP", "teqNP", "cmpNP", "cmnNP", + "orrDNPs", "movDPs", "bicDNPs", "mvnDPs", +} + +local map_mul = { + shift = 21, mask = 7, + [0] = "mulNMSs", "mlaNMSDs", "umaalDNMS", "mlsDNMS", + "umullDNMSs", "umlalDNMSs", "smullDNMSs", "smlalDNMSs", +} + +local map_sync = { + shift = 20, mask = 15, -- NYI: brackets around N. R(D+1) for ldrexd/strexd. + [0] = "swpDMN", false, false, false, + "swpbDMN", false, false, false, + "strexDMN", "ldrexDN", "strexdDN", "ldrexdDN", + "strexbDMN", "ldrexbDN", "strexhDN", "ldrexhDN", +} + +local map_mulh = { + shift = 21, mask = 3, + [0] = { shift = 5, mask = 3, + [0] = "smlabbNMSD", "smlatbNMSD", "smlabtNMSD", "smlattNMSD", }, + { shift = 5, mask = 3, + [0] = "smlawbNMSD", "smulwbNMS", "smlawtNMSD", "smulwtNMS", }, + { shift = 5, mask = 3, + [0] = "smlalbbDNMS", "smlaltbDNMS", "smlalbtDNMS", "smlalttDNMS", }, + { shift = 5, mask = 3, + [0] = "smulbbNMS", "smultbNMS", "smulbtNMS", "smulttNMS", }, +} + +local map_misc = { + shift = 4, mask = 7, + -- NYI: decode PSR bits of msr. + [0] = { shift = 21, mask = 1, [0] = "mrsD", "msrM", }, + { shift = 21, mask = 3, "bxM", false, "clzDM", }, + { shift = 21, mask = 3, "bxjM", }, + { shift = 21, mask = 3, "blxM", }, + false, + { shift = 21, mask = 3, [0] = "qaddDMN", "qsubDMN", "qdaddDMN", "qdsubDMN", }, + false, + { shift = 21, mask = 3, "bkptK", }, +} + +local map_datar = { + shift = 4, mask = 9, + [9] = { + shift = 5, mask = 3, + [0] = { shift = 24, mask = 1, [0] = map_mul, map_sync, }, + { shift = 20, mask = 1, [0] = "strhDL", "ldrhDL", }, + { shift = 20, mask = 1, [0] = "ldrdDL", "ldrsbDL", }, + { shift = 20, mask = 1, [0] = "strdDL", "ldrshDL", }, + }, + _ = { + shift = 20, mask = 25, + [16] = { shift = 7, mask = 1, [0] = map_misc, map_mulh, }, + _ = { + shift = 0, mask = 0xffffffff, + [bor(0xe1a00000)] = "nop", + _ = map_data, + } + }, +} + +local map_datai = { + shift = 20, mask = 31, -- NYI: decode PSR bits of msr. Decode imm12. + [16] = "movwDW", [20] = "movtDW", + [18] = { shift = 0, mask = 0xf00ff, [0] = "nopv6", _ = "msrNW", }, + [22] = "msrNW", + _ = map_data, +} + +local map_branch = { + shift = 24, mask = 1, + [0] = "bB", "blB" +} + +local map_condins = { + [0] = map_datar, map_datai, map_load, map_load1, + map_loadm, map_branch, map_loadc, map_datac +} + +-- NYI: setend. +local map_uncondins = { + [0] = false, map_simddata, map_simdload, map_preload, + false, "blxB", map_loadcu, map_datacu, +} + +------------------------------------------------------------------------------ + +local map_gpr = { + [0] = "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc", +} + +local map_cond = { + [0] = "eq", "ne", "hs", "lo", "mi", "pl", "vs", "vc", + "hi", "ls", "ge", "lt", "gt", "le", "al", +} + +local map_shift = { [0] = "lsl", "lsr", "asr", "ror", } + +------------------------------------------------------------------------------ + +-- Output a nicely formatted line with an opcode and operands. +local function putop(ctx, text, operands) + local pos = ctx.pos + local extra = "" + if ctx.rel then + local sym = ctx.symtab[ctx.rel] + if sym then + extra = "\t->"..sym + elseif band(ctx.op, 0x0e000000) ~= 0x0a000000 then + extra = "\t; 0x"..tohex(ctx.rel) + end + end + if ctx.hexdump > 0 then + ctx.out(format("%08x %s %-5s %s%s\n", + ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra)) + else + ctx.out(format("%08x %-5s %s%s\n", + ctx.addr+pos, text, concat(operands, ", "), extra)) + end + ctx.pos = pos + 4 +end + +-- Fallback for unknown opcodes. +local function unknown(ctx) + return putop(ctx, ".long", { "0x"..tohex(ctx.op) }) +end + +-- Format operand 2 of load/store opcodes. +local function fmtload(ctx, op, pos) + local base = map_gpr[band(rshift(op, 16), 15)] + local x, ofs + local ext = (band(op, 0x04000000) == 0) + if not ext and band(op, 0x02000000) == 0 then + ofs = band(op, 4095) + if band(op, 0x00800000) == 0 then ofs = -ofs end + if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end + ofs = "#"..ofs + elseif ext and band(op, 0x00400000) ~= 0 then + ofs = band(op, 15) + band(rshift(op, 4), 0xf0) + if band(op, 0x00800000) == 0 then ofs = -ofs end + if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end + ofs = "#"..ofs + else + ofs = map_gpr[band(op, 15)] + if ext or band(op, 0xfe0) == 0 then + elseif band(op, 0xfe0) == 0x60 then + ofs = format("%s, rrx", ofs) + else + local sh = band(rshift(op, 7), 31) + if sh == 0 then sh = 32 end + ofs = format("%s, %s #%d", ofs, map_shift[band(rshift(op, 5), 3)], sh) + end + if band(op, 0x00800000) == 0 then ofs = "-"..ofs end + end + if ofs == "#0" then + x = format("[%s]", base) + elseif band(op, 0x01000000) == 0 then + x = format("[%s], %s", base, ofs) + else + x = format("[%s, %s]", base, ofs) + end + if band(op, 0x01200000) == 0x01200000 then x = x.."!" end + return x +end + +-- Format operand 2 of vector load/store opcodes. +local function fmtvload(ctx, op, pos) + local base = map_gpr[band(rshift(op, 16), 15)] + local ofs = band(op, 255)*4 + if band(op, 0x00800000) == 0 then ofs = -ofs end + if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end + if ofs == 0 then + return format("[%s]", base) + else + return format("[%s, #%d]", base, ofs) + end +end + +local function fmtvr(op, vr, sh0, sh1) + if vr == "s" then + return format("s%d", 2*band(rshift(op, sh0), 15)+band(rshift(op, sh1), 1)) + else + return format("d%d", band(rshift(op, sh0), 15)+band(rshift(op, sh1-4), 16)) + end +end + +-- Disassemble a single instruction. +local function disass_ins(ctx) + local pos = ctx.pos + local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) + local op = bor(lshift(b3, 24), lshift(b2, 16), lshift(b1, 8), b0) + local operands = {} + local suffix = "" + local last, name, pat + local vr + ctx.op = op + ctx.rel = nil + + local cond = rshift(op, 28) + local opat + if cond == 15 then + opat = map_uncondins[band(rshift(op, 25), 7)] + else + if cond ~= 14 then suffix = map_cond[cond] end + opat = map_condins[band(rshift(op, 25), 7)] + end + while type(opat) ~= "string" do + if not opat then return unknown(ctx) end + opat = opat[band(rshift(op, opat.shift), opat.mask)] or opat._ + end + name, pat = match(opat, "^([a-z0-9]*)(.*)") + if sub(pat, 1, 1) == "." then + local s2, p2 = match(pat, "^([a-z0-9.]*)(.*)") + suffix = suffix..s2 + pat = p2 + end + + for p in gmatch(pat, ".") do + local x = nil + if p == "D" then + x = map_gpr[band(rshift(op, 12), 15)] + elseif p == "N" then + x = map_gpr[band(rshift(op, 16), 15)] + elseif p == "S" then + x = map_gpr[band(rshift(op, 8), 15)] + elseif p == "M" then + x = map_gpr[band(op, 15)] + elseif p == "d" then + x = fmtvr(op, vr, 12, 22) + elseif p == "n" then + x = fmtvr(op, vr, 16, 7) + elseif p == "m" then + x = fmtvr(op, vr, 0, 5) + elseif p == "P" then + if band(op, 0x02000000) ~= 0 then + x = ror(band(op, 255), 2*band(rshift(op, 8), 15)) + else + x = map_gpr[band(op, 15)] + if band(op, 0xff0) ~= 0 then + operands[#operands+1] = x + local s = map_shift[band(rshift(op, 5), 3)] + local r = nil + if band(op, 0xf90) == 0 then + if s == "ror" then s = "rrx" else r = "#32" end + elseif band(op, 0x10) == 0 then + r = "#"..band(rshift(op, 7), 31) + else + r = map_gpr[band(rshift(op, 8), 15)] + end + if name == "mov" then name = s; x = r + elseif r then x = format("%s %s", s, r) + else x = s end + end + end + elseif p == "L" then + x = fmtload(ctx, op, pos) + elseif p == "l" then + x = fmtvload(ctx, op, pos) + elseif p == "B" then + local addr = ctx.addr + pos + 8 + arshift(lshift(op, 8), 6) + if cond == 15 then addr = addr + band(rshift(op, 23), 2) end + ctx.rel = addr + x = "0x"..tohex(addr) + elseif p == "F" then + vr = "s" + elseif p == "G" then + vr = "d" + elseif p == "." then + suffix = suffix..(vr == "s" and ".f32" or ".f64") + elseif p == "R" then + if band(op, 0x00200000) ~= 0 and #operands == 1 then + operands[1] = operands[1].."!" + end + local t = {} + for i=0,15 do + if band(rshift(op, i), 1) == 1 then t[#t+1] = map_gpr[i] end + end + x = "{"..concat(t, ", ").."}" + elseif p == "r" then + if band(op, 0x00200000) ~= 0 and #operands == 2 then + operands[1] = operands[1].."!" + end + local s = tonumber(sub(last, 2)) + local n = band(op, 255) + if vr == "d" then n = rshift(n, 1) end + operands[#operands] = format("{%s-%s%d}", last, vr, s+n-1) + elseif p == "W" then + x = band(op, 0x0fff) + band(rshift(op, 4), 0xf000) + elseif p == "T" then + x = "#0x"..tohex(band(op, 0x00ffffff), 6) + elseif p == "U" then + x = band(rshift(op, 7), 31) + if x == 0 then x = nil end + elseif p == "u" then + x = band(rshift(op, 7), 31) + if band(op, 0x40) == 0 then + if x == 0 then x = nil else x = "lsl #"..x end + else + if x == 0 then x = "asr #32" else x = "asr #"..x end + end + elseif p == "v" then + x = band(rshift(op, 7), 31) + elseif p == "w" then + x = band(rshift(op, 16), 31) + elseif p == "x" then + x = band(rshift(op, 16), 31) + 1 + elseif p == "X" then + x = band(rshift(op, 16), 31) - last + 1 + elseif p == "Y" then + x = band(rshift(op, 12), 0xf0) + band(op, 0x0f) + elseif p == "K" then + x = "#0x"..tohex(band(rshift(op, 4), 0x0000fff0) + band(op, 15), 4) + elseif p == "s" then + if band(op, 0x00100000) ~= 0 then suffix = "s"..suffix end + else + assert(false) + end + if x then + last = x + if type(x) == "number" then x = "#"..x end + operands[#operands+1] = x + end + end + + return putop(ctx, name..suffix, operands) +end + +------------------------------------------------------------------------------ + +-- Disassemble a block of code. +local function disass_block(ctx, ofs, len) + if not ofs then ofs = 0 end + local stop = len and ofs+len or #ctx.code + ctx.pos = ofs + ctx.rel = nil + while ctx.pos < stop do disass_ins(ctx) end +end + +-- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). +local function create_(code, addr, out) + local ctx = {} + ctx.code = code + ctx.addr = addr or 0 + ctx.out = out or io.write + ctx.symtab = {} + ctx.disass = disass_block + ctx.hexdump = 8 + return ctx +end + +-- Simple API: disassemble code (a string) at address and output via out. +local function disass_(code, addr, out) + create_(code, addr, out):disass() +end + +-- Return register name for RID. +local function regname_(r) + if r < 16 then return map_gpr[r] end + return "d"..(r-16) +end + +-- Public module functions. +module(...) + +create = create_ +disass = disass_ +regname = regname_ + + +``` + +`include/luajit-2.0.5/src/jit/dis_mips.lua`: + +```lua +---------------------------------------------------------------------------- +-- LuaJIT MIPS disassembler module. +-- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- Released under the MIT/X license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- This is a helper module used by the LuaJIT machine code dumper module. +-- +-- It disassembles all standard MIPS32R1/R2 instructions. +-- Default mode is big-endian, but see: dis_mipsel.lua +------------------------------------------------------------------------------ + +local type = type +local byte, format = string.byte, string.format +local match, gmatch = string.match, string.gmatch +local concat = table.concat +local bit = require("bit") +local band, bor, tohex = bit.band, bit.bor, bit.tohex +local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift + +------------------------------------------------------------------------------ +-- Primary and extended opcode maps +------------------------------------------------------------------------------ + +local map_movci = { shift = 16, mask = 1, [0] = "movfDSC", "movtDSC", } +local map_srl = { shift = 21, mask = 1, [0] = "srlDTA", "rotrDTA", } +local map_srlv = { shift = 6, mask = 1, [0] = "srlvDTS", "rotrvDTS", } + +local map_special = { + shift = 0, mask = 63, + [0] = { shift = 0, mask = -1, [0] = "nop", _ = "sllDTA" }, + map_movci, map_srl, "sraDTA", + "sllvDTS", false, map_srlv, "sravDTS", + "jrS", "jalrD1S", "movzDST", "movnDST", + "syscallY", "breakY", false, "sync", + "mfhiD", "mthiS", "mfloD", "mtloS", + false, false, false, false, + "multST", "multuST", "divST", "divuST", + false, false, false, false, + "addDST", "addu|moveDST0", "subDST", "subu|neguDS0T", + "andDST", "orDST", "xorDST", "nor|notDST0", + false, false, "sltDST", "sltuDST", + false, false, false, false, + "tgeSTZ", "tgeuSTZ", "tltSTZ", "tltuSTZ", + "teqSTZ", false, "tneSTZ", +} + +local map_special2 = { + shift = 0, mask = 63, + [0] = "maddST", "madduST", "mulDST", false, + "msubST", "msubuST", + [32] = "clzDS", [33] = "cloDS", + [63] = "sdbbpY", +} + +local map_bshfl = { + shift = 6, mask = 31, + [2] = "wsbhDT", + [16] = "sebDT", + [24] = "sehDT", +} + +local map_special3 = { + shift = 0, mask = 63, + [0] = "extTSAK", [4] = "insTSAL", + [32] = map_bshfl, + [59] = "rdhwrTD", +} + +local map_regimm = { + shift = 16, mask = 31, + [0] = "bltzSB", "bgezSB", "bltzlSB", "bgezlSB", + false, false, false, false, + "tgeiSI", "tgeiuSI", "tltiSI", "tltiuSI", + "teqiSI", false, "tneiSI", false, + "bltzalSB", "bgezalSB", "bltzallSB", "bgezallSB", + false, false, false, false, + false, false, false, false, + false, false, false, "synciSO", +} + +local map_cop0 = { + shift = 25, mask = 1, + [0] = { + shift = 21, mask = 15, + [0] = "mfc0TDW", [4] = "mtc0TDW", + [10] = "rdpgprDT", + [11] = { shift = 5, mask = 1, [0] = "diT0", "eiT0", }, + [14] = "wrpgprDT", + }, { + shift = 0, mask = 63, + [1] = "tlbr", [2] = "tlbwi", [6] = "tlbwr", [8] = "tlbp", + [24] = "eret", [31] = "deret", + [32] = "wait", + }, +} + +local map_cop1s = { + shift = 0, mask = 63, + [0] = "add.sFGH", "sub.sFGH", "mul.sFGH", "div.sFGH", + "sqrt.sFG", "abs.sFG", "mov.sFG", "neg.sFG", + "round.l.sFG", "trunc.l.sFG", "ceil.l.sFG", "floor.l.sFG", + "round.w.sFG", "trunc.w.sFG", "ceil.w.sFG", "floor.w.sFG", + false, + { shift = 16, mask = 1, [0] = "movf.sFGC", "movt.sFGC" }, + "movz.sFGT", "movn.sFGT", + false, "recip.sFG", "rsqrt.sFG", false, + false, false, false, false, + false, false, false, false, + false, "cvt.d.sFG", false, false, + "cvt.w.sFG", "cvt.l.sFG", "cvt.ps.sFGH", false, + false, false, false, false, + false, false, false, false, + "c.f.sVGH", "c.un.sVGH", "c.eq.sVGH", "c.ueq.sVGH", + "c.olt.sVGH", "c.ult.sVGH", "c.ole.sVGH", "c.ule.sVGH", + "c.sf.sVGH", "c.ngle.sVGH", "c.seq.sVGH", "c.ngl.sVGH", + "c.lt.sVGH", "c.nge.sVGH", "c.le.sVGH", "c.ngt.sVGH", +} + +local map_cop1d = { + shift = 0, mask = 63, + [0] = "add.dFGH", "sub.dFGH", "mul.dFGH", "div.dFGH", + "sqrt.dFG", "abs.dFG", "mov.dFG", "neg.dFG", + "round.l.dFG", "trunc.l.dFG", "ceil.l.dFG", "floor.l.dFG", + "round.w.dFG", "trunc.w.dFG", "ceil.w.dFG", "floor.w.dFG", + false, + { shift = 16, mask = 1, [0] = "movf.dFGC", "movt.dFGC" }, + "movz.dFGT", "movn.dFGT", + false, "recip.dFG", "rsqrt.dFG", false, + false, false, false, false, + false, false, false, false, + "cvt.s.dFG", false, false, false, + "cvt.w.dFG", "cvt.l.dFG", false, false, + false, false, false, false, + false, false, false, false, + "c.f.dVGH", "c.un.dVGH", "c.eq.dVGH", "c.ueq.dVGH", + "c.olt.dVGH", "c.ult.dVGH", "c.ole.dVGH", "c.ule.dVGH", + "c.df.dVGH", "c.ngle.dVGH", "c.deq.dVGH", "c.ngl.dVGH", + "c.lt.dVGH", "c.nge.dVGH", "c.le.dVGH", "c.ngt.dVGH", +} + +local map_cop1ps = { + shift = 0, mask = 63, + [0] = "add.psFGH", "sub.psFGH", "mul.psFGH", false, + false, "abs.psFG", "mov.psFG", "neg.psFG", + false, false, false, false, + false, false, false, false, + false, + { shift = 16, mask = 1, [0] = "movf.psFGC", "movt.psFGC" }, + "movz.psFGT", "movn.psFGT", + false, false, false, false, + false, false, false, false, + false, false, false, false, + "cvt.s.puFG", false, false, false, + false, false, false, false, + "cvt.s.plFG", false, false, false, + "pll.psFGH", "plu.psFGH", "pul.psFGH", "puu.psFGH", + "c.f.psVGH", "c.un.psVGH", "c.eq.psVGH", "c.ueq.psVGH", + "c.olt.psVGH", "c.ult.psVGH", "c.ole.psVGH", "c.ule.psVGH", + "c.psf.psVGH", "c.ngle.psVGH", "c.pseq.psVGH", "c.ngl.psVGH", + "c.lt.psVGH", "c.nge.psVGH", "c.le.psVGH", "c.ngt.psVGH", +} + +local map_cop1w = { + shift = 0, mask = 63, + [32] = "cvt.s.wFG", [33] = "cvt.d.wFG", +} + +local map_cop1l = { + shift = 0, mask = 63, + [32] = "cvt.s.lFG", [33] = "cvt.d.lFG", +} + +local map_cop1bc = { + shift = 16, mask = 3, + [0] = "bc1fCB", "bc1tCB", "bc1flCB", "bc1tlCB", +} + +local map_cop1 = { + shift = 21, mask = 31, + [0] = "mfc1TG", false, "cfc1TG", "mfhc1TG", + "mtc1TG", false, "ctc1TG", "mthc1TG", + map_cop1bc, false, false, false, + false, false, false, false, + map_cop1s, map_cop1d, false, false, + map_cop1w, map_cop1l, map_cop1ps, +} + +local map_cop1x = { + shift = 0, mask = 63, + [0] = "lwxc1FSX", "ldxc1FSX", false, false, + false, "luxc1FSX", false, false, + "swxc1FSX", "sdxc1FSX", false, false, + false, "suxc1FSX", false, "prefxMSX", + false, false, false, false, + false, false, false, false, + false, false, false, false, + false, false, "alnv.psFGHS", false, + "madd.sFRGH", "madd.dFRGH", false, false, + false, false, "madd.psFRGH", false, + "msub.sFRGH", "msub.dFRGH", false, false, + false, false, "msub.psFRGH", false, + "nmadd.sFRGH", "nmadd.dFRGH", false, false, + false, false, "nmadd.psFRGH", false, + "nmsub.sFRGH", "nmsub.dFRGH", false, false, + false, false, "nmsub.psFRGH", false, +} + +local map_pri = { + [0] = map_special, map_regimm, "jJ", "jalJ", + "beq|beqz|bST00B", "bne|bnezST0B", "blezSB", "bgtzSB", + "addiTSI", "addiu|liTS0I", "sltiTSI", "sltiuTSI", + "andiTSU", "ori|liTS0U", "xoriTSU", "luiTU", + map_cop0, map_cop1, false, map_cop1x, + "beql|beqzlST0B", "bnel|bnezlST0B", "blezlSB", "bgtzlSB", + false, false, false, false, + map_special2, false, false, map_special3, + "lbTSO", "lhTSO", "lwlTSO", "lwTSO", + "lbuTSO", "lhuTSO", "lwrTSO", false, + "sbTSO", "shTSO", "swlTSO", "swTSO", + false, false, "swrTSO", "cacheNSO", + "llTSO", "lwc1HSO", "lwc2TSO", "prefNSO", + false, "ldc1HSO", "ldc2TSO", false, + "scTSO", "swc1HSO", "swc2TSO", false, + false, "sdc1HSO", "sdc2TSO", false, +} + +------------------------------------------------------------------------------ + +local map_gpr = { + [0] = "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", + "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", + "r24", "r25", "r26", "r27", "r28", "sp", "r30", "ra", +} + +------------------------------------------------------------------------------ + +-- Output a nicely formatted line with an opcode and operands. +local function putop(ctx, text, operands) + local pos = ctx.pos + local extra = "" + if ctx.rel then + local sym = ctx.symtab[ctx.rel] + if sym then extra = "\t->"..sym end + end + if ctx.hexdump > 0 then + ctx.out(format("%08x %s %-7s %s%s\n", + ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra)) + else + ctx.out(format("%08x %-7s %s%s\n", + ctx.addr+pos, text, concat(operands, ", "), extra)) + end + ctx.pos = pos + 4 +end + +-- Fallback for unknown opcodes. +local function unknown(ctx) + return putop(ctx, ".long", { "0x"..tohex(ctx.op) }) +end + +local function get_be(ctx) + local pos = ctx.pos + local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) + return bor(lshift(b0, 24), lshift(b1, 16), lshift(b2, 8), b3) +end + +local function get_le(ctx) + local pos = ctx.pos + local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) + return bor(lshift(b3, 24), lshift(b2, 16), lshift(b1, 8), b0) +end + +-- Disassemble a single instruction. +local function disass_ins(ctx) + local op = ctx:get() + local operands = {} + local last = nil + ctx.op = op + ctx.rel = nil + + local opat = map_pri[rshift(op, 26)] + while type(opat) ~= "string" do + if not opat then return unknown(ctx) end + opat = opat[band(rshift(op, opat.shift), opat.mask)] or opat._ + end + local name, pat = match(opat, "^([a-z0-9_.]*)(.*)") + local altname, pat2 = match(pat, "|([a-z0-9_.|]*)(.*)") + if altname then pat = pat2 end + + for p in gmatch(pat, ".") do + local x = nil + if p == "S" then + x = map_gpr[band(rshift(op, 21), 31)] + elseif p == "T" then + x = map_gpr[band(rshift(op, 16), 31)] + elseif p == "D" then + x = map_gpr[band(rshift(op, 11), 31)] + elseif p == "F" then + x = "f"..band(rshift(op, 6), 31) + elseif p == "G" then + x = "f"..band(rshift(op, 11), 31) + elseif p == "H" then + x = "f"..band(rshift(op, 16), 31) + elseif p == "R" then + x = "f"..band(rshift(op, 21), 31) + elseif p == "A" then + x = band(rshift(op, 6), 31) + elseif p == "M" then + x = band(rshift(op, 11), 31) + elseif p == "N" then + x = band(rshift(op, 16), 31) + elseif p == "C" then + x = band(rshift(op, 18), 7) + if x == 0 then x = nil end + elseif p == "K" then + x = band(rshift(op, 11), 31) + 1 + elseif p == "L" then + x = band(rshift(op, 11), 31) - last + 1 + elseif p == "I" then + x = arshift(lshift(op, 16), 16) + elseif p == "U" then + x = band(op, 0xffff) + elseif p == "O" then + local disp = arshift(lshift(op, 16), 16) + operands[#operands] = format("%d(%s)", disp, last) + elseif p == "X" then + local index = map_gpr[band(rshift(op, 16), 31)] + operands[#operands] = format("%s(%s)", index, last) + elseif p == "B" then + x = ctx.addr + ctx.pos + arshift(lshift(op, 16), 16)*4 + 4 + ctx.rel = x + x = "0x"..tohex(x) + elseif p == "J" then + x = band(ctx.addr + ctx.pos, 0xf0000000) + band(op, 0x03ffffff)*4 + ctx.rel = x + x = "0x"..tohex(x) + elseif p == "V" then + x = band(rshift(op, 8), 7) + if x == 0 then x = nil end + elseif p == "W" then + x = band(op, 7) + if x == 0 then x = nil end + elseif p == "Y" then + x = band(rshift(op, 6), 0x000fffff) + if x == 0 then x = nil end + elseif p == "Z" then + x = band(rshift(op, 6), 1023) + if x == 0 then x = nil end + elseif p == "0" then + if last == "r0" or last == 0 then + local n = #operands + operands[n] = nil + last = operands[n-1] + if altname then + local a1, a2 = match(altname, "([^|]*)|(.*)") + if a1 then name, altname = a1, a2 + else name = altname end + end + end + elseif p == "1" then + if last == "ra" then + operands[#operands] = nil + end + else + assert(false) + end + if x then operands[#operands+1] = x; last = x end + end + + return putop(ctx, name, operands) +end + +------------------------------------------------------------------------------ + +-- Disassemble a block of code. +local function disass_block(ctx, ofs, len) + if not ofs then ofs = 0 end + local stop = len and ofs+len or #ctx.code + stop = stop - stop % 4 + ctx.pos = ofs - ofs % 4 + ctx.rel = nil + while ctx.pos < stop do disass_ins(ctx) end +end + +-- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). +local function create_(code, addr, out) + local ctx = {} + ctx.code = code + ctx.addr = addr or 0 + ctx.out = out or io.write + ctx.symtab = {} + ctx.disass = disass_block + ctx.hexdump = 8 + ctx.get = get_be + return ctx +end + +local function create_el_(code, addr, out) + local ctx = create_(code, addr, out) + ctx.get = get_le + return ctx +end + +-- Simple API: disassemble code (a string) at address and output via out. +local function disass_(code, addr, out) + create_(code, addr, out):disass() +end + +local function disass_el_(code, addr, out) + create_el_(code, addr, out):disass() +end + +-- Return register name for RID. +local function regname_(r) + if r < 32 then return map_gpr[r] end + return "f"..(r-32) +end + +-- Public module functions. +module(...) + +create = create_ +create_el = create_el_ +disass = disass_ +disass_el = disass_el_ +regname = regname_ + + +``` + +`include/luajit-2.0.5/src/jit/dis_mipsel.lua`: + +```lua +---------------------------------------------------------------------------- +-- LuaJIT MIPSEL disassembler wrapper module. +-- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- This module just exports the little-endian functions from the +-- MIPS disassembler module. All the interesting stuff is there. +------------------------------------------------------------------------------ + +local require = require + +module(...) + +local dis_mips = require(_PACKAGE.."dis_mips") + +create = dis_mips.create_el +disass = dis_mips.disass_el +regname = dis_mips.regname + + +``` + +`include/luajit-2.0.5/src/jit/dis_ppc.lua`: + +```lua +---------------------------------------------------------------------------- +-- LuaJIT PPC disassembler module. +-- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- Released under the MIT/X license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- This is a helper module used by the LuaJIT machine code dumper module. +-- +-- It disassembles all common, non-privileged 32/64 bit PowerPC instructions +-- plus the e500 SPE instructions and some Cell/Xenon extensions. +-- +-- NYI: VMX, VMX128 +------------------------------------------------------------------------------ + +local type = type +local byte, format = string.byte, string.format +local match, gmatch, gsub = string.match, string.gmatch, string.gsub +local concat = table.concat +local bit = require("bit") +local band, bor, tohex = bit.band, bit.bor, bit.tohex +local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift + +------------------------------------------------------------------------------ +-- Primary and extended opcode maps +------------------------------------------------------------------------------ + +local map_crops = { + shift = 1, mask = 1023, + [0] = "mcrfXX", + [33] = "crnor|crnotCCC=", [129] = "crandcCCC", + [193] = "crxor|crclrCCC%", [225] = "crnandCCC", + [257] = "crandCCC", [289] = "creqv|crsetCCC%", + [417] = "crorcCCC", [449] = "cror|crmoveCCC=", + [16] = "b_lrKB", [528] = "b_ctrKB", + [150] = "isync", +} + +local map_rlwinm = setmetatable({ + shift = 0, mask = -1, +}, +{ __index = function(t, x) + local rot = band(rshift(x, 11), 31) + local mb = band(rshift(x, 6), 31) + local me = band(rshift(x, 1), 31) + if mb == 0 and me == 31-rot then + return "slwiRR~A." + elseif me == 31 and mb == 32-rot then + return "srwiRR~-A." + else + return "rlwinmRR~AAA." + end + end +}) + +local map_rld = { + shift = 2, mask = 7, + [0] = "rldiclRR~HM.", "rldicrRR~HM.", "rldicRR~HM.", "rldimiRR~HM.", + { + shift = 1, mask = 1, + [0] = "rldclRR~RM.", "rldcrRR~RM.", + }, +} + +local map_ext = setmetatable({ + shift = 1, mask = 1023, + + [0] = "cmp_YLRR", [32] = "cmpl_YLRR", + [4] = "twARR", [68] = "tdARR", + + [8] = "subfcRRR.", [40] = "subfRRR.", + [104] = "negRR.", [136] = "subfeRRR.", + [200] = "subfzeRR.", [232] = "subfmeRR.", + [520] = "subfcoRRR.", [552] = "subfoRRR.", + [616] = "negoRR.", [648] = "subfeoRRR.", + [712] = "subfzeoRR.", [744] = "subfmeoRR.", + + [9] = "mulhduRRR.", [73] = "mulhdRRR.", [233] = "mulldRRR.", + [457] = "divduRRR.", [489] = "divdRRR.", + [745] = "mulldoRRR.", + [969] = "divduoRRR.", [1001] = "divdoRRR.", + + [10] = "addcRRR.", [138] = "addeRRR.", + [202] = "addzeRR.", [234] = "addmeRR.", [266] = "addRRR.", + [522] = "addcoRRR.", [650] = "addeoRRR.", + [714] = "addzeoRR.", [746] = "addmeoRR.", [778] = "addoRRR.", + + [11] = "mulhwuRRR.", [75] = "mulhwRRR.", [235] = "mullwRRR.", + [459] = "divwuRRR.", [491] = "divwRRR.", + [747] = "mullwoRRR.", + [971] = "divwouRRR.", [1003] = "divwoRRR.", + + [15] = "iselltRRR", [47] = "iselgtRRR", [79] = "iseleqRRR", + + [144] = { shift = 20, mask = 1, [0] = "mtcrfRZ~", "mtocrfRZ~", }, + [19] = { shift = 20, mask = 1, [0] = "mfcrR", "mfocrfRZ", }, + [371] = { shift = 11, mask = 1023, [392] = "mftbR", [424] = "mftbuR", }, + [339] = { + shift = 11, mask = 1023, + [32] = "mferR", [256] = "mflrR", [288] = "mfctrR", [16] = "mfspefscrR", + }, + [467] = { + shift = 11, mask = 1023, + [32] = "mtxerR", [256] = "mtlrR", [288] = "mtctrR", [16] = "mtspefscrR", + }, + + [20] = "lwarxRR0R", [84] = "ldarxRR0R", + + [21] = "ldxRR0R", [53] = "lduxRRR", + [149] = "stdxRR0R", [181] = "stduxRRR", + [341] = "lwaxRR0R", [373] = "lwauxRRR", + + [23] = "lwzxRR0R", [55] = "lwzuxRRR", + [87] = "lbzxRR0R", [119] = "lbzuxRRR", + [151] = "stwxRR0R", [183] = "stwuxRRR", + [215] = "stbxRR0R", [247] = "stbuxRRR", + [279] = "lhzxRR0R", [311] = "lhzuxRRR", + [343] = "lhaxRR0R", [375] = "lhauxRRR", + [407] = "sthxRR0R", [439] = "sthuxRRR", + + [54] = "dcbst-R0R", [86] = "dcbf-R0R", + [150] = "stwcxRR0R.", [214] = "stdcxRR0R.", + [246] = "dcbtst-R0R", [278] = "dcbt-R0R", + [310] = "eciwxRR0R", [438] = "ecowxRR0R", + [470] = "dcbi-RR", + + [598] = { + shift = 21, mask = 3, + [0] = "sync", "lwsync", "ptesync", + }, + [758] = "dcba-RR", + [854] = "eieio", [982] = "icbi-R0R", [1014] = "dcbz-R0R", + + [26] = "cntlzwRR~", [58] = "cntlzdRR~", + [122] = "popcntbRR~", + [154] = "prtywRR~", [186] = "prtydRR~", + + [28] = "andRR~R.", [60] = "andcRR~R.", [124] = "nor|notRR~R=.", + [284] = "eqvRR~R.", [316] = "xorRR~R.", + [412] = "orcRR~R.", [444] = "or|mrRR~R=.", [476] = "nandRR~R.", + [508] = "cmpbRR~R", + + [512] = "mcrxrX", + + [532] = "ldbrxRR0R", [660] = "stdbrxRR0R", + + [533] = "lswxRR0R", [597] = "lswiRR0A", + [661] = "stswxRR0R", [725] = "stswiRR0A", + + [534] = "lwbrxRR0R", [662] = "stwbrxRR0R", + [790] = "lhbrxRR0R", [918] = "sthbrxRR0R", + + [535] = "lfsxFR0R", [567] = "lfsuxFRR", + [599] = "lfdxFR0R", [631] = "lfduxFRR", + [663] = "stfsxFR0R", [695] = "stfsuxFRR", + [727] = "stfdxFR0R", [759] = "stfduxFR0R", + [855] = "lfiwaxFR0R", + [983] = "stfiwxFR0R", + + [24] = "slwRR~R.", + + [27] = "sldRR~R.", [536] = "srwRR~R.", + [792] = "srawRR~R.", [824] = "srawiRR~A.", + + [794] = "sradRR~R.", [826] = "sradiRR~H.", [827] = "sradiRR~H.", + [922] = "extshRR~.", [954] = "extsbRR~.", [986] = "extswRR~.", + + [539] = "srdRR~R.", +}, +{ __index = function(t, x) + if band(x, 31) == 15 then return "iselRRRC" end + end +}) + +local map_ld = { + shift = 0, mask = 3, + [0] = "ldRRE", "lduRRE", "lwaRRE", +} + +local map_std = { + shift = 0, mask = 3, + [0] = "stdRRE", "stduRRE", +} + +local map_fps = { + shift = 5, mask = 1, + { + shift = 1, mask = 15, + [0] = false, false, "fdivsFFF.", false, + "fsubsFFF.", "faddsFFF.", "fsqrtsF-F.", false, + "fresF-F.", "fmulsFF-F.", "frsqrtesF-F.", false, + "fmsubsFFFF~.", "fmaddsFFFF~.", "fnmsubsFFFF~.", "fnmaddsFFFF~.", + } +} + +local map_fpd = { + shift = 5, mask = 1, + [0] = { + shift = 1, mask = 1023, + [0] = "fcmpuXFF", [32] = "fcmpoXFF", [64] = "mcrfsXX", + [38] = "mtfsb1A.", [70] = "mtfsb0A.", [134] = "mtfsfiA>>-A>", + [8] = "fcpsgnFFF.", [40] = "fnegF-F.", [72] = "fmrF-F.", + [136] = "fnabsF-F.", [264] = "fabsF-F.", + [12] = "frspF-F.", + [14] = "fctiwF-F.", [15] = "fctiwzF-F.", + [583] = "mffsF.", [711] = "mtfsfZF.", + [392] = "frinF-F.", [424] = "frizF-F.", + [456] = "fripF-F.", [488] = "frimF-F.", + [814] = "fctidF-F.", [815] = "fctidzF-F.", [846] = "fcfidF-F.", + }, + { + shift = 1, mask = 15, + [0] = false, false, "fdivFFF.", false, + "fsubFFF.", "faddFFF.", "fsqrtF-F.", "fselFFFF~.", + "freF-F.", "fmulFF-F.", "frsqrteF-F.", false, + "fmsubFFFF~.", "fmaddFFFF~.", "fnmsubFFFF~.", "fnmaddFFFF~.", + } +} + +local map_spe = { + shift = 0, mask = 2047, + + [512] = "evaddwRRR", [514] = "evaddiwRAR~", + [516] = "evsubwRRR~", [518] = "evsubiwRAR~", + [520] = "evabsRR", [521] = "evnegRR", + [522] = "evextsbRR", [523] = "evextshRR", [524] = "evrndwRR", + [525] = "evcntlzwRR", [526] = "evcntlswRR", + + [527] = "brincRRR", + + [529] = "evandRRR", [530] = "evandcRRR", [534] = "evxorRRR", + [535] = "evor|evmrRRR=", [536] = "evnor|evnotRRR=", + [537] = "eveqvRRR", [539] = "evorcRRR", [542] = "evnandRRR", + + [544] = "evsrwuRRR", [545] = "evsrwsRRR", + [546] = "evsrwiuRRA", [547] = "evsrwisRRA", + [548] = "evslwRRR", [550] = "evslwiRRA", + [552] = "evrlwRRR", [553] = "evsplatiRS", + [554] = "evrlwiRRA", [555] = "evsplatfiRS", + [556] = "evmergehiRRR", [557] = "evmergeloRRR", + [558] = "evmergehiloRRR", [559] = "evmergelohiRRR", + + [560] = "evcmpgtuYRR", [561] = "evcmpgtsYRR", + [562] = "evcmpltuYRR", [563] = "evcmpltsYRR", + [564] = "evcmpeqYRR", + + [632] = "evselRRR", [633] = "evselRRRW", + [634] = "evselRRRW", [635] = "evselRRRW", + [636] = "evselRRRW", [637] = "evselRRRW", + [638] = "evselRRRW", [639] = "evselRRRW", + + [640] = "evfsaddRRR", [641] = "evfssubRRR", + [644] = "evfsabsRR", [645] = "evfsnabsRR", [646] = "evfsnegRR", + [648] = "evfsmulRRR", [649] = "evfsdivRRR", + [652] = "evfscmpgtYRR", [653] = "evfscmpltYRR", [654] = "evfscmpeqYRR", + [656] = "evfscfuiR-R", [657] = "evfscfsiR-R", + [658] = "evfscfufR-R", [659] = "evfscfsfR-R", + [660] = "evfsctuiR-R", [661] = "evfsctsiR-R", + [662] = "evfsctufR-R", [663] = "evfsctsfR-R", + [664] = "evfsctuizR-R", [666] = "evfsctsizR-R", + [668] = "evfststgtYRR", [669] = "evfststltYRR", [670] = "evfststeqYRR", + + [704] = "efsaddRRR", [705] = "efssubRRR", + [708] = "efsabsRR", [709] = "efsnabsRR", [710] = "efsnegRR", + [712] = "efsmulRRR", [713] = "efsdivRRR", + [716] = "efscmpgtYRR", [717] = "efscmpltYRR", [718] = "efscmpeqYRR", + [719] = "efscfdR-R", + [720] = "efscfuiR-R", [721] = "efscfsiR-R", + [722] = "efscfufR-R", [723] = "efscfsfR-R", + [724] = "efsctuiR-R", [725] = "efsctsiR-R", + [726] = "efsctufR-R", [727] = "efsctsfR-R", + [728] = "efsctuizR-R", [730] = "efsctsizR-R", + [732] = "efststgtYRR", [733] = "efststltYRR", [734] = "efststeqYRR", + + [736] = "efdaddRRR", [737] = "efdsubRRR", + [738] = "efdcfuidR-R", [739] = "efdcfsidR-R", + [740] = "efdabsRR", [741] = "efdnabsRR", [742] = "efdnegRR", + [744] = "efdmulRRR", [745] = "efddivRRR", + [746] = "efdctuidzR-R", [747] = "efdctsidzR-R", + [748] = "efdcmpgtYRR", [749] = "efdcmpltYRR", [750] = "efdcmpeqYRR", + [751] = "efdcfsR-R", + [752] = "efdcfuiR-R", [753] = "efdcfsiR-R", + [754] = "efdcfufR-R", [755] = "efdcfsfR-R", + [756] = "efdctuiR-R", [757] = "efdctsiR-R", + [758] = "efdctufR-R", [759] = "efdctsfR-R", + [760] = "efdctuizR-R", [762] = "efdctsizR-R", + [764] = "efdtstgtYRR", [765] = "efdtstltYRR", [766] = "efdtsteqYRR", + + [768] = "evlddxRR0R", [769] = "evlddRR8", + [770] = "evldwxRR0R", [771] = "evldwRR8", + [772] = "evldhxRR0R", [773] = "evldhRR8", + [776] = "evlhhesplatxRR0R", [777] = "evlhhesplatRR2", + [780] = "evlhhousplatxRR0R", [781] = "evlhhousplatRR2", + [782] = "evlhhossplatxRR0R", [783] = "evlhhossplatRR2", + [784] = "evlwhexRR0R", [785] = "evlwheRR4", + [788] = "evlwhouxRR0R", [789] = "evlwhouRR4", + [790] = "evlwhosxRR0R", [791] = "evlwhosRR4", + [792] = "evlwwsplatxRR0R", [793] = "evlwwsplatRR4", + [796] = "evlwhsplatxRR0R", [797] = "evlwhsplatRR4", + + [800] = "evstddxRR0R", [801] = "evstddRR8", + [802] = "evstdwxRR0R", [803] = "evstdwRR8", + [804] = "evstdhxRR0R", [805] = "evstdhRR8", + [816] = "evstwhexRR0R", [817] = "evstwheRR4", + [820] = "evstwhoxRR0R", [821] = "evstwhoRR4", + [824] = "evstwwexRR0R", [825] = "evstwweRR4", + [828] = "evstwwoxRR0R", [829] = "evstwwoRR4", + + [1027] = "evmhessfRRR", [1031] = "evmhossfRRR", [1032] = "evmheumiRRR", + [1033] = "evmhesmiRRR", [1035] = "evmhesmfRRR", [1036] = "evmhoumiRRR", + [1037] = "evmhosmiRRR", [1039] = "evmhosmfRRR", [1059] = "evmhessfaRRR", + [1063] = "evmhossfaRRR", [1064] = "evmheumiaRRR", [1065] = "evmhesmiaRRR", + [1067] = "evmhesmfaRRR", [1068] = "evmhoumiaRRR", [1069] = "evmhosmiaRRR", + [1071] = "evmhosmfaRRR", [1095] = "evmwhssfRRR", [1096] = "evmwlumiRRR", + [1100] = "evmwhumiRRR", [1101] = "evmwhsmiRRR", [1103] = "evmwhsmfRRR", + [1107] = "evmwssfRRR", [1112] = "evmwumiRRR", [1113] = "evmwsmiRRR", + [1115] = "evmwsmfRRR", [1127] = "evmwhssfaRRR", [1128] = "evmwlumiaRRR", + [1132] = "evmwhumiaRRR", [1133] = "evmwhsmiaRRR", [1135] = "evmwhsmfaRRR", + [1139] = "evmwssfaRRR", [1144] = "evmwumiaRRR", [1145] = "evmwsmiaRRR", + [1147] = "evmwsmfaRRR", + + [1216] = "evaddusiaawRR", [1217] = "evaddssiaawRR", + [1218] = "evsubfusiaawRR", [1219] = "evsubfssiaawRR", + [1220] = "evmraRR", + [1222] = "evdivwsRRR", [1223] = "evdivwuRRR", + [1224] = "evaddumiaawRR", [1225] = "evaddsmiaawRR", + [1226] = "evsubfumiaawRR", [1227] = "evsubfsmiaawRR", + + [1280] = "evmheusiaawRRR", [1281] = "evmhessiaawRRR", + [1283] = "evmhessfaawRRR", [1284] = "evmhousiaawRRR", + [1285] = "evmhossiaawRRR", [1287] = "evmhossfaawRRR", + [1288] = "evmheumiaawRRR", [1289] = "evmhesmiaawRRR", + [1291] = "evmhesmfaawRRR", [1292] = "evmhoumiaawRRR", + [1293] = "evmhosmiaawRRR", [1295] = "evmhosmfaawRRR", + [1320] = "evmhegumiaaRRR", [1321] = "evmhegsmiaaRRR", + [1323] = "evmhegsmfaaRRR", [1324] = "evmhogumiaaRRR", + [1325] = "evmhogsmiaaRRR", [1327] = "evmhogsmfaaRRR", + [1344] = "evmwlusiaawRRR", [1345] = "evmwlssiaawRRR", + [1352] = "evmwlumiaawRRR", [1353] = "evmwlsmiaawRRR", + [1363] = "evmwssfaaRRR", [1368] = "evmwumiaaRRR", + [1369] = "evmwsmiaaRRR", [1371] = "evmwsmfaaRRR", + [1408] = "evmheusianwRRR", [1409] = "evmhessianwRRR", + [1411] = "evmhessfanwRRR", [1412] = "evmhousianwRRR", + [1413] = "evmhossianwRRR", [1415] = "evmhossfanwRRR", + [1416] = "evmheumianwRRR", [1417] = "evmhesmianwRRR", + [1419] = "evmhesmfanwRRR", [1420] = "evmhoumianwRRR", + [1421] = "evmhosmianwRRR", [1423] = "evmhosmfanwRRR", + [1448] = "evmhegumianRRR", [1449] = "evmhegsmianRRR", + [1451] = "evmhegsmfanRRR", [1452] = "evmhogumianRRR", + [1453] = "evmhogsmianRRR", [1455] = "evmhogsmfanRRR", + [1472] = "evmwlusianwRRR", [1473] = "evmwlssianwRRR", + [1480] = "evmwlumianwRRR", [1481] = "evmwlsmianwRRR", + [1491] = "evmwssfanRRR", [1496] = "evmwumianRRR", + [1497] = "evmwsmianRRR", [1499] = "evmwsmfanRRR", +} + +local map_pri = { + [0] = false, false, "tdiARI", "twiARI", + map_spe, false, false, "mulliRRI", + "subficRRI", false, "cmpl_iYLRU", "cmp_iYLRI", + "addicRRI", "addic.RRI", "addi|liRR0I", "addis|lisRR0I", + "b_KBJ", "sc", "bKJ", map_crops, + "rlwimiRR~AAA.", map_rlwinm, false, "rlwnmRR~RAA.", + "oriNRR~U", "orisRR~U", "xoriRR~U", "xorisRR~U", + "andi.RR~U", "andis.RR~U", map_rld, map_ext, + "lwzRRD", "lwzuRRD", "lbzRRD", "lbzuRRD", + "stwRRD", "stwuRRD", "stbRRD", "stbuRRD", + "lhzRRD", "lhzuRRD", "lhaRRD", "lhauRRD", + "sthRRD", "sthuRRD", "lmwRRD", "stmwRRD", + "lfsFRD", "lfsuFRD", "lfdFRD", "lfduFRD", + "stfsFRD", "stfsuFRD", "stfdFRD", "stfduFRD", + false, false, map_ld, map_fps, + false, false, map_std, map_fpd, +} + +------------------------------------------------------------------------------ + +local map_gpr = { + [0] = "r0", "sp", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", + "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", + "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", +} + +local map_cond = { [0] = "lt", "gt", "eq", "so", "ge", "le", "ne", "ns", } + +-- Format a condition bit. +local function condfmt(cond) + if cond <= 3 then + return map_cond[band(cond, 3)] + else + return format("4*cr%d+%s", rshift(cond, 2), map_cond[band(cond, 3)]) + end +end + +------------------------------------------------------------------------------ + +-- Output a nicely formatted line with an opcode and operands. +local function putop(ctx, text, operands) + local pos = ctx.pos + local extra = "" + if ctx.rel then + local sym = ctx.symtab[ctx.rel] + if sym then extra = "\t->"..sym end + end + if ctx.hexdump > 0 then + ctx.out(format("%08x %s %-7s %s%s\n", + ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra)) + else + ctx.out(format("%08x %-7s %s%s\n", + ctx.addr+pos, text, concat(operands, ", "), extra)) + end + ctx.pos = pos + 4 +end + +-- Fallback for unknown opcodes. +local function unknown(ctx) + return putop(ctx, ".long", { "0x"..tohex(ctx.op) }) +end + +-- Disassemble a single instruction. +local function disass_ins(ctx) + local pos = ctx.pos + local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) + local op = bor(lshift(b0, 24), lshift(b1, 16), lshift(b2, 8), b3) + local operands = {} + local last = nil + local rs = 21 + ctx.op = op + ctx.rel = nil + + local opat = map_pri[rshift(b0, 2)] + while type(opat) ~= "string" do + if not opat then return unknown(ctx) end + opat = opat[band(rshift(op, opat.shift), opat.mask)] + end + local name, pat = match(opat, "^([a-z0-9_.]*)(.*)") + local altname, pat2 = match(pat, "|([a-z0-9_.]*)(.*)") + if altname then pat = pat2 end + + for p in gmatch(pat, ".") do + local x = nil + if p == "R" then + x = map_gpr[band(rshift(op, rs), 31)] + rs = rs - 5 + elseif p == "F" then + x = "f"..band(rshift(op, rs), 31) + rs = rs - 5 + elseif p == "A" then + x = band(rshift(op, rs), 31) + rs = rs - 5 + elseif p == "S" then + x = arshift(lshift(op, 27-rs), 27) + rs = rs - 5 + elseif p == "I" then + x = arshift(lshift(op, 16), 16) + elseif p == "U" then + x = band(op, 0xffff) + elseif p == "D" or p == "E" then + local disp = arshift(lshift(op, 16), 16) + if p == "E" then disp = band(disp, -4) end + if last == "r0" then last = "0" end + operands[#operands] = format("%d(%s)", disp, last) + elseif p >= "2" and p <= "8" then + local disp = band(rshift(op, rs), 31) * p + if last == "r0" then last = "0" end + operands[#operands] = format("%d(%s)", disp, last) + elseif p == "H" then + x = band(rshift(op, rs), 31) + lshift(band(op, 2), 4) + rs = rs - 5 + elseif p == "M" then + x = band(rshift(op, rs), 31) + band(op, 0x20) + elseif p == "C" then + x = condfmt(band(rshift(op, rs), 31)) + rs = rs - 5 + elseif p == "B" then + local bo = rshift(op, 21) + local cond = band(rshift(op, 16), 31) + local cn = "" + rs = rs - 10 + if band(bo, 4) == 0 then + cn = band(bo, 2) == 0 and "dnz" or "dz" + if band(bo, 0x10) == 0 then + cn = cn..(band(bo, 8) == 0 and "f" or "t") + end + if band(bo, 0x10) == 0 then x = condfmt(cond) end + name = name..(band(bo, 1) == band(rshift(op, 15), 1) and "-" or "+") + elseif band(bo, 0x10) == 0 then + cn = map_cond[band(cond, 3) + (band(bo, 8) == 0 and 4 or 0)] + if cond > 3 then x = "cr"..rshift(cond, 2) end + name = name..(band(bo, 1) == band(rshift(op, 15), 1) and "-" or "+") + end + name = gsub(name, "_", cn) + elseif p == "J" then + x = arshift(lshift(op, 27-rs), 29-rs)*4 + if band(op, 2) == 0 then x = ctx.addr + pos + x end + ctx.rel = x + x = "0x"..tohex(x) + elseif p == "K" then + if band(op, 1) ~= 0 then name = name.."l" end + if band(op, 2) ~= 0 then name = name.."a" end + elseif p == "X" or p == "Y" then + x = band(rshift(op, rs+2), 7) + if x == 0 and p == "Y" then x = nil else x = "cr"..x end + rs = rs - 5 + elseif p == "W" then + x = "cr"..band(op, 7) + elseif p == "Z" then + x = band(rshift(op, rs-4), 255) + rs = rs - 10 + elseif p == ">" then + operands[#operands] = rshift(operands[#operands], 1) + elseif p == "0" then + if last == "r0" then + operands[#operands] = nil + if altname then name = altname end + end + elseif p == "L" then + name = gsub(name, "_", band(op, 0x00200000) ~= 0 and "d" or "w") + elseif p == "." then + if band(op, 1) == 1 then name = name.."." end + elseif p == "N" then + if op == 0x60000000 then name = "nop"; break end + elseif p == "~" then + local n = #operands + operands[n-1], operands[n] = operands[n], operands[n-1] + elseif p == "=" then + local n = #operands + if last == operands[n-1] then + operands[n] = nil + name = altname + end + elseif p == "%" then + local n = #operands + if last == operands[n-1] and last == operands[n-2] then + operands[n] = nil + operands[n-1] = nil + name = altname + end + elseif p == "-" then + rs = rs - 5 + else + assert(false) + end + if x then operands[#operands+1] = x; last = x end + end + + return putop(ctx, name, operands) +end + +------------------------------------------------------------------------------ + +-- Disassemble a block of code. +local function disass_block(ctx, ofs, len) + if not ofs then ofs = 0 end + local stop = len and ofs+len or #ctx.code + stop = stop - stop % 4 + ctx.pos = ofs - ofs % 4 + ctx.rel = nil + while ctx.pos < stop do disass_ins(ctx) end +end + +-- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). +local function create_(code, addr, out) + local ctx = {} + ctx.code = code + ctx.addr = addr or 0 + ctx.out = out or io.write + ctx.symtab = {} + ctx.disass = disass_block + ctx.hexdump = 8 + return ctx +end + +-- Simple API: disassemble code (a string) at address and output via out. +local function disass_(code, addr, out) + create_(code, addr, out):disass() +end + +-- Return register name for RID. +local function regname_(r) + if r < 32 then return map_gpr[r] end + return "f"..(r-32) +end + +-- Public module functions. +module(...) + +create = create_ +disass = disass_ +regname = regname_ + + +``` + +`include/luajit-2.0.5/src/jit/dis_x64.lua`: + +```lua +---------------------------------------------------------------------------- +-- LuaJIT x64 disassembler wrapper module. +-- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- This module just exports the 64 bit functions from the combined +-- x86/x64 disassembler module. All the interesting stuff is there. +------------------------------------------------------------------------------ + +local require = require + +module(...) + +local dis_x86 = require(_PACKAGE.."dis_x86") + +create = dis_x86.create64 +disass = dis_x86.disass64 +regname = dis_x86.regname64 + + +``` + +`include/luajit-2.0.5/src/jit/dis_x86.lua`: + +```lua +---------------------------------------------------------------------------- +-- LuaJIT x86/x64 disassembler module. +-- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- This is a helper module used by the LuaJIT machine code dumper module. +-- +-- Sending small code snippets to an external disassembler and mixing the +-- output with our own stuff was too fragile. So I had to bite the bullet +-- and write yet another x86 disassembler. Oh well ... +-- +-- The output format is very similar to what ndisasm generates. But it has +-- been developed independently by looking at the opcode tables from the +-- Intel and AMD manuals. The supported instruction set is quite extensive +-- and reflects what a current generation Intel or AMD CPU implements in +-- 32 bit and 64 bit mode. Yes, this includes MMX, SSE, SSE2, SSE3, SSSE3, +-- SSE4.1, SSE4.2, SSE4a and even privileged and hypervisor (VMX/SVM) +-- instructions. +-- +-- Notes: +-- * The (useless) a16 prefix, 3DNow and pre-586 opcodes are unsupported. +-- * No attempt at optimization has been made -- it's fast enough for my needs. +-- * The public API may change when more architectures are added. +------------------------------------------------------------------------------ + +local type = type +local sub, byte, format = string.sub, string.byte, string.format +local match, gmatch, gsub = string.match, string.gmatch, string.gsub +local lower, rep = string.lower, string.rep + +-- Map for 1st opcode byte in 32 bit mode. Ugly? Well ... read on. +local map_opc1_32 = { +--0x +[0]="addBmr","addVmr","addBrm","addVrm","addBai","addVai","push es","pop es", +"orBmr","orVmr","orBrm","orVrm","orBai","orVai","push cs","opc2*", +--1x +"adcBmr","adcVmr","adcBrm","adcVrm","adcBai","adcVai","push ss","pop ss", +"sbbBmr","sbbVmr","sbbBrm","sbbVrm","sbbBai","sbbVai","push ds","pop ds", +--2x +"andBmr","andVmr","andBrm","andVrm","andBai","andVai","es:seg","daa", +"subBmr","subVmr","subBrm","subVrm","subBai","subVai","cs:seg","das", +--3x +"xorBmr","xorVmr","xorBrm","xorVrm","xorBai","xorVai","ss:seg","aaa", +"cmpBmr","cmpVmr","cmpBrm","cmpVrm","cmpBai","cmpVai","ds:seg","aas", +--4x +"incVR","incVR","incVR","incVR","incVR","incVR","incVR","incVR", +"decVR","decVR","decVR","decVR","decVR","decVR","decVR","decVR", +--5x +"pushUR","pushUR","pushUR","pushUR","pushUR","pushUR","pushUR","pushUR", +"popUR","popUR","popUR","popUR","popUR","popUR","popUR","popUR", +--6x +"sz*pushaw,pusha","sz*popaw,popa","boundVrm","arplWmr", +"fs:seg","gs:seg","o16:","a16", +"pushUi","imulVrmi","pushBs","imulVrms", +"insb","insVS","outsb","outsVS", +--7x +"joBj","jnoBj","jbBj","jnbBj","jzBj","jnzBj","jbeBj","jaBj", +"jsBj","jnsBj","jpeBj","jpoBj","jlBj","jgeBj","jleBj","jgBj", +--8x +"arith!Bmi","arith!Vmi","arith!Bmi","arith!Vms", +"testBmr","testVmr","xchgBrm","xchgVrm", +"movBmr","movVmr","movBrm","movVrm", +"movVmg","leaVrm","movWgm","popUm", +--9x +"nop*xchgVaR|pause|xchgWaR|repne nop","xchgVaR","xchgVaR","xchgVaR", +"xchgVaR","xchgVaR","xchgVaR","xchgVaR", +"sz*cbw,cwde,cdqe","sz*cwd,cdq,cqo","call farViw","wait", +"sz*pushfw,pushf","sz*popfw,popf","sahf","lahf", +--Ax +"movBao","movVao","movBoa","movVoa", +"movsb","movsVS","cmpsb","cmpsVS", +"testBai","testVai","stosb","stosVS", +"lodsb","lodsVS","scasb","scasVS", +--Bx +"movBRi","movBRi","movBRi","movBRi","movBRi","movBRi","movBRi","movBRi", +"movVRI","movVRI","movVRI","movVRI","movVRI","movVRI","movVRI","movVRI", +--Cx +"shift!Bmu","shift!Vmu","retBw","ret","$lesVrm","$ldsVrm","movBmi","movVmi", +"enterBwu","leave","retfBw","retf","int3","intBu","into","iretVS", +--Dx +"shift!Bm1","shift!Vm1","shift!Bmc","shift!Vmc","aamBu","aadBu","salc","xlatb", +"fp*0","fp*1","fp*2","fp*3","fp*4","fp*5","fp*6","fp*7", +--Ex +"loopneBj","loopeBj","loopBj","sz*jcxzBj,jecxzBj,jrcxzBj", +"inBau","inVau","outBua","outVua", +"callVj","jmpVj","jmp farViw","jmpBj","inBad","inVad","outBda","outVda", +--Fx +"lock:","int1","repne:rep","rep:","hlt","cmc","testb!Bm","testv!Vm", +"clc","stc","cli","sti","cld","std","incb!Bm","incd!Vm", +} +assert(#map_opc1_32 == 255) + +-- Map for 1st opcode byte in 64 bit mode (overrides only). +local map_opc1_64 = setmetatable({ + [0x06]=false, [0x07]=false, [0x0e]=false, + [0x16]=false, [0x17]=false, [0x1e]=false, [0x1f]=false, + [0x27]=false, [0x2f]=false, [0x37]=false, [0x3f]=false, + [0x60]=false, [0x61]=false, [0x62]=false, [0x63]="movsxdVrDmt", [0x67]="a32:", + [0x40]="rex*", [0x41]="rex*b", [0x42]="rex*x", [0x43]="rex*xb", + [0x44]="rex*r", [0x45]="rex*rb", [0x46]="rex*rx", [0x47]="rex*rxb", + [0x48]="rex*w", [0x49]="rex*wb", [0x4a]="rex*wx", [0x4b]="rex*wxb", + [0x4c]="rex*wr", [0x4d]="rex*wrb", [0x4e]="rex*wrx", [0x4f]="rex*wrxb", + [0x82]=false, [0x9a]=false, [0xc4]=false, [0xc5]=false, [0xce]=false, + [0xd4]=false, [0xd5]=false, [0xd6]=false, [0xea]=false, +}, { __index = map_opc1_32 }) + +-- Map for 2nd opcode byte (0F xx). True CISC hell. Hey, I told you. +-- Prefix dependent MMX/SSE opcodes: (none)|rep|o16|repne, -|F3|66|F2 +local map_opc2 = { +--0x +[0]="sldt!Dmp","sgdt!Ump","larVrm","lslVrm",nil,"syscall","clts","sysret", +"invd","wbinvd",nil,"ud1",nil,"$prefetch!Bm","femms","3dnowMrmu", +--1x +"movupsXrm|movssXrm|movupdXrm|movsdXrm", +"movupsXmr|movssXmr|movupdXmr|movsdXmr", +"movhlpsXrm$movlpsXrm|movsldupXrm|movlpdXrm|movddupXrm", +"movlpsXmr||movlpdXmr", +"unpcklpsXrm||unpcklpdXrm", +"unpckhpsXrm||unpckhpdXrm", +"movlhpsXrm$movhpsXrm|movshdupXrm|movhpdXrm", +"movhpsXmr||movhpdXmr", +"$prefetcht!Bm","hintnopVm","hintnopVm","hintnopVm", +"hintnopVm","hintnopVm","hintnopVm","hintnopVm", +--2x +"movUmx$","movUmy$","movUxm$","movUym$","movUmz$",nil,"movUzm$",nil, +"movapsXrm||movapdXrm", +"movapsXmr||movapdXmr", +"cvtpi2psXrMm|cvtsi2ssXrVmt|cvtpi2pdXrMm|cvtsi2sdXrVmt", +"movntpsXmr|movntssXmr|movntpdXmr|movntsdXmr", +"cvttps2piMrXm|cvttss2siVrXm|cvttpd2piMrXm|cvttsd2siVrXm", +"cvtps2piMrXm|cvtss2siVrXm|cvtpd2piMrXm|cvtsd2siVrXm", +"ucomissXrm||ucomisdXrm", +"comissXrm||comisdXrm", +--3x +"wrmsr","rdtsc","rdmsr","rdpmc","sysenter","sysexit",nil,"getsec", +"opc3*38",nil,"opc3*3a",nil,nil,nil,nil,nil, +--4x +"cmovoVrm","cmovnoVrm","cmovbVrm","cmovnbVrm", +"cmovzVrm","cmovnzVrm","cmovbeVrm","cmovaVrm", +"cmovsVrm","cmovnsVrm","cmovpeVrm","cmovpoVrm", +"cmovlVrm","cmovgeVrm","cmovleVrm","cmovgVrm", +--5x +"movmskpsVrXm$||movmskpdVrXm$","sqrtpsXrm|sqrtssXrm|sqrtpdXrm|sqrtsdXrm", +"rsqrtpsXrm|rsqrtssXrm","rcppsXrm|rcpssXrm", +"andpsXrm||andpdXrm","andnpsXrm||andnpdXrm", +"orpsXrm||orpdXrm","xorpsXrm||xorpdXrm", +"addpsXrm|addssXrm|addpdXrm|addsdXrm","mulpsXrm|mulssXrm|mulpdXrm|mulsdXrm", +"cvtps2pdXrm|cvtss2sdXrm|cvtpd2psXrm|cvtsd2ssXrm", +"cvtdq2psXrm|cvttps2dqXrm|cvtps2dqXrm", +"subpsXrm|subssXrm|subpdXrm|subsdXrm","minpsXrm|minssXrm|minpdXrm|minsdXrm", +"divpsXrm|divssXrm|divpdXrm|divsdXrm","maxpsXrm|maxssXrm|maxpdXrm|maxsdXrm", +--6x +"punpcklbwPrm","punpcklwdPrm","punpckldqPrm","packsswbPrm", +"pcmpgtbPrm","pcmpgtwPrm","pcmpgtdPrm","packuswbPrm", +"punpckhbwPrm","punpckhwdPrm","punpckhdqPrm","packssdwPrm", +"||punpcklqdqXrm","||punpckhqdqXrm", +"movPrVSm","movqMrm|movdquXrm|movdqaXrm", +--7x +"pshufwMrmu|pshufhwXrmu|pshufdXrmu|pshuflwXrmu","pshiftw!Pmu", +"pshiftd!Pmu","pshiftq!Mmu||pshiftdq!Xmu", +"pcmpeqbPrm","pcmpeqwPrm","pcmpeqdPrm","emms|", +"vmreadUmr||extrqXmuu$|insertqXrmuu$","vmwriteUrm||extrqXrm$|insertqXrm$", +nil,nil, +"||haddpdXrm|haddpsXrm","||hsubpdXrm|hsubpsXrm", +"movVSmMr|movqXrm|movVSmXr","movqMmr|movdquXmr|movdqaXmr", +--8x +"joVj","jnoVj","jbVj","jnbVj","jzVj","jnzVj","jbeVj","jaVj", +"jsVj","jnsVj","jpeVj","jpoVj","jlVj","jgeVj","jleVj","jgVj", +--9x +"setoBm","setnoBm","setbBm","setnbBm","setzBm","setnzBm","setbeBm","setaBm", +"setsBm","setnsBm","setpeBm","setpoBm","setlBm","setgeBm","setleBm","setgBm", +--Ax +"push fs","pop fs","cpuid","btVmr","shldVmru","shldVmrc",nil,nil, +"push gs","pop gs","rsm","btsVmr","shrdVmru","shrdVmrc","fxsave!Dmp","imulVrm", +--Bx +"cmpxchgBmr","cmpxchgVmr","$lssVrm","btrVmr", +"$lfsVrm","$lgsVrm","movzxVrBmt","movzxVrWmt", +"|popcntVrm","ud2Dp","bt!Vmu","btcVmr", +"bsfVrm","bsrVrm|lzcntVrm|bsrWrm","movsxVrBmt","movsxVrWmt", +--Cx +"xaddBmr","xaddVmr", +"cmppsXrmu|cmpssXrmu|cmppdXrmu|cmpsdXrmu","$movntiVmr|", +"pinsrwPrWmu","pextrwDrPmu", +"shufpsXrmu||shufpdXrmu","$cmpxchg!Qmp", +"bswapVR","bswapVR","bswapVR","bswapVR","bswapVR","bswapVR","bswapVR","bswapVR", +--Dx +"||addsubpdXrm|addsubpsXrm","psrlwPrm","psrldPrm","psrlqPrm", +"paddqPrm","pmullwPrm", +"|movq2dqXrMm|movqXmr|movdq2qMrXm$","pmovmskbVrMm||pmovmskbVrXm", +"psubusbPrm","psubuswPrm","pminubPrm","pandPrm", +"paddusbPrm","padduswPrm","pmaxubPrm","pandnPrm", +--Ex +"pavgbPrm","psrawPrm","psradPrm","pavgwPrm", +"pmulhuwPrm","pmulhwPrm", +"|cvtdq2pdXrm|cvttpd2dqXrm|cvtpd2dqXrm","$movntqMmr||$movntdqXmr", +"psubsbPrm","psubswPrm","pminswPrm","porPrm", +"paddsbPrm","paddswPrm","pmaxswPrm","pxorPrm", +--Fx +"|||lddquXrm","psllwPrm","pslldPrm","psllqPrm", +"pmuludqPrm","pmaddwdPrm","psadbwPrm","maskmovqMrm||maskmovdquXrm$", +"psubbPrm","psubwPrm","psubdPrm","psubqPrm", +"paddbPrm","paddwPrm","padddPrm","ud", +} +assert(map_opc2[255] == "ud") + +-- Map for three-byte opcodes. Can't wait for their next invention. +local map_opc3 = { +["38"] = { -- [66] 0f 38 xx +--0x +[0]="pshufbPrm","phaddwPrm","phadddPrm","phaddswPrm", +"pmaddubswPrm","phsubwPrm","phsubdPrm","phsubswPrm", +"psignbPrm","psignwPrm","psigndPrm","pmulhrswPrm", +nil,nil,nil,nil, +--1x +"||pblendvbXrma",nil,nil,nil, +"||blendvpsXrma","||blendvpdXrma",nil,"||ptestXrm", +nil,nil,nil,nil, +"pabsbPrm","pabswPrm","pabsdPrm",nil, +--2x +"||pmovsxbwXrm","||pmovsxbdXrm","||pmovsxbqXrm","||pmovsxwdXrm", +"||pmovsxwqXrm","||pmovsxdqXrm",nil,nil, +"||pmuldqXrm","||pcmpeqqXrm","||$movntdqaXrm","||packusdwXrm", +nil,nil,nil,nil, +--3x +"||pmovzxbwXrm","||pmovzxbdXrm","||pmovzxbqXrm","||pmovzxwdXrm", +"||pmovzxwqXrm","||pmovzxdqXrm",nil,"||pcmpgtqXrm", +"||pminsbXrm","||pminsdXrm","||pminuwXrm","||pminudXrm", +"||pmaxsbXrm","||pmaxsdXrm","||pmaxuwXrm","||pmaxudXrm", +--4x +"||pmulddXrm","||phminposuwXrm", +--Fx +[0xf0] = "|||crc32TrBmt",[0xf1] = "|||crc32TrVmt", +}, + +["3a"] = { -- [66] 0f 3a xx +--0x +[0x00]=nil,nil,nil,nil,nil,nil,nil,nil, +"||roundpsXrmu","||roundpdXrmu","||roundssXrmu","||roundsdXrmu", +"||blendpsXrmu","||blendpdXrmu","||pblendwXrmu","palignrPrmu", +--1x +nil,nil,nil,nil, +"||pextrbVmXru","||pextrwVmXru","||pextrVmSXru","||extractpsVmXru", +nil,nil,nil,nil,nil,nil,nil,nil, +--2x +"||pinsrbXrVmu","||insertpsXrmu","||pinsrXrVmuS",nil, +--4x +[0x40] = "||dppsXrmu", +[0x41] = "||dppdXrmu", +[0x42] = "||mpsadbwXrmu", +--6x +[0x60] = "||pcmpestrmXrmu",[0x61] = "||pcmpestriXrmu", +[0x62] = "||pcmpistrmXrmu",[0x63] = "||pcmpistriXrmu", +}, +} + +-- Map for VMX/SVM opcodes 0F 01 C0-FF (sgdt group with register operands). +local map_opcvm = { +[0xc1]="vmcall",[0xc2]="vmlaunch",[0xc3]="vmresume",[0xc4]="vmxoff", +[0xc8]="monitor",[0xc9]="mwait", +[0xd8]="vmrun",[0xd9]="vmmcall",[0xda]="vmload",[0xdb]="vmsave", +[0xdc]="stgi",[0xdd]="clgi",[0xde]="skinit",[0xdf]="invlpga", +[0xf8]="swapgs",[0xf9]="rdtscp", +} + +-- Map for FP opcodes. And you thought stack machines are simple? +local map_opcfp = { +-- D8-DF 00-BF: opcodes with a memory operand. +-- D8 +[0]="faddFm","fmulFm","fcomFm","fcompFm","fsubFm","fsubrFm","fdivFm","fdivrFm", +"fldFm",nil,"fstFm","fstpFm","fldenvVm","fldcwWm","fnstenvVm","fnstcwWm", +-- DA +"fiaddDm","fimulDm","ficomDm","ficompDm", +"fisubDm","fisubrDm","fidivDm","fidivrDm", +-- DB +"fildDm","fisttpDm","fistDm","fistpDm",nil,"fld twordFmp",nil,"fstp twordFmp", +-- DC +"faddGm","fmulGm","fcomGm","fcompGm","fsubGm","fsubrGm","fdivGm","fdivrGm", +-- DD +"fldGm","fisttpQm","fstGm","fstpGm","frstorDmp",nil,"fnsaveDmp","fnstswWm", +-- DE +"fiaddWm","fimulWm","ficomWm","ficompWm", +"fisubWm","fisubrWm","fidivWm","fidivrWm", +-- DF +"fildWm","fisttpWm","fistWm","fistpWm", +"fbld twordFmp","fildQm","fbstp twordFmp","fistpQm", +-- xx C0-FF: opcodes with a pseudo-register operand. +-- D8 +"faddFf","fmulFf","fcomFf","fcompFf","fsubFf","fsubrFf","fdivFf","fdivrFf", +-- D9 +"fldFf","fxchFf",{"fnop"},nil, +{"fchs","fabs",nil,nil,"ftst","fxam"}, +{"fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz"}, +{"f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp"}, +{"fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"}, +-- DA +"fcmovbFf","fcmoveFf","fcmovbeFf","fcmovuFf",nil,{nil,"fucompp"},nil,nil, +-- DB +"fcmovnbFf","fcmovneFf","fcmovnbeFf","fcmovnuFf", +{nil,nil,"fnclex","fninit"},"fucomiFf","fcomiFf",nil, +-- DC +"fadd toFf","fmul toFf",nil,nil, +"fsub toFf","fsubr toFf","fdivr toFf","fdiv toFf", +-- DD +"ffreeFf",nil,"fstFf","fstpFf","fucomFf","fucompFf",nil,nil, +-- DE +"faddpFf","fmulpFf",nil,{nil,"fcompp"}, +"fsubrpFf","fsubpFf","fdivrpFf","fdivpFf", +-- DF +nil,nil,nil,nil,{"fnstsw ax"},"fucomipFf","fcomipFf",nil, +} +assert(map_opcfp[126] == "fcomipFf") + +-- Map for opcode groups. The subkey is sp from the ModRM byte. +local map_opcgroup = { + arith = { "add", "or", "adc", "sbb", "and", "sub", "xor", "cmp" }, + shift = { "rol", "ror", "rcl", "rcr", "shl", "shr", "sal", "sar" }, + testb = { "testBmi", "testBmi", "not", "neg", "mul", "imul", "div", "idiv" }, + testv = { "testVmi", "testVmi", "not", "neg", "mul", "imul", "div", "idiv" }, + incb = { "inc", "dec" }, + incd = { "inc", "dec", "callUmp", "$call farDmp", + "jmpUmp", "$jmp farDmp", "pushUm" }, + sldt = { "sldt", "str", "lldt", "ltr", "verr", "verw" }, + sgdt = { "vm*$sgdt", "vm*$sidt", "$lgdt", "vm*$lidt", + "smsw", nil, "lmsw", "vm*$invlpg" }, + bt = { nil, nil, nil, nil, "bt", "bts", "btr", "btc" }, + cmpxchg = { nil, "sz*,cmpxchg8bQmp,cmpxchg16bXmp", nil, nil, + nil, nil, "vmptrld|vmxon|vmclear", "vmptrst" }, + pshiftw = { nil, nil, "psrlw", nil, "psraw", nil, "psllw" }, + pshiftd = { nil, nil, "psrld", nil, "psrad", nil, "pslld" }, + pshiftq = { nil, nil, "psrlq", nil, nil, nil, "psllq" }, + pshiftdq = { nil, nil, "psrlq", "psrldq", nil, nil, "psllq", "pslldq" }, + fxsave = { "$fxsave", "$fxrstor", "$ldmxcsr", "$stmxcsr", + nil, "lfenceDp$", "mfenceDp$", "sfenceDp$clflush" }, + prefetch = { "prefetch", "prefetchw" }, + prefetcht = { "prefetchnta", "prefetcht0", "prefetcht1", "prefetcht2" }, +} + +------------------------------------------------------------------------------ + +-- Maps for register names. +local map_regs = { + B = { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh", + "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b" }, + B64 = { "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil", + "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b" }, + W = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", + "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w" }, + D = { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", + "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d" }, + Q = { "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" }, + M = { "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7", + "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" }, -- No x64 ext! + X = { "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", + "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" }, +} +local map_segregs = { "es", "cs", "ss", "ds", "fs", "gs", "segr6", "segr7" } + +-- Maps for size names. +local map_sz2n = { + B = 1, W = 2, D = 4, Q = 8, M = 8, X = 16, +} +local map_sz2prefix = { + B = "byte", W = "word", D = "dword", + Q = "qword", + M = "qword", X = "xword", + F = "dword", G = "qword", -- No need for sizes/register names for these two. +} + +------------------------------------------------------------------------------ + +-- Output a nicely formatted line with an opcode and operands. +local function putop(ctx, text, operands) + local code, pos, hex = ctx.code, ctx.pos, "" + local hmax = ctx.hexdump + if hmax > 0 then + for i=ctx.start,pos-1 do + hex = hex..format("%02X", byte(code, i, i)) + end + if #hex > hmax then hex = sub(hex, 1, hmax)..". " + else hex = hex..rep(" ", hmax-#hex+2) end + end + if operands then text = text.." "..operands end + if ctx.o16 then text = "o16 "..text; ctx.o16 = false end + if ctx.a32 then text = "a32 "..text; ctx.a32 = false end + if ctx.rep then text = ctx.rep.." "..text; ctx.rep = false end + if ctx.rex then + local t = (ctx.rexw and "w" or "")..(ctx.rexr and "r" or "").. + (ctx.rexx and "x" or "")..(ctx.rexb and "b" or "") + if t ~= "" then text = "rex."..t.." "..text end + ctx.rexw = false; ctx.rexr = false; ctx.rexx = false; ctx.rexb = false + ctx.rex = false + end + if ctx.seg then + local text2, n = gsub(text, "%[", "["..ctx.seg..":") + if n == 0 then text = ctx.seg.." "..text else text = text2 end + ctx.seg = false + end + if ctx.lock then text = "lock "..text; ctx.lock = false end + local imm = ctx.imm + if imm then + local sym = ctx.symtab[imm] + if sym then text = text.."\t->"..sym end + end + ctx.out(format("%08x %s%s\n", ctx.addr+ctx.start, hex, text)) + ctx.mrm = false + ctx.start = pos + ctx.imm = nil +end + +-- Clear all prefix flags. +local function clearprefixes(ctx) + ctx.o16 = false; ctx.seg = false; ctx.lock = false; ctx.rep = false + ctx.rexw = false; ctx.rexr = false; ctx.rexx = false; ctx.rexb = false + ctx.rex = false; ctx.a32 = false +end + +-- Fallback for incomplete opcodes at the end. +local function incomplete(ctx) + ctx.pos = ctx.stop+1 + clearprefixes(ctx) + return putop(ctx, "(incomplete)") +end + +-- Fallback for unknown opcodes. +local function unknown(ctx) + clearprefixes(ctx) + return putop(ctx, "(unknown)") +end + +-- Return an immediate of the specified size. +local function getimm(ctx, pos, n) + if pos+n-1 > ctx.stop then return incomplete(ctx) end + local code = ctx.code + if n == 1 then + local b1 = byte(code, pos, pos) + return b1 + elseif n == 2 then + local b1, b2 = byte(code, pos, pos+1) + return b1+b2*256 + else + local b1, b2, b3, b4 = byte(code, pos, pos+3) + local imm = b1+b2*256+b3*65536+b4*16777216 + ctx.imm = imm + return imm + end +end + +-- Process pattern string and generate the operands. +local function putpat(ctx, name, pat) + local operands, regs, sz, mode, sp, rm, sc, rx, sdisp + local code, pos, stop = ctx.code, ctx.pos, ctx.stop + + -- Chars used: 1DFGIMPQRSTUVWXacdfgijmoprstuwxyz + for p in gmatch(pat, ".") do + local x = nil + if p == "V" or p == "U" then + if ctx.rexw then sz = "Q"; ctx.rexw = false + elseif ctx.o16 then sz = "W"; ctx.o16 = false + elseif p == "U" and ctx.x64 then sz = "Q" + else sz = "D" end + regs = map_regs[sz] + elseif p == "T" then + if ctx.rexw then sz = "Q"; ctx.rexw = false else sz = "D" end + regs = map_regs[sz] + elseif p == "B" then + sz = "B" + regs = ctx.rex and map_regs.B64 or map_regs.B + elseif match(p, "[WDQMXFG]") then + sz = p + regs = map_regs[sz] + elseif p == "P" then + sz = ctx.o16 and "X" or "M"; ctx.o16 = false + regs = map_regs[sz] + elseif p == "S" then + name = name..lower(sz) + elseif p == "s" then + local imm = getimm(ctx, pos, 1); if not imm then return end + x = imm <= 127 and format("+0x%02x", imm) + or format("-0x%02x", 256-imm) + pos = pos+1 + elseif p == "u" then + local imm = getimm(ctx, pos, 1); if not imm then return end + x = format("0x%02x", imm) + pos = pos+1 + elseif p == "w" then + local imm = getimm(ctx, pos, 2); if not imm then return end + x = format("0x%x", imm) + pos = pos+2 + elseif p == "o" then -- [offset] + if ctx.x64 then + local imm1 = getimm(ctx, pos, 4); if not imm1 then return end + local imm2 = getimm(ctx, pos+4, 4); if not imm2 then return end + x = format("[0x%08x%08x]", imm2, imm1) + pos = pos+8 + else + local imm = getimm(ctx, pos, 4); if not imm then return end + x = format("[0x%08x]", imm) + pos = pos+4 + end + elseif p == "i" or p == "I" then + local n = map_sz2n[sz] + if n == 8 and ctx.x64 and p == "I" then + local imm1 = getimm(ctx, pos, 4); if not imm1 then return end + local imm2 = getimm(ctx, pos+4, 4); if not imm2 then return end + x = format("0x%08x%08x", imm2, imm1) + else + if n == 8 then n = 4 end + local imm = getimm(ctx, pos, n); if not imm then return end + if sz == "Q" and (imm < 0 or imm > 0x7fffffff) then + imm = (0xffffffff+1)-imm + x = format(imm > 65535 and "-0x%08x" or "-0x%x", imm) + else + x = format(imm > 65535 and "0x%08x" or "0x%x", imm) + end + end + pos = pos+n + elseif p == "j" then + local n = map_sz2n[sz] + if n == 8 then n = 4 end + local imm = getimm(ctx, pos, n); if not imm then return end + if sz == "B" and imm > 127 then imm = imm-256 + elseif imm > 2147483647 then imm = imm-4294967296 end + pos = pos+n + imm = imm + pos + ctx.addr + if imm > 4294967295 and not ctx.x64 then imm = imm-4294967296 end + ctx.imm = imm + if sz == "W" then + x = format("word 0x%04x", imm%65536) + elseif ctx.x64 then + local lo = imm % 0x1000000 + x = format("0x%02x%06x", (imm-lo) / 0x1000000, lo) + else + x = format("0x%08x", imm) + end + elseif p == "R" then + local r = byte(code, pos-1, pos-1)%8 + if ctx.rexb then r = r + 8; ctx.rexb = false end + x = regs[r+1] + elseif p == "a" then x = regs[1] + elseif p == "c" then x = "cl" + elseif p == "d" then x = "dx" + elseif p == "1" then x = "1" + else + if not mode then + mode = ctx.mrm + if not mode then + if pos > stop then return incomplete(ctx) end + mode = byte(code, pos, pos) + pos = pos+1 + end + rm = mode%8; mode = (mode-rm)/8 + sp = mode%8; mode = (mode-sp)/8 + sdisp = "" + if mode < 3 then + if rm == 4 then + if pos > stop then return incomplete(ctx) end + sc = byte(code, pos, pos) + pos = pos+1 + rm = sc%8; sc = (sc-rm)/8 + rx = sc%8; sc = (sc-rx)/8 + if ctx.rexx then rx = rx + 8; ctx.rexx = false end + if rx == 4 then rx = nil end + end + if mode > 0 or rm == 5 then + local dsz = mode + if dsz ~= 1 then dsz = 4 end + local disp = getimm(ctx, pos, dsz); if not disp then return end + if mode == 0 then rm = nil end + if rm or rx or (not sc and ctx.x64 and not ctx.a32) then + if dsz == 1 and disp > 127 then + sdisp = format("-0x%x", 256-disp) + elseif disp >= 0 and disp <= 0x7fffffff then + sdisp = format("+0x%x", disp) + else + sdisp = format("-0x%x", (0xffffffff+1)-disp) + end + else + sdisp = format(ctx.x64 and not ctx.a32 and + not (disp >= 0 and disp <= 0x7fffffff) + and "0xffffffff%08x" or "0x%08x", disp) + end + pos = pos+dsz + end + end + if rm and ctx.rexb then rm = rm + 8; ctx.rexb = false end + if ctx.rexr then sp = sp + 8; ctx.rexr = false end + end + if p == "m" then + if mode == 3 then x = regs[rm+1] + else + local aregs = ctx.a32 and map_regs.D or ctx.aregs + local srm, srx = "", "" + if rm then srm = aregs[rm+1] + elseif not sc and ctx.x64 and not ctx.a32 then srm = "rip" end + ctx.a32 = false + if rx then + if rm then srm = srm.."+" end + srx = aregs[rx+1] + if sc > 0 then srx = srx.."*"..(2^sc) end + end + x = format("[%s%s%s]", srm, srx, sdisp) + end + if mode < 3 and + (not match(pat, "[aRrgp]") or match(pat, "t")) then -- Yuck. + x = map_sz2prefix[sz].." "..x + end + elseif p == "r" then x = regs[sp+1] + elseif p == "g" then x = map_segregs[sp+1] + elseif p == "p" then -- Suppress prefix. + elseif p == "f" then x = "st"..rm + elseif p == "x" then + if sp == 0 and ctx.lock and not ctx.x64 then + x = "CR8"; ctx.lock = false + else + x = "CR"..sp + end + elseif p == "y" then x = "DR"..sp + elseif p == "z" then x = "TR"..sp + elseif p == "t" then + else + error("bad pattern `"..pat.."'") + end + end + if x then operands = operands and operands..", "..x or x end + end + ctx.pos = pos + return putop(ctx, name, operands) +end + +-- Forward declaration. +local map_act + +-- Fetch and cache MRM byte. +local function getmrm(ctx) + local mrm = ctx.mrm + if not mrm then + local pos = ctx.pos + if pos > ctx.stop then return nil end + mrm = byte(ctx.code, pos, pos) + ctx.pos = pos+1 + ctx.mrm = mrm + end + return mrm +end + +-- Dispatch to handler depending on pattern. +local function dispatch(ctx, opat, patgrp) + if not opat then return unknown(ctx) end + if match(opat, "%|") then -- MMX/SSE variants depending on prefix. + local p + if ctx.rep then + p = ctx.rep=="rep" and "%|([^%|]*)" or "%|[^%|]*%|[^%|]*%|([^%|]*)" + ctx.rep = false + elseif ctx.o16 then p = "%|[^%|]*%|([^%|]*)"; ctx.o16 = false + else p = "^[^%|]*" end + opat = match(opat, p) + if not opat then return unknown(ctx) end +-- ctx.rep = false; ctx.o16 = false + --XXX fails for 66 f2 0f 38 f1 06 crc32 eax,WORD PTR [esi] + --XXX remove in branches? + end + if match(opat, "%$") then -- reg$mem variants. + local mrm = getmrm(ctx); if not mrm then return incomplete(ctx) end + opat = match(opat, mrm >= 192 and "^[^%$]*" or "%$(.*)") + if opat == "" then return unknown(ctx) end + end + if opat == "" then return unknown(ctx) end + local name, pat = match(opat, "^([a-z0-9 ]*)(.*)") + if pat == "" and patgrp then pat = patgrp end + return map_act[sub(pat, 1, 1)](ctx, name, pat) +end + +-- Get a pattern from an opcode map and dispatch to handler. +local function dispatchmap(ctx, opcmap) + local pos = ctx.pos + local opat = opcmap[byte(ctx.code, pos, pos)] + pos = pos + 1 + ctx.pos = pos + return dispatch(ctx, opat) +end + +-- Map for action codes. The key is the first char after the name. +map_act = { + -- Simple opcodes without operands. + [""] = function(ctx, name, pat) + return putop(ctx, name) + end, + + -- Operand size chars fall right through. + B = putpat, W = putpat, D = putpat, Q = putpat, + V = putpat, U = putpat, T = putpat, + M = putpat, X = putpat, P = putpat, + F = putpat, G = putpat, + + -- Collect prefixes. + [":"] = function(ctx, name, pat) + ctx[pat == ":" and name or sub(pat, 2)] = name + if ctx.pos - ctx.start > 5 then return unknown(ctx) end -- Limit #prefixes. + end, + + -- Chain to special handler specified by name. + ["*"] = function(ctx, name, pat) + return map_act[name](ctx, name, sub(pat, 2)) + end, + + -- Use named subtable for opcode group. + ["!"] = function(ctx, name, pat) + local mrm = getmrm(ctx); if not mrm then return incomplete(ctx) end + return dispatch(ctx, map_opcgroup[name][((mrm-(mrm%8))/8)%8+1], sub(pat, 2)) + end, + + -- o16,o32[,o64] variants. + sz = function(ctx, name, pat) + if ctx.o16 then ctx.o16 = false + else + pat = match(pat, ",(.*)") + if ctx.rexw then + local p = match(pat, ",(.*)") + if p then pat = p; ctx.rexw = false end + end + end + pat = match(pat, "^[^,]*") + return dispatch(ctx, pat) + end, + + -- Two-byte opcode dispatch. + opc2 = function(ctx, name, pat) + return dispatchmap(ctx, map_opc2) + end, + + -- Three-byte opcode dispatch. + opc3 = function(ctx, name, pat) + return dispatchmap(ctx, map_opc3[pat]) + end, + + -- VMX/SVM dispatch. + vm = function(ctx, name, pat) + return dispatch(ctx, map_opcvm[ctx.mrm]) + end, + + -- Floating point opcode dispatch. + fp = function(ctx, name, pat) + local mrm = getmrm(ctx); if not mrm then return incomplete(ctx) end + local rm = mrm%8 + local idx = pat*8 + ((mrm-rm)/8)%8 + if mrm >= 192 then idx = idx + 64 end + local opat = map_opcfp[idx] + if type(opat) == "table" then opat = opat[rm+1] end + return dispatch(ctx, opat) + end, + + -- REX prefix. + rex = function(ctx, name, pat) + if ctx.rex then return unknown(ctx) end -- Only 1 REX prefix allowed. + for p in gmatch(pat, ".") do ctx["rex"..p] = true end + ctx.rex = true + end, + + -- Special case for nop with REX prefix. + nop = function(ctx, name, pat) + return dispatch(ctx, ctx.rex and pat or "nop") + end, +} + +------------------------------------------------------------------------------ + +-- Disassemble a block of code. +local function disass_block(ctx, ofs, len) + if not ofs then ofs = 0 end + local stop = len and ofs+len or #ctx.code + ofs = ofs + 1 + ctx.start = ofs + ctx.pos = ofs + ctx.stop = stop + ctx.imm = nil + ctx.mrm = false + clearprefixes(ctx) + while ctx.pos <= stop do dispatchmap(ctx, ctx.map1) end + if ctx.pos ~= ctx.start then incomplete(ctx) end +end + +-- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). +local function create_(code, addr, out) + local ctx = {} + ctx.code = code + ctx.addr = (addr or 0) - 1 + ctx.out = out or io.write + ctx.symtab = {} + ctx.disass = disass_block + ctx.hexdump = 16 + ctx.x64 = false + ctx.map1 = map_opc1_32 + ctx.aregs = map_regs.D + return ctx +end + +local function create64_(code, addr, out) + local ctx = create_(code, addr, out) + ctx.x64 = true + ctx.map1 = map_opc1_64 + ctx.aregs = map_regs.Q + return ctx +end + +-- Simple API: disassemble code (a string) at address and output via out. +local function disass_(code, addr, out) + create_(code, addr, out):disass() +end + +local function disass64_(code, addr, out) + create64_(code, addr, out):disass() +end + +-- Return register name for RID. +local function regname_(r) + if r < 8 then return map_regs.D[r+1] end + return map_regs.X[r-7] +end + +local function regname64_(r) + if r < 16 then return map_regs.Q[r+1] end + return map_regs.X[r-15] +end + +-- Public module functions. +module(...) + +create = create_ +create64 = create64_ +disass = disass_ +disass64 = disass64_ +regname = regname_ +regname64 = regname64_ + + +``` + +`include/luajit-2.0.5/src/jit/dump.lua`: + +```lua +---------------------------------------------------------------------------- +-- LuaJIT compiler dump module. +-- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- +-- This module can be used to debug the JIT compiler itself. It dumps the +-- code representations and structures used in various compiler stages. +-- +-- Example usage: +-- +-- luajit -jdump -e "local x=0; for i=1,1e6 do x=x+i end; print(x)" +-- luajit -jdump=im -e "for i=1,1000 do for j=1,1000 do end end" | less -R +-- luajit -jdump=is myapp.lua | less -R +-- luajit -jdump=-b myapp.lua +-- luajit -jdump=+aH,myapp.html myapp.lua +-- luajit -jdump=ixT,myapp.dump myapp.lua +-- +-- The first argument specifies the dump mode. The second argument gives +-- the output file name. Default output is to stdout, unless the environment +-- variable LUAJIT_DUMPFILE is set. The file is overwritten every time the +-- module is started. +-- +-- Different features can be turned on or off with the dump mode. If the +-- mode starts with a '+', the following features are added to the default +-- set of features; a '-' removes them. Otherwise the features are replaced. +-- +-- The following dump features are available (* marks the default): +-- +-- * t Print a line for each started, ended or aborted trace (see also -jv). +-- * b Dump the traced bytecode. +-- * i Dump the IR (intermediate representation). +-- r Augment the IR with register/stack slots. +-- s Dump the snapshot map. +-- * m Dump the generated machine code. +-- x Print each taken trace exit. +-- X Print each taken trace exit and the contents of all registers. +-- a Print the IR of aborted traces, too. +-- +-- The output format can be set with the following characters: +-- +-- T Plain text output. +-- A ANSI-colored text output +-- H Colorized HTML + CSS output. +-- +-- The default output format is plain text. It's set to ANSI-colored text +-- if the COLORTERM variable is set. Note: this is independent of any output +-- redirection, which is actually considered a feature. +-- +-- You probably want to use less -R to enjoy viewing ANSI-colored text from +-- a pipe or a file. Add this to your ~/.bashrc: export LESS="-R" +-- +------------------------------------------------------------------------------ + +-- Cache some library functions and objects. +local jit = require("jit") +assert(jit.version_num == 20005, "LuaJIT core/library version mismatch") +local jutil = require("jit.util") +local vmdef = require("jit.vmdef") +local funcinfo, funcbc = jutil.funcinfo, jutil.funcbc +local traceinfo, traceir, tracek = jutil.traceinfo, jutil.traceir, jutil.tracek +local tracemc, tracesnap = jutil.tracemc, jutil.tracesnap +local traceexitstub, ircalladdr = jutil.traceexitstub, jutil.ircalladdr +local bit = require("bit") +local band, shr = bit.band, bit.rshift +local sub, gsub, format = string.sub, string.gsub, string.format +local byte, rep = string.byte, string.rep +local type, tostring = type, tostring +local stdout, stderr = io.stdout, io.stderr + +-- Load other modules on-demand. +local bcline, disass + +-- Active flag, output file handle and dump mode. +local active, out, dumpmode + +------------------------------------------------------------------------------ + +local symtabmt = { __index = false } +local symtab = {} +local nexitsym = 0 + +-- Fill nested symbol table with per-trace exit stub addresses. +local function fillsymtab_tr(tr, nexit) + local t = {} + symtabmt.__index = t + if jit.arch == "mips" or jit.arch == "mipsel" then + t[traceexitstub(tr, 0)] = "exit" + return + end + for i=0,nexit-1 do + local addr = traceexitstub(tr, i) + t[addr] = tostring(i) + end + local addr = traceexitstub(tr, nexit) + if addr then t[addr] = "stack_check" end +end + +-- Fill symbol table with trace exit stub addresses. +local function fillsymtab(tr, nexit) + local t = symtab + if nexitsym == 0 then + local ircall = vmdef.ircall + for i=0,#ircall do + local addr = ircalladdr(i) + if addr ~= 0 then t[addr] = ircall[i] end + end + end + if nexitsym == 1000000 then -- Per-trace exit stubs. + fillsymtab_tr(tr, nexit) + elseif nexit > nexitsym then -- Shared exit stubs. + for i=nexitsym,nexit-1 do + local addr = traceexitstub(i) + if addr == nil then -- Fall back to per-trace exit stubs. + fillsymtab_tr(tr, nexit) + setmetatable(symtab, symtabmt) + nexit = 1000000 + break + end + t[addr] = tostring(i) + end + nexitsym = nexit + end + return t +end + +local function dumpwrite(s) + out:write(s) +end + +-- Disassemble machine code. +local function dump_mcode(tr) + local info = traceinfo(tr) + if not info then return end + local mcode, addr, loop = tracemc(tr) + if not mcode then return end + if not disass then disass = require("jit.dis_"..jit.arch) end + out:write("---- TRACE ", tr, " mcode ", #mcode, "\n") + local ctx = disass.create(mcode, addr, dumpwrite) + ctx.hexdump = 0 + ctx.symtab = fillsymtab(tr, info.nexit) + if loop ~= 0 then + symtab[addr+loop] = "LOOP" + ctx:disass(0, loop) + out:write("->LOOP:\n") + ctx:disass(loop, #mcode-loop) + symtab[addr+loop] = nil + else + ctx:disass(0, #mcode) + end +end + +------------------------------------------------------------------------------ + +local irtype_text = { + [0] = "nil", + "fal", + "tru", + "lud", + "str", + "p32", + "thr", + "pro", + "fun", + "p64", + "cdt", + "tab", + "udt", + "flt", + "num", + "i8 ", + "u8 ", + "i16", + "u16", + "int", + "u32", + "i64", + "u64", + "sfp", +} + +local colortype_ansi = { + [0] = "%s", + "%s", + "%s", + "\027[36m%s\027[m", + "\027[32m%s\027[m", + "%s", + "\027[1m%s\027[m", + "%s", + "\027[1m%s\027[m", + "%s", + "\027[33m%s\027[m", + "\027[31m%s\027[m", + "\027[36m%s\027[m", + "\027[34m%s\027[m", + "\027[34m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", +} + +local function colorize_text(s) + return s +end + +local function colorize_ansi(s, t) + return format(colortype_ansi[t], s) +end + +local irtype_ansi = setmetatable({}, + { __index = function(tab, t) + local s = colorize_ansi(irtype_text[t], t); tab[t] = s; return s; end }) + +local html_escape = { ["<"] = "<", [">"] = ">", ["&"] = "&", } + +local function colorize_html(s, t) + s = gsub(s, "[<>&]", html_escape) + return format('%s', irtype_text[t], s) +end + +local irtype_html = setmetatable({}, + { __index = function(tab, t) + local s = colorize_html(irtype_text[t], t); tab[t] = s; return s; end }) + +local header_html = [[ + +]] + +local colorize, irtype + +-- Lookup tables to convert some literals into names. +local litname = { + ["SLOAD "] = setmetatable({}, { __index = function(t, mode) + local s = "" + if band(mode, 1) ~= 0 then s = s.."P" end + if band(mode, 2) ~= 0 then s = s.."F" end + if band(mode, 4) ~= 0 then s = s.."T" end + if band(mode, 8) ~= 0 then s = s.."C" end + if band(mode, 16) ~= 0 then s = s.."R" end + if band(mode, 32) ~= 0 then s = s.."I" end + t[mode] = s + return s + end}), + ["XLOAD "] = { [0] = "", "R", "V", "RV", "U", "RU", "VU", "RVU", }, + ["CONV "] = setmetatable({}, { __index = function(t, mode) + local s = irtype[band(mode, 31)] + s = irtype[band(shr(mode, 5), 31)].."."..s + if band(mode, 0x400) ~= 0 then s = s.." trunc" + elseif band(mode, 0x800) ~= 0 then s = s.." sext" end + local c = shr(mode, 14) + if c == 2 then s = s.." index" elseif c == 3 then s = s.." check" end + t[mode] = s + return s + end}), + ["FLOAD "] = vmdef.irfield, + ["FREF "] = vmdef.irfield, + ["FPMATH"] = vmdef.irfpm, +} + +local function ctlsub(c) + if c == "\n" then return "\\n" + elseif c == "\r" then return "\\r" + elseif c == "\t" then return "\\t" + else return format("\\%03d", byte(c)) + end +end + +local function fmtfunc(func, pc) + local fi = funcinfo(func, pc) + if fi.loc then + return fi.loc + elseif fi.ffid then + return vmdef.ffnames[fi.ffid] + elseif fi.addr then + return format("C:%x", fi.addr) + else + return "(?)" + end +end + +local function formatk(tr, idx) + local k, t, slot = tracek(tr, idx) + local tn = type(k) + local s + if tn == "number" then + if k == 2^52+2^51 then + s = "bias" + else + s = format("%+.14g", k) + end + elseif tn == "string" then + s = format(#k > 20 and '"%.20s"~' or '"%s"', gsub(k, "%c", ctlsub)) + elseif tn == "function" then + s = fmtfunc(k) + elseif tn == "table" then + s = format("{%p}", k) + elseif tn == "userdata" then + if t == 12 then + s = format("userdata:%p", k) + else + s = format("[%p]", k) + if s == "[NULL]" then s = "NULL" end + end + elseif t == 21 then -- int64_t + s = sub(tostring(k), 1, -3) + if sub(s, 1, 1) ~= "-" then s = "+"..s end + else + s = tostring(k) -- For primitives. + end + s = colorize(format("%-4s", s), t) + if slot then + s = format("%s @%d", s, slot) + end + return s +end + +local function printsnap(tr, snap) + local n = 2 + for s=0,snap[1]-1 do + local sn = snap[n] + if shr(sn, 24) == s then + n = n + 1 + local ref = band(sn, 0xffff) - 0x8000 -- REF_BIAS + if ref < 0 then + out:write(formatk(tr, ref)) + elseif band(sn, 0x80000) ~= 0 then -- SNAP_SOFTFPNUM + out:write(colorize(format("%04d/%04d", ref, ref+1), 14)) + else + local m, ot, op1, op2 = traceir(tr, ref) + out:write(colorize(format("%04d", ref), band(ot, 31))) + end + out:write(band(sn, 0x10000) == 0 and " " or "|") -- SNAP_FRAME + else + out:write("---- ") + end + end + out:write("]\n") +end + +-- Dump snapshots (not interleaved with IR). +local function dump_snap(tr) + out:write("---- TRACE ", tr, " snapshots\n") + for i=0,1000000000 do + local snap = tracesnap(tr, i) + if not snap then break end + out:write(format("#%-3d %04d [ ", i, snap[0])) + printsnap(tr, snap) + end +end + +-- Return a register name or stack slot for a rid/sp location. +local function ridsp_name(ridsp, ins) + if not disass then disass = require("jit.dis_"..jit.arch) end + local rid, slot = band(ridsp, 0xff), shr(ridsp, 8) + if rid == 253 or rid == 254 then + return (slot == 0 or slot == 255) and " {sink" or format(" {%04d", ins-slot) + end + if ridsp > 255 then return format("[%x]", slot*4) end + if rid < 128 then return disass.regname(rid) end + return "" +end + +-- Dump CALL* function ref and return optional ctype. +local function dumpcallfunc(tr, ins) + local ctype + if ins > 0 then + local m, ot, op1, op2 = traceir(tr, ins) + if band(ot, 31) == 0 then -- nil type means CARG(func, ctype). + ins = op1 + ctype = formatk(tr, op2) + end + end + if ins < 0 then + out:write(format("[0x%x](", tonumber((tracek(tr, ins))))) + else + out:write(format("%04d (", ins)) + end + return ctype +end + +-- Recursively gather CALL* args and dump them. +local function dumpcallargs(tr, ins) + if ins < 0 then + out:write(formatk(tr, ins)) + else + local m, ot, op1, op2 = traceir(tr, ins) + local oidx = 6*shr(ot, 8) + local op = sub(vmdef.irnames, oidx+1, oidx+6) + if op == "CARG " then + dumpcallargs(tr, op1) + if op2 < 0 then + out:write(" ", formatk(tr, op2)) + else + out:write(" ", format("%04d", op2)) + end + else + out:write(format("%04d", ins)) + end + end +end + +-- Dump IR and interleaved snapshots. +local function dump_ir(tr, dumpsnap, dumpreg) + local info = traceinfo(tr) + if not info then return end + local nins = info.nins + out:write("---- TRACE ", tr, " IR\n") + local irnames = vmdef.irnames + local snapref = 65536 + local snap, snapno + if dumpsnap then + snap = tracesnap(tr, 0) + snapref = snap[0] + snapno = 0 + end + for ins=1,nins do + if ins >= snapref then + if dumpreg then + out:write(format(".... SNAP #%-3d [ ", snapno)) + else + out:write(format(".... SNAP #%-3d [ ", snapno)) + end + printsnap(tr, snap) + snapno = snapno + 1 + snap = tracesnap(tr, snapno) + snapref = snap and snap[0] or 65536 + end + local m, ot, op1, op2, ridsp = traceir(tr, ins) + local oidx, t = 6*shr(ot, 8), band(ot, 31) + local op = sub(irnames, oidx+1, oidx+6) + if op == "LOOP " then + if dumpreg then + out:write(format("%04d ------------ LOOP ------------\n", ins)) + else + out:write(format("%04d ------ LOOP ------------\n", ins)) + end + elseif op ~= "NOP " and op ~= "CARG " and + (dumpreg or op ~= "RENAME") then + local rid = band(ridsp, 255) + if dumpreg then + out:write(format("%04d %-6s", ins, ridsp_name(ridsp, ins))) + else + out:write(format("%04d ", ins)) + end + out:write(format("%s%s %s %s ", + (rid == 254 or rid == 253) and "}" or + (band(ot, 128) == 0 and " " or ">"), + band(ot, 64) == 0 and " " or "+", + irtype[t], op)) + local m1, m2 = band(m, 3), band(m, 3*4) + if sub(op, 1, 4) == "CALL" then + local ctype + if m2 == 1*4 then -- op2 == IRMlit + out:write(format("%-10s (", vmdef.ircall[op2])) + else + ctype = dumpcallfunc(tr, op2) + end + if op1 ~= -1 then dumpcallargs(tr, op1) end + out:write(")") + if ctype then out:write(" ctype ", ctype) end + elseif op == "CNEW " and op2 == -1 then + out:write(formatk(tr, op1)) + elseif m1 ~= 3 then -- op1 != IRMnone + if op1 < 0 then + out:write(formatk(tr, op1)) + else + out:write(format(m1 == 0 and "%04d" or "#%-3d", op1)) + end + if m2 ~= 3*4 then -- op2 != IRMnone + if m2 == 1*4 then -- op2 == IRMlit + local litn = litname[op] + if litn and litn[op2] then + out:write(" ", litn[op2]) + elseif op == "UREFO " or op == "UREFC " then + out:write(format(" #%-3d", shr(op2, 8))) + else + out:write(format(" #%-3d", op2)) + end + elseif op2 < 0 then + out:write(" ", formatk(tr, op2)) + else + out:write(format(" %04d", op2)) + end + end + end + out:write("\n") + end + end + if snap then + if dumpreg then + out:write(format(".... SNAP #%-3d [ ", snapno)) + else + out:write(format(".... SNAP #%-3d [ ", snapno)) + end + printsnap(tr, snap) + end +end + +------------------------------------------------------------------------------ + +local recprefix = "" +local recdepth = 0 + +-- Format trace error message. +local function fmterr(err, info) + if type(err) == "number" then + if type(info) == "function" then info = fmtfunc(info) end + err = format(vmdef.traceerr[err], info) + end + return err +end + +-- Dump trace states. +local function dump_trace(what, tr, func, pc, otr, oex) + if what == "stop" or (what == "abort" and dumpmode.a) then + if dumpmode.i then dump_ir(tr, dumpmode.s, dumpmode.r and what == "stop") + elseif dumpmode.s then dump_snap(tr) end + if dumpmode.m then dump_mcode(tr) end + end + if what == "start" then + if dumpmode.H then out:write('
\n') end
+    out:write("---- TRACE ", tr, " ", what)
+    if otr then out:write(" ", otr, "/", oex) end
+    out:write(" ", fmtfunc(func, pc), "\n")
+  elseif what == "stop" or what == "abort" then
+    out:write("---- TRACE ", tr, " ", what)
+    if what == "abort" then
+      out:write(" ", fmtfunc(func, pc), " -- ", fmterr(otr, oex), "\n")
+    else
+      local info = traceinfo(tr)
+      local link, ltype = info.link, info.linktype
+      if link == tr or link == 0 then
+	out:write(" -> ", ltype, "\n")
+      elseif ltype == "root" then
+	out:write(" -> ", link, "\n")
+      else
+	out:write(" -> ", link, " ", ltype, "\n")
+      end
+    end
+    if dumpmode.H then out:write("
\n\n") else out:write("\n") end + else + if what == "flush" then symtab, nexitsym = {}, 0 end + out:write("---- TRACE ", what, "\n\n") + end + out:flush() +end + +-- Dump recorded bytecode. +local function dump_record(tr, func, pc, depth, callee) + if depth ~= recdepth then + recdepth = depth + recprefix = rep(" .", depth) + end + local line + if pc >= 0 then + line = bcline(func, pc, recprefix) + if dumpmode.H then line = gsub(line, "[<>&]", html_escape) end + else + line = "0000 "..recprefix.." FUNCC \n" + callee = func + end + if pc <= 0 then + out:write(sub(line, 1, -2), " ; ", fmtfunc(func), "\n") + else + out:write(line) + end + if pc >= 0 and band(funcbc(func, pc), 0xff) < 16 then -- ORDER BC + out:write(bcline(func, pc+1, recprefix)) -- Write JMP for cond. + end +end + +------------------------------------------------------------------------------ + +-- Dump taken trace exits. +local function dump_texit(tr, ex, ngpr, nfpr, ...) + out:write("---- TRACE ", tr, " exit ", ex, "\n") + if dumpmode.X then + local regs = {...} + if jit.arch == "x64" then + for i=1,ngpr do + out:write(format(" %016x", regs[i])) + if i % 4 == 0 then out:write("\n") end + end + else + for i=1,ngpr do + out:write(format(" %08x", regs[i])) + if i % 8 == 0 then out:write("\n") end + end + end + if jit.arch == "mips" or jit.arch == "mipsel" then + for i=1,nfpr,2 do + out:write(format(" %+17.14g", regs[ngpr+i])) + if i % 8 == 7 then out:write("\n") end + end + else + for i=1,nfpr do + out:write(format(" %+17.14g", regs[ngpr+i])) + if i % 4 == 0 then out:write("\n") end + end + end + end +end + +------------------------------------------------------------------------------ + +-- Detach dump handlers. +local function dumpoff() + if active then + active = false + jit.attach(dump_texit) + jit.attach(dump_record) + jit.attach(dump_trace) + if out and out ~= stdout and out ~= stderr then out:close() end + out = nil + end +end + +-- Open the output file and attach dump handlers. +local function dumpon(opt, outfile) + if active then dumpoff() end + + local term = os.getenv("TERM") + local colormode = (term and term:match("color") or os.getenv("COLORTERM")) and "A" or "T" + if opt then + opt = gsub(opt, "[TAH]", function(mode) colormode = mode; return ""; end) + end + + local m = { t=true, b=true, i=true, m=true, } + if opt and opt ~= "" then + local o = sub(opt, 1, 1) + if o ~= "+" and o ~= "-" then m = {} end + for i=1,#opt do m[sub(opt, i, i)] = (o ~= "-") end + end + dumpmode = m + + if m.t or m.b or m.i or m.s or m.m then + jit.attach(dump_trace, "trace") + end + if m.b then + jit.attach(dump_record, "record") + if not bcline then bcline = require("jit.bc").line end + end + if m.x or m.X then + jit.attach(dump_texit, "texit") + end + + if not outfile then outfile = os.getenv("LUAJIT_DUMPFILE") end + if outfile then + out = outfile == "-" and stdout or assert(io.open(outfile, "w")) + else + out = stdout + end + + m[colormode] = true + if colormode == "A" then + colorize = colorize_ansi + irtype = irtype_ansi + elseif colormode == "H" then + colorize = colorize_html + irtype = irtype_html + out:write(header_html) + else + colorize = colorize_text + irtype = irtype_text + end + + active = true +end + +-- Public module functions. +module(...) + +on = dumpon +off = dumpoff +start = dumpon -- For -j command line option. + + +``` + +`include/luajit-2.0.5/src/jit/v.lua`: + +```lua +---------------------------------------------------------------------------- +-- Verbose mode of the LuaJIT compiler. +-- +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- +-- This module shows verbose information about the progress of the +-- JIT compiler. It prints one line for each generated trace. This module +-- is useful to see which code has been compiled or where the compiler +-- punts and falls back to the interpreter. +-- +-- Example usage: +-- +-- luajit -jv -e "for i=1,1000 do for j=1,1000 do end end" +-- luajit -jv=myapp.out myapp.lua +-- +-- Default output is to stderr. To redirect the output to a file, pass a +-- filename as an argument (use '-' for stdout) or set the environment +-- variable LUAJIT_VERBOSEFILE. The file is overwritten every time the +-- module is started. +-- +-- The output from the first example should look like this: +-- +-- [TRACE 1 (command line):1 loop] +-- [TRACE 2 (1/3) (command line):1 -> 1] +-- +-- The first number in each line is the internal trace number. Next are +-- the file name ('(command line)') and the line number (':1') where the +-- trace has started. Side traces also show the parent trace number and +-- the exit number where they are attached to in parentheses ('(1/3)'). +-- An arrow at the end shows where the trace links to ('-> 1'), unless +-- it loops to itself. +-- +-- In this case the inner loop gets hot and is traced first, generating +-- a root trace. Then the last exit from the 1st trace gets hot, too, +-- and triggers generation of the 2nd trace. The side trace follows the +-- path along the outer loop and *around* the inner loop, back to its +-- start, and then links to the 1st trace. Yes, this may seem unusual, +-- if you know how traditional compilers work. Trace compilers are full +-- of surprises like this -- have fun! :-) +-- +-- Aborted traces are shown like this: +-- +-- [TRACE --- foo.lua:44 -- leaving loop in root trace at foo:lua:50] +-- +-- Don't worry -- trace aborts are quite common, even in programs which +-- can be fully compiled. The compiler may retry several times until it +-- finds a suitable trace. +-- +-- Of course this doesn't work with features that are not-yet-implemented +-- (NYI error messages). The VM simply falls back to the interpreter. This +-- may not matter at all if the particular trace is not very high up in +-- the CPU usage profile. Oh, and the interpreter is quite fast, too. +-- +-- Also check out the -jdump module, which prints all the gory details. +-- +------------------------------------------------------------------------------ + +-- Cache some library functions and objects. +local jit = require("jit") +assert(jit.version_num == 20005, "LuaJIT core/library version mismatch") +local jutil = require("jit.util") +local vmdef = require("jit.vmdef") +local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo +local type, format = type, string.format +local stdout, stderr = io.stdout, io.stderr + +-- Active flag and output file handle. +local active, out + +------------------------------------------------------------------------------ + +local startloc, startex + +local function fmtfunc(func, pc) + local fi = funcinfo(func, pc) + if fi.loc then + return fi.loc + elseif fi.ffid then + return vmdef.ffnames[fi.ffid] + elseif fi.addr then + return format("C:%x", fi.addr) + else + return "(?)" + end +end + +-- Format trace error message. +local function fmterr(err, info) + if type(err) == "number" then + if type(info) == "function" then info = fmtfunc(info) end + err = format(vmdef.traceerr[err], info) + end + return err +end + +-- Dump trace states. +local function dump_trace(what, tr, func, pc, otr, oex) + if what == "start" then + startloc = fmtfunc(func, pc) + startex = otr and "("..otr.."/"..oex..") " or "" + else + if what == "abort" then + local loc = fmtfunc(func, pc) + if loc ~= startloc then + out:write(format("[TRACE --- %s%s -- %s at %s]\n", + startex, startloc, fmterr(otr, oex), loc)) + else + out:write(format("[TRACE --- %s%s -- %s]\n", + startex, startloc, fmterr(otr, oex))) + end + elseif what == "stop" then + local info = traceinfo(tr) + local link, ltype = info.link, info.linktype + if ltype == "interpreter" then + out:write(format("[TRACE %3s %s%s -- fallback to interpreter]\n", + tr, startex, startloc)) + elseif link == tr or link == 0 then + out:write(format("[TRACE %3s %s%s %s]\n", + tr, startex, startloc, ltype)) + elseif ltype == "root" then + out:write(format("[TRACE %3s %s%s -> %d]\n", + tr, startex, startloc, link)) + else + out:write(format("[TRACE %3s %s%s -> %d %s]\n", + tr, startex, startloc, link, ltype)) + end + else + out:write(format("[TRACE %s]\n", what)) + end + out:flush() + end +end + +------------------------------------------------------------------------------ + +-- Detach dump handlers. +local function dumpoff() + if active then + active = false + jit.attach(dump_trace) + if out and out ~= stdout and out ~= stderr then out:close() end + out = nil + end +end + +-- Open the output file and attach dump handlers. +local function dumpon(outfile) + if active then dumpoff() end + if not outfile then outfile = os.getenv("LUAJIT_VERBOSEFILE") end + if outfile then + out = outfile == "-" and stdout or assert(io.open(outfile, "w")) + else + out = stderr + end + jit.attach(dump_trace, "trace") + active = true +end + +-- Public module functions. +module(...) + +on = dumpon +off = dumpoff +start = dumpon -- For -j command line option. + + +``` + +`include/luajit-2.0.5/src/jit/vmdef.lua`: + +```lua +-- This is a generated file. DO NOT EDIT! + +module(...) + +bcnames = "ISLT ISGE ISLE ISGT ISEQV ISNEV ISEQS ISNES ISEQN ISNEN ISEQP ISNEP ISTC ISFC IST ISF MOV NOT UNM LEN ADDVN SUBVN MULVN DIVVN MODVN ADDNV SUBNV MULNV DIVNV MODNV ADDVV SUBVV MULVV DIVVV MODVV POW CAT KSTR KCDATAKSHORTKNUM KPRI KNIL UGET USETV USETS USETN USETP UCLO FNEW TNEW TDUP GGET GSET TGETV TGETS TGETB TSETV TSETS TSETB TSETM CALLM CALL CALLMTCALLT ITERC ITERN VARG ISNEXTRETM RET RET0 RET1 FORI JFORI FORL IFORL JFORL ITERL IITERLJITERLLOOP ILOOP JLOOP JMP FUNCF IFUNCFJFUNCFFUNCV IFUNCVJFUNCVFUNCC FUNCCW" + +irnames = "LT GE LE GT ULT UGE ULE UGT EQ NE ABC RETF NOP BASE PVAL GCSTEPHIOP LOOP USE PHI RENAMEKPRI KINT KGC KPTR KKPTR KNULL KNUM KINT64KSLOT BNOT BSWAP BAND BOR BXOR BSHL BSHR BSAR BROL BROR ADD SUB MUL DIV MOD POW NEG ABS ATAN2 LDEXP MIN MAX FPMATHADDOV SUBOV MULOV AREF HREFK HREF NEWREFUREFO UREFC FREF STRREFALOAD HLOAD ULOAD FLOAD XLOAD SLOAD VLOAD ASTOREHSTOREUSTOREFSTOREXSTORESNEW XSNEW TNEW TDUP CNEW CNEWI TBAR OBAR XBAR CONV TOBIT TOSTR STRTO CALLN CALLL CALLS CALLXSCARG " + +irfpm = { [0]="floor", "ceil", "trunc", "sqrt", "exp", "exp2", "log", "log2", "log10", "sin", "cos", "tan", "other", } + +irfield = { [0]="str.len", "func.env", "func.pc", "tab.meta", "tab.array", "tab.node", "tab.asize", "tab.hmask", "tab.nomm", "udata.meta", "udata.udtype", "udata.file", "cdata.ctypeid", "cdata.ptr", "cdata.int", "cdata.int64", "cdata.int64_4", } + +ircall = { +[0]="lj_str_cmp", +"lj_str_new", +"lj_strscan_num", +"lj_str_fromint", +"lj_str_fromnum", +"lj_tab_new1", +"lj_tab_dup", +"lj_tab_newkey", +"lj_tab_len", +"lj_gc_step_jit", +"lj_gc_barrieruv", +"lj_mem_newgco", +"lj_math_random_step", +"lj_vm_modi", +"sinh", +"cosh", +"tanh", +"fputc", +"fwrite", +"fflush", +"lj_vm_floor", +"lj_vm_ceil", +"lj_vm_trunc", +"sqrt", +"exp", +"lj_vm_exp2", +"log", +"lj_vm_log2", +"log10", +"sin", +"cos", +"tan", +"lj_vm_powi", +"pow", +"atan2", +"ldexp", +"lj_vm_tobit", +"softfp_add", +"softfp_sub", +"softfp_mul", +"softfp_div", +"softfp_cmp", +"softfp_i2d", +"softfp_d2i", +"softfp_ui2d", +"softfp_f2d", +"softfp_d2ui", +"softfp_d2f", +"softfp_i2f", +"softfp_ui2f", +"softfp_f2i", +"softfp_f2ui", +"fp64_l2d", +"fp64_ul2d", +"fp64_l2f", +"fp64_ul2f", +"fp64_d2l", +"fp64_d2ul", +"fp64_f2l", +"fp64_f2ul", +"lj_carith_divi64", +"lj_carith_divu64", +"lj_carith_modi64", +"lj_carith_modu64", +"lj_carith_powi64", +"lj_carith_powu64", +"lj_cdata_setfin", +"strlen", +"memcpy", +"memset", +"lj_vm_errno", +"lj_carith_mul64", +} + +traceerr = { +[0]="error thrown or hook called during recording", +"trace too long", +"trace too deep", +"too many snapshots", +"blacklisted", +"NYI: bytecode %d", +"leaving loop in root trace", +"inner loop in root trace", +"loop unroll limit reached", +"bad argument type", +"JIT compilation disabled for function", +"call unroll limit reached", +"down-recursion, restarting", +"NYI: C function %s", +"NYI: FastFunc %s", +"NYI: unsupported variant of FastFunc %s", +"NYI: return to lower frame", +"store with nil or NaN key", +"missing metamethod", +"looping index lookup", +"NYI: mixed sparse/dense table", +"symbol not in cache", +"NYI: unsupported C type conversion", +"NYI: unsupported C function type", +"guard would always fail", +"too many PHIs", +"persistent type instability", +"failed to allocate mcode memory", +"machine code too long", +"hit mcode limit (retrying)", +"too many spill slots", +"inconsistent register allocation", +"NYI: cannot assemble IR instruction %d", +"NYI: PHI shuffling too complex", +"NYI: register coalescing too complex", +} + +ffnames = { +[0]="Lua", +"C", +"assert", +"type", +"next", +"pairs", +"ipairs_aux", +"ipairs", +"getmetatable", +"setmetatable", +"getfenv", +"setfenv", +"rawget", +"rawset", +"rawequal", +"unpack", +"select", +"tonumber", +"tostring", +"error", +"pcall", +"xpcall", +"loadfile", +"load", +"loadstring", +"dofile", +"gcinfo", +"collectgarbage", +"newproxy", +"print", +"coroutine.status", +"coroutine.running", +"coroutine.create", +"coroutine.yield", +"coroutine.resume", +"coroutine.wrap_aux", +"coroutine.wrap", +"math.abs", +"math.floor", +"math.ceil", +"math.sqrt", +"math.log10", +"math.exp", +"math.sin", +"math.cos", +"math.tan", +"math.asin", +"math.acos", +"math.atan", +"math.sinh", +"math.cosh", +"math.tanh", +"math.frexp", +"math.modf", +"math.deg", +"math.rad", +"math.log", +"math.atan2", +"math.pow", +"math.fmod", +"math.ldexp", +"math.min", +"math.max", +"math.random", +"math.randomseed", +"bit.tobit", +"bit.bnot", +"bit.bswap", +"bit.lshift", +"bit.rshift", +"bit.arshift", +"bit.rol", +"bit.ror", +"bit.band", +"bit.bor", +"bit.bxor", +"bit.tohex", +"string.len", +"string.byte", +"string.char", +"string.sub", +"string.rep", +"string.reverse", +"string.lower", +"string.upper", +"string.dump", +"string.find", +"string.match", +"string.gmatch_aux", +"string.gmatch", +"string.gsub", +"string.format", +"table.foreachi", +"table.foreach", +"table.getn", +"table.maxn", +"table.insert", +"table.remove", +"table.concat", +"table.sort", +"io.method.close", +"io.method.read", +"io.method.write", +"io.method.flush", +"io.method.seek", +"io.method.setvbuf", +"io.method.lines", +"io.method.__gc", +"io.method.__tostring", +"io.open", +"io.popen", +"io.tmpfile", +"io.close", +"io.read", +"io.write", +"io.flush", +"io.input", +"io.output", +"io.lines", +"io.type", +"os.execute", +"os.remove", +"os.rename", +"os.tmpname", +"os.getenv", +"os.exit", +"os.clock", +"os.date", +"os.time", +"os.difftime", +"os.setlocale", +"debug.getregistry", +"debug.getmetatable", +"debug.setmetatable", +"debug.getfenv", +"debug.setfenv", +"debug.getinfo", +"debug.getlocal", +"debug.setlocal", +"debug.getupvalue", +"debug.setupvalue", +"debug.upvalueid", +"debug.upvaluejoin", +"debug.sethook", +"debug.gethook", +"debug.debug", +"debug.traceback", +"jit.on", +"jit.off", +"jit.flush", +"jit.status", +"jit.attach", +"jit.util.funcinfo", +"jit.util.funcbc", +"jit.util.funck", +"jit.util.funcuvname", +"jit.util.traceinfo", +"jit.util.traceir", +"jit.util.tracek", +"jit.util.tracesnap", +"jit.util.tracemc", +"jit.util.traceexitstub", +"jit.util.ircalladdr", +"jit.opt.start", +"ffi.meta.__index", +"ffi.meta.__newindex", +"ffi.meta.__eq", +"ffi.meta.__len", +"ffi.meta.__lt", +"ffi.meta.__le", +"ffi.meta.__concat", +"ffi.meta.__call", +"ffi.meta.__add", +"ffi.meta.__sub", +"ffi.meta.__mul", +"ffi.meta.__div", +"ffi.meta.__mod", +"ffi.meta.__pow", +"ffi.meta.__unm", +"ffi.meta.__tostring", +"ffi.meta.__pairs", +"ffi.meta.__ipairs", +"ffi.clib.__index", +"ffi.clib.__newindex", +"ffi.clib.__gc", +"ffi.callback.free", +"ffi.callback.set", +"ffi.cdef", +"ffi.new", +"ffi.cast", +"ffi.typeof", +"ffi.istype", +"ffi.sizeof", +"ffi.alignof", +"ffi.offsetof", +"ffi.errno", +"ffi.string", +"ffi.copy", +"ffi.fill", +"ffi.abi", +"ffi.metatype", +"ffi.gc", +"ffi.load", +} + + +``` + +`include/luajit-2.0.5/src/lauxlib.h`: + +```h +/* +** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lauxlib_h +#define lauxlib_h + + +#include +#include + +#include "lua.h" + + +#define luaL_getn(L,i) ((int)lua_objlen(L, i)) +#define luaL_setn(L,i,j) ((void)0) /* no op! */ + +/* extra error code for `luaL_load' */ +#define LUA_ERRFILE (LUA_ERRERR+1) + +typedef struct luaL_Reg { + const char *name; + lua_CFunction func; +} luaL_Reg; + +LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, + const luaL_Reg *l, int nup); +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l); +LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); +LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); +LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, + size_t *l); +LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, + const char *def, size_t *l); +LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); +LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); + +LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); +LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, + lua_Integer def); + +LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); +LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); +LUALIB_API void (luaL_checkany) (lua_State *L, int narg); + +LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); + +LUALIB_API void (luaL_where) (lua_State *L, int lvl); +LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); + +LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, + const char *const lst[]); + +LUALIB_API int (luaL_ref) (lua_State *L, int t); +LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); + +LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); +LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, + const char *name); +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); + +LUALIB_API lua_State *(luaL_newstate) (void); + + +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, + const char *r); + +LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, + const char *fname, int szhint); + +/* From Lua 5.2. */ +LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname); +LUALIB_API int luaL_execresult(lua_State *L, int stat); +LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, + const char *mode); +LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, + const char *name, const char *mode); +LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, const char *msg, + int level); + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define luaL_argcheck(L, cond,numarg,extramsg) \ + ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + + +typedef struct luaL_Buffer { + char *p; /* current position in buffer */ + int lvl; /* number of strings in the stack (level) */ + lua_State *L; + char buffer[LUAL_BUFFERSIZE]; +} luaL_Buffer; + +#define luaL_addchar(B,c) \ + ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ + (*(B)->p++ = (char)(c))) + +/* compatibility only */ +#define luaL_putchar(B,c) luaL_addchar(B,c) + +#define luaL_addsize(B,n) ((B)->p += (n)) + +LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); +LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); +LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); + + +/* }====================================================== */ + + +/* compatibility with ref system */ + +/* pre-defined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ + (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) + +#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) + +#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) + + +#define luaL_reg luaL_Reg + +#endif + +``` + +`include/luajit-2.0.5/src/lib_aux.c`: + +```c +/* +** Auxiliary library for the Lua/C API. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Major parts taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#include +#include +#include + +#define lib_aux_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" + +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_state.h" +#include "lj_trace.h" +#include "lj_lib.h" + +#if LJ_TARGET_POSIX +#include +#endif + +/* -- I/O error handling -------------------------------------------------- */ + +LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname) +{ + if (stat) { + setboolV(L->top++, 1); + return 1; + } else { + int en = errno; /* Lua API calls may change this value. */ + setnilV(L->top++); + if (fname) + lua_pushfstring(L, "%s: %s", fname, strerror(en)); + else + lua_pushfstring(L, "%s", strerror(en)); + setintV(L->top++, en); + lj_trace_abort(G(L)); + return 3; + } +} + +LUALIB_API int luaL_execresult(lua_State *L, int stat) +{ + if (stat != -1) { +#if LJ_TARGET_POSIX + if (WIFSIGNALED(stat)) { + stat = WTERMSIG(stat); + setnilV(L->top++); + lua_pushliteral(L, "signal"); + } else { + if (WIFEXITED(stat)) + stat = WEXITSTATUS(stat); + if (stat == 0) + setboolV(L->top++, 1); + else + setnilV(L->top++); + lua_pushliteral(L, "exit"); + } +#else + if (stat == 0) + setboolV(L->top++, 1); + else + setnilV(L->top++); + lua_pushliteral(L, "exit"); +#endif + setintV(L->top++, stat); + return 3; + } + return luaL_fileresult(L, 0, NULL); +} + +/* -- Module registration ------------------------------------------------- */ + +LUALIB_API const char *luaL_findtable(lua_State *L, int idx, + const char *fname, int szhint) +{ + const char *e; + lua_pushvalue(L, idx); + do { + e = strchr(fname, '.'); + if (e == NULL) e = fname + strlen(fname); + lua_pushlstring(L, fname, (size_t)(e - fname)); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { /* no such field? */ + lua_pop(L, 1); /* remove this nil */ + lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ + lua_pushlstring(L, fname, (size_t)(e - fname)); + lua_pushvalue(L, -2); + lua_settable(L, -4); /* set new table into field */ + } else if (!lua_istable(L, -1)) { /* field has a non-table value? */ + lua_pop(L, 2); /* remove table and value */ + return fname; /* return problematic part of the name */ + } + lua_remove(L, -2); /* remove previous table */ + fname = e + 1; + } while (*e == '.'); + return NULL; +} + +static int libsize(const luaL_Reg *l) +{ + int size = 0; + for (; l->name; l++) size++; + return size; +} + +LUALIB_API void luaL_openlib(lua_State *L, const char *libname, + const luaL_Reg *l, int nup) +{ + lj_lib_checkfpu(L); + if (libname) { + int size = libsize(l); + /* check whether lib already exists */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 16); + lua_getfield(L, -1, libname); /* get _LOADED[libname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) + lj_err_callerv(L, LJ_ERR_BADMODN, libname); + lua_pushvalue(L, -1); + lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ + } + lua_remove(L, -2); /* remove _LOADED table */ + lua_insert(L, -(nup+1)); /* move library table to below upvalues */ + } + for (; l->name; l++) { + int i; + for (i = 0; i < nup; i++) /* copy upvalues to the top */ + lua_pushvalue(L, -nup); + lua_pushcclosure(L, l->func, nup); + lua_setfield(L, -(nup+2), l->name); + } + lua_pop(L, nup); /* remove upvalues */ +} + +LUALIB_API void luaL_register(lua_State *L, const char *libname, + const luaL_Reg *l) +{ + luaL_openlib(L, libname, l, 0); +} + +LUALIB_API const char *luaL_gsub(lua_State *L, const char *s, + const char *p, const char *r) +{ + const char *wild; + size_t l = strlen(p); + luaL_Buffer b; + luaL_buffinit(L, &b); + while ((wild = strstr(s, p)) != NULL) { + luaL_addlstring(&b, s, (size_t)(wild - s)); /* push prefix */ + luaL_addstring(&b, r); /* push replacement in place of pattern */ + s = wild + l; /* continue after `p' */ + } + luaL_addstring(&b, s); /* push last suffix */ + luaL_pushresult(&b); + return lua_tostring(L, -1); +} + +/* -- Buffer handling ----------------------------------------------------- */ + +#define bufflen(B) ((size_t)((B)->p - (B)->buffer)) +#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) + +static int emptybuffer(luaL_Buffer *B) +{ + size_t l = bufflen(B); + if (l == 0) + return 0; /* put nothing on stack */ + lua_pushlstring(B->L, B->buffer, l); + B->p = B->buffer; + B->lvl++; + return 1; +} + +static void adjuststack(luaL_Buffer *B) +{ + if (B->lvl > 1) { + lua_State *L = B->L; + int toget = 1; /* number of levels to concat */ + size_t toplen = lua_strlen(L, -1); + do { + size_t l = lua_strlen(L, -(toget+1)); + if (!(B->lvl - toget + 1 >= LUA_MINSTACK/2 || toplen > l)) + break; + toplen += l; + toget++; + } while (toget < B->lvl); + lua_concat(L, toget); + B->lvl = B->lvl - toget + 1; + } +} + +LUALIB_API char *luaL_prepbuffer(luaL_Buffer *B) +{ + if (emptybuffer(B)) + adjuststack(B); + return B->buffer; +} + +LUALIB_API void luaL_addlstring(luaL_Buffer *B, const char *s, size_t l) +{ + while (l--) + luaL_addchar(B, *s++); +} + +LUALIB_API void luaL_addstring(luaL_Buffer *B, const char *s) +{ + luaL_addlstring(B, s, strlen(s)); +} + +LUALIB_API void luaL_pushresult(luaL_Buffer *B) +{ + emptybuffer(B); + lua_concat(B->L, B->lvl); + B->lvl = 1; +} + +LUALIB_API void luaL_addvalue(luaL_Buffer *B) +{ + lua_State *L = B->L; + size_t vl; + const char *s = lua_tolstring(L, -1, &vl); + if (vl <= bufffree(B)) { /* fit into buffer? */ + memcpy(B->p, s, vl); /* put it there */ + B->p += vl; + lua_pop(L, 1); /* remove from stack */ + } else { + if (emptybuffer(B)) + lua_insert(L, -2); /* put buffer before new value */ + B->lvl++; /* add new value into B stack */ + adjuststack(B); + } +} + +LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B) +{ + B->L = L; + B->p = B->buffer; + B->lvl = 0; +} + +/* -- Reference management ------------------------------------------------ */ + +#define FREELIST_REF 0 + +/* Convert a stack index to an absolute index. */ +#define abs_index(L, i) \ + ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : lua_gettop(L) + (i) + 1) + +LUALIB_API int luaL_ref(lua_State *L, int t) +{ + int ref; + t = abs_index(L, t); + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* remove from stack */ + return LUA_REFNIL; /* `nil' has a unique fixed reference */ + } + lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ + ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ + lua_pop(L, 1); /* remove it from stack */ + if (ref != 0) { /* any free element? */ + lua_rawgeti(L, t, ref); /* remove it from list */ + lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ + } else { /* no free elements */ + ref = (int)lua_objlen(L, t); + ref++; /* create new reference */ + } + lua_rawseti(L, t, ref); + return ref; +} + +LUALIB_API void luaL_unref(lua_State *L, int t, int ref) +{ + if (ref >= 0) { + t = abs_index(L, t); + lua_rawgeti(L, t, FREELIST_REF); + lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ + lua_pushinteger(L, ref); + lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ + } +} + +/* -- Default allocator and panic function -------------------------------- */ + +static int panic(lua_State *L) +{ + const char *s = lua_tostring(L, -1); + fputs("PANIC: unprotected error in call to Lua API (", stderr); + fputs(s ? s : "?", stderr); + fputc(')', stderr); fputc('\n', stderr); + fflush(stderr); + return 0; +} + +#ifdef LUAJIT_USE_SYSMALLOC + +#if LJ_64 && !defined(LUAJIT_USE_VALGRIND) +#error "Must use builtin allocator for 64 bit target" +#endif + +static void *mem_alloc(void *ud, void *ptr, size_t osize, size_t nsize) +{ + (void)ud; + (void)osize; + if (nsize == 0) { + free(ptr); + return NULL; + } else { + return realloc(ptr, nsize); + } +} + +LUALIB_API lua_State *luaL_newstate(void) +{ + lua_State *L = lua_newstate(mem_alloc, NULL); + if (L) G(L)->panic = panic; + return L; +} + +#else + +#include "lj_alloc.h" + +LUALIB_API lua_State *luaL_newstate(void) +{ + lua_State *L; + void *ud = lj_alloc_create(); + if (ud == NULL) return NULL; +#if LJ_64 + L = lj_state_newstate(lj_alloc_f, ud); +#else + L = lua_newstate(lj_alloc_f, ud); +#endif + if (L) G(L)->panic = panic; + return L; +} + +#if LJ_64 +LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) +{ + UNUSED(f); UNUSED(ud); + fputs("Must use luaL_newstate() for 64 bit target\n", stderr); + return NULL; +} +#endif + +#endif + + +``` + +`include/luajit-2.0.5/src/lib_base.c`: + +```c +/* +** Base and coroutine library. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#include + +#define lib_base_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_meta.h" +#include "lj_state.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#include "lj_cconv.h" +#endif +#include "lj_bc.h" +#include "lj_ff.h" +#include "lj_dispatch.h" +#include "lj_char.h" +#include "lj_strscan.h" +#include "lj_lib.h" + +/* -- Base library: checks ------------------------------------------------ */ + +#define LJLIB_MODULE_base + +LJLIB_ASM(assert) LJLIB_REC(.) +{ + GCstr *s; + lj_lib_checkany(L, 1); + s = lj_lib_optstr(L, 2); + if (s) + lj_err_callermsg(L, strdata(s)); + else + lj_err_caller(L, LJ_ERR_ASSERT); + return FFH_UNREACHABLE; +} + +/* ORDER LJ_T */ +LJLIB_PUSH("nil") +LJLIB_PUSH("boolean") +LJLIB_PUSH(top-1) /* boolean */ +LJLIB_PUSH("userdata") +LJLIB_PUSH("string") +LJLIB_PUSH("upval") +LJLIB_PUSH("thread") +LJLIB_PUSH("proto") +LJLIB_PUSH("function") +LJLIB_PUSH("trace") +LJLIB_PUSH("cdata") +LJLIB_PUSH("table") +LJLIB_PUSH(top-9) /* userdata */ +LJLIB_PUSH("number") +LJLIB_ASM_(type) LJLIB_REC(.) +/* Recycle the lj_lib_checkany(L, 1) from assert. */ + +/* -- Base library: iterators --------------------------------------------- */ + +/* This solves a circular dependency problem -- change FF_next_N as needed. */ +LJ_STATIC_ASSERT((int)FF_next == FF_next_N); + +LJLIB_ASM(next) +{ + lj_lib_checktab(L, 1); + return FFH_UNREACHABLE; +} + +#if LJ_52 || LJ_HASFFI +static int ffh_pairs(lua_State *L, MMS mm) +{ + TValue *o = lj_lib_checkany(L, 1); + cTValue *mo = lj_meta_lookup(L, o, mm); + if ((LJ_52 || tviscdata(o)) && !tvisnil(mo)) { + L->top = o+1; /* Only keep one argument. */ + copyTV(L, L->base-1, mo); /* Replace callable. */ + return FFH_TAILCALL; + } else { + if (!tvistab(o)) lj_err_argt(L, 1, LUA_TTABLE); + setfuncV(L, o-1, funcV(lj_lib_upvalue(L, 1))); + if (mm == MM_pairs) setnilV(o+1); else setintV(o+1, 0); + return FFH_RES(3); + } +} +#else +#define ffh_pairs(L, mm) (lj_lib_checktab(L, 1), FFH_UNREACHABLE) +#endif + +LJLIB_PUSH(lastcl) +LJLIB_ASM(pairs) +{ + return ffh_pairs(L, MM_pairs); +} + +LJLIB_NOREGUV LJLIB_ASM(ipairs_aux) LJLIB_REC(.) +{ + lj_lib_checktab(L, 1); + lj_lib_checkint(L, 2); + return FFH_UNREACHABLE; +} + +LJLIB_PUSH(lastcl) +LJLIB_ASM(ipairs) LJLIB_REC(.) +{ + return ffh_pairs(L, MM_ipairs); +} + +/* -- Base library: getters and setters ----------------------------------- */ + +LJLIB_ASM_(getmetatable) LJLIB_REC(.) +/* Recycle the lj_lib_checkany(L, 1) from assert. */ + +LJLIB_ASM(setmetatable) LJLIB_REC(.) +{ + GCtab *t = lj_lib_checktab(L, 1); + GCtab *mt = lj_lib_checktabornil(L, 2); + if (!tvisnil(lj_meta_lookup(L, L->base, MM_metatable))) + lj_err_caller(L, LJ_ERR_PROTMT); + setgcref(t->metatable, obj2gco(mt)); + if (mt) { lj_gc_objbarriert(L, t, mt); } + settabV(L, L->base-1, t); + return FFH_RES(1); +} + +LJLIB_CF(getfenv) +{ + GCfunc *fn; + cTValue *o = L->base; + if (!(o < L->top && tvisfunc(o))) { + int level = lj_lib_optint(L, 1, 1); + o = lj_debug_frame(L, level, &level); + if (o == NULL) + lj_err_arg(L, 1, LJ_ERR_INVLVL); + } + fn = &gcval(o)->fn; + settabV(L, L->top++, isluafunc(fn) ? tabref(fn->l.env) : tabref(L->env)); + return 1; +} + +LJLIB_CF(setfenv) +{ + GCfunc *fn; + GCtab *t = lj_lib_checktab(L, 2); + cTValue *o = L->base; + if (!(o < L->top && tvisfunc(o))) { + int level = lj_lib_checkint(L, 1); + if (level == 0) { + /* NOBARRIER: A thread (i.e. L) is never black. */ + setgcref(L->env, obj2gco(t)); + return 0; + } + o = lj_debug_frame(L, level, &level); + if (o == NULL) + lj_err_arg(L, 1, LJ_ERR_INVLVL); + } + fn = &gcval(o)->fn; + if (!isluafunc(fn)) + lj_err_caller(L, LJ_ERR_SETFENV); + setgcref(fn->l.env, obj2gco(t)); + lj_gc_objbarrier(L, obj2gco(fn), t); + setfuncV(L, L->top++, fn); + return 1; +} + +LJLIB_ASM(rawget) LJLIB_REC(.) +{ + lj_lib_checktab(L, 1); + lj_lib_checkany(L, 2); + return FFH_UNREACHABLE; +} + +LJLIB_CF(rawset) LJLIB_REC(.) +{ + lj_lib_checktab(L, 1); + lj_lib_checkany(L, 2); + L->top = 1+lj_lib_checkany(L, 3); + lua_rawset(L, 1); + return 1; +} + +LJLIB_CF(rawequal) LJLIB_REC(.) +{ + cTValue *o1 = lj_lib_checkany(L, 1); + cTValue *o2 = lj_lib_checkany(L, 2); + setboolV(L->top-1, lj_obj_equal(o1, o2)); + return 1; +} + +#if LJ_52 +LJLIB_CF(rawlen) LJLIB_REC(.) +{ + cTValue *o = L->base; + int32_t len; + if (L->top > o && tvisstr(o)) + len = (int32_t)strV(o)->len; + else + len = (int32_t)lj_tab_len(lj_lib_checktab(L, 1)); + setintV(L->top-1, len); + return 1; +} +#endif + +LJLIB_CF(unpack) +{ + GCtab *t = lj_lib_checktab(L, 1); + int32_t n, i = lj_lib_optint(L, 2, 1); + int32_t e = (L->base+3-1 < L->top && !tvisnil(L->base+3-1)) ? + lj_lib_checkint(L, 3) : (int32_t)lj_tab_len(t); + if (i > e) return 0; + n = e - i + 1; + if (n <= 0 || !lua_checkstack(L, n)) + lj_err_caller(L, LJ_ERR_UNPACK); + do { + cTValue *tv = lj_tab_getint(t, i); + if (tv) { + copyTV(L, L->top++, tv); + } else { + setnilV(L->top++); + } + } while (i++ < e); + return n; +} + +LJLIB_CF(select) LJLIB_REC(.) +{ + int32_t n = (int32_t)(L->top - L->base); + if (n >= 1 && tvisstr(L->base) && *strVdata(L->base) == '#') { + setintV(L->top-1, n-1); + return 1; + } else { + int32_t i = lj_lib_checkint(L, 1); + if (i < 0) i = n + i; else if (i > n) i = n; + if (i < 1) + lj_err_arg(L, 1, LJ_ERR_IDXRNG); + return n - i; + } +} + +/* -- Base library: conversions ------------------------------------------- */ + +LJLIB_ASM(tonumber) LJLIB_REC(.) +{ + int32_t base = lj_lib_optint(L, 2, 10); + if (base == 10) { + TValue *o = lj_lib_checkany(L, 1); + if (lj_strscan_numberobj(o)) { + copyTV(L, L->base-1, o); + return FFH_RES(1); + } +#if LJ_HASFFI + if (tviscdata(o)) { + CTState *cts = ctype_cts(L); + CType *ct = lj_ctype_rawref(cts, cdataV(o)->ctypeid); + if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); + if (ctype_isnum(ct->info) || ctype_iscomplex(ct->info)) { + if (LJ_DUALNUM && ctype_isinteger_or_bool(ct->info) && + ct->size <= 4 && !(ct->size == 4 && (ct->info & CTF_UNSIGNED))) { + int32_t i; + lj_cconv_ct_tv(cts, ctype_get(cts, CTID_INT32), (uint8_t *)&i, o, 0); + setintV(L->base-1, i); + return FFH_RES(1); + } + lj_cconv_ct_tv(cts, ctype_get(cts, CTID_DOUBLE), + (uint8_t *)&(L->base-1)->n, o, 0); + return FFH_RES(1); + } + } +#endif + } else { + const char *p = strdata(lj_lib_checkstr(L, 1)); + char *ep; + unsigned long ul; + if (base < 2 || base > 36) + lj_err_arg(L, 2, LJ_ERR_BASERNG); + ul = strtoul(p, &ep, base); + if (p != ep) { + while (lj_char_isspace((unsigned char)(*ep))) ep++; + if (*ep == '\0') { + if (LJ_DUALNUM && LJ_LIKELY(ul < 0x80000000u)) + setintV(L->base-1, (int32_t)ul); + else + setnumV(L->base-1, (lua_Number)ul); + return FFH_RES(1); + } + } + } + setnilV(L->base-1); + return FFH_RES(1); +} + +LJLIB_PUSH("nil") +LJLIB_PUSH("false") +LJLIB_PUSH("true") +LJLIB_ASM(tostring) LJLIB_REC(.) +{ + TValue *o = lj_lib_checkany(L, 1); + cTValue *mo; + L->top = o+1; /* Only keep one argument. */ + if (!tvisnil(mo = lj_meta_lookup(L, o, MM_tostring))) { + copyTV(L, L->base-1, mo); /* Replace callable. */ + return FFH_TAILCALL; + } else { + GCstr *s; + if (tvisnumber(o)) { + s = lj_str_fromnumber(L, o); + } else if (tvispri(o)) { + s = strV(lj_lib_upvalue(L, -(int32_t)itype(o))); + } else { + if (tvisfunc(o) && isffunc(funcV(o))) + lua_pushfstring(L, "function: builtin#%d", funcV(o)->c.ffid); + else + lua_pushfstring(L, "%s: %p", lj_typename(o), lua_topointer(L, 1)); + /* Note: lua_pushfstring calls the GC which may invalidate o. */ + s = strV(L->top-1); + } + setstrV(L, L->base-1, s); + return FFH_RES(1); + } +} + +/* -- Base library: throw and catch errors -------------------------------- */ + +LJLIB_CF(error) +{ + int32_t level = lj_lib_optint(L, 2, 1); + lua_settop(L, 1); + if (lua_isstring(L, 1) && level > 0) { + luaL_where(L, level); + lua_pushvalue(L, 1); + lua_concat(L, 2); + } + return lua_error(L); +} + +LJLIB_ASM(pcall) LJLIB_REC(.) +{ + lj_lib_checkany(L, 1); + lj_lib_checkfunc(L, 2); /* For xpcall only. */ + return FFH_UNREACHABLE; +} +LJLIB_ASM_(xpcall) LJLIB_REC(.) + +/* -- Base library: load Lua code ----------------------------------------- */ + +static int load_aux(lua_State *L, int status, int envarg) +{ + if (status == 0) { + if (tvistab(L->base+envarg-1)) { + GCfunc *fn = funcV(L->top-1); + GCtab *t = tabV(L->base+envarg-1); + setgcref(fn->c.env, obj2gco(t)); + lj_gc_objbarrier(L, fn, t); + } + return 1; + } else { + setnilV(L->top-2); + return 2; + } +} + +LJLIB_CF(loadfile) +{ + GCstr *fname = lj_lib_optstr(L, 1); + GCstr *mode = lj_lib_optstr(L, 2); + int status; + lua_settop(L, 3); /* Ensure env arg exists. */ + status = luaL_loadfilex(L, fname ? strdata(fname) : NULL, + mode ? strdata(mode) : NULL); + return load_aux(L, status, 3); +} + +static const char *reader_func(lua_State *L, void *ud, size_t *size) +{ + UNUSED(ud); + luaL_checkstack(L, 2, "too many nested functions"); + copyTV(L, L->top++, L->base); + lua_call(L, 0, 1); /* Call user-supplied function. */ + L->top--; + if (tvisnil(L->top)) { + *size = 0; + return NULL; + } else if (tvisstr(L->top) || tvisnumber(L->top)) { + copyTV(L, L->base+4, L->top); /* Anchor string in reserved stack slot. */ + return lua_tolstring(L, 5, size); + } else { + lj_err_caller(L, LJ_ERR_RDRSTR); + return NULL; + } +} + +LJLIB_CF(load) +{ + GCstr *name = lj_lib_optstr(L, 2); + GCstr *mode = lj_lib_optstr(L, 3); + int status; + if (L->base < L->top && (tvisstr(L->base) || tvisnumber(L->base))) { + GCstr *s = lj_lib_checkstr(L, 1); + lua_settop(L, 4); /* Ensure env arg exists. */ + status = luaL_loadbufferx(L, strdata(s), s->len, strdata(name ? name : s), + mode ? strdata(mode) : NULL); + } else { + lj_lib_checkfunc(L, 1); + lua_settop(L, 5); /* Reserve a slot for the string from the reader. */ + status = lua_loadx(L, reader_func, NULL, name ? strdata(name) : "=(load)", + mode ? strdata(mode) : NULL); + } + return load_aux(L, status, 4); +} + +LJLIB_CF(loadstring) +{ + return lj_cf_load(L); +} + +LJLIB_CF(dofile) +{ + GCstr *fname = lj_lib_optstr(L, 1); + setnilV(L->top); + L->top = L->base+1; + if (luaL_loadfile(L, fname ? strdata(fname) : NULL) != 0) + lua_error(L); + lua_call(L, 0, LUA_MULTRET); + return (int)(L->top - L->base) - 1; +} + +/* -- Base library: GC control -------------------------------------------- */ + +LJLIB_CF(gcinfo) +{ + setintV(L->top++, (G(L)->gc.total >> 10)); + return 1; +} + +LJLIB_CF(collectgarbage) +{ + int opt = lj_lib_checkopt(L, 1, LUA_GCCOLLECT, /* ORDER LUA_GC* */ + "\4stop\7restart\7collect\5count\1\377\4step\10setpause\12setstepmul"); + int32_t data = lj_lib_optint(L, 2, 0); + if (opt == LUA_GCCOUNT) { + setnumV(L->top, (lua_Number)G(L)->gc.total/1024.0); + } else { + int res = lua_gc(L, opt, data); + if (opt == LUA_GCSTEP) + setboolV(L->top, res); + else + setintV(L->top, res); + } + L->top++; + return 1; +} + +/* -- Base library: miscellaneous functions ------------------------------- */ + +LJLIB_PUSH(top-2) /* Upvalue holds weak table. */ +LJLIB_CF(newproxy) +{ + lua_settop(L, 1); + lua_newuserdata(L, 0); + if (lua_toboolean(L, 1) == 0) { /* newproxy(): without metatable. */ + return 1; + } else if (lua_isboolean(L, 1)) { /* newproxy(true): with metatable. */ + lua_newtable(L); + lua_pushvalue(L, -1); + lua_pushboolean(L, 1); + lua_rawset(L, lua_upvalueindex(1)); /* Remember mt in weak table. */ + } else { /* newproxy(proxy): inherit metatable. */ + int validproxy = 0; + if (lua_getmetatable(L, 1)) { + lua_rawget(L, lua_upvalueindex(1)); + validproxy = lua_toboolean(L, -1); + lua_pop(L, 1); + } + if (!validproxy) + lj_err_arg(L, 1, LJ_ERR_NOPROXY); + lua_getmetatable(L, 1); + } + lua_setmetatable(L, 2); + return 1; +} + +LJLIB_PUSH("tostring") +LJLIB_CF(print) +{ + ptrdiff_t i, nargs = L->top - L->base; + cTValue *tv = lj_tab_getstr(tabref(L->env), strV(lj_lib_upvalue(L, 1))); + int shortcut; + if (tv && !tvisnil(tv)) { + copyTV(L, L->top++, tv); + } else { + setstrV(L, L->top++, strV(lj_lib_upvalue(L, 1))); + lua_gettable(L, LUA_GLOBALSINDEX); + tv = L->top-1; + } + shortcut = (tvisfunc(tv) && funcV(tv)->c.ffid == FF_tostring); + for (i = 0; i < nargs; i++) { + const char *str; + size_t size; + cTValue *o = &L->base[i]; + if (shortcut && tvisstr(o)) { + str = strVdata(o); + size = strV(o)->len; + } else if (shortcut && tvisint(o)) { + char buf[LJ_STR_INTBUF]; + char *p = lj_str_bufint(buf, intV(o)); + size = (size_t)(buf+LJ_STR_INTBUF-p); + str = p; + } else if (shortcut && tvisnum(o)) { + char buf[LJ_STR_NUMBUF]; + size = lj_str_bufnum(buf, o); + str = buf; + } else { + copyTV(L, L->top+1, o); + copyTV(L, L->top, L->top-1); + L->top += 2; + lua_call(L, 1, 1); + str = lua_tolstring(L, -1, &size); + if (!str) + lj_err_caller(L, LJ_ERR_PRTOSTR); + L->top--; + } + if (i) + putchar('\t'); + fwrite(str, 1, size, stdout); + } + putchar('\n'); + return 0; +} + +LJLIB_PUSH(top-3) +LJLIB_SET(_VERSION) + +#include "lj_libdef.h" + +/* -- Coroutine library --------------------------------------------------- */ + +#define LJLIB_MODULE_coroutine + +LJLIB_CF(coroutine_status) +{ + const char *s; + lua_State *co; + if (!(L->top > L->base && tvisthread(L->base))) + lj_err_arg(L, 1, LJ_ERR_NOCORO); + co = threadV(L->base); + if (co == L) s = "running"; + else if (co->status == LUA_YIELD) s = "suspended"; + else if (co->status != 0) s = "dead"; + else if (co->base > tvref(co->stack)+1) s = "normal"; + else if (co->top == co->base) s = "dead"; + else s = "suspended"; + lua_pushstring(L, s); + return 1; +} + +LJLIB_CF(coroutine_running) +{ +#if LJ_52 + int ismain = lua_pushthread(L); + setboolV(L->top++, ismain); + return 2; +#else + if (lua_pushthread(L)) + setnilV(L->top++); + return 1; +#endif +} + +LJLIB_CF(coroutine_create) +{ + lua_State *L1; + if (!(L->base < L->top && tvisfunc(L->base))) + lj_err_argt(L, 1, LUA_TFUNCTION); + L1 = lua_newthread(L); + setfuncV(L, L1->top++, funcV(L->base)); + return 1; +} + +LJLIB_ASM(coroutine_yield) +{ + lj_err_caller(L, LJ_ERR_CYIELD); + return FFH_UNREACHABLE; +} + +static int ffh_resume(lua_State *L, lua_State *co, int wrap) +{ + if (co->cframe != NULL || co->status > LUA_YIELD || + (co->status == 0 && co->top == co->base)) { + ErrMsg em = co->cframe ? LJ_ERR_CORUN : LJ_ERR_CODEAD; + if (wrap) lj_err_caller(L, em); + setboolV(L->base-1, 0); + setstrV(L, L->base, lj_err_str(L, em)); + return FFH_RES(2); + } + lj_state_growstack(co, (MSize)(L->top - L->base)); + return FFH_RETRY; +} + +LJLIB_ASM(coroutine_resume) +{ + if (!(L->top > L->base && tvisthread(L->base))) + lj_err_arg(L, 1, LJ_ERR_NOCORO); + return ffh_resume(L, threadV(L->base), 0); +} + +LJLIB_NOREG LJLIB_ASM(coroutine_wrap_aux) +{ + return ffh_resume(L, threadV(lj_lib_upvalue(L, 1)), 1); +} + +/* Inline declarations. */ +LJ_ASMF void lj_ff_coroutine_wrap_aux(void); +#if !(LJ_TARGET_MIPS && defined(ljamalg_c)) +LJ_FUNCA_NORET void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L, + lua_State *co); +#endif + +/* Error handler, called from assembler VM. */ +void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L, lua_State *co) +{ + co->top--; copyTV(L, L->top, co->top); L->top++; + if (tvisstr(L->top-1)) + lj_err_callermsg(L, strVdata(L->top-1)); + else + lj_err_run(L); +} + +/* Forward declaration. */ +static void setpc_wrap_aux(lua_State *L, GCfunc *fn); + +LJLIB_CF(coroutine_wrap) +{ + lj_cf_coroutine_create(L); + lj_lib_pushcc(L, lj_ffh_coroutine_wrap_aux, FF_coroutine_wrap_aux, 1); + setpc_wrap_aux(L, funcV(L->top-1)); + return 1; +} + +#include "lj_libdef.h" + +/* Fix the PC of wrap_aux. Really ugly workaround. */ +static void setpc_wrap_aux(lua_State *L, GCfunc *fn) +{ + setmref(fn->c.pc, &L2GG(L)->bcff[lj_lib_init_coroutine[1]+2]); +} + +/* ------------------------------------------------------------------------ */ + +static void newproxy_weaktable(lua_State *L) +{ + /* NOBARRIER: The table is new (marked white). */ + GCtab *t = lj_tab_new(L, 0, 1); + settabV(L, L->top++, t); + setgcref(t->metatable, obj2gco(t)); + setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "__mode")), + lj_str_newlit(L, "kv")); + t->nomm = (uint8_t)(~(1u<env); + settabV(L, lj_tab_setstr(L, env, lj_str_newlit(L, "_G")), env); + lua_pushliteral(L, LUA_VERSION); /* top-3. */ + newproxy_weaktable(L); /* top-2. */ + LJ_LIB_REG(L, "_G", base); + LJ_LIB_REG(L, LUA_COLIBNAME, coroutine); + return 2; +} + + +``` + +`include/luajit-2.0.5/src/lib_bit.c`: + +```c +/* +** Bit manipulation library. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lib_bit_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_lib.h" + +/* ------------------------------------------------------------------------ */ + +#define LJLIB_MODULE_bit + +LJLIB_ASM(bit_tobit) LJLIB_REC(bit_unary IR_TOBIT) +{ + lj_lib_checknumber(L, 1); + return FFH_RETRY; +} +LJLIB_ASM_(bit_bnot) LJLIB_REC(bit_unary IR_BNOT) +LJLIB_ASM_(bit_bswap) LJLIB_REC(bit_unary IR_BSWAP) + +LJLIB_ASM(bit_lshift) LJLIB_REC(bit_shift IR_BSHL) +{ + lj_lib_checknumber(L, 1); + lj_lib_checkbit(L, 2); + return FFH_RETRY; +} +LJLIB_ASM_(bit_rshift) LJLIB_REC(bit_shift IR_BSHR) +LJLIB_ASM_(bit_arshift) LJLIB_REC(bit_shift IR_BSAR) +LJLIB_ASM_(bit_rol) LJLIB_REC(bit_shift IR_BROL) +LJLIB_ASM_(bit_ror) LJLIB_REC(bit_shift IR_BROR) + +LJLIB_ASM(bit_band) LJLIB_REC(bit_nary IR_BAND) +{ + int i = 0; + do { lj_lib_checknumber(L, ++i); } while (L->base+i < L->top); + return FFH_RETRY; +} +LJLIB_ASM_(bit_bor) LJLIB_REC(bit_nary IR_BOR) +LJLIB_ASM_(bit_bxor) LJLIB_REC(bit_nary IR_BXOR) + +/* ------------------------------------------------------------------------ */ + +LJLIB_CF(bit_tohex) +{ + uint32_t b = (uint32_t)lj_lib_checkbit(L, 1); + int32_t i, n = L->base+1 >= L->top ? 8 : lj_lib_checkbit(L, 2); + const char *hexdigits = "0123456789abcdef"; + char buf[8]; + if (n < 0) { n = -n; hexdigits = "0123456789ABCDEF"; } + if (n > 8) n = 8; + for (i = n; --i >= 0; ) { buf[i] = hexdigits[b & 15]; b >>= 4; } + lua_pushlstring(L, buf, (size_t)n); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +#include "lj_libdef.h" + +LUALIB_API int luaopen_bit(lua_State *L) +{ + LJ_LIB_REG(L, LUA_BITLIBNAME, bit); + return 1; +} + + +``` + +`include/luajit-2.0.5/src/lib_debug.c`: + +```c +/* +** Debug library. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lib_debug_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_lib.h" + +/* ------------------------------------------------------------------------ */ + +#define LJLIB_MODULE_debug + +LJLIB_CF(debug_getregistry) +{ + copyTV(L, L->top++, registry(L)); + return 1; +} + +LJLIB_CF(debug_getmetatable) +{ + lj_lib_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + setnilV(L->top-1); + } + return 1; +} + +LJLIB_CF(debug_setmetatable) +{ + lj_lib_checktabornil(L, 2); + L->top = L->base+2; + lua_setmetatable(L, 1); +#if !LJ_52 + setboolV(L->top-1, 1); +#endif + return 1; +} + +LJLIB_CF(debug_getfenv) +{ + lj_lib_checkany(L, 1); + lua_getfenv(L, 1); + return 1; +} + +LJLIB_CF(debug_setfenv) +{ + lj_lib_checktab(L, 2); + L->top = L->base+2; + if (!lua_setfenv(L, 1)) + lj_err_caller(L, LJ_ERR_SETFENV); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +static void settabss(lua_State *L, const char *i, const char *v) +{ + lua_pushstring(L, v); + lua_setfield(L, -2, i); +} + +static void settabsi(lua_State *L, const char *i, int v) +{ + lua_pushinteger(L, v); + lua_setfield(L, -2, i); +} + +static void settabsb(lua_State *L, const char *i, int v) +{ + lua_pushboolean(L, v); + lua_setfield(L, -2, i); +} + +static lua_State *getthread(lua_State *L, int *arg) +{ + if (L->base < L->top && tvisthread(L->base)) { + *arg = 1; + return threadV(L->base); + } else { + *arg = 0; + return L; + } +} + +static void treatstackoption(lua_State *L, lua_State *L1, const char *fname) +{ + if (L == L1) { + lua_pushvalue(L, -2); + lua_remove(L, -3); + } + else + lua_xmove(L1, L, 1); + lua_setfield(L, -2, fname); +} + +LJLIB_CF(debug_getinfo) +{ + lj_Debug ar; + int arg, opt_f = 0, opt_L = 0; + lua_State *L1 = getthread(L, &arg); + const char *options = luaL_optstring(L, arg+2, "flnSu"); + if (lua_isnumber(L, arg+1)) { + if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), (lua_Debug *)&ar)) { + setnilV(L->top-1); + return 1; + } + } else if (L->base+arg < L->top && tvisfunc(L->base+arg)) { + options = lua_pushfstring(L, ">%s", options); + setfuncV(L1, L1->top++, funcV(L->base+arg)); + } else { + lj_err_arg(L, arg+1, LJ_ERR_NOFUNCL); + } + if (!lj_debug_getinfo(L1, options, &ar, 1)) + lj_err_arg(L, arg+2, LJ_ERR_INVOPT); + lua_createtable(L, 0, 16); /* Create result table. */ + for (; *options; options++) { + switch (*options) { + case 'S': + settabss(L, "source", ar.source); + settabss(L, "short_src", ar.short_src); + settabsi(L, "linedefined", ar.linedefined); + settabsi(L, "lastlinedefined", ar.lastlinedefined); + settabss(L, "what", ar.what); + break; + case 'l': + settabsi(L, "currentline", ar.currentline); + break; + case 'u': + settabsi(L, "nups", ar.nups); + settabsi(L, "nparams", ar.nparams); + settabsb(L, "isvararg", ar.isvararg); + break; + case 'n': + settabss(L, "name", ar.name); + settabss(L, "namewhat", ar.namewhat); + break; + case 'f': opt_f = 1; break; + case 'L': opt_L = 1; break; + default: break; + } + } + if (opt_L) treatstackoption(L, L1, "activelines"); + if (opt_f) treatstackoption(L, L1, "func"); + return 1; /* Return result table. */ +} + +LJLIB_CF(debug_getlocal) +{ + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + const char *name; + int slot = lj_lib_checkint(L, arg+2); + if (tvisfunc(L->base+arg)) { + L->top = L->base+arg+1; + lua_pushstring(L, lua_getlocal(L, NULL, slot)); + return 1; + } + if (!lua_getstack(L1, lj_lib_checkint(L, arg+1), &ar)) + lj_err_arg(L, arg+1, LJ_ERR_LVLRNG); + name = lua_getlocal(L1, &ar, slot); + if (name) { + lua_xmove(L1, L, 1); + lua_pushstring(L, name); + lua_pushvalue(L, -2); + return 2; + } else { + setnilV(L->top-1); + return 1; + } +} + +LJLIB_CF(debug_setlocal) +{ + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + TValue *tv; + if (!lua_getstack(L1, lj_lib_checkint(L, arg+1), &ar)) + lj_err_arg(L, arg+1, LJ_ERR_LVLRNG); + tv = lj_lib_checkany(L, arg+3); + copyTV(L1, L1->top++, tv); + lua_pushstring(L, lua_setlocal(L1, &ar, lj_lib_checkint(L, arg+2))); + return 1; +} + +static int debug_getupvalue(lua_State *L, int get) +{ + int32_t n = lj_lib_checkint(L, 2); + const char *name; + lj_lib_checkfunc(L, 1); + name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); + if (name) { + lua_pushstring(L, name); + if (!get) return 1; + copyTV(L, L->top, L->top-2); + L->top++; + return 2; + } + return 0; +} + +LJLIB_CF(debug_getupvalue) +{ + return debug_getupvalue(L, 1); +} + +LJLIB_CF(debug_setupvalue) +{ + lj_lib_checkany(L, 3); + return debug_getupvalue(L, 0); +} + +LJLIB_CF(debug_upvalueid) +{ + GCfunc *fn = lj_lib_checkfunc(L, 1); + int32_t n = lj_lib_checkint(L, 2) - 1; + if ((uint32_t)n >= fn->l.nupvalues) + lj_err_arg(L, 2, LJ_ERR_IDXRNG); + setlightudV(L->top-1, isluafunc(fn) ? (void *)gcref(fn->l.uvptr[n]) : + (void *)&fn->c.upvalue[n]); + return 1; +} + +LJLIB_CF(debug_upvaluejoin) +{ + GCfunc *fn[2]; + GCRef *p[2]; + int i; + for (i = 0; i < 2; i++) { + int32_t n; + fn[i] = lj_lib_checkfunc(L, 2*i+1); + if (!isluafunc(fn[i])) + lj_err_arg(L, 2*i+1, LJ_ERR_NOLFUNC); + n = lj_lib_checkint(L, 2*i+2) - 1; + if ((uint32_t)n >= fn[i]->l.nupvalues) + lj_err_arg(L, 2*i+2, LJ_ERR_IDXRNG); + p[i] = &fn[i]->l.uvptr[n]; + } + setgcrefr(*p[0], *p[1]); + lj_gc_objbarrier(L, fn[0], gcref(*p[1])); + return 0; +} + +#if LJ_52 +LJLIB_CF(debug_getuservalue) +{ + TValue *o = L->base; + if (o < L->top && tvisudata(o)) + settabV(L, o, tabref(udataV(o)->env)); + else + setnilV(o); + L->top = o+1; + return 1; +} + +LJLIB_CF(debug_setuservalue) +{ + TValue *o = L->base; + if (!(o < L->top && tvisudata(o))) + lj_err_argt(L, 1, LUA_TUSERDATA); + if (!(o+1 < L->top && tvistab(o+1))) + lj_err_argt(L, 2, LUA_TTABLE); + L->top = o+2; + lua_setfenv(L, 1); + return 1; +} +#endif + +/* ------------------------------------------------------------------------ */ + +static const char KEY_HOOK = 'h'; + +static void hookf(lua_State *L, lua_Debug *ar) +{ + static const char *const hooknames[] = + {"call", "return", "line", "count", "tail return"}; + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_isfunction(L, -1)) { + lua_pushstring(L, hooknames[(int)ar->event]); + if (ar->currentline >= 0) + lua_pushinteger(L, ar->currentline); + else lua_pushnil(L); + lua_call(L, 2, 0); + } +} + +static int makemask(const char *smask, int count) +{ + int mask = 0; + if (strchr(smask, 'c')) mask |= LUA_MASKCALL; + if (strchr(smask, 'r')) mask |= LUA_MASKRET; + if (strchr(smask, 'l')) mask |= LUA_MASKLINE; + if (count > 0) mask |= LUA_MASKCOUNT; + return mask; +} + +static char *unmakemask(int mask, char *smask) +{ + int i = 0; + if (mask & LUA_MASKCALL) smask[i++] = 'c'; + if (mask & LUA_MASKRET) smask[i++] = 'r'; + if (mask & LUA_MASKLINE) smask[i++] = 'l'; + smask[i] = '\0'; + return smask; +} + +LJLIB_CF(debug_sethook) +{ + int arg, mask, count; + lua_Hook func; + (void)getthread(L, &arg); + if (lua_isnoneornil(L, arg+1)) { + lua_settop(L, arg+1); + func = NULL; mask = 0; count = 0; /* turn off hooks */ + } else { + const char *smask = luaL_checkstring(L, arg+2); + luaL_checktype(L, arg+1, LUA_TFUNCTION); + count = luaL_optint(L, arg+3, 0); + func = hookf; mask = makemask(smask, count); + } + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_pushvalue(L, arg+1); + lua_rawset(L, LUA_REGISTRYINDEX); + lua_sethook(L, func, mask, count); + return 0; +} + +LJLIB_CF(debug_gethook) +{ + char buff[5]; + int mask = lua_gethookmask(L); + lua_Hook hook = lua_gethook(L); + if (hook != NULL && hook != hookf) { /* external hook? */ + lua_pushliteral(L, "external hook"); + } else { + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */ + } + lua_pushstring(L, unmakemask(mask, buff)); + lua_pushinteger(L, lua_gethookcount(L)); + return 3; +} + +/* ------------------------------------------------------------------------ */ + +LJLIB_CF(debug_debug) +{ + for (;;) { + char buffer[250]; + fputs("lua_debug> ", stderr); + if (fgets(buffer, sizeof(buffer), stdin) == 0 || + strcmp(buffer, "cont\n") == 0) + return 0; + if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || + lua_pcall(L, 0, 0, 0)) { + fputs(lua_tostring(L, -1), stderr); + fputs("\n", stderr); + } + lua_settop(L, 0); /* remove eventual returns */ + } +} + +/* ------------------------------------------------------------------------ */ + +#define LEVELS1 12 /* size of the first part of the stack */ +#define LEVELS2 10 /* size of the second part of the stack */ + +LJLIB_CF(debug_traceback) +{ + int arg; + lua_State *L1 = getthread(L, &arg); + const char *msg = lua_tostring(L, arg+1); + if (msg == NULL && L->top > L->base+arg) + L->top = L->base+arg+1; + else + luaL_traceback(L, L1, msg, lj_lib_optint(L, arg+2, (L == L1))); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +#include "lj_libdef.h" + +LUALIB_API int luaopen_debug(lua_State *L) +{ + LJ_LIB_REG(L, LUA_DBLIBNAME, debug); + return 1; +} + + +``` + +`include/luajit-2.0.5/src/lib_ffi.c`: + +```c +/* +** FFI library. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lib_ffi_c +#define LUA_LIB + +#include + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_meta.h" +#include "lj_ctype.h" +#include "lj_cparse.h" +#include "lj_cdata.h" +#include "lj_cconv.h" +#include "lj_carith.h" +#include "lj_ccall.h" +#include "lj_ccallback.h" +#include "lj_clib.h" +#include "lj_ff.h" +#include "lj_lib.h" + +/* -- C type checks ------------------------------------------------------- */ + +/* Check first argument for a C type and returns its ID. */ +static CTypeID ffi_checkctype(lua_State *L, CTState *cts, TValue *param) +{ + TValue *o = L->base; + if (!(o < L->top)) { + err_argtype: + lj_err_argtype(L, 1, "C type"); + } + if (tvisstr(o)) { /* Parse an abstract C type declaration. */ + GCstr *s = strV(o); + CPState cp; + int errcode; + cp.L = L; + cp.cts = cts; + cp.srcname = strdata(s); + cp.p = strdata(s); + cp.param = param; + cp.mode = CPARSE_MODE_ABSTRACT|CPARSE_MODE_NOIMPLICIT; + errcode = lj_cparse(&cp); + if (errcode) lj_err_throw(L, errcode); /* Propagate errors. */ + return cp.val.id; + } else { + GCcdata *cd; + if (!tviscdata(o)) goto err_argtype; + if (param && param < L->top) lj_err_arg(L, 1, LJ_ERR_FFI_NUMPARAM); + cd = cdataV(o); + return cd->ctypeid == CTID_CTYPEID ? *(CTypeID *)cdataptr(cd) : cd->ctypeid; + } +} + +/* Check argument for C data and return it. */ +static GCcdata *ffi_checkcdata(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (!(o < L->top && tviscdata(o))) + lj_err_argt(L, narg, LUA_TCDATA); + return cdataV(o); +} + +/* Convert argument to C pointer. */ +static void *ffi_checkptr(lua_State *L, int narg, CTypeID id) +{ + CTState *cts = ctype_cts(L); + TValue *o = L->base + narg-1; + void *p; + if (o >= L->top) + lj_err_arg(L, narg, LJ_ERR_NOVAL); + lj_cconv_ct_tv(cts, ctype_get(cts, id), (uint8_t *)&p, o, CCF_ARG(narg)); + return p; +} + +/* Convert argument to int32_t. */ +static int32_t ffi_checkint(lua_State *L, int narg) +{ + CTState *cts = ctype_cts(L); + TValue *o = L->base + narg-1; + int32_t i; + if (o >= L->top) + lj_err_arg(L, narg, LJ_ERR_NOVAL); + lj_cconv_ct_tv(cts, ctype_get(cts, CTID_INT32), (uint8_t *)&i, o, + CCF_ARG(narg)); + return i; +} + +/* -- C type metamethods -------------------------------------------------- */ + +#define LJLIB_MODULE_ffi_meta + +/* Handle ctype __index/__newindex metamethods. */ +static int ffi_index_meta(lua_State *L, CTState *cts, CType *ct, MMS mm) +{ + CTypeID id = ctype_typeid(cts, ct); + cTValue *tv = lj_ctype_meta(cts, id, mm); + TValue *base = L->base; + if (!tv) { + const char *s; + err_index: + s = strdata(lj_ctype_repr(L, id, NULL)); + if (tvisstr(L->base+1)) { + lj_err_callerv(L, LJ_ERR_FFI_BADMEMBER, s, strVdata(L->base+1)); + } else { + const char *key = tviscdata(L->base+1) ? + strdata(lj_ctype_repr(L, cdataV(L->base+1)->ctypeid, NULL)) : + lj_typename(L->base+1); + lj_err_callerv(L, LJ_ERR_FFI_BADIDXW, s, key); + } + } + if (!tvisfunc(tv)) { + if (mm == MM_index) { + cTValue *o = lj_meta_tget(L, tv, base+1); + if (o) { + if (tvisnil(o)) goto err_index; + copyTV(L, L->top-1, o); + return 1; + } + } else { + TValue *o = lj_meta_tset(L, tv, base+1); + if (o) { + copyTV(L, o, base+2); + return 0; + } + } + copyTV(L, base, L->top); + tv = L->top-1; + } + return lj_meta_tailcall(L, tv); +} + +LJLIB_CF(ffi_meta___index) LJLIB_REC(cdata_index 0) +{ + CTState *cts = ctype_cts(L); + CTInfo qual = 0; + CType *ct; + uint8_t *p; + TValue *o = L->base; + if (!(o+1 < L->top && tviscdata(o))) /* Also checks for presence of key. */ + lj_err_argt(L, 1, LUA_TCDATA); + ct = lj_cdata_index(cts, cdataV(o), o+1, &p, &qual); + if ((qual & 1)) + return ffi_index_meta(L, cts, ct, MM_index); + if (lj_cdata_get(cts, ct, L->top-1, p)) + lj_gc_check(L); + return 1; +} + +LJLIB_CF(ffi_meta___newindex) LJLIB_REC(cdata_index 1) +{ + CTState *cts = ctype_cts(L); + CTInfo qual = 0; + CType *ct; + uint8_t *p; + TValue *o = L->base; + if (!(o+2 < L->top && tviscdata(o))) /* Also checks for key and value. */ + lj_err_argt(L, 1, LUA_TCDATA); + ct = lj_cdata_index(cts, cdataV(o), o+1, &p, &qual); + if ((qual & 1)) { + if ((qual & CTF_CONST)) + lj_err_caller(L, LJ_ERR_FFI_WRCONST); + return ffi_index_meta(L, cts, ct, MM_newindex); + } + lj_cdata_set(cts, ct, p, o+2, qual); + return 0; +} + +/* Common handler for cdata arithmetic. */ +static int ffi_arith(lua_State *L) +{ + MMS mm = (MMS)(curr_func(L)->c.ffid - (int)FF_ffi_meta___eq + (int)MM_eq); + return lj_carith_op(L, mm); +} + +/* The following functions must be in contiguous ORDER MM. */ +LJLIB_CF(ffi_meta___eq) LJLIB_REC(cdata_arith MM_eq) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___len) LJLIB_REC(cdata_arith MM_len) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___lt) LJLIB_REC(cdata_arith MM_lt) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___le) LJLIB_REC(cdata_arith MM_le) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___concat) LJLIB_REC(cdata_arith MM_concat) +{ + return ffi_arith(L); +} + +/* Forward declaration. */ +static int lj_cf_ffi_new(lua_State *L); + +LJLIB_CF(ffi_meta___call) LJLIB_REC(cdata_call) +{ + CTState *cts = ctype_cts(L); + GCcdata *cd = ffi_checkcdata(L, 1); + CTypeID id = cd->ctypeid; + CType *ct; + cTValue *tv; + MMS mm = MM_call; + if (cd->ctypeid == CTID_CTYPEID) { + id = *(CTypeID *)cdataptr(cd); + mm = MM_new; + } else { + int ret = lj_ccall_func(L, cd); + if (ret >= 0) + return ret; + } + /* Handle ctype __call/__new metamethod. */ + ct = ctype_raw(cts, id); + if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); + tv = lj_ctype_meta(cts, id, mm); + if (tv) + return lj_meta_tailcall(L, tv); + else if (mm == MM_call) + lj_err_callerv(L, LJ_ERR_FFI_BADCALL, strdata(lj_ctype_repr(L, id, NULL))); + return lj_cf_ffi_new(L); +} + +LJLIB_CF(ffi_meta___add) LJLIB_REC(cdata_arith MM_add) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___sub) LJLIB_REC(cdata_arith MM_sub) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___mul) LJLIB_REC(cdata_arith MM_mul) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___div) LJLIB_REC(cdata_arith MM_div) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___mod) LJLIB_REC(cdata_arith MM_mod) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___pow) LJLIB_REC(cdata_arith MM_pow) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___unm) LJLIB_REC(cdata_arith MM_unm) +{ + return ffi_arith(L); +} +/* End of contiguous ORDER MM. */ + +LJLIB_CF(ffi_meta___tostring) +{ + GCcdata *cd = ffi_checkcdata(L, 1); + const char *msg = "cdata<%s>: %p"; + CTypeID id = cd->ctypeid; + void *p = cdataptr(cd); + if (id == CTID_CTYPEID) { + msg = "ctype<%s>"; + id = *(CTypeID *)p; + } else { + CTState *cts = ctype_cts(L); + CType *ct = ctype_raw(cts, id); + if (ctype_isref(ct->info)) { + p = *(void **)p; + ct = ctype_rawchild(cts, ct); + } + if (ctype_iscomplex(ct->info)) { + setstrV(L, L->top-1, lj_ctype_repr_complex(L, cdataptr(cd), ct->size)); + goto checkgc; + } else if (ct->size == 8 && ctype_isinteger(ct->info)) { + setstrV(L, L->top-1, lj_ctype_repr_int64(L, *(uint64_t *)cdataptr(cd), + (ct->info & CTF_UNSIGNED))); + goto checkgc; + } else if (ctype_isfunc(ct->info)) { + p = *(void **)p; + } else if (ctype_isenum(ct->info)) { + msg = "cdata<%s>: %d"; + p = (void *)(uintptr_t)*(uint32_t **)p; + } else { + if (ctype_isptr(ct->info)) { + p = cdata_getptr(p, ct->size); + ct = ctype_rawchild(cts, ct); + } + if (ctype_isstruct(ct->info) || ctype_isvector(ct->info)) { + /* Handle ctype __tostring metamethod. */ + cTValue *tv = lj_ctype_meta(cts, ctype_typeid(cts, ct), MM_tostring); + if (tv) + return lj_meta_tailcall(L, tv); + } + } + } + lj_str_pushf(L, msg, strdata(lj_ctype_repr(L, id, NULL)), p); +checkgc: + lj_gc_check(L); + return 1; +} + +static int ffi_pairs(lua_State *L, MMS mm) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkcdata(L, 1)->ctypeid; + CType *ct = ctype_raw(cts, id); + cTValue *tv; + if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); + tv = lj_ctype_meta(cts, id, mm); + if (!tv) + lj_err_callerv(L, LJ_ERR_FFI_BADMM, strdata(lj_ctype_repr(L, id, NULL)), + strdata(mmname_str(G(L), mm))); + return lj_meta_tailcall(L, tv); +} + +LJLIB_CF(ffi_meta___pairs) +{ + return ffi_pairs(L, MM_pairs); +} + +LJLIB_CF(ffi_meta___ipairs) +{ + return ffi_pairs(L, MM_ipairs); +} + +LJLIB_PUSH("ffi") LJLIB_SET(__metatable) + +#include "lj_libdef.h" + +/* -- C library metamethods ----------------------------------------------- */ + +#define LJLIB_MODULE_ffi_clib + +/* Index C library by a name. */ +static TValue *ffi_clib_index(lua_State *L) +{ + TValue *o = L->base; + CLibrary *cl; + if (!(o < L->top && tvisudata(o) && udataV(o)->udtype == UDTYPE_FFI_CLIB)) + lj_err_argt(L, 1, LUA_TUSERDATA); + cl = (CLibrary *)uddata(udataV(o)); + if (!(o+1 < L->top && tvisstr(o+1))) + lj_err_argt(L, 2, LUA_TSTRING); + return lj_clib_index(L, cl, strV(o+1)); +} + +LJLIB_CF(ffi_clib___index) LJLIB_REC(clib_index 1) +{ + TValue *tv = ffi_clib_index(L); + if (tviscdata(tv)) { + CTState *cts = ctype_cts(L); + GCcdata *cd = cdataV(tv); + CType *s = ctype_get(cts, cd->ctypeid); + if (ctype_isextern(s->info)) { + CTypeID sid = ctype_cid(s->info); + void *sp = *(void **)cdataptr(cd); + CType *ct = ctype_raw(cts, sid); + if (lj_cconv_tv_ct(cts, ct, sid, L->top-1, sp)) + lj_gc_check(L); + return 1; + } + } + copyTV(L, L->top-1, tv); + return 1; +} + +LJLIB_CF(ffi_clib___newindex) LJLIB_REC(clib_index 0) +{ + TValue *tv = ffi_clib_index(L); + TValue *o = L->base+2; + if (o < L->top && tviscdata(tv)) { + CTState *cts = ctype_cts(L); + GCcdata *cd = cdataV(tv); + CType *d = ctype_get(cts, cd->ctypeid); + if (ctype_isextern(d->info)) { + CTInfo qual = 0; + for (;;) { /* Skip attributes and collect qualifiers. */ + d = ctype_child(cts, d); + if (!ctype_isattrib(d->info)) break; + if (ctype_attrib(d->info) == CTA_QUAL) qual |= d->size; + } + if (!((d->info|qual) & CTF_CONST)) { + lj_cconv_ct_tv(cts, d, *(void **)cdataptr(cd), o, 0); + return 0; + } + } + } + lj_err_caller(L, LJ_ERR_FFI_WRCONST); + return 0; /* unreachable */ +} + +LJLIB_CF(ffi_clib___gc) +{ + TValue *o = L->base; + if (o < L->top && tvisudata(o) && udataV(o)->udtype == UDTYPE_FFI_CLIB) + lj_clib_unload((CLibrary *)uddata(udataV(o))); + return 0; +} + +#include "lj_libdef.h" + +/* -- Callback function metamethods --------------------------------------- */ + +#define LJLIB_MODULE_ffi_callback + +static int ffi_callback_set(lua_State *L, GCfunc *fn) +{ + GCcdata *cd = ffi_checkcdata(L, 1); + CTState *cts = ctype_cts(L); + CType *ct = ctype_raw(cts, cd->ctypeid); + if (ctype_isptr(ct->info) && (LJ_32 || ct->size == 8)) { + MSize slot = lj_ccallback_ptr2slot(cts, *(void **)cdataptr(cd)); + if (slot < cts->cb.sizeid && cts->cb.cbid[slot] != 0) { + GCtab *t = cts->miscmap; + TValue *tv = lj_tab_setint(L, t, (int32_t)slot); + if (fn) { + setfuncV(L, tv, fn); + lj_gc_anybarriert(L, t); + } else { + setnilV(tv); + cts->cb.cbid[slot] = 0; + cts->cb.topid = slot < cts->cb.topid ? slot : cts->cb.topid; + } + return 0; + } + } + lj_err_caller(L, LJ_ERR_FFI_BADCBACK); + return 0; +} + +LJLIB_CF(ffi_callback_free) +{ + return ffi_callback_set(L, NULL); +} + +LJLIB_CF(ffi_callback_set) +{ + GCfunc *fn = lj_lib_checkfunc(L, 2); + return ffi_callback_set(L, fn); +} + +LJLIB_PUSH(top-1) LJLIB_SET(__index) + +#include "lj_libdef.h" + +/* -- FFI library functions ----------------------------------------------- */ + +#define LJLIB_MODULE_ffi + +LJLIB_CF(ffi_cdef) +{ + GCstr *s = lj_lib_checkstr(L, 1); + CPState cp; + int errcode; + cp.L = L; + cp.cts = ctype_cts(L); + cp.srcname = strdata(s); + cp.p = strdata(s); + cp.param = L->base+1; + cp.mode = CPARSE_MODE_MULTI|CPARSE_MODE_DIRECT; + errcode = lj_cparse(&cp); + if (errcode) lj_err_throw(L, errcode); /* Propagate errors. */ + lj_gc_check(L); + return 0; +} + +LJLIB_CF(ffi_new) LJLIB_REC(.) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkctype(L, cts, NULL); + CType *ct = ctype_raw(cts, id); + CTSize sz; + CTInfo info = lj_ctype_info(cts, id, &sz); + TValue *o = L->base+1; + GCcdata *cd; + if ((info & CTF_VLA)) { + o++; + sz = lj_ctype_vlsize(cts, ct, (CTSize)ffi_checkint(L, 2)); + } + if (sz == CTSIZE_INVALID) + lj_err_arg(L, 1, LJ_ERR_FFI_INVSIZE); + if (!(info & CTF_VLA) && ctype_align(info) <= CT_MEMALIGN) + cd = lj_cdata_new(cts, id, sz); + else + cd = lj_cdata_newv(cts, id, sz, ctype_align(info)); + setcdataV(L, o-1, cd); /* Anchor the uninitialized cdata. */ + lj_cconv_ct_init(cts, ct, sz, cdataptr(cd), + o, (MSize)(L->top - o)); /* Initialize cdata. */ + if (ctype_isstruct(ct->info)) { + /* Handle ctype __gc metamethod. Use the fast lookup here. */ + cTValue *tv = lj_tab_getinth(cts->miscmap, -(int32_t)id); + if (tv && tvistab(tv) && (tv = lj_meta_fast(L, tabV(tv), MM_gc))) { + GCtab *t = cts->finalizer; + if (gcref(t->metatable)) { + /* Add to finalizer table, if still enabled. */ + copyTV(L, lj_tab_set(L, t, o-1), tv); + lj_gc_anybarriert(L, t); + cd->marked |= LJ_GC_CDATA_FIN; + } + } + } + L->top = o; /* Only return the cdata itself. */ + lj_gc_check(L); + return 1; +} + +LJLIB_CF(ffi_cast) LJLIB_REC(ffi_new) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkctype(L, cts, NULL); + CType *d = ctype_raw(cts, id); + TValue *o = lj_lib_checkany(L, 2); + L->top = o+1; /* Make sure this is the last item on the stack. */ + if (!(ctype_isnum(d->info) || ctype_isptr(d->info) || ctype_isenum(d->info))) + lj_err_arg(L, 1, LJ_ERR_FFI_INVTYPE); + if (!(tviscdata(o) && cdataV(o)->ctypeid == id)) { + GCcdata *cd = lj_cdata_new(cts, id, d->size); + lj_cconv_ct_tv(cts, d, cdataptr(cd), o, CCF_CAST); + setcdataV(L, o, cd); + lj_gc_check(L); + } + return 1; +} + +LJLIB_CF(ffi_typeof) LJLIB_REC(.) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkctype(L, cts, L->base+1); + GCcdata *cd = lj_cdata_new(cts, CTID_CTYPEID, 4); + *(CTypeID *)cdataptr(cd) = id; + setcdataV(L, L->top-1, cd); + lj_gc_check(L); + return 1; +} + +LJLIB_CF(ffi_istype) LJLIB_REC(.) +{ + CTState *cts = ctype_cts(L); + CTypeID id1 = ffi_checkctype(L, cts, NULL); + TValue *o = lj_lib_checkany(L, 2); + int b = 0; + if (tviscdata(o)) { + GCcdata *cd = cdataV(o); + CTypeID id2 = cd->ctypeid == CTID_CTYPEID ? *(CTypeID *)cdataptr(cd) : + cd->ctypeid; + CType *ct1 = lj_ctype_rawref(cts, id1); + CType *ct2 = lj_ctype_rawref(cts, id2); + if (ct1 == ct2) { + b = 1; + } else if (ctype_type(ct1->info) == ctype_type(ct2->info) && + ct1->size == ct2->size) { + if (ctype_ispointer(ct1->info)) + b = lj_cconv_compatptr(cts, ct1, ct2, CCF_IGNQUAL); + else if (ctype_isnum(ct1->info) || ctype_isvoid(ct1->info)) + b = (((ct1->info ^ ct2->info) & ~(CTF_QUAL|CTF_LONG)) == 0); + } else if (ctype_isstruct(ct1->info) && ctype_isptr(ct2->info) && + ct1 == ctype_rawchild(cts, ct2)) { + b = 1; + } + } + setboolV(L->top-1, b); + setboolV(&G(L)->tmptv2, b); /* Remember for trace recorder. */ + return 1; +} + +LJLIB_CF(ffi_sizeof) LJLIB_REC(ffi_xof FF_ffi_sizeof) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkctype(L, cts, NULL); + CTSize sz; + if (LJ_UNLIKELY(tviscdata(L->base) && cdataisv(cdataV(L->base)))) { + sz = cdatavlen(cdataV(L->base)); + } else { + CType *ct = lj_ctype_rawref(cts, id); + if (ctype_isvltype(ct->info)) + sz = lj_ctype_vlsize(cts, ct, (CTSize)ffi_checkint(L, 2)); + else + sz = ctype_hassize(ct->info) ? ct->size : CTSIZE_INVALID; + if (LJ_UNLIKELY(sz == CTSIZE_INVALID)) { + setnilV(L->top-1); + return 1; + } + } + setintV(L->top-1, (int32_t)sz); + return 1; +} + +LJLIB_CF(ffi_alignof) LJLIB_REC(ffi_xof FF_ffi_alignof) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkctype(L, cts, NULL); + CTSize sz = 0; + CTInfo info = lj_ctype_info(cts, id, &sz); + setintV(L->top-1, 1 << ctype_align(info)); + return 1; +} + +LJLIB_CF(ffi_offsetof) LJLIB_REC(ffi_xof FF_ffi_offsetof) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkctype(L, cts, NULL); + GCstr *name = lj_lib_checkstr(L, 2); + CType *ct = lj_ctype_rawref(cts, id); + CTSize ofs; + if (ctype_isstruct(ct->info) && ct->size != CTSIZE_INVALID) { + CType *fct = lj_ctype_getfield(cts, ct, name, &ofs); + if (fct) { + setintV(L->top-1, ofs); + if (ctype_isfield(fct->info)) { + return 1; + } else if (ctype_isbitfield(fct->info)) { + setintV(L->top++, ctype_bitpos(fct->info)); + setintV(L->top++, ctype_bitbsz(fct->info)); + return 3; + } + } + } + return 0; +} + +LJLIB_CF(ffi_errno) LJLIB_REC(.) +{ + int err = errno; + if (L->top > L->base) + errno = ffi_checkint(L, 1); + setintV(L->top++, err); + return 1; +} + +LJLIB_CF(ffi_string) LJLIB_REC(.) +{ + CTState *cts = ctype_cts(L); + TValue *o = lj_lib_checkany(L, 1); + const char *p; + size_t len; + if (o+1 < L->top && !tvisnil(o+1)) { + len = (size_t)ffi_checkint(L, 2); + lj_cconv_ct_tv(cts, ctype_get(cts, CTID_P_CVOID), (uint8_t *)&p, o, + CCF_ARG(1)); + } else { + lj_cconv_ct_tv(cts, ctype_get(cts, CTID_P_CCHAR), (uint8_t *)&p, o, + CCF_ARG(1)); + len = strlen(p); + } + L->top = o+1; /* Make sure this is the last item on the stack. */ + setstrV(L, o, lj_str_new(L, p, len)); + lj_gc_check(L); + return 1; +} + +LJLIB_CF(ffi_copy) LJLIB_REC(.) +{ + void *dp = ffi_checkptr(L, 1, CTID_P_VOID); + void *sp = ffi_checkptr(L, 2, CTID_P_CVOID); + TValue *o = L->base+1; + CTSize len; + if (tvisstr(o) && o+1 >= L->top) + len = strV(o)->len+1; /* Copy Lua string including trailing '\0'. */ + else + len = (CTSize)ffi_checkint(L, 3); + memcpy(dp, sp, len); + return 0; +} + +LJLIB_CF(ffi_fill) LJLIB_REC(.) +{ + void *dp = ffi_checkptr(L, 1, CTID_P_VOID); + CTSize len = (CTSize)ffi_checkint(L, 2); + int32_t fill = 0; + if (L->base+2 < L->top && !tvisnil(L->base+2)) fill = ffi_checkint(L, 3); + memset(dp, fill, len); + return 0; +} + +#define H_(le, be) LJ_ENDIAN_SELECT(0x##le, 0x##be) + +/* Test ABI string. */ +LJLIB_CF(ffi_abi) LJLIB_REC(.) +{ + GCstr *s = lj_lib_checkstr(L, 1); + int b = 0; + switch (s->hash) { +#if LJ_64 + case H_(849858eb,ad35fd06): b = 1; break; /* 64bit */ +#else + case H_(662d3c79,d0e22477): b = 1; break; /* 32bit */ +#endif +#if LJ_ARCH_HASFPU + case H_(e33ee463,e33ee463): b = 1; break; /* fpu */ +#endif +#if LJ_ABI_SOFTFP + case H_(61211a23,c2e8c81c): b = 1; break; /* softfp */ +#else + case H_(539417a8,8ce0812f): b = 1; break; /* hardfp */ +#endif +#if LJ_ABI_EABI + case H_(2182df8f,f2ed1152): b = 1; break; /* eabi */ +#endif +#if LJ_ABI_WIN + case H_(4ab624a8,4ab624a8): b = 1; break; /* win */ +#endif + case H_(3af93066,1f001464): b = 1; break; /* le/be */ + default: + break; + } + setboolV(L->top-1, b); + setboolV(&G(L)->tmptv2, b); /* Remember for trace recorder. */ + return 1; +} + +#undef H_ + +LJLIB_PUSH(top-8) LJLIB_SET(!) /* Store reference to miscmap table. */ + +LJLIB_CF(ffi_metatype) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkctype(L, cts, NULL); + GCtab *mt = lj_lib_checktab(L, 2); + GCtab *t = cts->miscmap; + CType *ct = ctype_get(cts, id); /* Only allow raw types. */ + TValue *tv; + GCcdata *cd; + if (!(ctype_isstruct(ct->info) || ctype_iscomplex(ct->info) || + ctype_isvector(ct->info))) + lj_err_arg(L, 1, LJ_ERR_FFI_INVTYPE); + tv = lj_tab_setinth(L, t, -(int32_t)id); + if (!tvisnil(tv)) + lj_err_caller(L, LJ_ERR_PROTMT); + settabV(L, tv, mt); + lj_gc_anybarriert(L, t); + cd = lj_cdata_new(cts, CTID_CTYPEID, 4); + *(CTypeID *)cdataptr(cd) = id; + setcdataV(L, L->top-1, cd); + lj_gc_check(L); + return 1; +} + +LJLIB_PUSH(top-7) LJLIB_SET(!) /* Store reference to finalizer table. */ + +LJLIB_CF(ffi_gc) LJLIB_REC(.) +{ + GCcdata *cd = ffi_checkcdata(L, 1); + TValue *fin = lj_lib_checkany(L, 2); + CTState *cts = ctype_cts(L); + GCtab *t = cts->finalizer; + CType *ct = ctype_raw(cts, cd->ctypeid); + if (!(ctype_isptr(ct->info) || ctype_isstruct(ct->info) || + ctype_isrefarray(ct->info))) + lj_err_arg(L, 1, LJ_ERR_FFI_INVTYPE); + if (gcref(t->metatable)) { /* Update finalizer table, if still enabled. */ + copyTV(L, lj_tab_set(L, t, L->base), fin); + lj_gc_anybarriert(L, t); + if (!tvisnil(fin)) + cd->marked |= LJ_GC_CDATA_FIN; + else + cd->marked &= ~LJ_GC_CDATA_FIN; + } + L->top = L->base+1; /* Pass through the cdata object. */ + return 1; +} + +LJLIB_PUSH(top-5) LJLIB_SET(!) /* Store clib metatable in func environment. */ + +LJLIB_CF(ffi_load) +{ + GCstr *name = lj_lib_checkstr(L, 1); + int global = (L->base+1 < L->top && tvistruecond(L->base+1)); + lj_clib_load(L, tabref(curr_func(L)->c.env), name, global); + return 1; +} + +LJLIB_PUSH(top-4) LJLIB_SET(C) +LJLIB_PUSH(top-3) LJLIB_SET(os) +LJLIB_PUSH(top-2) LJLIB_SET(arch) + +#include "lj_libdef.h" + +/* ------------------------------------------------------------------------ */ + +/* Create special weak-keyed finalizer table. */ +static GCtab *ffi_finalizer(lua_State *L) +{ + /* NOBARRIER: The table is new (marked white). */ + GCtab *t = lj_tab_new(L, 0, 1); + settabV(L, L->top++, t); + setgcref(t->metatable, obj2gco(t)); + setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "__mode")), + lj_str_newlit(L, "k")); + t->nomm = (uint8_t)(~(1u<top-1); + lj_gc_anybarriert(L, t); + } +} + +LUALIB_API int luaopen_ffi(lua_State *L) +{ + CTState *cts = lj_ctype_init(L); + settabV(L, L->top++, (cts->miscmap = lj_tab_new(L, 0, 1))); + cts->finalizer = ffi_finalizer(L); + LJ_LIB_REG(L, NULL, ffi_meta); + /* NOBARRIER: basemt is a GC root. */ + setgcref(basemt_it(G(L), LJ_TCDATA), obj2gco(tabV(L->top-1))); + LJ_LIB_REG(L, NULL, ffi_clib); + LJ_LIB_REG(L, NULL, ffi_callback); + /* NOBARRIER: the key is new and lj_tab_newkey() handles the barrier. */ + settabV(L, lj_tab_setstr(L, cts->miscmap, &cts->g->strempty), tabV(L->top-1)); + L->top--; + lj_clib_default(L, tabV(L->top-1)); /* Create ffi.C default namespace. */ + lua_pushliteral(L, LJ_OS_NAME); + lua_pushliteral(L, LJ_ARCH_NAME); + LJ_LIB_REG(L, NULL, ffi); /* Note: no global "ffi" created! */ + ffi_register_module(L); + return 1; +} + +#endif + +``` + +`include/luajit-2.0.5/src/lib_init.c`: + +```c +/* +** Library initialization. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Major parts taken verbatim from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lib_init_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_arch.h" + +static const luaL_Reg lj_lib_load[] = { + { "", luaopen_base }, + { LUA_LOADLIBNAME, luaopen_package }, + { LUA_TABLIBNAME, luaopen_table }, + { LUA_IOLIBNAME, luaopen_io }, + { LUA_OSLIBNAME, luaopen_os }, + { LUA_STRLIBNAME, luaopen_string }, + { LUA_MATHLIBNAME, luaopen_math }, + { LUA_DBLIBNAME, luaopen_debug }, + { LUA_BITLIBNAME, luaopen_bit }, + { LUA_JITLIBNAME, luaopen_jit }, + { NULL, NULL } +}; + +static const luaL_Reg lj_lib_preload[] = { +#if LJ_HASFFI + { LUA_FFILIBNAME, luaopen_ffi }, +#endif + { NULL, NULL } +}; + +LUALIB_API void luaL_openlibs(lua_State *L) +{ + const luaL_Reg *lib; + for (lib = lj_lib_load; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_pushstring(L, lib->name); + lua_call(L, 1, 0); + } + luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD", + sizeof(lj_lib_preload)/sizeof(lj_lib_preload[0])-1); + for (lib = lj_lib_preload; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_setfield(L, -2, lib->name); + } + lua_pop(L, 1); +} + + +``` + +`include/luajit-2.0.5/src/lib_io.c`: + +```c +/* +** I/O library. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#include +#include + +#define lib_io_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_state.h" +#include "lj_ff.h" +#include "lj_lib.h" + +/* Userdata payload for I/O file. */ +typedef struct IOFileUD { + FILE *fp; /* File handle. */ + uint32_t type; /* File type. */ +} IOFileUD; + +#define IOFILE_TYPE_FILE 0 /* Regular file. */ +#define IOFILE_TYPE_PIPE 1 /* Pipe. */ +#define IOFILE_TYPE_STDF 2 /* Standard file handle. */ +#define IOFILE_TYPE_MASK 3 + +#define IOFILE_FLAG_CLOSE 4 /* Close after io.lines() iterator. */ + +#define IOSTDF_UD(L, id) (&gcref(G(L)->gcroot[(id)])->ud) +#define IOSTDF_IOF(L, id) ((IOFileUD *)uddata(IOSTDF_UD(L, (id)))) + +/* -- Open/close helpers -------------------------------------------------- */ + +static IOFileUD *io_tofilep(lua_State *L) +{ + if (!(L->base < L->top && tvisudata(L->base) && + udataV(L->base)->udtype == UDTYPE_IO_FILE)) + lj_err_argtype(L, 1, "FILE*"); + return (IOFileUD *)uddata(udataV(L->base)); +} + +static IOFileUD *io_tofile(lua_State *L) +{ + IOFileUD *iof = io_tofilep(L); + if (iof->fp == NULL) + lj_err_caller(L, LJ_ERR_IOCLFL); + return iof; +} + +static FILE *io_stdfile(lua_State *L, ptrdiff_t id) +{ + IOFileUD *iof = IOSTDF_IOF(L, id); + if (iof->fp == NULL) + lj_err_caller(L, LJ_ERR_IOSTDCL); + return iof->fp; +} + +static IOFileUD *io_file_new(lua_State *L) +{ + IOFileUD *iof = (IOFileUD *)lua_newuserdata(L, sizeof(IOFileUD)); + GCudata *ud = udataV(L->top-1); + ud->udtype = UDTYPE_IO_FILE; + /* NOBARRIER: The GCudata is new (marked white). */ + setgcrefr(ud->metatable, curr_func(L)->c.env); + iof->fp = NULL; + iof->type = IOFILE_TYPE_FILE; + return iof; +} + +static IOFileUD *io_file_open(lua_State *L, const char *mode) +{ + const char *fname = strdata(lj_lib_checkstr(L, 1)); + IOFileUD *iof = io_file_new(L); + iof->fp = fopen(fname, mode); + if (iof->fp == NULL) + luaL_argerror(L, 1, lj_str_pushf(L, "%s: %s", fname, strerror(errno))); + return iof; +} + +static int io_file_close(lua_State *L, IOFileUD *iof) +{ + int ok; + if ((iof->type & IOFILE_TYPE_MASK) == IOFILE_TYPE_FILE) { + ok = (fclose(iof->fp) == 0); + } else if ((iof->type & IOFILE_TYPE_MASK) == IOFILE_TYPE_PIPE) { + int stat = -1; +#if LJ_TARGET_POSIX + stat = pclose(iof->fp); +#elif LJ_TARGET_WINDOWS + stat = _pclose(iof->fp); +#else + lua_assert(0); + return 0; +#endif +#if LJ_52 + iof->fp = NULL; + return luaL_execresult(L, stat); +#else + ok = (stat != -1); +#endif + } else { + lua_assert((iof->type & IOFILE_TYPE_MASK) == IOFILE_TYPE_STDF); + setnilV(L->top++); + lua_pushliteral(L, "cannot close standard file"); + return 2; + } + iof->fp = NULL; + return luaL_fileresult(L, ok, NULL); +} + +/* -- Read/write helpers -------------------------------------------------- */ + +static int io_file_readnum(lua_State *L, FILE *fp) +{ + lua_Number d; + if (fscanf(fp, LUA_NUMBER_SCAN, &d) == 1) { + if (LJ_DUALNUM) { + int32_t i = lj_num2int(d); + if (d == (lua_Number)i && !tvismzero((cTValue *)&d)) { + setintV(L->top++, i); + return 1; + } + } + setnumV(L->top++, d); + return 1; + } else { + setnilV(L->top++); + return 0; + } +} + +static int io_file_readline(lua_State *L, FILE *fp, MSize chop) +{ + MSize m = LUAL_BUFFERSIZE, n = 0, ok = 0; + char *buf; + for (;;) { + buf = lj_str_needbuf(L, &G(L)->tmpbuf, m); + if (fgets(buf+n, m-n, fp) == NULL) break; + n += (MSize)strlen(buf+n); + ok |= n; + if (n && buf[n-1] == '\n') { n -= chop; break; } + if (n >= m - 64) m += m; + } + setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); + lj_gc_check(L); + return (int)ok; +} + +static void io_file_readall(lua_State *L, FILE *fp) +{ + MSize m, n; + for (m = LUAL_BUFFERSIZE, n = 0; ; m += m) { + char *buf = lj_str_needbuf(L, &G(L)->tmpbuf, m); + n += (MSize)fread(buf+n, 1, m-n, fp); + if (n != m) { + setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); + lj_gc_check(L); + return; + } + } +} + +static int io_file_readlen(lua_State *L, FILE *fp, MSize m) +{ + if (m) { + char *buf = lj_str_needbuf(L, &G(L)->tmpbuf, m); + MSize n = (MSize)fread(buf, 1, m, fp); + setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); + lj_gc_check(L); + return (n > 0 || m == 0); + } else { + int c = getc(fp); + ungetc(c, fp); + setstrV(L, L->top++, &G(L)->strempty); + return (c != EOF); + } +} + +static int io_file_read(lua_State *L, FILE *fp, int start) +{ + int ok, n, nargs = (int)(L->top - L->base) - start; + clearerr(fp); + if (nargs == 0) { + ok = io_file_readline(L, fp, 1); + n = start+1; /* Return 1 result. */ + } else { + /* The results plus the buffers go on top of the args. */ + luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); + ok = 1; + for (n = start; nargs-- && ok; n++) { + if (tvisstr(L->base+n)) { + const char *p = strVdata(L->base+n); + if (p[0] != '*') + lj_err_arg(L, n+1, LJ_ERR_INVOPT); + if (p[1] == 'n') + ok = io_file_readnum(L, fp); + else if ((p[1] & ~0x20) == 'L') + ok = io_file_readline(L, fp, (p[1] == 'l')); + else if (p[1] == 'a') + io_file_readall(L, fp); + else + lj_err_arg(L, n+1, LJ_ERR_INVFMT); + } else if (tvisnumber(L->base+n)) { + ok = io_file_readlen(L, fp, (MSize)lj_lib_checkint(L, n+1)); + } else { + lj_err_arg(L, n+1, LJ_ERR_INVOPT); + } + } + } + if (ferror(fp)) + return luaL_fileresult(L, 0, NULL); + if (!ok) + setnilV(L->top-1); /* Replace last result with nil. */ + return n - start; +} + +static int io_file_write(lua_State *L, FILE *fp, int start) +{ + cTValue *tv; + int status = 1; + for (tv = L->base+start; tv < L->top; tv++) { + if (tvisstr(tv)) { + MSize len = strV(tv)->len; + status = status && (fwrite(strVdata(tv), 1, len, fp) == len); + } else if (tvisint(tv)) { + char buf[LJ_STR_INTBUF]; + char *p = lj_str_bufint(buf, intV(tv)); + size_t len = (size_t)(buf+LJ_STR_INTBUF-p); + status = status && (fwrite(p, 1, len, fp) == len); + } else if (tvisnum(tv)) { + status = status && (fprintf(fp, LUA_NUMBER_FMT, numV(tv)) > 0); + } else { + lj_err_argt(L, (int)(tv - L->base) + 1, LUA_TSTRING); + } + } + if (LJ_52 && status) { + L->top = L->base+1; + if (start == 0) + setudataV(L, L->base, IOSTDF_UD(L, GCROOT_IO_OUTPUT)); + return 1; + } + return luaL_fileresult(L, status, NULL); +} + +static int io_file_iter(lua_State *L) +{ + GCfunc *fn = curr_func(L); + IOFileUD *iof = uddata(udataV(&fn->c.upvalue[0])); + int n = fn->c.nupvalues - 1; + if (iof->fp == NULL) + lj_err_caller(L, LJ_ERR_IOCLFL); + L->top = L->base; + if (n) { /* Copy upvalues with options to stack. */ + if (n > LUAI_MAXCSTACK) + lj_err_caller(L, LJ_ERR_STKOV); + lj_state_checkstack(L, (MSize)n); + memcpy(L->top, &fn->c.upvalue[1], n*sizeof(TValue)); + L->top += n; + } + n = io_file_read(L, iof->fp, 0); + if (ferror(iof->fp)) + lj_err_callermsg(L, strVdata(L->top-2)); + if (tvisnil(L->base) && (iof->type & IOFILE_FLAG_CLOSE)) { + io_file_close(L, iof); /* Return values are ignored. */ + return 0; + } + return n; +} + +static int io_file_lines(lua_State *L) +{ + int n = (int)(L->top - L->base); + if (n > LJ_MAX_UPVAL) + lj_err_caller(L, LJ_ERR_UNPACK); + lua_pushcclosure(L, io_file_iter, n); + return 1; +} + +/* -- I/O file methods ---------------------------------------------------- */ + +#define LJLIB_MODULE_io_method + +LJLIB_CF(io_method_close) +{ + IOFileUD *iof = L->base < L->top ? io_tofile(L) : + IOSTDF_IOF(L, GCROOT_IO_OUTPUT); + return io_file_close(L, iof); +} + +LJLIB_CF(io_method_read) +{ + return io_file_read(L, io_tofile(L)->fp, 1); +} + +LJLIB_CF(io_method_write) LJLIB_REC(io_write 0) +{ + return io_file_write(L, io_tofile(L)->fp, 1); +} + +LJLIB_CF(io_method_flush) LJLIB_REC(io_flush 0) +{ + return luaL_fileresult(L, fflush(io_tofile(L)->fp) == 0, NULL); +} + +LJLIB_CF(io_method_seek) +{ + FILE *fp = io_tofile(L)->fp; + int opt = lj_lib_checkopt(L, 2, 1, "\3set\3cur\3end"); + int64_t ofs = 0; + cTValue *o; + int res; + if (opt == 0) opt = SEEK_SET; + else if (opt == 1) opt = SEEK_CUR; + else if (opt == 2) opt = SEEK_END; + o = L->base+2; + if (o < L->top) { + if (tvisint(o)) + ofs = (int64_t)intV(o); + else if (tvisnum(o)) + ofs = (int64_t)numV(o); + else if (!tvisnil(o)) + lj_err_argt(L, 3, LUA_TNUMBER); + } +#if LJ_TARGET_POSIX + res = fseeko(fp, ofs, opt); +#elif _MSC_VER >= 1400 + res = _fseeki64(fp, ofs, opt); +#elif defined(__MINGW32__) + res = fseeko64(fp, ofs, opt); +#else + res = fseek(fp, (long)ofs, opt); +#endif + if (res) + return luaL_fileresult(L, 0, NULL); +#if LJ_TARGET_POSIX + ofs = ftello(fp); +#elif _MSC_VER >= 1400 + ofs = _ftelli64(fp); +#elif defined(__MINGW32__) + ofs = ftello64(fp); +#else + ofs = (int64_t)ftell(fp); +#endif + setint64V(L->top-1, ofs); + return 1; +} + +LJLIB_CF(io_method_setvbuf) +{ + FILE *fp = io_tofile(L)->fp; + int opt = lj_lib_checkopt(L, 2, -1, "\4full\4line\2no"); + size_t sz = (size_t)lj_lib_optint(L, 3, LUAL_BUFFERSIZE); + if (opt == 0) opt = _IOFBF; + else if (opt == 1) opt = _IOLBF; + else if (opt == 2) opt = _IONBF; + return luaL_fileresult(L, setvbuf(fp, NULL, opt, sz) == 0, NULL); +} + +LJLIB_CF(io_method_lines) +{ + io_tofile(L); + return io_file_lines(L); +} + +LJLIB_CF(io_method___gc) +{ + IOFileUD *iof = io_tofilep(L); + if (iof->fp != NULL && (iof->type & IOFILE_TYPE_MASK) != IOFILE_TYPE_STDF) + io_file_close(L, iof); + return 0; +} + +LJLIB_CF(io_method___tostring) +{ + IOFileUD *iof = io_tofilep(L); + if (iof->fp != NULL) + lua_pushfstring(L, "file (%p)", iof->fp); + else + lua_pushliteral(L, "file (closed)"); + return 1; +} + +LJLIB_PUSH(top-1) LJLIB_SET(__index) + +#include "lj_libdef.h" + +/* -- I/O library functions ----------------------------------------------- */ + +#define LJLIB_MODULE_io + +LJLIB_PUSH(top-2) LJLIB_SET(!) /* Set environment. */ + +LJLIB_CF(io_open) +{ + const char *fname = strdata(lj_lib_checkstr(L, 1)); + GCstr *s = lj_lib_optstr(L, 2); + const char *mode = s ? strdata(s) : "r"; + IOFileUD *iof = io_file_new(L); + iof->fp = fopen(fname, mode); + return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, fname); +} + +LJLIB_CF(io_popen) +{ +#if LJ_TARGET_POSIX || LJ_TARGET_WINDOWS + const char *fname = strdata(lj_lib_checkstr(L, 1)); + GCstr *s = lj_lib_optstr(L, 2); + const char *mode = s ? strdata(s) : "r"; + IOFileUD *iof = io_file_new(L); + iof->type = IOFILE_TYPE_PIPE; +#if LJ_TARGET_POSIX + fflush(NULL); + iof->fp = popen(fname, mode); +#else + iof->fp = _popen(fname, mode); +#endif + return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, fname); +#else + return luaL_error(L, LUA_QL("popen") " not supported"); +#endif +} + +LJLIB_CF(io_tmpfile) +{ + IOFileUD *iof = io_file_new(L); +#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA + iof->fp = NULL; errno = ENOSYS; +#else + iof->fp = tmpfile(); +#endif + return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, NULL); +} + +LJLIB_CF(io_close) +{ + return lj_cf_io_method_close(L); +} + +LJLIB_CF(io_read) +{ + return io_file_read(L, io_stdfile(L, GCROOT_IO_INPUT), 0); +} + +LJLIB_CF(io_write) LJLIB_REC(io_write GCROOT_IO_OUTPUT) +{ + return io_file_write(L, io_stdfile(L, GCROOT_IO_OUTPUT), 0); +} + +LJLIB_CF(io_flush) LJLIB_REC(io_flush GCROOT_IO_OUTPUT) +{ + return luaL_fileresult(L, fflush(io_stdfile(L, GCROOT_IO_OUTPUT)) == 0, NULL); +} + +static int io_std_getset(lua_State *L, ptrdiff_t id, const char *mode) +{ + if (L->base < L->top && !tvisnil(L->base)) { + if (tvisudata(L->base)) { + io_tofile(L); + L->top = L->base+1; + } else { + io_file_open(L, mode); + } + /* NOBARRIER: The standard I/O handles are GC roots. */ + setgcref(G(L)->gcroot[id], gcV(L->top-1)); + } else { + setudataV(L, L->top++, IOSTDF_UD(L, id)); + } + return 1; +} + +LJLIB_CF(io_input) +{ + return io_std_getset(L, GCROOT_IO_INPUT, "r"); +} + +LJLIB_CF(io_output) +{ + return io_std_getset(L, GCROOT_IO_OUTPUT, "w"); +} + +LJLIB_CF(io_lines) +{ + if (L->base == L->top) setnilV(L->top++); + if (!tvisnil(L->base)) { /* io.lines(fname) */ + IOFileUD *iof = io_file_open(L, "r"); + iof->type = IOFILE_TYPE_FILE|IOFILE_FLAG_CLOSE; + L->top--; + setudataV(L, L->base, udataV(L->top)); + } else { /* io.lines() iterates over stdin. */ + setudataV(L, L->base, IOSTDF_UD(L, GCROOT_IO_INPUT)); + } + return io_file_lines(L); +} + +LJLIB_CF(io_type) +{ + cTValue *o = lj_lib_checkany(L, 1); + if (!(tvisudata(o) && udataV(o)->udtype == UDTYPE_IO_FILE)) + setnilV(L->top++); + else if (((IOFileUD *)uddata(udataV(o)))->fp != NULL) + lua_pushliteral(L, "file"); + else + lua_pushliteral(L, "closed file"); + return 1; +} + +#include "lj_libdef.h" + +/* ------------------------------------------------------------------------ */ + +static GCobj *io_std_new(lua_State *L, FILE *fp, const char *name) +{ + IOFileUD *iof = (IOFileUD *)lua_newuserdata(L, sizeof(IOFileUD)); + GCudata *ud = udataV(L->top-1); + ud->udtype = UDTYPE_IO_FILE; + /* NOBARRIER: The GCudata is new (marked white). */ + setgcref(ud->metatable, gcV(L->top-3)); + iof->fp = fp; + iof->type = IOFILE_TYPE_STDF; + lua_setfield(L, -2, name); + return obj2gco(ud); +} + +LUALIB_API int luaopen_io(lua_State *L) +{ + LJ_LIB_REG(L, NULL, io_method); + copyTV(L, L->top, L->top-1); L->top++; + lua_setfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); + LJ_LIB_REG(L, LUA_IOLIBNAME, io); + setgcref(G(L)->gcroot[GCROOT_IO_INPUT], io_std_new(L, stdin, "stdin")); + setgcref(G(L)->gcroot[GCROOT_IO_OUTPUT], io_std_new(L, stdout, "stdout")); + io_std_new(L, stderr, "stderr"); + return 1; +} + + +``` + +`include/luajit-2.0.5/src/lib_jit.c`: + +```c +/* +** JIT library. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lib_jit_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_arch.h" +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_bc.h" +#if LJ_HASJIT +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_ircall.h" +#include "lj_iropt.h" +#include "lj_target.h" +#endif +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "lj_vmevent.h" +#include "lj_lib.h" + +#include "luajit.h" + +/* -- jit.* functions ----------------------------------------------------- */ + +#define LJLIB_MODULE_jit + +static int setjitmode(lua_State *L, int mode) +{ + int idx = 0; + if (L->base == L->top || tvisnil(L->base)) { /* jit.on/off/flush([nil]) */ + mode |= LUAJIT_MODE_ENGINE; + } else { + /* jit.on/off/flush(func|proto, nil|true|false) */ + if (tvisfunc(L->base) || tvisproto(L->base)) + idx = 1; + else if (!tvistrue(L->base)) /* jit.on/off/flush(true, nil|true|false) */ + goto err; + if (L->base+1 < L->top && tvisbool(L->base+1)) + mode |= boolV(L->base+1) ? LUAJIT_MODE_ALLFUNC : LUAJIT_MODE_ALLSUBFUNC; + else + mode |= LUAJIT_MODE_FUNC; + } + if (luaJIT_setmode(L, idx, mode) != 1) { + if ((mode & LUAJIT_MODE_MASK) == LUAJIT_MODE_ENGINE) + lj_err_caller(L, LJ_ERR_NOJIT); + err: + lj_err_argt(L, 1, LUA_TFUNCTION); + } + return 0; +} + +LJLIB_CF(jit_on) +{ + return setjitmode(L, LUAJIT_MODE_ON); +} + +LJLIB_CF(jit_off) +{ + return setjitmode(L, LUAJIT_MODE_OFF); +} + +LJLIB_CF(jit_flush) +{ +#if LJ_HASJIT + if (L->base < L->top && tvisnumber(L->base)) { + int traceno = lj_lib_checkint(L, 1); + luaJIT_setmode(L, traceno, LUAJIT_MODE_FLUSH|LUAJIT_MODE_TRACE); + return 0; + } +#endif + return setjitmode(L, LUAJIT_MODE_FLUSH); +} + +#if LJ_HASJIT +/* Push a string for every flag bit that is set. */ +static void flagbits_to_strings(lua_State *L, uint32_t flags, uint32_t base, + const char *str) +{ + for (; *str; base <<= 1, str += 1+*str) + if (flags & base) + setstrV(L, L->top++, lj_str_new(L, str+1, *(uint8_t *)str)); +} +#endif + +LJLIB_CF(jit_status) +{ +#if LJ_HASJIT + jit_State *J = L2J(L); + L->top = L->base; + setboolV(L->top++, (J->flags & JIT_F_ON) ? 1 : 0); + flagbits_to_strings(L, J->flags, JIT_F_CPU_FIRST, JIT_F_CPUSTRING); + flagbits_to_strings(L, J->flags, JIT_F_OPT_FIRST, JIT_F_OPTSTRING); + return (int)(L->top - L->base); +#else + setboolV(L->top++, 0); + return 1; +#endif +} + +LJLIB_CF(jit_attach) +{ +#ifdef LUAJIT_DISABLE_VMEVENT + luaL_error(L, "vmevent API disabled"); +#else + GCfunc *fn = lj_lib_checkfunc(L, 1); + GCstr *s = lj_lib_optstr(L, 2); + luaL_findtable(L, LUA_REGISTRYINDEX, LJ_VMEVENTS_REGKEY, LJ_VMEVENTS_HSIZE); + if (s) { /* Attach to given event. */ + const uint8_t *p = (const uint8_t *)strdata(s); + uint32_t h = s->len; + while (*p) h = h ^ (lj_rol(h, 6) + *p++); + lua_pushvalue(L, 1); + lua_rawseti(L, -2, VMEVENT_HASHIDX(h)); + G(L)->vmevmask = VMEVENT_NOCACHE; /* Invalidate cache. */ + } else { /* Detach if no event given. */ + setnilV(L->top++); + while (lua_next(L, -2)) { + L->top--; + if (tvisfunc(L->top) && funcV(L->top) == fn) { + setnilV(lj_tab_set(L, tabV(L->top-2), L->top-1)); + } + } + } +#endif + return 0; +} + +LJLIB_PUSH(top-5) LJLIB_SET(os) +LJLIB_PUSH(top-4) LJLIB_SET(arch) +LJLIB_PUSH(top-3) LJLIB_SET(version_num) +LJLIB_PUSH(top-2) LJLIB_SET(version) + +#include "lj_libdef.h" + +/* -- jit.util.* functions ------------------------------------------------ */ + +#define LJLIB_MODULE_jit_util + +/* -- Reflection API for Lua functions ------------------------------------ */ + +/* Return prototype of first argument (Lua function or prototype object) */ +static GCproto *check_Lproto(lua_State *L, int nolua) +{ + TValue *o = L->base; + if (L->top > o) { + if (tvisproto(o)) { + return protoV(o); + } else if (tvisfunc(o)) { + if (isluafunc(funcV(o))) + return funcproto(funcV(o)); + else if (nolua) + return NULL; + } + } + lj_err_argt(L, 1, LUA_TFUNCTION); + return NULL; /* unreachable */ +} + +static void setintfield(lua_State *L, GCtab *t, const char *name, int32_t val) +{ + setintV(lj_tab_setstr(L, t, lj_str_newz(L, name)), val); +} + +/* local info = jit.util.funcinfo(func [,pc]) */ +LJLIB_CF(jit_util_funcinfo) +{ + GCproto *pt = check_Lproto(L, 1); + if (pt) { + BCPos pc = (BCPos)lj_lib_optint(L, 2, 0); + GCtab *t; + lua_createtable(L, 0, 16); /* Increment hash size if fields are added. */ + t = tabV(L->top-1); + setintfield(L, t, "linedefined", pt->firstline); + setintfield(L, t, "lastlinedefined", pt->firstline + pt->numline); + setintfield(L, t, "stackslots", pt->framesize); + setintfield(L, t, "params", pt->numparams); + setintfield(L, t, "bytecodes", (int32_t)pt->sizebc); + setintfield(L, t, "gcconsts", (int32_t)pt->sizekgc); + setintfield(L, t, "nconsts", (int32_t)pt->sizekn); + setintfield(L, t, "upvalues", (int32_t)pt->sizeuv); + if (pc < pt->sizebc) + setintfield(L, t, "currentline", lj_debug_line(pt, pc)); + lua_pushboolean(L, (pt->flags & PROTO_VARARG)); + lua_setfield(L, -2, "isvararg"); + lua_pushboolean(L, (pt->flags & PROTO_CHILD)); + lua_setfield(L, -2, "children"); + setstrV(L, L->top++, proto_chunkname(pt)); + lua_setfield(L, -2, "source"); + lj_debug_pushloc(L, pt, pc); + lua_setfield(L, -2, "loc"); + setprotoV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "proto")), pt); + } else { + GCfunc *fn = funcV(L->base); + GCtab *t; + lua_createtable(L, 0, 4); /* Increment hash size if fields are added. */ + t = tabV(L->top-1); + if (!iscfunc(fn)) + setintfield(L, t, "ffid", fn->c.ffid); + setintptrV(lj_tab_setstr(L, t, lj_str_newlit(L, "addr")), + (intptr_t)(void *)fn->c.f); + setintfield(L, t, "upvalues", fn->c.nupvalues); + } + return 1; +} + +/* local ins, m = jit.util.funcbc(func, pc) */ +LJLIB_CF(jit_util_funcbc) +{ + GCproto *pt = check_Lproto(L, 0); + BCPos pc = (BCPos)lj_lib_checkint(L, 2); + if (pc < pt->sizebc) { + BCIns ins = proto_bc(pt)[pc]; + BCOp op = bc_op(ins); + lua_assert(op < BC__MAX); + setintV(L->top, ins); + setintV(L->top+1, lj_bc_mode[op]); + L->top += 2; + return 2; + } + return 0; +} + +/* local k = jit.util.funck(func, idx) */ +LJLIB_CF(jit_util_funck) +{ + GCproto *pt = check_Lproto(L, 0); + ptrdiff_t idx = (ptrdiff_t)lj_lib_checkint(L, 2); + if (idx >= 0) { + if (idx < (ptrdiff_t)pt->sizekn) { + copyTV(L, L->top-1, proto_knumtv(pt, idx)); + return 1; + } + } else { + if (~idx < (ptrdiff_t)pt->sizekgc) { + GCobj *gc = proto_kgc(pt, idx); + setgcV(L, L->top-1, gc, ~gc->gch.gct); + return 1; + } + } + return 0; +} + +/* local name = jit.util.funcuvname(func, idx) */ +LJLIB_CF(jit_util_funcuvname) +{ + GCproto *pt = check_Lproto(L, 0); + uint32_t idx = (uint32_t)lj_lib_checkint(L, 2); + if (idx < pt->sizeuv) { + setstrV(L, L->top-1, lj_str_newz(L, lj_debug_uvname(pt, idx))); + return 1; + } + return 0; +} + +/* -- Reflection API for traces ------------------------------------------- */ + +#if LJ_HASJIT + +/* Check trace argument. Must not throw for non-existent trace numbers. */ +static GCtrace *jit_checktrace(lua_State *L) +{ + TraceNo tr = (TraceNo)lj_lib_checkint(L, 1); + jit_State *J = L2J(L); + if (tr > 0 && tr < J->sizetrace) + return traceref(J, tr); + return NULL; +} + +/* Names of link types. ORDER LJ_TRLINK */ +static const char *const jit_trlinkname[] = { + "none", "root", "loop", "tail-recursion", "up-recursion", "down-recursion", + "interpreter", "return" +}; + +/* local info = jit.util.traceinfo(tr) */ +LJLIB_CF(jit_util_traceinfo) +{ + GCtrace *T = jit_checktrace(L); + if (T) { + GCtab *t; + lua_createtable(L, 0, 8); /* Increment hash size if fields are added. */ + t = tabV(L->top-1); + setintfield(L, t, "nins", (int32_t)T->nins - REF_BIAS - 1); + setintfield(L, t, "nk", REF_BIAS - (int32_t)T->nk); + setintfield(L, t, "link", T->link); + setintfield(L, t, "nexit", T->nsnap); + setstrV(L, L->top++, lj_str_newz(L, jit_trlinkname[T->linktype])); + lua_setfield(L, -2, "linktype"); + /* There are many more fields. Add them only when needed. */ + return 1; + } + return 0; +} + +/* local m, ot, op1, op2, prev = jit.util.traceir(tr, idx) */ +LJLIB_CF(jit_util_traceir) +{ + GCtrace *T = jit_checktrace(L); + IRRef ref = (IRRef)lj_lib_checkint(L, 2) + REF_BIAS; + if (T && ref >= REF_BIAS && ref < T->nins) { + IRIns *ir = &T->ir[ref]; + int32_t m = lj_ir_mode[ir->o]; + setintV(L->top-2, m); + setintV(L->top-1, ir->ot); + setintV(L->top++, (int32_t)ir->op1 - (irm_op1(m)==IRMref ? REF_BIAS : 0)); + setintV(L->top++, (int32_t)ir->op2 - (irm_op2(m)==IRMref ? REF_BIAS : 0)); + setintV(L->top++, ir->prev); + return 5; + } + return 0; +} + +/* local k, t [, slot] = jit.util.tracek(tr, idx) */ +LJLIB_CF(jit_util_tracek) +{ + GCtrace *T = jit_checktrace(L); + IRRef ref = (IRRef)lj_lib_checkint(L, 2) + REF_BIAS; + if (T && ref >= T->nk && ref < REF_BIAS) { + IRIns *ir = &T->ir[ref]; + int32_t slot = -1; + if (ir->o == IR_KSLOT) { + slot = ir->op2; + ir = &T->ir[ir->op1]; + } + lj_ir_kvalue(L, L->top-2, ir); + setintV(L->top-1, (int32_t)irt_type(ir->t)); + if (slot == -1) + return 2; + setintV(L->top++, slot); + return 3; + } + return 0; +} + +/* local snap = jit.util.tracesnap(tr, sn) */ +LJLIB_CF(jit_util_tracesnap) +{ + GCtrace *T = jit_checktrace(L); + SnapNo sn = (SnapNo)lj_lib_checkint(L, 2); + if (T && sn < T->nsnap) { + SnapShot *snap = &T->snap[sn]; + SnapEntry *map = &T->snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + GCtab *t; + lua_createtable(L, nent+2, 0); + t = tabV(L->top-1); + setintV(lj_tab_setint(L, t, 0), (int32_t)snap->ref - REF_BIAS); + setintV(lj_tab_setint(L, t, 1), (int32_t)snap->nslots); + for (n = 0; n < nent; n++) + setintV(lj_tab_setint(L, t, (int32_t)(n+2)), (int32_t)map[n]); + setintV(lj_tab_setint(L, t, (int32_t)(nent+2)), (int32_t)SNAP(255, 0, 0)); + return 1; + } + return 0; +} + +/* local mcode, addr, loop = jit.util.tracemc(tr) */ +LJLIB_CF(jit_util_tracemc) +{ + GCtrace *T = jit_checktrace(L); + if (T && T->mcode != NULL) { + setstrV(L, L->top-1, lj_str_new(L, (const char *)T->mcode, T->szmcode)); + setintptrV(L->top++, (intptr_t)(void *)T->mcode); + setintV(L->top++, T->mcloop); + return 3; + } + return 0; +} + +/* local addr = jit.util.traceexitstub([tr,] exitno) */ +LJLIB_CF(jit_util_traceexitstub) +{ +#ifdef EXITSTUBS_PER_GROUP + ExitNo exitno = (ExitNo)lj_lib_checkint(L, 1); + jit_State *J = L2J(L); + if (exitno < EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) { + setintptrV(L->top-1, (intptr_t)(void *)exitstub_addr(J, exitno)); + return 1; + } +#else + if (L->top > L->base+1) { /* Don't throw for one-argument variant. */ + GCtrace *T = jit_checktrace(L); + ExitNo exitno = (ExitNo)lj_lib_checkint(L, 2); + ExitNo maxexit = T->root ? T->nsnap+1 : T->nsnap; + if (T && T->mcode != NULL && exitno < maxexit) { + setintptrV(L->top-1, (intptr_t)(void *)exitstub_trace_addr(T, exitno)); + return 1; + } + } +#endif + return 0; +} + +/* local addr = jit.util.ircalladdr(idx) */ +LJLIB_CF(jit_util_ircalladdr) +{ + uint32_t idx = (uint32_t)lj_lib_checkint(L, 1); + if (idx < IRCALL__MAX) { + setintptrV(L->top-1, (intptr_t)(void *)lj_ir_callinfo[idx].func); + return 1; + } + return 0; +} + +#endif + +#include "lj_libdef.h" + +/* -- jit.opt module ------------------------------------------------------ */ + +#if LJ_HASJIT + +#define LJLIB_MODULE_jit_opt + +/* Parse optimization level. */ +static int jitopt_level(jit_State *J, const char *str) +{ + if (str[0] >= '0' && str[0] <= '9' && str[1] == '\0') { + uint32_t flags; + if (str[0] == '0') flags = JIT_F_OPT_0; + else if (str[0] == '1') flags = JIT_F_OPT_1; + else if (str[0] == '2') flags = JIT_F_OPT_2; + else flags = JIT_F_OPT_3; + J->flags = (J->flags & ~JIT_F_OPT_MASK) | flags; + return 1; /* Ok. */ + } + return 0; /* No match. */ +} + +/* Parse optimization flag. */ +static int jitopt_flag(jit_State *J, const char *str) +{ + const char *lst = JIT_F_OPTSTRING; + uint32_t opt; + int set = 1; + if (str[0] == '+') { + str++; + } else if (str[0] == '-') { + str++; + set = 0; + } else if (str[0] == 'n' && str[1] == 'o') { + str += str[2] == '-' ? 3 : 2; + set = 0; + } + for (opt = JIT_F_OPT_FIRST; ; opt <<= 1) { + size_t len = *(const uint8_t *)lst; + if (len == 0) + break; + if (strncmp(str, lst+1, len) == 0 && str[len] == '\0') { + if (set) J->flags |= opt; else J->flags &= ~opt; + return 1; /* Ok. */ + } + lst += 1+len; + } + return 0; /* No match. */ +} + +/* Parse optimization parameter. */ +static int jitopt_param(jit_State *J, const char *str) +{ + const char *lst = JIT_P_STRING; + int i; + for (i = 0; i < JIT_P__MAX; i++) { + size_t len = *(const uint8_t *)lst; + lua_assert(len != 0); + if (strncmp(str, lst+1, len) == 0 && str[len] == '=') { + int32_t n = 0; + const char *p = &str[len+1]; + while (*p >= '0' && *p <= '9') + n = n*10 + (*p++ - '0'); + if (*p) return 0; /* Malformed number. */ + J->param[i] = n; + if (i == JIT_P_hotloop) + lj_dispatch_init_hotcount(J2G(J)); + return 1; /* Ok. */ + } + lst += 1+len; + } + return 0; /* No match. */ +} + +/* jit.opt.start(flags...) */ +LJLIB_CF(jit_opt_start) +{ + jit_State *J = L2J(L); + int nargs = (int)(L->top - L->base); + if (nargs == 0) { + J->flags = (J->flags & ~JIT_F_OPT_MASK) | JIT_F_OPT_DEFAULT; + } else { + int i; + for (i = 1; i <= nargs; i++) { + const char *str = strdata(lj_lib_checkstr(L, i)); + if (!jitopt_level(J, str) && + !jitopt_flag(J, str) && + !jitopt_param(J, str)) + lj_err_callerv(L, LJ_ERR_JITOPT, str); + } + } + return 0; +} + +#include "lj_libdef.h" + +#endif + +/* -- JIT compiler initialization ----------------------------------------- */ + +#if LJ_HASJIT +/* Default values for JIT parameters. */ +static const int32_t jit_param_default[JIT_P__MAX+1] = { +#define JIT_PARAMINIT(len, name, value) (value), +JIT_PARAMDEF(JIT_PARAMINIT) +#undef JIT_PARAMINIT + 0 +}; +#endif + +#if LJ_TARGET_ARM && LJ_TARGET_LINUX +#include +#endif + +/* Arch-dependent CPU detection. */ +static uint32_t jit_cpudetect(lua_State *L) +{ + uint32_t flags = 0; +#if LJ_TARGET_X86ORX64 + uint32_t vendor[4]; + uint32_t features[4]; + if (lj_vm_cpuid(0, vendor) && lj_vm_cpuid(1, features)) { +#if !LJ_HASJIT +#define JIT_F_CMOV 1 +#define JIT_F_SSE2 2 +#endif + flags |= ((features[3] >> 15)&1) * JIT_F_CMOV; + flags |= ((features[3] >> 26)&1) * JIT_F_SSE2; +#if LJ_HASJIT + flags |= ((features[2] >> 0)&1) * JIT_F_SSE3; + flags |= ((features[2] >> 19)&1) * JIT_F_SSE4_1; + if (vendor[2] == 0x6c65746e) { /* Intel. */ + if ((features[0] & 0x0ff00f00) == 0x00000f00) /* P4. */ + flags |= JIT_F_P4; /* Currently unused. */ + else if ((features[0] & 0x0fff0ff0) == 0x000106c0) /* Atom. */ + flags |= JIT_F_LEA_AGU; + } else if (vendor[2] == 0x444d4163) { /* AMD. */ + uint32_t fam = (features[0] & 0x0ff00f00); + if (fam == 0x00000f00) /* K8. */ + flags |= JIT_F_SPLIT_XMM; + if (fam >= 0x00000f00) /* K8, K10. */ + flags |= JIT_F_PREFER_IMUL; + } +#endif + } + /* Check for required instruction set support on x86 (unnecessary on x64). */ +#if LJ_TARGET_X86 +#if !defined(LUAJIT_CPU_NOCMOV) + if (!(flags & JIT_F_CMOV)) + luaL_error(L, "CPU not supported"); +#endif +#if defined(LUAJIT_CPU_SSE2) + if (!(flags & JIT_F_SSE2)) + luaL_error(L, "CPU does not support SSE2 (recompile without -DLUAJIT_CPU_SSE2)"); +#endif +#endif +#elif LJ_TARGET_ARM +#if LJ_HASJIT + int ver = LJ_ARCH_VERSION; /* Compile-time ARM CPU detection. */ +#if LJ_TARGET_LINUX + if (ver < 70) { /* Runtime ARM CPU detection. */ + struct utsname ut; + uname(&ut); + if (strncmp(ut.machine, "armv", 4) == 0) { + if (ut.machine[4] >= '7') + ver = 70; + else if (ut.machine[4] == '6') + ver = 60; + } + } +#endif + flags |= ver >= 70 ? JIT_F_ARMV7 : + ver >= 61 ? JIT_F_ARMV6T2_ : + ver >= 60 ? JIT_F_ARMV6_ : 0; + flags |= LJ_ARCH_HASFPU == 0 ? 0 : ver >= 70 ? JIT_F_VFPV3 : JIT_F_VFPV2; +#endif +#elif LJ_TARGET_PPC +#if LJ_HASJIT +#if LJ_ARCH_SQRT + flags |= JIT_F_SQRT; +#endif +#if LJ_ARCH_ROUND + flags |= JIT_F_ROUND; +#endif +#endif +#elif LJ_TARGET_PPCSPE + /* Nothing to do. */ +#elif LJ_TARGET_MIPS +#if LJ_HASJIT + /* Compile-time MIPS CPU detection. */ +#if LJ_ARCH_VERSION >= 20 + flags |= JIT_F_MIPS32R2; +#endif + /* Runtime MIPS CPU detection. */ +#if defined(__GNUC__) + if (!(flags & JIT_F_MIPS32R2)) { + int x; + /* On MIPS32R1 rotr is treated as srl. rotr r2,r2,1 -> srl r2,r2,1. */ + __asm__("li $2, 1\n\t.long 0x00221042\n\tmove %0, $2" : "=r"(x) : : "$2"); + if (x) flags |= JIT_F_MIPS32R2; /* Either 0x80000000 (R2) or 0 (R1). */ + } +#endif +#endif +#else +#error "Missing CPU detection for this architecture" +#endif + UNUSED(L); + return flags; +} + +/* Initialize JIT compiler. */ +static void jit_init(lua_State *L) +{ + uint32_t flags = jit_cpudetect(L); +#if LJ_HASJIT + jit_State *J = L2J(L); +#if LJ_TARGET_X86 + /* Silently turn off the JIT compiler on CPUs without SSE2. */ + if ((flags & JIT_F_SSE2)) +#endif + J->flags = flags | JIT_F_ON | JIT_F_OPT_DEFAULT; + memcpy(J->param, jit_param_default, sizeof(J->param)); + lj_dispatch_update(G(L)); +#else + UNUSED(flags); +#endif +} + +LUALIB_API int luaopen_jit(lua_State *L) +{ + lua_pushliteral(L, LJ_OS_NAME); + lua_pushliteral(L, LJ_ARCH_NAME); + lua_pushinteger(L, LUAJIT_VERSION_NUM); + lua_pushliteral(L, LUAJIT_VERSION); + LJ_LIB_REG(L, LUA_JITLIBNAME, jit); +#ifndef LUAJIT_DISABLE_JITUTIL + LJ_LIB_REG(L, "jit.util", jit_util); +#endif +#if LJ_HASJIT + LJ_LIB_REG(L, "jit.opt", jit_opt); +#endif + L->top -= 2; + jit_init(L); + return 1; +} + + +``` + +`include/luajit-2.0.5/src/lib_math.c`: + +```c +/* +** Math library. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include + +#define lib_math_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_lib.h" +#include "lj_vm.h" + +/* ------------------------------------------------------------------------ */ + +#define LJLIB_MODULE_math + +LJLIB_ASM(math_abs) LJLIB_REC(.) +{ + lj_lib_checknumber(L, 1); + return FFH_RETRY; +} +LJLIB_ASM_(math_floor) LJLIB_REC(math_round IRFPM_FLOOR) +LJLIB_ASM_(math_ceil) LJLIB_REC(math_round IRFPM_CEIL) + +LJLIB_ASM(math_sqrt) LJLIB_REC(math_unary IRFPM_SQRT) +{ + lj_lib_checknum(L, 1); + return FFH_RETRY; +} +LJLIB_ASM_(math_log10) LJLIB_REC(math_unary IRFPM_LOG10) +LJLIB_ASM_(math_exp) LJLIB_REC(math_unary IRFPM_EXP) +LJLIB_ASM_(math_sin) LJLIB_REC(math_unary IRFPM_SIN) +LJLIB_ASM_(math_cos) LJLIB_REC(math_unary IRFPM_COS) +LJLIB_ASM_(math_tan) LJLIB_REC(math_unary IRFPM_TAN) +LJLIB_ASM_(math_asin) LJLIB_REC(math_atrig FF_math_asin) +LJLIB_ASM_(math_acos) LJLIB_REC(math_atrig FF_math_acos) +LJLIB_ASM_(math_atan) LJLIB_REC(math_atrig FF_math_atan) +LJLIB_ASM_(math_sinh) LJLIB_REC(math_htrig IRCALL_sinh) +LJLIB_ASM_(math_cosh) LJLIB_REC(math_htrig IRCALL_cosh) +LJLIB_ASM_(math_tanh) LJLIB_REC(math_htrig IRCALL_tanh) +LJLIB_ASM_(math_frexp) +LJLIB_ASM_(math_modf) LJLIB_REC(.) + +LJLIB_PUSH(57.29577951308232) +LJLIB_ASM_(math_deg) LJLIB_REC(math_degrad) + +LJLIB_PUSH(0.017453292519943295) +LJLIB_ASM_(math_rad) LJLIB_REC(math_degrad) + +LJLIB_ASM(math_log) LJLIB_REC(math_log) +{ + double x = lj_lib_checknum(L, 1); + if (L->base+1 < L->top) { + double y = lj_lib_checknum(L, 2); +#ifdef LUAJIT_NO_LOG2 + x = log(x); y = 1.0 / log(y); +#else + x = lj_vm_log2(x); y = 1.0 / lj_vm_log2(y); +#endif + setnumV(L->base-1, x*y); /* Do NOT join the expression to x / y. */ + return FFH_RES(1); + } + return FFH_RETRY; +} + +LJLIB_ASM(math_atan2) LJLIB_REC(.) +{ + lj_lib_checknum(L, 1); + lj_lib_checknum(L, 2); + return FFH_RETRY; +} +LJLIB_ASM_(math_pow) LJLIB_REC(.) +LJLIB_ASM_(math_fmod) + +LJLIB_ASM(math_ldexp) LJLIB_REC(.) +{ + lj_lib_checknum(L, 1); +#if LJ_DUALNUM && !LJ_TARGET_X86ORX64 + lj_lib_checkint(L, 2); +#else + lj_lib_checknum(L, 2); +#endif + return FFH_RETRY; +} + +LJLIB_ASM(math_min) LJLIB_REC(math_minmax IR_MIN) +{ + int i = 0; + do { lj_lib_checknumber(L, ++i); } while (L->base+i < L->top); + return FFH_RETRY; +} +LJLIB_ASM_(math_max) LJLIB_REC(math_minmax IR_MAX) + +LJLIB_PUSH(3.14159265358979323846) LJLIB_SET(pi) +LJLIB_PUSH(1e310) LJLIB_SET(huge) + +/* ------------------------------------------------------------------------ */ + +/* This implements a Tausworthe PRNG with period 2^223. Based on: +** Tables of maximally-equidistributed combined LFSR generators, +** Pierre L'Ecuyer, 1991, table 3, 1st entry. +** Full-period ME-CF generator with L=64, J=4, k=223, N1=49. +*/ + +/* PRNG state. */ +struct RandomState { + uint64_t gen[4]; /* State of the 4 LFSR generators. */ + int valid; /* State is valid. */ +}; + +/* Union needed for bit-pattern conversion between uint64_t and double. */ +typedef union { uint64_t u64; double d; } U64double; + +/* Update generator i and compute a running xor of all states. */ +#define TW223_GEN(i, k, q, s) \ + z = rs->gen[i]; \ + z = (((z<> (k-s)) ^ ((z&((uint64_t)(int64_t)-1 << (64-k)))<gen[i] = z; + +/* PRNG step function. Returns a double in the range 1.0 <= d < 2.0. */ +LJ_NOINLINE uint64_t LJ_FASTCALL lj_math_random_step(RandomState *rs) +{ + uint64_t z, r = 0; + TW223_GEN(0, 63, 31, 18) + TW223_GEN(1, 58, 19, 28) + TW223_GEN(2, 55, 24, 7) + TW223_GEN(3, 47, 21, 8) + return (r & U64x(000fffff,ffffffff)) | U64x(3ff00000,00000000); +} + +/* PRNG initialization function. */ +static void random_init(RandomState *rs, double d) +{ + uint32_t r = 0x11090601; /* 64-k[i] as four 8 bit constants. */ + int i; + for (i = 0; i < 4; i++) { + U64double u; + uint32_t m = 1u << (r&255); + r >>= 8; + u.d = d = d * 3.14159265358979323846 + 2.7182818284590452354; + if (u.u64 < m) u.u64 += m; /* Ensure k[i] MSB of gen[i] are non-zero. */ + rs->gen[i] = u.u64; + } + rs->valid = 1; + for (i = 0; i < 10; i++) + lj_math_random_step(rs); +} + +/* PRNG extract function. */ +LJLIB_PUSH(top-2) /* Upvalue holds userdata with RandomState. */ +LJLIB_CF(math_random) LJLIB_REC(.) +{ + int n = (int)(L->top - L->base); + RandomState *rs = (RandomState *)(uddata(udataV(lj_lib_upvalue(L, 1)))); + U64double u; + double d; + if (LJ_UNLIKELY(!rs->valid)) random_init(rs, 0.0); + u.u64 = lj_math_random_step(rs); + d = u.d - 1.0; + if (n > 0) { +#if LJ_DUALNUM + int isint = 1; + double r1; + lj_lib_checknumber(L, 1); + if (tvisint(L->base)) { + r1 = (lua_Number)intV(L->base); + } else { + isint = 0; + r1 = numV(L->base); + } +#else + double r1 = lj_lib_checknum(L, 1); +#endif + if (n == 1) { + d = lj_vm_floor(d*r1) + 1.0; /* d is an int in range [1, r1] */ + } else { +#if LJ_DUALNUM + double r2; + lj_lib_checknumber(L, 2); + if (tvisint(L->base+1)) { + r2 = (lua_Number)intV(L->base+1); + } else { + isint = 0; + r2 = numV(L->base+1); + } +#else + double r2 = lj_lib_checknum(L, 2); +#endif + d = lj_vm_floor(d*(r2-r1+1.0)) + r1; /* d is an int in range [r1, r2] */ + } +#if LJ_DUALNUM + if (isint) { + setintV(L->top-1, lj_num2int(d)); + return 1; + } +#endif + } /* else: d is a double in range [0, 1] */ + setnumV(L->top++, d); + return 1; +} + +/* PRNG seed function. */ +LJLIB_PUSH(top-2) /* Upvalue holds userdata with RandomState. */ +LJLIB_CF(math_randomseed) +{ + RandomState *rs = (RandomState *)(uddata(udataV(lj_lib_upvalue(L, 1)))); + random_init(rs, lj_lib_checknum(L, 1)); + return 0; +} + +/* ------------------------------------------------------------------------ */ + +#include "lj_libdef.h" + +LUALIB_API int luaopen_math(lua_State *L) +{ + RandomState *rs; + rs = (RandomState *)lua_newuserdata(L, sizeof(RandomState)); + rs->valid = 0; /* Use lazy initialization to save some time on startup. */ + LJ_LIB_REG(L, LUA_MATHLIBNAME, math); +#if defined(LUA_COMPAT_MOD) && !LJ_52 + lua_getfield(L, -1, "fmod"); + lua_setfield(L, -2, "mod"); +#endif + return 1; +} + + +``` + +`include/luajit-2.0.5/src/lib_os.c`: + +```c +/* +** OS library. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#include +#include + +#define lib_os_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_lib.h" + +#if LJ_TARGET_POSIX +#include +#else +#include +#endif + +#if !LJ_TARGET_PSVITA +#include +#endif + +/* ------------------------------------------------------------------------ */ + +#define LJLIB_MODULE_os + +LJLIB_CF(os_execute) +{ +#if LJ_NO_SYSTEM +#if LJ_52 + errno = ENOSYS; + return luaL_fileresult(L, 0, NULL); +#else + lua_pushinteger(L, -1); + return 1; +#endif +#else + const char *cmd = luaL_optstring(L, 1, NULL); + int stat = system(cmd); +#if LJ_52 + if (cmd) + return luaL_execresult(L, stat); + setboolV(L->top++, 1); +#else + setintV(L->top++, stat); +#endif + return 1; +#endif +} + +LJLIB_CF(os_remove) +{ + const char *filename = luaL_checkstring(L, 1); + return luaL_fileresult(L, remove(filename) == 0, filename); +} + +LJLIB_CF(os_rename) +{ + const char *fromname = luaL_checkstring(L, 1); + const char *toname = luaL_checkstring(L, 2); + return luaL_fileresult(L, rename(fromname, toname) == 0, fromname); +} + +LJLIB_CF(os_tmpname) +{ +#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA + lj_err_caller(L, LJ_ERR_OSUNIQF); + return 0; +#else +#if LJ_TARGET_POSIX + char buf[15+1]; + int fp; + strcpy(buf, "/tmp/lua_XXXXXX"); + fp = mkstemp(buf); + if (fp != -1) + close(fp); + else + lj_err_caller(L, LJ_ERR_OSUNIQF); +#else + char buf[L_tmpnam]; + if (tmpnam(buf) == NULL) + lj_err_caller(L, LJ_ERR_OSUNIQF); +#endif + lua_pushstring(L, buf); + return 1; +#endif +} + +LJLIB_CF(os_getenv) +{ +#if LJ_TARGET_CONSOLE + lua_pushnil(L); +#else + lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ +#endif + return 1; +} + +LJLIB_CF(os_exit) +{ + int status; + if (L->base < L->top && tvisbool(L->base)) + status = boolV(L->base) ? EXIT_SUCCESS : EXIT_FAILURE; + else + status = lj_lib_optint(L, 1, EXIT_SUCCESS); + if (L->base+1 < L->top && tvistruecond(L->base+1)) + lua_close(L); + exit(status); + return 0; /* Unreachable. */ +} + +LJLIB_CF(os_clock) +{ + setnumV(L->top++, ((lua_Number)clock())*(1.0/(lua_Number)CLOCKS_PER_SEC)); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +static void setfield(lua_State *L, const char *key, int value) +{ + lua_pushinteger(L, value); + lua_setfield(L, -2, key); +} + +static void setboolfield(lua_State *L, const char *key, int value) +{ + if (value < 0) /* undefined? */ + return; /* does not set field */ + lua_pushboolean(L, value); + lua_setfield(L, -2, key); +} + +static int getboolfield(lua_State *L, const char *key) +{ + int res; + lua_getfield(L, -1, key); + res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1); + lua_pop(L, 1); + return res; +} + +static int getfield(lua_State *L, const char *key, int d) +{ + int res; + lua_getfield(L, -1, key); + if (lua_isnumber(L, -1)) { + res = (int)lua_tointeger(L, -1); + } else { + if (d < 0) + lj_err_callerv(L, LJ_ERR_OSDATEF, key); + res = d; + } + lua_pop(L, 1); + return res; +} + +LJLIB_CF(os_date) +{ + const char *s = luaL_optstring(L, 1, "%c"); + time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); + struct tm *stm; +#if LJ_TARGET_POSIX + struct tm rtm; +#endif + if (*s == '!') { /* UTC? */ + s++; /* Skip '!' */ +#if LJ_TARGET_POSIX + stm = gmtime_r(&t, &rtm); +#else + stm = gmtime(&t); +#endif + } else { +#if LJ_TARGET_POSIX + stm = localtime_r(&t, &rtm); +#else + stm = localtime(&t); +#endif + } + if (stm == NULL) { /* Invalid date? */ + setnilV(L->top-1); + } else if (strcmp(s, "*t") == 0) { + lua_createtable(L, 0, 9); /* 9 = number of fields */ + setfield(L, "sec", stm->tm_sec); + setfield(L, "min", stm->tm_min); + setfield(L, "hour", stm->tm_hour); + setfield(L, "day", stm->tm_mday); + setfield(L, "month", stm->tm_mon+1); + setfield(L, "year", stm->tm_year+1900); + setfield(L, "wday", stm->tm_wday+1); + setfield(L, "yday", stm->tm_yday+1); + setboolfield(L, "isdst", stm->tm_isdst); + } else { + char cc[3]; + luaL_Buffer b; + cc[0] = '%'; cc[2] = '\0'; + luaL_buffinit(L, &b); + for (; *s; s++) { + if (*s != '%' || *(s + 1) == '\0') { /* No conversion specifier? */ + luaL_addchar(&b, *s); + } else { + size_t reslen; + char buff[200]; /* Should be big enough for any conversion result. */ + cc[1] = *(++s); + reslen = strftime(buff, sizeof(buff), cc, stm); + luaL_addlstring(&b, buff, reslen); + } + } + luaL_pushresult(&b); + } + return 1; +} + +LJLIB_CF(os_time) +{ + time_t t; + if (lua_isnoneornil(L, 1)) { /* called without args? */ + t = time(NULL); /* get current time */ + } else { + struct tm ts; + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); /* make sure table is at the top */ + ts.tm_sec = getfield(L, "sec", 0); + ts.tm_min = getfield(L, "min", 0); + ts.tm_hour = getfield(L, "hour", 12); + ts.tm_mday = getfield(L, "day", -1); + ts.tm_mon = getfield(L, "month", -1) - 1; + ts.tm_year = getfield(L, "year", -1) - 1900; + ts.tm_isdst = getboolfield(L, "isdst"); + t = mktime(&ts); + } + if (t == (time_t)(-1)) + lua_pushnil(L); + else + lua_pushnumber(L, (lua_Number)t); + return 1; +} + +LJLIB_CF(os_difftime) +{ + lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), + (time_t)(luaL_optnumber(L, 2, (lua_Number)0)))); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +LJLIB_CF(os_setlocale) +{ +#if LJ_TARGET_PSVITA + lua_pushliteral(L, "C"); +#else + GCstr *s = lj_lib_optstr(L, 1); + const char *str = s ? strdata(s) : NULL; + int opt = lj_lib_checkopt(L, 2, 6, + "\5ctype\7numeric\4time\7collate\10monetary\1\377\3all"); + if (opt == 0) opt = LC_CTYPE; + else if (opt == 1) opt = LC_NUMERIC; + else if (opt == 2) opt = LC_TIME; + else if (opt == 3) opt = LC_COLLATE; + else if (opt == 4) opt = LC_MONETARY; + else if (opt == 6) opt = LC_ALL; + lua_pushstring(L, setlocale(opt, str)); +#endif + return 1; +} + +/* ------------------------------------------------------------------------ */ + +#include "lj_libdef.h" + +LUALIB_API int luaopen_os(lua_State *L) +{ + LJ_LIB_REG(L, LUA_OSLIBNAME, os); + return 1; +} + + +``` + +`include/luajit-2.0.5/src/lib_package.c`: + +```c +/* +** Package library. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2012 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lib_package_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_lib.h" + +/* ------------------------------------------------------------------------ */ + +/* Error codes for ll_loadfunc. */ +#define PACKAGE_ERR_LIB 1 +#define PACKAGE_ERR_FUNC 2 +#define PACKAGE_ERR_LOAD 3 + +/* Redefined in platform specific part. */ +#define PACKAGE_LIB_FAIL "open" +#define setprogdir(L) ((void)0) + +/* Symbol name prefixes. */ +#define SYMPREFIX_CF "luaopen_%s" +#define SYMPREFIX_BC "luaJIT_BC_%s" + +#if LJ_TARGET_DLOPEN + +#include + +static void ll_unloadlib(void *lib) +{ + dlclose(lib); +} + +static void *ll_load(lua_State *L, const char *path, int gl) +{ + void *lib = dlopen(path, RTLD_NOW | (gl ? RTLD_GLOBAL : RTLD_LOCAL)); + if (lib == NULL) lua_pushstring(L, dlerror()); + return lib; +} + +static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym) +{ + lua_CFunction f = (lua_CFunction)dlsym(lib, sym); + if (f == NULL) lua_pushstring(L, dlerror()); + return f; +} + +static const char *ll_bcsym(void *lib, const char *sym) +{ +#if defined(RTLD_DEFAULT) + if (lib == NULL) lib = RTLD_DEFAULT; +#elif LJ_TARGET_OSX || LJ_TARGET_BSD + if (lib == NULL) lib = (void *)(intptr_t)-2; +#endif + return (const char *)dlsym(lib, sym); +} + +#elif LJ_TARGET_WINDOWS + +#define WIN32_LEAN_AND_MEAN +#include + +#ifndef GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS +#define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 4 +#define GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT 2 +BOOL WINAPI GetModuleHandleExA(DWORD, LPCSTR, HMODULE*); +#endif + +#undef setprogdir + +static void setprogdir(lua_State *L) +{ + char buff[MAX_PATH + 1]; + char *lb; + DWORD nsize = sizeof(buff); + DWORD n = GetModuleFileNameA(NULL, buff, nsize); + if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) { + luaL_error(L, "unable to get ModuleFileName"); + } else { + *lb = '\0'; + luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); + lua_remove(L, -2); /* remove original string */ + } +} + +static void pusherror(lua_State *L) +{ + DWORD error = GetLastError(); + char buffer[128]; + if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error, 0, buffer, sizeof(buffer), NULL)) + lua_pushstring(L, buffer); + else + lua_pushfstring(L, "system error %d\n", error); +} + +static void ll_unloadlib(void *lib) +{ + FreeLibrary((HINSTANCE)lib); +} + +static void *ll_load(lua_State *L, const char *path, int gl) +{ + HINSTANCE lib = LoadLibraryA(path); + if (lib == NULL) pusherror(L); + UNUSED(gl); + return lib; +} + +static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym) +{ + lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym); + if (f == NULL) pusherror(L); + return f; +} + +static const char *ll_bcsym(void *lib, const char *sym) +{ + if (lib) { + return (const char *)GetProcAddress((HINSTANCE)lib, sym); + } else { + HINSTANCE h = GetModuleHandleA(NULL); + const char *p = (const char *)GetProcAddress(h, sym); + if (p == NULL && GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (const char *)ll_bcsym, &h)) + p = (const char *)GetProcAddress(h, sym); + return p; + } +} + +#else + +#undef PACKAGE_LIB_FAIL +#define PACKAGE_LIB_FAIL "absent" + +#define DLMSG "dynamic libraries not enabled; no support for target OS" + +static void ll_unloadlib(void *lib) +{ + UNUSED(lib); +} + +static void *ll_load(lua_State *L, const char *path, int gl) +{ + UNUSED(path); UNUSED(gl); + lua_pushliteral(L, DLMSG); + return NULL; +} + +static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym) +{ + UNUSED(lib); UNUSED(sym); + lua_pushliteral(L, DLMSG); + return NULL; +} + +static const char *ll_bcsym(void *lib, const char *sym) +{ + UNUSED(lib); UNUSED(sym); + return NULL; +} + +#endif + +/* ------------------------------------------------------------------------ */ + +static void **ll_register(lua_State *L, const char *path) +{ + void **plib; + lua_pushfstring(L, "LOADLIB: %s", path); + lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ + if (!lua_isnil(L, -1)) { /* is there an entry? */ + plib = (void **)lua_touserdata(L, -1); + } else { /* no entry yet; create one */ + lua_pop(L, 1); + plib = (void **)lua_newuserdata(L, sizeof(void *)); + *plib = NULL; + luaL_getmetatable(L, "_LOADLIB"); + lua_setmetatable(L, -2); + lua_pushfstring(L, "LOADLIB: %s", path); + lua_pushvalue(L, -2); + lua_settable(L, LUA_REGISTRYINDEX); + } + return plib; +} + +static const char *mksymname(lua_State *L, const char *modname, + const char *prefix) +{ + const char *funcname; + const char *mark = strchr(modname, *LUA_IGMARK); + if (mark) modname = mark + 1; + funcname = luaL_gsub(L, modname, ".", "_"); + funcname = lua_pushfstring(L, prefix, funcname); + lua_remove(L, -2); /* remove 'gsub' result */ + return funcname; +} + +static int ll_loadfunc(lua_State *L, const char *path, const char *name, int r) +{ + void **reg = ll_register(L, path); + if (*reg == NULL) *reg = ll_load(L, path, (*name == '*')); + if (*reg == NULL) { + return PACKAGE_ERR_LIB; /* Unable to load library. */ + } else if (*name == '*') { /* Only load library into global namespace. */ + lua_pushboolean(L, 1); + return 0; + } else { + const char *sym = r ? name : mksymname(L, name, SYMPREFIX_CF); + lua_CFunction f = ll_sym(L, *reg, sym); + if (f) { + lua_pushcfunction(L, f); + return 0; + } + if (!r) { + const char *bcdata = ll_bcsym(*reg, mksymname(L, name, SYMPREFIX_BC)); + lua_pop(L, 1); + if (bcdata) { + if (luaL_loadbuffer(L, bcdata, ~(size_t)0, name) != 0) + return PACKAGE_ERR_LOAD; + return 0; + } + } + return PACKAGE_ERR_FUNC; /* Unable to find function. */ + } +} + +static int lj_cf_package_loadlib(lua_State *L) +{ + const char *path = luaL_checkstring(L, 1); + const char *init = luaL_checkstring(L, 2); + int st = ll_loadfunc(L, path, init, 1); + if (st == 0) { /* no errors? */ + return 1; /* return the loaded function */ + } else { /* error; error message is on stack top */ + lua_pushnil(L); + lua_insert(L, -2); + lua_pushstring(L, (st == PACKAGE_ERR_LIB) ? PACKAGE_LIB_FAIL : "init"); + return 3; /* return nil, error message, and where */ + } +} + +static int lj_cf_package_unloadlib(lua_State *L) +{ + void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); + if (*lib) ll_unloadlib(*lib); + *lib = NULL; /* mark library as closed */ + return 0; +} + +/* ------------------------------------------------------------------------ */ + +static int readable(const char *filename) +{ + FILE *f = fopen(filename, "r"); /* try to open file */ + if (f == NULL) return 0; /* open failed */ + fclose(f); + return 1; +} + +static const char *pushnexttemplate(lua_State *L, const char *path) +{ + const char *l; + while (*path == *LUA_PATHSEP) path++; /* skip separators */ + if (*path == '\0') return NULL; /* no more templates */ + l = strchr(path, *LUA_PATHSEP); /* find next separator */ + if (l == NULL) l = path + strlen(path); + lua_pushlstring(L, path, (size_t)(l - path)); /* template */ + return l; +} + +static const char *searchpath (lua_State *L, const char *name, + const char *path, const char *sep, + const char *dirsep) +{ + luaL_Buffer msg; /* to build error message */ + luaL_buffinit(L, &msg); + if (*sep != '\0') /* non-empty separator? */ + name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */ + while ((path = pushnexttemplate(L, path)) != NULL) { + const char *filename = luaL_gsub(L, lua_tostring(L, -1), + LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ + if (readable(filename)) /* does file exist and is readable? */ + return filename; /* return that file name */ + lua_pushfstring(L, "\n\tno file " LUA_QS, filename); + lua_remove(L, -2); /* remove file name */ + luaL_addvalue(&msg); /* concatenate error msg. entry */ + } + luaL_pushresult(&msg); /* create error message */ + return NULL; /* not found */ +} + +static int lj_cf_package_searchpath(lua_State *L) +{ + const char *f = searchpath(L, luaL_checkstring(L, 1), + luaL_checkstring(L, 2), + luaL_optstring(L, 3, "."), + luaL_optstring(L, 4, LUA_DIRSEP)); + if (f != NULL) { + return 1; + } else { /* error message is on top of the stack */ + lua_pushnil(L); + lua_insert(L, -2); + return 2; /* return nil + error message */ + } +} + +static const char *findfile(lua_State *L, const char *name, + const char *pname) +{ + const char *path; + lua_getfield(L, LUA_ENVIRONINDEX, pname); + path = lua_tostring(L, -1); + if (path == NULL) + luaL_error(L, LUA_QL("package.%s") " must be a string", pname); + return searchpath(L, name, path, ".", LUA_DIRSEP); +} + +static void loaderror(lua_State *L, const char *filename) +{ + luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", + lua_tostring(L, 1), filename, lua_tostring(L, -1)); +} + +static int lj_cf_package_loader_lua(lua_State *L) +{ + const char *filename; + const char *name = luaL_checkstring(L, 1); + filename = findfile(L, name, "path"); + if (filename == NULL) return 1; /* library not found in this path */ + if (luaL_loadfile(L, filename) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + +static int lj_cf_package_loader_c(lua_State *L) +{ + const char *name = luaL_checkstring(L, 1); + const char *filename = findfile(L, name, "cpath"); + if (filename == NULL) return 1; /* library not found in this path */ + if (ll_loadfunc(L, filename, name, 0) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + +static int lj_cf_package_loader_croot(lua_State *L) +{ + const char *filename; + const char *name = luaL_checkstring(L, 1); + const char *p = strchr(name, '.'); + int st; + if (p == NULL) return 0; /* is root */ + lua_pushlstring(L, name, (size_t)(p - name)); + filename = findfile(L, lua_tostring(L, -1), "cpath"); + if (filename == NULL) return 1; /* root not found */ + if ((st = ll_loadfunc(L, filename, name, 0)) != 0) { + if (st != PACKAGE_ERR_FUNC) loaderror(L, filename); /* real error */ + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); + return 1; /* function not found */ + } + return 1; +} + +static int lj_cf_package_loader_preload(lua_State *L) +{ + const char *name = luaL_checkstring(L, 1); + lua_getfield(L, LUA_ENVIRONINDEX, "preload"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.preload") " must be a table"); + lua_getfield(L, -1, name); + if (lua_isnil(L, -1)) { /* Not found? */ + const char *bcname = mksymname(L, name, SYMPREFIX_BC); + const char *bcdata = ll_bcsym(NULL, bcname); + if (bcdata == NULL || luaL_loadbuffer(L, bcdata, ~(size_t)0, name) != 0) + lua_pushfstring(L, "\n\tno field package.preload['%s']", name); + } + return 1; +} + +/* ------------------------------------------------------------------------ */ + +static const int sentinel_ = 0; +#define sentinel ((void *)&sentinel_) + +static int lj_cf_package_require(lua_State *L) +{ + const char *name = luaL_checkstring(L, 1); + int i; + lua_settop(L, 1); /* _LOADED table will be at index 2 */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, 2, name); + if (lua_toboolean(L, -1)) { /* is it there? */ + if (lua_touserdata(L, -1) == sentinel) /* check loops */ + luaL_error(L, "loop or previous error loading module " LUA_QS, name); + return 1; /* package is already loaded */ + } + /* else must load it; iterate over available loaders */ + lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.loaders") " must be a table"); + lua_pushliteral(L, ""); /* error message accumulator */ + for (i = 1; ; i++) { + lua_rawgeti(L, -2, i); /* get a loader */ + if (lua_isnil(L, -1)) + luaL_error(L, "module " LUA_QS " not found:%s", + name, lua_tostring(L, -2)); + lua_pushstring(L, name); + lua_call(L, 1, 1); /* call it */ + if (lua_isfunction(L, -1)) /* did it find module? */ + break; /* module loaded successfully */ + else if (lua_isstring(L, -1)) /* loader returned error message? */ + lua_concat(L, 2); /* accumulate it */ + else + lua_pop(L, 1); + } + lua_pushlightuserdata(L, sentinel); + lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ + lua_pushstring(L, name); /* pass name as argument to module */ + lua_call(L, 1, 1); /* run loaded module */ + if (!lua_isnil(L, -1)) /* non-nil return? */ + lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ + lua_getfield(L, 2, name); + if (lua_touserdata(L, -1) == sentinel) { /* module did not set a value? */ + lua_pushboolean(L, 1); /* use true as result */ + lua_pushvalue(L, -1); /* extra copy to be returned */ + lua_setfield(L, 2, name); /* _LOADED[name] = true */ + } + lj_lib_checkfpu(L); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +static void setfenv(lua_State *L) +{ + lua_Debug ar; + if (lua_getstack(L, 1, &ar) == 0 || + lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ + lua_iscfunction(L, -1)) + luaL_error(L, LUA_QL("module") " not called from a Lua function"); + lua_pushvalue(L, -2); + lua_setfenv(L, -2); + lua_pop(L, 1); +} + +static void dooptions(lua_State *L, int n) +{ + int i; + for (i = 2; i <= n; i++) { + lua_pushvalue(L, i); /* get option (a function) */ + lua_pushvalue(L, -2); /* module */ + lua_call(L, 1, 0); + } +} + +static void modinit(lua_State *L, const char *modname) +{ + const char *dot; + lua_pushvalue(L, -1); + lua_setfield(L, -2, "_M"); /* module._M = module */ + lua_pushstring(L, modname); + lua_setfield(L, -2, "_NAME"); + dot = strrchr(modname, '.'); /* look for last dot in module name */ + if (dot == NULL) dot = modname; else dot++; + /* set _PACKAGE as package name (full module name minus last part) */ + lua_pushlstring(L, modname, (size_t)(dot - modname)); + lua_setfield(L, -2, "_PACKAGE"); +} + +static int lj_cf_package_module(lua_State *L) +{ + const char *modname = luaL_checkstring(L, 1); + int loaded = lua_gettop(L) + 1; /* index of _LOADED table */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, loaded, modname); /* get _LOADED[modname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL) + lj_err_callerv(L, LJ_ERR_BADMODN, modname); + lua_pushvalue(L, -1); + lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ + } + /* check whether table already has a _NAME field */ + lua_getfield(L, -1, "_NAME"); + if (!lua_isnil(L, -1)) { /* is table an initialized module? */ + lua_pop(L, 1); + } else { /* no; initialize it */ + lua_pop(L, 1); + modinit(L, modname); + } + lua_pushvalue(L, -1); + setfenv(L); + dooptions(L, loaded - 1); + return 0; +} + +static int lj_cf_package_seeall(lua_State *L) +{ + luaL_checktype(L, 1, LUA_TTABLE); + if (!lua_getmetatable(L, 1)) { + lua_createtable(L, 0, 1); /* create new metatable */ + lua_pushvalue(L, -1); + lua_setmetatable(L, 1); + } + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setfield(L, -2, "__index"); /* mt.__index = _G */ + return 0; +} + +/* ------------------------------------------------------------------------ */ + +#define AUXMARK "\1" + +static void setpath(lua_State *L, const char *fieldname, const char *envname, + const char *def, int noenv) +{ +#if LJ_TARGET_CONSOLE + const char *path = NULL; + UNUSED(envname); +#else + const char *path = getenv(envname); +#endif + if (path == NULL || noenv) { + lua_pushstring(L, def); + } else { + path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, + LUA_PATHSEP AUXMARK LUA_PATHSEP); + luaL_gsub(L, path, AUXMARK, def); + lua_remove(L, -2); + } + setprogdir(L); + lua_setfield(L, -2, fieldname); +} + +static const luaL_Reg package_lib[] = { + { "loadlib", lj_cf_package_loadlib }, + { "searchpath", lj_cf_package_searchpath }, + { "seeall", lj_cf_package_seeall }, + { NULL, NULL } +}; + +static const luaL_Reg package_global[] = { + { "module", lj_cf_package_module }, + { "require", lj_cf_package_require }, + { NULL, NULL } +}; + +static const lua_CFunction package_loaders[] = +{ + lj_cf_package_loader_preload, + lj_cf_package_loader_lua, + lj_cf_package_loader_c, + lj_cf_package_loader_croot, + NULL +}; + +LUALIB_API int luaopen_package(lua_State *L) +{ + int i; + int noenv; + luaL_newmetatable(L, "_LOADLIB"); + lj_lib_pushcf(L, lj_cf_package_unloadlib, 1); + lua_setfield(L, -2, "__gc"); + luaL_register(L, LUA_LOADLIBNAME, package_lib); + lua_pushvalue(L, -1); + lua_replace(L, LUA_ENVIRONINDEX); + lua_createtable(L, sizeof(package_loaders)/sizeof(package_loaders[0])-1, 0); + for (i = 0; package_loaders[i] != NULL; i++) { + lj_lib_pushcf(L, package_loaders[i], 1); + lua_rawseti(L, -2, i+1); + } + lua_setfield(L, -2, "loaders"); + lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); + noenv = lua_toboolean(L, -1); + lua_pop(L, 1); + setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT, noenv); + setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT, noenv); + lua_pushliteral(L, LUA_PATH_CONFIG); + lua_setfield(L, -2, "config"); + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 16); + lua_setfield(L, -2, "loaded"); + luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD", 4); + lua_setfield(L, -2, "preload"); + lua_pushvalue(L, LUA_GLOBALSINDEX); + luaL_register(L, NULL, package_global); + lua_pop(L, 1); + return 1; +} + + +``` + +`include/luajit-2.0.5/src/lib_string.c`: + +```c +/* +** String library. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#include + +#define lib_string_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_meta.h" +#include "lj_state.h" +#include "lj_ff.h" +#include "lj_bcdump.h" +#include "lj_char.h" +#include "lj_lib.h" + +/* ------------------------------------------------------------------------ */ + +#define LJLIB_MODULE_string + +LJLIB_ASM(string_len) LJLIB_REC(.) +{ + lj_lib_checkstr(L, 1); + return FFH_RETRY; +} + +LJLIB_ASM(string_byte) LJLIB_REC(string_range 0) +{ + GCstr *s = lj_lib_checkstr(L, 1); + int32_t len = (int32_t)s->len; + int32_t start = lj_lib_optint(L, 2, 1); + int32_t stop = lj_lib_optint(L, 3, start); + int32_t n, i; + const unsigned char *p; + if (stop < 0) stop += len+1; + if (start < 0) start += len+1; + if (start <= 0) start = 1; + if (stop > len) stop = len; + if (start > stop) return FFH_RES(0); /* Empty interval: return no results. */ + start--; + n = stop - start; + if ((uint32_t)n > LUAI_MAXCSTACK) + lj_err_caller(L, LJ_ERR_STRSLC); + lj_state_checkstack(L, (MSize)n); + p = (const unsigned char *)strdata(s) + start; + for (i = 0; i < n; i++) + setintV(L->base + i-1, p[i]); + return FFH_RES(n); +} + +LJLIB_ASM(string_char) +{ + int i, nargs = (int)(L->top - L->base); + char *buf = lj_str_needbuf(L, &G(L)->tmpbuf, (MSize)nargs); + for (i = 1; i <= nargs; i++) { + int32_t k = lj_lib_checkint(L, i); + if (!checku8(k)) + lj_err_arg(L, i, LJ_ERR_BADVAL); + buf[i-1] = (char)k; + } + setstrV(L, L->base-1, lj_str_new(L, buf, (size_t)nargs)); + return FFH_RES(1); +} + +LJLIB_ASM(string_sub) LJLIB_REC(string_range 1) +{ + lj_lib_checkstr(L, 1); + lj_lib_checkint(L, 2); + setintV(L->base+2, lj_lib_optint(L, 3, -1)); + return FFH_RETRY; +} + +LJLIB_ASM(string_rep) +{ + GCstr *s = lj_lib_checkstr(L, 1); + int32_t k = lj_lib_checkint(L, 2); + GCstr *sep = lj_lib_optstr(L, 3); + int32_t len = (int32_t)s->len; + global_State *g = G(L); + int64_t tlen; + const char *src; + char *buf; + if (k <= 0) { + empty: + setstrV(L, L->base-1, &g->strempty); + return FFH_RES(1); + } + if (sep) { + tlen = (int64_t)len + sep->len; + if (tlen > LJ_MAX_STR) + lj_err_caller(L, LJ_ERR_STROV); + tlen *= k; + if (tlen > LJ_MAX_STR) + lj_err_caller(L, LJ_ERR_STROV); + } else { + tlen = (int64_t)k * len; + if (tlen > LJ_MAX_STR) + lj_err_caller(L, LJ_ERR_STROV); + } + if (tlen == 0) goto empty; + buf = lj_str_needbuf(L, &g->tmpbuf, (MSize)tlen); + src = strdata(s); + if (sep) { + tlen -= sep->len; /* Ignore trailing separator. */ + if (k > 1) { /* Paste one string and one separator. */ + int32_t i; + i = 0; while (i < len) *buf++ = src[i++]; + src = strdata(sep); len = sep->len; + i = 0; while (i < len) *buf++ = src[i++]; + src = g->tmpbuf.buf; len += s->len; k--; /* Now copy that k-1 times. */ + } + } + do { + int32_t i = 0; + do { *buf++ = src[i++]; } while (i < len); + } while (--k > 0); + setstrV(L, L->base-1, lj_str_new(L, g->tmpbuf.buf, (size_t)tlen)); + return FFH_RES(1); +} + +LJLIB_ASM(string_reverse) +{ + GCstr *s = lj_lib_checkstr(L, 1); + lj_str_needbuf(L, &G(L)->tmpbuf, s->len); + return FFH_RETRY; +} +LJLIB_ASM_(string_lower) +LJLIB_ASM_(string_upper) + +/* ------------------------------------------------------------------------ */ + +static int writer_buf(lua_State *L, const void *p, size_t size, void *b) +{ + luaL_addlstring((luaL_Buffer *)b, (const char *)p, size); + UNUSED(L); + return 0; +} + +LJLIB_CF(string_dump) +{ + GCfunc *fn = lj_lib_checkfunc(L, 1); + int strip = L->base+1 < L->top && tvistruecond(L->base+1); + luaL_Buffer b; + L->top = L->base+1; + luaL_buffinit(L, &b); + if (!isluafunc(fn) || lj_bcwrite(L, funcproto(fn), writer_buf, &b, strip)) + lj_err_caller(L, LJ_ERR_STRDUMP); + luaL_pushresult(&b); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +/* macro to `unsign' a character */ +#define uchar(c) ((unsigned char)(c)) + +#define CAP_UNFINISHED (-1) +#define CAP_POSITION (-2) + +typedef struct MatchState { + const char *src_init; /* init of source string */ + const char *src_end; /* end (`\0') of source string */ + lua_State *L; + int level; /* total number of captures (finished or unfinished) */ + int depth; + struct { + const char *init; + ptrdiff_t len; + } capture[LUA_MAXCAPTURES]; +} MatchState; + +#define L_ESC '%' +#define SPECIALS "^$*+?.([%-" + +static int check_capture(MatchState *ms, int l) +{ + l -= '1'; + if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED) + lj_err_caller(ms->L, LJ_ERR_STRCAPI); + return l; +} + +static int capture_to_close(MatchState *ms) +{ + int level = ms->level; + for (level--; level>=0; level--) + if (ms->capture[level].len == CAP_UNFINISHED) return level; + lj_err_caller(ms->L, LJ_ERR_STRPATC); + return 0; /* unreachable */ +} + +static const char *classend(MatchState *ms, const char *p) +{ + switch (*p++) { + case L_ESC: + if (*p == '\0') + lj_err_caller(ms->L, LJ_ERR_STRPATE); + return p+1; + case '[': + if (*p == '^') p++; + do { /* look for a `]' */ + if (*p == '\0') + lj_err_caller(ms->L, LJ_ERR_STRPATM); + if (*(p++) == L_ESC && *p != '\0') + p++; /* skip escapes (e.g. `%]') */ + } while (*p != ']'); + return p+1; + default: + return p; + } +} + +static const unsigned char match_class_map[32] = { + 0,LJ_CHAR_ALPHA,0,LJ_CHAR_CNTRL,LJ_CHAR_DIGIT,0,0,LJ_CHAR_GRAPH,0,0,0,0, + LJ_CHAR_LOWER,0,0,0,LJ_CHAR_PUNCT,0,0,LJ_CHAR_SPACE,0, + LJ_CHAR_UPPER,0,LJ_CHAR_ALNUM,LJ_CHAR_XDIGIT,0,0,0,0,0,0,0 +}; + +static int match_class(int c, int cl) +{ + if ((cl & 0xc0) == 0x40) { + int t = match_class_map[(cl&0x1f)]; + if (t) { + t = lj_char_isa(c, t); + return (cl & 0x20) ? t : !t; + } + if (cl == 'z') return c == 0; + if (cl == 'Z') return c != 0; + } + return (cl == c); +} + +static int matchbracketclass(int c, const char *p, const char *ec) +{ + int sig = 1; + if (*(p+1) == '^') { + sig = 0; + p++; /* skip the `^' */ + } + while (++p < ec) { + if (*p == L_ESC) { + p++; + if (match_class(c, uchar(*p))) + return sig; + } + else if ((*(p+1) == '-') && (p+2 < ec)) { + p+=2; + if (uchar(*(p-2)) <= c && c <= uchar(*p)) + return sig; + } + else if (uchar(*p) == c) return sig; + } + return !sig; +} + +static int singlematch(int c, const char *p, const char *ep) +{ + switch (*p) { + case '.': return 1; /* matches any char */ + case L_ESC: return match_class(c, uchar(*(p+1))); + case '[': return matchbracketclass(c, p, ep-1); + default: return (uchar(*p) == c); + } +} + +static const char *match(MatchState *ms, const char *s, const char *p); + +static const char *matchbalance(MatchState *ms, const char *s, const char *p) +{ + if (*p == 0 || *(p+1) == 0) + lj_err_caller(ms->L, LJ_ERR_STRPATU); + if (*s != *p) { + return NULL; + } else { + int b = *p; + int e = *(p+1); + int cont = 1; + while (++s < ms->src_end) { + if (*s == e) { + if (--cont == 0) return s+1; + } else if (*s == b) { + cont++; + } + } + } + return NULL; /* string ends out of balance */ +} + +static const char *max_expand(MatchState *ms, const char *s, + const char *p, const char *ep) +{ + ptrdiff_t i = 0; /* counts maximum expand for item */ + while ((s+i)src_end && singlematch(uchar(*(s+i)), p, ep)) + i++; + /* keeps trying to match with the maximum repetitions */ + while (i>=0) { + const char *res = match(ms, (s+i), ep+1); + if (res) return res; + i--; /* else didn't match; reduce 1 repetition to try again */ + } + return NULL; +} + +static const char *min_expand(MatchState *ms, const char *s, + const char *p, const char *ep) +{ + for (;;) { + const char *res = match(ms, s, ep+1); + if (res != NULL) + return res; + else if (ssrc_end && singlematch(uchar(*s), p, ep)) + s++; /* try with one more repetition */ + else + return NULL; + } +} + +static const char *start_capture(MatchState *ms, const char *s, + const char *p, int what) +{ + const char *res; + int level = ms->level; + if (level >= LUA_MAXCAPTURES) lj_err_caller(ms->L, LJ_ERR_STRCAPN); + ms->capture[level].init = s; + ms->capture[level].len = what; + ms->level = level+1; + if ((res=match(ms, s, p)) == NULL) /* match failed? */ + ms->level--; /* undo capture */ + return res; +} + +static const char *end_capture(MatchState *ms, const char *s, + const char *p) +{ + int l = capture_to_close(ms); + const char *res; + ms->capture[l].len = s - ms->capture[l].init; /* close capture */ + if ((res = match(ms, s, p)) == NULL) /* match failed? */ + ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ + return res; +} + +static const char *match_capture(MatchState *ms, const char *s, int l) +{ + size_t len; + l = check_capture(ms, l); + len = (size_t)ms->capture[l].len; + if ((size_t)(ms->src_end-s) >= len && + memcmp(ms->capture[l].init, s, len) == 0) + return s+len; + else + return NULL; +} + +static const char *match(MatchState *ms, const char *s, const char *p) +{ + if (++ms->depth > LJ_MAX_XLEVEL) + lj_err_caller(ms->L, LJ_ERR_STRPATX); + init: /* using goto's to optimize tail recursion */ + switch (*p) { + case '(': /* start capture */ + if (*(p+1) == ')') /* position capture? */ + s = start_capture(ms, s, p+2, CAP_POSITION); + else + s = start_capture(ms, s, p+1, CAP_UNFINISHED); + break; + case ')': /* end capture */ + s = end_capture(ms, s, p+1); + break; + case L_ESC: + switch (*(p+1)) { + case 'b': /* balanced string? */ + s = matchbalance(ms, s, p+2); + if (s == NULL) break; + p+=4; + goto init; /* else s = match(ms, s, p+4); */ + case 'f': { /* frontier? */ + const char *ep; char previous; + p += 2; + if (*p != '[') + lj_err_caller(ms->L, LJ_ERR_STRPATB); + ep = classend(ms, p); /* points to what is next */ + previous = (s == ms->src_init) ? '\0' : *(s-1); + if (matchbracketclass(uchar(previous), p, ep-1) || + !matchbracketclass(uchar(*s), p, ep-1)) { s = NULL; break; } + p=ep; + goto init; /* else s = match(ms, s, ep); */ + } + default: + if (lj_char_isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ + s = match_capture(ms, s, uchar(*(p+1))); + if (s == NULL) break; + p+=2; + goto init; /* else s = match(ms, s, p+2) */ + } + goto dflt; /* case default */ + } + break; + case '\0': /* end of pattern */ + break; /* match succeeded */ + case '$': + /* is the `$' the last char in pattern? */ + if (*(p+1) != '\0') goto dflt; + if (s != ms->src_end) s = NULL; /* check end of string */ + break; + default: dflt: { /* it is a pattern item */ + const char *ep = classend(ms, p); /* points to what is next */ + int m = ssrc_end && singlematch(uchar(*s), p, ep); + switch (*ep) { + case '?': { /* optional */ + const char *res; + if (m && ((res=match(ms, s+1, ep+1)) != NULL)) { + s = res; + break; + } + p=ep+1; + goto init; /* else s = match(ms, s, ep+1); */ + } + case '*': /* 0 or more repetitions */ + s = max_expand(ms, s, p, ep); + break; + case '+': /* 1 or more repetitions */ + s = (m ? max_expand(ms, s+1, p, ep) : NULL); + break; + case '-': /* 0 or more repetitions (minimum) */ + s = min_expand(ms, s, p, ep); + break; + default: + if (m) { s++; p=ep; goto init; } /* else s = match(ms, s+1, ep); */ + s = NULL; + break; + } + break; + } + } + ms->depth--; + return s; +} + +static const char *lmemfind(const char *s1, size_t l1, + const char *s2, size_t l2) +{ + if (l2 == 0) { + return s1; /* empty strings are everywhere */ + } else if (l2 > l1) { + return NULL; /* avoids a negative `l1' */ + } else { + const char *init; /* to search for a `*s2' inside `s1' */ + l2--; /* 1st char will be checked by `memchr' */ + l1 = l1-l2; /* `s2' cannot be found after that */ + while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { + init++; /* 1st char is already checked */ + if (memcmp(init, s2+1, l2) == 0) { + return init-1; + } else { /* correct `l1' and `s1' to try again */ + l1 -= (size_t)(init-s1); + s1 = init; + } + } + return NULL; /* not found */ + } +} + +static void push_onecapture(MatchState *ms, int i, const char *s, const char *e) +{ + if (i >= ms->level) { + if (i == 0) /* ms->level == 0, too */ + lua_pushlstring(ms->L, s, (size_t)(e - s)); /* add whole match */ + else + lj_err_caller(ms->L, LJ_ERR_STRCAPI); + } else { + ptrdiff_t l = ms->capture[i].len; + if (l == CAP_UNFINISHED) lj_err_caller(ms->L, LJ_ERR_STRCAPU); + if (l == CAP_POSITION) + lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); + else + lua_pushlstring(ms->L, ms->capture[i].init, (size_t)l); + } +} + +static int push_captures(MatchState *ms, const char *s, const char *e) +{ + int i; + int nlevels = (ms->level == 0 && s) ? 1 : ms->level; + luaL_checkstack(ms->L, nlevels, "too many captures"); + for (i = 0; i < nlevels; i++) + push_onecapture(ms, i, s, e); + return nlevels; /* number of strings pushed */ +} + +static ptrdiff_t posrelat(ptrdiff_t pos, size_t len) +{ + /* relative string position: negative means back from end */ + if (pos < 0) pos += (ptrdiff_t)len + 1; + return (pos >= 0) ? pos : 0; +} + +static int str_find_aux(lua_State *L, int find) +{ + size_t l1, l2; + const char *s = luaL_checklstring(L, 1, &l1); + const char *p = luaL_checklstring(L, 2, &l2); + ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; + if (init < 0) { + init = 0; + } else if ((size_t)(init) > l1) { +#if LJ_52 + setnilV(L->top-1); + return 1; +#else + init = (ptrdiff_t)l1; +#endif + } + if (find && (lua_toboolean(L, 4) || /* explicit request? */ + strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ + /* do a plain search */ + const char *s2 = lmemfind(s+init, l1-(size_t)init, p, l2); + if (s2) { + lua_pushinteger(L, s2-s+1); + lua_pushinteger(L, s2-s+(ptrdiff_t)l2); + return 2; + } + } else { + MatchState ms; + int anchor = (*p == '^') ? (p++, 1) : 0; + const char *s1=s+init; + ms.L = L; + ms.src_init = s; + ms.src_end = s+l1; + do { + const char *res; + ms.level = ms.depth = 0; + if ((res=match(&ms, s1, p)) != NULL) { + if (find) { + lua_pushinteger(L, s1-s+1); /* start */ + lua_pushinteger(L, res-s); /* end */ + return push_captures(&ms, NULL, 0) + 2; + } else { + return push_captures(&ms, s1, res); + } + } + } while (s1++ < ms.src_end && !anchor); + } + lua_pushnil(L); /* not found */ + return 1; +} + +LJLIB_CF(string_find) +{ + return str_find_aux(L, 1); +} + +LJLIB_CF(string_match) +{ + return str_find_aux(L, 0); +} + +LJLIB_NOREG LJLIB_CF(string_gmatch_aux) +{ + const char *p = strVdata(lj_lib_upvalue(L, 2)); + GCstr *str = strV(lj_lib_upvalue(L, 1)); + const char *s = strdata(str); + TValue *tvpos = lj_lib_upvalue(L, 3); + const char *src = s + tvpos->u32.lo; + MatchState ms; + ms.L = L; + ms.src_init = s; + ms.src_end = s + str->len; + for (; src <= ms.src_end; src++) { + const char *e; + ms.level = ms.depth = 0; + if ((e = match(&ms, src, p)) != NULL) { + int32_t pos = (int32_t)(e - s); + if (e == src) pos++; /* Ensure progress for empty match. */ + tvpos->u32.lo = (uint32_t)pos; + return push_captures(&ms, src, e); + } + } + return 0; /* not found */ +} + +LJLIB_CF(string_gmatch) +{ + lj_lib_checkstr(L, 1); + lj_lib_checkstr(L, 2); + L->top = L->base+3; + (L->top-1)->u64 = 0; + lj_lib_pushcc(L, lj_cf_string_gmatch_aux, FF_string_gmatch_aux, 3); + return 1; +} + +static void add_s(MatchState *ms, luaL_Buffer *b, const char *s, const char *e) +{ + size_t l, i; + const char *news = lua_tolstring(ms->L, 3, &l); + for (i = 0; i < l; i++) { + if (news[i] != L_ESC) { + luaL_addchar(b, news[i]); + } else { + i++; /* skip ESC */ + if (!lj_char_isdigit(uchar(news[i]))) { + luaL_addchar(b, news[i]); + } else if (news[i] == '0') { + luaL_addlstring(b, s, (size_t)(e - s)); + } else { + push_onecapture(ms, news[i] - '1', s, e); + luaL_addvalue(b); /* add capture to accumulated result */ + } + } + } +} + +static void add_value(MatchState *ms, luaL_Buffer *b, + const char *s, const char *e) +{ + lua_State *L = ms->L; + switch (lua_type(L, 3)) { + case LUA_TNUMBER: + case LUA_TSTRING: { + add_s(ms, b, s, e); + return; + } + case LUA_TFUNCTION: { + int n; + lua_pushvalue(L, 3); + n = push_captures(ms, s, e); + lua_call(L, n, 1); + break; + } + case LUA_TTABLE: { + push_onecapture(ms, 0, s, e); + lua_gettable(L, 3); + break; + } + } + if (!lua_toboolean(L, -1)) { /* nil or false? */ + lua_pop(L, 1); + lua_pushlstring(L, s, (size_t)(e - s)); /* keep original text */ + } else if (!lua_isstring(L, -1)) { + lj_err_callerv(L, LJ_ERR_STRGSRV, luaL_typename(L, -1)); + } + luaL_addvalue(b); /* add result to accumulator */ +} + +LJLIB_CF(string_gsub) +{ + size_t srcl; + const char *src = luaL_checklstring(L, 1, &srcl); + const char *p = luaL_checkstring(L, 2); + int tr = lua_type(L, 3); + int max_s = luaL_optint(L, 4, (int)(srcl+1)); + int anchor = (*p == '^') ? (p++, 1) : 0; + int n = 0; + MatchState ms; + luaL_Buffer b; + if (!(tr == LUA_TNUMBER || tr == LUA_TSTRING || + tr == LUA_TFUNCTION || tr == LUA_TTABLE)) + lj_err_arg(L, 3, LJ_ERR_NOSFT); + luaL_buffinit(L, &b); + ms.L = L; + ms.src_init = src; + ms.src_end = src+srcl; + while (n < max_s) { + const char *e; + ms.level = ms.depth = 0; + e = match(&ms, src, p); + if (e) { + n++; + add_value(&ms, &b, src, e); + } + if (e && e>src) /* non empty match? */ + src = e; /* skip it */ + else if (src < ms.src_end) + luaL_addchar(&b, *src++); + else + break; + if (anchor) + break; + } + luaL_addlstring(&b, src, (size_t)(ms.src_end-src)); + luaL_pushresult(&b); + lua_pushinteger(L, n); /* number of substitutions */ + return 2; +} + +/* ------------------------------------------------------------------------ */ + +/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ +#define MAX_FMTITEM 512 +/* valid flags in a format specification */ +#define FMT_FLAGS "-+ #0" +/* +** maximum size of each format specification (such as '%-099.99d') +** (+10 accounts for %99.99x plus margin of error) +*/ +#define MAX_FMTSPEC (sizeof(FMT_FLAGS) + sizeof(LUA_INTFRMLEN) + 10) + +static void addquoted(lua_State *L, luaL_Buffer *b, int arg) +{ + GCstr *str = lj_lib_checkstr(L, arg); + int32_t len = (int32_t)str->len; + const char *s = strdata(str); + luaL_addchar(b, '"'); + while (len--) { + uint32_t c = uchar(*s); + if (c == '"' || c == '\\' || c == '\n') { + luaL_addchar(b, '\\'); + } else if (lj_char_iscntrl(c)) { /* This can only be 0-31 or 127. */ + uint32_t d; + luaL_addchar(b, '\\'); + if (c >= 100 || lj_char_isdigit(uchar(s[1]))) { + luaL_addchar(b, '0'+(c >= 100)); if (c >= 100) c -= 100; + goto tens; + } else if (c >= 10) { + tens: + d = (c * 205) >> 11; c -= d * 10; luaL_addchar(b, '0'+d); + } + c += '0'; + } + luaL_addchar(b, c); + s++; + } + luaL_addchar(b, '"'); +} + +static const char *scanformat(lua_State *L, const char *strfrmt, char *form) +{ + const char *p = strfrmt; + while (*p != '\0' && strchr(FMT_FLAGS, *p) != NULL) p++; /* skip flags */ + if ((size_t)(p - strfrmt) >= sizeof(FMT_FLAGS)) + lj_err_caller(L, LJ_ERR_STRFMTR); + if (lj_char_isdigit(uchar(*p))) p++; /* skip width */ + if (lj_char_isdigit(uchar(*p))) p++; /* (2 digits at most) */ + if (*p == '.') { + p++; + if (lj_char_isdigit(uchar(*p))) p++; /* skip precision */ + if (lj_char_isdigit(uchar(*p))) p++; /* (2 digits at most) */ + } + if (lj_char_isdigit(uchar(*p))) + lj_err_caller(L, LJ_ERR_STRFMTW); + *(form++) = '%'; + strncpy(form, strfrmt, (size_t)(p - strfrmt + 1)); + form += p - strfrmt + 1; + *form = '\0'; + return p; +} + +static void addintlen(char *form) +{ + size_t l = strlen(form); + char spec = form[l - 1]; + strcpy(form + l - 1, LUA_INTFRMLEN); + form[l + sizeof(LUA_INTFRMLEN) - 2] = spec; + form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0'; +} + +static unsigned LUA_INTFRM_T num2intfrm(lua_State *L, int arg) +{ + if (sizeof(LUA_INTFRM_T) == 4) { + return (LUA_INTFRM_T)lj_lib_checkbit(L, arg); + } else { + cTValue *o; + lj_lib_checknumber(L, arg); + o = L->base+arg-1; + if (tvisint(o)) + return (LUA_INTFRM_T)intV(o); + else + return (LUA_INTFRM_T)numV(o); + } +} + +static unsigned LUA_INTFRM_T num2uintfrm(lua_State *L, int arg) +{ + if (sizeof(LUA_INTFRM_T) == 4) { + return (unsigned LUA_INTFRM_T)lj_lib_checkbit(L, arg); + } else { + cTValue *o; + lj_lib_checknumber(L, arg); + o = L->base+arg-1; + if (tvisint(o)) + return (unsigned LUA_INTFRM_T)intV(o); + else if ((int32_t)o->u32.hi < 0) + return (unsigned LUA_INTFRM_T)(LUA_INTFRM_T)numV(o); + else + return (unsigned LUA_INTFRM_T)numV(o); + } +} + +static GCstr *meta_tostring(lua_State *L, int arg) +{ + TValue *o = L->base+arg-1; + cTValue *mo; + lua_assert(o < L->top); /* Caller already checks for existence. */ + if (LJ_LIKELY(tvisstr(o))) + return strV(o); + if (!tvisnil(mo = lj_meta_lookup(L, o, MM_tostring))) { + copyTV(L, L->top++, mo); + copyTV(L, L->top++, o); + lua_call(L, 1, 1); + L->top--; + if (tvisstr(L->top)) + return strV(L->top); + o = L->base+arg-1; + copyTV(L, o, L->top); + } + if (tvisnumber(o)) { + return lj_str_fromnumber(L, o); + } else if (tvisnil(o)) { + return lj_str_newlit(L, "nil"); + } else if (tvisfalse(o)) { + return lj_str_newlit(L, "false"); + } else if (tvistrue(o)) { + return lj_str_newlit(L, "true"); + } else { + if (tvisfunc(o) && isffunc(funcV(o))) + lj_str_pushf(L, "function: builtin#%d", funcV(o)->c.ffid); + else + lj_str_pushf(L, "%s: %p", lj_typename(o), lua_topointer(L, arg)); + L->top--; + return strV(L->top); + } +} + +LJLIB_CF(string_format) +{ + int arg = 1, top = (int)(L->top - L->base); + GCstr *fmt = lj_lib_checkstr(L, arg); + const char *strfrmt = strdata(fmt); + const char *strfrmt_end = strfrmt + fmt->len; + luaL_Buffer b; + luaL_buffinit(L, &b); + while (strfrmt < strfrmt_end) { + if (*strfrmt != L_ESC) { + luaL_addchar(&b, *strfrmt++); + } else if (*++strfrmt == L_ESC) { + luaL_addchar(&b, *strfrmt++); /* %% */ + } else { /* format item */ + char form[MAX_FMTSPEC]; /* to store the format (`%...') */ + char buff[MAX_FMTITEM]; /* to store the formatted item */ + if (++arg > top) + luaL_argerror(L, arg, lj_obj_typename[0]); + strfrmt = scanformat(L, strfrmt, form); + switch (*strfrmt++) { + case 'c': + sprintf(buff, form, lj_lib_checkint(L, arg)); + break; + case 'd': case 'i': + addintlen(form); + sprintf(buff, form, num2intfrm(L, arg)); + break; + case 'o': case 'u': case 'x': case 'X': + addintlen(form); + sprintf(buff, form, num2uintfrm(L, arg)); + break; + case 'e': case 'E': case 'f': case 'g': case 'G': case 'a': case 'A': { + TValue tv; + tv.n = lj_lib_checknum(L, arg); + if (LJ_UNLIKELY((tv.u32.hi << 1) >= 0xffe00000)) { + /* Canonicalize output of non-finite values. */ + char *p, nbuf[LJ_STR_NUMBUF]; + size_t len = lj_str_bufnum(nbuf, &tv); + if (strfrmt[-1] < 'a') { + nbuf[len-3] = nbuf[len-3] - 0x20; + nbuf[len-2] = nbuf[len-2] - 0x20; + nbuf[len-1] = nbuf[len-1] - 0x20; + } + nbuf[len] = '\0'; + for (p = form; *p < 'A' && *p != '.'; p++) ; + *p++ = 's'; *p = '\0'; + sprintf(buff, form, nbuf); + break; + } + sprintf(buff, form, (double)tv.n); + break; + } + case 'q': + addquoted(L, &b, arg); + continue; + case 'p': + lj_str_pushf(L, "%p", lua_topointer(L, arg)); + luaL_addvalue(&b); + continue; + case 's': { + GCstr *str = meta_tostring(L, arg); + if (!strchr(form, '.') && str->len >= 100) { + /* no precision and string is too long to be formatted; + keep original string */ + setstrV(L, L->top++, str); + luaL_addvalue(&b); + continue; + } + sprintf(buff, form, strdata(str)); + break; + } + default: + lj_err_callerv(L, LJ_ERR_STRFMTO, *(strfrmt -1)); + break; + } + luaL_addlstring(&b, buff, strlen(buff)); + } + } + luaL_pushresult(&b); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +#include "lj_libdef.h" + +LUALIB_API int luaopen_string(lua_State *L) +{ + GCtab *mt; + global_State *g; + LJ_LIB_REG(L, LUA_STRLIBNAME, string); +#if defined(LUA_COMPAT_GFIND) && !LJ_52 + lua_getfield(L, -1, "gmatch"); + lua_setfield(L, -2, "gfind"); +#endif + mt = lj_tab_new(L, 0, 1); + /* NOBARRIER: basemt is a GC root. */ + g = G(L); + setgcref(basemt_it(g, LJ_TSTR), obj2gco(mt)); + settabV(L, lj_tab_setstr(L, mt, mmname_str(g, MM_index)), tabV(L->top-1)); + mt->nomm = (uint8_t)(~(1u<top, func); + setintV(L->top+1, i); + val = lj_tab_getint(t, (int32_t)i); + if (val) { copyTV(L, L->top+2, val); } else { setnilV(L->top+2); } + L->top += 3; + lua_call(L, 2, 1); + if (!tvisnil(L->top-1)) + return 1; + L->top--; + } + return 0; +} + +LJLIB_CF(table_foreach) +{ + GCtab *t = lj_lib_checktab(L, 1); + GCfunc *func = lj_lib_checkfunc(L, 2); + L->top = L->base+3; + setnilV(L->top-1); + while (lj_tab_next(L, t, L->top-1)) { + copyTV(L, L->top+2, L->top); + copyTV(L, L->top+1, L->top-1); + setfuncV(L, L->top, func); + L->top += 3; + lua_call(L, 2, 1); + if (!tvisnil(L->top-1)) + return 1; + L->top--; + } + return 0; +} + +LJLIB_ASM(table_getn) LJLIB_REC(.) +{ + lj_lib_checktab(L, 1); + return FFH_UNREACHABLE; +} + +LJLIB_CF(table_maxn) +{ + GCtab *t = lj_lib_checktab(L, 1); + TValue *array = tvref(t->array); + Node *node; + lua_Number m = 0; + ptrdiff_t i; + for (i = (ptrdiff_t)t->asize - 1; i >= 0; i--) + if (!tvisnil(&array[i])) { + m = (lua_Number)(int32_t)i; + break; + } + node = noderef(t->node); + for (i = (ptrdiff_t)t->hmask; i >= 0; i--) + if (!tvisnil(&node[i].val) && tvisnumber(&node[i].key)) { + lua_Number n = numberVnum(&node[i].key); + if (n > m) m = n; + } + setnumV(L->top-1, m); + return 1; +} + +LJLIB_CF(table_insert) LJLIB_REC(.) +{ + GCtab *t = lj_lib_checktab(L, 1); + int32_t n, i = (int32_t)lj_tab_len(t) + 1; + int nargs = (int)((char *)L->top - (char *)L->base); + if (nargs != 2*sizeof(TValue)) { + if (nargs != 3*sizeof(TValue)) + lj_err_caller(L, LJ_ERR_TABINS); + /* NOBARRIER: This just moves existing elements around. */ + for (n = lj_lib_checkint(L, 2); i > n; i--) { + /* The set may invalidate the get pointer, so need to do it first! */ + TValue *dst = lj_tab_setint(L, t, i); + cTValue *src = lj_tab_getint(t, i-1); + if (src) { + copyTV(L, dst, src); + } else { + setnilV(dst); + } + } + i = n; + } + { + TValue *dst = lj_tab_setint(L, t, i); + copyTV(L, dst, L->top-1); /* Set new value. */ + lj_gc_barriert(L, t, dst); + } + return 0; +} + +LJLIB_CF(table_remove) LJLIB_REC(.) +{ + GCtab *t = lj_lib_checktab(L, 1); + int32_t e = (int32_t)lj_tab_len(t); + int32_t pos = lj_lib_optint(L, 2, e); + if (!(1 <= pos && pos <= e)) /* Nothing to remove? */ + return 0; + lua_rawgeti(L, 1, pos); /* Get previous value. */ + /* NOBARRIER: This just moves existing elements around. */ + for (; pos < e; pos++) { + cTValue *src = lj_tab_getint(t, pos+1); + TValue *dst = lj_tab_setint(L, t, pos); + if (src) { + copyTV(L, dst, src); + } else { + setnilV(dst); + } + } + setnilV(lj_tab_setint(L, t, e)); /* Remove (last) value. */ + return 1; /* Return previous value. */ +} + +LJLIB_CF(table_concat) +{ + luaL_Buffer b; + GCtab *t = lj_lib_checktab(L, 1); + GCstr *sep = lj_lib_optstr(L, 2); + MSize seplen = sep ? sep->len : 0; + int32_t i = lj_lib_optint(L, 3, 1); + int32_t e = (L->base+3 < L->top && !tvisnil(L->base+3)) ? + lj_lib_checkint(L, 4) : (int32_t)lj_tab_len(t); + luaL_buffinit(L, &b); + if (i <= e) { + for (;;) { + cTValue *o; + lua_rawgeti(L, 1, i); + o = L->top-1; + if (!(tvisstr(o) || tvisnumber(o))) + lj_err_callerv(L, LJ_ERR_TABCAT, lj_typename(o), i); + luaL_addvalue(&b); + if (i++ == e) break; + if (seplen) + luaL_addlstring(&b, strdata(sep), seplen); + } + } + luaL_pushresult(&b); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +static void set2(lua_State *L, int i, int j) +{ + lua_rawseti(L, 1, i); + lua_rawseti(L, 1, j); +} + +static int sort_comp(lua_State *L, int a, int b) +{ + if (!lua_isnil(L, 2)) { /* function? */ + int res; + lua_pushvalue(L, 2); + lua_pushvalue(L, a-1); /* -1 to compensate function */ + lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */ + lua_call(L, 2, 1); + res = lua_toboolean(L, -1); + lua_pop(L, 1); + return res; + } else { /* a < b? */ + return lua_lessthan(L, a, b); + } +} + +static void auxsort(lua_State *L, int l, int u) +{ + while (l < u) { /* for tail recursion */ + int i, j; + /* sort elements a[l], a[(l+u)/2] and a[u] */ + lua_rawgeti(L, 1, l); + lua_rawgeti(L, 1, u); + if (sort_comp(L, -1, -2)) /* a[u] < a[l]? */ + set2(L, l, u); /* swap a[l] - a[u] */ + else + lua_pop(L, 2); + if (u-l == 1) break; /* only 2 elements */ + i = (l+u)/2; + lua_rawgeti(L, 1, i); + lua_rawgeti(L, 1, l); + if (sort_comp(L, -2, -1)) { /* a[i]= P */ + while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { + if (i>=u) lj_err_caller(L, LJ_ERR_TABSORT); + lua_pop(L, 1); /* remove a[i] */ + } + /* repeat --j until a[j] <= P */ + while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { + if (j<=l) lj_err_caller(L, LJ_ERR_TABSORT); + lua_pop(L, 1); /* remove a[j] */ + } + if (jbase+1)) + lj_lib_checkfunc(L, 2); + auxsort(L, 1, n); + return 0; +} + +#if LJ_52 +LJLIB_PUSH("n") +LJLIB_CF(table_pack) +{ + TValue *array, *base = L->base; + MSize i, n = (uint32_t)(L->top - base); + GCtab *t = lj_tab_new(L, n ? n+1 : 0, 1); + /* NOBARRIER: The table is new (marked white). */ + setintV(lj_tab_setstr(L, t, strV(lj_lib_upvalue(L, 1))), (int32_t)n); + for (array = tvref(t->array) + 1, i = 0; i < n; i++) + copyTV(L, &array[i], &base[i]); + settabV(L, base, t); + L->top = base+1; + lj_gc_check(L); + return 1; +} +#endif + +/* ------------------------------------------------------------------------ */ + +#include "lj_libdef.h" + +LUALIB_API int luaopen_table(lua_State *L) +{ + LJ_LIB_REG(L, LUA_TABLIBNAME, table); +#if LJ_52 + lua_getglobal(L, "unpack"); + lua_setfield(L, -2, "unpack"); +#endif + return 1; +} + + +``` + +`include/luajit-2.0.5/src/lj.supp`: + +```supp +# Valgrind suppression file for LuaJIT 2.0. +{ + Optimized string compare + Memcheck:Addr4 + fun:lj_str_cmp +} +{ + Optimized string compare + Memcheck:Addr1 + fun:lj_str_cmp +} +{ + Optimized string compare + Memcheck:Addr4 + fun:lj_str_new +} +{ + Optimized string compare + Memcheck:Addr1 + fun:lj_str_new +} +{ + Optimized string compare + Memcheck:Cond + fun:lj_str_new +} +{ + Optimized string compare + Memcheck:Addr4 + fun:str_fastcmp +} +{ + Optimized string compare + Memcheck:Addr1 + fun:str_fastcmp +} +{ + Optimized string compare + Memcheck:Cond + fun:str_fastcmp +} + +``` + +`include/luajit-2.0.5/src/lj_alloc.c`: + +```c +/* +** Bundled memory allocator. +** +** Beware: this is a HEAVILY CUSTOMIZED version of dlmalloc. +** The original bears the following remark: +** +** This is a version (aka dlmalloc) of malloc/free/realloc written by +** Doug Lea and released to the public domain, as explained at +** http://creativecommons.org/licenses/publicdomain. +** +** * Version pre-2.8.4 Wed Mar 29 19:46:29 2006 (dl at gee) +** +** No additional copyright is claimed over the customizations. +** Please do NOT bother the original author about this version here! +** +** If you want to use dlmalloc in another project, you should get +** the original from: ftp://gee.cs.oswego.edu/pub/misc/ +** For thread-safe derivatives, take a look at: +** - ptmalloc: http://www.malloc.de/ +** - nedmalloc: http://www.nedprod.com/programs/portable/nedmalloc/ +*/ + +#define lj_alloc_c +#define LUA_CORE + +/* To get the mremap prototype. Must be defined before any system includes. */ +#if defined(__linux__) && !defined(_GNU_SOURCE) +#define _GNU_SOURCE +#endif + +#include "lj_def.h" +#include "lj_arch.h" +#include "lj_alloc.h" + +#ifndef LUAJIT_USE_SYSMALLOC + +#define MAX_SIZE_T (~(size_t)0) +#define MALLOC_ALIGNMENT ((size_t)8U) + +#define DEFAULT_GRANULARITY ((size_t)128U * (size_t)1024U) +#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) +#define DEFAULT_MMAP_THRESHOLD ((size_t)128U * (size_t)1024U) +#define MAX_RELEASE_CHECK_RATE 255 + +/* ------------------- size_t and alignment properties -------------------- */ + +/* The byte and bit size of a size_t */ +#define SIZE_T_SIZE (sizeof(size_t)) +#define SIZE_T_BITSIZE (sizeof(size_t) << 3) + +/* Some constants coerced to size_t */ +/* Annoying but necessary to avoid errors on some platforms */ +#define SIZE_T_ZERO ((size_t)0) +#define SIZE_T_ONE ((size_t)1) +#define SIZE_T_TWO ((size_t)2) +#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) +#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) +#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) + +/* The bit mask value corresponding to MALLOC_ALIGNMENT */ +#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) + +/* the number of bytes to offset an address to align it */ +#define align_offset(A)\ + ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ + ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) + +/* -------------------------- MMAP support ------------------------------- */ + +#define MFAIL ((void *)(MAX_SIZE_T)) +#define CMFAIL ((char *)(MFAIL)) /* defined for convenience */ + +#define IS_DIRECT_BIT (SIZE_T_ONE) + +#if LJ_TARGET_WINDOWS + +#define WIN32_LEAN_AND_MEAN +#include + +#if LJ_64 + +/* Undocumented, but hey, that's what we all love so much about Windows. */ +typedef long (*PNTAVM)(HANDLE handle, void **addr, ULONG zbits, + size_t *size, ULONG alloctype, ULONG prot); +static PNTAVM ntavm; + +/* Number of top bits of the lower 32 bits of an address that must be zero. +** Apparently 0 gives us full 64 bit addresses and 1 gives us the lower 2GB. +*/ +#define NTAVM_ZEROBITS 1 + +static void INIT_MMAP(void) +{ + ntavm = (PNTAVM)GetProcAddress(GetModuleHandleA("ntdll.dll"), + "NtAllocateVirtualMemory"); +} + +/* Win64 32 bit MMAP via NtAllocateVirtualMemory. */ +static LJ_AINLINE void *CALL_MMAP(size_t size) +{ + DWORD olderr = GetLastError(); + void *ptr = NULL; + long st = ntavm(INVALID_HANDLE_VALUE, &ptr, NTAVM_ZEROBITS, &size, + MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); + SetLastError(olderr); + return st == 0 ? ptr : MFAIL; +} + +/* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ +static LJ_AINLINE void *DIRECT_MMAP(size_t size) +{ + DWORD olderr = GetLastError(); + void *ptr = NULL; + long st = ntavm(INVALID_HANDLE_VALUE, &ptr, NTAVM_ZEROBITS, &size, + MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, PAGE_READWRITE); + SetLastError(olderr); + return st == 0 ? ptr : MFAIL; +} + +#else + +#define INIT_MMAP() ((void)0) + +/* Win32 MMAP via VirtualAlloc */ +static LJ_AINLINE void *CALL_MMAP(size_t size) +{ + DWORD olderr = GetLastError(); + void *ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); + SetLastError(olderr); + return ptr ? ptr : MFAIL; +} + +/* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ +static LJ_AINLINE void *DIRECT_MMAP(size_t size) +{ + DWORD olderr = GetLastError(); + void *ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, + PAGE_READWRITE); + SetLastError(olderr); + return ptr ? ptr : MFAIL; +} + +#endif + +/* This function supports releasing coalesed segments */ +static LJ_AINLINE int CALL_MUNMAP(void *ptr, size_t size) +{ + DWORD olderr = GetLastError(); + MEMORY_BASIC_INFORMATION minfo; + char *cptr = (char *)ptr; + while (size) { + if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) + return -1; + if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || + minfo.State != MEM_COMMIT || minfo.RegionSize > size) + return -1; + if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) + return -1; + cptr += minfo.RegionSize; + size -= minfo.RegionSize; + } + SetLastError(olderr); + return 0; +} + +#else + +#include +#include + +#define MMAP_PROT (PROT_READ|PROT_WRITE) +#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) +#define MAP_ANONYMOUS MAP_ANON +#endif +#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS) + +#if LJ_64 +/* 64 bit mode needs special support for allocating memory in the lower 2GB. */ + +#if defined(MAP_32BIT) + +#if defined(__sun__) +#define MMAP_REGION_START ((uintptr_t)0x1000) +#else +/* Actually this only gives us max. 1GB in current Linux kernels. */ +#define MMAP_REGION_START ((uintptr_t)0) +#endif + +static LJ_AINLINE void *CALL_MMAP(size_t size) +{ + int olderr = errno; + void *ptr = mmap((void *)MMAP_REGION_START, size, MMAP_PROT, MAP_32BIT|MMAP_FLAGS, -1, 0); + errno = olderr; + return ptr; +} + +#elif LJ_TARGET_OSX || LJ_TARGET_PS4 || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__sun__) || LJ_TARGET_CYGWIN + +/* OSX and FreeBSD mmap() use a naive first-fit linear search. +** That's perfect for us. Except that -pagezero_size must be set for OSX, +** otherwise the lower 4GB are blocked. And the 32GB RLIMIT_DATA needs +** to be reduced to 250MB on FreeBSD. +*/ +#if LJ_TARGET_OSX || defined(__DragonFly__) +#define MMAP_REGION_START ((uintptr_t)0x10000) +#elif LJ_TARGET_PS4 +#define MMAP_REGION_START ((uintptr_t)0x4000) +#else +#define MMAP_REGION_START ((uintptr_t)0x10000000) +#endif +#define MMAP_REGION_END ((uintptr_t)0x80000000) + +#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4 +#include +#endif + +static LJ_AINLINE void *CALL_MMAP(size_t size) +{ + int olderr = errno; + /* Hint for next allocation. Doesn't need to be thread-safe. */ + static uintptr_t alloc_hint = MMAP_REGION_START; + int retry = 0; +#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4 + static int rlimit_modified = 0; + if (LJ_UNLIKELY(rlimit_modified == 0)) { + struct rlimit rlim; + rlim.rlim_cur = rlim.rlim_max = MMAP_REGION_START; + setrlimit(RLIMIT_DATA, &rlim); /* Ignore result. May fail below. */ + rlimit_modified = 1; + } +#endif + for (;;) { + void *p = mmap((void *)alloc_hint, size, MMAP_PROT, MMAP_FLAGS, -1, 0); + if ((uintptr_t)p >= MMAP_REGION_START && + (uintptr_t)p + size < MMAP_REGION_END) { + alloc_hint = (uintptr_t)p + size; + errno = olderr; + return p; + } + if (p != CMFAIL) munmap(p, size); +#if defined(__sun__) || defined(__DragonFly__) + alloc_hint += 0x1000000; /* Need near-exhaustive linear scan. */ + if (alloc_hint + size < MMAP_REGION_END) continue; +#endif + if (retry) break; + retry = 1; + alloc_hint = MMAP_REGION_START; + } + errno = olderr; + return CMFAIL; +} + +#else + +#error "NYI: need an equivalent of MAP_32BIT for this 64 bit OS" + +#endif + +#else + +/* 32 bit mode is easy. */ +static LJ_AINLINE void *CALL_MMAP(size_t size) +{ + int olderr = errno; + void *ptr = mmap(NULL, size, MMAP_PROT, MMAP_FLAGS, -1, 0); + errno = olderr; + return ptr; +} + +#endif + +#define INIT_MMAP() ((void)0) +#define DIRECT_MMAP(s) CALL_MMAP(s) + +static LJ_AINLINE int CALL_MUNMAP(void *ptr, size_t size) +{ + int olderr = errno; + int ret = munmap(ptr, size); + errno = olderr; + return ret; +} + +#if LJ_TARGET_LINUX +/* Need to define _GNU_SOURCE to get the mremap prototype. */ +static LJ_AINLINE void *CALL_MREMAP_(void *ptr, size_t osz, size_t nsz, + int flags) +{ + int olderr = errno; + ptr = mremap(ptr, osz, nsz, flags); + errno = olderr; + return ptr; +} + +#define CALL_MREMAP(addr, osz, nsz, mv) CALL_MREMAP_((addr), (osz), (nsz), (mv)) +#define CALL_MREMAP_NOMOVE 0 +#define CALL_MREMAP_MAYMOVE 1 +#if LJ_64 +#define CALL_MREMAP_MV CALL_MREMAP_NOMOVE +#else +#define CALL_MREMAP_MV CALL_MREMAP_MAYMOVE +#endif +#endif + +#endif + +#ifndef CALL_MREMAP +#define CALL_MREMAP(addr, osz, nsz, mv) ((void)osz, MFAIL) +#endif + +/* ----------------------- Chunk representations ------------------------ */ + +struct malloc_chunk { + size_t prev_foot; /* Size of previous chunk (if free). */ + size_t head; /* Size and inuse bits. */ + struct malloc_chunk *fd; /* double links -- used only if free. */ + struct malloc_chunk *bk; +}; + +typedef struct malloc_chunk mchunk; +typedef struct malloc_chunk *mchunkptr; +typedef struct malloc_chunk *sbinptr; /* The type of bins of chunks */ +typedef size_t bindex_t; /* Described below */ +typedef unsigned int binmap_t; /* Described below */ +typedef unsigned int flag_t; /* The type of various bit flag sets */ + +/* ------------------- Chunks sizes and alignments ----------------------- */ + +#define MCHUNK_SIZE (sizeof(mchunk)) + +#define CHUNK_OVERHEAD (SIZE_T_SIZE) + +/* Direct chunks need a second word of overhead ... */ +#define DIRECT_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) +/* ... and additional padding for fake next-chunk at foot */ +#define DIRECT_FOOT_PAD (FOUR_SIZE_T_SIZES) + +/* The smallest size we can malloc is an aligned minimal chunk */ +#define MIN_CHUNK_SIZE\ + ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) + +/* conversion from malloc headers to user pointers, and back */ +#define chunk2mem(p) ((void *)((char *)(p) + TWO_SIZE_T_SIZES)) +#define mem2chunk(mem) ((mchunkptr)((char *)(mem) - TWO_SIZE_T_SIZES)) +/* chunk associated with aligned address A */ +#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) + +/* Bounds on request (not chunk) sizes. */ +#define MAX_REQUEST ((~MIN_CHUNK_SIZE+1) << 2) +#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) + +/* pad request bytes into a usable size */ +#define pad_request(req) \ + (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) + +/* pad request, checking for minimum (but not maximum) */ +#define request2size(req) \ + (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) + +/* ------------------ Operations on head and foot fields ----------------- */ + +#define PINUSE_BIT (SIZE_T_ONE) +#define CINUSE_BIT (SIZE_T_TWO) +#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) + +/* Head value for fenceposts */ +#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) + +/* extraction of fields from head words */ +#define cinuse(p) ((p)->head & CINUSE_BIT) +#define pinuse(p) ((p)->head & PINUSE_BIT) +#define chunksize(p) ((p)->head & ~(INUSE_BITS)) + +#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) +#define clear_cinuse(p) ((p)->head &= ~CINUSE_BIT) + +/* Treat space at ptr +/- offset as a chunk */ +#define chunk_plus_offset(p, s) ((mchunkptr)(((char *)(p)) + (s))) +#define chunk_minus_offset(p, s) ((mchunkptr)(((char *)(p)) - (s))) + +/* Ptr to next or previous physical malloc_chunk. */ +#define next_chunk(p) ((mchunkptr)(((char *)(p)) + ((p)->head & ~INUSE_BITS))) +#define prev_chunk(p) ((mchunkptr)(((char *)(p)) - ((p)->prev_foot) )) + +/* extract next chunk's pinuse bit */ +#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) + +/* Get/set size at footer */ +#define get_foot(p, s) (((mchunkptr)((char *)(p) + (s)))->prev_foot) +#define set_foot(p, s) (((mchunkptr)((char *)(p) + (s)))->prev_foot = (s)) + +/* Set size, pinuse bit, and foot */ +#define set_size_and_pinuse_of_free_chunk(p, s)\ + ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) + +/* Set size, pinuse bit, foot, and clear next pinuse */ +#define set_free_with_pinuse(p, s, n)\ + (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) + +#define is_direct(p)\ + (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_DIRECT_BIT)) + +/* Get the internal overhead associated with chunk p */ +#define overhead_for(p)\ + (is_direct(p)? DIRECT_CHUNK_OVERHEAD : CHUNK_OVERHEAD) + +/* ---------------------- Overlaid data structures ----------------------- */ + +struct malloc_tree_chunk { + /* The first four fields must be compatible with malloc_chunk */ + size_t prev_foot; + size_t head; + struct malloc_tree_chunk *fd; + struct malloc_tree_chunk *bk; + + struct malloc_tree_chunk *child[2]; + struct malloc_tree_chunk *parent; + bindex_t index; +}; + +typedef struct malloc_tree_chunk tchunk; +typedef struct malloc_tree_chunk *tchunkptr; +typedef struct malloc_tree_chunk *tbinptr; /* The type of bins of trees */ + +/* A little helper macro for trees */ +#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) + +/* ----------------------------- Segments -------------------------------- */ + +struct malloc_segment { + char *base; /* base address */ + size_t size; /* allocated size */ + struct malloc_segment *next; /* ptr to next segment */ +}; + +typedef struct malloc_segment msegment; +typedef struct malloc_segment *msegmentptr; + +/* ---------------------------- malloc_state ----------------------------- */ + +/* Bin types, widths and sizes */ +#define NSMALLBINS (32U) +#define NTREEBINS (32U) +#define SMALLBIN_SHIFT (3U) +#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) +#define TREEBIN_SHIFT (8U) +#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) +#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) +#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) + +struct malloc_state { + binmap_t smallmap; + binmap_t treemap; + size_t dvsize; + size_t topsize; + mchunkptr dv; + mchunkptr top; + size_t trim_check; + size_t release_checks; + mchunkptr smallbins[(NSMALLBINS+1)*2]; + tbinptr treebins[NTREEBINS]; + msegment seg; +}; + +typedef struct malloc_state *mstate; + +#define is_initialized(M) ((M)->top != 0) + +/* -------------------------- system alloc setup ------------------------- */ + +/* page-align a size */ +#define page_align(S)\ + (((S) + (LJ_PAGESIZE - SIZE_T_ONE)) & ~(LJ_PAGESIZE - SIZE_T_ONE)) + +/* granularity-align a size */ +#define granularity_align(S)\ + (((S) + (DEFAULT_GRANULARITY - SIZE_T_ONE))\ + & ~(DEFAULT_GRANULARITY - SIZE_T_ONE)) + +#if LJ_TARGET_WINDOWS +#define mmap_align(S) granularity_align(S) +#else +#define mmap_align(S) page_align(S) +#endif + +/* True if segment S holds address A */ +#define segment_holds(S, A)\ + ((char *)(A) >= S->base && (char *)(A) < S->base + S->size) + +/* Return segment holding given address */ +static msegmentptr segment_holding(mstate m, char *addr) +{ + msegmentptr sp = &m->seg; + for (;;) { + if (addr >= sp->base && addr < sp->base + sp->size) + return sp; + if ((sp = sp->next) == 0) + return 0; + } +} + +/* Return true if segment contains a segment link */ +static int has_segment_link(mstate m, msegmentptr ss) +{ + msegmentptr sp = &m->seg; + for (;;) { + if ((char *)sp >= ss->base && (char *)sp < ss->base + ss->size) + return 1; + if ((sp = sp->next) == 0) + return 0; + } +} + +/* + TOP_FOOT_SIZE is padding at the end of a segment, including space + that may be needed to place segment records and fenceposts when new + noncontiguous segments are added. +*/ +#define TOP_FOOT_SIZE\ + (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) + +/* ---------------------------- Indexing Bins ---------------------------- */ + +#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) +#define small_index(s) ((s) >> SMALLBIN_SHIFT) +#define small_index2size(i) ((i) << SMALLBIN_SHIFT) +#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) + +/* addressing by index. See above about smallbin repositioning */ +#define smallbin_at(M, i) ((sbinptr)((char *)&((M)->smallbins[(i)<<1]))) +#define treebin_at(M,i) (&((M)->treebins[i])) + +/* assign tree index for size S to variable I */ +#define compute_tree_index(S, I)\ +{\ + unsigned int X = (unsigned int)(S >> TREEBIN_SHIFT);\ + if (X == 0) {\ + I = 0;\ + } else if (X > 0xFFFF) {\ + I = NTREEBINS-1;\ + } else {\ + unsigned int K = lj_fls(X);\ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ + }\ +} + +/* Bit representing maximum resolved size in a treebin at i */ +#define bit_for_tree_index(i) \ + (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) + +/* Shift placing maximum resolved bit in a treebin at i as sign bit */ +#define leftshift_for_tree_index(i) \ + ((i == NTREEBINS-1)? 0 : \ + ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) + +/* The size of the smallest chunk held in bin with index i */ +#define minsize_for_tree_index(i) \ + ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ + (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) + +/* ------------------------ Operations on bin maps ----------------------- */ + +/* bit corresponding to given index */ +#define idx2bit(i) ((binmap_t)(1) << (i)) + +/* Mark/Clear bits with given index */ +#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) +#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) +#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) + +#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) +#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) +#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) + +/* mask with all bits to left of least bit of x on */ +#define left_bits(x) ((x<<1) | (~(x<<1)+1)) + +/* Set cinuse bit and pinuse bit of next chunk */ +#define set_inuse(M,p,s)\ + ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ + ((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT) + +/* Set cinuse and pinuse of this chunk and pinuse of next chunk */ +#define set_inuse_and_pinuse(M,p,s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ + ((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT) + +/* Set size, cinuse and pinuse bit of this chunk */ +#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) + +/* ----------------------- Operations on smallbins ----------------------- */ + +/* Link a free chunk into a smallbin */ +#define insert_small_chunk(M, P, S) {\ + bindex_t I = small_index(S);\ + mchunkptr B = smallbin_at(M, I);\ + mchunkptr F = B;\ + if (!smallmap_is_marked(M, I))\ + mark_smallmap(M, I);\ + else\ + F = B->fd;\ + B->fd = P;\ + F->bk = P;\ + P->fd = F;\ + P->bk = B;\ +} + +/* Unlink a chunk from a smallbin */ +#define unlink_small_chunk(M, P, S) {\ + mchunkptr F = P->fd;\ + mchunkptr B = P->bk;\ + bindex_t I = small_index(S);\ + if (F == B) {\ + clear_smallmap(M, I);\ + } else {\ + F->bk = B;\ + B->fd = F;\ + }\ +} + +/* Unlink the first chunk from a smallbin */ +#define unlink_first_small_chunk(M, B, P, I) {\ + mchunkptr F = P->fd;\ + if (B == F) {\ + clear_smallmap(M, I);\ + } else {\ + B->fd = F;\ + F->bk = B;\ + }\ +} + +/* Replace dv node, binning the old one */ +/* Used only when dvsize known to be small */ +#define replace_dv(M, P, S) {\ + size_t DVS = M->dvsize;\ + if (DVS != 0) {\ + mchunkptr DV = M->dv;\ + insert_small_chunk(M, DV, DVS);\ + }\ + M->dvsize = S;\ + M->dv = P;\ +} + +/* ------------------------- Operations on trees ------------------------- */ + +/* Insert chunk into tree */ +#define insert_large_chunk(M, X, S) {\ + tbinptr *H;\ + bindex_t I;\ + compute_tree_index(S, I);\ + H = treebin_at(M, I);\ + X->index = I;\ + X->child[0] = X->child[1] = 0;\ + if (!treemap_is_marked(M, I)) {\ + mark_treemap(M, I);\ + *H = X;\ + X->parent = (tchunkptr)H;\ + X->fd = X->bk = X;\ + } else {\ + tchunkptr T = *H;\ + size_t K = S << leftshift_for_tree_index(I);\ + for (;;) {\ + if (chunksize(T) != S) {\ + tchunkptr *C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ + K <<= 1;\ + if (*C != 0) {\ + T = *C;\ + } else {\ + *C = X;\ + X->parent = T;\ + X->fd = X->bk = X;\ + break;\ + }\ + } else {\ + tchunkptr F = T->fd;\ + T->fd = F->bk = X;\ + X->fd = F;\ + X->bk = T;\ + X->parent = 0;\ + break;\ + }\ + }\ + }\ +} + +#define unlink_large_chunk(M, X) {\ + tchunkptr XP = X->parent;\ + tchunkptr R;\ + if (X->bk != X) {\ + tchunkptr F = X->fd;\ + R = X->bk;\ + F->bk = R;\ + R->fd = F;\ + } else {\ + tchunkptr *RP;\ + if (((R = *(RP = &(X->child[1]))) != 0) ||\ + ((R = *(RP = &(X->child[0]))) != 0)) {\ + tchunkptr *CP;\ + while ((*(CP = &(R->child[1])) != 0) ||\ + (*(CP = &(R->child[0])) != 0)) {\ + R = *(RP = CP);\ + }\ + *RP = 0;\ + }\ + }\ + if (XP != 0) {\ + tbinptr *H = treebin_at(M, X->index);\ + if (X == *H) {\ + if ((*H = R) == 0) \ + clear_treemap(M, X->index);\ + } else {\ + if (XP->child[0] == X) \ + XP->child[0] = R;\ + else \ + XP->child[1] = R;\ + }\ + if (R != 0) {\ + tchunkptr C0, C1;\ + R->parent = XP;\ + if ((C0 = X->child[0]) != 0) {\ + R->child[0] = C0;\ + C0->parent = R;\ + }\ + if ((C1 = X->child[1]) != 0) {\ + R->child[1] = C1;\ + C1->parent = R;\ + }\ + }\ + }\ +} + +/* Relays to large vs small bin operations */ + +#define insert_chunk(M, P, S)\ + if (is_small(S)) { insert_small_chunk(M, P, S)\ + } else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } + +#define unlink_chunk(M, P, S)\ + if (is_small(S)) { unlink_small_chunk(M, P, S)\ + } else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } + +/* ----------------------- Direct-mmapping chunks ----------------------- */ + +static void *direct_alloc(size_t nb) +{ + size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + if (LJ_LIKELY(mmsize > nb)) { /* Check for wrap around 0 */ + char *mm = (char *)(DIRECT_MMAP(mmsize)); + if (mm != CMFAIL) { + size_t offset = align_offset(chunk2mem(mm)); + size_t psize = mmsize - offset - DIRECT_FOOT_PAD; + mchunkptr p = (mchunkptr)(mm + offset); + p->prev_foot = offset | IS_DIRECT_BIT; + p->head = psize|CINUSE_BIT; + chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; + return chunk2mem(p); + } + } + return NULL; +} + +static mchunkptr direct_resize(mchunkptr oldp, size_t nb) +{ + size_t oldsize = chunksize(oldp); + if (is_small(nb)) /* Can't shrink direct regions below small size */ + return NULL; + /* Keep old chunk if big enough but not too big */ + if (oldsize >= nb + SIZE_T_SIZE && + (oldsize - nb) <= (DEFAULT_GRANULARITY >> 1)) { + return oldp; + } else { + size_t offset = oldp->prev_foot & ~IS_DIRECT_BIT; + size_t oldmmsize = oldsize + offset + DIRECT_FOOT_PAD; + size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + char *cp = (char *)CALL_MREMAP((char *)oldp - offset, + oldmmsize, newmmsize, CALL_MREMAP_MV); + if (cp != CMFAIL) { + mchunkptr newp = (mchunkptr)(cp + offset); + size_t psize = newmmsize - offset - DIRECT_FOOT_PAD; + newp->head = psize|CINUSE_BIT; + chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; + return newp; + } + } + return NULL; +} + +/* -------------------------- mspace management -------------------------- */ + +/* Initialize top chunk and its size */ +static void init_top(mstate m, mchunkptr p, size_t psize) +{ + /* Ensure alignment */ + size_t offset = align_offset(chunk2mem(p)); + p = (mchunkptr)((char *)p + offset); + psize -= offset; + + m->top = p; + m->topsize = psize; + p->head = psize | PINUSE_BIT; + /* set size of fake trailing chunk holding overhead space only once */ + chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; + m->trim_check = DEFAULT_TRIM_THRESHOLD; /* reset on each update */ +} + +/* Initialize bins for a new mstate that is otherwise zeroed out */ +static void init_bins(mstate m) +{ + /* Establish circular links for smallbins */ + bindex_t i; + for (i = 0; i < NSMALLBINS; i++) { + sbinptr bin = smallbin_at(m,i); + bin->fd = bin->bk = bin; + } +} + +/* Allocate chunk and prepend remainder with chunk in successor base. */ +static void *prepend_alloc(mstate m, char *newbase, char *oldbase, size_t nb) +{ + mchunkptr p = align_as_chunk(newbase); + mchunkptr oldfirst = align_as_chunk(oldbase); + size_t psize = (size_t)((char *)oldfirst - (char *)p); + mchunkptr q = chunk_plus_offset(p, nb); + size_t qsize = psize - nb; + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + + /* consolidate remainder with first chunk of old base */ + if (oldfirst == m->top) { + size_t tsize = m->topsize += qsize; + m->top = q; + q->head = tsize | PINUSE_BIT; + } else if (oldfirst == m->dv) { + size_t dsize = m->dvsize += qsize; + m->dv = q; + set_size_and_pinuse_of_free_chunk(q, dsize); + } else { + if (!cinuse(oldfirst)) { + size_t nsize = chunksize(oldfirst); + unlink_chunk(m, oldfirst, nsize); + oldfirst = chunk_plus_offset(oldfirst, nsize); + qsize += nsize; + } + set_free_with_pinuse(q, qsize, oldfirst); + insert_chunk(m, q, qsize); + } + + return chunk2mem(p); +} + +/* Add a segment to hold a new noncontiguous region */ +static void add_segment(mstate m, char *tbase, size_t tsize) +{ + /* Determine locations and sizes of segment, fenceposts, old top */ + char *old_top = (char *)m->top; + msegmentptr oldsp = segment_holding(m, old_top); + char *old_end = oldsp->base + oldsp->size; + size_t ssize = pad_request(sizeof(struct malloc_segment)); + char *rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + size_t offset = align_offset(chunk2mem(rawsp)); + char *asp = rawsp + offset; + char *csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; + mchunkptr sp = (mchunkptr)csp; + msegmentptr ss = (msegmentptr)(chunk2mem(sp)); + mchunkptr tnext = chunk_plus_offset(sp, ssize); + mchunkptr p = tnext; + + /* reset top to new space */ + init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); + + /* Set up segment record */ + set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); + *ss = m->seg; /* Push current record */ + m->seg.base = tbase; + m->seg.size = tsize; + m->seg.next = ss; + + /* Insert trailing fenceposts */ + for (;;) { + mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); + p->head = FENCEPOST_HEAD; + if ((char *)(&(nextp->head)) < old_end) + p = nextp; + else + break; + } + + /* Insert the rest of old top into a bin as an ordinary free chunk */ + if (csp != old_top) { + mchunkptr q = (mchunkptr)old_top; + size_t psize = (size_t)(csp - old_top); + mchunkptr tn = chunk_plus_offset(q, psize); + set_free_with_pinuse(q, psize, tn); + insert_chunk(m, q, psize); + } +} + +/* -------------------------- System allocation -------------------------- */ + +static void *alloc_sys(mstate m, size_t nb) +{ + char *tbase = CMFAIL; + size_t tsize = 0; + + /* Directly map large chunks */ + if (LJ_UNLIKELY(nb >= DEFAULT_MMAP_THRESHOLD)) { + void *mem = direct_alloc(nb); + if (mem != 0) + return mem; + } + + { + size_t req = nb + TOP_FOOT_SIZE + SIZE_T_ONE; + size_t rsize = granularity_align(req); + if (LJ_LIKELY(rsize > nb)) { /* Fail if wraps around zero */ + char *mp = (char *)(CALL_MMAP(rsize)); + if (mp != CMFAIL) { + tbase = mp; + tsize = rsize; + } + } + } + + if (tbase != CMFAIL) { + msegmentptr sp = &m->seg; + /* Try to merge with an existing segment */ + while (sp != 0 && tbase != sp->base + sp->size) + sp = sp->next; + if (sp != 0 && segment_holds(sp, m->top)) { /* append */ + sp->size += tsize; + init_top(m, m->top, m->topsize + tsize); + } else { + sp = &m->seg; + while (sp != 0 && sp->base != tbase + tsize) + sp = sp->next; + if (sp != 0) { + char *oldbase = sp->base; + sp->base = tbase; + sp->size += tsize; + return prepend_alloc(m, tbase, oldbase, nb); + } else { + add_segment(m, tbase, tsize); + } + } + + if (nb < m->topsize) { /* Allocate from new or extended top space */ + size_t rsize = m->topsize -= nb; + mchunkptr p = m->top; + mchunkptr r = m->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + return chunk2mem(p); + } + } + + return NULL; +} + +/* ----------------------- system deallocation -------------------------- */ + +/* Unmap and unlink any mmapped segments that don't contain used chunks */ +static size_t release_unused_segments(mstate m) +{ + size_t released = 0; + size_t nsegs = 0; + msegmentptr pred = &m->seg; + msegmentptr sp = pred->next; + while (sp != 0) { + char *base = sp->base; + size_t size = sp->size; + msegmentptr next = sp->next; + nsegs++; + { + mchunkptr p = align_as_chunk(base); + size_t psize = chunksize(p); + /* Can unmap if first chunk holds entire segment and not pinned */ + if (!cinuse(p) && (char *)p + psize >= base + size - TOP_FOOT_SIZE) { + tchunkptr tp = (tchunkptr)p; + if (p == m->dv) { + m->dv = 0; + m->dvsize = 0; + } else { + unlink_large_chunk(m, tp); + } + if (CALL_MUNMAP(base, size) == 0) { + released += size; + /* unlink obsoleted record */ + sp = pred; + sp->next = next; + } else { /* back out if cannot unmap */ + insert_large_chunk(m, tp, psize); + } + } + } + pred = sp; + sp = next; + } + /* Reset check counter */ + m->release_checks = nsegs > MAX_RELEASE_CHECK_RATE ? + nsegs : MAX_RELEASE_CHECK_RATE; + return released; +} + +static int alloc_trim(mstate m, size_t pad) +{ + size_t released = 0; + if (pad < MAX_REQUEST && is_initialized(m)) { + pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ + + if (m->topsize > pad) { + /* Shrink top space in granularity-size units, keeping at least one */ + size_t unit = DEFAULT_GRANULARITY; + size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - + SIZE_T_ONE) * unit; + msegmentptr sp = segment_holding(m, (char *)m->top); + + if (sp->size >= extra && + !has_segment_link(m, sp)) { /* can't shrink if pinned */ + size_t newsize = sp->size - extra; + /* Prefer mremap, fall back to munmap */ + if ((CALL_MREMAP(sp->base, sp->size, newsize, CALL_MREMAP_NOMOVE) != MFAIL) || + (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { + released = extra; + } + } + + if (released != 0) { + sp->size -= released; + init_top(m, m->top, m->topsize - released); + } + } + + /* Unmap any unused mmapped segments */ + released += release_unused_segments(m); + + /* On failure, disable autotrim to avoid repeated failed future calls */ + if (released == 0 && m->topsize > m->trim_check) + m->trim_check = MAX_SIZE_T; + } + + return (released != 0)? 1 : 0; +} + +/* ---------------------------- malloc support --------------------------- */ + +/* allocate a large request from the best fitting chunk in a treebin */ +static void *tmalloc_large(mstate m, size_t nb) +{ + tchunkptr v = 0; + size_t rsize = ~nb+1; /* Unsigned negation */ + tchunkptr t; + bindex_t idx; + compute_tree_index(nb, idx); + + if ((t = *treebin_at(m, idx)) != 0) { + /* Traverse tree for this bin looking for node with size == nb */ + size_t sizebits = nb << leftshift_for_tree_index(idx); + tchunkptr rst = 0; /* The deepest untaken right subtree */ + for (;;) { + tchunkptr rt; + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + v = t; + if ((rsize = trem) == 0) + break; + } + rt = t->child[1]; + t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; + if (rt != 0 && rt != t) + rst = rt; + if (t == 0) { + t = rst; /* set t to least subtree holding sizes > nb */ + break; + } + sizebits <<= 1; + } + } + + if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ + binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; + if (leftbits != 0) + t = *treebin_at(m, lj_ffs(leftbits)); + } + + while (t != 0) { /* find smallest of tree or subtree */ + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + rsize = trem; + v = t; + } + t = leftmost_child(t); + } + + /* If dv is a better fit, return NULL so malloc will use it */ + if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { + mchunkptr r = chunk_plus_offset(v, nb); + unlink_large_chunk(m, v); + if (rsize < MIN_CHUNK_SIZE) { + set_inuse_and_pinuse(m, v, (rsize + nb)); + } else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + insert_chunk(m, r, rsize); + } + return chunk2mem(v); + } + return NULL; +} + +/* allocate a small request from the best fitting chunk in a treebin */ +static void *tmalloc_small(mstate m, size_t nb) +{ + tchunkptr t, v; + mchunkptr r; + size_t rsize; + bindex_t i = lj_ffs(m->treemap); + + v = t = *treebin_at(m, i); + rsize = chunksize(t) - nb; + + while ((t = leftmost_child(t)) != 0) { + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + rsize = trem; + v = t; + } + } + + r = chunk_plus_offset(v, nb); + unlink_large_chunk(m, v); + if (rsize < MIN_CHUNK_SIZE) { + set_inuse_and_pinuse(m, v, (rsize + nb)); + } else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(m, r, rsize); + } + return chunk2mem(v); +} + +/* ----------------------------------------------------------------------- */ + +void *lj_alloc_create(void) +{ + size_t tsize = DEFAULT_GRANULARITY; + char *tbase; + INIT_MMAP(); + tbase = (char *)(CALL_MMAP(tsize)); + if (tbase != CMFAIL) { + size_t msize = pad_request(sizeof(struct malloc_state)); + mchunkptr mn; + mchunkptr msp = align_as_chunk(tbase); + mstate m = (mstate)(chunk2mem(msp)); + memset(m, 0, msize); + msp->head = (msize|PINUSE_BIT|CINUSE_BIT); + m->seg.base = tbase; + m->seg.size = tsize; + m->release_checks = MAX_RELEASE_CHECK_RATE; + init_bins(m); + mn = next_chunk(mem2chunk(m)); + init_top(m, mn, (size_t)((tbase + tsize) - (char *)mn) - TOP_FOOT_SIZE); + return m; + } + return NULL; +} + +void lj_alloc_destroy(void *msp) +{ + mstate ms = (mstate)msp; + msegmentptr sp = &ms->seg; + while (sp != 0) { + char *base = sp->base; + size_t size = sp->size; + sp = sp->next; + CALL_MUNMAP(base, size); + } +} + +static LJ_NOINLINE void *lj_alloc_malloc(void *msp, size_t nsize) +{ + mstate ms = (mstate)msp; + void *mem; + size_t nb; + if (nsize <= MAX_SMALL_REQUEST) { + bindex_t idx; + binmap_t smallbits; + nb = (nsize < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(nsize); + idx = small_index(nb); + smallbits = ms->smallmap >> idx; + + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + mchunkptr b, p; + idx += ~smallbits & 1; /* Uses next bin if idx empty */ + b = smallbin_at(ms, idx); + p = b->fd; + unlink_first_small_chunk(ms, b, p, idx); + set_inuse_and_pinuse(ms, p, small_index2size(idx)); + mem = chunk2mem(p); + return mem; + } else if (nb > ms->dvsize) { + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + mchunkptr b, p, r; + size_t rsize; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + bindex_t i = lj_ffs(leftbits); + b = smallbin_at(ms, i); + p = b->fd; + unlink_first_small_chunk(ms, b, p, i); + rsize = small_index2size(i) - nb; + /* Fit here cannot be remainderless if 4byte sizes */ + if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) { + set_inuse_and_pinuse(ms, p, small_index2size(i)); + } else { + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + r = chunk_plus_offset(p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(ms, r, rsize); + } + mem = chunk2mem(p); + return mem; + } else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { + return mem; + } + } + } else if (nsize >= MAX_REQUEST) { + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ + } else { + nb = pad_request(nsize); + if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { + return mem; + } + } + + if (nb <= ms->dvsize) { + size_t rsize = ms->dvsize - nb; + mchunkptr p = ms->dv; + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + mchunkptr r = ms->dv = chunk_plus_offset(p, nb); + ms->dvsize = rsize; + set_size_and_pinuse_of_free_chunk(r, rsize); + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + } else { /* exhaust dv */ + size_t dvs = ms->dvsize; + ms->dvsize = 0; + ms->dv = 0; + set_inuse_and_pinuse(ms, p, dvs); + } + mem = chunk2mem(p); + return mem; + } else if (nb < ms->topsize) { /* Split top */ + size_t rsize = ms->topsize -= nb; + mchunkptr p = ms->top; + mchunkptr r = ms->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + mem = chunk2mem(p); + return mem; + } + return alloc_sys(ms, nb); +} + +static LJ_NOINLINE void *lj_alloc_free(void *msp, void *ptr) +{ + if (ptr != 0) { + mchunkptr p = mem2chunk(ptr); + mstate fm = (mstate)msp; + size_t psize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { + size_t prevsize = p->prev_foot; + if ((prevsize & IS_DIRECT_BIT) != 0) { + prevsize &= ~IS_DIRECT_BIT; + psize += prevsize + DIRECT_FOOT_PAD; + CALL_MUNMAP((char *)p - prevsize, psize); + return NULL; + } else { + mchunkptr prev = chunk_minus_offset(p, prevsize); + psize += prevsize; + p = prev; + /* consolidate backward */ + if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); + } else if ((next->head & INUSE_BITS) == INUSE_BITS) { + fm->dvsize = psize; + set_free_with_pinuse(p, psize, next); + return NULL; + } + } + } + if (!cinuse(next)) { /* consolidate forward */ + if (next == fm->top) { + size_t tsize = fm->topsize += psize; + fm->top = p; + p->head = tsize | PINUSE_BIT; + if (p == fm->dv) { + fm->dv = 0; + fm->dvsize = 0; + } + if (tsize > fm->trim_check) + alloc_trim(fm, 0); + return NULL; + } else if (next == fm->dv) { + size_t dsize = fm->dvsize += psize; + fm->dv = p; + set_size_and_pinuse_of_free_chunk(p, dsize); + return NULL; + } else { + size_t nsize = chunksize(next); + psize += nsize; + unlink_chunk(fm, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); + if (p == fm->dv) { + fm->dvsize = psize; + return NULL; + } + } + } else { + set_free_with_pinuse(p, psize, next); + } + + if (is_small(psize)) { + insert_small_chunk(fm, p, psize); + } else { + tchunkptr tp = (tchunkptr)p; + insert_large_chunk(fm, tp, psize); + if (--fm->release_checks == 0) + release_unused_segments(fm); + } + } + return NULL; +} + +static LJ_NOINLINE void *lj_alloc_realloc(void *msp, void *ptr, size_t nsize) +{ + if (nsize >= MAX_REQUEST) { + return NULL; + } else { + mstate m = (mstate)msp; + mchunkptr oldp = mem2chunk(ptr); + size_t oldsize = chunksize(oldp); + mchunkptr next = chunk_plus_offset(oldp, oldsize); + mchunkptr newp = 0; + size_t nb = request2size(nsize); + + /* Try to either shrink or extend into top. Else malloc-copy-free */ + if (is_direct(oldp)) { + newp = direct_resize(oldp, nb); /* this may return NULL. */ + } else if (oldsize >= nb) { /* already big enough */ + size_t rsize = oldsize - nb; + newp = oldp; + if (rsize >= MIN_CHUNK_SIZE) { + mchunkptr rem = chunk_plus_offset(newp, nb); + set_inuse(m, newp, nb); + set_inuse(m, rem, rsize); + lj_alloc_free(m, chunk2mem(rem)); + } + } else if (next == m->top && oldsize + m->topsize > nb) { + /* Expand into top */ + size_t newsize = oldsize + m->topsize; + size_t newtopsize = newsize - nb; + mchunkptr newtop = chunk_plus_offset(oldp, nb); + set_inuse(m, oldp, nb); + newtop->head = newtopsize |PINUSE_BIT; + m->top = newtop; + m->topsize = newtopsize; + newp = oldp; + } + + if (newp != 0) { + return chunk2mem(newp); + } else { + void *newmem = lj_alloc_malloc(m, nsize); + if (newmem != 0) { + size_t oc = oldsize - overhead_for(oldp); + memcpy(newmem, ptr, oc < nsize ? oc : nsize); + lj_alloc_free(m, ptr); + } + return newmem; + } + } +} + +void *lj_alloc_f(void *msp, void *ptr, size_t osize, size_t nsize) +{ + (void)osize; + if (nsize == 0) { + return lj_alloc_free(msp, ptr); + } else if (ptr == NULL) { + return lj_alloc_malloc(msp, nsize); + } else { + return lj_alloc_realloc(msp, ptr, nsize); + } +} + +#endif + +``` + +`include/luajit-2.0.5/src/lj_alloc.h`: + +```h +/* +** Bundled memory allocator. +** Donated to the public domain. +*/ + +#ifndef _LJ_ALLOC_H +#define _LJ_ALLOC_H + +#include "lj_def.h" + +#ifndef LUAJIT_USE_SYSMALLOC +LJ_FUNC void *lj_alloc_create(void); +LJ_FUNC void lj_alloc_destroy(void *msp); +LJ_FUNC void *lj_alloc_f(void *msp, void *ptr, size_t osize, size_t nsize); +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_api.c`: + +```c +/* +** Public Lua/C API. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_api_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_func.h" +#include "lj_udata.h" +#include "lj_meta.h" +#include "lj_state.h" +#include "lj_bc.h" +#include "lj_frame.h" +#include "lj_trace.h" +#include "lj_vm.h" +#include "lj_strscan.h" + +/* -- Common helper functions --------------------------------------------- */ + +#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) +#define api_checkvalidindex(L, i) api_check(L, (i) != niltv(L)) + +static TValue *index2adr(lua_State *L, int idx) +{ + if (idx > 0) { + TValue *o = L->base + (idx - 1); + return o < L->top ? o : niltv(L); + } else if (idx > LUA_REGISTRYINDEX) { + api_check(L, idx != 0 && -idx <= L->top - L->base); + return L->top + idx; + } else if (idx == LUA_GLOBALSINDEX) { + TValue *o = &G(L)->tmptv; + settabV(L, o, tabref(L->env)); + return o; + } else if (idx == LUA_REGISTRYINDEX) { + return registry(L); + } else { + GCfunc *fn = curr_func(L); + api_check(L, fn->c.gct == ~LJ_TFUNC && !isluafunc(fn)); + if (idx == LUA_ENVIRONINDEX) { + TValue *o = &G(L)->tmptv; + settabV(L, o, tabref(fn->c.env)); + return o; + } else { + idx = LUA_GLOBALSINDEX - idx; + return idx <= fn->c.nupvalues ? &fn->c.upvalue[idx-1] : niltv(L); + } + } +} + +static TValue *stkindex2adr(lua_State *L, int idx) +{ + if (idx > 0) { + TValue *o = L->base + (idx - 1); + return o < L->top ? o : niltv(L); + } else { + api_check(L, idx != 0 && -idx <= L->top - L->base); + return L->top + idx; + } +} + +static GCtab *getcurrenv(lua_State *L) +{ + GCfunc *fn = curr_func(L); + return fn->c.gct == ~LJ_TFUNC ? tabref(fn->c.env) : tabref(L->env); +} + +/* -- Miscellaneous API functions ----------------------------------------- */ + +LUA_API int lua_status(lua_State *L) +{ + return L->status; +} + +LUA_API int lua_checkstack(lua_State *L, int size) +{ + if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) { + return 0; /* Stack overflow. */ + } else if (size > 0) { + lj_state_checkstack(L, (MSize)size); + } + return 1; +} + +LUALIB_API void luaL_checkstack(lua_State *L, int size, const char *msg) +{ + if (!lua_checkstack(L, size)) + lj_err_callerv(L, LJ_ERR_STKOVM, msg); +} + +LUA_API void lua_xmove(lua_State *from, lua_State *to, int n) +{ + TValue *f, *t; + if (from == to) return; + api_checknelems(from, n); + api_check(from, G(from) == G(to)); + lj_state_checkstack(to, (MSize)n); + f = from->top; + t = to->top = to->top + n; + while (--n >= 0) copyTV(to, --t, --f); + from->top = f; +} + +/* -- Stack manipulation -------------------------------------------------- */ + +LUA_API int lua_gettop(lua_State *L) +{ + return (int)(L->top - L->base); +} + +LUA_API void lua_settop(lua_State *L, int idx) +{ + if (idx >= 0) { + api_check(L, idx <= tvref(L->maxstack) - L->base); + if (L->base + idx > L->top) { + if (L->base + idx >= tvref(L->maxstack)) + lj_state_growstack(L, (MSize)idx - (MSize)(L->top - L->base)); + do { setnilV(L->top++); } while (L->top < L->base + idx); + } else { + L->top = L->base + idx; + } + } else { + api_check(L, -(idx+1) <= (L->top - L->base)); + L->top += idx+1; /* Shrinks top (idx < 0). */ + } +} + +LUA_API void lua_remove(lua_State *L, int idx) +{ + TValue *p = stkindex2adr(L, idx); + api_checkvalidindex(L, p); + while (++p < L->top) copyTV(L, p-1, p); + L->top--; +} + +LUA_API void lua_insert(lua_State *L, int idx) +{ + TValue *q, *p = stkindex2adr(L, idx); + api_checkvalidindex(L, p); + for (q = L->top; q > p; q--) copyTV(L, q, q-1); + copyTV(L, p, L->top); +} + +LUA_API void lua_replace(lua_State *L, int idx) +{ + api_checknelems(L, 1); + if (idx == LUA_GLOBALSINDEX) { + api_check(L, tvistab(L->top-1)); + /* NOBARRIER: A thread (i.e. L) is never black. */ + setgcref(L->env, obj2gco(tabV(L->top-1))); + } else if (idx == LUA_ENVIRONINDEX) { + GCfunc *fn = curr_func(L); + if (fn->c.gct != ~LJ_TFUNC) + lj_err_msg(L, LJ_ERR_NOENV); + api_check(L, tvistab(L->top-1)); + setgcref(fn->c.env, obj2gco(tabV(L->top-1))); + lj_gc_barrier(L, fn, L->top-1); + } else { + TValue *o = index2adr(L, idx); + api_checkvalidindex(L, o); + copyTV(L, o, L->top-1); + if (idx < LUA_GLOBALSINDEX) /* Need a barrier for upvalues. */ + lj_gc_barrier(L, curr_func(L), L->top-1); + } + L->top--; +} + +LUA_API void lua_pushvalue(lua_State *L, int idx) +{ + copyTV(L, L->top, index2adr(L, idx)); + incr_top(L); +} + +/* -- Stack getters ------------------------------------------------------- */ + +LUA_API int lua_type(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + if (tvisnumber(o)) { + return LUA_TNUMBER; +#if LJ_64 + } else if (tvislightud(o)) { + return LUA_TLIGHTUSERDATA; +#endif + } else if (o == niltv(L)) { + return LUA_TNONE; + } else { /* Magic internal/external tag conversion. ORDER LJ_T */ + uint32_t t = ~itype(o); +#if LJ_64 + int tt = (int)((U64x(75a06,98042110) >> 4*t) & 15u); +#else + int tt = (int)(((t < 8 ? 0x98042110u : 0x75a06u) >> 4*(t&7)) & 15u); +#endif + lua_assert(tt != LUA_TNIL || tvisnil(o)); + return tt; + } +} + +LUALIB_API void luaL_checktype(lua_State *L, int idx, int tt) +{ + if (lua_type(L, idx) != tt) + lj_err_argt(L, idx, tt); +} + +LUALIB_API void luaL_checkany(lua_State *L, int idx) +{ + if (index2adr(L, idx) == niltv(L)) + lj_err_arg(L, idx, LJ_ERR_NOVAL); +} + +LUA_API const char *lua_typename(lua_State *L, int t) +{ + UNUSED(L); + return lj_obj_typename[t+1]; +} + +LUA_API int lua_iscfunction(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + return tvisfunc(o) && !isluafunc(funcV(o)); +} + +LUA_API int lua_isnumber(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + TValue tmp; + return (tvisnumber(o) || (tvisstr(o) && lj_strscan_number(strV(o), &tmp))); +} + +LUA_API int lua_isstring(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + return (tvisstr(o) || tvisnumber(o)); +} + +LUA_API int lua_isuserdata(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + return (tvisudata(o) || tvislightud(o)); +} + +LUA_API int lua_rawequal(lua_State *L, int idx1, int idx2) +{ + cTValue *o1 = index2adr(L, idx1); + cTValue *o2 = index2adr(L, idx2); + return (o1 == niltv(L) || o2 == niltv(L)) ? 0 : lj_obj_equal(o1, o2); +} + +LUA_API int lua_equal(lua_State *L, int idx1, int idx2) +{ + cTValue *o1 = index2adr(L, idx1); + cTValue *o2 = index2adr(L, idx2); + if (tvisint(o1) && tvisint(o2)) { + return intV(o1) == intV(o2); + } else if (tvisnumber(o1) && tvisnumber(o2)) { + return numberVnum(o1) == numberVnum(o2); + } else if (itype(o1) != itype(o2)) { + return 0; + } else if (tvispri(o1)) { + return o1 != niltv(L) && o2 != niltv(L); +#if LJ_64 + } else if (tvislightud(o1)) { + return o1->u64 == o2->u64; +#endif + } else if (gcrefeq(o1->gcr, o2->gcr)) { + return 1; + } else if (!tvistabud(o1)) { + return 0; + } else { + TValue *base = lj_meta_equal(L, gcV(o1), gcV(o2), 0); + if ((uintptr_t)base <= 1) { + return (int)(uintptr_t)base; + } else { + L->top = base+2; + lj_vm_call(L, base, 1+1); + L->top -= 2; + return tvistruecond(L->top+1); + } + } +} + +LUA_API int lua_lessthan(lua_State *L, int idx1, int idx2) +{ + cTValue *o1 = index2adr(L, idx1); + cTValue *o2 = index2adr(L, idx2); + if (o1 == niltv(L) || o2 == niltv(L)) { + return 0; + } else if (tvisint(o1) && tvisint(o2)) { + return intV(o1) < intV(o2); + } else if (tvisnumber(o1) && tvisnumber(o2)) { + return numberVnum(o1) < numberVnum(o2); + } else { + TValue *base = lj_meta_comp(L, o1, o2, 0); + if ((uintptr_t)base <= 1) { + return (int)(uintptr_t)base; + } else { + L->top = base+2; + lj_vm_call(L, base, 1+1); + L->top -= 2; + return tvistruecond(L->top+1); + } + } +} + +LUA_API lua_Number lua_tonumber(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + TValue tmp; + if (LJ_LIKELY(tvisnumber(o))) + return numberVnum(o); + else if (tvisstr(o) && lj_strscan_num(strV(o), &tmp)) + return numV(&tmp); + else + return 0; +} + +LUALIB_API lua_Number luaL_checknumber(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + TValue tmp; + if (LJ_LIKELY(tvisnumber(o))) + return numberVnum(o); + else if (!(tvisstr(o) && lj_strscan_num(strV(o), &tmp))) + lj_err_argt(L, idx, LUA_TNUMBER); + return numV(&tmp); +} + +LUALIB_API lua_Number luaL_optnumber(lua_State *L, int idx, lua_Number def) +{ + cTValue *o = index2adr(L, idx); + TValue tmp; + if (LJ_LIKELY(tvisnumber(o))) + return numberVnum(o); + else if (tvisnil(o)) + return def; + else if (!(tvisstr(o) && lj_strscan_num(strV(o), &tmp))) + lj_err_argt(L, idx, LUA_TNUMBER); + return numV(&tmp); +} + +LUA_API lua_Integer lua_tointeger(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + TValue tmp; + lua_Number n; + if (LJ_LIKELY(tvisint(o))) { + return intV(o); + } else if (LJ_LIKELY(tvisnum(o))) { + n = numV(o); + } else { + if (!(tvisstr(o) && lj_strscan_number(strV(o), &tmp))) + return 0; + if (tvisint(&tmp)) + return (lua_Integer)intV(&tmp); + n = numV(&tmp); + } +#if LJ_64 + return (lua_Integer)n; +#else + return lj_num2int(n); +#endif +} + +LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + TValue tmp; + lua_Number n; + if (LJ_LIKELY(tvisint(o))) { + return intV(o); + } else if (LJ_LIKELY(tvisnum(o))) { + n = numV(o); + } else { + if (!(tvisstr(o) && lj_strscan_number(strV(o), &tmp))) + lj_err_argt(L, idx, LUA_TNUMBER); + if (tvisint(&tmp)) + return (lua_Integer)intV(&tmp); + n = numV(&tmp); + } +#if LJ_64 + return (lua_Integer)n; +#else + return lj_num2int(n); +#endif +} + +LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int idx, lua_Integer def) +{ + cTValue *o = index2adr(L, idx); + TValue tmp; + lua_Number n; + if (LJ_LIKELY(tvisint(o))) { + return intV(o); + } else if (LJ_LIKELY(tvisnum(o))) { + n = numV(o); + } else if (tvisnil(o)) { + return def; + } else { + if (!(tvisstr(o) && lj_strscan_number(strV(o), &tmp))) + lj_err_argt(L, idx, LUA_TNUMBER); + if (tvisint(&tmp)) + return (lua_Integer)intV(&tmp); + n = numV(&tmp); + } +#if LJ_64 + return (lua_Integer)n; +#else + return lj_num2int(n); +#endif +} + +LUA_API int lua_toboolean(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + return tvistruecond(o); +} + +LUA_API const char *lua_tolstring(lua_State *L, int idx, size_t *len) +{ + TValue *o = index2adr(L, idx); + GCstr *s; + if (LJ_LIKELY(tvisstr(o))) { + s = strV(o); + } else if (tvisnumber(o)) { + lj_gc_check(L); + o = index2adr(L, idx); /* GC may move the stack. */ + s = lj_str_fromnumber(L, o); + setstrV(L, o, s); + } else { + if (len != NULL) *len = 0; + return NULL; + } + if (len != NULL) *len = s->len; + return strdata(s); +} + +LUALIB_API const char *luaL_checklstring(lua_State *L, int idx, size_t *len) +{ + TValue *o = index2adr(L, idx); + GCstr *s; + if (LJ_LIKELY(tvisstr(o))) { + s = strV(o); + } else if (tvisnumber(o)) { + lj_gc_check(L); + o = index2adr(L, idx); /* GC may move the stack. */ + s = lj_str_fromnumber(L, o); + setstrV(L, o, s); + } else { + lj_err_argt(L, idx, LUA_TSTRING); + } + if (len != NULL) *len = s->len; + return strdata(s); +} + +LUALIB_API const char *luaL_optlstring(lua_State *L, int idx, + const char *def, size_t *len) +{ + TValue *o = index2adr(L, idx); + GCstr *s; + if (LJ_LIKELY(tvisstr(o))) { + s = strV(o); + } else if (tvisnil(o)) { + if (len != NULL) *len = def ? strlen(def) : 0; + return def; + } else if (tvisnumber(o)) { + lj_gc_check(L); + o = index2adr(L, idx); /* GC may move the stack. */ + s = lj_str_fromnumber(L, o); + setstrV(L, o, s); + } else { + lj_err_argt(L, idx, LUA_TSTRING); + } + if (len != NULL) *len = s->len; + return strdata(s); +} + +LUALIB_API int luaL_checkoption(lua_State *L, int idx, const char *def, + const char *const lst[]) +{ + ptrdiff_t i; + const char *s = lua_tolstring(L, idx, NULL); + if (s == NULL && (s = def) == NULL) + lj_err_argt(L, idx, LUA_TSTRING); + for (i = 0; lst[i]; i++) + if (strcmp(lst[i], s) == 0) + return (int)i; + lj_err_argv(L, idx, LJ_ERR_INVOPTM, s); +} + +LUA_API size_t lua_objlen(lua_State *L, int idx) +{ + TValue *o = index2adr(L, idx); + if (tvisstr(o)) { + return strV(o)->len; + } else if (tvistab(o)) { + return (size_t)lj_tab_len(tabV(o)); + } else if (tvisudata(o)) { + return udataV(o)->len; + } else if (tvisnumber(o)) { + GCstr *s = lj_str_fromnumber(L, o); + setstrV(L, o, s); + return s->len; + } else { + return 0; + } +} + +LUA_API lua_CFunction lua_tocfunction(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + if (tvisfunc(o)) { + BCOp op = bc_op(*mref(funcV(o)->c.pc, BCIns)); + if (op == BC_FUNCC || op == BC_FUNCCW) + return funcV(o)->c.f; + } + return NULL; +} + +LUA_API void *lua_touserdata(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + if (tvisudata(o)) + return uddata(udataV(o)); + else if (tvislightud(o)) + return lightudV(o); + else + return NULL; +} + +LUA_API lua_State *lua_tothread(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + return (!tvisthread(o)) ? NULL : threadV(o); +} + +LUA_API const void *lua_topointer(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + if (tvisudata(o)) + return uddata(udataV(o)); + else if (tvislightud(o)) + return lightudV(o); + else if (tviscdata(o)) + return cdataptr(cdataV(o)); + else if (tvisgcv(o)) + return gcV(o); + else + return NULL; +} + +/* -- Stack setters (object creation) ------------------------------------- */ + +LUA_API void lua_pushnil(lua_State *L) +{ + setnilV(L->top); + incr_top(L); +} + +LUA_API void lua_pushnumber(lua_State *L, lua_Number n) +{ + setnumV(L->top, n); + if (LJ_UNLIKELY(tvisnan(L->top))) + setnanV(L->top); /* Canonicalize injected NaNs. */ + incr_top(L); +} + +LUA_API void lua_pushinteger(lua_State *L, lua_Integer n) +{ + setintptrV(L->top, n); + incr_top(L); +} + +LUA_API void lua_pushlstring(lua_State *L, const char *str, size_t len) +{ + GCstr *s; + lj_gc_check(L); + s = lj_str_new(L, str, len); + setstrV(L, L->top, s); + incr_top(L); +} + +LUA_API void lua_pushstring(lua_State *L, const char *str) +{ + if (str == NULL) { + setnilV(L->top); + } else { + GCstr *s; + lj_gc_check(L); + s = lj_str_newz(L, str); + setstrV(L, L->top, s); + } + incr_top(L); +} + +LUA_API const char *lua_pushvfstring(lua_State *L, const char *fmt, + va_list argp) +{ + lj_gc_check(L); + return lj_str_pushvf(L, fmt, argp); +} + +LUA_API const char *lua_pushfstring(lua_State *L, const char *fmt, ...) +{ + const char *ret; + va_list argp; + lj_gc_check(L); + va_start(argp, fmt); + ret = lj_str_pushvf(L, fmt, argp); + va_end(argp); + return ret; +} + +LUA_API void lua_pushcclosure(lua_State *L, lua_CFunction f, int n) +{ + GCfunc *fn; + lj_gc_check(L); + api_checknelems(L, n); + fn = lj_func_newC(L, (MSize)n, getcurrenv(L)); + fn->c.f = f; + L->top -= n; + while (n--) + copyTV(L, &fn->c.upvalue[n], L->top+n); + setfuncV(L, L->top, fn); + lua_assert(iswhite(obj2gco(fn))); + incr_top(L); +} + +LUA_API void lua_pushboolean(lua_State *L, int b) +{ + setboolV(L->top, (b != 0)); + incr_top(L); +} + +LUA_API void lua_pushlightuserdata(lua_State *L, void *p) +{ + setlightudV(L->top, checklightudptr(L, p)); + incr_top(L); +} + +LUA_API void lua_createtable(lua_State *L, int narray, int nrec) +{ + GCtab *t; + lj_gc_check(L); + t = lj_tab_new(L, (uint32_t)(narray > 0 ? narray+1 : 0), hsize2hbits(nrec)); + settabV(L, L->top, t); + incr_top(L); +} + +LUALIB_API int luaL_newmetatable(lua_State *L, const char *tname) +{ + GCtab *regt = tabV(registry(L)); + TValue *tv = lj_tab_setstr(L, regt, lj_str_newz(L, tname)); + if (tvisnil(tv)) { + GCtab *mt = lj_tab_new(L, 0, 1); + settabV(L, tv, mt); + settabV(L, L->top++, mt); + lj_gc_anybarriert(L, regt); + return 1; + } else { + copyTV(L, L->top++, tv); + return 0; + } +} + +LUA_API int lua_pushthread(lua_State *L) +{ + setthreadV(L, L->top, L); + incr_top(L); + return (mainthread(G(L)) == L); +} + +LUA_API lua_State *lua_newthread(lua_State *L) +{ + lua_State *L1; + lj_gc_check(L); + L1 = lj_state_new(L); + setthreadV(L, L->top, L1); + incr_top(L); + return L1; +} + +LUA_API void *lua_newuserdata(lua_State *L, size_t size) +{ + GCudata *ud; + lj_gc_check(L); + if (size > LJ_MAX_UDATA) + lj_err_msg(L, LJ_ERR_UDATAOV); + ud = lj_udata_new(L, (MSize)size, getcurrenv(L)); + setudataV(L, L->top, ud); + incr_top(L); + return uddata(ud); +} + +LUA_API void lua_concat(lua_State *L, int n) +{ + api_checknelems(L, n); + if (n >= 2) { + n--; + do { + TValue *top = lj_meta_cat(L, L->top-1, -n); + if (top == NULL) { + L->top -= n; + break; + } + n -= (int)(L->top - top); + L->top = top+2; + lj_vm_call(L, top, 1+1); + L->top--; + copyTV(L, L->top-1, L->top); + } while (--n > 0); + } else if (n == 0) { /* Push empty string. */ + setstrV(L, L->top, &G(L)->strempty); + incr_top(L); + } + /* else n == 1: nothing to do. */ +} + +/* -- Object getters ------------------------------------------------------ */ + +LUA_API void lua_gettable(lua_State *L, int idx) +{ + cTValue *v, *t = index2adr(L, idx); + api_checkvalidindex(L, t); + v = lj_meta_tget(L, t, L->top-1); + if (v == NULL) { + L->top += 2; + lj_vm_call(L, L->top-2, 1+1); + L->top -= 2; + v = L->top+1; + } + copyTV(L, L->top-1, v); +} + +LUA_API void lua_getfield(lua_State *L, int idx, const char *k) +{ + cTValue *v, *t = index2adr(L, idx); + TValue key; + api_checkvalidindex(L, t); + setstrV(L, &key, lj_str_newz(L, k)); + v = lj_meta_tget(L, t, &key); + if (v == NULL) { + L->top += 2; + lj_vm_call(L, L->top-2, 1+1); + L->top -= 2; + v = L->top+1; + } + copyTV(L, L->top, v); + incr_top(L); +} + +LUA_API void lua_rawget(lua_State *L, int idx) +{ + cTValue *t = index2adr(L, idx); + api_check(L, tvistab(t)); + copyTV(L, L->top-1, lj_tab_get(L, tabV(t), L->top-1)); +} + +LUA_API void lua_rawgeti(lua_State *L, int idx, int n) +{ + cTValue *v, *t = index2adr(L, idx); + api_check(L, tvistab(t)); + v = lj_tab_getint(tabV(t), n); + if (v) { + copyTV(L, L->top, v); + } else { + setnilV(L->top); + } + incr_top(L); +} + +LUA_API int lua_getmetatable(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + GCtab *mt = NULL; + if (tvistab(o)) + mt = tabref(tabV(o)->metatable); + else if (tvisudata(o)) + mt = tabref(udataV(o)->metatable); + else + mt = tabref(basemt_obj(G(L), o)); + if (mt == NULL) + return 0; + settabV(L, L->top, mt); + incr_top(L); + return 1; +} + +LUALIB_API int luaL_getmetafield(lua_State *L, int idx, const char *field) +{ + if (lua_getmetatable(L, idx)) { + cTValue *tv = lj_tab_getstr(tabV(L->top-1), lj_str_newz(L, field)); + if (tv && !tvisnil(tv)) { + copyTV(L, L->top-1, tv); + return 1; + } + L->top--; + } + return 0; +} + +LUA_API void lua_getfenv(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + api_checkvalidindex(L, o); + if (tvisfunc(o)) { + settabV(L, L->top, tabref(funcV(o)->c.env)); + } else if (tvisudata(o)) { + settabV(L, L->top, tabref(udataV(o)->env)); + } else if (tvisthread(o)) { + settabV(L, L->top, tabref(threadV(o)->env)); + } else { + setnilV(L->top); + } + incr_top(L); +} + +LUA_API int lua_next(lua_State *L, int idx) +{ + cTValue *t = index2adr(L, idx); + int more; + api_check(L, tvistab(t)); + more = lj_tab_next(L, tabV(t), L->top-1); + if (more) { + incr_top(L); /* Return new key and value slot. */ + } else { /* End of traversal. */ + L->top--; /* Remove key slot. */ + } + return more; +} + +LUA_API const char *lua_getupvalue(lua_State *L, int idx, int n) +{ + TValue *val; + const char *name = lj_debug_uvnamev(index2adr(L, idx), (uint32_t)(n-1), &val); + if (name) { + copyTV(L, L->top, val); + incr_top(L); + } + return name; +} + +LUA_API void *lua_upvalueid(lua_State *L, int idx, int n) +{ + GCfunc *fn = funcV(index2adr(L, idx)); + n--; + api_check(L, (uint32_t)n < fn->l.nupvalues); + return isluafunc(fn) ? (void *)gcref(fn->l.uvptr[n]) : + (void *)&fn->c.upvalue[n]; +} + +LUA_API void lua_upvaluejoin(lua_State *L, int idx1, int n1, int idx2, int n2) +{ + GCfunc *fn1 = funcV(index2adr(L, idx1)); + GCfunc *fn2 = funcV(index2adr(L, idx2)); + n1--; n2--; + api_check(L, isluafunc(fn1) && (uint32_t)n1 < fn1->l.nupvalues); + api_check(L, isluafunc(fn2) && (uint32_t)n2 < fn2->l.nupvalues); + setgcrefr(fn1->l.uvptr[n1], fn2->l.uvptr[n2]); + lj_gc_objbarrier(L, fn1, gcref(fn1->l.uvptr[n1])); +} + +LUALIB_API void *luaL_checkudata(lua_State *L, int idx, const char *tname) +{ + cTValue *o = index2adr(L, idx); + if (tvisudata(o)) { + GCudata *ud = udataV(o); + cTValue *tv = lj_tab_getstr(tabV(registry(L)), lj_str_newz(L, tname)); + if (tv && tvistab(tv) && tabV(tv) == tabref(ud->metatable)) + return uddata(ud); + } + lj_err_argtype(L, idx, tname); + return NULL; /* unreachable */ +} + +/* -- Object setters ------------------------------------------------------ */ + +LUA_API void lua_settable(lua_State *L, int idx) +{ + TValue *o; + cTValue *t = index2adr(L, idx); + api_checknelems(L, 2); + api_checkvalidindex(L, t); + o = lj_meta_tset(L, t, L->top-2); + if (o) { + /* NOBARRIER: lj_meta_tset ensures the table is not black. */ + copyTV(L, o, L->top-1); + L->top -= 2; + } else { + L->top += 3; + copyTV(L, L->top-1, L->top-6); + lj_vm_call(L, L->top-3, 0+1); + L->top -= 3; + } +} + +LUA_API void lua_setfield(lua_State *L, int idx, const char *k) +{ + TValue *o; + TValue key; + cTValue *t = index2adr(L, idx); + api_checknelems(L, 1); + api_checkvalidindex(L, t); + setstrV(L, &key, lj_str_newz(L, k)); + o = lj_meta_tset(L, t, &key); + if (o) { + L->top--; + /* NOBARRIER: lj_meta_tset ensures the table is not black. */ + copyTV(L, o, L->top); + } else { + L->top += 3; + copyTV(L, L->top-1, L->top-6); + lj_vm_call(L, L->top-3, 0+1); + L->top -= 2; + } +} + +LUA_API void lua_rawset(lua_State *L, int idx) +{ + GCtab *t = tabV(index2adr(L, idx)); + TValue *dst, *key; + api_checknelems(L, 2); + key = L->top-2; + dst = lj_tab_set(L, t, key); + copyTV(L, dst, key+1); + lj_gc_anybarriert(L, t); + L->top = key; +} + +LUA_API void lua_rawseti(lua_State *L, int idx, int n) +{ + GCtab *t = tabV(index2adr(L, idx)); + TValue *dst, *src; + api_checknelems(L, 1); + dst = lj_tab_setint(L, t, n); + src = L->top-1; + copyTV(L, dst, src); + lj_gc_barriert(L, t, dst); + L->top = src; +} + +LUA_API int lua_setmetatable(lua_State *L, int idx) +{ + global_State *g; + GCtab *mt; + cTValue *o = index2adr(L, idx); + api_checknelems(L, 1); + api_checkvalidindex(L, o); + if (tvisnil(L->top-1)) { + mt = NULL; + } else { + api_check(L, tvistab(L->top-1)); + mt = tabV(L->top-1); + } + g = G(L); + if (tvistab(o)) { + setgcref(tabV(o)->metatable, obj2gco(mt)); + if (mt) + lj_gc_objbarriert(L, tabV(o), mt); + } else if (tvisudata(o)) { + setgcref(udataV(o)->metatable, obj2gco(mt)); + if (mt) + lj_gc_objbarrier(L, udataV(o), mt); + } else { + /* Flush cache, since traces specialize to basemt. But not during __gc. */ + if (lj_trace_flushall(L)) + lj_err_caller(L, LJ_ERR_NOGCMM); + if (tvisbool(o)) { + /* NOBARRIER: basemt is a GC root. */ + setgcref(basemt_it(g, LJ_TTRUE), obj2gco(mt)); + setgcref(basemt_it(g, LJ_TFALSE), obj2gco(mt)); + } else { + /* NOBARRIER: basemt is a GC root. */ + setgcref(basemt_obj(g, o), obj2gco(mt)); + } + } + L->top--; + return 1; +} + +LUA_API int lua_setfenv(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + GCtab *t; + api_checknelems(L, 1); + api_checkvalidindex(L, o); + api_check(L, tvistab(L->top-1)); + t = tabV(L->top-1); + if (tvisfunc(o)) { + setgcref(funcV(o)->c.env, obj2gco(t)); + } else if (tvisudata(o)) { + setgcref(udataV(o)->env, obj2gco(t)); + } else if (tvisthread(o)) { + setgcref(threadV(o)->env, obj2gco(t)); + } else { + L->top--; + return 0; + } + lj_gc_objbarrier(L, gcV(o), t); + L->top--; + return 1; +} + +LUA_API const char *lua_setupvalue(lua_State *L, int idx, int n) +{ + cTValue *f = index2adr(L, idx); + TValue *val; + const char *name; + api_checknelems(L, 1); + name = lj_debug_uvnamev(f, (uint32_t)(n-1), &val); + if (name) { + L->top--; + copyTV(L, val, L->top); + lj_gc_barrier(L, funcV(f), L->top); + } + return name; +} + +/* -- Calls --------------------------------------------------------------- */ + +LUA_API void lua_call(lua_State *L, int nargs, int nresults) +{ + api_check(L, L->status == 0 || L->status == LUA_ERRERR); + api_checknelems(L, nargs+1); + lj_vm_call(L, L->top - nargs, nresults+1); +} + +LUA_API int lua_pcall(lua_State *L, int nargs, int nresults, int errfunc) +{ + global_State *g = G(L); + uint8_t oldh = hook_save(g); + ptrdiff_t ef; + int status; + api_check(L, L->status == 0 || L->status == LUA_ERRERR); + api_checknelems(L, nargs+1); + if (errfunc == 0) { + ef = 0; + } else { + cTValue *o = stkindex2adr(L, errfunc); + api_checkvalidindex(L, o); + ef = savestack(L, o); + } + status = lj_vm_pcall(L, L->top - nargs, nresults+1, ef); + if (status) hook_restore(g, oldh); + return status; +} + +static TValue *cpcall(lua_State *L, lua_CFunction func, void *ud) +{ + GCfunc *fn = lj_func_newC(L, 0, getcurrenv(L)); + fn->c.f = func; + setfuncV(L, L->top, fn); + setlightudV(L->top+1, checklightudptr(L, ud)); + cframe_nres(L->cframe) = 1+0; /* Zero results. */ + L->top += 2; + return L->top-1; /* Now call the newly allocated C function. */ +} + +LUA_API int lua_cpcall(lua_State *L, lua_CFunction func, void *ud) +{ + global_State *g = G(L); + uint8_t oldh = hook_save(g); + int status; + api_check(L, L->status == 0 || L->status == LUA_ERRERR); + status = lj_vm_cpcall(L, func, ud, cpcall); + if (status) hook_restore(g, oldh); + return status; +} + +LUALIB_API int luaL_callmeta(lua_State *L, int idx, const char *field) +{ + if (luaL_getmetafield(L, idx, field)) { + TValue *base = L->top--; + copyTV(L, base, index2adr(L, idx)); + L->top = base+1; + lj_vm_call(L, base, 1+1); + return 1; + } + return 0; +} + +/* -- Coroutine yield and resume ------------------------------------------ */ + +LUA_API int lua_yield(lua_State *L, int nresults) +{ + void *cf = L->cframe; + global_State *g = G(L); + if (cframe_canyield(cf)) { + cf = cframe_raw(cf); + if (!hook_active(g)) { /* Regular yield: move results down if needed. */ + cTValue *f = L->top - nresults; + if (f > L->base) { + TValue *t = L->base; + while (--nresults >= 0) copyTV(L, t++, f++); + L->top = t; + } + L->cframe = NULL; + L->status = LUA_YIELD; + return -1; + } else { /* Yield from hook: add a pseudo-frame. */ + TValue *top = L->top; + hook_leave(g); + top->u64 = cframe_multres(cf); + setcont(top+1, lj_cont_hook); + setframe_pc(top+1, cframe_pc(cf)-1); + setframe_gc(top+2, obj2gco(L)); + setframe_ftsz(top+2, (int)((char *)(top+3)-(char *)L->base)+FRAME_CONT); + L->top = L->base = top+3; +#if LJ_TARGET_X64 + lj_err_throw(L, LUA_YIELD); +#else + L->cframe = NULL; + L->status = LUA_YIELD; + lj_vm_unwind_c(cf, LUA_YIELD); +#endif + } + } + lj_err_msg(L, LJ_ERR_CYIELD); + return 0; /* unreachable */ +} + +LUA_API int lua_resume(lua_State *L, int nargs) +{ + if (L->cframe == NULL && L->status <= LUA_YIELD) + return lj_vm_resume(L, L->top - nargs, 0, 0); + L->top = L->base; + setstrV(L, L->top, lj_err_str(L, LJ_ERR_COSUSP)); + incr_top(L); + return LUA_ERRRUN; +} + +/* -- GC and memory management -------------------------------------------- */ + +LUA_API int lua_gc(lua_State *L, int what, int data) +{ + global_State *g = G(L); + int res = 0; + switch (what) { + case LUA_GCSTOP: + g->gc.threshold = LJ_MAX_MEM; + break; + case LUA_GCRESTART: + g->gc.threshold = data == -1 ? (g->gc.total/100)*g->gc.pause : g->gc.total; + break; + case LUA_GCCOLLECT: + lj_gc_fullgc(L); + break; + case LUA_GCCOUNT: + res = (int)(g->gc.total >> 10); + break; + case LUA_GCCOUNTB: + res = (int)(g->gc.total & 0x3ff); + break; + case LUA_GCSTEP: { + MSize a = (MSize)data << 10; + g->gc.threshold = (a <= g->gc.total) ? (g->gc.total - a) : 0; + while (g->gc.total >= g->gc.threshold) + if (lj_gc_step(L) > 0) { + res = 1; + break; + } + break; + } + case LUA_GCSETPAUSE: + res = (int)(g->gc.pause); + g->gc.pause = (MSize)data; + break; + case LUA_GCSETSTEPMUL: + res = (int)(g->gc.stepmul); + g->gc.stepmul = (MSize)data; + break; + default: + res = -1; /* Invalid option. */ + } + return res; +} + +LUA_API lua_Alloc lua_getallocf(lua_State *L, void **ud) +{ + global_State *g = G(L); + if (ud) *ud = g->allocd; + return g->allocf; +} + +LUA_API void lua_setallocf(lua_State *L, lua_Alloc f, void *ud) +{ + global_State *g = G(L); + g->allocd = ud; + g->allocf = f; +} + + +``` + +`include/luajit-2.0.5/src/lj_arch.h`: + +```h +/* +** Target architecture selection. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_ARCH_H +#define _LJ_ARCH_H + +#include "lua.h" + +/* Target endianess. */ +#define LUAJIT_LE 0 +#define LUAJIT_BE 1 + +/* Target architectures. */ +#define LUAJIT_ARCH_X86 1 +#define LUAJIT_ARCH_x86 1 +#define LUAJIT_ARCH_X64 2 +#define LUAJIT_ARCH_x64 2 +#define LUAJIT_ARCH_ARM 3 +#define LUAJIT_ARCH_arm 3 +#define LUAJIT_ARCH_PPC 4 +#define LUAJIT_ARCH_ppc 4 +#define LUAJIT_ARCH_PPCSPE 5 +#define LUAJIT_ARCH_ppcspe 5 +#define LUAJIT_ARCH_MIPS 6 +#define LUAJIT_ARCH_mips 6 + +/* Target OS. */ +#define LUAJIT_OS_OTHER 0 +#define LUAJIT_OS_WINDOWS 1 +#define LUAJIT_OS_LINUX 2 +#define LUAJIT_OS_OSX 3 +#define LUAJIT_OS_BSD 4 +#define LUAJIT_OS_POSIX 5 + +/* Select native target if no target defined. */ +#ifndef LUAJIT_TARGET + +#if defined(__i386) || defined(__i386__) || defined(_M_IX86) +#define LUAJIT_TARGET LUAJIT_ARCH_X86 +#elif defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) +#define LUAJIT_TARGET LUAJIT_ARCH_X64 +#elif defined(__arm__) || defined(__arm) || defined(__ARM__) || defined(__ARM) +#define LUAJIT_TARGET LUAJIT_ARCH_ARM +#elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC) +#ifdef __NO_FPRS__ +#define LUAJIT_TARGET LUAJIT_ARCH_PPCSPE +#else +#define LUAJIT_TARGET LUAJIT_ARCH_PPC +#endif +#elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(__MIPS) +#define LUAJIT_TARGET LUAJIT_ARCH_MIPS +#else +#error "No support for this architecture (yet)" +#endif + +#endif + +/* Select native OS if no target OS defined. */ +#ifndef LUAJIT_OS + +#if defined(_WIN32) && !defined(_XBOX_VER) +#define LUAJIT_OS LUAJIT_OS_WINDOWS +#elif defined(__linux__) +#define LUAJIT_OS LUAJIT_OS_LINUX +#elif defined(__MACH__) && defined(__APPLE__) +#define LUAJIT_OS LUAJIT_OS_OSX +#elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ + defined(__NetBSD__) || defined(__OpenBSD__) || \ + defined(__DragonFly__)) && !defined(__ORBIS__) +#define LUAJIT_OS LUAJIT_OS_BSD +#elif (defined(__sun__) && defined(__svr4__)) +#define LUAJIT_OS LUAJIT_OS_POSIX +#elif defined(__CYGWIN__) +#define LJ_TARGET_CYGWIN 1 +#define LUAJIT_OS LUAJIT_OS_POSIX +#else +#define LUAJIT_OS LUAJIT_OS_OTHER +#endif + +#endif + +/* Set target OS properties. */ +#if LUAJIT_OS == LUAJIT_OS_WINDOWS +#define LJ_OS_NAME "Windows" +#elif LUAJIT_OS == LUAJIT_OS_LINUX +#define LJ_OS_NAME "Linux" +#elif LUAJIT_OS == LUAJIT_OS_OSX +#define LJ_OS_NAME "OSX" +#elif LUAJIT_OS == LUAJIT_OS_BSD +#define LJ_OS_NAME "BSD" +#elif LUAJIT_OS == LUAJIT_OS_POSIX +#define LJ_OS_NAME "POSIX" +#else +#define LJ_OS_NAME "Other" +#endif + +#define LJ_TARGET_WINDOWS (LUAJIT_OS == LUAJIT_OS_WINDOWS) +#define LJ_TARGET_LINUX (LUAJIT_OS == LUAJIT_OS_LINUX) +#define LJ_TARGET_OSX (LUAJIT_OS == LUAJIT_OS_OSX) +#define LJ_TARGET_IOS (LJ_TARGET_OSX && LUAJIT_TARGET == LUAJIT_ARCH_ARM) +#define LJ_TARGET_POSIX (LUAJIT_OS > LUAJIT_OS_WINDOWS) +#define LJ_TARGET_DLOPEN LJ_TARGET_POSIX + +#ifdef __CELLOS_LV2__ +#define LJ_TARGET_PS3 1 +#define LJ_TARGET_CONSOLE 1 +#endif + +#ifdef __ORBIS__ +#define LJ_TARGET_PS4 1 +#define LJ_TARGET_CONSOLE 1 +#undef NULL +#define NULL ((void*)0) +#endif + +#ifdef __psp2__ +#define LJ_TARGET_PSVITA 1 +#define LJ_TARGET_CONSOLE 1 +#endif + +#if _XBOX_VER >= 200 +#define LJ_TARGET_XBOX360 1 +#define LJ_TARGET_CONSOLE 1 +#endif + +#define LJ_NUMMODE_SINGLE 0 /* Single-number mode only. */ +#define LJ_NUMMODE_SINGLE_DUAL 1 /* Default to single-number mode. */ +#define LJ_NUMMODE_DUAL 2 /* Dual-number mode only. */ +#define LJ_NUMMODE_DUAL_SINGLE 3 /* Default to dual-number mode. */ + +/* Set target architecture properties. */ +#if LUAJIT_TARGET == LUAJIT_ARCH_X86 + +#define LJ_ARCH_NAME "x86" +#define LJ_ARCH_BITS 32 +#define LJ_ARCH_ENDIAN LUAJIT_LE +#if LJ_TARGET_WINDOWS || LJ_TARGET_CYGWIN +#define LJ_ABI_WIN 1 +#else +#define LJ_ABI_WIN 0 +#endif +#define LJ_TARGET_X86 1 +#define LJ_TARGET_X86ORX64 1 +#define LJ_TARGET_EHRETREG 0 +#define LJ_TARGET_MASKSHIFT 1 +#define LJ_TARGET_MASKROT 1 +#define LJ_TARGET_UNALIGNED 1 +#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE_DUAL + +#elif LUAJIT_TARGET == LUAJIT_ARCH_X64 + +#define LJ_ARCH_NAME "x64" +#define LJ_ARCH_BITS 64 +#define LJ_ARCH_ENDIAN LUAJIT_LE +#if LJ_TARGET_WINDOWS || LJ_TARGET_CYGWIN +#define LJ_ABI_WIN 1 +#else +#define LJ_ABI_WIN 0 +#endif +#define LJ_TARGET_X64 1 +#define LJ_TARGET_X86ORX64 1 +#define LJ_TARGET_EHRETREG 0 +#define LJ_TARGET_JUMPRANGE 31 /* +-2^31 = +-2GB */ +#define LJ_TARGET_MASKSHIFT 1 +#define LJ_TARGET_MASKROT 1 +#define LJ_TARGET_UNALIGNED 1 +#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE_DUAL + +#elif LUAJIT_TARGET == LUAJIT_ARCH_ARM + +#define LJ_ARCH_NAME "arm" +#define LJ_ARCH_BITS 32 +#define LJ_ARCH_ENDIAN LUAJIT_LE +#if !defined(LJ_ARCH_HASFPU) && __SOFTFP__ +#define LJ_ARCH_HASFPU 0 +#endif +#if !defined(LJ_ABI_SOFTFP) && !__ARM_PCS_VFP +#define LJ_ABI_SOFTFP 1 +#endif +#define LJ_ABI_EABI 1 +#define LJ_TARGET_ARM 1 +#define LJ_TARGET_EHRETREG 0 +#define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */ +#define LJ_TARGET_MASKSHIFT 0 +#define LJ_TARGET_MASKROT 1 +#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ +#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL + +#if __ARM_ARCH____ARM_ARCH_8__ || __ARM_ARCH_8A__ +#define LJ_ARCH_VERSION 80 +#elif __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH_7S__ || __ARM_ARCH_7VE__ +#define LJ_ARCH_VERSION 70 +#elif __ARM_ARCH_6T2__ +#define LJ_ARCH_VERSION 61 +#elif __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6K__ || __ARM_ARCH_6Z__ || __ARM_ARCH_6ZK__ +#define LJ_ARCH_VERSION 60 +#else +#define LJ_ARCH_VERSION 50 +#endif + +#elif LUAJIT_TARGET == LUAJIT_ARCH_PPC + +#define LJ_ARCH_NAME "ppc" +#if _LP64 +#define LJ_ARCH_BITS 64 +#else +#define LJ_ARCH_BITS 32 +#endif +#define LJ_ARCH_ENDIAN LUAJIT_BE +#define LJ_TARGET_PPC 1 +#define LJ_TARGET_EHRETREG 3 +#define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */ +#define LJ_TARGET_MASKSHIFT 0 +#define LJ_TARGET_MASKROT 1 +#define LJ_TARGET_UNIFYROT 1 /* Want only IR_BROL. */ +#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL_SINGLE + +#if _ARCH_PWR7 +#define LJ_ARCH_VERSION 70 +#elif _ARCH_PWR6 +#define LJ_ARCH_VERSION 60 +#elif _ARCH_PWR5X +#define LJ_ARCH_VERSION 51 +#elif _ARCH_PWR5 +#define LJ_ARCH_VERSION 50 +#elif _ARCH_PWR4 +#define LJ_ARCH_VERSION 40 +#else +#define LJ_ARCH_VERSION 0 +#endif +#if __PPC64__ || __powerpc64__ || LJ_TARGET_CONSOLE +#define LJ_ARCH_PPC64 1 +#define LJ_ARCH_NOFFI 1 +#endif +#if _ARCH_PPCSQ +#define LJ_ARCH_SQRT 1 +#endif +#if _ARCH_PWR5X +#define LJ_ARCH_ROUND 1 +#endif +#if __PPU__ +#define LJ_ARCH_CELL 1 +#endif +#if LJ_TARGET_XBOX360 +#define LJ_ARCH_XENON 1 +#endif + +#elif LUAJIT_TARGET == LUAJIT_ARCH_PPCSPE + +#define LJ_ARCH_NAME "ppcspe" +#define LJ_ARCH_BITS 32 +#define LJ_ARCH_ENDIAN LUAJIT_BE +#ifndef LJ_ABI_SOFTFP +#define LJ_ABI_SOFTFP 1 +#endif +#define LJ_ABI_EABI 1 +#define LJ_TARGET_PPCSPE 1 +#define LJ_TARGET_EHRETREG 3 +#define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */ +#define LJ_TARGET_MASKSHIFT 0 +#define LJ_TARGET_MASKROT 1 +#define LJ_TARGET_UNIFYROT 1 /* Want only IR_BROL. */ +#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE +#define LJ_ARCH_NOFFI 1 /* NYI: comparisons, calls. */ +#define LJ_ARCH_NOJIT 1 + +#elif LUAJIT_TARGET == LUAJIT_ARCH_MIPS + +#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) +#define LJ_ARCH_NAME "mipsel" +#define LJ_ARCH_ENDIAN LUAJIT_LE +#else +#define LJ_ARCH_NAME "mips" +#define LJ_ARCH_ENDIAN LUAJIT_BE +#endif +#define LJ_ARCH_BITS 32 +#define LJ_TARGET_MIPS 1 +#define LJ_TARGET_EHRETREG 4 +#define LJ_TARGET_JUMPRANGE 27 /* 2*2^27 = 256MB-aligned region */ +#define LJ_TARGET_MASKSHIFT 1 +#define LJ_TARGET_MASKROT 1 +#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ +#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE + +#if _MIPS_ARCH_MIPS32R2 +#define LJ_ARCH_VERSION 20 +#else +#define LJ_ARCH_VERSION 10 +#endif + +#else +#error "No target architecture defined" +#endif + +#ifndef LJ_PAGESIZE +#define LJ_PAGESIZE 4096 +#endif + +/* Check for minimum required compiler versions. */ +#if defined(__GNUC__) +#if LJ_TARGET_X86 +#if (__GNUC__ < 3) || ((__GNUC__ == 3) && __GNUC_MINOR__ < 4) +#error "Need at least GCC 3.4 or newer" +#endif +#elif LJ_TARGET_X64 +#if __GNUC__ < 4 +#error "Need at least GCC 4.0 or newer" +#endif +#elif LJ_TARGET_ARM +#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 2) +#error "Need at least GCC 4.2 or newer" +#endif +#elif !LJ_TARGET_PS3 +#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3) +#error "Need at least GCC 4.3 or newer" +#endif +#endif +#endif + +/* Check target-specific constraints. */ +#ifndef _BUILDVM_H +#if LJ_TARGET_X64 +#if __USING_SJLJ_EXCEPTIONS__ +#error "Need a C compiler with native exception handling on x64" +#endif +#elif LJ_TARGET_ARM +#if defined(__ARMEB__) +#error "No support for big-endian ARM" +#endif +#if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ +#error "No support for Cortex-M CPUs" +#endif +#if !(__ARM_EABI__ || LJ_TARGET_IOS) +#error "Only ARM EABI or iOS 3.0+ ABI is supported" +#endif +#elif LJ_TARGET_PPC || LJ_TARGET_PPCSPE +#if defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE) +#error "No support for PowerPC CPUs without double-precision FPU" +#endif +#if defined(_LITTLE_ENDIAN) +#error "No support for little-endian PowerPC" +#endif +#if defined(_LP64) +#error "No support for PowerPC 64 bit mode" +#endif +#elif LJ_TARGET_MIPS +#if defined(__mips_soft_float) +#error "No support for MIPS CPUs without FPU" +#endif +#if defined(_LP64) +#error "No support for MIPS64" +#endif +#endif +#endif + +/* Enable or disable the dual-number mode for the VM. */ +#if (LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE && LUAJIT_NUMMODE == 2) || \ + (LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL && LUAJIT_NUMMODE == 1) +#error "No support for this number mode on this architecture" +#endif +#if LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL || \ + (LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL_SINGLE && LUAJIT_NUMMODE != 1) || \ + (LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE_DUAL && LUAJIT_NUMMODE == 2) +#define LJ_DUALNUM 1 +#else +#define LJ_DUALNUM 0 +#endif + +#if LJ_TARGET_IOS || LJ_TARGET_CONSOLE +/* Runtime code generation is restricted on iOS. Complain to Apple, not me. */ +/* Ditto for the consoles. Complain to Sony or MS, not me. */ +#ifndef LUAJIT_ENABLE_JIT +#define LJ_OS_NOJIT 1 +#endif +#endif + +/* Disable or enable the JIT compiler. */ +#if defined(LUAJIT_DISABLE_JIT) || defined(LJ_ARCH_NOJIT) || defined(LJ_OS_NOJIT) +#define LJ_HASJIT 0 +#else +#define LJ_HASJIT 1 +#endif + +/* Disable or enable the FFI extension. */ +#if defined(LUAJIT_DISABLE_FFI) || defined(LJ_ARCH_NOFFI) +#define LJ_HASFFI 0 +#else +#define LJ_HASFFI 1 +#endif + +#ifndef LJ_ARCH_HASFPU +#define LJ_ARCH_HASFPU 1 +#endif +#ifndef LJ_ABI_SOFTFP +#define LJ_ABI_SOFTFP 0 +#endif +#define LJ_SOFTFP (!LJ_ARCH_HASFPU) + +#if LJ_ARCH_ENDIAN == LUAJIT_BE +#define LJ_LE 0 +#define LJ_BE 1 +#define LJ_ENDIAN_SELECT(le, be) be +#define LJ_ENDIAN_LOHI(lo, hi) hi lo +#else +#define LJ_LE 1 +#define LJ_BE 0 +#define LJ_ENDIAN_SELECT(le, be) le +#define LJ_ENDIAN_LOHI(lo, hi) lo hi +#endif + +#if LJ_ARCH_BITS == 32 +#define LJ_32 1 +#define LJ_64 0 +#else +#define LJ_32 0 +#define LJ_64 1 +#endif + +#ifndef LJ_TARGET_UNALIGNED +#define LJ_TARGET_UNALIGNED 0 +#endif + +/* Various workarounds for embedded operating systems. */ +#if (defined(__ANDROID__) && !defined(LJ_TARGET_X86ORX64)) || defined(__symbian__) || LJ_TARGET_XBOX360 +#define LUAJIT_NO_LOG2 +#endif +#if defined(__symbian__) +#define LUAJIT_NO_EXP2 +#endif +#if LJ_TARGET_CONSOLE || (LJ_TARGET_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0) +#define LJ_NO_SYSTEM 1 +#endif + +#if !defined(LUAJIT_NO_UNWIND) && __GNU_COMPACT_EH__ +/* NYI: no support for compact unwind specification, yet. */ +#define LUAJIT_NO_UNWIND 1 +#endif + +#if defined(LUAJIT_NO_UNWIND) || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3 || LJ_TARGET_PS4 +#define LJ_NO_UNWIND 1 +#endif + +/* Compatibility with Lua 5.1 vs. 5.2. */ +#ifdef LUAJIT_ENABLE_LUA52COMPAT +#define LJ_52 1 +#else +#define LJ_52 0 +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_asm.c`: + +```c +/* +** IR assembler (SSA IR -> machine code). +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_asm_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_gc.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_frame.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#endif +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_ircall.h" +#include "lj_iropt.h" +#include "lj_mcode.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#include "lj_snap.h" +#include "lj_asm.h" +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "lj_target.h" + +#ifdef LUA_USE_ASSERT +#include +#endif + +/* -- Assembler state and common macros ----------------------------------- */ + +/* Assembler state. */ +typedef struct ASMState { + RegCost cost[RID_MAX]; /* Reference and blended allocation cost for regs. */ + + MCode *mcp; /* Current MCode pointer (grows down). */ + MCode *mclim; /* Lower limit for MCode memory + red zone. */ +#ifdef LUA_USE_ASSERT + MCode *mcp_prev; /* Red zone overflow check. */ +#endif + + IRIns *ir; /* Copy of pointer to IR instructions/constants. */ + jit_State *J; /* JIT compiler state. */ + +#if LJ_TARGET_X86ORX64 + x86ModRM mrm; /* Fused x86 address operand. */ +#endif + + RegSet freeset; /* Set of free registers. */ + RegSet modset; /* Set of registers modified inside the loop. */ + RegSet weakset; /* Set of weakly referenced registers. */ + RegSet phiset; /* Set of PHI registers. */ + + uint32_t flags; /* Copy of JIT compiler flags. */ + int loopinv; /* Loop branch inversion (0:no, 1:yes, 2:yes+CC_P). */ + + int32_t evenspill; /* Next even spill slot. */ + int32_t oddspill; /* Next odd spill slot (or 0). */ + + IRRef curins; /* Reference of current instruction. */ + IRRef stopins; /* Stop assembly before hitting this instruction. */ + IRRef orignins; /* Original T->nins. */ + + IRRef snapref; /* Current snapshot is active after this reference. */ + IRRef snaprename; /* Rename highwater mark for snapshot check. */ + SnapNo snapno; /* Current snapshot number. */ + SnapNo loopsnapno; /* Loop snapshot number. */ + + IRRef fuseref; /* Fusion limit (loopref, 0 or FUSE_DISABLED). */ + IRRef sectref; /* Section base reference (loopref or 0). */ + IRRef loopref; /* Reference of LOOP instruction (or 0). */ + + BCReg topslot; /* Number of slots for stack check (unless 0). */ + int32_t gcsteps; /* Accumulated number of GC steps (per section). */ + + GCtrace *T; /* Trace to assemble. */ + GCtrace *parent; /* Parent trace (or NULL). */ + + MCode *mcbot; /* Bottom of reserved MCode. */ + MCode *mctop; /* Top of generated MCode. */ + MCode *mcloop; /* Pointer to loop MCode (or NULL). */ + MCode *invmcp; /* Points to invertible loop branch (or NULL). */ + MCode *flagmcp; /* Pending opportunity to merge flag setting ins. */ + MCode *realign; /* Realign loop if not NULL. */ + +#ifdef RID_NUM_KREF + int32_t krefk[RID_NUM_KREF]; +#endif + IRRef1 phireg[RID_MAX]; /* PHI register references. */ + uint16_t parentmap[LJ_MAX_JSLOTS]; /* Parent instruction to RegSP map. */ +} ASMState; + +#define IR(ref) (&as->ir[(ref)]) + +#define ASMREF_TMP1 REF_TRUE /* Temp. register. */ +#define ASMREF_TMP2 REF_FALSE /* Temp. register. */ +#define ASMREF_L REF_NIL /* Stores register for L. */ + +/* Check for variant to invariant references. */ +#define iscrossref(as, ref) ((ref) < as->sectref) + +/* Inhibit memory op fusion from variant to invariant references. */ +#define FUSE_DISABLED (~(IRRef)0) +#define mayfuse(as, ref) ((ref) > as->fuseref) +#define neverfuse(as) (as->fuseref == FUSE_DISABLED) +#define canfuse(as, ir) (!neverfuse(as) && !irt_isphi((ir)->t)) +#define opisfusableload(o) \ + ((o) == IR_ALOAD || (o) == IR_HLOAD || (o) == IR_ULOAD || \ + (o) == IR_FLOAD || (o) == IR_XLOAD || (o) == IR_SLOAD || (o) == IR_VLOAD) + +/* Sparse limit checks using a red zone before the actual limit. */ +#define MCLIM_REDZONE 64 + +static LJ_NORET LJ_NOINLINE void asm_mclimit(ASMState *as) +{ + lj_mcode_limiterr(as->J, (size_t)(as->mctop - as->mcp + 4*MCLIM_REDZONE)); +} + +static LJ_AINLINE void checkmclim(ASMState *as) +{ +#ifdef LUA_USE_ASSERT + if (as->mcp + MCLIM_REDZONE < as->mcp_prev) { + IRIns *ir = IR(as->curins+1); + fprintf(stderr, "RED ZONE OVERFLOW: %p IR %04d %02d %04d %04d\n", as->mcp, + as->curins+1-REF_BIAS, ir->o, ir->op1-REF_BIAS, ir->op2-REF_BIAS); + lua_assert(0); + } +#endif + if (LJ_UNLIKELY(as->mcp < as->mclim)) asm_mclimit(as); +#ifdef LUA_USE_ASSERT + as->mcp_prev = as->mcp; +#endif +} + +#ifdef RID_NUM_KREF +#define ra_iskref(ref) ((ref) < RID_NUM_KREF) +#define ra_krefreg(ref) ((Reg)(RID_MIN_KREF + (Reg)(ref))) +#define ra_krefk(as, ref) (as->krefk[(ref)]) + +static LJ_AINLINE void ra_setkref(ASMState *as, Reg r, int32_t k) +{ + IRRef ref = (IRRef)(r - RID_MIN_KREF); + as->krefk[ref] = k; + as->cost[r] = REGCOST(ref, ref); +} + +#else +#define ra_iskref(ref) 0 +#define ra_krefreg(ref) RID_MIN_GPR +#define ra_krefk(as, ref) 0 +#endif + +/* Arch-specific field offsets. */ +static const uint8_t field_ofs[IRFL__MAX+1] = { +#define FLOFS(name, ofs) (uint8_t)(ofs), +IRFLDEF(FLOFS) +#undef FLOFS + 0 +}; + +/* -- Target-specific instruction emitter --------------------------------- */ + +#if LJ_TARGET_X86ORX64 +#include "lj_emit_x86.h" +#elif LJ_TARGET_ARM +#include "lj_emit_arm.h" +#elif LJ_TARGET_PPC +#include "lj_emit_ppc.h" +#elif LJ_TARGET_MIPS +#include "lj_emit_mips.h" +#else +#error "Missing instruction emitter for target CPU" +#endif + +/* -- Register allocator debugging ---------------------------------------- */ + +/* #define LUAJIT_DEBUG_RA */ + +#ifdef LUAJIT_DEBUG_RA + +#include +#include + +#define RIDNAME(name) #name, +static const char *const ra_regname[] = { + GPRDEF(RIDNAME) + FPRDEF(RIDNAME) + VRIDDEF(RIDNAME) + NULL +}; +#undef RIDNAME + +static char ra_dbg_buf[65536]; +static char *ra_dbg_p; +static char *ra_dbg_merge; +static MCode *ra_dbg_mcp; + +static void ra_dstart(void) +{ + ra_dbg_p = ra_dbg_buf; + ra_dbg_merge = NULL; + ra_dbg_mcp = NULL; +} + +static void ra_dflush(void) +{ + fwrite(ra_dbg_buf, 1, (size_t)(ra_dbg_p-ra_dbg_buf), stdout); + ra_dstart(); +} + +static void ra_dprintf(ASMState *as, const char *fmt, ...) +{ + char *p; + va_list argp; + va_start(argp, fmt); + p = ra_dbg_mcp == as->mcp ? ra_dbg_merge : ra_dbg_p; + ra_dbg_mcp = NULL; + p += sprintf(p, "%08x \e[36m%04d ", (uintptr_t)as->mcp, as->curins-REF_BIAS); + for (;;) { + const char *e = strchr(fmt, '$'); + if (e == NULL) break; + memcpy(p, fmt, (size_t)(e-fmt)); + p += e-fmt; + if (e[1] == 'r') { + Reg r = va_arg(argp, Reg) & RID_MASK; + if (r <= RID_MAX) { + const char *q; + for (q = ra_regname[r]; *q; q++) + *p++ = *q >= 'A' && *q <= 'Z' ? *q + 0x20 : *q; + } else { + *p++ = '?'; + lua_assert(0); + } + } else if (e[1] == 'f' || e[1] == 'i') { + IRRef ref; + if (e[1] == 'f') + ref = va_arg(argp, IRRef); + else + ref = va_arg(argp, IRIns *) - as->ir; + if (ref >= REF_BIAS) + p += sprintf(p, "%04d", ref - REF_BIAS); + else + p += sprintf(p, "K%03d", REF_BIAS - ref); + } else if (e[1] == 's') { + uint32_t slot = va_arg(argp, uint32_t); + p += sprintf(p, "[sp+0x%x]", sps_scale(slot)); + } else if (e[1] == 'x') { + p += sprintf(p, "%08x", va_arg(argp, int32_t)); + } else { + lua_assert(0); + } + fmt = e+2; + } + va_end(argp); + while (*fmt) + *p++ = *fmt++; + *p++ = '\e'; *p++ = '['; *p++ = 'm'; *p++ = '\n'; + if (p > ra_dbg_buf+sizeof(ra_dbg_buf)-256) { + fwrite(ra_dbg_buf, 1, (size_t)(p-ra_dbg_buf), stdout); + p = ra_dbg_buf; + } + ra_dbg_p = p; +} + +#define RA_DBG_START() ra_dstart() +#define RA_DBG_FLUSH() ra_dflush() +#define RA_DBG_REF() \ + do { char *_p = ra_dbg_p; ra_dprintf(as, ""); \ + ra_dbg_merge = _p; ra_dbg_mcp = as->mcp; } while (0) +#define RA_DBGX(x) ra_dprintf x + +#else +#define RA_DBG_START() ((void)0) +#define RA_DBG_FLUSH() ((void)0) +#define RA_DBG_REF() ((void)0) +#define RA_DBGX(x) ((void)0) +#endif + +/* -- Register allocator -------------------------------------------------- */ + +#define ra_free(as, r) rset_set(as->freeset, (r)) +#define ra_modified(as, r) rset_set(as->modset, (r)) +#define ra_weak(as, r) rset_set(as->weakset, (r)) +#define ra_noweak(as, r) rset_clear(as->weakset, (r)) + +#define ra_used(ir) (ra_hasreg((ir)->r) || ra_hasspill((ir)->s)) + +/* Setup register allocator. */ +static void ra_setup(ASMState *as) +{ + Reg r; + /* Initially all regs (except the stack pointer) are free for use. */ + as->freeset = RSET_INIT; + as->modset = RSET_EMPTY; + as->weakset = RSET_EMPTY; + as->phiset = RSET_EMPTY; + memset(as->phireg, 0, sizeof(as->phireg)); + for (r = RID_MIN_GPR; r < RID_MAX; r++) + as->cost[r] = REGCOST(~0u, 0u); +} + +/* Rematerialize constants. */ +static Reg ra_rematk(ASMState *as, IRRef ref) +{ + IRIns *ir; + Reg r; + if (ra_iskref(ref)) { + r = ra_krefreg(ref); + lua_assert(!rset_test(as->freeset, r)); + ra_free(as, r); + ra_modified(as, r); + emit_loadi(as, r, ra_krefk(as, ref)); + return r; + } + ir = IR(ref); + r = ir->r; + lua_assert(ra_hasreg(r) && !ra_hasspill(ir->s)); + ra_free(as, r); + ra_modified(as, r); + ir->r = RID_INIT; /* Do not keep any hint. */ + RA_DBGX((as, "remat $i $r", ir, r)); +#if !LJ_SOFTFP + if (ir->o == IR_KNUM) { + emit_loadn(as, r, ir_knum(ir)); + } else +#endif + if (emit_canremat(REF_BASE) && ir->o == IR_BASE) { + ra_sethint(ir->r, RID_BASE); /* Restore BASE register hint. */ + emit_getgl(as, r, jit_base); + } else if (emit_canremat(ASMREF_L) && ir->o == IR_KPRI) { + lua_assert(irt_isnil(ir->t)); /* REF_NIL stores ASMREF_L register. */ + emit_getgl(as, r, jit_L); +#if LJ_64 + } else if (ir->o == IR_KINT64) { + emit_loadu64(as, r, ir_kint64(ir)->u64); +#endif + } else { + lua_assert(ir->o == IR_KINT || ir->o == IR_KGC || + ir->o == IR_KPTR || ir->o == IR_KKPTR || ir->o == IR_KNULL); + emit_loadi(as, r, ir->i); + } + return r; +} + +/* Force a spill. Allocate a new spill slot if needed. */ +static int32_t ra_spill(ASMState *as, IRIns *ir) +{ + int32_t slot = ir->s; + lua_assert(ir >= as->ir + REF_TRUE); + if (!ra_hasspill(slot)) { + if (irt_is64(ir->t)) { + slot = as->evenspill; + as->evenspill += 2; + } else if (as->oddspill) { + slot = as->oddspill; + as->oddspill = 0; + } else { + slot = as->evenspill; + as->oddspill = slot+1; + as->evenspill += 2; + } + if (as->evenspill > 256) + lj_trace_err(as->J, LJ_TRERR_SPILLOV); + ir->s = (uint8_t)slot; + } + return sps_scale(slot); +} + +/* Release the temporarily allocated register in ASMREF_TMP1/ASMREF_TMP2. */ +static Reg ra_releasetmp(ASMState *as, IRRef ref) +{ + IRIns *ir = IR(ref); + Reg r = ir->r; + lua_assert(ra_hasreg(r) && !ra_hasspill(ir->s)); + ra_free(as, r); + ra_modified(as, r); + ir->r = RID_INIT; + return r; +} + +/* Restore a register (marked as free). Rematerialize or force a spill. */ +static Reg ra_restore(ASMState *as, IRRef ref) +{ + if (emit_canremat(ref)) { + return ra_rematk(as, ref); + } else { + IRIns *ir = IR(ref); + int32_t ofs = ra_spill(as, ir); /* Force a spill slot. */ + Reg r = ir->r; + lua_assert(ra_hasreg(r)); + ra_sethint(ir->r, r); /* Keep hint. */ + ra_free(as, r); + if (!rset_test(as->weakset, r)) { /* Only restore non-weak references. */ + ra_modified(as, r); + RA_DBGX((as, "restore $i $r", ir, r)); + emit_spload(as, ir, r, ofs); + } + return r; + } +} + +/* Save a register to a spill slot. */ +static void ra_save(ASMState *as, IRIns *ir, Reg r) +{ + RA_DBGX((as, "save $i $r", ir, r)); + emit_spstore(as, ir, r, sps_scale(ir->s)); +} + +#define MINCOST(name) \ + if (rset_test(RSET_ALL, RID_##name) && \ + LJ_LIKELY(allow&RID2RSET(RID_##name)) && as->cost[RID_##name] < cost) \ + cost = as->cost[RID_##name]; + +/* Evict the register with the lowest cost, forcing a restore. */ +static Reg ra_evict(ASMState *as, RegSet allow) +{ + IRRef ref; + RegCost cost = ~(RegCost)0; + lua_assert(allow != RSET_EMPTY); + if (RID_NUM_FPR == 0 || allow < RID2RSET(RID_MAX_GPR)) { + GPRDEF(MINCOST) + } else { + FPRDEF(MINCOST) + } + ref = regcost_ref(cost); + lua_assert(ra_iskref(ref) || (ref >= as->T->nk && ref < as->T->nins)); + /* Preferably pick any weak ref instead of a non-weak, non-const ref. */ + if (!irref_isk(ref) && (as->weakset & allow)) { + IRIns *ir = IR(ref); + if (!rset_test(as->weakset, ir->r)) + ref = regcost_ref(as->cost[rset_pickbot((as->weakset & allow))]); + } + return ra_restore(as, ref); +} + +/* Pick any register (marked as free). Evict on-demand. */ +static Reg ra_pick(ASMState *as, RegSet allow) +{ + RegSet pick = as->freeset & allow; + if (!pick) + return ra_evict(as, allow); + else + return rset_picktop(pick); +} + +/* Get a scratch register (marked as free). */ +static Reg ra_scratch(ASMState *as, RegSet allow) +{ + Reg r = ra_pick(as, allow); + ra_modified(as, r); + RA_DBGX((as, "scratch $r", r)); + return r; +} + +/* Evict all registers from a set (if not free). */ +static void ra_evictset(ASMState *as, RegSet drop) +{ + RegSet work; + as->modset |= drop; +#if !LJ_SOFTFP + work = (drop & ~as->freeset) & RSET_FPR; + while (work) { + Reg r = rset_pickbot(work); + ra_restore(as, regcost_ref(as->cost[r])); + rset_clear(work, r); + checkmclim(as); + } +#endif + work = (drop & ~as->freeset); + while (work) { + Reg r = rset_pickbot(work); + ra_restore(as, regcost_ref(as->cost[r])); + rset_clear(work, r); + checkmclim(as); + } +} + +/* Evict (rematerialize) all registers allocated to constants. */ +static void ra_evictk(ASMState *as) +{ + RegSet work; +#if !LJ_SOFTFP + work = ~as->freeset & RSET_FPR; + while (work) { + Reg r = rset_pickbot(work); + IRRef ref = regcost_ref(as->cost[r]); + if (emit_canremat(ref) && irref_isk(ref)) { + ra_rematk(as, ref); + checkmclim(as); + } + rset_clear(work, r); + } +#endif + work = ~as->freeset & RSET_GPR; + while (work) { + Reg r = rset_pickbot(work); + IRRef ref = regcost_ref(as->cost[r]); + if (emit_canremat(ref) && irref_isk(ref)) { + ra_rematk(as, ref); + checkmclim(as); + } + rset_clear(work, r); + } +} + +#ifdef RID_NUM_KREF +/* Allocate a register for a constant. */ +static Reg ra_allock(ASMState *as, int32_t k, RegSet allow) +{ + /* First try to find a register which already holds the same constant. */ + RegSet pick, work = ~as->freeset & RSET_GPR; + Reg r; + while (work) { + IRRef ref; + r = rset_pickbot(work); + ref = regcost_ref(as->cost[r]); + if (ref < ASMREF_L && + k == (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i)) + return r; + rset_clear(work, r); + } + pick = as->freeset & allow; + if (pick) { + /* Constants should preferably get unmodified registers. */ + if ((pick & ~as->modset)) + pick &= ~as->modset; + r = rset_pickbot(pick); /* Reduce conflicts with inverse allocation. */ + } else { + r = ra_evict(as, allow); + } + RA_DBGX((as, "allock $x $r", k, r)); + ra_setkref(as, r, k); + rset_clear(as->freeset, r); + ra_noweak(as, r); + return r; +} + +/* Allocate a specific register for a constant. */ +static void ra_allockreg(ASMState *as, int32_t k, Reg r) +{ + Reg kr = ra_allock(as, k, RID2RSET(r)); + if (kr != r) { + IRIns irdummy; + irdummy.t.irt = IRT_INT; + ra_scratch(as, RID2RSET(r)); + emit_movrr(as, &irdummy, r, kr); + } +} +#else +#define ra_allockreg(as, k, r) emit_loadi(as, (r), (k)) +#endif + +/* Allocate a register for ref from the allowed set of registers. +** Note: this function assumes the ref does NOT have a register yet! +** Picks an optimal register, sets the cost and marks the register as non-free. +*/ +static Reg ra_allocref(ASMState *as, IRRef ref, RegSet allow) +{ + IRIns *ir = IR(ref); + RegSet pick = as->freeset & allow; + Reg r; + lua_assert(ra_noreg(ir->r)); + if (pick) { + /* First check register hint from propagation or PHI. */ + if (ra_hashint(ir->r)) { + r = ra_gethint(ir->r); + if (rset_test(pick, r)) /* Use hint register if possible. */ + goto found; + /* Rematerialization is cheaper than missing a hint. */ + if (rset_test(allow, r) && emit_canremat(regcost_ref(as->cost[r]))) { + ra_rematk(as, regcost_ref(as->cost[r])); + goto found; + } + RA_DBGX((as, "hintmiss $f $r", ref, r)); + } + /* Invariants should preferably get unmodified registers. */ + if (ref < as->loopref && !irt_isphi(ir->t)) { + if ((pick & ~as->modset)) + pick &= ~as->modset; + r = rset_pickbot(pick); /* Reduce conflicts with inverse allocation. */ + } else { + /* We've got plenty of regs, so get callee-save regs if possible. */ + if (RID_NUM_GPR > 8 && (pick & ~RSET_SCRATCH)) + pick &= ~RSET_SCRATCH; + r = rset_picktop(pick); + } + } else { + r = ra_evict(as, allow); + } +found: + RA_DBGX((as, "alloc $f $r", ref, r)); + ir->r = (uint8_t)r; + rset_clear(as->freeset, r); + ra_noweak(as, r); + as->cost[r] = REGCOST_REF_T(ref, irt_t(ir->t)); + return r; +} + +/* Allocate a register on-demand. */ +static Reg ra_alloc1(ASMState *as, IRRef ref, RegSet allow) +{ + Reg r = IR(ref)->r; + /* Note: allow is ignored if the register is already allocated. */ + if (ra_noreg(r)) r = ra_allocref(as, ref, allow); + ra_noweak(as, r); + return r; +} + +/* Rename register allocation and emit move. */ +static void ra_rename(ASMState *as, Reg down, Reg up) +{ + IRRef ren, ref = regcost_ref(as->cost[up] = as->cost[down]); + IRIns *ir = IR(ref); + ir->r = (uint8_t)up; + as->cost[down] = 0; + lua_assert((down < RID_MAX_GPR) == (up < RID_MAX_GPR)); + lua_assert(!rset_test(as->freeset, down) && rset_test(as->freeset, up)); + ra_free(as, down); /* 'down' is free ... */ + ra_modified(as, down); + rset_clear(as->freeset, up); /* ... and 'up' is now allocated. */ + ra_noweak(as, up); + RA_DBGX((as, "rename $f $r $r", regcost_ref(as->cost[up]), down, up)); + emit_movrr(as, ir, down, up); /* Backwards codegen needs inverse move. */ + if (!ra_hasspill(IR(ref)->s)) { /* Add the rename to the IR. */ + lj_ir_set(as->J, IRT(IR_RENAME, IRT_NIL), ref, as->snapno); + ren = tref_ref(lj_ir_emit(as->J)); + as->ir = as->T->ir; /* The IR may have been reallocated. */ + IR(ren)->r = (uint8_t)down; + IR(ren)->s = SPS_NONE; + } +} + +/* Pick a destination register (marked as free). +** Caveat: allow is ignored if there's already a destination register. +** Use ra_destreg() to get a specific register. +*/ +static Reg ra_dest(ASMState *as, IRIns *ir, RegSet allow) +{ + Reg dest = ir->r; + if (ra_hasreg(dest)) { + ra_free(as, dest); + ra_modified(as, dest); + } else { + if (ra_hashint(dest) && rset_test((as->freeset&allow), ra_gethint(dest))) { + dest = ra_gethint(dest); + ra_modified(as, dest); + RA_DBGX((as, "dest $r", dest)); + } else { + dest = ra_scratch(as, allow); + } + ir->r = dest; + } + if (LJ_UNLIKELY(ra_hasspill(ir->s))) ra_save(as, ir, dest); + return dest; +} + +/* Force a specific destination register (marked as free). */ +static void ra_destreg(ASMState *as, IRIns *ir, Reg r) +{ + Reg dest = ra_dest(as, ir, RID2RSET(r)); + if (dest != r) { + lua_assert(rset_test(as->freeset, r)); + ra_modified(as, r); + emit_movrr(as, ir, dest, r); + } +} + +#if LJ_TARGET_X86ORX64 +/* Propagate dest register to left reference. Emit moves as needed. +** This is a required fixup step for all 2-operand machine instructions. +*/ +static void ra_left(ASMState *as, Reg dest, IRRef lref) +{ + IRIns *ir = IR(lref); + Reg left = ir->r; + if (ra_noreg(left)) { + if (irref_isk(lref)) { + if (ir->o == IR_KNUM) { + cTValue *tv = ir_knum(ir); + /* FP remat needs a load except for +0. Still better than eviction. */ + if (tvispzero(tv) || !(as->freeset & RSET_FPR)) { + emit_loadn(as, dest, tv); + return; + } +#if LJ_64 + } else if (ir->o == IR_KINT64) { + emit_loadu64(as, dest, ir_kint64(ir)->u64); + return; +#endif + } else { + lua_assert(ir->o == IR_KINT || ir->o == IR_KGC || + ir->o == IR_KPTR || ir->o == IR_KKPTR || ir->o == IR_KNULL); + emit_loadi(as, dest, ir->i); + return; + } + } + if (!ra_hashint(left) && !iscrossref(as, lref)) + ra_sethint(ir->r, dest); /* Propagate register hint. */ + left = ra_allocref(as, lref, dest < RID_MAX_GPR ? RSET_GPR : RSET_FPR); + } + ra_noweak(as, left); + /* Move needed for true 3-operand instruction: y=a+b ==> y=a; y+=b. */ + if (dest != left) { + /* Use register renaming if dest is the PHI reg. */ + if (irt_isphi(ir->t) && as->phireg[dest] == lref) { + ra_modified(as, left); + ra_rename(as, left, dest); + } else { + emit_movrr(as, ir, dest, left); + } + } +} +#else +/* Similar to ra_left, except we override any hints. */ +static void ra_leftov(ASMState *as, Reg dest, IRRef lref) +{ + IRIns *ir = IR(lref); + Reg left = ir->r; + if (ra_noreg(left)) { + ra_sethint(ir->r, dest); /* Propagate register hint. */ + left = ra_allocref(as, lref, + (LJ_SOFTFP || dest < RID_MAX_GPR) ? RSET_GPR : RSET_FPR); + } + ra_noweak(as, left); + if (dest != left) { + /* Use register renaming if dest is the PHI reg. */ + if (irt_isphi(ir->t) && as->phireg[dest] == lref) { + ra_modified(as, left); + ra_rename(as, left, dest); + } else { + emit_movrr(as, ir, dest, left); + } + } +} +#endif + +#if !LJ_64 +/* Force a RID_RETLO/RID_RETHI destination register pair (marked as free). */ +static void ra_destpair(ASMState *as, IRIns *ir) +{ + Reg destlo = ir->r, desthi = (ir+1)->r; + /* First spill unrelated refs blocking the destination registers. */ + if (!rset_test(as->freeset, RID_RETLO) && + destlo != RID_RETLO && desthi != RID_RETLO) + ra_restore(as, regcost_ref(as->cost[RID_RETLO])); + if (!rset_test(as->freeset, RID_RETHI) && + destlo != RID_RETHI && desthi != RID_RETHI) + ra_restore(as, regcost_ref(as->cost[RID_RETHI])); + /* Next free the destination registers (if any). */ + if (ra_hasreg(destlo)) { + ra_free(as, destlo); + ra_modified(as, destlo); + } else { + destlo = RID_RETLO; + } + if (ra_hasreg(desthi)) { + ra_free(as, desthi); + ra_modified(as, desthi); + } else { + desthi = RID_RETHI; + } + /* Check for conflicts and shuffle the registers as needed. */ + if (destlo == RID_RETHI) { + if (desthi == RID_RETLO) { +#if LJ_TARGET_X86 + *--as->mcp = XI_XCHGa + RID_RETHI; +#else + emit_movrr(as, ir, RID_RETHI, RID_TMP); + emit_movrr(as, ir, RID_RETLO, RID_RETHI); + emit_movrr(as, ir, RID_TMP, RID_RETLO); +#endif + } else { + emit_movrr(as, ir, RID_RETHI, RID_RETLO); + if (desthi != RID_RETHI) emit_movrr(as, ir, desthi, RID_RETHI); + } + } else if (desthi == RID_RETLO) { + emit_movrr(as, ir, RID_RETLO, RID_RETHI); + if (destlo != RID_RETLO) emit_movrr(as, ir, destlo, RID_RETLO); + } else { + if (desthi != RID_RETHI) emit_movrr(as, ir, desthi, RID_RETHI); + if (destlo != RID_RETLO) emit_movrr(as, ir, destlo, RID_RETLO); + } + /* Restore spill slots (if any). */ + if (ra_hasspill((ir+1)->s)) ra_save(as, ir+1, RID_RETHI); + if (ra_hasspill(ir->s)) ra_save(as, ir, RID_RETLO); +} +#endif + +/* -- Snapshot handling --------- ----------------------------------------- */ + +/* Can we rematerialize a KNUM instead of forcing a spill? */ +static int asm_snap_canremat(ASMState *as) +{ + Reg r; + for (r = RID_MIN_FPR; r < RID_MAX_FPR; r++) + if (irref_isk(regcost_ref(as->cost[r]))) + return 1; + return 0; +} + +/* Check whether a sunk store corresponds to an allocation. */ +static int asm_sunk_store(ASMState *as, IRIns *ira, IRIns *irs) +{ + if (irs->s == 255) { + if (irs->o == IR_ASTORE || irs->o == IR_HSTORE || + irs->o == IR_FSTORE || irs->o == IR_XSTORE) { + IRIns *irk = IR(irs->op1); + if (irk->o == IR_AREF || irk->o == IR_HREFK) + irk = IR(irk->op1); + return (IR(irk->op1) == ira); + } + return 0; + } else { + return (ira + irs->s == irs); /* Quick check. */ + } +} + +/* Allocate register or spill slot for a ref that escapes to a snapshot. */ +static void asm_snap_alloc1(ASMState *as, IRRef ref) +{ + IRIns *ir = IR(ref); + if (!irref_isk(ref) && (!(ra_used(ir) || ir->r == RID_SUNK))) { + if (ir->r == RID_SINK) { + ir->r = RID_SUNK; +#if LJ_HASFFI + if (ir->o == IR_CNEWI) { /* Allocate CNEWI value. */ + asm_snap_alloc1(as, ir->op2); + if (LJ_32 && (ir+1)->o == IR_HIOP) + asm_snap_alloc1(as, (ir+1)->op2); + } else +#endif + { /* Allocate stored values for TNEW, TDUP and CNEW. */ + IRIns *irs; + lua_assert(ir->o == IR_TNEW || ir->o == IR_TDUP || ir->o == IR_CNEW); + for (irs = IR(as->snapref-1); irs > ir; irs--) + if (irs->r == RID_SINK && asm_sunk_store(as, ir, irs)) { + lua_assert(irs->o == IR_ASTORE || irs->o == IR_HSTORE || + irs->o == IR_FSTORE || irs->o == IR_XSTORE); + asm_snap_alloc1(as, irs->op2); + if (LJ_32 && (irs+1)->o == IR_HIOP) + asm_snap_alloc1(as, (irs+1)->op2); + } + } + } else { + RegSet allow; + if (ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT) { + IRIns *irc; + for (irc = IR(as->curins); irc > ir; irc--) + if ((irc->op1 == ref || irc->op2 == ref) && + !(irc->r == RID_SINK || irc->r == RID_SUNK)) + goto nosink; /* Don't sink conversion if result is used. */ + asm_snap_alloc1(as, ir->op1); + return; + } + nosink: + allow = (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR; + if ((as->freeset & allow) || + (allow == RSET_FPR && asm_snap_canremat(as))) { + /* Get a weak register if we have a free one or can rematerialize. */ + Reg r = ra_allocref(as, ref, allow); /* Allocate a register. */ + if (!irt_isphi(ir->t)) + ra_weak(as, r); /* But mark it as weakly referenced. */ + checkmclim(as); + RA_DBGX((as, "snapreg $f $r", ref, ir->r)); + } else { + ra_spill(as, ir); /* Otherwise force a spill slot. */ + RA_DBGX((as, "snapspill $f $s", ref, ir->s)); + } + } + } +} + +/* Allocate refs escaping to a snapshot. */ +static void asm_snap_alloc(ASMState *as) +{ + SnapShot *snap = &as->T->snap[as->snapno]; + SnapEntry *map = &as->T->snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + IRRef ref = snap_ref(sn); + if (!irref_isk(ref)) { + asm_snap_alloc1(as, ref); + if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM)) { + lua_assert(irt_type(IR(ref+1)->t) == IRT_SOFTFP); + asm_snap_alloc1(as, ref+1); + } + } + } +} + +/* All guards for a snapshot use the same exitno. This is currently the +** same as the snapshot number. Since the exact origin of the exit cannot +** be determined, all guards for the same snapshot must exit with the same +** RegSP mapping. +** A renamed ref which has been used in a prior guard for the same snapshot +** would cause an inconsistency. The easy way out is to force a spill slot. +*/ +static int asm_snap_checkrename(ASMState *as, IRRef ren) +{ + SnapShot *snap = &as->T->snap[as->snapno]; + SnapEntry *map = &as->T->snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + IRRef ref = snap_ref(sn); + if (ref == ren || (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM) && ++ref == ren)) { + IRIns *ir = IR(ref); + ra_spill(as, ir); /* Register renamed, so force a spill slot. */ + RA_DBGX((as, "snaprensp $f $s", ref, ir->s)); + return 1; /* Found. */ + } + } + return 0; /* Not found. */ +} + +/* Prepare snapshot for next guard instruction. */ +static void asm_snap_prep(ASMState *as) +{ + if (as->curins < as->snapref) { + do { + if (as->snapno == 0) return; /* Called by sunk stores before snap #0. */ + as->snapno--; + as->snapref = as->T->snap[as->snapno].ref; + } while (as->curins < as->snapref); + asm_snap_alloc(as); + as->snaprename = as->T->nins; + } else { + /* Process any renames above the highwater mark. */ + for (; as->snaprename < as->T->nins; as->snaprename++) { + IRIns *ir = IR(as->snaprename); + if (asm_snap_checkrename(as, ir->op1)) + ir->op2 = REF_BIAS-1; /* Kill rename. */ + } + } +} + +/* -- Miscellaneous helpers ----------------------------------------------- */ + +/* Collect arguments from CALL* and CARG instructions. */ +static void asm_collectargs(ASMState *as, IRIns *ir, + const CCallInfo *ci, IRRef *args) +{ + uint32_t n = CCI_NARGS(ci); + lua_assert(n <= CCI_NARGS_MAX*2); /* Account for split args. */ + if ((ci->flags & CCI_L)) { *args++ = ASMREF_L; n--; } + while (n-- > 1) { + ir = IR(ir->op1); + lua_assert(ir->o == IR_CARG); + args[n] = ir->op2 == REF_NIL ? 0 : ir->op2; + } + args[0] = ir->op1 == REF_NIL ? 0 : ir->op1; + lua_assert(IR(ir->op1)->o != IR_CARG); +} + +/* Reconstruct CCallInfo flags for CALLX*. */ +static uint32_t asm_callx_flags(ASMState *as, IRIns *ir) +{ + uint32_t nargs = 0; + if (ir->op1 != REF_NIL) { /* Count number of arguments first. */ + IRIns *ira = IR(ir->op1); + nargs++; + while (ira->o == IR_CARG) { nargs++; ira = IR(ira->op1); } + } +#if LJ_HASFFI + if (IR(ir->op2)->o == IR_CARG) { /* Copy calling convention info. */ + CTypeID id = (CTypeID)IR(IR(ir->op2)->op2)->i; + CType *ct = ctype_get(ctype_ctsG(J2G(as->J)), id); + nargs |= ((ct->info & CTF_VARARG) ? CCI_VARARG : 0); +#if LJ_TARGET_X86 + nargs |= (ctype_cconv(ct->info) << CCI_CC_SHIFT); +#endif + } +#endif + return (nargs | (ir->t.irt << CCI_OTSHIFT)); +} + +/* Calculate stack adjustment. */ +static int32_t asm_stack_adjust(ASMState *as) +{ + if (as->evenspill <= SPS_FIXED) + return 0; + return sps_scale(sps_align(as->evenspill)); +} + +/* Must match with hash*() in lj_tab.c. */ +static uint32_t ir_khash(IRIns *ir) +{ + uint32_t lo, hi; + if (irt_isstr(ir->t)) { + return ir_kstr(ir)->hash; + } else if (irt_isnum(ir->t)) { + lo = ir_knum(ir)->u32.lo; + hi = ir_knum(ir)->u32.hi << 1; + } else if (irt_ispri(ir->t)) { + lua_assert(!irt_isnil(ir->t)); + return irt_type(ir->t)-IRT_FALSE; + } else { + lua_assert(irt_isgcv(ir->t)); + lo = u32ptr(ir_kgc(ir)); + hi = lo + HASH_BIAS; + } + return hashrot(lo, hi); +} + +/* -- Allocations --------------------------------------------------------- */ + +static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args); +static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci); + +static void asm_snew(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_new]; + IRRef args[3]; + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ir->op1; /* const char *str */ + args[2] = ir->op2; /* size_t len */ + as->gcsteps++; + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); +} + +static void asm_tnew(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_new1]; + IRRef args[2]; + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ASMREF_TMP1; /* uint32_t ahsize */ + as->gcsteps++; + asm_setupresult(as, ir, ci); /* GCtab * */ + asm_gencall(as, ci, args); + ra_allockreg(as, ir->op1 | (ir->op2 << 24), ra_releasetmp(as, ASMREF_TMP1)); +} + +static void asm_tdup(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_dup]; + IRRef args[2]; + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ir->op1; /* const GCtab *kt */ + as->gcsteps++; + asm_setupresult(as, ir, ci); /* GCtab * */ + asm_gencall(as, ci, args); +} + +static void asm_gc_check(ASMState *as); + +/* Explicit GC step. */ +static void asm_gcstep(ASMState *as, IRIns *ir) +{ + IRIns *ira; + for (ira = IR(as->stopins+1); ira < ir; ira++) + if ((ira->o == IR_TNEW || ira->o == IR_TDUP || + (LJ_HASFFI && (ira->o == IR_CNEW || ira->o == IR_CNEWI))) && + ra_used(ira)) + as->gcsteps++; + if (as->gcsteps) + asm_gc_check(as); + as->gcsteps = 0x80000000; /* Prevent implicit GC check further up. */ +} + +/* -- PHI and loop handling ----------------------------------------------- */ + +/* Break a PHI cycle by renaming to a free register (evict if needed). */ +static void asm_phi_break(ASMState *as, RegSet blocked, RegSet blockedby, + RegSet allow) +{ + RegSet candidates = blocked & allow; + if (candidates) { /* If this register file has candidates. */ + /* Note: the set for ra_pick cannot be empty, since each register file + ** has some registers never allocated to PHIs. + */ + Reg down, up = ra_pick(as, ~blocked & allow); /* Get a free register. */ + if (candidates & ~blockedby) /* Optimize shifts, else it's a cycle. */ + candidates = candidates & ~blockedby; + down = rset_picktop(candidates); /* Pick candidate PHI register. */ + ra_rename(as, down, up); /* And rename it to the free register. */ + } +} + +/* PHI register shuffling. +** +** The allocator tries hard to preserve PHI register assignments across +** the loop body. Most of the time this loop does nothing, since there +** are no register mismatches. +** +** If a register mismatch is detected and ... +** - the register is currently free: rename it. +** - the register is blocked by an invariant: restore/remat and rename it. +** - Otherwise the register is used by another PHI, so mark it as blocked. +** +** The renames are order-sensitive, so just retry the loop if a register +** is marked as blocked, but has been freed in the meantime. A cycle is +** detected if all of the blocked registers are allocated. To break the +** cycle rename one of them to a free register and retry. +** +** Note that PHI spill slots are kept in sync and don't need to be shuffled. +*/ +static void asm_phi_shuffle(ASMState *as) +{ + RegSet work; + + /* Find and resolve PHI register mismatches. */ + for (;;) { + RegSet blocked = RSET_EMPTY; + RegSet blockedby = RSET_EMPTY; + RegSet phiset = as->phiset; + while (phiset) { /* Check all left PHI operand registers. */ + Reg r = rset_pickbot(phiset); + IRIns *irl = IR(as->phireg[r]); + Reg left = irl->r; + if (r != left) { /* Mismatch? */ + if (!rset_test(as->freeset, r)) { /* PHI register blocked? */ + IRRef ref = regcost_ref(as->cost[r]); + /* Blocked by other PHI (w/reg)? */ + if (!ra_iskref(ref) && irt_ismarked(IR(ref)->t)) { + rset_set(blocked, r); + if (ra_hasreg(left)) + rset_set(blockedby, left); + left = RID_NONE; + } else { /* Otherwise grab register from invariant. */ + ra_restore(as, ref); + checkmclim(as); + } + } + if (ra_hasreg(left)) { + ra_rename(as, left, r); + checkmclim(as); + } + } + rset_clear(phiset, r); + } + if (!blocked) break; /* Finished. */ + if (!(as->freeset & blocked)) { /* Break cycles if none are free. */ + asm_phi_break(as, blocked, blockedby, RSET_GPR); + if (!LJ_SOFTFP) asm_phi_break(as, blocked, blockedby, RSET_FPR); + checkmclim(as); + } /* Else retry some more renames. */ + } + + /* Restore/remat invariants whose registers are modified inside the loop. */ +#if !LJ_SOFTFP + work = as->modset & ~(as->freeset | as->phiset) & RSET_FPR; + while (work) { + Reg r = rset_pickbot(work); + ra_restore(as, regcost_ref(as->cost[r])); + rset_clear(work, r); + checkmclim(as); + } +#endif + work = as->modset & ~(as->freeset | as->phiset); + while (work) { + Reg r = rset_pickbot(work); + ra_restore(as, regcost_ref(as->cost[r])); + rset_clear(work, r); + checkmclim(as); + } + + /* Allocate and save all unsaved PHI regs and clear marks. */ + work = as->phiset; + while (work) { + Reg r = rset_picktop(work); + IRRef lref = as->phireg[r]; + IRIns *ir = IR(lref); + if (ra_hasspill(ir->s)) { /* Left PHI gained a spill slot? */ + irt_clearmark(ir->t); /* Handled here, so clear marker now. */ + ra_alloc1(as, lref, RID2RSET(r)); + ra_save(as, ir, r); /* Save to spill slot inside the loop. */ + checkmclim(as); + } + rset_clear(work, r); + } +} + +/* Copy unsynced left/right PHI spill slots. Rarely needed. */ +static void asm_phi_copyspill(ASMState *as) +{ + int need = 0; + IRIns *ir; + for (ir = IR(as->orignins-1); ir->o == IR_PHI; ir--) + if (ra_hasspill(ir->s) && ra_hasspill(IR(ir->op1)->s)) + need |= irt_isfp(ir->t) ? 2 : 1; /* Unsynced spill slot? */ + if ((need & 1)) { /* Copy integer spill slots. */ +#if !LJ_TARGET_X86ORX64 + Reg r = RID_TMP; +#else + Reg r = RID_RET; + if ((as->freeset & RSET_GPR)) + r = rset_pickbot((as->freeset & RSET_GPR)); + else + emit_spload(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); +#endif + for (ir = IR(as->orignins-1); ir->o == IR_PHI; ir--) { + if (ra_hasspill(ir->s)) { + IRIns *irl = IR(ir->op1); + if (ra_hasspill(irl->s) && !irt_isfp(ir->t)) { + emit_spstore(as, irl, r, sps_scale(irl->s)); + emit_spload(as, ir, r, sps_scale(ir->s)); + checkmclim(as); + } + } + } +#if LJ_TARGET_X86ORX64 + if (!rset_test(as->freeset, r)) + emit_spstore(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); +#endif + } +#if !LJ_SOFTFP + if ((need & 2)) { /* Copy FP spill slots. */ +#if LJ_TARGET_X86 + Reg r = RID_XMM0; +#else + Reg r = RID_FPRET; +#endif + if ((as->freeset & RSET_FPR)) + r = rset_pickbot((as->freeset & RSET_FPR)); + if (!rset_test(as->freeset, r)) + emit_spload(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); + for (ir = IR(as->orignins-1); ir->o == IR_PHI; ir--) { + if (ra_hasspill(ir->s)) { + IRIns *irl = IR(ir->op1); + if (ra_hasspill(irl->s) && irt_isfp(ir->t)) { + emit_spstore(as, irl, r, sps_scale(irl->s)); + emit_spload(as, ir, r, sps_scale(ir->s)); + checkmclim(as); + } + } + } + if (!rset_test(as->freeset, r)) + emit_spstore(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); + } +#endif +} + +/* Emit renames for left PHIs which are only spilled outside the loop. */ +static void asm_phi_fixup(ASMState *as) +{ + RegSet work = as->phiset; + while (work) { + Reg r = rset_picktop(work); + IRRef lref = as->phireg[r]; + IRIns *ir = IR(lref); + if (irt_ismarked(ir->t)) { + irt_clearmark(ir->t); + /* Left PHI gained a spill slot before the loop? */ + if (ra_hasspill(ir->s)) { + IRRef ren; + lj_ir_set(as->J, IRT(IR_RENAME, IRT_NIL), lref, as->loopsnapno); + ren = tref_ref(lj_ir_emit(as->J)); + as->ir = as->T->ir; /* The IR may have been reallocated. */ + IR(ren)->r = (uint8_t)r; + IR(ren)->s = SPS_NONE; + } + } + rset_clear(work, r); + } +} + +/* Setup right PHI reference. */ +static void asm_phi(ASMState *as, IRIns *ir) +{ + RegSet allow = ((!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR) & + ~as->phiset; + RegSet afree = (as->freeset & allow); + IRIns *irl = IR(ir->op1); + IRIns *irr = IR(ir->op2); + if (ir->r == RID_SINK) /* Sink PHI. */ + return; + /* Spill slot shuffling is not implemented yet (but rarely needed). */ + if (ra_hasspill(irl->s) || ra_hasspill(irr->s)) + lj_trace_err(as->J, LJ_TRERR_NYIPHI); + /* Leave at least one register free for non-PHIs (and PHI cycle breaking). */ + if ((afree & (afree-1))) { /* Two or more free registers? */ + Reg r; + if (ra_noreg(irr->r)) { /* Get a register for the right PHI. */ + r = ra_allocref(as, ir->op2, allow); + } else { /* Duplicate right PHI, need a copy (rare). */ + r = ra_scratch(as, allow); + emit_movrr(as, irr, r, irr->r); + } + ir->r = (uint8_t)r; + rset_set(as->phiset, r); + as->phireg[r] = (IRRef1)ir->op1; + irt_setmark(irl->t); /* Marks left PHIs _with_ register. */ + if (ra_noreg(irl->r)) + ra_sethint(irl->r, r); /* Set register hint for left PHI. */ + } else { /* Otherwise allocate a spill slot. */ + /* This is overly restrictive, but it triggers only on synthetic code. */ + if (ra_hasreg(irl->r) || ra_hasreg(irr->r)) + lj_trace_err(as->J, LJ_TRERR_NYIPHI); + ra_spill(as, ir); + irr->s = ir->s; /* Set right PHI spill slot. Sync left slot later. */ + } +} + +static void asm_loop_fixup(ASMState *as); + +/* Middle part of a loop. */ +static void asm_loop(ASMState *as) +{ + MCode *mcspill; + /* LOOP is a guard, so the snapno is up to date. */ + as->loopsnapno = as->snapno; + if (as->gcsteps) + asm_gc_check(as); + /* LOOP marks the transition from the variant to the invariant part. */ + as->flagmcp = as->invmcp = NULL; + as->sectref = 0; + if (!neverfuse(as)) as->fuseref = 0; + asm_phi_shuffle(as); + mcspill = as->mcp; + asm_phi_copyspill(as); + asm_loop_fixup(as); + as->mcloop = as->mcp; + RA_DBGX((as, "===== LOOP =====")); + if (!as->realign) RA_DBG_FLUSH(); + if (as->mcp != mcspill) + emit_jmp(as, mcspill); +} + +/* -- Target-specific assembler ------------------------------------------- */ + +#if LJ_TARGET_X86ORX64 +#include "lj_asm_x86.h" +#elif LJ_TARGET_ARM +#include "lj_asm_arm.h" +#elif LJ_TARGET_PPC +#include "lj_asm_ppc.h" +#elif LJ_TARGET_MIPS +#include "lj_asm_mips.h" +#else +#error "Missing assembler for target CPU" +#endif + +/* -- Head of trace ------------------------------------------------------- */ + +/* Head of a root trace. */ +static void asm_head_root(ASMState *as) +{ + int32_t spadj; + asm_head_root_base(as); + emit_setvmstate(as, (int32_t)as->T->traceno); + spadj = asm_stack_adjust(as); + as->T->spadjust = (uint16_t)spadj; + emit_spsub(as, spadj); + /* Root traces assume a checked stack for the starting proto. */ + as->T->topslot = gcref(as->T->startpt)->pt.framesize; +} + +/* Head of a side trace. +** +** The current simplistic algorithm requires that all slots inherited +** from the parent are live in a register between pass 2 and pass 3. This +** avoids the complexity of stack slot shuffling. But of course this may +** overflow the register set in some cases and cause the dreaded error: +** "NYI: register coalescing too complex". A refined algorithm is needed. +*/ +static void asm_head_side(ASMState *as) +{ + IRRef1 sloadins[RID_MAX]; + RegSet allow = RSET_ALL; /* Inverse of all coalesced registers. */ + RegSet live = RSET_EMPTY; /* Live parent registers. */ + IRIns *irp = &as->parent->ir[REF_BASE]; /* Parent base. */ + int32_t spadj, spdelta; + int pass2 = 0; + int pass3 = 0; + IRRef i; + + if (as->snapno && as->topslot > as->parent->topslot) { + /* Force snap #0 alloc to prevent register overwrite in stack check. */ + as->snapno = 0; + asm_snap_alloc(as); + } + allow = asm_head_side_base(as, irp, allow); + + /* Scan all parent SLOADs and collect register dependencies. */ + for (i = as->stopins; i > REF_BASE; i--) { + IRIns *ir = IR(i); + RegSP rs; + lua_assert((ir->o == IR_SLOAD && (ir->op2 & IRSLOAD_PARENT)) || + (LJ_SOFTFP && ir->o == IR_HIOP) || ir->o == IR_PVAL); + rs = as->parentmap[i - REF_FIRST]; + if (ra_hasreg(ir->r)) { + rset_clear(allow, ir->r); + if (ra_hasspill(ir->s)) { + ra_save(as, ir, ir->r); + checkmclim(as); + } + } else if (ra_hasspill(ir->s)) { + irt_setmark(ir->t); + pass2 = 1; + } + if (ir->r == rs) { /* Coalesce matching registers right now. */ + ra_free(as, ir->r); + } else if (ra_hasspill(regsp_spill(rs))) { + if (ra_hasreg(ir->r)) + pass3 = 1; + } else if (ra_used(ir)) { + sloadins[rs] = (IRRef1)i; + rset_set(live, rs); /* Block live parent register. */ + } + } + + /* Calculate stack frame adjustment. */ + spadj = asm_stack_adjust(as); + spdelta = spadj - (int32_t)as->parent->spadjust; + if (spdelta < 0) { /* Don't shrink the stack frame. */ + spadj = (int32_t)as->parent->spadjust; + spdelta = 0; + } + as->T->spadjust = (uint16_t)spadj; + + /* Reload spilled target registers. */ + if (pass2) { + for (i = as->stopins; i > REF_BASE; i--) { + IRIns *ir = IR(i); + if (irt_ismarked(ir->t)) { + RegSet mask; + Reg r; + RegSP rs; + irt_clearmark(ir->t); + rs = as->parentmap[i - REF_FIRST]; + if (!ra_hasspill(regsp_spill(rs))) + ra_sethint(ir->r, rs); /* Hint may be gone, set it again. */ + else if (sps_scale(regsp_spill(rs))+spdelta == sps_scale(ir->s)) + continue; /* Same spill slot, do nothing. */ + mask = ((!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR) & allow; + if (mask == RSET_EMPTY) + lj_trace_err(as->J, LJ_TRERR_NYICOAL); + r = ra_allocref(as, i, mask); + ra_save(as, ir, r); + rset_clear(allow, r); + if (r == rs) { /* Coalesce matching registers right now. */ + ra_free(as, r); + rset_clear(live, r); + } else if (ra_hasspill(regsp_spill(rs))) { + pass3 = 1; + } + checkmclim(as); + } + } + } + + /* Store trace number and adjust stack frame relative to the parent. */ + emit_setvmstate(as, (int32_t)as->T->traceno); + emit_spsub(as, spdelta); + +#if !LJ_TARGET_X86ORX64 + /* Restore BASE register from parent spill slot. */ + if (ra_hasspill(irp->s)) + emit_spload(as, IR(REF_BASE), IR(REF_BASE)->r, sps_scale(irp->s)); +#endif + + /* Restore target registers from parent spill slots. */ + if (pass3) { + RegSet work = ~as->freeset & RSET_ALL; + while (work) { + Reg r = rset_pickbot(work); + IRRef ref = regcost_ref(as->cost[r]); + RegSP rs = as->parentmap[ref - REF_FIRST]; + rset_clear(work, r); + if (ra_hasspill(regsp_spill(rs))) { + int32_t ofs = sps_scale(regsp_spill(rs)); + ra_free(as, r); + emit_spload(as, IR(ref), r, ofs); + checkmclim(as); + } + } + } + + /* Shuffle registers to match up target regs with parent regs. */ + for (;;) { + RegSet work; + + /* Repeatedly coalesce free live registers by moving to their target. */ + while ((work = as->freeset & live) != RSET_EMPTY) { + Reg rp = rset_pickbot(work); + IRIns *ir = IR(sloadins[rp]); + rset_clear(live, rp); + rset_clear(allow, rp); + ra_free(as, ir->r); + emit_movrr(as, ir, ir->r, rp); + checkmclim(as); + } + + /* We're done if no live registers remain. */ + if (live == RSET_EMPTY) + break; + + /* Break cycles by renaming one target to a temp. register. */ + if (live & RSET_GPR) { + RegSet tmpset = as->freeset & ~live & allow & RSET_GPR; + if (tmpset == RSET_EMPTY) + lj_trace_err(as->J, LJ_TRERR_NYICOAL); + ra_rename(as, rset_pickbot(live & RSET_GPR), rset_pickbot(tmpset)); + } + if (!LJ_SOFTFP && (live & RSET_FPR)) { + RegSet tmpset = as->freeset & ~live & allow & RSET_FPR; + if (tmpset == RSET_EMPTY) + lj_trace_err(as->J, LJ_TRERR_NYICOAL); + ra_rename(as, rset_pickbot(live & RSET_FPR), rset_pickbot(tmpset)); + } + checkmclim(as); + /* Continue with coalescing to fix up the broken cycle(s). */ + } + + /* Inherit top stack slot already checked by parent trace. */ + as->T->topslot = as->parent->topslot; + if (as->topslot > as->T->topslot) { /* Need to check for higher slot? */ +#ifdef EXITSTATE_CHECKEXIT + /* Highest exit + 1 indicates stack check. */ + ExitNo exitno = as->T->nsnap; +#else + /* Reuse the parent exit in the context of the parent trace. */ + ExitNo exitno = as->J->exitno; +#endif + as->T->topslot = (uint8_t)as->topslot; /* Remember for child traces. */ + asm_stack_check(as, as->topslot, irp, allow & RSET_GPR, exitno); + } +} + +/* -- Tail of trace ------------------------------------------------------- */ + +/* Get base slot for a snapshot. */ +static BCReg asm_baseslot(ASMState *as, SnapShot *snap, int *gotframe) +{ + SnapEntry *map = &as->T->snapmap[snap->mapofs]; + MSize n; + for (n = snap->nent; n > 0; n--) { + SnapEntry sn = map[n-1]; + if ((sn & SNAP_FRAME)) { + *gotframe = 1; + return snap_slot(sn); + } + } + return 0; +} + +/* Link to another trace. */ +static void asm_tail_link(ASMState *as) +{ + SnapNo snapno = as->T->nsnap-1; /* Last snapshot. */ + SnapShot *snap = &as->T->snap[snapno]; + int gotframe = 0; + BCReg baseslot = asm_baseslot(as, snap, &gotframe); + + as->topslot = snap->topslot; + checkmclim(as); + ra_allocref(as, REF_BASE, RID2RSET(RID_BASE)); + + if (as->T->link == 0) { + /* Setup fixed registers for exit to interpreter. */ + const BCIns *pc = snap_pc(as->T->snapmap[snap->mapofs + snap->nent]); + int32_t mres; + if (bc_op(*pc) == BC_JLOOP) { /* NYI: find a better way to do this. */ + BCIns *retpc = &traceref(as->J, bc_d(*pc))->startins; + if (bc_isret(bc_op(*retpc))) + pc = retpc; + } + ra_allockreg(as, i32ptr(J2GG(as->J)->dispatch), RID_DISPATCH); + ra_allockreg(as, i32ptr(pc), RID_LPC); + mres = (int32_t)(snap->nslots - baseslot); + switch (bc_op(*pc)) { + case BC_CALLM: case BC_CALLMT: + mres -= (int32_t)(1 + bc_a(*pc) + bc_c(*pc)); break; + case BC_RETM: mres -= (int32_t)(bc_a(*pc) + bc_d(*pc)); break; + case BC_TSETM: mres -= (int32_t)bc_a(*pc); break; + default: if (bc_op(*pc) < BC_FUNCF) mres = 0; break; + } + ra_allockreg(as, mres, RID_RET); /* Return MULTRES or 0. */ + } else if (baseslot) { + /* Save modified BASE for linking to trace with higher start frame. */ + emit_setgl(as, RID_BASE, jit_base); + } + emit_addptr(as, RID_BASE, 8*(int32_t)baseslot); + + /* Sync the interpreter state with the on-trace state. */ + asm_stack_restore(as, snap); + + /* Root traces that add frames need to check the stack at the end. */ + if (!as->parent && gotframe) + asm_stack_check(as, as->topslot, NULL, as->freeset & RSET_GPR, snapno); +} + +/* -- Trace setup --------------------------------------------------------- */ + +/* Clear reg/sp for all instructions and add register hints. */ +static void asm_setup_regsp(ASMState *as) +{ + GCtrace *T = as->T; + int sink = T->sinktags; + IRRef nins = T->nins; + IRIns *ir, *lastir; + int inloop; +#if LJ_TARGET_ARM + uint32_t rload = 0xa6402a64; +#endif + + ra_setup(as); + + /* Clear reg/sp for constants. */ + for (ir = IR(T->nk), lastir = IR(REF_BASE); ir < lastir; ir++) + ir->prev = REGSP_INIT; + + /* REF_BASE is used for implicit references to the BASE register. */ + lastir->prev = REGSP_HINT(RID_BASE); + + ir = IR(nins-1); + if (ir->o == IR_RENAME) { + do { ir--; nins--; } while (ir->o == IR_RENAME); + T->nins = nins; /* Remove any renames left over from ASM restart. */ + } + as->snaprename = nins; + as->snapref = nins; + as->snapno = T->nsnap; + + as->stopins = REF_BASE; + as->orignins = nins; + as->curins = nins; + + /* Setup register hints for parent link instructions. */ + ir = IR(REF_FIRST); + if (as->parent) { + uint16_t *p; + lastir = lj_snap_regspmap(as->parent, as->J->exitno, ir); + if (lastir - ir > LJ_MAX_JSLOTS) + lj_trace_err(as->J, LJ_TRERR_NYICOAL); + as->stopins = (IRRef)((lastir-1) - as->ir); + for (p = as->parentmap; ir < lastir; ir++) { + RegSP rs = ir->prev; + *p++ = (uint16_t)rs; /* Copy original parent RegSP to parentmap. */ + if (!ra_hasspill(regsp_spill(rs))) + ir->prev = (uint16_t)REGSP_HINT(regsp_reg(rs)); + else + ir->prev = REGSP_INIT; + } + } + + inloop = 0; + as->evenspill = SPS_FIRST; + for (lastir = IR(nins); ir < lastir; ir++) { + if (sink) { + if (ir->r == RID_SINK) + continue; + if (ir->r == RID_SUNK) { /* Revert after ASM restart. */ + ir->r = RID_SINK; + continue; + } + } + switch (ir->o) { + case IR_LOOP: + inloop = 1; + break; +#if LJ_TARGET_ARM + case IR_SLOAD: + if (!((ir->op2 & IRSLOAD_TYPECHECK) || (ir+1)->o == IR_HIOP)) + break; + /* fallthrough */ + case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + if (!LJ_SOFTFP && irt_isnum(ir->t)) break; + ir->prev = (uint16_t)REGSP_HINT((rload & 15)); + rload = lj_ror(rload, 4); + continue; +#endif + case IR_CALLXS: { + CCallInfo ci; + ci.flags = asm_callx_flags(as, ir); + ir->prev = asm_setup_call_slots(as, ir, &ci); + if (inloop) + as->modset |= RSET_SCRATCH; + continue; + } + case IR_CALLN: case IR_CALLL: case IR_CALLS: { + const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; + ir->prev = asm_setup_call_slots(as, ir, ci); + if (inloop) + as->modset |= (ci->flags & CCI_NOFPRCLOBBER) ? + (RSET_SCRATCH & ~RSET_FPR) : RSET_SCRATCH; + continue; + } +#if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) + case IR_HIOP: + switch ((ir-1)->o) { +#if LJ_SOFTFP && LJ_TARGET_ARM + case IR_SLOAD: case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + if (ra_hashint((ir-1)->r)) { + ir->prev = (ir-1)->prev + 1; + continue; + } + break; +#endif +#if !LJ_SOFTFP && LJ_NEED_FP64 + case IR_CONV: + if (irt_isfp((ir-1)->t)) { + ir->prev = REGSP_HINT(RID_FPRET); + continue; + } + /* fallthrough */ +#endif + case IR_CALLN: case IR_CALLXS: +#if LJ_SOFTFP + case IR_MIN: case IR_MAX: +#endif + (ir-1)->prev = REGSP_HINT(RID_RETLO); + ir->prev = REGSP_HINT(RID_RETHI); + continue; + default: + break; + } + break; +#endif +#if LJ_SOFTFP + case IR_MIN: case IR_MAX: + if ((ir+1)->o != IR_HIOP) break; + /* fallthrough */ +#endif + /* C calls evict all scratch regs and return results in RID_RET. */ + case IR_SNEW: case IR_XSNEW: case IR_NEWREF: + if (REGARG_NUMGPR < 3 && as->evenspill < 3) + as->evenspill = 3; /* lj_str_new and lj_tab_newkey need 3 args. */ + case IR_TNEW: case IR_TDUP: case IR_CNEW: case IR_CNEWI: case IR_TOSTR: + ir->prev = REGSP_HINT(RID_RET); + if (inloop) + as->modset = RSET_SCRATCH; + continue; + case IR_STRTO: case IR_OBAR: + if (inloop) + as->modset = RSET_SCRATCH; + break; +#if !LJ_TARGET_X86ORX64 && !LJ_SOFTFP + case IR_ATAN2: case IR_LDEXP: +#endif + case IR_POW: + if (!LJ_SOFTFP && irt_isnum(ir->t)) { +#if LJ_TARGET_X86ORX64 + ir->prev = REGSP_HINT(RID_XMM0); + if (inloop) + as->modset |= RSET_RANGE(RID_XMM0, RID_XMM1+1)|RID2RSET(RID_EAX); +#else + ir->prev = REGSP_HINT(RID_FPRET); + if (inloop) + as->modset |= RSET_SCRATCH; +#endif + continue; + } + /* fallthrough for integer POW */ + case IR_DIV: case IR_MOD: + if (!irt_isnum(ir->t)) { + ir->prev = REGSP_HINT(RID_RET); + if (inloop) + as->modset |= (RSET_SCRATCH & RSET_GPR); + continue; + } + break; + case IR_FPMATH: +#if LJ_TARGET_X86ORX64 + if (ir->op2 == IRFPM_EXP2) { /* May be joined to lj_vm_pow_sse. */ + ir->prev = REGSP_HINT(RID_XMM0); +#if !LJ_64 + if (as->evenspill < 4) /* Leave room for 16 byte scratch area. */ + as->evenspill = 4; +#endif + if (inloop) + as->modset |= RSET_RANGE(RID_XMM0, RID_XMM2+1)|RID2RSET(RID_EAX); + continue; + } else if (ir->op2 <= IRFPM_TRUNC && !(as->flags & JIT_F_SSE4_1)) { + ir->prev = REGSP_HINT(RID_XMM0); + if (inloop) + as->modset |= RSET_RANGE(RID_XMM0, RID_XMM3+1)|RID2RSET(RID_EAX); + continue; + } + break; +#else + ir->prev = REGSP_HINT(RID_FPRET); + if (inloop) + as->modset |= RSET_SCRATCH; + continue; +#endif +#if LJ_TARGET_X86ORX64 + /* Non-constant shift counts need to be in RID_ECX on x86/x64. */ + case IR_BSHL: case IR_BSHR: case IR_BSAR: case IR_BROL: case IR_BROR: + if (!irref_isk(ir->op2) && !ra_hashint(IR(ir->op2)->r)) { + IR(ir->op2)->r = REGSP_HINT(RID_ECX); + if (inloop) + rset_set(as->modset, RID_ECX); + } + break; +#endif + /* Do not propagate hints across type conversions or loads. */ + case IR_TOBIT: + case IR_XLOAD: +#if !LJ_TARGET_ARM + case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: +#endif + break; + case IR_CONV: + if (irt_isfp(ir->t) || (ir->op2 & IRCONV_SRCMASK) == IRT_NUM || + (ir->op2 & IRCONV_SRCMASK) == IRT_FLOAT) + break; + /* fallthrough */ + default: + /* Propagate hints across likely 'op reg, imm' or 'op reg'. */ + if (irref_isk(ir->op2) && !irref_isk(ir->op1) && + ra_hashint(regsp_reg(IR(ir->op1)->prev))) { + ir->prev = IR(ir->op1)->prev; + continue; + } + break; + } + ir->prev = REGSP_INIT; + } + if ((as->evenspill & 1)) + as->oddspill = as->evenspill++; + else + as->oddspill = 0; +} + +/* -- Assembler core ------------------------------------------------------ */ + +/* Assemble a trace. */ +void lj_asm_trace(jit_State *J, GCtrace *T) +{ + ASMState as_; + ASMState *as = &as_; + MCode *origtop; + + /* Ensure an initialized instruction beyond the last one for HIOP checks. */ + J->cur.nins = lj_ir_nextins(J); + J->cur.ir[J->cur.nins].o = IR_NOP; + + /* Setup initial state. Copy some fields to reduce indirections. */ + as->J = J; + as->T = T; + as->ir = T->ir; + as->flags = J->flags; + as->loopref = J->loopref; + as->realign = NULL; + as->loopinv = 0; + as->parent = J->parent ? traceref(J, J->parent) : NULL; + + /* Reserve MCode memory. */ + as->mctop = origtop = lj_mcode_reserve(J, &as->mcbot); + as->mcp = as->mctop; + as->mclim = as->mcbot + MCLIM_REDZONE; + asm_setup_target(as); + + do { + as->mcp = as->mctop; +#ifdef LUA_USE_ASSERT + as->mcp_prev = as->mcp; +#endif + as->curins = T->nins; + RA_DBG_START(); + RA_DBGX((as, "===== STOP =====")); + + /* General trace setup. Emit tail of trace. */ + asm_tail_prep(as); + as->mcloop = NULL; + as->flagmcp = NULL; + as->topslot = 0; + as->gcsteps = 0; + as->sectref = as->loopref; + as->fuseref = (as->flags & JIT_F_OPT_FUSE) ? as->loopref : FUSE_DISABLED; + asm_setup_regsp(as); + if (!as->loopref) + asm_tail_link(as); + + /* Assemble a trace in linear backwards order. */ + for (as->curins--; as->curins > as->stopins; as->curins--) { + IRIns *ir = IR(as->curins); + lua_assert(!(LJ_32 && irt_isint64(ir->t))); /* Handled by SPLIT. */ + if (!ra_used(ir) && !ir_sideeff(ir) && (as->flags & JIT_F_OPT_DCE)) + continue; /* Dead-code elimination can be soooo easy. */ + if (irt_isguard(ir->t)) + asm_snap_prep(as); + RA_DBG_REF(); + checkmclim(as); + asm_ir(as, ir); + } + } while (as->realign); /* Retry in case the MCode needs to be realigned. */ + + /* Emit head of trace. */ + RA_DBG_REF(); + checkmclim(as); + if (as->gcsteps > 0) { + as->curins = as->T->snap[0].ref; + asm_snap_prep(as); /* The GC check is a guard. */ + asm_gc_check(as); + } + ra_evictk(as); + if (as->parent) + asm_head_side(as); + else + asm_head_root(as); + asm_phi_fixup(as); + + RA_DBGX((as, "===== START ====")); + RA_DBG_FLUSH(); + if (as->freeset != RSET_ALL) + lj_trace_err(as->J, LJ_TRERR_BADRA); /* Ouch! Should never happen. */ + + /* Set trace entry point before fixing up tail to allow link to self. */ + T->mcode = as->mcp; + T->mcloop = as->mcloop ? (MSize)((char *)as->mcloop - (char *)as->mcp) : 0; + if (!as->loopref) + asm_tail_fixup(as, T->link); /* Note: this may change as->mctop! */ + T->szmcode = (MSize)((char *)as->mctop - (char *)as->mcp); + lj_mcode_sync(T->mcode, origtop); +} + +#undef IR + +#endif + +``` + +`include/luajit-2.0.5/src/lj_asm.h`: + +```h +/* +** IR assembler (SSA IR -> machine code). +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_ASM_H +#define _LJ_ASM_H + +#include "lj_jit.h" + +#if LJ_HASJIT +LJ_FUNC void lj_asm_trace(jit_State *J, GCtrace *T); +LJ_FUNC void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, + MCode *target); +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_asm_arm.h`: + +```h +/* +** ARM IR assembler (SSA IR -> machine code). +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Register allocator extensions --------------------------------------- */ + +/* Allocate a register with a hint. */ +static Reg ra_hintalloc(ASMState *as, IRRef ref, Reg hint, RegSet allow) +{ + Reg r = IR(ref)->r; + if (ra_noreg(r)) { + if (!ra_hashint(r) && !iscrossref(as, ref)) + ra_sethint(IR(ref)->r, hint); /* Propagate register hint. */ + r = ra_allocref(as, ref, allow); + } + ra_noweak(as, r); + return r; +} + +/* Allocate a scratch register pair. */ +static Reg ra_scratchpair(ASMState *as, RegSet allow) +{ + RegSet pick1 = as->freeset & allow; + RegSet pick2 = pick1 & (pick1 >> 1) & RSET_GPREVEN; + Reg r; + if (pick2) { + r = rset_picktop(pick2); + } else { + RegSet pick = pick1 & (allow >> 1) & RSET_GPREVEN; + if (pick) { + r = rset_picktop(pick); + ra_restore(as, regcost_ref(as->cost[r+1])); + } else { + pick = pick1 & (allow << 1) & RSET_GPRODD; + if (pick) { + r = ra_restore(as, regcost_ref(as->cost[rset_picktop(pick)-1])); + } else { + r = ra_evict(as, allow & (allow >> 1) & RSET_GPREVEN); + ra_restore(as, regcost_ref(as->cost[r+1])); + } + } + } + lua_assert(rset_test(RSET_GPREVEN, r)); + ra_modified(as, r); + ra_modified(as, r+1); + RA_DBGX((as, "scratchpair $r $r", r, r+1)); + return r; +} + +#if !LJ_SOFTFP +/* Allocate two source registers for three-operand instructions. */ +static Reg ra_alloc2(ASMState *as, IRIns *ir, RegSet allow) +{ + IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); + Reg left = irl->r, right = irr->r; + if (ra_hasreg(left)) { + ra_noweak(as, left); + if (ra_noreg(right)) + right = ra_allocref(as, ir->op2, rset_exclude(allow, left)); + else + ra_noweak(as, right); + } else if (ra_hasreg(right)) { + ra_noweak(as, right); + left = ra_allocref(as, ir->op1, rset_exclude(allow, right)); + } else if (ra_hashint(right)) { + right = ra_allocref(as, ir->op2, allow); + left = ra_alloc1(as, ir->op1, rset_exclude(allow, right)); + } else { + left = ra_allocref(as, ir->op1, allow); + right = ra_alloc1(as, ir->op2, rset_exclude(allow, left)); + } + return left | (right << 8); +} +#endif + +/* -- Guard handling ------------------------------------------------------ */ + +/* Generate an exit stub group at the bottom of the reserved MCode memory. */ +static MCode *asm_exitstub_gen(ASMState *as, ExitNo group) +{ + MCode *mxp = as->mcbot; + int i; + if (mxp + 4*4+4*EXITSTUBS_PER_GROUP >= as->mctop) + asm_mclimit(as); + /* str lr, [sp]; bl ->vm_exit_handler; .long DISPATCH_address, group. */ + *mxp++ = ARMI_STR|ARMI_LS_P|ARMI_LS_U|ARMF_D(RID_LR)|ARMF_N(RID_SP); + *mxp = ARMI_BL|((((MCode *)(void *)lj_vm_exit_handler-mxp)-2)&0x00ffffffu); + mxp++; + *mxp++ = (MCode)i32ptr(J2GG(as->J)->dispatch); /* DISPATCH address */ + *mxp++ = group*EXITSTUBS_PER_GROUP; + for (i = 0; i < EXITSTUBS_PER_GROUP; i++) + *mxp++ = ARMI_B|((-6-i)&0x00ffffffu); + lj_mcode_sync(as->mcbot, mxp); + lj_mcode_commitbot(as->J, mxp); + as->mcbot = mxp; + as->mclim = as->mcbot + MCLIM_REDZONE; + return mxp - EXITSTUBS_PER_GROUP; +} + +/* Setup all needed exit stubs. */ +static void asm_exitstub_setup(ASMState *as, ExitNo nexits) +{ + ExitNo i; + if (nexits >= EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) + lj_trace_err(as->J, LJ_TRERR_SNAPOV); + for (i = 0; i < (nexits+EXITSTUBS_PER_GROUP-1)/EXITSTUBS_PER_GROUP; i++) + if (as->J->exitstubgroup[i] == NULL) + as->J->exitstubgroup[i] = asm_exitstub_gen(as, i); +} + +/* Emit conditional branch to exit for guard. */ +static void asm_guardcc(ASMState *as, ARMCC cc) +{ + MCode *target = exitstub_addr(as->J, as->snapno); + MCode *p = as->mcp; + if (LJ_UNLIKELY(p == as->invmcp)) { + as->loopinv = 1; + *p = ARMI_BL | ((target-p-2) & 0x00ffffffu); + emit_branch(as, ARMF_CC(ARMI_B, cc^1), p+1); + return; + } + emit_branch(as, ARMF_CC(ARMI_BL, cc), target); +} + +/* -- Operand fusion ------------------------------------------------------ */ + +/* Limit linear search to this distance. Avoids O(n^2) behavior. */ +#define CONFLICT_SEARCH_LIM 31 + +/* Check if there's no conflicting instruction between curins and ref. */ +static int noconflict(ASMState *as, IRRef ref, IROp conflict) +{ + IRIns *ir = as->ir; + IRRef i = as->curins; + if (i > ref + CONFLICT_SEARCH_LIM) + return 0; /* Give up, ref is too far away. */ + while (--i > ref) + if (ir[i].o == conflict) + return 0; /* Conflict found. */ + return 1; /* Ok, no conflict. */ +} + +/* Fuse the array base of colocated arrays. */ +static int32_t asm_fuseabase(ASMState *as, IRRef ref) +{ + IRIns *ir = IR(ref); + if (ir->o == IR_TNEW && ir->op1 <= LJ_MAX_COLOSIZE && + !neverfuse(as) && noconflict(as, ref, IR_NEWREF)) + return (int32_t)sizeof(GCtab); + return 0; +} + +/* Fuse array/hash/upvalue reference into register+offset operand. */ +static Reg asm_fuseahuref(ASMState *as, IRRef ref, int32_t *ofsp, RegSet allow, + int lim) +{ + IRIns *ir = IR(ref); + if (ra_noreg(ir->r)) { + if (ir->o == IR_AREF) { + if (mayfuse(as, ref)) { + if (irref_isk(ir->op2)) { + IRRef tab = IR(ir->op1)->op1; + int32_t ofs = asm_fuseabase(as, tab); + IRRef refa = ofs ? tab : ir->op1; + ofs += 8*IR(ir->op2)->i; + if (ofs > -lim && ofs < lim) { + *ofsp = ofs; + return ra_alloc1(as, refa, allow); + } + } + } + } else if (ir->o == IR_HREFK) { + if (mayfuse(as, ref)) { + int32_t ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); + if (ofs < lim) { + *ofsp = ofs; + return ra_alloc1(as, ir->op1, allow); + } + } + } else if (ir->o == IR_UREFC) { + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + int32_t ofs = i32ptr(&gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.tv); + *ofsp = (ofs & 255); /* Mask out less bits to allow LDRD. */ + return ra_allock(as, (ofs & ~255), allow); + } + } + } + *ofsp = 0; + return ra_alloc1(as, ref, allow); +} + +/* Fuse m operand into arithmetic/logic instructions. */ +static uint32_t asm_fuseopm(ASMState *as, ARMIns ai, IRRef ref, RegSet allow) +{ + IRIns *ir = IR(ref); + if (ra_hasreg(ir->r)) { + ra_noweak(as, ir->r); + return ARMF_M(ir->r); + } else if (irref_isk(ref)) { + uint32_t k = emit_isk12(ai, ir->i); + if (k) + return k; + } else if (mayfuse(as, ref)) { + if (ir->o >= IR_BSHL && ir->o <= IR_BROR) { + Reg m = ra_alloc1(as, ir->op1, allow); + ARMShift sh = ir->o == IR_BSHL ? ARMSH_LSL : + ir->o == IR_BSHR ? ARMSH_LSR : + ir->o == IR_BSAR ? ARMSH_ASR : ARMSH_ROR; + if (irref_isk(ir->op2)) { + return m | ARMF_SH(sh, (IR(ir->op2)->i & 31)); + } else { + Reg s = ra_alloc1(as, ir->op2, rset_exclude(allow, m)); + return m | ARMF_RSH(sh, s); + } + } else if (ir->o == IR_ADD && ir->op1 == ir->op2) { + Reg m = ra_alloc1(as, ir->op1, allow); + return m | ARMF_SH(ARMSH_LSL, 1); + } + } + return ra_allocref(as, ref, allow); +} + +/* Fuse shifts into loads/stores. Only bother with BSHL 2 => lsl #2. */ +static IRRef asm_fuselsl2(ASMState *as, IRRef ref) +{ + IRIns *ir = IR(ref); + if (ra_noreg(ir->r) && mayfuse(as, ref) && ir->o == IR_BSHL && + irref_isk(ir->op2) && IR(ir->op2)->i == 2) + return ir->op1; + return 0; /* No fusion. */ +} + +/* Fuse XLOAD/XSTORE reference into load/store operand. */ +static void asm_fusexref(ASMState *as, ARMIns ai, Reg rd, IRRef ref, + RegSet allow, int32_t ofs) +{ + IRIns *ir = IR(ref); + Reg base; + if (ra_noreg(ir->r) && canfuse(as, ir)) { + int32_t lim = (!LJ_SOFTFP && (ai & 0x08000000)) ? 1024 : + (ai & 0x04000000) ? 4096 : 256; + if (ir->o == IR_ADD) { + int32_t ofs2; + if (irref_isk(ir->op2) && + (ofs2 = ofs + IR(ir->op2)->i) > -lim && ofs2 < lim && + (!(!LJ_SOFTFP && (ai & 0x08000000)) || !(ofs2 & 3))) { + ofs = ofs2; + ref = ir->op1; + } else if (ofs == 0 && !(!LJ_SOFTFP && (ai & 0x08000000))) { + IRRef lref = ir->op1, rref = ir->op2; + Reg rn, rm; + if ((ai & 0x04000000)) { + IRRef sref = asm_fuselsl2(as, rref); + if (sref) { + rref = sref; + ai |= ARMF_SH(ARMSH_LSL, 2); + } else if ((sref = asm_fuselsl2(as, lref)) != 0) { + lref = rref; + rref = sref; + ai |= ARMF_SH(ARMSH_LSL, 2); + } + } + rn = ra_alloc1(as, lref, allow); + rm = ra_alloc1(as, rref, rset_exclude(allow, rn)); + if ((ai & 0x04000000)) ai |= ARMI_LS_R; + emit_dnm(as, ai|ARMI_LS_P|ARMI_LS_U, rd, rn, rm); + return; + } + } else if (ir->o == IR_STRREF && !(!LJ_SOFTFP && (ai & 0x08000000))) { + lua_assert(ofs == 0); + ofs = (int32_t)sizeof(GCstr); + if (irref_isk(ir->op2)) { + ofs += IR(ir->op2)->i; + ref = ir->op1; + } else if (irref_isk(ir->op1)) { + ofs += IR(ir->op1)->i; + ref = ir->op2; + } else { + /* NYI: Fuse ADD with constant. */ + Reg rn = ra_alloc1(as, ir->op1, allow); + uint32_t m = asm_fuseopm(as, 0, ir->op2, rset_exclude(allow, rn)); + if ((ai & 0x04000000)) + emit_lso(as, ai, rd, rd, ofs); + else + emit_lsox(as, ai, rd, rd, ofs); + emit_dn(as, ARMI_ADD^m, rd, rn); + return; + } + if (ofs <= -lim || ofs >= lim) { + Reg rn = ra_alloc1(as, ref, allow); + Reg rm = ra_allock(as, ofs, rset_exclude(allow, rn)); + if ((ai & 0x04000000)) ai |= ARMI_LS_R; + emit_dnm(as, ai|ARMI_LS_P|ARMI_LS_U, rd, rn, rm); + return; + } + } + } + base = ra_alloc1(as, ref, allow); +#if !LJ_SOFTFP + if ((ai & 0x08000000)) + emit_vlso(as, ai, rd, base, ofs); + else +#endif + if ((ai & 0x04000000)) + emit_lso(as, ai, rd, base, ofs); + else + emit_lsox(as, ai, rd, base, ofs); +} + +#if !LJ_SOFTFP +/* Fuse to multiply-add/sub instruction. */ +static int asm_fusemadd(ASMState *as, IRIns *ir, ARMIns ai, ARMIns air) +{ + IRRef lref = ir->op1, rref = ir->op2; + IRIns *irm; + if (lref != rref && + ((mayfuse(as, lref) && (irm = IR(lref), irm->o == IR_MUL) && + ra_noreg(irm->r)) || + (mayfuse(as, rref) && (irm = IR(rref), irm->o == IR_MUL) && + (rref = lref, ai = air, ra_noreg(irm->r))))) { + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg add = ra_hintalloc(as, rref, dest, RSET_FPR); + Reg right, left = ra_alloc2(as, irm, + rset_exclude(rset_exclude(RSET_FPR, dest), add)); + right = (left >> 8); left &= 255; + emit_dnm(as, ai, (dest & 15), (left & 15), (right & 15)); + if (dest != add) emit_dm(as, ARMI_VMOV_D, (dest & 15), (add & 15)); + return 1; + } + return 0; +} +#endif + +/* -- Calls --------------------------------------------------------------- */ + +/* Generate a call to a C function. */ +static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) +{ + uint32_t n, nargs = CCI_NARGS(ci); + int32_t ofs = 0; +#if LJ_SOFTFP + Reg gpr = REGARG_FIRSTGPR; +#else + Reg gpr, fpr = REGARG_FIRSTFPR, fprodd = 0; +#endif + if ((void *)ci->func) + emit_call(as, (void *)ci->func); +#if !LJ_SOFTFP + for (gpr = REGARG_FIRSTGPR; gpr <= REGARG_LASTGPR; gpr++) + as->cost[gpr] = REGCOST(~0u, ASMREF_L); + gpr = REGARG_FIRSTGPR; +#endif + for (n = 0; n < nargs; n++) { /* Setup args. */ + IRRef ref = args[n]; + IRIns *ir = IR(ref); +#if !LJ_SOFTFP + if (ref && irt_isfp(ir->t)) { + RegSet of = as->freeset; + Reg src; + if (!LJ_ABI_SOFTFP && !(ci->flags & CCI_VARARG)) { + if (irt_isnum(ir->t)) { + if (fpr <= REGARG_LASTFPR) { + ra_leftov(as, fpr, ref); + fpr++; + continue; + } + } else if (fprodd) { /* Ick. */ + src = ra_alloc1(as, ref, RSET_FPR); + emit_dm(as, ARMI_VMOV_S, (fprodd & 15), (src & 15) | 0x00400000); + fprodd = 0; + continue; + } else if (fpr <= REGARG_LASTFPR) { + ra_leftov(as, fpr, ref); + fprodd = fpr++; + continue; + } + /* Workaround to protect argument GPRs from being used for remat. */ + as->freeset &= ~RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1); + src = ra_alloc1(as, ref, RSET_FPR); /* May alloc GPR to remat FPR. */ + as->freeset |= (of & RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1)); + fprodd = 0; + goto stackfp; + } + /* Workaround to protect argument GPRs from being used for remat. */ + as->freeset &= ~RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1); + src = ra_alloc1(as, ref, RSET_FPR); /* May alloc GPR to remat FPR. */ + as->freeset |= (of & RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1)); + if (irt_isnum(ir->t)) gpr = (gpr+1) & ~1u; + if (gpr <= REGARG_LASTGPR) { + lua_assert(rset_test(as->freeset, gpr)); /* Must have been evicted. */ + if (irt_isnum(ir->t)) { + lua_assert(rset_test(as->freeset, gpr+1)); /* Ditto. */ + emit_dnm(as, ARMI_VMOV_RR_D, gpr, gpr+1, (src & 15)); + gpr += 2; + } else { + emit_dn(as, ARMI_VMOV_R_S, gpr, (src & 15)); + gpr++; + } + } else { + stackfp: + if (irt_isnum(ir->t)) ofs = (ofs + 4) & ~4; + emit_spstore(as, ir, src, ofs); + ofs += irt_isnum(ir->t) ? 8 : 4; + } + } else +#endif + { + if (gpr <= REGARG_LASTGPR) { + lua_assert(rset_test(as->freeset, gpr)); /* Must have been evicted. */ + if (ref) ra_leftov(as, gpr, ref); + gpr++; + } else { + if (ref) { + Reg r = ra_alloc1(as, ref, RSET_GPR); + emit_spstore(as, ir, r, ofs); + } + ofs += 4; + } + } + } +} + +/* Setup result reg/sp for call. Evict scratch regs. */ +static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + RegSet drop = RSET_SCRATCH; + int hiop = ((ir+1)->o == IR_HIOP && !irt_isnil((ir+1)->t)); + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + if (hiop && ra_hasreg((ir+1)->r)) + rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ + ra_evictset(as, drop); /* Evictions must be performed first. */ + if (ra_used(ir)) { + lua_assert(!irt_ispri(ir->t)); + if (!LJ_SOFTFP && irt_isfp(ir->t)) { + if (LJ_ABI_SOFTFP || (ci->flags & (CCI_CASTU64|CCI_VARARG))) { + Reg dest = (ra_dest(as, ir, RSET_FPR) & 15); + if (irt_isnum(ir->t)) + emit_dnm(as, ARMI_VMOV_D_RR, RID_RETLO, RID_RETHI, dest); + else + emit_dn(as, ARMI_VMOV_S_R, RID_RET, dest); + } else { + ra_destreg(as, ir, RID_FPRET); + } + } else if (hiop) { + ra_destpair(as, ir); + } else { + ra_destreg(as, ir, RID_RET); + } + } + UNUSED(ci); +} + +static void asm_call(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX]; + const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; + asm_collectargs(as, ir, ci, args); + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +static void asm_callx(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX*2]; + CCallInfo ci; + IRRef func; + IRIns *irf; + ci.flags = asm_callx_flags(as, ir); + asm_collectargs(as, ir, &ci, args); + asm_setupresult(as, ir, &ci); + func = ir->op2; irf = IR(func); + if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } + if (irref_isk(func)) { /* Call to constant address. */ + ci.func = (ASMFunction)(void *)(irf->i); + } else { /* Need a non-argument register for indirect calls. */ + Reg freg = ra_alloc1(as, func, RSET_RANGE(RID_R4, RID_R12+1)); + emit_m(as, ARMI_BLXr, freg); + ci.func = (ASMFunction)(void *)0; + } + asm_gencall(as, &ci, args); +} + +/* -- Returns ------------------------------------------------------------- */ + +/* Return to lower frame. Guard that it goes to the right spot. */ +static void asm_retf(ASMState *as, IRIns *ir) +{ + Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); + void *pc = ir_kptr(IR(ir->op2)); + int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); + as->topslot -= (BCReg)delta; + if ((int32_t)as->topslot < 0) as->topslot = 0; + irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ + /* Need to force a spill on REF_BASE now to update the stack slot. */ + emit_lso(as, ARMI_STR, base, RID_SP, ra_spill(as, IR(REF_BASE))); + emit_setgl(as, base, jit_base); + emit_addptr(as, base, -8*delta); + asm_guardcc(as, CC_NE); + emit_nm(as, ARMI_CMP, RID_TMP, + ra_allock(as, i32ptr(pc), rset_exclude(RSET_GPR, base))); + emit_lso(as, ARMI_LDR, RID_TMP, base, -4); +} + +/* -- Type conversions ---------------------------------------------------- */ + +#if !LJ_SOFTFP +static void asm_tointg(ASMState *as, IRIns *ir, Reg left) +{ + Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); + Reg dest = ra_dest(as, ir, RSET_GPR); + asm_guardcc(as, CC_NE); + emit_d(as, ARMI_VMRS, 0); + emit_dm(as, ARMI_VCMP_D, (tmp & 15), (left & 15)); + emit_dm(as, ARMI_VCVT_F64_S32, (tmp & 15), (tmp & 15)); + emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); + emit_dm(as, ARMI_VCVT_S32_F64, (tmp & 15), (left & 15)); +} + +static void asm_tobit(ASMState *as, IRIns *ir) +{ + RegSet allow = RSET_FPR; + Reg left = ra_alloc1(as, ir->op1, allow); + Reg right = ra_alloc1(as, ir->op2, rset_clear(allow, left)); + Reg tmp = ra_scratch(as, rset_clear(allow, right)); + Reg dest = ra_dest(as, ir, RSET_GPR); + emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); + emit_dnm(as, ARMI_VADD_D, (tmp & 15), (left & 15), (right & 15)); +} +#endif + +static void asm_conv(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); +#if !LJ_SOFTFP + int stfp = (st == IRT_NUM || st == IRT_FLOAT); +#endif + IRRef lref = ir->op1; + /* 64 bit integer conversions are handled by SPLIT. */ + lua_assert(!irt_isint64(ir->t) && !(st == IRT_I64 || st == IRT_U64)); +#if LJ_SOFTFP + /* FP conversions are handled by SPLIT. */ + lua_assert(!irt_isfp(ir->t) && !(st == IRT_NUM || st == IRT_FLOAT)); + /* Can't check for same types: SPLIT uses CONV int.int + BXOR for sfp NEG. */ +#else + lua_assert(irt_type(ir->t) != st); + if (irt_isfp(ir->t)) { + Reg dest = ra_dest(as, ir, RSET_FPR); + if (stfp) { /* FP to FP conversion. */ + emit_dm(as, st == IRT_NUM ? ARMI_VCVT_F32_F64 : ARMI_VCVT_F64_F32, + (dest & 15), (ra_alloc1(as, lref, RSET_FPR) & 15)); + } else { /* Integer to FP conversion. */ + Reg left = ra_alloc1(as, lref, RSET_GPR); + ARMIns ai = irt_isfloat(ir->t) ? + (st == IRT_INT ? ARMI_VCVT_F32_S32 : ARMI_VCVT_F32_U32) : + (st == IRT_INT ? ARMI_VCVT_F64_S32 : ARMI_VCVT_F64_U32); + emit_dm(as, ai, (dest & 15), (dest & 15)); + emit_dn(as, ARMI_VMOV_S_R, left, (dest & 15)); + } + } else if (stfp) { /* FP to integer conversion. */ + if (irt_isguard(ir->t)) { + /* Checked conversions are only supported from number to int. */ + lua_assert(irt_isint(ir->t) && st == IRT_NUM); + asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); + } else { + Reg left = ra_alloc1(as, lref, RSET_FPR); + Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); + Reg dest = ra_dest(as, ir, RSET_GPR); + ARMIns ai; + emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); + ai = irt_isint(ir->t) ? + (st == IRT_NUM ? ARMI_VCVT_S32_F64 : ARMI_VCVT_S32_F32) : + (st == IRT_NUM ? ARMI_VCVT_U32_F64 : ARMI_VCVT_U32_F32); + emit_dm(as, ai, (tmp & 15), (left & 15)); + } + } else +#endif + { + Reg dest = ra_dest(as, ir, RSET_GPR); + if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ + Reg left = ra_alloc1(as, lref, RSET_GPR); + lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); + if ((as->flags & JIT_F_ARMV6)) { + ARMIns ai = st == IRT_I8 ? ARMI_SXTB : + st == IRT_U8 ? ARMI_UXTB : + st == IRT_I16 ? ARMI_SXTH : ARMI_UXTH; + emit_dm(as, ai, dest, left); + } else if (st == IRT_U8) { + emit_dn(as, ARMI_AND|ARMI_K12|255, dest, left); + } else { + uint32_t shift = st == IRT_I8 ? 24 : 16; + ARMShift sh = st == IRT_U16 ? ARMSH_LSR : ARMSH_ASR; + emit_dm(as, ARMI_MOV|ARMF_SH(sh, shift), dest, RID_TMP); + emit_dm(as, ARMI_MOV|ARMF_SH(ARMSH_LSL, shift), RID_TMP, left); + } + } else { /* Handle 32/32 bit no-op (cast). */ + ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ + } + } +} + +#if !LJ_SOFTFP && LJ_HASFFI +static void asm_conv64(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); + IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); + IRCallID id; + CCallInfo ci; + IRRef args[2]; + args[0] = (ir-1)->op1; + args[1] = ir->op1; + if (st == IRT_NUM || st == IRT_FLOAT) { + id = IRCALL_fp64_d2l + ((st == IRT_FLOAT) ? 2 : 0) + (dt - IRT_I64); + ir--; + } else { + id = IRCALL_fp64_l2d + ((dt == IRT_FLOAT) ? 2 : 0) + (st - IRT_I64); + } + ci = lj_ir_callinfo[id]; +#if !LJ_ABI_SOFTFP + ci.flags |= CCI_VARARG; /* These calls don't use the hard-float ABI! */ +#endif + asm_setupresult(as, ir, &ci); + asm_gencall(as, &ci, args); +} +#endif + +static void asm_strto(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; + IRRef args[2]; + Reg rlo = 0, rhi = 0, tmp; + int destused = ra_used(ir); + int32_t ofs = 0; + ra_evictset(as, RSET_SCRATCH); +#if LJ_SOFTFP + if (destused) { + if (ra_hasspill(ir->s) && ra_hasspill((ir+1)->s) && + (ir->s & 1) == 0 && ir->s + 1 == (ir+1)->s) { + int i; + for (i = 0; i < 2; i++) { + Reg r = (ir+i)->r; + if (ra_hasreg(r)) { + ra_free(as, r); + ra_modified(as, r); + emit_spload(as, ir+i, r, sps_scale((ir+i)->s)); + } + } + ofs = sps_scale(ir->s); + destused = 0; + } else { + rhi = ra_dest(as, ir+1, RSET_GPR); + rlo = ra_dest(as, ir, rset_exclude(RSET_GPR, rhi)); + } + } + asm_guardcc(as, CC_EQ); + if (destused) { + emit_lso(as, ARMI_LDR, rhi, RID_SP, 4); + emit_lso(as, ARMI_LDR, rlo, RID_SP, 0); + } +#else + UNUSED(rhi); + if (destused) { + if (ra_hasspill(ir->s)) { + ofs = sps_scale(ir->s); + destused = 0; + if (ra_hasreg(ir->r)) { + ra_free(as, ir->r); + ra_modified(as, ir->r); + emit_spload(as, ir, ir->r, ofs); + } + } else { + rlo = ra_dest(as, ir, RSET_FPR); + } + } + asm_guardcc(as, CC_EQ); + if (destused) + emit_vlso(as, ARMI_VLDR_D, rlo, RID_SP, 0); +#endif + emit_n(as, ARMI_CMP|ARMI_K12|0, RID_RET); /* Test return status. */ + args[0] = ir->op1; /* GCstr *str */ + args[1] = ASMREF_TMP1; /* TValue *n */ + asm_gencall(as, ci, args); + tmp = ra_releasetmp(as, ASMREF_TMP1); + if (ofs == 0) + emit_dm(as, ARMI_MOV, tmp, RID_SP); + else + emit_opk(as, ARMI_ADD, tmp, RID_SP, ofs, RSET_GPR); +} + +/* Get pointer to TValue. */ +static void asm_tvptr(ASMState *as, Reg dest, IRRef ref) +{ + IRIns *ir = IR(ref); + if (irt_isnum(ir->t)) { + if (irref_isk(ref)) { + /* Use the number constant itself as a TValue. */ + ra_allockreg(as, i32ptr(ir_knum(ir)), dest); + } else { +#if LJ_SOFTFP + lua_assert(0); +#else + /* Otherwise force a spill and use the spill slot. */ + emit_opk(as, ARMI_ADD, dest, RID_SP, ra_spill(as, ir), RSET_GPR); +#endif + } + } else { + /* Otherwise use [sp] and [sp+4] to hold the TValue. */ + RegSet allow = rset_exclude(RSET_GPR, dest); + Reg type; + emit_dm(as, ARMI_MOV, dest, RID_SP); + if (!irt_ispri(ir->t)) { + Reg src = ra_alloc1(as, ref, allow); + emit_lso(as, ARMI_STR, src, RID_SP, 0); + } + if ((ir+1)->o == IR_HIOP) + type = ra_alloc1(as, ref+1, allow); + else + type = ra_allock(as, irt_toitype(ir->t), allow); + emit_lso(as, ARMI_STR, type, RID_SP, 4); + } +} + +static void asm_tostr(ASMState *as, IRIns *ir) +{ + IRRef args[2]; + args[0] = ASMREF_L; + as->gcsteps++; + if (irt_isnum(IR(ir->op1)->t) || (ir+1)->o == IR_HIOP) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; + args[1] = ASMREF_TMP1; /* const lua_Number * */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op1); + } else { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; + args[1] = ir->op1; /* int32_t k */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + } +} + +/* -- Memory references --------------------------------------------------- */ + +static void asm_aref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg idx, base; + if (irref_isk(ir->op2)) { + IRRef tab = IR(ir->op1)->op1; + int32_t ofs = asm_fuseabase(as, tab); + IRRef refa = ofs ? tab : ir->op1; + uint32_t k = emit_isk12(ARMI_ADD, ofs + 8*IR(ir->op2)->i); + if (k) { + base = ra_alloc1(as, refa, RSET_GPR); + emit_dn(as, ARMI_ADD^k, dest, base); + return; + } + } + base = ra_alloc1(as, ir->op1, RSET_GPR); + idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); + emit_dnm(as, ARMI_ADD|ARMF_SH(ARMSH_LSL, 3), dest, base, idx); +} + +/* Inlined hash lookup. Specialized for key type and for const keys. +** The equivalent C code is: +** Node *n = hashkey(t, key); +** do { +** if (lj_obj_equal(&n->key, key)) return &n->val; +** } while ((n = nextnode(n))); +** return niltv(L); +*/ +static void asm_href(ASMState *as, IRIns *ir, IROp merge) +{ + RegSet allow = RSET_GPR; + int destused = ra_used(ir); + Reg dest = ra_dest(as, ir, allow); + Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); + Reg key = 0, keyhi = 0, keynumhi = RID_NONE, tmp = RID_TMP; + IRRef refkey = ir->op2; + IRIns *irkey = IR(refkey); + IRType1 kt = irkey->t; + int32_t k = 0, khi = emit_isk12(ARMI_CMP, irt_toitype(kt)); + uint32_t khash; + MCLabel l_end, l_loop; + rset_clear(allow, tab); + if (!irref_isk(refkey) || irt_isstr(kt)) { +#if LJ_SOFTFP + key = ra_alloc1(as, refkey, allow); + rset_clear(allow, key); + if (irkey[1].o == IR_HIOP) { + if (ra_hasreg((irkey+1)->r)) { + keynumhi = (irkey+1)->r; + keyhi = RID_TMP; + ra_noweak(as, keynumhi); + } else { + keyhi = keynumhi = ra_allocref(as, refkey+1, allow); + } + rset_clear(allow, keynumhi); + khi = 0; + } +#else + if (irt_isnum(kt)) { + key = ra_scratch(as, allow); + rset_clear(allow, key); + keyhi = keynumhi = ra_scratch(as, allow); + rset_clear(allow, keyhi); + khi = 0; + } else { + key = ra_alloc1(as, refkey, allow); + rset_clear(allow, key); + } +#endif + } else if (irt_isnum(kt)) { + int32_t val = (int32_t)ir_knum(irkey)->u32.lo; + k = emit_isk12(ARMI_CMP, val); + if (!k) { + key = ra_allock(as, val, allow); + rset_clear(allow, key); + } + val = (int32_t)ir_knum(irkey)->u32.hi; + khi = emit_isk12(ARMI_CMP, val); + if (!khi) { + keyhi = ra_allock(as, val, allow); + rset_clear(allow, keyhi); + } + } else if (!irt_ispri(kt)) { + k = emit_isk12(ARMI_CMP, irkey->i); + if (!k) { + key = ra_alloc1(as, refkey, allow); + rset_clear(allow, key); + } + } + if (!irt_ispri(kt)) + tmp = ra_scratchpair(as, allow); + + /* Key not found in chain: jump to exit (if merged) or load niltv. */ + l_end = emit_label(as); + as->invmcp = NULL; + if (merge == IR_NE) + asm_guardcc(as, CC_AL); + else if (destused) + emit_loada(as, dest, niltvg(J2G(as->J))); + + /* Follow hash chain until the end. */ + l_loop = --as->mcp; + emit_n(as, ARMI_CMP|ARMI_K12|0, dest); + emit_lso(as, ARMI_LDR, dest, dest, (int32_t)offsetof(Node, next)); + + /* Type and value comparison. */ + if (merge == IR_EQ) + asm_guardcc(as, CC_EQ); + else + emit_branch(as, ARMF_CC(ARMI_B, CC_EQ), l_end); + if (!irt_ispri(kt)) { + emit_nm(as, ARMF_CC(ARMI_CMP, CC_EQ)^k, tmp, key); + emit_nm(as, ARMI_CMP^khi, tmp+1, keyhi); + emit_lsox(as, ARMI_LDRD, tmp, dest, (int32_t)offsetof(Node, key)); + } else { + emit_n(as, ARMI_CMP^khi, tmp); + emit_lso(as, ARMI_LDR, tmp, dest, (int32_t)offsetof(Node, key.it)); + } + *l_loop = ARMF_CC(ARMI_B, CC_NE) | ((as->mcp-l_loop-2) & 0x00ffffffu); + + /* Load main position relative to tab->node into dest. */ + khash = irref_isk(refkey) ? ir_khash(irkey) : 1; + if (khash == 0) { + emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); + } else { + emit_dnm(as, ARMI_ADD|ARMF_SH(ARMSH_LSL, 3), dest, dest, tmp); + emit_dnm(as, ARMI_ADD|ARMF_SH(ARMSH_LSL, 1), tmp, tmp, tmp); + if (irt_isstr(kt)) { /* Fetch of str->hash is cheaper than ra_allock. */ + emit_dnm(as, ARMI_AND, tmp, tmp+1, RID_TMP); + emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); + emit_lso(as, ARMI_LDR, tmp+1, key, (int32_t)offsetof(GCstr, hash)); + emit_lso(as, ARMI_LDR, RID_TMP, tab, (int32_t)offsetof(GCtab, hmask)); + } else if (irref_isk(refkey)) { + emit_opk(as, ARMI_AND, tmp, RID_TMP, (int32_t)khash, + rset_exclude(rset_exclude(RSET_GPR, tab), dest)); + emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); + emit_lso(as, ARMI_LDR, RID_TMP, tab, (int32_t)offsetof(GCtab, hmask)); + } else { /* Must match with hash*() in lj_tab.c. */ + if (ra_hasreg(keynumhi)) { /* Canonicalize +-0.0 to 0.0. */ + if (keyhi == RID_TMP) + emit_dm(as, ARMF_CC(ARMI_MOV, CC_NE), keyhi, keynumhi); + emit_d(as, ARMF_CC(ARMI_MOV, CC_EQ)|ARMI_K12|0, keyhi); + } + emit_dnm(as, ARMI_AND, tmp, tmp, RID_TMP); + emit_dnm(as, ARMI_SUB|ARMF_SH(ARMSH_ROR, 32-HASH_ROT3), tmp, tmp, tmp+1); + emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); + emit_dnm(as, ARMI_EOR|ARMF_SH(ARMSH_ROR, 32-((HASH_ROT2+HASH_ROT1)&31)), + tmp, tmp+1, tmp); + emit_lso(as, ARMI_LDR, RID_TMP, tab, (int32_t)offsetof(GCtab, hmask)); + emit_dnm(as, ARMI_SUB|ARMF_SH(ARMSH_ROR, 32-HASH_ROT1), tmp+1, tmp+1, tmp); + if (ra_hasreg(keynumhi)) { + emit_dnm(as, ARMI_EOR, tmp+1, tmp, key); + emit_dnm(as, ARMI_ORR|ARMI_S, RID_TMP, tmp, key); /* Test for +-0.0. */ + emit_dnm(as, ARMI_ADD, tmp, keynumhi, keynumhi); +#if !LJ_SOFTFP + emit_dnm(as, ARMI_VMOV_RR_D, key, keynumhi, + (ra_alloc1(as, refkey, RSET_FPR) & 15)); +#endif + } else { + emit_dnm(as, ARMI_EOR, tmp+1, tmp, key); + emit_opk(as, ARMI_ADD, tmp, key, (int32_t)HASH_BIAS, + rset_exclude(rset_exclude(RSET_GPR, tab), key)); + } + } + } +} + +static void asm_hrefk(ASMState *as, IRIns *ir) +{ + IRIns *kslot = IR(ir->op2); + IRIns *irkey = IR(kslot->op1); + int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); + int32_t kofs = ofs + (int32_t)offsetof(Node, key); + Reg dest = (ra_used(ir) || ofs > 4095) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; + Reg node = ra_alloc1(as, ir->op1, RSET_GPR); + Reg key = RID_NONE, type = RID_TMP, idx = node; + RegSet allow = rset_exclude(RSET_GPR, node); + lua_assert(ofs % sizeof(Node) == 0); + if (ofs > 4095) { + idx = dest; + rset_clear(allow, dest); + kofs = (int32_t)offsetof(Node, key); + } else if (ra_hasreg(dest)) { + emit_opk(as, ARMI_ADD, dest, node, ofs, allow); + } + asm_guardcc(as, CC_NE); + if (!irt_ispri(irkey->t)) { + RegSet even = (as->freeset & allow); + even = even & (even >> 1) & RSET_GPREVEN; + if (even) { + key = ra_scratch(as, even); + if (rset_test(as->freeset, key+1)) { + type = key+1; + ra_modified(as, type); + } + } else { + key = ra_scratch(as, allow); + } + rset_clear(allow, key); + } + rset_clear(allow, type); + if (irt_isnum(irkey->t)) { + emit_opk(as, ARMF_CC(ARMI_CMP, CC_EQ), 0, type, + (int32_t)ir_knum(irkey)->u32.hi, allow); + emit_opk(as, ARMI_CMP, 0, key, + (int32_t)ir_knum(irkey)->u32.lo, allow); + } else { + if (ra_hasreg(key)) + emit_opk(as, ARMF_CC(ARMI_CMP, CC_EQ), 0, key, irkey->i, allow); + emit_n(as, ARMI_CMN|ARMI_K12|-irt_toitype(irkey->t), type); + } + emit_lso(as, ARMI_LDR, type, idx, kofs+4); + if (ra_hasreg(key)) emit_lso(as, ARMI_LDR, key, idx, kofs); + if (ofs > 4095) + emit_opk(as, ARMI_ADD, dest, node, ofs, RSET_GPR); +} + +static void asm_newref(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; + IRRef args[3]; + if (ir->r == RID_SINK) + return; + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ir->op1; /* GCtab *t */ + args[2] = ASMREF_TMP1; /* cTValue *key */ + asm_setupresult(as, ir, ci); /* TValue * */ + asm_gencall(as, ci, args); + asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op2); +} + +static void asm_uref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; + emit_lsptr(as, ARMI_LDR, dest, v); + } else { + Reg uv = ra_scratch(as, RSET_GPR); + Reg func = ra_alloc1(as, ir->op1, RSET_GPR); + if (ir->o == IR_UREFC) { + asm_guardcc(as, CC_NE); + emit_n(as, ARMI_CMP|ARMI_K12|1, RID_TMP); + emit_opk(as, ARMI_ADD, dest, uv, + (int32_t)offsetof(GCupval, tv), RSET_GPR); + emit_lso(as, ARMI_LDRB, RID_TMP, uv, (int32_t)offsetof(GCupval, closed)); + } else { + emit_lso(as, ARMI_LDR, dest, uv, (int32_t)offsetof(GCupval, v)); + } + emit_lso(as, ARMI_LDR, uv, func, + (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); + } +} + +static void asm_fref(ASMState *as, IRIns *ir) +{ + UNUSED(as); UNUSED(ir); + lua_assert(!ra_used(ir)); +} + +static void asm_strref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + IRRef ref = ir->op2, refk = ir->op1; + Reg r; + if (irref_isk(ref)) { + IRRef tmp = refk; refk = ref; ref = tmp; + } else if (!irref_isk(refk)) { + uint32_t k, m = ARMI_K12|sizeof(GCstr); + Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); + IRIns *irr = IR(ir->op2); + if (ra_hasreg(irr->r)) { + ra_noweak(as, irr->r); + right = irr->r; + } else if (mayfuse(as, irr->op2) && + irr->o == IR_ADD && irref_isk(irr->op2) && + (k = emit_isk12(ARMI_ADD, + (int32_t)sizeof(GCstr) + IR(irr->op2)->i))) { + m = k; + right = ra_alloc1(as, irr->op1, rset_exclude(RSET_GPR, left)); + } else { + right = ra_allocref(as, ir->op2, rset_exclude(RSET_GPR, left)); + } + emit_dn(as, ARMI_ADD^m, dest, dest); + emit_dnm(as, ARMI_ADD, dest, left, right); + return; + } + r = ra_alloc1(as, ref, RSET_GPR); + emit_opk(as, ARMI_ADD, dest, r, + sizeof(GCstr) + IR(refk)->i, rset_exclude(RSET_GPR, r)); +} + +/* -- Loads and stores ---------------------------------------------------- */ + +static ARMIns asm_fxloadins(IRIns *ir) +{ + switch (irt_type(ir->t)) { + case IRT_I8: return ARMI_LDRSB; + case IRT_U8: return ARMI_LDRB; + case IRT_I16: return ARMI_LDRSH; + case IRT_U16: return ARMI_LDRH; + case IRT_NUM: lua_assert(!LJ_SOFTFP); return ARMI_VLDR_D; + case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VLDR_S; + default: return ARMI_LDR; + } +} + +static ARMIns asm_fxstoreins(IRIns *ir) +{ + switch (irt_type(ir->t)) { + case IRT_I8: case IRT_U8: return ARMI_STRB; + case IRT_I16: case IRT_U16: return ARMI_STRH; + case IRT_NUM: lua_assert(!LJ_SOFTFP); return ARMI_VSTR_D; + case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VSTR_S; + default: return ARMI_STR; + } +} + +static void asm_fload(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg idx = ra_alloc1(as, ir->op1, RSET_GPR); + ARMIns ai = asm_fxloadins(ir); + int32_t ofs; + if (ir->op2 == IRFL_TAB_ARRAY) { + ofs = asm_fuseabase(as, ir->op1); + if (ofs) { /* Turn the t->array load into an add for colocated arrays. */ + emit_dn(as, ARMI_ADD|ARMI_K12|ofs, dest, idx); + return; + } + } + ofs = field_ofs[ir->op2]; + if ((ai & 0x04000000)) + emit_lso(as, ai, dest, idx, ofs); + else + emit_lsox(as, ai, dest, idx, ofs); +} + +static void asm_fstore(ASMState *as, IRIns *ir) +{ + if (ir->r != RID_SINK) { + Reg src = ra_alloc1(as, ir->op2, RSET_GPR); + IRIns *irf = IR(ir->op1); + Reg idx = ra_alloc1(as, irf->op1, rset_exclude(RSET_GPR, src)); + int32_t ofs = field_ofs[irf->op2]; + ARMIns ai = asm_fxstoreins(ir); + if ((ai & 0x04000000)) + emit_lso(as, ai, src, idx, ofs); + else + emit_lsox(as, ai, src, idx, ofs); + } +} + +static void asm_xload(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, + (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR); + lua_assert(!(ir->op2 & IRXLOAD_UNALIGNED)); + asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR, 0); +} + +static void asm_xstore(ASMState *as, IRIns *ir, int32_t ofs) +{ + if (ir->r != RID_SINK) { + Reg src = ra_alloc1(as, ir->op2, + (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR); + asm_fusexref(as, asm_fxstoreins(ir), src, ir->op1, + rset_exclude(RSET_GPR, src), ofs); + } +} + +static void asm_ahuvload(ASMState *as, IRIns *ir) +{ + int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP); + IRType t = hiop ? IRT_NUM : irt_type(ir->t); + Reg dest = RID_NONE, type = RID_NONE, idx; + RegSet allow = RSET_GPR; + int32_t ofs = 0; + if (hiop && ra_used(ir+1)) { + type = ra_dest(as, ir+1, allow); + rset_clear(allow, type); + } + if (ra_used(ir)) { + lua_assert((LJ_SOFTFP ? 0 : irt_isnum(ir->t)) || + irt_isint(ir->t) || irt_isaddr(ir->t)); + dest = ra_dest(as, ir, (!LJ_SOFTFP && t == IRT_NUM) ? RSET_FPR : allow); + rset_clear(allow, dest); + } + idx = asm_fuseahuref(as, ir->op1, &ofs, allow, + (!LJ_SOFTFP && t == IRT_NUM) ? 1024 : 4096); + if (!hiop || type == RID_NONE) { + rset_clear(allow, idx); + if (ofs < 256 && ra_hasreg(dest) && (dest & 1) == 0 && + rset_test((as->freeset & allow), dest+1)) { + type = dest+1; + ra_modified(as, type); + } else { + type = RID_TMP; + } + } + asm_guardcc(as, t == IRT_NUM ? CC_HS : CC_NE); + emit_n(as, ARMI_CMN|ARMI_K12|-irt_toitype_(t), type); + if (ra_hasreg(dest)) { +#if !LJ_SOFTFP + if (t == IRT_NUM) + emit_vlso(as, ARMI_VLDR_D, dest, idx, ofs); + else +#endif + emit_lso(as, ARMI_LDR, dest, idx, ofs); + } + emit_lso(as, ARMI_LDR, type, idx, ofs+4); +} + +static void asm_ahustore(ASMState *as, IRIns *ir) +{ + if (ir->r != RID_SINK) { + RegSet allow = RSET_GPR; + Reg idx, src = RID_NONE, type = RID_NONE; + int32_t ofs = 0; +#if !LJ_SOFTFP + if (irt_isnum(ir->t)) { + src = ra_alloc1(as, ir->op2, RSET_FPR); + idx = asm_fuseahuref(as, ir->op1, &ofs, allow, 1024); + emit_vlso(as, ARMI_VSTR_D, src, idx, ofs); + } else +#endif + { + int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP); + if (!irt_ispri(ir->t)) { + src = ra_alloc1(as, ir->op2, allow); + rset_clear(allow, src); + } + if (hiop) + type = ra_alloc1(as, (ir+1)->op2, allow); + else + type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); + idx = asm_fuseahuref(as, ir->op1, &ofs, rset_exclude(allow, type), 4096); + if (ra_hasreg(src)) emit_lso(as, ARMI_STR, src, idx, ofs); + emit_lso(as, ARMI_STR, type, idx, ofs+4); + } + } +} + +static void asm_sload(ASMState *as, IRIns *ir) +{ + int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 4 : 0); + int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP); + IRType t = hiop ? IRT_NUM : irt_type(ir->t); + Reg dest = RID_NONE, type = RID_NONE, base; + RegSet allow = RSET_GPR; + lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ + lua_assert(irt_isguard(ir->t) || !(ir->op2 & IRSLOAD_TYPECHECK)); +#if LJ_SOFTFP + lua_assert(!(ir->op2 & IRSLOAD_CONVERT)); /* Handled by LJ_SOFTFP SPLIT. */ + if (hiop && ra_used(ir+1)) { + type = ra_dest(as, ir+1, allow); + rset_clear(allow, type); + } +#else + if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(ir->t) && t == IRT_INT) { + dest = ra_scratch(as, RSET_FPR); + asm_tointg(as, ir, dest); + t = IRT_NUM; /* Continue with a regular number type check. */ + } else +#endif + if (ra_used(ir)) { + Reg tmp = RID_NONE; + if ((ir->op2 & IRSLOAD_CONVERT)) + tmp = ra_scratch(as, t == IRT_INT ? RSET_FPR : RSET_GPR); + lua_assert((LJ_SOFTFP ? 0 : irt_isnum(ir->t)) || + irt_isint(ir->t) || irt_isaddr(ir->t)); + dest = ra_dest(as, ir, (!LJ_SOFTFP && t == IRT_NUM) ? RSET_FPR : allow); + rset_clear(allow, dest); + base = ra_alloc1(as, REF_BASE, allow); + if ((ir->op2 & IRSLOAD_CONVERT)) { + if (t == IRT_INT) { + emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); + emit_dm(as, ARMI_VCVT_S32_F64, (tmp & 15), (tmp & 15)); + t = IRT_NUM; /* Check for original type. */ + } else { + emit_dm(as, ARMI_VCVT_F64_S32, (dest & 15), (dest & 15)); + emit_dn(as, ARMI_VMOV_S_R, tmp, (dest & 15)); + t = IRT_INT; /* Check for original type. */ + } + dest = tmp; + } + goto dotypecheck; + } + base = ra_alloc1(as, REF_BASE, allow); +dotypecheck: + rset_clear(allow, base); + if ((ir->op2 & IRSLOAD_TYPECHECK)) { + if (ra_noreg(type)) { + if (ofs < 256 && ra_hasreg(dest) && (dest & 1) == 0 && + rset_test((as->freeset & allow), dest+1)) { + type = dest+1; + ra_modified(as, type); + } else { + type = RID_TMP; + } + } + asm_guardcc(as, t == IRT_NUM ? CC_HS : CC_NE); + emit_n(as, ARMI_CMN|ARMI_K12|-irt_toitype_(t), type); + } + if (ra_hasreg(dest)) { +#if !LJ_SOFTFP + if (t == IRT_NUM) { + if (ofs < 1024) { + emit_vlso(as, ARMI_VLDR_D, dest, base, ofs); + } else { + if (ra_hasreg(type)) emit_lso(as, ARMI_LDR, type, base, ofs+4); + emit_vlso(as, ARMI_VLDR_D, dest, RID_TMP, 0); + emit_opk(as, ARMI_ADD, RID_TMP, base, ofs, allow); + return; + } + } else +#endif + emit_lso(as, ARMI_LDR, dest, base, ofs); + } + if (ra_hasreg(type)) emit_lso(as, ARMI_LDR, type, base, ofs+4); +} + +/* -- Allocations --------------------------------------------------------- */ + +#if LJ_HASFFI +static void asm_cnew(ASMState *as, IRIns *ir) +{ + CTState *cts = ctype_ctsG(J2G(as->J)); + CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; + CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? + lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; + IRRef args[2]; + RegSet allow = (RSET_GPR & ~RSET_SCRATCH); + RegSet drop = RSET_SCRATCH; + lua_assert(sz != CTSIZE_INVALID); + + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ASMREF_TMP1; /* MSize size */ + as->gcsteps++; + + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + ra_evictset(as, drop); + if (ra_used(ir)) + ra_destreg(as, ir, RID_RET); /* GCcdata * */ + + /* Initialize immutable cdata object. */ + if (ir->o == IR_CNEWI) { + int32_t ofs = sizeof(GCcdata); + lua_assert(sz == 4 || sz == 8); + if (sz == 8) { + ofs += 4; ir++; + lua_assert(ir->o == IR_HIOP); + } + for (;;) { + Reg r = ra_alloc1(as, ir->op2, allow); + emit_lso(as, ARMI_STR, r, RID_RET, ofs); + rset_clear(allow, r); + if (ofs == sizeof(GCcdata)) break; + ofs -= 4; ir--; + } + } + /* Initialize gct and ctypeid. lj_mem_newgco() already sets marked. */ + { + uint32_t k = emit_isk12(ARMI_MOV, ctypeid); + Reg r = k ? RID_R1 : ra_allock(as, ctypeid, allow); + emit_lso(as, ARMI_STRB, RID_TMP, RID_RET, offsetof(GCcdata, gct)); + emit_lsox(as, ARMI_STRH, r, RID_RET, offsetof(GCcdata, ctypeid)); + emit_d(as, ARMI_MOV|ARMI_K12|~LJ_TCDATA, RID_TMP); + if (k) emit_d(as, ARMI_MOV^k, RID_R1); + } + asm_gencall(as, ci, args); + ra_allockreg(as, (int32_t)(sz+sizeof(GCcdata)), + ra_releasetmp(as, ASMREF_TMP1)); +} +#else +#define asm_cnew(as, ir) ((void)0) +#endif + +/* -- Write barriers ------------------------------------------------------ */ + +static void asm_tbar(ASMState *as, IRIns *ir) +{ + Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); + Reg link = ra_scratch(as, rset_exclude(RSET_GPR, tab)); + Reg gr = ra_allock(as, i32ptr(J2G(as->J)), + rset_exclude(rset_exclude(RSET_GPR, tab), link)); + Reg mark = RID_TMP; + MCLabel l_end = emit_label(as); + emit_lso(as, ARMI_STR, link, tab, (int32_t)offsetof(GCtab, gclist)); + emit_lso(as, ARMI_STRB, mark, tab, (int32_t)offsetof(GCtab, marked)); + emit_lso(as, ARMI_STR, tab, gr, + (int32_t)offsetof(global_State, gc.grayagain)); + emit_dn(as, ARMI_BIC|ARMI_K12|LJ_GC_BLACK, mark, mark); + emit_lso(as, ARMI_LDR, link, gr, + (int32_t)offsetof(global_State, gc.grayagain)); + emit_branch(as, ARMF_CC(ARMI_B, CC_EQ), l_end); + emit_n(as, ARMI_TST|ARMI_K12|LJ_GC_BLACK, mark); + emit_lso(as, ARMI_LDRB, mark, tab, (int32_t)offsetof(GCtab, marked)); +} + +static void asm_obar(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; + IRRef args[2]; + MCLabel l_end; + Reg obj, val, tmp; + /* No need for other object barriers (yet). */ + lua_assert(IR(ir->op1)->o == IR_UREFC); + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ir->op1; /* TValue *tv */ + asm_gencall(as, ci, args); + if ((l_end[-1] >> 28) == CC_AL) + l_end[-1] = ARMF_CC(l_end[-1], CC_NE); + else + emit_branch(as, ARMF_CC(ARMI_B, CC_EQ), l_end); + ra_allockreg(as, i32ptr(J2G(as->J)), ra_releasetmp(as, ASMREF_TMP1)); + obj = IR(ir->op1)->r; + tmp = ra_scratch(as, rset_exclude(RSET_GPR, obj)); + emit_n(as, ARMF_CC(ARMI_TST, CC_NE)|ARMI_K12|LJ_GC_BLACK, tmp); + emit_n(as, ARMI_TST|ARMI_K12|LJ_GC_WHITES, RID_TMP); + val = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, obj)); + emit_lso(as, ARMI_LDRB, tmp, obj, + (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); + emit_lso(as, ARMI_LDRB, RID_TMP, val, (int32_t)offsetof(GChead, marked)); +} + +/* -- Arithmetic and logic operations ------------------------------------- */ + +#if !LJ_SOFTFP +static void asm_fparith(ASMState *as, IRIns *ir, ARMIns ai) +{ + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = (left >> 8); left &= 255; + emit_dnm(as, ai, (dest & 15), (left & 15), (right & 15)); +} + +static void asm_fpunary(ASMState *as, IRIns *ir, ARMIns ai) +{ + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg left = ra_hintalloc(as, ir->op1, dest, RSET_FPR); + emit_dm(as, ai, (dest & 15), (left & 15)); +} + +static int asm_fpjoin_pow(ASMState *as, IRIns *ir) +{ + IRIns *irp = IR(ir->op1); + if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { + IRIns *irpp = IR(irp->op1); + if (irpp == ir-2 && irpp->o == IR_FPMATH && + irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_pow]; + IRRef args[2]; + args[0] = irpp->op1; + args[1] = irp->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); + return 1; + } + } + return 0; +} +#endif + +static int asm_swapops(ASMState *as, IRRef lref, IRRef rref) +{ + IRIns *ir; + if (irref_isk(rref)) + return 0; /* Don't swap constants to the left. */ + if (irref_isk(lref)) + return 1; /* But swap constants to the right. */ + ir = IR(rref); + if ((ir->o >= IR_BSHL && ir->o <= IR_BROR) || + (ir->o == IR_ADD && ir->op1 == ir->op2)) + return 0; /* Don't swap fusable operands to the left. */ + ir = IR(lref); + if ((ir->o >= IR_BSHL && ir->o <= IR_BROR) || + (ir->o == IR_ADD && ir->op1 == ir->op2)) + return 1; /* But swap fusable operands to the right. */ + return 0; /* Otherwise don't swap. */ +} + +static void asm_intop(ASMState *as, IRIns *ir, ARMIns ai) +{ + IRRef lref = ir->op1, rref = ir->op2; + Reg left, dest = ra_dest(as, ir, RSET_GPR); + uint32_t m; + if (asm_swapops(as, lref, rref)) { + IRRef tmp = lref; lref = rref; rref = tmp; + if ((ai & ~ARMI_S) == ARMI_SUB || (ai & ~ARMI_S) == ARMI_SBC) + ai ^= (ARMI_SUB^ARMI_RSB); + } + left = ra_hintalloc(as, lref, dest, RSET_GPR); + m = asm_fuseopm(as, ai, rref, rset_exclude(RSET_GPR, left)); + if (irt_isguard(ir->t)) { /* For IR_ADDOV etc. */ + asm_guardcc(as, CC_VS); + ai |= ARMI_S; + } + emit_dn(as, ai^m, dest, left); +} + +static void asm_intop_s(ASMState *as, IRIns *ir, ARMIns ai) +{ + if (as->flagmcp == as->mcp) { /* Drop cmp r, #0. */ + as->flagmcp = NULL; + as->mcp++; + ai |= ARMI_S; + } + asm_intop(as, ir, ai); +} + +static void asm_bitop(ASMState *as, IRIns *ir, ARMIns ai) +{ + if (as->flagmcp == as->mcp) { /* Try to drop cmp r, #0. */ + uint32_t cc = (as->mcp[1] >> 28); + as->flagmcp = NULL; + if (cc <= CC_NE) { + as->mcp++; + ai |= ARMI_S; + } else if (cc == CC_GE) { + *++as->mcp ^= ((CC_GE^CC_PL) << 28); + ai |= ARMI_S; + } else if (cc == CC_LT) { + *++as->mcp ^= ((CC_LT^CC_MI) << 28); + ai |= ARMI_S; + } /* else: other conds don't work with bit ops. */ + } + if (ir->op2 == 0) { + Reg dest = ra_dest(as, ir, RSET_GPR); + uint32_t m = asm_fuseopm(as, ai, ir->op1, RSET_GPR); + emit_d(as, ai^m, dest); + } else { + /* NYI: Turn BAND !k12 into uxtb, uxth or bfc or shl+shr. */ + asm_intop(as, ir, ai); + } +} + +static void asm_intneg(ASMState *as, IRIns *ir, ARMIns ai) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + emit_dn(as, ai|ARMI_K12|0, dest, left); +} + +/* NYI: use add/shift for MUL(OV) with constants. FOLD only does 2^k. */ +static void asm_intmul(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, rset_exclude(RSET_GPR, dest)); + Reg right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + Reg tmp = RID_NONE; + /* ARMv5 restriction: dest != left and dest_hi != left. */ + if (dest == left && left != right) { left = right; right = dest; } + if (irt_isguard(ir->t)) { /* IR_MULOV */ + if (!(as->flags & JIT_F_ARMV6) && dest == left) + tmp = left = ra_scratch(as, rset_exclude(RSET_GPR, left)); + asm_guardcc(as, CC_NE); + emit_nm(as, ARMI_TEQ|ARMF_SH(ARMSH_ASR, 31), RID_TMP, dest); + emit_dnm(as, ARMI_SMULL|ARMF_S(right), dest, RID_TMP, left); + } else { + if (!(as->flags & JIT_F_ARMV6) && dest == left) tmp = left = RID_TMP; + emit_nm(as, ARMI_MUL|ARMF_S(right), dest, left); + } + /* Only need this for the dest == left == right case. */ + if (ra_hasreg(tmp)) emit_dm(as, ARMI_MOV, tmp, right); +} + +static void asm_add(ASMState *as, IRIns *ir) +{ +#if !LJ_SOFTFP + if (irt_isnum(ir->t)) { + if (!asm_fusemadd(as, ir, ARMI_VMLA_D, ARMI_VMLA_D)) + asm_fparith(as, ir, ARMI_VADD_D); + return; + } +#endif + asm_intop_s(as, ir, ARMI_ADD); +} + +static void asm_sub(ASMState *as, IRIns *ir) +{ +#if !LJ_SOFTFP + if (irt_isnum(ir->t)) { + if (!asm_fusemadd(as, ir, ARMI_VNMLS_D, ARMI_VMLS_D)) + asm_fparith(as, ir, ARMI_VSUB_D); + return; + } +#endif + asm_intop_s(as, ir, ARMI_SUB); +} + +static void asm_mul(ASMState *as, IRIns *ir) +{ +#if !LJ_SOFTFP + if (irt_isnum(ir->t)) { + asm_fparith(as, ir, ARMI_VMUL_D); + return; + } +#endif + asm_intmul(as, ir); +} + +static void asm_neg(ASMState *as, IRIns *ir) +{ +#if !LJ_SOFTFP + if (irt_isnum(ir->t)) { + asm_fpunary(as, ir, ARMI_VNEG_D); + return; + } +#endif + asm_intneg(as, ir, ARMI_RSB); +} + +static void asm_callid(ASMState *as, IRIns *ir, IRCallID id) +{ + const CCallInfo *ci = &lj_ir_callinfo[id]; + IRRef args[2]; + args[0] = ir->op1; + args[1] = ir->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +#if !LJ_SOFTFP +static void asm_callround(ASMState *as, IRIns *ir, int id) +{ + /* The modified regs must match with the *.dasc implementation. */ + RegSet drop = RID2RSET(RID_R0)|RID2RSET(RID_R1)|RID2RSET(RID_R2)| + RID2RSET(RID_R3)|RID2RSET(RID_R12); + RegSet of; + Reg dest, src; + ra_evictset(as, drop); + dest = ra_dest(as, ir, RSET_FPR); + emit_dnm(as, ARMI_VMOV_D_RR, RID_RETLO, RID_RETHI, (dest & 15)); + emit_call(as, id == IRFPM_FLOOR ? (void *)lj_vm_floor_sf : + id == IRFPM_CEIL ? (void *)lj_vm_ceil_sf : + (void *)lj_vm_trunc_sf); + /* Workaround to protect argument GPRs from being used for remat. */ + of = as->freeset; + as->freeset &= ~RSET_RANGE(RID_R0, RID_R1+1); + as->cost[RID_R0] = as->cost[RID_R1] = REGCOST(~0u, ASMREF_L); + src = ra_alloc1(as, ir->op1, RSET_FPR); /* May alloc GPR to remat FPR. */ + as->freeset |= (of & RSET_RANGE(RID_R0, RID_R1+1)); + emit_dnm(as, ARMI_VMOV_RR_D, RID_R0, RID_R1, (src & 15)); +} +#endif + +static void asm_bitswap(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + if ((as->flags & JIT_F_ARMV6)) { + emit_dm(as, ARMI_REV, dest, left); + } else { + Reg tmp2 = dest; + if (tmp2 == left) + tmp2 = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, dest), left)); + emit_dnm(as, ARMI_EOR|ARMF_SH(ARMSH_LSR, 8), dest, tmp2, RID_TMP); + emit_dm(as, ARMI_MOV|ARMF_SH(ARMSH_ROR, 8), tmp2, left); + emit_dn(as, ARMI_BIC|ARMI_K12|256*8|255, RID_TMP, RID_TMP); + emit_dnm(as, ARMI_EOR|ARMF_SH(ARMSH_ROR, 16), RID_TMP, left, left); + } +} + +static void asm_bitshift(ASMState *as, IRIns *ir, ARMShift sh) +{ + if (irref_isk(ir->op2)) { /* Constant shifts. */ + /* NYI: Turn SHL+SHR or BAND+SHR into uxtb, uxth or ubfx. */ + /* NYI: Turn SHL+ASR into sxtb, sxth or sbfx. */ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + int32_t shift = (IR(ir->op2)->i & 31); + emit_dm(as, ARMI_MOV|ARMF_SH(sh, shift), dest, left); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + Reg right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_dm(as, ARMI_MOV|ARMF_RSH(sh, right), dest, left); + } +} + +static void asm_intmin_max(ASMState *as, IRIns *ir, int cc) +{ + uint32_t kcmp = 0, kmov = 0; + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + Reg right = 0; + if (irref_isk(ir->op2)) { + kcmp = emit_isk12(ARMI_CMP, IR(ir->op2)->i); + if (kcmp) kmov = emit_isk12(ARMI_MOV, IR(ir->op2)->i); + } + if (!kmov) { + kcmp = 0; + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + } + if (kmov || dest != right) { + emit_dm(as, ARMF_CC(ARMI_MOV, cc)^kmov, dest, right); + cc ^= 1; /* Must use opposite conditions for paired moves. */ + } else { + cc ^= (CC_LT^CC_GT); /* Otherwise may swap CC_LT <-> CC_GT. */ + } + if (dest != left) emit_dm(as, ARMF_CC(ARMI_MOV, cc), dest, left); + emit_nm(as, ARMI_CMP^kcmp, left, right); +} + +#if LJ_SOFTFP +static void asm_sfpmin_max(ASMState *as, IRIns *ir, int cc) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_softfp_cmp]; + RegSet drop = RSET_SCRATCH; + Reg r; + IRRef args[4]; + args[0] = ir->op1; args[1] = (ir+1)->op1; + args[2] = ir->op2; args[3] = (ir+1)->op2; + /* __aeabi_cdcmple preserves r0-r3. */ + if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); + if (ra_hasreg((ir+1)->r)) rset_clear(drop, (ir+1)->r); + if (!rset_test(as->freeset, RID_R2) && + regcost_ref(as->cost[RID_R2]) == args[2]) rset_clear(drop, RID_R2); + if (!rset_test(as->freeset, RID_R3) && + regcost_ref(as->cost[RID_R3]) == args[3]) rset_clear(drop, RID_R3); + ra_evictset(as, drop); + ra_destpair(as, ir); + emit_dm(as, ARMF_CC(ARMI_MOV, cc), RID_RETHI, RID_R3); + emit_dm(as, ARMF_CC(ARMI_MOV, cc), RID_RETLO, RID_R2); + emit_call(as, (void *)ci->func); + for (r = RID_R0; r <= RID_R3; r++) + ra_leftov(as, r, args[r-RID_R0]); +} +#else +static void asm_fpmin_max(ASMState *as, IRIns *ir, int cc) +{ + Reg dest = (ra_dest(as, ir, RSET_FPR) & 15); + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = ((left >> 8) & 15); left &= 15; + if (dest != left) emit_dm(as, ARMF_CC(ARMI_VMOV_D, cc^1), dest, left); + if (dest != right) emit_dm(as, ARMF_CC(ARMI_VMOV_D, cc), dest, right); + emit_d(as, ARMI_VMRS, 0); + emit_dm(as, ARMI_VCMP_D, left, right); +} +#endif + +static void asm_min_max(ASMState *as, IRIns *ir, int cc, int fcc) +{ +#if LJ_SOFTFP + UNUSED(fcc); +#else + if (irt_isnum(ir->t)) + asm_fpmin_max(as, ir, fcc); + else +#endif + asm_intmin_max(as, ir, cc); +} + +/* -- Comparisons --------------------------------------------------------- */ + +/* Map of comparisons to flags. ORDER IR. */ +static const uint8_t asm_compmap[IR_ABC+1] = { + /* op FP swp int cc FP cc */ + /* LT */ CC_GE + (CC_HS << 4), + /* GE x */ CC_LT + (CC_HI << 4), + /* LE */ CC_GT + (CC_HI << 4), + /* GT x */ CC_LE + (CC_HS << 4), + /* ULT x */ CC_HS + (CC_LS << 4), + /* UGE */ CC_LO + (CC_LO << 4), + /* ULE x */ CC_HI + (CC_LO << 4), + /* UGT */ CC_LS + (CC_LS << 4), + /* EQ */ CC_NE + (CC_NE << 4), + /* NE */ CC_EQ + (CC_EQ << 4), + /* ABC */ CC_LS + (CC_LS << 4) /* Same as UGT. */ +}; + +#if LJ_SOFTFP +/* FP comparisons. */ +static void asm_sfpcomp(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_softfp_cmp]; + RegSet drop = RSET_SCRATCH; + Reg r; + IRRef args[4]; + int swp = (((ir->o ^ (ir->o >> 2)) & ~(ir->o >> 3) & 1) << 1); + args[swp^0] = ir->op1; args[swp^1] = (ir+1)->op1; + args[swp^2] = ir->op2; args[swp^3] = (ir+1)->op2; + /* __aeabi_cdcmple preserves r0-r3. This helps to reduce spills. */ + for (r = RID_R0; r <= RID_R3; r++) + if (!rset_test(as->freeset, r) && + regcost_ref(as->cost[r]) == args[r-RID_R0]) rset_clear(drop, r); + ra_evictset(as, drop); + asm_guardcc(as, (asm_compmap[ir->o] >> 4)); + emit_call(as, (void *)ci->func); + for (r = RID_R0; r <= RID_R3; r++) + ra_leftov(as, r, args[r-RID_R0]); +} +#else +/* FP comparisons. */ +static void asm_fpcomp(ASMState *as, IRIns *ir) +{ + Reg left, right; + ARMIns ai; + int swp = ((ir->o ^ (ir->o >> 2)) & ~(ir->o >> 3) & 1); + if (!swp && irref_isk(ir->op2) && ir_knum(IR(ir->op2))->u64 == 0) { + left = (ra_alloc1(as, ir->op1, RSET_FPR) & 15); + right = 0; + ai = ARMI_VCMPZ_D; + } else { + left = ra_alloc2(as, ir, RSET_FPR); + if (swp) { + right = (left & 15); left = ((left >> 8) & 15); + } else { + right = ((left >> 8) & 15); left &= 15; + } + ai = ARMI_VCMP_D; + } + asm_guardcc(as, (asm_compmap[ir->o] >> 4)); + emit_d(as, ARMI_VMRS, 0); + emit_dm(as, ai, left, right); +} +#endif + +/* Integer comparisons. */ +static void asm_intcomp(ASMState *as, IRIns *ir) +{ + ARMCC cc = (asm_compmap[ir->o] & 15); + IRRef lref = ir->op1, rref = ir->op2; + Reg left; + uint32_t m; + int cmpprev0 = 0; + lua_assert(irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)); + if (asm_swapops(as, lref, rref)) { + Reg tmp = lref; lref = rref; rref = tmp; + if (cc >= CC_GE) cc ^= 7; /* LT <-> GT, LE <-> GE */ + else if (cc > CC_NE) cc ^= 11; /* LO <-> HI, LS <-> HS */ + } + if (irref_isk(rref) && IR(rref)->i == 0) { + IRIns *irl = IR(lref); + cmpprev0 = (irl+1 == ir); + /* Combine comp(BAND(left, right), 0) into tst left, right. */ + if (cmpprev0 && irl->o == IR_BAND && !ra_used(irl)) { + IRRef blref = irl->op1, brref = irl->op2; + uint32_t m2 = 0; + Reg bleft; + if (asm_swapops(as, blref, brref)) { + Reg tmp = blref; blref = brref; brref = tmp; + } + if (irref_isk(brref)) { + m2 = emit_isk12(ARMI_AND, IR(brref)->i); + if ((m2 & (ARMI_AND^ARMI_BIC))) + goto notst; /* Not beneficial if we miss a constant operand. */ + } + if (cc == CC_GE) cc = CC_PL; + else if (cc == CC_LT) cc = CC_MI; + else if (cc > CC_NE) goto notst; /* Other conds don't work with tst. */ + bleft = ra_alloc1(as, blref, RSET_GPR); + if (!m2) m2 = asm_fuseopm(as, 0, brref, rset_exclude(RSET_GPR, bleft)); + asm_guardcc(as, cc); + emit_n(as, ARMI_TST^m2, bleft); + return; + } + } +notst: + left = ra_alloc1(as, lref, RSET_GPR); + m = asm_fuseopm(as, ARMI_CMP, rref, rset_exclude(RSET_GPR, left)); + asm_guardcc(as, cc); + emit_n(as, ARMI_CMP^m, left); + /* Signed comparison with zero and referencing previous ins? */ + if (cmpprev0 && (cc <= CC_NE || cc >= CC_GE)) + as->flagmcp = as->mcp; /* Allow elimination of the compare. */ +} + +#if LJ_HASFFI +/* 64 bit integer comparisons. */ +static void asm_int64comp(ASMState *as, IRIns *ir) +{ + int signedcomp = (ir->o <= IR_GT); + ARMCC cclo, cchi; + Reg leftlo, lefthi; + uint32_t mlo, mhi; + RegSet allow = RSET_GPR, oldfree; + + /* Always use unsigned comparison for loword. */ + cclo = asm_compmap[ir->o + (signedcomp ? 4 : 0)] & 15; + leftlo = ra_alloc1(as, ir->op1, allow); + oldfree = as->freeset; + mlo = asm_fuseopm(as, ARMI_CMP, ir->op2, rset_clear(allow, leftlo)); + allow &= ~(oldfree & ~as->freeset); /* Update for allocs of asm_fuseopm. */ + + /* Use signed or unsigned comparison for hiword. */ + cchi = asm_compmap[ir->o] & 15; + lefthi = ra_alloc1(as, (ir+1)->op1, allow); + mhi = asm_fuseopm(as, ARMI_CMP, (ir+1)->op2, rset_clear(allow, lefthi)); + + /* All register allocations must be performed _before_ this point. */ + if (signedcomp) { + MCLabel l_around = emit_label(as); + asm_guardcc(as, cclo); + emit_n(as, ARMI_CMP^mlo, leftlo); + emit_branch(as, ARMF_CC(ARMI_B, CC_NE), l_around); + if (cchi == CC_GE || cchi == CC_LE) cchi ^= 6; /* GE -> GT, LE -> LT */ + asm_guardcc(as, cchi); + } else { + asm_guardcc(as, cclo); + emit_n(as, ARMF_CC(ARMI_CMP, CC_EQ)^mlo, leftlo); + } + emit_n(as, ARMI_CMP^mhi, lefthi); +} +#endif + +/* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ + +/* Hiword op of a split 64 bit op. Previous op must be the loword op. */ +static void asm_hiop(ASMState *as, IRIns *ir) +{ +#if LJ_HASFFI || LJ_SOFTFP + /* HIOP is marked as a store because it needs its own DCE logic. */ + int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ + if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; + if ((ir-1)->o <= IR_NE) { /* 64 bit integer or FP comparisons. ORDER IR. */ + as->curins--; /* Always skip the loword comparison. */ +#if LJ_SOFTFP + if (!irt_isint(ir->t)) { + asm_sfpcomp(as, ir-1); + return; + } +#endif +#if LJ_HASFFI + asm_int64comp(as, ir-1); +#endif + return; +#if LJ_SOFTFP + } else if ((ir-1)->o == IR_MIN || (ir-1)->o == IR_MAX) { + as->curins--; /* Always skip the loword min/max. */ + if (uselo || usehi) + asm_sfpmin_max(as, ir-1, (ir-1)->o == IR_MIN ? CC_HI : CC_LO); + return; +#elif LJ_HASFFI + } else if ((ir-1)->o == IR_CONV) { + as->curins--; /* Always skip the CONV. */ + if (usehi || uselo) + asm_conv64(as, ir); + return; +#endif + } else if ((ir-1)->o == IR_XSTORE) { + if ((ir-1)->r != RID_SINK) + asm_xstore(as, ir, 4); + return; + } + if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ + switch ((ir-1)->o) { +#if LJ_HASFFI + case IR_ADD: + as->curins--; + asm_intop(as, ir, ARMI_ADC); + asm_intop(as, ir-1, ARMI_ADD|ARMI_S); + break; + case IR_SUB: + as->curins--; + asm_intop(as, ir, ARMI_SBC); + asm_intop(as, ir-1, ARMI_SUB|ARMI_S); + break; + case IR_NEG: + as->curins--; + asm_intneg(as, ir, ARMI_RSC); + asm_intneg(as, ir-1, ARMI_RSB|ARMI_S); + break; +#endif +#if LJ_SOFTFP + case IR_SLOAD: case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + case IR_STRTO: + if (!uselo) + ra_allocref(as, ir->op1, RSET_GPR); /* Mark lo op as used. */ + break; +#endif + case IR_CALLN: + case IR_CALLS: + case IR_CALLXS: + if (!uselo) + ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ + break; +#if LJ_SOFTFP + case IR_ASTORE: case IR_HSTORE: case IR_USTORE: case IR_TOSTR: +#endif + case IR_CNEWI: + /* Nothing to do here. Handled by lo op itself. */ + break; + default: lua_assert(0); break; + } +#else + UNUSED(as); UNUSED(ir); lua_assert(0); +#endif +} + +/* -- Stack handling ------------------------------------------------------ */ + +/* Check Lua stack size for overflow. Use exit handler as fallback. */ +static void asm_stack_check(ASMState *as, BCReg topslot, + IRIns *irp, RegSet allow, ExitNo exitno) +{ + Reg pbase; + uint32_t k; + if (irp) { + if (!ra_hasspill(irp->s)) { + pbase = irp->r; + lua_assert(ra_hasreg(pbase)); + } else if (allow) { + pbase = rset_pickbot(allow); + } else { + pbase = RID_RET; + emit_lso(as, ARMI_LDR, RID_RET, RID_SP, 0); /* Restore temp. register. */ + } + } else { + pbase = RID_BASE; + } + emit_branch(as, ARMF_CC(ARMI_BL, CC_LS), exitstub_addr(as->J, exitno)); + k = emit_isk12(0, (int32_t)(8*topslot)); + lua_assert(k); + emit_n(as, ARMI_CMP^k, RID_TMP); + emit_dnm(as, ARMI_SUB, RID_TMP, RID_TMP, pbase); + emit_lso(as, ARMI_LDR, RID_TMP, RID_TMP, + (int32_t)offsetof(lua_State, maxstack)); + if (irp) { /* Must not spill arbitrary registers in head of side trace. */ + int32_t i = i32ptr(&J2G(as->J)->jit_L); + if (ra_hasspill(irp->s)) + emit_lso(as, ARMI_LDR, pbase, RID_SP, sps_scale(irp->s)); + emit_lso(as, ARMI_LDR, RID_TMP, RID_TMP, (i & 4095)); + if (ra_hasspill(irp->s) && !allow) + emit_lso(as, ARMI_STR, RID_RET, RID_SP, 0); /* Save temp. register. */ + emit_loadi(as, RID_TMP, (i & ~4095)); + } else { + emit_getgl(as, RID_TMP, jit_L); + } +} + +/* Restore Lua stack from on-trace state. */ +static void asm_stack_restore(ASMState *as, SnapShot *snap) +{ + SnapEntry *map = &as->T->snapmap[snap->mapofs]; + SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; + MSize n, nent = snap->nent; + /* Store the value of all modified slots to the Lua stack. */ + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + BCReg s = snap_slot(sn); + int32_t ofs = 8*((int32_t)s-1); + IRRef ref = snap_ref(sn); + IRIns *ir = IR(ref); + if ((sn & SNAP_NORESTORE)) + continue; + if (irt_isnum(ir->t)) { +#if LJ_SOFTFP + RegSet odd = rset_exclude(RSET_GPRODD, RID_BASE); + Reg tmp; + lua_assert(irref_isk(ref)); /* LJ_SOFTFP: must be a number constant. */ + tmp = ra_allock(as, (int32_t)ir_knum(ir)->u32.lo, + rset_exclude(RSET_GPREVEN, RID_BASE)); + emit_lso(as, ARMI_STR, tmp, RID_BASE, ofs); + if (rset_test(as->freeset, tmp+1)) odd = RID2RSET(tmp+1); + tmp = ra_allock(as, (int32_t)ir_knum(ir)->u32.hi, odd); + emit_lso(as, ARMI_STR, tmp, RID_BASE, ofs+4); +#else + Reg src = ra_alloc1(as, ref, RSET_FPR); + emit_vlso(as, ARMI_VSTR_D, src, RID_BASE, ofs); +#endif + } else { + RegSet odd = rset_exclude(RSET_GPRODD, RID_BASE); + Reg type; + lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || irt_isinteger(ir->t)); + if (!irt_ispri(ir->t)) { + Reg src = ra_alloc1(as, ref, rset_exclude(RSET_GPREVEN, RID_BASE)); + emit_lso(as, ARMI_STR, src, RID_BASE, ofs); + if (rset_test(as->freeset, src+1)) odd = RID2RSET(src+1); + } + if ((sn & (SNAP_CONT|SNAP_FRAME))) { + if (s == 0) continue; /* Do not overwrite link to previous frame. */ + type = ra_allock(as, (int32_t)(*flinks--), odd); +#if LJ_SOFTFP + } else if ((sn & SNAP_SOFTFPNUM)) { + type = ra_alloc1(as, ref+1, rset_exclude(RSET_GPRODD, RID_BASE)); +#endif + } else { + type = ra_allock(as, (int32_t)irt_toitype(ir->t), odd); + } + emit_lso(as, ARMI_STR, type, RID_BASE, ofs+4); + } + checkmclim(as); + } + lua_assert(map + nent == flinks); +} + +/* -- GC handling --------------------------------------------------------- */ + +/* Check GC threshold and do one or more GC steps. */ +static void asm_gc_check(ASMState *as) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; + IRRef args[2]; + MCLabel l_end; + Reg tmp1, tmp2; + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ + asm_guardcc(as, CC_NE); /* Assumes asm_snap_prep() already done. */ + emit_n(as, ARMI_CMP|ARMI_K12|0, RID_RET); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ASMREF_TMP2; /* MSize steps */ + asm_gencall(as, ci, args); + tmp1 = ra_releasetmp(as, ASMREF_TMP1); + tmp2 = ra_releasetmp(as, ASMREF_TMP2); + emit_loadi(as, tmp2, as->gcsteps); + /* Jump around GC step if GC total < GC threshold. */ + emit_branch(as, ARMF_CC(ARMI_B, CC_LS), l_end); + emit_nm(as, ARMI_CMP, RID_TMP, tmp2); + emit_lso(as, ARMI_LDR, tmp2, tmp1, + (int32_t)offsetof(global_State, gc.threshold)); + emit_lso(as, ARMI_LDR, RID_TMP, tmp1, + (int32_t)offsetof(global_State, gc.total)); + ra_allockreg(as, i32ptr(J2G(as->J)), tmp1); + as->gcsteps = 0; + checkmclim(as); +} + +/* -- Loop handling ------------------------------------------------------- */ + +/* Fixup the loop branch. */ +static void asm_loop_fixup(ASMState *as) +{ + MCode *p = as->mctop; + MCode *target = as->mcp; + if (as->loopinv) { /* Inverted loop branch? */ + /* asm_guardcc already inverted the bcc and patched the final bl. */ + p[-2] |= ((uint32_t)(target-p) & 0x00ffffffu); + } else { + p[-1] = ARMI_B | ((uint32_t)((target-p)-1) & 0x00ffffffu); + } +} + +/* -- Head of trace ------------------------------------------------------- */ + +/* Reload L register from g->jit_L. */ +static void asm_head_lreg(ASMState *as) +{ + IRIns *ir = IR(ASMREF_L); + if (ra_used(ir)) { + Reg r = ra_dest(as, ir, RSET_GPR); + emit_getgl(as, r, jit_L); + ra_evictk(as); + } +} + +/* Coalesce BASE register for a root trace. */ +static void asm_head_root_base(ASMState *as) +{ + IRIns *ir; + asm_head_lreg(as); + ir = IR(REF_BASE); + if (ra_hasreg(ir->r) && (rset_test(as->modset, ir->r) || irt_ismarked(ir->t))) + ra_spill(as, ir); + ra_destreg(as, ir, RID_BASE); +} + +/* Coalesce BASE register for a side trace. */ +static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) +{ + IRIns *ir; + asm_head_lreg(as); + ir = IR(REF_BASE); + if (ra_hasreg(ir->r) && (rset_test(as->modset, ir->r) || irt_ismarked(ir->t))) + ra_spill(as, ir); + if (ra_hasspill(irp->s)) { + rset_clear(allow, ra_dest(as, ir, allow)); + } else { + Reg r = irp->r; + lua_assert(ra_hasreg(r)); + rset_clear(allow, r); + if (r != ir->r && !rset_test(as->freeset, r)) + ra_restore(as, regcost_ref(as->cost[r])); + ra_destreg(as, ir, r); + } + return allow; +} + +/* -- Tail of trace ------------------------------------------------------- */ + +/* Fixup the tail code. */ +static void asm_tail_fixup(ASMState *as, TraceNo lnk) +{ + MCode *p = as->mctop; + MCode *target; + int32_t spadj = as->T->spadjust; + if (spadj == 0) { + as->mctop = --p; + } else { + /* Patch stack adjustment. */ + uint32_t k = emit_isk12(ARMI_ADD, spadj); + lua_assert(k); + p[-2] = (ARMI_ADD^k) | ARMF_D(RID_SP) | ARMF_N(RID_SP); + } + /* Patch exit branch. */ + target = lnk ? traceref(as->J, lnk)->mcode : (MCode *)lj_vm_exit_interp; + p[-1] = ARMI_B|(((target-p)-1)&0x00ffffffu); +} + +/* Prepare tail of code. */ +static void asm_tail_prep(ASMState *as) +{ + MCode *p = as->mctop - 1; /* Leave room for exit branch. */ + if (as->loopref) { + as->invmcp = as->mcp = p; + } else { + as->mcp = p-1; /* Leave room for stack pointer adjustment. */ + as->invmcp = NULL; + } + *p = 0; /* Prevent load/store merging. */ +} + +/* -- Instruction dispatch ------------------------------------------------ */ + +/* Assemble a single instruction. */ +static void asm_ir(ASMState *as, IRIns *ir) +{ + switch ((IROp)ir->o) { + /* Miscellaneous ops. */ + case IR_LOOP: asm_loop(as); break; + case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; + case IR_USE: + ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; + case IR_PHI: asm_phi(as, ir); break; + case IR_HIOP: asm_hiop(as, ir); break; + case IR_GCSTEP: asm_gcstep(as, ir); break; + + /* Guarded assertions. */ + case IR_EQ: case IR_NE: + if ((ir-1)->o == IR_HREF && ir->op1 == as->curins-1) { + as->curins--; + asm_href(as, ir-1, (IROp)ir->o); + break; + } + /* fallthrough */ + case IR_LT: case IR_GE: case IR_LE: case IR_GT: + case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: + case IR_ABC: +#if !LJ_SOFTFP + if (irt_isnum(ir->t)) { asm_fpcomp(as, ir); break; } +#endif + asm_intcomp(as, ir); + break; + + case IR_RETF: asm_retf(as, ir); break; + + /* Bit ops. */ + case IR_BNOT: asm_bitop(as, ir, ARMI_MVN); break; + case IR_BSWAP: asm_bitswap(as, ir); break; + + case IR_BAND: asm_bitop(as, ir, ARMI_AND); break; + case IR_BOR: asm_bitop(as, ir, ARMI_ORR); break; + case IR_BXOR: asm_bitop(as, ir, ARMI_EOR); break; + + case IR_BSHL: asm_bitshift(as, ir, ARMSH_LSL); break; + case IR_BSHR: asm_bitshift(as, ir, ARMSH_LSR); break; + case IR_BSAR: asm_bitshift(as, ir, ARMSH_ASR); break; + case IR_BROR: asm_bitshift(as, ir, ARMSH_ROR); break; + case IR_BROL: lua_assert(0); break; + + /* Arithmetic ops. */ + case IR_ADD: case IR_ADDOV: asm_add(as, ir); break; + case IR_SUB: case IR_SUBOV: asm_sub(as, ir); break; + case IR_MUL: case IR_MULOV: asm_mul(as, ir); break; + case IR_MOD: asm_callid(as, ir, IRCALL_lj_vm_modi); break; + case IR_NEG: asm_neg(as, ir); break; + +#if LJ_SOFTFP + case IR_DIV: case IR_POW: case IR_ABS: + case IR_ATAN2: case IR_LDEXP: case IR_FPMATH: case IR_TOBIT: + lua_assert(0); /* Unused for LJ_SOFTFP. */ + break; +#else + case IR_DIV: asm_fparith(as, ir, ARMI_VDIV_D); break; + case IR_POW: asm_callid(as, ir, IRCALL_lj_vm_powi); break; + case IR_ABS: asm_fpunary(as, ir, ARMI_VABS_D); break; + case IR_ATAN2: asm_callid(as, ir, IRCALL_atan2); break; + case IR_LDEXP: asm_callid(as, ir, IRCALL_ldexp); break; + case IR_FPMATH: + if (ir->op2 == IRFPM_EXP2 && asm_fpjoin_pow(as, ir)) + break; + if (ir->op2 <= IRFPM_TRUNC) + asm_callround(as, ir, ir->op2); + else if (ir->op2 == IRFPM_SQRT) + asm_fpunary(as, ir, ARMI_VSQRT_D); + else + asm_callid(as, ir, IRCALL_lj_vm_floor + ir->op2); + break; + case IR_TOBIT: asm_tobit(as, ir); break; +#endif + + case IR_MIN: asm_min_max(as, ir, CC_GT, CC_HI); break; + case IR_MAX: asm_min_max(as, ir, CC_LT, CC_LO); break; + + /* Memory references. */ + case IR_AREF: asm_aref(as, ir); break; + case IR_HREF: asm_href(as, ir, 0); break; + case IR_HREFK: asm_hrefk(as, ir); break; + case IR_NEWREF: asm_newref(as, ir); break; + case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; + case IR_FREF: asm_fref(as, ir); break; + case IR_STRREF: asm_strref(as, ir); break; + + /* Loads and stores. */ + case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + asm_ahuvload(as, ir); + break; + case IR_FLOAD: asm_fload(as, ir); break; + case IR_XLOAD: asm_xload(as, ir); break; + case IR_SLOAD: asm_sload(as, ir); break; + + case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; + case IR_FSTORE: asm_fstore(as, ir); break; + case IR_XSTORE: asm_xstore(as, ir, 0); break; + + /* Allocations. */ + case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; + case IR_TNEW: asm_tnew(as, ir); break; + case IR_TDUP: asm_tdup(as, ir); break; + case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; + + /* Write barriers. */ + case IR_TBAR: asm_tbar(as, ir); break; + case IR_OBAR: asm_obar(as, ir); break; + + /* Type conversions. */ + case IR_CONV: asm_conv(as, ir); break; + case IR_TOSTR: asm_tostr(as, ir); break; + case IR_STRTO: asm_strto(as, ir); break; + + /* Calls. */ + case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; + case IR_CALLXS: asm_callx(as, ir); break; + case IR_CARG: break; + + default: + setintV(&as->J->errinfo, ir->o); + lj_trace_err_info(as->J, LJ_TRERR_NYIIR); + break; + } +} + +/* -- Trace setup --------------------------------------------------------- */ + +/* Ensure there are enough stack slots for call arguments. */ +static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + IRRef args[CCI_NARGS_MAX*2]; + uint32_t i, nargs = (int)CCI_NARGS(ci); + int nslots = 0, ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR, fprodd = 0; + asm_collectargs(as, ir, ci, args); + for (i = 0; i < nargs; i++) { + if (!LJ_SOFTFP && args[i] && irt_isfp(IR(args[i])->t)) { + if (!LJ_ABI_SOFTFP && !(ci->flags & CCI_VARARG)) { + if (irt_isnum(IR(args[i])->t)) { + if (nfpr > 0) nfpr--; + else fprodd = 0, nslots = (nslots + 3) & ~1; + } else { + if (fprodd) fprodd--; + else if (nfpr > 0) fprodd = 1, nfpr--; + else nslots++; + } + } else if (irt_isnum(IR(args[i])->t)) { + ngpr &= ~1; + if (ngpr > 0) ngpr -= 2; else nslots += 2; + } else { + if (ngpr > 0) ngpr--; else nslots++; + } + } else { + if (ngpr > 0) ngpr--; else nslots++; + } + } + if (nslots > as->evenspill) /* Leave room for args in stack slots. */ + as->evenspill = nslots; + return REGSP_HINT(RID_RET); +} + +static void asm_setup_target(ASMState *as) +{ + /* May need extra exit for asm_stack_check on side traces. */ + asm_exitstub_setup(as, as->T->nsnap + (as->parent ? 1 : 0)); +} + +/* -- Trace patching ------------------------------------------------------ */ + +/* Patch exit jumps of existing machine code to a new target. */ +void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) +{ + MCode *p = T->mcode; + MCode *pe = (MCode *)((char *)p + T->szmcode); + MCode *cstart = NULL, *cend = p; + MCode *mcarea = lj_mcode_patch(J, p, 0); + MCode *px = exitstub_addr(J, exitno) - 2; + for (; p < pe; p++) { + /* Look for bl_cc exitstub, replace with b_cc target. */ + uint32_t ins = *p; + if ((ins & 0x0f000000u) == 0x0b000000u && ins < 0xf0000000u && + ((ins ^ (px-p)) & 0x00ffffffu) == 0) { + *p = (ins & 0xfe000000u) | (((target-p)-2) & 0x00ffffffu); + cend = p+1; + if (!cstart) cstart = p; + } + } + lua_assert(cstart != NULL); + lj_mcode_sync(cstart, cend); + lj_mcode_patch(J, mcarea, 1); +} + + +``` + +`include/luajit-2.0.5/src/lj_asm_mips.h`: + +```h +/* +** MIPS IR assembler (SSA IR -> machine code). +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Register allocator extensions --------------------------------------- */ + +/* Allocate a register with a hint. */ +static Reg ra_hintalloc(ASMState *as, IRRef ref, Reg hint, RegSet allow) +{ + Reg r = IR(ref)->r; + if (ra_noreg(r)) { + if (!ra_hashint(r) && !iscrossref(as, ref)) + ra_sethint(IR(ref)->r, hint); /* Propagate register hint. */ + r = ra_allocref(as, ref, allow); + } + ra_noweak(as, r); + return r; +} + +/* Allocate a register or RID_ZERO. */ +static Reg ra_alloc1z(ASMState *as, IRRef ref, RegSet allow) +{ + Reg r = IR(ref)->r; + if (ra_noreg(r)) { + if (!(allow & RSET_FPR) && irref_isk(ref) && IR(ref)->i == 0) + return RID_ZERO; + r = ra_allocref(as, ref, allow); + } else { + ra_noweak(as, r); + } + return r; +} + +/* Allocate two source registers for three-operand instructions. */ +static Reg ra_alloc2(ASMState *as, IRIns *ir, RegSet allow) +{ + IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); + Reg left = irl->r, right = irr->r; + if (ra_hasreg(left)) { + ra_noweak(as, left); + if (ra_noreg(right)) + right = ra_alloc1z(as, ir->op2, rset_exclude(allow, left)); + else + ra_noweak(as, right); + } else if (ra_hasreg(right)) { + ra_noweak(as, right); + left = ra_alloc1z(as, ir->op1, rset_exclude(allow, right)); + } else if (ra_hashint(right)) { + right = ra_alloc1z(as, ir->op2, allow); + left = ra_alloc1z(as, ir->op1, rset_exclude(allow, right)); + } else { + left = ra_alloc1z(as, ir->op1, allow); + right = ra_alloc1z(as, ir->op2, rset_exclude(allow, left)); + } + return left | (right << 8); +} + +/* -- Guard handling ------------------------------------------------------ */ + +/* Need some spare long-range jump slots, for out-of-range branches. */ +#define MIPS_SPAREJUMP 4 + +/* Setup spare long-range jump slots per mcarea. */ +static void asm_sparejump_setup(ASMState *as) +{ + MCode *mxp = as->mcbot; + /* Assumes sizeof(MCLink) == 8. */ + if (((uintptr_t)mxp & (LJ_PAGESIZE-1)) == 8) { + lua_assert(MIPSI_NOP == 0); + memset(mxp+2, 0, MIPS_SPAREJUMP*8); + mxp += MIPS_SPAREJUMP*2; + lua_assert(mxp < as->mctop); + lj_mcode_sync(as->mcbot, mxp); + lj_mcode_commitbot(as->J, mxp); + as->mcbot = mxp; + as->mclim = as->mcbot + MCLIM_REDZONE; + } +} + +/* Setup exit stub after the end of each trace. */ +static void asm_exitstub_setup(ASMState *as) +{ + MCode *mxp = as->mctop; + /* sw TMP, 0(sp); j ->vm_exit_handler; li TMP, traceno */ + *--mxp = MIPSI_LI|MIPSF_T(RID_TMP)|as->T->traceno; + *--mxp = MIPSI_J|((((uintptr_t)(void *)lj_vm_exit_handler)>>2)&0x03ffffffu); + lua_assert(((uintptr_t)mxp ^ (uintptr_t)(void *)lj_vm_exit_handler)>>28 == 0); + *--mxp = MIPSI_SW|MIPSF_T(RID_TMP)|MIPSF_S(RID_SP)|0; + as->mctop = mxp; +} + +/* Keep this in-sync with exitstub_trace_addr(). */ +#define asm_exitstub_addr(as) ((as)->mctop) + +/* Emit conditional branch to exit for guard. */ +static void asm_guard(ASMState *as, MIPSIns mi, Reg rs, Reg rt) +{ + MCode *target = asm_exitstub_addr(as); + MCode *p = as->mcp; + if (LJ_UNLIKELY(p == as->invmcp)) { + as->invmcp = NULL; + as->loopinv = 1; + as->mcp = p+1; + mi = mi ^ ((mi>>28) == 1 ? 0x04000000u : 0x00010000u); /* Invert cond. */ + target = p; /* Patch target later in asm_loop_fixup. */ + } + emit_ti(as, MIPSI_LI, RID_TMP, as->snapno); + emit_branch(as, mi, rs, rt, target); +} + +/* -- Operand fusion ------------------------------------------------------ */ + +/* Limit linear search to this distance. Avoids O(n^2) behavior. */ +#define CONFLICT_SEARCH_LIM 31 + +/* Check if there's no conflicting instruction between curins and ref. */ +static int noconflict(ASMState *as, IRRef ref, IROp conflict) +{ + IRIns *ir = as->ir; + IRRef i = as->curins; + if (i > ref + CONFLICT_SEARCH_LIM) + return 0; /* Give up, ref is too far away. */ + while (--i > ref) + if (ir[i].o == conflict) + return 0; /* Conflict found. */ + return 1; /* Ok, no conflict. */ +} + +/* Fuse the array base of colocated arrays. */ +static int32_t asm_fuseabase(ASMState *as, IRRef ref) +{ + IRIns *ir = IR(ref); + if (ir->o == IR_TNEW && ir->op1 <= LJ_MAX_COLOSIZE && + !neverfuse(as) && noconflict(as, ref, IR_NEWREF)) + return (int32_t)sizeof(GCtab); + return 0; +} + +/* Fuse array/hash/upvalue reference into register+offset operand. */ +static Reg asm_fuseahuref(ASMState *as, IRRef ref, int32_t *ofsp, RegSet allow) +{ + IRIns *ir = IR(ref); + if (ra_noreg(ir->r)) { + if (ir->o == IR_AREF) { + if (mayfuse(as, ref)) { + if (irref_isk(ir->op2)) { + IRRef tab = IR(ir->op1)->op1; + int32_t ofs = asm_fuseabase(as, tab); + IRRef refa = ofs ? tab : ir->op1; + ofs += 8*IR(ir->op2)->i; + if (checki16(ofs)) { + *ofsp = ofs; + return ra_alloc1(as, refa, allow); + } + } + } + } else if (ir->o == IR_HREFK) { + if (mayfuse(as, ref)) { + int32_t ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); + if (checki16(ofs)) { + *ofsp = ofs; + return ra_alloc1(as, ir->op1, allow); + } + } + } else if (ir->o == IR_UREFC) { + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + int32_t ofs = i32ptr(&gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.tv); + int32_t jgl = (intptr_t)J2G(as->J); + if ((uint32_t)(ofs-jgl) < 65536) { + *ofsp = ofs-jgl-32768; + return RID_JGL; + } else { + *ofsp = (int16_t)ofs; + return ra_allock(as, ofs-(int16_t)ofs, allow); + } + } + } + } + *ofsp = 0; + return ra_alloc1(as, ref, allow); +} + +/* Fuse XLOAD/XSTORE reference into load/store operand. */ +static void asm_fusexref(ASMState *as, MIPSIns mi, Reg rt, IRRef ref, + RegSet allow, int32_t ofs) +{ + IRIns *ir = IR(ref); + Reg base; + if (ra_noreg(ir->r) && canfuse(as, ir)) { + if (ir->o == IR_ADD) { + int32_t ofs2; + if (irref_isk(ir->op2) && (ofs2 = ofs + IR(ir->op2)->i, checki16(ofs2))) { + ref = ir->op1; + ofs = ofs2; + } + } else if (ir->o == IR_STRREF) { + int32_t ofs2 = 65536; + lua_assert(ofs == 0); + ofs = (int32_t)sizeof(GCstr); + if (irref_isk(ir->op2)) { + ofs2 = ofs + IR(ir->op2)->i; + ref = ir->op1; + } else if (irref_isk(ir->op1)) { + ofs2 = ofs + IR(ir->op1)->i; + ref = ir->op2; + } + if (!checki16(ofs2)) { + /* NYI: Fuse ADD with constant. */ + Reg right, left = ra_alloc2(as, ir, allow); + right = (left >> 8); left &= 255; + emit_hsi(as, mi, rt, RID_TMP, ofs); + emit_dst(as, MIPSI_ADDU, RID_TMP, left, right); + return; + } + ofs = ofs2; + } + } + base = ra_alloc1(as, ref, allow); + emit_hsi(as, mi, rt, base, ofs); +} + +/* -- Calls --------------------------------------------------------------- */ + +/* Generate a call to a C function. */ +static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) +{ + uint32_t n, nargs = CCI_NARGS(ci); + int32_t ofs = 16; + Reg gpr, fpr = REGARG_FIRSTFPR; + if ((void *)ci->func) + emit_call(as, (void *)ci->func); + for (gpr = REGARG_FIRSTGPR; gpr <= REGARG_LASTGPR; gpr++) + as->cost[gpr] = REGCOST(~0u, ASMREF_L); + gpr = REGARG_FIRSTGPR; + for (n = 0; n < nargs; n++) { /* Setup args. */ + IRRef ref = args[n]; + if (ref) { + IRIns *ir = IR(ref); + if (irt_isfp(ir->t) && fpr <= REGARG_LASTFPR && + !(ci->flags & CCI_VARARG)) { + lua_assert(rset_test(as->freeset, fpr)); /* Already evicted. */ + ra_leftov(as, fpr, ref); + fpr += 2; + gpr += irt_isnum(ir->t) ? 2 : 1; + } else { + fpr = REGARG_LASTFPR+1; + if (irt_isnum(ir->t)) gpr = (gpr+1) & ~1; + if (gpr <= REGARG_LASTGPR) { + lua_assert(rset_test(as->freeset, gpr)); /* Already evicted. */ + if (irt_isfp(ir->t)) { + RegSet of = as->freeset; + Reg r; + /* Workaround to protect argument GPRs from being used for remat. */ + as->freeset &= ~RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1); + r = ra_alloc1(as, ref, RSET_FPR); + as->freeset |= (of & RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1)); + if (irt_isnum(ir->t)) { + emit_tg(as, MIPSI_MFC1, gpr+(LJ_BE?0:1), r+1); + emit_tg(as, MIPSI_MFC1, gpr+(LJ_BE?1:0), r); + lua_assert(rset_test(as->freeset, gpr+1)); /* Already evicted. */ + gpr += 2; + } else if (irt_isfloat(ir->t)) { + emit_tg(as, MIPSI_MFC1, gpr, r); + gpr++; + } + } else { + ra_leftov(as, gpr, ref); + gpr++; + } + } else { + Reg r = ra_alloc1z(as, ref, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); + if (irt_isnum(ir->t)) ofs = (ofs + 4) & ~4; + emit_spstore(as, ir, r, ofs); + ofs += irt_isnum(ir->t) ? 8 : 4; + } + } + } else { + fpr = REGARG_LASTFPR+1; + if (gpr <= REGARG_LASTGPR) + gpr++; + else + ofs += 4; + } + checkmclim(as); + } +} + +/* Setup result reg/sp for call. Evict scratch regs. */ +static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + RegSet drop = RSET_SCRATCH; + int hiop = ((ir+1)->o == IR_HIOP && !irt_isnil((ir+1)->t)); + if ((ci->flags & CCI_NOFPRCLOBBER)) + drop &= ~RSET_FPR; + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + if (hiop && ra_hasreg((ir+1)->r)) + rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ + ra_evictset(as, drop); /* Evictions must be performed first. */ + if (ra_used(ir)) { + lua_assert(!irt_ispri(ir->t)); + if (irt_isfp(ir->t)) { + if ((ci->flags & CCI_CASTU64)) { + int32_t ofs = sps_scale(ir->s); + Reg dest = ir->r; + if (ra_hasreg(dest)) { + ra_free(as, dest); + ra_modified(as, dest); + emit_tg(as, MIPSI_MTC1, RID_RETHI, dest+1); + emit_tg(as, MIPSI_MTC1, RID_RETLO, dest); + } + if (ofs) { + emit_tsi(as, MIPSI_SW, RID_RETLO, RID_SP, ofs+(LJ_BE?4:0)); + emit_tsi(as, MIPSI_SW, RID_RETHI, RID_SP, ofs+(LJ_BE?0:4)); + } + } else { + ra_destreg(as, ir, RID_FPRET); + } + } else if (hiop) { + ra_destpair(as, ir); + } else { + ra_destreg(as, ir, RID_RET); + } + } +} + +static void asm_call(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX]; + const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; + asm_collectargs(as, ir, ci, args); + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +static void asm_callx(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX*2]; + CCallInfo ci; + IRRef func; + IRIns *irf; + ci.flags = asm_callx_flags(as, ir); + asm_collectargs(as, ir, &ci, args); + asm_setupresult(as, ir, &ci); + func = ir->op2; irf = IR(func); + if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } + if (irref_isk(func)) { /* Call to constant address. */ + ci.func = (ASMFunction)(void *)(irf->i); + } else { /* Need specific register for indirect calls. */ + Reg r = ra_alloc1(as, func, RID2RSET(RID_CFUNCADDR)); + MCode *p = as->mcp; + if (r == RID_CFUNCADDR) + *--p = MIPSI_NOP; + else + *--p = MIPSI_MOVE | MIPSF_D(RID_CFUNCADDR) | MIPSF_S(r); + *--p = MIPSI_JALR | MIPSF_S(r); + as->mcp = p; + ci.func = (ASMFunction)(void *)0; + } + asm_gencall(as, &ci, args); +} + +static void asm_callid(ASMState *as, IRIns *ir, IRCallID id) +{ + const CCallInfo *ci = &lj_ir_callinfo[id]; + IRRef args[2]; + args[0] = ir->op1; + args[1] = ir->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +static void asm_callround(ASMState *as, IRIns *ir, IRCallID id) +{ + /* The modified regs must match with the *.dasc implementation. */ + RegSet drop = RID2RSET(RID_R1)|RID2RSET(RID_R12)|RID2RSET(RID_FPRET)| + RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(REGARG_FIRSTFPR); + if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); + ra_evictset(as, drop); + ra_destreg(as, ir, RID_FPRET); + emit_call(as, (void *)lj_ir_callinfo[id].func); + ra_leftov(as, REGARG_FIRSTFPR, ir->op1); +} + +/* -- Returns ------------------------------------------------------------- */ + +/* Return to lower frame. Guard that it goes to the right spot. */ +static void asm_retf(ASMState *as, IRIns *ir) +{ + Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); + void *pc = ir_kptr(IR(ir->op2)); + int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); + as->topslot -= (BCReg)delta; + if ((int32_t)as->topslot < 0) as->topslot = 0; + irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ + emit_setgl(as, base, jit_base); + emit_addptr(as, base, -8*delta); + asm_guard(as, MIPSI_BNE, RID_TMP, + ra_allock(as, i32ptr(pc), rset_exclude(RSET_GPR, base))); + emit_tsi(as, MIPSI_LW, RID_TMP, base, -8); +} + +/* -- Type conversions ---------------------------------------------------- */ + +static void asm_tointg(ASMState *as, IRIns *ir, Reg left) +{ + Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); + Reg dest = ra_dest(as, ir, RSET_GPR); + asm_guard(as, MIPSI_BC1F, 0, 0); + emit_fgh(as, MIPSI_C_EQ_D, 0, tmp, left); + emit_fg(as, MIPSI_CVT_D_W, tmp, tmp); + emit_tg(as, MIPSI_MFC1, dest, tmp); + emit_fg(as, MIPSI_CVT_W_D, tmp, left); +} + +static void asm_tobit(ASMState *as, IRIns *ir) +{ + RegSet allow = RSET_FPR; + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, allow); + Reg right = ra_alloc1(as, ir->op2, rset_clear(allow, left)); + Reg tmp = ra_scratch(as, rset_clear(allow, right)); + emit_tg(as, MIPSI_MFC1, dest, tmp); + emit_fgh(as, MIPSI_ADD_D, tmp, left, right); +} + +static void asm_conv(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); + int stfp = (st == IRT_NUM || st == IRT_FLOAT); + IRRef lref = ir->op1; + lua_assert(irt_type(ir->t) != st); + lua_assert(!(irt_isint64(ir->t) || + (st == IRT_I64 || st == IRT_U64))); /* Handled by SPLIT. */ + if (irt_isfp(ir->t)) { + Reg dest = ra_dest(as, ir, RSET_FPR); + if (stfp) { /* FP to FP conversion. */ + emit_fg(as, st == IRT_NUM ? MIPSI_CVT_S_D : MIPSI_CVT_D_S, + dest, ra_alloc1(as, lref, RSET_FPR)); + } else if (st == IRT_U32) { /* U32 to FP conversion. */ + /* y = (x ^ 0x8000000) + 2147483648.0 */ + Reg left = ra_alloc1(as, lref, RSET_GPR); + Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, dest)); + if (irt_isfloat(ir->t)) + emit_fg(as, MIPSI_CVT_S_D, dest, dest); + /* Must perform arithmetic with doubles to keep the precision. */ + emit_fgh(as, MIPSI_ADD_D, dest, dest, tmp); + emit_fg(as, MIPSI_CVT_D_W, dest, dest); + emit_lsptr(as, MIPSI_LDC1, (tmp & 31), + (void *)lj_ir_k64_find(as->J, U64x(41e00000,00000000)), + RSET_GPR); + emit_tg(as, MIPSI_MTC1, RID_TMP, dest); + emit_dst(as, MIPSI_XOR, RID_TMP, RID_TMP, left); + emit_ti(as, MIPSI_LUI, RID_TMP, 0x8000); + } else { /* Integer to FP conversion. */ + Reg left = ra_alloc1(as, lref, RSET_GPR); + emit_fg(as, irt_isfloat(ir->t) ? MIPSI_CVT_S_W : MIPSI_CVT_D_W, + dest, dest); + emit_tg(as, MIPSI_MTC1, left, dest); + } + } else if (stfp) { /* FP to integer conversion. */ + if (irt_isguard(ir->t)) { + /* Checked conversions are only supported from number to int. */ + lua_assert(irt_isint(ir->t) && st == IRT_NUM); + asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, lref, RSET_FPR); + Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); + if (irt_isu32(ir->t)) { + /* y = (int)floor(x - 2147483648.0) ^ 0x80000000 */ + emit_dst(as, MIPSI_XOR, dest, dest, RID_TMP); + emit_ti(as, MIPSI_LUI, RID_TMP, 0x8000); + emit_tg(as, MIPSI_MFC1, dest, tmp); + emit_fg(as, st == IRT_FLOAT ? MIPSI_FLOOR_W_S : MIPSI_FLOOR_W_D, + tmp, tmp); + emit_fgh(as, st == IRT_FLOAT ? MIPSI_SUB_S : MIPSI_SUB_D, + tmp, left, tmp); + if (st == IRT_FLOAT) + emit_lsptr(as, MIPSI_LWC1, (tmp & 31), + (void *)lj_ir_k64_find(as->J, U64x(4f000000,4f000000)), + RSET_GPR); + else + emit_lsptr(as, MIPSI_LDC1, (tmp & 31), + (void *)lj_ir_k64_find(as->J, U64x(41e00000,00000000)), + RSET_GPR); + } else { + emit_tg(as, MIPSI_MFC1, dest, tmp); + emit_fg(as, st == IRT_FLOAT ? MIPSI_TRUNC_W_S : MIPSI_TRUNC_W_D, + tmp, left); + } + } + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); + if ((ir->op2 & IRCONV_SEXT)) { + if ((as->flags & JIT_F_MIPS32R2)) { + emit_dst(as, st == IRT_I8 ? MIPSI_SEB : MIPSI_SEH, dest, 0, left); + } else { + uint32_t shift = st == IRT_I8 ? 24 : 16; + emit_dta(as, MIPSI_SRA, dest, dest, shift); + emit_dta(as, MIPSI_SLL, dest, left, shift); + } + } else { + emit_tsi(as, MIPSI_ANDI, dest, left, + (int32_t)(st == IRT_U8 ? 0xff : 0xffff)); + } + } else { /* 32/64 bit integer conversions. */ + /* Only need to handle 32/32 bit no-op (cast) on 32 bit archs. */ + ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ + } + } +} + +#if LJ_HASFFI +static void asm_conv64(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); + IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); + IRCallID id; + const CCallInfo *ci; + IRRef args[2]; + args[LJ_BE?0:1] = ir->op1; + args[LJ_BE?1:0] = (ir-1)->op1; + if (st == IRT_NUM || st == IRT_FLOAT) { + id = IRCALL_fp64_d2l + ((st == IRT_FLOAT) ? 2 : 0) + (dt - IRT_I64); + ir--; + } else { + id = IRCALL_fp64_l2d + ((dt == IRT_FLOAT) ? 2 : 0) + (st - IRT_I64); + } + ci = &lj_ir_callinfo[id]; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} +#endif + +static void asm_strto(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; + IRRef args[2]; + RegSet drop = RSET_SCRATCH; + if (ra_hasreg(ir->r)) rset_set(drop, ir->r); /* Spill dest reg (if any). */ + ra_evictset(as, drop); + asm_guard(as, MIPSI_BEQ, RID_RET, RID_ZERO); /* Test return status. */ + args[0] = ir->op1; /* GCstr *str */ + args[1] = ASMREF_TMP1; /* TValue *n */ + asm_gencall(as, ci, args); + /* Store the result to the spill slot or temp slots. */ + emit_tsi(as, MIPSI_ADDIU, ra_releasetmp(as, ASMREF_TMP1), + RID_SP, sps_scale(ir->s)); +} + +/* Get pointer to TValue. */ +static void asm_tvptr(ASMState *as, Reg dest, IRRef ref) +{ + IRIns *ir = IR(ref); + if (irt_isnum(ir->t)) { + if (irref_isk(ref)) /* Use the number constant itself as a TValue. */ + ra_allockreg(as, i32ptr(ir_knum(ir)), dest); + else /* Otherwise force a spill and use the spill slot. */ + emit_tsi(as, MIPSI_ADDIU, dest, RID_SP, ra_spill(as, ir)); + } else { + /* Otherwise use g->tmptv to hold the TValue. */ + RegSet allow = rset_exclude(RSET_GPR, dest); + Reg type; + emit_tsi(as, MIPSI_ADDIU, dest, RID_JGL, offsetof(global_State, tmptv)-32768); + if (!irt_ispri(ir->t)) { + Reg src = ra_alloc1(as, ref, allow); + emit_setgl(as, src, tmptv.gcr); + } + type = ra_allock(as, irt_toitype(ir->t), allow); + emit_setgl(as, type, tmptv.it); + } +} + +static void asm_tostr(ASMState *as, IRIns *ir) +{ + IRRef args[2]; + args[0] = ASMREF_L; + as->gcsteps++; + if (irt_isnum(IR(ir->op1)->t) || (ir+1)->o == IR_HIOP) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; + args[1] = ASMREF_TMP1; /* const lua_Number * */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op1); + } else { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; + args[1] = ir->op1; /* int32_t k */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + } +} + +/* -- Memory references --------------------------------------------------- */ + +static void asm_aref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg idx, base; + if (irref_isk(ir->op2)) { + IRRef tab = IR(ir->op1)->op1; + int32_t ofs = asm_fuseabase(as, tab); + IRRef refa = ofs ? tab : ir->op1; + ofs += 8*IR(ir->op2)->i; + if (checki16(ofs)) { + base = ra_alloc1(as, refa, RSET_GPR); + emit_tsi(as, MIPSI_ADDIU, dest, base, ofs); + return; + } + } + base = ra_alloc1(as, ir->op1, RSET_GPR); + idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); + emit_dst(as, MIPSI_ADDU, dest, RID_TMP, base); + emit_dta(as, MIPSI_SLL, RID_TMP, idx, 3); +} + +/* Inlined hash lookup. Specialized for key type and for const keys. +** The equivalent C code is: +** Node *n = hashkey(t, key); +** do { +** if (lj_obj_equal(&n->key, key)) return &n->val; +** } while ((n = nextnode(n))); +** return niltv(L); +*/ +static void asm_href(ASMState *as, IRIns *ir) +{ + RegSet allow = RSET_GPR; + int destused = ra_used(ir); + Reg dest = ra_dest(as, ir, allow); + Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); + Reg key = RID_NONE, type = RID_NONE, tmpnum = RID_NONE, tmp1 = RID_TMP, tmp2; + IRRef refkey = ir->op2; + IRIns *irkey = IR(refkey); + IRType1 kt = irkey->t; + uint32_t khash; + MCLabel l_end, l_loop, l_next; + + rset_clear(allow, tab); + if (irt_isnum(kt)) { + key = ra_alloc1(as, refkey, RSET_FPR); + tmpnum = ra_scratch(as, rset_exclude(RSET_FPR, key)); + } else if (!irt_ispri(kt)) { + key = ra_alloc1(as, refkey, allow); + rset_clear(allow, key); + type = ra_allock(as, irt_toitype(irkey->t), allow); + rset_clear(allow, type); + } + tmp2 = ra_scratch(as, allow); + rset_clear(allow, tmp2); + + /* Key not found in chain: load niltv. */ + l_end = emit_label(as); + if (destused) + emit_loada(as, dest, niltvg(J2G(as->J))); + else + *--as->mcp = MIPSI_NOP; + /* Follow hash chain until the end. */ + emit_move(as, dest, tmp1); + l_loop = --as->mcp; + emit_tsi(as, MIPSI_LW, tmp1, dest, (int32_t)offsetof(Node, next)); + l_next = emit_label(as); + + /* Type and value comparison. */ + if (irt_isnum(kt)) { + emit_branch(as, MIPSI_BC1T, 0, 0, l_end); + emit_fgh(as, MIPSI_C_EQ_D, 0, tmpnum, key); + emit_tg(as, MIPSI_MFC1, tmp1, key+1); + emit_branch(as, MIPSI_BEQ, tmp1, RID_ZERO, l_next); + emit_tsi(as, MIPSI_SLTIU, tmp1, tmp1, (int32_t)LJ_TISNUM); + emit_hsi(as, MIPSI_LDC1, tmpnum, dest, (int32_t)offsetof(Node, key.n)); + } else { + if (irt_ispri(kt)) { + emit_branch(as, MIPSI_BEQ, tmp1, type, l_end); + } else { + emit_branch(as, MIPSI_BEQ, tmp2, key, l_end); + emit_tsi(as, MIPSI_LW, tmp2, dest, (int32_t)offsetof(Node, key.gcr)); + emit_branch(as, MIPSI_BNE, tmp1, type, l_next); + } + } + emit_tsi(as, MIPSI_LW, tmp1, dest, (int32_t)offsetof(Node, key.it)); + *l_loop = MIPSI_BNE | MIPSF_S(tmp1) | ((as->mcp-l_loop-1) & 0xffffu); + + /* Load main position relative to tab->node into dest. */ + khash = irref_isk(refkey) ? ir_khash(irkey) : 1; + if (khash == 0) { + emit_tsi(as, MIPSI_LW, dest, tab, (int32_t)offsetof(GCtab, node)); + } else { + Reg tmphash = tmp1; + if (irref_isk(refkey)) + tmphash = ra_allock(as, khash, allow); + emit_dst(as, MIPSI_ADDU, dest, dest, tmp1); + lua_assert(sizeof(Node) == 24); + emit_dst(as, MIPSI_SUBU, tmp1, tmp2, tmp1); + emit_dta(as, MIPSI_SLL, tmp1, tmp1, 3); + emit_dta(as, MIPSI_SLL, tmp2, tmp1, 5); + emit_dst(as, MIPSI_AND, tmp1, tmp2, tmphash); + emit_tsi(as, MIPSI_LW, dest, tab, (int32_t)offsetof(GCtab, node)); + emit_tsi(as, MIPSI_LW, tmp2, tab, (int32_t)offsetof(GCtab, hmask)); + if (irref_isk(refkey)) { + /* Nothing to do. */ + } else if (irt_isstr(kt)) { + emit_tsi(as, MIPSI_LW, tmp1, key, (int32_t)offsetof(GCstr, hash)); + } else { /* Must match with hash*() in lj_tab.c. */ + emit_dst(as, MIPSI_SUBU, tmp1, tmp1, tmp2); + emit_rotr(as, tmp2, tmp2, dest, (-HASH_ROT3)&31); + emit_dst(as, MIPSI_XOR, tmp1, tmp1, tmp2); + emit_rotr(as, tmp1, tmp1, dest, (-HASH_ROT2-HASH_ROT1)&31); + emit_dst(as, MIPSI_SUBU, tmp2, tmp2, dest); + if (irt_isnum(kt)) { + emit_dst(as, MIPSI_XOR, tmp2, tmp2, tmp1); + if ((as->flags & JIT_F_MIPS32R2)) { + emit_dta(as, MIPSI_ROTR, dest, tmp1, (-HASH_ROT1)&31); + } else { + emit_dst(as, MIPSI_OR, dest, dest, tmp1); + emit_dta(as, MIPSI_SLL, tmp1, tmp1, HASH_ROT1); + emit_dta(as, MIPSI_SRL, dest, tmp1, (-HASH_ROT1)&31); + } + emit_dst(as, MIPSI_ADDU, tmp1, tmp1, tmp1); + emit_tg(as, MIPSI_MFC1, tmp2, key); + emit_tg(as, MIPSI_MFC1, tmp1, key+1); + } else { + emit_dst(as, MIPSI_XOR, tmp2, key, tmp1); + emit_rotr(as, dest, tmp1, tmp2, (-HASH_ROT1)&31); + emit_dst(as, MIPSI_ADDU, tmp1, key, ra_allock(as, HASH_BIAS, allow)); + } + } + } +} + +static void asm_hrefk(ASMState *as, IRIns *ir) +{ + IRIns *kslot = IR(ir->op2); + IRIns *irkey = IR(kslot->op1); + int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); + int32_t kofs = ofs + (int32_t)offsetof(Node, key); + Reg dest = (ra_used(ir)||ofs > 32736) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; + Reg node = ra_alloc1(as, ir->op1, RSET_GPR); + Reg key = RID_NONE, type = RID_TMP, idx = node; + RegSet allow = rset_exclude(RSET_GPR, node); + int32_t lo, hi; + lua_assert(ofs % sizeof(Node) == 0); + if (ofs > 32736) { + idx = dest; + rset_clear(allow, dest); + kofs = (int32_t)offsetof(Node, key); + } else if (ra_hasreg(dest)) { + emit_tsi(as, MIPSI_ADDIU, dest, node, ofs); + } + if (!irt_ispri(irkey->t)) { + key = ra_scratch(as, allow); + rset_clear(allow, key); + } + if (irt_isnum(irkey->t)) { + lo = (int32_t)ir_knum(irkey)->u32.lo; + hi = (int32_t)ir_knum(irkey)->u32.hi; + } else { + lo = irkey->i; + hi = irt_toitype(irkey->t); + if (!ra_hasreg(key)) + goto nolo; + } + asm_guard(as, MIPSI_BNE, key, lo ? ra_allock(as, lo, allow) : RID_ZERO); +nolo: + asm_guard(as, MIPSI_BNE, type, hi ? ra_allock(as, hi, allow) : RID_ZERO); + if (ra_hasreg(key)) emit_tsi(as, MIPSI_LW, key, idx, kofs+(LJ_BE?4:0)); + emit_tsi(as, MIPSI_LW, type, idx, kofs+(LJ_BE?0:4)); + if (ofs > 32736) + emit_tsi(as, MIPSI_ADDU, dest, node, ra_allock(as, ofs, allow)); +} + +static void asm_newref(ASMState *as, IRIns *ir) +{ + if (ir->r != RID_SINK) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; + IRRef args[3]; + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ir->op1; /* GCtab *t */ + args[2] = ASMREF_TMP1; /* cTValue *key */ + asm_setupresult(as, ir, ci); /* TValue * */ + asm_gencall(as, ci, args); + asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op2); + } +} + +static void asm_uref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; + emit_lsptr(as, MIPSI_LW, dest, v, RSET_GPR); + } else { + Reg uv = ra_scratch(as, RSET_GPR); + Reg func = ra_alloc1(as, ir->op1, RSET_GPR); + if (ir->o == IR_UREFC) { + asm_guard(as, MIPSI_BEQ, RID_TMP, RID_ZERO); + emit_tsi(as, MIPSI_ADDIU, dest, uv, (int32_t)offsetof(GCupval, tv)); + emit_tsi(as, MIPSI_LBU, RID_TMP, uv, (int32_t)offsetof(GCupval, closed)); + } else { + emit_tsi(as, MIPSI_LW, dest, uv, (int32_t)offsetof(GCupval, v)); + } + emit_tsi(as, MIPSI_LW, uv, func, + (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); + } +} + +static void asm_fref(ASMState *as, IRIns *ir) +{ + UNUSED(as); UNUSED(ir); + lua_assert(!ra_used(ir)); +} + +static void asm_strref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + IRRef ref = ir->op2, refk = ir->op1; + int32_t ofs = (int32_t)sizeof(GCstr); + Reg r; + if (irref_isk(ref)) { + IRRef tmp = refk; refk = ref; ref = tmp; + } else if (!irref_isk(refk)) { + Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); + IRIns *irr = IR(ir->op2); + if (ra_hasreg(irr->r)) { + ra_noweak(as, irr->r); + right = irr->r; + } else if (mayfuse(as, irr->op2) && + irr->o == IR_ADD && irref_isk(irr->op2) && + checki16(ofs + IR(irr->op2)->i)) { + ofs += IR(irr->op2)->i; + right = ra_alloc1(as, irr->op1, rset_exclude(RSET_GPR, left)); + } else { + right = ra_allocref(as, ir->op2, rset_exclude(RSET_GPR, left)); + } + emit_tsi(as, MIPSI_ADDIU, dest, dest, ofs); + emit_dst(as, MIPSI_ADDU, dest, left, right); + return; + } + r = ra_alloc1(as, ref, RSET_GPR); + ofs += IR(refk)->i; + if (checki16(ofs)) + emit_tsi(as, MIPSI_ADDIU, dest, r, ofs); + else + emit_dst(as, MIPSI_ADDU, dest, r, + ra_allock(as, ofs, rset_exclude(RSET_GPR, r))); +} + +/* -- Loads and stores ---------------------------------------------------- */ + +static MIPSIns asm_fxloadins(IRIns *ir) +{ + switch (irt_type(ir->t)) { + case IRT_I8: return MIPSI_LB; + case IRT_U8: return MIPSI_LBU; + case IRT_I16: return MIPSI_LH; + case IRT_U16: return MIPSI_LHU; + case IRT_NUM: return MIPSI_LDC1; + case IRT_FLOAT: return MIPSI_LWC1; + default: return MIPSI_LW; + } +} + +static MIPSIns asm_fxstoreins(IRIns *ir) +{ + switch (irt_type(ir->t)) { + case IRT_I8: case IRT_U8: return MIPSI_SB; + case IRT_I16: case IRT_U16: return MIPSI_SH; + case IRT_NUM: return MIPSI_SDC1; + case IRT_FLOAT: return MIPSI_SWC1; + default: return MIPSI_SW; + } +} + +static void asm_fload(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg idx = ra_alloc1(as, ir->op1, RSET_GPR); + MIPSIns mi = asm_fxloadins(ir); + int32_t ofs; + if (ir->op2 == IRFL_TAB_ARRAY) { + ofs = asm_fuseabase(as, ir->op1); + if (ofs) { /* Turn the t->array load into an add for colocated arrays. */ + emit_tsi(as, MIPSI_ADDIU, dest, idx, ofs); + return; + } + } + ofs = field_ofs[ir->op2]; + lua_assert(!irt_isfp(ir->t)); + emit_tsi(as, mi, dest, idx, ofs); +} + +static void asm_fstore(ASMState *as, IRIns *ir) +{ + if (ir->r != RID_SINK) { + Reg src = ra_alloc1z(as, ir->op2, RSET_GPR); + IRIns *irf = IR(ir->op1); + Reg idx = ra_alloc1(as, irf->op1, rset_exclude(RSET_GPR, src)); + int32_t ofs = field_ofs[irf->op2]; + MIPSIns mi = asm_fxstoreins(ir); + lua_assert(!irt_isfp(ir->t)); + emit_tsi(as, mi, src, idx, ofs); + } +} + +static void asm_xload(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); + lua_assert(!(ir->op2 & IRXLOAD_UNALIGNED)); + asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR, 0); +} + +static void asm_xstore(ASMState *as, IRIns *ir, int32_t ofs) +{ + if (ir->r != RID_SINK) { + Reg src = ra_alloc1z(as, ir->op2, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); + asm_fusexref(as, asm_fxstoreins(ir), src, ir->op1, + rset_exclude(RSET_GPR, src), ofs); + } +} + +static void asm_ahuvload(ASMState *as, IRIns *ir) +{ + IRType1 t = ir->t; + Reg dest = RID_NONE, type = RID_TMP, idx; + RegSet allow = RSET_GPR; + int32_t ofs = 0; + if (ra_used(ir)) { + lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); + dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); + rset_clear(allow, dest); + } + idx = asm_fuseahuref(as, ir->op1, &ofs, allow); + rset_clear(allow, idx); + if (irt_isnum(t)) { + asm_guard(as, MIPSI_BEQ, type, RID_ZERO); + emit_tsi(as, MIPSI_SLTIU, type, type, (int32_t)LJ_TISNUM); + if (ra_hasreg(dest)) + emit_hsi(as, MIPSI_LDC1, dest, idx, ofs); + } else { + asm_guard(as, MIPSI_BNE, type, ra_allock(as, irt_toitype(t), allow)); + if (ra_hasreg(dest)) emit_tsi(as, MIPSI_LW, dest, idx, ofs+(LJ_BE?4:0)); + } + emit_tsi(as, MIPSI_LW, type, idx, ofs+(LJ_BE?0:4)); +} + +static void asm_ahustore(ASMState *as, IRIns *ir) +{ + RegSet allow = RSET_GPR; + Reg idx, src = RID_NONE, type = RID_NONE; + int32_t ofs = 0; + if (ir->r == RID_SINK) + return; + if (irt_isnum(ir->t)) { + src = ra_alloc1(as, ir->op2, RSET_FPR); + } else { + if (!irt_ispri(ir->t)) { + src = ra_alloc1(as, ir->op2, allow); + rset_clear(allow, src); + } + type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); + rset_clear(allow, type); + } + idx = asm_fuseahuref(as, ir->op1, &ofs, allow); + if (irt_isnum(ir->t)) { + emit_hsi(as, MIPSI_SDC1, src, idx, ofs); + } else { + if (ra_hasreg(src)) + emit_tsi(as, MIPSI_SW, src, idx, ofs+(LJ_BE?4:0)); + emit_tsi(as, MIPSI_SW, type, idx, ofs+(LJ_BE?0:4)); + } +} + +static void asm_sload(ASMState *as, IRIns *ir) +{ + int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 4 : 0); + IRType1 t = ir->t; + Reg dest = RID_NONE, type = RID_NONE, base; + RegSet allow = RSET_GPR; + lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ + lua_assert(irt_isguard(t) || !(ir->op2 & IRSLOAD_TYPECHECK)); + lua_assert(!irt_isint(t) || (ir->op2 & (IRSLOAD_CONVERT|IRSLOAD_FRAME))); + if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(t) && irt_isint(t)) { + dest = ra_scratch(as, RSET_FPR); + asm_tointg(as, ir, dest); + t.irt = IRT_NUM; /* Continue with a regular number type check. */ + } else if (ra_used(ir)) { + lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); + dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); + rset_clear(allow, dest); + base = ra_alloc1(as, REF_BASE, allow); + rset_clear(allow, base); + if ((ir->op2 & IRSLOAD_CONVERT)) { + if (irt_isint(t)) { + Reg tmp = ra_scratch(as, RSET_FPR); + emit_tg(as, MIPSI_MFC1, dest, tmp); + emit_fg(as, MIPSI_CVT_W_D, tmp, tmp); + dest = tmp; + t.irt = IRT_NUM; /* Check for original type. */ + } else { + Reg tmp = ra_scratch(as, RSET_GPR); + emit_fg(as, MIPSI_CVT_D_W, dest, dest); + emit_tg(as, MIPSI_MTC1, tmp, dest); + dest = tmp; + t.irt = IRT_INT; /* Check for original type. */ + } + } + goto dotypecheck; + } + base = ra_alloc1(as, REF_BASE, allow); + rset_clear(allow, base); +dotypecheck: + if (irt_isnum(t)) { + if ((ir->op2 & IRSLOAD_TYPECHECK)) { + asm_guard(as, MIPSI_BEQ, RID_TMP, RID_ZERO); + emit_tsi(as, MIPSI_SLTIU, RID_TMP, RID_TMP, (int32_t)LJ_TISNUM); + type = RID_TMP; + } + if (ra_hasreg(dest)) emit_hsi(as, MIPSI_LDC1, dest, base, ofs); + } else { + if ((ir->op2 & IRSLOAD_TYPECHECK)) { + Reg ktype = ra_allock(as, irt_toitype(t), allow); + asm_guard(as, MIPSI_BNE, RID_TMP, ktype); + type = RID_TMP; + } + if (ra_hasreg(dest)) emit_tsi(as, MIPSI_LW, dest, base, ofs ^ (LJ_BE?4:0)); + } + if (ra_hasreg(type)) emit_tsi(as, MIPSI_LW, type, base, ofs ^ (LJ_BE?0:4)); +} + +/* -- Allocations --------------------------------------------------------- */ + +#if LJ_HASFFI +static void asm_cnew(ASMState *as, IRIns *ir) +{ + CTState *cts = ctype_ctsG(J2G(as->J)); + CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; + CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? + lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; + IRRef args[2]; + RegSet allow = (RSET_GPR & ~RSET_SCRATCH); + RegSet drop = RSET_SCRATCH; + lua_assert(sz != CTSIZE_INVALID); + + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ASMREF_TMP1; /* MSize size */ + as->gcsteps++; + + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + ra_evictset(as, drop); + if (ra_used(ir)) + ra_destreg(as, ir, RID_RET); /* GCcdata * */ + + /* Initialize immutable cdata object. */ + if (ir->o == IR_CNEWI) { + int32_t ofs = sizeof(GCcdata); + lua_assert(sz == 4 || sz == 8); + if (sz == 8) { + ofs += 4; + lua_assert((ir+1)->o == IR_HIOP); + if (LJ_LE) ir++; + } + for (;;) { + Reg r = ra_alloc1z(as, ir->op2, allow); + emit_tsi(as, MIPSI_SW, r, RID_RET, ofs); + rset_clear(allow, r); + if (ofs == sizeof(GCcdata)) break; + ofs -= 4; if (LJ_BE) ir++; else ir--; + } + } + /* Initialize gct and ctypeid. lj_mem_newgco() already sets marked. */ + emit_tsi(as, MIPSI_SB, RID_RET+1, RID_RET, offsetof(GCcdata, gct)); + emit_tsi(as, MIPSI_SH, RID_TMP, RID_RET, offsetof(GCcdata, ctypeid)); + emit_ti(as, MIPSI_LI, RID_RET+1, ~LJ_TCDATA); + emit_ti(as, MIPSI_LI, RID_TMP, ctypeid); /* Lower 16 bit used. Sign-ext ok. */ + asm_gencall(as, ci, args); + ra_allockreg(as, (int32_t)(sz+sizeof(GCcdata)), + ra_releasetmp(as, ASMREF_TMP1)); +} +#else +#define asm_cnew(as, ir) ((void)0) +#endif + +/* -- Write barriers ------------------------------------------------------ */ + +static void asm_tbar(ASMState *as, IRIns *ir) +{ + Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); + Reg mark = ra_scratch(as, rset_exclude(RSET_GPR, tab)); + Reg link = RID_TMP; + MCLabel l_end = emit_label(as); + emit_tsi(as, MIPSI_SW, link, tab, (int32_t)offsetof(GCtab, gclist)); + emit_tsi(as, MIPSI_SB, mark, tab, (int32_t)offsetof(GCtab, marked)); + emit_setgl(as, tab, gc.grayagain); + emit_getgl(as, link, gc.grayagain); + emit_dst(as, MIPSI_XOR, mark, mark, RID_TMP); /* Clear black bit. */ + emit_branch(as, MIPSI_BEQ, RID_TMP, RID_ZERO, l_end); + emit_tsi(as, MIPSI_ANDI, RID_TMP, mark, LJ_GC_BLACK); + emit_tsi(as, MIPSI_LBU, mark, tab, (int32_t)offsetof(GCtab, marked)); +} + +static void asm_obar(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; + IRRef args[2]; + MCLabel l_end; + Reg obj, val, tmp; + /* No need for other object barriers (yet). */ + lua_assert(IR(ir->op1)->o == IR_UREFC); + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ir->op1; /* TValue *tv */ + asm_gencall(as, ci, args); + emit_tsi(as, MIPSI_ADDIU, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); + obj = IR(ir->op1)->r; + tmp = ra_scratch(as, rset_exclude(RSET_GPR, obj)); + emit_branch(as, MIPSI_BEQ, RID_TMP, RID_ZERO, l_end); + emit_tsi(as, MIPSI_ANDI, tmp, tmp, LJ_GC_BLACK); + emit_branch(as, MIPSI_BEQ, RID_TMP, RID_ZERO, l_end); + emit_tsi(as, MIPSI_ANDI, RID_TMP, RID_TMP, LJ_GC_WHITES); + val = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, obj)); + emit_tsi(as, MIPSI_LBU, tmp, obj, + (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); + emit_tsi(as, MIPSI_LBU, RID_TMP, val, (int32_t)offsetof(GChead, marked)); +} + +/* -- Arithmetic and logic operations ------------------------------------- */ + +static void asm_fparith(ASMState *as, IRIns *ir, MIPSIns mi) +{ + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = (left >> 8); left &= 255; + emit_fgh(as, mi, dest, left, right); +} + +static void asm_fpunary(ASMState *as, IRIns *ir, MIPSIns mi) +{ + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg left = ra_hintalloc(as, ir->op1, dest, RSET_FPR); + emit_fg(as, mi, dest, left); +} + +static int asm_fpjoin_pow(ASMState *as, IRIns *ir) +{ + IRIns *irp = IR(ir->op1); + if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { + IRIns *irpp = IR(irp->op1); + if (irpp == ir-2 && irpp->o == IR_FPMATH && + irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_pow]; + IRRef args[2]; + args[0] = irpp->op1; + args[1] = irp->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); + return 1; + } + } + return 0; +} + +static void asm_add(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + asm_fparith(as, ir, MIPSI_ADD_D); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (checki16(k)) { + emit_tsi(as, MIPSI_ADDIU, dest, left, k); + return; + } + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_dst(as, MIPSI_ADDU, dest, left, right); + } +} + +static void asm_sub(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + asm_fparith(as, ir, MIPSI_SUB_D); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + emit_dst(as, MIPSI_SUBU, dest, left, right); + } +} + +static void asm_mul(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + asm_fparith(as, ir, MIPSI_MUL_D); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + emit_dst(as, MIPSI_MUL, dest, left, right); + } +} + +static void asm_neg(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + asm_fpunary(as, ir, MIPSI_NEG_D); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + emit_dst(as, MIPSI_SUBU, dest, RID_ZERO, left); + } +} + +static void asm_arithov(ASMState *as, IRIns *ir) +{ + Reg right, left, tmp, dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op2)) { + int k = IR(ir->op2)->i; + if (ir->o == IR_SUBOV) k = -k; + if (checki16(k)) { /* (dest < left) == (k >= 0 ? 1 : 0) */ + left = ra_alloc1(as, ir->op1, RSET_GPR); + asm_guard(as, k >= 0 ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); + emit_dst(as, MIPSI_SLT, RID_TMP, dest, dest == left ? RID_TMP : left); + emit_tsi(as, MIPSI_ADDIU, dest, left, k); + if (dest == left) emit_move(as, RID_TMP, left); + return; + } + } + left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + tmp = ra_scratch(as, rset_exclude(rset_exclude(rset_exclude(RSET_GPR, left), + right), dest)); + asm_guard(as, MIPSI_BLTZ, RID_TMP, 0); + emit_dst(as, MIPSI_AND, RID_TMP, RID_TMP, tmp); + if (ir->o == IR_ADDOV) { /* ((dest^left) & (dest^right)) < 0 */ + emit_dst(as, MIPSI_XOR, RID_TMP, dest, dest == right ? RID_TMP : right); + } else { /* ((dest^left) & (dest^~right)) < 0 */ + emit_dst(as, MIPSI_XOR, RID_TMP, RID_TMP, dest); + emit_dst(as, MIPSI_NOR, RID_TMP, dest == right ? RID_TMP : right, RID_ZERO); + } + emit_dst(as, MIPSI_XOR, tmp, dest, dest == left ? RID_TMP : left); + emit_dst(as, ir->o == IR_ADDOV ? MIPSI_ADDU : MIPSI_SUBU, dest, left, right); + if (dest == left || dest == right) + emit_move(as, RID_TMP, dest == left ? left : right); +} + +static void asm_mulov(ASMState *as, IRIns *ir) +{ +#if LJ_DUALNUM +#error "NYI: MULOV" +#else + UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused in single-number mode. */ +#endif +} + +#if LJ_HASFFI +static void asm_add64(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (k == 0) { + emit_dst(as, MIPSI_ADDU, dest, left, RID_TMP); + goto loarith; + } else if (checki16(k)) { + emit_dst(as, MIPSI_ADDU, dest, dest, RID_TMP); + emit_tsi(as, MIPSI_ADDIU, dest, left, k); + goto loarith; + } + } + emit_dst(as, MIPSI_ADDU, dest, dest, RID_TMP); + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_dst(as, MIPSI_ADDU, dest, left, right); +loarith: + ir--; + dest = ra_dest(as, ir, RSET_GPR); + left = ra_alloc1(as, ir->op1, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (k == 0) { + if (dest != left) + emit_move(as, dest, left); + return; + } else if (checki16(k)) { + if (dest == left) { + Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, left)); + emit_move(as, dest, tmp); + dest = tmp; + } + emit_dst(as, MIPSI_SLTU, RID_TMP, dest, left); + emit_tsi(as, MIPSI_ADDIU, dest, left, k); + return; + } + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + if (dest == left && dest == right) { + Reg tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), right)); + emit_move(as, dest, tmp); + dest = tmp; + } + emit_dst(as, MIPSI_SLTU, RID_TMP, dest, dest == left ? right : left); + emit_dst(as, MIPSI_ADDU, dest, left, right); +} + +static void asm_sub64(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + emit_dst(as, MIPSI_SUBU, dest, dest, RID_TMP); + emit_dst(as, MIPSI_SUBU, dest, left, right); + ir--; + dest = ra_dest(as, ir, RSET_GPR); + left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + if (dest == left) { + Reg tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), right)); + emit_move(as, dest, tmp); + dest = tmp; + } + emit_dst(as, MIPSI_SLTU, RID_TMP, left, dest); + emit_dst(as, MIPSI_SUBU, dest, left, right); +} + +static void asm_neg64(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + emit_dst(as, MIPSI_SUBU, dest, dest, RID_TMP); + emit_dst(as, MIPSI_SUBU, dest, RID_ZERO, left); + ir--; + dest = ra_dest(as, ir, RSET_GPR); + left = ra_alloc1(as, ir->op1, RSET_GPR); + emit_dst(as, MIPSI_SLTU, RID_TMP, RID_ZERO, dest); + emit_dst(as, MIPSI_SUBU, dest, RID_ZERO, left); +} +#endif + +static void asm_bitnot(ASMState *as, IRIns *ir) +{ + Reg left, right, dest = ra_dest(as, ir, RSET_GPR); + IRIns *irl = IR(ir->op1); + if (mayfuse(as, ir->op1) && irl->o == IR_BOR) { + left = ra_alloc2(as, irl, RSET_GPR); + right = (left >> 8); left &= 255; + } else { + left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + right = RID_ZERO; + } + emit_dst(as, MIPSI_NOR, dest, left, right); +} + +static void asm_bitswap(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + if ((as->flags & JIT_F_MIPS32R2)) { + emit_dta(as, MIPSI_ROTR, dest, RID_TMP, 16); + emit_dst(as, MIPSI_WSBH, RID_TMP, 0, left); + } else { + Reg tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), dest)); + emit_dst(as, MIPSI_OR, dest, dest, tmp); + emit_dst(as, MIPSI_OR, dest, dest, RID_TMP); + emit_tsi(as, MIPSI_ANDI, dest, dest, 0xff00); + emit_dta(as, MIPSI_SLL, RID_TMP, RID_TMP, 8); + emit_dta(as, MIPSI_SRL, dest, left, 8); + emit_tsi(as, MIPSI_ANDI, RID_TMP, left, 0xff00); + emit_dst(as, MIPSI_OR, tmp, tmp, RID_TMP); + emit_dta(as, MIPSI_SRL, tmp, left, 24); + emit_dta(as, MIPSI_SLL, RID_TMP, left, 24); + } +} + +static void asm_bitop(ASMState *as, IRIns *ir, MIPSIns mi, MIPSIns mik) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (checku16(k)) { + emit_tsi(as, mik, dest, left, k); + return; + } + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_dst(as, mi, dest, left, right); +} + +static void asm_bitshift(ASMState *as, IRIns *ir, MIPSIns mi, MIPSIns mik) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op2)) { /* Constant shifts. */ + uint32_t shift = (uint32_t)(IR(ir->op2)->i & 31); + emit_dta(as, mik, dest, ra_hintalloc(as, ir->op1, dest, RSET_GPR), shift); + } else { + Reg right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + emit_dst(as, mi, dest, right, left); /* Shift amount is in rs. */ + } +} + +static void asm_bitror(ASMState *as, IRIns *ir) +{ + if ((as->flags & JIT_F_MIPS32R2)) { + asm_bitshift(as, ir, MIPSI_ROTRV, MIPSI_ROTR); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op2)) { /* Constant shifts. */ + uint32_t shift = (uint32_t)(IR(ir->op2)->i & 31); + Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + emit_rotr(as, dest, left, RID_TMP, shift); + } else { + Reg right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + emit_dst(as, MIPSI_OR, dest, dest, RID_TMP); + emit_dst(as, MIPSI_SRLV, dest, right, left); + emit_dst(as, MIPSI_SLLV, RID_TMP, RID_TMP, left); + emit_dst(as, MIPSI_SUBU, RID_TMP, ra_allock(as, 32, RSET_GPR), right); + } + } +} + +static void asm_min_max(ASMState *as, IRIns *ir, int ismax) +{ + if (irt_isnum(ir->t)) { + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = (left >> 8); left &= 255; + if (dest == left) { + emit_fg(as, MIPSI_MOVT_D, dest, right); + } else { + emit_fg(as, MIPSI_MOVF_D, dest, left); + if (dest != right) emit_fg(as, MIPSI_MOV_D, dest, right); + } + emit_fgh(as, MIPSI_C_OLT_D, 0, ismax ? left : right, ismax ? right : left); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + if (dest == left) { + emit_dst(as, MIPSI_MOVN, dest, right, RID_TMP); + } else { + emit_dst(as, MIPSI_MOVZ, dest, left, RID_TMP); + if (dest != right) emit_move(as, dest, right); + } + emit_dst(as, MIPSI_SLT, RID_TMP, + ismax ? left : right, ismax ? right : left); + } +} + +/* -- Comparisons --------------------------------------------------------- */ + +static void asm_comp(ASMState *as, IRIns *ir) +{ + /* ORDER IR: LT GE LE GT ULT UGE ULE UGT. */ + IROp op = ir->o; + if (irt_isnum(ir->t)) { + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = (left >> 8); left &= 255; + asm_guard(as, (op&1) ? MIPSI_BC1T : MIPSI_BC1F, 0, 0); + emit_fgh(as, MIPSI_C_OLT_D + ((op&3) ^ ((op>>2)&1)), 0, left, right); + } else { + Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); + if (op == IR_ABC) op = IR_UGT; + if ((op&4) == 0 && irref_isk(ir->op2) && IR(ir->op2)->i == 0) { + MIPSIns mi = (op&2) ? ((op&1) ? MIPSI_BLEZ : MIPSI_BGTZ) : + ((op&1) ? MIPSI_BLTZ : MIPSI_BGEZ); + asm_guard(as, mi, left, 0); + } else { + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if ((op&2)) k++; + if (checki16(k)) { + asm_guard(as, (op&1) ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); + emit_tsi(as, (op&4) ? MIPSI_SLTIU : MIPSI_SLTI, + RID_TMP, left, k); + return; + } + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + asm_guard(as, ((op^(op>>1))&1) ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); + emit_dst(as, (op&4) ? MIPSI_SLTU : MIPSI_SLT, + RID_TMP, (op&2) ? right : left, (op&2) ? left : right); + } + } +} + +static void asm_compeq(ASMState *as, IRIns *ir) +{ + Reg right, left = ra_alloc2(as, ir, irt_isnum(ir->t) ? RSET_FPR : RSET_GPR); + right = (left >> 8); left &= 255; + if (irt_isnum(ir->t)) { + asm_guard(as, (ir->o & 1) ? MIPSI_BC1T : MIPSI_BC1F, 0, 0); + emit_fgh(as, MIPSI_C_EQ_D, 0, left, right); + } else { + asm_guard(as, (ir->o & 1) ? MIPSI_BEQ : MIPSI_BNE, left, right); + } +} + +#if LJ_HASFFI +/* 64 bit integer comparisons. */ +static void asm_comp64(ASMState *as, IRIns *ir) +{ + /* ORDER IR: LT GE LE GT ULT UGE ULE UGT. */ + IROp op = (ir-1)->o; + MCLabel l_end; + Reg rightlo, leftlo, righthi, lefthi = ra_alloc2(as, ir, RSET_GPR); + righthi = (lefthi >> 8); lefthi &= 255; + leftlo = ra_alloc2(as, ir-1, + rset_exclude(rset_exclude(RSET_GPR, lefthi), righthi)); + rightlo = (leftlo >> 8); leftlo &= 255; + asm_guard(as, ((op^(op>>1))&1) ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); + l_end = emit_label(as); + if (lefthi != righthi) + emit_dst(as, (op&4) ? MIPSI_SLTU : MIPSI_SLT, RID_TMP, + (op&2) ? righthi : lefthi, (op&2) ? lefthi : righthi); + emit_dst(as, MIPSI_SLTU, RID_TMP, + (op&2) ? rightlo : leftlo, (op&2) ? leftlo : rightlo); + if (lefthi != righthi) + emit_branch(as, MIPSI_BEQ, lefthi, righthi, l_end); +} + +static void asm_comp64eq(ASMState *as, IRIns *ir) +{ + Reg tmp, right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + asm_guard(as, ((ir-1)->o & 1) ? MIPSI_BEQ : MIPSI_BNE, RID_TMP, RID_ZERO); + tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), right)); + emit_dst(as, MIPSI_OR, RID_TMP, RID_TMP, tmp); + emit_dst(as, MIPSI_XOR, tmp, left, right); + left = ra_alloc2(as, ir-1, RSET_GPR); + right = (left >> 8); left &= 255; + emit_dst(as, MIPSI_XOR, RID_TMP, left, right); +} +#endif + +/* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ + +/* Hiword op of a split 64 bit op. Previous op must be the loword op. */ +static void asm_hiop(ASMState *as, IRIns *ir) +{ +#if LJ_HASFFI + /* HIOP is marked as a store because it needs its own DCE logic. */ + int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ + if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; + if ((ir-1)->o == IR_CONV) { /* Conversions to/from 64 bit. */ + as->curins--; /* Always skip the CONV. */ + if (usehi || uselo) + asm_conv64(as, ir); + return; + } else if ((ir-1)->o < IR_EQ) { /* 64 bit integer comparisons. ORDER IR. */ + as->curins--; /* Always skip the loword comparison. */ + asm_comp64(as, ir); + return; + } else if ((ir-1)->o <= IR_NE) { /* 64 bit integer comparisons. ORDER IR. */ + as->curins--; /* Always skip the loword comparison. */ + asm_comp64eq(as, ir); + return; + } else if ((ir-1)->o == IR_XSTORE) { + as->curins--; /* Handle both stores here. */ + if ((ir-1)->r != RID_SINK) { + asm_xstore(as, ir, LJ_LE ? 4 : 0); + asm_xstore(as, ir-1, LJ_LE ? 0 : 4); + } + return; + } + if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ + switch ((ir-1)->o) { + case IR_ADD: as->curins--; asm_add64(as, ir); break; + case IR_SUB: as->curins--; asm_sub64(as, ir); break; + case IR_NEG: as->curins--; asm_neg64(as, ir); break; + case IR_CALLN: + case IR_CALLXS: + if (!uselo) + ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ + break; + case IR_CNEWI: + /* Nothing to do here. Handled by lo op itself. */ + break; + default: lua_assert(0); break; + } +#else + UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused without FFI. */ +#endif +} + +/* -- Stack handling ------------------------------------------------------ */ + +/* Check Lua stack size for overflow. Use exit handler as fallback. */ +static void asm_stack_check(ASMState *as, BCReg topslot, + IRIns *irp, RegSet allow, ExitNo exitno) +{ + /* Try to get an unused temp. register, otherwise spill/restore RID_RET*. */ + Reg tmp, pbase = irp ? (ra_hasreg(irp->r) ? irp->r : RID_TMP) : RID_BASE; + ExitNo oldsnap = as->snapno; + rset_clear(allow, pbase); + tmp = allow ? rset_pickbot(allow) : + (pbase == RID_RETHI ? RID_RETLO : RID_RETHI); + as->snapno = exitno; + asm_guard(as, MIPSI_BNE, RID_TMP, RID_ZERO); + as->snapno = oldsnap; + if (allow == RSET_EMPTY) /* Restore temp. register. */ + emit_tsi(as, MIPSI_LW, tmp, RID_SP, 0); + else + ra_modified(as, tmp); + emit_tsi(as, MIPSI_SLTIU, RID_TMP, RID_TMP, (int32_t)(8*topslot)); + emit_dst(as, MIPSI_SUBU, RID_TMP, tmp, pbase); + emit_tsi(as, MIPSI_LW, tmp, tmp, offsetof(lua_State, maxstack)); + if (pbase == RID_TMP) + emit_getgl(as, RID_TMP, jit_base); + emit_getgl(as, tmp, jit_L); + if (allow == RSET_EMPTY) /* Spill temp. register. */ + emit_tsi(as, MIPSI_SW, tmp, RID_SP, 0); +} + +/* Restore Lua stack from on-trace state. */ +static void asm_stack_restore(ASMState *as, SnapShot *snap) +{ + SnapEntry *map = &as->T->snapmap[snap->mapofs]; + SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; + MSize n, nent = snap->nent; + /* Store the value of all modified slots to the Lua stack. */ + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + BCReg s = snap_slot(sn); + int32_t ofs = 8*((int32_t)s-1); + IRRef ref = snap_ref(sn); + IRIns *ir = IR(ref); + if ((sn & SNAP_NORESTORE)) + continue; + if (irt_isnum(ir->t)) { + Reg src = ra_alloc1(as, ref, RSET_FPR); + emit_hsi(as, MIPSI_SDC1, src, RID_BASE, ofs); + } else { + Reg type; + RegSet allow = rset_exclude(RSET_GPR, RID_BASE); + lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || irt_isinteger(ir->t)); + if (!irt_ispri(ir->t)) { + Reg src = ra_alloc1(as, ref, allow); + rset_clear(allow, src); + emit_tsi(as, MIPSI_SW, src, RID_BASE, ofs+(LJ_BE?4:0)); + } + if ((sn & (SNAP_CONT|SNAP_FRAME))) { + if (s == 0) continue; /* Do not overwrite link to previous frame. */ + type = ra_allock(as, (int32_t)(*flinks--), allow); + } else { + type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); + } + emit_tsi(as, MIPSI_SW, type, RID_BASE, ofs+(LJ_BE?0:4)); + } + checkmclim(as); + } + lua_assert(map + nent == flinks); +} + +/* -- GC handling --------------------------------------------------------- */ + +/* Check GC threshold and do one or more GC steps. */ +static void asm_gc_check(ASMState *as) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; + IRRef args[2]; + MCLabel l_end; + Reg tmp; + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ + /* Assumes asm_snap_prep() already done. */ + asm_guard(as, MIPSI_BNE, RID_RET, RID_ZERO); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ASMREF_TMP2; /* MSize steps */ + asm_gencall(as, ci, args); + emit_tsi(as, MIPSI_ADDIU, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); + tmp = ra_releasetmp(as, ASMREF_TMP2); + emit_loadi(as, tmp, as->gcsteps); + /* Jump around GC step if GC total < GC threshold. */ + emit_branch(as, MIPSI_BNE, RID_TMP, RID_ZERO, l_end); + emit_dst(as, MIPSI_SLTU, RID_TMP, RID_TMP, tmp); + emit_getgl(as, tmp, gc.threshold); + emit_getgl(as, RID_TMP, gc.total); + as->gcsteps = 0; + checkmclim(as); +} + +/* -- Loop handling ------------------------------------------------------- */ + +/* Fixup the loop branch. */ +static void asm_loop_fixup(ASMState *as) +{ + MCode *p = as->mctop; + MCode *target = as->mcp; + p[-1] = MIPSI_NOP; + if (as->loopinv) { /* Inverted loop branch? */ + /* asm_guard already inverted the cond branch. Only patch the target. */ + p[-3] |= ((target-p+2) & 0x0000ffffu); + } else { + p[-2] = MIPSI_J|(((uintptr_t)target>>2)&0x03ffffffu); + } +} + +/* -- Head of trace ------------------------------------------------------- */ + +/* Coalesce BASE register for a root trace. */ +static void asm_head_root_base(ASMState *as) +{ + IRIns *ir = IR(REF_BASE); + Reg r = ir->r; + if (as->loopinv) as->mctop--; + if (ra_hasreg(r)) { + ra_free(as, r); + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) + ir->r = RID_INIT; /* No inheritance for modified BASE register. */ + if (r != RID_BASE) + emit_move(as, r, RID_BASE); + } +} + +/* Coalesce BASE register for a side trace. */ +static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) +{ + IRIns *ir = IR(REF_BASE); + Reg r = ir->r; + if (as->loopinv) as->mctop--; + if (ra_hasreg(r)) { + ra_free(as, r); + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) + ir->r = RID_INIT; /* No inheritance for modified BASE register. */ + if (irp->r == r) { + rset_clear(allow, r); /* Mark same BASE register as coalesced. */ + } else if (ra_hasreg(irp->r) && rset_test(as->freeset, irp->r)) { + rset_clear(allow, irp->r); + emit_move(as, r, irp->r); /* Move from coalesced parent reg. */ + } else { + emit_getgl(as, r, jit_base); /* Otherwise reload BASE. */ + } + } + return allow; +} + +/* -- Tail of trace ------------------------------------------------------- */ + +/* Fixup the tail code. */ +static void asm_tail_fixup(ASMState *as, TraceNo lnk) +{ + MCode *target = lnk ? traceref(as->J,lnk)->mcode : (MCode *)lj_vm_exit_interp; + int32_t spadj = as->T->spadjust; + MCode *p = as->mctop-1; + *p = spadj ? (MIPSI_ADDIU|MIPSF_T(RID_SP)|MIPSF_S(RID_SP)|spadj) : MIPSI_NOP; + p[-1] = MIPSI_J|(((uintptr_t)target>>2)&0x03ffffffu); +} + +/* Prepare tail of code. */ +static void asm_tail_prep(ASMState *as) +{ + as->mcp = as->mctop-2; /* Leave room for branch plus nop or stack adj. */ + as->invmcp = as->loopref ? as->mcp : NULL; +} + +/* -- Instruction dispatch ------------------------------------------------ */ + +/* Assemble a single instruction. */ +static void asm_ir(ASMState *as, IRIns *ir) +{ + switch ((IROp)ir->o) { + /* Miscellaneous ops. */ + case IR_LOOP: asm_loop(as); break; + case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; + case IR_USE: + ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; + case IR_PHI: asm_phi(as, ir); break; + case IR_HIOP: asm_hiop(as, ir); break; + case IR_GCSTEP: asm_gcstep(as, ir); break; + + /* Guarded assertions. */ + case IR_EQ: case IR_NE: asm_compeq(as, ir); break; + case IR_LT: case IR_GE: case IR_LE: case IR_GT: + case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: + case IR_ABC: + asm_comp(as, ir); + break; + + case IR_RETF: asm_retf(as, ir); break; + + /* Bit ops. */ + case IR_BNOT: asm_bitnot(as, ir); break; + case IR_BSWAP: asm_bitswap(as, ir); break; + + case IR_BAND: asm_bitop(as, ir, MIPSI_AND, MIPSI_ANDI); break; + case IR_BOR: asm_bitop(as, ir, MIPSI_OR, MIPSI_ORI); break; + case IR_BXOR: asm_bitop(as, ir, MIPSI_XOR, MIPSI_XORI); break; + + case IR_BSHL: asm_bitshift(as, ir, MIPSI_SLLV, MIPSI_SLL); break; + case IR_BSHR: asm_bitshift(as, ir, MIPSI_SRLV, MIPSI_SRL); break; + case IR_BSAR: asm_bitshift(as, ir, MIPSI_SRAV, MIPSI_SRA); break; + case IR_BROL: lua_assert(0); break; + case IR_BROR: asm_bitror(as, ir); break; + + /* Arithmetic ops. */ + case IR_ADD: asm_add(as, ir); break; + case IR_SUB: asm_sub(as, ir); break; + case IR_MUL: asm_mul(as, ir); break; + case IR_DIV: asm_fparith(as, ir, MIPSI_DIV_D); break; + case IR_MOD: asm_callid(as, ir, IRCALL_lj_vm_modi); break; + case IR_POW: asm_callid(as, ir, IRCALL_lj_vm_powi); break; + case IR_NEG: asm_neg(as, ir); break; + + case IR_ABS: asm_fpunary(as, ir, MIPSI_ABS_D); break; + case IR_ATAN2: asm_callid(as, ir, IRCALL_atan2); break; + case IR_LDEXP: asm_callid(as, ir, IRCALL_ldexp); break; + case IR_MIN: asm_min_max(as, ir, 0); break; + case IR_MAX: asm_min_max(as, ir, 1); break; + case IR_FPMATH: + if (ir->op2 == IRFPM_EXP2 && asm_fpjoin_pow(as, ir)) + break; + if (ir->op2 <= IRFPM_TRUNC) + asm_callround(as, ir, IRCALL_lj_vm_floor + ir->op2); + else if (ir->op2 == IRFPM_SQRT) + asm_fpunary(as, ir, MIPSI_SQRT_D); + else + asm_callid(as, ir, IRCALL_lj_vm_floor + ir->op2); + break; + + /* Overflow-checking arithmetic ops. */ + case IR_ADDOV: asm_arithov(as, ir); break; + case IR_SUBOV: asm_arithov(as, ir); break; + case IR_MULOV: asm_mulov(as, ir); break; + + /* Memory references. */ + case IR_AREF: asm_aref(as, ir); break; + case IR_HREF: asm_href(as, ir); break; + case IR_HREFK: asm_hrefk(as, ir); break; + case IR_NEWREF: asm_newref(as, ir); break; + case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; + case IR_FREF: asm_fref(as, ir); break; + case IR_STRREF: asm_strref(as, ir); break; + + /* Loads and stores. */ + case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + asm_ahuvload(as, ir); + break; + case IR_FLOAD: asm_fload(as, ir); break; + case IR_XLOAD: asm_xload(as, ir); break; + case IR_SLOAD: asm_sload(as, ir); break; + + case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; + case IR_FSTORE: asm_fstore(as, ir); break; + case IR_XSTORE: asm_xstore(as, ir, 0); break; + + /* Allocations. */ + case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; + case IR_TNEW: asm_tnew(as, ir); break; + case IR_TDUP: asm_tdup(as, ir); break; + case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; + + /* Write barriers. */ + case IR_TBAR: asm_tbar(as, ir); break; + case IR_OBAR: asm_obar(as, ir); break; + + /* Type conversions. */ + case IR_CONV: asm_conv(as, ir); break; + case IR_TOBIT: asm_tobit(as, ir); break; + case IR_TOSTR: asm_tostr(as, ir); break; + case IR_STRTO: asm_strto(as, ir); break; + + /* Calls. */ + case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; + case IR_CALLXS: asm_callx(as, ir); break; + case IR_CARG: break; + + default: + setintV(&as->J->errinfo, ir->o); + lj_trace_err_info(as->J, LJ_TRERR_NYIIR); + break; + } +} + +/* -- Trace setup --------------------------------------------------------- */ + +/* Ensure there are enough stack slots for call arguments. */ +static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + IRRef args[CCI_NARGS_MAX*2]; + uint32_t i, nargs = (int)CCI_NARGS(ci); + int nslots = 4, ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR; + asm_collectargs(as, ir, ci, args); + for (i = 0; i < nargs; i++) { + if (args[i] && irt_isfp(IR(args[i])->t) && + nfpr > 0 && !(ci->flags & CCI_VARARG)) { + nfpr--; + ngpr -= irt_isnum(IR(args[i])->t) ? 2 : 1; + } else if (args[i] && irt_isnum(IR(args[i])->t)) { + nfpr = 0; + ngpr = ngpr & ~1; + if (ngpr > 0) ngpr -= 2; else nslots = (nslots+3) & ~1; + } else { + nfpr = 0; + if (ngpr > 0) ngpr--; else nslots++; + } + } + if (nslots > as->evenspill) /* Leave room for args in stack slots. */ + as->evenspill = nslots; + return irt_isfp(ir->t) ? REGSP_HINT(RID_FPRET) : REGSP_HINT(RID_RET); +} + +static void asm_setup_target(ASMState *as) +{ + asm_sparejump_setup(as); + asm_exitstub_setup(as); +} + +/* -- Trace patching ------------------------------------------------------ */ + +/* Patch exit jumps of existing machine code to a new target. */ +void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) +{ + MCode *p = T->mcode; + MCode *pe = (MCode *)((char *)p + T->szmcode); + MCode *px = exitstub_trace_addr(T, exitno); + MCode *cstart = NULL, *cstop = NULL; + MCode *mcarea = lj_mcode_patch(J, p, 0); + MCode exitload = MIPSI_LI | MIPSF_T(RID_TMP) | exitno; + MCode tjump = MIPSI_J|(((uintptr_t)target>>2)&0x03ffffffu); + for (p++; p < pe; p++) { + if (*p == exitload) { /* Look for load of exit number. */ + if (((p[-1] ^ (px-p)) & 0xffffu) == 0) { /* Look for exitstub branch. */ + ptrdiff_t delta = target - p; + if (((delta + 0x8000) >> 16) == 0) { /* Patch in-range branch. */ + patchbranch: + p[-1] = (p[-1] & 0xffff0000u) | (delta & 0xffffu); + *p = MIPSI_NOP; /* Replace the load of the exit number. */ + cstop = p; + if (!cstart) cstart = p-1; + } else { /* Branch out of range. Use spare jump slot in mcarea. */ + int i; + for (i = 2; i < 2+MIPS_SPAREJUMP*2; i += 2) { + if (mcarea[i] == tjump) { + delta = mcarea+i - p; + goto patchbranch; + } else if (mcarea[i] == MIPSI_NOP) { + mcarea[i] = tjump; + cstart = mcarea+i; + delta = mcarea+i - p; + goto patchbranch; + } + } + /* Ignore jump slot overflow. Child trace is simply not attached. */ + } + } else if (p+1 == pe) { + /* Patch NOP after code for inverted loop branch. Use of J is ok. */ + lua_assert(p[1] == MIPSI_NOP); + p[1] = tjump; + *p = MIPSI_NOP; /* Replace the load of the exit number. */ + cstop = p+2; + if (!cstart) cstart = p+1; + } + } + } + if (cstart) lj_mcode_sync(cstart, cstop); + lj_mcode_patch(J, mcarea, 1); +} + + +``` + +`include/luajit-2.0.5/src/lj_asm_ppc.h`: + +```h +/* +** PPC IR assembler (SSA IR -> machine code). +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Register allocator extensions --------------------------------------- */ + +/* Allocate a register with a hint. */ +static Reg ra_hintalloc(ASMState *as, IRRef ref, Reg hint, RegSet allow) +{ + Reg r = IR(ref)->r; + if (ra_noreg(r)) { + if (!ra_hashint(r) && !iscrossref(as, ref)) + ra_sethint(IR(ref)->r, hint); /* Propagate register hint. */ + r = ra_allocref(as, ref, allow); + } + ra_noweak(as, r); + return r; +} + +/* Allocate two source registers for three-operand instructions. */ +static Reg ra_alloc2(ASMState *as, IRIns *ir, RegSet allow) +{ + IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); + Reg left = irl->r, right = irr->r; + if (ra_hasreg(left)) { + ra_noweak(as, left); + if (ra_noreg(right)) + right = ra_allocref(as, ir->op2, rset_exclude(allow, left)); + else + ra_noweak(as, right); + } else if (ra_hasreg(right)) { + ra_noweak(as, right); + left = ra_allocref(as, ir->op1, rset_exclude(allow, right)); + } else if (ra_hashint(right)) { + right = ra_allocref(as, ir->op2, allow); + left = ra_alloc1(as, ir->op1, rset_exclude(allow, right)); + } else { + left = ra_allocref(as, ir->op1, allow); + right = ra_alloc1(as, ir->op2, rset_exclude(allow, left)); + } + return left | (right << 8); +} + +/* -- Guard handling ------------------------------------------------------ */ + +/* Setup exit stubs after the end of each trace. */ +static void asm_exitstub_setup(ASMState *as, ExitNo nexits) +{ + ExitNo i; + MCode *mxp = as->mctop; + if (mxp - (nexits + 3 + MCLIM_REDZONE) < as->mclim) + asm_mclimit(as); + /* 1: mflr r0; bl ->vm_exit_handler; li r0, traceno; bl <1; bl <1; ... */ + for (i = nexits-1; (int32_t)i >= 0; i--) + *--mxp = PPCI_BL|(((-3-i)&0x00ffffffu)<<2); + *--mxp = PPCI_LI|PPCF_T(RID_TMP)|as->T->traceno; /* Read by exit handler. */ + mxp--; + *mxp = PPCI_BL|((((MCode *)(void *)lj_vm_exit_handler-mxp)&0x00ffffffu)<<2); + *--mxp = PPCI_MFLR|PPCF_T(RID_TMP); + as->mctop = mxp; +} + +static MCode *asm_exitstub_addr(ASMState *as, ExitNo exitno) +{ + /* Keep this in-sync with exitstub_trace_addr(). */ + return as->mctop + exitno + 3; +} + +/* Emit conditional branch to exit for guard. */ +static void asm_guardcc(ASMState *as, PPCCC cc) +{ + MCode *target = asm_exitstub_addr(as, as->snapno); + MCode *p = as->mcp; + if (LJ_UNLIKELY(p == as->invmcp)) { + as->loopinv = 1; + *p = PPCI_B | (((target-p) & 0x00ffffffu) << 2); + emit_condbranch(as, PPCI_BC, cc^4, p); + return; + } + emit_condbranch(as, PPCI_BC, cc, target); +} + +/* -- Operand fusion ------------------------------------------------------ */ + +/* Limit linear search to this distance. Avoids O(n^2) behavior. */ +#define CONFLICT_SEARCH_LIM 31 + +/* Check if there's no conflicting instruction between curins and ref. */ +static int noconflict(ASMState *as, IRRef ref, IROp conflict) +{ + IRIns *ir = as->ir; + IRRef i = as->curins; + if (i > ref + CONFLICT_SEARCH_LIM) + return 0; /* Give up, ref is too far away. */ + while (--i > ref) + if (ir[i].o == conflict) + return 0; /* Conflict found. */ + return 1; /* Ok, no conflict. */ +} + +/* Fuse the array base of colocated arrays. */ +static int32_t asm_fuseabase(ASMState *as, IRRef ref) +{ + IRIns *ir = IR(ref); + if (ir->o == IR_TNEW && ir->op1 <= LJ_MAX_COLOSIZE && + !neverfuse(as) && noconflict(as, ref, IR_NEWREF)) + return (int32_t)sizeof(GCtab); + return 0; +} + +/* Indicates load/store indexed is ok. */ +#define AHUREF_LSX ((int32_t)0x80000000) + +/* Fuse array/hash/upvalue reference into register+offset operand. */ +static Reg asm_fuseahuref(ASMState *as, IRRef ref, int32_t *ofsp, RegSet allow) +{ + IRIns *ir = IR(ref); + if (ra_noreg(ir->r)) { + if (ir->o == IR_AREF) { + if (mayfuse(as, ref)) { + if (irref_isk(ir->op2)) { + IRRef tab = IR(ir->op1)->op1; + int32_t ofs = asm_fuseabase(as, tab); + IRRef refa = ofs ? tab : ir->op1; + ofs += 8*IR(ir->op2)->i; + if (checki16(ofs)) { + *ofsp = ofs; + return ra_alloc1(as, refa, allow); + } + } + if (*ofsp == AHUREF_LSX) { + Reg base = ra_alloc1(as, ir->op1, allow); + Reg idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); + return base | (idx << 8); + } + } + } else if (ir->o == IR_HREFK) { + if (mayfuse(as, ref)) { + int32_t ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); + if (checki16(ofs)) { + *ofsp = ofs; + return ra_alloc1(as, ir->op1, allow); + } + } + } else if (ir->o == IR_UREFC) { + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + int32_t ofs = i32ptr(&gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.tv); + int32_t jgl = (intptr_t)J2G(as->J); + if ((uint32_t)(ofs-jgl) < 65536) { + *ofsp = ofs-jgl-32768; + return RID_JGL; + } else { + *ofsp = (int16_t)ofs; + return ra_allock(as, ofs-(int16_t)ofs, allow); + } + } + } + } + *ofsp = 0; + return ra_alloc1(as, ref, allow); +} + +/* Fuse XLOAD/XSTORE reference into load/store operand. */ +static void asm_fusexref(ASMState *as, PPCIns pi, Reg rt, IRRef ref, + RegSet allow, int32_t ofs) +{ + IRIns *ir = IR(ref); + Reg base; + if (ra_noreg(ir->r) && canfuse(as, ir)) { + if (ir->o == IR_ADD) { + int32_t ofs2; + if (irref_isk(ir->op2) && (ofs2 = ofs + IR(ir->op2)->i, checki16(ofs2))) { + ofs = ofs2; + ref = ir->op1; + } else if (ofs == 0) { + Reg right, left = ra_alloc2(as, ir, allow); + right = (left >> 8); left &= 255; + emit_fab(as, PPCI_LWZX | ((pi >> 20) & 0x780), rt, left, right); + return; + } + } else if (ir->o == IR_STRREF) { + lua_assert(ofs == 0); + ofs = (int32_t)sizeof(GCstr); + if (irref_isk(ir->op2)) { + ofs += IR(ir->op2)->i; + ref = ir->op1; + } else if (irref_isk(ir->op1)) { + ofs += IR(ir->op1)->i; + ref = ir->op2; + } else { + /* NYI: Fuse ADD with constant. */ + Reg tmp, right, left = ra_alloc2(as, ir, allow); + right = (left >> 8); left &= 255; + tmp = ra_scratch(as, rset_exclude(rset_exclude(allow, left), right)); + emit_fai(as, pi, rt, tmp, ofs); + emit_tab(as, PPCI_ADD, tmp, left, right); + return; + } + if (!checki16(ofs)) { + Reg left = ra_alloc1(as, ref, allow); + Reg right = ra_allock(as, ofs, rset_exclude(allow, left)); + emit_fab(as, PPCI_LWZX | ((pi >> 20) & 0x780), rt, left, right); + return; + } + } + } + base = ra_alloc1(as, ref, allow); + emit_fai(as, pi, rt, base, ofs); +} + +/* Fuse XLOAD/XSTORE reference into indexed-only load/store operand. */ +static void asm_fusexrefx(ASMState *as, PPCIns pi, Reg rt, IRRef ref, + RegSet allow) +{ + IRIns *ira = IR(ref); + Reg right, left; + if (canfuse(as, ira) && ira->o == IR_ADD && ra_noreg(ira->r)) { + left = ra_alloc2(as, ira, allow); + right = (left >> 8); left &= 255; + } else { + right = ra_alloc1(as, ref, allow); + left = RID_R0; + } + emit_tab(as, pi, rt, left, right); +} + +/* Fuse to multiply-add/sub instruction. */ +static int asm_fusemadd(ASMState *as, IRIns *ir, PPCIns pi, PPCIns pir) +{ + IRRef lref = ir->op1, rref = ir->op2; + IRIns *irm; + if (lref != rref && + ((mayfuse(as, lref) && (irm = IR(lref), irm->o == IR_MUL) && + ra_noreg(irm->r)) || + (mayfuse(as, rref) && (irm = IR(rref), irm->o == IR_MUL) && + (rref = lref, pi = pir, ra_noreg(irm->r))))) { + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg add = ra_alloc1(as, rref, RSET_FPR); + Reg right, left = ra_alloc2(as, irm, rset_exclude(RSET_FPR, add)); + right = (left >> 8); left &= 255; + emit_facb(as, pi, dest, left, right, add); + return 1; + } + return 0; +} + +/* -- Calls --------------------------------------------------------------- */ + +/* Generate a call to a C function. */ +static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) +{ + uint32_t n, nargs = CCI_NARGS(ci); + int32_t ofs = 8; + Reg gpr = REGARG_FIRSTGPR, fpr = REGARG_FIRSTFPR; + if ((void *)ci->func) + emit_call(as, (void *)ci->func); + for (n = 0; n < nargs; n++) { /* Setup args. */ + IRRef ref = args[n]; + if (ref) { + IRIns *ir = IR(ref); + if (irt_isfp(ir->t)) { + if (fpr <= REGARG_LASTFPR) { + lua_assert(rset_test(as->freeset, fpr)); /* Already evicted. */ + ra_leftov(as, fpr, ref); + fpr++; + } else { + Reg r = ra_alloc1(as, ref, RSET_FPR); + if (irt_isnum(ir->t)) ofs = (ofs + 4) & ~4; + emit_spstore(as, ir, r, ofs); + ofs += irt_isnum(ir->t) ? 8 : 4; + } + } else { + if (gpr <= REGARG_LASTGPR) { + lua_assert(rset_test(as->freeset, gpr)); /* Already evicted. */ + ra_leftov(as, gpr, ref); + gpr++; + } else { + Reg r = ra_alloc1(as, ref, RSET_GPR); + emit_spstore(as, ir, r, ofs); + ofs += 4; + } + } + } else { + if (gpr <= REGARG_LASTGPR) + gpr++; + else + ofs += 4; + } + checkmclim(as); + } + if ((ci->flags & CCI_VARARG)) /* Vararg calls need to know about FPR use. */ + emit_tab(as, fpr == REGARG_FIRSTFPR ? PPCI_CRXOR : PPCI_CREQV, 6, 6, 6); +} + +/* Setup result reg/sp for call. Evict scratch regs. */ +static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + RegSet drop = RSET_SCRATCH; + int hiop = ((ir+1)->o == IR_HIOP && !irt_isnil((ir+1)->t)); + if ((ci->flags & CCI_NOFPRCLOBBER)) + drop &= ~RSET_FPR; + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + if (hiop && ra_hasreg((ir+1)->r)) + rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ + ra_evictset(as, drop); /* Evictions must be performed first. */ + if (ra_used(ir)) { + lua_assert(!irt_ispri(ir->t)); + if (irt_isfp(ir->t)) { + if ((ci->flags & CCI_CASTU64)) { + /* Use spill slot or temp slots. */ + int32_t ofs = ir->s ? sps_scale(ir->s) : SPOFS_TMP; + Reg dest = ir->r; + if (ra_hasreg(dest)) { + ra_free(as, dest); + ra_modified(as, dest); + emit_fai(as, PPCI_LFD, dest, RID_SP, ofs); + } + emit_tai(as, PPCI_STW, RID_RETHI, RID_SP, ofs); + emit_tai(as, PPCI_STW, RID_RETLO, RID_SP, ofs+4); + } else { + ra_destreg(as, ir, RID_FPRET); + } + } else if (hiop) { + ra_destpair(as, ir); + } else { + ra_destreg(as, ir, RID_RET); + } + } +} + +static void asm_call(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX]; + const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; + asm_collectargs(as, ir, ci, args); + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +static void asm_callx(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX*2]; + CCallInfo ci; + IRRef func; + IRIns *irf; + ci.flags = asm_callx_flags(as, ir); + asm_collectargs(as, ir, &ci, args); + asm_setupresult(as, ir, &ci); + func = ir->op2; irf = IR(func); + if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } + if (irref_isk(func)) { /* Call to constant address. */ + ci.func = (ASMFunction)(void *)(irf->i); + } else { /* Need a non-argument register for indirect calls. */ + RegSet allow = RSET_GPR & ~RSET_RANGE(RID_R0, REGARG_LASTGPR+1); + Reg freg = ra_alloc1(as, func, allow); + *--as->mcp = PPCI_BCTRL; + *--as->mcp = PPCI_MTCTR | PPCF_T(freg); + ci.func = (ASMFunction)(void *)0; + } + asm_gencall(as, &ci, args); +} + +static void asm_callid(ASMState *as, IRIns *ir, IRCallID id) +{ + const CCallInfo *ci = &lj_ir_callinfo[id]; + IRRef args[2]; + args[0] = ir->op1; + args[1] = ir->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +/* -- Returns ------------------------------------------------------------- */ + +/* Return to lower frame. Guard that it goes to the right spot. */ +static void asm_retf(ASMState *as, IRIns *ir) +{ + Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); + void *pc = ir_kptr(IR(ir->op2)); + int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); + as->topslot -= (BCReg)delta; + if ((int32_t)as->topslot < 0) as->topslot = 0; + irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ + emit_setgl(as, base, jit_base); + emit_addptr(as, base, -8*delta); + asm_guardcc(as, CC_NE); + emit_ab(as, PPCI_CMPW, RID_TMP, + ra_allock(as, i32ptr(pc), rset_exclude(RSET_GPR, base))); + emit_tai(as, PPCI_LWZ, RID_TMP, base, -8); +} + +/* -- Type conversions ---------------------------------------------------- */ + +static void asm_tointg(ASMState *as, IRIns *ir, Reg left) +{ + RegSet allow = RSET_FPR; + Reg tmp = ra_scratch(as, rset_clear(allow, left)); + Reg fbias = ra_scratch(as, rset_clear(allow, tmp)); + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg hibias = ra_allock(as, 0x43300000, rset_exclude(RSET_GPR, dest)); + asm_guardcc(as, CC_NE); + emit_fab(as, PPCI_FCMPU, 0, tmp, left); + emit_fab(as, PPCI_FSUB, tmp, tmp, fbias); + emit_fai(as, PPCI_LFD, tmp, RID_SP, SPOFS_TMP); + emit_tai(as, PPCI_STW, RID_TMP, RID_SP, SPOFS_TMPLO); + emit_tai(as, PPCI_STW, hibias, RID_SP, SPOFS_TMPHI); + emit_asi(as, PPCI_XORIS, RID_TMP, dest, 0x8000); + emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); + emit_lsptr(as, PPCI_LFS, (fbias & 31), + (void *)lj_ir_k64_find(as->J, U64x(59800004,59800000)), + RSET_GPR); + emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); + emit_fb(as, PPCI_FCTIWZ, tmp, left); +} + +static void asm_tobit(ASMState *as, IRIns *ir) +{ + RegSet allow = RSET_FPR; + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, allow); + Reg right = ra_alloc1(as, ir->op2, rset_clear(allow, left)); + Reg tmp = ra_scratch(as, rset_clear(allow, right)); + emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); + emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); + emit_fab(as, PPCI_FADD, tmp, left, right); +} + +static void asm_conv(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); + int stfp = (st == IRT_NUM || st == IRT_FLOAT); + IRRef lref = ir->op1; + lua_assert(irt_type(ir->t) != st); + lua_assert(!(irt_isint64(ir->t) || + (st == IRT_I64 || st == IRT_U64))); /* Handled by SPLIT. */ + if (irt_isfp(ir->t)) { + Reg dest = ra_dest(as, ir, RSET_FPR); + if (stfp) { /* FP to FP conversion. */ + if (st == IRT_NUM) /* double -> float conversion. */ + emit_fb(as, PPCI_FRSP, dest, ra_alloc1(as, lref, RSET_FPR)); + else /* float -> double conversion is a no-op on PPC. */ + ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ + } else { /* Integer to FP conversion. */ + /* IRT_INT: Flip hibit, bias with 2^52, subtract 2^52+2^31. */ + /* IRT_U32: Bias with 2^52, subtract 2^52. */ + RegSet allow = RSET_GPR; + Reg left = ra_alloc1(as, lref, allow); + Reg hibias = ra_allock(as, 0x43300000, rset_clear(allow, left)); + Reg fbias = ra_scratch(as, rset_exclude(RSET_FPR, dest)); + const float *kbias; + if (irt_isfloat(ir->t)) emit_fb(as, PPCI_FRSP, dest, dest); + emit_fab(as, PPCI_FSUB, dest, dest, fbias); + emit_fai(as, PPCI_LFD, dest, RID_SP, SPOFS_TMP); + kbias = (const float *)lj_ir_k64_find(as->J, U64x(59800004,59800000)); + if (st == IRT_U32) kbias++; + emit_lsptr(as, PPCI_LFS, (fbias & 31), (void *)kbias, + rset_clear(allow, hibias)); + emit_tai(as, PPCI_STW, st == IRT_U32 ? left : RID_TMP, + RID_SP, SPOFS_TMPLO); + emit_tai(as, PPCI_STW, hibias, RID_SP, SPOFS_TMPHI); + if (st != IRT_U32) emit_asi(as, PPCI_XORIS, RID_TMP, left, 0x8000); + } + } else if (stfp) { /* FP to integer conversion. */ + if (irt_isguard(ir->t)) { + /* Checked conversions are only supported from number to int. */ + lua_assert(irt_isint(ir->t) && st == IRT_NUM); + asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, lref, RSET_FPR); + Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); + if (irt_isu32(ir->t)) { + /* Convert both x and x-2^31 to int and merge results. */ + Reg tmpi = ra_scratch(as, rset_exclude(RSET_GPR, dest)); + emit_asb(as, PPCI_OR, dest, dest, tmpi); /* Select with mask idiom. */ + emit_asb(as, PPCI_AND, tmpi, tmpi, RID_TMP); + emit_asb(as, PPCI_ANDC, dest, dest, RID_TMP); + emit_tai(as, PPCI_LWZ, tmpi, RID_SP, SPOFS_TMPLO); /* tmp = (int)(x) */ + emit_tai(as, PPCI_ADDIS, dest, dest, 0x8000); /* dest += 2^31 */ + emit_asb(as, PPCI_SRAWI, RID_TMP, dest, 31); /* mask = -(dest < 0) */ + emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); + emit_tai(as, PPCI_LWZ, dest, + RID_SP, SPOFS_TMPLO); /* dest = (int)(x-2^31) */ + emit_fb(as, PPCI_FCTIWZ, tmp, left); + emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); + emit_fb(as, PPCI_FCTIWZ, tmp, tmp); + emit_fab(as, PPCI_FSUB, tmp, left, tmp); + emit_lsptr(as, PPCI_LFS, (tmp & 31), + (void *)lj_ir_k64_find(as->J, U64x(4f000000,00000000)), + RSET_GPR); + } else { + emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); + emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); + emit_fb(as, PPCI_FCTIWZ, tmp, left); + } + } + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); + if ((ir->op2 & IRCONV_SEXT)) + emit_as(as, st == IRT_I8 ? PPCI_EXTSB : PPCI_EXTSH, dest, left); + else + emit_rot(as, PPCI_RLWINM, dest, left, 0, st == IRT_U8 ? 24 : 16, 31); + } else { /* 32/64 bit integer conversions. */ + /* Only need to handle 32/32 bit no-op (cast) on 32 bit archs. */ + ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ + } + } +} + +#if LJ_HASFFI +static void asm_conv64(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); + IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); + IRCallID id; + const CCallInfo *ci; + IRRef args[2]; + args[0] = ir->op1; + args[1] = (ir-1)->op1; + if (st == IRT_NUM || st == IRT_FLOAT) { + id = IRCALL_fp64_d2l + ((st == IRT_FLOAT) ? 2 : 0) + (dt - IRT_I64); + ir--; + } else { + id = IRCALL_fp64_l2d + ((dt == IRT_FLOAT) ? 2 : 0) + (st - IRT_I64); + } + ci = &lj_ir_callinfo[id]; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} +#endif + +static void asm_strto(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; + IRRef args[2]; + int32_t ofs; + RegSet drop = RSET_SCRATCH; + if (ra_hasreg(ir->r)) rset_set(drop, ir->r); /* Spill dest reg (if any). */ + ra_evictset(as, drop); + asm_guardcc(as, CC_EQ); + emit_ai(as, PPCI_CMPWI, RID_RET, 0); /* Test return status. */ + args[0] = ir->op1; /* GCstr *str */ + args[1] = ASMREF_TMP1; /* TValue *n */ + asm_gencall(as, ci, args); + /* Store the result to the spill slot or temp slots. */ + ofs = ir->s ? sps_scale(ir->s) : SPOFS_TMP; + emit_tai(as, PPCI_ADDI, ra_releasetmp(as, ASMREF_TMP1), RID_SP, ofs); +} + +/* Get pointer to TValue. */ +static void asm_tvptr(ASMState *as, Reg dest, IRRef ref) +{ + IRIns *ir = IR(ref); + if (irt_isnum(ir->t)) { + if (irref_isk(ref)) /* Use the number constant itself as a TValue. */ + ra_allockreg(as, i32ptr(ir_knum(ir)), dest); + else /* Otherwise force a spill and use the spill slot. */ + emit_tai(as, PPCI_ADDI, dest, RID_SP, ra_spill(as, ir)); + } else { + /* Otherwise use g->tmptv to hold the TValue. */ + RegSet allow = rset_exclude(RSET_GPR, dest); + Reg type; + emit_tai(as, PPCI_ADDI, dest, RID_JGL, offsetof(global_State, tmptv)-32768); + if (!irt_ispri(ir->t)) { + Reg src = ra_alloc1(as, ref, allow); + emit_setgl(as, src, tmptv.gcr); + } + type = ra_allock(as, irt_toitype(ir->t), allow); + emit_setgl(as, type, tmptv.it); + } +} + +static void asm_tostr(ASMState *as, IRIns *ir) +{ + IRRef args[2]; + args[0] = ASMREF_L; + as->gcsteps++; + if (irt_isnum(IR(ir->op1)->t) || (ir+1)->o == IR_HIOP) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; + args[1] = ASMREF_TMP1; /* const lua_Number * */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op1); + } else { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; + args[1] = ir->op1; /* int32_t k */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + } +} + +/* -- Memory references --------------------------------------------------- */ + +static void asm_aref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg idx, base; + if (irref_isk(ir->op2)) { + IRRef tab = IR(ir->op1)->op1; + int32_t ofs = asm_fuseabase(as, tab); + IRRef refa = ofs ? tab : ir->op1; + ofs += 8*IR(ir->op2)->i; + if (checki16(ofs)) { + base = ra_alloc1(as, refa, RSET_GPR); + emit_tai(as, PPCI_ADDI, dest, base, ofs); + return; + } + } + base = ra_alloc1(as, ir->op1, RSET_GPR); + idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); + emit_tab(as, PPCI_ADD, dest, RID_TMP, base); + emit_slwi(as, RID_TMP, idx, 3); +} + +/* Inlined hash lookup. Specialized for key type and for const keys. +** The equivalent C code is: +** Node *n = hashkey(t, key); +** do { +** if (lj_obj_equal(&n->key, key)) return &n->val; +** } while ((n = nextnode(n))); +** return niltv(L); +*/ +static void asm_href(ASMState *as, IRIns *ir, IROp merge) +{ + RegSet allow = RSET_GPR; + int destused = ra_used(ir); + Reg dest = ra_dest(as, ir, allow); + Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); + Reg key = RID_NONE, tmp1 = RID_TMP, tmp2; + Reg tisnum = RID_NONE, tmpnum = RID_NONE; + IRRef refkey = ir->op2; + IRIns *irkey = IR(refkey); + IRType1 kt = irkey->t; + uint32_t khash; + MCLabel l_end, l_loop, l_next; + + rset_clear(allow, tab); + if (irt_isnum(kt)) { + key = ra_alloc1(as, refkey, RSET_FPR); + tmpnum = ra_scratch(as, rset_exclude(RSET_FPR, key)); + tisnum = ra_allock(as, (int32_t)LJ_TISNUM, allow); + rset_clear(allow, tisnum); + } else if (!irt_ispri(kt)) { + key = ra_alloc1(as, refkey, allow); + rset_clear(allow, key); + } + tmp2 = ra_scratch(as, allow); + rset_clear(allow, tmp2); + + /* Key not found in chain: jump to exit (if merged) or load niltv. */ + l_end = emit_label(as); + as->invmcp = NULL; + if (merge == IR_NE) + asm_guardcc(as, CC_EQ); + else if (destused) + emit_loada(as, dest, niltvg(J2G(as->J))); + + /* Follow hash chain until the end. */ + l_loop = --as->mcp; + emit_ai(as, PPCI_CMPWI, dest, 0); + emit_tai(as, PPCI_LWZ, dest, dest, (int32_t)offsetof(Node, next)); + l_next = emit_label(as); + + /* Type and value comparison. */ + if (merge == IR_EQ) + asm_guardcc(as, CC_EQ); + else + emit_condbranch(as, PPCI_BC|PPCF_Y, CC_EQ, l_end); + if (irt_isnum(kt)) { + emit_fab(as, PPCI_FCMPU, 0, tmpnum, key); + emit_condbranch(as, PPCI_BC, CC_GE, l_next); + emit_ab(as, PPCI_CMPLW, tmp1, tisnum); + emit_fai(as, PPCI_LFD, tmpnum, dest, (int32_t)offsetof(Node, key.n)); + } else { + if (!irt_ispri(kt)) { + emit_ab(as, PPCI_CMPW, tmp2, key); + emit_condbranch(as, PPCI_BC, CC_NE, l_next); + } + emit_ai(as, PPCI_CMPWI, tmp1, irt_toitype(irkey->t)); + if (!irt_ispri(kt)) + emit_tai(as, PPCI_LWZ, tmp2, dest, (int32_t)offsetof(Node, key.gcr)); + } + emit_tai(as, PPCI_LWZ, tmp1, dest, (int32_t)offsetof(Node, key.it)); + *l_loop = PPCI_BC | PPCF_Y | PPCF_CC(CC_NE) | + (((char *)as->mcp-(char *)l_loop) & 0xffffu); + + /* Load main position relative to tab->node into dest. */ + khash = irref_isk(refkey) ? ir_khash(irkey) : 1; + if (khash == 0) { + emit_tai(as, PPCI_LWZ, dest, tab, (int32_t)offsetof(GCtab, node)); + } else { + Reg tmphash = tmp1; + if (irref_isk(refkey)) + tmphash = ra_allock(as, khash, allow); + emit_tab(as, PPCI_ADD, dest, dest, tmp1); + emit_tai(as, PPCI_MULLI, tmp1, tmp1, sizeof(Node)); + emit_asb(as, PPCI_AND, tmp1, tmp2, tmphash); + emit_tai(as, PPCI_LWZ, dest, tab, (int32_t)offsetof(GCtab, node)); + emit_tai(as, PPCI_LWZ, tmp2, tab, (int32_t)offsetof(GCtab, hmask)); + if (irref_isk(refkey)) { + /* Nothing to do. */ + } else if (irt_isstr(kt)) { + emit_tai(as, PPCI_LWZ, tmp1, key, (int32_t)offsetof(GCstr, hash)); + } else { /* Must match with hash*() in lj_tab.c. */ + emit_tab(as, PPCI_SUBF, tmp1, tmp2, tmp1); + emit_rotlwi(as, tmp2, tmp2, HASH_ROT3); + emit_asb(as, PPCI_XOR, tmp1, tmp1, tmp2); + emit_rotlwi(as, tmp1, tmp1, (HASH_ROT2+HASH_ROT1)&31); + emit_tab(as, PPCI_SUBF, tmp2, dest, tmp2); + if (irt_isnum(kt)) { + int32_t ofs = ra_spill(as, irkey); + emit_asb(as, PPCI_XOR, tmp2, tmp2, tmp1); + emit_rotlwi(as, dest, tmp1, HASH_ROT1); + emit_tab(as, PPCI_ADD, tmp1, tmp1, tmp1); + emit_tai(as, PPCI_LWZ, tmp2, RID_SP, ofs+4); + emit_tai(as, PPCI_LWZ, tmp1, RID_SP, ofs); + } else { + emit_asb(as, PPCI_XOR, tmp2, key, tmp1); + emit_rotlwi(as, dest, tmp1, HASH_ROT1); + emit_tai(as, PPCI_ADDI, tmp1, tmp2, HASH_BIAS); + emit_tai(as, PPCI_ADDIS, tmp2, key, (HASH_BIAS + 32768)>>16); + } + } + } +} + +static void asm_hrefk(ASMState *as, IRIns *ir) +{ + IRIns *kslot = IR(ir->op2); + IRIns *irkey = IR(kslot->op1); + int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); + int32_t kofs = ofs + (int32_t)offsetof(Node, key); + Reg dest = (ra_used(ir)||ofs > 32736) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; + Reg node = ra_alloc1(as, ir->op1, RSET_GPR); + Reg key = RID_NONE, type = RID_TMP, idx = node; + RegSet allow = rset_exclude(RSET_GPR, node); + lua_assert(ofs % sizeof(Node) == 0); + if (ofs > 32736) { + idx = dest; + rset_clear(allow, dest); + kofs = (int32_t)offsetof(Node, key); + } else if (ra_hasreg(dest)) { + emit_tai(as, PPCI_ADDI, dest, node, ofs); + } + asm_guardcc(as, CC_NE); + if (!irt_ispri(irkey->t)) { + key = ra_scratch(as, allow); + rset_clear(allow, key); + } + rset_clear(allow, type); + if (irt_isnum(irkey->t)) { + emit_cmpi(as, key, (int32_t)ir_knum(irkey)->u32.lo); + asm_guardcc(as, CC_NE); + emit_cmpi(as, type, (int32_t)ir_knum(irkey)->u32.hi); + } else { + if (ra_hasreg(key)) { + emit_cmpi(as, key, irkey->i); /* May use RID_TMP, i.e. type. */ + asm_guardcc(as, CC_NE); + } + emit_ai(as, PPCI_CMPWI, type, irt_toitype(irkey->t)); + } + if (ra_hasreg(key)) emit_tai(as, PPCI_LWZ, key, idx, kofs+4); + emit_tai(as, PPCI_LWZ, type, idx, kofs); + if (ofs > 32736) { + emit_tai(as, PPCI_ADDIS, dest, dest, (ofs + 32768) >> 16); + emit_tai(as, PPCI_ADDI, dest, node, ofs); + } +} + +static void asm_newref(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; + IRRef args[3]; + if (ir->r == RID_SINK) + return; + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ir->op1; /* GCtab *t */ + args[2] = ASMREF_TMP1; /* cTValue *key */ + asm_setupresult(as, ir, ci); /* TValue * */ + asm_gencall(as, ci, args); + asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op2); +} + +static void asm_uref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; + emit_lsptr(as, PPCI_LWZ, dest, v, RSET_GPR); + } else { + Reg uv = ra_scratch(as, RSET_GPR); + Reg func = ra_alloc1(as, ir->op1, RSET_GPR); + if (ir->o == IR_UREFC) { + asm_guardcc(as, CC_NE); + emit_ai(as, PPCI_CMPWI, RID_TMP, 1); + emit_tai(as, PPCI_ADDI, dest, uv, (int32_t)offsetof(GCupval, tv)); + emit_tai(as, PPCI_LBZ, RID_TMP, uv, (int32_t)offsetof(GCupval, closed)); + } else { + emit_tai(as, PPCI_LWZ, dest, uv, (int32_t)offsetof(GCupval, v)); + } + emit_tai(as, PPCI_LWZ, uv, func, + (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); + } +} + +static void asm_fref(ASMState *as, IRIns *ir) +{ + UNUSED(as); UNUSED(ir); + lua_assert(!ra_used(ir)); +} + +static void asm_strref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + IRRef ref = ir->op2, refk = ir->op1; + int32_t ofs = (int32_t)sizeof(GCstr); + Reg r; + if (irref_isk(ref)) { + IRRef tmp = refk; refk = ref; ref = tmp; + } else if (!irref_isk(refk)) { + Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); + IRIns *irr = IR(ir->op2); + if (ra_hasreg(irr->r)) { + ra_noweak(as, irr->r); + right = irr->r; + } else if (mayfuse(as, irr->op2) && + irr->o == IR_ADD && irref_isk(irr->op2) && + checki16(ofs + IR(irr->op2)->i)) { + ofs += IR(irr->op2)->i; + right = ra_alloc1(as, irr->op1, rset_exclude(RSET_GPR, left)); + } else { + right = ra_allocref(as, ir->op2, rset_exclude(RSET_GPR, left)); + } + emit_tai(as, PPCI_ADDI, dest, dest, ofs); + emit_tab(as, PPCI_ADD, dest, left, right); + return; + } + r = ra_alloc1(as, ref, RSET_GPR); + ofs += IR(refk)->i; + if (checki16(ofs)) + emit_tai(as, PPCI_ADDI, dest, r, ofs); + else + emit_tab(as, PPCI_ADD, dest, r, + ra_allock(as, ofs, rset_exclude(RSET_GPR, r))); +} + +/* -- Loads and stores ---------------------------------------------------- */ + +static PPCIns asm_fxloadins(IRIns *ir) +{ + switch (irt_type(ir->t)) { + case IRT_I8: return PPCI_LBZ; /* Needs sign-extension. */ + case IRT_U8: return PPCI_LBZ; + case IRT_I16: return PPCI_LHA; + case IRT_U16: return PPCI_LHZ; + case IRT_NUM: return PPCI_LFD; + case IRT_FLOAT: return PPCI_LFS; + default: return PPCI_LWZ; + } +} + +static PPCIns asm_fxstoreins(IRIns *ir) +{ + switch (irt_type(ir->t)) { + case IRT_I8: case IRT_U8: return PPCI_STB; + case IRT_I16: case IRT_U16: return PPCI_STH; + case IRT_NUM: return PPCI_STFD; + case IRT_FLOAT: return PPCI_STFS; + default: return PPCI_STW; + } +} + +static void asm_fload(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg idx = ra_alloc1(as, ir->op1, RSET_GPR); + PPCIns pi = asm_fxloadins(ir); + int32_t ofs; + if (ir->op2 == IRFL_TAB_ARRAY) { + ofs = asm_fuseabase(as, ir->op1); + if (ofs) { /* Turn the t->array load into an add for colocated arrays. */ + emit_tai(as, PPCI_ADDI, dest, idx, ofs); + return; + } + } + ofs = field_ofs[ir->op2]; + lua_assert(!irt_isi8(ir->t)); + emit_tai(as, pi, dest, idx, ofs); +} + +static void asm_fstore(ASMState *as, IRIns *ir) +{ + if (ir->r != RID_SINK) { + Reg src = ra_alloc1(as, ir->op2, RSET_GPR); + IRIns *irf = IR(ir->op1); + Reg idx = ra_alloc1(as, irf->op1, rset_exclude(RSET_GPR, src)); + int32_t ofs = field_ofs[irf->op2]; + PPCIns pi = asm_fxstoreins(ir); + emit_tai(as, pi, src, idx, ofs); + } +} + +static void asm_xload(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); + lua_assert(!(ir->op2 & IRXLOAD_UNALIGNED)); + if (irt_isi8(ir->t)) + emit_as(as, PPCI_EXTSB, dest, dest); + asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR, 0); +} + +static void asm_xstore(ASMState *as, IRIns *ir, int32_t ofs) +{ + IRIns *irb; + if (ir->r == RID_SINK) + return; + if (ofs == 0 && mayfuse(as, ir->op2) && (irb = IR(ir->op2))->o == IR_BSWAP && + ra_noreg(irb->r) && (irt_isint(ir->t) || irt_isu32(ir->t))) { + /* Fuse BSWAP with XSTORE to stwbrx. */ + Reg src = ra_alloc1(as, irb->op1, RSET_GPR); + asm_fusexrefx(as, PPCI_STWBRX, src, ir->op1, rset_exclude(RSET_GPR, src)); + } else { + Reg src = ra_alloc1(as, ir->op2, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); + asm_fusexref(as, asm_fxstoreins(ir), src, ir->op1, + rset_exclude(RSET_GPR, src), ofs); + } +} + +static void asm_ahuvload(ASMState *as, IRIns *ir) +{ + IRType1 t = ir->t; + Reg dest = RID_NONE, type = RID_TMP, tmp = RID_TMP, idx; + RegSet allow = RSET_GPR; + int32_t ofs = AHUREF_LSX; + if (ra_used(ir)) { + lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); + if (!irt_isnum(t)) ofs = 0; + dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); + rset_clear(allow, dest); + } + idx = asm_fuseahuref(as, ir->op1, &ofs, allow); + if (irt_isnum(t)) { + Reg tisnum = ra_allock(as, (int32_t)LJ_TISNUM, rset_exclude(allow, idx)); + asm_guardcc(as, CC_GE); + emit_ab(as, PPCI_CMPLW, type, tisnum); + if (ra_hasreg(dest)) { + if (ofs == AHUREF_LSX) { + tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, + (idx&255)), (idx>>8))); + emit_fab(as, PPCI_LFDX, dest, (idx&255), tmp); + } else { + emit_fai(as, PPCI_LFD, dest, idx, ofs); + } + } + } else { + asm_guardcc(as, CC_NE); + emit_ai(as, PPCI_CMPWI, type, irt_toitype(t)); + if (ra_hasreg(dest)) emit_tai(as, PPCI_LWZ, dest, idx, ofs+4); + } + if (ofs == AHUREF_LSX) { + emit_tab(as, PPCI_LWZX, type, (idx&255), tmp); + emit_slwi(as, tmp, (idx>>8), 3); + } else { + emit_tai(as, PPCI_LWZ, type, idx, ofs); + } +} + +static void asm_ahustore(ASMState *as, IRIns *ir) +{ + RegSet allow = RSET_GPR; + Reg idx, src = RID_NONE, type = RID_NONE; + int32_t ofs = AHUREF_LSX; + if (ir->r == RID_SINK) + return; + if (irt_isnum(ir->t)) { + src = ra_alloc1(as, ir->op2, RSET_FPR); + } else { + if (!irt_ispri(ir->t)) { + src = ra_alloc1(as, ir->op2, allow); + rset_clear(allow, src); + ofs = 0; + } + type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); + rset_clear(allow, type); + } + idx = asm_fuseahuref(as, ir->op1, &ofs, allow); + if (irt_isnum(ir->t)) { + if (ofs == AHUREF_LSX) { + emit_fab(as, PPCI_STFDX, src, (idx&255), RID_TMP); + emit_slwi(as, RID_TMP, (idx>>8), 3); + } else { + emit_fai(as, PPCI_STFD, src, idx, ofs); + } + } else { + if (ra_hasreg(src)) + emit_tai(as, PPCI_STW, src, idx, ofs+4); + if (ofs == AHUREF_LSX) { + emit_tab(as, PPCI_STWX, type, (idx&255), RID_TMP); + emit_slwi(as, RID_TMP, (idx>>8), 3); + } else { + emit_tai(as, PPCI_STW, type, idx, ofs); + } + } +} + +static void asm_sload(ASMState *as, IRIns *ir) +{ + int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 0 : 4); + IRType1 t = ir->t; + Reg dest = RID_NONE, type = RID_NONE, base; + RegSet allow = RSET_GPR; + lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ + lua_assert(irt_isguard(t) || !(ir->op2 & IRSLOAD_TYPECHECK)); + lua_assert(LJ_DUALNUM || + !irt_isint(t) || (ir->op2 & (IRSLOAD_CONVERT|IRSLOAD_FRAME))); + if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(t) && irt_isint(t)) { + dest = ra_scratch(as, RSET_FPR); + asm_tointg(as, ir, dest); + t.irt = IRT_NUM; /* Continue with a regular number type check. */ + } else if (ra_used(ir)) { + lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); + dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); + rset_clear(allow, dest); + base = ra_alloc1(as, REF_BASE, allow); + rset_clear(allow, base); + if ((ir->op2 & IRSLOAD_CONVERT)) { + if (irt_isint(t)) { + emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); + dest = ra_scratch(as, RSET_FPR); + emit_fai(as, PPCI_STFD, dest, RID_SP, SPOFS_TMP); + emit_fb(as, PPCI_FCTIWZ, dest, dest); + t.irt = IRT_NUM; /* Check for original type. */ + } else { + Reg tmp = ra_scratch(as, allow); + Reg hibias = ra_allock(as, 0x43300000, rset_clear(allow, tmp)); + Reg fbias = ra_scratch(as, rset_exclude(RSET_FPR, dest)); + emit_fab(as, PPCI_FSUB, dest, dest, fbias); + emit_fai(as, PPCI_LFD, dest, RID_SP, SPOFS_TMP); + emit_lsptr(as, PPCI_LFS, (fbias & 31), + (void *)lj_ir_k64_find(as->J, U64x(59800004,59800000)), + rset_clear(allow, hibias)); + emit_tai(as, PPCI_STW, tmp, RID_SP, SPOFS_TMPLO); + emit_tai(as, PPCI_STW, hibias, RID_SP, SPOFS_TMPHI); + emit_asi(as, PPCI_XORIS, tmp, tmp, 0x8000); + dest = tmp; + t.irt = IRT_INT; /* Check for original type. */ + } + } + goto dotypecheck; + } + base = ra_alloc1(as, REF_BASE, allow); + rset_clear(allow, base); +dotypecheck: + if (irt_isnum(t)) { + if ((ir->op2 & IRSLOAD_TYPECHECK)) { + Reg tisnum = ra_allock(as, (int32_t)LJ_TISNUM, allow); + asm_guardcc(as, CC_GE); + emit_ab(as, PPCI_CMPLW, RID_TMP, tisnum); + type = RID_TMP; + } + if (ra_hasreg(dest)) emit_fai(as, PPCI_LFD, dest, base, ofs-4); + } else { + if ((ir->op2 & IRSLOAD_TYPECHECK)) { + asm_guardcc(as, CC_NE); + emit_ai(as, PPCI_CMPWI, RID_TMP, irt_toitype(t)); + type = RID_TMP; + } + if (ra_hasreg(dest)) emit_tai(as, PPCI_LWZ, dest, base, ofs); + } + if (ra_hasreg(type)) emit_tai(as, PPCI_LWZ, type, base, ofs-4); +} + +/* -- Allocations --------------------------------------------------------- */ + +#if LJ_HASFFI +static void asm_cnew(ASMState *as, IRIns *ir) +{ + CTState *cts = ctype_ctsG(J2G(as->J)); + CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; + CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? + lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; + IRRef args[2]; + RegSet allow = (RSET_GPR & ~RSET_SCRATCH); + RegSet drop = RSET_SCRATCH; + lua_assert(sz != CTSIZE_INVALID); + + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ASMREF_TMP1; /* MSize size */ + as->gcsteps++; + + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + ra_evictset(as, drop); + if (ra_used(ir)) + ra_destreg(as, ir, RID_RET); /* GCcdata * */ + + /* Initialize immutable cdata object. */ + if (ir->o == IR_CNEWI) { + int32_t ofs = sizeof(GCcdata); + lua_assert(sz == 4 || sz == 8); + if (sz == 8) { + ofs += 4; + lua_assert((ir+1)->o == IR_HIOP); + } + for (;;) { + Reg r = ra_alloc1(as, ir->op2, allow); + emit_tai(as, PPCI_STW, r, RID_RET, ofs); + rset_clear(allow, r); + if (ofs == sizeof(GCcdata)) break; + ofs -= 4; ir++; + } + } + /* Initialize gct and ctypeid. lj_mem_newgco() already sets marked. */ + emit_tai(as, PPCI_STB, RID_RET+1, RID_RET, offsetof(GCcdata, gct)); + emit_tai(as, PPCI_STH, RID_TMP, RID_RET, offsetof(GCcdata, ctypeid)); + emit_ti(as, PPCI_LI, RID_RET+1, ~LJ_TCDATA); + emit_ti(as, PPCI_LI, RID_TMP, ctypeid); /* Lower 16 bit used. Sign-ext ok. */ + asm_gencall(as, ci, args); + ra_allockreg(as, (int32_t)(sz+sizeof(GCcdata)), + ra_releasetmp(as, ASMREF_TMP1)); +} +#else +#define asm_cnew(as, ir) ((void)0) +#endif + +/* -- Write barriers ------------------------------------------------------ */ + +static void asm_tbar(ASMState *as, IRIns *ir) +{ + Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); + Reg mark = ra_scratch(as, rset_exclude(RSET_GPR, tab)); + Reg link = RID_TMP; + MCLabel l_end = emit_label(as); + emit_tai(as, PPCI_STW, link, tab, (int32_t)offsetof(GCtab, gclist)); + emit_tai(as, PPCI_STB, mark, tab, (int32_t)offsetof(GCtab, marked)); + emit_setgl(as, tab, gc.grayagain); + lua_assert(LJ_GC_BLACK == 0x04); + emit_rot(as, PPCI_RLWINM, mark, mark, 0, 30, 28); /* Clear black bit. */ + emit_getgl(as, link, gc.grayagain); + emit_condbranch(as, PPCI_BC|PPCF_Y, CC_EQ, l_end); + emit_asi(as, PPCI_ANDIDOT, RID_TMP, mark, LJ_GC_BLACK); + emit_tai(as, PPCI_LBZ, mark, tab, (int32_t)offsetof(GCtab, marked)); +} + +static void asm_obar(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; + IRRef args[2]; + MCLabel l_end; + Reg obj, val, tmp; + /* No need for other object barriers (yet). */ + lua_assert(IR(ir->op1)->o == IR_UREFC); + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ir->op1; /* TValue *tv */ + asm_gencall(as, ci, args); + emit_tai(as, PPCI_ADDI, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); + obj = IR(ir->op1)->r; + tmp = ra_scratch(as, rset_exclude(RSET_GPR, obj)); + emit_condbranch(as, PPCI_BC|PPCF_Y, CC_EQ, l_end); + emit_asi(as, PPCI_ANDIDOT, tmp, tmp, LJ_GC_BLACK); + emit_condbranch(as, PPCI_BC, CC_EQ, l_end); + emit_asi(as, PPCI_ANDIDOT, RID_TMP, RID_TMP, LJ_GC_WHITES); + val = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, obj)); + emit_tai(as, PPCI_LBZ, tmp, obj, + (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); + emit_tai(as, PPCI_LBZ, RID_TMP, val, (int32_t)offsetof(GChead, marked)); +} + +/* -- Arithmetic and logic operations ------------------------------------- */ + +static void asm_fparith(ASMState *as, IRIns *ir, PPCIns pi) +{ + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = (left >> 8); left &= 255; + if (pi == PPCI_FMUL) + emit_fac(as, pi, dest, left, right); + else + emit_fab(as, pi, dest, left, right); +} + +static void asm_fpunary(ASMState *as, IRIns *ir, PPCIns pi) +{ + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg left = ra_hintalloc(as, ir->op1, dest, RSET_FPR); + emit_fb(as, pi, dest, left); +} + +static int asm_fpjoin_pow(ASMState *as, IRIns *ir) +{ + IRIns *irp = IR(ir->op1); + if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { + IRIns *irpp = IR(irp->op1); + if (irpp == ir-2 && irpp->o == IR_FPMATH && + irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_pow]; + IRRef args[2]; + args[0] = irpp->op1; + args[1] = irp->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); + return 1; + } + } + return 0; +} + +static void asm_add(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + if (!asm_fusemadd(as, ir, PPCI_FMADD, PPCI_FMADD)) + asm_fparith(as, ir, PPCI_FADD); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + PPCIns pi; + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (checki16(k)) { + pi = PPCI_ADDI; + /* May fail due to spills/restores above, but simplifies the logic. */ + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + pi = PPCI_ADDICDOT; + } + emit_tai(as, pi, dest, left, k); + return; + } else if ((k & 0xffff) == 0) { + emit_tai(as, PPCI_ADDIS, dest, left, (k >> 16)); + return; + } else if (!as->sectref) { + emit_tai(as, PPCI_ADDIS, dest, dest, (k + 32768) >> 16); + emit_tai(as, PPCI_ADDI, dest, left, k); + return; + } + } + pi = PPCI_ADD; + /* May fail due to spills/restores above, but simplifies the logic. */ + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + pi |= PPCF_DOT; + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_tab(as, pi, dest, left, right); + } +} + +static void asm_sub(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + if (!asm_fusemadd(as, ir, PPCI_FMSUB, PPCI_FNMSUB)) + asm_fparith(as, ir, PPCI_FSUB); + } else { + PPCIns pi = PPCI_SUBF; + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left, right; + if (irref_isk(ir->op1)) { + int32_t k = IR(ir->op1)->i; + if (checki16(k)) { + right = ra_alloc1(as, ir->op2, RSET_GPR); + emit_tai(as, PPCI_SUBFIC, dest, right, k); + return; + } + } + /* May fail due to spills/restores above, but simplifies the logic. */ + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + pi |= PPCF_DOT; + } + left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_tab(as, pi, dest, right, left); /* Subtract right _from_ left. */ + } +} + +static void asm_mul(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + asm_fparith(as, ir, PPCI_FMUL); + } else { + PPCIns pi = PPCI_MULLW; + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (checki16(k)) { + emit_tai(as, PPCI_MULLI, dest, left, k); + return; + } + } + /* May fail due to spills/restores above, but simplifies the logic. */ + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + pi |= PPCF_DOT; + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_tab(as, pi, dest, left, right); + } +} + +static void asm_neg(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + asm_fpunary(as, ir, PPCI_FNEG); + } else { + Reg dest, left; + PPCIns pi = PPCI_NEG; + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + pi |= PPCF_DOT; + } + dest = ra_dest(as, ir, RSET_GPR); + left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + emit_tab(as, pi, dest, left, 0); + } +} + +static void asm_arithov(ASMState *as, IRIns *ir, PPCIns pi) +{ + Reg dest, left, right; + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + } + asm_guardcc(as, CC_SO); + dest = ra_dest(as, ir, RSET_GPR); + left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + if (pi == PPCI_SUBFO) { Reg tmp = left; left = right; right = tmp; } + emit_tab(as, pi|PPCF_DOT, dest, left, right); +} + +#if LJ_HASFFI +static void asm_add64(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); + PPCIns pi = PPCI_ADDE; + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (k == 0) + pi = PPCI_ADDZE; + else if (k == -1) + pi = PPCI_ADDME; + else + goto needright; + right = 0; + } else { + needright: + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + } + emit_tab(as, pi, dest, left, right); + ir--; + dest = ra_dest(as, ir, RSET_GPR); + left = ra_alloc1(as, ir->op1, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (checki16(k)) { + emit_tai(as, PPCI_ADDIC, dest, left, k); + return; + } + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_tab(as, PPCI_ADDC, dest, left, right); +} + +static void asm_sub64(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left, right = ra_alloc1(as, ir->op2, RSET_GPR); + PPCIns pi = PPCI_SUBFE; + if (irref_isk(ir->op1)) { + int32_t k = IR(ir->op1)->i; + if (k == 0) + pi = PPCI_SUBFZE; + else if (k == -1) + pi = PPCI_SUBFME; + else + goto needleft; + left = 0; + } else { + needleft: + left = ra_alloc1(as, ir->op1, rset_exclude(RSET_GPR, right)); + } + emit_tab(as, pi, dest, right, left); /* Subtract right _from_ left. */ + ir--; + dest = ra_dest(as, ir, RSET_GPR); + right = ra_alloc1(as, ir->op2, RSET_GPR); + if (irref_isk(ir->op1)) { + int32_t k = IR(ir->op1)->i; + if (checki16(k)) { + emit_tai(as, PPCI_SUBFIC, dest, right, k); + return; + } + } + left = ra_alloc1(as, ir->op1, rset_exclude(RSET_GPR, right)); + emit_tab(as, PPCI_SUBFC, dest, right, left); +} + +static void asm_neg64(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + emit_tab(as, PPCI_SUBFZE, dest, left, 0); + ir--; + dest = ra_dest(as, ir, RSET_GPR); + left = ra_alloc1(as, ir->op1, RSET_GPR); + emit_tai(as, PPCI_SUBFIC, dest, left, 0); +} +#endif + +static void asm_bitnot(ASMState *as, IRIns *ir) +{ + Reg dest, left, right; + PPCIns pi = PPCI_NOR; + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + pi |= PPCF_DOT; + } + dest = ra_dest(as, ir, RSET_GPR); + if (mayfuse(as, ir->op1)) { + IRIns *irl = IR(ir->op1); + if (irl->o == IR_BAND) + pi ^= (PPCI_NOR ^ PPCI_NAND); + else if (irl->o == IR_BXOR) + pi ^= (PPCI_NOR ^ PPCI_EQV); + else if (irl->o != IR_BOR) + goto nofuse; + left = ra_hintalloc(as, irl->op1, dest, RSET_GPR); + right = ra_alloc1(as, irl->op2, rset_exclude(RSET_GPR, left)); + } else { +nofuse: + left = right = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + } + emit_asb(as, pi, dest, left, right); +} + +static void asm_bitswap(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + IRIns *irx; + if (mayfuse(as, ir->op1) && (irx = IR(ir->op1))->o == IR_XLOAD && + ra_noreg(irx->r) && (irt_isint(irx->t) || irt_isu32(irx->t))) { + /* Fuse BSWAP with XLOAD to lwbrx. */ + asm_fusexrefx(as, PPCI_LWBRX, dest, irx->op1, RSET_GPR); + } else { + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + Reg tmp = dest; + if (tmp == left) { + tmp = RID_TMP; + emit_mr(as, dest, RID_TMP); + } + emit_rot(as, PPCI_RLWIMI, tmp, left, 24, 16, 23); + emit_rot(as, PPCI_RLWIMI, tmp, left, 24, 0, 7); + emit_rotlwi(as, tmp, left, 8); + } +} + +static void asm_bitop(ASMState *as, IRIns *ir, PPCIns pi, PPCIns pik) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + Reg tmp = left; + if ((checku16(k) || (k & 0xffff) == 0) || (tmp = dest, !as->sectref)) { + if (!checku16(k)) { + emit_asi(as, pik ^ (PPCI_ORI ^ PPCI_ORIS), dest, tmp, (k >> 16)); + if ((k & 0xffff) == 0) return; + } + emit_asi(as, pik, dest, left, k); + return; + } + } + /* May fail due to spills/restores above, but simplifies the logic. */ + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + pi |= PPCF_DOT; + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_asb(as, pi, dest, left, right); +} + +/* Fuse BAND with contiguous bitmask and a shift to rlwinm. */ +static void asm_fuseandsh(ASMState *as, PPCIns pi, int32_t mask, IRRef ref) +{ + IRIns *ir; + Reg left; + if (mayfuse(as, ref) && (ir = IR(ref), ra_noreg(ir->r)) && + irref_isk(ir->op2) && ir->o >= IR_BSHL && ir->o <= IR_BROR) { + int32_t sh = (IR(ir->op2)->i & 31); + switch (ir->o) { + case IR_BSHL: + if ((mask & ((1u<>sh))) goto nofuse; + sh = ((32-sh)&31); + break; + case IR_BROL: + break; + default: + goto nofuse; + } + left = ra_alloc1(as, ir->op1, RSET_GPR); + *--as->mcp = pi | PPCF_T(left) | PPCF_B(sh); + return; + } +nofuse: + left = ra_alloc1(as, ref, RSET_GPR); + *--as->mcp = pi | PPCF_T(left); +} + +static void asm_bitand(ASMState *as, IRIns *ir) +{ + Reg dest, left, right; + IRRef lref = ir->op1; + PPCIns dot = 0; + IRRef op2; + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + dot = PPCF_DOT; + } + dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (k) { + /* First check for a contiguous bitmask as used by rlwinm. */ + uint32_t s1 = lj_ffs((uint32_t)k); + uint32_t k1 = ((uint32_t)k >> s1); + if ((k1 & (k1+1)) == 0) { + asm_fuseandsh(as, PPCI_RLWINM|dot | PPCF_A(dest) | + PPCF_MB(31-lj_fls((uint32_t)k)) | PPCF_ME(31-s1), + k, lref); + return; + } + if (~(uint32_t)k) { + uint32_t s2 = lj_ffs(~(uint32_t)k); + uint32_t k2 = (~(uint32_t)k >> s2); + if ((k2 & (k2+1)) == 0) { + asm_fuseandsh(as, PPCI_RLWINM|dot | PPCF_A(dest) | + PPCF_MB(32-s2) | PPCF_ME(30-lj_fls(~(uint32_t)k)), + k, lref); + return; + } + } + } + if (checku16(k)) { + left = ra_alloc1(as, lref, RSET_GPR); + emit_asi(as, PPCI_ANDIDOT, dest, left, k); + return; + } else if ((k & 0xffff) == 0) { + left = ra_alloc1(as, lref, RSET_GPR); + emit_asi(as, PPCI_ANDISDOT, dest, left, (k >> 16)); + return; + } + } + op2 = ir->op2; + if (mayfuse(as, op2) && IR(op2)->o == IR_BNOT && ra_noreg(IR(op2)->r)) { + dot ^= (PPCI_AND ^ PPCI_ANDC); + op2 = IR(op2)->op1; + } + left = ra_hintalloc(as, lref, dest, RSET_GPR); + right = ra_alloc1(as, op2, rset_exclude(RSET_GPR, left)); + emit_asb(as, PPCI_AND ^ dot, dest, left, right); +} + +static void asm_bitshift(ASMState *as, IRIns *ir, PPCIns pi, PPCIns pik) +{ + Reg dest, left; + Reg dot = 0; + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + dot = PPCF_DOT; + } + dest = ra_dest(as, ir, RSET_GPR); + left = ra_alloc1(as, ir->op1, RSET_GPR); + if (irref_isk(ir->op2)) { /* Constant shifts. */ + int32_t shift = (IR(ir->op2)->i & 31); + if (pik == 0) /* SLWI */ + emit_rot(as, PPCI_RLWINM|dot, dest, left, shift, 0, 31-shift); + else if (pik == 1) /* SRWI */ + emit_rot(as, PPCI_RLWINM|dot, dest, left, (32-shift)&31, shift, 31); + else + emit_asb(as, pik|dot, dest, left, shift); + } else { + Reg right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_asb(as, pi|dot, dest, left, right); + } +} + +static void asm_min_max(ASMState *as, IRIns *ir, int ismax) +{ + if (irt_isnum(ir->t)) { + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg tmp = dest; + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = (left >> 8); left &= 255; + if (tmp == left || tmp == right) + tmp = ra_scratch(as, rset_exclude(rset_exclude(rset_exclude(RSET_FPR, + dest), left), right)); + emit_facb(as, PPCI_FSEL, dest, tmp, + ismax ? left : right, ismax ? right : left); + emit_fab(as, PPCI_FSUB, tmp, left, right); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg tmp1 = RID_TMP, tmp2 = dest; + Reg right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + if (tmp2 == left || tmp2 == right) + tmp2 = ra_scratch(as, rset_exclude(rset_exclude(rset_exclude(RSET_GPR, + dest), left), right)); + emit_tab(as, PPCI_ADD, dest, tmp2, right); + emit_asb(as, ismax ? PPCI_ANDC : PPCI_AND, tmp2, tmp2, tmp1); + emit_tab(as, PPCI_SUBFE, tmp1, tmp1, tmp1); + emit_tab(as, PPCI_SUBFC, tmp2, tmp2, tmp1); + emit_asi(as, PPCI_XORIS, tmp2, right, 0x8000); + emit_asi(as, PPCI_XORIS, tmp1, left, 0x8000); + } +} + +/* -- Comparisons --------------------------------------------------------- */ + +#define CC_UNSIGNED 0x08 /* Unsigned integer comparison. */ +#define CC_TWO 0x80 /* Check two flags for FP comparison. */ + +/* Map of comparisons to flags. ORDER IR. */ +static const uint8_t asm_compmap[IR_ABC+1] = { + /* op int cc FP cc */ + /* LT */ CC_GE + (CC_GE<<4), + /* GE */ CC_LT + (CC_LE<<4) + CC_TWO, + /* LE */ CC_GT + (CC_GE<<4) + CC_TWO, + /* GT */ CC_LE + (CC_LE<<4), + /* ULT */ CC_GE + CC_UNSIGNED + (CC_GT<<4) + CC_TWO, + /* UGE */ CC_LT + CC_UNSIGNED + (CC_LT<<4), + /* ULE */ CC_GT + CC_UNSIGNED + (CC_GT<<4), + /* UGT */ CC_LE + CC_UNSIGNED + (CC_LT<<4) + CC_TWO, + /* EQ */ CC_NE + (CC_NE<<4), + /* NE */ CC_EQ + (CC_EQ<<4), + /* ABC */ CC_LE + CC_UNSIGNED + (CC_LT<<4) + CC_TWO /* Same as UGT. */ +}; + +static void asm_intcomp_(ASMState *as, IRRef lref, IRRef rref, Reg cr, PPCCC cc) +{ + Reg right, left = ra_alloc1(as, lref, RSET_GPR); + if (irref_isk(rref)) { + int32_t k = IR(rref)->i; + if ((cc & CC_UNSIGNED) == 0) { /* Signed comparison with constant. */ + if (checki16(k)) { + emit_tai(as, PPCI_CMPWI, cr, left, k); + /* Signed comparison with zero and referencing previous ins? */ + if (k == 0 && lref == as->curins-1) + as->flagmcp = as->mcp; /* Allow elimination of the compare. */ + return; + } else if ((cc & 3) == (CC_EQ & 3)) { /* Use CMPLWI for EQ or NE. */ + if (checku16(k)) { + emit_tai(as, PPCI_CMPLWI, cr, left, k); + return; + } else if (!as->sectref && ra_noreg(IR(rref)->r)) { + emit_tai(as, PPCI_CMPLWI, cr, RID_TMP, k); + emit_asi(as, PPCI_XORIS, RID_TMP, left, (k >> 16)); + return; + } + } + } else { /* Unsigned comparison with constant. */ + if (checku16(k)) { + emit_tai(as, PPCI_CMPLWI, cr, left, k); + return; + } + } + } + right = ra_alloc1(as, rref, rset_exclude(RSET_GPR, left)); + emit_tab(as, (cc & CC_UNSIGNED) ? PPCI_CMPLW : PPCI_CMPW, cr, left, right); +} + +static void asm_comp(ASMState *as, IRIns *ir) +{ + PPCCC cc = asm_compmap[ir->o]; + if (irt_isnum(ir->t)) { + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = (left >> 8); left &= 255; + asm_guardcc(as, (cc >> 4)); + if ((cc & CC_TWO)) + emit_tab(as, PPCI_CROR, ((cc>>4)&3), ((cc>>4)&3), (CC_EQ&3)); + emit_fab(as, PPCI_FCMPU, 0, left, right); + } else { + IRRef lref = ir->op1, rref = ir->op2; + if (irref_isk(lref) && !irref_isk(rref)) { + /* Swap constants to the right (only for ABC). */ + IRRef tmp = lref; lref = rref; rref = tmp; + if ((cc & 2) == 0) cc ^= 1; /* LT <-> GT, LE <-> GE */ + } + asm_guardcc(as, cc); + asm_intcomp_(as, lref, rref, 0, cc); + } +} + +#if LJ_HASFFI +/* 64 bit integer comparisons. */ +static void asm_comp64(ASMState *as, IRIns *ir) +{ + PPCCC cc = asm_compmap[(ir-1)->o]; + if ((cc&3) == (CC_EQ&3)) { + asm_guardcc(as, cc); + emit_tab(as, (cc&4) ? PPCI_CRAND : PPCI_CROR, + (CC_EQ&3), (CC_EQ&3), 4+(CC_EQ&3)); + } else { + asm_guardcc(as, CC_EQ); + emit_tab(as, PPCI_CROR, (CC_EQ&3), (CC_EQ&3), ((cc^~(cc>>2))&1)); + emit_tab(as, (cc&4) ? PPCI_CRAND : PPCI_CRANDC, + (CC_EQ&3), (CC_EQ&3), 4+(cc&3)); + } + /* Loword comparison sets cr1 and is unsigned, except for equality. */ + asm_intcomp_(as, (ir-1)->op1, (ir-1)->op2, 4, + cc | ((cc&3) == (CC_EQ&3) ? 0 : CC_UNSIGNED)); + /* Hiword comparison sets cr0. */ + asm_intcomp_(as, ir->op1, ir->op2, 0, cc); + as->flagmcp = NULL; /* Doesn't work here. */ +} +#endif + +/* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ + +/* Hiword op of a split 64 bit op. Previous op must be the loword op. */ +static void asm_hiop(ASMState *as, IRIns *ir) +{ +#if LJ_HASFFI + /* HIOP is marked as a store because it needs its own DCE logic. */ + int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ + if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; + if ((ir-1)->o == IR_CONV) { /* Conversions to/from 64 bit. */ + as->curins--; /* Always skip the CONV. */ + if (usehi || uselo) + asm_conv64(as, ir); + return; + } else if ((ir-1)->o <= IR_NE) { /* 64 bit integer comparisons. ORDER IR. */ + as->curins--; /* Always skip the loword comparison. */ + asm_comp64(as, ir); + return; + } else if ((ir-1)->o == IR_XSTORE) { + as->curins--; /* Handle both stores here. */ + if ((ir-1)->r != RID_SINK) { + asm_xstore(as, ir, 0); + asm_xstore(as, ir-1, 4); + } + return; + } + if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ + switch ((ir-1)->o) { + case IR_ADD: as->curins--; asm_add64(as, ir); break; + case IR_SUB: as->curins--; asm_sub64(as, ir); break; + case IR_NEG: as->curins--; asm_neg64(as, ir); break; + case IR_CALLN: + case IR_CALLXS: + if (!uselo) + ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ + break; + case IR_CNEWI: + /* Nothing to do here. Handled by lo op itself. */ + break; + default: lua_assert(0); break; + } +#else + UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused without FFI. */ +#endif +} + +/* -- Stack handling ------------------------------------------------------ */ + +/* Check Lua stack size for overflow. Use exit handler as fallback. */ +static void asm_stack_check(ASMState *as, BCReg topslot, + IRIns *irp, RegSet allow, ExitNo exitno) +{ + /* Try to get an unused temp. register, otherwise spill/restore RID_RET*. */ + Reg tmp, pbase = irp ? (ra_hasreg(irp->r) ? irp->r : RID_TMP) : RID_BASE; + rset_clear(allow, pbase); + tmp = allow ? rset_pickbot(allow) : + (pbase == RID_RETHI ? RID_RETLO : RID_RETHI); + emit_condbranch(as, PPCI_BC, CC_LT, asm_exitstub_addr(as, exitno)); + if (allow == RSET_EMPTY) /* Restore temp. register. */ + emit_tai(as, PPCI_LWZ, tmp, RID_SP, SPOFS_TMPW); + else + ra_modified(as, tmp); + emit_ai(as, PPCI_CMPLWI, RID_TMP, (int32_t)(8*topslot)); + emit_tab(as, PPCI_SUBF, RID_TMP, pbase, tmp); + emit_tai(as, PPCI_LWZ, tmp, tmp, offsetof(lua_State, maxstack)); + if (pbase == RID_TMP) + emit_getgl(as, RID_TMP, jit_base); + emit_getgl(as, tmp, jit_L); + if (allow == RSET_EMPTY) /* Spill temp. register. */ + emit_tai(as, PPCI_STW, tmp, RID_SP, SPOFS_TMPW); +} + +/* Restore Lua stack from on-trace state. */ +static void asm_stack_restore(ASMState *as, SnapShot *snap) +{ + SnapEntry *map = &as->T->snapmap[snap->mapofs]; + SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; + MSize n, nent = snap->nent; + /* Store the value of all modified slots to the Lua stack. */ + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + BCReg s = snap_slot(sn); + int32_t ofs = 8*((int32_t)s-1); + IRRef ref = snap_ref(sn); + IRIns *ir = IR(ref); + if ((sn & SNAP_NORESTORE)) + continue; + if (irt_isnum(ir->t)) { + Reg src = ra_alloc1(as, ref, RSET_FPR); + emit_fai(as, PPCI_STFD, src, RID_BASE, ofs); + } else { + Reg type; + RegSet allow = rset_exclude(RSET_GPR, RID_BASE); + lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || irt_isinteger(ir->t)); + if (!irt_ispri(ir->t)) { + Reg src = ra_alloc1(as, ref, allow); + rset_clear(allow, src); + emit_tai(as, PPCI_STW, src, RID_BASE, ofs+4); + } + if ((sn & (SNAP_CONT|SNAP_FRAME))) { + if (s == 0) continue; /* Do not overwrite link to previous frame. */ + type = ra_allock(as, (int32_t)(*flinks--), allow); + } else { + type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); + } + emit_tai(as, PPCI_STW, type, RID_BASE, ofs); + } + checkmclim(as); + } + lua_assert(map + nent == flinks); +} + +/* -- GC handling --------------------------------------------------------- */ + +/* Check GC threshold and do one or more GC steps. */ +static void asm_gc_check(ASMState *as) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; + IRRef args[2]; + MCLabel l_end; + Reg tmp; + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ + asm_guardcc(as, CC_NE); /* Assumes asm_snap_prep() already done. */ + emit_ai(as, PPCI_CMPWI, RID_RET, 0); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ASMREF_TMP2; /* MSize steps */ + asm_gencall(as, ci, args); + emit_tai(as, PPCI_ADDI, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); + tmp = ra_releasetmp(as, ASMREF_TMP2); + emit_loadi(as, tmp, as->gcsteps); + /* Jump around GC step if GC total < GC threshold. */ + emit_condbranch(as, PPCI_BC|PPCF_Y, CC_LT, l_end); + emit_ab(as, PPCI_CMPLW, RID_TMP, tmp); + emit_getgl(as, tmp, gc.threshold); + emit_getgl(as, RID_TMP, gc.total); + as->gcsteps = 0; + checkmclim(as); +} + +/* -- Loop handling ------------------------------------------------------- */ + +/* Fixup the loop branch. */ +static void asm_loop_fixup(ASMState *as) +{ + MCode *p = as->mctop; + MCode *target = as->mcp; + if (as->loopinv) { /* Inverted loop branch? */ + /* asm_guardcc already inverted the cond branch and patched the final b. */ + p[-2] = (p[-2] & (0xffff0000u & ~PPCF_Y)) | (((target-p+2) & 0x3fffu) << 2); + } else { + p[-1] = PPCI_B|(((target-p+1)&0x00ffffffu)<<2); + } +} + +/* -- Head of trace ------------------------------------------------------- */ + +/* Coalesce BASE register for a root trace. */ +static void asm_head_root_base(ASMState *as) +{ + IRIns *ir = IR(REF_BASE); + Reg r = ir->r; + if (ra_hasreg(r)) { + ra_free(as, r); + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) + ir->r = RID_INIT; /* No inheritance for modified BASE register. */ + if (r != RID_BASE) + emit_mr(as, r, RID_BASE); + } +} + +/* Coalesce BASE register for a side trace. */ +static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) +{ + IRIns *ir = IR(REF_BASE); + Reg r = ir->r; + if (ra_hasreg(r)) { + ra_free(as, r); + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) + ir->r = RID_INIT; /* No inheritance for modified BASE register. */ + if (irp->r == r) { + rset_clear(allow, r); /* Mark same BASE register as coalesced. */ + } else if (ra_hasreg(irp->r) && rset_test(as->freeset, irp->r)) { + rset_clear(allow, irp->r); + emit_mr(as, r, irp->r); /* Move from coalesced parent reg. */ + } else { + emit_getgl(as, r, jit_base); /* Otherwise reload BASE. */ + } + } + return allow; +} + +/* -- Tail of trace ------------------------------------------------------- */ + +/* Fixup the tail code. */ +static void asm_tail_fixup(ASMState *as, TraceNo lnk) +{ + MCode *p = as->mctop; + MCode *target; + int32_t spadj = as->T->spadjust; + if (spadj == 0) { + *--p = PPCI_NOP; + *--p = PPCI_NOP; + as->mctop = p; + } else { + /* Patch stack adjustment. */ + lua_assert(checki16(CFRAME_SIZE+spadj)); + p[-3] = PPCI_ADDI | PPCF_T(RID_TMP) | PPCF_A(RID_SP) | (CFRAME_SIZE+spadj); + p[-2] = PPCI_STWU | PPCF_T(RID_TMP) | PPCF_A(RID_SP) | spadj; + } + /* Patch exit branch. */ + target = lnk ? traceref(as->J, lnk)->mcode : (MCode *)lj_vm_exit_interp; + p[-1] = PPCI_B|(((target-p+1)&0x00ffffffu)<<2); +} + +/* Prepare tail of code. */ +static void asm_tail_prep(ASMState *as) +{ + MCode *p = as->mctop - 1; /* Leave room for exit branch. */ + if (as->loopref) { + as->invmcp = as->mcp = p; + } else { + as->mcp = p-2; /* Leave room for stack pointer adjustment. */ + as->invmcp = NULL; + } +} + +/* -- Instruction dispatch ------------------------------------------------ */ + +/* Assemble a single instruction. */ +static void asm_ir(ASMState *as, IRIns *ir) +{ + switch ((IROp)ir->o) { + /* Miscellaneous ops. */ + case IR_LOOP: asm_loop(as); break; + case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; + case IR_USE: + ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; + case IR_PHI: asm_phi(as, ir); break; + case IR_HIOP: asm_hiop(as, ir); break; + case IR_GCSTEP: asm_gcstep(as, ir); break; + + /* Guarded assertions. */ + case IR_EQ: case IR_NE: + if ((ir-1)->o == IR_HREF && ir->op1 == as->curins-1) { + as->curins--; + asm_href(as, ir-1, (IROp)ir->o); + break; + } + /* fallthrough */ + case IR_LT: case IR_GE: case IR_LE: case IR_GT: + case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: + case IR_ABC: + asm_comp(as, ir); + break; + + case IR_RETF: asm_retf(as, ir); break; + + /* Bit ops. */ + case IR_BNOT: asm_bitnot(as, ir); break; + case IR_BSWAP: asm_bitswap(as, ir); break; + + case IR_BAND: asm_bitand(as, ir); break; + case IR_BOR: asm_bitop(as, ir, PPCI_OR, PPCI_ORI); break; + case IR_BXOR: asm_bitop(as, ir, PPCI_XOR, PPCI_XORI); break; + + case IR_BSHL: asm_bitshift(as, ir, PPCI_SLW, 0); break; + case IR_BSHR: asm_bitshift(as, ir, PPCI_SRW, 1); break; + case IR_BSAR: asm_bitshift(as, ir, PPCI_SRAW, PPCI_SRAWI); break; + case IR_BROL: asm_bitshift(as, ir, PPCI_RLWNM|PPCF_MB(0)|PPCF_ME(31), + PPCI_RLWINM|PPCF_MB(0)|PPCF_ME(31)); break; + case IR_BROR: lua_assert(0); break; + + /* Arithmetic ops. */ + case IR_ADD: asm_add(as, ir); break; + case IR_SUB: asm_sub(as, ir); break; + case IR_MUL: asm_mul(as, ir); break; + case IR_DIV: asm_fparith(as, ir, PPCI_FDIV); break; + case IR_MOD: asm_callid(as, ir, IRCALL_lj_vm_modi); break; + case IR_POW: asm_callid(as, ir, IRCALL_lj_vm_powi); break; + case IR_NEG: asm_neg(as, ir); break; + + case IR_ABS: asm_fpunary(as, ir, PPCI_FABS); break; + case IR_ATAN2: asm_callid(as, ir, IRCALL_atan2); break; + case IR_LDEXP: asm_callid(as, ir, IRCALL_ldexp); break; + case IR_MIN: asm_min_max(as, ir, 0); break; + case IR_MAX: asm_min_max(as, ir, 1); break; + case IR_FPMATH: + if (ir->op2 == IRFPM_EXP2 && asm_fpjoin_pow(as, ir)) + break; + if (ir->op2 == IRFPM_SQRT && (as->flags & JIT_F_SQRT)) + asm_fpunary(as, ir, PPCI_FSQRT); + else + asm_callid(as, ir, IRCALL_lj_vm_floor + ir->op2); + break; + + /* Overflow-checking arithmetic ops. */ + case IR_ADDOV: asm_arithov(as, ir, PPCI_ADDO); break; + case IR_SUBOV: asm_arithov(as, ir, PPCI_SUBFO); break; + case IR_MULOV: asm_arithov(as, ir, PPCI_MULLWO); break; + + /* Memory references. */ + case IR_AREF: asm_aref(as, ir); break; + case IR_HREF: asm_href(as, ir, 0); break; + case IR_HREFK: asm_hrefk(as, ir); break; + case IR_NEWREF: asm_newref(as, ir); break; + case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; + case IR_FREF: asm_fref(as, ir); break; + case IR_STRREF: asm_strref(as, ir); break; + + /* Loads and stores. */ + case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + asm_ahuvload(as, ir); + break; + case IR_FLOAD: asm_fload(as, ir); break; + case IR_XLOAD: asm_xload(as, ir); break; + case IR_SLOAD: asm_sload(as, ir); break; + + case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; + case IR_FSTORE: asm_fstore(as, ir); break; + case IR_XSTORE: asm_xstore(as, ir, 0); break; + + /* Allocations. */ + case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; + case IR_TNEW: asm_tnew(as, ir); break; + case IR_TDUP: asm_tdup(as, ir); break; + case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; + + /* Write barriers. */ + case IR_TBAR: asm_tbar(as, ir); break; + case IR_OBAR: asm_obar(as, ir); break; + + /* Type conversions. */ + case IR_CONV: asm_conv(as, ir); break; + case IR_TOBIT: asm_tobit(as, ir); break; + case IR_TOSTR: asm_tostr(as, ir); break; + case IR_STRTO: asm_strto(as, ir); break; + + /* Calls. */ + case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; + case IR_CALLXS: asm_callx(as, ir); break; + case IR_CARG: break; + + default: + setintV(&as->J->errinfo, ir->o); + lj_trace_err_info(as->J, LJ_TRERR_NYIIR); + break; + } +} + +/* -- Trace setup --------------------------------------------------------- */ + +/* Ensure there are enough stack slots for call arguments. */ +static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + IRRef args[CCI_NARGS_MAX*2]; + uint32_t i, nargs = (int)CCI_NARGS(ci); + int nslots = 2, ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR; + asm_collectargs(as, ir, ci, args); + for (i = 0; i < nargs; i++) + if (args[i] && irt_isfp(IR(args[i])->t)) { + if (nfpr > 0) nfpr--; else nslots = (nslots+3) & ~1; + } else { + if (ngpr > 0) ngpr--; else nslots++; + } + if (nslots > as->evenspill) /* Leave room for args in stack slots. */ + as->evenspill = nslots; + return irt_isfp(ir->t) ? REGSP_HINT(RID_FPRET) : REGSP_HINT(RID_RET); +} + +static void asm_setup_target(ASMState *as) +{ + asm_exitstub_setup(as, as->T->nsnap + (as->parent ? 1 : 0)); +} + +/* -- Trace patching ------------------------------------------------------ */ + +/* Patch exit jumps of existing machine code to a new target. */ +void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) +{ + MCode *p = T->mcode; + MCode *pe = (MCode *)((char *)p + T->szmcode); + MCode *px = exitstub_trace_addr(T, exitno); + MCode *cstart = NULL; + MCode *mcarea = lj_mcode_patch(J, p, 0); + int clearso = 0; + for (; p < pe; p++) { + /* Look for exitstub branch, try to replace with branch to target. */ + uint32_t ins = *p; + if ((ins & 0xfc000000u) == 0x40000000u && + ((ins ^ ((char *)px-(char *)p)) & 0xffffu) == 0) { + ptrdiff_t delta = (char *)target - (char *)p; + if (((ins >> 16) & 3) == (CC_SO&3)) { + clearso = sizeof(MCode); + delta -= sizeof(MCode); + } + /* Many, but not all short-range branches can be patched directly. */ + if (((delta + 0x8000) >> 16) == 0) { + *p = (ins & 0xffdf0000u) | ((uint32_t)delta & 0xffffu) | + ((delta & 0x8000) * (PPCF_Y/0x8000)); + if (!cstart) cstart = p; + } + } else if ((ins & 0xfc000000u) == PPCI_B && + ((ins ^ ((char *)px-(char *)p)) & 0x03ffffffu) == 0) { + ptrdiff_t delta = (char *)target - (char *)p; + lua_assert(((delta + 0x02000000) >> 26) == 0); + *p = PPCI_B | ((uint32_t)delta & 0x03ffffffu); + if (!cstart) cstart = p; + } + } + { /* Always patch long-range branch in exit stub itself. */ + ptrdiff_t delta = (char *)target - (char *)px - clearso; + lua_assert(((delta + 0x02000000) >> 26) == 0); + *px = PPCI_B | ((uint32_t)delta & 0x03ffffffu); + } + if (!cstart) cstart = px; + lj_mcode_sync(cstart, px+1); + if (clearso) { /* Extend the current trace. Ugly workaround. */ + MCode *pp = J->cur.mcode; + J->cur.szmcode += sizeof(MCode); + *--pp = PPCI_MCRXR; /* Clear SO flag. */ + J->cur.mcode = pp; + lj_mcode_sync(pp, pp+1); + } + lj_mcode_patch(J, mcarea, 1); +} + + +``` + +`include/luajit-2.0.5/src/lj_asm_x86.h`: + +```h +/* +** x86/x64 IR assembler (SSA IR -> machine code). +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Guard handling ------------------------------------------------------ */ + +/* Generate an exit stub group at the bottom of the reserved MCode memory. */ +static MCode *asm_exitstub_gen(ASMState *as, ExitNo group) +{ + ExitNo i, groupofs = (group*EXITSTUBS_PER_GROUP) & 0xff; + MCode *mxp = as->mcbot; + MCode *mxpstart = mxp; + if (mxp + (2+2)*EXITSTUBS_PER_GROUP+8+5 >= as->mctop) + asm_mclimit(as); + /* Push low byte of exitno for each exit stub. */ + *mxp++ = XI_PUSHi8; *mxp++ = (MCode)groupofs; + for (i = 1; i < EXITSTUBS_PER_GROUP; i++) { + *mxp++ = XI_JMPs; *mxp++ = (MCode)((2+2)*(EXITSTUBS_PER_GROUP - i) - 2); + *mxp++ = XI_PUSHi8; *mxp++ = (MCode)(groupofs + i); + } + /* Push the high byte of the exitno for each exit stub group. */ + *mxp++ = XI_PUSHi8; *mxp++ = (MCode)((group*EXITSTUBS_PER_GROUP)>>8); + /* Store DISPATCH at original stack slot 0. Account for the two push ops. */ + *mxp++ = XI_MOVmi; + *mxp++ = MODRM(XM_OFS8, 0, RID_ESP); + *mxp++ = MODRM(XM_SCALE1, RID_ESP, RID_ESP); + *mxp++ = 2*sizeof(void *); + *(int32_t *)mxp = ptr2addr(J2GG(as->J)->dispatch); mxp += 4; + /* Jump to exit handler which fills in the ExitState. */ + *mxp++ = XI_JMP; mxp += 4; + *((int32_t *)(mxp-4)) = jmprel(mxp, (MCode *)(void *)lj_vm_exit_handler); + /* Commit the code for this group (even if assembly fails later on). */ + lj_mcode_commitbot(as->J, mxp); + as->mcbot = mxp; + as->mclim = as->mcbot + MCLIM_REDZONE; + return mxpstart; +} + +/* Setup all needed exit stubs. */ +static void asm_exitstub_setup(ASMState *as, ExitNo nexits) +{ + ExitNo i; + if (nexits >= EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) + lj_trace_err(as->J, LJ_TRERR_SNAPOV); + for (i = 0; i < (nexits+EXITSTUBS_PER_GROUP-1)/EXITSTUBS_PER_GROUP; i++) + if (as->J->exitstubgroup[i] == NULL) + as->J->exitstubgroup[i] = asm_exitstub_gen(as, i); +} + +/* Emit conditional branch to exit for guard. +** It's important to emit this *after* all registers have been allocated, +** because rematerializations may invalidate the flags. +*/ +static void asm_guardcc(ASMState *as, int cc) +{ + MCode *target = exitstub_addr(as->J, as->snapno); + MCode *p = as->mcp; + if (LJ_UNLIKELY(p == as->invmcp)) { + as->loopinv = 1; + *(int32_t *)(p+1) = jmprel(p+5, target); + target = p; + cc ^= 1; + if (as->realign) { + emit_sjcc(as, cc, target); + return; + } + } + emit_jcc(as, cc, target); +} + +/* -- Memory operand fusion ----------------------------------------------- */ + +/* Limit linear search to this distance. Avoids O(n^2) behavior. */ +#define CONFLICT_SEARCH_LIM 31 + +/* Check if a reference is a signed 32 bit constant. */ +static int asm_isk32(ASMState *as, IRRef ref, int32_t *k) +{ + if (irref_isk(ref)) { + IRIns *ir = IR(ref); + if (ir->o != IR_KINT64) { + *k = ir->i; + return 1; + } else if (checki32((int64_t)ir_kint64(ir)->u64)) { + *k = (int32_t)ir_kint64(ir)->u64; + return 1; + } + } + return 0; +} + +/* Check if there's no conflicting instruction between curins and ref. +** Also avoid fusing loads if there are multiple references. +*/ +static int noconflict(ASMState *as, IRRef ref, IROp conflict, int noload) +{ + IRIns *ir = as->ir; + IRRef i = as->curins; + if (i > ref + CONFLICT_SEARCH_LIM) + return 0; /* Give up, ref is too far away. */ + while (--i > ref) { + if (ir[i].o == conflict) + return 0; /* Conflict found. */ + else if (!noload && (ir[i].op1 == ref || ir[i].op2 == ref)) + return 0; + } + return 1; /* Ok, no conflict. */ +} + +/* Fuse array base into memory operand. */ +static IRRef asm_fuseabase(ASMState *as, IRRef ref) +{ + IRIns *irb = IR(ref); + as->mrm.ofs = 0; + if (irb->o == IR_FLOAD) { + IRIns *ira = IR(irb->op1); + lua_assert(irb->op2 == IRFL_TAB_ARRAY); + /* We can avoid the FLOAD of t->array for colocated arrays. */ + if (ira->o == IR_TNEW && ira->op1 <= LJ_MAX_COLOSIZE && + !neverfuse(as) && noconflict(as, irb->op1, IR_NEWREF, 1)) { + as->mrm.ofs = (int32_t)sizeof(GCtab); /* Ofs to colocated array. */ + return irb->op1; /* Table obj. */ + } + } else if (irb->o == IR_ADD && irref_isk(irb->op2)) { + /* Fuse base offset (vararg load). */ + as->mrm.ofs = IR(irb->op2)->i; + return irb->op1; + } + return ref; /* Otherwise use the given array base. */ +} + +/* Fuse array reference into memory operand. */ +static void asm_fusearef(ASMState *as, IRIns *ir, RegSet allow) +{ + IRIns *irx; + lua_assert(ir->o == IR_AREF); + as->mrm.base = (uint8_t)ra_alloc1(as, asm_fuseabase(as, ir->op1), allow); + irx = IR(ir->op2); + if (irref_isk(ir->op2)) { + as->mrm.ofs += 8*irx->i; + as->mrm.idx = RID_NONE; + } else { + rset_clear(allow, as->mrm.base); + as->mrm.scale = XM_SCALE8; + /* Fuse a constant ADD (e.g. t[i+1]) into the offset. + ** Doesn't help much without ABCelim, but reduces register pressure. + */ + if (!LJ_64 && /* Has bad effects with negative index on x64. */ + mayfuse(as, ir->op2) && ra_noreg(irx->r) && + irx->o == IR_ADD && irref_isk(irx->op2)) { + as->mrm.ofs += 8*IR(irx->op2)->i; + as->mrm.idx = (uint8_t)ra_alloc1(as, irx->op1, allow); + } else { + as->mrm.idx = (uint8_t)ra_alloc1(as, ir->op2, allow); + } + } +} + +/* Fuse array/hash/upvalue reference into memory operand. +** Caveat: this may allocate GPRs for the base/idx registers. Be sure to +** pass the final allow mask, excluding any GPRs used for other inputs. +** In particular: 2-operand GPR instructions need to call ra_dest() first! +*/ +static void asm_fuseahuref(ASMState *as, IRRef ref, RegSet allow) +{ + IRIns *ir = IR(ref); + if (ra_noreg(ir->r)) { + switch ((IROp)ir->o) { + case IR_AREF: + if (mayfuse(as, ref)) { + asm_fusearef(as, ir, allow); + return; + } + break; + case IR_HREFK: + if (mayfuse(as, ref)) { + as->mrm.base = (uint8_t)ra_alloc1(as, ir->op1, allow); + as->mrm.ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); + as->mrm.idx = RID_NONE; + return; + } + break; + case IR_UREFC: + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + GCupval *uv = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv; + as->mrm.ofs = ptr2addr(&uv->tv); + as->mrm.base = as->mrm.idx = RID_NONE; + return; + } + break; + default: + lua_assert(ir->o == IR_HREF || ir->o == IR_NEWREF || ir->o == IR_UREFO || + ir->o == IR_KKPTR); + break; + } + } + as->mrm.base = (uint8_t)ra_alloc1(as, ref, allow); + as->mrm.ofs = 0; + as->mrm.idx = RID_NONE; +} + +/* Fuse FLOAD/FREF reference into memory operand. */ +static void asm_fusefref(ASMState *as, IRIns *ir, RegSet allow) +{ + lua_assert(ir->o == IR_FLOAD || ir->o == IR_FREF); + as->mrm.ofs = field_ofs[ir->op2]; + as->mrm.idx = RID_NONE; + if (irref_isk(ir->op1)) { + as->mrm.ofs += IR(ir->op1)->i; + as->mrm.base = RID_NONE; + } else { + as->mrm.base = (uint8_t)ra_alloc1(as, ir->op1, allow); + } +} + +/* Fuse string reference into memory operand. */ +static void asm_fusestrref(ASMState *as, IRIns *ir, RegSet allow) +{ + IRIns *irr; + lua_assert(ir->o == IR_STRREF); + as->mrm.base = as->mrm.idx = RID_NONE; + as->mrm.scale = XM_SCALE1; + as->mrm.ofs = sizeof(GCstr); + if (irref_isk(ir->op1)) { + as->mrm.ofs += IR(ir->op1)->i; + } else { + Reg r = ra_alloc1(as, ir->op1, allow); + rset_clear(allow, r); + as->mrm.base = (uint8_t)r; + } + irr = IR(ir->op2); + if (irref_isk(ir->op2)) { + as->mrm.ofs += irr->i; + } else { + Reg r; + /* Fuse a constant add into the offset, e.g. string.sub(s, i+10). */ + if (!LJ_64 && /* Has bad effects with negative index on x64. */ + mayfuse(as, ir->op2) && irr->o == IR_ADD && irref_isk(irr->op2)) { + as->mrm.ofs += IR(irr->op2)->i; + r = ra_alloc1(as, irr->op1, allow); + } else { + r = ra_alloc1(as, ir->op2, allow); + } + if (as->mrm.base == RID_NONE) + as->mrm.base = (uint8_t)r; + else + as->mrm.idx = (uint8_t)r; + } +} + +static void asm_fusexref(ASMState *as, IRRef ref, RegSet allow) +{ + IRIns *ir = IR(ref); + as->mrm.idx = RID_NONE; + if (ir->o == IR_KPTR || ir->o == IR_KKPTR) { + as->mrm.ofs = ir->i; + as->mrm.base = RID_NONE; + } else if (ir->o == IR_STRREF) { + asm_fusestrref(as, ir, allow); + } else { + as->mrm.ofs = 0; + if (canfuse(as, ir) && ir->o == IR_ADD && ra_noreg(ir->r)) { + /* Gather (base+idx*sz)+ofs as emitted by cdata ptr/array indexing. */ + IRIns *irx; + IRRef idx; + Reg r; + if (asm_isk32(as, ir->op2, &as->mrm.ofs)) { /* Recognize x+ofs. */ + ref = ir->op1; + ir = IR(ref); + if (!(ir->o == IR_ADD && canfuse(as, ir) && ra_noreg(ir->r))) + goto noadd; + } + as->mrm.scale = XM_SCALE1; + idx = ir->op1; + ref = ir->op2; + irx = IR(idx); + if (!(irx->o == IR_BSHL || irx->o == IR_ADD)) { /* Try other operand. */ + idx = ir->op2; + ref = ir->op1; + irx = IR(idx); + } + if (canfuse(as, irx) && ra_noreg(irx->r)) { + if (irx->o == IR_BSHL && irref_isk(irx->op2) && IR(irx->op2)->i <= 3) { + /* Recognize idx<op1; + as->mrm.scale = (uint8_t)(IR(irx->op2)->i << 6); + } else if (irx->o == IR_ADD && irx->op1 == irx->op2) { + /* FOLD does idx*2 ==> idx<<1 ==> idx+idx. */ + idx = irx->op1; + as->mrm.scale = XM_SCALE2; + } + } + r = ra_alloc1(as, idx, allow); + rset_clear(allow, r); + as->mrm.idx = (uint8_t)r; + } + noadd: + as->mrm.base = (uint8_t)ra_alloc1(as, ref, allow); + } +} + +/* Fuse load into memory operand. */ +static Reg asm_fuseload(ASMState *as, IRRef ref, RegSet allow) +{ + IRIns *ir = IR(ref); + if (ra_hasreg(ir->r)) { + if (allow != RSET_EMPTY) { /* Fast path. */ + ra_noweak(as, ir->r); + return ir->r; + } + fusespill: + /* Force a spill if only memory operands are allowed (asm_x87load). */ + as->mrm.base = RID_ESP; + as->mrm.ofs = ra_spill(as, ir); + as->mrm.idx = RID_NONE; + return RID_MRM; + } + if (ir->o == IR_KNUM) { + RegSet avail = as->freeset & ~as->modset & RSET_FPR; + lua_assert(allow != RSET_EMPTY); + if (!(avail & (avail-1))) { /* Fuse if less than two regs available. */ + as->mrm.ofs = ptr2addr(ir_knum(ir)); + as->mrm.base = as->mrm.idx = RID_NONE; + return RID_MRM; + } + } else if (ref == REF_BASE || ir->o == IR_KINT64) { + RegSet avail = as->freeset & ~as->modset & RSET_GPR; + lua_assert(allow != RSET_EMPTY); + if (!(avail & (avail-1))) { /* Fuse if less than two regs available. */ + as->mrm.ofs = ptr2addr(ref == REF_BASE ? (void *)&J2G(as->J)->jit_base : (void *)ir_kint64(ir)); + as->mrm.base = as->mrm.idx = RID_NONE; + return RID_MRM; + } + } else if (mayfuse(as, ref)) { + RegSet xallow = (allow & RSET_GPR) ? allow : RSET_GPR; + if (ir->o == IR_SLOAD) { + if (!(ir->op2 & (IRSLOAD_PARENT|IRSLOAD_CONVERT)) && + noconflict(as, ref, IR_RETF, 0)) { + as->mrm.base = (uint8_t)ra_alloc1(as, REF_BASE, xallow); + as->mrm.ofs = 8*((int32_t)ir->op1-1) + ((ir->op2&IRSLOAD_FRAME)?4:0); + as->mrm.idx = RID_NONE; + return RID_MRM; + } + } else if (ir->o == IR_FLOAD) { + /* Generic fusion is only ok for 32 bit operand (but see asm_comp). */ + if ((irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)) && + noconflict(as, ref, IR_FSTORE, 0)) { + asm_fusefref(as, ir, xallow); + return RID_MRM; + } + } else if (ir->o == IR_ALOAD || ir->o == IR_HLOAD || ir->o == IR_ULOAD) { + if (noconflict(as, ref, ir->o + IRDELTA_L2S, 0)) { + asm_fuseahuref(as, ir->op1, xallow); + return RID_MRM; + } + } else if (ir->o == IR_XLOAD) { + /* Generic fusion is not ok for 8/16 bit operands (but see asm_comp). + ** Fusing unaligned memory operands is ok on x86 (except for SIMD types). + */ + if ((!irt_typerange(ir->t, IRT_I8, IRT_U16)) && + noconflict(as, ref, IR_XSTORE, 0)) { + asm_fusexref(as, ir->op1, xallow); + return RID_MRM; + } + } else if (ir->o == IR_VLOAD) { + asm_fuseahuref(as, ir->op1, xallow); + return RID_MRM; + } + } + if (!(as->freeset & allow) && !emit_canremat(ref) && + (allow == RSET_EMPTY || ra_hasspill(ir->s) || iscrossref(as, ref))) + goto fusespill; + return ra_allocref(as, ref, allow); +} + +#if LJ_64 +/* Don't fuse a 32 bit load into a 64 bit operation. */ +static Reg asm_fuseloadm(ASMState *as, IRRef ref, RegSet allow, int is64) +{ + if (is64 && !irt_is64(IR(ref)->t)) + return ra_alloc1(as, ref, allow); + return asm_fuseload(as, ref, allow); +} +#else +#define asm_fuseloadm(as, ref, allow, is64) asm_fuseload(as, (ref), (allow)) +#endif + +/* -- Calls --------------------------------------------------------------- */ + +/* Count the required number of stack slots for a call. */ +static int asm_count_call_slots(ASMState *as, const CCallInfo *ci, IRRef *args) +{ + uint32_t i, nargs = CCI_NARGS(ci); + int nslots = 0; +#if LJ_64 + if (LJ_ABI_WIN) { + nslots = (int)(nargs*2); /* Only matters for more than four args. */ + } else { + int ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR; + for (i = 0; i < nargs; i++) + if (args[i] && irt_isfp(IR(args[i])->t)) { + if (nfpr > 0) nfpr--; else nslots += 2; + } else { + if (ngpr > 0) ngpr--; else nslots += 2; + } + } +#else + int ngpr = 0; + if ((ci->flags & CCI_CC_MASK) == CCI_CC_FASTCALL) + ngpr = 2; + else if ((ci->flags & CCI_CC_MASK) == CCI_CC_THISCALL) + ngpr = 1; + for (i = 0; i < nargs; i++) + if (args[i] && irt_isfp(IR(args[i])->t)) { + nslots += irt_isnum(IR(args[i])->t) ? 2 : 1; + } else { + if (ngpr > 0) ngpr--; else nslots++; + } +#endif + return nslots; +} + +/* Generate a call to a C function. */ +static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) +{ + uint32_t n, nargs = CCI_NARGS(ci); + int32_t ofs = STACKARG_OFS; +#if LJ_64 + uint32_t gprs = REGARG_GPRS; + Reg fpr = REGARG_FIRSTFPR; +#if !LJ_ABI_WIN + MCode *patchnfpr = NULL; +#endif +#else + uint32_t gprs = 0; + if ((ci->flags & CCI_CC_MASK) != CCI_CC_CDECL) { + if ((ci->flags & CCI_CC_MASK) == CCI_CC_THISCALL) + gprs = (REGARG_GPRS & 31); + else if ((ci->flags & CCI_CC_MASK) == CCI_CC_FASTCALL) + gprs = REGARG_GPRS; + } +#endif + if ((void *)ci->func) + emit_call(as, ci->func); +#if LJ_64 + if ((ci->flags & CCI_VARARG)) { /* Special handling for vararg calls. */ +#if LJ_ABI_WIN + for (n = 0; n < 4 && n < nargs; n++) { + IRIns *ir = IR(args[n]); + if (irt_isfp(ir->t)) /* Duplicate FPRs in GPRs. */ + emit_rr(as, XO_MOVDto, (irt_isnum(ir->t) ? REX_64 : 0) | (fpr+n), + ((gprs >> (n*5)) & 31)); /* Either MOVD or MOVQ. */ + } +#else + patchnfpr = --as->mcp; /* Indicate number of used FPRs in register al. */ + *--as->mcp = XI_MOVrib | RID_EAX; +#endif + } +#endif + for (n = 0; n < nargs; n++) { /* Setup args. */ + IRRef ref = args[n]; + IRIns *ir = IR(ref); + Reg r; +#if LJ_64 && LJ_ABI_WIN + /* Windows/x64 argument registers are strictly positional. */ + r = irt_isfp(ir->t) ? (fpr <= REGARG_LASTFPR ? fpr : 0) : (gprs & 31); + fpr++; gprs >>= 5; +#elif LJ_64 + /* POSIX/x64 argument registers are used in order of appearance. */ + if (irt_isfp(ir->t)) { + r = fpr <= REGARG_LASTFPR ? fpr++ : 0; + } else { + r = gprs & 31; gprs >>= 5; + } +#else + if (ref && irt_isfp(ir->t)) { + r = 0; + } else { + r = gprs & 31; gprs >>= 5; + if (!ref) continue; + } +#endif + if (r) { /* Argument is in a register. */ + if (r < RID_MAX_GPR && ref < ASMREF_TMP1) { +#if LJ_64 + if (ir->o == IR_KINT64) + emit_loadu64(as, r, ir_kint64(ir)->u64); + else +#endif + emit_loadi(as, r, ir->i); + } else { + lua_assert(rset_test(as->freeset, r)); /* Must have been evicted. */ + if (ra_hasreg(ir->r)) { + ra_noweak(as, ir->r); + emit_movrr(as, ir, r, ir->r); + } else { + ra_allocref(as, ref, RID2RSET(r)); + } + } + } else if (irt_isfp(ir->t)) { /* FP argument is on stack. */ + lua_assert(!(irt_isfloat(ir->t) && irref_isk(ref))); /* No float k. */ + if (LJ_32 && (ofs & 4) && irref_isk(ref)) { + /* Split stores for unaligned FP consts. */ + emit_movmroi(as, RID_ESP, ofs, (int32_t)ir_knum(ir)->u32.lo); + emit_movmroi(as, RID_ESP, ofs+4, (int32_t)ir_knum(ir)->u32.hi); + } else { + r = ra_alloc1(as, ref, RSET_FPR); + emit_rmro(as, irt_isnum(ir->t) ? XO_MOVSDto : XO_MOVSSto, + r, RID_ESP, ofs); + } + ofs += (LJ_32 && irt_isfloat(ir->t)) ? 4 : 8; + } else { /* Non-FP argument is on stack. */ + if (LJ_32 && ref < ASMREF_TMP1) { + emit_movmroi(as, RID_ESP, ofs, ir->i); + } else { + r = ra_alloc1(as, ref, RSET_GPR); + emit_movtomro(as, REX_64 + r, RID_ESP, ofs); + } + ofs += sizeof(intptr_t); + } + checkmclim(as); + } +#if LJ_64 && !LJ_ABI_WIN + if (patchnfpr) *patchnfpr = fpr - REGARG_FIRSTFPR; +#endif +} + +/* Setup result reg/sp for call. Evict scratch regs. */ +static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + RegSet drop = RSET_SCRATCH; + int hiop = (LJ_32 && (ir+1)->o == IR_HIOP && !irt_isnil((ir+1)->t)); + if ((ci->flags & CCI_NOFPRCLOBBER)) + drop &= ~RSET_FPR; + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + if (hiop && ra_hasreg((ir+1)->r)) + rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ + ra_evictset(as, drop); /* Evictions must be performed first. */ + if (ra_used(ir)) { + if (irt_isfp(ir->t)) { + int32_t ofs = sps_scale(ir->s); /* Use spill slot or temp slots. */ +#if LJ_64 + if ((ci->flags & CCI_CASTU64)) { + Reg dest = ir->r; + if (ra_hasreg(dest)) { + ra_free(as, dest); + ra_modified(as, dest); + emit_rr(as, XO_MOVD, dest|REX_64, RID_RET); /* Really MOVQ. */ + } + if (ofs) emit_movtomro(as, RID_RET|REX_64, RID_ESP, ofs); + } else { + ra_destreg(as, ir, RID_FPRET); + } +#else + /* Number result is in x87 st0 for x86 calling convention. */ + Reg dest = ir->r; + if (ra_hasreg(dest)) { + ra_free(as, dest); + ra_modified(as, dest); + emit_rmro(as, irt_isnum(ir->t) ? XMM_MOVRM(as) : XO_MOVSS, + dest, RID_ESP, ofs); + } + if ((ci->flags & CCI_CASTU64)) { + emit_movtomro(as, RID_RETLO, RID_ESP, ofs); + emit_movtomro(as, RID_RETHI, RID_ESP, ofs+4); + } else { + emit_rmro(as, irt_isnum(ir->t) ? XO_FSTPq : XO_FSTPd, + irt_isnum(ir->t) ? XOg_FSTPq : XOg_FSTPd, RID_ESP, ofs); + } +#endif +#if LJ_32 + } else if (hiop) { + ra_destpair(as, ir); +#endif + } else { + lua_assert(!irt_ispri(ir->t)); + ra_destreg(as, ir, RID_RET); + } + } else if (LJ_32 && irt_isfp(ir->t) && !(ci->flags & CCI_CASTU64)) { + emit_x87op(as, XI_FPOP); /* Pop unused result from x87 st0. */ + } +} + +static void asm_call(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX]; + const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; + asm_collectargs(as, ir, ci, args); + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +/* Return a constant function pointer or NULL for indirect calls. */ +static void *asm_callx_func(ASMState *as, IRIns *irf, IRRef func) +{ +#if LJ_32 + UNUSED(as); + if (irref_isk(func)) + return (void *)irf->i; +#else + if (irref_isk(func)) { + MCode *p; + if (irf->o == IR_KINT64) + p = (MCode *)(void *)ir_k64(irf)->u64; + else + p = (MCode *)(void *)(uintptr_t)(uint32_t)irf->i; + if (p - as->mcp == (int32_t)(p - as->mcp)) + return p; /* Call target is still in +-2GB range. */ + /* Avoid the indirect case of emit_call(). Try to hoist func addr. */ + } +#endif + return NULL; +} + +static void asm_callx(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX*2]; + CCallInfo ci; + IRRef func; + IRIns *irf; + int32_t spadj = 0; + ci.flags = asm_callx_flags(as, ir); + asm_collectargs(as, ir, &ci, args); + asm_setupresult(as, ir, &ci); +#if LJ_32 + /* Have to readjust stack after non-cdecl calls due to callee cleanup. */ + if ((ci.flags & CCI_CC_MASK) != CCI_CC_CDECL) + spadj = 4 * asm_count_call_slots(as, &ci, args); +#endif + func = ir->op2; irf = IR(func); + if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } + ci.func = (ASMFunction)asm_callx_func(as, irf, func); + if (!(void *)ci.func) { + /* Use a (hoistable) non-scratch register for indirect calls. */ + RegSet allow = (RSET_GPR & ~RSET_SCRATCH); + Reg r = ra_alloc1(as, func, allow); + if (LJ_32) emit_spsub(as, spadj); /* Above code may cause restores! */ + emit_rr(as, XO_GROUP5, XOg_CALL, r); + } else if (LJ_32) { + emit_spsub(as, spadj); + } + asm_gencall(as, &ci, args); +} + +/* -- Returns ------------------------------------------------------------- */ + +/* Return to lower frame. Guard that it goes to the right spot. */ +static void asm_retf(ASMState *as, IRIns *ir) +{ + Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); + void *pc = ir_kptr(IR(ir->op2)); + int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); + as->topslot -= (BCReg)delta; + if ((int32_t)as->topslot < 0) as->topslot = 0; + irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ + emit_setgl(as, base, jit_base); + emit_addptr(as, base, -8*delta); + asm_guardcc(as, CC_NE); + emit_gmroi(as, XG_ARITHi(XOg_CMP), base, -4, ptr2addr(pc)); +} + +/* -- Type conversions ---------------------------------------------------- */ + +static void asm_tointg(ASMState *as, IRIns *ir, Reg left) +{ + Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); + Reg dest = ra_dest(as, ir, RSET_GPR); + asm_guardcc(as, CC_P); + asm_guardcc(as, CC_NE); + emit_rr(as, XO_UCOMISD, left, tmp); + emit_rr(as, XO_CVTSI2SD, tmp, dest); + if (!(as->flags & JIT_F_SPLIT_XMM)) + emit_rr(as, XO_XORPS, tmp, tmp); /* Avoid partial register stall. */ + emit_rr(as, XO_CVTTSD2SI, dest, left); + /* Can't fuse since left is needed twice. */ +} + +static void asm_tobit(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg tmp = ra_noreg(IR(ir->op1)->r) ? + ra_alloc1(as, ir->op1, RSET_FPR) : + ra_scratch(as, RSET_FPR); + Reg right = asm_fuseload(as, ir->op2, rset_exclude(RSET_FPR, tmp)); + emit_rr(as, XO_MOVDto, tmp, dest); + emit_mrm(as, XO_ADDSD, tmp, right); + ra_left(as, tmp, ir->op1); +} + +static void asm_conv(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); + int st64 = (st == IRT_I64 || st == IRT_U64 || (LJ_64 && st == IRT_P64)); + int stfp = (st == IRT_NUM || st == IRT_FLOAT); + IRRef lref = ir->op1; + lua_assert(irt_type(ir->t) != st); + lua_assert(!(LJ_32 && (irt_isint64(ir->t) || st64))); /* Handled by SPLIT. */ + if (irt_isfp(ir->t)) { + Reg dest = ra_dest(as, ir, RSET_FPR); + if (stfp) { /* FP to FP conversion. */ + Reg left = asm_fuseload(as, lref, RSET_FPR); + emit_mrm(as, st == IRT_NUM ? XO_CVTSD2SS : XO_CVTSS2SD, dest, left); + if (left == dest) return; /* Avoid the XO_XORPS. */ + } else if (LJ_32 && st == IRT_U32) { /* U32 to FP conversion on x86. */ + /* number = (2^52+2^51 .. u32) - (2^52+2^51) */ + cTValue *k = lj_ir_k64_find(as->J, U64x(43380000,00000000)); + Reg bias = ra_scratch(as, rset_exclude(RSET_FPR, dest)); + if (irt_isfloat(ir->t)) + emit_rr(as, XO_CVTSD2SS, dest, dest); + emit_rr(as, XO_SUBSD, dest, bias); /* Subtract 2^52+2^51 bias. */ + emit_rr(as, XO_XORPS, dest, bias); /* Merge bias and integer. */ + emit_loadn(as, bias, k); + emit_mrm(as, XO_MOVD, dest, asm_fuseload(as, lref, RSET_GPR)); + return; + } else { /* Integer to FP conversion. */ + Reg left = (LJ_64 && (st == IRT_U32 || st == IRT_U64)) ? + ra_alloc1(as, lref, RSET_GPR) : + asm_fuseloadm(as, lref, RSET_GPR, st64); + if (LJ_64 && st == IRT_U64) { + MCLabel l_end = emit_label(as); + const void *k = lj_ir_k64_find(as->J, U64x(43f00000,00000000)); + emit_rma(as, XO_ADDSD, dest, k); /* Add 2^64 to compensate. */ + emit_sjcc(as, CC_NS, l_end); + emit_rr(as, XO_TEST, left|REX_64, left); /* Check if u64 >= 2^63. */ + } + emit_mrm(as, irt_isnum(ir->t) ? XO_CVTSI2SD : XO_CVTSI2SS, + dest|((LJ_64 && (st64 || st == IRT_U32)) ? REX_64 : 0), left); + } + if (!(as->flags & JIT_F_SPLIT_XMM)) + emit_rr(as, XO_XORPS, dest, dest); /* Avoid partial register stall. */ + } else if (stfp) { /* FP to integer conversion. */ + if (irt_isguard(ir->t)) { + /* Checked conversions are only supported from number to int. */ + lua_assert(irt_isint(ir->t) && st == IRT_NUM); + asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + x86Op op = st == IRT_NUM ? + ((ir->op2 & IRCONV_TRUNC) ? XO_CVTTSD2SI : XO_CVTSD2SI) : + ((ir->op2 & IRCONV_TRUNC) ? XO_CVTTSS2SI : XO_CVTSS2SI); + if (LJ_64 ? irt_isu64(ir->t) : irt_isu32(ir->t)) { + /* LJ_64: For inputs >= 2^63 add -2^64, convert again. */ + /* LJ_32: For inputs >= 2^31 add -2^31, convert again and add 2^31. */ + Reg tmp = ra_noreg(IR(lref)->r) ? ra_alloc1(as, lref, RSET_FPR) : + ra_scratch(as, RSET_FPR); + MCLabel l_end = emit_label(as); + if (LJ_32) + emit_gri(as, XG_ARITHi(XOg_ADD), dest, (int32_t)0x80000000); + emit_rr(as, op, dest|REX_64, tmp); + if (st == IRT_NUM) + emit_rma(as, XO_ADDSD, tmp, lj_ir_k64_find(as->J, + LJ_64 ? U64x(c3f00000,00000000) : U64x(c1e00000,00000000))); + else + emit_rma(as, XO_ADDSS, tmp, lj_ir_k64_find(as->J, + LJ_64 ? U64x(00000000,df800000) : U64x(00000000,cf000000))); + emit_sjcc(as, CC_NS, l_end); + emit_rr(as, XO_TEST, dest|REX_64, dest); /* Check if dest negative. */ + emit_rr(as, op, dest|REX_64, tmp); + ra_left(as, tmp, lref); + } else { + Reg left = asm_fuseload(as, lref, RSET_FPR); + if (LJ_64 && irt_isu32(ir->t)) + emit_rr(as, XO_MOV, dest, dest); /* Zero hiword. */ + emit_mrm(as, op, + dest|((LJ_64 && + (irt_is64(ir->t) || irt_isu32(ir->t))) ? REX_64 : 0), + left); + } + } + } else if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ + Reg left, dest = ra_dest(as, ir, RSET_GPR); + RegSet allow = RSET_GPR; + x86Op op; + lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); + if (st == IRT_I8) { + op = XO_MOVSXb; allow = RSET_GPR8; dest |= FORCE_REX; + } else if (st == IRT_U8) { + op = XO_MOVZXb; allow = RSET_GPR8; dest |= FORCE_REX; + } else if (st == IRT_I16) { + op = XO_MOVSXw; + } else { + op = XO_MOVZXw; + } + left = asm_fuseload(as, lref, allow); + /* Add extra MOV if source is already in wrong register. */ + if (!LJ_64 && left != RID_MRM && !rset_test(allow, left)) { + Reg tmp = ra_scratch(as, allow); + emit_rr(as, op, dest, tmp); + emit_rr(as, XO_MOV, tmp, left); + } else { + emit_mrm(as, op, dest, left); + } + } else { /* 32/64 bit integer conversions. */ + if (LJ_32) { /* Only need to handle 32/32 bit no-op (cast) on x86. */ + Reg dest = ra_dest(as, ir, RSET_GPR); + ra_left(as, dest, lref); /* Do nothing, but may need to move regs. */ + } else if (irt_is64(ir->t)) { + Reg dest = ra_dest(as, ir, RSET_GPR); + if (st64 || !(ir->op2 & IRCONV_SEXT)) { + /* 64/64 bit no-op (cast) or 32 to 64 bit zero extension. */ + ra_left(as, dest, lref); /* Do nothing, but may need to move regs. */ + } else { /* 32 to 64 bit sign extension. */ + Reg left = asm_fuseload(as, lref, RSET_GPR); + emit_mrm(as, XO_MOVSXd, dest|REX_64, left); + } + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + if (st64) { + Reg left = asm_fuseload(as, lref, RSET_GPR); + /* This is either a 32 bit reg/reg mov which zeroes the hiword + ** or a load of the loword from a 64 bit address. + */ + emit_mrm(as, XO_MOV, dest, left); + } else { /* 32/32 bit no-op (cast). */ + ra_left(as, dest, lref); /* Do nothing, but may need to move regs. */ + } + } + } +} + +#if LJ_32 && LJ_HASFFI +/* No SSE conversions to/from 64 bit on x86, so resort to ugly x87 code. */ + +/* 64 bit integer to FP conversion in 32 bit mode. */ +static void asm_conv_fp_int64(ASMState *as, IRIns *ir) +{ + Reg hi = ra_alloc1(as, ir->op1, RSET_GPR); + Reg lo = ra_alloc1(as, (ir-1)->op1, rset_exclude(RSET_GPR, hi)); + int32_t ofs = sps_scale(ir->s); /* Use spill slot or temp slots. */ + Reg dest = ir->r; + if (ra_hasreg(dest)) { + ra_free(as, dest); + ra_modified(as, dest); + emit_rmro(as, irt_isnum(ir->t) ? XMM_MOVRM(as) : XO_MOVSS, + dest, RID_ESP, ofs); + } + emit_rmro(as, irt_isnum(ir->t) ? XO_FSTPq : XO_FSTPd, + irt_isnum(ir->t) ? XOg_FSTPq : XOg_FSTPd, RID_ESP, ofs); + if (((ir-1)->op2 & IRCONV_SRCMASK) == IRT_U64) { + /* For inputs in [2^63,2^64-1] add 2^64 to compensate. */ + MCLabel l_end = emit_label(as); + emit_rma(as, XO_FADDq, XOg_FADDq, + lj_ir_k64_find(as->J, U64x(43f00000,00000000))); + emit_sjcc(as, CC_NS, l_end); + emit_rr(as, XO_TEST, hi, hi); /* Check if u64 >= 2^63. */ + } else { + lua_assert(((ir-1)->op2 & IRCONV_SRCMASK) == IRT_I64); + } + emit_rmro(as, XO_FILDq, XOg_FILDq, RID_ESP, 0); + /* NYI: Avoid narrow-to-wide store-to-load forwarding stall. */ + emit_rmro(as, XO_MOVto, hi, RID_ESP, 4); + emit_rmro(as, XO_MOVto, lo, RID_ESP, 0); +} + +/* FP to 64 bit integer conversion in 32 bit mode. */ +static void asm_conv_int64_fp(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); + IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); + Reg lo, hi; + lua_assert(st == IRT_NUM || st == IRT_FLOAT); + lua_assert(dt == IRT_I64 || dt == IRT_U64); + lua_assert(((ir-1)->op2 & IRCONV_TRUNC)); + hi = ra_dest(as, ir, RSET_GPR); + lo = ra_dest(as, ir-1, rset_exclude(RSET_GPR, hi)); + if (ra_used(ir-1)) emit_rmro(as, XO_MOV, lo, RID_ESP, 0); + /* NYI: Avoid wide-to-narrow store-to-load forwarding stall. */ + if (!(as->flags & JIT_F_SSE3)) { /* Set FPU rounding mode to default. */ + emit_rmro(as, XO_FLDCW, XOg_FLDCW, RID_ESP, 4); + emit_rmro(as, XO_MOVto, lo, RID_ESP, 4); + emit_gri(as, XG_ARITHi(XOg_AND), lo, 0xf3ff); + } + if (dt == IRT_U64) { + /* For inputs in [2^63,2^64-1] add -2^64 and convert again. */ + MCLabel l_pop, l_end = emit_label(as); + emit_x87op(as, XI_FPOP); + l_pop = emit_label(as); + emit_sjmp(as, l_end); + emit_rmro(as, XO_MOV, hi, RID_ESP, 4); + if ((as->flags & JIT_F_SSE3)) + emit_rmro(as, XO_FISTTPq, XOg_FISTTPq, RID_ESP, 0); + else + emit_rmro(as, XO_FISTPq, XOg_FISTPq, RID_ESP, 0); + emit_rma(as, XO_FADDq, XOg_FADDq, + lj_ir_k64_find(as->J, U64x(c3f00000,00000000))); + emit_sjcc(as, CC_NS, l_pop); + emit_rr(as, XO_TEST, hi, hi); /* Check if out-of-range (2^63). */ + } + emit_rmro(as, XO_MOV, hi, RID_ESP, 4); + if ((as->flags & JIT_F_SSE3)) { /* Truncation is easy with SSE3. */ + emit_rmro(as, XO_FISTTPq, XOg_FISTTPq, RID_ESP, 0); + } else { /* Otherwise set FPU rounding mode to truncate before the store. */ + emit_rmro(as, XO_FISTPq, XOg_FISTPq, RID_ESP, 0); + emit_rmro(as, XO_FLDCW, XOg_FLDCW, RID_ESP, 0); + emit_rmro(as, XO_MOVtow, lo, RID_ESP, 0); + emit_rmro(as, XO_ARITHw(XOg_OR), lo, RID_ESP, 0); + emit_loadi(as, lo, 0xc00); + emit_rmro(as, XO_FNSTCW, XOg_FNSTCW, RID_ESP, 0); + } + if (dt == IRT_U64) + emit_x87op(as, XI_FDUP); + emit_mrm(as, st == IRT_NUM ? XO_FLDq : XO_FLDd, + st == IRT_NUM ? XOg_FLDq: XOg_FLDd, + asm_fuseload(as, ir->op1, RSET_EMPTY)); +} +#endif + +static void asm_strto(ASMState *as, IRIns *ir) +{ + /* Force a spill slot for the destination register (if any). */ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; + IRRef args[2]; + RegSet drop = RSET_SCRATCH; + if ((drop & RSET_FPR) != RSET_FPR && ra_hasreg(ir->r)) + rset_set(drop, ir->r); /* WIN64 doesn't spill all FPRs. */ + ra_evictset(as, drop); + asm_guardcc(as, CC_E); + emit_rr(as, XO_TEST, RID_RET, RID_RET); /* Test return status. */ + args[0] = ir->op1; /* GCstr *str */ + args[1] = ASMREF_TMP1; /* TValue *n */ + asm_gencall(as, ci, args); + /* Store the result to the spill slot or temp slots. */ + emit_rmro(as, XO_LEA, ra_releasetmp(as, ASMREF_TMP1)|REX_64, + RID_ESP, sps_scale(ir->s)); +} + +static void asm_tostr(ASMState *as, IRIns *ir) +{ + IRIns *irl = IR(ir->op1); + IRRef args[2]; + args[0] = ASMREF_L; + as->gcsteps++; + if (irt_isnum(irl->t)) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; + args[1] = ASMREF_TMP1; /* const lua_Number * */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + emit_rmro(as, XO_LEA, ra_releasetmp(as, ASMREF_TMP1)|REX_64, + RID_ESP, ra_spill(as, irl)); + } else { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; + args[1] = ir->op1; /* int32_t k */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + } +} + +/* -- Memory references --------------------------------------------------- */ + +static void asm_aref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + asm_fusearef(as, ir, RSET_GPR); + if (!(as->mrm.idx == RID_NONE && as->mrm.ofs == 0)) + emit_mrm(as, XO_LEA, dest, RID_MRM); + else if (as->mrm.base != dest) + emit_rr(as, XO_MOV, dest, as->mrm.base); +} + +/* Merge NE(HREF, niltv) check. */ +static MCode *merge_href_niltv(ASMState *as, IRIns *ir) +{ + /* Assumes nothing else generates NE of HREF. */ + if ((ir[1].o == IR_NE || ir[1].o == IR_EQ) && ir[1].op1 == as->curins && + ra_hasreg(ir->r)) { + MCode *p = as->mcp; + p += (LJ_64 && *p != XI_ARITHi) ? 7+6 : 6+6; + /* Ensure no loop branch inversion happened. */ + if (p[-6] == 0x0f && p[-5] == XI_JCCn+(CC_NE^(ir[1].o & 1))) { + as->mcp = p; /* Kill cmp reg, imm32 + jz exit. */ + return p + *(int32_t *)(p-4); /* Return exit address. */ + } + } + return NULL; +} + +/* Inlined hash lookup. Specialized for key type and for const keys. +** The equivalent C code is: +** Node *n = hashkey(t, key); +** do { +** if (lj_obj_equal(&n->key, key)) return &n->val; +** } while ((n = nextnode(n))); +** return niltv(L); +*/ +static void asm_href(ASMState *as, IRIns *ir) +{ + MCode *nilexit = merge_href_niltv(as, ir); /* Do this before any restores. */ + RegSet allow = RSET_GPR; + Reg dest = ra_dest(as, ir, allow); + Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); + Reg key = RID_NONE, tmp = RID_NONE; + IRIns *irkey = IR(ir->op2); + int isk = irref_isk(ir->op2); + IRType1 kt = irkey->t; + uint32_t khash; + MCLabel l_end, l_loop, l_next; + + if (!isk) { + rset_clear(allow, tab); + key = ra_alloc1(as, ir->op2, irt_isnum(kt) ? RSET_FPR : allow); + if (!irt_isstr(kt)) + tmp = ra_scratch(as, rset_exclude(allow, key)); + } + + /* Key not found in chain: jump to exit (if merged with NE) or load niltv. */ + l_end = emit_label(as); + if (nilexit && ir[1].o == IR_NE) { + emit_jcc(as, CC_E, nilexit); /* XI_JMP is not found by lj_asm_patchexit. */ + nilexit = NULL; + } else { + emit_loada(as, dest, niltvg(J2G(as->J))); + } + + /* Follow hash chain until the end. */ + l_loop = emit_sjcc_label(as, CC_NZ); + emit_rr(as, XO_TEST, dest, dest); + emit_rmro(as, XO_MOV, dest, dest, offsetof(Node, next)); + l_next = emit_label(as); + + /* Type and value comparison. */ + if (nilexit) + emit_jcc(as, CC_E, nilexit); + else + emit_sjcc(as, CC_E, l_end); + if (irt_isnum(kt)) { + if (isk) { + /* Assumes -0.0 is already canonicalized to +0.0. */ + emit_gmroi(as, XG_ARITHi(XOg_CMP), dest, offsetof(Node, key.u32.lo), + (int32_t)ir_knum(irkey)->u32.lo); + emit_sjcc(as, CC_NE, l_next); + emit_gmroi(as, XG_ARITHi(XOg_CMP), dest, offsetof(Node, key.u32.hi), + (int32_t)ir_knum(irkey)->u32.hi); + } else { + emit_sjcc(as, CC_P, l_next); + emit_rmro(as, XO_UCOMISD, key, dest, offsetof(Node, key.n)); + emit_sjcc(as, CC_AE, l_next); + /* The type check avoids NaN penalties and complaints from Valgrind. */ +#if LJ_64 + emit_u32(as, LJ_TISNUM); + emit_rmro(as, XO_ARITHi, XOg_CMP, dest, offsetof(Node, key.it)); +#else + emit_i8(as, LJ_TISNUM); + emit_rmro(as, XO_ARITHi8, XOg_CMP, dest, offsetof(Node, key.it)); +#endif + } +#if LJ_64 + } else if (irt_islightud(kt)) { + emit_rmro(as, XO_CMP, key|REX_64, dest, offsetof(Node, key.u64)); +#endif + } else { + if (!irt_ispri(kt)) { + lua_assert(irt_isaddr(kt)); + if (isk) + emit_gmroi(as, XG_ARITHi(XOg_CMP), dest, offsetof(Node, key.gcr), + ptr2addr(ir_kgc(irkey))); + else + emit_rmro(as, XO_CMP, key, dest, offsetof(Node, key.gcr)); + emit_sjcc(as, CC_NE, l_next); + } + lua_assert(!irt_isnil(kt)); + emit_i8(as, irt_toitype(kt)); + emit_rmro(as, XO_ARITHi8, XOg_CMP, dest, offsetof(Node, key.it)); + } + emit_sfixup(as, l_loop); + checkmclim(as); + + /* Load main position relative to tab->node into dest. */ + khash = isk ? ir_khash(irkey) : 1; + if (khash == 0) { + emit_rmro(as, XO_MOV, dest, tab, offsetof(GCtab, node)); + } else { + emit_rmro(as, XO_ARITH(XOg_ADD), dest, tab, offsetof(GCtab, node)); + if ((as->flags & JIT_F_PREFER_IMUL)) { + emit_i8(as, sizeof(Node)); + emit_rr(as, XO_IMULi8, dest, dest); + } else { + emit_shifti(as, XOg_SHL, dest, 3); + emit_rmrxo(as, XO_LEA, dest, dest, dest, XM_SCALE2, 0); + } + if (isk) { + emit_gri(as, XG_ARITHi(XOg_AND), dest, (int32_t)khash); + emit_rmro(as, XO_MOV, dest, tab, offsetof(GCtab, hmask)); + } else if (irt_isstr(kt)) { + emit_rmro(as, XO_ARITH(XOg_AND), dest, key, offsetof(GCstr, hash)); + emit_rmro(as, XO_MOV, dest, tab, offsetof(GCtab, hmask)); + } else { /* Must match with hashrot() in lj_tab.c. */ + emit_rmro(as, XO_ARITH(XOg_AND), dest, tab, offsetof(GCtab, hmask)); + emit_rr(as, XO_ARITH(XOg_SUB), dest, tmp); + emit_shifti(as, XOg_ROL, tmp, HASH_ROT3); + emit_rr(as, XO_ARITH(XOg_XOR), dest, tmp); + emit_shifti(as, XOg_ROL, dest, HASH_ROT2); + emit_rr(as, XO_ARITH(XOg_SUB), tmp, dest); + emit_shifti(as, XOg_ROL, dest, HASH_ROT1); + emit_rr(as, XO_ARITH(XOg_XOR), tmp, dest); + if (irt_isnum(kt)) { + emit_rr(as, XO_ARITH(XOg_ADD), dest, dest); +#if LJ_64 + emit_shifti(as, XOg_SHR|REX_64, dest, 32); + emit_rr(as, XO_MOV, tmp, dest); + emit_rr(as, XO_MOVDto, key|REX_64, dest); +#else + emit_rmro(as, XO_MOV, dest, RID_ESP, ra_spill(as, irkey)+4); + emit_rr(as, XO_MOVDto, key, tmp); +#endif + } else { + emit_rr(as, XO_MOV, tmp, key); + emit_rmro(as, XO_LEA, dest, key, HASH_BIAS); + } + } + } +} + +static void asm_hrefk(ASMState *as, IRIns *ir) +{ + IRIns *kslot = IR(ir->op2); + IRIns *irkey = IR(kslot->op1); + int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); + Reg dest = ra_used(ir) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; + Reg node = ra_alloc1(as, ir->op1, RSET_GPR); +#if !LJ_64 + MCLabel l_exit; +#endif + lua_assert(ofs % sizeof(Node) == 0); + if (ra_hasreg(dest)) { + if (ofs != 0) { + if (dest == node && !(as->flags & JIT_F_LEA_AGU)) + emit_gri(as, XG_ARITHi(XOg_ADD), dest, ofs); + else + emit_rmro(as, XO_LEA, dest, node, ofs); + } else if (dest != node) { + emit_rr(as, XO_MOV, dest, node); + } + } + asm_guardcc(as, CC_NE); +#if LJ_64 + if (!irt_ispri(irkey->t)) { + Reg key = ra_scratch(as, rset_exclude(RSET_GPR, node)); + emit_rmro(as, XO_CMP, key|REX_64, node, + ofs + (int32_t)offsetof(Node, key.u64)); + lua_assert(irt_isnum(irkey->t) || irt_isgcv(irkey->t)); + /* Assumes -0.0 is already canonicalized to +0.0. */ + emit_loadu64(as, key, irt_isnum(irkey->t) ? ir_knum(irkey)->u64 : + ((uint64_t)irt_toitype(irkey->t) << 32) | + (uint64_t)(uint32_t)ptr2addr(ir_kgc(irkey))); + } else { + lua_assert(!irt_isnil(irkey->t)); + emit_i8(as, irt_toitype(irkey->t)); + emit_rmro(as, XO_ARITHi8, XOg_CMP, node, + ofs + (int32_t)offsetof(Node, key.it)); + } +#else + l_exit = emit_label(as); + if (irt_isnum(irkey->t)) { + /* Assumes -0.0 is already canonicalized to +0.0. */ + emit_gmroi(as, XG_ARITHi(XOg_CMP), node, + ofs + (int32_t)offsetof(Node, key.u32.lo), + (int32_t)ir_knum(irkey)->u32.lo); + emit_sjcc(as, CC_NE, l_exit); + emit_gmroi(as, XG_ARITHi(XOg_CMP), node, + ofs + (int32_t)offsetof(Node, key.u32.hi), + (int32_t)ir_knum(irkey)->u32.hi); + } else { + if (!irt_ispri(irkey->t)) { + lua_assert(irt_isgcv(irkey->t)); + emit_gmroi(as, XG_ARITHi(XOg_CMP), node, + ofs + (int32_t)offsetof(Node, key.gcr), + ptr2addr(ir_kgc(irkey))); + emit_sjcc(as, CC_NE, l_exit); + } + lua_assert(!irt_isnil(irkey->t)); + emit_i8(as, irt_toitype(irkey->t)); + emit_rmro(as, XO_ARITHi8, XOg_CMP, node, + ofs + (int32_t)offsetof(Node, key.it)); + } +#endif +} + +static void asm_newref(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; + IRRef args[3]; + IRIns *irkey; + Reg tmp; + if (ir->r == RID_SINK) + return; + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ir->op1; /* GCtab *t */ + args[2] = ASMREF_TMP1; /* cTValue *key */ + asm_setupresult(as, ir, ci); /* TValue * */ + asm_gencall(as, ci, args); + tmp = ra_releasetmp(as, ASMREF_TMP1); + irkey = IR(ir->op2); + if (irt_isnum(irkey->t)) { + /* For numbers use the constant itself or a spill slot as a TValue. */ + if (irref_isk(ir->op2)) + emit_loada(as, tmp, ir_knum(irkey)); + else + emit_rmro(as, XO_LEA, tmp|REX_64, RID_ESP, ra_spill(as, irkey)); + } else { + /* Otherwise use g->tmptv to hold the TValue. */ + if (!irref_isk(ir->op2)) { + Reg src = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, tmp)); + emit_movtomro(as, REX_64IR(irkey, src), tmp, 0); + } else if (!irt_ispri(irkey->t)) { + emit_movmroi(as, tmp, 0, irkey->i); + } + if (!(LJ_64 && irt_islightud(irkey->t))) + emit_movmroi(as, tmp, 4, irt_toitype(irkey->t)); + emit_loada(as, tmp, &J2G(as->J)->tmptv); + } +} + +static void asm_uref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; + emit_rma(as, XO_MOV, dest, v); + } else { + Reg uv = ra_scratch(as, RSET_GPR); + Reg func = ra_alloc1(as, ir->op1, RSET_GPR); + if (ir->o == IR_UREFC) { + emit_rmro(as, XO_LEA, dest, uv, offsetof(GCupval, tv)); + asm_guardcc(as, CC_NE); + emit_i8(as, 1); + emit_rmro(as, XO_ARITHib, XOg_CMP, uv, offsetof(GCupval, closed)); + } else { + emit_rmro(as, XO_MOV, dest, uv, offsetof(GCupval, v)); + } + emit_rmro(as, XO_MOV, uv, func, + (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); + } +} + +static void asm_fref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + asm_fusefref(as, ir, RSET_GPR); + emit_mrm(as, XO_LEA, dest, RID_MRM); +} + +static void asm_strref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + asm_fusestrref(as, ir, RSET_GPR); + if (as->mrm.base == RID_NONE) + emit_loadi(as, dest, as->mrm.ofs); + else if (as->mrm.base == dest && as->mrm.idx == RID_NONE) + emit_gri(as, XG_ARITHi(XOg_ADD), dest, as->mrm.ofs); + else + emit_mrm(as, XO_LEA, dest, RID_MRM); +} + +/* -- Loads and stores ---------------------------------------------------- */ + +static void asm_fxload(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); + x86Op xo; + if (ir->o == IR_FLOAD) + asm_fusefref(as, ir, RSET_GPR); + else + asm_fusexref(as, ir->op1, RSET_GPR); + /* ir->op2 is ignored -- unaligned loads are ok on x86. */ + switch (irt_type(ir->t)) { + case IRT_I8: xo = XO_MOVSXb; break; + case IRT_U8: xo = XO_MOVZXb; break; + case IRT_I16: xo = XO_MOVSXw; break; + case IRT_U16: xo = XO_MOVZXw; break; + case IRT_NUM: xo = XMM_MOVRM(as); break; + case IRT_FLOAT: xo = XO_MOVSS; break; + default: + if (LJ_64 && irt_is64(ir->t)) + dest |= REX_64; + else + lua_assert(irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)); + xo = XO_MOV; + break; + } + emit_mrm(as, xo, dest, RID_MRM); +} + +static void asm_fxstore(ASMState *as, IRIns *ir) +{ + RegSet allow = RSET_GPR; + Reg src = RID_NONE, osrc = RID_NONE; + int32_t k = 0; + if (ir->r == RID_SINK) + return; + /* The IRT_I16/IRT_U16 stores should never be simplified for constant + ** values since mov word [mem], imm16 has a length-changing prefix. + */ + if (irt_isi16(ir->t) || irt_isu16(ir->t) || irt_isfp(ir->t) || + !asm_isk32(as, ir->op2, &k)) { + RegSet allow8 = irt_isfp(ir->t) ? RSET_FPR : + (irt_isi8(ir->t) || irt_isu8(ir->t)) ? RSET_GPR8 : RSET_GPR; + src = osrc = ra_alloc1(as, ir->op2, allow8); + if (!LJ_64 && !rset_test(allow8, src)) { /* Already in wrong register. */ + rset_clear(allow, osrc); + src = ra_scratch(as, allow8); + } + rset_clear(allow, src); + } + if (ir->o == IR_FSTORE) { + asm_fusefref(as, IR(ir->op1), allow); + } else { + asm_fusexref(as, ir->op1, allow); + if (LJ_32 && ir->o == IR_HIOP) as->mrm.ofs += 4; + } + if (ra_hasreg(src)) { + x86Op xo; + switch (irt_type(ir->t)) { + case IRT_I8: case IRT_U8: xo = XO_MOVtob; src |= FORCE_REX; break; + case IRT_I16: case IRT_U16: xo = XO_MOVtow; break; + case IRT_NUM: xo = XO_MOVSDto; break; + case IRT_FLOAT: xo = XO_MOVSSto; break; +#if LJ_64 + case IRT_LIGHTUD: lua_assert(0); /* NYI: mask 64 bit lightuserdata. */ +#endif + default: + if (LJ_64 && irt_is64(ir->t)) + src |= REX_64; + else + lua_assert(irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)); + xo = XO_MOVto; + break; + } + emit_mrm(as, xo, src, RID_MRM); + if (!LJ_64 && src != osrc) { + ra_noweak(as, osrc); + emit_rr(as, XO_MOV, src, osrc); + } + } else { + if (irt_isi8(ir->t) || irt_isu8(ir->t)) { + emit_i8(as, k); + emit_mrm(as, XO_MOVmib, 0, RID_MRM); + } else { + lua_assert(irt_is64(ir->t) || irt_isint(ir->t) || irt_isu32(ir->t) || + irt_isaddr(ir->t)); + emit_i32(as, k); + emit_mrm(as, XO_MOVmi, REX_64IR(ir, 0), RID_MRM); + } + } +} + +#if LJ_64 +static Reg asm_load_lightud64(ASMState *as, IRIns *ir, int typecheck) +{ + if (ra_used(ir) || typecheck) { + Reg dest = ra_dest(as, ir, RSET_GPR); + if (typecheck) { + Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, dest)); + asm_guardcc(as, CC_NE); + emit_i8(as, -2); + emit_rr(as, XO_ARITHi8, XOg_CMP, tmp); + emit_shifti(as, XOg_SAR|REX_64, tmp, 47); + emit_rr(as, XO_MOV, tmp|REX_64, dest); + } + return dest; + } else { + return RID_NONE; + } +} +#endif + +static void asm_ahuvload(ASMState *as, IRIns *ir) +{ + lua_assert(irt_isnum(ir->t) || irt_ispri(ir->t) || irt_isaddr(ir->t) || + (LJ_DUALNUM && irt_isint(ir->t))); +#if LJ_64 + if (irt_islightud(ir->t)) { + Reg dest = asm_load_lightud64(as, ir, 1); + if (ra_hasreg(dest)) { + asm_fuseahuref(as, ir->op1, RSET_GPR); + emit_mrm(as, XO_MOV, dest|REX_64, RID_MRM); + } + return; + } else +#endif + if (ra_used(ir)) { + RegSet allow = irt_isnum(ir->t) ? RSET_FPR : RSET_GPR; + Reg dest = ra_dest(as, ir, allow); + asm_fuseahuref(as, ir->op1, RSET_GPR); + emit_mrm(as, dest < RID_MAX_GPR ? XO_MOV : XMM_MOVRM(as), dest, RID_MRM); + } else { + asm_fuseahuref(as, ir->op1, RSET_GPR); + } + /* Always do the type check, even if the load result is unused. */ + as->mrm.ofs += 4; + asm_guardcc(as, irt_isnum(ir->t) ? CC_AE : CC_NE); + if (LJ_64 && irt_type(ir->t) >= IRT_NUM) { + lua_assert(irt_isinteger(ir->t) || irt_isnum(ir->t)); + emit_u32(as, LJ_TISNUM); + emit_mrm(as, XO_ARITHi, XOg_CMP, RID_MRM); + } else { + emit_i8(as, irt_toitype(ir->t)); + emit_mrm(as, XO_ARITHi8, XOg_CMP, RID_MRM); + } +} + +static void asm_ahustore(ASMState *as, IRIns *ir) +{ + if (ir->r == RID_SINK) + return; + if (irt_isnum(ir->t)) { + Reg src = ra_alloc1(as, ir->op2, RSET_FPR); + asm_fuseahuref(as, ir->op1, RSET_GPR); + emit_mrm(as, XO_MOVSDto, src, RID_MRM); +#if LJ_64 + } else if (irt_islightud(ir->t)) { + Reg src = ra_alloc1(as, ir->op2, RSET_GPR); + asm_fuseahuref(as, ir->op1, rset_exclude(RSET_GPR, src)); + emit_mrm(as, XO_MOVto, src|REX_64, RID_MRM); +#endif + } else { + IRIns *irr = IR(ir->op2); + RegSet allow = RSET_GPR; + Reg src = RID_NONE; + if (!irref_isk(ir->op2)) { + src = ra_alloc1(as, ir->op2, allow); + rset_clear(allow, src); + } + asm_fuseahuref(as, ir->op1, allow); + if (ra_hasreg(src)) { + emit_mrm(as, XO_MOVto, src, RID_MRM); + } else if (!irt_ispri(irr->t)) { + lua_assert(irt_isaddr(ir->t) || (LJ_DUALNUM && irt_isinteger(ir->t))); + emit_i32(as, irr->i); + emit_mrm(as, XO_MOVmi, 0, RID_MRM); + } + as->mrm.ofs += 4; + emit_i32(as, (int32_t)irt_toitype(ir->t)); + emit_mrm(as, XO_MOVmi, 0, RID_MRM); + } +} + +static void asm_sload(ASMState *as, IRIns *ir) +{ + int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 4 : 0); + IRType1 t = ir->t; + Reg base; + lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ + lua_assert(irt_isguard(t) || !(ir->op2 & IRSLOAD_TYPECHECK)); + lua_assert(LJ_DUALNUM || + !irt_isint(t) || (ir->op2 & (IRSLOAD_CONVERT|IRSLOAD_FRAME))); + if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(t) && irt_isint(t)) { + Reg left = ra_scratch(as, RSET_FPR); + asm_tointg(as, ir, left); /* Frees dest reg. Do this before base alloc. */ + base = ra_alloc1(as, REF_BASE, RSET_GPR); + emit_rmro(as, XMM_MOVRM(as), left, base, ofs); + t.irt = IRT_NUM; /* Continue with a regular number type check. */ +#if LJ_64 + } else if (irt_islightud(t)) { + Reg dest = asm_load_lightud64(as, ir, (ir->op2 & IRSLOAD_TYPECHECK)); + if (ra_hasreg(dest)) { + base = ra_alloc1(as, REF_BASE, RSET_GPR); + emit_rmro(as, XO_MOV, dest|REX_64, base, ofs); + } + return; +#endif + } else if (ra_used(ir)) { + RegSet allow = irt_isnum(t) ? RSET_FPR : RSET_GPR; + Reg dest = ra_dest(as, ir, allow); + base = ra_alloc1(as, REF_BASE, RSET_GPR); + lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); + if ((ir->op2 & IRSLOAD_CONVERT)) { + t.irt = irt_isint(t) ? IRT_NUM : IRT_INT; /* Check for original type. */ + emit_rmro(as, irt_isint(t) ? XO_CVTSI2SD : XO_CVTSD2SI, dest, base, ofs); + } else if (irt_isnum(t)) { + emit_rmro(as, XMM_MOVRM(as), dest, base, ofs); + } else { + emit_rmro(as, XO_MOV, dest, base, ofs); + } + } else { + if (!(ir->op2 & IRSLOAD_TYPECHECK)) + return; /* No type check: avoid base alloc. */ + base = ra_alloc1(as, REF_BASE, RSET_GPR); + } + if ((ir->op2 & IRSLOAD_TYPECHECK)) { + /* Need type check, even if the load result is unused. */ + asm_guardcc(as, irt_isnum(t) ? CC_AE : CC_NE); + if (LJ_64 && irt_type(t) >= IRT_NUM) { + lua_assert(irt_isinteger(t) || irt_isnum(t)); + emit_u32(as, LJ_TISNUM); + emit_rmro(as, XO_ARITHi, XOg_CMP, base, ofs+4); + } else { + emit_i8(as, irt_toitype(t)); + emit_rmro(as, XO_ARITHi8, XOg_CMP, base, ofs+4); + } + } +} + +/* -- Allocations --------------------------------------------------------- */ + +#if LJ_HASFFI +static void asm_cnew(ASMState *as, IRIns *ir) +{ + CTState *cts = ctype_ctsG(J2G(as->J)); + CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; + CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? + lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; + IRRef args[2]; + lua_assert(sz != CTSIZE_INVALID); + + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ASMREF_TMP1; /* MSize size */ + as->gcsteps++; + asm_setupresult(as, ir, ci); /* GCcdata * */ + + /* Initialize immutable cdata object. */ + if (ir->o == IR_CNEWI) { + RegSet allow = (RSET_GPR & ~RSET_SCRATCH); +#if LJ_64 + Reg r64 = sz == 8 ? REX_64 : 0; + if (irref_isk(ir->op2)) { + IRIns *irk = IR(ir->op2); + uint64_t k = irk->o == IR_KINT64 ? ir_k64(irk)->u64 : + (uint64_t)(uint32_t)irk->i; + if (sz == 4 || checki32((int64_t)k)) { + emit_i32(as, (int32_t)k); + emit_rmro(as, XO_MOVmi, r64, RID_RET, sizeof(GCcdata)); + } else { + emit_movtomro(as, RID_ECX + r64, RID_RET, sizeof(GCcdata)); + emit_loadu64(as, RID_ECX, k); + } + } else { + Reg r = ra_alloc1(as, ir->op2, allow); + emit_movtomro(as, r + r64, RID_RET, sizeof(GCcdata)); + } +#else + int32_t ofs = sizeof(GCcdata); + if (sz == 8) { + ofs += 4; ir++; + lua_assert(ir->o == IR_HIOP); + } + do { + if (irref_isk(ir->op2)) { + emit_movmroi(as, RID_RET, ofs, IR(ir->op2)->i); + } else { + Reg r = ra_alloc1(as, ir->op2, allow); + emit_movtomro(as, r, RID_RET, ofs); + rset_clear(allow, r); + } + if (ofs == sizeof(GCcdata)) break; + ofs -= 4; ir--; + } while (1); +#endif + lua_assert(sz == 4 || sz == 8); + } + + /* Combine initialization of marked, gct and ctypeid. */ + emit_movtomro(as, RID_ECX, RID_RET, offsetof(GCcdata, marked)); + emit_gri(as, XG_ARITHi(XOg_OR), RID_ECX, + (int32_t)((~LJ_TCDATA<<8)+(ctypeid<<16))); + emit_gri(as, XG_ARITHi(XOg_AND), RID_ECX, LJ_GC_WHITES); + emit_opgl(as, XO_MOVZXb, RID_ECX, gc.currentwhite); + + asm_gencall(as, ci, args); + emit_loadi(as, ra_releasetmp(as, ASMREF_TMP1), (int32_t)(sz+sizeof(GCcdata))); +} +#else +#define asm_cnew(as, ir) ((void)0) +#endif + +/* -- Write barriers ------------------------------------------------------ */ + +static void asm_tbar(ASMState *as, IRIns *ir) +{ + Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); + Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, tab)); + MCLabel l_end = emit_label(as); + emit_movtomro(as, tmp, tab, offsetof(GCtab, gclist)); + emit_setgl(as, tab, gc.grayagain); + emit_getgl(as, tmp, gc.grayagain); + emit_i8(as, ~LJ_GC_BLACK); + emit_rmro(as, XO_ARITHib, XOg_AND, tab, offsetof(GCtab, marked)); + emit_sjcc(as, CC_Z, l_end); + emit_i8(as, LJ_GC_BLACK); + emit_rmro(as, XO_GROUP3b, XOg_TEST, tab, offsetof(GCtab, marked)); +} + +static void asm_obar(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; + IRRef args[2]; + MCLabel l_end; + Reg obj; + /* No need for other object barriers (yet). */ + lua_assert(IR(ir->op1)->o == IR_UREFC); + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ir->op1; /* TValue *tv */ + asm_gencall(as, ci, args); + emit_loada(as, ra_releasetmp(as, ASMREF_TMP1), J2G(as->J)); + obj = IR(ir->op1)->r; + emit_sjcc(as, CC_Z, l_end); + emit_i8(as, LJ_GC_WHITES); + if (irref_isk(ir->op2)) { + GCobj *vp = ir_kgc(IR(ir->op2)); + emit_rma(as, XO_GROUP3b, XOg_TEST, &vp->gch.marked); + } else { + Reg val = ra_alloc1(as, ir->op2, rset_exclude(RSET_SCRATCH&RSET_GPR, obj)); + emit_rmro(as, XO_GROUP3b, XOg_TEST, val, (int32_t)offsetof(GChead, marked)); + } + emit_sjcc(as, CC_Z, l_end); + emit_i8(as, LJ_GC_BLACK); + emit_rmro(as, XO_GROUP3b, XOg_TEST, obj, + (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); +} + +/* -- FP/int arithmetic and logic operations ------------------------------ */ + +/* Load reference onto x87 stack. Force a spill to memory if needed. */ +static void asm_x87load(ASMState *as, IRRef ref) +{ + IRIns *ir = IR(ref); + if (ir->o == IR_KNUM) { + cTValue *tv = ir_knum(ir); + if (tvispzero(tv)) /* Use fldz only for +0. */ + emit_x87op(as, XI_FLDZ); + else if (tvispone(tv)) + emit_x87op(as, XI_FLD1); + else + emit_rma(as, XO_FLDq, XOg_FLDq, tv); + } else if (ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT && !ra_used(ir) && + !irref_isk(ir->op1) && mayfuse(as, ir->op1)) { + IRIns *iri = IR(ir->op1); + emit_rmro(as, XO_FILDd, XOg_FILDd, RID_ESP, ra_spill(as, iri)); + } else { + emit_mrm(as, XO_FLDq, XOg_FLDq, asm_fuseload(as, ref, RSET_EMPTY)); + } +} + +/* Try to rejoin pow from EXP2, MUL and LOG2 (if still unsplit). */ +static int fpmjoin_pow(ASMState *as, IRIns *ir) +{ + IRIns *irp = IR(ir->op1); + if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { + IRIns *irpp = IR(irp->op1); + if (irpp == ir-2 && irpp->o == IR_FPMATH && + irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { + /* The modified regs must match with the *.dasc implementation. */ + RegSet drop = RSET_RANGE(RID_XMM0, RID_XMM2+1)|RID2RSET(RID_EAX); + IRIns *irx; + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + ra_evictset(as, drop); + ra_destreg(as, ir, RID_XMM0); + emit_call(as, lj_vm_pow_sse); + irx = IR(irpp->op1); + if (ra_noreg(irx->r) && ra_gethint(irx->r) == RID_XMM1) + irx->r = RID_INIT; /* Avoid allocating xmm1 for x. */ + ra_left(as, RID_XMM0, irpp->op1); + ra_left(as, RID_XMM1, irp->op2); + return 1; + } + } + return 0; +} + +static void asm_fpmath(ASMState *as, IRIns *ir) +{ + IRFPMathOp fpm = ir->o == IR_FPMATH ? (IRFPMathOp)ir->op2 : IRFPM_OTHER; + if (fpm == IRFPM_SQRT) { + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg left = asm_fuseload(as, ir->op1, RSET_FPR); + emit_mrm(as, XO_SQRTSD, dest, left); + } else if (fpm <= IRFPM_TRUNC) { + if (as->flags & JIT_F_SSE4_1) { /* SSE4.1 has a rounding instruction. */ + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg left = asm_fuseload(as, ir->op1, RSET_FPR); + /* ROUNDSD has a 4-byte opcode which doesn't fit in x86Op. + ** Let's pretend it's a 3-byte opcode, and compensate afterwards. + ** This is atrocious, but the alternatives are much worse. + */ + /* Round down/up/trunc == 1001/1010/1011. */ + emit_i8(as, 0x09 + fpm); + emit_mrm(as, XO_ROUNDSD, dest, left); + if (LJ_64 && as->mcp[1] != (MCode)(XO_ROUNDSD >> 16)) { + as->mcp[0] = as->mcp[1]; as->mcp[1] = 0x0f; /* Swap 0F and REX. */ + } + *--as->mcp = 0x66; /* 1st byte of ROUNDSD opcode. */ + } else { /* Call helper functions for SSE2 variant. */ + /* The modified regs must match with the *.dasc implementation. */ + RegSet drop = RSET_RANGE(RID_XMM0, RID_XMM3+1)|RID2RSET(RID_EAX); + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + ra_evictset(as, drop); + ra_destreg(as, ir, RID_XMM0); + emit_call(as, fpm == IRFPM_FLOOR ? lj_vm_floor_sse : + fpm == IRFPM_CEIL ? lj_vm_ceil_sse : lj_vm_trunc_sse); + ra_left(as, RID_XMM0, ir->op1); + } + } else if (fpm == IRFPM_EXP2 && fpmjoin_pow(as, ir)) { + /* Rejoined to pow(). */ + } else { /* Handle x87 ops. */ + int32_t ofs = sps_scale(ir->s); /* Use spill slot or temp slots. */ + Reg dest = ir->r; + if (ra_hasreg(dest)) { + ra_free(as, dest); + ra_modified(as, dest); + emit_rmro(as, XMM_MOVRM(as), dest, RID_ESP, ofs); + } + emit_rmro(as, XO_FSTPq, XOg_FSTPq, RID_ESP, ofs); + switch (fpm) { /* st0 = lj_vm_*(st0) */ + case IRFPM_EXP: emit_call(as, lj_vm_exp_x87); break; + case IRFPM_EXP2: emit_call(as, lj_vm_exp2_x87); break; + case IRFPM_SIN: emit_x87op(as, XI_FSIN); break; + case IRFPM_COS: emit_x87op(as, XI_FCOS); break; + case IRFPM_TAN: emit_x87op(as, XI_FPOP); emit_x87op(as, XI_FPTAN); break; + case IRFPM_LOG: case IRFPM_LOG2: case IRFPM_LOG10: + /* Note: the use of fyl2xp1 would be pointless here. When computing + ** log(1.0+eps) the precision is already lost after 1.0 is added. + ** Subtracting 1.0 won't recover it. OTOH math.log1p would make sense. + */ + emit_x87op(as, XI_FYL2X); break; + case IRFPM_OTHER: + switch (ir->o) { + case IR_ATAN2: + emit_x87op(as, XI_FPATAN); asm_x87load(as, ir->op2); break; + case IR_LDEXP: + emit_x87op(as, XI_FPOP1); emit_x87op(as, XI_FSCALE); break; + default: lua_assert(0); break; + } + break; + default: lua_assert(0); break; + } + asm_x87load(as, ir->op1); + switch (fpm) { + case IRFPM_LOG: emit_x87op(as, XI_FLDLN2); break; + case IRFPM_LOG2: emit_x87op(as, XI_FLD1); break; + case IRFPM_LOG10: emit_x87op(as, XI_FLDLG2); break; + case IRFPM_OTHER: + if (ir->o == IR_LDEXP) asm_x87load(as, ir->op2); + break; + default: break; + } + } +} + +static void asm_fppowi(ASMState *as, IRIns *ir) +{ + /* The modified regs must match with the *.dasc implementation. */ + RegSet drop = RSET_RANGE(RID_XMM0, RID_XMM1+1)|RID2RSET(RID_EAX); + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + ra_evictset(as, drop); + ra_destreg(as, ir, RID_XMM0); + emit_call(as, lj_vm_powi_sse); + ra_left(as, RID_XMM0, ir->op1); + ra_left(as, RID_EAX, ir->op2); +} + +#if LJ_64 && LJ_HASFFI +static void asm_arith64(ASMState *as, IRIns *ir, IRCallID id) +{ + const CCallInfo *ci = &lj_ir_callinfo[id]; + IRRef args[2]; + args[0] = ir->op1; + args[1] = ir->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} +#endif + +static void asm_intmod(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_vm_modi]; + IRRef args[2]; + args[0] = ir->op1; + args[1] = ir->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +static int asm_swapops(ASMState *as, IRIns *ir) +{ + IRIns *irl = IR(ir->op1); + IRIns *irr = IR(ir->op2); + lua_assert(ra_noreg(irr->r)); + if (!irm_iscomm(lj_ir_mode[ir->o])) + return 0; /* Can't swap non-commutative operations. */ + if (irref_isk(ir->op2)) + return 0; /* Don't swap constants to the left. */ + if (ra_hasreg(irl->r)) + return 1; /* Swap if left already has a register. */ + if (ra_samehint(ir->r, irr->r)) + return 1; /* Swap if dest and right have matching hints. */ + if (as->curins > as->loopref) { /* In variant part? */ + if (ir->op2 < as->loopref && !irt_isphi(irr->t)) + return 0; /* Keep invariants on the right. */ + if (ir->op1 < as->loopref && !irt_isphi(irl->t)) + return 1; /* Swap invariants to the right. */ + } + if (opisfusableload(irl->o)) + return 1; /* Swap fusable loads to the right. */ + return 0; /* Otherwise don't swap. */ +} + +static void asm_fparith(ASMState *as, IRIns *ir, x86Op xo) +{ + IRRef lref = ir->op1; + IRRef rref = ir->op2; + RegSet allow = RSET_FPR; + Reg dest; + Reg right = IR(rref)->r; + if (ra_hasreg(right)) { + rset_clear(allow, right); + ra_noweak(as, right); + } + dest = ra_dest(as, ir, allow); + if (lref == rref) { + right = dest; + } else if (ra_noreg(right)) { + if (asm_swapops(as, ir)) { + IRRef tmp = lref; lref = rref; rref = tmp; + } + right = asm_fuseload(as, rref, rset_clear(allow, dest)); + } + emit_mrm(as, xo, dest, right); + ra_left(as, dest, lref); +} + +static void asm_intarith(ASMState *as, IRIns *ir, x86Arith xa) +{ + IRRef lref = ir->op1; + IRRef rref = ir->op2; + RegSet allow = RSET_GPR; + Reg dest, right; + int32_t k = 0; + if (as->flagmcp == as->mcp) { /* Drop test r,r instruction. */ + MCode *p = as->mcp + ((LJ_64 && *as->mcp < XI_TESTb) ? 3 : 2); + if ((p[1] & 15) < 14) { + if ((p[1] & 15) >= 12) p[1] -= 4; /* L <->S, NL <-> NS */ + as->flagmcp = NULL; + as->mcp = p; + } /* else: cannot transform LE/NLE to cc without use of OF. */ + } + right = IR(rref)->r; + if (ra_hasreg(right)) { + rset_clear(allow, right); + ra_noweak(as, right); + } + dest = ra_dest(as, ir, allow); + if (lref == rref) { + right = dest; + } else if (ra_noreg(right) && !asm_isk32(as, rref, &k)) { + if (asm_swapops(as, ir)) { + IRRef tmp = lref; lref = rref; rref = tmp; + } + right = asm_fuseloadm(as, rref, rset_clear(allow, dest), irt_is64(ir->t)); + } + if (irt_isguard(ir->t)) /* For IR_ADDOV etc. */ + asm_guardcc(as, CC_O); + if (xa != XOg_X_IMUL) { + if (ra_hasreg(right)) + emit_mrm(as, XO_ARITH(xa), REX_64IR(ir, dest), right); + else + emit_gri(as, XG_ARITHi(xa), REX_64IR(ir, dest), k); + } else if (ra_hasreg(right)) { /* IMUL r, mrm. */ + emit_mrm(as, XO_IMUL, REX_64IR(ir, dest), right); + } else { /* IMUL r, r, k. */ + /* NYI: use lea/shl/add/sub (FOLD only does 2^k) depending on CPU. */ + Reg left = asm_fuseloadm(as, lref, RSET_GPR, irt_is64(ir->t)); + x86Op xo; + if (checki8(k)) { emit_i8(as, k); xo = XO_IMULi8; + } else { emit_i32(as, k); xo = XO_IMULi; } + emit_mrm(as, xo, REX_64IR(ir, dest), left); + return; + } + ra_left(as, dest, lref); +} + +/* LEA is really a 4-operand ADD with an independent destination register, +** up to two source registers and an immediate. One register can be scaled +** by 1, 2, 4 or 8. This can be used to avoid moves or to fuse several +** instructions. +** +** Currently only a few common cases are supported: +** - 3-operand ADD: y = a+b; y = a+k with a and b already allocated +** - Left ADD fusion: y = (a+b)+k; y = (a+k)+b +** - Right ADD fusion: y = a+(b+k) +** The ommited variants have already been reduced by FOLD. +** +** There are more fusion opportunities, like gathering shifts or joining +** common references. But these are probably not worth the trouble, since +** array indexing is not decomposed and already makes use of all fields +** of the ModRM operand. +*/ +static int asm_lea(ASMState *as, IRIns *ir) +{ + IRIns *irl = IR(ir->op1); + IRIns *irr = IR(ir->op2); + RegSet allow = RSET_GPR; + Reg dest; + as->mrm.base = as->mrm.idx = RID_NONE; + as->mrm.scale = XM_SCALE1; + as->mrm.ofs = 0; + if (ra_hasreg(irl->r)) { + rset_clear(allow, irl->r); + ra_noweak(as, irl->r); + as->mrm.base = irl->r; + if (irref_isk(ir->op2) || ra_hasreg(irr->r)) { + /* The PHI renaming logic does a better job in some cases. */ + if (ra_hasreg(ir->r) && + ((irt_isphi(irl->t) && as->phireg[ir->r] == ir->op1) || + (irt_isphi(irr->t) && as->phireg[ir->r] == ir->op2))) + return 0; + if (irref_isk(ir->op2)) { + as->mrm.ofs = irr->i; + } else { + rset_clear(allow, irr->r); + ra_noweak(as, irr->r); + as->mrm.idx = irr->r; + } + } else if (irr->o == IR_ADD && mayfuse(as, ir->op2) && + irref_isk(irr->op2)) { + Reg idx = ra_alloc1(as, irr->op1, allow); + rset_clear(allow, idx); + as->mrm.idx = (uint8_t)idx; + as->mrm.ofs = IR(irr->op2)->i; + } else { + return 0; + } + } else if (ir->op1 != ir->op2 && irl->o == IR_ADD && mayfuse(as, ir->op1) && + (irref_isk(ir->op2) || irref_isk(irl->op2))) { + Reg idx, base = ra_alloc1(as, irl->op1, allow); + rset_clear(allow, base); + as->mrm.base = (uint8_t)base; + if (irref_isk(ir->op2)) { + as->mrm.ofs = irr->i; + idx = ra_alloc1(as, irl->op2, allow); + } else { + as->mrm.ofs = IR(irl->op2)->i; + idx = ra_alloc1(as, ir->op2, allow); + } + rset_clear(allow, idx); + as->mrm.idx = (uint8_t)idx; + } else { + return 0; + } + dest = ra_dest(as, ir, allow); + emit_mrm(as, XO_LEA, dest, RID_MRM); + return 1; /* Success. */ +} + +static void asm_add(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) + asm_fparith(as, ir, XO_ADDSD); + else if ((as->flags & JIT_F_LEA_AGU) || as->flagmcp == as->mcp || + irt_is64(ir->t) || !asm_lea(as, ir)) + asm_intarith(as, ir, XOg_ADD); +} + +static void asm_neg_not(ASMState *as, IRIns *ir, x86Group3 xg) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + emit_rr(as, XO_GROUP3, REX_64IR(ir, xg), dest); + ra_left(as, dest, ir->op1); +} + +static void asm_min_max(ASMState *as, IRIns *ir, int cc) +{ + Reg right, dest = ra_dest(as, ir, RSET_GPR); + IRRef lref = ir->op1, rref = ir->op2; + if (irref_isk(rref)) { lref = rref; rref = ir->op1; } + right = ra_alloc1(as, rref, rset_exclude(RSET_GPR, dest)); + emit_rr(as, XO_CMOV + (cc<<24), REX_64IR(ir, dest), right); + emit_rr(as, XO_CMP, REX_64IR(ir, dest), right); + ra_left(as, dest, lref); +} + +static void asm_bitswap(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + as->mcp = emit_op(XO_BSWAP + ((dest&7) << 24), + REX_64IR(ir, 0), dest, 0, as->mcp, 1); + ra_left(as, dest, ir->op1); +} + +static void asm_bitshift(ASMState *as, IRIns *ir, x86Shift xs) +{ + IRRef rref = ir->op2; + IRIns *irr = IR(rref); + Reg dest; + if (irref_isk(rref)) { /* Constant shifts. */ + int shift; + dest = ra_dest(as, ir, RSET_GPR); + shift = irr->i & (irt_is64(ir->t) ? 63 : 31); + switch (shift) { + case 0: break; + case 1: emit_rr(as, XO_SHIFT1, REX_64IR(ir, xs), dest); break; + default: emit_shifti(as, REX_64IR(ir, xs), dest, shift); break; + } + } else { /* Variable shifts implicitly use register cl (i.e. ecx). */ + Reg right; + dest = ra_dest(as, ir, rset_exclude(RSET_GPR, RID_ECX)); + if (dest == RID_ECX) { + dest = ra_scratch(as, rset_exclude(RSET_GPR, RID_ECX)); + emit_rr(as, XO_MOV, RID_ECX, dest); + } + right = irr->r; + if (ra_noreg(right)) + right = ra_allocref(as, rref, RID2RSET(RID_ECX)); + else if (right != RID_ECX) + ra_scratch(as, RID2RSET(RID_ECX)); + emit_rr(as, XO_SHIFTcl, REX_64IR(ir, xs), dest); + ra_noweak(as, right); + if (right != RID_ECX) + emit_rr(as, XO_MOV, RID_ECX, right); + } + ra_left(as, dest, ir->op1); + /* + ** Note: avoid using the flags resulting from a shift or rotate! + ** All of them cause a partial flag stall, except for r,1 shifts + ** (but not rotates). And a shift count of 0 leaves the flags unmodified. + */ +} + +/* -- Comparisons --------------------------------------------------------- */ + +/* Virtual flags for unordered FP comparisons. */ +#define VCC_U 0x1000 /* Unordered. */ +#define VCC_P 0x2000 /* Needs extra CC_P branch. */ +#define VCC_S 0x4000 /* Swap avoids CC_P branch. */ +#define VCC_PS (VCC_P|VCC_S) + +/* Map of comparisons to flags. ORDER IR. */ +#define COMPFLAGS(ci, cin, cu, cf) ((ci)+((cu)<<4)+((cin)<<8)+(cf)) +static const uint16_t asm_compmap[IR_ABC+1] = { + /* signed non-eq unsigned flags */ + /* LT */ COMPFLAGS(CC_GE, CC_G, CC_AE, VCC_PS), + /* GE */ COMPFLAGS(CC_L, CC_L, CC_B, 0), + /* LE */ COMPFLAGS(CC_G, CC_G, CC_A, VCC_PS), + /* GT */ COMPFLAGS(CC_LE, CC_L, CC_BE, 0), + /* ULT */ COMPFLAGS(CC_AE, CC_A, CC_AE, VCC_U), + /* UGE */ COMPFLAGS(CC_B, CC_B, CC_B, VCC_U|VCC_PS), + /* ULE */ COMPFLAGS(CC_A, CC_A, CC_A, VCC_U), + /* UGT */ COMPFLAGS(CC_BE, CC_B, CC_BE, VCC_U|VCC_PS), + /* EQ */ COMPFLAGS(CC_NE, CC_NE, CC_NE, VCC_P), + /* NE */ COMPFLAGS(CC_E, CC_E, CC_E, VCC_U|VCC_P), + /* ABC */ COMPFLAGS(CC_BE, CC_B, CC_BE, VCC_U|VCC_PS) /* Same as UGT. */ +}; + +/* FP and integer comparisons. */ +static void asm_comp(ASMState *as, IRIns *ir, uint32_t cc) +{ + if (irt_isnum(ir->t)) { + IRRef lref = ir->op1; + IRRef rref = ir->op2; + Reg left, right; + MCLabel l_around; + /* + ** An extra CC_P branch is required to preserve ordered/unordered + ** semantics for FP comparisons. This can be avoided by swapping + ** the operands and inverting the condition (except for EQ and UNE). + ** So always try to swap if possible. + ** + ** Another option would be to swap operands to achieve better memory + ** operand fusion. But it's unlikely that this outweighs the cost + ** of the extra branches. + */ + if (cc & VCC_S) { /* Swap? */ + IRRef tmp = lref; lref = rref; rref = tmp; + cc ^= (VCC_PS|(5<<4)); /* A <-> B, AE <-> BE, PS <-> none */ + } + left = ra_alloc1(as, lref, RSET_FPR); + right = asm_fuseload(as, rref, rset_exclude(RSET_FPR, left)); + l_around = emit_label(as); + asm_guardcc(as, cc >> 4); + if (cc & VCC_P) { /* Extra CC_P branch required? */ + if (!(cc & VCC_U)) { + asm_guardcc(as, CC_P); /* Branch to exit for ordered comparisons. */ + } else if (l_around != as->invmcp) { + emit_sjcc(as, CC_P, l_around); /* Branch around for unordered. */ + } else { + /* Patched to mcloop by asm_loop_fixup. */ + as->loopinv = 2; + if (as->realign) + emit_sjcc(as, CC_P, as->mcp); + else + emit_jcc(as, CC_P, as->mcp); + } + } + emit_mrm(as, XO_UCOMISD, left, right); + } else { + IRRef lref = ir->op1, rref = ir->op2; + IROp leftop = (IROp)(IR(lref)->o); + Reg r64 = REX_64IR(ir, 0); + int32_t imm = 0; + lua_assert(irt_is64(ir->t) || irt_isint(ir->t) || + irt_isu32(ir->t) || irt_isaddr(ir->t) || irt_isu8(ir->t)); + /* Swap constants (only for ABC) and fusable loads to the right. */ + if (irref_isk(lref) || (!irref_isk(rref) && opisfusableload(leftop))) { + if ((cc & 0xc) == 0xc) cc ^= 0x53; /* L <-> G, LE <-> GE */ + else if ((cc & 0xa) == 0x2) cc ^= 0x55; /* A <-> B, AE <-> BE */ + lref = ir->op2; rref = ir->op1; + } + if (asm_isk32(as, rref, &imm)) { + IRIns *irl = IR(lref); + /* Check wether we can use test ins. Not for unsigned, since CF=0. */ + int usetest = (imm == 0 && (cc & 0xa) != 0x2); + if (usetest && irl->o == IR_BAND && irl+1 == ir && !ra_used(irl)) { + /* Combine comp(BAND(ref, r/imm), 0) into test mrm, r/imm. */ + Reg right, left = RID_NONE; + RegSet allow = RSET_GPR; + if (!asm_isk32(as, irl->op2, &imm)) { + left = ra_alloc1(as, irl->op2, allow); + rset_clear(allow, left); + } else { /* Try to Fuse IRT_I8/IRT_U8 loads, too. See below. */ + IRIns *irll = IR(irl->op1); + if (opisfusableload((IROp)irll->o) && + (irt_isi8(irll->t) || irt_isu8(irll->t))) { + IRType1 origt = irll->t; /* Temporarily flip types. */ + irll->t.irt = (irll->t.irt & ~IRT_TYPE) | IRT_INT; + as->curins--; /* Skip to BAND to avoid failing in noconflict(). */ + right = asm_fuseload(as, irl->op1, RSET_GPR); + as->curins++; + irll->t = origt; + if (right != RID_MRM) goto test_nofuse; + /* Fusion succeeded, emit test byte mrm, imm8. */ + asm_guardcc(as, cc); + emit_i8(as, (imm & 0xff)); + emit_mrm(as, XO_GROUP3b, XOg_TEST, RID_MRM); + return; + } + } + as->curins--; /* Skip to BAND to avoid failing in noconflict(). */ + right = asm_fuseloadm(as, irl->op1, allow, r64); + as->curins++; /* Undo the above. */ + test_nofuse: + asm_guardcc(as, cc); + if (ra_noreg(left)) { + emit_i32(as, imm); + emit_mrm(as, XO_GROUP3, r64 + XOg_TEST, right); + } else { + emit_mrm(as, XO_TEST, r64 + left, right); + } + } else { + Reg left; + if (opisfusableload((IROp)irl->o) && + ((irt_isu8(irl->t) && checku8(imm)) || + ((irt_isi8(irl->t) || irt_isi16(irl->t)) && checki8(imm)) || + (irt_isu16(irl->t) && checku16(imm) && checki8((int16_t)imm)))) { + /* Only the IRT_INT case is fused by asm_fuseload. + ** The IRT_I8/IRT_U8 loads and some IRT_I16/IRT_U16 loads + ** are handled here. + ** Note that cmp word [mem], imm16 should not be generated, + ** since it has a length-changing prefix. Compares of a word + ** against a sign-extended imm8 are ok, however. + */ + IRType1 origt = irl->t; /* Temporarily flip types. */ + irl->t.irt = (irl->t.irt & ~IRT_TYPE) | IRT_INT; + left = asm_fuseload(as, lref, RSET_GPR); + irl->t = origt; + if (left == RID_MRM) { /* Fusion succeeded? */ + if (irt_isu8(irl->t) || irt_isu16(irl->t)) + cc >>= 4; /* Need unsigned compare. */ + asm_guardcc(as, cc); + emit_i8(as, imm); + emit_mrm(as, (irt_isi8(origt) || irt_isu8(origt)) ? + XO_ARITHib : XO_ARITHiw8, r64 + XOg_CMP, RID_MRM); + return; + } /* Otherwise handle register case as usual. */ + } else { + left = asm_fuseloadm(as, lref, + irt_isu8(ir->t) ? RSET_GPR8 : RSET_GPR, r64); + } + asm_guardcc(as, cc); + if (usetest && left != RID_MRM) { + /* Use test r,r instead of cmp r,0. */ + x86Op xo = XO_TEST; + if (irt_isu8(ir->t)) { + lua_assert(ir->o == IR_EQ || ir->o == IR_NE); + xo = XO_TESTb; + if (!rset_test(RSET_RANGE(RID_EAX, RID_EBX+1), left)) { + if (LJ_64) { + left |= FORCE_REX; + } else { + emit_i32(as, 0xff); + emit_mrm(as, XO_GROUP3, XOg_TEST, left); + return; + } + } + } + emit_rr(as, xo, r64 + left, left); + if (irl+1 == ir) /* Referencing previous ins? */ + as->flagmcp = as->mcp; /* Set flag to drop test r,r if possible. */ + } else { + emit_gmrmi(as, XG_ARITHi(XOg_CMP), r64 + left, imm); + } + } + } else { + Reg left = ra_alloc1(as, lref, RSET_GPR); + Reg right = asm_fuseloadm(as, rref, rset_exclude(RSET_GPR, left), r64); + asm_guardcc(as, cc); + emit_mrm(as, XO_CMP, r64 + left, right); + } + } +} + +#if LJ_32 && LJ_HASFFI +/* 64 bit integer comparisons in 32 bit mode. */ +static void asm_comp_int64(ASMState *as, IRIns *ir) +{ + uint32_t cc = asm_compmap[(ir-1)->o]; + RegSet allow = RSET_GPR; + Reg lefthi = RID_NONE, leftlo = RID_NONE; + Reg righthi = RID_NONE, rightlo = RID_NONE; + MCLabel l_around; + x86ModRM mrm; + + as->curins--; /* Skip loword ins. Avoids failing in noconflict(), too. */ + + /* Allocate/fuse hiword operands. */ + if (irref_isk(ir->op2)) { + lefthi = asm_fuseload(as, ir->op1, allow); + } else { + lefthi = ra_alloc1(as, ir->op1, allow); + rset_clear(allow, lefthi); + righthi = asm_fuseload(as, ir->op2, allow); + if (righthi == RID_MRM) { + if (as->mrm.base != RID_NONE) rset_clear(allow, as->mrm.base); + if (as->mrm.idx != RID_NONE) rset_clear(allow, as->mrm.idx); + } else { + rset_clear(allow, righthi); + } + } + mrm = as->mrm; /* Save state for hiword instruction. */ + + /* Allocate/fuse loword operands. */ + if (irref_isk((ir-1)->op2)) { + leftlo = asm_fuseload(as, (ir-1)->op1, allow); + } else { + leftlo = ra_alloc1(as, (ir-1)->op1, allow); + rset_clear(allow, leftlo); + rightlo = asm_fuseload(as, (ir-1)->op2, allow); + } + + /* All register allocations must be performed _before_ this point. */ + l_around = emit_label(as); + as->invmcp = as->flagmcp = NULL; /* Cannot use these optimizations. */ + + /* Loword comparison and branch. */ + asm_guardcc(as, cc >> 4); /* Always use unsigned compare for loword. */ + if (ra_noreg(rightlo)) { + int32_t imm = IR((ir-1)->op2)->i; + if (imm == 0 && ((cc >> 4) & 0xa) != 0x2 && leftlo != RID_MRM) + emit_rr(as, XO_TEST, leftlo, leftlo); + else + emit_gmrmi(as, XG_ARITHi(XOg_CMP), leftlo, imm); + } else { + emit_mrm(as, XO_CMP, leftlo, rightlo); + } + + /* Hiword comparison and branches. */ + if ((cc & 15) != CC_NE) + emit_sjcc(as, CC_NE, l_around); /* Hiword unequal: skip loword compare. */ + if ((cc & 15) != CC_E) + asm_guardcc(as, cc >> 8); /* Hiword compare without equality check. */ + as->mrm = mrm; /* Restore state. */ + if (ra_noreg(righthi)) { + int32_t imm = IR(ir->op2)->i; + if (imm == 0 && (cc & 0xa) != 0x2 && lefthi != RID_MRM) + emit_rr(as, XO_TEST, lefthi, lefthi); + else + emit_gmrmi(as, XG_ARITHi(XOg_CMP), lefthi, imm); + } else { + emit_mrm(as, XO_CMP, lefthi, righthi); + } +} +#endif + +/* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ + +/* Hiword op of a split 64 bit op. Previous op must be the loword op. */ +static void asm_hiop(ASMState *as, IRIns *ir) +{ +#if LJ_32 && LJ_HASFFI + /* HIOP is marked as a store because it needs its own DCE logic. */ + int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ + if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; + if ((ir-1)->o == IR_CONV) { /* Conversions to/from 64 bit. */ + if (usehi || uselo) { + if (irt_isfp(ir->t)) + asm_conv_fp_int64(as, ir); + else + asm_conv_int64_fp(as, ir); + } + as->curins--; /* Always skip the CONV. */ + return; + } else if ((ir-1)->o <= IR_NE) { /* 64 bit integer comparisons. ORDER IR. */ + asm_comp_int64(as, ir); + return; + } else if ((ir-1)->o == IR_XSTORE) { + if ((ir-1)->r != RID_SINK) + asm_fxstore(as, ir); + return; + } + if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ + switch ((ir-1)->o) { + case IR_ADD: + as->flagmcp = NULL; + as->curins--; + asm_intarith(as, ir, XOg_ADC); + asm_intarith(as, ir-1, XOg_ADD); + break; + case IR_SUB: + as->flagmcp = NULL; + as->curins--; + asm_intarith(as, ir, XOg_SBB); + asm_intarith(as, ir-1, XOg_SUB); + break; + case IR_NEG: { + Reg dest = ra_dest(as, ir, RSET_GPR); + emit_rr(as, XO_GROUP3, XOg_NEG, dest); + emit_i8(as, 0); + emit_rr(as, XO_ARITHi8, XOg_ADC, dest); + ra_left(as, dest, ir->op1); + as->curins--; + asm_neg_not(as, ir-1, XOg_NEG); + break; + } + case IR_CALLN: + case IR_CALLXS: + if (!uselo) + ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ + break; + case IR_CNEWI: + /* Nothing to do here. Handled by CNEWI itself. */ + break; + default: lua_assert(0); break; + } +#else + UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused on x64 or without FFI. */ +#endif +} + +/* -- Stack handling ------------------------------------------------------ */ + +/* Check Lua stack size for overflow. Use exit handler as fallback. */ +static void asm_stack_check(ASMState *as, BCReg topslot, + IRIns *irp, RegSet allow, ExitNo exitno) +{ + /* Try to get an unused temp. register, otherwise spill/restore eax. */ + Reg pbase = irp ? irp->r : RID_BASE; + Reg r = allow ? rset_pickbot(allow) : RID_EAX; + emit_jcc(as, CC_B, exitstub_addr(as->J, exitno)); + if (allow == RSET_EMPTY) /* Restore temp. register. */ + emit_rmro(as, XO_MOV, r|REX_64, RID_ESP, 0); + else + ra_modified(as, r); + emit_gri(as, XG_ARITHi(XOg_CMP), r, (int32_t)(8*topslot)); + if (ra_hasreg(pbase) && pbase != r) + emit_rr(as, XO_ARITH(XOg_SUB), r, pbase); + else + emit_rmro(as, XO_ARITH(XOg_SUB), r, RID_NONE, + ptr2addr(&J2G(as->J)->jit_base)); + emit_rmro(as, XO_MOV, r, r, offsetof(lua_State, maxstack)); + emit_getgl(as, r, jit_L); + if (allow == RSET_EMPTY) /* Spill temp. register. */ + emit_rmro(as, XO_MOVto, r|REX_64, RID_ESP, 0); +} + +/* Restore Lua stack from on-trace state. */ +static void asm_stack_restore(ASMState *as, SnapShot *snap) +{ + SnapEntry *map = &as->T->snapmap[snap->mapofs]; + SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; + MSize n, nent = snap->nent; + /* Store the value of all modified slots to the Lua stack. */ + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + BCReg s = snap_slot(sn); + int32_t ofs = 8*((int32_t)s-1); + IRRef ref = snap_ref(sn); + IRIns *ir = IR(ref); + if ((sn & SNAP_NORESTORE)) + continue; + if (irt_isnum(ir->t)) { + Reg src = ra_alloc1(as, ref, RSET_FPR); + emit_rmro(as, XO_MOVSDto, src, RID_BASE, ofs); + } else { + lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || + (LJ_DUALNUM && irt_isinteger(ir->t))); + if (!irref_isk(ref)) { + Reg src = ra_alloc1(as, ref, rset_exclude(RSET_GPR, RID_BASE)); + emit_movtomro(as, REX_64IR(ir, src), RID_BASE, ofs); + } else if (!irt_ispri(ir->t)) { + emit_movmroi(as, RID_BASE, ofs, ir->i); + } + if ((sn & (SNAP_CONT|SNAP_FRAME))) { + if (s != 0) /* Do not overwrite link to previous frame. */ + emit_movmroi(as, RID_BASE, ofs+4, (int32_t)(*flinks--)); + } else { + if (!(LJ_64 && irt_islightud(ir->t))) + emit_movmroi(as, RID_BASE, ofs+4, irt_toitype(ir->t)); + } + } + checkmclim(as); + } + lua_assert(map + nent == flinks); +} + +/* -- GC handling --------------------------------------------------------- */ + +/* Check GC threshold and do one or more GC steps. */ +static void asm_gc_check(ASMState *as) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; + IRRef args[2]; + MCLabel l_end; + Reg tmp; + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ + asm_guardcc(as, CC_NE); /* Assumes asm_snap_prep() already done. */ + emit_rr(as, XO_TEST, RID_RET, RID_RET); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ASMREF_TMP2; /* MSize steps */ + asm_gencall(as, ci, args); + tmp = ra_releasetmp(as, ASMREF_TMP1); + emit_loada(as, tmp, J2G(as->J)); + emit_loadi(as, ra_releasetmp(as, ASMREF_TMP2), as->gcsteps); + /* Jump around GC step if GC total < GC threshold. */ + emit_sjcc(as, CC_B, l_end); + emit_opgl(as, XO_ARITH(XOg_CMP), tmp, gc.threshold); + emit_getgl(as, tmp, gc.total); + as->gcsteps = 0; + checkmclim(as); +} + +/* -- Loop handling ------------------------------------------------------- */ + +/* Fixup the loop branch. */ +static void asm_loop_fixup(ASMState *as) +{ + MCode *p = as->mctop; + MCode *target = as->mcp; + if (as->realign) { /* Realigned loops use short jumps. */ + as->realign = NULL; /* Stop another retry. */ + lua_assert(((intptr_t)target & 15) == 0); + if (as->loopinv) { /* Inverted loop branch? */ + p -= 5; + p[0] = XI_JMP; + lua_assert(target - p >= -128); + p[-1] = (MCode)(target - p); /* Patch sjcc. */ + if (as->loopinv == 2) + p[-3] = (MCode)(target - p + 2); /* Patch opt. short jp. */ + } else { + lua_assert(target - p >= -128); + p[-1] = (MCode)(int8_t)(target - p); /* Patch short jmp. */ + p[-2] = XI_JMPs; + } + } else { + MCode *newloop; + p[-5] = XI_JMP; + if (as->loopinv) { /* Inverted loop branch? */ + /* asm_guardcc already inverted the jcc and patched the jmp. */ + p -= 5; + newloop = target+4; + *(int32_t *)(p-4) = (int32_t)(target - p); /* Patch jcc. */ + if (as->loopinv == 2) { + *(int32_t *)(p-10) = (int32_t)(target - p + 6); /* Patch opt. jp. */ + newloop = target+8; + } + } else { /* Otherwise just patch jmp. */ + *(int32_t *)(p-4) = (int32_t)(target - p); + newloop = target+3; + } + /* Realign small loops and shorten the loop branch. */ + if (newloop >= p - 128) { + as->realign = newloop; /* Force a retry and remember alignment. */ + as->curins = as->stopins; /* Abort asm_trace now. */ + as->T->nins = as->orignins; /* Remove any added renames. */ + } + } +} + +/* -- Head of trace ------------------------------------------------------- */ + +/* Coalesce BASE register for a root trace. */ +static void asm_head_root_base(ASMState *as) +{ + IRIns *ir = IR(REF_BASE); + Reg r = ir->r; + if (ra_hasreg(r)) { + ra_free(as, r); + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) + ir->r = RID_INIT; /* No inheritance for modified BASE register. */ + if (r != RID_BASE) + emit_rr(as, XO_MOV, r, RID_BASE); + } +} + +/* Coalesce or reload BASE register for a side trace. */ +static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) +{ + IRIns *ir = IR(REF_BASE); + Reg r = ir->r; + if (ra_hasreg(r)) { + ra_free(as, r); + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) + ir->r = RID_INIT; /* No inheritance for modified BASE register. */ + if (irp->r == r) { + rset_clear(allow, r); /* Mark same BASE register as coalesced. */ + } else if (ra_hasreg(irp->r) && rset_test(as->freeset, irp->r)) { + rset_clear(allow, irp->r); + emit_rr(as, XO_MOV, r, irp->r); /* Move from coalesced parent reg. */ + } else { + emit_getgl(as, r, jit_base); /* Otherwise reload BASE. */ + } + } + return allow; +} + +/* -- Tail of trace ------------------------------------------------------- */ + +/* Fixup the tail code. */ +static void asm_tail_fixup(ASMState *as, TraceNo lnk) +{ + /* Note: don't use as->mcp swap + emit_*: emit_op overwrites more bytes. */ + MCode *p = as->mctop; + MCode *target, *q; + int32_t spadj = as->T->spadjust; + if (spadj == 0) { + p -= ((as->flags & JIT_F_LEA_AGU) ? 7 : 6) + (LJ_64 ? 1 : 0); + } else { + MCode *p1; + /* Patch stack adjustment. */ + if (checki8(spadj)) { + p -= 3; + p1 = p-6; + *p1 = (MCode)spadj; + } else { + p1 = p-9; + *(int32_t *)p1 = spadj; + } + if ((as->flags & JIT_F_LEA_AGU)) { +#if LJ_64 + p1[-4] = 0x48; +#endif + p1[-3] = (MCode)XI_LEA; + p1[-2] = MODRM(checki8(spadj) ? XM_OFS8 : XM_OFS32, RID_ESP, RID_ESP); + p1[-1] = MODRM(XM_SCALE1, RID_ESP, RID_ESP); + } else { +#if LJ_64 + p1[-3] = 0x48; +#endif + p1[-2] = (MCode)(checki8(spadj) ? XI_ARITHi8 : XI_ARITHi); + p1[-1] = MODRM(XM_REG, XOg_ADD, RID_ESP); + } + } + /* Patch exit branch. */ + target = lnk ? traceref(as->J, lnk)->mcode : (MCode *)lj_vm_exit_interp; + *(int32_t *)(p-4) = jmprel(p, target); + p[-5] = XI_JMP; + /* Drop unused mcode tail. Fill with NOPs to make the prefetcher happy. */ + for (q = as->mctop-1; q >= p; q--) + *q = XI_NOP; + as->mctop = p; +} + +/* Prepare tail of code. */ +static void asm_tail_prep(ASMState *as) +{ + MCode *p = as->mctop; + /* Realign and leave room for backwards loop branch or exit branch. */ + if (as->realign) { + int i = ((int)(intptr_t)as->realign) & 15; + /* Fill unused mcode tail with NOPs to make the prefetcher happy. */ + while (i-- > 0) + *--p = XI_NOP; + as->mctop = p; + p -= (as->loopinv ? 5 : 2); /* Space for short/near jmp. */ + } else { + p -= 5; /* Space for exit branch (near jmp). */ + } + if (as->loopref) { + as->invmcp = as->mcp = p; + } else { + /* Leave room for ESP adjustment: add esp, imm or lea esp, [esp+imm] */ + as->mcp = p - (((as->flags & JIT_F_LEA_AGU) ? 7 : 6) + (LJ_64 ? 1 : 0)); + as->invmcp = NULL; + } +} + +/* -- Instruction dispatch ------------------------------------------------ */ + +/* Assemble a single instruction. */ +static void asm_ir(ASMState *as, IRIns *ir) +{ + switch ((IROp)ir->o) { + /* Miscellaneous ops. */ + case IR_LOOP: asm_loop(as); break; + case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; + case IR_USE: + ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; + case IR_PHI: asm_phi(as, ir); break; + case IR_HIOP: asm_hiop(as, ir); break; + case IR_GCSTEP: asm_gcstep(as, ir); break; + + /* Guarded assertions. */ + case IR_LT: case IR_GE: case IR_LE: case IR_GT: + case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: + case IR_EQ: case IR_NE: case IR_ABC: + asm_comp(as, ir, asm_compmap[ir->o]); + break; + + case IR_RETF: asm_retf(as, ir); break; + + /* Bit ops. */ + case IR_BNOT: asm_neg_not(as, ir, XOg_NOT); break; + case IR_BSWAP: asm_bitswap(as, ir); break; + + case IR_BAND: asm_intarith(as, ir, XOg_AND); break; + case IR_BOR: asm_intarith(as, ir, XOg_OR); break; + case IR_BXOR: asm_intarith(as, ir, XOg_XOR); break; + + case IR_BSHL: asm_bitshift(as, ir, XOg_SHL); break; + case IR_BSHR: asm_bitshift(as, ir, XOg_SHR); break; + case IR_BSAR: asm_bitshift(as, ir, XOg_SAR); break; + case IR_BROL: asm_bitshift(as, ir, XOg_ROL); break; + case IR_BROR: asm_bitshift(as, ir, XOg_ROR); break; + + /* Arithmetic ops. */ + case IR_ADD: asm_add(as, ir); break; + case IR_SUB: + if (irt_isnum(ir->t)) + asm_fparith(as, ir, XO_SUBSD); + else /* Note: no need for LEA trick here. i-k is encoded as i+(-k). */ + asm_intarith(as, ir, XOg_SUB); + break; + case IR_MUL: + if (irt_isnum(ir->t)) + asm_fparith(as, ir, XO_MULSD); + else + asm_intarith(as, ir, XOg_X_IMUL); + break; + case IR_DIV: +#if LJ_64 && LJ_HASFFI + if (!irt_isnum(ir->t)) + asm_arith64(as, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_divi64 : + IRCALL_lj_carith_divu64); + else +#endif + asm_fparith(as, ir, XO_DIVSD); + break; + case IR_MOD: +#if LJ_64 && LJ_HASFFI + if (!irt_isint(ir->t)) + asm_arith64(as, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_modi64 : + IRCALL_lj_carith_modu64); + else +#endif + asm_intmod(as, ir); + break; + + case IR_NEG: + if (irt_isnum(ir->t)) + asm_fparith(as, ir, XO_XORPS); + else + asm_neg_not(as, ir, XOg_NEG); + break; + case IR_ABS: asm_fparith(as, ir, XO_ANDPS); break; + + case IR_MIN: + if (irt_isnum(ir->t)) + asm_fparith(as, ir, XO_MINSD); + else + asm_min_max(as, ir, CC_G); + break; + case IR_MAX: + if (irt_isnum(ir->t)) + asm_fparith(as, ir, XO_MAXSD); + else + asm_min_max(as, ir, CC_L); + break; + + case IR_FPMATH: case IR_ATAN2: case IR_LDEXP: + asm_fpmath(as, ir); + break; + case IR_POW: +#if LJ_64 && LJ_HASFFI + if (!irt_isnum(ir->t)) + asm_arith64(as, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_powi64 : + IRCALL_lj_carith_powu64); + else +#endif + asm_fppowi(as, ir); + break; + + /* Overflow-checking arithmetic ops. Note: don't use LEA here! */ + case IR_ADDOV: asm_intarith(as, ir, XOg_ADD); break; + case IR_SUBOV: asm_intarith(as, ir, XOg_SUB); break; + case IR_MULOV: asm_intarith(as, ir, XOg_X_IMUL); break; + + /* Memory references. */ + case IR_AREF: asm_aref(as, ir); break; + case IR_HREF: asm_href(as, ir); break; + case IR_HREFK: asm_hrefk(as, ir); break; + case IR_NEWREF: asm_newref(as, ir); break; + case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; + case IR_FREF: asm_fref(as, ir); break; + case IR_STRREF: asm_strref(as, ir); break; + + /* Loads and stores. */ + case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + asm_ahuvload(as, ir); + break; + case IR_FLOAD: case IR_XLOAD: asm_fxload(as, ir); break; + case IR_SLOAD: asm_sload(as, ir); break; + + case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; + case IR_FSTORE: case IR_XSTORE: asm_fxstore(as, ir); break; + + /* Allocations. */ + case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; + case IR_TNEW: asm_tnew(as, ir); break; + case IR_TDUP: asm_tdup(as, ir); break; + case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; + + /* Write barriers. */ + case IR_TBAR: asm_tbar(as, ir); break; + case IR_OBAR: asm_obar(as, ir); break; + + /* Type conversions. */ + case IR_TOBIT: asm_tobit(as, ir); break; + case IR_CONV: asm_conv(as, ir); break; + case IR_TOSTR: asm_tostr(as, ir); break; + case IR_STRTO: asm_strto(as, ir); break; + + /* Calls. */ + case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; + case IR_CALLXS: asm_callx(as, ir); break; + case IR_CARG: break; + + default: + setintV(&as->J->errinfo, ir->o); + lj_trace_err_info(as->J, LJ_TRERR_NYIIR); + break; + } +} + +/* -- Trace setup --------------------------------------------------------- */ + +/* Ensure there are enough stack slots for call arguments. */ +static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + IRRef args[CCI_NARGS_MAX*2]; + int nslots; + asm_collectargs(as, ir, ci, args); + nslots = asm_count_call_slots(as, ci, args); + if (nslots > as->evenspill) /* Leave room for args in stack slots. */ + as->evenspill = nslots; +#if LJ_64 + return irt_isfp(ir->t) ? REGSP_HINT(RID_FPRET) : REGSP_HINT(RID_RET); +#else + return irt_isfp(ir->t) ? REGSP_INIT : REGSP_HINT(RID_RET); +#endif +} + +/* Target-specific setup. */ +static void asm_setup_target(ASMState *as) +{ + asm_exitstub_setup(as, as->T->nsnap); +} + +/* -- Trace patching ------------------------------------------------------ */ + +static const uint8_t map_op1[256] = { +0x92,0x92,0x92,0x92,0x52,0x45,0x51,0x51,0x92,0x92,0x92,0x92,0x52,0x45,0x51,0x20, +0x92,0x92,0x92,0x92,0x52,0x45,0x51,0x51,0x92,0x92,0x92,0x92,0x52,0x45,0x51,0x51, +0x92,0x92,0x92,0x92,0x52,0x45,0x10,0x51,0x92,0x92,0x92,0x92,0x52,0x45,0x10,0x51, +0x92,0x92,0x92,0x92,0x52,0x45,0x10,0x51,0x92,0x92,0x92,0x92,0x52,0x45,0x10,0x51, +#if LJ_64 +0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14, +#else +0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51, +#endif +0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51, +0x51,0x51,0x92,0x92,0x10,0x10,0x12,0x11,0x45,0x86,0x52,0x93,0x51,0x51,0x51,0x51, +0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52, +0x93,0x86,0x93,0x93,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92, +0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x47,0x51,0x51,0x51,0x51,0x51, +#if LJ_64 +0x59,0x59,0x59,0x59,0x51,0x51,0x51,0x51,0x52,0x45,0x51,0x51,0x51,0x51,0x51,0x51, +#else +0x55,0x55,0x55,0x55,0x51,0x51,0x51,0x51,0x52,0x45,0x51,0x51,0x51,0x51,0x51,0x51, +#endif +0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05, +0x93,0x93,0x53,0x51,0x70,0x71,0x93,0x86,0x54,0x51,0x53,0x51,0x51,0x52,0x51,0x51, +0x92,0x92,0x92,0x92,0x52,0x52,0x51,0x51,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92, +0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x45,0x45,0x47,0x52,0x51,0x51,0x51,0x51, +0x10,0x51,0x10,0x10,0x51,0x51,0x63,0x66,0x51,0x51,0x51,0x51,0x51,0x51,0x92,0x92 +}; + +static const uint8_t map_op2[256] = { +0x93,0x93,0x93,0x93,0x52,0x52,0x52,0x52,0x52,0x52,0x51,0x52,0x51,0x93,0x52,0x94, +0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93, +0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93, +0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x34,0x51,0x35,0x51,0x51,0x51,0x51,0x51, +0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93, +0x53,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93, +0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93, +0x94,0x54,0x54,0x54,0x93,0x93,0x93,0x52,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93, +0x46,0x46,0x46,0x46,0x46,0x46,0x46,0x46,0x46,0x46,0x46,0x46,0x46,0x46,0x46,0x46, +0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93, +0x52,0x52,0x52,0x93,0x94,0x93,0x51,0x51,0x52,0x52,0x52,0x93,0x94,0x93,0x93,0x93, +0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x94,0x93,0x93,0x93,0x93,0x93, +0x93,0x93,0x94,0x93,0x94,0x94,0x94,0x93,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52, +0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93, +0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93, +0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x52 +}; + +static uint32_t asm_x86_inslen(const uint8_t* p) +{ + uint32_t result = 0; + uint32_t prefixes = 0; + uint32_t x = map_op1[*p]; + for (;;) { + switch (x >> 4) { + case 0: return result + x + (prefixes & 4); + case 1: prefixes |= x; x = map_op1[*++p]; result++; break; + case 2: x = map_op2[*++p]; break; + case 3: p++; goto mrm; + case 4: result -= (prefixes & 2); /* fallthrough */ + case 5: return result + (x & 15); + case 6: /* Group 3. */ + if (p[1] & 0x38) x = 2; + else if ((prefixes & 2) && (x == 0x66)) x = 4; + goto mrm; + case 7: /* VEX c4/c5. */ + if (LJ_32 && p[1] < 0xc0) { + x = 2; + goto mrm; + } + if (x == 0x70) { + x = *++p & 0x1f; + result++; + if (x >= 2) { + p += 2; + result += 2; + goto mrm; + } + } + p++; + result++; + x = map_op2[*++p]; + break; + case 8: result -= (prefixes & 2); /* fallthrough */ + case 9: mrm: /* ModR/M and possibly SIB. */ + result += (x & 15); + x = *++p; + switch (x >> 6) { + case 0: if ((x & 7) == 5) return result + 4; break; + case 1: result++; break; + case 2: result += 4; break; + case 3: return result; + } + if ((x & 7) == 4) { + result++; + if (x < 0x40 && (p[1] & 7) == 5) result += 4; + } + return result; + } + } +} + +/* Patch exit jumps of existing machine code to a new target. */ +void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) +{ + MCode *p = T->mcode; + MCode *mcarea = lj_mcode_patch(J, p, 0); + MSize len = T->szmcode; + MCode *px = exitstub_addr(J, exitno) - 6; + MCode *pe = p+len-6; + uint32_t stateaddr = u32ptr(&J2G(J)->vmstate); + if (len > 5 && p[len-5] == XI_JMP && p+len-6 + *(int32_t *)(p+len-4) == px) + *(int32_t *)(p+len-4) = jmprel(p+len, target); + /* Do not patch parent exit for a stack check. Skip beyond vmstate update. */ + for (; p < pe; p += asm_x86_inslen(p)) + if (*(uint32_t *)(p+(LJ_64 ? 3 : 2)) == stateaddr && p[0] == XI_MOVmi) + break; + lua_assert(p < pe); + for (; p < pe; p += asm_x86_inslen(p)) + if ((*(uint16_t *)p & 0xf0ff) == 0x800f && p + *(int32_t *)(p+2) == px) + *(int32_t *)(p+2) = jmprel(p+6, target); + lj_mcode_sync(T->mcode, T->mcode + T->szmcode); + lj_mcode_patch(J, mcarea, 1); +} + + +``` + +`include/luajit-2.0.5/src/lj_bc.c`: + +```c +/* +** Bytecode instruction modes. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_bc_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_bc.h" + +/* Bytecode offsets and bytecode instruction modes. */ +#include "lj_bcdef.h" + + +``` + +`include/luajit-2.0.5/src/lj_bc.h`: + +```h +/* +** Bytecode instruction format. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_BC_H +#define _LJ_BC_H + +#include "lj_def.h" +#include "lj_arch.h" + +/* Bytecode instruction format, 32 bit wide, fields of 8 or 16 bit: +** +** +----+----+----+----+ +** | B | C | A | OP | Format ABC +** +----+----+----+----+ +** | D | A | OP | Format AD +** +-------------------- +** MSB LSB +** +** In-memory instructions are always stored in host byte order. +*/ + +/* Operand ranges and related constants. */ +#define BCMAX_A 0xff +#define BCMAX_B 0xff +#define BCMAX_C 0xff +#define BCMAX_D 0xffff +#define BCBIAS_J 0x8000 +#define NO_REG BCMAX_A +#define NO_JMP (~(BCPos)0) + +/* Macros to get instruction fields. */ +#define bc_op(i) ((BCOp)((i)&0xff)) +#define bc_a(i) ((BCReg)(((i)>>8)&0xff)) +#define bc_b(i) ((BCReg)((i)>>24)) +#define bc_c(i) ((BCReg)(((i)>>16)&0xff)) +#define bc_d(i) ((BCReg)((i)>>16)) +#define bc_j(i) ((ptrdiff_t)bc_d(i)-BCBIAS_J) + +/* Macros to set instruction fields. */ +#define setbc_byte(p, x, ofs) \ + ((uint8_t *)(p))[LJ_ENDIAN_SELECT(ofs, 3-ofs)] = (uint8_t)(x) +#define setbc_op(p, x) setbc_byte(p, (x), 0) +#define setbc_a(p, x) setbc_byte(p, (x), 1) +#define setbc_b(p, x) setbc_byte(p, (x), 3) +#define setbc_c(p, x) setbc_byte(p, (x), 2) +#define setbc_d(p, x) \ + ((uint16_t *)(p))[LJ_ENDIAN_SELECT(1, 0)] = (uint16_t)(x) +#define setbc_j(p, x) setbc_d(p, (BCPos)((int32_t)(x)+BCBIAS_J)) + +/* Macros to compose instructions. */ +#define BCINS_ABC(o, a, b, c) \ + (((BCIns)(o))|((BCIns)(a)<<8)|((BCIns)(b)<<24)|((BCIns)(c)<<16)) +#define BCINS_AD(o, a, d) \ + (((BCIns)(o))|((BCIns)(a)<<8)|((BCIns)(d)<<16)) +#define BCINS_AJ(o, a, j) BCINS_AD(o, a, (BCPos)((int32_t)(j)+BCBIAS_J)) + +/* Bytecode instruction definition. Order matters, see below. +** +** (name, filler, Amode, Bmode, Cmode or Dmode, metamethod) +** +** The opcode name suffixes specify the type for RB/RC or RD: +** V = variable slot +** S = string const +** N = number const +** P = primitive type (~itype) +** B = unsigned byte literal +** M = multiple args/results +*/ +#define BCDEF(_) \ + /* Comparison ops. ORDER OPR. */ \ + _(ISLT, var, ___, var, lt) \ + _(ISGE, var, ___, var, lt) \ + _(ISLE, var, ___, var, le) \ + _(ISGT, var, ___, var, le) \ + \ + _(ISEQV, var, ___, var, eq) \ + _(ISNEV, var, ___, var, eq) \ + _(ISEQS, var, ___, str, eq) \ + _(ISNES, var, ___, str, eq) \ + _(ISEQN, var, ___, num, eq) \ + _(ISNEN, var, ___, num, eq) \ + _(ISEQP, var, ___, pri, eq) \ + _(ISNEP, var, ___, pri, eq) \ + \ + /* Unary test and copy ops. */ \ + _(ISTC, dst, ___, var, ___) \ + _(ISFC, dst, ___, var, ___) \ + _(IST, ___, ___, var, ___) \ + _(ISF, ___, ___, var, ___) \ + \ + /* Unary ops. */ \ + _(MOV, dst, ___, var, ___) \ + _(NOT, dst, ___, var, ___) \ + _(UNM, dst, ___, var, unm) \ + _(LEN, dst, ___, var, len) \ + \ + /* Binary ops. ORDER OPR. VV last, POW must be next. */ \ + _(ADDVN, dst, var, num, add) \ + _(SUBVN, dst, var, num, sub) \ + _(MULVN, dst, var, num, mul) \ + _(DIVVN, dst, var, num, div) \ + _(MODVN, dst, var, num, mod) \ + \ + _(ADDNV, dst, var, num, add) \ + _(SUBNV, dst, var, num, sub) \ + _(MULNV, dst, var, num, mul) \ + _(DIVNV, dst, var, num, div) \ + _(MODNV, dst, var, num, mod) \ + \ + _(ADDVV, dst, var, var, add) \ + _(SUBVV, dst, var, var, sub) \ + _(MULVV, dst, var, var, mul) \ + _(DIVVV, dst, var, var, div) \ + _(MODVV, dst, var, var, mod) \ + \ + _(POW, dst, var, var, pow) \ + _(CAT, dst, rbase, rbase, concat) \ + \ + /* Constant ops. */ \ + _(KSTR, dst, ___, str, ___) \ + _(KCDATA, dst, ___, cdata, ___) \ + _(KSHORT, dst, ___, lits, ___) \ + _(KNUM, dst, ___, num, ___) \ + _(KPRI, dst, ___, pri, ___) \ + _(KNIL, base, ___, base, ___) \ + \ + /* Upvalue and function ops. */ \ + _(UGET, dst, ___, uv, ___) \ + _(USETV, uv, ___, var, ___) \ + _(USETS, uv, ___, str, ___) \ + _(USETN, uv, ___, num, ___) \ + _(USETP, uv, ___, pri, ___) \ + _(UCLO, rbase, ___, jump, ___) \ + _(FNEW, dst, ___, func, gc) \ + \ + /* Table ops. */ \ + _(TNEW, dst, ___, lit, gc) \ + _(TDUP, dst, ___, tab, gc) \ + _(GGET, dst, ___, str, index) \ + _(GSET, var, ___, str, newindex) \ + _(TGETV, dst, var, var, index) \ + _(TGETS, dst, var, str, index) \ + _(TGETB, dst, var, lit, index) \ + _(TSETV, var, var, var, newindex) \ + _(TSETS, var, var, str, newindex) \ + _(TSETB, var, var, lit, newindex) \ + _(TSETM, base, ___, num, newindex) \ + \ + /* Calls and vararg handling. T = tail call. */ \ + _(CALLM, base, lit, lit, call) \ + _(CALL, base, lit, lit, call) \ + _(CALLMT, base, ___, lit, call) \ + _(CALLT, base, ___, lit, call) \ + _(ITERC, base, lit, lit, call) \ + _(ITERN, base, lit, lit, call) \ + _(VARG, base, lit, lit, ___) \ + _(ISNEXT, base, ___, jump, ___) \ + \ + /* Returns. */ \ + _(RETM, base, ___, lit, ___) \ + _(RET, rbase, ___, lit, ___) \ + _(RET0, rbase, ___, lit, ___) \ + _(RET1, rbase, ___, lit, ___) \ + \ + /* Loops and branches. I/J = interp/JIT, I/C/L = init/call/loop. */ \ + _(FORI, base, ___, jump, ___) \ + _(JFORI, base, ___, jump, ___) \ + \ + _(FORL, base, ___, jump, ___) \ + _(IFORL, base, ___, jump, ___) \ + _(JFORL, base, ___, lit, ___) \ + \ + _(ITERL, base, ___, jump, ___) \ + _(IITERL, base, ___, jump, ___) \ + _(JITERL, base, ___, lit, ___) \ + \ + _(LOOP, rbase, ___, jump, ___) \ + _(ILOOP, rbase, ___, jump, ___) \ + _(JLOOP, rbase, ___, lit, ___) \ + \ + _(JMP, rbase, ___, jump, ___) \ + \ + /* Function headers. I/J = interp/JIT, F/V/C = fixarg/vararg/C func. */ \ + _(FUNCF, rbase, ___, ___, ___) \ + _(IFUNCF, rbase, ___, ___, ___) \ + _(JFUNCF, rbase, ___, lit, ___) \ + _(FUNCV, rbase, ___, ___, ___) \ + _(IFUNCV, rbase, ___, ___, ___) \ + _(JFUNCV, rbase, ___, lit, ___) \ + _(FUNCC, rbase, ___, ___, ___) \ + _(FUNCCW, rbase, ___, ___, ___) + +/* Bytecode opcode numbers. */ +typedef enum { +#define BCENUM(name, ma, mb, mc, mt) BC_##name, +BCDEF(BCENUM) +#undef BCENUM + BC__MAX +} BCOp; + +LJ_STATIC_ASSERT((int)BC_ISEQV+1 == (int)BC_ISNEV); +LJ_STATIC_ASSERT(((int)BC_ISEQV^1) == (int)BC_ISNEV); +LJ_STATIC_ASSERT(((int)BC_ISEQS^1) == (int)BC_ISNES); +LJ_STATIC_ASSERT(((int)BC_ISEQN^1) == (int)BC_ISNEN); +LJ_STATIC_ASSERT(((int)BC_ISEQP^1) == (int)BC_ISNEP); +LJ_STATIC_ASSERT(((int)BC_ISLT^1) == (int)BC_ISGE); +LJ_STATIC_ASSERT(((int)BC_ISLE^1) == (int)BC_ISGT); +LJ_STATIC_ASSERT(((int)BC_ISLT^3) == (int)BC_ISGT); +LJ_STATIC_ASSERT((int)BC_IST-(int)BC_ISTC == (int)BC_ISF-(int)BC_ISFC); +LJ_STATIC_ASSERT((int)BC_CALLT-(int)BC_CALL == (int)BC_CALLMT-(int)BC_CALLM); +LJ_STATIC_ASSERT((int)BC_CALLMT + 1 == (int)BC_CALLT); +LJ_STATIC_ASSERT((int)BC_RETM + 1 == (int)BC_RET); +LJ_STATIC_ASSERT((int)BC_FORL + 1 == (int)BC_IFORL); +LJ_STATIC_ASSERT((int)BC_FORL + 2 == (int)BC_JFORL); +LJ_STATIC_ASSERT((int)BC_ITERL + 1 == (int)BC_IITERL); +LJ_STATIC_ASSERT((int)BC_ITERL + 2 == (int)BC_JITERL); +LJ_STATIC_ASSERT((int)BC_LOOP + 1 == (int)BC_ILOOP); +LJ_STATIC_ASSERT((int)BC_LOOP + 2 == (int)BC_JLOOP); +LJ_STATIC_ASSERT((int)BC_FUNCF + 1 == (int)BC_IFUNCF); +LJ_STATIC_ASSERT((int)BC_FUNCF + 2 == (int)BC_JFUNCF); +LJ_STATIC_ASSERT((int)BC_FUNCV + 1 == (int)BC_IFUNCV); +LJ_STATIC_ASSERT((int)BC_FUNCV + 2 == (int)BC_JFUNCV); + +/* This solves a circular dependency problem, change as needed. */ +#define FF_next_N 4 + +/* Stack slots used by FORI/FORL, relative to operand A. */ +enum { + FORL_IDX, FORL_STOP, FORL_STEP, FORL_EXT +}; + +/* Bytecode operand modes. ORDER BCMode */ +typedef enum { + BCMnone, BCMdst, BCMbase, BCMvar, BCMrbase, BCMuv, /* Mode A must be <= 7 */ + BCMlit, BCMlits, BCMpri, BCMnum, BCMstr, BCMtab, BCMfunc, BCMjump, BCMcdata, + BCM_max +} BCMode; +#define BCM___ BCMnone + +#define bcmode_a(op) ((BCMode)(lj_bc_mode[op] & 7)) +#define bcmode_b(op) ((BCMode)((lj_bc_mode[op]>>3) & 15)) +#define bcmode_c(op) ((BCMode)((lj_bc_mode[op]>>7) & 15)) +#define bcmode_d(op) bcmode_c(op) +#define bcmode_hasd(op) ((lj_bc_mode[op] & (15<<3)) == (BCMnone<<3)) +#define bcmode_mm(op) ((MMS)(lj_bc_mode[op]>>11)) + +#define BCMODE(name, ma, mb, mc, mm) \ + (BCM##ma|(BCM##mb<<3)|(BCM##mc<<7)|(MM_##mm<<11)), +#define BCMODE_FF 0 + +static LJ_AINLINE int bc_isret(BCOp op) +{ + return (op == BC_RETM || op == BC_RET || op == BC_RET0 || op == BC_RET1); +} + +LJ_DATA const uint16_t lj_bc_mode[]; +LJ_DATA const uint16_t lj_bc_ofs[]; + +#endif + +``` + +`include/luajit-2.0.5/src/lj_bcdump.h`: + +```h +/* +** Bytecode dump definitions. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_BCDUMP_H +#define _LJ_BCDUMP_H + +#include "lj_obj.h" +#include "lj_lex.h" + +/* -- Bytecode dump format ------------------------------------------------ */ + +/* +** dump = header proto+ 0U +** header = ESC 'L' 'J' versionB flagsU [namelenU nameB*] +** proto = lengthU pdata +** pdata = phead bcinsW* uvdataH* kgc* knum* [debugB*] +** phead = flagsB numparamsB framesizeB numuvB numkgcU numknU numbcU +** [debuglenU [firstlineU numlineU]] +** kgc = kgctypeU { ktab | (loU hiU) | (rloU rhiU iloU ihiU) | strB* } +** knum = intU0 | (loU1 hiU) +** ktab = narrayU nhashU karray* khash* +** karray = ktabk +** khash = ktabk ktabk +** ktabk = ktabtypeU { intU | (loU hiU) | strB* } +** +** B = 8 bit, H = 16 bit, W = 32 bit, U = ULEB128 of W, U0/U1 = ULEB128 of W+1 +*/ + +/* Bytecode dump header. */ +#define BCDUMP_HEAD1 0x1b +#define BCDUMP_HEAD2 0x4c +#define BCDUMP_HEAD3 0x4a + +/* If you perform *any* kind of private modifications to the bytecode itself +** or to the dump format, you *must* set BCDUMP_VERSION to 0x80 or higher. +*/ +#define BCDUMP_VERSION 1 + +/* Compatibility flags. */ +#define BCDUMP_F_BE 0x01 +#define BCDUMP_F_STRIP 0x02 +#define BCDUMP_F_FFI 0x04 + +#define BCDUMP_F_KNOWN (BCDUMP_F_FFI*2-1) + +/* Type codes for the GC constants of a prototype. Plus length for strings. */ +enum { + BCDUMP_KGC_CHILD, BCDUMP_KGC_TAB, BCDUMP_KGC_I64, BCDUMP_KGC_U64, + BCDUMP_KGC_COMPLEX, BCDUMP_KGC_STR +}; + +/* Type codes for the keys/values of a constant table. */ +enum { + BCDUMP_KTAB_NIL, BCDUMP_KTAB_FALSE, BCDUMP_KTAB_TRUE, + BCDUMP_KTAB_INT, BCDUMP_KTAB_NUM, BCDUMP_KTAB_STR +}; + +/* -- Bytecode reader/writer ---------------------------------------------- */ + +LJ_FUNC int lj_bcwrite(lua_State *L, GCproto *pt, lua_Writer writer, + void *data, int strip); +LJ_FUNC GCproto *lj_bcread(LexState *ls); + +#endif + +``` + +`include/luajit-2.0.5/src/lj_bcread.c`: + +```c +/* +** Bytecode reader. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_bcread_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_bc.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#include "lj_cdata.h" +#include "lualib.h" +#endif +#include "lj_lex.h" +#include "lj_bcdump.h" +#include "lj_state.h" + +/* Reuse some lexer fields for our own purposes. */ +#define bcread_flags(ls) ls->level +#define bcread_swap(ls) \ + ((bcread_flags(ls) & BCDUMP_F_BE) != LJ_BE*BCDUMP_F_BE) +#define bcread_oldtop(L, ls) restorestack(L, ls->lastline) +#define bcread_savetop(L, ls, top) \ + ls->lastline = (BCLine)savestack(L, (top)) + +/* -- Input buffer handling ----------------------------------------------- */ + +/* Throw reader error. */ +static LJ_NOINLINE void bcread_error(LexState *ls, ErrMsg em) +{ + lua_State *L = ls->L; + const char *name = ls->chunkarg; + if (*name == BCDUMP_HEAD1) name = "(binary)"; + else if (*name == '@' || *name == '=') name++; + lj_str_pushf(L, "%s: %s", name, err2msg(em)); + lj_err_throw(L, LUA_ERRSYNTAX); +} + +/* Resize input buffer. */ +static void bcread_resize(LexState *ls, MSize len) +{ + if (ls->sb.sz < len) { + MSize sz = ls->sb.sz * 2; + while (len > sz) sz = sz * 2; + lj_str_resizebuf(ls->L, &ls->sb, sz); + /* Caveat: this may change ls->sb.buf which may affect ls->p. */ + } +} + +/* Refill buffer if needed. */ +static LJ_NOINLINE void bcread_fill(LexState *ls, MSize len, int need) +{ + lua_assert(len != 0); + if (len > LJ_MAX_MEM || ls->current < 0) + bcread_error(ls, LJ_ERR_BCBAD); + do { + const char *buf; + size_t size; + if (ls->n) { /* Copy remainder to buffer. */ + if (ls->sb.n) { /* Move down in buffer. */ + lua_assert(ls->p + ls->n == ls->sb.buf + ls->sb.n); + if (ls->n != ls->sb.n) + memmove(ls->sb.buf, ls->p, ls->n); + } else { /* Copy from buffer provided by reader. */ + bcread_resize(ls, len); + memcpy(ls->sb.buf, ls->p, ls->n); + } + ls->p = ls->sb.buf; + } + ls->sb.n = ls->n; + buf = ls->rfunc(ls->L, ls->rdata, &size); /* Get more data from reader. */ + if (buf == NULL || size == 0) { /* EOF? */ + if (need) bcread_error(ls, LJ_ERR_BCBAD); + ls->current = -1; /* Only bad if we get called again. */ + break; + } + if (ls->sb.n) { /* Append to buffer. */ + MSize n = ls->sb.n + (MSize)size; + bcread_resize(ls, n < len ? len : n); + memcpy(ls->sb.buf + ls->sb.n, buf, size); + ls->n = ls->sb.n = n; + ls->p = ls->sb.buf; + } else { /* Return buffer provided by reader. */ + ls->n = (MSize)size; + ls->p = buf; + } + } while (ls->n < len); +} + +/* Need a certain number of bytes. */ +static LJ_AINLINE void bcread_need(LexState *ls, MSize len) +{ + if (LJ_UNLIKELY(ls->n < len)) + bcread_fill(ls, len, 1); +} + +/* Want to read up to a certain number of bytes, but may need less. */ +static LJ_AINLINE void bcread_want(LexState *ls, MSize len) +{ + if (LJ_UNLIKELY(ls->n < len)) + bcread_fill(ls, len, 0); +} + +#define bcread_dec(ls) check_exp(ls->n > 0, ls->n--) +#define bcread_consume(ls, len) check_exp(ls->n >= (len), ls->n -= (len)) + +/* Return memory block from buffer. */ +static uint8_t *bcread_mem(LexState *ls, MSize len) +{ + uint8_t *p = (uint8_t *)ls->p; + bcread_consume(ls, len); + ls->p = (char *)p + len; + return p; +} + +/* Copy memory block from buffer. */ +static void bcread_block(LexState *ls, void *q, MSize len) +{ + memcpy(q, bcread_mem(ls, len), len); +} + +/* Read byte from buffer. */ +static LJ_AINLINE uint32_t bcread_byte(LexState *ls) +{ + bcread_dec(ls); + return (uint32_t)(uint8_t)*ls->p++; +} + +/* Read ULEB128 value from buffer. */ +static uint32_t bcread_uleb128(LexState *ls) +{ + const uint8_t *p = (const uint8_t *)ls->p; + uint32_t v = *p++; + if (LJ_UNLIKELY(v >= 0x80)) { + int sh = 0; + v &= 0x7f; + do { + v |= ((*p & 0x7f) << (sh += 7)); + bcread_dec(ls); + } while (*p++ >= 0x80); + } + bcread_dec(ls); + ls->p = (char *)p; + return v; +} + +/* Read top 32 bits of 33 bit ULEB128 value from buffer. */ +static uint32_t bcread_uleb128_33(LexState *ls) +{ + const uint8_t *p = (const uint8_t *)ls->p; + uint32_t v = (*p++ >> 1); + if (LJ_UNLIKELY(v >= 0x40)) { + int sh = -1; + v &= 0x3f; + do { + v |= ((*p & 0x7f) << (sh += 7)); + bcread_dec(ls); + } while (*p++ >= 0x80); + } + bcread_dec(ls); + ls->p = (char *)p; + return v; +} + +/* -- Bytecode reader ----------------------------------------------------- */ + +/* Read debug info of a prototype. */ +static void bcread_dbg(LexState *ls, GCproto *pt, MSize sizedbg) +{ + void *lineinfo = (void *)proto_lineinfo(pt); + bcread_block(ls, lineinfo, sizedbg); + /* Swap lineinfo if the endianess differs. */ + if (bcread_swap(ls) && pt->numline >= 256) { + MSize i, n = pt->sizebc-1; + if (pt->numline < 65536) { + uint16_t *p = (uint16_t *)lineinfo; + for (i = 0; i < n; i++) p[i] = (uint16_t)((p[i] >> 8)|(p[i] << 8)); + } else { + uint32_t *p = (uint32_t *)lineinfo; + for (i = 0; i < n; i++) p[i] = lj_bswap(p[i]); + } + } +} + +/* Find pointer to varinfo. */ +static const void *bcread_varinfo(GCproto *pt) +{ + const uint8_t *p = proto_uvinfo(pt); + MSize n = pt->sizeuv; + if (n) while (*p++ || --n) ; + return p; +} + +/* Read a single constant key/value of a template table. */ +static void bcread_ktabk(LexState *ls, TValue *o) +{ + MSize tp = bcread_uleb128(ls); + if (tp >= BCDUMP_KTAB_STR) { + MSize len = tp - BCDUMP_KTAB_STR; + const char *p = (const char *)bcread_mem(ls, len); + setstrV(ls->L, o, lj_str_new(ls->L, p, len)); + } else if (tp == BCDUMP_KTAB_INT) { + setintV(o, (int32_t)bcread_uleb128(ls)); + } else if (tp == BCDUMP_KTAB_NUM) { + o->u32.lo = bcread_uleb128(ls); + o->u32.hi = bcread_uleb128(ls); + } else { + lua_assert(tp <= BCDUMP_KTAB_TRUE); + setitype(o, ~tp); + } +} + +/* Read a template table. */ +static GCtab *bcread_ktab(LexState *ls) +{ + MSize narray = bcread_uleb128(ls); + MSize nhash = bcread_uleb128(ls); + GCtab *t = lj_tab_new(ls->L, narray, hsize2hbits(nhash)); + if (narray) { /* Read array entries. */ + MSize i; + TValue *o = tvref(t->array); + for (i = 0; i < narray; i++, o++) + bcread_ktabk(ls, o); + } + if (nhash) { /* Read hash entries. */ + MSize i; + for (i = 0; i < nhash; i++) { + TValue key; + bcread_ktabk(ls, &key); + lua_assert(!tvisnil(&key)); + bcread_ktabk(ls, lj_tab_set(ls->L, t, &key)); + } + } + return t; +} + +/* Read GC constants of a prototype. */ +static void bcread_kgc(LexState *ls, GCproto *pt, MSize sizekgc) +{ + MSize i; + GCRef *kr = mref(pt->k, GCRef) - (ptrdiff_t)sizekgc; + for (i = 0; i < sizekgc; i++, kr++) { + MSize tp = bcread_uleb128(ls); + if (tp >= BCDUMP_KGC_STR) { + MSize len = tp - BCDUMP_KGC_STR; + const char *p = (const char *)bcread_mem(ls, len); + setgcref(*kr, obj2gco(lj_str_new(ls->L, p, len))); + } else if (tp == BCDUMP_KGC_TAB) { + setgcref(*kr, obj2gco(bcread_ktab(ls))); +#if LJ_HASFFI + } else if (tp != BCDUMP_KGC_CHILD) { + CTypeID id = tp == BCDUMP_KGC_COMPLEX ? CTID_COMPLEX_DOUBLE : + tp == BCDUMP_KGC_I64 ? CTID_INT64 : CTID_UINT64; + CTSize sz = tp == BCDUMP_KGC_COMPLEX ? 16 : 8; + GCcdata *cd = lj_cdata_new_(ls->L, id, sz); + TValue *p = (TValue *)cdataptr(cd); + setgcref(*kr, obj2gco(cd)); + p[0].u32.lo = bcread_uleb128(ls); + p[0].u32.hi = bcread_uleb128(ls); + if (tp == BCDUMP_KGC_COMPLEX) { + p[1].u32.lo = bcread_uleb128(ls); + p[1].u32.hi = bcread_uleb128(ls); + } +#endif + } else { + lua_State *L = ls->L; + lua_assert(tp == BCDUMP_KGC_CHILD); + if (L->top <= bcread_oldtop(L, ls)) /* Stack underflow? */ + bcread_error(ls, LJ_ERR_BCBAD); + L->top--; + setgcref(*kr, obj2gco(protoV(L->top))); + } + } +} + +/* Read number constants of a prototype. */ +static void bcread_knum(LexState *ls, GCproto *pt, MSize sizekn) +{ + MSize i; + TValue *o = mref(pt->k, TValue); + for (i = 0; i < sizekn; i++, o++) { + int isnum = (ls->p[0] & 1); + uint32_t lo = bcread_uleb128_33(ls); + if (isnum) { + o->u32.lo = lo; + o->u32.hi = bcread_uleb128(ls); + } else { + setintV(o, lo); + } + } +} + +/* Read bytecode instructions. */ +static void bcread_bytecode(LexState *ls, GCproto *pt, MSize sizebc) +{ + BCIns *bc = proto_bc(pt); + bc[0] = BCINS_AD((pt->flags & PROTO_VARARG) ? BC_FUNCV : BC_FUNCF, + pt->framesize, 0); + bcread_block(ls, bc+1, (sizebc-1)*(MSize)sizeof(BCIns)); + /* Swap bytecode instructions if the endianess differs. */ + if (bcread_swap(ls)) { + MSize i; + for (i = 1; i < sizebc; i++) bc[i] = lj_bswap(bc[i]); + } +} + +/* Read upvalue refs. */ +static void bcread_uv(LexState *ls, GCproto *pt, MSize sizeuv) +{ + if (sizeuv) { + uint16_t *uv = proto_uv(pt); + bcread_block(ls, uv, sizeuv*2); + /* Swap upvalue refs if the endianess differs. */ + if (bcread_swap(ls)) { + MSize i; + for (i = 0; i < sizeuv; i++) + uv[i] = (uint16_t)((uv[i] >> 8)|(uv[i] << 8)); + } + } +} + +/* Read a prototype. */ +static GCproto *bcread_proto(LexState *ls) +{ + GCproto *pt; + MSize framesize, numparams, flags, sizeuv, sizekgc, sizekn, sizebc, sizept; + MSize ofsk, ofsuv, ofsdbg; + MSize sizedbg = 0; + BCLine firstline = 0, numline = 0; + MSize len, startn; + + /* Read length. */ + if (ls->n > 0 && ls->p[0] == 0) { /* Shortcut EOF. */ + ls->n--; ls->p++; + return NULL; + } + bcread_want(ls, 5); + len = bcread_uleb128(ls); + if (!len) return NULL; /* EOF */ + bcread_need(ls, len); + startn = ls->n; + + /* Read prototype header. */ + flags = bcread_byte(ls); + numparams = bcread_byte(ls); + framesize = bcread_byte(ls); + sizeuv = bcread_byte(ls); + sizekgc = bcread_uleb128(ls); + sizekn = bcread_uleb128(ls); + sizebc = bcread_uleb128(ls) + 1; + if (!(bcread_flags(ls) & BCDUMP_F_STRIP)) { + sizedbg = bcread_uleb128(ls); + if (sizedbg) { + firstline = bcread_uleb128(ls); + numline = bcread_uleb128(ls); + } + } + + /* Calculate total size of prototype including all colocated arrays. */ + sizept = (MSize)sizeof(GCproto) + + sizebc*(MSize)sizeof(BCIns) + + sizekgc*(MSize)sizeof(GCRef); + sizept = (sizept + (MSize)sizeof(TValue)-1) & ~((MSize)sizeof(TValue)-1); + ofsk = sizept; sizept += sizekn*(MSize)sizeof(TValue); + ofsuv = sizept; sizept += ((sizeuv+1)&~1)*2; + ofsdbg = sizept; sizept += sizedbg; + + /* Allocate prototype object and initialize its fields. */ + pt = (GCproto *)lj_mem_newgco(ls->L, (MSize)sizept); + pt->gct = ~LJ_TPROTO; + pt->numparams = (uint8_t)numparams; + pt->framesize = (uint8_t)framesize; + pt->sizebc = sizebc; + setmref(pt->k, (char *)pt + ofsk); + setmref(pt->uv, (char *)pt + ofsuv); + pt->sizekgc = 0; /* Set to zero until fully initialized. */ + pt->sizekn = sizekn; + pt->sizept = sizept; + pt->sizeuv = (uint8_t)sizeuv; + pt->flags = (uint8_t)flags; + pt->trace = 0; + setgcref(pt->chunkname, obj2gco(ls->chunkname)); + + /* Close potentially uninitialized gap between bc and kgc. */ + *(uint32_t *)((char *)pt + ofsk - sizeof(GCRef)*(sizekgc+1)) = 0; + + /* Read bytecode instructions and upvalue refs. */ + bcread_bytecode(ls, pt, sizebc); + bcread_uv(ls, pt, sizeuv); + + /* Read constants. */ + bcread_kgc(ls, pt, sizekgc); + pt->sizekgc = sizekgc; + bcread_knum(ls, pt, sizekn); + + /* Read and initialize debug info. */ + pt->firstline = firstline; + pt->numline = numline; + if (sizedbg) { + MSize sizeli = (sizebc-1) << (numline < 256 ? 0 : numline < 65536 ? 1 : 2); + setmref(pt->lineinfo, (char *)pt + ofsdbg); + setmref(pt->uvinfo, (char *)pt + ofsdbg + sizeli); + bcread_dbg(ls, pt, sizedbg); + setmref(pt->varinfo, bcread_varinfo(pt)); + } else { + setmref(pt->lineinfo, NULL); + setmref(pt->uvinfo, NULL); + setmref(pt->varinfo, NULL); + } + + if (len != startn - ls->n) + bcread_error(ls, LJ_ERR_BCBAD); + return pt; +} + +/* Read and check header of bytecode dump. */ +static int bcread_header(LexState *ls) +{ + uint32_t flags; + bcread_want(ls, 3+5+5); + if (bcread_byte(ls) != BCDUMP_HEAD2 || + bcread_byte(ls) != BCDUMP_HEAD3 || + bcread_byte(ls) != BCDUMP_VERSION) return 0; + bcread_flags(ls) = flags = bcread_uleb128(ls); + if ((flags & ~(BCDUMP_F_KNOWN)) != 0) return 0; + if ((flags & BCDUMP_F_FFI)) { +#if LJ_HASFFI + lua_State *L = ls->L; + if (!ctype_ctsG(G(L))) { + ptrdiff_t oldtop = savestack(L, L->top); + luaopen_ffi(L); /* Load FFI library on-demand. */ + L->top = restorestack(L, oldtop); + } +#else + return 0; +#endif + } + if ((flags & BCDUMP_F_STRIP)) { + ls->chunkname = lj_str_newz(ls->L, ls->chunkarg); + } else { + MSize len = bcread_uleb128(ls); + bcread_need(ls, len); + ls->chunkname = lj_str_new(ls->L, (const char *)bcread_mem(ls, len), len); + } + return 1; /* Ok. */ +} + +/* Read a bytecode dump. */ +GCproto *lj_bcread(LexState *ls) +{ + lua_State *L = ls->L; + lua_assert(ls->current == BCDUMP_HEAD1); + bcread_savetop(L, ls, L->top); + lj_str_resetbuf(&ls->sb); + /* Check for a valid bytecode dump header. */ + if (!bcread_header(ls)) + bcread_error(ls, LJ_ERR_BCFMT); + for (;;) { /* Process all prototypes in the bytecode dump. */ + GCproto *pt = bcread_proto(ls); + if (!pt) break; + setprotoV(L, L->top, pt); + incr_top(L); + } + if ((int32_t)ls->n > 0 || L->top-1 != bcread_oldtop(L, ls)) + bcread_error(ls, LJ_ERR_BCBAD); + /* Pop off last prototype. */ + L->top--; + return protoV(L->top); +} + + +``` + +`include/luajit-2.0.5/src/lj_bcwrite.c`: + +```c +/* +** Bytecode writer. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_bcwrite_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_str.h" +#include "lj_bc.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#endif +#if LJ_HASJIT +#include "lj_dispatch.h" +#include "lj_jit.h" +#endif +#include "lj_bcdump.h" +#include "lj_vm.h" + +/* Context for bytecode writer. */ +typedef struct BCWriteCtx { + SBuf sb; /* Output buffer. */ + lua_State *L; /* Lua state. */ + GCproto *pt; /* Root prototype. */ + lua_Writer wfunc; /* Writer callback. */ + void *wdata; /* Writer callback data. */ + int strip; /* Strip debug info. */ + int status; /* Status from writer callback. */ +} BCWriteCtx; + +/* -- Output buffer handling ---------------------------------------------- */ + +/* Resize buffer if needed. */ +static LJ_NOINLINE void bcwrite_resize(BCWriteCtx *ctx, MSize len) +{ + MSize sz = ctx->sb.sz * 2; + while (ctx->sb.n + len > sz) sz = sz * 2; + lj_str_resizebuf(ctx->L, &ctx->sb, sz); +} + +/* Need a certain amount of buffer space. */ +static LJ_AINLINE void bcwrite_need(BCWriteCtx *ctx, MSize len) +{ + if (LJ_UNLIKELY(ctx->sb.n + len > ctx->sb.sz)) + bcwrite_resize(ctx, len); +} + +/* Add memory block to buffer. */ +static void bcwrite_block(BCWriteCtx *ctx, const void *p, MSize len) +{ + uint8_t *q = (uint8_t *)(ctx->sb.buf + ctx->sb.n); + MSize i; + ctx->sb.n += len; + for (i = 0; i < len; i++) q[i] = ((uint8_t *)p)[i]; +} + +/* Add byte to buffer. */ +static LJ_AINLINE void bcwrite_byte(BCWriteCtx *ctx, uint8_t b) +{ + ctx->sb.buf[ctx->sb.n++] = b; +} + +/* Add ULEB128 value to buffer. */ +static void bcwrite_uleb128(BCWriteCtx *ctx, uint32_t v) +{ + MSize n = ctx->sb.n; + uint8_t *p = (uint8_t *)ctx->sb.buf; + for (; v >= 0x80; v >>= 7) + p[n++] = (uint8_t)((v & 0x7f) | 0x80); + p[n++] = (uint8_t)v; + ctx->sb.n = n; +} + +/* -- Bytecode writer ----------------------------------------------------- */ + +/* Write a single constant key/value of a template table. */ +static void bcwrite_ktabk(BCWriteCtx *ctx, cTValue *o, int narrow) +{ + bcwrite_need(ctx, 1+10); + if (tvisstr(o)) { + const GCstr *str = strV(o); + MSize len = str->len; + bcwrite_need(ctx, 5+len); + bcwrite_uleb128(ctx, BCDUMP_KTAB_STR+len); + bcwrite_block(ctx, strdata(str), len); + } else if (tvisint(o)) { + bcwrite_byte(ctx, BCDUMP_KTAB_INT); + bcwrite_uleb128(ctx, intV(o)); + } else if (tvisnum(o)) { + if (!LJ_DUALNUM && narrow) { /* Narrow number constants to integers. */ + lua_Number num = numV(o); + int32_t k = lj_num2int(num); + if (num == (lua_Number)k) { /* -0 is never a constant. */ + bcwrite_byte(ctx, BCDUMP_KTAB_INT); + bcwrite_uleb128(ctx, k); + return; + } + } + bcwrite_byte(ctx, BCDUMP_KTAB_NUM); + bcwrite_uleb128(ctx, o->u32.lo); + bcwrite_uleb128(ctx, o->u32.hi); + } else { + lua_assert(tvispri(o)); + bcwrite_byte(ctx, BCDUMP_KTAB_NIL+~itype(o)); + } +} + +/* Write a template table. */ +static void bcwrite_ktab(BCWriteCtx *ctx, const GCtab *t) +{ + MSize narray = 0, nhash = 0; + if (t->asize > 0) { /* Determine max. length of array part. */ + ptrdiff_t i; + TValue *array = tvref(t->array); + for (i = (ptrdiff_t)t->asize-1; i >= 0; i--) + if (!tvisnil(&array[i])) + break; + narray = (MSize)(i+1); + } + if (t->hmask > 0) { /* Count number of used hash slots. */ + MSize i, hmask = t->hmask; + Node *node = noderef(t->node); + for (i = 0; i <= hmask; i++) + nhash += !tvisnil(&node[i].val); + } + /* Write number of array slots and hash slots. */ + bcwrite_uleb128(ctx, narray); + bcwrite_uleb128(ctx, nhash); + if (narray) { /* Write array entries (may contain nil). */ + MSize i; + TValue *o = tvref(t->array); + for (i = 0; i < narray; i++, o++) + bcwrite_ktabk(ctx, o, 1); + } + if (nhash) { /* Write hash entries. */ + MSize i = nhash; + Node *node = noderef(t->node) + t->hmask; + for (;; node--) + if (!tvisnil(&node->val)) { + bcwrite_ktabk(ctx, &node->key, 0); + bcwrite_ktabk(ctx, &node->val, 1); + if (--i == 0) break; + } + } +} + +/* Write GC constants of a prototype. */ +static void bcwrite_kgc(BCWriteCtx *ctx, GCproto *pt) +{ + MSize i, sizekgc = pt->sizekgc; + GCRef *kr = mref(pt->k, GCRef) - (ptrdiff_t)sizekgc; + for (i = 0; i < sizekgc; i++, kr++) { + GCobj *o = gcref(*kr); + MSize tp, need = 1; + /* Determine constant type and needed size. */ + if (o->gch.gct == ~LJ_TSTR) { + tp = BCDUMP_KGC_STR + gco2str(o)->len; + need = 5+gco2str(o)->len; + } else if (o->gch.gct == ~LJ_TPROTO) { + lua_assert((pt->flags & PROTO_CHILD)); + tp = BCDUMP_KGC_CHILD; +#if LJ_HASFFI + } else if (o->gch.gct == ~LJ_TCDATA) { + CTypeID id = gco2cd(o)->ctypeid; + need = 1+4*5; + if (id == CTID_INT64) { + tp = BCDUMP_KGC_I64; + } else if (id == CTID_UINT64) { + tp = BCDUMP_KGC_U64; + } else { + lua_assert(id == CTID_COMPLEX_DOUBLE); + tp = BCDUMP_KGC_COMPLEX; + } +#endif + } else { + lua_assert(o->gch.gct == ~LJ_TTAB); + tp = BCDUMP_KGC_TAB; + need = 1+2*5; + } + /* Write constant type. */ + bcwrite_need(ctx, need); + bcwrite_uleb128(ctx, tp); + /* Write constant data (if any). */ + if (tp >= BCDUMP_KGC_STR) { + bcwrite_block(ctx, strdata(gco2str(o)), gco2str(o)->len); + } else if (tp == BCDUMP_KGC_TAB) { + bcwrite_ktab(ctx, gco2tab(o)); +#if LJ_HASFFI + } else if (tp != BCDUMP_KGC_CHILD) { + cTValue *p = (TValue *)cdataptr(gco2cd(o)); + bcwrite_uleb128(ctx, p[0].u32.lo); + bcwrite_uleb128(ctx, p[0].u32.hi); + if (tp == BCDUMP_KGC_COMPLEX) { + bcwrite_uleb128(ctx, p[1].u32.lo); + bcwrite_uleb128(ctx, p[1].u32.hi); + } +#endif + } + } +} + +/* Write number constants of a prototype. */ +static void bcwrite_knum(BCWriteCtx *ctx, GCproto *pt) +{ + MSize i, sizekn = pt->sizekn; + cTValue *o = mref(pt->k, TValue); + bcwrite_need(ctx, 10*sizekn); + for (i = 0; i < sizekn; i++, o++) { + int32_t k; + if (tvisint(o)) { + k = intV(o); + goto save_int; + } else { + /* Write a 33 bit ULEB128 for the int (lsb=0) or loword (lsb=1). */ + if (!LJ_DUALNUM) { /* Narrow number constants to integers. */ + lua_Number num = numV(o); + k = lj_num2int(num); + if (num == (lua_Number)k) { /* -0 is never a constant. */ + save_int: + bcwrite_uleb128(ctx, 2*(uint32_t)k | ((uint32_t)k & 0x80000000u)); + if (k < 0) { + char *p = &ctx->sb.buf[ctx->sb.n-1]; + *p = (*p & 7) | ((k>>27) & 0x18); + } + continue; + } + } + bcwrite_uleb128(ctx, 1+(2*o->u32.lo | (o->u32.lo & 0x80000000u))); + if (o->u32.lo >= 0x80000000u) { + char *p = &ctx->sb.buf[ctx->sb.n-1]; + *p = (*p & 7) | ((o->u32.lo>>27) & 0x18); + } + bcwrite_uleb128(ctx, o->u32.hi); + } + } +} + +/* Write bytecode instructions. */ +static void bcwrite_bytecode(BCWriteCtx *ctx, GCproto *pt) +{ + MSize nbc = pt->sizebc-1; /* Omit the [JI]FUNC* header. */ +#if LJ_HASJIT + uint8_t *p = (uint8_t *)&ctx->sb.buf[ctx->sb.n]; +#endif + bcwrite_block(ctx, proto_bc(pt)+1, nbc*(MSize)sizeof(BCIns)); +#if LJ_HASJIT + /* Unpatch modified bytecode containing ILOOP/JLOOP etc. */ + if ((pt->flags & PROTO_ILOOP) || pt->trace) { + jit_State *J = L2J(ctx->L); + MSize i; + for (i = 0; i < nbc; i++, p += sizeof(BCIns)) { + BCOp op = (BCOp)p[LJ_ENDIAN_SELECT(0, 3)]; + if (op == BC_IFORL || op == BC_IITERL || op == BC_ILOOP || + op == BC_JFORI) { + p[LJ_ENDIAN_SELECT(0, 3)] = (uint8_t)(op-BC_IFORL+BC_FORL); + } else if (op == BC_JFORL || op == BC_JITERL || op == BC_JLOOP) { + BCReg rd = p[LJ_ENDIAN_SELECT(2, 1)] + (p[LJ_ENDIAN_SELECT(3, 0)] << 8); + BCIns ins = traceref(J, rd)->startins; + p[LJ_ENDIAN_SELECT(0, 3)] = (uint8_t)(op-BC_JFORL+BC_FORL); + p[LJ_ENDIAN_SELECT(2, 1)] = bc_c(ins); + p[LJ_ENDIAN_SELECT(3, 0)] = bc_b(ins); + } + } + } +#endif +} + +/* Write prototype. */ +static void bcwrite_proto(BCWriteCtx *ctx, GCproto *pt) +{ + MSize sizedbg = 0; + + /* Recursively write children of prototype. */ + if ((pt->flags & PROTO_CHILD)) { + ptrdiff_t i, n = pt->sizekgc; + GCRef *kr = mref(pt->k, GCRef) - 1; + for (i = 0; i < n; i++, kr--) { + GCobj *o = gcref(*kr); + if (o->gch.gct == ~LJ_TPROTO) + bcwrite_proto(ctx, gco2pt(o)); + } + } + + /* Start writing the prototype info to a buffer. */ + lj_str_resetbuf(&ctx->sb); + ctx->sb.n = 5; /* Leave room for final size. */ + bcwrite_need(ctx, 4+6*5+(pt->sizebc-1)*(MSize)sizeof(BCIns)+pt->sizeuv*2); + + /* Write prototype header. */ + bcwrite_byte(ctx, (pt->flags & (PROTO_CHILD|PROTO_VARARG|PROTO_FFI))); + bcwrite_byte(ctx, pt->numparams); + bcwrite_byte(ctx, pt->framesize); + bcwrite_byte(ctx, pt->sizeuv); + bcwrite_uleb128(ctx, pt->sizekgc); + bcwrite_uleb128(ctx, pt->sizekn); + bcwrite_uleb128(ctx, pt->sizebc-1); + if (!ctx->strip) { + if (proto_lineinfo(pt)) + sizedbg = pt->sizept - (MSize)((char *)proto_lineinfo(pt) - (char *)pt); + bcwrite_uleb128(ctx, sizedbg); + if (sizedbg) { + bcwrite_uleb128(ctx, pt->firstline); + bcwrite_uleb128(ctx, pt->numline); + } + } + + /* Write bytecode instructions and upvalue refs. */ + bcwrite_bytecode(ctx, pt); + bcwrite_block(ctx, proto_uv(pt), pt->sizeuv*2); + + /* Write constants. */ + bcwrite_kgc(ctx, pt); + bcwrite_knum(ctx, pt); + + /* Write debug info, if not stripped. */ + if (sizedbg) { + bcwrite_need(ctx, sizedbg); + bcwrite_block(ctx, proto_lineinfo(pt), sizedbg); + } + + /* Pass buffer to writer function. */ + if (ctx->status == 0) { + MSize n = ctx->sb.n - 5; + MSize nn = (lj_fls(n)+8)*9 >> 6; + ctx->sb.n = 5 - nn; + bcwrite_uleb128(ctx, n); /* Fill in final size. */ + lua_assert(ctx->sb.n == 5); + ctx->status = ctx->wfunc(ctx->L, ctx->sb.buf+5-nn, nn+n, ctx->wdata); + } +} + +/* Write header of bytecode dump. */ +static void bcwrite_header(BCWriteCtx *ctx) +{ + GCstr *chunkname = proto_chunkname(ctx->pt); + const char *name = strdata(chunkname); + MSize len = chunkname->len; + lj_str_resetbuf(&ctx->sb); + bcwrite_need(ctx, 5+5+len); + bcwrite_byte(ctx, BCDUMP_HEAD1); + bcwrite_byte(ctx, BCDUMP_HEAD2); + bcwrite_byte(ctx, BCDUMP_HEAD3); + bcwrite_byte(ctx, BCDUMP_VERSION); + bcwrite_byte(ctx, (ctx->strip ? BCDUMP_F_STRIP : 0) + + (LJ_BE ? BCDUMP_F_BE : 0) + + ((ctx->pt->flags & PROTO_FFI) ? BCDUMP_F_FFI : 0)); + if (!ctx->strip) { + bcwrite_uleb128(ctx, len); + bcwrite_block(ctx, name, len); + } + ctx->status = ctx->wfunc(ctx->L, ctx->sb.buf, ctx->sb.n, ctx->wdata); +} + +/* Write footer of bytecode dump. */ +static void bcwrite_footer(BCWriteCtx *ctx) +{ + if (ctx->status == 0) { + uint8_t zero = 0; + ctx->status = ctx->wfunc(ctx->L, &zero, 1, ctx->wdata); + } +} + +/* Protected callback for bytecode writer. */ +static TValue *cpwriter(lua_State *L, lua_CFunction dummy, void *ud) +{ + BCWriteCtx *ctx = (BCWriteCtx *)ud; + UNUSED(dummy); + lj_str_resizebuf(L, &ctx->sb, 1024); /* Avoids resize for most prototypes. */ + bcwrite_header(ctx); + bcwrite_proto(ctx, ctx->pt); + bcwrite_footer(ctx); + return NULL; +} + +/* Write bytecode for a prototype. */ +int lj_bcwrite(lua_State *L, GCproto *pt, lua_Writer writer, void *data, + int strip) +{ + BCWriteCtx ctx; + int status; + ctx.L = L; + ctx.pt = pt; + ctx.wfunc = writer; + ctx.wdata = data; + ctx.strip = strip; + ctx.status = 0; + lj_str_initbuf(&ctx.sb); + status = lj_vm_cpcall(L, NULL, &ctx, cpwriter); + if (status == 0) status = ctx.status; + lj_str_freebuf(G(ctx.L), &ctx.sb); + return status; +} + + +``` + +`include/luajit-2.0.5/src/lj_carith.c`: + +```c +/* +** C data arithmetic. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_tab.h" +#include "lj_meta.h" +#include "lj_ctype.h" +#include "lj_cconv.h" +#include "lj_cdata.h" +#include "lj_carith.h" + +/* -- C data arithmetic --------------------------------------------------- */ + +/* Binary operands of an operator converted to ctypes. */ +typedef struct CDArith { + uint8_t *p[2]; + CType *ct[2]; +} CDArith; + +/* Check arguments for arithmetic metamethods. */ +static int carith_checkarg(lua_State *L, CTState *cts, CDArith *ca) +{ + TValue *o = L->base; + int ok = 1; + MSize i; + if (o+1 >= L->top) + lj_err_argt(L, 1, LUA_TCDATA); + for (i = 0; i < 2; i++, o++) { + if (tviscdata(o)) { + GCcdata *cd = cdataV(o); + CTypeID id = (CTypeID)cd->ctypeid; + CType *ct = ctype_raw(cts, id); + uint8_t *p = (uint8_t *)cdataptr(cd); + if (ctype_isptr(ct->info)) { + p = (uint8_t *)cdata_getptr(p, ct->size); + if (ctype_isref(ct->info)) ct = ctype_rawchild(cts, ct); + } else if (ctype_isfunc(ct->info)) { + p = (uint8_t *)*(void **)p; + ct = ctype_get(cts, + lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR)); + } + if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); + ca->ct[i] = ct; + ca->p[i] = p; + } else if (tvisint(o)) { + ca->ct[i] = ctype_get(cts, CTID_INT32); + ca->p[i] = (uint8_t *)&o->i; + } else if (tvisnum(o)) { + ca->ct[i] = ctype_get(cts, CTID_DOUBLE); + ca->p[i] = (uint8_t *)&o->n; + } else if (tvisnil(o)) { + ca->ct[i] = ctype_get(cts, CTID_P_VOID); + ca->p[i] = (uint8_t *)0; + } else if (tvisstr(o)) { + TValue *o2 = i == 0 ? o+1 : o-1; + CType *ct = ctype_raw(cts, cdataV(o2)->ctypeid); + ca->ct[i] = NULL; + ca->p[i] = (uint8_t *)strVdata(o); + ok = 0; + if (ctype_isenum(ct->info)) { + CTSize ofs; + CType *cct = lj_ctype_getfield(cts, ct, strV(o), &ofs); + if (cct && ctype_isconstval(cct->info)) { + ca->ct[i] = ctype_child(cts, cct); + ca->p[i] = (uint8_t *)&cct->size; /* Assumes ct does not grow. */ + ok = 1; + } else { + ca->ct[1-i] = ct; /* Use enum to improve error message. */ + ca->p[1-i] = NULL; + break; + } + } + } else { + ca->ct[i] = NULL; + ca->p[i] = (void *)(intptr_t)1; /* To make it unequal. */ + ok = 0; + } + } + return ok; +} + +/* Pointer arithmetic. */ +static int carith_ptr(lua_State *L, CTState *cts, CDArith *ca, MMS mm) +{ + CType *ctp = ca->ct[0]; + uint8_t *pp = ca->p[0]; + ptrdiff_t idx; + CTSize sz; + CTypeID id; + GCcdata *cd; + if (ctype_isptr(ctp->info) || ctype_isrefarray(ctp->info)) { + if ((mm == MM_sub || mm == MM_eq || mm == MM_lt || mm == MM_le) && + (ctype_isptr(ca->ct[1]->info) || ctype_isrefarray(ca->ct[1]->info))) { + uint8_t *pp2 = ca->p[1]; + if (mm == MM_eq) { /* Pointer equality. Incompatible pointers are ok. */ + setboolV(L->top-1, (pp == pp2)); + return 1; + } + if (!lj_cconv_compatptr(cts, ctp, ca->ct[1], CCF_IGNQUAL)) + return 0; + if (mm == MM_sub) { /* Pointer difference. */ + intptr_t diff; + sz = lj_ctype_size(cts, ctype_cid(ctp->info)); /* Element size. */ + if (sz == 0 || sz == CTSIZE_INVALID) + return 0; + diff = ((intptr_t)pp - (intptr_t)pp2) / (int32_t)sz; + /* All valid pointer differences on x64 are in (-2^47, +2^47), + ** which fits into a double without loss of precision. + */ + setintptrV(L->top-1, (int32_t)diff); + return 1; + } else if (mm == MM_lt) { /* Pointer comparison (unsigned). */ + setboolV(L->top-1, ((uintptr_t)pp < (uintptr_t)pp2)); + return 1; + } else { + lua_assert(mm == MM_le); + setboolV(L->top-1, ((uintptr_t)pp <= (uintptr_t)pp2)); + return 1; + } + } + if (!((mm == MM_add || mm == MM_sub) && ctype_isnum(ca->ct[1]->info))) + return 0; + lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ca->ct[1], + (uint8_t *)&idx, ca->p[1], 0); + if (mm == MM_sub) idx = -idx; + } else if (mm == MM_add && ctype_isnum(ctp->info) && + (ctype_isptr(ca->ct[1]->info) || ctype_isrefarray(ca->ct[1]->info))) { + /* Swap pointer and index. */ + ctp = ca->ct[1]; pp = ca->p[1]; + lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ca->ct[0], + (uint8_t *)&idx, ca->p[0], 0); + } else { + return 0; + } + sz = lj_ctype_size(cts, ctype_cid(ctp->info)); /* Element size. */ + if (sz == CTSIZE_INVALID) + return 0; + pp += idx*(int32_t)sz; /* Compute pointer + index. */ + id = lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(ctp->info)), + CTSIZE_PTR); + cd = lj_cdata_new(cts, id, CTSIZE_PTR); + *(uint8_t **)cdataptr(cd) = pp; + setcdataV(L, L->top-1, cd); + lj_gc_check(L); + return 1; +} + +/* 64 bit integer arithmetic. */ +static int carith_int64(lua_State *L, CTState *cts, CDArith *ca, MMS mm) +{ + if (ctype_isnum(ca->ct[0]->info) && ca->ct[0]->size <= 8 && + ctype_isnum(ca->ct[1]->info) && ca->ct[1]->size <= 8) { + CTypeID id = (((ca->ct[0]->info & CTF_UNSIGNED) && ca->ct[0]->size == 8) || + ((ca->ct[1]->info & CTF_UNSIGNED) && ca->ct[1]->size == 8)) ? + CTID_UINT64 : CTID_INT64; + CType *ct = ctype_get(cts, id); + GCcdata *cd; + uint64_t u0, u1, *up; + lj_cconv_ct_ct(cts, ct, ca->ct[0], (uint8_t *)&u0, ca->p[0], 0); + if (mm != MM_unm) + lj_cconv_ct_ct(cts, ct, ca->ct[1], (uint8_t *)&u1, ca->p[1], 0); + switch (mm) { + case MM_eq: + setboolV(L->top-1, (u0 == u1)); + return 1; + case MM_lt: + setboolV(L->top-1, + id == CTID_INT64 ? ((int64_t)u0 < (int64_t)u1) : (u0 < u1)); + return 1; + case MM_le: + setboolV(L->top-1, + id == CTID_INT64 ? ((int64_t)u0 <= (int64_t)u1) : (u0 <= u1)); + return 1; + default: break; + } + cd = lj_cdata_new(cts, id, 8); + up = (uint64_t *)cdataptr(cd); + setcdataV(L, L->top-1, cd); + switch (mm) { + case MM_add: *up = u0 + u1; break; + case MM_sub: *up = u0 - u1; break; + case MM_mul: *up = u0 * u1; break; + case MM_div: + if (id == CTID_INT64) + *up = (uint64_t)lj_carith_divi64((int64_t)u0, (int64_t)u1); + else + *up = lj_carith_divu64(u0, u1); + break; + case MM_mod: + if (id == CTID_INT64) + *up = (uint64_t)lj_carith_modi64((int64_t)u0, (int64_t)u1); + else + *up = lj_carith_modu64(u0, u1); + break; + case MM_pow: + if (id == CTID_INT64) + *up = (uint64_t)lj_carith_powi64((int64_t)u0, (int64_t)u1); + else + *up = lj_carith_powu64(u0, u1); + break; + case MM_unm: *up = (uint64_t)-(int64_t)u0; break; + default: lua_assert(0); break; + } + lj_gc_check(L); + return 1; + } + return 0; +} + +/* Handle ctype arithmetic metamethods. */ +static int lj_carith_meta(lua_State *L, CTState *cts, CDArith *ca, MMS mm) +{ + cTValue *tv = NULL; + if (tviscdata(L->base)) { + CTypeID id = cdataV(L->base)->ctypeid; + CType *ct = ctype_raw(cts, id); + if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); + tv = lj_ctype_meta(cts, id, mm); + } + if (!tv && L->base+1 < L->top && tviscdata(L->base+1)) { + CTypeID id = cdataV(L->base+1)->ctypeid; + CType *ct = ctype_raw(cts, id); + if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); + tv = lj_ctype_meta(cts, id, mm); + } + if (!tv) { + const char *repr[2]; + int i, isenum = -1, isstr = -1; + if (mm == MM_eq) { /* Equality checks never raise an error. */ + int eq = ca->p[0] == ca->p[1]; + setboolV(L->top-1, eq); + setboolV(&G(L)->tmptv2, eq); /* Remember for trace recorder. */ + return 1; + } + for (i = 0; i < 2; i++) { + if (ca->ct[i] && tviscdata(L->base+i)) { + if (ctype_isenum(ca->ct[i]->info)) isenum = i; + repr[i] = strdata(lj_ctype_repr(L, ctype_typeid(cts, ca->ct[i]), NULL)); + } else { + if (tvisstr(&L->base[i])) isstr = i; + repr[i] = lj_typename(&L->base[i]); + } + } + if ((isenum ^ isstr) == 1) + lj_err_callerv(L, LJ_ERR_FFI_BADCONV, repr[isstr], repr[isenum]); + lj_err_callerv(L, mm == MM_len ? LJ_ERR_FFI_BADLEN : + mm == MM_concat ? LJ_ERR_FFI_BADCONCAT : + mm < MM_add ? LJ_ERR_FFI_BADCOMP : LJ_ERR_FFI_BADARITH, + repr[0], repr[1]); + } + return lj_meta_tailcall(L, tv); +} + +/* Arithmetic operators for cdata. */ +int lj_carith_op(lua_State *L, MMS mm) +{ + CTState *cts = ctype_cts(L); + CDArith ca; + if (carith_checkarg(L, cts, &ca)) { + if (carith_int64(L, cts, &ca, mm) || carith_ptr(L, cts, &ca, mm)) { + copyTV(L, &G(L)->tmptv2, L->top-1); /* Remember for trace recorder. */ + return 1; + } + } + return lj_carith_meta(L, cts, &ca, mm); +} + +/* -- 64 bit integer arithmetic helpers ----------------------------------- */ + +#if LJ_32 && LJ_HASJIT +/* Signed/unsigned 64 bit multiplication. */ +int64_t lj_carith_mul64(int64_t a, int64_t b) +{ + return a * b; +} +#endif + +/* Unsigned 64 bit division. */ +uint64_t lj_carith_divu64(uint64_t a, uint64_t b) +{ + if (b == 0) return U64x(80000000,00000000); + return a / b; +} + +/* Signed 64 bit division. */ +int64_t lj_carith_divi64(int64_t a, int64_t b) +{ + if (b == 0 || (a == (int64_t)U64x(80000000,00000000) && b == -1)) + return U64x(80000000,00000000); + return a / b; +} + +/* Unsigned 64 bit modulo. */ +uint64_t lj_carith_modu64(uint64_t a, uint64_t b) +{ + if (b == 0) return U64x(80000000,00000000); + return a % b; +} + +/* Signed 64 bit modulo. */ +int64_t lj_carith_modi64(int64_t a, int64_t b) +{ + if (b == 0) return U64x(80000000,00000000); + if (a == (int64_t)U64x(80000000,00000000) && b == -1) return 0; + return a % b; +} + +/* Unsigned 64 bit x^k. */ +uint64_t lj_carith_powu64(uint64_t x, uint64_t k) +{ + uint64_t y; + if (k == 0) + return 1; + for (; (k & 1) == 0; k >>= 1) x *= x; + y = x; + if ((k >>= 1) != 0) { + for (;;) { + x *= x; + if (k == 1) break; + if (k & 1) y *= x; + k >>= 1; + } + y *= x; + } + return y; +} + +/* Signed 64 bit x^k. */ +int64_t lj_carith_powi64(int64_t x, int64_t k) +{ + if (k == 0) + return 1; + if (k < 0) { + if (x == 0) + return U64x(7fffffff,ffffffff); + else if (x == 1) + return 1; + else if (x == -1) + return (k & 1) ? -1 : 1; + else + return 0; + } + return (int64_t)lj_carith_powu64((uint64_t)x, (uint64_t)k); +} + +#endif + +``` + +`include/luajit-2.0.5/src/lj_carith.h`: + +```h +/* +** C data arithmetic. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CARITH_H +#define _LJ_CARITH_H + +#include "lj_obj.h" + +#if LJ_HASFFI + +LJ_FUNC int lj_carith_op(lua_State *L, MMS mm); + +#if LJ_32 && LJ_HASJIT +LJ_FUNC int64_t lj_carith_mul64(int64_t x, int64_t k); +#endif +LJ_FUNC uint64_t lj_carith_divu64(uint64_t a, uint64_t b); +LJ_FUNC int64_t lj_carith_divi64(int64_t a, int64_t b); +LJ_FUNC uint64_t lj_carith_modu64(uint64_t a, uint64_t b); +LJ_FUNC int64_t lj_carith_modi64(int64_t a, int64_t b); +LJ_FUNC uint64_t lj_carith_powu64(uint64_t x, uint64_t k); +LJ_FUNC int64_t lj_carith_powi64(int64_t x, int64_t k); + +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_ccall.c`: + +```c +/* +** FFI C call handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_ctype.h" +#include "lj_cconv.h" +#include "lj_cdata.h" +#include "lj_ccall.h" +#include "lj_trace.h" + +/* Target-specific handling of register arguments. */ +#if LJ_TARGET_X86 +/* -- x86 calling conventions --------------------------------------------- */ + +#if LJ_ABI_WIN + +#define CCALL_HANDLE_STRUCTRET \ + /* Return structs bigger than 8 by reference (on stack only). */ \ + cc->retref = (sz > 8); \ + if (cc->retref) cc->stack[nsp++] = (GPRArg)dp; + +#define CCALL_HANDLE_COMPLEXRET CCALL_HANDLE_STRUCTRET + +#else + +#if LJ_TARGET_OSX + +#define CCALL_HANDLE_STRUCTRET \ + /* Return structs of size 1, 2, 4 or 8 in registers. */ \ + cc->retref = !(sz == 1 || sz == 2 || sz == 4 || sz == 8); \ + if (cc->retref) { \ + if (ngpr < maxgpr) \ + cc->gpr[ngpr++] = (GPRArg)dp; \ + else \ + cc->stack[nsp++] = (GPRArg)dp; \ + } else { /* Struct with single FP field ends up in FPR. */ \ + cc->resx87 = ccall_classify_struct(cts, ctr); \ + } + +#define CCALL_HANDLE_STRUCTRET2 \ + if (cc->resx87) sp = (uint8_t *)&cc->fpr[0]; \ + memcpy(dp, sp, ctr->size); + +#else + +#define CCALL_HANDLE_STRUCTRET \ + cc->retref = 1; /* Return all structs by reference (in reg or on stack). */ \ + if (ngpr < maxgpr) \ + cc->gpr[ngpr++] = (GPRArg)dp; \ + else \ + cc->stack[nsp++] = (GPRArg)dp; + +#endif + +#define CCALL_HANDLE_COMPLEXRET \ + /* Return complex float in GPRs and complex double by reference. */ \ + cc->retref = (sz > 8); \ + if (cc->retref) { \ + if (ngpr < maxgpr) \ + cc->gpr[ngpr++] = (GPRArg)dp; \ + else \ + cc->stack[nsp++] = (GPRArg)dp; \ + } + +#endif + +#define CCALL_HANDLE_COMPLEXRET2 \ + if (!cc->retref) \ + *(int64_t *)dp = *(int64_t *)sp; /* Copy complex float from GPRs. */ + +#define CCALL_HANDLE_STRUCTARG \ + ngpr = maxgpr; /* Pass all structs by value on the stack. */ + +#define CCALL_HANDLE_COMPLEXARG \ + isfp = 1; /* Pass complex by value on stack. */ + +#define CCALL_HANDLE_REGARG \ + if (!isfp) { /* Only non-FP values may be passed in registers. */ \ + if (n > 1) { /* Anything > 32 bit is passed on the stack. */ \ + if (!LJ_ABI_WIN) ngpr = maxgpr; /* Prevent reordering. */ \ + } else if (ngpr + 1 <= maxgpr) { \ + dp = &cc->gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } \ + } + +#elif LJ_TARGET_X64 && LJ_ABI_WIN +/* -- Windows/x64 calling conventions ------------------------------------- */ + +#define CCALL_HANDLE_STRUCTRET \ + /* Return structs of size 1, 2, 4 or 8 in a GPR. */ \ + cc->retref = !(sz == 1 || sz == 2 || sz == 4 || sz == 8); \ + if (cc->retref) cc->gpr[ngpr++] = (GPRArg)dp; + +#define CCALL_HANDLE_COMPLEXRET CCALL_HANDLE_STRUCTRET + +#define CCALL_HANDLE_COMPLEXRET2 \ + if (!cc->retref) \ + *(int64_t *)dp = *(int64_t *)sp; /* Copy complex float from GPRs. */ + +#define CCALL_HANDLE_STRUCTARG \ + /* Pass structs of size 1, 2, 4 or 8 in a GPR by value. */ \ + if (!(sz == 1 || sz == 2 || sz == 4 || sz == 8)) { \ + rp = cdataptr(lj_cdata_new(cts, did, sz)); \ + sz = CTSIZE_PTR; /* Pass all other structs by reference. */ \ + } + +#define CCALL_HANDLE_COMPLEXARG \ + /* Pass complex float in a GPR and complex double by reference. */ \ + if (sz != 2*sizeof(float)) { \ + rp = cdataptr(lj_cdata_new(cts, did, sz)); \ + sz = CTSIZE_PTR; \ + } + +/* Windows/x64 argument registers are strictly positional (use ngpr). */ +#define CCALL_HANDLE_REGARG \ + if (isfp) { \ + if (ngpr < maxgpr) { dp = &cc->fpr[ngpr++]; nfpr = ngpr; goto done; } \ + } else { \ + if (ngpr < maxgpr) { dp = &cc->gpr[ngpr++]; goto done; } \ + } + +#elif LJ_TARGET_X64 +/* -- POSIX/x64 calling conventions --------------------------------------- */ + +#define CCALL_HANDLE_STRUCTRET \ + int rcl[2]; rcl[0] = rcl[1] = 0; \ + if (ccall_classify_struct(cts, ctr, rcl, 0)) { \ + cc->retref = 1; /* Return struct by reference. */ \ + cc->gpr[ngpr++] = (GPRArg)dp; \ + } else { \ + cc->retref = 0; /* Return small structs in registers. */ \ + } + +#define CCALL_HANDLE_STRUCTRET2 \ + int rcl[2]; rcl[0] = rcl[1] = 0; \ + ccall_classify_struct(cts, ctr, rcl, 0); \ + ccall_struct_ret(cc, rcl, dp, ctr->size); + +#define CCALL_HANDLE_COMPLEXRET \ + /* Complex values are returned in one or two FPRs. */ \ + cc->retref = 0; + +#define CCALL_HANDLE_COMPLEXRET2 \ + if (ctr->size == 2*sizeof(float)) { /* Copy complex float from FPR. */ \ + *(int64_t *)dp = cc->fpr[0].l[0]; \ + } else { /* Copy non-contiguous complex double from FPRs. */ \ + ((int64_t *)dp)[0] = cc->fpr[0].l[0]; \ + ((int64_t *)dp)[1] = cc->fpr[1].l[0]; \ + } + +#define CCALL_HANDLE_STRUCTARG \ + int rcl[2]; rcl[0] = rcl[1] = 0; \ + if (!ccall_classify_struct(cts, d, rcl, 0)) { \ + cc->nsp = nsp; cc->ngpr = ngpr; cc->nfpr = nfpr; \ + if (ccall_struct_arg(cc, cts, d, rcl, o, narg)) goto err_nyi; \ + nsp = cc->nsp; ngpr = cc->ngpr; nfpr = cc->nfpr; \ + continue; \ + } /* Pass all other structs by value on stack. */ + +#define CCALL_HANDLE_COMPLEXARG \ + isfp = 2; /* Pass complex in FPRs or on stack. Needs postprocessing. */ + +#define CCALL_HANDLE_REGARG \ + if (isfp) { /* Try to pass argument in FPRs. */ \ + int n2 = ctype_isvector(d->info) ? 1 : n; \ + if (nfpr + n2 <= CCALL_NARG_FPR) { \ + dp = &cc->fpr[nfpr]; \ + nfpr += n2; \ + goto done; \ + } \ + } else { /* Try to pass argument in GPRs. */ \ + /* Note that reordering is explicitly allowed in the x64 ABI. */ \ + if (n <= 2 && ngpr + n <= maxgpr) { \ + dp = &cc->gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } \ + } + +#elif LJ_TARGET_ARM +/* -- ARM calling conventions --------------------------------------------- */ + +#if LJ_ABI_SOFTFP + +#define CCALL_HANDLE_STRUCTRET \ + /* Return structs of size <= 4 in a GPR. */ \ + cc->retref = !(sz <= 4); \ + if (cc->retref) cc->gpr[ngpr++] = (GPRArg)dp; + +#define CCALL_HANDLE_COMPLEXRET \ + cc->retref = 1; /* Return all complex values by reference. */ \ + cc->gpr[ngpr++] = (GPRArg)dp; + +#define CCALL_HANDLE_COMPLEXRET2 \ + UNUSED(dp); /* Nothing to do. */ + +#define CCALL_HANDLE_STRUCTARG \ + /* Pass all structs by value in registers and/or on the stack. */ + +#define CCALL_HANDLE_COMPLEXARG \ + /* Pass complex by value in 2 or 4 GPRs. */ + +#define CCALL_HANDLE_REGARG_FP1 +#define CCALL_HANDLE_REGARG_FP2 + +#else + +#define CCALL_HANDLE_STRUCTRET \ + cc->retref = !ccall_classify_struct(cts, ctr, ct); \ + if (cc->retref) cc->gpr[ngpr++] = (GPRArg)dp; + +#define CCALL_HANDLE_STRUCTRET2 \ + if (ccall_classify_struct(cts, ctr, ct) > 1) sp = (uint8_t *)&cc->fpr[0]; \ + memcpy(dp, sp, ctr->size); + +#define CCALL_HANDLE_COMPLEXRET \ + if (!(ct->info & CTF_VARARG)) cc->retref = 0; /* Return complex in FPRs. */ + +#define CCALL_HANDLE_COMPLEXRET2 \ + if (!(ct->info & CTF_VARARG)) memcpy(dp, &cc->fpr[0], ctr->size); + +#define CCALL_HANDLE_STRUCTARG \ + isfp = (ccall_classify_struct(cts, d, ct) > 1); + /* Pass all structs by value in registers and/or on the stack. */ + +#define CCALL_HANDLE_COMPLEXARG \ + isfp = 1; /* Pass complex by value in FPRs or on stack. */ + +#define CCALL_HANDLE_REGARG_FP1 \ + if (isfp && !(ct->info & CTF_VARARG)) { \ + if ((d->info & CTF_ALIGN) > CTALIGN_PTR) { \ + if (nfpr + (n >> 1) <= CCALL_NARG_FPR) { \ + dp = &cc->fpr[nfpr]; \ + nfpr += (n >> 1); \ + goto done; \ + } \ + } else { \ + if (sz > 1 && fprodd != nfpr) fprodd = 0; \ + if (fprodd) { \ + if (2*nfpr+n <= 2*CCALL_NARG_FPR+1) { \ + dp = (void *)&cc->fpr[fprodd-1].f[1]; \ + nfpr += (n >> 1); \ + if ((n & 1)) fprodd = 0; else fprodd = nfpr-1; \ + goto done; \ + } \ + } else { \ + if (2*nfpr+n <= 2*CCALL_NARG_FPR) { \ + dp = (void *)&cc->fpr[nfpr]; \ + nfpr += (n >> 1); \ + if ((n & 1)) fprodd = ++nfpr; else fprodd = 0; \ + goto done; \ + } \ + } \ + } \ + fprodd = 0; /* No reordering after the first FP value is on stack. */ \ + } else { + +#define CCALL_HANDLE_REGARG_FP2 } + +#endif + +#define CCALL_HANDLE_REGARG \ + CCALL_HANDLE_REGARG_FP1 \ + if ((d->info & CTF_ALIGN) > CTALIGN_PTR) { \ + if (ngpr < maxgpr) \ + ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ + } \ + if (ngpr < maxgpr) { \ + dp = &cc->gpr[ngpr]; \ + if (ngpr + n > maxgpr) { \ + nsp += ngpr + n - maxgpr; /* Assumes contiguous gpr/stack fields. */ \ + if (nsp > CCALL_MAXSTACK) goto err_nyi; /* Too many arguments. */ \ + ngpr = maxgpr; \ + } else { \ + ngpr += n; \ + } \ + goto done; \ + } CCALL_HANDLE_REGARG_FP2 + +#define CCALL_HANDLE_RET \ + if ((ct->info & CTF_VARARG)) sp = (uint8_t *)&cc->gpr[0]; + +#elif LJ_TARGET_PPC +/* -- PPC calling conventions --------------------------------------------- */ + +#define CCALL_HANDLE_STRUCTRET \ + cc->retref = 1; /* Return all structs by reference. */ \ + cc->gpr[ngpr++] = (GPRArg)dp; + +#define CCALL_HANDLE_COMPLEXRET \ + /* Complex values are returned in 2 or 4 GPRs. */ \ + cc->retref = 0; + +#define CCALL_HANDLE_COMPLEXRET2 \ + memcpy(dp, sp, ctr->size); /* Copy complex from GPRs. */ + +#define CCALL_HANDLE_STRUCTARG \ + rp = cdataptr(lj_cdata_new(cts, did, sz)); \ + sz = CTSIZE_PTR; /* Pass all structs by reference. */ + +#define CCALL_HANDLE_COMPLEXARG \ + /* Pass complex by value in 2 or 4 GPRs. */ + +#define CCALL_HANDLE_REGARG \ + if (isfp) { /* Try to pass argument in FPRs. */ \ + if (nfpr + 1 <= CCALL_NARG_FPR) { \ + dp = &cc->fpr[nfpr]; \ + nfpr += 1; \ + d = ctype_get(cts, CTID_DOUBLE); /* FPRs always hold doubles. */ \ + goto done; \ + } \ + } else { /* Try to pass argument in GPRs. */ \ + if (n > 1) { \ + lua_assert(n == 2 || n == 4); /* int64_t or complex (float). */ \ + if (ctype_isinteger(d->info)) \ + ngpr = (ngpr + 1u) & ~1u; /* Align int64_t to regpair. */ \ + else if (ngpr + n > maxgpr) \ + ngpr = maxgpr; /* Prevent reordering. */ \ + } \ + if (ngpr + n <= maxgpr) { \ + dp = &cc->gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } \ + } + +#define CCALL_HANDLE_RET \ + if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ + ctr = ctype_get(cts, CTID_DOUBLE); /* FPRs always hold doubles. */ + +#elif LJ_TARGET_PPCSPE +/* -- PPC/SPE calling conventions ----------------------------------------- */ + +#define CCALL_HANDLE_STRUCTRET \ + cc->retref = 1; /* Return all structs by reference. */ \ + cc->gpr[ngpr++] = (GPRArg)dp; + +#define CCALL_HANDLE_COMPLEXRET \ + /* Complex values are returned in 2 or 4 GPRs. */ \ + cc->retref = 0; + +#define CCALL_HANDLE_COMPLEXRET2 \ + memcpy(dp, sp, ctr->size); /* Copy complex from GPRs. */ + +#define CCALL_HANDLE_STRUCTARG \ + rp = cdataptr(lj_cdata_new(cts, did, sz)); \ + sz = CTSIZE_PTR; /* Pass all structs by reference. */ + +#define CCALL_HANDLE_COMPLEXARG \ + /* Pass complex by value in 2 or 4 GPRs. */ + +/* PPC/SPE has a softfp ABI. */ +#define CCALL_HANDLE_REGARG \ + if (n > 1) { /* Doesn't fit in a single GPR? */ \ + lua_assert(n == 2 || n == 4); /* int64_t, double or complex (float). */ \ + if (n == 2) \ + ngpr = (ngpr + 1u) & ~1u; /* Only align 64 bit value to regpair. */ \ + else if (ngpr + n > maxgpr) \ + ngpr = maxgpr; /* Prevent reordering. */ \ + } \ + if (ngpr + n <= maxgpr) { \ + dp = &cc->gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } + +#elif LJ_TARGET_MIPS +/* -- MIPS calling conventions -------------------------------------------- */ + +#define CCALL_HANDLE_STRUCTRET \ + cc->retref = 1; /* Return all structs by reference. */ \ + cc->gpr[ngpr++] = (GPRArg)dp; + +#define CCALL_HANDLE_COMPLEXRET \ + /* Complex values are returned in 1 or 2 FPRs. */ \ + cc->retref = 0; + +#define CCALL_HANDLE_COMPLEXRET2 \ + if (ctr->size == 2*sizeof(float)) { /* Copy complex float from FPRs. */ \ + ((float *)dp)[0] = cc->fpr[0].f; \ + ((float *)dp)[1] = cc->fpr[1].f; \ + } else { /* Copy complex double from FPRs. */ \ + ((double *)dp)[0] = cc->fpr[0].d; \ + ((double *)dp)[1] = cc->fpr[1].d; \ + } + +#define CCALL_HANDLE_STRUCTARG \ + /* Pass all structs by value in registers and/or on the stack. */ + +#define CCALL_HANDLE_COMPLEXARG \ + /* Pass complex by value in 2 or 4 GPRs. */ + +#define CCALL_HANDLE_REGARG \ + if (isfp && nfpr < CCALL_NARG_FPR && !(ct->info & CTF_VARARG)) { \ + /* Try to pass argument in FPRs. */ \ + dp = n == 1 ? (void *)&cc->fpr[nfpr].f : (void *)&cc->fpr[nfpr].d; \ + nfpr++; ngpr += n; \ + goto done; \ + } else { /* Try to pass argument in GPRs. */ \ + nfpr = CCALL_NARG_FPR; \ + if ((d->info & CTF_ALIGN) > CTALIGN_PTR) \ + ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ + if (ngpr < maxgpr) { \ + dp = &cc->gpr[ngpr]; \ + if (ngpr + n > maxgpr) { \ + nsp += ngpr + n - maxgpr; /* Assumes contiguous gpr/stack fields. */ \ + if (nsp > CCALL_MAXSTACK) goto err_nyi; /* Too many arguments. */ \ + ngpr = maxgpr; \ + } else { \ + ngpr += n; \ + } \ + goto done; \ + } \ + } + +#define CCALL_HANDLE_RET \ + if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ + sp = (uint8_t *)&cc->fpr[0].f; + +#else +#error "Missing calling convention definitions for this architecture" +#endif + +#ifndef CCALL_HANDLE_STRUCTRET2 +#define CCALL_HANDLE_STRUCTRET2 \ + memcpy(dp, sp, ctr->size); /* Copy struct return value from GPRs. */ +#endif + +/* -- x86 OSX ABI struct classification ----------------------------------- */ + +#if LJ_TARGET_X86 && LJ_TARGET_OSX + +/* Check for struct with single FP field. */ +static int ccall_classify_struct(CTState *cts, CType *ct) +{ + CTSize sz = ct->size; + if (!(sz == sizeof(float) || sz == sizeof(double))) return 0; + if ((ct->info & CTF_UNION)) return 0; + while (ct->sib) { + ct = ctype_get(cts, ct->sib); + if (ctype_isfield(ct->info)) { + CType *sct = ctype_rawchild(cts, ct); + if (ctype_isfp(sct->info)) { + if (sct->size == sz) + return (sz >> 2); /* Return 1 for float or 2 for double. */ + } else if (ctype_isstruct(sct->info)) { + if (sct->size) + return ccall_classify_struct(cts, sct); + } else { + break; + } + } else if (ctype_isbitfield(ct->info)) { + break; + } else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) { + CType *sct = ctype_rawchild(cts, ct); + if (sct->size) + return ccall_classify_struct(cts, sct); + } + } + return 0; +} + +#endif + +/* -- x64 struct classification ------------------------------------------- */ + +#if LJ_TARGET_X64 && !LJ_ABI_WIN + +/* Register classes for x64 struct classification. */ +#define CCALL_RCL_INT 1 +#define CCALL_RCL_SSE 2 +#define CCALL_RCL_MEM 4 +/* NYI: classify vectors. */ + +static int ccall_classify_struct(CTState *cts, CType *ct, int *rcl, CTSize ofs); + +/* Classify a C type. */ +static void ccall_classify_ct(CTState *cts, CType *ct, int *rcl, CTSize ofs) +{ + if (ctype_isarray(ct->info)) { + CType *cct = ctype_rawchild(cts, ct); + CTSize eofs, esz = cct->size, asz = ct->size; + for (eofs = 0; eofs < asz; eofs += esz) + ccall_classify_ct(cts, cct, rcl, ofs+eofs); + } else if (ctype_isstruct(ct->info)) { + ccall_classify_struct(cts, ct, rcl, ofs); + } else { + int cl = ctype_isfp(ct->info) ? CCALL_RCL_SSE : CCALL_RCL_INT; + lua_assert(ctype_hassize(ct->info)); + if ((ofs & (ct->size-1))) cl = CCALL_RCL_MEM; /* Unaligned. */ + rcl[(ofs >= 8)] |= cl; + } +} + +/* Recursively classify a struct based on its fields. */ +static int ccall_classify_struct(CTState *cts, CType *ct, int *rcl, CTSize ofs) +{ + if (ct->size > 16) return CCALL_RCL_MEM; /* Too big, gets memory class. */ + while (ct->sib) { + CTSize fofs; + ct = ctype_get(cts, ct->sib); + fofs = ofs+ct->size; + if (ctype_isfield(ct->info)) + ccall_classify_ct(cts, ctype_rawchild(cts, ct), rcl, fofs); + else if (ctype_isbitfield(ct->info)) + rcl[(fofs >= 8)] |= CCALL_RCL_INT; /* NYI: unaligned bitfields? */ + else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) + ccall_classify_struct(cts, ctype_rawchild(cts, ct), rcl, fofs); + } + return ((rcl[0]|rcl[1]) & CCALL_RCL_MEM); /* Memory class? */ +} + +/* Try to split up a small struct into registers. */ +static int ccall_struct_reg(CCallState *cc, GPRArg *dp, int *rcl) +{ + MSize ngpr = cc->ngpr, nfpr = cc->nfpr; + uint32_t i; + for (i = 0; i < 2; i++) { + lua_assert(!(rcl[i] & CCALL_RCL_MEM)); + if ((rcl[i] & CCALL_RCL_INT)) { /* Integer class takes precedence. */ + if (ngpr >= CCALL_NARG_GPR) return 1; /* Register overflow. */ + cc->gpr[ngpr++] = dp[i]; + } else if ((rcl[i] & CCALL_RCL_SSE)) { + if (nfpr >= CCALL_NARG_FPR) return 1; /* Register overflow. */ + cc->fpr[nfpr++].l[0] = dp[i]; + } + } + cc->ngpr = ngpr; cc->nfpr = nfpr; + return 0; /* Ok. */ +} + +/* Pass a small struct argument. */ +static int ccall_struct_arg(CCallState *cc, CTState *cts, CType *d, int *rcl, + TValue *o, int narg) +{ + GPRArg dp[2]; + dp[0] = dp[1] = 0; + /* Convert to temp. struct. */ + lj_cconv_ct_tv(cts, d, (uint8_t *)dp, o, CCF_ARG(narg)); + if (ccall_struct_reg(cc, dp, rcl)) { /* Register overflow? Pass on stack. */ + MSize nsp = cc->nsp, n = rcl[1] ? 2 : 1; + if (nsp + n > CCALL_MAXSTACK) return 1; /* Too many arguments. */ + cc->nsp = nsp + n; + memcpy(&cc->stack[nsp], dp, n*CTSIZE_PTR); + } + return 0; /* Ok. */ +} + +/* Combine returned small struct. */ +static void ccall_struct_ret(CCallState *cc, int *rcl, uint8_t *dp, CTSize sz) +{ + GPRArg sp[2]; + MSize ngpr = 0, nfpr = 0; + uint32_t i; + for (i = 0; i < 2; i++) { + if ((rcl[i] & CCALL_RCL_INT)) { /* Integer class takes precedence. */ + sp[i] = cc->gpr[ngpr++]; + } else if ((rcl[i] & CCALL_RCL_SSE)) { + sp[i] = cc->fpr[nfpr++].l[0]; + } + } + memcpy(dp, sp, sz); +} +#endif + +/* -- ARM hard-float ABI struct classification ---------------------------- */ + +#if LJ_TARGET_ARM && !LJ_ABI_SOFTFP + +/* Classify a struct based on its fields. */ +static unsigned int ccall_classify_struct(CTState *cts, CType *ct, CType *ctf) +{ + CTSize sz = ct->size; + unsigned int r = 0, n = 0, isu = (ct->info & CTF_UNION); + if ((ctf->info & CTF_VARARG)) goto noth; + while (ct->sib) { + CType *sct; + ct = ctype_get(cts, ct->sib); + if (ctype_isfield(ct->info)) { + sct = ctype_rawchild(cts, ct); + if (ctype_isfp(sct->info)) { + r |= sct->size; + if (!isu) n++; else if (n == 0) n = 1; + } else if (ctype_iscomplex(sct->info)) { + r |= (sct->size >> 1); + if (!isu) n += 2; else if (n < 2) n = 2; + } else if (ctype_isstruct(sct->info)) { + goto substruct; + } else { + goto noth; + } + } else if (ctype_isbitfield(ct->info)) { + goto noth; + } else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) { + sct = ctype_rawchild(cts, ct); + substruct: + if (sct->size > 0) { + unsigned int s = ccall_classify_struct(cts, sct, ctf); + if (s <= 1) goto noth; + r |= (s & 255); + if (!isu) n += (s >> 8); else if (n < (s >>8)) n = (s >> 8); + } + } + } + if ((r == 4 || r == 8) && n <= 4) + return r + (n << 8); +noth: /* Not a homogeneous float/double aggregate. */ + return (sz <= 4); /* Return structs of size <= 4 in a GPR. */ +} + +#endif + +/* -- Common C call handling ---------------------------------------------- */ + +/* Infer the destination CTypeID for a vararg argument. */ +CTypeID lj_ccall_ctid_vararg(CTState *cts, cTValue *o) +{ + if (tvisnumber(o)) { + return CTID_DOUBLE; + } else if (tviscdata(o)) { + CTypeID id = cdataV(o)->ctypeid; + CType *s = ctype_get(cts, id); + if (ctype_isrefarray(s->info)) { + return lj_ctype_intern(cts, + CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(s->info)), CTSIZE_PTR); + } else if (ctype_isstruct(s->info) || ctype_isfunc(s->info)) { + /* NYI: how to pass a struct by value in a vararg argument? */ + return lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR); + } else if (ctype_isfp(s->info) && s->size == sizeof(float)) { + return CTID_DOUBLE; + } else { + return id; + } + } else if (tvisstr(o)) { + return CTID_P_CCHAR; + } else if (tvisbool(o)) { + return CTID_BOOL; + } else { + return CTID_P_VOID; + } +} + +/* Setup arguments for C call. */ +static int ccall_set_args(lua_State *L, CTState *cts, CType *ct, + CCallState *cc) +{ + int gcsteps = 0; + TValue *o, *top = L->top; + CTypeID fid; + CType *ctr; + MSize maxgpr, ngpr = 0, nsp = 0, narg; +#if CCALL_NARG_FPR + MSize nfpr = 0; +#if LJ_TARGET_ARM + MSize fprodd = 0; +#endif +#endif + + /* Clear unused regs to get some determinism in case of misdeclaration. */ + memset(cc->gpr, 0, sizeof(cc->gpr)); +#if CCALL_NUM_FPR + memset(cc->fpr, 0, sizeof(cc->fpr)); +#endif + +#if LJ_TARGET_X86 + /* x86 has several different calling conventions. */ + cc->resx87 = 0; + switch (ctype_cconv(ct->info)) { + case CTCC_FASTCALL: maxgpr = 2; break; + case CTCC_THISCALL: maxgpr = 1; break; + default: maxgpr = 0; break; + } +#else + maxgpr = CCALL_NARG_GPR; +#endif + + /* Perform required setup for some result types. */ + ctr = ctype_rawchild(cts, ct); + if (ctype_isvector(ctr->info)) { + if (!(CCALL_VECTOR_REG && (ctr->size == 8 || ctr->size == 16))) + goto err_nyi; + } else if (ctype_iscomplex(ctr->info) || ctype_isstruct(ctr->info)) { + /* Preallocate cdata object and anchor it after arguments. */ + CTSize sz = ctr->size; + GCcdata *cd = lj_cdata_new(cts, ctype_cid(ct->info), sz); + void *dp = cdataptr(cd); + setcdataV(L, L->top++, cd); + if (ctype_isstruct(ctr->info)) { + CCALL_HANDLE_STRUCTRET + } else { + CCALL_HANDLE_COMPLEXRET + } +#if LJ_TARGET_X86 + } else if (ctype_isfp(ctr->info)) { + cc->resx87 = ctr->size == sizeof(float) ? 1 : 2; +#endif + } + + /* Skip initial attributes. */ + fid = ct->sib; + while (fid) { + CType *ctf = ctype_get(cts, fid); + if (!ctype_isattrib(ctf->info)) break; + fid = ctf->sib; + } + + /* Walk through all passed arguments. */ + for (o = L->base+1, narg = 1; o < top; o++, narg++) { + CTypeID did; + CType *d; + CTSize sz; + MSize n, isfp = 0, isva = 0; + void *dp, *rp = NULL; + + if (fid) { /* Get argument type from field. */ + CType *ctf = ctype_get(cts, fid); + fid = ctf->sib; + lua_assert(ctype_isfield(ctf->info)); + did = ctype_cid(ctf->info); + } else { + if (!(ct->info & CTF_VARARG)) + lj_err_caller(L, LJ_ERR_FFI_NUMARG); /* Too many arguments. */ + did = lj_ccall_ctid_vararg(cts, o); /* Infer vararg type. */ + isva = 1; + } + d = ctype_raw(cts, did); + sz = d->size; + + /* Find out how (by value/ref) and where (GPR/FPR) to pass an argument. */ + if (ctype_isnum(d->info)) { + if (sz > 8) goto err_nyi; + if ((d->info & CTF_FP)) + isfp = 1; + } else if (ctype_isvector(d->info)) { + if (CCALL_VECTOR_REG && (sz == 8 || sz == 16)) + isfp = 1; + else + goto err_nyi; + } else if (ctype_isstruct(d->info)) { + CCALL_HANDLE_STRUCTARG + } else if (ctype_iscomplex(d->info)) { + CCALL_HANDLE_COMPLEXARG + } else { + sz = CTSIZE_PTR; + } + sz = (sz + CTSIZE_PTR-1) & ~(CTSIZE_PTR-1); + n = sz / CTSIZE_PTR; /* Number of GPRs or stack slots needed. */ + + CCALL_HANDLE_REGARG /* Handle register arguments. */ + + /* Otherwise pass argument on stack. */ + if (CCALL_ALIGN_STACKARG && !rp && (d->info & CTF_ALIGN) > CTALIGN_PTR) { + MSize align = (1u << ctype_align(d->info-CTALIGN_PTR)) -1; + nsp = (nsp + align) & ~align; /* Align argument on stack. */ + } + if (nsp + n > CCALL_MAXSTACK) { /* Too many arguments. */ + err_nyi: + lj_err_caller(L, LJ_ERR_FFI_NYICALL); + } + dp = &cc->stack[nsp]; + nsp += n; + isva = 0; + + done: + if (rp) { /* Pass by reference. */ + gcsteps++; + *(void **)dp = rp; + dp = rp; + } + lj_cconv_ct_tv(cts, d, (uint8_t *)dp, o, CCF_ARG(narg)); + /* Extend passed integers to 32 bits at least. */ + if (ctype_isinteger_or_bool(d->info) && d->size < 4) { + if (d->info & CTF_UNSIGNED) + *(uint32_t *)dp = d->size == 1 ? (uint32_t)*(uint8_t *)dp : + (uint32_t)*(uint16_t *)dp; + else + *(int32_t *)dp = d->size == 1 ? (int32_t)*(int8_t *)dp : + (int32_t)*(int16_t *)dp; + } +#if LJ_TARGET_X64 && LJ_ABI_WIN + if (isva) { /* Windows/x64 mirrors varargs in both register sets. */ + if (nfpr == ngpr) + cc->gpr[ngpr-1] = cc->fpr[ngpr-1].l[0]; + else + cc->fpr[ngpr-1].l[0] = cc->gpr[ngpr-1]; + } +#else + UNUSED(isva); +#endif +#if LJ_TARGET_X64 && !LJ_ABI_WIN + if (isfp == 2 && n == 2 && (uint8_t *)dp == (uint8_t *)&cc->fpr[nfpr-2]) { + cc->fpr[nfpr-1].d[0] = cc->fpr[nfpr-2].d[1]; /* Split complex double. */ + cc->fpr[nfpr-2].d[1] = 0; + } +#else + UNUSED(isfp); +#endif + } + if (fid) lj_err_caller(L, LJ_ERR_FFI_NUMARG); /* Too few arguments. */ + +#if LJ_TARGET_X64 || LJ_TARGET_PPC + cc->nfpr = nfpr; /* Required for vararg functions. */ +#endif + cc->nsp = nsp; + cc->spadj = (CCALL_SPS_FREE + CCALL_SPS_EXTRA)*CTSIZE_PTR; + if (nsp > CCALL_SPS_FREE) + cc->spadj += (((nsp-CCALL_SPS_FREE)*CTSIZE_PTR + 15u) & ~15u); + return gcsteps; +} + +/* Get results from C call. */ +static int ccall_get_results(lua_State *L, CTState *cts, CType *ct, + CCallState *cc, int *ret) +{ + CType *ctr = ctype_rawchild(cts, ct); + uint8_t *sp = (uint8_t *)&cc->gpr[0]; + if (ctype_isvoid(ctr->info)) { + *ret = 0; /* Zero results. */ + return 0; /* No additional GC step. */ + } + *ret = 1; /* One result. */ + if (ctype_isstruct(ctr->info)) { + /* Return cdata object which is already on top of stack. */ + if (!cc->retref) { + void *dp = cdataptr(cdataV(L->top-1)); /* Use preallocated object. */ + CCALL_HANDLE_STRUCTRET2 + } + return 1; /* One GC step. */ + } + if (ctype_iscomplex(ctr->info)) { + /* Return cdata object which is already on top of stack. */ + void *dp = cdataptr(cdataV(L->top-1)); /* Use preallocated object. */ + CCALL_HANDLE_COMPLEXRET2 + return 1; /* One GC step. */ + } + if (LJ_BE && ctype_isinteger_or_bool(ctr->info) && ctr->size < CTSIZE_PTR) + sp += (CTSIZE_PTR - ctr->size); +#if CCALL_NUM_FPR + if (ctype_isfp(ctr->info) || ctype_isvector(ctr->info)) + sp = (uint8_t *)&cc->fpr[0]; +#endif +#ifdef CCALL_HANDLE_RET + CCALL_HANDLE_RET +#endif + /* No reference types end up here, so there's no need for the CTypeID. */ + lua_assert(!(ctype_isrefarray(ctr->info) || ctype_isstruct(ctr->info))); + return lj_cconv_tv_ct(cts, ctr, 0, L->top-1, sp); +} + +/* Call C function. */ +int lj_ccall_func(lua_State *L, GCcdata *cd) +{ + CTState *cts = ctype_cts(L); + CType *ct = ctype_raw(cts, cd->ctypeid); + CTSize sz = CTSIZE_PTR; + if (ctype_isptr(ct->info)) { + sz = ct->size; + ct = ctype_rawchild(cts, ct); + } + if (ctype_isfunc(ct->info)) { + CCallState cc; + int gcsteps, ret; + cc.func = (void (*)(void))cdata_getptr(cdataptr(cd), sz); + gcsteps = ccall_set_args(L, cts, ct, &cc); + ct = (CType *)((intptr_t)ct-(intptr_t)cts->tab); + cts->cb.slot = ~0u; + lj_vm_ffi_call(&cc); + if (cts->cb.slot != ~0u) { /* Blacklist function that called a callback. */ + TValue tv; + setlightudV(&tv, (void *)cc.func); + setboolV(lj_tab_set(L, cts->miscmap, &tv), 1); + } + ct = (CType *)((intptr_t)ct+(intptr_t)cts->tab); /* May be reallocated. */ + gcsteps += ccall_get_results(L, cts, ct, &cc, &ret); +#if LJ_TARGET_X86 && LJ_ABI_WIN + /* Automatically detect __stdcall and fix up C function declaration. */ + if (cc.spadj && ctype_cconv(ct->info) == CTCC_CDECL) { + CTF_INSERT(ct->info, CCONV, CTCC_STDCALL); + lj_trace_abort(G(L)); + } +#endif + while (gcsteps-- > 0) + lj_gc_check(L); + return ret; + } + return -1; /* Not a function. */ +} + +#endif + +``` + +`include/luajit-2.0.5/src/lj_ccall.h`: + +```h +/* +** FFI C call handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CCALL_H +#define _LJ_CCALL_H + +#include "lj_obj.h" +#include "lj_ctype.h" + +#if LJ_HASFFI + +/* -- C calling conventions ----------------------------------------------- */ + +#if LJ_TARGET_X86ORX64 + +#if LJ_TARGET_X86 +#define CCALL_NARG_GPR 2 /* For fastcall arguments. */ +#define CCALL_NARG_FPR 0 +#define CCALL_NRET_GPR 2 +#define CCALL_NRET_FPR 1 /* For FP results on x87 stack. */ +#define CCALL_ALIGN_STACKARG 0 /* Don't align argument on stack. */ +#elif LJ_ABI_WIN +#define CCALL_NARG_GPR 4 +#define CCALL_NARG_FPR 4 +#define CCALL_NRET_GPR 1 +#define CCALL_NRET_FPR 1 +#define CCALL_SPS_EXTRA 4 +#else +#define CCALL_NARG_GPR 6 +#define CCALL_NARG_FPR 8 +#define CCALL_NRET_GPR 2 +#define CCALL_NRET_FPR 2 +#define CCALL_VECTOR_REG 1 /* Pass vectors in registers. */ +#endif + +#define CCALL_SPS_FREE 1 +#define CCALL_ALIGN_CALLSTATE 16 + +typedef LJ_ALIGN(16) union FPRArg { + double d[2]; + float f[4]; + uint8_t b[16]; + uint16_t s[8]; + int i[4]; + int64_t l[2]; +} FPRArg; + +typedef intptr_t GPRArg; + +#elif LJ_TARGET_ARM + +#define CCALL_NARG_GPR 4 +#define CCALL_NRET_GPR 2 /* For softfp double. */ +#if LJ_ABI_SOFTFP +#define CCALL_NARG_FPR 0 +#define CCALL_NRET_FPR 0 +#else +#define CCALL_NARG_FPR 8 +#define CCALL_NRET_FPR 4 +#endif +#define CCALL_SPS_FREE 0 + +typedef intptr_t GPRArg; +typedef union FPRArg { + double d; + float f[2]; +} FPRArg; + +#elif LJ_TARGET_PPC + +#define CCALL_NARG_GPR 8 +#define CCALL_NARG_FPR 8 +#define CCALL_NRET_GPR 4 /* For complex double. */ +#define CCALL_NRET_FPR 1 +#define CCALL_SPS_EXTRA 4 +#define CCALL_SPS_FREE 0 + +typedef intptr_t GPRArg; +typedef double FPRArg; + +#elif LJ_TARGET_PPCSPE + +#define CCALL_NARG_GPR 8 +#define CCALL_NARG_FPR 0 +#define CCALL_NRET_GPR 4 /* For softfp complex double. */ +#define CCALL_NRET_FPR 0 +#define CCALL_SPS_FREE 0 /* NYI */ + +typedef intptr_t GPRArg; + +#elif LJ_TARGET_MIPS + +#define CCALL_NARG_GPR 4 +#define CCALL_NARG_FPR 2 +#define CCALL_NRET_GPR 2 +#define CCALL_NRET_FPR 2 +#define CCALL_SPS_EXTRA 7 +#define CCALL_SPS_FREE 1 + +typedef intptr_t GPRArg; +typedef union FPRArg { + double d; + struct { LJ_ENDIAN_LOHI(float f; , float g;) }; +} FPRArg; + +#else +#error "Missing calling convention definitions for this architecture" +#endif + +#ifndef CCALL_SPS_EXTRA +#define CCALL_SPS_EXTRA 0 +#endif +#ifndef CCALL_VECTOR_REG +#define CCALL_VECTOR_REG 0 +#endif +#ifndef CCALL_ALIGN_STACKARG +#define CCALL_ALIGN_STACKARG 1 +#endif +#ifndef CCALL_ALIGN_CALLSTATE +#define CCALL_ALIGN_CALLSTATE 8 +#endif + +#define CCALL_NUM_GPR \ + (CCALL_NARG_GPR > CCALL_NRET_GPR ? CCALL_NARG_GPR : CCALL_NRET_GPR) +#define CCALL_NUM_FPR \ + (CCALL_NARG_FPR > CCALL_NRET_FPR ? CCALL_NARG_FPR : CCALL_NRET_FPR) + +/* Check against constants in lj_ctype.h. */ +LJ_STATIC_ASSERT(CCALL_NUM_GPR <= CCALL_MAX_GPR); +LJ_STATIC_ASSERT(CCALL_NUM_FPR <= CCALL_MAX_FPR); + +#define CCALL_MAXSTACK 32 + +/* -- C call state -------------------------------------------------------- */ + +typedef LJ_ALIGN(CCALL_ALIGN_CALLSTATE) struct CCallState { + void (*func)(void); /* Pointer to called function. */ + uint32_t spadj; /* Stack pointer adjustment. */ + uint8_t nsp; /* Number of stack slots. */ + uint8_t retref; /* Return value by reference. */ +#if LJ_TARGET_X64 + uint8_t ngpr; /* Number of arguments in GPRs. */ + uint8_t nfpr; /* Number of arguments in FPRs. */ +#elif LJ_TARGET_X86 + uint8_t resx87; /* Result on x87 stack: 1:float, 2:double. */ +#elif LJ_TARGET_PPC + uint8_t nfpr; /* Number of arguments in FPRs. */ +#endif +#if LJ_32 + int32_t align1; +#endif +#if CCALL_NUM_FPR + FPRArg fpr[CCALL_NUM_FPR]; /* Arguments/results in FPRs. */ +#endif + GPRArg gpr[CCALL_NUM_GPR]; /* Arguments/results in GPRs. */ + GPRArg stack[CCALL_MAXSTACK]; /* Stack slots. */ +} CCallState; + +/* -- C call handling ----------------------------------------------------- */ + +/* Really belongs to lj_vm.h. */ +LJ_ASMF void LJ_FASTCALL lj_vm_ffi_call(CCallState *cc); + +LJ_FUNC CTypeID lj_ccall_ctid_vararg(CTState *cts, cTValue *o); +LJ_FUNC int lj_ccall_func(lua_State *L, GCcdata *cd); + +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_ccallback.c`: + +```c +/* +** FFI C callback handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_tab.h" +#include "lj_state.h" +#include "lj_frame.h" +#include "lj_ctype.h" +#include "lj_cconv.h" +#include "lj_ccall.h" +#include "lj_ccallback.h" +#include "lj_target.h" +#include "lj_mcode.h" +#include "lj_trace.h" +#include "lj_vm.h" + +/* -- Target-specific handling of callback slots -------------------------- */ + +#define CALLBACK_MCODE_SIZE (LJ_PAGESIZE * LJ_NUM_CBPAGE) + +#if LJ_OS_NOJIT + +/* Disabled callback support. */ +#define CALLBACK_SLOT2OFS(slot) (0*(slot)) +#define CALLBACK_OFS2SLOT(ofs) (0*(ofs)) +#define CALLBACK_MAX_SLOT 0 + +#elif LJ_TARGET_X86ORX64 + +#define CALLBACK_MCODE_HEAD (LJ_64 ? 8 : 0) +#define CALLBACK_MCODE_GROUP (-2+1+2+5+(LJ_64 ? 6 : 5)) + +#define CALLBACK_SLOT2OFS(slot) \ + (CALLBACK_MCODE_HEAD + CALLBACK_MCODE_GROUP*((slot)/32) + 4*(slot)) + +static MSize CALLBACK_OFS2SLOT(MSize ofs) +{ + MSize group; + ofs -= CALLBACK_MCODE_HEAD; + group = ofs / (32*4 + CALLBACK_MCODE_GROUP); + return (ofs % (32*4 + CALLBACK_MCODE_GROUP))/4 + group*32; +} + +#define CALLBACK_MAX_SLOT \ + (((CALLBACK_MCODE_SIZE-CALLBACK_MCODE_HEAD)/(CALLBACK_MCODE_GROUP+4*32))*32) + +#elif LJ_TARGET_ARM + +#define CALLBACK_MCODE_HEAD 32 +#define CALLBACK_SLOT2OFS(slot) (CALLBACK_MCODE_HEAD + 8*(slot)) +#define CALLBACK_OFS2SLOT(ofs) (((ofs)-CALLBACK_MCODE_HEAD)/8) +#define CALLBACK_MAX_SLOT (CALLBACK_OFS2SLOT(CALLBACK_MCODE_SIZE)) + +#elif LJ_TARGET_PPC + +#define CALLBACK_MCODE_HEAD 24 +#define CALLBACK_SLOT2OFS(slot) (CALLBACK_MCODE_HEAD + 8*(slot)) +#define CALLBACK_OFS2SLOT(ofs) (((ofs)-CALLBACK_MCODE_HEAD)/8) +#define CALLBACK_MAX_SLOT (CALLBACK_OFS2SLOT(CALLBACK_MCODE_SIZE)) + +#elif LJ_TARGET_MIPS + +#define CALLBACK_MCODE_HEAD 24 +#define CALLBACK_SLOT2OFS(slot) (CALLBACK_MCODE_HEAD + 8*(slot)) +#define CALLBACK_OFS2SLOT(ofs) (((ofs)-CALLBACK_MCODE_HEAD)/8) +#define CALLBACK_MAX_SLOT (CALLBACK_OFS2SLOT(CALLBACK_MCODE_SIZE)) + +#else + +/* Missing support for this architecture. */ +#define CALLBACK_SLOT2OFS(slot) (0*(slot)) +#define CALLBACK_OFS2SLOT(ofs) (0*(ofs)) +#define CALLBACK_MAX_SLOT 0 + +#endif + +/* Convert callback slot number to callback function pointer. */ +static void *callback_slot2ptr(CTState *cts, MSize slot) +{ + return (uint8_t *)cts->cb.mcode + CALLBACK_SLOT2OFS(slot); +} + +/* Convert callback function pointer to slot number. */ +MSize lj_ccallback_ptr2slot(CTState *cts, void *p) +{ + uintptr_t ofs = (uintptr_t)((uint8_t *)p -(uint8_t *)cts->cb.mcode); + if (ofs < CALLBACK_MCODE_SIZE) { + MSize slot = CALLBACK_OFS2SLOT((MSize)ofs); + if (CALLBACK_SLOT2OFS(slot) == (MSize)ofs) + return slot; + } + return ~0u; /* Not a known callback function pointer. */ +} + +/* Initialize machine code for callback function pointers. */ +#if LJ_OS_NOJIT +/* Disabled callback support. */ +#define callback_mcode_init(g, p) UNUSED(p) +#elif LJ_TARGET_X86ORX64 +static void callback_mcode_init(global_State *g, uint8_t *page) +{ + uint8_t *p = page; + uint8_t *target = (uint8_t *)(void *)lj_vm_ffi_callback; + MSize slot; +#if LJ_64 + *(void **)p = target; p += 8; +#endif + for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { + /* mov al, slot; jmp group */ + *p++ = XI_MOVrib | RID_EAX; *p++ = (uint8_t)slot; + if ((slot & 31) == 31 || slot == CALLBACK_MAX_SLOT-1) { + /* push ebp/rbp; mov ah, slot>>8; mov ebp, &g. */ + *p++ = XI_PUSH + RID_EBP; + *p++ = XI_MOVrib | (RID_EAX+4); *p++ = (uint8_t)(slot >> 8); + *p++ = XI_MOVri | RID_EBP; + *(int32_t *)p = i32ptr(g); p += 4; +#if LJ_64 + /* jmp [rip-pageofs] where lj_vm_ffi_callback is stored. */ + *p++ = XI_GROUP5; *p++ = XM_OFS0 + (XOg_JMP<<3) + RID_EBP; + *(int32_t *)p = (int32_t)(page-(p+4)); p += 4; +#else + /* jmp lj_vm_ffi_callback. */ + *p++ = XI_JMP; *(int32_t *)p = target-(p+4); p += 4; +#endif + } else { + *p++ = XI_JMPs; *p++ = (uint8_t)((2+2)*(31-(slot&31)) - 2); + } + } + lua_assert(p - page <= CALLBACK_MCODE_SIZE); +} +#elif LJ_TARGET_ARM +static void callback_mcode_init(global_State *g, uint32_t *page) +{ + uint32_t *p = page; + void *target = (void *)lj_vm_ffi_callback; + MSize slot; + /* This must match with the saveregs macro in buildvm_arm.dasc. */ + *p++ = ARMI_SUB|ARMF_D(RID_R12)|ARMF_N(RID_R12)|ARMF_M(RID_PC); + *p++ = ARMI_PUSH|ARMF_N(RID_SP)|RSET_RANGE(RID_R4,RID_R11+1)|RID2RSET(RID_LR); + *p++ = ARMI_SUB|ARMI_K12|ARMF_D(RID_R12)|ARMF_N(RID_R12)|CALLBACK_MCODE_HEAD; + *p++ = ARMI_STR|ARMI_LS_P|ARMI_LS_W|ARMF_D(RID_R12)|ARMF_N(RID_SP)|(CFRAME_SIZE-4*9); + *p++ = ARMI_LDR|ARMI_LS_P|ARMI_LS_U|ARMF_D(RID_R12)|ARMF_N(RID_PC); + *p++ = ARMI_LDR|ARMI_LS_P|ARMI_LS_U|ARMF_D(RID_PC)|ARMF_N(RID_PC); + *p++ = u32ptr(g); + *p++ = u32ptr(target); + for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { + *p++ = ARMI_MOV|ARMF_D(RID_R12)|ARMF_M(RID_PC); + *p = ARMI_B | ((page-p-2) & 0x00ffffffu); + p++; + } + lua_assert(p - page <= CALLBACK_MCODE_SIZE); +} +#elif LJ_TARGET_PPC +static void callback_mcode_init(global_State *g, uint32_t *page) +{ + uint32_t *p = page; + void *target = (void *)lj_vm_ffi_callback; + MSize slot; + *p++ = PPCI_LIS | PPCF_T(RID_TMP) | (u32ptr(target) >> 16); + *p++ = PPCI_LIS | PPCF_T(RID_R12) | (u32ptr(g) >> 16); + *p++ = PPCI_ORI | PPCF_A(RID_TMP)|PPCF_T(RID_TMP) | (u32ptr(target) & 0xffff); + *p++ = PPCI_ORI | PPCF_A(RID_R12)|PPCF_T(RID_R12) | (u32ptr(g) & 0xffff); + *p++ = PPCI_MTCTR | PPCF_T(RID_TMP); + *p++ = PPCI_BCTR; + for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { + *p++ = PPCI_LI | PPCF_T(RID_R11) | slot; + *p = PPCI_B | (((page-p) & 0x00ffffffu) << 2); + p++; + } + lua_assert(p - page <= CALLBACK_MCODE_SIZE); +} +#elif LJ_TARGET_MIPS +static void callback_mcode_init(global_State *g, uint32_t *page) +{ + uint32_t *p = page; + void *target = (void *)lj_vm_ffi_callback; + MSize slot; + *p++ = MIPSI_SW | MIPSF_T(RID_R1)|MIPSF_S(RID_SP) | 0; + *p++ = MIPSI_LUI | MIPSF_T(RID_R3) | (u32ptr(target) >> 16); + *p++ = MIPSI_LUI | MIPSF_T(RID_R2) | (u32ptr(g) >> 16); + *p++ = MIPSI_ORI | MIPSF_T(RID_R3)|MIPSF_S(RID_R3) |(u32ptr(target)&0xffff); + *p++ = MIPSI_JR | MIPSF_S(RID_R3); + *p++ = MIPSI_ORI | MIPSF_T(RID_R2)|MIPSF_S(RID_R2) | (u32ptr(g)&0xffff); + for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { + *p = MIPSI_B | ((page-p-1) & 0x0000ffffu); + p++; + *p++ = MIPSI_LI | MIPSF_T(RID_R1) | slot; + } + lua_assert(p - page <= CALLBACK_MCODE_SIZE); +} +#else +/* Missing support for this architecture. */ +#define callback_mcode_init(g, p) UNUSED(p) +#endif + +/* -- Machine code management --------------------------------------------- */ + +#if LJ_TARGET_WINDOWS + +#define WIN32_LEAN_AND_MEAN +#include + +#elif LJ_TARGET_POSIX + +#include +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +#endif + +/* Allocate and initialize area for callback function pointers. */ +static void callback_mcode_new(CTState *cts) +{ + size_t sz = (size_t)CALLBACK_MCODE_SIZE; + void *p; + if (CALLBACK_MAX_SLOT == 0) + lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); +#if LJ_TARGET_WINDOWS + p = VirtualAlloc(NULL, sz, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); + if (!p) + lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); +#elif LJ_TARGET_POSIX + p = mmap(NULL, sz, (PROT_READ|PROT_WRITE), MAP_PRIVATE|MAP_ANONYMOUS, + -1, 0); + if (p == MAP_FAILED) + lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); +#else + /* Fallback allocator. Fails if memory is not executable by default. */ + p = lj_mem_new(cts->L, sz); +#endif + cts->cb.mcode = p; + callback_mcode_init(cts->g, p); + lj_mcode_sync(p, (char *)p + sz); +#if LJ_TARGET_WINDOWS + { + DWORD oprot; + VirtualProtect(p, sz, PAGE_EXECUTE_READ, &oprot); + } +#elif LJ_TARGET_POSIX + mprotect(p, sz, (PROT_READ|PROT_EXEC)); +#endif +} + +/* Free area for callback function pointers. */ +void lj_ccallback_mcode_free(CTState *cts) +{ + size_t sz = (size_t)CALLBACK_MCODE_SIZE; + void *p = cts->cb.mcode; + if (p == NULL) return; +#if LJ_TARGET_WINDOWS + VirtualFree(p, 0, MEM_RELEASE); + UNUSED(sz); +#elif LJ_TARGET_POSIX + munmap(p, sz); +#else + lj_mem_free(cts->g, p, sz); +#endif +} + +/* -- C callback entry ---------------------------------------------------- */ + +/* Target-specific handling of register arguments. Similar to lj_ccall.c. */ +#if LJ_TARGET_X86 + +#define CALLBACK_HANDLE_REGARG \ + if (!isfp) { /* Only non-FP values may be passed in registers. */ \ + if (n > 1) { /* Anything > 32 bit is passed on the stack. */ \ + if (!LJ_ABI_WIN) ngpr = maxgpr; /* Prevent reordering. */ \ + } else if (ngpr + 1 <= maxgpr) { \ + sp = &cts->cb.gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } \ + } + +#elif LJ_TARGET_X64 && LJ_ABI_WIN + +/* Windows/x64 argument registers are strictly positional (use ngpr). */ +#define CALLBACK_HANDLE_REGARG \ + if (isfp) { \ + if (ngpr < maxgpr) { sp = &cts->cb.fpr[ngpr++]; UNUSED(nfpr); goto done; } \ + } else { \ + if (ngpr < maxgpr) { sp = &cts->cb.gpr[ngpr++]; goto done; } \ + } + +#elif LJ_TARGET_X64 + +#define CALLBACK_HANDLE_REGARG \ + if (isfp) { \ + if (nfpr + n <= CCALL_NARG_FPR) { \ + sp = &cts->cb.fpr[nfpr]; \ + nfpr += n; \ + goto done; \ + } \ + } else { \ + if (ngpr + n <= maxgpr) { \ + sp = &cts->cb.gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } \ + } + +#elif LJ_TARGET_ARM + +#if LJ_ABI_SOFTFP + +#define CALLBACK_HANDLE_REGARG_FP1 UNUSED(isfp); +#define CALLBACK_HANDLE_REGARG_FP2 + +#else + +#define CALLBACK_HANDLE_REGARG_FP1 \ + if (isfp) { \ + if (n == 1) { \ + if (fprodd) { \ + sp = &cts->cb.fpr[fprodd-1]; \ + fprodd = 0; \ + goto done; \ + } else if (nfpr + 1 <= CCALL_NARG_FPR) { \ + sp = &cts->cb.fpr[nfpr++]; \ + fprodd = nfpr; \ + goto done; \ + } \ + } else { \ + if (nfpr + 1 <= CCALL_NARG_FPR) { \ + sp = &cts->cb.fpr[nfpr++]; \ + goto done; \ + } \ + } \ + fprodd = 0; /* No reordering after the first FP value is on stack. */ \ + } else { + +#define CALLBACK_HANDLE_REGARG_FP2 } + +#endif + +#define CALLBACK_HANDLE_REGARG \ + CALLBACK_HANDLE_REGARG_FP1 \ + if (n > 1) ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ + if (ngpr + n <= maxgpr) { \ + sp = &cts->cb.gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } CALLBACK_HANDLE_REGARG_FP2 + +#elif LJ_TARGET_PPC + +#define CALLBACK_HANDLE_REGARG \ + if (isfp) { \ + if (nfpr + 1 <= CCALL_NARG_FPR) { \ + sp = &cts->cb.fpr[nfpr++]; \ + cta = ctype_get(cts, CTID_DOUBLE); /* FPRs always hold doubles. */ \ + goto done; \ + } \ + } else { /* Try to pass argument in GPRs. */ \ + if (n > 1) { \ + lua_assert(ctype_isinteger(cta->info) && n == 2); /* int64_t. */ \ + ngpr = (ngpr + 1u) & ~1u; /* Align int64_t to regpair. */ \ + } \ + if (ngpr + n <= maxgpr) { \ + sp = &cts->cb.gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } \ + } + +#define CALLBACK_HANDLE_RET \ + if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ + *(double *)dp = *(float *)dp; /* FPRs always hold doubles. */ + +#elif LJ_TARGET_MIPS + +#define CALLBACK_HANDLE_REGARG \ + if (isfp && nfpr < CCALL_NARG_FPR) { /* Try to pass argument in FPRs. */ \ + sp = (void *)((uint8_t *)&cts->cb.fpr[nfpr] + ((LJ_BE && n==1) ? 4 : 0)); \ + nfpr++; ngpr += n; \ + goto done; \ + } else { /* Try to pass argument in GPRs. */ \ + nfpr = CCALL_NARG_FPR; \ + if (n > 1) ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ + if (ngpr + n <= maxgpr) { \ + sp = &cts->cb.gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } \ + } + +#define CALLBACK_HANDLE_RET \ + if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ + ((float *)dp)[1] = *(float *)dp; + +#else +#error "Missing calling convention definitions for this architecture" +#endif + +/* Convert and push callback arguments to Lua stack. */ +static void callback_conv_args(CTState *cts, lua_State *L) +{ + TValue *o = L->top; + intptr_t *stack = cts->cb.stack; + MSize slot = cts->cb.slot; + CTypeID id = 0, rid, fid; + int gcsteps = 0; + CType *ct; + GCfunc *fn; + MSize ngpr = 0, nsp = 0, maxgpr = CCALL_NARG_GPR; +#if CCALL_NARG_FPR + MSize nfpr = 0; +#if LJ_TARGET_ARM + MSize fprodd = 0; +#endif +#endif + + if (slot < cts->cb.sizeid && (id = cts->cb.cbid[slot]) != 0) { + ct = ctype_get(cts, id); + rid = ctype_cid(ct->info); + fn = funcV(lj_tab_getint(cts->miscmap, (int32_t)slot)); + } else { /* Must set up frame first, before throwing the error. */ + ct = NULL; + rid = 0; + fn = (GCfunc *)L; + } + o->u32.lo = LJ_CONT_FFI_CALLBACK; /* Continuation returns from callback. */ + o->u32.hi = rid; /* Return type. x86: +(spadj<<16). */ + o++; + setframe_gc(o, obj2gco(fn)); + setframe_ftsz(o, (int)((char *)(o+1) - (char *)L->base) + FRAME_CONT); + L->top = L->base = ++o; + if (!ct) + lj_err_caller(cts->L, LJ_ERR_FFI_BADCBACK); + if (isluafunc(fn)) + setcframe_pc(L->cframe, proto_bc(funcproto(fn))+1); + lj_state_checkstack(L, LUA_MINSTACK); /* May throw. */ + o = L->base; /* Might have been reallocated. */ + +#if LJ_TARGET_X86 + /* x86 has several different calling conventions. */ + switch (ctype_cconv(ct->info)) { + case CTCC_FASTCALL: maxgpr = 2; break; + case CTCC_THISCALL: maxgpr = 1; break; + default: maxgpr = 0; break; + } +#endif + + fid = ct->sib; + while (fid) { + CType *ctf = ctype_get(cts, fid); + if (!ctype_isattrib(ctf->info)) { + CType *cta; + void *sp; + CTSize sz; + int isfp; + MSize n; + lua_assert(ctype_isfield(ctf->info)); + cta = ctype_rawchild(cts, ctf); + isfp = ctype_isfp(cta->info); + sz = (cta->size + CTSIZE_PTR-1) & ~(CTSIZE_PTR-1); + n = sz / CTSIZE_PTR; /* Number of GPRs or stack slots needed. */ + + CALLBACK_HANDLE_REGARG /* Handle register arguments. */ + + /* Otherwise pass argument on stack. */ + if (CCALL_ALIGN_STACKARG && LJ_32 && sz == 8) + nsp = (nsp + 1) & ~1u; /* Align 64 bit argument on stack. */ + sp = &stack[nsp]; + nsp += n; + + done: + if (LJ_BE && cta->size < CTSIZE_PTR) + sp = (void *)((uint8_t *)sp + CTSIZE_PTR-cta->size); + gcsteps += lj_cconv_tv_ct(cts, cta, 0, o++, sp); + } + fid = ctf->sib; + } + L->top = o; +#if LJ_TARGET_X86 + /* Store stack adjustment for returns from non-cdecl callbacks. */ + if (ctype_cconv(ct->info) != CTCC_CDECL) + (L->base-2)->u32.hi |= (nsp << (16+2)); +#endif + while (gcsteps-- > 0) + lj_gc_check(L); +} + +/* Convert Lua object to callback result. */ +static void callback_conv_result(CTState *cts, lua_State *L, TValue *o) +{ + CType *ctr = ctype_raw(cts, (uint16_t)(L->base-2)->u32.hi); +#if LJ_TARGET_X86 + cts->cb.gpr[2] = 0; +#endif + if (!ctype_isvoid(ctr->info)) { + uint8_t *dp = (uint8_t *)&cts->cb.gpr[0]; +#if CCALL_NUM_FPR + if (ctype_isfp(ctr->info)) + dp = (uint8_t *)&cts->cb.fpr[0]; +#endif + lj_cconv_ct_tv(cts, ctr, dp, o, 0); +#ifdef CALLBACK_HANDLE_RET + CALLBACK_HANDLE_RET +#endif + /* Extend returned integers to (at least) 32 bits. */ + if (ctype_isinteger_or_bool(ctr->info) && ctr->size < 4) { + if (ctr->info & CTF_UNSIGNED) + *(uint32_t *)dp = ctr->size == 1 ? (uint32_t)*(uint8_t *)dp : + (uint32_t)*(uint16_t *)dp; + else + *(int32_t *)dp = ctr->size == 1 ? (int32_t)*(int8_t *)dp : + (int32_t)*(int16_t *)dp; + } +#if LJ_TARGET_X86 + if (ctype_isfp(ctr->info)) + cts->cb.gpr[2] = ctr->size == sizeof(float) ? 1 : 2; +#endif + } +} + +/* Enter callback. */ +lua_State * LJ_FASTCALL lj_ccallback_enter(CTState *cts, void *cf) +{ + lua_State *L = cts->L; + global_State *g = cts->g; + lua_assert(L != NULL); + if (gcref(g->jit_L)) { + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_FFI_BADCBACK)); + if (g->panic) g->panic(L); + exit(EXIT_FAILURE); + } + lj_trace_abort(g); /* Never record across callback. */ + /* Setup C frame. */ + cframe_prev(cf) = L->cframe; + setcframe_L(cf, L); + cframe_errfunc(cf) = -1; + cframe_nres(cf) = 0; + L->cframe = cf; + callback_conv_args(cts, L); + return L; /* Now call the function on this stack. */ +} + +/* Leave callback. */ +void LJ_FASTCALL lj_ccallback_leave(CTState *cts, TValue *o) +{ + lua_State *L = cts->L; + GCfunc *fn; + TValue *obase = L->base; + L->base = L->top; /* Keep continuation frame for throwing errors. */ + if (o >= L->base) { + /* PC of RET* is lost. Point to last line for result conv. errors. */ + fn = curr_func(L); + if (isluafunc(fn)) { + GCproto *pt = funcproto(fn); + setcframe_pc(L->cframe, proto_bc(pt)+pt->sizebc+1); + } + } + callback_conv_result(cts, L, o); + /* Finally drop C frame and continuation frame. */ + L->cframe = cframe_prev(L->cframe); + L->top -= 2; + L->base = obase; + cts->cb.slot = 0; /* Blacklist C function that called the callback. */ +} + +/* -- C callback management ----------------------------------------------- */ + +/* Get an unused slot in the callback slot table. */ +static MSize callback_slot_new(CTState *cts, CType *ct) +{ + CTypeID id = ctype_typeid(cts, ct); + CTypeID1 *cbid = cts->cb.cbid; + MSize top; + for (top = cts->cb.topid; top < cts->cb.sizeid; top++) + if (LJ_LIKELY(cbid[top] == 0)) + goto found; +#if CALLBACK_MAX_SLOT + if (top >= CALLBACK_MAX_SLOT) +#endif + lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); + if (!cts->cb.mcode) + callback_mcode_new(cts); + lj_mem_growvec(cts->L, cbid, cts->cb.sizeid, CALLBACK_MAX_SLOT, CTypeID1); + cts->cb.cbid = cbid; + memset(cbid+top, 0, (cts->cb.sizeid-top)*sizeof(CTypeID1)); +found: + cbid[top] = id; + cts->cb.topid = top+1; + return top; +} + +/* Check for function pointer and supported argument/result types. */ +static CType *callback_checkfunc(CTState *cts, CType *ct) +{ + int narg = 0; + if (!ctype_isptr(ct->info) || (LJ_64 && ct->size != CTSIZE_PTR)) + return NULL; + ct = ctype_rawchild(cts, ct); + if (ctype_isfunc(ct->info)) { + CType *ctr = ctype_rawchild(cts, ct); + CTypeID fid = ct->sib; + if (!(ctype_isvoid(ctr->info) || ctype_isenum(ctr->info) || + ctype_isptr(ctr->info) || (ctype_isnum(ctr->info) && ctr->size <= 8))) + return NULL; + if ((ct->info & CTF_VARARG)) + return NULL; + while (fid) { + CType *ctf = ctype_get(cts, fid); + if (!ctype_isattrib(ctf->info)) { + CType *cta; + lua_assert(ctype_isfield(ctf->info)); + cta = ctype_rawchild(cts, ctf); + if (!(ctype_isenum(cta->info) || ctype_isptr(cta->info) || + (ctype_isnum(cta->info) && cta->size <= 8)) || + ++narg >= LUA_MINSTACK-3) + return NULL; + } + fid = ctf->sib; + } + return ct; + } + return NULL; +} + +/* Create a new callback and return the callback function pointer. */ +void *lj_ccallback_new(CTState *cts, CType *ct, GCfunc *fn) +{ + ct = callback_checkfunc(cts, ct); + if (ct) { + MSize slot = callback_slot_new(cts, ct); + GCtab *t = cts->miscmap; + setfuncV(cts->L, lj_tab_setint(cts->L, t, (int32_t)slot), fn); + lj_gc_anybarriert(cts->L, t); + return callback_slot2ptr(cts, slot); + } + return NULL; /* Bad conversion. */ +} + +#endif + +``` + +`include/luajit-2.0.5/src/lj_ccallback.h`: + +```h +/* +** FFI C callback handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CCALLBACK_H +#define _LJ_CCALLBACK_H + +#include "lj_obj.h" +#include "lj_ctype.h" + +#if LJ_HASFFI + +/* Really belongs to lj_vm.h. */ +LJ_ASMF void lj_vm_ffi_callback(void); + +LJ_FUNC MSize lj_ccallback_ptr2slot(CTState *cts, void *p); +LJ_FUNCA lua_State * LJ_FASTCALL lj_ccallback_enter(CTState *cts, void *cf); +LJ_FUNCA void LJ_FASTCALL lj_ccallback_leave(CTState *cts, TValue *o); +LJ_FUNC void *lj_ccallback_new(CTState *cts, CType *ct, GCfunc *fn); +LJ_FUNC void lj_ccallback_mcode_free(CTState *cts); + +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_cconv.c`: + +```c +/* +** C type conversions. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_err.h" +#include "lj_tab.h" +#include "lj_ctype.h" +#include "lj_cdata.h" +#include "lj_cconv.h" +#include "lj_ccallback.h" + +/* -- Conversion errors --------------------------------------------------- */ + +/* Bad conversion. */ +LJ_NORET static void cconv_err_conv(CTState *cts, CType *d, CType *s, + CTInfo flags) +{ + const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); + const char *src; + if ((flags & CCF_FROMTV)) + src = lj_obj_typename[1+(ctype_isnum(s->info) ? LUA_TNUMBER : + ctype_isarray(s->info) ? LUA_TSTRING : LUA_TNIL)]; + else + src = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, s), NULL)); + if (CCF_GETARG(flags)) + lj_err_argv(cts->L, CCF_GETARG(flags), LJ_ERR_FFI_BADCONV, src, dst); + else + lj_err_callerv(cts->L, LJ_ERR_FFI_BADCONV, src, dst); +} + +/* Bad conversion from TValue. */ +LJ_NORET static void cconv_err_convtv(CTState *cts, CType *d, TValue *o, + CTInfo flags) +{ + const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); + const char *src = lj_typename(o); + if (CCF_GETARG(flags)) + lj_err_argv(cts->L, CCF_GETARG(flags), LJ_ERR_FFI_BADCONV, src, dst); + else + lj_err_callerv(cts->L, LJ_ERR_FFI_BADCONV, src, dst); +} + +/* Initializer overflow. */ +LJ_NORET static void cconv_err_initov(CTState *cts, CType *d) +{ + const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); + lj_err_callerv(cts->L, LJ_ERR_FFI_INITOV, dst); +} + +/* -- C type compatibility checks ----------------------------------------- */ + +/* Get raw type and qualifiers for a child type. Resolves enums, too. */ +static CType *cconv_childqual(CTState *cts, CType *ct, CTInfo *qual) +{ + ct = ctype_child(cts, ct); + for (;;) { + if (ctype_isattrib(ct->info)) { + if (ctype_attrib(ct->info) == CTA_QUAL) *qual |= ct->size; + } else if (!ctype_isenum(ct->info)) { + break; + } + ct = ctype_child(cts, ct); + } + *qual |= (ct->info & CTF_QUAL); + return ct; +} + +/* Check for compatible types when converting to a pointer. +** Note: these checks are more relaxed than what C99 mandates. +*/ +int lj_cconv_compatptr(CTState *cts, CType *d, CType *s, CTInfo flags) +{ + if (!((flags & CCF_CAST) || d == s)) { + CTInfo dqual = 0, squal = 0; + d = cconv_childqual(cts, d, &dqual); + if (!ctype_isstruct(s->info)) + s = cconv_childqual(cts, s, &squal); + if ((flags & CCF_SAME)) { + if (dqual != squal) + return 0; /* Different qualifiers. */ + } else if (!(flags & CCF_IGNQUAL)) { + if ((dqual & squal) != squal) + return 0; /* Discarded qualifiers. */ + if (ctype_isvoid(d->info) || ctype_isvoid(s->info)) + return 1; /* Converting to/from void * is always ok. */ + } + if (ctype_type(d->info) != ctype_type(s->info) || + d->size != s->size) + return 0; /* Different type or different size. */ + if (ctype_isnum(d->info)) { + if (((d->info ^ s->info) & (CTF_BOOL|CTF_FP))) + return 0; /* Different numeric types. */ + } else if (ctype_ispointer(d->info)) { + /* Check child types for compatibility. */ + return lj_cconv_compatptr(cts, d, s, flags|CCF_SAME); + } else if (ctype_isstruct(d->info)) { + if (d != s) + return 0; /* Must be exact same type for struct/union. */ + } else if (ctype_isfunc(d->info)) { + /* NYI: structural equality of functions. */ + } + } + return 1; /* Types are compatible. */ +} + +/* -- C type to C type conversion ----------------------------------------- */ + +/* Convert C type to C type. Caveat: expects to get the raw CType! +** +** Note: This is only used by the interpreter and not optimized at all. +** The JIT compiler will do a much better job specializing for each case. +*/ +void lj_cconv_ct_ct(CTState *cts, CType *d, CType *s, + uint8_t *dp, uint8_t *sp, CTInfo flags) +{ + CTSize dsize = d->size, ssize = s->size; + CTInfo dinfo = d->info, sinfo = s->info; + void *tmpptr; + + lua_assert(!ctype_isenum(dinfo) && !ctype_isenum(sinfo)); + lua_assert(!ctype_isattrib(dinfo) && !ctype_isattrib(sinfo)); + + if (ctype_type(dinfo) > CT_MAYCONVERT || ctype_type(sinfo) > CT_MAYCONVERT) + goto err_conv; + + /* Some basic sanity checks. */ + lua_assert(!ctype_isnum(dinfo) || dsize > 0); + lua_assert(!ctype_isnum(sinfo) || ssize > 0); + lua_assert(!ctype_isbool(dinfo) || dsize == 1 || dsize == 4); + lua_assert(!ctype_isbool(sinfo) || ssize == 1 || ssize == 4); + lua_assert(!ctype_isinteger(dinfo) || (1u< ssize) { /* Zero-extend or sign-extend LSB. */ +#if LJ_LE + uint8_t fill = (!(sinfo & CTF_UNSIGNED) && (sp[ssize-1]&0x80)) ? 0xff : 0; + memcpy(dp, sp, ssize); + memset(dp + ssize, fill, dsize-ssize); +#else + uint8_t fill = (!(sinfo & CTF_UNSIGNED) && (sp[0]&0x80)) ? 0xff : 0; + memset(dp, fill, dsize-ssize); + memcpy(dp + (dsize-ssize), sp, ssize); +#endif + } else { /* Copy LSB. */ +#if LJ_LE + memcpy(dp, sp, dsize); +#else + memcpy(dp, sp + (ssize-dsize), dsize); +#endif + } + break; + case CCX(I, F): { + double n; /* Always convert via double. */ + conv_I_F: + /* Convert source to double. */ + if (ssize == sizeof(double)) n = *(double *)sp; + else if (ssize == sizeof(float)) n = (double)*(float *)sp; + else goto err_conv; /* NYI: long double. */ + /* Then convert double to integer. */ + /* The conversion must exactly match the semantics of JIT-compiled code! */ + if (dsize < 4 || (dsize == 4 && !(dinfo & CTF_UNSIGNED))) { + int32_t i = (int32_t)n; + if (dsize == 4) *(int32_t *)dp = i; + else if (dsize == 2) *(int16_t *)dp = (int16_t)i; + else *(int8_t *)dp = (int8_t)i; + } else if (dsize == 4) { + *(uint32_t *)dp = (uint32_t)n; + } else if (dsize == 8) { + if (!(dinfo & CTF_UNSIGNED)) + *(int64_t *)dp = (int64_t)n; + else + *(uint64_t *)dp = lj_num2u64(n); + } else { + goto err_conv; /* NYI: conversion to >64 bit integers. */ + } + break; + } + case CCX(I, C): + s = ctype_child(cts, s); + sinfo = s->info; + ssize = s->size; + goto conv_I_F; /* Just convert re. */ + case CCX(I, P): + if (!(flags & CCF_CAST)) goto err_conv; + sinfo = CTINFO(CT_NUM, CTF_UNSIGNED); + goto conv_I_I; + case CCX(I, A): + if (!(flags & CCF_CAST)) goto err_conv; + sinfo = CTINFO(CT_NUM, CTF_UNSIGNED); + ssize = CTSIZE_PTR; + tmpptr = sp; + sp = (uint8_t *)&tmpptr; + goto conv_I_I; + + /* Destination is a floating-point number. */ + case CCX(F, B): + case CCX(F, I): { + double n; /* Always convert via double. */ + conv_F_I: + /* First convert source to double. */ + /* The conversion must exactly match the semantics of JIT-compiled code! */ + if (ssize < 4 || (ssize == 4 && !(sinfo & CTF_UNSIGNED))) { + int32_t i; + if (ssize == 4) { + i = *(int32_t *)sp; + } else if (!(sinfo & CTF_UNSIGNED)) { + if (ssize == 2) i = *(int16_t *)sp; + else i = *(int8_t *)sp; + } else { + if (ssize == 2) i = *(uint16_t *)sp; + else i = *(uint8_t *)sp; + } + n = (double)i; + } else if (ssize == 4) { + n = (double)*(uint32_t *)sp; + } else if (ssize == 8) { + if (!(sinfo & CTF_UNSIGNED)) n = (double)*(int64_t *)sp; + else n = (double)*(uint64_t *)sp; + } else { + goto err_conv; /* NYI: conversion from >64 bit integers. */ + } + /* Convert double to destination. */ + if (dsize == sizeof(double)) *(double *)dp = n; + else if (dsize == sizeof(float)) *(float *)dp = (float)n; + else goto err_conv; /* NYI: long double. */ + break; + } + case CCX(F, F): { + double n; /* Always convert via double. */ + conv_F_F: + if (ssize == dsize) goto copyval; + /* Convert source to double. */ + if (ssize == sizeof(double)) n = *(double *)sp; + else if (ssize == sizeof(float)) n = (double)*(float *)sp; + else goto err_conv; /* NYI: long double. */ + /* Convert double to destination. */ + if (dsize == sizeof(double)) *(double *)dp = n; + else if (dsize == sizeof(float)) *(float *)dp = (float)n; + else goto err_conv; /* NYI: long double. */ + break; + } + case CCX(F, C): + s = ctype_child(cts, s); + sinfo = s->info; + ssize = s->size; + goto conv_F_F; /* Ignore im, and convert from re. */ + + /* Destination is a complex number. */ + case CCX(C, I): + d = ctype_child(cts, d); + dinfo = d->info; + dsize = d->size; + memset(dp + dsize, 0, dsize); /* Clear im. */ + goto conv_F_I; /* Convert to re. */ + case CCX(C, F): + d = ctype_child(cts, d); + dinfo = d->info; + dsize = d->size; + memset(dp + dsize, 0, dsize); /* Clear im. */ + goto conv_F_F; /* Convert to re. */ + + case CCX(C, C): + if (dsize != ssize) { /* Different types: convert re/im separately. */ + CType *dc = ctype_child(cts, d); + CType *sc = ctype_child(cts, s); + lj_cconv_ct_ct(cts, dc, sc, dp, sp, flags); + lj_cconv_ct_ct(cts, dc, sc, dp + dc->size, sp + sc->size, flags); + return; + } + goto copyval; /* Otherwise this is easy. */ + + /* Destination is a vector. */ + case CCX(V, I): + case CCX(V, F): + case CCX(V, C): { + CType *dc = ctype_child(cts, d); + CTSize esize; + /* First convert the scalar to the first element. */ + lj_cconv_ct_ct(cts, dc, s, dp, sp, flags); + /* Then replicate it to the other elements (splat). */ + for (sp = dp, esize = dc->size; dsize > esize; dsize -= esize) { + dp += esize; + memcpy(dp, sp, esize); + } + break; + } + + case CCX(V, V): + /* Copy same-sized vectors, even for different lengths/element-types. */ + if (dsize != ssize) goto err_conv; + goto copyval; + + /* Destination is a pointer. */ + case CCX(P, I): + if (!(flags & CCF_CAST)) goto err_conv; + dinfo = CTINFO(CT_NUM, CTF_UNSIGNED); + goto conv_I_I; + + case CCX(P, F): + if (!(flags & CCF_CAST) || !(flags & CCF_FROMTV)) goto err_conv; + /* The signed conversion is cheaper. x64 really has 47 bit pointers. */ + dinfo = CTINFO(CT_NUM, (LJ_64 && dsize == 8) ? 0 : CTF_UNSIGNED); + goto conv_I_F; + + case CCX(P, P): + if (!lj_cconv_compatptr(cts, d, s, flags)) goto err_conv; + cdata_setptr(dp, dsize, cdata_getptr(sp, ssize)); + break; + + case CCX(P, A): + case CCX(P, S): + if (!lj_cconv_compatptr(cts, d, s, flags)) goto err_conv; + cdata_setptr(dp, dsize, sp); + break; + + /* Destination is an array. */ + case CCX(A, A): + if ((flags & CCF_CAST) || (d->info & CTF_VLA) || dsize != ssize || + d->size == CTSIZE_INVALID || !lj_cconv_compatptr(cts, d, s, flags)) + goto err_conv; + goto copyval; + + /* Destination is a struct/union. */ + case CCX(S, S): + if ((flags & CCF_CAST) || (d->info & CTF_VLA) || d != s) + goto err_conv; /* Must be exact same type. */ +copyval: /* Copy value. */ + lua_assert(dsize == ssize); + memcpy(dp, sp, dsize); + break; + + default: + err_conv: + cconv_err_conv(cts, d, s, flags); + } +} + +/* -- C type to TValue conversion ----------------------------------------- */ + +/* Convert C type to TValue. Caveat: expects to get the raw CType! */ +int lj_cconv_tv_ct(CTState *cts, CType *s, CTypeID sid, + TValue *o, uint8_t *sp) +{ + CTInfo sinfo = s->info; + if (ctype_isnum(sinfo)) { + if (!ctype_isbool(sinfo)) { + if (ctype_isinteger(sinfo) && s->size > 4) goto copyval; + if (LJ_DUALNUM && ctype_isinteger(sinfo)) { + int32_t i; + lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT32), s, + (uint8_t *)&i, sp, 0); + if ((sinfo & CTF_UNSIGNED) && i < 0) + setnumV(o, (lua_Number)(uint32_t)i); + else + setintV(o, i); + } else { + lj_cconv_ct_ct(cts, ctype_get(cts, CTID_DOUBLE), s, + (uint8_t *)&o->n, sp, 0); + /* Numbers are NOT canonicalized here! Beware of uninitialized data. */ + lua_assert(tvisnum(o)); + } + } else { + uint32_t b = s->size == 1 ? (*sp != 0) : (*(int *)sp != 0); + setboolV(o, b); + setboolV(&cts->g->tmptv2, b); /* Remember for trace recorder. */ + } + return 0; + } else if (ctype_isrefarray(sinfo) || ctype_isstruct(sinfo)) { + /* Create reference. */ + setcdataV(cts->L, o, lj_cdata_newref(cts, sp, sid)); + return 1; /* Need GC step. */ + } else { + GCcdata *cd; + CTSize sz; + copyval: /* Copy value. */ + sz = s->size; + lua_assert(sz != CTSIZE_INVALID); + /* Attributes are stripped, qualifiers are kept (but mostly ignored). */ + cd = lj_cdata_new(cts, ctype_typeid(cts, s), sz); + setcdataV(cts->L, o, cd); + memcpy(cdataptr(cd), sp, sz); + return 1; /* Need GC step. */ + } +} + +/* Convert bitfield to TValue. */ +int lj_cconv_tv_bf(CTState *cts, CType *s, TValue *o, uint8_t *sp) +{ + CTInfo info = s->info; + CTSize pos, bsz; + uint32_t val; + lua_assert(ctype_isbitfield(info)); + /* NYI: packed bitfields may cause misaligned reads. */ + switch (ctype_bitcsz(info)) { + case 4: val = *(uint32_t *)sp; break; + case 2: val = *(uint16_t *)sp; break; + case 1: val = *(uint8_t *)sp; break; + default: lua_assert(0); val = 0; break; + } + /* Check if a packed bitfield crosses a container boundary. */ + pos = ctype_bitpos(info); + bsz = ctype_bitbsz(info); + lua_assert(pos < 8*ctype_bitcsz(info)); + lua_assert(bsz > 0 && bsz <= 8*ctype_bitcsz(info)); + if (pos + bsz > 8*ctype_bitcsz(info)) + lj_err_caller(cts->L, LJ_ERR_FFI_NYIPACKBIT); + if (!(info & CTF_BOOL)) { + CTSize shift = 32 - bsz; + if (!(info & CTF_UNSIGNED)) { + setintV(o, (int32_t)(val << (shift-pos)) >> shift); + } else { + val = (val << (shift-pos)) >> shift; + if (!LJ_DUALNUM || (int32_t)val < 0) + setnumV(o, (lua_Number)(uint32_t)val); + else + setintV(o, (int32_t)val); + } + } else { + lua_assert(bsz == 1); + setboolV(o, (val >> pos) & 1); + } + return 0; /* No GC step needed. */ +} + +/* -- TValue to C type conversion ----------------------------------------- */ + +/* Convert table to array. */ +static void cconv_array_tab(CTState *cts, CType *d, + uint8_t *dp, GCtab *t, CTInfo flags) +{ + int32_t i; + CType *dc = ctype_rawchild(cts, d); /* Array element type. */ + CTSize size = d->size, esize = dc->size, ofs = 0; + for (i = 0; ; i++) { + TValue *tv = (TValue *)lj_tab_getint(t, i); + if (!tv || tvisnil(tv)) { + if (i == 0) continue; /* Try again for 1-based tables. */ + break; /* Stop at first nil. */ + } + if (ofs >= size) + cconv_err_initov(cts, d); + lj_cconv_ct_tv(cts, dc, dp + ofs, tv, flags); + ofs += esize; + } + if (size != CTSIZE_INVALID) { /* Only fill up arrays with known size. */ + if (ofs == esize) { /* Replicate a single element. */ + for (; ofs < size; ofs += esize) memcpy(dp + ofs, dp, esize); + } else { /* Otherwise fill the remainder with zero. */ + memset(dp + ofs, 0, size - ofs); + } + } +} + +/* Convert table to sub-struct/union. */ +static void cconv_substruct_tab(CTState *cts, CType *d, uint8_t *dp, + GCtab *t, int32_t *ip, CTInfo flags) +{ + CTypeID id = d->sib; + while (id) { + CType *df = ctype_get(cts, id); + id = df->sib; + if (ctype_isfield(df->info) || ctype_isbitfield(df->info)) { + TValue *tv; + int32_t i = *ip, iz = i; + if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ + if (i >= 0) { + retry: + tv = (TValue *)lj_tab_getint(t, i); + if (!tv || tvisnil(tv)) { + if (i == 0) { i = 1; goto retry; } /* 1-based tables. */ + if (iz == 0) { *ip = i = -1; goto tryname; } /* Init named fields. */ + break; /* Stop at first nil. */ + } + *ip = i + 1; + } else { + tryname: + tv = (TValue *)lj_tab_getstr(t, gco2str(gcref(df->name))); + if (!tv || tvisnil(tv)) continue; + } + if (ctype_isfield(df->info)) + lj_cconv_ct_tv(cts, ctype_rawchild(cts, df), dp+df->size, tv, flags); + else + lj_cconv_bf_tv(cts, df, dp+df->size, tv); + if ((d->info & CTF_UNION)) break; + } else if (ctype_isxattrib(df->info, CTA_SUBTYPE)) { + cconv_substruct_tab(cts, ctype_rawchild(cts, df), + dp+df->size, t, ip, flags); + } /* Ignore all other entries in the chain. */ + } +} + +/* Convert table to struct/union. */ +static void cconv_struct_tab(CTState *cts, CType *d, + uint8_t *dp, GCtab *t, CTInfo flags) +{ + int32_t i = 0; + memset(dp, 0, d->size); /* Much simpler to clear the struct first. */ + cconv_substruct_tab(cts, d, dp, t, &i, flags); +} + +/* Convert TValue to C type. Caveat: expects to get the raw CType! */ +void lj_cconv_ct_tv(CTState *cts, CType *d, + uint8_t *dp, TValue *o, CTInfo flags) +{ + CTypeID sid = CTID_P_VOID; + CType *s; + void *tmpptr; + uint8_t tmpbool, *sp = (uint8_t *)&tmpptr; + if (LJ_LIKELY(tvisint(o))) { + sp = (uint8_t *)&o->i; + sid = CTID_INT32; + flags |= CCF_FROMTV; + } else if (LJ_LIKELY(tvisnum(o))) { + sp = (uint8_t *)&o->n; + sid = CTID_DOUBLE; + flags |= CCF_FROMTV; + } else if (tviscdata(o)) { + sp = cdataptr(cdataV(o)); + sid = cdataV(o)->ctypeid; + s = ctype_get(cts, sid); + if (ctype_isref(s->info)) { /* Resolve reference for value. */ + lua_assert(s->size == CTSIZE_PTR); + sp = *(void **)sp; + sid = ctype_cid(s->info); + } + s = ctype_raw(cts, sid); + if (ctype_isfunc(s->info)) { + sid = lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|sid), CTSIZE_PTR); + } else { + if (ctype_isenum(s->info)) s = ctype_child(cts, s); + goto doconv; + } + } else if (tvisstr(o)) { + GCstr *str = strV(o); + if (ctype_isenum(d->info)) { /* Match string against enum constant. */ + CTSize ofs; + CType *cct = lj_ctype_getfield(cts, d, str, &ofs); + if (!cct || !ctype_isconstval(cct->info)) + goto err_conv; + lua_assert(d->size == 4); + sp = (uint8_t *)&cct->size; + sid = ctype_cid(cct->info); + } else if (ctype_isrefarray(d->info)) { /* Copy string to array. */ + CType *dc = ctype_rawchild(cts, d); + CTSize sz = str->len+1; + if (!ctype_isinteger(dc->info) || dc->size != 1) + goto err_conv; + if (d->size != 0 && d->size < sz) + sz = d->size; + memcpy(dp, strdata(str), sz); + return; + } else { /* Otherwise pass it as a const char[]. */ + sp = (uint8_t *)strdata(str); + sid = CTID_A_CCHAR; + flags |= CCF_FROMTV; + } + } else if (tvistab(o)) { + if (ctype_isarray(d->info)) { + cconv_array_tab(cts, d, dp, tabV(o), flags); + return; + } else if (ctype_isstruct(d->info)) { + cconv_struct_tab(cts, d, dp, tabV(o), flags); + return; + } else { + goto err_conv; + } + } else if (tvisbool(o)) { + tmpbool = boolV(o); + sp = &tmpbool; + sid = CTID_BOOL; + } else if (tvisnil(o)) { + tmpptr = (void *)0; + flags |= CCF_FROMTV; + } else if (tvisudata(o)) { + GCudata *ud = udataV(o); + tmpptr = uddata(ud); + if (ud->udtype == UDTYPE_IO_FILE) + tmpptr = *(void **)tmpptr; + } else if (tvislightud(o)) { + tmpptr = lightudV(o); + } else if (tvisfunc(o)) { + void *p = lj_ccallback_new(cts, d, funcV(o)); + if (p) { + *(void **)dp = p; + return; + } + goto err_conv; + } else { + err_conv: + cconv_err_convtv(cts, d, o, flags); + } + s = ctype_get(cts, sid); +doconv: + if (ctype_isenum(d->info)) d = ctype_child(cts, d); + lj_cconv_ct_ct(cts, d, s, dp, sp, flags); +} + +/* Convert TValue to bitfield. */ +void lj_cconv_bf_tv(CTState *cts, CType *d, uint8_t *dp, TValue *o) +{ + CTInfo info = d->info; + CTSize pos, bsz; + uint32_t val, mask; + lua_assert(ctype_isbitfield(info)); + if ((info & CTF_BOOL)) { + uint8_t tmpbool; + lua_assert(ctype_bitbsz(info) == 1); + lj_cconv_ct_tv(cts, ctype_get(cts, CTID_BOOL), &tmpbool, o, 0); + val = tmpbool; + } else { + CTypeID did = (info & CTF_UNSIGNED) ? CTID_UINT32 : CTID_INT32; + lj_cconv_ct_tv(cts, ctype_get(cts, did), (uint8_t *)&val, o, 0); + } + pos = ctype_bitpos(info); + bsz = ctype_bitbsz(info); + lua_assert(pos < 8*ctype_bitcsz(info)); + lua_assert(bsz > 0 && bsz <= 8*ctype_bitcsz(info)); + /* Check if a packed bitfield crosses a container boundary. */ + if (pos + bsz > 8*ctype_bitcsz(info)) + lj_err_caller(cts->L, LJ_ERR_FFI_NYIPACKBIT); + mask = ((1u << bsz) - 1u) << pos; + val = (val << pos) & mask; + /* NYI: packed bitfields may cause misaligned reads/writes. */ + switch (ctype_bitcsz(info)) { + case 4: *(uint32_t *)dp = (*(uint32_t *)dp & ~mask) | (uint32_t)val; break; + case 2: *(uint16_t *)dp = (*(uint16_t *)dp & ~mask) | (uint16_t)val; break; + case 1: *(uint8_t *)dp = (*(uint8_t *)dp & ~mask) | (uint8_t)val; break; + default: lua_assert(0); break; + } +} + +/* -- Initialize C type with TValues -------------------------------------- */ + +/* Initialize an array with TValues. */ +static void cconv_array_init(CTState *cts, CType *d, CTSize sz, uint8_t *dp, + TValue *o, MSize len) +{ + CType *dc = ctype_rawchild(cts, d); /* Array element type. */ + CTSize ofs, esize = dc->size; + MSize i; + if (len*esize > sz) + cconv_err_initov(cts, d); + for (i = 0, ofs = 0; i < len; i++, ofs += esize) + lj_cconv_ct_tv(cts, dc, dp + ofs, o + i, 0); + if (ofs == esize) { /* Replicate a single element. */ + for (; ofs < sz; ofs += esize) memcpy(dp + ofs, dp, esize); + } else { /* Otherwise fill the remainder with zero. */ + memset(dp + ofs, 0, sz - ofs); + } +} + +/* Initialize a sub-struct/union with TValues. */ +static void cconv_substruct_init(CTState *cts, CType *d, uint8_t *dp, + TValue *o, MSize len, MSize *ip) +{ + CTypeID id = d->sib; + while (id) { + CType *df = ctype_get(cts, id); + id = df->sib; + if (ctype_isfield(df->info) || ctype_isbitfield(df->info)) { + MSize i = *ip; + if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ + if (i >= len) break; + *ip = i + 1; + if (ctype_isfield(df->info)) + lj_cconv_ct_tv(cts, ctype_rawchild(cts, df), dp+df->size, o + i, 0); + else + lj_cconv_bf_tv(cts, df, dp+df->size, o + i); + if ((d->info & CTF_UNION)) break; + } else if (ctype_isxattrib(df->info, CTA_SUBTYPE)) { + cconv_substruct_init(cts, ctype_rawchild(cts, df), + dp+df->size, o, len, ip); + if ((d->info & CTF_UNION)) break; + } /* Ignore all other entries in the chain. */ + } +} + +/* Initialize a struct/union with TValues. */ +static void cconv_struct_init(CTState *cts, CType *d, CTSize sz, uint8_t *dp, + TValue *o, MSize len) +{ + MSize i = 0; + memset(dp, 0, sz); /* Much simpler to clear the struct first. */ + cconv_substruct_init(cts, d, dp, o, len, &i); + if (i < len) + cconv_err_initov(cts, d); +} + +/* Check whether to use a multi-value initializer. +** This is true if an aggregate is to be initialized with a value. +** Valarrays are treated as values here so ct_tv handles (V|C, I|F). +*/ +int lj_cconv_multi_init(CTState *cts, CType *d, TValue *o) +{ + if (!(ctype_isrefarray(d->info) || ctype_isstruct(d->info))) + return 0; /* Destination is not an aggregate. */ + if (tvistab(o) || (tvisstr(o) && !ctype_isstruct(d->info))) + return 0; /* Initializer is not a value. */ + if (tviscdata(o) && lj_ctype_rawref(cts, cdataV(o)->ctypeid) == d) + return 0; /* Source and destination are identical aggregates. */ + return 1; /* Otherwise the initializer is a value. */ +} + +/* Initialize C type with TValues. Caveat: expects to get the raw CType! */ +void lj_cconv_ct_init(CTState *cts, CType *d, CTSize sz, + uint8_t *dp, TValue *o, MSize len) +{ + if (len == 0) + memset(dp, 0, sz); + else if (len == 1 && !lj_cconv_multi_init(cts, d, o)) + lj_cconv_ct_tv(cts, d, dp, o, 0); + else if (ctype_isarray(d->info)) /* Also handles valarray init with len>1. */ + cconv_array_init(cts, d, sz, dp, o, len); + else if (ctype_isstruct(d->info)) + cconv_struct_init(cts, d, sz, dp, o, len); + else + cconv_err_initov(cts, d); +} + +#endif + +``` + +`include/luajit-2.0.5/src/lj_cconv.h`: + +```h +/* +** C type conversions. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CCONV_H +#define _LJ_CCONV_H + +#include "lj_obj.h" +#include "lj_ctype.h" + +#if LJ_HASFFI + +/* Compressed C type index. ORDER CCX. */ +enum { + CCX_B, /* Bool. */ + CCX_I, /* Integer. */ + CCX_F, /* Floating-point number. */ + CCX_C, /* Complex. */ + CCX_V, /* Vector. */ + CCX_P, /* Pointer. */ + CCX_A, /* Refarray. */ + CCX_S /* Struct/union. */ +}; + +/* Convert C type info to compressed C type index. ORDER CT. ORDER CCX. */ +static LJ_AINLINE uint32_t cconv_idx(CTInfo info) +{ + uint32_t idx = ((info >> 26) & 15u); /* Dispatch bits. */ + lua_assert(ctype_type(info) <= CT_MAYCONVERT); +#if LJ_64 + idx = ((uint32_t)(U64x(f436fff5,fff7f021) >> 4*idx) & 15u); +#else + idx = (((idx < 8 ? 0xfff7f021u : 0xf436fff5) >> 4*(idx & 7u)) & 15u); +#endif + lua_assert(idx < 8); + return idx; +} + +#define cconv_idx2(dinfo, sinfo) \ + ((cconv_idx((dinfo)) << 3) + cconv_idx((sinfo))) + +#define CCX(dst, src) ((CCX_##dst << 3) + CCX_##src) + +/* Conversion flags. */ +#define CCF_CAST 0x00000001u +#define CCF_FROMTV 0x00000002u +#define CCF_SAME 0x00000004u +#define CCF_IGNQUAL 0x00000008u + +#define CCF_ARG_SHIFT 8 +#define CCF_ARG(n) ((n) << CCF_ARG_SHIFT) +#define CCF_GETARG(f) ((f) >> CCF_ARG_SHIFT) + +LJ_FUNC int lj_cconv_compatptr(CTState *cts, CType *d, CType *s, CTInfo flags); +LJ_FUNC void lj_cconv_ct_ct(CTState *cts, CType *d, CType *s, + uint8_t *dp, uint8_t *sp, CTInfo flags); +LJ_FUNC int lj_cconv_tv_ct(CTState *cts, CType *s, CTypeID sid, + TValue *o, uint8_t *sp); +LJ_FUNC int lj_cconv_tv_bf(CTState *cts, CType *s, TValue *o, uint8_t *sp); +LJ_FUNC void lj_cconv_ct_tv(CTState *cts, CType *d, + uint8_t *dp, TValue *o, CTInfo flags); +LJ_FUNC void lj_cconv_bf_tv(CTState *cts, CType *d, uint8_t *dp, TValue *o); +LJ_FUNC int lj_cconv_multi_init(CTState *cts, CType *d, TValue *o); +LJ_FUNC void lj_cconv_ct_init(CTState *cts, CType *d, CTSize sz, + uint8_t *dp, TValue *o, MSize len); + +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_cdata.c`: + +```c +/* +** C data management. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_ctype.h" +#include "lj_cconv.h" +#include "lj_cdata.h" + +/* -- C data allocation --------------------------------------------------- */ + +/* Allocate a new C data object holding a reference to another object. */ +GCcdata *lj_cdata_newref(CTState *cts, const void *p, CTypeID id) +{ + CTypeID refid = lj_ctype_intern(cts, CTINFO_REF(id), CTSIZE_PTR); + GCcdata *cd = lj_cdata_new(cts, refid, CTSIZE_PTR); + *(const void **)cdataptr(cd) = p; + return cd; +} + +/* Allocate variable-sized or specially aligned C data object. */ +GCcdata *lj_cdata_newv(CTState *cts, CTypeID id, CTSize sz, CTSize align) +{ + global_State *g; + MSize extra = sizeof(GCcdataVar) + sizeof(GCcdata) + + (align > CT_MEMALIGN ? (1u<L, extra + sz, char); + uintptr_t adata = (uintptr_t)p + sizeof(GCcdataVar) + sizeof(GCcdata); + uintptr_t almask = (1u << align) - 1u; + GCcdata *cd = (GCcdata *)(((adata + almask) & ~almask) - sizeof(GCcdata)); + lua_assert((char *)cd - p < 65536); + cdatav(cd)->offset = (uint16_t)((char *)cd - p); + cdatav(cd)->extra = extra; + cdatav(cd)->len = sz; + g = cts->g; + setgcrefr(cd->nextgc, g->gc.root); + setgcref(g->gc.root, obj2gco(cd)); + newwhite(g, obj2gco(cd)); + cd->marked |= 0x80; + cd->gct = ~LJ_TCDATA; + cd->ctypeid = id; + return cd; +} + +/* Free a C data object. */ +void LJ_FASTCALL lj_cdata_free(global_State *g, GCcdata *cd) +{ + if (LJ_UNLIKELY(cd->marked & LJ_GC_CDATA_FIN)) { + GCobj *root; + makewhite(g, obj2gco(cd)); + markfinalized(obj2gco(cd)); + if ((root = gcref(g->gc.mmudata)) != NULL) { + setgcrefr(cd->nextgc, root->gch.nextgc); + setgcref(root->gch.nextgc, obj2gco(cd)); + setgcref(g->gc.mmudata, obj2gco(cd)); + } else { + setgcref(cd->nextgc, obj2gco(cd)); + setgcref(g->gc.mmudata, obj2gco(cd)); + } + } else if (LJ_LIKELY(!cdataisv(cd))) { + CType *ct = ctype_raw(ctype_ctsG(g), cd->ctypeid); + CTSize sz = ctype_hassize(ct->info) ? ct->size : CTSIZE_PTR; + lua_assert(ctype_hassize(ct->info) || ctype_isfunc(ct->info) || + ctype_isextern(ct->info)); + lj_mem_free(g, cd, sizeof(GCcdata) + sz); + } else { + lj_mem_free(g, memcdatav(cd), sizecdatav(cd)); + } +} + +TValue * LJ_FASTCALL lj_cdata_setfin(lua_State *L, GCcdata *cd) +{ + global_State *g = G(L); + GCtab *t = ctype_ctsG(g)->finalizer; + if (gcref(t->metatable)) { + /* Add cdata to finalizer table, if still enabled. */ + TValue *tv, tmp; + setcdataV(L, &tmp, cd); + lj_gc_anybarriert(L, t); + tv = lj_tab_set(L, t, &tmp); + cd->marked |= LJ_GC_CDATA_FIN; + return tv; + } else { + /* Otherwise return dummy TValue. */ + return &g->tmptv; + } +} + +/* -- C data indexing ----------------------------------------------------- */ + +/* Index C data by a TValue. Return CType and pointer. */ +CType *lj_cdata_index(CTState *cts, GCcdata *cd, cTValue *key, uint8_t **pp, + CTInfo *qual) +{ + uint8_t *p = (uint8_t *)cdataptr(cd); + CType *ct = ctype_get(cts, cd->ctypeid); + ptrdiff_t idx; + + /* Resolve reference for cdata object. */ + if (ctype_isref(ct->info)) { + lua_assert(ct->size == CTSIZE_PTR); + p = *(uint8_t **)p; + ct = ctype_child(cts, ct); + } + +collect_attrib: + /* Skip attributes and collect qualifiers. */ + while (ctype_isattrib(ct->info)) { + if (ctype_attrib(ct->info) == CTA_QUAL) *qual |= ct->size; + ct = ctype_child(cts, ct); + } + lua_assert(!ctype_isref(ct->info)); /* Interning rejects refs to refs. */ + + if (tvisint(key)) { + idx = (ptrdiff_t)intV(key); + goto integer_key; + } else if (tvisnum(key)) { /* Numeric key. */ + idx = LJ_64 ? (ptrdiff_t)numV(key) : (ptrdiff_t)lj_num2int(numV(key)); + integer_key: + if (ctype_ispointer(ct->info)) { + CTSize sz = lj_ctype_size(cts, ctype_cid(ct->info)); /* Element size. */ + if (sz == CTSIZE_INVALID) + lj_err_caller(cts->L, LJ_ERR_FFI_INVSIZE); + if (ctype_isptr(ct->info)) { + p = (uint8_t *)cdata_getptr(p, ct->size); + } else if ((ct->info & (CTF_VECTOR|CTF_COMPLEX))) { + if ((ct->info & CTF_COMPLEX)) idx &= 1; + *qual |= CTF_CONST; /* Valarray elements are constant. */ + } + *pp = p + idx*(int32_t)sz; + return ct; + } + } else if (tviscdata(key)) { /* Integer cdata key. */ + GCcdata *cdk = cdataV(key); + CType *ctk = ctype_raw(cts, cdk->ctypeid); + if (ctype_isenum(ctk->info)) ctk = ctype_child(cts, ctk); + if (ctype_isinteger(ctk->info)) { + lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ctk, + (uint8_t *)&idx, cdataptr(cdk), 0); + goto integer_key; + } + } else if (tvisstr(key)) { /* String key. */ + GCstr *name = strV(key); + if (ctype_isstruct(ct->info)) { + CTSize ofs; + CType *fct = lj_ctype_getfieldq(cts, ct, name, &ofs, qual); + if (fct) { + *pp = p + ofs; + return fct; + } + } else if (ctype_iscomplex(ct->info)) { + if (name->len == 2) { + *qual |= CTF_CONST; /* Complex fields are constant. */ + if (strdata(name)[0] == 'r' && strdata(name)[1] == 'e') { + *pp = p; + return ct; + } else if (strdata(name)[0] == 'i' && strdata(name)[1] == 'm') { + *pp = p + (ct->size >> 1); + return ct; + } + } + } else if (cd->ctypeid == CTID_CTYPEID) { + /* Allow indexing a (pointer to) struct constructor to get constants. */ + CType *sct = ctype_raw(cts, *(CTypeID *)p); + if (ctype_isptr(sct->info)) + sct = ctype_rawchild(cts, sct); + if (ctype_isstruct(sct->info)) { + CTSize ofs; + CType *fct = lj_ctype_getfield(cts, sct, name, &ofs); + if (fct && ctype_isconstval(fct->info)) + return fct; + } + ct = sct; /* Allow resolving metamethods for constructors, too. */ + } + } + if (ctype_isptr(ct->info)) { /* Automatically perform '->'. */ + if (ctype_isstruct(ctype_rawchild(cts, ct)->info)) { + p = (uint8_t *)cdata_getptr(p, ct->size); + ct = ctype_child(cts, ct); + goto collect_attrib; + } + } + *qual |= 1; /* Lookup failed. */ + return ct; /* But return the resolved raw type. */ +} + +/* -- C data getters ------------------------------------------------------ */ + +/* Get constant value and convert to TValue. */ +static void cdata_getconst(CTState *cts, TValue *o, CType *ct) +{ + CType *ctt = ctype_child(cts, ct); + lua_assert(ctype_isinteger(ctt->info) && ctt->size <= 4); + /* Constants are already zero-extended/sign-extended to 32 bits. */ + if ((ctt->info & CTF_UNSIGNED) && (int32_t)ct->size < 0) + setnumV(o, (lua_Number)(uint32_t)ct->size); + else + setintV(o, (int32_t)ct->size); +} + +/* Get C data value and convert to TValue. */ +int lj_cdata_get(CTState *cts, CType *s, TValue *o, uint8_t *sp) +{ + CTypeID sid; + + if (ctype_isconstval(s->info)) { + cdata_getconst(cts, o, s); + return 0; /* No GC step needed. */ + } else if (ctype_isbitfield(s->info)) { + return lj_cconv_tv_bf(cts, s, o, sp); + } + + /* Get child type of pointer/array/field. */ + lua_assert(ctype_ispointer(s->info) || ctype_isfield(s->info)); + sid = ctype_cid(s->info); + s = ctype_get(cts, sid); + + /* Resolve reference for field. */ + if (ctype_isref(s->info)) { + lua_assert(s->size == CTSIZE_PTR); + sp = *(uint8_t **)sp; + sid = ctype_cid(s->info); + s = ctype_get(cts, sid); + } + + /* Skip attributes. */ + while (ctype_isattrib(s->info)) + s = ctype_child(cts, s); + + return lj_cconv_tv_ct(cts, s, sid, o, sp); +} + +/* -- C data setters ------------------------------------------------------ */ + +/* Convert TValue and set C data value. */ +void lj_cdata_set(CTState *cts, CType *d, uint8_t *dp, TValue *o, CTInfo qual) +{ + if (ctype_isconstval(d->info)) { + goto err_const; + } else if (ctype_isbitfield(d->info)) { + if (((d->info|qual) & CTF_CONST)) goto err_const; + lj_cconv_bf_tv(cts, d, dp, o); + return; + } + + /* Get child type of pointer/array/field. */ + lua_assert(ctype_ispointer(d->info) || ctype_isfield(d->info)); + d = ctype_child(cts, d); + + /* Resolve reference for field. */ + if (ctype_isref(d->info)) { + lua_assert(d->size == CTSIZE_PTR); + dp = *(uint8_t **)dp; + d = ctype_child(cts, d); + } + + /* Skip attributes and collect qualifiers. */ + for (;;) { + if (ctype_isattrib(d->info)) { + if (ctype_attrib(d->info) == CTA_QUAL) qual |= d->size; + } else { + break; + } + d = ctype_child(cts, d); + } + + lua_assert(ctype_hassize(d->info) && !ctype_isvoid(d->info)); + + if (((d->info|qual) & CTF_CONST)) { + err_const: + lj_err_caller(cts->L, LJ_ERR_FFI_WRCONST); + } + + lj_cconv_ct_tv(cts, d, dp, o, 0); +} + +#endif + +``` + +`include/luajit-2.0.5/src/lj_cdata.h`: + +```h +/* +** C data management. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CDATA_H +#define _LJ_CDATA_H + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_ctype.h" + +#if LJ_HASFFI + +/* Get C data pointer. */ +static LJ_AINLINE void *cdata_getptr(void *p, CTSize sz) +{ + if (LJ_64 && sz == 4) { /* Support 32 bit pointers on 64 bit targets. */ + return ((void *)(uintptr_t)*(uint32_t *)p); + } else { + lua_assert(sz == CTSIZE_PTR); + return *(void **)p; + } +} + +/* Set C data pointer. */ +static LJ_AINLINE void cdata_setptr(void *p, CTSize sz, const void *v) +{ + if (LJ_64 && sz == 4) { /* Support 32 bit pointers on 64 bit targets. */ + *(uint32_t *)p = (uint32_t)(uintptr_t)v; + } else { + lua_assert(sz == CTSIZE_PTR); + *(void **)p = (void *)v; + } +} + +/* Allocate fixed-size C data object. */ +static LJ_AINLINE GCcdata *lj_cdata_new(CTState *cts, CTypeID id, CTSize sz) +{ + GCcdata *cd; +#ifdef LUA_USE_ASSERT + CType *ct = ctype_raw(cts, id); + lua_assert((ctype_hassize(ct->info) ? ct->size : CTSIZE_PTR) == sz); +#endif + cd = (GCcdata *)lj_mem_newgco(cts->L, sizeof(GCcdata) + sz); + cd->gct = ~LJ_TCDATA; + cd->ctypeid = ctype_check(cts, id); + return cd; +} + +/* Variant which works without a valid CTState. */ +static LJ_AINLINE GCcdata *lj_cdata_new_(lua_State *L, CTypeID id, CTSize sz) +{ + GCcdata *cd = (GCcdata *)lj_mem_newgco(L, sizeof(GCcdata) + sz); + cd->gct = ~LJ_TCDATA; + cd->ctypeid = id; + return cd; +} + +LJ_FUNC GCcdata *lj_cdata_newref(CTState *cts, const void *pp, CTypeID id); +LJ_FUNC GCcdata *lj_cdata_newv(CTState *cts, CTypeID id, CTSize sz, + CTSize align); + +LJ_FUNC void LJ_FASTCALL lj_cdata_free(global_State *g, GCcdata *cd); +LJ_FUNCA TValue * LJ_FASTCALL lj_cdata_setfin(lua_State *L, GCcdata *cd); + +LJ_FUNC CType *lj_cdata_index(CTState *cts, GCcdata *cd, cTValue *key, + uint8_t **pp, CTInfo *qual); +LJ_FUNC int lj_cdata_get(CTState *cts, CType *s, TValue *o, uint8_t *sp); +LJ_FUNC void lj_cdata_set(CTState *cts, CType *d, uint8_t *dp, TValue *o, + CTInfo qual); + +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_char.c`: + +```c +/* +** Character types. +** Donated to the public domain. +** +** This is intended to replace the problematic libc single-byte NLS functions. +** These just don't make sense anymore with UTF-8 locales becoming the norm +** on POSIX systems. It never worked too well on Windows systems since hardly +** anyone bothered to call setlocale(). +** +** This table is hardcoded for ASCII. Identifiers include the characters +** 128-255, too. This allows for the use of all non-ASCII chars as identifiers +** in the lexer. This is a broad definition, but works well in practice +** for both UTF-8 locales and most single-byte locales (such as ISO-8859-*). +** +** If you really need proper character types for UTF-8 strings, please use +** an add-on library such as slnunicode: http://luaforge.net/projects/sln/ +*/ + +#define lj_char_c +#define LUA_CORE + +#include "lj_char.h" + +LJ_DATADEF const uint8_t lj_char_bits[257] = { + 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 152,152,152,152,152,152,152,152,152,152, 4, 4, 4, 4, 4, 4, + 4,176,176,176,176,176,176,160,160,160,160,160,160,160,160,160, + 160,160,160,160,160,160,160,160,160,160,160, 4, 4, 4, 4,132, + 4,208,208,208,208,208,208,192,192,192,192,192,192,192,192,192, + 192,192,192,192,192,192,192,192,192,192,192, 4, 4, 4, 4, 1, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128 +}; + + +``` + +`include/luajit-2.0.5/src/lj_char.h`: + +```h +/* +** Character types. +** Donated to the public domain. +*/ + +#ifndef _LJ_CHAR_H +#define _LJ_CHAR_H + +#include "lj_def.h" + +#define LJ_CHAR_CNTRL 0x01 +#define LJ_CHAR_SPACE 0x02 +#define LJ_CHAR_PUNCT 0x04 +#define LJ_CHAR_DIGIT 0x08 +#define LJ_CHAR_XDIGIT 0x10 +#define LJ_CHAR_UPPER 0x20 +#define LJ_CHAR_LOWER 0x40 +#define LJ_CHAR_IDENT 0x80 +#define LJ_CHAR_ALPHA (LJ_CHAR_LOWER|LJ_CHAR_UPPER) +#define LJ_CHAR_ALNUM (LJ_CHAR_ALPHA|LJ_CHAR_DIGIT) +#define LJ_CHAR_GRAPH (LJ_CHAR_ALNUM|LJ_CHAR_PUNCT) + +/* Only pass -1 or 0..255 to these macros. Never pass a signed char! */ +#define lj_char_isa(c, t) ((lj_char_bits+1)[(c)] & t) +#define lj_char_iscntrl(c) lj_char_isa((c), LJ_CHAR_CNTRL) +#define lj_char_isspace(c) lj_char_isa((c), LJ_CHAR_SPACE) +#define lj_char_ispunct(c) lj_char_isa((c), LJ_CHAR_PUNCT) +#define lj_char_isdigit(c) lj_char_isa((c), LJ_CHAR_DIGIT) +#define lj_char_isxdigit(c) lj_char_isa((c), LJ_CHAR_XDIGIT) +#define lj_char_isupper(c) lj_char_isa((c), LJ_CHAR_UPPER) +#define lj_char_islower(c) lj_char_isa((c), LJ_CHAR_LOWER) +#define lj_char_isident(c) lj_char_isa((c), LJ_CHAR_IDENT) +#define lj_char_isalpha(c) lj_char_isa((c), LJ_CHAR_ALPHA) +#define lj_char_isalnum(c) lj_char_isa((c), LJ_CHAR_ALNUM) +#define lj_char_isgraph(c) lj_char_isa((c), LJ_CHAR_GRAPH) + +#define lj_char_toupper(c) ((c) - (lj_char_islower(c) >> 1)) +#define lj_char_tolower(c) ((c) + lj_char_isupper(c)) + +LJ_DATA const uint8_t lj_char_bits[257]; + +#endif + +``` + +`include/luajit-2.0.5/src/lj_clib.c`: + +```c +/* +** FFI C library loader. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_tab.h" +#include "lj_str.h" +#include "lj_udata.h" +#include "lj_ctype.h" +#include "lj_cconv.h" +#include "lj_cdata.h" +#include "lj_clib.h" + +/* -- OS-specific functions ----------------------------------------------- */ + +#if LJ_TARGET_DLOPEN + +#include +#include + +#if defined(RTLD_DEFAULT) +#define CLIB_DEFHANDLE RTLD_DEFAULT +#elif LJ_TARGET_OSX || LJ_TARGET_BSD +#define CLIB_DEFHANDLE ((void *)(intptr_t)-2) +#else +#define CLIB_DEFHANDLE NULL +#endif + +LJ_NORET LJ_NOINLINE static void clib_error_(lua_State *L) +{ + lj_err_callermsg(L, dlerror()); +} + +#define clib_error(L, fmt, name) clib_error_(L) + +#if LJ_TARGET_CYGWIN +#define CLIB_SOPREFIX "cyg" +#else +#define CLIB_SOPREFIX "lib" +#endif + +#if LJ_TARGET_OSX +#define CLIB_SOEXT "%s.dylib" +#elif LJ_TARGET_CYGWIN +#define CLIB_SOEXT "%s.dll" +#else +#define CLIB_SOEXT "%s.so" +#endif + +static const char *clib_extname(lua_State *L, const char *name) +{ + if (!strchr(name, '/') +#if LJ_TARGET_CYGWIN + && !strchr(name, '\\') +#endif + ) { + if (!strchr(name, '.')) { + name = lj_str_pushf(L, CLIB_SOEXT, name); + L->top--; +#if LJ_TARGET_CYGWIN + } else { + return name; +#endif + } + if (!(name[0] == CLIB_SOPREFIX[0] && name[1] == CLIB_SOPREFIX[1] && + name[2] == CLIB_SOPREFIX[2])) { + name = lj_str_pushf(L, CLIB_SOPREFIX "%s", name); + L->top--; + } + } + return name; +} + +/* Check for a recognized ld script line. */ +static const char *clib_check_lds(lua_State *L, const char *buf) +{ + char *p, *e; + if ((!strncmp(buf, "GROUP", 5) || !strncmp(buf, "INPUT", 5)) && + (p = strchr(buf, '('))) { + while (*++p == ' ') ; + for (e = p; *e && *e != ' ' && *e != ')'; e++) ; + return strdata(lj_str_new(L, p, e-p)); + } + return NULL; +} + +/* Quick and dirty solution to resolve shared library name from ld script. */ +static const char *clib_resolve_lds(lua_State *L, const char *name) +{ + FILE *fp = fopen(name, "r"); + const char *p = NULL; + if (fp) { + char buf[256]; + if (fgets(buf, sizeof(buf), fp)) { + if (!strncmp(buf, "/* GNU ld script", 16)) { /* ld script magic? */ + while (fgets(buf, sizeof(buf), fp)) { /* Check all lines. */ + p = clib_check_lds(L, buf); + if (p) break; + } + } else { /* Otherwise check only the first line. */ + p = clib_check_lds(L, buf); + } + } + fclose(fp); + } + return p; +} + +static void *clib_loadlib(lua_State *L, const char *name, int global) +{ + void *h = dlopen(clib_extname(L, name), + RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); + if (!h) { + const char *e, *err = dlerror(); + if (*err == '/' && (e = strchr(err, ':')) && + (name = clib_resolve_lds(L, strdata(lj_str_new(L, err, e-err))))) { + h = dlopen(name, RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); + if (h) return h; + err = dlerror(); + } + lj_err_callermsg(L, err); + } + return h; +} + +static void clib_unloadlib(CLibrary *cl) +{ + if (cl->handle && cl->handle != CLIB_DEFHANDLE) + dlclose(cl->handle); +} + +static void *clib_getsym(CLibrary *cl, const char *name) +{ + void *p = dlsym(cl->handle, name); + return p; +} + +#elif LJ_TARGET_WINDOWS + +#define WIN32_LEAN_AND_MEAN +#include + +#ifndef GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS +#define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 4 +#define GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT 2 +BOOL WINAPI GetModuleHandleExA(DWORD, LPCSTR, HMODULE*); +#endif + +#define CLIB_DEFHANDLE ((void *)-1) + +/* Default libraries. */ +enum { + CLIB_HANDLE_EXE, + CLIB_HANDLE_DLL, + CLIB_HANDLE_CRT, + CLIB_HANDLE_KERNEL32, + CLIB_HANDLE_USER32, + CLIB_HANDLE_GDI32, + CLIB_HANDLE_MAX +}; + +static void *clib_def_handle[CLIB_HANDLE_MAX]; + +LJ_NORET LJ_NOINLINE static void clib_error(lua_State *L, const char *fmt, + const char *name) +{ + DWORD err = GetLastError(); + char buf[128]; + if (!FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM, + NULL, err, 0, buf, sizeof(buf), NULL)) + buf[0] = '\0'; + lj_err_callermsg(L, lj_str_pushf(L, fmt, name, buf)); +} + +static int clib_needext(const char *s) +{ + while (*s) { + if (*s == '/' || *s == '\\' || *s == '.') return 0; + s++; + } + return 1; +} + +static const char *clib_extname(lua_State *L, const char *name) +{ + if (clib_needext(name)) { + name = lj_str_pushf(L, "%s.dll", name); + L->top--; + } + return name; +} + +static void *clib_loadlib(lua_State *L, const char *name, int global) +{ + DWORD oldwerr = GetLastError(); + void *h = (void *)LoadLibraryA(clib_extname(L, name)); + if (!h) clib_error(L, "cannot load module " LUA_QS ": %s", name); + SetLastError(oldwerr); + UNUSED(global); + return h; +} + +static void clib_unloadlib(CLibrary *cl) +{ + if (cl->handle == CLIB_DEFHANDLE) { + MSize i; + for (i = CLIB_HANDLE_KERNEL32; i < CLIB_HANDLE_MAX; i++) { + void *h = clib_def_handle[i]; + if (h) { + clib_def_handle[i] = NULL; + FreeLibrary((HINSTANCE)h); + } + } + } else if (cl->handle) { + FreeLibrary((HINSTANCE)cl->handle); + } +} + +static void *clib_getsym(CLibrary *cl, const char *name) +{ + void *p = NULL; + if (cl->handle == CLIB_DEFHANDLE) { /* Search default libraries. */ + MSize i; + for (i = 0; i < CLIB_HANDLE_MAX; i++) { + HINSTANCE h = (HINSTANCE)clib_def_handle[i]; + if (!(void *)h) { /* Resolve default library handles (once). */ + switch (i) { + case CLIB_HANDLE_EXE: GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, &h); break; + case CLIB_HANDLE_DLL: + GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (const char *)clib_def_handle, &h); + break; + case CLIB_HANDLE_CRT: + GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (const char *)&_fmode, &h); + break; + case CLIB_HANDLE_KERNEL32: h = LoadLibraryA("kernel32.dll"); break; + case CLIB_HANDLE_USER32: h = LoadLibraryA("user32.dll"); break; + case CLIB_HANDLE_GDI32: h = LoadLibraryA("gdi32.dll"); break; + } + if (!h) continue; + clib_def_handle[i] = (void *)h; + } + p = (void *)GetProcAddress(h, name); + if (p) break; + } + } else { + p = (void *)GetProcAddress((HINSTANCE)cl->handle, name); + } + return p; +} + +#else + +#define CLIB_DEFHANDLE NULL + +LJ_NORET LJ_NOINLINE static void clib_error(lua_State *L, const char *fmt, + const char *name) +{ + lj_err_callermsg(L, lj_str_pushf(L, fmt, name, "no support for this OS")); +} + +static void *clib_loadlib(lua_State *L, const char *name, int global) +{ + lj_err_callermsg(L, "no support for loading dynamic libraries for this OS"); + UNUSED(name); UNUSED(global); + return NULL; +} + +static void clib_unloadlib(CLibrary *cl) +{ + UNUSED(cl); +} + +static void *clib_getsym(CLibrary *cl, const char *name) +{ + UNUSED(cl); UNUSED(name); + return NULL; +} + +#endif + +/* -- C library indexing -------------------------------------------------- */ + +#if LJ_TARGET_X86 && LJ_ABI_WIN +/* Compute argument size for fastcall/stdcall functions. */ +static CTSize clib_func_argsize(CTState *cts, CType *ct) +{ + CTSize n = 0; + while (ct->sib) { + CType *d; + ct = ctype_get(cts, ct->sib); + if (ctype_isfield(ct->info)) { + d = ctype_rawchild(cts, ct); + n += ((d->size + 3) & ~3); + } + } + return n; +} +#endif + +/* Get redirected or mangled external symbol. */ +static const char *clib_extsym(CTState *cts, CType *ct, GCstr *name) +{ + if (ct->sib) { + CType *ctf = ctype_get(cts, ct->sib); + if (ctype_isxattrib(ctf->info, CTA_REDIR)) + return strdata(gco2str(gcref(ctf->name))); + } + return strdata(name); +} + +/* Index a C library by name. */ +TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name) +{ + TValue *tv = lj_tab_setstr(L, cl->cache, name); + if (LJ_UNLIKELY(tvisnil(tv))) { + CTState *cts = ctype_cts(L); + CType *ct; + CTypeID id = lj_ctype_getname(cts, &ct, name, CLNS_INDEX); + if (!id) + lj_err_callerv(L, LJ_ERR_FFI_NODECL, strdata(name)); + if (ctype_isconstval(ct->info)) { + CType *ctt = ctype_child(cts, ct); + lua_assert(ctype_isinteger(ctt->info) && ctt->size <= 4); + if ((ctt->info & CTF_UNSIGNED) && (int32_t)ct->size < 0) + setnumV(tv, (lua_Number)(uint32_t)ct->size); + else + setintV(tv, (int32_t)ct->size); + } else { + const char *sym = clib_extsym(cts, ct, name); +#if LJ_TARGET_WINDOWS + DWORD oldwerr = GetLastError(); +#endif + void *p = clib_getsym(cl, sym); + GCcdata *cd; + lua_assert(ctype_isfunc(ct->info) || ctype_isextern(ct->info)); +#if LJ_TARGET_X86 && LJ_ABI_WIN + /* Retry with decorated name for fastcall/stdcall functions. */ + if (!p && ctype_isfunc(ct->info)) { + CTInfo cconv = ctype_cconv(ct->info); + if (cconv == CTCC_FASTCALL || cconv == CTCC_STDCALL) { + CTSize sz = clib_func_argsize(cts, ct); + const char *symd = lj_str_pushf(L, + cconv == CTCC_FASTCALL ? "@%s@%d" : "_%s@%d", + sym, sz); + L->top--; + p = clib_getsym(cl, symd); + } + } +#endif + if (!p) + clib_error(L, "cannot resolve symbol " LUA_QS ": %s", sym); +#if LJ_TARGET_WINDOWS + SetLastError(oldwerr); +#endif + cd = lj_cdata_new(cts, id, CTSIZE_PTR); + *(void **)cdataptr(cd) = p; + setcdataV(L, tv, cd); + } + } + return tv; +} + +/* -- C library management ------------------------------------------------ */ + +/* Create a new CLibrary object and push it on the stack. */ +static CLibrary *clib_new(lua_State *L, GCtab *mt) +{ + GCtab *t = lj_tab_new(L, 0, 0); + GCudata *ud = lj_udata_new(L, sizeof(CLibrary), t); + CLibrary *cl = (CLibrary *)uddata(ud); + cl->cache = t; + ud->udtype = UDTYPE_FFI_CLIB; + /* NOBARRIER: The GCudata is new (marked white). */ + setgcref(ud->metatable, obj2gco(mt)); + setudataV(L, L->top++, ud); + return cl; +} + +/* Load a C library. */ +void lj_clib_load(lua_State *L, GCtab *mt, GCstr *name, int global) +{ + void *handle = clib_loadlib(L, strdata(name), global); + CLibrary *cl = clib_new(L, mt); + cl->handle = handle; +} + +/* Unload a C library. */ +void lj_clib_unload(CLibrary *cl) +{ + clib_unloadlib(cl); + cl->handle = NULL; +} + +/* Create the default C library object. */ +void lj_clib_default(lua_State *L, GCtab *mt) +{ + CLibrary *cl = clib_new(L, mt); + cl->handle = CLIB_DEFHANDLE; +} + +#endif + +``` + +`include/luajit-2.0.5/src/lj_clib.h`: + +```h +/* +** FFI C library loader. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CLIB_H +#define _LJ_CLIB_H + +#include "lj_obj.h" + +#if LJ_HASFFI + +/* Namespace for C library indexing. */ +#define CLNS_INDEX ((1u<env. */ +} CLibrary; + +LJ_FUNC TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name); +LJ_FUNC void lj_clib_load(lua_State *L, GCtab *mt, GCstr *name, int global); +LJ_FUNC void lj_clib_unload(CLibrary *cl); +LJ_FUNC void lj_clib_default(lua_State *L, GCtab *mt); + +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_cparse.c`: + +```c +/* +** C declaration parser. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_ctype.h" +#include "lj_cparse.h" +#include "lj_frame.h" +#include "lj_vm.h" +#include "lj_char.h" +#include "lj_strscan.h" + +/* +** Important note: this is NOT a validating C parser! This is a minimal +** C declaration parser, solely for use by the LuaJIT FFI. +** +** It ought to return correct results for properly formed C declarations, +** but it may accept some invalid declarations, too (and return nonsense). +** Also, it shows rather generic error messages to avoid unnecessary bloat. +** If in doubt, please check the input against your favorite C compiler. +*/ + +/* -- C lexer ------------------------------------------------------------- */ + +/* C lexer token names. */ +static const char *const ctoknames[] = { +#define CTOKSTR(name, str) str, +CTOKDEF(CTOKSTR) +#undef CTOKSTR + NULL +}; + +/* Forward declaration. */ +LJ_NORET static void cp_err(CPState *cp, ErrMsg em); + +static const char *cp_tok2str(CPState *cp, CPToken tok) +{ + lua_assert(tok < CTOK_FIRSTDECL); + if (tok > CTOK_OFS) + return ctoknames[tok-CTOK_OFS-1]; + else if (!lj_char_iscntrl(tok)) + return lj_str_pushf(cp->L, "%c", tok); + else + return lj_str_pushf(cp->L, "char(%d)", tok); +} + +/* End-of-line? */ +static LJ_AINLINE int cp_iseol(CPChar c) +{ + return (c == '\n' || c == '\r'); +} + +/* Peek next raw character. */ +static LJ_AINLINE CPChar cp_rawpeek(CPState *cp) +{ + return (CPChar)(uint8_t)(*cp->p); +} + +static LJ_NOINLINE CPChar cp_get_bs(CPState *cp); + +/* Get next character. */ +static LJ_AINLINE CPChar cp_get(CPState *cp) +{ + cp->c = (CPChar)(uint8_t)(*cp->p++); + if (LJ_LIKELY(cp->c != '\\')) return cp->c; + return cp_get_bs(cp); +} + +/* Transparently skip backslash-escaped line breaks. */ +static LJ_NOINLINE CPChar cp_get_bs(CPState *cp) +{ + CPChar c2, c = cp_rawpeek(cp); + if (!cp_iseol(c)) return cp->c; + cp->p++; + c2 = cp_rawpeek(cp); + if (cp_iseol(c2) && c2 != c) cp->p++; + cp->linenumber++; + return cp_get(cp); +} + +/* Grow save buffer. */ +static LJ_NOINLINE void cp_save_grow(CPState *cp, CPChar c) +{ + MSize newsize; + if (cp->sb.sz >= CPARSE_MAX_BUF/2) + cp_err(cp, LJ_ERR_XELEM); + newsize = cp->sb.sz * 2; + lj_str_resizebuf(cp->L, &cp->sb, newsize); + cp->sb.buf[cp->sb.n++] = (char)c; +} + +/* Save character in buffer. */ +static LJ_AINLINE void cp_save(CPState *cp, CPChar c) +{ + if (LJ_UNLIKELY(cp->sb.n + 1 > cp->sb.sz)) + cp_save_grow(cp, c); + else + cp->sb.buf[cp->sb.n++] = (char)c; +} + +/* Skip line break. Handles "\n", "\r", "\r\n" or "\n\r". */ +static void cp_newline(CPState *cp) +{ + CPChar c = cp_rawpeek(cp); + if (cp_iseol(c) && c != cp->c) cp->p++; + cp->linenumber++; +} + +LJ_NORET static void cp_errmsg(CPState *cp, CPToken tok, ErrMsg em, ...) +{ + const char *msg, *tokstr; + lua_State *L; + va_list argp; + if (tok == 0) { + tokstr = NULL; + } else if (tok == CTOK_IDENT || tok == CTOK_INTEGER || tok == CTOK_STRING || + tok >= CTOK_FIRSTDECL) { + if (cp->sb.n == 0) cp_save(cp, '$'); + cp_save(cp, '\0'); + tokstr = cp->sb.buf; + } else { + tokstr = cp_tok2str(cp, tok); + } + L = cp->L; + va_start(argp, em); + msg = lj_str_pushvf(L, err2msg(em), argp); + va_end(argp); + if (tokstr) + msg = lj_str_pushf(L, err2msg(LJ_ERR_XNEAR), msg, tokstr); + if (cp->linenumber > 1) + msg = lj_str_pushf(L, "%s at line %d", msg, cp->linenumber); + lj_err_callermsg(L, msg); +} + +LJ_NORET LJ_NOINLINE static void cp_err_token(CPState *cp, CPToken tok) +{ + cp_errmsg(cp, cp->tok, LJ_ERR_XTOKEN, cp_tok2str(cp, tok)); +} + +LJ_NORET LJ_NOINLINE static void cp_err_badidx(CPState *cp, CType *ct) +{ + GCstr *s = lj_ctype_repr(cp->cts->L, ctype_typeid(cp->cts, ct), NULL); + cp_errmsg(cp, 0, LJ_ERR_FFI_BADIDX, strdata(s)); +} + +LJ_NORET LJ_NOINLINE static void cp_err(CPState *cp, ErrMsg em) +{ + cp_errmsg(cp, 0, em); +} + +/* -- Main lexical scanner ------------------------------------------------ */ + +/* Parse number literal. Only handles int32_t/uint32_t right now. */ +static CPToken cp_number(CPState *cp) +{ + StrScanFmt fmt; + TValue o; + do { cp_save(cp, cp->c); } while (lj_char_isident(cp_get(cp))); + cp_save(cp, '\0'); + fmt = lj_strscan_scan((const uint8_t *)cp->sb.buf, &o, STRSCAN_OPT_C); + if (fmt == STRSCAN_INT) cp->val.id = CTID_INT32; + else if (fmt == STRSCAN_U32) cp->val.id = CTID_UINT32; + else if (!(cp->mode & CPARSE_MODE_SKIP)) + cp_errmsg(cp, CTOK_INTEGER, LJ_ERR_XNUMBER); + cp->val.u32 = (uint32_t)o.i; + return CTOK_INTEGER; +} + +/* Parse identifier or keyword. */ +static CPToken cp_ident(CPState *cp) +{ + do { cp_save(cp, cp->c); } while (lj_char_isident(cp_get(cp))); + cp->str = lj_str_new(cp->L, cp->sb.buf, cp->sb.n); + cp->val.id = lj_ctype_getname(cp->cts, &cp->ct, cp->str, cp->tmask); + if (ctype_type(cp->ct->info) == CT_KW) + return ctype_cid(cp->ct->info); + return CTOK_IDENT; +} + +/* Parse parameter. */ +static CPToken cp_param(CPState *cp) +{ + CPChar c = cp_get(cp); + TValue *o = cp->param; + if (lj_char_isident(c) || c == '$') /* Reserve $xyz for future extensions. */ + cp_errmsg(cp, c, LJ_ERR_XSYNTAX); + if (!o || o >= cp->L->top) + cp_err(cp, LJ_ERR_FFI_NUMPARAM); + cp->param = o+1; + if (tvisstr(o)) { + cp->str = strV(o); + cp->val.id = 0; + cp->ct = &cp->cts->tab[0]; + return CTOK_IDENT; + } else if (tvisnumber(o)) { + cp->val.i32 = numberVint(o); + cp->val.id = CTID_INT32; + return CTOK_INTEGER; + } else { + GCcdata *cd; + if (!tviscdata(o)) + lj_err_argtype(cp->L, (int)(o-cp->L->base)+1, "type parameter"); + cd = cdataV(o); + if (cd->ctypeid == CTID_CTYPEID) + cp->val.id = *(CTypeID *)cdataptr(cd); + else + cp->val.id = cd->ctypeid; + return '$'; + } +} + +/* Parse string or character constant. */ +static CPToken cp_string(CPState *cp) +{ + CPChar delim = cp->c; + cp_get(cp); + while (cp->c != delim) { + CPChar c = cp->c; + if (c == '\0') cp_errmsg(cp, CTOK_EOF, LJ_ERR_XSTR); + if (c == '\\') { + c = cp_get(cp); + switch (c) { + case '\0': cp_errmsg(cp, CTOK_EOF, LJ_ERR_XSTR); break; + case 'a': c = '\a'; break; + case 'b': c = '\b'; break; + case 'f': c = '\f'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'v': c = '\v'; break; + case 'e': c = 27; break; + case 'x': + c = 0; + while (lj_char_isxdigit(cp_get(cp))) + c = (c<<4) + (lj_char_isdigit(cp->c) ? cp->c-'0' : (cp->c&15)+9); + cp_save(cp, (c & 0xff)); + continue; + default: + if (lj_char_isdigit(c)) { + c -= '0'; + if (lj_char_isdigit(cp_get(cp))) { + c = c*8 + (cp->c - '0'); + if (lj_char_isdigit(cp_get(cp))) { + c = c*8 + (cp->c - '0'); + cp_get(cp); + } + } + cp_save(cp, (c & 0xff)); + continue; + } + break; + } + } + cp_save(cp, c); + cp_get(cp); + } + cp_get(cp); + if (delim == '"') { + cp->str = lj_str_new(cp->L, cp->sb.buf, cp->sb.n); + return CTOK_STRING; + } else { + if (cp->sb.n != 1) cp_err_token(cp, '\''); + cp->val.i32 = (int32_t)(char)cp->sb.buf[0]; + cp->val.id = CTID_INT32; + return CTOK_INTEGER; + } +} + +/* Skip C comment. */ +static void cp_comment_c(CPState *cp) +{ + do { + if (cp_get(cp) == '*') { + do { + if (cp_get(cp) == '/') { cp_get(cp); return; } + } while (cp->c == '*'); + } + if (cp_iseol(cp->c)) cp_newline(cp); + } while (cp->c != '\0'); +} + +/* Skip C++ comment. */ +static void cp_comment_cpp(CPState *cp) +{ + while (!cp_iseol(cp_get(cp)) && cp->c != '\0') + ; +} + +/* Lexical scanner for C. Only a minimal subset is implemented. */ +static CPToken cp_next_(CPState *cp) +{ + lj_str_resetbuf(&cp->sb); + for (;;) { + if (lj_char_isident(cp->c)) + return lj_char_isdigit(cp->c) ? cp_number(cp) : cp_ident(cp); + switch (cp->c) { + case '\n': case '\r': cp_newline(cp); /* fallthrough. */ + case ' ': case '\t': case '\v': case '\f': cp_get(cp); break; + case '"': case '\'': return cp_string(cp); + case '/': + if (cp_get(cp) == '*') cp_comment_c(cp); + else if (cp->c == '/') cp_comment_cpp(cp); + else return '/'; + break; + case '|': + if (cp_get(cp) != '|') return '|'; + cp_get(cp); return CTOK_OROR; + case '&': + if (cp_get(cp) != '&') return '&'; + cp_get(cp); return CTOK_ANDAND; + case '=': + if (cp_get(cp) != '=') return '='; + cp_get(cp); return CTOK_EQ; + case '!': + if (cp_get(cp) != '=') return '!'; + cp_get(cp); return CTOK_NE; + case '<': + if (cp_get(cp) == '=') { cp_get(cp); return CTOK_LE; } + else if (cp->c == '<') { cp_get(cp); return CTOK_SHL; } + return '<'; + case '>': + if (cp_get(cp) == '=') { cp_get(cp); return CTOK_GE; } + else if (cp->c == '>') { cp_get(cp); return CTOK_SHR; } + return '>'; + case '-': + if (cp_get(cp) != '>') return '-'; + cp_get(cp); return CTOK_DEREF; + case '$': + return cp_param(cp); + case '\0': return CTOK_EOF; + default: { CPToken c = cp->c; cp_get(cp); return c; } + } + } +} + +static LJ_NOINLINE CPToken cp_next(CPState *cp) +{ + return (cp->tok = cp_next_(cp)); +} + +/* -- C parser ------------------------------------------------------------ */ + +/* Namespaces for resolving identifiers. */ +#define CPNS_DEFAULT \ + ((1u<linenumber = 1; + cp->depth = 0; + cp->curpack = 0; + cp->packstack[0] = 255; + lj_str_initbuf(&cp->sb); + lj_str_resizebuf(cp->L, &cp->sb, LJ_MIN_SBUF); + lua_assert(cp->p != NULL); + cp_get(cp); /* Read-ahead first char. */ + cp->tok = 0; + cp->tmask = CPNS_DEFAULT; + cp_next(cp); /* Read-ahead first token. */ +} + +/* Cleanup C parser state. */ +static void cp_cleanup(CPState *cp) +{ + global_State *g = G(cp->L); + lj_str_freebuf(g, &cp->sb); +} + +/* Check and consume optional token. */ +static int cp_opt(CPState *cp, CPToken tok) +{ + if (cp->tok == tok) { cp_next(cp); return 1; } + return 0; +} + +/* Check and consume token. */ +static void cp_check(CPState *cp, CPToken tok) +{ + if (cp->tok != tok) cp_err_token(cp, tok); + cp_next(cp); +} + +/* Check if the next token may start a type declaration. */ +static int cp_istypedecl(CPState *cp) +{ + if (cp->tok >= CTOK_FIRSTDECL && cp->tok <= CTOK_LASTDECL) return 1; + if (cp->tok == CTOK_IDENT && ctype_istypedef(cp->ct->info)) return 1; + if (cp->tok == '$') return 1; + return 0; +} + +/* -- Constant expression evaluator --------------------------------------- */ + +/* Forward declarations. */ +static void cp_expr_unary(CPState *cp, CPValue *k); +static void cp_expr_sub(CPState *cp, CPValue *k, int pri); + +/* Please note that type handling is very weak here. Most ops simply +** assume integer operands. Accessors are only needed to compute types and +** return synthetic values. The only purpose of the expression evaluator +** is to compute the values of constant expressions one would typically +** find in C header files. And again: this is NOT a validating C parser! +*/ + +/* Parse comma separated expression and return last result. */ +static void cp_expr_comma(CPState *cp, CPValue *k) +{ + do { cp_expr_sub(cp, k, 0); } while (cp_opt(cp, ',')); +} + +/* Parse sizeof/alignof operator. */ +static void cp_expr_sizeof(CPState *cp, CPValue *k, int wantsz) +{ + CTSize sz; + CTInfo info; + if (cp_opt(cp, '(')) { + if (cp_istypedecl(cp)) + k->id = cp_decl_abstract(cp); + else + cp_expr_comma(cp, k); + cp_check(cp, ')'); + } else { + cp_expr_unary(cp, k); + } + info = lj_ctype_info(cp->cts, k->id, &sz); + if (wantsz) { + if (sz != CTSIZE_INVALID) + k->u32 = sz; + else if (k->id != CTID_A_CCHAR) /* Special case for sizeof("string"). */ + cp_err(cp, LJ_ERR_FFI_INVSIZE); + } else { + k->u32 = 1u << ctype_align(info); + } + k->id = CTID_UINT32; /* Really size_t. */ +} + +/* Parse prefix operators. */ +static void cp_expr_prefix(CPState *cp, CPValue *k) +{ + if (cp->tok == CTOK_INTEGER) { + *k = cp->val; cp_next(cp); + } else if (cp_opt(cp, '+')) { + cp_expr_unary(cp, k); /* Nothing to do (well, integer promotion). */ + } else if (cp_opt(cp, '-')) { + cp_expr_unary(cp, k); k->i32 = -k->i32; + } else if (cp_opt(cp, '~')) { + cp_expr_unary(cp, k); k->i32 = ~k->i32; + } else if (cp_opt(cp, '!')) { + cp_expr_unary(cp, k); k->i32 = !k->i32; k->id = CTID_INT32; + } else if (cp_opt(cp, '(')) { + if (cp_istypedecl(cp)) { /* Cast operator. */ + CTypeID id = cp_decl_abstract(cp); + cp_check(cp, ')'); + cp_expr_unary(cp, k); + k->id = id; /* No conversion performed. */ + } else { /* Sub-expression. */ + cp_expr_comma(cp, k); + cp_check(cp, ')'); + } + } else if (cp_opt(cp, '*')) { /* Indirection. */ + CType *ct; + cp_expr_unary(cp, k); + ct = lj_ctype_rawref(cp->cts, k->id); + if (!ctype_ispointer(ct->info)) + cp_err_badidx(cp, ct); + k->u32 = 0; k->id = ctype_cid(ct->info); + } else if (cp_opt(cp, '&')) { /* Address operator. */ + cp_expr_unary(cp, k); + k->id = lj_ctype_intern(cp->cts, CTINFO(CT_PTR, CTALIGN_PTR+k->id), + CTSIZE_PTR); + } else if (cp_opt(cp, CTOK_SIZEOF)) { + cp_expr_sizeof(cp, k, 1); + } else if (cp_opt(cp, CTOK_ALIGNOF)) { + cp_expr_sizeof(cp, k, 0); + } else if (cp->tok == CTOK_IDENT) { + if (ctype_type(cp->ct->info) == CT_CONSTVAL) { + k->u32 = cp->ct->size; k->id = ctype_cid(cp->ct->info); + } else if (ctype_type(cp->ct->info) == CT_EXTERN) { + k->u32 = cp->val.id; k->id = ctype_cid(cp->ct->info); + } else if (ctype_type(cp->ct->info) == CT_FUNC) { + k->u32 = cp->val.id; k->id = cp->val.id; + } else { + goto err_expr; + } + cp_next(cp); + } else if (cp->tok == CTOK_STRING) { + CTSize sz = cp->str->len; + while (cp_next(cp) == CTOK_STRING) + sz += cp->str->len; + k->u32 = sz + 1; + k->id = CTID_A_CCHAR; + } else { + err_expr: + cp_errmsg(cp, cp->tok, LJ_ERR_XSYMBOL); + } +} + +/* Parse postfix operators. */ +static void cp_expr_postfix(CPState *cp, CPValue *k) +{ + for (;;) { + CType *ct; + if (cp_opt(cp, '[')) { /* Array/pointer index. */ + CPValue k2; + cp_expr_comma(cp, &k2); + ct = lj_ctype_rawref(cp->cts, k->id); + if (!ctype_ispointer(ct->info)) { + ct = lj_ctype_rawref(cp->cts, k2.id); + if (!ctype_ispointer(ct->info)) + cp_err_badidx(cp, ct); + } + cp_check(cp, ']'); + k->u32 = 0; + } else if (cp->tok == '.' || cp->tok == CTOK_DEREF) { /* Struct deref. */ + CTSize ofs; + CType *fct; + ct = lj_ctype_rawref(cp->cts, k->id); + if (cp->tok == CTOK_DEREF) { + if (!ctype_ispointer(ct->info)) + cp_err_badidx(cp, ct); + ct = lj_ctype_rawref(cp->cts, ctype_cid(ct->info)); + } + cp_next(cp); + if (cp->tok != CTOK_IDENT) cp_err_token(cp, CTOK_IDENT); + if (!ctype_isstruct(ct->info) || ct->size == CTSIZE_INVALID || + !(fct = lj_ctype_getfield(cp->cts, ct, cp->str, &ofs)) || + ctype_isbitfield(fct->info)) { + GCstr *s = lj_ctype_repr(cp->cts->L, ctype_typeid(cp->cts, ct), NULL); + cp_errmsg(cp, 0, LJ_ERR_FFI_BADMEMBER, strdata(s), strdata(cp->str)); + } + ct = fct; + k->u32 = ctype_isconstval(ct->info) ? ct->size : 0; + cp_next(cp); + } else { + return; + } + k->id = ctype_cid(ct->info); + } +} + +/* Parse infix operators. */ +static void cp_expr_infix(CPState *cp, CPValue *k, int pri) +{ + CPValue k2; + k2.u32 = 0; k2.id = 0; /* Silence the compiler. */ + for (;;) { + switch (pri) { + case 0: + if (cp_opt(cp, '?')) { + CPValue k3; + cp_expr_comma(cp, &k2); /* Right-associative. */ + cp_check(cp, ':'); + cp_expr_sub(cp, &k3, 0); + k->u32 = k->u32 ? k2.u32 : k3.u32; + k->id = k2.id > k3.id ? k2.id : k3.id; + continue; + } + case 1: + if (cp_opt(cp, CTOK_OROR)) { + cp_expr_sub(cp, &k2, 2); k->i32 = k->u32 || k2.u32; k->id = CTID_INT32; + continue; + } + case 2: + if (cp_opt(cp, CTOK_ANDAND)) { + cp_expr_sub(cp, &k2, 3); k->i32 = k->u32 && k2.u32; k->id = CTID_INT32; + continue; + } + case 3: + if (cp_opt(cp, '|')) { + cp_expr_sub(cp, &k2, 4); k->u32 = k->u32 | k2.u32; goto arith_result; + } + case 4: + if (cp_opt(cp, '^')) { + cp_expr_sub(cp, &k2, 5); k->u32 = k->u32 ^ k2.u32; goto arith_result; + } + case 5: + if (cp_opt(cp, '&')) { + cp_expr_sub(cp, &k2, 6); k->u32 = k->u32 & k2.u32; goto arith_result; + } + case 6: + if (cp_opt(cp, CTOK_EQ)) { + cp_expr_sub(cp, &k2, 7); k->i32 = k->u32 == k2.u32; k->id = CTID_INT32; + continue; + } else if (cp_opt(cp, CTOK_NE)) { + cp_expr_sub(cp, &k2, 7); k->i32 = k->u32 != k2.u32; k->id = CTID_INT32; + continue; + } + case 7: + if (cp_opt(cp, '<')) { + cp_expr_sub(cp, &k2, 8); + if (k->id == CTID_INT32 && k2.id == CTID_INT32) + k->i32 = k->i32 < k2.i32; + else + k->i32 = k->u32 < k2.u32; + k->id = CTID_INT32; + continue; + } else if (cp_opt(cp, '>')) { + cp_expr_sub(cp, &k2, 8); + if (k->id == CTID_INT32 && k2.id == CTID_INT32) + k->i32 = k->i32 > k2.i32; + else + k->i32 = k->u32 > k2.u32; + k->id = CTID_INT32; + continue; + } else if (cp_opt(cp, CTOK_LE)) { + cp_expr_sub(cp, &k2, 8); + if (k->id == CTID_INT32 && k2.id == CTID_INT32) + k->i32 = k->i32 <= k2.i32; + else + k->i32 = k->u32 <= k2.u32; + k->id = CTID_INT32; + continue; + } else if (cp_opt(cp, CTOK_GE)) { + cp_expr_sub(cp, &k2, 8); + if (k->id == CTID_INT32 && k2.id == CTID_INT32) + k->i32 = k->i32 >= k2.i32; + else + k->i32 = k->u32 >= k2.u32; + k->id = CTID_INT32; + continue; + } + case 8: + if (cp_opt(cp, CTOK_SHL)) { + cp_expr_sub(cp, &k2, 9); k->u32 = k->u32 << k2.u32; + continue; + } else if (cp_opt(cp, CTOK_SHR)) { + cp_expr_sub(cp, &k2, 9); + if (k->id == CTID_INT32) + k->i32 = k->i32 >> k2.i32; + else + k->u32 = k->u32 >> k2.u32; + continue; + } + case 9: + if (cp_opt(cp, '+')) { + cp_expr_sub(cp, &k2, 10); k->u32 = k->u32 + k2.u32; + arith_result: + if (k2.id > k->id) k->id = k2.id; /* Trivial promotion to unsigned. */ + continue; + } else if (cp_opt(cp, '-')) { + cp_expr_sub(cp, &k2, 10); k->u32 = k->u32 - k2.u32; goto arith_result; + } + case 10: + if (cp_opt(cp, '*')) { + cp_expr_unary(cp, &k2); k->u32 = k->u32 * k2.u32; goto arith_result; + } else if (cp_opt(cp, '/')) { + cp_expr_unary(cp, &k2); + if (k2.id > k->id) k->id = k2.id; /* Trivial promotion to unsigned. */ + if (k2.u32 == 0 || + (k->id == CTID_INT32 && k->u32 == 0x80000000u && k2.i32 == -1)) + cp_err(cp, LJ_ERR_BADVAL); + if (k->id == CTID_INT32) + k->i32 = k->i32 / k2.i32; + else + k->u32 = k->u32 / k2.u32; + continue; + } else if (cp_opt(cp, '%')) { + cp_expr_unary(cp, &k2); + if (k2.id > k->id) k->id = k2.id; /* Trivial promotion to unsigned. */ + if (k2.u32 == 0 || + (k->id == CTID_INT32 && k->u32 == 0x80000000u && k2.i32 == -1)) + cp_err(cp, LJ_ERR_BADVAL); + if (k->id == CTID_INT32) + k->i32 = k->i32 % k2.i32; + else + k->u32 = k->u32 % k2.u32; + continue; + } + default: + return; + } + } +} + +/* Parse and evaluate unary expression. */ +static void cp_expr_unary(CPState *cp, CPValue *k) +{ + if (++cp->depth > CPARSE_MAX_DECLDEPTH) cp_err(cp, LJ_ERR_XLEVELS); + cp_expr_prefix(cp, k); + cp_expr_postfix(cp, k); + cp->depth--; +} + +/* Parse and evaluate sub-expression. */ +static void cp_expr_sub(CPState *cp, CPValue *k, int pri) +{ + cp_expr_unary(cp, k); + cp_expr_infix(cp, k, pri); +} + +/* Parse constant integer expression. */ +static void cp_expr_kint(CPState *cp, CPValue *k) +{ + CType *ct; + cp_expr_sub(cp, k, 0); + ct = ctype_raw(cp->cts, k->id); + if (!ctype_isinteger(ct->info)) cp_err(cp, LJ_ERR_BADVAL); +} + +/* Parse (non-negative) size expression. */ +static CTSize cp_expr_ksize(CPState *cp) +{ + CPValue k; + cp_expr_kint(cp, &k); + if (k.u32 >= 0x80000000u) cp_err(cp, LJ_ERR_FFI_INVSIZE); + return k.u32; +} + +/* -- Type declaration stack management ----------------------------------- */ + +/* Add declaration element behind the insertion position. */ +static CPDeclIdx cp_add(CPDecl *decl, CTInfo info, CTSize size) +{ + CPDeclIdx top = decl->top; + if (top >= CPARSE_MAX_DECLSTACK) cp_err(decl->cp, LJ_ERR_XLEVELS); + decl->stack[top].info = info; + decl->stack[top].size = size; + decl->stack[top].sib = 0; + setgcrefnull(decl->stack[top].name); + decl->stack[top].next = decl->stack[decl->pos].next; + decl->stack[decl->pos].next = (CTypeID1)top; + decl->top = top+1; + return top; +} + +/* Push declaration element before the insertion position. */ +static CPDeclIdx cp_push(CPDecl *decl, CTInfo info, CTSize size) +{ + return (decl->pos = cp_add(decl, info, size)); +} + +/* Push or merge attributes. */ +static void cp_push_attributes(CPDecl *decl) +{ + CType *ct = &decl->stack[decl->pos]; + if (ctype_isfunc(ct->info)) { /* Ok to modify in-place. */ +#if LJ_TARGET_X86 + if ((decl->fattr & CTFP_CCONV)) + ct->info = (ct->info & (CTMASK_NUM|CTF_VARARG|CTMASK_CID)) + + (decl->fattr & ~CTMASK_CID); +#endif + } else { + if ((decl->attr & CTFP_ALIGNED) && !(decl->mode & CPARSE_MODE_FIELD)) + cp_push(decl, CTINFO(CT_ATTRIB, CTATTRIB(CTA_ALIGN)), + ctype_align(decl->attr)); + } +} + +/* Push unrolled type to declaration stack and merge qualifiers. */ +static void cp_push_type(CPDecl *decl, CTypeID id) +{ + CType *ct = ctype_get(decl->cp->cts, id); + CTInfo info = ct->info; + CTSize size = ct->size; + switch (ctype_type(info)) { + case CT_STRUCT: case CT_ENUM: + cp_push(decl, CTINFO(CT_TYPEDEF, id), 0); /* Don't copy unique types. */ + if ((decl->attr & CTF_QUAL)) { /* Push unmerged qualifiers. */ + cp_push(decl, CTINFO(CT_ATTRIB, CTATTRIB(CTA_QUAL)), + (decl->attr & CTF_QUAL)); + decl->attr &= ~CTF_QUAL; + } + break; + case CT_ATTRIB: + if (ctype_isxattrib(info, CTA_QUAL)) + decl->attr &= ~size; /* Remove redundant qualifiers. */ + cp_push_type(decl, ctype_cid(info)); /* Unroll. */ + cp_push(decl, info & ~CTMASK_CID, size); /* Copy type. */ + break; + case CT_ARRAY: + if ((ct->info & (CTF_VECTOR|CTF_COMPLEX))) { + info |= (decl->attr & CTF_QUAL); + decl->attr &= ~CTF_QUAL; + } + cp_push_type(decl, ctype_cid(info)); /* Unroll. */ + cp_push(decl, info & ~CTMASK_CID, size); /* Copy type. */ + decl->stack[decl->pos].sib = 1; /* Mark as already checked and sized. */ + /* Note: this is not copied to the ct->sib in the C type table. */ + break; + case CT_FUNC: + /* Copy type, link parameters (shared). */ + decl->stack[cp_push(decl, info, size)].sib = ct->sib; + break; + default: + /* Copy type, merge common qualifiers. */ + cp_push(decl, info|(decl->attr & CTF_QUAL), size); + decl->attr &= ~CTF_QUAL; + break; + } +} + +/* Consume the declaration element chain and intern the C type. */ +static CTypeID cp_decl_intern(CPState *cp, CPDecl *decl) +{ + CTypeID id = 0; + CPDeclIdx idx = 0; + CTSize csize = CTSIZE_INVALID; + CTSize cinfo = 0; + do { + CType *ct = &decl->stack[idx]; + CTInfo info = ct->info; + CTInfo size = ct->size; + /* The cid is already part of info for copies of pointers/functions. */ + idx = ct->next; + if (ctype_istypedef(info)) { + lua_assert(id == 0); + id = ctype_cid(info); + /* Always refetch info/size, since struct/enum may have been completed. */ + cinfo = ctype_get(cp->cts, id)->info; + csize = ctype_get(cp->cts, id)->size; + lua_assert(ctype_isstruct(cinfo) || ctype_isenum(cinfo)); + } else if (ctype_isfunc(info)) { /* Intern function. */ + CType *fct; + CTypeID fid; + CTypeID sib; + if (id) { + CType *refct = ctype_raw(cp->cts, id); + /* Reject function or refarray return types. */ + if (ctype_isfunc(refct->info) || ctype_isrefarray(refct->info)) + cp_err(cp, LJ_ERR_FFI_INVTYPE); + } + /* No intervening attributes allowed, skip forward. */ + while (idx) { + CType *ctn = &decl->stack[idx]; + if (!ctype_isattrib(ctn->info)) break; + idx = ctn->next; /* Skip attribute. */ + } + sib = ct->sib; /* Next line may reallocate the C type table. */ + fid = lj_ctype_new(cp->cts, &fct); + csize = CTSIZE_INVALID; + fct->info = cinfo = info + id; + fct->size = size; + fct->sib = sib; + id = fid; + } else if (ctype_isattrib(info)) { + if (ctype_isxattrib(info, CTA_QUAL)) + cinfo |= size; + else if (ctype_isxattrib(info, CTA_ALIGN)) + CTF_INSERT(cinfo, ALIGN, size); + id = lj_ctype_intern(cp->cts, info+id, size); + /* Inherit csize/cinfo from original type. */ + } else { + if (ctype_isnum(info)) { /* Handle mode/vector-size attributes. */ + lua_assert(id == 0); + if (!(info & CTF_BOOL)) { + CTSize msize = ctype_msizeP(decl->attr); + CTSize vsize = ctype_vsizeP(decl->attr); + if (msize && (!(info & CTF_FP) || (msize == 4 || msize == 8))) { + CTSize malign = lj_fls(msize); + if (malign > 4) malign = 4; /* Limit alignment. */ + CTF_INSERT(info, ALIGN, malign); + size = msize; /* Override size via mode. */ + } + if (vsize) { /* Vector size set? */ + CTSize esize = lj_fls(size); + if (vsize >= esize) { + /* Intern the element type first. */ + id = lj_ctype_intern(cp->cts, info, size); + /* Then create a vector (array) with vsize alignment. */ + size = (1u << vsize); + if (vsize > 4) vsize = 4; /* Limit alignment. */ + if (ctype_align(info) > vsize) vsize = ctype_align(info); + info = CTINFO(CT_ARRAY, (info & CTF_QUAL) + CTF_VECTOR + + CTALIGN(vsize)); + } + } + } + } else if (ctype_isptr(info)) { + /* Reject pointer/ref to ref. */ + if (id && ctype_isref(ctype_raw(cp->cts, id)->info)) + cp_err(cp, LJ_ERR_FFI_INVTYPE); + if (ctype_isref(info)) { + info &= ~CTF_VOLATILE; /* Refs are always const, never volatile. */ + /* No intervening attributes allowed, skip forward. */ + while (idx) { + CType *ctn = &decl->stack[idx]; + if (!ctype_isattrib(ctn->info)) break; + idx = ctn->next; /* Skip attribute. */ + } + } + } else if (ctype_isarray(info)) { /* Check for valid array size etc. */ + if (ct->sib == 0) { /* Only check/size arrays not copied by unroll. */ + if (ctype_isref(cinfo)) /* Reject arrays of refs. */ + cp_err(cp, LJ_ERR_FFI_INVTYPE); + /* Reject VLS or unknown-sized types. */ + if (ctype_isvltype(cinfo) || csize == CTSIZE_INVALID) + cp_err(cp, LJ_ERR_FFI_INVSIZE); + /* a[] and a[?] keep their invalid size. */ + if (size != CTSIZE_INVALID) { + uint64_t xsz = (uint64_t)size * csize; + if (xsz >= 0x80000000u) cp_err(cp, LJ_ERR_FFI_INVSIZE); + size = (CTSize)xsz; + } + } + if ((cinfo & CTF_ALIGN) > (info & CTF_ALIGN)) /* Find max. align. */ + info = (info & ~CTF_ALIGN) | (cinfo & CTF_ALIGN); + info |= (cinfo & CTF_QUAL); /* Inherit qual. */ + } else { + lua_assert(ctype_isvoid(info)); + } + csize = size; + cinfo = info+id; + id = lj_ctype_intern(cp->cts, info+id, size); + } + } while (idx); + return id; +} + +/* -- C declaration parser ------------------------------------------------ */ + +#define H_(le, be) LJ_ENDIAN_SELECT(0x##le, 0x##be) + +/* Reset declaration state to declaration specifier. */ +static void cp_decl_reset(CPDecl *decl) +{ + decl->pos = decl->specpos; + decl->top = decl->specpos+1; + decl->stack[decl->specpos].next = 0; + decl->attr = decl->specattr; + decl->fattr = decl->specfattr; + decl->name = NULL; + decl->redir = NULL; +} + +/* Parse constant initializer. */ +/* NYI: FP constants and strings as initializers. */ +static CTypeID cp_decl_constinit(CPState *cp, CType **ctp, CTypeID ctypeid) +{ + CType *ctt = ctype_get(cp->cts, ctypeid); + CTInfo info; + CTSize size; + CPValue k; + CTypeID constid; + while (ctype_isattrib(ctt->info)) { /* Skip attributes. */ + ctypeid = ctype_cid(ctt->info); /* Update ID, too. */ + ctt = ctype_get(cp->cts, ctypeid); + } + info = ctt->info; + size = ctt->size; + if (!ctype_isinteger(info) || !(info & CTF_CONST) || size > 4) + cp_err(cp, LJ_ERR_FFI_INVTYPE); + cp_check(cp, '='); + cp_expr_sub(cp, &k, 0); + constid = lj_ctype_new(cp->cts, ctp); + (*ctp)->info = CTINFO(CT_CONSTVAL, CTF_CONST|ctypeid); + k.u32 <<= 8*(4-size); + if ((info & CTF_UNSIGNED)) + k.u32 >>= 8*(4-size); + else + k.u32 = (uint32_t)((int32_t)k.u32 >> 8*(4-size)); + (*ctp)->size = k.u32; + return constid; +} + +/* Parse size in parentheses as part of attribute. */ +static CTSize cp_decl_sizeattr(CPState *cp) +{ + CTSize sz; + uint32_t oldtmask = cp->tmask; + cp->tmask = CPNS_DEFAULT; /* Required for expression evaluator. */ + cp_check(cp, '('); + sz = cp_expr_ksize(cp); + cp->tmask = oldtmask; + cp_check(cp, ')'); + return sz; +} + +/* Parse alignment attribute. */ +static void cp_decl_align(CPState *cp, CPDecl *decl) +{ + CTSize al = 4; /* Unspecified alignment is 16 bytes. */ + if (cp->tok == '(') { + al = cp_decl_sizeattr(cp); + al = al ? lj_fls(al) : 0; + } + CTF_INSERT(decl->attr, ALIGN, al); + decl->attr |= CTFP_ALIGNED; +} + +/* Parse GCC asm("name") redirect. */ +static void cp_decl_asm(CPState *cp, CPDecl *decl) +{ + UNUSED(decl); + cp_next(cp); + cp_check(cp, '('); + if (cp->tok == CTOK_STRING) { + GCstr *str = cp->str; + while (cp_next(cp) == CTOK_STRING) { + lj_str_pushf(cp->L, "%s%s", strdata(str), strdata(cp->str)); + cp->L->top--; + str = strV(cp->L->top); + } + decl->redir = str; + } + cp_check(cp, ')'); +} + +/* Parse GCC __attribute__((mode(...))). */ +static void cp_decl_mode(CPState *cp, CPDecl *decl) +{ + cp_check(cp, '('); + if (cp->tok == CTOK_IDENT) { + const char *s = strdata(cp->str); + CTSize sz = 0, vlen = 0; + if (s[0] == '_' && s[1] == '_') s += 2; + if (*s == 'V') { + s++; + vlen = *s++ - '0'; + if (*s >= '0' && *s <= '9') + vlen = vlen*10 + (*s++ - '0'); + } + switch (*s++) { + case 'Q': sz = 1; break; + case 'H': sz = 2; break; + case 'S': sz = 4; break; + case 'D': sz = 8; break; + case 'T': sz = 16; break; + case 'O': sz = 32; break; + default: goto bad_size; + } + if (*s == 'I' || *s == 'F') { + CTF_INSERT(decl->attr, MSIZEP, sz); + if (vlen) CTF_INSERT(decl->attr, VSIZEP, lj_fls(vlen*sz)); + } + bad_size: + cp_next(cp); + } + cp_check(cp, ')'); +} + +/* Parse GCC __attribute__((...)). */ +static void cp_decl_gccattribute(CPState *cp, CPDecl *decl) +{ + cp_next(cp); + cp_check(cp, '('); + cp_check(cp, '('); + while (cp->tok != ')') { + if (cp->tok == CTOK_IDENT) { + GCstr *attrstr = cp->str; + cp_next(cp); + switch (attrstr->hash) { + case H_(64a9208e,8ce14319): case H_(8e6331b2,95a282af): /* aligned */ + cp_decl_align(cp, decl); + break; + case H_(42eb47de,f0ede26c): case H_(29f48a09,cf383e0c): /* packed */ + decl->attr |= CTFP_PACKED; + break; + case H_(0a84eef6,8dfab04c): case H_(995cf92c,d5696591): /* mode */ + cp_decl_mode(cp, decl); + break; + case H_(0ab31997,2d5213fa): case H_(bf875611,200e9990): /* vector_size */ + { + CTSize vsize = cp_decl_sizeattr(cp); + if (vsize) CTF_INSERT(decl->attr, VSIZEP, lj_fls(vsize)); + } + break; +#if LJ_TARGET_X86 + case H_(5ad22db8,c689b848): case H_(439150fa,65ea78cb): /* regparm */ + CTF_INSERT(decl->fattr, REGPARM, cp_decl_sizeattr(cp)); + decl->fattr |= CTFP_CCONV; + break; + case H_(18fc0b98,7ff4c074): case H_(4e62abed,0a747424): /* cdecl */ + CTF_INSERT(decl->fattr, CCONV, CTCC_CDECL); + decl->fattr |= CTFP_CCONV; + break; + case H_(72b2e41b,494c5a44): case H_(f2356d59,f25fc9bd): /* thiscall */ + CTF_INSERT(decl->fattr, CCONV, CTCC_THISCALL); + decl->fattr |= CTFP_CCONV; + break; + case H_(0d0ffc42,ab746f88): case H_(21c54ba1,7f0ca7e3): /* fastcall */ + CTF_INSERT(decl->fattr, CCONV, CTCC_FASTCALL); + decl->fattr |= CTFP_CCONV; + break; + case H_(ef76b040,9412e06a): case H_(de56697b,c750e6e1): /* stdcall */ + CTF_INSERT(decl->fattr, CCONV, CTCC_STDCALL); + decl->fattr |= CTFP_CCONV; + break; + case H_(ea78b622,f234bd8e): case H_(252ffb06,8d50f34b): /* sseregparm */ + decl->fattr |= CTF_SSEREGPARM; + decl->fattr |= CTFP_CCONV; + break; +#endif + default: /* Skip all other attributes. */ + goto skip_attr; + } + } else if (cp->tok >= CTOK_FIRSTDECL) { /* For __attribute((const)) etc. */ + cp_next(cp); + skip_attr: + if (cp_opt(cp, '(')) { + while (cp->tok != ')' && cp->tok != CTOK_EOF) cp_next(cp); + cp_check(cp, ')'); + } + } else { + break; + } + if (!cp_opt(cp, ',')) break; + } + cp_check(cp, ')'); + cp_check(cp, ')'); +} + +/* Parse MSVC __declspec(...). */ +static void cp_decl_msvcattribute(CPState *cp, CPDecl *decl) +{ + cp_next(cp); + cp_check(cp, '('); + while (cp->tok == CTOK_IDENT) { + GCstr *attrstr = cp->str; + cp_next(cp); + switch (attrstr->hash) { + case H_(bc2395fa,98f267f8): /* align */ + cp_decl_align(cp, decl); + break; + default: /* Ignore all other attributes. */ + if (cp_opt(cp, '(')) { + while (cp->tok != ')' && cp->tok != CTOK_EOF) cp_next(cp); + cp_check(cp, ')'); + } + break; + } + } + cp_check(cp, ')'); +} + +/* Parse declaration attributes (and common qualifiers). */ +static void cp_decl_attributes(CPState *cp, CPDecl *decl) +{ + for (;;) { + switch (cp->tok) { + case CTOK_CONST: decl->attr |= CTF_CONST; break; + case CTOK_VOLATILE: decl->attr |= CTF_VOLATILE; break; + case CTOK_RESTRICT: break; /* Ignore. */ + case CTOK_EXTENSION: break; /* Ignore. */ + case CTOK_ATTRIBUTE: cp_decl_gccattribute(cp, decl); continue; + case CTOK_ASM: cp_decl_asm(cp, decl); continue; + case CTOK_DECLSPEC: cp_decl_msvcattribute(cp, decl); continue; + case CTOK_CCDECL: +#if LJ_TARGET_X86 + CTF_INSERT(decl->fattr, CCONV, cp->ct->size); + decl->fattr |= CTFP_CCONV; +#endif + break; + case CTOK_PTRSZ: +#if LJ_64 + CTF_INSERT(decl->attr, MSIZEP, cp->ct->size); +#endif + break; + default: return; + } + cp_next(cp); + } +} + +/* Parse struct/union/enum name. */ +static CTypeID cp_struct_name(CPState *cp, CPDecl *sdecl, CTInfo info) +{ + CTypeID sid; + CType *ct; + cp->tmask = CPNS_STRUCT; + cp_next(cp); + cp_decl_attributes(cp, sdecl); + cp->tmask = CPNS_DEFAULT; + if (cp->tok != '{') { + if (cp->tok != CTOK_IDENT) cp_err_token(cp, CTOK_IDENT); + if (cp->val.id) { /* Name of existing struct/union/enum. */ + sid = cp->val.id; + ct = cp->ct; + if ((ct->info ^ info) & (CTMASK_NUM|CTF_UNION)) /* Wrong type. */ + cp_errmsg(cp, 0, LJ_ERR_FFI_REDEF, strdata(gco2str(gcref(ct->name)))); + } else { /* Create named, incomplete struct/union/enum. */ + if ((cp->mode & CPARSE_MODE_NOIMPLICIT)) + cp_errmsg(cp, 0, LJ_ERR_FFI_BADTAG, strdata(cp->str)); + sid = lj_ctype_new(cp->cts, &ct); + ct->info = info; + ct->size = CTSIZE_INVALID; + ctype_setname(ct, cp->str); + lj_ctype_addname(cp->cts, ct, sid); + } + cp_next(cp); + } else { /* Create anonymous, incomplete struct/union/enum. */ + sid = lj_ctype_new(cp->cts, &ct); + ct->info = info; + ct->size = CTSIZE_INVALID; + } + if (cp->tok == '{') { + if (ct->size != CTSIZE_INVALID || ct->sib) + cp_errmsg(cp, 0, LJ_ERR_FFI_REDEF, strdata(gco2str(gcref(ct->name)))); + ct->sib = 1; /* Indicate the type is currently being defined. */ + } + return sid; +} + +/* Determine field alignment. */ +static CTSize cp_field_align(CPState *cp, CType *ct, CTInfo info) +{ + CTSize align = ctype_align(info); + UNUSED(cp); UNUSED(ct); +#if (LJ_TARGET_X86 && !LJ_ABI_WIN) || (LJ_TARGET_ARM && __APPLE__) + /* The SYSV i386 and iOS ABIs limit alignment of non-vector fields to 2^2. */ + if (align > 2 && !(info & CTFP_ALIGNED)) { + if (ctype_isarray(info) && !(info & CTF_VECTOR)) { + do { + ct = ctype_rawchild(cp->cts, ct); + info = ct->info; + } while (ctype_isarray(info) && !(info & CTF_VECTOR)); + } + if (ctype_isnum(info) || ctype_isenum(info)) + align = 2; + } +#endif + return align; +} + +/* Layout struct/union fields. */ +static void cp_struct_layout(CPState *cp, CTypeID sid, CTInfo sattr) +{ + CTSize bofs = 0, bmaxofs = 0; /* Bit offset and max. bit offset. */ + CTSize maxalign = ctype_align(sattr); + CType *sct = ctype_get(cp->cts, sid); + CTInfo sinfo = sct->info; + CTypeID fieldid = sct->sib; + while (fieldid) { + CType *ct = ctype_get(cp->cts, fieldid); + CTInfo attr = ct->size; /* Field declaration attributes (temp.). */ + + if (ctype_isfield(ct->info) || + (ctype_isxattrib(ct->info, CTA_SUBTYPE) && attr)) { + CTSize align, amask; /* Alignment (pow2) and alignment mask (bits). */ + CTSize sz; + CTInfo info = lj_ctype_info(cp->cts, ctype_cid(ct->info), &sz); + CTSize bsz, csz = 8*sz; /* Field size and container size (in bits). */ + sinfo |= (info & (CTF_QUAL|CTF_VLA)); /* Merge pseudo-qualifiers. */ + + /* Check for size overflow and determine alignment. */ + if (sz >= 0x20000000u || bofs + csz < bofs || (info & CTF_VLA)) { + if (!(sz == CTSIZE_INVALID && ctype_isarray(info) && + !(sinfo & CTF_UNION))) + cp_err(cp, LJ_ERR_FFI_INVSIZE); + csz = sz = 0; /* Treat a[] and a[?] as zero-sized. */ + } + align = cp_field_align(cp, ct, info); + if (((attr|sattr) & CTFP_PACKED) || + ((attr & CTFP_ALIGNED) && ctype_align(attr) > align)) + align = ctype_align(attr); + if (cp->packstack[cp->curpack] < align) + align = cp->packstack[cp->curpack]; + if (align > maxalign) maxalign = align; + amask = (8u << align) - 1; + + bsz = ctype_bitcsz(ct->info); /* Bitfield size (temp.). */ + if (bsz == CTBSZ_FIELD || !ctype_isfield(ct->info)) { + bsz = csz; /* Regular fields or subtypes always fill the container. */ + bofs = (bofs + amask) & ~amask; /* Start new aligned field. */ + ct->size = (bofs >> 3); /* Store field offset. */ + } else { /* Bitfield. */ + if (bsz == 0 || (attr & CTFP_ALIGNED) || + (!((attr|sattr) & CTFP_PACKED) && (bofs & amask) + bsz > csz)) + bofs = (bofs + amask) & ~amask; /* Start new aligned field. */ + + /* Prefer regular field over bitfield. */ + if (bsz == csz && (bofs & amask) == 0) { + ct->info = CTINFO(CT_FIELD, ctype_cid(ct->info)); + ct->size = (bofs >> 3); /* Store field offset. */ + } else { + ct->info = CTINFO(CT_BITFIELD, + (info & (CTF_QUAL|CTF_UNSIGNED|CTF_BOOL)) + + (csz << (CTSHIFT_BITCSZ-3)) + (bsz << CTSHIFT_BITBSZ)); +#if LJ_BE + ct->info += ((csz - (bofs & (csz-1)) - bsz) << CTSHIFT_BITPOS); +#else + ct->info += ((bofs & (csz-1)) << CTSHIFT_BITPOS); +#endif + ct->size = ((bofs & ~(csz-1)) >> 3); /* Store container offset. */ + } + } + + /* Determine next offset or max. offset. */ + if ((sinfo & CTF_UNION)) { + if (bsz > bmaxofs) bmaxofs = bsz; + } else { + bofs += bsz; + } + } /* All other fields in the chain are already set up. */ + + fieldid = ct->sib; + } + + /* Complete struct/union. */ + sct->info = sinfo + CTALIGN(maxalign); + bofs = (sinfo & CTF_UNION) ? bmaxofs : bofs; + maxalign = (8u << maxalign) - 1; + sct->size = (((bofs + maxalign) & ~maxalign) >> 3); +} + +/* Parse struct/union declaration. */ +static CTypeID cp_decl_struct(CPState *cp, CPDecl *sdecl, CTInfo sinfo) +{ + CTypeID sid = cp_struct_name(cp, sdecl, sinfo); + if (cp_opt(cp, '{')) { /* Struct/union definition. */ + CTypeID lastid = sid; + int lastdecl = 0; + while (cp->tok != '}') { + CPDecl decl; + CPscl scl = cp_decl_spec(cp, &decl, CDF_STATIC); + decl.mode = scl ? CPARSE_MODE_DIRECT : + CPARSE_MODE_DIRECT|CPARSE_MODE_ABSTRACT|CPARSE_MODE_FIELD; + + for (;;) { + CTypeID ctypeid; + + if (lastdecl) cp_err_token(cp, '}'); + + /* Parse field declarator. */ + decl.bits = CTSIZE_INVALID; + cp_declarator(cp, &decl); + ctypeid = cp_decl_intern(cp, &decl); + + if ((scl & CDF_STATIC)) { /* Static constant in struct namespace. */ + CType *ct; + CTypeID fieldid = cp_decl_constinit(cp, &ct, ctypeid); + ctype_get(cp->cts, lastid)->sib = fieldid; + lastid = fieldid; + ctype_setname(ct, decl.name); + } else { + CTSize bsz = CTBSZ_FIELD; /* Temp. for layout phase. */ + CType *ct; + CTypeID fieldid = lj_ctype_new(cp->cts, &ct); /* Do this first. */ + CType *tct = ctype_raw(cp->cts, ctypeid); + + if (decl.bits == CTSIZE_INVALID) { /* Regular field. */ + if (ctype_isarray(tct->info) && tct->size == CTSIZE_INVALID) + lastdecl = 1; /* a[] or a[?] must be the last declared field. */ + + /* Accept transparent struct/union/enum. */ + if (!decl.name) { + if (!((ctype_isstruct(tct->info) && !(tct->info & CTF_VLA)) || + ctype_isenum(tct->info))) + cp_err_token(cp, CTOK_IDENT); + ct->info = CTINFO(CT_ATTRIB, CTATTRIB(CTA_SUBTYPE) + ctypeid); + ct->size = ctype_isstruct(tct->info) ? + (decl.attr|0x80000000u) : 0; /* For layout phase. */ + goto add_field; + } + } else { /* Bitfield. */ + bsz = decl.bits; + if (!ctype_isinteger_or_bool(tct->info) || + (bsz == 0 && decl.name) || 8*tct->size > CTBSZ_MAX || + bsz > ((tct->info & CTF_BOOL) ? 1 : 8*tct->size)) + cp_errmsg(cp, ':', LJ_ERR_BADVAL); + } + + /* Create temporary field for layout phase. */ + ct->info = CTINFO(CT_FIELD, ctypeid + (bsz << CTSHIFT_BITCSZ)); + ct->size = decl.attr; + if (decl.name) ctype_setname(ct, decl.name); + + add_field: + ctype_get(cp->cts, lastid)->sib = fieldid; + lastid = fieldid; + } + if (!cp_opt(cp, ',')) break; + cp_decl_reset(&decl); + } + cp_check(cp, ';'); + } + cp_check(cp, '}'); + ctype_get(cp->cts, lastid)->sib = 0; /* Drop sib = 1 for empty structs. */ + cp_decl_attributes(cp, sdecl); /* Layout phase needs postfix attributes. */ + cp_struct_layout(cp, sid, sdecl->attr); + } + return sid; +} + +/* Parse enum declaration. */ +static CTypeID cp_decl_enum(CPState *cp, CPDecl *sdecl) +{ + CTypeID eid = cp_struct_name(cp, sdecl, CTINFO(CT_ENUM, CTID_VOID)); + CTInfo einfo = CTINFO(CT_ENUM, CTALIGN(2) + CTID_UINT32); + CTSize esize = 4; /* Only 32 bit enums are supported. */ + if (cp_opt(cp, '{')) { /* Enum definition. */ + CPValue k; + CTypeID lastid = eid; + k.u32 = 0; + k.id = CTID_INT32; + do { + GCstr *name = cp->str; + if (cp->tok != CTOK_IDENT) cp_err_token(cp, CTOK_IDENT); + if (cp->val.id) cp_errmsg(cp, 0, LJ_ERR_FFI_REDEF, strdata(name)); + cp_next(cp); + if (cp_opt(cp, '=')) { + cp_expr_kint(cp, &k); + if (k.id == CTID_UINT32) { + /* C99 says that enum constants are always (signed) integers. + ** But since unsigned constants like 0x80000000 are quite common, + ** those are left as uint32_t. + */ + if (k.i32 >= 0) k.id = CTID_INT32; + } else { + /* OTOH it's common practice and even mandated by some ABIs + ** that the enum type itself is unsigned, unless there are any + ** negative constants. + */ + k.id = CTID_INT32; + if (k.i32 < 0) einfo = CTINFO(CT_ENUM, CTALIGN(2) + CTID_INT32); + } + } + /* Add named enum constant. */ + { + CType *ct; + CTypeID constid = lj_ctype_new(cp->cts, &ct); + ctype_get(cp->cts, lastid)->sib = constid; + lastid = constid; + ctype_setname(ct, name); + ct->info = CTINFO(CT_CONSTVAL, CTF_CONST|k.id); + ct->size = k.u32++; + if (k.u32 == 0x80000000u) k.id = CTID_UINT32; + lj_ctype_addname(cp->cts, ct, constid); + } + if (!cp_opt(cp, ',')) break; + } while (cp->tok != '}'); /* Trailing ',' is ok. */ + cp_check(cp, '}'); + /* Complete enum. */ + ctype_get(cp->cts, eid)->info = einfo; + ctype_get(cp->cts, eid)->size = esize; + } + return eid; +} + +/* Parse declaration specifiers. */ +static CPscl cp_decl_spec(CPState *cp, CPDecl *decl, CPscl scl) +{ + uint32_t cds = 0, sz = 0; + CTypeID tdef = 0; + + decl->cp = cp; + decl->mode = cp->mode; + decl->name = NULL; + decl->redir = NULL; + decl->attr = 0; + decl->fattr = 0; + decl->pos = decl->top = 0; + decl->stack[0].next = 0; + + for (;;) { /* Parse basic types. */ + cp_decl_attributes(cp, decl); + if (cp->tok >= CTOK_FIRSTDECL && cp->tok <= CTOK_LASTDECLFLAG) { + uint32_t cbit; + if (cp->ct->size) { + if (sz) goto end_decl; + sz = cp->ct->size; + } + cbit = (1u << (cp->tok - CTOK_FIRSTDECL)); + cds = cds | cbit | ((cbit & cds & CDF_LONG) << 1); + if (cp->tok >= CTOK_FIRSTSCL) { + if (!(scl & cbit)) cp_errmsg(cp, cp->tok, LJ_ERR_FFI_BADSCL); + } else if (tdef) { + goto end_decl; + } + cp_next(cp); + continue; + } + if (sz || tdef || + (cds & (CDF_SHORT|CDF_LONG|CDF_SIGNED|CDF_UNSIGNED|CDF_COMPLEX))) + break; + switch (cp->tok) { + case CTOK_STRUCT: + tdef = cp_decl_struct(cp, decl, CTINFO(CT_STRUCT, 0)); + continue; + case CTOK_UNION: + tdef = cp_decl_struct(cp, decl, CTINFO(CT_STRUCT, CTF_UNION)); + continue; + case CTOK_ENUM: + tdef = cp_decl_enum(cp, decl); + continue; + case CTOK_IDENT: + if (ctype_istypedef(cp->ct->info)) { + tdef = ctype_cid(cp->ct->info); /* Get typedef. */ + cp_next(cp); + continue; + } + break; + case '$': + tdef = cp->val.id; + cp_next(cp); + continue; + default: + break; + } + break; + } +end_decl: + + if ((cds & CDF_COMPLEX)) /* Use predefined complex types. */ + tdef = sz == 4 ? CTID_COMPLEX_FLOAT : CTID_COMPLEX_DOUBLE; + + if (tdef) { + cp_push_type(decl, tdef); + } else if ((cds & CDF_VOID)) { + cp_push(decl, CTINFO(CT_VOID, (decl->attr & CTF_QUAL)), CTSIZE_INVALID); + decl->attr &= ~CTF_QUAL; + } else { + /* Determine type info and size. */ + CTInfo info = CTINFO(CT_NUM, (cds & CDF_UNSIGNED) ? CTF_UNSIGNED : 0); + if ((cds & CDF_BOOL)) { + if ((cds & ~(CDF_SCL|CDF_BOOL|CDF_INT|CDF_SIGNED|CDF_UNSIGNED))) + cp_errmsg(cp, 0, LJ_ERR_FFI_INVTYPE); + info |= CTF_BOOL; + if (!(cds & CDF_SIGNED)) info |= CTF_UNSIGNED; + if (!sz) { + sz = 1; + } + } else if ((cds & CDF_FP)) { + info = CTINFO(CT_NUM, CTF_FP); + if ((cds & CDF_LONG)) sz = sizeof(long double); + } else if ((cds & CDF_CHAR)) { + if ((cds & (CDF_CHAR|CDF_SIGNED|CDF_UNSIGNED)) == CDF_CHAR) + info |= CTF_UCHAR; /* Handle platforms where char is unsigned. */ + } else if ((cds & CDF_SHORT)) { + sz = sizeof(short); + } else if ((cds & CDF_LONGLONG)) { + sz = 8; + } else if ((cds & CDF_LONG)) { + info |= CTF_LONG; + sz = sizeof(long); + } else if (!sz) { + if (!(cds & (CDF_SIGNED|CDF_UNSIGNED))) + cp_errmsg(cp, cp->tok, LJ_ERR_FFI_DECLSPEC); + sz = sizeof(int); + } + lua_assert(sz != 0); + info += CTALIGN(lj_fls(sz)); /* Use natural alignment. */ + info += (decl->attr & CTF_QUAL); /* Merge qualifiers. */ + cp_push(decl, info, sz); + decl->attr &= ~CTF_QUAL; + } + decl->specpos = decl->pos; + decl->specattr = decl->attr; + decl->specfattr = decl->fattr; + return (cds & CDF_SCL); /* Return storage class. */ +} + +/* Parse array declaration. */ +static void cp_decl_array(CPState *cp, CPDecl *decl) +{ + CTInfo info = CTINFO(CT_ARRAY, 0); + CTSize nelem = CTSIZE_INVALID; /* Default size for a[] or a[?]. */ + cp_decl_attributes(cp, decl); + if (cp_opt(cp, '?')) + info |= CTF_VLA; /* Create variable-length array a[?]. */ + else if (cp->tok != ']') + nelem = cp_expr_ksize(cp); + cp_check(cp, ']'); + cp_add(decl, info, nelem); +} + +/* Parse function declaration. */ +static void cp_decl_func(CPState *cp, CPDecl *fdecl) +{ + CTSize nargs = 0; + CTInfo info = CTINFO(CT_FUNC, 0); + CTypeID lastid = 0, anchor = 0; + if (cp->tok != ')') { + do { + CPDecl decl; + CTypeID ctypeid, fieldid; + CType *ct; + if (cp_opt(cp, '.')) { /* Vararg function. */ + cp_check(cp, '.'); /* Workaround for the minimalistic lexer. */ + cp_check(cp, '.'); + info |= CTF_VARARG; + break; + } + cp_decl_spec(cp, &decl, CDF_REGISTER); + decl.mode = CPARSE_MODE_DIRECT|CPARSE_MODE_ABSTRACT; + cp_declarator(cp, &decl); + ctypeid = cp_decl_intern(cp, &decl); + ct = ctype_raw(cp->cts, ctypeid); + if (ctype_isvoid(ct->info)) + break; + else if (ctype_isrefarray(ct->info)) + ctypeid = lj_ctype_intern(cp->cts, + CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(ct->info)), CTSIZE_PTR); + else if (ctype_isfunc(ct->info)) + ctypeid = lj_ctype_intern(cp->cts, + CTINFO(CT_PTR, CTALIGN_PTR|ctypeid), CTSIZE_PTR); + /* Add new parameter. */ + fieldid = lj_ctype_new(cp->cts, &ct); + if (anchor) + ctype_get(cp->cts, lastid)->sib = fieldid; + else + anchor = fieldid; + lastid = fieldid; + if (decl.name) ctype_setname(ct, decl.name); + ct->info = CTINFO(CT_FIELD, ctypeid); + ct->size = nargs++; + } while (cp_opt(cp, ',')); + } + cp_check(cp, ')'); + if (cp_opt(cp, '{')) { /* Skip function definition. */ + int level = 1; + cp->mode |= CPARSE_MODE_SKIP; + for (;;) { + if (cp->tok == '{') level++; + else if (cp->tok == '}' && --level == 0) break; + else if (cp->tok == CTOK_EOF) cp_err_token(cp, '}'); + cp_next(cp); + } + cp->mode &= ~CPARSE_MODE_SKIP; + cp->tok = ';'; /* Ok for cp_decl_multi(), error in cp_decl_single(). */ + } + info |= (fdecl->fattr & ~CTMASK_CID); + fdecl->fattr = 0; + fdecl->stack[cp_add(fdecl, info, nargs)].sib = anchor; +} + +/* Parse declarator. */ +static void cp_declarator(CPState *cp, CPDecl *decl) +{ + if (++cp->depth > CPARSE_MAX_DECLDEPTH) cp_err(cp, LJ_ERR_XLEVELS); + + for (;;) { /* Head of declarator. */ + if (cp_opt(cp, '*')) { /* Pointer. */ + CTSize sz; + CTInfo info; + cp_decl_attributes(cp, decl); + sz = CTSIZE_PTR; + info = CTINFO(CT_PTR, CTALIGN_PTR); +#if LJ_64 + if (ctype_msizeP(decl->attr) == 4) { + sz = 4; + info = CTINFO(CT_PTR, CTALIGN(2)); + } +#endif + info += (decl->attr & (CTF_QUAL|CTF_REF)); + decl->attr &= ~(CTF_QUAL|(CTMASK_MSIZEP<attr &= ~(CTF_QUAL|(CTMASK_MSIZEP<mode & CPARSE_MODE_ABSTRACT) && + (cp->tok == ')' || cp_istypedecl(cp))) goto func_decl; + pos = decl->pos; + cp_declarator(cp, decl); + cp_check(cp, ')'); + decl->pos = pos; + } else if (cp->tok == CTOK_IDENT) { /* Direct declarator. */ + if (!(decl->mode & CPARSE_MODE_DIRECT)) cp_err_token(cp, CTOK_EOF); + decl->name = cp->str; + decl->nameid = cp->val.id; + cp_next(cp); + } else { /* Abstract declarator. */ + if (!(decl->mode & CPARSE_MODE_ABSTRACT)) cp_err_token(cp, CTOK_IDENT); + } + + for (;;) { /* Tail of declarator. */ + if (cp_opt(cp, '[')) { /* Array. */ + cp_decl_array(cp, decl); + } else if (cp_opt(cp, '(')) { /* Function. */ + func_decl: + cp_decl_func(cp, decl); + } else { + break; + } + } + + if ((decl->mode & CPARSE_MODE_FIELD) && cp_opt(cp, ':')) /* Field width. */ + decl->bits = cp_expr_ksize(cp); + + /* Process postfix attributes. */ + cp_decl_attributes(cp, decl); + cp_push_attributes(decl); + + cp->depth--; +} + +/* Parse an abstract type declaration and return it's C type ID. */ +static CTypeID cp_decl_abstract(CPState *cp) +{ + CPDecl decl; + cp_decl_spec(cp, &decl, 0); + decl.mode = CPARSE_MODE_ABSTRACT; + cp_declarator(cp, &decl); + return cp_decl_intern(cp, &decl); +} + +/* Handle pragmas. */ +static void cp_pragma(CPState *cp, BCLine pragmaline) +{ + cp_next(cp); + if (cp->tok == CTOK_IDENT && + cp->str->hash == H_(e79b999f,42ca3e85)) { /* pack */ + cp_next(cp); + cp_check(cp, '('); + if (cp->tok == CTOK_IDENT) { + if (cp->str->hash == H_(738e923c,a1b65954)) { /* push */ + if (cp->curpack < CPARSE_MAX_PACKSTACK) { + cp->packstack[cp->curpack+1] = cp->packstack[cp->curpack]; + cp->curpack++; + } + } else if (cp->str->hash == H_(6c71cf27,6c71cf27)) { /* pop */ + if (cp->curpack > 0) cp->curpack--; + } else { + cp_errmsg(cp, cp->tok, LJ_ERR_XSYMBOL); + } + cp_next(cp); + if (!cp_opt(cp, ',')) goto end_pack; + } + if (cp->tok == CTOK_INTEGER) { + cp->packstack[cp->curpack] = cp->val.u32 ? lj_fls(cp->val.u32) : 0; + cp_next(cp); + } else { + cp->packstack[cp->curpack] = 255; + } + end_pack: + cp_check(cp, ')'); + } else { /* Ignore all other pragmas. */ + while (cp->tok != CTOK_EOF && cp->linenumber == pragmaline) + cp_next(cp); + } +} + +/* Parse multiple C declarations of types or extern identifiers. */ +static void cp_decl_multi(CPState *cp) +{ + int first = 1; + while (cp->tok != CTOK_EOF) { + CPDecl decl; + CPscl scl; + if (cp_opt(cp, ';')) { /* Skip empty statements. */ + first = 0; + continue; + } + if (cp->tok == '#') { /* Workaround, since we have no preprocessor, yet. */ + BCLine pragmaline = cp->linenumber; + if (!(cp_next(cp) == CTOK_IDENT && + cp->str->hash == H_(f5e6b4f8,1d509107))) /* pragma */ + cp_errmsg(cp, cp->tok, LJ_ERR_XSYMBOL); + cp_pragma(cp, pragmaline); + continue; + } + scl = cp_decl_spec(cp, &decl, CDF_TYPEDEF|CDF_EXTERN|CDF_STATIC); + if ((cp->tok == ';' || cp->tok == CTOK_EOF) && + ctype_istypedef(decl.stack[0].info)) { + CTInfo info = ctype_rawchild(cp->cts, &decl.stack[0])->info; + if (ctype_isstruct(info) || ctype_isenum(info)) + goto decl_end; /* Accept empty declaration of struct/union/enum. */ + } + for (;;) { + CTypeID ctypeid; + cp_declarator(cp, &decl); + ctypeid = cp_decl_intern(cp, &decl); + if (decl.name && !decl.nameid) { /* NYI: redeclarations are ignored. */ + CType *ct; + CTypeID id; + if ((scl & CDF_TYPEDEF)) { /* Create new typedef. */ + id = lj_ctype_new(cp->cts, &ct); + ct->info = CTINFO(CT_TYPEDEF, ctypeid); + goto noredir; + } else if (ctype_isfunc(ctype_get(cp->cts, ctypeid)->info)) { + /* Treat both static and extern function declarations as extern. */ + ct = ctype_get(cp->cts, ctypeid); + /* We always get new anonymous functions (typedefs are copied). */ + lua_assert(gcref(ct->name) == NULL); + id = ctypeid; /* Just name it. */ + } else if ((scl & CDF_STATIC)) { /* Accept static constants. */ + id = cp_decl_constinit(cp, &ct, ctypeid); + goto noredir; + } else { /* External references have extern or no storage class. */ + id = lj_ctype_new(cp->cts, &ct); + ct->info = CTINFO(CT_EXTERN, ctypeid); + } + if (decl.redir) { /* Add attribute for redirected symbol name. */ + CType *cta; + CTypeID aid = lj_ctype_new(cp->cts, &cta); + ct = ctype_get(cp->cts, id); /* Table may have been reallocated. */ + cta->info = CTINFO(CT_ATTRIB, CTATTRIB(CTA_REDIR)); + cta->sib = ct->sib; + ct->sib = aid; + ctype_setname(cta, decl.redir); + } + noredir: + ctype_setname(ct, decl.name); + lj_ctype_addname(cp->cts, ct, id); + } + if (!cp_opt(cp, ',')) break; + cp_decl_reset(&decl); + } + decl_end: + if (cp->tok == CTOK_EOF && first) break; /* May omit ';' for 1 decl. */ + first = 0; + cp_check(cp, ';'); + } +} + +/* Parse a single C type declaration. */ +static void cp_decl_single(CPState *cp) +{ + CPDecl decl; + cp_decl_spec(cp, &decl, 0); + cp_declarator(cp, &decl); + cp->val.id = cp_decl_intern(cp, &decl); + if (cp->tok != CTOK_EOF) cp_err_token(cp, CTOK_EOF); +} + +#undef H_ + +/* ------------------------------------------------------------------------ */ + +/* Protected callback for C parser. */ +static TValue *cpcparser(lua_State *L, lua_CFunction dummy, void *ud) +{ + CPState *cp = (CPState *)ud; + UNUSED(dummy); + cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ + cp_init(cp); + if ((cp->mode & CPARSE_MODE_MULTI)) + cp_decl_multi(cp); + else + cp_decl_single(cp); + if (cp->param && cp->param != cp->L->top) + cp_err(cp, LJ_ERR_FFI_NUMPARAM); + lua_assert(cp->depth == 0); + return NULL; +} + +/* C parser. */ +int lj_cparse(CPState *cp) +{ + LJ_CTYPE_SAVE(cp->cts); + int errcode = lj_vm_cpcall(cp->L, NULL, cp, cpcparser); + if (errcode) + LJ_CTYPE_RESTORE(cp->cts); + cp_cleanup(cp); + return errcode; +} + +#endif + +``` + +`include/luajit-2.0.5/src/lj_cparse.h`: + +```h +/* +** C declaration parser. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CPARSE_H +#define _LJ_CPARSE_H + +#include "lj_obj.h" +#include "lj_ctype.h" + +#if LJ_HASFFI + +/* C parser limits. */ +#define CPARSE_MAX_BUF 32768 /* Max. token buffer size. */ +#define CPARSE_MAX_DECLSTACK 100 /* Max. declaration stack depth. */ +#define CPARSE_MAX_DECLDEPTH 20 /* Max. recursive declaration depth. */ +#define CPARSE_MAX_PACKSTACK 7 /* Max. pack pragma stack depth. */ + +/* Flags for C parser mode. */ +#define CPARSE_MODE_MULTI 1 /* Process multiple declarations. */ +#define CPARSE_MODE_ABSTRACT 2 /* Accept abstract declarators. */ +#define CPARSE_MODE_DIRECT 4 /* Accept direct declarators. */ +#define CPARSE_MODE_FIELD 8 /* Accept field width in bits, too. */ +#define CPARSE_MODE_NOIMPLICIT 16 /* Reject implicit declarations. */ +#define CPARSE_MODE_SKIP 32 /* Skip definitions, ignore errors. */ + +typedef int CPChar; /* C parser character. Unsigned ext. from char. */ +typedef int CPToken; /* C parser token. */ + +/* C parser internal value representation. */ +typedef struct CPValue { + union { + int32_t i32; /* Value for CTID_INT32. */ + uint32_t u32; /* Value for CTID_UINT32. */ + }; + CTypeID id; /* C Type ID of the value. */ +} CPValue; + +/* C parser state. */ +typedef struct CPState { + CPChar c; /* Current character. */ + CPToken tok; /* Current token. */ + CPValue val; /* Token value. */ + GCstr *str; /* Interned string of identifier/keyword. */ + CType *ct; /* C type table entry. */ + const char *p; /* Current position in input buffer. */ + SBuf sb; /* String buffer for tokens. */ + lua_State *L; /* Lua state. */ + CTState *cts; /* C type state. */ + TValue *param; /* C type parameters. */ + const char *srcname; /* Current source name. */ + BCLine linenumber; /* Input line counter. */ + int depth; /* Recursive declaration depth. */ + uint32_t tmask; /* Type mask for next identifier. */ + uint32_t mode; /* C parser mode. */ + uint8_t packstack[CPARSE_MAX_PACKSTACK]; /* Stack for pack pragmas. */ + uint8_t curpack; /* Current position in pack pragma stack. */ +} CPState; + +LJ_FUNC int lj_cparse(CPState *cp); + +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_crecord.c`: + +```c +/* +** Trace recorder for C data operations. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_ffrecord_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT && LJ_HASFFI + +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_frame.h" +#include "lj_ctype.h" +#include "lj_cdata.h" +#include "lj_cparse.h" +#include "lj_cconv.h" +#include "lj_clib.h" +#include "lj_ccall.h" +#include "lj_ff.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_ircall.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#include "lj_record.h" +#include "lj_ffrecord.h" +#include "lj_snap.h" +#include "lj_crecord.h" +#include "lj_dispatch.h" + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +#define emitconv(a, dt, st, flags) \ + emitir(IRT(IR_CONV, (dt)), (a), (st)|((dt) << 5)|(flags)) + +/* -- C type checks ------------------------------------------------------- */ + +static GCcdata *argv2cdata(jit_State *J, TRef tr, cTValue *o) +{ + GCcdata *cd; + TRef trtypeid; + if (!tref_iscdata(tr)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + cd = cdataV(o); + /* Specialize to the CTypeID. */ + trtypeid = emitir(IRT(IR_FLOAD, IRT_U16), tr, IRFL_CDATA_CTYPEID); + emitir(IRTG(IR_EQ, IRT_INT), trtypeid, lj_ir_kint(J, (int32_t)cd->ctypeid)); + return cd; +} + +/* Specialize to the CTypeID held by a cdata constructor. */ +static CTypeID crec_constructor(jit_State *J, GCcdata *cd, TRef tr) +{ + CTypeID id; + lua_assert(tref_iscdata(tr) && cd->ctypeid == CTID_CTYPEID); + id = *(CTypeID *)cdataptr(cd); + tr = emitir(IRT(IR_FLOAD, IRT_INT), tr, IRFL_CDATA_INT); + emitir(IRTG(IR_EQ, IRT_INT), tr, lj_ir_kint(J, (int32_t)id)); + return id; +} + +static CTypeID argv2ctype(jit_State *J, TRef tr, cTValue *o) +{ + if (tref_isstr(tr)) { + GCstr *s = strV(o); + CPState cp; + CTypeID oldtop; + /* Specialize to the string containing the C type declaration. */ + emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, s)); + cp.L = J->L; + cp.cts = ctype_ctsG(J2G(J)); + oldtop = cp.cts->top; + cp.srcname = strdata(s); + cp.p = strdata(s); + cp.param = NULL; + cp.mode = CPARSE_MODE_ABSTRACT|CPARSE_MODE_NOIMPLICIT; + if (lj_cparse(&cp) || cp.cts->top > oldtop) /* Avoid new struct defs. */ + lj_trace_err(J, LJ_TRERR_BADTYPE); + return cp.val.id; + } else { + GCcdata *cd = argv2cdata(J, tr, o); + return cd->ctypeid == CTID_CTYPEID ? crec_constructor(J, cd, tr) : + cd->ctypeid; + } +} + +/* Convert CType to IRType (if possible). */ +static IRType crec_ct2irt(CTState *cts, CType *ct) +{ + if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); + if (LJ_LIKELY(ctype_isnum(ct->info))) { + if ((ct->info & CTF_FP)) { + if (ct->size == sizeof(double)) + return IRT_NUM; + else if (ct->size == sizeof(float)) + return IRT_FLOAT; + } else { + uint32_t b = lj_fls(ct->size); + if (b <= 3) + return IRT_I8 + 2*b + ((ct->info & CTF_UNSIGNED) ? 1 : 0); + } + } else if (ctype_isptr(ct->info)) { + return (LJ_64 && ct->size == 8) ? IRT_P64 : IRT_P32; + } else if (ctype_iscomplex(ct->info)) { + if (ct->size == 2*sizeof(double)) + return IRT_NUM; + else if (ct->size == 2*sizeof(float)) + return IRT_FLOAT; + } + return IRT_CDATA; +} + +/* -- Optimized memory fill and copy -------------------------------------- */ + +/* Maximum length and unroll of inlined copy/fill. */ +#define CREC_COPY_MAXUNROLL 16 +#define CREC_COPY_MAXLEN 128 + +#define CREC_FILL_MAXUNROLL 16 + +/* Number of windowed registers used for optimized memory copy. */ +#if LJ_TARGET_X86 +#define CREC_COPY_REGWIN 2 +#elif LJ_TARGET_PPC || LJ_TARGET_MIPS +#define CREC_COPY_REGWIN 8 +#else +#define CREC_COPY_REGWIN 4 +#endif + +/* List of memory offsets for copy/fill. */ +typedef struct CRecMemList { + CTSize ofs; /* Offset in bytes. */ + IRType tp; /* Type of load/store. */ + TRef trofs; /* TRef of interned offset. */ + TRef trval; /* TRef of load value. */ +} CRecMemList; + +/* Generate copy list for element-wise struct copy. */ +static MSize crec_copy_struct(CRecMemList *ml, CTState *cts, CType *ct) +{ + CTypeID fid = ct->sib; + MSize mlp = 0; + while (fid) { + CType *df = ctype_get(cts, fid); + fid = df->sib; + if (ctype_isfield(df->info)) { + CType *cct; + IRType tp; + if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ + cct = ctype_rawchild(cts, df); /* Field type. */ + tp = crec_ct2irt(cts, cct); + if (tp == IRT_CDATA) return 0; /* NYI: aggregates. */ + if (mlp >= CREC_COPY_MAXUNROLL) return 0; + ml[mlp].ofs = df->size; + ml[mlp].tp = tp; + mlp++; + if (ctype_iscomplex(cct->info)) { + if (mlp >= CREC_COPY_MAXUNROLL) return 0; + ml[mlp].ofs = df->size + (cct->size >> 1); + ml[mlp].tp = tp; + mlp++; + } + } else if (!ctype_isconstval(df->info)) { + /* NYI: bitfields and sub-structures. */ + return 0; + } + } + return mlp; +} + +/* Generate unrolled copy list, from highest to lowest step size/alignment. */ +static MSize crec_copy_unroll(CRecMemList *ml, CTSize len, CTSize step, + IRType tp) +{ + CTSize ofs = 0; + MSize mlp = 0; + if (tp == IRT_CDATA) tp = IRT_U8 + 2*lj_fls(step); + do { + while (ofs + step <= len) { + if (mlp >= CREC_COPY_MAXUNROLL) return 0; + ml[mlp].ofs = ofs; + ml[mlp].tp = tp; + mlp++; + ofs += step; + } + step >>= 1; + tp -= 2; + } while (ofs < len); + return mlp; +} + +/* +** Emit copy list with windowed loads/stores. +** LJ_TARGET_UNALIGNED: may emit unaligned loads/stores (not marked as such). +*/ +static void crec_copy_emit(jit_State *J, CRecMemList *ml, MSize mlp, + TRef trdst, TRef trsrc) +{ + MSize i, j, rwin = 0; + for (i = 0, j = 0; i < mlp; ) { + TRef trofs = lj_ir_kintp(J, ml[i].ofs); + TRef trsptr = emitir(IRT(IR_ADD, IRT_PTR), trsrc, trofs); + ml[i].trval = emitir(IRT(IR_XLOAD, ml[i].tp), trsptr, 0); + ml[i].trofs = trofs; + i++; + rwin += (LJ_SOFTFP && ml[i].tp == IRT_NUM) ? 2 : 1; + if (rwin >= CREC_COPY_REGWIN || i >= mlp) { /* Flush buffered stores. */ + rwin = 0; + for ( ; j < i; j++) { + TRef trdptr = emitir(IRT(IR_ADD, IRT_PTR), trdst, ml[j].trofs); + emitir(IRT(IR_XSTORE, ml[j].tp), trdptr, ml[j].trval); + } + } + } +} + +/* Optimized memory copy. */ +static void crec_copy(jit_State *J, TRef trdst, TRef trsrc, TRef trlen, + CType *ct) +{ + if (tref_isk(trlen)) { /* Length must be constant. */ + CRecMemList ml[CREC_COPY_MAXUNROLL]; + MSize mlp = 0; + CTSize step = 1, len = (CTSize)IR(tref_ref(trlen))->i; + IRType tp = IRT_CDATA; + int needxbar = 0; + if (len == 0) return; /* Shortcut. */ + if (len > CREC_COPY_MAXLEN) goto fallback; + if (ct) { + CTState *cts = ctype_ctsG(J2G(J)); + lua_assert(ctype_isarray(ct->info) || ctype_isstruct(ct->info)); + if (ctype_isarray(ct->info)) { + CType *cct = ctype_rawchild(cts, ct); + tp = crec_ct2irt(cts, cct); + if (tp == IRT_CDATA) goto rawcopy; + step = lj_ir_type_size[tp]; + lua_assert((len & (step-1)) == 0); + } else if ((ct->info & CTF_UNION)) { + step = (1u << ctype_align(ct->info)); + goto rawcopy; + } else { + mlp = crec_copy_struct(ml, cts, ct); + goto emitcopy; + } + } else { + rawcopy: + needxbar = 1; + if (LJ_TARGET_UNALIGNED || step >= CTSIZE_PTR) + step = CTSIZE_PTR; + } + mlp = crec_copy_unroll(ml, len, step, tp); + emitcopy: + if (mlp) { + crec_copy_emit(J, ml, mlp, trdst, trsrc); + if (needxbar) + emitir(IRT(IR_XBAR, IRT_NIL), 0, 0); + return; + } + } +fallback: + /* Call memcpy. Always needs a barrier to disable alias analysis. */ + lj_ir_call(J, IRCALL_memcpy, trdst, trsrc, trlen); + emitir(IRT(IR_XBAR, IRT_NIL), 0, 0); +} + +/* Generate unrolled fill list, from highest to lowest step size/alignment. */ +static MSize crec_fill_unroll(CRecMemList *ml, CTSize len, CTSize step) +{ + CTSize ofs = 0; + MSize mlp = 0; + IRType tp = IRT_U8 + 2*lj_fls(step); + do { + while (ofs + step <= len) { + if (mlp >= CREC_COPY_MAXUNROLL) return 0; + ml[mlp].ofs = ofs; + ml[mlp].tp = tp; + mlp++; + ofs += step; + } + step >>= 1; + tp -= 2; + } while (ofs < len); + return mlp; +} + +/* +** Emit stores for fill list. +** LJ_TARGET_UNALIGNED: may emit unaligned stores (not marked as such). +*/ +static void crec_fill_emit(jit_State *J, CRecMemList *ml, MSize mlp, + TRef trdst, TRef trfill) +{ + MSize i; + for (i = 0; i < mlp; i++) { + TRef trofs = lj_ir_kintp(J, ml[i].ofs); + TRef trdptr = emitir(IRT(IR_ADD, IRT_PTR), trdst, trofs); + emitir(IRT(IR_XSTORE, ml[i].tp), trdptr, trfill); + } +} + +/* Optimized memory fill. */ +static void crec_fill(jit_State *J, TRef trdst, TRef trlen, TRef trfill, + CTSize step) +{ + if (tref_isk(trlen)) { /* Length must be constant. */ + CRecMemList ml[CREC_FILL_MAXUNROLL]; + MSize mlp; + CTSize len = (CTSize)IR(tref_ref(trlen))->i; + if (len == 0) return; /* Shortcut. */ + if (LJ_TARGET_UNALIGNED || step >= CTSIZE_PTR) + step = CTSIZE_PTR; + if (step * CREC_FILL_MAXUNROLL < len) goto fallback; + mlp = crec_fill_unroll(ml, len, step); + if (!mlp) goto fallback; + if (tref_isk(trfill) || ml[0].tp != IRT_U8) + trfill = emitconv(trfill, IRT_INT, IRT_U8, 0); + if (ml[0].tp != IRT_U8) { /* Scatter U8 to U16/U32/U64. */ + if (CTSIZE_PTR == 8 && ml[0].tp == IRT_U64) { + if (tref_isk(trfill)) /* Pointless on x64 with zero-extended regs. */ + trfill = emitconv(trfill, IRT_U64, IRT_U32, 0); + trfill = emitir(IRT(IR_MUL, IRT_U64), trfill, + lj_ir_kint64(J, U64x(01010101,01010101))); + } else { + trfill = emitir(IRTI(IR_MUL), trfill, + lj_ir_kint(J, ml[0].tp == IRT_U16 ? 0x0101 : 0x01010101)); + } + } + crec_fill_emit(J, ml, mlp, trdst, trfill); + } else { +fallback: + /* Call memset. Always needs a barrier to disable alias analysis. */ + lj_ir_call(J, IRCALL_memset, trdst, trfill, trlen); /* Note: arg order! */ + } + emitir(IRT(IR_XBAR, IRT_NIL), 0, 0); +} + +/* -- Convert C type to C type -------------------------------------------- */ + +/* +** This code mirrors the code in lj_cconv.c. It performs the same steps +** for the trace recorder that lj_cconv.c does for the interpreter. +** +** One major difference is that we can get away with much fewer checks +** here. E.g. checks for casts, constness or correct types can often be +** omitted, even if they might fail. The interpreter subsequently throws +** an error, which aborts the trace. +** +** All operations are specialized to their C types, so the on-trace +** outcome must be the same as the outcome in the interpreter. If the +** interpreter doesn't throw an error, then the trace is correct, too. +** Care must be taken not to generate invalid (temporary) IR or to +** trigger asserts. +*/ + +/* Determine whether a passed number or cdata number is non-zero. */ +static int crec_isnonzero(CType *s, void *p) +{ + if (p == (void *)0) + return 0; + if (p == (void *)1) + return 1; + if ((s->info & CTF_FP)) { + if (s->size == sizeof(float)) + return (*(float *)p != 0); + else + return (*(double *)p != 0); + } else { + if (s->size == 1) + return (*(uint8_t *)p != 0); + else if (s->size == 2) + return (*(uint16_t *)p != 0); + else if (s->size == 4) + return (*(uint32_t *)p != 0); + else + return (*(uint64_t *)p != 0); + } +} + +static TRef crec_ct_ct(jit_State *J, CType *d, CType *s, TRef dp, TRef sp, + void *svisnz) +{ + IRType dt = crec_ct2irt(ctype_ctsG(J2G(J)), d); + IRType st = crec_ct2irt(ctype_ctsG(J2G(J)), s); + CTSize dsize = d->size, ssize = s->size; + CTInfo dinfo = d->info, sinfo = s->info; + + if (ctype_type(dinfo) > CT_MAYCONVERT || ctype_type(sinfo) > CT_MAYCONVERT) + goto err_conv; + + /* + ** Note: Unlike lj_cconv_ct_ct(), sp holds the _value_ of pointers and + ** numbers up to 8 bytes. Otherwise sp holds a pointer. + */ + + switch (cconv_idx2(dinfo, sinfo)) { + /* Destination is a bool. */ + case CCX(B, B): + goto xstore; /* Source operand is already normalized. */ + case CCX(B, I): + case CCX(B, F): + if (st != IRT_CDATA) { + /* Specialize to the result of a comparison against 0. */ + TRef zero = (st == IRT_NUM || st == IRT_FLOAT) ? lj_ir_knum(J, 0) : + (st == IRT_I64 || st == IRT_U64) ? lj_ir_kint64(J, 0) : + lj_ir_kint(J, 0); + int isnz = crec_isnonzero(s, svisnz); + emitir(IRTG(isnz ? IR_NE : IR_EQ, st), sp, zero); + sp = lj_ir_kint(J, isnz); + goto xstore; + } + goto err_nyi; + + /* Destination is an integer. */ + case CCX(I, B): + case CCX(I, I): + conv_I_I: + if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; + /* Extend 32 to 64 bit integer. */ + if (dsize == 8 && ssize < 8 && !(LJ_64 && (sinfo & CTF_UNSIGNED))) + sp = emitconv(sp, dt, ssize < 4 ? IRT_INT : st, + (sinfo & CTF_UNSIGNED) ? 0 : IRCONV_SEXT); + else if (dsize < 8 && ssize == 8) /* Truncate from 64 bit integer. */ + sp = emitconv(sp, dsize < 4 ? IRT_INT : dt, st, 0); + else if (st == IRT_INT) + sp = lj_opt_narrow_toint(J, sp); + xstore: + if (dt == IRT_I64 || dt == IRT_U64) lj_needsplit(J); + if (dp == 0) return sp; + emitir(IRT(IR_XSTORE, dt), dp, sp); + break; + case CCX(I, C): + sp = emitir(IRT(IR_XLOAD, st), sp, 0); /* Load re. */ + /* fallthrough */ + case CCX(I, F): + if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; + sp = emitconv(sp, dsize < 4 ? IRT_INT : dt, st, IRCONV_TRUNC|IRCONV_ANY); + goto xstore; + case CCX(I, P): + case CCX(I, A): + sinfo = CTINFO(CT_NUM, CTF_UNSIGNED); + ssize = CTSIZE_PTR; + st = IRT_UINTP; + if (((dsize ^ ssize) & 8) == 0) { /* Must insert no-op type conversion. */ + sp = emitconv(sp, dsize < 4 ? IRT_INT : dt, IRT_PTR, 0); + goto xstore; + } + goto conv_I_I; + + /* Destination is a floating-point number. */ + case CCX(F, B): + case CCX(F, I): + conv_F_I: + if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; + sp = emitconv(sp, dt, ssize < 4 ? IRT_INT : st, 0); + goto xstore; + case CCX(F, C): + sp = emitir(IRT(IR_XLOAD, st), sp, 0); /* Load re. */ + /* fallthrough */ + case CCX(F, F): + conv_F_F: + if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; + if (dt != st) sp = emitconv(sp, dt, st, 0); + goto xstore; + + /* Destination is a complex number. */ + case CCX(C, I): + case CCX(C, F): + { /* Clear im. */ + TRef ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, (dsize >> 1))); + emitir(IRT(IR_XSTORE, dt), ptr, lj_ir_knum(J, 0)); + } + /* Convert to re. */ + if ((sinfo & CTF_FP)) goto conv_F_F; else goto conv_F_I; + + case CCX(C, C): + if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; + { + TRef re, im, ptr; + re = emitir(IRT(IR_XLOAD, st), sp, 0); + ptr = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, (ssize >> 1))); + im = emitir(IRT(IR_XLOAD, st), ptr, 0); + if (dt != st) { + re = emitconv(re, dt, st, 0); + im = emitconv(im, dt, st, 0); + } + emitir(IRT(IR_XSTORE, dt), dp, re); + ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, (dsize >> 1))); + emitir(IRT(IR_XSTORE, dt), ptr, im); + } + break; + + /* Destination is a vector. */ + case CCX(V, I): + case CCX(V, F): + case CCX(V, C): + case CCX(V, V): + goto err_nyi; + + /* Destination is a pointer. */ + case CCX(P, P): + case CCX(P, A): + case CCX(P, S): + /* There are only 32 bit pointers/addresses on 32 bit machines. + ** Also ok on x64, since all 32 bit ops clear the upper part of the reg. + */ + goto xstore; + case CCX(P, I): + if (st == IRT_CDATA) goto err_nyi; + if (!LJ_64 && ssize == 8) /* Truncate from 64 bit integer. */ + sp = emitconv(sp, IRT_U32, st, 0); + goto xstore; + case CCX(P, F): + if (st == IRT_CDATA) goto err_nyi; + /* The signed conversion is cheaper. x64 really has 47 bit pointers. */ + sp = emitconv(sp, (LJ_64 && dsize == 8) ? IRT_I64 : IRT_U32, + st, IRCONV_TRUNC|IRCONV_ANY); + goto xstore; + + /* Destination is an array. */ + case CCX(A, A): + /* Destination is a struct/union. */ + case CCX(S, S): + if (dp == 0) goto err_conv; + crec_copy(J, dp, sp, lj_ir_kint(J, dsize), d); + break; + + default: + err_conv: + err_nyi: + lj_trace_err(J, LJ_TRERR_NYICONV); + break; + } + return 0; +} + +/* -- Convert C type to TValue (load) ------------------------------------- */ + +static TRef crec_tv_ct(jit_State *J, CType *s, CTypeID sid, TRef sp) +{ + CTState *cts = ctype_ctsG(J2G(J)); + IRType t = crec_ct2irt(cts, s); + CTInfo sinfo = s->info; + if (ctype_isnum(sinfo)) { + TRef tr; + if (t == IRT_CDATA) + goto err_nyi; /* NYI: copyval of >64 bit integers. */ + tr = emitir(IRT(IR_XLOAD, t), sp, 0); + if (t == IRT_FLOAT || t == IRT_U32) { /* Keep uint32_t/float as numbers. */ + return emitconv(tr, IRT_NUM, t, 0); + } else if (t == IRT_I64 || t == IRT_U64) { /* Box 64 bit integer. */ + sp = tr; + lj_needsplit(J); + } else if ((sinfo & CTF_BOOL)) { + /* Assume not equal to zero. Fixup and emit pending guard later. */ + lj_ir_set(J, IRTGI(IR_NE), tr, lj_ir_kint(J, 0)); + J->postproc = LJ_POST_FIXGUARD; + return TREF_TRUE; + } else { + return tr; + } + } else if (ctype_isptr(sinfo) || ctype_isenum(sinfo)) { + sp = emitir(IRT(IR_XLOAD, t), sp, 0); /* Box pointers and enums. */ + } else if (ctype_isrefarray(sinfo) || ctype_isstruct(sinfo)) { + cts->L = J->L; + sid = lj_ctype_intern(cts, CTINFO_REF(sid), CTSIZE_PTR); /* Create ref. */ + } else if (ctype_iscomplex(sinfo)) { /* Unbox/box complex. */ + ptrdiff_t esz = (ptrdiff_t)(s->size >> 1); + TRef ptr, tr1, tr2, dp; + dp = emitir(IRTG(IR_CNEW, IRT_CDATA), lj_ir_kint(J, sid), TREF_NIL); + tr1 = emitir(IRT(IR_XLOAD, t), sp, 0); + ptr = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, esz)); + tr2 = emitir(IRT(IR_XLOAD, t), ptr, 0); + ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, sizeof(GCcdata))); + emitir(IRT(IR_XSTORE, t), ptr, tr1); + ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, sizeof(GCcdata)+esz)); + emitir(IRT(IR_XSTORE, t), ptr, tr2); + return dp; + } else { + /* NYI: copyval of vectors. */ + err_nyi: + lj_trace_err(J, LJ_TRERR_NYICONV); + } + /* Box pointer, ref, enum or 64 bit integer. */ + return emitir(IRTG(IR_CNEWI, IRT_CDATA), lj_ir_kint(J, sid), sp); +} + +/* -- Convert TValue to C type (store) ------------------------------------ */ + +static TRef crec_ct_tv(jit_State *J, CType *d, TRef dp, TRef sp, cTValue *sval) +{ + CTState *cts = ctype_ctsG(J2G(J)); + CTypeID sid = CTID_P_VOID; + void *svisnz = 0; + CType *s; + if (LJ_LIKELY(tref_isinteger(sp))) { + sid = CTID_INT32; + svisnz = (void *)(intptr_t)(tvisint(sval)?(intV(sval)!=0):!tviszero(sval)); + } else if (tref_isnum(sp)) { + sid = CTID_DOUBLE; + svisnz = (void *)(intptr_t)(tvisint(sval)?(intV(sval)!=0):!tviszero(sval)); + } else if (tref_isbool(sp)) { + sp = lj_ir_kint(J, tref_istrue(sp) ? 1 : 0); + sid = CTID_BOOL; + } else if (tref_isnil(sp)) { + sp = lj_ir_kptr(J, NULL); + } else if (tref_isudata(sp)) { + GCudata *ud = udataV(sval); + if (ud->udtype == UDTYPE_IO_FILE) { + TRef tr = emitir(IRT(IR_FLOAD, IRT_U8), sp, IRFL_UDATA_UDTYPE); + emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, UDTYPE_IO_FILE)); + sp = emitir(IRT(IR_FLOAD, IRT_PTR), sp, IRFL_UDATA_FILE); + } else { + sp = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, sizeof(GCudata))); + } + } else if (tref_isstr(sp)) { + if (ctype_isenum(d->info)) { /* Match string against enum constant. */ + GCstr *str = strV(sval); + CTSize ofs; + CType *cct = lj_ctype_getfield(cts, d, str, &ofs); + /* Specialize to the name of the enum constant. */ + emitir(IRTG(IR_EQ, IRT_STR), sp, lj_ir_kstr(J, str)); + if (cct && ctype_isconstval(cct->info)) { + lua_assert(ctype_child(cts, cct)->size == 4); + svisnz = (void *)(intptr_t)(ofs != 0); + sp = lj_ir_kint(J, (int32_t)ofs); + sid = ctype_cid(cct->info); + } /* else: interpreter will throw. */ + } else if (ctype_isrefarray(d->info)) { /* Copy string to array. */ + lj_trace_err(J, LJ_TRERR_BADTYPE); /* NYI */ + } else { /* Otherwise pass the string data as a const char[]. */ + /* Don't use STRREF. It folds with SNEW, which loses the trailing NUL. */ + sp = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, sizeof(GCstr))); + sid = CTID_A_CCHAR; + } + } else { /* NYI: tref_istab(sp), tref_islightud(sp). */ + IRType t; + sid = argv2cdata(J, sp, sval)->ctypeid; + s = ctype_raw(cts, sid); + svisnz = cdataptr(cdataV(sval)); + t = crec_ct2irt(cts, s); + if (ctype_isptr(s->info)) { + sp = emitir(IRT(IR_FLOAD, t), sp, IRFL_CDATA_PTR); + if (ctype_isref(s->info)) { + svisnz = *(void **)svisnz; + s = ctype_rawchild(cts, s); + if (ctype_isenum(s->info)) s = ctype_child(cts, s); + t = crec_ct2irt(cts, s); + } else { + goto doconv; + } + } else if (t == IRT_I64 || t == IRT_U64) { + sp = emitir(IRT(IR_FLOAD, t), sp, IRFL_CDATA_INT64); + lj_needsplit(J); + goto doconv; + } else if (t == IRT_INT || t == IRT_U32) { + if (ctype_isenum(s->info)) s = ctype_child(cts, s); + sp = emitir(IRT(IR_FLOAD, t), sp, IRFL_CDATA_INT); + goto doconv; + } else { + sp = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, sizeof(GCcdata))); + } + if (ctype_isnum(s->info) && t != IRT_CDATA) + sp = emitir(IRT(IR_XLOAD, t), sp, 0); /* Load number value. */ + goto doconv; + } + s = ctype_get(cts, sid); +doconv: + if (ctype_isenum(d->info)) d = ctype_child(cts, d); + return crec_ct_ct(J, d, s, dp, sp, svisnz); +} + +/* -- C data metamethods -------------------------------------------------- */ + +/* This would be rather difficult in FOLD, so do it here: +** (base+k)+(idx*sz)+ofs ==> (base+idx*sz)+(ofs+k) +** (base+(idx+k)*sz)+ofs ==> (base+idx*sz)+(ofs+k*sz) +*/ +static TRef crec_reassoc_ofs(jit_State *J, TRef tr, ptrdiff_t *ofsp, MSize sz) +{ + IRIns *ir = IR(tref_ref(tr)); + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && irref_isk(ir->op2) && + (ir->o == IR_ADD || ir->o == IR_ADDOV || ir->o == IR_SUBOV)) { + IRIns *irk = IR(ir->op2); + ptrdiff_t k; + if (LJ_64 && irk->o == IR_KINT64) + k = (ptrdiff_t)ir_kint64(irk)->u64 * sz; + else + k = (ptrdiff_t)irk->i * sz; + if (ir->o == IR_SUBOV) *ofsp -= k; else *ofsp += k; + tr = ir->op1; /* Not a TRef, but the caller doesn't care. */ + } + return tr; +} + +/* Record ctype __index/__newindex metamethods. */ +static void crec_index_meta(jit_State *J, CTState *cts, CType *ct, + RecordFFData *rd) +{ + CTypeID id = ctype_typeid(cts, ct); + cTValue *tv = lj_ctype_meta(cts, id, rd->data ? MM_newindex : MM_index); + if (!tv) + lj_trace_err(J, LJ_TRERR_BADTYPE); + if (tvisfunc(tv)) { + J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; + rd->nres = -1; /* Pending tailcall. */ + } else if (rd->data == 0 && tvistab(tv) && tref_isstr(J->base[1])) { + /* Specialize to result of __index lookup. */ + cTValue *o = lj_tab_get(J->L, tabV(tv), &rd->argv[1]); + J->base[0] = lj_record_constify(J, o); + if (!J->base[0]) + lj_trace_err(J, LJ_TRERR_BADTYPE); + /* Always specialize to the key. */ + emitir(IRTG(IR_EQ, IRT_STR), J->base[1], lj_ir_kstr(J, strV(&rd->argv[1]))); + } else { + /* NYI: resolving of non-function metamethods. */ + /* NYI: non-string keys for __index table. */ + /* NYI: stores to __newindex table. */ + lj_trace_err(J, LJ_TRERR_BADTYPE); + } +} + +void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd) +{ + TRef idx, ptr = J->base[0]; + ptrdiff_t ofs = sizeof(GCcdata); + GCcdata *cd = argv2cdata(J, ptr, &rd->argv[0]); + CTState *cts = ctype_ctsG(J2G(J)); + CType *ct = ctype_raw(cts, cd->ctypeid); + CTypeID sid = 0; + + /* Resolve pointer or reference for cdata object. */ + if (ctype_isptr(ct->info)) { + IRType t = (LJ_64 && ct->size == 8) ? IRT_P64 : IRT_P32; + if (ctype_isref(ct->info)) ct = ctype_rawchild(cts, ct); + ptr = emitir(IRT(IR_FLOAD, t), ptr, IRFL_CDATA_PTR); + ofs = 0; + ptr = crec_reassoc_ofs(J, ptr, &ofs, 1); + } + +again: + idx = J->base[1]; + if (tref_isnumber(idx)) { + idx = lj_opt_narrow_cindex(J, idx); + if (ctype_ispointer(ct->info)) { + CTSize sz; + integer_key: + if ((ct->info & CTF_COMPLEX)) + idx = emitir(IRT(IR_BAND, IRT_INTP), idx, lj_ir_kintp(J, 1)); + sz = lj_ctype_size(cts, (sid = ctype_cid(ct->info))); + idx = crec_reassoc_ofs(J, idx, &ofs, sz); +#if LJ_TARGET_ARM || LJ_TARGET_PPC + /* Hoist base add to allow fusion of index/shift into operands. */ + if (LJ_LIKELY(J->flags & JIT_F_OPT_LOOP) && ofs +#if LJ_TARGET_ARM + && (sz == 1 || sz == 4) +#endif + ) { + ptr = emitir(IRT(IR_ADD, IRT_PTR), ptr, lj_ir_kintp(J, ofs)); + ofs = 0; + } +#endif + idx = emitir(IRT(IR_MUL, IRT_INTP), idx, lj_ir_kintp(J, sz)); + ptr = emitir(IRT(IR_ADD, IRT_PTR), idx, ptr); + } + } else if (tref_iscdata(idx)) { + GCcdata *cdk = cdataV(&rd->argv[1]); + CType *ctk = ctype_raw(cts, cdk->ctypeid); + IRType t = crec_ct2irt(cts, ctk); + if (ctype_ispointer(ct->info) && t >= IRT_I8 && t <= IRT_U64) { + if (ctk->size == 8) { + idx = emitir(IRT(IR_FLOAD, t), idx, IRFL_CDATA_INT64); + } else if (ctk->size == 4) { + idx = emitir(IRT(IR_FLOAD, t), idx, IRFL_CDATA_INT); + } else { + idx = emitir(IRT(IR_ADD, IRT_PTR), idx, + lj_ir_kintp(J, sizeof(GCcdata))); + idx = emitir(IRT(IR_XLOAD, t), idx, 0); + } + if (LJ_64 && ctk->size < sizeof(intptr_t) && !(ctk->info & CTF_UNSIGNED)) + idx = emitconv(idx, IRT_INTP, IRT_INT, IRCONV_SEXT); + if (!LJ_64 && ctk->size > sizeof(intptr_t)) { + idx = emitconv(idx, IRT_INTP, t, 0); + lj_needsplit(J); + } + goto integer_key; + } + } else if (tref_isstr(idx)) { + GCstr *name = strV(&rd->argv[1]); + if (cd && cd->ctypeid == CTID_CTYPEID) + ct = ctype_raw(cts, crec_constructor(J, cd, ptr)); + if (ctype_isstruct(ct->info)) { + CTSize fofs; + CType *fct; + fct = lj_ctype_getfield(cts, ct, name, &fofs); + if (fct) { + /* Always specialize to the field name. */ + emitir(IRTG(IR_EQ, IRT_STR), idx, lj_ir_kstr(J, name)); + if (ctype_isconstval(fct->info)) { + if (fct->size >= 0x80000000u && + (ctype_child(cts, fct)->info & CTF_UNSIGNED)) { + J->base[0] = lj_ir_knum(J, (lua_Number)(uint32_t)fct->size); + return; + } + J->base[0] = lj_ir_kint(J, (int32_t)fct->size); + return; /* Interpreter will throw for newindex. */ + } else if (ctype_isbitfield(fct->info)) { + lj_trace_err(J, LJ_TRERR_NYICONV); + } else { + lua_assert(ctype_isfield(fct->info)); + sid = ctype_cid(fct->info); + } + ofs += (ptrdiff_t)fofs; + } + } else if (ctype_iscomplex(ct->info)) { + if (name->len == 2 && + ((strdata(name)[0] == 'r' && strdata(name)[1] == 'e') || + (strdata(name)[0] == 'i' && strdata(name)[1] == 'm'))) { + /* Always specialize to the field name. */ + emitir(IRTG(IR_EQ, IRT_STR), idx, lj_ir_kstr(J, name)); + if (strdata(name)[0] == 'i') ofs += (ct->size >> 1); + sid = ctype_cid(ct->info); + } + } + } + if (!sid) { + if (ctype_isptr(ct->info)) { /* Automatically perform '->'. */ + CType *cct = ctype_rawchild(cts, ct); + if (ctype_isstruct(cct->info)) { + ct = cct; + cd = NULL; + if (tref_isstr(idx)) goto again; + } + } + crec_index_meta(J, cts, ct, rd); + return; + } + + if (ofs) + ptr = emitir(IRT(IR_ADD, IRT_PTR), ptr, lj_ir_kintp(J, ofs)); + + /* Resolve reference for field. */ + ct = ctype_get(cts, sid); + if (ctype_isref(ct->info)) { + ptr = emitir(IRT(IR_XLOAD, IRT_PTR), ptr, 0); + sid = ctype_cid(ct->info); + ct = ctype_get(cts, sid); + } + + while (ctype_isattrib(ct->info)) + ct = ctype_child(cts, ct); /* Skip attributes. */ + + if (rd->data == 0) { /* __index metamethod. */ + J->base[0] = crec_tv_ct(J, ct, sid, ptr); + } else { /* __newindex metamethod. */ + rd->nres = 0; + J->needsnap = 1; + crec_ct_tv(J, ct, ptr, J->base[2], &rd->argv[2]); + } +} + +/* Record setting a finalizer. */ +static void crec_finalizer(jit_State *J, TRef trcd, cTValue *fin) +{ + TRef trlo = lj_ir_call(J, IRCALL_lj_cdata_setfin, trcd); + TRef trhi = emitir(IRT(IR_ADD, IRT_P32), trlo, lj_ir_kint(J, 4)); + if (LJ_BE) { TRef tmp = trlo; trlo = trhi; trhi = tmp; } + if (tvisfunc(fin)) { + emitir(IRT(IR_XSTORE, IRT_P32), trlo, lj_ir_kfunc(J, funcV(fin))); + emitir(IRTI(IR_XSTORE), trhi, lj_ir_kint(J, LJ_TFUNC)); + } else if (tviscdata(fin)) { + emitir(IRT(IR_XSTORE, IRT_P32), trlo, + lj_ir_kgc(J, obj2gco(cdataV(fin)), IRT_CDATA)); + emitir(IRTI(IR_XSTORE), trhi, lj_ir_kint(J, LJ_TCDATA)); + } else { + lj_trace_err(J, LJ_TRERR_BADTYPE); + } + J->needsnap = 1; +} + +/* Record cdata allocation. */ +static void crec_alloc(jit_State *J, RecordFFData *rd, CTypeID id) +{ + CTState *cts = ctype_ctsG(J2G(J)); + CTSize sz; + CTInfo info = lj_ctype_info(cts, id, &sz); + CType *d = ctype_raw(cts, id); + TRef trid; + if (!sz || sz > 128 || (info & CTF_VLA) || ctype_align(info) > CT_MEMALIGN) + lj_trace_err(J, LJ_TRERR_NYICONV); /* NYI: large/special allocations. */ + trid = lj_ir_kint(J, id); + /* Use special instruction to box pointer or 32/64 bit integer. */ + if (ctype_isptr(info) || (ctype_isinteger(info) && (sz == 4 || sz == 8))) { + TRef sp = J->base[1] ? crec_ct_tv(J, d, 0, J->base[1], &rd->argv[1]) : + ctype_isptr(info) ? lj_ir_kptr(J, NULL) : + sz == 4 ? lj_ir_kint(J, 0) : + (lj_needsplit(J), lj_ir_kint64(J, 0)); + J->base[0] = emitir(IRTG(IR_CNEWI, IRT_CDATA), trid, sp); + } else { + TRef trcd = emitir(IRTG(IR_CNEW, IRT_CDATA), trid, TREF_NIL); + cTValue *fin; + J->base[0] = trcd; + if (J->base[1] && !J->base[2] && + !lj_cconv_multi_init(cts, d, &rd->argv[1])) { + goto single_init; + } else if (ctype_isarray(d->info)) { + CType *dc = ctype_rawchild(cts, d); /* Array element type. */ + CTSize ofs, esize = dc->size; + TRef sp = 0; + TValue tv; + TValue *sval = &tv; + MSize i; + tv.u64 = 0; + if (!(ctype_isnum(dc->info) || ctype_isptr(dc->info))) + lj_trace_err(J, LJ_TRERR_NYICONV); /* NYI: init array of aggregates. */ + for (i = 1, ofs = 0; ofs < sz; ofs += esize) { + TRef dp = emitir(IRT(IR_ADD, IRT_PTR), trcd, + lj_ir_kintp(J, ofs + sizeof(GCcdata))); + if (J->base[i]) { + sp = J->base[i]; + sval = &rd->argv[i]; + i++; + } else if (i != 2) { + sp = ctype_isnum(dc->info) ? lj_ir_kint(J, 0) : TREF_NIL; + } + crec_ct_tv(J, dc, dp, sp, sval); + } + } else if (ctype_isstruct(d->info)) { + CTypeID fid = d->sib; + MSize i = 1; + while (fid) { + CType *df = ctype_get(cts, fid); + fid = df->sib; + if (ctype_isfield(df->info)) { + CType *dc; + TRef sp, dp; + TValue tv; + TValue *sval = &tv; + setintV(&tv, 0); + if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ + dc = ctype_rawchild(cts, df); /* Field type. */ + if (!(ctype_isnum(dc->info) || ctype_isptr(dc->info) || + ctype_isenum(dc->info))) + lj_trace_err(J, LJ_TRERR_NYICONV); /* NYI: init aggregates. */ + if (J->base[i]) { + sp = J->base[i]; + sval = &rd->argv[i]; + i++; + } else { + sp = ctype_isptr(dc->info) ? TREF_NIL : lj_ir_kint(J, 0); + } + dp = emitir(IRT(IR_ADD, IRT_PTR), trcd, + lj_ir_kintp(J, df->size + sizeof(GCcdata))); + crec_ct_tv(J, dc, dp, sp, sval); + } else if (!ctype_isconstval(df->info)) { + /* NYI: init bitfields and sub-structures. */ + lj_trace_err(J, LJ_TRERR_NYICONV); + } + } + } else { + TRef dp; + single_init: + dp = emitir(IRT(IR_ADD, IRT_PTR), trcd, lj_ir_kintp(J, sizeof(GCcdata))); + if (J->base[1]) { + crec_ct_tv(J, d, dp, J->base[1], &rd->argv[1]); + } else { + TValue tv; + tv.u64 = 0; + crec_ct_tv(J, d, dp, lj_ir_kint(J, 0), &tv); + } + } + /* Handle __gc metamethod. */ + fin = lj_ctype_meta(cts, id, MM_gc); + if (fin) + crec_finalizer(J, trcd, fin); + } +} + +/* Record argument conversions. */ +static TRef crec_call_args(jit_State *J, RecordFFData *rd, + CTState *cts, CType *ct) +{ + TRef args[CCI_NARGS_MAX]; + CTypeID fid; + MSize i, n; + TRef tr, *base; + cTValue *o; +#if LJ_TARGET_X86 +#if LJ_ABI_WIN + TRef *arg0 = NULL, *arg1 = NULL; +#endif + int ngpr = 0; + if (ctype_cconv(ct->info) == CTCC_THISCALL) + ngpr = 1; + else if (ctype_cconv(ct->info) == CTCC_FASTCALL) + ngpr = 2; +#endif + + /* Skip initial attributes. */ + fid = ct->sib; + while (fid) { + CType *ctf = ctype_get(cts, fid); + if (!ctype_isattrib(ctf->info)) break; + fid = ctf->sib; + } + args[0] = TREF_NIL; + for (n = 0, base = J->base+1, o = rd->argv+1; *base; n++, base++, o++) { + CTypeID did; + CType *d; + + if (n >= CCI_NARGS_MAX) + lj_trace_err(J, LJ_TRERR_NYICALL); + + if (fid) { /* Get argument type from field. */ + CType *ctf = ctype_get(cts, fid); + fid = ctf->sib; + lua_assert(ctype_isfield(ctf->info)); + did = ctype_cid(ctf->info); + } else { + if (!(ct->info & CTF_VARARG)) + lj_trace_err(J, LJ_TRERR_NYICALL); /* Too many arguments. */ + did = lj_ccall_ctid_vararg(cts, o); /* Infer vararg type. */ + } + d = ctype_raw(cts, did); + if (!(ctype_isnum(d->info) || ctype_isptr(d->info) || + ctype_isenum(d->info))) + lj_trace_err(J, LJ_TRERR_NYICALL); + tr = crec_ct_tv(J, d, 0, *base, o); + if (ctype_isinteger_or_bool(d->info)) { + if (d->size < 4) { + if ((d->info & CTF_UNSIGNED)) + tr = emitconv(tr, IRT_INT, d->size==1 ? IRT_U8 : IRT_U16, 0); + else + tr = emitconv(tr, IRT_INT, d->size==1 ? IRT_I8 : IRT_I16,IRCONV_SEXT); + } + } else if (LJ_SOFTFP && ctype_isfp(d->info) && d->size > 4) { + lj_needsplit(J); + } +#if LJ_TARGET_X86 + /* 64 bit args must not end up in registers for fastcall/thiscall. */ +#if LJ_ABI_WIN + if (!ctype_isfp(d->info)) { + /* Sigh, the Windows/x86 ABI allows reordering across 64 bit args. */ + if (tref_typerange(tr, IRT_I64, IRT_U64)) { + if (ngpr) { + arg0 = &args[n]; args[n++] = TREF_NIL; ngpr--; + if (ngpr) { + arg1 = &args[n]; args[n++] = TREF_NIL; ngpr--; + } + } + } else { + if (arg0) { *arg0 = tr; arg0 = NULL; n--; continue; } + if (arg1) { *arg1 = tr; arg1 = NULL; n--; continue; } + if (ngpr) ngpr--; + } + } +#else + if (!ctype_isfp(d->info) && ngpr) { + if (tref_typerange(tr, IRT_I64, IRT_U64)) { + /* No reordering for other x86 ABIs. Simply add alignment args. */ + do { args[n++] = TREF_NIL; } while (--ngpr); + } else { + ngpr--; + } + } +#endif +#endif + args[n] = tr; + } + tr = args[0]; + for (i = 1; i < n; i++) + tr = emitir(IRT(IR_CARG, IRT_NIL), tr, args[i]); + return tr; +} + +/* Create a snapshot for the caller, simulating a 'false' return value. */ +static void crec_snap_caller(jit_State *J) +{ + lua_State *L = J->L; + TValue *base = L->base, *top = L->top; + const BCIns *pc = J->pc; + TRef ftr = J->base[-1]; + ptrdiff_t delta; + if (!frame_islua(base-1) || J->framedepth <= 0) + lj_trace_err(J, LJ_TRERR_NYICALL); + J->pc = frame_pc(base-1); delta = 1+bc_a(J->pc[-1]); + L->top = base; L->base = base - delta; + J->base[-1] = TREF_FALSE; + J->base -= delta; J->baseslot -= (BCReg)delta; + J->maxslot = (BCReg)delta; J->framedepth--; + lj_snap_add(J); + L->base = base; L->top = top; + J->framedepth++; J->maxslot = 1; + J->base += delta; J->baseslot += (BCReg)delta; + J->base[-1] = ftr; J->pc = pc; +} + +/* Record function call. */ +static int crec_call(jit_State *J, RecordFFData *rd, GCcdata *cd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + CType *ct = ctype_raw(cts, cd->ctypeid); + IRType tp = IRT_PTR; + if (ctype_isptr(ct->info)) { + tp = (LJ_64 && ct->size == 8) ? IRT_P64 : IRT_P32; + ct = ctype_rawchild(cts, ct); + } + if (ctype_isfunc(ct->info)) { + TRef func = emitir(IRT(IR_FLOAD, tp), J->base[0], IRFL_CDATA_PTR); + CType *ctr = ctype_rawchild(cts, ct); + IRType t = crec_ct2irt(cts, ctr); + TRef tr; + TValue tv; + /* Check for blacklisted C functions that might call a callback. */ + setlightudV(&tv, + cdata_getptr(cdataptr(cd), (LJ_64 && tp == IRT_P64) ? 8 : 4)); + if (tvistrue(lj_tab_get(J->L, cts->miscmap, &tv))) + lj_trace_err(J, LJ_TRERR_BLACKL); + if (ctype_isvoid(ctr->info)) { + t = IRT_NIL; + rd->nres = 0; + } else if (!(ctype_isnum(ctr->info) || ctype_isptr(ctr->info) || + ctype_isenum(ctr->info)) || t == IRT_CDATA) { + lj_trace_err(J, LJ_TRERR_NYICALL); + } + if ((ct->info & CTF_VARARG) +#if LJ_TARGET_X86 + || ctype_cconv(ct->info) != CTCC_CDECL +#endif + ) + func = emitir(IRT(IR_CARG, IRT_NIL), func, + lj_ir_kint(J, ctype_typeid(cts, ct))); + tr = emitir(IRT(IR_CALLXS, t), crec_call_args(J, rd, cts, ct), func); + if (ctype_isbool(ctr->info)) { + if (frame_islua(J->L->base-1) && bc_b(frame_pc(J->L->base-1)[-1]) == 1) { + /* Don't check result if ignored. */ + tr = TREF_NIL; + } else { + crec_snap_caller(J); +#if LJ_TARGET_X86ORX64 + /* Note: only the x86/x64 backend supports U8 and only for EQ(tr, 0). */ + lj_ir_set(J, IRTG(IR_NE, IRT_U8), tr, lj_ir_kint(J, 0)); +#else + lj_ir_set(J, IRTGI(IR_NE), tr, lj_ir_kint(J, 0)); +#endif + J->postproc = LJ_POST_FIXGUARDSNAP; + tr = TREF_TRUE; + } + } else if (t == IRT_PTR || (LJ_64 && t == IRT_P32) || + t == IRT_I64 || t == IRT_U64 || ctype_isenum(ctr->info)) { + TRef trid = lj_ir_kint(J, ctype_cid(ct->info)); + tr = emitir(IRTG(IR_CNEWI, IRT_CDATA), trid, tr); + if (t == IRT_I64 || t == IRT_U64) lj_needsplit(J); + } else if (t == IRT_FLOAT || t == IRT_U32) { + tr = emitconv(tr, IRT_NUM, t, 0); + } else if (t == IRT_I8 || t == IRT_I16) { + tr = emitconv(tr, IRT_INT, t, IRCONV_SEXT); + } else if (t == IRT_U8 || t == IRT_U16) { + tr = emitconv(tr, IRT_INT, t, 0); + } + J->base[0] = tr; + J->needsnap = 1; + return 1; + } + return 0; +} + +void LJ_FASTCALL recff_cdata_call(jit_State *J, RecordFFData *rd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + GCcdata *cd = argv2cdata(J, J->base[0], &rd->argv[0]); + CTypeID id = cd->ctypeid; + CType *ct; + cTValue *tv; + MMS mm = MM_call; + if (id == CTID_CTYPEID) { + id = crec_constructor(J, cd, J->base[0]); + mm = MM_new; + } else if (crec_call(J, rd, cd)) { + return; + } + /* Record ctype __call/__new metamethod. */ + ct = ctype_raw(cts, id); + tv = lj_ctype_meta(cts, ctype_isptr(ct->info) ? ctype_cid(ct->info) : id, mm); + if (tv) { + if (tvisfunc(tv)) { + J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; + rd->nres = -1; /* Pending tailcall. */ + return; + } + } else if (mm == MM_new) { + crec_alloc(J, rd, id); + return; + } + /* No metamethod or NYI: non-function metamethods. */ + lj_trace_err(J, LJ_TRERR_BADTYPE); +} + +static TRef crec_arith_int64(jit_State *J, TRef *sp, CType **s, MMS mm) +{ + if (sp[0] && sp[1] && ctype_isnum(s[0]->info) && ctype_isnum(s[1]->info)) { + IRType dt; + CTypeID id; + TRef tr; + MSize i; + IROp op; + lj_needsplit(J); + if (((s[0]->info & CTF_UNSIGNED) && s[0]->size == 8) || + ((s[1]->info & CTF_UNSIGNED) && s[1]->size == 8)) { + dt = IRT_U64; id = CTID_UINT64; + } else { + dt = IRT_I64; id = CTID_INT64; + if (mm < MM_add && + !((s[0]->info | s[1]->info) & CTF_FP) && + s[0]->size == 4 && s[1]->size == 4) { /* Try to narrow comparison. */ + if (!((s[0]->info ^ s[1]->info) & CTF_UNSIGNED) || + (tref_isk(sp[1]) && IR(tref_ref(sp[1]))->i >= 0)) { + dt = (s[0]->info & CTF_UNSIGNED) ? IRT_U32 : IRT_INT; + goto comp; + } else if (tref_isk(sp[0]) && IR(tref_ref(sp[0]))->i >= 0) { + dt = (s[1]->info & CTF_UNSIGNED) ? IRT_U32 : IRT_INT; + goto comp; + } + } + } + for (i = 0; i < 2; i++) { + IRType st = tref_type(sp[i]); + if (st == IRT_NUM || st == IRT_FLOAT) + sp[i] = emitconv(sp[i], dt, st, IRCONV_TRUNC|IRCONV_ANY); + else if (!(st == IRT_I64 || st == IRT_U64)) + sp[i] = emitconv(sp[i], dt, IRT_INT, + (s[i]->info & CTF_UNSIGNED) ? 0 : IRCONV_SEXT); + } + if (mm < MM_add) { + comp: + /* Assume true comparison. Fixup and emit pending guard later. */ + if (mm == MM_eq) { + op = IR_EQ; + } else { + op = mm == MM_lt ? IR_LT : IR_LE; + if (dt == IRT_U32 || dt == IRT_U64) + op += (IR_ULT-IR_LT); + } + lj_ir_set(J, IRTG(op, dt), sp[0], sp[1]); + J->postproc = LJ_POST_FIXGUARD; + return TREF_TRUE; + } else { + tr = emitir(IRT(mm+(int)IR_ADD-(int)MM_add, dt), sp[0], sp[1]); + } + return emitir(IRTG(IR_CNEWI, IRT_CDATA), lj_ir_kint(J, id), tr); + } + return 0; +} + +static TRef crec_arith_ptr(jit_State *J, TRef *sp, CType **s, MMS mm) +{ + CTState *cts = ctype_ctsG(J2G(J)); + CType *ctp = s[0]; + if (!(sp[0] && sp[1])) return 0; + if (ctype_isptr(ctp->info) || ctype_isrefarray(ctp->info)) { + if ((mm == MM_sub || mm == MM_eq || mm == MM_lt || mm == MM_le) && + (ctype_isptr(s[1]->info) || ctype_isrefarray(s[1]->info))) { + if (mm == MM_sub) { /* Pointer difference. */ + TRef tr; + CTSize sz = lj_ctype_size(cts, ctype_cid(ctp->info)); + if (sz == 0 || (sz & (sz-1)) != 0) + return 0; /* NYI: integer division. */ + tr = emitir(IRT(IR_SUB, IRT_INTP), sp[0], sp[1]); + tr = emitir(IRT(IR_BSAR, IRT_INTP), tr, lj_ir_kint(J, lj_fls(sz))); +#if LJ_64 + tr = emitconv(tr, IRT_NUM, IRT_INTP, 0); +#endif + return tr; + } else { /* Pointer comparison (unsigned). */ + /* Assume true comparison. Fixup and emit pending guard later. */ + IROp op = mm == MM_eq ? IR_EQ : mm == MM_lt ? IR_ULT : IR_ULE; + lj_ir_set(J, IRTG(op, IRT_PTR), sp[0], sp[1]); + J->postproc = LJ_POST_FIXGUARD; + return TREF_TRUE; + } + } + if (!((mm == MM_add || mm == MM_sub) && ctype_isnum(s[1]->info))) + return 0; + } else if (mm == MM_add && ctype_isnum(ctp->info) && + (ctype_isptr(s[1]->info) || ctype_isrefarray(s[1]->info))) { + TRef tr = sp[0]; sp[0] = sp[1]; sp[1] = tr; /* Swap pointer and index. */ + ctp = s[1]; + } else { + return 0; + } + { + TRef tr = sp[1]; + IRType t = tref_type(tr); + CTSize sz = lj_ctype_size(cts, ctype_cid(ctp->info)); + CTypeID id; +#if LJ_64 + if (t == IRT_NUM || t == IRT_FLOAT) + tr = emitconv(tr, IRT_INTP, t, IRCONV_TRUNC|IRCONV_ANY); + else if (!(t == IRT_I64 || t == IRT_U64)) + tr = emitconv(tr, IRT_INTP, IRT_INT, + ((t - IRT_I8) & 1) ? 0 : IRCONV_SEXT); +#else + if (!tref_typerange(sp[1], IRT_I8, IRT_U32)) { + tr = emitconv(tr, IRT_INTP, t, + (t == IRT_NUM || t == IRT_FLOAT) ? + IRCONV_TRUNC|IRCONV_ANY : 0); + } +#endif + tr = emitir(IRT(IR_MUL, IRT_INTP), tr, lj_ir_kintp(J, sz)); + tr = emitir(IRT(mm+(int)IR_ADD-(int)MM_add, IRT_PTR), sp[0], tr); + id = lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(ctp->info)), + CTSIZE_PTR); + return emitir(IRTG(IR_CNEWI, IRT_CDATA), lj_ir_kint(J, id), tr); + } +} + +/* Record ctype arithmetic metamethods. */ +static TRef crec_arith_meta(jit_State *J, TRef *sp, CType **s, CTState *cts, + RecordFFData *rd) +{ + cTValue *tv = NULL; + if (J->base[0]) { + if (tviscdata(&rd->argv[0])) { + CTypeID id = argv2cdata(J, J->base[0], &rd->argv[0])->ctypeid; + CType *ct = ctype_raw(cts, id); + if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); + tv = lj_ctype_meta(cts, id, (MMS)rd->data); + } + if (!tv && J->base[1] && tviscdata(&rd->argv[1])) { + CTypeID id = argv2cdata(J, J->base[1], &rd->argv[1])->ctypeid; + CType *ct = ctype_raw(cts, id); + if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); + tv = lj_ctype_meta(cts, id, (MMS)rd->data); + } + } + if (tv) { + if (tvisfunc(tv)) { + J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; + rd->nres = -1; /* Pending tailcall. */ + return 0; + } /* NYI: non-function metamethods. */ + } else if ((MMS)rd->data == MM_eq) { /* Fallback cdata pointer comparison. */ + if (sp[0] && sp[1] && ctype_isnum(s[0]->info) == ctype_isnum(s[1]->info)) { + /* Assume true comparison. Fixup and emit pending guard later. */ + lj_ir_set(J, IRTG(IR_EQ, IRT_PTR), sp[0], sp[1]); + J->postproc = LJ_POST_FIXGUARD; + return TREF_TRUE; + } else { + return TREF_FALSE; + } + } + lj_trace_err(J, LJ_TRERR_BADTYPE); + return 0; +} + +void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + TRef sp[2]; + CType *s[2]; + MSize i; + for (i = 0; i < 2; i++) { + TRef tr = J->base[i]; + CType *ct = ctype_get(cts, CTID_DOUBLE); + if (!tr) { + lj_trace_err(J, LJ_TRERR_BADTYPE); + } else if (tref_iscdata(tr)) { + CTypeID id = argv2cdata(J, tr, &rd->argv[i])->ctypeid; + IRType t; + ct = ctype_raw(cts, id); + t = crec_ct2irt(cts, ct); + if (ctype_isptr(ct->info)) { /* Resolve pointer or reference. */ + tr = emitir(IRT(IR_FLOAD, t), tr, IRFL_CDATA_PTR); + if (ctype_isref(ct->info)) { + ct = ctype_rawchild(cts, ct); + t = crec_ct2irt(cts, ct); + } + } else if (t == IRT_I64 || t == IRT_U64) { + tr = emitir(IRT(IR_FLOAD, t), tr, IRFL_CDATA_INT64); + lj_needsplit(J); + goto ok; + } else if (t == IRT_INT || t == IRT_U32) { + tr = emitir(IRT(IR_FLOAD, t), tr, IRFL_CDATA_INT); + if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); + goto ok; + } else if (ctype_isfunc(ct->info)) { + tr = emitir(IRT(IR_FLOAD, IRT_PTR), tr, IRFL_CDATA_PTR); + ct = ctype_get(cts, + lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR)); + goto ok; + } else { + tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCcdata))); + } + if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); + if (ctype_isnum(ct->info)) { + if (t == IRT_CDATA) { + tr = 0; + } else { + if (t == IRT_I64 || t == IRT_U64) lj_needsplit(J); + tr = emitir(IRT(IR_XLOAD, t), tr, 0); + } + } + } else if (tref_isnil(tr)) { + tr = lj_ir_kptr(J, NULL); + ct = ctype_get(cts, CTID_P_VOID); + } else if (tref_isinteger(tr)) { + ct = ctype_get(cts, CTID_INT32); + } else if (tref_isstr(tr)) { + TRef tr2 = J->base[1-i]; + CTypeID id = argv2cdata(J, tr2, &rd->argv[1-i])->ctypeid; + ct = ctype_raw(cts, id); + if (ctype_isenum(ct->info)) { /* Match string against enum constant. */ + GCstr *str = strV(&rd->argv[i]); + CTSize ofs; + CType *cct = lj_ctype_getfield(cts, ct, str, &ofs); + if (cct && ctype_isconstval(cct->info)) { + /* Specialize to the name of the enum constant. */ + emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, str)); + ct = ctype_child(cts, cct); + tr = lj_ir_kint(J, (int32_t)ofs); + } else { /* Interpreter will throw or return false. */ + ct = ctype_get(cts, CTID_P_VOID); + } + } else if (ctype_isptr(ct->info)) { + tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCstr))); + } else { + ct = ctype_get(cts, CTID_P_VOID); + } + } else if (!tref_isnum(tr)) { + tr = 0; + ct = ctype_get(cts, CTID_P_VOID); + } + ok: + s[i] = ct; + sp[i] = tr; + } + { + TRef tr; + if (!(tr = crec_arith_int64(J, sp, s, (MMS)rd->data)) && + !(tr = crec_arith_ptr(J, sp, s, (MMS)rd->data)) && + !(tr = crec_arith_meta(J, sp, s, cts, rd))) + return; + J->base[0] = tr; + /* Fixup cdata comparisons, too. Avoids some cdata escapes. */ + if (J->postproc == LJ_POST_FIXGUARD && frame_iscont(J->L->base-1) && + !irt_isguard(J->guardemit)) { + const BCIns *pc = frame_contpc(J->L->base-1) - 1; + if (bc_op(*pc) <= BC_ISNEP) { + setframe_pc(&J2G(J)->tmptv, pc); + J2G(J)->tmptv.u32.lo = ((tref_istrue(tr) ^ bc_op(*pc)) & 1); + J->postproc = LJ_POST_FIXCOMP; + } + } + } +} + +/* -- C library namespace metamethods ------------------------------------- */ + +void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + if (tref_isudata(J->base[0]) && tref_isstr(J->base[1]) && + udataV(&rd->argv[0])->udtype == UDTYPE_FFI_CLIB) { + CLibrary *cl = (CLibrary *)uddata(udataV(&rd->argv[0])); + GCstr *name = strV(&rd->argv[1]); + CType *ct; + CTypeID id = lj_ctype_getname(cts, &ct, name, CLNS_INDEX); + cTValue *tv = lj_tab_getstr(cl->cache, name); + rd->nres = rd->data; + if (id && tv && !tvisnil(tv)) { + /* Specialize to the symbol name and make the result a constant. */ + emitir(IRTG(IR_EQ, IRT_STR), J->base[1], lj_ir_kstr(J, name)); + if (ctype_isconstval(ct->info)) { + if (ct->size >= 0x80000000u && + (ctype_child(cts, ct)->info & CTF_UNSIGNED)) + J->base[0] = lj_ir_knum(J, (lua_Number)(uint32_t)ct->size); + else + J->base[0] = lj_ir_kint(J, (int32_t)ct->size); + } else if (ctype_isextern(ct->info)) { + CTypeID sid = ctype_cid(ct->info); + void *sp = *(void **)cdataptr(cdataV(tv)); + TRef ptr; + ct = ctype_raw(cts, sid); + if (LJ_64 && !checkptr32(sp)) + ptr = lj_ir_kintp(J, (uintptr_t)sp); + else + ptr = lj_ir_kptr(J, sp); + if (rd->data) { + J->base[0] = crec_tv_ct(J, ct, sid, ptr); + } else { + J->needsnap = 1; + crec_ct_tv(J, ct, ptr, J->base[2], &rd->argv[2]); + } + } else { + J->base[0] = lj_ir_kgc(J, obj2gco(cdataV(tv)), IRT_CDATA); + } + } else { + lj_trace_err(J, LJ_TRERR_NOCACHE); + } + } /* else: interpreter will throw. */ +} + +/* -- FFI library functions ----------------------------------------------- */ + +static TRef crec_toint(jit_State *J, CTState *cts, TRef sp, TValue *sval) +{ + return crec_ct_tv(J, ctype_get(cts, CTID_INT32), 0, sp, sval); +} + +void LJ_FASTCALL recff_ffi_new(jit_State *J, RecordFFData *rd) +{ + crec_alloc(J, rd, argv2ctype(J, J->base[0], &rd->argv[0])); +} + +void LJ_FASTCALL recff_ffi_errno(jit_State *J, RecordFFData *rd) +{ + UNUSED(rd); + if (J->base[0]) + lj_trace_err(J, LJ_TRERR_NYICALL); + J->base[0] = lj_ir_call(J, IRCALL_lj_vm_errno); +} + +void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + TRef tr = J->base[0]; + if (tr) { + TRef trlen = J->base[1]; + if (!tref_isnil(trlen)) { + trlen = crec_toint(J, cts, trlen, &rd->argv[1]); + tr = crec_ct_tv(J, ctype_get(cts, CTID_P_CVOID), 0, tr, &rd->argv[0]); + } else { + tr = crec_ct_tv(J, ctype_get(cts, CTID_P_CCHAR), 0, tr, &rd->argv[0]); + trlen = lj_ir_call(J, IRCALL_strlen, tr); + } + J->base[0] = emitir(IRT(IR_XSNEW, IRT_STR), tr, trlen); + } /* else: interpreter will throw. */ +} + +void LJ_FASTCALL recff_ffi_copy(jit_State *J, RecordFFData *rd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + TRef trdst = J->base[0], trsrc = J->base[1], trlen = J->base[2]; + if (trdst && trsrc && (trlen || tref_isstr(trsrc))) { + trdst = crec_ct_tv(J, ctype_get(cts, CTID_P_VOID), 0, trdst, &rd->argv[0]); + trsrc = crec_ct_tv(J, ctype_get(cts, CTID_P_CVOID), 0, trsrc, &rd->argv[1]); + if (trlen) { + trlen = crec_toint(J, cts, trlen, &rd->argv[2]); + } else { + trlen = emitir(IRTI(IR_FLOAD), J->base[1], IRFL_STR_LEN); + trlen = emitir(IRTI(IR_ADD), trlen, lj_ir_kint(J, 1)); + } + rd->nres = 0; + crec_copy(J, trdst, trsrc, trlen, NULL); + } /* else: interpreter will throw. */ +} + +void LJ_FASTCALL recff_ffi_fill(jit_State *J, RecordFFData *rd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + TRef trdst = J->base[0], trlen = J->base[1], trfill = J->base[2]; + if (trdst && trlen) { + CTSize step = 1; + if (tviscdata(&rd->argv[0])) { /* Get alignment of original destination. */ + CTSize sz; + CType *ct = ctype_raw(cts, cdataV(&rd->argv[0])->ctypeid); + if (ctype_isptr(ct->info)) + ct = ctype_rawchild(cts, ct); + step = (1u<argv[0]); + trlen = crec_toint(J, cts, trlen, &rd->argv[1]); + if (trfill) + trfill = crec_toint(J, cts, trfill, &rd->argv[2]); + else + trfill = lj_ir_kint(J, 0); + rd->nres = 0; + crec_fill(J, trdst, trlen, trfill, step); + } /* else: interpreter will throw. */ +} + +void LJ_FASTCALL recff_ffi_typeof(jit_State *J, RecordFFData *rd) +{ + if (tref_iscdata(J->base[0])) { + TRef trid = lj_ir_kint(J, argv2ctype(J, J->base[0], &rd->argv[0])); + J->base[0] = emitir(IRTG(IR_CNEWI, IRT_CDATA), + lj_ir_kint(J, CTID_CTYPEID), trid); + } else { + setfuncV(J->L, &J->errinfo, J->fn); + lj_trace_err_info(J, LJ_TRERR_NYIFFU); + } +} + +void LJ_FASTCALL recff_ffi_istype(jit_State *J, RecordFFData *rd) +{ + argv2ctype(J, J->base[0], &rd->argv[0]); + if (tref_iscdata(J->base[1])) { + argv2ctype(J, J->base[1], &rd->argv[1]); + J->postproc = LJ_POST_FIXBOOL; + J->base[0] = TREF_TRUE; + } else { + J->base[0] = TREF_FALSE; + } +} + +void LJ_FASTCALL recff_ffi_abi(jit_State *J, RecordFFData *rd) +{ + if (tref_isstr(J->base[0])) { + /* Specialize to the ABI string to make the boolean result a constant. */ + emitir(IRTG(IR_EQ, IRT_STR), J->base[0], lj_ir_kstr(J, strV(&rd->argv[0]))); + J->postproc = LJ_POST_FIXBOOL; + J->base[0] = TREF_TRUE; + } else { + lj_trace_err(J, LJ_TRERR_BADTYPE); + } +} + +/* Record ffi.sizeof(), ffi.alignof(), ffi.offsetof(). */ +void LJ_FASTCALL recff_ffi_xof(jit_State *J, RecordFFData *rd) +{ + CTypeID id = argv2ctype(J, J->base[0], &rd->argv[0]); + if (rd->data == FF_ffi_sizeof) { + CType *ct = lj_ctype_rawref(ctype_ctsG(J2G(J)), id); + if (ctype_isvltype(ct->info)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + } else if (rd->data == FF_ffi_offsetof) { /* Specialize to the field name. */ + if (!tref_isstr(J->base[1])) + lj_trace_err(J, LJ_TRERR_BADTYPE); + emitir(IRTG(IR_EQ, IRT_STR), J->base[1], lj_ir_kstr(J, strV(&rd->argv[1]))); + rd->nres = 3; /* Just in case. */ + } + J->postproc = LJ_POST_FIXCONST; + J->base[0] = J->base[1] = J->base[2] = TREF_NIL; +} + +void LJ_FASTCALL recff_ffi_gc(jit_State *J, RecordFFData *rd) +{ + argv2cdata(J, J->base[0], &rd->argv[0]); + crec_finalizer(J, J->base[0], &rd->argv[1]); +} + +/* -- Miscellaneous library functions ------------------------------------- */ + +void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + CType *d, *ct = lj_ctype_rawref(cts, cdataV(&rd->argv[0])->ctypeid); + if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); + if (ctype_isnum(ct->info) || ctype_iscomplex(ct->info)) { + if (ctype_isinteger_or_bool(ct->info) && ct->size <= 4 && + !(ct->size == 4 && (ct->info & CTF_UNSIGNED))) + d = ctype_get(cts, CTID_INT32); + else + d = ctype_get(cts, CTID_DOUBLE); + J->base[0] = crec_ct_tv(J, d, 0, J->base[0], &rd->argv[0]); + } else { + J->base[0] = TREF_NIL; + } +} + +#undef IR +#undef emitir +#undef emitconv + +#endif + +``` + +`include/luajit-2.0.5/src/lj_crecord.h`: + +```h +/* +** Trace recorder for C data operations. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CRECORD_H +#define _LJ_CRECORD_H + +#include "lj_obj.h" +#include "lj_jit.h" +#include "lj_ffrecord.h" + +#if LJ_HASJIT && LJ_HASFFI +LJ_FUNC void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_cdata_call(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_new(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_errno(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_copy(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_fill(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_typeof(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_istype(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_abi(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_xof(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_gc(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd); +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_ctype.c`: + +```c +/* +** C type management. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_ctype.h" +#include "lj_ccallback.h" + +/* -- C type definitions -------------------------------------------------- */ + +/* Predefined typedefs. */ +#define CTTDDEF(_) \ + /* Vararg handling. */ \ + _("va_list", P_VOID) \ + _("__builtin_va_list", P_VOID) \ + _("__gnuc_va_list", P_VOID) \ + /* From stddef.h. */ \ + _("ptrdiff_t", INT_PSZ) \ + _("size_t", UINT_PSZ) \ + _("wchar_t", WCHAR) \ + /* Subset of stdint.h. */ \ + _("int8_t", INT8) \ + _("int16_t", INT16) \ + _("int32_t", INT32) \ + _("int64_t", INT64) \ + _("uint8_t", UINT8) \ + _("uint16_t", UINT16) \ + _("uint32_t", UINT32) \ + _("uint64_t", UINT64) \ + _("intptr_t", INT_PSZ) \ + _("uintptr_t", UINT_PSZ) \ + /* End of typedef list. */ + +/* Keywords (only the ones we actually care for). */ +#define CTKWDEF(_) \ + /* Type specifiers. */ \ + _("void", -1, CTOK_VOID) \ + _("_Bool", 0, CTOK_BOOL) \ + _("bool", 1, CTOK_BOOL) \ + _("char", 1, CTOK_CHAR) \ + _("int", 4, CTOK_INT) \ + _("__int8", 1, CTOK_INT) \ + _("__int16", 2, CTOK_INT) \ + _("__int32", 4, CTOK_INT) \ + _("__int64", 8, CTOK_INT) \ + _("float", 4, CTOK_FP) \ + _("double", 8, CTOK_FP) \ + _("long", 0, CTOK_LONG) \ + _("short", 0, CTOK_SHORT) \ + _("_Complex", 0, CTOK_COMPLEX) \ + _("complex", 0, CTOK_COMPLEX) \ + _("__complex", 0, CTOK_COMPLEX) \ + _("__complex__", 0, CTOK_COMPLEX) \ + _("signed", 0, CTOK_SIGNED) \ + _("__signed", 0, CTOK_SIGNED) \ + _("__signed__", 0, CTOK_SIGNED) \ + _("unsigned", 0, CTOK_UNSIGNED) \ + /* Type qualifiers. */ \ + _("const", 0, CTOK_CONST) \ + _("__const", 0, CTOK_CONST) \ + _("__const__", 0, CTOK_CONST) \ + _("volatile", 0, CTOK_VOLATILE) \ + _("__volatile", 0, CTOK_VOLATILE) \ + _("__volatile__", 0, CTOK_VOLATILE) \ + _("restrict", 0, CTOK_RESTRICT) \ + _("__restrict", 0, CTOK_RESTRICT) \ + _("__restrict__", 0, CTOK_RESTRICT) \ + _("inline", 0, CTOK_INLINE) \ + _("__inline", 0, CTOK_INLINE) \ + _("__inline__", 0, CTOK_INLINE) \ + /* Storage class specifiers. */ \ + _("typedef", 0, CTOK_TYPEDEF) \ + _("extern", 0, CTOK_EXTERN) \ + _("static", 0, CTOK_STATIC) \ + _("auto", 0, CTOK_AUTO) \ + _("register", 0, CTOK_REGISTER) \ + /* GCC Attributes. */ \ + _("__extension__", 0, CTOK_EXTENSION) \ + _("__attribute", 0, CTOK_ATTRIBUTE) \ + _("__attribute__", 0, CTOK_ATTRIBUTE) \ + _("asm", 0, CTOK_ASM) \ + _("__asm", 0, CTOK_ASM) \ + _("__asm__", 0, CTOK_ASM) \ + /* MSVC Attributes. */ \ + _("__declspec", 0, CTOK_DECLSPEC) \ + _("__cdecl", CTCC_CDECL, CTOK_CCDECL) \ + _("__thiscall", CTCC_THISCALL, CTOK_CCDECL) \ + _("__fastcall", CTCC_FASTCALL, CTOK_CCDECL) \ + _("__stdcall", CTCC_STDCALL, CTOK_CCDECL) \ + _("__ptr32", 4, CTOK_PTRSZ) \ + _("__ptr64", 8, CTOK_PTRSZ) \ + /* Other type specifiers. */ \ + _("struct", 0, CTOK_STRUCT) \ + _("union", 0, CTOK_UNION) \ + _("enum", 0, CTOK_ENUM) \ + /* Operators. */ \ + _("sizeof", 0, CTOK_SIZEOF) \ + _("__alignof", 0, CTOK_ALIGNOF) \ + _("__alignof__", 0, CTOK_ALIGNOF) \ + /* End of keyword list. */ + +/* Type info for predefined types. Size merged in. */ +static CTInfo lj_ctype_typeinfo[] = { +#define CTTYINFODEF(id, sz, ct, info) CTINFO((ct),(((sz)&0x3fu)<<10)+(info)), +#define CTTDINFODEF(name, id) CTINFO(CT_TYPEDEF, CTID_##id), +#define CTKWINFODEF(name, sz, kw) CTINFO(CT_KW,(((sz)&0x3fu)<<10)+(kw)), +CTTYDEF(CTTYINFODEF) +CTTDDEF(CTTDINFODEF) +CTKWDEF(CTKWINFODEF) +#undef CTTYINFODEF +#undef CTTDINFODEF +#undef CTKWINFODEF + 0 +}; + +/* Predefined type names collected in a single string. */ +static const char * const lj_ctype_typenames = +#define CTTDNAMEDEF(name, id) name "\0" +#define CTKWNAMEDEF(name, sz, cds) name "\0" +CTTDDEF(CTTDNAMEDEF) +CTKWDEF(CTKWNAMEDEF) +#undef CTTDNAMEDEF +#undef CTKWNAMEDEF +; + +#define CTTYPEINFO_NUM (sizeof(lj_ctype_typeinfo)/sizeof(CTInfo)-1) +#ifdef LUAJIT_CTYPE_CHECK_ANCHOR +#define CTTYPETAB_MIN CTTYPEINFO_NUM +#else +#define CTTYPETAB_MIN 128 +#endif + +/* -- C type interning ---------------------------------------------------- */ + +#define ct_hashtype(info, size) (hashrot(info, size) & CTHASH_MASK) +#define ct_hashname(name) \ + (hashrot(u32ptr(name), u32ptr(name) + HASH_BIAS) & CTHASH_MASK) + +/* Create new type element. */ +CTypeID lj_ctype_new(CTState *cts, CType **ctp) +{ + CTypeID id = cts->top; + CType *ct; + lua_assert(cts->L); + if (LJ_UNLIKELY(id >= cts->sizetab)) { + if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV); +#ifdef LUAJIT_CTYPE_CHECK_ANCHOR + ct = lj_mem_newvec(cts->L, id+1, CType); + memcpy(ct, cts->tab, id*sizeof(CType)); + memset(cts->tab, 0, id*sizeof(CType)); + lj_mem_freevec(cts->g, cts->tab, cts->sizetab, CType); + cts->tab = ct; + cts->sizetab = id+1; +#else + lj_mem_growvec(cts->L, cts->tab, cts->sizetab, CTID_MAX, CType); +#endif + } + cts->top = id+1; + *ctp = ct = &cts->tab[id]; + ct->info = 0; + ct->size = 0; + ct->sib = 0; + ct->next = 0; + setgcrefnull(ct->name); + return id; +} + +/* Intern a type element. */ +CTypeID lj_ctype_intern(CTState *cts, CTInfo info, CTSize size) +{ + uint32_t h = ct_hashtype(info, size); + CTypeID id = cts->hash[h]; + lua_assert(cts->L); + while (id) { + CType *ct = ctype_get(cts, id); + if (ct->info == info && ct->size == size) + return id; + id = ct->next; + } + id = cts->top; + if (LJ_UNLIKELY(id >= cts->sizetab)) { + if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV); + lj_mem_growvec(cts->L, cts->tab, cts->sizetab, CTID_MAX, CType); + } + cts->top = id+1; + cts->tab[id].info = info; + cts->tab[id].size = size; + cts->tab[id].sib = 0; + cts->tab[id].next = cts->hash[h]; + setgcrefnull(cts->tab[id].name); + cts->hash[h] = (CTypeID1)id; + return id; +} + +/* Add type element to hash table. */ +static void ctype_addtype(CTState *cts, CType *ct, CTypeID id) +{ + uint32_t h = ct_hashtype(ct->info, ct->size); + ct->next = cts->hash[h]; + cts->hash[h] = (CTypeID1)id; +} + +/* Add named element to hash table. */ +void lj_ctype_addname(CTState *cts, CType *ct, CTypeID id) +{ + uint32_t h = ct_hashname(gcref(ct->name)); + ct->next = cts->hash[h]; + cts->hash[h] = (CTypeID1)id; +} + +/* Get a C type by name, matching the type mask. */ +CTypeID lj_ctype_getname(CTState *cts, CType **ctp, GCstr *name, uint32_t tmask) +{ + CTypeID id = cts->hash[ct_hashname(name)]; + while (id) { + CType *ct = ctype_get(cts, id); + if (gcref(ct->name) == obj2gco(name) && + ((tmask >> ctype_type(ct->info)) & 1)) { + *ctp = ct; + return id; + } + id = ct->next; + } + *ctp = &cts->tab[0]; /* Simplify caller logic. ctype_get() would assert. */ + return 0; +} + +/* Get a struct/union/enum/function field by name. */ +CType *lj_ctype_getfieldq(CTState *cts, CType *ct, GCstr *name, CTSize *ofs, + CTInfo *qual) +{ + while (ct->sib) { + ct = ctype_get(cts, ct->sib); + if (gcref(ct->name) == obj2gco(name)) { + *ofs = ct->size; + return ct; + } + if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) { + CType *fct, *cct = ctype_child(cts, ct); + CTInfo q = 0; + while (ctype_isattrib(cct->info)) { + if (ctype_attrib(cct->info) == CTA_QUAL) q |= cct->size; + cct = ctype_child(cts, cct); + } + fct = lj_ctype_getfieldq(cts, cct, name, ofs, qual); + if (fct) { + if (qual) *qual |= q; + *ofs += ct->size; + return fct; + } + } + } + return NULL; /* Not found. */ +} + +/* -- C type information -------------------------------------------------- */ + +/* Follow references and get raw type for a C type ID. */ +CType *lj_ctype_rawref(CTState *cts, CTypeID id) +{ + CType *ct = ctype_get(cts, id); + while (ctype_isattrib(ct->info) || ctype_isref(ct->info)) + ct = ctype_child(cts, ct); + return ct; +} + +/* Get size for a C type ID. Does NOT support VLA/VLS. */ +CTSize lj_ctype_size(CTState *cts, CTypeID id) +{ + CType *ct = ctype_raw(cts, id); + return ctype_hassize(ct->info) ? ct->size : CTSIZE_INVALID; +} + +/* Get size for a variable-length C type. Does NOT support other C types. */ +CTSize lj_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem) +{ + uint64_t xsz = 0; + if (ctype_isstruct(ct->info)) { + CTypeID arrid = 0, fid = ct->sib; + xsz = ct->size; /* Add the struct size. */ + while (fid) { + CType *ctf = ctype_get(cts, fid); + if (ctype_type(ctf->info) == CT_FIELD) + arrid = ctype_cid(ctf->info); /* Remember last field of VLS. */ + fid = ctf->sib; + } + ct = ctype_raw(cts, arrid); + } + lua_assert(ctype_isvlarray(ct->info)); /* Must be a VLA. */ + ct = ctype_rawchild(cts, ct); /* Get array element. */ + lua_assert(ctype_hassize(ct->info)); + /* Calculate actual size of VLA and check for overflow. */ + xsz += (uint64_t)ct->size * nelem; + return xsz < 0x80000000u ? (CTSize)xsz : CTSIZE_INVALID; +} + +/* Get type, qualifiers, size and alignment for a C type ID. */ +CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp) +{ + CTInfo qual = 0; + CType *ct = ctype_get(cts, id); + for (;;) { + CTInfo info = ct->info; + if (ctype_isenum(info)) { + /* Follow child. Need to look at its attributes, too. */ + } else if (ctype_isattrib(info)) { + if (ctype_isxattrib(info, CTA_QUAL)) + qual |= ct->size; + else if (ctype_isxattrib(info, CTA_ALIGN) && !(qual & CTFP_ALIGNED)) + qual |= CTFP_ALIGNED + CTALIGN(ct->size); + } else { + if (!(qual & CTFP_ALIGNED)) qual |= (info & CTF_ALIGN); + qual |= (info & ~(CTF_ALIGN|CTMASK_CID)); + lua_assert(ctype_hassize(info) || ctype_isfunc(info)); + *szp = ctype_isfunc(info) ? CTSIZE_INVALID : ct->size; + break; + } + ct = ctype_get(cts, ctype_cid(info)); + } + return qual; +} + +/* Get ctype metamethod. */ +cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm) +{ + CType *ct = ctype_get(cts, id); + cTValue *tv; + while (ctype_isattrib(ct->info) || ctype_isref(ct->info)) { + id = ctype_cid(ct->info); + ct = ctype_get(cts, id); + } + if (ctype_isptr(ct->info) && + ctype_isfunc(ctype_get(cts, ctype_cid(ct->info))->info)) + tv = lj_tab_getstr(cts->miscmap, &cts->g->strempty); + else + tv = lj_tab_getinth(cts->miscmap, -(int32_t)id); + if (tv && tvistab(tv) && + (tv = lj_tab_getstr(tabV(tv), mmname_str(cts->g, mm))) && !tvisnil(tv)) + return tv; + return NULL; +} + +/* -- C type representation ----------------------------------------------- */ + +/* Fixed max. length of a C type representation. */ +#define CTREPR_MAX 512 + +typedef struct CTRepr { + char *pb, *pe; + CTState *cts; + lua_State *L; + int needsp; + int ok; + char buf[CTREPR_MAX]; +} CTRepr; + +/* Prepend string. */ +static void ctype_prepstr(CTRepr *ctr, const char *str, MSize len) +{ + char *p = ctr->pb; + if (ctr->buf + len+1 > p) { ctr->ok = 0; return; } + if (ctr->needsp) *--p = ' '; + ctr->needsp = 1; + p -= len; + while (len-- > 0) p[len] = str[len]; + ctr->pb = p; +} + +#define ctype_preplit(ctr, str) ctype_prepstr((ctr), "" str, sizeof(str)-1) + +/* Prepend char. */ +static void ctype_prepc(CTRepr *ctr, int c) +{ + if (ctr->buf >= ctr->pb) { ctr->ok = 0; return; } + *--ctr->pb = c; +} + +/* Prepend number. */ +static void ctype_prepnum(CTRepr *ctr, uint32_t n) +{ + char *p = ctr->pb; + if (ctr->buf + 10+1 > p) { ctr->ok = 0; return; } + do { *--p = (char)('0' + n % 10); } while (n /= 10); + ctr->pb = p; + ctr->needsp = 0; +} + +/* Append char. */ +static void ctype_appc(CTRepr *ctr, int c) +{ + if (ctr->pe >= ctr->buf + CTREPR_MAX) { ctr->ok = 0; return; } + *ctr->pe++ = c; +} + +/* Append number. */ +static void ctype_appnum(CTRepr *ctr, uint32_t n) +{ + char buf[10]; + char *p = buf+sizeof(buf); + char *q = ctr->pe; + if (q > ctr->buf + CTREPR_MAX - 10) { ctr->ok = 0; return; } + do { *--p = (char)('0' + n % 10); } while (n /= 10); + do { *q++ = *p++; } while (p < buf+sizeof(buf)); + ctr->pe = q; +} + +/* Prepend qualifiers. */ +static void ctype_prepqual(CTRepr *ctr, CTInfo info) +{ + if ((info & CTF_VOLATILE)) ctype_preplit(ctr, "volatile"); + if ((info & CTF_CONST)) ctype_preplit(ctr, "const"); +} + +/* Prepend named type. */ +static void ctype_preptype(CTRepr *ctr, CType *ct, CTInfo qual, const char *t) +{ + if (gcref(ct->name)) { + GCstr *str = gco2str(gcref(ct->name)); + ctype_prepstr(ctr, strdata(str), str->len); + } else { + if (ctr->needsp) ctype_prepc(ctr, ' '); + ctype_prepnum(ctr, ctype_typeid(ctr->cts, ct)); + ctr->needsp = 1; + } + ctype_prepstr(ctr, t, (MSize)strlen(t)); + ctype_prepqual(ctr, qual); +} + +static void ctype_repr(CTRepr *ctr, CTypeID id) +{ + CType *ct = ctype_get(ctr->cts, id); + CTInfo qual = 0; + int ptrto = 0; + for (;;) { + CTInfo info = ct->info; + CTSize size = ct->size; + switch (ctype_type(info)) { + case CT_NUM: + if ((info & CTF_BOOL)) { + ctype_preplit(ctr, "bool"); + } else if ((info & CTF_FP)) { + if (size == sizeof(double)) ctype_preplit(ctr, "double"); + else if (size == sizeof(float)) ctype_preplit(ctr, "float"); + else ctype_preplit(ctr, "long double"); + } else if (size == 1) { + if (!((info ^ CTF_UCHAR) & CTF_UNSIGNED)) ctype_preplit(ctr, "char"); + else if (CTF_UCHAR) ctype_preplit(ctr, "signed char"); + else ctype_preplit(ctr, "unsigned char"); + } else if (size < 8) { + if (size == 4) ctype_preplit(ctr, "int"); + else ctype_preplit(ctr, "short"); + if ((info & CTF_UNSIGNED)) ctype_preplit(ctr, "unsigned"); + } else { + ctype_preplit(ctr, "_t"); + ctype_prepnum(ctr, size*8); + ctype_preplit(ctr, "int"); + if ((info & CTF_UNSIGNED)) ctype_prepc(ctr, 'u'); + } + ctype_prepqual(ctr, (qual|info)); + return; + case CT_VOID: + ctype_preplit(ctr, "void"); + ctype_prepqual(ctr, (qual|info)); + return; + case CT_STRUCT: + ctype_preptype(ctr, ct, qual, (info & CTF_UNION) ? "union" : "struct"); + return; + case CT_ENUM: + if (id == CTID_CTYPEID) { + ctype_preplit(ctr, "ctype"); + return; + } + ctype_preptype(ctr, ct, qual, "enum"); + return; + case CT_ATTRIB: + if (ctype_attrib(info) == CTA_QUAL) qual |= size; + break; + case CT_PTR: + if ((info & CTF_REF)) { + ctype_prepc(ctr, '&'); + } else { + ctype_prepqual(ctr, (qual|info)); + if (LJ_64 && size == 4) ctype_preplit(ctr, "__ptr32"); + ctype_prepc(ctr, '*'); + } + qual = 0; + ptrto = 1; + ctr->needsp = 1; + break; + case CT_ARRAY: + if (ctype_isrefarray(info)) { + ctr->needsp = 1; + if (ptrto) { ptrto = 0; ctype_prepc(ctr, '('); ctype_appc(ctr, ')'); } + ctype_appc(ctr, '['); + if (size != CTSIZE_INVALID) { + CTSize csize = ctype_child(ctr->cts, ct)->size; + ctype_appnum(ctr, csize ? size/csize : 0); + } else if ((info & CTF_VLA)) { + ctype_appc(ctr, '?'); + } + ctype_appc(ctr, ']'); + } else if ((info & CTF_COMPLEX)) { + if (size == 2*sizeof(float)) ctype_preplit(ctr, "float"); + ctype_preplit(ctr, "complex"); + return; + } else { + ctype_preplit(ctr, ")))"); + ctype_prepnum(ctr, size); + ctype_preplit(ctr, "__attribute__((vector_size("); + } + break; + case CT_FUNC: + ctr->needsp = 1; + if (ptrto) { ptrto = 0; ctype_prepc(ctr, '('); ctype_appc(ctr, ')'); } + ctype_appc(ctr, '('); + ctype_appc(ctr, ')'); + break; + default: + lua_assert(0); + break; + } + ct = ctype_get(ctr->cts, ctype_cid(info)); + } +} + +/* Return a printable representation of a C type. */ +GCstr *lj_ctype_repr(lua_State *L, CTypeID id, GCstr *name) +{ + global_State *g = G(L); + CTRepr ctr; + ctr.pb = ctr.pe = &ctr.buf[CTREPR_MAX/2]; + ctr.cts = ctype_ctsG(g); + ctr.L = L; + ctr.ok = 1; + ctr.needsp = 0; + if (name) ctype_prepstr(&ctr, strdata(name), name->len); + ctype_repr(&ctr, id); + if (LJ_UNLIKELY(!ctr.ok)) return lj_str_newlit(L, "?"); + return lj_str_new(L, ctr.pb, ctr.pe - ctr.pb); +} + +/* Convert int64_t/uint64_t to string with 'LL' or 'ULL' suffix. */ +GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned) +{ + char buf[1+20+3]; + char *p = buf+sizeof(buf); + int sign = 0; + *--p = 'L'; *--p = 'L'; + if (isunsigned) { + *--p = 'U'; + } else if ((int64_t)n < 0) { + n = (uint64_t)-(int64_t)n; + sign = 1; + } + do { *--p = (char)('0' + n % 10); } while (n /= 10); + if (sign) *--p = '-'; + return lj_str_new(L, p, (size_t)(buf+sizeof(buf)-p)); +} + +/* Convert complex to string with 'i' or 'I' suffix. */ +GCstr *lj_ctype_repr_complex(lua_State *L, void *sp, CTSize size) +{ + char buf[2*LJ_STR_NUMBUF+2+1]; + TValue re, im; + size_t len; + if (size == 2*sizeof(double)) { + re.n = *(double *)sp; im.n = ((double *)sp)[1]; + } else { + re.n = (double)*(float *)sp; im.n = (double)((float *)sp)[1]; + } + len = lj_str_bufnum(buf, &re); + if (!(im.u32.hi & 0x80000000u) || im.n != im.n) buf[len++] = '+'; + len += lj_str_bufnum(buf+len, &im); + buf[len] = buf[len-1] >= 'a' ? 'I' : 'i'; + return lj_str_new(L, buf, len+1); +} + +/* -- C type state -------------------------------------------------------- */ + +/* Initialize C type table and state. */ +CTState *lj_ctype_init(lua_State *L) +{ + CTState *cts = lj_mem_newt(L, sizeof(CTState), CTState); + CType *ct = lj_mem_newvec(L, CTTYPETAB_MIN, CType); + const char *name = lj_ctype_typenames; + CTypeID id; + memset(cts, 0, sizeof(CTState)); + cts->tab = ct; + cts->sizetab = CTTYPETAB_MIN; + cts->top = CTTYPEINFO_NUM; + cts->L = NULL; + cts->g = G(L); + for (id = 0; id < CTTYPEINFO_NUM; id++, ct++) { + CTInfo info = lj_ctype_typeinfo[id]; + ct->size = (CTSize)((int32_t)(info << 16) >> 26); + ct->info = info & 0xffff03ffu; + ct->sib = 0; + if (ctype_type(info) == CT_KW || ctype_istypedef(info)) { + size_t len = strlen(name); + GCstr *str = lj_str_new(L, name, len); + ctype_setname(ct, str); + name += len+1; + lj_ctype_addname(cts, ct, id); + } else { + setgcrefnull(ct->name); + ct->next = 0; + if (!ctype_isenum(info)) ctype_addtype(cts, ct, id); + } + } + setmref(G(L)->ctype_state, cts); + return cts; +} + +/* Free C type table and state. */ +void lj_ctype_freestate(global_State *g) +{ + CTState *cts = ctype_ctsG(g); + if (cts) { + lj_ccallback_mcode_free(cts); + lj_mem_freevec(g, cts->tab, cts->sizetab, CType); + lj_mem_freevec(g, cts->cb.cbid, cts->cb.sizeid, CTypeID1); + lj_mem_freet(g, cts); + } +} + +#endif + +``` + +`include/luajit-2.0.5/src/lj_ctype.h`: + +```h +/* +** C type management. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CTYPE_H +#define _LJ_CTYPE_H + +#include "lj_obj.h" +#include "lj_gc.h" + +#if LJ_HASFFI + +/* -- C type definitions -------------------------------------------------- */ + +/* C type numbers. Highest 4 bits of C type info. ORDER CT. */ +enum { + /* Externally visible types. */ + CT_NUM, /* Integer or floating-point numbers. */ + CT_STRUCT, /* Struct or union. */ + CT_PTR, /* Pointer or reference. */ + CT_ARRAY, /* Array or complex type. */ + CT_MAYCONVERT = CT_ARRAY, + CT_VOID, /* Void type. */ + CT_ENUM, /* Enumeration. */ + CT_HASSIZE = CT_ENUM, /* Last type where ct->size holds the actual size. */ + CT_FUNC, /* Function. */ + CT_TYPEDEF, /* Typedef. */ + CT_ATTRIB, /* Miscellaneous attributes. */ + /* Internal element types. */ + CT_FIELD, /* Struct/union field or function parameter. */ + CT_BITFIELD, /* Struct/union bitfield. */ + CT_CONSTVAL, /* Constant value. */ + CT_EXTERN, /* External reference. */ + CT_KW /* Keyword. */ +}; + +LJ_STATIC_ASSERT(((int)CT_PTR & (int)CT_ARRAY) == CT_PTR); +LJ_STATIC_ASSERT(((int)CT_STRUCT & (int)CT_ARRAY) == CT_STRUCT); + +/* +** ---------- info ------------ +** |type flags... A cid | size | sib | next | name | +** +----------------------------+--------+-------+-------+-------+-- +** |NUM BFcvUL.. A | size | | type | | +** |STRUCT ..cvU..V A | size | field | name? | name? | +** |PTR ..cvR... A cid | size | | type | | +** |ARRAY VCcv...V A cid | size | | type | | +** |VOID ..cv.... A | size | | type | | +** |ENUM A cid | size | const | name? | name? | +** |FUNC ....VS.. cc cid | nargs | field | name? | name? | +** |TYPEDEF cid | | | name | name | +** |ATTRIB attrnum cid | attr | sib? | type? | | +** |FIELD cid | offset | field | | name? | +** |BITFIELD B.cvU csz bsz pos | offset | field | | name? | +** |CONSTVAL c cid | value | const | name | name | +** |EXTERN cid | | sib? | name | name | +** |KW tok | size | | name | name | +** +----------------------------+--------+-------+-------+-------+-- +** ^^ ^^--- bits used for C type conversion dispatch +*/ + +/* C type info flags. TFFArrrr */ +#define CTF_BOOL 0x08000000u /* Boolean: NUM, BITFIELD. */ +#define CTF_FP 0x04000000u /* Floating-point: NUM. */ +#define CTF_CONST 0x02000000u /* Const qualifier. */ +#define CTF_VOLATILE 0x01000000u /* Volatile qualifier. */ +#define CTF_UNSIGNED 0x00800000u /* Unsigned: NUM, BITFIELD. */ +#define CTF_LONG 0x00400000u /* Long: NUM. */ +#define CTF_VLA 0x00100000u /* Variable-length: ARRAY, STRUCT. */ +#define CTF_REF 0x00800000u /* Reference: PTR. */ +#define CTF_VECTOR 0x08000000u /* Vector: ARRAY. */ +#define CTF_COMPLEX 0x04000000u /* Complex: ARRAY. */ +#define CTF_UNION 0x00800000u /* Union: STRUCT. */ +#define CTF_VARARG 0x00800000u /* Vararg: FUNC. */ +#define CTF_SSEREGPARM 0x00400000u /* SSE register parameters: FUNC. */ + +#define CTF_QUAL (CTF_CONST|CTF_VOLATILE) +#define CTF_ALIGN (CTMASK_ALIGN< 0 ? CTF_UNSIGNED : 0) + +/* Flags used in parser. .F.Ammvf cp->attr */ +#define CTFP_ALIGNED 0x00000001u /* cp->attr + ALIGN */ +#define CTFP_PACKED 0x00000002u /* cp->attr */ +/* ...C...f cp->fattr */ +#define CTFP_CCONV 0x00000001u /* cp->fattr + CCONV/[SSE]REGPARM */ + +/* C type info bitfields. */ +#define CTMASK_CID 0x0000ffffu /* Max. 65536 type IDs. */ +#define CTMASK_NUM 0xf0000000u /* Max. 16 type numbers. */ +#define CTSHIFT_NUM 28 +#define CTMASK_ALIGN 15 /* Max. alignment is 2^15. */ +#define CTSHIFT_ALIGN 16 +#define CTMASK_ATTRIB 255 /* Max. 256 attributes. */ +#define CTSHIFT_ATTRIB 16 +#define CTMASK_CCONV 3 /* Max. 4 calling conventions. */ +#define CTSHIFT_CCONV 16 +#define CTMASK_REGPARM 3 /* Max. 0-3 regparms. */ +#define CTSHIFT_REGPARM 18 +/* Bitfields only used in parser. */ +#define CTMASK_VSIZEP 15 /* Max. vector size is 2^15. */ +#define CTSHIFT_VSIZEP 4 +#define CTMASK_MSIZEP 255 /* Max. type size (via mode) is 128. */ +#define CTSHIFT_MSIZEP 8 + +/* Info bits for BITFIELD. Max. size of bitfield is 64 bits. */ +#define CTBSZ_MAX 32 /* Max. size of bitfield is 32 bit. */ +#define CTBSZ_FIELD 127 /* Temp. marker for regular field. */ +#define CTMASK_BITPOS 127 +#define CTMASK_BITBSZ 127 +#define CTMASK_BITCSZ 127 +#define CTSHIFT_BITPOS 0 +#define CTSHIFT_BITBSZ 8 +#define CTSHIFT_BITCSZ 16 + +#define CTF_INSERT(info, field, val) \ + info = (info & ~(CTMASK_##field<> CTSHIFT_NUM) +#define ctype_cid(info) ((CTypeID)((info) & CTMASK_CID)) +#define ctype_align(info) (((info) >> CTSHIFT_ALIGN) & CTMASK_ALIGN) +#define ctype_attrib(info) (((info) >> CTSHIFT_ATTRIB) & CTMASK_ATTRIB) +#define ctype_bitpos(info) (((info) >> CTSHIFT_BITPOS) & CTMASK_BITPOS) +#define ctype_bitbsz(info) (((info) >> CTSHIFT_BITBSZ) & CTMASK_BITBSZ) +#define ctype_bitcsz(info) (((info) >> CTSHIFT_BITCSZ) & CTMASK_BITCSZ) +#define ctype_vsizeP(info) (((info) >> CTSHIFT_VSIZEP) & CTMASK_VSIZEP) +#define ctype_msizeP(info) (((info) >> CTSHIFT_MSIZEP) & CTMASK_MSIZEP) +#define ctype_cconv(info) (((info) >> CTSHIFT_CCONV) & CTMASK_CCONV) + +/* Simple type checks. */ +#define ctype_isnum(info) (ctype_type((info)) == CT_NUM) +#define ctype_isvoid(info) (ctype_type((info)) == CT_VOID) +#define ctype_isptr(info) (ctype_type((info)) == CT_PTR) +#define ctype_isarray(info) (ctype_type((info)) == CT_ARRAY) +#define ctype_isstruct(info) (ctype_type((info)) == CT_STRUCT) +#define ctype_isfunc(info) (ctype_type((info)) == CT_FUNC) +#define ctype_isenum(info) (ctype_type((info)) == CT_ENUM) +#define ctype_istypedef(info) (ctype_type((info)) == CT_TYPEDEF) +#define ctype_isattrib(info) (ctype_type((info)) == CT_ATTRIB) +#define ctype_isfield(info) (ctype_type((info)) == CT_FIELD) +#define ctype_isbitfield(info) (ctype_type((info)) == CT_BITFIELD) +#define ctype_isconstval(info) (ctype_type((info)) == CT_CONSTVAL) +#define ctype_isextern(info) (ctype_type((info)) == CT_EXTERN) +#define ctype_hassize(info) (ctype_type((info)) <= CT_HASSIZE) + +/* Combined type and flag checks. */ +#define ctype_isinteger(info) \ + (((info) & (CTMASK_NUM|CTF_BOOL|CTF_FP)) == CTINFO(CT_NUM, 0)) +#define ctype_isinteger_or_bool(info) \ + (((info) & (CTMASK_NUM|CTF_FP)) == CTINFO(CT_NUM, 0)) +#define ctype_isbool(info) \ + (((info) & (CTMASK_NUM|CTF_BOOL)) == CTINFO(CT_NUM, CTF_BOOL)) +#define ctype_isfp(info) \ + (((info) & (CTMASK_NUM|CTF_FP)) == CTINFO(CT_NUM, CTF_FP)) + +#define ctype_ispointer(info) \ + ((ctype_type(info) >> 1) == (CT_PTR >> 1)) /* Pointer or array. */ +#define ctype_isref(info) \ + (((info) & (CTMASK_NUM|CTF_REF)) == CTINFO(CT_PTR, CTF_REF)) + +#define ctype_isrefarray(info) \ + (((info) & (CTMASK_NUM|CTF_VECTOR|CTF_COMPLEX)) == CTINFO(CT_ARRAY, 0)) +#define ctype_isvector(info) \ + (((info) & (CTMASK_NUM|CTF_VECTOR)) == CTINFO(CT_ARRAY, CTF_VECTOR)) +#define ctype_iscomplex(info) \ + (((info) & (CTMASK_NUM|CTF_COMPLEX)) == CTINFO(CT_ARRAY, CTF_COMPLEX)) + +#define ctype_isvltype(info) \ + (((info) & ((CTMASK_NUM|CTF_VLA) - (2u<") _(STRING, "") \ + _(INTEGER, "") _(EOF, "") \ + _(OROR, "||") _(ANDAND, "&&") _(EQ, "==") _(NE, "!=") \ + _(LE, "<=") _(GE, ">=") _(SHL, "<<") _(SHR, ">>") _(DEREF, "->") + +/* Simple declaration specifiers. */ +#define CDSDEF(_) \ + _(VOID) _(BOOL) _(CHAR) _(INT) _(FP) \ + _(LONG) _(LONGLONG) _(SHORT) _(COMPLEX) _(SIGNED) _(UNSIGNED) \ + _(CONST) _(VOLATILE) _(RESTRICT) _(INLINE) \ + _(TYPEDEF) _(EXTERN) _(STATIC) _(AUTO) _(REGISTER) + +/* C keywords. */ +#define CKWDEF(_) \ + CDSDEF(_) _(EXTENSION) _(ASM) _(ATTRIBUTE) \ + _(DECLSPEC) _(CCDECL) _(PTRSZ) \ + _(STRUCT) _(UNION) _(ENUM) \ + _(SIZEOF) _(ALIGNOF) + +/* C token numbers. */ +enum { + CTOK_OFS = 255, +#define CTOKNUM(name, sym) CTOK_##name, +#define CKWNUM(name) CTOK_##name, +CTOKDEF(CTOKNUM) +CKWDEF(CKWNUM) +#undef CTOKNUM +#undef CKWNUM + CTOK_FIRSTDECL = CTOK_VOID, + CTOK_FIRSTSCL = CTOK_TYPEDEF, + CTOK_LASTDECLFLAG = CTOK_REGISTER, + CTOK_LASTDECL = CTOK_ENUM +}; + +/* Declaration specifier flags. */ +enum { +#define CDSFLAG(name) CDF_##name = (1u << (CTOK_##name - CTOK_FIRSTDECL)), +CDSDEF(CDSFLAG) +#undef CDSFLAG + CDF__END +}; + +#define CDF_SCL (CDF_TYPEDEF|CDF_EXTERN|CDF_STATIC|CDF_AUTO|CDF_REGISTER) + +/* -- C type management --------------------------------------------------- */ + +#define ctype_ctsG(g) (mref((g)->ctype_state, CTState)) + +/* Get C type state. */ +static LJ_AINLINE CTState *ctype_cts(lua_State *L) +{ + CTState *cts = ctype_ctsG(G(L)); + cts->L = L; /* Save L for errors and allocations. */ + return cts; +} + +/* Save and restore state of C type table. */ +#define LJ_CTYPE_SAVE(cts) CTState savects_ = *(cts) +#define LJ_CTYPE_RESTORE(cts) \ + ((cts)->top = savects_.top, \ + memcpy((cts)->hash, savects_.hash, sizeof(savects_.hash))) + +/* Check C type ID for validity when assertions are enabled. */ +static LJ_AINLINE CTypeID ctype_check(CTState *cts, CTypeID id) +{ + lua_assert(id > 0 && id < cts->top); UNUSED(cts); + return id; +} + +/* Get C type for C type ID. */ +static LJ_AINLINE CType *ctype_get(CTState *cts, CTypeID id) +{ + return &cts->tab[ctype_check(cts, id)]; +} + +/* Get C type ID for a C type. */ +#define ctype_typeid(cts, ct) ((CTypeID)((ct) - (cts)->tab)) + +/* Get child C type. */ +static LJ_AINLINE CType *ctype_child(CTState *cts, CType *ct) +{ + lua_assert(!(ctype_isvoid(ct->info) || ctype_isstruct(ct->info) || + ctype_isbitfield(ct->info))); /* These don't have children. */ + return ctype_get(cts, ctype_cid(ct->info)); +} + +/* Get raw type for a C type ID. */ +static LJ_AINLINE CType *ctype_raw(CTState *cts, CTypeID id) +{ + CType *ct = ctype_get(cts, id); + while (ctype_isattrib(ct->info)) ct = ctype_child(cts, ct); + return ct; +} + +/* Get raw type of the child of a C type. */ +static LJ_AINLINE CType *ctype_rawchild(CTState *cts, CType *ct) +{ + do { ct = ctype_child(cts, ct); } while (ctype_isattrib(ct->info)); + return ct; +} + +/* Set the name of a C type table element. */ +static LJ_AINLINE void ctype_setname(CType *ct, GCstr *s) +{ + /* NOBARRIER: mark string as fixed -- the C type table is never collected. */ + fixstring(s); + setgcref(ct->name, obj2gco(s)); +} + +LJ_FUNC CTypeID lj_ctype_new(CTState *cts, CType **ctp); +LJ_FUNC CTypeID lj_ctype_intern(CTState *cts, CTInfo info, CTSize size); +LJ_FUNC void lj_ctype_addname(CTState *cts, CType *ct, CTypeID id); +LJ_FUNC CTypeID lj_ctype_getname(CTState *cts, CType **ctp, GCstr *name, + uint32_t tmask); +LJ_FUNC CType *lj_ctype_getfieldq(CTState *cts, CType *ct, GCstr *name, + CTSize *ofs, CTInfo *qual); +#define lj_ctype_getfield(cts, ct, name, ofs) \ + lj_ctype_getfieldq((cts), (ct), (name), (ofs), NULL) +LJ_FUNC CType *lj_ctype_rawref(CTState *cts, CTypeID id); +LJ_FUNC CTSize lj_ctype_size(CTState *cts, CTypeID id); +LJ_FUNC CTSize lj_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem); +LJ_FUNC CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp); +LJ_FUNC cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm); +LJ_FUNC GCstr *lj_ctype_repr(lua_State *L, CTypeID id, GCstr *name); +LJ_FUNC GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned); +LJ_FUNC GCstr *lj_ctype_repr_complex(lua_State *L, void *sp, CTSize size); +LJ_FUNC CTState *lj_ctype_init(lua_State *L); +LJ_FUNC void lj_ctype_freestate(global_State *g); + +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_debug.c`: + +```c +/* +** Debugging and introspection. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_debug_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_state.h" +#include "lj_frame.h" +#include "lj_bc.h" +#include "lj_vm.h" +#if LJ_HASJIT +#include "lj_jit.h" +#endif + +/* -- Frames -------------------------------------------------------------- */ + +/* Get frame corresponding to a level. */ +cTValue *lj_debug_frame(lua_State *L, int level, int *size) +{ + cTValue *frame, *nextframe, *bot = tvref(L->stack); + /* Traverse frames backwards. */ + for (nextframe = frame = L->base-1; frame > bot; ) { + if (frame_gc(frame) == obj2gco(L)) + level++; /* Skip dummy frames. See lj_meta_call(). */ + if (level-- == 0) { + *size = (int)(nextframe - frame); + return frame; /* Level found. */ + } + nextframe = frame; + if (frame_islua(frame)) { + frame = frame_prevl(frame); + } else { + if (frame_isvarg(frame)) + level++; /* Skip vararg pseudo-frame. */ + frame = frame_prevd(frame); + } + } + *size = level; + return NULL; /* Level not found. */ +} + +/* Invalid bytecode position. */ +#define NO_BCPOS (~(BCPos)0) + +/* Return bytecode position for function/frame or NO_BCPOS. */ +static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe) +{ + const BCIns *ins; + GCproto *pt; + BCPos pos; + lua_assert(fn->c.gct == ~LJ_TFUNC || fn->c.gct == ~LJ_TTHREAD); + if (!isluafunc(fn)) { /* Cannot derive a PC for non-Lua functions. */ + return NO_BCPOS; + } else if (nextframe == NULL) { /* Lua function on top. */ + void *cf = cframe_raw(L->cframe); + if (cf == NULL || (char *)cframe_pc(cf) == (char *)cframe_L(cf)) + return NO_BCPOS; + ins = cframe_pc(cf); /* Only happens during error/hook handling. */ + } else { + if (frame_islua(nextframe)) { + ins = frame_pc(nextframe); + } else if (frame_iscont(nextframe)) { + ins = frame_contpc(nextframe); + } else { + /* Lua function below errfunc/gc/hook: find cframe to get the PC. */ + void *cf = cframe_raw(L->cframe); + TValue *f = L->base-1; + for (;;) { + if (cf == NULL) + return NO_BCPOS; + while (cframe_nres(cf) < 0) { + if (f >= restorestack(L, -cframe_nres(cf))) + break; + cf = cframe_raw(cframe_prev(cf)); + if (cf == NULL) + return NO_BCPOS; + } + if (f < nextframe) + break; + if (frame_islua(f)) { + f = frame_prevl(f); + } else { + if (frame_isc(f) || (LJ_HASFFI && frame_iscont(f) && + (f-1)->u32.lo == LJ_CONT_FFI_CALLBACK)) + cf = cframe_raw(cframe_prev(cf)); + f = frame_prevd(f); + } + } + ins = cframe_pc(cf); + } + } + pt = funcproto(fn); + pos = proto_bcpos(pt, ins) - 1; +#if LJ_HASJIT + if (pos > pt->sizebc) { /* Undo the effects of lj_trace_exit for JLOOP. */ + GCtrace *T = (GCtrace *)((char *)(ins-1) - offsetof(GCtrace, startins)); + lua_assert(bc_isret(bc_op(ins[-1]))); + pos = proto_bcpos(pt, mref(T->startpc, const BCIns)); + } +#endif + return pos; +} + +/* -- Line numbers -------------------------------------------------------- */ + +/* Get line number for a bytecode position. */ +BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc) +{ + const void *lineinfo = proto_lineinfo(pt); + if (pc <= pt->sizebc && lineinfo) { + BCLine first = pt->firstline; + if (pc == pt->sizebc) return first + pt->numline; + if (pc-- == 0) return first; + if (pt->numline < 256) + return first + (BCLine)((const uint8_t *)lineinfo)[pc]; + else if (pt->numline < 65536) + return first + (BCLine)((const uint16_t *)lineinfo)[pc]; + else + return first + (BCLine)((const uint32_t *)lineinfo)[pc]; + } + return 0; +} + +/* Get line number for function/frame. */ +static BCLine debug_frameline(lua_State *L, GCfunc *fn, cTValue *nextframe) +{ + BCPos pc = debug_framepc(L, fn, nextframe); + if (pc != NO_BCPOS) { + GCproto *pt = funcproto(fn); + lua_assert(pc <= pt->sizebc); + return lj_debug_line(pt, pc); + } + return -1; +} + +/* -- Variable names ------------------------------------------------------ */ + +/* Read ULEB128 value. */ +static uint32_t debug_read_uleb128(const uint8_t **pp) +{ + const uint8_t *p = *pp; + uint32_t v = *p++; + if (LJ_UNLIKELY(v >= 0x80)) { + int sh = 0; + v &= 0x7f; + do { v |= ((*p & 0x7f) << (sh += 7)); } while (*p++ >= 0x80); + } + *pp = p; + return v; +} + +/* Get name of a local variable from slot number and PC. */ +static const char *debug_varname(const GCproto *pt, BCPos pc, BCReg slot) +{ + const uint8_t *p = proto_varinfo(pt); + if (p) { + BCPos lastpc = 0; + for (;;) { + const char *name = (const char *)p; + uint32_t vn = *p++; + BCPos startpc, endpc; + if (vn < VARNAME__MAX) { + if (vn == VARNAME_END) break; /* End of varinfo. */ + } else { + while (*p++) ; /* Skip over variable name string. */ + } + lastpc = startpc = lastpc + debug_read_uleb128(&p); + if (startpc > pc) break; + endpc = startpc + debug_read_uleb128(&p); + if (pc < endpc && slot-- == 0) { + if (vn < VARNAME__MAX) { +#define VARNAMESTR(name, str) str "\0" + name = VARNAMEDEF(VARNAMESTR); +#undef VARNAMESTR + if (--vn) while (*name++ || --vn) ; + } + return name; + } + } + } + return NULL; +} + +/* Get name of local variable from 1-based slot number and function/frame. */ +static TValue *debug_localname(lua_State *L, const lua_Debug *ar, + const char **name, BCReg slot1) +{ + uint32_t offset = (uint32_t)ar->i_ci & 0xffff; + uint32_t size = (uint32_t)ar->i_ci >> 16; + TValue *frame = tvref(L->stack) + offset; + TValue *nextframe = size ? frame + size : NULL; + GCfunc *fn = frame_func(frame); + BCPos pc = debug_framepc(L, fn, nextframe); + if (!nextframe) nextframe = L->top; + if ((int)slot1 < 0) { /* Negative slot number is for varargs. */ + if (pc != NO_BCPOS) { + GCproto *pt = funcproto(fn); + if ((pt->flags & PROTO_VARARG)) { + slot1 = pt->numparams + (BCReg)(-(int)slot1); + if (frame_isvarg(frame)) { /* Vararg frame has been set up? (pc!=0) */ + nextframe = frame; + frame = frame_prevd(frame); + } + if (frame + slot1 < nextframe) { + *name = "(*vararg)"; + return frame+slot1; + } + } + } + return NULL; + } + if (pc != NO_BCPOS && + (*name = debug_varname(funcproto(fn), pc, slot1-1)) != NULL) + ; + else if (slot1 > 0 && frame + slot1 < nextframe) + *name = "(*temporary)"; + return frame+slot1; +} + +/* Get name of upvalue. */ +const char *lj_debug_uvname(GCproto *pt, uint32_t idx) +{ + const uint8_t *p = proto_uvinfo(pt); + lua_assert(idx < pt->sizeuv); + if (!p) return ""; + if (idx) while (*p++ || --idx) ; + return (const char *)p; +} + +/* Get name and value of upvalue. */ +const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp) +{ + if (tvisfunc(o)) { + GCfunc *fn = funcV(o); + if (isluafunc(fn)) { + GCproto *pt = funcproto(fn); + if (idx < pt->sizeuv) { + *tvp = uvval(&gcref(fn->l.uvptr[idx])->uv); + return lj_debug_uvname(pt, idx); + } + } else { + if (idx < fn->c.nupvalues) { + *tvp = &fn->c.upvalue[idx]; + return ""; + } + } + } + return NULL; +} + +/* Deduce name of an object from slot number and PC. */ +const char *lj_debug_slotname(GCproto *pt, const BCIns *ip, BCReg slot, + const char **name) +{ + const char *lname; +restart: + lname = debug_varname(pt, proto_bcpos(pt, ip), slot); + if (lname != NULL) { *name = lname; return "local"; } + while (--ip > proto_bc(pt)) { + BCIns ins = *ip; + BCOp op = bc_op(ins); + BCReg ra = bc_a(ins); + if (bcmode_a(op) == BCMbase) { + if (slot >= ra && (op != BC_KNIL || slot <= bc_d(ins))) + return NULL; + } else if (bcmode_a(op) == BCMdst && ra == slot) { + switch (bc_op(ins)) { + case BC_MOV: + if (ra == slot) { slot = bc_d(ins); goto restart; } + break; + case BC_GGET: + *name = strdata(gco2str(proto_kgc(pt, ~(ptrdiff_t)bc_d(ins)))); + return "global"; + case BC_TGETS: + *name = strdata(gco2str(proto_kgc(pt, ~(ptrdiff_t)bc_c(ins)))); + if (ip > proto_bc(pt)) { + BCIns insp = ip[-1]; + if (bc_op(insp) == BC_MOV && bc_a(insp) == ra+1 && + bc_d(insp) == bc_b(ins)) + return "method"; + } + return "field"; + case BC_UGET: + *name = lj_debug_uvname(pt, bc_d(ins)); + return "upvalue"; + default: + return NULL; + } + } + } + return NULL; +} + +/* Deduce function name from caller of a frame. */ +const char *lj_debug_funcname(lua_State *L, TValue *frame, const char **name) +{ + TValue *pframe; + GCfunc *fn; + BCPos pc; + if (frame <= tvref(L->stack)) + return NULL; + if (frame_isvarg(frame)) + frame = frame_prevd(frame); + pframe = frame_prev(frame); + fn = frame_func(pframe); + pc = debug_framepc(L, fn, frame); + if (pc != NO_BCPOS) { + GCproto *pt = funcproto(fn); + const BCIns *ip = &proto_bc(pt)[check_exp(pc < pt->sizebc, pc)]; + MMS mm = bcmode_mm(bc_op(*ip)); + if (mm == MM_call) { + BCReg slot = bc_a(*ip); + if (bc_op(*ip) == BC_ITERC) slot -= 3; + return lj_debug_slotname(pt, ip, slot, name); + } else if (mm != MM__MAX) { + *name = strdata(mmname_str(G(L), mm)); + return "metamethod"; + } + } + return NULL; +} + +/* -- Source code locations ----------------------------------------------- */ + +/* Generate shortened source name. */ +void lj_debug_shortname(char *out, GCstr *str) +{ + const char *src = strdata(str); + if (*src == '=') { + strncpy(out, src+1, LUA_IDSIZE); /* Remove first char. */ + out[LUA_IDSIZE-1] = '\0'; /* Ensures null termination. */ + } else if (*src == '@') { /* Output "source", or "...source". */ + size_t len = str->len-1; + src++; /* Skip the `@' */ + if (len >= LUA_IDSIZE) { + src += len-(LUA_IDSIZE-4); /* Get last part of file name. */ + *out++ = '.'; *out++ = '.'; *out++ = '.'; + } + strcpy(out, src); + } else { /* Output [string "string"]. */ + size_t len; /* Length, up to first control char. */ + for (len = 0; len < LUA_IDSIZE-12; len++) + if (((const unsigned char *)src)[len] < ' ') break; + strcpy(out, "[string \""); out += 9; + if (src[len] != '\0') { /* Must truncate? */ + if (len > LUA_IDSIZE-15) len = LUA_IDSIZE-15; + strncpy(out, src, len); out += len; + strcpy(out, "..."); out += 3; + } else { + strcpy(out, src); out += len; + } + strcpy(out, "\"]"); + } +} + +/* Add current location of a frame to error message. */ +void lj_debug_addloc(lua_State *L, const char *msg, + cTValue *frame, cTValue *nextframe) +{ + if (frame) { + GCfunc *fn = frame_func(frame); + if (isluafunc(fn)) { + BCLine line = debug_frameline(L, fn, nextframe); + if (line >= 0) { + char buf[LUA_IDSIZE]; + lj_debug_shortname(buf, proto_chunkname(funcproto(fn))); + lj_str_pushf(L, "%s:%d: %s", buf, line, msg); + return; + } + } + } + lj_str_pushf(L, "%s", msg); +} + +/* Push location string for a bytecode position to Lua stack. */ +void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc) +{ + GCstr *name = proto_chunkname(pt); + const char *s = strdata(name); + MSize i, len = name->len; + BCLine line = lj_debug_line(pt, pc); + if (*s == '@') { + s++; len--; + for (i = len; i > 0; i--) + if (s[i] == '/' || s[i] == '\\') { + s += i+1; + break; + } + lj_str_pushf(L, "%s:%d", s, line); + } else if (len > 40) { + lj_str_pushf(L, "%p:%d", pt, line); + } else if (*s == '=') { + lj_str_pushf(L, "%s:%d", s+1, line); + } else { + lj_str_pushf(L, "\"%s\":%d", s, line); + } +} + +/* -- Public debug API ---------------------------------------------------- */ + +/* lua_getupvalue() and lua_setupvalue() are in lj_api.c. */ + +LUA_API const char *lua_getlocal(lua_State *L, const lua_Debug *ar, int n) +{ + const char *name = NULL; + if (ar) { + TValue *o = debug_localname(L, ar, &name, (BCReg)n); + if (name) { + copyTV(L, L->top, o); + incr_top(L); + } + } else if (tvisfunc(L->top-1) && isluafunc(funcV(L->top-1))) { + name = debug_varname(funcproto(funcV(L->top-1)), 0, (BCReg)n-1); + } + return name; +} + +LUA_API const char *lua_setlocal(lua_State *L, const lua_Debug *ar, int n) +{ + const char *name = NULL; + TValue *o = debug_localname(L, ar, &name, (BCReg)n); + if (name) + copyTV(L, o, L->top-1); + L->top--; + return name; +} + +int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, int ext) +{ + int opt_f = 0, opt_L = 0; + TValue *frame = NULL; + TValue *nextframe = NULL; + GCfunc *fn; + if (*what == '>') { + TValue *func = L->top - 1; + api_check(L, tvisfunc(func)); + fn = funcV(func); + L->top--; + what++; + } else { + uint32_t offset = (uint32_t)ar->i_ci & 0xffff; + uint32_t size = (uint32_t)ar->i_ci >> 16; + lua_assert(offset != 0); + frame = tvref(L->stack) + offset; + if (size) nextframe = frame + size; + lua_assert(frame <= tvref(L->maxstack) && + (!nextframe || nextframe <= tvref(L->maxstack))); + fn = frame_func(frame); + lua_assert(fn->c.gct == ~LJ_TFUNC); + } + for (; *what; what++) { + if (*what == 'S') { + if (isluafunc(fn)) { + GCproto *pt = funcproto(fn); + BCLine firstline = pt->firstline; + GCstr *name = proto_chunkname(pt); + ar->source = strdata(name); + lj_debug_shortname(ar->short_src, name); + ar->linedefined = (int)firstline; + ar->lastlinedefined = (int)(firstline + pt->numline); + ar->what = (firstline || !pt->numline) ? "Lua" : "main"; + } else { + ar->source = "=[C]"; + ar->short_src[0] = '['; + ar->short_src[1] = 'C'; + ar->short_src[2] = ']'; + ar->short_src[3] = '\0'; + ar->linedefined = -1; + ar->lastlinedefined = -1; + ar->what = "C"; + } + } else if (*what == 'l') { + ar->currentline = frame ? debug_frameline(L, fn, nextframe) : -1; + } else if (*what == 'u') { + ar->nups = fn->c.nupvalues; + if (ext) { + if (isluafunc(fn)) { + GCproto *pt = funcproto(fn); + ar->nparams = pt->numparams; + ar->isvararg = !!(pt->flags & PROTO_VARARG); + } else { + ar->nparams = 0; + ar->isvararg = 1; + } + } + } else if (*what == 'n') { + ar->namewhat = frame ? lj_debug_funcname(L, frame, &ar->name) : NULL; + if (ar->namewhat == NULL) { + ar->namewhat = ""; + ar->name = NULL; + } + } else if (*what == 'f') { + opt_f = 1; + } else if (*what == 'L') { + opt_L = 1; + } else { + return 0; /* Bad option. */ + } + } + if (opt_f) { + setfuncV(L, L->top, fn); + incr_top(L); + } + if (opt_L) { + if (isluafunc(fn)) { + GCtab *t = lj_tab_new(L, 0, 0); + GCproto *pt = funcproto(fn); + const void *lineinfo = proto_lineinfo(pt); + if (lineinfo) { + BCLine first = pt->firstline; + int sz = pt->numline < 256 ? 1 : pt->numline < 65536 ? 2 : 4; + MSize i, szl = pt->sizebc-1; + for (i = 0; i < szl; i++) { + BCLine line = first + + (sz == 1 ? (BCLine)((const uint8_t *)lineinfo)[i] : + sz == 2 ? (BCLine)((const uint16_t *)lineinfo)[i] : + (BCLine)((const uint32_t *)lineinfo)[i]); + setboolV(lj_tab_setint(L, t, line), 1); + } + } + settabV(L, L->top, t); + } else { + setnilV(L->top); + } + incr_top(L); + } + return 1; /* Ok. */ +} + +LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar) +{ + return lj_debug_getinfo(L, what, (lj_Debug *)ar, 0); +} + +LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar) +{ + int size; + cTValue *frame = lj_debug_frame(L, level, &size); + if (frame) { + ar->i_ci = (size << 16) + (int)(frame - tvref(L->stack)); + return 1; + } else { + ar->i_ci = level - size; + return 0; + } +} + +/* Number of frames for the leading and trailing part of a traceback. */ +#define TRACEBACK_LEVELS1 12 +#define TRACEBACK_LEVELS2 10 + +LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, const char *msg, + int level) +{ + int top = (int)(L->top - L->base); + int lim = TRACEBACK_LEVELS1; + lua_Debug ar; + if (msg) lua_pushfstring(L, "%s\n", msg); + lua_pushliteral(L, "stack traceback:"); + while (lua_getstack(L1, level++, &ar)) { + GCfunc *fn; + if (level > lim) { + if (!lua_getstack(L1, level + TRACEBACK_LEVELS2, &ar)) { + level--; + } else { + lua_pushliteral(L, "\n\t..."); + lua_getstack(L1, -10, &ar); + level = ar.i_ci - TRACEBACK_LEVELS2; + } + lim = 2147483647; + continue; + } + lua_getinfo(L1, "Snlf", &ar); + fn = funcV(L1->top-1); L1->top--; + if (isffunc(fn) && !*ar.namewhat) + lua_pushfstring(L, "\n\t[builtin#%d]:", fn->c.ffid); + else + lua_pushfstring(L, "\n\t%s:", ar.short_src); + if (ar.currentline > 0) + lua_pushfstring(L, "%d:", ar.currentline); + if (*ar.namewhat) { + lua_pushfstring(L, " in function " LUA_QS, ar.name); + } else { + if (*ar.what == 'm') { + lua_pushliteral(L, " in main chunk"); + } else if (*ar.what == 'C') { + lua_pushfstring(L, " at %p", fn->c.f); + } else { + lua_pushfstring(L, " in function <%s:%d>", + ar.short_src, ar.linedefined); + } + } + if ((int)(L->top - L->base) - top >= 15) + lua_concat(L, (int)(L->top - L->base) - top); + } + lua_concat(L, (int)(L->top - L->base) - top); +} + + +``` + +`include/luajit-2.0.5/src/lj_debug.h`: + +```h +/* +** Debugging and introspection. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_DEBUG_H +#define _LJ_DEBUG_H + +#include "lj_obj.h" + +typedef struct lj_Debug { + /* Common fields. Must be in the same order as in lua.h. */ + int event; + const char *name; + const char *namewhat; + const char *what; + const char *source; + int currentline; + int nups; + int linedefined; + int lastlinedefined; + char short_src[LUA_IDSIZE]; + int i_ci; + /* Extended fields. Only valid if lj_debug_getinfo() is called with ext = 1.*/ + int nparams; + int isvararg; +} lj_Debug; + +LJ_FUNC cTValue *lj_debug_frame(lua_State *L, int level, int *size); +LJ_FUNC BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc); +LJ_FUNC const char *lj_debug_uvname(GCproto *pt, uint32_t idx); +LJ_FUNC const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp); +LJ_FUNC const char *lj_debug_slotname(GCproto *pt, const BCIns *pc, + BCReg slot, const char **name); +LJ_FUNC const char *lj_debug_funcname(lua_State *L, TValue *frame, + const char **name); +LJ_FUNC void lj_debug_shortname(char *out, GCstr *str); +LJ_FUNC void lj_debug_addloc(lua_State *L, const char *msg, + cTValue *frame, cTValue *nextframe); +LJ_FUNC void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc); +LJ_FUNC int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, + int ext); + +/* Fixed internal variable names. */ +#define VARNAMEDEF(_) \ + _(FOR_IDX, "(for index)") \ + _(FOR_STOP, "(for limit)") \ + _(FOR_STEP, "(for step)") \ + _(FOR_GEN, "(for generator)") \ + _(FOR_STATE, "(for state)") \ + _(FOR_CTL, "(for control)") + +enum { + VARNAME_END, +#define VARNAMEENUM(name, str) VARNAME_##name, + VARNAMEDEF(VARNAMEENUM) +#undef VARNAMEENUM + VARNAME__MAX +}; + +#endif + +``` + +`include/luajit-2.0.5/src/lj_def.h`: + +```h +/* +** LuaJIT common internal definitions. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_DEF_H +#define _LJ_DEF_H + +#include "lua.h" + +#if defined(_MSC_VER) +/* MSVC is stuck in the last century and doesn't have C99's stdint.h. */ +typedef __int8 int8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +#ifdef _WIN64 +typedef __int64 intptr_t; +typedef unsigned __int64 uintptr_t; +#else +typedef __int32 intptr_t; +typedef unsigned __int32 uintptr_t; +#endif +#elif defined(__symbian__) +/* Cough. */ +typedef signed char int8_t; +typedef short int int16_t; +typedef int int32_t; +typedef long long int64_t; +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; +typedef int intptr_t; +typedef unsigned int uintptr_t; +#else +#include +#endif + +/* Needed everywhere. */ +#include +#include + +/* Various VM limits. */ +#define LJ_MAX_MEM 0x7fffff00 /* Max. total memory allocation. */ +#define LJ_MAX_ALLOC LJ_MAX_MEM /* Max. individual allocation length. */ +#define LJ_MAX_STR LJ_MAX_MEM /* Max. string length. */ +#define LJ_MAX_UDATA LJ_MAX_MEM /* Max. userdata length. */ + +#define LJ_MAX_STRTAB (1<<26) /* Max. string table size. */ +#define LJ_MAX_HBITS 26 /* Max. hash bits. */ +#define LJ_MAX_ABITS 28 /* Max. bits of array key. */ +#define LJ_MAX_ASIZE ((1<<(LJ_MAX_ABITS-1))+1) /* Max. array part size. */ +#define LJ_MAX_COLOSIZE 16 /* Max. elems for colocated array. */ + +#define LJ_MAX_LINE LJ_MAX_MEM /* Max. source code line number. */ +#define LJ_MAX_XLEVEL 200 /* Max. syntactic nesting level. */ +#define LJ_MAX_BCINS (1<<26) /* Max. # of bytecode instructions. */ +#define LJ_MAX_SLOTS 250 /* Max. # of slots in a Lua func. */ +#define LJ_MAX_LOCVAR 200 /* Max. # of local variables. */ +#define LJ_MAX_UPVAL 60 /* Max. # of upvalues. */ + +#define LJ_MAX_IDXCHAIN 100 /* __index/__newindex chain limit. */ +#define LJ_STACK_EXTRA 5 /* Extra stack space (metamethods). */ + +#define LJ_NUM_CBPAGE 1 /* Number of FFI callback pages. */ + +/* Minimum table/buffer sizes. */ +#define LJ_MIN_GLOBAL 6 /* Min. global table size (hbits). */ +#define LJ_MIN_REGISTRY 2 /* Min. registry size (hbits). */ +#define LJ_MIN_STRTAB 256 /* Min. string table size (pow2). */ +#define LJ_MIN_SBUF 32 /* Min. string buffer length. */ +#define LJ_MIN_VECSZ 8 /* Min. size for growable vectors. */ +#define LJ_MIN_IRSZ 32 /* Min. size for growable IR. */ +#define LJ_MIN_K64SZ 16 /* Min. size for chained K64Array. */ + +/* JIT compiler limits. */ +#define LJ_MAX_JSLOTS 250 /* Max. # of stack slots for a trace. */ +#define LJ_MAX_PHI 64 /* Max. # of PHIs for a loop. */ +#define LJ_MAX_EXITSTUBGR 16 /* Max. # of exit stub groups. */ + +/* Various macros. */ +#ifndef UNUSED +#define UNUSED(x) ((void)(x)) /* to avoid warnings */ +#endif + +#define U64x(hi, lo) (((uint64_t)0x##hi << 32) + (uint64_t)0x##lo) +#define i32ptr(p) ((int32_t)(intptr_t)(void *)(p)) +#define u32ptr(p) ((uint32_t)(intptr_t)(void *)(p)) + +#define checki8(x) ((x) == (int32_t)(int8_t)(x)) +#define checku8(x) ((x) == (int32_t)(uint8_t)(x)) +#define checki16(x) ((x) == (int32_t)(int16_t)(x)) +#define checku16(x) ((x) == (int32_t)(uint16_t)(x)) +#define checki32(x) ((x) == (int32_t)(x)) +#define checku32(x) ((x) == (uint32_t)(x)) +#define checkptr32(x) ((uintptr_t)(x) == (uint32_t)(uintptr_t)(x)) + +/* Every half-decent C compiler transforms this into a rotate instruction. */ +#define lj_rol(x, n) (((x)<<(n)) | ((x)>>(-(int)(n)&(8*sizeof(x)-1)))) +#define lj_ror(x, n) (((x)<<(-(int)(n)&(8*sizeof(x)-1))) | ((x)>>(n))) + +/* A really naive Bloom filter. But sufficient for our needs. */ +typedef uintptr_t BloomFilter; +#define BLOOM_MASK (8*sizeof(BloomFilter) - 1) +#define bloombit(x) ((uintptr_t)1 << ((x) & BLOOM_MASK)) +#define bloomset(b, x) ((b) |= bloombit((x))) +#define bloomtest(b, x) ((b) & bloombit((x))) + +#if defined(__GNUC__) || defined(__psp2__) + +#define LJ_NORET __attribute__((noreturn)) +#define LJ_ALIGN(n) __attribute__((aligned(n))) +#define LJ_INLINE inline +#define LJ_AINLINE inline __attribute__((always_inline)) +#define LJ_NOINLINE __attribute__((noinline)) + +#if defined(__ELF__) || defined(__MACH__) || defined(__psp2__) +#if !((defined(__sun__) && defined(__svr4__)) || defined(__CELLOS_LV2__)) +#define LJ_NOAPI extern __attribute__((visibility("hidden"))) +#endif +#endif + +/* Note: it's only beneficial to use fastcall on x86 and then only for up to +** two non-FP args. The amalgamated compile covers all LJ_FUNC cases. Only +** indirect calls and related tail-called C functions are marked as fastcall. +*/ +#if defined(__i386__) +#define LJ_FASTCALL __attribute__((fastcall)) +#endif + +#define LJ_LIKELY(x) __builtin_expect(!!(x), 1) +#define LJ_UNLIKELY(x) __builtin_expect(!!(x), 0) + +#define lj_ffs(x) ((uint32_t)__builtin_ctz(x)) +/* Don't ask ... */ +#if defined(__INTEL_COMPILER) && (defined(__i386__) || defined(__x86_64__)) +static LJ_AINLINE uint32_t lj_fls(uint32_t x) +{ + uint32_t r; __asm__("bsrl %1, %0" : "=r" (r) : "rm" (x) : "cc"); return r; +} +#else +#define lj_fls(x) ((uint32_t)(__builtin_clz(x)^31)) +#endif + +#if defined(__arm__) +static LJ_AINLINE uint32_t lj_bswap(uint32_t x) +{ +#if defined(__psp2__) + return __builtin_rev(x); +#else + uint32_t r; +#if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\ + __ARM_ARCH_6ZK__ || __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ + __asm__("rev %0, %1" : "=r" (r) : "r" (x)); + return r; +#else +#ifdef __thumb__ + r = x ^ lj_ror(x, 16); +#else + __asm__("eor %0, %1, %1, ror #16" : "=r" (r) : "r" (x)); +#endif + return ((r & 0xff00ffffu) >> 8) ^ lj_ror(x, 8); +#endif +#endif +} + +static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) +{ + return ((uint64_t)lj_bswap((uint32_t)x)<<32) | lj_bswap((uint32_t)(x>>32)); +} +#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +static LJ_AINLINE uint32_t lj_bswap(uint32_t x) +{ + return (uint32_t)__builtin_bswap32((int32_t)x); +} + +static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) +{ + return (uint64_t)__builtin_bswap64((int64_t)x); +} +#elif defined(__i386__) || defined(__x86_64__) +static LJ_AINLINE uint32_t lj_bswap(uint32_t x) +{ + uint32_t r; __asm__("bswap %0" : "=r" (r) : "0" (x)); return r; +} + +#if defined(__i386__) +static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) +{ + return ((uint64_t)lj_bswap((uint32_t)x)<<32) | lj_bswap((uint32_t)(x>>32)); +} +#else +static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) +{ + uint64_t r; __asm__("bswap %0" : "=r" (r) : "0" (x)); return r; +} +#endif +#else +static LJ_AINLINE uint32_t lj_bswap(uint32_t x) +{ + return (x << 24) | ((x & 0xff00) << 8) | ((x >> 8) & 0xff00) | (x >> 24); +} + +static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) +{ + return (uint64_t)lj_bswap((uint32_t)(x >> 32)) | + ((uint64_t)lj_bswap((uint32_t)x) << 32); +} +#endif + +typedef union __attribute__((packed)) Unaligned16 { + uint16_t u; + uint8_t b[2]; +} Unaligned16; + +typedef union __attribute__((packed)) Unaligned32 { + uint32_t u; + uint8_t b[4]; +} Unaligned32; + +/* Unaligned load of uint16_t. */ +static LJ_AINLINE uint16_t lj_getu16(const void *p) +{ + return ((const Unaligned16 *)p)->u; +} + +/* Unaligned load of uint32_t. */ +static LJ_AINLINE uint32_t lj_getu32(const void *p) +{ + return ((const Unaligned32 *)p)->u; +} + +#elif defined(_MSC_VER) + +#define LJ_NORET __declspec(noreturn) +#define LJ_ALIGN(n) __declspec(align(n)) +#define LJ_INLINE __inline +#define LJ_AINLINE __forceinline +#define LJ_NOINLINE __declspec(noinline) +#if defined(_M_IX86) +#define LJ_FASTCALL __fastcall +#endif + +#ifdef _M_PPC +unsigned int _CountLeadingZeros(long); +#pragma intrinsic(_CountLeadingZeros) +static LJ_AINLINE uint32_t lj_fls(uint32_t x) +{ + return _CountLeadingZeros(x) ^ 31; +} +#else +unsigned char _BitScanForward(uint32_t *, unsigned long); +unsigned char _BitScanReverse(uint32_t *, unsigned long); +#pragma intrinsic(_BitScanForward) +#pragma intrinsic(_BitScanReverse) + +static LJ_AINLINE uint32_t lj_ffs(uint32_t x) +{ + uint32_t r; _BitScanForward(&r, x); return r; +} + +static LJ_AINLINE uint32_t lj_fls(uint32_t x) +{ + uint32_t r; _BitScanReverse(&r, x); return r; +} +#endif + +unsigned long _byteswap_ulong(unsigned long); +uint64_t _byteswap_uint64(uint64_t); +#define lj_bswap(x) (_byteswap_ulong((x))) +#define lj_bswap64(x) (_byteswap_uint64((x))) + +#if defined(_M_PPC) && defined(LUAJIT_NO_UNALIGNED) +/* +** Replacement for unaligned loads on Xbox 360. Disabled by default since it's +** usually more costly than the occasional stall when crossing a cache-line. +*/ +static LJ_AINLINE uint16_t lj_getu16(const void *v) +{ + const uint8_t *p = (const uint8_t *)v; + return (uint16_t)((p[0]<<8) | p[1]); +} +static LJ_AINLINE uint32_t lj_getu32(const void *v) +{ + const uint8_t *p = (const uint8_t *)v; + return (uint32_t)((p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]); +} +#else +/* Unaligned loads are generally ok on x86/x64. */ +#define lj_getu16(p) (*(uint16_t *)(p)) +#define lj_getu32(p) (*(uint32_t *)(p)) +#endif + +#else +#error "missing defines for your compiler" +#endif + +/* Optional defines. */ +#ifndef LJ_FASTCALL +#define LJ_FASTCALL +#endif +#ifndef LJ_NORET +#define LJ_NORET +#endif +#ifndef LJ_NOAPI +#define LJ_NOAPI extern +#endif +#ifndef LJ_LIKELY +#define LJ_LIKELY(x) (x) +#define LJ_UNLIKELY(x) (x) +#endif + +/* Attributes for internal functions. */ +#define LJ_DATA LJ_NOAPI +#define LJ_DATADEF +#define LJ_ASMF LJ_NOAPI +#define LJ_FUNCA LJ_NOAPI +#if defined(ljamalg_c) +#define LJ_FUNC static +#else +#define LJ_FUNC LJ_NOAPI +#endif +#define LJ_FUNC_NORET LJ_FUNC LJ_NORET +#define LJ_FUNCA_NORET LJ_FUNCA LJ_NORET +#define LJ_ASMF_NORET LJ_ASMF LJ_NORET + +/* Runtime assertions. */ +#ifdef lua_assert +#define check_exp(c, e) (lua_assert(c), (e)) +#define api_check(l, e) lua_assert(e) +#else +#define lua_assert(c) ((void)0) +#define check_exp(c, e) (e) +#define api_check luai_apicheck +#endif + +/* Static assertions. */ +#define LJ_ASSERT_NAME2(name, line) name ## line +#define LJ_ASSERT_NAME(line) LJ_ASSERT_NAME2(lj_assert_, line) +#ifdef __COUNTER__ +#define LJ_STATIC_ASSERT(cond) \ + extern void LJ_ASSERT_NAME(__COUNTER__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1]) +#else +#define LJ_STATIC_ASSERT(cond) \ + extern void LJ_ASSERT_NAME(__LINE__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1]) +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_dispatch.c`: + +```c +/* +** Instruction dispatch handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_dispatch_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_func.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_meta.h" +#include "lj_debug.h" +#include "lj_state.h" +#include "lj_frame.h" +#include "lj_bc.h" +#include "lj_ff.h" +#if LJ_HASJIT +#include "lj_jit.h" +#endif +#if LJ_HASFFI +#include "lj_ccallback.h" +#endif +#include "lj_trace.h" +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "luajit.h" + +/* Bump GG_NUM_ASMFF in lj_dispatch.h as needed. Ugly. */ +LJ_STATIC_ASSERT(GG_NUM_ASMFF == FF_NUM_ASMFUNC); + +/* -- Dispatch table management ------------------------------------------- */ + +#if LJ_TARGET_MIPS +#include +LJ_FUNCA_NORET void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L, + lua_State *co); + +#define GOTFUNC(name) (ASMFunction)name, +static const ASMFunction dispatch_got[] = { + GOTDEF(GOTFUNC) +}; +#undef GOTFUNC +#endif + +/* Initialize instruction dispatch table and hot counters. */ +void lj_dispatch_init(GG_State *GG) +{ + uint32_t i; + ASMFunction *disp = GG->dispatch; + for (i = 0; i < GG_LEN_SDISP; i++) + disp[GG_LEN_DDISP+i] = disp[i] = makeasmfunc(lj_bc_ofs[i]); + for (i = GG_LEN_SDISP; i < GG_LEN_DDISP; i++) + disp[i] = makeasmfunc(lj_bc_ofs[i]); + /* The JIT engine is off by default. luaopen_jit() turns it on. */ + disp[BC_FORL] = disp[BC_IFORL]; + disp[BC_ITERL] = disp[BC_IITERL]; + disp[BC_LOOP] = disp[BC_ILOOP]; + disp[BC_FUNCF] = disp[BC_IFUNCF]; + disp[BC_FUNCV] = disp[BC_IFUNCV]; + GG->g.bc_cfunc_ext = GG->g.bc_cfunc_int = BCINS_AD(BC_FUNCC, LUA_MINSTACK, 0); + for (i = 0; i < GG_NUM_ASMFF; i++) + GG->bcff[i] = BCINS_AD(BC__MAX+i, 0, 0); +#if LJ_TARGET_MIPS + memcpy(GG->got, dispatch_got, LJ_GOT__MAX*4); +#endif +} + +#if LJ_HASJIT +/* Initialize hotcount table. */ +void lj_dispatch_init_hotcount(global_State *g) +{ + int32_t hotloop = G2J(g)->param[JIT_P_hotloop]; + HotCount start = (HotCount)(hotloop*HOTCOUNT_LOOP - 1); + HotCount *hotcount = G2GG(g)->hotcount; + uint32_t i; + for (i = 0; i < HOTCOUNT_SIZE; i++) + hotcount[i] = start; +} +#endif + +/* Internal dispatch mode bits. */ +#define DISPMODE_JIT 0x01 /* JIT compiler on. */ +#define DISPMODE_REC 0x02 /* Recording active. */ +#define DISPMODE_INS 0x04 /* Override instruction dispatch. */ +#define DISPMODE_CALL 0x08 /* Override call dispatch. */ +#define DISPMODE_RET 0x10 /* Override return dispatch. */ + +/* Update dispatch table depending on various flags. */ +void lj_dispatch_update(global_State *g) +{ + uint8_t oldmode = g->dispatchmode; + uint8_t mode = 0; +#if LJ_HASJIT + mode |= (G2J(g)->flags & JIT_F_ON) ? DISPMODE_JIT : 0; + mode |= G2J(g)->state != LJ_TRACE_IDLE ? + (DISPMODE_REC|DISPMODE_INS|DISPMODE_CALL) : 0; +#endif + mode |= (g->hookmask & (LUA_MASKLINE|LUA_MASKCOUNT)) ? DISPMODE_INS : 0; + mode |= (g->hookmask & LUA_MASKCALL) ? DISPMODE_CALL : 0; + mode |= (g->hookmask & LUA_MASKRET) ? DISPMODE_RET : 0; + if (oldmode != mode) { /* Mode changed? */ + ASMFunction *disp = G2GG(g)->dispatch; + ASMFunction f_forl, f_iterl, f_loop, f_funcf, f_funcv; + g->dispatchmode = mode; + + /* Hotcount if JIT is on, but not while recording. */ + if ((mode & (DISPMODE_JIT|DISPMODE_REC)) == DISPMODE_JIT) { + f_forl = makeasmfunc(lj_bc_ofs[BC_FORL]); + f_iterl = makeasmfunc(lj_bc_ofs[BC_ITERL]); + f_loop = makeasmfunc(lj_bc_ofs[BC_LOOP]); + f_funcf = makeasmfunc(lj_bc_ofs[BC_FUNCF]); + f_funcv = makeasmfunc(lj_bc_ofs[BC_FUNCV]); + } else { /* Otherwise use the non-hotcounting instructions. */ + f_forl = disp[GG_LEN_DDISP+BC_IFORL]; + f_iterl = disp[GG_LEN_DDISP+BC_IITERL]; + f_loop = disp[GG_LEN_DDISP+BC_ILOOP]; + f_funcf = makeasmfunc(lj_bc_ofs[BC_IFUNCF]); + f_funcv = makeasmfunc(lj_bc_ofs[BC_IFUNCV]); + } + /* Init static counting instruction dispatch first (may be copied below). */ + disp[GG_LEN_DDISP+BC_FORL] = f_forl; + disp[GG_LEN_DDISP+BC_ITERL] = f_iterl; + disp[GG_LEN_DDISP+BC_LOOP] = f_loop; + + /* Set dynamic instruction dispatch. */ + if ((oldmode ^ mode) & (DISPMODE_REC|DISPMODE_INS)) { + /* Need to update the whole table. */ + if (!(mode & (DISPMODE_REC|DISPMODE_INS))) { /* No ins dispatch? */ + /* Copy static dispatch table to dynamic dispatch table. */ + memcpy(&disp[0], &disp[GG_LEN_DDISP], GG_LEN_SDISP*sizeof(ASMFunction)); + /* Overwrite with dynamic return dispatch. */ + if ((mode & DISPMODE_RET)) { + disp[BC_RETM] = lj_vm_rethook; + disp[BC_RET] = lj_vm_rethook; + disp[BC_RET0] = lj_vm_rethook; + disp[BC_RET1] = lj_vm_rethook; + } + } else { + /* The recording dispatch also checks for hooks. */ + ASMFunction f = (mode & DISPMODE_REC) ? lj_vm_record : lj_vm_inshook; + uint32_t i; + for (i = 0; i < GG_LEN_SDISP; i++) + disp[i] = f; + } + } else if (!(mode & (DISPMODE_REC|DISPMODE_INS))) { + /* Otherwise set dynamic counting ins. */ + disp[BC_FORL] = f_forl; + disp[BC_ITERL] = f_iterl; + disp[BC_LOOP] = f_loop; + /* Set dynamic return dispatch. */ + if ((mode & DISPMODE_RET)) { + disp[BC_RETM] = lj_vm_rethook; + disp[BC_RET] = lj_vm_rethook; + disp[BC_RET0] = lj_vm_rethook; + disp[BC_RET1] = lj_vm_rethook; + } else { + disp[BC_RETM] = disp[GG_LEN_DDISP+BC_RETM]; + disp[BC_RET] = disp[GG_LEN_DDISP+BC_RET]; + disp[BC_RET0] = disp[GG_LEN_DDISP+BC_RET0]; + disp[BC_RET1] = disp[GG_LEN_DDISP+BC_RET1]; + } + } + + /* Set dynamic call dispatch. */ + if ((oldmode ^ mode) & DISPMODE_CALL) { /* Update the whole table? */ + uint32_t i; + if ((mode & DISPMODE_CALL) == 0) { /* No call hooks? */ + for (i = GG_LEN_SDISP; i < GG_LEN_DDISP; i++) + disp[i] = makeasmfunc(lj_bc_ofs[i]); + } else { + for (i = GG_LEN_SDISP; i < GG_LEN_DDISP; i++) + disp[i] = lj_vm_callhook; + } + } + if (!(mode & DISPMODE_CALL)) { /* Overwrite dynamic counting ins. */ + disp[BC_FUNCF] = f_funcf; + disp[BC_FUNCV] = f_funcv; + } + +#if LJ_HASJIT + /* Reset hotcounts for JIT off to on transition. */ + if ((mode & DISPMODE_JIT) && !(oldmode & DISPMODE_JIT)) + lj_dispatch_init_hotcount(g); +#endif + } +} + +/* -- JIT mode setting ---------------------------------------------------- */ + +#if LJ_HASJIT +/* Set JIT mode for a single prototype. */ +static void setptmode(global_State *g, GCproto *pt, int mode) +{ + if ((mode & LUAJIT_MODE_ON)) { /* (Re-)enable JIT compilation. */ + pt->flags &= ~PROTO_NOJIT; + lj_trace_reenableproto(pt); /* Unpatch all ILOOP etc. bytecodes. */ + } else { /* Flush and/or disable JIT compilation. */ + if (!(mode & LUAJIT_MODE_FLUSH)) + pt->flags |= PROTO_NOJIT; + lj_trace_flushproto(g, pt); /* Flush all traces of prototype. */ + } +} + +/* Recursively set the JIT mode for all children of a prototype. */ +static void setptmode_all(global_State *g, GCproto *pt, int mode) +{ + ptrdiff_t i; + if (!(pt->flags & PROTO_CHILD)) return; + for (i = -(ptrdiff_t)pt->sizekgc; i < 0; i++) { + GCobj *o = proto_kgc(pt, i); + if (o->gch.gct == ~LJ_TPROTO) { + setptmode(g, gco2pt(o), mode); + setptmode_all(g, gco2pt(o), mode); + } + } +} +#endif + +/* Public API function: control the JIT engine. */ +int luaJIT_setmode(lua_State *L, int idx, int mode) +{ + global_State *g = G(L); + int mm = mode & LUAJIT_MODE_MASK; + lj_trace_abort(g); /* Abort recording on any state change. */ + /* Avoid pulling the rug from under our own feet. */ + if ((g->hookmask & HOOK_GC)) + lj_err_caller(L, LJ_ERR_NOGCMM); + switch (mm) { +#if LJ_HASJIT + case LUAJIT_MODE_ENGINE: + if ((mode & LUAJIT_MODE_FLUSH)) { + lj_trace_flushall(L); + } else { + if (!(mode & LUAJIT_MODE_ON)) + G2J(g)->flags &= ~(uint32_t)JIT_F_ON; +#if LJ_TARGET_X86ORX64 + else if ((G2J(g)->flags & JIT_F_SSE2)) + G2J(g)->flags |= (uint32_t)JIT_F_ON; + else + return 0; /* Don't turn on JIT compiler without SSE2 support. */ +#else + else + G2J(g)->flags |= (uint32_t)JIT_F_ON; +#endif + lj_dispatch_update(g); + } + break; + case LUAJIT_MODE_FUNC: + case LUAJIT_MODE_ALLFUNC: + case LUAJIT_MODE_ALLSUBFUNC: { + cTValue *tv = idx == 0 ? frame_prev(L->base-1) : + idx > 0 ? L->base + (idx-1) : L->top + idx; + GCproto *pt; + if ((idx == 0 || tvisfunc(tv)) && isluafunc(&gcval(tv)->fn)) + pt = funcproto(&gcval(tv)->fn); /* Cannot use funcV() for frame slot. */ + else if (tvisproto(tv)) + pt = protoV(tv); + else + return 0; /* Failed. */ + if (mm != LUAJIT_MODE_ALLSUBFUNC) + setptmode(g, pt, mode); + if (mm != LUAJIT_MODE_FUNC) + setptmode_all(g, pt, mode); + break; + } + case LUAJIT_MODE_TRACE: + if (!(mode & LUAJIT_MODE_FLUSH)) + return 0; /* Failed. */ + lj_trace_flush(G2J(g), idx); + break; +#else + case LUAJIT_MODE_ENGINE: + case LUAJIT_MODE_FUNC: + case LUAJIT_MODE_ALLFUNC: + case LUAJIT_MODE_ALLSUBFUNC: + UNUSED(idx); + if ((mode & LUAJIT_MODE_ON)) + return 0; /* Failed. */ + break; +#endif + case LUAJIT_MODE_WRAPCFUNC: + if ((mode & LUAJIT_MODE_ON)) { + if (idx != 0) { + cTValue *tv = idx > 0 ? L->base + (idx-1) : L->top + idx; + if (tvislightud(tv)) + g->wrapf = (lua_CFunction)lightudV(tv); + else + return 0; /* Failed. */ + } else { + return 0; /* Failed. */ + } + g->bc_cfunc_ext = BCINS_AD(BC_FUNCCW, 0, 0); + } else { + g->bc_cfunc_ext = BCINS_AD(BC_FUNCC, 0, 0); + } + break; + default: + return 0; /* Failed. */ + } + return 1; /* OK. */ +} + +/* Enforce (dynamic) linker error for version mismatches. See luajit.c. */ +LUA_API void LUAJIT_VERSION_SYM(void) +{ +} + +/* -- Hooks --------------------------------------------------------------- */ + +/* This function can be called asynchronously (e.g. during a signal). */ +LUA_API int lua_sethook(lua_State *L, lua_Hook func, int mask, int count) +{ + global_State *g = G(L); + mask &= HOOK_EVENTMASK; + if (func == NULL || mask == 0) { mask = 0; func = NULL; } /* Consistency. */ + g->hookf = func; + g->hookcount = g->hookcstart = (int32_t)count; + g->hookmask = (uint8_t)((g->hookmask & ~HOOK_EVENTMASK) | mask); + lj_trace_abort(g); /* Abort recording on any hook change. */ + lj_dispatch_update(g); + return 1; +} + +LUA_API lua_Hook lua_gethook(lua_State *L) +{ + return G(L)->hookf; +} + +LUA_API int lua_gethookmask(lua_State *L) +{ + return G(L)->hookmask & HOOK_EVENTMASK; +} + +LUA_API int lua_gethookcount(lua_State *L) +{ + return (int)G(L)->hookcstart; +} + +/* Call a hook. */ +static void callhook(lua_State *L, int event, BCLine line) +{ + global_State *g = G(L); + lua_Hook hookf = g->hookf; + if (hookf && !hook_active(g)) { + lua_Debug ar; + lj_trace_abort(g); /* Abort recording on any hook call. */ + ar.event = event; + ar.currentline = line; + /* Top frame, nextframe = NULL. */ + ar.i_ci = (int)((L->base-1) - tvref(L->stack)); + lj_state_checkstack(L, 1+LUA_MINSTACK); + hook_enter(g); + hookf(L, &ar); + lua_assert(hook_active(g)); + hook_leave(g); + } +} + +/* -- Dispatch callbacks -------------------------------------------------- */ + +/* Calculate number of used stack slots in the current frame. */ +static BCReg cur_topslot(GCproto *pt, const BCIns *pc, uint32_t nres) +{ + BCIns ins = pc[-1]; + if (bc_op(ins) == BC_UCLO) + ins = pc[bc_j(ins)]; + switch (bc_op(ins)) { + case BC_CALLM: case BC_CALLMT: return bc_a(ins) + bc_c(ins) + nres-1+1; + case BC_RETM: return bc_a(ins) + bc_d(ins) + nres-1; + case BC_TSETM: return bc_a(ins) + nres-1; + default: return pt->framesize; + } +} + +/* Instruction dispatch. Used by instr/line/return hooks or when recording. */ +void LJ_FASTCALL lj_dispatch_ins(lua_State *L, const BCIns *pc) +{ + ERRNO_SAVE + GCfunc *fn = curr_func(L); + GCproto *pt = funcproto(fn); + void *cf = cframe_raw(L->cframe); + const BCIns *oldpc = cframe_pc(cf); + global_State *g = G(L); + BCReg slots; + setcframe_pc(cf, pc); + slots = cur_topslot(pt, pc, cframe_multres_n(cf)); + L->top = L->base + slots; /* Fix top. */ +#if LJ_HASJIT + { + jit_State *J = G2J(g); + if (J->state != LJ_TRACE_IDLE) { +#ifdef LUA_USE_ASSERT + ptrdiff_t delta = L->top - L->base; +#endif + J->L = L; + lj_trace_ins(J, pc-1); /* The interpreter bytecode PC is offset by 1. */ + lua_assert(L->top - L->base == delta); + } + } +#endif + if ((g->hookmask & LUA_MASKCOUNT) && g->hookcount == 0) { + g->hookcount = g->hookcstart; + callhook(L, LUA_HOOKCOUNT, -1); + L->top = L->base + slots; /* Fix top again. */ + } + if ((g->hookmask & LUA_MASKLINE)) { + BCPos npc = proto_bcpos(pt, pc) - 1; + BCPos opc = proto_bcpos(pt, oldpc) - 1; + BCLine line = lj_debug_line(pt, npc); + if (pc <= oldpc || opc >= pt->sizebc || line != lj_debug_line(pt, opc)) { + callhook(L, LUA_HOOKLINE, line); + L->top = L->base + slots; /* Fix top again. */ + } + } + if ((g->hookmask & LUA_MASKRET) && bc_isret(bc_op(pc[-1]))) + callhook(L, LUA_HOOKRET, -1); + ERRNO_RESTORE +} + +/* Initialize call. Ensure stack space and return # of missing parameters. */ +static int call_init(lua_State *L, GCfunc *fn) +{ + if (isluafunc(fn)) { + GCproto *pt = funcproto(fn); + int numparams = pt->numparams; + int gotparams = (int)(L->top - L->base); + int need = pt->framesize; + if ((pt->flags & PROTO_VARARG)) need += 1+gotparams; + lj_state_checkstack(L, (MSize)need); + numparams -= gotparams; + return numparams >= 0 ? numparams : 0; + } else { + lj_state_checkstack(L, LUA_MINSTACK); + return 0; + } +} + +/* Call dispatch. Used by call hooks, hot calls or when recording. */ +ASMFunction LJ_FASTCALL lj_dispatch_call(lua_State *L, const BCIns *pc) +{ + ERRNO_SAVE + GCfunc *fn = curr_func(L); + BCOp op; + global_State *g = G(L); +#if LJ_HASJIT + jit_State *J = G2J(g); +#endif + int missing = call_init(L, fn); +#if LJ_HASJIT + J->L = L; + if ((uintptr_t)pc & 1) { /* Marker for hot call. */ +#ifdef LUA_USE_ASSERT + ptrdiff_t delta = L->top - L->base; +#endif + pc = (const BCIns *)((uintptr_t)pc & ~(uintptr_t)1); + lj_trace_hot(J, pc); + lua_assert(L->top - L->base == delta); + goto out; + } else if (J->state != LJ_TRACE_IDLE && + !(g->hookmask & (HOOK_GC|HOOK_VMEVENT))) { +#ifdef LUA_USE_ASSERT + ptrdiff_t delta = L->top - L->base; +#endif + /* Record the FUNC* bytecodes, too. */ + lj_trace_ins(J, pc-1); /* The interpreter bytecode PC is offset by 1. */ + lua_assert(L->top - L->base == delta); + } +#endif + if ((g->hookmask & LUA_MASKCALL)) { + int i; + for (i = 0; i < missing; i++) /* Add missing parameters. */ + setnilV(L->top++); + callhook(L, LUA_HOOKCALL, -1); + /* Preserve modifications of missing parameters by lua_setlocal(). */ + while (missing-- > 0 && tvisnil(L->top - 1)) + L->top--; + } +#if LJ_HASJIT +out: +#endif + op = bc_op(pc[-1]); /* Get FUNC* op. */ +#if LJ_HASJIT + /* Use the non-hotcounting variants if JIT is off or while recording. */ + if ((!(J->flags & JIT_F_ON) || J->state != LJ_TRACE_IDLE) && + (op == BC_FUNCF || op == BC_FUNCV)) + op = (BCOp)((int)op+(int)BC_IFUNCF-(int)BC_FUNCF); +#endif + ERRNO_RESTORE + return makeasmfunc(lj_bc_ofs[op]); /* Return static dispatch target. */ +} + + +``` + +`include/luajit-2.0.5/src/lj_dispatch.h`: + +```h +/* +** Instruction dispatch handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_DISPATCH_H +#define _LJ_DISPATCH_H + +#include "lj_obj.h" +#include "lj_bc.h" +#if LJ_HASJIT +#include "lj_jit.h" +#endif + +#if LJ_TARGET_MIPS +/* Need our own global offset table for the dreaded MIPS calling conventions. */ +#if LJ_HASJIT +#define JITGOTDEF(_) _(lj_trace_exit) _(lj_trace_hot) +#else +#define JITGOTDEF(_) +#endif +#if LJ_HASFFI +#define FFIGOTDEF(_) \ + _(lj_meta_equal_cd) _(lj_ccallback_enter) _(lj_ccallback_leave) +#else +#define FFIGOTDEF(_) +#endif +#define GOTDEF(_) \ + _(floor) _(ceil) _(trunc) _(log) _(log10) _(exp) _(sin) _(cos) _(tan) \ + _(asin) _(acos) _(atan) _(sinh) _(cosh) _(tanh) _(frexp) _(modf) _(atan2) \ + _(pow) _(fmod) _(ldexp) \ + _(lj_dispatch_call) _(lj_dispatch_ins) _(lj_err_throw) \ + _(lj_ffh_coroutine_wrap_err) _(lj_func_closeuv) _(lj_func_newL_gc) \ + _(lj_gc_barrieruv) _(lj_gc_step) _(lj_gc_step_fixtop) _(lj_meta_arith) \ + _(lj_meta_call) _(lj_meta_cat) _(lj_meta_comp) _(lj_meta_equal) \ + _(lj_meta_for) _(lj_meta_len) _(lj_meta_tget) _(lj_meta_tset) \ + _(lj_state_growstack) _(lj_str_fromnum) _(lj_str_fromnumber) _(lj_str_new) \ + _(lj_tab_dup) _(lj_tab_get) _(lj_tab_getinth) _(lj_tab_len) _(lj_tab_new) \ + _(lj_tab_newkey) _(lj_tab_next) _(lj_tab_reasize) \ + JITGOTDEF(_) FFIGOTDEF(_) + +enum { +#define GOTENUM(name) LJ_GOT_##name, +GOTDEF(GOTENUM) +#undef GOTENUM + LJ_GOT__MAX +}; +#endif + +/* Type of hot counter. Must match the code in the assembler VM. */ +/* 16 bits are sufficient. Only 0.0015% overhead with maximum slot penalty. */ +typedef uint16_t HotCount; + +/* Number of hot counter hash table entries (must be a power of two). */ +#define HOTCOUNT_SIZE 64 +#define HOTCOUNT_PCMASK ((HOTCOUNT_SIZE-1)*sizeof(HotCount)) + +/* Hotcount decrements. */ +#define HOTCOUNT_LOOP 2 +#define HOTCOUNT_CALL 1 + +/* This solves a circular dependency problem -- bump as needed. Sigh. */ +#define GG_NUM_ASMFF 62 + +#define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF) +#define GG_LEN_SDISP BC_FUNCF +#define GG_LEN_DISP (GG_LEN_DDISP + GG_LEN_SDISP) + +/* Global state, main thread and extra fields are allocated together. */ +typedef struct GG_State { + lua_State L; /* Main thread. */ + global_State g; /* Global state. */ +#if LJ_TARGET_MIPS + ASMFunction got[LJ_GOT__MAX]; /* Global offset table. */ +#endif +#if LJ_HASJIT + jit_State J; /* JIT state. */ + HotCount hotcount[HOTCOUNT_SIZE]; /* Hot counters. */ +#endif + ASMFunction dispatch[GG_LEN_DISP]; /* Instruction dispatch tables. */ + BCIns bcff[GG_NUM_ASMFF]; /* Bytecode for ASM fast functions. */ +} GG_State; + +#define GG_OFS(field) ((int)offsetof(GG_State, field)) +#define G2GG(gl) ((GG_State *)((char *)(gl) - GG_OFS(g))) +#define J2GG(j) ((GG_State *)((char *)(j) - GG_OFS(J))) +#define L2GG(L) (G2GG(G(L))) +#define J2G(J) (&J2GG(J)->g) +#define G2J(gl) (&G2GG(gl)->J) +#define L2J(L) (&L2GG(L)->J) +#define GG_G2DISP (GG_OFS(dispatch) - GG_OFS(g)) +#define GG_DISP2G (GG_OFS(g) - GG_OFS(dispatch)) +#define GG_DISP2J (GG_OFS(J) - GG_OFS(dispatch)) +#define GG_DISP2HOT (GG_OFS(hotcount) - GG_OFS(dispatch)) +#define GG_DISP2STATIC (GG_LEN_DDISP*(int)sizeof(ASMFunction)) + +#define hotcount_get(gg, pc) \ + (gg)->hotcount[(u32ptr(pc)>>2) & (HOTCOUNT_SIZE-1)] +#define hotcount_set(gg, pc, val) \ + (hotcount_get((gg), (pc)) = (HotCount)(val)) + +/* Dispatch table management. */ +LJ_FUNC void lj_dispatch_init(GG_State *GG); +#if LJ_HASJIT +LJ_FUNC void lj_dispatch_init_hotcount(global_State *g); +#endif +LJ_FUNC void lj_dispatch_update(global_State *g); + +/* Instruction dispatch callback for hooks or when recording. */ +LJ_FUNCA void LJ_FASTCALL lj_dispatch_ins(lua_State *L, const BCIns *pc); +LJ_FUNCA ASMFunction LJ_FASTCALL lj_dispatch_call(lua_State *L, const BCIns*pc); +LJ_FUNCA void LJ_FASTCALL lj_dispatch_return(lua_State *L, const BCIns *pc); + +#if LJ_HASFFI && !defined(_BUILDVM_H) +/* Save/restore errno and GetLastError() around hooks, exits and recording. */ +#include +#if LJ_TARGET_WINDOWS +#define WIN32_LEAN_AND_MEAN +#include +#define ERRNO_SAVE int olderr = errno; DWORD oldwerr = GetLastError(); +#define ERRNO_RESTORE errno = olderr; SetLastError(oldwerr); +#else +#define ERRNO_SAVE int olderr = errno; +#define ERRNO_RESTORE errno = olderr; +#endif +#else +#define ERRNO_SAVE +#define ERRNO_RESTORE +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_emit_arm.h`: + +```h +/* +** ARM instruction emitter. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Constant encoding --------------------------------------------------- */ + +static uint8_t emit_invai[16] = { + /* AND */ (ARMI_AND^ARMI_BIC) >> 21, + /* EOR */ 0, + /* SUB */ (ARMI_SUB^ARMI_ADD) >> 21, + /* RSB */ 0, + /* ADD */ (ARMI_ADD^ARMI_SUB) >> 21, + /* ADC */ (ARMI_ADC^ARMI_SBC) >> 21, + /* SBC */ (ARMI_SBC^ARMI_ADC) >> 21, + /* RSC */ 0, + /* TST */ 0, + /* TEQ */ 0, + /* CMP */ (ARMI_CMP^ARMI_CMN) >> 21, + /* CMN */ (ARMI_CMN^ARMI_CMP) >> 21, + /* ORR */ 0, + /* MOV */ (ARMI_MOV^ARMI_MVN) >> 21, + /* BIC */ (ARMI_BIC^ARMI_AND) >> 21, + /* MVN */ (ARMI_MVN^ARMI_MOV) >> 21 +}; + +/* Encode constant in K12 format for data processing instructions. */ +static uint32_t emit_isk12(ARMIns ai, int32_t n) +{ + uint32_t invai, i, m = (uint32_t)n; + /* K12: unsigned 8 bit value, rotated in steps of two bits. */ + for (i = 0; i < 4096; i += 256, m = lj_rol(m, 2)) + if (m <= 255) return ARMI_K12|m|i; + /* Otherwise try negation/complement with the inverse instruction. */ + invai = emit_invai[((ai >> 21) & 15)]; + if (!invai) return 0; /* Failed. No inverse instruction. */ + m = ~(uint32_t)n; + if (invai == ((ARMI_SUB^ARMI_ADD) >> 21) || + invai == (ARMI_CMP^ARMI_CMN) >> 21) m++; + for (i = 0; i < 4096; i += 256, m = lj_rol(m, 2)) + if (m <= 255) return ARMI_K12|(invai<<21)|m|i; + return 0; /* Failed. */ +} + +/* -- Emit basic instructions --------------------------------------------- */ + +static void emit_dnm(ASMState *as, ARMIns ai, Reg rd, Reg rn, Reg rm) +{ + *--as->mcp = ai | ARMF_D(rd) | ARMF_N(rn) | ARMF_M(rm); +} + +static void emit_dm(ASMState *as, ARMIns ai, Reg rd, Reg rm) +{ + *--as->mcp = ai | ARMF_D(rd) | ARMF_M(rm); +} + +static void emit_dn(ASMState *as, ARMIns ai, Reg rd, Reg rn) +{ + *--as->mcp = ai | ARMF_D(rd) | ARMF_N(rn); +} + +static void emit_nm(ASMState *as, ARMIns ai, Reg rn, Reg rm) +{ + *--as->mcp = ai | ARMF_N(rn) | ARMF_M(rm); +} + +static void emit_d(ASMState *as, ARMIns ai, Reg rd) +{ + *--as->mcp = ai | ARMF_D(rd); +} + +static void emit_n(ASMState *as, ARMIns ai, Reg rn) +{ + *--as->mcp = ai | ARMF_N(rn); +} + +static void emit_m(ASMState *as, ARMIns ai, Reg rm) +{ + *--as->mcp = ai | ARMF_M(rm); +} + +static void emit_lsox(ASMState *as, ARMIns ai, Reg rd, Reg rn, int32_t ofs) +{ + lua_assert(ofs >= -255 && ofs <= 255); + if (ofs < 0) ofs = -ofs; else ai |= ARMI_LS_U; + *--as->mcp = ai | ARMI_LS_P | ARMI_LSX_I | ARMF_D(rd) | ARMF_N(rn) | + ((ofs & 0xf0) << 4) | (ofs & 0x0f); +} + +static void emit_lso(ASMState *as, ARMIns ai, Reg rd, Reg rn, int32_t ofs) +{ + lua_assert(ofs >= -4095 && ofs <= 4095); + /* Combine LDR/STR pairs to LDRD/STRD. */ + if (*as->mcp == (ai|ARMI_LS_P|ARMI_LS_U|ARMF_D(rd^1)|ARMF_N(rn)|(ofs^4)) && + (ai & ~(ARMI_LDR^ARMI_STR)) == ARMI_STR && rd != rn && + (uint32_t)ofs <= 252 && !(ofs & 3) && !((rd ^ (ofs >>2)) & 1) && + as->mcp != as->mcloop) { + as->mcp++; + emit_lsox(as, ai == ARMI_LDR ? ARMI_LDRD : ARMI_STRD, rd&~1, rn, ofs&~4); + return; + } + if (ofs < 0) ofs = -ofs; else ai |= ARMI_LS_U; + *--as->mcp = ai | ARMI_LS_P | ARMF_D(rd) | ARMF_N(rn) | ofs; +} + +#if !LJ_SOFTFP +static void emit_vlso(ASMState *as, ARMIns ai, Reg rd, Reg rn, int32_t ofs) +{ + lua_assert(ofs >= -1020 && ofs <= 1020 && (ofs&3) == 0); + if (ofs < 0) ofs = -ofs; else ai |= ARMI_LS_U; + *--as->mcp = ai | ARMI_LS_P | ARMF_D(rd & 15) | ARMF_N(rn) | (ofs >> 2); +} +#endif + +/* -- Emit loads/stores --------------------------------------------------- */ + +/* Prefer spills of BASE/L. */ +#define emit_canremat(ref) ((ref) < ASMREF_L) + +/* Try to find a one step delta relative to another constant. */ +static int emit_kdelta1(ASMState *as, Reg d, int32_t i) +{ + RegSet work = ~as->freeset & RSET_GPR; + while (work) { + Reg r = rset_picktop(work); + IRRef ref = regcost_ref(as->cost[r]); + lua_assert(r != d); + if (emit_canremat(ref)) { + int32_t delta = i - (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i); + uint32_t k = emit_isk12(ARMI_ADD, delta); + if (k) { + if (k == ARMI_K12) + emit_dm(as, ARMI_MOV, d, r); + else + emit_dn(as, ARMI_ADD^k, d, r); + return 1; + } + } + rset_clear(work, r); + } + return 0; /* Failed. */ +} + +/* Try to find a two step delta relative to another constant. */ +static int emit_kdelta2(ASMState *as, Reg d, int32_t i) +{ + RegSet work = ~as->freeset & RSET_GPR; + while (work) { + Reg r = rset_picktop(work); + IRRef ref = regcost_ref(as->cost[r]); + lua_assert(r != d); + if (emit_canremat(ref)) { + int32_t other = ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i; + if (other) { + int32_t delta = i - other; + uint32_t sh, inv = 0, k2, k; + if (delta < 0) { delta = -delta; inv = ARMI_ADD^ARMI_SUB; } + sh = lj_ffs(delta) & ~1; + k2 = emit_isk12(0, delta & (255 << sh)); + k = emit_isk12(0, delta & ~(255 << sh)); + if (k) { + emit_dn(as, ARMI_ADD^k2^inv, d, d); + emit_dn(as, ARMI_ADD^k^inv, d, r); + return 1; + } + } + } + rset_clear(work, r); + } + return 0; /* Failed. */ +} + +/* Load a 32 bit constant into a GPR. */ +static void emit_loadi(ASMState *as, Reg r, int32_t i) +{ + uint32_t k = emit_isk12(ARMI_MOV, i); + lua_assert(rset_test(as->freeset, r) || r == RID_TMP); + if (k) { + /* Standard K12 constant. */ + emit_d(as, ARMI_MOV^k, r); + } else if ((as->flags & JIT_F_ARMV6T2) && (uint32_t)i < 0x00010000u) { + /* 16 bit loword constant for ARMv6T2. */ + emit_d(as, ARMI_MOVW|(i & 0x0fff)|((i & 0xf000)<<4), r); + } else if (emit_kdelta1(as, r, i)) { + /* One step delta relative to another constant. */ + } else if ((as->flags & JIT_F_ARMV6T2)) { + /* 32 bit hiword/loword constant for ARMv6T2. */ + emit_d(as, ARMI_MOVT|((i>>16) & 0x0fff)|(((i>>16) & 0xf000)<<4), r); + emit_d(as, ARMI_MOVW|(i & 0x0fff)|((i & 0xf000)<<4), r); + } else if (emit_kdelta2(as, r, i)) { + /* Two step delta relative to another constant. */ + } else { + /* Otherwise construct the constant with up to 4 instructions. */ + /* NYI: use mvn+bic, use pc-relative loads. */ + for (;;) { + uint32_t sh = lj_ffs(i) & ~1; + int32_t m = i & (255 << sh); + i &= ~(255 << sh); + if (i == 0) { + emit_d(as, ARMI_MOV ^ emit_isk12(0, m), r); + break; + } + emit_dn(as, ARMI_ORR ^ emit_isk12(0, m), r, r); + } + } +} + +#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr))) + +static Reg ra_allock(ASMState *as, int32_t k, RegSet allow); + +/* Get/set from constant pointer. */ +static void emit_lsptr(ASMState *as, ARMIns ai, Reg r, void *p) +{ + int32_t i = i32ptr(p); + emit_lso(as, ai, r, ra_allock(as, (i & ~4095), rset_exclude(RSET_GPR, r)), + (i & 4095)); +} + +#if !LJ_SOFTFP +/* Load a number constant into an FPR. */ +static void emit_loadn(ASMState *as, Reg r, cTValue *tv) +{ + int32_t i; + if ((as->flags & JIT_F_VFPV3) && !tv->u32.lo) { + uint32_t hi = tv->u32.hi; + uint32_t b = ((hi >> 22) & 0x1ff); + if (!(hi & 0xffff) && (b == 0x100 || b == 0x0ff)) { + *--as->mcp = ARMI_VMOVI_D | ARMF_D(r & 15) | + ((tv->u32.hi >> 12) & 0x00080000) | + ((tv->u32.hi >> 4) & 0x00070000) | + ((tv->u32.hi >> 16) & 0x0000000f); + return; + } + } + i = i32ptr(tv); + emit_vlso(as, ARMI_VLDR_D, r, + ra_allock(as, (i & ~1020), RSET_GPR), (i & 1020)); +} +#endif + +/* Get/set global_State fields. */ +#define emit_getgl(as, r, field) \ + emit_lsptr(as, ARMI_LDR, (r), (void *)&J2G(as->J)->field) +#define emit_setgl(as, r, field) \ + emit_lsptr(as, ARMI_STR, (r), (void *)&J2G(as->J)->field) + +/* Trace number is determined from pc of exit instruction. */ +#define emit_setvmstate(as, i) UNUSED(i) + +/* -- Emit control-flow instructions -------------------------------------- */ + +/* Label for internal jumps. */ +typedef MCode *MCLabel; + +/* Return label pointing to current PC. */ +#define emit_label(as) ((as)->mcp) + +static void emit_branch(ASMState *as, ARMIns ai, MCode *target) +{ + MCode *p = as->mcp; + ptrdiff_t delta = (target - p) - 1; + lua_assert(((delta + 0x00800000) >> 24) == 0); + *--p = ai | ((uint32_t)delta & 0x00ffffffu); + as->mcp = p; +} + +#define emit_jmp(as, target) emit_branch(as, ARMI_B, (target)) + +static void emit_call(ASMState *as, void *target) +{ + MCode *p = --as->mcp; + ptrdiff_t delta = ((char *)target - (char *)p) - 8; + if ((((delta>>2) + 0x00800000) >> 24) == 0) { + if ((delta & 1)) + *p = ARMI_BLX | ((uint32_t)(delta>>2) & 0x00ffffffu) | ((delta&2) << 23); + else + *p = ARMI_BL | ((uint32_t)(delta>>2) & 0x00ffffffu); + } else { /* Target out of range: need indirect call. But don't use R0-R3. */ + Reg r = ra_allock(as, i32ptr(target), RSET_RANGE(RID_R4, RID_R12+1)); + *p = ARMI_BLXr | ARMF_M(r); + } +} + +/* -- Emit generic operations --------------------------------------------- */ + +/* Generic move between two regs. */ +static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) +{ +#if LJ_SOFTFP + lua_assert(!irt_isnum(ir->t)); UNUSED(ir); +#else + if (dst >= RID_MAX_GPR) { + emit_dm(as, irt_isnum(ir->t) ? ARMI_VMOV_D : ARMI_VMOV_S, + (dst & 15), (src & 15)); + return; + } +#endif + if (as->mcp != as->mcloop) { /* Swap early registers for loads/stores. */ + MCode ins = *as->mcp, swp = (src^dst); + if ((ins & 0x0c000000) == 0x04000000 && (ins & 0x02000010) != 0x02000010) { + if (!((ins ^ (dst << 16)) & 0x000f0000)) + *as->mcp = ins ^ (swp << 16); /* Swap N in load/store. */ + if (!(ins & 0x00100000) && !((ins ^ (dst << 12)) & 0x0000f000)) + *as->mcp = ins ^ (swp << 12); /* Swap D in store. */ + } + } + emit_dm(as, ARMI_MOV, dst, src); +} + +/* Generic load of register from stack slot. */ +static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ +#if LJ_SOFTFP + lua_assert(!irt_isnum(ir->t)); UNUSED(ir); +#else + if (r >= RID_MAX_GPR) + emit_vlso(as, irt_isnum(ir->t) ? ARMI_VLDR_D : ARMI_VLDR_S, r, RID_SP, ofs); + else +#endif + emit_lso(as, ARMI_LDR, r, RID_SP, ofs); +} + +/* Generic store of register to stack slot. */ +static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ +#if LJ_SOFTFP + lua_assert(!irt_isnum(ir->t)); UNUSED(ir); +#else + if (r >= RID_MAX_GPR) + emit_vlso(as, irt_isnum(ir->t) ? ARMI_VSTR_D : ARMI_VSTR_S, r, RID_SP, ofs); + else +#endif + emit_lso(as, ARMI_STR, r, RID_SP, ofs); +} + +/* Emit an arithmetic/logic operation with a constant operand. */ +static void emit_opk(ASMState *as, ARMIns ai, Reg dest, Reg src, + int32_t i, RegSet allow) +{ + uint32_t k = emit_isk12(ai, i); + if (k) + emit_dn(as, ai^k, dest, src); + else + emit_dnm(as, ai, dest, src, ra_allock(as, i, allow)); +} + +/* Add offset to pointer. */ +static void emit_addptr(ASMState *as, Reg r, int32_t ofs) +{ + if (ofs) + emit_opk(as, ARMI_ADD, r, r, ofs, rset_exclude(RSET_GPR, r)); +} + +#define emit_spsub(as, ofs) emit_addptr(as, RID_SP, -(ofs)) + + +``` + +`include/luajit-2.0.5/src/lj_emit_mips.h`: + +```h +/* +** MIPS instruction emitter. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Emit basic instructions --------------------------------------------- */ + +static void emit_dst(ASMState *as, MIPSIns mi, Reg rd, Reg rs, Reg rt) +{ + *--as->mcp = mi | MIPSF_D(rd) | MIPSF_S(rs) | MIPSF_T(rt); +} + +static void emit_dta(ASMState *as, MIPSIns mi, Reg rd, Reg rt, uint32_t a) +{ + *--as->mcp = mi | MIPSF_D(rd) | MIPSF_T(rt) | MIPSF_A(a); +} + +#define emit_ds(as, mi, rd, rs) emit_dst(as, (mi), (rd), (rs), 0) +#define emit_tg(as, mi, rt, rg) emit_dst(as, (mi), (rg)&31, 0, (rt)) + +static void emit_tsi(ASMState *as, MIPSIns mi, Reg rt, Reg rs, int32_t i) +{ + *--as->mcp = mi | MIPSF_T(rt) | MIPSF_S(rs) | (i & 0xffff); +} + +#define emit_ti(as, mi, rt, i) emit_tsi(as, (mi), (rt), 0, (i)) +#define emit_hsi(as, mi, rh, rs, i) emit_tsi(as, (mi), (rh) & 31, (rs), (i)) + +static void emit_fgh(ASMState *as, MIPSIns mi, Reg rf, Reg rg, Reg rh) +{ + *--as->mcp = mi | MIPSF_F(rf&31) | MIPSF_G(rg&31) | MIPSF_H(rh&31); +} + +#define emit_fg(as, mi, rf, rg) emit_fgh(as, (mi), (rf), (rg), 0) + +static void emit_rotr(ASMState *as, Reg dest, Reg src, Reg tmp, uint32_t shift) +{ + if ((as->flags & JIT_F_MIPS32R2)) { + emit_dta(as, MIPSI_ROTR, dest, src, shift); + } else { + emit_dst(as, MIPSI_OR, dest, dest, tmp); + emit_dta(as, MIPSI_SLL, dest, src, (-shift)&31); + emit_dta(as, MIPSI_SRL, tmp, src, shift); + } +} + +/* -- Emit loads/stores --------------------------------------------------- */ + +/* Prefer rematerialization of BASE/L from global_State over spills. */ +#define emit_canremat(ref) ((ref) <= REF_BASE) + +/* Try to find a one step delta relative to another constant. */ +static int emit_kdelta1(ASMState *as, Reg t, int32_t i) +{ + RegSet work = ~as->freeset & RSET_GPR; + while (work) { + Reg r = rset_picktop(work); + IRRef ref = regcost_ref(as->cost[r]); + lua_assert(r != t); + if (ref < ASMREF_L) { + int32_t delta = i - (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i); + if (checki16(delta)) { + emit_tsi(as, MIPSI_ADDIU, t, r, delta); + return 1; + } + } + rset_clear(work, r); + } + return 0; /* Failed. */ +} + +/* Load a 32 bit constant into a GPR. */ +static void emit_loadi(ASMState *as, Reg r, int32_t i) +{ + if (checki16(i)) { + emit_ti(as, MIPSI_LI, r, i); + } else { + if ((i & 0xffff)) { + int32_t jgl = i32ptr(J2G(as->J)); + if ((uint32_t)(i-jgl) < 65536) { + emit_tsi(as, MIPSI_ADDIU, r, RID_JGL, i-jgl-32768); + return; + } else if (emit_kdelta1(as, r, i)) { + return; + } else if ((i >> 16) == 0) { + emit_tsi(as, MIPSI_ORI, r, RID_ZERO, i); + return; + } + emit_tsi(as, MIPSI_ORI, r, r, i); + } + emit_ti(as, MIPSI_LUI, r, (i >> 16)); + } +} + +#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr))) + +static Reg ra_allock(ASMState *as, int32_t k, RegSet allow); +static void ra_allockreg(ASMState *as, int32_t k, Reg r); + +/* Get/set from constant pointer. */ +static void emit_lsptr(ASMState *as, MIPSIns mi, Reg r, void *p, RegSet allow) +{ + int32_t jgl = i32ptr(J2G(as->J)); + int32_t i = i32ptr(p); + Reg base; + if ((uint32_t)(i-jgl) < 65536) { + i = i-jgl-32768; + base = RID_JGL; + } else { + base = ra_allock(as, i-(int16_t)i, allow); + } + emit_tsi(as, mi, r, base, i); +} + +#define emit_loadn(as, r, tv) \ + emit_lsptr(as, MIPSI_LDC1, ((r) & 31), (void *)(tv), RSET_GPR) + +/* Get/set global_State fields. */ +static void emit_lsglptr(ASMState *as, MIPSIns mi, Reg r, int32_t ofs) +{ + emit_tsi(as, mi, r, RID_JGL, ofs-32768); +} + +#define emit_getgl(as, r, field) \ + emit_lsglptr(as, MIPSI_LW, (r), (int32_t)offsetof(global_State, field)) +#define emit_setgl(as, r, field) \ + emit_lsglptr(as, MIPSI_SW, (r), (int32_t)offsetof(global_State, field)) + +/* Trace number is determined from per-trace exit stubs. */ +#define emit_setvmstate(as, i) UNUSED(i) + +/* -- Emit control-flow instructions -------------------------------------- */ + +/* Label for internal jumps. */ +typedef MCode *MCLabel; + +/* Return label pointing to current PC. */ +#define emit_label(as) ((as)->mcp) + +static void emit_branch(ASMState *as, MIPSIns mi, Reg rs, Reg rt, MCode *target) +{ + MCode *p = as->mcp; + ptrdiff_t delta = target - p; + lua_assert(((delta + 0x8000) >> 16) == 0); + *--p = mi | MIPSF_S(rs) | MIPSF_T(rt) | ((uint32_t)delta & 0xffffu); + as->mcp = p; +} + +static void emit_jmp(ASMState *as, MCode *target) +{ + *--as->mcp = MIPSI_NOP; + emit_branch(as, MIPSI_B, RID_ZERO, RID_ZERO, (target)); +} + +static void emit_call(ASMState *as, void *target) +{ + MCode *p = as->mcp; + *--p = MIPSI_NOP; + if ((((uintptr_t)target ^ (uintptr_t)p) >> 28) == 0) + *--p = MIPSI_JAL | (((uintptr_t)target >>2) & 0x03ffffffu); + else /* Target out of range: need indirect call. */ + *--p = MIPSI_JALR | MIPSF_S(RID_CFUNCADDR); + as->mcp = p; + ra_allockreg(as, i32ptr(target), RID_CFUNCADDR); +} + +/* -- Emit generic operations --------------------------------------------- */ + +#define emit_move(as, dst, src) \ + emit_ds(as, MIPSI_MOVE, (dst), (src)) + +/* Generic move between two regs. */ +static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) +{ + if (dst < RID_MAX_GPR) + emit_move(as, dst, src); + else + emit_fg(as, irt_isnum(ir->t) ? MIPSI_MOV_D : MIPSI_MOV_S, dst, src); +} + +/* Generic load of register from stack slot. */ +static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ + if (r < RID_MAX_GPR) + emit_tsi(as, MIPSI_LW, r, RID_SP, ofs); + else + emit_tsi(as, irt_isnum(ir->t) ? MIPSI_LDC1 : MIPSI_LWC1, + (r & 31), RID_SP, ofs); +} + +/* Generic store of register to stack slot. */ +static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ + if (r < RID_MAX_GPR) + emit_tsi(as, MIPSI_SW, r, RID_SP, ofs); + else + emit_tsi(as, irt_isnum(ir->t) ? MIPSI_SDC1 : MIPSI_SWC1, + (r&31), RID_SP, ofs); +} + +/* Add offset to pointer. */ +static void emit_addptr(ASMState *as, Reg r, int32_t ofs) +{ + if (ofs) { + lua_assert(checki16(ofs)); + emit_tsi(as, MIPSI_ADDIU, r, r, ofs); + } +} + +#define emit_spsub(as, ofs) emit_addptr(as, RID_SP, -(ofs)) + + +``` + +`include/luajit-2.0.5/src/lj_emit_ppc.h`: + +```h +/* +** PPC instruction emitter. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Emit basic instructions --------------------------------------------- */ + +static void emit_tab(ASMState *as, PPCIns pi, Reg rt, Reg ra, Reg rb) +{ + *--as->mcp = pi | PPCF_T(rt) | PPCF_A(ra) | PPCF_B(rb); +} + +#define emit_asb(as, pi, ra, rs, rb) emit_tab(as, (pi), (rs), (ra), (rb)) +#define emit_as(as, pi, ra, rs) emit_tab(as, (pi), (rs), (ra), 0) +#define emit_ab(as, pi, ra, rb) emit_tab(as, (pi), 0, (ra), (rb)) + +static void emit_tai(ASMState *as, PPCIns pi, Reg rt, Reg ra, int32_t i) +{ + *--as->mcp = pi | PPCF_T(rt) | PPCF_A(ra) | (i & 0xffff); +} + +#define emit_ti(as, pi, rt, i) emit_tai(as, (pi), (rt), 0, (i)) +#define emit_ai(as, pi, ra, i) emit_tai(as, (pi), 0, (ra), (i)) +#define emit_asi(as, pi, ra, rs, i) emit_tai(as, (pi), (rs), (ra), (i)) + +#define emit_fab(as, pi, rf, ra, rb) \ + emit_tab(as, (pi), (rf)&31, (ra)&31, (rb)&31) +#define emit_fb(as, pi, rf, rb) emit_tab(as, (pi), (rf)&31, 0, (rb)&31) +#define emit_fac(as, pi, rf, ra, rc) \ + emit_tab(as, (pi) | PPCF_C((rc) & 31), (rf)&31, (ra)&31, 0) +#define emit_facb(as, pi, rf, ra, rc, rb) \ + emit_tab(as, (pi) | PPCF_C((rc) & 31), (rf)&31, (ra)&31, (rb)&31) +#define emit_fai(as, pi, rf, ra, i) emit_tai(as, (pi), (rf)&31, (ra), (i)) + +static void emit_rot(ASMState *as, PPCIns pi, Reg ra, Reg rs, + int32_t n, int32_t b, int32_t e) +{ + *--as->mcp = pi | PPCF_T(rs) | PPCF_A(ra) | PPCF_B(n) | + PPCF_MB(b) | PPCF_ME(e); +} + +static void emit_slwi(ASMState *as, Reg ra, Reg rs, int32_t n) +{ + lua_assert(n >= 0 && n < 32); + emit_rot(as, PPCI_RLWINM, ra, rs, n, 0, 31-n); +} + +static void emit_rotlwi(ASMState *as, Reg ra, Reg rs, int32_t n) +{ + lua_assert(n >= 0 && n < 32); + emit_rot(as, PPCI_RLWINM, ra, rs, n, 0, 31); +} + +/* -- Emit loads/stores --------------------------------------------------- */ + +/* Prefer rematerialization of BASE/L from global_State over spills. */ +#define emit_canremat(ref) ((ref) <= REF_BASE) + +/* Try to find a one step delta relative to another constant. */ +static int emit_kdelta1(ASMState *as, Reg t, int32_t i) +{ + RegSet work = ~as->freeset & RSET_GPR; + while (work) { + Reg r = rset_picktop(work); + IRRef ref = regcost_ref(as->cost[r]); + lua_assert(r != t); + if (ref < ASMREF_L) { + int32_t delta = i - (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i); + if (checki16(delta)) { + emit_tai(as, PPCI_ADDI, t, r, delta); + return 1; + } + } + rset_clear(work, r); + } + return 0; /* Failed. */ +} + +/* Load a 32 bit constant into a GPR. */ +static void emit_loadi(ASMState *as, Reg r, int32_t i) +{ + if (checki16(i)) { + emit_ti(as, PPCI_LI, r, i); + } else { + if ((i & 0xffff)) { + int32_t jgl = i32ptr(J2G(as->J)); + if ((uint32_t)(i-jgl) < 65536) { + emit_tai(as, PPCI_ADDI, r, RID_JGL, i-jgl-32768); + return; + } else if (emit_kdelta1(as, r, i)) { + return; + } + emit_asi(as, PPCI_ORI, r, r, i); + } + emit_ti(as, PPCI_LIS, r, (i >> 16)); + } +} + +#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr))) + +static Reg ra_allock(ASMState *as, int32_t k, RegSet allow); + +/* Get/set from constant pointer. */ +static void emit_lsptr(ASMState *as, PPCIns pi, Reg r, void *p, RegSet allow) +{ + int32_t jgl = i32ptr(J2G(as->J)); + int32_t i = i32ptr(p); + Reg base; + if ((uint32_t)(i-jgl) < 65536) { + i = i-jgl-32768; + base = RID_JGL; + } else { + base = ra_allock(as, i-(int16_t)i, allow); + } + emit_tai(as, pi, r, base, i); +} + +#define emit_loadn(as, r, tv) \ + emit_lsptr(as, PPCI_LFD, ((r) & 31), (void *)(tv), RSET_GPR) + +/* Get/set global_State fields. */ +static void emit_lsglptr(ASMState *as, PPCIns pi, Reg r, int32_t ofs) +{ + emit_tai(as, pi, r, RID_JGL, ofs-32768); +} + +#define emit_getgl(as, r, field) \ + emit_lsglptr(as, PPCI_LWZ, (r), (int32_t)offsetof(global_State, field)) +#define emit_setgl(as, r, field) \ + emit_lsglptr(as, PPCI_STW, (r), (int32_t)offsetof(global_State, field)) + +/* Trace number is determined from per-trace exit stubs. */ +#define emit_setvmstate(as, i) UNUSED(i) + +/* -- Emit control-flow instructions -------------------------------------- */ + +/* Label for internal jumps. */ +typedef MCode *MCLabel; + +/* Return label pointing to current PC. */ +#define emit_label(as) ((as)->mcp) + +static void emit_condbranch(ASMState *as, PPCIns pi, PPCCC cc, MCode *target) +{ + MCode *p = --as->mcp; + ptrdiff_t delta = (char *)target - (char *)p; + lua_assert(((delta + 0x8000) >> 16) == 0); + pi ^= (delta & 0x8000) * (PPCF_Y/0x8000); + *p = pi | PPCF_CC(cc) | ((uint32_t)delta & 0xffffu); +} + +static void emit_jmp(ASMState *as, MCode *target) +{ + MCode *p = --as->mcp; + ptrdiff_t delta = (char *)target - (char *)p; + *p = PPCI_B | (delta & 0x03fffffcu); +} + +static void emit_call(ASMState *as, void *target) +{ + MCode *p = --as->mcp; + ptrdiff_t delta = (char *)target - (char *)p; + if ((((delta>>2) + 0x00800000) >> 24) == 0) { + *p = PPCI_BL | (delta & 0x03fffffcu); + } else { /* Target out of range: need indirect call. Don't use arg reg. */ + RegSet allow = RSET_GPR & ~RSET_RANGE(RID_R0, REGARG_LASTGPR+1); + Reg r = ra_allock(as, i32ptr(target), allow); + *p = PPCI_BCTRL; + p[-1] = PPCI_MTCTR | PPCF_T(r); + as->mcp = p-1; + } +} + +/* -- Emit generic operations --------------------------------------------- */ + +#define emit_mr(as, dst, src) \ + emit_asb(as, PPCI_MR, (dst), (src), (src)) + +/* Generic move between two regs. */ +static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) +{ + UNUSED(ir); + if (dst < RID_MAX_GPR) + emit_mr(as, dst, src); + else + emit_fb(as, PPCI_FMR, dst, src); +} + +/* Generic load of register from stack slot. */ +static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ + if (r < RID_MAX_GPR) + emit_tai(as, PPCI_LWZ, r, RID_SP, ofs); + else + emit_fai(as, irt_isnum(ir->t) ? PPCI_LFD : PPCI_LFS, r, RID_SP, ofs); +} + +/* Generic store of register to stack slot. */ +static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ + if (r < RID_MAX_GPR) + emit_tai(as, PPCI_STW, r, RID_SP, ofs); + else + emit_fai(as, irt_isnum(ir->t) ? PPCI_STFD : PPCI_STFS, r, RID_SP, ofs); +} + +/* Emit a compare (for equality) with a constant operand. */ +static void emit_cmpi(ASMState *as, Reg r, int32_t k) +{ + if (checki16(k)) { + emit_ai(as, PPCI_CMPWI, r, k); + } else if (checku16(k)) { + emit_ai(as, PPCI_CMPLWI, r, k); + } else { + emit_ai(as, PPCI_CMPLWI, RID_TMP, k); + emit_asi(as, PPCI_XORIS, RID_TMP, r, (k >> 16)); + } +} + +/* Add offset to pointer. */ +static void emit_addptr(ASMState *as, Reg r, int32_t ofs) +{ + if (ofs) { + emit_tai(as, PPCI_ADDI, r, r, ofs); + if (!checki16(ofs)) + emit_tai(as, PPCI_ADDIS, r, r, (ofs + 32768) >> 16); + } +} + +static void emit_spsub(ASMState *as, int32_t ofs) +{ + if (ofs) { + emit_tai(as, PPCI_STWU, RID_TMP, RID_SP, -ofs); + emit_tai(as, PPCI_ADDI, RID_TMP, RID_SP, + CFRAME_SIZE + (as->parent ? as->parent->spadjust : 0)); + } +} + + +``` + +`include/luajit-2.0.5/src/lj_emit_x86.h`: + +```h +/* +** x86/x64 instruction emitter. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Emit basic instructions --------------------------------------------- */ + +#define MODRM(mode, r1, r2) ((MCode)((mode)+(((r1)&7)<<3)+((r2)&7))) + +#if LJ_64 +#define REXRB(p, rr, rb) \ + { MCode rex = 0x40 + (((rr)>>1)&4) + (((rb)>>3)&1); \ + if (rex != 0x40) *--(p) = rex; } +#define FORCE_REX 0x200 +#define REX_64 (FORCE_REX|0x080000) +#else +#define REXRB(p, rr, rb) ((void)0) +#define FORCE_REX 0 +#define REX_64 0 +#endif + +#define emit_i8(as, i) (*--as->mcp = (MCode)(i)) +#define emit_i32(as, i) (*(int32_t *)(as->mcp-4) = (i), as->mcp -= 4) +#define emit_u32(as, u) (*(uint32_t *)(as->mcp-4) = (u), as->mcp -= 4) + +#define emit_x87op(as, xo) \ + (*(uint16_t *)(as->mcp-2) = (uint16_t)(xo), as->mcp -= 2) + +/* op */ +static LJ_AINLINE MCode *emit_op(x86Op xo, Reg rr, Reg rb, Reg rx, + MCode *p, int delta) +{ + int n = (int8_t)xo; +#if defined(__GNUC__) + if (__builtin_constant_p(xo) && n == -2) + p[delta-2] = (MCode)(xo >> 24); + else if (__builtin_constant_p(xo) && n == -3) + *(uint16_t *)(p+delta-3) = (uint16_t)(xo >> 16); + else +#endif + *(uint32_t *)(p+delta-5) = (uint32_t)xo; + p += n + delta; +#if LJ_64 + { + uint32_t rex = 0x40 + ((rr>>1)&(4+(FORCE_REX>>1)))+((rx>>2)&2)+((rb>>3)&1); + if (rex != 0x40) { + rex |= (rr >> 16); + if (n == -4) { *p = (MCode)rex; rex = (MCode)(xo >> 8); } + else if ((xo & 0xffffff) == 0x6600fd) { *p = (MCode)rex; rex = 0x66; } + *--p = (MCode)rex; + } + } +#else + UNUSED(rr); UNUSED(rb); UNUSED(rx); +#endif + return p; +} + +/* op + modrm */ +#define emit_opm(xo, mode, rr, rb, p, delta) \ + (p[(delta)-1] = MODRM((mode), (rr), (rb)), \ + emit_op((xo), (rr), (rb), 0, (p), (delta))) + +/* op + modrm + sib */ +#define emit_opmx(xo, mode, scale, rr, rb, rx, p) \ + (p[-1] = MODRM((scale), (rx), (rb)), \ + p[-2] = MODRM((mode), (rr), RID_ESP), \ + emit_op((xo), (rr), (rb), (rx), (p), -1)) + +/* op r1, r2 */ +static void emit_rr(ASMState *as, x86Op xo, Reg r1, Reg r2) +{ + MCode *p = as->mcp; + as->mcp = emit_opm(xo, XM_REG, r1, r2, p, 0); +} + +#if LJ_64 && defined(LUA_USE_ASSERT) +/* [addr] is sign-extended in x64 and must be in lower 2G (not 4G). */ +static int32_t ptr2addr(const void *p) +{ + lua_assert((uintptr_t)p < (uintptr_t)0x80000000); + return i32ptr(p); +} +#else +#define ptr2addr(p) (i32ptr((p))) +#endif + +/* op r, [addr] */ +static void emit_rma(ASMState *as, x86Op xo, Reg rr, const void *addr) +{ + MCode *p = as->mcp; + *(int32_t *)(p-4) = ptr2addr(addr); +#if LJ_64 + p[-5] = MODRM(XM_SCALE1, RID_ESP, RID_EBP); + as->mcp = emit_opm(xo, XM_OFS0, rr, RID_ESP, p, -5); +#else + as->mcp = emit_opm(xo, XM_OFS0, rr, RID_EBP, p, -4); +#endif +} + +/* op r, [base+ofs] */ +static void emit_rmro(ASMState *as, x86Op xo, Reg rr, Reg rb, int32_t ofs) +{ + MCode *p = as->mcp; + x86Mode mode; + if (ra_hasreg(rb)) { + if (ofs == 0 && (rb&7) != RID_EBP) { + mode = XM_OFS0; + } else if (checki8(ofs)) { + *--p = (MCode)ofs; + mode = XM_OFS8; + } else { + p -= 4; + *(int32_t *)p = ofs; + mode = XM_OFS32; + } + if ((rb&7) == RID_ESP) + *--p = MODRM(XM_SCALE1, RID_ESP, RID_ESP); + } else { + *(int32_t *)(p-4) = ofs; +#if LJ_64 + p[-5] = MODRM(XM_SCALE1, RID_ESP, RID_EBP); + p -= 5; + rb = RID_ESP; +#else + p -= 4; + rb = RID_EBP; +#endif + mode = XM_OFS0; + } + as->mcp = emit_opm(xo, mode, rr, rb, p, 0); +} + +/* op r, [base+idx*scale+ofs] */ +static void emit_rmrxo(ASMState *as, x86Op xo, Reg rr, Reg rb, Reg rx, + x86Mode scale, int32_t ofs) +{ + MCode *p = as->mcp; + x86Mode mode; + if (ofs == 0 && (rb&7) != RID_EBP) { + mode = XM_OFS0; + } else if (checki8(ofs)) { + mode = XM_OFS8; + *--p = (MCode)ofs; + } else { + mode = XM_OFS32; + p -= 4; + *(int32_t *)p = ofs; + } + as->mcp = emit_opmx(xo, mode, scale, rr, rb, rx, p); +} + +/* op r, i */ +static void emit_gri(ASMState *as, x86Group xg, Reg rb, int32_t i) +{ + MCode *p = as->mcp; + x86Op xo; + if (checki8(i)) { + *--p = (MCode)i; + xo = XG_TOXOi8(xg); + } else { + p -= 4; + *(int32_t *)p = i; + xo = XG_TOXOi(xg); + } + as->mcp = emit_opm(xo, XM_REG, (Reg)(xg & 7) | (rb & REX_64), rb, p, 0); +} + +/* op [base+ofs], i */ +static void emit_gmroi(ASMState *as, x86Group xg, Reg rb, int32_t ofs, + int32_t i) +{ + x86Op xo; + if (checki8(i)) { + emit_i8(as, i); + xo = XG_TOXOi8(xg); + } else { + emit_i32(as, i); + xo = XG_TOXOi(xg); + } + emit_rmro(as, xo, (Reg)(xg & 7), rb, ofs); +} + +#define emit_shifti(as, xg, r, i) \ + (emit_i8(as, (i)), emit_rr(as, XO_SHIFTi, (Reg)(xg), (r))) + +/* op r, rm/mrm */ +static void emit_mrm(ASMState *as, x86Op xo, Reg rr, Reg rb) +{ + MCode *p = as->mcp; + x86Mode mode = XM_REG; + if (rb == RID_MRM) { + rb = as->mrm.base; + if (rb == RID_NONE) { + rb = RID_EBP; + mode = XM_OFS0; + p -= 4; + *(int32_t *)p = as->mrm.ofs; + if (as->mrm.idx != RID_NONE) + goto mrmidx; +#if LJ_64 + *--p = MODRM(XM_SCALE1, RID_ESP, RID_EBP); + rb = RID_ESP; +#endif + } else { + if (as->mrm.ofs == 0 && (rb&7) != RID_EBP) { + mode = XM_OFS0; + } else if (checki8(as->mrm.ofs)) { + *--p = (MCode)as->mrm.ofs; + mode = XM_OFS8; + } else { + p -= 4; + *(int32_t *)p = as->mrm.ofs; + mode = XM_OFS32; + } + if (as->mrm.idx != RID_NONE) { + mrmidx: + as->mcp = emit_opmx(xo, mode, as->mrm.scale, rr, rb, as->mrm.idx, p); + return; + } + if ((rb&7) == RID_ESP) + *--p = MODRM(XM_SCALE1, RID_ESP, RID_ESP); + } + } + as->mcp = emit_opm(xo, mode, rr, rb, p, 0); +} + +/* op rm/mrm, i */ +static void emit_gmrmi(ASMState *as, x86Group xg, Reg rb, int32_t i) +{ + x86Op xo; + if (checki8(i)) { + emit_i8(as, i); + xo = XG_TOXOi8(xg); + } else { + emit_i32(as, i); + xo = XG_TOXOi(xg); + } + emit_mrm(as, xo, (Reg)(xg & 7) | (rb & REX_64), (rb & ~REX_64)); +} + +/* -- Emit loads/stores --------------------------------------------------- */ + +/* Instruction selection for XMM moves. */ +#define XMM_MOVRR(as) ((as->flags & JIT_F_SPLIT_XMM) ? XO_MOVSD : XO_MOVAPS) +#define XMM_MOVRM(as) ((as->flags & JIT_F_SPLIT_XMM) ? XO_MOVLPD : XO_MOVSD) + +/* mov [base+ofs], i */ +static void emit_movmroi(ASMState *as, Reg base, int32_t ofs, int32_t i) +{ + emit_i32(as, i); + emit_rmro(as, XO_MOVmi, 0, base, ofs); +} + +/* mov [base+ofs], r */ +#define emit_movtomro(as, r, base, ofs) \ + emit_rmro(as, XO_MOVto, (r), (base), (ofs)) + +/* Get/set global_State fields. */ +#define emit_opgl(as, xo, r, field) \ + emit_rma(as, (xo), (r), (void *)&J2G(as->J)->field) +#define emit_getgl(as, r, field) emit_opgl(as, XO_MOV, (r), field) +#define emit_setgl(as, r, field) emit_opgl(as, XO_MOVto, (r), field) + +#define emit_setvmstate(as, i) \ + (emit_i32(as, i), emit_opgl(as, XO_MOVmi, 0, vmstate)) + +/* mov r, i / xor r, r */ +static void emit_loadi(ASMState *as, Reg r, int32_t i) +{ + /* XOR r,r is shorter, but modifies the flags. This is bad for HIOP. */ + if (i == 0 && !(LJ_32 && (IR(as->curins)->o == IR_HIOP || + (as->curins+1 < as->T->nins && + IR(as->curins+1)->o == IR_HIOP)))) { + emit_rr(as, XO_ARITH(XOg_XOR), r, r); + } else { + MCode *p = as->mcp; + *(int32_t *)(p-4) = i; + p[-5] = (MCode)(XI_MOVri+(r&7)); + p -= 5; + REXRB(p, 0, r); + as->mcp = p; + } +} + +/* mov r, addr */ +#define emit_loada(as, r, addr) \ + emit_loadi(as, (r), ptr2addr((addr))) + +#if LJ_64 +/* mov r, imm64 or shorter 32 bit extended load. */ +static void emit_loadu64(ASMState *as, Reg r, uint64_t u64) +{ + if (checku32(u64)) { /* 32 bit load clears upper 32 bits. */ + emit_loadi(as, r, (int32_t)u64); + } else if (checki32((int64_t)u64)) { /* Sign-extended 32 bit load. */ + MCode *p = as->mcp; + *(int32_t *)(p-4) = (int32_t)u64; + as->mcp = emit_opm(XO_MOVmi, XM_REG, REX_64, r, p, -4); + } else { /* Full-size 64 bit load. */ + MCode *p = as->mcp; + *(uint64_t *)(p-8) = u64; + p[-9] = (MCode)(XI_MOVri+(r&7)); + p[-10] = 0x48 + ((r>>3)&1); + p -= 10; + as->mcp = p; + } +} +#endif + +/* movsd r, [&tv->n] / xorps r, r */ +static void emit_loadn(ASMState *as, Reg r, cTValue *tv) +{ + if (tvispzero(tv)) /* Use xor only for +0. */ + emit_rr(as, XO_XORPS, r, r); + else + emit_rma(as, XMM_MOVRM(as), r, &tv->n); +} + +/* -- Emit control-flow instructions -------------------------------------- */ + +/* Label for short jumps. */ +typedef MCode *MCLabel; + +#if LJ_32 && LJ_HASFFI +/* jmp short target */ +static void emit_sjmp(ASMState *as, MCLabel target) +{ + MCode *p = as->mcp; + ptrdiff_t delta = target - p; + lua_assert(delta == (int8_t)delta); + p[-1] = (MCode)(int8_t)delta; + p[-2] = XI_JMPs; + as->mcp = p - 2; +} +#endif + +/* jcc short target */ +static void emit_sjcc(ASMState *as, int cc, MCLabel target) +{ + MCode *p = as->mcp; + ptrdiff_t delta = target - p; + lua_assert(delta == (int8_t)delta); + p[-1] = (MCode)(int8_t)delta; + p[-2] = (MCode)(XI_JCCs+(cc&15)); + as->mcp = p - 2; +} + +/* jcc short (pending target) */ +static MCLabel emit_sjcc_label(ASMState *as, int cc) +{ + MCode *p = as->mcp; + p[-1] = 0; + p[-2] = (MCode)(XI_JCCs+(cc&15)); + as->mcp = p - 2; + return p; +} + +/* Fixup jcc short target. */ +static void emit_sfixup(ASMState *as, MCLabel source) +{ + source[-1] = (MCode)(as->mcp-source); +} + +/* Return label pointing to current PC. */ +#define emit_label(as) ((as)->mcp) + +/* Compute relative 32 bit offset for jump and call instructions. */ +static LJ_AINLINE int32_t jmprel(MCode *p, MCode *target) +{ + ptrdiff_t delta = target - p; + lua_assert(delta == (int32_t)delta); + return (int32_t)delta; +} + +/* jcc target */ +static void emit_jcc(ASMState *as, int cc, MCode *target) +{ + MCode *p = as->mcp; + *(int32_t *)(p-4) = jmprel(p, target); + p[-5] = (MCode)(XI_JCCn+(cc&15)); + p[-6] = 0x0f; + as->mcp = p - 6; +} + +/* jmp target */ +static void emit_jmp(ASMState *as, MCode *target) +{ + MCode *p = as->mcp; + *(int32_t *)(p-4) = jmprel(p, target); + p[-5] = XI_JMP; + as->mcp = p - 5; +} + +/* call target */ +static void emit_call_(ASMState *as, MCode *target) +{ + MCode *p = as->mcp; +#if LJ_64 + if (target-p != (int32_t)(target-p)) { + /* Assumes RID_RET is never an argument to calls and always clobbered. */ + emit_rr(as, XO_GROUP5, XOg_CALL, RID_RET); + emit_loadu64(as, RID_RET, (uint64_t)target); + return; + } +#endif + *(int32_t *)(p-4) = jmprel(p, target); + p[-5] = XI_CALL; + as->mcp = p - 5; +} + +#define emit_call(as, f) emit_call_(as, (MCode *)(void *)(f)) + +/* -- Emit generic operations --------------------------------------------- */ + +/* Use 64 bit operations to handle 64 bit IR types. */ +#if LJ_64 +#define REX_64IR(ir, r) ((r) + (irt_is64((ir)->t) ? REX_64 : 0)) +#else +#define REX_64IR(ir, r) (r) +#endif + +/* Generic move between two regs. */ +static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) +{ + UNUSED(ir); + if (dst < RID_MAX_GPR) + emit_rr(as, XO_MOV, REX_64IR(ir, dst), src); + else + emit_rr(as, XMM_MOVRR(as), dst, src); +} + +/* Generic load of register from stack slot. */ +static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ + if (r < RID_MAX_GPR) + emit_rmro(as, XO_MOV, REX_64IR(ir, r), RID_ESP, ofs); + else + emit_rmro(as, irt_isnum(ir->t) ? XMM_MOVRM(as) : XO_MOVSS, r, RID_ESP, ofs); +} + +/* Generic store of register to stack slot. */ +static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ + if (r < RID_MAX_GPR) + emit_rmro(as, XO_MOVto, REX_64IR(ir, r), RID_ESP, ofs); + else + emit_rmro(as, irt_isnum(ir->t) ? XO_MOVSDto : XO_MOVSSto, r, RID_ESP, ofs); +} + +/* Add offset to pointer. */ +static void emit_addptr(ASMState *as, Reg r, int32_t ofs) +{ + if (ofs) { + if ((as->flags & JIT_F_LEA_AGU)) + emit_rmro(as, XO_LEA, r, r, ofs); + else + emit_gri(as, XG_ARITHi(XOg_ADD), r, ofs); + } +} + +#define emit_spsub(as, ofs) emit_addptr(as, RID_ESP|REX_64, -(ofs)) + +/* Prefer rematerialization of BASE/L from global_State over spills. */ +#define emit_canremat(ref) ((ref) <= REF_BASE) + + +``` + +`include/luajit-2.0.5/src/lj_err.c`: + +```c +/* +** Error handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_err_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_str.h" +#include "lj_func.h" +#include "lj_state.h" +#include "lj_frame.h" +#include "lj_ff.h" +#include "lj_trace.h" +#include "lj_vm.h" + +/* +** LuaJIT can either use internal or external frame unwinding: +** +** - Internal frame unwinding (INT) is free-standing and doesn't require +** any OS or library support. +** +** - External frame unwinding (EXT) uses the system-provided unwind handler. +** +** Pros and Cons: +** +** - EXT requires unwind tables for *all* functions on the C stack between +** the pcall/catch and the error/throw. This is the default on x64, +** but needs to be manually enabled on x86/PPC for non-C++ code. +** +** - INT is faster when actually throwing errors (but this happens rarely). +** Setting up error handlers is zero-cost in any case. +** +** - EXT provides full interoperability with C++ exceptions. You can throw +** Lua errors or C++ exceptions through a mix of Lua frames and C++ frames. +** C++ destructors are called as needed. C++ exceptions caught by pcall +** are converted to the string "C++ exception". Lua errors can be caught +** with catch (...) in C++. +** +** - INT has only limited support for automatically catching C++ exceptions +** on POSIX systems using DWARF2 stack unwinding. Other systems may use +** the wrapper function feature. Lua errors thrown through C++ frames +** cannot be caught by C++ code and C++ destructors are not run. +** +** EXT is the default on x64 systems, INT is the default on all other systems. +** +** EXT can be manually enabled on POSIX systems using GCC and DWARF2 stack +** unwinding with -DLUAJIT_UNWIND_EXTERNAL. *All* C code must be compiled +** with -funwind-tables (or -fexceptions). This includes LuaJIT itself (set +** TARGET_CFLAGS), all of your C/Lua binding code, all loadable C modules +** and all C libraries that have callbacks which may be used to call back +** into Lua. C++ code must *not* be compiled with -fno-exceptions. +** +** EXT cannot be enabled on WIN32 since system exceptions use code-driven SEH. +** EXT is mandatory on WIN64 since the calling convention has an abundance +** of callee-saved registers (rbx, rbp, rsi, rdi, r12-r15, xmm6-xmm15). +** The POSIX/x64 interpreter only saves r12/r13 for INT (e.g. PS4). +*/ + +#if defined(__GNUC__) && (LJ_TARGET_X64 || defined(LUAJIT_UNWIND_EXTERNAL)) && !LJ_NO_UNWIND +#define LJ_UNWIND_EXT 1 +#elif LJ_TARGET_X64 && LJ_TARGET_WINDOWS +#define LJ_UNWIND_EXT 1 +#endif + +/* -- Error messages ------------------------------------------------------ */ + +/* Error message strings. */ +LJ_DATADEF const char *lj_err_allmsg = +#define ERRDEF(name, msg) msg "\0" +#include "lj_errmsg.h" +; + +/* -- Internal frame unwinding -------------------------------------------- */ + +/* Unwind Lua stack and move error message to new top. */ +LJ_NOINLINE static void unwindstack(lua_State *L, TValue *top) +{ + lj_func_closeuv(L, top); + if (top < L->top-1) { + copyTV(L, top, L->top-1); + L->top = top+1; + } + lj_state_relimitstack(L); +} + +/* Unwind until stop frame. Optionally cleanup frames. */ +static void *err_unwind(lua_State *L, void *stopcf, int errcode) +{ + TValue *frame = L->base-1; + void *cf = L->cframe; + while (cf) { + int32_t nres = cframe_nres(cframe_raw(cf)); + if (nres < 0) { /* C frame without Lua frame? */ + TValue *top = restorestack(L, -nres); + if (frame < top) { /* Frame reached? */ + if (errcode) { + L->cframe = cframe_prev(cf); + L->base = frame+1; + unwindstack(L, top); + } + return cf; + } + } + if (frame <= tvref(L->stack)) + break; + switch (frame_typep(frame)) { + case FRAME_LUA: /* Lua frame. */ + case FRAME_LUAP: + frame = frame_prevl(frame); + break; + case FRAME_C: /* C frame. */ +#if LJ_HASFFI + unwind_c: +#endif +#if LJ_UNWIND_EXT + if (errcode) { + L->cframe = cframe_prev(cf); + L->base = frame_prevd(frame) + 1; + unwindstack(L, frame); + } else if (cf != stopcf) { + cf = cframe_prev(cf); + frame = frame_prevd(frame); + break; + } + return NULL; /* Continue unwinding. */ +#else + UNUSED(stopcf); + cf = cframe_prev(cf); + frame = frame_prevd(frame); + break; +#endif + case FRAME_CP: /* Protected C frame. */ + if (cframe_canyield(cf)) { /* Resume? */ + if (errcode) { + hook_leave(G(L)); /* Assumes nobody uses coroutines inside hooks. */ + L->cframe = NULL; + L->status = (uint8_t)errcode; + } + return cf; + } + if (errcode) { + L->cframe = cframe_prev(cf); + L->base = frame_prevd(frame) + 1; + unwindstack(L, frame); + } + return cf; + case FRAME_CONT: /* Continuation frame. */ +#if LJ_HASFFI + if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) + goto unwind_c; +#endif + case FRAME_VARG: /* Vararg frame. */ + frame = frame_prevd(frame); + break; + case FRAME_PCALL: /* FF pcall() frame. */ + case FRAME_PCALLH: /* FF pcall() frame inside hook. */ + if (errcode) { + if (errcode == LUA_YIELD) { + frame = frame_prevd(frame); + break; + } + if (frame_typep(frame) == FRAME_PCALL) + hook_leave(G(L)); + L->cframe = cf; + L->base = frame_prevd(frame) + 1; + unwindstack(L, L->base); + } + return (void *)((intptr_t)cf | CFRAME_UNWIND_FF); + } + } + /* No C frame. */ + if (errcode) { + L->cframe = NULL; + L->base = tvref(L->stack)+1; + unwindstack(L, L->base); + if (G(L)->panic) + G(L)->panic(L); + exit(EXIT_FAILURE); + } + return L; /* Anything non-NULL will do. */ +} + +/* -- External frame unwinding -------------------------------------------- */ + +#if defined(__GNUC__) && !LJ_NO_UNWIND && !LJ_ABI_WIN + +/* +** We have to use our own definitions instead of the mandatory (!) unwind.h, +** since various OS, distros and compilers mess up the header installation. +*/ + +typedef struct _Unwind_Exception +{ + uint64_t exclass; + void (*excleanup)(int, struct _Unwind_Exception *); + uintptr_t p1, p2; +} __attribute__((__aligned__)) _Unwind_Exception; + +typedef struct _Unwind_Context _Unwind_Context; + +#define _URC_OK 0 +#define _URC_FATAL_PHASE1_ERROR 3 +#define _URC_HANDLER_FOUND 6 +#define _URC_INSTALL_CONTEXT 7 +#define _URC_CONTINUE_UNWIND 8 +#define _URC_FAILURE 9 + +#if !LJ_TARGET_ARM + +extern uintptr_t _Unwind_GetCFA(_Unwind_Context *); +extern void _Unwind_SetGR(_Unwind_Context *, int, uintptr_t); +extern void _Unwind_SetIP(_Unwind_Context *, uintptr_t); +extern void _Unwind_DeleteException(_Unwind_Exception *); +extern int _Unwind_RaiseException(_Unwind_Exception *); + +#define _UA_SEARCH_PHASE 1 +#define _UA_CLEANUP_PHASE 2 +#define _UA_HANDLER_FRAME 4 +#define _UA_FORCE_UNWIND 8 + +#define LJ_UEXCLASS 0x4c55414a49543200ULL /* LUAJIT2\0 */ +#define LJ_UEXCLASS_MAKE(c) (LJ_UEXCLASS | (uint64_t)(c)) +#define LJ_UEXCLASS_CHECK(cl) (((cl) ^ LJ_UEXCLASS) <= 0xff) +#define LJ_UEXCLASS_ERRCODE(cl) ((int)((cl) & 0xff)) + +/* DWARF2 personality handler referenced from interpreter .eh_frame. */ +LJ_FUNCA int lj_err_unwind_dwarf(int version, int actions, + uint64_t uexclass, _Unwind_Exception *uex, _Unwind_Context *ctx) +{ + void *cf; + lua_State *L; + if (version != 1) + return _URC_FATAL_PHASE1_ERROR; + UNUSED(uexclass); + cf = (void *)_Unwind_GetCFA(ctx); + L = cframe_L(cf); + if ((actions & _UA_SEARCH_PHASE)) { +#if LJ_UNWIND_EXT + if (err_unwind(L, cf, 0) == NULL) + return _URC_CONTINUE_UNWIND; +#endif + if (!LJ_UEXCLASS_CHECK(uexclass)) { + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); + } + return _URC_HANDLER_FOUND; + } + if ((actions & _UA_CLEANUP_PHASE)) { + int errcode; + if (LJ_UEXCLASS_CHECK(uexclass)) { + errcode = LJ_UEXCLASS_ERRCODE(uexclass); + } else { + if ((actions & _UA_HANDLER_FRAME)) + _Unwind_DeleteException(uex); + errcode = LUA_ERRRUN; + } +#if LJ_UNWIND_EXT + cf = err_unwind(L, cf, errcode); + if ((actions & _UA_FORCE_UNWIND)) { + return _URC_CONTINUE_UNWIND; + } else if (cf) { + _Unwind_SetGR(ctx, LJ_TARGET_EHRETREG, errcode); + _Unwind_SetIP(ctx, (uintptr_t)(cframe_unwind_ff(cf) ? + lj_vm_unwind_ff_eh : + lj_vm_unwind_c_eh)); + return _URC_INSTALL_CONTEXT; + } +#if LJ_TARGET_X86ORX64 + else if ((actions & _UA_HANDLER_FRAME)) { + /* Workaround for ancient libgcc bug. Still present in RHEL 5.5. :-/ + ** Real fix: http://gcc.gnu.org/viewcvs/trunk/gcc/unwind-dw2.c?r1=121165&r2=124837&pathrev=153877&diff_format=h + */ + _Unwind_SetGR(ctx, LJ_TARGET_EHRETREG, errcode); + _Unwind_SetIP(ctx, (uintptr_t)lj_vm_unwind_rethrow); + return _URC_INSTALL_CONTEXT; + } +#endif +#else + /* This is not the proper way to escape from the unwinder. We get away with + ** it on non-x64 because the interpreter restores all callee-saved regs. + */ + lj_err_throw(L, errcode); +#endif + } + return _URC_CONTINUE_UNWIND; +} + +#if LJ_UNWIND_EXT +#if LJ_TARGET_OSX || defined(__OpenBSD__) +/* Sorry, no thread safety for OSX. Complain to Apple, not me. */ +static _Unwind_Exception static_uex; +#else +static __thread _Unwind_Exception static_uex; +#endif + +/* Raise DWARF2 exception. */ +static void err_raise_ext(int errcode) +{ + static_uex.exclass = LJ_UEXCLASS_MAKE(errcode); + static_uex.excleanup = NULL; + _Unwind_RaiseException(&static_uex); +} +#endif + +#else + +extern void _Unwind_DeleteException(void *); +extern int __gnu_unwind_frame (void *, _Unwind_Context *); +extern int _Unwind_VRS_Set(_Unwind_Context *, int, uint32_t, int, void *); +extern int _Unwind_VRS_Get(_Unwind_Context *, int, uint32_t, int, void *); + +static inline uint32_t _Unwind_GetGR(_Unwind_Context *ctx, int r) +{ + uint32_t v; + _Unwind_VRS_Get(ctx, 0, r, 0, &v); + return v; +} + +static inline void _Unwind_SetGR(_Unwind_Context *ctx, int r, uint32_t v) +{ + _Unwind_VRS_Set(ctx, 0, r, 0, &v); +} + +#define _US_VIRTUAL_UNWIND_FRAME 0 +#define _US_UNWIND_FRAME_STARTING 1 +#define _US_ACTION_MASK 3 +#define _US_FORCE_UNWIND 8 + +/* ARM unwinder personality handler referenced from interpreter .ARM.extab. */ +LJ_FUNCA int lj_err_unwind_arm(int state, void *ucb, _Unwind_Context *ctx) +{ + void *cf = (void *)_Unwind_GetGR(ctx, 13); + lua_State *L = cframe_L(cf); + if ((state & _US_ACTION_MASK) == _US_VIRTUAL_UNWIND_FRAME) { + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); + return _URC_HANDLER_FOUND; + } + if ((state&(_US_ACTION_MASK|_US_FORCE_UNWIND)) == _US_UNWIND_FRAME_STARTING) { + _Unwind_DeleteException(ucb); + _Unwind_SetGR(ctx, 15, (uint32_t)(void *)lj_err_throw); + _Unwind_SetGR(ctx, 0, (uint32_t)L); + _Unwind_SetGR(ctx, 1, (uint32_t)LUA_ERRRUN); + return _URC_INSTALL_CONTEXT; + } + if (__gnu_unwind_frame(ucb, ctx) != _URC_OK) + return _URC_FAILURE; + return _URC_CONTINUE_UNWIND; +} + +#endif + +#elif LJ_TARGET_X64 && LJ_ABI_WIN + +/* +** Someone in Redmond owes me several days of my life. A lot of this is +** undocumented or just plain wrong on MSDN. Some of it can be gathered +** from 3rd party docs or must be found by trial-and-error. They really +** don't want you to write your own language-specific exception handler +** or to interact gracefully with MSVC. :-( +** +** Apparently MSVC doesn't call C++ destructors for foreign exceptions +** unless you compile your C++ code with /EHa. Unfortunately this means +** catch (...) also catches things like access violations. The use of +** _set_se_translator doesn't really help, because it requires /EHa, too. +*/ + +#define WIN32_LEAN_AND_MEAN +#include + +/* Taken from: http://www.nynaeve.net/?p=99 */ +typedef struct UndocumentedDispatcherContext { + ULONG64 ControlPc; + ULONG64 ImageBase; + PRUNTIME_FUNCTION FunctionEntry; + ULONG64 EstablisherFrame; + ULONG64 TargetIp; + PCONTEXT ContextRecord; + void (*LanguageHandler)(void); + PVOID HandlerData; + PUNWIND_HISTORY_TABLE HistoryTable; + ULONG ScopeIndex; + ULONG Fill0; +} UndocumentedDispatcherContext; + +/* Another wild guess. */ +extern void __DestructExceptionObject(EXCEPTION_RECORD *rec, int nothrow); + +#ifdef MINGW_SDK_INIT +/* Workaround for broken MinGW64 declaration. */ +VOID RtlUnwindEx_FIXED(PVOID,PVOID,PVOID,PVOID,PVOID,PVOID) asm("RtlUnwindEx"); +#define RtlUnwindEx RtlUnwindEx_FIXED +#endif + +#define LJ_MSVC_EXCODE ((DWORD)0xe06d7363) +#define LJ_GCC_EXCODE ((DWORD)0x20474343) + +#define LJ_EXCODE ((DWORD)0xe24c4a00) +#define LJ_EXCODE_MAKE(c) (LJ_EXCODE | (DWORD)(c)) +#define LJ_EXCODE_CHECK(cl) (((cl) ^ LJ_EXCODE) <= 0xff) +#define LJ_EXCODE_ERRCODE(cl) ((int)((cl) & 0xff)) + +/* Win64 exception handler for interpreter frame. */ +LJ_FUNCA EXCEPTION_DISPOSITION lj_err_unwind_win64(EXCEPTION_RECORD *rec, + void *cf, CONTEXT *ctx, UndocumentedDispatcherContext *dispatch) +{ + lua_State *L = cframe_L(cf); + int errcode = LJ_EXCODE_CHECK(rec->ExceptionCode) ? + LJ_EXCODE_ERRCODE(rec->ExceptionCode) : LUA_ERRRUN; + if ((rec->ExceptionFlags & 6)) { /* EH_UNWINDING|EH_EXIT_UNWIND */ + /* Unwind internal frames. */ + err_unwind(L, cf, errcode); + } else { + void *cf2 = err_unwind(L, cf, 0); + if (cf2) { /* We catch it, so start unwinding the upper frames. */ + if (rec->ExceptionCode == LJ_MSVC_EXCODE || + rec->ExceptionCode == LJ_GCC_EXCODE) { +#if LJ_TARGET_WINDOWS + __DestructExceptionObject(rec, 1); +#endif + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); + } else if (!LJ_EXCODE_CHECK(rec->ExceptionCode)) { + /* Don't catch access violations etc. */ + return ExceptionContinueSearch; + } + /* Unwind the stack and call all handlers for all lower C frames + ** (including ourselves) again with EH_UNWINDING set. Then set + ** rsp = cf, rax = errcode and jump to the specified target. + */ + RtlUnwindEx(cf, (void *)((cframe_unwind_ff(cf2) && errcode != LUA_YIELD) ? + lj_vm_unwind_ff_eh : + lj_vm_unwind_c_eh), + rec, (void *)(uintptr_t)errcode, ctx, dispatch->HistoryTable); + /* RtlUnwindEx should never return. */ + } + } + return ExceptionContinueSearch; +} + +/* Raise Windows exception. */ +static void err_raise_ext(int errcode) +{ + RaiseException(LJ_EXCODE_MAKE(errcode), 1 /* EH_NONCONTINUABLE */, 0, NULL); +} + +#endif + +/* -- Error handling ------------------------------------------------------ */ + +/* Throw error. Find catch frame, unwind stack and continue. */ +LJ_NOINLINE void LJ_FASTCALL lj_err_throw(lua_State *L, int errcode) +{ + global_State *g = G(L); + lj_trace_abort(g); + setgcrefnull(g->jit_L); + L->status = 0; +#if LJ_UNWIND_EXT + err_raise_ext(errcode); + /* + ** A return from this function signals a corrupt C stack that cannot be + ** unwound. We have no choice but to call the panic function and exit. + ** + ** Usually this is caused by a C function without unwind information. + ** This should never happen on x64, but may happen if you've manually + ** enabled LUAJIT_UNWIND_EXTERNAL and forgot to recompile *every* + ** non-C++ file with -funwind-tables. + */ + if (G(L)->panic) + G(L)->panic(L); +#else + { + void *cf = err_unwind(L, NULL, errcode); + if (cframe_unwind_ff(cf)) + lj_vm_unwind_ff(cframe_raw(cf)); + else + lj_vm_unwind_c(cframe_raw(cf), errcode); + } +#endif + exit(EXIT_FAILURE); +} + +/* Return string object for error message. */ +LJ_NOINLINE GCstr *lj_err_str(lua_State *L, ErrMsg em) +{ + return lj_str_newz(L, err2msg(em)); +} + +/* Out-of-memory error. */ +LJ_NOINLINE void lj_err_mem(lua_State *L) +{ + if (L->status == LUA_ERRERR+1) /* Don't touch the stack during lua_open. */ + lj_vm_unwind_c(L->cframe, LUA_ERRMEM); + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRMEM)); + lj_err_throw(L, LUA_ERRMEM); +} + +/* Find error function for runtime errors. Requires an extra stack traversal. */ +static ptrdiff_t finderrfunc(lua_State *L) +{ + cTValue *frame = L->base-1, *bot = tvref(L->stack); + void *cf = L->cframe; + while (frame > bot && cf) { + while (cframe_nres(cframe_raw(cf)) < 0) { /* cframe without frame? */ + if (frame >= restorestack(L, -cframe_nres(cf))) + break; + if (cframe_errfunc(cf) >= 0) /* Error handler not inherited (-1)? */ + return cframe_errfunc(cf); + cf = cframe_prev(cf); /* Else unwind cframe and continue searching. */ + if (cf == NULL) + return 0; + } + switch (frame_typep(frame)) { + case FRAME_LUA: + case FRAME_LUAP: + frame = frame_prevl(frame); + break; + case FRAME_C: + cf = cframe_prev(cf); + /* fallthrough */ + case FRAME_VARG: + frame = frame_prevd(frame); + break; + case FRAME_CONT: +#if LJ_HASFFI + if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) + cf = cframe_prev(cf); +#endif + frame = frame_prevd(frame); + break; + case FRAME_CP: + if (cframe_canyield(cf)) return 0; + if (cframe_errfunc(cf) >= 0) + return cframe_errfunc(cf); + frame = frame_prevd(frame); + break; + case FRAME_PCALL: + case FRAME_PCALLH: + if (frame_ftsz(frame) >= (ptrdiff_t)(2*sizeof(TValue))) /* xpcall? */ + return savestack(L, frame-1); /* Point to xpcall's errorfunc. */ + return 0; + default: + lua_assert(0); + return 0; + } + } + return 0; +} + +/* Runtime error. */ +LJ_NOINLINE void lj_err_run(lua_State *L) +{ + ptrdiff_t ef = finderrfunc(L); + if (ef) { + TValue *errfunc = restorestack(L, ef); + TValue *top = L->top; + lj_trace_abort(G(L)); + if (!tvisfunc(errfunc) || L->status == LUA_ERRERR) { + setstrV(L, top-1, lj_err_str(L, LJ_ERR_ERRERR)); + lj_err_throw(L, LUA_ERRERR); + } + L->status = LUA_ERRERR; + copyTV(L, top, top-1); + copyTV(L, top-1, errfunc); + L->top = top+1; + lj_vm_call(L, top, 1+1); /* Stack: |errfunc|msg| -> |msg| */ + } + lj_err_throw(L, LUA_ERRRUN); +} + +/* Formatted runtime error message. */ +LJ_NORET LJ_NOINLINE static void err_msgv(lua_State *L, ErrMsg em, ...) +{ + const char *msg; + va_list argp; + va_start(argp, em); + if (curr_funcisL(L)) L->top = curr_topL(L); + msg = lj_str_pushvf(L, err2msg(em), argp); + va_end(argp); + lj_debug_addloc(L, msg, L->base-1, NULL); + lj_err_run(L); +} + +/* Non-vararg variant for better calling conventions. */ +LJ_NOINLINE void lj_err_msg(lua_State *L, ErrMsg em) +{ + err_msgv(L, em); +} + +/* Lexer error. */ +LJ_NOINLINE void lj_err_lex(lua_State *L, GCstr *src, const char *tok, + BCLine line, ErrMsg em, va_list argp) +{ + char buff[LUA_IDSIZE]; + const char *msg; + lj_debug_shortname(buff, src); + msg = lj_str_pushvf(L, err2msg(em), argp); + msg = lj_str_pushf(L, "%s:%d: %s", buff, line, msg); + if (tok) + lj_str_pushf(L, err2msg(LJ_ERR_XNEAR), msg, tok); + lj_err_throw(L, LUA_ERRSYNTAX); +} + +/* Typecheck error for operands. */ +LJ_NOINLINE void lj_err_optype(lua_State *L, cTValue *o, ErrMsg opm) +{ + const char *tname = lj_typename(o); + const char *opname = err2msg(opm); + if (curr_funcisL(L)) { + GCproto *pt = curr_proto(L); + const BCIns *pc = cframe_Lpc(L) - 1; + const char *oname = NULL; + const char *kind = lj_debug_slotname(pt, pc, (BCReg)(o-L->base), &oname); + if (kind) + err_msgv(L, LJ_ERR_BADOPRT, opname, kind, oname, tname); + } + err_msgv(L, LJ_ERR_BADOPRV, opname, tname); +} + +/* Typecheck error for ordered comparisons. */ +LJ_NOINLINE void lj_err_comp(lua_State *L, cTValue *o1, cTValue *o2) +{ + const char *t1 = lj_typename(o1); + const char *t2 = lj_typename(o2); + err_msgv(L, t1 == t2 ? LJ_ERR_BADCMPV : LJ_ERR_BADCMPT, t1, t2); + /* This assumes the two "boolean" entries are commoned by the C compiler. */ +} + +/* Typecheck error for __call. */ +LJ_NOINLINE void lj_err_optype_call(lua_State *L, TValue *o) +{ + /* Gross hack if lua_[p]call or pcall/xpcall fail for a non-callable object: + ** L->base still points to the caller. So add a dummy frame with L instead + ** of a function. See lua_getstack(). + */ + const BCIns *pc = cframe_Lpc(L); + if (((ptrdiff_t)pc & FRAME_TYPE) != FRAME_LUA) { + const char *tname = lj_typename(o); + setframe_pc(o, pc); + setframe_gc(o, obj2gco(L)); + L->top = L->base = o+1; + err_msgv(L, LJ_ERR_BADCALL, tname); + } + lj_err_optype(L, o, LJ_ERR_OPCALL); +} + +/* Error in context of caller. */ +LJ_NOINLINE void lj_err_callermsg(lua_State *L, const char *msg) +{ + TValue *frame = L->base-1; + TValue *pframe = NULL; + if (frame_islua(frame)) { + pframe = frame_prevl(frame); + } else if (frame_iscont(frame)) { +#if LJ_HASFFI + if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) { + pframe = frame; + frame = NULL; + } else +#endif + { + pframe = frame_prevd(frame); +#if LJ_HASFFI + /* Remove frame for FFI metamethods. */ + if (frame_func(frame)->c.ffid >= FF_ffi_meta___index && + frame_func(frame)->c.ffid <= FF_ffi_meta___tostring) { + L->base = pframe+1; + L->top = frame; + setcframe_pc(cframe_raw(L->cframe), frame_contpc(frame)); + } +#endif + } + } + lj_debug_addloc(L, msg, pframe, frame); + lj_err_run(L); +} + +/* Formatted error in context of caller. */ +LJ_NOINLINE void lj_err_callerv(lua_State *L, ErrMsg em, ...) +{ + const char *msg; + va_list argp; + va_start(argp, em); + msg = lj_str_pushvf(L, err2msg(em), argp); + va_end(argp); + lj_err_callermsg(L, msg); +} + +/* Error in context of caller. */ +LJ_NOINLINE void lj_err_caller(lua_State *L, ErrMsg em) +{ + lj_err_callermsg(L, err2msg(em)); +} + +/* Argument error message. */ +LJ_NORET LJ_NOINLINE static void err_argmsg(lua_State *L, int narg, + const char *msg) +{ + const char *fname = "?"; + const char *ftype = lj_debug_funcname(L, L->base - 1, &fname); + if (narg < 0 && narg > LUA_REGISTRYINDEX) + narg = (int)(L->top - L->base) + narg + 1; + if (ftype && ftype[3] == 'h' && --narg == 0) /* Check for "method". */ + msg = lj_str_pushf(L, err2msg(LJ_ERR_BADSELF), fname, msg); + else + msg = lj_str_pushf(L, err2msg(LJ_ERR_BADARG), narg, fname, msg); + lj_err_callermsg(L, msg); +} + +/* Formatted argument error. */ +LJ_NOINLINE void lj_err_argv(lua_State *L, int narg, ErrMsg em, ...) +{ + const char *msg; + va_list argp; + va_start(argp, em); + msg = lj_str_pushvf(L, err2msg(em), argp); + va_end(argp); + err_argmsg(L, narg, msg); +} + +/* Argument error. */ +LJ_NOINLINE void lj_err_arg(lua_State *L, int narg, ErrMsg em) +{ + err_argmsg(L, narg, err2msg(em)); +} + +/* Typecheck error for arguments. */ +LJ_NOINLINE void lj_err_argtype(lua_State *L, int narg, const char *xname) +{ + const char *tname, *msg; + if (narg <= LUA_REGISTRYINDEX) { + if (narg >= LUA_GLOBALSINDEX) { + tname = lj_obj_itypename[~LJ_TTAB]; + } else { + GCfunc *fn = curr_func(L); + int idx = LUA_GLOBALSINDEX - narg; + if (idx <= fn->c.nupvalues) + tname = lj_typename(&fn->c.upvalue[idx-1]); + else + tname = lj_obj_typename[0]; + } + } else { + TValue *o = narg < 0 ? L->top + narg : L->base + narg-1; + tname = o < L->top ? lj_typename(o) : lj_obj_typename[0]; + } + msg = lj_str_pushf(L, err2msg(LJ_ERR_BADTYPE), xname, tname); + err_argmsg(L, narg, msg); +} + +/* Typecheck error for arguments. */ +LJ_NOINLINE void lj_err_argt(lua_State *L, int narg, int tt) +{ + lj_err_argtype(L, narg, lj_obj_typename[tt+1]); +} + +/* -- Public error handling API ------------------------------------------- */ + +LUA_API lua_CFunction lua_atpanic(lua_State *L, lua_CFunction panicf) +{ + lua_CFunction old = G(L)->panic; + G(L)->panic = panicf; + return old; +} + +/* Forwarders for the public API (C calling convention and no LJ_NORET). */ +LUA_API int lua_error(lua_State *L) +{ + lj_err_run(L); + return 0; /* unreachable */ +} + +LUALIB_API int luaL_argerror(lua_State *L, int narg, const char *msg) +{ + err_argmsg(L, narg, msg); + return 0; /* unreachable */ +} + +LUALIB_API int luaL_typerror(lua_State *L, int narg, const char *xname) +{ + lj_err_argtype(L, narg, xname); + return 0; /* unreachable */ +} + +LUALIB_API void luaL_where(lua_State *L, int level) +{ + int size; + cTValue *frame = lj_debug_frame(L, level, &size); + lj_debug_addloc(L, "", frame, size ? frame+size : NULL); +} + +LUALIB_API int luaL_error(lua_State *L, const char *fmt, ...) +{ + const char *msg; + va_list argp; + va_start(argp, fmt); + msg = lj_str_pushvf(L, fmt, argp); + va_end(argp); + lj_err_callermsg(L, msg); + return 0; /* unreachable */ +} + + +``` + +`include/luajit-2.0.5/src/lj_err.h`: + +```h +/* +** Error handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_ERR_H +#define _LJ_ERR_H + +#include + +#include "lj_obj.h" + +typedef enum { +#define ERRDEF(name, msg) \ + LJ_ERR_##name, LJ_ERR_##name##_ = LJ_ERR_##name + sizeof(msg)-1, +#include "lj_errmsg.h" + LJ_ERR__MAX +} ErrMsg; + +LJ_DATA const char *lj_err_allmsg; +#define err2msg(em) (lj_err_allmsg+(int)(em)) + +LJ_FUNC GCstr *lj_err_str(lua_State *L, ErrMsg em); +LJ_FUNCA_NORET void LJ_FASTCALL lj_err_throw(lua_State *L, int errcode); +LJ_FUNC_NORET void lj_err_mem(lua_State *L); +LJ_FUNC_NORET void lj_err_run(lua_State *L); +LJ_FUNC_NORET void lj_err_msg(lua_State *L, ErrMsg em); +LJ_FUNC_NORET void lj_err_lex(lua_State *L, GCstr *src, const char *tok, + BCLine line, ErrMsg em, va_list argp); +LJ_FUNC_NORET void lj_err_optype(lua_State *L, cTValue *o, ErrMsg opm); +LJ_FUNC_NORET void lj_err_comp(lua_State *L, cTValue *o1, cTValue *o2); +LJ_FUNC_NORET void lj_err_optype_call(lua_State *L, TValue *o); +LJ_FUNC_NORET void lj_err_callermsg(lua_State *L, const char *msg); +LJ_FUNC_NORET void lj_err_callerv(lua_State *L, ErrMsg em, ...); +LJ_FUNC_NORET void lj_err_caller(lua_State *L, ErrMsg em); +LJ_FUNC_NORET void lj_err_arg(lua_State *L, int narg, ErrMsg em); +LJ_FUNC_NORET void lj_err_argv(lua_State *L, int narg, ErrMsg em, ...); +LJ_FUNC_NORET void lj_err_argtype(lua_State *L, int narg, const char *xname); +LJ_FUNC_NORET void lj_err_argt(lua_State *L, int narg, int tt); + +#endif + +``` + +`include/luajit-2.0.5/src/lj_errmsg.h`: + +```h +/* +** VM error messages. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* This file may be included multiple times with different ERRDEF macros. */ + +/* Basic error handling. */ +ERRDEF(ERRMEM, "not enough memory") +ERRDEF(ERRERR, "error in error handling") +ERRDEF(ERRCPP, "C++ exception") + +/* Allocations. */ +ERRDEF(STROV, "string length overflow") +ERRDEF(UDATAOV, "userdata length overflow") +ERRDEF(STKOV, "stack overflow") +ERRDEF(STKOVM, "stack overflow (%s)") +ERRDEF(TABOV, "table overflow") + +/* Table indexing. */ +ERRDEF(NANIDX, "table index is NaN") +ERRDEF(NILIDX, "table index is nil") +ERRDEF(NEXTIDX, "invalid key to " LUA_QL("next")) + +/* Metamethod resolving. */ +ERRDEF(BADCALL, "attempt to call a %s value") +ERRDEF(BADOPRT, "attempt to %s %s " LUA_QS " (a %s value)") +ERRDEF(BADOPRV, "attempt to %s a %s value") +ERRDEF(BADCMPT, "attempt to compare %s with %s") +ERRDEF(BADCMPV, "attempt to compare two %s values") +ERRDEF(GETLOOP, "loop in gettable") +ERRDEF(SETLOOP, "loop in settable") +ERRDEF(OPCALL, "call") +ERRDEF(OPINDEX, "index") +ERRDEF(OPARITH, "perform arithmetic on") +ERRDEF(OPCAT, "concatenate") +ERRDEF(OPLEN, "get length of") + +/* Type checks. */ +ERRDEF(BADSELF, "calling " LUA_QS " on bad self (%s)") +ERRDEF(BADARG, "bad argument #%d to " LUA_QS " (%s)") +ERRDEF(BADTYPE, "%s expected, got %s") +ERRDEF(BADVAL, "invalid value") +ERRDEF(NOVAL, "value expected") +ERRDEF(NOCORO, "coroutine expected") +ERRDEF(NOTABN, "nil or table expected") +ERRDEF(NOLFUNC, "Lua function expected") +ERRDEF(NOFUNCL, "function or level expected") +ERRDEF(NOSFT, "string/function/table expected") +ERRDEF(NOPROXY, "boolean or proxy expected") +ERRDEF(FORINIT, LUA_QL("for") " initial value must be a number") +ERRDEF(FORLIM, LUA_QL("for") " limit must be a number") +ERRDEF(FORSTEP, LUA_QL("for") " step must be a number") + +/* C API checks. */ +ERRDEF(NOENV, "no calling environment") +ERRDEF(CYIELD, "attempt to yield across C-call boundary") +ERRDEF(BADLU, "bad light userdata pointer") +ERRDEF(NOGCMM, "bad action while in __gc metamethod") +#if LJ_TARGET_WINDOWS +ERRDEF(BADFPU, "bad FPU precision (use D3DCREATE_FPU_PRESERVE with DirectX)") +#endif + +/* Standard library function errors. */ +ERRDEF(ASSERT, "assertion failed!") +ERRDEF(PROTMT, "cannot change a protected metatable") +ERRDEF(UNPACK, "too many results to unpack") +ERRDEF(RDRSTR, "reader function must return a string") +ERRDEF(PRTOSTR, LUA_QL("tostring") " must return a string to " LUA_QL("print")) +ERRDEF(IDXRNG, "index out of range") +ERRDEF(BASERNG, "base out of range") +ERRDEF(LVLRNG, "level out of range") +ERRDEF(INVLVL, "invalid level") +ERRDEF(INVOPT, "invalid option") +ERRDEF(INVOPTM, "invalid option " LUA_QS) +ERRDEF(INVFMT, "invalid format") +ERRDEF(SETFENV, LUA_QL("setfenv") " cannot change environment of given object") +ERRDEF(CORUN, "cannot resume running coroutine") +ERRDEF(CODEAD, "cannot resume dead coroutine") +ERRDEF(COSUSP, "cannot resume non-suspended coroutine") +ERRDEF(TABINS, "wrong number of arguments to " LUA_QL("insert")) +ERRDEF(TABCAT, "invalid value (%s) at index %d in table for " LUA_QL("concat")) +ERRDEF(TABSORT, "invalid order function for sorting") +ERRDEF(IOCLFL, "attempt to use a closed file") +ERRDEF(IOSTDCL, "standard file is closed") +ERRDEF(OSUNIQF, "unable to generate a unique filename") +ERRDEF(OSDATEF, "field " LUA_QS " missing in date table") +ERRDEF(STRDUMP, "unable to dump given function") +ERRDEF(STRSLC, "string slice too long") +ERRDEF(STRPATB, "missing " LUA_QL("[") " after " LUA_QL("%f") " in pattern") +ERRDEF(STRPATC, "invalid pattern capture") +ERRDEF(STRPATE, "malformed pattern (ends with " LUA_QL("%") ")") +ERRDEF(STRPATM, "malformed pattern (missing " LUA_QL("]") ")") +ERRDEF(STRPATU, "unbalanced pattern") +ERRDEF(STRPATX, "pattern too complex") +ERRDEF(STRCAPI, "invalid capture index") +ERRDEF(STRCAPN, "too many captures") +ERRDEF(STRCAPU, "unfinished capture") +ERRDEF(STRFMTO, "invalid option " LUA_QL("%%%c") " to " LUA_QL("format")) +ERRDEF(STRFMTR, "invalid format (repeated flags)") +ERRDEF(STRFMTW, "invalid format (width or precision too long)") +ERRDEF(STRGSRV, "invalid replacement value (a %s)") +ERRDEF(BADMODN, "name conflict for module " LUA_QS) +#if LJ_HASJIT +ERRDEF(JITPROT, "runtime code generation failed, restricted kernel?") +#if LJ_TARGET_X86ORX64 +ERRDEF(NOJIT, "JIT compiler disabled, CPU does not support SSE2") +#else +ERRDEF(NOJIT, "JIT compiler disabled") +#endif +#elif defined(LJ_ARCH_NOJIT) +ERRDEF(NOJIT, "no JIT compiler for this architecture (yet)") +#else +ERRDEF(NOJIT, "JIT compiler permanently disabled by build option") +#endif +ERRDEF(JITOPT, "unknown or malformed optimization flag " LUA_QS) + +/* Lexer/parser errors. */ +ERRDEF(XMODE, "attempt to load chunk with wrong mode") +ERRDEF(XNEAR, "%s near " LUA_QS) +ERRDEF(XELEM, "lexical element too long") +ERRDEF(XLINES, "chunk has too many lines") +ERRDEF(XLEVELS, "chunk has too many syntax levels") +ERRDEF(XNUMBER, "malformed number") +ERRDEF(XLSTR, "unfinished long string") +ERRDEF(XLCOM, "unfinished long comment") +ERRDEF(XSTR, "unfinished string") +ERRDEF(XESC, "invalid escape sequence") +ERRDEF(XLDELIM, "invalid long string delimiter") +ERRDEF(XTOKEN, LUA_QS " expected") +ERRDEF(XJUMP, "control structure too long") +ERRDEF(XSLOTS, "function or expression too complex") +ERRDEF(XLIMC, "chunk has more than %d local variables") +ERRDEF(XLIMM, "main function has more than %d %s") +ERRDEF(XLIMF, "function at line %d has more than %d %s") +ERRDEF(XMATCH, LUA_QS " expected (to close " LUA_QS " at line %d)") +ERRDEF(XFIXUP, "function too long for return fixup") +ERRDEF(XPARAM, " or " LUA_QL("...") " expected") +#if !LJ_52 +ERRDEF(XAMBIG, "ambiguous syntax (function call x new statement)") +#endif +ERRDEF(XFUNARG, "function arguments expected") +ERRDEF(XSYMBOL, "unexpected symbol") +ERRDEF(XDOTS, "cannot use " LUA_QL("...") " outside a vararg function") +ERRDEF(XSYNTAX, "syntax error") +ERRDEF(XFOR, LUA_QL("=") " or " LUA_QL("in") " expected") +ERRDEF(XBREAK, "no loop to break") +ERRDEF(XLUNDEF, "undefined label " LUA_QS) +ERRDEF(XLDUP, "duplicate label " LUA_QS) +ERRDEF(XGSCOPE, " jumps into the scope of local " LUA_QS) + +/* Bytecode reader errors. */ +ERRDEF(BCFMT, "cannot load incompatible bytecode") +ERRDEF(BCBAD, "cannot load malformed bytecode") + +#if LJ_HASFFI +/* FFI errors. */ +ERRDEF(FFI_INVTYPE, "invalid C type") +ERRDEF(FFI_INVSIZE, "size of C type is unknown or too large") +ERRDEF(FFI_BADSCL, "bad storage class") +ERRDEF(FFI_DECLSPEC, "declaration specifier expected") +ERRDEF(FFI_BADTAG, "undeclared or implicit tag " LUA_QS) +ERRDEF(FFI_REDEF, "attempt to redefine " LUA_QS) +ERRDEF(FFI_NUMPARAM, "wrong number of type parameters") +ERRDEF(FFI_INITOV, "too many initializers for " LUA_QS) +ERRDEF(FFI_BADCONV, "cannot convert " LUA_QS " to " LUA_QS) +ERRDEF(FFI_BADLEN, "attempt to get length of " LUA_QS) +ERRDEF(FFI_BADCONCAT, "attempt to concatenate " LUA_QS " and " LUA_QS) +ERRDEF(FFI_BADARITH, "attempt to perform arithmetic on " LUA_QS " and " LUA_QS) +ERRDEF(FFI_BADCOMP, "attempt to compare " LUA_QS " with " LUA_QS) +ERRDEF(FFI_BADCALL, LUA_QS " is not callable") +ERRDEF(FFI_NUMARG, "wrong number of arguments for function call") +ERRDEF(FFI_BADMEMBER, LUA_QS " has no member named " LUA_QS) +ERRDEF(FFI_BADIDX, LUA_QS " cannot be indexed") +ERRDEF(FFI_BADIDXW, LUA_QS " cannot be indexed with " LUA_QS) +ERRDEF(FFI_BADMM, LUA_QS " has no " LUA_QS " metamethod") +ERRDEF(FFI_WRCONST, "attempt to write to constant location") +ERRDEF(FFI_NODECL, "missing declaration for symbol " LUA_QS) +ERRDEF(FFI_BADCBACK, "bad callback") +#if LJ_OS_NOJIT +ERRDEF(FFI_CBACKOV, "no support for callbacks on this OS") +#else +ERRDEF(FFI_CBACKOV, "too many callbacks") +#endif +ERRDEF(FFI_NYIPACKBIT, "NYI: packed bit fields") +ERRDEF(FFI_NYICALL, "NYI: cannot call this C function (yet)") +#endif + +#undef ERRDEF + +/* Detecting unused error messages: + awk -F, '/^ERRDEF/ { gsub(/ERRDEF./, ""); printf "grep -q LJ_ERR_%s *.[ch] || echo %s\n", $1, $1}' lj_errmsg.h | sh +*/ + +``` + +`include/luajit-2.0.5/src/lj_ff.h`: + +```h +/* +** Fast function IDs. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_FF_H +#define _LJ_FF_H + +/* Fast function ID. */ +typedef enum { + FF_LUA_ = FF_LUA, /* Lua function (must be 0). */ + FF_C_ = FF_C, /* Regular C function (must be 1). */ +#define FFDEF(name) FF_##name, +#include "lj_ffdef.h" + FF__MAX +} FastFunc; + +#endif + +``` + +`include/luajit-2.0.5/src/lj_ffrecord.c`: + +```c +/* +** Fast function call recorder. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_ffrecord_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_frame.h" +#include "lj_bc.h" +#include "lj_ff.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_ircall.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#include "lj_record.h" +#include "lj_ffrecord.h" +#include "lj_crecord.h" +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "lj_strscan.h" + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +/* -- Fast function recording handlers ------------------------------------ */ + +/* Conventions for fast function call handlers: +** +** The argument slots start at J->base[0]. All of them are guaranteed to be +** valid and type-specialized references. J->base[J->maxslot] is set to 0 +** as a sentinel. The runtime argument values start at rd->argv[0]. +** +** In general fast functions should check for presence of all of their +** arguments and for the correct argument types. Some simplifications +** are allowed if the interpreter throws instead. But even if recording +** is aborted, the generated IR must be consistent (no zero-refs). +** +** The number of results in rd->nres is set to 1. Handlers that return +** a different number of results need to override it. A negative value +** prevents return processing (e.g. for pending calls). +** +** Results need to be stored starting at J->base[0]. Return processing +** moves them to the right slots later. +** +** The per-ffid auxiliary data is the value of the 2nd part of the +** LJLIB_REC() annotation. This allows handling similar functionality +** in a common handler. +*/ + +/* Type of handler to record a fast function. */ +typedef void (LJ_FASTCALL *RecordFunc)(jit_State *J, RecordFFData *rd); + +/* Get runtime value of int argument. */ +static int32_t argv2int(jit_State *J, TValue *o) +{ + if (!lj_strscan_numberobj(o)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + return tvisint(o) ? intV(o) : lj_num2int(numV(o)); +} + +/* Get runtime value of string argument. */ +static GCstr *argv2str(jit_State *J, TValue *o) +{ + if (LJ_LIKELY(tvisstr(o))) { + return strV(o); + } else { + GCstr *s; + if (!tvisnumber(o)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + if (tvisint(o)) + s = lj_str_fromint(J->L, intV(o)); + else + s = lj_str_fromnum(J->L, &o->n); + setstrV(J->L, o, s); + return s; + } +} + +/* Return number of results wanted by caller. */ +static ptrdiff_t results_wanted(jit_State *J) +{ + TValue *frame = J->L->base-1; + if (frame_islua(frame)) + return (ptrdiff_t)bc_b(frame_pc(frame)[-1]) - 1; + else + return -1; +} + +/* Throw error for unsupported variant of fast function. */ +LJ_NORET static void recff_nyiu(jit_State *J) +{ + setfuncV(J->L, &J->errinfo, J->fn); + lj_trace_err_info(J, LJ_TRERR_NYIFFU); +} + +/* Fallback handler for all fast functions that are not recorded (yet). */ +static void LJ_FASTCALL recff_nyi(jit_State *J, RecordFFData *rd) +{ + setfuncV(J->L, &J->errinfo, J->fn); + lj_trace_err_info(J, LJ_TRERR_NYIFF); + UNUSED(rd); +} + +/* C functions can have arbitrary side-effects and are not recorded (yet). */ +static void LJ_FASTCALL recff_c(jit_State *J, RecordFFData *rd) +{ + setfuncV(J->L, &J->errinfo, J->fn); + lj_trace_err_info(J, LJ_TRERR_NYICF); + UNUSED(rd); +} + +/* -- Base library fast functions ----------------------------------------- */ + +static void LJ_FASTCALL recff_assert(jit_State *J, RecordFFData *rd) +{ + /* Arguments already specialized. The interpreter throws for nil/false. */ + rd->nres = J->maxslot; /* Pass through all arguments. */ +} + +static void LJ_FASTCALL recff_type(jit_State *J, RecordFFData *rd) +{ + /* Arguments already specialized. Result is a constant string. Neat, huh? */ + uint32_t t; + if (tvisnumber(&rd->argv[0])) + t = ~LJ_TNUMX; + else if (LJ_64 && tvislightud(&rd->argv[0])) + t = ~LJ_TLIGHTUD; + else + t = ~itype(&rd->argv[0]); + J->base[0] = lj_ir_kstr(J, strV(&J->fn->c.upvalue[t])); + UNUSED(rd); +} + +static void LJ_FASTCALL recff_getmetatable(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + if (tr) { + RecordIndex ix; + ix.tab = tr; + copyTV(J->L, &ix.tabv, &rd->argv[0]); + if (lj_record_mm_lookup(J, &ix, MM_metatable)) + J->base[0] = ix.mobj; + else + J->base[0] = ix.mt; + } /* else: Interpreter will throw. */ +} + +static void LJ_FASTCALL recff_setmetatable(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + TRef mt = J->base[1]; + if (tref_istab(tr) && (tref_istab(mt) || (mt && tref_isnil(mt)))) { + TRef fref, mtref; + RecordIndex ix; + ix.tab = tr; + copyTV(J->L, &ix.tabv, &rd->argv[0]); + lj_record_mm_lookup(J, &ix, MM_metatable); /* Guard for no __metatable. */ + fref = emitir(IRT(IR_FREF, IRT_P32), tr, IRFL_TAB_META); + mtref = tref_isnil(mt) ? lj_ir_knull(J, IRT_TAB) : mt; + emitir(IRT(IR_FSTORE, IRT_TAB), fref, mtref); + if (!tref_isnil(mt)) + emitir(IRT(IR_TBAR, IRT_TAB), tr, 0); + J->base[0] = tr; + J->needsnap = 1; + } /* else: Interpreter will throw. */ +} + +static void LJ_FASTCALL recff_rawget(jit_State *J, RecordFFData *rd) +{ + RecordIndex ix; + ix.tab = J->base[0]; ix.key = J->base[1]; + if (tref_istab(ix.tab) && ix.key) { + ix.val = 0; ix.idxchain = 0; + settabV(J->L, &ix.tabv, tabV(&rd->argv[0])); + copyTV(J->L, &ix.keyv, &rd->argv[1]); + J->base[0] = lj_record_idx(J, &ix); + } /* else: Interpreter will throw. */ +} + +static void LJ_FASTCALL recff_rawset(jit_State *J, RecordFFData *rd) +{ + RecordIndex ix; + ix.tab = J->base[0]; ix.key = J->base[1]; ix.val = J->base[2]; + if (tref_istab(ix.tab) && ix.key && ix.val) { + ix.idxchain = 0; + settabV(J->L, &ix.tabv, tabV(&rd->argv[0])); + copyTV(J->L, &ix.keyv, &rd->argv[1]); + copyTV(J->L, &ix.valv, &rd->argv[2]); + lj_record_idx(J, &ix); + /* Pass through table at J->base[0] as result. */ + } /* else: Interpreter will throw. */ +} + +static void LJ_FASTCALL recff_rawequal(jit_State *J, RecordFFData *rd) +{ + TRef tra = J->base[0]; + TRef trb = J->base[1]; + if (tra && trb) { + int diff = lj_record_objcmp(J, tra, trb, &rd->argv[0], &rd->argv[1]); + J->base[0] = diff ? TREF_FALSE : TREF_TRUE; + } /* else: Interpreter will throw. */ +} + +#if LJ_52 +static void LJ_FASTCALL recff_rawlen(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + if (tref_isstr(tr)) + J->base[0] = emitir(IRTI(IR_FLOAD), tr, IRFL_STR_LEN); + else if (tref_istab(tr)) + J->base[0] = lj_ir_call(J, IRCALL_lj_tab_len, tr); + /* else: Interpreter will throw. */ + UNUSED(rd); +} +#endif + +/* Determine mode of select() call. */ +int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv) +{ + if (tref_isstr(tr) && *strVdata(tv) == '#') { /* select('#', ...) */ + if (strV(tv)->len == 1) { + emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, strV(tv))); + } else { + TRef trptr = emitir(IRT(IR_STRREF, IRT_P32), tr, lj_ir_kint(J, 0)); + TRef trchar = emitir(IRT(IR_XLOAD, IRT_U8), trptr, IRXLOAD_READONLY); + emitir(IRTG(IR_EQ, IRT_INT), trchar, lj_ir_kint(J, '#')); + } + return 0; + } else { /* select(n, ...) */ + int32_t start = argv2int(J, tv); + if (start == 0) lj_trace_err(J, LJ_TRERR_BADTYPE); /* A bit misleading. */ + return start; + } +} + +static void LJ_FASTCALL recff_select(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + if (tr) { + ptrdiff_t start = lj_ffrecord_select_mode(J, tr, &rd->argv[0]); + if (start == 0) { /* select('#', ...) */ + J->base[0] = lj_ir_kint(J, J->maxslot - 1); + } else if (tref_isk(tr)) { /* select(k, ...) */ + ptrdiff_t n = (ptrdiff_t)J->maxslot; + if (start < 0) start += n; + else if (start > n) start = n; + rd->nres = n - start; + if (start >= 1) { + ptrdiff_t i; + for (i = 0; i < n - start; i++) + J->base[i] = J->base[start+i]; + } /* else: Interpreter will throw. */ + } else { + recff_nyiu(J); + } + } /* else: Interpreter will throw. */ +} + +static void LJ_FASTCALL recff_tonumber(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + TRef base = J->base[1]; + if (tr && !tref_isnil(base)) { + base = lj_opt_narrow_toint(J, base); + if (!tref_isk(base) || IR(tref_ref(base))->i != 10) + recff_nyiu(J); + } + if (tref_isnumber_str(tr)) { + if (tref_isstr(tr)) { + TValue tmp; + if (!lj_strscan_num(strV(&rd->argv[0]), &tmp)) + recff_nyiu(J); /* Would need an inverted STRTO for this case. */ + tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); + } +#if LJ_HASFFI + } else if (tref_iscdata(tr)) { + lj_crecord_tonumber(J, rd); + return; +#endif + } else { + tr = TREF_NIL; + } + J->base[0] = tr; + UNUSED(rd); +} + +static TValue *recff_metacall_cp(lua_State *L, lua_CFunction dummy, void *ud) +{ + jit_State *J = (jit_State *)ud; + lj_record_tailcall(J, 0, 1); + UNUSED(L); UNUSED(dummy); + return NULL; +} + +static int recff_metacall(jit_State *J, RecordFFData *rd, MMS mm) +{ + RecordIndex ix; + ix.tab = J->base[0]; + copyTV(J->L, &ix.tabv, &rd->argv[0]); + if (lj_record_mm_lookup(J, &ix, mm)) { /* Has metamethod? */ + int errcode; + TValue argv0; + /* Temporarily insert metamethod below object. */ + J->base[1] = J->base[0]; + J->base[0] = ix.mobj; + copyTV(J->L, &argv0, &rd->argv[0]); + copyTV(J->L, &rd->argv[1], &rd->argv[0]); + copyTV(J->L, &rd->argv[0], &ix.mobjv); + /* Need to protect lj_record_tailcall because it may throw. */ + errcode = lj_vm_cpcall(J->L, NULL, J, recff_metacall_cp); + /* Always undo Lua stack changes to avoid confusing the interpreter. */ + copyTV(J->L, &rd->argv[0], &argv0); + if (errcode) + lj_err_throw(J->L, errcode); /* Propagate errors. */ + rd->nres = -1; /* Pending call. */ + return 1; /* Tailcalled to metamethod. */ + } + return 0; +} + +static void LJ_FASTCALL recff_tostring(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + if (tref_isstr(tr)) { + /* Ignore __tostring in the string base metatable. */ + /* Pass on result in J->base[0]. */ + } else if (!recff_metacall(J, rd, MM_tostring)) { + if (tref_isnumber(tr)) { + J->base[0] = emitir(IRT(IR_TOSTR, IRT_STR), tr, 0); + } else if (tref_ispri(tr)) { + J->base[0] = lj_ir_kstr(J, strV(&J->fn->c.upvalue[tref_type(tr)])); + } else { + recff_nyiu(J); + } + } +} + +static void LJ_FASTCALL recff_ipairs_aux(jit_State *J, RecordFFData *rd) +{ + RecordIndex ix; + ix.tab = J->base[0]; + if (tref_istab(ix.tab)) { + if (!tvisnumber(&rd->argv[1])) /* No support for string coercion. */ + lj_trace_err(J, LJ_TRERR_BADTYPE); + setintV(&ix.keyv, numberVint(&rd->argv[1])+1); + settabV(J->L, &ix.tabv, tabV(&rd->argv[0])); + ix.val = 0; ix.idxchain = 0; + ix.key = lj_opt_narrow_toint(J, J->base[1]); + J->base[0] = ix.key = emitir(IRTI(IR_ADD), ix.key, lj_ir_kint(J, 1)); + J->base[1] = lj_record_idx(J, &ix); + rd->nres = tref_isnil(J->base[1]) ? 0 : 2; + } /* else: Interpreter will throw. */ +} + +static void LJ_FASTCALL recff_ipairs(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + if (!((LJ_52 || (LJ_HASFFI && tref_iscdata(tr))) && + recff_metacall(J, rd, MM_ipairs))) { + if (tref_istab(tr)) { + J->base[0] = lj_ir_kfunc(J, funcV(&J->fn->c.upvalue[0])); + J->base[1] = tr; + J->base[2] = lj_ir_kint(J, 0); + rd->nres = 3; + } /* else: Interpreter will throw. */ + } +} + +static void LJ_FASTCALL recff_pcall(jit_State *J, RecordFFData *rd) +{ + if (J->maxslot >= 1) { + lj_record_call(J, 0, J->maxslot - 1); + rd->nres = -1; /* Pending call. */ + } /* else: Interpreter will throw. */ +} + +static TValue *recff_xpcall_cp(lua_State *L, lua_CFunction dummy, void *ud) +{ + jit_State *J = (jit_State *)ud; + lj_record_call(J, 1, J->maxslot - 2); + UNUSED(L); UNUSED(dummy); + return NULL; +} + +static void LJ_FASTCALL recff_xpcall(jit_State *J, RecordFFData *rd) +{ + if (J->maxslot >= 2) { + TValue argv0, argv1; + TRef tmp; + int errcode; + /* Swap function and traceback. */ + tmp = J->base[0]; J->base[0] = J->base[1]; J->base[1] = tmp; + copyTV(J->L, &argv0, &rd->argv[0]); + copyTV(J->L, &argv1, &rd->argv[1]); + copyTV(J->L, &rd->argv[0], &argv1); + copyTV(J->L, &rd->argv[1], &argv0); + /* Need to protect lj_record_call because it may throw. */ + errcode = lj_vm_cpcall(J->L, NULL, J, recff_xpcall_cp); + /* Always undo Lua stack swap to avoid confusing the interpreter. */ + copyTV(J->L, &rd->argv[0], &argv0); + copyTV(J->L, &rd->argv[1], &argv1); + if (errcode) + lj_err_throw(J->L, errcode); /* Propagate errors. */ + rd->nres = -1; /* Pending call. */ + } /* else: Interpreter will throw. */ +} + +/* -- Math library fast functions ----------------------------------------- */ + +static void LJ_FASTCALL recff_math_abs(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_ir_tonum(J, J->base[0]); + J->base[0] = emitir(IRTN(IR_ABS), tr, lj_ir_knum_abs(J)); + UNUSED(rd); +} + +/* Record rounding functions math.floor and math.ceil. */ +static void LJ_FASTCALL recff_math_round(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + if (!tref_isinteger(tr)) { /* Pass through integers unmodified. */ + tr = emitir(IRTN(IR_FPMATH), lj_ir_tonum(J, tr), rd->data); + /* Result is integral (or NaN/Inf), but may not fit an int32_t. */ + if (LJ_DUALNUM) { /* Try to narrow using a guarded conversion to int. */ + lua_Number n = lj_vm_foldfpm(numberVnum(&rd->argv[0]), rd->data); + if (n == (lua_Number)lj_num2int(n)) + tr = emitir(IRTGI(IR_CONV), tr, IRCONV_INT_NUM|IRCONV_CHECK); + } + J->base[0] = tr; + } +} + +/* Record unary math.* functions, mapped to IR_FPMATH opcode. */ +static void LJ_FASTCALL recff_math_unary(jit_State *J, RecordFFData *rd) +{ + J->base[0] = emitir(IRTN(IR_FPMATH), lj_ir_tonum(J, J->base[0]), rd->data); +} + +/* Record math.log. */ +static void LJ_FASTCALL recff_math_log(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_ir_tonum(J, J->base[0]); + if (J->base[1]) { +#ifdef LUAJIT_NO_LOG2 + uint32_t fpm = IRFPM_LOG; +#else + uint32_t fpm = IRFPM_LOG2; +#endif + TRef trb = lj_ir_tonum(J, J->base[1]); + tr = emitir(IRTN(IR_FPMATH), tr, fpm); + trb = emitir(IRTN(IR_FPMATH), trb, fpm); + trb = emitir(IRTN(IR_DIV), lj_ir_knum_one(J), trb); + tr = emitir(IRTN(IR_MUL), tr, trb); + } else { + tr = emitir(IRTN(IR_FPMATH), tr, IRFPM_LOG); + } + J->base[0] = tr; + UNUSED(rd); +} + +/* Record math.atan2. */ +static void LJ_FASTCALL recff_math_atan2(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_ir_tonum(J, J->base[0]); + TRef tr2 = lj_ir_tonum(J, J->base[1]); + J->base[0] = emitir(IRTN(IR_ATAN2), tr, tr2); + UNUSED(rd); +} + +/* Record math.ldexp. */ +static void LJ_FASTCALL recff_math_ldexp(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_ir_tonum(J, J->base[0]); +#if LJ_TARGET_X86ORX64 + TRef tr2 = lj_ir_tonum(J, J->base[1]); +#else + TRef tr2 = lj_opt_narrow_toint(J, J->base[1]); +#endif + J->base[0] = emitir(IRTN(IR_LDEXP), tr, tr2); + UNUSED(rd); +} + +/* Record math.asin, math.acos, math.atan. */ +static void LJ_FASTCALL recff_math_atrig(jit_State *J, RecordFFData *rd) +{ + TRef y = lj_ir_tonum(J, J->base[0]); + TRef x = lj_ir_knum_one(J); + uint32_t ffid = rd->data; + if (ffid != FF_math_atan) { + TRef tmp = emitir(IRTN(IR_MUL), y, y); + tmp = emitir(IRTN(IR_SUB), x, tmp); + tmp = emitir(IRTN(IR_FPMATH), tmp, IRFPM_SQRT); + if (ffid == FF_math_asin) { x = tmp; } else { x = y; y = tmp; } + } + J->base[0] = emitir(IRTN(IR_ATAN2), y, x); +} + +static void LJ_FASTCALL recff_math_htrig(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_ir_tonum(J, J->base[0]); + J->base[0] = emitir(IRTN(IR_CALLN), tr, rd->data); +} + +static void LJ_FASTCALL recff_math_modf(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + if (tref_isinteger(tr)) { + J->base[0] = tr; + J->base[1] = lj_ir_kint(J, 0); + } else { + TRef trt; + tr = lj_ir_tonum(J, tr); + trt = emitir(IRTN(IR_FPMATH), tr, IRFPM_TRUNC); + J->base[0] = trt; + J->base[1] = emitir(IRTN(IR_SUB), tr, trt); + } + rd->nres = 2; +} + +static void LJ_FASTCALL recff_math_degrad(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_ir_tonum(J, J->base[0]); + TRef trm = lj_ir_knum(J, numV(&J->fn->c.upvalue[0])); + J->base[0] = emitir(IRTN(IR_MUL), tr, trm); + UNUSED(rd); +} + +static void LJ_FASTCALL recff_math_pow(jit_State *J, RecordFFData *rd) +{ + J->base[0] = lj_opt_narrow_pow(J, J->base[0], J->base[1], + &rd->argv[0], &rd->argv[1]); + UNUSED(rd); +} + +static void LJ_FASTCALL recff_math_minmax(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_ir_tonumber(J, J->base[0]); + uint32_t op = rd->data; + BCReg i; + for (i = 1; J->base[i] != 0; i++) { + TRef tr2 = lj_ir_tonumber(J, J->base[i]); + IRType t = IRT_INT; + if (!(tref_isinteger(tr) && tref_isinteger(tr2))) { + if (tref_isinteger(tr)) tr = emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT); + if (tref_isinteger(tr2)) tr2 = emitir(IRTN(IR_CONV), tr2, IRCONV_NUM_INT); + t = IRT_NUM; + } + tr = emitir(IRT(op, t), tr, tr2); + } + J->base[0] = tr; +} + +static void LJ_FASTCALL recff_math_random(jit_State *J, RecordFFData *rd) +{ + GCudata *ud = udataV(&J->fn->c.upvalue[0]); + TRef tr, one; + lj_ir_kgc(J, obj2gco(ud), IRT_UDATA); /* Prevent collection. */ + tr = lj_ir_call(J, IRCALL_lj_math_random_step, lj_ir_kptr(J, uddata(ud))); + one = lj_ir_knum_one(J); + tr = emitir(IRTN(IR_SUB), tr, one); + if (J->base[0]) { + TRef tr1 = lj_ir_tonum(J, J->base[0]); + if (J->base[1]) { /* d = floor(d*(r2-r1+1.0)) + r1 */ + TRef tr2 = lj_ir_tonum(J, J->base[1]); + tr2 = emitir(IRTN(IR_SUB), tr2, tr1); + tr2 = emitir(IRTN(IR_ADD), tr2, one); + tr = emitir(IRTN(IR_MUL), tr, tr2); + tr = emitir(IRTN(IR_FPMATH), tr, IRFPM_FLOOR); + tr = emitir(IRTN(IR_ADD), tr, tr1); + } else { /* d = floor(d*r1) + 1.0 */ + tr = emitir(IRTN(IR_MUL), tr, tr1); + tr = emitir(IRTN(IR_FPMATH), tr, IRFPM_FLOOR); + tr = emitir(IRTN(IR_ADD), tr, one); + } + } + J->base[0] = tr; + UNUSED(rd); +} + +/* -- Bit library fast functions ------------------------------------------ */ + +/* Record unary bit.tobit, bit.bnot, bit.bswap. */ +static void LJ_FASTCALL recff_bit_unary(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_opt_narrow_tobit(J, J->base[0]); + J->base[0] = (rd->data == IR_TOBIT) ? tr : emitir(IRTI(rd->data), tr, 0); +} + +/* Record N-ary bit.band, bit.bor, bit.bxor. */ +static void LJ_FASTCALL recff_bit_nary(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_opt_narrow_tobit(J, J->base[0]); + uint32_t op = rd->data; + BCReg i; + for (i = 1; J->base[i] != 0; i++) + tr = emitir(IRTI(op), tr, lj_opt_narrow_tobit(J, J->base[i])); + J->base[0] = tr; +} + +/* Record bit shifts. */ +static void LJ_FASTCALL recff_bit_shift(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_opt_narrow_tobit(J, J->base[0]); + TRef tsh = lj_opt_narrow_tobit(J, J->base[1]); + IROp op = (IROp)rd->data; + if (!(op < IR_BROL ? LJ_TARGET_MASKSHIFT : LJ_TARGET_MASKROT) && + !tref_isk(tsh)) + tsh = emitir(IRTI(IR_BAND), tsh, lj_ir_kint(J, 31)); +#ifdef LJ_TARGET_UNIFYROT + if (op == (LJ_TARGET_UNIFYROT == 1 ? IR_BROR : IR_BROL)) { + op = LJ_TARGET_UNIFYROT == 1 ? IR_BROL : IR_BROR; + tsh = emitir(IRTI(IR_NEG), tsh, tsh); + } +#endif + J->base[0] = emitir(IRTI(op), tr, tsh); +} + +/* -- String library fast functions --------------------------------------- */ + +static void LJ_FASTCALL recff_string_len(jit_State *J, RecordFFData *rd) +{ + J->base[0] = emitir(IRTI(IR_FLOAD), lj_ir_tostr(J, J->base[0]), IRFL_STR_LEN); + UNUSED(rd); +} + +/* Handle string.byte (rd->data = 0) and string.sub (rd->data = 1). */ +static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd) +{ + TRef trstr = lj_ir_tostr(J, J->base[0]); + TRef trlen = emitir(IRTI(IR_FLOAD), trstr, IRFL_STR_LEN); + TRef tr0 = lj_ir_kint(J, 0); + TRef trstart, trend; + GCstr *str = argv2str(J, &rd->argv[0]); + int32_t start, end; + if (rd->data) { /* string.sub(str, start [,end]) */ + start = argv2int(J, &rd->argv[1]); + trstart = lj_opt_narrow_toint(J, J->base[1]); + trend = J->base[2]; + if (tref_isnil(trend)) { + trend = lj_ir_kint(J, -1); + end = -1; + } else { + trend = lj_opt_narrow_toint(J, trend); + end = argv2int(J, &rd->argv[2]); + } + } else { /* string.byte(str, [,start [,end]]) */ + if (tref_isnil(J->base[1])) { + start = 1; + trstart = lj_ir_kint(J, 1); + } else { + start = argv2int(J, &rd->argv[1]); + trstart = lj_opt_narrow_toint(J, J->base[1]); + } + if (J->base[1] && !tref_isnil(J->base[2])) { + trend = lj_opt_narrow_toint(J, J->base[2]); + end = argv2int(J, &rd->argv[2]); + } else { + trend = trstart; + end = start; + } + } + if (end < 0) { + emitir(IRTGI(IR_LT), trend, tr0); + trend = emitir(IRTI(IR_ADD), emitir(IRTI(IR_ADD), trlen, trend), + lj_ir_kint(J, 1)); + end = end+(int32_t)str->len+1; + } else if ((MSize)end <= str->len) { + emitir(IRTGI(IR_ULE), trend, trlen); + } else { + emitir(IRTGI(IR_GT), trend, trlen); + end = (int32_t)str->len; + trend = trlen; + } + if (start < 0) { + emitir(IRTGI(IR_LT), trstart, tr0); + trstart = emitir(IRTI(IR_ADD), trlen, trstart); + start = start+(int32_t)str->len; + emitir(start < 0 ? IRTGI(IR_LT) : IRTGI(IR_GE), trstart, tr0); + if (start < 0) { + trstart = tr0; + start = 0; + } + } else { + if (start == 0) { + emitir(IRTGI(IR_EQ), trstart, tr0); + trstart = tr0; + } else { + trstart = emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, -1)); + emitir(IRTGI(IR_GE), trstart, tr0); + start--; + } + } + if (rd->data) { /* Return string.sub result. */ + if (end - start >= 0) { + /* Also handle empty range here, to avoid extra traces. */ + TRef trptr, trslen = emitir(IRTI(IR_SUB), trend, trstart); + emitir(IRTGI(IR_GE), trslen, tr0); + trptr = emitir(IRT(IR_STRREF, IRT_P32), trstr, trstart); + J->base[0] = emitir(IRT(IR_SNEW, IRT_STR), trptr, trslen); + } else { /* Range underflow: return empty string. */ + emitir(IRTGI(IR_LT), trend, trstart); + J->base[0] = lj_ir_kstr(J, lj_str_new(J->L, strdata(str), 0)); + } + } else { /* Return string.byte result(s). */ + ptrdiff_t i, len = end - start; + if (len > 0) { + TRef trslen = emitir(IRTI(IR_SUB), trend, trstart); + emitir(IRTGI(IR_EQ), trslen, lj_ir_kint(J, (int32_t)len)); + if (J->baseslot + len > LJ_MAX_JSLOTS) + lj_trace_err_info(J, LJ_TRERR_STACKOV); + rd->nres = len; + for (i = 0; i < len; i++) { + TRef tmp = emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, (int32_t)i)); + tmp = emitir(IRT(IR_STRREF, IRT_P32), trstr, tmp); + J->base[i] = emitir(IRT(IR_XLOAD, IRT_U8), tmp, IRXLOAD_READONLY); + } + } else { /* Empty range or range underflow: return no results. */ + emitir(IRTGI(IR_LE), trend, trstart); + rd->nres = 0; + } + } +} + +/* -- Table library fast functions ---------------------------------------- */ + +static void LJ_FASTCALL recff_table_getn(jit_State *J, RecordFFData *rd) +{ + if (tref_istab(J->base[0])) + J->base[0] = lj_ir_call(J, IRCALL_lj_tab_len, J->base[0]); + /* else: Interpreter will throw. */ + UNUSED(rd); +} + +static void LJ_FASTCALL recff_table_remove(jit_State *J, RecordFFData *rd) +{ + TRef tab = J->base[0]; + rd->nres = 0; + if (tref_istab(tab)) { + if (tref_isnil(J->base[1])) { /* Simple pop: t[#t] = nil */ + TRef trlen = lj_ir_call(J, IRCALL_lj_tab_len, tab); + GCtab *t = tabV(&rd->argv[0]); + MSize len = lj_tab_len(t); + emitir(IRTGI(len ? IR_NE : IR_EQ), trlen, lj_ir_kint(J, 0)); + if (len) { + RecordIndex ix; + ix.tab = tab; + ix.key = trlen; + settabV(J->L, &ix.tabv, t); + setintV(&ix.keyv, len); + ix.idxchain = 0; + if (results_wanted(J) != 0) { /* Specialize load only if needed. */ + ix.val = 0; + J->base[0] = lj_record_idx(J, &ix); /* Load previous value. */ + rd->nres = 1; + /* Assumes ix.key/ix.tab is not modified for raw lj_record_idx(). */ + } + ix.val = TREF_NIL; + lj_record_idx(J, &ix); /* Remove value. */ + } + } else { /* Complex case: remove in the middle. */ + recff_nyiu(J); + } + } /* else: Interpreter will throw. */ +} + +static void LJ_FASTCALL recff_table_insert(jit_State *J, RecordFFData *rd) +{ + RecordIndex ix; + ix.tab = J->base[0]; + ix.val = J->base[1]; + rd->nres = 0; + if (tref_istab(ix.tab) && ix.val) { + if (!J->base[2]) { /* Simple push: t[#t+1] = v */ + TRef trlen = lj_ir_call(J, IRCALL_lj_tab_len, ix.tab); + GCtab *t = tabV(&rd->argv[0]); + ix.key = emitir(IRTI(IR_ADD), trlen, lj_ir_kint(J, 1)); + settabV(J->L, &ix.tabv, t); + setintV(&ix.keyv, lj_tab_len(t) + 1); + ix.idxchain = 0; + lj_record_idx(J, &ix); /* Set new value. */ + } else { /* Complex case: insert in the middle. */ + recff_nyiu(J); + } + } /* else: Interpreter will throw. */ +} + +/* -- I/O library fast functions ------------------------------------------ */ + +/* Get FILE* for I/O function. Any I/O error aborts recording, so there's +** no need to encode the alternate cases for any of the guards. +*/ +static TRef recff_io_fp(jit_State *J, TRef *udp, int32_t id) +{ + TRef tr, ud, fp; + if (id) { /* io.func() */ + tr = lj_ir_kptr(J, &J2G(J)->gcroot[id]); + ud = emitir(IRT(IR_XLOAD, IRT_UDATA), tr, 0); + } else { /* fp:method() */ + ud = J->base[0]; + if (!tref_isudata(ud)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + tr = emitir(IRT(IR_FLOAD, IRT_U8), ud, IRFL_UDATA_UDTYPE); + emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, UDTYPE_IO_FILE)); + } + *udp = ud; + fp = emitir(IRT(IR_FLOAD, IRT_PTR), ud, IRFL_UDATA_FILE); + emitir(IRTG(IR_NE, IRT_PTR), fp, lj_ir_knull(J, IRT_PTR)); + return fp; +} + +static void LJ_FASTCALL recff_io_write(jit_State *J, RecordFFData *rd) +{ + TRef ud, fp = recff_io_fp(J, &ud, rd->data); + TRef zero = lj_ir_kint(J, 0); + TRef one = lj_ir_kint(J, 1); + ptrdiff_t i = rd->data == 0 ? 1 : 0; + for (; J->base[i]; i++) { + TRef str = lj_ir_tostr(J, J->base[i]); + TRef buf = emitir(IRT(IR_STRREF, IRT_P32), str, zero); + TRef len = emitir(IRTI(IR_FLOAD), str, IRFL_STR_LEN); + if (tref_isk(len) && IR(tref_ref(len))->i == 1) { + TRef tr = emitir(IRT(IR_XLOAD, IRT_U8), buf, IRXLOAD_READONLY); + tr = lj_ir_call(J, IRCALL_fputc, tr, fp); + if (results_wanted(J) != 0) /* Check result only if not ignored. */ + emitir(IRTGI(IR_NE), tr, lj_ir_kint(J, -1)); + } else { + TRef tr = lj_ir_call(J, IRCALL_fwrite, buf, one, len, fp); + if (results_wanted(J) != 0) /* Check result only if not ignored. */ + emitir(IRTGI(IR_EQ), tr, len); + } + } + J->base[0] = LJ_52 ? ud : TREF_TRUE; +} + +static void LJ_FASTCALL recff_io_flush(jit_State *J, RecordFFData *rd) +{ + TRef ud, fp = recff_io_fp(J, &ud, rd->data); + TRef tr = lj_ir_call(J, IRCALL_fflush, fp); + if (results_wanted(J) != 0) /* Check result only if not ignored. */ + emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, 0)); + J->base[0] = TREF_TRUE; +} + +/* -- Record calls to fast functions -------------------------------------- */ + +#include "lj_recdef.h" + +static uint32_t recdef_lookup(GCfunc *fn) +{ + if (fn->c.ffid < sizeof(recff_idmap)/sizeof(recff_idmap[0])) + return recff_idmap[fn->c.ffid]; + else + return 0; +} + +/* Record entry to a fast function or C function. */ +void lj_ffrecord_func(jit_State *J) +{ + RecordFFData rd; + uint32_t m = recdef_lookup(J->fn); + rd.data = m & 0xff; + rd.nres = 1; /* Default is one result. */ + rd.argv = J->L->base; + J->base[J->maxslot] = 0; /* Mark end of arguments. */ + (recff_func[m >> 8])(J, &rd); /* Call recff_* handler. */ + if (rd.nres >= 0) { + if (J->postproc == LJ_POST_NONE) J->postproc = LJ_POST_FFRETRY; + lj_record_ret(J, 0, rd.nres); + } +} + +#undef IR +#undef emitir + +#endif + +``` + +`include/luajit-2.0.5/src/lj_ffrecord.h`: + +```h +/* +** Fast function call recorder. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_FFRECORD_H +#define _LJ_FFRECORD_H + +#include "lj_obj.h" +#include "lj_jit.h" + +#if LJ_HASJIT +/* Data used by handlers to record a fast function. */ +typedef struct RecordFFData { + TValue *argv; /* Runtime argument values. */ + ptrdiff_t nres; /* Number of returned results (defaults to 1). */ + uint32_t data; /* Per-ffid auxiliary data (opcode, literal etc.). */ +} RecordFFData; + +LJ_FUNC int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv); +LJ_FUNC void lj_ffrecord_func(jit_State *J); +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_frame.h`: + +```h +/* +** Stack frames. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_FRAME_H +#define _LJ_FRAME_H + +#include "lj_obj.h" +#include "lj_bc.h" + +/* -- Lua stack frame ----------------------------------------------------- */ + +/* Frame type markers in callee function slot (callee base-1). */ +enum { + FRAME_LUA, FRAME_C, FRAME_CONT, FRAME_VARG, + FRAME_LUAP, FRAME_CP, FRAME_PCALL, FRAME_PCALLH +}; +#define FRAME_TYPE 3 +#define FRAME_P 4 +#define FRAME_TYPEP (FRAME_TYPE|FRAME_P) + +/* Macros to access and modify Lua frames. */ +#define frame_gc(f) (gcref((f)->fr.func)) +#define frame_func(f) (&frame_gc(f)->fn) +#define frame_ftsz(f) ((f)->fr.tp.ftsz) + +#define frame_type(f) (frame_ftsz(f) & FRAME_TYPE) +#define frame_typep(f) (frame_ftsz(f) & FRAME_TYPEP) +#define frame_islua(f) (frame_type(f) == FRAME_LUA) +#define frame_isc(f) (frame_type(f) == FRAME_C) +#define frame_iscont(f) (frame_typep(f) == FRAME_CONT) +#define frame_isvarg(f) (frame_typep(f) == FRAME_VARG) +#define frame_ispcall(f) ((frame_ftsz(f) & 6) == FRAME_PCALL) + +#define frame_pc(f) (mref((f)->fr.tp.pcr, const BCIns)) +#define frame_contpc(f) (frame_pc((f)-1)) +#if LJ_64 +#define frame_contf(f) \ + ((ASMFunction)(void *)((intptr_t)lj_vm_asm_begin + \ + (intptr_t)(int32_t)((f)-1)->u32.lo)) +#else +#define frame_contf(f) ((ASMFunction)gcrefp(((f)-1)->gcr, void)) +#endif +#define frame_delta(f) (frame_ftsz(f) >> 3) +#define frame_sized(f) (frame_ftsz(f) & ~FRAME_TYPEP) + +#define frame_prevl(f) ((f) - (1+bc_a(frame_pc(f)[-1]))) +#define frame_prevd(f) ((TValue *)((char *)(f) - frame_sized(f))) +#define frame_prev(f) (frame_islua(f)?frame_prevl(f):frame_prevd(f)) +/* Note: this macro does not skip over FRAME_VARG. */ + +#define setframe_pc(f, pc) (setmref((f)->fr.tp.pcr, (pc))) +#define setframe_ftsz(f, sz) ((f)->fr.tp.ftsz = (sz)) +#define setframe_gc(f, p) (setgcref((f)->fr.func, (p))) + +/* -- C stack frame ------------------------------------------------------- */ + +/* Macros to access and modify the C stack frame chain. */ + +/* These definitions must match with the arch-specific *.dasc files. */ +#if LJ_TARGET_X86 +#define CFRAME_OFS_ERRF (15*4) +#define CFRAME_OFS_NRES (14*4) +#define CFRAME_OFS_PREV (13*4) +#define CFRAME_OFS_L (12*4) +#define CFRAME_OFS_PC (6*4) +#define CFRAME_OFS_MULTRES (5*4) +#define CFRAME_SIZE (12*4) +#define CFRAME_SHIFT_MULTRES 0 +#elif LJ_TARGET_X64 +#if LJ_ABI_WIN +#define CFRAME_OFS_PREV (13*8) +#define CFRAME_OFS_PC (25*4) +#define CFRAME_OFS_L (24*4) +#define CFRAME_OFS_ERRF (23*4) +#define CFRAME_OFS_NRES (22*4) +#define CFRAME_OFS_MULTRES (21*4) +#define CFRAME_SIZE (10*8) +#define CFRAME_SIZE_JIT (CFRAME_SIZE + 9*16 + 4*8) +#define CFRAME_SHIFT_MULTRES 0 +#else +#define CFRAME_OFS_PREV (4*8) +#define CFRAME_OFS_PC (7*4) +#define CFRAME_OFS_L (6*4) +#define CFRAME_OFS_ERRF (5*4) +#define CFRAME_OFS_NRES (4*4) +#define CFRAME_OFS_MULTRES (1*4) +#if LJ_NO_UNWIND +#define CFRAME_SIZE (12*8) +#else +#define CFRAME_SIZE (10*8) +#endif +#define CFRAME_SIZE_JIT (CFRAME_SIZE + 16) +#define CFRAME_SHIFT_MULTRES 0 +#endif +#elif LJ_TARGET_ARM +#define CFRAME_OFS_ERRF 24 +#define CFRAME_OFS_NRES 20 +#define CFRAME_OFS_PREV 16 +#define CFRAME_OFS_L 12 +#define CFRAME_OFS_PC 8 +#define CFRAME_OFS_MULTRES 4 +#if LJ_ARCH_HASFPU +#define CFRAME_SIZE 128 +#else +#define CFRAME_SIZE 64 +#endif +#define CFRAME_SHIFT_MULTRES 3 +#elif LJ_TARGET_PPC +#if LJ_TARGET_XBOX360 +#define CFRAME_OFS_ERRF 424 +#define CFRAME_OFS_NRES 420 +#define CFRAME_OFS_PREV 400 +#define CFRAME_OFS_L 416 +#define CFRAME_OFS_PC 412 +#define CFRAME_OFS_MULTRES 408 +#define CFRAME_SIZE 384 +#define CFRAME_SHIFT_MULTRES 3 +#elif LJ_ARCH_PPC64 +#define CFRAME_OFS_ERRF 472 +#define CFRAME_OFS_NRES 468 +#define CFRAME_OFS_PREV 448 +#define CFRAME_OFS_L 464 +#define CFRAME_OFS_PC 460 +#define CFRAME_OFS_MULTRES 456 +#define CFRAME_SIZE 400 +#define CFRAME_SHIFT_MULTRES 3 +#else +#define CFRAME_OFS_ERRF 48 +#define CFRAME_OFS_NRES 44 +#define CFRAME_OFS_PREV 40 +#define CFRAME_OFS_L 36 +#define CFRAME_OFS_PC 32 +#define CFRAME_OFS_MULTRES 28 +#define CFRAME_SIZE 272 +#define CFRAME_SHIFT_MULTRES 3 +#endif +#elif LJ_TARGET_PPCSPE +#define CFRAME_OFS_ERRF 28 +#define CFRAME_OFS_NRES 24 +#define CFRAME_OFS_PREV 20 +#define CFRAME_OFS_L 16 +#define CFRAME_OFS_PC 12 +#define CFRAME_OFS_MULTRES 8 +#define CFRAME_SIZE 184 +#define CFRAME_SHIFT_MULTRES 3 +#elif LJ_TARGET_MIPS +#define CFRAME_OFS_ERRF 124 +#define CFRAME_OFS_NRES 120 +#define CFRAME_OFS_PREV 116 +#define CFRAME_OFS_L 112 +#define CFRAME_OFS_PC 20 +#define CFRAME_OFS_MULTRES 16 +#define CFRAME_SIZE 112 +#define CFRAME_SHIFT_MULTRES 3 +#else +#error "Missing CFRAME_* definitions for this architecture" +#endif + +#ifndef CFRAME_SIZE_JIT +#define CFRAME_SIZE_JIT CFRAME_SIZE +#endif + +#define CFRAME_RESUME 1 +#define CFRAME_UNWIND_FF 2 /* Only used in unwinder. */ +#define CFRAME_RAWMASK (~(intptr_t)(CFRAME_RESUME|CFRAME_UNWIND_FF)) + +#define cframe_errfunc(cf) (*(int32_t *)(((char *)(cf))+CFRAME_OFS_ERRF)) +#define cframe_nres(cf) (*(int32_t *)(((char *)(cf))+CFRAME_OFS_NRES)) +#define cframe_prev(cf) (*(void **)(((char *)(cf))+CFRAME_OFS_PREV)) +#define cframe_multres(cf) (*(uint32_t *)(((char *)(cf))+CFRAME_OFS_MULTRES)) +#define cframe_multres_n(cf) (cframe_multres((cf)) >> CFRAME_SHIFT_MULTRES) +#define cframe_L(cf) \ + (&gcref(*(GCRef *)(((char *)(cf))+CFRAME_OFS_L))->th) +#define cframe_pc(cf) \ + (mref(*(MRef *)(((char *)(cf))+CFRAME_OFS_PC), const BCIns)) +#define setcframe_L(cf, L) \ + (setmref(*(MRef *)(((char *)(cf))+CFRAME_OFS_L), (L))) +#define setcframe_pc(cf, pc) \ + (setmref(*(MRef *)(((char *)(cf))+CFRAME_OFS_PC), (pc))) +#define cframe_canyield(cf) ((intptr_t)(cf) & CFRAME_RESUME) +#define cframe_unwind_ff(cf) ((intptr_t)(cf) & CFRAME_UNWIND_FF) +#define cframe_raw(cf) ((void *)((intptr_t)(cf) & CFRAME_RAWMASK)) +#define cframe_Lpc(L) cframe_pc(cframe_raw(L->cframe)) + +#endif + +``` + +`include/luajit-2.0.5/src/lj_func.c`: + +```c +/* +** Function handling (prototypes, functions and upvalues). +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_func_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_func.h" +#include "lj_trace.h" +#include "lj_vm.h" + +/* -- Prototypes ---------------------------------------------------------- */ + +void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt) +{ + lj_mem_free(g, pt, pt->sizept); +} + +/* -- Upvalues ------------------------------------------------------------ */ + +static void unlinkuv(GCupval *uv) +{ + lua_assert(uvprev(uvnext(uv)) == uv && uvnext(uvprev(uv)) == uv); + setgcrefr(uvnext(uv)->prev, uv->prev); + setgcrefr(uvprev(uv)->next, uv->next); +} + +/* Find existing open upvalue for a stack slot or create a new one. */ +static GCupval *func_finduv(lua_State *L, TValue *slot) +{ + global_State *g = G(L); + GCRef *pp = &L->openupval; + GCupval *p; + GCupval *uv; + /* Search the sorted list of open upvalues. */ + while (gcref(*pp) != NULL && uvval((p = gco2uv(gcref(*pp)))) >= slot) { + lua_assert(!p->closed && uvval(p) != &p->tv); + if (uvval(p) == slot) { /* Found open upvalue pointing to same slot? */ + if (isdead(g, obj2gco(p))) /* Resurrect it, if it's dead. */ + flipwhite(obj2gco(p)); + return p; + } + pp = &p->nextgc; + } + /* No matching upvalue found. Create a new one. */ + uv = lj_mem_newt(L, sizeof(GCupval), GCupval); + newwhite(g, uv); + uv->gct = ~LJ_TUPVAL; + uv->closed = 0; /* Still open. */ + setmref(uv->v, slot); /* Pointing to the stack slot. */ + /* NOBARRIER: The GCupval is new (marked white) and open. */ + setgcrefr(uv->nextgc, *pp); /* Insert into sorted list of open upvalues. */ + setgcref(*pp, obj2gco(uv)); + setgcref(uv->prev, obj2gco(&g->uvhead)); /* Insert into GC list, too. */ + setgcrefr(uv->next, g->uvhead.next); + setgcref(uvnext(uv)->prev, obj2gco(uv)); + setgcref(g->uvhead.next, obj2gco(uv)); + lua_assert(uvprev(uvnext(uv)) == uv && uvnext(uvprev(uv)) == uv); + return uv; +} + +/* Create an empty and closed upvalue. */ +static GCupval *func_emptyuv(lua_State *L) +{ + GCupval *uv = (GCupval *)lj_mem_newgco(L, sizeof(GCupval)); + uv->gct = ~LJ_TUPVAL; + uv->closed = 1; + setnilV(&uv->tv); + setmref(uv->v, &uv->tv); + return uv; +} + +/* Close all open upvalues pointing to some stack level or above. */ +void LJ_FASTCALL lj_func_closeuv(lua_State *L, TValue *level) +{ + GCupval *uv; + global_State *g = G(L); + while (gcref(L->openupval) != NULL && + uvval((uv = gco2uv(gcref(L->openupval)))) >= level) { + GCobj *o = obj2gco(uv); + lua_assert(!isblack(o) && !uv->closed && uvval(uv) != &uv->tv); + setgcrefr(L->openupval, uv->nextgc); /* No longer in open list. */ + if (isdead(g, o)) { + lj_func_freeuv(g, uv); + } else { + unlinkuv(uv); + lj_gc_closeuv(g, uv); + } + } +} + +void LJ_FASTCALL lj_func_freeuv(global_State *g, GCupval *uv) +{ + if (!uv->closed) + unlinkuv(uv); + lj_mem_freet(g, uv); +} + +/* -- Functions (closures) ------------------------------------------------ */ + +GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env) +{ + GCfunc *fn = (GCfunc *)lj_mem_newgco(L, sizeCfunc(nelems)); + fn->c.gct = ~LJ_TFUNC; + fn->c.ffid = FF_C; + fn->c.nupvalues = (uint8_t)nelems; + /* NOBARRIER: The GCfunc is new (marked white). */ + setmref(fn->c.pc, &G(L)->bc_cfunc_ext); + setgcref(fn->c.env, obj2gco(env)); + return fn; +} + +static GCfunc *func_newL(lua_State *L, GCproto *pt, GCtab *env) +{ + uint32_t count; + GCfunc *fn = (GCfunc *)lj_mem_newgco(L, sizeLfunc((MSize)pt->sizeuv)); + fn->l.gct = ~LJ_TFUNC; + fn->l.ffid = FF_LUA; + fn->l.nupvalues = 0; /* Set to zero until upvalues are initialized. */ + /* NOBARRIER: Really a setgcref. But the GCfunc is new (marked white). */ + setmref(fn->l.pc, proto_bc(pt)); + setgcref(fn->l.env, obj2gco(env)); + /* Saturating 3 bit counter (0..7) for created closures. */ + count = (uint32_t)pt->flags + PROTO_CLCOUNT; + pt->flags = (uint8_t)(count - ((count >> PROTO_CLC_BITS) & PROTO_CLCOUNT)); + return fn; +} + +/* Create a new Lua function with empty upvalues. */ +GCfunc *lj_func_newL_empty(lua_State *L, GCproto *pt, GCtab *env) +{ + GCfunc *fn = func_newL(L, pt, env); + MSize i, nuv = pt->sizeuv; + /* NOBARRIER: The GCfunc is new (marked white). */ + for (i = 0; i < nuv; i++) { + GCupval *uv = func_emptyuv(L); + int32_t v = proto_uv(pt)[i]; + uv->immutable = ((v / PROTO_UV_IMMUTABLE) & 1); + uv->dhash = (uint32_t)(uintptr_t)pt ^ (v << 24); + setgcref(fn->l.uvptr[i], obj2gco(uv)); + } + fn->l.nupvalues = (uint8_t)nuv; + return fn; +} + +/* Do a GC check and create a new Lua function with inherited upvalues. */ +GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent) +{ + GCfunc *fn; + GCRef *puv; + MSize i, nuv; + TValue *base; + lj_gc_check_fixtop(L); + fn = func_newL(L, pt, tabref(parent->env)); + /* NOBARRIER: The GCfunc is new (marked white). */ + puv = parent->uvptr; + nuv = pt->sizeuv; + base = L->base; + for (i = 0; i < nuv; i++) { + uint32_t v = proto_uv(pt)[i]; + GCupval *uv; + if ((v & PROTO_UV_LOCAL)) { + uv = func_finduv(L, base + (v & 0xff)); + uv->immutable = ((v / PROTO_UV_IMMUTABLE) & 1); + uv->dhash = (uint32_t)(uintptr_t)mref(parent->pc, char) ^ (v << 24); + } else { + uv = &gcref(puv[v])->uv; + } + setgcref(fn->l.uvptr[i], obj2gco(uv)); + } + fn->l.nupvalues = (uint8_t)nuv; + return fn; +} + +void LJ_FASTCALL lj_func_free(global_State *g, GCfunc *fn) +{ + MSize size = isluafunc(fn) ? sizeLfunc((MSize)fn->l.nupvalues) : + sizeCfunc((MSize)fn->c.nupvalues); + lj_mem_free(g, fn, size); +} + + +``` + +`include/luajit-2.0.5/src/lj_func.h`: + +```h +/* +** Function handling (prototypes, functions and upvalues). +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_FUNC_H +#define _LJ_FUNC_H + +#include "lj_obj.h" + +/* Prototypes. */ +LJ_FUNC void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt); + +/* Upvalues. */ +LJ_FUNCA void LJ_FASTCALL lj_func_closeuv(lua_State *L, TValue *level); +LJ_FUNC void LJ_FASTCALL lj_func_freeuv(global_State *g, GCupval *uv); + +/* Functions (closures). */ +LJ_FUNC GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env); +LJ_FUNC GCfunc *lj_func_newL_empty(lua_State *L, GCproto *pt, GCtab *env); +LJ_FUNCA GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent); +LJ_FUNC void LJ_FASTCALL lj_func_free(global_State *g, GCfunc *c); + +#endif + +``` + +`include/luajit-2.0.5/src/lj_gc.c`: + +```c +/* +** Garbage collector. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_gc_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_func.h" +#include "lj_udata.h" +#include "lj_meta.h" +#include "lj_state.h" +#include "lj_frame.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#include "lj_cdata.h" +#endif +#include "lj_trace.h" +#include "lj_vm.h" + +#define GCSTEPSIZE 1024u +#define GCSWEEPMAX 40 +#define GCSWEEPCOST 10 +#define GCFINALIZECOST 100 + +/* Macros to set GCobj colors and flags. */ +#define white2gray(x) ((x)->gch.marked &= (uint8_t)~LJ_GC_WHITES) +#define gray2black(x) ((x)->gch.marked |= LJ_GC_BLACK) +#define isfinalized(u) ((u)->marked & LJ_GC_FINALIZED) + +/* -- Mark phase ---------------------------------------------------------- */ + +/* Mark a TValue (if needed). */ +#define gc_marktv(g, tv) \ + { lua_assert(!tvisgcv(tv) || (~itype(tv) == gcval(tv)->gch.gct)); \ + if (tviswhite(tv)) gc_mark(g, gcV(tv)); } + +/* Mark a GCobj (if needed). */ +#define gc_markobj(g, o) \ + { if (iswhite(obj2gco(o))) gc_mark(g, obj2gco(o)); } + +/* Mark a string object. */ +#define gc_mark_str(s) ((s)->marked &= (uint8_t)~LJ_GC_WHITES) + +/* Mark a white GCobj. */ +static void gc_mark(global_State *g, GCobj *o) +{ + int gct = o->gch.gct; + lua_assert(iswhite(o) && !isdead(g, o)); + white2gray(o); + if (LJ_UNLIKELY(gct == ~LJ_TUDATA)) { + GCtab *mt = tabref(gco2ud(o)->metatable); + gray2black(o); /* Userdata are never gray. */ + if (mt) gc_markobj(g, mt); + gc_markobj(g, tabref(gco2ud(o)->env)); + } else if (LJ_UNLIKELY(gct == ~LJ_TUPVAL)) { + GCupval *uv = gco2uv(o); + gc_marktv(g, uvval(uv)); + if (uv->closed) + gray2black(o); /* Closed upvalues are never gray. */ + } else if (gct != ~LJ_TSTR && gct != ~LJ_TCDATA) { + lua_assert(gct == ~LJ_TFUNC || gct == ~LJ_TTAB || + gct == ~LJ_TTHREAD || gct == ~LJ_TPROTO); + setgcrefr(o->gch.gclist, g->gc.gray); + setgcref(g->gc.gray, o); + } +} + +/* Mark GC roots. */ +static void gc_mark_gcroot(global_State *g) +{ + ptrdiff_t i; + for (i = 0; i < GCROOT_MAX; i++) + if (gcref(g->gcroot[i]) != NULL) + gc_markobj(g, gcref(g->gcroot[i])); +} + +/* Start a GC cycle and mark the root set. */ +static void gc_mark_start(global_State *g) +{ + setgcrefnull(g->gc.gray); + setgcrefnull(g->gc.grayagain); + setgcrefnull(g->gc.weak); + gc_markobj(g, mainthread(g)); + gc_markobj(g, tabref(mainthread(g)->env)); + gc_marktv(g, &g->registrytv); + gc_mark_gcroot(g); + g->gc.state = GCSpropagate; +} + +/* Mark open upvalues. */ +static void gc_mark_uv(global_State *g) +{ + GCupval *uv; + for (uv = uvnext(&g->uvhead); uv != &g->uvhead; uv = uvnext(uv)) { + lua_assert(uvprev(uvnext(uv)) == uv && uvnext(uvprev(uv)) == uv); + if (isgray(obj2gco(uv))) + gc_marktv(g, uvval(uv)); + } +} + +/* Mark userdata in mmudata list. */ +static void gc_mark_mmudata(global_State *g) +{ + GCobj *root = gcref(g->gc.mmudata); + GCobj *u = root; + if (u) { + do { + u = gcnext(u); + makewhite(g, u); /* Could be from previous GC. */ + gc_mark(g, u); + } while (u != root); + } +} + +/* Separate userdata objects to be finalized to mmudata list. */ +size_t lj_gc_separateudata(global_State *g, int all) +{ + size_t m = 0; + GCRef *p = &mainthread(g)->nextgc; + GCobj *o; + while ((o = gcref(*p)) != NULL) { + if (!(iswhite(o) || all) || isfinalized(gco2ud(o))) { + p = &o->gch.nextgc; /* Nothing to do. */ + } else if (!lj_meta_fastg(g, tabref(gco2ud(o)->metatable), MM_gc)) { + markfinalized(o); /* Done, as there's no __gc metamethod. */ + p = &o->gch.nextgc; + } else { /* Otherwise move userdata to be finalized to mmudata list. */ + m += sizeudata(gco2ud(o)); + markfinalized(o); + *p = o->gch.nextgc; + if (gcref(g->gc.mmudata)) { /* Link to end of mmudata list. */ + GCobj *root = gcref(g->gc.mmudata); + setgcrefr(o->gch.nextgc, root->gch.nextgc); + setgcref(root->gch.nextgc, o); + setgcref(g->gc.mmudata, o); + } else { /* Create circular list. */ + setgcref(o->gch.nextgc, o); + setgcref(g->gc.mmudata, o); + } + } + } + return m; +} + +/* -- Propagation phase --------------------------------------------------- */ + +/* Traverse a table. */ +static int gc_traverse_tab(global_State *g, GCtab *t) +{ + int weak = 0; + cTValue *mode; + GCtab *mt = tabref(t->metatable); + if (mt) + gc_markobj(g, mt); + mode = lj_meta_fastg(g, mt, MM_mode); + if (mode && tvisstr(mode)) { /* Valid __mode field? */ + const char *modestr = strVdata(mode); + int c; + while ((c = *modestr++)) { + if (c == 'k') weak |= LJ_GC_WEAKKEY; + else if (c == 'v') weak |= LJ_GC_WEAKVAL; + } + if (weak) { /* Weak tables are cleared in the atomic phase. */ +#if LJ_HASFFI + CTState *cts = ctype_ctsG(g); + if (cts && cts->finalizer == t) { + weak = (int)(~0u & ~LJ_GC_WEAKVAL); + } else +#endif + { + t->marked = (uint8_t)((t->marked & ~LJ_GC_WEAK) | weak); + setgcrefr(t->gclist, g->gc.weak); + setgcref(g->gc.weak, obj2gco(t)); + } + } + } + if (weak == LJ_GC_WEAK) /* Nothing to mark if both keys/values are weak. */ + return 1; + if (!(weak & LJ_GC_WEAKVAL)) { /* Mark array part. */ + MSize i, asize = t->asize; + for (i = 0; i < asize; i++) + gc_marktv(g, arrayslot(t, i)); + } + if (t->hmask > 0) { /* Mark hash part. */ + Node *node = noderef(t->node); + MSize i, hmask = t->hmask; + for (i = 0; i <= hmask; i++) { + Node *n = &node[i]; + if (!tvisnil(&n->val)) { /* Mark non-empty slot. */ + lua_assert(!tvisnil(&n->key)); + if (!(weak & LJ_GC_WEAKKEY)) gc_marktv(g, &n->key); + if (!(weak & LJ_GC_WEAKVAL)) gc_marktv(g, &n->val); + } + } + } + return weak; +} + +/* Traverse a function. */ +static void gc_traverse_func(global_State *g, GCfunc *fn) +{ + gc_markobj(g, tabref(fn->c.env)); + if (isluafunc(fn)) { + uint32_t i; + lua_assert(fn->l.nupvalues <= funcproto(fn)->sizeuv); + gc_markobj(g, funcproto(fn)); + for (i = 0; i < fn->l.nupvalues; i++) /* Mark Lua function upvalues. */ + gc_markobj(g, &gcref(fn->l.uvptr[i])->uv); + } else { + uint32_t i; + for (i = 0; i < fn->c.nupvalues; i++) /* Mark C function upvalues. */ + gc_marktv(g, &fn->c.upvalue[i]); + } +} + +#if LJ_HASJIT +/* Mark a trace. */ +static void gc_marktrace(global_State *g, TraceNo traceno) +{ + GCobj *o = obj2gco(traceref(G2J(g), traceno)); + lua_assert(traceno != G2J(g)->cur.traceno); + if (iswhite(o)) { + white2gray(o); + setgcrefr(o->gch.gclist, g->gc.gray); + setgcref(g->gc.gray, o); + } +} + +/* Traverse a trace. */ +static void gc_traverse_trace(global_State *g, GCtrace *T) +{ + IRRef ref; + if (T->traceno == 0) return; + for (ref = T->nk; ref < REF_TRUE; ref++) { + IRIns *ir = &T->ir[ref]; + if (ir->o == IR_KGC) + gc_markobj(g, ir_kgc(ir)); + } + if (T->link) gc_marktrace(g, T->link); + if (T->nextroot) gc_marktrace(g, T->nextroot); + if (T->nextside) gc_marktrace(g, T->nextside); + gc_markobj(g, gcref(T->startpt)); +} + +/* The current trace is a GC root while not anchored in the prototype (yet). */ +#define gc_traverse_curtrace(g) gc_traverse_trace(g, &G2J(g)->cur) +#else +#define gc_traverse_curtrace(g) UNUSED(g) +#endif + +/* Traverse a prototype. */ +static void gc_traverse_proto(global_State *g, GCproto *pt) +{ + ptrdiff_t i; + gc_mark_str(proto_chunkname(pt)); + for (i = -(ptrdiff_t)pt->sizekgc; i < 0; i++) /* Mark collectable consts. */ + gc_markobj(g, proto_kgc(pt, i)); +#if LJ_HASJIT + if (pt->trace) gc_marktrace(g, pt->trace); +#endif +} + +/* Traverse the frame structure of a stack. */ +static MSize gc_traverse_frames(global_State *g, lua_State *th) +{ + TValue *frame, *top = th->top-1, *bot = tvref(th->stack); + /* Note: extra vararg frame not skipped, marks function twice (harmless). */ + for (frame = th->base-1; frame > bot; frame = frame_prev(frame)) { + GCfunc *fn = frame_func(frame); + TValue *ftop = frame; + if (isluafunc(fn)) ftop += funcproto(fn)->framesize; + if (ftop > top) top = ftop; + gc_markobj(g, fn); /* Need to mark hidden function (or L). */ + } + top++; /* Correct bias of -1 (frame == base-1). */ + if (top > tvref(th->maxstack)) top = tvref(th->maxstack); + return (MSize)(top - bot); /* Return minimum needed stack size. */ +} + +/* Traverse a thread object. */ +static void gc_traverse_thread(global_State *g, lua_State *th) +{ + TValue *o, *top = th->top; + for (o = tvref(th->stack)+1; o < top; o++) + gc_marktv(g, o); + if (g->gc.state == GCSatomic) { + top = tvref(th->stack) + th->stacksize; + for (; o < top; o++) /* Clear unmarked slots. */ + setnilV(o); + } + gc_markobj(g, tabref(th->env)); + lj_state_shrinkstack(th, gc_traverse_frames(g, th)); +} + +/* Propagate one gray object. Traverse it and turn it black. */ +static size_t propagatemark(global_State *g) +{ + GCobj *o = gcref(g->gc.gray); + int gct = o->gch.gct; + lua_assert(isgray(o)); + gray2black(o); + setgcrefr(g->gc.gray, o->gch.gclist); /* Remove from gray list. */ + if (LJ_LIKELY(gct == ~LJ_TTAB)) { + GCtab *t = gco2tab(o); + if (gc_traverse_tab(g, t) > 0) + black2gray(o); /* Keep weak tables gray. */ + return sizeof(GCtab) + sizeof(TValue) * t->asize + + (t->hmask ? sizeof(Node) * (t->hmask + 1) : 0); + } else if (LJ_LIKELY(gct == ~LJ_TFUNC)) { + GCfunc *fn = gco2func(o); + gc_traverse_func(g, fn); + return isluafunc(fn) ? sizeLfunc((MSize)fn->l.nupvalues) : + sizeCfunc((MSize)fn->c.nupvalues); + } else if (LJ_LIKELY(gct == ~LJ_TPROTO)) { + GCproto *pt = gco2pt(o); + gc_traverse_proto(g, pt); + return pt->sizept; + } else if (LJ_LIKELY(gct == ~LJ_TTHREAD)) { + lua_State *th = gco2th(o); + setgcrefr(th->gclist, g->gc.grayagain); + setgcref(g->gc.grayagain, o); + black2gray(o); /* Threads are never black. */ + gc_traverse_thread(g, th); + return sizeof(lua_State) + sizeof(TValue) * th->stacksize; + } else { +#if LJ_HASJIT + GCtrace *T = gco2trace(o); + gc_traverse_trace(g, T); + return ((sizeof(GCtrace)+7)&~7) + (T->nins-T->nk)*sizeof(IRIns) + + T->nsnap*sizeof(SnapShot) + T->nsnapmap*sizeof(SnapEntry); +#else + lua_assert(0); + return 0; +#endif + } +} + +/* Propagate all gray objects. */ +static size_t gc_propagate_gray(global_State *g) +{ + size_t m = 0; + while (gcref(g->gc.gray) != NULL) + m += propagatemark(g); + return m; +} + +/* -- Sweep phase --------------------------------------------------------- */ + +/* Try to shrink some common data structures. */ +static void gc_shrink(global_State *g, lua_State *L) +{ + if (g->strnum <= (g->strmask >> 2) && g->strmask > LJ_MIN_STRTAB*2-1) + lj_str_resize(L, g->strmask >> 1); /* Shrink string table. */ + if (g->tmpbuf.sz > LJ_MIN_SBUF*2) + lj_str_resizebuf(L, &g->tmpbuf, g->tmpbuf.sz >> 1); /* Shrink temp buf. */ +} + +/* Type of GC free functions. */ +typedef void (LJ_FASTCALL *GCFreeFunc)(global_State *g, GCobj *o); + +/* GC free functions for LJ_TSTR .. LJ_TUDATA. ORDER LJ_T */ +static const GCFreeFunc gc_freefunc[] = { + (GCFreeFunc)lj_str_free, + (GCFreeFunc)lj_func_freeuv, + (GCFreeFunc)lj_state_free, + (GCFreeFunc)lj_func_freeproto, + (GCFreeFunc)lj_func_free, +#if LJ_HASJIT + (GCFreeFunc)lj_trace_free, +#else + (GCFreeFunc)0, +#endif +#if LJ_HASFFI + (GCFreeFunc)lj_cdata_free, +#else + (GCFreeFunc)0, +#endif + (GCFreeFunc)lj_tab_free, + (GCFreeFunc)lj_udata_free +}; + +/* Full sweep of a GC list. */ +#define gc_fullsweep(g, p) gc_sweep(g, (p), LJ_MAX_MEM) + +/* Partial sweep of a GC list. */ +static GCRef *gc_sweep(global_State *g, GCRef *p, uint32_t lim) +{ + /* Mask with other white and LJ_GC_FIXED. Or LJ_GC_SFIXED on shutdown. */ + int ow = otherwhite(g); + GCobj *o; + while ((o = gcref(*p)) != NULL && lim-- > 0) { + if (o->gch.gct == ~LJ_TTHREAD) /* Need to sweep open upvalues, too. */ + gc_fullsweep(g, &gco2th(o)->openupval); + if (((o->gch.marked ^ LJ_GC_WHITES) & ow)) { /* Black or current white? */ + lua_assert(!isdead(g, o) || (o->gch.marked & LJ_GC_FIXED)); + makewhite(g, o); /* Value is alive, change to the current white. */ + p = &o->gch.nextgc; + } else { /* Otherwise value is dead, free it. */ + lua_assert(isdead(g, o) || ow == LJ_GC_SFIXED); + setgcrefr(*p, o->gch.nextgc); + if (o == gcref(g->gc.root)) + setgcrefr(g->gc.root, o->gch.nextgc); /* Adjust list anchor. */ + gc_freefunc[o->gch.gct - ~LJ_TSTR](g, o); + } + } + return p; +} + +/* Check whether we can clear a key or a value slot from a table. */ +static int gc_mayclear(cTValue *o, int val) +{ + if (tvisgcv(o)) { /* Only collectable objects can be weak references. */ + if (tvisstr(o)) { /* But strings cannot be used as weak references. */ + gc_mark_str(strV(o)); /* And need to be marked. */ + return 0; + } + if (iswhite(gcV(o))) + return 1; /* Object is about to be collected. */ + if (tvisudata(o) && val && isfinalized(udataV(o))) + return 1; /* Finalized userdata is dropped only from values. */ + } + return 0; /* Cannot clear. */ +} + +/* Clear collected entries from weak tables. */ +static void gc_clearweak(GCobj *o) +{ + while (o) { + GCtab *t = gco2tab(o); + lua_assert((t->marked & LJ_GC_WEAK)); + if ((t->marked & LJ_GC_WEAKVAL)) { + MSize i, asize = t->asize; + for (i = 0; i < asize; i++) { + /* Clear array slot when value is about to be collected. */ + TValue *tv = arrayslot(t, i); + if (gc_mayclear(tv, 1)) + setnilV(tv); + } + } + if (t->hmask > 0) { + Node *node = noderef(t->node); + MSize i, hmask = t->hmask; + for (i = 0; i <= hmask; i++) { + Node *n = &node[i]; + /* Clear hash slot when key or value is about to be collected. */ + if (!tvisnil(&n->val) && (gc_mayclear(&n->key, 0) || + gc_mayclear(&n->val, 1))) + setnilV(&n->val); + } + } + o = gcref(t->gclist); + } +} + +/* Call a userdata or cdata finalizer. */ +static void gc_call_finalizer(global_State *g, lua_State *L, + cTValue *mo, GCobj *o) +{ + /* Save and restore lots of state around the __gc callback. */ + uint8_t oldh = hook_save(g); + MSize oldt = g->gc.threshold; + int errcode; + TValue *top; + lj_trace_abort(g); + top = L->top; + L->top = top+2; + hook_entergc(g); /* Disable hooks and new traces during __gc. */ + g->gc.threshold = LJ_MAX_MEM; /* Prevent GC steps. */ + copyTV(L, top, mo); + setgcV(L, top+1, o, ~o->gch.gct); + errcode = lj_vm_pcall(L, top+1, 1+0, -1); /* Stack: |mo|o| -> | */ + hook_restore(g, oldh); + g->gc.threshold = oldt; /* Restore GC threshold. */ + if (errcode) + lj_err_throw(L, errcode); /* Propagate errors. */ +} + +/* Finalize one userdata or cdata object from the mmudata list. */ +static void gc_finalize(lua_State *L) +{ + global_State *g = G(L); + GCobj *o = gcnext(gcref(g->gc.mmudata)); + cTValue *mo; + lua_assert(gcref(g->jit_L) == NULL); /* Must not be called on trace. */ + /* Unchain from list of userdata to be finalized. */ + if (o == gcref(g->gc.mmudata)) + setgcrefnull(g->gc.mmudata); + else + setgcrefr(gcref(g->gc.mmudata)->gch.nextgc, o->gch.nextgc); +#if LJ_HASFFI + if (o->gch.gct == ~LJ_TCDATA) { + TValue tmp, *tv; + /* Add cdata back to the GC list and make it white. */ + setgcrefr(o->gch.nextgc, g->gc.root); + setgcref(g->gc.root, o); + makewhite(g, o); + o->gch.marked &= (uint8_t)~LJ_GC_CDATA_FIN; + /* Resolve finalizer. */ + setcdataV(L, &tmp, gco2cd(o)); + tv = lj_tab_set(L, ctype_ctsG(g)->finalizer, &tmp); + if (!tvisnil(tv)) { + g->gc.nocdatafin = 0; + copyTV(L, &tmp, tv); + setnilV(tv); /* Clear entry in finalizer table. */ + gc_call_finalizer(g, L, &tmp, o); + } + return; + } +#endif + /* Add userdata back to the main userdata list and make it white. */ + setgcrefr(o->gch.nextgc, mainthread(g)->nextgc); + setgcref(mainthread(g)->nextgc, o); + makewhite(g, o); + /* Resolve the __gc metamethod. */ + mo = lj_meta_fastg(g, tabref(gco2ud(o)->metatable), MM_gc); + if (mo) + gc_call_finalizer(g, L, mo, o); +} + +/* Finalize all userdata objects from mmudata list. */ +void lj_gc_finalize_udata(lua_State *L) +{ + while (gcref(G(L)->gc.mmudata) != NULL) + gc_finalize(L); +} + +#if LJ_HASFFI +/* Finalize all cdata objects from finalizer table. */ +void lj_gc_finalize_cdata(lua_State *L) +{ + global_State *g = G(L); + CTState *cts = ctype_ctsG(g); + if (cts) { + GCtab *t = cts->finalizer; + Node *node = noderef(t->node); + ptrdiff_t i; + setgcrefnull(t->metatable); /* Mark finalizer table as disabled. */ + for (i = (ptrdiff_t)t->hmask; i >= 0; i--) + if (!tvisnil(&node[i].val) && tviscdata(&node[i].key)) { + GCobj *o = gcV(&node[i].key); + TValue tmp; + makewhite(g, o); + o->gch.marked &= (uint8_t)~LJ_GC_CDATA_FIN; + copyTV(L, &tmp, &node[i].val); + setnilV(&node[i].val); + gc_call_finalizer(g, L, &tmp, o); + } + } +} +#endif + +/* Free all remaining GC objects. */ +void lj_gc_freeall(global_State *g) +{ + MSize i, strmask; + /* Free everything, except super-fixed objects (the main thread). */ + g->gc.currentwhite = LJ_GC_WHITES | LJ_GC_SFIXED; + gc_fullsweep(g, &g->gc.root); + strmask = g->strmask; + for (i = 0; i <= strmask; i++) /* Free all string hash chains. */ + gc_fullsweep(g, &g->strhash[i]); +} + +/* -- Collector ----------------------------------------------------------- */ + +/* Atomic part of the GC cycle, transitioning from mark to sweep phase. */ +static void atomic(global_State *g, lua_State *L) +{ + size_t udsize; + + gc_mark_uv(g); /* Need to remark open upvalues (the thread may be dead). */ + gc_propagate_gray(g); /* Propagate any left-overs. */ + + setgcrefr(g->gc.gray, g->gc.weak); /* Empty the list of weak tables. */ + setgcrefnull(g->gc.weak); + lua_assert(!iswhite(obj2gco(mainthread(g)))); + gc_markobj(g, L); /* Mark running thread. */ + gc_traverse_curtrace(g); /* Traverse current trace. */ + gc_mark_gcroot(g); /* Mark GC roots (again). */ + gc_propagate_gray(g); /* Propagate all of the above. */ + + setgcrefr(g->gc.gray, g->gc.grayagain); /* Empty the 2nd chance list. */ + setgcrefnull(g->gc.grayagain); + gc_propagate_gray(g); /* Propagate it. */ + + udsize = lj_gc_separateudata(g, 0); /* Separate userdata to be finalized. */ + gc_mark_mmudata(g); /* Mark them. */ + udsize += gc_propagate_gray(g); /* And propagate the marks. */ + + /* All marking done, clear weak tables. */ + gc_clearweak(gcref(g->gc.weak)); + + /* Prepare for sweep phase. */ + g->gc.currentwhite = (uint8_t)otherwhite(g); /* Flip current white. */ + g->strempty.marked = g->gc.currentwhite; + setmref(g->gc.sweep, &g->gc.root); + g->gc.estimate = g->gc.total - (MSize)udsize; /* Initial estimate. */ +} + +/* GC state machine. Returns a cost estimate for each step performed. */ +static size_t gc_onestep(lua_State *L) +{ + global_State *g = G(L); + switch (g->gc.state) { + case GCSpause: + gc_mark_start(g); /* Start a new GC cycle by marking all GC roots. */ + return 0; + case GCSpropagate: + if (gcref(g->gc.gray) != NULL) + return propagatemark(g); /* Propagate one gray object. */ + g->gc.state = GCSatomic; /* End of mark phase. */ + return 0; + case GCSatomic: + if (gcref(g->jit_L)) /* Don't run atomic phase on trace. */ + return LJ_MAX_MEM; + atomic(g, L); + g->gc.state = GCSsweepstring; /* Start of sweep phase. */ + g->gc.sweepstr = 0; + return 0; + case GCSsweepstring: { + MSize old = g->gc.total; + gc_fullsweep(g, &g->strhash[g->gc.sweepstr++]); /* Sweep one chain. */ + if (g->gc.sweepstr > g->strmask) + g->gc.state = GCSsweep; /* All string hash chains sweeped. */ + lua_assert(old >= g->gc.total); + g->gc.estimate -= old - g->gc.total; + return GCSWEEPCOST; + } + case GCSsweep: { + MSize old = g->gc.total; + setmref(g->gc.sweep, gc_sweep(g, mref(g->gc.sweep, GCRef), GCSWEEPMAX)); + lua_assert(old >= g->gc.total); + g->gc.estimate -= old - g->gc.total; + if (gcref(*mref(g->gc.sweep, GCRef)) == NULL) { + gc_shrink(g, L); + if (gcref(g->gc.mmudata)) { /* Need any finalizations? */ + g->gc.state = GCSfinalize; +#if LJ_HASFFI + g->gc.nocdatafin = 1; +#endif + } else { /* Otherwise skip this phase to help the JIT. */ + g->gc.state = GCSpause; /* End of GC cycle. */ + g->gc.debt = 0; + } + } + return GCSWEEPMAX*GCSWEEPCOST; + } + case GCSfinalize: + if (gcref(g->gc.mmudata) != NULL) { + if (gcref(g->jit_L)) /* Don't call finalizers on trace. */ + return LJ_MAX_MEM; + gc_finalize(L); /* Finalize one userdata object. */ + if (g->gc.estimate > GCFINALIZECOST) + g->gc.estimate -= GCFINALIZECOST; + return GCFINALIZECOST; + } +#if LJ_HASFFI + if (!g->gc.nocdatafin) lj_tab_rehash(L, ctype_ctsG(g)->finalizer); +#endif + g->gc.state = GCSpause; /* End of GC cycle. */ + g->gc.debt = 0; + return 0; + default: + lua_assert(0); + return 0; + } +} + +/* Perform a limited amount of incremental GC steps. */ +int LJ_FASTCALL lj_gc_step(lua_State *L) +{ + global_State *g = G(L); + MSize lim; + int32_t ostate = g->vmstate; + setvmstate(g, GC); + lim = (GCSTEPSIZE/100) * g->gc.stepmul; + if (lim == 0) + lim = LJ_MAX_MEM; + if (g->gc.total > g->gc.threshold) + g->gc.debt += g->gc.total - g->gc.threshold; + do { + lim -= (MSize)gc_onestep(L); + if (g->gc.state == GCSpause) { + g->gc.threshold = (g->gc.estimate/100) * g->gc.pause; + g->vmstate = ostate; + return 1; /* Finished a GC cycle. */ + } + } while ((int32_t)lim > 0); + if (g->gc.debt < GCSTEPSIZE) { + g->gc.threshold = g->gc.total + GCSTEPSIZE; + g->vmstate = ostate; + return -1; + } else { + g->gc.debt -= GCSTEPSIZE; + g->gc.threshold = g->gc.total; + g->vmstate = ostate; + return 0; + } +} + +/* Ditto, but fix the stack top first. */ +void LJ_FASTCALL lj_gc_step_fixtop(lua_State *L) +{ + if (curr_funcisL(L)) L->top = curr_topL(L); + lj_gc_step(L); +} + +#if LJ_HASJIT +/* Perform multiple GC steps. Called from JIT-compiled code. */ +int LJ_FASTCALL lj_gc_step_jit(global_State *g, MSize steps) +{ + lua_State *L = gco2th(gcref(g->jit_L)); + L->base = mref(G(L)->jit_base, TValue); + L->top = curr_topL(L); + while (steps-- > 0 && lj_gc_step(L) == 0) + ; + /* Return 1 to force a trace exit. */ + return (G(L)->gc.state == GCSatomic || G(L)->gc.state == GCSfinalize); +} +#endif + +/* Perform a full GC cycle. */ +void lj_gc_fullgc(lua_State *L) +{ + global_State *g = G(L); + int32_t ostate = g->vmstate; + setvmstate(g, GC); + if (g->gc.state <= GCSatomic) { /* Caught somewhere in the middle. */ + setmref(g->gc.sweep, &g->gc.root); /* Sweep everything (preserving it). */ + setgcrefnull(g->gc.gray); /* Reset lists from partial propagation. */ + setgcrefnull(g->gc.grayagain); + setgcrefnull(g->gc.weak); + g->gc.state = GCSsweepstring; /* Fast forward to the sweep phase. */ + g->gc.sweepstr = 0; + } + while (g->gc.state == GCSsweepstring || g->gc.state == GCSsweep) + gc_onestep(L); /* Finish sweep. */ + lua_assert(g->gc.state == GCSfinalize || g->gc.state == GCSpause); + /* Now perform a full GC. */ + g->gc.state = GCSpause; + do { gc_onestep(L); } while (g->gc.state != GCSpause); + g->gc.threshold = (g->gc.estimate/100) * g->gc.pause; + g->vmstate = ostate; +} + +/* -- Write barriers ------------------------------------------------------ */ + +/* Move the GC propagation frontier forward. */ +void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v) +{ + lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); + lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause); + lua_assert(o->gch.gct != ~LJ_TTAB); + /* Preserve invariant during propagation. Otherwise it doesn't matter. */ + if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) + gc_mark(g, v); /* Move frontier forward. */ + else + makewhite(g, o); /* Make it white to avoid the following barrier. */ +} + +/* Specialized barrier for closed upvalue. Pass &uv->tv. */ +void LJ_FASTCALL lj_gc_barrieruv(global_State *g, TValue *tv) +{ +#define TV2MARKED(x) \ + (*((uint8_t *)(x) - offsetof(GCupval, tv) + offsetof(GCupval, marked))) + if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) + gc_mark(g, gcV(tv)); + else + TV2MARKED(tv) = (TV2MARKED(tv) & (uint8_t)~LJ_GC_COLORS) | curwhite(g); +#undef TV2MARKED +} + +/* Close upvalue. Also needs a write barrier. */ +void lj_gc_closeuv(global_State *g, GCupval *uv) +{ + GCobj *o = obj2gco(uv); + /* Copy stack slot to upvalue itself and point to the copy. */ + copyTV(mainthread(g), &uv->tv, uvval(uv)); + setmref(uv->v, &uv->tv); + uv->closed = 1; + setgcrefr(o->gch.nextgc, g->gc.root); + setgcref(g->gc.root, o); + if (isgray(o)) { /* A closed upvalue is never gray, so fix this. */ + if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) { + gray2black(o); /* Make it black and preserve invariant. */ + if (tviswhite(&uv->tv)) + lj_gc_barrierf(g, o, gcV(&uv->tv)); + } else { + makewhite(g, o); /* Make it white, i.e. sweep the upvalue. */ + lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause); + } + } +} + +#if LJ_HASJIT +/* Mark a trace if it's saved during the propagation phase. */ +void lj_gc_barriertrace(global_State *g, uint32_t traceno) +{ + if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) + gc_marktrace(g, traceno); +} +#endif + +/* -- Allocator ----------------------------------------------------------- */ + +/* Call pluggable memory allocator to allocate or resize a fragment. */ +void *lj_mem_realloc(lua_State *L, void *p, MSize osz, MSize nsz) +{ + global_State *g = G(L); + lua_assert((osz == 0) == (p == NULL)); + p = g->allocf(g->allocd, p, osz, nsz); + if (p == NULL && nsz > 0) + lj_err_mem(L); + lua_assert((nsz == 0) == (p == NULL)); + lua_assert(checkptr32(p)); + g->gc.total = (g->gc.total - osz) + nsz; + return p; +} + +/* Allocate new GC object and link it to the root set. */ +void * LJ_FASTCALL lj_mem_newgco(lua_State *L, MSize size) +{ + global_State *g = G(L); + GCobj *o = (GCobj *)g->allocf(g->allocd, NULL, 0, size); + if (o == NULL) + lj_err_mem(L); + lua_assert(checkptr32(o)); + g->gc.total += size; + setgcrefr(o->gch.nextgc, g->gc.root); + setgcref(g->gc.root, o); + newwhite(g, o); + return o; +} + +/* Resize growable vector. */ +void *lj_mem_grow(lua_State *L, void *p, MSize *szp, MSize lim, MSize esz) +{ + MSize sz = (*szp) << 1; + if (sz < LJ_MIN_VECSZ) + sz = LJ_MIN_VECSZ; + if (sz > lim) + sz = lim; + p = lj_mem_realloc(L, p, (*szp)*esz, sz*esz); + *szp = sz; + return p; +} + + +``` + +`include/luajit-2.0.5/src/lj_gc.h`: + +```h +/* +** Garbage collector. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_GC_H +#define _LJ_GC_H + +#include "lj_obj.h" + +/* Garbage collector states. Order matters. */ +enum { + GCSpause, GCSpropagate, GCSatomic, GCSsweepstring, GCSsweep, GCSfinalize +}; + +/* Bitmasks for marked field of GCobj. */ +#define LJ_GC_WHITE0 0x01 +#define LJ_GC_WHITE1 0x02 +#define LJ_GC_BLACK 0x04 +#define LJ_GC_FINALIZED 0x08 +#define LJ_GC_WEAKKEY 0x08 +#define LJ_GC_WEAKVAL 0x10 +#define LJ_GC_CDATA_FIN 0x10 +#define LJ_GC_FIXED 0x20 +#define LJ_GC_SFIXED 0x40 + +#define LJ_GC_WHITES (LJ_GC_WHITE0 | LJ_GC_WHITE1) +#define LJ_GC_COLORS (LJ_GC_WHITES | LJ_GC_BLACK) +#define LJ_GC_WEAK (LJ_GC_WEAKKEY | LJ_GC_WEAKVAL) + +/* Macros to test and set GCobj colors. */ +#define iswhite(x) ((x)->gch.marked & LJ_GC_WHITES) +#define isblack(x) ((x)->gch.marked & LJ_GC_BLACK) +#define isgray(x) (!((x)->gch.marked & (LJ_GC_BLACK|LJ_GC_WHITES))) +#define tviswhite(x) (tvisgcv(x) && iswhite(gcV(x))) +#define otherwhite(g) (g->gc.currentwhite ^ LJ_GC_WHITES) +#define isdead(g, v) ((v)->gch.marked & otherwhite(g) & LJ_GC_WHITES) + +#define curwhite(g) ((g)->gc.currentwhite & LJ_GC_WHITES) +#define newwhite(g, x) (obj2gco(x)->gch.marked = (uint8_t)curwhite(g)) +#define makewhite(g, x) \ + ((x)->gch.marked = ((x)->gch.marked & (uint8_t)~LJ_GC_COLORS) | curwhite(g)) +#define flipwhite(x) ((x)->gch.marked ^= LJ_GC_WHITES) +#define black2gray(x) ((x)->gch.marked &= (uint8_t)~LJ_GC_BLACK) +#define fixstring(s) ((s)->marked |= LJ_GC_FIXED) +#define markfinalized(x) ((x)->gch.marked |= LJ_GC_FINALIZED) + +/* Collector. */ +LJ_FUNC size_t lj_gc_separateudata(global_State *g, int all); +LJ_FUNC void lj_gc_finalize_udata(lua_State *L); +#if LJ_HASFFI +LJ_FUNC void lj_gc_finalize_cdata(lua_State *L); +#else +#define lj_gc_finalize_cdata(L) UNUSED(L) +#endif +LJ_FUNC void lj_gc_freeall(global_State *g); +LJ_FUNCA int LJ_FASTCALL lj_gc_step(lua_State *L); +LJ_FUNCA void LJ_FASTCALL lj_gc_step_fixtop(lua_State *L); +#if LJ_HASJIT +LJ_FUNC int LJ_FASTCALL lj_gc_step_jit(global_State *g, MSize steps); +#endif +LJ_FUNC void lj_gc_fullgc(lua_State *L); + +/* GC check: drive collector forward if the GC threshold has been reached. */ +#define lj_gc_check(L) \ + { if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) \ + lj_gc_step(L); } +#define lj_gc_check_fixtop(L) \ + { if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) \ + lj_gc_step_fixtop(L); } + +/* Write barriers. */ +LJ_FUNC void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v); +LJ_FUNCA void LJ_FASTCALL lj_gc_barrieruv(global_State *g, TValue *tv); +LJ_FUNC void lj_gc_closeuv(global_State *g, GCupval *uv); +#if LJ_HASJIT +LJ_FUNC void lj_gc_barriertrace(global_State *g, uint32_t traceno); +#endif + +/* Move the GC propagation frontier back for tables (make it gray again). */ +static LJ_AINLINE void lj_gc_barrierback(global_State *g, GCtab *t) +{ + GCobj *o = obj2gco(t); + lua_assert(isblack(o) && !isdead(g, o)); + lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause); + black2gray(o); + setgcrefr(t->gclist, g->gc.grayagain); + setgcref(g->gc.grayagain, o); +} + +/* Barrier for stores to table objects. TValue and GCobj variant. */ +#define lj_gc_anybarriert(L, t) \ + { if (LJ_UNLIKELY(isblack(obj2gco(t)))) lj_gc_barrierback(G(L), (t)); } +#define lj_gc_barriert(L, t, tv) \ + { if (tviswhite(tv) && isblack(obj2gco(t))) \ + lj_gc_barrierback(G(L), (t)); } +#define lj_gc_objbarriert(L, t, o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) \ + lj_gc_barrierback(G(L), (t)); } + +/* Barrier for stores to any other object. TValue and GCobj variant. */ +#define lj_gc_barrier(L, p, tv) \ + { if (tviswhite(tv) && isblack(obj2gco(p))) \ + lj_gc_barrierf(G(L), obj2gco(p), gcV(tv)); } +#define lj_gc_objbarrier(L, p, o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ + lj_gc_barrierf(G(L), obj2gco(p), obj2gco(o)); } + +/* Allocator. */ +LJ_FUNC void *lj_mem_realloc(lua_State *L, void *p, MSize osz, MSize nsz); +LJ_FUNC void * LJ_FASTCALL lj_mem_newgco(lua_State *L, MSize size); +LJ_FUNC void *lj_mem_grow(lua_State *L, void *p, + MSize *szp, MSize lim, MSize esz); + +#define lj_mem_new(L, s) lj_mem_realloc(L, NULL, 0, (s)) + +static LJ_AINLINE void lj_mem_free(global_State *g, void *p, size_t osize) +{ + g->gc.total -= (MSize)osize; + g->allocf(g->allocd, p, osize, 0); +} + +#define lj_mem_newvec(L, n, t) ((t *)lj_mem_new(L, (MSize)((n)*sizeof(t)))) +#define lj_mem_reallocvec(L, p, on, n, t) \ + ((p) = (t *)lj_mem_realloc(L, p, (on)*sizeof(t), (MSize)((n)*sizeof(t)))) +#define lj_mem_growvec(L, p, n, m, t) \ + ((p) = (t *)lj_mem_grow(L, (p), &(n), (m), (MSize)sizeof(t))) +#define lj_mem_freevec(g, p, n, t) lj_mem_free(g, (p), (n)*sizeof(t)) + +#define lj_mem_newobj(L, t) ((t *)lj_mem_newgco(L, sizeof(t))) +#define lj_mem_newt(L, s, t) ((t *)lj_mem_new(L, (s))) +#define lj_mem_freet(g, p) lj_mem_free(g, (p), sizeof(*(p))) + +#endif + +``` + +`include/luajit-2.0.5/src/lj_gdbjit.c`: + +```c +/* +** Client for the GDB JIT API. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_gdbjit_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_frame.h" +#include "lj_jit.h" +#include "lj_dispatch.h" + +/* This is not compiled in by default. +** Enable with -DLUAJIT_USE_GDBJIT in the Makefile and recompile everything. +*/ +#ifdef LUAJIT_USE_GDBJIT + +/* The GDB JIT API allows JIT compilers to pass debug information about +** JIT-compiled code back to GDB. You need at least GDB 7.0 or higher +** to see it in action. +** +** This is a passive API, so it works even when not running under GDB +** or when attaching to an already running process. Alas, this implies +** enabling it always has a non-negligible overhead -- do not use in +** release mode! +** +** The LuaJIT GDB JIT client is rather minimal at the moment. It gives +** each trace a symbol name and adds a source location and frame unwind +** information. Obviously LuaJIT itself and any embedding C application +** should be compiled with debug symbols, too (see the Makefile). +** +** Traces are named TRACE_1, TRACE_2, ... these correspond to the trace +** numbers from -jv or -jdump. Use "break TRACE_1" or "tbreak TRACE_1" etc. +** to set breakpoints on specific traces (even ahead of their creation). +** +** The source location for each trace allows listing the corresponding +** source lines with the GDB command "list" (but only if the Lua source +** has been loaded from a file). Currently this is always set to the +** location where the trace has been started. +** +** Frame unwind information can be inspected with the GDB command +** "info frame". This also allows proper backtraces across JIT-compiled +** code with the GDB command "bt". +** +** You probably want to add the following settings to a .gdbinit file +** (or add them to ~/.gdbinit): +** set disassembly-flavor intel +** set breakpoint pending on +** +** Here's a sample GDB session: +** ------------------------------------------------------------------------ + +$ cat >x.lua +for outer=1,100 do + for inner=1,100 do end +end +^D + +$ luajit -jv x.lua +[TRACE 1 x.lua:2] +[TRACE 2 (1/3) x.lua:1 -> 1] + +$ gdb --quiet --args luajit x.lua +(gdb) tbreak TRACE_1 +Function "TRACE_1" not defined. +Temporary breakpoint 1 (TRACE_1) pending. +(gdb) run +Starting program: luajit x.lua + +Temporary breakpoint 1, TRACE_1 () at x.lua:2 +2 for inner=1,100 do end +(gdb) list +1 for outer=1,100 do +2 for inner=1,100 do end +3 end +(gdb) bt +#0 TRACE_1 () at x.lua:2 +#1 0x08053690 in lua_pcall [...] +[...] +#7 0x0806ff90 in main [...] +(gdb) disass TRACE_1 +Dump of assembler code for function TRACE_1: +0xf7fd9fba : mov DWORD PTR ds:0xf7e0e2a0,0x1 +0xf7fd9fc4 : movsd xmm7,QWORD PTR [edx+0x20] +[...] +0xf7fd9ff8 : jmp 0xf7fd2014 +End of assembler dump. +(gdb) tbreak TRACE_2 +Function "TRACE_2" not defined. +Temporary breakpoint 2 (TRACE_2) pending. +(gdb) cont +Continuing. + +Temporary breakpoint 2, TRACE_2 () at x.lua:1 +1 for outer=1,100 do +(gdb) info frame +Stack level 0, frame at 0xffffd7c0: + eip = 0xf7fd9f60 in TRACE_2 (x.lua:1); saved eip 0x8053690 + called by frame at 0xffffd7e0 + source language unknown. + Arglist at 0xffffd78c, args: + Locals at 0xffffd78c, Previous frame's sp is 0xffffd7c0 + Saved registers: + ebx at 0xffffd7ac, ebp at 0xffffd7b8, esi at 0xffffd7b0, edi at 0xffffd7b4, + eip at 0xffffd7bc +(gdb) + +** ------------------------------------------------------------------------ +*/ + +/* -- GDB JIT API --------------------------------------------------------- */ + +/* GDB JIT actions. */ +enum { + GDBJIT_NOACTION = 0, + GDBJIT_REGISTER, + GDBJIT_UNREGISTER +}; + +/* GDB JIT entry. */ +typedef struct GDBJITentry { + struct GDBJITentry *next_entry; + struct GDBJITentry *prev_entry; + const char *symfile_addr; + uint64_t symfile_size; +} GDBJITentry; + +/* GDB JIT descriptor. */ +typedef struct GDBJITdesc { + uint32_t version; + uint32_t action_flag; + GDBJITentry *relevant_entry; + GDBJITentry *first_entry; +} GDBJITdesc; + +GDBJITdesc __jit_debug_descriptor = { + 1, GDBJIT_NOACTION, NULL, NULL +}; + +/* GDB sets a breakpoint at this function. */ +void LJ_NOINLINE __jit_debug_register_code() +{ + __asm__ __volatile__(""); +}; + +/* -- In-memory ELF object definitions ------------------------------------ */ + +/* ELF definitions. */ +typedef struct ELFheader { + uint8_t emagic[4]; + uint8_t eclass; + uint8_t eendian; + uint8_t eversion; + uint8_t eosabi; + uint8_t eabiversion; + uint8_t epad[7]; + uint16_t type; + uint16_t machine; + uint32_t version; + uintptr_t entry; + uintptr_t phofs; + uintptr_t shofs; + uint32_t flags; + uint16_t ehsize; + uint16_t phentsize; + uint16_t phnum; + uint16_t shentsize; + uint16_t shnum; + uint16_t shstridx; +} ELFheader; + +typedef struct ELFsectheader { + uint32_t name; + uint32_t type; + uintptr_t flags; + uintptr_t addr; + uintptr_t ofs; + uintptr_t size; + uint32_t link; + uint32_t info; + uintptr_t align; + uintptr_t entsize; +} ELFsectheader; + +#define ELFSECT_IDX_ABS 0xfff1 + +enum { + ELFSECT_TYPE_PROGBITS = 1, + ELFSECT_TYPE_SYMTAB = 2, + ELFSECT_TYPE_STRTAB = 3, + ELFSECT_TYPE_NOBITS = 8 +}; + +#define ELFSECT_FLAGS_WRITE 1 +#define ELFSECT_FLAGS_ALLOC 2 +#define ELFSECT_FLAGS_EXEC 4 + +typedef struct ELFsymbol { +#if LJ_64 + uint32_t name; + uint8_t info; + uint8_t other; + uint16_t sectidx; + uintptr_t value; + uint64_t size; +#else + uint32_t name; + uintptr_t value; + uint32_t size; + uint8_t info; + uint8_t other; + uint16_t sectidx; +#endif +} ELFsymbol; + +enum { + ELFSYM_TYPE_FUNC = 2, + ELFSYM_TYPE_FILE = 4, + ELFSYM_BIND_LOCAL = 0 << 4, + ELFSYM_BIND_GLOBAL = 1 << 4, +}; + +/* DWARF definitions. */ +#define DW_CIE_VERSION 1 + +enum { + DW_CFA_nop = 0x0, + DW_CFA_offset_extended = 0x5, + DW_CFA_def_cfa = 0xc, + DW_CFA_def_cfa_offset = 0xe, + DW_CFA_offset_extended_sf = 0x11, + DW_CFA_advance_loc = 0x40, + DW_CFA_offset = 0x80 +}; + +enum { + DW_EH_PE_udata4 = 3, + DW_EH_PE_textrel = 0x20 +}; + +enum { + DW_TAG_compile_unit = 0x11 +}; + +enum { + DW_children_no = 0, + DW_children_yes = 1 +}; + +enum { + DW_AT_name = 0x03, + DW_AT_stmt_list = 0x10, + DW_AT_low_pc = 0x11, + DW_AT_high_pc = 0x12 +}; + +enum { + DW_FORM_addr = 0x01, + DW_FORM_data4 = 0x06, + DW_FORM_string = 0x08 +}; + +enum { + DW_LNS_extended_op = 0, + DW_LNS_copy = 1, + DW_LNS_advance_pc = 2, + DW_LNS_advance_line = 3 +}; + +enum { + DW_LNE_end_sequence = 1, + DW_LNE_set_address = 2 +}; + +enum { +#if LJ_TARGET_X86 + DW_REG_AX, DW_REG_CX, DW_REG_DX, DW_REG_BX, + DW_REG_SP, DW_REG_BP, DW_REG_SI, DW_REG_DI, + DW_REG_RA, +#elif LJ_TARGET_X64 + /* Yes, the order is strange, but correct. */ + DW_REG_AX, DW_REG_DX, DW_REG_CX, DW_REG_BX, + DW_REG_SI, DW_REG_DI, DW_REG_BP, DW_REG_SP, + DW_REG_8, DW_REG_9, DW_REG_10, DW_REG_11, + DW_REG_12, DW_REG_13, DW_REG_14, DW_REG_15, + DW_REG_RA, +#elif LJ_TARGET_ARM + DW_REG_SP = 13, + DW_REG_RA = 14, +#elif LJ_TARGET_PPC + DW_REG_SP = 1, + DW_REG_RA = 65, + DW_REG_CR = 70, +#elif LJ_TARGET_MIPS + DW_REG_SP = 29, + DW_REG_RA = 31, +#else +#error "Unsupported target architecture" +#endif +}; + +/* Minimal list of sections for the in-memory ELF object. */ +enum { + GDBJIT_SECT_NULL, + GDBJIT_SECT_text, + GDBJIT_SECT_eh_frame, + GDBJIT_SECT_shstrtab, + GDBJIT_SECT_strtab, + GDBJIT_SECT_symtab, + GDBJIT_SECT_debug_info, + GDBJIT_SECT_debug_abbrev, + GDBJIT_SECT_debug_line, + GDBJIT_SECT__MAX +}; + +enum { + GDBJIT_SYM_UNDEF, + GDBJIT_SYM_FILE, + GDBJIT_SYM_FUNC, + GDBJIT_SYM__MAX +}; + +/* In-memory ELF object. */ +typedef struct GDBJITobj { + ELFheader hdr; /* ELF header. */ + ELFsectheader sect[GDBJIT_SECT__MAX]; /* ELF sections. */ + ELFsymbol sym[GDBJIT_SYM__MAX]; /* ELF symbol table. */ + uint8_t space[4096]; /* Space for various section data. */ +} GDBJITobj; + +/* Combined structure for GDB JIT entry and ELF object. */ +typedef struct GDBJITentryobj { + GDBJITentry entry; + size_t sz; + GDBJITobj obj; +} GDBJITentryobj; + +/* Template for in-memory ELF header. */ +static const ELFheader elfhdr_template = { + .emagic = { 0x7f, 'E', 'L', 'F' }, + .eclass = LJ_64 ? 2 : 1, + .eendian = LJ_ENDIAN_SELECT(1, 2), + .eversion = 1, +#if LJ_TARGET_LINUX + .eosabi = 0, /* Nope, it's not 3. */ +#elif defined(__FreeBSD__) + .eosabi = 9, +#elif defined(__NetBSD__) + .eosabi = 2, +#elif defined(__OpenBSD__) + .eosabi = 12, +#elif defined(__DragonFly__) + .eosabi = 0, +#elif (defined(__sun__) && defined(__svr4__)) + .eosabi = 6, +#else + .eosabi = 0, +#endif + .eabiversion = 0, + .epad = { 0, 0, 0, 0, 0, 0, 0 }, + .type = 1, +#if LJ_TARGET_X86 + .machine = 3, +#elif LJ_TARGET_X64 + .machine = 62, +#elif LJ_TARGET_ARM + .machine = 40, +#elif LJ_TARGET_PPC + .machine = 20, +#elif LJ_TARGET_MIPS + .machine = 8, +#else +#error "Unsupported target architecture" +#endif + .version = 1, + .entry = 0, + .phofs = 0, + .shofs = offsetof(GDBJITobj, sect), + .flags = 0, + .ehsize = sizeof(ELFheader), + .phentsize = 0, + .phnum = 0, + .shentsize = sizeof(ELFsectheader), + .shnum = GDBJIT_SECT__MAX, + .shstridx = GDBJIT_SECT_shstrtab +}; + +/* -- In-memory ELF object generation ------------------------------------- */ + +/* Context for generating the ELF object for the GDB JIT API. */ +typedef struct GDBJITctx { + uint8_t *p; /* Pointer to next address in obj.space. */ + uint8_t *startp; /* Pointer to start address in obj.space. */ + GCtrace *T; /* Generate symbols for this trace. */ + uintptr_t mcaddr; /* Machine code address. */ + MSize szmcode; /* Size of machine code. */ + MSize spadjp; /* Stack adjustment for parent trace or interpreter. */ + MSize spadj; /* Stack adjustment for trace itself. */ + BCLine lineno; /* Starting line number. */ + const char *filename; /* Starting file name. */ + size_t objsize; /* Final size of ELF object. */ + GDBJITobj obj; /* In-memory ELF object. */ +} GDBJITctx; + +/* Add a zero-terminated string. */ +static uint32_t gdbjit_strz(GDBJITctx *ctx, const char *str) +{ + uint8_t *p = ctx->p; + uint32_t ofs = (uint32_t)(p - ctx->startp); + do { + *p++ = (uint8_t)*str; + } while (*str++); + ctx->p = p; + return ofs; +} + +/* Append a decimal number. */ +static void gdbjit_catnum(GDBJITctx *ctx, uint32_t n) +{ + if (n >= 10) { uint32_t m = n / 10; n = n % 10; gdbjit_catnum(ctx, m); } + *ctx->p++ = '0' + n; +} + +/* Add a ULEB128 value. */ +static void gdbjit_uleb128(GDBJITctx *ctx, uint32_t v) +{ + uint8_t *p = ctx->p; + for (; v >= 0x80; v >>= 7) + *p++ = (uint8_t)((v & 0x7f) | 0x80); + *p++ = (uint8_t)v; + ctx->p = p; +} + +/* Add a SLEB128 value. */ +static void gdbjit_sleb128(GDBJITctx *ctx, int32_t v) +{ + uint8_t *p = ctx->p; + for (; (uint32_t)(v+0x40) >= 0x80; v >>= 7) + *p++ = (uint8_t)((v & 0x7f) | 0x80); + *p++ = (uint8_t)(v & 0x7f); + ctx->p = p; +} + +/* Shortcuts to generate DWARF structures. */ +#define DB(x) (*p++ = (x)) +#define DI8(x) (*(int8_t *)p = (x), p++) +#define DU16(x) (*(uint16_t *)p = (x), p += 2) +#define DU32(x) (*(uint32_t *)p = (x), p += 4) +#define DADDR(x) (*(uintptr_t *)p = (x), p += sizeof(uintptr_t)) +#define DUV(x) (ctx->p = p, gdbjit_uleb128(ctx, (x)), p = ctx->p) +#define DSV(x) (ctx->p = p, gdbjit_sleb128(ctx, (x)), p = ctx->p) +#define DSTR(str) (ctx->p = p, gdbjit_strz(ctx, (str)), p = ctx->p) +#define DALIGNNOP(s) while ((uintptr_t)p & ((s)-1)) *p++ = DW_CFA_nop +#define DSECT(name, stmt) \ + { uint32_t *szp_##name = (uint32_t *)p; p += 4; stmt \ + *szp_##name = (uint32_t)((p-(uint8_t *)szp_##name)-4); } \ + +/* Initialize ELF section headers. */ +static void LJ_FASTCALL gdbjit_secthdr(GDBJITctx *ctx) +{ + ELFsectheader *sect; + + *ctx->p++ = '\0'; /* Empty string at start of string table. */ + +#define SECTDEF(id, tp, al) \ + sect = &ctx->obj.sect[GDBJIT_SECT_##id]; \ + sect->name = gdbjit_strz(ctx, "." #id); \ + sect->type = ELFSECT_TYPE_##tp; \ + sect->align = (al) + + SECTDEF(text, NOBITS, 16); + sect->flags = ELFSECT_FLAGS_ALLOC|ELFSECT_FLAGS_EXEC; + sect->addr = ctx->mcaddr; + sect->ofs = 0; + sect->size = ctx->szmcode; + + SECTDEF(eh_frame, PROGBITS, sizeof(uintptr_t)); + sect->flags = ELFSECT_FLAGS_ALLOC; + + SECTDEF(shstrtab, STRTAB, 1); + SECTDEF(strtab, STRTAB, 1); + + SECTDEF(symtab, SYMTAB, sizeof(uintptr_t)); + sect->ofs = offsetof(GDBJITobj, sym); + sect->size = sizeof(ctx->obj.sym); + sect->link = GDBJIT_SECT_strtab; + sect->entsize = sizeof(ELFsymbol); + sect->info = GDBJIT_SYM_FUNC; + + SECTDEF(debug_info, PROGBITS, 1); + SECTDEF(debug_abbrev, PROGBITS, 1); + SECTDEF(debug_line, PROGBITS, 1); + +#undef SECTDEF +} + +/* Initialize symbol table. */ +static void LJ_FASTCALL gdbjit_symtab(GDBJITctx *ctx) +{ + ELFsymbol *sym; + + *ctx->p++ = '\0'; /* Empty string at start of string table. */ + + sym = &ctx->obj.sym[GDBJIT_SYM_FILE]; + sym->name = gdbjit_strz(ctx, "JIT mcode"); + sym->sectidx = ELFSECT_IDX_ABS; + sym->info = ELFSYM_TYPE_FILE|ELFSYM_BIND_LOCAL; + + sym = &ctx->obj.sym[GDBJIT_SYM_FUNC]; + sym->name = gdbjit_strz(ctx, "TRACE_"); ctx->p--; + gdbjit_catnum(ctx, ctx->T->traceno); *ctx->p++ = '\0'; + sym->sectidx = GDBJIT_SECT_text; + sym->value = 0; + sym->size = ctx->szmcode; + sym->info = ELFSYM_TYPE_FUNC|ELFSYM_BIND_GLOBAL; +} + +/* Initialize .eh_frame section. */ +static void LJ_FASTCALL gdbjit_ehframe(GDBJITctx *ctx) +{ + uint8_t *p = ctx->p; + uint8_t *framep = p; + + /* Emit DWARF EH CIE. */ + DSECT(CIE, + DU32(0); /* Offset to CIE itself. */ + DB(DW_CIE_VERSION); + DSTR("zR"); /* Augmentation. */ + DUV(1); /* Code alignment factor. */ + DSV(-(int32_t)sizeof(uintptr_t)); /* Data alignment factor. */ + DB(DW_REG_RA); /* Return address register. */ + DB(1); DB(DW_EH_PE_textrel|DW_EH_PE_udata4); /* Augmentation data. */ + DB(DW_CFA_def_cfa); DUV(DW_REG_SP); DUV(sizeof(uintptr_t)); +#if LJ_TARGET_PPC + DB(DW_CFA_offset_extended_sf); DB(DW_REG_RA); DSV(-1); +#else + DB(DW_CFA_offset|DW_REG_RA); DUV(1); +#endif + DALIGNNOP(sizeof(uintptr_t)); + ) + + /* Emit DWARF EH FDE. */ + DSECT(FDE, + DU32((uint32_t)(p-framep)); /* Offset to CIE. */ + DU32(0); /* Machine code offset relative to .text. */ + DU32(ctx->szmcode); /* Machine code length. */ + DB(0); /* Augmentation data. */ + /* Registers saved in CFRAME. */ +#if LJ_TARGET_X86 + DB(DW_CFA_offset|DW_REG_BP); DUV(2); + DB(DW_CFA_offset|DW_REG_DI); DUV(3); + DB(DW_CFA_offset|DW_REG_SI); DUV(4); + DB(DW_CFA_offset|DW_REG_BX); DUV(5); +#elif LJ_TARGET_X64 + DB(DW_CFA_offset|DW_REG_BP); DUV(2); + DB(DW_CFA_offset|DW_REG_BX); DUV(3); + DB(DW_CFA_offset|DW_REG_15); DUV(4); + DB(DW_CFA_offset|DW_REG_14); DUV(5); + /* Extra registers saved for JIT-compiled code. */ + DB(DW_CFA_offset|DW_REG_13); DUV(9); + DB(DW_CFA_offset|DW_REG_12); DUV(10); +#elif LJ_TARGET_ARM + { + int i; + for (i = 11; i >= 4; i--) { DB(DW_CFA_offset|i); DUV(2+(11-i)); } + } +#elif LJ_TARGET_PPC + { + int i; + DB(DW_CFA_offset_extended); DB(DW_REG_CR); DUV(55); + for (i = 14; i <= 31; i++) { + DB(DW_CFA_offset|i); DUV(37+(31-i)); + DB(DW_CFA_offset|32|i); DUV(2+2*(31-i)); + } + } +#elif LJ_TARGET_MIPS + { + int i; + DB(DW_CFA_offset|30); DUV(2); + for (i = 23; i >= 16; i--) { DB(DW_CFA_offset|i); DUV(26-i); } + for (i = 30; i >= 20; i -= 2) { DB(DW_CFA_offset|32|i); DUV(42-i); } + } +#else +#error "Unsupported target architecture" +#endif + if (ctx->spadjp != ctx->spadj) { /* Parent/interpreter stack frame size. */ + DB(DW_CFA_def_cfa_offset); DUV(ctx->spadjp); + DB(DW_CFA_advance_loc|1); /* Only an approximation. */ + } + DB(DW_CFA_def_cfa_offset); DUV(ctx->spadj); /* Trace stack frame size. */ + DALIGNNOP(sizeof(uintptr_t)); + ) + + ctx->p = p; +} + +/* Initialize .debug_info section. */ +static void LJ_FASTCALL gdbjit_debuginfo(GDBJITctx *ctx) +{ + uint8_t *p = ctx->p; + + DSECT(info, + DU16(2); /* DWARF version. */ + DU32(0); /* Abbrev offset. */ + DB(sizeof(uintptr_t)); /* Pointer size. */ + + DUV(1); /* Abbrev #1: DW_TAG_compile_unit. */ + DSTR(ctx->filename); /* DW_AT_name. */ + DADDR(ctx->mcaddr); /* DW_AT_low_pc. */ + DADDR(ctx->mcaddr + ctx->szmcode); /* DW_AT_high_pc. */ + DU32(0); /* DW_AT_stmt_list. */ + ) + + ctx->p = p; +} + +/* Initialize .debug_abbrev section. */ +static void LJ_FASTCALL gdbjit_debugabbrev(GDBJITctx *ctx) +{ + uint8_t *p = ctx->p; + + /* Abbrev #1: DW_TAG_compile_unit. */ + DUV(1); DUV(DW_TAG_compile_unit); + DB(DW_children_no); + DUV(DW_AT_name); DUV(DW_FORM_string); + DUV(DW_AT_low_pc); DUV(DW_FORM_addr); + DUV(DW_AT_high_pc); DUV(DW_FORM_addr); + DUV(DW_AT_stmt_list); DUV(DW_FORM_data4); + DB(0); DB(0); + + ctx->p = p; +} + +#define DLNE(op, s) (DB(DW_LNS_extended_op), DUV(1+(s)), DB((op))) + +/* Initialize .debug_line section. */ +static void LJ_FASTCALL gdbjit_debugline(GDBJITctx *ctx) +{ + uint8_t *p = ctx->p; + + DSECT(line, + DU16(2); /* DWARF version. */ + DSECT(header, + DB(1); /* Minimum instruction length. */ + DB(1); /* is_stmt. */ + DI8(0); /* Line base for special opcodes. */ + DB(2); /* Line range for special opcodes. */ + DB(3+1); /* Opcode base at DW_LNS_advance_line+1. */ + DB(0); DB(1); DB(1); /* Standard opcode lengths. */ + /* Directory table. */ + DB(0); + /* File name table. */ + DSTR(ctx->filename); DUV(0); DUV(0); DUV(0); + DB(0); + ) + + DLNE(DW_LNE_set_address, sizeof(uintptr_t)); DADDR(ctx->mcaddr); + if (ctx->lineno) { + DB(DW_LNS_advance_line); DSV(ctx->lineno-1); + } + DB(DW_LNS_copy); + DB(DW_LNS_advance_pc); DUV(ctx->szmcode); + DLNE(DW_LNE_end_sequence, 0); + ) + + ctx->p = p; +} + +#undef DLNE + +/* Undef shortcuts. */ +#undef DB +#undef DI8 +#undef DU16 +#undef DU32 +#undef DADDR +#undef DUV +#undef DSV +#undef DSTR +#undef DALIGNNOP +#undef DSECT + +/* Type of a section initializer callback. */ +typedef void (LJ_FASTCALL *GDBJITinitf)(GDBJITctx *ctx); + +/* Call section initializer and set the section offset and size. */ +static void gdbjit_initsect(GDBJITctx *ctx, int sect, GDBJITinitf initf) +{ + ctx->startp = ctx->p; + ctx->obj.sect[sect].ofs = (uintptr_t)((char *)ctx->p - (char *)&ctx->obj); + initf(ctx); + ctx->obj.sect[sect].size = (uintptr_t)(ctx->p - ctx->startp); +} + +#define SECTALIGN(p, a) \ + ((p) = (uint8_t *)(((uintptr_t)(p) + ((a)-1)) & ~(uintptr_t)((a)-1))) + +/* Build in-memory ELF object. */ +static void gdbjit_buildobj(GDBJITctx *ctx) +{ + GDBJITobj *obj = &ctx->obj; + /* Fill in ELF header and clear structures. */ + memcpy(&obj->hdr, &elfhdr_template, sizeof(ELFheader)); + memset(&obj->sect, 0, sizeof(ELFsectheader)*GDBJIT_SECT__MAX); + memset(&obj->sym, 0, sizeof(ELFsymbol)*GDBJIT_SYM__MAX); + /* Initialize sections. */ + ctx->p = obj->space; + gdbjit_initsect(ctx, GDBJIT_SECT_shstrtab, gdbjit_secthdr); + gdbjit_initsect(ctx, GDBJIT_SECT_strtab, gdbjit_symtab); + gdbjit_initsect(ctx, GDBJIT_SECT_debug_info, gdbjit_debuginfo); + gdbjit_initsect(ctx, GDBJIT_SECT_debug_abbrev, gdbjit_debugabbrev); + gdbjit_initsect(ctx, GDBJIT_SECT_debug_line, gdbjit_debugline); + SECTALIGN(ctx->p, sizeof(uintptr_t)); + gdbjit_initsect(ctx, GDBJIT_SECT_eh_frame, gdbjit_ehframe); + ctx->objsize = (size_t)((char *)ctx->p - (char *)obj); + lua_assert(ctx->objsize < sizeof(GDBJITobj)); +} + +#undef SECTALIGN + +/* -- Interface to GDB JIT API -------------------------------------------- */ + +/* Add new entry to GDB JIT symbol chain. */ +static void gdbjit_newentry(lua_State *L, GDBJITctx *ctx) +{ + /* Allocate memory for GDB JIT entry and ELF object. */ + MSize sz = (MSize)(sizeof(GDBJITentryobj) - sizeof(GDBJITobj) + ctx->objsize); + GDBJITentryobj *eo = lj_mem_newt(L, sz, GDBJITentryobj); + memcpy(&eo->obj, &ctx->obj, ctx->objsize); /* Copy ELF object. */ + eo->sz = sz; + ctx->T->gdbjit_entry = (void *)eo; + /* Link new entry to chain and register it. */ + eo->entry.prev_entry = NULL; + eo->entry.next_entry = __jit_debug_descriptor.first_entry; + if (eo->entry.next_entry) + eo->entry.next_entry->prev_entry = &eo->entry; + eo->entry.symfile_addr = (const char *)&eo->obj; + eo->entry.symfile_size = ctx->objsize; + __jit_debug_descriptor.first_entry = &eo->entry; + __jit_debug_descriptor.relevant_entry = &eo->entry; + __jit_debug_descriptor.action_flag = GDBJIT_REGISTER; + __jit_debug_register_code(); +} + +/* Add debug info for newly compiled trace and notify GDB. */ +void lj_gdbjit_addtrace(jit_State *J, GCtrace *T) +{ + GDBJITctx ctx; + GCproto *pt = &gcref(T->startpt)->pt; + TraceNo parent = T->ir[REF_BASE].op1; + const BCIns *startpc = mref(T->startpc, const BCIns); + ctx.T = T; + ctx.mcaddr = (uintptr_t)T->mcode; + ctx.szmcode = T->szmcode; + ctx.spadjp = CFRAME_SIZE_JIT + + (MSize)(parent ? traceref(J, parent)->spadjust : 0); + ctx.spadj = CFRAME_SIZE_JIT + T->spadjust; + lua_assert(startpc >= proto_bc(pt) && startpc < proto_bc(pt) + pt->sizebc); + ctx.lineno = lj_debug_line(pt, proto_bcpos(pt, startpc)); + ctx.filename = proto_chunknamestr(pt); + if (*ctx.filename == '@' || *ctx.filename == '=') + ctx.filename++; + else + ctx.filename = "(string)"; + gdbjit_buildobj(&ctx); + gdbjit_newentry(J->L, &ctx); +} + +/* Delete debug info for trace and notify GDB. */ +void lj_gdbjit_deltrace(jit_State *J, GCtrace *T) +{ + GDBJITentryobj *eo = (GDBJITentryobj *)T->gdbjit_entry; + if (eo) { + if (eo->entry.prev_entry) + eo->entry.prev_entry->next_entry = eo->entry.next_entry; + else + __jit_debug_descriptor.first_entry = eo->entry.next_entry; + if (eo->entry.next_entry) + eo->entry.next_entry->prev_entry = eo->entry.prev_entry; + __jit_debug_descriptor.relevant_entry = &eo->entry; + __jit_debug_descriptor.action_flag = GDBJIT_UNREGISTER; + __jit_debug_register_code(); + lj_mem_free(J2G(J), eo, eo->sz); + } +} + +#endif +#endif + +``` + +`include/luajit-2.0.5/src/lj_gdbjit.h`: + +```h +/* +** Client for the GDB JIT API. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_GDBJIT_H +#define _LJ_GDBJIT_H + +#include "lj_obj.h" +#include "lj_jit.h" + +#if LJ_HASJIT && defined(LUAJIT_USE_GDBJIT) + +LJ_FUNC void lj_gdbjit_addtrace(jit_State *J, GCtrace *T); +LJ_FUNC void lj_gdbjit_deltrace(jit_State *J, GCtrace *T); + +#else +#define lj_gdbjit_addtrace(J, T) UNUSED(T) +#define lj_gdbjit_deltrace(J, T) UNUSED(T) +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_ir.c`: + +```c +/* +** SSA IR (Intermediate Representation) emitter. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_ir_c +#define LUA_CORE + +/* For pointers to libc/libm functions. */ +#include +#include + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_gc.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_ircall.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#include "lj_cdata.h" +#include "lj_carith.h" +#endif +#include "lj_vm.h" +#include "lj_strscan.h" +#include "lj_lib.h" + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) +#define fins (&J->fold.ins) + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +/* -- IR tables ----------------------------------------------------------- */ + +/* IR instruction modes. */ +LJ_DATADEF const uint8_t lj_ir_mode[IR__MAX+1] = { +IRDEF(IRMODE) + 0 +}; + +/* IR type sizes. */ +LJ_DATADEF const uint8_t lj_ir_type_size[IRT__MAX+1] = { +#define IRTSIZE(name, size) size, +IRTDEF(IRTSIZE) +#undef IRTSIZE + 0 +}; + +/* C call info for CALL* instructions. */ +LJ_DATADEF const CCallInfo lj_ir_callinfo[] = { +#define IRCALLCI(cond, name, nargs, kind, type, flags) \ + { (ASMFunction)IRCALLCOND_##cond(name), \ + (nargs)|(CCI_CALL_##kind)|(IRT_##type<irbuf + J->irbotlim; + MSize szins = J->irtoplim - J->irbotlim; + if (szins) { + baseir = (IRIns *)lj_mem_realloc(J->L, baseir, szins*sizeof(IRIns), + 2*szins*sizeof(IRIns)); + J->irtoplim = J->irbotlim + 2*szins; + } else { + baseir = (IRIns *)lj_mem_realloc(J->L, NULL, 0, LJ_MIN_IRSZ*sizeof(IRIns)); + J->irbotlim = REF_BASE - LJ_MIN_IRSZ/4; + J->irtoplim = J->irbotlim + LJ_MIN_IRSZ; + } + J->cur.ir = J->irbuf = baseir - J->irbotlim; +} + +/* Grow IR buffer at the bottom or shift it up. */ +static void lj_ir_growbot(jit_State *J) +{ + IRIns *baseir = J->irbuf + J->irbotlim; + MSize szins = J->irtoplim - J->irbotlim; + lua_assert(szins != 0); + lua_assert(J->cur.nk == J->irbotlim); + if (J->cur.nins + (szins >> 1) < J->irtoplim) { + /* More than half of the buffer is free on top: shift up by a quarter. */ + MSize ofs = szins >> 2; + memmove(baseir + ofs, baseir, (J->cur.nins - J->irbotlim)*sizeof(IRIns)); + J->irbotlim -= ofs; + J->irtoplim -= ofs; + J->cur.ir = J->irbuf = baseir - J->irbotlim; + } else { + /* Double the buffer size, but split the growth amongst top/bottom. */ + IRIns *newbase = lj_mem_newt(J->L, 2*szins*sizeof(IRIns), IRIns); + MSize ofs = szins >= 256 ? 128 : (szins >> 1); /* Limit bottom growth. */ + memcpy(newbase + ofs, baseir, (J->cur.nins - J->irbotlim)*sizeof(IRIns)); + lj_mem_free(G(J->L), baseir, szins*sizeof(IRIns)); + J->irbotlim -= ofs; + J->irtoplim = J->irbotlim + 2*szins; + J->cur.ir = J->irbuf = newbase - J->irbotlim; + } +} + +/* Emit IR without any optimizations. */ +TRef LJ_FASTCALL lj_ir_emit(jit_State *J) +{ + IRRef ref = lj_ir_nextins(J); + IRIns *ir = IR(ref); + IROp op = fins->o; + ir->prev = J->chain[op]; + J->chain[op] = (IRRef1)ref; + ir->o = op; + ir->op1 = fins->op1; + ir->op2 = fins->op2; + J->guardemit.irt |= fins->t.irt; + return TREF(ref, irt_t((ir->t = fins->t))); +} + +/* Emit call to a C function. */ +TRef lj_ir_call(jit_State *J, IRCallID id, ...) +{ + const CCallInfo *ci = &lj_ir_callinfo[id]; + uint32_t n = CCI_NARGS(ci); + TRef tr = TREF_NIL; + va_list argp; + va_start(argp, id); + if ((ci->flags & CCI_L)) n--; + if (n > 0) + tr = va_arg(argp, IRRef); + while (n-- > 1) + tr = emitir(IRT(IR_CARG, IRT_NIL), tr, va_arg(argp, IRRef)); + va_end(argp); + if (CCI_OP(ci) == IR_CALLS) + J->needsnap = 1; /* Need snapshot after call with side effect. */ + return emitir(CCI_OPTYPE(ci), tr, id); +} + +/* -- Interning of constants ---------------------------------------------- */ + +/* +** IR instructions for constants are kept between J->cur.nk >= ref < REF_BIAS. +** They are chained like all other instructions, but grow downwards. +** The are interned (like strings in the VM) to facilitate reference +** comparisons. The same constant must get the same reference. +*/ + +/* Get ref of next IR constant and optionally grow IR. +** Note: this may invalidate all IRIns *! +*/ +static LJ_AINLINE IRRef ir_nextk(jit_State *J) +{ + IRRef ref = J->cur.nk; + if (LJ_UNLIKELY(ref <= J->irbotlim)) lj_ir_growbot(J); + J->cur.nk = --ref; + return ref; +} + +/* Intern int32_t constant. */ +TRef LJ_FASTCALL lj_ir_kint(jit_State *J, int32_t k) +{ + IRIns *ir, *cir = J->cur.ir; + IRRef ref; + for (ref = J->chain[IR_KINT]; ref; ref = cir[ref].prev) + if (cir[ref].i == k) + goto found; + ref = ir_nextk(J); + ir = IR(ref); + ir->i = k; + ir->t.irt = IRT_INT; + ir->o = IR_KINT; + ir->prev = J->chain[IR_KINT]; + J->chain[IR_KINT] = (IRRef1)ref; +found: + return TREF(ref, IRT_INT); +} + +/* The MRef inside the KNUM/KINT64 IR instructions holds the address of the +** 64 bit constant. The constants themselves are stored in a chained array +** and shared across traces. +** +** Rationale for choosing this data structure: +** - The address of the constants is embedded in the generated machine code +** and must never move. A resizable array or hash table wouldn't work. +** - Most apps need very few non-32 bit integer constants (less than a dozen). +** - Linear search is hard to beat in terms of speed and low complexity. +*/ +typedef struct K64Array { + MRef next; /* Pointer to next list. */ + MSize numk; /* Number of used elements in this array. */ + TValue k[LJ_MIN_K64SZ]; /* Array of constants. */ +} K64Array; + +/* Free all chained arrays. */ +void lj_ir_k64_freeall(jit_State *J) +{ + K64Array *k; + for (k = mref(J->k64, K64Array); k; ) { + K64Array *next = mref(k->next, K64Array); + lj_mem_free(J2G(J), k, sizeof(K64Array)); + k = next; + } +} + +/* Find 64 bit constant in chained array or add it. */ +cTValue *lj_ir_k64_find(jit_State *J, uint64_t u64) +{ + K64Array *k, *kp = NULL; + TValue *ntv; + MSize idx; + /* Search for the constant in the whole chain of arrays. */ + for (k = mref(J->k64, K64Array); k; k = mref(k->next, K64Array)) { + kp = k; /* Remember previous element in list. */ + for (idx = 0; idx < k->numk; idx++) { /* Search one array. */ + TValue *tv = &k->k[idx]; + if (tv->u64 == u64) /* Needed for +-0/NaN/absmask. */ + return tv; + } + } + /* Constant was not found, need to add it. */ + if (!(kp && kp->numk < LJ_MIN_K64SZ)) { /* Allocate a new array. */ + K64Array *kn = lj_mem_newt(J->L, sizeof(K64Array), K64Array); + setmref(kn->next, NULL); + kn->numk = 0; + if (kp) + setmref(kp->next, kn); /* Chain to the end of the list. */ + else + setmref(J->k64, kn); /* Link first array. */ + kp = kn; + } + ntv = &kp->k[kp->numk++]; /* Add to current array. */ + ntv->u64 = u64; + return ntv; +} + +/* Intern 64 bit constant, given by its address. */ +TRef lj_ir_k64(jit_State *J, IROp op, cTValue *tv) +{ + IRIns *ir, *cir = J->cur.ir; + IRRef ref; + IRType t = op == IR_KNUM ? IRT_NUM : IRT_I64; + for (ref = J->chain[op]; ref; ref = cir[ref].prev) + if (ir_k64(&cir[ref]) == tv) + goto found; + ref = ir_nextk(J); + ir = IR(ref); + lua_assert(checkptr32(tv)); + setmref(ir->ptr, tv); + ir->t.irt = t; + ir->o = op; + ir->prev = J->chain[op]; + J->chain[op] = (IRRef1)ref; +found: + return TREF(ref, t); +} + +/* Intern FP constant, given by its 64 bit pattern. */ +TRef lj_ir_knum_u64(jit_State *J, uint64_t u64) +{ + return lj_ir_k64(J, IR_KNUM, lj_ir_k64_find(J, u64)); +} + +/* Intern 64 bit integer constant. */ +TRef lj_ir_kint64(jit_State *J, uint64_t u64) +{ + return lj_ir_k64(J, IR_KINT64, lj_ir_k64_find(J, u64)); +} + +/* Check whether a number is int and return it. -0 is NOT considered an int. */ +static int numistrueint(lua_Number n, int32_t *kp) +{ + int32_t k = lj_num2int(n); + if (n == (lua_Number)k) { + if (kp) *kp = k; + if (k == 0) { /* Special check for -0. */ + TValue tv; + setnumV(&tv, n); + if (tv.u32.hi != 0) + return 0; + } + return 1; + } + return 0; +} + +/* Intern number as int32_t constant if possible, otherwise as FP constant. */ +TRef lj_ir_knumint(jit_State *J, lua_Number n) +{ + int32_t k; + if (numistrueint(n, &k)) + return lj_ir_kint(J, k); + else + return lj_ir_knum(J, n); +} + +/* Intern GC object "constant". */ +TRef lj_ir_kgc(jit_State *J, GCobj *o, IRType t) +{ + IRIns *ir, *cir = J->cur.ir; + IRRef ref; + lua_assert(!isdead(J2G(J), o)); + for (ref = J->chain[IR_KGC]; ref; ref = cir[ref].prev) + if (ir_kgc(&cir[ref]) == o) + goto found; + ref = ir_nextk(J); + ir = IR(ref); + /* NOBARRIER: Current trace is a GC root. */ + setgcref(ir->gcr, o); + ir->t.irt = (uint8_t)t; + ir->o = IR_KGC; + ir->prev = J->chain[IR_KGC]; + J->chain[IR_KGC] = (IRRef1)ref; +found: + return TREF(ref, t); +} + +/* Intern 32 bit pointer constant. */ +TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr) +{ + IRIns *ir, *cir = J->cur.ir; + IRRef ref; + lua_assert((void *)(intptr_t)i32ptr(ptr) == ptr); + for (ref = J->chain[op]; ref; ref = cir[ref].prev) + if (mref(cir[ref].ptr, void) == ptr) + goto found; + ref = ir_nextk(J); + ir = IR(ref); + setmref(ir->ptr, ptr); + ir->t.irt = IRT_P32; + ir->o = op; + ir->prev = J->chain[op]; + J->chain[op] = (IRRef1)ref; +found: + return TREF(ref, IRT_P32); +} + +/* Intern typed NULL constant. */ +TRef lj_ir_knull(jit_State *J, IRType t) +{ + IRIns *ir, *cir = J->cur.ir; + IRRef ref; + for (ref = J->chain[IR_KNULL]; ref; ref = cir[ref].prev) + if (irt_t(cir[ref].t) == t) + goto found; + ref = ir_nextk(J); + ir = IR(ref); + ir->i = 0; + ir->t.irt = (uint8_t)t; + ir->o = IR_KNULL; + ir->prev = J->chain[IR_KNULL]; + J->chain[IR_KNULL] = (IRRef1)ref; +found: + return TREF(ref, t); +} + +/* Intern key slot. */ +TRef lj_ir_kslot(jit_State *J, TRef key, IRRef slot) +{ + IRIns *ir, *cir = J->cur.ir; + IRRef2 op12 = IRREF2((IRRef1)key, (IRRef1)slot); + IRRef ref; + /* Const part is not touched by CSE/DCE, so 0-65535 is ok for IRMlit here. */ + lua_assert(tref_isk(key) && slot == (IRRef)(IRRef1)slot); + for (ref = J->chain[IR_KSLOT]; ref; ref = cir[ref].prev) + if (cir[ref].op12 == op12) + goto found; + ref = ir_nextk(J); + ir = IR(ref); + ir->op12 = op12; + ir->t.irt = IRT_P32; + ir->o = IR_KSLOT; + ir->prev = J->chain[IR_KSLOT]; + J->chain[IR_KSLOT] = (IRRef1)ref; +found: + return TREF(ref, IRT_P32); +} + +/* -- Access to IR constants ---------------------------------------------- */ + +/* Copy value of IR constant. */ +void lj_ir_kvalue(lua_State *L, TValue *tv, const IRIns *ir) +{ + UNUSED(L); + lua_assert(ir->o != IR_KSLOT); /* Common mistake. */ + switch (ir->o) { + case IR_KPRI: setitype(tv, irt_toitype(ir->t)); break; + case IR_KINT: setintV(tv, ir->i); break; + case IR_KGC: setgcV(L, tv, ir_kgc(ir), irt_toitype(ir->t)); break; + case IR_KPTR: case IR_KKPTR: case IR_KNULL: + setlightudV(tv, mref(ir->ptr, void)); + break; + case IR_KNUM: setnumV(tv, ir_knum(ir)->n); break; +#if LJ_HASFFI + case IR_KINT64: { + GCcdata *cd = lj_cdata_new_(L, CTID_INT64, 8); + *(uint64_t *)cdataptr(cd) = ir_kint64(ir)->u64; + setcdataV(L, tv, cd); + break; + } +#endif + default: lua_assert(0); break; + } +} + +/* -- Convert IR operand types -------------------------------------------- */ + +/* Convert from string to number. */ +TRef LJ_FASTCALL lj_ir_tonumber(jit_State *J, TRef tr) +{ + if (!tref_isnumber(tr)) { + if (tref_isstr(tr)) + tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); + else + lj_trace_err(J, LJ_TRERR_BADTYPE); + } + return tr; +} + +/* Convert from integer or string to number. */ +TRef LJ_FASTCALL lj_ir_tonum(jit_State *J, TRef tr) +{ + if (!tref_isnum(tr)) { + if (tref_isinteger(tr)) + tr = emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT); + else if (tref_isstr(tr)) + tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); + else + lj_trace_err(J, LJ_TRERR_BADTYPE); + } + return tr; +} + +/* Convert from integer or number to string. */ +TRef LJ_FASTCALL lj_ir_tostr(jit_State *J, TRef tr) +{ + if (!tref_isstr(tr)) { + if (!tref_isnumber(tr)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + tr = emitir(IRT(IR_TOSTR, IRT_STR), tr, 0); + } + return tr; +} + +/* -- Miscellaneous IR ops ------------------------------------------------ */ + +/* Evaluate numeric comparison. */ +int lj_ir_numcmp(lua_Number a, lua_Number b, IROp op) +{ + switch (op) { + case IR_EQ: return (a == b); + case IR_NE: return (a != b); + case IR_LT: return (a < b); + case IR_GE: return (a >= b); + case IR_LE: return (a <= b); + case IR_GT: return (a > b); + case IR_ULT: return !(a >= b); + case IR_UGE: return !(a < b); + case IR_ULE: return !(a > b); + case IR_UGT: return !(a <= b); + default: lua_assert(0); return 0; + } +} + +/* Evaluate string comparison. */ +int lj_ir_strcmp(GCstr *a, GCstr *b, IROp op) +{ + int res = lj_str_cmp(a, b); + switch (op) { + case IR_LT: return (res < 0); + case IR_GE: return (res >= 0); + case IR_LE: return (res <= 0); + case IR_GT: return (res > 0); + default: lua_assert(0); return 0; + } +} + +/* Rollback IR to previous state. */ +void lj_ir_rollback(jit_State *J, IRRef ref) +{ + IRRef nins = J->cur.nins; + while (nins > ref) { + IRIns *ir; + nins--; + ir = IR(nins); + J->chain[ir->o] = ir->prev; + } + J->cur.nins = nins; +} + +#undef IR +#undef fins +#undef emitir + +#endif + +``` + +`include/luajit-2.0.5/src/lj_ir.h`: + +```h +/* +** SSA IR (Intermediate Representation) format. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_IR_H +#define _LJ_IR_H + +#include "lj_obj.h" + +/* -- IR instructions ----------------------------------------------------- */ + +/* IR instruction definition. Order matters, see below. ORDER IR */ +#define IRDEF(_) \ + /* Guarded assertions. */ \ + /* Must be properly aligned to flip opposites (^1) and (un)ordered (^4). */ \ + _(LT, N , ref, ref) \ + _(GE, N , ref, ref) \ + _(LE, N , ref, ref) \ + _(GT, N , ref, ref) \ + \ + _(ULT, N , ref, ref) \ + _(UGE, N , ref, ref) \ + _(ULE, N , ref, ref) \ + _(UGT, N , ref, ref) \ + \ + _(EQ, C , ref, ref) \ + _(NE, C , ref, ref) \ + \ + _(ABC, N , ref, ref) \ + _(RETF, S , ref, ref) \ + \ + /* Miscellaneous ops. */ \ + _(NOP, N , ___, ___) \ + _(BASE, N , lit, lit) \ + _(PVAL, N , lit, ___) \ + _(GCSTEP, S , ___, ___) \ + _(HIOP, S , ref, ref) \ + _(LOOP, S , ___, ___) \ + _(USE, S , ref, ___) \ + _(PHI, S , ref, ref) \ + _(RENAME, S , ref, lit) \ + \ + /* Constants. */ \ + _(KPRI, N , ___, ___) \ + _(KINT, N , cst, ___) \ + _(KGC, N , cst, ___) \ + _(KPTR, N , cst, ___) \ + _(KKPTR, N , cst, ___) \ + _(KNULL, N , cst, ___) \ + _(KNUM, N , cst, ___) \ + _(KINT64, N , cst, ___) \ + _(KSLOT, N , ref, lit) \ + \ + /* Bit ops. */ \ + _(BNOT, N , ref, ___) \ + _(BSWAP, N , ref, ___) \ + _(BAND, C , ref, ref) \ + _(BOR, C , ref, ref) \ + _(BXOR, C , ref, ref) \ + _(BSHL, N , ref, ref) \ + _(BSHR, N , ref, ref) \ + _(BSAR, N , ref, ref) \ + _(BROL, N , ref, ref) \ + _(BROR, N , ref, ref) \ + \ + /* Arithmetic ops. ORDER ARITH */ \ + _(ADD, C , ref, ref) \ + _(SUB, N , ref, ref) \ + _(MUL, C , ref, ref) \ + _(DIV, N , ref, ref) \ + _(MOD, N , ref, ref) \ + _(POW, N , ref, ref) \ + _(NEG, N , ref, ref) \ + \ + _(ABS, N , ref, ref) \ + _(ATAN2, N , ref, ref) \ + _(LDEXP, N , ref, ref) \ + _(MIN, C , ref, ref) \ + _(MAX, C , ref, ref) \ + _(FPMATH, N , ref, lit) \ + \ + /* Overflow-checking arithmetic ops. */ \ + _(ADDOV, CW, ref, ref) \ + _(SUBOV, NW, ref, ref) \ + _(MULOV, CW, ref, ref) \ + \ + /* Memory ops. A = array, H = hash, U = upvalue, F = field, S = stack. */ \ + \ + /* Memory references. */ \ + _(AREF, R , ref, ref) \ + _(HREFK, R , ref, ref) \ + _(HREF, L , ref, ref) \ + _(NEWREF, S , ref, ref) \ + _(UREFO, LW, ref, lit) \ + _(UREFC, LW, ref, lit) \ + _(FREF, R , ref, lit) \ + _(STRREF, N , ref, ref) \ + \ + /* Loads and Stores. These must be in the same order. */ \ + _(ALOAD, L , ref, ___) \ + _(HLOAD, L , ref, ___) \ + _(ULOAD, L , ref, ___) \ + _(FLOAD, L , ref, lit) \ + _(XLOAD, L , ref, lit) \ + _(SLOAD, L , lit, lit) \ + _(VLOAD, L , ref, ___) \ + \ + _(ASTORE, S , ref, ref) \ + _(HSTORE, S , ref, ref) \ + _(USTORE, S , ref, ref) \ + _(FSTORE, S , ref, ref) \ + _(XSTORE, S , ref, ref) \ + \ + /* Allocations. */ \ + _(SNEW, N , ref, ref) /* CSE is ok, not marked as A. */ \ + _(XSNEW, A , ref, ref) \ + _(TNEW, AW, lit, lit) \ + _(TDUP, AW, ref, ___) \ + _(CNEW, AW, ref, ref) \ + _(CNEWI, NW, ref, ref) /* CSE is ok, not marked as A. */ \ + \ + /* Barriers. */ \ + _(TBAR, S , ref, ___) \ + _(OBAR, S , ref, ref) \ + _(XBAR, S , ___, ___) \ + \ + /* Type conversions. */ \ + _(CONV, NW, ref, lit) \ + _(TOBIT, N , ref, ref) \ + _(TOSTR, N , ref, ___) \ + _(STRTO, N , ref, ___) \ + \ + /* Calls. */ \ + _(CALLN, N , ref, lit) \ + _(CALLL, L , ref, lit) \ + _(CALLS, S , ref, lit) \ + _(CALLXS, S , ref, ref) \ + _(CARG, N , ref, ref) \ + \ + /* End of list. */ + +/* IR opcodes (max. 256). */ +typedef enum { +#define IRENUM(name, m, m1, m2) IR_##name, +IRDEF(IRENUM) +#undef IRENUM + IR__MAX +} IROp; + +/* Stored opcode. */ +typedef uint8_t IROp1; + +LJ_STATIC_ASSERT(((int)IR_EQ^1) == (int)IR_NE); +LJ_STATIC_ASSERT(((int)IR_LT^1) == (int)IR_GE); +LJ_STATIC_ASSERT(((int)IR_LE^1) == (int)IR_GT); +LJ_STATIC_ASSERT(((int)IR_LT^3) == (int)IR_GT); +LJ_STATIC_ASSERT(((int)IR_LT^4) == (int)IR_ULT); + +/* Delta between xLOAD and xSTORE. */ +#define IRDELTA_L2S ((int)IR_ASTORE - (int)IR_ALOAD) + +LJ_STATIC_ASSERT((int)IR_HLOAD + IRDELTA_L2S == (int)IR_HSTORE); +LJ_STATIC_ASSERT((int)IR_ULOAD + IRDELTA_L2S == (int)IR_USTORE); +LJ_STATIC_ASSERT((int)IR_FLOAD + IRDELTA_L2S == (int)IR_FSTORE); +LJ_STATIC_ASSERT((int)IR_XLOAD + IRDELTA_L2S == (int)IR_XSTORE); + +/* -- Named IR literals --------------------------------------------------- */ + +/* FPMATH sub-functions. ORDER FPM. */ +#define IRFPMDEF(_) \ + _(FLOOR) _(CEIL) _(TRUNC) /* Must be first and in this order. */ \ + _(SQRT) _(EXP) _(EXP2) _(LOG) _(LOG2) _(LOG10) \ + _(SIN) _(COS) _(TAN) \ + _(OTHER) + +typedef enum { +#define FPMENUM(name) IRFPM_##name, +IRFPMDEF(FPMENUM) +#undef FPMENUM + IRFPM__MAX +} IRFPMathOp; + +/* FLOAD fields. */ +#define IRFLDEF(_) \ + _(STR_LEN, offsetof(GCstr, len)) \ + _(FUNC_ENV, offsetof(GCfunc, l.env)) \ + _(FUNC_PC, offsetof(GCfunc, l.pc)) \ + _(TAB_META, offsetof(GCtab, metatable)) \ + _(TAB_ARRAY, offsetof(GCtab, array)) \ + _(TAB_NODE, offsetof(GCtab, node)) \ + _(TAB_ASIZE, offsetof(GCtab, asize)) \ + _(TAB_HMASK, offsetof(GCtab, hmask)) \ + _(TAB_NOMM, offsetof(GCtab, nomm)) \ + _(UDATA_META, offsetof(GCudata, metatable)) \ + _(UDATA_UDTYPE, offsetof(GCudata, udtype)) \ + _(UDATA_FILE, sizeof(GCudata)) \ + _(CDATA_CTYPEID, offsetof(GCcdata, ctypeid)) \ + _(CDATA_PTR, sizeof(GCcdata)) \ + _(CDATA_INT, sizeof(GCcdata)) \ + _(CDATA_INT64, sizeof(GCcdata)) \ + _(CDATA_INT64_4, sizeof(GCcdata) + 4) + +typedef enum { +#define FLENUM(name, ofs) IRFL_##name, +IRFLDEF(FLENUM) +#undef FLENUM + IRFL__MAX +} IRFieldID; + +/* SLOAD mode bits, stored in op2. */ +#define IRSLOAD_PARENT 0x01 /* Coalesce with parent trace. */ +#define IRSLOAD_FRAME 0x02 /* Load hiword of frame. */ +#define IRSLOAD_TYPECHECK 0x04 /* Needs type check. */ +#define IRSLOAD_CONVERT 0x08 /* Number to integer conversion. */ +#define IRSLOAD_READONLY 0x10 /* Read-only, omit slot store. */ +#define IRSLOAD_INHERIT 0x20 /* Inherited by exits/side traces. */ + +/* XLOAD mode, stored in op2. */ +#define IRXLOAD_READONLY 1 /* Load from read-only data. */ +#define IRXLOAD_VOLATILE 2 /* Load from volatile data. */ +#define IRXLOAD_UNALIGNED 4 /* Unaligned load. */ + +/* CONV mode, stored in op2. */ +#define IRCONV_SRCMASK 0x001f /* Source IRType. */ +#define IRCONV_DSTMASK 0x03e0 /* Dest. IRType (also in ir->t). */ +#define IRCONV_DSH 5 +#define IRCONV_NUM_INT ((IRT_NUM<>2)&3)) +#define irm_iscomm(m) ((m) & IRM_C) +#define irm_kind(m) ((m) & IRM_S) + +#define IRMODE(name, m, m1, m2) (((IRM##m1)|((IRM##m2)<<2)|(IRM_##m))^IRM_W), + +LJ_DATA const uint8_t lj_ir_mode[IR__MAX+1]; + +/* -- IR instruction types ------------------------------------------------ */ + +/* Map of itypes to non-negative numbers. ORDER LJ_T. +** LJ_TUPVAL/LJ_TTRACE never appear in a TValue. Use these itypes for +** IRT_P32 and IRT_P64, which never escape the IR. +** The various integers are only used in the IR and can only escape to +** a TValue after implicit or explicit conversion. Their types must be +** contiguous and next to IRT_NUM (see the typerange macros below). +*/ +#define IRTDEF(_) \ + _(NIL, 4) _(FALSE, 4) _(TRUE, 4) _(LIGHTUD, LJ_64 ? 8 : 4) _(STR, 4) \ + _(P32, 4) _(THREAD, 4) _(PROTO, 4) _(FUNC, 4) _(P64, 8) _(CDATA, 4) \ + _(TAB, 4) _(UDATA, 4) \ + _(FLOAT, 4) _(NUM, 8) _(I8, 1) _(U8, 1) _(I16, 2) _(U16, 2) \ + _(INT, 4) _(U32, 4) _(I64, 8) _(U64, 8) \ + _(SOFTFP, 4) /* There is room for 9 more types. */ + +/* IR result type and flags (8 bit). */ +typedef enum { +#define IRTENUM(name, size) IRT_##name, +IRTDEF(IRTENUM) +#undef IRTENUM + IRT__MAX, + + /* Native pointer type and the corresponding integer type. */ + IRT_PTR = LJ_64 ? IRT_P64 : IRT_P32, + IRT_INTP = LJ_64 ? IRT_I64 : IRT_INT, + IRT_UINTP = LJ_64 ? IRT_U64 : IRT_U32, + + /* Additional flags. */ + IRT_MARK = 0x20, /* Marker for misc. purposes. */ + IRT_ISPHI = 0x40, /* Instruction is left or right PHI operand. */ + IRT_GUARD = 0x80, /* Instruction is a guard. */ + + /* Masks. */ + IRT_TYPE = 0x1f, + IRT_T = 0xff +} IRType; + +#define irtype_ispri(irt) ((uint32_t)(irt) <= IRT_TRUE) + +/* Stored IRType. */ +typedef struct IRType1 { uint8_t irt; } IRType1; + +#define IRT(o, t) ((uint32_t)(((o)<<8) | (t))) +#define IRTI(o) (IRT((o), IRT_INT)) +#define IRTN(o) (IRT((o), IRT_NUM)) +#define IRTG(o, t) (IRT((o), IRT_GUARD|(t))) +#define IRTGI(o) (IRT((o), IRT_GUARD|IRT_INT)) + +#define irt_t(t) ((IRType)(t).irt) +#define irt_type(t) ((IRType)((t).irt & IRT_TYPE)) +#define irt_sametype(t1, t2) ((((t1).irt ^ (t2).irt) & IRT_TYPE) == 0) +#define irt_typerange(t, first, last) \ + ((uint32_t)((t).irt & IRT_TYPE) - (uint32_t)(first) <= (uint32_t)(last-first)) + +#define irt_isnil(t) (irt_type(t) == IRT_NIL) +#define irt_ispri(t) ((uint32_t)irt_type(t) <= IRT_TRUE) +#define irt_islightud(t) (irt_type(t) == IRT_LIGHTUD) +#define irt_isstr(t) (irt_type(t) == IRT_STR) +#define irt_istab(t) (irt_type(t) == IRT_TAB) +#define irt_iscdata(t) (irt_type(t) == IRT_CDATA) +#define irt_isfloat(t) (irt_type(t) == IRT_FLOAT) +#define irt_isnum(t) (irt_type(t) == IRT_NUM) +#define irt_isint(t) (irt_type(t) == IRT_INT) +#define irt_isi8(t) (irt_type(t) == IRT_I8) +#define irt_isu8(t) (irt_type(t) == IRT_U8) +#define irt_isi16(t) (irt_type(t) == IRT_I16) +#define irt_isu16(t) (irt_type(t) == IRT_U16) +#define irt_isu32(t) (irt_type(t) == IRT_U32) +#define irt_isi64(t) (irt_type(t) == IRT_I64) +#define irt_isu64(t) (irt_type(t) == IRT_U64) + +#define irt_isfp(t) (irt_isnum(t) || irt_isfloat(t)) +#define irt_isinteger(t) (irt_typerange((t), IRT_I8, IRT_INT)) +#define irt_isgcv(t) (irt_typerange((t), IRT_STR, IRT_UDATA)) +#define irt_isaddr(t) (irt_typerange((t), IRT_LIGHTUD, IRT_UDATA)) +#define irt_isint64(t) (irt_typerange((t), IRT_I64, IRT_U64)) + +#if LJ_64 +#define IRT_IS64 \ + ((1u<> irt_type(t)) & 1) +#define irt_is64orfp(t) (((IRT_IS64|(1u<>irt_type(t)) & 1) + +#define irt_size(t) (lj_ir_type_size[irt_t((t))]) + +LJ_DATA const uint8_t lj_ir_type_size[]; + +static LJ_AINLINE IRType itype2irt(const TValue *tv) +{ + if (tvisint(tv)) + return IRT_INT; + else if (tvisnum(tv)) + return IRT_NUM; +#if LJ_64 + else if (tvislightud(tv)) + return IRT_LIGHTUD; +#endif + else + return (IRType)~itype(tv); +} + +static LJ_AINLINE uint32_t irt_toitype_(IRType t) +{ + lua_assert(!LJ_64 || t != IRT_LIGHTUD); + if (LJ_DUALNUM && t > IRT_NUM) { + return LJ_TISNUM; + } else { + lua_assert(t <= IRT_NUM); + return ~(uint32_t)t; + } +} + +#define irt_toitype(t) irt_toitype_(irt_type((t))) + +#define irt_isguard(t) ((t).irt & IRT_GUARD) +#define irt_ismarked(t) ((t).irt & IRT_MARK) +#define irt_setmark(t) ((t).irt |= IRT_MARK) +#define irt_clearmark(t) ((t).irt &= ~IRT_MARK) +#define irt_isphi(t) ((t).irt & IRT_ISPHI) +#define irt_setphi(t) ((t).irt |= IRT_ISPHI) +#define irt_clearphi(t) ((t).irt &= ~IRT_ISPHI) + +/* Stored combined IR opcode and type. */ +typedef uint16_t IROpT; + +/* -- IR references ------------------------------------------------------- */ + +/* IR references. */ +typedef uint16_t IRRef1; /* One stored reference. */ +typedef uint32_t IRRef2; /* Two stored references. */ +typedef uint32_t IRRef; /* Used to pass around references. */ + +/* Fixed references. */ +enum { + REF_BIAS = 0x8000, + REF_TRUE = REF_BIAS-3, + REF_FALSE = REF_BIAS-2, + REF_NIL = REF_BIAS-1, /* \--- Constants grow downwards. */ + REF_BASE = REF_BIAS, /* /--- IR grows upwards. */ + REF_FIRST = REF_BIAS+1, + REF_DROP = 0xffff +}; + +/* Note: IRMlit operands must be < REF_BIAS, too! +** This allows for fast and uniform manipulation of all operands +** without looking up the operand mode in lj_ir_mode: +** - CSE calculates the maximum reference of two operands. +** This must work with mixed reference/literal operands, too. +** - DCE marking only checks for operand >= REF_BIAS. +** - LOOP needs to substitute reference operands. +** Constant references and literals must not be modified. +*/ + +#define IRREF2(lo, hi) ((IRRef2)(lo) | ((IRRef2)(hi) << 16)) + +#define irref_isk(ref) ((ref) < REF_BIAS) + +/* Tagged IR references (32 bit). +** +** +-------+-------+---------------+ +** | irt | flags | ref | +** +-------+-------+---------------+ +** +** The tag holds a copy of the IRType and speeds up IR type checks. +*/ +typedef uint32_t TRef; + +#define TREF_REFMASK 0x0000ffff +#define TREF_FRAME 0x00010000 +#define TREF_CONT 0x00020000 + +#define TREF(ref, t) ((TRef)((ref) + ((t)<<24))) + +#define tref_ref(tr) ((IRRef1)(tr)) +#define tref_t(tr) ((IRType)((tr)>>24)) +#define tref_type(tr) ((IRType)(((tr)>>24) & IRT_TYPE)) +#define tref_typerange(tr, first, last) \ + ((((tr)>>24) & IRT_TYPE) - (TRef)(first) <= (TRef)(last-first)) + +#define tref_istype(tr, t) (((tr) & (IRT_TYPE<<24)) == ((t)<<24)) +#define tref_isnil(tr) (tref_istype((tr), IRT_NIL)) +#define tref_isfalse(tr) (tref_istype((tr), IRT_FALSE)) +#define tref_istrue(tr) (tref_istype((tr), IRT_TRUE)) +#define tref_isstr(tr) (tref_istype((tr), IRT_STR)) +#define tref_isfunc(tr) (tref_istype((tr), IRT_FUNC)) +#define tref_iscdata(tr) (tref_istype((tr), IRT_CDATA)) +#define tref_istab(tr) (tref_istype((tr), IRT_TAB)) +#define tref_isudata(tr) (tref_istype((tr), IRT_UDATA)) +#define tref_isnum(tr) (tref_istype((tr), IRT_NUM)) +#define tref_isint(tr) (tref_istype((tr), IRT_INT)) + +#define tref_isbool(tr) (tref_typerange((tr), IRT_FALSE, IRT_TRUE)) +#define tref_ispri(tr) (tref_typerange((tr), IRT_NIL, IRT_TRUE)) +#define tref_istruecond(tr) (!tref_typerange((tr), IRT_NIL, IRT_FALSE)) +#define tref_isinteger(tr) (tref_typerange((tr), IRT_I8, IRT_INT)) +#define tref_isnumber(tr) (tref_typerange((tr), IRT_NUM, IRT_INT)) +#define tref_isnumber_str(tr) (tref_isnumber((tr)) || tref_isstr((tr))) +#define tref_isgcv(tr) (tref_typerange((tr), IRT_STR, IRT_UDATA)) + +#define tref_isk(tr) (irref_isk(tref_ref((tr)))) +#define tref_isk2(tr1, tr2) (irref_isk(tref_ref((tr1) | (tr2)))) + +#define TREF_PRI(t) (TREF(REF_NIL-(t), (t))) +#define TREF_NIL (TREF_PRI(IRT_NIL)) +#define TREF_FALSE (TREF_PRI(IRT_FALSE)) +#define TREF_TRUE (TREF_PRI(IRT_TRUE)) + +/* -- IR format ----------------------------------------------------------- */ + +/* IR instruction format (64 bit). +** +** 16 16 8 8 8 8 +** +-------+-------+---+---+---+---+ +** | op1 | op2 | t | o | r | s | +** +-------+-------+---+---+---+---+ +** | op12/i/gco | ot | prev | (alternative fields in union) +** +---------------+-------+-------+ +** 32 16 16 +** +** prev is only valid prior to register allocation and then reused for r + s. +*/ + +typedef union IRIns { + struct { + LJ_ENDIAN_LOHI( + IRRef1 op1; /* IR operand 1. */ + , IRRef1 op2; /* IR operand 2. */ + ) + IROpT ot; /* IR opcode and type (overlaps t and o). */ + IRRef1 prev; /* Previous ins in same chain (overlaps r and s). */ + }; + struct { + IRRef2 op12; /* IR operand 1 and 2 (overlaps op1 and op2). */ + LJ_ENDIAN_LOHI( + IRType1 t; /* IR type. */ + , IROp1 o; /* IR opcode. */ + ) + LJ_ENDIAN_LOHI( + uint8_t r; /* Register allocation (overlaps prev). */ + , uint8_t s; /* Spill slot allocation (overlaps prev). */ + ) + }; + int32_t i; /* 32 bit signed integer literal (overlaps op12). */ + GCRef gcr; /* GCobj constant (overlaps op12). */ + MRef ptr; /* Pointer constant (overlaps op12). */ +} IRIns; + +#define ir_kgc(ir) check_exp((ir)->o == IR_KGC, gcref((ir)->gcr)) +#define ir_kstr(ir) (gco2str(ir_kgc((ir)))) +#define ir_ktab(ir) (gco2tab(ir_kgc((ir)))) +#define ir_kfunc(ir) (gco2func(ir_kgc((ir)))) +#define ir_kcdata(ir) (gco2cd(ir_kgc((ir)))) +#define ir_knum(ir) check_exp((ir)->o == IR_KNUM, mref((ir)->ptr, cTValue)) +#define ir_kint64(ir) check_exp((ir)->o == IR_KINT64, mref((ir)->ptr,cTValue)) +#define ir_k64(ir) \ + check_exp((ir)->o == IR_KNUM || (ir)->o == IR_KINT64, mref((ir)->ptr,cTValue)) +#define ir_kptr(ir) \ + check_exp((ir)->o == IR_KPTR || (ir)->o == IR_KKPTR, mref((ir)->ptr, void)) + +/* A store or any other op with a non-weak guard has a side-effect. */ +static LJ_AINLINE int ir_sideeff(IRIns *ir) +{ + return (((ir->t.irt | ~IRT_GUARD) & lj_ir_mode[ir->o]) >= IRM_S); +} + +LJ_STATIC_ASSERT((int)IRT_GUARD == (int)IRM_W); + +#endif + +``` + +`include/luajit-2.0.5/src/lj_ircall.h`: + +```h +/* +** IR CALL* instruction definitions. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_IRCALL_H +#define _LJ_IRCALL_H + +#include "lj_obj.h" +#include "lj_ir.h" +#include "lj_jit.h" + +/* C call info for CALL* instructions. */ +typedef struct CCallInfo { + ASMFunction func; /* Function pointer. */ + uint32_t flags; /* Number of arguments and flags. */ +} CCallInfo; + +#define CCI_NARGS(ci) ((ci)->flags & 0xff) /* Extract # of args. */ +#define CCI_NARGS_MAX 32 /* Max. # of args. */ + +#define CCI_OTSHIFT 16 +#define CCI_OPTYPE(ci) ((ci)->flags >> CCI_OTSHIFT) /* Get op/type. */ +#define CCI_OPSHIFT 24 +#define CCI_OP(ci) ((ci)->flags >> CCI_OPSHIFT) /* Get op. */ + +#define CCI_CALL_N (IR_CALLN << CCI_OPSHIFT) +#define CCI_CALL_L (IR_CALLL << CCI_OPSHIFT) +#define CCI_CALL_S (IR_CALLS << CCI_OPSHIFT) +#define CCI_CALL_FN (CCI_CALL_N|CCI_CC_FASTCALL) +#define CCI_CALL_FL (CCI_CALL_L|CCI_CC_FASTCALL) +#define CCI_CALL_FS (CCI_CALL_S|CCI_CC_FASTCALL) + +/* C call info flags. */ +#define CCI_L 0x0100 /* Implicit L arg. */ +#define CCI_CASTU64 0x0200 /* Cast u64 result to number. */ +#define CCI_NOFPRCLOBBER 0x0400 /* Does not clobber any FPRs. */ +#define CCI_VARARG 0x0800 /* Vararg function. */ + +#define CCI_CC_MASK 0x3000 /* Calling convention mask. */ +#define CCI_CC_SHIFT 12 +/* ORDER CC */ +#define CCI_CC_CDECL 0x0000 /* Default cdecl calling convention. */ +#define CCI_CC_THISCALL 0x1000 /* Thiscall calling convention. */ +#define CCI_CC_FASTCALL 0x2000 /* Fastcall calling convention. */ +#define CCI_CC_STDCALL 0x3000 /* Stdcall calling convention. */ + +/* Helpers for conditional function definitions. */ +#define IRCALLCOND_ANY(x) x + +#if LJ_TARGET_X86ORX64 +#define IRCALLCOND_FPMATH(x) NULL +#else +#define IRCALLCOND_FPMATH(x) x +#endif + +#if LJ_SOFTFP +#define IRCALLCOND_SOFTFP(x) x +#if LJ_HASFFI +#define IRCALLCOND_SOFTFP_FFI(x) x +#else +#define IRCALLCOND_SOFTFP_FFI(x) NULL +#endif +#else +#define IRCALLCOND_SOFTFP(x) NULL +#define IRCALLCOND_SOFTFP_FFI(x) NULL +#endif + +#define LJ_NEED_FP64 (LJ_TARGET_ARM || LJ_TARGET_PPC || LJ_TARGET_MIPS) + +#if LJ_HASFFI && (LJ_SOFTFP || LJ_NEED_FP64) +#define IRCALLCOND_FP64_FFI(x) x +#else +#define IRCALLCOND_FP64_FFI(x) NULL +#endif + +#if LJ_HASFFI +#define IRCALLCOND_FFI(x) x +#if LJ_32 +#define IRCALLCOND_FFI32(x) x +#else +#define IRCALLCOND_FFI32(x) NULL +#endif +#else +#define IRCALLCOND_FFI(x) NULL +#define IRCALLCOND_FFI32(x) NULL +#endif + +#if LJ_SOFTFP +#define ARG1_FP 2 /* Treat as 2 32 bit arguments. */ +#else +#define ARG1_FP 1 +#endif + +#if LJ_32 +#define ARG2_64 4 /* Treat as 4 32 bit arguments. */ +#else +#define ARG2_64 2 +#endif + +/* Function definitions for CALL* instructions. */ +#define IRCALLDEF(_) \ + _(ANY, lj_str_cmp, 2, FN, INT, CCI_NOFPRCLOBBER) \ + _(ANY, lj_str_new, 3, S, STR, CCI_L) \ + _(ANY, lj_strscan_num, 2, FN, INT, 0) \ + _(ANY, lj_str_fromint, 2, FN, STR, CCI_L) \ + _(ANY, lj_str_fromnum, 2, FN, STR, CCI_L) \ + _(ANY, lj_tab_new1, 2, FS, TAB, CCI_L) \ + _(ANY, lj_tab_dup, 2, FS, TAB, CCI_L) \ + _(ANY, lj_tab_newkey, 3, S, P32, CCI_L) \ + _(ANY, lj_tab_len, 1, FL, INT, 0) \ + _(ANY, lj_gc_step_jit, 2, FS, NIL, CCI_L) \ + _(ANY, lj_gc_barrieruv, 2, FS, NIL, 0) \ + _(ANY, lj_mem_newgco, 2, FS, P32, CCI_L) \ + _(ANY, lj_math_random_step, 1, FS, NUM, CCI_CASTU64) \ + _(ANY, lj_vm_modi, 2, FN, INT, 0) \ + _(ANY, sinh, ARG1_FP, N, NUM, 0) \ + _(ANY, cosh, ARG1_FP, N, NUM, 0) \ + _(ANY, tanh, ARG1_FP, N, NUM, 0) \ + _(ANY, fputc, 2, S, INT, 0) \ + _(ANY, fwrite, 4, S, INT, 0) \ + _(ANY, fflush, 1, S, INT, 0) \ + /* ORDER FPM */ \ + _(FPMATH, lj_vm_floor, ARG1_FP, N, NUM, 0) \ + _(FPMATH, lj_vm_ceil, ARG1_FP, N, NUM, 0) \ + _(FPMATH, lj_vm_trunc, ARG1_FP, N, NUM, 0) \ + _(FPMATH, sqrt, ARG1_FP, N, NUM, 0) \ + _(FPMATH, exp, ARG1_FP, N, NUM, 0) \ + _(FPMATH, lj_vm_exp2, ARG1_FP, N, NUM, 0) \ + _(FPMATH, log, ARG1_FP, N, NUM, 0) \ + _(FPMATH, lj_vm_log2, ARG1_FP, N, NUM, 0) \ + _(FPMATH, log10, ARG1_FP, N, NUM, 0) \ + _(FPMATH, sin, ARG1_FP, N, NUM, 0) \ + _(FPMATH, cos, ARG1_FP, N, NUM, 0) \ + _(FPMATH, tan, ARG1_FP, N, NUM, 0) \ + _(FPMATH, lj_vm_powi, ARG1_FP+1, N, NUM, 0) \ + _(FPMATH, pow, ARG1_FP*2, N, NUM, 0) \ + _(FPMATH, atan2, ARG1_FP*2, N, NUM, 0) \ + _(FPMATH, ldexp, ARG1_FP+1, N, NUM, 0) \ + _(SOFTFP, lj_vm_tobit, 2, N, INT, 0) \ + _(SOFTFP, softfp_add, 4, N, NUM, 0) \ + _(SOFTFP, softfp_sub, 4, N, NUM, 0) \ + _(SOFTFP, softfp_mul, 4, N, NUM, 0) \ + _(SOFTFP, softfp_div, 4, N, NUM, 0) \ + _(SOFTFP, softfp_cmp, 4, N, NIL, 0) \ + _(SOFTFP, softfp_i2d, 1, N, NUM, 0) \ + _(SOFTFP, softfp_d2i, 2, N, INT, 0) \ + _(SOFTFP_FFI, softfp_ui2d, 1, N, NUM, 0) \ + _(SOFTFP_FFI, softfp_f2d, 1, N, NUM, 0) \ + _(SOFTFP_FFI, softfp_d2ui, 2, N, INT, 0) \ + _(SOFTFP_FFI, softfp_d2f, 2, N, FLOAT, 0) \ + _(SOFTFP_FFI, softfp_i2f, 1, N, FLOAT, 0) \ + _(SOFTFP_FFI, softfp_ui2f, 1, N, FLOAT, 0) \ + _(SOFTFP_FFI, softfp_f2i, 1, N, INT, 0) \ + _(SOFTFP_FFI, softfp_f2ui, 1, N, INT, 0) \ + _(FP64_FFI, fp64_l2d, 2, N, NUM, 0) \ + _(FP64_FFI, fp64_ul2d, 2, N, NUM, 0) \ + _(FP64_FFI, fp64_l2f, 2, N, FLOAT, 0) \ + _(FP64_FFI, fp64_ul2f, 2, N, FLOAT, 0) \ + _(FP64_FFI, fp64_d2l, ARG1_FP, N, I64, 0) \ + _(FP64_FFI, fp64_d2ul, ARG1_FP, N, U64, 0) \ + _(FP64_FFI, fp64_f2l, 1, N, I64, 0) \ + _(FP64_FFI, fp64_f2ul, 1, N, U64, 0) \ + _(FFI, lj_carith_divi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \ + _(FFI, lj_carith_divu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \ + _(FFI, lj_carith_modi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \ + _(FFI, lj_carith_modu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \ + _(FFI, lj_carith_powi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \ + _(FFI, lj_carith_powu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \ + _(FFI, lj_cdata_setfin, 2, FN, P32, CCI_L) \ + _(FFI, strlen, 1, L, INTP, 0) \ + _(FFI, memcpy, 3, S, PTR, 0) \ + _(FFI, memset, 3, S, PTR, 0) \ + _(FFI, lj_vm_errno, 0, S, INT, CCI_NOFPRCLOBBER) \ + _(FFI32, lj_carith_mul64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) + \ + /* End of list. */ + +typedef enum { +#define IRCALLENUM(cond, name, nargs, kind, type, flags) IRCALL_##name, +IRCALLDEF(IRCALLENUM) +#undef IRCALLENUM + IRCALL__MAX +} IRCallID; + +LJ_FUNC TRef lj_ir_call(jit_State *J, IRCallID id, ...); + +LJ_DATA const CCallInfo lj_ir_callinfo[IRCALL__MAX+1]; + +/* Soft-float declarations. */ +#if LJ_SOFTFP +#if LJ_TARGET_ARM +#define softfp_add __aeabi_dadd +#define softfp_sub __aeabi_dsub +#define softfp_mul __aeabi_dmul +#define softfp_div __aeabi_ddiv +#define softfp_cmp __aeabi_cdcmple +#define softfp_i2d __aeabi_i2d +#define softfp_d2i __aeabi_d2iz +#define softfp_ui2d __aeabi_ui2d +#define softfp_f2d __aeabi_f2d +#define softfp_d2ui __aeabi_d2uiz +#define softfp_d2f __aeabi_d2f +#define softfp_i2f __aeabi_i2f +#define softfp_ui2f __aeabi_ui2f +#define softfp_f2i __aeabi_f2iz +#define softfp_f2ui __aeabi_f2uiz +#define fp64_l2d __aeabi_l2d +#define fp64_ul2d __aeabi_ul2d +#define fp64_l2f __aeabi_l2f +#define fp64_ul2f __aeabi_ul2f +#if LJ_TARGET_IOS +#define fp64_d2l __fixdfdi +#define fp64_d2ul __fixunsdfdi +#define fp64_f2l __fixsfdi +#define fp64_f2ul __fixunssfdi +#else +#define fp64_d2l __aeabi_d2lz +#define fp64_d2ul __aeabi_d2ulz +#define fp64_f2l __aeabi_f2lz +#define fp64_f2ul __aeabi_f2ulz +#endif +#else +#error "Missing soft-float definitions for target architecture" +#endif +extern double softfp_add(double a, double b); +extern double softfp_sub(double a, double b); +extern double softfp_mul(double a, double b); +extern double softfp_div(double a, double b); +extern void softfp_cmp(double a, double b); +extern double softfp_i2d(int32_t a); +extern int32_t softfp_d2i(double a); +#if LJ_HASFFI +extern double softfp_ui2d(uint32_t a); +extern double softfp_f2d(float a); +extern uint32_t softfp_d2ui(double a); +extern float softfp_d2f(double a); +extern float softfp_i2f(int32_t a); +extern float softfp_ui2f(uint32_t a); +extern int32_t softfp_f2i(float a); +extern uint32_t softfp_f2ui(float a); +#endif +#endif + +#if LJ_HASFFI && LJ_NEED_FP64 && !(LJ_TARGET_ARM && LJ_SOFTFP) +#ifdef __GNUC__ +#define fp64_l2d __floatdidf +#define fp64_ul2d __floatundidf +#define fp64_l2f __floatdisf +#define fp64_ul2f __floatundisf +#define fp64_d2l __fixdfdi +#define fp64_d2ul __fixunsdfdi +#define fp64_f2l __fixsfdi +#define fp64_f2ul __fixunssfdi +#else +#error "Missing fp64 helper definitions for this compiler" +#endif +#endif + +#if LJ_HASFFI && (LJ_SOFTFP || LJ_NEED_FP64) +extern double fp64_l2d(int64_t a); +extern double fp64_ul2d(uint64_t a); +extern float fp64_l2f(int64_t a); +extern float fp64_ul2f(uint64_t a); +extern int64_t fp64_d2l(double a); +extern uint64_t fp64_d2ul(double a); +extern int64_t fp64_f2l(float a); +extern uint64_t fp64_f2ul(float a); +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_iropt.h`: + +```h +/* +** Common header for IR emitter and optimizations. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_IROPT_H +#define _LJ_IROPT_H + +#include + +#include "lj_obj.h" +#include "lj_jit.h" + +#if LJ_HASJIT +/* IR emitter. */ +LJ_FUNC void LJ_FASTCALL lj_ir_growtop(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_ir_emit(jit_State *J); + +/* Save current IR in J->fold.ins, but do not emit it (yet). */ +static LJ_AINLINE void lj_ir_set_(jit_State *J, uint16_t ot, IRRef1 a, IRRef1 b) +{ + J->fold.ins.ot = ot; J->fold.ins.op1 = a; J->fold.ins.op2 = b; +} + +#define lj_ir_set(J, ot, a, b) \ + lj_ir_set_(J, (uint16_t)(ot), (IRRef1)(a), (IRRef1)(b)) + +/* Get ref of next IR instruction and optionally grow IR. +** Note: this may invalidate all IRIns*! +*/ +static LJ_AINLINE IRRef lj_ir_nextins(jit_State *J) +{ + IRRef ref = J->cur.nins; + if (LJ_UNLIKELY(ref >= J->irtoplim)) lj_ir_growtop(J); + J->cur.nins = ref + 1; + return ref; +} + +/* Interning of constants. */ +LJ_FUNC TRef LJ_FASTCALL lj_ir_kint(jit_State *J, int32_t k); +LJ_FUNC void lj_ir_k64_freeall(jit_State *J); +LJ_FUNC TRef lj_ir_k64(jit_State *J, IROp op, cTValue *tv); +LJ_FUNC cTValue *lj_ir_k64_find(jit_State *J, uint64_t u64); +LJ_FUNC TRef lj_ir_knum_u64(jit_State *J, uint64_t u64); +LJ_FUNC TRef lj_ir_knumint(jit_State *J, lua_Number n); +LJ_FUNC TRef lj_ir_kint64(jit_State *J, uint64_t u64); +LJ_FUNC TRef lj_ir_kgc(jit_State *J, GCobj *o, IRType t); +LJ_FUNC TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr); +LJ_FUNC TRef lj_ir_knull(jit_State *J, IRType t); +LJ_FUNC TRef lj_ir_kslot(jit_State *J, TRef key, IRRef slot); + +#if LJ_64 +#define lj_ir_kintp(J, k) lj_ir_kint64(J, (uint64_t)(k)) +#else +#define lj_ir_kintp(J, k) lj_ir_kint(J, (int32_t)(k)) +#endif + +static LJ_AINLINE TRef lj_ir_knum(jit_State *J, lua_Number n) +{ + TValue tv; + tv.n = n; + return lj_ir_knum_u64(J, tv.u64); +} + +#define lj_ir_kstr(J, str) lj_ir_kgc(J, obj2gco((str)), IRT_STR) +#define lj_ir_ktab(J, tab) lj_ir_kgc(J, obj2gco((tab)), IRT_TAB) +#define lj_ir_kfunc(J, func) lj_ir_kgc(J, obj2gco((func)), IRT_FUNC) +#define lj_ir_kptr(J, ptr) lj_ir_kptr_(J, IR_KPTR, (ptr)) +#define lj_ir_kkptr(J, ptr) lj_ir_kptr_(J, IR_KKPTR, (ptr)) + +/* Special FP constants. */ +#define lj_ir_knum_zero(J) lj_ir_knum_u64(J, U64x(00000000,00000000)) +#define lj_ir_knum_one(J) lj_ir_knum_u64(J, U64x(3ff00000,00000000)) +#define lj_ir_knum_tobit(J) lj_ir_knum_u64(J, U64x(43380000,00000000)) + +/* Special 128 bit SIMD constants. */ +#define lj_ir_knum_abs(J) lj_ir_k64(J, IR_KNUM, LJ_KSIMD(J, LJ_KSIMD_ABS)) +#define lj_ir_knum_neg(J) lj_ir_k64(J, IR_KNUM, LJ_KSIMD(J, LJ_KSIMD_NEG)) + +/* Access to constants. */ +LJ_FUNC void lj_ir_kvalue(lua_State *L, TValue *tv, const IRIns *ir); + +/* Convert IR operand types. */ +LJ_FUNC TRef LJ_FASTCALL lj_ir_tonumber(jit_State *J, TRef tr); +LJ_FUNC TRef LJ_FASTCALL lj_ir_tonum(jit_State *J, TRef tr); +LJ_FUNC TRef LJ_FASTCALL lj_ir_tostr(jit_State *J, TRef tr); + +/* Miscellaneous IR ops. */ +LJ_FUNC int lj_ir_numcmp(lua_Number a, lua_Number b, IROp op); +LJ_FUNC int lj_ir_strcmp(GCstr *a, GCstr *b, IROp op); +LJ_FUNC void lj_ir_rollback(jit_State *J, IRRef ref); + +/* Emit IR instructions with on-the-fly optimizations. */ +LJ_FUNC TRef LJ_FASTCALL lj_opt_fold(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_cse(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_cselim(jit_State *J, IRRef lim); + +/* Special return values for the fold functions. */ +enum { + NEXTFOLD, /* Couldn't fold, pass on. */ + RETRYFOLD, /* Retry fold with modified fins. */ + KINTFOLD, /* Return ref for int constant in fins->i. */ + FAILFOLD, /* Guard would always fail. */ + DROPFOLD, /* Guard eliminated. */ + MAX_FOLD +}; + +#define INTFOLD(k) ((J->fold.ins.i = (k)), (TRef)KINTFOLD) +#define INT64FOLD(k) (lj_ir_kint64(J, (k))) +#define CONDFOLD(cond) ((TRef)FAILFOLD + (TRef)(cond)) +#define LEFTFOLD (J->fold.ins.op1) +#define RIGHTFOLD (J->fold.ins.op2) +#define CSEFOLD (lj_opt_cse(J)) +#define EMITFOLD (lj_ir_emit(J)) + +/* Load/store forwarding. */ +LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_aload(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_hload(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_uload(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_fload(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_xload(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_tab_len(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_hrefk(jit_State *J); +LJ_FUNC int LJ_FASTCALL lj_opt_fwd_href_nokey(jit_State *J); +LJ_FUNC int LJ_FASTCALL lj_opt_fwd_tptr(jit_State *J, IRRef lim); +LJ_FUNC int lj_opt_fwd_wasnonnil(jit_State *J, IROpT loadop, IRRef xref); + +/* Dead-store elimination. */ +LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_ahstore(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_fstore(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_xstore(jit_State *J); + +/* Narrowing. */ +LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_convert(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_index(jit_State *J, TRef key); +LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_toint(jit_State *J, TRef tr); +LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_tobit(jit_State *J, TRef tr); +#if LJ_HASFFI +LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_cindex(jit_State *J, TRef key); +#endif +LJ_FUNC TRef lj_opt_narrow_arith(jit_State *J, TRef rb, TRef rc, + TValue *vb, TValue *vc, IROp op); +LJ_FUNC TRef lj_opt_narrow_unm(jit_State *J, TRef rc, TValue *vc); +LJ_FUNC TRef lj_opt_narrow_mod(jit_State *J, TRef rb, TRef rc, TValue *vb, TValue *vc); +LJ_FUNC TRef lj_opt_narrow_pow(jit_State *J, TRef rb, TRef rc, TValue *vb, TValue *vc); +LJ_FUNC IRType lj_opt_narrow_forl(jit_State *J, cTValue *forbase); + +/* Optimization passes. */ +LJ_FUNC void lj_opt_dce(jit_State *J); +LJ_FUNC int lj_opt_loop(jit_State *J); +#if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) +LJ_FUNC void lj_opt_split(jit_State *J); +#else +#define lj_opt_split(J) UNUSED(J) +#endif +LJ_FUNC void lj_opt_sink(jit_State *J); + +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_jit.h`: + +```h +/* +** Common definitions for the JIT compiler. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_JIT_H +#define _LJ_JIT_H + +#include "lj_obj.h" +#include "lj_ir.h" + +/* JIT engine flags. */ +#define JIT_F_ON 0x00000001 + +/* CPU-specific JIT engine flags. */ +#if LJ_TARGET_X86ORX64 +#define JIT_F_CMOV 0x00000010 +#define JIT_F_SSE2 0x00000020 +#define JIT_F_SSE3 0x00000040 +#define JIT_F_SSE4_1 0x00000080 +#define JIT_F_P4 0x00000100 +#define JIT_F_PREFER_IMUL 0x00000200 +#define JIT_F_SPLIT_XMM 0x00000400 +#define JIT_F_LEA_AGU 0x00000800 + +/* Names for the CPU-specific flags. Must match the order above. */ +#define JIT_F_CPU_FIRST JIT_F_CMOV +#define JIT_F_CPUSTRING "\4CMOV\4SSE2\4SSE3\6SSE4.1\2P4\3AMD\2K8\4ATOM" +#elif LJ_TARGET_ARM +#define JIT_F_ARMV6_ 0x00000010 +#define JIT_F_ARMV6T2_ 0x00000020 +#define JIT_F_ARMV7 0x00000040 +#define JIT_F_VFPV2 0x00000080 +#define JIT_F_VFPV3 0x00000100 + +#define JIT_F_ARMV6 (JIT_F_ARMV6_|JIT_F_ARMV6T2_|JIT_F_ARMV7) +#define JIT_F_ARMV6T2 (JIT_F_ARMV6T2_|JIT_F_ARMV7) +#define JIT_F_VFP (JIT_F_VFPV2|JIT_F_VFPV3) + +/* Names for the CPU-specific flags. Must match the order above. */ +#define JIT_F_CPU_FIRST JIT_F_ARMV6_ +#define JIT_F_CPUSTRING "\5ARMv6\7ARMv6T2\5ARMv7\5VFPv2\5VFPv3" +#elif LJ_TARGET_PPC +#define JIT_F_SQRT 0x00000010 +#define JIT_F_ROUND 0x00000020 + +/* Names for the CPU-specific flags. Must match the order above. */ +#define JIT_F_CPU_FIRST JIT_F_SQRT +#define JIT_F_CPUSTRING "\4SQRT\5ROUND" +#elif LJ_TARGET_MIPS +#define JIT_F_MIPS32R2 0x00000010 + +/* Names for the CPU-specific flags. Must match the order above. */ +#define JIT_F_CPU_FIRST JIT_F_MIPS32R2 +#define JIT_F_CPUSTRING "\010MIPS32R2" +#else +#define JIT_F_CPU_FIRST 0 +#define JIT_F_CPUSTRING "" +#endif + +/* Optimization flags. */ +#define JIT_F_OPT_MASK 0x0fff0000 + +#define JIT_F_OPT_FOLD 0x00010000 +#define JIT_F_OPT_CSE 0x00020000 +#define JIT_F_OPT_DCE 0x00040000 +#define JIT_F_OPT_FWD 0x00080000 +#define JIT_F_OPT_DSE 0x00100000 +#define JIT_F_OPT_NARROW 0x00200000 +#define JIT_F_OPT_LOOP 0x00400000 +#define JIT_F_OPT_ABC 0x00800000 +#define JIT_F_OPT_SINK 0x01000000 +#define JIT_F_OPT_FUSE 0x02000000 + +/* Optimizations names for -O. Must match the order above. */ +#define JIT_F_OPT_FIRST JIT_F_OPT_FOLD +#define JIT_F_OPTSTRING \ + "\4fold\3cse\3dce\3fwd\3dse\6narrow\4loop\3abc\4sink\4fuse" + +/* Optimization levels set a fixed combination of flags. */ +#define JIT_F_OPT_0 0 +#define JIT_F_OPT_1 (JIT_F_OPT_FOLD|JIT_F_OPT_CSE|JIT_F_OPT_DCE) +#define JIT_F_OPT_2 (JIT_F_OPT_1|JIT_F_OPT_NARROW|JIT_F_OPT_LOOP) +#define JIT_F_OPT_3 (JIT_F_OPT_2|\ + JIT_F_OPT_FWD|JIT_F_OPT_DSE|JIT_F_OPT_ABC|JIT_F_OPT_SINK|JIT_F_OPT_FUSE) +#define JIT_F_OPT_DEFAULT JIT_F_OPT_3 + +#if LJ_TARGET_WINDOWS || LJ_64 +/* See: http://blogs.msdn.com/oldnewthing/archive/2003/10/08/55239.aspx */ +#define JIT_P_sizemcode_DEFAULT 64 +#else +/* Could go as low as 4K, but the mmap() overhead would be rather high. */ +#define JIT_P_sizemcode_DEFAULT 32 +#endif + +/* Optimization parameters and their defaults. Length is a char in octal! */ +#define JIT_PARAMDEF(_) \ + _(\010, maxtrace, 1000) /* Max. # of traces in cache. */ \ + _(\011, maxrecord, 4000) /* Max. # of recorded IR instructions. */ \ + _(\012, maxirconst, 500) /* Max. # of IR constants of a trace. */ \ + _(\007, maxside, 100) /* Max. # of side traces of a root trace. */ \ + _(\007, maxsnap, 500) /* Max. # of snapshots for a trace. */ \ + \ + _(\007, hotloop, 56) /* # of iter. to detect a hot loop/call. */ \ + _(\007, hotexit, 10) /* # of taken exits to start a side trace. */ \ + _(\007, tryside, 4) /* # of attempts to compile a side trace. */ \ + \ + _(\012, instunroll, 4) /* Max. unroll for instable loops. */ \ + _(\012, loopunroll, 15) /* Max. unroll for loop ops in side traces. */ \ + _(\012, callunroll, 3) /* Max. unroll for recursive calls. */ \ + _(\011, recunroll, 2) /* Min. unroll for true recursion. */ \ + \ + /* Size of each machine code area (in KBytes). */ \ + _(\011, sizemcode, JIT_P_sizemcode_DEFAULT) \ + /* Max. total size of all machine code areas (in KBytes). */ \ + _(\010, maxmcode, 512) \ + /* End of list. */ + +enum { +#define JIT_PARAMENUM(len, name, value) JIT_P_##name, +JIT_PARAMDEF(JIT_PARAMENUM) +#undef JIT_PARAMENUM + JIT_P__MAX +}; + +#define JIT_PARAMSTR(len, name, value) #len #name +#define JIT_P_STRING JIT_PARAMDEF(JIT_PARAMSTR) + +/* Trace compiler state. */ +typedef enum { + LJ_TRACE_IDLE, /* Trace compiler idle. */ + LJ_TRACE_ACTIVE = 0x10, + LJ_TRACE_RECORD, /* Bytecode recording active. */ + LJ_TRACE_START, /* New trace started. */ + LJ_TRACE_END, /* End of trace. */ + LJ_TRACE_ASM, /* Assemble trace. */ + LJ_TRACE_ERR /* Trace aborted with error. */ +} TraceState; + +/* Post-processing action. */ +typedef enum { + LJ_POST_NONE, /* No action. */ + LJ_POST_FIXCOMP, /* Fixup comparison and emit pending guard. */ + LJ_POST_FIXGUARD, /* Fixup and emit pending guard. */ + LJ_POST_FIXGUARDSNAP, /* Fixup and emit pending guard and snapshot. */ + LJ_POST_FIXBOOL, /* Fixup boolean result. */ + LJ_POST_FIXCONST, /* Fixup constant results. */ + LJ_POST_FFRETRY /* Suppress recording of retried fast functions. */ +} PostProc; + +/* Machine code type. */ +#if LJ_TARGET_X86ORX64 +typedef uint8_t MCode; +#else +typedef uint32_t MCode; +#endif + +/* Stack snapshot header. */ +typedef struct SnapShot { + uint16_t mapofs; /* Offset into snapshot map. */ + IRRef1 ref; /* First IR ref for this snapshot. */ + uint8_t nslots; /* Number of valid slots. */ + uint8_t topslot; /* Maximum frame extent. */ + uint8_t nent; /* Number of compressed entries. */ + uint8_t count; /* Count of taken exits for this snapshot. */ +} SnapShot; + +#define SNAPCOUNT_DONE 255 /* Already compiled and linked a side trace. */ + +/* Compressed snapshot entry. */ +typedef uint32_t SnapEntry; + +#define SNAP_FRAME 0x010000 /* Frame slot. */ +#define SNAP_CONT 0x020000 /* Continuation slot. */ +#define SNAP_NORESTORE 0x040000 /* No need to restore slot. */ +#define SNAP_SOFTFPNUM 0x080000 /* Soft-float number. */ +LJ_STATIC_ASSERT(SNAP_FRAME == TREF_FRAME); +LJ_STATIC_ASSERT(SNAP_CONT == TREF_CONT); + +#define SNAP(slot, flags, ref) (((SnapEntry)(slot) << 24) + (flags) + (ref)) +#define SNAP_TR(slot, tr) \ + (((SnapEntry)(slot) << 24) + ((tr) & (TREF_CONT|TREF_FRAME|TREF_REFMASK))) +#define SNAP_MKPC(pc) ((SnapEntry)u32ptr(pc)) +#define SNAP_MKFTSZ(ftsz) ((SnapEntry)(ftsz)) +#define snap_ref(sn) ((sn) & 0xffff) +#define snap_slot(sn) ((BCReg)((sn) >> 24)) +#define snap_isframe(sn) ((sn) & SNAP_FRAME) +#define snap_pc(sn) ((const BCIns *)(uintptr_t)(sn)) +#define snap_setref(sn, ref) (((sn) & (0xffff0000&~SNAP_NORESTORE)) | (ref)) + +/* Snapshot and exit numbers. */ +typedef uint32_t SnapNo; +typedef uint32_t ExitNo; + +/* Trace number. */ +typedef uint32_t TraceNo; /* Used to pass around trace numbers. */ +typedef uint16_t TraceNo1; /* Stored trace number. */ + +/* Type of link. ORDER LJ_TRLINK */ +typedef enum { + LJ_TRLINK_NONE, /* Incomplete trace. No link, yet. */ + LJ_TRLINK_ROOT, /* Link to other root trace. */ + LJ_TRLINK_LOOP, /* Loop to same trace. */ + LJ_TRLINK_TAILREC, /* Tail-recursion. */ + LJ_TRLINK_UPREC, /* Up-recursion. */ + LJ_TRLINK_DOWNREC, /* Down-recursion. */ + LJ_TRLINK_INTERP, /* Fallback to interpreter. */ + LJ_TRLINK_RETURN /* Return to interpreter. */ +} TraceLink; + +/* Trace object. */ +typedef struct GCtrace { + GCHeader; + uint8_t topslot; /* Top stack slot already checked to be allocated. */ + uint8_t linktype; /* Type of link. */ + IRRef nins; /* Next IR instruction. Biased with REF_BIAS. */ + GCRef gclist; + IRIns *ir; /* IR instructions/constants. Biased with REF_BIAS. */ + IRRef nk; /* Lowest IR constant. Biased with REF_BIAS. */ + uint16_t nsnap; /* Number of snapshots. */ + uint16_t nsnapmap; /* Number of snapshot map elements. */ + SnapShot *snap; /* Snapshot array. */ + SnapEntry *snapmap; /* Snapshot map. */ + GCRef startpt; /* Starting prototype. */ + MRef startpc; /* Bytecode PC of starting instruction. */ + BCIns startins; /* Original bytecode of starting instruction. */ + MSize szmcode; /* Size of machine code. */ + MCode *mcode; /* Start of machine code. */ + MSize mcloop; /* Offset of loop start in machine code. */ + uint16_t nchild; /* Number of child traces (root trace only). */ + uint16_t spadjust; /* Stack pointer adjustment (offset in bytes). */ + TraceNo1 traceno; /* Trace number. */ + TraceNo1 link; /* Linked trace (or self for loops). */ + TraceNo1 root; /* Root trace of side trace (or 0 for root traces). */ + TraceNo1 nextroot; /* Next root trace for same prototype. */ + TraceNo1 nextside; /* Next side trace of same root trace. */ + uint8_t sinktags; /* Trace has SINK tags. */ + uint8_t unused1; +#ifdef LUAJIT_USE_GDBJIT + void *gdbjit_entry; /* GDB JIT entry. */ +#endif +} GCtrace; + +#define gco2trace(o) check_exp((o)->gch.gct == ~LJ_TTRACE, (GCtrace *)(o)) +#define traceref(J, n) \ + check_exp((n)>0 && (MSize)(n)sizetrace, (GCtrace *)gcref(J->trace[(n)])) + +LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCtrace, gclist)); + +static LJ_AINLINE MSize snap_nextofs(GCtrace *T, SnapShot *snap) +{ + if (snap+1 == &T->snap[T->nsnap]) + return T->nsnapmap; + else + return (snap+1)->mapofs; +} + +/* Round-robin penalty cache for bytecodes leading to aborted traces. */ +typedef struct HotPenalty { + MRef pc; /* Starting bytecode PC. */ + uint16_t val; /* Penalty value, i.e. hotcount start. */ + uint16_t reason; /* Abort reason (really TraceErr). */ +} HotPenalty; + +#define PENALTY_SLOTS 64 /* Penalty cache slot. Must be a power of 2. */ +#define PENALTY_MIN (36*2) /* Minimum penalty value. */ +#define PENALTY_MAX 60000 /* Maximum penalty value. */ +#define PENALTY_RNDBITS 4 /* # of random bits to add to penalty value. */ + +/* Round-robin backpropagation cache for narrowing conversions. */ +typedef struct BPropEntry { + IRRef1 key; /* Key: original reference. */ + IRRef1 val; /* Value: reference after conversion. */ + IRRef mode; /* Mode for this entry (currently IRCONV_*). */ +} BPropEntry; + +/* Number of slots for the backpropagation cache. Must be a power of 2. */ +#define BPROP_SLOTS 16 + +/* Scalar evolution analysis cache. */ +typedef struct ScEvEntry { + MRef pc; /* Bytecode PC of FORI. */ + IRRef1 idx; /* Index reference. */ + IRRef1 start; /* Constant start reference. */ + IRRef1 stop; /* Constant stop reference. */ + IRRef1 step; /* Constant step reference. */ + IRType1 t; /* Scalar type. */ + uint8_t dir; /* Direction. 1: +, 0: -. */ +} ScEvEntry; + +/* 128 bit SIMD constants. */ +enum { + LJ_KSIMD_ABS, + LJ_KSIMD_NEG, + LJ_KSIMD__MAX +}; + +/* Get 16 byte aligned pointer to SIMD constant. */ +#define LJ_KSIMD(J, n) \ + ((TValue *)(((intptr_t)&J->ksimd[2*(n)] + 15) & ~(intptr_t)15)) + +/* Set/reset flag to activate the SPLIT pass for the current trace. */ +#if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) +#define lj_needsplit(J) (J->needsplit = 1) +#define lj_resetsplit(J) (J->needsplit = 0) +#else +#define lj_needsplit(J) UNUSED(J) +#define lj_resetsplit(J) UNUSED(J) +#endif + +/* Fold state is used to fold instructions on-the-fly. */ +typedef struct FoldState { + IRIns ins; /* Currently emitted instruction. */ + IRIns left; /* Instruction referenced by left operand. */ + IRIns right; /* Instruction referenced by right operand. */ +} FoldState; + +/* JIT compiler state. */ +typedef struct jit_State { + GCtrace cur; /* Current trace. */ + + lua_State *L; /* Current Lua state. */ + const BCIns *pc; /* Current PC. */ + GCfunc *fn; /* Current function. */ + GCproto *pt; /* Current prototype. */ + TRef *base; /* Current frame base, points into J->slots. */ + + uint32_t flags; /* JIT engine flags. */ + BCReg maxslot; /* Relative to baseslot. */ + BCReg baseslot; /* Current frame base, offset into J->slots. */ + + uint8_t mergesnap; /* Allowed to merge with next snapshot. */ + uint8_t needsnap; /* Need snapshot before recording next bytecode. */ + IRType1 guardemit; /* Accumulated IRT_GUARD for emitted instructions. */ + uint8_t bcskip; /* Number of bytecode instructions to skip. */ + + FoldState fold; /* Fold state. */ + + const BCIns *bc_min; /* Start of allowed bytecode range for root trace. */ + MSize bc_extent; /* Extent of the range. */ + + TraceState state; /* Trace compiler state. */ + + int32_t instunroll; /* Unroll counter for instable loops. */ + int32_t loopunroll; /* Unroll counter for loop ops in side traces. */ + int32_t tailcalled; /* Number of successive tailcalls. */ + int32_t framedepth; /* Current frame depth. */ + int32_t retdepth; /* Return frame depth (count of RETF). */ + + MRef k64; /* Pointer to chained array of 64 bit constants. */ + TValue ksimd[LJ_KSIMD__MAX*2+1]; /* 16 byte aligned SIMD constants. */ + + IRIns *irbuf; /* Temp. IR instruction buffer. Biased with REF_BIAS. */ + IRRef irtoplim; /* Upper limit of instuction buffer (biased). */ + IRRef irbotlim; /* Lower limit of instuction buffer (biased). */ + IRRef loopref; /* Last loop reference or ref of final LOOP (or 0). */ + + MSize sizesnap; /* Size of temp. snapshot buffer. */ + SnapShot *snapbuf; /* Temp. snapshot buffer. */ + SnapEntry *snapmapbuf; /* Temp. snapshot map buffer. */ + MSize sizesnapmap; /* Size of temp. snapshot map buffer. */ + + PostProc postproc; /* Required post-processing after execution. */ +#if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) + int needsplit; /* Need SPLIT pass. */ +#endif + + GCRef *trace; /* Array of traces. */ + TraceNo freetrace; /* Start of scan for next free trace. */ + MSize sizetrace; /* Size of trace array. */ + + IRRef1 chain[IR__MAX]; /* IR instruction skip-list chain anchors. */ + TRef slot[LJ_MAX_JSLOTS+LJ_STACK_EXTRA]; /* Stack slot map. */ + + int32_t param[JIT_P__MAX]; /* JIT engine parameters. */ + + MCode *exitstubgroup[LJ_MAX_EXITSTUBGR]; /* Exit stub group addresses. */ + + HotPenalty penalty[PENALTY_SLOTS]; /* Penalty slots. */ + uint32_t penaltyslot; /* Round-robin index into penalty slots. */ + uint32_t prngstate; /* PRNG state. */ + + BPropEntry bpropcache[BPROP_SLOTS]; /* Backpropagation cache slots. */ + uint32_t bpropslot; /* Round-robin index into bpropcache slots. */ + + ScEvEntry scev; /* Scalar evolution analysis cache slots. */ + + const BCIns *startpc; /* Bytecode PC of starting instruction. */ + TraceNo parent; /* Parent of current side trace (0 for root traces). */ + ExitNo exitno; /* Exit number in parent of current side trace. */ + + BCIns *patchpc; /* PC for pending re-patch. */ + BCIns patchins; /* Instruction for pending re-patch. */ + + int mcprot; /* Protection of current mcode area. */ + MCode *mcarea; /* Base of current mcode area. */ + MCode *mctop; /* Top of current mcode area. */ + MCode *mcbot; /* Bottom of current mcode area. */ + size_t szmcarea; /* Size of current mcode area. */ + size_t szallmcarea; /* Total size of all allocated mcode areas. */ + + TValue errinfo; /* Additional info element for trace errors. */ +} +#if LJ_TARGET_ARM +LJ_ALIGN(16) /* For DISPATCH-relative addresses in assembler part. */ +#endif +jit_State; + +/* Trivial PRNG e.g. used for penalty randomization. */ +static LJ_AINLINE uint32_t LJ_PRNG_BITS(jit_State *J, int bits) +{ + /* Yes, this LCG is very weak, but that doesn't matter for our use case. */ + J->prngstate = J->prngstate * 1103515245 + 12345; + return J->prngstate >> (32-bits); +} + +#endif + +``` + +`include/luajit-2.0.5/src/lj_lex.c`: + +```c +/* +** Lexical analyzer. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_lex_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#if LJ_HASFFI +#include "lj_tab.h" +#include "lj_ctype.h" +#include "lj_cdata.h" +#include "lualib.h" +#endif +#include "lj_state.h" +#include "lj_lex.h" +#include "lj_parse.h" +#include "lj_char.h" +#include "lj_strscan.h" + +/* Lua lexer token names. */ +static const char *const tokennames[] = { +#define TKSTR1(name) #name, +#define TKSTR2(name, sym) #sym, +TKDEF(TKSTR1, TKSTR2) +#undef TKSTR1 +#undef TKSTR2 + NULL +}; + +/* -- Buffer handling ----------------------------------------------------- */ + +#define char2int(c) ((int)(uint8_t)(c)) +#define next(ls) \ + (ls->current = (ls->n--) > 0 ? char2int(*ls->p++) : fillbuf(ls)) +#define save_and_next(ls) (save(ls, ls->current), next(ls)) +#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') +#define END_OF_STREAM (-1) + +static int fillbuf(LexState *ls) +{ + size_t sz; + const char *buf = ls->rfunc(ls->L, ls->rdata, &sz); + if (buf == NULL || sz == 0) return END_OF_STREAM; + ls->n = (MSize)sz - 1; + ls->p = buf; + return char2int(*(ls->p++)); +} + +static LJ_NOINLINE void save_grow(LexState *ls, int c) +{ + MSize newsize; + if (ls->sb.sz >= LJ_MAX_STR/2) + lj_lex_error(ls, 0, LJ_ERR_XELEM); + newsize = ls->sb.sz * 2; + lj_str_resizebuf(ls->L, &ls->sb, newsize); + ls->sb.buf[ls->sb.n++] = (char)c; +} + +static LJ_AINLINE void save(LexState *ls, int c) +{ + if (LJ_UNLIKELY(ls->sb.n + 1 > ls->sb.sz)) + save_grow(ls, c); + else + ls->sb.buf[ls->sb.n++] = (char)c; +} + +static void inclinenumber(LexState *ls) +{ + int old = ls->current; + lua_assert(currIsNewline(ls)); + next(ls); /* skip `\n' or `\r' */ + if (currIsNewline(ls) && ls->current != old) + next(ls); /* skip `\n\r' or `\r\n' */ + if (++ls->linenumber >= LJ_MAX_LINE) + lj_lex_error(ls, ls->token, LJ_ERR_XLINES); +} + +/* -- Scanner for terminals ----------------------------------------------- */ + +/* Parse a number literal. */ +static void lex_number(LexState *ls, TValue *tv) +{ + StrScanFmt fmt; + int c, xp = 'e'; + lua_assert(lj_char_isdigit(ls->current)); + if ((c = ls->current) == '0') { + save_and_next(ls); + if ((ls->current | 0x20) == 'x') xp = 'p'; + } + while (lj_char_isident(ls->current) || ls->current == '.' || + ((ls->current == '-' || ls->current == '+') && (c | 0x20) == xp)) { + c = ls->current; + save_and_next(ls); + } + save(ls, '\0'); + fmt = lj_strscan_scan((const uint8_t *)ls->sb.buf, tv, + (LJ_DUALNUM ? STRSCAN_OPT_TOINT : STRSCAN_OPT_TONUM) | + (LJ_HASFFI ? (STRSCAN_OPT_LL|STRSCAN_OPT_IMAG) : 0)); + if (LJ_DUALNUM && fmt == STRSCAN_INT) { + setitype(tv, LJ_TISNUM); + } else if (fmt == STRSCAN_NUM) { + /* Already in correct format. */ +#if LJ_HASFFI + } else if (fmt != STRSCAN_ERROR) { + lua_State *L = ls->L; + GCcdata *cd; + lua_assert(fmt == STRSCAN_I64 || fmt == STRSCAN_U64 || fmt == STRSCAN_IMAG); + if (!ctype_ctsG(G(L))) { + ptrdiff_t oldtop = savestack(L, L->top); + luaopen_ffi(L); /* Load FFI library on-demand. */ + L->top = restorestack(L, oldtop); + } + if (fmt == STRSCAN_IMAG) { + cd = lj_cdata_new_(L, CTID_COMPLEX_DOUBLE, 2*sizeof(double)); + ((double *)cdataptr(cd))[0] = 0; + ((double *)cdataptr(cd))[1] = numV(tv); + } else { + cd = lj_cdata_new_(L, fmt==STRSCAN_I64 ? CTID_INT64 : CTID_UINT64, 8); + *(uint64_t *)cdataptr(cd) = tv->u64; + } + lj_parse_keepcdata(ls, tv, cd); +#endif + } else { + lua_assert(fmt == STRSCAN_ERROR); + lj_lex_error(ls, TK_number, LJ_ERR_XNUMBER); + } +} + +static int skip_sep(LexState *ls) +{ + int count = 0; + int s = ls->current; + lua_assert(s == '[' || s == ']'); + save_and_next(ls); + while (ls->current == '=') { + save_and_next(ls); + count++; + } + return (ls->current == s) ? count : (-count) - 1; +} + +static void read_long_string(LexState *ls, TValue *tv, int sep) +{ + save_and_next(ls); /* skip 2nd `[' */ + if (currIsNewline(ls)) /* string starts with a newline? */ + inclinenumber(ls); /* skip it */ + for (;;) { + switch (ls->current) { + case END_OF_STREAM: + lj_lex_error(ls, TK_eof, tv ? LJ_ERR_XLSTR : LJ_ERR_XLCOM); + break; + case ']': + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `]' */ + goto endloop; + } + break; + case '\n': + case '\r': + save(ls, '\n'); + inclinenumber(ls); + if (!tv) lj_str_resetbuf(&ls->sb); /* avoid wasting space */ + break; + default: + if (tv) save_and_next(ls); + else next(ls); + break; + } + } endloop: + if (tv) { + GCstr *str = lj_parse_keepstr(ls, ls->sb.buf + (2 + (MSize)sep), + ls->sb.n - 2*(2 + (MSize)sep)); + setstrV(ls->L, tv, str); + } +} + +static void read_string(LexState *ls, int delim, TValue *tv) +{ + save_and_next(ls); + while (ls->current != delim) { + switch (ls->current) { + case END_OF_STREAM: + lj_lex_error(ls, TK_eof, LJ_ERR_XSTR); + continue; + case '\n': + case '\r': + lj_lex_error(ls, TK_string, LJ_ERR_XSTR); + continue; + case '\\': { + int c = next(ls); /* Skip the '\\'. */ + switch (c) { + case 'a': c = '\a'; break; + case 'b': c = '\b'; break; + case 'f': c = '\f'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'v': c = '\v'; break; + case 'x': /* Hexadecimal escape '\xXX'. */ + c = (next(ls) & 15u) << 4; + if (!lj_char_isdigit(ls->current)) { + if (!lj_char_isxdigit(ls->current)) goto err_xesc; + c += 9 << 4; + } + c += (next(ls) & 15u); + if (!lj_char_isdigit(ls->current)) { + if (!lj_char_isxdigit(ls->current)) goto err_xesc; + c += 9; + } + break; + case 'z': /* Skip whitespace. */ + next(ls); + while (lj_char_isspace(ls->current)) + if (currIsNewline(ls)) inclinenumber(ls); else next(ls); + continue; + case '\n': case '\r': save(ls, '\n'); inclinenumber(ls); continue; + case '\\': case '\"': case '\'': break; + case END_OF_STREAM: continue; + default: + if (!lj_char_isdigit(c)) + goto err_xesc; + c -= '0'; /* Decimal escape '\ddd'. */ + if (lj_char_isdigit(next(ls))) { + c = c*10 + (ls->current - '0'); + if (lj_char_isdigit(next(ls))) { + c = c*10 + (ls->current - '0'); + if (c > 255) { + err_xesc: + lj_lex_error(ls, TK_string, LJ_ERR_XESC); + } + next(ls); + } + } + save(ls, c); + continue; + } + save(ls, c); + next(ls); + continue; + } + default: + save_and_next(ls); + break; + } + } + save_and_next(ls); /* skip delimiter */ + setstrV(ls->L, tv, lj_parse_keepstr(ls, ls->sb.buf + 1, ls->sb.n - 2)); +} + +/* -- Main lexical scanner ------------------------------------------------ */ + +static int llex(LexState *ls, TValue *tv) +{ + lj_str_resetbuf(&ls->sb); + for (;;) { + if (lj_char_isident(ls->current)) { + GCstr *s; + if (lj_char_isdigit(ls->current)) { /* Numeric literal. */ + lex_number(ls, tv); + return TK_number; + } + /* Identifier or reserved word. */ + do { + save_and_next(ls); + } while (lj_char_isident(ls->current)); + s = lj_parse_keepstr(ls, ls->sb.buf, ls->sb.n); + setstrV(ls->L, tv, s); + if (s->reserved > 0) /* Reserved word? */ + return TK_OFS + s->reserved; + return TK_name; + } + switch (ls->current) { + case '\n': + case '\r': + inclinenumber(ls); + continue; + case ' ': + case '\t': + case '\v': + case '\f': + next(ls); + continue; + case '-': + next(ls); + if (ls->current != '-') return '-'; + /* else is a comment */ + next(ls); + if (ls->current == '[') { + int sep = skip_sep(ls); + lj_str_resetbuf(&ls->sb); /* `skip_sep' may dirty the buffer */ + if (sep >= 0) { + read_long_string(ls, NULL, sep); /* long comment */ + lj_str_resetbuf(&ls->sb); + continue; + } + } + /* else short comment */ + while (!currIsNewline(ls) && ls->current != END_OF_STREAM) + next(ls); + continue; + case '[': { + int sep = skip_sep(ls); + if (sep >= 0) { + read_long_string(ls, tv, sep); + return TK_string; + } else if (sep == -1) { + return '['; + } else { + lj_lex_error(ls, TK_string, LJ_ERR_XLDELIM); + continue; + } + } + case '=': + next(ls); + if (ls->current != '=') return '='; else { next(ls); return TK_eq; } + case '<': + next(ls); + if (ls->current != '=') return '<'; else { next(ls); return TK_le; } + case '>': + next(ls); + if (ls->current != '=') return '>'; else { next(ls); return TK_ge; } + case '~': + next(ls); + if (ls->current != '=') return '~'; else { next(ls); return TK_ne; } + case ':': + next(ls); + if (ls->current != ':') return ':'; else { next(ls); return TK_label; } + case '"': + case '\'': + read_string(ls, ls->current, tv); + return TK_string; + case '.': + save_and_next(ls); + if (ls->current == '.') { + next(ls); + if (ls->current == '.') { + next(ls); + return TK_dots; /* ... */ + } + return TK_concat; /* .. */ + } else if (!lj_char_isdigit(ls->current)) { + return '.'; + } else { + lex_number(ls, tv); + return TK_number; + } + case END_OF_STREAM: + return TK_eof; + default: { + int c = ls->current; + next(ls); + return c; /* Single-char tokens (+ - / ...). */ + } + } + } +} + +/* -- Lexer API ----------------------------------------------------------- */ + +/* Setup lexer state. */ +int lj_lex_setup(lua_State *L, LexState *ls) +{ + int header = 0; + ls->L = L; + ls->fs = NULL; + ls->n = 0; + ls->p = NULL; + ls->vstack = NULL; + ls->sizevstack = 0; + ls->vtop = 0; + ls->bcstack = NULL; + ls->sizebcstack = 0; + ls->token = 0; + ls->lookahead = TK_eof; /* No look-ahead token. */ + ls->linenumber = 1; + ls->lastline = 1; + lj_str_resizebuf(ls->L, &ls->sb, LJ_MIN_SBUF); + next(ls); /* Read-ahead first char. */ + if (ls->current == 0xef && ls->n >= 2 && char2int(ls->p[0]) == 0xbb && + char2int(ls->p[1]) == 0xbf) { /* Skip UTF-8 BOM (if buffered). */ + ls->n -= 2; + ls->p += 2; + next(ls); + header = 1; + } + if (ls->current == '#') { /* Skip POSIX #! header line. */ + do { + next(ls); + if (ls->current == END_OF_STREAM) return 0; + } while (!currIsNewline(ls)); + inclinenumber(ls); + header = 1; + } + if (ls->current == LUA_SIGNATURE[0]) { /* Bytecode dump. */ + if (header) { + /* + ** Loading bytecode with an extra header is disabled for security + ** reasons. This may circumvent the usual check for bytecode vs. + ** Lua code by looking at the first char. Since this is a potential + ** security violation no attempt is made to echo the chunkname either. + */ + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_BCBAD)); + lj_err_throw(L, LUA_ERRSYNTAX); + } + return 1; + } + return 0; +} + +/* Cleanup lexer state. */ +void lj_lex_cleanup(lua_State *L, LexState *ls) +{ + global_State *g = G(L); + lj_mem_freevec(g, ls->bcstack, ls->sizebcstack, BCInsLine); + lj_mem_freevec(g, ls->vstack, ls->sizevstack, VarInfo); + lj_str_freebuf(g, &ls->sb); +} + +void lj_lex_next(LexState *ls) +{ + ls->lastline = ls->linenumber; + if (LJ_LIKELY(ls->lookahead == TK_eof)) { /* No lookahead token? */ + ls->token = llex(ls, &ls->tokenval); /* Get next token. */ + } else { /* Otherwise return lookahead token. */ + ls->token = ls->lookahead; + ls->lookahead = TK_eof; + ls->tokenval = ls->lookaheadval; + } +} + +LexToken lj_lex_lookahead(LexState *ls) +{ + lua_assert(ls->lookahead == TK_eof); + ls->lookahead = llex(ls, &ls->lookaheadval); + return ls->lookahead; +} + +const char *lj_lex_token2str(LexState *ls, LexToken token) +{ + if (token > TK_OFS) + return tokennames[token-TK_OFS-1]; + else if (!lj_char_iscntrl(token)) + return lj_str_pushf(ls->L, "%c", token); + else + return lj_str_pushf(ls->L, "char(%d)", token); +} + +void lj_lex_error(LexState *ls, LexToken token, ErrMsg em, ...) +{ + const char *tok; + va_list argp; + if (token == 0) { + tok = NULL; + } else if (token == TK_name || token == TK_string || token == TK_number) { + save(ls, '\0'); + tok = ls->sb.buf; + } else { + tok = lj_lex_token2str(ls, token); + } + va_start(argp, em); + lj_err_lex(ls->L, ls->chunkname, tok, ls->linenumber, em, argp); + va_end(argp); +} + +void lj_lex_init(lua_State *L) +{ + uint32_t i; + for (i = 0; i < TK_RESERVED; i++) { + GCstr *s = lj_str_newz(L, tokennames[i]); + fixstring(s); /* Reserved words are never collected. */ + s->reserved = (uint8_t)(i+1); + } +} + + +``` + +`include/luajit-2.0.5/src/lj_lex.h`: + +```h +/* +** Lexical analyzer. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_LEX_H +#define _LJ_LEX_H + +#include + +#include "lj_obj.h" +#include "lj_err.h" + +/* Lua lexer tokens. */ +#define TKDEF(_, __) \ + _(and) _(break) _(do) _(else) _(elseif) _(end) _(false) \ + _(for) _(function) _(goto) _(if) _(in) _(local) _(nil) _(not) _(or) \ + _(repeat) _(return) _(then) _(true) _(until) _(while) \ + __(concat, ..) __(dots, ...) __(eq, ==) __(ge, >=) __(le, <=) __(ne, ~=) \ + __(label, ::) __(number, ) __(name, ) __(string, ) \ + __(eof, ) + +enum { + TK_OFS = 256, +#define TKENUM1(name) TK_##name, +#define TKENUM2(name, sym) TK_##name, +TKDEF(TKENUM1, TKENUM2) +#undef TKENUM1 +#undef TKENUM2 + TK_RESERVED = TK_while - TK_OFS +}; + +typedef int LexToken; + +/* Combined bytecode ins/line. Only used during bytecode generation. */ +typedef struct BCInsLine { + BCIns ins; /* Bytecode instruction. */ + BCLine line; /* Line number for this bytecode. */ +} BCInsLine; + +/* Info for local variables. Only used during bytecode generation. */ +typedef struct VarInfo { + GCRef name; /* Local variable name or goto/label name. */ + BCPos startpc; /* First point where the local variable is active. */ + BCPos endpc; /* First point where the local variable is dead. */ + uint8_t slot; /* Variable slot. */ + uint8_t info; /* Variable/goto/label info. */ +} VarInfo; + +/* Lua lexer state. */ +typedef struct LexState { + struct FuncState *fs; /* Current FuncState. Defined in lj_parse.c. */ + struct lua_State *L; /* Lua state. */ + TValue tokenval; /* Current token value. */ + TValue lookaheadval; /* Lookahead token value. */ + int current; /* Current character (charint). */ + LexToken token; /* Current token. */ + LexToken lookahead; /* Lookahead token. */ + MSize n; /* Bytes left in input buffer. */ + const char *p; /* Current position in input buffer. */ + SBuf sb; /* String buffer for tokens. */ + lua_Reader rfunc; /* Reader callback. */ + void *rdata; /* Reader callback data. */ + BCLine linenumber; /* Input line counter. */ + BCLine lastline; /* Line of last token. */ + GCstr *chunkname; /* Current chunk name (interned string). */ + const char *chunkarg; /* Chunk name argument. */ + const char *mode; /* Allow loading bytecode (b) and/or source text (t). */ + VarInfo *vstack; /* Stack for names and extents of local variables. */ + MSize sizevstack; /* Size of variable stack. */ + MSize vtop; /* Top of variable stack. */ + BCInsLine *bcstack; /* Stack for bytecode instructions/line numbers. */ + MSize sizebcstack; /* Size of bytecode stack. */ + uint32_t level; /* Syntactical nesting level. */ +} LexState; + +LJ_FUNC int lj_lex_setup(lua_State *L, LexState *ls); +LJ_FUNC void lj_lex_cleanup(lua_State *L, LexState *ls); +LJ_FUNC void lj_lex_next(LexState *ls); +LJ_FUNC LexToken lj_lex_lookahead(LexState *ls); +LJ_FUNC const char *lj_lex_token2str(LexState *ls, LexToken token); +LJ_FUNC_NORET void lj_lex_error(LexState *ls, LexToken token, ErrMsg em, ...); +LJ_FUNC void lj_lex_init(lua_State *L); + +#endif + +``` + +`include/luajit-2.0.5/src/lj_lib.c`: + +```c +/* +** Library function support. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_lib_c +#define LUA_CORE + +#include "lauxlib.h" + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_func.h" +#include "lj_bc.h" +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "lj_strscan.h" +#include "lj_lib.h" + +/* -- Library initialization ---------------------------------------------- */ + +static GCtab *lib_create_table(lua_State *L, const char *libname, int hsize) +{ + if (libname) { + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 16); + lua_getfield(L, -1, libname); + if (!tvistab(L->top-1)) { + L->top--; + if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, hsize) != NULL) + lj_err_callerv(L, LJ_ERR_BADMODN, libname); + settabV(L, L->top, tabV(L->top-1)); + L->top++; + lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ + } + L->top--; + settabV(L, L->top-1, tabV(L->top)); + } else { + lua_createtable(L, 0, hsize); + } + return tabV(L->top-1); +} + +void lj_lib_register(lua_State *L, const char *libname, + const uint8_t *p, const lua_CFunction *cf) +{ + GCtab *env = tabref(L->env); + GCfunc *ofn = NULL; + int ffid = *p++; + BCIns *bcff = &L2GG(L)->bcff[*p++]; + GCtab *tab = lib_create_table(L, libname, *p++); + ptrdiff_t tpos = L->top - L->base; + + /* Avoid barriers further down. */ + lj_gc_anybarriert(L, tab); + tab->nomm = 0; + + for (;;) { + uint32_t tag = *p++; + MSize len = tag & LIBINIT_LENMASK; + tag &= LIBINIT_TAGMASK; + if (tag != LIBINIT_STRING) { + const char *name; + MSize nuv = (MSize)(L->top - L->base - tpos); + GCfunc *fn = lj_func_newC(L, nuv, env); + if (nuv) { + L->top = L->base + tpos; + memcpy(fn->c.upvalue, L->top, sizeof(TValue)*nuv); + } + fn->c.ffid = (uint8_t)(ffid++); + name = (const char *)p; + p += len; + if (tag == LIBINIT_CF) + setmref(fn->c.pc, &G(L)->bc_cfunc_int); + else + setmref(fn->c.pc, bcff++); + if (tag == LIBINIT_ASM_) + fn->c.f = ofn->c.f; /* Copy handler from previous function. */ + else + fn->c.f = *cf++; /* Get cf or handler from C function table. */ + if (len) { + /* NOBARRIER: See above for common barrier. */ + setfuncV(L, lj_tab_setstr(L, tab, lj_str_new(L, name, len)), fn); + } + ofn = fn; + } else { + switch (tag | len) { + case LIBINIT_SET: + L->top -= 2; + if (tvisstr(L->top+1) && strV(L->top+1)->len == 0) + env = tabV(L->top); + else /* NOBARRIER: See above for common barrier. */ + copyTV(L, lj_tab_set(L, tab, L->top+1), L->top); + break; + case LIBINIT_NUMBER: + memcpy(&L->top->n, p, sizeof(double)); + L->top++; + p += sizeof(double); + break; + case LIBINIT_COPY: + copyTV(L, L->top, L->top - *p++); + L->top++; + break; + case LIBINIT_LASTCL: + setfuncV(L, L->top++, ofn); + break; + case LIBINIT_FFID: + ffid++; + break; + case LIBINIT_END: + return; + default: + setstrV(L, L->top++, lj_str_new(L, (const char *)p, len)); + p += len; + break; + } + } + } +} + +/* -- Type checks --------------------------------------------------------- */ + +TValue *lj_lib_checkany(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (o >= L->top) + lj_err_arg(L, narg, LJ_ERR_NOVAL); + return o; +} + +GCstr *lj_lib_checkstr(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (o < L->top) { + if (LJ_LIKELY(tvisstr(o))) { + return strV(o); + } else if (tvisnumber(o)) { + GCstr *s = lj_str_fromnumber(L, o); + setstrV(L, o, s); + return s; + } + } + lj_err_argt(L, narg, LUA_TSTRING); + return NULL; /* unreachable */ +} + +GCstr *lj_lib_optstr(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + return (o < L->top && !tvisnil(o)) ? lj_lib_checkstr(L, narg) : NULL; +} + +#if LJ_DUALNUM +void lj_lib_checknumber(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (!(o < L->top && lj_strscan_numberobj(o))) + lj_err_argt(L, narg, LUA_TNUMBER); +} +#endif + +lua_Number lj_lib_checknum(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (!(o < L->top && + (tvisnumber(o) || (tvisstr(o) && lj_strscan_num(strV(o), o))))) + lj_err_argt(L, narg, LUA_TNUMBER); + if (LJ_UNLIKELY(tvisint(o))) { + lua_Number n = (lua_Number)intV(o); + setnumV(o, n); + return n; + } else { + return numV(o); + } +} + +int32_t lj_lib_checkint(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (!(o < L->top && lj_strscan_numberobj(o))) + lj_err_argt(L, narg, LUA_TNUMBER); + if (LJ_LIKELY(tvisint(o))) { + return intV(o); + } else { + int32_t i = lj_num2int(numV(o)); + if (LJ_DUALNUM) setintV(o, i); + return i; + } +} + +int32_t lj_lib_optint(lua_State *L, int narg, int32_t def) +{ + TValue *o = L->base + narg-1; + return (o < L->top && !tvisnil(o)) ? lj_lib_checkint(L, narg) : def; +} + +int32_t lj_lib_checkbit(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (!(o < L->top && lj_strscan_numberobj(o))) + lj_err_argt(L, narg, LUA_TNUMBER); + if (LJ_LIKELY(tvisint(o))) { + return intV(o); + } else { + int32_t i = lj_num2bit(numV(o)); + if (LJ_DUALNUM) setintV(o, i); + return i; + } +} + +GCfunc *lj_lib_checkfunc(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (!(o < L->top && tvisfunc(o))) + lj_err_argt(L, narg, LUA_TFUNCTION); + return funcV(o); +} + +GCtab *lj_lib_checktab(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (!(o < L->top && tvistab(o))) + lj_err_argt(L, narg, LUA_TTABLE); + return tabV(o); +} + +GCtab *lj_lib_checktabornil(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (o < L->top) { + if (tvistab(o)) + return tabV(o); + else if (tvisnil(o)) + return NULL; + } + lj_err_arg(L, narg, LJ_ERR_NOTABN); + return NULL; /* unreachable */ +} + +int lj_lib_checkopt(lua_State *L, int narg, int def, const char *lst) +{ + GCstr *s = def >= 0 ? lj_lib_optstr(L, narg) : lj_lib_checkstr(L, narg); + if (s) { + const char *opt = strdata(s); + MSize len = s->len; + int i; + for (i = 0; *(const uint8_t *)lst; i++) { + if (*(const uint8_t *)lst == len && memcmp(opt, lst+1, len) == 0) + return i; + lst += 1+*(const uint8_t *)lst; + } + lj_err_argv(L, narg, LJ_ERR_INVOPTM, opt); + } + return def; +} + + +``` + +`include/luajit-2.0.5/src/lj_lib.h`: + +```h +/* +** Library function support. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_LIB_H +#define _LJ_LIB_H + +#include "lj_obj.h" + +/* +** A fallback handler is called by the assembler VM if the fast path fails: +** +** - too few arguments: unrecoverable. +** - wrong argument type: recoverable, if coercion succeeds. +** - bad argument value: unrecoverable. +** - stack overflow: recoverable, if stack reallocation succeeds. +** - extra handling: recoverable. +** +** The unrecoverable cases throw an error with lj_err_arg(), lj_err_argtype(), +** lj_err_caller() or lj_err_callermsg(). +** The recoverable cases return 0 or the number of results + 1. +** The assembler VM retries the fast path only if 0 is returned. +** This time the fallback must not be called again or it gets stuck in a loop. +*/ + +/* Return values from fallback handler. */ +#define FFH_RETRY 0 +#define FFH_UNREACHABLE FFH_RETRY +#define FFH_RES(n) ((n)+1) +#define FFH_TAILCALL (-1) + +LJ_FUNC TValue *lj_lib_checkany(lua_State *L, int narg); +LJ_FUNC GCstr *lj_lib_checkstr(lua_State *L, int narg); +LJ_FUNC GCstr *lj_lib_optstr(lua_State *L, int narg); +#if LJ_DUALNUM +LJ_FUNC void lj_lib_checknumber(lua_State *L, int narg); +#else +#define lj_lib_checknumber(L, narg) lj_lib_checknum((L), (narg)) +#endif +LJ_FUNC lua_Number lj_lib_checknum(lua_State *L, int narg); +LJ_FUNC int32_t lj_lib_checkint(lua_State *L, int narg); +LJ_FUNC int32_t lj_lib_optint(lua_State *L, int narg, int32_t def); +LJ_FUNC int32_t lj_lib_checkbit(lua_State *L, int narg); +LJ_FUNC GCfunc *lj_lib_checkfunc(lua_State *L, int narg); +LJ_FUNC GCtab *lj_lib_checktab(lua_State *L, int narg); +LJ_FUNC GCtab *lj_lib_checktabornil(lua_State *L, int narg); +LJ_FUNC int lj_lib_checkopt(lua_State *L, int narg, int def, const char *lst); + +/* Avoid including lj_frame.h. */ +#define lj_lib_upvalue(L, n) \ + (&gcref((L->base-1)->fr.func)->fn.c.upvalue[(n)-1]) + +#if LJ_TARGET_WINDOWS +#define lj_lib_checkfpu(L) \ + do { setnumV(L->top++, (lua_Number)1437217655); \ + if (lua_tointeger(L, -1) != 1437217655) lj_err_caller(L, LJ_ERR_BADFPU); \ + L->top--; } while (0) +#else +#define lj_lib_checkfpu(L) UNUSED(L) +#endif + +/* Push internal function on the stack. */ +static LJ_AINLINE void lj_lib_pushcc(lua_State *L, lua_CFunction f, + int id, int n) +{ + GCfunc *fn; + lua_pushcclosure(L, f, n); + fn = funcV(L->top-1); + fn->c.ffid = (uint8_t)id; + setmref(fn->c.pc, &G(L)->bc_cfunc_int); +} + +#define lj_lib_pushcf(L, fn, id) (lj_lib_pushcc(L, (fn), (id), 0)) + +/* Library function declarations. Scanned by buildvm. */ +#define LJLIB_CF(name) static int lj_cf_##name(lua_State *L) +#define LJLIB_ASM(name) static int lj_ffh_##name(lua_State *L) +#define LJLIB_ASM_(name) +#define LJLIB_SET(name) +#define LJLIB_PUSH(arg) +#define LJLIB_REC(handler) +#define LJLIB_NOREGUV +#define LJLIB_NOREG + +#define LJ_LIB_REG(L, regname, name) \ + lj_lib_register(L, regname, lj_lib_init_##name, lj_lib_cf_##name) + +LJ_FUNC void lj_lib_register(lua_State *L, const char *libname, + const uint8_t *init, const lua_CFunction *cf); + +/* Library init data tags. */ +#define LIBINIT_LENMASK 0x3f +#define LIBINIT_TAGMASK 0xc0 +#define LIBINIT_CF 0x00 +#define LIBINIT_ASM 0x40 +#define LIBINIT_ASM_ 0x80 +#define LIBINIT_STRING 0xc0 +#define LIBINIT_MAXSTR 0x39 +#define LIBINIT_SET 0xfa +#define LIBINIT_NUMBER 0xfb +#define LIBINIT_COPY 0xfc +#define LIBINIT_LASTCL 0xfd +#define LIBINIT_FFID 0xfe +#define LIBINIT_END 0xff + +/* Exported library functions. */ + +typedef struct RandomState RandomState; +LJ_FUNC uint64_t LJ_FASTCALL lj_math_random_step(RandomState *rs); + +#endif + +``` + +`include/luajit-2.0.5/src/lj_load.c`: + +```c +/* +** Load and dump code. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include +#include + +#define lj_load_c +#define LUA_CORE + +#include "lua.h" +#include "lauxlib.h" + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_func.h" +#include "lj_frame.h" +#include "lj_vm.h" +#include "lj_lex.h" +#include "lj_bcdump.h" +#include "lj_parse.h" + +/* -- Load Lua source code and bytecode ----------------------------------- */ + +static TValue *cpparser(lua_State *L, lua_CFunction dummy, void *ud) +{ + LexState *ls = (LexState *)ud; + GCproto *pt; + GCfunc *fn; + int bc; + UNUSED(dummy); + cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ + bc = lj_lex_setup(L, ls); + if (ls->mode && !strchr(ls->mode, bc ? 'b' : 't')) { + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_XMODE)); + lj_err_throw(L, LUA_ERRSYNTAX); + } + pt = bc ? lj_bcread(ls) : lj_parse(ls); + fn = lj_func_newL_empty(L, pt, tabref(L->env)); + /* Don't combine above/below into one statement. */ + setfuncV(L, L->top++, fn); + return NULL; +} + +LUA_API int lua_loadx(lua_State *L, lua_Reader reader, void *data, + const char *chunkname, const char *mode) +{ + LexState ls; + int status; + ls.rfunc = reader; + ls.rdata = data; + ls.chunkarg = chunkname ? chunkname : "?"; + ls.mode = mode; + lj_str_initbuf(&ls.sb); + status = lj_vm_cpcall(L, NULL, &ls, cpparser); + lj_lex_cleanup(L, &ls); + lj_gc_check(L); + return status; +} + +LUA_API int lua_load(lua_State *L, lua_Reader reader, void *data, + const char *chunkname) +{ + return lua_loadx(L, reader, data, chunkname, NULL); +} + +typedef struct FileReaderCtx { + FILE *fp; + char buf[LUAL_BUFFERSIZE]; +} FileReaderCtx; + +static const char *reader_file(lua_State *L, void *ud, size_t *size) +{ + FileReaderCtx *ctx = (FileReaderCtx *)ud; + UNUSED(L); + if (feof(ctx->fp)) return NULL; + *size = fread(ctx->buf, 1, sizeof(ctx->buf), ctx->fp); + return *size > 0 ? ctx->buf : NULL; +} + +LUALIB_API int luaL_loadfilex(lua_State *L, const char *filename, + const char *mode) +{ + FileReaderCtx ctx; + int status; + const char *chunkname; + if (filename) { + ctx.fp = fopen(filename, "rb"); + if (ctx.fp == NULL) { + lua_pushfstring(L, "cannot open %s: %s", filename, strerror(errno)); + return LUA_ERRFILE; + } + chunkname = lua_pushfstring(L, "@%s", filename); + } else { + ctx.fp = stdin; + chunkname = "=stdin"; + } + status = lua_loadx(L, reader_file, &ctx, chunkname, mode); + if (ferror(ctx.fp)) { + L->top -= filename ? 2 : 1; + lua_pushfstring(L, "cannot read %s: %s", chunkname+1, strerror(errno)); + if (filename) + fclose(ctx.fp); + return LUA_ERRFILE; + } + if (filename) { + L->top--; + copyTV(L, L->top-1, L->top); + fclose(ctx.fp); + } + return status; +} + +LUALIB_API int luaL_loadfile(lua_State *L, const char *filename) +{ + return luaL_loadfilex(L, filename, NULL); +} + +typedef struct StringReaderCtx { + const char *str; + size_t size; +} StringReaderCtx; + +static const char *reader_string(lua_State *L, void *ud, size_t *size) +{ + StringReaderCtx *ctx = (StringReaderCtx *)ud; + UNUSED(L); + if (ctx->size == 0) return NULL; + *size = ctx->size; + ctx->size = 0; + return ctx->str; +} + +LUALIB_API int luaL_loadbufferx(lua_State *L, const char *buf, size_t size, + const char *name, const char *mode) +{ + StringReaderCtx ctx; + ctx.str = buf; + ctx.size = size; + return lua_loadx(L, reader_string, &ctx, name, mode); +} + +LUALIB_API int luaL_loadbuffer(lua_State *L, const char *buf, size_t size, + const char *name) +{ + return luaL_loadbufferx(L, buf, size, name, NULL); +} + +LUALIB_API int luaL_loadstring(lua_State *L, const char *s) +{ + return luaL_loadbuffer(L, s, strlen(s), s); +} + +/* -- Dump bytecode ------------------------------------------------------- */ + +LUA_API int lua_dump(lua_State *L, lua_Writer writer, void *data) +{ + cTValue *o = L->top-1; + api_check(L, L->top > L->base); + if (tvisfunc(o) && isluafunc(funcV(o))) + return lj_bcwrite(L, funcproto(funcV(o)), writer, data, 0); + else + return 1; +} + + +``` + +`include/luajit-2.0.5/src/lj_mcode.c`: + +```c +/* +** Machine code management. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_mcode_c +#define LUA_CORE + +#include "lj_obj.h" +#if LJ_HASJIT +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_jit.h" +#include "lj_mcode.h" +#include "lj_trace.h" +#include "lj_dispatch.h" +#endif +#if LJ_HASJIT || LJ_HASFFI +#include "lj_vm.h" +#endif + +/* -- OS-specific functions ----------------------------------------------- */ + +#if LJ_HASJIT || LJ_HASFFI + +/* Define this if you want to run LuaJIT with Valgrind. */ +#ifdef LUAJIT_USE_VALGRIND +#include +#endif + +#if LJ_TARGET_IOS +void sys_icache_invalidate(void *start, size_t len); +#endif + +/* Synchronize data/instruction cache. */ +void lj_mcode_sync(void *start, void *end) +{ +#ifdef LUAJIT_USE_VALGRIND + VALGRIND_DISCARD_TRANSLATIONS(start, (char *)end-(char *)start); +#endif +#if LJ_TARGET_X86ORX64 + UNUSED(start); UNUSED(end); +#elif LJ_TARGET_IOS + sys_icache_invalidate(start, (char *)end-(char *)start); +#elif LJ_TARGET_PPC + lj_vm_cachesync(start, end); +#elif defined(__GNUC__) + __clear_cache(start, end); +#else +#error "Missing builtin to flush instruction cache" +#endif +} + +#endif + +#if LJ_HASJIT + +#if LJ_TARGET_WINDOWS + +#define WIN32_LEAN_AND_MEAN +#include + +#define MCPROT_RW PAGE_READWRITE +#define MCPROT_RX PAGE_EXECUTE_READ +#define MCPROT_RWX PAGE_EXECUTE_READWRITE + +static void *mcode_alloc_at(jit_State *J, uintptr_t hint, size_t sz, DWORD prot) +{ + void *p = VirtualAlloc((void *)hint, sz, + MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, prot); + if (!p && !hint) + lj_trace_err(J, LJ_TRERR_MCODEAL); + return p; +} + +static void mcode_free(jit_State *J, void *p, size_t sz) +{ + UNUSED(J); UNUSED(sz); + VirtualFree(p, 0, MEM_RELEASE); +} + +static int mcode_setprot(void *p, size_t sz, DWORD prot) +{ + DWORD oprot; + return !VirtualProtect(p, sz, prot, &oprot); +} + +#elif LJ_TARGET_POSIX + +#include + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +#define MCPROT_RW (PROT_READ|PROT_WRITE) +#define MCPROT_RX (PROT_READ|PROT_EXEC) +#define MCPROT_RWX (PROT_READ|PROT_WRITE|PROT_EXEC) + +static void *mcode_alloc_at(jit_State *J, uintptr_t hint, size_t sz, int prot) +{ + void *p = mmap((void *)hint, sz, prot, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + if (p == MAP_FAILED) { + if (!hint) lj_trace_err(J, LJ_TRERR_MCODEAL); + p = NULL; + } + return p; +} + +static void mcode_free(jit_State *J, void *p, size_t sz) +{ + UNUSED(J); + munmap(p, sz); +} + +static int mcode_setprot(void *p, size_t sz, int prot) +{ + return mprotect(p, sz, prot); +} + +#elif LJ_64 + +#error "Missing OS support for explicit placement of executable memory" + +#else + +/* Fallback allocator. This will fail if memory is not executable by default. */ +#define LUAJIT_UNPROTECT_MCODE +#define MCPROT_RW 0 +#define MCPROT_RX 0 +#define MCPROT_RWX 0 + +static void *mcode_alloc_at(jit_State *J, uintptr_t hint, size_t sz, int prot) +{ + UNUSED(hint); UNUSED(prot); + return lj_mem_new(J->L, sz); +} + +static void mcode_free(jit_State *J, void *p, size_t sz) +{ + lj_mem_free(J2G(J), p, sz); +} + +#endif + +/* -- MCode area protection ----------------------------------------------- */ + +/* Define this ONLY if page protection twiddling becomes a bottleneck. */ +#ifdef LUAJIT_UNPROTECT_MCODE + +/* It's generally considered to be a potential security risk to have +** pages with simultaneous write *and* execute access in a process. +** +** Do not even think about using this mode for server processes or +** apps handling untrusted external data (such as a browser). +** +** The security risk is not in LuaJIT itself -- but if an adversary finds +** any *other* flaw in your C application logic, then any RWX memory page +** simplifies writing an exploit considerably. +*/ +#define MCPROT_GEN MCPROT_RWX +#define MCPROT_RUN MCPROT_RWX + +static void mcode_protect(jit_State *J, int prot) +{ + UNUSED(J); UNUSED(prot); +} + +#else + +/* This is the default behaviour and much safer: +** +** Most of the time the memory pages holding machine code are executable, +** but NONE of them is writable. +** +** The current memory area is marked read-write (but NOT executable) only +** during the short time window while the assembler generates machine code. +*/ +#define MCPROT_GEN MCPROT_RW +#define MCPROT_RUN MCPROT_RX + +/* Protection twiddling failed. Probably due to kernel security. */ +static LJ_NOINLINE void mcode_protfail(jit_State *J) +{ + lua_CFunction panic = J2G(J)->panic; + if (panic) { + lua_State *L = J->L; + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_JITPROT)); + panic(L); + } +} + +/* Change protection of MCode area. */ +static void mcode_protect(jit_State *J, int prot) +{ + if (J->mcprot != prot) { + if (LJ_UNLIKELY(mcode_setprot(J->mcarea, J->szmcarea, prot))) + mcode_protfail(J); + J->mcprot = prot; + } +} + +#endif + +/* -- MCode area allocation ----------------------------------------------- */ + +#if LJ_64 +#define mcode_validptr(p) (p) +#else +#define mcode_validptr(p) ((p) && (uintptr_t)(p) < 0xffff0000) +#endif + +#ifdef LJ_TARGET_JUMPRANGE + +/* Get memory within relative jump distance of our code in 64 bit mode. */ +static void *mcode_alloc(jit_State *J, size_t sz) +{ + /* Target an address in the static assembler code (64K aligned). + ** Try addresses within a distance of target-range/2+1MB..target+range/2-1MB. + ** Use half the jump range so every address in the range can reach any other. + */ +#if LJ_TARGET_MIPS + /* Use the middle of the 256MB-aligned region. */ + uintptr_t target = ((uintptr_t)(void *)lj_vm_exit_handler & 0xf0000000u) + + 0x08000000u; +#else + uintptr_t target = (uintptr_t)(void *)lj_vm_exit_handler & ~(uintptr_t)0xffff; +#endif + const uintptr_t range = (1u << (LJ_TARGET_JUMPRANGE-1)) - (1u << 21); + /* First try a contiguous area below the last one. */ + uintptr_t hint = J->mcarea ? (uintptr_t)J->mcarea - sz : 0; + int i; + /* Limit probing iterations, depending on the available pool size. */ + for (i = 0; i < LJ_TARGET_JUMPRANGE; i++) { + if (mcode_validptr(hint)) { + void *p = mcode_alloc_at(J, hint, sz, MCPROT_GEN); + + if (mcode_validptr(p) && + ((uintptr_t)p + sz - target < range || target - (uintptr_t)p < range)) + return p; + if (p) mcode_free(J, p, sz); /* Free badly placed area. */ + } + /* Next try probing 64K-aligned pseudo-random addresses. */ + do { + hint = LJ_PRNG_BITS(J, LJ_TARGET_JUMPRANGE-16) << 16; + } while (!(hint + sz < range+range)); + hint = target + hint - range; + } + lj_trace_err(J, LJ_TRERR_MCODEAL); /* Give up. OS probably ignores hints? */ + return NULL; +} + +#else + +/* All memory addresses are reachable by relative jumps. */ +static void *mcode_alloc(jit_State *J, size_t sz) +{ +#ifdef __OpenBSD__ + /* Allow better executable memory allocation for OpenBSD W^X mode. */ + void *p = mcode_alloc_at(J, 0, sz, MCPROT_RUN); + if (p && mcode_setprot(p, sz, MCPROT_GEN)) { + mcode_free(J, p, sz); + return NULL; + } + return p; +#else + return mcode_alloc_at(J, 0, sz, MCPROT_GEN); +#endif +} + +#endif + +/* -- MCode area management ----------------------------------------------- */ + +/* Linked list of MCode areas. */ +typedef struct MCLink { + MCode *next; /* Next area. */ + size_t size; /* Size of current area. */ +} MCLink; + +/* Allocate a new MCode area. */ +static void mcode_allocarea(jit_State *J) +{ + MCode *oldarea = J->mcarea; + size_t sz = (size_t)J->param[JIT_P_sizemcode] << 10; + sz = (sz + LJ_PAGESIZE-1) & ~(size_t)(LJ_PAGESIZE - 1); + J->mcarea = (MCode *)mcode_alloc(J, sz); + J->szmcarea = sz; + J->mcprot = MCPROT_GEN; + J->mctop = (MCode *)((char *)J->mcarea + J->szmcarea); + J->mcbot = (MCode *)((char *)J->mcarea + sizeof(MCLink)); + ((MCLink *)J->mcarea)->next = oldarea; + ((MCLink *)J->mcarea)->size = sz; + J->szallmcarea += sz; +} + +/* Free all MCode areas. */ +void lj_mcode_free(jit_State *J) +{ + MCode *mc = J->mcarea; + J->mcarea = NULL; + J->szallmcarea = 0; + while (mc) { + MCode *next = ((MCLink *)mc)->next; + mcode_free(J, mc, ((MCLink *)mc)->size); + mc = next; + } +} + +/* -- MCode transactions -------------------------------------------------- */ + +/* Reserve the remainder of the current MCode area. */ +MCode *lj_mcode_reserve(jit_State *J, MCode **lim) +{ + if (!J->mcarea) + mcode_allocarea(J); + else + mcode_protect(J, MCPROT_GEN); + *lim = J->mcbot; + return J->mctop; +} + +/* Commit the top part of the current MCode area. */ +void lj_mcode_commit(jit_State *J, MCode *top) +{ + J->mctop = top; + mcode_protect(J, MCPROT_RUN); +} + +/* Abort the reservation. */ +void lj_mcode_abort(jit_State *J) +{ + if (J->mcarea) + mcode_protect(J, MCPROT_RUN); +} + +/* Set/reset protection to allow patching of MCode areas. */ +MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish) +{ +#ifdef LUAJIT_UNPROTECT_MCODE + UNUSED(J); UNUSED(ptr); UNUSED(finish); + return NULL; +#else + if (finish) { + if (J->mcarea == ptr) + mcode_protect(J, MCPROT_RUN); + else if (LJ_UNLIKELY(mcode_setprot(ptr, ((MCLink *)ptr)->size, MCPROT_RUN))) + mcode_protfail(J); + return NULL; + } else { + MCode *mc = J->mcarea; + /* Try current area first to use the protection cache. */ + if (ptr >= mc && ptr < (MCode *)((char *)mc + J->szmcarea)) { + mcode_protect(J, MCPROT_GEN); + return mc; + } + /* Otherwise search through the list of MCode areas. */ + for (;;) { + mc = ((MCLink *)mc)->next; + lua_assert(mc != NULL); + if (ptr >= mc && ptr < (MCode *)((char *)mc + ((MCLink *)mc)->size)) { + if (LJ_UNLIKELY(mcode_setprot(mc, ((MCLink *)mc)->size, MCPROT_GEN))) + mcode_protfail(J); + return mc; + } + } + } +#endif +} + +/* Limit of MCode reservation reached. */ +void lj_mcode_limiterr(jit_State *J, size_t need) +{ + size_t sizemcode, maxmcode; + lj_mcode_abort(J); + sizemcode = (size_t)J->param[JIT_P_sizemcode] << 10; + sizemcode = (sizemcode + LJ_PAGESIZE-1) & ~(size_t)(LJ_PAGESIZE - 1); + maxmcode = (size_t)J->param[JIT_P_maxmcode] << 10; + if ((size_t)need > sizemcode) + lj_trace_err(J, LJ_TRERR_MCODEOV); /* Too long for any area. */ + if (J->szallmcarea + sizemcode > maxmcode) + lj_trace_err(J, LJ_TRERR_MCODEAL); + mcode_allocarea(J); + lj_trace_err(J, LJ_TRERR_MCODELM); /* Retry with new area. */ +} + +#endif + +``` + +`include/luajit-2.0.5/src/lj_mcode.h`: + +```h +/* +** Machine code management. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_MCODE_H +#define _LJ_MCODE_H + +#include "lj_obj.h" + +#if LJ_HASJIT || LJ_HASFFI +LJ_FUNC void lj_mcode_sync(void *start, void *end); +#endif + +#if LJ_HASJIT + +#include "lj_jit.h" + +LJ_FUNC void lj_mcode_free(jit_State *J); +LJ_FUNC MCode *lj_mcode_reserve(jit_State *J, MCode **lim); +LJ_FUNC void lj_mcode_commit(jit_State *J, MCode *m); +LJ_FUNC void lj_mcode_abort(jit_State *J); +LJ_FUNC MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish); +LJ_FUNC_NORET void lj_mcode_limiterr(jit_State *J, size_t need); + +#define lj_mcode_commitbot(J, m) (J->mcbot = (m)) + +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_meta.c`: + +```c +/* +** Metamethod handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_meta_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_meta.h" +#include "lj_frame.h" +#include "lj_bc.h" +#include "lj_vm.h" +#include "lj_strscan.h" + +/* -- Metamethod handling ------------------------------------------------- */ + +/* String interning of metamethod names for fast indexing. */ +void lj_meta_init(lua_State *L) +{ +#define MMNAME(name) "__" #name + const char *metanames = MMDEF(MMNAME); +#undef MMNAME + global_State *g = G(L); + const char *p, *q; + uint32_t mm; + for (mm = 0, p = metanames; *p; mm++, p = q) { + GCstr *s; + for (q = p+2; *q && *q != '_'; q++) ; + s = lj_str_new(L, p, (size_t)(q-p)); + /* NOBARRIER: g->gcroot[] is a GC root. */ + setgcref(g->gcroot[GCROOT_MMNAME+mm], obj2gco(s)); + } +} + +/* Negative caching of a few fast metamethods. See the lj_meta_fast() macro. */ +cTValue *lj_meta_cache(GCtab *mt, MMS mm, GCstr *name) +{ + cTValue *mo = lj_tab_getstr(mt, name); + lua_assert(mm <= MM_FAST); + if (!mo || tvisnil(mo)) { /* No metamethod? */ + mt->nomm |= (uint8_t)(1u<metatable); + else if (tvisudata(o)) + mt = tabref(udataV(o)->metatable); + else + mt = tabref(basemt_obj(G(L), o)); + if (mt) { + cTValue *mo = lj_tab_getstr(mt, mmname_str(G(L), mm)); + if (mo) + return mo; + } + return niltv(L); +} + +#if LJ_HASFFI +/* Tailcall from C function. */ +int lj_meta_tailcall(lua_State *L, cTValue *tv) +{ + TValue *base = L->base; + TValue *top = L->top; + const BCIns *pc = frame_pc(base-1); /* Preserve old PC from frame. */ + copyTV(L, base-1, tv); /* Replace frame with new object. */ + top->u32.lo = LJ_CONT_TAILCALL; + setframe_pc(top, pc); + setframe_gc(top+1, obj2gco(L)); /* Dummy frame object. */ + setframe_ftsz(top+1, (int)((char *)(top+2) - (char *)base) + FRAME_CONT); + L->base = L->top = top+2; + /* + ** before: [old_mo|PC] [... ...] + ** ^base ^top + ** after: [new_mo|itype] [... ...] [NULL|PC] [dummy|delta] + ** ^base/top + ** tailcall: [new_mo|PC] [... ...] + ** ^base ^top + */ + return 0; +} +#endif + +/* Setup call to metamethod to be run by Assembler VM. */ +static TValue *mmcall(lua_State *L, ASMFunction cont, cTValue *mo, + cTValue *a, cTValue *b) +{ + /* + ** |-- framesize -> top top+1 top+2 top+3 + ** before: [func slots ...] + ** mm setup: [func slots ...] [cont|?] [mo|tmtype] [a] [b] + ** in asm: [func slots ...] [cont|PC] [mo|delta] [a] [b] + ** ^-- func base ^-- mm base + ** after mm: [func slots ...] [result] + ** ^-- copy to base[PC_RA] --/ for lj_cont_ra + ** istruecond + branch for lj_cont_cond* + ** ignore for lj_cont_nop + ** next PC: [func slots ...] + */ + TValue *top = L->top; + if (curr_funcisL(L)) top = curr_topL(L); + setcont(top, cont); /* Assembler VM stores PC in upper word. */ + copyTV(L, top+1, mo); /* Store metamethod and two arguments. */ + copyTV(L, top+2, a); + copyTV(L, top+3, b); + return top+2; /* Return new base. */ +} + +/* -- C helpers for some instructions, called from assembler VM ----------- */ + +/* Helper for TGET*. __index chain and metamethod. */ +cTValue *lj_meta_tget(lua_State *L, cTValue *o, cTValue *k) +{ + int loop; + for (loop = 0; loop < LJ_MAX_IDXCHAIN; loop++) { + cTValue *mo; + if (LJ_LIKELY(tvistab(o))) { + GCtab *t = tabV(o); + cTValue *tv = lj_tab_get(L, t, k); + if (!tvisnil(tv) || + !(mo = lj_meta_fast(L, tabref(t->metatable), MM_index))) + return tv; + } else if (tvisnil(mo = lj_meta_lookup(L, o, MM_index))) { + lj_err_optype(L, o, LJ_ERR_OPINDEX); + return NULL; /* unreachable */ + } + if (tvisfunc(mo)) { + L->top = mmcall(L, lj_cont_ra, mo, o, k); + return NULL; /* Trigger metamethod call. */ + } + o = mo; + } + lj_err_msg(L, LJ_ERR_GETLOOP); + return NULL; /* unreachable */ +} + +/* Helper for TSET*. __newindex chain and metamethod. */ +TValue *lj_meta_tset(lua_State *L, cTValue *o, cTValue *k) +{ + TValue tmp; + int loop; + for (loop = 0; loop < LJ_MAX_IDXCHAIN; loop++) { + cTValue *mo; + if (LJ_LIKELY(tvistab(o))) { + GCtab *t = tabV(o); + cTValue *tv = lj_tab_get(L, t, k); + if (LJ_LIKELY(!tvisnil(tv))) { + t->nomm = 0; /* Invalidate negative metamethod cache. */ + lj_gc_anybarriert(L, t); + return (TValue *)tv; + } else if (!(mo = lj_meta_fast(L, tabref(t->metatable), MM_newindex))) { + t->nomm = 0; /* Invalidate negative metamethod cache. */ + lj_gc_anybarriert(L, t); + if (tv != niltv(L)) + return (TValue *)tv; + if (tvisnil(k)) lj_err_msg(L, LJ_ERR_NILIDX); + else if (tvisint(k)) { setnumV(&tmp, (lua_Number)intV(k)); k = &tmp; } + else if (tvisnum(k) && tvisnan(k)) lj_err_msg(L, LJ_ERR_NANIDX); + return lj_tab_newkey(L, t, k); + } + } else if (tvisnil(mo = lj_meta_lookup(L, o, MM_newindex))) { + lj_err_optype(L, o, LJ_ERR_OPINDEX); + return NULL; /* unreachable */ + } + if (tvisfunc(mo)) { + L->top = mmcall(L, lj_cont_nop, mo, o, k); + /* L->top+2 = v filled in by caller. */ + return NULL; /* Trigger metamethod call. */ + } + copyTV(L, &tmp, mo); + o = &tmp; + } + lj_err_msg(L, LJ_ERR_SETLOOP); + return NULL; /* unreachable */ +} + +static cTValue *str2num(cTValue *o, TValue *n) +{ + if (tvisnum(o)) + return o; + else if (tvisint(o)) + return (setnumV(n, (lua_Number)intV(o)), n); + else if (tvisstr(o) && lj_strscan_num(strV(o), n)) + return n; + else + return NULL; +} + +/* Helper for arithmetic instructions. Coercion, metamethod. */ +TValue *lj_meta_arith(lua_State *L, TValue *ra, cTValue *rb, cTValue *rc, + BCReg op) +{ + MMS mm = bcmode_mm(op); + TValue tempb, tempc; + cTValue *b, *c; + if ((b = str2num(rb, &tempb)) != NULL && + (c = str2num(rc, &tempc)) != NULL) { /* Try coercion first. */ + setnumV(ra, lj_vm_foldarith(numV(b), numV(c), (int)mm-MM_add)); + return NULL; + } else { + cTValue *mo = lj_meta_lookup(L, rb, mm); + if (tvisnil(mo)) { + mo = lj_meta_lookup(L, rc, mm); + if (tvisnil(mo)) { + if (str2num(rb, &tempb) == NULL) rc = rb; + lj_err_optype(L, rc, LJ_ERR_OPARITH); + return NULL; /* unreachable */ + } + } + return mmcall(L, lj_cont_ra, mo, rb, rc); + } +} + +/* In-place coercion of a number to a string. */ +static LJ_AINLINE int tostring(lua_State *L, TValue *o) +{ + if (tvisstr(o)) { + return 1; + } else if (tvisnumber(o)) { + setstrV(L, o, lj_str_fromnumber(L, o)); + return 1; + } else { + return 0; + } +} + +/* Helper for CAT. Coercion, iterative concat, __concat metamethod. */ +TValue *lj_meta_cat(lua_State *L, TValue *top, int left) +{ + int fromc = 0; + if (left < 0) { left = -left; fromc = 1; } + do { + int n = 1; + if (!(tvisstr(top-1) || tvisnumber(top-1)) || !tostring(L, top)) { + cTValue *mo = lj_meta_lookup(L, top-1, MM_concat); + if (tvisnil(mo)) { + mo = lj_meta_lookup(L, top, MM_concat); + if (tvisnil(mo)) { + if (tvisstr(top-1) || tvisnumber(top-1)) top++; + lj_err_optype(L, top-1, LJ_ERR_OPCAT); + return NULL; /* unreachable */ + } + } + /* One of the top two elements is not a string, call __cat metamethod: + ** + ** before: [...][CAT stack .........................] + ** top-1 top top+1 top+2 + ** pick two: [...][CAT stack ...] [o1] [o2] + ** setup mm: [...][CAT stack ...] [cont|?] [mo|tmtype] [o1] [o2] + ** in asm: [...][CAT stack ...] [cont|PC] [mo|delta] [o1] [o2] + ** ^-- func base ^-- mm base + ** after mm: [...][CAT stack ...] <--push-- [result] + ** next step: [...][CAT stack .............] + */ + copyTV(L, top+2, top); /* Careful with the order of stack copies! */ + copyTV(L, top+1, top-1); + copyTV(L, top, mo); + setcont(top-1, lj_cont_cat); + return top+1; /* Trigger metamethod call. */ + } else if (strV(top)->len == 0) { /* Shortcut. */ + (void)tostring(L, top-1); + } else { + /* Pick as many strings as possible from the top and concatenate them: + ** + ** before: [...][CAT stack ...........................] + ** pick str: [...][CAT stack ...] [...... strings ......] + ** concat: [...][CAT stack ...] [result] + ** next step: [...][CAT stack ............] + */ + MSize tlen = strV(top)->len; + char *buffer; + int i; + for (n = 1; n <= left && tostring(L, top-n); n++) { + MSize len = strV(top-n)->len; + if (len >= LJ_MAX_STR - tlen) + lj_err_msg(L, LJ_ERR_STROV); + tlen += len; + } + buffer = lj_str_needbuf(L, &G(L)->tmpbuf, tlen); + n--; + tlen = 0; + for (i = n; i >= 0; i--) { + MSize len = strV(top-i)->len; + memcpy(buffer + tlen, strVdata(top-i), len); + tlen += len; + } + setstrV(L, top-n, lj_str_new(L, buffer, tlen)); + } + left -= n; + top -= n; + } while (left >= 1); + if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) { + if (!fromc) L->top = curr_topL(L); + lj_gc_step(L); + } + return NULL; +} + +/* Helper for LEN. __len metamethod. */ +TValue * LJ_FASTCALL lj_meta_len(lua_State *L, cTValue *o) +{ + cTValue *mo = lj_meta_lookup(L, o, MM_len); + if (tvisnil(mo)) { + if (LJ_52 && tvistab(o)) + tabref(tabV(o)->metatable)->nomm |= (uint8_t)(1u<gch.metatable), MM_eq); + if (mo) { + TValue *top; + uint32_t it; + if (tabref(o1->gch.metatable) != tabref(o2->gch.metatable)) { + cTValue *mo2 = lj_meta_fast(L, tabref(o2->gch.metatable), MM_eq); + if (mo2 == NULL || !lj_obj_equal(mo, mo2)) + return (TValue *)(intptr_t)ne; + } + top = curr_top(L); + setcont(top, ne ? lj_cont_condf : lj_cont_condt); + copyTV(L, top+1, mo); + it = ~(uint32_t)o1->gch.gct; + setgcV(L, top+2, o1, it); + setgcV(L, top+3, o2, it); + return top+2; /* Trigger metamethod call. */ + } + return (TValue *)(intptr_t)ne; +} + +#if LJ_HASFFI +TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins) +{ + ASMFunction cont = (bc_op(ins) & 1) ? lj_cont_condf : lj_cont_condt; + int op = (int)bc_op(ins) & ~1; + TValue tv; + cTValue *mo, *o2, *o1 = &L->base[bc_a(ins)]; + cTValue *o1mm = o1; + if (op == BC_ISEQV) { + o2 = &L->base[bc_d(ins)]; + if (!tviscdata(o1mm)) o1mm = o2; + } else if (op == BC_ISEQS) { + setstrV(L, &tv, gco2str(proto_kgc(curr_proto(L), ~(ptrdiff_t)bc_d(ins)))); + o2 = &tv; + } else if (op == BC_ISEQN) { + o2 = &mref(curr_proto(L)->k, cTValue)[bc_d(ins)]; + } else { + lua_assert(op == BC_ISEQP); + setitype(&tv, ~bc_d(ins)); + o2 = &tv; + } + mo = lj_meta_lookup(L, o1mm, MM_eq); + if (LJ_LIKELY(!tvisnil(mo))) + return mmcall(L, cont, mo, o1, o2); + else + return (TValue *)(intptr_t)(bc_op(ins) & 1); +} +#endif + +/* Helper for ordered comparisons. String compare, __lt/__le metamethods. */ +TValue *lj_meta_comp(lua_State *L, cTValue *o1, cTValue *o2, int op) +{ + if (LJ_HASFFI && (tviscdata(o1) || tviscdata(o2))) { + ASMFunction cont = (op & 1) ? lj_cont_condf : lj_cont_condt; + MMS mm = (op & 2) ? MM_le : MM_lt; + cTValue *mo = lj_meta_lookup(L, tviscdata(o1) ? o1 : o2, mm); + if (LJ_UNLIKELY(tvisnil(mo))) goto err; + return mmcall(L, cont, mo, o1, o2); + } else if (LJ_52 || itype(o1) == itype(o2)) { + /* Never called with two numbers. */ + if (tvisstr(o1) && tvisstr(o2)) { + int32_t res = lj_str_cmp(strV(o1), strV(o2)); + return (TValue *)(intptr_t)(((op&2) ? res <= 0 : res < 0) ^ (op&1)); + } else { + trymt: + while (1) { + ASMFunction cont = (op & 1) ? lj_cont_condf : lj_cont_condt; + MMS mm = (op & 2) ? MM_le : MM_lt; + cTValue *mo = lj_meta_lookup(L, o1, mm); +#if LJ_52 + if (tvisnil(mo) && tvisnil((mo = lj_meta_lookup(L, o2, mm)))) +#else + cTValue *mo2 = lj_meta_lookup(L, o2, mm); + if (tvisnil(mo) || !lj_obj_equal(mo, mo2)) +#endif + { + if (op & 2) { /* MM_le not found: retry with MM_lt. */ + cTValue *ot = o1; o1 = o2; o2 = ot; /* Swap operands. */ + op ^= 3; /* Use LT and flip condition. */ + continue; + } + goto err; + } + return mmcall(L, cont, mo, o1, o2); + } + } + } else if (tvisbool(o1) && tvisbool(o2)) { + goto trymt; + } else { + err: + lj_err_comp(L, o1, o2); + return NULL; + } +} + +/* Helper for calls. __call metamethod. */ +void lj_meta_call(lua_State *L, TValue *func, TValue *top) +{ + cTValue *mo = lj_meta_lookup(L, func, MM_call); + TValue *p; + if (!tvisfunc(mo)) + lj_err_optype_call(L, func); + for (p = top; p > func; p--) copyTV(L, p, p-1); + copyTV(L, func, mo); +} + +/* Helper for FORI. Coercion. */ +void LJ_FASTCALL lj_meta_for(lua_State *L, TValue *o) +{ + if (!lj_strscan_numberobj(o)) lj_err_msg(L, LJ_ERR_FORINIT); + if (!lj_strscan_numberobj(o+1)) lj_err_msg(L, LJ_ERR_FORLIM); + if (!lj_strscan_numberobj(o+2)) lj_err_msg(L, LJ_ERR_FORSTEP); + if (LJ_DUALNUM) { + /* Ensure all slots are integers or all slots are numbers. */ + int32_t k[3]; + int nint = 0; + ptrdiff_t i; + for (i = 0; i <= 2; i++) { + if (tvisint(o+i)) { + k[i] = intV(o+i); nint++; + } else { + k[i] = lj_num2int(numV(o+i)); nint += ((lua_Number)k[i] == numV(o+i)); + } + } + if (nint == 3) { /* Narrow to integers. */ + setintV(o, k[0]); + setintV(o+1, k[1]); + setintV(o+2, k[2]); + } else if (nint != 0) { /* Widen to numbers. */ + if (tvisint(o)) setnumV(o, (lua_Number)intV(o)); + if (tvisint(o+1)) setnumV(o+1, (lua_Number)intV(o+1)); + if (tvisint(o+2)) setnumV(o+2, (lua_Number)intV(o+2)); + } + } +} + + +``` + +`include/luajit-2.0.5/src/lj_meta.h`: + +```h +/* +** Metamethod handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_META_H +#define _LJ_META_H + +#include "lj_obj.h" + +/* Metamethod handling */ +LJ_FUNC void lj_meta_init(lua_State *L); +LJ_FUNC cTValue *lj_meta_cache(GCtab *mt, MMS mm, GCstr *name); +LJ_FUNC cTValue *lj_meta_lookup(lua_State *L, cTValue *o, MMS mm); +#if LJ_HASFFI +LJ_FUNC int lj_meta_tailcall(lua_State *L, cTValue *tv); +#endif + +#define lj_meta_fastg(g, mt, mm) \ + ((mt) == NULL ? NULL : ((mt)->nomm & (1u<<(mm))) ? NULL : \ + lj_meta_cache(mt, mm, mmname_str(g, mm))) +#define lj_meta_fast(L, mt, mm) lj_meta_fastg(G(L), mt, mm) + +/* C helpers for some instructions, called from assembler VM. */ +LJ_FUNCA cTValue *lj_meta_tget(lua_State *L, cTValue *o, cTValue *k); +LJ_FUNCA TValue *lj_meta_tset(lua_State *L, cTValue *o, cTValue *k); +LJ_FUNCA TValue *lj_meta_arith(lua_State *L, TValue *ra, cTValue *rb, + cTValue *rc, BCReg op); +LJ_FUNCA TValue *lj_meta_cat(lua_State *L, TValue *top, int left); +LJ_FUNCA TValue * LJ_FASTCALL lj_meta_len(lua_State *L, cTValue *o); +LJ_FUNCA TValue *lj_meta_equal(lua_State *L, GCobj *o1, GCobj *o2, int ne); +LJ_FUNCA TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins); +LJ_FUNCA TValue *lj_meta_comp(lua_State *L, cTValue *o1, cTValue *o2, int op); +LJ_FUNCA void lj_meta_call(lua_State *L, TValue *func, TValue *top); +LJ_FUNCA void LJ_FASTCALL lj_meta_for(lua_State *L, TValue *o); + +#endif + +``` + +`include/luajit-2.0.5/src/lj_obj.c`: + +```c +/* +** Miscellaneous object handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_obj_c +#define LUA_CORE + +#include "lj_obj.h" + +/* Object type names. */ +LJ_DATADEF const char *const lj_obj_typename[] = { /* ORDER LUA_T */ + "no value", "nil", "boolean", "userdata", "number", "string", + "table", "function", "userdata", "thread", "proto", "cdata" +}; + +LJ_DATADEF const char *const lj_obj_itypename[] = { /* ORDER LJ_T */ + "nil", "boolean", "boolean", "userdata", "string", "upval", "thread", + "proto", "function", "trace", "cdata", "table", "userdata", "number" +}; + +/* Compare two objects without calling metamethods. */ +int lj_obj_equal(cTValue *o1, cTValue *o2) +{ + if (itype(o1) == itype(o2)) { + if (tvispri(o1)) + return 1; + if (!tvisnum(o1)) + return gcrefeq(o1->gcr, o2->gcr); + } else if (!tvisnumber(o1) || !tvisnumber(o2)) { + return 0; + } + return numberVnum(o1) == numberVnum(o2); +} + + +``` + +`include/luajit-2.0.5/src/lj_obj.h`: + +```h +/* +** LuaJIT VM tags, values and objects. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#ifndef _LJ_OBJ_H +#define _LJ_OBJ_H + +#include "lua.h" +#include "lj_def.h" +#include "lj_arch.h" + +/* -- Memory references (32 bit address space) ---------------------------- */ + +/* Memory size. */ +typedef uint32_t MSize; + +/* Memory reference */ +typedef struct MRef { + uint32_t ptr32; /* Pseudo 32 bit pointer. */ +} MRef; + +#define mref(r, t) ((t *)(void *)(uintptr_t)(r).ptr32) + +#define setmref(r, p) ((r).ptr32 = (uint32_t)(uintptr_t)(void *)(p)) +#define setmrefr(r, v) ((r).ptr32 = (v).ptr32) + +/* -- GC object references (32 bit address space) ------------------------- */ + +/* GCobj reference */ +typedef struct GCRef { + uint32_t gcptr32; /* Pseudo 32 bit pointer. */ +} GCRef; + +/* Common GC header for all collectable objects. */ +#define GCHeader GCRef nextgc; uint8_t marked; uint8_t gct +/* This occupies 6 bytes, so use the next 2 bytes for non-32 bit fields. */ + +#define gcref(r) ((GCobj *)(uintptr_t)(r).gcptr32) +#define gcrefp(r, t) ((t *)(void *)(uintptr_t)(r).gcptr32) +#define gcrefu(r) ((r).gcptr32) +#define gcrefi(r) ((int32_t)(r).gcptr32) +#define gcrefeq(r1, r2) ((r1).gcptr32 == (r2).gcptr32) +#define gcnext(gc) (gcref((gc)->gch.nextgc)) + +#define setgcref(r, gc) ((r).gcptr32 = (uint32_t)(uintptr_t)&(gc)->gch) +#define setgcrefi(r, i) ((r).gcptr32 = (uint32_t)(i)) +#define setgcrefp(r, p) ((r).gcptr32 = (uint32_t)(uintptr_t)(p)) +#define setgcrefnull(r) ((r).gcptr32 = 0) +#define setgcrefr(r, v) ((r).gcptr32 = (v).gcptr32) + +/* IMPORTANT NOTE: +** +** All uses of the setgcref* macros MUST be accompanied with a write barrier. +** +** This is to ensure the integrity of the incremental GC. The invariant +** to preserve is that a black object never points to a white object. +** I.e. never store a white object into a field of a black object. +** +** It's ok to LEAVE OUT the write barrier ONLY in the following cases: +** - The source is not a GC object (NULL). +** - The target is a GC root. I.e. everything in global_State. +** - The target is a lua_State field (threads are never black). +** - The target is a stack slot, see setgcV et al. +** - The target is an open upvalue, i.e. pointing to a stack slot. +** - The target is a newly created object (i.e. marked white). But make +** sure nothing invokes the GC inbetween. +** - The target and the source are the same object (self-reference). +** - The target already contains the object (e.g. moving elements around). +** +** The most common case is a store to a stack slot. All other cases where +** a barrier has been omitted are annotated with a NOBARRIER comment. +** +** The same logic applies for stores to table slots (array part or hash +** part). ALL uses of lj_tab_set* require a barrier for the stored value +** *and* the stored key, based on the above rules. In practice this means +** a barrier is needed if *either* of the key or value are a GC object. +** +** It's ok to LEAVE OUT the write barrier in the following special cases: +** - The stored value is nil. The key doesn't matter because it's either +** not resurrected or lj_tab_newkey() will take care of the key barrier. +** - The key doesn't matter if the *previously* stored value is guaranteed +** to be non-nil (because the key is kept alive in the table). +** - The key doesn't matter if it's guaranteed not to be part of the table, +** since lj_tab_newkey() takes care of the key barrier. This applies +** trivially to new tables, but watch out for resurrected keys. Storing +** a nil value leaves the key in the table! +** +** In case of doubt use lj_gc_anybarriert() as it's rather cheap. It's used +** by the interpreter for all table stores. +** +** Note: In contrast to Lua's GC, LuaJIT's GC does *not* specially mark +** dead keys in tables. The reference is left in, but it's guaranteed to +** be never dereferenced as long as the value is nil. It's ok if the key is +** freed or if any object subsequently gets the same address. +** +** Not destroying dead keys helps to keep key hash slots stable. This avoids +** specialization back-off for HREFK when a value flips between nil and +** non-nil and the GC gets in the way. It also allows safely hoisting +** HREF/HREFK across GC steps. Dead keys are only removed if a table is +** resized (i.e. by NEWREF) and xREF must not be CSEd across a resize. +** +** The trade-off is that a write barrier for tables must take the key into +** account, too. Implicitly resurrecting the key by storing a non-nil value +** may invalidate the incremental GC invariant. +*/ + +/* -- Common type definitions --------------------------------------------- */ + +/* Types for handling bytecodes. Need this here, details in lj_bc.h. */ +typedef uint32_t BCIns; /* Bytecode instruction. */ +typedef uint32_t BCPos; /* Bytecode position. */ +typedef uint32_t BCReg; /* Bytecode register. */ +typedef int32_t BCLine; /* Bytecode line number. */ + +/* Internal assembler functions. Never call these directly from C. */ +typedef void (*ASMFunction)(void); + +/* Resizable string buffer. Need this here, details in lj_str.h. */ +typedef struct SBuf { + char *buf; /* String buffer base. */ + MSize n; /* String buffer length. */ + MSize sz; /* String buffer size. */ +} SBuf; + +/* -- Tags and values ----------------------------------------------------- */ + +/* Frame link. */ +typedef union { + int32_t ftsz; /* Frame type and size of previous frame. */ + MRef pcr; /* Overlaps PC for Lua frames. */ +} FrameLink; + +/* Tagged value. */ +typedef LJ_ALIGN(8) union TValue { + uint64_t u64; /* 64 bit pattern overlaps number. */ + lua_Number n; /* Number object overlaps split tag/value object. */ + struct { + LJ_ENDIAN_LOHI( + union { + GCRef gcr; /* GCobj reference (if any). */ + int32_t i; /* Integer value. */ + }; + , uint32_t it; /* Internal object tag. Must overlap MSW of number. */ + ) + }; + struct { + LJ_ENDIAN_LOHI( + GCRef func; /* Function for next frame (or dummy L). */ + , FrameLink tp; /* Link to previous frame. */ + ) + } fr; + struct { + LJ_ENDIAN_LOHI( + uint32_t lo; /* Lower 32 bits of number. */ + , uint32_t hi; /* Upper 32 bits of number. */ + ) + } u32; +} TValue; + +typedef const TValue cTValue; + +#define tvref(r) (mref(r, TValue)) + +/* More external and GCobj tags for internal objects. */ +#define LAST_TT LUA_TTHREAD +#define LUA_TPROTO (LAST_TT+1) +#define LUA_TCDATA (LAST_TT+2) + +/* Internal object tags. +** +** Internal tags overlap the MSW of a number object (must be a double). +** Interpreted as a double these are special NaNs. The FPU only generates +** one type of NaN (0xfff8_0000_0000_0000). So MSWs > 0xfff80000 are available +** for use as internal tags. Small negative numbers are used to shorten the +** encoding of type comparisons (reg/mem against sign-ext. 8 bit immediate). +** +** ---MSW---.---LSW--- +** primitive types | itype | | +** lightuserdata | itype | void * | (32 bit platforms) +** lightuserdata |ffff| void * | (64 bit platforms, 47 bit pointers) +** GC objects | itype | GCRef | +** int (LJ_DUALNUM)| itype | int | +** number -------double------ +** +** ORDER LJ_T +** Primitive types nil/false/true must be first, lightuserdata next. +** GC objects are at the end, table/userdata must be lowest. +** Also check lj_ir.h for similar ordering constraints. +*/ +#define LJ_TNIL (~0u) +#define LJ_TFALSE (~1u) +#define LJ_TTRUE (~2u) +#define LJ_TLIGHTUD (~3u) +#define LJ_TSTR (~4u) +#define LJ_TUPVAL (~5u) +#define LJ_TTHREAD (~6u) +#define LJ_TPROTO (~7u) +#define LJ_TFUNC (~8u) +#define LJ_TTRACE (~9u) +#define LJ_TCDATA (~10u) +#define LJ_TTAB (~11u) +#define LJ_TUDATA (~12u) +/* This is just the canonical number type used in some places. */ +#define LJ_TNUMX (~13u) + +/* Integers have itype == LJ_TISNUM doubles have itype < LJ_TISNUM */ +#if LJ_64 +#define LJ_TISNUM 0xfffeffffu +#else +#define LJ_TISNUM LJ_TNUMX +#endif +#define LJ_TISTRUECOND LJ_TFALSE +#define LJ_TISPRI LJ_TTRUE +#define LJ_TISGCV (LJ_TSTR+1) +#define LJ_TISTABUD LJ_TTAB + +/* -- String object ------------------------------------------------------- */ + +/* String object header. String payload follows. */ +typedef struct GCstr { + GCHeader; + uint8_t reserved; /* Used by lexer for fast lookup of reserved words. */ + uint8_t unused; + MSize hash; /* Hash of string. */ + MSize len; /* Size of string. */ +} GCstr; + +#define strref(r) (&gcref((r))->str) +#define strdata(s) ((const char *)((s)+1)) +#define strdatawr(s) ((char *)((s)+1)) +#define strVdata(o) strdata(strV(o)) +#define sizestring(s) (sizeof(struct GCstr)+(s)->len+1) + +/* -- Userdata object ----------------------------------------------------- */ + +/* Userdata object. Payload follows. */ +typedef struct GCudata { + GCHeader; + uint8_t udtype; /* Userdata type. */ + uint8_t unused2; + GCRef env; /* Should be at same offset in GCfunc. */ + MSize len; /* Size of payload. */ + GCRef metatable; /* Must be at same offset in GCtab. */ + uint32_t align1; /* To force 8 byte alignment of the payload. */ +} GCudata; + +/* Userdata types. */ +enum { + UDTYPE_USERDATA, /* Regular userdata. */ + UDTYPE_IO_FILE, /* I/O library FILE. */ + UDTYPE_FFI_CLIB, /* FFI C library namespace. */ + UDTYPE__MAX +}; + +#define uddata(u) ((void *)((u)+1)) +#define sizeudata(u) (sizeof(struct GCudata)+(u)->len) + +/* -- C data object ------------------------------------------------------- */ + +/* C data object. Payload follows. */ +typedef struct GCcdata { + GCHeader; + uint16_t ctypeid; /* C type ID. */ +} GCcdata; + +/* Prepended to variable-sized or realigned C data objects. */ +typedef struct GCcdataVar { + uint16_t offset; /* Offset to allocated memory (relative to GCcdata). */ + uint16_t extra; /* Extra space allocated (incl. GCcdata + GCcdatav). */ + MSize len; /* Size of payload. */ +} GCcdataVar; + +#define cdataptr(cd) ((void *)((cd)+1)) +#define cdataisv(cd) ((cd)->marked & 0x80) +#define cdatav(cd) ((GCcdataVar *)((char *)(cd) - sizeof(GCcdataVar))) +#define cdatavlen(cd) check_exp(cdataisv(cd), cdatav(cd)->len) +#define sizecdatav(cd) (cdatavlen(cd) + cdatav(cd)->extra) +#define memcdatav(cd) ((void *)((char *)(cd) - cdatav(cd)->offset)) + +/* -- Prototype object ---------------------------------------------------- */ + +#define SCALE_NUM_GCO ((int32_t)sizeof(lua_Number)/sizeof(GCRef)) +#define round_nkgc(n) (((n) + SCALE_NUM_GCO-1) & ~(SCALE_NUM_GCO-1)) + +typedef struct GCproto { + GCHeader; + uint8_t numparams; /* Number of parameters. */ + uint8_t framesize; /* Fixed frame size. */ + MSize sizebc; /* Number of bytecode instructions. */ + GCRef gclist; + MRef k; /* Split constant array (points to the middle). */ + MRef uv; /* Upvalue list. local slot|0x8000 or parent uv idx. */ + MSize sizekgc; /* Number of collectable constants. */ + MSize sizekn; /* Number of lua_Number constants. */ + MSize sizept; /* Total size including colocated arrays. */ + uint8_t sizeuv; /* Number of upvalues. */ + uint8_t flags; /* Miscellaneous flags (see below). */ + uint16_t trace; /* Anchor for chain of root traces. */ + /* ------ The following fields are for debugging/tracebacks only ------ */ + GCRef chunkname; /* Name of the chunk this function was defined in. */ + BCLine firstline; /* First line of the function definition. */ + BCLine numline; /* Number of lines for the function definition. */ + MRef lineinfo; /* Compressed map from bytecode ins. to source line. */ + MRef uvinfo; /* Upvalue names. */ + MRef varinfo; /* Names and compressed extents of local variables. */ +} GCproto; + +/* Flags for prototype. */ +#define PROTO_CHILD 0x01 /* Has child prototypes. */ +#define PROTO_VARARG 0x02 /* Vararg function. */ +#define PROTO_FFI 0x04 /* Uses BC_KCDATA for FFI datatypes. */ +#define PROTO_NOJIT 0x08 /* JIT disabled for this function. */ +#define PROTO_ILOOP 0x10 /* Patched bytecode with ILOOP etc. */ +/* Only used during parsing. */ +#define PROTO_HAS_RETURN 0x20 /* Already emitted a return. */ +#define PROTO_FIXUP_RETURN 0x40 /* Need to fixup emitted returns. */ +/* Top bits used for counting created closures. */ +#define PROTO_CLCOUNT 0x20 /* Base of saturating 3 bit counter. */ +#define PROTO_CLC_BITS 3 +#define PROTO_CLC_POLY (3*PROTO_CLCOUNT) /* Polymorphic threshold. */ + +#define PROTO_UV_LOCAL 0x8000 /* Upvalue for local slot. */ +#define PROTO_UV_IMMUTABLE 0x4000 /* Immutable upvalue. */ + +#define proto_kgc(pt, idx) \ + check_exp((uintptr_t)(intptr_t)(idx) >= (uintptr_t)-(intptr_t)(pt)->sizekgc, \ + gcref(mref((pt)->k, GCRef)[(idx)])) +#define proto_knumtv(pt, idx) \ + check_exp((uintptr_t)(idx) < (pt)->sizekn, &mref((pt)->k, TValue)[(idx)]) +#define proto_bc(pt) ((BCIns *)((char *)(pt) + sizeof(GCproto))) +#define proto_bcpos(pt, pc) ((BCPos)((pc) - proto_bc(pt))) +#define proto_uv(pt) (mref((pt)->uv, uint16_t)) + +#define proto_chunkname(pt) (strref((pt)->chunkname)) +#define proto_chunknamestr(pt) (strdata(proto_chunkname((pt)))) +#define proto_lineinfo(pt) (mref((pt)->lineinfo, const void)) +#define proto_uvinfo(pt) (mref((pt)->uvinfo, const uint8_t)) +#define proto_varinfo(pt) (mref((pt)->varinfo, const uint8_t)) + +/* -- Upvalue object ------------------------------------------------------ */ + +typedef struct GCupval { + GCHeader; + uint8_t closed; /* Set if closed (i.e. uv->v == &uv->u.value). */ + uint8_t immutable; /* Immutable value. */ + union { + TValue tv; /* If closed: the value itself. */ + struct { /* If open: double linked list, anchored at thread. */ + GCRef prev; + GCRef next; + }; + }; + MRef v; /* Points to stack slot (open) or above (closed). */ + uint32_t dhash; /* Disambiguation hash: dh1 != dh2 => cannot alias. */ +} GCupval; + +#define uvprev(uv_) (&gcref((uv_)->prev)->uv) +#define uvnext(uv_) (&gcref((uv_)->next)->uv) +#define uvval(uv_) (mref((uv_)->v, TValue)) + +/* -- Function object (closures) ------------------------------------------ */ + +/* Common header for functions. env should be at same offset in GCudata. */ +#define GCfuncHeader \ + GCHeader; uint8_t ffid; uint8_t nupvalues; \ + GCRef env; GCRef gclist; MRef pc + +typedef struct GCfuncC { + GCfuncHeader; + lua_CFunction f; /* C function to be called. */ + TValue upvalue[1]; /* Array of upvalues (TValue). */ +} GCfuncC; + +typedef struct GCfuncL { + GCfuncHeader; + GCRef uvptr[1]; /* Array of _pointers_ to upvalue objects (GCupval). */ +} GCfuncL; + +typedef union GCfunc { + GCfuncC c; + GCfuncL l; +} GCfunc; + +#define FF_LUA 0 +#define FF_C 1 +#define isluafunc(fn) ((fn)->c.ffid == FF_LUA) +#define iscfunc(fn) ((fn)->c.ffid == FF_C) +#define isffunc(fn) ((fn)->c.ffid > FF_C) +#define funcproto(fn) \ + check_exp(isluafunc(fn), (GCproto *)(mref((fn)->l.pc, char)-sizeof(GCproto))) +#define sizeCfunc(n) (sizeof(GCfuncC)-sizeof(TValue)+sizeof(TValue)*(n)) +#define sizeLfunc(n) (sizeof(GCfuncL)-sizeof(GCRef)+sizeof(GCRef)*(n)) + +/* -- Table object -------------------------------------------------------- */ + +/* Hash node. */ +typedef struct Node { + TValue val; /* Value object. Must be first field. */ + TValue key; /* Key object. */ + MRef next; /* Hash chain. */ + MRef freetop; /* Top of free elements (stored in t->node[0]). */ +} Node; + +LJ_STATIC_ASSERT(offsetof(Node, val) == 0); + +typedef struct GCtab { + GCHeader; + uint8_t nomm; /* Negative cache for fast metamethods. */ + int8_t colo; /* Array colocation. */ + MRef array; /* Array part. */ + GCRef gclist; + GCRef metatable; /* Must be at same offset in GCudata. */ + MRef node; /* Hash part. */ + uint32_t asize; /* Size of array part (keys [0, asize-1]). */ + uint32_t hmask; /* Hash part mask (size of hash part - 1). */ +} GCtab; + +#define sizetabcolo(n) ((n)*sizeof(TValue) + sizeof(GCtab)) +#define tabref(r) (&gcref((r))->tab) +#define noderef(r) (mref((r), Node)) +#define nextnode(n) (mref((n)->next, Node)) + +/* -- State objects ------------------------------------------------------- */ + +/* VM states. */ +enum { + LJ_VMST_INTERP, /* Interpreter. */ + LJ_VMST_C, /* C function. */ + LJ_VMST_GC, /* Garbage collector. */ + LJ_VMST_EXIT, /* Trace exit handler. */ + LJ_VMST_RECORD, /* Trace recorder. */ + LJ_VMST_OPT, /* Optimizer. */ + LJ_VMST_ASM, /* Assembler. */ + LJ_VMST__MAX +}; + +#define setvmstate(g, st) ((g)->vmstate = ~LJ_VMST_##st) + +/* Metamethods. ORDER MM */ +#ifdef LJ_HASFFI +#define MMDEF_FFI(_) _(new) +#else +#define MMDEF_FFI(_) +#endif + +#if LJ_52 || LJ_HASFFI +#define MMDEF_PAIRS(_) _(pairs) _(ipairs) +#else +#define MMDEF_PAIRS(_) +#define MM_pairs 255 +#define MM_ipairs 255 +#endif + +#define MMDEF(_) \ + _(index) _(newindex) _(gc) _(mode) _(eq) _(len) \ + /* Only the above (fast) metamethods are negative cached (max. 8). */ \ + _(lt) _(le) _(concat) _(call) \ + /* The following must be in ORDER ARITH. */ \ + _(add) _(sub) _(mul) _(div) _(mod) _(pow) _(unm) \ + /* The following are used in the standard libraries. */ \ + _(metatable) _(tostring) MMDEF_FFI(_) MMDEF_PAIRS(_) + +typedef enum { +#define MMENUM(name) MM_##name, +MMDEF(MMENUM) +#undef MMENUM + MM__MAX, + MM____ = MM__MAX, + MM_FAST = MM_len +} MMS; + +/* GC root IDs. */ +typedef enum { + GCROOT_MMNAME, /* Metamethod names. */ + GCROOT_MMNAME_LAST = GCROOT_MMNAME + MM__MAX-1, + GCROOT_BASEMT, /* Metatables for base types. */ + GCROOT_BASEMT_NUM = GCROOT_BASEMT + ~LJ_TNUMX, + GCROOT_IO_INPUT, /* Userdata for default I/O input file. */ + GCROOT_IO_OUTPUT, /* Userdata for default I/O output file. */ + GCROOT_MAX +} GCRootID; + +#define basemt_it(g, it) ((g)->gcroot[GCROOT_BASEMT+~(it)]) +#define basemt_obj(g, o) ((g)->gcroot[GCROOT_BASEMT+itypemap(o)]) +#define mmname_str(g, mm) (strref((g)->gcroot[GCROOT_MMNAME+(mm)])) + +typedef struct GCState { + MSize total; /* Memory currently allocated. */ + MSize threshold; /* Memory threshold. */ + uint8_t currentwhite; /* Current white color. */ + uint8_t state; /* GC state. */ + uint8_t nocdatafin; /* No cdata finalizer called. */ + uint8_t unused2; + MSize sweepstr; /* Sweep position in string table. */ + GCRef root; /* List of all collectable objects. */ + MRef sweep; /* Sweep position in root list. */ + GCRef gray; /* List of gray objects. */ + GCRef grayagain; /* List of objects for atomic traversal. */ + GCRef weak; /* List of weak tables (to be cleared). */ + GCRef mmudata; /* List of userdata (to be finalized). */ + MSize stepmul; /* Incremental GC step granularity. */ + MSize debt; /* Debt (how much GC is behind schedule). */ + MSize estimate; /* Estimate of memory actually in use. */ + MSize pause; /* Pause between successive GC cycles. */ +} GCState; + +/* Global state, shared by all threads of a Lua universe. */ +typedef struct global_State { + GCRef *strhash; /* String hash table (hash chain anchors). */ + MSize strmask; /* String hash mask (size of hash table - 1). */ + MSize strnum; /* Number of strings in hash table. */ + lua_Alloc allocf; /* Memory allocator. */ + void *allocd; /* Memory allocator data. */ + GCState gc; /* Garbage collector. */ + SBuf tmpbuf; /* Temporary buffer for string concatenation. */ + Node nilnode; /* Fallback 1-element hash part (nil key and value). */ + GCstr strempty; /* Empty string. */ + uint8_t stremptyz; /* Zero terminator of empty string. */ + uint8_t hookmask; /* Hook mask. */ + uint8_t dispatchmode; /* Dispatch mode. */ + uint8_t vmevmask; /* VM event mask. */ + GCRef mainthref; /* Link to main thread. */ + TValue registrytv; /* Anchor for registry. */ + TValue tmptv, tmptv2; /* Temporary TValues. */ + GCupval uvhead; /* Head of double-linked list of all open upvalues. */ + int32_t hookcount; /* Instruction hook countdown. */ + int32_t hookcstart; /* Start count for instruction hook counter. */ + lua_Hook hookf; /* Hook function. */ + lua_CFunction wrapf; /* Wrapper for C function calls. */ + lua_CFunction panic; /* Called as a last resort for errors. */ + volatile int32_t vmstate; /* VM state or current JIT code trace number. */ + BCIns bc_cfunc_int; /* Bytecode for internal C function calls. */ + BCIns bc_cfunc_ext; /* Bytecode for external C function calls. */ + GCRef jit_L; /* Current JIT code lua_State or NULL. */ + MRef jit_base; /* Current JIT code L->base. */ + MRef ctype_state; /* Pointer to C type state. */ + GCRef gcroot[GCROOT_MAX]; /* GC roots. */ +} global_State; + +#define mainthread(g) (&gcref(g->mainthref)->th) +#define niltv(L) \ + check_exp(tvisnil(&G(L)->nilnode.val), &G(L)->nilnode.val) +#define niltvg(g) \ + check_exp(tvisnil(&(g)->nilnode.val), &(g)->nilnode.val) + +/* Hook management. Hook event masks are defined in lua.h. */ +#define HOOK_EVENTMASK 0x0f +#define HOOK_ACTIVE 0x10 +#define HOOK_ACTIVE_SHIFT 4 +#define HOOK_VMEVENT 0x20 +#define HOOK_GC 0x40 +#define hook_active(g) ((g)->hookmask & HOOK_ACTIVE) +#define hook_enter(g) ((g)->hookmask |= HOOK_ACTIVE) +#define hook_entergc(g) ((g)->hookmask |= (HOOK_ACTIVE|HOOK_GC)) +#define hook_vmevent(g) ((g)->hookmask |= (HOOK_ACTIVE|HOOK_VMEVENT)) +#define hook_leave(g) ((g)->hookmask &= ~HOOK_ACTIVE) +#define hook_save(g) ((g)->hookmask & ~HOOK_EVENTMASK) +#define hook_restore(g, h) \ + ((g)->hookmask = ((g)->hookmask & HOOK_EVENTMASK) | (h)) + +/* Per-thread state object. */ +struct lua_State { + GCHeader; + uint8_t dummy_ffid; /* Fake FF_C for curr_funcisL() on dummy frames. */ + uint8_t status; /* Thread status. */ + MRef glref; /* Link to global state. */ + GCRef gclist; /* GC chain. */ + TValue *base; /* Base of currently executing function. */ + TValue *top; /* First free slot in the stack. */ + MRef maxstack; /* Last free slot in the stack. */ + MRef stack; /* Stack base. */ + GCRef openupval; /* List of open upvalues in the stack. */ + GCRef env; /* Thread environment (table of globals). */ + void *cframe; /* End of C stack frame chain. */ + MSize stacksize; /* True stack size (incl. LJ_STACK_EXTRA). */ +}; + +#define G(L) (mref(L->glref, global_State)) +#define registry(L) (&G(L)->registrytv) + +/* Macros to access the currently executing (Lua) function. */ +#define curr_func(L) (&gcref((L->base-1)->fr.func)->fn) +#define curr_funcisL(L) (isluafunc(curr_func(L))) +#define curr_proto(L) (funcproto(curr_func(L))) +#define curr_topL(L) (L->base + curr_proto(L)->framesize) +#define curr_top(L) (curr_funcisL(L) ? curr_topL(L) : L->top) + +/* -- GC object definition and conversions -------------------------------- */ + +/* GC header for generic access to common fields of GC objects. */ +typedef struct GChead { + GCHeader; + uint8_t unused1; + uint8_t unused2; + GCRef env; + GCRef gclist; + GCRef metatable; +} GChead; + +/* The env field SHOULD be at the same offset for all GC objects. */ +LJ_STATIC_ASSERT(offsetof(GChead, env) == offsetof(GCfuncL, env)); +LJ_STATIC_ASSERT(offsetof(GChead, env) == offsetof(GCudata, env)); + +/* The metatable field MUST be at the same offset for all GC objects. */ +LJ_STATIC_ASSERT(offsetof(GChead, metatable) == offsetof(GCtab, metatable)); +LJ_STATIC_ASSERT(offsetof(GChead, metatable) == offsetof(GCudata, metatable)); + +/* The gclist field MUST be at the same offset for all GC objects. */ +LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(lua_State, gclist)); +LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCproto, gclist)); +LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCfuncL, gclist)); +LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCtab, gclist)); + +typedef union GCobj { + GChead gch; + GCstr str; + GCupval uv; + lua_State th; + GCproto pt; + GCfunc fn; + GCcdata cd; + GCtab tab; + GCudata ud; +} GCobj; + +/* Macros to convert a GCobj pointer into a specific value. */ +#define gco2str(o) check_exp((o)->gch.gct == ~LJ_TSTR, &(o)->str) +#define gco2uv(o) check_exp((o)->gch.gct == ~LJ_TUPVAL, &(o)->uv) +#define gco2th(o) check_exp((o)->gch.gct == ~LJ_TTHREAD, &(o)->th) +#define gco2pt(o) check_exp((o)->gch.gct == ~LJ_TPROTO, &(o)->pt) +#define gco2func(o) check_exp((o)->gch.gct == ~LJ_TFUNC, &(o)->fn) +#define gco2cd(o) check_exp((o)->gch.gct == ~LJ_TCDATA, &(o)->cd) +#define gco2tab(o) check_exp((o)->gch.gct == ~LJ_TTAB, &(o)->tab) +#define gco2ud(o) check_exp((o)->gch.gct == ~LJ_TUDATA, &(o)->ud) + +/* Macro to convert any collectable object into a GCobj pointer. */ +#define obj2gco(v) ((GCobj *)(v)) + +/* -- TValue getters/setters ---------------------------------------------- */ + +#ifdef LUA_USE_ASSERT +#include "lj_gc.h" +#endif + +/* Macros to test types. */ +#define itype(o) ((o)->it) +#define tvisnil(o) (itype(o) == LJ_TNIL) +#define tvisfalse(o) (itype(o) == LJ_TFALSE) +#define tvistrue(o) (itype(o) == LJ_TTRUE) +#define tvisbool(o) (tvisfalse(o) || tvistrue(o)) +#if LJ_64 +#define tvislightud(o) (((int32_t)itype(o) >> 15) == -2) +#else +#define tvislightud(o) (itype(o) == LJ_TLIGHTUD) +#endif +#define tvisstr(o) (itype(o) == LJ_TSTR) +#define tvisfunc(o) (itype(o) == LJ_TFUNC) +#define tvisthread(o) (itype(o) == LJ_TTHREAD) +#define tvisproto(o) (itype(o) == LJ_TPROTO) +#define tviscdata(o) (itype(o) == LJ_TCDATA) +#define tvistab(o) (itype(o) == LJ_TTAB) +#define tvisudata(o) (itype(o) == LJ_TUDATA) +#define tvisnumber(o) (itype(o) <= LJ_TISNUM) +#define tvisint(o) (LJ_DUALNUM && itype(o) == LJ_TISNUM) +#define tvisnum(o) (itype(o) < LJ_TISNUM) + +#define tvistruecond(o) (itype(o) < LJ_TISTRUECOND) +#define tvispri(o) (itype(o) >= LJ_TISPRI) +#define tvistabud(o) (itype(o) <= LJ_TISTABUD) /* && !tvisnum() */ +#define tvisgcv(o) ((itype(o) - LJ_TISGCV) > (LJ_TNUMX - LJ_TISGCV)) + +/* Special macros to test numbers for NaN, +0, -0, +1 and raw equality. */ +#define tvisnan(o) ((o)->n != (o)->n) +#if LJ_64 +#define tviszero(o) (((o)->u64 << 1) == 0) +#else +#define tviszero(o) (((o)->u32.lo | ((o)->u32.hi << 1)) == 0) +#endif +#define tvispzero(o) ((o)->u64 == 0) +#define tvismzero(o) ((o)->u64 == U64x(80000000,00000000)) +#define tvispone(o) ((o)->u64 == U64x(3ff00000,00000000)) +#define rawnumequal(o1, o2) ((o1)->u64 == (o2)->u64) + +/* Macros to convert type ids. */ +#if LJ_64 +#define itypemap(o) \ + (tvisnumber(o) ? ~LJ_TNUMX : tvislightud(o) ? ~LJ_TLIGHTUD : ~itype(o)) +#else +#define itypemap(o) (tvisnumber(o) ? ~LJ_TNUMX : ~itype(o)) +#endif + +/* Macros to get tagged values. */ +#define gcval(o) (gcref((o)->gcr)) +#define boolV(o) check_exp(tvisbool(o), (LJ_TFALSE - (o)->it)) +#if LJ_64 +#define lightudV(o) \ + check_exp(tvislightud(o), (void *)((o)->u64 & U64x(00007fff,ffffffff))) +#else +#define lightudV(o) check_exp(tvislightud(o), gcrefp((o)->gcr, void)) +#endif +#define gcV(o) check_exp(tvisgcv(o), gcval(o)) +#define strV(o) check_exp(tvisstr(o), &gcval(o)->str) +#define funcV(o) check_exp(tvisfunc(o), &gcval(o)->fn) +#define threadV(o) check_exp(tvisthread(o), &gcval(o)->th) +#define protoV(o) check_exp(tvisproto(o), &gcval(o)->pt) +#define cdataV(o) check_exp(tviscdata(o), &gcval(o)->cd) +#define tabV(o) check_exp(tvistab(o), &gcval(o)->tab) +#define udataV(o) check_exp(tvisudata(o), &gcval(o)->ud) +#define numV(o) check_exp(tvisnum(o), (o)->n) +#define intV(o) check_exp(tvisint(o), (int32_t)(o)->i) + +/* Macros to set tagged values. */ +#define setitype(o, i) ((o)->it = (i)) +#define setnilV(o) ((o)->it = LJ_TNIL) +#define setboolV(o, x) ((o)->it = LJ_TFALSE-(uint32_t)(x)) + +static LJ_AINLINE void setlightudV(TValue *o, void *p) +{ +#if LJ_64 + o->u64 = (uint64_t)p | (((uint64_t)0xffff) << 48); +#else + setgcrefp(o->gcr, p); setitype(o, LJ_TLIGHTUD); +#endif +} + +#if LJ_64 +#define checklightudptr(L, p) \ + (((uint64_t)(p) >> 47) ? (lj_err_msg(L, LJ_ERR_BADLU), NULL) : (p)) +#define setcont(o, f) \ + ((o)->u64 = (uint64_t)(void *)(f) - (uint64_t)lj_vm_asm_begin) +#else +#define checklightudptr(L, p) (p) +#define setcont(o, f) setlightudV((o), (void *)(f)) +#endif + +#define tvchecklive(L, o) \ + UNUSED(L), lua_assert(!tvisgcv(o) || \ + ((~itype(o) == gcval(o)->gch.gct) && !isdead(G(L), gcval(o)))) + +static LJ_AINLINE void setgcV(lua_State *L, TValue *o, GCobj *v, uint32_t itype) +{ + setgcref(o->gcr, v); setitype(o, itype); tvchecklive(L, o); +} + +#define define_setV(name, type, tag) \ +static LJ_AINLINE void name(lua_State *L, TValue *o, type *v) \ +{ \ + setgcV(L, o, obj2gco(v), tag); \ +} +define_setV(setstrV, GCstr, LJ_TSTR) +define_setV(setthreadV, lua_State, LJ_TTHREAD) +define_setV(setprotoV, GCproto, LJ_TPROTO) +define_setV(setfuncV, GCfunc, LJ_TFUNC) +define_setV(setcdataV, GCcdata, LJ_TCDATA) +define_setV(settabV, GCtab, LJ_TTAB) +define_setV(setudataV, GCudata, LJ_TUDATA) + +#define setnumV(o, x) ((o)->n = (x)) +#define setnanV(o) ((o)->u64 = U64x(fff80000,00000000)) +#define setpinfV(o) ((o)->u64 = U64x(7ff00000,00000000)) +#define setminfV(o) ((o)->u64 = U64x(fff00000,00000000)) + +static LJ_AINLINE void setintV(TValue *o, int32_t i) +{ +#if LJ_DUALNUM + o->i = (uint32_t)i; setitype(o, LJ_TISNUM); +#else + o->n = (lua_Number)i; +#endif +} + +static LJ_AINLINE void setint64V(TValue *o, int64_t i) +{ + if (LJ_DUALNUM && LJ_LIKELY(i == (int64_t)(int32_t)i)) + setintV(o, (int32_t)i); + else + setnumV(o, (lua_Number)i); +} + +#if LJ_64 +#define setintptrV(o, i) setint64V((o), (i)) +#else +#define setintptrV(o, i) setintV((o), (i)) +#endif + +/* Copy tagged values. */ +static LJ_AINLINE void copyTV(lua_State *L, TValue *o1, const TValue *o2) +{ + *o1 = *o2; tvchecklive(L, o1); +} + +/* -- Number to integer conversion ---------------------------------------- */ + +#if LJ_SOFTFP +LJ_ASMF int32_t lj_vm_tobit(double x); +#endif + +static LJ_AINLINE int32_t lj_num2bit(lua_Number n) +{ +#if LJ_SOFTFP + return lj_vm_tobit(n); +#else + TValue o; + o.n = n + 6755399441055744.0; /* 2^52 + 2^51 */ + return (int32_t)o.u32.lo; +#endif +} + +#if LJ_TARGET_X86 && !defined(__SSE2__) +#define lj_num2int(n) lj_num2bit((n)) +#else +#define lj_num2int(n) ((int32_t)(n)) +#endif + +static LJ_AINLINE uint64_t lj_num2u64(lua_Number n) +{ +#ifdef _MSC_VER + if (n >= 9223372036854775808.0) /* They think it's a feature. */ + return (uint64_t)(int64_t)(n - 18446744073709551616.0); + else +#endif + return (uint64_t)n; +} + +static LJ_AINLINE int32_t numberVint(cTValue *o) +{ + if (LJ_LIKELY(tvisint(o))) + return intV(o); + else + return lj_num2int(numV(o)); +} + +static LJ_AINLINE lua_Number numberVnum(cTValue *o) +{ + if (LJ_UNLIKELY(tvisint(o))) + return (lua_Number)intV(o); + else + return numV(o); +} + +/* -- Miscellaneous object handling --------------------------------------- */ + +/* Names and maps for internal and external object tags. */ +LJ_DATA const char *const lj_obj_typename[1+LUA_TCDATA+1]; +LJ_DATA const char *const lj_obj_itypename[~LJ_TNUMX+1]; + +#define lj_typename(o) (lj_obj_itypename[itypemap(o)]) + +/* Compare two objects without calling metamethods. */ +LJ_FUNC int lj_obj_equal(cTValue *o1, cTValue *o2); + +#endif + +``` + +`include/luajit-2.0.5/src/lj_opt_dce.c`: + +```c +/* +** DCE: Dead Code Elimination. Pre-LOOP only -- ASM already performs DCE. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_opt_dce_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) + +/* Scan through all snapshots and mark all referenced instructions. */ +static void dce_marksnap(jit_State *J) +{ + SnapNo i, nsnap = J->cur.nsnap; + for (i = 0; i < nsnap; i++) { + SnapShot *snap = &J->cur.snap[i]; + SnapEntry *map = &J->cur.snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + for (n = 0; n < nent; n++) { + IRRef ref = snap_ref(map[n]); + if (ref >= REF_FIRST) + irt_setmark(IR(ref)->t); + } + } +} + +/* Backwards propagate marks. Replace unused instructions with NOPs. */ +static void dce_propagate(jit_State *J) +{ + IRRef1 *pchain[IR__MAX]; + IRRef ins; + uint32_t i; + for (i = 0; i < IR__MAX; i++) pchain[i] = &J->chain[i]; + for (ins = J->cur.nins-1; ins >= REF_FIRST; ins--) { + IRIns *ir = IR(ins); + if (irt_ismarked(ir->t)) { + irt_clearmark(ir->t); + pchain[ir->o] = &ir->prev; + } else if (!ir_sideeff(ir)) { + *pchain[ir->o] = ir->prev; /* Reroute original instruction chain. */ + ir->t.irt = IRT_NIL; + ir->o = IR_NOP; /* Replace instruction with NOP. */ + ir->op1 = ir->op2 = 0; + ir->prev = 0; + continue; + } + if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t); + if (ir->op2 >= REF_FIRST) irt_setmark(IR(ir->op2)->t); + } +} + +/* Dead Code Elimination. +** +** First backpropagate marks for all used instructions. Then replace +** the unused ones with a NOP. Note that compressing the IR to eliminate +** the NOPs does not pay off. +*/ +void lj_opt_dce(jit_State *J) +{ + if ((J->flags & JIT_F_OPT_DCE)) { + dce_marksnap(J); + dce_propagate(J); + memset(J->bpropcache, 0, sizeof(J->bpropcache)); /* Invalidate cache. */ + } +} + +#undef IR + +#endif + +``` + +`include/luajit-2.0.5/src/lj_opt_fold.c`: + +```c +/* +** FOLD: Constant Folding, Algebraic Simplifications and Reassociation. +** ABCelim: Array Bounds Check Elimination. +** CSE: Common-Subexpression Elimination. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_opt_fold_c +#define LUA_CORE + +#include + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#endif +#include "lj_carith.h" +#include "lj_vm.h" +#include "lj_strscan.h" + +/* Here's a short description how the FOLD engine processes instructions: +** +** The FOLD engine receives a single instruction stored in fins (J->fold.ins). +** The instruction and its operands are used to select matching fold rules. +** These are applied iteratively until a fixed point is reached. +** +** The 8 bit opcode of the instruction itself plus the opcodes of the +** two instructions referenced by its operands form a 24 bit key +** 'ins left right' (unused operands -> 0, literals -> lowest 8 bits). +** +** This key is used for partial matching against the fold rules. The +** left/right operand fields of the key are successively masked with +** the 'any' wildcard, from most specific to least specific: +** +** ins left right +** ins any right +** ins left any +** ins any any +** +** The masked key is used to lookup a matching fold rule in a semi-perfect +** hash table. If a matching rule is found, the related fold function is run. +** Multiple rules can share the same fold function. A fold rule may return +** one of several special values: +** +** - NEXTFOLD means no folding was applied, because an additional test +** inside the fold function failed. Matching continues against less +** specific fold rules. Finally the instruction is passed on to CSE. +** +** - RETRYFOLD means the instruction was modified in-place. Folding is +** retried as if this instruction had just been received. +** +** All other return values are terminal actions -- no further folding is +** applied: +** +** - INTFOLD(i) returns a reference to the integer constant i. +** +** - LEFTFOLD and RIGHTFOLD return the left/right operand reference +** without emitting an instruction. +** +** - CSEFOLD and EMITFOLD pass the instruction directly to CSE or emit +** it without passing through any further optimizations. +** +** - FAILFOLD, DROPFOLD and CONDFOLD only apply to instructions which have +** no result (e.g. guarded assertions): FAILFOLD means the guard would +** always fail, i.e. the current trace is pointless. DROPFOLD means +** the guard is always true and has been eliminated. CONDFOLD is a +** shortcut for FAILFOLD + cond (i.e. drop if true, otherwise fail). +** +** - Any other return value is interpreted as an IRRef or TRef. This +** can be a reference to an existing or a newly created instruction. +** Only the least-significant 16 bits (IRRef1) are used to form a TRef +** which is finally returned to the caller. +** +** The FOLD engine receives instructions both from the trace recorder and +** substituted instructions from LOOP unrolling. This means all types +** of instructions may end up here, even though the recorder bypasses +** FOLD in some cases. Thus all loads, stores and allocations must have +** an any/any rule to avoid being passed on to CSE. +** +** Carefully read the following requirements before adding or modifying +** any fold rules: +** +** Requirement #1: All fold rules must preserve their destination type. +** +** Consistently use INTFOLD() (KINT result) or lj_ir_knum() (KNUM result). +** Never use lj_ir_knumint() which can have either a KINT or KNUM result. +** +** Requirement #2: Fold rules should not create *new* instructions which +** reference operands *across* PHIs. +** +** E.g. a RETRYFOLD with 'fins->op1 = fleft->op1' is invalid if the +** left operand is a PHI. Then fleft->op1 would point across the PHI +** frontier to an invariant instruction. Adding a PHI for this instruction +** would be counterproductive. The solution is to add a barrier which +** prevents folding across PHIs, i.e. 'PHIBARRIER(fleft)' in this case. +** The only exception is for recurrences with high latencies like +** repeated int->num->int conversions. +** +** One could relax this condition a bit if the referenced instruction is +** a PHI, too. But this often leads to worse code due to excessive +** register shuffling. +** +** Note: returning *existing* instructions (e.g. LEFTFOLD) is ok, though. +** Even returning fleft->op1 would be ok, because a new PHI will added, +** if needed. But again, this leads to excessive register shuffling and +** should be avoided. +** +** Requirement #3: The set of all fold rules must be monotonic to guarantee +** termination. +** +** The goal is optimization, so one primarily wants to add strength-reducing +** rules. This means eliminating an instruction or replacing an instruction +** with one or more simpler instructions. Don't add fold rules which point +** into the other direction. +** +** Some rules (like commutativity) do not directly reduce the strength of +** an instruction, but enable other fold rules (e.g. by moving constants +** to the right operand). These rules must be made unidirectional to avoid +** cycles. +** +** Rule of thumb: the trace recorder expands the IR and FOLD shrinks it. +*/ + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) +#define fins (&J->fold.ins) +#define fleft (&J->fold.left) +#define fright (&J->fold.right) +#define knumleft (ir_knum(fleft)->n) +#define knumright (ir_knum(fright)->n) + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +/* Fold function type. Fastcall on x86 significantly reduces their size. */ +typedef IRRef (LJ_FASTCALL *FoldFunc)(jit_State *J); + +/* Macros for the fold specs, so buildvm can recognize them. */ +#define LJFOLD(x) +#define LJFOLDX(x) +#define LJFOLDF(name) static TRef LJ_FASTCALL fold_##name(jit_State *J) +/* Note: They must be at the start of a line or buildvm ignores them! */ + +/* Barrier to prevent using operands across PHIs. */ +#define PHIBARRIER(ir) if (irt_isphi((ir)->t)) return NEXTFOLD + +/* Barrier to prevent folding across a GC step. +** GC steps can only happen at the head of a trace and at LOOP. +** And the GC is only driven forward if there is at least one allocation. +*/ +#define gcstep_barrier(J, ref) \ + ((ref) < J->chain[IR_LOOP] && \ + (J->chain[IR_SNEW] || J->chain[IR_XSNEW] || \ + J->chain[IR_TNEW] || J->chain[IR_TDUP] || \ + J->chain[IR_CNEW] || J->chain[IR_CNEWI] || J->chain[IR_TOSTR])) + +/* -- Constant folding for FP numbers ------------------------------------- */ + +LJFOLD(ADD KNUM KNUM) +LJFOLD(SUB KNUM KNUM) +LJFOLD(MUL KNUM KNUM) +LJFOLD(DIV KNUM KNUM) +LJFOLD(NEG KNUM KNUM) +LJFOLD(ABS KNUM KNUM) +LJFOLD(ATAN2 KNUM KNUM) +LJFOLD(LDEXP KNUM KNUM) +LJFOLD(MIN KNUM KNUM) +LJFOLD(MAX KNUM KNUM) +LJFOLDF(kfold_numarith) +{ + lua_Number a = knumleft; + lua_Number b = knumright; + lua_Number y = lj_vm_foldarith(a, b, fins->o - IR_ADD); + return lj_ir_knum(J, y); +} + +LJFOLD(LDEXP KNUM KINT) +LJFOLDF(kfold_ldexp) +{ +#if LJ_TARGET_X86ORX64 + UNUSED(J); + return NEXTFOLD; +#else + return lj_ir_knum(J, ldexp(knumleft, fright->i)); +#endif +} + +LJFOLD(FPMATH KNUM any) +LJFOLDF(kfold_fpmath) +{ + lua_Number a = knumleft; + lua_Number y = lj_vm_foldfpm(a, fins->op2); + return lj_ir_knum(J, y); +} + +LJFOLD(POW KNUM KINT) +LJFOLDF(kfold_numpow) +{ + lua_Number a = knumleft; + lua_Number b = (lua_Number)fright->i; + lua_Number y = lj_vm_foldarith(a, b, IR_POW - IR_ADD); + return lj_ir_knum(J, y); +} + +/* Must not use kfold_kref for numbers (could be NaN). */ +LJFOLD(EQ KNUM KNUM) +LJFOLD(NE KNUM KNUM) +LJFOLD(LT KNUM KNUM) +LJFOLD(GE KNUM KNUM) +LJFOLD(LE KNUM KNUM) +LJFOLD(GT KNUM KNUM) +LJFOLD(ULT KNUM KNUM) +LJFOLD(UGE KNUM KNUM) +LJFOLD(ULE KNUM KNUM) +LJFOLD(UGT KNUM KNUM) +LJFOLDF(kfold_numcomp) +{ + return CONDFOLD(lj_ir_numcmp(knumleft, knumright, (IROp)fins->o)); +} + +/* -- Constant folding for 32 bit integers -------------------------------- */ + +static int32_t kfold_intop(int32_t k1, int32_t k2, IROp op) +{ + switch (op) { + case IR_ADD: k1 += k2; break; + case IR_SUB: k1 -= k2; break; + case IR_MUL: k1 *= k2; break; + case IR_MOD: k1 = lj_vm_modi(k1, k2); break; + case IR_NEG: k1 = -k1; break; + case IR_BAND: k1 &= k2; break; + case IR_BOR: k1 |= k2; break; + case IR_BXOR: k1 ^= k2; break; + case IR_BSHL: k1 <<= (k2 & 31); break; + case IR_BSHR: k1 = (int32_t)((uint32_t)k1 >> (k2 & 31)); break; + case IR_BSAR: k1 >>= (k2 & 31); break; + case IR_BROL: k1 = (int32_t)lj_rol((uint32_t)k1, (k2 & 31)); break; + case IR_BROR: k1 = (int32_t)lj_ror((uint32_t)k1, (k2 & 31)); break; + case IR_MIN: k1 = k1 < k2 ? k1 : k2; break; + case IR_MAX: k1 = k1 > k2 ? k1 : k2; break; + default: lua_assert(0); break; + } + return k1; +} + +LJFOLD(ADD KINT KINT) +LJFOLD(SUB KINT KINT) +LJFOLD(MUL KINT KINT) +LJFOLD(MOD KINT KINT) +LJFOLD(NEG KINT KINT) +LJFOLD(BAND KINT KINT) +LJFOLD(BOR KINT KINT) +LJFOLD(BXOR KINT KINT) +LJFOLD(BSHL KINT KINT) +LJFOLD(BSHR KINT KINT) +LJFOLD(BSAR KINT KINT) +LJFOLD(BROL KINT KINT) +LJFOLD(BROR KINT KINT) +LJFOLD(MIN KINT KINT) +LJFOLD(MAX KINT KINT) +LJFOLDF(kfold_intarith) +{ + return INTFOLD(kfold_intop(fleft->i, fright->i, (IROp)fins->o)); +} + +LJFOLD(ADDOV KINT KINT) +LJFOLD(SUBOV KINT KINT) +LJFOLD(MULOV KINT KINT) +LJFOLDF(kfold_intovarith) +{ + lua_Number n = lj_vm_foldarith((lua_Number)fleft->i, (lua_Number)fright->i, + fins->o - IR_ADDOV); + int32_t k = lj_num2int(n); + if (n != (lua_Number)k) + return FAILFOLD; + return INTFOLD(k); +} + +LJFOLD(BNOT KINT) +LJFOLDF(kfold_bnot) +{ + return INTFOLD(~fleft->i); +} + +LJFOLD(BSWAP KINT) +LJFOLDF(kfold_bswap) +{ + return INTFOLD((int32_t)lj_bswap((uint32_t)fleft->i)); +} + +LJFOLD(LT KINT KINT) +LJFOLD(GE KINT KINT) +LJFOLD(LE KINT KINT) +LJFOLD(GT KINT KINT) +LJFOLD(ULT KINT KINT) +LJFOLD(UGE KINT KINT) +LJFOLD(ULE KINT KINT) +LJFOLD(UGT KINT KINT) +LJFOLD(ABC KINT KINT) +LJFOLDF(kfold_intcomp) +{ + int32_t a = fleft->i, b = fright->i; + switch ((IROp)fins->o) { + case IR_LT: return CONDFOLD(a < b); + case IR_GE: return CONDFOLD(a >= b); + case IR_LE: return CONDFOLD(a <= b); + case IR_GT: return CONDFOLD(a > b); + case IR_ULT: return CONDFOLD((uint32_t)a < (uint32_t)b); + case IR_UGE: return CONDFOLD((uint32_t)a >= (uint32_t)b); + case IR_ULE: return CONDFOLD((uint32_t)a <= (uint32_t)b); + case IR_ABC: + case IR_UGT: return CONDFOLD((uint32_t)a > (uint32_t)b); + default: lua_assert(0); return FAILFOLD; + } +} + +LJFOLD(UGE any KINT) +LJFOLDF(kfold_intcomp0) +{ + if (fright->i == 0) + return DROPFOLD; + return NEXTFOLD; +} + +/* -- Constant folding for 64 bit integers -------------------------------- */ + +static uint64_t kfold_int64arith(uint64_t k1, uint64_t k2, IROp op) +{ + switch (op) { +#if LJ_64 || LJ_HASFFI + case IR_ADD: k1 += k2; break; + case IR_SUB: k1 -= k2; break; +#endif +#if LJ_HASFFI + case IR_MUL: k1 *= k2; break; + case IR_BAND: k1 &= k2; break; + case IR_BOR: k1 |= k2; break; + case IR_BXOR: k1 ^= k2; break; +#endif + default: UNUSED(k2); lua_assert(0); break; + } + return k1; +} + +LJFOLD(ADD KINT64 KINT64) +LJFOLD(SUB KINT64 KINT64) +LJFOLD(MUL KINT64 KINT64) +LJFOLD(BAND KINT64 KINT64) +LJFOLD(BOR KINT64 KINT64) +LJFOLD(BXOR KINT64 KINT64) +LJFOLDF(kfold_int64arith) +{ + return INT64FOLD(kfold_int64arith(ir_k64(fleft)->u64, + ir_k64(fright)->u64, (IROp)fins->o)); +} + +LJFOLD(DIV KINT64 KINT64) +LJFOLD(MOD KINT64 KINT64) +LJFOLD(POW KINT64 KINT64) +LJFOLDF(kfold_int64arith2) +{ +#if LJ_HASFFI + uint64_t k1 = ir_k64(fleft)->u64, k2 = ir_k64(fright)->u64; + if (irt_isi64(fins->t)) { + k1 = fins->o == IR_DIV ? lj_carith_divi64((int64_t)k1, (int64_t)k2) : + fins->o == IR_MOD ? lj_carith_modi64((int64_t)k1, (int64_t)k2) : + lj_carith_powi64((int64_t)k1, (int64_t)k2); + } else { + k1 = fins->o == IR_DIV ? lj_carith_divu64(k1, k2) : + fins->o == IR_MOD ? lj_carith_modu64(k1, k2) : + lj_carith_powu64(k1, k2); + } + return INT64FOLD(k1); +#else + UNUSED(J); lua_assert(0); return FAILFOLD; +#endif +} + +LJFOLD(BSHL KINT64 KINT) +LJFOLD(BSHR KINT64 KINT) +LJFOLD(BSAR KINT64 KINT) +LJFOLD(BROL KINT64 KINT) +LJFOLD(BROR KINT64 KINT) +LJFOLDF(kfold_int64shift) +{ +#if LJ_HASFFI || LJ_64 + uint64_t k = ir_k64(fleft)->u64; + int32_t sh = (fright->i & 63); + switch ((IROp)fins->o) { + case IR_BSHL: k <<= sh; break; +#if LJ_HASFFI + case IR_BSHR: k >>= sh; break; + case IR_BSAR: k = (uint64_t)((int64_t)k >> sh); break; + case IR_BROL: k = lj_rol(k, sh); break; + case IR_BROR: k = lj_ror(k, sh); break; +#endif + default: lua_assert(0); break; + } + return INT64FOLD(k); +#else + UNUSED(J); lua_assert(0); return FAILFOLD; +#endif +} + +LJFOLD(BNOT KINT64) +LJFOLDF(kfold_bnot64) +{ +#if LJ_HASFFI + return INT64FOLD(~ir_k64(fleft)->u64); +#else + UNUSED(J); lua_assert(0); return FAILFOLD; +#endif +} + +LJFOLD(BSWAP KINT64) +LJFOLDF(kfold_bswap64) +{ +#if LJ_HASFFI + return INT64FOLD(lj_bswap64(ir_k64(fleft)->u64)); +#else + UNUSED(J); lua_assert(0); return FAILFOLD; +#endif +} + +LJFOLD(LT KINT64 KINT64) +LJFOLD(GE KINT64 KINT64) +LJFOLD(LE KINT64 KINT64) +LJFOLD(GT KINT64 KINT64) +LJFOLD(ULT KINT64 KINT64) +LJFOLD(UGE KINT64 KINT64) +LJFOLD(ULE KINT64 KINT64) +LJFOLD(UGT KINT64 KINT64) +LJFOLDF(kfold_int64comp) +{ +#if LJ_HASFFI + uint64_t a = ir_k64(fleft)->u64, b = ir_k64(fright)->u64; + switch ((IROp)fins->o) { + case IR_LT: return CONDFOLD((int64_t)a < (int64_t)b); + case IR_GE: return CONDFOLD((int64_t)a >= (int64_t)b); + case IR_LE: return CONDFOLD((int64_t)a <= (int64_t)b); + case IR_GT: return CONDFOLD((int64_t)a > (int64_t)b); + case IR_ULT: return CONDFOLD(a < b); + case IR_UGE: return CONDFOLD(a >= b); + case IR_ULE: return CONDFOLD(a <= b); + case IR_UGT: return CONDFOLD(a > b); + default: lua_assert(0); return FAILFOLD; + } +#else + UNUSED(J); lua_assert(0); return FAILFOLD; +#endif +} + +LJFOLD(UGE any KINT64) +LJFOLDF(kfold_int64comp0) +{ +#if LJ_HASFFI + if (ir_k64(fright)->u64 == 0) + return DROPFOLD; + return NEXTFOLD; +#else + UNUSED(J); lua_assert(0); return FAILFOLD; +#endif +} + +/* -- Constant folding for strings ---------------------------------------- */ + +LJFOLD(SNEW KKPTR KINT) +LJFOLDF(kfold_snew_kptr) +{ + GCstr *s = lj_str_new(J->L, (const char *)ir_kptr(fleft), (size_t)fright->i); + return lj_ir_kstr(J, s); +} + +LJFOLD(SNEW any KINT) +LJFOLDF(kfold_snew_empty) +{ + if (fright->i == 0) + return lj_ir_kstr(J, &J2G(J)->strempty); + return NEXTFOLD; +} + +LJFOLD(STRREF KGC KINT) +LJFOLDF(kfold_strref) +{ + GCstr *str = ir_kstr(fleft); + lua_assert((MSize)fright->i <= str->len); + return lj_ir_kkptr(J, (char *)strdata(str) + fright->i); +} + +LJFOLD(STRREF SNEW any) +LJFOLDF(kfold_strref_snew) +{ + PHIBARRIER(fleft); + if (irref_isk(fins->op2) && fright->i == 0) { + return fleft->op1; /* strref(snew(ptr, len), 0) ==> ptr */ + } else { + /* Reassociate: strref(snew(strref(str, a), len), b) ==> strref(str, a+b) */ + IRIns *ir = IR(fleft->op1); + if (ir->o == IR_STRREF) { + IRRef1 str = ir->op1; /* IRIns * is not valid across emitir. */ + PHIBARRIER(ir); + fins->op2 = emitir(IRTI(IR_ADD), ir->op2, fins->op2); /* Clobbers fins! */ + fins->op1 = str; + fins->ot = IRT(IR_STRREF, IRT_P32); + return RETRYFOLD; + } + } + return NEXTFOLD; +} + +LJFOLD(CALLN CARG IRCALL_lj_str_cmp) +LJFOLDF(kfold_strcmp) +{ + if (irref_isk(fleft->op1) && irref_isk(fleft->op2)) { + GCstr *a = ir_kstr(IR(fleft->op1)); + GCstr *b = ir_kstr(IR(fleft->op2)); + return INTFOLD(lj_str_cmp(a, b)); + } + return NEXTFOLD; +} + +/* -- Constant folding of pointer arithmetic ------------------------------ */ + +LJFOLD(ADD KGC KINT) +LJFOLD(ADD KGC KINT64) +LJFOLDF(kfold_add_kgc) +{ + GCobj *o = ir_kgc(fleft); +#if LJ_64 + ptrdiff_t ofs = (ptrdiff_t)ir_kint64(fright)->u64; +#else + ptrdiff_t ofs = fright->i; +#endif +#if LJ_HASFFI + if (irt_iscdata(fleft->t)) { + CType *ct = ctype_raw(ctype_ctsG(J2G(J)), gco2cd(o)->ctypeid); + if (ctype_isnum(ct->info) || ctype_isenum(ct->info) || + ctype_isptr(ct->info) || ctype_isfunc(ct->info) || + ctype_iscomplex(ct->info) || ctype_isvector(ct->info)) + return lj_ir_kkptr(J, (char *)o + ofs); + } +#endif + return lj_ir_kptr(J, (char *)o + ofs); +} + +LJFOLD(ADD KPTR KINT) +LJFOLD(ADD KPTR KINT64) +LJFOLD(ADD KKPTR KINT) +LJFOLD(ADD KKPTR KINT64) +LJFOLDF(kfold_add_kptr) +{ + void *p = ir_kptr(fleft); +#if LJ_64 + ptrdiff_t ofs = (ptrdiff_t)ir_kint64(fright)->u64; +#else + ptrdiff_t ofs = fright->i; +#endif + return lj_ir_kptr_(J, fleft->o, (char *)p + ofs); +} + +LJFOLD(ADD any KGC) +LJFOLD(ADD any KPTR) +LJFOLD(ADD any KKPTR) +LJFOLDF(kfold_add_kright) +{ + if (fleft->o == IR_KINT || fleft->o == IR_KINT64) { + IRRef1 tmp = fins->op1; fins->op1 = fins->op2; fins->op2 = tmp; + return RETRYFOLD; + } + return NEXTFOLD; +} + +/* -- Constant folding of conversions ------------------------------------- */ + +LJFOLD(TOBIT KNUM KNUM) +LJFOLDF(kfold_tobit) +{ + return INTFOLD(lj_num2bit(knumleft)); +} + +LJFOLD(CONV KINT IRCONV_NUM_INT) +LJFOLDF(kfold_conv_kint_num) +{ + return lj_ir_knum(J, (lua_Number)fleft->i); +} + +LJFOLD(CONV KINT IRCONV_NUM_U32) +LJFOLDF(kfold_conv_kintu32_num) +{ + return lj_ir_knum(J, (lua_Number)(uint32_t)fleft->i); +} + +LJFOLD(CONV KINT IRCONV_INT_I8) +LJFOLD(CONV KINT IRCONV_INT_U8) +LJFOLD(CONV KINT IRCONV_INT_I16) +LJFOLD(CONV KINT IRCONV_INT_U16) +LJFOLDF(kfold_conv_kint_ext) +{ + int32_t k = fleft->i; + if ((fins->op2 & IRCONV_SRCMASK) == IRT_I8) k = (int8_t)k; + else if ((fins->op2 & IRCONV_SRCMASK) == IRT_U8) k = (uint8_t)k; + else if ((fins->op2 & IRCONV_SRCMASK) == IRT_I16) k = (int16_t)k; + else k = (uint16_t)k; + return INTFOLD(k); +} + +LJFOLD(CONV KINT IRCONV_I64_INT) +LJFOLD(CONV KINT IRCONV_U64_INT) +LJFOLD(CONV KINT IRCONV_I64_U32) +LJFOLD(CONV KINT IRCONV_U64_U32) +LJFOLDF(kfold_conv_kint_i64) +{ + if ((fins->op2 & IRCONV_SEXT)) + return INT64FOLD((uint64_t)(int64_t)fleft->i); + else + return INT64FOLD((uint64_t)(int64_t)(uint32_t)fleft->i); +} + +LJFOLD(CONV KINT64 IRCONV_NUM_I64) +LJFOLDF(kfold_conv_kint64_num_i64) +{ + return lj_ir_knum(J, (lua_Number)(int64_t)ir_kint64(fleft)->u64); +} + +LJFOLD(CONV KINT64 IRCONV_NUM_U64) +LJFOLDF(kfold_conv_kint64_num_u64) +{ + return lj_ir_knum(J, (lua_Number)ir_kint64(fleft)->u64); +} + +LJFOLD(CONV KINT64 IRCONV_INT_I64) +LJFOLD(CONV KINT64 IRCONV_U32_I64) +LJFOLDF(kfold_conv_kint64_int_i64) +{ + return INTFOLD((int32_t)ir_kint64(fleft)->u64); +} + +LJFOLD(CONV KNUM IRCONV_INT_NUM) +LJFOLDF(kfold_conv_knum_int_num) +{ + lua_Number n = knumleft; + if (!(fins->op2 & IRCONV_TRUNC)) { + int32_t k = lj_num2int(n); + if (irt_isguard(fins->t) && n != (lua_Number)k) { + /* We're about to create a guard which always fails, like CONV +1.5. + ** Some pathological loops cause this during LICM, e.g.: + ** local x,k,t = 0,1.5,{1,[1.5]=2} + ** for i=1,200 do x = x+ t[k]; k = k == 1 and 1.5 or 1 end + ** assert(x == 300) + */ + return FAILFOLD; + } + return INTFOLD(k); + } else { + return INTFOLD((int32_t)n); + } +} + +LJFOLD(CONV KNUM IRCONV_U32_NUM) +LJFOLDF(kfold_conv_knum_u32_num) +{ + lua_assert((fins->op2 & IRCONV_TRUNC)); +#ifdef _MSC_VER + { /* Workaround for MSVC bug. */ + volatile uint32_t u = (uint32_t)knumleft; + return INTFOLD((int32_t)u); + } +#else + return INTFOLD((int32_t)(uint32_t)knumleft); +#endif +} + +LJFOLD(CONV KNUM IRCONV_I64_NUM) +LJFOLDF(kfold_conv_knum_i64_num) +{ + lua_assert((fins->op2 & IRCONV_TRUNC)); + return INT64FOLD((uint64_t)(int64_t)knumleft); +} + +LJFOLD(CONV KNUM IRCONV_U64_NUM) +LJFOLDF(kfold_conv_knum_u64_num) +{ + lua_assert((fins->op2 & IRCONV_TRUNC)); + return INT64FOLD(lj_num2u64(knumleft)); +} + +LJFOLD(TOSTR KNUM) +LJFOLDF(kfold_tostr_knum) +{ + return lj_ir_kstr(J, lj_str_fromnum(J->L, &knumleft)); +} + +LJFOLD(TOSTR KINT) +LJFOLDF(kfold_tostr_kint) +{ + return lj_ir_kstr(J, lj_str_fromint(J->L, fleft->i)); +} + +LJFOLD(STRTO KGC) +LJFOLDF(kfold_strto) +{ + TValue n; + if (lj_strscan_num(ir_kstr(fleft), &n)) + return lj_ir_knum(J, numV(&n)); + return FAILFOLD; +} + +/* -- Constant folding of equality checks --------------------------------- */ + +/* Don't constant-fold away FLOAD checks against KNULL. */ +LJFOLD(EQ FLOAD KNULL) +LJFOLD(NE FLOAD KNULL) +LJFOLDX(lj_opt_cse) + +/* But fold all other KNULL compares, since only KNULL is equal to KNULL. */ +LJFOLD(EQ any KNULL) +LJFOLD(NE any KNULL) +LJFOLD(EQ KNULL any) +LJFOLD(NE KNULL any) +LJFOLD(EQ KINT KINT) /* Constants are unique, so same refs <==> same value. */ +LJFOLD(NE KINT KINT) +LJFOLD(EQ KINT64 KINT64) +LJFOLD(NE KINT64 KINT64) +LJFOLD(EQ KGC KGC) +LJFOLD(NE KGC KGC) +LJFOLDF(kfold_kref) +{ + return CONDFOLD((fins->op1 == fins->op2) ^ (fins->o == IR_NE)); +} + +/* -- Algebraic shortcuts ------------------------------------------------- */ + +LJFOLD(FPMATH FPMATH IRFPM_FLOOR) +LJFOLD(FPMATH FPMATH IRFPM_CEIL) +LJFOLD(FPMATH FPMATH IRFPM_TRUNC) +LJFOLDF(shortcut_round) +{ + IRFPMathOp op = (IRFPMathOp)fleft->op2; + if (op == IRFPM_FLOOR || op == IRFPM_CEIL || op == IRFPM_TRUNC) + return LEFTFOLD; /* round(round_left(x)) = round_left(x) */ + return NEXTFOLD; +} + +LJFOLD(ABS ABS KNUM) +LJFOLDF(shortcut_left) +{ + return LEFTFOLD; /* f(g(x)) ==> g(x) */ +} + +LJFOLD(ABS NEG KNUM) +LJFOLDF(shortcut_dropleft) +{ + PHIBARRIER(fleft); + fins->op1 = fleft->op1; /* abs(neg(x)) ==> abs(x) */ + return RETRYFOLD; +} + +/* Note: no safe shortcuts with STRTO and TOSTR ("1e2" ==> +100 ==> "100"). */ +LJFOLD(NEG NEG any) +LJFOLD(BNOT BNOT) +LJFOLD(BSWAP BSWAP) +LJFOLDF(shortcut_leftleft) +{ + PHIBARRIER(fleft); /* See above. Fold would be ok, but not beneficial. */ + return fleft->op1; /* f(g(x)) ==> x */ +} + +/* -- FP algebraic simplifications ---------------------------------------- */ + +/* FP arithmetic is tricky -- there's not much to simplify. +** Please note the following common pitfalls before sending "improvements": +** x+0 ==> x is INVALID for x=-0 +** 0-x ==> -x is INVALID for x=+0 +** x*0 ==> 0 is INVALID for x=-0, x=+-Inf or x=NaN +*/ + +LJFOLD(ADD NEG any) +LJFOLDF(simplify_numadd_negx) +{ + PHIBARRIER(fleft); + fins->o = IR_SUB; /* (-a) + b ==> b - a */ + fins->op1 = fins->op2; + fins->op2 = fleft->op1; + return RETRYFOLD; +} + +LJFOLD(ADD any NEG) +LJFOLDF(simplify_numadd_xneg) +{ + PHIBARRIER(fright); + fins->o = IR_SUB; /* a + (-b) ==> a - b */ + fins->op2 = fright->op1; + return RETRYFOLD; +} + +LJFOLD(SUB any KNUM) +LJFOLDF(simplify_numsub_k) +{ + lua_Number n = knumright; + if (n == 0.0) /* x - (+-0) ==> x */ + return LEFTFOLD; + return NEXTFOLD; +} + +LJFOLD(SUB NEG KNUM) +LJFOLDF(simplify_numsub_negk) +{ + PHIBARRIER(fleft); + fins->op2 = fleft->op1; /* (-x) - k ==> (-k) - x */ + fins->op1 = (IRRef1)lj_ir_knum(J, -knumright); + return RETRYFOLD; +} + +LJFOLD(SUB any NEG) +LJFOLDF(simplify_numsub_xneg) +{ + PHIBARRIER(fright); + fins->o = IR_ADD; /* a - (-b) ==> a + b */ + fins->op2 = fright->op1; + return RETRYFOLD; +} + +LJFOLD(MUL any KNUM) +LJFOLD(DIV any KNUM) +LJFOLDF(simplify_nummuldiv_k) +{ + lua_Number n = knumright; + if (n == 1.0) { /* x o 1 ==> x */ + return LEFTFOLD; + } else if (n == -1.0) { /* x o -1 ==> -x */ + fins->o = IR_NEG; + fins->op2 = (IRRef1)lj_ir_knum_neg(J); + return RETRYFOLD; + } else if (fins->o == IR_MUL && n == 2.0) { /* x * 2 ==> x + x */ + fins->o = IR_ADD; + fins->op2 = fins->op1; + return RETRYFOLD; + } else if (fins->o == IR_DIV) { /* x / 2^k ==> x * 2^-k */ + uint64_t u = ir_knum(fright)->u64; + uint32_t ex = ((uint32_t)(u >> 52) & 0x7ff); + if ((u & U64x(000fffff,ffffffff)) == 0 && ex - 1 < 0x7fd) { + u = (u & ((uint64_t)1 << 63)) | ((uint64_t)(0x7fe - ex) << 52); + fins->o = IR_MUL; /* Multiply by exact reciprocal. */ + fins->op2 = lj_ir_knum_u64(J, u); + return RETRYFOLD; + } + } + return NEXTFOLD; +} + +LJFOLD(MUL NEG KNUM) +LJFOLD(DIV NEG KNUM) +LJFOLDF(simplify_nummuldiv_negk) +{ + PHIBARRIER(fleft); + fins->op1 = fleft->op1; /* (-a) o k ==> a o (-k) */ + fins->op2 = (IRRef1)lj_ir_knum(J, -knumright); + return RETRYFOLD; +} + +LJFOLD(MUL NEG NEG) +LJFOLD(DIV NEG NEG) +LJFOLDF(simplify_nummuldiv_negneg) +{ + PHIBARRIER(fleft); + PHIBARRIER(fright); + fins->op1 = fleft->op1; /* (-a) o (-b) ==> a o b */ + fins->op2 = fright->op1; + return RETRYFOLD; +} + +LJFOLD(POW any KINT) +LJFOLDF(simplify_numpow_xk) +{ + int32_t k = fright->i; + TRef ref = fins->op1; + if (k == 0) /* x ^ 0 ==> 1 */ + return lj_ir_knum_one(J); /* Result must be a number, not an int. */ + if (k == 1) /* x ^ 1 ==> x */ + return LEFTFOLD; + if ((uint32_t)(k+65536) > 2*65536u) /* Limit code explosion. */ + return NEXTFOLD; + if (k < 0) { /* x ^ (-k) ==> (1/x) ^ k. */ + ref = emitir(IRTN(IR_DIV), lj_ir_knum_one(J), ref); + k = -k; + } + /* Unroll x^k for 1 <= k <= 65536. */ + for (; (k & 1) == 0; k >>= 1) /* Handle leading zeros. */ + ref = emitir(IRTN(IR_MUL), ref, ref); + if ((k >>= 1) != 0) { /* Handle trailing bits. */ + TRef tmp = emitir(IRTN(IR_MUL), ref, ref); + for (; k != 1; k >>= 1) { + if (k & 1) + ref = emitir(IRTN(IR_MUL), ref, tmp); + tmp = emitir(IRTN(IR_MUL), tmp, tmp); + } + ref = emitir(IRTN(IR_MUL), ref, tmp); + } + return ref; +} + +LJFOLD(POW KNUM any) +LJFOLDF(simplify_numpow_kx) +{ + lua_Number n = knumleft; + if (n == 2.0) { /* 2.0 ^ i ==> ldexp(1.0, tonum(i)) */ + fins->o = IR_CONV; +#if LJ_TARGET_X86ORX64 + fins->op1 = fins->op2; + fins->op2 = IRCONV_NUM_INT; + fins->op2 = (IRRef1)lj_opt_fold(J); +#endif + fins->op1 = (IRRef1)lj_ir_knum_one(J); + fins->o = IR_LDEXP; + return RETRYFOLD; + } + return NEXTFOLD; +} + +/* -- Simplify conversions ------------------------------------------------ */ + +LJFOLD(CONV CONV IRCONV_NUM_INT) /* _NUM */ +LJFOLDF(shortcut_conv_num_int) +{ + PHIBARRIER(fleft); + /* Only safe with a guarded conversion to int. */ + if ((fleft->op2 & IRCONV_SRCMASK) == IRT_NUM && irt_isguard(fleft->t)) + return fleft->op1; /* f(g(x)) ==> x */ + return NEXTFOLD; +} + +LJFOLD(CONV CONV IRCONV_INT_NUM) /* _INT */ +LJFOLD(CONV CONV IRCONV_U32_NUM) /* _U32*/ +LJFOLDF(simplify_conv_int_num) +{ + /* Fold even across PHI to avoid expensive num->int conversions in loop. */ + if ((fleft->op2 & IRCONV_SRCMASK) == + ((fins->op2 & IRCONV_DSTMASK) >> IRCONV_DSH)) + return fleft->op1; + return NEXTFOLD; +} + +LJFOLD(CONV CONV IRCONV_I64_NUM) /* _INT or _U32 */ +LJFOLD(CONV CONV IRCONV_U64_NUM) /* _INT or _U32 */ +LJFOLDF(simplify_conv_i64_num) +{ + PHIBARRIER(fleft); + if ((fleft->op2 & IRCONV_SRCMASK) == IRT_INT) { + /* Reduce to a sign-extension. */ + fins->op1 = fleft->op1; + fins->op2 = ((IRT_I64<<5)|IRT_INT|IRCONV_SEXT); + return RETRYFOLD; + } else if ((fleft->op2 & IRCONV_SRCMASK) == IRT_U32) { +#if LJ_TARGET_X64 + return fleft->op1; +#else + /* Reduce to a zero-extension. */ + fins->op1 = fleft->op1; + fins->op2 = (IRT_I64<<5)|IRT_U32; + return RETRYFOLD; +#endif + } + return NEXTFOLD; +} + +LJFOLD(CONV CONV IRCONV_INT_I64) /* _INT or _U32 */ +LJFOLD(CONV CONV IRCONV_INT_U64) /* _INT or _U32 */ +LJFOLD(CONV CONV IRCONV_U32_I64) /* _INT or _U32 */ +LJFOLD(CONV CONV IRCONV_U32_U64) /* _INT or _U32 */ +LJFOLDF(simplify_conv_int_i64) +{ + int src; + PHIBARRIER(fleft); + src = (fleft->op2 & IRCONV_SRCMASK); + if (src == IRT_INT || src == IRT_U32) { + if (src == ((fins->op2 & IRCONV_DSTMASK) >> IRCONV_DSH)) { + return fleft->op1; + } else { + fins->op2 = ((fins->op2 & IRCONV_DSTMASK) | src); + fins->op1 = fleft->op1; + return RETRYFOLD; + } + } + return NEXTFOLD; +} + +LJFOLD(CONV CONV IRCONV_FLOAT_NUM) /* _FLOAT */ +LJFOLDF(simplify_conv_flt_num) +{ + PHIBARRIER(fleft); + if ((fleft->op2 & IRCONV_SRCMASK) == IRT_FLOAT) + return fleft->op1; + return NEXTFOLD; +} + +/* Shortcut TOBIT + IRT_NUM <- IRT_INT/IRT_U32 conversion. */ +LJFOLD(TOBIT CONV KNUM) +LJFOLDF(simplify_tobit_conv) +{ + /* Fold even across PHI to avoid expensive num->int conversions in loop. */ + if ((fleft->op2 & IRCONV_SRCMASK) == IRT_INT) { + lua_assert(irt_isnum(fleft->t)); + return fleft->op1; + } else if ((fleft->op2 & IRCONV_SRCMASK) == IRT_U32) { + lua_assert(irt_isnum(fleft->t)); + fins->o = IR_CONV; + fins->op1 = fleft->op1; + fins->op2 = (IRT_INT<<5)|IRT_U32; + return RETRYFOLD; + } + return NEXTFOLD; +} + +/* Shortcut floor/ceil/round + IRT_NUM <- IRT_INT/IRT_U32 conversion. */ +LJFOLD(FPMATH CONV IRFPM_FLOOR) +LJFOLD(FPMATH CONV IRFPM_CEIL) +LJFOLD(FPMATH CONV IRFPM_TRUNC) +LJFOLDF(simplify_floor_conv) +{ + if ((fleft->op2 & IRCONV_SRCMASK) == IRT_INT || + (fleft->op2 & IRCONV_SRCMASK) == IRT_U32) + return LEFTFOLD; + return NEXTFOLD; +} + +/* Strength reduction of widening. */ +LJFOLD(CONV any IRCONV_I64_INT) +LJFOLD(CONV any IRCONV_U64_INT) +LJFOLDF(simplify_conv_sext) +{ + IRRef ref = fins->op1; + int64_t ofs = 0; + if (!(fins->op2 & IRCONV_SEXT)) + return NEXTFOLD; + PHIBARRIER(fleft); + if (fleft->o == IR_XLOAD && (irt_isu8(fleft->t) || irt_isu16(fleft->t))) + goto ok_reduce; + if (fleft->o == IR_ADD && irref_isk(fleft->op2)) { + ofs = (int64_t)IR(fleft->op2)->i; + ref = fleft->op1; + } + /* Use scalar evolution analysis results to strength-reduce sign-extension. */ + if (ref == J->scev.idx) { + IRRef lo = J->scev.dir ? J->scev.start : J->scev.stop; + lua_assert(irt_isint(J->scev.t)); + if (lo && IR(lo)->i + ofs >= 0) { + ok_reduce: +#if LJ_TARGET_X64 + /* Eliminate widening. All 32 bit ops do an implicit zero-extension. */ + return LEFTFOLD; +#else + /* Reduce to a (cheaper) zero-extension. */ + fins->op2 &= ~IRCONV_SEXT; + return RETRYFOLD; +#endif + } + } + return NEXTFOLD; +} + +/* Strength reduction of narrowing. */ +LJFOLD(CONV ADD IRCONV_INT_I64) +LJFOLD(CONV SUB IRCONV_INT_I64) +LJFOLD(CONV MUL IRCONV_INT_I64) +LJFOLD(CONV ADD IRCONV_INT_U64) +LJFOLD(CONV SUB IRCONV_INT_U64) +LJFOLD(CONV MUL IRCONV_INT_U64) +LJFOLD(CONV ADD IRCONV_U32_I64) +LJFOLD(CONV SUB IRCONV_U32_I64) +LJFOLD(CONV MUL IRCONV_U32_I64) +LJFOLD(CONV ADD IRCONV_U32_U64) +LJFOLD(CONV SUB IRCONV_U32_U64) +LJFOLD(CONV MUL IRCONV_U32_U64) +LJFOLDF(simplify_conv_narrow) +{ + IROp op = (IROp)fleft->o; + IRType t = irt_type(fins->t); + IRRef op1 = fleft->op1, op2 = fleft->op2, mode = fins->op2; + PHIBARRIER(fleft); + op1 = emitir(IRTI(IR_CONV), op1, mode); + op2 = emitir(IRTI(IR_CONV), op2, mode); + fins->ot = IRT(op, t); + fins->op1 = op1; + fins->op2 = op2; + return RETRYFOLD; +} + +/* Special CSE rule for CONV. */ +LJFOLD(CONV any any) +LJFOLDF(cse_conv) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_CSE)) { + IRRef op1 = fins->op1, op2 = (fins->op2 & IRCONV_MODEMASK); + uint8_t guard = irt_isguard(fins->t); + IRRef ref = J->chain[IR_CONV]; + while (ref > op1) { + IRIns *ir = IR(ref); + /* Commoning with stronger checks is ok. */ + if (ir->op1 == op1 && (ir->op2 & IRCONV_MODEMASK) == op2 && + irt_isguard(ir->t) >= guard) + return ref; + ref = ir->prev; + } + } + return EMITFOLD; /* No fallthrough to regular CSE. */ +} + +/* FP conversion narrowing. */ +LJFOLD(TOBIT ADD KNUM) +LJFOLD(TOBIT SUB KNUM) +LJFOLD(CONV ADD IRCONV_INT_NUM) +LJFOLD(CONV SUB IRCONV_INT_NUM) +LJFOLD(CONV ADD IRCONV_I64_NUM) +LJFOLD(CONV SUB IRCONV_I64_NUM) +LJFOLDF(narrow_convert) +{ + PHIBARRIER(fleft); + /* Narrowing ignores PHIs and repeating it inside the loop is not useful. */ + if (J->chain[IR_LOOP]) + return NEXTFOLD; + lua_assert(fins->o != IR_CONV || (fins->op2&IRCONV_CONVMASK) != IRCONV_TOBIT); + return lj_opt_narrow_convert(J); +} + +/* -- Integer algebraic simplifications ----------------------------------- */ + +LJFOLD(ADD any KINT) +LJFOLD(ADDOV any KINT) +LJFOLD(SUBOV any KINT) +LJFOLDF(simplify_intadd_k) +{ + if (fright->i == 0) /* i o 0 ==> i */ + return LEFTFOLD; + return NEXTFOLD; +} + +LJFOLD(MULOV any KINT) +LJFOLDF(simplify_intmul_k) +{ + if (fright->i == 0) /* i * 0 ==> 0 */ + return RIGHTFOLD; + if (fright->i == 1) /* i * 1 ==> i */ + return LEFTFOLD; + if (fright->i == 2) { /* i * 2 ==> i + i */ + fins->o = IR_ADDOV; + fins->op2 = fins->op1; + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(SUB any KINT) +LJFOLDF(simplify_intsub_k) +{ + if (fright->i == 0) /* i - 0 ==> i */ + return LEFTFOLD; + fins->o = IR_ADD; /* i - k ==> i + (-k) */ + fins->op2 = (IRRef1)lj_ir_kint(J, -fright->i); /* Overflow for -2^31 ok. */ + return RETRYFOLD; +} + +LJFOLD(SUB KINT any) +LJFOLD(SUB KINT64 any) +LJFOLDF(simplify_intsub_kleft) +{ + if (fleft->o == IR_KINT ? (fleft->i == 0) : (ir_kint64(fleft)->u64 == 0)) { + fins->o = IR_NEG; /* 0 - i ==> -i */ + fins->op1 = fins->op2; + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(ADD any KINT64) +LJFOLDF(simplify_intadd_k64) +{ + if (ir_kint64(fright)->u64 == 0) /* i + 0 ==> i */ + return LEFTFOLD; + return NEXTFOLD; +} + +LJFOLD(SUB any KINT64) +LJFOLDF(simplify_intsub_k64) +{ + uint64_t k = ir_kint64(fright)->u64; + if (k == 0) /* i - 0 ==> i */ + return LEFTFOLD; + fins->o = IR_ADD; /* i - k ==> i + (-k) */ + fins->op2 = (IRRef1)lj_ir_kint64(J, (uint64_t)-(int64_t)k); + return RETRYFOLD; +} + +static TRef simplify_intmul_k(jit_State *J, int32_t k) +{ + /* Note: many more simplifications are possible, e.g. 2^k1 +- 2^k2. + ** But this is mainly intended for simple address arithmetic. + ** Also it's easier for the backend to optimize the original multiplies. + */ + if (k == 1) { /* i * 1 ==> i */ + return LEFTFOLD; + } else if ((k & (k-1)) == 0) { /* i * 2^k ==> i << k */ + fins->o = IR_BSHL; + fins->op2 = lj_ir_kint(J, lj_fls((uint32_t)k)); + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(MUL any KINT) +LJFOLDF(simplify_intmul_k32) +{ + if (fright->i == 0) /* i * 0 ==> 0 */ + return INTFOLD(0); + else if (fright->i > 0) + return simplify_intmul_k(J, fright->i); + return NEXTFOLD; +} + +LJFOLD(MUL any KINT64) +LJFOLDF(simplify_intmul_k64) +{ + if (ir_kint64(fright)->u64 == 0) /* i * 0 ==> 0 */ + return INT64FOLD(0); +#if LJ_64 + /* NYI: SPLIT for BSHL and 32 bit backend support. */ + else if (ir_kint64(fright)->u64 < 0x80000000u) + return simplify_intmul_k(J, (int32_t)ir_kint64(fright)->u64); +#endif + return NEXTFOLD; +} + +LJFOLD(MOD any KINT) +LJFOLDF(simplify_intmod_k) +{ + int32_t k = fright->i; + lua_assert(k != 0); + if (k > 0 && (k & (k-1)) == 0) { /* i % (2^k) ==> i & (2^k-1) */ + fins->o = IR_BAND; + fins->op2 = lj_ir_kint(J, k-1); + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(MOD KINT any) +LJFOLDF(simplify_intmod_kleft) +{ + if (fleft->i == 0) + return INTFOLD(0); + return NEXTFOLD; +} + +LJFOLD(SUB any any) +LJFOLD(SUBOV any any) +LJFOLDF(simplify_intsub) +{ + if (fins->op1 == fins->op2 && !irt_isnum(fins->t)) /* i - i ==> 0 */ + return irt_is64(fins->t) ? INT64FOLD(0) : INTFOLD(0); + return NEXTFOLD; +} + +LJFOLD(SUB ADD any) +LJFOLDF(simplify_intsubadd_leftcancel) +{ + if (!irt_isnum(fins->t)) { + PHIBARRIER(fleft); + if (fins->op2 == fleft->op1) /* (i + j) - i ==> j */ + return fleft->op2; + if (fins->op2 == fleft->op2) /* (i + j) - j ==> i */ + return fleft->op1; + } + return NEXTFOLD; +} + +LJFOLD(SUB SUB any) +LJFOLDF(simplify_intsubsub_leftcancel) +{ + if (!irt_isnum(fins->t)) { + PHIBARRIER(fleft); + if (fins->op2 == fleft->op1) { /* (i - j) - i ==> 0 - j */ + fins->op1 = (IRRef1)lj_ir_kint(J, 0); + fins->op2 = fleft->op2; + return RETRYFOLD; + } + } + return NEXTFOLD; +} + +LJFOLD(SUB any SUB) +LJFOLDF(simplify_intsubsub_rightcancel) +{ + if (!irt_isnum(fins->t)) { + PHIBARRIER(fright); + if (fins->op1 == fright->op1) /* i - (i - j) ==> j */ + return fright->op2; + } + return NEXTFOLD; +} + +LJFOLD(SUB any ADD) +LJFOLDF(simplify_intsubadd_rightcancel) +{ + if (!irt_isnum(fins->t)) { + PHIBARRIER(fright); + if (fins->op1 == fright->op1) { /* i - (i + j) ==> 0 - j */ + fins->op2 = fright->op2; + fins->op1 = (IRRef1)lj_ir_kint(J, 0); + return RETRYFOLD; + } + if (fins->op1 == fright->op2) { /* i - (j + i) ==> 0 - j */ + fins->op2 = fright->op1; + fins->op1 = (IRRef1)lj_ir_kint(J, 0); + return RETRYFOLD; + } + } + return NEXTFOLD; +} + +LJFOLD(SUB ADD ADD) +LJFOLDF(simplify_intsubaddadd_cancel) +{ + if (!irt_isnum(fins->t)) { + PHIBARRIER(fleft); + PHIBARRIER(fright); + if (fleft->op1 == fright->op1) { /* (i + j1) - (i + j2) ==> j1 - j2 */ + fins->op1 = fleft->op2; + fins->op2 = fright->op2; + return RETRYFOLD; + } + if (fleft->op1 == fright->op2) { /* (i + j1) - (j2 + i) ==> j1 - j2 */ + fins->op1 = fleft->op2; + fins->op2 = fright->op1; + return RETRYFOLD; + } + if (fleft->op2 == fright->op1) { /* (j1 + i) - (i + j2) ==> j1 - j2 */ + fins->op1 = fleft->op1; + fins->op2 = fright->op2; + return RETRYFOLD; + } + if (fleft->op2 == fright->op2) { /* (j1 + i) - (j2 + i) ==> j1 - j2 */ + fins->op1 = fleft->op1; + fins->op2 = fright->op1; + return RETRYFOLD; + } + } + return NEXTFOLD; +} + +LJFOLD(BAND any KINT) +LJFOLD(BAND any KINT64) +LJFOLDF(simplify_band_k) +{ + int64_t k = fright->o == IR_KINT ? (int64_t)fright->i : + (int64_t)ir_k64(fright)->u64; + if (k == 0) /* i & 0 ==> 0 */ + return RIGHTFOLD; + if (k == -1) /* i & -1 ==> i */ + return LEFTFOLD; + return NEXTFOLD; +} + +LJFOLD(BOR any KINT) +LJFOLD(BOR any KINT64) +LJFOLDF(simplify_bor_k) +{ + int64_t k = fright->o == IR_KINT ? (int64_t)fright->i : + (int64_t)ir_k64(fright)->u64; + if (k == 0) /* i | 0 ==> i */ + return LEFTFOLD; + if (k == -1) /* i | -1 ==> -1 */ + return RIGHTFOLD; + return NEXTFOLD; +} + +LJFOLD(BXOR any KINT) +LJFOLD(BXOR any KINT64) +LJFOLDF(simplify_bxor_k) +{ + int64_t k = fright->o == IR_KINT ? (int64_t)fright->i : + (int64_t)ir_k64(fright)->u64; + if (k == 0) /* i xor 0 ==> i */ + return LEFTFOLD; + if (k == -1) { /* i xor -1 ==> ~i */ + fins->o = IR_BNOT; + fins->op2 = 0; + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(BSHL any KINT) +LJFOLD(BSHR any KINT) +LJFOLD(BSAR any KINT) +LJFOLD(BROL any KINT) +LJFOLD(BROR any KINT) +LJFOLDF(simplify_shift_ik) +{ + int32_t mask = irt_is64(fins->t) ? 63 : 31; + int32_t k = (fright->i & mask); + if (k == 0) /* i o 0 ==> i */ + return LEFTFOLD; + if (k == 1 && fins->o == IR_BSHL) { /* i << 1 ==> i + i */ + fins->o = IR_ADD; + fins->op2 = fins->op1; + return RETRYFOLD; + } + if (k != fright->i) { /* i o k ==> i o (k & mask) */ + fins->op2 = (IRRef1)lj_ir_kint(J, k); + return RETRYFOLD; + } +#ifndef LJ_TARGET_UNIFYROT + if (fins->o == IR_BROR) { /* bror(i, k) ==> brol(i, (-k)&mask) */ + fins->o = IR_BROL; + fins->op2 = (IRRef1)lj_ir_kint(J, (-k)&mask); + return RETRYFOLD; + } +#endif + return NEXTFOLD; +} + +LJFOLD(BSHL any BAND) +LJFOLD(BSHR any BAND) +LJFOLD(BSAR any BAND) +LJFOLD(BROL any BAND) +LJFOLD(BROR any BAND) +LJFOLDF(simplify_shift_andk) +{ + IRIns *irk = IR(fright->op2); + PHIBARRIER(fright); + if ((fins->o < IR_BROL ? LJ_TARGET_MASKSHIFT : LJ_TARGET_MASKROT) && + irk->o == IR_KINT) { /* i o (j & mask) ==> i o j */ + int32_t mask = irt_is64(fins->t) ? 63 : 31; + int32_t k = irk->i & mask; + if (k == mask) { + fins->op2 = fright->op1; + return RETRYFOLD; + } + } + return NEXTFOLD; +} + +LJFOLD(BSHL KINT any) +LJFOLD(BSHR KINT any) +LJFOLD(BSHL KINT64 any) +LJFOLD(BSHR KINT64 any) +LJFOLDF(simplify_shift1_ki) +{ + int64_t k = fleft->o == IR_KINT ? (int64_t)fleft->i : + (int64_t)ir_k64(fleft)->u64; + if (k == 0) /* 0 o i ==> 0 */ + return LEFTFOLD; + return NEXTFOLD; +} + +LJFOLD(BSAR KINT any) +LJFOLD(BROL KINT any) +LJFOLD(BROR KINT any) +LJFOLD(BSAR KINT64 any) +LJFOLD(BROL KINT64 any) +LJFOLD(BROR KINT64 any) +LJFOLDF(simplify_shift2_ki) +{ + int64_t k = fleft->o == IR_KINT ? (int64_t)fleft->i : + (int64_t)ir_k64(fleft)->u64; + if (k == 0 || k == -1) /* 0 o i ==> 0; -1 o i ==> -1 */ + return LEFTFOLD; + return NEXTFOLD; +} + +LJFOLD(BSHL BAND KINT) +LJFOLD(BSHR BAND KINT) +LJFOLD(BROL BAND KINT) +LJFOLD(BROR BAND KINT) +LJFOLDF(simplify_shiftk_andk) +{ + IRIns *irk = IR(fleft->op2); + PHIBARRIER(fleft); + if (irk->o == IR_KINT) { /* (i & k1) o k2 ==> (i o k2) & (k1 o k2) */ + int32_t k = kfold_intop(irk->i, fright->i, (IROp)fins->o); + fins->op1 = fleft->op1; + fins->op1 = (IRRef1)lj_opt_fold(J); + fins->op2 = (IRRef1)lj_ir_kint(J, k); + fins->ot = IRTI(IR_BAND); + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(BAND BSHL KINT) +LJFOLD(BAND BSHR KINT) +LJFOLDF(simplify_andk_shiftk) +{ + IRIns *irk = IR(fleft->op2); + if (irk->o == IR_KINT && + kfold_intop(-1, irk->i, (IROp)fleft->o) == fright->i) + return LEFTFOLD; /* (i o k1) & k2 ==> i, if (-1 o k1) == k2 */ + return NEXTFOLD; +} + +/* -- Reassociation ------------------------------------------------------- */ + +LJFOLD(ADD ADD KINT) +LJFOLD(MUL MUL KINT) +LJFOLD(BAND BAND KINT) +LJFOLD(BOR BOR KINT) +LJFOLD(BXOR BXOR KINT) +LJFOLDF(reassoc_intarith_k) +{ + IRIns *irk = IR(fleft->op2); + if (irk->o == IR_KINT) { + int32_t k = kfold_intop(irk->i, fright->i, (IROp)fins->o); + if (k == irk->i) /* (i o k1) o k2 ==> i o k1, if (k1 o k2) == k1. */ + return LEFTFOLD; + PHIBARRIER(fleft); + fins->op1 = fleft->op1; + fins->op2 = (IRRef1)lj_ir_kint(J, k); + return RETRYFOLD; /* (i o k1) o k2 ==> i o (k1 o k2) */ + } + return NEXTFOLD; +} + +LJFOLD(ADD ADD KINT64) +LJFOLD(MUL MUL KINT64) +LJFOLD(BAND BAND KINT64) +LJFOLD(BOR BOR KINT64) +LJFOLD(BXOR BXOR KINT64) +LJFOLDF(reassoc_intarith_k64) +{ +#if LJ_HASFFI || LJ_64 + IRIns *irk = IR(fleft->op2); + if (irk->o == IR_KINT64) { + uint64_t k = kfold_int64arith(ir_k64(irk)->u64, + ir_k64(fright)->u64, (IROp)fins->o); + PHIBARRIER(fleft); + fins->op1 = fleft->op1; + fins->op2 = (IRRef1)lj_ir_kint64(J, k); + return RETRYFOLD; /* (i o k1) o k2 ==> i o (k1 o k2) */ + } + return NEXTFOLD; +#else + UNUSED(J); lua_assert(0); return FAILFOLD; +#endif +} + +LJFOLD(MIN MIN any) +LJFOLD(MAX MAX any) +LJFOLD(BAND BAND any) +LJFOLD(BOR BOR any) +LJFOLDF(reassoc_dup) +{ + if (fins->op2 == fleft->op1 || fins->op2 == fleft->op2) + return LEFTFOLD; /* (a o b) o a ==> a o b; (a o b) o b ==> a o b */ + return NEXTFOLD; +} + +LJFOLD(BXOR BXOR any) +LJFOLDF(reassoc_bxor) +{ + PHIBARRIER(fleft); + if (fins->op2 == fleft->op1) /* (a xor b) xor a ==> b */ + return fleft->op2; + if (fins->op2 == fleft->op2) /* (a xor b) xor b ==> a */ + return fleft->op1; + return NEXTFOLD; +} + +LJFOLD(BSHL BSHL KINT) +LJFOLD(BSHR BSHR KINT) +LJFOLD(BSAR BSAR KINT) +LJFOLD(BROL BROL KINT) +LJFOLD(BROR BROR KINT) +LJFOLDF(reassoc_shift) +{ + IRIns *irk = IR(fleft->op2); + PHIBARRIER(fleft); /* The (shift any KINT) rule covers k2 == 0 and more. */ + if (irk->o == IR_KINT) { /* (i o k1) o k2 ==> i o (k1 + k2) */ + int32_t mask = irt_is64(fins->t) ? 63 : 31; + int32_t k = (irk->i & mask) + (fright->i & mask); + if (k > mask) { /* Combined shift too wide? */ + if (fins->o == IR_BSHL || fins->o == IR_BSHR) + return mask == 31 ? INTFOLD(0) : INT64FOLD(0); + else if (fins->o == IR_BSAR) + k = mask; + else + k &= mask; + } + fins->op1 = fleft->op1; + fins->op2 = (IRRef1)lj_ir_kint(J, k); + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(MIN MIN KNUM) +LJFOLD(MAX MAX KNUM) +LJFOLD(MIN MIN KINT) +LJFOLD(MAX MAX KINT) +LJFOLDF(reassoc_minmax_k) +{ + IRIns *irk = IR(fleft->op2); + if (irk->o == IR_KNUM) { + lua_Number a = ir_knum(irk)->n; + lua_Number y = lj_vm_foldarith(a, knumright, fins->o - IR_ADD); + if (a == y) /* (x o k1) o k2 ==> x o k1, if (k1 o k2) == k1. */ + return LEFTFOLD; + PHIBARRIER(fleft); + fins->op1 = fleft->op1; + fins->op2 = (IRRef1)lj_ir_knum(J, y); + return RETRYFOLD; /* (x o k1) o k2 ==> x o (k1 o k2) */ + } else if (irk->o == IR_KINT) { + int32_t a = irk->i; + int32_t y = kfold_intop(a, fright->i, fins->o); + if (a == y) /* (x o k1) o k2 ==> x o k1, if (k1 o k2) == k1. */ + return LEFTFOLD; + PHIBARRIER(fleft); + fins->op1 = fleft->op1; + fins->op2 = (IRRef1)lj_ir_kint(J, y); + return RETRYFOLD; /* (x o k1) o k2 ==> x o (k1 o k2) */ + } + return NEXTFOLD; +} + +LJFOLD(MIN MAX any) +LJFOLD(MAX MIN any) +LJFOLDF(reassoc_minmax_left) +{ + if (fins->op2 == fleft->op1 || fins->op2 == fleft->op2) + return RIGHTFOLD; /* (b o1 a) o2 b ==> b; (a o1 b) o2 b ==> b */ + return NEXTFOLD; +} + +LJFOLD(MIN any MAX) +LJFOLD(MAX any MIN) +LJFOLDF(reassoc_minmax_right) +{ + if (fins->op1 == fright->op1 || fins->op1 == fright->op2) + return LEFTFOLD; /* a o2 (a o1 b) ==> a; a o2 (b o1 a) ==> a */ + return NEXTFOLD; +} + +/* -- Array bounds check elimination -------------------------------------- */ + +/* Eliminate ABC across PHIs to handle t[i-1] forwarding case. +** ABC(asize, (i+k)+(-k)) ==> ABC(asize, i), but only if it already exists. +** Could be generalized to (i+k1)+k2 ==> i+(k1+k2), but needs better disambig. +*/ +LJFOLD(ABC any ADD) +LJFOLDF(abc_fwd) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_ABC)) { + if (irref_isk(fright->op2)) { + IRIns *add2 = IR(fright->op1); + if (add2->o == IR_ADD && irref_isk(add2->op2) && + IR(fright->op2)->i == -IR(add2->op2)->i) { + IRRef ref = J->chain[IR_ABC]; + IRRef lim = add2->op1; + if (fins->op1 > lim) lim = fins->op1; + while (ref > lim) { + IRIns *ir = IR(ref); + if (ir->op1 == fins->op1 && ir->op2 == add2->op1) + return DROPFOLD; + ref = ir->prev; + } + } + } + } + return NEXTFOLD; +} + +/* Eliminate ABC for constants. +** ABC(asize, k1), ABC(asize k2) ==> ABC(asize, max(k1, k2)) +** Drop second ABC if k2 is lower. Otherwise patch first ABC with k2. +*/ +LJFOLD(ABC any KINT) +LJFOLDF(abc_k) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_ABC)) { + IRRef ref = J->chain[IR_ABC]; + IRRef asize = fins->op1; + while (ref > asize) { + IRIns *ir = IR(ref); + if (ir->op1 == asize && irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (fright->i > k) + ir->op2 = fins->op2; + return DROPFOLD; + } + ref = ir->prev; + } + return EMITFOLD; /* Already performed CSE. */ + } + return NEXTFOLD; +} + +/* Eliminate invariant ABC inside loop. */ +LJFOLD(ABC any any) +LJFOLDF(abc_invar) +{ + /* Invariant ABC marked as PTR. Drop if op1 is invariant, too. */ + if (!irt_isint(fins->t) && fins->op1 < J->chain[IR_LOOP] && + !irt_isphi(IR(fins->op1)->t)) + return DROPFOLD; + return NEXTFOLD; +} + +/* -- Commutativity ------------------------------------------------------- */ + +/* The refs of commutative ops are canonicalized. Lower refs go to the right. +** Rationale behind this: +** - It (also) moves constants to the right. +** - It reduces the number of FOLD rules (e.g. (BOR any KINT) suffices). +** - It helps CSE to find more matches. +** - The assembler generates better code with constants at the right. +*/ + +LJFOLD(ADD any any) +LJFOLD(MUL any any) +LJFOLD(ADDOV any any) +LJFOLD(MULOV any any) +LJFOLDF(comm_swap) +{ + if (fins->op1 < fins->op2) { /* Move lower ref to the right. */ + IRRef1 tmp = fins->op1; + fins->op1 = fins->op2; + fins->op2 = tmp; + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(EQ any any) +LJFOLD(NE any any) +LJFOLDF(comm_equal) +{ + /* For non-numbers only: x == x ==> drop; x ~= x ==> fail */ + if (fins->op1 == fins->op2 && !irt_isnum(fins->t)) + return CONDFOLD(fins->o == IR_EQ); + return fold_comm_swap(J); +} + +LJFOLD(LT any any) +LJFOLD(GE any any) +LJFOLD(LE any any) +LJFOLD(GT any any) +LJFOLD(ULT any any) +LJFOLD(UGE any any) +LJFOLD(ULE any any) +LJFOLD(UGT any any) +LJFOLDF(comm_comp) +{ + /* For non-numbers only: x <=> x ==> drop; x <> x ==> fail */ + if (fins->op1 == fins->op2 && !irt_isnum(fins->t)) + return CONDFOLD((fins->o ^ (fins->o >> 1)) & 1); + if (fins->op1 < fins->op2) { /* Move lower ref to the right. */ + IRRef1 tmp = fins->op1; + fins->op1 = fins->op2; + fins->op2 = tmp; + fins->o ^= 3; /* GT <-> LT, GE <-> LE, does not affect U */ + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(BAND any any) +LJFOLD(BOR any any) +LJFOLD(MIN any any) +LJFOLD(MAX any any) +LJFOLDF(comm_dup) +{ + if (fins->op1 == fins->op2) /* x o x ==> x */ + return LEFTFOLD; + return fold_comm_swap(J); +} + +LJFOLD(BXOR any any) +LJFOLDF(comm_bxor) +{ + if (fins->op1 == fins->op2) /* i xor i ==> 0 */ + return irt_is64(fins->t) ? INT64FOLD(0) : INTFOLD(0); + return fold_comm_swap(J); +} + +/* -- Simplification of compound expressions ------------------------------ */ + +static TRef kfold_xload(jit_State *J, IRIns *ir, const void *p) +{ + int32_t k; + switch (irt_type(ir->t)) { + case IRT_NUM: return lj_ir_knum_u64(J, *(uint64_t *)p); + case IRT_I8: k = (int32_t)*(int8_t *)p; break; + case IRT_U8: k = (int32_t)*(uint8_t *)p; break; + case IRT_I16: k = (int32_t)(int16_t)lj_getu16(p); break; + case IRT_U16: k = (int32_t)(uint16_t)lj_getu16(p); break; + case IRT_INT: case IRT_U32: k = (int32_t)lj_getu32(p); break; + case IRT_I64: case IRT_U64: return lj_ir_kint64(J, *(uint64_t *)p); + default: return 0; + } + return lj_ir_kint(J, k); +} + +/* Turn: string.sub(str, a, b) == kstr +** into: string.byte(str, a) == string.byte(kstr, 1) etc. +** Note: this creates unaligned XLOADs on x86/x64. +*/ +LJFOLD(EQ SNEW KGC) +LJFOLD(NE SNEW KGC) +LJFOLDF(merge_eqne_snew_kgc) +{ + GCstr *kstr = ir_kstr(fright); + int32_t len = (int32_t)kstr->len; + lua_assert(irt_isstr(fins->t)); + +#if LJ_TARGET_UNALIGNED +#define FOLD_SNEW_MAX_LEN 4 /* Handle string lengths 0, 1, 2, 3, 4. */ +#define FOLD_SNEW_TYPE8 IRT_I8 /* Creates shorter immediates. */ +#else +#define FOLD_SNEW_MAX_LEN 1 /* Handle string lengths 0 or 1. */ +#define FOLD_SNEW_TYPE8 IRT_U8 /* Prefer unsigned loads. */ +#endif + + PHIBARRIER(fleft); + if (len <= FOLD_SNEW_MAX_LEN) { + IROp op = (IROp)fins->o; + IRRef strref = fleft->op1; + if (IR(strref)->o != IR_STRREF) + return NEXTFOLD; + if (op == IR_EQ) { + emitir(IRTGI(IR_EQ), fleft->op2, lj_ir_kint(J, len)); + /* Caveat: fins/fleft/fright is no longer valid after emitir. */ + } else { + /* NE is not expanded since this would need an OR of two conds. */ + if (!irref_isk(fleft->op2)) /* Only handle the constant length case. */ + return NEXTFOLD; + if (IR(fleft->op2)->i != len) + return DROPFOLD; + } + if (len > 0) { + /* A 4 byte load for length 3 is ok -- all strings have an extra NUL. */ + uint16_t ot = (uint16_t)(len == 1 ? IRT(IR_XLOAD, FOLD_SNEW_TYPE8) : + len == 2 ? IRT(IR_XLOAD, IRT_U16) : + IRTI(IR_XLOAD)); + TRef tmp = emitir(ot, strref, + IRXLOAD_READONLY | (len > 1 ? IRXLOAD_UNALIGNED : 0)); + TRef val = kfold_xload(J, IR(tref_ref(tmp)), strdata(kstr)); + if (len == 3) + tmp = emitir(IRTI(IR_BAND), tmp, + lj_ir_kint(J, LJ_ENDIAN_SELECT(0x00ffffff, 0xffffff00))); + fins->op1 = (IRRef1)tmp; + fins->op2 = (IRRef1)val; + fins->ot = (IROpT)IRTGI(op); + return RETRYFOLD; + } else { + return DROPFOLD; + } + } + return NEXTFOLD; +} + +/* -- Loads --------------------------------------------------------------- */ + +/* Loads cannot be folded or passed on to CSE in general. +** Alias analysis is needed to check for forwarding opportunities. +** +** Caveat: *all* loads must be listed here or they end up at CSE! +*/ + +LJFOLD(ALOAD any) +LJFOLDX(lj_opt_fwd_aload) + +/* From HREF fwd (see below). Must eliminate, not supported by fwd/backend. */ +LJFOLD(HLOAD KKPTR) +LJFOLDF(kfold_hload_kkptr) +{ + UNUSED(J); + lua_assert(ir_kptr(fleft) == niltvg(J2G(J))); + return TREF_NIL; +} + +LJFOLD(HLOAD any) +LJFOLDX(lj_opt_fwd_hload) + +LJFOLD(ULOAD any) +LJFOLDX(lj_opt_fwd_uload) + +LJFOLD(CALLL any IRCALL_lj_tab_len) +LJFOLDX(lj_opt_fwd_tab_len) + +/* Upvalue refs are really loads, but there are no corresponding stores. +** So CSE is ok for them, except for UREFO across a GC step (see below). +** If the referenced function is const, its upvalue addresses are const, too. +** This can be used to improve CSE by looking for the same address, +** even if the upvalues originate from a different function. +*/ +LJFOLD(UREFO KGC any) +LJFOLD(UREFC KGC any) +LJFOLDF(cse_uref) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_CSE)) { + IRRef ref = J->chain[fins->o]; + GCfunc *fn = ir_kfunc(fleft); + GCupval *uv = gco2uv(gcref(fn->l.uvptr[(fins->op2 >> 8)])); + while (ref > 0) { + IRIns *ir = IR(ref); + if (irref_isk(ir->op1)) { + GCfunc *fn2 = ir_kfunc(IR(ir->op1)); + if (gco2uv(gcref(fn2->l.uvptr[(ir->op2 >> 8)])) == uv) { + if (fins->o == IR_UREFO && gcstep_barrier(J, ref)) + break; + return ref; + } + } + ref = ir->prev; + } + } + return EMITFOLD; +} + +LJFOLD(HREFK any any) +LJFOLDX(lj_opt_fwd_hrefk) + +LJFOLD(HREF TNEW any) +LJFOLDF(fwd_href_tnew) +{ + if (lj_opt_fwd_href_nokey(J)) + return lj_ir_kkptr(J, niltvg(J2G(J))); + return NEXTFOLD; +} + +LJFOLD(HREF TDUP KPRI) +LJFOLD(HREF TDUP KGC) +LJFOLD(HREF TDUP KNUM) +LJFOLDF(fwd_href_tdup) +{ + TValue keyv; + lj_ir_kvalue(J->L, &keyv, fright); + if (lj_tab_get(J->L, ir_ktab(IR(fleft->op1)), &keyv) == niltvg(J2G(J)) && + lj_opt_fwd_href_nokey(J)) + return lj_ir_kkptr(J, niltvg(J2G(J))); + return NEXTFOLD; +} + +/* We can safely FOLD/CSE array/hash refs and field loads, since there +** are no corresponding stores. But we need to check for any NEWREF with +** an aliased table, as it may invalidate all of the pointers and fields. +** Only HREF needs the NEWREF check -- AREF and HREFK already depend on +** FLOADs. And NEWREF itself is treated like a store (see below). +*/ +LJFOLD(FLOAD TNEW IRFL_TAB_ASIZE) +LJFOLDF(fload_tab_tnew_asize) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) + return INTFOLD(fleft->op1); + return NEXTFOLD; +} + +LJFOLD(FLOAD TNEW IRFL_TAB_HMASK) +LJFOLDF(fload_tab_tnew_hmask) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) + return INTFOLD((1 << fleft->op2)-1); + return NEXTFOLD; +} + +LJFOLD(FLOAD TDUP IRFL_TAB_ASIZE) +LJFOLDF(fload_tab_tdup_asize) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) + return INTFOLD((int32_t)ir_ktab(IR(fleft->op1))->asize); + return NEXTFOLD; +} + +LJFOLD(FLOAD TDUP IRFL_TAB_HMASK) +LJFOLDF(fload_tab_tdup_hmask) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) + return INTFOLD((int32_t)ir_ktab(IR(fleft->op1))->hmask); + return NEXTFOLD; +} + +LJFOLD(HREF any any) +LJFOLD(FLOAD any IRFL_TAB_ARRAY) +LJFOLD(FLOAD any IRFL_TAB_NODE) +LJFOLD(FLOAD any IRFL_TAB_ASIZE) +LJFOLD(FLOAD any IRFL_TAB_HMASK) +LJFOLDF(fload_tab_ah) +{ + TRef tr = lj_opt_cse(J); + return lj_opt_fwd_tptr(J, tref_ref(tr)) ? tr : EMITFOLD; +} + +/* Strings are immutable, so we can safely FOLD/CSE the related FLOAD. */ +LJFOLD(FLOAD KGC IRFL_STR_LEN) +LJFOLDF(fload_str_len_kgc) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) + return INTFOLD((int32_t)ir_kstr(fleft)->len); + return NEXTFOLD; +} + +LJFOLD(FLOAD SNEW IRFL_STR_LEN) +LJFOLDF(fload_str_len_snew) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) { + PHIBARRIER(fleft); + return fleft->op2; + } + return NEXTFOLD; +} + +/* The C type ID of cdata objects is immutable. */ +LJFOLD(FLOAD KGC IRFL_CDATA_CTYPEID) +LJFOLDF(fload_cdata_typeid_kgc) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) + return INTFOLD((int32_t)ir_kcdata(fleft)->ctypeid); + return NEXTFOLD; +} + +/* Get the contents of immutable cdata objects. */ +LJFOLD(FLOAD KGC IRFL_CDATA_PTR) +LJFOLD(FLOAD KGC IRFL_CDATA_INT) +LJFOLD(FLOAD KGC IRFL_CDATA_INT64) +LJFOLDF(fload_cdata_int64_kgc) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) { + void *p = cdataptr(ir_kcdata(fleft)); + if (irt_is64(fins->t)) + return INT64FOLD(*(uint64_t *)p); + else + return INTFOLD(*(int32_t *)p); + } + return NEXTFOLD; +} + +LJFOLD(FLOAD CNEW IRFL_CDATA_CTYPEID) +LJFOLD(FLOAD CNEWI IRFL_CDATA_CTYPEID) +LJFOLDF(fload_cdata_typeid_cnew) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) + return fleft->op1; /* No PHI barrier needed. CNEW/CNEWI op1 is const. */ + return NEXTFOLD; +} + +/* Pointer, int and int64 cdata objects are immutable. */ +LJFOLD(FLOAD CNEWI IRFL_CDATA_PTR) +LJFOLD(FLOAD CNEWI IRFL_CDATA_INT) +LJFOLD(FLOAD CNEWI IRFL_CDATA_INT64) +LJFOLDF(fload_cdata_ptr_int64_cnew) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) + return fleft->op2; /* Fold even across PHI to avoid allocations. */ + return NEXTFOLD; +} + +LJFOLD(FLOAD any IRFL_STR_LEN) +LJFOLD(FLOAD any IRFL_CDATA_CTYPEID) +LJFOLD(FLOAD any IRFL_CDATA_PTR) +LJFOLD(FLOAD any IRFL_CDATA_INT) +LJFOLD(FLOAD any IRFL_CDATA_INT64) +LJFOLD(VLOAD any any) /* Vararg loads have no corresponding stores. */ +LJFOLDX(lj_opt_cse) + +/* All other field loads need alias analysis. */ +LJFOLD(FLOAD any any) +LJFOLDX(lj_opt_fwd_fload) + +/* This is for LOOP only. Recording handles SLOADs internally. */ +LJFOLD(SLOAD any any) +LJFOLDF(fwd_sload) +{ + if ((fins->op2 & IRSLOAD_FRAME)) { + TRef tr = lj_opt_cse(J); + return tref_ref(tr) < J->chain[IR_RETF] ? EMITFOLD : tr; + } else { + lua_assert(J->slot[fins->op1] != 0); + return J->slot[fins->op1]; + } +} + +/* Only fold for KKPTR. The pointer _and_ the contents must be const. */ +LJFOLD(XLOAD KKPTR any) +LJFOLDF(xload_kptr) +{ + TRef tr = kfold_xload(J, fins, ir_kptr(fleft)); + return tr ? tr : NEXTFOLD; +} + +LJFOLD(XLOAD any any) +LJFOLDX(lj_opt_fwd_xload) + +/* -- Write barriers ------------------------------------------------------ */ + +/* Write barriers are amenable to CSE, but not across any incremental +** GC steps. +** +** The same logic applies to open upvalue references, because a stack +** may be resized during a GC step (not the current stack, but maybe that +** of a coroutine). +*/ +LJFOLD(TBAR any) +LJFOLD(OBAR any any) +LJFOLD(UREFO any any) +LJFOLDF(barrier_tab) +{ + TRef tr = lj_opt_cse(J); + if (gcstep_barrier(J, tref_ref(tr))) /* CSE across GC step? */ + return EMITFOLD; /* Raw emit. Assumes fins is left intact by CSE. */ + return tr; +} + +LJFOLD(TBAR TNEW) +LJFOLD(TBAR TDUP) +LJFOLDF(barrier_tnew_tdup) +{ + /* New tables are always white and never need a barrier. */ + if (fins->op1 < J->chain[IR_LOOP]) /* Except across a GC step. */ + return NEXTFOLD; + return DROPFOLD; +} + +/* -- Stores and allocations ---------------------------------------------- */ + +/* Stores and allocations cannot be folded or passed on to CSE in general. +** But some stores can be eliminated with dead-store elimination (DSE). +** +** Caveat: *all* stores and allocs must be listed here or they end up at CSE! +*/ + +LJFOLD(ASTORE any any) +LJFOLD(HSTORE any any) +LJFOLDX(lj_opt_dse_ahstore) + +LJFOLD(USTORE any any) +LJFOLDX(lj_opt_dse_ustore) + +LJFOLD(FSTORE any any) +LJFOLDX(lj_opt_dse_fstore) + +LJFOLD(XSTORE any any) +LJFOLDX(lj_opt_dse_xstore) + +LJFOLD(NEWREF any any) /* Treated like a store. */ +LJFOLD(CALLS any any) +LJFOLD(CALLL any any) /* Safeguard fallback. */ +LJFOLD(CALLXS any any) +LJFOLD(XBAR) +LJFOLD(RETF any any) /* Modifies BASE. */ +LJFOLD(TNEW any any) +LJFOLD(TDUP any) +LJFOLD(CNEW any any) +LJFOLD(XSNEW any any) +LJFOLDX(lj_ir_emit) + +/* ------------------------------------------------------------------------ */ + +/* Every entry in the generated hash table is a 32 bit pattern: +** +** xxxxxxxx iiiiiii lllllll rrrrrrrrrr +** +** xxxxxxxx = 8 bit index into fold function table +** iiiiiii = 7 bit folded instruction opcode +** lllllll = 7 bit left instruction opcode +** rrrrrrrrrr = 8 bit right instruction opcode or 10 bits from literal field +*/ + +#include "lj_folddef.h" + +/* ------------------------------------------------------------------------ */ + +/* Fold IR instruction. */ +TRef LJ_FASTCALL lj_opt_fold(jit_State *J) +{ + uint32_t key, any; + IRRef ref; + + if (LJ_UNLIKELY((J->flags & JIT_F_OPT_MASK) != JIT_F_OPT_DEFAULT)) { + lua_assert(((JIT_F_OPT_FOLD|JIT_F_OPT_FWD|JIT_F_OPT_CSE|JIT_F_OPT_DSE) | + JIT_F_OPT_DEFAULT) == JIT_F_OPT_DEFAULT); + /* Folding disabled? Chain to CSE, but not for loads/stores/allocs. */ + if (!(J->flags & JIT_F_OPT_FOLD) && irm_kind(lj_ir_mode[fins->o]) == IRM_N) + return lj_opt_cse(J); + + /* No FOLD, forwarding or CSE? Emit raw IR for loads, except for SLOAD. */ + if ((J->flags & (JIT_F_OPT_FOLD|JIT_F_OPT_FWD|JIT_F_OPT_CSE)) != + (JIT_F_OPT_FOLD|JIT_F_OPT_FWD|JIT_F_OPT_CSE) && + irm_kind(lj_ir_mode[fins->o]) == IRM_L && fins->o != IR_SLOAD) + return lj_ir_emit(J); + + /* No FOLD or DSE? Emit raw IR for stores. */ + if ((J->flags & (JIT_F_OPT_FOLD|JIT_F_OPT_DSE)) != + (JIT_F_OPT_FOLD|JIT_F_OPT_DSE) && + irm_kind(lj_ir_mode[fins->o]) == IRM_S) + return lj_ir_emit(J); + } + + /* Fold engine start/retry point. */ +retry: + /* Construct key from opcode and operand opcodes (unless literal/none). */ + key = ((uint32_t)fins->o << 17); + if (fins->op1 >= J->cur.nk) { + key += (uint32_t)IR(fins->op1)->o << 10; + *fleft = *IR(fins->op1); + } + if (fins->op2 >= J->cur.nk) { + key += (uint32_t)IR(fins->op2)->o; + *fright = *IR(fins->op2); + } else { + key += (fins->op2 & 0x3ffu); /* Literal mask. Must include IRCONV_*MASK. */ + } + + /* Check for a match in order from most specific to least specific. */ + any = 0; + for (;;) { + uint32_t k = key | (any & 0x1ffff); + uint32_t h = fold_hashkey(k); + uint32_t fh = fold_hash[h]; /* Lookup key in semi-perfect hash table. */ + if ((fh & 0xffffff) == k || (fh = fold_hash[h+1], (fh & 0xffffff) == k)) { + ref = (IRRef)tref_ref(fold_func[fh >> 24](J)); + if (ref != NEXTFOLD) + break; + } + if (any == 0xfffff) /* Exhausted folding. Pass on to CSE. */ + return lj_opt_cse(J); + any = (any | (any >> 10)) ^ 0xffc00; + } + + /* Return value processing, ordered by frequency. */ + if (LJ_LIKELY(ref >= MAX_FOLD)) + return TREF(ref, irt_t(IR(ref)->t)); + if (ref == RETRYFOLD) + goto retry; + if (ref == KINTFOLD) + return lj_ir_kint(J, fins->i); + if (ref == FAILFOLD) + lj_trace_err(J, LJ_TRERR_GFAIL); + lua_assert(ref == DROPFOLD); + return REF_DROP; +} + +/* -- Common-Subexpression Elimination ------------------------------------ */ + +/* CSE an IR instruction. This is very fast due to the skip-list chains. */ +TRef LJ_FASTCALL lj_opt_cse(jit_State *J) +{ + /* Avoid narrow to wide store-to-load forwarding stall */ + IRRef2 op12 = (IRRef2)fins->op1 + ((IRRef2)fins->op2 << 16); + IROp op = fins->o; + if (LJ_LIKELY(J->flags & JIT_F_OPT_CSE)) { + /* Limited search for same operands in per-opcode chain. */ + IRRef ref = J->chain[op]; + IRRef lim = fins->op1; + if (fins->op2 > lim) lim = fins->op2; /* Relies on lit < REF_BIAS. */ + while (ref > lim) { + if (IR(ref)->op12 == op12) + return TREF(ref, irt_t(IR(ref)->t)); /* Common subexpression found. */ + ref = IR(ref)->prev; + } + } + /* Otherwise emit IR (inlined for speed). */ + { + IRRef ref = lj_ir_nextins(J); + IRIns *ir = IR(ref); + ir->prev = J->chain[op]; + ir->op12 = op12; + J->chain[op] = (IRRef1)ref; + ir->o = fins->o; + J->guardemit.irt |= fins->t.irt; + return TREF(ref, irt_t((ir->t = fins->t))); + } +} + +/* CSE with explicit search limit. */ +TRef LJ_FASTCALL lj_opt_cselim(jit_State *J, IRRef lim) +{ + IRRef ref = J->chain[fins->o]; + IRRef2 op12 = (IRRef2)fins->op1 + ((IRRef2)fins->op2 << 16); + while (ref > lim) { + if (IR(ref)->op12 == op12) + return ref; + ref = IR(ref)->prev; + } + return lj_ir_emit(J); +} + +/* ------------------------------------------------------------------------ */ + +#undef IR +#undef fins +#undef fleft +#undef fright +#undef knumleft +#undef knumright +#undef emitir + +#endif + +``` + +`include/luajit-2.0.5/src/lj_opt_loop.c`: + +```c +/* +** LOOP: Loop Optimizations. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_opt_loop_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_err.h" +#include "lj_str.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#include "lj_snap.h" +#include "lj_vm.h" + +/* Loop optimization: +** +** Traditional Loop-Invariant Code Motion (LICM) splits the instructions +** of a loop into invariant and variant instructions. The invariant +** instructions are hoisted out of the loop and only the variant +** instructions remain inside the loop body. +** +** Unfortunately LICM is mostly useless for compiling dynamic languages. +** The IR has many guards and most of the subsequent instructions are +** control-dependent on them. The first non-hoistable guard would +** effectively prevent hoisting of all subsequent instructions. +** +** That's why we use a special form of unrolling using copy-substitution, +** combined with redundancy elimination: +** +** The recorded instruction stream is re-emitted to the compiler pipeline +** with substituted operands. The substitution table is filled with the +** refs returned by re-emitting each instruction. This can be done +** on-the-fly, because the IR is in strict SSA form, where every ref is +** defined before its use. +** +** This aproach generates two code sections, separated by the LOOP +** instruction: +** +** 1. The recorded instructions form a kind of pre-roll for the loop. It +** contains a mix of invariant and variant instructions and performs +** exactly one loop iteration (but not necessarily the 1st iteration). +** +** 2. The loop body contains only the variant instructions and performs +** all remaining loop iterations. +** +** On first sight that looks like a waste of space, because the variant +** instructions are present twice. But the key insight is that the +** pre-roll honors the control-dependencies for *both* the pre-roll itself +** *and* the loop body! +** +** It also means one doesn't have to explicitly model control-dependencies +** (which, BTW, wouldn't help LICM much). And it's much easier to +** integrate sparse snapshotting with this approach. +** +** One of the nicest aspects of this approach is that all of the +** optimizations of the compiler pipeline (FOLD, CSE, FWD, etc.) can be +** reused with only minor restrictions (e.g. one should not fold +** instructions across loop-carried dependencies). +** +** But in general all optimizations can be applied which only need to look +** backwards into the generated instruction stream. At any point in time +** during the copy-substitution process this contains both a static loop +** iteration (the pre-roll) and a dynamic one (from the to-be-copied +** instruction up to the end of the partial loop body). +** +** Since control-dependencies are implicitly kept, CSE also applies to all +** kinds of guards. The major advantage is that all invariant guards can +** be hoisted, too. +** +** Load/store forwarding works across loop iterations, too. This is +** important if loop-carried dependencies are kept in upvalues or tables. +** E.g. 'self.idx = self.idx + 1' deep down in some OO-style method may +** become a forwarded loop-recurrence after inlining. +** +** Since the IR is in SSA form, loop-carried dependencies have to be +** modeled with PHI instructions. The potential candidates for PHIs are +** collected on-the-fly during copy-substitution. After eliminating the +** redundant ones, PHI instructions are emitted *below* the loop body. +** +** Note that this departure from traditional SSA form doesn't change the +** semantics of the PHI instructions themselves. But it greatly simplifies +** on-the-fly generation of the IR and the machine code. +*/ + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +/* Emit raw IR without passing through optimizations. */ +#define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) + +/* -- PHI elimination ----------------------------------------------------- */ + +/* Emit or eliminate collected PHIs. */ +static void loop_emit_phi(jit_State *J, IRRef1 *subst, IRRef1 *phi, IRRef nphi, + SnapNo onsnap) +{ + int passx = 0; + IRRef i, j, nslots; + IRRef invar = J->chain[IR_LOOP]; + /* Pass #1: mark redundant and potentially redundant PHIs. */ + for (i = 0, j = 0; i < nphi; i++) { + IRRef lref = phi[i]; + IRRef rref = subst[lref]; + if (lref == rref || rref == REF_DROP) { /* Invariants are redundant. */ + irt_clearphi(IR(lref)->t); + } else { + phi[j++] = (IRRef1)lref; + if (!(IR(rref)->op1 == lref || IR(rref)->op2 == lref)) { + /* Quick check for simple recurrences failed, need pass2. */ + irt_setmark(IR(lref)->t); + passx = 1; + } + } + } + nphi = j; + /* Pass #2: traverse variant part and clear marks of non-redundant PHIs. */ + if (passx) { + SnapNo s; + for (i = J->cur.nins-1; i > invar; i--) { + IRIns *ir = IR(i); + if (!irref_isk(ir->op2)) irt_clearmark(IR(ir->op2)->t); + if (!irref_isk(ir->op1)) { + irt_clearmark(IR(ir->op1)->t); + if (ir->op1 < invar && + ir->o >= IR_CALLN && ir->o <= IR_CARG) { /* ORDER IR */ + ir = IR(ir->op1); + while (ir->o == IR_CARG) { + if (!irref_isk(ir->op2)) irt_clearmark(IR(ir->op2)->t); + if (irref_isk(ir->op1)) break; + ir = IR(ir->op1); + irt_clearmark(ir->t); + } + } + } + } + for (s = J->cur.nsnap-1; s >= onsnap; s--) { + SnapShot *snap = &J->cur.snap[s]; + SnapEntry *map = &J->cur.snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + for (n = 0; n < nent; n++) { + IRRef ref = snap_ref(map[n]); + if (!irref_isk(ref)) irt_clearmark(IR(ref)->t); + } + } + } + /* Pass #3: add PHIs for variant slots without a corresponding SLOAD. */ + nslots = J->baseslot+J->maxslot; + for (i = 1; i < nslots; i++) { + IRRef ref = tref_ref(J->slot[i]); + while (!irref_isk(ref) && ref != subst[ref]) { + IRIns *ir = IR(ref); + irt_clearmark(ir->t); /* Unmark potential uses, too. */ + if (irt_isphi(ir->t) || irt_ispri(ir->t)) + break; + irt_setphi(ir->t); + if (nphi >= LJ_MAX_PHI) + lj_trace_err(J, LJ_TRERR_PHIOV); + phi[nphi++] = (IRRef1)ref; + ref = subst[ref]; + if (ref > invar) + break; + } + } + /* Pass #4: propagate non-redundant PHIs. */ + while (passx) { + passx = 0; + for (i = 0; i < nphi; i++) { + IRRef lref = phi[i]; + IRIns *ir = IR(lref); + if (!irt_ismarked(ir->t)) { /* Propagate only from unmarked PHIs. */ + IRIns *irr = IR(subst[lref]); + if (irt_ismarked(irr->t)) { /* Right ref points to other PHI? */ + irt_clearmark(irr->t); /* Mark that PHI as non-redundant. */ + passx = 1; /* Retry. */ + } + } + } + } + /* Pass #5: emit PHI instructions or eliminate PHIs. */ + for (i = 0; i < nphi; i++) { + IRRef lref = phi[i]; + IRIns *ir = IR(lref); + if (!irt_ismarked(ir->t)) { /* Emit PHI if not marked. */ + IRRef rref = subst[lref]; + if (rref > invar) + irt_setphi(IR(rref)->t); + emitir_raw(IRT(IR_PHI, irt_type(ir->t)), lref, rref); + } else { /* Otherwise eliminate PHI. */ + irt_clearmark(ir->t); + irt_clearphi(ir->t); + } + } +} + +/* -- Loop unrolling using copy-substitution ------------------------------ */ + +/* Copy-substitute snapshot. */ +static void loop_subst_snap(jit_State *J, SnapShot *osnap, + SnapEntry *loopmap, IRRef1 *subst) +{ + SnapEntry *nmap, *omap = &J->cur.snapmap[osnap->mapofs]; + SnapEntry *nextmap = &J->cur.snapmap[snap_nextofs(&J->cur, osnap)]; + MSize nmapofs; + MSize on, ln, nn, onent = osnap->nent; + BCReg nslots = osnap->nslots; + SnapShot *snap = &J->cur.snap[J->cur.nsnap]; + if (irt_isguard(J->guardemit)) { /* Guard inbetween? */ + nmapofs = J->cur.nsnapmap; + J->cur.nsnap++; /* Add new snapshot. */ + } else { /* Otherwise overwrite previous snapshot. */ + snap--; + nmapofs = snap->mapofs; + } + J->guardemit.irt = 0; + /* Setup new snapshot. */ + snap->mapofs = (uint16_t)nmapofs; + snap->ref = (IRRef1)J->cur.nins; + snap->nslots = nslots; + snap->topslot = osnap->topslot; + snap->count = 0; + nmap = &J->cur.snapmap[nmapofs]; + /* Substitute snapshot slots. */ + on = ln = nn = 0; + while (on < onent) { + SnapEntry osn = omap[on], lsn = loopmap[ln]; + if (snap_slot(lsn) < snap_slot(osn)) { /* Copy slot from loop map. */ + nmap[nn++] = lsn; + ln++; + } else { /* Copy substituted slot from snapshot map. */ + if (snap_slot(lsn) == snap_slot(osn)) ln++; /* Shadowed loop slot. */ + if (!irref_isk(snap_ref(osn))) + osn = snap_setref(osn, subst[snap_ref(osn)]); + nmap[nn++] = osn; + on++; + } + } + while (snap_slot(loopmap[ln]) < nslots) /* Copy remaining loop slots. */ + nmap[nn++] = loopmap[ln++]; + snap->nent = (uint8_t)nn; + omap += onent; + nmap += nn; + while (omap < nextmap) /* Copy PC + frame links. */ + *nmap++ = *omap++; + J->cur.nsnapmap = (uint16_t)(nmap - J->cur.snapmap); +} + +/* Unroll loop. */ +static void loop_unroll(jit_State *J) +{ + IRRef1 phi[LJ_MAX_PHI]; + uint32_t nphi = 0; + IRRef1 *subst; + SnapNo onsnap; + SnapShot *osnap, *loopsnap; + SnapEntry *loopmap, *psentinel; + IRRef ins, invar; + + /* Use temp buffer for substitution table. + ** Only non-constant refs in [REF_BIAS,invar) are valid indexes. + ** Caveat: don't call into the VM or run the GC or the buffer may be gone. + */ + invar = J->cur.nins; + subst = (IRRef1 *)lj_str_needbuf(J->L, &G(J->L)->tmpbuf, + (invar-REF_BIAS)*sizeof(IRRef1)) - REF_BIAS; + subst[REF_BASE] = REF_BASE; + + /* LOOP separates the pre-roll from the loop body. */ + emitir_raw(IRTG(IR_LOOP, IRT_NIL), 0, 0); + + /* Grow snapshot buffer and map for copy-substituted snapshots. + ** Need up to twice the number of snapshots minus #0 and loop snapshot. + ** Need up to twice the number of entries plus fallback substitutions + ** from the loop snapshot entries for each new snapshot. + ** Caveat: both calls may reallocate J->cur.snap and J->cur.snapmap! + */ + onsnap = J->cur.nsnap; + lj_snap_grow_buf(J, 2*onsnap-2); + lj_snap_grow_map(J, J->cur.nsnapmap*2+(onsnap-2)*J->cur.snap[onsnap-1].nent); + + /* The loop snapshot is used for fallback substitutions. */ + loopsnap = &J->cur.snap[onsnap-1]; + loopmap = &J->cur.snapmap[loopsnap->mapofs]; + /* The PC of snapshot #0 and the loop snapshot must match. */ + psentinel = &loopmap[loopsnap->nent]; + lua_assert(*psentinel == J->cur.snapmap[J->cur.snap[0].nent]); + *psentinel = SNAP(255, 0, 0); /* Replace PC with temporary sentinel. */ + + /* Start substitution with snapshot #1 (#0 is empty for root traces). */ + osnap = &J->cur.snap[1]; + + /* Copy and substitute all recorded instructions and snapshots. */ + for (ins = REF_FIRST; ins < invar; ins++) { + IRIns *ir; + IRRef op1, op2; + + if (ins >= osnap->ref) /* Instruction belongs to next snapshot? */ + loop_subst_snap(J, osnap++, loopmap, subst); /* Copy-substitute it. */ + + /* Substitute instruction operands. */ + ir = IR(ins); + op1 = ir->op1; + if (!irref_isk(op1)) op1 = subst[op1]; + op2 = ir->op2; + if (!irref_isk(op2)) op2 = subst[op2]; + if (irm_kind(lj_ir_mode[ir->o]) == IRM_N && + op1 == ir->op1 && op2 == ir->op2) { /* Regular invariant ins? */ + subst[ins] = (IRRef1)ins; /* Shortcut. */ + } else { + /* Re-emit substituted instruction to the FOLD/CSE/etc. pipeline. */ + IRType1 t = ir->t; /* Get this first, since emitir may invalidate ir. */ + IRRef ref = tref_ref(emitir(ir->ot & ~IRT_ISPHI, op1, op2)); + subst[ins] = (IRRef1)ref; + if (ref != ins) { + IRIns *irr = IR(ref); + if (ref < invar) { /* Loop-carried dependency? */ + /* Potential PHI? */ + if (!irref_isk(ref) && !irt_isphi(irr->t) && !irt_ispri(irr->t)) { + irt_setphi(irr->t); + if (nphi >= LJ_MAX_PHI) + lj_trace_err(J, LJ_TRERR_PHIOV); + phi[nphi++] = (IRRef1)ref; + } + /* Check all loop-carried dependencies for type instability. */ + if (!irt_sametype(t, irr->t)) { + if (irt_isinteger(t) && irt_isinteger(irr->t)) + continue; + else if (irt_isnum(t) && irt_isinteger(irr->t)) /* Fix int->num. */ + ref = tref_ref(emitir(IRTN(IR_CONV), ref, IRCONV_NUM_INT)); + else if (irt_isnum(irr->t) && irt_isinteger(t)) /* Fix num->int. */ + ref = tref_ref(emitir(IRTGI(IR_CONV), ref, + IRCONV_INT_NUM|IRCONV_CHECK)); + else + lj_trace_err(J, LJ_TRERR_TYPEINS); + subst[ins] = (IRRef1)ref; + irr = IR(ref); + goto phiconv; + } + } else if (ref != REF_DROP && irr->o == IR_CONV && + ref > invar && irr->op1 < invar) { + /* May need an extra PHI for a CONV. */ + ref = irr->op1; + irr = IR(ref); + phiconv: + if (ref < invar && !irref_isk(ref) && !irt_isphi(irr->t)) { + irt_setphi(irr->t); + if (nphi >= LJ_MAX_PHI) + lj_trace_err(J, LJ_TRERR_PHIOV); + phi[nphi++] = (IRRef1)ref; + } + } + } + } + } + if (!irt_isguard(J->guardemit)) /* Drop redundant snapshot. */ + J->cur.nsnapmap = (uint16_t)J->cur.snap[--J->cur.nsnap].mapofs; + lua_assert(J->cur.nsnapmap <= J->sizesnapmap); + *psentinel = J->cur.snapmap[J->cur.snap[0].nent]; /* Restore PC. */ + + loop_emit_phi(J, subst, phi, nphi, onsnap); +} + +/* Undo any partial changes made by the loop optimization. */ +static void loop_undo(jit_State *J, IRRef ins, SnapNo nsnap, MSize nsnapmap) +{ + ptrdiff_t i; + SnapShot *snap = &J->cur.snap[nsnap-1]; + SnapEntry *map = J->cur.snapmap; + map[snap->mapofs + snap->nent] = map[J->cur.snap[0].nent]; /* Restore PC. */ + J->cur.nsnapmap = (uint16_t)nsnapmap; + J->cur.nsnap = nsnap; + J->guardemit.irt = 0; + lj_ir_rollback(J, ins); + for (i = 0; i < BPROP_SLOTS; i++) { /* Remove backprop. cache entries. */ + BPropEntry *bp = &J->bpropcache[i]; + if (bp->val >= ins) + bp->key = 0; + } + for (ins--; ins >= REF_FIRST; ins--) { /* Remove flags. */ + IRIns *ir = IR(ins); + irt_clearphi(ir->t); + irt_clearmark(ir->t); + } +} + +/* Protected callback for loop optimization. */ +static TValue *cploop_opt(lua_State *L, lua_CFunction dummy, void *ud) +{ + UNUSED(L); UNUSED(dummy); + loop_unroll((jit_State *)ud); + return NULL; +} + +/* Loop optimization. */ +int lj_opt_loop(jit_State *J) +{ + IRRef nins = J->cur.nins; + SnapNo nsnap = J->cur.nsnap; + MSize nsnapmap = J->cur.nsnapmap; + int errcode = lj_vm_cpcall(J->L, NULL, J, cploop_opt); + if (LJ_UNLIKELY(errcode)) { + lua_State *L = J->L; + if (errcode == LUA_ERRRUN && tvisnumber(L->top-1)) { /* Trace error? */ + int32_t e = numberVint(L->top-1); + switch ((TraceError)e) { + case LJ_TRERR_TYPEINS: /* Type instability. */ + case LJ_TRERR_GFAIL: /* Guard would always fail. */ + /* Unrolling via recording fixes many cases, e.g. a flipped boolean. */ + if (--J->instunroll < 0) /* But do not unroll forever. */ + break; + L->top--; /* Remove error object. */ + loop_undo(J, nins, nsnap, nsnapmap); + return 1; /* Loop optimization failed, continue recording. */ + default: + break; + } + } + lj_err_throw(L, errcode); /* Propagate all other errors. */ + } + return 0; /* Loop optimization is ok. */ +} + +#undef IR +#undef emitir +#undef emitir_raw + +#endif + +``` + +`include/luajit-2.0.5/src/lj_opt_mem.c`: + +```c +/* +** Memory access optimizations. +** AA: Alias Analysis using high-level semantic disambiguation. +** FWD: Load Forwarding (L2L) + Store Forwarding (S2L). +** DSE: Dead-Store Elimination. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_opt_mem_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_tab.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) +#define fins (&J->fold.ins) +#define fleft (&J->fold.left) +#define fright (&J->fold.right) + +/* +** Caveat #1: return value is not always a TRef -- only use with tref_ref(). +** Caveat #2: FWD relies on active CSE for xREF operands -- see lj_opt_fold(). +*/ + +/* Return values from alias analysis. */ +typedef enum { + ALIAS_NO, /* The two refs CANNOT alias (exact). */ + ALIAS_MAY, /* The two refs MAY alias (inexact). */ + ALIAS_MUST /* The two refs MUST alias (exact). */ +} AliasRet; + +/* -- ALOAD/HLOAD forwarding and ASTORE/HSTORE elimination ---------------- */ + +/* Simplified escape analysis: check for intervening stores. */ +static AliasRet aa_escape(jit_State *J, IRIns *ir, IRIns *stop) +{ + IRRef ref = (IRRef)(ir - J->cur.ir); /* The ref that might be stored. */ + for (ir++; ir < stop; ir++) + if (ir->op2 == ref && + (ir->o == IR_ASTORE || ir->o == IR_HSTORE || + ir->o == IR_USTORE || ir->o == IR_FSTORE)) + return ALIAS_MAY; /* Reference was stored and might alias. */ + return ALIAS_NO; /* Reference was not stored. */ +} + +/* Alias analysis for two different table references. */ +static AliasRet aa_table(jit_State *J, IRRef ta, IRRef tb) +{ + IRIns *taba = IR(ta), *tabb = IR(tb); + int newa, newb; + lua_assert(ta != tb); + lua_assert(irt_istab(taba->t) && irt_istab(tabb->t)); + /* Disambiguate new allocations. */ + newa = (taba->o == IR_TNEW || taba->o == IR_TDUP); + newb = (tabb->o == IR_TNEW || tabb->o == IR_TDUP); + if (newa && newb) + return ALIAS_NO; /* Two different allocations never alias. */ + if (newb) { /* At least one allocation? */ + IRIns *tmp = taba; taba = tabb; tabb = tmp; + } else if (!newa) { + return ALIAS_MAY; /* Anything else: we just don't know. */ + } + return aa_escape(J, taba, tabb); +} + +/* Alias analysis for array and hash access using key-based disambiguation. */ +static AliasRet aa_ahref(jit_State *J, IRIns *refa, IRIns *refb) +{ + IRRef ka = refa->op2; + IRRef kb = refb->op2; + IRIns *keya, *keyb; + IRRef ta, tb; + if (refa == refb) + return ALIAS_MUST; /* Shortcut for same refs. */ + keya = IR(ka); + if (keya->o == IR_KSLOT) { ka = keya->op1; keya = IR(ka); } + keyb = IR(kb); + if (keyb->o == IR_KSLOT) { kb = keyb->op1; keyb = IR(kb); } + ta = (refa->o==IR_HREFK || refa->o==IR_AREF) ? IR(refa->op1)->op1 : refa->op1; + tb = (refb->o==IR_HREFK || refb->o==IR_AREF) ? IR(refb->op1)->op1 : refb->op1; + if (ka == kb) { + /* Same key. Check for same table with different ref (NEWREF vs. HREF). */ + if (ta == tb) + return ALIAS_MUST; /* Same key, same table. */ + else + return aa_table(J, ta, tb); /* Same key, possibly different table. */ + } + if (irref_isk(ka) && irref_isk(kb)) + return ALIAS_NO; /* Different constant keys. */ + if (refa->o == IR_AREF) { + /* Disambiguate array references based on index arithmetic. */ + int32_t ofsa = 0, ofsb = 0; + IRRef basea = ka, baseb = kb; + lua_assert(refb->o == IR_AREF); + /* Gather base and offset from t[base] or t[base+-ofs]. */ + if (keya->o == IR_ADD && irref_isk(keya->op2)) { + basea = keya->op1; + ofsa = IR(keya->op2)->i; + if (basea == kb && ofsa != 0) + return ALIAS_NO; /* t[base+-ofs] vs. t[base]. */ + } + if (keyb->o == IR_ADD && irref_isk(keyb->op2)) { + baseb = keyb->op1; + ofsb = IR(keyb->op2)->i; + if (ka == baseb && ofsb != 0) + return ALIAS_NO; /* t[base] vs. t[base+-ofs]. */ + } + if (basea == baseb && ofsa != ofsb) + return ALIAS_NO; /* t[base+-o1] vs. t[base+-o2] and o1 != o2. */ + } else { + /* Disambiguate hash references based on the type of their keys. */ + lua_assert((refa->o==IR_HREF || refa->o==IR_HREFK || refa->o==IR_NEWREF) && + (refb->o==IR_HREF || refb->o==IR_HREFK || refb->o==IR_NEWREF)); + if (!irt_sametype(keya->t, keyb->t)) + return ALIAS_NO; /* Different key types. */ + } + if (ta == tb) + return ALIAS_MAY; /* Same table, cannot disambiguate keys. */ + else + return aa_table(J, ta, tb); /* Try to disambiguate tables. */ +} + +/* Array and hash load forwarding. */ +static TRef fwd_ahload(jit_State *J, IRRef xref) +{ + IRIns *xr = IR(xref); + IRRef lim = xref; /* Search limit. */ + IRRef ref; + + /* Search for conflicting stores. */ + ref = J->chain[fins->o+IRDELTA_L2S]; + while (ref > xref) { + IRIns *store = IR(ref); + switch (aa_ahref(J, xr, IR(store->op1))) { + case ALIAS_NO: break; /* Continue searching. */ + case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ + case ALIAS_MUST: return store->op2; /* Store forwarding. */ + } + ref = store->prev; + } + + /* No conflicting store (yet): const-fold loads from allocations. */ + { + IRIns *ir = (xr->o == IR_HREFK || xr->o == IR_AREF) ? IR(xr->op1) : xr; + IRRef tab = ir->op1; + ir = IR(tab); + if (ir->o == IR_TNEW || (ir->o == IR_TDUP && irref_isk(xr->op2))) { + /* A NEWREF with a number key may end up pointing to the array part. + ** But it's referenced from HSTORE and not found in the ASTORE chain. + ** For now simply consider this a conflict without forwarding anything. + */ + if (xr->o == IR_AREF) { + IRRef ref2 = J->chain[IR_NEWREF]; + while (ref2 > tab) { + IRIns *newref = IR(ref2); + if (irt_isnum(IR(newref->op2)->t)) + goto cselim; + ref2 = newref->prev; + } + } + /* NEWREF inhibits CSE for HREF, and dependent FLOADs from HREFK/AREF. + ** But the above search for conflicting stores was limited by xref. + ** So continue searching, limited by the TNEW/TDUP. Store forwarding + ** is ok, too. A conflict does NOT limit the search for a matching load. + */ + while (ref > tab) { + IRIns *store = IR(ref); + switch (aa_ahref(J, xr, IR(store->op1))) { + case ALIAS_NO: break; /* Continue searching. */ + case ALIAS_MAY: goto cselim; /* Conflicting store. */ + case ALIAS_MUST: return store->op2; /* Store forwarding. */ + } + ref = store->prev; + } + lua_assert(ir->o != IR_TNEW || irt_isnil(fins->t)); + if (irt_ispri(fins->t)) { + return TREF_PRI(irt_type(fins->t)); + } else if (irt_isnum(fins->t) || (LJ_DUALNUM && irt_isint(fins->t)) || + irt_isstr(fins->t)) { + TValue keyv; + cTValue *tv; + IRIns *key = IR(xr->op2); + if (key->o == IR_KSLOT) key = IR(key->op1); + lj_ir_kvalue(J->L, &keyv, key); + tv = lj_tab_get(J->L, ir_ktab(IR(ir->op1)), &keyv); + lua_assert(itype2irt(tv) == irt_type(fins->t)); + if (irt_isnum(fins->t)) + return lj_ir_knum_u64(J, tv->u64); + else if (LJ_DUALNUM && irt_isint(fins->t)) + return lj_ir_kint(J, intV(tv)); + else + return lj_ir_kstr(J, strV(tv)); + } + /* Othwerwise: don't intern as a constant. */ + } + } + +cselim: + /* Try to find a matching load. Below the conflicting store, if any. */ + ref = J->chain[fins->o]; + while (ref > lim) { + IRIns *load = IR(ref); + if (load->op1 == xref) + return ref; /* Load forwarding. */ + ref = load->prev; + } + return 0; /* Conflict or no match. */ +} + +/* Reassociate ALOAD across PHIs to handle t[i-1] forwarding case. */ +static TRef fwd_aload_reassoc(jit_State *J) +{ + IRIns *irx = IR(fins->op1); + IRIns *key = IR(irx->op2); + if (key->o == IR_ADD && irref_isk(key->op2)) { + IRIns *add2 = IR(key->op1); + if (add2->o == IR_ADD && irref_isk(add2->op2) && + IR(key->op2)->i == -IR(add2->op2)->i) { + IRRef ref = J->chain[IR_AREF]; + IRRef lim = add2->op1; + if (irx->op1 > lim) lim = irx->op1; + while (ref > lim) { + IRIns *ir = IR(ref); + if (ir->op1 == irx->op1 && ir->op2 == add2->op1) + return fwd_ahload(J, ref); + ref = ir->prev; + } + } + } + return 0; +} + +/* ALOAD forwarding. */ +TRef LJ_FASTCALL lj_opt_fwd_aload(jit_State *J) +{ + IRRef ref; + if ((ref = fwd_ahload(J, fins->op1)) || + (ref = fwd_aload_reassoc(J))) + return ref; + return EMITFOLD; +} + +/* HLOAD forwarding. */ +TRef LJ_FASTCALL lj_opt_fwd_hload(jit_State *J) +{ + IRRef ref = fwd_ahload(J, fins->op1); + if (ref) + return ref; + return EMITFOLD; +} + +/* HREFK forwarding. */ +TRef LJ_FASTCALL lj_opt_fwd_hrefk(jit_State *J) +{ + IRRef tab = fleft->op1; + IRRef ref = J->chain[IR_NEWREF]; + while (ref > tab) { + IRIns *newref = IR(ref); + if (tab == newref->op1) { + if (fright->op1 == newref->op2) + return ref; /* Forward from NEWREF. */ + else + goto docse; + } else if (aa_table(J, tab, newref->op1) != ALIAS_NO) { + goto docse; + } + ref = newref->prev; + } + /* No conflicting NEWREF: key location unchanged for HREFK of TDUP. */ + if (IR(tab)->o == IR_TDUP) + fins->t.irt &= ~IRT_GUARD; /* Drop HREFK guard. */ +docse: + return CSEFOLD; +} + +/* Check whether HREF of TNEW/TDUP can be folded to niltv. */ +int LJ_FASTCALL lj_opt_fwd_href_nokey(jit_State *J) +{ + IRRef lim = fins->op1; /* Search limit. */ + IRRef ref; + + /* The key for an ASTORE may end up in the hash part after a NEWREF. */ + if (irt_isnum(fright->t) && J->chain[IR_NEWREF] > lim) { + ref = J->chain[IR_ASTORE]; + while (ref > lim) { + if (ref < J->chain[IR_NEWREF]) + return 0; /* Conflict. */ + ref = IR(ref)->prev; + } + } + + /* Search for conflicting stores. */ + ref = J->chain[IR_HSTORE]; + while (ref > lim) { + IRIns *store = IR(ref); + if (aa_ahref(J, fins, IR(store->op1)) != ALIAS_NO) + return 0; /* Conflict. */ + ref = store->prev; + } + + return 1; /* No conflict. Can fold to niltv. */ +} + +/* Check whether there's no aliasing NEWREF for the left operand. */ +int LJ_FASTCALL lj_opt_fwd_tptr(jit_State *J, IRRef lim) +{ + IRRef ta = fins->op1; + IRRef ref = J->chain[IR_NEWREF]; + while (ref > lim) { + IRIns *newref = IR(ref); + if (ta == newref->op1 || aa_table(J, ta, newref->op1) != ALIAS_NO) + return 0; /* Conflict. */ + ref = newref->prev; + } + return 1; /* No conflict. Can safely FOLD/CSE. */ +} + +/* ASTORE/HSTORE elimination. */ +TRef LJ_FASTCALL lj_opt_dse_ahstore(jit_State *J) +{ + IRRef xref = fins->op1; /* xREF reference. */ + IRRef val = fins->op2; /* Stored value reference. */ + IRIns *xr = IR(xref); + IRRef1 *refp = &J->chain[fins->o]; + IRRef ref = *refp; + while (ref > xref) { /* Search for redundant or conflicting stores. */ + IRIns *store = IR(ref); + switch (aa_ahref(J, xr, IR(store->op1))) { + case ALIAS_NO: + break; /* Continue searching. */ + case ALIAS_MAY: /* Store to MAYBE the same location. */ + if (store->op2 != val) /* Conflict if the value is different. */ + goto doemit; + break; /* Otherwise continue searching. */ + case ALIAS_MUST: /* Store to the same location. */ + if (store->op2 == val) /* Same value: drop the new store. */ + return DROPFOLD; + /* Different value: try to eliminate the redundant store. */ + if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ + IRIns *ir; + /* Check for any intervening guards (includes conflicting loads). */ + for (ir = IR(J->cur.nins-1); ir > store; ir--) + if (irt_isguard(ir->t) || ir->o == IR_CALLL) + goto doemit; /* No elimination possible. */ + /* Remove redundant store from chain and replace with NOP. */ + *refp = store->prev; + store->o = IR_NOP; + store->t.irt = IRT_NIL; + store->op1 = store->op2 = 0; + store->prev = 0; + /* Now emit the new store instead. */ + } + goto doemit; + } + ref = *(refp = &store->prev); + } +doemit: + return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ +} + +/* -- ULOAD forwarding ---------------------------------------------------- */ + +/* The current alias analysis for upvalues is very simplistic. It only +** disambiguates between the unique upvalues of the same function. +** This is good enough for now, since most upvalues are read-only. +** +** A more precise analysis would be feasible with the help of the parser: +** generate a unique key for every upvalue, even across all prototypes. +** Lacking a realistic use-case, it's unclear whether this is beneficial. +*/ +static AliasRet aa_uref(IRIns *refa, IRIns *refb) +{ + if (refa->o != refb->o) + return ALIAS_NO; /* Different UREFx type. */ + if (refa->op1 == refb->op1) { /* Same function. */ + if (refa->op2 == refb->op2) + return ALIAS_MUST; /* Same function, same upvalue idx. */ + else + return ALIAS_NO; /* Same function, different upvalue idx. */ + } else { /* Different functions, check disambiguation hash values. */ + if (((refa->op2 ^ refb->op2) & 0xff)) + return ALIAS_NO; /* Upvalues with different hash values cannot alias. */ + else + return ALIAS_MAY; /* No conclusion can be drawn for same hash value. */ + } +} + +/* ULOAD forwarding. */ +TRef LJ_FASTCALL lj_opt_fwd_uload(jit_State *J) +{ + IRRef uref = fins->op1; + IRRef lim = REF_BASE; /* Search limit. */ + IRIns *xr = IR(uref); + IRRef ref; + + /* Search for conflicting stores. */ + ref = J->chain[IR_USTORE]; + while (ref > lim) { + IRIns *store = IR(ref); + switch (aa_uref(xr, IR(store->op1))) { + case ALIAS_NO: break; /* Continue searching. */ + case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ + case ALIAS_MUST: return store->op2; /* Store forwarding. */ + } + ref = store->prev; + } + +cselim: + /* Try to find a matching load. Below the conflicting store, if any. */ + + ref = J->chain[IR_ULOAD]; + while (ref > lim) { + IRIns *ir = IR(ref); + if (ir->op1 == uref || + (IR(ir->op1)->op12 == IR(uref)->op12 && IR(ir->op1)->o == IR(uref)->o)) + return ref; /* Match for identical or equal UREFx (non-CSEable UREFO). */ + ref = ir->prev; + } + return lj_ir_emit(J); +} + +/* USTORE elimination. */ +TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J) +{ + IRRef xref = fins->op1; /* xREF reference. */ + IRRef val = fins->op2; /* Stored value reference. */ + IRIns *xr = IR(xref); + IRRef1 *refp = &J->chain[IR_USTORE]; + IRRef ref = *refp; + while (ref > xref) { /* Search for redundant or conflicting stores. */ + IRIns *store = IR(ref); + switch (aa_uref(xr, IR(store->op1))) { + case ALIAS_NO: + break; /* Continue searching. */ + case ALIAS_MAY: /* Store to MAYBE the same location. */ + if (store->op2 != val) /* Conflict if the value is different. */ + goto doemit; + break; /* Otherwise continue searching. */ + case ALIAS_MUST: /* Store to the same location. */ + if (store->op2 == val) /* Same value: drop the new store. */ + return DROPFOLD; + /* Different value: try to eliminate the redundant store. */ + if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ + IRIns *ir; + /* Check for any intervening guards (includes conflicting loads). */ + for (ir = IR(J->cur.nins-1); ir > store; ir--) + if (irt_isguard(ir->t)) + goto doemit; /* No elimination possible. */ + /* Remove redundant store from chain and replace with NOP. */ + *refp = store->prev; + store->o = IR_NOP; + store->t.irt = IRT_NIL; + store->op1 = store->op2 = 0; + store->prev = 0; + if (ref+1 < J->cur.nins && + store[1].o == IR_OBAR && store[1].op1 == xref) { + IRRef1 *bp = &J->chain[IR_OBAR]; + IRIns *obar; + for (obar = IR(*bp); *bp > ref+1; obar = IR(*bp)) + bp = &obar->prev; + /* Remove OBAR, too. */ + *bp = obar->prev; + obar->o = IR_NOP; + obar->t.irt = IRT_NIL; + obar->op1 = obar->op2 = 0; + obar->prev = 0; + } + /* Now emit the new store instead. */ + } + goto doemit; + } + ref = *(refp = &store->prev); + } +doemit: + return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ +} + +/* -- FLOAD forwarding and FSTORE elimination ----------------------------- */ + +/* Alias analysis for field access. +** Field loads are cheap and field stores are rare. +** Simple disambiguation based on field types is good enough. +*/ +static AliasRet aa_fref(jit_State *J, IRIns *refa, IRIns *refb) +{ + if (refa->op2 != refb->op2) + return ALIAS_NO; /* Different fields. */ + if (refa->op1 == refb->op1) + return ALIAS_MUST; /* Same field, same object. */ + else if (refa->op2 >= IRFL_TAB_META && refa->op2 <= IRFL_TAB_NOMM) + return aa_table(J, refa->op1, refb->op1); /* Disambiguate tables. */ + else + return ALIAS_MAY; /* Same field, possibly different object. */ +} + +/* Only the loads for mutable fields end up here (see FOLD). */ +TRef LJ_FASTCALL lj_opt_fwd_fload(jit_State *J) +{ + IRRef oref = fins->op1; /* Object reference. */ + IRRef fid = fins->op2; /* Field ID. */ + IRRef lim = oref; /* Search limit. */ + IRRef ref; + + /* Search for conflicting stores. */ + ref = J->chain[IR_FSTORE]; + while (ref > oref) { + IRIns *store = IR(ref); + switch (aa_fref(J, fins, IR(store->op1))) { + case ALIAS_NO: break; /* Continue searching. */ + case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ + case ALIAS_MUST: return store->op2; /* Store forwarding. */ + } + ref = store->prev; + } + + /* No conflicting store: const-fold field loads from allocations. */ + if (fid == IRFL_TAB_META) { + IRIns *ir = IR(oref); + if (ir->o == IR_TNEW || ir->o == IR_TDUP) + return lj_ir_knull(J, IRT_TAB); + } + +cselim: + /* Try to find a matching load. Below the conflicting store, if any. */ + return lj_opt_cselim(J, lim); +} + +/* FSTORE elimination. */ +TRef LJ_FASTCALL lj_opt_dse_fstore(jit_State *J) +{ + IRRef fref = fins->op1; /* FREF reference. */ + IRRef val = fins->op2; /* Stored value reference. */ + IRIns *xr = IR(fref); + IRRef1 *refp = &J->chain[IR_FSTORE]; + IRRef ref = *refp; + while (ref > fref) { /* Search for redundant or conflicting stores. */ + IRIns *store = IR(ref); + switch (aa_fref(J, xr, IR(store->op1))) { + case ALIAS_NO: + break; /* Continue searching. */ + case ALIAS_MAY: + if (store->op2 != val) /* Conflict if the value is different. */ + goto doemit; + break; /* Otherwise continue searching. */ + case ALIAS_MUST: + if (store->op2 == val) /* Same value: drop the new store. */ + return DROPFOLD; + /* Different value: try to eliminate the redundant store. */ + if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ + IRIns *ir; + /* Check for any intervening guards or conflicting loads. */ + for (ir = IR(J->cur.nins-1); ir > store; ir--) + if (irt_isguard(ir->t) || (ir->o == IR_FLOAD && ir->op2 == xr->op2)) + goto doemit; /* No elimination possible. */ + /* Remove redundant store from chain and replace with NOP. */ + *refp = store->prev; + store->o = IR_NOP; + store->t.irt = IRT_NIL; + store->op1 = store->op2 = 0; + store->prev = 0; + /* Now emit the new store instead. */ + } + goto doemit; + } + ref = *(refp = &store->prev); + } +doemit: + return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ +} + +/* -- XLOAD forwarding and XSTORE elimination ----------------------------- */ + +/* Find cdata allocation for a reference (if any). */ +static IRIns *aa_findcnew(jit_State *J, IRIns *ir) +{ + while (ir->o == IR_ADD) { + if (!irref_isk(ir->op1)) { + IRIns *ir1 = aa_findcnew(J, IR(ir->op1)); /* Left-recursion. */ + if (ir1) return ir1; + } + if (irref_isk(ir->op2)) return NULL; + ir = IR(ir->op2); /* Flatten right-recursion. */ + } + return ir->o == IR_CNEW ? ir : NULL; +} + +/* Alias analysis for two cdata allocations. */ +static AliasRet aa_cnew(jit_State *J, IRIns *refa, IRIns *refb) +{ + IRIns *cnewa = aa_findcnew(J, refa); + IRIns *cnewb = aa_findcnew(J, refb); + if (cnewa == cnewb) + return ALIAS_MAY; /* Same allocation or neither is an allocation. */ + if (cnewa && cnewb) + return ALIAS_NO; /* Two different allocations never alias. */ + if (cnewb) { cnewa = cnewb; refb = refa; } + return aa_escape(J, cnewa, refb); +} + +/* Alias analysis for XLOAD/XSTORE. */ +static AliasRet aa_xref(jit_State *J, IRIns *refa, IRIns *xa, IRIns *xb) +{ + ptrdiff_t ofsa = 0, ofsb = 0; + IRIns *refb = IR(xb->op1); + IRIns *basea = refa, *baseb = refb; + if (refa == refb && irt_sametype(xa->t, xb->t)) + return ALIAS_MUST; /* Shortcut for same refs with identical type. */ + /* Offset-based disambiguation. */ + if (refa->o == IR_ADD && irref_isk(refa->op2)) { + IRIns *irk = IR(refa->op2); + basea = IR(refa->op1); + ofsa = (LJ_64 && irk->o == IR_KINT64) ? (ptrdiff_t)ir_k64(irk)->u64 : + (ptrdiff_t)irk->i; + } + if (refb->o == IR_ADD && irref_isk(refb->op2)) { + IRIns *irk = IR(refb->op2); + baseb = IR(refb->op1); + ofsb = (LJ_64 && irk->o == IR_KINT64) ? (ptrdiff_t)ir_k64(irk)->u64 : + (ptrdiff_t)irk->i; + } + /* Treat constified pointers like base vs. base+offset. */ + if (basea->o == IR_KPTR && baseb->o == IR_KPTR) { + ofsb += (char *)ir_kptr(baseb) - (char *)ir_kptr(basea); + baseb = basea; + } + /* This implements (very) strict aliasing rules. + ** Different types do NOT alias, except for differences in signedness. + ** Type punning through unions is allowed (but forces a reload). + */ + if (basea == baseb) { + ptrdiff_t sza = irt_size(xa->t), szb = irt_size(xb->t); + if (ofsa == ofsb) { + if (sza == szb && irt_isfp(xa->t) == irt_isfp(xb->t)) + return ALIAS_MUST; /* Same-sized, same-kind. May need to convert. */ + } else if (ofsa + sza <= ofsb || ofsb + szb <= ofsa) { + return ALIAS_NO; /* Non-overlapping base+-o1 vs. base+-o2. */ + } + /* NYI: extract, extend or reinterpret bits (int <-> fp). */ + return ALIAS_MAY; /* Overlapping or type punning: force reload. */ + } + if (!irt_sametype(xa->t, xb->t) && + !(irt_typerange(xa->t, IRT_I8, IRT_U64) && + ((xa->t.irt - IRT_I8) ^ (xb->t.irt - IRT_I8)) == 1)) + return ALIAS_NO; + /* NYI: structural disambiguation. */ + return aa_cnew(J, basea, baseb); /* Try to disambiguate allocations. */ +} + +/* Return CSEd reference or 0. Caveat: swaps lower ref to the right! */ +static IRRef reassoc_trycse(jit_State *J, IROp op, IRRef op1, IRRef op2) +{ + IRRef ref = J->chain[op]; + IRRef lim = op1; + if (op2 > lim) { lim = op2; op2 = op1; op1 = lim; } + while (ref > lim) { + IRIns *ir = IR(ref); + if (ir->op1 == op1 && ir->op2 == op2) + return ref; + ref = ir->prev; + } + return 0; +} + +/* Reassociate index references. */ +static IRRef reassoc_xref(jit_State *J, IRIns *ir) +{ + ptrdiff_t ofs = 0; + if (ir->o == IR_ADD && irref_isk(ir->op2)) { /* Get constant offset. */ + IRIns *irk = IR(ir->op2); + ofs = (LJ_64 && irk->o == IR_KINT64) ? (ptrdiff_t)ir_k64(irk)->u64 : + (ptrdiff_t)irk->i; + ir = IR(ir->op1); + } + if (ir->o == IR_ADD) { /* Add of base + index. */ + /* Index ref > base ref for loop-carried dependences. Only check op1. */ + IRIns *ir2, *ir1 = IR(ir->op1); + int32_t shift = 0; + IRRef idxref; + /* Determine index shifts. Don't bother with IR_MUL here. */ + if (ir1->o == IR_BSHL && irref_isk(ir1->op2)) + shift = IR(ir1->op2)->i; + else if (ir1->o == IR_ADD && ir1->op1 == ir1->op2) + shift = 1; + else + ir1 = ir; + ir2 = IR(ir1->op1); + /* A non-reassociated add. Must be a loop-carried dependence. */ + if (ir2->o == IR_ADD && irt_isint(ir2->t) && irref_isk(ir2->op2)) + ofs += (ptrdiff_t)IR(ir2->op2)->i << shift; + else + return 0; + idxref = ir2->op1; + /* Try to CSE the reassociated chain. Give up if not found. */ + if (ir1 != ir && + !(idxref = reassoc_trycse(J, ir1->o, idxref, + ir1->o == IR_BSHL ? ir1->op2 : idxref))) + return 0; + if (!(idxref = reassoc_trycse(J, IR_ADD, idxref, ir->op2))) + return 0; + if (ofs != 0) { + IRRef refk = tref_ref(lj_ir_kintp(J, ofs)); + if (!(idxref = reassoc_trycse(J, IR_ADD, idxref, refk))) + return 0; + } + return idxref; /* Success, found a reassociated index reference. Phew. */ + } + return 0; /* Failure. */ +} + +/* XLOAD forwarding. */ +TRef LJ_FASTCALL lj_opt_fwd_xload(jit_State *J) +{ + IRRef xref = fins->op1; + IRIns *xr = IR(xref); + IRRef lim = xref; /* Search limit. */ + IRRef ref; + + if ((fins->op2 & IRXLOAD_READONLY)) + goto cselim; + if ((fins->op2 & IRXLOAD_VOLATILE)) + goto doemit; + + /* Search for conflicting stores. */ + ref = J->chain[IR_XSTORE]; +retry: + if (J->chain[IR_CALLXS] > lim) lim = J->chain[IR_CALLXS]; + if (J->chain[IR_XBAR] > lim) lim = J->chain[IR_XBAR]; + while (ref > lim) { + IRIns *store = IR(ref); + switch (aa_xref(J, xr, fins, store)) { + case ALIAS_NO: break; /* Continue searching. */ + case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ + case ALIAS_MUST: + /* Emit conversion if the loaded type doesn't match the forwarded type. */ + if (!irt_sametype(fins->t, IR(store->op2)->t)) { + IRType dt = irt_type(fins->t), st = irt_type(IR(store->op2)->t); + if (dt == IRT_I8 || dt == IRT_I16) { /* Trunc + sign-extend. */ + st = dt | IRCONV_SEXT; + dt = IRT_INT; + } else if (dt == IRT_U8 || dt == IRT_U16) { /* Trunc + zero-extend. */ + st = dt; + dt = IRT_INT; + } + fins->ot = IRT(IR_CONV, dt); + fins->op1 = store->op2; + fins->op2 = (dt<<5)|st; + return RETRYFOLD; + } + return store->op2; /* Store forwarding. */ + } + ref = store->prev; + } + +cselim: + /* Try to find a matching load. Below the conflicting store, if any. */ + ref = J->chain[IR_XLOAD]; + while (ref > lim) { + /* CSE for XLOAD depends on the type, but not on the IRXLOAD_* flags. */ + if (IR(ref)->op1 == xref && irt_sametype(IR(ref)->t, fins->t)) + return ref; + ref = IR(ref)->prev; + } + + /* Reassociate XLOAD across PHIs to handle a[i-1] forwarding case. */ + if (!(fins->op2 & IRXLOAD_READONLY) && J->chain[IR_LOOP] && + xref == fins->op1 && (xref = reassoc_xref(J, xr)) != 0) { + ref = J->chain[IR_XSTORE]; + while (ref > lim) /* Skip stores that have already been checked. */ + ref = IR(ref)->prev; + lim = xref; + xr = IR(xref); + goto retry; /* Retry with the reassociated reference. */ + } +doemit: + return EMITFOLD; +} + +/* XSTORE elimination. */ +TRef LJ_FASTCALL lj_opt_dse_xstore(jit_State *J) +{ + IRRef xref = fins->op1; + IRIns *xr = IR(xref); + IRRef lim = xref; /* Search limit. */ + IRRef val = fins->op2; /* Stored value reference. */ + IRRef1 *refp = &J->chain[IR_XSTORE]; + IRRef ref = *refp; + if (J->chain[IR_CALLXS] > lim) lim = J->chain[IR_CALLXS]; + if (J->chain[IR_XBAR] > lim) lim = J->chain[IR_XBAR]; + if (J->chain[IR_XSNEW] > lim) lim = J->chain[IR_XSNEW]; + while (ref > lim) { /* Search for redundant or conflicting stores. */ + IRIns *store = IR(ref); + switch (aa_xref(J, xr, fins, store)) { + case ALIAS_NO: + break; /* Continue searching. */ + case ALIAS_MAY: + if (store->op2 != val) /* Conflict if the value is different. */ + goto doemit; + break; /* Otherwise continue searching. */ + case ALIAS_MUST: + if (store->op2 == val) /* Same value: drop the new store. */ + return DROPFOLD; + /* Different value: try to eliminate the redundant store. */ + if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ + IRIns *ir; + /* Check for any intervening guards or any XLOADs (no AA performed). */ + for (ir = IR(J->cur.nins-1); ir > store; ir--) + if (irt_isguard(ir->t) || ir->o == IR_XLOAD) + goto doemit; /* No elimination possible. */ + /* Remove redundant store from chain and replace with NOP. */ + *refp = store->prev; + store->o = IR_NOP; + store->t.irt = IRT_NIL; + store->op1 = store->op2 = 0; + store->prev = 0; + /* Now emit the new store instead. */ + } + goto doemit; + } + ref = *(refp = &store->prev); + } +doemit: + return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ +} + +/* -- Forwarding of lj_tab_len -------------------------------------------- */ + +/* This is rather simplistic right now, but better than nothing. */ +TRef LJ_FASTCALL lj_opt_fwd_tab_len(jit_State *J) +{ + IRRef tab = fins->op1; /* Table reference. */ + IRRef lim = tab; /* Search limit. */ + IRRef ref; + + /* Any ASTORE is a conflict and limits the search. */ + if (J->chain[IR_ASTORE] > lim) lim = J->chain[IR_ASTORE]; + + /* Search for conflicting HSTORE with numeric key. */ + ref = J->chain[IR_HSTORE]; + while (ref > lim) { + IRIns *store = IR(ref); + IRIns *href = IR(store->op1); + IRIns *key = IR(href->op2); + if (irt_isnum(key->o == IR_KSLOT ? IR(key->op1)->t : key->t)) { + lim = ref; /* Conflicting store found, limits search for TLEN. */ + break; + } + ref = store->prev; + } + + /* Try to find a matching load. Below the conflicting store, if any. */ + return lj_opt_cselim(J, lim); +} + +/* -- ASTORE/HSTORE previous type analysis -------------------------------- */ + +/* Check whether the previous value for a table store is non-nil. +** This can be derived either from a previous store or from a previous +** load (because all loads from tables perform a type check). +** +** The result of the analysis can be used to avoid the metatable check +** and the guard against HREF returning niltv. Both of these are cheap, +** so let's not spend too much effort on the analysis. +** +** A result of 1 is exact: previous value CANNOT be nil. +** A result of 0 is inexact: previous value MAY be nil. +*/ +int lj_opt_fwd_wasnonnil(jit_State *J, IROpT loadop, IRRef xref) +{ + /* First check stores. */ + IRRef ref = J->chain[loadop+IRDELTA_L2S]; + while (ref > xref) { + IRIns *store = IR(ref); + if (store->op1 == xref) { /* Same xREF. */ + /* A nil store MAY alias, but a non-nil store MUST alias. */ + return !irt_isnil(store->t); + } else if (irt_isnil(store->t)) { /* Must check any nil store. */ + IRRef skref = IR(store->op1)->op2; + IRRef xkref = IR(xref)->op2; + /* Same key type MAY alias. Need ALOAD check due to multiple int types. */ + if (loadop == IR_ALOAD || irt_sametype(IR(skref)->t, IR(xkref)->t)) { + if (skref == xkref || !irref_isk(skref) || !irref_isk(xkref)) + return 0; /* A nil store with same const key or var key MAY alias. */ + /* Different const keys CANNOT alias. */ + } /* Different key types CANNOT alias. */ + } /* Other non-nil stores MAY alias. */ + ref = store->prev; + } + + /* Check loads since nothing could be derived from stores. */ + ref = J->chain[loadop]; + while (ref > xref) { + IRIns *load = IR(ref); + if (load->op1 == xref) { /* Same xREF. */ + /* A nil load MAY alias, but a non-nil load MUST alias. */ + return !irt_isnil(load->t); + } /* Other non-nil loads MAY alias. */ + ref = load->prev; + } + return 0; /* Nothing derived at all, previous value MAY be nil. */ +} + +/* ------------------------------------------------------------------------ */ + +#undef IR +#undef fins +#undef fleft +#undef fright + +#endif + +``` + +`include/luajit-2.0.5/src/lj_opt_narrow.c`: + +```c +/* +** NARROW: Narrowing of numbers to integers (double to int32_t). +** STRIPOV: Stripping of overflow checks. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_opt_narrow_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_bc.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#include "lj_vm.h" +#include "lj_strscan.h" + +/* Rationale for narrowing optimizations: +** +** Lua has only a single number type and this is a FP double by default. +** Narrowing doubles to integers does not pay off for the interpreter on a +** current-generation x86/x64 machine. Most FP operations need the same +** amount of execution resources as their integer counterparts, except +** with slightly longer latencies. Longer latencies are a non-issue for +** the interpreter, since they are usually hidden by other overhead. +** +** The total CPU execution bandwidth is the sum of the bandwidth of the FP +** and the integer units, because they execute in parallel. The FP units +** have an equal or higher bandwidth than the integer units. Not using +** them means losing execution bandwidth. Moving work away from them to +** the already quite busy integer units is a losing proposition. +** +** The situation for JIT-compiled code is a bit different: the higher code +** density makes the extra latencies much more visible. Tight loops expose +** the latencies for updating the induction variables. Array indexing +** requires narrowing conversions with high latencies and additional +** guards (to check that the index is really an integer). And many common +** optimizations only work on integers. +** +** One solution would be speculative, eager narrowing of all number loads. +** This causes many problems, like losing -0 or the need to resolve type +** mismatches between traces. It also effectively forces the integer type +** to have overflow-checking semantics. This impedes many basic +** optimizations and requires adding overflow checks to all integer +** arithmetic operations (whereas FP arithmetics can do without). +** +** Always replacing an FP op with an integer op plus an overflow check is +** counter-productive on a current-generation super-scalar CPU. Although +** the overflow check branches are highly predictable, they will clog the +** execution port for the branch unit and tie up reorder buffers. This is +** turning a pure data-flow dependency into a different data-flow +** dependency (with slightly lower latency) *plus* a control dependency. +** In general, you don't want to do this since latencies due to data-flow +** dependencies can be well hidden by out-of-order execution. +** +** A better solution is to keep all numbers as FP values and only narrow +** when it's beneficial to do so. LuaJIT uses predictive narrowing for +** induction variables and demand-driven narrowing for index expressions, +** integer arguments and bit operations. Additionally it can eliminate or +** hoist most of the resulting overflow checks. Regular arithmetic +** computations are never narrowed to integers. +** +** The integer type in the IR has convenient wrap-around semantics and +** ignores overflow. Extra operations have been added for +** overflow-checking arithmetic (ADDOV/SUBOV) instead of an extra type. +** Apart from reducing overall complexity of the compiler, this also +** nicely solves the problem where you want to apply algebraic +** simplifications to ADD, but not to ADDOV. And the x86/x64 assembler can +** use lea instead of an add for integer ADD, but not for ADDOV (lea does +** not affect the flags, but it helps to avoid register moves). +** +** +** All of the above has to be reconsidered for architectures with slow FP +** operations or without a hardware FPU. The dual-number mode of LuaJIT +** addresses this issue. Arithmetic operations are performed on integers +** as far as possible and overflow checks are added as needed. +** +** This implies that narrowing for integer arguments and bit operations +** should also strip overflow checks, e.g. replace ADDOV with ADD. The +** original overflow guards are weak and can be eliminated by DCE, if +** there's no other use. +** +** A slight twist is that it's usually beneficial to use overflow-checked +** integer arithmetics if all inputs are already integers. This is the only +** change that affects the single-number mode, too. +*/ + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) +#define fins (&J->fold.ins) + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +#define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) + +/* -- Elimination of narrowing type conversions --------------------------- */ + +/* Narrowing of index expressions and bit operations is demand-driven. The +** trace recorder emits a narrowing type conversion (CONV.int.num or TOBIT) +** in all of these cases (e.g. array indexing or string indexing). FOLD +** already takes care of eliminating simple redundant conversions like +** CONV.int.num(CONV.num.int(x)) ==> x. +** +** But the surrounding code is FP-heavy and arithmetic operations are +** performed on FP numbers (for the single-number mode). Consider a common +** example such as 'x=t[i+1]', with 'i' already an integer (due to induction +** variable narrowing). The index expression would be recorded as +** CONV.int.num(ADD(CONV.num.int(i), 1)) +** which is clearly suboptimal. +** +** One can do better by recursively backpropagating the narrowing type +** conversion across FP arithmetic operations. This turns FP ops into +** their corresponding integer counterparts. Depending on the semantics of +** the conversion they also need to check for overflow. Currently only ADD +** and SUB are supported. +** +** The above example can be rewritten as +** ADDOV(CONV.int.num(CONV.num.int(i)), 1) +** and then into ADDOV(i, 1) after folding of the conversions. The original +** FP ops remain in the IR and are eliminated by DCE since all references to +** them are gone. +** +** [In dual-number mode the trace recorder already emits ADDOV etc., but +** this can be further reduced. See below.] +** +** Special care has to be taken to avoid narrowing across an operation +** which is potentially operating on non-integral operands. One obvious +** case is when an expression contains a non-integral constant, but ends +** up as an integer index at runtime (like t[x+1.5] with x=0.5). +** +** Operations with two non-constant operands illustrate a similar problem +** (like t[a+b] with a=1.5 and b=2.5). Backpropagation has to stop there, +** unless it can be proven that either operand is integral (e.g. by CSEing +** a previous conversion). As a not-so-obvious corollary this logic also +** applies for a whole expression tree (e.g. t[(a+1)+(b+1)]). +** +** Correctness of the transformation is guaranteed by avoiding to expand +** the tree by adding more conversions than the one we would need to emit +** if not backpropagating. TOBIT employs a more optimistic rule, because +** the conversion has special semantics, designed to make the life of the +** compiler writer easier. ;-) +** +** Using on-the-fly backpropagation of an expression tree doesn't work +** because it's unknown whether the transform is correct until the end. +** This either requires IR rollback and cache invalidation for every +** subtree or a two-pass algorithm. The former didn't work out too well, +** so the code now combines a recursive collector with a stack-based +** emitter. +** +** [A recursive backpropagation algorithm with backtracking, employing +** skip-list lookup and round-robin caching, emitting stack operations +** on-the-fly for a stack-based interpreter -- and all of that in a meager +** kilobyte? Yep, compilers are a great treasure chest. Throw away your +** textbooks and read the codebase of a compiler today!] +** +** There's another optimization opportunity for array indexing: it's +** always accompanied by an array bounds-check. The outermost overflow +** check may be delegated to the ABC operation. This works because ABC is +** an unsigned comparison and wrap-around due to overflow creates negative +** numbers. +** +** But this optimization is only valid for constants that cannot overflow +** an int32_t into the range of valid array indexes [0..2^27+1). A check +** for +-2^30 is safe since -2^31 - 2^30 wraps to 2^30 and 2^31-1 + 2^30 +** wraps to -2^30-1. +** +** It's also good enough in practice, since e.g. t[i+1] or t[i-10] are +** quite common. So the above example finally ends up as ADD(i, 1)! +** +** Later on, the assembler is able to fuse the whole array reference and +** the ADD into the memory operands of loads and other instructions. This +** is why LuaJIT is able to generate very pretty (and fast) machine code +** for array indexing. And that, my dear, concludes another story about +** one of the hidden secrets of LuaJIT ... +*/ + +/* Maximum backpropagation depth and maximum stack size. */ +#define NARROW_MAX_BACKPROP 100 +#define NARROW_MAX_STACK 256 + +/* The stack machine has a 32 bit instruction format: [IROpT | IRRef1] +** The lower 16 bits hold a reference (or 0). The upper 16 bits hold +** the IR opcode + type or one of the following special opcodes: +*/ +enum { + NARROW_REF, /* Push ref. */ + NARROW_CONV, /* Push conversion of ref. */ + NARROW_SEXT, /* Push sign-extension of ref. */ + NARROW_INT /* Push KINT ref. The next code holds an int32_t. */ +}; + +typedef uint32_t NarrowIns; + +#define NARROWINS(op, ref) (((op) << 16) + (ref)) +#define narrow_op(ins) ((IROpT)((ins) >> 16)) +#define narrow_ref(ins) ((IRRef1)(ins)) + +/* Context used for narrowing of type conversions. */ +typedef struct NarrowConv { + jit_State *J; /* JIT compiler state. */ + NarrowIns *sp; /* Current stack pointer. */ + NarrowIns *maxsp; /* Maximum stack pointer minus redzone. */ + IRRef mode; /* Conversion mode (IRCONV_*). */ + IRType t; /* Destination type: IRT_INT or IRT_I64. */ + NarrowIns stack[NARROW_MAX_STACK]; /* Stack holding stack-machine code. */ +} NarrowConv; + +/* Lookup a reference in the backpropagation cache. */ +static BPropEntry *narrow_bpc_get(jit_State *J, IRRef1 key, IRRef mode) +{ + ptrdiff_t i; + for (i = 0; i < BPROP_SLOTS; i++) { + BPropEntry *bp = &J->bpropcache[i]; + /* Stronger checks are ok, too. */ + if (bp->key == key && bp->mode >= mode && + ((bp->mode ^ mode) & IRCONV_MODEMASK) == 0) + return bp; + } + return NULL; +} + +/* Add an entry to the backpropagation cache. */ +static void narrow_bpc_set(jit_State *J, IRRef1 key, IRRef1 val, IRRef mode) +{ + uint32_t slot = J->bpropslot; + BPropEntry *bp = &J->bpropcache[slot]; + J->bpropslot = (slot + 1) & (BPROP_SLOTS-1); + bp->key = key; + bp->val = val; + bp->mode = mode; +} + +/* Backpropagate overflow stripping. */ +static void narrow_stripov_backprop(NarrowConv *nc, IRRef ref, int depth) +{ + jit_State *J = nc->J; + IRIns *ir = IR(ref); + if (ir->o == IR_ADDOV || ir->o == IR_SUBOV || + (ir->o == IR_MULOV && (nc->mode & IRCONV_CONVMASK) == IRCONV_ANY)) { + BPropEntry *bp = narrow_bpc_get(nc->J, ref, IRCONV_TOBIT); + if (bp) { + ref = bp->val; + } else if (++depth < NARROW_MAX_BACKPROP && nc->sp < nc->maxsp) { + NarrowIns *savesp = nc->sp; + narrow_stripov_backprop(nc, ir->op1, depth); + if (nc->sp < nc->maxsp) { + narrow_stripov_backprop(nc, ir->op2, depth); + if (nc->sp < nc->maxsp) { + *nc->sp++ = NARROWINS(IRT(ir->o - IR_ADDOV + IR_ADD, IRT_INT), ref); + return; + } + } + nc->sp = savesp; /* Path too deep, need to backtrack. */ + } + } + *nc->sp++ = NARROWINS(NARROW_REF, ref); +} + +/* Backpropagate narrowing conversion. Return number of needed conversions. */ +static int narrow_conv_backprop(NarrowConv *nc, IRRef ref, int depth) +{ + jit_State *J = nc->J; + IRIns *ir = IR(ref); + IRRef cref; + + if (nc->sp >= nc->maxsp) return 10; /* Path too deep. */ + + /* Check the easy cases first. */ + if (ir->o == IR_CONV && (ir->op2 & IRCONV_SRCMASK) == IRT_INT) { + if ((nc->mode & IRCONV_CONVMASK) <= IRCONV_ANY) + narrow_stripov_backprop(nc, ir->op1, depth+1); + else + *nc->sp++ = NARROWINS(NARROW_REF, ir->op1); /* Undo conversion. */ + if (nc->t == IRT_I64) + *nc->sp++ = NARROWINS(NARROW_SEXT, 0); /* Sign-extend integer. */ + return 0; + } else if (ir->o == IR_KNUM) { /* Narrow FP constant. */ + lua_Number n = ir_knum(ir)->n; + if ((nc->mode & IRCONV_CONVMASK) == IRCONV_TOBIT) { + /* Allows a wider range of constants. */ + int64_t k64 = (int64_t)n; + if (n == (lua_Number)k64) { /* Only if const doesn't lose precision. */ + *nc->sp++ = NARROWINS(NARROW_INT, 0); + *nc->sp++ = (NarrowIns)k64; /* But always truncate to 32 bits. */ + return 0; + } + } else { + int32_t k = lj_num2int(n); + /* Only if constant is a small integer. */ + if (checki16(k) && n == (lua_Number)k) { + *nc->sp++ = NARROWINS(NARROW_INT, 0); + *nc->sp++ = (NarrowIns)k; + return 0; + } + } + return 10; /* Never narrow other FP constants (this is rare). */ + } + + /* Try to CSE the conversion. Stronger checks are ok, too. */ + cref = J->chain[fins->o]; + while (cref > ref) { + IRIns *cr = IR(cref); + if (cr->op1 == ref && + (fins->o == IR_TOBIT || + ((cr->op2 & IRCONV_MODEMASK) == (nc->mode & IRCONV_MODEMASK) && + irt_isguard(cr->t) >= irt_isguard(fins->t)))) { + *nc->sp++ = NARROWINS(NARROW_REF, cref); + return 0; /* Already there, no additional conversion needed. */ + } + cref = cr->prev; + } + + /* Backpropagate across ADD/SUB. */ + if (ir->o == IR_ADD || ir->o == IR_SUB) { + /* Try cache lookup first. */ + IRRef mode = nc->mode; + BPropEntry *bp; + /* Inner conversions need a stronger check. */ + if ((mode & IRCONV_CONVMASK) == IRCONV_INDEX && depth > 0) + mode += IRCONV_CHECK-IRCONV_INDEX; + bp = narrow_bpc_get(nc->J, (IRRef1)ref, mode); + if (bp) { + *nc->sp++ = NARROWINS(NARROW_REF, bp->val); + return 0; + } else if (nc->t == IRT_I64) { + /* Try sign-extending from an existing (checked) conversion to int. */ + mode = (IRT_INT<<5)|IRT_NUM|IRCONV_INDEX; + bp = narrow_bpc_get(nc->J, (IRRef1)ref, mode); + if (bp) { + *nc->sp++ = NARROWINS(NARROW_REF, bp->val); + *nc->sp++ = NARROWINS(NARROW_SEXT, 0); + return 0; + } + } + if (++depth < NARROW_MAX_BACKPROP && nc->sp < nc->maxsp) { + NarrowIns *savesp = nc->sp; + int count = narrow_conv_backprop(nc, ir->op1, depth); + count += narrow_conv_backprop(nc, ir->op2, depth); + if (count <= 1) { /* Limit total number of conversions. */ + *nc->sp++ = NARROWINS(IRT(ir->o, nc->t), ref); + return count; + } + nc->sp = savesp; /* Too many conversions, need to backtrack. */ + } + } + + /* Otherwise add a conversion. */ + *nc->sp++ = NARROWINS(NARROW_CONV, ref); + return 1; +} + +/* Emit the conversions collected during backpropagation. */ +static IRRef narrow_conv_emit(jit_State *J, NarrowConv *nc) +{ + /* The fins fields must be saved now -- emitir() overwrites them. */ + IROpT guardot = irt_isguard(fins->t) ? IRTG(IR_ADDOV-IR_ADD, 0) : 0; + IROpT convot = fins->ot; + IRRef1 convop2 = fins->op2; + NarrowIns *next = nc->stack; /* List of instructions from backpropagation. */ + NarrowIns *last = nc->sp; + NarrowIns *sp = nc->stack; /* Recycle the stack to store operands. */ + while (next < last) { /* Simple stack machine to process the ins. list. */ + NarrowIns ref = *next++; + IROpT op = narrow_op(ref); + if (op == NARROW_REF) { + *sp++ = ref; + } else if (op == NARROW_CONV) { + *sp++ = emitir_raw(convot, ref, convop2); /* Raw emit avoids a loop. */ + } else if (op == NARROW_SEXT) { + lua_assert(sp >= nc->stack+1); + sp[-1] = emitir(IRT(IR_CONV, IRT_I64), sp[-1], + (IRT_I64<<5)|IRT_INT|IRCONV_SEXT); + } else if (op == NARROW_INT) { + lua_assert(next < last); + *sp++ = nc->t == IRT_I64 ? + lj_ir_kint64(J, (int64_t)(int32_t)*next++) : + lj_ir_kint(J, *next++); + } else { /* Regular IROpT. Pops two operands and pushes one result. */ + IRRef mode = nc->mode; + lua_assert(sp >= nc->stack+2); + sp--; + /* Omit some overflow checks for array indexing. See comments above. */ + if ((mode & IRCONV_CONVMASK) == IRCONV_INDEX) { + if (next == last && irref_isk(narrow_ref(sp[0])) && + (uint32_t)IR(narrow_ref(sp[0]))->i + 0x40000000u < 0x80000000u) + guardot = 0; + else /* Otherwise cache a stronger check. */ + mode += IRCONV_CHECK-IRCONV_INDEX; + } + sp[-1] = emitir(op+guardot, sp[-1], sp[0]); + /* Add to cache. */ + if (narrow_ref(ref)) + narrow_bpc_set(J, narrow_ref(ref), narrow_ref(sp[-1]), mode); + } + } + lua_assert(sp == nc->stack+1); + return nc->stack[0]; +} + +/* Narrow a type conversion of an arithmetic operation. */ +TRef LJ_FASTCALL lj_opt_narrow_convert(jit_State *J) +{ + if ((J->flags & JIT_F_OPT_NARROW)) { + NarrowConv nc; + nc.J = J; + nc.sp = nc.stack; + nc.maxsp = &nc.stack[NARROW_MAX_STACK-4]; + nc.t = irt_type(fins->t); + if (fins->o == IR_TOBIT) { + nc.mode = IRCONV_TOBIT; /* Used only in the backpropagation cache. */ + } else { + nc.mode = fins->op2; + } + if (narrow_conv_backprop(&nc, fins->op1, 0) <= 1) + return narrow_conv_emit(J, &nc); + } + return NEXTFOLD; +} + +/* -- Narrowing of implicit conversions ----------------------------------- */ + +/* Recursively strip overflow checks. */ +static TRef narrow_stripov(jit_State *J, TRef tr, int lastop, IRRef mode) +{ + IRRef ref = tref_ref(tr); + IRIns *ir = IR(ref); + int op = ir->o; + if (op >= IR_ADDOV && op <= lastop) { + BPropEntry *bp = narrow_bpc_get(J, ref, mode); + if (bp) { + return TREF(bp->val, irt_t(IR(bp->val)->t)); + } else { + IRRef op1 = ir->op1, op2 = ir->op2; /* The IR may be reallocated. */ + op1 = narrow_stripov(J, op1, lastop, mode); + op2 = narrow_stripov(J, op2, lastop, mode); + tr = emitir(IRT(op - IR_ADDOV + IR_ADD, + ((mode & IRCONV_DSTMASK) >> IRCONV_DSH)), op1, op2); + narrow_bpc_set(J, ref, tref_ref(tr), mode); + } + } else if (LJ_64 && (mode & IRCONV_SEXT) && !irt_is64(ir->t)) { + tr = emitir(IRT(IR_CONV, IRT_INTP), tr, mode); + } + return tr; +} + +/* Narrow array index. */ +TRef LJ_FASTCALL lj_opt_narrow_index(jit_State *J, TRef tr) +{ + IRIns *ir; + lua_assert(tref_isnumber(tr)); + if (tref_isnum(tr)) /* Conversion may be narrowed, too. See above. */ + return emitir(IRTGI(IR_CONV), tr, IRCONV_INT_NUM|IRCONV_INDEX); + /* Omit some overflow checks for array indexing. See comments above. */ + ir = IR(tref_ref(tr)); + if ((ir->o == IR_ADDOV || ir->o == IR_SUBOV) && irref_isk(ir->op2) && + (uint32_t)IR(ir->op2)->i + 0x40000000u < 0x80000000u) + return emitir(IRTI(ir->o - IR_ADDOV + IR_ADD), ir->op1, ir->op2); + return tr; +} + +/* Narrow conversion to integer operand (overflow undefined). */ +TRef LJ_FASTCALL lj_opt_narrow_toint(jit_State *J, TRef tr) +{ + if (tref_isstr(tr)) + tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); + if (tref_isnum(tr)) /* Conversion may be narrowed, too. See above. */ + return emitir(IRTI(IR_CONV), tr, IRCONV_INT_NUM|IRCONV_ANY); + if (!tref_isinteger(tr)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + /* + ** Undefined overflow semantics allow stripping of ADDOV, SUBOV and MULOV. + ** Use IRCONV_TOBIT for the cache entries, since the semantics are the same. + */ + return narrow_stripov(J, tr, IR_MULOV, (IRT_INT<<5)|IRT_INT|IRCONV_TOBIT); +} + +/* Narrow conversion to bitop operand (overflow wrapped). */ +TRef LJ_FASTCALL lj_opt_narrow_tobit(jit_State *J, TRef tr) +{ + if (tref_isstr(tr)) + tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); + if (tref_isnum(tr)) /* Conversion may be narrowed, too. See above. */ + return emitir(IRTI(IR_TOBIT), tr, lj_ir_knum_tobit(J)); + if (!tref_isinteger(tr)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + /* + ** Wrapped overflow semantics allow stripping of ADDOV and SUBOV. + ** MULOV cannot be stripped due to precision widening. + */ + return narrow_stripov(J, tr, IR_SUBOV, (IRT_INT<<5)|IRT_INT|IRCONV_TOBIT); +} + +#if LJ_HASFFI +/* Narrow C array index (overflow undefined). */ +TRef LJ_FASTCALL lj_opt_narrow_cindex(jit_State *J, TRef tr) +{ + lua_assert(tref_isnumber(tr)); + if (tref_isnum(tr)) + return emitir(IRT(IR_CONV, IRT_INTP), tr, (IRT_INTP<<5)|IRT_NUM|IRCONV_ANY); + /* Undefined overflow semantics allow stripping of ADDOV, SUBOV and MULOV. */ + return narrow_stripov(J, tr, IR_MULOV, + LJ_64 ? ((IRT_INTP<<5)|IRT_INT|IRCONV_SEXT) : + ((IRT_INTP<<5)|IRT_INT|IRCONV_TOBIT)); +} +#endif + +/* -- Narrowing of arithmetic operators ----------------------------------- */ + +/* Check whether a number fits into an int32_t (-0 is ok, too). */ +static int numisint(lua_Number n) +{ + return (n == (lua_Number)lj_num2int(n)); +} + +/* Convert string to number. Error out for non-numeric string values. */ +static TRef conv_str_tonum(jit_State *J, TRef tr, TValue *o) +{ + if (tref_isstr(tr)) { + tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); + /* Would need an inverted STRTO for this rare and useless case. */ + if (!lj_strscan_num(strV(o), o)) /* Convert in-place. Value used below. */ + lj_trace_err(J, LJ_TRERR_BADTYPE); /* Punt if non-numeric. */ + } + return tr; +} + +/* Narrowing of arithmetic operations. */ +TRef lj_opt_narrow_arith(jit_State *J, TRef rb, TRef rc, + TValue *vb, TValue *vc, IROp op) +{ + rb = conv_str_tonum(J, rb, vb); + rc = conv_str_tonum(J, rc, vc); + /* Must not narrow MUL in non-DUALNUM variant, because it loses -0. */ + if ((op >= IR_ADD && op <= (LJ_DUALNUM ? IR_MUL : IR_SUB)) && + tref_isinteger(rb) && tref_isinteger(rc) && + numisint(lj_vm_foldarith(numberVnum(vb), numberVnum(vc), + (int)op - (int)IR_ADD))) + return emitir(IRTGI((int)op - (int)IR_ADD + (int)IR_ADDOV), rb, rc); + if (!tref_isnum(rb)) rb = emitir(IRTN(IR_CONV), rb, IRCONV_NUM_INT); + if (!tref_isnum(rc)) rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT); + return emitir(IRTN(op), rb, rc); +} + +/* Narrowing of unary minus operator. */ +TRef lj_opt_narrow_unm(jit_State *J, TRef rc, TValue *vc) +{ + rc = conv_str_tonum(J, rc, vc); + if (tref_isinteger(rc)) { + if ((uint32_t)numberVint(vc) != 0x80000000u) + return emitir(IRTGI(IR_SUBOV), lj_ir_kint(J, 0), rc); + rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT); + } + return emitir(IRTN(IR_NEG), rc, lj_ir_knum_neg(J)); +} + +/* Narrowing of modulo operator. */ +TRef lj_opt_narrow_mod(jit_State *J, TRef rb, TRef rc, TValue *vb, TValue *vc) +{ + TRef tmp; + rb = conv_str_tonum(J, rb, vb); + rc = conv_str_tonum(J, rc, vc); + if ((LJ_DUALNUM || (J->flags & JIT_F_OPT_NARROW)) && + tref_isinteger(rb) && tref_isinteger(rc) && + (tvisint(vc) ? intV(vc) != 0 : !tviszero(vc))) { + emitir(IRTGI(IR_NE), rc, lj_ir_kint(J, 0)); + return emitir(IRTI(IR_MOD), rb, rc); + } + /* b % c ==> b - floor(b/c)*c */ + rb = lj_ir_tonum(J, rb); + rc = lj_ir_tonum(J, rc); + tmp = emitir(IRTN(IR_DIV), rb, rc); + tmp = emitir(IRTN(IR_FPMATH), tmp, IRFPM_FLOOR); + tmp = emitir(IRTN(IR_MUL), tmp, rc); + return emitir(IRTN(IR_SUB), rb, tmp); +} + +/* Narrowing of power operator or math.pow. */ +TRef lj_opt_narrow_pow(jit_State *J, TRef rb, TRef rc, TValue *vb, TValue *vc) +{ + rb = conv_str_tonum(J, rb, vb); + rb = lj_ir_tonum(J, rb); /* Left arg is always treated as an FP number. */ + rc = conv_str_tonum(J, rc, vc); + /* Narrowing must be unconditional to preserve (-x)^i semantics. */ + if (tvisint(vc) || numisint(numV(vc))) { + int checkrange = 0; + /* Split pow is faster for bigger exponents. But do this only for (+k)^i. */ + if (tref_isk(rb) && (int32_t)ir_knum(IR(tref_ref(rb)))->u32.hi >= 0) { + int32_t k = numberVint(vc); + if (!(k >= -65536 && k <= 65536)) goto split_pow; + checkrange = 1; + } + if (!tref_isinteger(rc)) { + /* Guarded conversion to integer! */ + rc = emitir(IRTGI(IR_CONV), rc, IRCONV_INT_NUM|IRCONV_CHECK); + } + if (checkrange && !tref_isk(rc)) { /* Range guard: -65536 <= i <= 65536 */ + TRef tmp = emitir(IRTI(IR_ADD), rc, lj_ir_kint(J, 65536)); + emitir(IRTGI(IR_ULE), tmp, lj_ir_kint(J, 2*65536)); + } + return emitir(IRTN(IR_POW), rb, rc); + } +split_pow: + /* FOLD covers most cases, but some are easier to do here. */ + if (tref_isk(rb) && tvispone(ir_knum(IR(tref_ref(rb))))) + return rb; /* 1 ^ x ==> 1 */ + rc = lj_ir_tonum(J, rc); + if (tref_isk(rc) && ir_knum(IR(tref_ref(rc)))->n == 0.5) + return emitir(IRTN(IR_FPMATH), rb, IRFPM_SQRT); /* x ^ 0.5 ==> sqrt(x) */ + /* Split up b^c into exp2(c*log2(b)). Assembler may rejoin later. */ + rb = emitir(IRTN(IR_FPMATH), rb, IRFPM_LOG2); + rc = emitir(IRTN(IR_MUL), rb, rc); + return emitir(IRTN(IR_FPMATH), rc, IRFPM_EXP2); +} + +/* -- Predictive narrowing of induction variables ------------------------- */ + +/* Narrow a single runtime value. */ +static int narrow_forl(jit_State *J, cTValue *o) +{ + if (tvisint(o)) return 1; + if (LJ_DUALNUM || (J->flags & JIT_F_OPT_NARROW)) return numisint(numV(o)); + return 0; +} + +/* Narrow the FORL index type by looking at the runtime values. */ +IRType lj_opt_narrow_forl(jit_State *J, cTValue *tv) +{ + lua_assert(tvisnumber(&tv[FORL_IDX]) && + tvisnumber(&tv[FORL_STOP]) && + tvisnumber(&tv[FORL_STEP])); + /* Narrow only if the runtime values of start/stop/step are all integers. */ + if (narrow_forl(J, &tv[FORL_IDX]) && + narrow_forl(J, &tv[FORL_STOP]) && + narrow_forl(J, &tv[FORL_STEP])) { + /* And if the loop index can't possibly overflow. */ + lua_Number step = numberVnum(&tv[FORL_STEP]); + lua_Number sum = numberVnum(&tv[FORL_STOP]) + step; + if (0 <= step ? (sum <= 2147483647.0) : (sum >= -2147483648.0)) + return IRT_INT; + } + return IRT_NUM; +} + +#undef IR +#undef fins +#undef emitir +#undef emitir_raw + +#endif + +``` + +`include/luajit-2.0.5/src/lj_opt_sink.c`: + +```c +/* +** SINK: Allocation Sinking and Store Sinking. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_opt_sink_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" +#include "lj_target.h" + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) + +/* Check whether the store ref points to an eligible allocation. */ +static IRIns *sink_checkalloc(jit_State *J, IRIns *irs) +{ + IRIns *ir = IR(irs->op1); + if (!irref_isk(ir->op2)) + return NULL; /* Non-constant key. */ + if (ir->o == IR_HREFK || ir->o == IR_AREF) + ir = IR(ir->op1); + else if (!(ir->o == IR_HREF || ir->o == IR_NEWREF || + ir->o == IR_FREF || ir->o == IR_ADD)) + return NULL; /* Unhandled reference type (for XSTORE). */ + ir = IR(ir->op1); + if (!(ir->o == IR_TNEW || ir->o == IR_TDUP || ir->o == IR_CNEW)) + return NULL; /* Not an allocation. */ + return ir; /* Return allocation. */ +} + +/* Recursively check whether a value depends on a PHI. */ +static int sink_phidep(jit_State *J, IRRef ref) +{ + IRIns *ir = IR(ref); + if (irt_isphi(ir->t)) return 1; + if (ir->op1 >= REF_FIRST && sink_phidep(J, ir->op1)) return 1; + if (ir->op2 >= REF_FIRST && sink_phidep(J, ir->op2)) return 1; + return 0; +} + +/* Check whether a value is a sinkable PHI or loop-invariant. */ +static int sink_checkphi(jit_State *J, IRIns *ira, IRRef ref) +{ + if (ref >= REF_FIRST) { + IRIns *ir = IR(ref); + if (irt_isphi(ir->t) || (ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT && + irt_isphi(IR(ir->op1)->t))) { + ira->prev++; + return 1; /* Sinkable PHI. */ + } + /* Otherwise the value must be loop-invariant. */ + return ref < J->loopref && !sink_phidep(J, ref); + } + return 1; /* Constant (non-PHI). */ +} + +/* Mark non-sinkable allocations using single-pass backward propagation. +** +** Roots for the marking process are: +** - Some PHIs or snapshots (see below). +** - Non-PHI, non-constant values stored to PHI allocations. +** - All guards. +** - Any remaining loads not eliminated by store-to-load forwarding. +** - Stores with non-constant keys. +** - All stored values. +*/ +static void sink_mark_ins(jit_State *J) +{ + IRIns *ir, *irlast = IR(J->cur.nins-1); + for (ir = irlast ; ; ir--) { + switch (ir->o) { + case IR_BASE: + return; /* Finished. */ + case IR_CALLL: /* IRCALL_lj_tab_len */ + case IR_ALOAD: case IR_HLOAD: case IR_XLOAD: case IR_TBAR: + irt_setmark(IR(ir->op1)->t); /* Mark ref for remaining loads. */ + break; + case IR_FLOAD: + if (irt_ismarked(ir->t) || ir->op2 == IRFL_TAB_META) + irt_setmark(IR(ir->op1)->t); /* Mark table for remaining loads. */ + break; + case IR_ASTORE: case IR_HSTORE: case IR_FSTORE: case IR_XSTORE: { + IRIns *ira = sink_checkalloc(J, ir); + if (!ira || (irt_isphi(ira->t) && !sink_checkphi(J, ira, ir->op2))) + irt_setmark(IR(ir->op1)->t); /* Mark ineligible ref. */ + irt_setmark(IR(ir->op2)->t); /* Mark stored value. */ + break; + } +#if LJ_HASFFI + case IR_CNEWI: + if (irt_isphi(ir->t) && + (!sink_checkphi(J, ir, ir->op2) || + (LJ_32 && ir+1 < irlast && (ir+1)->o == IR_HIOP && + !sink_checkphi(J, ir, (ir+1)->op2)))) + irt_setmark(ir->t); /* Mark ineligible allocation. */ + /* fallthrough */ +#endif + case IR_USTORE: + irt_setmark(IR(ir->op2)->t); /* Mark stored value. */ + break; +#if LJ_HASFFI + case IR_CALLXS: +#endif + case IR_CALLS: + irt_setmark(IR(ir->op1)->t); /* Mark (potentially) stored values. */ + break; + case IR_PHI: { + IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); + irl->prev = irr->prev = 0; /* Clear PHI value counts. */ + if (irl->o == irr->o && + (irl->o == IR_TNEW || irl->o == IR_TDUP || + (LJ_HASFFI && (irl->o == IR_CNEW || irl->o == IR_CNEWI)))) + break; + irt_setmark(irl->t); + irt_setmark(irr->t); + break; + } + default: + if (irt_ismarked(ir->t) || irt_isguard(ir->t)) { /* Propagate mark. */ + if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t); + if (ir->op2 >= REF_FIRST) irt_setmark(IR(ir->op2)->t); + } + break; + } + } +} + +/* Mark all instructions referenced by a snapshot. */ +static void sink_mark_snap(jit_State *J, SnapShot *snap) +{ + SnapEntry *map = &J->cur.snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + for (n = 0; n < nent; n++) { + IRRef ref = snap_ref(map[n]); + if (!irref_isk(ref)) + irt_setmark(IR(ref)->t); + } +} + +/* Iteratively remark PHI refs with differing marks or PHI value counts. */ +static void sink_remark_phi(jit_State *J) +{ + IRIns *ir; + int remark; + do { + remark = 0; + for (ir = IR(J->cur.nins-1); ir->o == IR_PHI; ir--) { + IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); + if (!((irl->t.irt ^ irr->t.irt) & IRT_MARK) && irl->prev == irr->prev) + continue; + remark |= (~(irl->t.irt & irr->t.irt) & IRT_MARK); + irt_setmark(IR(ir->op1)->t); + irt_setmark(IR(ir->op2)->t); + } + } while (remark); +} + +/* Sweep instructions and tag sunken allocations and stores. */ +static void sink_sweep_ins(jit_State *J) +{ + IRIns *ir, *irfirst = IR(J->cur.nk); + for (ir = IR(J->cur.nins-1) ; ir >= irfirst; ir--) { + switch (ir->o) { + case IR_ASTORE: case IR_HSTORE: case IR_FSTORE: case IR_XSTORE: { + IRIns *ira = sink_checkalloc(J, ir); + if (ira && !irt_ismarked(ira->t)) { + int delta = (int)(ir - ira); + ir->prev = REGSP(RID_SINK, delta > 255 ? 255 : delta); + } else { + ir->prev = REGSP_INIT; + } + break; + } + case IR_NEWREF: + if (!irt_ismarked(IR(ir->op1)->t)) { + ir->prev = REGSP(RID_SINK, 0); + } else { + irt_clearmark(ir->t); + ir->prev = REGSP_INIT; + } + break; +#if LJ_HASFFI + case IR_CNEW: case IR_CNEWI: +#endif + case IR_TNEW: case IR_TDUP: + if (!irt_ismarked(ir->t)) { + ir->t.irt &= ~IRT_GUARD; + ir->prev = REGSP(RID_SINK, 0); + J->cur.sinktags = 1; /* Signal present SINK tags to assembler. */ + } else { + irt_clearmark(ir->t); + ir->prev = REGSP_INIT; + } + break; + case IR_PHI: { + IRIns *ira = IR(ir->op2); + if (!irt_ismarked(ira->t) && + (ira->o == IR_TNEW || ira->o == IR_TDUP || + (LJ_HASFFI && (ira->o == IR_CNEW || ira->o == IR_CNEWI)))) { + ir->prev = REGSP(RID_SINK, 0); + } else { + ir->prev = REGSP_INIT; + } + break; + } + default: + irt_clearmark(ir->t); + ir->prev = REGSP_INIT; + break; + } + } +} + +/* Allocation sinking and store sinking. +** +** 1. Mark all non-sinkable allocations. +** 2. Then sink all remaining allocations and the related stores. +*/ +void lj_opt_sink(jit_State *J) +{ + const uint32_t need = (JIT_F_OPT_SINK|JIT_F_OPT_FWD| + JIT_F_OPT_DCE|JIT_F_OPT_CSE|JIT_F_OPT_FOLD); + if ((J->flags & need) == need && + (J->chain[IR_TNEW] || J->chain[IR_TDUP] || + (LJ_HASFFI && (J->chain[IR_CNEW] || J->chain[IR_CNEWI])))) { + if (!J->loopref) + sink_mark_snap(J, &J->cur.snap[J->cur.nsnap-1]); + sink_mark_ins(J); + if (J->loopref) + sink_remark_phi(J); + sink_sweep_ins(J); + } +} + +#undef IR + +#endif + +``` + +`include/luajit-2.0.5/src/lj_opt_split.c`: + +```c +/* +** SPLIT: Split 64 bit IR instructions into 32 bit IR instructions. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_opt_split_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT && (LJ_SOFTFP || (LJ_32 && LJ_HASFFI)) + +#include "lj_err.h" +#include "lj_str.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_ircall.h" +#include "lj_iropt.h" +#include "lj_vm.h" + +/* SPLIT pass: +** +** This pass splits up 64 bit IR instructions into multiple 32 bit IR +** instructions. It's only active for soft-float targets or for 32 bit CPUs +** which lack native 64 bit integer operations (the FFI is currently the +** only emitter for 64 bit integer instructions). +** +** Splitting the IR in a separate pass keeps each 32 bit IR assembler +** backend simple. Only a small amount of extra functionality needs to be +** implemented. This is much easier than adding support for allocating +** register pairs to each backend (believe me, I tried). A few simple, but +** important optimizations can be performed by the SPLIT pass, which would +** be tedious to do in the backend. +** +** The basic idea is to replace each 64 bit IR instruction with its 32 bit +** equivalent plus an extra HIOP instruction. The splitted IR is not passed +** through FOLD or any other optimizations, so each HIOP is guaranteed to +** immediately follow it's counterpart. The actual functionality of HIOP is +** inferred from the previous instruction. +** +** The operands of HIOP hold the hiword input references. The output of HIOP +** is the hiword output reference, which is also used to hold the hiword +** register or spill slot information. The register allocator treats this +** instruction independently of any other instruction, which improves code +** quality compared to using fixed register pairs. +** +** It's easier to split up some instructions into two regular 32 bit +** instructions. E.g. XLOAD is split up into two XLOADs with two different +** addresses. Obviously 64 bit constants need to be split up into two 32 bit +** constants, too. Some hiword instructions can be entirely omitted, e.g. +** when zero-extending a 32 bit value to 64 bits. 64 bit arguments for calls +** are split up into two 32 bit arguments each. +** +** On soft-float targets, floating-point instructions are directly converted +** to soft-float calls by the SPLIT pass (except for comparisons and MIN/MAX). +** HIOP for number results has the type IRT_SOFTFP ("sfp" in -jdump). +** +** Here's the IR and x64 machine code for 'x.b = x.a + 1' for a struct with +** two int64_t fields: +** +** 0100 p32 ADD base +8 +** 0101 i64 XLOAD 0100 +** 0102 i64 ADD 0101 +1 +** 0103 p32 ADD base +16 +** 0104 i64 XSTORE 0103 0102 +** +** mov rax, [esi+0x8] +** add rax, +0x01 +** mov [esi+0x10], rax +** +** Here's the transformed IR and the x86 machine code after the SPLIT pass: +** +** 0100 p32 ADD base +8 +** 0101 int XLOAD 0100 +** 0102 p32 ADD base +12 +** 0103 int XLOAD 0102 +** 0104 int ADD 0101 +1 +** 0105 int HIOP 0103 +0 +** 0106 p32 ADD base +16 +** 0107 int XSTORE 0106 0104 +** 0108 int HIOP 0106 0105 +** +** mov eax, [esi+0x8] +** mov ecx, [esi+0xc] +** add eax, +0x01 +** adc ecx, +0x00 +** mov [esi+0x10], eax +** mov [esi+0x14], ecx +** +** You may notice the reassociated hiword address computation, which is +** later fused into the mov operands by the assembler. +*/ + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) + +/* Directly emit the transformed IR without updating chains etc. */ +static IRRef split_emit(jit_State *J, uint16_t ot, IRRef1 op1, IRRef1 op2) +{ + IRRef nref = lj_ir_nextins(J); + IRIns *ir = IR(nref); + ir->ot = ot; + ir->op1 = op1; + ir->op2 = op2; + return nref; +} + +#if LJ_SOFTFP +/* Emit a (checked) number to integer conversion. */ +static IRRef split_num2int(jit_State *J, IRRef lo, IRRef hi, int check) +{ + IRRef tmp, res; +#if LJ_LE + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), lo, hi); +#else + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hi, lo); +#endif + res = split_emit(J, IRTI(IR_CALLN), tmp, IRCALL_softfp_d2i); + if (check) { + tmp = split_emit(J, IRTI(IR_CALLN), res, IRCALL_softfp_i2d); + split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); + split_emit(J, IRTGI(IR_EQ), tmp, lo); + split_emit(J, IRTG(IR_HIOP, IRT_SOFTFP), tmp+1, hi); + } + return res; +} + +/* Emit a CALLN with one split 64 bit argument. */ +static IRRef split_call_l(jit_State *J, IRRef1 *hisubst, IRIns *oir, + IRIns *ir, IRCallID id) +{ + IRRef tmp, op1 = ir->op1; + J->cur.nins--; +#if LJ_LE + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); +#else + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); +#endif + ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, id); + return split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); +} + +/* Emit a CALLN with one split 64 bit argument and a 32 bit argument. */ +static IRRef split_call_li(jit_State *J, IRRef1 *hisubst, IRIns *oir, + IRIns *ir, IRCallID id) +{ + IRRef tmp, op1 = ir->op1, op2 = ir->op2; + J->cur.nins--; +#if LJ_LE + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); +#else + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); +#endif + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, oir[op2].prev); + ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, id); + return split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); +} +#endif + +/* Emit a CALLN with two split 64 bit arguments. */ +static IRRef split_call_ll(jit_State *J, IRRef1 *hisubst, IRIns *oir, + IRIns *ir, IRCallID id) +{ + IRRef tmp, op1 = ir->op1, op2 = ir->op2; + J->cur.nins--; +#if LJ_LE + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, oir[op2].prev); + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, hisubst[op2]); +#else + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, hisubst[op2]); + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, oir[op2].prev); +#endif + ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, id); + return split_emit(J, + IRT(IR_HIOP, (LJ_SOFTFP && irt_isnum(ir->t)) ? IRT_SOFTFP : IRT_INT), + tmp, tmp); +} + +/* Get a pointer to the other 32 bit word (LE: hiword, BE: loword). */ +static IRRef split_ptr(jit_State *J, IRIns *oir, IRRef ref) +{ + IRRef nref = oir[ref].prev; + IRIns *ir = IR(nref); + int32_t ofs = 4; + if (ir->o == IR_KPTR) + return lj_ir_kptr(J, (char *)ir_kptr(ir) + ofs); + if (ir->o == IR_ADD && irref_isk(ir->op2) && !irt_isphi(oir[ref].t)) { + /* Reassociate address. */ + ofs += IR(ir->op2)->i; + nref = ir->op1; + if (ofs == 0) return nref; + } + return split_emit(J, IRTI(IR_ADD), nref, lj_ir_kint(J, ofs)); +} + +/* Substitute references of a snapshot. */ +static void split_subst_snap(jit_State *J, SnapShot *snap, IRIns *oir) +{ + SnapEntry *map = &J->cur.snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + IRIns *ir = &oir[snap_ref(sn)]; + if (!(LJ_SOFTFP && (sn & SNAP_SOFTFPNUM) && irref_isk(snap_ref(sn)))) + map[n] = ((sn & 0xffff0000) | ir->prev); + } +} + +/* Transform the old IR to the new IR. */ +static void split_ir(jit_State *J) +{ + IRRef nins = J->cur.nins, nk = J->cur.nk; + MSize irlen = nins - nk; + MSize need = (irlen+1)*(sizeof(IRIns) + sizeof(IRRef1)); + IRIns *oir = (IRIns *)lj_str_needbuf(J->L, &G(J->L)->tmpbuf, need); + IRRef1 *hisubst; + IRRef ref, snref; + SnapShot *snap; + + /* Copy old IR to buffer. */ + memcpy(oir, IR(nk), irlen*sizeof(IRIns)); + /* Bias hiword substitution table and old IR. Loword kept in field prev. */ + hisubst = (IRRef1 *)&oir[irlen] - nk; + oir -= nk; + + /* Remove all IR instructions, but retain IR constants. */ + J->cur.nins = REF_FIRST; + J->loopref = 0; + + /* Process constants and fixed references. */ + for (ref = nk; ref <= REF_BASE; ref++) { + IRIns *ir = &oir[ref]; + if ((LJ_SOFTFP && ir->o == IR_KNUM) || ir->o == IR_KINT64) { + /* Split up 64 bit constant. */ + TValue tv = *ir_k64(ir); + ir->prev = lj_ir_kint(J, (int32_t)tv.u32.lo); + hisubst[ref] = lj_ir_kint(J, (int32_t)tv.u32.hi); + } else { + ir->prev = ref; /* Identity substitution for loword. */ + hisubst[ref] = 0; + } + } + + /* Process old IR instructions. */ + snap = J->cur.snap; + snref = snap->ref; + for (ref = REF_FIRST; ref < nins; ref++) { + IRIns *ir = &oir[ref]; + IRRef nref = lj_ir_nextins(J); + IRIns *nir = IR(nref); + IRRef hi = 0; + + if (ref >= snref) { + snap->ref = nref; + split_subst_snap(J, snap++, oir); + snref = snap < &J->cur.snap[J->cur.nsnap] ? snap->ref : ~(IRRef)0; + } + + /* Copy-substitute old instruction to new instruction. */ + nir->op1 = ir->op1 < nk ? ir->op1 : oir[ir->op1].prev; + nir->op2 = ir->op2 < nk ? ir->op2 : oir[ir->op2].prev; + ir->prev = nref; /* Loword substitution. */ + nir->o = ir->o; + nir->t.irt = ir->t.irt & ~(IRT_MARK|IRT_ISPHI); + hisubst[ref] = 0; + + /* Split 64 bit instructions. */ +#if LJ_SOFTFP + if (irt_isnum(ir->t)) { + nir->t.irt = IRT_INT | (nir->t.irt & IRT_GUARD); /* Turn into INT op. */ + /* Note: hi ref = lo ref + 1! Required for SNAP_SOFTFPNUM logic. */ + switch (ir->o) { + case IR_ADD: + hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_add); + break; + case IR_SUB: + hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_sub); + break; + case IR_MUL: + hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_mul); + break; + case IR_DIV: + hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_div); + break; + case IR_POW: + hi = split_call_li(J, hisubst, oir, ir, IRCALL_lj_vm_powi); + break; + case IR_FPMATH: + /* Try to rejoin pow from EXP2, MUL and LOG2. */ + if (nir->op2 == IRFPM_EXP2 && nir->op1 > J->loopref) { + IRIns *irp = IR(nir->op1); + if (irp->o == IR_CALLN && irp->op2 == IRCALL_softfp_mul) { + IRIns *irm4 = IR(irp->op1); + IRIns *irm3 = IR(irm4->op1); + IRIns *irm12 = IR(irm3->op1); + IRIns *irl1 = IR(irm12->op1); + if (irm12->op1 > J->loopref && irl1->o == IR_CALLN && + irl1->op2 == IRCALL_lj_vm_log2) { + IRRef tmp = irl1->op1; /* Recycle first two args from LOG2. */ + IRRef arg3 = irm3->op2, arg4 = irm4->op2; + J->cur.nins--; + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, arg3); + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, arg4); + ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, IRCALL_pow); + hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); + break; + } + } + } + hi = split_call_l(J, hisubst, oir, ir, IRCALL_lj_vm_floor + ir->op2); + break; + case IR_ATAN2: + hi = split_call_ll(J, hisubst, oir, ir, IRCALL_atan2); + break; + case IR_LDEXP: + hi = split_call_li(J, hisubst, oir, ir, IRCALL_ldexp); + break; + case IR_NEG: case IR_ABS: + nir->o = IR_CONV; /* Pass through loword. */ + nir->op2 = (IRT_INT << 5) | IRT_INT; + hi = split_emit(J, IRT(ir->o == IR_NEG ? IR_BXOR : IR_BAND, IRT_SOFTFP), + hisubst[ir->op1], hisubst[ir->op2]); + break; + case IR_SLOAD: + if ((nir->op2 & IRSLOAD_CONVERT)) { /* Convert from int to number. */ + nir->op2 &= ~IRSLOAD_CONVERT; + ir->prev = nref = split_emit(J, IRTI(IR_CALLN), nref, + IRCALL_softfp_i2d); + hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); + break; + } + /* fallthrough */ + case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + case IR_STRTO: + hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); + break; + case IR_XLOAD: { + IRIns inslo = *nir; /* Save/undo the emit of the lo XLOAD. */ + J->cur.nins--; + hi = split_ptr(J, oir, ir->op1); /* Insert the hiref ADD. */ + nref = lj_ir_nextins(J); + nir = IR(nref); + *nir = inslo; /* Re-emit lo XLOAD immediately before hi XLOAD. */ + hi = split_emit(J, IRT(IR_XLOAD, IRT_SOFTFP), hi, ir->op2); +#if LJ_LE + ir->prev = nref; +#else + ir->prev = hi; hi = nref; +#endif + break; + } + case IR_ASTORE: case IR_HSTORE: case IR_USTORE: case IR_XSTORE: + split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nir->op1, hisubst[ir->op2]); + break; + case IR_CONV: { /* Conversion to number. Others handled below. */ + IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); + UNUSED(st); +#if LJ_32 && LJ_HASFFI + if (st == IRT_I64 || st == IRT_U64) { + hi = split_call_l(J, hisubst, oir, ir, + st == IRT_I64 ? IRCALL_fp64_l2d : IRCALL_fp64_ul2d); + break; + } +#endif + lua_assert(st == IRT_INT || + (LJ_32 && LJ_HASFFI && (st == IRT_U32 || st == IRT_FLOAT))); + nir->o = IR_CALLN; +#if LJ_32 && LJ_HASFFI + nir->op2 = st == IRT_INT ? IRCALL_softfp_i2d : + st == IRT_FLOAT ? IRCALL_softfp_f2d : + IRCALL_softfp_ui2d; +#else + nir->op2 = IRCALL_softfp_i2d; +#endif + hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); + break; + } + case IR_CALLN: + case IR_CALLL: + case IR_CALLS: + case IR_CALLXS: + goto split_call; + case IR_PHI: + if (nir->op1 == nir->op2) + J->cur.nins--; /* Drop useless PHIs. */ + if (hisubst[ir->op1] != hisubst[ir->op2]) + split_emit(J, IRT(IR_PHI, IRT_SOFTFP), + hisubst[ir->op1], hisubst[ir->op2]); + break; + case IR_HIOP: + J->cur.nins--; /* Drop joining HIOP. */ + ir->prev = nir->op1; + hi = nir->op2; + break; + default: + lua_assert(ir->o <= IR_NE || ir->o == IR_MIN || ir->o == IR_MAX); + hi = split_emit(J, IRTG(IR_HIOP, IRT_SOFTFP), + hisubst[ir->op1], hisubst[ir->op2]); + break; + } + } else +#endif +#if LJ_32 && LJ_HASFFI + if (irt_isint64(ir->t)) { + IRRef hiref = hisubst[ir->op1]; + nir->t.irt = IRT_INT | (nir->t.irt & IRT_GUARD); /* Turn into INT op. */ + switch (ir->o) { + case IR_ADD: + case IR_SUB: + /* Use plain op for hiword if loword cannot produce a carry/borrow. */ + if (irref_isk(nir->op2) && IR(nir->op2)->i == 0) { + ir->prev = nir->op1; /* Pass through loword. */ + nir->op1 = hiref; nir->op2 = hisubst[ir->op2]; + hi = nref; + break; + } + /* fallthrough */ + case IR_NEG: + hi = split_emit(J, IRTI(IR_HIOP), hiref, hisubst[ir->op2]); + break; + case IR_MUL: + hi = split_call_ll(J, hisubst, oir, ir, IRCALL_lj_carith_mul64); + break; + case IR_DIV: + hi = split_call_ll(J, hisubst, oir, ir, + irt_isi64(ir->t) ? IRCALL_lj_carith_divi64 : + IRCALL_lj_carith_divu64); + break; + case IR_MOD: + hi = split_call_ll(J, hisubst, oir, ir, + irt_isi64(ir->t) ? IRCALL_lj_carith_modi64 : + IRCALL_lj_carith_modu64); + break; + case IR_POW: + hi = split_call_ll(J, hisubst, oir, ir, + irt_isi64(ir->t) ? IRCALL_lj_carith_powi64 : + IRCALL_lj_carith_powu64); + break; + case IR_FLOAD: + lua_assert(ir->op2 == IRFL_CDATA_INT64); + hi = split_emit(J, IRTI(IR_FLOAD), nir->op1, IRFL_CDATA_INT64_4); +#if LJ_BE + ir->prev = hi; hi = nref; +#endif + break; + case IR_XLOAD: + hi = split_emit(J, IRTI(IR_XLOAD), split_ptr(J, oir, ir->op1), ir->op2); +#if LJ_BE + ir->prev = hi; hi = nref; +#endif + break; + case IR_XSTORE: + split_emit(J, IRTI(IR_HIOP), nir->op1, hisubst[ir->op2]); + break; + case IR_CONV: { /* Conversion to 64 bit integer. Others handled below. */ + IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); +#if LJ_SOFTFP + if (st == IRT_NUM) { /* NUM to 64 bit int conv. */ + hi = split_call_l(J, hisubst, oir, ir, + irt_isi64(ir->t) ? IRCALL_fp64_d2l : IRCALL_fp64_d2ul); + } else if (st == IRT_FLOAT) { /* FLOAT to 64 bit int conv. */ + nir->o = IR_CALLN; + nir->op2 = irt_isi64(ir->t) ? IRCALL_fp64_f2l : IRCALL_fp64_f2ul; + hi = split_emit(J, IRTI(IR_HIOP), nref, nref); + } +#else + if (st == IRT_NUM || st == IRT_FLOAT) { /* FP to 64 bit int conv. */ + hi = split_emit(J, IRTI(IR_HIOP), nir->op1, nref); + } +#endif + else if (st == IRT_I64 || st == IRT_U64) { /* 64/64 bit cast. */ + /* Drop cast, since assembler doesn't care. But fwd both parts. */ + hi = hiref; + goto fwdlo; + } else if ((ir->op2 & IRCONV_SEXT)) { /* Sign-extend to 64 bit. */ + IRRef k31 = lj_ir_kint(J, 31); + nir = IR(nref); /* May have been reallocated. */ + ir->prev = nir->op1; /* Pass through loword. */ + nir->o = IR_BSAR; /* hi = bsar(lo, 31). */ + nir->op2 = k31; + hi = nref; + } else { /* Zero-extend to 64 bit. */ + hi = lj_ir_kint(J, 0); + goto fwdlo; + } + break; + } + case IR_CALLXS: + goto split_call; + case IR_PHI: { + IRRef hiref2; + if ((irref_isk(nir->op1) && irref_isk(nir->op2)) || + nir->op1 == nir->op2) + J->cur.nins--; /* Drop useless PHIs. */ + hiref2 = hisubst[ir->op2]; + if (!((irref_isk(hiref) && irref_isk(hiref2)) || hiref == hiref2)) + split_emit(J, IRTI(IR_PHI), hiref, hiref2); + break; + } + case IR_HIOP: + J->cur.nins--; /* Drop joining HIOP. */ + ir->prev = nir->op1; + hi = nir->op2; + break; + default: + lua_assert(ir->o <= IR_NE); /* Comparisons. */ + split_emit(J, IRTGI(IR_HIOP), hiref, hisubst[ir->op2]); + break; + } + } else +#endif +#if LJ_SOFTFP + if (ir->o == IR_SLOAD) { + if ((nir->op2 & IRSLOAD_CONVERT)) { /* Convert from number to int. */ + nir->op2 &= ~IRSLOAD_CONVERT; + if (!(nir->op2 & IRSLOAD_TYPECHECK)) + nir->t.irt = IRT_INT; /* Drop guard. */ + split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); + ir->prev = split_num2int(J, nref, nref+1, irt_isguard(ir->t)); + } + } else if (ir->o == IR_TOBIT) { + IRRef tmp, op1 = ir->op1; + J->cur.nins--; +#if LJ_LE + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); +#else + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); +#endif + ir->prev = split_emit(J, IRTI(IR_CALLN), tmp, IRCALL_lj_vm_tobit); + } else if (ir->o == IR_TOSTR) { + if (hisubst[ir->op1]) { + if (irref_isk(ir->op1)) + nir->op1 = ir->op1; + else + split_emit(J, IRT(IR_HIOP, IRT_NIL), hisubst[ir->op1], nref); + } + } else if (ir->o == IR_HREF || ir->o == IR_NEWREF) { + if (irref_isk(ir->op2) && hisubst[ir->op2]) + nir->op2 = ir->op2; + } else +#endif + if (ir->o == IR_CONV) { /* See above, too. */ + IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); +#if LJ_32 && LJ_HASFFI + if (st == IRT_I64 || st == IRT_U64) { /* Conversion from 64 bit int. */ +#if LJ_SOFTFP + if (irt_isfloat(ir->t)) { + split_call_l(J, hisubst, oir, ir, + st == IRT_I64 ? IRCALL_fp64_l2f : IRCALL_fp64_ul2f); + J->cur.nins--; /* Drop unused HIOP. */ + } +#else + if (irt_isfp(ir->t)) { /* 64 bit integer to FP conversion. */ + ir->prev = split_emit(J, IRT(IR_HIOP, irt_type(ir->t)), + hisubst[ir->op1], nref); + } +#endif + else { /* Truncate to lower 32 bits. */ + fwdlo: + ir->prev = nir->op1; /* Forward loword. */ + /* Replace with NOP to avoid messing up the snapshot logic. */ + nir->ot = IRT(IR_NOP, IRT_NIL); + nir->op1 = nir->op2 = 0; + } + } +#endif +#if LJ_SOFTFP && LJ_32 && LJ_HASFFI + else if (irt_isfloat(ir->t)) { + if (st == IRT_NUM) { + split_call_l(J, hisubst, oir, ir, IRCALL_softfp_d2f); + J->cur.nins--; /* Drop unused HIOP. */ + } else { + nir->o = IR_CALLN; + nir->op2 = st == IRT_INT ? IRCALL_softfp_i2f : IRCALL_softfp_ui2f; + } + } else if (st == IRT_FLOAT) { + nir->o = IR_CALLN; + nir->op2 = irt_isint(ir->t) ? IRCALL_softfp_f2i : IRCALL_softfp_f2ui; + } else +#endif +#if LJ_SOFTFP + if (st == IRT_NUM || (LJ_32 && LJ_HASFFI && st == IRT_FLOAT)) { + if (irt_isguard(ir->t)) { + lua_assert(st == IRT_NUM && irt_isint(ir->t)); + J->cur.nins--; + ir->prev = split_num2int(J, nir->op1, hisubst[ir->op1], 1); + } else { + split_call_l(J, hisubst, oir, ir, +#if LJ_32 && LJ_HASFFI + st == IRT_NUM ? + (irt_isint(ir->t) ? IRCALL_softfp_d2i : IRCALL_softfp_d2ui) : + (irt_isint(ir->t) ? IRCALL_softfp_f2i : IRCALL_softfp_f2ui) +#else + IRCALL_softfp_d2i +#endif + ); + J->cur.nins--; /* Drop unused HIOP. */ + } + } +#endif + } else if (ir->o == IR_CALLXS) { + IRRef hiref; + split_call: + hiref = hisubst[ir->op1]; + if (hiref) { + IROpT ot = nir->ot; + IRRef op2 = nir->op2; + nir->ot = IRT(IR_CARG, IRT_NIL); +#if LJ_LE + nir->op2 = hiref; +#else + nir->op2 = nir->op1; nir->op1 = hiref; +#endif + ir->prev = nref = split_emit(J, ot, nref, op2); + } + if (LJ_SOFTFP ? irt_is64(ir->t) : irt_isint64(ir->t)) + hi = split_emit(J, + IRT(IR_HIOP, (LJ_SOFTFP && irt_isnum(ir->t)) ? IRT_SOFTFP : IRT_INT), + nref, nref); + } else if (ir->o == IR_CARG) { + IRRef hiref = hisubst[ir->op1]; + if (hiref) { + IRRef op2 = nir->op2; +#if LJ_LE + nir->op2 = hiref; +#else + nir->op2 = nir->op1; nir->op1 = hiref; +#endif + ir->prev = nref = split_emit(J, IRT(IR_CARG, IRT_NIL), nref, op2); + nir = IR(nref); + } + hiref = hisubst[ir->op2]; + if (hiref) { +#if !LJ_TARGET_X86 + int carg = 0; + IRIns *cir; + for (cir = IR(nir->op1); cir->o == IR_CARG; cir = IR(cir->op1)) + carg++; + if ((carg & 1) == 0) { /* Align 64 bit arguments. */ + IRRef op2 = nir->op2; + nir->op2 = REF_NIL; + nref = split_emit(J, IRT(IR_CARG, IRT_NIL), nref, op2); + nir = IR(nref); + } +#endif +#if LJ_BE + { IRRef tmp = nir->op2; nir->op2 = hiref; hiref = tmp; } +#endif + ir->prev = split_emit(J, IRT(IR_CARG, IRT_NIL), nref, hiref); + } + } else if (ir->o == IR_CNEWI) { + if (hisubst[ir->op2]) + split_emit(J, IRT(IR_HIOP, IRT_NIL), nref, hisubst[ir->op2]); + } else if (ir->o == IR_LOOP) { + J->loopref = nref; /* Needed by assembler. */ + } + hisubst[ref] = hi; /* Store hiword substitution. */ + } + if (snref == nins) { /* Substitution for last snapshot. */ + snap->ref = J->cur.nins; + split_subst_snap(J, snap, oir); + } + + /* Add PHI marks. */ + for (ref = J->cur.nins-1; ref >= REF_FIRST; ref--) { + IRIns *ir = IR(ref); + if (ir->o != IR_PHI) break; + if (!irref_isk(ir->op1)) irt_setphi(IR(ir->op1)->t); + if (ir->op2 > J->loopref) irt_setphi(IR(ir->op2)->t); + } +} + +/* Protected callback for split pass. */ +static TValue *cpsplit(lua_State *L, lua_CFunction dummy, void *ud) +{ + jit_State *J = (jit_State *)ud; + split_ir(J); + UNUSED(L); UNUSED(dummy); + return NULL; +} + +#if defined(LUA_USE_ASSERT) || LJ_SOFTFP +/* Slow, but sure way to check whether a SPLIT pass is needed. */ +static int split_needsplit(jit_State *J) +{ + IRIns *ir, *irend; + IRRef ref; + for (ir = IR(REF_FIRST), irend = IR(J->cur.nins); ir < irend; ir++) + if (LJ_SOFTFP ? irt_is64orfp(ir->t) : irt_isint64(ir->t)) + return 1; + if (LJ_SOFTFP) { + for (ref = J->chain[IR_SLOAD]; ref; ref = IR(ref)->prev) + if ((IR(ref)->op2 & IRSLOAD_CONVERT)) + return 1; + if (J->chain[IR_TOBIT]) + return 1; + } + for (ref = J->chain[IR_CONV]; ref; ref = IR(ref)->prev) { + IRType st = (IR(ref)->op2 & IRCONV_SRCMASK); + if ((LJ_SOFTFP && (st == IRT_NUM || st == IRT_FLOAT)) || + st == IRT_I64 || st == IRT_U64) + return 1; + } + return 0; /* Nope. */ +} +#endif + +/* SPLIT pass. */ +void lj_opt_split(jit_State *J) +{ +#if LJ_SOFTFP + if (!J->needsplit) + J->needsplit = split_needsplit(J); +#else + lua_assert(J->needsplit >= split_needsplit(J)); /* Verify flag. */ +#endif + if (J->needsplit) { + int errcode = lj_vm_cpcall(J->L, NULL, J, cpsplit); + if (errcode) { + /* Completely reset the trace to avoid inconsistent dump on abort. */ + J->cur.nins = J->cur.nk = REF_BASE; + J->cur.nsnap = 0; + lj_err_throw(J->L, errcode); /* Propagate errors. */ + } + } +} + +#undef IR + +#endif + +``` + +`include/luajit-2.0.5/src/lj_parse.c`: + +```c +/* +** Lua parser (source code -> bytecode). +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_parse_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_func.h" +#include "lj_state.h" +#include "lj_bc.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#endif +#include "lj_lex.h" +#include "lj_parse.h" +#include "lj_vm.h" +#include "lj_vmevent.h" + +/* -- Parser structures and definitions ----------------------------------- */ + +/* Expression kinds. */ +typedef enum { + /* Constant expressions must be first and in this order: */ + VKNIL, + VKFALSE, + VKTRUE, + VKSTR, /* sval = string value */ + VKNUM, /* nval = number value */ + VKLAST = VKNUM, + VKCDATA, /* nval = cdata value, not treated as a constant expression */ + /* Non-constant expressions follow: */ + VLOCAL, /* info = local register, aux = vstack index */ + VUPVAL, /* info = upvalue index, aux = vstack index */ + VGLOBAL, /* sval = string value */ + VINDEXED, /* info = table register, aux = index reg/byte/string const */ + VJMP, /* info = instruction PC */ + VRELOCABLE, /* info = instruction PC */ + VNONRELOC, /* info = result register */ + VCALL, /* info = instruction PC, aux = base */ + VVOID +} ExpKind; + +/* Expression descriptor. */ +typedef struct ExpDesc { + union { + struct { + uint32_t info; /* Primary info. */ + uint32_t aux; /* Secondary info. */ + } s; + TValue nval; /* Number value. */ + GCstr *sval; /* String value. */ + } u; + ExpKind k; + BCPos t; /* True condition jump list. */ + BCPos f; /* False condition jump list. */ +} ExpDesc; + +/* Macros for expressions. */ +#define expr_hasjump(e) ((e)->t != (e)->f) + +#define expr_isk(e) ((e)->k <= VKLAST) +#define expr_isk_nojump(e) (expr_isk(e) && !expr_hasjump(e)) +#define expr_isnumk(e) ((e)->k == VKNUM) +#define expr_isnumk_nojump(e) (expr_isnumk(e) && !expr_hasjump(e)) +#define expr_isstrk(e) ((e)->k == VKSTR) + +#define expr_numtv(e) check_exp(expr_isnumk((e)), &(e)->u.nval) +#define expr_numberV(e) numberVnum(expr_numtv((e))) + +/* Initialize expression. */ +static LJ_AINLINE void expr_init(ExpDesc *e, ExpKind k, uint32_t info) +{ + e->k = k; + e->u.s.info = info; + e->f = e->t = NO_JMP; +} + +/* Check number constant for +-0. */ +static int expr_numiszero(ExpDesc *e) +{ + TValue *o = expr_numtv(e); + return tvisint(o) ? (intV(o) == 0) : tviszero(o); +} + +/* Per-function linked list of scope blocks. */ +typedef struct FuncScope { + struct FuncScope *prev; /* Link to outer scope. */ + MSize vstart; /* Start of block-local variables. */ + uint8_t nactvar; /* Number of active vars outside the scope. */ + uint8_t flags; /* Scope flags. */ +} FuncScope; + +#define FSCOPE_LOOP 0x01 /* Scope is a (breakable) loop. */ +#define FSCOPE_BREAK 0x02 /* Break used in scope. */ +#define FSCOPE_GOLA 0x04 /* Goto or label used in scope. */ +#define FSCOPE_UPVAL 0x08 /* Upvalue in scope. */ +#define FSCOPE_NOCLOSE 0x10 /* Do not close upvalues. */ + +#define NAME_BREAK ((GCstr *)(uintptr_t)1) + +/* Index into variable stack. */ +typedef uint16_t VarIndex; +#define LJ_MAX_VSTACK (65536 - LJ_MAX_UPVAL) + +/* Variable/goto/label info. */ +#define VSTACK_VAR_RW 0x01 /* R/W variable. */ +#define VSTACK_GOTO 0x02 /* Pending goto. */ +#define VSTACK_LABEL 0x04 /* Label. */ + +/* Per-function state. */ +typedef struct FuncState { + GCtab *kt; /* Hash table for constants. */ + LexState *ls; /* Lexer state. */ + lua_State *L; /* Lua state. */ + FuncScope *bl; /* Current scope. */ + struct FuncState *prev; /* Enclosing function. */ + BCPos pc; /* Next bytecode position. */ + BCPos lasttarget; /* Bytecode position of last jump target. */ + BCPos jpc; /* Pending jump list to next bytecode. */ + BCReg freereg; /* First free register. */ + BCReg nactvar; /* Number of active local variables. */ + BCReg nkn, nkgc; /* Number of lua_Number/GCobj constants */ + BCLine linedefined; /* First line of the function definition. */ + BCInsLine *bcbase; /* Base of bytecode stack. */ + BCPos bclim; /* Limit of bytecode stack. */ + MSize vbase; /* Base of variable stack for this function. */ + uint8_t flags; /* Prototype flags. */ + uint8_t numparams; /* Number of parameters. */ + uint8_t framesize; /* Fixed frame size. */ + uint8_t nuv; /* Number of upvalues */ + VarIndex varmap[LJ_MAX_LOCVAR]; /* Map from register to variable idx. */ + VarIndex uvmap[LJ_MAX_UPVAL]; /* Map from upvalue to variable idx. */ + VarIndex uvtmp[LJ_MAX_UPVAL]; /* Temporary upvalue map. */ +} FuncState; + +/* Binary and unary operators. ORDER OPR */ +typedef enum BinOpr { + OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, /* ORDER ARITH */ + OPR_CONCAT, + OPR_NE, OPR_EQ, + OPR_LT, OPR_GE, OPR_LE, OPR_GT, + OPR_AND, OPR_OR, + OPR_NOBINOPR +} BinOpr; + +LJ_STATIC_ASSERT((int)BC_ISGE-(int)BC_ISLT == (int)OPR_GE-(int)OPR_LT); +LJ_STATIC_ASSERT((int)BC_ISLE-(int)BC_ISLT == (int)OPR_LE-(int)OPR_LT); +LJ_STATIC_ASSERT((int)BC_ISGT-(int)BC_ISLT == (int)OPR_GT-(int)OPR_LT); +LJ_STATIC_ASSERT((int)BC_SUBVV-(int)BC_ADDVV == (int)OPR_SUB-(int)OPR_ADD); +LJ_STATIC_ASSERT((int)BC_MULVV-(int)BC_ADDVV == (int)OPR_MUL-(int)OPR_ADD); +LJ_STATIC_ASSERT((int)BC_DIVVV-(int)BC_ADDVV == (int)OPR_DIV-(int)OPR_ADD); +LJ_STATIC_ASSERT((int)BC_MODVV-(int)BC_ADDVV == (int)OPR_MOD-(int)OPR_ADD); + +/* -- Error handling ------------------------------------------------------ */ + +LJ_NORET LJ_NOINLINE static void err_syntax(LexState *ls, ErrMsg em) +{ + lj_lex_error(ls, ls->token, em); +} + +LJ_NORET LJ_NOINLINE static void err_token(LexState *ls, LexToken token) +{ + lj_lex_error(ls, ls->token, LJ_ERR_XTOKEN, lj_lex_token2str(ls, token)); +} + +LJ_NORET static void err_limit(FuncState *fs, uint32_t limit, const char *what) +{ + if (fs->linedefined == 0) + lj_lex_error(fs->ls, 0, LJ_ERR_XLIMM, limit, what); + else + lj_lex_error(fs->ls, 0, LJ_ERR_XLIMF, fs->linedefined, limit, what); +} + +#define checklimit(fs, v, l, m) if ((v) >= (l)) err_limit(fs, l, m) +#define checklimitgt(fs, v, l, m) if ((v) > (l)) err_limit(fs, l, m) +#define checkcond(ls, c, em) { if (!(c)) err_syntax(ls, em); } + +/* -- Management of constants --------------------------------------------- */ + +/* Return bytecode encoding for primitive constant. */ +#define const_pri(e) check_exp((e)->k <= VKTRUE, (e)->k) + +#define tvhaskslot(o) ((o)->u32.hi == 0) +#define tvkslot(o) ((o)->u32.lo) + +/* Add a number constant. */ +static BCReg const_num(FuncState *fs, ExpDesc *e) +{ + lua_State *L = fs->L; + TValue *o; + lua_assert(expr_isnumk(e)); + o = lj_tab_set(L, fs->kt, &e->u.nval); + if (tvhaskslot(o)) + return tvkslot(o); + o->u64 = fs->nkn; + return fs->nkn++; +} + +/* Add a GC object constant. */ +static BCReg const_gc(FuncState *fs, GCobj *gc, uint32_t itype) +{ + lua_State *L = fs->L; + TValue key, *o; + setgcV(L, &key, gc, itype); + /* NOBARRIER: the key is new or kept alive. */ + o = lj_tab_set(L, fs->kt, &key); + if (tvhaskslot(o)) + return tvkslot(o); + o->u64 = fs->nkgc; + return fs->nkgc++; +} + +/* Add a string constant. */ +static BCReg const_str(FuncState *fs, ExpDesc *e) +{ + lua_assert(expr_isstrk(e) || e->k == VGLOBAL); + return const_gc(fs, obj2gco(e->u.sval), LJ_TSTR); +} + +/* Anchor string constant to avoid GC. */ +GCstr *lj_parse_keepstr(LexState *ls, const char *str, size_t len) +{ + /* NOBARRIER: the key is new or kept alive. */ + lua_State *L = ls->L; + GCstr *s = lj_str_new(L, str, len); + TValue *tv = lj_tab_setstr(L, ls->fs->kt, s); + if (tvisnil(tv)) setboolV(tv, 1); + lj_gc_check(L); + return s; +} + +#if LJ_HASFFI +/* Anchor cdata to avoid GC. */ +void lj_parse_keepcdata(LexState *ls, TValue *tv, GCcdata *cd) +{ + /* NOBARRIER: the key is new or kept alive. */ + lua_State *L = ls->L; + setcdataV(L, tv, cd); + setboolV(lj_tab_set(L, ls->fs->kt, tv), 1); +} +#endif + +/* -- Jump list handling -------------------------------------------------- */ + +/* Get next element in jump list. */ +static BCPos jmp_next(FuncState *fs, BCPos pc) +{ + ptrdiff_t delta = bc_j(fs->bcbase[pc].ins); + if ((BCPos)delta == NO_JMP) + return NO_JMP; + else + return (BCPos)(((ptrdiff_t)pc+1)+delta); +} + +/* Check if any of the instructions on the jump list produce no value. */ +static int jmp_novalue(FuncState *fs, BCPos list) +{ + for (; list != NO_JMP; list = jmp_next(fs, list)) { + BCIns p = fs->bcbase[list >= 1 ? list-1 : list].ins; + if (!(bc_op(p) == BC_ISTC || bc_op(p) == BC_ISFC || bc_a(p) == NO_REG)) + return 1; + } + return 0; +} + +/* Patch register of test instructions. */ +static int jmp_patchtestreg(FuncState *fs, BCPos pc, BCReg reg) +{ + BCInsLine *ilp = &fs->bcbase[pc >= 1 ? pc-1 : pc]; + BCOp op = bc_op(ilp->ins); + if (op == BC_ISTC || op == BC_ISFC) { + if (reg != NO_REG && reg != bc_d(ilp->ins)) { + setbc_a(&ilp->ins, reg); + } else { /* Nothing to store or already in the right register. */ + setbc_op(&ilp->ins, op+(BC_IST-BC_ISTC)); + setbc_a(&ilp->ins, 0); + } + } else if (bc_a(ilp->ins) == NO_REG) { + if (reg == NO_REG) { + ilp->ins = BCINS_AJ(BC_JMP, bc_a(fs->bcbase[pc].ins), 0); + } else { + setbc_a(&ilp->ins, reg); + if (reg >= bc_a(ilp[1].ins)) + setbc_a(&ilp[1].ins, reg+1); + } + } else { + return 0; /* Cannot patch other instructions. */ + } + return 1; +} + +/* Drop values for all instructions on jump list. */ +static void jmp_dropval(FuncState *fs, BCPos list) +{ + for (; list != NO_JMP; list = jmp_next(fs, list)) + jmp_patchtestreg(fs, list, NO_REG); +} + +/* Patch jump instruction to target. */ +static void jmp_patchins(FuncState *fs, BCPos pc, BCPos dest) +{ + BCIns *jmp = &fs->bcbase[pc].ins; + BCPos offset = dest-(pc+1)+BCBIAS_J; + lua_assert(dest != NO_JMP); + if (offset > BCMAX_D) + err_syntax(fs->ls, LJ_ERR_XJUMP); + setbc_d(jmp, offset); +} + +/* Append to jump list. */ +static void jmp_append(FuncState *fs, BCPos *l1, BCPos l2) +{ + if (l2 == NO_JMP) { + return; + } else if (*l1 == NO_JMP) { + *l1 = l2; + } else { + BCPos list = *l1; + BCPos next; + while ((next = jmp_next(fs, list)) != NO_JMP) /* Find last element. */ + list = next; + jmp_patchins(fs, list, l2); + } +} + +/* Patch jump list and preserve produced values. */ +static void jmp_patchval(FuncState *fs, BCPos list, BCPos vtarget, + BCReg reg, BCPos dtarget) +{ + while (list != NO_JMP) { + BCPos next = jmp_next(fs, list); + if (jmp_patchtestreg(fs, list, reg)) + jmp_patchins(fs, list, vtarget); /* Jump to target with value. */ + else + jmp_patchins(fs, list, dtarget); /* Jump to default target. */ + list = next; + } +} + +/* Jump to following instruction. Append to list of pending jumps. */ +static void jmp_tohere(FuncState *fs, BCPos list) +{ + fs->lasttarget = fs->pc; + jmp_append(fs, &fs->jpc, list); +} + +/* Patch jump list to target. */ +static void jmp_patch(FuncState *fs, BCPos list, BCPos target) +{ + if (target == fs->pc) { + jmp_tohere(fs, list); + } else { + lua_assert(target < fs->pc); + jmp_patchval(fs, list, target, NO_REG, target); + } +} + +/* -- Bytecode register allocator ----------------------------------------- */ + +/* Bump frame size. */ +static void bcreg_bump(FuncState *fs, BCReg n) +{ + BCReg sz = fs->freereg + n; + if (sz > fs->framesize) { + if (sz >= LJ_MAX_SLOTS) + err_syntax(fs->ls, LJ_ERR_XSLOTS); + fs->framesize = (uint8_t)sz; + } +} + +/* Reserve registers. */ +static void bcreg_reserve(FuncState *fs, BCReg n) +{ + bcreg_bump(fs, n); + fs->freereg += n; +} + +/* Free register. */ +static void bcreg_free(FuncState *fs, BCReg reg) +{ + if (reg >= fs->nactvar) { + fs->freereg--; + lua_assert(reg == fs->freereg); + } +} + +/* Free register for expression. */ +static void expr_free(FuncState *fs, ExpDesc *e) +{ + if (e->k == VNONRELOC) + bcreg_free(fs, e->u.s.info); +} + +/* -- Bytecode emitter ---------------------------------------------------- */ + +/* Emit bytecode instruction. */ +static BCPos bcemit_INS(FuncState *fs, BCIns ins) +{ + BCPos pc = fs->pc; + LexState *ls = fs->ls; + jmp_patchval(fs, fs->jpc, pc, NO_REG, pc); + fs->jpc = NO_JMP; + if (LJ_UNLIKELY(pc >= fs->bclim)) { + ptrdiff_t base = fs->bcbase - ls->bcstack; + checklimit(fs, ls->sizebcstack, LJ_MAX_BCINS, "bytecode instructions"); + lj_mem_growvec(fs->L, ls->bcstack, ls->sizebcstack, LJ_MAX_BCINS,BCInsLine); + fs->bclim = (BCPos)(ls->sizebcstack - base); + fs->bcbase = ls->bcstack + base; + } + fs->bcbase[pc].ins = ins; + fs->bcbase[pc].line = ls->lastline; + fs->pc = pc+1; + return pc; +} + +#define bcemit_ABC(fs, o, a, b, c) bcemit_INS(fs, BCINS_ABC(o, a, b, c)) +#define bcemit_AD(fs, o, a, d) bcemit_INS(fs, BCINS_AD(o, a, d)) +#define bcemit_AJ(fs, o, a, j) bcemit_INS(fs, BCINS_AJ(o, a, j)) + +#define bcptr(fs, e) (&(fs)->bcbase[(e)->u.s.info].ins) + +/* -- Bytecode emitter for expressions ------------------------------------ */ + +/* Discharge non-constant expression to any register. */ +static void expr_discharge(FuncState *fs, ExpDesc *e) +{ + BCIns ins; + if (e->k == VUPVAL) { + ins = BCINS_AD(BC_UGET, 0, e->u.s.info); + } else if (e->k == VGLOBAL) { + ins = BCINS_AD(BC_GGET, 0, const_str(fs, e)); + } else if (e->k == VINDEXED) { + BCReg rc = e->u.s.aux; + if ((int32_t)rc < 0) { + ins = BCINS_ABC(BC_TGETS, 0, e->u.s.info, ~rc); + } else if (rc > BCMAX_C) { + ins = BCINS_ABC(BC_TGETB, 0, e->u.s.info, rc-(BCMAX_C+1)); + } else { + bcreg_free(fs, rc); + ins = BCINS_ABC(BC_TGETV, 0, e->u.s.info, rc); + } + bcreg_free(fs, e->u.s.info); + } else if (e->k == VCALL) { + e->u.s.info = e->u.s.aux; + e->k = VNONRELOC; + return; + } else if (e->k == VLOCAL) { + e->k = VNONRELOC; + return; + } else { + return; + } + e->u.s.info = bcemit_INS(fs, ins); + e->k = VRELOCABLE; +} + +/* Emit bytecode to set a range of registers to nil. */ +static void bcemit_nil(FuncState *fs, BCReg from, BCReg n) +{ + if (fs->pc > fs->lasttarget) { /* No jumps to current position? */ + BCIns *ip = &fs->bcbase[fs->pc-1].ins; + BCReg pto, pfrom = bc_a(*ip); + switch (bc_op(*ip)) { /* Try to merge with the previous instruction. */ + case BC_KPRI: + if (bc_d(*ip) != ~LJ_TNIL) break; + if (from == pfrom) { + if (n == 1) return; + } else if (from == pfrom+1) { + from = pfrom; + n++; + } else { + break; + } + *ip = BCINS_AD(BC_KNIL, from, from+n-1); /* Replace KPRI. */ + return; + case BC_KNIL: + pto = bc_d(*ip); + if (pfrom <= from && from <= pto+1) { /* Can we connect both ranges? */ + if (from+n-1 > pto) + setbc_d(ip, from+n-1); /* Patch previous instruction range. */ + return; + } + break; + default: + break; + } + } + /* Emit new instruction or replace old instruction. */ + bcemit_INS(fs, n == 1 ? BCINS_AD(BC_KPRI, from, VKNIL) : + BCINS_AD(BC_KNIL, from, from+n-1)); +} + +/* Discharge an expression to a specific register. Ignore branches. */ +static void expr_toreg_nobranch(FuncState *fs, ExpDesc *e, BCReg reg) +{ + BCIns ins; + expr_discharge(fs, e); + if (e->k == VKSTR) { + ins = BCINS_AD(BC_KSTR, reg, const_str(fs, e)); + } else if (e->k == VKNUM) { +#if LJ_DUALNUM + cTValue *tv = expr_numtv(e); + if (tvisint(tv) && checki16(intV(tv))) + ins = BCINS_AD(BC_KSHORT, reg, (BCReg)(uint16_t)intV(tv)); + else +#else + lua_Number n = expr_numberV(e); + int32_t k = lj_num2int(n); + if (checki16(k) && n == (lua_Number)k) + ins = BCINS_AD(BC_KSHORT, reg, (BCReg)(uint16_t)k); + else +#endif + ins = BCINS_AD(BC_KNUM, reg, const_num(fs, e)); +#if LJ_HASFFI + } else if (e->k == VKCDATA) { + fs->flags |= PROTO_FFI; + ins = BCINS_AD(BC_KCDATA, reg, + const_gc(fs, obj2gco(cdataV(&e->u.nval)), LJ_TCDATA)); +#endif + } else if (e->k == VRELOCABLE) { + setbc_a(bcptr(fs, e), reg); + goto noins; + } else if (e->k == VNONRELOC) { + if (reg == e->u.s.info) + goto noins; + ins = BCINS_AD(BC_MOV, reg, e->u.s.info); + } else if (e->k == VKNIL) { + bcemit_nil(fs, reg, 1); + goto noins; + } else if (e->k <= VKTRUE) { + ins = BCINS_AD(BC_KPRI, reg, const_pri(e)); + } else { + lua_assert(e->k == VVOID || e->k == VJMP); + return; + } + bcemit_INS(fs, ins); +noins: + e->u.s.info = reg; + e->k = VNONRELOC; +} + +/* Forward declaration. */ +static BCPos bcemit_jmp(FuncState *fs); + +/* Discharge an expression to a specific register. */ +static void expr_toreg(FuncState *fs, ExpDesc *e, BCReg reg) +{ + expr_toreg_nobranch(fs, e, reg); + if (e->k == VJMP) + jmp_append(fs, &e->t, e->u.s.info); /* Add it to the true jump list. */ + if (expr_hasjump(e)) { /* Discharge expression with branches. */ + BCPos jend, jfalse = NO_JMP, jtrue = NO_JMP; + if (jmp_novalue(fs, e->t) || jmp_novalue(fs, e->f)) { + BCPos jval = (e->k == VJMP) ? NO_JMP : bcemit_jmp(fs); + jfalse = bcemit_AD(fs, BC_KPRI, reg, VKFALSE); + bcemit_AJ(fs, BC_JMP, fs->freereg, 1); + jtrue = bcemit_AD(fs, BC_KPRI, reg, VKTRUE); + jmp_tohere(fs, jval); + } + jend = fs->pc; + fs->lasttarget = jend; + jmp_patchval(fs, e->f, jend, reg, jfalse); + jmp_patchval(fs, e->t, jend, reg, jtrue); + } + e->f = e->t = NO_JMP; + e->u.s.info = reg; + e->k = VNONRELOC; +} + +/* Discharge an expression to the next free register. */ +static void expr_tonextreg(FuncState *fs, ExpDesc *e) +{ + expr_discharge(fs, e); + expr_free(fs, e); + bcreg_reserve(fs, 1); + expr_toreg(fs, e, fs->freereg - 1); +} + +/* Discharge an expression to any register. */ +static BCReg expr_toanyreg(FuncState *fs, ExpDesc *e) +{ + expr_discharge(fs, e); + if (e->k == VNONRELOC) { + if (!expr_hasjump(e)) return e->u.s.info; /* Already in a register. */ + if (e->u.s.info >= fs->nactvar) { + expr_toreg(fs, e, e->u.s.info); /* Discharge to temp. register. */ + return e->u.s.info; + } + } + expr_tonextreg(fs, e); /* Discharge to next register. */ + return e->u.s.info; +} + +/* Partially discharge expression to a value. */ +static void expr_toval(FuncState *fs, ExpDesc *e) +{ + if (expr_hasjump(e)) + expr_toanyreg(fs, e); + else + expr_discharge(fs, e); +} + +/* Emit store for LHS expression. */ +static void bcemit_store(FuncState *fs, ExpDesc *var, ExpDesc *e) +{ + BCIns ins; + if (var->k == VLOCAL) { + fs->ls->vstack[var->u.s.aux].info |= VSTACK_VAR_RW; + expr_free(fs, e); + expr_toreg(fs, e, var->u.s.info); + return; + } else if (var->k == VUPVAL) { + fs->ls->vstack[var->u.s.aux].info |= VSTACK_VAR_RW; + expr_toval(fs, e); + if (e->k <= VKTRUE) + ins = BCINS_AD(BC_USETP, var->u.s.info, const_pri(e)); + else if (e->k == VKSTR) + ins = BCINS_AD(BC_USETS, var->u.s.info, const_str(fs, e)); + else if (e->k == VKNUM) + ins = BCINS_AD(BC_USETN, var->u.s.info, const_num(fs, e)); + else + ins = BCINS_AD(BC_USETV, var->u.s.info, expr_toanyreg(fs, e)); + } else if (var->k == VGLOBAL) { + BCReg ra = expr_toanyreg(fs, e); + ins = BCINS_AD(BC_GSET, ra, const_str(fs, var)); + } else { + BCReg ra, rc; + lua_assert(var->k == VINDEXED); + ra = expr_toanyreg(fs, e); + rc = var->u.s.aux; + if ((int32_t)rc < 0) { + ins = BCINS_ABC(BC_TSETS, ra, var->u.s.info, ~rc); + } else if (rc > BCMAX_C) { + ins = BCINS_ABC(BC_TSETB, ra, var->u.s.info, rc-(BCMAX_C+1)); + } else { + /* Free late alloced key reg to avoid assert on free of value reg. */ + /* This can only happen when called from expr_table(). */ + lua_assert(e->k != VNONRELOC || ra < fs->nactvar || + rc < ra || (bcreg_free(fs, rc),1)); + ins = BCINS_ABC(BC_TSETV, ra, var->u.s.info, rc); + } + } + bcemit_INS(fs, ins); + expr_free(fs, e); +} + +/* Emit method lookup expression. */ +static void bcemit_method(FuncState *fs, ExpDesc *e, ExpDesc *key) +{ + BCReg idx, func, obj = expr_toanyreg(fs, e); + expr_free(fs, e); + func = fs->freereg; + bcemit_AD(fs, BC_MOV, func+1, obj); /* Copy object to first argument. */ + lua_assert(expr_isstrk(key)); + idx = const_str(fs, key); + if (idx <= BCMAX_C) { + bcreg_reserve(fs, 2); + bcemit_ABC(fs, BC_TGETS, func, obj, idx); + } else { + bcreg_reserve(fs, 3); + bcemit_AD(fs, BC_KSTR, func+2, idx); + bcemit_ABC(fs, BC_TGETV, func, obj, func+2); + fs->freereg--; + } + e->u.s.info = func; + e->k = VNONRELOC; +} + +/* -- Bytecode emitter for branches --------------------------------------- */ + +/* Emit unconditional branch. */ +static BCPos bcemit_jmp(FuncState *fs) +{ + BCPos jpc = fs->jpc; + BCPos j = fs->pc - 1; + BCIns *ip = &fs->bcbase[j].ins; + fs->jpc = NO_JMP; + if ((int32_t)j >= (int32_t)fs->lasttarget && bc_op(*ip) == BC_UCLO) { + setbc_j(ip, NO_JMP); + fs->lasttarget = j+1; + } else { + j = bcemit_AJ(fs, BC_JMP, fs->freereg, NO_JMP); + } + jmp_append(fs, &j, jpc); + return j; +} + +/* Invert branch condition of bytecode instruction. */ +static void invertcond(FuncState *fs, ExpDesc *e) +{ + BCIns *ip = &fs->bcbase[e->u.s.info - 1].ins; + setbc_op(ip, bc_op(*ip)^1); +} + +/* Emit conditional branch. */ +static BCPos bcemit_branch(FuncState *fs, ExpDesc *e, int cond) +{ + BCPos pc; + if (e->k == VRELOCABLE) { + BCIns *ip = bcptr(fs, e); + if (bc_op(*ip) == BC_NOT) { + *ip = BCINS_AD(cond ? BC_ISF : BC_IST, 0, bc_d(*ip)); + return bcemit_jmp(fs); + } + } + if (e->k != VNONRELOC) { + bcreg_reserve(fs, 1); + expr_toreg_nobranch(fs, e, fs->freereg-1); + } + bcemit_AD(fs, cond ? BC_ISTC : BC_ISFC, NO_REG, e->u.s.info); + pc = bcemit_jmp(fs); + expr_free(fs, e); + return pc; +} + +/* Emit branch on true condition. */ +static void bcemit_branch_t(FuncState *fs, ExpDesc *e) +{ + BCPos pc; + expr_discharge(fs, e); + if (e->k == VKSTR || e->k == VKNUM || e->k == VKTRUE) + pc = NO_JMP; /* Never jump. */ + else if (e->k == VJMP) + invertcond(fs, e), pc = e->u.s.info; + else if (e->k == VKFALSE || e->k == VKNIL) + expr_toreg_nobranch(fs, e, NO_REG), pc = bcemit_jmp(fs); + else + pc = bcemit_branch(fs, e, 0); + jmp_append(fs, &e->f, pc); + jmp_tohere(fs, e->t); + e->t = NO_JMP; +} + +/* Emit branch on false condition. */ +static void bcemit_branch_f(FuncState *fs, ExpDesc *e) +{ + BCPos pc; + expr_discharge(fs, e); + if (e->k == VKNIL || e->k == VKFALSE) + pc = NO_JMP; /* Never jump. */ + else if (e->k == VJMP) + pc = e->u.s.info; + else if (e->k == VKSTR || e->k == VKNUM || e->k == VKTRUE) + expr_toreg_nobranch(fs, e, NO_REG), pc = bcemit_jmp(fs); + else + pc = bcemit_branch(fs, e, 1); + jmp_append(fs, &e->t, pc); + jmp_tohere(fs, e->f); + e->f = NO_JMP; +} + +/* -- Bytecode emitter for operators -------------------------------------- */ + +/* Try constant-folding of arithmetic operators. */ +static int foldarith(BinOpr opr, ExpDesc *e1, ExpDesc *e2) +{ + TValue o; + lua_Number n; + if (!expr_isnumk_nojump(e1) || !expr_isnumk_nojump(e2)) return 0; + n = lj_vm_foldarith(expr_numberV(e1), expr_numberV(e2), (int)opr-OPR_ADD); + setnumV(&o, n); + if (tvisnan(&o) || tvismzero(&o)) return 0; /* Avoid NaN and -0 as consts. */ + if (LJ_DUALNUM) { + int32_t k = lj_num2int(n); + if ((lua_Number)k == n) { + setintV(&e1->u.nval, k); + return 1; + } + } + setnumV(&e1->u.nval, n); + return 1; +} + +/* Emit arithmetic operator. */ +static void bcemit_arith(FuncState *fs, BinOpr opr, ExpDesc *e1, ExpDesc *e2) +{ + BCReg rb, rc, t; + uint32_t op; + if (foldarith(opr, e1, e2)) + return; + if (opr == OPR_POW) { + op = BC_POW; + rc = expr_toanyreg(fs, e2); + rb = expr_toanyreg(fs, e1); + } else { + op = opr-OPR_ADD+BC_ADDVV; + /* Must discharge 2nd operand first since VINDEXED might free regs. */ + expr_toval(fs, e2); + if (expr_isnumk(e2) && (rc = const_num(fs, e2)) <= BCMAX_C) + op -= BC_ADDVV-BC_ADDVN; + else + rc = expr_toanyreg(fs, e2); + /* 1st operand discharged by bcemit_binop_left, but need KNUM/KSHORT. */ + lua_assert(expr_isnumk(e1) || e1->k == VNONRELOC); + expr_toval(fs, e1); + /* Avoid two consts to satisfy bytecode constraints. */ + if (expr_isnumk(e1) && !expr_isnumk(e2) && + (t = const_num(fs, e1)) <= BCMAX_B) { + rb = rc; rc = t; op -= BC_ADDVV-BC_ADDNV; + } else { + rb = expr_toanyreg(fs, e1); + } + } + /* Using expr_free might cause asserts if the order is wrong. */ + if (e1->k == VNONRELOC && e1->u.s.info >= fs->nactvar) fs->freereg--; + if (e2->k == VNONRELOC && e2->u.s.info >= fs->nactvar) fs->freereg--; + e1->u.s.info = bcemit_ABC(fs, op, 0, rb, rc); + e1->k = VRELOCABLE; +} + +/* Emit comparison operator. */ +static void bcemit_comp(FuncState *fs, BinOpr opr, ExpDesc *e1, ExpDesc *e2) +{ + ExpDesc *eret = e1; + BCIns ins; + expr_toval(fs, e1); + if (opr == OPR_EQ || opr == OPR_NE) { + BCOp op = opr == OPR_EQ ? BC_ISEQV : BC_ISNEV; + BCReg ra; + if (expr_isk(e1)) { e1 = e2; e2 = eret; } /* Need constant in 2nd arg. */ + ra = expr_toanyreg(fs, e1); /* First arg must be in a reg. */ + expr_toval(fs, e2); + switch (e2->k) { + case VKNIL: case VKFALSE: case VKTRUE: + ins = BCINS_AD(op+(BC_ISEQP-BC_ISEQV), ra, const_pri(e2)); + break; + case VKSTR: + ins = BCINS_AD(op+(BC_ISEQS-BC_ISEQV), ra, const_str(fs, e2)); + break; + case VKNUM: + ins = BCINS_AD(op+(BC_ISEQN-BC_ISEQV), ra, const_num(fs, e2)); + break; + default: + ins = BCINS_AD(op, ra, expr_toanyreg(fs, e2)); + break; + } + } else { + uint32_t op = opr-OPR_LT+BC_ISLT; + BCReg ra, rd; + if ((op-BC_ISLT) & 1) { /* GT -> LT, GE -> LE */ + e1 = e2; e2 = eret; /* Swap operands. */ + op = ((op-BC_ISLT)^3)+BC_ISLT; + expr_toval(fs, e1); + } + rd = expr_toanyreg(fs, e2); + ra = expr_toanyreg(fs, e1); + ins = BCINS_AD(op, ra, rd); + } + /* Using expr_free might cause asserts if the order is wrong. */ + if (e1->k == VNONRELOC && e1->u.s.info >= fs->nactvar) fs->freereg--; + if (e2->k == VNONRELOC && e2->u.s.info >= fs->nactvar) fs->freereg--; + bcemit_INS(fs, ins); + eret->u.s.info = bcemit_jmp(fs); + eret->k = VJMP; +} + +/* Fixup left side of binary operator. */ +static void bcemit_binop_left(FuncState *fs, BinOpr op, ExpDesc *e) +{ + if (op == OPR_AND) { + bcemit_branch_t(fs, e); + } else if (op == OPR_OR) { + bcemit_branch_f(fs, e); + } else if (op == OPR_CONCAT) { + expr_tonextreg(fs, e); + } else if (op == OPR_EQ || op == OPR_NE) { + if (!expr_isk_nojump(e)) expr_toanyreg(fs, e); + } else { + if (!expr_isnumk_nojump(e)) expr_toanyreg(fs, e); + } +} + +/* Emit binary operator. */ +static void bcemit_binop(FuncState *fs, BinOpr op, ExpDesc *e1, ExpDesc *e2) +{ + if (op <= OPR_POW) { + bcemit_arith(fs, op, e1, e2); + } else if (op == OPR_AND) { + lua_assert(e1->t == NO_JMP); /* List must be closed. */ + expr_discharge(fs, e2); + jmp_append(fs, &e2->f, e1->f); + *e1 = *e2; + } else if (op == OPR_OR) { + lua_assert(e1->f == NO_JMP); /* List must be closed. */ + expr_discharge(fs, e2); + jmp_append(fs, &e2->t, e1->t); + *e1 = *e2; + } else if (op == OPR_CONCAT) { + expr_toval(fs, e2); + if (e2->k == VRELOCABLE && bc_op(*bcptr(fs, e2)) == BC_CAT) { + lua_assert(e1->u.s.info == bc_b(*bcptr(fs, e2))-1); + expr_free(fs, e1); + setbc_b(bcptr(fs, e2), e1->u.s.info); + e1->u.s.info = e2->u.s.info; + } else { + expr_tonextreg(fs, e2); + expr_free(fs, e2); + expr_free(fs, e1); + e1->u.s.info = bcemit_ABC(fs, BC_CAT, 0, e1->u.s.info, e2->u.s.info); + } + e1->k = VRELOCABLE; + } else { + lua_assert(op == OPR_NE || op == OPR_EQ || + op == OPR_LT || op == OPR_GE || op == OPR_LE || op == OPR_GT); + bcemit_comp(fs, op, e1, e2); + } +} + +/* Emit unary operator. */ +static void bcemit_unop(FuncState *fs, BCOp op, ExpDesc *e) +{ + if (op == BC_NOT) { + /* Swap true and false lists. */ + { BCPos temp = e->f; e->f = e->t; e->t = temp; } + jmp_dropval(fs, e->f); + jmp_dropval(fs, e->t); + expr_discharge(fs, e); + if (e->k == VKNIL || e->k == VKFALSE) { + e->k = VKTRUE; + return; + } else if (expr_isk(e) || (LJ_HASFFI && e->k == VKCDATA)) { + e->k = VKFALSE; + return; + } else if (e->k == VJMP) { + invertcond(fs, e); + return; + } else if (e->k == VRELOCABLE) { + bcreg_reserve(fs, 1); + setbc_a(bcptr(fs, e), fs->freereg-1); + e->u.s.info = fs->freereg-1; + e->k = VNONRELOC; + } else { + lua_assert(e->k == VNONRELOC); + } + } else { + lua_assert(op == BC_UNM || op == BC_LEN); + if (op == BC_UNM && !expr_hasjump(e)) { /* Constant-fold negations. */ +#if LJ_HASFFI + if (e->k == VKCDATA) { /* Fold in-place since cdata is not interned. */ + GCcdata *cd = cdataV(&e->u.nval); + int64_t *p = (int64_t *)cdataptr(cd); + if (cd->ctypeid == CTID_COMPLEX_DOUBLE) + p[1] ^= (int64_t)U64x(80000000,00000000); + else + *p = -*p; + return; + } else +#endif + if (expr_isnumk(e) && !expr_numiszero(e)) { /* Avoid folding to -0. */ + TValue *o = expr_numtv(e); + if (tvisint(o)) { + int32_t k = intV(o); + if (k == -k) + setnumV(o, -(lua_Number)k); + else + setintV(o, -k); + return; + } else { + o->u64 ^= U64x(80000000,00000000); + return; + } + } + } + expr_toanyreg(fs, e); + } + expr_free(fs, e); + e->u.s.info = bcemit_AD(fs, op, 0, e->u.s.info); + e->k = VRELOCABLE; +} + +/* -- Lexer support ------------------------------------------------------- */ + +/* Check and consume optional token. */ +static int lex_opt(LexState *ls, LexToken tok) +{ + if (ls->token == tok) { + lj_lex_next(ls); + return 1; + } + return 0; +} + +/* Check and consume token. */ +static void lex_check(LexState *ls, LexToken tok) +{ + if (ls->token != tok) + err_token(ls, tok); + lj_lex_next(ls); +} + +/* Check for matching token. */ +static void lex_match(LexState *ls, LexToken what, LexToken who, BCLine line) +{ + if (!lex_opt(ls, what)) { + if (line == ls->linenumber) { + err_token(ls, what); + } else { + const char *swhat = lj_lex_token2str(ls, what); + const char *swho = lj_lex_token2str(ls, who); + lj_lex_error(ls, ls->token, LJ_ERR_XMATCH, swhat, swho, line); + } + } +} + +/* Check for string token. */ +static GCstr *lex_str(LexState *ls) +{ + GCstr *s; + if (ls->token != TK_name && (LJ_52 || ls->token != TK_goto)) + err_token(ls, TK_name); + s = strV(&ls->tokenval); + lj_lex_next(ls); + return s; +} + +/* -- Variable handling --------------------------------------------------- */ + +#define var_get(ls, fs, i) ((ls)->vstack[(fs)->varmap[(i)]]) + +/* Define a new local variable. */ +static void var_new(LexState *ls, BCReg n, GCstr *name) +{ + FuncState *fs = ls->fs; + MSize vtop = ls->vtop; + checklimit(fs, fs->nactvar+n, LJ_MAX_LOCVAR, "local variables"); + if (LJ_UNLIKELY(vtop >= ls->sizevstack)) { + if (ls->sizevstack >= LJ_MAX_VSTACK) + lj_lex_error(ls, 0, LJ_ERR_XLIMC, LJ_MAX_VSTACK); + lj_mem_growvec(ls->L, ls->vstack, ls->sizevstack, LJ_MAX_VSTACK, VarInfo); + } + lua_assert((uintptr_t)name < VARNAME__MAX || + lj_tab_getstr(fs->kt, name) != NULL); + /* NOBARRIER: name is anchored in fs->kt and ls->vstack is not a GCobj. */ + setgcref(ls->vstack[vtop].name, obj2gco(name)); + fs->varmap[fs->nactvar+n] = (uint16_t)vtop; + ls->vtop = vtop+1; +} + +#define var_new_lit(ls, n, v) \ + var_new(ls, (n), lj_parse_keepstr(ls, "" v, sizeof(v)-1)) + +#define var_new_fixed(ls, n, vn) \ + var_new(ls, (n), (GCstr *)(uintptr_t)(vn)) + +/* Add local variables. */ +static void var_add(LexState *ls, BCReg nvars) +{ + FuncState *fs = ls->fs; + BCReg nactvar = fs->nactvar; + while (nvars--) { + VarInfo *v = &var_get(ls, fs, nactvar); + v->startpc = fs->pc; + v->slot = nactvar++; + v->info = 0; + } + fs->nactvar = nactvar; +} + +/* Remove local variables. */ +static void var_remove(LexState *ls, BCReg tolevel) +{ + FuncState *fs = ls->fs; + while (fs->nactvar > tolevel) + var_get(ls, fs, --fs->nactvar).endpc = fs->pc; +} + +/* Lookup local variable name. */ +static BCReg var_lookup_local(FuncState *fs, GCstr *n) +{ + int i; + for (i = fs->nactvar-1; i >= 0; i--) { + if (n == strref(var_get(fs->ls, fs, i).name)) + return (BCReg)i; + } + return (BCReg)-1; /* Not found. */ +} + +/* Lookup or add upvalue index. */ +static MSize var_lookup_uv(FuncState *fs, MSize vidx, ExpDesc *e) +{ + MSize i, n = fs->nuv; + for (i = 0; i < n; i++) + if (fs->uvmap[i] == vidx) + return i; /* Already exists. */ + /* Otherwise create a new one. */ + checklimit(fs, fs->nuv, LJ_MAX_UPVAL, "upvalues"); + lua_assert(e->k == VLOCAL || e->k == VUPVAL); + fs->uvmap[n] = (uint16_t)vidx; + fs->uvtmp[n] = (uint16_t)(e->k == VLOCAL ? vidx : LJ_MAX_VSTACK+e->u.s.info); + fs->nuv = n+1; + return n; +} + +/* Forward declaration. */ +static void fscope_uvmark(FuncState *fs, BCReg level); + +/* Recursively lookup variables in enclosing functions. */ +static MSize var_lookup_(FuncState *fs, GCstr *name, ExpDesc *e, int first) +{ + if (fs) { + BCReg reg = var_lookup_local(fs, name); + if ((int32_t)reg >= 0) { /* Local in this function? */ + expr_init(e, VLOCAL, reg); + if (!first) + fscope_uvmark(fs, reg); /* Scope now has an upvalue. */ + return (MSize)(e->u.s.aux = (uint32_t)fs->varmap[reg]); + } else { + MSize vidx = var_lookup_(fs->prev, name, e, 0); /* Var in outer func? */ + if ((int32_t)vidx >= 0) { /* Yes, make it an upvalue here. */ + e->u.s.info = (uint8_t)var_lookup_uv(fs, vidx, e); + e->k = VUPVAL; + return vidx; + } + } + } else { /* Not found in any function, must be a global. */ + expr_init(e, VGLOBAL, 0); + e->u.sval = name; + } + return (MSize)-1; /* Global. */ +} + +/* Lookup variable name. */ +#define var_lookup(ls, e) \ + var_lookup_((ls)->fs, lex_str(ls), (e), 1) + +/* -- Goto an label handling ---------------------------------------------- */ + +/* Add a new goto or label. */ +static MSize gola_new(LexState *ls, GCstr *name, uint8_t info, BCPos pc) +{ + FuncState *fs = ls->fs; + MSize vtop = ls->vtop; + if (LJ_UNLIKELY(vtop >= ls->sizevstack)) { + if (ls->sizevstack >= LJ_MAX_VSTACK) + lj_lex_error(ls, 0, LJ_ERR_XLIMC, LJ_MAX_VSTACK); + lj_mem_growvec(ls->L, ls->vstack, ls->sizevstack, LJ_MAX_VSTACK, VarInfo); + } + lua_assert(name == NAME_BREAK || lj_tab_getstr(fs->kt, name) != NULL); + /* NOBARRIER: name is anchored in fs->kt and ls->vstack is not a GCobj. */ + setgcref(ls->vstack[vtop].name, obj2gco(name)); + ls->vstack[vtop].startpc = pc; + ls->vstack[vtop].slot = (uint8_t)fs->nactvar; + ls->vstack[vtop].info = info; + ls->vtop = vtop+1; + return vtop; +} + +#define gola_isgoto(v) ((v)->info & VSTACK_GOTO) +#define gola_islabel(v) ((v)->info & VSTACK_LABEL) +#define gola_isgotolabel(v) ((v)->info & (VSTACK_GOTO|VSTACK_LABEL)) + +/* Patch goto to jump to label. */ +static void gola_patch(LexState *ls, VarInfo *vg, VarInfo *vl) +{ + FuncState *fs = ls->fs; + BCPos pc = vg->startpc; + setgcrefnull(vg->name); /* Invalidate pending goto. */ + setbc_a(&fs->bcbase[pc].ins, vl->slot); + jmp_patch(fs, pc, vl->startpc); +} + +/* Patch goto to close upvalues. */ +static void gola_close(LexState *ls, VarInfo *vg) +{ + FuncState *fs = ls->fs; + BCPos pc = vg->startpc; + BCIns *ip = &fs->bcbase[pc].ins; + lua_assert(gola_isgoto(vg)); + lua_assert(bc_op(*ip) == BC_JMP || bc_op(*ip) == BC_UCLO); + setbc_a(ip, vg->slot); + if (bc_op(*ip) == BC_JMP) { + BCPos next = jmp_next(fs, pc); + if (next != NO_JMP) jmp_patch(fs, next, pc); /* Jump to UCLO. */ + setbc_op(ip, BC_UCLO); /* Turn into UCLO. */ + setbc_j(ip, NO_JMP); + } +} + +/* Resolve pending forward gotos for label. */ +static void gola_resolve(LexState *ls, FuncScope *bl, MSize idx) +{ + VarInfo *vg = ls->vstack + bl->vstart; + VarInfo *vl = ls->vstack + idx; + for (; vg < vl; vg++) + if (gcrefeq(vg->name, vl->name) && gola_isgoto(vg)) { + if (vg->slot < vl->slot) { + GCstr *name = strref(var_get(ls, ls->fs, vg->slot).name); + lua_assert((uintptr_t)name >= VARNAME__MAX); + ls->linenumber = ls->fs->bcbase[vg->startpc].line; + lua_assert(strref(vg->name) != NAME_BREAK); + lj_lex_error(ls, 0, LJ_ERR_XGSCOPE, + strdata(strref(vg->name)), strdata(name)); + } + gola_patch(ls, vg, vl); + } +} + +/* Fixup remaining gotos and labels for scope. */ +static void gola_fixup(LexState *ls, FuncScope *bl) +{ + VarInfo *v = ls->vstack + bl->vstart; + VarInfo *ve = ls->vstack + ls->vtop; + for (; v < ve; v++) { + GCstr *name = strref(v->name); + if (name != NULL) { /* Only consider remaining valid gotos/labels. */ + if (gola_islabel(v)) { + VarInfo *vg; + setgcrefnull(v->name); /* Invalidate label that goes out of scope. */ + for (vg = v+1; vg < ve; vg++) /* Resolve pending backward gotos. */ + if (strref(vg->name) == name && gola_isgoto(vg)) { + if ((bl->flags&FSCOPE_UPVAL) && vg->slot > v->slot) + gola_close(ls, vg); + gola_patch(ls, vg, v); + } + } else if (gola_isgoto(v)) { + if (bl->prev) { /* Propagate goto or break to outer scope. */ + bl->prev->flags |= name == NAME_BREAK ? FSCOPE_BREAK : FSCOPE_GOLA; + v->slot = bl->nactvar; + if ((bl->flags & FSCOPE_UPVAL)) + gola_close(ls, v); + } else { /* No outer scope: undefined goto label or no loop. */ + ls->linenumber = ls->fs->bcbase[v->startpc].line; + if (name == NAME_BREAK) + lj_lex_error(ls, 0, LJ_ERR_XBREAK); + else + lj_lex_error(ls, 0, LJ_ERR_XLUNDEF, strdata(name)); + } + } + } + } +} + +/* Find existing label. */ +static VarInfo *gola_findlabel(LexState *ls, GCstr *name) +{ + VarInfo *v = ls->vstack + ls->fs->bl->vstart; + VarInfo *ve = ls->vstack + ls->vtop; + for (; v < ve; v++) + if (strref(v->name) == name && gola_islabel(v)) + return v; + return NULL; +} + +/* -- Scope handling ------------------------------------------------------ */ + +/* Begin a scope. */ +static void fscope_begin(FuncState *fs, FuncScope *bl, int flags) +{ + bl->nactvar = (uint8_t)fs->nactvar; + bl->flags = flags; + bl->vstart = fs->ls->vtop; + bl->prev = fs->bl; + fs->bl = bl; + lua_assert(fs->freereg == fs->nactvar); +} + +/* End a scope. */ +static void fscope_end(FuncState *fs) +{ + FuncScope *bl = fs->bl; + LexState *ls = fs->ls; + fs->bl = bl->prev; + var_remove(ls, bl->nactvar); + fs->freereg = fs->nactvar; + lua_assert(bl->nactvar == fs->nactvar); + if ((bl->flags & (FSCOPE_UPVAL|FSCOPE_NOCLOSE)) == FSCOPE_UPVAL) + bcemit_AJ(fs, BC_UCLO, bl->nactvar, 0); + if ((bl->flags & FSCOPE_BREAK)) { + if ((bl->flags & FSCOPE_LOOP)) { + MSize idx = gola_new(ls, NAME_BREAK, VSTACK_LABEL, fs->pc); + ls->vtop = idx; /* Drop break label immediately. */ + gola_resolve(ls, bl, idx); + } else { /* Need the fixup step to propagate the breaks. */ + gola_fixup(ls, bl); + return; + } + } + if ((bl->flags & FSCOPE_GOLA)) { + gola_fixup(ls, bl); + } +} + +/* Mark scope as having an upvalue. */ +static void fscope_uvmark(FuncState *fs, BCReg level) +{ + FuncScope *bl; + for (bl = fs->bl; bl && bl->nactvar > level; bl = bl->prev) + ; + if (bl) + bl->flags |= FSCOPE_UPVAL; +} + +/* -- Function state management ------------------------------------------- */ + +/* Fixup bytecode for prototype. */ +static void fs_fixup_bc(FuncState *fs, GCproto *pt, BCIns *bc, MSize n) +{ + BCInsLine *base = fs->bcbase; + MSize i; + pt->sizebc = n; + bc[0] = BCINS_AD((fs->flags & PROTO_VARARG) ? BC_FUNCV : BC_FUNCF, + fs->framesize, 0); + for (i = 1; i < n; i++) + bc[i] = base[i].ins; +} + +/* Fixup upvalues for child prototype, step #2. */ +static void fs_fixup_uv2(FuncState *fs, GCproto *pt) +{ + VarInfo *vstack = fs->ls->vstack; + uint16_t *uv = proto_uv(pt); + MSize i, n = pt->sizeuv; + for (i = 0; i < n; i++) { + VarIndex vidx = uv[i]; + if (vidx >= LJ_MAX_VSTACK) + uv[i] = vidx - LJ_MAX_VSTACK; + else if ((vstack[vidx].info & VSTACK_VAR_RW)) + uv[i] = vstack[vidx].slot | PROTO_UV_LOCAL; + else + uv[i] = vstack[vidx].slot | PROTO_UV_LOCAL | PROTO_UV_IMMUTABLE; + } +} + +/* Fixup constants for prototype. */ +static void fs_fixup_k(FuncState *fs, GCproto *pt, void *kptr) +{ + GCtab *kt; + TValue *array; + Node *node; + MSize i, hmask; + checklimitgt(fs, fs->nkn, BCMAX_D+1, "constants"); + checklimitgt(fs, fs->nkgc, BCMAX_D+1, "constants"); + setmref(pt->k, kptr); + pt->sizekn = fs->nkn; + pt->sizekgc = fs->nkgc; + kt = fs->kt; + array = tvref(kt->array); + for (i = 0; i < kt->asize; i++) + if (tvhaskslot(&array[i])) { + TValue *tv = &((TValue *)kptr)[tvkslot(&array[i])]; + if (LJ_DUALNUM) + setintV(tv, (int32_t)i); + else + setnumV(tv, (lua_Number)i); + } + node = noderef(kt->node); + hmask = kt->hmask; + for (i = 0; i <= hmask; i++) { + Node *n = &node[i]; + if (tvhaskslot(&n->val)) { + ptrdiff_t kidx = (ptrdiff_t)tvkslot(&n->val); + lua_assert(!tvisint(&n->key)); + if (tvisnum(&n->key)) { + TValue *tv = &((TValue *)kptr)[kidx]; + if (LJ_DUALNUM) { + lua_Number nn = numV(&n->key); + int32_t k = lj_num2int(nn); + lua_assert(!tvismzero(&n->key)); + if ((lua_Number)k == nn) + setintV(tv, k); + else + *tv = n->key; + } else { + *tv = n->key; + } + } else { + GCobj *o = gcV(&n->key); + setgcref(((GCRef *)kptr)[~kidx], o); + lj_gc_objbarrier(fs->L, pt, o); + if (tvisproto(&n->key)) + fs_fixup_uv2(fs, gco2pt(o)); + } + } + } +} + +/* Fixup upvalues for prototype, step #1. */ +static void fs_fixup_uv1(FuncState *fs, GCproto *pt, uint16_t *uv) +{ + setmref(pt->uv, uv); + pt->sizeuv = fs->nuv; + memcpy(uv, fs->uvtmp, fs->nuv*sizeof(VarIndex)); +} + +#ifndef LUAJIT_DISABLE_DEBUGINFO +/* Prepare lineinfo for prototype. */ +static size_t fs_prep_line(FuncState *fs, BCLine numline) +{ + return (fs->pc-1) << (numline < 256 ? 0 : numline < 65536 ? 1 : 2); +} + +/* Fixup lineinfo for prototype. */ +static void fs_fixup_line(FuncState *fs, GCproto *pt, + void *lineinfo, BCLine numline) +{ + BCInsLine *base = fs->bcbase + 1; + BCLine first = fs->linedefined; + MSize i = 0, n = fs->pc-1; + pt->firstline = fs->linedefined; + pt->numline = numline; + setmref(pt->lineinfo, lineinfo); + if (LJ_LIKELY(numline < 256)) { + uint8_t *li = (uint8_t *)lineinfo; + do { + BCLine delta = base[i].line - first; + lua_assert(delta >= 0 && delta < 256); + li[i] = (uint8_t)delta; + } while (++i < n); + } else if (LJ_LIKELY(numline < 65536)) { + uint16_t *li = (uint16_t *)lineinfo; + do { + BCLine delta = base[i].line - first; + lua_assert(delta >= 0 && delta < 65536); + li[i] = (uint16_t)delta; + } while (++i < n); + } else { + uint32_t *li = (uint32_t *)lineinfo; + do { + BCLine delta = base[i].line - first; + lua_assert(delta >= 0); + li[i] = (uint32_t)delta; + } while (++i < n); + } +} + +/* Resize buffer if needed. */ +static LJ_NOINLINE void fs_buf_resize(LexState *ls, MSize len) +{ + MSize sz = ls->sb.sz * 2; + while (ls->sb.n + len > sz) sz = sz * 2; + lj_str_resizebuf(ls->L, &ls->sb, sz); +} + +static LJ_AINLINE void fs_buf_need(LexState *ls, MSize len) +{ + if (LJ_UNLIKELY(ls->sb.n + len > ls->sb.sz)) + fs_buf_resize(ls, len); +} + +/* Add string to buffer. */ +static void fs_buf_str(LexState *ls, const char *str, MSize len) +{ + char *p = ls->sb.buf + ls->sb.n; + MSize i; + ls->sb.n += len; + for (i = 0; i < len; i++) p[i] = str[i]; +} + +/* Add ULEB128 value to buffer. */ +static void fs_buf_uleb128(LexState *ls, uint32_t v) +{ + MSize n = ls->sb.n; + uint8_t *p = (uint8_t *)ls->sb.buf; + for (; v >= 0x80; v >>= 7) + p[n++] = (uint8_t)((v & 0x7f) | 0x80); + p[n++] = (uint8_t)v; + ls->sb.n = n; +} + +/* Prepare variable info for prototype. */ +static size_t fs_prep_var(LexState *ls, FuncState *fs, size_t *ofsvar) +{ + VarInfo *vs =ls->vstack, *ve; + MSize i, n; + BCPos lastpc; + lj_str_resetbuf(&ls->sb); /* Copy to temp. string buffer. */ + /* Store upvalue names. */ + for (i = 0, n = fs->nuv; i < n; i++) { + GCstr *s = strref(vs[fs->uvmap[i]].name); + MSize len = s->len+1; + fs_buf_need(ls, len); + fs_buf_str(ls, strdata(s), len); + } + *ofsvar = ls->sb.n; + lastpc = 0; + /* Store local variable names and compressed ranges. */ + for (ve = vs + ls->vtop, vs += fs->vbase; vs < ve; vs++) { + if (!gola_isgotolabel(vs)) { + GCstr *s = strref(vs->name); + BCPos startpc; + if ((uintptr_t)s < VARNAME__MAX) { + fs_buf_need(ls, 1 + 2*5); + ls->sb.buf[ls->sb.n++] = (uint8_t)(uintptr_t)s; + } else { + MSize len = s->len+1; + fs_buf_need(ls, len + 2*5); + fs_buf_str(ls, strdata(s), len); + } + startpc = vs->startpc; + fs_buf_uleb128(ls, startpc-lastpc); + fs_buf_uleb128(ls, vs->endpc-startpc); + lastpc = startpc; + } + } + fs_buf_need(ls, 1); + ls->sb.buf[ls->sb.n++] = '\0'; /* Terminator for varinfo. */ + return ls->sb.n; +} + +/* Fixup variable info for prototype. */ +static void fs_fixup_var(LexState *ls, GCproto *pt, uint8_t *p, size_t ofsvar) +{ + setmref(pt->uvinfo, p); + setmref(pt->varinfo, (char *)p + ofsvar); + memcpy(p, ls->sb.buf, ls->sb.n); /* Copy from temp. string buffer. */ +} +#else + +/* Initialize with empty debug info, if disabled. */ +#define fs_prep_line(fs, numline) (UNUSED(numline), 0) +#define fs_fixup_line(fs, pt, li, numline) \ + pt->firstline = pt->numline = 0, setmref((pt)->lineinfo, NULL) +#define fs_prep_var(ls, fs, ofsvar) (UNUSED(ofsvar), 0) +#define fs_fixup_var(ls, pt, p, ofsvar) \ + setmref((pt)->uvinfo, NULL), setmref((pt)->varinfo, NULL) + +#endif + +/* Check if bytecode op returns. */ +static int bcopisret(BCOp op) +{ + switch (op) { + case BC_CALLMT: case BC_CALLT: + case BC_RETM: case BC_RET: case BC_RET0: case BC_RET1: + return 1; + default: + return 0; + } +} + +/* Fixup return instruction for prototype. */ +static void fs_fixup_ret(FuncState *fs) +{ + BCPos lastpc = fs->pc; + if (lastpc <= fs->lasttarget || !bcopisret(bc_op(fs->bcbase[lastpc-1].ins))) { + if ((fs->bl->flags & FSCOPE_UPVAL)) + bcemit_AJ(fs, BC_UCLO, 0, 0); + bcemit_AD(fs, BC_RET0, 0, 1); /* Need final return. */ + } + fs->bl->flags |= FSCOPE_NOCLOSE; /* Handled above. */ + fscope_end(fs); + lua_assert(fs->bl == NULL); + /* May need to fixup returns encoded before first function was created. */ + if (fs->flags & PROTO_FIXUP_RETURN) { + BCPos pc; + for (pc = 1; pc < lastpc; pc++) { + BCIns ins = fs->bcbase[pc].ins; + BCPos offset; + switch (bc_op(ins)) { + case BC_CALLMT: case BC_CALLT: + case BC_RETM: case BC_RET: case BC_RET0: case BC_RET1: + offset = bcemit_INS(fs, ins); /* Copy original instruction. */ + fs->bcbase[offset].line = fs->bcbase[pc].line; + offset = offset-(pc+1)+BCBIAS_J; + if (offset > BCMAX_D) + err_syntax(fs->ls, LJ_ERR_XFIXUP); + /* Replace with UCLO plus branch. */ + fs->bcbase[pc].ins = BCINS_AD(BC_UCLO, 0, offset); + break; + case BC_UCLO: + return; /* We're done. */ + default: + break; + } + } + } +} + +/* Finish a FuncState and return the new prototype. */ +static GCproto *fs_finish(LexState *ls, BCLine line) +{ + lua_State *L = ls->L; + FuncState *fs = ls->fs; + BCLine numline = line - fs->linedefined; + size_t sizept, ofsk, ofsuv, ofsli, ofsdbg, ofsvar; + GCproto *pt; + + /* Apply final fixups. */ + fs_fixup_ret(fs); + + /* Calculate total size of prototype including all colocated arrays. */ + sizept = sizeof(GCproto) + fs->pc*sizeof(BCIns) + fs->nkgc*sizeof(GCRef); + sizept = (sizept + sizeof(TValue)-1) & ~(sizeof(TValue)-1); + ofsk = sizept; sizept += fs->nkn*sizeof(TValue); + ofsuv = sizept; sizept += ((fs->nuv+1)&~1)*2; + ofsli = sizept; sizept += fs_prep_line(fs, numline); + ofsdbg = sizept; sizept += fs_prep_var(ls, fs, &ofsvar); + + /* Allocate prototype and initialize its fields. */ + pt = (GCproto *)lj_mem_newgco(L, (MSize)sizept); + pt->gct = ~LJ_TPROTO; + pt->sizept = (MSize)sizept; + pt->trace = 0; + pt->flags = (uint8_t)(fs->flags & ~(PROTO_HAS_RETURN|PROTO_FIXUP_RETURN)); + pt->numparams = fs->numparams; + pt->framesize = fs->framesize; + setgcref(pt->chunkname, obj2gco(ls->chunkname)); + + /* Close potentially uninitialized gap between bc and kgc. */ + *(uint32_t *)((char *)pt + ofsk - sizeof(GCRef)*(fs->nkgc+1)) = 0; + fs_fixup_bc(fs, pt, (BCIns *)((char *)pt + sizeof(GCproto)), fs->pc); + fs_fixup_k(fs, pt, (void *)((char *)pt + ofsk)); + fs_fixup_uv1(fs, pt, (uint16_t *)((char *)pt + ofsuv)); + fs_fixup_line(fs, pt, (void *)((char *)pt + ofsli), numline); + fs_fixup_var(ls, pt, (uint8_t *)((char *)pt + ofsdbg), ofsvar); + + lj_vmevent_send(L, BC, + setprotoV(L, L->top++, pt); + ); + + L->top--; /* Pop table of constants. */ + ls->vtop = fs->vbase; /* Reset variable stack. */ + ls->fs = fs->prev; + lua_assert(ls->fs != NULL || ls->token == TK_eof); + return pt; +} + +/* Initialize a new FuncState. */ +static void fs_init(LexState *ls, FuncState *fs) +{ + lua_State *L = ls->L; + fs->prev = ls->fs; ls->fs = fs; /* Append to list. */ + fs->ls = ls; + fs->vbase = ls->vtop; + fs->L = L; + fs->pc = 0; + fs->lasttarget = 0; + fs->jpc = NO_JMP; + fs->freereg = 0; + fs->nkgc = 0; + fs->nkn = 0; + fs->nactvar = 0; + fs->nuv = 0; + fs->bl = NULL; + fs->flags = 0; + fs->framesize = 1; /* Minimum frame size. */ + fs->kt = lj_tab_new(L, 0, 0); + /* Anchor table of constants in stack to avoid being collected. */ + settabV(L, L->top, fs->kt); + incr_top(L); +} + +/* -- Expressions --------------------------------------------------------- */ + +/* Forward declaration. */ +static void expr(LexState *ls, ExpDesc *v); + +/* Return string expression. */ +static void expr_str(LexState *ls, ExpDesc *e) +{ + expr_init(e, VKSTR, 0); + e->u.sval = lex_str(ls); +} + +/* Return index expression. */ +static void expr_index(FuncState *fs, ExpDesc *t, ExpDesc *e) +{ + /* Already called: expr_toval(fs, e). */ + t->k = VINDEXED; + if (expr_isnumk(e)) { +#if LJ_DUALNUM + if (tvisint(expr_numtv(e))) { + int32_t k = intV(expr_numtv(e)); + if (checku8(k)) { + t->u.s.aux = BCMAX_C+1+(uint32_t)k; /* 256..511: const byte key */ + return; + } + } +#else + lua_Number n = expr_numberV(e); + int32_t k = lj_num2int(n); + if (checku8(k) && n == (lua_Number)k) { + t->u.s.aux = BCMAX_C+1+(uint32_t)k; /* 256..511: const byte key */ + return; + } +#endif + } else if (expr_isstrk(e)) { + BCReg idx = const_str(fs, e); + if (idx <= BCMAX_C) { + t->u.s.aux = ~idx; /* -256..-1: const string key */ + return; + } + } + t->u.s.aux = expr_toanyreg(fs, e); /* 0..255: register */ +} + +/* Parse index expression with named field. */ +static void expr_field(LexState *ls, ExpDesc *v) +{ + FuncState *fs = ls->fs; + ExpDesc key; + expr_toanyreg(fs, v); + lj_lex_next(ls); /* Skip dot or colon. */ + expr_str(ls, &key); + expr_index(fs, v, &key); +} + +/* Parse index expression with brackets. */ +static void expr_bracket(LexState *ls, ExpDesc *v) +{ + lj_lex_next(ls); /* Skip '['. */ + expr(ls, v); + expr_toval(ls->fs, v); + lex_check(ls, ']'); +} + +/* Get value of constant expression. */ +static void expr_kvalue(TValue *v, ExpDesc *e) +{ + if (e->k <= VKTRUE) { + setitype(v, ~(uint32_t)e->k); + } else if (e->k == VKSTR) { + setgcref(v->gcr, obj2gco(e->u.sval)); + setitype(v, LJ_TSTR); + } else { + lua_assert(tvisnumber(expr_numtv(e))); + *v = *expr_numtv(e); + } +} + +/* Parse table constructor expression. */ +static void expr_table(LexState *ls, ExpDesc *e) +{ + FuncState *fs = ls->fs; + BCLine line = ls->linenumber; + GCtab *t = NULL; + int vcall = 0, needarr = 0, fixt = 0; + uint32_t narr = 1; /* First array index. */ + uint32_t nhash = 0; /* Number of hash entries. */ + BCReg freg = fs->freereg; + BCPos pc = bcemit_AD(fs, BC_TNEW, freg, 0); + expr_init(e, VNONRELOC, freg); + bcreg_reserve(fs, 1); + freg++; + lex_check(ls, '{'); + while (ls->token != '}') { + ExpDesc key, val; + vcall = 0; + if (ls->token == '[') { + expr_bracket(ls, &key); /* Already calls expr_toval. */ + if (!expr_isk(&key)) expr_index(fs, e, &key); + if (expr_isnumk(&key) && expr_numiszero(&key)) needarr = 1; else nhash++; + lex_check(ls, '='); + } else if ((ls->token == TK_name || (!LJ_52 && ls->token == TK_goto)) && + lj_lex_lookahead(ls) == '=') { + expr_str(ls, &key); + lex_check(ls, '='); + nhash++; + } else { + expr_init(&key, VKNUM, 0); + setintV(&key.u.nval, (int)narr); + narr++; + needarr = vcall = 1; + } + expr(ls, &val); + if (expr_isk(&key) && key.k != VKNIL && + (key.k == VKSTR || expr_isk_nojump(&val))) { + TValue k, *v; + if (!t) { /* Create template table on demand. */ + BCReg kidx; + t = lj_tab_new(fs->L, needarr ? narr : 0, hsize2hbits(nhash)); + kidx = const_gc(fs, obj2gco(t), LJ_TTAB); + fs->bcbase[pc].ins = BCINS_AD(BC_TDUP, freg-1, kidx); + } + vcall = 0; + expr_kvalue(&k, &key); + v = lj_tab_set(fs->L, t, &k); + lj_gc_anybarriert(fs->L, t); + if (expr_isk_nojump(&val)) { /* Add const key/value to template table. */ + expr_kvalue(v, &val); + } else { /* Otherwise create dummy string key (avoids lj_tab_newkey). */ + settabV(fs->L, v, t); /* Preserve key with table itself as value. */ + fixt = 1; /* Fix this later, after all resizes. */ + goto nonconst; + } + } else { + nonconst: + if (val.k != VCALL) { expr_toanyreg(fs, &val); vcall = 0; } + if (expr_isk(&key)) expr_index(fs, e, &key); + bcemit_store(fs, e, &val); + } + fs->freereg = freg; + if (!lex_opt(ls, ',') && !lex_opt(ls, ';')) break; + } + lex_match(ls, '}', '{', line); + if (vcall) { + BCInsLine *ilp = &fs->bcbase[fs->pc-1]; + ExpDesc en; + lua_assert(bc_a(ilp->ins) == freg && + bc_op(ilp->ins) == (narr > 256 ? BC_TSETV : BC_TSETB)); + expr_init(&en, VKNUM, 0); + en.u.nval.u32.lo = narr-1; + en.u.nval.u32.hi = 0x43300000; /* Biased integer to avoid denormals. */ + if (narr > 256) { fs->pc--; ilp--; } + ilp->ins = BCINS_AD(BC_TSETM, freg, const_num(fs, &en)); + setbc_b(&ilp[-1].ins, 0); + } + if (pc == fs->pc-1) { /* Make expr relocable if possible. */ + e->u.s.info = pc; + fs->freereg--; + e->k = VRELOCABLE; + } else { + e->k = VNONRELOC; /* May have been changed by expr_index. */ + } + if (!t) { /* Construct TNEW RD: hhhhhaaaaaaaaaaa. */ + BCIns *ip = &fs->bcbase[pc].ins; + if (!needarr) narr = 0; + else if (narr < 3) narr = 3; + else if (narr > 0x7ff) narr = 0x7ff; + setbc_d(ip, narr|(hsize2hbits(nhash)<<11)); + } else { + if (needarr && t->asize < narr) + lj_tab_reasize(fs->L, t, narr-1); + if (fixt) { /* Fix value for dummy keys in template table. */ + Node *node = noderef(t->node); + uint32_t i, hmask = t->hmask; + for (i = 0; i <= hmask; i++) { + Node *n = &node[i]; + if (tvistab(&n->val)) { + lua_assert(tabV(&n->val) == t); + setnilV(&n->val); /* Turn value into nil. */ + } + } + } + lj_gc_check(fs->L); + } +} + +/* Parse function parameters. */ +static BCReg parse_params(LexState *ls, int needself) +{ + FuncState *fs = ls->fs; + BCReg nparams = 0; + lex_check(ls, '('); + if (needself) + var_new_lit(ls, nparams++, "self"); + if (ls->token != ')') { + do { + if (ls->token == TK_name || (!LJ_52 && ls->token == TK_goto)) { + var_new(ls, nparams++, lex_str(ls)); + } else if (ls->token == TK_dots) { + lj_lex_next(ls); + fs->flags |= PROTO_VARARG; + break; + } else { + err_syntax(ls, LJ_ERR_XPARAM); + } + } while (lex_opt(ls, ',')); + } + var_add(ls, nparams); + lua_assert(fs->nactvar == nparams); + bcreg_reserve(fs, nparams); + lex_check(ls, ')'); + return nparams; +} + +/* Forward declaration. */ +static void parse_chunk(LexState *ls); + +/* Parse body of a function. */ +static void parse_body(LexState *ls, ExpDesc *e, int needself, BCLine line) +{ + FuncState fs, *pfs = ls->fs; + FuncScope bl; + GCproto *pt; + ptrdiff_t oldbase = pfs->bcbase - ls->bcstack; + fs_init(ls, &fs); + fscope_begin(&fs, &bl, 0); + fs.linedefined = line; + fs.numparams = (uint8_t)parse_params(ls, needself); + fs.bcbase = pfs->bcbase + pfs->pc; + fs.bclim = pfs->bclim - pfs->pc; + bcemit_AD(&fs, BC_FUNCF, 0, 0); /* Placeholder. */ + parse_chunk(ls); + if (ls->token != TK_end) lex_match(ls, TK_end, TK_function, line); + pt = fs_finish(ls, (ls->lastline = ls->linenumber)); + pfs->bcbase = ls->bcstack + oldbase; /* May have been reallocated. */ + pfs->bclim = (BCPos)(ls->sizebcstack - oldbase); + /* Store new prototype in the constant array of the parent. */ + expr_init(e, VRELOCABLE, + bcemit_AD(pfs, BC_FNEW, 0, const_gc(pfs, obj2gco(pt), LJ_TPROTO))); +#if LJ_HASFFI + pfs->flags |= (fs.flags & PROTO_FFI); +#endif + if (!(pfs->flags & PROTO_CHILD)) { + if (pfs->flags & PROTO_HAS_RETURN) + pfs->flags |= PROTO_FIXUP_RETURN; + pfs->flags |= PROTO_CHILD; + } + lj_lex_next(ls); +} + +/* Parse expression list. Last expression is left open. */ +static BCReg expr_list(LexState *ls, ExpDesc *v) +{ + BCReg n = 1; + expr(ls, v); + while (lex_opt(ls, ',')) { + expr_tonextreg(ls->fs, v); + expr(ls, v); + n++; + } + return n; +} + +/* Parse function argument list. */ +static void parse_args(LexState *ls, ExpDesc *e) +{ + FuncState *fs = ls->fs; + ExpDesc args; + BCIns ins; + BCReg base; + BCLine line = ls->linenumber; + if (ls->token == '(') { +#if !LJ_52 + if (line != ls->lastline) + err_syntax(ls, LJ_ERR_XAMBIG); +#endif + lj_lex_next(ls); + if (ls->token == ')') { /* f(). */ + args.k = VVOID; + } else { + expr_list(ls, &args); + if (args.k == VCALL) /* f(a, b, g()) or f(a, b, ...). */ + setbc_b(bcptr(fs, &args), 0); /* Pass on multiple results. */ + } + lex_match(ls, ')', '(', line); + } else if (ls->token == '{') { + expr_table(ls, &args); + } else if (ls->token == TK_string) { + expr_init(&args, VKSTR, 0); + args.u.sval = strV(&ls->tokenval); + lj_lex_next(ls); + } else { + err_syntax(ls, LJ_ERR_XFUNARG); + return; /* Silence compiler. */ + } + lua_assert(e->k == VNONRELOC); + base = e->u.s.info; /* Base register for call. */ + if (args.k == VCALL) { + ins = BCINS_ABC(BC_CALLM, base, 2, args.u.s.aux - base - 1); + } else { + if (args.k != VVOID) + expr_tonextreg(fs, &args); + ins = BCINS_ABC(BC_CALL, base, 2, fs->freereg - base); + } + expr_init(e, VCALL, bcemit_INS(fs, ins)); + e->u.s.aux = base; + fs->bcbase[fs->pc - 1].line = line; + fs->freereg = base+1; /* Leave one result by default. */ +} + +/* Parse primary expression. */ +static void expr_primary(LexState *ls, ExpDesc *v) +{ + FuncState *fs = ls->fs; + /* Parse prefix expression. */ + if (ls->token == '(') { + BCLine line = ls->linenumber; + lj_lex_next(ls); + expr(ls, v); + lex_match(ls, ')', '(', line); + expr_discharge(ls->fs, v); + } else if (ls->token == TK_name || (!LJ_52 && ls->token == TK_goto)) { + var_lookup(ls, v); + } else { + err_syntax(ls, LJ_ERR_XSYMBOL); + } + for (;;) { /* Parse multiple expression suffixes. */ + if (ls->token == '.') { + expr_field(ls, v); + } else if (ls->token == '[') { + ExpDesc key; + expr_toanyreg(fs, v); + expr_bracket(ls, &key); + expr_index(fs, v, &key); + } else if (ls->token == ':') { + ExpDesc key; + lj_lex_next(ls); + expr_str(ls, &key); + bcemit_method(fs, v, &key); + parse_args(ls, v); + } else if (ls->token == '(' || ls->token == TK_string || ls->token == '{') { + expr_tonextreg(fs, v); + parse_args(ls, v); + } else { + break; + } + } +} + +/* Parse simple expression. */ +static void expr_simple(LexState *ls, ExpDesc *v) +{ + switch (ls->token) { + case TK_number: + expr_init(v, (LJ_HASFFI && tviscdata(&ls->tokenval)) ? VKCDATA : VKNUM, 0); + copyTV(ls->L, &v->u.nval, &ls->tokenval); + break; + case TK_string: + expr_init(v, VKSTR, 0); + v->u.sval = strV(&ls->tokenval); + break; + case TK_nil: + expr_init(v, VKNIL, 0); + break; + case TK_true: + expr_init(v, VKTRUE, 0); + break; + case TK_false: + expr_init(v, VKFALSE, 0); + break; + case TK_dots: { /* Vararg. */ + FuncState *fs = ls->fs; + BCReg base; + checkcond(ls, fs->flags & PROTO_VARARG, LJ_ERR_XDOTS); + bcreg_reserve(fs, 1); + base = fs->freereg-1; + expr_init(v, VCALL, bcemit_ABC(fs, BC_VARG, base, 2, fs->numparams)); + v->u.s.aux = base; + break; + } + case '{': /* Table constructor. */ + expr_table(ls, v); + return; + case TK_function: + lj_lex_next(ls); + parse_body(ls, v, 0, ls->linenumber); + return; + default: + expr_primary(ls, v); + return; + } + lj_lex_next(ls); +} + +/* Manage syntactic levels to avoid blowing up the stack. */ +static void synlevel_begin(LexState *ls) +{ + if (++ls->level >= LJ_MAX_XLEVEL) + lj_lex_error(ls, 0, LJ_ERR_XLEVELS); +} + +#define synlevel_end(ls) ((ls)->level--) + +/* Convert token to binary operator. */ +static BinOpr token2binop(LexToken tok) +{ + switch (tok) { + case '+': return OPR_ADD; + case '-': return OPR_SUB; + case '*': return OPR_MUL; + case '/': return OPR_DIV; + case '%': return OPR_MOD; + case '^': return OPR_POW; + case TK_concat: return OPR_CONCAT; + case TK_ne: return OPR_NE; + case TK_eq: return OPR_EQ; + case '<': return OPR_LT; + case TK_le: return OPR_LE; + case '>': return OPR_GT; + case TK_ge: return OPR_GE; + case TK_and: return OPR_AND; + case TK_or: return OPR_OR; + default: return OPR_NOBINOPR; + } +} + +/* Priorities for each binary operator. ORDER OPR. */ +static const struct { + uint8_t left; /* Left priority. */ + uint8_t right; /* Right priority. */ +} priority[] = { + {6,6}, {6,6}, {7,7}, {7,7}, {7,7}, /* ADD SUB MUL DIV MOD */ + {10,9}, {5,4}, /* POW CONCAT (right associative) */ + {3,3}, {3,3}, /* EQ NE */ + {3,3}, {3,3}, {3,3}, {3,3}, /* LT GE GT LE */ + {2,2}, {1,1} /* AND OR */ +}; + +#define UNARY_PRIORITY 8 /* Priority for unary operators. */ + +/* Forward declaration. */ +static BinOpr expr_binop(LexState *ls, ExpDesc *v, uint32_t limit); + +/* Parse unary expression. */ +static void expr_unop(LexState *ls, ExpDesc *v) +{ + BCOp op; + if (ls->token == TK_not) { + op = BC_NOT; + } else if (ls->token == '-') { + op = BC_UNM; + } else if (ls->token == '#') { + op = BC_LEN; + } else { + expr_simple(ls, v); + return; + } + lj_lex_next(ls); + expr_binop(ls, v, UNARY_PRIORITY); + bcemit_unop(ls->fs, op, v); +} + +/* Parse binary expressions with priority higher than the limit. */ +static BinOpr expr_binop(LexState *ls, ExpDesc *v, uint32_t limit) +{ + BinOpr op; + synlevel_begin(ls); + expr_unop(ls, v); + op = token2binop(ls->token); + while (op != OPR_NOBINOPR && priority[op].left > limit) { + ExpDesc v2; + BinOpr nextop; + lj_lex_next(ls); + bcemit_binop_left(ls->fs, op, v); + /* Parse binary expression with higher priority. */ + nextop = expr_binop(ls, &v2, priority[op].right); + bcemit_binop(ls->fs, op, v, &v2); + op = nextop; + } + synlevel_end(ls); + return op; /* Return unconsumed binary operator (if any). */ +} + +/* Parse expression. */ +static void expr(LexState *ls, ExpDesc *v) +{ + expr_binop(ls, v, 0); /* Priority 0: parse whole expression. */ +} + +/* Assign expression to the next register. */ +static void expr_next(LexState *ls) +{ + ExpDesc e; + expr(ls, &e); + expr_tonextreg(ls->fs, &e); +} + +/* Parse conditional expression. */ +static BCPos expr_cond(LexState *ls) +{ + ExpDesc v; + expr(ls, &v); + if (v.k == VKNIL) v.k = VKFALSE; + bcemit_branch_t(ls->fs, &v); + return v.f; +} + +/* -- Assignments --------------------------------------------------------- */ + +/* List of LHS variables. */ +typedef struct LHSVarList { + ExpDesc v; /* LHS variable. */ + struct LHSVarList *prev; /* Link to previous LHS variable. */ +} LHSVarList; + +/* Eliminate write-after-read hazards for local variable assignment. */ +static void assign_hazard(LexState *ls, LHSVarList *lh, const ExpDesc *v) +{ + FuncState *fs = ls->fs; + BCReg reg = v->u.s.info; /* Check against this variable. */ + BCReg tmp = fs->freereg; /* Rename to this temp. register (if needed). */ + int hazard = 0; + for (; lh; lh = lh->prev) { + if (lh->v.k == VINDEXED) { + if (lh->v.u.s.info == reg) { /* t[i], t = 1, 2 */ + hazard = 1; + lh->v.u.s.info = tmp; + } + if (lh->v.u.s.aux == reg) { /* t[i], i = 1, 2 */ + hazard = 1; + lh->v.u.s.aux = tmp; + } + } + } + if (hazard) { + bcemit_AD(fs, BC_MOV, tmp, reg); /* Rename conflicting variable. */ + bcreg_reserve(fs, 1); + } +} + +/* Adjust LHS/RHS of an assignment. */ +static void assign_adjust(LexState *ls, BCReg nvars, BCReg nexps, ExpDesc *e) +{ + FuncState *fs = ls->fs; + int32_t extra = (int32_t)nvars - (int32_t)nexps; + if (e->k == VCALL) { + extra++; /* Compensate for the VCALL itself. */ + if (extra < 0) extra = 0; + setbc_b(bcptr(fs, e), extra+1); /* Fixup call results. */ + if (extra > 1) bcreg_reserve(fs, (BCReg)extra-1); + } else { + if (e->k != VVOID) + expr_tonextreg(fs, e); /* Close last expression. */ + if (extra > 0) { /* Leftover LHS are set to nil. */ + BCReg reg = fs->freereg; + bcreg_reserve(fs, (BCReg)extra); + bcemit_nil(fs, reg, (BCReg)extra); + } + } + if (nexps > nvars) + ls->fs->freereg -= nexps - nvars; /* Drop leftover regs. */ +} + +/* Recursively parse assignment statement. */ +static void parse_assignment(LexState *ls, LHSVarList *lh, BCReg nvars) +{ + ExpDesc e; + checkcond(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED, LJ_ERR_XSYNTAX); + if (lex_opt(ls, ',')) { /* Collect LHS list and recurse upwards. */ + LHSVarList vl; + vl.prev = lh; + expr_primary(ls, &vl.v); + if (vl.v.k == VLOCAL) + assign_hazard(ls, lh, &vl.v); + checklimit(ls->fs, ls->level + nvars, LJ_MAX_XLEVEL, "variable names"); + parse_assignment(ls, &vl, nvars+1); + } else { /* Parse RHS. */ + BCReg nexps; + lex_check(ls, '='); + nexps = expr_list(ls, &e); + if (nexps == nvars) { + if (e.k == VCALL) { + if (bc_op(*bcptr(ls->fs, &e)) == BC_VARG) { /* Vararg assignment. */ + ls->fs->freereg--; + e.k = VRELOCABLE; + } else { /* Multiple call results. */ + e.u.s.info = e.u.s.aux; /* Base of call is not relocatable. */ + e.k = VNONRELOC; + } + } + bcemit_store(ls->fs, &lh->v, &e); + return; + } + assign_adjust(ls, nvars, nexps, &e); + } + /* Assign RHS to LHS and recurse downwards. */ + expr_init(&e, VNONRELOC, ls->fs->freereg-1); + bcemit_store(ls->fs, &lh->v, &e); +} + +/* Parse call statement or assignment. */ +static void parse_call_assign(LexState *ls) +{ + FuncState *fs = ls->fs; + LHSVarList vl; + expr_primary(ls, &vl.v); + if (vl.v.k == VCALL) { /* Function call statement. */ + setbc_b(bcptr(fs, &vl.v), 1); /* No results. */ + } else { /* Start of an assignment. */ + vl.prev = NULL; + parse_assignment(ls, &vl, 1); + } +} + +/* Parse 'local' statement. */ +static void parse_local(LexState *ls) +{ + if (lex_opt(ls, TK_function)) { /* Local function declaration. */ + ExpDesc v, b; + FuncState *fs = ls->fs; + var_new(ls, 0, lex_str(ls)); + expr_init(&v, VLOCAL, fs->freereg); + v.u.s.aux = fs->varmap[fs->freereg]; + bcreg_reserve(fs, 1); + var_add(ls, 1); + parse_body(ls, &b, 0, ls->linenumber); + /* bcemit_store(fs, &v, &b) without setting VSTACK_VAR_RW. */ + expr_free(fs, &b); + expr_toreg(fs, &b, v.u.s.info); + /* The upvalue is in scope, but the local is only valid after the store. */ + var_get(ls, fs, fs->nactvar - 1).startpc = fs->pc; + } else { /* Local variable declaration. */ + ExpDesc e; + BCReg nexps, nvars = 0; + do { /* Collect LHS. */ + var_new(ls, nvars++, lex_str(ls)); + } while (lex_opt(ls, ',')); + if (lex_opt(ls, '=')) { /* Optional RHS. */ + nexps = expr_list(ls, &e); + } else { /* Or implicitly set to nil. */ + e.k = VVOID; + nexps = 0; + } + assign_adjust(ls, nvars, nexps, &e); + var_add(ls, nvars); + } +} + +/* Parse 'function' statement. */ +static void parse_func(LexState *ls, BCLine line) +{ + FuncState *fs; + ExpDesc v, b; + int needself = 0; + lj_lex_next(ls); /* Skip 'function'. */ + /* Parse function name. */ + var_lookup(ls, &v); + while (ls->token == '.') /* Multiple dot-separated fields. */ + expr_field(ls, &v); + if (ls->token == ':') { /* Optional colon to signify method call. */ + needself = 1; + expr_field(ls, &v); + } + parse_body(ls, &b, needself, line); + fs = ls->fs; + bcemit_store(fs, &v, &b); + fs->bcbase[fs->pc - 1].line = line; /* Set line for the store. */ +} + +/* -- Control transfer statements ----------------------------------------- */ + +/* Check for end of block. */ +static int endofblock(LexToken token) +{ + switch (token) { + case TK_else: case TK_elseif: case TK_end: case TK_until: case TK_eof: + return 1; + default: + return 0; + } +} + +/* Parse 'return' statement. */ +static void parse_return(LexState *ls) +{ + BCIns ins; + FuncState *fs = ls->fs; + lj_lex_next(ls); /* Skip 'return'. */ + fs->flags |= PROTO_HAS_RETURN; + if (endofblock(ls->token) || ls->token == ';') { /* Bare return. */ + ins = BCINS_AD(BC_RET0, 0, 1); + } else { /* Return with one or more values. */ + ExpDesc e; /* Receives the _last_ expression in the list. */ + BCReg nret = expr_list(ls, &e); + if (nret == 1) { /* Return one result. */ + if (e.k == VCALL) { /* Check for tail call. */ + BCIns *ip = bcptr(fs, &e); + /* It doesn't pay off to add BC_VARGT just for 'return ...'. */ + if (bc_op(*ip) == BC_VARG) goto notailcall; + fs->pc--; + ins = BCINS_AD(bc_op(*ip)-BC_CALL+BC_CALLT, bc_a(*ip), bc_c(*ip)); + } else { /* Can return the result from any register. */ + ins = BCINS_AD(BC_RET1, expr_toanyreg(fs, &e), 2); + } + } else { + if (e.k == VCALL) { /* Append all results from a call. */ + notailcall: + setbc_b(bcptr(fs, &e), 0); + ins = BCINS_AD(BC_RETM, fs->nactvar, e.u.s.aux - fs->nactvar); + } else { + expr_tonextreg(fs, &e); /* Force contiguous registers. */ + ins = BCINS_AD(BC_RET, fs->nactvar, nret+1); + } + } + } + if (fs->flags & PROTO_CHILD) + bcemit_AJ(fs, BC_UCLO, 0, 0); /* May need to close upvalues first. */ + bcemit_INS(fs, ins); +} + +/* Parse 'break' statement. */ +static void parse_break(LexState *ls) +{ + ls->fs->bl->flags |= FSCOPE_BREAK; + gola_new(ls, NAME_BREAK, VSTACK_GOTO, bcemit_jmp(ls->fs)); +} + +/* Parse 'goto' statement. */ +static void parse_goto(LexState *ls) +{ + FuncState *fs = ls->fs; + GCstr *name = lex_str(ls); + VarInfo *vl = gola_findlabel(ls, name); + if (vl) /* Treat backwards goto within same scope like a loop. */ + bcemit_AJ(fs, BC_LOOP, vl->slot, -1); /* No BC range check. */ + fs->bl->flags |= FSCOPE_GOLA; + gola_new(ls, name, VSTACK_GOTO, bcemit_jmp(fs)); +} + +/* Parse label. */ +static void parse_label(LexState *ls) +{ + FuncState *fs = ls->fs; + GCstr *name; + MSize idx; + fs->lasttarget = fs->pc; + fs->bl->flags |= FSCOPE_GOLA; + lj_lex_next(ls); /* Skip '::'. */ + name = lex_str(ls); + if (gola_findlabel(ls, name)) + lj_lex_error(ls, 0, LJ_ERR_XLDUP, strdata(name)); + idx = gola_new(ls, name, VSTACK_LABEL, fs->pc); + lex_check(ls, TK_label); + /* Recursively parse trailing statements: labels and ';' (Lua 5.2 only). */ + for (;;) { + if (ls->token == TK_label) { + synlevel_begin(ls); + parse_label(ls); + synlevel_end(ls); + } else if (LJ_52 && ls->token == ';') { + lj_lex_next(ls); + } else { + break; + } + } + /* Trailing label is considered to be outside of scope. */ + if (endofblock(ls->token) && ls->token != TK_until) + ls->vstack[idx].slot = fs->bl->nactvar; + gola_resolve(ls, fs->bl, idx); +} + +/* -- Blocks, loops and conditional statements ---------------------------- */ + +/* Parse a block. */ +static void parse_block(LexState *ls) +{ + FuncState *fs = ls->fs; + FuncScope bl; + fscope_begin(fs, &bl, 0); + parse_chunk(ls); + fscope_end(fs); +} + +/* Parse 'while' statement. */ +static void parse_while(LexState *ls, BCLine line) +{ + FuncState *fs = ls->fs; + BCPos start, loop, condexit; + FuncScope bl; + lj_lex_next(ls); /* Skip 'while'. */ + start = fs->lasttarget = fs->pc; + condexit = expr_cond(ls); + fscope_begin(fs, &bl, FSCOPE_LOOP); + lex_check(ls, TK_do); + loop = bcemit_AD(fs, BC_LOOP, fs->nactvar, 0); + parse_block(ls); + jmp_patch(fs, bcemit_jmp(fs), start); + lex_match(ls, TK_end, TK_while, line); + fscope_end(fs); + jmp_tohere(fs, condexit); + jmp_patchins(fs, loop, fs->pc); +} + +/* Parse 'repeat' statement. */ +static void parse_repeat(LexState *ls, BCLine line) +{ + FuncState *fs = ls->fs; + BCPos loop = fs->lasttarget = fs->pc; + BCPos condexit; + FuncScope bl1, bl2; + fscope_begin(fs, &bl1, FSCOPE_LOOP); /* Breakable loop scope. */ + fscope_begin(fs, &bl2, 0); /* Inner scope. */ + lj_lex_next(ls); /* Skip 'repeat'. */ + bcemit_AD(fs, BC_LOOP, fs->nactvar, 0); + parse_chunk(ls); + lex_match(ls, TK_until, TK_repeat, line); + condexit = expr_cond(ls); /* Parse condition (still inside inner scope). */ + if (!(bl2.flags & FSCOPE_UPVAL)) { /* No upvalues? Just end inner scope. */ + fscope_end(fs); + } else { /* Otherwise generate: cond: UCLO+JMP out, !cond: UCLO+JMP loop. */ + parse_break(ls); /* Break from loop and close upvalues. */ + jmp_tohere(fs, condexit); + fscope_end(fs); /* End inner scope and close upvalues. */ + condexit = bcemit_jmp(fs); + } + jmp_patch(fs, condexit, loop); /* Jump backwards if !cond. */ + jmp_patchins(fs, loop, fs->pc); + fscope_end(fs); /* End loop scope. */ +} + +/* Parse numeric 'for'. */ +static void parse_for_num(LexState *ls, GCstr *varname, BCLine line) +{ + FuncState *fs = ls->fs; + BCReg base = fs->freereg; + FuncScope bl; + BCPos loop, loopend; + /* Hidden control variables. */ + var_new_fixed(ls, FORL_IDX, VARNAME_FOR_IDX); + var_new_fixed(ls, FORL_STOP, VARNAME_FOR_STOP); + var_new_fixed(ls, FORL_STEP, VARNAME_FOR_STEP); + /* Visible copy of index variable. */ + var_new(ls, FORL_EXT, varname); + lex_check(ls, '='); + expr_next(ls); + lex_check(ls, ','); + expr_next(ls); + if (lex_opt(ls, ',')) { + expr_next(ls); + } else { + bcemit_AD(fs, BC_KSHORT, fs->freereg, 1); /* Default step is 1. */ + bcreg_reserve(fs, 1); + } + var_add(ls, 3); /* Hidden control variables. */ + lex_check(ls, TK_do); + loop = bcemit_AJ(fs, BC_FORI, base, NO_JMP); + fscope_begin(fs, &bl, 0); /* Scope for visible variables. */ + var_add(ls, 1); + bcreg_reserve(fs, 1); + parse_block(ls); + fscope_end(fs); + /* Perform loop inversion. Loop control instructions are at the end. */ + loopend = bcemit_AJ(fs, BC_FORL, base, NO_JMP); + fs->bcbase[loopend].line = line; /* Fix line for control ins. */ + jmp_patchins(fs, loopend, loop+1); + jmp_patchins(fs, loop, fs->pc); +} + +/* Try to predict whether the iterator is next() and specialize the bytecode. +** Detecting next() and pairs() by name is simplistic, but quite effective. +** The interpreter backs off if the check for the closure fails at runtime. +*/ +static int predict_next(LexState *ls, FuncState *fs, BCPos pc) +{ + BCIns ins = fs->bcbase[pc].ins; + GCstr *name; + cTValue *o; + switch (bc_op(ins)) { + case BC_MOV: + name = gco2str(gcref(var_get(ls, fs, bc_d(ins)).name)); + break; + case BC_UGET: + name = gco2str(gcref(ls->vstack[fs->uvmap[bc_d(ins)]].name)); + break; + case BC_GGET: + /* There's no inverse index (yet), so lookup the strings. */ + o = lj_tab_getstr(fs->kt, lj_str_newlit(ls->L, "pairs")); + if (o && tvhaskslot(o) && tvkslot(o) == bc_d(ins)) + return 1; + o = lj_tab_getstr(fs->kt, lj_str_newlit(ls->L, "next")); + if (o && tvhaskslot(o) && tvkslot(o) == bc_d(ins)) + return 1; + return 0; + default: + return 0; + } + return (name->len == 5 && !strcmp(strdata(name), "pairs")) || + (name->len == 4 && !strcmp(strdata(name), "next")); +} + +/* Parse 'for' iterator. */ +static void parse_for_iter(LexState *ls, GCstr *indexname) +{ + FuncState *fs = ls->fs; + ExpDesc e; + BCReg nvars = 0; + BCLine line; + BCReg base = fs->freereg + 3; + BCPos loop, loopend, exprpc = fs->pc; + FuncScope bl; + int isnext; + /* Hidden control variables. */ + var_new_fixed(ls, nvars++, VARNAME_FOR_GEN); + var_new_fixed(ls, nvars++, VARNAME_FOR_STATE); + var_new_fixed(ls, nvars++, VARNAME_FOR_CTL); + /* Visible variables returned from iterator. */ + var_new(ls, nvars++, indexname); + while (lex_opt(ls, ',')) + var_new(ls, nvars++, lex_str(ls)); + lex_check(ls, TK_in); + line = ls->linenumber; + assign_adjust(ls, 3, expr_list(ls, &e), &e); + bcreg_bump(fs, 3); /* The iterator needs another 3 slots (func + 2 args). */ + isnext = (nvars <= 5 && predict_next(ls, fs, exprpc)); + var_add(ls, 3); /* Hidden control variables. */ + lex_check(ls, TK_do); + loop = bcemit_AJ(fs, isnext ? BC_ISNEXT : BC_JMP, base, NO_JMP); + fscope_begin(fs, &bl, 0); /* Scope for visible variables. */ + var_add(ls, nvars-3); + bcreg_reserve(fs, nvars-3); + parse_block(ls); + fscope_end(fs); + /* Perform loop inversion. Loop control instructions are at the end. */ + jmp_patchins(fs, loop, fs->pc); + bcemit_ABC(fs, isnext ? BC_ITERN : BC_ITERC, base, nvars-3+1, 2+1); + loopend = bcemit_AJ(fs, BC_ITERL, base, NO_JMP); + fs->bcbase[loopend-1].line = line; /* Fix line for control ins. */ + fs->bcbase[loopend].line = line; + jmp_patchins(fs, loopend, loop+1); +} + +/* Parse 'for' statement. */ +static void parse_for(LexState *ls, BCLine line) +{ + FuncState *fs = ls->fs; + GCstr *varname; + FuncScope bl; + fscope_begin(fs, &bl, FSCOPE_LOOP); + lj_lex_next(ls); /* Skip 'for'. */ + varname = lex_str(ls); /* Get first variable name. */ + if (ls->token == '=') + parse_for_num(ls, varname, line); + else if (ls->token == ',' || ls->token == TK_in) + parse_for_iter(ls, varname); + else + err_syntax(ls, LJ_ERR_XFOR); + lex_match(ls, TK_end, TK_for, line); + fscope_end(fs); /* Resolve break list. */ +} + +/* Parse condition and 'then' block. */ +static BCPos parse_then(LexState *ls) +{ + BCPos condexit; + lj_lex_next(ls); /* Skip 'if' or 'elseif'. */ + condexit = expr_cond(ls); + lex_check(ls, TK_then); + parse_block(ls); + return condexit; +} + +/* Parse 'if' statement. */ +static void parse_if(LexState *ls, BCLine line) +{ + FuncState *fs = ls->fs; + BCPos flist; + BCPos escapelist = NO_JMP; + flist = parse_then(ls); + while (ls->token == TK_elseif) { /* Parse multiple 'elseif' blocks. */ + jmp_append(fs, &escapelist, bcemit_jmp(fs)); + jmp_tohere(fs, flist); + flist = parse_then(ls); + } + if (ls->token == TK_else) { /* Parse optional 'else' block. */ + jmp_append(fs, &escapelist, bcemit_jmp(fs)); + jmp_tohere(fs, flist); + lj_lex_next(ls); /* Skip 'else'. */ + parse_block(ls); + } else { + jmp_append(fs, &escapelist, flist); + } + jmp_tohere(fs, escapelist); + lex_match(ls, TK_end, TK_if, line); +} + +/* -- Parse statements ---------------------------------------------------- */ + +/* Parse a statement. Returns 1 if it must be the last one in a chunk. */ +static int parse_stmt(LexState *ls) +{ + BCLine line = ls->linenumber; + switch (ls->token) { + case TK_if: + parse_if(ls, line); + break; + case TK_while: + parse_while(ls, line); + break; + case TK_do: + lj_lex_next(ls); + parse_block(ls); + lex_match(ls, TK_end, TK_do, line); + break; + case TK_for: + parse_for(ls, line); + break; + case TK_repeat: + parse_repeat(ls, line); + break; + case TK_function: + parse_func(ls, line); + break; + case TK_local: + lj_lex_next(ls); + parse_local(ls); + break; + case TK_return: + parse_return(ls); + return 1; /* Must be last. */ + case TK_break: + lj_lex_next(ls); + parse_break(ls); + return !LJ_52; /* Must be last in Lua 5.1. */ +#if LJ_52 + case ';': + lj_lex_next(ls); + break; +#endif + case TK_label: + parse_label(ls); + break; + case TK_goto: + if (LJ_52 || lj_lex_lookahead(ls) == TK_name) { + lj_lex_next(ls); + parse_goto(ls); + break; + } /* else: fallthrough */ + default: + parse_call_assign(ls); + break; + } + return 0; +} + +/* A chunk is a list of statements optionally separated by semicolons. */ +static void parse_chunk(LexState *ls) +{ + int islast = 0; + synlevel_begin(ls); + while (!islast && !endofblock(ls->token)) { + islast = parse_stmt(ls); + lex_opt(ls, ';'); + lua_assert(ls->fs->framesize >= ls->fs->freereg && + ls->fs->freereg >= ls->fs->nactvar); + ls->fs->freereg = ls->fs->nactvar; /* Free registers after each stmt. */ + } + synlevel_end(ls); +} + +/* Entry point of bytecode parser. */ +GCproto *lj_parse(LexState *ls) +{ + FuncState fs; + FuncScope bl; + GCproto *pt; + lua_State *L = ls->L; +#ifdef LUAJIT_DISABLE_DEBUGINFO + ls->chunkname = lj_str_newlit(L, "="); +#else + ls->chunkname = lj_str_newz(L, ls->chunkarg); +#endif + setstrV(L, L->top, ls->chunkname); /* Anchor chunkname string. */ + incr_top(L); + ls->level = 0; + fs_init(ls, &fs); + fs.linedefined = 0; + fs.numparams = 0; + fs.bcbase = NULL; + fs.bclim = 0; + fs.flags |= PROTO_VARARG; /* Main chunk is always a vararg func. */ + fscope_begin(&fs, &bl, 0); + bcemit_AD(&fs, BC_FUNCV, 0, 0); /* Placeholder. */ + lj_lex_next(ls); /* Read-ahead first token. */ + parse_chunk(ls); + if (ls->token != TK_eof) + err_token(ls, TK_eof); + pt = fs_finish(ls, ls->linenumber); + L->top--; /* Drop chunkname. */ + lua_assert(fs.prev == NULL); + lua_assert(ls->fs == NULL); + lua_assert(pt->sizeuv == 0); + return pt; +} + + +``` + +`include/luajit-2.0.5/src/lj_parse.h`: + +```h +/* +** Lua parser (source code -> bytecode). +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_PARSE_H +#define _LJ_PARSE_H + +#include "lj_obj.h" +#include "lj_lex.h" + +LJ_FUNC GCproto *lj_parse(LexState *ls); +LJ_FUNC GCstr *lj_parse_keepstr(LexState *ls, const char *str, size_t l); +#if LJ_HASFFI +LJ_FUNC void lj_parse_keepcdata(LexState *ls, TValue *tv, GCcdata *cd); +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_record.c`: + +```c +/* +** Trace recorder (bytecode -> SSA IR). +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_record_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_meta.h" +#include "lj_frame.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#endif +#include "lj_bc.h" +#include "lj_ff.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_ircall.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#include "lj_record.h" +#include "lj_ffrecord.h" +#include "lj_snap.h" +#include "lj_dispatch.h" +#include "lj_vm.h" + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +/* Emit raw IR without passing through optimizations. */ +#define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) + +/* -- Sanity checks ------------------------------------------------------- */ + +#ifdef LUA_USE_ASSERT +/* Sanity check the whole IR -- sloooow. */ +static void rec_check_ir(jit_State *J) +{ + IRRef i, nins = J->cur.nins, nk = J->cur.nk; + lua_assert(nk <= REF_BIAS && nins >= REF_BIAS && nins < 65536); + for (i = nins-1; i >= nk; i--) { + IRIns *ir = IR(i); + uint32_t mode = lj_ir_mode[ir->o]; + IRRef op1 = ir->op1; + IRRef op2 = ir->op2; + switch (irm_op1(mode)) { + case IRMnone: lua_assert(op1 == 0); break; + case IRMref: lua_assert(op1 >= nk); + lua_assert(i >= REF_BIAS ? op1 < i : op1 > i); break; + case IRMlit: break; + case IRMcst: lua_assert(i < REF_BIAS); continue; + } + switch (irm_op2(mode)) { + case IRMnone: lua_assert(op2 == 0); break; + case IRMref: lua_assert(op2 >= nk); + lua_assert(i >= REF_BIAS ? op2 < i : op2 > i); break; + case IRMlit: break; + case IRMcst: lua_assert(0); break; + } + if (ir->prev) { + lua_assert(ir->prev >= nk); + lua_assert(i >= REF_BIAS ? ir->prev < i : ir->prev > i); + lua_assert(ir->o == IR_NOP || IR(ir->prev)->o == ir->o); + } + } +} + +/* Compare stack slots and frames of the recorder and the VM. */ +static void rec_check_slots(jit_State *J) +{ + BCReg s, nslots = J->baseslot + J->maxslot; + int32_t depth = 0; + cTValue *base = J->L->base - J->baseslot; + lua_assert(J->baseslot >= 1 && J->baseslot < LJ_MAX_JSLOTS); + lua_assert(J->baseslot == 1 || (J->slot[J->baseslot-1] & TREF_FRAME)); + lua_assert(nslots < LJ_MAX_JSLOTS); + for (s = 0; s < nslots; s++) { + TRef tr = J->slot[s]; + if (tr) { + cTValue *tv = &base[s]; + IRRef ref = tref_ref(tr); + IRIns *ir; + lua_assert(ref >= J->cur.nk && ref < J->cur.nins); + ir = IR(ref); + lua_assert(irt_t(ir->t) == tref_t(tr)); + if (s == 0) { + lua_assert(tref_isfunc(tr)); + } else if ((tr & TREF_FRAME)) { + GCfunc *fn = gco2func(frame_gc(tv)); + BCReg delta = (BCReg)(tv - frame_prev(tv)); + lua_assert(tref_isfunc(tr)); + if (tref_isk(tr)) lua_assert(fn == ir_kfunc(ir)); + lua_assert(s > delta ? (J->slot[s-delta] & TREF_FRAME) : (s == delta)); + depth++; + } else if ((tr & TREF_CONT)) { + lua_assert(ir_kptr(ir) == gcrefp(tv->gcr, void)); + lua_assert((J->slot[s+1] & TREF_FRAME)); + depth++; + } else { + if (tvisnumber(tv)) + lua_assert(tref_isnumber(tr)); /* Could be IRT_INT etc., too. */ + else + lua_assert(itype2irt(tv) == tref_type(tr)); + if (tref_isk(tr)) { /* Compare constants. */ + TValue tvk; + lj_ir_kvalue(J->L, &tvk, ir); + if (!(tvisnum(&tvk) && tvisnan(&tvk))) + lua_assert(lj_obj_equal(tv, &tvk)); + else + lua_assert(tvisnum(tv) && tvisnan(tv)); + } + } + } + } + lua_assert(J->framedepth == depth); +} +#endif + +/* -- Type handling and specialization ------------------------------------ */ + +/* Note: these functions return tagged references (TRef). */ + +/* Specialize a slot to a specific type. Note: slot can be negative! */ +static TRef sloadt(jit_State *J, int32_t slot, IRType t, int mode) +{ + /* Caller may set IRT_GUARD in t. */ + TRef ref = emitir_raw(IRT(IR_SLOAD, t), (int32_t)J->baseslot+slot, mode); + J->base[slot] = ref; + return ref; +} + +/* Specialize a slot to the runtime type. Note: slot can be negative! */ +static TRef sload(jit_State *J, int32_t slot) +{ + IRType t = itype2irt(&J->L->base[slot]); + TRef ref = emitir_raw(IRTG(IR_SLOAD, t), (int32_t)J->baseslot+slot, + IRSLOAD_TYPECHECK); + if (irtype_ispri(t)) ref = TREF_PRI(t); /* Canonicalize primitive refs. */ + J->base[slot] = ref; + return ref; +} + +/* Get TRef from slot. Load slot and specialize if not done already. */ +#define getslot(J, s) (J->base[(s)] ? J->base[(s)] : sload(J, (int32_t)(s))) + +/* Get TRef for current function. */ +static TRef getcurrf(jit_State *J) +{ + if (J->base[-1]) + return J->base[-1]; + lua_assert(J->baseslot == 1); + return sloadt(J, -1, IRT_FUNC, IRSLOAD_READONLY); +} + +/* Compare for raw object equality. +** Returns 0 if the objects are the same. +** Returns 1 if they are different, but the same type. +** Returns 2 for two different types. +** Comparisons between primitives always return 1 -- no caller cares about it. +*/ +int lj_record_objcmp(jit_State *J, TRef a, TRef b, cTValue *av, cTValue *bv) +{ + int diff = !lj_obj_equal(av, bv); + if (!tref_isk2(a, b)) { /* Shortcut, also handles primitives. */ + IRType ta = tref_isinteger(a) ? IRT_INT : tref_type(a); + IRType tb = tref_isinteger(b) ? IRT_INT : tref_type(b); + if (ta != tb) { + /* Widen mixed number/int comparisons to number/number comparison. */ + if (ta == IRT_INT && tb == IRT_NUM) { + a = emitir(IRTN(IR_CONV), a, IRCONV_NUM_INT); + ta = IRT_NUM; + } else if (ta == IRT_NUM && tb == IRT_INT) { + b = emitir(IRTN(IR_CONV), b, IRCONV_NUM_INT); + } else { + return 2; /* Two different types are never equal. */ + } + } + emitir(IRTG(diff ? IR_NE : IR_EQ, ta), a, b); + } + return diff; +} + +/* Constify a value. Returns 0 for non-representable object types. */ +TRef lj_record_constify(jit_State *J, cTValue *o) +{ + if (tvisgcv(o)) + return lj_ir_kgc(J, gcV(o), itype2irt(o)); + else if (tvisint(o)) + return lj_ir_kint(J, intV(o)); + else if (tvisnum(o)) + return lj_ir_knumint(J, numV(o)); + else if (tvisbool(o)) + return TREF_PRI(itype2irt(o)); + else + return 0; /* Can't represent lightuserdata (pointless). */ +} + +/* -- Record loop ops ----------------------------------------------------- */ + +/* Loop event. */ +typedef enum { + LOOPEV_LEAVE, /* Loop is left or not entered. */ + LOOPEV_ENTERLO, /* Loop is entered with a low iteration count left. */ + LOOPEV_ENTER /* Loop is entered. */ +} LoopEvent; + +/* Canonicalize slots: convert integers to numbers. */ +static void canonicalize_slots(jit_State *J) +{ + BCReg s; + if (LJ_DUALNUM) return; + for (s = J->baseslot+J->maxslot-1; s >= 1; s--) { + TRef tr = J->slot[s]; + if (tref_isinteger(tr)) { + IRIns *ir = IR(tref_ref(tr)); + if (!(ir->o == IR_SLOAD && (ir->op2 & IRSLOAD_READONLY))) + J->slot[s] = emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT); + } + } +} + +/* Stop recording. */ +static void rec_stop(jit_State *J, TraceLink linktype, TraceNo lnk) +{ + lj_trace_end(J); + J->cur.linktype = (uint8_t)linktype; + J->cur.link = (uint16_t)lnk; + /* Looping back at the same stack level? */ + if (lnk == J->cur.traceno && J->framedepth + J->retdepth == 0) { + if ((J->flags & JIT_F_OPT_LOOP)) /* Shall we try to create a loop? */ + goto nocanon; /* Do not canonicalize or we lose the narrowing. */ + if (J->cur.root) /* Otherwise ensure we always link to the root trace. */ + J->cur.link = J->cur.root; + } + canonicalize_slots(J); +nocanon: + /* Note: all loop ops must set J->pc to the following instruction! */ + lj_snap_add(J); /* Add loop snapshot. */ + J->needsnap = 0; + J->mergesnap = 1; /* In case recording continues. */ +} + +/* Search bytecode backwards for a int/num constant slot initializer. */ +static TRef find_kinit(jit_State *J, const BCIns *endpc, BCReg slot, IRType t) +{ + /* This algorithm is rather simplistic and assumes quite a bit about + ** how the bytecode is generated. It works fine for FORI initializers, + ** but it won't necessarily work in other cases (e.g. iterator arguments). + ** It doesn't do anything fancy, either (like backpropagating MOVs). + */ + const BCIns *pc, *startpc = proto_bc(J->pt); + for (pc = endpc-1; pc > startpc; pc--) { + BCIns ins = *pc; + BCOp op = bc_op(ins); + /* First try to find the last instruction that stores to this slot. */ + if (bcmode_a(op) == BCMbase && bc_a(ins) <= slot) { + return 0; /* Multiple results, e.g. from a CALL or KNIL. */ + } else if (bcmode_a(op) == BCMdst && bc_a(ins) == slot) { + if (op == BC_KSHORT || op == BC_KNUM) { /* Found const. initializer. */ + /* Now try to verify there's no forward jump across it. */ + const BCIns *kpc = pc; + for (; pc > startpc; pc--) + if (bc_op(*pc) == BC_JMP) { + const BCIns *target = pc+bc_j(*pc)+1; + if (target > kpc && target <= endpc) + return 0; /* Conditional assignment. */ + } + if (op == BC_KSHORT) { + int32_t k = (int32_t)(int16_t)bc_d(ins); + return t == IRT_INT ? lj_ir_kint(J, k) : lj_ir_knum(J, (lua_Number)k); + } else { + cTValue *tv = proto_knumtv(J->pt, bc_d(ins)); + if (t == IRT_INT) { + int32_t k = numberVint(tv); + if (tvisint(tv) || numV(tv) == (lua_Number)k) /* -0 is ok here. */ + return lj_ir_kint(J, k); + return 0; /* Type mismatch. */ + } else { + return lj_ir_knum(J, numberVnum(tv)); + } + } + } + return 0; /* Non-constant initializer. */ + } + } + return 0; /* No assignment to this slot found? */ +} + +/* Load and optionally convert a FORI argument from a slot. */ +static TRef fori_load(jit_State *J, BCReg slot, IRType t, int mode) +{ + int conv = (tvisint(&J->L->base[slot]) != (t==IRT_INT)) ? IRSLOAD_CONVERT : 0; + return sloadt(J, (int32_t)slot, + t + (((mode & IRSLOAD_TYPECHECK) || + (conv && t == IRT_INT && !(mode >> 16))) ? + IRT_GUARD : 0), + mode + conv); +} + +/* Peek before FORI to find a const initializer. Otherwise load from slot. */ +static TRef fori_arg(jit_State *J, const BCIns *fori, BCReg slot, + IRType t, int mode) +{ + TRef tr = J->base[slot]; + if (!tr) { + tr = find_kinit(J, fori, slot, t); + if (!tr) + tr = fori_load(J, slot, t, mode); + } + return tr; +} + +/* Return the direction of the FOR loop iterator. +** It's important to exactly reproduce the semantics of the interpreter. +*/ +static int rec_for_direction(cTValue *o) +{ + return (tvisint(o) ? intV(o) : (int32_t)o->u32.hi) >= 0; +} + +/* Simulate the runtime behavior of the FOR loop iterator. */ +static LoopEvent rec_for_iter(IROp *op, cTValue *o, int isforl) +{ + lua_Number stopv = numberVnum(&o[FORL_STOP]); + lua_Number idxv = numberVnum(&o[FORL_IDX]); + lua_Number stepv = numberVnum(&o[FORL_STEP]); + if (isforl) + idxv += stepv; + if (rec_for_direction(&o[FORL_STEP])) { + if (idxv <= stopv) { + *op = IR_LE; + return idxv + 2*stepv > stopv ? LOOPEV_ENTERLO : LOOPEV_ENTER; + } + *op = IR_GT; return LOOPEV_LEAVE; + } else { + if (stopv <= idxv) { + *op = IR_GE; + return idxv + 2*stepv < stopv ? LOOPEV_ENTERLO : LOOPEV_ENTER; + } + *op = IR_LT; return LOOPEV_LEAVE; + } +} + +/* Record checks for FOR loop overflow and step direction. */ +static void rec_for_check(jit_State *J, IRType t, int dir, + TRef stop, TRef step, int init) +{ + if (!tref_isk(step)) { + /* Non-constant step: need a guard for the direction. */ + TRef zero = (t == IRT_INT) ? lj_ir_kint(J, 0) : lj_ir_knum_zero(J); + emitir(IRTG(dir ? IR_GE : IR_LT, t), step, zero); + /* Add hoistable overflow checks for a narrowed FORL index. */ + if (init && t == IRT_INT) { + if (tref_isk(stop)) { + /* Constant stop: optimize check away or to a range check for step. */ + int32_t k = IR(tref_ref(stop))->i; + if (dir) { + if (k > 0) + emitir(IRTGI(IR_LE), step, lj_ir_kint(J, (int32_t)0x7fffffff-k)); + } else { + if (k < 0) + emitir(IRTGI(IR_GE), step, lj_ir_kint(J, (int32_t)0x80000000-k)); + } + } else { + /* Stop+step variable: need full overflow check. */ + TRef tr = emitir(IRTGI(IR_ADDOV), step, stop); + emitir(IRTI(IR_USE), tr, 0); /* ADDOV is weak. Avoid dead result. */ + } + } + } else if (init && t == IRT_INT && !tref_isk(stop)) { + /* Constant step: optimize overflow check to a range check for stop. */ + int32_t k = IR(tref_ref(step))->i; + k = (int32_t)(dir ? 0x7fffffff : 0x80000000) - k; + emitir(IRTGI(dir ? IR_LE : IR_GE), stop, lj_ir_kint(J, k)); + } +} + +/* Record a FORL instruction. */ +static void rec_for_loop(jit_State *J, const BCIns *fori, ScEvEntry *scev, + int init) +{ + BCReg ra = bc_a(*fori); + cTValue *tv = &J->L->base[ra]; + TRef idx = J->base[ra+FORL_IDX]; + IRType t = idx ? tref_type(idx) : + (init || LJ_DUALNUM) ? lj_opt_narrow_forl(J, tv) : IRT_NUM; + int mode = IRSLOAD_INHERIT + + ((!LJ_DUALNUM || tvisint(tv) == (t == IRT_INT)) ? IRSLOAD_READONLY : 0); + TRef stop = fori_arg(J, fori, ra+FORL_STOP, t, mode); + TRef step = fori_arg(J, fori, ra+FORL_STEP, t, mode); + int tc, dir = rec_for_direction(&tv[FORL_STEP]); + lua_assert(bc_op(*fori) == BC_FORI || bc_op(*fori) == BC_JFORI); + scev->t.irt = t; + scev->dir = dir; + scev->stop = tref_ref(stop); + scev->step = tref_ref(step); + rec_for_check(J, t, dir, stop, step, init); + scev->start = tref_ref(find_kinit(J, fori, ra+FORL_IDX, IRT_INT)); + tc = (LJ_DUALNUM && + !(scev->start && irref_isk(scev->stop) && irref_isk(scev->step) && + tvisint(&tv[FORL_IDX]) == (t == IRT_INT))) ? + IRSLOAD_TYPECHECK : 0; + if (tc) { + J->base[ra+FORL_STOP] = stop; + J->base[ra+FORL_STEP] = step; + } + if (!idx) + idx = fori_load(J, ra+FORL_IDX, t, + IRSLOAD_INHERIT + tc + (J->scev.start << 16)); + if (!init) + J->base[ra+FORL_IDX] = idx = emitir(IRT(IR_ADD, t), idx, step); + J->base[ra+FORL_EXT] = idx; + scev->idx = tref_ref(idx); + setmref(scev->pc, fori); + J->maxslot = ra+FORL_EXT+1; +} + +/* Record FORL/JFORL or FORI/JFORI. */ +static LoopEvent rec_for(jit_State *J, const BCIns *fori, int isforl) +{ + BCReg ra = bc_a(*fori); + TValue *tv = &J->L->base[ra]; + TRef *tr = &J->base[ra]; + IROp op; + LoopEvent ev; + TRef stop; + IRType t; + if (isforl) { /* Handle FORL/JFORL opcodes. */ + TRef idx = tr[FORL_IDX]; + if (mref(J->scev.pc, const BCIns) == fori && tref_ref(idx) == J->scev.idx) { + t = J->scev.t.irt; + stop = J->scev.stop; + idx = emitir(IRT(IR_ADD, t), idx, J->scev.step); + tr[FORL_EXT] = tr[FORL_IDX] = idx; + } else { + ScEvEntry scev; + rec_for_loop(J, fori, &scev, 0); + t = scev.t.irt; + stop = scev.stop; + } + } else { /* Handle FORI/JFORI opcodes. */ + BCReg i; + lj_meta_for(J->L, tv); + t = (LJ_DUALNUM || tref_isint(tr[FORL_IDX])) ? lj_opt_narrow_forl(J, tv) : + IRT_NUM; + for (i = FORL_IDX; i <= FORL_STEP; i++) { + if (!tr[i]) sload(J, ra+i); + lua_assert(tref_isnumber_str(tr[i])); + if (tref_isstr(tr[i])) + tr[i] = emitir(IRTG(IR_STRTO, IRT_NUM), tr[i], 0); + if (t == IRT_INT) { + if (!tref_isinteger(tr[i])) + tr[i] = emitir(IRTGI(IR_CONV), tr[i], IRCONV_INT_NUM|IRCONV_CHECK); + } else { + if (!tref_isnum(tr[i])) + tr[i] = emitir(IRTN(IR_CONV), tr[i], IRCONV_NUM_INT); + } + } + tr[FORL_EXT] = tr[FORL_IDX]; + stop = tr[FORL_STOP]; + rec_for_check(J, t, rec_for_direction(&tv[FORL_STEP]), + stop, tr[FORL_STEP], 1); + } + + ev = rec_for_iter(&op, tv, isforl); + if (ev == LOOPEV_LEAVE) { + J->maxslot = ra+FORL_EXT+1; + J->pc = fori+1; + } else { + J->maxslot = ra; + J->pc = fori+bc_j(*fori)+1; + } + lj_snap_add(J); + + emitir(IRTG(op, t), tr[FORL_IDX], stop); + + if (ev == LOOPEV_LEAVE) { + J->maxslot = ra; + J->pc = fori+bc_j(*fori)+1; + } else { + J->maxslot = ra+FORL_EXT+1; + J->pc = fori+1; + } + J->needsnap = 1; + return ev; +} + +/* Record ITERL/JITERL. */ +static LoopEvent rec_iterl(jit_State *J, const BCIns iterins) +{ + BCReg ra = bc_a(iterins); + lua_assert(J->base[ra] != 0); + if (!tref_isnil(J->base[ra])) { /* Looping back? */ + J->base[ra-1] = J->base[ra]; /* Copy result of ITERC to control var. */ + J->maxslot = ra-1+bc_b(J->pc[-1]); + J->pc += bc_j(iterins)+1; + return LOOPEV_ENTER; + } else { + J->maxslot = ra-3; + J->pc++; + return LOOPEV_LEAVE; + } +} + +/* Record LOOP/JLOOP. Now, that was easy. */ +static LoopEvent rec_loop(jit_State *J, BCReg ra) +{ + if (ra < J->maxslot) J->maxslot = ra; + J->pc++; + return LOOPEV_ENTER; +} + +/* Check if a loop repeatedly failed to trace because it didn't loop back. */ +static int innerloopleft(jit_State *J, const BCIns *pc) +{ + ptrdiff_t i; + for (i = 0; i < PENALTY_SLOTS; i++) + if (mref(J->penalty[i].pc, const BCIns) == pc) { + if ((J->penalty[i].reason == LJ_TRERR_LLEAVE || + J->penalty[i].reason == LJ_TRERR_LINNER) && + J->penalty[i].val >= 2*PENALTY_MIN) + return 1; + break; + } + return 0; +} + +/* Handle the case when an interpreted loop op is hit. */ +static void rec_loop_interp(jit_State *J, const BCIns *pc, LoopEvent ev) +{ + if (J->parent == 0) { + if (pc == J->startpc && J->framedepth + J->retdepth == 0) { + /* Same loop? */ + if (ev == LOOPEV_LEAVE) /* Must loop back to form a root trace. */ + lj_trace_err(J, LJ_TRERR_LLEAVE); + rec_stop(J, LJ_TRLINK_LOOP, J->cur.traceno); /* Looping root trace. */ + } else if (ev != LOOPEV_LEAVE) { /* Entering inner loop? */ + /* It's usually better to abort here and wait until the inner loop + ** is traced. But if the inner loop repeatedly didn't loop back, + ** this indicates a low trip count. In this case try unrolling + ** an inner loop even in a root trace. But it's better to be a bit + ** more conservative here and only do it for very short loops. + */ + if (bc_j(*pc) != -1 && !innerloopleft(J, pc)) + lj_trace_err(J, LJ_TRERR_LINNER); /* Root trace hit an inner loop. */ + if ((ev != LOOPEV_ENTERLO && + J->loopref && J->cur.nins - J->loopref > 24) || --J->loopunroll < 0) + lj_trace_err(J, LJ_TRERR_LUNROLL); /* Limit loop unrolling. */ + J->loopref = J->cur.nins; + } + } else if (ev != LOOPEV_LEAVE) { /* Side trace enters an inner loop. */ + J->loopref = J->cur.nins; + if (--J->loopunroll < 0) + lj_trace_err(J, LJ_TRERR_LUNROLL); /* Limit loop unrolling. */ + } /* Side trace continues across a loop that's left or not entered. */ +} + +/* Handle the case when an already compiled loop op is hit. */ +static void rec_loop_jit(jit_State *J, TraceNo lnk, LoopEvent ev) +{ + if (J->parent == 0) { /* Root trace hit an inner loop. */ + /* Better let the inner loop spawn a side trace back here. */ + lj_trace_err(J, LJ_TRERR_LINNER); + } else if (ev != LOOPEV_LEAVE) { /* Side trace enters a compiled loop. */ + J->instunroll = 0; /* Cannot continue across a compiled loop op. */ + if (J->pc == J->startpc && J->framedepth + J->retdepth == 0) + rec_stop(J, LJ_TRLINK_LOOP, J->cur.traceno); /* Form an extra loop. */ + else + rec_stop(J, LJ_TRLINK_ROOT, lnk); /* Link to the loop. */ + } /* Side trace continues across a loop that's left or not entered. */ +} + +/* -- Record calls and returns -------------------------------------------- */ + +/* Specialize to the runtime value of the called function or its prototype. */ +static TRef rec_call_specialize(jit_State *J, GCfunc *fn, TRef tr) +{ + TRef kfunc; + if (isluafunc(fn)) { + GCproto *pt = funcproto(fn); + /* Too many closures created? Probably not a monomorphic function. */ + if (pt->flags >= PROTO_CLC_POLY) { /* Specialize to prototype instead. */ + TRef trpt = emitir(IRT(IR_FLOAD, IRT_P32), tr, IRFL_FUNC_PC); + emitir(IRTG(IR_EQ, IRT_P32), trpt, lj_ir_kptr(J, proto_bc(pt))); + (void)lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); /* Prevent GC of proto. */ + return tr; + } + } + /* Otherwise specialize to the function (closure) value itself. */ + kfunc = lj_ir_kfunc(J, fn); + emitir(IRTG(IR_EQ, IRT_FUNC), tr, kfunc); + return kfunc; +} + +/* Record call setup. */ +static void rec_call_setup(jit_State *J, BCReg func, ptrdiff_t nargs) +{ + RecordIndex ix; + TValue *functv = &J->L->base[func]; + TRef *fbase = &J->base[func]; + ptrdiff_t i; + for (i = 0; i <= nargs; i++) + (void)getslot(J, func+i); /* Ensure func and all args have a reference. */ + if (!tref_isfunc(fbase[0])) { /* Resolve __call metamethod. */ + ix.tab = fbase[0]; + copyTV(J->L, &ix.tabv, functv); + if (!lj_record_mm_lookup(J, &ix, MM_call) || !tref_isfunc(ix.mobj)) + lj_trace_err(J, LJ_TRERR_NOMM); + for (i = ++nargs; i > 0; i--) /* Shift arguments up. */ + fbase[i] = fbase[i-1]; + fbase[0] = ix.mobj; /* Replace function. */ + functv = &ix.mobjv; + } + fbase[0] = TREF_FRAME | rec_call_specialize(J, funcV(functv), fbase[0]); + J->maxslot = (BCReg)nargs; +} + +/* Record call. */ +void lj_record_call(jit_State *J, BCReg func, ptrdiff_t nargs) +{ + rec_call_setup(J, func, nargs); + /* Bump frame. */ + J->framedepth++; + J->base += func+1; + J->baseslot += func+1; +} + +/* Record tail call. */ +void lj_record_tailcall(jit_State *J, BCReg func, ptrdiff_t nargs) +{ + rec_call_setup(J, func, nargs); + if (frame_isvarg(J->L->base - 1)) { + BCReg cbase = (BCReg)frame_delta(J->L->base - 1); + if (--J->framedepth < 0) + lj_trace_err(J, LJ_TRERR_NYIRETL); + J->baseslot -= (BCReg)cbase; + J->base -= cbase; + func += cbase; + } + /* Move func + args down. */ + memmove(&J->base[-1], &J->base[func], sizeof(TRef)*(J->maxslot+1)); + /* Note: the new TREF_FRAME is now at J->base[-1] (even for slot #0). */ + /* Tailcalls can form a loop, so count towards the loop unroll limit. */ + if (++J->tailcalled > J->loopunroll) + lj_trace_err(J, LJ_TRERR_LUNROLL); +} + +/* Check unroll limits for down-recursion. */ +static int check_downrec_unroll(jit_State *J, GCproto *pt) +{ + IRRef ptref; + for (ptref = J->chain[IR_KGC]; ptref; ptref = IR(ptref)->prev) + if (ir_kgc(IR(ptref)) == obj2gco(pt)) { + int count = 0; + IRRef ref; + for (ref = J->chain[IR_RETF]; ref; ref = IR(ref)->prev) + if (IR(ref)->op1 == ptref) + count++; + if (count) { + if (J->pc == J->startpc) { + if (count + J->tailcalled > J->param[JIT_P_recunroll]) + return 1; + } else { + lj_trace_err(J, LJ_TRERR_DOWNREC); + } + } + } + return 0; +} + +/* Record return. */ +void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults) +{ + TValue *frame = J->L->base - 1; + ptrdiff_t i; + for (i = 0; i < gotresults; i++) + (void)getslot(J, rbase+i); /* Ensure all results have a reference. */ + while (frame_ispcall(frame)) { /* Immediately resolve pcall() returns. */ + BCReg cbase = (BCReg)frame_delta(frame); + if (--J->framedepth <= 0) + lj_trace_err(J, LJ_TRERR_NYIRETL); + lua_assert(J->baseslot > 1); + gotresults++; + rbase += cbase; + J->baseslot -= (BCReg)cbase; + J->base -= cbase; + J->base[--rbase] = TREF_TRUE; /* Prepend true to results. */ + frame = frame_prevd(frame); + } + /* Return to lower frame via interpreter for unhandled cases. */ + if (J->framedepth == 0 && J->pt && bc_isret(bc_op(*J->pc)) && + (!frame_islua(frame) || + (J->parent == 0 && !bc_isret(bc_op(J->cur.startins))))) { + /* NYI: specialize to frame type and return directly, not via RET*. */ + for (i = 0; i < (ptrdiff_t)rbase; i++) + J->base[i] = 0; /* Purge dead slots. */ + J->maxslot = rbase + (BCReg)gotresults; + rec_stop(J, LJ_TRLINK_RETURN, 0); /* Return to interpreter. */ + return; + } + if (frame_isvarg(frame)) { + BCReg cbase = (BCReg)frame_delta(frame); + if (--J->framedepth < 0) /* NYI: return of vararg func to lower frame. */ + lj_trace_err(J, LJ_TRERR_NYIRETL); + lua_assert(J->baseslot > 1); + rbase += cbase; + J->baseslot -= (BCReg)cbase; + J->base -= cbase; + frame = frame_prevd(frame); + } + if (frame_islua(frame)) { /* Return to Lua frame. */ + BCIns callins = *(frame_pc(frame)-1); + ptrdiff_t nresults = bc_b(callins) ? (ptrdiff_t)bc_b(callins)-1 :gotresults; + BCReg cbase = bc_a(callins); + GCproto *pt = funcproto(frame_func(frame - (cbase+1))); + if ((pt->flags & PROTO_NOJIT)) + lj_trace_err(J, LJ_TRERR_CJITOFF); + if (J->framedepth == 0 && J->pt && frame == J->L->base - 1) { + if (check_downrec_unroll(J, pt)) { + J->maxslot = (BCReg)(rbase + gotresults); + lj_snap_purge(J); + rec_stop(J, LJ_TRLINK_DOWNREC, J->cur.traceno); /* Down-recursion. */ + return; + } + lj_snap_add(J); + } + for (i = 0; i < nresults; i++) /* Adjust results. */ + J->base[i-1] = i < gotresults ? J->base[rbase+i] : TREF_NIL; + J->maxslot = cbase+(BCReg)nresults; + if (J->framedepth > 0) { /* Return to a frame that is part of the trace. */ + J->framedepth--; + lua_assert(J->baseslot > cbase+1); + J->baseslot -= cbase+1; + J->base -= cbase+1; + } else if (J->parent == 0 && !bc_isret(bc_op(J->cur.startins))) { + /* Return to lower frame would leave the loop in a root trace. */ + lj_trace_err(J, LJ_TRERR_LLEAVE); + } else if (J->needsnap) { /* Tailcalled to ff with side-effects. */ + lj_trace_err(J, LJ_TRERR_NYIRETL); /* No way to insert snapshot here. */ + } else { /* Return to lower frame. Guard for the target we return to. */ + TRef trpt = lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); + TRef trpc = lj_ir_kptr(J, (void *)frame_pc(frame)); + emitir(IRTG(IR_RETF, IRT_P32), trpt, trpc); + J->retdepth++; + J->needsnap = 1; + lua_assert(J->baseslot == 1); + /* Shift result slots up and clear the slots of the new frame below. */ + memmove(J->base + cbase, J->base-1, sizeof(TRef)*nresults); + memset(J->base-1, 0, sizeof(TRef)*(cbase+1)); + } + } else if (frame_iscont(frame)) { /* Return to continuation frame. */ + ASMFunction cont = frame_contf(frame); + BCReg cbase = (BCReg)frame_delta(frame); + if ((J->framedepth -= 2) < 0) + lj_trace_err(J, LJ_TRERR_NYIRETL); + J->baseslot -= (BCReg)cbase; + J->base -= cbase; + J->maxslot = cbase-2; + if (cont == lj_cont_ra) { + /* Copy result to destination slot. */ + BCReg dst = bc_a(*(frame_contpc(frame)-1)); + J->base[dst] = gotresults ? J->base[cbase+rbase] : TREF_NIL; + if (dst >= J->maxslot) J->maxslot = dst+1; + } else if (cont == lj_cont_nop) { + /* Nothing to do here. */ + } else if (cont == lj_cont_cat) { + lua_assert(0); + } else { + /* Result type already specialized. */ + lua_assert(cont == lj_cont_condf || cont == lj_cont_condt); + } + } else { + lj_trace_err(J, LJ_TRERR_NYIRETL); /* NYI: handle return to C frame. */ + } + lua_assert(J->baseslot >= 1); +} + +/* -- Metamethod handling ------------------------------------------------- */ + +/* Prepare to record call to metamethod. */ +static BCReg rec_mm_prep(jit_State *J, ASMFunction cont) +{ + BCReg s, top = curr_proto(J->L)->framesize; + TRef trcont; + setcont(&J->L->base[top], cont); +#if LJ_64 + trcont = lj_ir_kptr(J, (void *)((int64_t)cont - (int64_t)lj_vm_asm_begin)); +#else + trcont = lj_ir_kptr(J, (void *)cont); +#endif + J->base[top] = trcont | TREF_CONT; + J->framedepth++; + for (s = J->maxslot; s < top; s++) + J->base[s] = 0; /* Clear frame gap to avoid resurrecting previous refs. */ + return top+1; +} + +/* Record metamethod lookup. */ +int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm) +{ + RecordIndex mix; + GCtab *mt; + if (tref_istab(ix->tab)) { + mt = tabref(tabV(&ix->tabv)->metatable); + mix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_TAB_META); + } else if (tref_isudata(ix->tab)) { + int udtype = udataV(&ix->tabv)->udtype; + mt = tabref(udataV(&ix->tabv)->metatable); + /* The metatables of special userdata objects are treated as immutable. */ + if (udtype != UDTYPE_USERDATA) { + cTValue *mo; + if (LJ_HASFFI && udtype == UDTYPE_FFI_CLIB) { + /* Specialize to the C library namespace object. */ + emitir(IRTG(IR_EQ, IRT_P32), ix->tab, lj_ir_kptr(J, udataV(&ix->tabv))); + } else { + /* Specialize to the type of userdata. */ + TRef tr = emitir(IRT(IR_FLOAD, IRT_U8), ix->tab, IRFL_UDATA_UDTYPE); + emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, udtype)); + } + immutable_mt: + mo = lj_tab_getstr(mt, mmname_str(J2G(J), mm)); + if (!mo || tvisnil(mo)) + return 0; /* No metamethod. */ + /* Treat metamethod or index table as immutable, too. */ + if (!(tvisfunc(mo) || tvistab(mo))) + lj_trace_err(J, LJ_TRERR_BADTYPE); + copyTV(J->L, &ix->mobjv, mo); + ix->mobj = lj_ir_kgc(J, gcV(mo), tvisfunc(mo) ? IRT_FUNC : IRT_TAB); + ix->mtv = mt; + ix->mt = TREF_NIL; /* Dummy value for comparison semantics. */ + return 1; /* Got metamethod or index table. */ + } + mix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_UDATA_META); + } else { + /* Specialize to base metatable. Must flush mcode in lua_setmetatable(). */ + mt = tabref(basemt_obj(J2G(J), &ix->tabv)); + if (mt == NULL) { + ix->mt = TREF_NIL; + return 0; /* No metamethod. */ + } + /* The cdata metatable is treated as immutable. */ + if (LJ_HASFFI && tref_iscdata(ix->tab)) goto immutable_mt; + ix->mt = mix.tab = lj_ir_ktab(J, mt); + goto nocheck; + } + ix->mt = mt ? mix.tab : TREF_NIL; + emitir(IRTG(mt ? IR_NE : IR_EQ, IRT_TAB), mix.tab, lj_ir_knull(J, IRT_TAB)); +nocheck: + if (mt) { + GCstr *mmstr = mmname_str(J2G(J), mm); + cTValue *mo = lj_tab_getstr(mt, mmstr); + if (mo && !tvisnil(mo)) + copyTV(J->L, &ix->mobjv, mo); + ix->mtv = mt; + settabV(J->L, &mix.tabv, mt); + setstrV(J->L, &mix.keyv, mmstr); + mix.key = lj_ir_kstr(J, mmstr); + mix.val = 0; + mix.idxchain = 0; + ix->mobj = lj_record_idx(J, &mix); + return !tref_isnil(ix->mobj); /* 1 if metamethod found, 0 if not. */ + } + return 0; /* No metamethod. */ +} + +/* Record call to arithmetic metamethod. */ +static TRef rec_mm_arith(jit_State *J, RecordIndex *ix, MMS mm) +{ + /* Set up metamethod call first to save ix->tab and ix->tabv. */ + BCReg func = rec_mm_prep(J, lj_cont_ra); + TRef *base = J->base + func; + TValue *basev = J->L->base + func; + base[1] = ix->tab; base[2] = ix->key; + copyTV(J->L, basev+1, &ix->tabv); + copyTV(J->L, basev+2, &ix->keyv); + if (!lj_record_mm_lookup(J, ix, mm)) { /* Lookup mm on 1st operand. */ + if (mm != MM_unm) { + ix->tab = ix->key; + copyTV(J->L, &ix->tabv, &ix->keyv); + if (lj_record_mm_lookup(J, ix, mm)) /* Lookup mm on 2nd operand. */ + goto ok; + } + lj_trace_err(J, LJ_TRERR_NOMM); + } +ok: + base[0] = ix->mobj; + copyTV(J->L, basev+0, &ix->mobjv); + lj_record_call(J, func, 2); + return 0; /* No result yet. */ +} + +/* Record call to __len metamethod. */ +static TRef rec_mm_len(jit_State *J, TRef tr, TValue *tv) +{ + RecordIndex ix; + ix.tab = tr; + copyTV(J->L, &ix.tabv, tv); + if (lj_record_mm_lookup(J, &ix, MM_len)) { + BCReg func = rec_mm_prep(J, lj_cont_ra); + TRef *base = J->base + func; + TValue *basev = J->L->base + func; + base[0] = ix.mobj; copyTV(J->L, basev+0, &ix.mobjv); + base[1] = tr; copyTV(J->L, basev+1, tv); +#if LJ_52 + base[2] = tr; copyTV(J->L, basev+2, tv); +#else + base[2] = TREF_NIL; setnilV(basev+2); +#endif + lj_record_call(J, func, 2); + } else { + if (LJ_52 && tref_istab(tr)) + return lj_ir_call(J, IRCALL_lj_tab_len, tr); + lj_trace_err(J, LJ_TRERR_NOMM); + } + return 0; /* No result yet. */ +} + +/* Call a comparison metamethod. */ +static void rec_mm_callcomp(jit_State *J, RecordIndex *ix, int op) +{ + BCReg func = rec_mm_prep(J, (op&1) ? lj_cont_condf : lj_cont_condt); + TRef *base = J->base + func; + TValue *tv = J->L->base + func; + base[0] = ix->mobj; base[1] = ix->val; base[2] = ix->key; + copyTV(J->L, tv+0, &ix->mobjv); + copyTV(J->L, tv+1, &ix->valv); + copyTV(J->L, tv+2, &ix->keyv); + lj_record_call(J, func, 2); +} + +/* Record call to equality comparison metamethod (for tab and udata only). */ +static void rec_mm_equal(jit_State *J, RecordIndex *ix, int op) +{ + ix->tab = ix->val; + copyTV(J->L, &ix->tabv, &ix->valv); + if (lj_record_mm_lookup(J, ix, MM_eq)) { /* Lookup mm on 1st operand. */ + cTValue *bv; + TRef mo1 = ix->mobj; + TValue mo1v; + copyTV(J->L, &mo1v, &ix->mobjv); + /* Avoid the 2nd lookup and the objcmp if the metatables are equal. */ + bv = &ix->keyv; + if (tvistab(bv) && tabref(tabV(bv)->metatable) == ix->mtv) { + TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_TAB_META); + emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); + } else if (tvisudata(bv) && tabref(udataV(bv)->metatable) == ix->mtv) { + TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_UDATA_META); + emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); + } else { /* Lookup metamethod on 2nd operand and compare both. */ + ix->tab = ix->key; + copyTV(J->L, &ix->tabv, bv); + if (!lj_record_mm_lookup(J, ix, MM_eq) || + lj_record_objcmp(J, mo1, ix->mobj, &mo1v, &ix->mobjv)) + return; + } + rec_mm_callcomp(J, ix, op); + } +} + +/* Record call to ordered comparison metamethods (for arbitrary objects). */ +static void rec_mm_comp(jit_State *J, RecordIndex *ix, int op) +{ + ix->tab = ix->val; + copyTV(J->L, &ix->tabv, &ix->valv); + while (1) { + MMS mm = (op & 2) ? MM_le : MM_lt; /* Try __le + __lt or only __lt. */ +#if LJ_52 + if (!lj_record_mm_lookup(J, ix, mm)) { /* Lookup mm on 1st operand. */ + ix->tab = ix->key; + copyTV(J->L, &ix->tabv, &ix->keyv); + if (!lj_record_mm_lookup(J, ix, mm)) /* Lookup mm on 2nd operand. */ + goto nomatch; + } + rec_mm_callcomp(J, ix, op); + return; +#else + if (lj_record_mm_lookup(J, ix, mm)) { /* Lookup mm on 1st operand. */ + cTValue *bv; + TRef mo1 = ix->mobj; + TValue mo1v; + copyTV(J->L, &mo1v, &ix->mobjv); + /* Avoid the 2nd lookup and the objcmp if the metatables are equal. */ + bv = &ix->keyv; + if (tvistab(bv) && tabref(tabV(bv)->metatable) == ix->mtv) { + TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_TAB_META); + emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); + } else if (tvisudata(bv) && tabref(udataV(bv)->metatable) == ix->mtv) { + TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_UDATA_META); + emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); + } else { /* Lookup metamethod on 2nd operand and compare both. */ + ix->tab = ix->key; + copyTV(J->L, &ix->tabv, bv); + if (!lj_record_mm_lookup(J, ix, mm) || + lj_record_objcmp(J, mo1, ix->mobj, &mo1v, &ix->mobjv)) + goto nomatch; + } + rec_mm_callcomp(J, ix, op); + return; + } +#endif + nomatch: + /* Lookup failed. Retry with __lt and swapped operands. */ + if (!(op & 2)) break; /* Already at __lt. Interpreter will throw. */ + ix->tab = ix->key; ix->key = ix->val; ix->val = ix->tab; + copyTV(J->L, &ix->tabv, &ix->keyv); + copyTV(J->L, &ix->keyv, &ix->valv); + copyTV(J->L, &ix->valv, &ix->tabv); + op ^= 3; + } +} + +#if LJ_HASFFI +/* Setup call to cdata comparison metamethod. */ +static void rec_mm_comp_cdata(jit_State *J, RecordIndex *ix, int op, MMS mm) +{ + lj_snap_add(J); + if (tref_iscdata(ix->val)) { + ix->tab = ix->val; + copyTV(J->L, &ix->tabv, &ix->valv); + } else { + lua_assert(tref_iscdata(ix->key)); + ix->tab = ix->key; + copyTV(J->L, &ix->tabv, &ix->keyv); + } + lj_record_mm_lookup(J, ix, mm); + rec_mm_callcomp(J, ix, op); +} +#endif + +/* -- Indexed access ------------------------------------------------------ */ + +/* Record bounds-check. */ +static void rec_idx_abc(jit_State *J, TRef asizeref, TRef ikey, uint32_t asize) +{ + /* Try to emit invariant bounds checks. */ + if ((J->flags & (JIT_F_OPT_LOOP|JIT_F_OPT_ABC)) == + (JIT_F_OPT_LOOP|JIT_F_OPT_ABC)) { + IRRef ref = tref_ref(ikey); + IRIns *ir = IR(ref); + int32_t ofs = 0; + IRRef ofsref = 0; + /* Handle constant offsets. */ + if (ir->o == IR_ADD && irref_isk(ir->op2)) { + ofsref = ir->op2; + ofs = IR(ofsref)->i; + ref = ir->op1; + ir = IR(ref); + } + /* Got scalar evolution analysis results for this reference? */ + if (ref == J->scev.idx) { + int32_t stop; + lua_assert(irt_isint(J->scev.t) && ir->o == IR_SLOAD); + stop = numberVint(&(J->L->base - J->baseslot)[ir->op1 + FORL_STOP]); + /* Runtime value for stop of loop is within bounds? */ + if ((uint64_t)stop + ofs < (uint64_t)asize) { + /* Emit invariant bounds check for stop. */ + emitir(IRTG(IR_ABC, IRT_P32), asizeref, ofs == 0 ? J->scev.stop : + emitir(IRTI(IR_ADD), J->scev.stop, ofsref)); + /* Emit invariant bounds check for start, if not const or negative. */ + if (!(J->scev.dir && J->scev.start && + (int64_t)IR(J->scev.start)->i + ofs >= 0)) + emitir(IRTG(IR_ABC, IRT_P32), asizeref, ikey); + return; + } + } + } + emitir(IRTGI(IR_ABC), asizeref, ikey); /* Emit regular bounds check. */ +} + +/* Record indexed key lookup. */ +static TRef rec_idx_key(jit_State *J, RecordIndex *ix) +{ + TRef key; + GCtab *t = tabV(&ix->tabv); + ix->oldv = lj_tab_get(J->L, t, &ix->keyv); /* Lookup previous value. */ + + /* Integer keys are looked up in the array part first. */ + key = ix->key; + if (tref_isnumber(key)) { + int32_t k = numberVint(&ix->keyv); + if (!tvisint(&ix->keyv) && numV(&ix->keyv) != (lua_Number)k) + k = LJ_MAX_ASIZE; + if ((MSize)k < LJ_MAX_ASIZE) { /* Potential array key? */ + TRef ikey = lj_opt_narrow_index(J, key); + TRef asizeref = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_ASIZE); + if ((MSize)k < t->asize) { /* Currently an array key? */ + TRef arrayref; + rec_idx_abc(J, asizeref, ikey, t->asize); + arrayref = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_ARRAY); + return emitir(IRT(IR_AREF, IRT_P32), arrayref, ikey); + } else { /* Currently not in array (may be an array extension)? */ + emitir(IRTGI(IR_ULE), asizeref, ikey); /* Inv. bounds check. */ + if (k == 0 && tref_isk(key)) + key = lj_ir_knum_zero(J); /* Canonicalize 0 or +-0.0 to +0.0. */ + /* And continue with the hash lookup. */ + } + } else if (!tref_isk(key)) { + /* We can rule out const numbers which failed the integerness test + ** above. But all other numbers are potential array keys. + */ + if (t->asize == 0) { /* True sparse tables have an empty array part. */ + /* Guard that the array part stays empty. */ + TRef tmp = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_ASIZE); + emitir(IRTGI(IR_EQ), tmp, lj_ir_kint(J, 0)); + } else { + lj_trace_err(J, LJ_TRERR_NYITMIX); + } + } + } + + /* Otherwise the key is located in the hash part. */ + if (t->hmask == 0) { /* Shortcut for empty hash part. */ + /* Guard that the hash part stays empty. */ + TRef tmp = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK); + emitir(IRTGI(IR_EQ), tmp, lj_ir_kint(J, 0)); + return lj_ir_kkptr(J, niltvg(J2G(J))); + } + if (tref_isinteger(key)) /* Hash keys are based on numbers, not ints. */ + key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT); + if (tref_isk(key)) { + /* Optimize lookup of constant hash keys. */ + MSize hslot = (MSize)((char *)ix->oldv - (char *)&noderef(t->node)[0].val); + if (t->hmask > 0 && hslot <= t->hmask*(MSize)sizeof(Node) && + hslot <= 65535*(MSize)sizeof(Node)) { + TRef node, kslot; + TRef hm = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK); + emitir(IRTGI(IR_EQ), hm, lj_ir_kint(J, (int32_t)t->hmask)); + node = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_NODE); + kslot = lj_ir_kslot(J, key, hslot / sizeof(Node)); + return emitir(IRTG(IR_HREFK, IRT_P32), node, kslot); + } + } + /* Fall back to a regular hash lookup. */ + return emitir(IRT(IR_HREF, IRT_P32), ix->tab, key); +} + +/* Determine whether a key is NOT one of the fast metamethod names. */ +static int nommstr(jit_State *J, TRef key) +{ + if (tref_isstr(key)) { + if (tref_isk(key)) { + GCstr *str = ir_kstr(IR(tref_ref(key))); + uint32_t mm; + for (mm = 0; mm <= MM_FAST; mm++) + if (mmname_str(J2G(J), mm) == str) + return 0; /* MUST be one the fast metamethod names. */ + } else { + return 0; /* Variable string key MAY be a metamethod name. */ + } + } + return 1; /* CANNOT be a metamethod name. */ +} + +/* Record indexed load/store. */ +TRef lj_record_idx(jit_State *J, RecordIndex *ix) +{ + TRef xref; + IROp xrefop, loadop; + cTValue *oldv; + + while (!tref_istab(ix->tab)) { /* Handle non-table lookup. */ + /* Never call raw lj_record_idx() on non-table. */ + lua_assert(ix->idxchain != 0); + if (!lj_record_mm_lookup(J, ix, ix->val ? MM_newindex : MM_index)) + lj_trace_err(J, LJ_TRERR_NOMM); + handlemm: + if (tref_isfunc(ix->mobj)) { /* Handle metamethod call. */ + BCReg func = rec_mm_prep(J, ix->val ? lj_cont_nop : lj_cont_ra); + TRef *base = J->base + func; + TValue *tv = J->L->base + func; + base[0] = ix->mobj; base[1] = ix->tab; base[2] = ix->key; + setfuncV(J->L, tv+0, funcV(&ix->mobjv)); + copyTV(J->L, tv+1, &ix->tabv); + copyTV(J->L, tv+2, &ix->keyv); + if (ix->val) { + base[3] = ix->val; + copyTV(J->L, tv+3, &ix->valv); + lj_record_call(J, func, 3); /* mobj(tab, key, val) */ + return 0; + } else { + lj_record_call(J, func, 2); /* res = mobj(tab, key) */ + return 0; /* No result yet. */ + } + } + /* Otherwise retry lookup with metaobject. */ + ix->tab = ix->mobj; + copyTV(J->L, &ix->tabv, &ix->mobjv); + if (--ix->idxchain == 0) + lj_trace_err(J, LJ_TRERR_IDXLOOP); + } + + /* First catch nil and NaN keys for tables. */ + if (tvisnil(&ix->keyv) || (tvisnum(&ix->keyv) && tvisnan(&ix->keyv))) { + if (ix->val) /* Better fail early. */ + lj_trace_err(J, LJ_TRERR_STORENN); + if (tref_isk(ix->key)) { + if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_index)) + goto handlemm; + return TREF_NIL; + } + } + + /* Record the key lookup. */ + xref = rec_idx_key(J, ix); + xrefop = IR(tref_ref(xref))->o; + loadop = xrefop == IR_AREF ? IR_ALOAD : IR_HLOAD; + /* The lj_meta_tset() inconsistency is gone, but better play safe. */ + oldv = xrefop == IR_KKPTR ? (cTValue *)ir_kptr(IR(tref_ref(xref))) : ix->oldv; + + if (ix->val == 0) { /* Indexed load */ + IRType t = itype2irt(oldv); + TRef res; + if (oldv == niltvg(J2G(J))) { + emitir(IRTG(IR_EQ, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J)))); + res = TREF_NIL; + } else { + res = emitir(IRTG(loadop, t), xref, 0); + } + if (t == IRT_NIL && ix->idxchain && lj_record_mm_lookup(J, ix, MM_index)) + goto handlemm; + if (irtype_ispri(t)) res = TREF_PRI(t); /* Canonicalize primitives. */ + return res; + } else { /* Indexed store. */ + GCtab *mt = tabref(tabV(&ix->tabv)->metatable); + int keybarrier = tref_isgcv(ix->key) && !tref_isnil(ix->val); + if (tvisnil(oldv)) { /* Previous value was nil? */ + /* Need to duplicate the hasmm check for the early guards. */ + int hasmm = 0; + if (ix->idxchain && mt) { + cTValue *mo = lj_tab_getstr(mt, mmname_str(J2G(J), MM_newindex)); + hasmm = mo && !tvisnil(mo); + } + if (hasmm) + emitir(IRTG(loadop, IRT_NIL), xref, 0); /* Guard for nil value. */ + else if (xrefop == IR_HREF) + emitir(IRTG(oldv == niltvg(J2G(J)) ? IR_EQ : IR_NE, IRT_P32), + xref, lj_ir_kkptr(J, niltvg(J2G(J)))); + if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_newindex)) { + lua_assert(hasmm); + goto handlemm; + } + lua_assert(!hasmm); + if (oldv == niltvg(J2G(J))) { /* Need to insert a new key. */ + TRef key = ix->key; + if (tref_isinteger(key)) /* NEWREF needs a TValue as a key. */ + key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT); + xref = emitir(IRT(IR_NEWREF, IRT_P32), ix->tab, key); + keybarrier = 0; /* NEWREF already takes care of the key barrier. */ + } + } else if (!lj_opt_fwd_wasnonnil(J, loadop, tref_ref(xref))) { + /* Cannot derive that the previous value was non-nil, must do checks. */ + if (xrefop == IR_HREF) /* Guard against store to niltv. */ + emitir(IRTG(IR_NE, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J)))); + if (ix->idxchain) { /* Metamethod lookup required? */ + /* A check for NULL metatable is cheaper (hoistable) than a load. */ + if (!mt) { + TRef mtref = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_TAB_META); + emitir(IRTG(IR_EQ, IRT_TAB), mtref, lj_ir_knull(J, IRT_TAB)); + } else { + IRType t = itype2irt(oldv); + emitir(IRTG(loadop, t), xref, 0); /* Guard for non-nil value. */ + } + } + } else { + keybarrier = 0; /* Previous non-nil value kept the key alive. */ + } + /* Convert int to number before storing. */ + if (!LJ_DUALNUM && tref_isinteger(ix->val)) + ix->val = emitir(IRTN(IR_CONV), ix->val, IRCONV_NUM_INT); + emitir(IRT(loadop+IRDELTA_L2S, tref_type(ix->val)), xref, ix->val); + if (keybarrier || tref_isgcv(ix->val)) + emitir(IRT(IR_TBAR, IRT_NIL), ix->tab, 0); + /* Invalidate neg. metamethod cache for stores with certain string keys. */ + if (!nommstr(J, ix->key)) { + TRef fref = emitir(IRT(IR_FREF, IRT_P32), ix->tab, IRFL_TAB_NOMM); + emitir(IRT(IR_FSTORE, IRT_U8), fref, lj_ir_kint(J, 0)); + } + J->needsnap = 1; + return 0; + } +} + +/* -- Upvalue access ------------------------------------------------------ */ + +/* Check whether upvalue is immutable and ok to constify. */ +static int rec_upvalue_constify(jit_State *J, GCupval *uvp) +{ + if (uvp->immutable) { + cTValue *o = uvval(uvp); + /* Don't constify objects that may retain large amounts of memory. */ +#if LJ_HASFFI + if (tviscdata(o)) { + GCcdata *cd = cdataV(o); + if (!cdataisv(cd) && !(cd->marked & LJ_GC_CDATA_FIN)) { + CType *ct = ctype_raw(ctype_ctsG(J2G(J)), cd->ctypeid); + if (!ctype_hassize(ct->info) || ct->size <= 16) + return 1; + } + return 0; + } +#else + UNUSED(J); +#endif + if (!(tvistab(o) || tvisudata(o) || tvisthread(o))) + return 1; + } + return 0; +} + +/* Record upvalue load/store. */ +static TRef rec_upvalue(jit_State *J, uint32_t uv, TRef val) +{ + GCupval *uvp = &gcref(J->fn->l.uvptr[uv])->uv; + TRef fn = getcurrf(J); + IRRef uref; + int needbarrier = 0; + if (rec_upvalue_constify(J, uvp)) { /* Try to constify immutable upvalue. */ + TRef tr, kfunc; + lua_assert(val == 0); + if (!tref_isk(fn)) { /* Late specialization of current function. */ + if (J->pt->flags >= PROTO_CLC_POLY) + goto noconstify; + kfunc = lj_ir_kfunc(J, J->fn); + emitir(IRTG(IR_EQ, IRT_FUNC), fn, kfunc); + J->base[-1] = TREF_FRAME | kfunc; + fn = kfunc; + } + tr = lj_record_constify(J, uvval(uvp)); + if (tr) + return tr; + } +noconstify: + /* Note: this effectively limits LJ_MAX_UPVAL to 127. */ + uv = (uv << 8) | (hashrot(uvp->dhash, uvp->dhash + HASH_BIAS) & 0xff); + if (!uvp->closed) { + uref = tref_ref(emitir(IRTG(IR_UREFO, IRT_P32), fn, uv)); + /* In current stack? */ + if (uvval(uvp) >= tvref(J->L->stack) && + uvval(uvp) < tvref(J->L->maxstack)) { + int32_t slot = (int32_t)(uvval(uvp) - (J->L->base - J->baseslot)); + if (slot >= 0) { /* Aliases an SSA slot? */ + emitir(IRTG(IR_EQ, IRT_P32), + REF_BASE, + emitir(IRT(IR_ADD, IRT_P32), uref, + lj_ir_kint(J, (slot - 1) * -8))); + slot -= (int32_t)J->baseslot; /* Note: slot number may be negative! */ + if (val == 0) { + return getslot(J, slot); + } else { + J->base[slot] = val; + if (slot >= (int32_t)J->maxslot) J->maxslot = (BCReg)(slot+1); + return 0; + } + } + } + emitir(IRTG(IR_UGT, IRT_P32), + emitir(IRT(IR_SUB, IRT_P32), uref, REF_BASE), + lj_ir_kint(J, (J->baseslot + J->maxslot) * 8)); + } else { + needbarrier = 1; + uref = tref_ref(emitir(IRTG(IR_UREFC, IRT_P32), fn, uv)); + } + if (val == 0) { /* Upvalue load */ + IRType t = itype2irt(uvval(uvp)); + TRef res = emitir(IRTG(IR_ULOAD, t), uref, 0); + if (irtype_ispri(t)) res = TREF_PRI(t); /* Canonicalize primitive refs. */ + return res; + } else { /* Upvalue store. */ + /* Convert int to number before storing. */ + if (!LJ_DUALNUM && tref_isinteger(val)) + val = emitir(IRTN(IR_CONV), val, IRCONV_NUM_INT); + emitir(IRT(IR_USTORE, tref_type(val)), uref, val); + if (needbarrier && tref_isgcv(val)) + emitir(IRT(IR_OBAR, IRT_NIL), uref, val); + J->needsnap = 1; + return 0; + } +} + +/* -- Record calls to Lua functions --------------------------------------- */ + +/* Check unroll limits for calls. */ +static void check_call_unroll(jit_State *J, TraceNo lnk) +{ + cTValue *frame = J->L->base - 1; + void *pc = mref(frame_func(frame)->l.pc, void); + int32_t depth = J->framedepth; + int32_t count = 0; + if ((J->pt->flags & PROTO_VARARG)) depth--; /* Vararg frame still missing. */ + for (; depth > 0; depth--) { /* Count frames with same prototype. */ + if (frame_iscont(frame)) depth--; + frame = frame_prev(frame); + if (mref(frame_func(frame)->l.pc, void) == pc) + count++; + } + if (J->pc == J->startpc) { + if (count + J->tailcalled > J->param[JIT_P_recunroll]) { + J->pc++; + if (J->framedepth + J->retdepth == 0) + rec_stop(J, LJ_TRLINK_TAILREC, J->cur.traceno); /* Tail-recursion. */ + else + rec_stop(J, LJ_TRLINK_UPREC, J->cur.traceno); /* Up-recursion. */ + } + } else { + if (count > J->param[JIT_P_callunroll]) { + if (lnk) { /* Possible tail- or up-recursion. */ + lj_trace_flush(J, lnk); /* Flush trace that only returns. */ + /* Set a small, pseudo-random hotcount for a quick retry of JFUNC*. */ + hotcount_set(J2GG(J), J->pc+1, LJ_PRNG_BITS(J, 4)); + } + lj_trace_err(J, LJ_TRERR_CUNROLL); + } + } +} + +/* Record Lua function setup. */ +static void rec_func_setup(jit_State *J) +{ + GCproto *pt = J->pt; + BCReg s, numparams = pt->numparams; + if ((pt->flags & PROTO_NOJIT)) + lj_trace_err(J, LJ_TRERR_CJITOFF); + if (J->baseslot + pt->framesize >= LJ_MAX_JSLOTS) + lj_trace_err(J, LJ_TRERR_STACKOV); + /* Fill up missing parameters with nil. */ + for (s = J->maxslot; s < numparams; s++) + J->base[s] = TREF_NIL; + /* The remaining slots should never be read before they are written. */ + J->maxslot = numparams; +} + +/* Record Lua vararg function setup. */ +static void rec_func_vararg(jit_State *J) +{ + GCproto *pt = J->pt; + BCReg s, fixargs, vframe = J->maxslot+1; + lua_assert((pt->flags & PROTO_VARARG)); + if (J->baseslot + vframe + pt->framesize >= LJ_MAX_JSLOTS) + lj_trace_err(J, LJ_TRERR_STACKOV); + J->base[vframe-1] = J->base[-1]; /* Copy function up. */ + /* Copy fixarg slots up and set their original slots to nil. */ + fixargs = pt->numparams < J->maxslot ? pt->numparams : J->maxslot; + for (s = 0; s < fixargs; s++) { + J->base[vframe+s] = J->base[s]; + J->base[s] = TREF_NIL; + } + J->maxslot = fixargs; + J->framedepth++; + J->base += vframe; + J->baseslot += vframe; +} + +/* Record entry to a Lua function. */ +static void rec_func_lua(jit_State *J) +{ + rec_func_setup(J); + check_call_unroll(J, 0); +} + +/* Record entry to an already compiled function. */ +static void rec_func_jit(jit_State *J, TraceNo lnk) +{ + GCtrace *T; + rec_func_setup(J); + T = traceref(J, lnk); + if (T->linktype == LJ_TRLINK_RETURN) { /* Trace returns to interpreter? */ + check_call_unroll(J, lnk); + /* Temporarily unpatch JFUNC* to continue recording across function. */ + J->patchins = *J->pc; + J->patchpc = (BCIns *)J->pc; + *J->patchpc = T->startins; + return; + } + J->instunroll = 0; /* Cannot continue across a compiled function. */ + if (J->pc == J->startpc && J->framedepth + J->retdepth == 0) + rec_stop(J, LJ_TRLINK_TAILREC, J->cur.traceno); /* Extra tail-recursion. */ + else + rec_stop(J, LJ_TRLINK_ROOT, lnk); /* Link to the function. */ +} + +/* -- Vararg handling ----------------------------------------------------- */ + +/* Detect y = select(x, ...) idiom. */ +static int select_detect(jit_State *J) +{ + BCIns ins = J->pc[1]; + if (bc_op(ins) == BC_CALLM && bc_b(ins) == 2 && bc_c(ins) == 1) { + cTValue *func = &J->L->base[bc_a(ins)]; + if (tvisfunc(func) && funcV(func)->c.ffid == FF_select) { + TRef kfunc = lj_ir_kfunc(J, funcV(func)); + emitir(IRTG(IR_EQ, IRT_FUNC), getslot(J, bc_a(ins)), kfunc); + return 1; + } + } + return 0; +} + +/* Record vararg instruction. */ +static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) +{ + int32_t numparams = J->pt->numparams; + ptrdiff_t nvararg = frame_delta(J->L->base-1) - numparams - 1; + lua_assert(frame_isvarg(J->L->base-1)); + if (J->framedepth > 0) { /* Simple case: varargs defined on-trace. */ + ptrdiff_t i; + if (nvararg < 0) nvararg = 0; + if (nresults == -1) { + nresults = nvararg; + J->maxslot = dst + (BCReg)nvararg; + } else if (dst + nresults > J->maxslot) { + J->maxslot = dst + (BCReg)nresults; + } + for (i = 0; i < nresults; i++) + J->base[dst+i] = i < nvararg ? getslot(J, i - nvararg - 1) : TREF_NIL; + } else { /* Unknown number of varargs passed to trace. */ + TRef fr = emitir(IRTI(IR_SLOAD), 0, IRSLOAD_READONLY|IRSLOAD_FRAME); + int32_t frofs = 8*(1+numparams)+FRAME_VARG; + if (nresults >= 0) { /* Known fixed number of results. */ + ptrdiff_t i; + if (nvararg > 0) { + ptrdiff_t nload = nvararg >= nresults ? nresults : nvararg; + TRef vbase; + if (nvararg >= nresults) + emitir(IRTGI(IR_GE), fr, lj_ir_kint(J, frofs+8*(int32_t)nresults)); + else + emitir(IRTGI(IR_EQ), fr, lj_ir_kint(J, frame_ftsz(J->L->base-1))); + vbase = emitir(IRTI(IR_SUB), REF_BASE, fr); + vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8)); + for (i = 0; i < nload; i++) { + IRType t = itype2irt(&J->L->base[i-1-nvararg]); + TRef aref = emitir(IRT(IR_AREF, IRT_P32), + vbase, lj_ir_kint(J, (int32_t)i)); + TRef tr = emitir(IRTG(IR_VLOAD, t), aref, 0); + if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */ + J->base[dst+i] = tr; + } + } else { + emitir(IRTGI(IR_LE), fr, lj_ir_kint(J, frofs)); + nvararg = 0; + } + for (i = nvararg; i < nresults; i++) + J->base[dst+i] = TREF_NIL; + if (dst + (BCReg)nresults > J->maxslot) + J->maxslot = dst + (BCReg)nresults; + } else if (select_detect(J)) { /* y = select(x, ...) */ + TRef tridx = J->base[dst-1]; + TRef tr = TREF_NIL; + ptrdiff_t idx = lj_ffrecord_select_mode(J, tridx, &J->L->base[dst-1]); + if (idx < 0) goto nyivarg; + if (idx != 0 && !tref_isinteger(tridx)) + tridx = emitir(IRTGI(IR_CONV), tridx, IRCONV_INT_NUM|IRCONV_INDEX); + if (idx != 0 && tref_isk(tridx)) { + emitir(IRTGI(idx <= nvararg ? IR_GE : IR_LT), + fr, lj_ir_kint(J, frofs+8*(int32_t)idx)); + frofs -= 8; /* Bias for 1-based index. */ + } else if (idx <= nvararg) { /* Compute size. */ + TRef tmp = emitir(IRTI(IR_ADD), fr, lj_ir_kint(J, -frofs)); + if (numparams) + emitir(IRTGI(IR_GE), tmp, lj_ir_kint(J, 0)); + tr = emitir(IRTI(IR_BSHR), tmp, lj_ir_kint(J, 3)); + if (idx != 0) { + tridx = emitir(IRTI(IR_ADD), tridx, lj_ir_kint(J, -1)); + rec_idx_abc(J, tr, tridx, (uint32_t)nvararg); + } + } else { + TRef tmp = lj_ir_kint(J, frofs); + if (idx != 0) { + TRef tmp2 = emitir(IRTI(IR_BSHL), tridx, lj_ir_kint(J, 3)); + tmp = emitir(IRTI(IR_ADD), tmp2, tmp); + } else { + tr = lj_ir_kint(J, 0); + } + emitir(IRTGI(IR_LT), fr, tmp); + } + if (idx != 0 && idx <= nvararg) { + IRType t; + TRef aref, vbase = emitir(IRTI(IR_SUB), REF_BASE, fr); + vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8)); + t = itype2irt(&J->L->base[idx-2-nvararg]); + aref = emitir(IRT(IR_AREF, IRT_P32), vbase, tridx); + tr = emitir(IRTG(IR_VLOAD, t), aref, 0); + if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */ + } + J->base[dst-2] = tr; + J->maxslot = dst-1; + J->bcskip = 2; /* Skip CALLM + select. */ + } else { + nyivarg: + setintV(&J->errinfo, BC_VARG); + lj_trace_err_info(J, LJ_TRERR_NYIBC); + } + } +} + +/* -- Record allocations -------------------------------------------------- */ + +static TRef rec_tnew(jit_State *J, uint32_t ah) +{ + uint32_t asize = ah & 0x7ff; + uint32_t hbits = ah >> 11; + if (asize == 0x7ff) asize = 0x801; + return emitir(IRTG(IR_TNEW, IRT_TAB), asize, hbits); +} + +/* -- Record bytecode ops ------------------------------------------------- */ + +/* Prepare for comparison. */ +static void rec_comp_prep(jit_State *J) +{ + /* Prevent merging with snapshot #0 (GC exit) since we fixup the PC. */ + if (J->cur.nsnap == 1 && J->cur.snap[0].ref == J->cur.nins) + emitir_raw(IRT(IR_NOP, IRT_NIL), 0, 0); + lj_snap_add(J); +} + +/* Fixup comparison. */ +static void rec_comp_fixup(jit_State *J, const BCIns *pc, int cond) +{ + BCIns jmpins = pc[1]; + const BCIns *npc = pc + 2 + (cond ? bc_j(jmpins) : 0); + SnapShot *snap = &J->cur.snap[J->cur.nsnap-1]; + /* Set PC to opposite target to avoid re-recording the comp. in side trace. */ + J->cur.snapmap[snap->mapofs + snap->nent] = SNAP_MKPC(npc); + J->needsnap = 1; + if (bc_a(jmpins) < J->maxslot) J->maxslot = bc_a(jmpins); + lj_snap_shrink(J); /* Shrink last snapshot if possible. */ +} + +/* Record the next bytecode instruction (_before_ it's executed). */ +void lj_record_ins(jit_State *J) +{ + cTValue *lbase; + RecordIndex ix; + const BCIns *pc; + BCIns ins; + BCOp op; + TRef ra, rb, rc; + + /* Perform post-processing action before recording the next instruction. */ + if (LJ_UNLIKELY(J->postproc != LJ_POST_NONE)) { + switch (J->postproc) { + case LJ_POST_FIXCOMP: /* Fixup comparison. */ + pc = frame_pc(&J2G(J)->tmptv); + rec_comp_fixup(J, pc, (!tvistruecond(&J2G(J)->tmptv2) ^ (bc_op(*pc)&1))); + /* fallthrough */ + case LJ_POST_FIXGUARD: /* Fixup and emit pending guard. */ + case LJ_POST_FIXGUARDSNAP: /* Fixup and emit pending guard and snapshot. */ + if (!tvistruecond(&J2G(J)->tmptv2)) { + J->fold.ins.o ^= 1; /* Flip guard to opposite. */ + if (J->postproc == LJ_POST_FIXGUARDSNAP) { + SnapShot *snap = &J->cur.snap[J->cur.nsnap-1]; + J->cur.snapmap[snap->mapofs+snap->nent-1]--; /* False -> true. */ + } + } + lj_opt_fold(J); /* Emit pending guard. */ + /* fallthrough */ + case LJ_POST_FIXBOOL: + if (!tvistruecond(&J2G(J)->tmptv2)) { + BCReg s; + TValue *tv = J->L->base; + for (s = 0; s < J->maxslot; s++) /* Fixup stack slot (if any). */ + if (J->base[s] == TREF_TRUE && tvisfalse(&tv[s])) { + J->base[s] = TREF_FALSE; + break; + } + } + break; + case LJ_POST_FIXCONST: + { + BCReg s; + TValue *tv = J->L->base; + for (s = 0; s < J->maxslot; s++) /* Constify stack slots (if any). */ + if (J->base[s] == TREF_NIL && !tvisnil(&tv[s])) + J->base[s] = lj_record_constify(J, &tv[s]); + } + break; + case LJ_POST_FFRETRY: /* Suppress recording of retried fast function. */ + if (bc_op(*J->pc) >= BC__MAX) + return; + break; + default: lua_assert(0); break; + } + J->postproc = LJ_POST_NONE; + } + + /* Need snapshot before recording next bytecode (e.g. after a store). */ + if (J->needsnap) { + J->needsnap = 0; + lj_snap_purge(J); + lj_snap_add(J); + J->mergesnap = 1; + } + + /* Skip some bytecodes. */ + if (LJ_UNLIKELY(J->bcskip > 0)) { + J->bcskip--; + return; + } + + /* Record only closed loops for root traces. */ + pc = J->pc; + if (J->framedepth == 0 && + (MSize)((char *)pc - (char *)J->bc_min) >= J->bc_extent) + lj_trace_err(J, LJ_TRERR_LLEAVE); + +#ifdef LUA_USE_ASSERT + rec_check_slots(J); + rec_check_ir(J); +#endif + + /* Keep a copy of the runtime values of var/num/str operands. */ +#define rav (&ix.valv) +#define rbv (&ix.tabv) +#define rcv (&ix.keyv) + + lbase = J->L->base; + ins = *pc; + op = bc_op(ins); + ra = bc_a(ins); + ix.val = 0; + switch (bcmode_a(op)) { + case BCMvar: + copyTV(J->L, rav, &lbase[ra]); ix.val = ra = getslot(J, ra); break; + default: break; /* Handled later. */ + } + rb = bc_b(ins); + rc = bc_c(ins); + switch (bcmode_b(op)) { + case BCMnone: rb = 0; rc = bc_d(ins); break; /* Upgrade rc to 'rd'. */ + case BCMvar: + copyTV(J->L, rbv, &lbase[rb]); ix.tab = rb = getslot(J, rb); break; + default: break; /* Handled later. */ + } + switch (bcmode_c(op)) { + case BCMvar: + copyTV(J->L, rcv, &lbase[rc]); ix.key = rc = getslot(J, rc); break; + case BCMpri: setitype(rcv, ~rc); ix.key = rc = TREF_PRI(IRT_NIL+rc); break; + case BCMnum: { cTValue *tv = proto_knumtv(J->pt, rc); + copyTV(J->L, rcv, tv); ix.key = rc = tvisint(tv) ? lj_ir_kint(J, intV(tv)) : + lj_ir_knumint(J, numV(tv)); } break; + case BCMstr: { GCstr *s = gco2str(proto_kgc(J->pt, ~(ptrdiff_t)rc)); + setstrV(J->L, rcv, s); ix.key = rc = lj_ir_kstr(J, s); } break; + default: break; /* Handled later. */ + } + + switch (op) { + + /* -- Comparison ops ---------------------------------------------------- */ + + case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: +#if LJ_HASFFI + if (tref_iscdata(ra) || tref_iscdata(rc)) { + rec_mm_comp_cdata(J, &ix, op, ((int)op & 2) ? MM_le : MM_lt); + break; + } +#endif + /* Emit nothing for two numeric or string consts. */ + if (!(tref_isk2(ra,rc) && tref_isnumber_str(ra) && tref_isnumber_str(rc))) { + IRType ta = tref_isinteger(ra) ? IRT_INT : tref_type(ra); + IRType tc = tref_isinteger(rc) ? IRT_INT : tref_type(rc); + int irop; + if (ta != tc) { + /* Widen mixed number/int comparisons to number/number comparison. */ + if (ta == IRT_INT && tc == IRT_NUM) { + ra = emitir(IRTN(IR_CONV), ra, IRCONV_NUM_INT); + ta = IRT_NUM; + } else if (ta == IRT_NUM && tc == IRT_INT) { + rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT); + } else if (LJ_52) { + ta = IRT_NIL; /* Force metamethod for different types. */ + } else if (!((ta == IRT_FALSE || ta == IRT_TRUE) && + (tc == IRT_FALSE || tc == IRT_TRUE))) { + break; /* Interpreter will throw for two different types. */ + } + } + rec_comp_prep(J); + irop = (int)op - (int)BC_ISLT + (int)IR_LT; + if (ta == IRT_NUM) { + if ((irop & 1)) irop ^= 4; /* ISGE/ISGT are unordered. */ + if (!lj_ir_numcmp(numberVnum(rav), numberVnum(rcv), (IROp)irop)) + irop ^= 5; + } else if (ta == IRT_INT) { + if (!lj_ir_numcmp(numberVnum(rav), numberVnum(rcv), (IROp)irop)) + irop ^= 1; + } else if (ta == IRT_STR) { + if (!lj_ir_strcmp(strV(rav), strV(rcv), (IROp)irop)) irop ^= 1; + ra = lj_ir_call(J, IRCALL_lj_str_cmp, ra, rc); + rc = lj_ir_kint(J, 0); + ta = IRT_INT; + } else { + rec_mm_comp(J, &ix, (int)op); + break; + } + emitir(IRTG(irop, ta), ra, rc); + rec_comp_fixup(J, J->pc, ((int)op ^ irop) & 1); + } + break; + + case BC_ISEQV: case BC_ISNEV: + case BC_ISEQS: case BC_ISNES: + case BC_ISEQN: case BC_ISNEN: + case BC_ISEQP: case BC_ISNEP: +#if LJ_HASFFI + if (tref_iscdata(ra) || tref_iscdata(rc)) { + rec_mm_comp_cdata(J, &ix, op, MM_eq); + break; + } +#endif + /* Emit nothing for two non-table, non-udata consts. */ + if (!(tref_isk2(ra, rc) && !(tref_istab(ra) || tref_isudata(ra)))) { + int diff; + rec_comp_prep(J); + diff = lj_record_objcmp(J, ra, rc, rav, rcv); + if (diff == 2 || !(tref_istab(ra) || tref_isudata(ra))) + rec_comp_fixup(J, J->pc, ((int)op & 1) == !diff); + else if (diff == 1) /* Only check __eq if different, but same type. */ + rec_mm_equal(J, &ix, (int)op); + } + break; + + /* -- Unary test and copy ops ------------------------------------------- */ + + case BC_ISTC: case BC_ISFC: + if ((op & 1) == tref_istruecond(rc)) + rc = 0; /* Don't store if condition is not true. */ + /* fallthrough */ + case BC_IST: case BC_ISF: /* Type specialization suffices. */ + if (bc_a(pc[1]) < J->maxslot) + J->maxslot = bc_a(pc[1]); /* Shrink used slots. */ + break; + + /* -- Unary ops --------------------------------------------------------- */ + + case BC_NOT: + /* Type specialization already forces const result. */ + rc = tref_istruecond(rc) ? TREF_FALSE : TREF_TRUE; + break; + + case BC_LEN: + if (tref_isstr(rc)) + rc = emitir(IRTI(IR_FLOAD), rc, IRFL_STR_LEN); + else if (!LJ_52 && tref_istab(rc)) + rc = lj_ir_call(J, IRCALL_lj_tab_len, rc); + else + rc = rec_mm_len(J, rc, rcv); + break; + + /* -- Arithmetic ops ---------------------------------------------------- */ + + case BC_UNM: + if (tref_isnumber_str(rc)) { + rc = lj_opt_narrow_unm(J, rc, rcv); + } else { + ix.tab = rc; + copyTV(J->L, &ix.tabv, rcv); + rc = rec_mm_arith(J, &ix, MM_unm); + } + break; + + case BC_ADDNV: case BC_SUBNV: case BC_MULNV: case BC_DIVNV: case BC_MODNV: + /* Swap rb/rc and rbv/rcv. rav is temp. */ + ix.tab = rc; ix.key = rc = rb; rb = ix.tab; + copyTV(J->L, rav, rbv); + copyTV(J->L, rbv, rcv); + copyTV(J->L, rcv, rav); + if (op == BC_MODNV) + goto recmod; + /* fallthrough */ + case BC_ADDVN: case BC_SUBVN: case BC_MULVN: case BC_DIVVN: + case BC_ADDVV: case BC_SUBVV: case BC_MULVV: case BC_DIVVV: { + MMS mm = bcmode_mm(op); + if (tref_isnumber_str(rb) && tref_isnumber_str(rc)) + rc = lj_opt_narrow_arith(J, rb, rc, rbv, rcv, + (int)mm - (int)MM_add + (int)IR_ADD); + else + rc = rec_mm_arith(J, &ix, mm); + break; + } + + case BC_MODVN: case BC_MODVV: + recmod: + if (tref_isnumber_str(rb) && tref_isnumber_str(rc)) + rc = lj_opt_narrow_mod(J, rb, rc, rbv, rcv); + else + rc = rec_mm_arith(J, &ix, MM_mod); + break; + + case BC_POW: + if (tref_isnumber_str(rb) && tref_isnumber_str(rc)) + rc = lj_opt_narrow_pow(J, rb, rc, rbv, rcv); + else + rc = rec_mm_arith(J, &ix, MM_pow); + break; + + /* -- Constant and move ops --------------------------------------------- */ + + case BC_MOV: + /* Clear gap of method call to avoid resurrecting previous refs. */ + if (ra > J->maxslot) J->base[ra-1] = 0; + break; + case BC_KSTR: case BC_KNUM: case BC_KPRI: + break; + case BC_KSHORT: + rc = lj_ir_kint(J, (int32_t)(int16_t)rc); + break; + case BC_KNIL: + while (ra <= rc) + J->base[ra++] = TREF_NIL; + if (rc >= J->maxslot) J->maxslot = rc+1; + break; +#if LJ_HASFFI + case BC_KCDATA: + rc = lj_ir_kgc(J, proto_kgc(J->pt, ~(ptrdiff_t)rc), IRT_CDATA); + break; +#endif + + /* -- Upvalue and function ops ------------------------------------------ */ + + case BC_UGET: + rc = rec_upvalue(J, rc, 0); + break; + case BC_USETV: case BC_USETS: case BC_USETN: case BC_USETP: + rec_upvalue(J, ra, rc); + break; + + /* -- Table ops --------------------------------------------------------- */ + + case BC_GGET: case BC_GSET: + settabV(J->L, &ix.tabv, tabref(J->fn->l.env)); + ix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), getcurrf(J), IRFL_FUNC_ENV); + ix.idxchain = LJ_MAX_IDXCHAIN; + rc = lj_record_idx(J, &ix); + break; + + case BC_TGETB: case BC_TSETB: + setintV(&ix.keyv, (int32_t)rc); + ix.key = lj_ir_kint(J, (int32_t)rc); + /* fallthrough */ + case BC_TGETV: case BC_TGETS: case BC_TSETV: case BC_TSETS: + ix.idxchain = LJ_MAX_IDXCHAIN; + rc = lj_record_idx(J, &ix); + break; + + case BC_TNEW: + rc = rec_tnew(J, rc); + break; + case BC_TDUP: + rc = emitir(IRTG(IR_TDUP, IRT_TAB), + lj_ir_ktab(J, gco2tab(proto_kgc(J->pt, ~(ptrdiff_t)rc))), 0); + break; + + /* -- Calls and vararg handling ----------------------------------------- */ + + case BC_ITERC: + J->base[ra] = getslot(J, ra-3); + J->base[ra+1] = getslot(J, ra-2); + J->base[ra+2] = getslot(J, ra-1); + { /* Do the actual copy now because lj_record_call needs the values. */ + TValue *b = &J->L->base[ra]; + copyTV(J->L, b, b-3); + copyTV(J->L, b+1, b-2); + copyTV(J->L, b+2, b-1); + } + lj_record_call(J, ra, (ptrdiff_t)rc-1); + break; + + /* L->top is set to L->base+ra+rc+NARGS-1+1. See lj_dispatch_ins(). */ + case BC_CALLM: + rc = (BCReg)(J->L->top - J->L->base) - ra; + /* fallthrough */ + case BC_CALL: + lj_record_call(J, ra, (ptrdiff_t)rc-1); + break; + + case BC_CALLMT: + rc = (BCReg)(J->L->top - J->L->base) - ra; + /* fallthrough */ + case BC_CALLT: + lj_record_tailcall(J, ra, (ptrdiff_t)rc-1); + break; + + case BC_VARG: + rec_varg(J, ra, (ptrdiff_t)rb-1); + break; + + /* -- Returns ----------------------------------------------------------- */ + + case BC_RETM: + /* L->top is set to L->base+ra+rc+NRESULTS-1, see lj_dispatch_ins(). */ + rc = (BCReg)(J->L->top - J->L->base) - ra + 1; + /* fallthrough */ + case BC_RET: case BC_RET0: case BC_RET1: + lj_record_ret(J, ra, (ptrdiff_t)rc-1); + break; + + /* -- Loops and branches ------------------------------------------------ */ + + case BC_FORI: + if (rec_for(J, pc, 0) != LOOPEV_LEAVE) + J->loopref = J->cur.nins; + break; + case BC_JFORI: + lua_assert(bc_op(pc[(ptrdiff_t)rc-BCBIAS_J]) == BC_JFORL); + if (rec_for(J, pc, 0) != LOOPEV_LEAVE) /* Link to existing loop. */ + rec_stop(J, LJ_TRLINK_ROOT, bc_d(pc[(ptrdiff_t)rc-BCBIAS_J])); + /* Continue tracing if the loop is not entered. */ + break; + + case BC_FORL: + rec_loop_interp(J, pc, rec_for(J, pc+((ptrdiff_t)rc-BCBIAS_J), 1)); + break; + case BC_ITERL: + rec_loop_interp(J, pc, rec_iterl(J, *pc)); + break; + case BC_LOOP: + rec_loop_interp(J, pc, rec_loop(J, ra)); + break; + + case BC_JFORL: + rec_loop_jit(J, rc, rec_for(J, pc+bc_j(traceref(J, rc)->startins), 1)); + break; + case BC_JITERL: + rec_loop_jit(J, rc, rec_iterl(J, traceref(J, rc)->startins)); + break; + case BC_JLOOP: + rec_loop_jit(J, rc, rec_loop(J, ra)); + break; + + case BC_IFORL: + case BC_IITERL: + case BC_ILOOP: + case BC_IFUNCF: + case BC_IFUNCV: + lj_trace_err(J, LJ_TRERR_BLACKL); + break; + + case BC_JMP: + if (ra < J->maxslot) + J->maxslot = ra; /* Shrink used slots. */ + break; + + /* -- Function headers -------------------------------------------------- */ + + case BC_FUNCF: + rec_func_lua(J); + break; + case BC_JFUNCF: + rec_func_jit(J, rc); + break; + + case BC_FUNCV: + rec_func_vararg(J); + rec_func_lua(J); + break; + case BC_JFUNCV: + lua_assert(0); /* Cannot happen. No hotcall counting for varag funcs. */ + break; + + case BC_FUNCC: + case BC_FUNCCW: + lj_ffrecord_func(J); + break; + + default: + if (op >= BC__MAX) { + lj_ffrecord_func(J); + break; + } + /* fallthrough */ + case BC_ITERN: + case BC_ISNEXT: + case BC_CAT: + case BC_UCLO: + case BC_FNEW: + case BC_TSETM: + setintV(&J->errinfo, (int32_t)op); + lj_trace_err_info(J, LJ_TRERR_NYIBC); + break; + } + + /* rc == 0 if we have no result yet, e.g. pending __index metamethod call. */ + if (bcmode_a(op) == BCMdst && rc) { + J->base[ra] = rc; + if (ra >= J->maxslot) J->maxslot = ra+1; + } + +#undef rav +#undef rbv +#undef rcv + + /* Limit the number of recorded IR instructions. */ + if (J->cur.nins > REF_FIRST+(IRRef)J->param[JIT_P_maxrecord]) + lj_trace_err(J, LJ_TRERR_TRACEOV); +} + +/* -- Recording setup ----------------------------------------------------- */ + +/* Setup recording for a root trace started by a hot loop. */ +static const BCIns *rec_setup_root(jit_State *J) +{ + /* Determine the next PC and the bytecode range for the loop. */ + const BCIns *pcj, *pc = J->pc; + BCIns ins = *pc; + BCReg ra = bc_a(ins); + switch (bc_op(ins)) { + case BC_FORL: + J->bc_extent = (MSize)(-bc_j(ins))*sizeof(BCIns); + pc += 1+bc_j(ins); + J->bc_min = pc; + break; + case BC_ITERL: + lua_assert(bc_op(pc[-1]) == BC_ITERC); + J->maxslot = ra + bc_b(pc[-1]) - 1; + J->bc_extent = (MSize)(-bc_j(ins))*sizeof(BCIns); + pc += 1+bc_j(ins); + lua_assert(bc_op(pc[-1]) == BC_JMP); + J->bc_min = pc; + break; + case BC_LOOP: + /* Only check BC range for real loops, but not for "repeat until true". */ + pcj = pc + bc_j(ins); + ins = *pcj; + if (bc_op(ins) == BC_JMP && bc_j(ins) < 0) { + J->bc_min = pcj+1 + bc_j(ins); + J->bc_extent = (MSize)(-bc_j(ins))*sizeof(BCIns); + } + J->maxslot = ra; + pc++; + break; + case BC_RET: + case BC_RET0: + case BC_RET1: + /* No bytecode range check for down-recursive root traces. */ + J->maxslot = ra + bc_d(ins) - 1; + break; + case BC_FUNCF: + /* No bytecode range check for root traces started by a hot call. */ + J->maxslot = J->pt->numparams; + pc++; + break; + default: + lua_assert(0); + break; + } + return pc; +} + +/* Setup for recording a new trace. */ +void lj_record_setup(jit_State *J) +{ + uint32_t i; + + /* Initialize state related to current trace. */ + memset(J->slot, 0, sizeof(J->slot)); + memset(J->chain, 0, sizeof(J->chain)); + memset(J->bpropcache, 0, sizeof(J->bpropcache)); + J->scev.idx = REF_NIL; + setmref(J->scev.pc, NULL); + + J->baseslot = 1; /* Invoking function is at base[-1]. */ + J->base = J->slot + J->baseslot; + J->maxslot = 0; + J->framedepth = 0; + J->retdepth = 0; + + J->instunroll = J->param[JIT_P_instunroll]; + J->loopunroll = J->param[JIT_P_loopunroll]; + J->tailcalled = 0; + J->loopref = 0; + + J->bc_min = NULL; /* Means no limit. */ + J->bc_extent = ~(MSize)0; + + /* Emit instructions for fixed references. Also triggers initial IR alloc. */ + emitir_raw(IRT(IR_BASE, IRT_P32), J->parent, J->exitno); + for (i = 0; i <= 2; i++) { + IRIns *ir = IR(REF_NIL-i); + ir->i = 0; + ir->t.irt = (uint8_t)(IRT_NIL+i); + ir->o = IR_KPRI; + ir->prev = 0; + } + J->cur.nk = REF_TRUE; + + J->startpc = J->pc; + setmref(J->cur.startpc, J->pc); + if (J->parent) { /* Side trace. */ + GCtrace *T = traceref(J, J->parent); + TraceNo root = T->root ? T->root : J->parent; + J->cur.root = (uint16_t)root; + J->cur.startins = BCINS_AD(BC_JMP, 0, 0); + /* Check whether we could at least potentially form an extra loop. */ + if (J->exitno == 0 && T->snap[0].nent == 0) { + /* We can narrow a FORL for some side traces, too. */ + if (J->pc > proto_bc(J->pt) && bc_op(J->pc[-1]) == BC_JFORI && + bc_d(J->pc[bc_j(J->pc[-1])-1]) == root) { + lj_snap_add(J); + rec_for_loop(J, J->pc-1, &J->scev, 1); + goto sidecheck; + } + } else { + J->startpc = NULL; /* Prevent forming an extra loop. */ + } + lj_snap_replay(J, T); + sidecheck: + if (traceref(J, J->cur.root)->nchild >= J->param[JIT_P_maxside] || + T->snap[J->exitno].count >= J->param[JIT_P_hotexit] + + J->param[JIT_P_tryside]) { + rec_stop(J, LJ_TRLINK_INTERP, 0); + } + } else { /* Root trace. */ + J->cur.root = 0; + J->cur.startins = *J->pc; + J->pc = rec_setup_root(J); + /* Note: the loop instruction itself is recorded at the end and not + ** at the start! So snapshot #0 needs to point to the *next* instruction. + */ + lj_snap_add(J); + if (bc_op(J->cur.startins) == BC_FORL) + rec_for_loop(J, J->pc-1, &J->scev, 1); + if (1 + J->pt->framesize >= LJ_MAX_JSLOTS) + lj_trace_err(J, LJ_TRERR_STACKOV); + } +#ifdef LUAJIT_ENABLE_CHECKHOOK + /* Regularly check for instruction/line hooks from compiled code and + ** exit to the interpreter if the hooks are set. + ** + ** This is a compile-time option and disabled by default, since the + ** hook checks may be quite expensive in tight loops. + ** + ** Note this is only useful if hooks are *not* set most of the time. + ** Use this only if you want to *asynchronously* interrupt the execution. + ** + ** You can set the instruction hook via lua_sethook() with a count of 1 + ** from a signal handler or another native thread. Please have a look + ** at the first few functions in luajit.c for an example (Ctrl-C handler). + */ + { + TRef tr = emitir(IRT(IR_XLOAD, IRT_U8), + lj_ir_kptr(J, &J2G(J)->hookmask), IRXLOAD_VOLATILE); + tr = emitir(IRTI(IR_BAND), tr, lj_ir_kint(J, (LUA_MASKLINE|LUA_MASKCOUNT))); + emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, 0)); + } +#endif +} + +#undef IR +#undef emitir_raw +#undef emitir + +#endif + +``` + +`include/luajit-2.0.5/src/lj_record.h`: + +```h +/* +** Trace recorder (bytecode -> SSA IR). +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_RECORD_H +#define _LJ_RECORD_H + +#include "lj_obj.h" +#include "lj_jit.h" + +#if LJ_HASJIT +/* Context for recording an indexed load/store. */ +typedef struct RecordIndex { + TValue tabv; /* Runtime value of table (or indexed object). */ + TValue keyv; /* Runtime value of key. */ + TValue valv; /* Runtime value of stored value. */ + TValue mobjv; /* Runtime value of metamethod object. */ + GCtab *mtv; /* Runtime value of metatable object. */ + cTValue *oldv; /* Runtime value of previously stored value. */ + TRef tab; /* Table (or indexed object) reference. */ + TRef key; /* Key reference. */ + TRef val; /* Value reference for a store or 0 for a load. */ + TRef mt; /* Metatable reference. */ + TRef mobj; /* Metamethod object reference. */ + int idxchain; /* Index indirections left or 0 for raw lookup. */ +} RecordIndex; + +LJ_FUNC int lj_record_objcmp(jit_State *J, TRef a, TRef b, + cTValue *av, cTValue *bv); +LJ_FUNC TRef lj_record_constify(jit_State *J, cTValue *o); + +LJ_FUNC void lj_record_call(jit_State *J, BCReg func, ptrdiff_t nargs); +LJ_FUNC void lj_record_tailcall(jit_State *J, BCReg func, ptrdiff_t nargs); +LJ_FUNC void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults); + +LJ_FUNC int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm); +LJ_FUNC TRef lj_record_idx(jit_State *J, RecordIndex *ix); + +LJ_FUNC void lj_record_ins(jit_State *J); +LJ_FUNC void lj_record_setup(jit_State *J); +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_snap.c`: + +```c +/* +** Snapshot handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_snap_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_gc.h" +#include "lj_tab.h" +#include "lj_state.h" +#include "lj_frame.h" +#include "lj_bc.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#include "lj_snap.h" +#include "lj_target.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#include "lj_cdata.h" +#endif + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +/* Emit raw IR without passing through optimizations. */ +#define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) + +/* -- Snapshot buffer allocation ------------------------------------------ */ + +/* Grow snapshot buffer. */ +void lj_snap_grow_buf_(jit_State *J, MSize need) +{ + MSize maxsnap = (MSize)J->param[JIT_P_maxsnap]; + if (need > maxsnap) + lj_trace_err(J, LJ_TRERR_SNAPOV); + lj_mem_growvec(J->L, J->snapbuf, J->sizesnap, maxsnap, SnapShot); + J->cur.snap = J->snapbuf; +} + +/* Grow snapshot map buffer. */ +void lj_snap_grow_map_(jit_State *J, MSize need) +{ + if (need < 2*J->sizesnapmap) + need = 2*J->sizesnapmap; + else if (need < 64) + need = 64; + J->snapmapbuf = (SnapEntry *)lj_mem_realloc(J->L, J->snapmapbuf, + J->sizesnapmap*sizeof(SnapEntry), need*sizeof(SnapEntry)); + J->cur.snapmap = J->snapmapbuf; + J->sizesnapmap = need; +} + +/* -- Snapshot generation ------------------------------------------------- */ + +/* Add all modified slots to the snapshot. */ +static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots) +{ + IRRef retf = J->chain[IR_RETF]; /* Limits SLOAD restore elimination. */ + BCReg s; + MSize n = 0; + for (s = 0; s < nslots; s++) { + TRef tr = J->slot[s]; + IRRef ref = tref_ref(tr); + if (ref) { + SnapEntry sn = SNAP_TR(s, tr); + IRIns *ir = &J->cur.ir[ref]; + if (!(sn & (SNAP_CONT|SNAP_FRAME)) && + ir->o == IR_SLOAD && ir->op1 == s && ref > retf) { + /* No need to snapshot unmodified non-inherited slots. */ + if (!(ir->op2 & IRSLOAD_INHERIT)) + continue; + /* No need to restore readonly slots and unmodified non-parent slots. */ + if (!(LJ_DUALNUM && (ir->op2 & IRSLOAD_CONVERT)) && + (ir->op2 & (IRSLOAD_READONLY|IRSLOAD_PARENT)) != IRSLOAD_PARENT) + sn |= SNAP_NORESTORE; + } + if (LJ_SOFTFP && irt_isnum(ir->t)) + sn |= SNAP_SOFTFPNUM; + map[n++] = sn; + } + } + return n; +} + +/* Add frame links at the end of the snapshot. */ +static BCReg snapshot_framelinks(jit_State *J, SnapEntry *map) +{ + cTValue *frame = J->L->base - 1; + cTValue *lim = J->L->base - J->baseslot; + cTValue *ftop = frame + funcproto(frame_func(frame))->framesize; + MSize f = 0; + map[f++] = SNAP_MKPC(J->pc); /* The current PC is always the first entry. */ + while (frame > lim) { /* Backwards traversal of all frames above base. */ + if (frame_islua(frame)) { + map[f++] = SNAP_MKPC(frame_pc(frame)); + frame = frame_prevl(frame); + } else if (frame_iscont(frame)) { + map[f++] = SNAP_MKFTSZ(frame_ftsz(frame)); + map[f++] = SNAP_MKPC(frame_contpc(frame)); + frame = frame_prevd(frame); + } else { + lua_assert(!frame_isc(frame)); + map[f++] = SNAP_MKFTSZ(frame_ftsz(frame)); + frame = frame_prevd(frame); + continue; + } + if (frame + funcproto(frame_func(frame))->framesize > ftop) + ftop = frame + funcproto(frame_func(frame))->framesize; + } + lua_assert(f == (MSize)(1 + J->framedepth)); + return (BCReg)(ftop - lim); +} + +/* Take a snapshot of the current stack. */ +static void snapshot_stack(jit_State *J, SnapShot *snap, MSize nsnapmap) +{ + BCReg nslots = J->baseslot + J->maxslot; + MSize nent; + SnapEntry *p; + /* Conservative estimate. */ + lj_snap_grow_map(J, nsnapmap + nslots + (MSize)J->framedepth+1); + p = &J->cur.snapmap[nsnapmap]; + nent = snapshot_slots(J, p, nslots); + snap->topslot = (uint8_t)snapshot_framelinks(J, p + nent); + snap->mapofs = (uint16_t)nsnapmap; + snap->ref = (IRRef1)J->cur.nins; + snap->nent = (uint8_t)nent; + snap->nslots = (uint8_t)nslots; + snap->count = 0; + J->cur.nsnapmap = (uint16_t)(nsnapmap + nent + 1 + J->framedepth); +} + +/* Add or merge a snapshot. */ +void lj_snap_add(jit_State *J) +{ + MSize nsnap = J->cur.nsnap; + MSize nsnapmap = J->cur.nsnapmap; + /* Merge if no ins. inbetween or if requested and no guard inbetween. */ + if (J->mergesnap ? !irt_isguard(J->guardemit) : + (nsnap > 0 && J->cur.snap[nsnap-1].ref == J->cur.nins)) { + if (nsnap == 1) { /* But preserve snap #0 PC. */ + emitir_raw(IRT(IR_NOP, IRT_NIL), 0, 0); + goto nomerge; + } + nsnapmap = J->cur.snap[--nsnap].mapofs; + } else { + nomerge: + lj_snap_grow_buf(J, nsnap+1); + J->cur.nsnap = (uint16_t)(nsnap+1); + } + J->mergesnap = 0; + J->guardemit.irt = 0; + snapshot_stack(J, &J->cur.snap[nsnap], nsnapmap); +} + +/* -- Snapshot modification ----------------------------------------------- */ + +#define SNAP_USEDEF_SLOTS (LJ_MAX_JSLOTS+LJ_STACK_EXTRA) + +/* Find unused slots with reaching-definitions bytecode data-flow analysis. */ +static BCReg snap_usedef(jit_State *J, uint8_t *udf, + const BCIns *pc, BCReg maxslot) +{ + BCReg s; + GCobj *o; + + if (maxslot == 0) return 0; +#ifdef LUAJIT_USE_VALGRIND + /* Avoid errors for harmless reads beyond maxslot. */ + memset(udf, 1, SNAP_USEDEF_SLOTS); +#else + memset(udf, 1, maxslot); +#endif + + /* Treat open upvalues as used. */ + o = gcref(J->L->openupval); + while (o) { + if (uvval(gco2uv(o)) < J->L->base) break; + udf[uvval(gco2uv(o)) - J->L->base] = 0; + o = gcref(o->gch.nextgc); + } + +#define USE_SLOT(s) udf[(s)] &= ~1 +#define DEF_SLOT(s) udf[(s)] *= 3 + + /* Scan through following bytecode and check for uses/defs. */ + lua_assert(pc >= proto_bc(J->pt) && pc < proto_bc(J->pt) + J->pt->sizebc); + for (;;) { + BCIns ins = *pc++; + BCOp op = bc_op(ins); + switch (bcmode_b(op)) { + case BCMvar: USE_SLOT(bc_b(ins)); break; + default: break; + } + switch (bcmode_c(op)) { + case BCMvar: USE_SLOT(bc_c(ins)); break; + case BCMrbase: + lua_assert(op == BC_CAT); + for (s = bc_b(ins); s <= bc_c(ins); s++) USE_SLOT(s); + for (; s < maxslot; s++) DEF_SLOT(s); + break; + case BCMjump: + handle_jump: { + BCReg minslot = bc_a(ins); + if (op >= BC_FORI && op <= BC_JFORL) minslot += FORL_EXT; + else if (op >= BC_ITERL && op <= BC_JITERL) minslot += bc_b(pc[-2])-1; + else if (op == BC_UCLO) { pc += bc_j(ins); break; } + for (s = minslot; s < maxslot; s++) DEF_SLOT(s); + return minslot < maxslot ? minslot : maxslot; + } + case BCMlit: + if (op == BC_JFORL || op == BC_JITERL || op == BC_JLOOP) { + goto handle_jump; + } else if (bc_isret(op)) { + BCReg top = op == BC_RETM ? maxslot : (bc_a(ins) + bc_d(ins)-1); + for (s = 0; s < bc_a(ins); s++) DEF_SLOT(s); + for (; s < top; s++) USE_SLOT(s); + for (; s < maxslot; s++) DEF_SLOT(s); + return 0; + } + break; + case BCMfunc: return maxslot; /* NYI: will abort, anyway. */ + default: break; + } + switch (bcmode_a(op)) { + case BCMvar: USE_SLOT(bc_a(ins)); break; + case BCMdst: + if (!(op == BC_ISTC || op == BC_ISFC)) DEF_SLOT(bc_a(ins)); + break; + case BCMbase: + if (op >= BC_CALLM && op <= BC_VARG) { + BCReg top = (op == BC_CALLM || op == BC_CALLMT || bc_c(ins) == 0) ? + maxslot : (bc_a(ins) + bc_c(ins)); + s = bc_a(ins) - ((op == BC_ITERC || op == BC_ITERN) ? 3 : 0); + for (; s < top; s++) USE_SLOT(s); + for (; s < maxslot; s++) DEF_SLOT(s); + if (op == BC_CALLT || op == BC_CALLMT) { + for (s = 0; s < bc_a(ins); s++) DEF_SLOT(s); + return 0; + } + } else if (op == BC_KNIL) { + for (s = bc_a(ins); s <= bc_d(ins); s++) DEF_SLOT(s); + } else if (op == BC_TSETM) { + for (s = bc_a(ins)-1; s < maxslot; s++) USE_SLOT(s); + } + break; + default: break; + } + lua_assert(pc >= proto_bc(J->pt) && pc < proto_bc(J->pt) + J->pt->sizebc); + } + +#undef USE_SLOT +#undef DEF_SLOT + + return 0; /* unreachable */ +} + +/* Purge dead slots before the next snapshot. */ +void lj_snap_purge(jit_State *J) +{ + uint8_t udf[SNAP_USEDEF_SLOTS]; + BCReg maxslot = J->maxslot; + BCReg s = snap_usedef(J, udf, J->pc, maxslot); + for (; s < maxslot; s++) + if (udf[s] != 0) + J->base[s] = 0; /* Purge dead slots. */ +} + +/* Shrink last snapshot. */ +void lj_snap_shrink(jit_State *J) +{ + SnapShot *snap = &J->cur.snap[J->cur.nsnap-1]; + SnapEntry *map = &J->cur.snapmap[snap->mapofs]; + MSize n, m, nlim, nent = snap->nent; + uint8_t udf[SNAP_USEDEF_SLOTS]; + BCReg maxslot = J->maxslot; + BCReg minslot = snap_usedef(J, udf, snap_pc(map[nent]), maxslot); + BCReg baseslot = J->baseslot; + maxslot += baseslot; + minslot += baseslot; + snap->nslots = (uint8_t)maxslot; + for (n = m = 0; n < nent; n++) { /* Remove unused slots from snapshot. */ + BCReg s = snap_slot(map[n]); + if (s < minslot || (s < maxslot && udf[s-baseslot] == 0)) + map[m++] = map[n]; /* Only copy used slots. */ + } + snap->nent = (uint8_t)m; + nlim = J->cur.nsnapmap - snap->mapofs - 1; + while (n <= nlim) map[m++] = map[n++]; /* Move PC + frame links down. */ + J->cur.nsnapmap = (uint16_t)(snap->mapofs + m); /* Free up space in map. */ +} + +/* -- Snapshot access ----------------------------------------------------- */ + +/* Initialize a Bloom Filter with all renamed refs. +** There are very few renames (often none), so the filter has +** very few bits set. This makes it suitable for negative filtering. +*/ +static BloomFilter snap_renamefilter(GCtrace *T, SnapNo lim) +{ + BloomFilter rfilt = 0; + IRIns *ir; + for (ir = &T->ir[T->nins-1]; ir->o == IR_RENAME; ir--) + if (ir->op2 <= lim) + bloomset(rfilt, ir->op1); + return rfilt; +} + +/* Process matching renames to find the original RegSP. */ +static RegSP snap_renameref(GCtrace *T, SnapNo lim, IRRef ref, RegSP rs) +{ + IRIns *ir; + for (ir = &T->ir[T->nins-1]; ir->o == IR_RENAME; ir--) + if (ir->op1 == ref && ir->op2 <= lim) + rs = ir->prev; + return rs; +} + +/* Copy RegSP from parent snapshot to the parent links of the IR. */ +IRIns *lj_snap_regspmap(GCtrace *T, SnapNo snapno, IRIns *ir) +{ + SnapShot *snap = &T->snap[snapno]; + SnapEntry *map = &T->snapmap[snap->mapofs]; + BloomFilter rfilt = snap_renamefilter(T, snapno); + MSize n = 0; + IRRef ref = 0; + for ( ; ; ir++) { + uint32_t rs; + if (ir->o == IR_SLOAD) { + if (!(ir->op2 & IRSLOAD_PARENT)) break; + for ( ; ; n++) { + lua_assert(n < snap->nent); + if (snap_slot(map[n]) == ir->op1) { + ref = snap_ref(map[n++]); + break; + } + } + } else if (LJ_SOFTFP && ir->o == IR_HIOP) { + ref++; + } else if (ir->o == IR_PVAL) { + ref = ir->op1 + REF_BIAS; + } else { + break; + } + rs = T->ir[ref].prev; + if (bloomtest(rfilt, ref)) + rs = snap_renameref(T, snapno, ref, rs); + ir->prev = (uint16_t)rs; + lua_assert(regsp_used(rs)); + } + return ir; +} + +/* -- Snapshot replay ----------------------------------------------------- */ + +/* Replay constant from parent trace. */ +static TRef snap_replay_const(jit_State *J, IRIns *ir) +{ + /* Only have to deal with constants that can occur in stack slots. */ + switch ((IROp)ir->o) { + case IR_KPRI: return TREF_PRI(irt_type(ir->t)); + case IR_KINT: return lj_ir_kint(J, ir->i); + case IR_KGC: return lj_ir_kgc(J, ir_kgc(ir), irt_t(ir->t)); + case IR_KNUM: return lj_ir_k64(J, IR_KNUM, ir_knum(ir)); + case IR_KINT64: return lj_ir_k64(J, IR_KINT64, ir_kint64(ir)); + case IR_KPTR: return lj_ir_kptr(J, ir_kptr(ir)); /* Continuation. */ + default: lua_assert(0); return TREF_NIL; break; + } +} + +/* De-duplicate parent reference. */ +static TRef snap_dedup(jit_State *J, SnapEntry *map, MSize nmax, IRRef ref) +{ + MSize j; + for (j = 0; j < nmax; j++) + if (snap_ref(map[j]) == ref) + return J->slot[snap_slot(map[j])] & ~(SNAP_CONT|SNAP_FRAME); + return 0; +} + +/* Emit parent reference with de-duplication. */ +static TRef snap_pref(jit_State *J, GCtrace *T, SnapEntry *map, MSize nmax, + BloomFilter seen, IRRef ref) +{ + IRIns *ir = &T->ir[ref]; + TRef tr; + if (irref_isk(ref)) + tr = snap_replay_const(J, ir); + else if (!regsp_used(ir->prev)) + tr = 0; + else if (!bloomtest(seen, ref) || (tr = snap_dedup(J, map, nmax, ref)) == 0) + tr = emitir(IRT(IR_PVAL, irt_type(ir->t)), ref - REF_BIAS, 0); + return tr; +} + +/* Check whether a sunk store corresponds to an allocation. Slow path. */ +static int snap_sunk_store2(GCtrace *T, IRIns *ira, IRIns *irs) +{ + if (irs->o == IR_ASTORE || irs->o == IR_HSTORE || + irs->o == IR_FSTORE || irs->o == IR_XSTORE) { + IRIns *irk = &T->ir[irs->op1]; + if (irk->o == IR_AREF || irk->o == IR_HREFK) + irk = &T->ir[irk->op1]; + return (&T->ir[irk->op1] == ira); + } + return 0; +} + +/* Check whether a sunk store corresponds to an allocation. Fast path. */ +static LJ_AINLINE int snap_sunk_store(GCtrace *T, IRIns *ira, IRIns *irs) +{ + if (irs->s != 255) + return (ira + irs->s == irs); /* Fast check. */ + return snap_sunk_store2(T, ira, irs); +} + +/* Replay snapshot state to setup side trace. */ +void lj_snap_replay(jit_State *J, GCtrace *T) +{ + SnapShot *snap = &T->snap[J->exitno]; + SnapEntry *map = &T->snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + BloomFilter seen = 0; + int pass23 = 0; + J->framedepth = 0; + /* Emit IR for slots inherited from parent snapshot. */ + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + BCReg s = snap_slot(sn); + IRRef ref = snap_ref(sn); + IRIns *ir = &T->ir[ref]; + TRef tr; + /* The bloom filter avoids O(nent^2) overhead for de-duping slots. */ + if (bloomtest(seen, ref) && (tr = snap_dedup(J, map, n, ref)) != 0) + goto setslot; + bloomset(seen, ref); + if (irref_isk(ref)) { + tr = snap_replay_const(J, ir); + } else if (!regsp_used(ir->prev)) { + pass23 = 1; + lua_assert(s != 0); + tr = s; + } else { + IRType t = irt_type(ir->t); + uint32_t mode = IRSLOAD_INHERIT|IRSLOAD_PARENT; + if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM)) t = IRT_NUM; + if (ir->o == IR_SLOAD) mode |= (ir->op2 & IRSLOAD_READONLY); + tr = emitir_raw(IRT(IR_SLOAD, t), s, mode); + } + setslot: + J->slot[s] = tr | (sn&(SNAP_CONT|SNAP_FRAME)); /* Same as TREF_* flags. */ + J->framedepth += ((sn & (SNAP_CONT|SNAP_FRAME)) && s); + if ((sn & SNAP_FRAME)) + J->baseslot = s+1; + } + if (pass23) { + IRIns *irlast = &T->ir[snap->ref]; + pass23 = 0; + /* Emit dependent PVALs. */ + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + IRRef refp = snap_ref(sn); + IRIns *ir = &T->ir[refp]; + if (regsp_reg(ir->r) == RID_SUNK) { + if (J->slot[snap_slot(sn)] != snap_slot(sn)) continue; + pass23 = 1; + lua_assert(ir->o == IR_TNEW || ir->o == IR_TDUP || + ir->o == IR_CNEW || ir->o == IR_CNEWI); + if (ir->op1 >= T->nk) snap_pref(J, T, map, nent, seen, ir->op1); + if (ir->op2 >= T->nk) snap_pref(J, T, map, nent, seen, ir->op2); + if (LJ_HASFFI && ir->o == IR_CNEWI) { + if (LJ_32 && refp+1 < T->nins && (ir+1)->o == IR_HIOP) + snap_pref(J, T, map, nent, seen, (ir+1)->op2); + } else { + IRIns *irs; + for (irs = ir+1; irs < irlast; irs++) + if (irs->r == RID_SINK && snap_sunk_store(T, ir, irs)) { + if (snap_pref(J, T, map, nent, seen, irs->op2) == 0) + snap_pref(J, T, map, nent, seen, T->ir[irs->op2].op1); + else if ((LJ_SOFTFP || (LJ_32 && LJ_HASFFI)) && + irs+1 < irlast && (irs+1)->o == IR_HIOP) + snap_pref(J, T, map, nent, seen, (irs+1)->op2); + } + } + } else if (!irref_isk(refp) && !regsp_used(ir->prev)) { + lua_assert(ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT); + J->slot[snap_slot(sn)] = snap_pref(J, T, map, nent, seen, ir->op1); + } + } + /* Replay sunk instructions. */ + for (n = 0; pass23 && n < nent; n++) { + SnapEntry sn = map[n]; + IRRef refp = snap_ref(sn); + IRIns *ir = &T->ir[refp]; + if (regsp_reg(ir->r) == RID_SUNK) { + TRef op1, op2; + if (J->slot[snap_slot(sn)] != snap_slot(sn)) { /* De-dup allocs. */ + J->slot[snap_slot(sn)] = J->slot[J->slot[snap_slot(sn)]]; + continue; + } + op1 = ir->op1; + if (op1 >= T->nk) op1 = snap_pref(J, T, map, nent, seen, op1); + op2 = ir->op2; + if (op2 >= T->nk) op2 = snap_pref(J, T, map, nent, seen, op2); + if (LJ_HASFFI && ir->o == IR_CNEWI) { + if (LJ_32 && refp+1 < T->nins && (ir+1)->o == IR_HIOP) { + lj_needsplit(J); /* Emit joining HIOP. */ + op2 = emitir_raw(IRT(IR_HIOP, IRT_I64), op2, + snap_pref(J, T, map, nent, seen, (ir+1)->op2)); + } + J->slot[snap_slot(sn)] = emitir(ir->ot & ~(IRT_MARK|IRT_ISPHI), op1, op2); + } else { + IRIns *irs; + TRef tr = emitir(ir->ot, op1, op2); + J->slot[snap_slot(sn)] = tr; + for (irs = ir+1; irs < irlast; irs++) + if (irs->r == RID_SINK && snap_sunk_store(T, ir, irs)) { + IRIns *irr = &T->ir[irs->op1]; + TRef val, key = irr->op2, tmp = tr; + if (irr->o != IR_FREF) { + IRIns *irk = &T->ir[key]; + if (irr->o == IR_HREFK) + key = lj_ir_kslot(J, snap_replay_const(J, &T->ir[irk->op1]), + irk->op2); + else + key = snap_replay_const(J, irk); + if (irr->o == IR_HREFK || irr->o == IR_AREF) { + IRIns *irf = &T->ir[irr->op1]; + tmp = emitir(irf->ot, tmp, irf->op2); + } + } + tmp = emitir(irr->ot, tmp, key); + val = snap_pref(J, T, map, nent, seen, irs->op2); + if (val == 0) { + IRIns *irc = &T->ir[irs->op2]; + lua_assert(irc->o == IR_CONV && irc->op2 == IRCONV_NUM_INT); + val = snap_pref(J, T, map, nent, seen, irc->op1); + val = emitir(IRTN(IR_CONV), val, IRCONV_NUM_INT); + } else if ((LJ_SOFTFP || (LJ_32 && LJ_HASFFI)) && + irs+1 < irlast && (irs+1)->o == IR_HIOP) { + IRType t = IRT_I64; + if (LJ_SOFTFP && irt_type((irs+1)->t) == IRT_SOFTFP) + t = IRT_NUM; + lj_needsplit(J); + if (irref_isk(irs->op2) && irref_isk((irs+1)->op2)) { + uint64_t k = (uint32_t)T->ir[irs->op2].i + + ((uint64_t)T->ir[(irs+1)->op2].i << 32); + val = lj_ir_k64(J, t == IRT_I64 ? IR_KINT64 : IR_KNUM, + lj_ir_k64_find(J, k)); + } else { + val = emitir_raw(IRT(IR_HIOP, t), val, + snap_pref(J, T, map, nent, seen, (irs+1)->op2)); + } + tmp = emitir(IRT(irs->o, t), tmp, val); + continue; + } + tmp = emitir(irs->ot, tmp, val); + } else if (LJ_HASFFI && irs->o == IR_XBAR && ir->o == IR_CNEW) { + emitir(IRT(IR_XBAR, IRT_NIL), 0, 0); + } + } + } + } + } + J->base = J->slot + J->baseslot; + J->maxslot = snap->nslots - J->baseslot; + lj_snap_add(J); + if (pass23) /* Need explicit GC step _after_ initial snapshot. */ + emitir_raw(IRTG(IR_GCSTEP, IRT_NIL), 0, 0); +} + +/* -- Snapshot restore ---------------------------------------------------- */ + +static void snap_unsink(jit_State *J, GCtrace *T, ExitState *ex, + SnapNo snapno, BloomFilter rfilt, + IRIns *ir, TValue *o); + +/* Restore a value from the trace exit state. */ +static void snap_restoreval(jit_State *J, GCtrace *T, ExitState *ex, + SnapNo snapno, BloomFilter rfilt, + IRRef ref, TValue *o) +{ + IRIns *ir = &T->ir[ref]; + IRType1 t = ir->t; + RegSP rs = ir->prev; + if (irref_isk(ref)) { /* Restore constant slot. */ + lj_ir_kvalue(J->L, o, ir); + return; + } + if (LJ_UNLIKELY(bloomtest(rfilt, ref))) + rs = snap_renameref(T, snapno, ref, rs); + if (ra_hasspill(regsp_spill(rs))) { /* Restore from spill slot. */ + int32_t *sps = &ex->spill[regsp_spill(rs)]; + if (irt_isinteger(t)) { + setintV(o, *sps); +#if !LJ_SOFTFP + } else if (irt_isnum(t)) { + o->u64 = *(uint64_t *)sps; +#endif + } else if (LJ_64 && irt_islightud(t)) { + /* 64 bit lightuserdata which may escape already has the tag bits. */ + o->u64 = *(uint64_t *)sps; + } else { + lua_assert(!irt_ispri(t)); /* PRI refs never have a spill slot. */ + setgcrefi(o->gcr, *sps); + setitype(o, irt_toitype(t)); + } + } else { /* Restore from register. */ + Reg r = regsp_reg(rs); + if (ra_noreg(r)) { + lua_assert(ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT); + snap_restoreval(J, T, ex, snapno, rfilt, ir->op1, o); + if (LJ_DUALNUM) setnumV(o, (lua_Number)intV(o)); + return; + } else if (irt_isinteger(t)) { + setintV(o, (int32_t)ex->gpr[r-RID_MIN_GPR]); +#if !LJ_SOFTFP + } else if (irt_isnum(t)) { + setnumV(o, ex->fpr[r-RID_MIN_FPR]); +#endif + } else if (LJ_64 && irt_islightud(t)) { + /* 64 bit lightuserdata which may escape already has the tag bits. */ + o->u64 = ex->gpr[r-RID_MIN_GPR]; + } else { + if (!irt_ispri(t)) + setgcrefi(o->gcr, ex->gpr[r-RID_MIN_GPR]); + setitype(o, irt_toitype(t)); + } + } +} + +#if LJ_HASFFI +/* Restore raw data from the trace exit state. */ +static void snap_restoredata(GCtrace *T, ExitState *ex, + SnapNo snapno, BloomFilter rfilt, + IRRef ref, void *dst, CTSize sz) +{ + IRIns *ir = &T->ir[ref]; + RegSP rs = ir->prev; + int32_t *src; + uint64_t tmp; + if (irref_isk(ref)) { + if (ir->o == IR_KNUM || ir->o == IR_KINT64) { + src = mref(ir->ptr, int32_t); + } else if (sz == 8) { + tmp = (uint64_t)(uint32_t)ir->i; + src = (int32_t *)&tmp; + } else { + src = &ir->i; + } + } else { + if (LJ_UNLIKELY(bloomtest(rfilt, ref))) + rs = snap_renameref(T, snapno, ref, rs); + if (ra_hasspill(regsp_spill(rs))) { + src = &ex->spill[regsp_spill(rs)]; + if (sz == 8 && !irt_is64(ir->t)) { + tmp = (uint64_t)(uint32_t)*src; + src = (int32_t *)&tmp; + } + } else { + Reg r = regsp_reg(rs); + if (ra_noreg(r)) { + /* Note: this assumes CNEWI is never used for SOFTFP split numbers. */ + lua_assert(sz == 8 && ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT); + snap_restoredata(T, ex, snapno, rfilt, ir->op1, dst, 4); + *(lua_Number *)dst = (lua_Number)*(int32_t *)dst; + return; + } + src = (int32_t *)&ex->gpr[r-RID_MIN_GPR]; +#if !LJ_SOFTFP + if (r >= RID_MAX_GPR) { + src = (int32_t *)&ex->fpr[r-RID_MIN_FPR]; +#if LJ_TARGET_PPC + if (sz == 4) { /* PPC FPRs are always doubles. */ + *(float *)dst = (float)*(double *)src; + return; + } +#else + if (LJ_BE && sz == 4) src++; +#endif + } +#endif + } + } + lua_assert(sz == 1 || sz == 2 || sz == 4 || sz == 8); + if (sz == 4) *(int32_t *)dst = *src; + else if (sz == 8) *(int64_t *)dst = *(int64_t *)src; + else if (sz == 1) *(int8_t *)dst = (int8_t)*src; + else *(int16_t *)dst = (int16_t)*src; +} +#endif + +/* Unsink allocation from the trace exit state. Unsink sunk stores. */ +static void snap_unsink(jit_State *J, GCtrace *T, ExitState *ex, + SnapNo snapno, BloomFilter rfilt, + IRIns *ir, TValue *o) +{ + lua_assert(ir->o == IR_TNEW || ir->o == IR_TDUP || + ir->o == IR_CNEW || ir->o == IR_CNEWI); +#if LJ_HASFFI + if (ir->o == IR_CNEW || ir->o == IR_CNEWI) { + CTState *cts = ctype_cts(J->L); + CTypeID id = (CTypeID)T->ir[ir->op1].i; + CTSize sz = lj_ctype_size(cts, id); + GCcdata *cd = lj_cdata_new(cts, id, sz); + setcdataV(J->L, o, cd); + if (ir->o == IR_CNEWI) { + uint8_t *p = (uint8_t *)cdataptr(cd); + lua_assert(sz == 4 || sz == 8); + if (LJ_32 && sz == 8 && ir+1 < T->ir + T->nins && (ir+1)->o == IR_HIOP) { + snap_restoredata(T, ex, snapno, rfilt, (ir+1)->op2, LJ_LE?p+4:p, 4); + if (LJ_BE) p += 4; + sz = 4; + } + snap_restoredata(T, ex, snapno, rfilt, ir->op2, p, sz); + } else { + IRIns *irs, *irlast = &T->ir[T->snap[snapno].ref]; + for (irs = ir+1; irs < irlast; irs++) + if (irs->r == RID_SINK && snap_sunk_store(T, ir, irs)) { + IRIns *iro = &T->ir[T->ir[irs->op1].op2]; + uint8_t *p = (uint8_t *)cd; + CTSize szs; + lua_assert(irs->o == IR_XSTORE && T->ir[irs->op1].o == IR_ADD); + lua_assert(iro->o == IR_KINT || iro->o == IR_KINT64); + if (irt_is64(irs->t)) szs = 8; + else if (irt_isi8(irs->t) || irt_isu8(irs->t)) szs = 1; + else if (irt_isi16(irs->t) || irt_isu16(irs->t)) szs = 2; + else szs = 4; + if (LJ_64 && iro->o == IR_KINT64) + p += (int64_t)ir_k64(iro)->u64; + else + p += iro->i; + lua_assert(p >= (uint8_t *)cdataptr(cd) && + p + szs <= (uint8_t *)cdataptr(cd) + sz); + if (LJ_32 && irs+1 < T->ir + T->nins && (irs+1)->o == IR_HIOP) { + lua_assert(szs == 4); + snap_restoredata(T, ex, snapno, rfilt, (irs+1)->op2, LJ_LE?p+4:p,4); + if (LJ_BE) p += 4; + } + snap_restoredata(T, ex, snapno, rfilt, irs->op2, p, szs); + } + } + } else +#endif + { + IRIns *irs, *irlast; + GCtab *t = ir->o == IR_TNEW ? lj_tab_new(J->L, ir->op1, ir->op2) : + lj_tab_dup(J->L, ir_ktab(&T->ir[ir->op1])); + settabV(J->L, o, t); + irlast = &T->ir[T->snap[snapno].ref]; + for (irs = ir+1; irs < irlast; irs++) + if (irs->r == RID_SINK && snap_sunk_store(T, ir, irs)) { + IRIns *irk = &T->ir[irs->op1]; + TValue tmp, *val; + lua_assert(irs->o == IR_ASTORE || irs->o == IR_HSTORE || + irs->o == IR_FSTORE); + if (irk->o == IR_FREF) { + lua_assert(irk->op2 == IRFL_TAB_META); + snap_restoreval(J, T, ex, snapno, rfilt, irs->op2, &tmp); + /* NOBARRIER: The table is new (marked white). */ + setgcref(t->metatable, obj2gco(tabV(&tmp))); + } else { + irk = &T->ir[irk->op2]; + if (irk->o == IR_KSLOT) irk = &T->ir[irk->op1]; + lj_ir_kvalue(J->L, &tmp, irk); + val = lj_tab_set(J->L, t, &tmp); + /* NOBARRIER: The table is new (marked white). */ + snap_restoreval(J, T, ex, snapno, rfilt, irs->op2, val); + if (LJ_SOFTFP && irs+1 < T->ir + T->nins && (irs+1)->o == IR_HIOP) { + snap_restoreval(J, T, ex, snapno, rfilt, (irs+1)->op2, &tmp); + val->u32.hi = tmp.u32.lo; + } + } + } + } +} + +/* Restore interpreter state from exit state with the help of a snapshot. */ +const BCIns *lj_snap_restore(jit_State *J, void *exptr) +{ + ExitState *ex = (ExitState *)exptr; + SnapNo snapno = J->exitno; /* For now, snapno == exitno. */ + GCtrace *T = traceref(J, J->parent); + SnapShot *snap = &T->snap[snapno]; + MSize n, nent = snap->nent; + SnapEntry *map = &T->snapmap[snap->mapofs]; + SnapEntry *flinks = &T->snapmap[snap_nextofs(T, snap)-1]; + int32_t ftsz0; + TValue *frame; + BloomFilter rfilt = snap_renamefilter(T, snapno); + const BCIns *pc = snap_pc(map[nent]); + lua_State *L = J->L; + + /* Set interpreter PC to the next PC to get correct error messages. */ + setcframe_pc(cframe_raw(L->cframe), pc+1); + + /* Make sure the stack is big enough for the slots from the snapshot. */ + if (LJ_UNLIKELY(L->base + snap->topslot >= tvref(L->maxstack))) { + L->top = curr_topL(L); + lj_state_growstack(L, snap->topslot - curr_proto(L)->framesize); + } + + /* Fill stack slots with data from the registers and spill slots. */ + frame = L->base-1; + ftsz0 = frame_ftsz(frame); /* Preserve link to previous frame in slot #0. */ + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + if (!(sn & SNAP_NORESTORE)) { + TValue *o = &frame[snap_slot(sn)]; + IRRef ref = snap_ref(sn); + IRIns *ir = &T->ir[ref]; + if (ir->r == RID_SUNK) { + MSize j; + for (j = 0; j < n; j++) + if (snap_ref(map[j]) == ref) { /* De-duplicate sunk allocations. */ + copyTV(L, o, &frame[snap_slot(map[j])]); + goto dupslot; + } + snap_unsink(J, T, ex, snapno, rfilt, ir, o); + dupslot: + continue; + } + snap_restoreval(J, T, ex, snapno, rfilt, ref, o); + if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM) && tvisint(o)) { + TValue tmp; + snap_restoreval(J, T, ex, snapno, rfilt, ref+1, &tmp); + o->u32.hi = tmp.u32.lo; + } else if ((sn & (SNAP_CONT|SNAP_FRAME))) { + /* Overwrite tag with frame link. */ + o->fr.tp.ftsz = snap_slot(sn) != 0 ? (int32_t)*flinks-- : ftsz0; + L->base = o+1; + } + } + } + lua_assert(map + nent == flinks); + + /* Compute current stack top. */ + switch (bc_op(*pc)) { + default: + if (bc_op(*pc) < BC_FUNCF) { + L->top = curr_topL(L); + break; + } + /* fallthrough */ + case BC_CALLM: case BC_CALLMT: case BC_RETM: case BC_TSETM: + L->top = frame + snap->nslots; + break; + } + return pc; +} + +#undef emitir_raw +#undef emitir + +#endif + +``` + +`include/luajit-2.0.5/src/lj_snap.h`: + +```h +/* +** Snapshot handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_SNAP_H +#define _LJ_SNAP_H + +#include "lj_obj.h" +#include "lj_jit.h" + +#if LJ_HASJIT +LJ_FUNC void lj_snap_add(jit_State *J); +LJ_FUNC void lj_snap_purge(jit_State *J); +LJ_FUNC void lj_snap_shrink(jit_State *J); +LJ_FUNC IRIns *lj_snap_regspmap(GCtrace *T, SnapNo snapno, IRIns *ir); +LJ_FUNC void lj_snap_replay(jit_State *J, GCtrace *T); +LJ_FUNC const BCIns *lj_snap_restore(jit_State *J, void *exptr); +LJ_FUNC void lj_snap_grow_buf_(jit_State *J, MSize need); +LJ_FUNC void lj_snap_grow_map_(jit_State *J, MSize need); + +static LJ_AINLINE void lj_snap_grow_buf(jit_State *J, MSize need) +{ + if (LJ_UNLIKELY(need > J->sizesnap)) lj_snap_grow_buf_(J, need); +} + +static LJ_AINLINE void lj_snap_grow_map(jit_State *J, MSize need) +{ + if (LJ_UNLIKELY(need > J->sizesnapmap)) lj_snap_grow_map_(J, need); +} + +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_state.c`: + +```c +/* +** State and stack handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_state_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_func.h" +#include "lj_meta.h" +#include "lj_state.h" +#include "lj_frame.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#endif +#include "lj_trace.h" +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "lj_lex.h" +#include "lj_alloc.h" + +/* -- Stack handling ------------------------------------------------------ */ + +/* Stack sizes. */ +#define LJ_STACK_MIN LUA_MINSTACK /* Min. stack size. */ +#define LJ_STACK_MAX LUAI_MAXSTACK /* Max. stack size. */ +#define LJ_STACK_START (2*LJ_STACK_MIN) /* Starting stack size. */ +#define LJ_STACK_MAXEX (LJ_STACK_MAX + 1 + LJ_STACK_EXTRA) + +/* Explanation of LJ_STACK_EXTRA: +** +** Calls to metamethods store their arguments beyond the current top +** without checking for the stack limit. This avoids stack resizes which +** would invalidate passed TValue pointers. The stack check is performed +** later by the function header. This can safely resize the stack or raise +** an error. Thus we need some extra slots beyond the current stack limit. +** +** Most metamethods need 4 slots above top (cont, mobj, arg1, arg2) plus +** one extra slot if mobj is not a function. Only lj_meta_tset needs 5 +** slots above top, but then mobj is always a function. So we can get by +** with 5 extra slots. +*/ + +/* Resize stack slots and adjust pointers in state. */ +static void resizestack(lua_State *L, MSize n) +{ + TValue *st, *oldst = tvref(L->stack); + ptrdiff_t delta; + MSize oldsize = L->stacksize; + MSize realsize = n + 1 + LJ_STACK_EXTRA; + GCobj *up; + lua_assert((MSize)(tvref(L->maxstack)-oldst)==L->stacksize-LJ_STACK_EXTRA-1); + st = (TValue *)lj_mem_realloc(L, tvref(L->stack), + (MSize)(L->stacksize*sizeof(TValue)), + (MSize)(realsize*sizeof(TValue))); + setmref(L->stack, st); + delta = (char *)st - (char *)oldst; + setmref(L->maxstack, st + n); + while (oldsize < realsize) /* Clear new slots. */ + setnilV(st + oldsize++); + L->stacksize = realsize; + L->base = (TValue *)((char *)L->base + delta); + L->top = (TValue *)((char *)L->top + delta); + for (up = gcref(L->openupval); up != NULL; up = gcnext(up)) + setmref(gco2uv(up)->v, (TValue *)((char *)uvval(gco2uv(up)) + delta)); + if (obj2gco(L) == gcref(G(L)->jit_L)) + setmref(G(L)->jit_base, mref(G(L)->jit_base, char) + delta); +} + +/* Relimit stack after error, in case the limit was overdrawn. */ +void lj_state_relimitstack(lua_State *L) +{ + if (L->stacksize > LJ_STACK_MAXEX && L->top-tvref(L->stack) < LJ_STACK_MAX-1) + resizestack(L, LJ_STACK_MAX); +} + +/* Try to shrink the stack (called from GC). */ +void lj_state_shrinkstack(lua_State *L, MSize used) +{ + if (L->stacksize > LJ_STACK_MAXEX) + return; /* Avoid stack shrinking while handling stack overflow. */ + if (4*used < L->stacksize && + 2*(LJ_STACK_START+LJ_STACK_EXTRA) < L->stacksize && + obj2gco(L) != gcref(G(L)->jit_L)) /* Don't shrink stack of live trace. */ + resizestack(L, L->stacksize >> 1); +} + +/* Try to grow stack. */ +void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need) +{ + MSize n; + if (L->stacksize > LJ_STACK_MAXEX) /* Overflow while handling overflow? */ + lj_err_throw(L, LUA_ERRERR); + n = L->stacksize + need; + if (n > LJ_STACK_MAX) { + n += 2*LUA_MINSTACK; + } else if (n < 2*L->stacksize) { + n = 2*L->stacksize; + if (n >= LJ_STACK_MAX) + n = LJ_STACK_MAX; + } + resizestack(L, n); + if (L->stacksize > LJ_STACK_MAXEX) + lj_err_msg(L, LJ_ERR_STKOV); +} + +void LJ_FASTCALL lj_state_growstack1(lua_State *L) +{ + lj_state_growstack(L, 1); +} + +/* Allocate basic stack for new state. */ +static void stack_init(lua_State *L1, lua_State *L) +{ + TValue *stend, *st = lj_mem_newvec(L, LJ_STACK_START+LJ_STACK_EXTRA, TValue); + setmref(L1->stack, st); + L1->stacksize = LJ_STACK_START + LJ_STACK_EXTRA; + stend = st + L1->stacksize; + setmref(L1->maxstack, stend - LJ_STACK_EXTRA - 1); + L1->base = L1->top = st+1; + setthreadV(L1, st, L1); /* Needed for curr_funcisL() on empty stack. */ + while (st < stend) /* Clear new slots. */ + setnilV(st++); +} + +/* -- State handling ------------------------------------------------------ */ + +/* Open parts that may cause memory-allocation errors. */ +static TValue *cpluaopen(lua_State *L, lua_CFunction dummy, void *ud) +{ + global_State *g = G(L); + UNUSED(dummy); + UNUSED(ud); + stack_init(L, L); + /* NOBARRIER: State initialization, all objects are white. */ + setgcref(L->env, obj2gco(lj_tab_new(L, 0, LJ_MIN_GLOBAL))); + settabV(L, registry(L), lj_tab_new(L, 0, LJ_MIN_REGISTRY)); + lj_str_resize(L, LJ_MIN_STRTAB-1); + lj_meta_init(L); + lj_lex_init(L); + fixstring(lj_err_str(L, LJ_ERR_ERRMEM)); /* Preallocate memory error msg. */ + g->gc.threshold = 4*g->gc.total; + lj_trace_initstate(g); + return NULL; +} + +static void close_state(lua_State *L) +{ + global_State *g = G(L); + lj_func_closeuv(L, tvref(L->stack)); + lj_gc_freeall(g); + lua_assert(gcref(g->gc.root) == obj2gco(L)); + lua_assert(g->strnum == 0); + lj_trace_freestate(g); +#if LJ_HASFFI + lj_ctype_freestate(g); +#endif + lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); + lj_str_freebuf(g, &g->tmpbuf); + lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); + lua_assert(g->gc.total == sizeof(GG_State)); +#ifndef LUAJIT_USE_SYSMALLOC + if (g->allocf == lj_alloc_f) + lj_alloc_destroy(g->allocd); + else +#endif + g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0); +} + +#if LJ_64 && !(defined(LUAJIT_USE_VALGRIND) && defined(LUAJIT_USE_SYSMALLOC)) +lua_State *lj_state_newstate(lua_Alloc f, void *ud) +#else +LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) +#endif +{ + GG_State *GG = (GG_State *)f(ud, NULL, 0, sizeof(GG_State)); + lua_State *L = &GG->L; + global_State *g = &GG->g; + if (GG == NULL || !checkptr32(GG)) return NULL; + memset(GG, 0, sizeof(GG_State)); + L->gct = ~LJ_TTHREAD; + L->marked = LJ_GC_WHITE0 | LJ_GC_FIXED | LJ_GC_SFIXED; /* Prevent free. */ + L->dummy_ffid = FF_C; + setmref(L->glref, g); + g->gc.currentwhite = LJ_GC_WHITE0 | LJ_GC_FIXED; + g->strempty.marked = LJ_GC_WHITE0; + g->strempty.gct = ~LJ_TSTR; + g->allocf = f; + g->allocd = ud; + setgcref(g->mainthref, obj2gco(L)); + setgcref(g->uvhead.prev, obj2gco(&g->uvhead)); + setgcref(g->uvhead.next, obj2gco(&g->uvhead)); + g->strmask = ~(MSize)0; + setnilV(registry(L)); + setnilV(&g->nilnode.val); + setnilV(&g->nilnode.key); + setmref(g->nilnode.freetop, &g->nilnode); + lj_str_initbuf(&g->tmpbuf); + g->gc.state = GCSpause; + setgcref(g->gc.root, obj2gco(L)); + setmref(g->gc.sweep, &g->gc.root); + g->gc.total = sizeof(GG_State); + g->gc.pause = LUAI_GCPAUSE; + g->gc.stepmul = LUAI_GCMUL; + lj_dispatch_init((GG_State *)L); + L->status = LUA_ERRERR+1; /* Avoid touching the stack upon memory error. */ + if (lj_vm_cpcall(L, NULL, NULL, cpluaopen) != 0) { + /* Memory allocation error: free partial state. */ + close_state(L); + return NULL; + } + L->status = 0; + return L; +} + +static TValue *cpfinalize(lua_State *L, lua_CFunction dummy, void *ud) +{ + UNUSED(dummy); + UNUSED(ud); + lj_gc_finalize_cdata(L); + lj_gc_finalize_udata(L); + /* Frame pop omitted. */ + return NULL; +} + +LUA_API void lua_close(lua_State *L) +{ + global_State *g = G(L); + int i; + L = mainthread(g); /* Only the main thread can be closed. */ + lj_func_closeuv(L, tvref(L->stack)); + lj_gc_separateudata(g, 1); /* Separate udata which have GC metamethods. */ +#if LJ_HASJIT + G2J(g)->flags &= ~JIT_F_ON; + G2J(g)->state = LJ_TRACE_IDLE; + lj_dispatch_update(g); +#endif + for (i = 0;;) { + hook_enter(g); + L->status = 0; + L->cframe = NULL; + L->base = L->top = tvref(L->stack) + 1; + if (lj_vm_cpcall(L, NULL, NULL, cpfinalize) == 0) { + if (++i >= 10) break; + lj_gc_separateudata(g, 1); /* Separate udata again. */ + if (gcref(g->gc.mmudata) == NULL) /* Until nothing is left to do. */ + break; + } + } + close_state(L); +} + +lua_State *lj_state_new(lua_State *L) +{ + lua_State *L1 = lj_mem_newobj(L, lua_State); + L1->gct = ~LJ_TTHREAD; + L1->dummy_ffid = FF_C; + L1->status = 0; + L1->stacksize = 0; + setmref(L1->stack, NULL); + L1->cframe = NULL; + /* NOBARRIER: The lua_State is new (marked white). */ + setgcrefnull(L1->openupval); + setmrefr(L1->glref, L->glref); + setgcrefr(L1->env, L->env); + stack_init(L1, L); /* init stack */ + lua_assert(iswhite(obj2gco(L1))); + return L1; +} + +void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L) +{ + lua_assert(L != mainthread(g)); + lj_func_closeuv(L, tvref(L->stack)); + lua_assert(gcref(L->openupval) == NULL); + lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); + lj_mem_freet(g, L); +} + + +``` + +`include/luajit-2.0.5/src/lj_state.h`: + +```h +/* +** State and stack handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_STATE_H +#define _LJ_STATE_H + +#include "lj_obj.h" + +#define incr_top(L) \ + (++L->top >= tvref(L->maxstack) && (lj_state_growstack1(L), 0)) + +#define savestack(L, p) ((char *)(p) - mref(L->stack, char)) +#define restorestack(L, n) ((TValue *)(mref(L->stack, char) + (n))) + +LJ_FUNC void lj_state_relimitstack(lua_State *L); +LJ_FUNC void lj_state_shrinkstack(lua_State *L, MSize used); +LJ_FUNCA void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need); +LJ_FUNC void LJ_FASTCALL lj_state_growstack1(lua_State *L); + +static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need) +{ + if ((mref(L->maxstack, char) - (char *)L->top) <= + (ptrdiff_t)need*(ptrdiff_t)sizeof(TValue)) + lj_state_growstack(L, need); +} + +LJ_FUNC lua_State *lj_state_new(lua_State *L); +LJ_FUNC void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L); +#if LJ_64 +LJ_FUNC lua_State *lj_state_newstate(lua_Alloc f, void *ud); +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_str.c`: + +```c +/* +** String handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#include + +#define lj_str_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_state.h" +#include "lj_char.h" + +/* -- String interning ---------------------------------------------------- */ + +/* Ordered compare of strings. Assumes string data is 4-byte aligned. */ +int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b) +{ + MSize i, n = a->len > b->len ? b->len : a->len; + for (i = 0; i < n; i += 4) { + /* Note: innocuous access up to end of string + 3. */ + uint32_t va = *(const uint32_t *)(strdata(a)+i); + uint32_t vb = *(const uint32_t *)(strdata(b)+i); + if (va != vb) { +#if LJ_LE + va = lj_bswap(va); vb = lj_bswap(vb); +#endif + i -= n; + if ((int32_t)i >= -3) { + va >>= 32+(i<<3); vb >>= 32+(i<<3); + if (va == vb) break; + } + return va < vb ? -1 : 1; + } + } + return (int32_t)(a->len - b->len); +} + +/* Fast string data comparison. Caveat: unaligned access to 1st string! */ +static LJ_AINLINE int str_fastcmp(const char *a, const char *b, MSize len) +{ + MSize i = 0; + lua_assert(len > 0); + lua_assert((((uintptr_t)a+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4); + do { /* Note: innocuous access up to end of string + 3. */ + uint32_t v = lj_getu32(a+i) ^ *(const uint32_t *)(b+i); + if (v) { + i -= len; +#if LJ_LE + return (int32_t)i >= -3 ? (v << (32+(i<<3))) : 1; +#else + return (int32_t)i >= -3 ? (v >> (32+(i<<3))) : 1; +#endif + } + i += 4; + } while (i < len); + return 0; +} + +/* Resize the string hash table (grow and shrink). */ +void lj_str_resize(lua_State *L, MSize newmask) +{ + global_State *g = G(L); + GCRef *newhash; + MSize i; + if (g->gc.state == GCSsweepstring || newmask >= LJ_MAX_STRTAB-1) + return; /* No resizing during GC traversal or if already too big. */ + newhash = lj_mem_newvec(L, newmask+1, GCRef); + memset(newhash, 0, (newmask+1)*sizeof(GCRef)); + for (i = g->strmask; i != ~(MSize)0; i--) { /* Rehash old table. */ + GCobj *p = gcref(g->strhash[i]); + while (p) { /* Follow each hash chain and reinsert all strings. */ + MSize h = gco2str(p)->hash & newmask; + GCobj *next = gcnext(p); + /* NOBARRIER: The string table is a GC root. */ + setgcrefr(p->gch.nextgc, newhash[h]); + setgcref(newhash[h], p); + p = next; + } + } + lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); + g->strmask = newmask; + g->strhash = newhash; +} + +/* Intern a string and return string object. */ +GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx) +{ + global_State *g; + GCstr *s; + GCobj *o; + MSize len = (MSize)lenx; + MSize a, b, h = len; + if (lenx >= LJ_MAX_STR) + lj_err_msg(L, LJ_ERR_STROV); + g = G(L); + /* Compute string hash. Constants taken from lookup3 hash by Bob Jenkins. */ + if (len >= 4) { /* Caveat: unaligned access! */ + a = lj_getu32(str); + h ^= lj_getu32(str+len-4); + b = lj_getu32(str+(len>>1)-2); + h ^= b; h -= lj_rol(b, 14); + b += lj_getu32(str+(len>>2)-1); + } else if (len > 0) { + a = *(const uint8_t *)str; + h ^= *(const uint8_t *)(str+len-1); + b = *(const uint8_t *)(str+(len>>1)); + h ^= b; h -= lj_rol(b, 14); + } else { + return &g->strempty; + } + a ^= h; a -= lj_rol(h, 11); + b ^= a; b -= lj_rol(a, 25); + h ^= b; h -= lj_rol(b, 16); + /* Check if the string has already been interned. */ + o = gcref(g->strhash[h & g->strmask]); + if (LJ_LIKELY((((uintptr_t)str+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4)) { + while (o != NULL) { + GCstr *sx = gco2str(o); + if (sx->len == len && str_fastcmp(str, strdata(sx), len) == 0) { + /* Resurrect if dead. Can only happen with fixstring() (keywords). */ + if (isdead(g, o)) flipwhite(o); + return sx; /* Return existing string. */ + } + o = gcnext(o); + } + } else { /* Slow path: end of string is too close to a page boundary. */ + while (o != NULL) { + GCstr *sx = gco2str(o); + if (sx->len == len && memcmp(str, strdata(sx), len) == 0) { + /* Resurrect if dead. Can only happen with fixstring() (keywords). */ + if (isdead(g, o)) flipwhite(o); + return sx; /* Return existing string. */ + } + o = gcnext(o); + } + } + /* Nope, create a new string. */ + s = lj_mem_newt(L, sizeof(GCstr)+len+1, GCstr); + newwhite(g, s); + s->gct = ~LJ_TSTR; + s->len = len; + s->hash = h; + s->reserved = 0; + memcpy(strdatawr(s), str, len); + strdatawr(s)[len] = '\0'; /* Zero-terminate string. */ + /* Add it to string hash table. */ + h &= g->strmask; + s->nextgc = g->strhash[h]; + /* NOBARRIER: The string table is a GC root. */ + setgcref(g->strhash[h], obj2gco(s)); + if (g->strnum++ > g->strmask) /* Allow a 100% load factor. */ + lj_str_resize(L, (g->strmask<<1)+1); /* Grow string table. */ + return s; /* Return newly interned string. */ +} + +void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s) +{ + g->strnum--; + lj_mem_free(g, s, sizestring(s)); +} + +/* -- Type conversions ---------------------------------------------------- */ + +/* Print number to buffer. Canonicalizes non-finite values. */ +size_t LJ_FASTCALL lj_str_bufnum(char *s, cTValue *o) +{ + if (LJ_LIKELY((o->u32.hi << 1) < 0xffe00000)) { /* Finite? */ + lua_Number n = o->n; +#if __BIONIC__ + if (tvismzero(o)) { s[0] = '-'; s[1] = '0'; return 2; } +#endif + return (size_t)lua_number2str(s, n); + } else if (((o->u32.hi & 0x000fffff) | o->u32.lo) != 0) { + s[0] = 'n'; s[1] = 'a'; s[2] = 'n'; return 3; + } else if ((o->u32.hi & 0x80000000) == 0) { + s[0] = 'i'; s[1] = 'n'; s[2] = 'f'; return 3; + } else { + s[0] = '-'; s[1] = 'i'; s[2] = 'n'; s[3] = 'f'; return 4; + } +} + +/* Print integer to buffer. Returns pointer to start. */ +char * LJ_FASTCALL lj_str_bufint(char *p, int32_t k) +{ + uint32_t u = (uint32_t)(k < 0 ? -k : k); + p += 1+10; + do { *--p = (char)('0' + u % 10); } while (u /= 10); + if (k < 0) *--p = '-'; + return p; +} + +/* Convert number to string. */ +GCstr * LJ_FASTCALL lj_str_fromnum(lua_State *L, const lua_Number *np) +{ + char buf[LJ_STR_NUMBUF]; + size_t len = lj_str_bufnum(buf, (TValue *)np); + return lj_str_new(L, buf, len); +} + +/* Convert integer to string. */ +GCstr * LJ_FASTCALL lj_str_fromint(lua_State *L, int32_t k) +{ + char s[1+10]; + char *p = lj_str_bufint(s, k); + return lj_str_new(L, p, (size_t)(s+sizeof(s)-p)); +} + +GCstr * LJ_FASTCALL lj_str_fromnumber(lua_State *L, cTValue *o) +{ + return tvisint(o) ? lj_str_fromint(L, intV(o)) : lj_str_fromnum(L, &o->n); +} + +/* -- String formatting --------------------------------------------------- */ + +static void addstr(lua_State *L, SBuf *sb, const char *str, MSize len) +{ + char *p; + MSize i; + if (sb->n + len > sb->sz) { + MSize sz = sb->sz * 2; + while (sb->n + len > sz) sz = sz * 2; + lj_str_resizebuf(L, sb, sz); + } + p = sb->buf + sb->n; + sb->n += len; + for (i = 0; i < len; i++) p[i] = str[i]; +} + +static void addchar(lua_State *L, SBuf *sb, int c) +{ + if (sb->n + 1 > sb->sz) { + MSize sz = sb->sz * 2; + lj_str_resizebuf(L, sb, sz); + } + sb->buf[sb->n++] = (char)c; +} + +/* Push formatted message as a string object to Lua stack. va_list variant. */ +const char *lj_str_pushvf(lua_State *L, const char *fmt, va_list argp) +{ + SBuf *sb = &G(L)->tmpbuf; + lj_str_needbuf(L, sb, (MSize)strlen(fmt)); + lj_str_resetbuf(sb); + for (;;) { + const char *e = strchr(fmt, '%'); + if (e == NULL) break; + addstr(L, sb, fmt, (MSize)(e-fmt)); + /* This function only handles %s, %c, %d, %f and %p formats. */ + switch (e[1]) { + case 's': { + const char *s = va_arg(argp, char *); + if (s == NULL) s = "(null)"; + addstr(L, sb, s, (MSize)strlen(s)); + break; + } + case 'c': + addchar(L, sb, va_arg(argp, int)); + break; + case 'd': { + char buf[LJ_STR_INTBUF]; + char *p = lj_str_bufint(buf, va_arg(argp, int32_t)); + addstr(L, sb, p, (MSize)(buf+LJ_STR_INTBUF-p)); + break; + } + case 'f': { + char buf[LJ_STR_NUMBUF]; + TValue tv; + MSize len; + tv.n = (lua_Number)(va_arg(argp, LUAI_UACNUMBER)); + len = (MSize)lj_str_bufnum(buf, &tv); + addstr(L, sb, buf, len); + break; + } + case 'p': { +#define FMTP_CHARS (2*sizeof(ptrdiff_t)) + char buf[2+FMTP_CHARS]; + ptrdiff_t p = (ptrdiff_t)(va_arg(argp, void *)); + ptrdiff_t i, lasti = 2+FMTP_CHARS; + if (p == 0) { + addstr(L, sb, "NULL", 4); + break; + } +#if LJ_64 + /* Shorten output for 64 bit pointers. */ + lasti = 2+2*4+((p >> 32) ? 2+2*(lj_fls((uint32_t)(p >> 32))>>3) : 0); +#endif + buf[0] = '0'; + buf[1] = 'x'; + for (i = lasti-1; i >= 2; i--, p >>= 4) + buf[i] = "0123456789abcdef"[(p & 15)]; + addstr(L, sb, buf, (MSize)lasti); + break; + } + case '%': + addchar(L, sb, '%'); + break; + default: + addchar(L, sb, '%'); + addchar(L, sb, e[1]); + break; + } + fmt = e+2; + } + addstr(L, sb, fmt, (MSize)strlen(fmt)); + setstrV(L, L->top, lj_str_new(L, sb->buf, sb->n)); + incr_top(L); + return strVdata(L->top - 1); +} + +/* Push formatted message as a string object to Lua stack. Vararg variant. */ +const char *lj_str_pushf(lua_State *L, const char *fmt, ...) +{ + const char *msg; + va_list argp; + va_start(argp, fmt); + msg = lj_str_pushvf(L, fmt, argp); + va_end(argp); + return msg; +} + +/* -- Buffer handling ----------------------------------------------------- */ + +char *lj_str_needbuf(lua_State *L, SBuf *sb, MSize sz) +{ + if (sz > sb->sz) { + if (sz < LJ_MIN_SBUF) sz = LJ_MIN_SBUF; + lj_str_resizebuf(L, sb, sz); + } + return sb->buf; +} + + +``` + +`include/luajit-2.0.5/src/lj_str.h`: + +```h +/* +** String handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_STR_H +#define _LJ_STR_H + +#include + +#include "lj_obj.h" + +/* String interning. */ +LJ_FUNC int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b); +LJ_FUNC void lj_str_resize(lua_State *L, MSize newmask); +LJ_FUNCA GCstr *lj_str_new(lua_State *L, const char *str, size_t len); +LJ_FUNC void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s); + +#define lj_str_newz(L, s) (lj_str_new(L, s, strlen(s))) +#define lj_str_newlit(L, s) (lj_str_new(L, "" s, sizeof(s)-1)) + +/* Type conversions. */ +LJ_FUNC size_t LJ_FASTCALL lj_str_bufnum(char *s, cTValue *o); +LJ_FUNC char * LJ_FASTCALL lj_str_bufint(char *p, int32_t k); +LJ_FUNCA GCstr * LJ_FASTCALL lj_str_fromnum(lua_State *L, const lua_Number *np); +LJ_FUNC GCstr * LJ_FASTCALL lj_str_fromint(lua_State *L, int32_t k); +LJ_FUNCA GCstr * LJ_FASTCALL lj_str_fromnumber(lua_State *L, cTValue *o); + +#define LJ_STR_INTBUF (1+10) +#define LJ_STR_NUMBUF LUAI_MAXNUMBER2STR + +/* String formatting. */ +LJ_FUNC const char *lj_str_pushvf(lua_State *L, const char *fmt, va_list argp); +LJ_FUNC const char *lj_str_pushf(lua_State *L, const char *fmt, ...) +#if defined(__GNUC__) + __attribute__ ((format (printf, 2, 3))) +#endif + ; + +/* Resizable string buffers. Struct definition in lj_obj.h. */ +LJ_FUNC char *lj_str_needbuf(lua_State *L, SBuf *sb, MSize sz); + +#define lj_str_initbuf(sb) ((sb)->buf = NULL, (sb)->sz = 0) +#define lj_str_resetbuf(sb) ((sb)->n = 0) +#define lj_str_resizebuf(L, sb, size) \ + ((sb)->buf = (char *)lj_mem_realloc(L, (sb)->buf, (sb)->sz, (size)), \ + (sb)->sz = (size)) +#define lj_str_freebuf(g, sb) lj_mem_free(g, (void *)(sb)->buf, (sb)->sz) + +#endif + +``` + +`include/luajit-2.0.5/src/lj_strscan.c`: + +```c +/* +** String scanning. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include + +#define lj_strscan_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_char.h" +#include "lj_strscan.h" + +/* -- Scanning numbers ---------------------------------------------------- */ + +/* +** Rationale for the builtin string to number conversion library: +** +** It removes a dependency on libc's strtod(), which is a true portability +** nightmare. Mainly due to the plethora of supported OS and toolchain +** combinations. Sadly, the various implementations +** a) are often buggy, incomplete (no hex floats) and/or imprecise, +** b) sometimes crash or hang on certain inputs, +** c) return non-standard NaNs that need to be filtered out, and +** d) fail if the locale-specific decimal separator is not a dot, +** which can only be fixed with atrocious workarounds. +** +** Also, most of the strtod() implementations are hopelessly bloated, +** which is not just an I-cache hog, but a problem for static linkage +** on embedded systems, too. +** +** OTOH the builtin conversion function is very compact. Even though it +** does a lot more, like parsing long longs, octal or imaginary numbers +** and returning the result in different formats: +** a) It needs less than 3 KB (!) of machine code (on x64 with -Os), +** b) it doesn't perform any dynamic allocation and, +** c) it needs only around 600 bytes of stack space. +** +** The builtin function is faster than strtod() for typical inputs, e.g. +** "123", "1.5" or "1e6". Arguably, it's slower for very large exponents, +** which are not very common (this could be fixed, if needed). +** +** And most importantly, the builtin function is equally precise on all +** platforms. It correctly converts and rounds any input to a double. +** If this is not the case, please send a bug report -- but PLEASE verify +** that the implementation you're comparing to is not the culprit! +** +** The implementation quickly pre-scans the entire string first and +** handles simple integers on-the-fly. Otherwise, it dispatches to the +** base-specific parser. Hex and octal is straightforward. +** +** Decimal to binary conversion uses a fixed-length circular buffer in +** base 100. Some simple cases are handled directly. For other cases, the +** number in the buffer is up-scaled or down-scaled until the integer part +** is in the proper range. Then the integer part is rounded and converted +** to a double which is finally rescaled to the result. Denormals need +** special treatment to prevent incorrect 'double rounding'. +*/ + +/* Definitions for circular decimal digit buffer (base 100 = 2 digits/byte). */ +#define STRSCAN_DIG 1024 +#define STRSCAN_MAXDIG 800 /* 772 + extra are sufficient. */ +#define STRSCAN_DDIG (STRSCAN_DIG/2) +#define STRSCAN_DMASK (STRSCAN_DDIG-1) + +/* Helpers for circular buffer. */ +#define DNEXT(a) (((a)+1) & STRSCAN_DMASK) +#define DPREV(a) (((a)-1) & STRSCAN_DMASK) +#define DLEN(lo, hi) ((int32_t)(((lo)-(hi)) & STRSCAN_DMASK)) + +#define casecmp(c, k) (((c) | 0x20) == k) + +/* Final conversion to double. */ +static void strscan_double(uint64_t x, TValue *o, int32_t ex2, int32_t neg) +{ + double n; + + /* Avoid double rounding for denormals. */ + if (LJ_UNLIKELY(ex2 <= -1075 && x != 0)) { + /* NYI: all of this generates way too much code on 32 bit CPUs. */ +#if defined(__GNUC__) && LJ_64 + int32_t b = (int32_t)(__builtin_clzll(x)^63); +#else + int32_t b = (x>>32) ? 32+(int32_t)lj_fls((uint32_t)(x>>32)) : + (int32_t)lj_fls((uint32_t)x); +#endif + if ((int32_t)b + ex2 <= -1023 && (int32_t)b + ex2 >= -1075) { + uint64_t rb = (uint64_t)1 << (-1075-ex2); + if ((x & rb) && ((x & (rb+rb+rb-1)))) x += rb+rb; + x = (x & ~(rb+rb-1)); + } + } + + /* Convert to double using a signed int64_t conversion, then rescale. */ + lua_assert((int64_t)x >= 0); + n = (double)(int64_t)x; + if (neg) n = -n; + if (ex2) n = ldexp(n, ex2); + o->n = n; +} + +/* Parse hexadecimal number. */ +static StrScanFmt strscan_hex(const uint8_t *p, TValue *o, + StrScanFmt fmt, uint32_t opt, + int32_t ex2, int32_t neg, uint32_t dig) +{ + uint64_t x = 0; + uint32_t i; + + /* Scan hex digits. */ + for (i = dig > 16 ? 16 : dig ; i; i--, p++) { + uint32_t d = (*p != '.' ? *p : *++p); if (d > '9') d += 9; + x = (x << 4) + (d & 15); + } + + /* Summarize rounding-effect of excess digits. */ + for (i = 16; i < dig; i++, p++) + x |= ((*p != '.' ? *p : *++p) != '0'), ex2 += 4; + + /* Format-specific handling. */ + switch (fmt) { + case STRSCAN_INT: + if (!(opt & STRSCAN_OPT_TONUM) && x < 0x80000000u+neg) { + o->i = neg ? -(int32_t)x : (int32_t)x; + return STRSCAN_INT; /* Fast path for 32 bit integers. */ + } + if (!(opt & STRSCAN_OPT_C)) { fmt = STRSCAN_NUM; break; } + /* fallthrough */ + case STRSCAN_U32: + if (dig > 8) return STRSCAN_ERROR; + o->i = neg ? -(int32_t)x : (int32_t)x; + return STRSCAN_U32; + case STRSCAN_I64: + case STRSCAN_U64: + if (dig > 16) return STRSCAN_ERROR; + o->u64 = neg ? (uint64_t)-(int64_t)x : x; + return fmt; + default: + break; + } + + /* Reduce range then convert to double. */ + if ((x & U64x(c0000000,0000000))) { x = (x >> 2) | (x & 3); ex2 += 2; } + strscan_double(x, o, ex2, neg); + return fmt; +} + +/* Parse octal number. */ +static StrScanFmt strscan_oct(const uint8_t *p, TValue *o, + StrScanFmt fmt, int32_t neg, uint32_t dig) +{ + uint64_t x = 0; + + /* Scan octal digits. */ + if (dig > 22 || (dig == 22 && *p > '1')) return STRSCAN_ERROR; + while (dig-- > 0) { + if (!(*p >= '0' && *p <= '7')) return STRSCAN_ERROR; + x = (x << 3) + (*p++ & 7); + } + + /* Format-specific handling. */ + switch (fmt) { + case STRSCAN_INT: + if (x >= 0x80000000u+neg) fmt = STRSCAN_U32; + /* fallthrough */ + case STRSCAN_U32: + if ((x >> 32)) return STRSCAN_ERROR; + o->i = neg ? -(int32_t)x : (int32_t)x; + break; + default: + case STRSCAN_I64: + case STRSCAN_U64: + o->u64 = neg ? (uint64_t)-(int64_t)x : x; + break; + } + return fmt; +} + +/* Parse decimal number. */ +static StrScanFmt strscan_dec(const uint8_t *p, TValue *o, + StrScanFmt fmt, uint32_t opt, + int32_t ex10, int32_t neg, uint32_t dig) +{ + uint8_t xi[STRSCAN_DDIG], *xip = xi; + + if (dig) { + uint32_t i = dig; + if (i > STRSCAN_MAXDIG) { + ex10 += (int32_t)(i - STRSCAN_MAXDIG); + i = STRSCAN_MAXDIG; + } + /* Scan unaligned leading digit. */ + if (((ex10^i) & 1)) + *xip++ = ((*p != '.' ? *p : *++p) & 15), i--, p++; + /* Scan aligned double-digits. */ + for ( ; i > 1; i -= 2) { + uint32_t d = 10 * ((*p != '.' ? *p : *++p) & 15); p++; + *xip++ = d + ((*p != '.' ? *p : *++p) & 15); p++; + } + /* Scan and realign trailing digit. */ + if (i) *xip++ = 10 * ((*p != '.' ? *p : *++p) & 15), ex10--, dig++, p++; + + /* Summarize rounding-effect of excess digits. */ + if (dig > STRSCAN_MAXDIG) { + do { + if ((*p != '.' ? *p : *++p) != '0') { xip[-1] |= 1; break; } + p++; + } while (--dig > STRSCAN_MAXDIG); + dig = STRSCAN_MAXDIG; + } else { /* Simplify exponent. */ + while (ex10 > 0 && dig <= 18) *xip++ = 0, ex10 -= 2, dig += 2; + } + } else { /* Only got zeros. */ + ex10 = 0; + xi[0] = 0; + } + + /* Fast path for numbers in integer format (but handles e.g. 1e6, too). */ + if (dig <= 20 && ex10 == 0) { + uint8_t *xis; + uint64_t x = xi[0]; + double n; + for (xis = xi+1; xis < xip; xis++) x = x * 100 + *xis; + if (!(dig == 20 && (xi[0] > 18 || (int64_t)x >= 0))) { /* No overflow? */ + /* Format-specific handling. */ + switch (fmt) { + case STRSCAN_INT: + if (!(opt & STRSCAN_OPT_TONUM) && x < 0x80000000u+neg) { + o->i = neg ? -(int32_t)x : (int32_t)x; + return STRSCAN_INT; /* Fast path for 32 bit integers. */ + } + if (!(opt & STRSCAN_OPT_C)) { fmt = STRSCAN_NUM; goto plainnumber; } + /* fallthrough */ + case STRSCAN_U32: + if ((x >> 32) != 0) return STRSCAN_ERROR; + o->i = neg ? -(int32_t)x : (int32_t)x; + return STRSCAN_U32; + case STRSCAN_I64: + case STRSCAN_U64: + o->u64 = neg ? (uint64_t)-(int64_t)x : x; + return fmt; + default: + plainnumber: /* Fast path for plain numbers < 2^63. */ + if ((int64_t)x < 0) break; + n = (double)(int64_t)x; + if (neg) n = -n; + o->n = n; + return fmt; + } + } + } + + /* Slow non-integer path. */ + if (fmt == STRSCAN_INT) { + if ((opt & STRSCAN_OPT_C)) return STRSCAN_ERROR; + fmt = STRSCAN_NUM; + } else if (fmt > STRSCAN_INT) { + return STRSCAN_ERROR; + } + { + uint32_t hi = 0, lo = (uint32_t)(xip-xi); + int32_t ex2 = 0, idig = (int32_t)lo + (ex10 >> 1); + + lua_assert(lo > 0 && (ex10 & 1) == 0); + + /* Handle simple overflow/underflow. */ + if (idig > 310/2) { if (neg) setminfV(o); else setpinfV(o); return fmt; } + else if (idig < -326/2) { o->n = neg ? -0.0 : 0.0; return fmt; } + + /* Scale up until we have at least 17 or 18 integer part digits. */ + while (idig < 9 && idig < DLEN(lo, hi)) { + uint32_t i, cy = 0; + ex2 -= 6; + for (i = DPREV(lo); ; i = DPREV(i)) { + uint32_t d = (xi[i] << 6) + cy; + cy = (((d >> 2) * 5243) >> 17); d = d - cy * 100; /* Div/mod 100. */ + xi[i] = (uint8_t)d; + if (i == hi) break; + if (d == 0 && i == DPREV(lo)) lo = i; + } + if (cy) { + hi = DPREV(hi); + if (xi[DPREV(lo)] == 0) lo = DPREV(lo); + else if (hi == lo) { lo = DPREV(lo); xi[DPREV(lo)] |= xi[lo]; } + xi[hi] = (uint8_t)cy; idig++; + } + } + + /* Scale down until no more than 17 or 18 integer part digits remain. */ + while (idig > 9) { + uint32_t i = hi, cy = 0; + ex2 += 6; + do { + cy += xi[i]; + xi[i] = (cy >> 6); + cy = 100 * (cy & 0x3f); + if (xi[i] == 0 && i == hi) hi = DNEXT(hi), idig--; + i = DNEXT(i); + } while (i != lo); + while (cy) { + if (hi == lo) { xi[DPREV(lo)] |= 1; break; } + xi[lo] = (cy >> 6); lo = DNEXT(lo); + cy = 100 * (cy & 0x3f); + } + } + + /* Collect integer part digits and convert to rescaled double. */ + { + uint64_t x = xi[hi]; + uint32_t i; + for (i = DNEXT(hi); --idig > 0 && i != lo; i = DNEXT(i)) + x = x * 100 + xi[i]; + if (i == lo) { + while (--idig >= 0) x = x * 100; + } else { /* Gather round bit from remaining digits. */ + x <<= 1; ex2--; + do { + if (xi[i]) { x |= 1; break; } + i = DNEXT(i); + } while (i != lo); + } + strscan_double(x, o, ex2, neg); + } + } + return fmt; +} + +/* Scan string containing a number. Returns format. Returns value in o. */ +StrScanFmt lj_strscan_scan(const uint8_t *p, TValue *o, uint32_t opt) +{ + int32_t neg = 0; + + /* Remove leading space, parse sign and non-numbers. */ + if (LJ_UNLIKELY(!lj_char_isdigit(*p))) { + while (lj_char_isspace(*p)) p++; + if (*p == '+' || *p == '-') neg = (*p++ == '-'); + if (LJ_UNLIKELY(*p >= 'A')) { /* Parse "inf", "infinity" or "nan". */ + TValue tmp; + setnanV(&tmp); + if (casecmp(p[0],'i') && casecmp(p[1],'n') && casecmp(p[2],'f')) { + if (neg) setminfV(&tmp); else setpinfV(&tmp); + p += 3; + if (casecmp(p[0],'i') && casecmp(p[1],'n') && casecmp(p[2],'i') && + casecmp(p[3],'t') && casecmp(p[4],'y')) p += 5; + } else if (casecmp(p[0],'n') && casecmp(p[1],'a') && casecmp(p[2],'n')) { + p += 3; + } + while (lj_char_isspace(*p)) p++; + if (*p) return STRSCAN_ERROR; + o->u64 = tmp.u64; + return STRSCAN_NUM; + } + } + + /* Parse regular number. */ + { + StrScanFmt fmt = STRSCAN_INT; + int cmask = LJ_CHAR_DIGIT; + int base = (opt & STRSCAN_OPT_C) && *p == '0' ? 0 : 10; + const uint8_t *sp, *dp = NULL; + uint32_t dig = 0, hasdig = 0, x = 0; + int32_t ex = 0; + + /* Determine base and skip leading zeros. */ + if (LJ_UNLIKELY(*p <= '0')) { + if (*p == '0' && casecmp(p[1], 'x')) + base = 16, cmask = LJ_CHAR_XDIGIT, p += 2; + for ( ; ; p++) { + if (*p == '0') { + hasdig = 1; + } else if (*p == '.') { + if (dp) return STRSCAN_ERROR; + dp = p; + } else { + break; + } + } + } + + /* Preliminary digit and decimal point scan. */ + for (sp = p; ; p++) { + if (LJ_LIKELY(lj_char_isa(*p, cmask))) { + x = x * 10 + (*p & 15); /* For fast path below. */ + dig++; + } else if (*p == '.') { + if (dp) return STRSCAN_ERROR; + dp = p; + } else { + break; + } + } + if (!(hasdig | dig)) return STRSCAN_ERROR; + + /* Handle decimal point. */ + if (dp) { + fmt = STRSCAN_NUM; + if (dig) { + ex = (int32_t)(dp-(p-1)); dp = p-1; + while (ex < 0 && *dp-- == '0') ex++, dig--; /* Skip trailing zeros. */ + if (base == 16) ex *= 4; + } + } + + /* Parse exponent. */ + if (casecmp(*p, (uint32_t)(base == 16 ? 'p' : 'e'))) { + uint32_t xx; + int negx = 0; + fmt = STRSCAN_NUM; p++; + if (*p == '+' || *p == '-') negx = (*p++ == '-'); + if (!lj_char_isdigit(*p)) return STRSCAN_ERROR; + xx = (*p++ & 15); + while (lj_char_isdigit(*p)) { + if (xx < 65536) xx = xx * 10 + (*p & 15); + p++; + } + ex += negx ? -(int32_t)xx : (int32_t)xx; + } + + /* Parse suffix. */ + if (*p) { + /* I (IMAG), U (U32), LL (I64), ULL/LLU (U64), L (long), UL/LU (ulong). */ + /* NYI: f (float). Not needed until cp_number() handles non-integers. */ + if (casecmp(*p, 'i')) { + if (!(opt & STRSCAN_OPT_IMAG)) return STRSCAN_ERROR; + p++; fmt = STRSCAN_IMAG; + } else if (fmt == STRSCAN_INT) { + if (casecmp(*p, 'u')) p++, fmt = STRSCAN_U32; + if (casecmp(*p, 'l')) { + p++; + if (casecmp(*p, 'l')) p++, fmt += STRSCAN_I64 - STRSCAN_INT; + else if (!(opt & STRSCAN_OPT_C)) return STRSCAN_ERROR; + else if (sizeof(long) == 8) fmt += STRSCAN_I64 - STRSCAN_INT; + } + if (casecmp(*p, 'u') && (fmt == STRSCAN_INT || fmt == STRSCAN_I64)) + p++, fmt += STRSCAN_U32 - STRSCAN_INT; + if ((fmt == STRSCAN_U32 && !(opt & STRSCAN_OPT_C)) || + (fmt >= STRSCAN_I64 && !(opt & STRSCAN_OPT_LL))) + return STRSCAN_ERROR; + } + while (lj_char_isspace(*p)) p++; + if (*p) return STRSCAN_ERROR; + } + + /* Fast path for decimal 32 bit integers. */ + if (fmt == STRSCAN_INT && base == 10 && + (dig < 10 || (dig == 10 && *sp <= '2' && x < 0x80000000u+neg))) { + int32_t y = neg ? -(int32_t)x : (int32_t)x; + if ((opt & STRSCAN_OPT_TONUM)) { + o->n = (double)y; + return STRSCAN_NUM; + } else { + o->i = y; + return STRSCAN_INT; + } + } + + /* Dispatch to base-specific parser. */ + if (base == 0 && !(fmt == STRSCAN_NUM || fmt == STRSCAN_IMAG)) + return strscan_oct(sp, o, fmt, neg, dig); + if (base == 16) + fmt = strscan_hex(sp, o, fmt, opt, ex, neg, dig); + else + fmt = strscan_dec(sp, o, fmt, opt, ex, neg, dig); + + /* Try to convert number to integer, if requested. */ + if (fmt == STRSCAN_NUM && (opt & STRSCAN_OPT_TOINT)) { + double n = o->n; + int32_t i = lj_num2int(n); + if (n == (lua_Number)i) { o->i = i; return STRSCAN_INT; } + } + return fmt; + } +} + +int LJ_FASTCALL lj_strscan_num(GCstr *str, TValue *o) +{ + StrScanFmt fmt = lj_strscan_scan((const uint8_t *)strdata(str), o, + STRSCAN_OPT_TONUM); + lua_assert(fmt == STRSCAN_ERROR || fmt == STRSCAN_NUM); + return (fmt != STRSCAN_ERROR); +} + +#if LJ_DUALNUM +int LJ_FASTCALL lj_strscan_number(GCstr *str, TValue *o) +{ + StrScanFmt fmt = lj_strscan_scan((const uint8_t *)strdata(str), o, + STRSCAN_OPT_TOINT); + lua_assert(fmt == STRSCAN_ERROR || fmt == STRSCAN_NUM || fmt == STRSCAN_INT); + if (fmt == STRSCAN_INT) setitype(o, LJ_TISNUM); + return (fmt != STRSCAN_ERROR); +} +#endif + +#undef DNEXT +#undef DPREV +#undef DLEN + + +``` + +`include/luajit-2.0.5/src/lj_strscan.h`: + +```h +/* +** String scanning. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_STRSCAN_H +#define _LJ_STRSCAN_H + +#include "lj_obj.h" + +/* Options for accepted/returned formats. */ +#define STRSCAN_OPT_TOINT 0x01 /* Convert to int32_t, if possible. */ +#define STRSCAN_OPT_TONUM 0x02 /* Always convert to double. */ +#define STRSCAN_OPT_IMAG 0x04 +#define STRSCAN_OPT_LL 0x08 +#define STRSCAN_OPT_C 0x10 + +/* Returned format. */ +typedef enum { + STRSCAN_ERROR, + STRSCAN_NUM, STRSCAN_IMAG, + STRSCAN_INT, STRSCAN_U32, STRSCAN_I64, STRSCAN_U64, +} StrScanFmt; + +LJ_FUNC StrScanFmt lj_strscan_scan(const uint8_t *p, TValue *o, uint32_t opt); +LJ_FUNC int LJ_FASTCALL lj_strscan_num(GCstr *str, TValue *o); +#if LJ_DUALNUM +LJ_FUNC int LJ_FASTCALL lj_strscan_number(GCstr *str, TValue *o); +#else +#define lj_strscan_number(s, o) lj_strscan_num((s), (o)) +#endif + +/* Check for number or convert string to number/int in-place (!). */ +static LJ_AINLINE int lj_strscan_numberobj(TValue *o) +{ + return tvisnumber(o) || (tvisstr(o) && lj_strscan_number(strV(o), o)); +} + +#endif + +``` + +`include/luajit-2.0.5/src/lj_tab.c`: + +```c +/* +** Table handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_tab_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_tab.h" + +/* -- Object hashing ------------------------------------------------------ */ + +/* Hash values are masked with the table hash mask and used as an index. */ +static LJ_AINLINE Node *hashmask(const GCtab *t, uint32_t hash) +{ + Node *n = noderef(t->node); + return &n[hash & t->hmask]; +} + +/* String hashes are precomputed when they are interned. */ +#define hashstr(t, s) hashmask(t, (s)->hash) + +#define hashlohi(t, lo, hi) hashmask((t), hashrot((lo), (hi))) +#define hashnum(t, o) hashlohi((t), (o)->u32.lo, ((o)->u32.hi << 1)) +#define hashptr(t, p) hashlohi((t), u32ptr(p), u32ptr(p) + HASH_BIAS) +#define hashgcref(t, r) hashlohi((t), gcrefu(r), gcrefu(r) + HASH_BIAS) + +/* Hash an arbitrary key and return its anchor position in the hash table. */ +static Node *hashkey(const GCtab *t, cTValue *key) +{ + lua_assert(!tvisint(key)); + if (tvisstr(key)) + return hashstr(t, strV(key)); + else if (tvisnum(key)) + return hashnum(t, key); + else if (tvisbool(key)) + return hashmask(t, boolV(key)); + else + return hashgcref(t, key->gcr); + /* Only hash 32 bits of lightuserdata on a 64 bit CPU. Good enough? */ +} + +/* -- Table creation and destruction -------------------------------------- */ + +/* Create new hash part for table. */ +static LJ_AINLINE void newhpart(lua_State *L, GCtab *t, uint32_t hbits) +{ + uint32_t hsize; + Node *node; + lua_assert(hbits != 0); + if (hbits > LJ_MAX_HBITS) + lj_err_msg(L, LJ_ERR_TABOV); + hsize = 1u << hbits; + node = lj_mem_newvec(L, hsize, Node); + setmref(node->freetop, &node[hsize]); + setmref(t->node, node); + t->hmask = hsize-1; +} + +/* +** Q: Why all of these copies of t->hmask, t->node etc. to local variables? +** A: Because alias analysis for C is _really_ tough. +** Even state-of-the-art C compilers won't produce good code without this. +*/ + +/* Clear hash part of table. */ +static LJ_AINLINE void clearhpart(GCtab *t) +{ + uint32_t i, hmask = t->hmask; + Node *node = noderef(t->node); + lua_assert(t->hmask != 0); + for (i = 0; i <= hmask; i++) { + Node *n = &node[i]; + setmref(n->next, NULL); + setnilV(&n->key); + setnilV(&n->val); + } +} + +/* Clear array part of table. */ +static LJ_AINLINE void clearapart(GCtab *t) +{ + uint32_t i, asize = t->asize; + TValue *array = tvref(t->array); + for (i = 0; i < asize; i++) + setnilV(&array[i]); +} + +/* Create a new table. Note: the slots are not initialized (yet). */ +static GCtab *newtab(lua_State *L, uint32_t asize, uint32_t hbits) +{ + GCtab *t; + /* First try to colocate the array part. */ + if (LJ_MAX_COLOSIZE != 0 && asize > 0 && asize <= LJ_MAX_COLOSIZE) { + lua_assert((sizeof(GCtab) & 7) == 0); + t = (GCtab *)lj_mem_newgco(L, sizetabcolo(asize)); + t->gct = ~LJ_TTAB; + t->nomm = (uint8_t)~0; + t->colo = (int8_t)asize; + setmref(t->array, (TValue *)((char *)t + sizeof(GCtab))); + setgcrefnull(t->metatable); + t->asize = asize; + t->hmask = 0; + setmref(t->node, &G(L)->nilnode); + } else { /* Otherwise separately allocate the array part. */ + t = lj_mem_newobj(L, GCtab); + t->gct = ~LJ_TTAB; + t->nomm = (uint8_t)~0; + t->colo = 0; + setmref(t->array, NULL); + setgcrefnull(t->metatable); + t->asize = 0; /* In case the array allocation fails. */ + t->hmask = 0; + setmref(t->node, &G(L)->nilnode); + if (asize > 0) { + if (asize > LJ_MAX_ASIZE) + lj_err_msg(L, LJ_ERR_TABOV); + setmref(t->array, lj_mem_newvec(L, asize, TValue)); + t->asize = asize; + } + } + if (hbits) + newhpart(L, t, hbits); + return t; +} + +/* Create a new table. +** +** IMPORTANT NOTE: The API differs from lua_createtable()! +** +** The array size is non-inclusive. E.g. asize=128 creates array slots +** for 0..127, but not for 128. If you need slots 1..128, pass asize=129 +** (slot 0 is wasted in this case). +** +** The hash size is given in hash bits. hbits=0 means no hash part. +** hbits=1 creates 2 hash slots, hbits=2 creates 4 hash slots and so on. +*/ +GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits) +{ + GCtab *t = newtab(L, asize, hbits); + clearapart(t); + if (t->hmask > 0) clearhpart(t); + return t; +} + +#if LJ_HASJIT +GCtab * LJ_FASTCALL lj_tab_new1(lua_State *L, uint32_t ahsize) +{ + GCtab *t = newtab(L, ahsize & 0xffffff, ahsize >> 24); + clearapart(t); + if (t->hmask > 0) clearhpart(t); + return t; +} +#endif + +/* Duplicate a table. */ +GCtab * LJ_FASTCALL lj_tab_dup(lua_State *L, const GCtab *kt) +{ + GCtab *t; + uint32_t asize, hmask; + t = newtab(L, kt->asize, kt->hmask > 0 ? lj_fls(kt->hmask)+1 : 0); + lua_assert(kt->asize == t->asize && kt->hmask == t->hmask); + t->nomm = 0; /* Keys with metamethod names may be present. */ + asize = kt->asize; + if (asize > 0) { + TValue *array = tvref(t->array); + TValue *karray = tvref(kt->array); + if (asize < 64) { /* An inlined loop beats memcpy for < 512 bytes. */ + uint32_t i; + for (i = 0; i < asize; i++) + copyTV(L, &array[i], &karray[i]); + } else { + memcpy(array, karray, asize*sizeof(TValue)); + } + } + hmask = kt->hmask; + if (hmask > 0) { + uint32_t i; + Node *node = noderef(t->node); + Node *knode = noderef(kt->node); + ptrdiff_t d = (char *)node - (char *)knode; + setmref(node->freetop, (Node *)((char *)noderef(knode->freetop) + d)); + for (i = 0; i <= hmask; i++) { + Node *kn = &knode[i]; + Node *n = &node[i]; + Node *next = nextnode(kn); + /* Don't use copyTV here, since it asserts on a copy of a dead key. */ + n->val = kn->val; n->key = kn->key; + setmref(n->next, next == NULL? next : (Node *)((char *)next + d)); + } + } + return t; +} + +/* Free a table. */ +void LJ_FASTCALL lj_tab_free(global_State *g, GCtab *t) +{ + if (t->hmask > 0) + lj_mem_freevec(g, noderef(t->node), t->hmask+1, Node); + if (t->asize > 0 && LJ_MAX_COLOSIZE != 0 && t->colo <= 0) + lj_mem_freevec(g, tvref(t->array), t->asize, TValue); + if (LJ_MAX_COLOSIZE != 0 && t->colo) + lj_mem_free(g, t, sizetabcolo((uint32_t)t->colo & 0x7f)); + else + lj_mem_freet(g, t); +} + +/* -- Table resizing ------------------------------------------------------ */ + +/* Resize a table to fit the new array/hash part sizes. */ +static void resizetab(lua_State *L, GCtab *t, uint32_t asize, uint32_t hbits) +{ + Node *oldnode = noderef(t->node); + uint32_t oldasize = t->asize; + uint32_t oldhmask = t->hmask; + if (asize > oldasize) { /* Array part grows? */ + TValue *array; + uint32_t i; + if (asize > LJ_MAX_ASIZE) + lj_err_msg(L, LJ_ERR_TABOV); + if (LJ_MAX_COLOSIZE != 0 && t->colo > 0) { + /* A colocated array must be separated and copied. */ + TValue *oarray = tvref(t->array); + array = lj_mem_newvec(L, asize, TValue); + t->colo = (int8_t)(t->colo | 0x80); /* Mark as separated (colo < 0). */ + for (i = 0; i < oldasize; i++) + copyTV(L, &array[i], &oarray[i]); + } else { + array = (TValue *)lj_mem_realloc(L, tvref(t->array), + oldasize*sizeof(TValue), asize*sizeof(TValue)); + } + setmref(t->array, array); + t->asize = asize; + for (i = oldasize; i < asize; i++) /* Clear newly allocated slots. */ + setnilV(&array[i]); + } + /* Create new (empty) hash part. */ + if (hbits) { + newhpart(L, t, hbits); + clearhpart(t); + } else { + global_State *g = G(L); + setmref(t->node, &g->nilnode); + t->hmask = 0; + } + if (asize < oldasize) { /* Array part shrinks? */ + TValue *array = tvref(t->array); + uint32_t i; + t->asize = asize; /* Note: This 'shrinks' even colocated arrays. */ + for (i = asize; i < oldasize; i++) /* Reinsert old array values. */ + if (!tvisnil(&array[i])) + copyTV(L, lj_tab_setinth(L, t, (int32_t)i), &array[i]); + /* Physically shrink only separated arrays. */ + if (LJ_MAX_COLOSIZE != 0 && t->colo <= 0) + setmref(t->array, lj_mem_realloc(L, array, + oldasize*sizeof(TValue), asize*sizeof(TValue))); + } + if (oldhmask > 0) { /* Reinsert pairs from old hash part. */ + global_State *g; + uint32_t i; + for (i = 0; i <= oldhmask; i++) { + Node *n = &oldnode[i]; + if (!tvisnil(&n->val)) + copyTV(L, lj_tab_set(L, t, &n->key), &n->val); + } + g = G(L); + lj_mem_freevec(g, oldnode, oldhmask+1, Node); + } +} + +static uint32_t countint(cTValue *key, uint32_t *bins) +{ + lua_assert(!tvisint(key)); + if (tvisnum(key)) { + lua_Number nk = numV(key); + int32_t k = lj_num2int(nk); + if ((uint32_t)k < LJ_MAX_ASIZE && nk == (lua_Number)k) { + bins[(k > 2 ? lj_fls((uint32_t)(k-1)) : 0)]++; + return 1; + } + } + return 0; +} + +static uint32_t countarray(const GCtab *t, uint32_t *bins) +{ + uint32_t na, b, i; + if (t->asize == 0) return 0; + for (na = i = b = 0; b < LJ_MAX_ABITS; b++) { + uint32_t n, top = 2u << b; + TValue *array; + if (top >= t->asize) { + top = t->asize-1; + if (i > top) + break; + } + array = tvref(t->array); + for (n = 0; i <= top; i++) + if (!tvisnil(&array[i])) + n++; + bins[b] += n; + na += n; + } + return na; +} + +static uint32_t counthash(const GCtab *t, uint32_t *bins, uint32_t *narray) +{ + uint32_t total, na, i, hmask = t->hmask; + Node *node = noderef(t->node); + for (total = na = 0, i = 0; i <= hmask; i++) { + Node *n = &node[i]; + if (!tvisnil(&n->val)) { + na += countint(&n->key, bins); + total++; + } + } + *narray += na; + return total; +} + +static uint32_t bestasize(uint32_t bins[], uint32_t *narray) +{ + uint32_t b, sum, na = 0, sz = 0, nn = *narray; + for (b = 0, sum = 0; 2*nn > (1u< 0 && 2*(sum += bins[b]) > (1u<hmask > 0 ? lj_fls(t->hmask)+1 : 0); +} + +/* -- Table getters ------------------------------------------------------- */ + +cTValue * LJ_FASTCALL lj_tab_getinth(GCtab *t, int32_t key) +{ + TValue k; + Node *n; + k.n = (lua_Number)key; + n = hashnum(t, &k); + do { + if (tvisnum(&n->key) && n->key.n == k.n) + return &n->val; + } while ((n = nextnode(n))); + return NULL; +} + +cTValue *lj_tab_getstr(GCtab *t, GCstr *key) +{ + Node *n = hashstr(t, key); + do { + if (tvisstr(&n->key) && strV(&n->key) == key) + return &n->val; + } while ((n = nextnode(n))); + return NULL; +} + +cTValue *lj_tab_get(lua_State *L, GCtab *t, cTValue *key) +{ + if (tvisstr(key)) { + cTValue *tv = lj_tab_getstr(t, strV(key)); + if (tv) + return tv; + } else if (tvisint(key)) { + cTValue *tv = lj_tab_getint(t, intV(key)); + if (tv) + return tv; + } else if (tvisnum(key)) { + lua_Number nk = numV(key); + int32_t k = lj_num2int(nk); + if (nk == (lua_Number)k) { + cTValue *tv = lj_tab_getint(t, k); + if (tv) + return tv; + } else { + goto genlookup; /* Else use the generic lookup. */ + } + } else if (!tvisnil(key)) { + Node *n; + genlookup: + n = hashkey(t, key); + do { + if (lj_obj_equal(&n->key, key)) + return &n->val; + } while ((n = nextnode(n))); + } + return niltv(L); +} + +/* -- Table setters ------------------------------------------------------- */ + +/* Insert new key. Use Brent's variation to optimize the chain length. */ +TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key) +{ + Node *n = hashkey(t, key); + if (!tvisnil(&n->val) || t->hmask == 0) { + Node *nodebase = noderef(t->node); + Node *collide, *freenode = noderef(nodebase->freetop); + lua_assert(freenode >= nodebase && freenode <= nodebase+t->hmask+1); + do { + if (freenode == nodebase) { /* No free node found? */ + rehashtab(L, t, key); /* Rehash table. */ + return lj_tab_set(L, t, key); /* Retry key insertion. */ + } + } while (!tvisnil(&(--freenode)->key)); + setmref(nodebase->freetop, freenode); + lua_assert(freenode != &G(L)->nilnode); + collide = hashkey(t, &n->key); + if (collide != n) { /* Colliding node not the main node? */ + while (noderef(collide->next) != n) /* Find predecessor. */ + collide = nextnode(collide); + setmref(collide->next, freenode); /* Relink chain. */ + /* Copy colliding node into free node and free main node. */ + freenode->val = n->val; + freenode->key = n->key; + freenode->next = n->next; + setmref(n->next, NULL); + setnilV(&n->val); + /* Rechain pseudo-resurrected string keys with colliding hashes. */ + while (nextnode(freenode)) { + Node *nn = nextnode(freenode); + if (tvisstr(&nn->key) && !tvisnil(&nn->val) && + hashstr(t, strV(&nn->key)) == n) { + freenode->next = nn->next; + nn->next = n->next; + setmref(n->next, nn); + } else { + freenode = nn; + } + } + } else { /* Otherwise use free node. */ + setmrefr(freenode->next, n->next); /* Insert into chain. */ + setmref(n->next, freenode); + n = freenode; + } + } + n->key.u64 = key->u64; + if (LJ_UNLIKELY(tvismzero(&n->key))) + n->key.u64 = 0; + lj_gc_anybarriert(L, t); + lua_assert(tvisnil(&n->val)); + return &n->val; +} + +TValue *lj_tab_setinth(lua_State *L, GCtab *t, int32_t key) +{ + TValue k; + Node *n; + k.n = (lua_Number)key; + n = hashnum(t, &k); + do { + if (tvisnum(&n->key) && n->key.n == k.n) + return &n->val; + } while ((n = nextnode(n))); + return lj_tab_newkey(L, t, &k); +} + +TValue *lj_tab_setstr(lua_State *L, GCtab *t, GCstr *key) +{ + TValue k; + Node *n = hashstr(t, key); + do { + if (tvisstr(&n->key) && strV(&n->key) == key) + return &n->val; + } while ((n = nextnode(n))); + setstrV(L, &k, key); + return lj_tab_newkey(L, t, &k); +} + +TValue *lj_tab_set(lua_State *L, GCtab *t, cTValue *key) +{ + Node *n; + t->nomm = 0; /* Invalidate negative metamethod cache. */ + if (tvisstr(key)) { + return lj_tab_setstr(L, t, strV(key)); + } else if (tvisint(key)) { + return lj_tab_setint(L, t, intV(key)); + } else if (tvisnum(key)) { + lua_Number nk = numV(key); + int32_t k = lj_num2int(nk); + if (nk == (lua_Number)k) + return lj_tab_setint(L, t, k); + if (tvisnan(key)) + lj_err_msg(L, LJ_ERR_NANIDX); + /* Else use the generic lookup. */ + } else if (tvisnil(key)) { + lj_err_msg(L, LJ_ERR_NILIDX); + } + n = hashkey(t, key); + do { + if (lj_obj_equal(&n->key, key)) + return &n->val; + } while ((n = nextnode(n))); + return lj_tab_newkey(L, t, key); +} + +/* -- Table traversal ----------------------------------------------------- */ + +/* Get the traversal index of a key. */ +static uint32_t keyindex(lua_State *L, GCtab *t, cTValue *key) +{ + TValue tmp; + if (tvisint(key)) { + int32_t k = intV(key); + if ((uint32_t)k < t->asize) + return (uint32_t)k; /* Array key indexes: [0..t->asize-1] */ + setnumV(&tmp, (lua_Number)k); + key = &tmp; + } else if (tvisnum(key)) { + lua_Number nk = numV(key); + int32_t k = lj_num2int(nk); + if ((uint32_t)k < t->asize && nk == (lua_Number)k) + return (uint32_t)k; /* Array key indexes: [0..t->asize-1] */ + } + if (!tvisnil(key)) { + Node *n = hashkey(t, key); + do { + if (lj_obj_equal(&n->key, key)) + return t->asize + (uint32_t)(n - noderef(t->node)); + /* Hash key indexes: [t->asize..t->asize+t->nmask] */ + } while ((n = nextnode(n))); + if (key->u32.hi == 0xfffe7fff) /* ITERN was despecialized while running. */ + return key->u32.lo - 1; + lj_err_msg(L, LJ_ERR_NEXTIDX); + return 0; /* unreachable */ + } + return ~0u; /* A nil key starts the traversal. */ +} + +/* Advance to the next step in a table traversal. */ +int lj_tab_next(lua_State *L, GCtab *t, TValue *key) +{ + uint32_t i = keyindex(L, t, key); /* Find predecessor key index. */ + for (i++; i < t->asize; i++) /* First traverse the array keys. */ + if (!tvisnil(arrayslot(t, i))) { + setintV(key, i); + copyTV(L, key+1, arrayslot(t, i)); + return 1; + } + for (i -= t->asize; i <= t->hmask; i++) { /* Then traverse the hash keys. */ + Node *n = &noderef(t->node)[i]; + if (!tvisnil(&n->val)) { + copyTV(L, key, &n->key); + copyTV(L, key+1, &n->val); + return 1; + } + } + return 0; /* End of traversal. */ +} + +/* -- Table length calculation -------------------------------------------- */ + +static MSize unbound_search(GCtab *t, MSize j) +{ + cTValue *tv; + MSize i = j; /* i is zero or a present index */ + j++; + /* find `i' and `j' such that i is present and j is not */ + while ((tv = lj_tab_getint(t, (int32_t)j)) && !tvisnil(tv)) { + i = j; + j *= 2; + if (j > (MSize)(INT_MAX-2)) { /* overflow? */ + /* table was built with bad purposes: resort to linear search */ + i = 1; + while ((tv = lj_tab_getint(t, (int32_t)i)) && !tvisnil(tv)) i++; + return i - 1; + } + } + /* now do a binary search between them */ + while (j - i > 1) { + MSize m = (i+j)/2; + cTValue *tvb = lj_tab_getint(t, (int32_t)m); + if (tvb && !tvisnil(tvb)) i = m; else j = m; + } + return i; +} + +/* +** Try to find a boundary in table `t'. A `boundary' is an integer index +** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). +*/ +MSize LJ_FASTCALL lj_tab_len(GCtab *t) +{ + MSize j = (MSize)t->asize; + if (j > 1 && tvisnil(arrayslot(t, j-1))) { + MSize i = 1; + while (j - i > 1) { + MSize m = (i+j)/2; + if (tvisnil(arrayslot(t, m-1))) j = m; else i = m; + } + return i-1; + } + if (j) j--; + if (t->hmask <= 0) + return j; + return unbound_search(t, j); +} + + +``` + +`include/luajit-2.0.5/src/lj_tab.h`: + +```h +/* +** Table handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_TAB_H +#define _LJ_TAB_H + +#include "lj_obj.h" + +/* Hash constants. Tuned using a brute force search. */ +#define HASH_BIAS (-0x04c11db7) +#define HASH_ROT1 14 +#define HASH_ROT2 5 +#define HASH_ROT3 13 + +/* Scramble the bits of numbers and pointers. */ +static LJ_AINLINE uint32_t hashrot(uint32_t lo, uint32_t hi) +{ +#if LJ_TARGET_X86ORX64 + /* Prefer variant that compiles well for a 2-operand CPU. */ + lo ^= hi; hi = lj_rol(hi, HASH_ROT1); + lo -= hi; hi = lj_rol(hi, HASH_ROT2); + hi ^= lo; hi -= lj_rol(lo, HASH_ROT3); +#else + lo ^= hi; + lo = lo - lj_rol(hi, HASH_ROT1); + hi = lo ^ lj_rol(hi, HASH_ROT1 + HASH_ROT2); + hi = hi - lj_rol(lo, HASH_ROT3); +#endif + return hi; +} + +#define hsize2hbits(s) ((s) ? ((s)==1 ? 1 : 1+lj_fls((uint32_t)((s)-1))) : 0) + +LJ_FUNCA GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits); +#if LJ_HASJIT +LJ_FUNC GCtab * LJ_FASTCALL lj_tab_new1(lua_State *L, uint32_t ahsize); +#endif +LJ_FUNCA GCtab * LJ_FASTCALL lj_tab_dup(lua_State *L, const GCtab *kt); +LJ_FUNC void LJ_FASTCALL lj_tab_free(global_State *g, GCtab *t); +#if LJ_HASFFI +LJ_FUNC void lj_tab_rehash(lua_State *L, GCtab *t); +#endif +LJ_FUNCA void lj_tab_reasize(lua_State *L, GCtab *t, uint32_t nasize); + +/* Caveat: all getters except lj_tab_get() can return NULL! */ + +LJ_FUNCA cTValue * LJ_FASTCALL lj_tab_getinth(GCtab *t, int32_t key); +LJ_FUNC cTValue *lj_tab_getstr(GCtab *t, GCstr *key); +LJ_FUNCA cTValue *lj_tab_get(lua_State *L, GCtab *t, cTValue *key); + +/* Caveat: all setters require a write barrier for the stored value. */ + +LJ_FUNCA TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key); +LJ_FUNC TValue *lj_tab_setinth(lua_State *L, GCtab *t, int32_t key); +LJ_FUNC TValue *lj_tab_setstr(lua_State *L, GCtab *t, GCstr *key); +LJ_FUNC TValue *lj_tab_set(lua_State *L, GCtab *t, cTValue *key); + +#define inarray(t, key) ((MSize)(key) < (MSize)(t)->asize) +#define arrayslot(t, i) (&tvref((t)->array)[(i)]) +#define lj_tab_getint(t, key) \ + (inarray((t), (key)) ? arrayslot((t), (key)) : lj_tab_getinth((t), (key))) +#define lj_tab_setint(L, t, key) \ + (inarray((t), (key)) ? arrayslot((t), (key)) : lj_tab_setinth(L, (t), (key))) + +LJ_FUNCA int lj_tab_next(lua_State *L, GCtab *t, TValue *key); +LJ_FUNCA MSize LJ_FASTCALL lj_tab_len(GCtab *t); + +#endif + +``` + +`include/luajit-2.0.5/src/lj_target.h`: + +```h +/* +** Definitions for target CPU. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_TARGET_H +#define _LJ_TARGET_H + +#include "lj_def.h" +#include "lj_arch.h" + +/* -- Registers and spill slots ------------------------------------------- */ + +/* Register type (uint8_t in ir->r). */ +typedef uint32_t Reg; + +/* The hi-bit is NOT set for an allocated register. This means the value +** can be directly used without masking. The hi-bit is set for a register +** allocation hint or for RID_INIT, RID_SINK or RID_SUNK. +*/ +#define RID_NONE 0x80 +#define RID_MASK 0x7f +#define RID_INIT (RID_NONE|RID_MASK) +#define RID_SINK (RID_INIT-1) +#define RID_SUNK (RID_INIT-2) + +#define ra_noreg(r) ((r) & RID_NONE) +#define ra_hasreg(r) (!((r) & RID_NONE)) + +/* The ra_hashint() macro assumes a previous test for ra_noreg(). */ +#define ra_hashint(r) ((r) < RID_SUNK) +#define ra_gethint(r) ((Reg)((r) & RID_MASK)) +#define ra_sethint(rr, r) rr = (uint8_t)((r)|RID_NONE) +#define ra_samehint(r1, r2) (ra_gethint((r1)^(r2)) == 0) + +/* Spill slot 0 means no spill slot has been allocated. */ +#define SPS_NONE 0 + +#define ra_hasspill(s) ((s) != SPS_NONE) + +/* Combined register and spill slot (uint16_t in ir->prev). */ +typedef uint32_t RegSP; + +#define REGSP(r, s) ((r) + ((s) << 8)) +#define REGSP_HINT(r) ((r)|RID_NONE) +#define REGSP_INIT REGSP(RID_INIT, 0) + +#define regsp_reg(rs) ((rs) & 255) +#define regsp_spill(rs) ((rs) >> 8) +#define regsp_used(rs) \ + (((rs) & ~REGSP(RID_MASK, 0)) != REGSP(RID_NONE, 0)) + +/* -- Register sets ------------------------------------------------------- */ + +/* Bitset for registers. 32 registers suffice for most architectures. +** Note that one set holds bits for both GPRs and FPRs. +*/ +#if LJ_TARGET_PPC || LJ_TARGET_MIPS +typedef uint64_t RegSet; +#else +typedef uint32_t RegSet; +#endif + +#define RID2RSET(r) (((RegSet)1) << (r)) +#define RSET_EMPTY ((RegSet)0) +#define RSET_RANGE(lo, hi) ((RID2RSET((hi)-(lo))-1) << (lo)) + +#define rset_test(rs, r) ((int)((rs) >> (r)) & 1) +#define rset_set(rs, r) (rs |= RID2RSET(r)) +#define rset_clear(rs, r) (rs &= ~RID2RSET(r)) +#define rset_exclude(rs, r) (rs & ~RID2RSET(r)) +#if LJ_TARGET_PPC || LJ_TARGET_MIPS +#define rset_picktop(rs) ((Reg)(__builtin_clzll(rs)^63)) +#define rset_pickbot(rs) ((Reg)__builtin_ctzll(rs)) +#else +#define rset_picktop(rs) ((Reg)lj_fls(rs)) +#define rset_pickbot(rs) ((Reg)lj_ffs(rs)) +#endif + +/* -- Register allocation cost -------------------------------------------- */ + +/* The register allocation heuristic keeps track of the cost for allocating +** a specific register: +** +** A free register (obviously) has a cost of 0 and a 1-bit in the free mask. +** +** An already allocated register has the (non-zero) IR reference in the lowest +** bits and the result of a blended cost-model in the higher bits. +** +** The allocator first checks the free mask for a hit. Otherwise an (unrolled) +** linear search for the minimum cost is used. The search doesn't need to +** keep track of the position of the minimum, which makes it very fast. +** The lowest bits of the minimum cost show the desired IR reference whose +** register is the one to evict. +** +** Without the cost-model this degenerates to the standard heuristics for +** (reverse) linear-scan register allocation. Since code generation is done +** in reverse, a live interval extends from the last use to the first def. +** For an SSA IR the IR reference is the first (and only) def and thus +** trivially marks the end of the interval. The LSRA heuristics says to pick +** the register whose live interval has the furthest extent, i.e. the lowest +** IR reference in our case. +** +** A cost-model should take into account other factors, like spill-cost and +** restore- or rematerialization-cost, which depend on the kind of instruction. +** E.g. constants have zero spill costs, variant instructions have higher +** costs than invariants and PHIs should preferably never be spilled. +** +** Here's a first cut at simple, but effective blended cost-model for R-LSRA: +** - Due to careful design of the IR, constants already have lower IR +** references than invariants and invariants have lower IR references +** than variants. +** - The cost in the upper 16 bits is the sum of the IR reference and a +** weighted score. The score currently only takes into account whether +** the IRT_ISPHI bit is set in the instruction type. +** - The PHI weight is the minimum distance (in IR instructions) a PHI +** reference has to be further apart from a non-PHI reference to be spilled. +** - It should be a power of two (for speed) and must be between 2 and 32768. +** Good values for the PHI weight seem to be between 40 and 150. +** - Further study is required. +*/ +#define REGCOST_PHI_WEIGHT 64 + +/* Cost for allocating a specific register. */ +typedef uint32_t RegCost; + +/* Note: assumes 16 bit IRRef1. */ +#define REGCOST(cost, ref) ((RegCost)(ref) + ((RegCost)(cost) << 16)) +#define regcost_ref(rc) ((IRRef1)(rc)) + +#define REGCOST_T(t) \ + ((RegCost)((t)&IRT_ISPHI) * (((RegCost)(REGCOST_PHI_WEIGHT)<<16)/IRT_ISPHI)) +#define REGCOST_REF_T(ref, t) (REGCOST((ref), (ref)) + REGCOST_T((t))) + +/* -- Target-specific definitions ----------------------------------------- */ + +#if LJ_TARGET_X86ORX64 +#include "lj_target_x86.h" +#elif LJ_TARGET_ARM +#include "lj_target_arm.h" +#elif LJ_TARGET_PPC +#include "lj_target_ppc.h" +#elif LJ_TARGET_MIPS +#include "lj_target_mips.h" +#else +#error "Missing include for target CPU" +#endif + +#ifdef EXITSTUBS_PER_GROUP +/* Return the address of an exit stub. */ +static LJ_AINLINE char *exitstub_addr_(char **group, uint32_t exitno) +{ + lua_assert(group[exitno / EXITSTUBS_PER_GROUP] != NULL); + return (char *)group[exitno / EXITSTUBS_PER_GROUP] + + EXITSTUB_SPACING*(exitno % EXITSTUBS_PER_GROUP); +} +/* Avoid dependence on lj_jit.h if only including lj_target.h. */ +#define exitstub_addr(J, exitno) \ + ((MCode *)exitstub_addr_((char **)((J)->exitstubgroup), (exitno))) +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_target_arm.h`: + +```h +/* +** Definitions for ARM CPUs. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_TARGET_ARM_H +#define _LJ_TARGET_ARM_H + +/* -- Registers IDs ------------------------------------------------------- */ + +#define GPRDEF(_) \ + _(R0) _(R1) _(R2) _(R3) _(R4) _(R5) _(R6) _(R7) \ + _(R8) _(R9) _(R10) _(R11) _(R12) _(SP) _(LR) _(PC) +#if LJ_SOFTFP +#define FPRDEF(_) +#else +#define FPRDEF(_) \ + _(D0) _(D1) _(D2) _(D3) _(D4) _(D5) _(D6) _(D7) \ + _(D8) _(D9) _(D10) _(D11) _(D12) _(D13) _(D14) _(D15) +#endif +#define VRIDDEF(_) + +#define RIDENUM(name) RID_##name, + +enum { + GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ + FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ + RID_MAX, + RID_TMP = RID_LR, + + /* Calling conventions. */ + RID_RET = RID_R0, + RID_RETLO = RID_R0, + RID_RETHI = RID_R1, +#if LJ_SOFTFP + RID_FPRET = RID_R0, +#else + RID_FPRET = RID_D0, +#endif + + /* These definitions must match with the *.dasc file(s): */ + RID_BASE = RID_R9, /* Interpreter BASE. */ + RID_LPC = RID_R6, /* Interpreter PC. */ + RID_DISPATCH = RID_R7, /* Interpreter DISPATCH table. */ + RID_LREG = RID_R8, /* Interpreter L. */ + + /* Register ranges [min, max) and number of registers. */ + RID_MIN_GPR = RID_R0, + RID_MAX_GPR = RID_PC+1, + RID_MIN_FPR = RID_MAX_GPR, +#if LJ_SOFTFP + RID_MAX_FPR = RID_MIN_FPR, +#else + RID_MAX_FPR = RID_D15+1, +#endif + RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, + RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR +}; + +#define RID_NUM_KREF RID_NUM_GPR +#define RID_MIN_KREF RID_R0 + +/* -- Register sets ------------------------------------------------------- */ + +/* Make use of all registers, except sp, lr and pc. */ +#define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_R12+1)) +#define RSET_GPREVEN \ + (RID2RSET(RID_R0)|RID2RSET(RID_R2)|RID2RSET(RID_R4)|RID2RSET(RID_R6)| \ + RID2RSET(RID_R8)|RID2RSET(RID_R10)) +#define RSET_GPRODD \ + (RID2RSET(RID_R1)|RID2RSET(RID_R3)|RID2RSET(RID_R5)|RID2RSET(RID_R7)| \ + RID2RSET(RID_R9)|RID2RSET(RID_R11)) +#if LJ_SOFTFP +#define RSET_FPR 0 +#else +#define RSET_FPR (RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR)) +#endif +#define RSET_ALL (RSET_GPR|RSET_FPR) +#define RSET_INIT RSET_ALL + +/* ABI-specific register sets. lr is an implicit scratch register. */ +#define RSET_SCRATCH_GPR_ (RSET_RANGE(RID_R0, RID_R3+1)|RID2RSET(RID_R12)) +#ifdef __APPLE__ +#define RSET_SCRATCH_GPR (RSET_SCRATCH_GPR_|RID2RSET(RID_R9)) +#else +#define RSET_SCRATCH_GPR RSET_SCRATCH_GPR_ +#endif +#if LJ_SOFTFP +#define RSET_SCRATCH_FPR 0 +#else +#define RSET_SCRATCH_FPR (RSET_RANGE(RID_D0, RID_D7+1)) +#endif +#define RSET_SCRATCH (RSET_SCRATCH_GPR|RSET_SCRATCH_FPR) +#define REGARG_FIRSTGPR RID_R0 +#define REGARG_LASTGPR RID_R3 +#define REGARG_NUMGPR 4 +#if LJ_ABI_SOFTFP +#define REGARG_FIRSTFPR 0 +#define REGARG_LASTFPR 0 +#define REGARG_NUMFPR 0 +#else +#define REGARG_FIRSTFPR RID_D0 +#define REGARG_LASTFPR RID_D7 +#define REGARG_NUMFPR 8 +#endif + +/* -- Spill slots --------------------------------------------------------- */ + +/* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. +** +** SPS_FIXED: Available fixed spill slots in interpreter frame. +** This definition must match with the *.dasc file(s). +** +** SPS_FIRST: First spill slot for general use. Reserve min. two 32 bit slots. +*/ +#define SPS_FIXED 2 +#define SPS_FIRST 2 + +#define SPOFS_TMP 0 + +#define sps_scale(slot) (4 * (int32_t)(slot)) +#define sps_align(slot) (((slot) - SPS_FIXED + 1) & ~1) + +/* -- Exit state ---------------------------------------------------------- */ + +/* This definition must match with the *.dasc file(s). */ +typedef struct { +#if !LJ_SOFTFP + lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ +#endif + int32_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ + int32_t spill[256]; /* Spill slots. */ +} ExitState; + +/* PC after instruction that caused an exit. Used to find the trace number. */ +#define EXITSTATE_PCREG RID_PC +/* Highest exit + 1 indicates stack check. */ +#define EXITSTATE_CHECKEXIT 1 + +#define EXITSTUB_SPACING 4 +#define EXITSTUBS_PER_GROUP 32 + +/* -- Instructions -------------------------------------------------------- */ + +/* Instruction fields. */ +#define ARMF_CC(ai, cc) (((ai) ^ ARMI_CCAL) | ((cc) << 28)) +#define ARMF_N(r) ((r) << 16) +#define ARMF_D(r) ((r) << 12) +#define ARMF_S(r) ((r) << 8) +#define ARMF_M(r) (r) +#define ARMF_SH(sh, n) (((sh) << 5) | ((n) << 7)) +#define ARMF_RSH(sh, r) (0x10 | ((sh) << 5) | ARMF_S(r)) + +typedef enum ARMIns { + ARMI_CCAL = 0xe0000000, + ARMI_S = 0x000100000, + ARMI_K12 = 0x02000000, + ARMI_KNEG = 0x00200000, + ARMI_LS_W = 0x00200000, + ARMI_LS_U = 0x00800000, + ARMI_LS_P = 0x01000000, + ARMI_LS_R = 0x02000000, + ARMI_LSX_I = 0x00400000, + + ARMI_AND = 0xe0000000, + ARMI_EOR = 0xe0200000, + ARMI_SUB = 0xe0400000, + ARMI_RSB = 0xe0600000, + ARMI_ADD = 0xe0800000, + ARMI_ADC = 0xe0a00000, + ARMI_SBC = 0xe0c00000, + ARMI_RSC = 0xe0e00000, + ARMI_TST = 0xe1100000, + ARMI_TEQ = 0xe1300000, + ARMI_CMP = 0xe1500000, + ARMI_CMN = 0xe1700000, + ARMI_ORR = 0xe1800000, + ARMI_MOV = 0xe1a00000, + ARMI_BIC = 0xe1c00000, + ARMI_MVN = 0xe1e00000, + + ARMI_NOP = 0xe1a00000, + + ARMI_MUL = 0xe0000090, + ARMI_SMULL = 0xe0c00090, + + ARMI_LDR = 0xe4100000, + ARMI_LDRB = 0xe4500000, + ARMI_LDRH = 0xe01000b0, + ARMI_LDRSB = 0xe01000d0, + ARMI_LDRSH = 0xe01000f0, + ARMI_LDRD = 0xe00000d0, + ARMI_STR = 0xe4000000, + ARMI_STRB = 0xe4400000, + ARMI_STRH = 0xe00000b0, + ARMI_STRD = 0xe00000f0, + ARMI_PUSH = 0xe92d0000, + + ARMI_B = 0xea000000, + ARMI_BL = 0xeb000000, + ARMI_BLX = 0xfa000000, + ARMI_BLXr = 0xe12fff30, + + /* ARMv6 */ + ARMI_REV = 0xe6bf0f30, + ARMI_SXTB = 0xe6af0070, + ARMI_SXTH = 0xe6bf0070, + ARMI_UXTB = 0xe6ef0070, + ARMI_UXTH = 0xe6ff0070, + + /* ARMv6T2 */ + ARMI_MOVW = 0xe3000000, + ARMI_MOVT = 0xe3400000, + + /* VFP */ + ARMI_VMOV_D = 0xeeb00b40, + ARMI_VMOV_S = 0xeeb00a40, + ARMI_VMOVI_D = 0xeeb00b00, + + ARMI_VMOV_R_S = 0xee100a10, + ARMI_VMOV_S_R = 0xee000a10, + ARMI_VMOV_RR_D = 0xec500b10, + ARMI_VMOV_D_RR = 0xec400b10, + + ARMI_VADD_D = 0xee300b00, + ARMI_VSUB_D = 0xee300b40, + ARMI_VMUL_D = 0xee200b00, + ARMI_VMLA_D = 0xee000b00, + ARMI_VMLS_D = 0xee000b40, + ARMI_VNMLS_D = 0xee100b00, + ARMI_VDIV_D = 0xee800b00, + + ARMI_VABS_D = 0xeeb00bc0, + ARMI_VNEG_D = 0xeeb10b40, + ARMI_VSQRT_D = 0xeeb10bc0, + + ARMI_VCMP_D = 0xeeb40b40, + ARMI_VCMPZ_D = 0xeeb50b40, + + ARMI_VMRS = 0xeef1fa10, + + ARMI_VCVT_S32_F32 = 0xeebd0ac0, + ARMI_VCVT_S32_F64 = 0xeebd0bc0, + ARMI_VCVT_U32_F32 = 0xeebc0ac0, + ARMI_VCVT_U32_F64 = 0xeebc0bc0, + ARMI_VCVTR_S32_F32 = 0xeebd0a40, + ARMI_VCVTR_S32_F64 = 0xeebd0b40, + ARMI_VCVTR_U32_F32 = 0xeebc0a40, + ARMI_VCVTR_U32_F64 = 0xeebc0b40, + ARMI_VCVT_F32_S32 = 0xeeb80ac0, + ARMI_VCVT_F64_S32 = 0xeeb80bc0, + ARMI_VCVT_F32_U32 = 0xeeb80a40, + ARMI_VCVT_F64_U32 = 0xeeb80b40, + ARMI_VCVT_F32_F64 = 0xeeb70bc0, + ARMI_VCVT_F64_F32 = 0xeeb70ac0, + + ARMI_VLDR_S = 0xed100a00, + ARMI_VLDR_D = 0xed100b00, + ARMI_VSTR_S = 0xed000a00, + ARMI_VSTR_D = 0xed000b00, +} ARMIns; + +typedef enum ARMShift { + ARMSH_LSL, ARMSH_LSR, ARMSH_ASR, ARMSH_ROR +} ARMShift; + +/* ARM condition codes. */ +typedef enum ARMCC { + CC_EQ, CC_NE, CC_CS, CC_CC, CC_MI, CC_PL, CC_VS, CC_VC, + CC_HI, CC_LS, CC_GE, CC_LT, CC_GT, CC_LE, CC_AL, + CC_HS = CC_CS, CC_LO = CC_CC +} ARMCC; + +#endif + +``` + +`include/luajit-2.0.5/src/lj_target_mips.h`: + +```h +/* +** Definitions for MIPS CPUs. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_TARGET_MIPS_H +#define _LJ_TARGET_MIPS_H + +/* -- Registers IDs ------------------------------------------------------- */ + +#define GPRDEF(_) \ + _(R0) _(R1) _(R2) _(R3) _(R4) _(R5) _(R6) _(R7) \ + _(R8) _(R9) _(R10) _(R11) _(R12) _(R13) _(R14) _(R15) \ + _(R16) _(R17) _(R18) _(R19) _(R20) _(R21) _(R22) _(R23) \ + _(R24) _(R25) _(SYS1) _(SYS2) _(R28) _(SP) _(R30) _(RA) +#define FPRDEF(_) \ + _(F0) _(F1) _(F2) _(F3) _(F4) _(F5) _(F6) _(F7) \ + _(F8) _(F9) _(F10) _(F11) _(F12) _(F13) _(F14) _(F15) \ + _(F16) _(F17) _(F18) _(F19) _(F20) _(F21) _(F22) _(F23) \ + _(F24) _(F25) _(F26) _(F27) _(F28) _(F29) _(F30) _(F31) +#define VRIDDEF(_) + +#define RIDENUM(name) RID_##name, + +enum { + GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ + FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ + RID_MAX, + RID_ZERO = RID_R0, + RID_TMP = RID_RA, + RID_GP = RID_R28, + + /* Calling conventions. */ + RID_RET = RID_R2, +#if LJ_LE + RID_RETHI = RID_R3, + RID_RETLO = RID_R2, +#else + RID_RETHI = RID_R2, + RID_RETLO = RID_R3, +#endif + RID_FPRET = RID_F0, + RID_CFUNCADDR = RID_R25, + + /* These definitions must match with the *.dasc file(s): */ + RID_BASE = RID_R16, /* Interpreter BASE. */ + RID_LPC = RID_R18, /* Interpreter PC. */ + RID_DISPATCH = RID_R19, /* Interpreter DISPATCH table. */ + RID_LREG = RID_R20, /* Interpreter L. */ + RID_JGL = RID_R30, /* On-trace: global_State + 32768. */ + + /* Register ranges [min, max) and number of registers. */ + RID_MIN_GPR = RID_R0, + RID_MAX_GPR = RID_RA+1, + RID_MIN_FPR = RID_F0, + RID_MAX_FPR = RID_F31+1, + RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, + RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR /* Only even regs are used. */ +}; + +#define RID_NUM_KREF RID_NUM_GPR +#define RID_MIN_KREF RID_R0 + +/* -- Register sets ------------------------------------------------------- */ + +/* Make use of all registers, except ZERO, TMP, SP, SYS1, SYS2, JGL and GP. */ +#define RSET_FIXED \ + (RID2RSET(RID_ZERO)|RID2RSET(RID_TMP)|RID2RSET(RID_SP)|\ + RID2RSET(RID_SYS1)|RID2RSET(RID_SYS2)|RID2RSET(RID_JGL)|RID2RSET(RID_GP)) +#define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR) - RSET_FIXED) +#define RSET_FPR \ + (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\ + RID2RSET(RID_F8)|RID2RSET(RID_F10)|RID2RSET(RID_F12)|RID2RSET(RID_F14)|\ + RID2RSET(RID_F16)|RID2RSET(RID_F18)|RID2RSET(RID_F20)|RID2RSET(RID_F22)|\ + RID2RSET(RID_F24)|RID2RSET(RID_F26)|RID2RSET(RID_F28)|RID2RSET(RID_F30)) +#define RSET_ALL (RSET_GPR|RSET_FPR) +#define RSET_INIT RSET_ALL + +#define RSET_SCRATCH_GPR \ + (RSET_RANGE(RID_R1, RID_R15+1)|\ + RID2RSET(RID_R24)|RID2RSET(RID_R25)) +#define RSET_SCRATCH_FPR \ + (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\ + RID2RSET(RID_F8)|RID2RSET(RID_F10)|RID2RSET(RID_F12)|RID2RSET(RID_F14)|\ + RID2RSET(RID_F16)|RID2RSET(RID_F18)) +#define RSET_SCRATCH (RSET_SCRATCH_GPR|RSET_SCRATCH_FPR) +#define REGARG_FIRSTGPR RID_R4 +#define REGARG_LASTGPR RID_R7 +#define REGARG_NUMGPR 4 +#define REGARG_FIRSTFPR RID_F12 +#define REGARG_LASTFPR RID_F14 +#define REGARG_NUMFPR 2 + +/* -- Spill slots --------------------------------------------------------- */ + +/* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. +** +** SPS_FIXED: Available fixed spill slots in interpreter frame. +** This definition must match with the *.dasc file(s). +** +** SPS_FIRST: First spill slot for general use. +*/ +#define SPS_FIXED 5 +#define SPS_FIRST 4 + +#define SPOFS_TMP 0 + +#define sps_scale(slot) (4 * (int32_t)(slot)) +#define sps_align(slot) (((slot) - SPS_FIXED + 1) & ~1) + +/* -- Exit state ---------------------------------------------------------- */ + +/* This definition must match with the *.dasc file(s). */ +typedef struct { + lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ + int32_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ + int32_t spill[256]; /* Spill slots. */ +} ExitState; + +/* Highest exit + 1 indicates stack check. */ +#define EXITSTATE_CHECKEXIT 1 + +/* Return the address of a per-trace exit stub. */ +static LJ_AINLINE uint32_t *exitstub_trace_addr_(uint32_t *p) +{ + while (*p == 0x00000000) p++; /* Skip MIPSI_NOP. */ + return p; +} +/* Avoid dependence on lj_jit.h if only including lj_target.h. */ +#define exitstub_trace_addr(T, exitno) \ + exitstub_trace_addr_((MCode *)((char *)(T)->mcode + (T)->szmcode)) + +/* -- Instructions -------------------------------------------------------- */ + +/* Instruction fields. */ +#define MIPSF_S(r) ((r) << 21) +#define MIPSF_T(r) ((r) << 16) +#define MIPSF_D(r) ((r) << 11) +#define MIPSF_R(r) ((r) << 21) +#define MIPSF_H(r) ((r) << 16) +#define MIPSF_G(r) ((r) << 11) +#define MIPSF_F(r) ((r) << 6) +#define MIPSF_A(n) ((n) << 6) +#define MIPSF_M(n) ((n) << 11) + +typedef enum MIPSIns { + /* Integer instructions. */ + MIPSI_MOVE = 0x00000021, + MIPSI_NOP = 0x00000000, + + MIPSI_LI = 0x24000000, + MIPSI_LU = 0x34000000, + MIPSI_LUI = 0x3c000000, + + MIPSI_ADDIU = 0x24000000, + MIPSI_ANDI = 0x30000000, + MIPSI_ORI = 0x34000000, + MIPSI_XORI = 0x38000000, + MIPSI_SLTI = 0x28000000, + MIPSI_SLTIU = 0x2c000000, + + MIPSI_ADDU = 0x00000021, + MIPSI_SUBU = 0x00000023, + MIPSI_MUL = 0x70000002, + MIPSI_AND = 0x00000024, + MIPSI_OR = 0x00000025, + MIPSI_XOR = 0x00000026, + MIPSI_NOR = 0x00000027, + MIPSI_SLT = 0x0000002a, + MIPSI_SLTU = 0x0000002b, + MIPSI_MOVZ = 0x0000000a, + MIPSI_MOVN = 0x0000000b, + + MIPSI_SLL = 0x00000000, + MIPSI_SRL = 0x00000002, + MIPSI_SRA = 0x00000003, + MIPSI_ROTR = 0x00200002, /* MIPS32R2 */ + MIPSI_SLLV = 0x00000004, + MIPSI_SRLV = 0x00000006, + MIPSI_SRAV = 0x00000007, + MIPSI_ROTRV = 0x00000046, /* MIPS32R2 */ + + MIPSI_SEB = 0x7c000420, /* MIPS32R2 */ + MIPSI_SEH = 0x7c000620, /* MIPS32R2 */ + MIPSI_WSBH = 0x7c0000a0, /* MIPS32R2 */ + + MIPSI_B = 0x10000000, + MIPSI_J = 0x08000000, + MIPSI_JAL = 0x0c000000, + MIPSI_JR = 0x00000008, + MIPSI_JALR = 0x0000f809, + + MIPSI_BEQ = 0x10000000, + MIPSI_BNE = 0x14000000, + MIPSI_BLEZ = 0x18000000, + MIPSI_BGTZ = 0x1c000000, + MIPSI_BLTZ = 0x04000000, + MIPSI_BGEZ = 0x04010000, + + /* Load/store instructions. */ + MIPSI_LW = 0x8c000000, + MIPSI_SW = 0xac000000, + MIPSI_LB = 0x80000000, + MIPSI_SB = 0xa0000000, + MIPSI_LH = 0x84000000, + MIPSI_SH = 0xa4000000, + MIPSI_LBU = 0x90000000, + MIPSI_LHU = 0x94000000, + MIPSI_LWC1 = 0xc4000000, + MIPSI_SWC1 = 0xe4000000, + MIPSI_LDC1 = 0xd4000000, + MIPSI_SDC1 = 0xf4000000, + + /* FP instructions. */ + MIPSI_MOV_S = 0x46000006, + MIPSI_MOV_D = 0x46200006, + MIPSI_MOVT_D = 0x46210011, + MIPSI_MOVF_D = 0x46200011, + + MIPSI_ABS_D = 0x46200005, + MIPSI_NEG_D = 0x46200007, + + MIPSI_ADD_D = 0x46200000, + MIPSI_SUB_D = 0x46200001, + MIPSI_MUL_D = 0x46200002, + MIPSI_DIV_D = 0x46200003, + MIPSI_SQRT_D = 0x46200004, + + MIPSI_ADD_S = 0x46000000, + MIPSI_SUB_S = 0x46000001, + + MIPSI_CVT_D_S = 0x46000021, + MIPSI_CVT_W_S = 0x46000024, + MIPSI_CVT_S_D = 0x46200020, + MIPSI_CVT_W_D = 0x46200024, + MIPSI_CVT_S_W = 0x46800020, + MIPSI_CVT_D_W = 0x46800021, + + MIPSI_TRUNC_W_S = 0x4600000d, + MIPSI_TRUNC_W_D = 0x4620000d, + MIPSI_FLOOR_W_S = 0x4600000f, + MIPSI_FLOOR_W_D = 0x4620000f, + + MIPSI_MFC1 = 0x44000000, + MIPSI_MTC1 = 0x44800000, + + MIPSI_BC1F = 0x45000000, + MIPSI_BC1T = 0x45010000, + + MIPSI_C_EQ_D = 0x46200032, + MIPSI_C_OLT_D = 0x46200034, + MIPSI_C_ULT_D = 0x46200035, + MIPSI_C_OLE_D = 0x46200036, + MIPSI_C_ULE_D = 0x46200037, + +} MIPSIns; + +#endif + +``` + +`include/luajit-2.0.5/src/lj_target_ppc.h`: + +```h +/* +** Definitions for PPC CPUs. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_TARGET_PPC_H +#define _LJ_TARGET_PPC_H + +/* -- Registers IDs ------------------------------------------------------- */ + +#define GPRDEF(_) \ + _(R0) _(SP) _(SYS1) _(R3) _(R4) _(R5) _(R6) _(R7) \ + _(R8) _(R9) _(R10) _(R11) _(R12) _(SYS2) _(R14) _(R15) \ + _(R16) _(R17) _(R18) _(R19) _(R20) _(R21) _(R22) _(R23) \ + _(R24) _(R25) _(R26) _(R27) _(R28) _(R29) _(R30) _(R31) +#define FPRDEF(_) \ + _(F0) _(F1) _(F2) _(F3) _(F4) _(F5) _(F6) _(F7) \ + _(F8) _(F9) _(F10) _(F11) _(F12) _(F13) _(F14) _(F15) \ + _(F16) _(F17) _(F18) _(F19) _(F20) _(F21) _(F22) _(F23) \ + _(F24) _(F25) _(F26) _(F27) _(F28) _(F29) _(F30) _(F31) +#define VRIDDEF(_) + +#define RIDENUM(name) RID_##name, + +enum { + GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ + FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ + RID_MAX, + RID_TMP = RID_R0, + + /* Calling conventions. */ + RID_RET = RID_R3, + RID_RETHI = RID_R3, + RID_RETLO = RID_R4, + RID_FPRET = RID_F1, + + /* These definitions must match with the *.dasc file(s): */ + RID_BASE = RID_R14, /* Interpreter BASE. */ + RID_LPC = RID_R16, /* Interpreter PC. */ + RID_DISPATCH = RID_R17, /* Interpreter DISPATCH table. */ + RID_LREG = RID_R18, /* Interpreter L. */ + RID_JGL = RID_R31, /* On-trace: global_State + 32768. */ + + /* Register ranges [min, max) and number of registers. */ + RID_MIN_GPR = RID_R0, + RID_MAX_GPR = RID_R31+1, + RID_MIN_FPR = RID_F0, + RID_MAX_FPR = RID_F31+1, + RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, + RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR +}; + +#define RID_NUM_KREF RID_NUM_GPR +#define RID_MIN_KREF RID_R0 + +/* -- Register sets ------------------------------------------------------- */ + +/* Make use of all registers, except TMP, SP, SYS1, SYS2 and JGL. */ +#define RSET_FIXED \ + (RID2RSET(RID_TMP)|RID2RSET(RID_SP)|RID2RSET(RID_SYS1)|\ + RID2RSET(RID_SYS2)|RID2RSET(RID_JGL)) +#define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR) - RSET_FIXED) +#define RSET_FPR RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR) +#define RSET_ALL (RSET_GPR|RSET_FPR) +#define RSET_INIT RSET_ALL + +#define RSET_SCRATCH_GPR (RSET_RANGE(RID_R3, RID_R12+1)) +#define RSET_SCRATCH_FPR (RSET_RANGE(RID_F0, RID_F13+1)) +#define RSET_SCRATCH (RSET_SCRATCH_GPR|RSET_SCRATCH_FPR) +#define REGARG_FIRSTGPR RID_R3 +#define REGARG_LASTGPR RID_R10 +#define REGARG_NUMGPR 8 +#define REGARG_FIRSTFPR RID_F1 +#define REGARG_LASTFPR RID_F8 +#define REGARG_NUMFPR 8 + +/* -- Spill slots --------------------------------------------------------- */ + +/* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. +** +** SPS_FIXED: Available fixed spill slots in interpreter frame. +** This definition must match with the *.dasc file(s). +** +** SPS_FIRST: First spill slot for general use. +** [sp+12] tmplo word \ +** [sp+ 8] tmphi word / tmp dword, parameter area for callee +** [sp+ 4] tmpw, LR of callee +** [sp+ 0] stack chain +*/ +#define SPS_FIXED 7 +#define SPS_FIRST 4 + +/* Stack offsets for temporary slots. Used for FP<->int conversions etc. */ +#define SPOFS_TMPW 4 +#define SPOFS_TMP 8 +#define SPOFS_TMPHI 8 +#define SPOFS_TMPLO 12 + +#define sps_scale(slot) (4 * (int32_t)(slot)) +#define sps_align(slot) (((slot) - SPS_FIXED + 3) & ~3) + +/* -- Exit state ---------------------------------------------------------- */ + +/* This definition must match with the *.dasc file(s). */ +typedef struct { + lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ + int32_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ + int32_t spill[256]; /* Spill slots. */ +} ExitState; + +/* Highest exit + 1 indicates stack check. */ +#define EXITSTATE_CHECKEXIT 1 + +/* Return the address of a per-trace exit stub. */ +static LJ_AINLINE uint32_t *exitstub_trace_addr_(uint32_t *p, uint32_t exitno) +{ + while (*p == 0x60000000) p++; /* Skip PPCI_NOP. */ + return p + 3 + exitno; +} +/* Avoid dependence on lj_jit.h if only including lj_target.h. */ +#define exitstub_trace_addr(T, exitno) \ + exitstub_trace_addr_((MCode *)((char *)(T)->mcode + (T)->szmcode), (exitno)) + +/* -- Instructions -------------------------------------------------------- */ + +/* Instruction fields. */ +#define PPCF_CC(cc) ((((cc) & 3) << 16) | (((cc) & 4) << 22)) +#define PPCF_T(r) ((r) << 21) +#define PPCF_A(r) ((r) << 16) +#define PPCF_B(r) ((r) << 11) +#define PPCF_C(r) ((r) << 6) +#define PPCF_MB(n) ((n) << 6) +#define PPCF_ME(n) ((n) << 1) +#define PPCF_Y 0x00200000 +#define PPCF_DOT 0x00000001 + +typedef enum PPCIns { + /* Integer instructions. */ + PPCI_MR = 0x7c000378, + PPCI_NOP = 0x60000000, + + PPCI_LI = 0x38000000, + PPCI_LIS = 0x3c000000, + + PPCI_ADD = 0x7c000214, + PPCI_ADDC = 0x7c000014, + PPCI_ADDO = 0x7c000614, + PPCI_ADDE = 0x7c000114, + PPCI_ADDZE = 0x7c000194, + PPCI_ADDME = 0x7c0001d4, + PPCI_ADDI = 0x38000000, + PPCI_ADDIS = 0x3c000000, + PPCI_ADDIC = 0x30000000, + PPCI_ADDICDOT = 0x34000000, + + PPCI_SUBF = 0x7c000050, + PPCI_SUBFC = 0x7c000010, + PPCI_SUBFO = 0x7c000450, + PPCI_SUBFE = 0x7c000110, + PPCI_SUBFZE = 0x7c000190, + PPCI_SUBFME = 0x7c0001d0, + PPCI_SUBFIC = 0x20000000, + + PPCI_NEG = 0x7c0000d0, + + PPCI_AND = 0x7c000038, + PPCI_ANDC = 0x7c000078, + PPCI_NAND = 0x7c0003b8, + PPCI_ANDIDOT = 0x70000000, + PPCI_ANDISDOT = 0x74000000, + + PPCI_OR = 0x7c000378, + PPCI_NOR = 0x7c0000f8, + PPCI_ORI = 0x60000000, + PPCI_ORIS = 0x64000000, + + PPCI_XOR = 0x7c000278, + PPCI_EQV = 0x7c000238, + PPCI_XORI = 0x68000000, + PPCI_XORIS = 0x6c000000, + + PPCI_CMPW = 0x7c000000, + PPCI_CMPLW = 0x7c000040, + PPCI_CMPWI = 0x2c000000, + PPCI_CMPLWI = 0x28000000, + + PPCI_MULLW = 0x7c0001d6, + PPCI_MULLI = 0x1c000000, + PPCI_MULLWO = 0x7c0005d6, + + PPCI_EXTSB = 0x7c000774, + PPCI_EXTSH = 0x7c000734, + + PPCI_SLW = 0x7c000030, + PPCI_SRW = 0x7c000430, + PPCI_SRAW = 0x7c000630, + PPCI_SRAWI = 0x7c000670, + + PPCI_RLWNM = 0x5c000000, + PPCI_RLWINM = 0x54000000, + PPCI_RLWIMI = 0x50000000, + + PPCI_B = 0x48000000, + PPCI_BL = 0x48000001, + PPCI_BC = 0x40800000, + PPCI_BCL = 0x40800001, + PPCI_BCTR = 0x4e800420, + PPCI_BCTRL = 0x4e800421, + + PPCI_CRANDC = 0x4c000102, + PPCI_CRXOR = 0x4c000182, + PPCI_CRAND = 0x4c000202, + PPCI_CREQV = 0x4c000242, + PPCI_CRORC = 0x4c000342, + PPCI_CROR = 0x4c000382, + + PPCI_MFLR = 0x7c0802a6, + PPCI_MTCTR = 0x7c0903a6, + + PPCI_MCRXR = 0x7c000400, + + /* Load/store instructions. */ + PPCI_LWZ = 0x80000000, + PPCI_LBZ = 0x88000000, + PPCI_STW = 0x90000000, + PPCI_STB = 0x98000000, + PPCI_LHZ = 0xa0000000, + PPCI_LHA = 0xa8000000, + PPCI_STH = 0xb0000000, + + PPCI_STWU = 0x94000000, + + PPCI_LFS = 0xc0000000, + PPCI_LFD = 0xc8000000, + PPCI_STFS = 0xd0000000, + PPCI_STFD = 0xd8000000, + + PPCI_LWZX = 0x7c00002e, + PPCI_LBZX = 0x7c0000ae, + PPCI_STWX = 0x7c00012e, + PPCI_STBX = 0x7c0001ae, + PPCI_LHZX = 0x7c00022e, + PPCI_LHAX = 0x7c0002ae, + PPCI_STHX = 0x7c00032e, + + PPCI_LWBRX = 0x7c00042c, + PPCI_STWBRX = 0x7c00052c, + + PPCI_LFSX = 0x7c00042e, + PPCI_LFDX = 0x7c0004ae, + PPCI_STFSX = 0x7c00052e, + PPCI_STFDX = 0x7c0005ae, + + /* FP instructions. */ + PPCI_FMR = 0xfc000090, + PPCI_FNEG = 0xfc000050, + PPCI_FABS = 0xfc000210, + + PPCI_FRSP = 0xfc000018, + PPCI_FCTIWZ = 0xfc00001e, + + PPCI_FADD = 0xfc00002a, + PPCI_FSUB = 0xfc000028, + PPCI_FMUL = 0xfc000032, + PPCI_FDIV = 0xfc000024, + PPCI_FSQRT = 0xfc00002c, + + PPCI_FMADD = 0xfc00003a, + PPCI_FMSUB = 0xfc000038, + PPCI_FNMSUB = 0xfc00003c, + + PPCI_FCMPU = 0xfc000000, + PPCI_FSEL = 0xfc00002e, +} PPCIns; + +typedef enum PPCCC { + CC_GE, CC_LE, CC_NE, CC_NS, CC_LT, CC_GT, CC_EQ, CC_SO +} PPCCC; + +#endif + +``` + +`include/luajit-2.0.5/src/lj_target_x86.h`: + +```h +/* +** Definitions for x86 and x64 CPUs. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_TARGET_X86_H +#define _LJ_TARGET_X86_H + +/* -- Registers IDs ------------------------------------------------------- */ + +#if LJ_64 +#define GPRDEF(_) \ + _(EAX) _(ECX) _(EDX) _(EBX) _(ESP) _(EBP) _(ESI) _(EDI) \ + _(R8D) _(R9D) _(R10D) _(R11D) _(R12D) _(R13D) _(R14D) _(R15D) +#define FPRDEF(_) \ + _(XMM0) _(XMM1) _(XMM2) _(XMM3) _(XMM4) _(XMM5) _(XMM6) _(XMM7) \ + _(XMM8) _(XMM9) _(XMM10) _(XMM11) _(XMM12) _(XMM13) _(XMM14) _(XMM15) +#else +#define GPRDEF(_) \ + _(EAX) _(ECX) _(EDX) _(EBX) _(ESP) _(EBP) _(ESI) _(EDI) +#define FPRDEF(_) \ + _(XMM0) _(XMM1) _(XMM2) _(XMM3) _(XMM4) _(XMM5) _(XMM6) _(XMM7) +#endif +#define VRIDDEF(_) \ + _(MRM) + +#define RIDENUM(name) RID_##name, + +enum { + GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ + FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ + RID_MAX, + RID_MRM = RID_MAX, /* Pseudo-id for ModRM operand. */ + + /* Calling conventions. */ + RID_RET = RID_EAX, +#if LJ_64 + RID_FPRET = RID_XMM0, +#else + RID_RETLO = RID_EAX, + RID_RETHI = RID_EDX, +#endif + + /* These definitions must match with the *.dasc file(s): */ + RID_BASE = RID_EDX, /* Interpreter BASE. */ +#if LJ_64 && !LJ_ABI_WIN + RID_LPC = RID_EBX, /* Interpreter PC. */ + RID_DISPATCH = RID_R14D, /* Interpreter DISPATCH table. */ +#else + RID_LPC = RID_ESI, /* Interpreter PC. */ + RID_DISPATCH = RID_EBX, /* Interpreter DISPATCH table. */ +#endif + + /* Register ranges [min, max) and number of registers. */ + RID_MIN_GPR = RID_EAX, + RID_MIN_FPR = RID_XMM0, + RID_MAX_GPR = RID_MIN_FPR, + RID_MAX_FPR = RID_MAX, + RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, + RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR, +}; + +/* -- Register sets ------------------------------------------------------- */ + +/* Make use of all registers, except the stack pointer. */ +#define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR)-RID2RSET(RID_ESP)) +#define RSET_FPR (RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR)) +#define RSET_ALL (RSET_GPR|RSET_FPR) +#define RSET_INIT RSET_ALL + +#if LJ_64 +/* Note: this requires the use of FORCE_REX! */ +#define RSET_GPR8 RSET_GPR +#else +#define RSET_GPR8 (RSET_RANGE(RID_EAX, RID_EBX+1)) +#endif + +/* ABI-specific register sets. */ +#define RSET_ACD (RID2RSET(RID_EAX)|RID2RSET(RID_ECX)|RID2RSET(RID_EDX)) +#if LJ_64 +#if LJ_ABI_WIN +/* Windows x64 ABI. */ +#define RSET_SCRATCH \ + (RSET_ACD|RSET_RANGE(RID_R8D, RID_R11D+1)|RSET_RANGE(RID_XMM0, RID_XMM5+1)) +#define REGARG_GPRS \ + (RID_ECX|((RID_EDX|((RID_R8D|(RID_R9D<<5))<<5))<<5)) +#define REGARG_NUMGPR 4 +#define REGARG_NUMFPR 4 +#define REGARG_FIRSTFPR RID_XMM0 +#define REGARG_LASTFPR RID_XMM3 +#define STACKARG_OFS (4*8) +#else +/* The rest of the civilized x64 world has a common ABI. */ +#define RSET_SCRATCH \ + (RSET_ACD|RSET_RANGE(RID_ESI, RID_R11D+1)|RSET_FPR) +#define REGARG_GPRS \ + (RID_EDI|((RID_ESI|((RID_EDX|((RID_ECX|((RID_R8D|(RID_R9D \ + <<5))<<5))<<5))<<5))<<5)) +#define REGARG_NUMGPR 6 +#define REGARG_NUMFPR 8 +#define REGARG_FIRSTFPR RID_XMM0 +#define REGARG_LASTFPR RID_XMM7 +#define STACKARG_OFS 0 +#endif +#else +/* Common x86 ABI. */ +#define RSET_SCRATCH (RSET_ACD|RSET_FPR) +#define REGARG_GPRS (RID_ECX|(RID_EDX<<5)) /* Fastcall only. */ +#define REGARG_NUMGPR 2 /* Fastcall only. */ +#define REGARG_NUMFPR 0 +#define STACKARG_OFS 0 +#endif + +#if LJ_64 +/* Prefer the low 8 regs of each type to reduce REX prefixes. */ +#undef rset_picktop +#define rset_picktop(rs) (lj_fls(lj_bswap(rs)) ^ 0x18) +#endif + +/* -- Spill slots --------------------------------------------------------- */ + +/* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. +** +** SPS_FIXED: Available fixed spill slots in interpreter frame. +** This definition must match with the *.dasc file(s). +** +** SPS_FIRST: First spill slot for general use. Reserve min. two 32 bit slots. +*/ +#if LJ_64 +#if LJ_ABI_WIN +#define SPS_FIXED (4*2) +#define SPS_FIRST (4*2) /* Don't use callee register save area. */ +#else +#define SPS_FIXED 4 +#define SPS_FIRST 2 +#endif +#else +#define SPS_FIXED 6 +#define SPS_FIRST 2 +#endif + +#define SPOFS_TMP 0 + +#define sps_scale(slot) (4 * (int32_t)(slot)) +#define sps_align(slot) (((slot) - SPS_FIXED + 3) & ~3) + +/* -- Exit state ---------------------------------------------------------- */ + +/* This definition must match with the *.dasc file(s). */ +typedef struct { + lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ + intptr_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ + int32_t spill[256]; /* Spill slots. */ +} ExitState; + +/* Limited by the range of a short fwd jump (127): (2+2)*(32-1)-2 = 122. */ +#define EXITSTUB_SPACING (2+2) +#define EXITSTUBS_PER_GROUP 32 + +/* -- x86 ModRM operand encoding ------------------------------------------ */ + +typedef enum { + XM_OFS0 = 0x00, XM_OFS8 = 0x40, XM_OFS32 = 0x80, XM_REG = 0xc0, + XM_SCALE1 = 0x00, XM_SCALE2 = 0x40, XM_SCALE4 = 0x80, XM_SCALE8 = 0xc0, + XM_MASK = 0xc0 +} x86Mode; + +/* Structure to hold variable ModRM operand. */ +typedef struct { + int32_t ofs; /* Offset. */ + uint8_t base; /* Base register or RID_NONE. */ + uint8_t idx; /* Index register or RID_NONE. */ + uint8_t scale; /* Index scale (XM_SCALE1 .. XM_SCALE8). */ +} x86ModRM; + +/* -- Opcodes ------------------------------------------------------------- */ + +/* Macros to construct variable-length x86 opcodes. -(len+1) is in LSB. */ +#define XO_(o) ((uint32_t)(0x0000fe + (0x##o<<24))) +#define XO_FPU(a,b) ((uint32_t)(0x00fd + (0x##a<<16)+(0x##b<<24))) +#define XO_0f(o) ((uint32_t)(0x0f00fd + (0x##o<<24))) +#define XO_66(o) ((uint32_t)(0x6600fd + (0x##o<<24))) +#define XO_660f(o) ((uint32_t)(0x0f66fc + (0x##o<<24))) +#define XO_f20f(o) ((uint32_t)(0x0ff2fc + (0x##o<<24))) +#define XO_f30f(o) ((uint32_t)(0x0ff3fc + (0x##o<<24))) + +/* This list of x86 opcodes is not intended to be complete. Opcodes are only +** included when needed. Take a look at DynASM or jit.dis_x86 to see the +** whole mess. +*/ +typedef enum { + /* Fixed length opcodes. XI_* prefix. */ + XI_NOP = 0x90, + XI_XCHGa = 0x90, + XI_CALL = 0xe8, + XI_JMP = 0xe9, + XI_JMPs = 0xeb, + XI_PUSH = 0x50, /* Really 50+r. */ + XI_JCCs = 0x70, /* Really 7x. */ + XI_JCCn = 0x80, /* Really 0f8x. */ + XI_LEA = 0x8d, + XI_MOVrib = 0xb0, /* Really b0+r. */ + XI_MOVri = 0xb8, /* Really b8+r. */ + XI_ARITHib = 0x80, + XI_ARITHi = 0x81, + XI_ARITHi8 = 0x83, + XI_PUSHi8 = 0x6a, + XI_TESTb = 0x84, + XI_TEST = 0x85, + XI_MOVmi = 0xc7, + XI_GROUP5 = 0xff, + + /* Note: little-endian byte-order! */ + XI_FLDZ = 0xeed9, + XI_FLD1 = 0xe8d9, + XI_FLDLG2 = 0xecd9, + XI_FLDLN2 = 0xedd9, + XI_FDUP = 0xc0d9, /* Really fld st0. */ + XI_FPOP = 0xd8dd, /* Really fstp st0. */ + XI_FPOP1 = 0xd9dd, /* Really fstp st1. */ + XI_FRNDINT = 0xfcd9, + XI_FSIN = 0xfed9, + XI_FCOS = 0xffd9, + XI_FPTAN = 0xf2d9, + XI_FPATAN = 0xf3d9, + XI_FSCALE = 0xfdd9, + XI_FYL2X = 0xf1d9, + + /* Variable-length opcodes. XO_* prefix. */ + XO_MOV = XO_(8b), + XO_MOVto = XO_(89), + XO_MOVtow = XO_66(89), + XO_MOVtob = XO_(88), + XO_MOVmi = XO_(c7), + XO_MOVmib = XO_(c6), + XO_LEA = XO_(8d), + XO_ARITHib = XO_(80), + XO_ARITHi = XO_(81), + XO_ARITHi8 = XO_(83), + XO_ARITHiw8 = XO_66(83), + XO_SHIFTi = XO_(c1), + XO_SHIFT1 = XO_(d1), + XO_SHIFTcl = XO_(d3), + XO_IMUL = XO_0f(af), + XO_IMULi = XO_(69), + XO_IMULi8 = XO_(6b), + XO_CMP = XO_(3b), + XO_TESTb = XO_(84), + XO_TEST = XO_(85), + XO_GROUP3b = XO_(f6), + XO_GROUP3 = XO_(f7), + XO_GROUP5b = XO_(fe), + XO_GROUP5 = XO_(ff), + XO_MOVZXb = XO_0f(b6), + XO_MOVZXw = XO_0f(b7), + XO_MOVSXb = XO_0f(be), + XO_MOVSXw = XO_0f(bf), + XO_MOVSXd = XO_(63), + XO_BSWAP = XO_0f(c8), + XO_CMOV = XO_0f(40), + + XO_MOVSD = XO_f20f(10), + XO_MOVSDto = XO_f20f(11), + XO_MOVSS = XO_f30f(10), + XO_MOVSSto = XO_f30f(11), + XO_MOVLPD = XO_660f(12), + XO_MOVAPS = XO_0f(28), + XO_XORPS = XO_0f(57), + XO_ANDPS = XO_0f(54), + XO_ADDSD = XO_f20f(58), + XO_SUBSD = XO_f20f(5c), + XO_MULSD = XO_f20f(59), + XO_DIVSD = XO_f20f(5e), + XO_SQRTSD = XO_f20f(51), + XO_MINSD = XO_f20f(5d), + XO_MAXSD = XO_f20f(5f), + XO_ROUNDSD = 0x0b3a0ffc, /* Really 66 0f 3a 0b. See asm_fpmath. */ + XO_UCOMISD = XO_660f(2e), + XO_CVTSI2SD = XO_f20f(2a), + XO_CVTSD2SI = XO_f20f(2d), + XO_CVTTSD2SI= XO_f20f(2c), + XO_CVTSI2SS = XO_f30f(2a), + XO_CVTSS2SI = XO_f30f(2d), + XO_CVTTSS2SI= XO_f30f(2c), + XO_CVTSS2SD = XO_f30f(5a), + XO_CVTSD2SS = XO_f20f(5a), + XO_ADDSS = XO_f30f(58), + XO_MOVD = XO_660f(6e), + XO_MOVDto = XO_660f(7e), + + XO_FLDd = XO_(d9), XOg_FLDd = 0, + XO_FLDq = XO_(dd), XOg_FLDq = 0, + XO_FILDd = XO_(db), XOg_FILDd = 0, + XO_FILDq = XO_(df), XOg_FILDq = 5, + XO_FSTPd = XO_(d9), XOg_FSTPd = 3, + XO_FSTPq = XO_(dd), XOg_FSTPq = 3, + XO_FISTPq = XO_(df), XOg_FISTPq = 7, + XO_FISTTPq = XO_(dd), XOg_FISTTPq = 1, + XO_FADDq = XO_(dc), XOg_FADDq = 0, + XO_FLDCW = XO_(d9), XOg_FLDCW = 5, + XO_FNSTCW = XO_(d9), XOg_FNSTCW = 7 +} x86Op; + +/* x86 opcode groups. */ +typedef uint32_t x86Group; + +#define XG_(i8, i, g) ((x86Group)(((i8) << 16) + ((i) << 8) + (g))) +#define XG_ARITHi(g) XG_(XI_ARITHi8, XI_ARITHi, g) +#define XG_TOXOi(xg) ((x86Op)(0x000000fe + (((xg)<<16) & 0xff000000))) +#define XG_TOXOi8(xg) ((x86Op)(0x000000fe + (((xg)<<8) & 0xff000000))) + +#define XO_ARITH(a) ((x86Op)(0x030000fe + ((a)<<27))) +#define XO_ARITHw(a) ((x86Op)(0x036600fd + ((a)<<27))) + +typedef enum { + XOg_ADD, XOg_OR, XOg_ADC, XOg_SBB, XOg_AND, XOg_SUB, XOg_XOR, XOg_CMP, + XOg_X_IMUL +} x86Arith; + +typedef enum { + XOg_ROL, XOg_ROR, XOg_RCL, XOg_RCR, XOg_SHL, XOg_SHR, XOg_SAL, XOg_SAR +} x86Shift; + +typedef enum { + XOg_TEST, XOg_TEST_, XOg_NOT, XOg_NEG, XOg_MUL, XOg_IMUL, XOg_DIV, XOg_IDIV +} x86Group3; + +typedef enum { + XOg_INC, XOg_DEC, XOg_CALL, XOg_CALLfar, XOg_JMP, XOg_JMPfar, XOg_PUSH +} x86Group5; + +/* x86 condition codes. */ +typedef enum { + CC_O, CC_NO, CC_B, CC_NB, CC_E, CC_NE, CC_BE, CC_NBE, + CC_S, CC_NS, CC_P, CC_NP, CC_L, CC_NL, CC_LE, CC_NLE, + CC_C = CC_B, CC_NAE = CC_C, CC_NC = CC_NB, CC_AE = CC_NB, + CC_Z = CC_E, CC_NZ = CC_NE, CC_NA = CC_BE, CC_A = CC_NBE, + CC_PE = CC_P, CC_PO = CC_NP, CC_NGE = CC_L, CC_GE = CC_NL, + CC_NG = CC_LE, CC_G = CC_NLE +} x86CC; + +#endif + +``` + +`include/luajit-2.0.5/src/lj_trace.c`: + +```c +/* +** Trace management. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_trace_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_str.h" +#include "lj_frame.h" +#include "lj_state.h" +#include "lj_bc.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" +#include "lj_mcode.h" +#include "lj_trace.h" +#include "lj_snap.h" +#include "lj_gdbjit.h" +#include "lj_record.h" +#include "lj_asm.h" +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "lj_vmevent.h" +#include "lj_target.h" + +/* -- Error handling ------------------------------------------------------ */ + +/* Synchronous abort with error message. */ +void lj_trace_err(jit_State *J, TraceError e) +{ + setnilV(&J->errinfo); /* No error info. */ + setintV(J->L->top++, (int32_t)e); + lj_err_throw(J->L, LUA_ERRRUN); +} + +/* Synchronous abort with error message and error info. */ +void lj_trace_err_info(jit_State *J, TraceError e) +{ + setintV(J->L->top++, (int32_t)e); + lj_err_throw(J->L, LUA_ERRRUN); +} + +/* -- Trace management ---------------------------------------------------- */ + +/* The current trace is first assembled in J->cur. The variable length +** arrays point to shared, growable buffers (J->irbuf etc.). When trace +** recording ends successfully, the current trace and its data structures +** are copied to a new (compact) GCtrace object. +*/ + +/* Find a free trace number. */ +static TraceNo trace_findfree(jit_State *J) +{ + MSize osz, lim; + if (J->freetrace == 0) + J->freetrace = 1; + for (; J->freetrace < J->sizetrace; J->freetrace++) + if (traceref(J, J->freetrace) == NULL) + return J->freetrace++; + /* Need to grow trace array. */ + lim = (MSize)J->param[JIT_P_maxtrace] + 1; + if (lim < 2) lim = 2; else if (lim > 65535) lim = 65535; + osz = J->sizetrace; + if (osz >= lim) + return 0; /* Too many traces. */ + lj_mem_growvec(J->L, J->trace, J->sizetrace, lim, GCRef); + for (; osz < J->sizetrace; osz++) + setgcrefnull(J->trace[osz]); + return J->freetrace; +} + +#define TRACE_APPENDVEC(field, szfield, tp) \ + T->field = (tp *)p; \ + memcpy(p, J->cur.field, J->cur.szfield*sizeof(tp)); \ + p += J->cur.szfield*sizeof(tp); + +#ifdef LUAJIT_USE_PERFTOOLS +/* +** Create symbol table of JIT-compiled code. For use with Linux perf tools. +** Example usage: +** perf record -f -e cycles luajit test.lua +** perf report -s symbol +** rm perf.data /tmp/perf-*.map +*/ +#include +#include + +static void perftools_addtrace(GCtrace *T) +{ + static FILE *fp; + GCproto *pt = &gcref(T->startpt)->pt; + const BCIns *startpc = mref(T->startpc, const BCIns); + const char *name = proto_chunknamestr(pt); + BCLine lineno; + if (name[0] == '@' || name[0] == '=') + name++; + else + name = "(string)"; + lua_assert(startpc >= proto_bc(pt) && startpc < proto_bc(pt) + pt->sizebc); + lineno = lj_debug_line(pt, proto_bcpos(pt, startpc)); + if (!fp) { + char fname[40]; + sprintf(fname, "/tmp/perf-%d.map", getpid()); + if (!(fp = fopen(fname, "w"))) return; + setlinebuf(fp); + } + fprintf(fp, "%lx %x TRACE_%d::%s:%u\n", + (long)T->mcode, T->szmcode, T->traceno, name, lineno); +} +#endif + +/* Allocate space for copy of trace. */ +static GCtrace *trace_save_alloc(jit_State *J) +{ + size_t sztr = ((sizeof(GCtrace)+7)&~7); + size_t szins = (J->cur.nins-J->cur.nk)*sizeof(IRIns); + size_t sz = sztr + szins + + J->cur.nsnap*sizeof(SnapShot) + + J->cur.nsnapmap*sizeof(SnapEntry); + return lj_mem_newt(J->L, (MSize)sz, GCtrace); +} + +/* Save current trace by copying and compacting it. */ +static void trace_save(jit_State *J, GCtrace *T) +{ + size_t sztr = ((sizeof(GCtrace)+7)&~7); + size_t szins = (J->cur.nins-J->cur.nk)*sizeof(IRIns); + char *p = (char *)T + sztr; + memcpy(T, &J->cur, sizeof(GCtrace)); + setgcrefr(T->nextgc, J2G(J)->gc.root); + setgcrefp(J2G(J)->gc.root, T); + newwhite(J2G(J), T); + T->gct = ~LJ_TTRACE; + T->ir = (IRIns *)p - J->cur.nk; + memcpy(p, J->cur.ir+J->cur.nk, szins); + p += szins; + TRACE_APPENDVEC(snap, nsnap, SnapShot) + TRACE_APPENDVEC(snapmap, nsnapmap, SnapEntry) + J->cur.traceno = 0; + setgcrefp(J->trace[T->traceno], T); + lj_gc_barriertrace(J2G(J), T->traceno); + lj_gdbjit_addtrace(J, T); +#ifdef LUAJIT_USE_PERFTOOLS + perftools_addtrace(T); +#endif +} + +void LJ_FASTCALL lj_trace_free(global_State *g, GCtrace *T) +{ + jit_State *J = G2J(g); + if (T->traceno) { + lj_gdbjit_deltrace(J, T); + if (T->traceno < J->freetrace) + J->freetrace = T->traceno; + setgcrefnull(J->trace[T->traceno]); + } + lj_mem_free(g, T, + ((sizeof(GCtrace)+7)&~7) + (T->nins-T->nk)*sizeof(IRIns) + + T->nsnap*sizeof(SnapShot) + T->nsnapmap*sizeof(SnapEntry)); +} + +/* Re-enable compiling a prototype by unpatching any modified bytecode. */ +void lj_trace_reenableproto(GCproto *pt) +{ + if ((pt->flags & PROTO_ILOOP)) { + BCIns *bc = proto_bc(pt); + BCPos i, sizebc = pt->sizebc;; + pt->flags &= ~PROTO_ILOOP; + if (bc_op(bc[0]) == BC_IFUNCF) + setbc_op(&bc[0], BC_FUNCF); + for (i = 1; i < sizebc; i++) { + BCOp op = bc_op(bc[i]); + if (op == BC_IFORL || op == BC_IITERL || op == BC_ILOOP) + setbc_op(&bc[i], (int)op+(int)BC_LOOP-(int)BC_ILOOP); + } + } +} + +/* Unpatch the bytecode modified by a root trace. */ +static void trace_unpatch(jit_State *J, GCtrace *T) +{ + BCOp op = bc_op(T->startins); + BCIns *pc = mref(T->startpc, BCIns); + UNUSED(J); + if (op == BC_JMP) + return; /* No need to unpatch branches in parent traces (yet). */ + switch (bc_op(*pc)) { + case BC_JFORL: + lua_assert(traceref(J, bc_d(*pc)) == T); + *pc = T->startins; + pc += bc_j(T->startins); + lua_assert(bc_op(*pc) == BC_JFORI); + setbc_op(pc, BC_FORI); + break; + case BC_JITERL: + case BC_JLOOP: + lua_assert(op == BC_ITERL || op == BC_LOOP || bc_isret(op)); + *pc = T->startins; + break; + case BC_JMP: + lua_assert(op == BC_ITERL); + pc += bc_j(*pc)+2; + if (bc_op(*pc) == BC_JITERL) { + lua_assert(traceref(J, bc_d(*pc)) == T); + *pc = T->startins; + } + break; + case BC_JFUNCF: + lua_assert(op == BC_FUNCF); + *pc = T->startins; + break; + default: /* Already unpatched. */ + break; + } +} + +/* Flush a root trace. */ +static void trace_flushroot(jit_State *J, GCtrace *T) +{ + GCproto *pt = &gcref(T->startpt)->pt; + lua_assert(T->root == 0 && pt != NULL); + /* First unpatch any modified bytecode. */ + trace_unpatch(J, T); + /* Unlink root trace from chain anchored in prototype. */ + if (pt->trace == T->traceno) { /* Trace is first in chain. Easy. */ + pt->trace = T->nextroot; + } else if (pt->trace) { /* Otherwise search in chain of root traces. */ + GCtrace *T2 = traceref(J, pt->trace); + if (T2) { + for (; T2->nextroot; T2 = traceref(J, T2->nextroot)) + if (T2->nextroot == T->traceno) { + T2->nextroot = T->nextroot; /* Unlink from chain. */ + break; + } + } + } +} + +/* Flush a trace. Only root traces are considered. */ +void lj_trace_flush(jit_State *J, TraceNo traceno) +{ + if (traceno > 0 && traceno < J->sizetrace) { + GCtrace *T = traceref(J, traceno); + if (T && T->root == 0) + trace_flushroot(J, T); + } +} + +/* Flush all traces associated with a prototype. */ +void lj_trace_flushproto(global_State *g, GCproto *pt) +{ + while (pt->trace != 0) + trace_flushroot(G2J(g), traceref(G2J(g), pt->trace)); +} + +/* Flush all traces. */ +int lj_trace_flushall(lua_State *L) +{ + jit_State *J = L2J(L); + ptrdiff_t i; + if ((J2G(J)->hookmask & HOOK_GC)) + return 1; + for (i = (ptrdiff_t)J->sizetrace-1; i > 0; i--) { + GCtrace *T = traceref(J, i); + if (T) { + if (T->root == 0) + trace_flushroot(J, T); + lj_gdbjit_deltrace(J, T); + T->traceno = 0; + setgcrefnull(J->trace[i]); + } + } + J->cur.traceno = 0; + J->freetrace = 0; + /* Clear penalty cache. */ + memset(J->penalty, 0, sizeof(J->penalty)); + /* Free the whole machine code and invalidate all exit stub groups. */ + lj_mcode_free(J); + memset(J->exitstubgroup, 0, sizeof(J->exitstubgroup)); + lj_vmevent_send(L, TRACE, + setstrV(L, L->top++, lj_str_newlit(L, "flush")); + ); + return 0; +} + +/* Initialize JIT compiler state. */ +void lj_trace_initstate(global_State *g) +{ + jit_State *J = G2J(g); + TValue *tv; + /* Initialize SIMD constants. */ + tv = LJ_KSIMD(J, LJ_KSIMD_ABS); + tv[0].u64 = U64x(7fffffff,ffffffff); + tv[1].u64 = U64x(7fffffff,ffffffff); + tv = LJ_KSIMD(J, LJ_KSIMD_NEG); + tv[0].u64 = U64x(80000000,00000000); + tv[1].u64 = U64x(80000000,00000000); +} + +/* Free everything associated with the JIT compiler state. */ +void lj_trace_freestate(global_State *g) +{ + jit_State *J = G2J(g); +#ifdef LUA_USE_ASSERT + { /* This assumes all traces have already been freed. */ + ptrdiff_t i; + for (i = 1; i < (ptrdiff_t)J->sizetrace; i++) + lua_assert(i == (ptrdiff_t)J->cur.traceno || traceref(J, i) == NULL); + } +#endif + lj_mcode_free(J); + lj_ir_k64_freeall(J); + lj_mem_freevec(g, J->snapmapbuf, J->sizesnapmap, SnapEntry); + lj_mem_freevec(g, J->snapbuf, J->sizesnap, SnapShot); + lj_mem_freevec(g, J->irbuf + J->irbotlim, J->irtoplim - J->irbotlim, IRIns); + lj_mem_freevec(g, J->trace, J->sizetrace, GCRef); +} + +/* -- Penalties and blacklisting ------------------------------------------ */ + +/* Blacklist a bytecode instruction. */ +static void blacklist_pc(GCproto *pt, BCIns *pc) +{ + setbc_op(pc, (int)bc_op(*pc)+(int)BC_ILOOP-(int)BC_LOOP); + pt->flags |= PROTO_ILOOP; +} + +/* Penalize a bytecode instruction. */ +static void penalty_pc(jit_State *J, GCproto *pt, BCIns *pc, TraceError e) +{ + uint32_t i, val = PENALTY_MIN; + for (i = 0; i < PENALTY_SLOTS; i++) + if (mref(J->penalty[i].pc, const BCIns) == pc) { /* Cache slot found? */ + /* First try to bump its hotcount several times. */ + val = ((uint32_t)J->penalty[i].val << 1) + + LJ_PRNG_BITS(J, PENALTY_RNDBITS); + if (val > PENALTY_MAX) { + blacklist_pc(pt, pc); /* Blacklist it, if that didn't help. */ + return; + } + goto setpenalty; + } + /* Assign a new penalty cache slot. */ + i = J->penaltyslot; + J->penaltyslot = (J->penaltyslot + 1) & (PENALTY_SLOTS-1); + setmref(J->penalty[i].pc, pc); +setpenalty: + J->penalty[i].val = (uint16_t)val; + J->penalty[i].reason = e; + hotcount_set(J2GG(J), pc+1, val); +} + +/* -- Trace compiler state machine ---------------------------------------- */ + +/* Start tracing. */ +static void trace_start(jit_State *J) +{ + lua_State *L; + TraceNo traceno; + + if ((J->pt->flags & PROTO_NOJIT)) { /* JIT disabled for this proto? */ + if (J->parent == 0) { + /* Lazy bytecode patching to disable hotcount events. */ + lua_assert(bc_op(*J->pc) == BC_FORL || bc_op(*J->pc) == BC_ITERL || + bc_op(*J->pc) == BC_LOOP || bc_op(*J->pc) == BC_FUNCF); + setbc_op(J->pc, (int)bc_op(*J->pc)+(int)BC_ILOOP-(int)BC_LOOP); + J->pt->flags |= PROTO_ILOOP; + } + J->state = LJ_TRACE_IDLE; /* Silently ignored. */ + return; + } + + /* Get a new trace number. */ + traceno = trace_findfree(J); + if (LJ_UNLIKELY(traceno == 0)) { /* No free trace? */ + lua_assert((J2G(J)->hookmask & HOOK_GC) == 0); + lj_trace_flushall(J->L); + J->state = LJ_TRACE_IDLE; /* Silently ignored. */ + return; + } + setgcrefp(J->trace[traceno], &J->cur); + + /* Setup enough of the current trace to be able to send the vmevent. */ + memset(&J->cur, 0, sizeof(GCtrace)); + J->cur.traceno = traceno; + J->cur.nins = J->cur.nk = REF_BASE; + J->cur.ir = J->irbuf; + J->cur.snap = J->snapbuf; + J->cur.snapmap = J->snapmapbuf; + J->mergesnap = 0; + J->needsnap = 0; + J->bcskip = 0; + J->guardemit.irt = 0; + J->postproc = LJ_POST_NONE; + lj_resetsplit(J); + setgcref(J->cur.startpt, obj2gco(J->pt)); + + L = J->L; + lj_vmevent_send(L, TRACE, + setstrV(L, L->top++, lj_str_newlit(L, "start")); + setintV(L->top++, traceno); + setfuncV(L, L->top++, J->fn); + setintV(L->top++, proto_bcpos(J->pt, J->pc)); + if (J->parent) { + setintV(L->top++, J->parent); + setintV(L->top++, J->exitno); + } + ); + lj_record_setup(J); +} + +/* Stop tracing. */ +static void trace_stop(jit_State *J) +{ + BCIns *pc = mref(J->cur.startpc, BCIns); + BCOp op = bc_op(J->cur.startins); + GCproto *pt = &gcref(J->cur.startpt)->pt; + TraceNo traceno = J->cur.traceno; + GCtrace *T = trace_save_alloc(J); /* Do this first. May throw OOM. */ + lua_State *L; + + switch (op) { + case BC_FORL: + setbc_op(pc+bc_j(J->cur.startins), BC_JFORI); /* Patch FORI, too. */ + /* fallthrough */ + case BC_LOOP: + case BC_ITERL: + case BC_FUNCF: + /* Patch bytecode of starting instruction in root trace. */ + setbc_op(pc, (int)op+(int)BC_JLOOP-(int)BC_LOOP); + setbc_d(pc, traceno); + addroot: + /* Add to root trace chain in prototype. */ + J->cur.nextroot = pt->trace; + pt->trace = (TraceNo1)traceno; + break; + case BC_RET: + case BC_RET0: + case BC_RET1: + *pc = BCINS_AD(BC_JLOOP, J->cur.snap[0].nslots, traceno); + goto addroot; + case BC_JMP: + /* Patch exit branch in parent to side trace entry. */ + lua_assert(J->parent != 0 && J->cur.root != 0); + lj_asm_patchexit(J, traceref(J, J->parent), J->exitno, J->cur.mcode); + /* Avoid compiling a side trace twice (stack resizing uses parent exit). */ + traceref(J, J->parent)->snap[J->exitno].count = SNAPCOUNT_DONE; + /* Add to side trace chain in root trace. */ + { + GCtrace *root = traceref(J, J->cur.root); + root->nchild++; + J->cur.nextside = root->nextside; + root->nextside = (TraceNo1)traceno; + } + break; + default: + lua_assert(0); + break; + } + + /* Commit new mcode only after all patching is done. */ + lj_mcode_commit(J, J->cur.mcode); + J->postproc = LJ_POST_NONE; + trace_save(J, T); + + L = J->L; + lj_vmevent_send(L, TRACE, + setstrV(L, L->top++, lj_str_newlit(L, "stop")); + setintV(L->top++, traceno); + ); +} + +/* Start a new root trace for down-recursion. */ +static int trace_downrec(jit_State *J) +{ + /* Restart recording at the return instruction. */ + lua_assert(J->pt != NULL); + lua_assert(bc_isret(bc_op(*J->pc))); + if (bc_op(*J->pc) == BC_RETM) + return 0; /* NYI: down-recursion with RETM. */ + J->parent = 0; + J->exitno = 0; + J->state = LJ_TRACE_RECORD; + trace_start(J); + return 1; +} + +/* Abort tracing. */ +static int trace_abort(jit_State *J) +{ + lua_State *L = J->L; + TraceError e = LJ_TRERR_RECERR; + TraceNo traceno; + + J->postproc = LJ_POST_NONE; + lj_mcode_abort(J); + if (tvisnumber(L->top-1)) + e = (TraceError)numberVint(L->top-1); + if (e == LJ_TRERR_MCODELM) { + L->top--; /* Remove error object */ + J->state = LJ_TRACE_ASM; + return 1; /* Retry ASM with new MCode area. */ + } + /* Penalize or blacklist starting bytecode instruction. */ + if (J->parent == 0 && !bc_isret(bc_op(J->cur.startins))) + penalty_pc(J, &gcref(J->cur.startpt)->pt, mref(J->cur.startpc, BCIns), e); + + /* Is there anything to abort? */ + traceno = J->cur.traceno; + if (traceno) { + ptrdiff_t errobj = savestack(L, L->top-1); /* Stack may be resized. */ + J->cur.link = 0; + J->cur.linktype = LJ_TRLINK_NONE; + lj_vmevent_send(L, TRACE, + TValue *frame; + const BCIns *pc; + GCfunc *fn; + setstrV(L, L->top++, lj_str_newlit(L, "abort")); + setintV(L->top++, traceno); + /* Find original Lua function call to generate a better error message. */ + frame = J->L->base-1; + pc = J->pc; + while (!isluafunc(frame_func(frame))) { + pc = (frame_iscont(frame) ? frame_contpc(frame) : frame_pc(frame)) - 1; + frame = frame_prev(frame); + } + fn = frame_func(frame); + setfuncV(L, L->top++, fn); + setintV(L->top++, proto_bcpos(funcproto(fn), pc)); + copyTV(L, L->top++, restorestack(L, errobj)); + copyTV(L, L->top++, &J->errinfo); + ); + /* Drop aborted trace after the vmevent (which may still access it). */ + setgcrefnull(J->trace[traceno]); + if (traceno < J->freetrace) + J->freetrace = traceno; + J->cur.traceno = 0; + } + L->top--; /* Remove error object */ + if (e == LJ_TRERR_DOWNREC) + return trace_downrec(J); + else if (e == LJ_TRERR_MCODEAL) + lj_trace_flushall(L); + return 0; +} + +/* Perform pending re-patch of a bytecode instruction. */ +static LJ_AINLINE void trace_pendpatch(jit_State *J, int force) +{ + if (LJ_UNLIKELY(J->patchpc)) { + if (force || J->bcskip == 0) { + *J->patchpc = J->patchins; + J->patchpc = NULL; + } else { + J->bcskip = 0; + } + } +} + +/* State machine for the trace compiler. Protected callback. */ +static TValue *trace_state(lua_State *L, lua_CFunction dummy, void *ud) +{ + jit_State *J = (jit_State *)ud; + UNUSED(dummy); + do { + retry: + switch (J->state) { + case LJ_TRACE_START: + J->state = LJ_TRACE_RECORD; /* trace_start() may change state. */ + trace_start(J); + lj_dispatch_update(J2G(J)); + break; + + case LJ_TRACE_RECORD: + trace_pendpatch(J, 0); + setvmstate(J2G(J), RECORD); + lj_vmevent_send_(L, RECORD, + /* Save/restore tmptv state for trace recorder. */ + TValue savetv = J2G(J)->tmptv; + TValue savetv2 = J2G(J)->tmptv2; + setintV(L->top++, J->cur.traceno); + setfuncV(L, L->top++, J->fn); + setintV(L->top++, J->pt ? (int32_t)proto_bcpos(J->pt, J->pc) : -1); + setintV(L->top++, J->framedepth); + , + J2G(J)->tmptv = savetv; + J2G(J)->tmptv2 = savetv2; + ); + lj_record_ins(J); + break; + + case LJ_TRACE_END: + trace_pendpatch(J, 1); + J->loopref = 0; + if ((J->flags & JIT_F_OPT_LOOP) && + J->cur.link == J->cur.traceno && J->framedepth + J->retdepth == 0) { + setvmstate(J2G(J), OPT); + lj_opt_dce(J); + if (lj_opt_loop(J)) { /* Loop optimization failed? */ + J->cur.link = 0; + J->cur.linktype = LJ_TRLINK_NONE; + J->loopref = J->cur.nins; + J->state = LJ_TRACE_RECORD; /* Try to continue recording. */ + break; + } + J->loopref = J->chain[IR_LOOP]; /* Needed by assembler. */ + } + lj_opt_split(J); + lj_opt_sink(J); + if (!J->loopref) J->cur.snap[J->cur.nsnap-1].count = SNAPCOUNT_DONE; + J->state = LJ_TRACE_ASM; + break; + + case LJ_TRACE_ASM: + setvmstate(J2G(J), ASM); + lj_asm_trace(J, &J->cur); + trace_stop(J); + setvmstate(J2G(J), INTERP); + J->state = LJ_TRACE_IDLE; + lj_dispatch_update(J2G(J)); + return NULL; + + default: /* Trace aborted asynchronously. */ + setintV(L->top++, (int32_t)LJ_TRERR_RECERR); + /* fallthrough */ + case LJ_TRACE_ERR: + trace_pendpatch(J, 1); + if (trace_abort(J)) + goto retry; + setvmstate(J2G(J), INTERP); + J->state = LJ_TRACE_IDLE; + lj_dispatch_update(J2G(J)); + return NULL; + } + } while (J->state > LJ_TRACE_RECORD); + return NULL; +} + +/* -- Event handling ------------------------------------------------------ */ + +/* A bytecode instruction is about to be executed. Record it. */ +void lj_trace_ins(jit_State *J, const BCIns *pc) +{ + /* Note: J->L must already be set. pc is the true bytecode PC here. */ + J->pc = pc; + J->fn = curr_func(J->L); + J->pt = isluafunc(J->fn) ? funcproto(J->fn) : NULL; + while (lj_vm_cpcall(J->L, NULL, (void *)J, trace_state) != 0) + J->state = LJ_TRACE_ERR; +} + +/* A hotcount triggered. Start recording a root trace. */ +void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc) +{ + /* Note: pc is the interpreter bytecode PC here. It's offset by 1. */ + ERRNO_SAVE + /* Reset hotcount. */ + hotcount_set(J2GG(J), pc, J->param[JIT_P_hotloop]*HOTCOUNT_LOOP); + /* Only start a new trace if not recording or inside __gc call or vmevent. */ + if (J->state == LJ_TRACE_IDLE && + !(J2G(J)->hookmask & (HOOK_GC|HOOK_VMEVENT))) { + J->parent = 0; /* Root trace. */ + J->exitno = 0; + J->state = LJ_TRACE_START; + lj_trace_ins(J, pc-1); + } + ERRNO_RESTORE +} + +/* Check for a hot side exit. If yes, start recording a side trace. */ +static void trace_hotside(jit_State *J, const BCIns *pc) +{ + SnapShot *snap = &traceref(J, J->parent)->snap[J->exitno]; + if (!(J2G(J)->hookmask & (HOOK_GC|HOOK_VMEVENT)) && + snap->count != SNAPCOUNT_DONE && + ++snap->count >= J->param[JIT_P_hotexit]) { + lua_assert(J->state == LJ_TRACE_IDLE); + /* J->parent is non-zero for a side trace. */ + J->state = LJ_TRACE_START; + lj_trace_ins(J, pc); + } +} + +/* Tiny struct to pass data to protected call. */ +typedef struct ExitDataCP { + jit_State *J; + void *exptr; /* Pointer to exit state. */ + const BCIns *pc; /* Restart interpreter at this PC. */ +} ExitDataCP; + +/* Need to protect lj_snap_restore because it may throw. */ +static TValue *trace_exit_cp(lua_State *L, lua_CFunction dummy, void *ud) +{ + ExitDataCP *exd = (ExitDataCP *)ud; + cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ + exd->pc = lj_snap_restore(exd->J, exd->exptr); + UNUSED(dummy); + return NULL; +} + +#ifndef LUAJIT_DISABLE_VMEVENT +/* Push all registers from exit state. */ +static void trace_exit_regs(lua_State *L, ExitState *ex) +{ + int32_t i; + setintV(L->top++, RID_NUM_GPR); + setintV(L->top++, RID_NUM_FPR); + for (i = 0; i < RID_NUM_GPR; i++) { + if (sizeof(ex->gpr[i]) == sizeof(int32_t)) + setintV(L->top++, (int32_t)ex->gpr[i]); + else + setnumV(L->top++, (lua_Number)ex->gpr[i]); + } +#if !LJ_SOFTFP + for (i = 0; i < RID_NUM_FPR; i++) { + setnumV(L->top, ex->fpr[i]); + if (LJ_UNLIKELY(tvisnan(L->top))) + setnanV(L->top); + L->top++; + } +#endif +} +#endif + +#ifdef EXITSTATE_PCREG +/* Determine trace number from pc of exit instruction. */ +static TraceNo trace_exit_find(jit_State *J, MCode *pc) +{ + TraceNo traceno; + for (traceno = 1; traceno < J->sizetrace; traceno++) { + GCtrace *T = traceref(J, traceno); + if (T && pc >= T->mcode && pc < (MCode *)((char *)T->mcode + T->szmcode)) + return traceno; + } + lua_assert(0); + return 0; +} +#endif + +/* A trace exited. Restore interpreter state. */ +int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr) +{ + ERRNO_SAVE + lua_State *L = J->L; + ExitState *ex = (ExitState *)exptr; + ExitDataCP exd; + int errcode; + const BCIns *pc; + void *cf; + GCtrace *T; +#ifdef EXITSTATE_PCREG + J->parent = trace_exit_find(J, (MCode *)(intptr_t)ex->gpr[EXITSTATE_PCREG]); +#endif + T = traceref(J, J->parent); UNUSED(T); +#ifdef EXITSTATE_CHECKEXIT + if (J->exitno == T->nsnap) { /* Treat stack check like a parent exit. */ + lua_assert(T->root != 0); + J->exitno = T->ir[REF_BASE].op2; + J->parent = T->ir[REF_BASE].op1; + T = traceref(J, J->parent); + } +#endif + lua_assert(T != NULL && J->exitno < T->nsnap); + exd.J = J; + exd.exptr = exptr; + errcode = lj_vm_cpcall(L, NULL, &exd, trace_exit_cp); + if (errcode) + return -errcode; /* Return negated error code. */ + + lj_vmevent_send(L, TEXIT, + lj_state_checkstack(L, 4+RID_NUM_GPR+RID_NUM_FPR+LUA_MINSTACK); + setintV(L->top++, J->parent); + setintV(L->top++, J->exitno); + trace_exit_regs(L, ex); + ); + + pc = exd.pc; + cf = cframe_raw(L->cframe); + setcframe_pc(cf, pc); + if (G(L)->gc.state == GCSatomic || G(L)->gc.state == GCSfinalize) { + if (!(G(L)->hookmask & HOOK_GC)) + lj_gc_step(L); /* Exited because of GC: drive GC forward. */ + } else { + trace_hotside(J, pc); + } + if (bc_op(*pc) == BC_JLOOP) { + BCIns *retpc = &traceref(J, bc_d(*pc))->startins; + if (bc_isret(bc_op(*retpc))) { + if (J->state == LJ_TRACE_RECORD) { + J->patchins = *pc; + J->patchpc = (BCIns *)pc; + *J->patchpc = *retpc; + J->bcskip = 1; + } else { + pc = retpc; + setcframe_pc(cf, pc); + } + } + } + /* Return MULTRES or 0. */ + ERRNO_RESTORE + switch (bc_op(*pc)) { + case BC_CALLM: case BC_CALLMT: + return (int)((BCReg)(L->top - L->base) - bc_a(*pc) - bc_c(*pc)); + case BC_RETM: + return (int)((BCReg)(L->top - L->base) + 1 - bc_a(*pc) - bc_d(*pc)); + case BC_TSETM: + return (int)((BCReg)(L->top - L->base) + 1 - bc_a(*pc)); + default: + if (bc_op(*pc) >= BC_FUNCF) + return (int)((BCReg)(L->top - L->base) + 1); + return 0; + } +} + +#endif + +``` + +`include/luajit-2.0.5/src/lj_trace.h`: + +```h +/* +** Trace management. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_TRACE_H +#define _LJ_TRACE_H + +#include "lj_obj.h" + +#if LJ_HASJIT +#include "lj_jit.h" +#include "lj_dispatch.h" + +/* Trace errors. */ +typedef enum { +#define TREDEF(name, msg) LJ_TRERR_##name, +#include "lj_traceerr.h" + LJ_TRERR__MAX +} TraceError; + +LJ_FUNC_NORET void lj_trace_err(jit_State *J, TraceError e); +LJ_FUNC_NORET void lj_trace_err_info(jit_State *J, TraceError e); + +/* Trace management. */ +LJ_FUNC void LJ_FASTCALL lj_trace_free(global_State *g, GCtrace *T); +LJ_FUNC void lj_trace_reenableproto(GCproto *pt); +LJ_FUNC void lj_trace_flushproto(global_State *g, GCproto *pt); +LJ_FUNC void lj_trace_flush(jit_State *J, TraceNo traceno); +LJ_FUNC int lj_trace_flushall(lua_State *L); +LJ_FUNC void lj_trace_initstate(global_State *g); +LJ_FUNC void lj_trace_freestate(global_State *g); + +/* Event handling. */ +LJ_FUNC void lj_trace_ins(jit_State *J, const BCIns *pc); +LJ_FUNCA void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc); +LJ_FUNCA int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr); + +/* Signal asynchronous abort of trace or end of trace. */ +#define lj_trace_abort(g) (G2J(g)->state &= ~LJ_TRACE_ACTIVE) +#define lj_trace_end(J) (J->state = LJ_TRACE_END) + +#else + +#define lj_trace_flushall(L) (UNUSED(L), 0) +#define lj_trace_initstate(g) UNUSED(g) +#define lj_trace_freestate(g) UNUSED(g) +#define lj_trace_abort(g) UNUSED(g) +#define lj_trace_end(J) UNUSED(J) + +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_traceerr.h`: + +```h +/* +** Trace compiler error messages. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* This file may be included multiple times with different TREDEF macros. */ + +/* Recording. */ +TREDEF(RECERR, "error thrown or hook called during recording") +TREDEF(TRACEOV, "trace too long") +TREDEF(STACKOV, "trace too deep") +TREDEF(SNAPOV, "too many snapshots") +TREDEF(BLACKL, "blacklisted") +TREDEF(NYIBC, "NYI: bytecode %d") + +/* Recording loop ops. */ +TREDEF(LLEAVE, "leaving loop in root trace") +TREDEF(LINNER, "inner loop in root trace") +TREDEF(LUNROLL, "loop unroll limit reached") + +/* Recording calls/returns. */ +TREDEF(BADTYPE, "bad argument type") +TREDEF(CJITOFF, "JIT compilation disabled for function") +TREDEF(CUNROLL, "call unroll limit reached") +TREDEF(DOWNREC, "down-recursion, restarting") +TREDEF(NYICF, "NYI: C function %s") +TREDEF(NYIFF, "NYI: FastFunc %s") +TREDEF(NYIFFU, "NYI: unsupported variant of FastFunc %s") +TREDEF(NYIRETL, "NYI: return to lower frame") + +/* Recording indexed load/store. */ +TREDEF(STORENN, "store with nil or NaN key") +TREDEF(NOMM, "missing metamethod") +TREDEF(IDXLOOP, "looping index lookup") +TREDEF(NYITMIX, "NYI: mixed sparse/dense table") + +/* Recording C data operations. */ +TREDEF(NOCACHE, "symbol not in cache") +TREDEF(NYICONV, "NYI: unsupported C type conversion") +TREDEF(NYICALL, "NYI: unsupported C function type") + +/* Optimizations. */ +TREDEF(GFAIL, "guard would always fail") +TREDEF(PHIOV, "too many PHIs") +TREDEF(TYPEINS, "persistent type instability") + +/* Assembler. */ +TREDEF(MCODEAL, "failed to allocate mcode memory") +TREDEF(MCODEOV, "machine code too long") +TREDEF(MCODELM, "hit mcode limit (retrying)") +TREDEF(SPILLOV, "too many spill slots") +TREDEF(BADRA, "inconsistent register allocation") +TREDEF(NYIIR, "NYI: cannot assemble IR instruction %d") +TREDEF(NYIPHI, "NYI: PHI shuffling too complex") +TREDEF(NYICOAL, "NYI: register coalescing too complex") + +#undef TREDEF + +/* Detecting unused error messages: + awk -F, '/^TREDEF/ { gsub(/TREDEF./, ""); printf "grep -q LJ_TRERR_%s *.[ch] || echo %s\n", $1, $1}' lj_traceerr.h | sh +*/ + +``` + +`include/luajit-2.0.5/src/lj_udata.c`: + +```c +/* +** Userdata handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_udata_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_udata.h" + +GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env) +{ + GCudata *ud = lj_mem_newt(L, sizeof(GCudata) + sz, GCudata); + global_State *g = G(L); + newwhite(g, ud); /* Not finalized. */ + ud->gct = ~LJ_TUDATA; + ud->udtype = UDTYPE_USERDATA; + ud->len = sz; + /* NOBARRIER: The GCudata is new (marked white). */ + setgcrefnull(ud->metatable); + setgcref(ud->env, obj2gco(env)); + /* Chain to userdata list (after main thread). */ + setgcrefr(ud->nextgc, mainthread(g)->nextgc); + setgcref(mainthread(g)->nextgc, obj2gco(ud)); + return ud; +} + +void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud) +{ + lj_mem_free(g, ud, sizeudata(ud)); +} + + +``` + +`include/luajit-2.0.5/src/lj_udata.h`: + +```h +/* +** Userdata handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_UDATA_H +#define _LJ_UDATA_H + +#include "lj_obj.h" + +LJ_FUNC GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env); +LJ_FUNC void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud); + +#endif + +``` + +`include/luajit-2.0.5/src/lj_vm.h`: + +```h +/* +** Assembler VM interface definitions. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_VM_H +#define _LJ_VM_H + +#include "lj_obj.h" + +/* Entry points for ASM parts of VM. */ +LJ_ASMF void lj_vm_call(lua_State *L, TValue *base, int nres1); +LJ_ASMF int lj_vm_pcall(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); +typedef TValue *(*lua_CPFunction)(lua_State *L, lua_CFunction func, void *ud); +LJ_ASMF int lj_vm_cpcall(lua_State *L, lua_CFunction func, void *ud, + lua_CPFunction cp); +LJ_ASMF int lj_vm_resume(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); +LJ_ASMF_NORET void LJ_FASTCALL lj_vm_unwind_c(void *cframe, int errcode); +LJ_ASMF_NORET void LJ_FASTCALL lj_vm_unwind_ff(void *cframe); +LJ_ASMF void lj_vm_unwind_c_eh(void); +LJ_ASMF void lj_vm_unwind_ff_eh(void); +#if LJ_TARGET_X86ORX64 +LJ_ASMF void lj_vm_unwind_rethrow(void); +#endif + +/* Miscellaneous functions. */ +#if LJ_TARGET_X86ORX64 +LJ_ASMF int lj_vm_cpuid(uint32_t f, uint32_t res[4]); +#endif +#if LJ_TARGET_PPC +void lj_vm_cachesync(void *start, void *end); +#endif +LJ_ASMF double lj_vm_foldarith(double x, double y, int op); +#if LJ_HASJIT +LJ_ASMF double lj_vm_foldfpm(double x, int op); +#endif +#if !LJ_ARCH_HASFPU +/* Declared in lj_obj.h: LJ_ASMF int32_t lj_vm_tobit(double x); */ +#endif + +/* Dispatch targets for recording and hooks. */ +LJ_ASMF void lj_vm_record(void); +LJ_ASMF void lj_vm_inshook(void); +LJ_ASMF void lj_vm_rethook(void); +LJ_ASMF void lj_vm_callhook(void); + +/* Trace exit handling. */ +LJ_ASMF void lj_vm_exit_handler(void); +LJ_ASMF void lj_vm_exit_interp(void); + +/* Internal math helper functions. */ +#if LJ_TARGET_X86ORX64 || LJ_TARGET_PPC +#define lj_vm_floor floor +#define lj_vm_ceil ceil +#else +LJ_ASMF double lj_vm_floor(double); +LJ_ASMF double lj_vm_ceil(double); +#if LJ_TARGET_ARM +LJ_ASMF double lj_vm_floor_sf(double); +LJ_ASMF double lj_vm_ceil_sf(double); +#endif +#endif +#if defined(LUAJIT_NO_LOG2) || LJ_TARGET_X86ORX64 +LJ_ASMF double lj_vm_log2(double); +#else +#define lj_vm_log2 log2 +#endif + +#if LJ_HASJIT +#if LJ_TARGET_X86ORX64 +LJ_ASMF void lj_vm_floor_sse(void); +LJ_ASMF void lj_vm_ceil_sse(void); +LJ_ASMF void lj_vm_trunc_sse(void); +LJ_ASMF void lj_vm_exp_x87(void); +LJ_ASMF void lj_vm_exp2_x87(void); +LJ_ASMF void lj_vm_pow_sse(void); +LJ_ASMF void lj_vm_powi_sse(void); +#else +#if LJ_TARGET_PPC +#define lj_vm_trunc trunc +#else +LJ_ASMF double lj_vm_trunc(double); +#if LJ_TARGET_ARM +LJ_ASMF double lj_vm_trunc_sf(double); +#endif +#endif +LJ_ASMF double lj_vm_powi(double, int32_t); +#ifdef LUAJIT_NO_EXP2 +LJ_ASMF double lj_vm_exp2(double); +#else +#define lj_vm_exp2 exp2 +#endif +#endif +LJ_ASMF int32_t LJ_FASTCALL lj_vm_modi(int32_t, int32_t); +#if LJ_HASFFI +LJ_ASMF int lj_vm_errno(void); +#endif +#endif + +/* Continuations for metamethods. */ +LJ_ASMF void lj_cont_cat(void); /* Continue with concatenation. */ +LJ_ASMF void lj_cont_ra(void); /* Store result in RA from instruction. */ +LJ_ASMF void lj_cont_nop(void); /* Do nothing, just continue execution. */ +LJ_ASMF void lj_cont_condt(void); /* Branch if result is true. */ +LJ_ASMF void lj_cont_condf(void); /* Branch if result is false. */ +LJ_ASMF void lj_cont_hook(void); /* Continue from hook yield. */ + +enum { LJ_CONT_TAILCALL, LJ_CONT_FFI_CALLBACK }; /* Special continuations. */ + +/* Start of the ASM code. */ +LJ_ASMF char lj_vm_asm_begin[]; + +/* Bytecode offsets are relative to lj_vm_asm_begin. */ +#define makeasmfunc(ofs) ((ASMFunction)(lj_vm_asm_begin + (ofs))) + +#endif + +``` + +`include/luajit-2.0.5/src/lj_vmevent.c`: + +```c +/* +** VM event handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include + +#define lj_vmevent_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_state.h" +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "lj_vmevent.h" + +ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev) +{ + global_State *g = G(L); + GCstr *s = lj_str_newlit(L, LJ_VMEVENTS_REGKEY); + cTValue *tv = lj_tab_getstr(tabV(registry(L)), s); + if (tvistab(tv)) { + int hash = VMEVENT_HASH(ev); + tv = lj_tab_getint(tabV(tv), hash); + if (tv && tvisfunc(tv)) { + lj_state_checkstack(L, LUA_MINSTACK); + setfuncV(L, L->top++, funcV(tv)); + return savestack(L, L->top); + } + } + g->vmevmask &= ~VMEVENT_MASK(ev); /* No handler: cache this fact. */ + return 0; +} + +void lj_vmevent_call(lua_State *L, ptrdiff_t argbase) +{ + global_State *g = G(L); + uint8_t oldmask = g->vmevmask; + uint8_t oldh = hook_save(g); + int status; + g->vmevmask = 0; /* Disable all events. */ + hook_vmevent(g); + status = lj_vm_pcall(L, restorestack(L, argbase), 0+1, 0); + if (LJ_UNLIKELY(status)) { + /* Really shouldn't use stderr here, but where else to complain? */ + L->top--; + fputs("VM handler failed: ", stderr); + fputs(tvisstr(L->top) ? strVdata(L->top) : "?", stderr); + fputc('\n', stderr); + } + hook_restore(g, oldh); + if (g->vmevmask != VMEVENT_NOCACHE) + g->vmevmask = oldmask; /* Restore event mask, but not if not modified. */ +} + + +``` + +`include/luajit-2.0.5/src/lj_vmevent.h`: + +```h +/* +** VM event handling. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_VMEVENT_H +#define _LJ_VMEVENT_H + +#include "lj_obj.h" + +/* Registry key for VM event handler table. */ +#define LJ_VMEVENTS_REGKEY "_VMEVENTS" +#define LJ_VMEVENTS_HSIZE 4 + +#define VMEVENT_MASK(ev) ((uint8_t)1 << ((int)(ev) & 7)) +#define VMEVENT_HASH(ev) ((int)(ev) & ~7) +#define VMEVENT_HASHIDX(h) ((int)(h) << 3) +#define VMEVENT_NOCACHE 255 + +#define VMEVENT_DEF(name, hash) \ + LJ_VMEVENT_##name##_, \ + LJ_VMEVENT_##name = ((LJ_VMEVENT_##name##_) & 7)|((hash) << 3) + +/* VM event IDs. */ +typedef enum { + VMEVENT_DEF(BC, 0x00003883), + VMEVENT_DEF(TRACE, 0xb2d91467), + VMEVENT_DEF(RECORD, 0x9284bf4f), + VMEVENT_DEF(TEXIT, 0xb29df2b0), + LJ_VMEVENT__MAX +} VMEvent; + +#ifdef LUAJIT_DISABLE_VMEVENT +#define lj_vmevent_send(L, ev, args) UNUSED(L) +#define lj_vmevent_send_(L, ev, args, post) UNUSED(L) +#else +#define lj_vmevent_send(L, ev, args) \ + if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ + ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \ + if (argbase) { \ + args \ + lj_vmevent_call(L, argbase); \ + } \ + } +#define lj_vmevent_send_(L, ev, args, post) \ + if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ + ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \ + if (argbase) { \ + args \ + lj_vmevent_call(L, argbase); \ + post \ + } \ + } + +LJ_FUNC ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev); +LJ_FUNC void lj_vmevent_call(lua_State *L, ptrdiff_t argbase); +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/lj_vmmath.c`: + +```c +/* +** Math helper functions for assembler VM. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_vmmath_c +#define LUA_CORE + +#include +#include + +#include "lj_obj.h" +#include "lj_ir.h" +#include "lj_vm.h" + +/* -- Helper functions for generated machine code ------------------------- */ + +#if LJ_TARGET_X86ORX64 +/* Wrapper functions to avoid linker issues on OSX. */ +LJ_FUNCA double lj_vm_sinh(double x) { return sinh(x); } +LJ_FUNCA double lj_vm_cosh(double x) { return cosh(x); } +LJ_FUNCA double lj_vm_tanh(double x) { return tanh(x); } +#endif + +#if !LJ_TARGET_X86ORX64 +double lj_vm_foldarith(double x, double y, int op) +{ + switch (op) { + case IR_ADD - IR_ADD: return x+y; break; + case IR_SUB - IR_ADD: return x-y; break; + case IR_MUL - IR_ADD: return x*y; break; + case IR_DIV - IR_ADD: return x/y; break; + case IR_MOD - IR_ADD: return x-lj_vm_floor(x/y)*y; break; + case IR_POW - IR_ADD: return pow(x, y); break; + case IR_NEG - IR_ADD: return -x; break; + case IR_ABS - IR_ADD: return fabs(x); break; +#if LJ_HASJIT + case IR_ATAN2 - IR_ADD: return atan2(x, y); break; + case IR_LDEXP - IR_ADD: return ldexp(x, (int)y); break; + case IR_MIN - IR_ADD: return x > y ? y : x; break; + case IR_MAX - IR_ADD: return x < y ? y : x; break; +#endif + default: return x; + } +} +#endif + +#if LJ_HASJIT + +#ifdef LUAJIT_NO_LOG2 +double lj_vm_log2(double a) +{ + return log(a) * 1.4426950408889634074; +} +#endif + +#ifdef LUAJIT_NO_EXP2 +double lj_vm_exp2(double a) +{ + return exp(a * 0.6931471805599453); +} +#endif + +#if !(LJ_TARGET_ARM || LJ_TARGET_PPC) +int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b) +{ + uint32_t y, ua, ub; + lua_assert(b != 0); /* This must be checked before using this function. */ + ua = a < 0 ? (uint32_t)-a : (uint32_t)a; + ub = b < 0 ? (uint32_t)-b : (uint32_t)b; + y = ua % ub; + if (y != 0 && (a^b) < 0) y = y - ub; + if (((int32_t)y^b) < 0) y = (uint32_t)-(int32_t)y; + return (int32_t)y; +} +#endif + +#if !LJ_TARGET_X86ORX64 +/* Unsigned x^k. */ +static double lj_vm_powui(double x, uint32_t k) +{ + double y; + lua_assert(k != 0); + for (; (k & 1) == 0; k >>= 1) x *= x; + y = x; + if ((k >>= 1) != 0) { + for (;;) { + x *= x; + if (k == 1) break; + if (k & 1) y *= x; + k >>= 1; + } + y *= x; + } + return y; +} + +/* Signed x^k. */ +double lj_vm_powi(double x, int32_t k) +{ + if (k > 1) + return lj_vm_powui(x, (uint32_t)k); + else if (k == 1) + return x; + else if (k == 0) + return 1.0; + else + return 1.0 / lj_vm_powui(x, (uint32_t)-k); +} + +/* Computes fpm(x) for extended math functions. */ +double lj_vm_foldfpm(double x, int fpm) +{ + switch (fpm) { + case IRFPM_FLOOR: return lj_vm_floor(x); + case IRFPM_CEIL: return lj_vm_ceil(x); + case IRFPM_TRUNC: return lj_vm_trunc(x); + case IRFPM_SQRT: return sqrt(x); + case IRFPM_EXP: return exp(x); + case IRFPM_EXP2: return lj_vm_exp2(x); + case IRFPM_LOG: return log(x); + case IRFPM_LOG2: return lj_vm_log2(x); + case IRFPM_LOG10: return log10(x); + case IRFPM_SIN: return sin(x); + case IRFPM_COS: return cos(x); + case IRFPM_TAN: return tan(x); + default: lua_assert(0); + } + return 0; +} +#endif + +#if LJ_HASFFI +int lj_vm_errno(void) +{ + return errno; +} +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/ljamalg.c`: + +```c +/* +** LuaJIT core and libraries amalgamation. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* ++--------------------------------------------------------------------------+ +| WARNING: Compiling the amalgamation needs a lot of virtual memory | +| (around 300 MB with GCC 4.x)! If you don't have enough physical memory | +| your machine will start swapping to disk and the compile will not finish | +| within a reasonable amount of time. | +| So either compile on a bigger machine or use the non-amalgamated build. | ++--------------------------------------------------------------------------+ +*/ + +#define ljamalg_c +#define LUA_CORE + +/* To get the mremap prototype. Must be defined before any system includes. */ +#if defined(__linux__) && !defined(_GNU_SOURCE) +#define _GNU_SOURCE +#endif + +#ifndef WINVER +#define WINVER 0x0501 +#endif + +#include "lua.h" +#include "lauxlib.h" + +#include "lj_gc.c" +#include "lj_err.c" +#include "lj_char.c" +#include "lj_bc.c" +#include "lj_obj.c" +#include "lj_str.c" +#include "lj_tab.c" +#include "lj_func.c" +#include "lj_udata.c" +#include "lj_meta.c" +#include "lj_debug.c" +#include "lj_state.c" +#include "lj_dispatch.c" +#include "lj_vmevent.c" +#include "lj_vmmath.c" +#include "lj_strscan.c" +#include "lj_api.c" +#include "lj_lex.c" +#include "lj_parse.c" +#include "lj_bcread.c" +#include "lj_bcwrite.c" +#include "lj_load.c" +#include "lj_ctype.c" +#include "lj_cdata.c" +#include "lj_cconv.c" +#include "lj_ccall.c" +#include "lj_ccallback.c" +#include "lj_carith.c" +#include "lj_clib.c" +#include "lj_cparse.c" +#include "lj_lib.c" +#include "lj_ir.c" +#include "lj_opt_mem.c" +#include "lj_opt_fold.c" +#include "lj_opt_narrow.c" +#include "lj_opt_dce.c" +#include "lj_opt_loop.c" +#include "lj_opt_split.c" +#include "lj_opt_sink.c" +#include "lj_mcode.c" +#include "lj_snap.c" +#include "lj_record.c" +#include "lj_crecord.c" +#include "lj_ffrecord.c" +#include "lj_asm.c" +#include "lj_trace.c" +#include "lj_gdbjit.c" +#include "lj_alloc.c" + +#include "lib_aux.c" +#include "lib_base.c" +#include "lib_math.c" +#include "lib_string.c" +#include "lib_table.c" +#include "lib_io.c" +#include "lib_os.c" +#include "lib_package.c" +#include "lib_debug.c" +#include "lib_bit.c" +#include "lib_jit.c" +#include "lib_ffi.c" +#include "lib_init.c" + + +``` + +`include/luajit-2.0.5/src/lua.h`: + +```h +/* +** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ +** Lua - An Extensible Extension Language +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) +** See Copyright Notice at the end of this file +*/ + + +#ifndef lua_h +#define lua_h + +#include +#include + + +#include "luaconf.h" + + +#define LUA_VERSION "Lua 5.1" +#define LUA_RELEASE "Lua 5.1.4" +#define LUA_VERSION_NUM 501 +#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" + + +/* mark for precompiled code (`Lua') */ +#define LUA_SIGNATURE "\033Lua" + +/* option for multiple returns in `lua_pcall' and `lua_call' */ +#define LUA_MULTRET (-1) + + +/* +** pseudo-indices +*/ +#define LUA_REGISTRYINDEX (-10000) +#define LUA_ENVIRONINDEX (-10001) +#define LUA_GLOBALSINDEX (-10002) +#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) + + +/* thread status; 0 is OK */ +#define LUA_YIELD 1 +#define LUA_ERRRUN 2 +#define LUA_ERRSYNTAX 3 +#define LUA_ERRMEM 4 +#define LUA_ERRERR 5 + + +typedef struct lua_State lua_State; + +typedef int (*lua_CFunction) (lua_State *L); + + +/* +** functions that read/write blocks when loading/dumping Lua chunks +*/ +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); + +typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); + + +/* +** prototype for memory-allocation functions +*/ +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); + + +/* +** basic types +*/ +#define LUA_TNONE (-1) + +#define LUA_TNIL 0 +#define LUA_TBOOLEAN 1 +#define LUA_TLIGHTUSERDATA 2 +#define LUA_TNUMBER 3 +#define LUA_TSTRING 4 +#define LUA_TTABLE 5 +#define LUA_TFUNCTION 6 +#define LUA_TUSERDATA 7 +#define LUA_TTHREAD 8 + + + +/* minimum Lua stack available to a C function */ +#define LUA_MINSTACK 20 + + +/* +** generic extra include file +*/ +#if defined(LUA_USER_H) +#include LUA_USER_H +#endif + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + + + +/* +** state manipulation +*/ +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); +LUA_API void (lua_close) (lua_State *L); +LUA_API lua_State *(lua_newthread) (lua_State *L); + +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + + +/* +** basic stack manipulation +*/ +LUA_API int (lua_gettop) (lua_State *L); +LUA_API void (lua_settop) (lua_State *L, int idx); +LUA_API void (lua_pushvalue) (lua_State *L, int idx); +LUA_API void (lua_remove) (lua_State *L, int idx); +LUA_API void (lua_insert) (lua_State *L, int idx); +LUA_API void (lua_replace) (lua_State *L, int idx); +LUA_API int (lua_checkstack) (lua_State *L, int sz); + +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); + + +/* +** access functions (stack -> C) +*/ + +LUA_API int (lua_isnumber) (lua_State *L, int idx); +LUA_API int (lua_isstring) (lua_State *L, int idx); +LUA_API int (lua_iscfunction) (lua_State *L, int idx); +LUA_API int (lua_isuserdata) (lua_State *L, int idx); +LUA_API int (lua_type) (lua_State *L, int idx); +LUA_API const char *(lua_typename) (lua_State *L, int tp); + +LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); + +LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); +LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); +LUA_API int (lua_toboolean) (lua_State *L, int idx); +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); +LUA_API size_t (lua_objlen) (lua_State *L, int idx); +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); +LUA_API void *(lua_touserdata) (lua_State *L, int idx); +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); +LUA_API const void *(lua_topointer) (lua_State *L, int idx); + + +/* +** push functions (C -> stack) +*/ +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); +LUA_API void (lua_pushstring) (lua_State *L, const char *s); +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, + va_list argp); +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +LUA_API void (lua_pushboolean) (lua_State *L, int b); +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); +LUA_API int (lua_pushthread) (lua_State *L); + + +/* +** get functions (Lua -> stack) +*/ +LUA_API void (lua_gettable) (lua_State *L, int idx); +LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawget) (lua_State *L, int idx); +LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); +LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); +LUA_API void (lua_getfenv) (lua_State *L, int idx); + + +/* +** set functions (stack -> Lua) +*/ +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API int (lua_setfenv) (lua_State *L, int idx); + + +/* +** `load' and `call' functions (load and run Lua code) +*/ +LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); +LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); +LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname); + +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); + + +/* +** coroutine functions +*/ +LUA_API int (lua_yield) (lua_State *L, int nresults); +LUA_API int (lua_resume) (lua_State *L, int narg); +LUA_API int (lua_status) (lua_State *L); + +/* +** garbage-collection function and options +*/ + +#define LUA_GCSTOP 0 +#define LUA_GCRESTART 1 +#define LUA_GCCOLLECT 2 +#define LUA_GCCOUNT 3 +#define LUA_GCCOUNTB 4 +#define LUA_GCSTEP 5 +#define LUA_GCSETPAUSE 6 +#define LUA_GCSETSTEPMUL 7 + +LUA_API int (lua_gc) (lua_State *L, int what, int data); + + +/* +** miscellaneous functions +*/ + +LUA_API int (lua_error) (lua_State *L); + +LUA_API int (lua_next) (lua_State *L, int idx); + +LUA_API void (lua_concat) (lua_State *L, int n); + +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define lua_pop(L,n) lua_settop(L, -(n)-1) + +#define lua_newtable(L) lua_createtable(L, 0, 0) + +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) + +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) + +#define lua_strlen(L,i) lua_objlen(L, (i)) + +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) + +#define lua_pushliteral(L, s) \ + lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) + +#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) +#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) + +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) + + + +/* +** compatibility macros and functions +*/ + +#define lua_open() luaL_newstate() + +#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) + +#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) + +#define lua_Chunkreader lua_Reader +#define lua_Chunkwriter lua_Writer + + +/* hack */ +LUA_API void lua_setlevel (lua_State *from, lua_State *to); + + +/* +** {====================================================================== +** Debug API +** ======================================================================= +*/ + + +/* +** Event codes +*/ +#define LUA_HOOKCALL 0 +#define LUA_HOOKRET 1 +#define LUA_HOOKLINE 2 +#define LUA_HOOKCOUNT 3 +#define LUA_HOOKTAILRET 4 + + +/* +** Event masks +*/ +#define LUA_MASKCALL (1 << LUA_HOOKCALL) +#define LUA_MASKRET (1 << LUA_HOOKRET) +#define LUA_MASKLINE (1 << LUA_HOOKLINE) +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) + +typedef struct lua_Debug lua_Debug; /* activation record */ + + +/* Functions to be called by the debuger in specific events */ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook lua_gethook (lua_State *L); +LUA_API int lua_gethookmask (lua_State *L); +LUA_API int lua_gethookcount (lua_State *L); + +/* From Lua 5.2. */ +LUA_API void *lua_upvalueid (lua_State *L, int idx, int n); +LUA_API void lua_upvaluejoin (lua_State *L, int idx1, int n1, int idx2, int n2); +LUA_API int lua_loadx (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname, const char *mode); + + +struct lua_Debug { + int event; + const char *name; /* (n) */ + const char *namewhat; /* (n) `global', `local', `field', `method' */ + const char *what; /* (S) `Lua', `C', `main', `tail' */ + const char *source; /* (S) */ + int currentline; /* (l) */ + int nups; /* (u) number of upvalues */ + int linedefined; /* (S) */ + int lastlinedefined; /* (S) */ + char short_src[LUA_IDSIZE]; /* (S) */ + /* private part */ + int i_ci; /* active function */ +}; + +/* }====================================================================== */ + + +/****************************************************************************** +* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + + +#endif + +``` + +`include/luajit-2.0.5/src/lua.hpp`: + +```hpp +// C++ wrapper for LuaJIT header files. + +extern "C" { +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "luajit.h" +} + + +``` + +`include/luajit-2.0.5/src/luaconf.h`: + +```h +/* +** Configuration header. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef luaconf_h +#define luaconf_h + +#ifndef WINVER +#define WINVER 0x0501 +#endif +#include +#include + +/* Default path for loading Lua and C modules with require(). */ +#if defined(_WIN32) +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_PATH_DEFAULT \ + ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" +#define LUA_CPATH_DEFAULT \ + ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" +#else +/* +** Note to distribution maintainers: do NOT patch the following lines! +** Please read ../doc/install.html#distro and pass PREFIX=/usr instead. +*/ +#ifndef LUA_MULTILIB +#define LUA_MULTILIB "lib" +#endif +#ifndef LUA_LMULTILIB +#define LUA_LMULTILIB "lib" +#endif +#define LUA_LROOT "/usr/local" +#define LUA_LUADIR "/lua/5.1/" +#define LUA_LJDIR "/luajit-2.0.5/" + +#ifdef LUA_ROOT +#define LUA_JROOT LUA_ROOT +#define LUA_RLDIR LUA_ROOT "/share" LUA_LUADIR +#define LUA_RCDIR LUA_ROOT "/" LUA_MULTILIB LUA_LUADIR +#define LUA_RLPATH ";" LUA_RLDIR "?.lua;" LUA_RLDIR "?/init.lua" +#define LUA_RCPATH ";" LUA_RCDIR "?.so" +#else +#define LUA_JROOT LUA_LROOT +#define LUA_RLPATH +#define LUA_RCPATH +#endif + +#define LUA_JPATH ";" LUA_JROOT "/share" LUA_LJDIR "?.lua" +#define LUA_LLDIR LUA_LROOT "/share" LUA_LUADIR +#define LUA_LCDIR LUA_LROOT "/" LUA_LMULTILIB LUA_LUADIR +#define LUA_LLPATH ";" LUA_LLDIR "?.lua;" LUA_LLDIR "?/init.lua" +#define LUA_LCPATH1 ";" LUA_LCDIR "?.so" +#define LUA_LCPATH2 ";" LUA_LCDIR "loadall.so" + +#define LUA_PATH_DEFAULT "./?.lua" LUA_JPATH LUA_LLPATH LUA_RLPATH +#define LUA_CPATH_DEFAULT "./?.so" LUA_LCPATH1 LUA_RCPATH LUA_LCPATH2 +#endif + +/* Environment variable names for path overrides and initialization code. */ +#define LUA_PATH "LUA_PATH" +#define LUA_CPATH "LUA_CPATH" +#define LUA_INIT "LUA_INIT" + +/* Special file system characters. */ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif +#define LUA_PATHSEP ";" +#define LUA_PATH_MARK "?" +#define LUA_EXECDIR "!" +#define LUA_IGMARK "-" +#define LUA_PATH_CONFIG \ + LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" \ + LUA_EXECDIR "\n" LUA_IGMARK + +/* Quoting in error messages. */ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + +/* Various tunables. */ +#define LUAI_MAXSTACK 65500 /* Max. # of stack slots for a thread (<64K). */ +#define LUAI_MAXCSTACK 8000 /* Max. # of stack slots for a C func (<10K). */ +#define LUAI_GCPAUSE 200 /* Pause GC until memory is at 200%. */ +#define LUAI_GCMUL 200 /* Run GC at 200% of allocation speed. */ +#define LUA_MAXCAPTURES 32 /* Max. pattern captures. */ + +/* Compatibility with older library function names. */ +#define LUA_COMPAT_MOD /* OLD: math.mod, NEW: math.fmod */ +#define LUA_COMPAT_GFIND /* OLD: string.gfind, NEW: string.gmatch */ + +/* Configuration for the frontend (the luajit executable). */ +#if defined(luajit_c) +#define LUA_PROGNAME "luajit" /* Fallback frontend name. */ +#define LUA_PROMPT "> " /* Interactive prompt. */ +#define LUA_PROMPT2 ">> " /* Continuation prompt. */ +#define LUA_MAXINPUT 512 /* Max. input line length. */ +#endif + +/* Note: changing the following defines breaks the Lua 5.1 ABI. */ +#define LUA_INTEGER ptrdiff_t +#define LUA_IDSIZE 60 /* Size of lua_Debug.short_src. */ +/* +** Size of lauxlib and io.* on-stack buffers. Weird workaround to avoid using +** unreasonable amounts of stack space, but still retain ABI compatibility. +** Blame Lua for depending on BUFSIZ in the ABI, blame **** for wrecking it. +*/ +#define LUAL_BUFFERSIZE (BUFSIZ > 16384 ? 8192 : BUFSIZ) + +/* The following defines are here only for compatibility with luaconf.h +** from the standard Lua distribution. They must not be changed for LuaJIT. +*/ +#define LUA_NUMBER_DOUBLE +#define LUA_NUMBER double +#define LUAI_UACNUMBER double +#define LUA_NUMBER_SCAN "%lf" +#define LUA_NUMBER_FMT "%.14g" +#define lua_number2str(s, n) sprintf((s), LUA_NUMBER_FMT, (n)) +#define LUAI_MAXNUMBER2STR 32 +#define LUA_INTFRMLEN "l" +#define LUA_INTFRM_T long + +/* Linkage of public API functions. */ +#if defined(LUA_BUILD_AS_DLL) +#if defined(LUA_CORE) || defined(LUA_LIB) +#define LUA_API __declspec(dllexport) +#else +#define LUA_API __declspec(dllimport) +#endif +#else +#define LUA_API extern +#endif + +#define LUALIB_API LUA_API + +/* Support for internal assertions. */ +#if defined(LUA_USE_ASSERT) || defined(LUA_USE_APICHECK) +#include +#endif +#ifdef LUA_USE_ASSERT +#define lua_assert(x) assert(x) +#endif +#ifdef LUA_USE_APICHECK +#define luai_apicheck(L, o) { (void)L; assert(o); } +#else +#define luai_apicheck(L, o) { (void)L; } +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/luajit.c`: + +```c +/* +** LuaJIT frontend. Runs commands, scripts, read-eval-print (REPL) etc. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#include +#include +#include + +#define luajit_c + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "luajit.h" + +#include "lj_arch.h" + +#if LJ_TARGET_POSIX +#include +#define lua_stdin_is_tty() isatty(0) +#elif LJ_TARGET_WINDOWS +#include +#ifdef __BORLANDC__ +#define lua_stdin_is_tty() isatty(_fileno(stdin)) +#else +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) +#endif +#else +#define lua_stdin_is_tty() 1 +#endif + +#if !LJ_TARGET_CONSOLE +#include +#endif + +static lua_State *globalL = NULL; +static const char *progname = LUA_PROGNAME; + +#if !LJ_TARGET_CONSOLE +static void lstop(lua_State *L, lua_Debug *ar) +{ + (void)ar; /* unused arg. */ + lua_sethook(L, NULL, 0, 0); + /* Avoid luaL_error -- a C hook doesn't add an extra frame. */ + luaL_where(L, 0); + lua_pushfstring(L, "%sinterrupted!", lua_tostring(L, -1)); + lua_error(L); +} + +static void laction(int i) +{ + signal(i, SIG_DFL); /* if another SIGINT happens before lstop, + terminate process (default action) */ + lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); +} +#endif + +static void print_usage(void) +{ + fprintf(stderr, + "usage: %s [options]... [script [args]...].\n" + "Available options are:\n" + " -e chunk Execute string " LUA_QL("chunk") ".\n" + " -l name Require library " LUA_QL("name") ".\n" + " -b ... Save or list bytecode.\n" + " -j cmd Perform LuaJIT control command.\n" + " -O[opt] Control LuaJIT optimizations.\n" + " -i Enter interactive mode after executing " LUA_QL("script") ".\n" + " -v Show version information.\n" + " -E Ignore environment variables.\n" + " -- Stop handling options.\n" + " - Execute stdin and stop handling options.\n" + , + progname); + fflush(stderr); +} + +static void l_message(const char *pname, const char *msg) +{ + if (pname) fprintf(stderr, "%s: ", pname); + fprintf(stderr, "%s\n", msg); + fflush(stderr); +} + +static int report(lua_State *L, int status) +{ + if (status && !lua_isnil(L, -1)) { + const char *msg = lua_tostring(L, -1); + if (msg == NULL) msg = "(error object is not a string)"; + l_message(progname, msg); + lua_pop(L, 1); + } + return status; +} + +static int traceback(lua_State *L) +{ + if (!lua_isstring(L, 1)) { /* Non-string error object? Try metamethod. */ + if (lua_isnoneornil(L, 1) || + !luaL_callmeta(L, 1, "__tostring") || + !lua_isstring(L, -1)) + return 1; /* Return non-string error object. */ + lua_remove(L, 1); /* Replace object by result of __tostring metamethod. */ + } + luaL_traceback(L, L, lua_tostring(L, 1), 1); + return 1; +} + +static int docall(lua_State *L, int narg, int clear) +{ + int status; + int base = lua_gettop(L) - narg; /* function index */ + lua_pushcfunction(L, traceback); /* push traceback function */ + lua_insert(L, base); /* put it under chunk and args */ +#if !LJ_TARGET_CONSOLE + signal(SIGINT, laction); +#endif + status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); +#if !LJ_TARGET_CONSOLE + signal(SIGINT, SIG_DFL); +#endif + lua_remove(L, base); /* remove traceback function */ + /* force a complete garbage collection in case of errors */ + if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); + return status; +} + +static void print_version(void) +{ + fputs(LUAJIT_VERSION " -- " LUAJIT_COPYRIGHT ". " LUAJIT_URL "\n", stdout); +} + +static void print_jit_status(lua_State *L) +{ + int n; + const char *s; + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, -1, "jit"); /* Get jit.* module table. */ + lua_remove(L, -2); + lua_getfield(L, -1, "status"); + lua_remove(L, -2); + n = lua_gettop(L); + lua_call(L, 0, LUA_MULTRET); + fputs(lua_toboolean(L, n) ? "JIT: ON" : "JIT: OFF", stdout); + for (n++; (s = lua_tostring(L, n)); n++) { + putc(' ', stdout); + fputs(s, stdout); + } + putc('\n', stdout); +} + +static int getargs(lua_State *L, char **argv, int n) +{ + int narg; + int i; + int argc = 0; + while (argv[argc]) argc++; /* count total number of arguments */ + narg = argc - (n + 1); /* number of arguments to the script */ + luaL_checkstack(L, narg + 3, "too many arguments to script"); + for (i = n+1; i < argc; i++) + lua_pushstring(L, argv[i]); + lua_createtable(L, narg, n + 1); + for (i = 0; i < argc; i++) { + lua_pushstring(L, argv[i]); + lua_rawseti(L, -2, i - n); + } + return narg; +} + +static int dofile(lua_State *L, const char *name) +{ + int status = luaL_loadfile(L, name) || docall(L, 0, 1); + return report(L, status); +} + +static int dostring(lua_State *L, const char *s, const char *name) +{ + int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1); + return report(L, status); +} + +static int dolibrary(lua_State *L, const char *name) +{ + lua_getglobal(L, "require"); + lua_pushstring(L, name); + return report(L, docall(L, 1, 1)); +} + +static void write_prompt(lua_State *L, int firstline) +{ + const char *p; + lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2"); + p = lua_tostring(L, -1); + if (p == NULL) p = firstline ? LUA_PROMPT : LUA_PROMPT2; + fputs(p, stdout); + fflush(stdout); + lua_pop(L, 1); /* remove global */ +} + +static int incomplete(lua_State *L, int status) +{ + if (status == LUA_ERRSYNTAX) { + size_t lmsg; + const char *msg = lua_tolstring(L, -1, &lmsg); + const char *tp = msg + lmsg - (sizeof(LUA_QL("")) - 1); + if (strstr(msg, LUA_QL("")) == tp) { + lua_pop(L, 1); + return 1; + } + } + return 0; /* else... */ +} + +static int pushline(lua_State *L, int firstline) +{ + char buf[LUA_MAXINPUT]; + write_prompt(L, firstline); + if (fgets(buf, LUA_MAXINPUT, stdin)) { + size_t len = strlen(buf); + if (len > 0 && buf[len-1] == '\n') + buf[len-1] = '\0'; + if (firstline && buf[0] == '=') + lua_pushfstring(L, "return %s", buf+1); + else + lua_pushstring(L, buf); + return 1; + } + return 0; +} + +static int loadline(lua_State *L) +{ + int status; + lua_settop(L, 0); + if (!pushline(L, 1)) + return -1; /* no input */ + for (;;) { /* repeat until gets a complete line */ + status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); + if (!incomplete(L, status)) break; /* cannot try to add lines? */ + if (!pushline(L, 0)) /* no more input? */ + return -1; + lua_pushliteral(L, "\n"); /* add a new line... */ + lua_insert(L, -2); /* ...between the two lines */ + lua_concat(L, 3); /* join them */ + } + lua_remove(L, 1); /* remove line */ + return status; +} + +static void dotty(lua_State *L) +{ + int status; + const char *oldprogname = progname; + progname = NULL; + while ((status = loadline(L)) != -1) { + if (status == 0) status = docall(L, 0, 0); + report(L, status); + if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */ + lua_getglobal(L, "print"); + lua_insert(L, 1); + if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) + l_message(progname, + lua_pushfstring(L, "error calling " LUA_QL("print") " (%s)", + lua_tostring(L, -1))); + } + } + lua_settop(L, 0); /* clear stack */ + fputs("\n", stdout); + fflush(stdout); + progname = oldprogname; +} + +static int handle_script(lua_State *L, char **argv, int n) +{ + int status; + const char *fname; + int narg = getargs(L, argv, n); /* collect arguments */ + lua_setglobal(L, "arg"); + fname = argv[n]; + if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) + fname = NULL; /* stdin */ + status = luaL_loadfile(L, fname); + lua_insert(L, -(narg+1)); + if (status == 0) + status = docall(L, narg, 0); + else + lua_pop(L, narg); + return report(L, status); +} + +/* Load add-on module. */ +static int loadjitmodule(lua_State *L) +{ + lua_getglobal(L, "require"); + lua_pushliteral(L, "jit."); + lua_pushvalue(L, -3); + lua_concat(L, 2); + if (lua_pcall(L, 1, 1, 0)) { + const char *msg = lua_tostring(L, -1); + if (msg && !strncmp(msg, "module ", 7)) + goto nomodule; + return report(L, 1); + } + lua_getfield(L, -1, "start"); + if (lua_isnil(L, -1)) { + nomodule: + l_message(progname, + "unknown luaJIT command or jit.* modules not installed"); + return 1; + } + lua_remove(L, -2); /* Drop module table. */ + return 0; +} + +/* Run command with options. */ +static int runcmdopt(lua_State *L, const char *opt) +{ + int narg = 0; + if (opt && *opt) { + for (;;) { /* Split arguments. */ + const char *p = strchr(opt, ','); + narg++; + if (!p) break; + if (p == opt) + lua_pushnil(L); + else + lua_pushlstring(L, opt, (size_t)(p - opt)); + opt = p + 1; + } + if (*opt) + lua_pushstring(L, opt); + else + lua_pushnil(L); + } + return report(L, lua_pcall(L, narg, 0, 0)); +} + +/* JIT engine control command: try jit library first or load add-on module. */ +static int dojitcmd(lua_State *L, const char *cmd) +{ + const char *opt = strchr(cmd, '='); + lua_pushlstring(L, cmd, opt ? (size_t)(opt - cmd) : strlen(cmd)); + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, -1, "jit"); /* Get jit.* module table. */ + lua_remove(L, -2); + lua_pushvalue(L, -2); + lua_gettable(L, -2); /* Lookup library function. */ + if (!lua_isfunction(L, -1)) { + lua_pop(L, 2); /* Drop non-function and jit.* table, keep module name. */ + if (loadjitmodule(L)) + return 1; + } else { + lua_remove(L, -2); /* Drop jit.* table. */ + } + lua_remove(L, -2); /* Drop module name. */ + return runcmdopt(L, opt ? opt+1 : opt); +} + +/* Optimization flags. */ +static int dojitopt(lua_State *L, const char *opt) +{ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, -1, "jit.opt"); /* Get jit.opt.* module table. */ + lua_remove(L, -2); + lua_getfield(L, -1, "start"); + lua_remove(L, -2); + return runcmdopt(L, opt); +} + +/* Save or list bytecode. */ +static int dobytecode(lua_State *L, char **argv) +{ + int narg = 0; + lua_pushliteral(L, "bcsave"); + if (loadjitmodule(L)) + return 1; + if (argv[0][2]) { + narg++; + argv[0][1] = '-'; + lua_pushstring(L, argv[0]+1); + } + for (argv++; *argv != NULL; narg++, argv++) + lua_pushstring(L, *argv); + return report(L, lua_pcall(L, narg, 0, 0)); +} + +/* check that argument has no extra characters at the end */ +#define notail(x) {if ((x)[2] != '\0') return -1;} + +#define FLAGS_INTERACTIVE 1 +#define FLAGS_VERSION 2 +#define FLAGS_EXEC 4 +#define FLAGS_OPTION 8 +#define FLAGS_NOENV 16 + +static int collectargs(char **argv, int *flags) +{ + int i; + for (i = 1; argv[i] != NULL; i++) { + if (argv[i][0] != '-') /* Not an option? */ + return i; + switch (argv[i][1]) { /* Check option. */ + case '-': + notail(argv[i]); + return (argv[i+1] != NULL ? i+1 : 0); + case '\0': + return i; + case 'i': + notail(argv[i]); + *flags |= FLAGS_INTERACTIVE; + /* fallthrough */ + case 'v': + notail(argv[i]); + *flags |= FLAGS_VERSION; + break; + case 'e': + *flags |= FLAGS_EXEC; + case 'j': /* LuaJIT extension */ + case 'l': + *flags |= FLAGS_OPTION; + if (argv[i][2] == '\0') { + i++; + if (argv[i] == NULL) return -1; + } + break; + case 'O': break; /* LuaJIT extension */ + case 'b': /* LuaJIT extension */ + if (*flags) return -1; + *flags |= FLAGS_EXEC; + return 0; + case 'E': + *flags |= FLAGS_NOENV; + break; + default: return -1; /* invalid option */ + } + } + return 0; +} + +static int runargs(lua_State *L, char **argv, int n) +{ + int i; + for (i = 1; i < n; i++) { + if (argv[i] == NULL) continue; + lua_assert(argv[i][0] == '-'); + switch (argv[i][1]) { /* option */ + case 'e': { + const char *chunk = argv[i] + 2; + if (*chunk == '\0') chunk = argv[++i]; + lua_assert(chunk != NULL); + if (dostring(L, chunk, "=(command line)") != 0) + return 1; + break; + } + case 'l': { + const char *filename = argv[i] + 2; + if (*filename == '\0') filename = argv[++i]; + lua_assert(filename != NULL); + if (dolibrary(L, filename)) + return 1; /* stop if file fails */ + break; + } + case 'j': { /* LuaJIT extension */ + const char *cmd = argv[i] + 2; + if (*cmd == '\0') cmd = argv[++i]; + lua_assert(cmd != NULL); + if (dojitcmd(L, cmd)) + return 1; + break; + } + case 'O': /* LuaJIT extension */ + if (dojitopt(L, argv[i] + 2)) + return 1; + break; + case 'b': /* LuaJIT extension */ + return dobytecode(L, argv+i); + default: break; + } + } + return 0; +} + +static int handle_luainit(lua_State *L) +{ +#if LJ_TARGET_CONSOLE + const char *init = NULL; +#else + const char *init = getenv(LUA_INIT); +#endif + if (init == NULL) + return 0; /* status OK */ + else if (init[0] == '@') + return dofile(L, init+1); + else + return dostring(L, init, "=" LUA_INIT); +} + +static struct Smain { + char **argv; + int argc; + int status; +} smain; + +static int pmain(lua_State *L) +{ + struct Smain *s = &smain; + char **argv = s->argv; + int script; + int flags = 0; + globalL = L; + if (argv[0] && argv[0][0]) progname = argv[0]; + LUAJIT_VERSION_SYM(); /* linker-enforced version check */ + script = collectargs(argv, &flags); + if (script < 0) { /* invalid args? */ + print_usage(); + s->status = 1; + return 0; + } + if ((flags & FLAGS_NOENV)) { + lua_pushboolean(L, 1); + lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); + } + lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ + luaL_openlibs(L); /* open libraries */ + lua_gc(L, LUA_GCRESTART, -1); + if (!(flags & FLAGS_NOENV)) { + s->status = handle_luainit(L); + if (s->status != 0) return 0; + } + if ((flags & FLAGS_VERSION)) print_version(); + s->status = runargs(L, argv, (script > 0) ? script : s->argc); + if (s->status != 0) return 0; + if (script) { + s->status = handle_script(L, argv, script); + if (s->status != 0) return 0; + } + if ((flags & FLAGS_INTERACTIVE)) { + print_jit_status(L); + dotty(L); + } else if (script == 0 && !(flags & (FLAGS_EXEC|FLAGS_VERSION))) { + if (lua_stdin_is_tty()) { + print_version(); + print_jit_status(L); + dotty(L); + } else { + dofile(L, NULL); /* executes stdin as a file */ + } + } + return 0; +} + +int main(int argc, char **argv) +{ + int status; + lua_State *L = lua_open(); /* create state */ + if (L == NULL) { + l_message(argv[0], "cannot create state: not enough memory"); + return EXIT_FAILURE; + } + smain.argc = argc; + smain.argv = argv; + status = lua_cpcall(L, pmain, NULL); + report(L, status); + lua_close(L); + return (status || smain.status) ? EXIT_FAILURE : EXIT_SUCCESS; +} + + +``` + +`include/luajit-2.0.5/src/luajit.h`: + +```h +/* +** LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ +** +** Copyright (C) 2005-2017 Mike Pall. All rights reserved. +** +** Permission is hereby granted, free of charge, to any person obtaining +** a copy of this software and associated documentation files (the +** "Software"), to deal in the Software without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Software, and to +** permit persons to whom the Software is furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be +** included in all copies or substantial portions of the Software. +** +** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +** +** [ MIT license: http://www.opensource.org/licenses/mit-license.php ] +*/ + +#ifndef _LUAJIT_H +#define _LUAJIT_H + +#include "lua.h" + +#define LUAJIT_VERSION "LuaJIT 2.0.5" +#define LUAJIT_VERSION_NUM 20005 /* Version 2.0.5 = 02.00.05. */ +#define LUAJIT_VERSION_SYM luaJIT_version_2_0_5 +#define LUAJIT_COPYRIGHT "Copyright (C) 2005-2017 Mike Pall" +#define LUAJIT_URL "http://luajit.org/" + +/* Modes for luaJIT_setmode. */ +#define LUAJIT_MODE_MASK 0x00ff + +enum { + LUAJIT_MODE_ENGINE, /* Set mode for whole JIT engine. */ + LUAJIT_MODE_DEBUG, /* Set debug mode (idx = level). */ + + LUAJIT_MODE_FUNC, /* Change mode for a function. */ + LUAJIT_MODE_ALLFUNC, /* Recurse into subroutine protos. */ + LUAJIT_MODE_ALLSUBFUNC, /* Change only the subroutines. */ + + LUAJIT_MODE_TRACE, /* Flush a compiled trace. */ + + LUAJIT_MODE_WRAPCFUNC = 0x10, /* Set wrapper mode for C function calls. */ + + LUAJIT_MODE_MAX +}; + +/* Flags or'ed in to the mode. */ +#define LUAJIT_MODE_OFF 0x0000 /* Turn feature off. */ +#define LUAJIT_MODE_ON 0x0100 /* Turn feature on. */ +#define LUAJIT_MODE_FLUSH 0x0200 /* Flush JIT-compiled code. */ + +/* LuaJIT public C API. */ + +/* Control the JIT engine. */ +LUA_API int luaJIT_setmode(lua_State *L, int idx, int mode); + +/* Enforce (dynamic) linker error for version mismatches. Call from main. */ +LUA_API void LUAJIT_VERSION_SYM(void); + +#endif + +``` + +`include/luajit-2.0.5/src/lualib.h`: + +```h +/* +** Standard library header. +** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LUALIB_H +#define _LUALIB_H + +#include "lua.h" + +#define LUA_FILEHANDLE "FILE*" + +#define LUA_COLIBNAME "coroutine" +#define LUA_MATHLIBNAME "math" +#define LUA_STRLIBNAME "string" +#define LUA_TABLIBNAME "table" +#define LUA_IOLIBNAME "io" +#define LUA_OSLIBNAME "os" +#define LUA_LOADLIBNAME "package" +#define LUA_DBLIBNAME "debug" +#define LUA_BITLIBNAME "bit" +#define LUA_JITLIBNAME "jit" +#define LUA_FFILIBNAME "ffi" + +LUALIB_API int luaopen_base(lua_State *L); +LUALIB_API int luaopen_math(lua_State *L); +LUALIB_API int luaopen_string(lua_State *L); +LUALIB_API int luaopen_table(lua_State *L); +LUALIB_API int luaopen_io(lua_State *L); +LUALIB_API int luaopen_os(lua_State *L); +LUALIB_API int luaopen_package(lua_State *L); +LUALIB_API int luaopen_debug(lua_State *L); +LUALIB_API int luaopen_bit(lua_State *L); +LUALIB_API int luaopen_jit(lua_State *L); +LUALIB_API int luaopen_ffi(lua_State *L); + +LUALIB_API void luaL_openlibs(lua_State *L); + +#ifndef lua_assert +#define lua_assert(x) ((void)0) +#endif + +#endif + +``` + +`include/luajit-2.0.5/src/msvcbuild.bat`: + +```bat +@rem Script to build LuaJIT with MSVC. +@rem Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +@rem +@rem Either open a "Visual Studio .NET Command Prompt" +@rem (Note that the Express Edition does not contain an x64 compiler) +@rem -or- +@rem Open a "Windows SDK Command Shell" and set the compiler environment: +@rem setenv /release /x86 +@rem -or- +@rem setenv /release /x64 +@rem +@rem Then cd to this directory and run this script. + +@if not defined INCLUDE goto :FAIL + +@setlocal +@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline +@set LJLINK=link /nologo +@set LJMT=mt /nologo +@set LJLIB=lib /nologo /nodefaultlib +@set DASMDIR=..\dynasm +@set DASM=%DASMDIR%\dynasm.lua +@set LJDLLNAME=lua51.dll +@set LJLIBNAME=lua51.lib +@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c + +%LJCOMPILE% host\minilua.c +@if errorlevel 1 goto :BAD +%LJLINK% /out:minilua.exe minilua.obj +@if errorlevel 1 goto :BAD +if exist minilua.exe.manifest^ + %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe + +@set DASMFLAGS=-D WIN -D JIT -D FFI -D P64 +@set LJARCH=x64 +@minilua +@if errorlevel 8 goto :X64 +@set DASMFLAGS=-D WIN -D JIT -D FFI +@set LJARCH=x86 +:X64 +minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc +@if errorlevel 1 goto :BAD + +%LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c +@if errorlevel 1 goto :BAD +%LJLINK% /out:buildvm.exe buildvm*.obj +@if errorlevel 1 goto :BAD +if exist buildvm.exe.manifest^ + %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe + +buildvm -m peobj -o lj_vm.obj +@if errorlevel 1 goto :BAD +buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m libdef -o lj_libdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m recdef -o lj_recdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m folddef -o lj_folddef.h lj_opt_fold.c +@if errorlevel 1 goto :BAD + +@if "%1" neq "debug" goto :NODEBUG +@shift +@set LJCOMPILE=%LJCOMPILE% /Zi +@set LJLINK=%LJLINK% /debug +:NODEBUG +@if "%1"=="amalg" goto :AMALGDLL +@if "%1"=="static" goto :STATIC +%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c +@if errorlevel 1 goto :BAD +%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj +@if errorlevel 1 goto :BAD +@goto :MTDLL +:STATIC +%LJCOMPILE% lj_*.c lib_*.c +@if errorlevel 1 goto :BAD +%LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj +@if errorlevel 1 goto :BAD +@goto :MTDLL +:AMALGDLL +%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL ljamalg.c +@if errorlevel 1 goto :BAD +%LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj +@if errorlevel 1 goto :BAD +:MTDLL +if exist %LJDLLNAME%.manifest^ + %LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2 + +%LJCOMPILE% luajit.c +@if errorlevel 1 goto :BAD +%LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME% +@if errorlevel 1 goto :BAD +if exist luajit.exe.manifest^ + %LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe + +@del *.obj *.manifest minilua.exe buildvm.exe +@del host\buildvm_arch.h +@del lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h +@echo. +@echo === Successfully built LuaJIT for Windows/%LJARCH% === + +@goto :END +:BAD +@echo. +@echo ******************************************************* +@echo *** Build FAILED -- Please check the error messages *** +@echo ******************************************************* +@goto :END +:FAIL +@echo You must open a "Visual Studio .NET Command Prompt" to run this script +:END + +``` + +`include/luajit-2.0.5/src/ps4build.bat`: + +```bat +@rem Script to build LuaJIT with the PS4 SDK. +@rem Donated to the public domain. +@rem +@rem Open a "Visual Studio .NET Command Prompt" (64 bit host compiler) +@rem Then cd to this directory and run this script. + +@if not defined INCLUDE goto :FAIL +@if not defined SCE_ORBIS_SDK_DIR goto :FAIL + +@setlocal +@rem ---- Host compiler ---- +@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE +@set LJLINK=link /nologo +@set LJMT=mt /nologo +@set DASMDIR=..\dynasm +@set DASM=%DASMDIR%\dynasm.lua +@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c + +%LJCOMPILE% host\minilua.c +@if errorlevel 1 goto :BAD +%LJLINK% /out:minilua.exe minilua.obj +@if errorlevel 1 goto :BAD +if exist minilua.exe.manifest^ + %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe + +@rem Check for 64 bit host compiler. +@minilua +@if not errorlevel 8 goto :FAIL + +@set DASMFLAGS=-D P64 -D NO_UNWIND +minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc +@if errorlevel 1 goto :BAD + +%LJCOMPILE% /I "." /I %DASMDIR% -DLUAJIT_TARGET=LUAJIT_ARCH_X64 -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_NO_UNWIND host\buildvm*.c +@if errorlevel 1 goto :BAD +%LJLINK% /out:buildvm.exe buildvm*.obj +@if errorlevel 1 goto :BAD +if exist buildvm.exe.manifest^ + %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe + +buildvm -m elfasm -o lj_vm.s +@if errorlevel 1 goto :BAD +buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m libdef -o lj_libdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m recdef -o lj_recdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m folddef -o lj_folddef.h lj_opt_fold.c +@if errorlevel 1 goto :BAD + +@rem ---- Cross compiler ---- +@set LJCOMPILE="%SCE_ORBIS_SDK_DIR%\host_tools\bin\orbis-clang" -c -Wall -DLUAJIT_DISABLE_FFI +@set LJLIB="%SCE_ORBIS_SDK_DIR%\host_tools\bin\orbis-ar" rcus +@set INCLUDE="" + +orbis-as -o lj_vm.o lj_vm.s + +@if "%1" neq "debug" goto :NODEBUG +@shift +@set LJCOMPILE=%LJCOMPILE% -g -O0 +@set TARGETLIB=libluajitD.a +goto :BUILD +:NODEBUG +@set LJCOMPILE=%LJCOMPILE% -O2 +@set TARGETLIB=libluajit.a +:BUILD +del %TARGETLIB% +@if "%1"=="amalg" goto :AMALG +for %%f in (lj_*.c lib_*.c) do ( + %LJCOMPILE% %%f + @if errorlevel 1 goto :BAD +) + +%LJLIB% %TARGETLIB% lj_*.o lib_*.o +@if errorlevel 1 goto :BAD +@goto :NOAMALG +:AMALG +%LJCOMPILE% ljamalg.c +@if errorlevel 1 goto :BAD +%LJLIB% %TARGETLIB% ljamalg.o lj_vm.o +@if errorlevel 1 goto :BAD +:NOAMALG + +@del *.o *.obj *.manifest minilua.exe buildvm.exe +@echo. +@echo === Successfully built LuaJIT for PS4 === + +@goto :END +:BAD +@echo. +@echo ******************************************************* +@echo *** Build FAILED -- Please check the error messages *** +@echo ******************************************************* +@goto :END +:FAIL +@echo To run this script you must open a "Visual Studio .NET Command Prompt" +@echo (64 bit host compiler). The PS4 Orbis SDK must be installed, too. +:END + +``` + +`include/luajit-2.0.5/src/psvitabuild.bat`: + +```bat +@rem Script to build LuaJIT with the PS Vita SDK. +@rem Donated to the public domain. +@rem +@rem Open a "Visual Studio .NET Command Prompt" (32 bit host compiler) +@rem Then cd to this directory and run this script. + +@if not defined INCLUDE goto :FAIL +@if not defined SCE_PSP2_SDK_DIR goto :FAIL + +@setlocal +@rem ---- Host compiler ---- +@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE +@set LJLINK=link /nologo +@set LJMT=mt /nologo +@set DASMDIR=..\dynasm +@set DASM=%DASMDIR%\dynasm.lua +@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c + +%LJCOMPILE% host\minilua.c +@if errorlevel 1 goto :BAD +%LJLINK% /out:minilua.exe minilua.obj +@if errorlevel 1 goto :BAD +if exist minilua.exe.manifest^ + %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe + +@rem Check for 32 bit host compiler. +@minilua +@if errorlevel 8 goto :FAIL + +@set DASMFLAGS=-D FPU -D HFABI +minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_arm.dasc +@if errorlevel 1 goto :BAD + +%LJCOMPILE% /I "." /I %DASMDIR% -DLUAJIT_TARGET=LUAJIT_ARCH_ARM -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLJ_TARGET_PSVITA=1 host\buildvm*.c +@if errorlevel 1 goto :BAD +%LJLINK% /out:buildvm.exe buildvm*.obj +@if errorlevel 1 goto :BAD +if exist buildvm.exe.manifest^ + %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe + +buildvm -m elfasm -o lj_vm.s +@if errorlevel 1 goto :BAD +buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m libdef -o lj_libdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m recdef -o lj_recdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m folddef -o lj_folddef.h lj_opt_fold.c +@if errorlevel 1 goto :BAD + +@rem ---- Cross compiler ---- +@set LJCOMPILE="%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2snc" -c -w -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC +@set LJLIB="%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2ld32" -r --output= +@set INCLUDE="" + +"%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2as" -o lj_vm.o lj_vm.s + +@if "%1" neq "debug" goto :NODEBUG +@shift +@set LJCOMPILE=%LJCOMPILE% -g -O0 +@set TARGETLIB=libluajitD.a +goto :BUILD +:NODEBUG +@set LJCOMPILE=%LJCOMPILE% -O2 +@set TARGETLIB=libluajit.a +:BUILD +del %TARGETLIB% + +%LJCOMPILE% ljamalg.c +@if errorlevel 1 goto :BAD +%LJLIB%%TARGETLIB% ljamalg.o lj_vm.o +@if errorlevel 1 goto :BAD + +@del *.o *.obj *.manifest minilua.exe buildvm.exe +@echo. +@echo === Successfully built LuaJIT for PS Vita === + +@goto :END +:BAD +@echo. +@echo ******************************************************* +@echo *** Build FAILED -- Please check the error messages *** +@echo ******************************************************* +@goto :END +:FAIL +@echo To run this script you must open a "Visual Studio .NET Command Prompt" +@echo (32 bit host compiler). The PS Vita SDK must be installed, too. +:END + +``` + +`include/luajit-2.0.5/src/script.lua`: + +```lua +print(client.GetUsername()) +``` + +`include/luajit-2.0.5/src/vm_arm.dasc`: + +```dasc +|// Low-level VM code for ARM CPUs. +|// Bytecode interpreter, fast functions and helper functions. +|// Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +| +|.arch arm +|.section code_op, code_sub +| +|.actionlist build_actionlist +|.globals GLOB_ +|.globalnames globnames +|.externnames extnames +| +|// Note: The ragged indentation of the instructions is intentional. +|// The starting columns indicate data dependencies. +| +|//----------------------------------------------------------------------- +| +|// Fixed register assignments for the interpreter. +| +|// The following must be C callee-save. +|.define MASKR8, r4 // 255*8 constant for fast bytecode decoding. +|.define KBASE, r5 // Constants of current Lua function. +|.define PC, r6 // Next PC. +|.define DISPATCH, r7 // Opcode dispatch table. +|.define LREG, r8 // Register holding lua_State (also in SAVE_L). +| +|// C callee-save in EABI, but often refetched. Temporary in iOS 3.0+. +|.define BASE, r9 // Base of current Lua stack frame. +| +|// The following temporaries are not saved across C calls, except for RA/RC. +|.define RA, r10 // Callee-save. +|.define RC, r11 // Callee-save. +|.define RB, r12 +|.define OP, r12 // Overlaps RB, must not be lr. +|.define INS, lr +| +|// Calling conventions. Also used as temporaries. +|.define CARG1, r0 +|.define CARG2, r1 +|.define CARG3, r2 +|.define CARG4, r3 +|.define CARG12, r0 // For 1st soft-fp double. +|.define CARG34, r2 // For 2nd soft-fp double. +| +|.define CRET1, r0 +|.define CRET2, r1 +| +|// Stack layout while in interpreter. Must match with lj_frame.h. +|.define SAVE_R4, [sp, #28] +|.define CFRAME_SPACE, #28 +|.define SAVE_ERRF, [sp, #24] +|.define SAVE_NRES, [sp, #20] +|.define SAVE_CFRAME, [sp, #16] +|.define SAVE_L, [sp, #12] +|.define SAVE_PC, [sp, #8] +|.define SAVE_MULTRES, [sp, #4] +|.define ARG5, [sp] +| +|.define TMPDhi, [sp, #4] +|.define TMPDlo, [sp] +|.define TMPD, [sp] +|.define TMPDp, sp +| +|.if FPU +|.macro saveregs +| push {r5, r6, r7, r8, r9, r10, r11, lr} +| vpush {d8-d15} +| sub sp, sp, CFRAME_SPACE+4 +| str r4, SAVE_R4 +|.endmacro +|.macro restoreregs_ret +| ldr r4, SAVE_R4 +| add sp, sp, CFRAME_SPACE+4 +| vpop {d8-d15} +| pop {r5, r6, r7, r8, r9, r10, r11, pc} +|.endmacro +|.else +|.macro saveregs +| push {r4, r5, r6, r7, r8, r9, r10, r11, lr} +| sub sp, sp, CFRAME_SPACE +|.endmacro +|.macro restoreregs_ret +| add sp, sp, CFRAME_SPACE +| pop {r4, r5, r6, r7, r8, r9, r10, r11, pc} +|.endmacro +|.endif +| +|// Type definitions. Some of these are only used for documentation. +|.type L, lua_State, LREG +|.type GL, global_State +|.type TVALUE, TValue +|.type GCOBJ, GCobj +|.type STR, GCstr +|.type TAB, GCtab +|.type LFUNC, GCfuncL +|.type CFUNC, GCfuncC +|.type PROTO, GCproto +|.type UPVAL, GCupval +|.type NODE, Node +|.type NARGS8, int +|.type TRACE, GCtrace +| +|//----------------------------------------------------------------------- +| +|// Trap for not-yet-implemented parts. +|.macro NYI; ud; .endmacro +| +|//----------------------------------------------------------------------- +| +|// Access to frame relative to BASE. +|.define FRAME_FUNC, #-8 +|.define FRAME_PC, #-4 +| +|.macro decode_RA8, dst, ins; and dst, MASKR8, ins, lsr #5; .endmacro +|.macro decode_RB8, dst, ins; and dst, MASKR8, ins, lsr #21; .endmacro +|.macro decode_RC8, dst, ins; and dst, MASKR8, ins, lsr #13; .endmacro +|.macro decode_RD, dst, ins; lsr dst, ins, #16; .endmacro +|.macro decode_OP, dst, ins; and dst, ins, #255; .endmacro +| +|// Instruction fetch. +|.macro ins_NEXT1 +| ldrb OP, [PC] +|.endmacro +|.macro ins_NEXT2 +| ldr INS, [PC], #4 +|.endmacro +|// Instruction decode+dispatch. +|.macro ins_NEXT3 +| ldr OP, [DISPATCH, OP, lsl #2] +| decode_RA8 RA, INS +| decode_RD RC, INS +| bx OP +|.endmacro +|.macro ins_NEXT +| ins_NEXT1 +| ins_NEXT2 +| ins_NEXT3 +|.endmacro +| +|// Instruction footer. +|.if 1 +| // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. +| .define ins_next, ins_NEXT +| .define ins_next_, ins_NEXT +| .define ins_next1, ins_NEXT1 +| .define ins_next2, ins_NEXT2 +| .define ins_next3, ins_NEXT3 +|.else +| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. +| // Affects only certain kinds of benchmarks (and only with -j off). +| .macro ins_next +| b ->ins_next +| .endmacro +| .macro ins_next1 +| .endmacro +| .macro ins_next2 +| .endmacro +| .macro ins_next3 +| b ->ins_next +| .endmacro +| .macro ins_next_ +| ->ins_next: +| ins_NEXT +| .endmacro +|.endif +| +|// Avoid register name substitution for field name. +#define field_pc pc +| +|// Call decode and dispatch. +|.macro ins_callt +| // BASE = new base, CARG3 = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC +| ldr PC, LFUNC:CARG3->field_pc +| ldrb OP, [PC] // STALL: load PC. early PC. +| ldr INS, [PC], #4 +| ldr OP, [DISPATCH, OP, lsl #2] // STALL: load OP. early OP. +| decode_RA8 RA, INS +| add RA, RA, BASE +| bx OP +|.endmacro +| +|.macro ins_call +| // BASE = new base, CARG3 = LFUNC/CFUNC, RC = nargs*8, PC = caller PC +| str PC, [BASE, FRAME_PC] +| ins_callt // STALL: locked PC. +|.endmacro +| +|//----------------------------------------------------------------------- +| +|// Macros to test operand types. +|.macro checktp, reg, tp; cmn reg, #-tp; .endmacro +|.macro checktpeq, reg, tp; cmneq reg, #-tp; .endmacro +|.macro checktpne, reg, tp; cmnne reg, #-tp; .endmacro +|.macro checkstr, reg, target; checktp reg, LJ_TSTR; bne target; .endmacro +|.macro checktab, reg, target; checktp reg, LJ_TTAB; bne target; .endmacro +|.macro checkfunc, reg, target; checktp reg, LJ_TFUNC; bne target; .endmacro +| +|// Assumes DISPATCH is relative to GL. +#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) +#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) +| +#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) +| +|.macro hotcheck, delta +| lsr CARG1, PC, #1 +| and CARG1, CARG1, #126 +| sub CARG1, CARG1, #-GG_DISP2HOT +| ldrh CARG2, [DISPATCH, CARG1] +| subs CARG2, CARG2, #delta +| strh CARG2, [DISPATCH, CARG1] +|.endmacro +| +|.macro hotloop +| hotcheck HOTCOUNT_LOOP +| blo ->vm_hotloop +|.endmacro +| +|.macro hotcall +| hotcheck HOTCOUNT_CALL +| blo ->vm_hotcall +|.endmacro +| +|// Set current VM state. +|.macro mv_vmstate, reg, st; mvn reg, #LJ_VMST_..st; .endmacro +|.macro st_vmstate, reg; str reg, [DISPATCH, #DISPATCH_GL(vmstate)]; .endmacro +| +|// Move table write barrier back. Overwrites mark and tmp. +|.macro barrierback, tab, mark, tmp +| ldr tmp, [DISPATCH, #DISPATCH_GL(gc.grayagain)] +| bic mark, mark, #LJ_GC_BLACK // black2gray(tab) +| str tab, [DISPATCH, #DISPATCH_GL(gc.grayagain)] +| strb mark, tab->marked +| str tmp, tab->gclist +|.endmacro +| +|.macro .IOS, a, b +|.if IOS +| a, b +|.endif +|.endmacro +| +|//----------------------------------------------------------------------- + +#if !LJ_DUALNUM +#error "Only dual-number mode supported for ARM target" +#endif + +/* Generate subroutines used by opcodes and other parts of the VM. */ +/* The .code_sub section should be last to help static branch prediction. */ +static void build_subroutines(BuildCtx *ctx) +{ + |.code_sub + | + |//----------------------------------------------------------------------- + |//-- Return handling ---------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_returnp: + | // See vm_return. Also: RB = previous base. + | tst PC, #FRAME_P + | beq ->cont_dispatch + | + | // Return from pcall or xpcall fast func. + | ldr PC, [RB, FRAME_PC] // Fetch PC of previous frame. + | mvn CARG2, #~LJ_TTRUE + | mov BASE, RB + | // Prepending may overwrite the pcall frame, so do it at the end. + | str CARG2, [RA, FRAME_PC] // Prepend true to results. + | sub RA, RA, #8 + | + |->vm_returnc: + | adds RC, RC, #8 // RC = (nresults+1)*8. + | mov CRET1, #LUA_YIELD + | beq ->vm_unwind_c_eh + | str RC, SAVE_MULTRES + | ands CARG1, PC, #FRAME_TYPE + | beq ->BC_RET_Z // Handle regular return to Lua. + | + |->vm_return: + | // BASE = base, RA = resultptr, RC/MULTRES = (nresults+1)*8, PC = return + | // CARG1 = PC & FRAME_TYPE + | bic RB, PC, #FRAME_TYPEP + | cmp CARG1, #FRAME_C + | sub RB, BASE, RB // RB = previous base. + | bne ->vm_returnp + | + | str RB, L->base + | ldr KBASE, SAVE_NRES + | mv_vmstate CARG4, C + | sub BASE, BASE, #8 + | subs CARG3, RC, #8 + | lsl KBASE, KBASE, #3 // KBASE = (nresults_wanted+1)*8 + | st_vmstate CARG4 + | beq >2 + |1: + | subs CARG3, CARG3, #8 + | ldrd CARG12, [RA], #8 + | strd CARG12, [BASE], #8 + | bne <1 + |2: + | cmp KBASE, RC // More/less results wanted? + | bne >6 + |3: + | str BASE, L->top // Store new top. + | + |->vm_leave_cp: + | ldr RC, SAVE_CFRAME // Restore previous C frame. + | mov CRET1, #0 // Ok return status for vm_pcall. + | str RC, L->cframe + | + |->vm_leave_unw: + | restoreregs_ret + | + |6: + | blt >7 // Less results wanted? + | // More results wanted. Check stack size and fill up results with nil. + | ldr CARG3, L->maxstack + | mvn CARG2, #~LJ_TNIL + | cmp BASE, CARG3 + | bhs >8 + | str CARG2, [BASE, #4] + | add RC, RC, #8 + | add BASE, BASE, #8 + | b <2 + | + |7: // Less results wanted. + | sub CARG1, RC, KBASE + | cmp KBASE, #0 // LUA_MULTRET+1 case? + | subne BASE, BASE, CARG1 // Either keep top or shrink it. + | b <3 + | + |8: // Corner case: need to grow stack for filling up results. + | // This can happen if: + | // - A C function grows the stack (a lot). + | // - The GC shrinks the stack in between. + | // - A return back from a lua_call() with (high) nresults adjustment. + | str BASE, L->top // Save current top held in BASE (yes). + | lsr CARG2, KBASE, #3 + | mov CARG1, L + | bl extern lj_state_growstack // (lua_State *L, int n) + | ldr BASE, L->top // Need the (realloced) L->top in BASE. + | b <2 + | + |->vm_unwind_c: // Unwind C stack, return from vm_pcall. + | // (void *cframe, int errcode) + | mov sp, CARG1 + | mov CRET1, CARG2 + |->vm_unwind_c_eh: // Landing pad for external unwinder. + | ldr L, SAVE_L + | mv_vmstate CARG4, C + | ldr GL:CARG3, L->glref + | str CARG4, GL:CARG3->vmstate + | b ->vm_leave_unw + | + |->vm_unwind_ff: // Unwind C stack, return from ff pcall. + | // (void *cframe) + | bic CARG1, CARG1, #~CFRAME_RAWMASK // Use two steps: bic sp is deprecated. + | mov sp, CARG1 + |->vm_unwind_ff_eh: // Landing pad for external unwinder. + | ldr L, SAVE_L + | mov MASKR8, #255 + | mov RC, #16 // 2 results: false + error message. + | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. + | ldr BASE, L->base + | ldr DISPATCH, L->glref // Setup pointer to dispatch table. + | mvn CARG1, #~LJ_TFALSE + | sub RA, BASE, #8 // Results start at BASE-8. + | ldr PC, [BASE, FRAME_PC] // Fetch PC of previous frame. + | add DISPATCH, DISPATCH, #GG_G2DISP + | mv_vmstate CARG2, INTERP + | str CARG1, [BASE, #-4] // Prepend false to error message. + | st_vmstate CARG2 + | b ->vm_returnc + | + |//----------------------------------------------------------------------- + |//-- Grow stack for calls ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_growstack_c: // Grow stack for C function. + | // CARG1 = L + | mov CARG2, #LUA_MINSTACK + | b >2 + | + |->vm_growstack_l: // Grow stack for Lua function. + | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC + | add RC, BASE, RC + | sub RA, RA, BASE + | mov CARG1, L + | str BASE, L->base + | add PC, PC, #4 // Must point after first instruction. + | str RC, L->top + | lsr CARG2, RA, #3 + |2: + | // L->base = new base, L->top = top + | str PC, SAVE_PC + | bl extern lj_state_growstack // (lua_State *L, int n) + | ldr BASE, L->base + | ldr RC, L->top + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] + | sub NARGS8:RC, RC, BASE + | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC + | ins_callt // Just retry the call. + | + |//----------------------------------------------------------------------- + |//-- Entry points into the assembler VM --------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_resume: // Setup C frame and resume thread. + | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) + | saveregs + | mov L, CARG1 + | ldr DISPATCH, L:CARG1->glref // Setup pointer to dispatch table. + | mov BASE, CARG2 + | add DISPATCH, DISPATCH, #GG_G2DISP + | str L, SAVE_L + | mov PC, #FRAME_CP + | str CARG3, SAVE_NRES + | add CARG2, sp, #CFRAME_RESUME + | ldrb CARG1, L->status + | str CARG3, SAVE_ERRF + | str CARG2, L->cframe + | str CARG3, SAVE_CFRAME + | cmp CARG1, #0 + | str L, SAVE_PC // Any value outside of bytecode is ok. + | beq >3 + | + | // Resume after yield (like a return). + | mov RA, BASE + | ldr BASE, L->base + | ldr CARG1, L->top + | mov MASKR8, #255 + | strb CARG3, L->status + | sub RC, CARG1, BASE + | ldr PC, [BASE, FRAME_PC] + | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. + | mv_vmstate CARG2, INTERP + | add RC, RC, #8 + | ands CARG1, PC, #FRAME_TYPE + | st_vmstate CARG2 + | str RC, SAVE_MULTRES + | beq ->BC_RET_Z + | b ->vm_return + | + |->vm_pcall: // Setup protected C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) + | saveregs + | mov PC, #FRAME_CP + | str CARG4, SAVE_ERRF + | b >1 + | + |->vm_call: // Setup C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1) + | saveregs + | mov PC, #FRAME_C + | + |1: // Entry point for vm_pcall above (PC = ftype). + | ldr RC, L:CARG1->cframe + | str CARG3, SAVE_NRES + | mov L, CARG1 + | str CARG1, SAVE_L + | mov BASE, CARG2 + | str sp, L->cframe // Add our C frame to cframe chain. + | ldr DISPATCH, L->glref // Setup pointer to dispatch table. + | str CARG1, SAVE_PC // Any value outside of bytecode is ok. + | str RC, SAVE_CFRAME + | add DISPATCH, DISPATCH, #GG_G2DISP + | + |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). + | ldr RB, L->base // RB = old base (for vmeta_call). + | ldr CARG1, L->top + | mov MASKR8, #255 + | add PC, PC, BASE + | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. + | sub PC, PC, RB // PC = frame delta + frame type + | mv_vmstate CARG2, INTERP + | sub NARGS8:RC, CARG1, BASE + | st_vmstate CARG2 + | + |->vm_call_dispatch: + | // RB = old base, BASE = new base, RC = nargs*8, PC = caller PC + | ldrd CARG34, [BASE, FRAME_FUNC] + | checkfunc CARG4, ->vmeta_call + | + |->vm_call_dispatch_f: + | ins_call + | // BASE = new base, CARG3 = func, RC = nargs*8, PC = caller PC + | + |->vm_cpcall: // Setup protected C frame, call C. + | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) + | saveregs + | mov L, CARG1 + | ldr RA, L:CARG1->stack + | str CARG1, SAVE_L + | ldr RB, L->top + | str CARG1, SAVE_PC // Any value outside of bytecode is ok. + | ldr RC, L->cframe + | sub RA, RA, RB // Compute -savestack(L, L->top). + | str sp, L->cframe // Add our C frame to cframe chain. + | mov RB, #0 + | str RA, SAVE_NRES // Neg. delta means cframe w/o frame. + | str RB, SAVE_ERRF // No error function. + | str RC, SAVE_CFRAME + | blx CARG4 // (lua_State *L, lua_CFunction func, void *ud) + | ldr DISPATCH, L->glref // Setup pointer to dispatch table. + | movs BASE, CRET1 + | mov PC, #FRAME_CP + | add DISPATCH, DISPATCH, #GG_G2DISP + | bne <3 // Else continue with the call. + | b ->vm_leave_cp // No base? Just remove C frame. + | + |//----------------------------------------------------------------------- + |//-- Metamethod handling ------------------------------------------------ + |//----------------------------------------------------------------------- + | + |//-- Continuation dispatch ---------------------------------------------- + | + |->cont_dispatch: + | // BASE = meta base, RA = resultptr, RC = (nresults+1)*8 + | ldr LFUNC:CARG3, [RB, FRAME_FUNC] + | ldr CARG1, [BASE, #-16] // Get continuation. + | mov CARG4, BASE + | mov BASE, RB // Restore caller BASE. + |.if FFI + | cmp CARG1, #1 + |.endif + | ldr PC, [CARG4, #-12] // Restore PC from [cont|PC]. + | ldr CARG3, LFUNC:CARG3->field_pc + | mvn INS, #~LJ_TNIL + | add CARG2, RA, RC + | str INS, [CARG2, #-4] // Ensure one valid arg. + |.if FFI + | bls >1 + |.endif + | ldr KBASE, [CARG3, #PC2PROTO(k)] + | // BASE = base, RA = resultptr, CARG4 = meta base + | bx CARG1 + | + |.if FFI + |1: + | beq ->cont_ffi_callback // cont = 1: return from FFI callback. + | // cont = 0: tailcall from C function. + | sub CARG4, CARG4, #16 + | sub RC, CARG4, BASE + | b ->vm_call_tail + |.endif + | + |->cont_cat: // RA = resultptr, CARG4 = meta base + | ldr INS, [PC, #-4] + | sub CARG2, CARG4, #16 + | ldrd CARG34, [RA] + | str BASE, L->base + | decode_RB8 RC, INS + | decode_RA8 RA, INS + | add CARG1, BASE, RC + | subs CARG1, CARG2, CARG1 + | strdne CARG34, [CARG2] + | movne CARG3, CARG1 + | bne ->BC_CAT_Z + | strd CARG34, [BASE, RA] + | b ->cont_nop + | + |//-- Table indexing metamethods ----------------------------------------- + | + |->vmeta_tgets1: + | add CARG2, BASE, RB + | b >2 + | + |->vmeta_tgets: + | sub CARG2, DISPATCH, #-DISPATCH_GL(tmptv) + | mvn CARG4, #~LJ_TTAB + | str TAB:RB, [CARG2] + | str CARG4, [CARG2, #4] + |2: + | mvn CARG4, #~LJ_TSTR + | str STR:RC, TMPDlo + | str CARG4, TMPDhi + | mov CARG3, TMPDp + | b >1 + | + |->vmeta_tgetb: // RC = index + | decode_RB8 RB, INS + | str RC, TMPDlo + | mvn CARG4, #~LJ_TISNUM + | add CARG2, BASE, RB + | str CARG4, TMPDhi + | mov CARG3, TMPDp + | b >1 + | + |->vmeta_tgetv: + | add CARG2, BASE, RB + | add CARG3, BASE, RC + |1: + | str BASE, L->base + | mov CARG1, L + | str PC, SAVE_PC + | bl extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) + | // Returns TValue * (finished) or NULL (metamethod). + | .IOS ldr BASE, L->base + | cmp CRET1, #0 + | beq >3 + | ldrd CARG34, [CRET1] + | ins_next1 + | ins_next2 + | strd CARG34, [BASE, RA] + | ins_next3 + | + |3: // Call __index metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k + | rsb CARG1, BASE, #FRAME_CONT + | ldr BASE, L->top + | mov NARGS8:RC, #16 // 2 args for func(t, k). + | str PC, [BASE, #-12] // [cont|PC] + | add PC, CARG1, BASE + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. + | b ->vm_call_dispatch_f + | + |//----------------------------------------------------------------------- + | + |->vmeta_tsets1: + | add CARG2, BASE, RB + | b >2 + | + |->vmeta_tsets: + | sub CARG2, DISPATCH, #-DISPATCH_GL(tmptv) + | mvn CARG4, #~LJ_TTAB + | str TAB:RB, [CARG2] + | str CARG4, [CARG2, #4] + |2: + | mvn CARG4, #~LJ_TSTR + | str STR:RC, TMPDlo + | str CARG4, TMPDhi + | mov CARG3, TMPDp + | b >1 + | + |->vmeta_tsetb: // RC = index + | decode_RB8 RB, INS + | str RC, TMPDlo + | mvn CARG4, #~LJ_TISNUM + | add CARG2, BASE, RB + | str CARG4, TMPDhi + | mov CARG3, TMPDp + | b >1 + | + |->vmeta_tsetv: + | add CARG2, BASE, RB + | add CARG3, BASE, RC + |1: + | str BASE, L->base + | mov CARG1, L + | str PC, SAVE_PC + | bl extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) + | // Returns TValue * (finished) or NULL (metamethod). + | .IOS ldr BASE, L->base + | cmp CRET1, #0 + | ldrd CARG34, [BASE, RA] + | beq >3 + | ins_next1 + | // NOBARRIER: lj_meta_tset ensures the table is not black. + | strd CARG34, [CRET1] + | ins_next2 + | ins_next3 + | + |3: // Call __newindex metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) + | rsb CARG1, BASE, #FRAME_CONT + | ldr BASE, L->top + | mov NARGS8:RC, #24 // 3 args for func(t, k, v). + | strd CARG34, [BASE, #16] // Copy value to third argument. + | str PC, [BASE, #-12] // [cont|PC] + | add PC, CARG1, BASE + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. + | b ->vm_call_dispatch_f + | + |//-- Comparison metamethods --------------------------------------------- + | + |->vmeta_comp: + | mov CARG1, L + | sub PC, PC, #4 + | mov CARG2, RA + | str BASE, L->base + | mov CARG3, RC + | str PC, SAVE_PC + | decode_OP CARG4, INS + | bl extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) + | // Returns 0/1 or TValue * (metamethod). + |3: + | .IOS ldr BASE, L->base + | cmp CRET1, #1 + | bhi ->vmeta_binop + |4: + | ldrh RB, [PC, #2] + | add PC, PC, #4 + | add RB, PC, RB, lsl #2 + | subhs PC, RB, #0x20000 + |->cont_nop: + | ins_next + | + |->cont_ra: // RA = resultptr + | ldr INS, [PC, #-4] + | ldrd CARG12, [RA] + | decode_RA8 CARG3, INS + | strd CARG12, [BASE, CARG3] + | b ->cont_nop + | + |->cont_condt: // RA = resultptr + | ldr CARG2, [RA, #4] + | mvn CARG1, #~LJ_TTRUE + | cmp CARG1, CARG2 // Branch if result is true. + | b <4 + | + |->cont_condf: // RA = resultptr + | ldr CARG2, [RA, #4] + | checktp CARG2, LJ_TFALSE // Branch if result is false. + | b <4 + | + |->vmeta_equal: + | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. + | sub PC, PC, #4 + | str BASE, L->base + | mov CARG1, L + | str PC, SAVE_PC + | bl extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) + | // Returns 0/1 or TValue * (metamethod). + | b <3 + | + |->vmeta_equal_cd: + |.if FFI + | sub PC, PC, #4 + | str BASE, L->base + | mov CARG1, L + | mov CARG2, INS + | str PC, SAVE_PC + | bl extern lj_meta_equal_cd // (lua_State *L, BCIns op) + | // Returns 0/1 or TValue * (metamethod). + | b <3 + |.endif + | + |//-- Arithmetic metamethods --------------------------------------------- + | + |->vmeta_arith_vn: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | add CARG3, BASE, RB + | add CARG4, KBASE, RC + | b >1 + | + |->vmeta_arith_nv: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | add CARG4, BASE, RB + | add CARG3, KBASE, RC + | b >1 + | + |->vmeta_unm: + | ldr INS, [PC, #-8] + | sub PC, PC, #4 + | add CARG3, BASE, RC + | add CARG4, BASE, RC + | b >1 + | + |->vmeta_arith_vv: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | add CARG3, BASE, RB + | add CARG4, BASE, RC + |1: + | decode_OP OP, INS + | add CARG2, BASE, RA + | str BASE, L->base + | mov CARG1, L + | str PC, SAVE_PC + | str OP, ARG5 + | bl extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) + | // Returns NULL (finished) or TValue * (metamethod). + | .IOS ldr BASE, L->base + | cmp CRET1, #0 + | beq ->cont_nop + | + | // Call metamethod for binary op. + |->vmeta_binop: + | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 + | sub CARG2, CRET1, BASE + | str PC, [CRET1, #-12] // [cont|PC] + | add PC, CARG2, #FRAME_CONT + | mov BASE, CRET1 + | mov NARGS8:RC, #16 // 2 args for func(o1, o2). + | b ->vm_call_dispatch + | + |->vmeta_len: + | add CARG2, BASE, RC + | str BASE, L->base + | mov CARG1, L + | str PC, SAVE_PC + | bl extern lj_meta_len // (lua_State *L, TValue *o) + | // Returns NULL (retry) or TValue * (metamethod base). + | .IOS ldr BASE, L->base +#if LJ_52 + | cmp CRET1, #0 + | bne ->vmeta_binop // Binop call for compatibility. + | ldr TAB:CARG1, [BASE, RC] + | b ->BC_LEN_Z +#else + | b ->vmeta_binop // Binop call for compatibility. +#endif + | + |//-- Call metamethod ---------------------------------------------------- + | + |->vmeta_call: // Resolve and call __call metamethod. + | // RB = old base, BASE = new base, RC = nargs*8 + | mov CARG1, L + | str RB, L->base // This is the callers base! + | sub CARG2, BASE, #8 + | str PC, SAVE_PC + | add CARG3, BASE, NARGS8:RC + | .IOS mov RA, BASE + | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + | .IOS mov BASE, RA + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. + | add NARGS8:RC, NARGS8:RC, #8 // Got one more argument now. + | ins_call + | + |->vmeta_callt: // Resolve __call for BC_CALLT. + | // BASE = old base, RA = new base, RC = nargs*8 + | mov CARG1, L + | str BASE, L->base + | sub CARG2, RA, #8 + | str PC, SAVE_PC + | add CARG3, RA, NARGS8:RC + | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + | .IOS ldr BASE, L->base + | ldr LFUNC:CARG3, [RA, FRAME_FUNC] // Guaranteed to be a function here. + | ldr PC, [BASE, FRAME_PC] + | add NARGS8:RC, NARGS8:RC, #8 // Got one more argument now. + | b ->BC_CALLT2_Z + | + |//-- Argument coercion for 'for' statement ------------------------------ + | + |->vmeta_for: + | mov CARG1, L + | str BASE, L->base + | mov CARG2, RA + | str PC, SAVE_PC + | bl extern lj_meta_for // (lua_State *L, TValue *base) + | .IOS ldr BASE, L->base + |.if JIT + | ldrb OP, [PC, #-4] + |.endif + | ldr INS, [PC, #-4] + |.if JIT + | cmp OP, #BC_JFORI + |.endif + | decode_RA8 RA, INS + | decode_RD RC, INS + |.if JIT + | beq =>BC_JFORI + |.endif + | b =>BC_FORI + | + |//----------------------------------------------------------------------- + |//-- Fast functions ----------------------------------------------------- + |//----------------------------------------------------------------------- + | + |.macro .ffunc, name + |->ff_ .. name: + |.endmacro + | + |.macro .ffunc_1, name + |->ff_ .. name: + | ldrd CARG12, [BASE] + | cmp NARGS8:RC, #8 + | blo ->fff_fallback + |.endmacro + | + |.macro .ffunc_2, name + |->ff_ .. name: + | ldrd CARG12, [BASE] + | ldrd CARG34, [BASE, #8] + | cmp NARGS8:RC, #16 + | blo ->fff_fallback + |.endmacro + | + |.macro .ffunc_n, name + | .ffunc_1 name + | checktp CARG2, LJ_TISNUM + | bhs ->fff_fallback + |.endmacro + | + |.macro .ffunc_nn, name + | .ffunc_2 name + | checktp CARG2, LJ_TISNUM + | cmnlo CARG4, #-LJ_TISNUM + | bhs ->fff_fallback + |.endmacro + | + |.macro .ffunc_d, name + | .ffunc name + | ldr CARG2, [BASE, #4] + | cmp NARGS8:RC, #8 + | vldr d0, [BASE] + | blo ->fff_fallback + | checktp CARG2, LJ_TISNUM + | bhs ->fff_fallback + |.endmacro + | + |.macro .ffunc_dd, name + | .ffunc name + | ldr CARG2, [BASE, #4] + | ldr CARG4, [BASE, #12] + | cmp NARGS8:RC, #16 + | vldr d0, [BASE] + | vldr d1, [BASE, #8] + | blo ->fff_fallback + | checktp CARG2, LJ_TISNUM + | cmnlo CARG4, #-LJ_TISNUM + | bhs ->fff_fallback + |.endmacro + | + |// Inlined GC threshold check. Caveat: uses CARG1 and CARG2. + |.macro ffgccheck + | ldr CARG1, [DISPATCH, #DISPATCH_GL(gc.total)] + | ldr CARG2, [DISPATCH, #DISPATCH_GL(gc.threshold)] + | cmp CARG1, CARG2 + | blge ->fff_gcstep + |.endmacro + | + |//-- Base library: checks ----------------------------------------------- + | + |.ffunc_1 assert + | checktp CARG2, LJ_TTRUE + | bhi ->fff_fallback + | ldr PC, [BASE, FRAME_PC] + | strd CARG12, [BASE, #-8] + | mov RB, BASE + | subs RA, NARGS8:RC, #8 + | add RC, NARGS8:RC, #8 // Compute (nresults+1)*8. + | beq ->fff_res // Done if exactly 1 argument. + |1: + | ldrd CARG12, [RB, #8] + | subs RA, RA, #8 + | strd CARG12, [RB], #8 + | bne <1 + | b ->fff_res + | + |.ffunc type + | ldr CARG2, [BASE, #4] + | cmp NARGS8:RC, #8 + | blo ->fff_fallback + | checktp CARG2, LJ_TISNUM + | mvnlo CARG2, #~LJ_TISNUM + | rsb CARG4, CARG2, #(int)(offsetof(GCfuncC, upvalue)>>3)-1 + | lsl CARG4, CARG4, #3 + | ldrd CARG12, [CFUNC:CARG3, CARG4] + | b ->fff_restv + | + |//-- Base library: getters and setters --------------------------------- + | + |.ffunc_1 getmetatable + | checktp CARG2, LJ_TTAB + | cmnne CARG2, #-LJ_TUDATA + | bne >6 + |1: // Field metatable must be at same offset for GCtab and GCudata! + | ldr TAB:RB, TAB:CARG1->metatable + |2: + | mvn CARG2, #~LJ_TNIL + | ldr STR:RC, [DISPATCH, #DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])] + | cmp TAB:RB, #0 + | beq ->fff_restv + | ldr CARG3, TAB:RB->hmask + | ldr CARG4, STR:RC->hash + | ldr NODE:INS, TAB:RB->node + | and CARG3, CARG3, CARG4 // idx = str->hash & tab->hmask + | add CARG3, CARG3, CARG3, lsl #1 + | add NODE:INS, NODE:INS, CARG3, lsl #3 // node = tab->node + idx*3*8 + |3: // Rearranged logic, because we expect _not_ to find the key. + | ldrd CARG34, NODE:INS->key // STALL: early NODE:INS. + | ldrd CARG12, NODE:INS->val + | ldr NODE:INS, NODE:INS->next + | checktp CARG4, LJ_TSTR + | cmpeq CARG3, STR:RC + | beq >5 + | cmp NODE:INS, #0 + | bne <3 + |4: + | mov CARG1, RB // Use metatable as default result. + | mvn CARG2, #~LJ_TTAB + | b ->fff_restv + |5: + | checktp CARG2, LJ_TNIL + | bne ->fff_restv + | b <4 + | + |6: + | checktp CARG2, LJ_TISNUM + | mvnhs CARG2, CARG2 + | movlo CARG2, #~LJ_TISNUM + | add CARG4, DISPATCH, CARG2, lsl #2 + | ldr TAB:RB, [CARG4, #DISPATCH_GL(gcroot[GCROOT_BASEMT])] + | b <2 + | + |.ffunc_2 setmetatable + | // Fast path: no mt for table yet and not clearing the mt. + | checktp CARG2, LJ_TTAB + | ldreq TAB:RB, TAB:CARG1->metatable + | checktpeq CARG4, LJ_TTAB + | ldrbeq CARG4, TAB:CARG1->marked + | cmpeq TAB:RB, #0 + | bne ->fff_fallback + | tst CARG4, #LJ_GC_BLACK // isblack(table) + | str TAB:CARG3, TAB:CARG1->metatable + | beq ->fff_restv + | barrierback TAB:CARG1, CARG4, CARG3 + | b ->fff_restv + | + |.ffunc rawget + | ldrd CARG34, [BASE] + | cmp NARGS8:RC, #16 + | blo ->fff_fallback + | mov CARG2, CARG3 + | checktab CARG4, ->fff_fallback + | mov CARG1, L + | add CARG3, BASE, #8 + | .IOS mov RA, BASE + | bl extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) + | // Returns cTValue *. + | .IOS mov BASE, RA + | ldrd CARG12, [CRET1] + | b ->fff_restv + | + |//-- Base library: conversions ------------------------------------------ + | + |.ffunc tonumber + | // Only handles the number case inline (without a base argument). + | ldrd CARG12, [BASE] + | cmp NARGS8:RC, #8 + | bne ->fff_fallback + | checktp CARG2, LJ_TISNUM + | bls ->fff_restv + | b ->fff_fallback + | + |.ffunc_1 tostring + | // Only handles the string or number case inline. + | checktp CARG2, LJ_TSTR + | // A __tostring method in the string base metatable is ignored. + | beq ->fff_restv + | // Handle numbers inline, unless a number base metatable is present. + | ldr CARG4, [DISPATCH, #DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])] + | str BASE, L->base + | checktp CARG2, LJ_TISNUM + | cmpls CARG4, #0 + | str PC, SAVE_PC // Redundant (but a defined value). + | bhi ->fff_fallback + | ffgccheck + | mov CARG1, L + | mov CARG2, BASE + | bl extern lj_str_fromnumber // (lua_State *L, cTValue *o) + | // Returns GCstr *. + | ldr BASE, L->base + | mvn CARG2, #~LJ_TSTR + | b ->fff_restv + | + |//-- Base library: iterators ------------------------------------------- + | + |.ffunc_1 next + | mvn CARG4, #~LJ_TNIL + | checktab CARG2, ->fff_fallback + | strd CARG34, [BASE, NARGS8:RC] // Set missing 2nd arg to nil. + | ldr PC, [BASE, FRAME_PC] + | mov CARG2, CARG1 + | str BASE, L->base // Add frame since C call can throw. + | mov CARG1, L + | str BASE, L->top // Dummy frame length is ok. + | add CARG3, BASE, #8 + | str PC, SAVE_PC + | bl extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) + | // Returns 0 at end of traversal. + | .IOS ldr BASE, L->base + | cmp CRET1, #0 + | mvneq CRET2, #~LJ_TNIL + | beq ->fff_restv // End of traversal: return nil. + | ldrd CARG12, [BASE, #8] // Copy key and value to results. + | ldrd CARG34, [BASE, #16] + | mov RC, #(2+1)*8 + | strd CARG12, [BASE, #-8] + | strd CARG34, [BASE] + | b ->fff_res + | + |.ffunc_1 pairs + | checktab CARG2, ->fff_fallback +#if LJ_52 + | ldr TAB:RB, TAB:CARG1->metatable +#endif + | ldrd CFUNC:CARG34, CFUNC:CARG3->upvalue[0] + | ldr PC, [BASE, FRAME_PC] +#if LJ_52 + | cmp TAB:RB, #0 + | bne ->fff_fallback +#endif + | mvn CARG2, #~LJ_TNIL + | mov RC, #(3+1)*8 + | strd CFUNC:CARG34, [BASE, #-8] + | str CARG2, [BASE, #12] + | b ->fff_res + | + |.ffunc_2 ipairs_aux + | checktp CARG2, LJ_TTAB + | checktpeq CARG4, LJ_TISNUM + | bne ->fff_fallback + | ldr RB, TAB:CARG1->asize + | ldr RC, TAB:CARG1->array + | add CARG3, CARG3, #1 + | ldr PC, [BASE, FRAME_PC] + | cmp CARG3, RB + | add RC, RC, CARG3, lsl #3 + | strd CARG34, [BASE, #-8] + | ldrdlo CARG12, [RC] + | mov RC, #(0+1)*8 + | bhs >2 // Not in array part? + |1: + | checktp CARG2, LJ_TNIL + | movne RC, #(2+1)*8 + | strdne CARG12, [BASE] + | b ->fff_res + |2: // Check for empty hash part first. Otherwise call C function. + | ldr RB, TAB:CARG1->hmask + | mov CARG2, CARG3 + | cmp RB, #0 + | beq ->fff_res + | .IOS mov RA, BASE + | bl extern lj_tab_getinth // (GCtab *t, int32_t key) + | // Returns cTValue * or NULL. + | .IOS mov BASE, RA + | cmp CRET1, #0 + | beq ->fff_res + | ldrd CARG12, [CRET1] + | b <1 + | + |.ffunc_1 ipairs + | checktab CARG2, ->fff_fallback +#if LJ_52 + | ldr TAB:RB, TAB:CARG1->metatable +#endif + | ldrd CFUNC:CARG34, CFUNC:CARG3->upvalue[0] + | ldr PC, [BASE, FRAME_PC] +#if LJ_52 + | cmp TAB:RB, #0 + | bne ->fff_fallback +#endif + | mov CARG1, #0 + | mvn CARG2, #~LJ_TISNUM + | mov RC, #(3+1)*8 + | strd CFUNC:CARG34, [BASE, #-8] + | strd CARG12, [BASE, #8] + | b ->fff_res + | + |//-- Base library: catch errors ---------------------------------------- + | + |.ffunc pcall + | ldrb RA, [DISPATCH, #DISPATCH_GL(hookmask)] + | cmp NARGS8:RC, #8 + | blo ->fff_fallback + | tst RA, #HOOK_ACTIVE // Remember active hook before pcall. + | mov RB, BASE + | add BASE, BASE, #8 + | moveq PC, #8+FRAME_PCALL + | movne PC, #8+FRAME_PCALLH + | sub NARGS8:RC, NARGS8:RC, #8 + | b ->vm_call_dispatch + | + |.ffunc_2 xpcall + | ldrb RA, [DISPATCH, #DISPATCH_GL(hookmask)] + | checkfunc CARG4, ->fff_fallback // Traceback must be a function. + | mov RB, BASE + | strd CARG12, [BASE, #8] // Swap function and traceback. + | strd CARG34, [BASE] + | tst RA, #HOOK_ACTIVE // Remember active hook before pcall. + | add BASE, BASE, #16 + | moveq PC, #16+FRAME_PCALL + | movne PC, #16+FRAME_PCALLH + | sub NARGS8:RC, NARGS8:RC, #16 + | b ->vm_call_dispatch + | + |//-- Coroutine library -------------------------------------------------- + | + |.macro coroutine_resume_wrap, resume + |.if resume + |.ffunc_1 coroutine_resume + | checktp CARG2, LJ_TTHREAD + | bne ->fff_fallback + |.else + |.ffunc coroutine_wrap_aux + | ldr L:CARG1, CFUNC:CARG3->upvalue[0].gcr + |.endif + | ldr PC, [BASE, FRAME_PC] + | str BASE, L->base + | ldr CARG2, L:CARG1->top + | ldrb RA, L:CARG1->status + | ldr RB, L:CARG1->base + | add CARG3, CARG2, NARGS8:RC + | add CARG4, CARG2, RA + | str PC, SAVE_PC + | cmp CARG4, RB + | beq ->fff_fallback + | ldr CARG4, L:CARG1->maxstack + | ldr RB, L:CARG1->cframe + | cmp RA, #LUA_YIELD + | cmpls CARG3, CARG4 + | cmpls RB, #0 + | bhi ->fff_fallback + |1: + |.if resume + | sub CARG3, CARG3, #8 // Keep resumed thread in stack for GC. + | add BASE, BASE, #8 + | sub NARGS8:RC, NARGS8:RC, #8 + |.endif + | str CARG3, L:CARG1->top + | str BASE, L->top + |2: // Move args to coroutine. + | ldrd CARG34, [BASE, RB] + | cmp RB, NARGS8:RC + | strdne CARG34, [CARG2, RB] + | add RB, RB, #8 + | bne <2 + | + | mov CARG3, #0 + | mov L:RA, L:CARG1 + | mov CARG4, #0 + | bl ->vm_resume // (lua_State *L, TValue *base, 0, 0) + | // Returns thread status. + |4: + | ldr CARG3, L:RA->base + | mv_vmstate CARG2, INTERP + | ldr CARG4, L:RA->top + | st_vmstate CARG2 + | cmp CRET1, #LUA_YIELD + | ldr BASE, L->base + | bhi >8 + | subs RC, CARG4, CARG3 + | ldr CARG1, L->maxstack + | add CARG2, BASE, RC + | beq >6 // No results? + | cmp CARG2, CARG1 + | mov RB, #0 + | bhi >9 // Need to grow stack? + | + | sub CARG4, RC, #8 + | str CARG3, L:RA->top // Clear coroutine stack. + |5: // Move results from coroutine. + | ldrd CARG12, [CARG3, RB] + | cmp RB, CARG4 + | strd CARG12, [BASE, RB] + | add RB, RB, #8 + | bne <5 + |6: + |.if resume + | mvn CARG3, #~LJ_TTRUE + | add RC, RC, #16 + |7: + | str CARG3, [BASE, #-4] // Prepend true/false to results. + | sub RA, BASE, #8 + |.else + | mov RA, BASE + | add RC, RC, #8 + |.endif + | ands CARG1, PC, #FRAME_TYPE + | str PC, SAVE_PC + | str RC, SAVE_MULTRES + | beq ->BC_RET_Z + | b ->vm_return + | + |8: // Coroutine returned with error (at co->top-1). + |.if resume + | ldrd CARG12, [CARG4, #-8]! + | mvn CARG3, #~LJ_TFALSE + | mov RC, #(2+1)*8 + | str CARG4, L:RA->top // Remove error from coroutine stack. + | strd CARG12, [BASE] // Copy error message. + | b <7 + |.else + | mov CARG1, L + | mov CARG2, L:RA + | bl extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) + | // Never returns. + |.endif + | + |9: // Handle stack expansion on return from yield. + | mov CARG1, L + | lsr CARG2, RC, #3 + | bl extern lj_state_growstack // (lua_State *L, int n) + | mov CRET1, #0 + | b <4 + |.endmacro + | + | coroutine_resume_wrap 1 // coroutine.resume + | coroutine_resume_wrap 0 // coroutine.wrap + | + |.ffunc coroutine_yield + | ldr CARG1, L->cframe + | add CARG2, BASE, NARGS8:RC + | str BASE, L->base + | tst CARG1, #CFRAME_RESUME + | str CARG2, L->top + | mov CRET1, #LUA_YIELD + | mov CARG3, #0 + | beq ->fff_fallback + | str CARG3, L->cframe + | strb CRET1, L->status + | b ->vm_leave_unw + | + |//-- Math library ------------------------------------------------------- + | + |.macro math_round, func + | .ffunc_1 math_ .. func + | checktp CARG2, LJ_TISNUM + | beq ->fff_restv + | bhi ->fff_fallback + | // Round FP value and normalize result. + | lsl CARG3, CARG2, #1 + | adds RB, CARG3, #0x00200000 + | bpl >2 // |x| < 1? + | mvn CARG4, #0x3e0 + | subs RB, CARG4, RB, asr #21 + | lsl CARG4, CARG2, #11 + | lsl CARG3, CARG1, #11 + | orr CARG4, CARG4, #0x80000000 + | rsb INS, RB, #32 + | orr CARG4, CARG4, CARG1, lsr #21 + | bls >3 // |x| >= 2^31? + | orr CARG3, CARG3, CARG4, lsl INS + | lsr CARG1, CARG4, RB + |.if "func" == "floor" + | tst CARG3, CARG2, asr #31 + | addne CARG1, CARG1, #1 + |.else + | bics CARG3, CARG3, CARG2, asr #31 + | addsne CARG1, CARG1, #1 + | ldrdvs CARG12, >9 + | bvs ->fff_restv + |.endif + | cmp CARG2, #0 + | rsblt CARG1, CARG1, #0 + |1: + | mvn CARG2, #~LJ_TISNUM + | b ->fff_restv + | + |2: // |x| < 1 + | bcs ->fff_restv // |x| is not finite. + | orr CARG3, CARG3, CARG1 // ztest = abs(hi) | lo + |.if "func" == "floor" + | tst CARG3, CARG2, asr #31 // return (ztest & sign) == 0 ? 0 : -1 + | moveq CARG1, #0 + | mvnne CARG1, #0 + |.else + | bics CARG3, CARG3, CARG2, asr #31 // return (ztest & ~sign) == 0 ? 0 : 1 + | moveq CARG1, #0 + | movne CARG1, #1 + |.endif + | mvn CARG2, #~LJ_TISNUM + | b ->fff_restv + | + |3: // |x| >= 2^31. Check for x == -(2^31). + | cmpeq CARG4, #0x80000000 + |.if "func" == "floor" + | cmpeq CARG3, #0 + |.endif + | bne >4 + | cmp CARG2, #0 + | movmi CARG1, #0x80000000 + | bmi <1 + |4: + | bl ->vm_..func.._sf + | b ->fff_restv + |.endmacro + | + | math_round floor + | math_round ceil + | + |.align 8 + |9: + | .long 0x00000000, 0x41e00000 // 2^31. + | + |.ffunc_1 math_abs + | checktp CARG2, LJ_TISNUM + | bhi ->fff_fallback + | bicne CARG2, CARG2, #0x80000000 + | bne ->fff_restv + | cmp CARG1, #0 + | rsbslt CARG1, CARG1, #0 + | ldrdvs CARG12, <9 + | // Fallthrough. + | + |->fff_restv: + | // CARG12 = TValue result. + | ldr PC, [BASE, FRAME_PC] + | strd CARG12, [BASE, #-8] + |->fff_res1: + | // PC = return. + | mov RC, #(1+1)*8 + |->fff_res: + | // RC = (nresults+1)*8, PC = return. + | ands CARG1, PC, #FRAME_TYPE + | ldreq INS, [PC, #-4] + | str RC, SAVE_MULTRES + | sub RA, BASE, #8 + | bne ->vm_return + | decode_RB8 RB, INS + |5: + | cmp RB, RC // More results expected? + | bhi >6 + | decode_RA8 CARG1, INS + | ins_next1 + | ins_next2 + | // Adjust BASE. KBASE is assumed to be set for the calling frame. + | sub BASE, RA, CARG1 + | ins_next3 + | + |6: // Fill up results with nil. + | add CARG2, RA, RC + | mvn CARG1, #~LJ_TNIL + | add RC, RC, #8 + | str CARG1, [CARG2, #-4] + | b <5 + | + |.macro math_extern, func + |.if HFABI + | .ffunc_d math_ .. func + |.else + | .ffunc_n math_ .. func + |.endif + | .IOS mov RA, BASE + | bl extern func + | .IOS mov BASE, RA + |.if HFABI + | b ->fff_resd + |.else + | b ->fff_restv + |.endif + |.endmacro + | + |.macro math_extern2, func + |.if HFABI + | .ffunc_dd math_ .. func + |.else + | .ffunc_nn math_ .. func + |.endif + | .IOS mov RA, BASE + | bl extern func + | .IOS mov BASE, RA + |.if HFABI + | b ->fff_resd + |.else + | b ->fff_restv + |.endif + |.endmacro + | + |.if FPU + | .ffunc_d math_sqrt + | vsqrt.f64 d0, d0 + |->fff_resd: + | ldr PC, [BASE, FRAME_PC] + | vstr d0, [BASE, #-8] + | b ->fff_res1 + |.else + | math_extern sqrt + |.endif + | + |.ffunc math_log + |.if HFABI + | ldr CARG2, [BASE, #4] + | cmp NARGS8:RC, #8 // Need exactly 1 argument. + | vldr d0, [BASE] + | bne ->fff_fallback + |.else + | ldrd CARG12, [BASE] + | cmp NARGS8:RC, #8 // Need exactly 1 argument. + | bne ->fff_fallback + |.endif + | checktp CARG2, LJ_TISNUM + | bhs ->fff_fallback + | .IOS mov RA, BASE + | bl extern log + | .IOS mov BASE, RA + |.if HFABI + | b ->fff_resd + |.else + | b ->fff_restv + |.endif + | + | math_extern log10 + | math_extern exp + | math_extern sin + | math_extern cos + | math_extern tan + | math_extern asin + | math_extern acos + | math_extern atan + | math_extern sinh + | math_extern cosh + | math_extern tanh + | math_extern2 pow + | math_extern2 atan2 + | math_extern2 fmod + | + |->ff_math_deg: + |.if FPU + | .ffunc_d math_rad + | vldr d1, CFUNC:CARG3->upvalue[0] + | vmul.f64 d0, d0, d1 + | b ->fff_resd + |.else + | .ffunc_n math_rad + | ldrd CARG34, CFUNC:CARG3->upvalue[0] + | bl extern __aeabi_dmul + | b ->fff_restv + |.endif + | + |.if HFABI + | .ffunc math_ldexp + | ldr CARG4, [BASE, #4] + | ldrd CARG12, [BASE, #8] + | cmp NARGS8:RC, #16 + | blo ->fff_fallback + | vldr d0, [BASE] + | checktp CARG4, LJ_TISNUM + | bhs ->fff_fallback + | checktp CARG2, LJ_TISNUM + | bne ->fff_fallback + | .IOS mov RA, BASE + | bl extern ldexp // (double x, int exp) + | .IOS mov BASE, RA + | b ->fff_resd + |.else + |.ffunc_2 math_ldexp + | checktp CARG2, LJ_TISNUM + | bhs ->fff_fallback + | checktp CARG4, LJ_TISNUM + | bne ->fff_fallback + | .IOS mov RA, BASE + | bl extern ldexp // (double x, int exp) + | .IOS mov BASE, RA + | b ->fff_restv + |.endif + | + |.if HFABI + |.ffunc_d math_frexp + | mov CARG1, sp + | .IOS mov RA, BASE + | bl extern frexp + | .IOS mov BASE, RA + | ldr CARG3, [sp] + | mvn CARG4, #~LJ_TISNUM + | ldr PC, [BASE, FRAME_PC] + | vstr d0, [BASE, #-8] + | mov RC, #(2+1)*8 + | strd CARG34, [BASE] + | b ->fff_res + |.else + |.ffunc_n math_frexp + | mov CARG3, sp + | .IOS mov RA, BASE + | bl extern frexp + | .IOS mov BASE, RA + | ldr CARG3, [sp] + | mvn CARG4, #~LJ_TISNUM + | ldr PC, [BASE, FRAME_PC] + | strd CARG12, [BASE, #-8] + | mov RC, #(2+1)*8 + | strd CARG34, [BASE] + | b ->fff_res + |.endif + | + |.if HFABI + |.ffunc_d math_modf + | sub CARG1, BASE, #8 + | ldr PC, [BASE, FRAME_PC] + | .IOS mov RA, BASE + | bl extern modf + | .IOS mov BASE, RA + | mov RC, #(2+1)*8 + | vstr d0, [BASE] + | b ->fff_res + |.else + |.ffunc_n math_modf + | sub CARG3, BASE, #8 + | ldr PC, [BASE, FRAME_PC] + | .IOS mov RA, BASE + | bl extern modf + | .IOS mov BASE, RA + | mov RC, #(2+1)*8 + | strd CARG12, [BASE] + | b ->fff_res + |.endif + | + |.macro math_minmax, name, cond, fcond + |.if FPU + | .ffunc_1 name + | add RB, BASE, RC + | checktp CARG2, LJ_TISNUM + | add RA, BASE, #8 + | bne >4 + |1: // Handle integers. + | ldrd CARG34, [RA] + | cmp RA, RB + | bhs ->fff_restv + | checktp CARG4, LJ_TISNUM + | bne >3 + | cmp CARG1, CARG3 + | add RA, RA, #8 + | mov..cond CARG1, CARG3 + | b <1 + |3: // Convert intermediate result to number and continue below. + | vmov s4, CARG1 + | bhi ->fff_fallback + | vldr d1, [RA] + | vcvt.f64.s32 d0, s4 + | b >6 + | + |4: + | vldr d0, [BASE] + | bhi ->fff_fallback + |5: // Handle numbers. + | ldrd CARG34, [RA] + | vldr d1, [RA] + | cmp RA, RB + | bhs ->fff_resd + | checktp CARG4, LJ_TISNUM + | bhs >7 + |6: + | vcmp.f64 d0, d1 + | vmrs + | add RA, RA, #8 + | vmov..fcond.f64 d0, d1 + | b <5 + |7: // Convert integer to number and continue above. + | vmov s4, CARG3 + | bhi ->fff_fallback + | vcvt.f64.s32 d1, s4 + | b <6 + | + |.else + | + | .ffunc_1 name + | checktp CARG2, LJ_TISNUM + | mov RA, #8 + | bne >4 + |1: // Handle integers. + | ldrd CARG34, [BASE, RA] + | cmp RA, RC + | bhs ->fff_restv + | checktp CARG4, LJ_TISNUM + | bne >3 + | cmp CARG1, CARG3 + | add RA, RA, #8 + | mov..cond CARG1, CARG3 + | b <1 + |3: // Convert intermediate result to number and continue below. + | bhi ->fff_fallback + | bl extern __aeabi_i2d + | ldrd CARG34, [BASE, RA] + | b >6 + | + |4: + | bhi ->fff_fallback + |5: // Handle numbers. + | ldrd CARG34, [BASE, RA] + | cmp RA, RC + | bhs ->fff_restv + | checktp CARG4, LJ_TISNUM + | bhs >7 + |6: + | bl extern __aeabi_cdcmple + | add RA, RA, #8 + | mov..fcond CARG1, CARG3 + | mov..fcond CARG2, CARG4 + | b <5 + |7: // Convert integer to number and continue above. + | bhi ->fff_fallback + | strd CARG12, TMPD + | mov CARG1, CARG3 + | bl extern __aeabi_i2d + | ldrd CARG34, TMPD + | b <6 + |.endif + |.endmacro + | + | math_minmax math_min, gt, hi + | math_minmax math_max, lt, lo + | + |//-- String library ----------------------------------------------------- + | + |.ffunc_1 string_len + | checkstr CARG2, ->fff_fallback + | ldr CARG1, STR:CARG1->len + | mvn CARG2, #~LJ_TISNUM + | b ->fff_restv + | + |.ffunc string_byte // Only handle the 1-arg case here. + | ldrd CARG12, [BASE] + | ldr PC, [BASE, FRAME_PC] + | cmp NARGS8:RC, #8 + | checktpeq CARG2, LJ_TSTR // Need exactly 1 argument. + | bne ->fff_fallback + | ldr CARG3, STR:CARG1->len + | ldrb CARG1, STR:CARG1[1] // Access is always ok (NUL at end). + | mvn CARG2, #~LJ_TISNUM + | cmp CARG3, #0 + | moveq RC, #(0+1)*8 + | movne RC, #(1+1)*8 + | strd CARG12, [BASE, #-8] + | b ->fff_res + | + |.ffunc string_char // Only handle the 1-arg case here. + | ffgccheck + | ldrd CARG12, [BASE] + | ldr PC, [BASE, FRAME_PC] + | cmp NARGS8:RC, #8 // Need exactly 1 argument. + | checktpeq CARG2, LJ_TISNUM + | bicseq CARG4, CARG1, #255 + | mov CARG3, #1 + | bne ->fff_fallback + | str CARG1, TMPD + | mov CARG2, TMPDp // Points to stack. Little-endian. + |->fff_newstr: + | // CARG2 = str, CARG3 = len. + | str BASE, L->base + | mov CARG1, L + | str PC, SAVE_PC + | bl extern lj_str_new // (lua_State *L, char *str, size_t l) + | // Returns GCstr *. + | ldr BASE, L->base + | mvn CARG2, #~LJ_TSTR + | b ->fff_restv + | + |.ffunc string_sub + | ffgccheck + | ldrd CARG12, [BASE] + | ldrd CARG34, [BASE, #16] + | cmp NARGS8:RC, #16 + | mvn RB, #0 + | beq >1 + | blo ->fff_fallback + | checktp CARG4, LJ_TISNUM + | mov RB, CARG3 + | bne ->fff_fallback + |1: + | ldrd CARG34, [BASE, #8] + | checktp CARG2, LJ_TSTR + | ldreq CARG2, STR:CARG1->len + | checktpeq CARG4, LJ_TISNUM + | bne ->fff_fallback + | // CARG1 = str, CARG2 = str->len, CARG3 = start, RB = end + | add CARG4, CARG2, #1 + | cmp CARG3, #0 // if (start < 0) start += len+1 + | addlt CARG3, CARG3, CARG4 + | cmp CARG3, #1 // if (start < 1) start = 1 + | movlt CARG3, #1 + | cmp RB, #0 // if (end < 0) end += len+1 + | addlt RB, RB, CARG4 + | bic RB, RB, RB, asr #31 // if (end < 0) end = 0 + | cmp RB, CARG2 // if (end > len) end = len + | add CARG1, STR:CARG1, #sizeof(GCstr)-1 + | movgt RB, CARG2 + | add CARG2, CARG1, CARG3 + | subs CARG3, RB, CARG3 // len = end - start + | add CARG3, CARG3, #1 // len += 1 + | bge ->fff_newstr + |->fff_emptystr: + | sub STR:CARG1, DISPATCH, #-DISPATCH_GL(strempty) + | mvn CARG2, #~LJ_TSTR + | b ->fff_restv + | + |.ffunc string_rep // Only handle the 1-char case inline. + | ffgccheck + | ldrd CARG12, [BASE] + | ldrd CARG34, [BASE, #8] + | cmp NARGS8:RC, #16 + | bne ->fff_fallback // Exactly 2 arguments + | checktp CARG2, LJ_TSTR + | checktpeq CARG4, LJ_TISNUM + | bne ->fff_fallback + | subs CARG4, CARG3, #1 + | ldr CARG2, STR:CARG1->len + | blt ->fff_emptystr // Count <= 0? + | cmp CARG2, #1 + | blo ->fff_emptystr // Zero-length string? + | bne ->fff_fallback // Fallback for > 1-char strings. + | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] + | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] + | ldr CARG1, STR:CARG1[1] + | cmp RB, CARG3 + | blo ->fff_fallback + |1: // Fill buffer with char. + | strb CARG1, [CARG2, CARG4] + | subs CARG4, CARG4, #1 + | bge <1 + | b ->fff_newstr + | + |.ffunc string_reverse + | ffgccheck + | ldrd CARG12, [BASE] + | cmp NARGS8:RC, #8 + | blo ->fff_fallback + | checkstr CARG2, ->fff_fallback + | ldr CARG3, STR:CARG1->len + | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] + | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] + | mov CARG4, CARG3 + | add CARG1, STR:CARG1, #sizeof(GCstr) + | cmp RB, CARG3 + | blo ->fff_fallback + |1: // Reverse string copy. + | ldrb RB, [CARG1], #1 + | subs CARG4, CARG4, #1 + | blt ->fff_newstr + | strb RB, [CARG2, CARG4] + | b <1 + | + |.macro ffstring_case, name, lo + | .ffunc name + | ffgccheck + | ldrd CARG12, [BASE] + | cmp NARGS8:RC, #8 + | blo ->fff_fallback + | checkstr CARG2, ->fff_fallback + | ldr CARG3, STR:CARG1->len + | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] + | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] + | mov CARG4, #0 + | add CARG1, STR:CARG1, #sizeof(GCstr) + | cmp RB, CARG3 + | blo ->fff_fallback + |1: // ASCII case conversion. + | ldrb RB, [CARG1, CARG4] + | cmp CARG4, CARG3 + | bhs ->fff_newstr + | sub RC, RB, #lo + | cmp RC, #26 + | eorlo RB, RB, #0x20 + | strb RB, [CARG2, CARG4] + | add CARG4, CARG4, #1 + | b <1 + |.endmacro + | + |ffstring_case string_lower, 65 + |ffstring_case string_upper, 97 + | + |//-- Table library ------------------------------------------------------ + | + |.ffunc_1 table_getn + | checktab CARG2, ->fff_fallback + | .IOS mov RA, BASE + | bl extern lj_tab_len // (GCtab *t) + | // Returns uint32_t (but less than 2^31). + | .IOS mov BASE, RA + | mvn CARG2, #~LJ_TISNUM + | b ->fff_restv + | + |//-- Bit library -------------------------------------------------------- + | + |// FP number to bit conversion for soft-float. Clobbers r0-r3. + |->vm_tobit_fb: + | bhi ->fff_fallback + |->vm_tobit: + | lsl RB, CARG2, #1 + | adds RB, RB, #0x00200000 + | movpl CARG1, #0 // |x| < 1? + | bxpl lr + | mvn CARG4, #0x3e0 + | subs RB, CARG4, RB, asr #21 + | bmi >1 // |x| >= 2^32? + | lsl CARG4, CARG2, #11 + | orr CARG4, CARG4, #0x80000000 + | orr CARG4, CARG4, CARG1, lsr #21 + | cmp CARG2, #0 + | lsr CARG1, CARG4, RB + | rsblt CARG1, CARG1, #0 + | bx lr + |1: + | add RB, RB, #21 + | lsr CARG4, CARG1, RB + | rsb RB, RB, #20 + | lsl CARG1, CARG2, #12 + | cmp CARG2, #0 + | orr CARG1, CARG4, CARG1, lsl RB + | rsblt CARG1, CARG1, #0 + | bx lr + | + |.macro .ffunc_bit, name + | .ffunc_1 bit_..name + | checktp CARG2, LJ_TISNUM + | blne ->vm_tobit_fb + |.endmacro + | + |.ffunc_bit tobit + | mvn CARG2, #~LJ_TISNUM + | b ->fff_restv + | + |.macro .ffunc_bit_op, name, ins + | .ffunc_bit name + | mov CARG3, CARG1 + | mov RA, #8 + |1: + | ldrd CARG12, [BASE, RA] + | cmp RA, NARGS8:RC + | add RA, RA, #8 + | bge >2 + | checktp CARG2, LJ_TISNUM + | blne ->vm_tobit_fb + | ins CARG3, CARG3, CARG1 + | b <1 + |.endmacro + | + |.ffunc_bit_op band, and + |.ffunc_bit_op bor, orr + |.ffunc_bit_op bxor, eor + | + |2: + | mvn CARG4, #~LJ_TISNUM + | ldr PC, [BASE, FRAME_PC] + | strd CARG34, [BASE, #-8] + | b ->fff_res1 + | + |.ffunc_bit bswap + | eor CARG3, CARG1, CARG1, ror #16 + | bic CARG3, CARG3, #0x00ff0000 + | ror CARG1, CARG1, #8 + | mvn CARG2, #~LJ_TISNUM + | eor CARG1, CARG1, CARG3, lsr #8 + | b ->fff_restv + | + |.ffunc_bit bnot + | mvn CARG1, CARG1 + | mvn CARG2, #~LJ_TISNUM + | b ->fff_restv + | + |.macro .ffunc_bit_sh, name, ins, shmod + | .ffunc bit_..name + | ldrd CARG12, [BASE, #8] + | cmp NARGS8:RC, #16 + | blo ->fff_fallback + | checktp CARG2, LJ_TISNUM + | blne ->vm_tobit_fb + |.if shmod == 0 + | and RA, CARG1, #31 + |.else + | rsb RA, CARG1, #0 + |.endif + | ldrd CARG12, [BASE] + | checktp CARG2, LJ_TISNUM + | blne ->vm_tobit_fb + | ins CARG1, CARG1, RA + | mvn CARG2, #~LJ_TISNUM + | b ->fff_restv + |.endmacro + | + |.ffunc_bit_sh lshift, lsl, 0 + |.ffunc_bit_sh rshift, lsr, 0 + |.ffunc_bit_sh arshift, asr, 0 + |.ffunc_bit_sh rol, ror, 1 + |.ffunc_bit_sh ror, ror, 0 + | + |//----------------------------------------------------------------------- + | + |->fff_fallback: // Call fast function fallback handler. + | // BASE = new base, RC = nargs*8 + | ldr CARG3, [BASE, FRAME_FUNC] + | ldr CARG2, L->maxstack + | add CARG1, BASE, NARGS8:RC + | ldr PC, [BASE, FRAME_PC] // Fallback may overwrite PC. + | str CARG1, L->top + | ldr CARG3, CFUNC:CARG3->f + | str BASE, L->base + | add CARG1, CARG1, #8*LUA_MINSTACK + | str PC, SAVE_PC // Redundant (but a defined value). + | cmp CARG1, CARG2 + | mov CARG1, L + | bhi >5 // Need to grow stack. + | blx CARG3 // (lua_State *L) + | // Either throws an error, or recovers and returns -1, 0 or nresults+1. + | ldr BASE, L->base + | cmp CRET1, #0 + | lsl RC, CRET1, #3 + | sub RA, BASE, #8 + | bgt ->fff_res // Returned nresults+1? + |1: // Returned 0 or -1: retry fast path. + | ldr CARG1, L->top + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] + | sub NARGS8:RC, CARG1, BASE + | bne ->vm_call_tail // Returned -1? + | ins_callt // Returned 0: retry fast path. + | + |// Reconstruct previous base for vmeta_call during tailcall. + |->vm_call_tail: + | ands CARG1, PC, #FRAME_TYPE + | bic CARG2, PC, #FRAME_TYPEP + | ldreq INS, [PC, #-4] + | andeq CARG2, MASKR8, INS, lsr #5 // Conditional decode_RA8. + | addeq CARG2, CARG2, #8 + | sub RB, BASE, CARG2 + | b ->vm_call_dispatch // Resolve again for tailcall. + | + |5: // Grow stack for fallback handler. + | mov CARG2, #LUA_MINSTACK + | bl extern lj_state_growstack // (lua_State *L, int n) + | ldr BASE, L->base + | cmp CARG1, CARG1 // Set zero-flag to force retry. + | b <1 + | + |->fff_gcstep: // Call GC step function. + | // BASE = new base, RC = nargs*8 + | mov RA, lr + | str BASE, L->base + | add CARG2, BASE, NARGS8:RC + | str PC, SAVE_PC // Redundant (but a defined value). + | str CARG2, L->top + | mov CARG1, L + | bl extern lj_gc_step // (lua_State *L) + | ldr BASE, L->base + | mov lr, RA // Help return address predictor. + | ldr CFUNC:CARG3, [BASE, FRAME_FUNC] + | bx lr + | + |//----------------------------------------------------------------------- + |//-- Special dispatch targets ------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_record: // Dispatch target for recording phase. + |.if JIT + | ldrb CARG1, [DISPATCH, #DISPATCH_GL(hookmask)] + | tst CARG1, #HOOK_VMEVENT // No recording while in vmevent. + | bne >5 + | // Decrement the hookcount for consistency, but always do the call. + | ldr CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] + | tst CARG1, #HOOK_ACTIVE + | bne >1 + | sub CARG2, CARG2, #1 + | tst CARG1, #LUA_MASKLINE|LUA_MASKCOUNT + | strne CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] + | b >1 + |.endif + | + |->vm_rethook: // Dispatch target for return hooks. + | ldrb CARG1, [DISPATCH, #DISPATCH_GL(hookmask)] + | tst CARG1, #HOOK_ACTIVE // Hook already active? + | beq >1 + |5: // Re-dispatch to static ins. + | decode_OP OP, INS + | add OP, DISPATCH, OP, lsl #2 + | ldr pc, [OP, #GG_DISP2STATIC] + | + |->vm_inshook: // Dispatch target for instr/line hooks. + | ldrb CARG1, [DISPATCH, #DISPATCH_GL(hookmask)] + | ldr CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] + | tst CARG1, #HOOK_ACTIVE // Hook already active? + | bne <5 + | tst CARG1, #LUA_MASKLINE|LUA_MASKCOUNT + | beq <5 + | subs CARG2, CARG2, #1 + | str CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] + | beq >1 + | tst CARG1, #LUA_MASKLINE + | beq <5 + |1: + | mov CARG1, L + | str BASE, L->base + | mov CARG2, PC + | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. + | bl extern lj_dispatch_ins // (lua_State *L, const BCIns *pc) + |3: + | ldr BASE, L->base + |4: // Re-dispatch to static ins. + | ldrb OP, [PC, #-4] + | ldr INS, [PC, #-4] + | add OP, DISPATCH, OP, lsl #2 + | ldr OP, [OP, #GG_DISP2STATIC] + | decode_RA8 RA, INS + | decode_RD RC, INS + | bx OP + | + |->cont_hook: // Continue from hook yield. + | ldr CARG1, [CARG4, #-24] + | add PC, PC, #4 + | str CARG1, SAVE_MULTRES // Restore MULTRES for *M ins. + | b <4 + | + |->vm_hotloop: // Hot loop counter underflow. + |.if JIT + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Same as curr_topL(L). + | sub CARG1, DISPATCH, #-GG_DISP2J + | str PC, SAVE_PC + | ldr CARG3, LFUNC:CARG3->field_pc + | mov CARG2, PC + | str L, [DISPATCH, #DISPATCH_J(L)] + | ldrb CARG3, [CARG3, #PC2PROTO(framesize)] + | str BASE, L->base + | add CARG3, BASE, CARG3, lsl #3 + | str CARG3, L->top + | bl extern lj_trace_hot // (jit_State *J, const BCIns *pc) + | b <3 + |.endif + | + |->vm_callhook: // Dispatch target for call hooks. + | mov CARG2, PC + |.if JIT + | b >1 + |.endif + | + |->vm_hotcall: // Hot call counter underflow. + |.if JIT + | orr CARG2, PC, #1 + |1: + |.endif + | add CARG4, BASE, RC + | str PC, SAVE_PC + | mov CARG1, L + | str BASE, L->base + | sub RA, RA, BASE + | str CARG4, L->top + | bl extern lj_dispatch_call // (lua_State *L, const BCIns *pc) + | // Returns ASMFunction. + | ldr BASE, L->base + | ldr CARG4, L->top + | mov CARG2, #0 + | add RA, BASE, RA + | sub NARGS8:RC, CARG4, BASE + | str CARG2, SAVE_PC // Invalidate for subsequent line hook. + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] + | ldr INS, [PC, #-4] + | bx CRET1 + | + |//----------------------------------------------------------------------- + |//-- Trace exit handler ------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_exit_handler: + |.if JIT + | sub sp, sp, #12 + | push {r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12} + | ldr CARG1, [sp, #64] // Load original value of lr. + | ldr DISPATCH, [lr] // Load DISPATCH. + | add CARG3, sp, #64 // Recompute original value of sp. + | mv_vmstate CARG4, EXIT + | str CARG3, [sp, #52] // Store sp in RID_SP + | st_vmstate CARG4 + | ldr CARG2, [CARG1, #-4]! // Get exit instruction. + | str CARG1, [sp, #56] // Store exit pc in RID_LR and RID_PC. + | str CARG1, [sp, #60] + |.if FPU + | vpush {d0-d15} + |.endif + | lsl CARG2, CARG2, #8 + | add CARG1, CARG1, CARG2, asr #6 + | ldr CARG2, [lr, #4] // Load exit stub group offset. + | sub CARG1, CARG1, lr + | ldr L, [DISPATCH, #DISPATCH_GL(jit_L)] + | add CARG1, CARG2, CARG1, lsr #2 // Compute exit number. + | ldr BASE, [DISPATCH, #DISPATCH_GL(jit_base)] + | str CARG1, [DISPATCH, #DISPATCH_J(exitno)] + | mov CARG4, #0 + | str L, [DISPATCH, #DISPATCH_J(L)] + | str BASE, L->base + | str CARG4, [DISPATCH, #DISPATCH_GL(jit_L)] + | sub CARG1, DISPATCH, #-GG_DISP2J + | mov CARG2, sp + | bl extern lj_trace_exit // (jit_State *J, ExitState *ex) + | // Returns MULTRES (unscaled) or negated error code. + | ldr CARG2, L->cframe + | ldr BASE, L->base + | bic CARG2, CARG2, #~CFRAME_RAWMASK // Use two steps: bic sp is deprecated. + | mov sp, CARG2 + | ldr PC, SAVE_PC // Get SAVE_PC. + | str L, SAVE_L // Set SAVE_L (on-trace resume/yield). + | b >1 + |.endif + |->vm_exit_interp: + | // CARG1 = MULTRES or negated error code, BASE, PC and DISPATCH set. + |.if JIT + | ldr L, SAVE_L + |1: + | cmp CARG1, #0 + | blt >3 // Check for error from exit. + | lsl RC, CARG1, #3 + | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] + | str RC, SAVE_MULTRES + | mov CARG3, #0 + | ldr CARG2, LFUNC:CARG2->field_pc + | str CARG3, [DISPATCH, #DISPATCH_GL(jit_L)] + | mv_vmstate CARG4, INTERP + | ldr KBASE, [CARG2, #PC2PROTO(k)] + | // Modified copy of ins_next which handles function header dispatch, too. + | ldrb OP, [PC] + | mov MASKR8, #255 + | ldr INS, [PC], #4 + | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. + | st_vmstate CARG4 + | cmp OP, #BC_FUNCF // Function header? + | ldr OP, [DISPATCH, OP, lsl #2] + | decode_RA8 RA, INS + | lsrlo RC, INS, #16 // No: Decode operands A*8 and D. + | subhs RC, RC, #8 + | addhs RA, RA, BASE // Yes: RA = BASE+framesize*8, RC = nargs*8 + | bx OP + | + |3: // Rethrow error from the right C frame. + | rsb CARG2, CARG1, #0 + | mov CARG1, L + | bl extern lj_err_throw // (lua_State *L, int errcode) + |.endif + | + |//----------------------------------------------------------------------- + |//-- Math helper functions ---------------------------------------------- + |//----------------------------------------------------------------------- + | + |// FP value rounding. Called from JIT code. + |// + |// double lj_vm_floor/ceil/trunc(double x); + |.macro vm_round, func, hf + |.if hf == 1 + | vmov CARG1, CARG2, d0 + |.endif + | lsl CARG3, CARG2, #1 + | adds RB, CARG3, #0x00200000 + | bpl >2 // |x| < 1? + | mvn CARG4, #0x3cc + | subs RB, CARG4, RB, asr #21 // 2^0: RB = 51, 2^51: RB = 0. + | bxlo lr // |x| >= 2^52: done. + | mvn CARG4, #1 + | bic CARG3, CARG1, CARG4, lsl RB // ztest = lo & ~lomask + | and CARG1, CARG1, CARG4, lsl RB // lo &= lomask + | subs RB, RB, #32 + | bicpl CARG4, CARG2, CARG4, lsl RB // |x| <= 2^20: ztest |= hi & ~himask + | orrpl CARG3, CARG3, CARG4 + | mvnpl CARG4, #1 + | andpl CARG2, CARG2, CARG4, lsl RB // |x| <= 2^20: hi &= himask + |.if "func" == "floor" + | tst CARG3, CARG2, asr #31 // iszero = ((ztest & signmask) == 0) + |.else + | bics CARG3, CARG3, CARG2, asr #31 // iszero = ((ztest & ~signmask) == 0) + |.endif + |.if hf == 1 + | vmoveq d0, CARG1, CARG2 + |.endif + | bxeq lr // iszero: done. + | mvn CARG4, #1 + | cmp RB, #0 + | lslpl CARG3, CARG4, RB + | mvnmi CARG3, #0 + | add RB, RB, #32 + | subs CARG1, CARG1, CARG4, lsl RB // lo = lo-lomask + | sbc CARG2, CARG2, CARG3 // hi = hi-himask+carry + |.if hf == 1 + | vmov d0, CARG1, CARG2 + |.endif + | bx lr + | + |2: // |x| < 1: + | bxcs lr // |x| is not finite. + | orr CARG3, CARG3, CARG1 // ztest = (2*hi) | lo + |.if "func" == "floor" + | tst CARG3, CARG2, asr #31 // iszero = ((ztest & signmask) == 0) + |.else + | bics CARG3, CARG3, CARG2, asr #31 // iszero = ((ztest & ~signmask) == 0) + |.endif + | mov CARG1, #0 // lo = 0 + | and CARG2, CARG2, #0x80000000 + | ldrne CARG4, <9 // hi = sign(x) | (iszero ? 0.0 : 1.0) + | orrne CARG2, CARG2, CARG4 + |.if hf == 1 + | vmov d0, CARG1, CARG2 + |.endif + | bx lr + |.endmacro + | + |9: + | .long 0x3ff00000 // hiword(+1.0) + | + |->vm_floor: + |.if HFABI + | vm_round floor, 1 + |.endif + |->vm_floor_sf: + | vm_round floor, 0 + | + |->vm_ceil: + |.if HFABI + | vm_round ceil, 1 + |.endif + |->vm_ceil_sf: + | vm_round ceil, 0 + | + |.macro vm_trunc, hf + |.if JIT + |.if hf == 1 + | vmov CARG1, CARG2, d0 + |.endif + | lsl CARG3, CARG2, #1 + | adds RB, CARG3, #0x00200000 + | andpl CARG2, CARG2, #0x80000000 // |x| < 1? hi = sign(x), lo = 0. + | movpl CARG1, #0 + |.if hf == 1 + | vmovpl d0, CARG1, CARG2 + |.endif + | bxpl lr + | mvn CARG4, #0x3cc + | subs RB, CARG4, RB, asr #21 // 2^0: RB = 51, 2^51: RB = 0. + | bxlo lr // |x| >= 2^52: already done. + | mvn CARG4, #1 + | and CARG1, CARG1, CARG4, lsl RB // lo &= lomask + | subs RB, RB, #32 + | andpl CARG2, CARG2, CARG4, lsl RB // |x| <= 2^20: hi &= himask + |.if hf == 1 + | vmov d0, CARG1, CARG2 + |.endif + | bx lr + |.endif + |.endmacro + | + |->vm_trunc: + |.if HFABI + | vm_trunc 1 + |.endif + |->vm_trunc_sf: + | vm_trunc 0 + | + | // double lj_vm_mod(double dividend, double divisor); + |->vm_mod: + |.if FPU + | // Special calling convention. Also, RC (r11) is not preserved. + | vdiv.f64 d0, d6, d7 + | mov RC, lr + | vmov CARG1, CARG2, d0 + | bl ->vm_floor_sf + | vmov d0, CARG1, CARG2 + | vmul.f64 d0, d0, d7 + | mov lr, RC + | vsub.f64 d6, d6, d0 + | bx lr + |.else + | push {r0, r1, r2, r3, r4, lr} + | bl extern __aeabi_ddiv + | bl ->vm_floor_sf + | ldrd CARG34, [sp, #8] + | bl extern __aeabi_dmul + | ldrd CARG34, [sp] + | eor CARG2, CARG2, #0x80000000 + | bl extern __aeabi_dadd + | add sp, sp, #20 + | pop {pc} + |.endif + | + | // int lj_vm_modi(int dividend, int divisor); + |->vm_modi: + | ands RB, CARG1, #0x80000000 + | rsbmi CARG1, CARG1, #0 // a = |dividend| + | eor RB, RB, CARG2, asr #1 // Keep signdiff and sign(divisor). + | cmp CARG2, #0 + | rsbmi CARG2, CARG2, #0 // b = |divisor| + | subs CARG4, CARG2, #1 + | cmpne CARG1, CARG2 + | moveq CARG1, #0 // if (b == 1 || a == b) a = 0 + | tsthi CARG2, CARG4 + | andeq CARG1, CARG1, CARG4 // else if ((b & (b-1)) == 0) a &= b-1 + | bls >1 + | // Use repeated subtraction to get the remainder. + | clz CARG3, CARG1 + | clz CARG4, CARG2 + | sub CARG4, CARG4, CARG3 + | rsbs CARG3, CARG4, #31 // entry = (31-(clz(b)-clz(a)))*8 + | addne pc, pc, CARG3, lsl #3 // Duff's device. + | nop + { + int i; + for (i = 31; i >= 0; i--) { + | cmp CARG1, CARG2, lsl #i + | subhs CARG1, CARG1, CARG2, lsl #i + } + } + |1: + | cmp CARG1, #0 + | cmpne RB, #0 + | submi CARG1, CARG1, CARG2 // if (y != 0 && signdiff) y = y - b + | eors CARG2, CARG1, RB, lsl #1 + | rsbmi CARG1, CARG1, #0 // if (sign(divisor) != sign(y)) y = -y + | bx lr + | + |//----------------------------------------------------------------------- + |//-- Miscellaneous functions -------------------------------------------- + |//----------------------------------------------------------------------- + | + |//----------------------------------------------------------------------- + |//-- FFI helper functions ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |// Handler for callback functions. + |// Saveregs already performed. Callback slot number in [sp], g in r12. + |->vm_ffi_callback: + |.if FFI + |.type CTSTATE, CTState, PC + | ldr CTSTATE, GL:r12->ctype_state + | add DISPATCH, r12, #GG_G2DISP + |.if FPU + | str r4, SAVE_R4 + | add r4, sp, CFRAME_SPACE+4+8*8 + | vstmdb r4!, {d8-d15} + |.endif + |.if HFABI + | add r12, CTSTATE, #offsetof(CTState, cb.fpr[8]) + |.endif + | strd CARG34, CTSTATE->cb.gpr[2] + | strd CARG12, CTSTATE->cb.gpr[0] + |.if HFABI + | vstmdb r12!, {d0-d7} + |.endif + | ldr CARG4, [sp] + | add CARG3, sp, #CFRAME_SIZE + | mov CARG1, CTSTATE + | lsr CARG4, CARG4, #3 + | str CARG3, CTSTATE->cb.stack + | mov CARG2, sp + | str CARG4, CTSTATE->cb.slot + | str CTSTATE, SAVE_PC // Any value outside of bytecode is ok. + | bl extern lj_ccallback_enter // (CTState *cts, void *cf) + | // Returns lua_State *. + | ldr BASE, L:CRET1->base + | mv_vmstate CARG2, INTERP + | ldr RC, L:CRET1->top + | mov MASKR8, #255 + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] + | mov L, CRET1 + | sub RC, RC, BASE + | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. + | st_vmstate CARG2 + | ins_callt + |.endif + | + |->cont_ffi_callback: // Return from FFI callback. + |.if FFI + | ldr CTSTATE, [DISPATCH, #DISPATCH_GL(ctype_state)] + | str BASE, L->base + | str CARG4, L->top + | str L, CTSTATE->L + | mov CARG1, CTSTATE + | mov CARG2, RA + | bl extern lj_ccallback_leave // (CTState *cts, TValue *o) + | ldrd CARG12, CTSTATE->cb.gpr[0] + |.if HFABI + | vldr d0, CTSTATE->cb.fpr[0] + |.endif + | b ->vm_leave_unw + |.endif + | + |->vm_ffi_call: // Call C function via FFI. + | // Caveat: needs special frame unwinding, see below. + |.if FFI + | .type CCSTATE, CCallState, r4 + | push {CCSTATE, r5, r11, lr} + | mov CCSTATE, CARG1 + | ldr CARG1, CCSTATE:CARG1->spadj + | ldrb CARG2, CCSTATE->nsp + | add CARG3, CCSTATE, #offsetof(CCallState, stack) + |.if HFABI + | add RB, CCSTATE, #offsetof(CCallState, fpr[0]) + |.endif + | mov r11, sp + | sub sp, sp, CARG1 // Readjust stack. + | subs CARG2, CARG2, #1 + |.if HFABI + | vldm RB, {d0-d7} + |.endif + | ldr RB, CCSTATE->func + | bmi >2 + |1: // Copy stack slots. + | ldr CARG4, [CARG3, CARG2, lsl #2] + | str CARG4, [sp, CARG2, lsl #2] + | subs CARG2, CARG2, #1 + | bpl <1 + |2: + | ldrd CARG12, CCSTATE->gpr[0] + | ldrd CARG34, CCSTATE->gpr[2] + | blx RB + | mov sp, r11 + |.if HFABI + | add r12, CCSTATE, #offsetof(CCallState, fpr[4]) + |.endif + | strd CRET1, CCSTATE->gpr[0] + |.if HFABI + | vstmdb r12!, {d0-d3} + |.endif + | pop {CCSTATE, r5, r11, pc} + |.endif + |// Note: vm_ffi_call must be the last function in this object file! + | + |//----------------------------------------------------------------------- +} + +/* Generate the code for a single instruction. */ +static void build_ins(BuildCtx *ctx, BCOp op, int defop) +{ + int vk = 0; + |=>defop: + + switch (op) { + + /* -- Comparison ops ---------------------------------------------------- */ + + /* Remember: all ops branch for a true comparison, fall through otherwise. */ + + case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: + | // RA = src1*8, RC = src2, JMP with RC = target + | lsl RC, RC, #3 + | ldrd CARG12, [RA, BASE]! + | ldrh RB, [PC, #2] + | ldrd CARG34, [RC, BASE]! + | add PC, PC, #4 + | add RB, PC, RB, lsl #2 + | checktp CARG2, LJ_TISNUM + | bne >3 + | checktp CARG4, LJ_TISNUM + | bne >4 + | cmp CARG1, CARG3 + if (op == BC_ISLT) { + | sublt PC, RB, #0x20000 + } else if (op == BC_ISGE) { + | subge PC, RB, #0x20000 + } else if (op == BC_ISLE) { + | suble PC, RB, #0x20000 + } else { + | subgt PC, RB, #0x20000 + } + |1: + | ins_next + | + |3: // CARG12 is not an integer. + |.if FPU + | vldr d0, [RA] + | bhi ->vmeta_comp + | // d0 is a number. + | checktp CARG4, LJ_TISNUM + | vldr d1, [RC] + | blo >5 + | bhi ->vmeta_comp + | // d0 is a number, CARG3 is an integer. + | vmov s4, CARG3 + | vcvt.f64.s32 d1, s4 + | b >5 + |4: // CARG1 is an integer, CARG34 is not an integer. + | vldr d1, [RC] + | bhi ->vmeta_comp + | // CARG1 is an integer, d1 is a number. + | vmov s4, CARG1 + | vcvt.f64.s32 d0, s4 + |5: // d0 and d1 are numbers. + | vcmp.f64 d0, d1 + | vmrs + | // To preserve NaN semantics GE/GT branch on unordered, but LT/LE don't. + if (op == BC_ISLT) { + | sublo PC, RB, #0x20000 + } else if (op == BC_ISGE) { + | subhs PC, RB, #0x20000 + } else if (op == BC_ISLE) { + | subls PC, RB, #0x20000 + } else { + | subhi PC, RB, #0x20000 + } + | b <1 + |.else + | bhi ->vmeta_comp + | // CARG12 is a number. + | checktp CARG4, LJ_TISNUM + | movlo RA, RB // Save RB. + | blo >5 + | bhi ->vmeta_comp + | // CARG12 is a number, CARG3 is an integer. + | mov CARG1, CARG3 + | mov RC, RA + | mov RA, RB // Save RB. + | bl extern __aeabi_i2d + | mov CARG3, CARG1 + | mov CARG4, CARG2 + | ldrd CARG12, [RC] // Restore first operand. + | b >5 + |4: // CARG1 is an integer, CARG34 is not an integer. + | bhi ->vmeta_comp + | // CARG1 is an integer, CARG34 is a number. + | mov RA, RB // Save RB. + | bl extern __aeabi_i2d + | ldrd CARG34, [RC] // Restore second operand. + |5: // CARG12 and CARG34 are numbers. + | bl extern __aeabi_cdcmple + | // To preserve NaN semantics GE/GT branch on unordered, but LT/LE don't. + if (op == BC_ISLT) { + | sublo PC, RA, #0x20000 + } else if (op == BC_ISGE) { + | subhs PC, RA, #0x20000 + } else if (op == BC_ISLE) { + | subls PC, RA, #0x20000 + } else { + | subhi PC, RA, #0x20000 + } + | b <1 + |.endif + break; + + case BC_ISEQV: case BC_ISNEV: + vk = op == BC_ISEQV; + | // RA = src1*8, RC = src2, JMP with RC = target + | lsl RC, RC, #3 + | ldrd CARG12, [RA, BASE]! + | ldrh RB, [PC, #2] + | ldrd CARG34, [RC, BASE]! + | add PC, PC, #4 + | add RB, PC, RB, lsl #2 + | checktp CARG2, LJ_TISNUM + | cmnls CARG4, #-LJ_TISNUM + if (vk) { + | bls ->BC_ISEQN_Z + } else { + | bls ->BC_ISNEN_Z + } + | // Either or both types are not numbers. + |.if FFI + | checktp CARG2, LJ_TCDATA + | checktpne CARG4, LJ_TCDATA + | beq ->vmeta_equal_cd + |.endif + | cmp CARG2, CARG4 // Compare types. + | bne >2 // Not the same type? + | checktp CARG2, LJ_TISPRI + | bhs >1 // Same type and primitive type? + | + | // Same types and not a primitive type. Compare GCobj or pvalue. + | cmp CARG1, CARG3 + if (vk) { + | bne >3 // Different GCobjs or pvalues? + |1: // Branch if same. + | sub PC, RB, #0x20000 + |2: // Different. + | ins_next + |3: + | checktp CARG2, LJ_TISTABUD + | bhi <2 // Different objects and not table/ud? + } else { + | beq >1 // Same GCobjs or pvalues? + | checktp CARG2, LJ_TISTABUD + | bhi >2 // Different objects and not table/ud? + } + | // Different tables or userdatas. Need to check __eq metamethod. + | // Field metatable must be at same offset for GCtab and GCudata! + | ldr TAB:RA, TAB:CARG1->metatable + | cmp TAB:RA, #0 + if (vk) { + | beq <2 // No metatable? + } else { + | beq >2 // No metatable? + } + | ldrb RA, TAB:RA->nomm + | mov CARG4, #1-vk // ne = 0 or 1. + | mov CARG2, CARG1 + | tst RA, #1<vmeta_equal // 'no __eq' flag not set? + if (vk) { + | b <2 + } else { + |2: // Branch if different. + | sub PC, RB, #0x20000 + |1: // Same. + | ins_next + } + break; + + case BC_ISEQS: case BC_ISNES: + vk = op == BC_ISEQS; + | // RA = src*8, RC = str_const (~), JMP with RC = target + | mvn RC, RC + | ldrd CARG12, [BASE, RA] + | ldrh RB, [PC, #2] + | ldr STR:CARG3, [KBASE, RC, lsl #2] + | add PC, PC, #4 + | add RB, PC, RB, lsl #2 + | checktp CARG2, LJ_TSTR + |.if FFI + | bne >7 + | cmp CARG1, CARG3 + |.else + | cmpeq CARG1, CARG3 + |.endif + if (vk) { + | subeq PC, RB, #0x20000 + |1: + } else { + |1: + | subne PC, RB, #0x20000 + } + | ins_next + | + |.if FFI + |7: + | checktp CARG2, LJ_TCDATA + | bne <1 + | b ->vmeta_equal_cd + |.endif + break; + + case BC_ISEQN: case BC_ISNEN: + vk = op == BC_ISEQN; + | // RA = src*8, RC = num_const (~), JMP with RC = target + | lsl RC, RC, #3 + | ldrd CARG12, [RA, BASE]! + | ldrh RB, [PC, #2] + | ldrd CARG34, [RC, KBASE]! + | add PC, PC, #4 + | add RB, PC, RB, lsl #2 + if (vk) { + |->BC_ISEQN_Z: + } else { + |->BC_ISNEN_Z: + } + | checktp CARG2, LJ_TISNUM + | bne >3 + | checktp CARG4, LJ_TISNUM + | bne >4 + | cmp CARG1, CARG3 + if (vk) { + | subeq PC, RB, #0x20000 + |1: + } else { + |1: + | subne PC, RB, #0x20000 + } + |2: + | ins_next + | + |3: // CARG12 is not an integer. + |.if FFI + | bhi >7 + |.else + if (!vk) { + | subhi PC, RB, #0x20000 + } + | bhi <2 + |.endif + |.if FPU + | checktp CARG4, LJ_TISNUM + | vmov s4, CARG3 + | vldr d0, [RA] + | vldrlo d1, [RC] + | vcvths.f64.s32 d1, s4 + | b >5 + |4: // CARG1 is an integer, d1 is a number. + | vmov s4, CARG1 + | vldr d1, [RC] + | vcvt.f64.s32 d0, s4 + |5: // d0 and d1 are numbers. + | vcmp.f64 d0, d1 + | vmrs + if (vk) { + | subeq PC, RB, #0x20000 + } else { + | subne PC, RB, #0x20000 + } + | b <2 + |.else + | // CARG12 is a number. + | checktp CARG4, LJ_TISNUM + | movlo RA, RB // Save RB. + | blo >5 + | // CARG12 is a number, CARG3 is an integer. + | mov CARG1, CARG3 + | mov RC, RA + |4: // CARG1 is an integer, CARG34 is a number. + | mov RA, RB // Save RB. + | bl extern __aeabi_i2d + | ldrd CARG34, [RC] // Restore other operand. + |5: // CARG12 and CARG34 are numbers. + | bl extern __aeabi_cdcmpeq + if (vk) { + | subeq PC, RA, #0x20000 + } else { + | subne PC, RA, #0x20000 + } + | b <2 + |.endif + | + |.if FFI + |7: + | checktp CARG2, LJ_TCDATA + | bne <1 + | b ->vmeta_equal_cd + |.endif + break; + + case BC_ISEQP: case BC_ISNEP: + vk = op == BC_ISEQP; + | // RA = src*8, RC = primitive_type (~), JMP with RC = target + | ldrd CARG12, [BASE, RA] + | ldrh RB, [PC, #2] + | add PC, PC, #4 + | mvn RC, RC + | add RB, PC, RB, lsl #2 + |.if FFI + | checktp CARG2, LJ_TCDATA + | beq ->vmeta_equal_cd + |.endif + | cmp CARG2, RC + if (vk) { + | subeq PC, RB, #0x20000 + } else { + | subne PC, RB, #0x20000 + } + | ins_next + break; + + /* -- Unary test and copy ops ------------------------------------------- */ + + case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: + | // RA = dst*8 or unused, RC = src, JMP with RC = target + | add RC, BASE, RC, lsl #3 + | ldrh RB, [PC, #2] + | ldrd CARG12, [RC] + | add PC, PC, #4 + | add RB, PC, RB, lsl #2 + | checktp CARG2, LJ_TTRUE + if (op == BC_ISTC || op == BC_IST) { + | subls PC, RB, #0x20000 + if (op == BC_ISTC) { + | strdls CARG12, [BASE, RA] + } + } else { + | subhi PC, RB, #0x20000 + if (op == BC_ISFC) { + | strdhi CARG12, [BASE, RA] + } + } + | ins_next + break; + + /* -- Unary ops --------------------------------------------------------- */ + + case BC_MOV: + | // RA = dst*8, RC = src + | lsl RC, RC, #3 + | ins_next1 + | ldrd CARG12, [BASE, RC] + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + break; + case BC_NOT: + | // RA = dst*8, RC = src + | add RC, BASE, RC, lsl #3 + | ins_next1 + | ldr CARG1, [RC, #4] + | add RA, BASE, RA + | ins_next2 + | checktp CARG1, LJ_TTRUE + | mvnls CARG2, #~LJ_TFALSE + | mvnhi CARG2, #~LJ_TTRUE + | str CARG2, [RA, #4] + | ins_next3 + break; + case BC_UNM: + | // RA = dst*8, RC = src + | lsl RC, RC, #3 + | ldrd CARG12, [BASE, RC] + | ins_next1 + | ins_next2 + | checktp CARG2, LJ_TISNUM + | bhi ->vmeta_unm + | eorne CARG2, CARG2, #0x80000000 + | bne >5 + | rsbseq CARG1, CARG1, #0 + | ldrdvs CARG12, >9 + |5: + | strd CARG12, [BASE, RA] + | ins_next3 + | + |.align 8 + |9: + | .long 0x00000000, 0x41e00000 // 2^31. + break; + case BC_LEN: + | // RA = dst*8, RC = src + | lsl RC, RC, #3 + | ldrd CARG12, [BASE, RC] + | checkstr CARG2, >2 + | ldr CARG1, STR:CARG1->len + |1: + | mvn CARG2, #~LJ_TISNUM + | ins_next1 + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + |2: + | checktab CARG2, ->vmeta_len +#if LJ_52 + | ldr TAB:CARG3, TAB:CARG1->metatable + | cmp TAB:CARG3, #0 + | bne >9 + |3: +#endif + |->BC_LEN_Z: + | .IOS mov RC, BASE + | bl extern lj_tab_len // (GCtab *t) + | // Returns uint32_t (but less than 2^31). + | .IOS mov BASE, RC + | b <1 +#if LJ_52 + |9: + | ldrb CARG4, TAB:CARG3->nomm + | tst CARG4, #1<vmeta_len +#endif + break; + + /* -- Binary ops -------------------------------------------------------- */ + + |.macro ins_arithcheck, cond, ncond, target + ||if (vk == 1) { + | cmn CARG4, #-LJ_TISNUM + | cmn..cond CARG2, #-LJ_TISNUM + ||} else { + | cmn CARG2, #-LJ_TISNUM + | cmn..cond CARG4, #-LJ_TISNUM + ||} + | b..ncond target + |.endmacro + |.macro ins_arithcheck_int, target + | ins_arithcheck eq, ne, target + |.endmacro + |.macro ins_arithcheck_num, target + | ins_arithcheck lo, hs, target + |.endmacro + | + |.macro ins_arithpre + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 + ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); + ||switch (vk) { + ||case 0: + | .if FPU + | ldrd CARG12, [RB, BASE]! + | ldrd CARG34, [RC, KBASE]! + | .else + | ldrd CARG12, [BASE, RB] + | ldrd CARG34, [KBASE, RC] + | .endif + || break; + ||case 1: + | .if FPU + | ldrd CARG34, [RB, BASE]! + | ldrd CARG12, [RC, KBASE]! + | .else + | ldrd CARG34, [BASE, RB] + | ldrd CARG12, [KBASE, RC] + | .endif + || break; + ||default: + | .if FPU + | ldrd CARG12, [RB, BASE]! + | ldrd CARG34, [RC, BASE]! + | .else + | ldrd CARG12, [BASE, RB] + | ldrd CARG34, [BASE, RC] + | .endif + || break; + ||} + |.endmacro + | + |.macro ins_arithpre_fpu, reg1, reg2 + |.if FPU + ||if (vk == 1) { + | vldr reg2, [RB] + | vldr reg1, [RC] + ||} else { + | vldr reg1, [RB] + | vldr reg2, [RC] + ||} + |.endif + |.endmacro + | + |.macro ins_arithpost_fpu, reg + | ins_next1 + | add RA, BASE, RA + | ins_next2 + | vstr reg, [RA] + | ins_next3 + |.endmacro + | + |.macro ins_arithfallback, ins + ||switch (vk) { + ||case 0: + | ins ->vmeta_arith_vn + || break; + ||case 1: + | ins ->vmeta_arith_nv + || break; + ||default: + | ins ->vmeta_arith_vv + || break; + ||} + |.endmacro + | + |.macro ins_arithdn, intins, fpins, fpcall + | ins_arithpre + |.if "intins" ~= "vm_modi" and not FPU + | ins_next1 + |.endif + | ins_arithcheck_int >5 + |.if "intins" == "smull" + | smull CARG1, RC, CARG3, CARG1 + | cmp RC, CARG1, asr #31 + | ins_arithfallback bne + |.elif "intins" == "vm_modi" + | movs CARG2, CARG3 + | ins_arithfallback beq + | bl ->vm_modi + | mvn CARG2, #~LJ_TISNUM + |.else + | intins CARG1, CARG1, CARG3 + | ins_arithfallback bvs + |.endif + |4: + |.if "intins" == "vm_modi" or FPU + | ins_next1 + |.endif + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + |5: // FP variant. + | ins_arithpre_fpu d6, d7 + | ins_arithfallback ins_arithcheck_num + |.if FPU + |.if "intins" == "vm_modi" + | bl fpcall + |.else + | fpins d6, d6, d7 + |.endif + | ins_arithpost_fpu d6 + |.else + | bl fpcall + |.if "intins" ~= "vm_modi" + | ins_next1 + |.endif + | b <4 + |.endif + |.endmacro + | + |.macro ins_arithfp, fpins, fpcall + | ins_arithpre + |.if "fpins" ~= "extern" or HFABI + | ins_arithpre_fpu d0, d1 + |.endif + | ins_arithfallback ins_arithcheck_num + |.if "fpins" == "extern" + | .IOS mov RC, BASE + | bl fpcall + | .IOS mov BASE, RC + |.elif FPU + | fpins d0, d0, d1 + |.else + | bl fpcall + |.endif + |.if ("fpins" ~= "extern" or HFABI) and FPU + | ins_arithpost_fpu d0 + |.else + | ins_next1 + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + |.endif + |.endmacro + + case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: + | ins_arithdn adds, vadd.f64, extern __aeabi_dadd + break; + case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: + | ins_arithdn subs, vsub.f64, extern __aeabi_dsub + break; + case BC_MULVN: case BC_MULNV: case BC_MULVV: + | ins_arithdn smull, vmul.f64, extern __aeabi_dmul + break; + case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: + | ins_arithfp vdiv.f64, extern __aeabi_ddiv + break; + case BC_MODVN: case BC_MODNV: case BC_MODVV: + | ins_arithdn vm_modi, vm_mod, ->vm_mod + break; + case BC_POW: + | // NYI: (partial) integer arithmetic. + | ins_arithfp extern, extern pow + break; + + case BC_CAT: + | decode_RB8 RC, INS + | decode_RC8 RB, INS + | // RA = dst*8, RC = src_start*8, RB = src_end*8 (note: RB/RC swapped!) + | sub CARG3, RB, RC + | str BASE, L->base + | add CARG2, BASE, RB + |->BC_CAT_Z: + | // RA = dst*8, RC = src_start*8, CARG2 = top-1 + | mov CARG1, L + | str PC, SAVE_PC + | lsr CARG3, CARG3, #3 + | bl extern lj_meta_cat // (lua_State *L, TValue *top, int left) + | // Returns NULL (finished) or TValue * (metamethod). + | ldr BASE, L->base + | cmp CRET1, #0 + | bne ->vmeta_binop + | ldrd CARG34, [BASE, RC] + | ins_next1 + | ins_next2 + | strd CARG34, [BASE, RA] // Copy result to RA. + | ins_next3 + break; + + /* -- Constant ops ------------------------------------------------------ */ + + case BC_KSTR: + | // RA = dst*8, RC = str_const (~) + | mvn RC, RC + | ins_next1 + | ldr CARG1, [KBASE, RC, lsl #2] + | mvn CARG2, #~LJ_TSTR + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + break; + case BC_KCDATA: + |.if FFI + | // RA = dst*8, RC = cdata_const (~) + | mvn RC, RC + | ins_next1 + | ldr CARG1, [KBASE, RC, lsl #2] + | mvn CARG2, #~LJ_TCDATA + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + |.endif + break; + case BC_KSHORT: + | // RA = dst*8, (RC = int16_literal) + | mov CARG1, INS, asr #16 // Refetch sign-extended reg. + | mvn CARG2, #~LJ_TISNUM + | ins_next1 + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + break; + case BC_KNUM: + | // RA = dst*8, RC = num_const + | lsl RC, RC, #3 + | ins_next1 + | ldrd CARG12, [KBASE, RC] + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + break; + case BC_KPRI: + | // RA = dst*8, RC = primitive_type (~) + | add RA, BASE, RA + | mvn RC, RC + | ins_next1 + | ins_next2 + | str RC, [RA, #4] + | ins_next3 + break; + case BC_KNIL: + | // RA = base*8, RC = end + | add RA, BASE, RA + | add RC, BASE, RC, lsl #3 + | mvn CARG1, #~LJ_TNIL + | str CARG1, [RA, #4] + | add RA, RA, #8 + |1: + | str CARG1, [RA, #4] + | cmp RA, RC + | add RA, RA, #8 + | blt <1 + | ins_next_ + break; + + /* -- Upvalue and function ops ------------------------------------------ */ + + case BC_UGET: + | // RA = dst*8, RC = uvnum + | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] + | lsl RC, RC, #2 + | add RC, RC, #offsetof(GCfuncL, uvptr) + | ldr UPVAL:CARG2, [LFUNC:CARG2, RC] + | ldr CARG2, UPVAL:CARG2->v + | ldrd CARG34, [CARG2] + | ins_next1 + | ins_next2 + | strd CARG34, [BASE, RA] + | ins_next3 + break; + case BC_USETV: + | // RA = uvnum*8, RC = src + | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] + | lsr RA, RA, #1 + | add RA, RA, #offsetof(GCfuncL, uvptr) + | lsl RC, RC, #3 + | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] + | ldrd CARG34, [BASE, RC] + | ldrb RB, UPVAL:CARG2->marked + | ldrb RC, UPVAL:CARG2->closed + | ldr CARG2, UPVAL:CARG2->v + | tst RB, #LJ_GC_BLACK // isblack(uv) + | add RB, CARG4, #-LJ_TISGCV + | cmpne RC, #0 + | strd CARG34, [CARG2] + | bne >2 // Upvalue is closed and black? + |1: + | ins_next + | + |2: // Check if new value is collectable. + | cmn RB, #-(LJ_TNUMX - LJ_TISGCV) + | ldrbhi RC, GCOBJ:CARG3->gch.marked + | bls <1 // tvisgcv(v) + | sub CARG1, DISPATCH, #-GG_DISP2G + | tst RC, #LJ_GC_WHITES + | // Crossed a write barrier. Move the barrier forward. + |.if IOS + | beq <1 + | mov RC, BASE + | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) + | mov BASE, RC + |.else + | blne extern lj_gc_barrieruv // (global_State *g, TValue *tv) + |.endif + | b <1 + break; + case BC_USETS: + | // RA = uvnum*8, RC = str_const (~) + | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] + | lsr RA, RA, #1 + | add RA, RA, #offsetof(GCfuncL, uvptr) + | mvn RC, RC + | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] + | ldr STR:CARG3, [KBASE, RC, lsl #2] + | ldrb RB, UPVAL:CARG2->marked + | ldrb RC, UPVAL:CARG2->closed + | ldr CARG2, UPVAL:CARG2->v + | mvn CARG4, #~LJ_TSTR + | tst RB, #LJ_GC_BLACK // isblack(uv) + | ldrb RB, STR:CARG3->marked + | strd CARG34, [CARG2] + | bne >2 + |1: + | ins_next + | + |2: // Check if string is white and ensure upvalue is closed. + | tst RB, #LJ_GC_WHITES // iswhite(str) + | cmpne RC, #0 + | sub CARG1, DISPATCH, #-GG_DISP2G + | // Crossed a write barrier. Move the barrier forward. + |.if IOS + | beq <1 + | mov RC, BASE + | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) + | mov BASE, RC + |.else + | blne extern lj_gc_barrieruv // (global_State *g, TValue *tv) + |.endif + | b <1 + break; + case BC_USETN: + | // RA = uvnum*8, RC = num_const + | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] + | lsr RA, RA, #1 + | add RA, RA, #offsetof(GCfuncL, uvptr) + | lsl RC, RC, #3 + | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] + | ldrd CARG34, [KBASE, RC] + | ldr CARG2, UPVAL:CARG2->v + | ins_next1 + | ins_next2 + | strd CARG34, [CARG2] + | ins_next3 + break; + case BC_USETP: + | // RA = uvnum*8, RC = primitive_type (~) + | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] + | lsr RA, RA, #1 + | add RA, RA, #offsetof(GCfuncL, uvptr) + | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] + | mvn RC, RC + | ldr CARG2, UPVAL:CARG2->v + | ins_next1 + | ins_next2 + | str RC, [CARG2, #4] + | ins_next3 + break; + + case BC_UCLO: + | // RA = level*8, RC = target + | ldr CARG3, L->openupval + | add RC, PC, RC, lsl #2 + | str BASE, L->base + | cmp CARG3, #0 + | sub PC, RC, #0x20000 + | beq >1 + | mov CARG1, L + | add CARG2, BASE, RA + | bl extern lj_func_closeuv // (lua_State *L, TValue *level) + | ldr BASE, L->base + |1: + | ins_next + break; + + case BC_FNEW: + | // RA = dst*8, RC = proto_const (~) (holding function prototype) + | mvn RC, RC + | str BASE, L->base + | ldr CARG2, [KBASE, RC, lsl #2] + | str PC, SAVE_PC + | ldr CARG3, [BASE, FRAME_FUNC] + | mov CARG1, L + | // (lua_State *L, GCproto *pt, GCfuncL *parent) + | bl extern lj_func_newL_gc + | // Returns GCfuncL *. + | ldr BASE, L->base + | mvn CARG2, #~LJ_TFUNC + | ins_next1 + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + break; + + /* -- Table ops --------------------------------------------------------- */ + + case BC_TNEW: + case BC_TDUP: + | // RA = dst*8, RC = (hbits|asize) | tab_const (~) + if (op == BC_TDUP) { + | mvn RC, RC + } + | ldr CARG3, [DISPATCH, #DISPATCH_GL(gc.total)] + | ldr CARG4, [DISPATCH, #DISPATCH_GL(gc.threshold)] + | str BASE, L->base + | str PC, SAVE_PC + | cmp CARG3, CARG4 + | mov CARG1, L + | bhs >5 + |1: + if (op == BC_TNEW) { + | lsl CARG2, RC, #21 + | lsr CARG3, RC, #11 + | asr RC, CARG2, #21 + | lsr CARG2, CARG2, #21 + | cmn RC, #1 + | addeq CARG2, CARG2, #2 + | bl extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) + | // Returns GCtab *. + } else { + | ldr CARG2, [KBASE, RC, lsl #2] + | bl extern lj_tab_dup // (lua_State *L, Table *kt) + | // Returns GCtab *. + } + | ldr BASE, L->base + | mvn CARG2, #~LJ_TTAB + | ins_next1 + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + |5: + | bl extern lj_gc_step_fixtop // (lua_State *L) + | mov CARG1, L + | b <1 + break; + + case BC_GGET: + | // RA = dst*8, RC = str_const (~) + case BC_GSET: + | // RA = dst*8, RC = str_const (~) + | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] + | mvn RC, RC + | ldr TAB:CARG1, LFUNC:CARG2->env + | ldr STR:RC, [KBASE, RC, lsl #2] + if (op == BC_GGET) { + | b ->BC_TGETS_Z + } else { + | b ->BC_TSETS_Z + } + break; + + case BC_TGETV: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | // RA = dst*8, RB = table*8, RC = key*8 + | ldrd TAB:CARG12, [BASE, RB] + | ldrd CARG34, [BASE, RC] + | checktab CARG2, ->vmeta_tgetv // STALL: load CARG12. + | checktp CARG4, LJ_TISNUM // Integer key? + | ldreq CARG4, TAB:CARG1->array + | ldreq CARG2, TAB:CARG1->asize + | bne >9 + | + | add CARG4, CARG4, CARG3, lsl #3 + | cmp CARG3, CARG2 // In array part? + | ldrdlo CARG34, [CARG4] + | bhs ->vmeta_tgetv + | ins_next1 // Overwrites RB! + | checktp CARG4, LJ_TNIL + | beq >5 + |1: + | ins_next2 + | strd CARG34, [BASE, RA] + | ins_next3 + | + |5: // Check for __index if table value is nil. + | ldr TAB:CARG2, TAB:CARG1->metatable + | cmp TAB:CARG2, #0 + | beq <1 // No metatable: done. + | ldrb CARG2, TAB:CARG2->nomm + | tst CARG2, #1<vmeta_tgetv + | + |9: + | checktp CARG4, LJ_TSTR // String key? + | moveq STR:RC, CARG3 + | beq ->BC_TGETS_Z + | b ->vmeta_tgetv + break; + case BC_TGETS: + | decode_RB8 RB, INS + | and RC, RC, #255 + | // RA = dst*8, RB = table*8, RC = str_const (~) + | ldrd CARG12, [BASE, RB] + | mvn RC, RC + | ldr STR:RC, [KBASE, RC, lsl #2] // STALL: early RC. + | checktab CARG2, ->vmeta_tgets1 + |->BC_TGETS_Z: + | // (TAB:RB =) TAB:CARG1 = GCtab *, STR:RC = GCstr *, RA = dst*8 + | ldr CARG3, TAB:CARG1->hmask + | ldr CARG4, STR:RC->hash + | ldr NODE:INS, TAB:CARG1->node + | mov TAB:RB, TAB:CARG1 + | and CARG3, CARG3, CARG4 // idx = str->hash & tab->hmask + | add CARG3, CARG3, CARG3, lsl #1 + | add NODE:INS, NODE:INS, CARG3, lsl #3 // node = tab->node + idx*3*8 + |1: + | ldrd CARG12, NODE:INS->key // STALL: early NODE:INS. + | ldrd CARG34, NODE:INS->val + | ldr NODE:INS, NODE:INS->next + | checktp CARG2, LJ_TSTR + | cmpeq CARG1, STR:RC + | bne >4 + | checktp CARG4, LJ_TNIL + | beq >5 + |3: + | ins_next1 + | ins_next2 + | strd CARG34, [BASE, RA] + | ins_next3 + | + |4: // Follow hash chain. + | cmp NODE:INS, #0 + | bne <1 + | // End of hash chain: key not found, nil result. + | + |5: // Check for __index if table value is nil. + | ldr TAB:CARG1, TAB:RB->metatable + | mov CARG3, #0 // Optional clear of undef. value (during load stall). + | mvn CARG4, #~LJ_TNIL + | cmp TAB:CARG1, #0 + | beq <3 // No metatable: done. + | ldrb CARG2, TAB:CARG1->nomm + | tst CARG2, #1<vmeta_tgets + break; + case BC_TGETB: + | decode_RB8 RB, INS + | and RC, RC, #255 + | // RA = dst*8, RB = table*8, RC = index + | ldrd CARG12, [BASE, RB] + | checktab CARG2, ->vmeta_tgetb // STALL: load CARG12. + | ldr CARG3, TAB:CARG1->asize + | ldr CARG4, TAB:CARG1->array + | lsl CARG2, RC, #3 + | cmp RC, CARG3 + | ldrdlo CARG34, [CARG4, CARG2] + | bhs ->vmeta_tgetb + | ins_next1 // Overwrites RB! + | checktp CARG4, LJ_TNIL + | beq >5 + |1: + | ins_next2 + | strd CARG34, [BASE, RA] + | ins_next3 + | + |5: // Check for __index if table value is nil. + | ldr TAB:CARG2, TAB:CARG1->metatable + | cmp TAB:CARG2, #0 + | beq <1 // No metatable: done. + | ldrb CARG2, TAB:CARG2->nomm + | tst CARG2, #1<vmeta_tgetb + break; + + case BC_TSETV: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | // RA = src*8, RB = table*8, RC = key*8 + | ldrd TAB:CARG12, [BASE, RB] + | ldrd CARG34, [BASE, RC] + | checktab CARG2, ->vmeta_tsetv // STALL: load CARG12. + | checktp CARG4, LJ_TISNUM // Integer key? + | ldreq CARG2, TAB:CARG1->array + | ldreq CARG4, TAB:CARG1->asize + | bne >9 + | + | add CARG2, CARG2, CARG3, lsl #3 + | cmp CARG3, CARG4 // In array part? + | ldrlo INS, [CARG2, #4] + | bhs ->vmeta_tsetv + | ins_next1 // Overwrites RB! + | checktp INS, LJ_TNIL + | ldrb INS, TAB:CARG1->marked + | ldrd CARG34, [BASE, RA] + | beq >5 + |1: + | tst INS, #LJ_GC_BLACK // isblack(table) + | strd CARG34, [CARG2] + | bne >7 + |2: + | ins_next2 + | ins_next3 + | + |5: // Check for __newindex if previous value is nil. + | ldr TAB:RA, TAB:CARG1->metatable + | cmp TAB:RA, #0 + | beq <1 // No metatable: done. + | ldrb RA, TAB:RA->nomm + | tst RA, #1<vmeta_tsetv + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:CARG1, INS, CARG3 + | b <2 + | + |9: + | checktp CARG4, LJ_TSTR // String key? + | moveq STR:RC, CARG3 + | beq ->BC_TSETS_Z + | b ->vmeta_tsetv + break; + case BC_TSETS: + | decode_RB8 RB, INS + | and RC, RC, #255 + | // RA = src*8, RB = table*8, RC = str_const (~) + | ldrd CARG12, [BASE, RB] + | mvn RC, RC + | ldr STR:RC, [KBASE, RC, lsl #2] // STALL: early RC. + | checktab CARG2, ->vmeta_tsets1 + |->BC_TSETS_Z: + | // (TAB:RB =) TAB:CARG1 = GCtab *, STR:RC = GCstr *, RA = dst*8 + | ldr CARG3, TAB:CARG1->hmask + | ldr CARG4, STR:RC->hash + | ldr NODE:INS, TAB:CARG1->node + | mov TAB:RB, TAB:CARG1 + | and CARG3, CARG3, CARG4 // idx = str->hash & tab->hmask + | add CARG3, CARG3, CARG3, lsl #1 + | mov CARG4, #0 + | add NODE:INS, NODE:INS, CARG3, lsl #3 // node = tab->node + idx*3*8 + | strb CARG4, TAB:RB->nomm // Clear metamethod cache. + |1: + | ldrd CARG12, NODE:INS->key + | ldr CARG4, NODE:INS->val.it + | ldr NODE:CARG3, NODE:INS->next + | checktp CARG2, LJ_TSTR + | cmpeq CARG1, STR:RC + | bne >5 + | ldrb CARG2, TAB:RB->marked + | checktp CARG4, LJ_TNIL // Key found, but nil value? + | ldrd CARG34, [BASE, RA] + | beq >4 + |2: + | tst CARG2, #LJ_GC_BLACK // isblack(table) + | strd CARG34, NODE:INS->val + | bne >7 + |3: + | ins_next + | + |4: // Check for __newindex if previous value is nil. + | ldr TAB:CARG1, TAB:RB->metatable + | cmp TAB:CARG1, #0 + | beq <2 // No metatable: done. + | ldrb CARG1, TAB:CARG1->nomm + | tst CARG1, #1<vmeta_tsets + | + |5: // Follow hash chain. + | movs NODE:INS, NODE:CARG3 + | bne <1 + | // End of hash chain: key not found, add a new one. + | + | // But check for __newindex first. + | ldr TAB:CARG1, TAB:RB->metatable + | mov CARG3, TMPDp + | str PC, SAVE_PC + | cmp TAB:CARG1, #0 // No metatable: continue. + | str BASE, L->base + | ldrbne CARG2, TAB:CARG1->nomm + | mov CARG1, L + | beq >6 + | tst CARG2, #1<vmeta_tsets // 'no __newindex' flag NOT set: check. + |6: + | mvn CARG4, #~LJ_TSTR + | str STR:RC, TMPDlo + | mov CARG2, TAB:RB + | str CARG4, TMPDhi + | bl extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) + | // Returns TValue *. + | ldr BASE, L->base + | ldrd CARG34, [BASE, RA] + | strd CARG34, [CRET1] + | b <3 // No 2nd write barrier needed. + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, CARG2, CARG3 + | b <3 + break; + case BC_TSETB: + | decode_RB8 RB, INS + | and RC, RC, #255 + | // RA = src*8, RB = table*8, RC = index + | ldrd CARG12, [BASE, RB] + | checktab CARG2, ->vmeta_tsetb // STALL: load CARG12. + | ldr CARG3, TAB:CARG1->asize + | ldr RB, TAB:CARG1->array + | lsl CARG2, RC, #3 + | cmp RC, CARG3 + | ldrdlo CARG34, [CARG2, RB]! + | bhs ->vmeta_tsetb + | ins_next1 // Overwrites RB! + | checktp CARG4, LJ_TNIL + | ldrb INS, TAB:CARG1->marked + | ldrd CARG34, [BASE, RA] + | beq >5 + |1: + | tst INS, #LJ_GC_BLACK // isblack(table) + | strd CARG34, [CARG2] + | bne >7 + |2: + | ins_next2 + | ins_next3 + | + |5: // Check for __newindex if previous value is nil. + | ldr TAB:RA, TAB:CARG1->metatable + | cmp TAB:RA, #0 + | beq <1 // No metatable: done. + | ldrb RA, TAB:RA->nomm + | tst RA, #1<vmeta_tsetb + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:CARG1, INS, CARG3 + | b <2 + break; + + case BC_TSETM: + | // RA = base*8 (table at base-1), RC = num_const (start index) + | add RA, BASE, RA + |1: + | ldr RB, SAVE_MULTRES + | ldr TAB:CARG2, [RA, #-8] // Guaranteed to be a table. + | ldr CARG1, [KBASE, RC, lsl #3] // Integer constant is in lo-word. + | subs RB, RB, #8 + | ldr CARG4, TAB:CARG2->asize + | beq >4 // Nothing to copy? + | add CARG3, CARG1, RB, lsr #3 + | cmp CARG3, CARG4 + | ldr CARG4, TAB:CARG2->array + | add RB, RA, RB + | bhi >5 + | add INS, CARG4, CARG1, lsl #3 + | ldrb CARG1, TAB:CARG2->marked + |3: // Copy result slots to table. + | ldrd CARG34, [RA], #8 + | strd CARG34, [INS], #8 + | cmp RA, RB + | blo <3 + | tst CARG1, #LJ_GC_BLACK // isblack(table) + | bne >7 + |4: + | ins_next + | + |5: // Need to resize array part. + | str BASE, L->base + | mov CARG1, L + | str PC, SAVE_PC + | bl extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) + | // Must not reallocate the stack. + | .IOS ldr BASE, L->base + | b <1 + | + |7: // Possible table write barrier for any value. Skip valiswhite check. + | barrierback TAB:CARG2, CARG1, CARG3 + | b <4 + break; + + /* -- Calls and vararg handling ----------------------------------------- */ + + case BC_CALLM: + | // RA = base*8, (RB = nresults+1,) RC = extra_nargs + | ldr CARG1, SAVE_MULTRES + | decode_RC8 NARGS8:RC, INS + | add NARGS8:RC, NARGS8:RC, CARG1 + | b ->BC_CALL_Z + break; + case BC_CALL: + | decode_RC8 NARGS8:RC, INS + | // RA = base*8, (RB = nresults+1,) RC = (nargs+1)*8 + |->BC_CALL_Z: + | mov RB, BASE // Save old BASE for vmeta_call. + | ldrd CARG34, [BASE, RA]! + | sub NARGS8:RC, NARGS8:RC, #8 + | add BASE, BASE, #8 + | checkfunc CARG4, ->vmeta_call + | ins_call + break; + + case BC_CALLMT: + | // RA = base*8, (RB = 0,) RC = extra_nargs + | ldr CARG1, SAVE_MULTRES + | add NARGS8:RC, CARG1, RC, lsl #3 + | b ->BC_CALLT1_Z + break; + case BC_CALLT: + | lsl NARGS8:RC, RC, #3 + | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 + |->BC_CALLT1_Z: + | ldrd LFUNC:CARG34, [RA, BASE]! + | sub NARGS8:RC, NARGS8:RC, #8 + | add RA, RA, #8 + | checkfunc CARG4, ->vmeta_callt + | ldr PC, [BASE, FRAME_PC] + |->BC_CALLT2_Z: + | mov RB, #0 + | ldrb CARG4, LFUNC:CARG3->ffid + | tst PC, #FRAME_TYPE + | bne >7 + |1: + | str LFUNC:CARG3, [BASE, FRAME_FUNC] // Copy function down, but keep PC. + | cmp NARGS8:RC, #0 + | beq >3 + |2: + | ldrd CARG12, [RA, RB] + | add INS, RB, #8 + | cmp INS, NARGS8:RC + | strd CARG12, [BASE, RB] + | mov RB, INS + | bne <2 + |3: + | cmp CARG4, #1 // (> FF_C) Calling a fast function? + | bhi >5 + |4: + | ins_callt + | + |5: // Tailcall to a fast function with a Lua frame below. + | ldr INS, [PC, #-4] + | decode_RA8 RA, INS + | sub CARG1, BASE, RA + | ldr LFUNC:CARG1, [CARG1, #-16] + | ldr CARG1, LFUNC:CARG1->field_pc + | ldr KBASE, [CARG1, #PC2PROTO(k)] + | b <4 + | + |7: // Tailcall from a vararg function. + | eor PC, PC, #FRAME_VARG + | tst PC, #FRAME_TYPEP // Vararg frame below? + | movne CARG4, #0 // Clear ffid if no Lua function below. + | bne <1 + | sub BASE, BASE, PC + | ldr PC, [BASE, FRAME_PC] + | tst PC, #FRAME_TYPE + | movne CARG4, #0 // Clear ffid if no Lua function below. + | b <1 + break; + + case BC_ITERC: + | // RA = base*8, (RB = nresults+1, RC = nargs+1 (2+1)) + | add RA, BASE, RA + | mov RB, BASE // Save old BASE for vmeta_call. + | ldrd CARG34, [RA, #-16] + | ldrd CARG12, [RA, #-8] + | add BASE, RA, #8 + | strd CARG34, [RA, #8] // Copy state. + | strd CARG12, [RA, #16] // Copy control var. + | // STALL: locked CARG34. + | ldrd LFUNC:CARG34, [RA, #-24] + | mov NARGS8:RC, #16 // Iterators get 2 arguments. + | // STALL: load CARG34. + | strd LFUNC:CARG34, [RA] // Copy callable. + | checkfunc CARG4, ->vmeta_call + | ins_call + break; + + case BC_ITERN: + | // RA = base*8, (RB = nresults+1, RC = nargs+1 (2+1)) + |.if JIT + | // NYI: add hotloop, record BC_ITERN. + |.endif + | add RA, BASE, RA + | ldr TAB:RB, [RA, #-16] + | ldr CARG1, [RA, #-8] // Get index from control var. + | ldr INS, TAB:RB->asize + | ldr CARG2, TAB:RB->array + | add PC, PC, #4 + |1: // Traverse array part. + | subs RC, CARG1, INS + | add CARG3, CARG2, CARG1, lsl #3 + | bhs >5 // Index points after array part? + | ldrd CARG34, [CARG3] + | checktp CARG4, LJ_TNIL + | addeq CARG1, CARG1, #1 // Skip holes in array part. + | beq <1 + | ldrh RC, [PC, #-2] + | mvn CARG2, #~LJ_TISNUM + | strd CARG34, [RA, #8] + | add RC, PC, RC, lsl #2 + | add RB, CARG1, #1 + | strd CARG12, [RA] + | sub PC, RC, #0x20000 + | str RB, [RA, #-8] // Update control var. + |3: + | ins_next + | + |5: // Traverse hash part. + | ldr CARG4, TAB:RB->hmask + | ldr NODE:RB, TAB:RB->node + |6: + | add CARG1, RC, RC, lsl #1 + | cmp RC, CARG4 // End of iteration? Branch to ITERL+1. + | add NODE:CARG3, NODE:RB, CARG1, lsl #3 // node = tab->node + idx*3*8 + | bhi <3 + | ldrd CARG12, NODE:CARG3->val + | checktp CARG2, LJ_TNIL + | add RC, RC, #1 + | beq <6 // Skip holes in hash part. + | ldrh RB, [PC, #-2] + | add RC, RC, INS + | ldrd CARG34, NODE:CARG3->key + | str RC, [RA, #-8] // Update control var. + | strd CARG12, [RA, #8] + | add RC, PC, RB, lsl #2 + | sub PC, RC, #0x20000 + | strd CARG34, [RA] + | b <3 + break; + + case BC_ISNEXT: + | // RA = base*8, RC = target (points to ITERN) + | add RA, BASE, RA + | add RC, PC, RC, lsl #2 + | ldrd CFUNC:CARG12, [RA, #-24] + | ldr CARG3, [RA, #-12] + | ldr CARG4, [RA, #-4] + | checktp CARG2, LJ_TFUNC + | ldrbeq CARG1, CFUNC:CARG1->ffid + | checktpeq CARG3, LJ_TTAB + | checktpeq CARG4, LJ_TNIL + | cmpeq CARG1, #FF_next_N + | subeq PC, RC, #0x20000 + | bne >5 + | ins_next1 + | ins_next2 + | mov CARG1, #0 + | mvn CARG2, #0x00018000 + | strd CARG1, [RA, #-8] // Initialize control var. + |1: + | ins_next3 + |5: // Despecialize bytecode if any of the checks fail. + | mov CARG1, #BC_JMP + | mov OP, #BC_ITERC + | strb CARG1, [PC, #-4] + | sub PC, RC, #0x20000 + | strb OP, [PC] // Subsumes ins_next1. + | ins_next2 + | b <1 + break; + + case BC_VARG: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 + | ldr CARG1, [BASE, FRAME_PC] + | add RC, BASE, RC + | add RA, BASE, RA + | add RC, RC, #FRAME_VARG + | add CARG4, RA, RB + | sub CARG3, BASE, #8 // CARG3 = vtop + | sub RC, RC, CARG1 // RC = vbase + | // Note: RC may now be even _above_ BASE if nargs was < numparams. + | cmp RB, #0 + | sub CARG1, CARG3, RC + | beq >5 // Copy all varargs? + | sub CARG4, CARG4, #16 + |1: // Copy vararg slots to destination slots. + | cmp RC, CARG3 + | ldrdlo CARG12, [RC], #8 + | mvnhs CARG2, #~LJ_TNIL + | cmp RA, CARG4 + | strd CARG12, [RA], #8 + | blo <1 + |2: + | ins_next + | + |5: // Copy all varargs. + | ldr CARG4, L->maxstack + | cmp CARG1, #0 + | movle RB, #8 // MULTRES = (0+1)*8 + | addgt RB, CARG1, #8 + | add CARG2, RA, CARG1 + | str RB, SAVE_MULTRES + | ble <2 + | cmp CARG2, CARG4 + | bhi >7 + |6: + | ldrd CARG12, [RC], #8 + | strd CARG12, [RA], #8 + | cmp RC, CARG3 + | blo <6 + | b <2 + | + |7: // Grow stack for varargs. + | lsr CARG2, CARG1, #3 + | str RA, L->top + | mov CARG1, L + | str BASE, L->base + | sub RC, RC, BASE // Need delta, because BASE may change. + | str PC, SAVE_PC + | sub RA, RA, BASE + | bl extern lj_state_growstack // (lua_State *L, int n) + | ldr BASE, L->base + | add RA, BASE, RA + | add RC, BASE, RC + | sub CARG3, BASE, #8 + | b <6 + break; + + /* -- Returns ----------------------------------------------------------- */ + + case BC_RETM: + | // RA = results*8, RC = extra results + | ldr CARG1, SAVE_MULTRES + | ldr PC, [BASE, FRAME_PC] + | add RA, BASE, RA + | add RC, CARG1, RC, lsl #3 + | b ->BC_RETM_Z + break; + + case BC_RET: + | // RA = results*8, RC = nresults+1 + | ldr PC, [BASE, FRAME_PC] + | lsl RC, RC, #3 + | add RA, BASE, RA + |->BC_RETM_Z: + | str RC, SAVE_MULTRES + |1: + | ands CARG1, PC, #FRAME_TYPE + | eor CARG2, PC, #FRAME_VARG + | bne ->BC_RETV2_Z + | + |->BC_RET_Z: + | // BASE = base, RA = resultptr, RC = (nresults+1)*8, PC = return + | ldr INS, [PC, #-4] + | subs CARG4, RC, #8 + | sub CARG3, BASE, #8 + | beq >3 + |2: + | ldrd CARG12, [RA], #8 + | add BASE, BASE, #8 + | subs CARG4, CARG4, #8 + | strd CARG12, [BASE, #-16] + | bne <2 + |3: + | decode_RA8 RA, INS + | sub CARG4, CARG3, RA + | decode_RB8 RB, INS + | ldr LFUNC:CARG1, [CARG4, FRAME_FUNC] + |5: + | cmp RB, RC // More results expected? + | bhi >6 + | mov BASE, CARG4 + | ldr CARG2, LFUNC:CARG1->field_pc + | ins_next1 + | ins_next2 + | ldr KBASE, [CARG2, #PC2PROTO(k)] + | ins_next3 + | + |6: // Fill up results with nil. + | mvn CARG2, #~LJ_TNIL + | add BASE, BASE, #8 + | add RC, RC, #8 + | str CARG2, [BASE, #-12] + | b <5 + | + |->BC_RETV1_Z: // Non-standard return case. + | add RA, BASE, RA + |->BC_RETV2_Z: + | tst CARG2, #FRAME_TYPEP + | bne ->vm_return + | // Return from vararg function: relocate BASE down. + | sub BASE, BASE, CARG2 + | ldr PC, [BASE, FRAME_PC] + | b <1 + break; + + case BC_RET0: case BC_RET1: + | // RA = results*8, RC = nresults+1 + | ldr PC, [BASE, FRAME_PC] + | lsl RC, RC, #3 + | str RC, SAVE_MULTRES + | ands CARG1, PC, #FRAME_TYPE + | eor CARG2, PC, #FRAME_VARG + | ldreq INS, [PC, #-4] + | bne ->BC_RETV1_Z + if (op == BC_RET1) { + | ldrd CARG12, [BASE, RA] + } + | sub CARG4, BASE, #8 + | decode_RA8 RA, INS + if (op == BC_RET1) { + | strd CARG12, [CARG4] + } + | sub BASE, CARG4, RA + | decode_RB8 RB, INS + | ldr LFUNC:CARG1, [BASE, FRAME_FUNC] + |5: + | cmp RB, RC + | bhi >6 + | ldr CARG2, LFUNC:CARG1->field_pc + | ins_next1 + | ins_next2 + | ldr KBASE, [CARG2, #PC2PROTO(k)] + | ins_next3 + | + |6: // Fill up results with nil. + | sub CARG2, CARG4, #4 + | mvn CARG3, #~LJ_TNIL + | str CARG3, [CARG2, RC] + | add RC, RC, #8 + | b <5 + break; + + /* -- Loops and branches ------------------------------------------------ */ + + |.define FOR_IDX, [RA]; .define FOR_TIDX, [RA, #4] + |.define FOR_STOP, [RA, #8]; .define FOR_TSTOP, [RA, #12] + |.define FOR_STEP, [RA, #16]; .define FOR_TSTEP, [RA, #20] + |.define FOR_EXT, [RA, #24]; .define FOR_TEXT, [RA, #28] + + case BC_FORL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IFORL follows. + break; + + case BC_JFORI: + case BC_JFORL: +#if !LJ_HASJIT + break; +#endif + case BC_FORI: + case BC_IFORL: + | // RA = base*8, RC = target (after end of loop or start of loop) + vk = (op == BC_IFORL || op == BC_JFORL); + | ldrd CARG12, [RA, BASE]! + if (op != BC_JFORL) { + | add RC, PC, RC, lsl #2 + } + if (!vk) { + | ldrd CARG34, FOR_STOP + | checktp CARG2, LJ_TISNUM + | ldr RB, FOR_TSTEP + | bne >5 + | checktp CARG4, LJ_TISNUM + | ldr CARG4, FOR_STEP + | checktpeq RB, LJ_TISNUM + | bne ->vmeta_for + | cmp CARG4, #0 + | blt >4 + | cmp CARG1, CARG3 + } else { + | ldrd CARG34, FOR_STEP + | checktp CARG2, LJ_TISNUM + | bne >5 + | adds CARG1, CARG1, CARG3 + | ldr CARG4, FOR_STOP + if (op == BC_IFORL) { + | addvs RC, PC, #0x20000 // Overflow: prevent branch. + } else { + | bvs >2 // Overflow: do not enter mcode. + } + | cmp CARG3, #0 + | blt >4 + | cmp CARG1, CARG4 + } + |1: + if (op == BC_FORI) { + | subgt PC, RC, #0x20000 + } else if (op == BC_JFORI) { + | sub PC, RC, #0x20000 + | ldrhle RC, [PC, #-2] + } else if (op == BC_IFORL) { + | suble PC, RC, #0x20000 + } + if (vk) { + | strd CARG12, FOR_IDX + } + |2: + | ins_next1 + | ins_next2 + | strd CARG12, FOR_EXT + if (op == BC_JFORI || op == BC_JFORL) { + | ble =>BC_JLOOP + } + |3: + | ins_next3 + | + |4: // Invert check for negative step. + if (!vk) { + | cmp CARG3, CARG1 + } else { + | cmp CARG4, CARG1 + } + | b <1 + | + |5: // FP loop. + if (!vk) { + | cmnlo CARG4, #-LJ_TISNUM + | cmnlo RB, #-LJ_TISNUM + | bhs ->vmeta_for + |.if FPU + | vldr d0, FOR_IDX + | vldr d1, FOR_STOP + | cmp RB, #0 + | vstr d0, FOR_EXT + |.else + | cmp RB, #0 + | strd CARG12, FOR_EXT + | blt >8 + |.endif + } else { + |.if FPU + | vldr d0, FOR_IDX + | vldr d2, FOR_STEP + | vldr d1, FOR_STOP + | cmp CARG4, #0 + | vadd.f64 d0, d0, d2 + |.else + | cmp CARG4, #0 + | blt >8 + | bl extern __aeabi_dadd + | strd CARG12, FOR_IDX + | ldrd CARG34, FOR_STOP + | strd CARG12, FOR_EXT + |.endif + } + |6: + |.if FPU + | vcmpge.f64 d0, d1 + | vcmplt.f64 d1, d0 + | vmrs + |.else + | bl extern __aeabi_cdcmple + |.endif + if (vk) { + |.if FPU + | vstr d0, FOR_IDX + | vstr d0, FOR_EXT + |.endif + } + if (op == BC_FORI) { + | subhi PC, RC, #0x20000 + } else if (op == BC_JFORI) { + | sub PC, RC, #0x20000 + | ldrhls RC, [PC, #-2] + | bls =>BC_JLOOP + } else if (op == BC_IFORL) { + | subls PC, RC, #0x20000 + } else { + | bls =>BC_JLOOP + } + | ins_next1 + | ins_next2 + | b <3 + | + |.if not FPU + |8: // Invert check for negative step. + if (vk) { + | bl extern __aeabi_dadd + | strd CARG12, FOR_IDX + | strd CARG12, FOR_EXT + } + | mov CARG3, CARG1 + | mov CARG4, CARG2 + | ldrd CARG12, FOR_STOP + | b <6 + |.endif + break; + + case BC_ITERL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IITERL follows. + break; + + case BC_JITERL: +#if !LJ_HASJIT + break; +#endif + case BC_IITERL: + | // RA = base*8, RC = target + | ldrd CARG12, [RA, BASE]! + if (op == BC_JITERL) { + | cmn CARG2, #-LJ_TNIL // Stop if iterator returned nil. + | strdne CARG12, [RA, #-8] + | bne =>BC_JLOOP + } else { + | add RC, PC, RC, lsl #2 + | // STALL: load CARG12. + | cmn CARG2, #-LJ_TNIL // Stop if iterator returned nil. + | subne PC, RC, #0x20000 // Otherwise save control var + branch. + | strdne CARG12, [RA, #-8] + } + | ins_next + break; + + case BC_LOOP: + | // RA = base*8, RC = target (loop extent) + | // Note: RA/RC is only used by trace recorder to determine scope/extent + | // This opcode does NOT jump, it's only purpose is to detect a hot loop. + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_ILOOP follows. + break; + + case BC_ILOOP: + | // RA = base*8, RC = target (loop extent) + | ins_next + break; + + case BC_JLOOP: + |.if JIT + | // RA = base (ignored), RC = traceno + | ldr CARG1, [DISPATCH, #DISPATCH_J(trace)] + | mov CARG2, #0 // Traces on ARM don't store the trace number, so use 0. + | ldr TRACE:RC, [CARG1, RC, lsl #2] + | st_vmstate CARG2 + | ldr RA, TRACE:RC->mcode + | str BASE, [DISPATCH, #DISPATCH_GL(jit_base)] + | str L, [DISPATCH, #DISPATCH_GL(jit_L)] + | bx RA + |.endif + break; + + case BC_JMP: + | // RA = base*8 (only used by trace recorder), RC = target + | add RC, PC, RC, lsl #2 + | sub PC, RC, #0x20000 + | ins_next + break; + + /* -- Function headers -------------------------------------------------- */ + + case BC_FUNCF: + |.if JIT + | hotcall + |.endif + case BC_FUNCV: /* NYI: compiled vararg functions. */ + | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. + break; + + case BC_JFUNCF: +#if !LJ_HASJIT + break; +#endif + case BC_IFUNCF: + | // BASE = new base, RA = BASE+framesize*8, CARG3 = LFUNC, RC = nargs*8 + | ldr CARG1, L->maxstack + | ldrb CARG2, [PC, #-4+PC2PROTO(numparams)] + | ldr KBASE, [PC, #-4+PC2PROTO(k)] + | cmp RA, CARG1 + | bhi ->vm_growstack_l + if (op != BC_JFUNCF) { + | ins_next1 + | ins_next2 + } + |2: + | cmp NARGS8:RC, CARG2, lsl #3 // Check for missing parameters. + | mvn CARG4, #~LJ_TNIL + | blo >3 + if (op == BC_JFUNCF) { + | decode_RD RC, INS + | b =>BC_JLOOP + } else { + | ins_next3 + } + | + |3: // Clear missing parameters. + | strd CARG34, [BASE, NARGS8:RC] + | add NARGS8:RC, NARGS8:RC, #8 + | b <2 + break; + + case BC_JFUNCV: +#if !LJ_HASJIT + break; +#endif + | NYI // NYI: compiled vararg functions + break; /* NYI: compiled vararg functions. */ + + case BC_IFUNCV: + | // BASE = new base, RA = BASE+framesize*8, CARG3 = LFUNC, RC = nargs*8 + | ldr CARG1, L->maxstack + | add CARG4, BASE, RC + | add RA, RA, RC + | str LFUNC:CARG3, [CARG4] // Store copy of LFUNC. + | add CARG2, RC, #8+FRAME_VARG + | ldr KBASE, [PC, #-4+PC2PROTO(k)] + | cmp RA, CARG1 + | str CARG2, [CARG4, #4] // Store delta + FRAME_VARG. + | bhs ->vm_growstack_l + | ldrb RB, [PC, #-4+PC2PROTO(numparams)] + | mov RA, BASE + | mov RC, CARG4 + | cmp RB, #0 + | add BASE, CARG4, #8 + | beq >3 + | mvn CARG3, #~LJ_TNIL + |1: + | cmp RA, RC // Less args than parameters? + | ldrdlo CARG12, [RA], #8 + | movhs CARG2, CARG3 + | strlo CARG3, [RA, #-4] // Clear old fixarg slot (help the GC). + |2: + | subs RB, RB, #1 + | strd CARG12, [CARG4, #8]! + | bne <1 + |3: + | ins_next + break; + + case BC_FUNCC: + case BC_FUNCCW: + | // BASE = new base, RA = BASE+framesize*8, CARG3 = CFUNC, RC = nargs*8 + if (op == BC_FUNCC) { + | ldr CARG4, CFUNC:CARG3->f + } else { + | ldr CARG4, [DISPATCH, #DISPATCH_GL(wrapf)] + } + | add CARG2, RA, NARGS8:RC + | ldr CARG1, L->maxstack + | add RC, BASE, NARGS8:RC + | str BASE, L->base + | cmp CARG2, CARG1 + | str RC, L->top + if (op == BC_FUNCCW) { + | ldr CARG2, CFUNC:CARG3->f + } + | mv_vmstate CARG3, C + | mov CARG1, L + | bhi ->vm_growstack_c // Need to grow stack. + | st_vmstate CARG3 + | blx CARG4 // (lua_State *L [, lua_CFunction f]) + | // Returns nresults. + | ldr BASE, L->base + | mv_vmstate CARG3, INTERP + | ldr CRET2, L->top + | lsl RC, CRET1, #3 + | st_vmstate CARG3 + | ldr PC, [BASE, FRAME_PC] + | sub RA, CRET2, RC // RA = L->top - nresults*8 + | b ->vm_returnc + break; + + /* ---------------------------------------------------------------------- */ + + default: + fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); + exit(2); + break; + } +} + +static int build_backend(BuildCtx *ctx) +{ + int op; + + dasm_growpc(Dst, BC__MAX); + + build_subroutines(ctx); + + |.code_op + for (op = 0; op < BC__MAX; op++) + build_ins(ctx, (BCOp)op, op); + + return BC__MAX; +} + +/* Emit pseudo frame-info for all assembler functions. */ +static void emit_asm_debug(BuildCtx *ctx) +{ + int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); + int i; + switch (ctx->mode) { + case BUILD_elfasm: + fprintf(ctx->fp, "\t.section .debug_frame,\"\",%%progbits\n"); + fprintf(ctx->fp, + ".Lframe0:\n" + "\t.long .LECIE0-.LSCIE0\n" + ".LSCIE0:\n" + "\t.long 0xffffffff\n" + "\t.byte 0x1\n" + "\t.string \"\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 0xe\n" /* Return address is in lr. */ + "\t.byte 0xc\n\t.uleb128 0xd\n\t.uleb128 0\n" /* def_cfa sp */ + "\t.align 2\n" + ".LECIE0:\n\n"); + fprintf(ctx->fp, + ".LSFDE0:\n" + "\t.long .LEFDE0-.LASFDE0\n" + ".LASFDE0:\n" + "\t.long .Lframe0\n" + "\t.long .Lbegin\n" + "\t.long %d\n" + "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ + "\t.byte 0x8e\n\t.uleb128 1\n", /* offset lr */ + fcofs, CFRAME_SIZE); + for (i = 11; i >= (LJ_ARCH_HASFPU ? 5 : 4); i--) /* offset r4-r11 */ + fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+i, 2+(11-i)); +#if LJ_ARCH_HASFPU + for (i = 15; i >= 8; i--) /* offset d8-d15 */ + fprintf(ctx->fp, "\t.byte 5\n\t.uleb128 %d, %d\n", + 64+2*i, 10+2*(15-i)); + fprintf(ctx->fp, "\t.byte 0x84\n\t.uleb128 %d\n", 25); /* offset r4 */ +#endif + fprintf(ctx->fp, + "\t.align 2\n" + ".LEFDE0:\n\n"); +#if LJ_HASFFI + fprintf(ctx->fp, + ".LSFDE1:\n" + "\t.long .LEFDE1-.LASFDE1\n" + ".LASFDE1:\n" + "\t.long .Lframe0\n" + "\t.long lj_vm_ffi_call\n" + "\t.long %d\n" + "\t.byte 0xe\n\t.uleb128 16\n" /* def_cfa_offset */ + "\t.byte 0x8e\n\t.uleb128 1\n" /* offset lr */ + "\t.byte 0x8b\n\t.uleb128 2\n" /* offset r11 */ + "\t.byte 0x85\n\t.uleb128 3\n" /* offset r5 */ + "\t.byte 0x84\n\t.uleb128 4\n" /* offset r4 */ + "\t.byte 0xd\n\t.uleb128 0xb\n" /* def_cfa_register r11 */ + "\t.align 2\n" + ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); +#endif + break; + default: + break; + } +} + + +``` + +`include/luajit-2.0.5/src/vm_mips.dasc`: + +```dasc +|// Low-level VM code for MIPS CPUs. +|// Bytecode interpreter, fast functions and helper functions. +|// Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +| +|.arch mips +|.section code_op, code_sub +| +|.actionlist build_actionlist +|.globals GLOB_ +|.globalnames globnames +|.externnames extnames +| +|// Note: The ragged indentation of the instructions is intentional. +|// The starting columns indicate data dependencies. +| +|//----------------------------------------------------------------------- +| +|// Fixed register assignments for the interpreter. +|// Don't use: r0 = 0, r26/r27 = reserved, r28 = gp, r29 = sp, r31 = ra +| +|// The following must be C callee-save (but BASE is often refetched). +|.define BASE, r16 // Base of current Lua stack frame. +|.define KBASE, r17 // Constants of current Lua function. +|.define PC, r18 // Next PC. +|.define DISPATCH, r19 // Opcode dispatch table. +|.define LREG, r20 // Register holding lua_State (also in SAVE_L). +|.define MULTRES, r21 // Size of multi-result: (nresults+1)*8. +|// NYI: r22 currently unused. +| +|.define JGL, r30 // On-trace: global_State + 32768. +| +|// Constants for type-comparisons, stores and conversions. C callee-save. +|.define TISNIL, r30 +|.define TOBIT, f30 // 2^52 + 2^51. +| +|// The following temporaries are not saved across C calls, except for RA. +|.define RA, r23 // Callee-save. +|.define RB, r8 +|.define RC, r9 +|.define RD, r10 +|.define INS, r11 +| +|.define AT, r1 // Assembler temporary. +|.define TMP0, r12 +|.define TMP1, r13 +|.define TMP2, r14 +|.define TMP3, r15 +| +|// Calling conventions. +|.define CFUNCADDR, r25 +|.define CARG1, r4 +|.define CARG2, r5 +|.define CARG3, r6 +|.define CARG4, r7 +| +|.define CRET1, r2 +|.define CRET2, r3 +| +|.define FARG1, f12 +|.define FARG2, f14 +| +|.define FRET1, f0 +|.define FRET2, f2 +| +|// Stack layout while in interpreter. Must match with lj_frame.h. +|.define CFRAME_SPACE, 112 // Delta for sp. +| +|.define SAVE_ERRF, 124(sp) // 32 bit C frame info. +|.define SAVE_NRES, 120(sp) +|.define SAVE_CFRAME, 116(sp) +|.define SAVE_L, 112(sp) +|//----- 8 byte aligned, ^^^^ 16 byte register save area, owned by interpreter. +|.define SAVE_GPR_, 72 // .. 72+10*4: 32 bit GPR saves. +|.define SAVE_FPR_, 24 // .. 24+6*8: 64 bit FPR saves. +|.define SAVE_PC, 20(sp) +|.define ARG5, 16(sp) +|.define CSAVE_4, 12(sp) +|.define CSAVE_3, 8(sp) +|.define CSAVE_2, 4(sp) +|.define CSAVE_1, 0(sp) +|//----- 8 byte aligned, ^^^^ 16 byte register save area, owned by callee. +| +|.define ARG5_OFS, 16 +|.define SAVE_MULTRES, ARG5 +| +|.macro saveregs +| addiu sp, sp, -CFRAME_SPACE +| sw ra, SAVE_GPR_+9*4(sp) +| sw r30, SAVE_GPR_+8*4(sp) +| sdc1 f30, SAVE_FPR_+5*8(sp) +| sw r23, SAVE_GPR_+7*4(sp) +| sw r22, SAVE_GPR_+6*4(sp) +| sdc1 f28, SAVE_FPR_+4*8(sp) +| sw r21, SAVE_GPR_+5*4(sp) +| sw r20, SAVE_GPR_+4*4(sp) +| sdc1 f26, SAVE_FPR_+3*8(sp) +| sw r19, SAVE_GPR_+3*4(sp) +| sw r18, SAVE_GPR_+2*4(sp) +| sdc1 f24, SAVE_FPR_+2*8(sp) +| sw r17, SAVE_GPR_+1*4(sp) +| sw r16, SAVE_GPR_+0*4(sp) +| sdc1 f22, SAVE_FPR_+1*8(sp) +| sdc1 f20, SAVE_FPR_+0*8(sp) +|.endmacro +| +|.macro restoreregs_ret +| lw ra, SAVE_GPR_+9*4(sp) +| lw r30, SAVE_GPR_+8*4(sp) +| ldc1 f30, SAVE_FPR_+5*8(sp) +| lw r23, SAVE_GPR_+7*4(sp) +| lw r22, SAVE_GPR_+6*4(sp) +| ldc1 f28, SAVE_FPR_+4*8(sp) +| lw r21, SAVE_GPR_+5*4(sp) +| lw r20, SAVE_GPR_+4*4(sp) +| ldc1 f26, SAVE_FPR_+3*8(sp) +| lw r19, SAVE_GPR_+3*4(sp) +| lw r18, SAVE_GPR_+2*4(sp) +| ldc1 f24, SAVE_FPR_+2*8(sp) +| lw r17, SAVE_GPR_+1*4(sp) +| lw r16, SAVE_GPR_+0*4(sp) +| ldc1 f22, SAVE_FPR_+1*8(sp) +| ldc1 f20, SAVE_FPR_+0*8(sp) +| jr ra +| addiu sp, sp, CFRAME_SPACE +|.endmacro +| +|// Type definitions. Some of these are only used for documentation. +|.type L, lua_State, LREG +|.type GL, global_State +|.type TVALUE, TValue +|.type GCOBJ, GCobj +|.type STR, GCstr +|.type TAB, GCtab +|.type LFUNC, GCfuncL +|.type CFUNC, GCfuncC +|.type PROTO, GCproto +|.type UPVAL, GCupval +|.type NODE, Node +|.type NARGS8, int +|.type TRACE, GCtrace +| +|//----------------------------------------------------------------------- +| +|// Trap for not-yet-implemented parts. +|.macro NYI; .long 0xf0f0f0f0; .endmacro +| +|// Macros to mark delay slots. +|.macro ., a; a; .endmacro +|.macro ., a,b; a,b; .endmacro +|.macro ., a,b,c; a,b,c; .endmacro +| +|//----------------------------------------------------------------------- +| +|// Endian-specific defines. +|.define FRAME_PC, LJ_ENDIAN_SELECT(-4,-8) +|.define FRAME_FUNC, LJ_ENDIAN_SELECT(-8,-4) +|.define HI, LJ_ENDIAN_SELECT(4,0) +|.define LO, LJ_ENDIAN_SELECT(0,4) +|.define OFS_RD, LJ_ENDIAN_SELECT(2,0) +|.define OFS_RA, LJ_ENDIAN_SELECT(1,2) +|.define OFS_OP, LJ_ENDIAN_SELECT(0,3) +| +|// Instruction decode. +|.macro decode_OP1, dst, ins; andi dst, ins, 0xff; .endmacro +|.macro decode_OP4a, dst, ins; andi dst, ins, 0xff; .endmacro +|.macro decode_OP4b, dst; sll dst, dst, 2; .endmacro +|.macro decode_RC4a, dst, ins; srl dst, ins, 14; .endmacro +|.macro decode_RC4b, dst; andi dst, dst, 0x3fc; .endmacro +|.macro decode_RD4b, dst; sll dst, dst, 2; .endmacro +|.macro decode_RA8a, dst, ins; srl dst, ins, 5; .endmacro +|.macro decode_RA8b, dst; andi dst, dst, 0x7f8; .endmacro +|.macro decode_RB8a, dst, ins; srl dst, ins, 21; .endmacro +|.macro decode_RB8b, dst; andi dst, dst, 0x7f8; .endmacro +|.macro decode_RD8a, dst, ins; srl dst, ins, 16; .endmacro +|.macro decode_RD8b, dst; sll dst, dst, 3; .endmacro +|.macro decode_RDtoRC8, dst, src; andi dst, src, 0x7f8; .endmacro +| +|// Instruction fetch. +|.macro ins_NEXT1 +| lw INS, 0(PC) +| addiu PC, PC, 4 +|.endmacro +|// Instruction decode+dispatch. +|.macro ins_NEXT2 +| decode_OP4a TMP1, INS +| decode_OP4b TMP1 +| addu TMP0, DISPATCH, TMP1 +| decode_RD8a RD, INS +| lw AT, 0(TMP0) +| decode_RA8a RA, INS +| decode_RD8b RD +| jr AT +| decode_RA8b RA +|.endmacro +|.macro ins_NEXT +| ins_NEXT1 +| ins_NEXT2 +|.endmacro +| +|// Instruction footer. +|.if 1 +| // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. +| .define ins_next, ins_NEXT +| .define ins_next_, ins_NEXT +| .define ins_next1, ins_NEXT1 +| .define ins_next2, ins_NEXT2 +|.else +| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. +| // Affects only certain kinds of benchmarks (and only with -j off). +| .macro ins_next +| b ->ins_next +| .endmacro +| .macro ins_next1 +| .endmacro +| .macro ins_next2 +| b ->ins_next +| .endmacro +| .macro ins_next_ +| ->ins_next: +| ins_NEXT +| .endmacro +|.endif +| +|// Call decode and dispatch. +|.macro ins_callt +| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC +| lw PC, LFUNC:RB->pc +| lw INS, 0(PC) +| addiu PC, PC, 4 +| decode_OP4a TMP1, INS +| decode_RA8a RA, INS +| decode_OP4b TMP1 +| decode_RA8b RA +| addu TMP0, DISPATCH, TMP1 +| lw TMP0, 0(TMP0) +| jr TMP0 +| addu RA, RA, BASE +|.endmacro +| +|.macro ins_call +| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, PC = caller PC +| sw PC, FRAME_PC(BASE) +| ins_callt +|.endmacro +| +|//----------------------------------------------------------------------- +| +|.macro branch_RD +| srl TMP0, RD, 1 +| lui AT, (-(BCBIAS_J*4 >> 16) & 65535) +| addu TMP0, TMP0, AT +| addu PC, PC, TMP0 +|.endmacro +| +|// Assumes DISPATCH is relative to GL. +#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) +#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) +#define GG_DISP2GOT (GG_OFS(got) - GG_OFS(dispatch)) +#define DISPATCH_GOT(name) (GG_DISP2GOT + 4*LJ_GOT_##name) +| +#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) +| +|.macro load_got, func +| lw CFUNCADDR, DISPATCH_GOT(func)(DISPATCH) +|.endmacro +|// Much faster. Sadly, there's no easy way to force the required code layout. +|// .macro call_intern, func; bal extern func; .endmacro +|.macro call_intern, func; jalr CFUNCADDR; .endmacro +|.macro call_extern; jalr CFUNCADDR; .endmacro +|.macro jmp_extern; jr CFUNCADDR; .endmacro +| +|.macro hotcheck, delta, target +| srl TMP1, PC, 1 +| andi TMP1, TMP1, 126 +| addu TMP1, TMP1, DISPATCH +| lhu TMP2, GG_DISP2HOT(TMP1) +| addiu TMP2, TMP2, -delta +| bltz TMP2, target +|. sh TMP2, GG_DISP2HOT(TMP1) +|.endmacro +| +|.macro hotloop +| hotcheck HOTCOUNT_LOOP, ->vm_hotloop +|.endmacro +| +|.macro hotcall +| hotcheck HOTCOUNT_CALL, ->vm_hotcall +|.endmacro +| +|// Set current VM state. Uses TMP0. +|.macro li_vmstate, st; li TMP0, ~LJ_VMST_..st; .endmacro +|.macro st_vmstate; sw TMP0, DISPATCH_GL(vmstate)(DISPATCH); .endmacro +| +|// Move table write barrier back. Overwrites mark and tmp. +|.macro barrierback, tab, mark, tmp, target +| lw tmp, DISPATCH_GL(gc.grayagain)(DISPATCH) +| andi mark, mark, ~LJ_GC_BLACK & 255 // black2gray(tab) +| sw tab, DISPATCH_GL(gc.grayagain)(DISPATCH) +| sb mark, tab->marked +| b target +|. sw tmp, tab->gclist +|.endmacro +| +|//----------------------------------------------------------------------- + +/* Generate subroutines used by opcodes and other parts of the VM. */ +/* The .code_sub section should be last to help static branch prediction. */ +static void build_subroutines(BuildCtx *ctx) +{ + |.code_sub + | + |//----------------------------------------------------------------------- + |//-- Return handling ---------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_returnp: + | // See vm_return. Also: TMP2 = previous base. + | andi AT, PC, FRAME_P + | beqz AT, ->cont_dispatch + |. li TMP1, LJ_TTRUE + | + | // Return from pcall or xpcall fast func. + | lw PC, FRAME_PC(TMP2) // Fetch PC of previous frame. + | move BASE, TMP2 // Restore caller base. + | // Prepending may overwrite the pcall frame, so do it at the end. + | sw TMP1, FRAME_PC(RA) // Prepend true to results. + | addiu RA, RA, -8 + | + |->vm_returnc: + | addiu RD, RD, 8 // RD = (nresults+1)*8. + | andi TMP0, PC, FRAME_TYPE + | beqz RD, ->vm_unwind_c_eh + |. li CRET1, LUA_YIELD + | beqz TMP0, ->BC_RET_Z // Handle regular return to Lua. + |. move MULTRES, RD + | + |->vm_return: + | // BASE = base, RA = resultptr, RD/MULTRES = (nresults+1)*8, PC = return + | // TMP0 = PC & FRAME_TYPE + | li TMP2, -8 + | xori AT, TMP0, FRAME_C + | and TMP2, PC, TMP2 + | bnez AT, ->vm_returnp + | subu TMP2, BASE, TMP2 // TMP2 = previous base. + | + | addiu TMP1, RD, -8 + | sw TMP2, L->base + | li_vmstate C + | lw TMP2, SAVE_NRES + | addiu BASE, BASE, -8 + | st_vmstate + | beqz TMP1, >2 + |. sll TMP2, TMP2, 3 + |1: + | addiu TMP1, TMP1, -8 + | ldc1 f0, 0(RA) + | addiu RA, RA, 8 + | sdc1 f0, 0(BASE) + | bnez TMP1, <1 + |. addiu BASE, BASE, 8 + | + |2: + | bne TMP2, RD, >6 + |3: + |. sw BASE, L->top // Store new top. + | + |->vm_leave_cp: + | lw TMP0, SAVE_CFRAME // Restore previous C frame. + | move CRET1, r0 // Ok return status for vm_pcall. + | sw TMP0, L->cframe + | + |->vm_leave_unw: + | restoreregs_ret + | + |6: + | lw TMP1, L->maxstack + | slt AT, TMP2, RD + | bnez AT, >7 // Less results wanted? + | // More results wanted. Check stack size and fill up results with nil. + |. slt AT, BASE, TMP1 + | beqz AT, >8 + |. nop + | sw TISNIL, HI(BASE) + | addiu RD, RD, 8 + | b <2 + |. addiu BASE, BASE, 8 + | + |7: // Less results wanted. + | subu TMP0, RD, TMP2 + | subu TMP0, BASE, TMP0 // Either keep top or shrink it. + | b <3 + |. movn BASE, TMP0, TMP2 // LUA_MULTRET+1 case? + | + |8: // Corner case: need to grow stack for filling up results. + | // This can happen if: + | // - A C function grows the stack (a lot). + | // - The GC shrinks the stack in between. + | // - A return back from a lua_call() with (high) nresults adjustment. + | load_got lj_state_growstack + | move MULTRES, RD + | srl CARG2, TMP2, 3 + | call_intern lj_state_growstack // (lua_State *L, int n) + |. move CARG1, L + | lw TMP2, SAVE_NRES + | lw BASE, L->top // Need the (realloced) L->top in BASE. + | move RD, MULTRES + | b <2 + |. sll TMP2, TMP2, 3 + | + |->vm_unwind_c: // Unwind C stack, return from vm_pcall. + | // (void *cframe, int errcode) + | move sp, CARG1 + | move CRET1, CARG2 + |->vm_unwind_c_eh: // Landing pad for external unwinder. + | lw L, SAVE_L + | li TMP0, ~LJ_VMST_C + | lw GL:TMP1, L->glref + | b ->vm_leave_unw + |. sw TMP0, GL:TMP1->vmstate + | + |->vm_unwind_ff: // Unwind C stack, return from ff pcall. + | // (void *cframe) + | li AT, -4 + | and sp, CARG1, AT + |->vm_unwind_ff_eh: // Landing pad for external unwinder. + | lw L, SAVE_L + | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | li TISNIL, LJ_TNIL + | lw BASE, L->base + | lw DISPATCH, L->glref // Setup pointer to dispatch table. + | mtc1 TMP3, TOBIT + | li TMP1, LJ_TFALSE + | li_vmstate INTERP + | lw PC, FRAME_PC(BASE) // Fetch PC of previous frame. + | cvt.d.s TOBIT, TOBIT + | addiu RA, BASE, -8 // Results start at BASE-8. + | addiu DISPATCH, DISPATCH, GG_G2DISP + | sw TMP1, HI(RA) // Prepend false to error message. + | st_vmstate + | b ->vm_returnc + |. li RD, 16 // 2 results: false + error message. + | + |//----------------------------------------------------------------------- + |//-- Grow stack for calls ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_growstack_c: // Grow stack for C function. + | b >2 + |. li CARG2, LUA_MINSTACK + | + |->vm_growstack_l: // Grow stack for Lua function. + | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC + | addu RC, BASE, RC + | subu RA, RA, BASE + | sw BASE, L->base + | addiu PC, PC, 4 // Must point after first instruction. + | sw RC, L->top + | srl CARG2, RA, 3 + |2: + | // L->base = new base, L->top = top + | load_got lj_state_growstack + | sw PC, SAVE_PC + | call_intern lj_state_growstack // (lua_State *L, int n) + |. move CARG1, L + | lw BASE, L->base + | lw RC, L->top + | lw LFUNC:RB, FRAME_FUNC(BASE) + | subu RC, RC, BASE + | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC + | ins_callt // Just retry the call. + | + |//----------------------------------------------------------------------- + |//-- Entry points into the assembler VM --------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_resume: // Setup C frame and resume thread. + | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) + | saveregs + | move L, CARG1 + | lw DISPATCH, L->glref // Setup pointer to dispatch table. + | move BASE, CARG2 + | lbu TMP1, L->status + | sw L, SAVE_L + | li PC, FRAME_CP + | addiu TMP0, sp, CFRAME_RESUME + | addiu DISPATCH, DISPATCH, GG_G2DISP + | sw r0, SAVE_NRES + | sw r0, SAVE_ERRF + | sw TMP0, L->cframe + | sw r0, SAVE_CFRAME + | beqz TMP1, >3 + |. sw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | + | // Resume after yield (like a return). + | move RA, BASE + | lw BASE, L->base + | lw TMP1, L->top + | lw PC, FRAME_PC(BASE) + | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | subu RD, TMP1, BASE + | mtc1 TMP3, TOBIT + | sb r0, L->status + | cvt.d.s TOBIT, TOBIT + | li_vmstate INTERP + | addiu RD, RD, 8 + | st_vmstate + | move MULTRES, RD + | andi TMP0, PC, FRAME_TYPE + | beqz TMP0, ->BC_RET_Z + |. li TISNIL, LJ_TNIL + | b ->vm_return + |. nop + | + |->vm_pcall: // Setup protected C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) + | saveregs + | sw CARG4, SAVE_ERRF + | b >1 + |. li PC, FRAME_CP + | + |->vm_call: // Setup C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1) + | saveregs + | li PC, FRAME_C + | + |1: // Entry point for vm_pcall above (PC = ftype). + | lw TMP1, L:CARG1->cframe + | sw CARG3, SAVE_NRES + | move L, CARG1 + | sw CARG1, SAVE_L + | move BASE, CARG2 + | sw sp, L->cframe // Add our C frame to cframe chain. + | lw DISPATCH, L->glref // Setup pointer to dispatch table. + | sw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | sw TMP1, SAVE_CFRAME + | addiu DISPATCH, DISPATCH, GG_G2DISP + | + |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). + | lw TMP2, L->base // TMP2 = old base (used in vmeta_call). + | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | lw TMP1, L->top + | mtc1 TMP3, TOBIT + | addu PC, PC, BASE + | subu NARGS8:RC, TMP1, BASE + | subu PC, PC, TMP2 // PC = frame delta + frame type + | cvt.d.s TOBIT, TOBIT + | li_vmstate INTERP + | li TISNIL, LJ_TNIL + | st_vmstate + | + |->vm_call_dispatch: + | // TMP2 = old base, BASE = new base, RC = nargs*8, PC = caller PC + | lw TMP0, FRAME_PC(BASE) + | li AT, LJ_TFUNC + | bne TMP0, AT, ->vmeta_call + |. lw LFUNC:RB, FRAME_FUNC(BASE) + | + |->vm_call_dispatch_f: + | ins_call + | // BASE = new base, RB = func, RC = nargs*8, PC = caller PC + | + |->vm_cpcall: // Setup protected C frame, call C. + | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) + | saveregs + | move L, CARG1 + | lw TMP0, L:CARG1->stack + | sw CARG1, SAVE_L + | lw TMP1, L->top + | sw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | subu TMP0, TMP0, TMP1 // Compute -savestack(L, L->top). + | lw TMP1, L->cframe + | sw sp, L->cframe // Add our C frame to cframe chain. + | sw TMP0, SAVE_NRES // Neg. delta means cframe w/o frame. + | sw r0, SAVE_ERRF // No error function. + | move CFUNCADDR, CARG4 + | jalr CARG4 // (lua_State *L, lua_CFunction func, void *ud) + |. sw TMP1, SAVE_CFRAME + | move BASE, CRET1 + | lw DISPATCH, L->glref // Setup pointer to dispatch table. + | li PC, FRAME_CP + | bnez CRET1, <3 // Else continue with the call. + |. addiu DISPATCH, DISPATCH, GG_G2DISP + | b ->vm_leave_cp // No base? Just remove C frame. + |. nop + | + |//----------------------------------------------------------------------- + |//-- Metamethod handling ------------------------------------------------ + |//----------------------------------------------------------------------- + | + |// The lj_meta_* functions (except for lj_meta_cat) don't reallocate the + |// stack, so BASE doesn't need to be reloaded across these calls. + | + |//-- Continuation dispatch ---------------------------------------------- + | + |->cont_dispatch: + | // BASE = meta base, RA = resultptr, RD = (nresults+1)*8 + | lw TMP0, -16+LO(BASE) // Continuation. + | move RB, BASE + | move BASE, TMP2 // Restore caller BASE. + | lw LFUNC:TMP1, FRAME_FUNC(TMP2) + |.if FFI + | sltiu AT, TMP0, 2 + |.endif + | lw PC, -16+HI(RB) // Restore PC from [cont|PC]. + | addu TMP2, RA, RD + | lw TMP1, LFUNC:TMP1->pc + |.if FFI + | bnez AT, >1 + |.endif + |. sw TISNIL, -8+HI(TMP2) // Ensure one valid arg. + | // BASE = base, RA = resultptr, RB = meta base + | jr TMP0 // Jump to continuation. + |. lw KBASE, PC2PROTO(k)(TMP1) + | + |.if FFI + |1: + | bnez TMP0, ->cont_ffi_callback // cont = 1: return from FFI callback. + | // cont = 0: tailcall from C function. + |. addiu TMP1, RB, -16 + | b ->vm_call_tail + |. subu RC, TMP1, BASE + |.endif + | + |->cont_cat: // RA = resultptr, RB = meta base + | lw INS, -4(PC) + | addiu CARG2, RB, -16 + | ldc1 f0, 0(RA) + | decode_RB8a MULTRES, INS + | decode_RA8a RA, INS + | decode_RB8b MULTRES + | decode_RA8b RA + | addu TMP1, BASE, MULTRES + | sw BASE, L->base + | subu CARG3, CARG2, TMP1 + | bne TMP1, CARG2, ->BC_CAT_Z + |. sdc1 f0, 0(CARG2) + | addu RA, BASE, RA + | b ->cont_nop + |. sdc1 f0, 0(RA) + | + |//-- Table indexing metamethods ----------------------------------------- + | + |->vmeta_tgets1: + | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) + | li TMP0, LJ_TSTR + | sw STR:RC, LO(CARG3) + | b >1 + |. sw TMP0, HI(CARG3) + | + |->vmeta_tgets: + | addiu CARG2, DISPATCH, DISPATCH_GL(tmptv) + | li TMP0, LJ_TTAB + | sw TAB:RB, LO(CARG2) + | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv2) + | sw TMP0, HI(CARG2) + | li TMP1, LJ_TSTR + | sw STR:RC, LO(CARG3) + | b >1 + |. sw TMP1, HI(CARG3) + | + |->vmeta_tgetb: // TMP0 = index + | mtc1 TMP0, f0 + | cvt.d.w f0, f0 + | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) + | sdc1 f0, 0(CARG3) + | + |->vmeta_tgetv: + |1: + | load_got lj_meta_tget + | sw BASE, L->base + | sw PC, SAVE_PC + | call_intern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) + |. move CARG1, L + | // Returns TValue * (finished) or NULL (metamethod). + | beqz CRET1, >3 + |. addiu TMP1, BASE, -FRAME_CONT + | ldc1 f0, 0(CRET1) + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + | + |3: // Call __index metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k + | lw BASE, L->top + | sw PC, -16+HI(BASE) // [cont|PC] + | subu PC, BASE, TMP1 + | lw LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | b ->vm_call_dispatch_f + |. li NARGS8:RC, 16 // 2 args for func(t, k). + | + |//----------------------------------------------------------------------- + | + |->vmeta_tsets1: + | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) + | li TMP0, LJ_TSTR + | sw STR:RC, LO(CARG3) + | b >1 + |. sw TMP0, HI(CARG3) + | + |->vmeta_tsets: + | addiu CARG2, DISPATCH, DISPATCH_GL(tmptv) + | li TMP0, LJ_TTAB + | sw TAB:RB, LO(CARG2) + | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv2) + | sw TMP0, HI(CARG2) + | li TMP1, LJ_TSTR + | sw STR:RC, LO(CARG3) + | b >1 + |. sw TMP1, HI(CARG3) + | + |->vmeta_tsetb: // TMP0 = index + | mtc1 TMP0, f0 + | cvt.d.w f0, f0 + | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) + | sdc1 f0, 0(CARG3) + | + |->vmeta_tsetv: + |1: + | load_got lj_meta_tset + | sw BASE, L->base + | sw PC, SAVE_PC + | call_intern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) + |. move CARG1, L + | // Returns TValue * (finished) or NULL (metamethod). + | beqz CRET1, >3 + |. ldc1 f0, 0(RA) + | // NOBARRIER: lj_meta_tset ensures the table is not black. + | ins_next1 + | sdc1 f0, 0(CRET1) + | ins_next2 + | + |3: // Call __newindex metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) + | addiu TMP1, BASE, -FRAME_CONT + | lw BASE, L->top + | sw PC, -16+HI(BASE) // [cont|PC] + | subu PC, BASE, TMP1 + | lw LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | sdc1 f0, 16(BASE) // Copy value to third argument. + | b ->vm_call_dispatch_f + |. li NARGS8:RC, 24 // 3 args for func(t, k, v) + | + |//-- Comparison metamethods --------------------------------------------- + | + |->vmeta_comp: + | // CARG2, CARG3 are already set by BC_ISLT/BC_ISGE/BC_ISLE/BC_ISGT. + | load_got lj_meta_comp + | addiu PC, PC, -4 + | sw BASE, L->base + | sw PC, SAVE_PC + | decode_OP1 CARG4, INS + | call_intern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) + |. move CARG1, L + | // Returns 0/1 or TValue * (metamethod). + |3: + | sltiu AT, CRET1, 2 + | beqz AT, ->vmeta_binop + | negu TMP2, CRET1 + |4: + | lhu RD, OFS_RD(PC) + | addiu PC, PC, 4 + | lui TMP1, (-(BCBIAS_J*4 >> 16) & 65535) + | sll RD, RD, 2 + | addu RD, RD, TMP1 + | and RD, RD, TMP2 + | addu PC, PC, RD + |->cont_nop: + | ins_next + | + |->cont_ra: // RA = resultptr + | lbu TMP1, -4+OFS_RA(PC) + | ldc1 f0, 0(RA) + | sll TMP1, TMP1, 3 + | addu TMP1, BASE, TMP1 + | b ->cont_nop + |. sdc1 f0, 0(TMP1) + | + |->cont_condt: // RA = resultptr + | lw TMP0, HI(RA) + | sltiu AT, TMP0, LJ_TISTRUECOND + | b <4 + |. negu TMP2, AT // Branch if result is true. + | + |->cont_condf: // RA = resultptr + | lw TMP0, HI(RA) + | sltiu AT, TMP0, LJ_TISTRUECOND + | b <4 + |. addiu TMP2, AT, -1 // Branch if result is false. + | + |->vmeta_equal: + | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. + | load_got lj_meta_equal + | addiu PC, PC, -4 + | sw BASE, L->base + | sw PC, SAVE_PC + | call_intern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) + |. move CARG1, L + | // Returns 0/1 or TValue * (metamethod). + | b <3 + |. nop + | + |->vmeta_equal_cd: + |.if FFI + | load_got lj_meta_equal_cd + | move CARG2, INS + | addiu PC, PC, -4 + | sw BASE, L->base + | sw PC, SAVE_PC + | call_intern lj_meta_equal_cd // (lua_State *L, BCIns op) + |. move CARG1, L + | // Returns 0/1 or TValue * (metamethod). + | b <3 + |. nop + |.endif + | + |//-- Arithmetic metamethods --------------------------------------------- + | + |->vmeta_unm: + | move CARG4, CARG3 + | + |->vmeta_arith: + | load_got lj_meta_arith + | decode_OP1 TMP0, INS + | sw BASE, L->base + | sw PC, SAVE_PC + | move CARG2, RA + | sw TMP0, ARG5 + | call_intern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) + |. move CARG1, L + | // Returns NULL (finished) or TValue * (metamethod). + | beqz CRET1, ->cont_nop + |. nop + | + | // Call metamethod for binary op. + |->vmeta_binop: + | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 + | subu TMP1, CRET1, BASE + | sw PC, -16+HI(CRET1) // [cont|PC] + | move TMP2, BASE + | addiu PC, TMP1, FRAME_CONT + | move BASE, CRET1 + | b ->vm_call_dispatch + |. li NARGS8:RC, 16 // 2 args for func(o1, o2). + | + |->vmeta_len: + | // CARG2 already set by BC_LEN. +#if LJ_52 + | move MULTRES, CARG1 +#endif + | load_got lj_meta_len + | sw BASE, L->base + | sw PC, SAVE_PC + | call_intern lj_meta_len // (lua_State *L, TValue *o) + |. move CARG1, L + | // Returns NULL (retry) or TValue * (metamethod base). +#if LJ_52 + | bnez CRET1, ->vmeta_binop // Binop call for compatibility. + |. nop + | b ->BC_LEN_Z + |. move CARG1, MULTRES +#else + | b ->vmeta_binop // Binop call for compatibility. + |. nop +#endif + | + |//-- Call metamethod ---------------------------------------------------- + | + |->vmeta_call: // Resolve and call __call metamethod. + | // TMP2 = old base, BASE = new base, RC = nargs*8 + | load_got lj_meta_call + | sw TMP2, L->base // This is the callers base! + | addiu CARG2, BASE, -8 + | sw PC, SAVE_PC + | addu CARG3, BASE, RC + | move MULTRES, NARGS8:RC + | call_intern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + |. move CARG1, L + | lw LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | addiu NARGS8:RC, MULTRES, 8 // Got one more argument now. + | ins_call + | + |->vmeta_callt: // Resolve __call for BC_CALLT. + | // BASE = old base, RA = new base, RC = nargs*8 + | load_got lj_meta_call + | sw BASE, L->base + | addiu CARG2, RA, -8 + | sw PC, SAVE_PC + | addu CARG3, RA, RC + | move MULTRES, NARGS8:RC + | call_intern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + |. move CARG1, L + | lw TMP1, FRAME_PC(BASE) + | lw LFUNC:RB, FRAME_FUNC(RA) // Guaranteed to be a function here. + | b ->BC_CALLT_Z + |. addiu NARGS8:RC, MULTRES, 8 // Got one more argument now. + | + |//-- Argument coercion for 'for' statement ------------------------------ + | + |->vmeta_for: + | load_got lj_meta_for + | sw BASE, L->base + | move CARG2, RA + | sw PC, SAVE_PC + | move MULTRES, INS + | call_intern lj_meta_for // (lua_State *L, TValue *base) + |. move CARG1, L + |.if JIT + | decode_OP1 TMP0, MULTRES + | li AT, BC_JFORI + |.endif + | decode_RA8a RA, MULTRES + | decode_RD8a RD, MULTRES + | decode_RA8b RA + |.if JIT + | beq TMP0, AT, =>BC_JFORI + |. decode_RD8b RD + | b =>BC_FORI + |. nop + |.else + | b =>BC_FORI + |. decode_RD8b RD + |.endif + | + |//----------------------------------------------------------------------- + |//-- Fast functions ----------------------------------------------------- + |//----------------------------------------------------------------------- + | + |.macro .ffunc, name + |->ff_ .. name: + |.endmacro + | + |.macro .ffunc_1, name + |->ff_ .. name: + | beqz NARGS8:RC, ->fff_fallback + |. lw CARG3, HI(BASE) + | lw CARG1, LO(BASE) + |.endmacro + | + |.macro .ffunc_2, name + |->ff_ .. name: + | sltiu AT, NARGS8:RC, 16 + | lw CARG3, HI(BASE) + | bnez AT, ->fff_fallback + |. lw CARG4, 8+HI(BASE) + | lw CARG1, LO(BASE) + | lw CARG2, 8+LO(BASE) + |.endmacro + | + |.macro .ffunc_n, name // Caveat: has delay slot! + |->ff_ .. name: + | lw CARG3, HI(BASE) + | beqz NARGS8:RC, ->fff_fallback + |. ldc1 FARG1, 0(BASE) + | sltiu AT, CARG3, LJ_TISNUM + | beqz AT, ->fff_fallback + |.endmacro + | + |.macro .ffunc_nn, name // Caveat: has delay slot! + |->ff_ .. name: + | sltiu AT, NARGS8:RC, 16 + | lw CARG3, HI(BASE) + | bnez AT, ->fff_fallback + |. lw CARG4, 8+HI(BASE) + | ldc1 FARG1, 0(BASE) + | ldc1 FARG2, 8(BASE) + | sltiu TMP0, CARG3, LJ_TISNUM + | sltiu TMP1, CARG4, LJ_TISNUM + | and TMP0, TMP0, TMP1 + | beqz TMP0, ->fff_fallback + |.endmacro + | + |// Inlined GC threshold check. Caveat: uses TMP0 and TMP1 and has delay slot! + |.macro ffgccheck + | lw TMP0, DISPATCH_GL(gc.total)(DISPATCH) + | lw TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) + | subu AT, TMP0, TMP1 + | bgezal AT, ->fff_gcstep + |.endmacro + | + |//-- Base library: checks ----------------------------------------------- + | + |.ffunc_1 assert + | sltiu AT, CARG3, LJ_TISTRUECOND + | beqz AT, ->fff_fallback + |. addiu RA, BASE, -8 + | lw PC, FRAME_PC(BASE) + | addiu RD, NARGS8:RC, 8 // Compute (nresults+1)*8. + | addu TMP2, RA, NARGS8:RC + | sw CARG3, HI(RA) + | addiu TMP1, BASE, 8 + | beq BASE, TMP2, ->fff_res // Done if exactly 1 argument. + |. sw CARG1, LO(RA) + |1: + | ldc1 f0, 0(TMP1) + | sdc1 f0, -8(TMP1) + | bne TMP1, TMP2, <1 + |. addiu TMP1, TMP1, 8 + | b ->fff_res + |. nop + | + |.ffunc type + | lw CARG3, HI(BASE) + | li TMP1, LJ_TISNUM + | beqz NARGS8:RC, ->fff_fallback + |. sltiu TMP0, CARG3, LJ_TISNUM + | movz TMP1, CARG3, TMP0 + | not TMP1, TMP1 + | sll TMP1, TMP1, 3 + | addu TMP1, CFUNC:RB, TMP1 + | b ->fff_resn + |. ldc1 FRET1, CFUNC:TMP1->upvalue + | + |//-- Base library: getters and setters --------------------------------- + | + |.ffunc_1 getmetatable + | li AT, LJ_TTAB + | bne CARG3, AT, >6 + |. li AT, LJ_TUDATA + |1: // Field metatable must be at same offset for GCtab and GCudata! + | lw TAB:CARG1, TAB:CARG1->metatable + |2: + | lw STR:RC, DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])(DISPATCH) + | beqz TAB:CARG1, ->fff_restv + |. li CARG3, LJ_TNIL + | lw TMP0, TAB:CARG1->hmask + | li CARG3, LJ_TTAB // Use metatable as default result. + | lw TMP1, STR:RC->hash + | lw NODE:TMP2, TAB:CARG1->node + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | sll TMP0, TMP1, 5 + | sll TMP1, TMP1, 3 + | subu TMP1, TMP0, TMP1 + | addu NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + | li AT, LJ_TSTR + |3: // Rearranged logic, because we expect _not_ to find the key. + | lw CARG4, offsetof(Node, key)+HI(NODE:TMP2) + | lw TMP0, offsetof(Node, key)+LO(NODE:TMP2) + | lw NODE:TMP3, NODE:TMP2->next + | bne CARG4, AT, >4 + |. lw CARG2, offsetof(Node, val)+HI(NODE:TMP2) + | beq TMP0, STR:RC, >5 + |. lw TMP1, offsetof(Node, val)+LO(NODE:TMP2) + |4: + | beqz NODE:TMP3, ->fff_restv // Not found, keep default result. + |. move NODE:TMP2, NODE:TMP3 + | b <3 + |. nop + |5: + | beq CARG2, TISNIL, ->fff_restv // Ditto for nil value. + |. nop + | move CARG3, CARG2 // Return value of mt.__metatable. + | b ->fff_restv + |. move CARG1, TMP1 + | + |6: + | beq CARG3, AT, <1 + |. sltiu TMP0, CARG3, LJ_TISNUM + | li TMP1, LJ_TISNUM + | movz TMP1, CARG3, TMP0 + | not TMP1, TMP1 + | sll TMP1, TMP1, 2 + | addu TMP1, DISPATCH, TMP1 + | b <2 + |. lw TAB:CARG1, DISPATCH_GL(gcroot[GCROOT_BASEMT])(TMP1) + | + |.ffunc_2 setmetatable + | // Fast path: no mt for table yet and not clearing the mt. + | li AT, LJ_TTAB + | bne CARG3, AT, ->fff_fallback + |. addiu CARG4, CARG4, -LJ_TTAB + | lw TAB:TMP1, TAB:CARG1->metatable + | lbu TMP3, TAB:CARG1->marked + | or AT, CARG4, TAB:TMP1 + | bnez AT, ->fff_fallback + |. andi AT, TMP3, LJ_GC_BLACK // isblack(table) + | beqz AT, ->fff_restv + |. sw TAB:CARG2, TAB:CARG1->metatable + | barrierback TAB:CARG1, TMP3, TMP0, ->fff_restv + | + |.ffunc rawget + | lw CARG4, HI(BASE) + | sltiu AT, NARGS8:RC, 16 + | lw TAB:CARG2, LO(BASE) + | load_got lj_tab_get + | addiu CARG4, CARG4, -LJ_TTAB + | or AT, AT, CARG4 + | bnez AT, ->fff_fallback + | addiu CARG3, BASE, 8 + | call_intern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) + |. move CARG1, L + | // Returns cTValue *. + | b ->fff_resn + |. ldc1 FRET1, 0(CRET1) + | + |//-- Base library: conversions ------------------------------------------ + | + |.ffunc tonumber + | // Only handles the number case inline (without a base argument). + | lw CARG1, HI(BASE) + | xori AT, NARGS8:RC, 8 + | sltiu CARG1, CARG1, LJ_TISNUM + | movn CARG1, r0, AT + | beqz CARG1, ->fff_fallback // Exactly one number argument. + |. ldc1 FRET1, 0(BASE) + | b ->fff_resn + |. nop + | + |.ffunc_1 tostring + | // Only handles the string or number case inline. + | li AT, LJ_TSTR + | // A __tostring method in the string base metatable is ignored. + | beq CARG3, AT, ->fff_restv // String key? + | // Handle numbers inline, unless a number base metatable is present. + |. lw TMP1, DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])(DISPATCH) + | sltiu TMP0, CARG3, LJ_TISNUM + | sltiu TMP1, TMP1, 1 + | and TMP0, TMP0, TMP1 + | beqz TMP0, ->fff_fallback + |. sw BASE, L->base // Add frame since C call can throw. + | ffgccheck + |. sw PC, SAVE_PC // Redundant (but a defined value). + | load_got lj_str_fromnum + | move CARG1, L + | call_intern lj_str_fromnum // (lua_State *L, lua_Number *np) + |. move CARG2, BASE + | // Returns GCstr *. + | li CARG3, LJ_TSTR + | b ->fff_restv + |. move CARG1, CRET1 + | + |//-- Base library: iterators ------------------------------------------- + | + |.ffunc next + | lw CARG1, HI(BASE) + | lw TAB:CARG2, LO(BASE) + | beqz NARGS8:RC, ->fff_fallback + |. addu TMP2, BASE, NARGS8:RC + | li AT, LJ_TTAB + | sw TISNIL, HI(TMP2) // Set missing 2nd arg to nil. + | bne CARG1, AT, ->fff_fallback + |. lw PC, FRAME_PC(BASE) + | load_got lj_tab_next + | sw BASE, L->base // Add frame since C call can throw. + | sw BASE, L->top // Dummy frame length is ok. + | addiu CARG3, BASE, 8 + | sw PC, SAVE_PC + | call_intern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) + |. move CARG1, L + | // Returns 0 at end of traversal. + | beqz CRET1, ->fff_restv // End of traversal: return nil. + |. li CARG3, LJ_TNIL + | ldc1 f0, 8(BASE) // Copy key and value to results. + | addiu RA, BASE, -8 + | ldc1 f2, 16(BASE) + | li RD, (2+1)*8 + | sdc1 f0, 0(RA) + | b ->fff_res + |. sdc1 f2, 8(RA) + | + |.ffunc_1 pairs + | li AT, LJ_TTAB + | bne CARG3, AT, ->fff_fallback + |. lw PC, FRAME_PC(BASE) +#if LJ_52 + | lw TAB:TMP2, TAB:CARG1->metatable + | ldc1 f0, CFUNC:RB->upvalue[0] + | bnez TAB:TMP2, ->fff_fallback +#else + | ldc1 f0, CFUNC:RB->upvalue[0] +#endif + |. addiu RA, BASE, -8 + | sw TISNIL, 8+HI(BASE) + | li RD, (3+1)*8 + | b ->fff_res + |. sdc1 f0, 0(RA) + | + |.ffunc ipairs_aux + | sltiu AT, NARGS8:RC, 16 + | lw CARG3, HI(BASE) + | lw TAB:CARG1, LO(BASE) + | lw CARG4, 8+HI(BASE) + | bnez AT, ->fff_fallback + |. ldc1 FARG2, 8(BASE) + | addiu CARG3, CARG3, -LJ_TTAB + | sltiu AT, CARG4, LJ_TISNUM + | li TMP0, 1 + | movn AT, r0, CARG3 + | mtc1 TMP0, FARG1 + | beqz AT, ->fff_fallback + |. lw PC, FRAME_PC(BASE) + | cvt.w.d FRET1, FARG2 + | cvt.d.w FARG1, FARG1 + | lw TMP0, TAB:CARG1->asize + | lw TMP1, TAB:CARG1->array + | mfc1 TMP2, FRET1 + | addiu RA, BASE, -8 + | add.d FARG2, FARG2, FARG1 + | addiu TMP2, TMP2, 1 + | sltu AT, TMP2, TMP0 + | sll TMP3, TMP2, 3 + | addu TMP3, TMP1, TMP3 + | beqz AT, >2 // Not in array part? + |. sdc1 FARG2, 0(RA) + | lw TMP2, HI(TMP3) + | ldc1 f0, 0(TMP3) + |1: + | beq TMP2, TISNIL, ->fff_res // End of iteration, return 0 results. + |. li RD, (0+1)*8 + | li RD, (2+1)*8 + | b ->fff_res + |. sdc1 f0, 8(RA) + |2: // Check for empty hash part first. Otherwise call C function. + | lw TMP0, TAB:CARG1->hmask + | load_got lj_tab_getinth + | beqz TMP0, ->fff_res + |. li RD, (0+1)*8 + | call_intern lj_tab_getinth // (GCtab *t, int32_t key) + |. move CARG2, TMP2 + | // Returns cTValue * or NULL. + | beqz CRET1, ->fff_res + |. li RD, (0+1)*8 + | lw TMP2, HI(CRET1) + | b <1 + |. ldc1 f0, 0(CRET1) + | + |.ffunc_1 ipairs + | li AT, LJ_TTAB + | bne CARG3, AT, ->fff_fallback + |. lw PC, FRAME_PC(BASE) +#if LJ_52 + | lw TAB:TMP2, TAB:CARG1->metatable + | ldc1 f0, CFUNC:RB->upvalue[0] + | bnez TAB:TMP2, ->fff_fallback +#else + | ldc1 f0, CFUNC:RB->upvalue[0] +#endif + |. addiu RA, BASE, -8 + | sw r0, 8+HI(BASE) + | sw r0, 8+LO(BASE) + | li RD, (3+1)*8 + | b ->fff_res + |. sdc1 f0, 0(RA) + | + |//-- Base library: catch errors ---------------------------------------- + | + |.ffunc pcall + | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | beqz NARGS8:RC, ->fff_fallback + | move TMP2, BASE + | addiu BASE, BASE, 8 + | // Remember active hook before pcall. + | srl TMP3, TMP3, HOOK_ACTIVE_SHIFT + | andi TMP3, TMP3, 1 + | addiu PC, TMP3, 8+FRAME_PCALL + | b ->vm_call_dispatch + |. addiu NARGS8:RC, NARGS8:RC, -8 + | + |.ffunc xpcall + | sltiu AT, NARGS8:RC, 16 + | lw CARG4, 8+HI(BASE) + | bnez AT, ->fff_fallback + |. ldc1 FARG2, 8(BASE) + | ldc1 FARG1, 0(BASE) + | lbu TMP1, DISPATCH_GL(hookmask)(DISPATCH) + | li AT, LJ_TFUNC + | move TMP2, BASE + | bne CARG4, AT, ->fff_fallback // Traceback must be a function. + | addiu BASE, BASE, 16 + | // Remember active hook before pcall. + | srl TMP3, TMP3, HOOK_ACTIVE_SHIFT + | sdc1 FARG2, 0(TMP2) // Swap function and traceback. + | andi TMP3, TMP3, 1 + | sdc1 FARG1, 8(TMP2) + | addiu PC, TMP3, 16+FRAME_PCALL + | b ->vm_call_dispatch + |. addiu NARGS8:RC, NARGS8:RC, -16 + | + |//-- Coroutine library -------------------------------------------------- + | + |.macro coroutine_resume_wrap, resume + |.if resume + |.ffunc_1 coroutine_resume + | li AT, LJ_TTHREAD + | bne CARG3, AT, ->fff_fallback + |.else + |.ffunc coroutine_wrap_aux + | lw L:CARG1, CFUNC:RB->upvalue[0].gcr + |.endif + | lbu TMP0, L:CARG1->status + | lw TMP1, L:CARG1->cframe + | lw CARG2, L:CARG1->top + | lw TMP2, L:CARG1->base + | addiu TMP3, TMP0, -LUA_YIELD + | bgtz TMP3, ->fff_fallback // st > LUA_YIELD? + |. xor TMP2, TMP2, CARG2 + | bnez TMP1, ->fff_fallback // cframe != 0? + |. or AT, TMP2, TMP0 + | lw TMP0, L:CARG1->maxstack + | beqz AT, ->fff_fallback // base == top && st == 0? + |. lw PC, FRAME_PC(BASE) + | addu TMP2, CARG2, NARGS8:RC + | sltu AT, TMP0, TMP2 + | bnez AT, ->fff_fallback // Stack overflow? + |. sw PC, SAVE_PC + | sw BASE, L->base + |1: + |.if resume + | addiu BASE, BASE, 8 // Keep resumed thread in stack for GC. + | addiu NARGS8:RC, NARGS8:RC, -8 + | addiu TMP2, TMP2, -8 + |.endif + | sw TMP2, L:CARG1->top + | addu TMP1, BASE, NARGS8:RC + | move CARG3, CARG2 + | sw BASE, L->top + |2: // Move args to coroutine. + | ldc1 f0, 0(BASE) + | sltu AT, BASE, TMP1 + | beqz AT, >3 + |. addiu BASE, BASE, 8 + | sdc1 f0, 0(CARG3) + | b <2 + |. addiu CARG3, CARG3, 8 + |3: + | bal ->vm_resume // (lua_State *L, TValue *base, 0, 0) + |. move L:RA, L:CARG1 + | // Returns thread status. + |4: + | lw TMP2, L:RA->base + | sltiu AT, CRET1, LUA_YIELD+1 + | lw TMP3, L:RA->top + | li_vmstate INTERP + | lw BASE, L->base + | st_vmstate + | beqz AT, >8 + |. subu RD, TMP3, TMP2 + | lw TMP0, L->maxstack + | beqz RD, >6 // No results? + |. addu TMP1, BASE, RD + | sltu AT, TMP0, TMP1 + | bnez AT, >9 // Need to grow stack? + |. addu TMP3, TMP2, RD + | sw TMP2, L:RA->top // Clear coroutine stack. + | move TMP1, BASE + |5: // Move results from coroutine. + | ldc1 f0, 0(TMP2) + | addiu TMP2, TMP2, 8 + | sltu AT, TMP2, TMP3 + | sdc1 f0, 0(TMP1) + | bnez AT, <5 + |. addiu TMP1, TMP1, 8 + |6: + | andi TMP0, PC, FRAME_TYPE + |.if resume + | li TMP1, LJ_TTRUE + | addiu RA, BASE, -8 + | sw TMP1, -8+HI(BASE) // Prepend true to results. + | addiu RD, RD, 16 + |.else + | move RA, BASE + | addiu RD, RD, 8 + |.endif + |7: + | sw PC, SAVE_PC + | beqz TMP0, ->BC_RET_Z + |. move MULTRES, RD + | b ->vm_return + |. nop + | + |8: // Coroutine returned with error (at co->top-1). + |.if resume + | addiu TMP3, TMP3, -8 + | li TMP1, LJ_TFALSE + | ldc1 f0, 0(TMP3) + | sw TMP3, L:RA->top // Remove error from coroutine stack. + | li RD, (2+1)*8 + | sw TMP1, -8+HI(BASE) // Prepend false to results. + | addiu RA, BASE, -8 + | sdc1 f0, 0(BASE) // Copy error message. + | b <7 + |. andi TMP0, PC, FRAME_TYPE + |.else + | load_got lj_ffh_coroutine_wrap_err + | move CARG2, L:RA + | call_intern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) + |. move CARG1, L + |.endif + | + |9: // Handle stack expansion on return from yield. + | load_got lj_state_growstack + | srl CARG2, RD, 3 + | call_intern lj_state_growstack // (lua_State *L, int n) + |. move CARG1, L + | b <4 + |. li CRET1, 0 + |.endmacro + | + | coroutine_resume_wrap 1 // coroutine.resume + | coroutine_resume_wrap 0 // coroutine.wrap + | + |.ffunc coroutine_yield + | lw TMP0, L->cframe + | addu TMP1, BASE, NARGS8:RC + | sw BASE, L->base + | andi TMP0, TMP0, CFRAME_RESUME + | sw TMP1, L->top + | beqz TMP0, ->fff_fallback + |. li CRET1, LUA_YIELD + | sw r0, L->cframe + | b ->vm_leave_unw + |. sb CRET1, L->status + | + |//-- Math library ------------------------------------------------------- + | + |.ffunc_n math_abs + |. abs.d FRET1, FARG1 + |->fff_resn: + | lw PC, FRAME_PC(BASE) + | addiu RA, BASE, -8 + | b ->fff_res1 + |. sdc1 FRET1, -8(BASE) + | + |->fff_restv: + | // CARG3/CARG1 = TValue result. + | lw PC, FRAME_PC(BASE) + | sw CARG3, -8+HI(BASE) + | addiu RA, BASE, -8 + | sw CARG1, -8+LO(BASE) + |->fff_res1: + | // RA = results, PC = return. + | li RD, (1+1)*8 + |->fff_res: + | // RA = results, RD = (nresults+1)*8, PC = return. + | andi TMP0, PC, FRAME_TYPE + | bnez TMP0, ->vm_return + |. move MULTRES, RD + | lw INS, -4(PC) + | decode_RB8a RB, INS + | decode_RB8b RB + |5: + | sltu AT, RD, RB + | bnez AT, >6 // More results expected? + |. decode_RA8a TMP0, INS + | decode_RA8b TMP0 + | ins_next1 + | // Adjust BASE. KBASE is assumed to be set for the calling frame. + | subu BASE, RA, TMP0 + | ins_next2 + | + |6: // Fill up results with nil. + | addu TMP1, RA, RD + | addiu RD, RD, 8 + | b <5 + |. sw TISNIL, -8+HI(TMP1) + | + |.macro math_extern, func + |->ff_math_ .. func: + | lw CARG3, HI(BASE) + | beqz NARGS8:RC, ->fff_fallback + |. load_got func + | sltiu AT, CARG3, LJ_TISNUM + | beqz AT, ->fff_fallback + |. nop + | call_extern + |. ldc1 FARG1, 0(BASE) + | b ->fff_resn + |. nop + |.endmacro + | + |.macro math_extern2, func + | .ffunc_nn math_ .. func + |. load_got func + | call_extern + |. nop + | b ->fff_resn + |. nop + |.endmacro + | + |.macro math_round, func + | .ffunc_n math_ .. func + |. nop + | bal ->vm_ .. func + |. nop + | b ->fff_resn + |. nop + |.endmacro + | + | math_round floor + | math_round ceil + | + |.ffunc math_log + | lw CARG3, HI(BASE) + | li AT, 8 + | bne NARGS8:RC, AT, ->fff_fallback // Exactly 1 argument. + |. load_got log + | sltiu AT, CARG3, LJ_TISNUM + | beqz AT, ->fff_fallback + |. nop + | call_extern + |. ldc1 FARG1, 0(BASE) + | b ->fff_resn + |. nop + | + | math_extern log10 + | math_extern exp + | math_extern sin + | math_extern cos + | math_extern tan + | math_extern asin + | math_extern acos + | math_extern atan + | math_extern sinh + | math_extern cosh + | math_extern tanh + | math_extern2 pow + | math_extern2 atan2 + | math_extern2 fmod + | + |.ffunc_n math_sqrt + |. sqrt.d FRET1, FARG1 + | b ->fff_resn + |. nop + | + |->ff_math_deg: + |.ffunc_n math_rad + |. ldc1 FARG2, CFUNC:RB->upvalue[0] + | b ->fff_resn + |. mul.d FRET1, FARG1, FARG2 + | + |.ffunc_nn math_ldexp + | cvt.w.d FARG2, FARG2 + | load_got ldexp + | mfc1 CARG3, FARG2 + | call_extern + |. nop + | b ->fff_resn + |. nop + | + |.ffunc_n math_frexp + | load_got frexp + | lw PC, FRAME_PC(BASE) + | call_extern + |. addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) + | lw TMP1, DISPATCH_GL(tmptv)(DISPATCH) + | addiu RA, BASE, -8 + | mtc1 TMP1, FARG2 + | sdc1 FRET1, 0(RA) + | cvt.d.w FARG2, FARG2 + | sdc1 FARG2, 8(RA) + | b ->fff_res + |. li RD, (2+1)*8 + | + |.ffunc_n math_modf + | load_got modf + | lw PC, FRAME_PC(BASE) + | call_extern + |. addiu CARG3, BASE, -8 + | addiu RA, BASE, -8 + | sdc1 FRET1, 0(BASE) + | b ->fff_res + |. li RD, (2+1)*8 + | + |.macro math_minmax, name, ismax + |->ff_ .. name: + | lw CARG3, HI(BASE) + | beqz NARGS8:RC, ->fff_fallback + |. ldc1 FRET1, 0(BASE) + | sltiu AT, CARG3, LJ_TISNUM + | beqz AT, ->fff_fallback + |. addu TMP2, BASE, NARGS8:RC + | addiu TMP1, BASE, 8 + | beq TMP1, TMP2, ->fff_resn + |1: + |. lw CARG3, HI(TMP1) + | ldc1 FARG1, 0(TMP1) + | addiu TMP1, TMP1, 8 + | sltiu AT, CARG3, LJ_TISNUM + | beqz AT, ->fff_fallback + |.if ismax + |. c.olt.d FARG1, FRET1 + |.else + |. c.olt.d FRET1, FARG1 + |.endif + | bne TMP1, TMP2, <1 + |. movf.d FRET1, FARG1 + | b ->fff_resn + |. nop + |.endmacro + | + | math_minmax math_min, 0 + | math_minmax math_max, 1 + | + |//-- String library ----------------------------------------------------- + | + |.ffunc_1 string_len + | li AT, LJ_TSTR + | bne CARG3, AT, ->fff_fallback + |. nop + | b ->fff_resi + |. lw CRET1, STR:CARG1->len + | + |.ffunc string_byte // Only handle the 1-arg case here. + | lw CARG3, HI(BASE) + | lw STR:CARG1, LO(BASE) + | xori AT, NARGS8:RC, 8 + | addiu CARG3, CARG3, -LJ_TSTR + | or AT, AT, CARG3 + | bnez AT, ->fff_fallback // Need exactly 1 string argument. + |. nop + | lw TMP0, STR:CARG1->len + | lbu TMP1, STR:CARG1[1] // Access is always ok (NUL at end). + | addiu RA, BASE, -8 + | sltu RD, r0, TMP0 + | mtc1 TMP1, f0 + | addiu RD, RD, 1 + | cvt.d.w f0, f0 + | lw PC, FRAME_PC(BASE) + | sll RD, RD, 3 // RD = ((str->len != 0)+1)*8 + | b ->fff_res + |. sdc1 f0, 0(RA) + | + |.ffunc string_char // Only handle the 1-arg case here. + | ffgccheck + |. nop + | lw CARG3, HI(BASE) + | ldc1 FARG1, 0(BASE) + | li AT, 8 + | bne NARGS8:RC, AT, ->fff_fallback // Exactly 1 argument. + |. sltiu AT, CARG3, LJ_TISNUM + | beqz AT, ->fff_fallback + |. li CARG3, 1 + | cvt.w.d FARG1, FARG1 + | addiu CARG2, sp, ARG5_OFS + | sltiu AT, TMP0, 256 + | mfc1 TMP0, FARG1 + | beqz AT, ->fff_fallback + |. sw TMP0, ARG5 + |->fff_newstr: + | load_got lj_str_new + | sw BASE, L->base + | sw PC, SAVE_PC + | call_intern lj_str_new // (lua_State *L, char *str, size_t l) + |. move CARG1, L + | // Returns GCstr *. + | lw BASE, L->base + | move CARG1, CRET1 + | b ->fff_restv + |. li CARG3, LJ_TSTR + | + |.ffunc string_sub + | ffgccheck + |. nop + | addiu AT, NARGS8:RC, -16 + | lw CARG3, 16+HI(BASE) + | ldc1 f0, 16(BASE) + | lw TMP0, HI(BASE) + | lw STR:CARG1, LO(BASE) + | bltz AT, ->fff_fallback + | lw CARG2, 8+HI(BASE) + | ldc1 f2, 8(BASE) + | beqz AT, >1 + |. li CARG4, -1 + | cvt.w.d f0, f0 + | sltiu AT, CARG3, LJ_TISNUM + | beqz AT, ->fff_fallback + |. mfc1 CARG4, f0 + |1: + | sltiu AT, CARG2, LJ_TISNUM + | beqz AT, ->fff_fallback + |. li AT, LJ_TSTR + | cvt.w.d f2, f2 + | bne TMP0, AT, ->fff_fallback + |. lw CARG2, STR:CARG1->len + | mfc1 CARG3, f2 + | // STR:CARG1 = str, CARG2 = str->len, CARG3 = start, CARG4 = end + | slt AT, CARG4, r0 + | addiu TMP0, CARG2, 1 + | addu TMP1, CARG4, TMP0 + | slt TMP3, CARG3, r0 + | movn CARG4, TMP1, AT // if (end < 0) end += len+1 + | addu TMP1, CARG3, TMP0 + | movn CARG3, TMP1, TMP3 // if (start < 0) start += len+1 + | li TMP2, 1 + | slt AT, CARG4, r0 + | slt TMP3, r0, CARG3 + | movn CARG4, r0, AT // if (end < 0) end = 0 + | movz CARG3, TMP2, TMP3 // if (start < 1) start = 1 + | slt AT, CARG2, CARG4 + | movn CARG4, CARG2, AT // if (end > len) end = len + | addu CARG2, STR:CARG1, CARG3 + | subu CARG3, CARG4, CARG3 // len = end - start + | addiu CARG2, CARG2, sizeof(GCstr)-1 + | bgez CARG3, ->fff_newstr + |. addiu CARG3, CARG3, 1 // len++ + |->fff_emptystr: // Return empty string. + | addiu STR:CARG1, DISPATCH, DISPATCH_GL(strempty) + | b ->fff_restv + |. li CARG3, LJ_TSTR + | + |.ffunc string_rep // Only handle the 1-char case inline. + | ffgccheck + |. nop + | lw TMP0, HI(BASE) + | addiu AT, NARGS8:RC, -16 // Exactly 2 arguments. + | lw CARG4, 8+HI(BASE) + | lw STR:CARG1, LO(BASE) + | addiu TMP0, TMP0, -LJ_TSTR + | ldc1 f0, 8(BASE) + | or AT, AT, TMP0 + | bnez AT, ->fff_fallback + |. sltiu AT, CARG4, LJ_TISNUM + | cvt.w.d f0, f0 + | beqz AT, ->fff_fallback + |. lw TMP0, STR:CARG1->len + | mfc1 CARG3, f0 + | lw TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | li AT, 1 + | blez CARG3, ->fff_emptystr // Count <= 0? + |. sltu AT, AT, TMP0 + | beqz TMP0, ->fff_emptystr // Zero length string? + |. sltu TMP0, TMP1, CARG3 + | or AT, AT, TMP0 + | lw CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | bnez AT, ->fff_fallback // Fallback for > 1-char strings. + |. lbu TMP0, STR:CARG1[1] + | addu TMP2, CARG2, CARG3 + |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). + | addiu TMP2, TMP2, -1 + | sltu AT, CARG2, TMP2 + | bnez AT, <1 + |. sb TMP0, 0(TMP2) + | b ->fff_newstr + |. nop + | + |.ffunc string_reverse + | ffgccheck + |. nop + | lw CARG3, HI(BASE) + | lw STR:CARG1, LO(BASE) + | beqz NARGS8:RC, ->fff_fallback + |. li AT, LJ_TSTR + | bne CARG3, AT, ->fff_fallback + |. lw TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | lw CARG3, STR:CARG1->len + | addiu CARG1, STR:CARG1, #STR + | lw CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | sltu AT, TMP1, CARG3 + | bnez AT, ->fff_fallback + |. addu TMP3, CARG1, CARG3 + | addu CARG4, CARG2, CARG3 + |1: // Reverse string copy. + | lbu TMP1, 0(CARG1) + | sltu AT, CARG1, TMP3 + | beqz AT, ->fff_newstr + |. addiu CARG1, CARG1, 1 + | addiu CARG4, CARG4, -1 + | b <1 + | sb TMP1, 0(CARG4) + | + |.macro ffstring_case, name, lo + | .ffunc name + | ffgccheck + |. nop + | lw CARG3, HI(BASE) + | lw STR:CARG1, LO(BASE) + | beqz NARGS8:RC, ->fff_fallback + |. li AT, LJ_TSTR + | bne CARG3, AT, ->fff_fallback + |. lw TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | lw CARG3, STR:CARG1->len + | addiu CARG1, STR:CARG1, #STR + | lw CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | sltu AT, TMP1, CARG3 + | bnez AT, ->fff_fallback + |. addu TMP3, CARG1, CARG3 + | move CARG4, CARG2 + |1: // ASCII case conversion. + | lbu TMP1, 0(CARG1) + | sltu AT, CARG1, TMP3 + | beqz AT, ->fff_newstr + |. addiu TMP0, TMP1, -lo + | xori TMP2, TMP1, 0x20 + | sltiu AT, TMP0, 26 + | movn TMP1, TMP2, AT + | addiu CARG1, CARG1, 1 + | sb TMP1, 0(CARG4) + | b <1 + |. addiu CARG4, CARG4, 1 + |.endmacro + | + |ffstring_case string_lower, 65 + |ffstring_case string_upper, 97 + | + |//-- Table library ------------------------------------------------------ + | + |.ffunc_1 table_getn + | li AT, LJ_TTAB + | bne CARG3, AT, ->fff_fallback + |. load_got lj_tab_len + | call_intern lj_tab_len // (GCtab *t) + |. nop + | // Returns uint32_t (but less than 2^31). + | b ->fff_resi + |. nop + | + |//-- Bit library -------------------------------------------------------- + | + |.macro .ffunc_bit, name + | .ffunc_n bit_..name + |. add.d FARG1, FARG1, TOBIT + | mfc1 CRET1, FARG1 + |.endmacro + | + |.macro .ffunc_bit_op, name, ins + | .ffunc_bit name + | addiu TMP1, BASE, 8 + | addu TMP2, BASE, NARGS8:RC + |1: + | lw CARG4, HI(TMP1) + | beq TMP1, TMP2, ->fff_resi + |. ldc1 FARG1, 0(TMP1) + | sltiu AT, CARG4, LJ_TISNUM + | beqz AT, ->fff_fallback + | add.d FARG1, FARG1, TOBIT + | mfc1 CARG2, FARG1 + | ins CRET1, CRET1, CARG2 + | b <1 + |. addiu TMP1, TMP1, 8 + |.endmacro + | + |.ffunc_bit_op band, and + |.ffunc_bit_op bor, or + |.ffunc_bit_op bxor, xor + | + |.ffunc_bit bswap + | srl TMP0, CRET1, 24 + | srl TMP2, CRET1, 8 + | sll TMP1, CRET1, 24 + | andi TMP2, TMP2, 0xff00 + | or TMP0, TMP0, TMP1 + | andi CRET1, CRET1, 0xff00 + | or TMP0, TMP0, TMP2 + | sll CRET1, CRET1, 8 + | b ->fff_resi + |. or CRET1, TMP0, CRET1 + | + |.ffunc_bit bnot + | b ->fff_resi + |. not CRET1, CRET1 + | + |.macro .ffunc_bit_sh, name, ins, shmod + | .ffunc_nn bit_..name + |. add.d FARG1, FARG1, TOBIT + | add.d FARG2, FARG2, TOBIT + | mfc1 CARG1, FARG1 + | mfc1 CARG2, FARG2 + |.if shmod == 1 + | li AT, 32 + | subu TMP0, AT, CARG2 + | sllv CARG2, CARG1, CARG2 + | srlv CARG1, CARG1, TMP0 + |.elif shmod == 2 + | li AT, 32 + | subu TMP0, AT, CARG2 + | srlv CARG2, CARG1, CARG2 + | sllv CARG1, CARG1, TMP0 + |.endif + | b ->fff_resi + |. ins CRET1, CARG1, CARG2 + |.endmacro + | + |.ffunc_bit_sh lshift, sllv, 0 + |.ffunc_bit_sh rshift, srlv, 0 + |.ffunc_bit_sh arshift, srav, 0 + |// Can't use rotrv, since it's only in MIPS32R2. + |.ffunc_bit_sh rol, or, 1 + |.ffunc_bit_sh ror, or, 2 + | + |.ffunc_bit tobit + |->fff_resi: + | mtc1 CRET1, FRET1 + | b ->fff_resn + |. cvt.d.w FRET1, FRET1 + | + |//----------------------------------------------------------------------- + | + |->fff_fallback: // Call fast function fallback handler. + | // BASE = new base, RB = CFUNC, RC = nargs*8 + | lw TMP3, CFUNC:RB->f + | addu TMP1, BASE, NARGS8:RC + | lw PC, FRAME_PC(BASE) // Fallback may overwrite PC. + | addiu TMP0, TMP1, 8*LUA_MINSTACK + | lw TMP2, L->maxstack + | sw PC, SAVE_PC // Redundant (but a defined value). + | sltu AT, TMP2, TMP0 + | sw BASE, L->base + | sw TMP1, L->top + | bnez AT, >5 // Need to grow stack. + |. move CFUNCADDR, TMP3 + | jalr TMP3 // (lua_State *L) + |. move CARG1, L + | // Either throws an error, or recovers and returns -1, 0 or nresults+1. + | lw BASE, L->base + | sll RD, CRET1, 3 + | bgtz CRET1, ->fff_res // Returned nresults+1? + |. addiu RA, BASE, -8 + |1: // Returned 0 or -1: retry fast path. + | lw TMP0, L->top + | lw LFUNC:RB, FRAME_FUNC(BASE) + | bnez CRET1, ->vm_call_tail // Returned -1? + |. subu NARGS8:RC, TMP0, BASE + | ins_callt // Returned 0: retry fast path. + | + |// Reconstruct previous base for vmeta_call during tailcall. + |->vm_call_tail: + | andi TMP0, PC, FRAME_TYPE + | li AT, -4 + | bnez TMP0, >3 + |. and TMP1, PC, AT + | lbu TMP1, OFS_RA(PC) + | sll TMP1, TMP1, 3 + | addiu TMP1, TMP1, 8 + |3: + | b ->vm_call_dispatch // Resolve again for tailcall. + |. subu TMP2, BASE, TMP1 + | + |5: // Grow stack for fallback handler. + | load_got lj_state_growstack + | li CARG2, LUA_MINSTACK + | call_intern lj_state_growstack // (lua_State *L, int n) + |. move CARG1, L + | lw BASE, L->base + | b <1 + |. li CRET1, 0 // Force retry. + | + |->fff_gcstep: // Call GC step function. + | // BASE = new base, RC = nargs*8 + | move MULTRES, ra + | load_got lj_gc_step + | sw BASE, L->base + | addu TMP0, BASE, NARGS8:RC + | sw PC, SAVE_PC // Redundant (but a defined value). + | sw TMP0, L->top + | call_intern lj_gc_step // (lua_State *L) + |. move CARG1, L + | lw BASE, L->base + | move ra, MULTRES + | lw TMP0, L->top + | lw CFUNC:RB, FRAME_FUNC(BASE) + | jr ra + |. subu NARGS8:RC, TMP0, BASE + | + |//----------------------------------------------------------------------- + |//-- Special dispatch targets ------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_record: // Dispatch target for recording phase. + |.if JIT + | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | andi AT, TMP3, HOOK_VMEVENT // No recording while in vmevent. + | bnez AT, >5 + | // Decrement the hookcount for consistency, but always do the call. + |. lw TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | andi AT, TMP3, HOOK_ACTIVE + | bnez AT, >1 + |. addiu TMP2, TMP2, -1 + | andi AT, TMP3, LUA_MASKLINE|LUA_MASKCOUNT + | beqz AT, >1 + |. nop + | b >1 + |. sw TMP2, DISPATCH_GL(hookcount)(DISPATCH) + |.endif + | + |->vm_rethook: // Dispatch target for return hooks. + | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | andi AT, TMP3, HOOK_ACTIVE // Hook already active? + | beqz AT, >1 + |5: // Re-dispatch to static ins. + |. lw AT, GG_DISP2STATIC(TMP0) // Assumes TMP0 holds DISPATCH+OP*4. + | jr AT + |. nop + | + |->vm_inshook: // Dispatch target for instr/line hooks. + | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | lw TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | andi AT, TMP3, HOOK_ACTIVE // Hook already active? + | bnez AT, <5 + |. andi AT, TMP3, LUA_MASKLINE|LUA_MASKCOUNT + | beqz AT, <5 + |. addiu TMP2, TMP2, -1 + | beqz TMP2, >1 + |. sw TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | andi AT, TMP3, LUA_MASKLINE + | beqz AT, <5 + |1: + |. load_got lj_dispatch_ins + | sw MULTRES, SAVE_MULTRES + | move CARG2, PC + | sw BASE, L->base + | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. + | call_intern lj_dispatch_ins // (lua_State *L, const BCIns *pc) + |. move CARG1, L + |3: + | lw BASE, L->base + |4: // Re-dispatch to static ins. + | lw INS, -4(PC) + | decode_OP4a TMP1, INS + | decode_OP4b TMP1 + | addu TMP0, DISPATCH, TMP1 + | decode_RD8a RD, INS + | lw AT, GG_DISP2STATIC(TMP0) + | decode_RA8a RA, INS + | decode_RD8b RD + | jr AT + | decode_RA8b RA + | + |->cont_hook: // Continue from hook yield. + | addiu PC, PC, 4 + | b <4 + |. lw MULTRES, -24+LO(RB) // Restore MULTRES for *M ins. + | + |->vm_hotloop: // Hot loop counter underflow. + |.if JIT + | lw LFUNC:TMP1, FRAME_FUNC(BASE) + | addiu CARG1, DISPATCH, GG_DISP2J + | sw PC, SAVE_PC + | lw TMP1, LFUNC:TMP1->pc + | move CARG2, PC + | sw L, DISPATCH_J(L)(DISPATCH) + | lbu TMP1, PC2PROTO(framesize)(TMP1) + | load_got lj_trace_hot + | sw BASE, L->base + | sll TMP1, TMP1, 3 + | addu TMP1, BASE, TMP1 + | call_intern lj_trace_hot // (jit_State *J, const BCIns *pc) + |. sw TMP1, L->top + | b <3 + |. nop + |.endif + | + |->vm_callhook: // Dispatch target for call hooks. + |.if JIT + | b >1 + |.endif + |. move CARG2, PC + | + |->vm_hotcall: // Hot call counter underflow. + |.if JIT + | ori CARG2, PC, 1 + |1: + |.endif + | load_got lj_dispatch_call + | addu TMP0, BASE, RC + | sw PC, SAVE_PC + | sw BASE, L->base + | subu RA, RA, BASE + | sw TMP0, L->top + | call_intern lj_dispatch_call // (lua_State *L, const BCIns *pc) + |. move CARG1, L + | // Returns ASMFunction. + | lw BASE, L->base + | lw TMP0, L->top + | sw r0, SAVE_PC // Invalidate for subsequent line hook. + | subu NARGS8:RC, TMP0, BASE + | addu RA, BASE, RA + | lw LFUNC:RB, FRAME_FUNC(BASE) + | jr CRET1 + |. lw INS, -4(PC) + | + |//----------------------------------------------------------------------- + |//-- Trace exit handler ------------------------------------------------- + |//----------------------------------------------------------------------- + | + |.macro savex_, a, b + | sdc1 f..a, 16+a*8(sp) + | sw r..a, 16+32*8+a*4(sp) + | sw r..b, 16+32*8+b*4(sp) + |.endmacro + | + |->vm_exit_handler: + |.if JIT + | addiu sp, sp, -(16+32*8+32*4) + | savex_ 0, 1 + | savex_ 2, 3 + | savex_ 4, 5 + | savex_ 6, 7 + | savex_ 8, 9 + | savex_ 10, 11 + | savex_ 12, 13 + | savex_ 14, 15 + | savex_ 16, 17 + | savex_ 18, 19 + | savex_ 20, 21 + | savex_ 22, 23 + | savex_ 24, 25 + | savex_ 26, 27 + | sdc1 f28, 16+28*8(sp) + | sw r28, 16+32*8+28*4(sp) + | sdc1 f30, 16+30*8(sp) + | sw r30, 16+32*8+30*4(sp) + | sw r0, 16+32*8+31*4(sp) // Clear RID_TMP. + | li_vmstate EXIT + | addiu TMP2, sp, 16+32*8+32*4 // Recompute original value of sp. + | addiu DISPATCH, JGL, -GG_DISP2G-32768 + | lw TMP1, 0(TMP2) // Load exit number. + | st_vmstate + | sw TMP2, 16+32*8+29*4(sp) // Store sp in RID_SP. + | lw L, DISPATCH_GL(jit_L)(DISPATCH) + | lw BASE, DISPATCH_GL(jit_base)(DISPATCH) + | load_got lj_trace_exit + | sw L, DISPATCH_J(L)(DISPATCH) + | sw ra, DISPATCH_J(parent)(DISPATCH) // Store trace number. + | sw TMP1, DISPATCH_J(exitno)(DISPATCH) // Store exit number. + | addiu CARG1, DISPATCH, GG_DISP2J + | sw BASE, L->base + | call_intern lj_trace_exit // (jit_State *J, ExitState *ex) + |. addiu CARG2, sp, 16 + | // Returns MULTRES (unscaled) or negated error code. + | lw TMP1, L->cframe + | li AT, -4 + | lw BASE, L->base + | and sp, TMP1, AT + | lw PC, SAVE_PC // Get SAVE_PC. + | b >1 + |. sw L, SAVE_L // Set SAVE_L (on-trace resume/yield). + |.endif + |->vm_exit_interp: + |.if JIT + | // CRET1 = MULTRES or negated error code, BASE, PC and JGL set. + | lw L, SAVE_L + | addiu DISPATCH, JGL, -GG_DISP2G-32768 + |1: + | bltz CRET1, >3 // Check for error from exit. + |. lw LFUNC:TMP1, FRAME_FUNC(BASE) + | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | sll MULTRES, CRET1, 3 + | li TISNIL, LJ_TNIL + | sw MULTRES, SAVE_MULTRES + | mtc1 TMP3, TOBIT + | lw TMP1, LFUNC:TMP1->pc + | sw r0, DISPATCH_GL(jit_L)(DISPATCH) + | lw KBASE, PC2PROTO(k)(TMP1) + | cvt.d.s TOBIT, TOBIT + | // Modified copy of ins_next which handles function header dispatch, too. + | lw INS, 0(PC) + | addiu PC, PC, 4 + | // Assumes TISNIL == ~LJ_VMST_INTERP == -1 + | sw TISNIL, DISPATCH_GL(vmstate)(DISPATCH) + | decode_OP4a TMP1, INS + | decode_OP4b TMP1 + | sltiu TMP2, TMP1, BC_FUNCF*4 // Function header? + | addu TMP0, DISPATCH, TMP1 + | decode_RD8a RD, INS + | lw AT, 0(TMP0) + | decode_RA8a RA, INS + | beqz TMP2, >2 + |. decode_RA8b RA + | jr AT + |. decode_RD8b RD + |2: + | addiu RC, MULTRES, -8 + | jr AT + |. addu RA, RA, BASE + | + |3: // Rethrow error from the right C frame. + | load_got lj_err_throw + | negu CARG2, CRET1 + | call_intern lj_err_throw // (lua_State *L, int errcode) + |. move CARG1, L + |.endif + | + |//----------------------------------------------------------------------- + |//-- Math helper functions ---------------------------------------------- + |//----------------------------------------------------------------------- + | + |// Modifies AT, TMP0, FRET1, FRET2, f4. Keeps all others incl. FARG1. + |.macro vm_round, func + | lui TMP0, 0x4330 // Hiword of 2^52 (double). + | mtc1 r0, f4 + | mtc1 TMP0, f5 + | abs.d FRET2, FARG1 // |x| + | mfc1 AT, f13 + | c.olt.d 0, FRET2, f4 + | add.d FRET1, FRET2, f4 // (|x| + 2^52) - 2^52 + | bc1f 0, >1 // Truncate only if |x| < 2^52. + |. sub.d FRET1, FRET1, f4 + | slt AT, AT, r0 + |.if "func" == "ceil" + | lui TMP0, 0xbff0 // Hiword of -1 (double). Preserves -0. + |.else + | lui TMP0, 0x3ff0 // Hiword of +1 (double). + |.endif + |.if "func" == "trunc" + | mtc1 TMP0, f5 + | c.olt.d 0, FRET2, FRET1 // |x| < result? + | sub.d FRET2, FRET1, f4 + | movt.d FRET1, FRET2, 0 // If yes, subtract +1. + | neg.d FRET2, FRET1 + | jr ra + |. movn.d FRET1, FRET2, AT // Merge sign bit back in. + |.else + | neg.d FRET2, FRET1 + | mtc1 TMP0, f5 + | movn.d FRET1, FRET2, AT // Merge sign bit back in. + |.if "func" == "ceil" + | c.olt.d 0, FRET1, FARG1 // x > result? + |.else + | c.olt.d 0, FARG1, FRET1 // x < result? + |.endif + | sub.d FRET2, FRET1, f4 // If yes, subtract +-1. + | jr ra + |. movt.d FRET1, FRET2, 0 + |.endif + |1: + | jr ra + |. mov.d FRET1, FARG1 + |.endmacro + | + |->vm_floor: + | vm_round floor + |->vm_ceil: + | vm_round ceil + |->vm_trunc: + |.if JIT + | vm_round trunc + |.endif + | + |//----------------------------------------------------------------------- + |//-- Miscellaneous functions -------------------------------------------- + |//----------------------------------------------------------------------- + | + |//----------------------------------------------------------------------- + |//-- FFI helper functions ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |// Handler for callback functions. Callback slot number in r1, g in r2. + |->vm_ffi_callback: + |.if FFI + |.type CTSTATE, CTState, PC + | saveregs + | lw CTSTATE, GL:r2->ctype_state + | addiu DISPATCH, r2, GG_G2DISP + | load_got lj_ccallback_enter + | sw r1, CTSTATE->cb.slot + | sw CARG1, CTSTATE->cb.gpr[0] + | sw CARG2, CTSTATE->cb.gpr[1] + | sdc1 FARG1, CTSTATE->cb.fpr[0] + | sw CARG3, CTSTATE->cb.gpr[2] + | sw CARG4, CTSTATE->cb.gpr[3] + | sdc1 FARG2, CTSTATE->cb.fpr[1] + | addiu TMP0, sp, CFRAME_SPACE+16 + | sw TMP0, CTSTATE->cb.stack + | sw r0, SAVE_PC // Any value outside of bytecode is ok. + | move CARG2, sp + | call_intern lj_ccallback_enter // (CTState *cts, void *cf) + |. move CARG1, CTSTATE + | // Returns lua_State *. + | lw BASE, L:CRET1->base + | lw RC, L:CRET1->top + | move L, CRET1 + | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | lw LFUNC:RB, FRAME_FUNC(BASE) + | mtc1 TMP3, TOBIT + | li_vmstate INTERP + | li TISNIL, LJ_TNIL + | subu RC, RC, BASE + | st_vmstate + | cvt.d.s TOBIT, TOBIT + | ins_callt + |.endif + | + |->cont_ffi_callback: // Return from FFI callback. + |.if FFI + | load_got lj_ccallback_leave + | lw CTSTATE, DISPATCH_GL(ctype_state)(DISPATCH) + | sw BASE, L->base + | sw RB, L->top + | sw L, CTSTATE->L + | move CARG2, RA + | call_intern lj_ccallback_leave // (CTState *cts, TValue *o) + |. move CARG1, CTSTATE + | lw CRET1, CTSTATE->cb.gpr[0] + | ldc1 FRET1, CTSTATE->cb.fpr[0] + | lw CRET2, CTSTATE->cb.gpr[1] + | b ->vm_leave_unw + |. ldc1 FRET2, CTSTATE->cb.fpr[1] + |.endif + | + |->vm_ffi_call: // Call C function via FFI. + | // Caveat: needs special frame unwinding, see below. + |.if FFI + | .type CCSTATE, CCallState, CARG1 + | lw TMP1, CCSTATE->spadj + | lbu CARG2, CCSTATE->nsp + | move TMP2, sp + | subu sp, sp, TMP1 + | sw ra, -4(TMP2) + | sll CARG2, CARG2, 2 + | sw r16, -8(TMP2) + | sw CCSTATE, -12(TMP2) + | move r16, TMP2 + | addiu TMP1, CCSTATE, offsetof(CCallState, stack) + | addiu TMP2, sp, 16 + | beqz CARG2, >2 + |. addu TMP3, TMP1, CARG2 + |1: + | lw TMP0, 0(TMP1) + | addiu TMP1, TMP1, 4 + | sltu AT, TMP1, TMP3 + | sw TMP0, 0(TMP2) + | bnez AT, <1 + |. addiu TMP2, TMP2, 4 + |2: + | lw CFUNCADDR, CCSTATE->func + | lw CARG2, CCSTATE->gpr[1] + | lw CARG3, CCSTATE->gpr[2] + | lw CARG4, CCSTATE->gpr[3] + | ldc1 FARG1, CCSTATE->fpr[0] + | ldc1 FARG2, CCSTATE->fpr[1] + | jalr CFUNCADDR + |. lw CARG1, CCSTATE->gpr[0] // Do this last, since CCSTATE is CARG1. + | lw CCSTATE:TMP1, -12(r16) + | lw TMP2, -8(r16) + | lw ra, -4(r16) + | sw CRET1, CCSTATE:TMP1->gpr[0] + | sw CRET2, CCSTATE:TMP1->gpr[1] + | sdc1 FRET1, CCSTATE:TMP1->fpr[0] + | sdc1 FRET2, CCSTATE:TMP1->fpr[1] + | move sp, r16 + | jr ra + |. move r16, TMP2 + |.endif + |// Note: vm_ffi_call must be the last function in this object file! + | + |//----------------------------------------------------------------------- +} + +/* Generate the code for a single instruction. */ +static void build_ins(BuildCtx *ctx, BCOp op, int defop) +{ + int vk = 0; + |=>defop: + + switch (op) { + + /* -- Comparison ops ---------------------------------------------------- */ + + /* Remember: all ops branch for a true comparison, fall through otherwise. */ + + case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: + | // RA = src1*8, RD = src2*8, JMP with RD = target + | addu CARG2, BASE, RA + | addu CARG3, BASE, RD + | lw TMP0, HI(CARG2) + | lw TMP1, HI(CARG3) + | ldc1 f0, 0(CARG2) + | ldc1 f2, 0(CARG3) + | sltiu TMP0, TMP0, LJ_TISNUM + | sltiu TMP1, TMP1, LJ_TISNUM + | lhu TMP2, OFS_RD(PC) + | and TMP0, TMP0, TMP1 + | addiu PC, PC, 4 + | beqz TMP0, ->vmeta_comp + |. lui TMP1, (-(BCBIAS_J*4 >> 16) & 65535) + | decode_RD4b TMP2 + | addu TMP2, TMP2, TMP1 + if (op == BC_ISLT || op == BC_ISGE) { + | c.olt.d f0, f2 + } else { + | c.ole.d f0, f2 + } + if (op == BC_ISLT || op == BC_ISLE) { + | movf TMP2, r0 + } else { + | movt TMP2, r0 + } + | addu PC, PC, TMP2 + |1: + | ins_next + break; + + case BC_ISEQV: case BC_ISNEV: + vk = op == BC_ISEQV; + | // RA = src1*8, RD = src2*8, JMP with RD = target + | addu RA, BASE, RA + | addiu PC, PC, 4 + | lw TMP0, HI(RA) + | ldc1 f0, 0(RA) + | addu RD, BASE, RD + | lhu TMP2, -4+OFS_RD(PC) + | lw TMP1, HI(RD) + | ldc1 f2, 0(RD) + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | sltiu AT, TMP0, LJ_TISNUM + | sltiu CARG1, TMP1, LJ_TISNUM + | decode_RD4b TMP2 + | and AT, AT, CARG1 + | beqz AT, >5 + |. addu TMP2, TMP2, TMP3 + | c.eq.d f0, f2 + if (vk) { + | movf TMP2, r0 + } else { + | movt TMP2, r0 + } + |1: + | addu PC, PC, TMP2 + | ins_next + |5: // Either or both types are not numbers. + | lw CARG2, LO(RA) + | lw CARG3, LO(RD) + |.if FFI + | li TMP3, LJ_TCDATA + | beq TMP0, TMP3, ->vmeta_equal_cd + |.endif + |. sltiu AT, TMP0, LJ_TISPRI // Not a primitive? + |.if FFI + | beq TMP1, TMP3, ->vmeta_equal_cd + |.endif + |. xor TMP3, CARG2, CARG3 // Same tv? + | xor TMP1, TMP1, TMP0 // Same type? + | sltiu CARG1, TMP0, LJ_TISTABUD+1 // Table or userdata? + | movz TMP3, r0, AT // Ignore tv if primitive. + | movn CARG1, r0, TMP1 // Tab/ud and same type? + | or AT, TMP1, TMP3 // Same type && (pri||same tv). + | movz CARG1, r0, AT + | beqz CARG1, <1 // Done if not tab/ud or not same type or same tv. + if (vk) { + |. movn TMP2, r0, AT + } else { + |. movz TMP2, r0, AT + } + | // Different tables or userdatas. Need to check __eq metamethod. + | // Field metatable must be at same offset for GCtab and GCudata! + | lw TAB:TMP1, TAB:CARG2->metatable + | beqz TAB:TMP1, <1 // No metatable? + |. nop + | lbu TMP1, TAB:TMP1->nomm + | andi TMP1, TMP1, 1<vmeta_equal // Handle __eq metamethod. + |. li CARG4, 1-vk // ne = 0 or 1. + break; + + case BC_ISEQS: case BC_ISNES: + vk = op == BC_ISEQS; + | // RA = src*8, RD = str_const*8 (~), JMP with RD = target + | addu RA, BASE, RA + | addiu PC, PC, 4 + | lw TMP0, HI(RA) + | srl RD, RD, 1 + | lw STR:TMP3, LO(RA) + | subu RD, KBASE, RD + | lhu TMP2, -4+OFS_RD(PC) + |.if FFI + | li AT, LJ_TCDATA + | beq TMP0, AT, ->vmeta_equal_cd + |.endif + |. lw STR:TMP1, -4(RD) // KBASE-4-str_const*4 + | addiu TMP0, TMP0, -LJ_TSTR + | decode_RD4b TMP2 + | xor TMP1, STR:TMP1, STR:TMP3 + | or TMP0, TMP0, TMP1 + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | addu TMP2, TMP2, TMP3 + if (vk) { + | movn TMP2, r0, TMP0 + } else { + | movz TMP2, r0, TMP0 + } + | addu PC, PC, TMP2 + | ins_next + break; + + case BC_ISEQN: case BC_ISNEN: + vk = op == BC_ISEQN; + | // RA = src*8, RD = num_const*8, JMP with RD = target + | addu RA, BASE, RA + | addiu PC, PC, 4 + | lw TMP0, HI(RA) + | ldc1 f0, 0(RA) + | addu RD, KBASE, RD + | lhu TMP2, -4+OFS_RD(PC) + | ldc1 f2, 0(RD) + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | sltiu AT, TMP0, LJ_TISNUM + | decode_RD4b TMP2 + |.if FFI + | beqz AT, >5 + |.else + | beqz AT, >1 + |.endif + |. addu TMP2, TMP2, TMP3 + | c.eq.d f0, f2 + if (vk) { + | movf TMP2, r0 + | addu PC, PC, TMP2 + |1: + } else { + | movt TMP2, r0 + |1: + | addu PC, PC, TMP2 + } + | ins_next + |.if FFI + |5: + | li AT, LJ_TCDATA + | beq TMP0, AT, ->vmeta_equal_cd + |. nop + | b <1 + |. nop + |.endif + break; + + case BC_ISEQP: case BC_ISNEP: + vk = op == BC_ISEQP; + | // RA = src*8, RD = primitive_type*8 (~), JMP with RD = target + | addu RA, BASE, RA + | srl TMP1, RD, 3 + | lw TMP0, HI(RA) + | lhu TMP2, OFS_RD(PC) + | not TMP1, TMP1 + | addiu PC, PC, 4 + |.if FFI + | li AT, LJ_TCDATA + | beq TMP0, AT, ->vmeta_equal_cd + |.endif + |. xor TMP0, TMP0, TMP1 + | decode_RD4b TMP2 + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | addu TMP2, TMP2, TMP3 + if (vk) { + | movn TMP2, r0, TMP0 + } else { + | movz TMP2, r0, TMP0 + } + | addu PC, PC, TMP2 + | ins_next + break; + + /* -- Unary test and copy ops ------------------------------------------- */ + + case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: + | // RA = dst*8 or unused, RD = src*8, JMP with RD = target + | addu RD, BASE, RD + | lhu TMP2, OFS_RD(PC) + | lw TMP0, HI(RD) + | addiu PC, PC, 4 + if (op == BC_IST || op == BC_ISF) { + | sltiu TMP0, TMP0, LJ_TISTRUECOND + | decode_RD4b TMP2 + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | addu TMP2, TMP2, TMP3 + if (op == BC_IST) { + | movz TMP2, r0, TMP0 + } else { + | movn TMP2, r0, TMP0 + } + | addu PC, PC, TMP2 + } else { + | sltiu TMP0, TMP0, LJ_TISTRUECOND + | ldc1 f0, 0(RD) + if (op == BC_ISTC) { + | beqz TMP0, >1 + } else { + | bnez TMP0, >1 + } + |. addu RA, BASE, RA + | decode_RD4b TMP2 + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | addu TMP2, TMP2, TMP3 + | sdc1 f0, 0(RA) + | addu PC, PC, TMP2 + |1: + } + | ins_next + break; + + /* -- Unary ops --------------------------------------------------------- */ + + case BC_MOV: + | // RA = dst*8, RD = src*8 + | addu RD, BASE, RD + | addu RA, BASE, RA + | ldc1 f0, 0(RD) + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + break; + case BC_NOT: + | // RA = dst*8, RD = src*8 + | addu RD, BASE, RD + | addu RA, BASE, RA + | lw TMP0, HI(RD) + | li TMP1, LJ_TFALSE + | sltiu TMP0, TMP0, LJ_TISTRUECOND + | addiu TMP1, TMP0, LJ_TTRUE + | ins_next1 + | sw TMP1, HI(RA) + | ins_next2 + break; + case BC_UNM: + | // RA = dst*8, RD = src*8 + | addu CARG3, BASE, RD + | addu RA, BASE, RA + | lw TMP0, HI(CARG3) + | ldc1 f0, 0(CARG3) + | sltiu AT, TMP0, LJ_TISNUM + | beqz AT, ->vmeta_unm + |. neg.d f0, f0 + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + break; + case BC_LEN: + | // RA = dst*8, RD = src*8 + | addu CARG2, BASE, RD + | addu RA, BASE, RA + | lw TMP0, HI(CARG2) + | lw CARG1, LO(CARG2) + | li AT, LJ_TSTR + | bne TMP0, AT, >2 + |. li AT, LJ_TTAB + | lw CRET1, STR:CARG1->len + |1: + | mtc1 CRET1, f0 + | cvt.d.w f0, f0 + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + |2: + | bne TMP0, AT, ->vmeta_len + |. nop +#if LJ_52 + | lw TAB:TMP2, TAB:CARG1->metatable + | bnez TAB:TMP2, >9 + |. nop + |3: +#endif + |->BC_LEN_Z: + | load_got lj_tab_len + | call_intern lj_tab_len // (GCtab *t) + |. nop + | // Returns uint32_t (but less than 2^31). + | b <1 + |. nop +#if LJ_52 + |9: + | lbu TMP0, TAB:TMP2->nomm + | andi TMP0, TMP0, 1<vmeta_len + |. nop +#endif + break; + + /* -- Binary ops -------------------------------------------------------- */ + + |.macro ins_arithpre + ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); + | decode_RB8a RB, INS + | decode_RB8b RB + | decode_RDtoRC8 RC, RD + | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 + ||switch (vk) { + ||case 0: + | addu CARG3, BASE, RB + | addu CARG4, KBASE, RC + | lw TMP1, HI(CARG3) + | ldc1 f20, 0(CARG3) + | ldc1 f22, 0(CARG4) + | sltiu AT, TMP1, LJ_TISNUM + || break; + ||case 1: + | addu CARG4, BASE, RB + | addu CARG3, KBASE, RC + | lw TMP1, HI(CARG4) + | ldc1 f22, 0(CARG4) + | ldc1 f20, 0(CARG3) + | sltiu AT, TMP1, LJ_TISNUM + || break; + ||default: + | addu CARG3, BASE, RB + | addu CARG4, BASE, RC + | lw TMP1, HI(CARG3) + | lw TMP2, HI(CARG4) + | ldc1 f20, 0(CARG3) + | ldc1 f22, 0(CARG4) + | sltiu AT, TMP1, LJ_TISNUM + | sltiu TMP0, TMP2, LJ_TISNUM + | and AT, AT, TMP0 + || break; + ||} + | beqz AT, ->vmeta_arith + |. addu RA, BASE, RA + |.endmacro + | + |.macro fpmod, a, b, c + |->BC_MODVN_Z: + | bal ->vm_floor // floor(b/c) + |. div.d FARG1, b, c + | mul.d a, FRET1, c + | sub.d a, b, a // b - floor(b/c)*c + |.endmacro + | + |.macro ins_arith, ins + | ins_arithpre + |.if "ins" == "fpmod_" + | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. + |. nop + |.else + | ins f0, f20, f22 + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + |.endif + |.endmacro + + case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: + | ins_arith add.d + break; + case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: + | ins_arith sub.d + break; + case BC_MULVN: case BC_MULNV: case BC_MULVV: + | ins_arith mul.d + break; + case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: + | ins_arith div.d + break; + case BC_MODVN: + | ins_arith fpmod + break; + case BC_MODNV: case BC_MODVV: + | ins_arith fpmod_ + break; + case BC_POW: + | decode_RB8a RB, INS + | decode_RB8b RB + | decode_RDtoRC8 RC, RD + | addu CARG3, BASE, RB + | addu CARG4, BASE, RC + | lw TMP1, HI(CARG3) + | lw TMP2, HI(CARG4) + | ldc1 FARG1, 0(CARG3) + | ldc1 FARG2, 0(CARG4) + | sltiu AT, TMP1, LJ_TISNUM + | sltiu TMP0, TMP2, LJ_TISNUM + | and AT, AT, TMP0 + | load_got pow + | beqz AT, ->vmeta_arith + |. addu RA, BASE, RA + | call_extern + |. nop + | ins_next1 + | sdc1 FRET1, 0(RA) + | ins_next2 + break; + + case BC_CAT: + | // RA = dst*8, RB = src_start*8, RC = src_end*8 + | decode_RB8a RB, INS + | decode_RB8b RB + | decode_RDtoRC8 RC, RD + | subu CARG3, RC, RB + | sw BASE, L->base + | addu CARG2, BASE, RC + | move MULTRES, RB + |->BC_CAT_Z: + | load_got lj_meta_cat + | srl CARG3, CARG3, 3 + | sw PC, SAVE_PC + | call_intern lj_meta_cat // (lua_State *L, TValue *top, int left) + |. move CARG1, L + | // Returns NULL (finished) or TValue * (metamethod). + | bnez CRET1, ->vmeta_binop + |. lw BASE, L->base + | addu RB, BASE, MULTRES + | ldc1 f0, 0(RB) + | addu RA, BASE, RA + | ins_next1 + | sdc1 f0, 0(RA) // Copy result from RB to RA. + | ins_next2 + break; + + /* -- Constant ops ------------------------------------------------------ */ + + case BC_KSTR: + | // RA = dst*8, RD = str_const*8 (~) + | srl TMP1, RD, 1 + | subu TMP1, KBASE, TMP1 + | ins_next1 + | lw TMP0, -4(TMP1) // KBASE-4-str_const*4 + | addu RA, BASE, RA + | li TMP2, LJ_TSTR + | sw TMP0, LO(RA) + | sw TMP2, HI(RA) + | ins_next2 + break; + case BC_KCDATA: + |.if FFI + | // RA = dst*8, RD = cdata_const*8 (~) + | srl TMP1, RD, 1 + | subu TMP1, KBASE, TMP1 + | ins_next1 + | lw TMP0, -4(TMP1) // KBASE-4-cdata_const*4 + | addu RA, BASE, RA + | li TMP2, LJ_TCDATA + | sw TMP0, LO(RA) + | sw TMP2, HI(RA) + | ins_next2 + |.endif + break; + case BC_KSHORT: + | // RA = dst*8, RD = int16_literal*8 + | sra RD, INS, 16 + | mtc1 RD, f0 + | addu RA, BASE, RA + | cvt.d.w f0, f0 + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + break; + case BC_KNUM: + | // RA = dst*8, RD = num_const*8 + | addu RD, KBASE, RD + | addu RA, BASE, RA + | ldc1 f0, 0(RD) + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + break; + case BC_KPRI: + | // RA = dst*8, RD = primitive_type*8 (~) + | srl TMP1, RD, 3 + | addu RA, BASE, RA + | not TMP0, TMP1 + | ins_next1 + | sw TMP0, HI(RA) + | ins_next2 + break; + case BC_KNIL: + | // RA = base*8, RD = end*8 + | addu RA, BASE, RA + | sw TISNIL, HI(RA) + | addiu RA, RA, 8 + | addu RD, BASE, RD + |1: + | sw TISNIL, HI(RA) + | slt AT, RA, RD + | bnez AT, <1 + |. addiu RA, RA, 8 + | ins_next_ + break; + + /* -- Upvalue and function ops ------------------------------------------ */ + + case BC_UGET: + | // RA = dst*8, RD = uvnum*8 + | lw LFUNC:RB, FRAME_FUNC(BASE) + | srl RD, RD, 1 + | addu RD, RD, LFUNC:RB + | lw UPVAL:RB, LFUNC:RD->uvptr + | ins_next1 + | lw TMP1, UPVAL:RB->v + | ldc1 f0, 0(TMP1) + | addu RA, BASE, RA + | sdc1 f0, 0(RA) + | ins_next2 + break; + case BC_USETV: + | // RA = uvnum*8, RD = src*8 + | lw LFUNC:RB, FRAME_FUNC(BASE) + | srl RA, RA, 1 + | addu RD, BASE, RD + | addu RA, RA, LFUNC:RB + | ldc1 f0, 0(RD) + | lw UPVAL:RB, LFUNC:RA->uvptr + | lbu TMP3, UPVAL:RB->marked + | lw CARG2, UPVAL:RB->v + | andi TMP3, TMP3, LJ_GC_BLACK // isblack(uv) + | lbu TMP0, UPVAL:RB->closed + | lw TMP2, HI(RD) + | sdc1 f0, 0(CARG2) + | li AT, LJ_GC_BLACK|1 + | or TMP3, TMP3, TMP0 + | beq TMP3, AT, >2 // Upvalue is closed and black? + |. addiu TMP2, TMP2, -(LJ_TNUMX+1) + |1: + | ins_next + | + |2: // Check if new value is collectable. + | sltiu AT, TMP2, LJ_TISGCV - (LJ_TNUMX+1) + | beqz AT, <1 // tvisgcv(v) + |. lw TMP1, LO(RD) + | lbu TMP3, GCOBJ:TMP1->gch.marked + | andi TMP3, TMP3, LJ_GC_WHITES // iswhite(v) + | beqz TMP3, <1 + |. load_got lj_gc_barrieruv + | // Crossed a write barrier. Move the barrier forward. + | call_intern lj_gc_barrieruv // (global_State *g, TValue *tv) + |. addiu CARG1, DISPATCH, GG_DISP2G + | b <1 + |. nop + break; + case BC_USETS: + | // RA = uvnum*8, RD = str_const*8 (~) + | lw LFUNC:RB, FRAME_FUNC(BASE) + | srl RA, RA, 1 + | srl TMP1, RD, 1 + | addu RA, RA, LFUNC:RB + | subu TMP1, KBASE, TMP1 + | lw UPVAL:RB, LFUNC:RA->uvptr + | lw STR:TMP1, -4(TMP1) // KBASE-4-str_const*4 + | lbu TMP2, UPVAL:RB->marked + | lw CARG2, UPVAL:RB->v + | lbu TMP3, STR:TMP1->marked + | andi AT, TMP2, LJ_GC_BLACK // isblack(uv) + | lbu TMP2, UPVAL:RB->closed + | li TMP0, LJ_TSTR + | sw STR:TMP1, LO(CARG2) + | bnez AT, >2 + |. sw TMP0, HI(CARG2) + |1: + | ins_next + | + |2: // Check if string is white and ensure upvalue is closed. + | beqz TMP2, <1 + |. andi AT, TMP3, LJ_GC_WHITES // iswhite(str) + | beqz AT, <1 + |. load_got lj_gc_barrieruv + | // Crossed a write barrier. Move the barrier forward. + | call_intern lj_gc_barrieruv // (global_State *g, TValue *tv) + |. addiu CARG1, DISPATCH, GG_DISP2G + | b <1 + |. nop + break; + case BC_USETN: + | // RA = uvnum*8, RD = num_const*8 + | lw LFUNC:RB, FRAME_FUNC(BASE) + | srl RA, RA, 1 + | addu RD, KBASE, RD + | addu RA, RA, LFUNC:RB + | ldc1 f0, 0(RD) + | lw UPVAL:RB, LFUNC:RA->uvptr + | ins_next1 + | lw TMP1, UPVAL:RB->v + | sdc1 f0, 0(TMP1) + | ins_next2 + break; + case BC_USETP: + | // RA = uvnum*8, RD = primitive_type*8 (~) + | lw LFUNC:RB, FRAME_FUNC(BASE) + | srl RA, RA, 1 + | srl TMP0, RD, 3 + | addu RA, RA, LFUNC:RB + | not TMP0, TMP0 + | lw UPVAL:RB, LFUNC:RA->uvptr + | ins_next1 + | lw TMP1, UPVAL:RB->v + | sw TMP0, HI(TMP1) + | ins_next2 + break; + + case BC_UCLO: + | // RA = level*8, RD = target + | lw TMP2, L->openupval + | branch_RD // Do this first since RD is not saved. + | load_got lj_func_closeuv + | sw BASE, L->base + | beqz TMP2, >1 + |. move CARG1, L + | call_intern lj_func_closeuv // (lua_State *L, TValue *level) + |. addu CARG2, BASE, RA + | lw BASE, L->base + |1: + | ins_next + break; + + case BC_FNEW: + | // RA = dst*8, RD = proto_const*8 (~) (holding function prototype) + | srl TMP1, RD, 1 + | load_got lj_func_newL_gc + | subu TMP1, KBASE, TMP1 + | lw CARG3, FRAME_FUNC(BASE) + | lw CARG2, -4(TMP1) // KBASE-4-tab_const*4 + | sw BASE, L->base + | sw PC, SAVE_PC + | // (lua_State *L, GCproto *pt, GCfuncL *parent) + | call_intern lj_func_newL_gc + |. move CARG1, L + | // Returns GCfuncL *. + | lw BASE, L->base + | li TMP0, LJ_TFUNC + | ins_next1 + | addu RA, BASE, RA + | sw TMP0, HI(RA) + | sw LFUNC:CRET1, LO(RA) + | ins_next2 + break; + + /* -- Table ops --------------------------------------------------------- */ + + case BC_TNEW: + case BC_TDUP: + | // RA = dst*8, RD = (hbits|asize)*8 | tab_const*8 (~) + | lw TMP0, DISPATCH_GL(gc.total)(DISPATCH) + | lw TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) + | sw BASE, L->base + | sw PC, SAVE_PC + | sltu AT, TMP0, TMP1 + | beqz AT, >5 + |1: + if (op == BC_TNEW) { + | load_got lj_tab_new + | srl CARG2, RD, 3 + | andi CARG2, CARG2, 0x7ff + | li TMP0, 0x801 + | addiu AT, CARG2, -0x7ff + | srl CARG3, RD, 14 + | movz CARG2, TMP0, AT + | // (lua_State *L, int32_t asize, uint32_t hbits) + | call_intern lj_tab_new + |. move CARG1, L + | // Returns Table *. + } else { + | load_got lj_tab_dup + | srl TMP1, RD, 1 + | subu TMP1, KBASE, TMP1 + | move CARG1, L + | call_intern lj_tab_dup // (lua_State *L, Table *kt) + |. lw CARG2, -4(TMP1) // KBASE-4-str_const*4 + | // Returns Table *. + } + | lw BASE, L->base + | ins_next1 + | addu RA, BASE, RA + | li TMP0, LJ_TTAB + | sw TAB:CRET1, LO(RA) + | sw TMP0, HI(RA) + | ins_next2 + |5: + | load_got lj_gc_step_fixtop + | move MULTRES, RD + | call_intern lj_gc_step_fixtop // (lua_State *L) + |. move CARG1, L + | b <1 + |. move RD, MULTRES + break; + + case BC_GGET: + | // RA = dst*8, RD = str_const*8 (~) + case BC_GSET: + | // RA = src*8, RD = str_const*8 (~) + | lw LFUNC:TMP2, FRAME_FUNC(BASE) + | srl TMP1, RD, 1 + | subu TMP1, KBASE, TMP1 + | lw TAB:RB, LFUNC:TMP2->env + | lw STR:RC, -4(TMP1) // KBASE-4-str_const*4 + if (op == BC_GGET) { + | b ->BC_TGETS_Z + } else { + | b ->BC_TSETS_Z + } + |. addu RA, BASE, RA + break; + + case BC_TGETV: + | // RA = dst*8, RB = table*8, RC = key*8 + | decode_RB8a RB, INS + | decode_RB8b RB + | decode_RDtoRC8 RC, RD + | addu CARG2, BASE, RB + | addu CARG3, BASE, RC + | lw TMP1, HI(CARG2) + | lw TMP2, HI(CARG3) + | lw TAB:RB, LO(CARG2) + | li AT, LJ_TTAB + | ldc1 f0, 0(CARG3) + | bne TMP1, AT, ->vmeta_tgetv + |. addu RA, BASE, RA + | sltiu AT, TMP2, LJ_TISNUM + | beqz AT, >5 + |. li AT, LJ_TSTR + | + | // Convert number key to integer, check for integerness and range. + | cvt.w.d f2, f0 + | lw TMP0, TAB:RB->asize + | mfc1 TMP2, f2 + | cvt.d.w f4, f2 + | lw TMP1, TAB:RB->array + | c.eq.d f0, f4 + | sltu AT, TMP2, TMP0 + | movf AT, r0 + | sll TMP2, TMP2, 3 + | beqz AT, ->vmeta_tgetv // Integer key and in array part? + |. addu TMP2, TMP1, TMP2 + | lw TMP0, HI(TMP2) + | beq TMP0, TISNIL, >2 + |. ldc1 f0, 0(TMP2) + |1: + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + | + |2: // Check for __index if table value is nil. + | lw TAB:TMP2, TAB:RB->metatable + | beqz TAB:TMP2, <1 // No metatable: done. + |. nop + | lbu TMP0, TAB:TMP2->nomm + | andi TMP0, TMP0, 1<vmeta_tgetv + |. nop + | + |5: + | bne TMP2, AT, ->vmeta_tgetv + |. lw STR:RC, LO(CARG3) + | b ->BC_TGETS_Z // String key? + |. nop + break; + case BC_TGETS: + | // RA = dst*8, RB = table*8, RC = str_const*4 (~) + | decode_RB8a RB, INS + | decode_RB8b RB + | addu CARG2, BASE, RB + | decode_RC4a RC, INS + | lw TMP0, HI(CARG2) + | decode_RC4b RC + | li AT, LJ_TTAB + | lw TAB:RB, LO(CARG2) + | subu CARG3, KBASE, RC + | lw STR:RC, -4(CARG3) // KBASE-4-str_const*4 + | bne TMP0, AT, ->vmeta_tgets1 + |. addu RA, BASE, RA + |->BC_TGETS_Z: + | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = dst*8 + | lw TMP0, TAB:RB->hmask + | lw TMP1, STR:RC->hash + | lw NODE:TMP2, TAB:RB->node + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | sll TMP0, TMP1, 5 + | sll TMP1, TMP1, 3 + | subu TMP1, TMP0, TMP1 + | addu NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + |1: + | lw CARG1, offsetof(Node, key)+HI(NODE:TMP2) + | lw TMP0, offsetof(Node, key)+LO(NODE:TMP2) + | lw NODE:TMP1, NODE:TMP2->next + | lw CARG2, offsetof(Node, val)+HI(NODE:TMP2) + | addiu CARG1, CARG1, -LJ_TSTR + | xor TMP0, TMP0, STR:RC + | or AT, CARG1, TMP0 + | bnez AT, >4 + |. lw TAB:TMP3, TAB:RB->metatable + | beq CARG2, TISNIL, >5 // Key found, but nil value? + |. lw CARG1, offsetof(Node, val)+LO(NODE:TMP2) + |3: + | ins_next1 + | sw CARG2, HI(RA) + | sw CARG1, LO(RA) + | ins_next2 + | + |4: // Follow hash chain. + | bnez NODE:TMP1, <1 + |. move NODE:TMP2, NODE:TMP1 + | // End of hash chain: key not found, nil result. + | + |5: // Check for __index if table value is nil. + | beqz TAB:TMP3, <3 // No metatable: done. + |. li CARG2, LJ_TNIL + | lbu TMP0, TAB:TMP3->nomm + | andi TMP0, TMP0, 1<vmeta_tgets + |. nop + break; + case BC_TGETB: + | // RA = dst*8, RB = table*8, RC = index*8 + | decode_RB8a RB, INS + | decode_RB8b RB + | addu CARG2, BASE, RB + | decode_RDtoRC8 RC, RD + | lw CARG1, HI(CARG2) + | li AT, LJ_TTAB + | lw TAB:RB, LO(CARG2) + | addu RA, BASE, RA + | bne CARG1, AT, ->vmeta_tgetb + |. srl TMP0, RC, 3 + | lw TMP1, TAB:RB->asize + | lw TMP2, TAB:RB->array + | sltu AT, TMP0, TMP1 + | beqz AT, ->vmeta_tgetb + |. addu RC, TMP2, RC + | lw TMP1, HI(RC) + | beq TMP1, TISNIL, >5 + |. ldc1 f0, 0(RC) + |1: + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + | + |5: // Check for __index if table value is nil. + | lw TAB:TMP2, TAB:RB->metatable + | beqz TAB:TMP2, <1 // No metatable: done. + |. nop + | lbu TMP1, TAB:TMP2->nomm + | andi TMP1, TMP1, 1<vmeta_tgetb // Caveat: preserve TMP0! + |. nop + break; + + case BC_TSETV: + | // RA = src*8, RB = table*8, RC = key*8 + | decode_RB8a RB, INS + | decode_RB8b RB + | decode_RDtoRC8 RC, RD + | addu CARG2, BASE, RB + | addu CARG3, BASE, RC + | lw TMP1, HI(CARG2) + | lw TMP2, HI(CARG3) + | lw TAB:RB, LO(CARG2) + | li AT, LJ_TTAB + | ldc1 f0, 0(CARG3) + | bne TMP1, AT, ->vmeta_tsetv + |. addu RA, BASE, RA + | sltiu AT, TMP2, LJ_TISNUM + | beqz AT, >5 + |. li AT, LJ_TSTR + | + | // Convert number key to integer, check for integerness and range. + | cvt.w.d f2, f0 + | lw TMP0, TAB:RB->asize + | mfc1 TMP2, f2 + | cvt.d.w f4, f2 + | lw TMP1, TAB:RB->array + | c.eq.d f0, f4 + | sltu AT, TMP2, TMP0 + | movf AT, r0 + | sll TMP2, TMP2, 3 + | beqz AT, ->vmeta_tsetv // Integer key and in array part? + |. addu TMP1, TMP1, TMP2 + | lbu TMP3, TAB:RB->marked + | lw TMP0, HI(TMP1) + | beq TMP0, TISNIL, >3 + |. ldc1 f0, 0(RA) + |1: + | andi AT, TMP3, LJ_GC_BLACK // isblack(table) + | bnez AT, >7 + |. sdc1 f0, 0(TMP1) + |2: + | ins_next + | + |3: // Check for __newindex if previous value is nil. + | lw TAB:TMP2, TAB:RB->metatable + | beqz TAB:TMP2, <1 // No metatable: done. + |. nop + | lbu TMP2, TAB:TMP2->nomm + | andi TMP2, TMP2, 1<vmeta_tsetv + |. nop + | + |5: + | bne TMP2, AT, ->vmeta_tsetv + |. lw STR:RC, LO(CARG3) + | b ->BC_TSETS_Z // String key? + |. nop + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0, <2 + break; + case BC_TSETS: + | // RA = src*8, RB = table*8, RC = str_const*8 (~) + | decode_RB8a RB, INS + | decode_RB8b RB + | addu CARG2, BASE, RB + | decode_RC4a RC, INS + | lw TMP0, HI(CARG2) + | decode_RC4b RC + | li AT, LJ_TTAB + | subu CARG3, KBASE, RC + | lw TAB:RB, LO(CARG2) + | lw STR:RC, -4(CARG3) // KBASE-4-str_const*4 + | bne TMP0, AT, ->vmeta_tsets1 + |. addu RA, BASE, RA + |->BC_TSETS_Z: + | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = BASE+src*8 + | lw TMP0, TAB:RB->hmask + | lw TMP1, STR:RC->hash + | lw NODE:TMP2, TAB:RB->node + | sb r0, TAB:RB->nomm // Clear metamethod cache. + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | sll TMP0, TMP1, 5 + | sll TMP1, TMP1, 3 + | subu TMP1, TMP0, TMP1 + | addu NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + | ldc1 f20, 0(RA) + |1: + | lw CARG1, offsetof(Node, key)+HI(NODE:TMP2) + | lw TMP0, offsetof(Node, key)+LO(NODE:TMP2) + | li AT, LJ_TSTR + | lw NODE:TMP1, NODE:TMP2->next + | bne CARG1, AT, >5 + |. lw CARG2, offsetof(Node, val)+HI(NODE:TMP2) + | bne TMP0, STR:RC, >5 + |. lbu TMP3, TAB:RB->marked + | beq CARG2, TISNIL, >4 // Key found, but nil value? + |. lw TAB:TMP0, TAB:RB->metatable + |2: + | andi AT, TMP3, LJ_GC_BLACK // isblack(table) + | bnez AT, >7 + |. sdc1 f20, NODE:TMP2->val + |3: + | ins_next + | + |4: // Check for __newindex if previous value is nil. + | beqz TAB:TMP0, <2 // No metatable: done. + |. nop + | lbu TMP0, TAB:TMP0->nomm + | andi TMP0, TMP0, 1<vmeta_tsets + |. nop + | + |5: // Follow hash chain. + | bnez NODE:TMP1, <1 + |. move NODE:TMP2, NODE:TMP1 + | // End of hash chain: key not found, add a new one + | + | // But check for __newindex first. + | lw TAB:TMP2, TAB:RB->metatable + | beqz TAB:TMP2, >6 // No metatable: continue. + |. addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) + | lbu TMP0, TAB:TMP2->nomm + | andi TMP0, TMP0, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. + |. li AT, LJ_TSTR + |6: + | load_got lj_tab_newkey + | sw STR:RC, LO(CARG3) + | sw AT, HI(CARG3) + | sw BASE, L->base + | move CARG2, TAB:RB + | sw PC, SAVE_PC + | call_intern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k + |. move CARG1, L + | // Returns TValue *. + | lw BASE, L->base + | b <3 // No 2nd write barrier needed. + |. sdc1 f20, 0(CRET1) + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0, <3 + break; + case BC_TSETB: + | // RA = src*8, RB = table*8, RC = index*8 + | decode_RB8a RB, INS + | decode_RB8b RB + | addu CARG2, BASE, RB + | decode_RDtoRC8 RC, RD + | lw CARG1, HI(CARG2) + | li AT, LJ_TTAB + | lw TAB:RB, LO(CARG2) + | addu RA, BASE, RA + | bne CARG1, AT, ->vmeta_tsetb + |. srl TMP0, RC, 3 + | lw TMP1, TAB:RB->asize + | lw TMP2, TAB:RB->array + | sltu AT, TMP0, TMP1 + | beqz AT, ->vmeta_tsetb + |. addu RC, TMP2, RC + | lw TMP1, HI(RC) + | lbu TMP3, TAB:RB->marked + | beq TMP1, TISNIL, >5 + |. ldc1 f0, 0(RA) + |1: + | andi AT, TMP3, LJ_GC_BLACK // isblack(table) + | bnez AT, >7 + |. sdc1 f0, 0(RC) + |2: + | ins_next + | + |5: // Check for __newindex if previous value is nil. + | lw TAB:TMP2, TAB:RB->metatable + | beqz TAB:TMP2, <1 // No metatable: done. + |. nop + | lbu TMP1, TAB:TMP2->nomm + | andi TMP1, TMP1, 1<vmeta_tsetb // Caveat: preserve TMP0! + |. nop + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0, <2 + break; + + case BC_TSETM: + | // RA = base*8 (table at base-1), RD = num_const*8 (start index) + | addu RA, BASE, RA + |1: + | addu TMP3, KBASE, RD + | lw TAB:CARG2, -8+LO(RA) // Guaranteed to be a table. + | addiu TMP0, MULTRES, -8 + | lw TMP3, LO(TMP3) // Integer constant is in lo-word. + | beqz TMP0, >4 // Nothing to copy? + |. srl CARG3, TMP0, 3 + | addu CARG3, CARG3, TMP3 + | lw TMP2, TAB:CARG2->asize + | sll TMP1, TMP3, 3 + | lbu TMP3, TAB:CARG2->marked + | lw CARG1, TAB:CARG2->array + | sltu AT, TMP2, CARG3 + | bnez AT, >5 + |. addu TMP2, RA, TMP0 + | addu TMP1, TMP1, CARG1 + | andi TMP0, TMP3, LJ_GC_BLACK // isblack(table) + |3: // Copy result slots to table. + | ldc1 f0, 0(RA) + | addiu RA, RA, 8 + | sltu AT, RA, TMP2 + | sdc1 f0, 0(TMP1) + | bnez AT, <3 + |. addiu TMP1, TMP1, 8 + | bnez TMP0, >7 + |. nop + |4: + | ins_next + | + |5: // Need to resize array part. + | load_got lj_tab_reasize + | sw BASE, L->base + | sw PC, SAVE_PC + | move BASE, RD + | call_intern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) + |. move CARG1, L + | // Must not reallocate the stack. + | move RD, BASE + | b <1 + |. lw BASE, L->base // Reload BASE for lack of a saved register. + | + |7: // Possible table write barrier for any value. Skip valiswhite check. + | barrierback TAB:CARG2, TMP3, TMP0, <4 + break; + + /* -- Calls and vararg handling ----------------------------------------- */ + + case BC_CALLM: + | // RA = base*8, (RB = (nresults+1)*8,) RC = extra_nargs*8 + | decode_RDtoRC8 NARGS8:RC, RD + | b ->BC_CALL_Z + |. addu NARGS8:RC, NARGS8:RC, MULTRES + break; + case BC_CALL: + | // RA = base*8, (RB = (nresults+1)*8,) RC = (nargs+1)*8 + | decode_RDtoRC8 NARGS8:RC, RD + |->BC_CALL_Z: + | move TMP2, BASE + | addu BASE, BASE, RA + | li AT, LJ_TFUNC + | lw TMP0, HI(BASE) + | lw LFUNC:RB, LO(BASE) + | addiu BASE, BASE, 8 + | bne TMP0, AT, ->vmeta_call + |. addiu NARGS8:RC, NARGS8:RC, -8 + | ins_call + break; + + case BC_CALLMT: + | // RA = base*8, (RB = 0,) RC = extra_nargs*8 + | addu NARGS8:RD, NARGS8:RD, MULTRES // BC_CALLT gets RC from RD. + | // Fall through. Assumes BC_CALLT follows. + break; + case BC_CALLT: + | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 + | addu RA, BASE, RA + | li AT, LJ_TFUNC + | lw TMP0, HI(RA) + | lw LFUNC:RB, LO(RA) + | move NARGS8:RC, RD + | lw TMP1, FRAME_PC(BASE) + | addiu RA, RA, 8 + | bne TMP0, AT, ->vmeta_callt + |. addiu NARGS8:RC, NARGS8:RC, -8 + |->BC_CALLT_Z: + | andi TMP0, TMP1, FRAME_TYPE // Caveat: preserve TMP0 until the 'or'. + | lbu TMP3, LFUNC:RB->ffid + | bnez TMP0, >7 + |. xori TMP2, TMP1, FRAME_VARG + |1: + | sw LFUNC:RB, FRAME_FUNC(BASE) // Copy function down, but keep PC. + | sltiu AT, TMP3, 2 // (> FF_C) Calling a fast function? + | move TMP2, BASE + | beqz NARGS8:RC, >3 + |. move TMP3, NARGS8:RC + |2: + | ldc1 f0, 0(RA) + | addiu RA, RA, 8 + | addiu TMP3, TMP3, -8 + | sdc1 f0, 0(TMP2) + | bnez TMP3, <2 + |. addiu TMP2, TMP2, 8 + |3: + | or TMP0, TMP0, AT + | beqz TMP0, >5 + |. nop + |4: + | ins_callt + | + |5: // Tailcall to a fast function with a Lua frame below. + | lw INS, -4(TMP1) + | decode_RA8a RA, INS + | decode_RA8b RA + | subu TMP1, BASE, RA + | lw LFUNC:TMP1, -8+FRAME_FUNC(TMP1) + | lw TMP1, LFUNC:TMP1->pc + | b <4 + |. lw KBASE, PC2PROTO(k)(TMP1) // Need to prepare KBASE. + | + |7: // Tailcall from a vararg function. + | andi AT, TMP2, FRAME_TYPEP + | bnez AT, <1 // Vararg frame below? + |. subu TMP2, BASE, TMP2 // Relocate BASE down. + | move BASE, TMP2 + | lw TMP1, FRAME_PC(TMP2) + | b <1 + |. andi TMP0, TMP1, FRAME_TYPE + break; + + case BC_ITERC: + | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 ((2+1)*8)) + | move TMP2, BASE + | addu BASE, BASE, RA + | li AT, LJ_TFUNC + | lw TMP1, -24+HI(BASE) + | lw LFUNC:RB, -24+LO(BASE) + | ldc1 f2, -8(BASE) + | ldc1 f0, -16(BASE) + | sw TMP1, HI(BASE) // Copy callable. + | sw LFUNC:RB, LO(BASE) + | sdc1 f2, 16(BASE) // Copy control var. + | sdc1 f0, 8(BASE) // Copy state. + | addiu BASE, BASE, 8 + | bne TMP1, AT, ->vmeta_call + |. li NARGS8:RC, 16 // Iterators get 2 arguments. + | ins_call + break; + + case BC_ITERN: + | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 (2+1)*8) + |.if JIT + | // NYI: add hotloop, record BC_ITERN. + |.endif + | addu RA, BASE, RA + | lw TAB:RB, -16+LO(RA) + | lw RC, -8+LO(RA) // Get index from control var. + | lw TMP0, TAB:RB->asize + | lw TMP1, TAB:RB->array + | addiu PC, PC, 4 + |1: // Traverse array part. + | sltu AT, RC, TMP0 + | beqz AT, >5 // Index points after array part? + |. sll TMP3, RC, 3 + | addu TMP3, TMP1, TMP3 + | lw TMP2, HI(TMP3) + | ldc1 f0, 0(TMP3) + | mtc1 RC, f2 + | lhu RD, -4+OFS_RD(PC) + | beq TMP2, TISNIL, <1 // Skip holes in array part. + |. addiu RC, RC, 1 + | cvt.d.w f2, f2 + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | sdc1 f0, 8(RA) + | decode_RD4b RD + | addu RD, RD, TMP3 + | sw RC, -8+LO(RA) // Update control var. + | addu PC, PC, RD + | sdc1 f2, 0(RA) + |3: + | ins_next + | + |5: // Traverse hash part. + | lw TMP1, TAB:RB->hmask + | subu RC, RC, TMP0 + | lw TMP2, TAB:RB->node + |6: + | sltu AT, TMP1, RC // End of iteration? Branch to ITERL+1. + | bnez AT, <3 + |. sll TMP3, RC, 5 + | sll RB, RC, 3 + | subu TMP3, TMP3, RB + | addu NODE:TMP3, TMP3, TMP2 + | lw RB, HI(NODE:TMP3) + | ldc1 f0, 0(NODE:TMP3) + | lhu RD, -4+OFS_RD(PC) + | beq RB, TISNIL, <6 // Skip holes in hash part. + |. addiu RC, RC, 1 + | ldc1 f2, NODE:TMP3->key + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | sdc1 f0, 8(RA) + | addu RC, RC, TMP0 + | decode_RD4b RD + | addu RD, RD, TMP3 + | sdc1 f2, 0(RA) + | addu PC, PC, RD + | b <3 + |. sw RC, -8+LO(RA) // Update control var. + break; + + case BC_ISNEXT: + | // RA = base*8, RD = target (points to ITERN) + | addu RA, BASE, RA + | srl TMP0, RD, 1 + | lw CARG1, -24+HI(RA) + | lw CFUNC:CARG2, -24+LO(RA) + | addu TMP0, PC, TMP0 + | lw CARG3, -16+HI(RA) + | lw CARG4, -8+HI(RA) + | li AT, LJ_TFUNC + | bne CARG1, AT, >5 + |. lui TMP2, (-(BCBIAS_J*4 >> 16) & 65535) + | lbu CARG2, CFUNC:CARG2->ffid + | addiu CARG3, CARG3, -LJ_TTAB + | addiu CARG4, CARG4, -LJ_TNIL + | or CARG3, CARG3, CARG4 + | addiu CARG2, CARG2, -FF_next_N + | or CARG2, CARG2, CARG3 + | bnez CARG2, >5 + |. lui TMP1, 0xfffe + | addu PC, TMP0, TMP2 + | ori TMP1, TMP1, 0x7fff + | sw r0, -8+LO(RA) // Initialize control var. + | sw TMP1, -8+HI(RA) + |1: + | ins_next + |5: // Despecialize bytecode if any of the checks fail. + | li TMP3, BC_JMP + | li TMP1, BC_ITERC + | sb TMP3, -4+OFS_OP(PC) + | addu PC, TMP0, TMP2 + | b <1 + |. sb TMP1, OFS_OP(PC) + break; + + case BC_VARG: + | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 + | lw TMP0, FRAME_PC(BASE) + | decode_RDtoRC8 RC, RD + | decode_RB8a RB, INS + | addu RC, BASE, RC + | decode_RB8b RB + | addu RA, BASE, RA + | addiu RC, RC, FRAME_VARG + | addu TMP2, RA, RB + | addiu TMP3, BASE, -8 // TMP3 = vtop + | subu RC, RC, TMP0 // RC = vbase + | // Note: RC may now be even _above_ BASE if nargs was < numparams. + | beqz RB, >5 // Copy all varargs? + |. subu TMP1, TMP3, RC + | addiu TMP2, TMP2, -16 + |1: // Copy vararg slots to destination slots. + | lw CARG1, HI(RC) + | sltu AT, RC, TMP3 + | lw CARG2, LO(RC) + | addiu RC, RC, 8 + | movz CARG1, TISNIL, AT + | sw CARG1, HI(RA) + | sw CARG2, LO(RA) + | sltu AT, RA, TMP2 + | bnez AT, <1 + |. addiu RA, RA, 8 + |3: + | ins_next + | + |5: // Copy all varargs. + | lw TMP0, L->maxstack + | blez TMP1, <3 // No vararg slots? + |. li MULTRES, 8 // MULTRES = (0+1)*8 + | addu TMP2, RA, TMP1 + | sltu AT, TMP0, TMP2 + | bnez AT, >7 + |. addiu MULTRES, TMP1, 8 + |6: + | ldc1 f0, 0(RC) + | addiu RC, RC, 8 + | sdc1 f0, 0(RA) + | sltu AT, RC, TMP3 + | bnez AT, <6 // More vararg slots? + |. addiu RA, RA, 8 + | b <3 + |. nop + | + |7: // Grow stack for varargs. + | load_got lj_state_growstack + | sw RA, L->top + | subu RA, RA, BASE + | sw BASE, L->base + | subu BASE, RC, BASE // Need delta, because BASE may change. + | sw PC, SAVE_PC + | srl CARG2, TMP1, 3 + | call_intern lj_state_growstack // (lua_State *L, int n) + |. move CARG1, L + | move RC, BASE + | lw BASE, L->base + | addu RA, BASE, RA + | addu RC, BASE, RC + | b <6 + |. addiu TMP3, BASE, -8 + break; + + /* -- Returns ----------------------------------------------------------- */ + + case BC_RETM: + | // RA = results*8, RD = extra_nresults*8 + | addu RD, RD, MULTRES // MULTRES >= 8, so RD >= 8. + | // Fall through. Assumes BC_RET follows. + break; + + case BC_RET: + | // RA = results*8, RD = (nresults+1)*8 + | lw PC, FRAME_PC(BASE) + | addu RA, BASE, RA + | move MULTRES, RD + |1: + | andi TMP0, PC, FRAME_TYPE + | bnez TMP0, ->BC_RETV_Z + |. xori TMP1, PC, FRAME_VARG + | + |->BC_RET_Z: + | // BASE = base, RA = resultptr, RD = (nresults+1)*8, PC = return + | lw INS, -4(PC) + | addiu TMP2, BASE, -8 + | addiu RC, RD, -8 + | decode_RA8a TMP0, INS + | decode_RB8a RB, INS + | decode_RA8b TMP0 + | decode_RB8b RB + | addu TMP3, TMP2, RB + | beqz RC, >3 + |. subu BASE, TMP2, TMP0 + |2: + | ldc1 f0, 0(RA) + | addiu RA, RA, 8 + | addiu RC, RC, -8 + | sdc1 f0, 0(TMP2) + | bnez RC, <2 + |. addiu TMP2, TMP2, 8 + |3: + | addiu TMP3, TMP3, -8 + |5: + | sltu AT, TMP2, TMP3 + | bnez AT, >6 + |. lw LFUNC:TMP1, FRAME_FUNC(BASE) + | ins_next1 + | lw TMP1, LFUNC:TMP1->pc + | lw KBASE, PC2PROTO(k)(TMP1) + | ins_next2 + | + |6: // Fill up results with nil. + | sw TISNIL, HI(TMP2) + | b <5 + |. addiu TMP2, TMP2, 8 + | + |->BC_RETV_Z: // Non-standard return case. + | andi TMP2, TMP1, FRAME_TYPEP + | bnez TMP2, ->vm_return + |. nop + | // Return from vararg function: relocate BASE down. + | subu BASE, BASE, TMP1 + | b <1 + |. lw PC, FRAME_PC(BASE) + break; + + case BC_RET0: case BC_RET1: + | // RA = results*8, RD = (nresults+1)*8 + | lw PC, FRAME_PC(BASE) + | addu RA, BASE, RA + | move MULTRES, RD + | andi TMP0, PC, FRAME_TYPE + | bnez TMP0, ->BC_RETV_Z + |. xori TMP1, PC, FRAME_VARG + | + | lw INS, -4(PC) + | addiu TMP2, BASE, -8 + if (op == BC_RET1) { + | ldc1 f0, 0(RA) + } + | decode_RB8a RB, INS + | decode_RA8a RA, INS + | decode_RB8b RB + | decode_RA8b RA + if (op == BC_RET1) { + | sdc1 f0, 0(TMP2) + } + | subu BASE, TMP2, RA + |5: + | sltu AT, RD, RB + | bnez AT, >6 + |. lw LFUNC:TMP1, FRAME_FUNC(BASE) + | ins_next1 + | lw TMP1, LFUNC:TMP1->pc + | lw KBASE, PC2PROTO(k)(TMP1) + | ins_next2 + | + |6: // Fill up results with nil. + | addiu TMP2, TMP2, 8 + | addiu RD, RD, 8 + | b <5 + if (op == BC_RET1) { + |. sw TISNIL, HI(TMP2) + } else { + |. sw TISNIL, -8+HI(TMP2) + } + break; + + /* -- Loops and branches ------------------------------------------------ */ + + case BC_FORL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IFORL follows. + break; + + case BC_JFORI: + case BC_JFORL: +#if !LJ_HASJIT + break; +#endif + case BC_FORI: + case BC_IFORL: + | // RA = base*8, RD = target (after end of loop or start of loop) + vk = (op == BC_IFORL || op == BC_JFORL); + | addu RA, BASE, RA + if (vk) { + | ldc1 f0, FORL_IDX*8(RA) + | ldc1 f4, FORL_STEP*8(RA) + | ldc1 f2, FORL_STOP*8(RA) + | lw TMP3, FORL_STEP*8+HI(RA) + | add.d f0, f0, f4 + | sdc1 f0, FORL_IDX*8(RA) + } else { + | lw TMP1, FORL_IDX*8+HI(RA) + | lw TMP3, FORL_STEP*8+HI(RA) + | lw TMP2, FORL_STOP*8+HI(RA) + | sltiu TMP1, TMP1, LJ_TISNUM + | sltiu TMP0, TMP3, LJ_TISNUM + | sltiu TMP2, TMP2, LJ_TISNUM + | and TMP1, TMP1, TMP0 + | and TMP1, TMP1, TMP2 + | ldc1 f0, FORL_IDX*8(RA) + | beqz TMP1, ->vmeta_for + |. ldc1 f2, FORL_STOP*8(RA) + } + if (op != BC_JFORL) { + | srl RD, RD, 1 + | lui TMP0, (-(BCBIAS_J*4 >> 16) & 65535) + } + | c.le.d 0, f0, f2 + | c.le.d 1, f2, f0 + | sdc1 f0, FORL_EXT*8(RA) + if (op == BC_JFORI) { + | li TMP1, 1 + | li TMP2, 1 + | addu TMP0, RD, TMP0 + | slt TMP3, TMP3, r0 + | movf TMP1, r0, 0 + | addu PC, PC, TMP0 + | movf TMP2, r0, 1 + | lhu RD, -4+OFS_RD(PC) + | movn TMP1, TMP2, TMP3 + | bnez TMP1, =>BC_JLOOP + |. decode_RD8b RD + } else if (op == BC_JFORL) { + | li TMP1, 1 + | li TMP2, 1 + | slt TMP3, TMP3, r0 + | movf TMP1, r0, 0 + | movf TMP2, r0, 1 + | movn TMP1, TMP2, TMP3 + | bnez TMP1, =>BC_JLOOP + |. nop + } else { + | addu TMP1, RD, TMP0 + | slt TMP3, TMP3, r0 + | move TMP2, TMP1 + if (op == BC_FORI) { + | movt TMP1, r0, 0 + | movt TMP2, r0, 1 + } else { + | movf TMP1, r0, 0 + | movf TMP2, r0, 1 + } + | movn TMP1, TMP2, TMP3 + | addu PC, PC, TMP1 + } + | ins_next + break; + + case BC_ITERL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IITERL follows. + break; + + case BC_JITERL: +#if !LJ_HASJIT + break; +#endif + case BC_IITERL: + | // RA = base*8, RD = target + | addu RA, BASE, RA + | lw TMP1, HI(RA) + | beq TMP1, TISNIL, >1 // Stop if iterator returned nil. + |. lw TMP2, LO(RA) + if (op == BC_JITERL) { + | sw TMP1, -8+HI(RA) + | b =>BC_JLOOP + |. sw TMP2, -8+LO(RA) + } else { + | branch_RD // Otherwise save control var + branch. + | sw TMP1, -8+HI(RA) + | sw TMP2, -8+LO(RA) + } + |1: + | ins_next + break; + + case BC_LOOP: + | // RA = base*8, RD = target (loop extent) + | // Note: RA/RD is only used by trace recorder to determine scope/extent + | // This opcode does NOT jump, it's only purpose is to detect a hot loop. + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_ILOOP follows. + break; + + case BC_ILOOP: + | // RA = base*8, RD = target (loop extent) + | ins_next + break; + + case BC_JLOOP: + |.if JIT + | // RA = base*8 (ignored), RD = traceno*8 + | lw TMP1, DISPATCH_J(trace)(DISPATCH) + | srl RD, RD, 1 + | li AT, 0 + | addu TMP1, TMP1, RD + | // Traces on MIPS don't store the trace number, so use 0. + | sw AT, DISPATCH_GL(vmstate)(DISPATCH) + | lw TRACE:TMP2, 0(TMP1) + | sw BASE, DISPATCH_GL(jit_base)(DISPATCH) + | sw L, DISPATCH_GL(jit_L)(DISPATCH) + | lw TMP2, TRACE:TMP2->mcode + | jr TMP2 + |. addiu JGL, DISPATCH, GG_DISP2G+32768 + |.endif + break; + + case BC_JMP: + | // RA = base*8 (only used by trace recorder), RD = target + | branch_RD + | ins_next + break; + + /* -- Function headers -------------------------------------------------- */ + + case BC_FUNCF: + |.if JIT + | hotcall + |.endif + case BC_FUNCV: /* NYI: compiled vararg functions. */ + | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. + break; + + case BC_JFUNCF: +#if !LJ_HASJIT + break; +#endif + case BC_IFUNCF: + | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 + | lw TMP2, L->maxstack + | lbu TMP1, -4+PC2PROTO(numparams)(PC) + | lw KBASE, -4+PC2PROTO(k)(PC) + | sltu AT, TMP2, RA + | bnez AT, ->vm_growstack_l + |. sll TMP1, TMP1, 3 + if (op != BC_JFUNCF) { + | ins_next1 + } + |2: + | sltu AT, NARGS8:RC, TMP1 // Check for missing parameters. + | bnez AT, >3 + |. addu AT, BASE, NARGS8:RC + if (op == BC_JFUNCF) { + | decode_RD8a RD, INS + | b =>BC_JLOOP + |. decode_RD8b RD + } else { + | ins_next2 + } + | + |3: // Clear missing parameters. + | sw TISNIL, HI(AT) + | b <2 + |. addiu NARGS8:RC, NARGS8:RC, 8 + break; + + case BC_JFUNCV: +#if !LJ_HASJIT + break; +#endif + | NYI // NYI: compiled vararg functions + break; /* NYI: compiled vararg functions. */ + + case BC_IFUNCV: + | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 + | addu TMP1, BASE, RC + | lw TMP2, L->maxstack + | addu TMP0, RA, RC + | sw LFUNC:RB, LO(TMP1) // Store copy of LFUNC. + | addiu TMP3, RC, 8+FRAME_VARG + | sltu AT, TMP0, TMP2 + | lw KBASE, -4+PC2PROTO(k)(PC) + | beqz AT, ->vm_growstack_l + |. sw TMP3, HI(TMP1) // Store delta + FRAME_VARG. + | lbu TMP2, -4+PC2PROTO(numparams)(PC) + | move RA, BASE + | move RC, TMP1 + | ins_next1 + | beqz TMP2, >3 + |. addiu BASE, TMP1, 8 + |1: + | lw TMP0, HI(RA) + | lw TMP3, LO(RA) + | sltu AT, RA, RC // Less args than parameters? + | move CARG1, TMP0 + | movz TMP0, TISNIL, AT // Clear missing parameters. + | movn CARG1, TISNIL, AT // Clear old fixarg slot (help the GC). + | sw TMP3, 8+LO(TMP1) + | addiu TMP2, TMP2, -1 + | sw TMP0, 8+HI(TMP1) + | addiu TMP1, TMP1, 8 + | sw CARG1, HI(RA) + | bnez TMP2, <1 + |. addiu RA, RA, 8 + |3: + | ins_next2 + break; + + case BC_FUNCC: + case BC_FUNCCW: + | // BASE = new base, RA = BASE+framesize*8, RB = CFUNC, RC = nargs*8 + if (op == BC_FUNCC) { + | lw CFUNCADDR, CFUNC:RB->f + } else { + | lw CFUNCADDR, DISPATCH_GL(wrapf)(DISPATCH) + } + | addu TMP1, RA, NARGS8:RC + | lw TMP2, L->maxstack + | addu RC, BASE, NARGS8:RC + | sw BASE, L->base + | sltu AT, TMP2, TMP1 + | sw RC, L->top + | li_vmstate C + if (op == BC_FUNCCW) { + | lw CARG2, CFUNC:RB->f + } + | bnez AT, ->vm_growstack_c // Need to grow stack. + |. move CARG1, L + | jalr CFUNCADDR // (lua_State *L [, lua_CFunction f]) + |. st_vmstate + | // Returns nresults. + | lw BASE, L->base + | sll RD, CRET1, 3 + | lw TMP1, L->top + | li_vmstate INTERP + | lw PC, FRAME_PC(BASE) // Fetch PC of caller. + | subu RA, TMP1, RD // RA = L->top - nresults*8 + | b ->vm_returnc + |. st_vmstate + break; + + /* ---------------------------------------------------------------------- */ + + default: + fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); + exit(2); + break; + } +} + +static int build_backend(BuildCtx *ctx) +{ + int op; + + dasm_growpc(Dst, BC__MAX); + + build_subroutines(ctx); + + |.code_op + for (op = 0; op < BC__MAX; op++) + build_ins(ctx, (BCOp)op, op); + + return BC__MAX; +} + +/* Emit pseudo frame-info for all assembler functions. */ +static void emit_asm_debug(BuildCtx *ctx) +{ + int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); + int i; + switch (ctx->mode) { + case BUILD_elfasm: + fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); + fprintf(ctx->fp, + ".Lframe0:\n" + "\t.4byte .LECIE0-.LSCIE0\n" + ".LSCIE0:\n" + "\t.4byte 0xffffffff\n" + "\t.byte 0x1\n" + "\t.string \"\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 31\n" + "\t.byte 0xc\n\t.uleb128 29\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE0:\n\n"); + fprintf(ctx->fp, + ".LSFDE0:\n" + "\t.4byte .LEFDE0-.LASFDE0\n" + ".LASFDE0:\n" + "\t.4byte .Lframe0\n" + "\t.4byte .Lbegin\n" + "\t.4byte %d\n" + "\t.byte 0xe\n\t.uleb128 %d\n" + "\t.byte 0x9f\n\t.sleb128 1\n" + "\t.byte 0x9e\n\t.sleb128 2\n", + fcofs, CFRAME_SIZE); + for (i = 23; i >= 16; i--) + fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+i, 26-i); + for (i = 30; i >= 20; i -= 2) + fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+32+i, 42-i); + fprintf(ctx->fp, + "\t.align 2\n" + ".LEFDE0:\n\n"); +#if LJ_HASFFI + fprintf(ctx->fp, + ".LSFDE1:\n" + "\t.4byte .LEFDE1-.LASFDE1\n" + ".LASFDE1:\n" + "\t.4byte .Lframe0\n" + "\t.4byte lj_vm_ffi_call\n" + "\t.4byte %d\n" + "\t.byte 0x9f\n\t.uleb128 1\n" + "\t.byte 0x90\n\t.uleb128 2\n" + "\t.byte 0xd\n\t.uleb128 0x10\n" + "\t.align 2\n" + ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); +#endif +#if !LJ_NO_UNWIND + fprintf(ctx->fp, "\t.section .eh_frame,\"aw\",@progbits\n"); + fprintf(ctx->fp, + "\t.globl lj_err_unwind_dwarf\n" + ".Lframe1:\n" + "\t.4byte .LECIE1-.LSCIE1\n" + ".LSCIE1:\n" + "\t.4byte 0\n" + "\t.byte 0x1\n" + "\t.string \"zPR\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 31\n" + "\t.uleb128 6\n" /* augmentation length */ + "\t.byte 0\n" + "\t.4byte lj_err_unwind_dwarf\n" + "\t.byte 0\n" + "\t.byte 0xc\n\t.uleb128 29\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE1:\n\n"); + fprintf(ctx->fp, + ".LSFDE2:\n" + "\t.4byte .LEFDE2-.LASFDE2\n" + ".LASFDE2:\n" + "\t.4byte .LASFDE2-.Lframe1\n" + "\t.4byte .Lbegin\n" + "\t.4byte %d\n" + "\t.uleb128 0\n" /* augmentation length */ + "\t.byte 0xe\n\t.uleb128 %d\n" + "\t.byte 0x9f\n\t.sleb128 1\n" + "\t.byte 0x9e\n\t.sleb128 2\n", + fcofs, CFRAME_SIZE); + for (i = 23; i >= 16; i--) + fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+i, 26-i); + for (i = 30; i >= 20; i -= 2) + fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+32+i, 42-i); + fprintf(ctx->fp, + "\t.align 2\n" + ".LEFDE2:\n\n"); +#if LJ_HASFFI + fprintf(ctx->fp, + ".Lframe2:\n" + "\t.4byte .LECIE2-.LSCIE2\n" + ".LSCIE2:\n" + "\t.4byte 0\n" + "\t.byte 0x1\n" + "\t.string \"zR\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 31\n" + "\t.uleb128 1\n" /* augmentation length */ + "\t.byte 0\n" + "\t.byte 0xc\n\t.uleb128 29\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE2:\n\n"); + fprintf(ctx->fp, + ".LSFDE3:\n" + "\t.4byte .LEFDE3-.LASFDE3\n" + ".LASFDE3:\n" + "\t.4byte .LASFDE3-.Lframe2\n" + "\t.4byte lj_vm_ffi_call\n" + "\t.4byte %d\n" + "\t.uleb128 0\n" /* augmentation length */ + "\t.byte 0x9f\n\t.uleb128 1\n" + "\t.byte 0x90\n\t.uleb128 2\n" + "\t.byte 0xd\n\t.uleb128 0x10\n" + "\t.align 2\n" + ".LEFDE3:\n\n", (int)ctx->codesz - fcofs); +#endif +#endif + break; + default: + break; + } +} + + +``` + +`include/luajit-2.0.5/src/vm_ppc.dasc`: + +```dasc +|// Low-level VM code for PowerPC CPUs. +|// Bytecode interpreter, fast functions and helper functions. +|// Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +| +|.arch ppc +|.section code_op, code_sub +| +|.actionlist build_actionlist +|.globals GLOB_ +|.globalnames globnames +|.externnames extnames +| +|// Note: The ragged indentation of the instructions is intentional. +|// The starting columns indicate data dependencies. +| +|//----------------------------------------------------------------------- +| +|// DynASM defines used by the PPC port: +|// +|// P64 64 bit pointers (only for GPR64 testing). +|// Note: a full PPC64 _LP64 port is not planned. +|// GPR64 64 bit registers (but possibly 32 bit pointers, e.g. PS3). +|// Affects reg saves, stack layout, carry/overflow/dot flags etc. +|// FRAME32 Use 32 bit frame layout, even with GPR64 (Xbox 360). +|// TOC Need table of contents (64 bit or 32 bit variant, e.g. PS3). +|// Function pointers are really a struct: code, TOC, env (optional). +|// TOCENV Function pointers have an environment pointer, too (not on PS3). +|// PPE Power Processor Element of Cell (PS3) or Xenon (Xbox 360). +|// Must avoid (slow) micro-coded instructions. +| +|.if P64 +|.define TOC, 1 +|.define TOCENV, 1 +|.macro lpx, a, b, c; ldx a, b, c; .endmacro +|.macro lp, a, b; ld a, b; .endmacro +|.macro stp, a, b; std a, b; .endmacro +|.define decode_OPP, decode_OP8 +|.if FFI +|// Missing: Calling conventions, 64 bit regs, TOC. +|.error lib_ffi not yet implemented for PPC64 +|.endif +|.else +|.macro lpx, a, b, c; lwzx a, b, c; .endmacro +|.macro lp, a, b; lwz a, b; .endmacro +|.macro stp, a, b; stw a, b; .endmacro +|.define decode_OPP, decode_OP4 +|.endif +| +|// Convenience macros for TOC handling. +|.if TOC +|// Linker needs a TOC patch area for every external call relocation. +|.macro blex, target; bl extern target@plt; nop; .endmacro +|.macro .toc, a, b; a, b; .endmacro +|.if P64 +|.define TOC_OFS, 8 +|.define ENV_OFS, 16 +|.else +|.define TOC_OFS, 4 +|.define ENV_OFS, 8 +|.endif +|.else // No TOC. +|.macro blex, target; bl extern target@plt; .endmacro +|.macro .toc, a, b; .endmacro +|.endif +|.macro .tocenv, a, b; .if TOCENV; a, b; .endif; .endmacro +| +|.macro .gpr64, a, b; .if GPR64; a, b; .endif; .endmacro +| +|.macro andix., y, a, i +|.if PPE +| rlwinm y, a, 0, 31-lj_fls(i), 31-lj_ffs(i) +| cmpwi y, 0 +|.else +| andi. y, a, i +|.endif +|.endmacro +| +|.macro clrso, reg +|.if PPE +| li reg, 0 +| mtxer reg +|.else +| mcrxr cr0 +|.endif +|.endmacro +| +|.macro checkov, reg, noov +|.if PPE +| mfxer reg +| add reg, reg, reg +| cmpwi reg, 0 +| li reg, 0 +| mtxer reg +| bgey noov +|.else +| mcrxr cr0 +| bley noov +|.endif +|.endmacro +| +|//----------------------------------------------------------------------- +| +|// Fixed register assignments for the interpreter. +|// Don't use: r1 = sp, r2 and r13 = reserved (TOC, TLS or SDATA) +| +|// The following must be C callee-save (but BASE is often refetched). +|.define BASE, r14 // Base of current Lua stack frame. +|.define KBASE, r15 // Constants of current Lua function. +|.define PC, r16 // Next PC. +|.define DISPATCH, r17 // Opcode dispatch table. +|.define LREG, r18 // Register holding lua_State (also in SAVE_L). +|.define MULTRES, r19 // Size of multi-result: (nresults+1)*8. +|.define JGL, r31 // On-trace: global_State + 32768. +| +|// Constants for type-comparisons, stores and conversions. C callee-save. +|.define TISNUM, r22 +|.define TISNIL, r23 +|.define ZERO, r24 +|.define TOBIT, f30 // 2^52 + 2^51. +|.define TONUM, f31 // 2^52 + 2^51 + 2^31. +| +|// The following temporaries are not saved across C calls, except for RA. +|.define RA, r20 // Callee-save. +|.define RB, r10 +|.define RC, r11 +|.define RD, r12 +|.define INS, r7 // Overlaps CARG5. +| +|.define TMP0, r0 +|.define TMP1, r8 +|.define TMP2, r9 +|.define TMP3, r6 // Overlaps CARG4. +| +|// Saved temporaries. +|.define SAVE0, r21 +| +|// Calling conventions. +|.define CARG1, r3 +|.define CARG2, r4 +|.define CARG3, r5 +|.define CARG4, r6 // Overlaps TMP3. +|.define CARG5, r7 // Overlaps INS. +| +|.define FARG1, f1 +|.define FARG2, f2 +| +|.define CRET1, r3 +|.define CRET2, r4 +| +|.define TOCREG, r2 // TOC register (only used by C code). +|.define ENVREG, r11 // Environment pointer (nested C functions). +| +|// Stack layout while in interpreter. Must match with lj_frame.h. +|.if GPR64 +|.if FRAME32 +| +|// 456(sp) // \ 32/64 bit C frame info +|.define TONUM_LO, 452(sp) // | +|.define TONUM_HI, 448(sp) // | +|.define TMPD_LO, 444(sp) // | +|.define TMPD_HI, 440(sp) // | +|.define SAVE_CR, 432(sp) // | 64 bit CR save. +|.define SAVE_ERRF, 424(sp) // > Parameter save area. +|.define SAVE_NRES, 420(sp) // | +|.define SAVE_L, 416(sp) // | +|.define SAVE_PC, 412(sp) // | +|.define SAVE_MULTRES, 408(sp) // | +|.define SAVE_CFRAME, 400(sp) // / 64 bit C frame chain. +|// 392(sp) // Reserved. +|.define CFRAME_SPACE, 384 // Delta for sp. +|// Back chain for sp: 384(sp) <-- sp entering interpreter +|.define SAVE_LR, 376(sp) // 32 bit LR stored in hi-part. +|.define SAVE_GPR_, 232 // .. 232+18*8: 64 bit GPR saves. +|.define SAVE_FPR_, 88 // .. 88+18*8: 64 bit FPR saves. +|// 80(sp) // Needed for 16 byte stack frame alignment. +|// 16(sp) // Callee parameter save area (ABI mandated). +|// 8(sp) // Reserved +|// Back chain for sp: 0(sp) <-- sp while in interpreter +|// 32 bit sp stored in hi-part of 0(sp). +| +|.define TMPD_BLO, 447(sp) +|.define TMPD, TMPD_HI +|.define TONUM_D, TONUM_HI +| +|.else +| +|// 508(sp) // \ 32 bit C frame info. +|.define SAVE_ERRF, 472(sp) // | +|.define SAVE_NRES, 468(sp) // | +|.define SAVE_L, 464(sp) // > Parameter save area. +|.define SAVE_PC, 460(sp) // | +|.define SAVE_MULTRES, 456(sp) // | +|.define SAVE_CFRAME, 448(sp) // / 64 bit C frame chain. +|.define SAVE_LR, 416(sp) +|.define CFRAME_SPACE, 400 // Delta for sp. +|// Back chain for sp: 400(sp) <-- sp entering interpreter +|.define SAVE_FPR_, 256 // .. 256+18*8: 64 bit FPR saves. +|.define SAVE_GPR_, 112 // .. 112+18*8: 64 bit GPR saves. +|// 48(sp) // Callee parameter save area (ABI mandated). +|.define SAVE_TOC, 40(sp) // TOC save area. +|.define TMPD_LO, 36(sp) // \ Link editor temp (ABI mandated). +|.define TMPD_HI, 32(sp) // / +|.define TONUM_LO, 28(sp) // \ Compiler temp (ABI mandated). +|.define TONUM_HI, 24(sp) // / +|// Next frame lr: 16(sp) +|.define SAVE_CR, 8(sp) // 64 bit CR save. +|// Back chain for sp: 0(sp) <-- sp while in interpreter +| +|.define TMPD_BLO, 39(sp) +|.define TMPD, TMPD_HI +|.define TONUM_D, TONUM_HI +| +|.endif +|.else +| +|.define SAVE_LR, 276(sp) +|.define CFRAME_SPACE, 272 // Delta for sp. +|// Back chain for sp: 272(sp) <-- sp entering interpreter +|.define SAVE_FPR_, 128 // .. 128+18*8: 64 bit FPR saves. +|.define SAVE_GPR_, 56 // .. 56+18*4: 32 bit GPR saves. +|.define SAVE_CR, 52(sp) // 32 bit CR save. +|.define SAVE_ERRF, 48(sp) // 32 bit C frame info. +|.define SAVE_NRES, 44(sp) +|.define SAVE_CFRAME, 40(sp) +|.define SAVE_L, 36(sp) +|.define SAVE_PC, 32(sp) +|.define SAVE_MULTRES, 28(sp) +|.define UNUSED1, 24(sp) +|.define TMPD_LO, 20(sp) +|.define TMPD_HI, 16(sp) +|.define TONUM_LO, 12(sp) +|.define TONUM_HI, 8(sp) +|// Next frame lr: 4(sp) +|// Back chain for sp: 0(sp) <-- sp while in interpreter +| +|.define TMPD_BLO, 23(sp) +|.define TMPD, TMPD_HI +|.define TONUM_D, TONUM_HI +| +|.endif +| +|.macro save_, reg +|.if GPR64 +| std r..reg, SAVE_GPR_+(reg-14)*8(sp) +|.else +| stw r..reg, SAVE_GPR_+(reg-14)*4(sp) +|.endif +| stfd f..reg, SAVE_FPR_+(reg-14)*8(sp) +|.endmacro +|.macro rest_, reg +|.if GPR64 +| ld r..reg, SAVE_GPR_+(reg-14)*8(sp) +|.else +| lwz r..reg, SAVE_GPR_+(reg-14)*4(sp) +|.endif +| lfd f..reg, SAVE_FPR_+(reg-14)*8(sp) +|.endmacro +| +|.macro saveregs +|.if GPR64 and not FRAME32 +| stdu sp, -CFRAME_SPACE(sp) +|.else +| stwu sp, -CFRAME_SPACE(sp) +|.endif +| save_ 14; save_ 15; save_ 16 +| mflr r0 +| save_ 17; save_ 18; save_ 19; save_ 20; save_ 21; save_ 22 +|.if GPR64 and not FRAME32 +| std r0, SAVE_LR +|.else +| stw r0, SAVE_LR +|.endif +| save_ 23; save_ 24; save_ 25 +| mfcr r0 +| save_ 26; save_ 27; save_ 28; save_ 29; save_ 30; save_ 31 +|.if GPR64 +| std r0, SAVE_CR +|.else +| stw r0, SAVE_CR +|.endif +| .toc std TOCREG, SAVE_TOC +|.endmacro +| +|.macro restoreregs +|.if GPR64 and not FRAME32 +| ld r0, SAVE_LR +|.else +| lwz r0, SAVE_LR +|.endif +|.if GPR64 +| ld r12, SAVE_CR +|.else +| lwz r12, SAVE_CR +|.endif +| rest_ 14; rest_ 15; rest_ 16; rest_ 17; rest_ 18; rest_ 19 +| mtlr r0; +|.if PPE; mtocrf 0x20, r12; .else; mtcrf 0x38, r12; .endif +| rest_ 20; rest_ 21; rest_ 22; rest_ 23; rest_ 24; rest_ 25 +|.if PPE; mtocrf 0x10, r12; .endif +| rest_ 26; rest_ 27; rest_ 28; rest_ 29; rest_ 30; rest_ 31 +|.if PPE; mtocrf 0x08, r12; .endif +| addi sp, sp, CFRAME_SPACE +|.endmacro +| +|// Type definitions. Some of these are only used for documentation. +|.type L, lua_State, LREG +|.type GL, global_State +|.type TVALUE, TValue +|.type GCOBJ, GCobj +|.type STR, GCstr +|.type TAB, GCtab +|.type LFUNC, GCfuncL +|.type CFUNC, GCfuncC +|.type PROTO, GCproto +|.type UPVAL, GCupval +|.type NODE, Node +|.type NARGS8, int +|.type TRACE, GCtrace +| +|//----------------------------------------------------------------------- +| +|// These basic macros should really be part of DynASM. +|.macro srwi, rx, ry, n; rlwinm rx, ry, 32-n, n, 31; .endmacro +|.macro slwi, rx, ry, n; rlwinm rx, ry, n, 0, 31-n; .endmacro +|.macro rotlwi, rx, ry, n; rlwinm rx, ry, n, 0, 31; .endmacro +|.macro rotlw, rx, ry, rn; rlwnm rx, ry, rn, 0, 31; .endmacro +|.macro subi, rx, ry, i; addi rx, ry, -i; .endmacro +| +|// Trap for not-yet-implemented parts. +|.macro NYI; tw 4, sp, sp; .endmacro +| +|// int/FP conversions. +|.macro tonum_i, freg, reg +| xoris reg, reg, 0x8000 +| stw reg, TONUM_LO +| lfd freg, TONUM_D +| fsub freg, freg, TONUM +|.endmacro +| +|.macro tonum_u, freg, reg +| stw reg, TONUM_LO +| lfd freg, TONUM_D +| fsub freg, freg, TOBIT +|.endmacro +| +|.macro toint, reg, freg, tmpfreg +| fctiwz tmpfreg, freg +| stfd tmpfreg, TMPD +| lwz reg, TMPD_LO +|.endmacro +| +|.macro toint, reg, freg +| toint reg, freg, freg +|.endmacro +| +|//----------------------------------------------------------------------- +| +|// Access to frame relative to BASE. +|.define FRAME_PC, -8 +|.define FRAME_FUNC, -4 +| +|// Instruction decode. +|.macro decode_OP4, dst, ins; rlwinm dst, ins, 2, 22, 29; .endmacro +|.macro decode_OP8, dst, ins; rlwinm dst, ins, 3, 21, 28; .endmacro +|.macro decode_RA8, dst, ins; rlwinm dst, ins, 27, 21, 28; .endmacro +|.macro decode_RB8, dst, ins; rlwinm dst, ins, 11, 21, 28; .endmacro +|.macro decode_RC8, dst, ins; rlwinm dst, ins, 19, 21, 28; .endmacro +|.macro decode_RD8, dst, ins; rlwinm dst, ins, 19, 13, 28; .endmacro +| +|.macro decode_OP1, dst, ins; rlwinm dst, ins, 0, 24, 31; .endmacro +|.macro decode_RD4, dst, ins; rlwinm dst, ins, 18, 14, 29; .endmacro +| +|// Instruction fetch. +|.macro ins_NEXT1 +| lwz INS, 0(PC) +| addi PC, PC, 4 +|.endmacro +|// Instruction decode+dispatch. Note: optimized for e300! +|.macro ins_NEXT2 +| decode_OPP TMP1, INS +| lpx TMP0, DISPATCH, TMP1 +| mtctr TMP0 +| decode_RB8 RB, INS +| decode_RD8 RD, INS +| decode_RA8 RA, INS +| decode_RC8 RC, INS +| bctr +|.endmacro +|.macro ins_NEXT +| ins_NEXT1 +| ins_NEXT2 +|.endmacro +| +|// Instruction footer. +|.if 1 +| // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. +| .define ins_next, ins_NEXT +| .define ins_next_, ins_NEXT +| .define ins_next1, ins_NEXT1 +| .define ins_next2, ins_NEXT2 +|.else +| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. +| // Affects only certain kinds of benchmarks (and only with -j off). +| .macro ins_next +| b ->ins_next +| .endmacro +| .macro ins_next1 +| .endmacro +| .macro ins_next2 +| b ->ins_next +| .endmacro +| .macro ins_next_ +| ->ins_next: +| ins_NEXT +| .endmacro +|.endif +| +|// Call decode and dispatch. +|.macro ins_callt +| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC +| lwz PC, LFUNC:RB->pc +| lwz INS, 0(PC) +| addi PC, PC, 4 +| decode_OPP TMP1, INS +| decode_RA8 RA, INS +| lpx TMP0, DISPATCH, TMP1 +| add RA, RA, BASE +| mtctr TMP0 +| bctr +|.endmacro +| +|.macro ins_call +| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, PC = caller PC +| stw PC, FRAME_PC(BASE) +| ins_callt +|.endmacro +| +|//----------------------------------------------------------------------- +| +|// Macros to test operand types. +|.macro checknum, reg; cmplw reg, TISNUM; .endmacro +|.macro checknum, cr, reg; cmplw cr, reg, TISNUM; .endmacro +|.macro checkstr, reg; cmpwi reg, LJ_TSTR; .endmacro +|.macro checktab, reg; cmpwi reg, LJ_TTAB; .endmacro +|.macro checkfunc, reg; cmpwi reg, LJ_TFUNC; .endmacro +|.macro checknil, reg; cmpwi reg, LJ_TNIL; .endmacro +| +|.macro branch_RD +| srwi TMP0, RD, 1 +| addis PC, PC, -(BCBIAS_J*4 >> 16) +| add PC, PC, TMP0 +|.endmacro +| +|// Assumes DISPATCH is relative to GL. +#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) +#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) +| +#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) +| +|.macro hotcheck, delta, target +| rlwinm TMP1, PC, 31, 25, 30 +| addi TMP1, TMP1, GG_DISP2HOT +| lhzx TMP2, DISPATCH, TMP1 +| addic. TMP2, TMP2, -delta +| sthx TMP2, DISPATCH, TMP1 +| blt target +|.endmacro +| +|.macro hotloop +| hotcheck HOTCOUNT_LOOP, ->vm_hotloop +|.endmacro +| +|.macro hotcall +| hotcheck HOTCOUNT_CALL, ->vm_hotcall +|.endmacro +| +|// Set current VM state. Uses TMP0. +|.macro li_vmstate, st; li TMP0, ~LJ_VMST_..st; .endmacro +|.macro st_vmstate; stw TMP0, DISPATCH_GL(vmstate)(DISPATCH); .endmacro +| +|// Move table write barrier back. Overwrites mark and tmp. +|.macro barrierback, tab, mark, tmp +| lwz tmp, DISPATCH_GL(gc.grayagain)(DISPATCH) +| // Assumes LJ_GC_BLACK is 0x04. +| rlwinm mark, mark, 0, 30, 28 // black2gray(tab) +| stw tab, DISPATCH_GL(gc.grayagain)(DISPATCH) +| stb mark, tab->marked +| stw tmp, tab->gclist +|.endmacro +| +|//----------------------------------------------------------------------- + +/* Generate subroutines used by opcodes and other parts of the VM. */ +/* The .code_sub section should be last to help static branch prediction. */ +static void build_subroutines(BuildCtx *ctx) +{ + |.code_sub + | + |//----------------------------------------------------------------------- + |//-- Return handling ---------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_returnp: + | // See vm_return. Also: TMP2 = previous base. + | andix. TMP0, PC, FRAME_P + | li TMP1, LJ_TTRUE + | beq ->cont_dispatch + | + | // Return from pcall or xpcall fast func. + | lwz PC, FRAME_PC(TMP2) // Fetch PC of previous frame. + | mr BASE, TMP2 // Restore caller base. + | // Prepending may overwrite the pcall frame, so do it at the end. + | stwu TMP1, FRAME_PC(RA) // Prepend true to results. + | + |->vm_returnc: + | addi RD, RD, 8 // RD = (nresults+1)*8. + | andix. TMP0, PC, FRAME_TYPE + | cmpwi cr1, RD, 0 + | li CRET1, LUA_YIELD + | beq cr1, ->vm_unwind_c_eh + | mr MULTRES, RD + | beq ->BC_RET_Z // Handle regular return to Lua. + | + |->vm_return: + | // BASE = base, RA = resultptr, RD/MULTRES = (nresults+1)*8, PC = return + | // TMP0 = PC & FRAME_TYPE + | cmpwi TMP0, FRAME_C + | rlwinm TMP2, PC, 0, 0, 28 + | li_vmstate C + | sub TMP2, BASE, TMP2 // TMP2 = previous base. + | bney ->vm_returnp + | + | addic. TMP1, RD, -8 + | stp TMP2, L->base + | lwz TMP2, SAVE_NRES + | subi BASE, BASE, 8 + | st_vmstate + | slwi TMP2, TMP2, 3 + | beq >2 + |1: + | addic. TMP1, TMP1, -8 + | lfd f0, 0(RA) + | addi RA, RA, 8 + | stfd f0, 0(BASE) + | addi BASE, BASE, 8 + | bney <1 + | + |2: + | cmpw TMP2, RD // More/less results wanted? + | bne >6 + |3: + | stp BASE, L->top // Store new top. + | + |->vm_leave_cp: + | lp TMP0, SAVE_CFRAME // Restore previous C frame. + | li CRET1, 0 // Ok return status for vm_pcall. + | stp TMP0, L->cframe + | + |->vm_leave_unw: + | restoreregs + | blr + | + |6: + | ble >7 // Less results wanted? + | // More results wanted. Check stack size and fill up results with nil. + | lwz TMP1, L->maxstack + | cmplw BASE, TMP1 + | bge >8 + | stw TISNIL, 0(BASE) + | addi RD, RD, 8 + | addi BASE, BASE, 8 + | b <2 + | + |7: // Less results wanted. + | subfic TMP3, TMP2, 0 // LUA_MULTRET+1 case? + | sub TMP0, RD, TMP2 + | subfe TMP1, TMP1, TMP1 // TMP1 = TMP2 == 0 ? 0 : -1 + | and TMP0, TMP0, TMP1 + | sub BASE, BASE, TMP0 // Either keep top or shrink it. + | b <3 + | + |8: // Corner case: need to grow stack for filling up results. + | // This can happen if: + | // - A C function grows the stack (a lot). + | // - The GC shrinks the stack in between. + | // - A return back from a lua_call() with (high) nresults adjustment. + | stp BASE, L->top // Save current top held in BASE (yes). + | mr SAVE0, RD + | srwi CARG2, TMP2, 3 + | mr CARG1, L + | bl extern lj_state_growstack // (lua_State *L, int n) + | lwz TMP2, SAVE_NRES + | mr RD, SAVE0 + | slwi TMP2, TMP2, 3 + | lp BASE, L->top // Need the (realloced) L->top in BASE. + | b <2 + | + |->vm_unwind_c: // Unwind C stack, return from vm_pcall. + | // (void *cframe, int errcode) + | mr sp, CARG1 + | mr CRET1, CARG2 + |->vm_unwind_c_eh: // Landing pad for external unwinder. + | lwz L, SAVE_L + | .toc ld TOCREG, SAVE_TOC + | li TMP0, ~LJ_VMST_C + | lwz GL:TMP1, L->glref + | stw TMP0, GL:TMP1->vmstate + | b ->vm_leave_unw + | + |->vm_unwind_ff: // Unwind C stack, return from ff pcall. + | // (void *cframe) + |.if GPR64 + | rldicr sp, CARG1, 0, 61 + |.else + | rlwinm sp, CARG1, 0, 0, 29 + |.endif + |->vm_unwind_ff_eh: // Landing pad for external unwinder. + | lwz L, SAVE_L + | .toc ld TOCREG, SAVE_TOC + | li TISNUM, LJ_TISNUM // Setup type comparison constants. + | lp BASE, L->base + | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | li ZERO, 0 + | stw TMP3, TMPD + | li TMP1, LJ_TFALSE + | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). + | li TISNIL, LJ_TNIL + | li_vmstate INTERP + | lfs TOBIT, TMPD + | lwz PC, FRAME_PC(BASE) // Fetch PC of previous frame. + | la RA, -8(BASE) // Results start at BASE-8. + | stw TMP3, TMPD + | addi DISPATCH, DISPATCH, GG_G2DISP + | stw TMP1, 0(RA) // Prepend false to error message. + | li RD, 16 // 2 results: false + error message. + | st_vmstate + | lfs TONUM, TMPD + | b ->vm_returnc + | + |//----------------------------------------------------------------------- + |//-- Grow stack for calls ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_growstack_c: // Grow stack for C function. + | li CARG2, LUA_MINSTACK + | b >2 + | + |->vm_growstack_l: // Grow stack for Lua function. + | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC + | add RC, BASE, RC + | sub RA, RA, BASE + | stp BASE, L->base + | addi PC, PC, 4 // Must point after first instruction. + | stp RC, L->top + | srwi CARG2, RA, 3 + |2: + | // L->base = new base, L->top = top + | stw PC, SAVE_PC + | mr CARG1, L + | bl extern lj_state_growstack // (lua_State *L, int n) + | lp BASE, L->base + | lp RC, L->top + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | sub RC, RC, BASE + | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC + | ins_callt // Just retry the call. + | + |//----------------------------------------------------------------------- + |//-- Entry points into the assembler VM --------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_resume: // Setup C frame and resume thread. + | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) + | saveregs + | mr L, CARG1 + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | mr BASE, CARG2 + | lbz TMP1, L->status + | stw L, SAVE_L + | li PC, FRAME_CP + | addi TMP0, sp, CFRAME_RESUME + | addi DISPATCH, DISPATCH, GG_G2DISP + | stw CARG3, SAVE_NRES + | cmplwi TMP1, 0 + | stw CARG3, SAVE_ERRF + | stp TMP0, L->cframe + | stp CARG3, SAVE_CFRAME + | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | beq >3 + | + | // Resume after yield (like a return). + | mr RA, BASE + | lp BASE, L->base + | li TISNUM, LJ_TISNUM // Setup type comparison constants. + | lp TMP1, L->top + | lwz PC, FRAME_PC(BASE) + | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | stb CARG3, L->status + | stw TMP3, TMPD + | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). + | lfs TOBIT, TMPD + | sub RD, TMP1, BASE + | stw TMP3, TMPD + | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) + | addi RD, RD, 8 + | stw TMP0, TONUM_HI + | li_vmstate INTERP + | li ZERO, 0 + | st_vmstate + | andix. TMP0, PC, FRAME_TYPE + | mr MULTRES, RD + | lfs TONUM, TMPD + | li TISNIL, LJ_TNIL + | beq ->BC_RET_Z + | b ->vm_return + | + |->vm_pcall: // Setup protected C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) + | saveregs + | li PC, FRAME_CP + | stw CARG4, SAVE_ERRF + | b >1 + | + |->vm_call: // Setup C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1) + | saveregs + | li PC, FRAME_C + | + |1: // Entry point for vm_pcall above (PC = ftype). + | lp TMP1, L:CARG1->cframe + | stw CARG3, SAVE_NRES + | mr L, CARG1 + | stw CARG1, SAVE_L + | mr BASE, CARG2 + | stp sp, L->cframe // Add our C frame to cframe chain. + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | stp TMP1, SAVE_CFRAME + | addi DISPATCH, DISPATCH, GG_G2DISP + | + |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). + | lp TMP2, L->base // TMP2 = old base (used in vmeta_call). + | li TISNUM, LJ_TISNUM // Setup type comparison constants. + | lp TMP1, L->top + | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | add PC, PC, BASE + | stw TMP3, TMPD + | li ZERO, 0 + | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). + | lfs TOBIT, TMPD + | sub PC, PC, TMP2 // PC = frame delta + frame type + | stw TMP3, TMPD + | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) + | sub NARGS8:RC, TMP1, BASE + | stw TMP0, TONUM_HI + | li_vmstate INTERP + | lfs TONUM, TMPD + | li TISNIL, LJ_TNIL + | st_vmstate + | + |->vm_call_dispatch: + | // TMP2 = old base, BASE = new base, RC = nargs*8, PC = caller PC + | lwz TMP0, FRAME_PC(BASE) + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | checkfunc TMP0; bne ->vmeta_call + | + |->vm_call_dispatch_f: + | ins_call + | // BASE = new base, RB = func, RC = nargs*8, PC = caller PC + | + |->vm_cpcall: // Setup protected C frame, call C. + | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) + | saveregs + | mr L, CARG1 + | lwz TMP0, L:CARG1->stack + | stw CARG1, SAVE_L + | lp TMP1, L->top + | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | sub TMP0, TMP0, TMP1 // Compute -savestack(L, L->top). + | lp TMP1, L->cframe + | stp sp, L->cframe // Add our C frame to cframe chain. + | .toc lp CARG4, 0(CARG4) + | li TMP2, 0 + | stw TMP0, SAVE_NRES // Neg. delta means cframe w/o frame. + | stw TMP2, SAVE_ERRF // No error function. + | stp TMP1, SAVE_CFRAME + | mtctr CARG4 + | bctrl // (lua_State *L, lua_CFunction func, void *ud) + |.if PPE + | mr BASE, CRET1 + | cmpwi CRET1, 0 + |.else + | mr. BASE, CRET1 + |.endif + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | li PC, FRAME_CP + | addi DISPATCH, DISPATCH, GG_G2DISP + | bne <3 // Else continue with the call. + | b ->vm_leave_cp // No base? Just remove C frame. + | + |//----------------------------------------------------------------------- + |//-- Metamethod handling ------------------------------------------------ + |//----------------------------------------------------------------------- + | + |// The lj_meta_* functions (except for lj_meta_cat) don't reallocate the + |// stack, so BASE doesn't need to be reloaded across these calls. + | + |//-- Continuation dispatch ---------------------------------------------- + | + |->cont_dispatch: + | // BASE = meta base, RA = resultptr, RD = (nresults+1)*8 + | lwz TMP0, -12(BASE) // Continuation. + | mr RB, BASE + | mr BASE, TMP2 // Restore caller BASE. + | lwz LFUNC:TMP1, FRAME_FUNC(TMP2) + |.if FFI + | cmplwi TMP0, 1 + |.endif + | lwz PC, -16(RB) // Restore PC from [cont|PC]. + | subi TMP2, RD, 8 + | lwz TMP1, LFUNC:TMP1->pc + | stwx TISNIL, RA, TMP2 // Ensure one valid arg. + |.if FFI + | ble >1 + |.endif + | lwz KBASE, PC2PROTO(k)(TMP1) + | // BASE = base, RA = resultptr, RB = meta base + | mtctr TMP0 + | bctr // Jump to continuation. + | + |.if FFI + |1: + | beq ->cont_ffi_callback // cont = 1: return from FFI callback. + | // cont = 0: tailcall from C function. + | subi TMP1, RB, 16 + | sub RC, TMP1, BASE + | b ->vm_call_tail + |.endif + | + |->cont_cat: // RA = resultptr, RB = meta base + | lwz INS, -4(PC) + | subi CARG2, RB, 16 + | decode_RB8 SAVE0, INS + | lfd f0, 0(RA) + | add TMP1, BASE, SAVE0 + | stp BASE, L->base + | cmplw TMP1, CARG2 + | sub CARG3, CARG2, TMP1 + | decode_RA8 RA, INS + | stfd f0, 0(CARG2) + | bney ->BC_CAT_Z + | stfdx f0, BASE, RA + | b ->cont_nop + | + |//-- Table indexing metamethods ----------------------------------------- + | + |->vmeta_tgets1: + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | li TMP0, LJ_TSTR + | decode_RB8 RB, INS + | stw STR:RC, 4(CARG3) + | add CARG2, BASE, RB + | stw TMP0, 0(CARG3) + | b >1 + | + |->vmeta_tgets: + | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) + | li TMP0, LJ_TTAB + | stw TAB:RB, 4(CARG2) + | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) + | stw TMP0, 0(CARG2) + | li TMP1, LJ_TSTR + | stw STR:RC, 4(CARG3) + | stw TMP1, 0(CARG3) + | b >1 + | + |->vmeta_tgetb: // TMP0 = index + |.if not DUALNUM + | tonum_u f0, TMP0 + |.endif + | decode_RB8 RB, INS + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | add CARG2, BASE, RB + |.if DUALNUM + | stw TISNUM, 0(CARG3) + | stw TMP0, 4(CARG3) + |.else + | stfd f0, 0(CARG3) + |.endif + | b >1 + | + |->vmeta_tgetv: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | add CARG2, BASE, RB + | add CARG3, BASE, RC + |1: + | stp BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) + | // Returns TValue * (finished) or NULL (metamethod). + | cmplwi CRET1, 0 + | beq >3 + | lfd f0, 0(CRET1) + | ins_next1 + | stfdx f0, BASE, RA + | ins_next2 + | + |3: // Call __index metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k + | subfic TMP1, BASE, FRAME_CONT + | lp BASE, L->top + | stw PC, -16(BASE) // [cont|PC] + | add PC, TMP1, BASE + | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | li NARGS8:RC, 16 // 2 args for func(t, k). + | b ->vm_call_dispatch_f + | + |//----------------------------------------------------------------------- + | + |->vmeta_tsets1: + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | li TMP0, LJ_TSTR + | decode_RB8 RB, INS + | stw STR:RC, 4(CARG3) + | add CARG2, BASE, RB + | stw TMP0, 0(CARG3) + | b >1 + | + |->vmeta_tsets: + | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) + | li TMP0, LJ_TTAB + | stw TAB:RB, 4(CARG2) + | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) + | stw TMP0, 0(CARG2) + | li TMP1, LJ_TSTR + | stw STR:RC, 4(CARG3) + | stw TMP1, 0(CARG3) + | b >1 + | + |->vmeta_tsetb: // TMP0 = index + |.if not DUALNUM + | tonum_u f0, TMP0 + |.endif + | decode_RB8 RB, INS + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | add CARG2, BASE, RB + |.if DUALNUM + | stw TISNUM, 0(CARG3) + | stw TMP0, 4(CARG3) + |.else + | stfd f0, 0(CARG3) + |.endif + | b >1 + | + |->vmeta_tsetv: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | add CARG2, BASE, RB + | add CARG3, BASE, RC + |1: + | stp BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) + | // Returns TValue * (finished) or NULL (metamethod). + | cmplwi CRET1, 0 + | lfdx f0, BASE, RA + | beq >3 + | // NOBARRIER: lj_meta_tset ensures the table is not black. + | ins_next1 + | stfd f0, 0(CRET1) + | ins_next2 + | + |3: // Call __newindex metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) + | subfic TMP1, BASE, FRAME_CONT + | lp BASE, L->top + | stw PC, -16(BASE) // [cont|PC] + | add PC, TMP1, BASE + | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | li NARGS8:RC, 24 // 3 args for func(t, k, v) + | stfd f0, 16(BASE) // Copy value to third argument. + | b ->vm_call_dispatch_f + | + |//-- Comparison metamethods --------------------------------------------- + | + |->vmeta_comp: + | mr CARG1, L + | subi PC, PC, 4 + |.if DUALNUM + | mr CARG2, RA + |.else + | add CARG2, BASE, RA + |.endif + | stw PC, SAVE_PC + |.if DUALNUM + | mr CARG3, RD + |.else + | add CARG3, BASE, RD + |.endif + | stp BASE, L->base + | decode_OP1 CARG4, INS + | bl extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) + | // Returns 0/1 or TValue * (metamethod). + |3: + | cmplwi CRET1, 1 + | bgt ->vmeta_binop + | subfic CRET1, CRET1, 0 + |4: + | lwz INS, 0(PC) + | addi PC, PC, 4 + | decode_RD4 TMP2, INS + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + | and TMP2, TMP2, CRET1 + | add PC, PC, TMP2 + |->cont_nop: + | ins_next + | + |->cont_ra: // RA = resultptr + | lwz INS, -4(PC) + | lfd f0, 0(RA) + | decode_RA8 TMP1, INS + | stfdx f0, BASE, TMP1 + | b ->cont_nop + | + |->cont_condt: // RA = resultptr + | lwz TMP0, 0(RA) + | .gpr64 extsw TMP0, TMP0 + | subfic TMP0, TMP0, LJ_TTRUE // Branch if result is true. + | subfe CRET1, CRET1, CRET1 + | not CRET1, CRET1 + | b <4 + | + |->cont_condf: // RA = resultptr + | lwz TMP0, 0(RA) + | .gpr64 extsw TMP0, TMP0 + | subfic TMP0, TMP0, LJ_TTRUE // Branch if result is false. + | subfe CRET1, CRET1, CRET1 + | b <4 + | + |->vmeta_equal: + | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. + | subi PC, PC, 4 + | stp BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) + | // Returns 0/1 or TValue * (metamethod). + | b <3 + | + |->vmeta_equal_cd: + |.if FFI + | mr CARG2, INS + | subi PC, PC, 4 + | stp BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_equal_cd // (lua_State *L, BCIns op) + | // Returns 0/1 or TValue * (metamethod). + | b <3 + |.endif + | + |//-- Arithmetic metamethods --------------------------------------------- + | + |->vmeta_arith_nv: + | add CARG3, KBASE, RC + | add CARG4, BASE, RB + | b >1 + |->vmeta_arith_nv2: + |.if DUALNUM + | mr CARG3, RC + | mr CARG4, RB + | b >1 + |.endif + | + |->vmeta_unm: + | mr CARG3, RD + | mr CARG4, RD + | b >1 + | + |->vmeta_arith_vn: + | add CARG3, BASE, RB + | add CARG4, KBASE, RC + | b >1 + | + |->vmeta_arith_vv: + | add CARG3, BASE, RB + | add CARG4, BASE, RC + |.if DUALNUM + | b >1 + |.endif + |->vmeta_arith_vn2: + |->vmeta_arith_vv2: + |.if DUALNUM + | mr CARG3, RB + | mr CARG4, RC + |.endif + |1: + | add CARG2, BASE, RA + | stp BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | decode_OP1 CARG5, INS // Caveat: CARG5 overlaps INS. + | bl extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) + | // Returns NULL (finished) or TValue * (metamethod). + | cmplwi CRET1, 0 + | beq ->cont_nop + | + | // Call metamethod for binary op. + |->vmeta_binop: + | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 + | sub TMP1, CRET1, BASE + | stw PC, -16(CRET1) // [cont|PC] + | mr TMP2, BASE + | addi PC, TMP1, FRAME_CONT + | mr BASE, CRET1 + | li NARGS8:RC, 16 // 2 args for func(o1, o2). + | b ->vm_call_dispatch + | + |->vmeta_len: +#if LJ_52 + | mr SAVE0, CARG1 +#endif + | mr CARG2, RD + | stp BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_len // (lua_State *L, TValue *o) + | // Returns NULL (retry) or TValue * (metamethod base). +#if LJ_52 + | cmplwi CRET1, 0 + | bne ->vmeta_binop // Binop call for compatibility. + | mr CARG1, SAVE0 + | b ->BC_LEN_Z +#else + | b ->vmeta_binop // Binop call for compatibility. +#endif + | + |//-- Call metamethod ---------------------------------------------------- + | + |->vmeta_call: // Resolve and call __call metamethod. + | // TMP2 = old base, BASE = new base, RC = nargs*8 + | mr CARG1, L + | stp TMP2, L->base // This is the callers base! + | subi CARG2, BASE, 8 + | stw PC, SAVE_PC + | add CARG3, BASE, RC + | mr SAVE0, NARGS8:RC + | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. + | ins_call + | + |->vmeta_callt: // Resolve __call for BC_CALLT. + | // BASE = old base, RA = new base, RC = nargs*8 + | mr CARG1, L + | stp BASE, L->base + | subi CARG2, RA, 8 + | stw PC, SAVE_PC + | add CARG3, RA, RC + | mr SAVE0, NARGS8:RC + | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + | lwz TMP1, FRAME_PC(BASE) + | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. + | lwz LFUNC:RB, FRAME_FUNC(RA) // Guaranteed to be a function here. + | b ->BC_CALLT_Z + | + |//-- Argument coercion for 'for' statement ------------------------------ + | + |->vmeta_for: + | mr CARG1, L + | stp BASE, L->base + | mr CARG2, RA + | stw PC, SAVE_PC + | mr SAVE0, INS + | bl extern lj_meta_for // (lua_State *L, TValue *base) + |.if JIT + | decode_OP1 TMP0, SAVE0 + |.endif + | decode_RA8 RA, SAVE0 + |.if JIT + | cmpwi TMP0, BC_JFORI + |.endif + | decode_RD8 RD, SAVE0 + |.if JIT + | beqy =>BC_JFORI + |.endif + | b =>BC_FORI + | + |//----------------------------------------------------------------------- + |//-- Fast functions ----------------------------------------------------- + |//----------------------------------------------------------------------- + | + |.macro .ffunc, name + |->ff_ .. name: + |.endmacro + | + |.macro .ffunc_1, name + |->ff_ .. name: + | cmplwi NARGS8:RC, 8 + | lwz CARG3, 0(BASE) + | lwz CARG1, 4(BASE) + | blt ->fff_fallback + |.endmacro + | + |.macro .ffunc_2, name + |->ff_ .. name: + | cmplwi NARGS8:RC, 16 + | lwz CARG3, 0(BASE) + | lwz CARG4, 8(BASE) + | lwz CARG1, 4(BASE) + | lwz CARG2, 12(BASE) + | blt ->fff_fallback + |.endmacro + | + |.macro .ffunc_n, name + |->ff_ .. name: + | cmplwi NARGS8:RC, 8 + | lwz CARG3, 0(BASE) + | lfd FARG1, 0(BASE) + | blt ->fff_fallback + | checknum CARG3; bge ->fff_fallback + |.endmacro + | + |.macro .ffunc_nn, name + |->ff_ .. name: + | cmplwi NARGS8:RC, 16 + | lwz CARG3, 0(BASE) + | lfd FARG1, 0(BASE) + | lwz CARG4, 8(BASE) + | lfd FARG2, 8(BASE) + | blt ->fff_fallback + | checknum CARG3; bge ->fff_fallback + | checknum CARG4; bge ->fff_fallback + |.endmacro + | + |// Inlined GC threshold check. Caveat: uses TMP0 and TMP1. + |.macro ffgccheck + | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) + | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) + | cmplw TMP0, TMP1 + | bgel ->fff_gcstep + |.endmacro + | + |//-- Base library: checks ----------------------------------------------- + | + |.ffunc_1 assert + | li TMP1, LJ_TFALSE + | la RA, -8(BASE) + | cmplw cr1, CARG3, TMP1 + | lwz PC, FRAME_PC(BASE) + | bge cr1, ->fff_fallback + | stw CARG3, 0(RA) + | addi RD, NARGS8:RC, 8 // Compute (nresults+1)*8. + | stw CARG1, 4(RA) + | beq ->fff_res // Done if exactly 1 argument. + | li TMP1, 8 + | subi RC, RC, 8 + |1: + | cmplw TMP1, RC + | lfdx f0, BASE, TMP1 + | stfdx f0, RA, TMP1 + | addi TMP1, TMP1, 8 + | bney <1 + | b ->fff_res + | + |.ffunc type + | cmplwi NARGS8:RC, 8 + | lwz CARG1, 0(BASE) + | blt ->fff_fallback + | .gpr64 extsw CARG1, CARG1 + | subfc TMP0, TISNUM, CARG1 + | subfe TMP2, CARG1, CARG1 + | orc TMP1, TMP2, TMP0 + | addi TMP1, TMP1, ~LJ_TISNUM+1 + | slwi TMP1, TMP1, 3 + | la TMP2, CFUNC:RB->upvalue + | lfdx FARG1, TMP2, TMP1 + | b ->fff_resn + | + |//-- Base library: getters and setters --------------------------------- + | + |.ffunc_1 getmetatable + | checktab CARG3; bne >6 + |1: // Field metatable must be at same offset for GCtab and GCudata! + | lwz TAB:CARG1, TAB:CARG1->metatable + |2: + | li CARG3, LJ_TNIL + | cmplwi TAB:CARG1, 0 + | lwz STR:RC, DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])(DISPATCH) + | beq ->fff_restv + | lwz TMP0, TAB:CARG1->hmask + | li CARG3, LJ_TTAB // Use metatable as default result. + | lwz TMP1, STR:RC->hash + | lwz NODE:TMP2, TAB:CARG1->node + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | slwi TMP0, TMP1, 5 + | slwi TMP1, TMP1, 3 + | sub TMP1, TMP0, TMP1 + | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + |3: // Rearranged logic, because we expect _not_ to find the key. + | lwz CARG4, NODE:TMP2->key + | lwz TMP0, 4+offsetof(Node, key)(NODE:TMP2) + | lwz CARG2, NODE:TMP2->val + | lwz TMP1, 4+offsetof(Node, val)(NODE:TMP2) + | checkstr CARG4; bne >4 + | cmpw TMP0, STR:RC; beq >5 + |4: + | lwz NODE:TMP2, NODE:TMP2->next + | cmplwi NODE:TMP2, 0 + | beq ->fff_restv // Not found, keep default result. + | b <3 + |5: + | checknil CARG2 + | beq ->fff_restv // Ditto for nil value. + | mr CARG3, CARG2 // Return value of mt.__metatable. + | mr CARG1, TMP1 + | b ->fff_restv + | + |6: + | cmpwi CARG3, LJ_TUDATA; beq <1 + | .gpr64 extsw CARG3, CARG3 + | subfc TMP0, TISNUM, CARG3 + | subfe TMP2, CARG3, CARG3 + | orc TMP1, TMP2, TMP0 + | addi TMP1, TMP1, ~LJ_TISNUM+1 + | slwi TMP1, TMP1, 2 + | la TMP2, DISPATCH_GL(gcroot[GCROOT_BASEMT])(DISPATCH) + | lwzx TAB:CARG1, TMP2, TMP1 + | b <2 + | + |.ffunc_2 setmetatable + | // Fast path: no mt for table yet and not clearing the mt. + | checktab CARG3; bne ->fff_fallback + | lwz TAB:TMP1, TAB:CARG1->metatable + | checktab CARG4; bne ->fff_fallback + | cmplwi TAB:TMP1, 0 + | lbz TMP3, TAB:CARG1->marked + | bne ->fff_fallback + | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + | stw TAB:CARG2, TAB:CARG1->metatable + | beq ->fff_restv + | barrierback TAB:CARG1, TMP3, TMP0 + | b ->fff_restv + | + |.ffunc rawget + | cmplwi NARGS8:RC, 16 + | lwz CARG4, 0(BASE) + | lwz TAB:CARG2, 4(BASE) + | blt ->fff_fallback + | checktab CARG4; bne ->fff_fallback + | la CARG3, 8(BASE) + | mr CARG1, L + | bl extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) + | // Returns cTValue *. + | lfd FARG1, 0(CRET1) + | b ->fff_resn + | + |//-- Base library: conversions ------------------------------------------ + | + |.ffunc tonumber + | // Only handles the number case inline (without a base argument). + | cmplwi NARGS8:RC, 8 + | lwz CARG1, 0(BASE) + | lfd FARG1, 0(BASE) + | bne ->fff_fallback // Exactly one argument. + | checknum CARG1; bgt ->fff_fallback + | b ->fff_resn + | + |.ffunc_1 tostring + | // Only handles the string or number case inline. + | checkstr CARG3 + | // A __tostring method in the string base metatable is ignored. + | beq ->fff_restv // String key? + | // Handle numbers inline, unless a number base metatable is present. + | lwz TMP0, DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])(DISPATCH) + | checknum CARG3 + | cmplwi cr1, TMP0, 0 + | stp BASE, L->base // Add frame since C call can throw. + | crorc 4*cr0+eq, 4*cr0+gt, 4*cr1+eq + | stw PC, SAVE_PC // Redundant (but a defined value). + | beq ->fff_fallback + | ffgccheck + | mr CARG1, L + | mr CARG2, BASE + |.if DUALNUM + | bl extern lj_str_fromnumber // (lua_State *L, cTValue *o) + |.else + | bl extern lj_str_fromnum // (lua_State *L, lua_Number *np) + |.endif + | // Returns GCstr *. + | li CARG3, LJ_TSTR + | b ->fff_restv + | + |//-- Base library: iterators ------------------------------------------- + | + |.ffunc next + | cmplwi NARGS8:RC, 8 + | lwz CARG1, 0(BASE) + | lwz TAB:CARG2, 4(BASE) + | blt ->fff_fallback + | stwx TISNIL, BASE, NARGS8:RC // Set missing 2nd arg to nil. + | checktab CARG1 + | lwz PC, FRAME_PC(BASE) + | bne ->fff_fallback + | stp BASE, L->base // Add frame since C call can throw. + | mr CARG1, L + | stp BASE, L->top // Dummy frame length is ok. + | la CARG3, 8(BASE) + | stw PC, SAVE_PC + | bl extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) + | // Returns 0 at end of traversal. + | cmplwi CRET1, 0 + | li CARG3, LJ_TNIL + | beq ->fff_restv // End of traversal: return nil. + | lfd f0, 8(BASE) // Copy key and value to results. + | la RA, -8(BASE) + | lfd f1, 16(BASE) + | stfd f0, 0(RA) + | li RD, (2+1)*8 + | stfd f1, 8(RA) + | b ->fff_res + | + |.ffunc_1 pairs + | checktab CARG3 + | lwz PC, FRAME_PC(BASE) + | bne ->fff_fallback +#if LJ_52 + | lwz TAB:TMP2, TAB:CARG1->metatable + | lfd f0, CFUNC:RB->upvalue[0] + | cmplwi TAB:TMP2, 0 + | la RA, -8(BASE) + | bne ->fff_fallback +#else + | lfd f0, CFUNC:RB->upvalue[0] + | la RA, -8(BASE) +#endif + | stw TISNIL, 8(BASE) + | li RD, (3+1)*8 + | stfd f0, 0(RA) + | b ->fff_res + | + |.ffunc ipairs_aux + | cmplwi NARGS8:RC, 16 + | lwz CARG3, 0(BASE) + | lwz TAB:CARG1, 4(BASE) + | lwz CARG4, 8(BASE) + |.if DUALNUM + | lwz TMP2, 12(BASE) + |.else + | lfd FARG2, 8(BASE) + |.endif + | blt ->fff_fallback + | checktab CARG3 + | checknum cr1, CARG4 + | lwz PC, FRAME_PC(BASE) + |.if DUALNUM + | bne ->fff_fallback + | bne cr1, ->fff_fallback + |.else + | lus TMP0, 0x3ff0 + | stw ZERO, TMPD_LO + | bne ->fff_fallback + | stw TMP0, TMPD_HI + | bge cr1, ->fff_fallback + | lfd FARG1, TMPD + | toint TMP2, FARG2, f0 + |.endif + | lwz TMP0, TAB:CARG1->asize + | lwz TMP1, TAB:CARG1->array + |.if not DUALNUM + | fadd FARG2, FARG2, FARG1 + |.endif + | addi TMP2, TMP2, 1 + | la RA, -8(BASE) + | cmplw TMP0, TMP2 + |.if DUALNUM + | stw TISNUM, 0(RA) + | slwi TMP3, TMP2, 3 + | stw TMP2, 4(RA) + |.else + | slwi TMP3, TMP2, 3 + | stfd FARG2, 0(RA) + |.endif + | ble >2 // Not in array part? + | lwzx TMP2, TMP1, TMP3 + | lfdx f0, TMP1, TMP3 + |1: + | checknil TMP2 + | li RD, (0+1)*8 + | beq ->fff_res // End of iteration, return 0 results. + | li RD, (2+1)*8 + | stfd f0, 8(RA) + | b ->fff_res + |2: // Check for empty hash part first. Otherwise call C function. + | lwz TMP0, TAB:CARG1->hmask + | cmplwi TMP0, 0 + | li RD, (0+1)*8 + | beq ->fff_res + | mr CARG2, TMP2 + | bl extern lj_tab_getinth // (GCtab *t, int32_t key) + | // Returns cTValue * or NULL. + | cmplwi CRET1, 0 + | li RD, (0+1)*8 + | beq ->fff_res + | lwz TMP2, 0(CRET1) + | lfd f0, 0(CRET1) + | b <1 + | + |.ffunc_1 ipairs + | checktab CARG3 + | lwz PC, FRAME_PC(BASE) + | bne ->fff_fallback +#if LJ_52 + | lwz TAB:TMP2, TAB:CARG1->metatable + | lfd f0, CFUNC:RB->upvalue[0] + | cmplwi TAB:TMP2, 0 + | la RA, -8(BASE) + | bne ->fff_fallback +#else + | lfd f0, CFUNC:RB->upvalue[0] + | la RA, -8(BASE) +#endif + |.if DUALNUM + | stw TISNUM, 8(BASE) + |.else + | stw ZERO, 8(BASE) + |.endif + | stw ZERO, 12(BASE) + | li RD, (3+1)*8 + | stfd f0, 0(RA) + | b ->fff_res + | + |//-- Base library: catch errors ---------------------------------------- + | + |.ffunc pcall + | cmplwi NARGS8:RC, 8 + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | blt ->fff_fallback + | mr TMP2, BASE + | la BASE, 8(BASE) + | // Remember active hook before pcall. + | rlwinm TMP3, TMP3, 32-HOOK_ACTIVE_SHIFT, 31, 31 + | subi NARGS8:RC, NARGS8:RC, 8 + | addi PC, TMP3, 8+FRAME_PCALL + | b ->vm_call_dispatch + | + |.ffunc xpcall + | cmplwi NARGS8:RC, 16 + | lwz CARG4, 8(BASE) + | lfd FARG2, 8(BASE) + | lfd FARG1, 0(BASE) + | blt ->fff_fallback + | lbz TMP1, DISPATCH_GL(hookmask)(DISPATCH) + | mr TMP2, BASE + | checkfunc CARG4; bne ->fff_fallback // Traceback must be a function. + | la BASE, 16(BASE) + | // Remember active hook before pcall. + | rlwinm TMP1, TMP1, 32-HOOK_ACTIVE_SHIFT, 31, 31 + | stfd FARG2, 0(TMP2) // Swap function and traceback. + | subi NARGS8:RC, NARGS8:RC, 16 + | stfd FARG1, 8(TMP2) + | addi PC, TMP1, 16+FRAME_PCALL + | b ->vm_call_dispatch + | + |//-- Coroutine library -------------------------------------------------- + | + |.macro coroutine_resume_wrap, resume + |.if resume + |.ffunc_1 coroutine_resume + | cmpwi CARG3, LJ_TTHREAD; bne ->fff_fallback + |.else + |.ffunc coroutine_wrap_aux + | lwz L:CARG1, CFUNC:RB->upvalue[0].gcr + |.endif + | lbz TMP0, L:CARG1->status + | lp TMP1, L:CARG1->cframe + | lp CARG2, L:CARG1->top + | cmplwi cr0, TMP0, LUA_YIELD + | lp TMP2, L:CARG1->base + | cmplwi cr1, TMP1, 0 + | lwz TMP0, L:CARG1->maxstack + | cmplw cr7, CARG2, TMP2 + | lwz PC, FRAME_PC(BASE) + | crorc 4*cr6+lt, 4*cr0+gt, 4*cr1+eq // st>LUA_YIELD || cframe!=0 + | add TMP2, CARG2, NARGS8:RC + | crandc 4*cr6+gt, 4*cr7+eq, 4*cr0+eq // base==top && st!=LUA_YIELD + | cmplw cr1, TMP2, TMP0 + | cror 4*cr6+lt, 4*cr6+lt, 4*cr6+gt + | stw PC, SAVE_PC + | cror 4*cr6+lt, 4*cr6+lt, 4*cr1+gt // cond1 || cond2 || stackov + | stp BASE, L->base + | blt cr6, ->fff_fallback + |1: + |.if resume + | addi BASE, BASE, 8 // Keep resumed thread in stack for GC. + | subi NARGS8:RC, NARGS8:RC, 8 + | subi TMP2, TMP2, 8 + |.endif + | stp TMP2, L:CARG1->top + | li TMP1, 0 + | stp BASE, L->top + |2: // Move args to coroutine. + | cmpw TMP1, NARGS8:RC + | lfdx f0, BASE, TMP1 + | beq >3 + | stfdx f0, CARG2, TMP1 + | addi TMP1, TMP1, 8 + | b <2 + |3: + | li CARG3, 0 + | mr L:SAVE0, L:CARG1 + | li CARG4, 0 + | bl ->vm_resume // (lua_State *L, TValue *base, 0, 0) + | // Returns thread status. + |4: + | lp TMP2, L:SAVE0->base + | cmplwi CRET1, LUA_YIELD + | lp TMP3, L:SAVE0->top + | li_vmstate INTERP + | lp BASE, L->base + | st_vmstate + | bgt >8 + | sub RD, TMP3, TMP2 + | lwz TMP0, L->maxstack + | cmplwi RD, 0 + | add TMP1, BASE, RD + | beq >6 // No results? + | cmplw TMP1, TMP0 + | li TMP1, 0 + | bgt >9 // Need to grow stack? + | + | subi TMP3, RD, 8 + | stp TMP2, L:SAVE0->top // Clear coroutine stack. + |5: // Move results from coroutine. + | cmplw TMP1, TMP3 + | lfdx f0, TMP2, TMP1 + | stfdx f0, BASE, TMP1 + | addi TMP1, TMP1, 8 + | bne <5 + |6: + | andix. TMP0, PC, FRAME_TYPE + |.if resume + | li TMP1, LJ_TTRUE + | la RA, -8(BASE) + | stw TMP1, -8(BASE) // Prepend true to results. + | addi RD, RD, 16 + |.else + | mr RA, BASE + | addi RD, RD, 8 + |.endif + |7: + | stw PC, SAVE_PC + | mr MULTRES, RD + | beq ->BC_RET_Z + | b ->vm_return + | + |8: // Coroutine returned with error (at co->top-1). + |.if resume + | andix. TMP0, PC, FRAME_TYPE + | la TMP3, -8(TMP3) + | li TMP1, LJ_TFALSE + | lfd f0, 0(TMP3) + | stp TMP3, L:SAVE0->top // Remove error from coroutine stack. + | li RD, (2+1)*8 + | stw TMP1, -8(BASE) // Prepend false to results. + | la RA, -8(BASE) + | stfd f0, 0(BASE) // Copy error message. + | b <7 + |.else + | mr CARG1, L + | mr CARG2, L:SAVE0 + | bl extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) + |.endif + | + |9: // Handle stack expansion on return from yield. + | mr CARG1, L + | srwi CARG2, RD, 3 + | bl extern lj_state_growstack // (lua_State *L, int n) + | li CRET1, 0 + | b <4 + |.endmacro + | + | coroutine_resume_wrap 1 // coroutine.resume + | coroutine_resume_wrap 0 // coroutine.wrap + | + |.ffunc coroutine_yield + | lp TMP0, L->cframe + | add TMP1, BASE, NARGS8:RC + | stp BASE, L->base + | andix. TMP0, TMP0, CFRAME_RESUME + | stp TMP1, L->top + | li CRET1, LUA_YIELD + | beq ->fff_fallback + | stp ZERO, L->cframe + | stb CRET1, L->status + | b ->vm_leave_unw + | + |//-- Math library ------------------------------------------------------- + | + |.ffunc_1 math_abs + | checknum CARG3 + |.if DUALNUM + | bne >2 + | srawi TMP1, CARG1, 31 + | xor TMP2, TMP1, CARG1 + |.if GPR64 + | lus TMP0, 0x8000 + | sub CARG1, TMP2, TMP1 + | cmplw CARG1, TMP0 + | beq >1 + |.else + | sub. CARG1, TMP2, TMP1 + | blt >1 + |.endif + |->fff_resi: + | lwz PC, FRAME_PC(BASE) + | la RA, -8(BASE) + | stw TISNUM, -8(BASE) + | stw CRET1, -4(BASE) + | b ->fff_res1 + |1: + | lus CARG3, 0x41e0 // 2^31. + | li CARG1, 0 + | b ->fff_restv + |2: + |.endif + | bge ->fff_fallback + | rlwinm CARG3, CARG3, 0, 1, 31 + | // Fallthrough. + | + |->fff_restv: + | // CARG3/CARG1 = TValue result. + | lwz PC, FRAME_PC(BASE) + | stw CARG3, -8(BASE) + | la RA, -8(BASE) + | stw CARG1, -4(BASE) + |->fff_res1: + | // RA = results, PC = return. + | li RD, (1+1)*8 + |->fff_res: + | // RA = results, RD = (nresults+1)*8, PC = return. + | andix. TMP0, PC, FRAME_TYPE + | mr MULTRES, RD + | bney ->vm_return + | lwz INS, -4(PC) + | decode_RB8 RB, INS + |5: + | cmplw RB, RD // More results expected? + | decode_RA8 TMP0, INS + | bgt >6 + | ins_next1 + | // Adjust BASE. KBASE is assumed to be set for the calling frame. + | sub BASE, RA, TMP0 + | ins_next2 + | + |6: // Fill up results with nil. + | subi TMP1, RD, 8 + | addi RD, RD, 8 + | stwx TISNIL, RA, TMP1 + | b <5 + | + |.macro math_extern, func + | .ffunc_n math_ .. func + | blex func + | b ->fff_resn + |.endmacro + | + |.macro math_extern2, func + | .ffunc_nn math_ .. func + | blex func + | b ->fff_resn + |.endmacro + | + |.macro math_round, func + | .ffunc_1 math_ .. func + | checknum CARG3; beqy ->fff_restv + | rlwinm TMP2, CARG3, 12, 21, 31 + | bge ->fff_fallback + | addic. TMP2, TMP2, -1023 // exp = exponent(x) - 1023 + | cmplwi cr1, TMP2, 31 // 0 <= exp < 31? + | subfic TMP0, TMP2, 31 + | blt >3 + | slwi TMP1, CARG3, 11 + | srwi TMP3, CARG1, 21 + | oris TMP1, TMP1, 0x8000 + | addi TMP2, TMP2, 1 + | or TMP1, TMP1, TMP3 + | slwi CARG2, CARG1, 11 + | bge cr1, >4 + | slw TMP3, TMP1, TMP2 + | srw RD, TMP1, TMP0 + | or TMP3, TMP3, CARG2 + | srawi TMP2, CARG3, 31 + |.if "func" == "floor" + | and TMP1, TMP3, TMP2 + | addic TMP0, TMP1, -1 + | subfe TMP1, TMP0, TMP1 + | add CARG1, RD, TMP1 + | xor CARG1, CARG1, TMP2 + | sub CARG1, CARG1, TMP2 + | b ->fff_resi + |.else + | andc TMP1, TMP3, TMP2 + | addic TMP0, TMP1, -1 + | subfe TMP1, TMP0, TMP1 + | add CARG1, RD, TMP1 + | cmpw CARG1, RD + | xor CARG1, CARG1, TMP2 + | sub CARG1, CARG1, TMP2 + | bge ->fff_resi + | // Overflow to 2^31. + | lus CARG3, 0x41e0 // 2^31. + | li CARG1, 0 + | b ->fff_restv + |.endif + |3: // |x| < 1 + | slwi TMP2, CARG3, 1 + | srawi TMP1, CARG3, 31 + | or TMP2, CARG1, TMP2 // ztest = (hi+hi) | lo + |.if "func" == "floor" + | and TMP1, TMP2, TMP1 // (ztest & sign) == 0 ? 0 : -1 + | subfic TMP2, TMP1, 0 + | subfe CARG1, CARG1, CARG1 + |.else + | andc TMP1, TMP2, TMP1 // (ztest & ~sign) == 0 ? 0 : 1 + | addic TMP2, TMP1, -1 + | subfe CARG1, TMP2, TMP1 + |.endif + | b ->fff_resi + |4: // exp >= 31. Check for -(2^31). + | xoris TMP1, TMP1, 0x8000 + | srawi TMP2, CARG3, 31 + |.if "func" == "floor" + | or TMP1, TMP1, CARG2 + |.endif + |.if PPE + | orc TMP1, TMP1, TMP2 + | cmpwi TMP1, 0 + |.else + | orc. TMP1, TMP1, TMP2 + |.endif + | crand 4*cr0+eq, 4*cr0+eq, 4*cr1+eq + | lus CARG1, 0x8000 // -(2^31). + | beqy ->fff_resi + |5: + | lfd FARG1, 0(BASE) + | blex func + | b ->fff_resn + |.endmacro + | + |.if DUALNUM + | math_round floor + | math_round ceil + |.else + | // NYI: use internal implementation. + | math_extern floor + | math_extern ceil + |.endif + | + |.if SQRT + |.ffunc_n math_sqrt + | fsqrt FARG1, FARG1 + | b ->fff_resn + |.else + | math_extern sqrt + |.endif + | + |.ffunc math_log + | cmplwi NARGS8:RC, 8 + | lwz CARG3, 0(BASE) + | lfd FARG1, 0(BASE) + | bne ->fff_fallback // Need exactly 1 argument. + | checknum CARG3; bge ->fff_fallback + | blex log + | b ->fff_resn + | + | math_extern log10 + | math_extern exp + | math_extern sin + | math_extern cos + | math_extern tan + | math_extern asin + | math_extern acos + | math_extern atan + | math_extern sinh + | math_extern cosh + | math_extern tanh + | math_extern2 pow + | math_extern2 atan2 + | math_extern2 fmod + | + |->ff_math_deg: + |.ffunc_n math_rad + | lfd FARG2, CFUNC:RB->upvalue[0] + | fmul FARG1, FARG1, FARG2 + | b ->fff_resn + | + |.if DUALNUM + |.ffunc math_ldexp + | cmplwi NARGS8:RC, 16 + | lwz CARG3, 0(BASE) + | lfd FARG1, 0(BASE) + | lwz CARG4, 8(BASE) + |.if GPR64 + | lwz CARG2, 12(BASE) + |.else + | lwz CARG1, 12(BASE) + |.endif + | blt ->fff_fallback + | checknum CARG3; bge ->fff_fallback + | checknum CARG4; bne ->fff_fallback + |.else + |.ffunc_nn math_ldexp + |.if GPR64 + | toint CARG2, FARG2 + |.else + | toint CARG1, FARG2 + |.endif + |.endif + | blex ldexp + | b ->fff_resn + | + |.ffunc_n math_frexp + |.if GPR64 + | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) + |.else + | la CARG1, DISPATCH_GL(tmptv)(DISPATCH) + |.endif + | lwz PC, FRAME_PC(BASE) + | blex frexp + | lwz TMP1, DISPATCH_GL(tmptv)(DISPATCH) + | la RA, -8(BASE) + |.if not DUALNUM + | tonum_i FARG2, TMP1 + |.endif + | stfd FARG1, 0(RA) + | li RD, (2+1)*8 + |.if DUALNUM + | stw TISNUM, 8(RA) + | stw TMP1, 12(RA) + |.else + | stfd FARG2, 8(RA) + |.endif + | b ->fff_res + | + |.ffunc_n math_modf + |.if GPR64 + | la CARG2, -8(BASE) + |.else + | la CARG1, -8(BASE) + |.endif + | lwz PC, FRAME_PC(BASE) + | blex modf + | la RA, -8(BASE) + | stfd FARG1, 0(BASE) + | li RD, (2+1)*8 + | b ->fff_res + | + |.macro math_minmax, name, ismax + |.if DUALNUM + | .ffunc_1 name + | checknum CARG3 + | addi TMP1, BASE, 8 + | add TMP2, BASE, NARGS8:RC + | bne >4 + |1: // Handle integers. + | lwz CARG4, 0(TMP1) + | cmplw cr1, TMP1, TMP2 + | lwz CARG2, 4(TMP1) + | bge cr1, ->fff_resi + | checknum CARG4 + | xoris TMP0, CARG1, 0x8000 + | xoris TMP3, CARG2, 0x8000 + | bne >3 + | subfc TMP3, TMP3, TMP0 + | subfe TMP0, TMP0, TMP0 + |.if ismax + | andc TMP3, TMP3, TMP0 + |.else + | and TMP3, TMP3, TMP0 + |.endif + | add CARG1, TMP3, CARG2 + |.if GPR64 + | rldicl CARG1, CARG1, 0, 32 + |.endif + | addi TMP1, TMP1, 8 + | b <1 + |3: + | bge ->fff_fallback + | // Convert intermediate result to number and continue below. + | tonum_i FARG1, CARG1 + | lfd FARG2, 0(TMP1) + | b >6 + |4: + | lfd FARG1, 0(BASE) + | bge ->fff_fallback + |5: // Handle numbers. + | lwz CARG4, 0(TMP1) + | cmplw cr1, TMP1, TMP2 + | lfd FARG2, 0(TMP1) + | bge cr1, ->fff_resn + | checknum CARG4; bge >7 + |6: + | fsub f0, FARG1, FARG2 + | addi TMP1, TMP1, 8 + |.if ismax + | fsel FARG1, f0, FARG1, FARG2 + |.else + | fsel FARG1, f0, FARG2, FARG1 + |.endif + | b <5 + |7: // Convert integer to number and continue above. + | lwz CARG2, 4(TMP1) + | bne ->fff_fallback + | tonum_i FARG2, CARG2 + | b <6 + |.else + | .ffunc_n name + | li TMP1, 8 + |1: + | lwzx CARG2, BASE, TMP1 + | lfdx FARG2, BASE, TMP1 + | cmplw cr1, TMP1, NARGS8:RC + | checknum CARG2 + | bge cr1, ->fff_resn + | bge ->fff_fallback + | fsub f0, FARG1, FARG2 + | addi TMP1, TMP1, 8 + |.if ismax + | fsel FARG1, f0, FARG1, FARG2 + |.else + | fsel FARG1, f0, FARG2, FARG1 + |.endif + | b <1 + |.endif + |.endmacro + | + | math_minmax math_min, 0 + | math_minmax math_max, 1 + | + |//-- String library ----------------------------------------------------- + | + |.ffunc_1 string_len + | checkstr CARG3; bne ->fff_fallback + | lwz CRET1, STR:CARG1->len + | b ->fff_resi + | + |.ffunc string_byte // Only handle the 1-arg case here. + | cmplwi NARGS8:RC, 8 + | lwz CARG3, 0(BASE) + | lwz STR:CARG1, 4(BASE) + | bne ->fff_fallback // Need exactly 1 argument. + | checkstr CARG3 + | bne ->fff_fallback + | lwz TMP0, STR:CARG1->len + |.if DUALNUM + | lbz CARG1, STR:CARG1[1] // Access is always ok (NUL at end). + | li RD, (0+1)*8 + | lwz PC, FRAME_PC(BASE) + | cmplwi TMP0, 0 + | la RA, -8(BASE) + | beqy ->fff_res + | b ->fff_resi + |.else + | lbz TMP1, STR:CARG1[1] // Access is always ok (NUL at end). + | addic TMP3, TMP0, -1 // RD = ((str->len != 0)+1)*8 + | subfe RD, TMP3, TMP0 + | stw TMP1, TONUM_LO // Inlined tonum_u f0, TMP1. + | addi RD, RD, 1 + | lfd f0, TONUM_D + | la RA, -8(BASE) + | lwz PC, FRAME_PC(BASE) + | fsub f0, f0, TOBIT + | slwi RD, RD, 3 + | stfd f0, 0(RA) + | b ->fff_res + |.endif + | + |.ffunc string_char // Only handle the 1-arg case here. + | ffgccheck + | cmplwi NARGS8:RC, 8 + | lwz CARG3, 0(BASE) + |.if DUALNUM + | lwz TMP0, 4(BASE) + | bne ->fff_fallback // Exactly 1 argument. + | checknum CARG3; bne ->fff_fallback + | la CARG2, 7(BASE) + |.else + | lfd FARG1, 0(BASE) + | bne ->fff_fallback // Exactly 1 argument. + | checknum CARG3; bge ->fff_fallback + | toint TMP0, FARG1 + | la CARG2, TMPD_BLO + |.endif + | li CARG3, 1 + | cmplwi TMP0, 255; bgt ->fff_fallback + |->fff_newstr: + | mr CARG1, L + | stp BASE, L->base + | stw PC, SAVE_PC + | bl extern lj_str_new // (lua_State *L, char *str, size_t l) + | // Returns GCstr *. + | lp BASE, L->base + | li CARG3, LJ_TSTR + | b ->fff_restv + | + |.ffunc string_sub + | ffgccheck + | cmplwi NARGS8:RC, 16 + | lwz CARG3, 16(BASE) + |.if not DUALNUM + | lfd f0, 16(BASE) + |.endif + | lwz TMP0, 0(BASE) + | lwz STR:CARG1, 4(BASE) + | blt ->fff_fallback + | lwz CARG2, 8(BASE) + |.if DUALNUM + | lwz TMP1, 12(BASE) + |.else + | lfd f1, 8(BASE) + |.endif + | li TMP2, -1 + | beq >1 + |.if DUALNUM + | checknum CARG3 + | lwz TMP2, 20(BASE) + | bne ->fff_fallback + |1: + | checknum CARG2; bne ->fff_fallback + |.else + | checknum CARG3; bge ->fff_fallback + | toint TMP2, f0 + |1: + | checknum CARG2; bge ->fff_fallback + |.endif + | checkstr TMP0; bne ->fff_fallback + |.if not DUALNUM + | toint TMP1, f1 + |.endif + | lwz TMP0, STR:CARG1->len + | cmplw TMP0, TMP2 // len < end? (unsigned compare) + | addi TMP3, TMP2, 1 + | blt >5 + |2: + | cmpwi TMP1, 0 // start <= 0? + | add TMP3, TMP1, TMP0 + | ble >7 + |3: + | sub CARG3, TMP2, TMP1 + | addi CARG2, STR:CARG1, #STR-1 + | srawi TMP0, CARG3, 31 + | addi CARG3, CARG3, 1 + | add CARG2, CARG2, TMP1 + | andc CARG3, CARG3, TMP0 + |.if GPR64 + | rldicl CARG2, CARG2, 0, 32 + | rldicl CARG3, CARG3, 0, 32 + |.endif + | b ->fff_newstr + | + |5: // Negative end or overflow. + | cmpw TMP0, TMP2 // len >= end? (signed compare) + | add TMP2, TMP0, TMP3 // Negative end: end = end+len+1. + | bge <2 + | mr TMP2, TMP0 // Overflow: end = len. + | b <2 + | + |7: // Negative start or underflow. + | .gpr64 extsw TMP1, TMP1 + | addic CARG3, TMP1, -1 + | subfe CARG3, CARG3, CARG3 + | srawi CARG2, TMP3, 31 // Note: modifies carry. + | andc TMP3, TMP3, CARG3 + | andc TMP1, TMP3, CARG2 + | addi TMP1, TMP1, 1 // start = 1 + (start ? start+len : 0) + | b <3 + | + |.ffunc string_rep // Only handle the 1-char case inline. + | ffgccheck + | cmplwi NARGS8:RC, 16 + | lwz TMP0, 0(BASE) + | lwz STR:CARG1, 4(BASE) + | lwz CARG4, 8(BASE) + |.if DUALNUM + | lwz CARG3, 12(BASE) + |.else + | lfd FARG2, 8(BASE) + |.endif + | bne ->fff_fallback // Exactly 2 arguments. + | checkstr TMP0; bne ->fff_fallback + |.if DUALNUM + | checknum CARG4; bne ->fff_fallback + |.else + | checknum CARG4; bge ->fff_fallback + | toint CARG3, FARG2 + |.endif + | lwz TMP0, STR:CARG1->len + | cmpwi CARG3, 0 + | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | ble >2 // Count <= 0? (or non-int) + | cmplwi TMP0, 1 + | subi TMP2, CARG3, 1 + | blt >2 // Zero length string? + | cmplw cr1, TMP1, CARG3 + | bne ->fff_fallback // Fallback for > 1-char strings. + | lbz TMP0, STR:CARG1[1] + | lp CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | blt cr1, ->fff_fallback + |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). + | cmplwi TMP2, 0 + | stbx TMP0, CARG2, TMP2 + | subi TMP2, TMP2, 1 + | bne <1 + | b ->fff_newstr + |2: // Return empty string. + | la STR:CARG1, DISPATCH_GL(strempty)(DISPATCH) + | li CARG3, LJ_TSTR + | b ->fff_restv + | + |.ffunc string_reverse + | ffgccheck + | cmplwi NARGS8:RC, 8 + | lwz CARG3, 0(BASE) + | lwz STR:CARG1, 4(BASE) + | blt ->fff_fallback + | checkstr CARG3 + | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | bne ->fff_fallback + | lwz CARG3, STR:CARG1->len + | la CARG1, #STR(STR:CARG1) + | lp CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | li TMP2, 0 + | cmplw TMP1, CARG3 + | subi TMP3, CARG3, 1 + | blt ->fff_fallback + |1: // Reverse string copy. + | cmpwi TMP3, 0 + | lbzx TMP1, CARG1, TMP2 + | blty ->fff_newstr + | stbx TMP1, CARG2, TMP3 + | subi TMP3, TMP3, 1 + | addi TMP2, TMP2, 1 + | b <1 + | + |.macro ffstring_case, name, lo + | .ffunc name + | ffgccheck + | cmplwi NARGS8:RC, 8 + | lwz CARG3, 0(BASE) + | lwz STR:CARG1, 4(BASE) + | blt ->fff_fallback + | checkstr CARG3 + | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | bne ->fff_fallback + | lwz CARG3, STR:CARG1->len + | la CARG1, #STR(STR:CARG1) + | lp CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | cmplw TMP1, CARG3 + | li TMP2, 0 + | blt ->fff_fallback + |1: // ASCII case conversion. + | cmplw TMP2, CARG3 + | lbzx TMP1, CARG1, TMP2 + | bgey ->fff_newstr + | subi TMP0, TMP1, lo + | xori TMP3, TMP1, 0x20 + | addic TMP0, TMP0, -26 + | subfe TMP3, TMP3, TMP3 + | rlwinm TMP3, TMP3, 0, 26, 26 // x &= 0x20. + | xor TMP1, TMP1, TMP3 + | stbx TMP1, CARG2, TMP2 + | addi TMP2, TMP2, 1 + | b <1 + |.endmacro + | + |ffstring_case string_lower, 65 + |ffstring_case string_upper, 97 + | + |//-- Table library ------------------------------------------------------ + | + |.ffunc_1 table_getn + | checktab CARG3; bne ->fff_fallback + | bl extern lj_tab_len // (GCtab *t) + | // Returns uint32_t (but less than 2^31). + | b ->fff_resi + | + |//-- Bit library -------------------------------------------------------- + | + |.macro .ffunc_bit, name + |.if DUALNUM + | .ffunc_1 bit_..name + | checknum CARG3; bnel ->fff_tobit_fb + |.else + | .ffunc_n bit_..name + | fadd FARG1, FARG1, TOBIT + | stfd FARG1, TMPD + | lwz CARG1, TMPD_LO + |.endif + |.endmacro + | + |.macro .ffunc_bit_op, name, ins + | .ffunc_bit name + | addi TMP1, BASE, 8 + | add TMP2, BASE, NARGS8:RC + |1: + | lwz CARG4, 0(TMP1) + | cmplw cr1, TMP1, TMP2 + |.if DUALNUM + | lwz CARG2, 4(TMP1) + |.else + | lfd FARG1, 0(TMP1) + |.endif + | bgey cr1, ->fff_resi + | checknum CARG4 + |.if DUALNUM + | bnel ->fff_bitop_fb + |.else + | fadd FARG1, FARG1, TOBIT + | bge ->fff_fallback + | stfd FARG1, TMPD + | lwz CARG2, TMPD_LO + |.endif + | ins CARG1, CARG1, CARG2 + | addi TMP1, TMP1, 8 + | b <1 + |.endmacro + | + |.ffunc_bit_op band, and + |.ffunc_bit_op bor, or + |.ffunc_bit_op bxor, xor + | + |.ffunc_bit bswap + | rotlwi TMP0, CARG1, 8 + | rlwimi TMP0, CARG1, 24, 0, 7 + | rlwimi TMP0, CARG1, 24, 16, 23 + | mr CRET1, TMP0 + | b ->fff_resi + | + |.ffunc_bit bnot + | not CRET1, CARG1 + | b ->fff_resi + | + |.macro .ffunc_bit_sh, name, ins, shmod + |.if DUALNUM + | .ffunc_2 bit_..name + | checknum CARG3; bnel ->fff_tobit_fb + | // Note: no inline conversion from number for 2nd argument! + | checknum CARG4; bne ->fff_fallback + |.else + | .ffunc_nn bit_..name + | fadd FARG1, FARG1, TOBIT + | fadd FARG2, FARG2, TOBIT + | stfd FARG1, TMPD + | lwz CARG1, TMPD_LO + | stfd FARG2, TMPD + | lwz CARG2, TMPD_LO + |.endif + |.if shmod == 1 + | rlwinm CARG2, CARG2, 0, 27, 31 + |.elif shmod == 2 + | neg CARG2, CARG2 + |.endif + | ins CRET1, CARG1, CARG2 + | b ->fff_resi + |.endmacro + | + |.ffunc_bit_sh lshift, slw, 1 + |.ffunc_bit_sh rshift, srw, 1 + |.ffunc_bit_sh arshift, sraw, 1 + |.ffunc_bit_sh rol, rotlw, 0 + |.ffunc_bit_sh ror, rotlw, 2 + | + |.ffunc_bit tobit + |.if DUALNUM + | b ->fff_resi + |.else + |->fff_resi: + | tonum_i FARG1, CRET1 + |.endif + |->fff_resn: + | lwz PC, FRAME_PC(BASE) + | la RA, -8(BASE) + | stfd FARG1, -8(BASE) + | b ->fff_res1 + | + |// Fallback FP number to bit conversion. + |->fff_tobit_fb: + |.if DUALNUM + | lfd FARG1, 0(BASE) + | bgt ->fff_fallback + | fadd FARG1, FARG1, TOBIT + | stfd FARG1, TMPD + | lwz CARG1, TMPD_LO + | blr + |.endif + |->fff_bitop_fb: + |.if DUALNUM + | lfd FARG1, 0(TMP1) + | bgt ->fff_fallback + | fadd FARG1, FARG1, TOBIT + | stfd FARG1, TMPD + | lwz CARG2, TMPD_LO + | blr + |.endif + | + |//----------------------------------------------------------------------- + | + |->fff_fallback: // Call fast function fallback handler. + | // BASE = new base, RB = CFUNC, RC = nargs*8 + | lp TMP3, CFUNC:RB->f + | add TMP1, BASE, NARGS8:RC + | lwz PC, FRAME_PC(BASE) // Fallback may overwrite PC. + | addi TMP0, TMP1, 8*LUA_MINSTACK + | lwz TMP2, L->maxstack + | stw PC, SAVE_PC // Redundant (but a defined value). + | .toc lp TMP3, 0(TMP3) + | cmplw TMP0, TMP2 + | stp BASE, L->base + | stp TMP1, L->top + | mr CARG1, L + | bgt >5 // Need to grow stack. + | mtctr TMP3 + | bctrl // (lua_State *L) + | // Either throws an error, or recovers and returns -1, 0 or nresults+1. + | lp BASE, L->base + | cmpwi CRET1, 0 + | slwi RD, CRET1, 3 + | la RA, -8(BASE) + | bgt ->fff_res // Returned nresults+1? + |1: // Returned 0 or -1: retry fast path. + | lp TMP0, L->top + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | sub NARGS8:RC, TMP0, BASE + | bne ->vm_call_tail // Returned -1? + | ins_callt // Returned 0: retry fast path. + | + |// Reconstruct previous base for vmeta_call during tailcall. + |->vm_call_tail: + | andix. TMP0, PC, FRAME_TYPE + | rlwinm TMP1, PC, 0, 0, 28 + | bne >3 + | lwz INS, -4(PC) + | decode_RA8 TMP1, INS + | addi TMP1, TMP1, 8 + |3: + | sub TMP2, BASE, TMP1 + | b ->vm_call_dispatch // Resolve again for tailcall. + | + |5: // Grow stack for fallback handler. + | li CARG2, LUA_MINSTACK + | bl extern lj_state_growstack // (lua_State *L, int n) + | lp BASE, L->base + | cmpw TMP0, TMP0 // Set 4*cr0+eq to force retry. + | b <1 + | + |->fff_gcstep: // Call GC step function. + | // BASE = new base, RC = nargs*8 + | mflr SAVE0 + | stp BASE, L->base + | add TMP0, BASE, NARGS8:RC + | stw PC, SAVE_PC // Redundant (but a defined value). + | stp TMP0, L->top + | mr CARG1, L + | bl extern lj_gc_step // (lua_State *L) + | lp BASE, L->base + | mtlr SAVE0 + | lp TMP0, L->top + | sub NARGS8:RC, TMP0, BASE + | lwz CFUNC:RB, FRAME_FUNC(BASE) + | blr + | + |//----------------------------------------------------------------------- + |//-- Special dispatch targets ------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_record: // Dispatch target for recording phase. + |.if JIT + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | andix. TMP0, TMP3, HOOK_VMEVENT // No recording while in vmevent. + | bne >5 + | // Decrement the hookcount for consistency, but always do the call. + | lwz TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | andix. TMP0, TMP3, HOOK_ACTIVE + | bne >1 + | subi TMP2, TMP2, 1 + | andi. TMP0, TMP3, LUA_MASKLINE|LUA_MASKCOUNT + | beqy >1 + | stw TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | b >1 + |.endif + | + |->vm_rethook: // Dispatch target for return hooks. + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | andix. TMP0, TMP3, HOOK_ACTIVE // Hook already active? + | beq >1 + |5: // Re-dispatch to static ins. + | addi TMP1, TMP1, GG_DISP2STATIC // Assumes decode_OPP TMP1, INS. + | lpx TMP0, DISPATCH, TMP1 + | mtctr TMP0 + | bctr + | + |->vm_inshook: // Dispatch target for instr/line hooks. + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | lwz TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | andix. TMP0, TMP3, HOOK_ACTIVE // Hook already active? + | rlwinm TMP0, TMP3, 31-LUA_HOOKLINE, 31, 0 + | bne <5 + | + | cmpwi cr1, TMP0, 0 + | addic. TMP2, TMP2, -1 + | beq cr1, <5 + | stw TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | beq >1 + | bge cr1, <5 + |1: + | mr CARG1, L + | stw MULTRES, SAVE_MULTRES + | mr CARG2, PC + | stp BASE, L->base + | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. + | bl extern lj_dispatch_ins // (lua_State *L, const BCIns *pc) + |3: + | lp BASE, L->base + |4: // Re-dispatch to static ins. + | lwz INS, -4(PC) + | decode_OPP TMP1, INS + | decode_RB8 RB, INS + | addi TMP1, TMP1, GG_DISP2STATIC + | decode_RD8 RD, INS + | lpx TMP0, DISPATCH, TMP1 + | decode_RA8 RA, INS + | decode_RC8 RC, INS + | mtctr TMP0 + | bctr + | + |->cont_hook: // Continue from hook yield. + | addi PC, PC, 4 + | lwz MULTRES, -20(RB) // Restore MULTRES for *M ins. + | b <4 + | + |->vm_hotloop: // Hot loop counter underflow. + |.if JIT + | lwz LFUNC:TMP1, FRAME_FUNC(BASE) + | addi CARG1, DISPATCH, GG_DISP2J + | stw PC, SAVE_PC + | lwz TMP1, LFUNC:TMP1->pc + | mr CARG2, PC + | stw L, DISPATCH_J(L)(DISPATCH) + | lbz TMP1, PC2PROTO(framesize)(TMP1) + | stp BASE, L->base + | slwi TMP1, TMP1, 3 + | add TMP1, BASE, TMP1 + | stp TMP1, L->top + | bl extern lj_trace_hot // (jit_State *J, const BCIns *pc) + | b <3 + |.endif + | + |->vm_callhook: // Dispatch target for call hooks. + | mr CARG2, PC + |.if JIT + | b >1 + |.endif + | + |->vm_hotcall: // Hot call counter underflow. + |.if JIT + | ori CARG2, PC, 1 + |1: + |.endif + | add TMP0, BASE, RC + | stw PC, SAVE_PC + | mr CARG1, L + | stp BASE, L->base + | sub RA, RA, BASE + | stp TMP0, L->top + | bl extern lj_dispatch_call // (lua_State *L, const BCIns *pc) + | // Returns ASMFunction. + | lp BASE, L->base + | lp TMP0, L->top + | stw ZERO, SAVE_PC // Invalidate for subsequent line hook. + | sub NARGS8:RC, TMP0, BASE + | add RA, BASE, RA + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | lwz INS, -4(PC) + | mtctr CRET1 + | bctr + | + |//----------------------------------------------------------------------- + |//-- Trace exit handler ------------------------------------------------- + |//----------------------------------------------------------------------- + | + |.macro savex_, a, b, c, d + | stfd f..a, 16+a*8(sp) + | stfd f..b, 16+b*8(sp) + | stfd f..c, 16+c*8(sp) + | stfd f..d, 16+d*8(sp) + |.endmacro + | + |->vm_exit_handler: + |.if JIT + | addi sp, sp, -(16+32*8+32*4) + | stmw r2, 16+32*8+2*4(sp) + | addi DISPATCH, JGL, -GG_DISP2G-32768 + | li CARG2, ~LJ_VMST_EXIT + | lwz CARG1, 16+32*8+32*4(sp) // Get stack chain. + | stw CARG2, DISPATCH_GL(vmstate)(DISPATCH) + | savex_ 0,1,2,3 + | stw CARG1, 0(sp) // Store extended stack chain. + | clrso TMP1 + | savex_ 4,5,6,7 + | addi CARG2, sp, 16+32*8+32*4 // Recompute original value of sp. + | savex_ 8,9,10,11 + | stw CARG2, 16+32*8+1*4(sp) // Store sp in RID_SP. + | savex_ 12,13,14,15 + | mflr CARG3 + | li TMP1, 0 + | savex_ 16,17,18,19 + | stw TMP1, 16+32*8+0*4(sp) // Clear RID_TMP. + | savex_ 20,21,22,23 + | lhz CARG4, 2(CARG3) // Load trace number. + | savex_ 24,25,26,27 + | lwz L, DISPATCH_GL(jit_L)(DISPATCH) + | savex_ 28,29,30,31 + | sub CARG3, TMP0, CARG3 // Compute exit number. + | lp BASE, DISPATCH_GL(jit_base)(DISPATCH) + | srwi CARG3, CARG3, 2 + | stw L, DISPATCH_J(L)(DISPATCH) + | subi CARG3, CARG3, 2 + | stw TMP1, DISPATCH_GL(jit_L)(DISPATCH) + | stw CARG4, DISPATCH_J(parent)(DISPATCH) + | stp BASE, L->base + | addi CARG1, DISPATCH, GG_DISP2J + | stw CARG3, DISPATCH_J(exitno)(DISPATCH) + | addi CARG2, sp, 16 + | bl extern lj_trace_exit // (jit_State *J, ExitState *ex) + | // Returns MULTRES (unscaled) or negated error code. + | lp TMP1, L->cframe + | lwz TMP2, 0(sp) + | lp BASE, L->base + |.if GPR64 + | rldicr sp, TMP1, 0, 61 + |.else + | rlwinm sp, TMP1, 0, 0, 29 + |.endif + | lwz PC, SAVE_PC // Get SAVE_PC. + | stw TMP2, 0(sp) + | stw L, SAVE_L // Set SAVE_L (on-trace resume/yield). + | b >1 + |.endif + |->vm_exit_interp: + |.if JIT + | // CARG1 = MULTRES or negated error code, BASE, PC and JGL set. + | lwz L, SAVE_L + | addi DISPATCH, JGL, -GG_DISP2G-32768 + |1: + | cmpwi CARG1, 0 + | blt >3 // Check for error from exit. + | lwz LFUNC:TMP1, FRAME_FUNC(BASE) + | slwi MULTRES, CARG1, 3 + | li TMP2, 0 + | stw MULTRES, SAVE_MULTRES + | lwz TMP1, LFUNC:TMP1->pc + | stw TMP2, DISPATCH_GL(jit_L)(DISPATCH) + | lwz KBASE, PC2PROTO(k)(TMP1) + | // Setup type comparison constants. + | li TISNUM, LJ_TISNUM + | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | stw TMP3, TMPD + | li ZERO, 0 + | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). + | lfs TOBIT, TMPD + | stw TMP3, TMPD + | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) + | li TISNIL, LJ_TNIL + | stw TMP0, TONUM_HI + | lfs TONUM, TMPD + | // Modified copy of ins_next which handles function header dispatch, too. + | lwz INS, 0(PC) + | addi PC, PC, 4 + | // Assumes TISNIL == ~LJ_VMST_INTERP == -1. + | stw TISNIL, DISPATCH_GL(vmstate)(DISPATCH) + | decode_OPP TMP1, INS + | decode_RA8 RA, INS + | lpx TMP0, DISPATCH, TMP1 + | mtctr TMP0 + | cmplwi TMP1, BC_FUNCF*4 // Function header? + | bge >2 + | decode_RB8 RB, INS + | decode_RD8 RD, INS + | decode_RC8 RC, INS + | bctr + |2: + | subi RC, MULTRES, 8 + | add RA, RA, BASE + | bctr + | + |3: // Rethrow error from the right C frame. + | neg CARG2, CARG1 + | mr CARG1, L + | bl extern lj_err_throw // (lua_State *L, int errcode) + |.endif + | + |//----------------------------------------------------------------------- + |//-- Math helper functions ---------------------------------------------- + |//----------------------------------------------------------------------- + | + |// NYI: Use internal implementations of floor, ceil, trunc. + | + |->vm_modi: + | divwo. TMP0, CARG1, CARG2 + | bso >1 + |.if GPR64 + | xor CARG3, CARG1, CARG2 + | cmpwi CARG3, 0 + |.else + | xor. CARG3, CARG1, CARG2 + |.endif + | mullw TMP0, TMP0, CARG2 + | sub CARG1, CARG1, TMP0 + | bgelr + | cmpwi CARG1, 0; beqlr + | add CARG1, CARG1, CARG2 + | blr + |1: + | cmpwi CARG2, 0 + | li CARG1, 0 + | beqlr + | clrso TMP0 // Clear SO for -2147483648 % -1 and return 0. + | blr + | + |//----------------------------------------------------------------------- + |//-- Miscellaneous functions -------------------------------------------- + |//----------------------------------------------------------------------- + | + |// void lj_vm_cachesync(void *start, void *end) + |// Flush D-Cache and invalidate I-Cache. Assumes 32 byte cache line size. + |// This is a good lower bound, except for very ancient PPC models. + |->vm_cachesync: + |.if JIT or FFI + | // Compute start of first cache line and number of cache lines. + | rlwinm CARG1, CARG1, 0, 0, 26 + | sub CARG2, CARG2, CARG1 + | addi CARG2, CARG2, 31 + | rlwinm. CARG2, CARG2, 27, 5, 31 + | beqlr + | mtctr CARG2 + | mr CARG3, CARG1 + |1: // Flush D-Cache. + | dcbst r0, CARG1 + | addi CARG1, CARG1, 32 + | bdnz <1 + | sync + | mtctr CARG2 + |1: // Invalidate I-Cache. + | icbi r0, CARG3 + | addi CARG3, CARG3, 32 + | bdnz <1 + | isync + | blr + |.endif + | + |//----------------------------------------------------------------------- + |//-- FFI helper functions ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |// Handler for callback functions. Callback slot number in r11, g in r12. + |->vm_ffi_callback: + |.if FFI + |.type CTSTATE, CTState, PC + | saveregs + | lwz CTSTATE, GL:r12->ctype_state + | addi DISPATCH, r12, GG_G2DISP + | stw r11, CTSTATE->cb.slot + | stw r3, CTSTATE->cb.gpr[0] + | stfd f1, CTSTATE->cb.fpr[0] + | stw r4, CTSTATE->cb.gpr[1] + | stfd f2, CTSTATE->cb.fpr[1] + | stw r5, CTSTATE->cb.gpr[2] + | stfd f3, CTSTATE->cb.fpr[2] + | stw r6, CTSTATE->cb.gpr[3] + | stfd f4, CTSTATE->cb.fpr[3] + | stw r7, CTSTATE->cb.gpr[4] + | stfd f5, CTSTATE->cb.fpr[4] + | stw r8, CTSTATE->cb.gpr[5] + | stfd f6, CTSTATE->cb.fpr[5] + | stw r9, CTSTATE->cb.gpr[6] + | stfd f7, CTSTATE->cb.fpr[6] + | stw r10, CTSTATE->cb.gpr[7] + | stfd f8, CTSTATE->cb.fpr[7] + | addi TMP0, sp, CFRAME_SPACE+8 + | stw TMP0, CTSTATE->cb.stack + | mr CARG1, CTSTATE + | stw CTSTATE, SAVE_PC // Any value outside of bytecode is ok. + | mr CARG2, sp + | bl extern lj_ccallback_enter // (CTState *cts, void *cf) + | // Returns lua_State *. + | lp BASE, L:CRET1->base + | li TISNUM, LJ_TISNUM // Setup type comparison constants. + | lp RC, L:CRET1->top + | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | li ZERO, 0 + | mr L, CRET1 + | stw TMP3, TMPD + | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). + | stw TMP0, TONUM_HI + | li TISNIL, LJ_TNIL + | li_vmstate INTERP + | lfs TOBIT, TMPD + | stw TMP3, TMPD + | sub RC, RC, BASE + | st_vmstate + | lfs TONUM, TMPD + | ins_callt + |.endif + | + |->cont_ffi_callback: // Return from FFI callback. + |.if FFI + | lwz CTSTATE, DISPATCH_GL(ctype_state)(DISPATCH) + | stp BASE, L->base + | stp RB, L->top + | stp L, CTSTATE->L + | mr CARG1, CTSTATE + | mr CARG2, RA + | bl extern lj_ccallback_leave // (CTState *cts, TValue *o) + | lwz CRET1, CTSTATE->cb.gpr[0] + | lfd FARG1, CTSTATE->cb.fpr[0] + | lwz CRET2, CTSTATE->cb.gpr[1] + | b ->vm_leave_unw + |.endif + | + |->vm_ffi_call: // Call C function via FFI. + | // Caveat: needs special frame unwinding, see below. + |.if FFI + | .type CCSTATE, CCallState, CARG1 + | lwz TMP1, CCSTATE->spadj + | mflr TMP0 + | lbz CARG2, CCSTATE->nsp + | lbz CARG3, CCSTATE->nfpr + | neg TMP1, TMP1 + | stw TMP0, 4(sp) + | cmpwi cr1, CARG3, 0 + | mr TMP2, sp + | addic. CARG2, CARG2, -1 + | stwux sp, sp, TMP1 + | crnot 4*cr1+eq, 4*cr1+eq // For vararg calls. + | stw r14, -4(TMP2) + | stw CCSTATE, -8(TMP2) + | mr r14, TMP2 + | la TMP1, CCSTATE->stack + | slwi CARG2, CARG2, 2 + | blty >2 + | la TMP2, 8(sp) + |1: + | lwzx TMP0, TMP1, CARG2 + | stwx TMP0, TMP2, CARG2 + | addic. CARG2, CARG2, -4 + | bge <1 + |2: + | bney cr1, >3 + | lfd f1, CCSTATE->fpr[0] + | lfd f2, CCSTATE->fpr[1] + | lfd f3, CCSTATE->fpr[2] + | lfd f4, CCSTATE->fpr[3] + | lfd f5, CCSTATE->fpr[4] + | lfd f6, CCSTATE->fpr[5] + | lfd f7, CCSTATE->fpr[6] + | lfd f8, CCSTATE->fpr[7] + |3: + | lp TMP0, CCSTATE->func + | lwz CARG2, CCSTATE->gpr[1] + | lwz CARG3, CCSTATE->gpr[2] + | lwz CARG4, CCSTATE->gpr[3] + | lwz CARG5, CCSTATE->gpr[4] + | mtctr TMP0 + | lwz r8, CCSTATE->gpr[5] + | lwz r9, CCSTATE->gpr[6] + | lwz r10, CCSTATE->gpr[7] + | lwz CARG1, CCSTATE->gpr[0] // Do this last, since CCSTATE is CARG1. + | bctrl + | lwz CCSTATE:TMP1, -8(r14) + | lwz TMP2, -4(r14) + | lwz TMP0, 4(r14) + | stw CARG1, CCSTATE:TMP1->gpr[0] + | stfd FARG1, CCSTATE:TMP1->fpr[0] + | stw CARG2, CCSTATE:TMP1->gpr[1] + | mtlr TMP0 + | stw CARG3, CCSTATE:TMP1->gpr[2] + | mr sp, r14 + | stw CARG4, CCSTATE:TMP1->gpr[3] + | mr r14, TMP2 + | blr + |.endif + |// Note: vm_ffi_call must be the last function in this object file! + | + |//----------------------------------------------------------------------- +} + +/* Generate the code for a single instruction. */ +static void build_ins(BuildCtx *ctx, BCOp op, int defop) +{ + int vk = 0; + |=>defop: + + switch (op) { + + /* -- Comparison ops ---------------------------------------------------- */ + + /* Remember: all ops branch for a true comparison, fall through otherwise. */ + + case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: + | // RA = src1*8, RD = src2*8, JMP with RD = target + |.if DUALNUM + | lwzux TMP0, RA, BASE + | addi PC, PC, 4 + | lwz CARG2, 4(RA) + | lwzux TMP1, RD, BASE + | lwz TMP2, -4(PC) + | checknum cr0, TMP0 + | lwz CARG3, 4(RD) + | decode_RD4 TMP2, TMP2 + | checknum cr1, TMP1 + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + | bne cr0, >7 + | bne cr1, >8 + | cmpw CARG2, CARG3 + if (op == BC_ISLT) { + | bge >2 + } else if (op == BC_ISGE) { + | blt >2 + } else if (op == BC_ISLE) { + | bgt >2 + } else { + | ble >2 + } + |1: + | add PC, PC, TMP2 + |2: + | ins_next + | + |7: // RA is not an integer. + | bgt cr0, ->vmeta_comp + | // RA is a number. + | lfd f0, 0(RA) + | bgt cr1, ->vmeta_comp + | blt cr1, >4 + | // RA is a number, RD is an integer. + | tonum_i f1, CARG3 + | b >5 + | + |8: // RA is an integer, RD is not an integer. + | bgt cr1, ->vmeta_comp + | // RA is an integer, RD is a number. + | tonum_i f0, CARG2 + |4: + | lfd f1, 0(RD) + |5: + | fcmpu cr0, f0, f1 + if (op == BC_ISLT) { + | bge <2 + } else if (op == BC_ISGE) { + | blt <2 + } else if (op == BC_ISLE) { + | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq + | bge <2 + } else { + | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq + | blt <2 + } + | b <1 + |.else + | lwzx TMP0, BASE, RA + | addi PC, PC, 4 + | lfdx f0, BASE, RA + | lwzx TMP1, BASE, RD + | checknum cr0, TMP0 + | lwz TMP2, -4(PC) + | lfdx f1, BASE, RD + | checknum cr1, TMP1 + | decode_RD4 TMP2, TMP2 + | bge cr0, ->vmeta_comp + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + | bge cr1, ->vmeta_comp + | fcmpu cr0, f0, f1 + if (op == BC_ISLT) { + | bge >1 + } else if (op == BC_ISGE) { + | blt >1 + } else if (op == BC_ISLE) { + | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq + | bge >1 + } else { + | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq + | blt >1 + } + | add PC, PC, TMP2 + |1: + | ins_next + |.endif + break; + + case BC_ISEQV: case BC_ISNEV: + vk = op == BC_ISEQV; + | // RA = src1*8, RD = src2*8, JMP with RD = target + |.if DUALNUM + | lwzux TMP0, RA, BASE + | addi PC, PC, 4 + | lwz CARG2, 4(RA) + | lwzux TMP1, RD, BASE + | checknum cr0, TMP0 + | lwz TMP2, -4(PC) + | checknum cr1, TMP1 + | decode_RD4 TMP2, TMP2 + | lwz CARG3, 4(RD) + | cror 4*cr7+gt, 4*cr0+gt, 4*cr1+gt + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + if (vk) { + | ble cr7, ->BC_ISEQN_Z + } else { + | ble cr7, ->BC_ISNEN_Z + } + |.else + | lwzux TMP0, RA, BASE + | lwz TMP2, 0(PC) + | lfd f0, 0(RA) + | addi PC, PC, 4 + | lwzux TMP1, RD, BASE + | checknum cr0, TMP0 + | decode_RD4 TMP2, TMP2 + | lfd f1, 0(RD) + | checknum cr1, TMP1 + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + | bge cr0, >5 + | bge cr1, >5 + | fcmpu cr0, f0, f1 + if (vk) { + | bne >1 + | add PC, PC, TMP2 + } else { + | beq >1 + | add PC, PC, TMP2 + } + |1: + | ins_next + |.endif + |5: // Either or both types are not numbers. + |.if not DUALNUM + | lwz CARG2, 4(RA) + | lwz CARG3, 4(RD) + |.endif + |.if FFI + | cmpwi cr7, TMP0, LJ_TCDATA + | cmpwi cr5, TMP1, LJ_TCDATA + |.endif + | not TMP3, TMP0 + | cmplw TMP0, TMP1 + | cmplwi cr1, TMP3, ~LJ_TISPRI // Primitive? + |.if FFI + | cror 4*cr7+eq, 4*cr7+eq, 4*cr5+eq + |.endif + | cmplwi cr6, TMP3, ~LJ_TISTABUD // Table or userdata? + |.if FFI + | beq cr7, ->vmeta_equal_cd + |.endif + | cmplw cr5, CARG2, CARG3 + | crandc 4*cr0+gt, 4*cr0+eq, 4*cr1+gt // 2: Same type and primitive. + | crorc 4*cr0+lt, 4*cr5+eq, 4*cr0+eq // 1: Same tv or different type. + | crand 4*cr0+eq, 4*cr0+eq, 4*cr5+eq // 0: Same type and same tv. + | mr SAVE0, PC + | cror 4*cr0+eq, 4*cr0+eq, 4*cr0+gt // 0 or 2. + | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+gt // 1 or 2. + if (vk) { + | bne cr0, >6 + | add PC, PC, TMP2 + |6: + } else { + | beq cr0, >6 + | add PC, PC, TMP2 + |6: + } + |.if DUALNUM + | bge cr0, >2 // Done if 1 or 2. + |1: + | ins_next + |2: + |.else + | blt cr0, <1 // Done if 1 or 2. + |.endif + | blt cr6, <1 // Done if not tab/ud. + | + | // Different tables or userdatas. Need to check __eq metamethod. + | // Field metatable must be at same offset for GCtab and GCudata! + | lwz TAB:TMP2, TAB:CARG2->metatable + | li CARG4, 1-vk // ne = 0 or 1. + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable? + | lbz TMP2, TAB:TMP2->nomm + | andix. TMP2, TMP2, 1<vmeta_equal // Handle __eq metamethod. + break; + + case BC_ISEQS: case BC_ISNES: + vk = op == BC_ISEQS; + | // RA = src*8, RD = str_const*8 (~), JMP with RD = target + | lwzux TMP0, RA, BASE + | srwi RD, RD, 1 + | lwz STR:TMP3, 4(RA) + | lwz TMP2, 0(PC) + | subfic RD, RD, -4 + | addi PC, PC, 4 + |.if FFI + | cmpwi TMP0, LJ_TCDATA + |.endif + | lwzx STR:TMP1, KBASE, RD // KBASE-4-str_const*4 + | .gpr64 extsw TMP0, TMP0 + | subfic TMP0, TMP0, LJ_TSTR + |.if FFI + | beq ->vmeta_equal_cd + |.endif + | sub TMP1, STR:TMP1, STR:TMP3 + | or TMP0, TMP0, TMP1 + | decode_RD4 TMP2, TMP2 + | subfic TMP0, TMP0, 0 + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + | subfe TMP1, TMP1, TMP1 + if (vk) { + | andc TMP2, TMP2, TMP1 + } else { + | and TMP2, TMP2, TMP1 + } + | add PC, PC, TMP2 + | ins_next + break; + + case BC_ISEQN: case BC_ISNEN: + vk = op == BC_ISEQN; + | // RA = src*8, RD = num_const*8, JMP with RD = target + |.if DUALNUM + | lwzux TMP0, RA, BASE + | addi PC, PC, 4 + | lwz CARG2, 4(RA) + | lwzux TMP1, RD, KBASE + | checknum cr0, TMP0 + | lwz TMP2, -4(PC) + | checknum cr1, TMP1 + | decode_RD4 TMP2, TMP2 + | lwz CARG3, 4(RD) + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + if (vk) { + |->BC_ISEQN_Z: + } else { + |->BC_ISNEN_Z: + } + | bne cr0, >7 + | bne cr1, >8 + | cmpw CARG2, CARG3 + |4: + |.else + if (vk) { + |->BC_ISEQN_Z: // Dummy label. + } else { + |->BC_ISNEN_Z: // Dummy label. + } + | lwzx TMP0, BASE, RA + | addi PC, PC, 4 + | lfdx f0, BASE, RA + | lwz TMP2, -4(PC) + | lfdx f1, KBASE, RD + | decode_RD4 TMP2, TMP2 + | checknum TMP0 + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + | bge >3 + | fcmpu cr0, f0, f1 + |.endif + if (vk) { + | bne >1 + | add PC, PC, TMP2 + |1: + |.if not FFI + |3: + |.endif + } else { + | beq >2 + |1: + |.if not FFI + |3: + |.endif + | add PC, PC, TMP2 + |2: + } + | ins_next + |.if FFI + |3: + | cmpwi TMP0, LJ_TCDATA + | beq ->vmeta_equal_cd + | b <1 + |.endif + |.if DUALNUM + |7: // RA is not an integer. + | bge cr0, <3 + | // RA is a number. + | lfd f0, 0(RA) + | blt cr1, >1 + | // RA is a number, RD is an integer. + | tonum_i f1, CARG3 + | b >2 + | + |8: // RA is an integer, RD is a number. + | tonum_i f0, CARG2 + |1: + | lfd f1, 0(RD) + |2: + | fcmpu cr0, f0, f1 + | b <4 + |.endif + break; + + case BC_ISEQP: case BC_ISNEP: + vk = op == BC_ISEQP; + | // RA = src*8, RD = primitive_type*8 (~), JMP with RD = target + | lwzx TMP0, BASE, RA + | srwi TMP1, RD, 3 + | lwz TMP2, 0(PC) + | not TMP1, TMP1 + | addi PC, PC, 4 + |.if FFI + | cmpwi TMP0, LJ_TCDATA + |.endif + | sub TMP0, TMP0, TMP1 + |.if FFI + | beq ->vmeta_equal_cd + |.endif + | decode_RD4 TMP2, TMP2 + | .gpr64 extsw TMP0, TMP0 + | addic TMP0, TMP0, -1 + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + | subfe TMP1, TMP1, TMP1 + if (vk) { + | and TMP2, TMP2, TMP1 + } else { + | andc TMP2, TMP2, TMP1 + } + | add PC, PC, TMP2 + | ins_next + break; + + /* -- Unary test and copy ops ------------------------------------------- */ + + case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: + | // RA = dst*8 or unused, RD = src*8, JMP with RD = target + | lwzx TMP0, BASE, RD + | lwz INS, 0(PC) + | addi PC, PC, 4 + if (op == BC_IST || op == BC_ISF) { + | .gpr64 extsw TMP0, TMP0 + | subfic TMP0, TMP0, LJ_TTRUE + | decode_RD4 TMP2, INS + | subfe TMP1, TMP1, TMP1 + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + if (op == BC_IST) { + | andc TMP2, TMP2, TMP1 + } else { + | and TMP2, TMP2, TMP1 + } + | add PC, PC, TMP2 + } else { + | li TMP1, LJ_TFALSE + | lfdx f0, BASE, RD + | cmplw TMP0, TMP1 + if (op == BC_ISTC) { + | bge >1 + } else { + | blt >1 + } + | addis PC, PC, -(BCBIAS_J*4 >> 16) + | decode_RD4 TMP2, INS + | stfdx f0, BASE, RA + | add PC, PC, TMP2 + |1: + } + | ins_next + break; + + /* -- Unary ops --------------------------------------------------------- */ + + case BC_MOV: + | // RA = dst*8, RD = src*8 + | ins_next1 + | lfdx f0, BASE, RD + | stfdx f0, BASE, RA + | ins_next2 + break; + case BC_NOT: + | // RA = dst*8, RD = src*8 + | ins_next1 + | lwzx TMP0, BASE, RD + | .gpr64 extsw TMP0, TMP0 + | subfic TMP1, TMP0, LJ_TTRUE + | adde TMP0, TMP0, TMP1 + | stwx TMP0, BASE, RA + | ins_next2 + break; + case BC_UNM: + | // RA = dst*8, RD = src*8 + | lwzux TMP1, RD, BASE + | lwz TMP0, 4(RD) + | checknum TMP1 + |.if DUALNUM + | bne >5 + |.if GPR64 + | lus TMP2, 0x8000 + | neg TMP0, TMP0 + | cmplw TMP0, TMP2 + | beq >4 + |.else + | nego. TMP0, TMP0 + | bso >4 + |1: + |.endif + | ins_next1 + | stwux TISNUM, RA, BASE + | stw TMP0, 4(RA) + |3: + | ins_next2 + |4: + |.if not GPR64 + | // Potential overflow. + | checkov TMP1, <1 // Ignore unrelated overflow. + |.endif + | lus TMP1, 0x41e0 // 2^31. + | li TMP0, 0 + | b >7 + |.endif + |5: + | bge ->vmeta_unm + | xoris TMP1, TMP1, 0x8000 + |7: + | ins_next1 + | stwux TMP1, RA, BASE + | stw TMP0, 4(RA) + |.if DUALNUM + | b <3 + |.else + | ins_next2 + |.endif + break; + case BC_LEN: + | // RA = dst*8, RD = src*8 + | lwzux TMP0, RD, BASE + | lwz CARG1, 4(RD) + | checkstr TMP0; bne >2 + | lwz CRET1, STR:CARG1->len + |1: + |.if DUALNUM + | ins_next1 + | stwux TISNUM, RA, BASE + | stw CRET1, 4(RA) + |.else + | tonum_u f0, CRET1 // Result is a non-negative integer. + | ins_next1 + | stfdx f0, BASE, RA + |.endif + | ins_next2 + |2: + | checktab TMP0; bne ->vmeta_len +#if LJ_52 + | lwz TAB:TMP2, TAB:CARG1->metatable + | cmplwi TAB:TMP2, 0 + | bne >9 + |3: +#endif + |->BC_LEN_Z: + | bl extern lj_tab_len // (GCtab *t) + | // Returns uint32_t (but less than 2^31). + | b <1 +#if LJ_52 + |9: + | lbz TMP0, TAB:TMP2->nomm + | andix. TMP0, TMP0, 1<vmeta_len +#endif + break; + + /* -- Binary ops -------------------------------------------------------- */ + + |.macro ins_arithpre + | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 + ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); + ||switch (vk) { + ||case 0: + | lwzx TMP1, BASE, RB + | .if DUALNUM + | lwzx TMP2, KBASE, RC + | .endif + | lfdx f14, BASE, RB + | lfdx f15, KBASE, RC + | .if DUALNUM + | checknum cr0, TMP1 + | checknum cr1, TMP2 + | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | bge ->vmeta_arith_vn + | .else + | checknum TMP1; bge ->vmeta_arith_vn + | .endif + || break; + ||case 1: + | lwzx TMP1, BASE, RB + | .if DUALNUM + | lwzx TMP2, KBASE, RC + | .endif + | lfdx f15, BASE, RB + | lfdx f14, KBASE, RC + | .if DUALNUM + | checknum cr0, TMP1 + | checknum cr1, TMP2 + | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | bge ->vmeta_arith_nv + | .else + | checknum TMP1; bge ->vmeta_arith_nv + | .endif + || break; + ||default: + | lwzx TMP1, BASE, RB + | lwzx TMP2, BASE, RC + | lfdx f14, BASE, RB + | lfdx f15, BASE, RC + | checknum cr0, TMP1 + | checknum cr1, TMP2 + | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | bge ->vmeta_arith_vv + || break; + ||} + |.endmacro + | + |.macro ins_arithfallback, ins + ||switch (vk) { + ||case 0: + | ins ->vmeta_arith_vn2 + || break; + ||case 1: + | ins ->vmeta_arith_nv2 + || break; + ||default: + | ins ->vmeta_arith_vv2 + || break; + ||} + |.endmacro + | + |.macro intmod, a, b, c + | bl ->vm_modi + |.endmacro + | + |.macro fpmod, a, b, c + |->BC_MODVN_Z: + | fdiv FARG1, b, c + | // NYI: Use internal implementation of floor. + | blex floor // floor(b/c) + | fmul a, FARG1, c + | fsub a, b, a // b - floor(b/c)*c + |.endmacro + | + |.macro ins_arithfp, fpins + | ins_arithpre + |.if "fpins" == "fpmod_" + | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. + |.else + | fpins f0, f14, f15 + | ins_next1 + | stfdx f0, BASE, RA + | ins_next2 + |.endif + |.endmacro + | + |.macro ins_arithdn, intins, fpins + | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 + ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); + ||switch (vk) { + ||case 0: + | lwzux TMP1, RB, BASE + | lwzux TMP2, RC, KBASE + | lwz CARG1, 4(RB) + | checknum cr0, TMP1 + | lwz CARG2, 4(RC) + || break; + ||case 1: + | lwzux TMP1, RB, BASE + | lwzux TMP2, RC, KBASE + | lwz CARG2, 4(RB) + | checknum cr0, TMP1 + | lwz CARG1, 4(RC) + || break; + ||default: + | lwzux TMP1, RB, BASE + | lwzux TMP2, RC, BASE + | lwz CARG1, 4(RB) + | checknum cr0, TMP1 + | lwz CARG2, 4(RC) + || break; + ||} + | checknum cr1, TMP2 + | bne >5 + | bne cr1, >5 + | intins CARG1, CARG1, CARG2 + | bso >4 + |1: + | ins_next1 + | stwux TISNUM, RA, BASE + | stw CARG1, 4(RA) + |2: + | ins_next2 + |4: // Overflow. + | checkov TMP0, <1 // Ignore unrelated overflow. + | ins_arithfallback b + |5: // FP variant. + ||if (vk == 1) { + | lfd f15, 0(RB) + | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | lfd f14, 0(RC) + ||} else { + | lfd f14, 0(RB) + | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | lfd f15, 0(RC) + ||} + | ins_arithfallback bge + |.if "fpins" == "fpmod_" + | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. + |.else + | fpins f0, f14, f15 + | ins_next1 + | stfdx f0, BASE, RA + | b <2 + |.endif + |.endmacro + | + |.macro ins_arith, intins, fpins + |.if DUALNUM + | ins_arithdn intins, fpins + |.else + | ins_arithfp fpins + |.endif + |.endmacro + + case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: + |.if GPR64 + |.macro addo32., y, a, b + | // Need to check overflow for (a<<32) + (b<<32). + | rldicr TMP0, a, 32, 31 + | rldicr TMP3, b, 32, 31 + | addo. TMP0, TMP0, TMP3 + | add y, a, b + |.endmacro + | ins_arith addo32., fadd + |.else + | ins_arith addo., fadd + |.endif + break; + case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: + |.if GPR64 + |.macro subo32., y, a, b + | // Need to check overflow for (a<<32) - (b<<32). + | rldicr TMP0, a, 32, 31 + | rldicr TMP3, b, 32, 31 + | subo. TMP0, TMP0, TMP3 + | sub y, a, b + |.endmacro + | ins_arith subo32., fsub + |.else + | ins_arith subo., fsub + |.endif + break; + case BC_MULVN: case BC_MULNV: case BC_MULVV: + | ins_arith mullwo., fmul + break; + case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: + | ins_arithfp fdiv + break; + case BC_MODVN: + | ins_arith intmod, fpmod + break; + case BC_MODNV: case BC_MODVV: + | ins_arith intmod, fpmod_ + break; + case BC_POW: + | // NYI: (partial) integer arithmetic. + | lwzx TMP1, BASE, RB + | lfdx FARG1, BASE, RB + | lwzx TMP2, BASE, RC + | lfdx FARG2, BASE, RC + | checknum cr0, TMP1 + | checknum cr1, TMP2 + | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | bge ->vmeta_arith_vv + | blex pow + | ins_next1 + | stfdx FARG1, BASE, RA + | ins_next2 + break; + + case BC_CAT: + | // RA = dst*8, RB = src_start*8, RC = src_end*8 + | sub CARG3, RC, RB + | stp BASE, L->base + | add CARG2, BASE, RC + | mr SAVE0, RB + |->BC_CAT_Z: + | stw PC, SAVE_PC + | mr CARG1, L + | srwi CARG3, CARG3, 3 + | bl extern lj_meta_cat // (lua_State *L, TValue *top, int left) + | // Returns NULL (finished) or TValue * (metamethod). + | cmplwi CRET1, 0 + | lp BASE, L->base + | bne ->vmeta_binop + | ins_next1 + | lfdx f0, BASE, SAVE0 // Copy result from RB to RA. + | stfdx f0, BASE, RA + | ins_next2 + break; + + /* -- Constant ops ------------------------------------------------------ */ + + case BC_KSTR: + | // RA = dst*8, RD = str_const*8 (~) + | srwi TMP1, RD, 1 + | subfic TMP1, TMP1, -4 + | ins_next1 + | lwzx TMP0, KBASE, TMP1 // KBASE-4-str_const*4 + | li TMP2, LJ_TSTR + | stwux TMP2, RA, BASE + | stw TMP0, 4(RA) + | ins_next2 + break; + case BC_KCDATA: + |.if FFI + | // RA = dst*8, RD = cdata_const*8 (~) + | srwi TMP1, RD, 1 + | subfic TMP1, TMP1, -4 + | ins_next1 + | lwzx TMP0, KBASE, TMP1 // KBASE-4-cdata_const*4 + | li TMP2, LJ_TCDATA + | stwux TMP2, RA, BASE + | stw TMP0, 4(RA) + | ins_next2 + |.endif + break; + case BC_KSHORT: + | // RA = dst*8, RD = int16_literal*8 + |.if DUALNUM + | slwi RD, RD, 13 + | srawi RD, RD, 16 + | ins_next1 + | stwux TISNUM, RA, BASE + | stw RD, 4(RA) + | ins_next2 + |.else + | // The soft-float approach is faster. + | slwi RD, RD, 13 + | srawi TMP1, RD, 31 + | xor TMP2, TMP1, RD + | sub TMP2, TMP2, TMP1 // TMP2 = abs(x) + | cntlzw TMP3, TMP2 + | subfic TMP1, TMP3, 0x40d // TMP1 = exponent-1 + | slw TMP2, TMP2, TMP3 // TMP2 = left aligned mantissa + | subfic TMP3, RD, 0 + | slwi TMP1, TMP1, 20 + | rlwimi RD, TMP2, 21, 1, 31 // hi = sign(x) | (mantissa>>11) + | subfe TMP0, TMP0, TMP0 + | add RD, RD, TMP1 // hi = hi + exponent-1 + | and RD, RD, TMP0 // hi = x == 0 ? 0 : hi + | ins_next1 + | stwux RD, RA, BASE + | stw ZERO, 4(RA) + | ins_next2 + |.endif + break; + case BC_KNUM: + | // RA = dst*8, RD = num_const*8 + | ins_next1 + | lfdx f0, KBASE, RD + | stfdx f0, BASE, RA + | ins_next2 + break; + case BC_KPRI: + | // RA = dst*8, RD = primitive_type*8 (~) + | srwi TMP1, RD, 3 + | not TMP0, TMP1 + | ins_next1 + | stwx TMP0, BASE, RA + | ins_next2 + break; + case BC_KNIL: + | // RA = base*8, RD = end*8 + | stwx TISNIL, BASE, RA + | addi RA, RA, 8 + |1: + | stwx TISNIL, BASE, RA + | cmpw RA, RD + | addi RA, RA, 8 + | blt <1 + | ins_next_ + break; + + /* -- Upvalue and function ops ------------------------------------------ */ + + case BC_UGET: + | // RA = dst*8, RD = uvnum*8 + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RD, RD, 1 + | addi RD, RD, offsetof(GCfuncL, uvptr) + | lwzx UPVAL:RB, LFUNC:RB, RD + | ins_next1 + | lwz TMP1, UPVAL:RB->v + | lfd f0, 0(TMP1) + | stfdx f0, BASE, RA + | ins_next2 + break; + case BC_USETV: + | // RA = uvnum*8, RD = src*8 + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RA, RA, 1 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | lfdux f0, RD, BASE + | lwzx UPVAL:RB, LFUNC:RB, RA + | lbz TMP3, UPVAL:RB->marked + | lwz CARG2, UPVAL:RB->v + | andix. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) + | lbz TMP0, UPVAL:RB->closed + | lwz TMP2, 0(RD) + | stfd f0, 0(CARG2) + | cmplwi cr1, TMP0, 0 + | lwz TMP1, 4(RD) + | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq + | subi TMP2, TMP2, (LJ_TNUMX+1) + | bne >2 // Upvalue is closed and black? + |1: + | ins_next + | + |2: // Check if new value is collectable. + | cmplwi TMP2, LJ_TISGCV - (LJ_TNUMX+1) + | bge <1 // tvisgcv(v) + | lbz TMP3, GCOBJ:TMP1->gch.marked + | andix. TMP3, TMP3, LJ_GC_WHITES // iswhite(v) + | la CARG1, GG_DISP2G(DISPATCH) + | // Crossed a write barrier. Move the barrier forward. + | beq <1 + | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) + | b <1 + break; + case BC_USETS: + | // RA = uvnum*8, RD = str_const*8 (~) + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi TMP1, RD, 1 + | srwi RA, RA, 1 + | subfic TMP1, TMP1, -4 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | lwzx STR:TMP1, KBASE, TMP1 // KBASE-4-str_const*4 + | lwzx UPVAL:RB, LFUNC:RB, RA + | lbz TMP3, UPVAL:RB->marked + | lwz CARG2, UPVAL:RB->v + | andix. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) + | lbz TMP3, STR:TMP1->marked + | lbz TMP2, UPVAL:RB->closed + | li TMP0, LJ_TSTR + | stw STR:TMP1, 4(CARG2) + | stw TMP0, 0(CARG2) + | bne >2 + |1: + | ins_next + | + |2: // Check if string is white and ensure upvalue is closed. + | andix. TMP3, TMP3, LJ_GC_WHITES // iswhite(str) + | cmplwi cr1, TMP2, 0 + | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq + | la CARG1, GG_DISP2G(DISPATCH) + | // Crossed a write barrier. Move the barrier forward. + | beq <1 + | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) + | b <1 + break; + case BC_USETN: + | // RA = uvnum*8, RD = num_const*8 + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RA, RA, 1 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | lfdx f0, KBASE, RD + | lwzx UPVAL:RB, LFUNC:RB, RA + | ins_next1 + | lwz TMP1, UPVAL:RB->v + | stfd f0, 0(TMP1) + | ins_next2 + break; + case BC_USETP: + | // RA = uvnum*8, RD = primitive_type*8 (~) + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RA, RA, 1 + | srwi TMP0, RD, 3 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | not TMP0, TMP0 + | lwzx UPVAL:RB, LFUNC:RB, RA + | ins_next1 + | lwz TMP1, UPVAL:RB->v + | stw TMP0, 0(TMP1) + | ins_next2 + break; + + case BC_UCLO: + | // RA = level*8, RD = target + | lwz TMP1, L->openupval + | branch_RD // Do this first since RD is not saved. + | stp BASE, L->base + | cmplwi TMP1, 0 + | mr CARG1, L + | beq >1 + | add CARG2, BASE, RA + | bl extern lj_func_closeuv // (lua_State *L, TValue *level) + | lp BASE, L->base + |1: + | ins_next + break; + + case BC_FNEW: + | // RA = dst*8, RD = proto_const*8 (~) (holding function prototype) + | srwi TMP1, RD, 1 + | stp BASE, L->base + | subfic TMP1, TMP1, -4 + | stw PC, SAVE_PC + | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 + | mr CARG1, L + | lwz CARG3, FRAME_FUNC(BASE) + | // (lua_State *L, GCproto *pt, GCfuncL *parent) + | bl extern lj_func_newL_gc + | // Returns GCfuncL *. + | lp BASE, L->base + | li TMP0, LJ_TFUNC + | stwux TMP0, RA, BASE + | stw LFUNC:CRET1, 4(RA) + | ins_next + break; + + /* -- Table ops --------------------------------------------------------- */ + + case BC_TNEW: + case BC_TDUP: + | // RA = dst*8, RD = (hbits|asize)*8 | tab_const*8 (~) + | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) + | mr CARG1, L + | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) + | stp BASE, L->base + | cmplw TMP0, TMP1 + | stw PC, SAVE_PC + | bge >5 + |1: + if (op == BC_TNEW) { + | rlwinm CARG2, RD, 29, 21, 31 + | rlwinm CARG3, RD, 18, 27, 31 + | cmpwi CARG2, 0x7ff; beq >3 + |2: + | bl extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) + | // Returns Table *. + } else { + | srwi TMP1, RD, 1 + | subfic TMP1, TMP1, -4 + | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 + | bl extern lj_tab_dup // (lua_State *L, Table *kt) + | // Returns Table *. + } + | lp BASE, L->base + | li TMP0, LJ_TTAB + | stwux TMP0, RA, BASE + | stw TAB:CRET1, 4(RA) + | ins_next + if (op == BC_TNEW) { + |3: + | li CARG2, 0x801 + | b <2 + } + |5: + | mr SAVE0, RD + | bl extern lj_gc_step_fixtop // (lua_State *L) + | mr RD, SAVE0 + | mr CARG1, L + | b <1 + break; + + case BC_GGET: + | // RA = dst*8, RD = str_const*8 (~) + case BC_GSET: + | // RA = src*8, RD = str_const*8 (~) + | lwz LFUNC:TMP2, FRAME_FUNC(BASE) + | srwi TMP1, RD, 1 + | lwz TAB:RB, LFUNC:TMP2->env + | subfic TMP1, TMP1, -4 + | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 + if (op == BC_GGET) { + | b ->BC_TGETS_Z + } else { + | b ->BC_TSETS_Z + } + break; + + case BC_TGETV: + | // RA = dst*8, RB = table*8, RC = key*8 + | lwzux CARG1, RB, BASE + | lwzux CARG2, RC, BASE + | lwz TAB:RB, 4(RB) + |.if DUALNUM + | lwz RC, 4(RC) + |.else + | lfd f0, 0(RC) + |.endif + | checktab CARG1 + | checknum cr1, CARG2 + | bne ->vmeta_tgetv + |.if DUALNUM + | lwz TMP0, TAB:RB->asize + | bne cr1, >5 + | lwz TMP1, TAB:RB->array + | cmplw TMP0, RC + | slwi TMP2, RC, 3 + |.else + | bge cr1, >5 + | // Convert number key to integer, check for integerness and range. + | fctiwz f1, f0 + | fadd f2, f0, TOBIT + | stfd f1, TMPD + | lwz TMP0, TAB:RB->asize + | fsub f2, f2, TOBIT + | lwz TMP2, TMPD_LO + | lwz TMP1, TAB:RB->array + | fcmpu cr1, f0, f2 + | cmplw cr0, TMP0, TMP2 + | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+eq + | slwi TMP2, TMP2, 3 + |.endif + | ble ->vmeta_tgetv // Integer key and in array part? + | lwzx TMP0, TMP1, TMP2 + | lfdx f14, TMP1, TMP2 + | checknil TMP0; beq >2 + |1: + | ins_next1 + | stfdx f14, BASE, RA + | ins_next2 + | + |2: // Check for __index if table value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable: done. + | lbz TMP0, TAB:TMP2->nomm + | andix. TMP0, TMP0, 1<vmeta_tgetv + | + |5: + | checkstr CARG2; bne ->vmeta_tgetv + |.if not DUALNUM + | lwz STR:RC, 4(RC) + |.endif + | b ->BC_TGETS_Z // String key? + break; + case BC_TGETS: + | // RA = dst*8, RB = table*8, RC = str_const*8 (~) + | lwzux CARG1, RB, BASE + | srwi TMP1, RC, 1 + | lwz TAB:RB, 4(RB) + | subfic TMP1, TMP1, -4 + | checktab CARG1 + | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 + | bne ->vmeta_tgets1 + |->BC_TGETS_Z: + | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = dst*8 + | lwz TMP0, TAB:RB->hmask + | lwz TMP1, STR:RC->hash + | lwz NODE:TMP2, TAB:RB->node + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | slwi TMP0, TMP1, 5 + | slwi TMP1, TMP1, 3 + | sub TMP1, TMP0, TMP1 + | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + |1: + | lwz CARG1, NODE:TMP2->key + | lwz TMP0, 4+offsetof(Node, key)(NODE:TMP2) + | lwz CARG2, NODE:TMP2->val + | lwz TMP1, 4+offsetof(Node, val)(NODE:TMP2) + | checkstr CARG1; bne >4 + | cmpw TMP0, STR:RC; bne >4 + | checknil CARG2; beq >5 // Key found, but nil value? + |3: + | stwux CARG2, RA, BASE + | stw TMP1, 4(RA) + | ins_next + | + |4: // Follow hash chain. + | lwz NODE:TMP2, NODE:TMP2->next + | cmplwi NODE:TMP2, 0 + | bne <1 + | // End of hash chain: key not found, nil result. + | li CARG2, LJ_TNIL + | + |5: // Check for __index if table value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <3 // No metatable: done. + | lbz TMP0, TAB:TMP2->nomm + | andix. TMP0, TMP0, 1<vmeta_tgets + break; + case BC_TGETB: + | // RA = dst*8, RB = table*8, RC = index*8 + | lwzux CARG1, RB, BASE + | srwi TMP0, RC, 3 + | lwz TAB:RB, 4(RB) + | checktab CARG1; bne ->vmeta_tgetb + | lwz TMP1, TAB:RB->asize + | lwz TMP2, TAB:RB->array + | cmplw TMP0, TMP1; bge ->vmeta_tgetb + | lwzx TMP1, TMP2, RC + | lfdx f0, TMP2, RC + | checknil TMP1; beq >5 + |1: + | ins_next1 + | stfdx f0, BASE, RA + | ins_next2 + | + |5: // Check for __index if table value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable: done. + | lbz TMP2, TAB:TMP2->nomm + | andix. TMP2, TMP2, 1<vmeta_tgetb // Caveat: preserve TMP0! + break; + + case BC_TSETV: + | // RA = src*8, RB = table*8, RC = key*8 + | lwzux CARG1, RB, BASE + | lwzux CARG2, RC, BASE + | lwz TAB:RB, 4(RB) + |.if DUALNUM + | lwz RC, 4(RC) + |.else + | lfd f0, 0(RC) + |.endif + | checktab CARG1 + | checknum cr1, CARG2 + | bne ->vmeta_tsetv + |.if DUALNUM + | lwz TMP0, TAB:RB->asize + | bne cr1, >5 + | lwz TMP1, TAB:RB->array + | cmplw TMP0, RC + | slwi TMP0, RC, 3 + |.else + | bge cr1, >5 + | // Convert number key to integer, check for integerness and range. + | fctiwz f1, f0 + | fadd f2, f0, TOBIT + | stfd f1, TMPD + | lwz TMP0, TAB:RB->asize + | fsub f2, f2, TOBIT + | lwz TMP2, TMPD_LO + | lwz TMP1, TAB:RB->array + | fcmpu cr1, f0, f2 + | cmplw cr0, TMP0, TMP2 + | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+eq + | slwi TMP0, TMP2, 3 + |.endif + | ble ->vmeta_tsetv // Integer key and in array part? + | lwzx TMP2, TMP1, TMP0 + | lbz TMP3, TAB:RB->marked + | lfdx f14, BASE, RA + | checknil TMP2; beq >3 + |1: + | andix. TMP2, TMP3, LJ_GC_BLACK // isblack(table) + | stfdx f14, TMP1, TMP0 + | bne >7 + |2: + | ins_next + | + |3: // Check for __newindex if previous value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable: done. + | lbz TMP2, TAB:TMP2->nomm + | andix. TMP2, TMP2, 1<vmeta_tsetv + | + |5: + | checkstr CARG2; bne ->vmeta_tsetv + |.if not DUALNUM + | lwz STR:RC, 4(RC) + |.endif + | b ->BC_TSETS_Z // String key? + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0 + | b <2 + break; + case BC_TSETS: + | // RA = src*8, RB = table*8, RC = str_const*8 (~) + | lwzux CARG1, RB, BASE + | srwi TMP1, RC, 1 + | lwz TAB:RB, 4(RB) + | subfic TMP1, TMP1, -4 + | checktab CARG1 + | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 + | bne ->vmeta_tsets1 + |->BC_TSETS_Z: + | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = src*8 + | lwz TMP0, TAB:RB->hmask + | lwz TMP1, STR:RC->hash + | lwz NODE:TMP2, TAB:RB->node + | stb ZERO, TAB:RB->nomm // Clear metamethod cache. + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | lfdx f14, BASE, RA + | slwi TMP0, TMP1, 5 + | slwi TMP1, TMP1, 3 + | sub TMP1, TMP0, TMP1 + | lbz TMP3, TAB:RB->marked + | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + |1: + | lwz CARG1, NODE:TMP2->key + | lwz TMP0, 4+offsetof(Node, key)(NODE:TMP2) + | lwz CARG2, NODE:TMP2->val + | lwz NODE:TMP1, NODE:TMP2->next + | checkstr CARG1; bne >5 + | cmpw TMP0, STR:RC; bne >5 + | checknil CARG2; beq >4 // Key found, but nil value? + |2: + | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + | stfd f14, NODE:TMP2->val + | bne >7 + |3: + | ins_next + | + |4: // Check for __newindex if previous value is nil. + | lwz TAB:TMP1, TAB:RB->metatable + | cmplwi TAB:TMP1, 0 + | beq <2 // No metatable: done. + | lbz TMP0, TAB:TMP1->nomm + | andix. TMP0, TMP0, 1<vmeta_tsets + | + |5: // Follow hash chain. + | cmplwi NODE:TMP1, 0 + | mr NODE:TMP2, NODE:TMP1 + | bne <1 + | // End of hash chain: key not found, add a new one. + | + | // But check for __newindex first. + | lwz TAB:TMP1, TAB:RB->metatable + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | stw PC, SAVE_PC + | mr CARG1, L + | cmplwi TAB:TMP1, 0 + | stp BASE, L->base + | beq >6 // No metatable: continue. + | lbz TMP0, TAB:TMP1->nomm + | andix. TMP0, TMP0, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. + |6: + | li TMP0, LJ_TSTR + | stw STR:RC, 4(CARG3) + | mr CARG2, TAB:RB + | stw TMP0, 0(CARG3) + | bl extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) + | // Returns TValue *. + | lp BASE, L->base + | stfd f14, 0(CRET1) + | b <3 // No 2nd write barrier needed. + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0 + | b <3 + break; + case BC_TSETB: + | // RA = src*8, RB = table*8, RC = index*8 + | lwzux CARG1, RB, BASE + | srwi TMP0, RC, 3 + | lwz TAB:RB, 4(RB) + | checktab CARG1; bne ->vmeta_tsetb + | lwz TMP1, TAB:RB->asize + | lwz TMP2, TAB:RB->array + | lbz TMP3, TAB:RB->marked + | cmplw TMP0, TMP1 + | lfdx f14, BASE, RA + | bge ->vmeta_tsetb + | lwzx TMP1, TMP2, RC + | checknil TMP1; beq >5 + |1: + | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + | stfdx f14, TMP2, RC + | bne >7 + |2: + | ins_next + | + |5: // Check for __newindex if previous value is nil. + | lwz TAB:TMP1, TAB:RB->metatable + | cmplwi TAB:TMP1, 0 + | beq <1 // No metatable: done. + | lbz TMP1, TAB:TMP1->nomm + | andix. TMP1, TMP1, 1<vmeta_tsetb // Caveat: preserve TMP0! + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0 + | b <2 + break; + + case BC_TSETM: + | // RA = base*8 (table at base-1), RD = num_const*8 (start index) + | add RA, BASE, RA + |1: + | add TMP3, KBASE, RD + | lwz TAB:CARG2, -4(RA) // Guaranteed to be a table. + | addic. TMP0, MULTRES, -8 + | lwz TMP3, 4(TMP3) // Integer constant is in lo-word. + | srwi CARG3, TMP0, 3 + | beq >4 // Nothing to copy? + | add CARG3, CARG3, TMP3 + | lwz TMP2, TAB:CARG2->asize + | slwi TMP1, TMP3, 3 + | lbz TMP3, TAB:CARG2->marked + | cmplw CARG3, TMP2 + | add TMP2, RA, TMP0 + | lwz TMP0, TAB:CARG2->array + | bgt >5 + | add TMP1, TMP1, TMP0 + | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + |3: // Copy result slots to table. + | lfd f0, 0(RA) + | addi RA, RA, 8 + | cmpw cr1, RA, TMP2 + | stfd f0, 0(TMP1) + | addi TMP1, TMP1, 8 + | blt cr1, <3 + | bne >7 + |4: + | ins_next + | + |5: // Need to resize array part. + | stp BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | mr SAVE0, RD + | bl extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) + | // Must not reallocate the stack. + | mr RD, SAVE0 + | b <1 + | + |7: // Possible table write barrier for any value. Skip valiswhite check. + | barrierback TAB:CARG2, TMP3, TMP0 + | b <4 + break; + + /* -- Calls and vararg handling ----------------------------------------- */ + + case BC_CALLM: + | // RA = base*8, (RB = (nresults+1)*8,) RC = extra_nargs*8 + | add NARGS8:RC, NARGS8:RC, MULTRES + | // Fall through. Assumes BC_CALL follows. + break; + case BC_CALL: + | // RA = base*8, (RB = (nresults+1)*8,) RC = (nargs+1)*8 + | mr TMP2, BASE + | lwzux TMP0, BASE, RA + | lwz LFUNC:RB, 4(BASE) + | subi NARGS8:RC, NARGS8:RC, 8 + | addi BASE, BASE, 8 + | checkfunc TMP0; bne ->vmeta_call + | ins_call + break; + + case BC_CALLMT: + | // RA = base*8, (RB = 0,) RC = extra_nargs*8 + | add NARGS8:RC, NARGS8:RC, MULTRES + | // Fall through. Assumes BC_CALLT follows. + break; + case BC_CALLT: + | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 + | lwzux TMP0, RA, BASE + | lwz LFUNC:RB, 4(RA) + | subi NARGS8:RC, NARGS8:RC, 8 + | lwz TMP1, FRAME_PC(BASE) + | checkfunc TMP0 + | addi RA, RA, 8 + | bne ->vmeta_callt + |->BC_CALLT_Z: + | andix. TMP0, TMP1, FRAME_TYPE // Caveat: preserve cr0 until the crand. + | lbz TMP3, LFUNC:RB->ffid + | xori TMP2, TMP1, FRAME_VARG + | cmplwi cr1, NARGS8:RC, 0 + | bne >7 + |1: + | stw LFUNC:RB, FRAME_FUNC(BASE) // Copy function down, but keep PC. + | li TMP2, 0 + | cmplwi cr7, TMP3, 1 // (> FF_C) Calling a fast function? + | beq cr1, >3 + |2: + | addi TMP3, TMP2, 8 + | lfdx f0, RA, TMP2 + | cmplw cr1, TMP3, NARGS8:RC + | stfdx f0, BASE, TMP2 + | mr TMP2, TMP3 + | bne cr1, <2 + |3: + | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+gt + | beq >5 + |4: + | ins_callt + | + |5: // Tailcall to a fast function with a Lua frame below. + | lwz INS, -4(TMP1) + | decode_RA8 RA, INS + | sub TMP1, BASE, RA + | lwz LFUNC:TMP1, FRAME_FUNC-8(TMP1) + | lwz TMP1, LFUNC:TMP1->pc + | lwz KBASE, PC2PROTO(k)(TMP1) // Need to prepare KBASE. + | b <4 + | + |7: // Tailcall from a vararg function. + | andix. TMP0, TMP2, FRAME_TYPEP + | bne <1 // Vararg frame below? + | sub BASE, BASE, TMP2 // Relocate BASE down. + | lwz TMP1, FRAME_PC(BASE) + | andix. TMP0, TMP1, FRAME_TYPE + | b <1 + break; + + case BC_ITERC: + | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 ((2+1)*8)) + | mr TMP2, BASE + | add BASE, BASE, RA + | lwz TMP1, -24(BASE) + | lwz LFUNC:RB, -20(BASE) + | lfd f1, -8(BASE) + | lfd f0, -16(BASE) + | stw TMP1, 0(BASE) // Copy callable. + | stw LFUNC:RB, 4(BASE) + | checkfunc TMP1 + | stfd f1, 16(BASE) // Copy control var. + | li NARGS8:RC, 16 // Iterators get 2 arguments. + | stfdu f0, 8(BASE) // Copy state. + | bne ->vmeta_call + | ins_call + break; + + case BC_ITERN: + | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 (2+1)*8) + |.if JIT + | // NYI: add hotloop, record BC_ITERN. + |.endif + | add RA, BASE, RA + | lwz TAB:RB, -12(RA) + | lwz RC, -4(RA) // Get index from control var. + | lwz TMP0, TAB:RB->asize + | lwz TMP1, TAB:RB->array + | addi PC, PC, 4 + |1: // Traverse array part. + | cmplw RC, TMP0 + | slwi TMP3, RC, 3 + | bge >5 // Index points after array part? + | lwzx TMP2, TMP1, TMP3 + | lfdx f0, TMP1, TMP3 + | checknil TMP2 + | lwz INS, -4(PC) + | beq >4 + |.if DUALNUM + | stw RC, 4(RA) + | stw TISNUM, 0(RA) + |.else + | tonum_u f1, RC + |.endif + | addi RC, RC, 1 + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | stfd f0, 8(RA) + | decode_RD4 TMP1, INS + | stw RC, -4(RA) // Update control var. + | add PC, TMP1, TMP3 + |.if not DUALNUM + | stfd f1, 0(RA) + |.endif + |3: + | ins_next + | + |4: // Skip holes in array part. + | addi RC, RC, 1 + | b <1 + | + |5: // Traverse hash part. + | lwz TMP1, TAB:RB->hmask + | sub RC, RC, TMP0 + | lwz TMP2, TAB:RB->node + |6: + | cmplw RC, TMP1 // End of iteration? Branch to ITERL+1. + | slwi TMP3, RC, 5 + | bgty <3 + | slwi RB, RC, 3 + | sub TMP3, TMP3, RB + | lwzx RB, TMP2, TMP3 + | lfdx f0, TMP2, TMP3 + | add NODE:TMP3, TMP2, TMP3 + | checknil RB + | lwz INS, -4(PC) + | beq >7 + | lfd f1, NODE:TMP3->key + | addis TMP2, PC, -(BCBIAS_J*4 >> 16) + | stfd f0, 8(RA) + | add RC, RC, TMP0 + | decode_RD4 TMP1, INS + | stfd f1, 0(RA) + | addi RC, RC, 1 + | add PC, TMP1, TMP2 + | stw RC, -4(RA) // Update control var. + | b <3 + | + |7: // Skip holes in hash part. + | addi RC, RC, 1 + | b <6 + break; + + case BC_ISNEXT: + | // RA = base*8, RD = target (points to ITERN) + | add RA, BASE, RA + | lwz TMP0, -24(RA) + | lwz CFUNC:TMP1, -20(RA) + | lwz TMP2, -16(RA) + | lwz TMP3, -8(RA) + | cmpwi cr0, TMP2, LJ_TTAB + | cmpwi cr1, TMP0, LJ_TFUNC + | cmpwi cr6, TMP3, LJ_TNIL + | bne cr1, >5 + | lbz TMP1, CFUNC:TMP1->ffid + | crand 4*cr0+eq, 4*cr0+eq, 4*cr6+eq + | cmpwi cr7, TMP1, FF_next_N + | srwi TMP0, RD, 1 + | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq + | add TMP3, PC, TMP0 + | bne cr0, >5 + | lus TMP1, 0xfffe + | ori TMP1, TMP1, 0x7fff + | stw ZERO, -4(RA) // Initialize control var. + | stw TMP1, -8(RA) + | addis PC, TMP3, -(BCBIAS_J*4 >> 16) + |1: + | ins_next + |5: // Despecialize bytecode if any of the checks fail. + | li TMP0, BC_JMP + | li TMP1, BC_ITERC + | stb TMP0, -1(PC) + | addis PC, TMP3, -(BCBIAS_J*4 >> 16) + | stb TMP1, 3(PC) + | b <1 + break; + + case BC_VARG: + | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 + | lwz TMP0, FRAME_PC(BASE) + | add RC, BASE, RC + | add RA, BASE, RA + | addi RC, RC, FRAME_VARG + | add TMP2, RA, RB + | subi TMP3, BASE, 8 // TMP3 = vtop + | sub RC, RC, TMP0 // RC = vbase + | // Note: RC may now be even _above_ BASE if nargs was < numparams. + | cmplwi cr1, RB, 0 + |.if PPE + | sub TMP1, TMP3, RC + | cmpwi TMP1, 0 + |.else + | sub. TMP1, TMP3, RC + |.endif + | beq cr1, >5 // Copy all varargs? + | subi TMP2, TMP2, 16 + | ble >2 // No vararg slots? + |1: // Copy vararg slots to destination slots. + | lfd f0, 0(RC) + | addi RC, RC, 8 + | stfd f0, 0(RA) + | cmplw RA, TMP2 + | cmplw cr1, RC, TMP3 + | bge >3 // All destination slots filled? + | addi RA, RA, 8 + | blt cr1, <1 // More vararg slots? + |2: // Fill up remainder with nil. + | stw TISNIL, 0(RA) + | cmplw RA, TMP2 + | addi RA, RA, 8 + | blt <2 + |3: + | ins_next + | + |5: // Copy all varargs. + | lwz TMP0, L->maxstack + | li MULTRES, 8 // MULTRES = (0+1)*8 + | bley <3 // No vararg slots? + | add TMP2, RA, TMP1 + | cmplw TMP2, TMP0 + | addi MULTRES, TMP1, 8 + | bgt >7 + |6: + | lfd f0, 0(RC) + | addi RC, RC, 8 + | stfd f0, 0(RA) + | cmplw RC, TMP3 + | addi RA, RA, 8 + | blt <6 // More vararg slots? + | b <3 + | + |7: // Grow stack for varargs. + | mr CARG1, L + | stp RA, L->top + | sub SAVE0, RC, BASE // Need delta, because BASE may change. + | stp BASE, L->base + | sub RA, RA, BASE + | stw PC, SAVE_PC + | srwi CARG2, TMP1, 3 + | bl extern lj_state_growstack // (lua_State *L, int n) + | lp BASE, L->base + | add RA, BASE, RA + | add RC, BASE, SAVE0 + | subi TMP3, BASE, 8 + | b <6 + break; + + /* -- Returns ----------------------------------------------------------- */ + + case BC_RETM: + | // RA = results*8, RD = extra_nresults*8 + | add RD, RD, MULTRES // MULTRES >= 8, so RD >= 8. + | // Fall through. Assumes BC_RET follows. + break; + + case BC_RET: + | // RA = results*8, RD = (nresults+1)*8 + | lwz PC, FRAME_PC(BASE) + | add RA, BASE, RA + | mr MULTRES, RD + |1: + | andix. TMP0, PC, FRAME_TYPE + | xori TMP1, PC, FRAME_VARG + | bne ->BC_RETV_Z + | + |->BC_RET_Z: + | // BASE = base, RA = resultptr, RD = (nresults+1)*8, PC = return + | lwz INS, -4(PC) + | cmpwi RD, 8 + | subi TMP2, BASE, 8 + | subi RC, RD, 8 + | decode_RB8 RB, INS + | beq >3 + | li TMP1, 0 + |2: + | addi TMP3, TMP1, 8 + | lfdx f0, RA, TMP1 + | cmpw TMP3, RC + | stfdx f0, TMP2, TMP1 + | beq >3 + | addi TMP1, TMP3, 8 + | lfdx f1, RA, TMP3 + | cmpw TMP1, RC + | stfdx f1, TMP2, TMP3 + | bne <2 + |3: + |5: + | cmplw RB, RD + | decode_RA8 RA, INS + | bgt >6 + | sub BASE, TMP2, RA + | lwz LFUNC:TMP1, FRAME_FUNC(BASE) + | ins_next1 + | lwz TMP1, LFUNC:TMP1->pc + | lwz KBASE, PC2PROTO(k)(TMP1) + | ins_next2 + | + |6: // Fill up results with nil. + | subi TMP1, RD, 8 + | addi RD, RD, 8 + | stwx TISNIL, TMP2, TMP1 + | b <5 + | + |->BC_RETV_Z: // Non-standard return case. + | andix. TMP2, TMP1, FRAME_TYPEP + | bne ->vm_return + | // Return from vararg function: relocate BASE down. + | sub BASE, BASE, TMP1 + | lwz PC, FRAME_PC(BASE) + | b <1 + break; + + case BC_RET0: case BC_RET1: + | // RA = results*8, RD = (nresults+1)*8 + | lwz PC, FRAME_PC(BASE) + | add RA, BASE, RA + | mr MULTRES, RD + | andix. TMP0, PC, FRAME_TYPE + | xori TMP1, PC, FRAME_VARG + | bney ->BC_RETV_Z + | + | lwz INS, -4(PC) + | subi TMP2, BASE, 8 + | decode_RB8 RB, INS + if (op == BC_RET1) { + | lfd f0, 0(RA) + | stfd f0, 0(TMP2) + } + |5: + | cmplw RB, RD + | decode_RA8 RA, INS + | bgt >6 + | sub BASE, TMP2, RA + | lwz LFUNC:TMP1, FRAME_FUNC(BASE) + | ins_next1 + | lwz TMP1, LFUNC:TMP1->pc + | lwz KBASE, PC2PROTO(k)(TMP1) + | ins_next2 + | + |6: // Fill up results with nil. + | subi TMP1, RD, 8 + | addi RD, RD, 8 + | stwx TISNIL, TMP2, TMP1 + | b <5 + break; + + /* -- Loops and branches ------------------------------------------------ */ + + case BC_FORL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IFORL follows. + break; + + case BC_JFORI: + case BC_JFORL: +#if !LJ_HASJIT + break; +#endif + case BC_FORI: + case BC_IFORL: + | // RA = base*8, RD = target (after end of loop or start of loop) + vk = (op == BC_IFORL || op == BC_JFORL); + |.if DUALNUM + | // Integer loop. + | lwzux TMP1, RA, BASE + | lwz CARG1, FORL_IDX*8+4(RA) + | cmplw cr0, TMP1, TISNUM + if (vk) { + | lwz CARG3, FORL_STEP*8+4(RA) + | bne >9 + |.if GPR64 + | // Need to check overflow for (a<<32) + (b<<32). + | rldicr TMP0, CARG1, 32, 31 + | rldicr TMP2, CARG3, 32, 31 + | add CARG1, CARG1, CARG3 + | addo. TMP0, TMP0, TMP2 + |.else + | addo. CARG1, CARG1, CARG3 + |.endif + | cmpwi cr6, CARG3, 0 + | lwz CARG2, FORL_STOP*8+4(RA) + | bso >6 + |4: + | stw CARG1, FORL_IDX*8+4(RA) + } else { + | lwz TMP3, FORL_STEP*8(RA) + | lwz CARG3, FORL_STEP*8+4(RA) + | lwz TMP2, FORL_STOP*8(RA) + | lwz CARG2, FORL_STOP*8+4(RA) + | cmplw cr7, TMP3, TISNUM + | cmplw cr1, TMP2, TISNUM + | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq + | crand 4*cr0+eq, 4*cr0+eq, 4*cr1+eq + | cmpwi cr6, CARG3, 0 + | bne >9 + } + | blt cr6, >5 + | cmpw CARG1, CARG2 + |1: + | stw TISNUM, FORL_EXT*8(RA) + if (op != BC_JFORL) { + | srwi RD, RD, 1 + } + | stw CARG1, FORL_EXT*8+4(RA) + if (op != BC_JFORL) { + | add RD, PC, RD + } + if (op == BC_FORI) { + | bgt >3 // See FP loop below. + } else if (op == BC_JFORI) { + | addis PC, RD, -(BCBIAS_J*4 >> 16) + | bley >7 + } else if (op == BC_IFORL) { + | bgt >2 + | addis PC, RD, -(BCBIAS_J*4 >> 16) + } else { + | bley =>BC_JLOOP + } + |2: + | ins_next + |5: // Invert check for negative step. + | cmpw CARG2, CARG1 + | b <1 + if (vk) { + |6: // Potential overflow. + | checkov TMP0, <4 // Ignore unrelated overflow. + | b <2 + } + |.endif + if (vk) { + |.if DUALNUM + |9: // FP loop. + | lfd f1, FORL_IDX*8(RA) + |.else + | lfdux f1, RA, BASE + |.endif + | lfd f3, FORL_STEP*8(RA) + | lfd f2, FORL_STOP*8(RA) + | lwz TMP3, FORL_STEP*8(RA) + | fadd f1, f1, f3 + | stfd f1, FORL_IDX*8(RA) + } else { + |.if DUALNUM + |9: // FP loop. + |.else + | lwzux TMP1, RA, BASE + | lwz TMP3, FORL_STEP*8(RA) + | lwz TMP2, FORL_STOP*8(RA) + | cmplw cr0, TMP1, TISNUM + | cmplw cr7, TMP3, TISNUM + | cmplw cr1, TMP2, TISNUM + |.endif + | lfd f1, FORL_IDX*8(RA) + | crand 4*cr0+lt, 4*cr0+lt, 4*cr7+lt + | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | lfd f2, FORL_STOP*8(RA) + | bge ->vmeta_for + } + | cmpwi cr6, TMP3, 0 + if (op != BC_JFORL) { + | srwi RD, RD, 1 + } + | stfd f1, FORL_EXT*8(RA) + if (op != BC_JFORL) { + | add RD, PC, RD + } + | fcmpu cr0, f1, f2 + if (op == BC_JFORI) { + | addis PC, RD, -(BCBIAS_J*4 >> 16) + } + | blt cr6, >5 + if (op == BC_FORI) { + | bgt >3 + } else if (op == BC_IFORL) { + |.if DUALNUM + | bgty <2 + |.else + | bgt >2 + |.endif + |1: + | addis PC, RD, -(BCBIAS_J*4 >> 16) + } else if (op == BC_JFORI) { + | bley >7 + } else { + | bley =>BC_JLOOP + } + |.if DUALNUM + | b <2 + |.else + |2: + | ins_next + |.endif + |5: // Negative step. + if (op == BC_FORI) { + | bge <2 + |3: // Used by integer loop, too. + | addis PC, RD, -(BCBIAS_J*4 >> 16) + } else if (op == BC_IFORL) { + | bgey <1 + } else if (op == BC_JFORI) { + | bgey >7 + } else { + | bgey =>BC_JLOOP + } + | b <2 + if (op == BC_JFORI) { + |7: + | lwz INS, -4(PC) + | decode_RD8 RD, INS + | b =>BC_JLOOP + } + break; + + case BC_ITERL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IITERL follows. + break; + + case BC_JITERL: +#if !LJ_HASJIT + break; +#endif + case BC_IITERL: + | // RA = base*8, RD = target + | lwzux TMP1, RA, BASE + | lwz TMP2, 4(RA) + | checknil TMP1; beq >1 // Stop if iterator returned nil. + if (op == BC_JITERL) { + | stw TMP1, -8(RA) + | stw TMP2, -4(RA) + | b =>BC_JLOOP + } else { + | branch_RD // Otherwise save control var + branch. + | stw TMP1, -8(RA) + | stw TMP2, -4(RA) + } + |1: + | ins_next + break; + + case BC_LOOP: + | // RA = base*8, RD = target (loop extent) + | // Note: RA/RD is only used by trace recorder to determine scope/extent + | // This opcode does NOT jump, it's only purpose is to detect a hot loop. + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_ILOOP follows. + break; + + case BC_ILOOP: + | // RA = base*8, RD = target (loop extent) + | ins_next + break; + + case BC_JLOOP: + |.if JIT + | // RA = base*8 (ignored), RD = traceno*8 + | lwz TMP1, DISPATCH_J(trace)(DISPATCH) + | srwi RD, RD, 1 + | // Traces on PPC don't store the trace number, so use 0. + | stw ZERO, DISPATCH_GL(vmstate)(DISPATCH) + | lwzx TRACE:TMP2, TMP1, RD + | clrso TMP1 + | lp TMP2, TRACE:TMP2->mcode + | stw BASE, DISPATCH_GL(jit_base)(DISPATCH) + | mtctr TMP2 + | stw L, DISPATCH_GL(jit_L)(DISPATCH) + | addi JGL, DISPATCH, GG_DISP2G+32768 + | bctr + |.endif + break; + + case BC_JMP: + | // RA = base*8 (only used by trace recorder), RD = target + | branch_RD + | ins_next + break; + + /* -- Function headers -------------------------------------------------- */ + + case BC_FUNCF: + |.if JIT + | hotcall + |.endif + case BC_FUNCV: /* NYI: compiled vararg functions. */ + | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. + break; + + case BC_JFUNCF: +#if !LJ_HASJIT + break; +#endif + case BC_IFUNCF: + | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 + | lwz TMP2, L->maxstack + | lbz TMP1, -4+PC2PROTO(numparams)(PC) + | lwz KBASE, -4+PC2PROTO(k)(PC) + | cmplw RA, TMP2 + | slwi TMP1, TMP1, 3 + | bgt ->vm_growstack_l + if (op != BC_JFUNCF) { + | ins_next1 + } + |2: + | cmplw NARGS8:RC, TMP1 // Check for missing parameters. + | blt >3 + if (op == BC_JFUNCF) { + | decode_RD8 RD, INS + | b =>BC_JLOOP + } else { + | ins_next2 + } + | + |3: // Clear missing parameters. + | stwx TISNIL, BASE, NARGS8:RC + | addi NARGS8:RC, NARGS8:RC, 8 + | b <2 + break; + + case BC_JFUNCV: +#if !LJ_HASJIT + break; +#endif + | NYI // NYI: compiled vararg functions + break; /* NYI: compiled vararg functions. */ + + case BC_IFUNCV: + | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 + | lwz TMP2, L->maxstack + | add TMP1, BASE, RC + | add TMP0, RA, RC + | stw LFUNC:RB, 4(TMP1) // Store copy of LFUNC. + | addi TMP3, RC, 8+FRAME_VARG + | lwz KBASE, -4+PC2PROTO(k)(PC) + | cmplw TMP0, TMP2 + | stw TMP3, 0(TMP1) // Store delta + FRAME_VARG. + | bge ->vm_growstack_l + | lbz TMP2, -4+PC2PROTO(numparams)(PC) + | mr RA, BASE + | mr RC, TMP1 + | ins_next1 + | cmpwi TMP2, 0 + | addi BASE, TMP1, 8 + | beq >3 + |1: + | cmplw RA, RC // Less args than parameters? + | lwz TMP0, 0(RA) + | lwz TMP3, 4(RA) + | bge >4 + | stw TISNIL, 0(RA) // Clear old fixarg slot (help the GC). + | addi RA, RA, 8 + |2: + | addic. TMP2, TMP2, -1 + | stw TMP0, 8(TMP1) + | stw TMP3, 12(TMP1) + | addi TMP1, TMP1, 8 + | bne <1 + |3: + | ins_next2 + | + |4: // Clear missing parameters. + | li TMP0, LJ_TNIL + | b <2 + break; + + case BC_FUNCC: + case BC_FUNCCW: + | // BASE = new base, RA = BASE+framesize*8, RB = CFUNC, RC = nargs*8 + if (op == BC_FUNCC) { + | lp RD, CFUNC:RB->f + } else { + | lp RD, DISPATCH_GL(wrapf)(DISPATCH) + } + | add TMP1, RA, NARGS8:RC + | lwz TMP2, L->maxstack + | .toc lp TMP3, 0(RD) + | add RC, BASE, NARGS8:RC + | stp BASE, L->base + | cmplw TMP1, TMP2 + | stp RC, L->top + | li_vmstate C + |.if TOC + | mtctr TMP3 + |.else + | mtctr RD + |.endif + if (op == BC_FUNCCW) { + | lp CARG2, CFUNC:RB->f + } + | mr CARG1, L + | bgt ->vm_growstack_c // Need to grow stack. + | .toc lp TOCREG, TOC_OFS(RD) + | .tocenv lp ENVREG, ENV_OFS(RD) + | st_vmstate + | bctrl // (lua_State *L [, lua_CFunction f]) + | // Returns nresults. + | lp BASE, L->base + | .toc ld TOCREG, SAVE_TOC + | slwi RD, CRET1, 3 + | lp TMP1, L->top + | li_vmstate INTERP + | lwz PC, FRAME_PC(BASE) // Fetch PC of caller. + | sub RA, TMP1, RD // RA = L->top - nresults*8 + | st_vmstate + | b ->vm_returnc + break; + + /* ---------------------------------------------------------------------- */ + + default: + fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); + exit(2); + break; + } +} + +static int build_backend(BuildCtx *ctx) +{ + int op; + + dasm_growpc(Dst, BC__MAX); + + build_subroutines(ctx); + + |.code_op + for (op = 0; op < BC__MAX; op++) + build_ins(ctx, (BCOp)op, op); + + return BC__MAX; +} + +/* Emit pseudo frame-info for all assembler functions. */ +static void emit_asm_debug(BuildCtx *ctx) +{ + int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); + int i; + switch (ctx->mode) { + case BUILD_elfasm: + fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); + fprintf(ctx->fp, + ".Lframe0:\n" + "\t.long .LECIE0-.LSCIE0\n" + ".LSCIE0:\n" + "\t.long 0xffffffff\n" + "\t.byte 0x1\n" + "\t.string \"\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 65\n" + "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE0:\n\n"); + fprintf(ctx->fp, + ".LSFDE0:\n" + "\t.long .LEFDE0-.LASFDE0\n" + ".LASFDE0:\n" + "\t.long .Lframe0\n" + "\t.long .Lbegin\n" + "\t.long %d\n" + "\t.byte 0xe\n\t.uleb128 %d\n" + "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" + "\t.byte 0x5\n\t.uleb128 70\n\t.uleb128 55\n", + fcofs, CFRAME_SIZE); + for (i = 14; i <= 31; i++) + fprintf(ctx->fp, + "\t.byte %d\n\t.uleb128 %d\n" + "\t.byte %d\n\t.uleb128 %d\n", + 0x80+i, 37+(31-i), 0x80+32+i, 2+2*(31-i)); + fprintf(ctx->fp, + "\t.align 2\n" + ".LEFDE0:\n\n"); +#if LJ_HASFFI + fprintf(ctx->fp, + ".LSFDE1:\n" + "\t.long .LEFDE1-.LASFDE1\n" + ".LASFDE1:\n" + "\t.long .Lframe0\n" +#if LJ_TARGET_PS3 + "\t.long .lj_vm_ffi_call\n" +#else + "\t.long lj_vm_ffi_call\n" +#endif + "\t.long %d\n" + "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" + "\t.byte 0x8e\n\t.uleb128 2\n" + "\t.byte 0xd\n\t.uleb128 0xe\n" + "\t.align 2\n" + ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); +#endif +#if !LJ_NO_UNWIND + fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); + fprintf(ctx->fp, + ".Lframe1:\n" + "\t.long .LECIE1-.LSCIE1\n" + ".LSCIE1:\n" + "\t.long 0\n" + "\t.byte 0x1\n" + "\t.string \"zPR\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 65\n" + "\t.uleb128 6\n" /* augmentation length */ + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.long lj_err_unwind_dwarf-.\n" + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE1:\n\n"); + fprintf(ctx->fp, + ".LSFDE2:\n" + "\t.long .LEFDE2-.LASFDE2\n" + ".LASFDE2:\n" + "\t.long .LASFDE2-.Lframe1\n" + "\t.long .Lbegin-.\n" + "\t.long %d\n" + "\t.uleb128 0\n" /* augmentation length */ + "\t.byte 0xe\n\t.uleb128 %d\n" + "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" + "\t.byte 0x5\n\t.uleb128 70\n\t.uleb128 55\n", + fcofs, CFRAME_SIZE); + for (i = 14; i <= 31; i++) + fprintf(ctx->fp, + "\t.byte %d\n\t.uleb128 %d\n" + "\t.byte %d\n\t.uleb128 %d\n", + 0x80+i, 37+(31-i), 0x80+32+i, 2+2*(31-i)); + fprintf(ctx->fp, + "\t.align 2\n" + ".LEFDE2:\n\n"); +#if LJ_HASFFI + fprintf(ctx->fp, + ".Lframe2:\n" + "\t.long .LECIE2-.LSCIE2\n" + ".LSCIE2:\n" + "\t.long 0\n" + "\t.byte 0x1\n" + "\t.string \"zR\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 65\n" + "\t.uleb128 1\n" /* augmentation length */ + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE2:\n\n"); + fprintf(ctx->fp, + ".LSFDE3:\n" + "\t.long .LEFDE3-.LASFDE3\n" + ".LASFDE3:\n" + "\t.long .LASFDE3-.Lframe2\n" + "\t.long lj_vm_ffi_call-.\n" + "\t.long %d\n" + "\t.uleb128 0\n" /* augmentation length */ + "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" + "\t.byte 0x8e\n\t.uleb128 2\n" + "\t.byte 0xd\n\t.uleb128 0xe\n" + "\t.align 2\n" + ".LEFDE3:\n\n", (int)ctx->codesz - fcofs); +#endif +#endif + break; + default: + break; + } +} + + +``` + +`include/luajit-2.0.5/src/vm_ppcspe.dasc`: + +```dasc +|// Low-level VM code for PowerPC/e500 CPUs. +|// Bytecode interpreter, fast functions and helper functions. +|// Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +| +|.arch ppc +|.section code_op, code_sub +| +|.actionlist build_actionlist +|.globals GLOB_ +|.globalnames globnames +|.externnames extnames +| +|// Note: The ragged indentation of the instructions is intentional. +|// The starting columns indicate data dependencies. +| +|//----------------------------------------------------------------------- +| +|// Fixed register assignments for the interpreter. +|// Don't use: r1 = sp, r2 and r13 = reserved and/or small data area ptr +| +|// The following must be C callee-save (but BASE is often refetched). +|.define BASE, r14 // Base of current Lua stack frame. +|.define KBASE, r15 // Constants of current Lua function. +|.define PC, r16 // Next PC. +|.define DISPATCH, r17 // Opcode dispatch table. +|.define LREG, r18 // Register holding lua_State (also in SAVE_L). +|.define MULTRES, r19 // Size of multi-result: (nresults+1)*8. +| +|// Constants for vectorized type-comparisons (hi+low GPR). C callee-save. +|.define TISNUM, r22 +|.define TISSTR, r23 +|.define TISTAB, r24 +|.define TISFUNC, r25 +|.define TISNIL, r26 +|.define TOBIT, r27 +|.define ZERO, TOBIT // Zero in lo word. +| +|// The following temporaries are not saved across C calls, except for RA. +|.define RA, r20 // Callee-save. +|.define RB, r10 +|.define RC, r11 +|.define RD, r12 +|.define INS, r7 // Overlaps CARG5. +| +|.define TMP0, r0 +|.define TMP1, r8 +|.define TMP2, r9 +|.define TMP3, r6 // Overlaps CARG4. +| +|// Saved temporaries. +|.define SAVE0, r21 +| +|// Calling conventions. +|.define CARG1, r3 +|.define CARG2, r4 +|.define CARG3, r5 +|.define CARG4, r6 // Overlaps TMP3. +|.define CARG5, r7 // Overlaps INS. +| +|.define CRET1, r3 +|.define CRET2, r4 +| +|// Stack layout while in interpreter. Must match with lj_frame.h. +|.define SAVE_LR, 188(sp) +|.define CFRAME_SPACE, 184 // Delta for sp. +|// Back chain for sp: 184(sp) <-- sp entering interpreter +|.define SAVE_r31, 176(sp) // 64 bit register saves. +|.define SAVE_r30, 168(sp) +|.define SAVE_r29, 160(sp) +|.define SAVE_r28, 152(sp) +|.define SAVE_r27, 144(sp) +|.define SAVE_r26, 136(sp) +|.define SAVE_r25, 128(sp) +|.define SAVE_r24, 120(sp) +|.define SAVE_r23, 112(sp) +|.define SAVE_r22, 104(sp) +|.define SAVE_r21, 96(sp) +|.define SAVE_r20, 88(sp) +|.define SAVE_r19, 80(sp) +|.define SAVE_r18, 72(sp) +|.define SAVE_r17, 64(sp) +|.define SAVE_r16, 56(sp) +|.define SAVE_r15, 48(sp) +|.define SAVE_r14, 40(sp) +|.define SAVE_CR, 36(sp) +|.define UNUSED1, 32(sp) +|.define SAVE_ERRF, 28(sp) // 32 bit C frame info. +|.define SAVE_NRES, 24(sp) +|.define SAVE_CFRAME, 20(sp) +|.define SAVE_L, 16(sp) +|.define SAVE_PC, 12(sp) +|.define SAVE_MULTRES, 8(sp) +|// Next frame lr: 4(sp) +|// Back chain for sp: 0(sp) <-- sp while in interpreter +| +|.macro save_, reg; evstdd reg, SAVE_..reg; .endmacro +|.macro rest_, reg; evldd reg, SAVE_..reg; .endmacro +| +|.macro saveregs +| stwu sp, -CFRAME_SPACE(sp) +| save_ r14; save_ r15; save_ r16; save_ r17; save_ r18; save_ r19 +| mflr r0; mfcr r12 +| save_ r20; save_ r21; save_ r22; save_ r23; save_ r24; save_ r25 +| stw r0, SAVE_LR; stw r12, SAVE_CR +| save_ r26; save_ r27; save_ r28; save_ r29; save_ r30; save_ r31 +|.endmacro +| +|.macro restoreregs +| lwz r0, SAVE_LR; lwz r12, SAVE_CR +| rest_ r14; rest_ r15; rest_ r16; rest_ r17; rest_ r18; rest_ r19 +| mtlr r0; mtcrf 0x38, r12 +| rest_ r20; rest_ r21; rest_ r22; rest_ r23; rest_ r24; rest_ r25 +| rest_ r26; rest_ r27; rest_ r28; rest_ r29; rest_ r30; rest_ r31 +| addi sp, sp, CFRAME_SPACE +|.endmacro +| +|// Type definitions. Some of these are only used for documentation. +|.type L, lua_State, LREG +|.type GL, global_State +|.type TVALUE, TValue +|.type GCOBJ, GCobj +|.type STR, GCstr +|.type TAB, GCtab +|.type LFUNC, GCfuncL +|.type CFUNC, GCfuncC +|.type PROTO, GCproto +|.type UPVAL, GCupval +|.type NODE, Node +|.type NARGS8, int +|.type TRACE, GCtrace +| +|//----------------------------------------------------------------------- +| +|// These basic macros should really be part of DynASM. +|.macro srwi, rx, ry, n; rlwinm rx, ry, 32-n, n, 31; .endmacro +|.macro slwi, rx, ry, n; rlwinm rx, ry, n, 0, 31-n; .endmacro +|.macro rotlwi, rx, ry, n; rlwinm rx, ry, n, 0, 31; .endmacro +|.macro rotlw, rx, ry, rn; rlwnm rx, ry, rn, 0, 31; .endmacro +|.macro subi, rx, ry, i; addi rx, ry, -i; .endmacro +| +|// Trap for not-yet-implemented parts. +|.macro NYI; tw 4, sp, sp; .endmacro +| +|//----------------------------------------------------------------------- +| +|// Access to frame relative to BASE. +|.define FRAME_PC, -8 +|.define FRAME_FUNC, -4 +| +|// Instruction decode. +|.macro decode_OP4, dst, ins; rlwinm dst, ins, 2, 22, 29; .endmacro +|.macro decode_RA8, dst, ins; rlwinm dst, ins, 27, 21, 28; .endmacro +|.macro decode_RB8, dst, ins; rlwinm dst, ins, 11, 21, 28; .endmacro +|.macro decode_RC8, dst, ins; rlwinm dst, ins, 19, 21, 28; .endmacro +|.macro decode_RD8, dst, ins; rlwinm dst, ins, 19, 13, 28; .endmacro +| +|.macro decode_OP1, dst, ins; rlwinm dst, ins, 0, 24, 31; .endmacro +|.macro decode_RD4, dst, ins; rlwinm dst, ins, 18, 14, 29; .endmacro +| +|// Instruction fetch. +|.macro ins_NEXT1 +| lwz INS, 0(PC) +| addi PC, PC, 4 +|.endmacro +|// Instruction decode+dispatch. +|.macro ins_NEXT2 +| decode_OP4 TMP1, INS +| decode_RB8 RB, INS +| decode_RD8 RD, INS +| lwzx TMP0, DISPATCH, TMP1 +| decode_RA8 RA, INS +| decode_RC8 RC, INS +| mtctr TMP0 +| bctr +|.endmacro +|.macro ins_NEXT +| ins_NEXT1 +| ins_NEXT2 +|.endmacro +| +|// Instruction footer. +|.if 1 +| // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. +| .define ins_next, ins_NEXT +| .define ins_next_, ins_NEXT +| .define ins_next1, ins_NEXT1 +| .define ins_next2, ins_NEXT2 +|.else +| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. +| // Affects only certain kinds of benchmarks (and only with -j off). +| .macro ins_next +| b ->ins_next +| .endmacro +| .macro ins_next1 +| .endmacro +| .macro ins_next2 +| b ->ins_next +| .endmacro +| .macro ins_next_ +| ->ins_next: +| ins_NEXT +| .endmacro +|.endif +| +|// Call decode and dispatch. +|.macro ins_callt +| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC +| lwz PC, LFUNC:RB->pc +| lwz INS, 0(PC) +| addi PC, PC, 4 +| decode_OP4 TMP1, INS +| decode_RA8 RA, INS +| lwzx TMP0, DISPATCH, TMP1 +| add RA, RA, BASE +| mtctr TMP0 +| bctr +|.endmacro +| +|.macro ins_call +| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, PC = caller PC +| stw PC, FRAME_PC(BASE) +| ins_callt +|.endmacro +| +|//----------------------------------------------------------------------- +| +|// Macros to test operand types. +|.macro checknum, reg; evcmpltu reg, TISNUM; .endmacro +|.macro checkstr, reg; evcmpeq reg, TISSTR; .endmacro +|.macro checktab, reg; evcmpeq reg, TISTAB; .endmacro +|.macro checkfunc, reg; evcmpeq reg, TISFUNC; .endmacro +|.macro checknil, reg; evcmpeq reg, TISNIL; .endmacro +|.macro checkok, label; blt label; .endmacro +|.macro checkfail, label; bge label; .endmacro +|.macro checkanyfail, label; bns label; .endmacro +|.macro checkallok, label; bso label; .endmacro +| +|.macro branch_RD +| srwi TMP0, RD, 1 +| add PC, PC, TMP0 +| addis PC, PC, -(BCBIAS_J*4 >> 16) +|.endmacro +| +|// Assumes DISPATCH is relative to GL. +#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) +#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) +| +#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) +| +|.macro hotloop +| NYI +|.endmacro +| +|.macro hotcall +| NYI +|.endmacro +| +|// Set current VM state. Uses TMP0. +|.macro li_vmstate, st; li TMP0, ~LJ_VMST_..st; .endmacro +|.macro st_vmstate; stw TMP0, DISPATCH_GL(vmstate)(DISPATCH); .endmacro +| +|// Move table write barrier back. Overwrites mark and tmp. +|.macro barrierback, tab, mark, tmp +| lwz tmp, DISPATCH_GL(gc.grayagain)(DISPATCH) +| // Assumes LJ_GC_BLACK is 0x04. +| rlwinm mark, mark, 0, 30, 28 // black2gray(tab) +| stw tab, DISPATCH_GL(gc.grayagain)(DISPATCH) +| stb mark, tab->marked +| stw tmp, tab->gclist +|.endmacro +| +|//----------------------------------------------------------------------- + +/* Generate subroutines used by opcodes and other parts of the VM. */ +/* The .code_sub section should be last to help static branch prediction. */ +static void build_subroutines(BuildCtx *ctx) +{ + |.code_sub + | + |//----------------------------------------------------------------------- + |//-- Return handling ---------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_returnp: + | // See vm_return. Also: TMP2 = previous base. + | andi. TMP0, PC, FRAME_P + | evsplati TMP1, LJ_TTRUE + | beq ->cont_dispatch + | + | // Return from pcall or xpcall fast func. + | lwz PC, FRAME_PC(TMP2) // Fetch PC of previous frame. + | mr BASE, TMP2 // Restore caller base. + | // Prepending may overwrite the pcall frame, so do it at the end. + | stwu TMP1, FRAME_PC(RA) // Prepend true to results. + | + |->vm_returnc: + | addi RD, RD, 8 // RD = (nresults+1)*8. + | andi. TMP0, PC, FRAME_TYPE + | cmpwi cr1, RD, 0 + | li CRET1, LUA_YIELD + | beq cr1, ->vm_unwind_c_eh + | mr MULTRES, RD + | beq ->BC_RET_Z // Handle regular return to Lua. + | + |->vm_return: + | // BASE = base, RA = resultptr, RD/MULTRES = (nresults+1)*8, PC = return + | // TMP0 = PC & FRAME_TYPE + | cmpwi TMP0, FRAME_C + | rlwinm TMP2, PC, 0, 0, 28 + | li_vmstate C + | sub TMP2, BASE, TMP2 // TMP2 = previous base. + | bne ->vm_returnp + | + | addic. TMP1, RD, -8 + | stw TMP2, L->base + | lwz TMP2, SAVE_NRES + | subi BASE, BASE, 8 + | st_vmstate + | slwi TMP2, TMP2, 3 + | beq >2 + |1: + | addic. TMP1, TMP1, -8 + | evldd TMP0, 0(RA) + | addi RA, RA, 8 + | evstdd TMP0, 0(BASE) + | addi BASE, BASE, 8 + | bne <1 + | + |2: + | cmpw TMP2, RD // More/less results wanted? + | bne >6 + |3: + | stw BASE, L->top // Store new top. + | + |->vm_leave_cp: + | lwz TMP0, SAVE_CFRAME // Restore previous C frame. + | li CRET1, 0 // Ok return status for vm_pcall. + | stw TMP0, L->cframe + | + |->vm_leave_unw: + | restoreregs + | blr + | + |6: + | ble >7 // Less results wanted? + | // More results wanted. Check stack size and fill up results with nil. + | lwz TMP1, L->maxstack + | cmplw BASE, TMP1 + | bge >8 + | evstdd TISNIL, 0(BASE) + | addi RD, RD, 8 + | addi BASE, BASE, 8 + | b <2 + | + |7: // Less results wanted. + | sub TMP0, RD, TMP2 + | cmpwi TMP2, 0 // LUA_MULTRET+1 case? + | sub TMP0, BASE, TMP0 // Subtract the difference. + | iseleq BASE, BASE, TMP0 // Either keep top or shrink it. + | b <3 + | + |8: // Corner case: need to grow stack for filling up results. + | // This can happen if: + | // - A C function grows the stack (a lot). + | // - The GC shrinks the stack in between. + | // - A return back from a lua_call() with (high) nresults adjustment. + | stw BASE, L->top // Save current top held in BASE (yes). + | mr SAVE0, RD + | mr CARG2, TMP2 + | mr CARG1, L + | bl extern lj_state_growstack // (lua_State *L, int n) + | lwz TMP2, SAVE_NRES + | mr RD, SAVE0 + | slwi TMP2, TMP2, 3 + | lwz BASE, L->top // Need the (realloced) L->top in BASE. + | b <2 + | + |->vm_unwind_c: // Unwind C stack, return from vm_pcall. + | // (void *cframe, int errcode) + | mr sp, CARG1 + | mr CRET1, CARG2 + |->vm_unwind_c_eh: // Landing pad for external unwinder. + | lwz L, SAVE_L + | li TMP0, ~LJ_VMST_C + | lwz GL:TMP1, L->glref + | stw TMP0, GL:TMP1->vmstate + | b ->vm_leave_unw + | + |->vm_unwind_ff: // Unwind C stack, return from ff pcall. + | // (void *cframe) + | rlwinm sp, CARG1, 0, 0, 29 + |->vm_unwind_ff_eh: // Landing pad for external unwinder. + | lwz L, SAVE_L + | evsplati TISNUM, LJ_TISNUM+1 // Setup type comparison constants. + | evsplati TISFUNC, LJ_TFUNC + | lus TOBIT, 0x4338 + | evsplati TISTAB, LJ_TTAB + | li TMP0, 0 + | lwz BASE, L->base + | evmergelo TOBIT, TOBIT, TMP0 + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | evsplati TISSTR, LJ_TSTR + | li TMP1, LJ_TFALSE + | evsplati TISNIL, LJ_TNIL + | li_vmstate INTERP + | lwz PC, FRAME_PC(BASE) // Fetch PC of previous frame. + | la RA, -8(BASE) // Results start at BASE-8. + | addi DISPATCH, DISPATCH, GG_G2DISP + | stw TMP1, 0(RA) // Prepend false to error message. + | li RD, 16 // 2 results: false + error message. + | st_vmstate + | b ->vm_returnc + | + |//----------------------------------------------------------------------- + |//-- Grow stack for calls ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_growstack_c: // Grow stack for C function. + | li CARG2, LUA_MINSTACK + | b >2 + | + |->vm_growstack_l: // Grow stack for Lua function. + | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC + | add RC, BASE, RC + | sub RA, RA, BASE + | stw BASE, L->base + | addi PC, PC, 4 // Must point after first instruction. + | stw RC, L->top + | srwi CARG2, RA, 3 + |2: + | // L->base = new base, L->top = top + | stw PC, SAVE_PC + | mr CARG1, L + | bl extern lj_state_growstack // (lua_State *L, int n) + | lwz BASE, L->base + | lwz RC, L->top + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | sub RC, RC, BASE + | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC + | ins_callt // Just retry the call. + | + |//----------------------------------------------------------------------- + |//-- Entry points into the assembler VM --------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_resume: // Setup C frame and resume thread. + | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) + | saveregs + | mr L, CARG1 + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | mr BASE, CARG2 + | lbz TMP1, L->status + | stw L, SAVE_L + | li PC, FRAME_CP + | addi TMP0, sp, CFRAME_RESUME + | addi DISPATCH, DISPATCH, GG_G2DISP + | stw CARG3, SAVE_NRES + | cmplwi TMP1, 0 + | stw CARG3, SAVE_ERRF + | stw TMP0, L->cframe + | stw CARG3, SAVE_CFRAME + | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | beq >3 + | + | // Resume after yield (like a return). + | mr RA, BASE + | lwz BASE, L->base + | evsplati TISNUM, LJ_TISNUM+1 // Setup type comparison constants. + | lwz TMP1, L->top + | evsplati TISFUNC, LJ_TFUNC + | lus TOBIT, 0x4338 + | evsplati TISTAB, LJ_TTAB + | lwz PC, FRAME_PC(BASE) + | li TMP2, 0 + | evsplati TISSTR, LJ_TSTR + | sub RD, TMP1, BASE + | evmergelo TOBIT, TOBIT, TMP2 + | stb CARG3, L->status + | andi. TMP0, PC, FRAME_TYPE + | li_vmstate INTERP + | addi RD, RD, 8 + | evsplati TISNIL, LJ_TNIL + | mr MULTRES, RD + | st_vmstate + | beq ->BC_RET_Z + | b ->vm_return + | + |->vm_pcall: // Setup protected C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) + | saveregs + | li PC, FRAME_CP + | stw CARG4, SAVE_ERRF + | b >1 + | + |->vm_call: // Setup C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1) + | saveregs + | li PC, FRAME_C + | + |1: // Entry point for vm_pcall above (PC = ftype). + | lwz TMP1, L:CARG1->cframe + | stw CARG3, SAVE_NRES + | mr L, CARG1 + | stw CARG1, SAVE_L + | mr BASE, CARG2 + | stw sp, L->cframe // Add our C frame to cframe chain. + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | stw TMP1, SAVE_CFRAME + | addi DISPATCH, DISPATCH, GG_G2DISP + | + |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). + | lwz TMP2, L->base // TMP2 = old base (used in vmeta_call). + | evsplati TISNUM, LJ_TISNUM+1 // Setup type comparison constants. + | lwz TMP1, L->top + | evsplati TISFUNC, LJ_TFUNC + | add PC, PC, BASE + | evsplati TISTAB, LJ_TTAB + | lus TOBIT, 0x4338 + | li TMP0, 0 + | sub PC, PC, TMP2 // PC = frame delta + frame type + | evsplati TISSTR, LJ_TSTR + | sub NARGS8:RC, TMP1, BASE + | evmergelo TOBIT, TOBIT, TMP0 + | li_vmstate INTERP + | evsplati TISNIL, LJ_TNIL + | st_vmstate + | + |->vm_call_dispatch: + | // TMP2 = old base, BASE = new base, RC = nargs*8, PC = caller PC + | li TMP0, -8 + | evlddx LFUNC:RB, BASE, TMP0 + | checkfunc LFUNC:RB + | checkfail ->vmeta_call + | + |->vm_call_dispatch_f: + | ins_call + | // BASE = new base, RB = func, RC = nargs*8, PC = caller PC + | + |->vm_cpcall: // Setup protected C frame, call C. + | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) + | saveregs + | mr L, CARG1 + | lwz TMP0, L:CARG1->stack + | stw CARG1, SAVE_L + | lwz TMP1, L->top + | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | sub TMP0, TMP0, TMP1 // Compute -savestack(L, L->top). + | lwz TMP1, L->cframe + | stw sp, L->cframe // Add our C frame to cframe chain. + | li TMP2, 0 + | stw TMP0, SAVE_NRES // Neg. delta means cframe w/o frame. + | stw TMP2, SAVE_ERRF // No error function. + | stw TMP1, SAVE_CFRAME + | mtctr CARG4 + | bctrl // (lua_State *L, lua_CFunction func, void *ud) + | mr. BASE, CRET1 + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | li PC, FRAME_CP + | addi DISPATCH, DISPATCH, GG_G2DISP + | bne <3 // Else continue with the call. + | b ->vm_leave_cp // No base? Just remove C frame. + | + |//----------------------------------------------------------------------- + |//-- Metamethod handling ------------------------------------------------ + |//----------------------------------------------------------------------- + | + |// The lj_meta_* functions (except for lj_meta_cat) don't reallocate the + |// stack, so BASE doesn't need to be reloaded across these calls. + | + |//-- Continuation dispatch ---------------------------------------------- + | + |->cont_dispatch: + | // BASE = meta base, RA = resultptr, RD = (nresults+1)*8 + | lwz TMP0, -12(BASE) // Continuation. + | mr RB, BASE + | mr BASE, TMP2 // Restore caller BASE. + | lwz LFUNC:TMP1, FRAME_FUNC(TMP2) + | cmplwi TMP0, 0 + | lwz PC, -16(RB) // Restore PC from [cont|PC]. + | beq >1 + | subi TMP2, RD, 8 + | lwz TMP1, LFUNC:TMP1->pc + | evstddx TISNIL, RA, TMP2 // Ensure one valid arg. + | lwz KBASE, PC2PROTO(k)(TMP1) + | // BASE = base, RA = resultptr, RB = meta base + | mtctr TMP0 + | bctr // Jump to continuation. + | + |1: // Tail call from C function. + | subi TMP1, RB, 16 + | sub RC, TMP1, BASE + | b ->vm_call_tail + | + |->cont_cat: // RA = resultptr, RB = meta base + | lwz INS, -4(PC) + | subi CARG2, RB, 16 + | decode_RB8 SAVE0, INS + | evldd TMP0, 0(RA) + | add TMP1, BASE, SAVE0 + | stw BASE, L->base + | cmplw TMP1, CARG2 + | sub CARG3, CARG2, TMP1 + | decode_RA8 RA, INS + | evstdd TMP0, 0(CARG2) + | bne ->BC_CAT_Z + | evstddx TMP0, BASE, RA + | b ->cont_nop + | + |//-- Table indexing metamethods ----------------------------------------- + | + |->vmeta_tgets1: + | evmergelo STR:RC, TISSTR, STR:RC + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | decode_RB8 RB, INS + | evstdd STR:RC, 0(CARG3) + | add CARG2, BASE, RB + | b >1 + | + |->vmeta_tgets: + | evmergelo TAB:RB, TISTAB, TAB:RB + | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) + | evmergelo STR:RC, TISSTR, STR:RC + | evstdd TAB:RB, 0(CARG2) + | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) + | evstdd STR:RC, 0(CARG3) + | b >1 + | + |->vmeta_tgetb: // TMP0 = index + | efdcfsi TMP0, TMP0 + | decode_RB8 RB, INS + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | add CARG2, BASE, RB + | evstdd TMP0, 0(CARG3) + | b >1 + | + |->vmeta_tgetv: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | add CARG2, BASE, RB + | add CARG3, BASE, RC + |1: + | stw BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) + | // Returns TValue * (finished) or NULL (metamethod). + | cmplwi CRET1, 0 + | beq >3 + | evldd TMP0, 0(CRET1) + | evstddx TMP0, BASE, RA + | ins_next + | + |3: // Call __index metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k + | subfic TMP1, BASE, FRAME_CONT + | lwz BASE, L->top + | stw PC, -16(BASE) // [cont|PC] + | add PC, TMP1, BASE + | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | li NARGS8:RC, 16 // 2 args for func(t, k). + | b ->vm_call_dispatch_f + | + |//----------------------------------------------------------------------- + | + |->vmeta_tsets1: + | evmergelo STR:RC, TISSTR, STR:RC + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | decode_RB8 RB, INS + | evstdd STR:RC, 0(CARG3) + | add CARG2, BASE, RB + | b >1 + | + |->vmeta_tsets: + | evmergelo TAB:RB, TISTAB, TAB:RB + | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) + | evmergelo STR:RC, TISSTR, STR:RC + | evstdd TAB:RB, 0(CARG2) + | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) + | evstdd STR:RC, 0(CARG3) + | b >1 + | + |->vmeta_tsetb: // TMP0 = index + | efdcfsi TMP0, TMP0 + | decode_RB8 RB, INS + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | add CARG2, BASE, RB + | evstdd TMP0, 0(CARG3) + | b >1 + | + |->vmeta_tsetv: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | add CARG2, BASE, RB + | add CARG3, BASE, RC + |1: + | stw BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) + | // Returns TValue * (finished) or NULL (metamethod). + | cmplwi CRET1, 0 + | evlddx TMP0, BASE, RA + | beq >3 + | // NOBARRIER: lj_meta_tset ensures the table is not black. + | evstdd TMP0, 0(CRET1) + | ins_next + | + |3: // Call __newindex metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) + | subfic TMP1, BASE, FRAME_CONT + | lwz BASE, L->top + | stw PC, -16(BASE) // [cont|PC] + | add PC, TMP1, BASE + | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | li NARGS8:RC, 24 // 3 args for func(t, k, v) + | evstdd TMP0, 16(BASE) // Copy value to third argument. + | b ->vm_call_dispatch_f + | + |//-- Comparison metamethods --------------------------------------------- + | + |->vmeta_comp: + | mr CARG1, L + | subi PC, PC, 4 + | add CARG2, BASE, RA + | stw PC, SAVE_PC + | add CARG3, BASE, RD + | stw BASE, L->base + | decode_OP1 CARG4, INS + | bl extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) + | // Returns 0/1 or TValue * (metamethod). + |3: + | cmplwi CRET1, 1 + | bgt ->vmeta_binop + |4: + | lwz INS, 0(PC) + | addi PC, PC, 4 + | decode_RD4 TMP2, INS + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | add TMP2, TMP2, TMP3 + | isellt PC, PC, TMP2 + |->cont_nop: + | ins_next + | + |->cont_ra: // RA = resultptr + | lwz INS, -4(PC) + | evldd TMP0, 0(RA) + | decode_RA8 TMP1, INS + | evstddx TMP0, BASE, TMP1 + | b ->cont_nop + | + |->cont_condt: // RA = resultptr + | lwz TMP0, 0(RA) + | li TMP1, LJ_TTRUE + | cmplw TMP1, TMP0 // Branch if result is true. + | b <4 + | + |->cont_condf: // RA = resultptr + | lwz TMP0, 0(RA) + | li TMP1, LJ_TFALSE + | cmplw TMP0, TMP1 // Branch if result is false. + | b <4 + | + |->vmeta_equal: + | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. + | subi PC, PC, 4 + | stw BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) + | // Returns 0/1 or TValue * (metamethod). + | b <3 + | + |//-- Arithmetic metamethods --------------------------------------------- + | + |->vmeta_arith_vn: + | add CARG3, BASE, RB + | add CARG4, KBASE, RC + | b >1 + | + |->vmeta_arith_nv: + | add CARG3, KBASE, RC + | add CARG4, BASE, RB + | b >1 + | + |->vmeta_unm: + | add CARG3, BASE, RD + | mr CARG4, CARG3 + | b >1 + | + |->vmeta_arith_vv: + | add CARG3, BASE, RB + | add CARG4, BASE, RC + |1: + | add CARG2, BASE, RA + | stw BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | decode_OP1 CARG5, INS // Caveat: CARG5 overlaps INS. + | bl extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) + | // Returns NULL (finished) or TValue * (metamethod). + | cmplwi CRET1, 0 + | beq ->cont_nop + | + | // Call metamethod for binary op. + |->vmeta_binop: + | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 + | sub TMP1, CRET1, BASE + | stw PC, -16(CRET1) // [cont|PC] + | mr TMP2, BASE + | addi PC, TMP1, FRAME_CONT + | mr BASE, CRET1 + | li NARGS8:RC, 16 // 2 args for func(o1, o2). + | b ->vm_call_dispatch + | + |->vmeta_len: +#if LJ_52 + | mr SAVE0, CARG1 +#endif + | add CARG2, BASE, RD + | stw BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_len // (lua_State *L, TValue *o) + | // Returns NULL (retry) or TValue * (metamethod base). +#if LJ_52 + | cmplwi CRET1, 0 + | bne ->vmeta_binop // Binop call for compatibility. + | mr CARG1, SAVE0 + | b ->BC_LEN_Z +#else + | b ->vmeta_binop // Binop call for compatibility. +#endif + | + |//-- Call metamethod ---------------------------------------------------- + | + |->vmeta_call: // Resolve and call __call metamethod. + | // TMP2 = old base, BASE = new base, RC = nargs*8 + | mr CARG1, L + | stw TMP2, L->base // This is the callers base! + | subi CARG2, BASE, 8 + | stw PC, SAVE_PC + | add CARG3, BASE, RC + | mr SAVE0, NARGS8:RC + | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. + | ins_call + | + |->vmeta_callt: // Resolve __call for BC_CALLT. + | // BASE = old base, RA = new base, RC = nargs*8 + | mr CARG1, L + | stw BASE, L->base + | subi CARG2, RA, 8 + | stw PC, SAVE_PC + | add CARG3, RA, RC + | mr SAVE0, NARGS8:RC + | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + | lwz TMP1, FRAME_PC(BASE) + | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. + | lwz LFUNC:RB, FRAME_FUNC(RA) // Guaranteed to be a function here. + | b ->BC_CALLT_Z + | + |//-- Argument coercion for 'for' statement ------------------------------ + | + |->vmeta_for: + | mr CARG1, L + | stw BASE, L->base + | mr CARG2, RA + | stw PC, SAVE_PC + | mr SAVE0, INS + | bl extern lj_meta_for // (lua_State *L, TValue *base) + |.if JIT + | decode_OP1 TMP0, SAVE0 + |.endif + | decode_RA8 RA, SAVE0 + |.if JIT + | cmpwi TMP0, BC_JFORI + |.endif + | decode_RD8 RD, SAVE0 + |.if JIT + | beq =>BC_JFORI + |.endif + | b =>BC_FORI + | + |//----------------------------------------------------------------------- + |//-- Fast functions ----------------------------------------------------- + |//----------------------------------------------------------------------- + | + |.macro .ffunc, name + |->ff_ .. name: + |.endmacro + | + |.macro .ffunc_1, name + |->ff_ .. name: + | cmplwi NARGS8:RC, 8 + | evldd CARG1, 0(BASE) + | blt ->fff_fallback + |.endmacro + | + |.macro .ffunc_2, name + |->ff_ .. name: + | cmplwi NARGS8:RC, 16 + | evldd CARG1, 0(BASE) + | evldd CARG2, 8(BASE) + | blt ->fff_fallback + |.endmacro + | + |.macro .ffunc_n, name + | .ffunc_1 name + | checknum CARG1 + | checkfail ->fff_fallback + |.endmacro + | + |.macro .ffunc_nn, name + | .ffunc_2 name + | evmergehi TMP0, CARG1, CARG2 + | checknum TMP0 + | checkanyfail ->fff_fallback + |.endmacro + | + |// Inlined GC threshold check. Caveat: uses TMP0 and TMP1. + |.macro ffgccheck + | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) + | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) + | cmplw TMP0, TMP1 + | bgel ->fff_gcstep + |.endmacro + | + |//-- Base library: checks ----------------------------------------------- + | + |.ffunc assert + | cmplwi NARGS8:RC, 8 + | evldd TMP0, 0(BASE) + | blt ->fff_fallback + | evaddw TMP1, TISNIL, TISNIL // Synthesize LJ_TFALSE. + | la RA, -8(BASE) + | evcmpltu cr1, TMP0, TMP1 + | lwz PC, FRAME_PC(BASE) + | bge cr1, ->fff_fallback + | evstdd TMP0, 0(RA) + | addi RD, NARGS8:RC, 8 // Compute (nresults+1)*8. + | beq ->fff_res // Done if exactly 1 argument. + | li TMP1, 8 + | subi RC, RC, 8 + |1: + | cmplw TMP1, RC + | evlddx TMP0, BASE, TMP1 + | evstddx TMP0, RA, TMP1 + | addi TMP1, TMP1, 8 + | bne <1 + | b ->fff_res + | + |.ffunc type + | cmplwi NARGS8:RC, 8 + | lwz CARG1, 0(BASE) + | blt ->fff_fallback + | li TMP2, ~LJ_TNUMX + | cmplw CARG1, TISNUM + | not TMP1, CARG1 + | isellt TMP1, TMP2, TMP1 + | slwi TMP1, TMP1, 3 + | la TMP2, CFUNC:RB->upvalue + | evlddx STR:CRET1, TMP2, TMP1 + | b ->fff_restv + | + |//-- Base library: getters and setters --------------------------------- + | + |.ffunc_1 getmetatable + | checktab CARG1 + | evmergehi TMP1, CARG1, CARG1 + | checkfail >6 + |1: // Field metatable must be at same offset for GCtab and GCudata! + | lwz TAB:RB, TAB:CARG1->metatable + |2: + | evmr CRET1, TISNIL + | cmplwi TAB:RB, 0 + | lwz STR:RC, DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])(DISPATCH) + | beq ->fff_restv + | lwz TMP0, TAB:RB->hmask + | evmergelo CRET1, TISTAB, TAB:RB // Use metatable as default result. + | lwz TMP1, STR:RC->hash + | lwz NODE:TMP2, TAB:RB->node + | evmergelo STR:RC, TISSTR, STR:RC + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | slwi TMP0, TMP1, 5 + | slwi TMP1, TMP1, 3 + | sub TMP1, TMP0, TMP1 + | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + |3: // Rearranged logic, because we expect _not_ to find the key. + | evldd TMP0, NODE:TMP2->key + | evldd TMP1, NODE:TMP2->val + | evcmpeq TMP0, STR:RC + | lwz NODE:TMP2, NODE:TMP2->next + | checkallok >5 + | cmplwi NODE:TMP2, 0 + | beq ->fff_restv // Not found, keep default result. + | b <3 + |5: + | checknil TMP1 + | checkok ->fff_restv // Ditto for nil value. + | evmr CRET1, TMP1 // Return value of mt.__metatable. + | b ->fff_restv + | + |6: + | cmpwi TMP1, LJ_TUDATA + | not TMP1, TMP1 + | beq <1 + | checknum CARG1 + | slwi TMP1, TMP1, 2 + | li TMP2, 4*~LJ_TNUMX + | isellt TMP1, TMP2, TMP1 + | la TMP2, DISPATCH_GL(gcroot[GCROOT_BASEMT])(DISPATCH) + | lwzx TAB:RB, TMP2, TMP1 + | b <2 + | + |.ffunc_2 setmetatable + | // Fast path: no mt for table yet and not clearing the mt. + | evmergehi TMP0, TAB:CARG1, TAB:CARG2 + | checktab TMP0 + | checkanyfail ->fff_fallback + | lwz TAB:TMP1, TAB:CARG1->metatable + | cmplwi TAB:TMP1, 0 + | lbz TMP3, TAB:CARG1->marked + | bne ->fff_fallback + | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + | stw TAB:CARG2, TAB:CARG1->metatable + | beq ->fff_restv + | barrierback TAB:CARG1, TMP3, TMP0 + | b ->fff_restv + | + |.ffunc rawget + | cmplwi NARGS8:RC, 16 + | evldd CARG2, 0(BASE) + | blt ->fff_fallback + | checktab CARG2 + | la CARG3, 8(BASE) + | checkfail ->fff_fallback + | mr CARG1, L + | bl extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) + | // Returns cTValue *. + | evldd CRET1, 0(CRET1) + | b ->fff_restv + | + |//-- Base library: conversions ------------------------------------------ + | + |.ffunc tonumber + | // Only handles the number case inline (without a base argument). + | cmplwi NARGS8:RC, 8 + | evldd CARG1, 0(BASE) + | bne ->fff_fallback // Exactly one argument. + | checknum CARG1 + | checkok ->fff_restv + | b ->fff_fallback + | + |.ffunc_1 tostring + | // Only handles the string or number case inline. + | checkstr CARG1 + | // A __tostring method in the string base metatable is ignored. + | checkok ->fff_restv // String key? + | // Handle numbers inline, unless a number base metatable is present. + | lwz TMP0, DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])(DISPATCH) + | checknum CARG1 + | cmplwi cr1, TMP0, 0 + | stw BASE, L->base // Add frame since C call can throw. + | crand 4*cr0+eq, 4*cr0+lt, 4*cr1+eq + | stw PC, SAVE_PC // Redundant (but a defined value). + | bne ->fff_fallback + | ffgccheck + | mr CARG1, L + | mr CARG2, BASE + | bl extern lj_str_fromnum // (lua_State *L, lua_Number *np) + | // Returns GCstr *. + | evmergelo STR:CRET1, TISSTR, STR:CRET1 + | b ->fff_restv + | + |//-- Base library: iterators ------------------------------------------- + | + |.ffunc next + | cmplwi NARGS8:RC, 8 + | evldd CARG2, 0(BASE) + | blt ->fff_fallback + | evstddx TISNIL, BASE, NARGS8:RC // Set missing 2nd arg to nil. + | checktab TAB:CARG2 + | lwz PC, FRAME_PC(BASE) + | checkfail ->fff_fallback + | stw BASE, L->base // Add frame since C call can throw. + | mr CARG1, L + | stw BASE, L->top // Dummy frame length is ok. + | la CARG3, 8(BASE) + | stw PC, SAVE_PC + | bl extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) + | // Returns 0 at end of traversal. + | cmplwi CRET1, 0 + | evmr CRET1, TISNIL + | beq ->fff_restv // End of traversal: return nil. + | evldd TMP0, 8(BASE) // Copy key and value to results. + | la RA, -8(BASE) + | evldd TMP1, 16(BASE) + | evstdd TMP0, 0(RA) + | li RD, (2+1)*8 + | evstdd TMP1, 8(RA) + | b ->fff_res + | + |.ffunc_1 pairs + | checktab TAB:CARG1 + | lwz PC, FRAME_PC(BASE) + | checkfail ->fff_fallback +#if LJ_52 + | lwz TAB:TMP2, TAB:CARG1->metatable + | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] + | cmplwi TAB:TMP2, 0 + | la RA, -8(BASE) + | bne ->fff_fallback +#else + | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] + | la RA, -8(BASE) +#endif + | evstdd TISNIL, 8(BASE) + | li RD, (3+1)*8 + | evstdd CFUNC:TMP0, 0(RA) + | b ->fff_res + | + |.ffunc_2 ipairs_aux + | checktab TAB:CARG1 + | lwz PC, FRAME_PC(BASE) + | checkfail ->fff_fallback + | checknum CARG2 + | lus TMP3, 0x3ff0 + | checkfail ->fff_fallback + | efdctsi TMP2, CARG2 + | lwz TMP0, TAB:CARG1->asize + | evmergelo TMP3, TMP3, ZERO + | lwz TMP1, TAB:CARG1->array + | efdadd CARG2, CARG2, TMP3 + | addi TMP2, TMP2, 1 + | la RA, -8(BASE) + | cmplw TMP0, TMP2 + | slwi TMP3, TMP2, 3 + | evstdd CARG2, 0(RA) + | ble >2 // Not in array part? + | evlddx TMP1, TMP1, TMP3 + |1: + | checknil TMP1 + | li RD, (0+1)*8 + | checkok ->fff_res // End of iteration, return 0 results. + | li RD, (2+1)*8 + | evstdd TMP1, 8(RA) + | b ->fff_res + |2: // Check for empty hash part first. Otherwise call C function. + | lwz TMP0, TAB:CARG1->hmask + | cmplwi TMP0, 0 + | li RD, (0+1)*8 + | beq ->fff_res + | mr CARG2, TMP2 + | bl extern lj_tab_getinth // (GCtab *t, int32_t key) + | // Returns cTValue * or NULL. + | cmplwi CRET1, 0 + | li RD, (0+1)*8 + | beq ->fff_res + | evldd TMP1, 0(CRET1) + | b <1 + | + |.ffunc_1 ipairs + | checktab TAB:CARG1 + | lwz PC, FRAME_PC(BASE) + | checkfail ->fff_fallback +#if LJ_52 + | lwz TAB:TMP2, TAB:CARG1->metatable + | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] + | cmplwi TAB:TMP2, 0 + | la RA, -8(BASE) + | bne ->fff_fallback +#else + | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] + | la RA, -8(BASE) +#endif + | evsplati TMP1, 0 + | li RD, (3+1)*8 + | evstdd TMP1, 8(BASE) + | evstdd CFUNC:TMP0, 0(RA) + | b ->fff_res + | + |//-- Base library: catch errors ---------------------------------------- + | + |.ffunc pcall + | cmplwi NARGS8:RC, 8 + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | blt ->fff_fallback + | mr TMP2, BASE + | la BASE, 8(BASE) + | // Remember active hook before pcall. + | rlwinm TMP3, TMP3, 32-HOOK_ACTIVE_SHIFT, 31, 31 + | subi NARGS8:RC, NARGS8:RC, 8 + | addi PC, TMP3, 8+FRAME_PCALL + | b ->vm_call_dispatch + | + |.ffunc_2 xpcall + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | mr TMP2, BASE + | checkfunc CARG2 // Traceback must be a function. + | checkfail ->fff_fallback + | la BASE, 16(BASE) + | // Remember active hook before pcall. + | rlwinm TMP3, TMP3, 32-HOOK_ACTIVE_SHIFT, 31, 31 + | evstdd CARG2, 0(TMP2) // Swap function and traceback. + | subi NARGS8:RC, NARGS8:RC, 16 + | evstdd CARG1, 8(TMP2) + | addi PC, TMP3, 16+FRAME_PCALL + | b ->vm_call_dispatch + | + |//-- Coroutine library -------------------------------------------------- + | + |.macro coroutine_resume_wrap, resume + |.if resume + |.ffunc_1 coroutine_resume + | evmergehi TMP0, L:CARG1, L:CARG1 + |.else + |.ffunc coroutine_wrap_aux + | lwz L:CARG1, CFUNC:RB->upvalue[0].gcr + |.endif + |.if resume + | cmpwi TMP0, LJ_TTHREAD + | bne ->fff_fallback + |.endif + | lbz TMP0, L:CARG1->status + | lwz TMP1, L:CARG1->cframe + | lwz CARG2, L:CARG1->top + | cmplwi cr0, TMP0, LUA_YIELD + | lwz TMP2, L:CARG1->base + | cmplwi cr1, TMP1, 0 + | lwz TMP0, L:CARG1->maxstack + | cmplw cr7, CARG2, TMP2 + | lwz PC, FRAME_PC(BASE) + | crorc 4*cr6+lt, 4*cr0+gt, 4*cr1+eq // st>LUA_YIELD || cframe!=0 + | add TMP2, CARG2, NARGS8:RC + | crandc 4*cr6+gt, 4*cr7+eq, 4*cr0+eq // base==top && st!=LUA_YIELD + | cmplw cr1, TMP2, TMP0 + | cror 4*cr6+lt, 4*cr6+lt, 4*cr6+gt + | stw PC, SAVE_PC + | cror 4*cr6+lt, 4*cr6+lt, 4*cr1+gt // cond1 || cond2 || stackov + | stw BASE, L->base + | blt cr6, ->fff_fallback + |1: + |.if resume + | addi BASE, BASE, 8 // Keep resumed thread in stack for GC. + | subi NARGS8:RC, NARGS8:RC, 8 + | subi TMP2, TMP2, 8 + |.endif + | stw TMP2, L:CARG1->top + | li TMP1, 0 + | stw BASE, L->top + |2: // Move args to coroutine. + | cmpw TMP1, NARGS8:RC + | evlddx TMP0, BASE, TMP1 + | beq >3 + | evstddx TMP0, CARG2, TMP1 + | addi TMP1, TMP1, 8 + | b <2 + |3: + | li CARG3, 0 + | mr L:SAVE0, L:CARG1 + | li CARG4, 0 + | bl ->vm_resume // (lua_State *L, TValue *base, 0, 0) + | // Returns thread status. + |4: + | lwz TMP2, L:SAVE0->base + | cmplwi CRET1, LUA_YIELD + | lwz TMP3, L:SAVE0->top + | li_vmstate INTERP + | lwz BASE, L->base + | st_vmstate + | bgt >8 + | sub RD, TMP3, TMP2 + | lwz TMP0, L->maxstack + | cmplwi RD, 0 + | add TMP1, BASE, RD + | beq >6 // No results? + | cmplw TMP1, TMP0 + | li TMP1, 0 + | bgt >9 // Need to grow stack? + | + | subi TMP3, RD, 8 + | stw TMP2, L:SAVE0->top // Clear coroutine stack. + |5: // Move results from coroutine. + | cmplw TMP1, TMP3 + | evlddx TMP0, TMP2, TMP1 + | evstddx TMP0, BASE, TMP1 + | addi TMP1, TMP1, 8 + | bne <5 + |6: + | andi. TMP0, PC, FRAME_TYPE + |.if resume + | li TMP1, LJ_TTRUE + | la RA, -8(BASE) + | stw TMP1, -8(BASE) // Prepend true to results. + | addi RD, RD, 16 + |.else + | mr RA, BASE + | addi RD, RD, 8 + |.endif + |7: + | stw PC, SAVE_PC + | mr MULTRES, RD + | beq ->BC_RET_Z + | b ->vm_return + | + |8: // Coroutine returned with error (at co->top-1). + |.if resume + | andi. TMP0, PC, FRAME_TYPE + | la TMP3, -8(TMP3) + | li TMP1, LJ_TFALSE + | evldd TMP0, 0(TMP3) + | stw TMP3, L:SAVE0->top // Remove error from coroutine stack. + | li RD, (2+1)*8 + | stw TMP1, -8(BASE) // Prepend false to results. + | la RA, -8(BASE) + | evstdd TMP0, 0(BASE) // Copy error message. + | b <7 + |.else + | mr CARG1, L + | mr CARG2, L:SAVE0 + | bl extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) + |.endif + | + |9: // Handle stack expansion on return from yield. + | mr CARG1, L + | srwi CARG2, RD, 3 + | bl extern lj_state_growstack // (lua_State *L, int n) + | li CRET1, 0 + | b <4 + |.endmacro + | + | coroutine_resume_wrap 1 // coroutine.resume + | coroutine_resume_wrap 0 // coroutine.wrap + | + |.ffunc coroutine_yield + | lwz TMP0, L->cframe + | add TMP1, BASE, NARGS8:RC + | stw BASE, L->base + | andi. TMP0, TMP0, CFRAME_RESUME + | stw TMP1, L->top + | li CRET1, LUA_YIELD + | beq ->fff_fallback + | stw ZERO, L->cframe + | stb CRET1, L->status + | b ->vm_leave_unw + | + |//-- Math library ------------------------------------------------------- + | + |.ffunc_n math_abs + | efdabs CRET1, CARG1 + | // Fallthrough. + | + |->fff_restv: + | // CRET1 = TValue result. + | lwz PC, FRAME_PC(BASE) + | la RA, -8(BASE) + | evstdd CRET1, 0(RA) + |->fff_res1: + | // RA = results, PC = return. + | li RD, (1+1)*8 + |->fff_res: + | // RA = results, RD = (nresults+1)*8, PC = return. + | andi. TMP0, PC, FRAME_TYPE + | mr MULTRES, RD + | bne ->vm_return + | lwz INS, -4(PC) + | decode_RB8 RB, INS + |5: + | cmplw RB, RD // More results expected? + | decode_RA8 TMP0, INS + | bgt >6 + | ins_next1 + | // Adjust BASE. KBASE is assumed to be set for the calling frame. + | sub BASE, RA, TMP0 + | ins_next2 + | + |6: // Fill up results with nil. + | subi TMP1, RD, 8 + | addi RD, RD, 8 + | evstddx TISNIL, RA, TMP1 + | b <5 + | + |.macro math_extern, func + | .ffunc math_ .. func + | cmplwi NARGS8:RC, 8 + | evldd CARG2, 0(BASE) + | blt ->fff_fallback + | checknum CARG2 + | evmergehi CARG1, CARG2, CARG2 + | checkfail ->fff_fallback + | bl extern func@plt + | evmergelo CRET1, CRET1, CRET2 + | b ->fff_restv + |.endmacro + | + |.macro math_extern2, func + | .ffunc math_ .. func + | cmplwi NARGS8:RC, 16 + | evldd CARG2, 0(BASE) + | evldd CARG4, 8(BASE) + | blt ->fff_fallback + | evmergehi CARG1, CARG4, CARG2 + | checknum CARG1 + | evmergehi CARG3, CARG4, CARG4 + | checkanyfail ->fff_fallback + | bl extern func@plt + | evmergelo CRET1, CRET1, CRET2 + | b ->fff_restv + |.endmacro + | + |.macro math_round, func + | .ffunc math_ .. func + | cmplwi NARGS8:RC, 8 + | evldd CARG2, 0(BASE) + | blt ->fff_fallback + | checknum CARG2 + | evmergehi CARG1, CARG2, CARG2 + | checkfail ->fff_fallback + | lwz PC, FRAME_PC(BASE) + | bl ->vm_..func.._hilo; + | la RA, -8(BASE) + | evstdd CRET2, 0(RA) + | b ->fff_res1 + |.endmacro + | + | math_round floor + | math_round ceil + | + | math_extern sqrt + | + |.ffunc math_log + | cmplwi NARGS8:RC, 8 + | evldd CARG2, 0(BASE) + | bne ->fff_fallback // Need exactly 1 argument. + | checknum CARG2 + | evmergehi CARG1, CARG2, CARG2 + | checkfail ->fff_fallback + | bl extern log@plt + | evmergelo CRET1, CRET1, CRET2 + | b ->fff_restv + | + | math_extern log10 + | math_extern exp + | math_extern sin + | math_extern cos + | math_extern tan + | math_extern asin + | math_extern acos + | math_extern atan + | math_extern sinh + | math_extern cosh + | math_extern tanh + | math_extern2 pow + | math_extern2 atan2 + | math_extern2 fmod + | + |->ff_math_deg: + |.ffunc_n math_rad + | evldd CARG2, CFUNC:RB->upvalue[0] + | efdmul CRET1, CARG1, CARG2 + | b ->fff_restv + | + |.ffunc math_ldexp + | cmplwi NARGS8:RC, 16 + | evldd CARG2, 0(BASE) + | evldd CARG4, 8(BASE) + | blt ->fff_fallback + | evmergehi CARG1, CARG4, CARG2 + | checknum CARG1 + | checkanyfail ->fff_fallback + | efdctsi CARG3, CARG4 + | bl extern ldexp@plt + | evmergelo CRET1, CRET1, CRET2 + | b ->fff_restv + | + |.ffunc math_frexp + | cmplwi NARGS8:RC, 8 + | evldd CARG2, 0(BASE) + | blt ->fff_fallback + | checknum CARG2 + | evmergehi CARG1, CARG2, CARG2 + | checkfail ->fff_fallback + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | lwz PC, FRAME_PC(BASE) + | bl extern frexp@plt + | lwz TMP1, DISPATCH_GL(tmptv)(DISPATCH) + | evmergelo CRET1, CRET1, CRET2 + | efdcfsi CRET2, TMP1 + | la RA, -8(BASE) + | evstdd CRET1, 0(RA) + | li RD, (2+1)*8 + | evstdd CRET2, 8(RA) + | b ->fff_res + | + |.ffunc math_modf + | cmplwi NARGS8:RC, 8 + | evldd CARG2, 0(BASE) + | blt ->fff_fallback + | checknum CARG2 + | evmergehi CARG1, CARG2, CARG2 + | checkfail ->fff_fallback + | la CARG3, -8(BASE) + | lwz PC, FRAME_PC(BASE) + | bl extern modf@plt + | evmergelo CRET1, CRET1, CRET2 + | la RA, -8(BASE) + | evstdd CRET1, 0(BASE) + | li RD, (2+1)*8 + | b ->fff_res + | + |.macro math_minmax, name, cmpop + | .ffunc_1 name + | checknum CARG1 + | li TMP1, 8 + | checkfail ->fff_fallback + |1: + | evlddx CARG2, BASE, TMP1 + | cmplw cr1, TMP1, NARGS8:RC + | checknum CARG2 + | bge cr1, ->fff_restv // Ok, since CRET1 = CARG1. + | checkfail ->fff_fallback + | cmpop CARG2, CARG1 + | addi TMP1, TMP1, 8 + | crmove 4*cr0+lt, 4*cr0+gt + | evsel CARG1, CARG2, CARG1 + | b <1 + |.endmacro + | + | math_minmax math_min, efdtstlt + | math_minmax math_max, efdtstgt + | + |//-- String library ----------------------------------------------------- + | + |.ffunc_1 string_len + | checkstr STR:CARG1 + | checkfail ->fff_fallback + | lwz TMP0, STR:CARG1->len + | efdcfsi CRET1, TMP0 + | b ->fff_restv + | + |.ffunc string_byte // Only handle the 1-arg case here. + | cmplwi NARGS8:RC, 8 + | evldd STR:CARG1, 0(BASE) + | bne ->fff_fallback // Need exactly 1 argument. + | checkstr STR:CARG1 + | la RA, -8(BASE) + | checkfail ->fff_fallback + | lwz TMP0, STR:CARG1->len + | li RD, (0+1)*8 + | lbz TMP1, STR:CARG1[1] // Access is always ok (NUL at end). + | li TMP2, (1+1)*8 + | cmplwi TMP0, 0 + | lwz PC, FRAME_PC(BASE) + | efdcfsi CRET1, TMP1 + | iseleq RD, RD, TMP2 + | evstdd CRET1, 0(RA) + | b ->fff_res + | + |.ffunc string_char // Only handle the 1-arg case here. + | ffgccheck + | cmplwi NARGS8:RC, 8 + | evldd CARG1, 0(BASE) + | bne ->fff_fallback // Exactly 1 argument. + | checknum CARG1 + | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) + | checkfail ->fff_fallback + | efdctsiz TMP0, CARG1 + | li CARG3, 1 + | cmplwi TMP0, 255 + | stb TMP0, 0(CARG2) + | bgt ->fff_fallback + |->fff_newstr: + | mr CARG1, L + | stw BASE, L->base + | stw PC, SAVE_PC + | bl extern lj_str_new // (lua_State *L, char *str, size_t l) + | // Returns GCstr *. + | lwz BASE, L->base + | evmergelo STR:CRET1, TISSTR, STR:CRET1 + | b ->fff_restv + | + |.ffunc string_sub + | ffgccheck + | cmplwi NARGS8:RC, 16 + | evldd CARG3, 16(BASE) + | evldd STR:CARG1, 0(BASE) + | blt ->fff_fallback + | evldd CARG2, 8(BASE) + | li TMP2, -1 + | beq >1 + | checknum CARG3 + | checkfail ->fff_fallback + | efdctsiz TMP2, CARG3 + |1: + | checknum CARG2 + | checkfail ->fff_fallback + | checkstr STR:CARG1 + | efdctsiz TMP1, CARG2 + | checkfail ->fff_fallback + | lwz TMP0, STR:CARG1->len + | cmplw TMP0, TMP2 // len < end? (unsigned compare) + | add TMP3, TMP2, TMP0 + | blt >5 + |2: + | cmpwi TMP1, 0 // start <= 0? + | add TMP3, TMP1, TMP0 + | ble >7 + |3: + | sub. CARG3, TMP2, TMP1 + | addi CARG2, STR:CARG1, #STR-1 + | addi CARG3, CARG3, 1 + | add CARG2, CARG2, TMP1 + | isellt CARG3, r0, CARG3 + | b ->fff_newstr + | + |5: // Negative end or overflow. + | cmpw TMP0, TMP2 + | addi TMP3, TMP3, 1 + | iselgt TMP2, TMP3, TMP0 // end = end > len ? len : end+len+1 + | b <2 + | + |7: // Negative start or underflow. + | cmpwi cr1, TMP3, 0 + | iseleq TMP1, r0, TMP3 + | isel TMP1, r0, TMP1, 4*cr1+lt + | addi TMP1, TMP1, 1 // start = 1 + (start ? start+len : 0) + | b <3 + | + |.ffunc string_rep // Only handle the 1-char case inline. + | ffgccheck + | cmplwi NARGS8:RC, 16 + | evldd CARG1, 0(BASE) + | evldd CARG2, 8(BASE) + | bne ->fff_fallback // Exactly 2 arguments. + | checknum CARG2 + | checkfail ->fff_fallback + | checkstr STR:CARG1 + | efdctsiz CARG3, CARG2 + | checkfail ->fff_fallback + | lwz TMP0, STR:CARG1->len + | cmpwi CARG3, 0 + | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | ble >2 // Count <= 0? (or non-int) + | cmplwi TMP0, 1 + | subi TMP2, CARG3, 1 + | blt >2 // Zero length string? + | cmplw cr1, TMP1, CARG3 + | bne ->fff_fallback // Fallback for > 1-char strings. + | lbz TMP0, STR:CARG1[1] + | lwz CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | blt cr1, ->fff_fallback + |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). + | cmplwi TMP2, 0 + | stbx TMP0, CARG2, TMP2 + | subi TMP2, TMP2, 1 + | bne <1 + | b ->fff_newstr + |2: // Return empty string. + | la STR:CRET1, DISPATCH_GL(strempty)(DISPATCH) + | evmergelo CRET1, TISSTR, STR:CRET1 + | b ->fff_restv + | + |.ffunc string_reverse + | ffgccheck + | cmplwi NARGS8:RC, 8 + | evldd CARG1, 0(BASE) + | blt ->fff_fallback + | checkstr STR:CARG1 + | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | checkfail ->fff_fallback + | lwz CARG3, STR:CARG1->len + | la CARG1, #STR(STR:CARG1) + | lwz CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | li TMP2, 0 + | cmplw TMP1, CARG3 + | subi TMP3, CARG3, 1 + | blt ->fff_fallback + |1: // Reverse string copy. + | cmpwi TMP3, 0 + | lbzx TMP1, CARG1, TMP2 + | blt ->fff_newstr + | stbx TMP1, CARG2, TMP3 + | subi TMP3, TMP3, 1 + | addi TMP2, TMP2, 1 + | b <1 + | + |.macro ffstring_case, name, lo + | .ffunc name + | ffgccheck + | cmplwi NARGS8:RC, 8 + | evldd CARG1, 0(BASE) + | blt ->fff_fallback + | checkstr STR:CARG1 + | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | checkfail ->fff_fallback + | lwz CARG3, STR:CARG1->len + | la CARG1, #STR(STR:CARG1) + | lwz CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | cmplw TMP1, CARG3 + | li TMP2, 0 + | blt ->fff_fallback + |1: // ASCII case conversion. + | cmplw TMP2, CARG3 + | lbzx TMP1, CARG1, TMP2 + | bge ->fff_newstr + | subi TMP0, TMP1, lo + | xori TMP3, TMP1, 0x20 + | cmplwi TMP0, 26 + | isellt TMP1, TMP3, TMP1 + | stbx TMP1, CARG2, TMP2 + | addi TMP2, TMP2, 1 + | b <1 + |.endmacro + | + |ffstring_case string_lower, 65 + |ffstring_case string_upper, 97 + | + |//-- Table library ------------------------------------------------------ + | + |.ffunc_1 table_getn + | checktab CARG1 + | checkfail ->fff_fallback + | bl extern lj_tab_len // (GCtab *t) + | // Returns uint32_t (but less than 2^31). + | efdcfsi CRET1, CRET1 + | b ->fff_restv + | + |//-- Bit library -------------------------------------------------------- + | + |.macro .ffunc_bit, name + | .ffunc_n bit_..name + | efdadd CARG1, CARG1, TOBIT + |.endmacro + | + |.ffunc_bit tobit + |->fff_resbit: + | efdcfsi CRET1, CARG1 + | b ->fff_restv + | + |.macro .ffunc_bit_op, name, ins + | .ffunc_bit name + | li TMP1, 8 + |1: + | evlddx CARG2, BASE, TMP1 + | cmplw cr1, TMP1, NARGS8:RC + | checknum CARG2 + | bge cr1, ->fff_resbit + | checkfail ->fff_fallback + | efdadd CARG2, CARG2, TOBIT + | ins CARG1, CARG1, CARG2 + | addi TMP1, TMP1, 8 + | b <1 + |.endmacro + | + |.ffunc_bit_op band, and + |.ffunc_bit_op bor, or + |.ffunc_bit_op bxor, xor + | + |.ffunc_bit bswap + | rotlwi TMP0, CARG1, 8 + | rlwimi TMP0, CARG1, 24, 0, 7 + | rlwimi TMP0, CARG1, 24, 16, 23 + | efdcfsi CRET1, TMP0 + | b ->fff_restv + | + |.ffunc_bit bnot + | not TMP0, CARG1 + | efdcfsi CRET1, TMP0 + | b ->fff_restv + | + |.macro .ffunc_bit_sh, name, ins, shmod + | .ffunc_nn bit_..name + | efdadd CARG2, CARG2, TOBIT + | efdadd CARG1, CARG1, TOBIT + |.if shmod == 1 + | rlwinm CARG2, CARG2, 0, 27, 31 + |.elif shmod == 2 + | neg CARG2, CARG2 + |.endif + | ins TMP0, CARG1, CARG2 + | efdcfsi CRET1, TMP0 + | b ->fff_restv + |.endmacro + | + |.ffunc_bit_sh lshift, slw, 1 + |.ffunc_bit_sh rshift, srw, 1 + |.ffunc_bit_sh arshift, sraw, 1 + |.ffunc_bit_sh rol, rotlw, 0 + |.ffunc_bit_sh ror, rotlw, 2 + | + |//----------------------------------------------------------------------- + | + |->fff_fallback: // Call fast function fallback handler. + | // BASE = new base, RB = CFUNC, RC = nargs*8 + | lwz TMP3, CFUNC:RB->f + | add TMP1, BASE, NARGS8:RC + | lwz PC, FRAME_PC(BASE) // Fallback may overwrite PC. + | addi TMP0, TMP1, 8*LUA_MINSTACK + | lwz TMP2, L->maxstack + | stw PC, SAVE_PC // Redundant (but a defined value). + | cmplw TMP0, TMP2 + | stw BASE, L->base + | stw TMP1, L->top + | mr CARG1, L + | bgt >5 // Need to grow stack. + | mtctr TMP3 + | bctrl // (lua_State *L) + | // Either throws an error, or recovers and returns -1, 0 or nresults+1. + | lwz BASE, L->base + | cmpwi CRET1, 0 + | slwi RD, CRET1, 3 + | la RA, -8(BASE) + | bgt ->fff_res // Returned nresults+1? + |1: // Returned 0 or -1: retry fast path. + | lwz TMP0, L->top + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | sub NARGS8:RC, TMP0, BASE + | bne ->vm_call_tail // Returned -1? + | ins_callt // Returned 0: retry fast path. + | + |// Reconstruct previous base for vmeta_call during tailcall. + |->vm_call_tail: + | andi. TMP0, PC, FRAME_TYPE + | rlwinm TMP1, PC, 0, 0, 28 + | bne >3 + | lwz INS, -4(PC) + | decode_RA8 TMP1, INS + | addi TMP1, TMP1, 8 + |3: + | sub TMP2, BASE, TMP1 + | b ->vm_call_dispatch // Resolve again for tailcall. + | + |5: // Grow stack for fallback handler. + | li CARG2, LUA_MINSTACK + | bl extern lj_state_growstack // (lua_State *L, int n) + | lwz BASE, L->base + | cmpw TMP0, TMP0 // Set 4*cr0+eq to force retry. + | b <1 + | + |->fff_gcstep: // Call GC step function. + | // BASE = new base, RC = nargs*8 + | mflr SAVE0 + | stw BASE, L->base + | add TMP0, BASE, NARGS8:RC + | stw PC, SAVE_PC // Redundant (but a defined value). + | stw TMP0, L->top + | mr CARG1, L + | bl extern lj_gc_step // (lua_State *L) + | lwz BASE, L->base + | mtlr SAVE0 + | lwz TMP0, L->top + | sub NARGS8:RC, TMP0, BASE + | lwz CFUNC:RB, FRAME_FUNC(BASE) + | blr + | + |//----------------------------------------------------------------------- + |//-- Special dispatch targets ------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_record: // Dispatch target for recording phase. + |.if JIT + | NYI + |.endif + | + |->vm_rethook: // Dispatch target for return hooks. + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | andi. TMP0, TMP3, HOOK_ACTIVE // Hook already active? + | beq >1 + |5: // Re-dispatch to static ins. + | addi TMP1, TMP1, GG_DISP2STATIC // Assumes decode_OP4 TMP1, INS. + | lwzx TMP0, DISPATCH, TMP1 + | mtctr TMP0 + | bctr + | + |->vm_inshook: // Dispatch target for instr/line hooks. + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | lwz TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | andi. TMP0, TMP3, HOOK_ACTIVE // Hook already active? + | rlwinm TMP0, TMP3, 31-LUA_HOOKLINE, 31, 0 + | bne <5 + | + | cmpwi cr1, TMP0, 0 + | addic. TMP2, TMP2, -1 + | beq cr1, <5 + | stw TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | beq >1 + | bge cr1, <5 + |1: + | mr CARG1, L + | stw MULTRES, SAVE_MULTRES + | mr CARG2, PC + | stw BASE, L->base + | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. + | bl extern lj_dispatch_ins // (lua_State *L, const BCIns *pc) + |3: + | lwz BASE, L->base + |4: // Re-dispatch to static ins. + | lwz INS, -4(PC) + | decode_OP4 TMP1, INS + | decode_RB8 RB, INS + | addi TMP1, TMP1, GG_DISP2STATIC + | decode_RD8 RD, INS + | lwzx TMP0, DISPATCH, TMP1 + | decode_RA8 RA, INS + | decode_RC8 RC, INS + | mtctr TMP0 + | bctr + | + |->cont_hook: // Continue from hook yield. + | addi PC, PC, 4 + | lwz MULTRES, -20(RB) // Restore MULTRES for *M ins. + | b <4 + | + |->vm_hotloop: // Hot loop counter underflow. + |.if JIT + | NYI + |.endif + | + |->vm_callhook: // Dispatch target for call hooks. + | mr CARG2, PC + |.if JIT + | b >1 + |.endif + | + |->vm_hotcall: // Hot call counter underflow. + |.if JIT + | ori CARG2, PC, 1 + |1: + |.endif + | add TMP0, BASE, RC + | stw PC, SAVE_PC + | mr CARG1, L + | stw BASE, L->base + | sub RA, RA, BASE + | stw TMP0, L->top + | bl extern lj_dispatch_call // (lua_State *L, const BCIns *pc) + | // Returns ASMFunction. + | lwz BASE, L->base + | lwz TMP0, L->top + | stw ZERO, SAVE_PC // Invalidate for subsequent line hook. + | sub NARGS8:RC, TMP0, BASE + | add RA, BASE, RA + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | mtctr CRET1 + | bctr + | + |//----------------------------------------------------------------------- + |//-- Trace exit handler ------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_exit_handler: + |.if JIT + | NYI + |.endif + |->vm_exit_interp: + |.if JIT + | NYI + |.endif + | + |//----------------------------------------------------------------------- + |//-- Math helper functions ---------------------------------------------- + |//----------------------------------------------------------------------- + | + |// FP value rounding. Called by math.floor/math.ceil fast functions + |// and from JIT code. + |// + |// This can be inlined if the CPU has the frin/friz/frip/frim instructions. + |// The alternative hard-float approaches have a deep dependency chain. + |// The resulting latency is at least 3x-7x the double-precision FP latency + |// (e500v2: 6cy, e600: 5cy, Cell: 10cy) or around 20-70 cycles. + |// + |// The soft-float approach is tedious, but much faster (e500v2: ~11cy/~6cy). + |// However it relies on a fast way to transfer the FP value to GPRs + |// (e500v2: 0cy for lo-word, 1cy for hi-word). + |// + |.macro vm_round, name, mode + | // Used temporaries: TMP0, TMP1, TMP2, TMP3. + |->name.._efd: // Input: CARG2, output: CRET2 + | evmergehi CARG1, CARG2, CARG2 + |->name.._hilo: + | // Input: CARG1 (hi), CARG2 (hi, lo), output: CRET2 + | rlwinm TMP2, CARG1, 12, 21, 31 + | addic. TMP2, TMP2, -1023 // exp = exponent(x) - 1023 + | li TMP1, -1 + | cmplwi cr1, TMP2, 51 // 0 <= exp <= 51? + | subfic TMP0, TMP2, 52 + | bgt cr1, >1 + | lus TMP3, 0xfff0 + | slw TMP0, TMP1, TMP0 // lomask = -1 << (52-exp) + | sraw TMP1, TMP3, TMP2 // himask = (int32_t)0xfff00000 >> exp + |.if mode == 2 // trunc(x): + | evmergelo TMP0, TMP1, TMP0 + | evand CRET2, CARG2, TMP0 // hi &= himask, lo &= lomask + |.else + | andc TMP2, CARG2, TMP0 + | andc TMP3, CARG1, TMP1 + | or TMP2, TMP2, TMP3 // ztest = (hi&~himask) | (lo&~lomask) + | srawi TMP3, CARG1, 31 // signmask = (int32_t)hi >> 31 + |.if mode == 0 // floor(x): + | and. TMP2, TMP2, TMP3 // iszero = ((ztest & signmask) == 0) + |.else // ceil(x): + | andc. TMP2, TMP2, TMP3 // iszero = ((ztest & ~signmask) == 0) + |.endif + | and CARG2, CARG2, TMP0 // lo &= lomask + | and CARG1, CARG1, TMP1 // hi &= himask + | subc TMP0, CARG2, TMP0 + | iseleq TMP0, CARG2, TMP0 // lo = iszero ? lo : lo-lomask + | sube TMP1, CARG1, TMP1 + | iseleq TMP1, CARG1, TMP1 // hi = iszero ? hi : hi-himask+carry + | evmergelo CRET2, TMP1, TMP0 + |.endif + | blr + |1: + | bgtlr // Already done if >=2^52, +-inf or nan. + |.if mode == 2 // trunc(x): + | rlwinm TMP1, CARG1, 0, 0, 0 // hi = sign(x) + | li TMP0, 0 + | evmergelo CRET2, TMP1, TMP0 + |.else + | rlwinm TMP2, CARG1, 0, 1, 31 + | srawi TMP0, CARG1, 31 // signmask = (int32_t)hi >> 31 + | or TMP2, TMP2, CARG2 // ztest = abs(hi) | lo + | lus TMP1, 0x3ff0 + |.if mode == 0 // floor(x): + | and. TMP2, TMP2, TMP0 // iszero = ((ztest & signmask) == 0) + |.else // ceil(x): + | andc. TMP2, TMP2, TMP0 // iszero = ((ztest & ~signmask) == 0) + |.endif + | li TMP0, 0 + | iseleq TMP1, r0, TMP1 + | rlwimi CARG1, TMP1, 0, 1, 31 // hi = sign(x) | (iszero ? 0.0 : 1.0) + | evmergelo CRET2, CARG1, TMP0 + |.endif + | blr + |.endmacro + | + |->vm_floor: + | mflr CARG3 + | evmergelo CARG2, CARG1, CARG2 + | bl ->vm_floor_hilo + | mtlr CARG3 + | evmergehi CRET1, CRET2, CRET2 + | blr + | + | vm_round vm_floor, 0 + | vm_round vm_ceil, 1 + |.if JIT + | vm_round vm_trunc, 2 + |.else + |->vm_trunc_efd: + |->vm_trunc_hilo: + |.endif + | + |//----------------------------------------------------------------------- + |//-- Miscellaneous functions -------------------------------------------- + |//----------------------------------------------------------------------- + | + |//----------------------------------------------------------------------- + |//-- FFI helper functions ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_ffi_call: + |.if FFI + | NYI + |.endif + | + |//----------------------------------------------------------------------- +} + +/* Generate the code for a single instruction. */ +static void build_ins(BuildCtx *ctx, BCOp op, int defop) +{ + int vk = 0; + |=>defop: + + switch (op) { + + /* -- Comparison ops ---------------------------------------------------- */ + + /* Remember: all ops branch for a true comparison, fall through otherwise. */ + + case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: + | // RA = src1*8, RD = src2*8, JMP with RD = target + | evlddx TMP0, BASE, RA + | addi PC, PC, 4 + | evlddx TMP1, BASE, RD + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | lwz TMP2, -4(PC) + | evmergehi RB, TMP0, TMP1 + | decode_RD4 TMP2, TMP2 + | checknum RB + | add TMP2, TMP2, TMP3 + | checkanyfail ->vmeta_comp + | efdcmplt TMP0, TMP1 + if (op == BC_ISLE || op == BC_ISGT) { + | efdcmpeq cr1, TMP0, TMP1 + | cror 4*cr0+gt, 4*cr0+gt, 4*cr1+gt + } + if (op == BC_ISLT || op == BC_ISLE) { + | iselgt PC, TMP2, PC + } else { + | iselgt PC, PC, TMP2 + } + | ins_next + break; + + case BC_ISEQV: case BC_ISNEV: + vk = op == BC_ISEQV; + | // RA = src1*8, RD = src2*8, JMP with RD = target + | evlddx CARG2, BASE, RA + | addi PC, PC, 4 + | evlddx CARG3, BASE, RD + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | lwz TMP2, -4(PC) + | evmergehi RB, CARG2, CARG3 + | decode_RD4 TMP2, TMP2 + | checknum RB + | add TMP2, TMP2, TMP3 + | checkanyfail >5 + | efdcmpeq CARG2, CARG3 + if (vk) { + | iselgt PC, TMP2, PC + } else { + | iselgt PC, PC, TMP2 + } + |1: + | ins_next + | + |5: // Either or both types are not numbers. + | evcmpeq CARG2, CARG3 + | not TMP3, RB + | cmplwi cr1, TMP3, ~LJ_TISPRI // Primitive? + | crorc 4*cr7+lt, 4*cr0+so, 4*cr0+lt // 1: Same tv or different type. + | cmplwi cr6, TMP3, ~LJ_TISTABUD // Table or userdata? + | crandc 4*cr7+gt, 4*cr0+lt, 4*cr1+gt // 2: Same type and primitive. + | mr SAVE0, PC + if (vk) { + | isel PC, TMP2, PC, 4*cr7+gt + } else { + | isel TMP2, PC, TMP2, 4*cr7+gt + } + | cror 4*cr7+lt, 4*cr7+lt, 4*cr7+gt // 1 or 2. + if (vk) { + | isel PC, TMP2, PC, 4*cr0+so + } else { + | isel PC, PC, TMP2, 4*cr0+so + } + | blt cr7, <1 // Done if 1 or 2. + | blt cr6, <1 // Done if not tab/ud. + | + | // Different tables or userdatas. Need to check __eq metamethod. + | // Field metatable must be at same offset for GCtab and GCudata! + | lwz TAB:TMP2, TAB:CARG2->metatable + | li CARG4, 1-vk // ne = 0 or 1. + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable? + | lbz TMP2, TAB:TMP2->nomm + | andi. TMP2, TMP2, 1<vmeta_equal // Handle __eq metamethod. + break; + + case BC_ISEQS: case BC_ISNES: + vk = op == BC_ISEQS; + | // RA = src*8, RD = str_const*8 (~), JMP with RD = target + | evlddx TMP0, BASE, RA + | srwi RD, RD, 1 + | lwz INS, 0(PC) + | subfic RD, RD, -4 + | addi PC, PC, 4 + | lwzx STR:TMP1, KBASE, RD // KBASE-4-str_const*4 + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | decode_RD4 TMP2, INS + | evmergelo STR:TMP1, TISSTR, STR:TMP1 + | add TMP2, TMP2, TMP3 + | evcmpeq TMP0, STR:TMP1 + if (vk) { + | isel PC, TMP2, PC, 4*cr0+so + } else { + | isel PC, PC, TMP2, 4*cr0+so + } + | ins_next + break; + + case BC_ISEQN: case BC_ISNEN: + vk = op == BC_ISEQN; + | // RA = src*8, RD = num_const*8, JMP with RD = target + | evlddx TMP0, BASE, RA + | addi PC, PC, 4 + | evlddx TMP1, KBASE, RD + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | lwz INS, -4(PC) + | checknum TMP0 + | checkfail >5 + | efdcmpeq TMP0, TMP1 + |1: + | decode_RD4 TMP2, INS + | add TMP2, TMP2, TMP3 + if (vk) { + | iselgt PC, TMP2, PC + |5: + } else { + | iselgt PC, PC, TMP2 + } + |3: + | ins_next + if (!vk) { + |5: + | decode_RD4 TMP2, INS + | add PC, TMP2, TMP3 + | b <3 + } + break; + + case BC_ISEQP: case BC_ISNEP: + vk = op == BC_ISEQP; + | // RA = src*8, RD = primitive_type*8 (~), JMP with RD = target + | lwzx TMP0, BASE, RA + | srwi TMP1, RD, 3 + | lwz INS, 0(PC) + | addi PC, PC, 4 + | not TMP1, TMP1 + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | cmplw TMP0, TMP1 + | decode_RD4 TMP2, INS + | add TMP2, TMP2, TMP3 + if (vk) { + | iseleq PC, TMP2, PC + } else { + | iseleq PC, PC, TMP2 + } + | ins_next + break; + + /* -- Unary test and copy ops ------------------------------------------- */ + + case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: + | // RA = dst*8 or unused, RD = src*8, JMP with RD = target + | evlddx TMP0, BASE, RD + | evaddw TMP1, TISNIL, TISNIL // Synthesize LJ_TFALSE. + | lwz INS, 0(PC) + | evcmpltu TMP0, TMP1 + | addi PC, PC, 4 + if (op == BC_IST || op == BC_ISF) { + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | decode_RD4 TMP2, INS + | add TMP2, TMP2, TMP3 + if (op == BC_IST) { + | isellt PC, TMP2, PC + } else { + | isellt PC, PC, TMP2 + } + } else { + if (op == BC_ISTC) { + | checkfail >1 + } else { + | checkok >1 + } + | addis PC, PC, -(BCBIAS_J*4 >> 16) + | decode_RD4 TMP2, INS + | evstddx TMP0, BASE, RA + | add PC, PC, TMP2 + |1: + } + | ins_next + break; + + /* -- Unary ops --------------------------------------------------------- */ + + case BC_MOV: + | // RA = dst*8, RD = src*8 + | ins_next1 + | evlddx TMP0, BASE, RD + | evstddx TMP0, BASE, RA + | ins_next2 + break; + case BC_NOT: + | // RA = dst*8, RD = src*8 + | ins_next1 + | lwzx TMP0, BASE, RD + | subfic TMP1, TMP0, LJ_TTRUE + | adde TMP0, TMP0, TMP1 + | stwx TMP0, BASE, RA + | ins_next2 + break; + case BC_UNM: + | // RA = dst*8, RD = src*8 + | evlddx TMP0, BASE, RD + | checknum TMP0 + | checkfail ->vmeta_unm + | efdneg TMP0, TMP0 + | ins_next1 + | evstddx TMP0, BASE, RA + | ins_next2 + break; + case BC_LEN: + | // RA = dst*8, RD = src*8 + | evlddx CARG1, BASE, RD + | checkstr CARG1 + | checkfail >2 + | lwz CRET1, STR:CARG1->len + |1: + | ins_next1 + | efdcfsi TMP0, CRET1 + | evstddx TMP0, BASE, RA + | ins_next2 + |2: + | checktab CARG1 + | checkfail ->vmeta_len +#if LJ_52 + | lwz TAB:TMP2, TAB:CARG1->metatable + | cmplwi TAB:TMP2, 0 + | bne >9 + |3: +#endif + |->BC_LEN_Z: + | bl extern lj_tab_len // (GCtab *t) + | // Returns uint32_t (but less than 2^31). + | b <1 +#if LJ_52 + |9: + | lbz TMP0, TAB:TMP2->nomm + | andi. TMP0, TMP0, 1<vmeta_len +#endif + break; + + /* -- Binary ops -------------------------------------------------------- */ + + |.macro ins_arithpre, t0, t1 + | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 + ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); + ||switch (vk) { + ||case 0: + | evlddx t0, BASE, RB + | checknum t0 + | evlddx t1, KBASE, RC + | checkfail ->vmeta_arith_vn + || break; + ||case 1: + | evlddx t1, BASE, RB + | checknum t1 + | evlddx t0, KBASE, RC + | checkfail ->vmeta_arith_nv + || break; + ||default: + | evlddx t0, BASE, RB + | evlddx t1, BASE, RC + | evmergehi TMP2, t0, t1 + | checknum TMP2 + | checkanyfail ->vmeta_arith_vv + || break; + ||} + |.endmacro + | + |.macro ins_arith, ins + | ins_arithpre TMP0, TMP1 + | ins_next1 + | ins TMP0, TMP0, TMP1 + | evstddx TMP0, BASE, RA + | ins_next2 + |.endmacro + + case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: + | ins_arith efdadd + break; + case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: + | ins_arith efdsub + break; + case BC_MULVN: case BC_MULNV: case BC_MULVV: + | ins_arith efdmul + break; + case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: + | ins_arith efddiv + break; + case BC_MODVN: + | ins_arithpre RD, SAVE0 + |->BC_MODVN_Z: + | efddiv CARG2, RD, SAVE0 + | bl ->vm_floor_efd // floor(b/c) + | efdmul TMP0, CRET2, SAVE0 + | ins_next1 + | efdsub TMP0, RD, TMP0 // b - floor(b/c)*c + | evstddx TMP0, BASE, RA + | ins_next2 + break; + case BC_MODNV: case BC_MODVV: + | ins_arithpre RD, SAVE0 + | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. + break; + case BC_POW: + | evlddx CARG2, BASE, RB + | evlddx CARG4, BASE, RC + | evmergehi CARG1, CARG4, CARG2 + | checknum CARG1 + | evmergehi CARG3, CARG4, CARG4 + | checkanyfail ->vmeta_arith_vv + | bl extern pow@plt + | evmergelo CRET2, CRET1, CRET2 + | evstddx CRET2, BASE, RA + | ins_next + break; + + case BC_CAT: + | // RA = dst*8, RB = src_start*8, RC = src_end*8 + | sub CARG3, RC, RB + | stw BASE, L->base + | add CARG2, BASE, RC + | mr SAVE0, RB + |->BC_CAT_Z: + | stw PC, SAVE_PC + | mr CARG1, L + | srwi CARG3, CARG3, 3 + | bl extern lj_meta_cat // (lua_State *L, TValue *top, int left) + | // Returns NULL (finished) or TValue * (metamethod). + | cmplwi CRET1, 0 + | lwz BASE, L->base + | bne ->vmeta_binop + | evlddx TMP0, BASE, SAVE0 // Copy result from RB to RA. + | evstddx TMP0, BASE, RA + | ins_next + break; + + /* -- Constant ops ------------------------------------------------------ */ + + case BC_KSTR: + | // RA = dst*8, RD = str_const*8 (~) + | ins_next1 + | srwi TMP1, RD, 1 + | subfic TMP1, TMP1, -4 + | lwzx TMP0, KBASE, TMP1 // KBASE-4-str_const*4 + | evmergelo TMP0, TISSTR, TMP0 + | evstddx TMP0, BASE, RA + | ins_next2 + break; + case BC_KCDATA: + |.if FFI + | // RA = dst*8, RD = cdata_const*8 (~) + | ins_next1 + | srwi TMP1, RD, 1 + | subfic TMP1, TMP1, -4 + | lwzx TMP0, KBASE, TMP1 // KBASE-4-cdata_const*4 + | li TMP2, LJ_TCDATA + | evmergelo TMP0, TMP2, TMP0 + | evstddx TMP0, BASE, RA + | ins_next2 + |.endif + break; + case BC_KSHORT: + | // RA = dst*8, RD = int16_literal*8 + | srwi TMP1, RD, 3 + | extsh TMP1, TMP1 + | ins_next1 + | efdcfsi TMP0, TMP1 + | evstddx TMP0, BASE, RA + | ins_next2 + break; + case BC_KNUM: + | // RA = dst*8, RD = num_const*8 + | evlddx TMP0, KBASE, RD + | ins_next1 + | evstddx TMP0, BASE, RA + | ins_next2 + break; + case BC_KPRI: + | // RA = dst*8, RD = primitive_type*8 (~) + | srwi TMP1, RD, 3 + | not TMP0, TMP1 + | ins_next1 + | stwx TMP0, BASE, RA + | ins_next2 + break; + case BC_KNIL: + | // RA = base*8, RD = end*8 + | evstddx TISNIL, BASE, RA + | addi RA, RA, 8 + |1: + | evstddx TISNIL, BASE, RA + | cmpw RA, RD + | addi RA, RA, 8 + | blt <1 + | ins_next_ + break; + + /* -- Upvalue and function ops ------------------------------------------ */ + + case BC_UGET: + | // RA = dst*8, RD = uvnum*8 + | ins_next1 + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RD, RD, 1 + | addi RD, RD, offsetof(GCfuncL, uvptr) + | lwzx UPVAL:RB, LFUNC:RB, RD + | lwz TMP1, UPVAL:RB->v + | evldd TMP0, 0(TMP1) + | evstddx TMP0, BASE, RA + | ins_next2 + break; + case BC_USETV: + | // RA = uvnum*8, RD = src*8 + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RA, RA, 1 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | evlddx TMP1, BASE, RD + | lwzx UPVAL:RB, LFUNC:RB, RA + | lbz TMP3, UPVAL:RB->marked + | lwz CARG2, UPVAL:RB->v + | andi. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) + | lbz TMP0, UPVAL:RB->closed + | evmergehi TMP2, TMP1, TMP1 + | evstdd TMP1, 0(CARG2) + | cmplwi cr1, TMP0, 0 + | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq + | subi TMP2, TMP2, (LJ_TISNUM+1) + | bne >2 // Upvalue is closed and black? + |1: + | ins_next + | + |2: // Check if new value is collectable. + | cmplwi TMP2, LJ_TISGCV - (LJ_TISNUM+1) + | bge <1 // tvisgcv(v) + | lbz TMP3, GCOBJ:TMP1->gch.marked + | andi. TMP3, TMP3, LJ_GC_WHITES // iswhite(v) + | la CARG1, GG_DISP2G(DISPATCH) + | // Crossed a write barrier. Move the barrier forward. + | beq <1 + | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) + | b <1 + break; + case BC_USETS: + | // RA = uvnum*8, RD = str_const*8 (~) + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi TMP1, RD, 1 + | srwi RA, RA, 1 + | subfic TMP1, TMP1, -4 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | lwzx STR:TMP1, KBASE, TMP1 // KBASE-4-str_const*4 + | lwzx UPVAL:RB, LFUNC:RB, RA + | evmergelo STR:TMP1, TISSTR, STR:TMP1 + | lbz TMP3, UPVAL:RB->marked + | lwz CARG2, UPVAL:RB->v + | andi. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) + | lbz TMP3, STR:TMP1->marked + | lbz TMP2, UPVAL:RB->closed + | evstdd STR:TMP1, 0(CARG2) + | bne >2 + |1: + | ins_next + | + |2: // Check if string is white and ensure upvalue is closed. + | andi. TMP3, TMP3, LJ_GC_WHITES // iswhite(str) + | cmplwi cr1, TMP2, 0 + | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq + | la CARG1, GG_DISP2G(DISPATCH) + | // Crossed a write barrier. Move the barrier forward. + | beq <1 + | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) + | b <1 + break; + case BC_USETN: + | // RA = uvnum*8, RD = num_const*8 + | ins_next1 + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RA, RA, 1 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | evlddx TMP0, KBASE, RD + | lwzx UPVAL:RB, LFUNC:RB, RA + | lwz TMP1, UPVAL:RB->v + | evstdd TMP0, 0(TMP1) + | ins_next2 + break; + case BC_USETP: + | // RA = uvnum*8, RD = primitive_type*8 (~) + | ins_next1 + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RA, RA, 1 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | srwi TMP0, RD, 3 + | lwzx UPVAL:RB, LFUNC:RB, RA + | not TMP0, TMP0 + | lwz TMP1, UPVAL:RB->v + | stw TMP0, 0(TMP1) + | ins_next2 + break; + + case BC_UCLO: + | // RA = level*8, RD = target + | lwz TMP1, L->openupval + | branch_RD // Do this first since RD is not saved. + | stw BASE, L->base + | cmplwi TMP1, 0 + | mr CARG1, L + | beq >1 + | add CARG2, BASE, RA + | bl extern lj_func_closeuv // (lua_State *L, TValue *level) + | lwz BASE, L->base + |1: + | ins_next + break; + + case BC_FNEW: + | // RA = dst*8, RD = proto_const*8 (~) (holding function prototype) + | srwi TMP1, RD, 1 + | stw BASE, L->base + | subfic TMP1, TMP1, -4 + | stw PC, SAVE_PC + | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 + | mr CARG1, L + | lwz CARG3, FRAME_FUNC(BASE) + | // (lua_State *L, GCproto *pt, GCfuncL *parent) + | bl extern lj_func_newL_gc + | // Returns GCfuncL *. + | lwz BASE, L->base + | evmergelo LFUNC:CRET1, TISFUNC, LFUNC:CRET1 + | evstddx LFUNC:CRET1, BASE, RA + | ins_next + break; + + /* -- Table ops --------------------------------------------------------- */ + + case BC_TNEW: + case BC_TDUP: + | // RA = dst*8, RD = (hbits|asize)*8 | tab_const*8 (~) + | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) + | mr CARG1, L + | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) + | stw BASE, L->base + | cmplw TMP0, TMP1 + | stw PC, SAVE_PC + | bge >5 + |1: + if (op == BC_TNEW) { + | rlwinm CARG2, RD, 29, 21, 31 + | rlwinm CARG3, RD, 18, 27, 31 + | cmpwi CARG2, 0x7ff + | li TMP1, 0x801 + | iseleq CARG2, TMP1, CARG2 + | bl extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) + | // Returns Table *. + } else { + | srwi TMP1, RD, 1 + | subfic TMP1, TMP1, -4 + | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 + | bl extern lj_tab_dup // (lua_State *L, Table *kt) + | // Returns Table *. + } + | lwz BASE, L->base + | evmergelo TAB:CRET1, TISTAB, TAB:CRET1 + | evstddx TAB:CRET1, BASE, RA + | ins_next + |5: + | mr SAVE0, RD + | bl extern lj_gc_step_fixtop // (lua_State *L) + | mr RD, SAVE0 + | mr CARG1, L + | b <1 + break; + + case BC_GGET: + | // RA = dst*8, RD = str_const*8 (~) + case BC_GSET: + | // RA = src*8, RD = str_const*8 (~) + | lwz LFUNC:TMP2, FRAME_FUNC(BASE) + | srwi TMP1, RD, 1 + | lwz TAB:RB, LFUNC:TMP2->env + | subfic TMP1, TMP1, -4 + | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 + if (op == BC_GGET) { + | b ->BC_TGETS_Z + } else { + | b ->BC_TSETS_Z + } + break; + + case BC_TGETV: + | // RA = dst*8, RB = table*8, RC = key*8 + | evlddx TAB:RB, BASE, RB + | evlddx RC, BASE, RC + | checktab TAB:RB + | checkfail ->vmeta_tgetv + | checknum RC + | checkfail >5 + | // Convert number key to integer + | efdctsi TMP2, RC + | lwz TMP0, TAB:RB->asize + | efdcfsi TMP1, TMP2 + | cmplw cr0, TMP0, TMP2 + | efdcmpeq cr1, RC, TMP1 + | lwz TMP1, TAB:RB->array + | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+gt + | slwi TMP2, TMP2, 3 + | ble ->vmeta_tgetv // Integer key and in array part? + | evlddx TMP1, TMP1, TMP2 + | checknil TMP1 + | checkok >2 + |1: + | evstddx TMP1, BASE, RA + | ins_next + | + |2: // Check for __index if table value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable: done. + | lbz TMP0, TAB:TMP2->nomm + | andi. TMP0, TMP0, 1<vmeta_tgetv + | + |5: + | checkstr STR:RC // String key? + | checkok ->BC_TGETS_Z + | b ->vmeta_tgetv + break; + case BC_TGETS: + | // RA = dst*8, RB = table*8, RC = str_const*8 (~) + | evlddx TAB:RB, BASE, RB + | srwi TMP1, RC, 1 + | checktab TAB:RB + | subfic TMP1, TMP1, -4 + | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 + | checkfail ->vmeta_tgets1 + |->BC_TGETS_Z: + | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = dst*8 + | lwz TMP0, TAB:RB->hmask + | lwz TMP1, STR:RC->hash + | lwz NODE:TMP2, TAB:RB->node + | evmergelo STR:RC, TISSTR, STR:RC + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | slwi TMP0, TMP1, 5 + | slwi TMP1, TMP1, 3 + | sub TMP1, TMP0, TMP1 + | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + |1: + | evldd TMP0, NODE:TMP2->key + | evldd TMP1, NODE:TMP2->val + | evcmpeq TMP0, STR:RC + | checkanyfail >4 + | checknil TMP1 + | checkok >5 // Key found, but nil value? + |3: + | evstddx TMP1, BASE, RA + | ins_next + | + |4: // Follow hash chain. + | lwz NODE:TMP2, NODE:TMP2->next + | cmplwi NODE:TMP2, 0 + | bne <1 + | // End of hash chain: key not found, nil result. + | evmr TMP1, TISNIL + | + |5: // Check for __index if table value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <3 // No metatable: done. + | lbz TMP0, TAB:TMP2->nomm + | andi. TMP0, TMP0, 1<vmeta_tgets + break; + case BC_TGETB: + | // RA = dst*8, RB = table*8, RC = index*8 + | evlddx TAB:RB, BASE, RB + | srwi TMP0, RC, 3 + | checktab TAB:RB + | checkfail ->vmeta_tgetb + | lwz TMP1, TAB:RB->asize + | lwz TMP2, TAB:RB->array + | cmplw TMP0, TMP1 + | bge ->vmeta_tgetb + | evlddx TMP1, TMP2, RC + | checknil TMP1 + | checkok >5 + |1: + | ins_next1 + | evstddx TMP1, BASE, RA + | ins_next2 + | + |5: // Check for __index if table value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable: done. + | lbz TMP2, TAB:TMP2->nomm + | andi. TMP2, TMP2, 1<vmeta_tgetb // Caveat: preserve TMP0! + break; + + case BC_TSETV: + | // RA = src*8, RB = table*8, RC = key*8 + | evlddx TAB:RB, BASE, RB + | evlddx RC, BASE, RC + | checktab TAB:RB + | checkfail ->vmeta_tsetv + | checknum RC + | checkfail >5 + | // Convert number key to integer + | efdctsi TMP2, RC + | evlddx SAVE0, BASE, RA + | lwz TMP0, TAB:RB->asize + | efdcfsi TMP1, TMP2 + | cmplw cr0, TMP0, TMP2 + | efdcmpeq cr1, RC, TMP1 + | lwz TMP1, TAB:RB->array + | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+gt + | slwi TMP0, TMP2, 3 + | ble ->vmeta_tsetv // Integer key and in array part? + | lbz TMP3, TAB:RB->marked + | evlddx TMP2, TMP1, TMP0 + | checknil TMP2 + | checkok >3 + |1: + | andi. TMP2, TMP3, LJ_GC_BLACK // isblack(table) + | evstddx SAVE0, TMP1, TMP0 + | bne >7 + |2: + | ins_next + | + |3: // Check for __newindex if previous value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable: done. + | lbz TMP2, TAB:TMP2->nomm + | andi. TMP2, TMP2, 1<vmeta_tsetv + | + |5: + | checkstr STR:RC // String key? + | checkok ->BC_TSETS_Z + | b ->vmeta_tsetv + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0 + | b <2 + break; + case BC_TSETS: + | // RA = src*8, RB = table*8, RC = str_const*8 (~) + | evlddx TAB:RB, BASE, RB + | srwi TMP1, RC, 1 + | checktab TAB:RB + | subfic TMP1, TMP1, -4 + | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 + | checkfail ->vmeta_tsets1 + |->BC_TSETS_Z: + | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = src*8 + | lwz TMP0, TAB:RB->hmask + | lwz TMP1, STR:RC->hash + | lwz NODE:TMP2, TAB:RB->node + | evmergelo STR:RC, TISSTR, STR:RC + | stb ZERO, TAB:RB->nomm // Clear metamethod cache. + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | evlddx SAVE0, BASE, RA + | slwi TMP0, TMP1, 5 + | slwi TMP1, TMP1, 3 + | sub TMP1, TMP0, TMP1 + | lbz TMP3, TAB:RB->marked + | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + |1: + | evldd TMP0, NODE:TMP2->key + | evldd TMP1, NODE:TMP2->val + | evcmpeq TMP0, STR:RC + | checkanyfail >5 + | checknil TMP1 + | checkok >4 // Key found, but nil value? + |2: + | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + | evstdd SAVE0, NODE:TMP2->val + | bne >7 + |3: + | ins_next + | + |4: // Check for __newindex if previous value is nil. + | lwz TAB:TMP1, TAB:RB->metatable + | cmplwi TAB:TMP1, 0 + | beq <2 // No metatable: done. + | lbz TMP0, TAB:TMP1->nomm + | andi. TMP0, TMP0, 1<vmeta_tsets + | + |5: // Follow hash chain. + | lwz NODE:TMP2, NODE:TMP2->next + | cmplwi NODE:TMP2, 0 + | bne <1 + | // End of hash chain: key not found, add a new one. + | + | // But check for __newindex first. + | lwz TAB:TMP1, TAB:RB->metatable + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | stw PC, SAVE_PC + | mr CARG1, L + | cmplwi TAB:TMP1, 0 + | stw BASE, L->base + | beq >6 // No metatable: continue. + | lbz TMP0, TAB:TMP1->nomm + | andi. TMP0, TMP0, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. + |6: + | mr CARG2, TAB:RB + | evstdd STR:RC, 0(CARG3) + | bl extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) + | // Returns TValue *. + | lwz BASE, L->base + | evstdd SAVE0, 0(CRET1) + | b <3 // No 2nd write barrier needed. + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0 + | b <3 + break; + case BC_TSETB: + | // RA = src*8, RB = table*8, RC = index*8 + | evlddx TAB:RB, BASE, RB + | srwi TMP0, RC, 3 + | checktab TAB:RB + | checkfail ->vmeta_tsetb + | lwz TMP1, TAB:RB->asize + | lwz TMP2, TAB:RB->array + | lbz TMP3, TAB:RB->marked + | cmplw TMP0, TMP1 + | evlddx SAVE0, BASE, RA + | bge ->vmeta_tsetb + | evlddx TMP1, TMP2, RC + | checknil TMP1 + | checkok >5 + |1: + | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + | evstddx SAVE0, TMP2, RC + | bne >7 + |2: + | ins_next + | + |5: // Check for __newindex if previous value is nil. + | lwz TAB:TMP1, TAB:RB->metatable + | cmplwi TAB:TMP1, 0 + | beq <1 // No metatable: done. + | lbz TMP1, TAB:TMP1->nomm + | andi. TMP1, TMP1, 1<vmeta_tsetb // Caveat: preserve TMP0! + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0 + | b <2 + break; + + case BC_TSETM: + | // RA = base*8 (table at base-1), RD = num_const*8 (start index) + | add RA, BASE, RA + |1: + | add TMP3, KBASE, RD + | lwz TAB:CARG2, -4(RA) // Guaranteed to be a table. + | addic. TMP0, MULTRES, -8 + | lwz TMP3, 4(TMP3) // Integer constant is in lo-word. + | srwi CARG3, TMP0, 3 + | beq >4 // Nothing to copy? + | add CARG3, CARG3, TMP3 + | lwz TMP2, TAB:CARG2->asize + | slwi TMP1, TMP3, 3 + | lbz TMP3, TAB:CARG2->marked + | cmplw CARG3, TMP2 + | add TMP2, RA, TMP0 + | lwz TMP0, TAB:CARG2->array + | bgt >5 + | add TMP1, TMP1, TMP0 + | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + |3: // Copy result slots to table. + | evldd TMP0, 0(RA) + | addi RA, RA, 8 + | cmpw cr1, RA, TMP2 + | evstdd TMP0, 0(TMP1) + | addi TMP1, TMP1, 8 + | blt cr1, <3 + | bne >7 + |4: + | ins_next + | + |5: // Need to resize array part. + | stw BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | mr SAVE0, RD + | bl extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) + | // Must not reallocate the stack. + | mr RD, SAVE0 + | b <1 + | + |7: // Possible table write barrier for any value. Skip valiswhite check. + | barrierback TAB:CARG2, TMP3, TMP0 + | b <4 + break; + + /* -- Calls and vararg handling ----------------------------------------- */ + + case BC_CALLM: + | // RA = base*8, (RB = (nresults+1)*8,) RC = extra_nargs*8 + | add NARGS8:RC, NARGS8:RC, MULTRES + | // Fall through. Assumes BC_CALL follows. + break; + case BC_CALL: + | // RA = base*8, (RB = (nresults+1)*8,) RC = (nargs+1)*8 + | evlddx LFUNC:RB, BASE, RA + | mr TMP2, BASE + | add BASE, BASE, RA + | subi NARGS8:RC, NARGS8:RC, 8 + | checkfunc LFUNC:RB + | addi BASE, BASE, 8 + | checkfail ->vmeta_call + | ins_call + break; + + case BC_CALLMT: + | // RA = base*8, (RB = 0,) RC = extra_nargs*8 + | add NARGS8:RC, NARGS8:RC, MULTRES + | // Fall through. Assumes BC_CALLT follows. + break; + case BC_CALLT: + | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 + | evlddx LFUNC:RB, BASE, RA + | add RA, BASE, RA + | lwz TMP1, FRAME_PC(BASE) + | subi NARGS8:RC, NARGS8:RC, 8 + | checkfunc LFUNC:RB + | addi RA, RA, 8 + | checkfail ->vmeta_callt + |->BC_CALLT_Z: + | andi. TMP0, TMP1, FRAME_TYPE // Caveat: preserve cr0 until the crand. + | lbz TMP3, LFUNC:RB->ffid + | xori TMP2, TMP1, FRAME_VARG + | cmplwi cr1, NARGS8:RC, 0 + | bne >7 + |1: + | stw LFUNC:RB, FRAME_FUNC(BASE) // Copy function down, but keep PC. + | li TMP2, 0 + | cmplwi cr7, TMP3, 1 // (> FF_C) Calling a fast function? + | beq cr1, >3 + |2: + | addi TMP3, TMP2, 8 + | evlddx TMP0, RA, TMP2 + | cmplw cr1, TMP3, NARGS8:RC + | evstddx TMP0, BASE, TMP2 + | mr TMP2, TMP3 + | bne cr1, <2 + |3: + | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+gt + | beq >5 + |4: + | ins_callt + | + |5: // Tailcall to a fast function with a Lua frame below. + | lwz INS, -4(TMP1) + | decode_RA8 RA, INS + | sub TMP1, BASE, RA + | lwz LFUNC:TMP1, FRAME_FUNC-8(TMP1) + | lwz TMP1, LFUNC:TMP1->pc + | lwz KBASE, PC2PROTO(k)(TMP1) // Need to prepare KBASE. + | b <4 + | + |7: // Tailcall from a vararg function. + | andi. TMP0, TMP2, FRAME_TYPEP + | bne <1 // Vararg frame below? + | sub BASE, BASE, TMP2 // Relocate BASE down. + | lwz TMP1, FRAME_PC(BASE) + | andi. TMP0, TMP1, FRAME_TYPE + | b <1 + break; + + case BC_ITERC: + | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 ((2+1)*8)) + | subi RA, RA, 24 // evldd doesn't support neg. offsets. + | mr TMP2, BASE + | evlddx LFUNC:RB, BASE, RA + | add BASE, BASE, RA + | evldd TMP0, 8(BASE) + | evldd TMP1, 16(BASE) + | evstdd LFUNC:RB, 24(BASE) // Copy callable. + | checkfunc LFUNC:RB + | evstdd TMP0, 32(BASE) // Copy state. + | li NARGS8:RC, 16 // Iterators get 2 arguments. + | evstdd TMP1, 40(BASE) // Copy control var. + | addi BASE, BASE, 32 + | checkfail ->vmeta_call + | ins_call + break; + + case BC_ITERN: + | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 (2+1)*8) + |.if JIT + | // NYI: add hotloop, record BC_ITERN. + |.endif + | add RA, BASE, RA + | lwz TAB:RB, -12(RA) + | lwz RC, -4(RA) // Get index from control var. + | lwz TMP0, TAB:RB->asize + | lwz TMP1, TAB:RB->array + | addi PC, PC, 4 + |1: // Traverse array part. + | cmplw RC, TMP0 + | slwi TMP3, RC, 3 + | bge >5 // Index points after array part? + | evlddx TMP2, TMP1, TMP3 + | checknil TMP2 + | lwz INS, -4(PC) + | checkok >4 + | efdcfsi TMP0, RC + | addi RC, RC, 1 + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | evstdd TMP2, 8(RA) + | decode_RD4 TMP1, INS + | stw RC, -4(RA) // Update control var. + | add PC, TMP1, TMP3 + | evstdd TMP0, 0(RA) + |3: + | ins_next + | + |4: // Skip holes in array part. + | addi RC, RC, 1 + | b <1 + | + |5: // Traverse hash part. + | lwz TMP1, TAB:RB->hmask + | sub RC, RC, TMP0 + | lwz TMP2, TAB:RB->node + |6: + | cmplw RC, TMP1 // End of iteration? Branch to ITERL+1. + | slwi TMP3, RC, 5 + | bgt <3 + | slwi RB, RC, 3 + | sub TMP3, TMP3, RB + | evlddx RB, TMP2, TMP3 + | add NODE:TMP3, TMP2, TMP3 + | checknil RB + | lwz INS, -4(PC) + | checkok >7 + | evldd TMP3, NODE:TMP3->key + | addis TMP2, PC, -(BCBIAS_J*4 >> 16) + | evstdd RB, 8(RA) + | add RC, RC, TMP0 + | decode_RD4 TMP1, INS + | evstdd TMP3, 0(RA) + | addi RC, RC, 1 + | add PC, TMP1, TMP2 + | stw RC, -4(RA) // Update control var. + | b <3 + | + |7: // Skip holes in hash part. + | addi RC, RC, 1 + | b <6 + break; + + case BC_ISNEXT: + | // RA = base*8, RD = target (points to ITERN) + | add RA, BASE, RA + | li TMP2, -24 + | evlddx CFUNC:TMP1, RA, TMP2 + | lwz TMP2, -16(RA) + | lwz TMP3, -8(RA) + | evmergehi TMP0, CFUNC:TMP1, CFUNC:TMP1 + | cmpwi cr0, TMP2, LJ_TTAB + | cmpwi cr1, TMP0, LJ_TFUNC + | cmpwi cr6, TMP3, LJ_TNIL + | bne cr1, >5 + | lbz TMP1, CFUNC:TMP1->ffid + | crand 4*cr0+eq, 4*cr0+eq, 4*cr6+eq + | cmpwi cr7, TMP1, FF_next_N + | srwi TMP0, RD, 1 + | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq + | add TMP3, PC, TMP0 + | bne cr0, >5 + | lus TMP1, 0xfffe + | ori TMP1, TMP1, 0x7fff + | stw ZERO, -4(RA) // Initialize control var. + | stw TMP1, -8(RA) + | addis PC, TMP3, -(BCBIAS_J*4 >> 16) + |1: + | ins_next + |5: // Despecialize bytecode if any of the checks fail. + | li TMP0, BC_JMP + | li TMP1, BC_ITERC + | stb TMP0, -1(PC) + | addis PC, TMP3, -(BCBIAS_J*4 >> 16) + | stb TMP1, 3(PC) + | b <1 + break; + + case BC_VARG: + | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 + | lwz TMP0, FRAME_PC(BASE) + | add RC, BASE, RC + | add RA, BASE, RA + | addi RC, RC, FRAME_VARG + | add TMP2, RA, RB + | subi TMP3, BASE, 8 // TMP3 = vtop + | sub RC, RC, TMP0 // RC = vbase + | // Note: RC may now be even _above_ BASE if nargs was < numparams. + | cmplwi cr1, RB, 0 + | sub. TMP1, TMP3, RC + | beq cr1, >5 // Copy all varargs? + | subi TMP2, TMP2, 16 + | ble >2 // No vararg slots? + |1: // Copy vararg slots to destination slots. + | evldd TMP0, 0(RC) + | addi RC, RC, 8 + | evstdd TMP0, 0(RA) + | cmplw RA, TMP2 + | cmplw cr1, RC, TMP3 + | bge >3 // All destination slots filled? + | addi RA, RA, 8 + | blt cr1, <1 // More vararg slots? + |2: // Fill up remainder with nil. + | evstdd TISNIL, 0(RA) + | cmplw RA, TMP2 + | addi RA, RA, 8 + | blt <2 + |3: + | ins_next + | + |5: // Copy all varargs. + | lwz TMP0, L->maxstack + | li MULTRES, 8 // MULTRES = (0+1)*8 + | ble <3 // No vararg slots? + | add TMP2, RA, TMP1 + | cmplw TMP2, TMP0 + | addi MULTRES, TMP1, 8 + | bgt >7 + |6: + | evldd TMP0, 0(RC) + | addi RC, RC, 8 + | evstdd TMP0, 0(RA) + | cmplw RC, TMP3 + | addi RA, RA, 8 + | blt <6 // More vararg slots? + | b <3 + | + |7: // Grow stack for varargs. + | mr CARG1, L + | stw RA, L->top + | sub SAVE0, RC, BASE // Need delta, because BASE may change. + | stw BASE, L->base + | sub RA, RA, BASE + | stw PC, SAVE_PC + | srwi CARG2, TMP1, 3 + | bl extern lj_state_growstack // (lua_State *L, int n) + | lwz BASE, L->base + | add RA, BASE, RA + | add RC, BASE, SAVE0 + | subi TMP3, BASE, 8 + | b <6 + break; + + /* -- Returns ----------------------------------------------------------- */ + + case BC_RETM: + | // RA = results*8, RD = extra_nresults*8 + | add RD, RD, MULTRES // MULTRES >= 8, so RD >= 8. + | // Fall through. Assumes BC_RET follows. + break; + + case BC_RET: + | // RA = results*8, RD = (nresults+1)*8 + | lwz PC, FRAME_PC(BASE) + | add RA, BASE, RA + | mr MULTRES, RD + |1: + | andi. TMP0, PC, FRAME_TYPE + | xori TMP1, PC, FRAME_VARG + | bne ->BC_RETV_Z + | + |->BC_RET_Z: + | // BASE = base, RA = resultptr, RD = (nresults+1)*8, PC = return + | lwz INS, -4(PC) + | cmpwi RD, 8 + | subi TMP2, BASE, 8 + | subi RC, RD, 8 + | decode_RB8 RB, INS + | beq >3 + | li TMP1, 0 + |2: + | addi TMP3, TMP1, 8 + | evlddx TMP0, RA, TMP1 + | cmpw TMP3, RC + | evstddx TMP0, TMP2, TMP1 + | beq >3 + | addi TMP1, TMP3, 8 + | evlddx TMP0, RA, TMP3 + | cmpw TMP1, RC + | evstddx TMP0, TMP2, TMP3 + | bne <2 + |3: + |5: + | cmplw RB, RD + | decode_RA8 RA, INS + | bgt >6 + | sub BASE, TMP2, RA + | lwz LFUNC:TMP1, FRAME_FUNC(BASE) + | ins_next1 + | lwz TMP1, LFUNC:TMP1->pc + | lwz KBASE, PC2PROTO(k)(TMP1) + | ins_next2 + | + |6: // Fill up results with nil. + | subi TMP1, RD, 8 + | addi RD, RD, 8 + | evstddx TISNIL, TMP2, TMP1 + | b <5 + | + |->BC_RETV_Z: // Non-standard return case. + | andi. TMP2, TMP1, FRAME_TYPEP + | bne ->vm_return + | // Return from vararg function: relocate BASE down. + | sub BASE, BASE, TMP1 + | lwz PC, FRAME_PC(BASE) + | b <1 + break; + + case BC_RET0: case BC_RET1: + | // RA = results*8, RD = (nresults+1)*8 + | lwz PC, FRAME_PC(BASE) + | add RA, BASE, RA + | mr MULTRES, RD + | andi. TMP0, PC, FRAME_TYPE + | xori TMP1, PC, FRAME_VARG + | bne ->BC_RETV_Z + | + | lwz INS, -4(PC) + | subi TMP2, BASE, 8 + | decode_RB8 RB, INS + if (op == BC_RET1) { + | evldd TMP0, 0(RA) + | evstdd TMP0, 0(TMP2) + } + |5: + | cmplw RB, RD + | decode_RA8 RA, INS + | bgt >6 + | sub BASE, TMP2, RA + | lwz LFUNC:TMP1, FRAME_FUNC(BASE) + | ins_next1 + | lwz TMP1, LFUNC:TMP1->pc + | lwz KBASE, PC2PROTO(k)(TMP1) + | ins_next2 + | + |6: // Fill up results with nil. + | subi TMP1, RD, 8 + | addi RD, RD, 8 + | evstddx TISNIL, TMP2, TMP1 + | b <5 + break; + + /* -- Loops and branches ------------------------------------------------ */ + + case BC_FORL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IFORL follows. + break; + + case BC_JFORI: + case BC_JFORL: +#if !LJ_HASJIT + break; +#endif + case BC_FORI: + case BC_IFORL: + | // RA = base*8, RD = target (after end of loop or start of loop) + vk = (op == BC_IFORL || op == BC_JFORL); + | add RA, BASE, RA + | evldd TMP1, FORL_IDX*8(RA) + | evldd TMP3, FORL_STEP*8(RA) + | evldd TMP2, FORL_STOP*8(RA) + if (!vk) { + | evcmpgtu cr0, TMP1, TISNUM + | evcmpgtu cr7, TMP3, TISNUM + | evcmpgtu cr1, TMP2, TISNUM + | cror 4*cr0+lt, 4*cr0+lt, 4*cr7+lt + | cror 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | blt ->vmeta_for + } + if (vk) { + | efdadd TMP1, TMP1, TMP3 + | evstdd TMP1, FORL_IDX*8(RA) + } + | evcmpgts TMP3, TISNIL + | evstdd TMP1, FORL_EXT*8(RA) + | bge >2 + | efdcmpgt TMP1, TMP2 + |1: + if (op != BC_JFORL) { + | srwi RD, RD, 1 + | add RD, PC, RD + if (op == BC_JFORI) { + | addis PC, RD, -(BCBIAS_J*4 >> 16) + } else { + | addis RD, RD, -(BCBIAS_J*4 >> 16) + } + } + if (op == BC_FORI) { + | iselgt PC, RD, PC + } else if (op == BC_IFORL) { + | iselgt PC, PC, RD + } else { + | ble =>BC_JLOOP + } + | ins_next + |2: + | efdcmpgt TMP2, TMP1 + | b <1 + break; + + case BC_ITERL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IITERL follows. + break; + + case BC_JITERL: +#if !LJ_HASJIT + break; +#endif + case BC_IITERL: + | // RA = base*8, RD = target + | evlddx TMP1, BASE, RA + | subi RA, RA, 8 + | checknil TMP1 + | checkok >1 // Stop if iterator returned nil. + if (op == BC_JITERL) { + | NYI + } else { + | branch_RD // Otherwise save control var + branch. + | evstddx TMP1, BASE, RA + } + |1: + | ins_next + break; + + case BC_LOOP: + | // RA = base*8, RD = target (loop extent) + | // Note: RA/RD is only used by trace recorder to determine scope/extent + | // This opcode does NOT jump, it's only purpose is to detect a hot loop. + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_ILOOP follows. + break; + + case BC_ILOOP: + | // RA = base*8, RD = target (loop extent) + | ins_next + break; + + case BC_JLOOP: + |.if JIT + | NYI + |.endif + break; + + case BC_JMP: + | // RA = base*8 (only used by trace recorder), RD = target + | branch_RD + | ins_next + break; + + /* -- Function headers -------------------------------------------------- */ + + case BC_FUNCF: + |.if JIT + | hotcall + |.endif + case BC_FUNCV: /* NYI: compiled vararg functions. */ + | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. + break; + + case BC_JFUNCF: +#if !LJ_HASJIT + break; +#endif + case BC_IFUNCF: + | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 + | lwz TMP2, L->maxstack + | lbz TMP1, -4+PC2PROTO(numparams)(PC) + | lwz KBASE, -4+PC2PROTO(k)(PC) + | cmplw RA, TMP2 + | slwi TMP1, TMP1, 3 + | bgt ->vm_growstack_l + | ins_next1 + |2: + | cmplw NARGS8:RC, TMP1 // Check for missing parameters. + | ble >3 + if (op == BC_JFUNCF) { + | NYI + } else { + | ins_next2 + } + | + |3: // Clear missing parameters. + | evstddx TISNIL, BASE, NARGS8:RC + | addi NARGS8:RC, NARGS8:RC, 8 + | b <2 + break; + + case BC_JFUNCV: +#if !LJ_HASJIT + break; +#endif + | NYI // NYI: compiled vararg functions + break; /* NYI: compiled vararg functions. */ + + case BC_IFUNCV: + | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 + | lwz TMP2, L->maxstack + | add TMP1, BASE, RC + | add TMP0, RA, RC + | stw LFUNC:RB, 4(TMP1) // Store copy of LFUNC. + | addi TMP3, RC, 8+FRAME_VARG + | lwz KBASE, -4+PC2PROTO(k)(PC) + | cmplw TMP0, TMP2 + | stw TMP3, 0(TMP1) // Store delta + FRAME_VARG. + | bge ->vm_growstack_l + | lbz TMP2, -4+PC2PROTO(numparams)(PC) + | mr RA, BASE + | mr RC, TMP1 + | ins_next1 + | cmpwi TMP2, 0 + | addi BASE, TMP1, 8 + | beq >3 + |1: + | cmplw RA, RC // Less args than parameters? + | evldd TMP0, 0(RA) + | bge >4 + | evstdd TISNIL, 0(RA) // Clear old fixarg slot (help the GC). + | addi RA, RA, 8 + |2: + | addic. TMP2, TMP2, -1 + | evstdd TMP0, 8(TMP1) + | addi TMP1, TMP1, 8 + | bne <1 + |3: + | ins_next2 + | + |4: // Clear missing parameters. + | evmr TMP0, TISNIL + | b <2 + break; + + case BC_FUNCC: + case BC_FUNCCW: + | // BASE = new base, RA = BASE+framesize*8, RB = CFUNC, RC = nargs*8 + if (op == BC_FUNCC) { + | lwz TMP3, CFUNC:RB->f + } else { + | lwz TMP3, DISPATCH_GL(wrapf)(DISPATCH) + } + | add TMP1, RA, NARGS8:RC + | lwz TMP2, L->maxstack + | add RC, BASE, NARGS8:RC + | stw BASE, L->base + | cmplw TMP1, TMP2 + | stw RC, L->top + | li_vmstate C + | mtctr TMP3 + if (op == BC_FUNCCW) { + | lwz CARG2, CFUNC:RB->f + } + | mr CARG1, L + | bgt ->vm_growstack_c // Need to grow stack. + | st_vmstate + | bctrl // (lua_State *L [, lua_CFunction f]) + | // Returns nresults. + | lwz TMP1, L->top + | slwi RD, CRET1, 3 + | lwz BASE, L->base + | li_vmstate INTERP + | lwz PC, FRAME_PC(BASE) // Fetch PC of caller. + | sub RA, TMP1, RD // RA = L->top - nresults*8 + | st_vmstate + | b ->vm_returnc + break; + + /* ---------------------------------------------------------------------- */ + + default: + fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); + exit(2); + break; + } +} + +static int build_backend(BuildCtx *ctx) +{ + int op; + + dasm_growpc(Dst, BC__MAX); + + build_subroutines(ctx); + + |.code_op + for (op = 0; op < BC__MAX; op++) + build_ins(ctx, (BCOp)op, op); + + return BC__MAX; +} + +/* Emit pseudo frame-info for all assembler functions. */ +static void emit_asm_debug(BuildCtx *ctx) +{ + int i; + switch (ctx->mode) { + case BUILD_elfasm: + fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); + fprintf(ctx->fp, + ".Lframe0:\n" + "\t.long .LECIE0-.LSCIE0\n" + ".LSCIE0:\n" + "\t.long 0xffffffff\n" + "\t.byte 0x1\n" + "\t.string \"\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 65\n" + "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE0:\n\n"); + fprintf(ctx->fp, + ".LSFDE0:\n" + "\t.long .LEFDE0-.LASFDE0\n" + ".LASFDE0:\n" + "\t.long .Lframe0\n" + "\t.long .Lbegin\n" + "\t.long %d\n" + "\t.byte 0xe\n\t.uleb128 %d\n" + "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" + "\t.byte 0x5\n\t.uleb128 70\n\t.sleb128 37\n", + (int)ctx->codesz, CFRAME_SIZE); + for (i = 14; i <= 31; i++) + fprintf(ctx->fp, + "\t.byte %d\n\t.uleb128 %d\n" + "\t.byte 5\n\t.uleb128 %d\n\t.uleb128 %d\n", + 0x80+i, 1+2*(31-i), 1200+i, 2+2*(31-i)); + fprintf(ctx->fp, + "\t.align 2\n" + ".LEFDE0:\n\n"); + fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); + fprintf(ctx->fp, + ".Lframe1:\n" + "\t.long .LECIE1-.LSCIE1\n" + ".LSCIE1:\n" + "\t.long 0\n" + "\t.byte 0x1\n" + "\t.string \"zPR\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 65\n" + "\t.uleb128 6\n" /* augmentation length */ + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.long lj_err_unwind_dwarf-.\n" + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE1:\n\n"); + fprintf(ctx->fp, + ".LSFDE1:\n" + "\t.long .LEFDE1-.LASFDE1\n" + ".LASFDE1:\n" + "\t.long .LASFDE1-.Lframe1\n" + "\t.long .Lbegin-.\n" + "\t.long %d\n" + "\t.uleb128 0\n" /* augmentation length */ + "\t.byte 0xe\n\t.uleb128 %d\n" + "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" + "\t.byte 0x5\n\t.uleb128 70\n\t.sleb128 37\n", + (int)ctx->codesz, CFRAME_SIZE); + for (i = 14; i <= 31; i++) + fprintf(ctx->fp, + "\t.byte %d\n\t.uleb128 %d\n" + "\t.byte 5\n\t.uleb128 %d\n\t.uleb128 %d\n", + 0x80+i, 1+2*(31-i), 1200+i, 2+2*(31-i)); + fprintf(ctx->fp, + "\t.align 2\n" + ".LEFDE1:\n\n"); + break; + default: + break; + } +} + + +``` + +`include/luajit-2.0.5/src/vm_x86.dasc`: + +```dasc +|// Low-level VM code for x86 CPUs. +|// Bytecode interpreter, fast functions and helper functions. +|// Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h +| +|.if P64 +|.arch x64 +|.else +|.arch x86 +|.endif +|.section code_op, code_sub +| +|.actionlist build_actionlist +|.globals GLOB_ +|.globalnames globnames +|.externnames extnames +| +|//----------------------------------------------------------------------- +| +|.if P64 +|.define X64, 1 +|.define SSE, 1 +|.if WIN +|.define X64WIN, 1 +|.endif +|.endif +| +|// Fixed register assignments for the interpreter. +|// This is very fragile and has many dependencies. Caveat emptor. +|.define BASE, edx // Not C callee-save, refetched anyway. +|.if not X64 +|.define KBASE, edi // Must be C callee-save. +|.define KBASEa, KBASE +|.define PC, esi // Must be C callee-save. +|.define PCa, PC +|.define DISPATCH, ebx // Must be C callee-save. +|.elif X64WIN +|.define KBASE, edi // Must be C callee-save. +|.define KBASEa, rdi +|.define PC, esi // Must be C callee-save. +|.define PCa, rsi +|.define DISPATCH, ebx // Must be C callee-save. +|.else +|.define KBASE, r15d // Must be C callee-save. +|.define KBASEa, r15 +|.define PC, ebx // Must be C callee-save. +|.define PCa, rbx +|.define DISPATCH, r14d // Must be C callee-save. +|.endif +| +|.define RA, ecx +|.define RAH, ch +|.define RAL, cl +|.define RB, ebp // Must be ebp (C callee-save). +|.define RC, eax // Must be eax. +|.define RCW, ax +|.define RCH, ah +|.define RCL, al +|.define OP, RB +|.define RD, RC +|.define RDW, RCW +|.define RDL, RCL +|.if X64 +|.define RAa, rcx +|.define RBa, rbp +|.define RCa, rax +|.define RDa, rax +|.else +|.define RAa, RA +|.define RBa, RB +|.define RCa, RC +|.define RDa, RD +|.endif +| +|.if not X64 +|.define FCARG1, ecx // x86 fastcall arguments. +|.define FCARG2, edx +|.elif X64WIN +|.define CARG1, rcx // x64/WIN64 C call arguments. +|.define CARG2, rdx +|.define CARG3, r8 +|.define CARG4, r9 +|.define CARG1d, ecx +|.define CARG2d, edx +|.define CARG3d, r8d +|.define CARG4d, r9d +|.define FCARG1, CARG1d // Upwards compatible to x86 fastcall. +|.define FCARG2, CARG2d +|.else +|.define CARG1, rdi // x64/POSIX C call arguments. +|.define CARG2, rsi +|.define CARG3, rdx +|.define CARG4, rcx +|.define CARG5, r8 +|.define CARG6, r9 +|.define CARG1d, edi +|.define CARG2d, esi +|.define CARG3d, edx +|.define CARG4d, ecx +|.define CARG5d, r8d +|.define CARG6d, r9d +|.define FCARG1, CARG1d // Simulate x86 fastcall. +|.define FCARG2, CARG2d +|.endif +| +|// Type definitions. Some of these are only used for documentation. +|.type L, lua_State +|.type GL, global_State +|.type TVALUE, TValue +|.type GCOBJ, GCobj +|.type STR, GCstr +|.type TAB, GCtab +|.type LFUNC, GCfuncL +|.type CFUNC, GCfuncC +|.type PROTO, GCproto +|.type UPVAL, GCupval +|.type NODE, Node +|.type NARGS, int +|.type TRACE, GCtrace +| +|// Stack layout while in interpreter. Must match with lj_frame.h. +|//----------------------------------------------------------------------- +|.if not X64 // x86 stack layout. +| +|.define CFRAME_SPACE, aword*7 // Delta for esp (see <--). +|.macro saveregs_ +| push edi; push esi; push ebx +| sub esp, CFRAME_SPACE +|.endmacro +|.macro saveregs +| push ebp; saveregs_ +|.endmacro +|.macro restoreregs +| add esp, CFRAME_SPACE +| pop ebx; pop esi; pop edi; pop ebp +|.endmacro +| +|.define SAVE_ERRF, aword [esp+aword*15] // vm_pcall/vm_cpcall only. +|.define SAVE_NRES, aword [esp+aword*14] +|.define SAVE_CFRAME, aword [esp+aword*13] +|.define SAVE_L, aword [esp+aword*12] +|//----- 16 byte aligned, ^^^ arguments from C caller +|.define SAVE_RET, aword [esp+aword*11] //<-- esp entering interpreter. +|.define SAVE_R4, aword [esp+aword*10] +|.define SAVE_R3, aword [esp+aword*9] +|.define SAVE_R2, aword [esp+aword*8] +|//----- 16 byte aligned +|.define SAVE_R1, aword [esp+aword*7] //<-- esp after register saves. +|.define SAVE_PC, aword [esp+aword*6] +|.define TMP2, aword [esp+aword*5] +|.define TMP1, aword [esp+aword*4] +|//----- 16 byte aligned +|.define ARG4, aword [esp+aword*3] +|.define ARG3, aword [esp+aword*2] +|.define ARG2, aword [esp+aword*1] +|.define ARG1, aword [esp] //<-- esp while in interpreter. +|//----- 16 byte aligned, ^^^ arguments for C callee +| +|// FPARGx overlaps ARGx and ARG(x+1) on x86. +|.define FPARG3, qword [esp+qword*1] +|.define FPARG1, qword [esp] +|// TMPQ overlaps TMP1/TMP2. ARG5/MULTRES overlap TMP1/TMP2 (and TMPQ). +|.define TMPQ, qword [esp+aword*4] +|.define TMP3, ARG4 +|.define ARG5, TMP1 +|.define TMPa, TMP1 +|.define MULTRES, TMP2 +| +|// Arguments for vm_call and vm_pcall. +|.define INARG_BASE, SAVE_CFRAME // Overwritten by SAVE_CFRAME! +| +|// Arguments for vm_cpcall. +|.define INARG_CP_CALL, SAVE_ERRF +|.define INARG_CP_UD, SAVE_NRES +|.define INARG_CP_FUNC, SAVE_CFRAME +| +|//----------------------------------------------------------------------- +|.elif X64WIN // x64/Windows stack layout +| +|.define CFRAME_SPACE, aword*5 // Delta for rsp (see <--). +|.macro saveregs_ +| push rdi; push rsi; push rbx +| sub rsp, CFRAME_SPACE +|.endmacro +|.macro saveregs +| push rbp; saveregs_ +|.endmacro +|.macro restoreregs +| add rsp, CFRAME_SPACE +| pop rbx; pop rsi; pop rdi; pop rbp +|.endmacro +| +|.define SAVE_CFRAME, aword [rsp+aword*13] +|.define SAVE_PC, dword [rsp+dword*25] +|.define SAVE_L, dword [rsp+dword*24] +|.define SAVE_ERRF, dword [rsp+dword*23] +|.define SAVE_NRES, dword [rsp+dword*22] +|.define TMP2, dword [rsp+dword*21] +|.define TMP1, dword [rsp+dword*20] +|//----- 16 byte aligned, ^^^ 32 byte register save area, owned by interpreter +|.define SAVE_RET, aword [rsp+aword*9] //<-- rsp entering interpreter. +|.define SAVE_R4, aword [rsp+aword*8] +|.define SAVE_R3, aword [rsp+aword*7] +|.define SAVE_R2, aword [rsp+aword*6] +|.define SAVE_R1, aword [rsp+aword*5] //<-- rsp after register saves. +|.define ARG5, aword [rsp+aword*4] +|.define CSAVE_4, aword [rsp+aword*3] +|.define CSAVE_3, aword [rsp+aword*2] +|.define CSAVE_2, aword [rsp+aword*1] +|.define CSAVE_1, aword [rsp] //<-- rsp while in interpreter. +|//----- 16 byte aligned, ^^^ 32 byte register save area, owned by callee +| +|// TMPQ overlaps TMP1/TMP2. MULTRES overlaps TMP2 (and TMPQ). +|.define TMPQ, qword [rsp+aword*10] +|.define MULTRES, TMP2 +|.define TMPa, ARG5 +|.define ARG5d, dword [rsp+aword*4] +|.define TMP3, ARG5d +| +|//----------------------------------------------------------------------- +|.else // x64/POSIX stack layout +| +|.define CFRAME_SPACE, aword*5 // Delta for rsp (see <--). +|.macro saveregs_ +| push rbx; push r15; push r14 +|.if NO_UNWIND +| push r13; push r12 +|.endif +| sub rsp, CFRAME_SPACE +|.endmacro +|.macro saveregs +| push rbp; saveregs_ +|.endmacro +|.macro restoreregs +| add rsp, CFRAME_SPACE +|.if NO_UNWIND +| pop r12; pop r13 +|.endif +| pop r14; pop r15; pop rbx; pop rbp +|.endmacro +| +|//----- 16 byte aligned, +|.if NO_UNWIND +|.define SAVE_RET, aword [rsp+aword*11] //<-- rsp entering interpreter. +|.define SAVE_R4, aword [rsp+aword*10] +|.define SAVE_R3, aword [rsp+aword*9] +|.define SAVE_R2, aword [rsp+aword*8] +|.define SAVE_R1, aword [rsp+aword*7] +|.define SAVE_RU2, aword [rsp+aword*6] +|.define SAVE_RU1, aword [rsp+aword*5] //<-- rsp after register saves. +|.else +|.define SAVE_RET, aword [rsp+aword*9] //<-- rsp entering interpreter. +|.define SAVE_R4, aword [rsp+aword*8] +|.define SAVE_R3, aword [rsp+aword*7] +|.define SAVE_R2, aword [rsp+aword*6] +|.define SAVE_R1, aword [rsp+aword*5] //<-- rsp after register saves. +|.endif +|.define SAVE_CFRAME, aword [rsp+aword*4] +|.define SAVE_PC, dword [rsp+dword*7] +|.define SAVE_L, dword [rsp+dword*6] +|.define SAVE_ERRF, dword [rsp+dword*5] +|.define SAVE_NRES, dword [rsp+dword*4] +|.define TMPa, aword [rsp+aword*1] +|.define TMP2, dword [rsp+dword*1] +|.define TMP1, dword [rsp] //<-- rsp while in interpreter. +|//----- 16 byte aligned +| +|// TMPQ overlaps TMP1/TMP2. MULTRES overlaps TMP2 (and TMPQ). +|.define TMPQ, qword [rsp] +|.define TMP3, dword [rsp+aword*1] +|.define MULTRES, TMP2 +| +|.endif +| +|//----------------------------------------------------------------------- +| +|// Instruction headers. +|.macro ins_A; .endmacro +|.macro ins_AD; .endmacro +|.macro ins_AJ; .endmacro +|.macro ins_ABC; movzx RB, RCH; movzx RC, RCL; .endmacro +|.macro ins_AB_; movzx RB, RCH; .endmacro +|.macro ins_A_C; movzx RC, RCL; .endmacro +|.macro ins_AND; not RDa; .endmacro +| +|// Instruction decode+dispatch. Carefully tuned (nope, lodsd is not faster). +|.macro ins_NEXT +| mov RC, [PC] +| movzx RA, RCH +| movzx OP, RCL +| add PC, 4 +| shr RC, 16 +|.if X64 +| jmp aword [DISPATCH+OP*8] +|.else +| jmp aword [DISPATCH+OP*4] +|.endif +|.endmacro +| +|// Instruction footer. +|.if 1 +| // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. +| .define ins_next, ins_NEXT +| .define ins_next_, ins_NEXT +|.else +| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. +| // Affects only certain kinds of benchmarks (and only with -j off). +| // Around 10%-30% slower on Core2, a lot more slower on P4. +| .macro ins_next +| jmp ->ins_next +| .endmacro +| .macro ins_next_ +| ->ins_next: +| ins_NEXT +| .endmacro +|.endif +| +|// Call decode and dispatch. +|.macro ins_callt +| // BASE = new base, RB = LFUNC, RD = nargs+1, [BASE-4] = PC +| mov PC, LFUNC:RB->pc +| mov RA, [PC] +| movzx OP, RAL +| movzx RA, RAH +| add PC, 4 +|.if X64 +| jmp aword [DISPATCH+OP*8] +|.else +| jmp aword [DISPATCH+OP*4] +|.endif +|.endmacro +| +|.macro ins_call +| // BASE = new base, RB = LFUNC, RD = nargs+1 +| mov [BASE-4], PC +| ins_callt +|.endmacro +| +|//----------------------------------------------------------------------- +| +|// Macros to test operand types. +|.macro checktp, reg, tp; cmp dword [BASE+reg*8+4], tp; .endmacro +|.macro checknum, reg, target; checktp reg, LJ_TISNUM; jae target; .endmacro +|.macro checkint, reg, target; checktp reg, LJ_TISNUM; jne target; .endmacro +|.macro checkstr, reg, target; checktp reg, LJ_TSTR; jne target; .endmacro +|.macro checktab, reg, target; checktp reg, LJ_TTAB; jne target; .endmacro +| +|// These operands must be used with movzx. +|.define PC_OP, byte [PC-4] +|.define PC_RA, byte [PC-3] +|.define PC_RB, byte [PC-1] +|.define PC_RC, byte [PC-2] +|.define PC_RD, word [PC-2] +| +|.macro branchPC, reg +| lea PC, [PC+reg*4-BCBIAS_J*4] +|.endmacro +| +|// Assumes DISPATCH is relative to GL. +#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) +#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) +| +#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) +| +|// Decrement hashed hotcount and trigger trace recorder if zero. +|.macro hotloop, reg +| mov reg, PC +| shr reg, 1 +| and reg, HOTCOUNT_PCMASK +| sub word [DISPATCH+reg+GG_DISP2HOT], HOTCOUNT_LOOP +| jb ->vm_hotloop +|.endmacro +| +|.macro hotcall, reg +| mov reg, PC +| shr reg, 1 +| and reg, HOTCOUNT_PCMASK +| sub word [DISPATCH+reg+GG_DISP2HOT], HOTCOUNT_CALL +| jb ->vm_hotcall +|.endmacro +| +|// Set current VM state. +|.macro set_vmstate, st +| mov dword [DISPATCH+DISPATCH_GL(vmstate)], ~LJ_VMST_..st +|.endmacro +| +|// x87 compares. +|.macro fcomparepp // Compare and pop st0 >< st1. +| fucomip st1 +| fpop +|.endmacro +| +|.macro fdup; fld st0; .endmacro +|.macro fpop1; fstp st1; .endmacro +| +|// Synthesize SSE FP constants. +|.macro sseconst_abs, reg, tmp // Synthesize abs mask. +|.if X64 +| mov64 tmp, U64x(7fffffff,ffffffff); movd reg, tmp +|.else +| pxor reg, reg; pcmpeqd reg, reg; psrlq reg, 1 +|.endif +|.endmacro +| +|.macro sseconst_hi, reg, tmp, val // Synthesize hi-32 bit const. +|.if X64 +| mov64 tmp, U64x(val,00000000); movd reg, tmp +|.else +| mov tmp, 0x .. val; movd reg, tmp; pshufd reg, reg, 0x51 +|.endif +|.endmacro +| +|.macro sseconst_sign, reg, tmp // Synthesize sign mask. +| sseconst_hi reg, tmp, 80000000 +|.endmacro +|.macro sseconst_1, reg, tmp // Synthesize 1.0. +| sseconst_hi reg, tmp, 3ff00000 +|.endmacro +|.macro sseconst_m1, reg, tmp // Synthesize -1.0. +| sseconst_hi reg, tmp, bff00000 +|.endmacro +|.macro sseconst_2p52, reg, tmp // Synthesize 2^52. +| sseconst_hi reg, tmp, 43300000 +|.endmacro +|.macro sseconst_tobit, reg, tmp // Synthesize 2^52 + 2^51. +| sseconst_hi reg, tmp, 43380000 +|.endmacro +| +|// Move table write barrier back. Overwrites reg. +|.macro barrierback, tab, reg +| and byte tab->marked, (uint8_t)~LJ_GC_BLACK // black2gray(tab) +| mov reg, [DISPATCH+DISPATCH_GL(gc.grayagain)] +| mov [DISPATCH+DISPATCH_GL(gc.grayagain)], tab +| mov tab->gclist, reg +|.endmacro +| +|//----------------------------------------------------------------------- + +/* Generate subroutines used by opcodes and other parts of the VM. */ +/* The .code_sub section should be last to help static branch prediction. */ +static void build_subroutines(BuildCtx *ctx) +{ + |.code_sub + | + |//----------------------------------------------------------------------- + |//-- Return handling ---------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_returnp: + | test PC, FRAME_P + | jz ->cont_dispatch + | + | // Return from pcall or xpcall fast func. + | and PC, -8 + | sub BASE, PC // Restore caller base. + | lea RAa, [RA+PC-8] // Rebase RA and prepend one result. + | mov PC, [BASE-4] // Fetch PC of previous frame. + | // Prepending may overwrite the pcall frame, so do it at the end. + | mov dword [BASE+RA+4], LJ_TTRUE // Prepend true to results. + | + |->vm_returnc: + | add RD, 1 // RD = nresults+1 + | jz ->vm_unwind_yield + | mov MULTRES, RD + | test PC, FRAME_TYPE + | jz ->BC_RET_Z // Handle regular return to Lua. + | + |->vm_return: + | // BASE = base, RA = resultofs, RD = nresults+1 (= MULTRES), PC = return + | xor PC, FRAME_C + | test PC, FRAME_TYPE + | jnz ->vm_returnp + | + | // Return to C. + | set_vmstate C + | and PC, -8 + | sub PC, BASE + | neg PC // Previous base = BASE - delta. + | + | sub RD, 1 + | jz >2 + |1: // Move results down. + |.if X64 + | mov RBa, [BASE+RA] + | mov [BASE-8], RBa + |.else + | mov RB, [BASE+RA] + | mov [BASE-8], RB + | mov RB, [BASE+RA+4] + | mov [BASE-4], RB + |.endif + | add BASE, 8 + | sub RD, 1 + | jnz <1 + |2: + | mov L:RB, SAVE_L + | mov L:RB->base, PC + |3: + | mov RD, MULTRES + | mov RA, SAVE_NRES // RA = wanted nresults+1 + |4: + | cmp RA, RD + | jne >6 // More/less results wanted? + |5: + | sub BASE, 8 + | mov L:RB->top, BASE + | + |->vm_leave_cp: + | mov RAa, SAVE_CFRAME // Restore previous C frame. + | mov L:RB->cframe, RAa + | xor eax, eax // Ok return status for vm_pcall. + | + |->vm_leave_unw: + | restoreregs + | ret + | + |6: + | jb >7 // Less results wanted? + | // More results wanted. Check stack size and fill up results with nil. + | cmp BASE, L:RB->maxstack + | ja >8 + | mov dword [BASE-4], LJ_TNIL + | add BASE, 8 + | add RD, 1 + | jmp <4 + | + |7: // Less results wanted. + | test RA, RA + | jz <5 // But check for LUA_MULTRET+1. + | sub RA, RD // Negative result! + | lea BASE, [BASE+RA*8] // Correct top. + | jmp <5 + | + |8: // Corner case: need to grow stack for filling up results. + | // This can happen if: + | // - A C function grows the stack (a lot). + | // - The GC shrinks the stack in between. + | // - A return back from a lua_call() with (high) nresults adjustment. + | mov L:RB->top, BASE // Save current top held in BASE (yes). + | mov MULTRES, RD // Need to fill only remainder with nil. + | mov FCARG2, RA + | mov FCARG1, L:RB + | call extern lj_state_growstack@8 // (lua_State *L, int n) + | mov BASE, L:RB->top // Need the (realloced) L->top in BASE. + | jmp <3 + | + |->vm_unwind_yield: + | mov al, LUA_YIELD + | jmp ->vm_unwind_c_eh + | + |->vm_unwind_c@8: // Unwind C stack, return from vm_pcall. + | // (void *cframe, int errcode) + |.if X64 + | mov eax, CARG2d // Error return status for vm_pcall. + | mov rsp, CARG1 + |.else + | mov eax, FCARG2 // Error return status for vm_pcall. + | mov esp, FCARG1 + |.endif + |->vm_unwind_c_eh: // Landing pad for external unwinder. + | mov L:RB, SAVE_L + | mov GL:RB, L:RB->glref + | mov dword GL:RB->vmstate, ~LJ_VMST_C + | jmp ->vm_leave_unw + | + |->vm_unwind_rethrow: + |.if X64 and not X64WIN + | mov FCARG1, SAVE_L + | mov FCARG2, eax + | restoreregs + | jmp extern lj_err_throw@8 // (lua_State *L, int errcode) + |.endif + | + |->vm_unwind_ff@4: // Unwind C stack, return from ff pcall. + | // (void *cframe) + |.if X64 + | and CARG1, CFRAME_RAWMASK + | mov rsp, CARG1 + |.else + | and FCARG1, CFRAME_RAWMASK + | mov esp, FCARG1 + |.endif + |->vm_unwind_ff_eh: // Landing pad for external unwinder. + | mov L:RB, SAVE_L + | mov RAa, -8 // Results start at BASE+RA = BASE-8. + | mov RD, 1+1 // Really 1+2 results, incr. later. + | mov BASE, L:RB->base + | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. + | add DISPATCH, GG_G2DISP + | mov PC, [BASE-4] // Fetch PC of previous frame. + | mov dword [BASE-4], LJ_TFALSE // Prepend false to error message. + | set_vmstate INTERP + | jmp ->vm_returnc // Increments RD/MULTRES and returns. + | + |//----------------------------------------------------------------------- + |//-- Grow stack for calls ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_growstack_c: // Grow stack for C function. + | mov FCARG2, LUA_MINSTACK + | jmp >2 + | + |->vm_growstack_v: // Grow stack for vararg Lua function. + | sub RD, 8 + | jmp >1 + | + |->vm_growstack_f: // Grow stack for fixarg Lua function. + | // BASE = new base, RD = nargs+1, RB = L, PC = first PC + | lea RD, [BASE+NARGS:RD*8-8] + |1: + | movzx RA, byte [PC-4+PC2PROTO(framesize)] + | add PC, 4 // Must point after first instruction. + | mov L:RB->base, BASE + | mov L:RB->top, RD + | mov SAVE_PC, PC + | mov FCARG2, RA + |2: + | // RB = L, L->base = new base, L->top = top + | mov FCARG1, L:RB + | call extern lj_state_growstack@8 // (lua_State *L, int n) + | mov BASE, L:RB->base + | mov RD, L:RB->top + | mov LFUNC:RB, [BASE-8] + | sub RD, BASE + | shr RD, 3 + | add NARGS:RD, 1 + | // BASE = new base, RB = LFUNC, RD = nargs+1 + | ins_callt // Just retry the call. + | + |//----------------------------------------------------------------------- + |//-- Entry points into the assembler VM --------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_resume: // Setup C frame and resume thread. + | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) + | saveregs + |.if X64 + | mov L:RB, CARG1d // Caveat: CARG1d may be RA. + | mov SAVE_L, CARG1d + | mov RA, CARG2d + |.else + | mov L:RB, SAVE_L + | mov RA, INARG_BASE // Caveat: overlaps SAVE_CFRAME! + |.endif + | mov PC, FRAME_CP + | xor RD, RD + | lea KBASEa, [esp+CFRAME_RESUME] + | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. + | add DISPATCH, GG_G2DISP + | mov L:RB->cframe, KBASEa + | mov SAVE_PC, RD // Any value outside of bytecode is ok. + | mov SAVE_CFRAME, RDa + |.if X64 + | mov SAVE_NRES, RD + | mov SAVE_ERRF, RD + |.endif + | cmp byte L:RB->status, RDL + | je >3 // Initial resume (like a call). + | + | // Resume after yield (like a return). + | set_vmstate INTERP + | mov byte L:RB->status, RDL + | mov BASE, L:RB->base + | mov RD, L:RB->top + | sub RD, RA + | shr RD, 3 + | add RD, 1 // RD = nresults+1 + | sub RA, BASE // RA = resultofs + | mov PC, [BASE-4] + | mov MULTRES, RD + | test PC, FRAME_TYPE + | jz ->BC_RET_Z + | jmp ->vm_return + | + |->vm_pcall: // Setup protected C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) + | saveregs + | mov PC, FRAME_CP + |.if X64 + | mov SAVE_ERRF, CARG4d + |.endif + | jmp >1 + | + |->vm_call: // Setup C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1) + | saveregs + | mov PC, FRAME_C + | + |1: // Entry point for vm_pcall above (PC = ftype). + |.if X64 + | mov SAVE_NRES, CARG3d + | mov L:RB, CARG1d // Caveat: CARG1d may be RA. + | mov SAVE_L, CARG1d + | mov RA, CARG2d + |.else + | mov L:RB, SAVE_L + | mov RA, INARG_BASE // Caveat: overlaps SAVE_CFRAME! + |.endif + | + | mov KBASEa, L:RB->cframe // Add our C frame to cframe chain. + | mov SAVE_CFRAME, KBASEa + | mov SAVE_PC, L:RB // Any value outside of bytecode is ok. + |.if X64 + | mov L:RB->cframe, rsp + |.else + | mov L:RB->cframe, esp + |.endif + | + |2: // Entry point for vm_cpcall below (RA = base, RB = L, PC = ftype). + | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. + | add DISPATCH, GG_G2DISP + | + |3: // Entry point for vm_resume above (RA = base, RB = L, PC = ftype). + | set_vmstate INTERP + | mov BASE, L:RB->base // BASE = old base (used in vmeta_call). + | add PC, RA + | sub PC, BASE // PC = frame delta + frame type + | + | mov RD, L:RB->top + | sub RD, RA + | shr NARGS:RD, 3 + | add NARGS:RD, 1 // RD = nargs+1 + | + |->vm_call_dispatch: + | mov LFUNC:RB, [RA-8] + | cmp dword [RA-4], LJ_TFUNC + | jne ->vmeta_call // Ensure KBASE defined and != BASE. + | + |->vm_call_dispatch_f: + | mov BASE, RA + | ins_call + | // BASE = new base, RB = func, RD = nargs+1, PC = caller PC + | + |->vm_cpcall: // Setup protected C frame, call C. + | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) + | saveregs + |.if X64 + | mov L:RB, CARG1d // Caveat: CARG1d may be RA. + | mov SAVE_L, CARG1d + |.else + | mov L:RB, SAVE_L + | // Caveat: INARG_CP_* and SAVE_CFRAME/SAVE_NRES/SAVE_ERRF overlap! + | mov RC, INARG_CP_UD // Get args before they are overwritten. + | mov RA, INARG_CP_FUNC + | mov BASE, INARG_CP_CALL + |.endif + | mov SAVE_PC, L:RB // Any value outside of bytecode is ok. + | + | mov KBASE, L:RB->stack // Compute -savestack(L, L->top). + | sub KBASE, L:RB->top + | mov SAVE_ERRF, 0 // No error function. + | mov SAVE_NRES, KBASE // Neg. delta means cframe w/o frame. + | // Handler may change cframe_nres(L->cframe) or cframe_errfunc(L->cframe). + | + |.if X64 + | mov KBASEa, L:RB->cframe // Add our C frame to cframe chain. + | mov SAVE_CFRAME, KBASEa + | mov L:RB->cframe, rsp + | + | call CARG4 // (lua_State *L, lua_CFunction func, void *ud) + |.else + | mov ARG3, RC // Have to copy args downwards. + | mov ARG2, RA + | mov ARG1, L:RB + | + | mov KBASE, L:RB->cframe // Add our C frame to cframe chain. + | mov SAVE_CFRAME, KBASE + | mov L:RB->cframe, esp + | + | call BASE // (lua_State *L, lua_CFunction func, void *ud) + |.endif + | // TValue * (new base) or NULL returned in eax (RC). + | test RC, RC + | jz ->vm_leave_cp // No base? Just remove C frame. + | mov RA, RC + | mov PC, FRAME_CP + | jmp <2 // Else continue with the call. + | + |//----------------------------------------------------------------------- + |//-- Metamethod handling ------------------------------------------------ + |//----------------------------------------------------------------------- + | + |//-- Continuation dispatch ---------------------------------------------- + | + |->cont_dispatch: + | // BASE = meta base, RA = resultofs, RD = nresults+1 (also in MULTRES) + | add RA, BASE + | and PC, -8 + | mov RB, BASE + | sub BASE, PC // Restore caller BASE. + | mov dword [RA+RD*8-4], LJ_TNIL // Ensure one valid arg. + | mov RC, RA // ... in [RC] + | mov PC, [RB-12] // Restore PC from [cont|PC]. + |.if X64 + | movsxd RAa, dword [RB-16] // May be negative on WIN64 with debug. + |.if FFI + | cmp RA, 1 + | jbe >1 + |.endif + | lea KBASEa, qword [=>0] + | add RAa, KBASEa + |.else + | mov RA, dword [RB-16] + |.if FFI + | cmp RA, 1 + | jbe >1 + |.endif + |.endif + | mov LFUNC:KBASE, [BASE-8] + | mov KBASE, LFUNC:KBASE->pc + | mov KBASE, [KBASE+PC2PROTO(k)] + | // BASE = base, RC = result, RB = meta base + | jmp RAa // Jump to continuation. + | + |.if FFI + |1: + | je ->cont_ffi_callback // cont = 1: return from FFI callback. + | // cont = 0: Tail call from C function. + | sub RB, BASE + | shr RB, 3 + | lea RD, [RB-1] + | jmp ->vm_call_tail + |.endif + | + |->cont_cat: // BASE = base, RC = result, RB = mbase + | movzx RA, PC_RB + | sub RB, 16 + | lea RA, [BASE+RA*8] + | sub RA, RB + | je ->cont_ra + | neg RA + | shr RA, 3 + |.if X64WIN + | mov CARG3d, RA + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE + | mov RCa, [RC] + | mov [RB], RCa + | mov CARG2d, RB + |.elif X64 + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE + | mov CARG3d, RA + | mov RAa, [RC] + | mov [RB], RAa + | mov CARG2d, RB + |.else + | mov ARG3, RA + | mov RA, [RC+4] + | mov RC, [RC] + | mov [RB+4], RA + | mov [RB], RC + | mov ARG2, RB + |.endif + | jmp ->BC_CAT_Z + | + |//-- Table indexing metamethods ----------------------------------------- + | + |->vmeta_tgets: + | mov TMP1, RC // RC = GCstr * + | mov TMP2, LJ_TSTR + | lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2. + | cmp PC_OP, BC_GGET + | jne >1 + | lea RA, [DISPATCH+DISPATCH_GL(tmptv)] // Store fn->l.env in g->tmptv. + | mov [RA], TAB:RB // RB = GCtab * + | mov dword [RA+4], LJ_TTAB + | mov RB, RA + | jmp >2 + | + |->vmeta_tgetb: + | movzx RC, PC_RC + |.if DUALNUM + | mov TMP2, LJ_TISNUM + | mov TMP1, RC + |.elif SSE + | cvtsi2sd xmm0, RC + | movsd TMPQ, xmm0 + |.else + | mov ARG4, RC + | fild ARG4 + | fstp TMPQ + |.endif + | lea RCa, TMPQ // Store temp. TValue in TMPQ. + | jmp >1 + | + |->vmeta_tgetv: + | movzx RC, PC_RC // Reload TValue *k from RC. + | lea RC, [BASE+RC*8] + |1: + | movzx RB, PC_RB // Reload TValue *t from RB. + | lea RB, [BASE+RB*8] + |2: + |.if X64 + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. + | mov CARG2d, RB + | mov CARG3, RCa // May be 64 bit ptr to stack. + | mov L:RB, L:CARG1d + |.else + | mov ARG2, RB + | mov L:RB, SAVE_L + | mov ARG3, RC + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | call extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) + | // TValue * (finished) or NULL (metamethod) returned in eax (RC). + | mov BASE, L:RB->base + | test RC, RC + | jz >3 + |->cont_ra: // BASE = base, RC = result + | movzx RA, PC_RA + |.if X64 + | mov RBa, [RC] + | mov [BASE+RA*8], RBa + |.else + | mov RB, [RC+4] + | mov RC, [RC] + | mov [BASE+RA*8+4], RB + | mov [BASE+RA*8], RC + |.endif + | ins_next + | + |3: // Call __index metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k + | mov RA, L:RB->top + | mov [RA-12], PC // [cont|PC] + | lea PC, [RA+FRAME_CONT] + | sub PC, BASE + | mov LFUNC:RB, [RA-8] // Guaranteed to be a function here. + | mov NARGS:RD, 2+1 // 2 args for func(t, k). + | jmp ->vm_call_dispatch_f + | + |//----------------------------------------------------------------------- + | + |->vmeta_tsets: + | mov TMP1, RC // RC = GCstr * + | mov TMP2, LJ_TSTR + | lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2. + | cmp PC_OP, BC_GSET + | jne >1 + | lea RA, [DISPATCH+DISPATCH_GL(tmptv)] // Store fn->l.env in g->tmptv. + | mov [RA], TAB:RB // RB = GCtab * + | mov dword [RA+4], LJ_TTAB + | mov RB, RA + | jmp >2 + | + |->vmeta_tsetb: + | movzx RC, PC_RC + |.if DUALNUM + | mov TMP2, LJ_TISNUM + | mov TMP1, RC + |.elif SSE + | cvtsi2sd xmm0, RC + | movsd TMPQ, xmm0 + |.else + | mov ARG4, RC + | fild ARG4 + | fstp TMPQ + |.endif + | lea RCa, TMPQ // Store temp. TValue in TMPQ. + | jmp >1 + | + |->vmeta_tsetv: + | movzx RC, PC_RC // Reload TValue *k from RC. + | lea RC, [BASE+RC*8] + |1: + | movzx RB, PC_RB // Reload TValue *t from RB. + | lea RB, [BASE+RB*8] + |2: + |.if X64 + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. + | mov CARG2d, RB + | mov CARG3, RCa // May be 64 bit ptr to stack. + | mov L:RB, L:CARG1d + |.else + | mov ARG2, RB + | mov L:RB, SAVE_L + | mov ARG3, RC + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | call extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) + | // TValue * (finished) or NULL (metamethod) returned in eax (RC). + | mov BASE, L:RB->base + | test RC, RC + | jz >3 + | // NOBARRIER: lj_meta_tset ensures the table is not black. + | movzx RA, PC_RA + |.if X64 + | mov RBa, [BASE+RA*8] + | mov [RC], RBa + |.else + | mov RB, [BASE+RA*8+4] + | mov RA, [BASE+RA*8] + | mov [RC+4], RB + | mov [RC], RA + |.endif + |->cont_nop: // BASE = base, (RC = result) + | ins_next + | + |3: // Call __newindex metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) + | mov RA, L:RB->top + | mov [RA-12], PC // [cont|PC] + | movzx RC, PC_RA + | // Copy value to third argument. + |.if X64 + | mov RBa, [BASE+RC*8] + | mov [RA+16], RBa + |.else + | mov RB, [BASE+RC*8+4] + | mov RC, [BASE+RC*8] + | mov [RA+20], RB + | mov [RA+16], RC + |.endif + | lea PC, [RA+FRAME_CONT] + | sub PC, BASE + | mov LFUNC:RB, [RA-8] // Guaranteed to be a function here. + | mov NARGS:RD, 3+1 // 3 args for func(t, k, v). + | jmp ->vm_call_dispatch_f + | + |//-- Comparison metamethods --------------------------------------------- + | + |->vmeta_comp: + |.if X64 + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Caveat: CARG2d/CARG3d == BASE. + |.if X64WIN + | lea CARG3d, [BASE+RD*8] + | lea CARG2d, [BASE+RA*8] + |.else + | lea CARG2d, [BASE+RA*8] + | lea CARG3d, [BASE+RD*8] + |.endif + | mov CARG1d, L:RB // Caveat: CARG1d/CARG4d == RA. + | movzx CARG4d, PC_OP + |.else + | movzx RB, PC_OP + | lea RD, [BASE+RD*8] + | lea RA, [BASE+RA*8] + | mov ARG4, RB + | mov L:RB, SAVE_L + | mov ARG3, RD + | mov ARG2, RA + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | call extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) + | // 0/1 or TValue * (metamethod) returned in eax (RC). + |3: + | mov BASE, L:RB->base + | cmp RC, 1 + | ja ->vmeta_binop + |4: + | lea PC, [PC+4] + | jb >6 + |5: + | movzx RD, PC_RD + | branchPC RD + |6: + | ins_next + | + |->cont_condt: // BASE = base, RC = result + | add PC, 4 + | cmp dword [RC+4], LJ_TISTRUECOND // Branch if result is true. + | jb <5 + | jmp <6 + | + |->cont_condf: // BASE = base, RC = result + | cmp dword [RC+4], LJ_TISTRUECOND // Branch if result is false. + | jmp <4 + | + |->vmeta_equal: + | sub PC, 4 + |.if X64WIN + | mov CARG3d, RD + | mov CARG4d, RB + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Caveat: CARG2d == BASE. + | mov CARG2d, RA + | mov CARG1d, L:RB // Caveat: CARG1d == RA. + |.elif X64 + | mov CARG2d, RA + | mov CARG4d, RB // Caveat: CARG4d == RA. + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Caveat: CARG3d == BASE. + | mov CARG3d, RD + | mov CARG1d, L:RB + |.else + | mov ARG4, RB + | mov L:RB, SAVE_L + | mov ARG3, RD + | mov ARG2, RA + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | call extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) + | // 0/1 or TValue * (metamethod) returned in eax (RC). + | jmp <3 + | + |->vmeta_equal_cd: + |.if FFI + | sub PC, 4 + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | mov FCARG1, L:RB + | mov FCARG2, dword [PC-4] + | mov SAVE_PC, PC + | call extern lj_meta_equal_cd@8 // (lua_State *L, BCIns ins) + | // 0/1 or TValue * (metamethod) returned in eax (RC). + | jmp <3 + |.endif + | + |//-- Arithmetic metamethods --------------------------------------------- + | + |->vmeta_arith_vno: + |.if DUALNUM + | movzx RB, PC_RB + |.endif + |->vmeta_arith_vn: + | lea RC, [KBASE+RC*8] + | jmp >1 + | + |->vmeta_arith_nvo: + |.if DUALNUM + | movzx RC, PC_RC + |.endif + |->vmeta_arith_nv: + | lea RC, [KBASE+RC*8] + | lea RB, [BASE+RB*8] + | xchg RB, RC + | jmp >2 + | + |->vmeta_unm: + | lea RC, [BASE+RD*8] + | mov RB, RC + | jmp >2 + | + |->vmeta_arith_vvo: + |.if DUALNUM + | movzx RB, PC_RB + |.endif + |->vmeta_arith_vv: + | lea RC, [BASE+RC*8] + |1: + | lea RB, [BASE+RB*8] + |2: + | lea RA, [BASE+RA*8] + |.if X64WIN + | mov CARG3d, RB + | mov CARG4d, RC + | movzx RC, PC_OP + | mov ARG5d, RC + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Caveat: CARG2d == BASE. + | mov CARG2d, RA + | mov CARG1d, L:RB // Caveat: CARG1d == RA. + |.elif X64 + | movzx CARG5d, PC_OP + | mov CARG2d, RA + | mov CARG4d, RC // Caveat: CARG4d == RA. + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE // Caveat: CARG3d == BASE. + | mov CARG3d, RB + | mov L:RB, L:CARG1d + |.else + | mov ARG3, RB + | mov L:RB, SAVE_L + | mov ARG4, RC + | movzx RC, PC_OP + | mov ARG2, RA + | mov ARG5, RC + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | call extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) + | // NULL (finished) or TValue * (metamethod) returned in eax (RC). + | mov BASE, L:RB->base + | test RC, RC + | jz ->cont_nop + | + | // Call metamethod for binary op. + |->vmeta_binop: + | // BASE = base, RC = new base, stack = cont/func/o1/o2 + | mov RA, RC + | sub RC, BASE + | mov [RA-12], PC // [cont|PC] + | lea PC, [RC+FRAME_CONT] + | mov NARGS:RD, 2+1 // 2 args for func(o1, o2). + | jmp ->vm_call_dispatch + | + |->vmeta_len: + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | lea FCARG2, [BASE+RD*8] // Caveat: FCARG2 == BASE + | mov L:FCARG1, L:RB + | mov SAVE_PC, PC + | call extern lj_meta_len@8 // (lua_State *L, TValue *o) + | // NULL (retry) or TValue * (metamethod) returned in eax (RC). + | mov BASE, L:RB->base +#if LJ_52 + | test RC, RC + | jne ->vmeta_binop // Binop call for compatibility. + | movzx RD, PC_RD + | mov TAB:FCARG1, [BASE+RD*8] + | jmp ->BC_LEN_Z +#else + | jmp ->vmeta_binop // Binop call for compatibility. +#endif + | + |//-- Call metamethod ---------------------------------------------------- + | + |->vmeta_call_ra: + | lea RA, [BASE+RA*8+8] + |->vmeta_call: // Resolve and call __call metamethod. + | // BASE = old base, RA = new base, RC = nargs+1, PC = return + | mov TMP2, RA // Save RA, RC for us. + | mov TMP1, NARGS:RD + | sub RA, 8 + |.if X64 + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Caveat: CARG2d/CARG3d may be BASE. + | mov CARG2d, RA + | lea CARG3d, [RA+NARGS:RD*8] + | mov CARG1d, L:RB // Caveat: CARG1d may be RA. + |.else + | lea RC, [RA+NARGS:RD*8] + | mov L:RB, SAVE_L + | mov ARG2, RA + | mov ARG3, RC + | mov ARG1, L:RB + | mov L:RB->base, BASE // This is the callers base! + |.endif + | mov SAVE_PC, PC + | call extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + | mov BASE, L:RB->base + | mov RA, TMP2 + | mov NARGS:RD, TMP1 + | mov LFUNC:RB, [RA-8] + | add NARGS:RD, 1 + | // This is fragile. L->base must not move, KBASE must always be defined. + | cmp KBASE, BASE // Continue with CALLT if flag set. + | je ->BC_CALLT_Z + | mov BASE, RA + | ins_call // Otherwise call resolved metamethod. + | + |//-- Argument coercion for 'for' statement ------------------------------ + | + |->vmeta_for: + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | mov FCARG2, RA // Caveat: FCARG2 == BASE + | mov L:FCARG1, L:RB // Caveat: FCARG1 == RA + | mov SAVE_PC, PC + | call extern lj_meta_for@8 // (lua_State *L, TValue *base) + | mov BASE, L:RB->base + | mov RC, [PC-4] + | movzx RA, RCH + | movzx OP, RCL + | shr RC, 16 + |.if X64 + | jmp aword [DISPATCH+OP*8+GG_DISP2STATIC] // Retry FORI or JFORI. + |.else + | jmp aword [DISPATCH+OP*4+GG_DISP2STATIC] // Retry FORI or JFORI. + |.endif + | + |//----------------------------------------------------------------------- + |//-- Fast functions ----------------------------------------------------- + |//----------------------------------------------------------------------- + | + |.macro .ffunc, name + |->ff_ .. name: + |.endmacro + | + |.macro .ffunc_1, name + |->ff_ .. name: + | cmp NARGS:RD, 1+1; jb ->fff_fallback + |.endmacro + | + |.macro .ffunc_2, name + |->ff_ .. name: + | cmp NARGS:RD, 2+1; jb ->fff_fallback + |.endmacro + | + |.macro .ffunc_n, name + | .ffunc_1 name + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + | fld qword [BASE] + |.endmacro + | + |.macro .ffunc_n, name, op + | .ffunc_1 name + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + | op + | fld qword [BASE] + |.endmacro + | + |.macro .ffunc_nsse, name, op + | .ffunc_1 name + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + | op xmm0, qword [BASE] + |.endmacro + | + |.macro .ffunc_nsse, name + | .ffunc_nsse name, movsd + |.endmacro + | + |.macro .ffunc_nn, name + | .ffunc_2 name + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + | cmp dword [BASE+12], LJ_TISNUM; jae ->fff_fallback + | fld qword [BASE] + | fld qword [BASE+8] + |.endmacro + | + |.macro .ffunc_nnsse, name + | .ffunc_2 name + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + | cmp dword [BASE+12], LJ_TISNUM; jae ->fff_fallback + | movsd xmm0, qword [BASE] + | movsd xmm1, qword [BASE+8] + |.endmacro + | + |.macro .ffunc_nnr, name + | .ffunc_2 name + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + | cmp dword [BASE+12], LJ_TISNUM; jae ->fff_fallback + | fld qword [BASE+8] + | fld qword [BASE] + |.endmacro + | + |// Inlined GC threshold check. Caveat: uses label 1. + |.macro ffgccheck + | mov RB, [DISPATCH+DISPATCH_GL(gc.total)] + | cmp RB, [DISPATCH+DISPATCH_GL(gc.threshold)] + | jb >1 + | call ->fff_gcstep + |1: + |.endmacro + | + |//-- Base library: checks ----------------------------------------------- + | + |.ffunc_1 assert + | mov RB, [BASE+4] + | cmp RB, LJ_TISTRUECOND; jae ->fff_fallback + | mov PC, [BASE-4] + | mov MULTRES, RD + | mov [BASE-4], RB + | mov RB, [BASE] + | mov [BASE-8], RB + | sub RD, 2 + | jz >2 + | mov RA, BASE + |1: + | add RA, 8 + |.if X64 + | mov RBa, [RA] + | mov [RA-8], RBa + |.else + | mov RB, [RA+4] + | mov [RA-4], RB + | mov RB, [RA] + | mov [RA-8], RB + |.endif + | sub RD, 1 + | jnz <1 + |2: + | mov RD, MULTRES + | jmp ->fff_res_ + | + |.ffunc_1 type + | mov RB, [BASE+4] + |.if X64 + | mov RA, RB + | sar RA, 15 + | cmp RA, -2 + | je >3 + |.endif + | mov RC, ~LJ_TNUMX + | not RB + | cmp RC, RB + | cmova RC, RB + |2: + | mov CFUNC:RB, [BASE-8] + | mov STR:RC, [CFUNC:RB+RC*8+((char *)(&((GCfuncC *)0)->upvalue))] + | mov PC, [BASE-4] + | mov dword [BASE-4], LJ_TSTR + | mov [BASE-8], STR:RC + | jmp ->fff_res1 + |.if X64 + |3: + | mov RC, ~LJ_TLIGHTUD + | jmp <2 + |.endif + | + |//-- Base library: getters and setters --------------------------------- + | + |.ffunc_1 getmetatable + | mov RB, [BASE+4] + | mov PC, [BASE-4] + | cmp RB, LJ_TTAB; jne >6 + |1: // Field metatable must be at same offset for GCtab and GCudata! + | mov TAB:RB, [BASE] + | mov TAB:RB, TAB:RB->metatable + |2: + | test TAB:RB, TAB:RB + | mov dword [BASE-4], LJ_TNIL + | jz ->fff_res1 + | mov STR:RC, [DISPATCH+DISPATCH_GL(gcroot)+4*(GCROOT_MMNAME+MM_metatable)] + | mov dword [BASE-4], LJ_TTAB // Store metatable as default result. + | mov [BASE-8], TAB:RB + | mov RA, TAB:RB->hmask + | and RA, STR:RC->hash + | imul RA, #NODE + | add NODE:RA, TAB:RB->node + |3: // Rearranged logic, because we expect _not_ to find the key. + | cmp dword NODE:RA->key.it, LJ_TSTR + | jne >4 + | cmp dword NODE:RA->key.gcr, STR:RC + | je >5 + |4: + | mov NODE:RA, NODE:RA->next + | test NODE:RA, NODE:RA + | jnz <3 + | jmp ->fff_res1 // Not found, keep default result. + |5: + | mov RB, [RA+4] + | cmp RB, LJ_TNIL; je ->fff_res1 // Ditto for nil value. + | mov RC, [RA] + | mov [BASE-4], RB // Return value of mt.__metatable. + | mov [BASE-8], RC + | jmp ->fff_res1 + | + |6: + | cmp RB, LJ_TUDATA; je <1 + |.if X64 + | cmp RB, LJ_TNUMX; ja >8 + | cmp RB, LJ_TISNUM; jbe >7 + | mov RB, LJ_TLIGHTUD + | jmp >8 + |7: + |.else + | cmp RB, LJ_TISNUM; ja >8 + |.endif + | mov RB, LJ_TNUMX + |8: + | not RB + | mov TAB:RB, [DISPATCH+RB*4+DISPATCH_GL(gcroot[GCROOT_BASEMT])] + | jmp <2 + | + |.ffunc_2 setmetatable + | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback + | // Fast path: no mt for table yet and not clearing the mt. + | mov TAB:RB, [BASE] + | cmp dword TAB:RB->metatable, 0; jne ->fff_fallback + | cmp dword [BASE+12], LJ_TTAB; jne ->fff_fallback + | mov TAB:RC, [BASE+8] + | mov TAB:RB->metatable, TAB:RC + | mov PC, [BASE-4] + | mov dword [BASE-4], LJ_TTAB // Return original table. + | mov [BASE-8], TAB:RB + | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) + | jz >1 + | // Possible write barrier. Table is black, but skip iswhite(mt) check. + | barrierback TAB:RB, RC + |1: + | jmp ->fff_res1 + | + |.ffunc_2 rawget + | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback + |.if X64WIN + | mov RB, BASE // Save BASE. + | lea CARG3d, [BASE+8] + | mov CARG2d, [BASE] // Caveat: CARG2d == BASE. + | mov CARG1d, SAVE_L + |.elif X64 + | mov RB, BASE // Save BASE. + | mov CARG2d, [BASE] + | lea CARG3d, [BASE+8] // Caveat: CARG3d == BASE. + | mov CARG1d, SAVE_L + |.else + | mov TAB:RD, [BASE] + | mov L:RB, SAVE_L + | mov ARG2, TAB:RD + | mov ARG1, L:RB + | mov RB, BASE // Save BASE. + | add BASE, 8 + | mov ARG3, BASE + |.endif + | call extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) + | // cTValue * returned in eax (RD). + | mov BASE, RB // Restore BASE. + | // Copy table slot. + |.if X64 + | mov RBa, [RD] + | mov PC, [BASE-4] + | mov [BASE-8], RBa + |.else + | mov RB, [RD] + | mov RD, [RD+4] + | mov PC, [BASE-4] + | mov [BASE-8], RB + | mov [BASE-4], RD + |.endif + | jmp ->fff_res1 + | + |//-- Base library: conversions ------------------------------------------ + | + |.ffunc tonumber + | // Only handles the number case inline (without a base argument). + | cmp NARGS:RD, 1+1; jne ->fff_fallback // Exactly one argument. + | cmp dword [BASE+4], LJ_TISNUM + |.if DUALNUM + | jne >1 + | mov RB, dword [BASE]; jmp ->fff_resi + |1: + | ja ->fff_fallback + |.else + | jae ->fff_fallback + |.endif + |.if SSE + | movsd xmm0, qword [BASE]; jmp ->fff_resxmm0 + |.else + | fld qword [BASE]; jmp ->fff_resn + |.endif + | + |.ffunc_1 tostring + | // Only handles the string or number case inline. + | mov PC, [BASE-4] + | cmp dword [BASE+4], LJ_TSTR; jne >3 + | // A __tostring method in the string base metatable is ignored. + | mov STR:RD, [BASE] + |2: + | mov dword [BASE-4], LJ_TSTR + | mov [BASE-8], STR:RD + | jmp ->fff_res1 + |3: // Handle numbers inline, unless a number base metatable is present. + | cmp dword [BASE+4], LJ_TISNUM; ja ->fff_fallback + | cmp dword [DISPATCH+DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])], 0 + | jne ->fff_fallback + | ffgccheck // Caveat: uses label 1. + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Add frame since C call can throw. + | mov SAVE_PC, PC // Redundant (but a defined value). + |.if X64 and not X64WIN + | mov FCARG2, BASE // Otherwise: FCARG2 == BASE + |.endif + | mov L:FCARG1, L:RB + |.if DUALNUM + | call extern lj_str_fromnumber@8 // (lua_State *L, cTValue *o) + |.else + | call extern lj_str_fromnum@8 // (lua_State *L, lua_Number *np) + |.endif + | // GCstr returned in eax (RD). + | mov BASE, L:RB->base + | jmp <2 + | + |//-- Base library: iterators ------------------------------------------- + | + |.ffunc_1 next + | je >2 // Missing 2nd arg? + |1: + | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Add frame since C call can throw. + | mov L:RB->top, BASE // Dummy frame length is ok. + | mov PC, [BASE-4] + |.if X64WIN + | lea CARG3d, [BASE+8] + | mov CARG2d, [BASE] // Caveat: CARG2d == BASE. + | mov CARG1d, L:RB + |.elif X64 + | mov CARG2d, [BASE] + | lea CARG3d, [BASE+8] // Caveat: CARG3d == BASE. + | mov CARG1d, L:RB + |.else + | mov TAB:RD, [BASE] + | mov ARG2, TAB:RD + | mov ARG1, L:RB + | add BASE, 8 + | mov ARG3, BASE + |.endif + | mov SAVE_PC, PC // Needed for ITERN fallback. + | call extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) + | // Flag returned in eax (RD). + | mov BASE, L:RB->base + | test RD, RD; jz >3 // End of traversal? + | // Copy key and value to results. + |.if X64 + | mov RBa, [BASE+8] + | mov RDa, [BASE+16] + | mov [BASE-8], RBa + | mov [BASE], RDa + |.else + | mov RB, [BASE+8] + | mov RD, [BASE+12] + | mov [BASE-8], RB + | mov [BASE-4], RD + | mov RB, [BASE+16] + | mov RD, [BASE+20] + | mov [BASE], RB + | mov [BASE+4], RD + |.endif + |->fff_res2: + | mov RD, 1+2 + | jmp ->fff_res + |2: // Set missing 2nd arg to nil. + | mov dword [BASE+12], LJ_TNIL + | jmp <1 + |3: // End of traversal: return nil. + | mov dword [BASE-4], LJ_TNIL + | jmp ->fff_res1 + | + |.ffunc_1 pairs + | mov TAB:RB, [BASE] + | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback +#if LJ_52 + | cmp dword TAB:RB->metatable, 0; jne ->fff_fallback +#endif + | mov CFUNC:RB, [BASE-8] + | mov CFUNC:RD, CFUNC:RB->upvalue[0] + | mov PC, [BASE-4] + | mov dword [BASE-4], LJ_TFUNC + | mov [BASE-8], CFUNC:RD + | mov dword [BASE+12], LJ_TNIL + | mov RD, 1+3 + | jmp ->fff_res + | + |.ffunc_2 ipairs_aux + | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback + | cmp dword [BASE+12], LJ_TISNUM + |.if DUALNUM + | jne ->fff_fallback + |.else + | jae ->fff_fallback + |.endif + | mov PC, [BASE-4] + |.if DUALNUM + | mov RD, dword [BASE+8] + | add RD, 1 + | mov dword [BASE-4], LJ_TISNUM + | mov dword [BASE-8], RD + |.elif SSE + | movsd xmm0, qword [BASE+8] + | sseconst_1 xmm1, RBa + | addsd xmm0, xmm1 + | cvtsd2si RD, xmm0 + | movsd qword [BASE-8], xmm0 + |.else + | fld qword [BASE+8] + | fld1 + | faddp st1 + | fist ARG1 + | fstp qword [BASE-8] + | mov RD, ARG1 + |.endif + | mov TAB:RB, [BASE] + | cmp RD, TAB:RB->asize; jae >2 // Not in array part? + | shl RD, 3 + | add RD, TAB:RB->array + |1: + | cmp dword [RD+4], LJ_TNIL; je ->fff_res0 + | // Copy array slot. + |.if X64 + | mov RBa, [RD] + | mov [BASE], RBa + |.else + | mov RB, [RD] + | mov RD, [RD+4] + | mov [BASE], RB + | mov [BASE+4], RD + |.endif + | jmp ->fff_res2 + |2: // Check for empty hash part first. Otherwise call C function. + | cmp dword TAB:RB->hmask, 0; je ->fff_res0 + | mov FCARG1, TAB:RB + | mov RB, BASE // Save BASE. + | mov FCARG2, RD // Caveat: FCARG2 == BASE + | call extern lj_tab_getinth@8 // (GCtab *t, int32_t key) + | // cTValue * or NULL returned in eax (RD). + | mov BASE, RB + | test RD, RD + | jnz <1 + |->fff_res0: + | mov RD, 1+0 + | jmp ->fff_res + | + |.ffunc_1 ipairs + | mov TAB:RB, [BASE] + | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback +#if LJ_52 + | cmp dword TAB:RB->metatable, 0; jne ->fff_fallback +#endif + | mov CFUNC:RB, [BASE-8] + | mov CFUNC:RD, CFUNC:RB->upvalue[0] + | mov PC, [BASE-4] + | mov dword [BASE-4], LJ_TFUNC + | mov [BASE-8], CFUNC:RD + |.if DUALNUM + | mov dword [BASE+12], LJ_TISNUM + | mov dword [BASE+8], 0 + |.elif SSE + | xorps xmm0, xmm0 + | movsd qword [BASE+8], xmm0 + |.else + | fldz + | fstp qword [BASE+8] + |.endif + | mov RD, 1+3 + | jmp ->fff_res + | + |//-- Base library: catch errors ---------------------------------------- + | + |.ffunc_1 pcall + | lea RA, [BASE+8] + | sub NARGS:RD, 1 + | mov PC, 8+FRAME_PCALL + |1: + | movzx RB, byte [DISPATCH+DISPATCH_GL(hookmask)] + | shr RB, HOOK_ACTIVE_SHIFT + | and RB, 1 + | add PC, RB // Remember active hook before pcall. + | jmp ->vm_call_dispatch + | + |.ffunc_2 xpcall + | cmp dword [BASE+12], LJ_TFUNC; jne ->fff_fallback + | mov RB, [BASE+4] // Swap function and traceback. + | mov [BASE+12], RB + | mov dword [BASE+4], LJ_TFUNC + | mov LFUNC:RB, [BASE] + | mov PC, [BASE+8] + | mov [BASE+8], LFUNC:RB + | mov [BASE], PC + | lea RA, [BASE+16] + | sub NARGS:RD, 2 + | mov PC, 16+FRAME_PCALL + | jmp <1 + | + |//-- Coroutine library -------------------------------------------------- + | + |.macro coroutine_resume_wrap, resume + |.if resume + |.ffunc_1 coroutine_resume + | mov L:RB, [BASE] + |.else + |.ffunc coroutine_wrap_aux + | mov CFUNC:RB, [BASE-8] + | mov L:RB, CFUNC:RB->upvalue[0].gcr + |.endif + | mov PC, [BASE-4] + | mov SAVE_PC, PC + |.if X64 + | mov TMP1, L:RB + |.else + | mov ARG1, L:RB + |.endif + |.if resume + | cmp dword [BASE+4], LJ_TTHREAD; jne ->fff_fallback + |.endif + | cmp aword L:RB->cframe, 0; jne ->fff_fallback + | cmp byte L:RB->status, LUA_YIELD; ja ->fff_fallback + | mov RA, L:RB->top + | je >1 // Status != LUA_YIELD (i.e. 0)? + | cmp RA, L:RB->base // Check for presence of initial func. + | je ->fff_fallback + |1: + |.if resume + | lea PC, [RA+NARGS:RD*8-16] // Check stack space (-1-thread). + |.else + | lea PC, [RA+NARGS:RD*8-8] // Check stack space (-1). + |.endif + | cmp PC, L:RB->maxstack; ja ->fff_fallback + | mov L:RB->top, PC + | + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + |.if resume + | add BASE, 8 // Keep resumed thread in stack for GC. + |.endif + | mov L:RB->top, BASE + |.if resume + | lea RB, [BASE+NARGS:RD*8-24] // RB = end of source for stack move. + |.else + | lea RB, [BASE+NARGS:RD*8-16] // RB = end of source for stack move. + |.endif + | sub RBa, PCa // Relative to PC. + | + | cmp PC, RA + | je >3 + |2: // Move args to coroutine. + |.if X64 + | mov RCa, [PC+RB] + | mov [PC-8], RCa + |.else + | mov RC, [PC+RB+4] + | mov [PC-4], RC + | mov RC, [PC+RB] + | mov [PC-8], RC + |.endif + | sub PC, 8 + | cmp PC, RA + | jne <2 + |3: + |.if X64 + | mov CARG2d, RA + | mov CARG1d, TMP1 + |.else + | mov ARG2, RA + | xor RA, RA + | mov ARG4, RA + | mov ARG3, RA + |.endif + | call ->vm_resume // (lua_State *L, TValue *base, 0, 0) + | set_vmstate INTERP + | + | mov L:RB, SAVE_L + |.if X64 + | mov L:PC, TMP1 + |.else + | mov L:PC, ARG1 // The callee doesn't modify SAVE_L. + |.endif + | mov BASE, L:RB->base + | cmp eax, LUA_YIELD + | ja >8 + |4: + | mov RA, L:PC->base + | mov KBASE, L:PC->top + | mov L:PC->top, RA // Clear coroutine stack. + | mov PC, KBASE + | sub PC, RA + | je >6 // No results? + | lea RD, [BASE+PC] + | shr PC, 3 + | cmp RD, L:RB->maxstack + | ja >9 // Need to grow stack? + | + | mov RB, BASE + | sub RBa, RAa + |5: // Move results from coroutine. + |.if X64 + | mov RDa, [RA] + | mov [RA+RB], RDa + |.else + | mov RD, [RA] + | mov [RA+RB], RD + | mov RD, [RA+4] + | mov [RA+RB+4], RD + |.endif + | add RA, 8 + | cmp RA, KBASE + | jne <5 + |6: + |.if resume + | lea RD, [PC+2] // nresults+1 = 1 + true + results. + | mov dword [BASE-4], LJ_TTRUE // Prepend true to results. + |.else + | lea RD, [PC+1] // nresults+1 = 1 + results. + |.endif + |7: + | mov PC, SAVE_PC + | mov MULTRES, RD + |.if resume + | mov RAa, -8 + |.else + | xor RA, RA + |.endif + | test PC, FRAME_TYPE + | jz ->BC_RET_Z + | jmp ->vm_return + | + |8: // Coroutine returned with error (at co->top-1). + |.if resume + | mov dword [BASE-4], LJ_TFALSE // Prepend false to results. + | mov RA, L:PC->top + | sub RA, 8 + | mov L:PC->top, RA // Clear error from coroutine stack. + | // Copy error message. + |.if X64 + | mov RDa, [RA] + | mov [BASE], RDa + |.else + | mov RD, [RA] + | mov [BASE], RD + | mov RD, [RA+4] + | mov [BASE+4], RD + |.endif + | mov RD, 1+2 // nresults+1 = 1 + false + error. + | jmp <7 + |.else + | mov FCARG2, L:PC + | mov FCARG1, L:RB + | call extern lj_ffh_coroutine_wrap_err@8 // (lua_State *L, lua_State *co) + | // Error function does not return. + |.endif + | + |9: // Handle stack expansion on return from yield. + |.if X64 + | mov L:RA, TMP1 + |.else + | mov L:RA, ARG1 // The callee doesn't modify SAVE_L. + |.endif + | mov L:RA->top, KBASE // Undo coroutine stack clearing. + | mov FCARG2, PC + | mov FCARG1, L:RB + | call extern lj_state_growstack@8 // (lua_State *L, int n) + |.if X64 + | mov L:PC, TMP1 + |.else + | mov L:PC, ARG1 + |.endif + | mov BASE, L:RB->base + | jmp <4 // Retry the stack move. + |.endmacro + | + | coroutine_resume_wrap 1 // coroutine.resume + | coroutine_resume_wrap 0 // coroutine.wrap + | + |.ffunc coroutine_yield + | mov L:RB, SAVE_L + | test aword L:RB->cframe, CFRAME_RESUME + | jz ->fff_fallback + | mov L:RB->base, BASE + | lea RD, [BASE+NARGS:RD*8-8] + | mov L:RB->top, RD + | xor RD, RD + | mov aword L:RB->cframe, RDa + | mov al, LUA_YIELD + | mov byte L:RB->status, al + | jmp ->vm_leave_unw + | + |//-- Math library ------------------------------------------------------- + | + |.if not DUALNUM + |->fff_resi: // Dummy. + |.endif + | + |.if SSE + |->fff_resn: + | mov PC, [BASE-4] + | fstp qword [BASE-8] + | jmp ->fff_res1 + |.endif + | + | .ffunc_1 math_abs + |.if DUALNUM + | cmp dword [BASE+4], LJ_TISNUM; jne >2 + | mov RB, dword [BASE] + | cmp RB, 0; jns ->fff_resi + | neg RB; js >1 + |->fff_resbit: + |->fff_resi: + | mov PC, [BASE-4] + | mov dword [BASE-4], LJ_TISNUM + | mov dword [BASE-8], RB + | jmp ->fff_res1 + |1: + | mov PC, [BASE-4] + | mov dword [BASE-4], 0x41e00000 // 2^31. + | mov dword [BASE-8], 0 + | jmp ->fff_res1 + |2: + | ja ->fff_fallback + |.else + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + |.endif + | + |.if SSE + | movsd xmm0, qword [BASE] + | sseconst_abs xmm1, RDa + | andps xmm0, xmm1 + |->fff_resxmm0: + | mov PC, [BASE-4] + | movsd qword [BASE-8], xmm0 + | // fallthrough + |.else + | fld qword [BASE] + | fabs + | // fallthrough + |->fff_resxmm0: // Dummy. + |->fff_resn: + | mov PC, [BASE-4] + | fstp qword [BASE-8] + |.endif + | + |->fff_res1: + | mov RD, 1+1 + |->fff_res: + | mov MULTRES, RD + |->fff_res_: + | test PC, FRAME_TYPE + | jnz >7 + |5: + | cmp PC_RB, RDL // More results expected? + | ja >6 + | // Adjust BASE. KBASE is assumed to be set for the calling frame. + | movzx RA, PC_RA + | not RAa // Note: ~RA = -(RA+1) + | lea BASE, [BASE+RA*8] // base = base - (RA+1)*8 + | ins_next + | + |6: // Fill up results with nil. + | mov dword [BASE+RD*8-12], LJ_TNIL + | add RD, 1 + | jmp <5 + | + |7: // Non-standard return case. + | mov RAa, -8 // Results start at BASE+RA = BASE-8. + | jmp ->vm_return + | + |.macro math_round, func + | .ffunc math_ .. func + |.if DUALNUM + | cmp dword [BASE+4], LJ_TISNUM; jne >1 + | mov RB, dword [BASE]; jmp ->fff_resi + |1: + | ja ->fff_fallback + |.else + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + |.endif + |.if SSE + | movsd xmm0, qword [BASE] + | call ->vm_ .. func + | .if DUALNUM + | cvtsd2si RB, xmm0 + | cmp RB, 0x80000000 + | jne ->fff_resi + | cvtsi2sd xmm1, RB + | ucomisd xmm0, xmm1 + | jp ->fff_resxmm0 + | je ->fff_resi + | .endif + | jmp ->fff_resxmm0 + |.else + | fld qword [BASE] + | call ->vm_ .. func + | .if DUALNUM + | fist ARG1 + | mov RB, ARG1 + | cmp RB, 0x80000000; jne >2 + | fdup + | fild ARG1 + | fcomparepp + | jp ->fff_resn + | jne ->fff_resn + |2: + | fpop + | jmp ->fff_resi + | .else + | jmp ->fff_resn + | .endif + |.endif + |.endmacro + | + | math_round floor + | math_round ceil + | + |.if SSE + |.ffunc_nsse math_sqrt, sqrtsd; jmp ->fff_resxmm0 + |.else + |.ffunc_n math_sqrt; fsqrt; jmp ->fff_resn + |.endif + | + |.ffunc math_log + | cmp NARGS:RD, 1+1; jne ->fff_fallback // Exactly one argument. + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + | fldln2; fld qword [BASE]; fyl2x; jmp ->fff_resn + | + |.ffunc_n math_log10, fldlg2; fyl2x; jmp ->fff_resn + |.ffunc_n math_exp; call ->vm_exp_x87; jmp ->fff_resn + | + |.ffunc_n math_sin; fsin; jmp ->fff_resn + |.ffunc_n math_cos; fcos; jmp ->fff_resn + |.ffunc_n math_tan; fptan; fpop; jmp ->fff_resn + | + |.ffunc_n math_asin + | fdup; fmul st0; fld1; fsubrp st1; fsqrt; fpatan + | jmp ->fff_resn + |.ffunc_n math_acos + | fdup; fmul st0; fld1; fsubrp st1; fsqrt; fxch; fpatan + | jmp ->fff_resn + |.ffunc_n math_atan; fld1; fpatan; jmp ->fff_resn + | + |.macro math_extern, func + |.if SSE + | .ffunc_nsse math_ .. func + | .if not X64 + | movsd FPARG1, xmm0 + | .endif + |.else + | .ffunc_n math_ .. func + | fstp FPARG1 + |.endif + | mov RB, BASE + | call extern lj_vm_ .. func + | mov BASE, RB + | .if X64 + | jmp ->fff_resxmm0 + | .else + | jmp ->fff_resn + | .endif + |.endmacro + | + | math_extern sinh + | math_extern cosh + | math_extern tanh + | + |->ff_math_deg: + |.if SSE + |.ffunc_nsse math_rad + | mov CFUNC:RB, [BASE-8] + | mulsd xmm0, qword CFUNC:RB->upvalue[0] + | jmp ->fff_resxmm0 + |.else + |.ffunc_n math_rad + | mov CFUNC:RB, [BASE-8] + | fmul qword CFUNC:RB->upvalue[0] + | jmp ->fff_resn + |.endif + | + |.ffunc_nn math_atan2; fpatan; jmp ->fff_resn + |.ffunc_nnr math_ldexp; fscale; fpop1; jmp ->fff_resn + | + |.ffunc_1 math_frexp + | mov RB, [BASE+4] + | cmp RB, LJ_TISNUM; jae ->fff_fallback + | mov PC, [BASE-4] + | mov RC, [BASE] + | mov [BASE-4], RB; mov [BASE-8], RC + | shl RB, 1; cmp RB, 0xffe00000; jae >3 + | or RC, RB; jz >3 + | mov RC, 1022 + | cmp RB, 0x00200000; jb >4 + |1: + | shr RB, 21; sub RB, RC // Extract and unbias exponent. + |.if SSE + | cvtsi2sd xmm0, RB + |.else + | mov TMP1, RB; fild TMP1 + |.endif + | mov RB, [BASE-4] + | and RB, 0x800fffff // Mask off exponent. + | or RB, 0x3fe00000 // Put mantissa in range [0.5,1) or 0. + | mov [BASE-4], RB + |2: + |.if SSE + | movsd qword [BASE], xmm0 + |.else + | fstp qword [BASE] + |.endif + | mov RD, 1+2 + | jmp ->fff_res + |3: // Return +-0, +-Inf, NaN unmodified and an exponent of 0. + |.if SSE + | xorps xmm0, xmm0; jmp <2 + |.else + | fldz; jmp <2 + |.endif + |4: // Handle denormals by multiplying with 2^54 and adjusting the bias. + |.if SSE + | movsd xmm0, qword [BASE] + | sseconst_hi xmm1, RBa, 43500000 // 2^54. + | mulsd xmm0, xmm1 + | movsd qword [BASE-8], xmm0 + |.else + | fld qword [BASE] + | mov TMP1, 0x5a800000; fmul TMP1 // x = x*2^54 + | fstp qword [BASE-8] + |.endif + | mov RB, [BASE-4]; mov RC, 1076; shl RB, 1; jmp <1 + | + |.if SSE + |.ffunc_nsse math_modf + |.else + |.ffunc_n math_modf + |.endif + | mov RB, [BASE+4] + | mov PC, [BASE-4] + | shl RB, 1; cmp RB, 0xffe00000; je >4 // +-Inf? + |.if SSE + | movaps xmm4, xmm0 + | call ->vm_trunc + | subsd xmm4, xmm0 + |1: + | movsd qword [BASE-8], xmm0 + | movsd qword [BASE], xmm4 + |.else + | fdup + | call ->vm_trunc + | fsub st1, st0 + |1: + | fstp qword [BASE-8] + | fstp qword [BASE] + |.endif + | mov RC, [BASE-4]; mov RB, [BASE+4] + | xor RC, RB; js >3 // Need to adjust sign? + |2: + | mov RD, 1+2 + | jmp ->fff_res + |3: + | xor RB, 0x80000000; mov [BASE+4], RB // Flip sign of fraction. + | jmp <2 + |4: + |.if SSE + | xorps xmm4, xmm4; jmp <1 // Return +-Inf and +-0. + |.else + | fldz; fxch; jmp <1 // Return +-Inf and +-0. + |.endif + | + |.ffunc_nnr math_fmod + |1: ; fprem; fnstsw ax; and ax, 0x400; jnz <1 + | fpop1 + | jmp ->fff_resn + | + |.if SSE + |.ffunc_nnsse math_pow; call ->vm_pow; jmp ->fff_resxmm0 + |.else + |.ffunc_nn math_pow; call ->vm_pow; jmp ->fff_resn + |.endif + | + |.macro math_minmax, name, cmovop, fcmovop, sseop + | .ffunc name + | mov RA, 2 + | cmp dword [BASE+4], LJ_TISNUM + |.if DUALNUM + | jne >4 + | mov RB, dword [BASE] + |1: // Handle integers. + | cmp RA, RD; jae ->fff_resi + | cmp dword [BASE+RA*8-4], LJ_TISNUM; jne >3 + | cmp RB, dword [BASE+RA*8-8] + | cmovop RB, dword [BASE+RA*8-8] + | add RA, 1 + | jmp <1 + |3: + | ja ->fff_fallback + | // Convert intermediate result to number and continue below. + |.if SSE + | cvtsi2sd xmm0, RB + |.else + | mov TMP1, RB + | fild TMP1 + |.endif + | jmp >6 + |4: + | ja ->fff_fallback + |.else + | jae ->fff_fallback + |.endif + | + |.if SSE + | movsd xmm0, qword [BASE] + |5: // Handle numbers or integers. + | cmp RA, RD; jae ->fff_resxmm0 + | cmp dword [BASE+RA*8-4], LJ_TISNUM + |.if DUALNUM + | jb >6 + | ja ->fff_fallback + | cvtsi2sd xmm1, dword [BASE+RA*8-8] + | jmp >7 + |.else + | jae ->fff_fallback + |.endif + |6: + | movsd xmm1, qword [BASE+RA*8-8] + |7: + | sseop xmm0, xmm1 + | add RA, 1 + | jmp <5 + |.else + | fld qword [BASE] + |5: // Handle numbers or integers. + | cmp RA, RD; jae ->fff_resn + | cmp dword [BASE+RA*8-4], LJ_TISNUM + |.if DUALNUM + | jb >6 + | ja >9 + | fild dword [BASE+RA*8-8] + | jmp >7 + |.else + | jae >9 + |.endif + |6: + | fld qword [BASE+RA*8-8] + |7: + | fucomi st1; fcmovop st1; fpop1 + | add RA, 1 + | jmp <5 + |.endif + |.endmacro + | + | math_minmax math_min, cmovg, fcmovnbe, minsd + | math_minmax math_max, cmovl, fcmovbe, maxsd + |.if not SSE + |9: + | fpop; jmp ->fff_fallback + |.endif + | + |//-- String library ----------------------------------------------------- + | + |.ffunc_1 string_len + | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback + | mov STR:RB, [BASE] + |.if DUALNUM + | mov RB, dword STR:RB->len; jmp ->fff_resi + |.elif SSE + | cvtsi2sd xmm0, dword STR:RB->len; jmp ->fff_resxmm0 + |.else + | fild dword STR:RB->len; jmp ->fff_resn + |.endif + | + |.ffunc string_byte // Only handle the 1-arg case here. + | cmp NARGS:RD, 1+1; jne ->fff_fallback + | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback + | mov STR:RB, [BASE] + | mov PC, [BASE-4] + | cmp dword STR:RB->len, 1 + | jb ->fff_res0 // Return no results for empty string. + | movzx RB, byte STR:RB[1] + |.if DUALNUM + | jmp ->fff_resi + |.elif SSE + | cvtsi2sd xmm0, RB; jmp ->fff_resxmm0 + |.else + | mov TMP1, RB; fild TMP1; jmp ->fff_resn + |.endif + | + |.ffunc string_char // Only handle the 1-arg case here. + | ffgccheck + | cmp NARGS:RD, 1+1; jne ->fff_fallback // *Exactly* 1 arg. + | cmp dword [BASE+4], LJ_TISNUM + |.if DUALNUM + | jne ->fff_fallback + | mov RB, dword [BASE] + | cmp RB, 255; ja ->fff_fallback + | mov TMP2, RB + |.elif SSE + | jae ->fff_fallback + | cvttsd2si RB, qword [BASE] + | cmp RB, 255; ja ->fff_fallback + | mov TMP2, RB + |.else + | jae ->fff_fallback + | fld qword [BASE] + | fistp TMP2 + | cmp TMP2, 255; ja ->fff_fallback + |.endif + |.if X64 + | mov TMP3, 1 + |.else + | mov ARG3, 1 + |.endif + | lea RDa, TMP2 // Points to stack. Little-endian. + |->fff_newstr: + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + |.if X64 + | mov CARG3d, TMP3 // Zero-extended to size_t. + | mov CARG2, RDa // May be 64 bit ptr to stack. + | mov CARG1d, L:RB + |.else + | mov ARG2, RD + | mov ARG1, L:RB + |.endif + | mov SAVE_PC, PC + | call extern lj_str_new // (lua_State *L, char *str, size_t l) + | // GCstr * returned in eax (RD). + | mov BASE, L:RB->base + | mov PC, [BASE-4] + | mov dword [BASE-4], LJ_TSTR + | mov [BASE-8], STR:RD + | jmp ->fff_res1 + | + |.ffunc string_sub + | ffgccheck + | mov TMP2, -1 + | cmp NARGS:RD, 1+2; jb ->fff_fallback + | jna >1 + | cmp dword [BASE+20], LJ_TISNUM + |.if DUALNUM + | jne ->fff_fallback + | mov RB, dword [BASE+16] + | mov TMP2, RB + |.elif SSE + | jae ->fff_fallback + | cvttsd2si RB, qword [BASE+16] + | mov TMP2, RB + |.else + | jae ->fff_fallback + | fld qword [BASE+16] + | fistp TMP2 + |.endif + |1: + | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback + | cmp dword [BASE+12], LJ_TISNUM + |.if DUALNUM + | jne ->fff_fallback + |.else + | jae ->fff_fallback + |.endif + | mov STR:RB, [BASE] + | mov TMP3, STR:RB + | mov RB, STR:RB->len + |.if DUALNUM + | mov RA, dword [BASE+8] + |.elif SSE + | cvttsd2si RA, qword [BASE+8] + |.else + | fld qword [BASE+8] + | fistp ARG3 + | mov RA, ARG3 + |.endif + | mov RC, TMP2 + | cmp RB, RC // len < end? (unsigned compare) + | jb >5 + |2: + | test RA, RA // start <= 0? + | jle >7 + |3: + | mov STR:RB, TMP3 + | sub RC, RA // start > end? + | jl ->fff_emptystr + | lea RB, [STR:RB+RA+#STR-1] + | add RC, 1 + |4: + |.if X64 + | mov TMP3, RC + |.else + | mov ARG3, RC + |.endif + | mov RD, RB + | jmp ->fff_newstr + | + |5: // Negative end or overflow. + | jl >6 + | lea RC, [RC+RB+1] // end = end+(len+1) + | jmp <2 + |6: // Overflow. + | mov RC, RB // end = len + | jmp <2 + | + |7: // Negative start or underflow. + | je >8 + | add RA, RB // start = start+(len+1) + | add RA, 1 + | jg <3 // start > 0? + |8: // Underflow. + | mov RA, 1 // start = 1 + | jmp <3 + | + |->fff_emptystr: // Range underflow. + | xor RC, RC // Zero length. Any ptr in RB is ok. + | jmp <4 + | + |.ffunc string_rep // Only handle the 1-char case inline. + | ffgccheck + | cmp NARGS:RD, 2+1; jne ->fff_fallback // Exactly 2 arguments. + | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback + | cmp dword [BASE+12], LJ_TISNUM + | mov STR:RB, [BASE] + |.if DUALNUM + | jne ->fff_fallback + | mov RC, dword [BASE+8] + |.elif SSE + | jae ->fff_fallback + | cvttsd2si RC, qword [BASE+8] + |.else + | jae ->fff_fallback + | fld qword [BASE+8] + | fistp TMP2 + | mov RC, TMP2 + |.endif + | test RC, RC + | jle ->fff_emptystr // Count <= 0? (or non-int) + | cmp dword STR:RB->len, 1 + | jb ->fff_emptystr // Zero length string? + | jne ->fff_fallback_2 // Fallback for > 1-char strings. + | cmp [DISPATCH+DISPATCH_GL(tmpbuf.sz)], RC; jb ->fff_fallback_2 + | movzx RA, byte STR:RB[1] + | mov RB, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] + |.if X64 + | mov TMP3, RC + |.else + | mov ARG3, RC + |.endif + |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). + | mov [RB], RAL + | add RB, 1 + | sub RC, 1 + | jnz <1 + | mov RD, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] + | jmp ->fff_newstr + | + |.ffunc_1 string_reverse + | ffgccheck + | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback + | mov STR:RB, [BASE] + | mov RC, STR:RB->len + | test RC, RC + | jz ->fff_emptystr // Zero length string? + | cmp [DISPATCH+DISPATCH_GL(tmpbuf.sz)], RC; jb ->fff_fallback_1 + | add RB, #STR + | mov TMP2, PC // Need another temp register. + |.if X64 + | mov TMP3, RC + |.else + | mov ARG3, RC + |.endif + | mov PC, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] + |1: + | movzx RA, byte [RB] + | add RB, 1 + | sub RC, 1 + | mov [PC+RC], RAL + | jnz <1 + | mov RD, PC + | mov PC, TMP2 + | jmp ->fff_newstr + | + |.macro ffstring_case, name, lo, hi + | .ffunc_1 name + | ffgccheck + | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback + | mov STR:RB, [BASE] + | mov RC, STR:RB->len + | cmp [DISPATCH+DISPATCH_GL(tmpbuf.sz)], RC; jb ->fff_fallback_1 + | add RB, #STR + | mov TMP2, PC // Need another temp register. + |.if X64 + | mov TMP3, RC + |.else + | mov ARG3, RC + |.endif + | mov PC, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] + | jmp >3 + |1: // ASCII case conversion. Yes, this is suboptimal code (do you care?). + | movzx RA, byte [RB+RC] + | cmp RA, lo + | jb >2 + | cmp RA, hi + | ja >2 + | xor RA, 0x20 + |2: + | mov [PC+RC], RAL + |3: + | sub RC, 1 + | jns <1 + | mov RD, PC + | mov PC, TMP2 + | jmp ->fff_newstr + |.endmacro + | + |ffstring_case string_lower, 0x41, 0x5a + |ffstring_case string_upper, 0x61, 0x7a + | + |//-- Table library ------------------------------------------------------ + | + |.ffunc_1 table_getn + | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback + | mov RB, BASE // Save BASE. + | mov TAB:FCARG1, [BASE] + | call extern lj_tab_len@4 // LJ_FASTCALL (GCtab *t) + | // Length of table returned in eax (RD). + | mov BASE, RB // Restore BASE. + |.if DUALNUM + | mov RB, RD; jmp ->fff_resi + |.elif SSE + | cvtsi2sd xmm0, RD; jmp ->fff_resxmm0 + |.else + | mov ARG1, RD; fild ARG1; jmp ->fff_resn + |.endif + | + |//-- Bit library -------------------------------------------------------- + | + |.define TOBIT_BIAS, 0x59c00000 // 2^52 + 2^51 (float, not double!). + | + |.macro .ffunc_bit, name, kind, fdef + | fdef name + |.if kind == 2 + |.if SSE + | sseconst_tobit xmm1, RBa + |.else + | mov TMP1, TOBIT_BIAS + |.endif + |.endif + | cmp dword [BASE+4], LJ_TISNUM + |.if DUALNUM + | jne >1 + | mov RB, dword [BASE] + |.if kind > 0 + | jmp >2 + |.else + | jmp ->fff_resbit + |.endif + |1: + | ja ->fff_fallback + |.else + | jae ->fff_fallback + |.endif + |.if SSE + | movsd xmm0, qword [BASE] + |.if kind < 2 + | sseconst_tobit xmm1, RBa + |.endif + | addsd xmm0, xmm1 + | movd RB, xmm0 + |.else + | fld qword [BASE] + |.if kind < 2 + | mov TMP1, TOBIT_BIAS + |.endif + | fadd TMP1 + | fstp FPARG1 + |.if kind > 0 + | mov RB, ARG1 + |.endif + |.endif + |2: + |.endmacro + | + |.macro .ffunc_bit, name, kind + | .ffunc_bit name, kind, .ffunc_1 + |.endmacro + | + |.ffunc_bit bit_tobit, 0 + |.if DUALNUM or SSE + |.if not SSE + | mov RB, ARG1 + |.endif + | jmp ->fff_resbit + |.else + | fild ARG1 + | jmp ->fff_resn + |.endif + | + |.macro .ffunc_bit_op, name, ins + | .ffunc_bit name, 2 + | mov TMP2, NARGS:RD // Save for fallback. + | lea RD, [BASE+NARGS:RD*8-16] + |1: + | cmp RD, BASE + | jbe ->fff_resbit + | cmp dword [RD+4], LJ_TISNUM + |.if DUALNUM + | jne >2 + | ins RB, dword [RD] + | sub RD, 8 + | jmp <1 + |2: + | ja ->fff_fallback_bit_op + |.else + | jae ->fff_fallback_bit_op + |.endif + |.if SSE + | movsd xmm0, qword [RD] + | addsd xmm0, xmm1 + | movd RA, xmm0 + | ins RB, RA + |.else + | fld qword [RD] + | fadd TMP1 + | fstp FPARG1 + | ins RB, ARG1 + |.endif + | sub RD, 8 + | jmp <1 + |.endmacro + | + |.ffunc_bit_op bit_band, and + |.ffunc_bit_op bit_bor, or + |.ffunc_bit_op bit_bxor, xor + | + |.ffunc_bit bit_bswap, 1 + | bswap RB + | jmp ->fff_resbit + | + |.ffunc_bit bit_bnot, 1 + | not RB + |.if DUALNUM + | jmp ->fff_resbit + |.elif SSE + |->fff_resbit: + | cvtsi2sd xmm0, RB + | jmp ->fff_resxmm0 + |.else + |->fff_resbit: + | mov ARG1, RB + | fild ARG1 + | jmp ->fff_resn + |.endif + | + |->fff_fallback_bit_op: + | mov NARGS:RD, TMP2 // Restore for fallback + | jmp ->fff_fallback + | + |.macro .ffunc_bit_sh, name, ins + |.if DUALNUM + | .ffunc_bit name, 1, .ffunc_2 + | // Note: no inline conversion from number for 2nd argument! + | cmp dword [BASE+12], LJ_TISNUM; jne ->fff_fallback + | mov RA, dword [BASE+8] + |.elif SSE + | .ffunc_nnsse name + | sseconst_tobit xmm2, RBa + | addsd xmm0, xmm2 + | addsd xmm1, xmm2 + | movd RB, xmm0 + | movd RA, xmm1 + |.else + | .ffunc_nn name + | mov TMP1, TOBIT_BIAS + | fadd TMP1 + | fstp FPARG3 + | fadd TMP1 + | fstp FPARG1 + | mov RA, ARG3 + | mov RB, ARG1 + |.endif + | ins RB, cl // Assumes RA is ecx. + | jmp ->fff_resbit + |.endmacro + | + |.ffunc_bit_sh bit_lshift, shl + |.ffunc_bit_sh bit_rshift, shr + |.ffunc_bit_sh bit_arshift, sar + |.ffunc_bit_sh bit_rol, rol + |.ffunc_bit_sh bit_ror, ror + | + |//----------------------------------------------------------------------- + | + |->fff_fallback_2: + | mov NARGS:RD, 1+2 // Other args are ignored, anyway. + | jmp ->fff_fallback + |->fff_fallback_1: + | mov NARGS:RD, 1+1 // Other args are ignored, anyway. + |->fff_fallback: // Call fast function fallback handler. + | // BASE = new base, RD = nargs+1 + | mov L:RB, SAVE_L + | mov PC, [BASE-4] // Fallback may overwrite PC. + | mov SAVE_PC, PC // Redundant (but a defined value). + | mov L:RB->base, BASE + | lea RD, [BASE+NARGS:RD*8-8] + | lea RA, [RD+8*LUA_MINSTACK] // Ensure enough space for handler. + | mov L:RB->top, RD + | mov CFUNC:RD, [BASE-8] + | cmp RA, L:RB->maxstack + | ja >5 // Need to grow stack. + |.if X64 + | mov CARG1d, L:RB + |.else + | mov ARG1, L:RB + |.endif + | call aword CFUNC:RD->f // (lua_State *L) + | mov BASE, L:RB->base + | // Either throws an error, or recovers and returns -1, 0 or nresults+1. + | test RD, RD; jg ->fff_res // Returned nresults+1? + |1: + | mov RA, L:RB->top + | sub RA, BASE + | shr RA, 3 + | test RD, RD + | lea NARGS:RD, [RA+1] + | mov LFUNC:RB, [BASE-8] + | jne ->vm_call_tail // Returned -1? + | ins_callt // Returned 0: retry fast path. + | + |// Reconstruct previous base for vmeta_call during tailcall. + |->vm_call_tail: + | mov RA, BASE + | test PC, FRAME_TYPE + | jnz >3 + | movzx RB, PC_RA + | not RBa // Note: ~RB = -(RB+1) + | lea BASE, [BASE+RB*8] // base = base - (RB+1)*8 + | jmp ->vm_call_dispatch // Resolve again for tailcall. + |3: + | mov RB, PC + | and RB, -8 + | sub BASE, RB + | jmp ->vm_call_dispatch // Resolve again for tailcall. + | + |5: // Grow stack for fallback handler. + | mov FCARG2, LUA_MINSTACK + | mov FCARG1, L:RB + | call extern lj_state_growstack@8 // (lua_State *L, int n) + | mov BASE, L:RB->base + | xor RD, RD // Simulate a return 0. + | jmp <1 // Dumb retry (goes through ff first). + | + |->fff_gcstep: // Call GC step function. + | // BASE = new base, RD = nargs+1 + | pop RBa // Must keep stack at same level. + | mov TMPa, RBa // Save return address + | mov L:RB, SAVE_L + | mov SAVE_PC, PC // Redundant (but a defined value). + | mov L:RB->base, BASE + | lea RD, [BASE+NARGS:RD*8-8] + | mov FCARG1, L:RB + | mov L:RB->top, RD + | call extern lj_gc_step@4 // (lua_State *L) + | mov BASE, L:RB->base + | mov RD, L:RB->top + | sub RD, BASE + | shr RD, 3 + | add NARGS:RD, 1 + | mov RBa, TMPa + | push RBa // Restore return address. + | ret + | + |//----------------------------------------------------------------------- + |//-- Special dispatch targets ------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_record: // Dispatch target for recording phase. + |.if JIT + | movzx RD, byte [DISPATCH+DISPATCH_GL(hookmask)] + | test RDL, HOOK_VMEVENT // No recording while in vmevent. + | jnz >5 + | // Decrement the hookcount for consistency, but always do the call. + | test RDL, HOOK_ACTIVE + | jnz >1 + | test RDL, LUA_MASKLINE|LUA_MASKCOUNT + | jz >1 + | dec dword [DISPATCH+DISPATCH_GL(hookcount)] + | jmp >1 + |.endif + | + |->vm_rethook: // Dispatch target for return hooks. + | movzx RD, byte [DISPATCH+DISPATCH_GL(hookmask)] + | test RDL, HOOK_ACTIVE // Hook already active? + | jnz >5 + | jmp >1 + | + |->vm_inshook: // Dispatch target for instr/line hooks. + | movzx RD, byte [DISPATCH+DISPATCH_GL(hookmask)] + | test RDL, HOOK_ACTIVE // Hook already active? + | jnz >5 + | + | test RDL, LUA_MASKLINE|LUA_MASKCOUNT + | jz >5 + | dec dword [DISPATCH+DISPATCH_GL(hookcount)] + | jz >1 + | test RDL, LUA_MASKLINE + | jz >5 + |1: + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | mov FCARG2, PC // Caveat: FCARG2 == BASE + | mov FCARG1, L:RB + | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. + | call extern lj_dispatch_ins@8 // (lua_State *L, BCIns *pc) + |3: + | mov BASE, L:RB->base + |4: + | movzx RA, PC_RA + |5: + | movzx OP, PC_OP + | movzx RD, PC_RD + |.if X64 + | jmp aword [DISPATCH+OP*8+GG_DISP2STATIC] // Re-dispatch to static ins. + |.else + | jmp aword [DISPATCH+OP*4+GG_DISP2STATIC] // Re-dispatch to static ins. + |.endif + | + |->cont_hook: // Continue from hook yield. + | add PC, 4 + | mov RA, [RB-24] + | mov MULTRES, RA // Restore MULTRES for *M ins. + | jmp <4 + | + |->vm_hotloop: // Hot loop counter underflow. + |.if JIT + | mov LFUNC:RB, [BASE-8] // Same as curr_topL(L). + | mov RB, LFUNC:RB->pc + | movzx RD, byte [RB+PC2PROTO(framesize)] + | lea RD, [BASE+RD*8] + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | mov L:RB->top, RD + | mov FCARG2, PC + | lea FCARG1, [DISPATCH+GG_DISP2J] + | mov aword [DISPATCH+DISPATCH_J(L)], L:RBa + | mov SAVE_PC, PC + | call extern lj_trace_hot@8 // (jit_State *J, const BCIns *pc) + | jmp <3 + |.endif + | + |->vm_callhook: // Dispatch target for call hooks. + | mov SAVE_PC, PC + |.if JIT + | jmp >1 + |.endif + | + |->vm_hotcall: // Hot call counter underflow. + |.if JIT + | mov SAVE_PC, PC + | or PC, 1 // Marker for hot call. + |1: + |.endif + | lea RD, [BASE+NARGS:RD*8-8] + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | mov L:RB->top, RD + | mov FCARG2, PC + | mov FCARG1, L:RB + | call extern lj_dispatch_call@8 // (lua_State *L, const BCIns *pc) + | // ASMFunction returned in eax/rax (RDa). + | mov SAVE_PC, 0 // Invalidate for subsequent line hook. + |.if JIT + | and PC, -2 + |.endif + | mov BASE, L:RB->base + | mov RAa, RDa + | mov RD, L:RB->top + | sub RD, BASE + | mov RBa, RAa + | movzx RA, PC_RA + | shr RD, 3 + | add NARGS:RD, 1 + | jmp RBa + | + |//----------------------------------------------------------------------- + |//-- Trace exit handler ------------------------------------------------- + |//----------------------------------------------------------------------- + | + |// Called from an exit stub with the exit number on the stack. + |// The 16 bit exit number is stored with two (sign-extended) push imm8. + |->vm_exit_handler: + |.if JIT + |.if X64 + | push r13; push r12 + | push r11; push r10; push r9; push r8 + | push rdi; push rsi; push rbp; lea rbp, [rsp+88]; push rbp + | push rbx; push rdx; push rcx; push rax + | movzx RC, byte [rbp-8] // Reconstruct exit number. + | mov RCH, byte [rbp-16] + | mov [rbp-8], r15; mov [rbp-16], r14 + |.else + | push ebp; lea ebp, [esp+12]; push ebp + | push ebx; push edx; push ecx; push eax + | movzx RC, byte [ebp-4] // Reconstruct exit number. + | mov RCH, byte [ebp-8] + | mov [ebp-4], edi; mov [ebp-8], esi + |.endif + | // Caveat: DISPATCH is ebx. + | mov DISPATCH, [ebp] + | mov RA, [DISPATCH+DISPATCH_GL(vmstate)] // Get trace number. + | set_vmstate EXIT + | mov [DISPATCH+DISPATCH_J(exitno)], RC + | mov [DISPATCH+DISPATCH_J(parent)], RA + |.if X64 + |.if X64WIN + | sub rsp, 16*8+4*8 // Room for SSE regs + save area. + |.else + | sub rsp, 16*8 // Room for SSE regs. + |.endif + | add rbp, -128 + | movsd qword [rbp-8], xmm15; movsd qword [rbp-16], xmm14 + | movsd qword [rbp-24], xmm13; movsd qword [rbp-32], xmm12 + | movsd qword [rbp-40], xmm11; movsd qword [rbp-48], xmm10 + | movsd qword [rbp-56], xmm9; movsd qword [rbp-64], xmm8 + | movsd qword [rbp-72], xmm7; movsd qword [rbp-80], xmm6 + | movsd qword [rbp-88], xmm5; movsd qword [rbp-96], xmm4 + | movsd qword [rbp-104], xmm3; movsd qword [rbp-112], xmm2 + | movsd qword [rbp-120], xmm1; movsd qword [rbp-128], xmm0 + |.else + | sub esp, 8*8+16 // Room for SSE regs + args. + | movsd qword [ebp-40], xmm7; movsd qword [ebp-48], xmm6 + | movsd qword [ebp-56], xmm5; movsd qword [ebp-64], xmm4 + | movsd qword [ebp-72], xmm3; movsd qword [ebp-80], xmm2 + | movsd qword [ebp-88], xmm1; movsd qword [ebp-96], xmm0 + |.endif + | // Caveat: RB is ebp. + | mov L:RB, [DISPATCH+DISPATCH_GL(jit_L)] + | mov BASE, [DISPATCH+DISPATCH_GL(jit_base)] + | mov aword [DISPATCH+DISPATCH_J(L)], L:RBa + | mov dword [DISPATCH+DISPATCH_GL(jit_L)], 0 + | mov L:RB->base, BASE + |.if X64WIN + | lea CARG2, [rsp+4*8] + |.elif X64 + | mov CARG2, rsp + |.else + | lea FCARG2, [esp+16] + |.endif + | lea FCARG1, [DISPATCH+GG_DISP2J] + | call extern lj_trace_exit@8 // (jit_State *J, ExitState *ex) + | // MULTRES or negated error code returned in eax (RD). + | mov RAa, L:RB->cframe + | and RAa, CFRAME_RAWMASK + |.if X64WIN + | // Reposition stack later. + |.elif X64 + | mov rsp, RAa // Reposition stack to C frame. + |.else + | mov esp, RAa // Reposition stack to C frame. + |.endif + | mov [RAa+CFRAME_OFS_L], L:RB // Set SAVE_L (on-trace resume/yield). + | mov BASE, L:RB->base + | mov PC, [RAa+CFRAME_OFS_PC] // Get SAVE_PC. + |.if X64 + | jmp >1 + |.endif + |.endif + |->vm_exit_interp: + | // RD = MULTRES or negated error code, BASE, PC and DISPATCH set. + |.if JIT + |.if X64 + | // Restore additional callee-save registers only used in compiled code. + |.if X64WIN + | lea RAa, [rsp+9*16+4*8] + |1: + | movdqa xmm15, [RAa-9*16] + | movdqa xmm14, [RAa-8*16] + | movdqa xmm13, [RAa-7*16] + | movdqa xmm12, [RAa-6*16] + | movdqa xmm11, [RAa-5*16] + | movdqa xmm10, [RAa-4*16] + | movdqa xmm9, [RAa-3*16] + | movdqa xmm8, [RAa-2*16] + | movdqa xmm7, [RAa-1*16] + | mov rsp, RAa // Reposition stack to C frame. + | movdqa xmm6, [RAa] + | mov r15, CSAVE_3 + | mov r14, CSAVE_4 + |.else + | add rsp, 16 // Reposition stack to C frame. + |1: + |.endif + | mov r13, TMPa + | mov r12, TMPQ + |.endif + | test RD, RD; js >3 // Check for error from exit. + | mov MULTRES, RD + | mov LFUNC:KBASE, [BASE-8] + | mov KBASE, LFUNC:KBASE->pc + | mov KBASE, [KBASE+PC2PROTO(k)] + | mov dword [DISPATCH+DISPATCH_GL(jit_L)], 0 + | set_vmstate INTERP + | // Modified copy of ins_next which handles function header dispatch, too. + | mov RC, [PC] + | movzx RA, RCH + | movzx OP, RCL + | add PC, 4 + | shr RC, 16 + | cmp OP, BC_FUNCF // Function header? + | jb >2 + | mov RC, MULTRES // RC/RD holds nres+1. + |2: + |.if X64 + | jmp aword [DISPATCH+OP*8] + |.else + | jmp aword [DISPATCH+OP*4] + |.endif + | + |3: // Rethrow error from the right C frame. + | neg RD + | mov FCARG1, L:RB + | mov FCARG2, RD + | call extern lj_err_throw@8 // (lua_State *L, int errcode) + |.endif + | + |//----------------------------------------------------------------------- + |//-- Math helper functions ---------------------------------------------- + |//----------------------------------------------------------------------- + | + |// FP value rounding. Called by math.floor/math.ceil fast functions + |// and from JIT code. + | + |// x87 variant: Arg/ret on x87 stack. No int/xmm registers modified. + |.macro vm_round_x87, mode1, mode2 + | fnstcw word [esp+4] // Caveat: overwrites ARG1 and ARG2. + | mov [esp+8], eax + | mov ax, mode1 + | or ax, [esp+4] + |.if mode2 ~= 0xffff + | and ax, mode2 + |.endif + | mov [esp+6], ax + | fldcw word [esp+6] + | frndint + | fldcw word [esp+4] + | mov eax, [esp+8] + | ret + |.endmacro + | + |// SSE variant: arg/ret is xmm0. xmm0-xmm3 and RD (eax) modified. + |.macro vm_round_sse, mode + | sseconst_abs xmm2, RDa + | sseconst_2p52 xmm3, RDa + | movaps xmm1, xmm0 + | andpd xmm1, xmm2 // |x| + | ucomisd xmm3, xmm1 // No truncation if 2^52 <= |x|. + | jbe >1 + | andnpd xmm2, xmm0 // Isolate sign bit. + |.if mode == 2 // trunc(x)? + | movaps xmm0, xmm1 + | addsd xmm1, xmm3 // (|x| + 2^52) - 2^52 + | subsd xmm1, xmm3 + | sseconst_1 xmm3, RDa + | cmpsd xmm0, xmm1, 1 // |x| < result? + | andpd xmm0, xmm3 + | subsd xmm1, xmm0 // If yes, subtract -1. + | orpd xmm1, xmm2 // Merge sign bit back in. + |.else + | addsd xmm1, xmm3 // (|x| + 2^52) - 2^52 + | subsd xmm1, xmm3 + | orpd xmm1, xmm2 // Merge sign bit back in. + | .if mode == 1 // ceil(x)? + | sseconst_m1 xmm2, RDa // Must subtract -1 to preserve -0. + | cmpsd xmm0, xmm1, 6 // x > result? + | .else // floor(x)? + | sseconst_1 xmm2, RDa + | cmpsd xmm0, xmm1, 1 // x < result? + | .endif + | andpd xmm0, xmm2 + | subsd xmm1, xmm0 // If yes, subtract +-1. + |.endif + | movaps xmm0, xmm1 + |1: + | ret + |.endmacro + | + |.macro vm_round, name, ssemode, mode1, mode2 + |->name: + |.if not SSE + | vm_round_x87 mode1, mode2 + |.endif + |->name .. _sse: + | vm_round_sse ssemode + |.endmacro + | + | vm_round vm_floor, 0, 0x0400, 0xf7ff + | vm_round vm_ceil, 1, 0x0800, 0xfbff + | vm_round vm_trunc, 2, 0x0c00, 0xffff + | + |// FP modulo x%y. Called by BC_MOD* and vm_arith. + |->vm_mod: + |.if SSE + |// Args in xmm0/xmm1, return value in xmm0. + |// Caveat: xmm0-xmm5 and RC (eax) modified! + | movaps xmm5, xmm0 + | divsd xmm0, xmm1 + | sseconst_abs xmm2, RDa + | sseconst_2p52 xmm3, RDa + | movaps xmm4, xmm0 + | andpd xmm4, xmm2 // |x/y| + | ucomisd xmm3, xmm4 // No truncation if 2^52 <= |x/y|. + | jbe >1 + | andnpd xmm2, xmm0 // Isolate sign bit. + | addsd xmm4, xmm3 // (|x/y| + 2^52) - 2^52 + | subsd xmm4, xmm3 + | orpd xmm4, xmm2 // Merge sign bit back in. + | sseconst_1 xmm2, RDa + | cmpsd xmm0, xmm4, 1 // x/y < result? + | andpd xmm0, xmm2 + | subsd xmm4, xmm0 // If yes, subtract 1.0. + | movaps xmm0, xmm5 + | mulsd xmm1, xmm4 + | subsd xmm0, xmm1 + | ret + |1: + | mulsd xmm1, xmm0 + | movaps xmm0, xmm5 + | subsd xmm0, xmm1 + | ret + |.else + |// Args/ret on x87 stack (y on top). No xmm registers modified. + |// Caveat: needs 3 slots on x87 stack! RC (eax) modified! + | fld st1 + | fdiv st1 + | fnstcw word [esp+4] + | mov ax, 0x0400 + | or ax, [esp+4] + | and ax, 0xf7ff + | mov [esp+6], ax + | fldcw word [esp+6] + | frndint + | fldcw word [esp+4] + | fmulp st1 + | fsubp st1 + | ret + |.endif + | + |// FP log2(x). Called by math.log(x, base). + |->vm_log2: + |.if X64WIN + | movsd qword [rsp+8], xmm0 // Use scratch area. + | fld1 + | fld qword [rsp+8] + | fyl2x + | fstp qword [rsp+8] + | movsd xmm0, qword [rsp+8] + |.elif X64 + | movsd qword [rsp-8], xmm0 // Use red zone. + | fld1 + | fld qword [rsp-8] + | fyl2x + | fstp qword [rsp-8] + | movsd xmm0, qword [rsp-8] + |.else + | fld1 + | fld qword [esp+4] + | fyl2x + |.endif + | ret + | + |// FP exponentiation e^x and 2^x. Called by math.exp fast function and + |// from JIT code. Arg/ret on x87 stack. No int/xmm regs modified. + |// Caveat: needs 3 slots on x87 stack! + |->vm_exp_x87: + | fldl2e; fmulp st1 // e^x ==> 2^(x*log2(e)) + |->vm_exp2_x87: + | .if X64WIN + | .define expscratch, dword [rsp+8] // Use scratch area. + | .elif X64 + | .define expscratch, dword [rsp-8] // Use red zone. + | .else + | .define expscratch, dword [esp+4] // Needs 4 byte scratch area. + | .endif + | fst expscratch // Caveat: overwrites ARG1. + | cmp expscratch, 0x7f800000; je >1 // Special case: e^+Inf = +Inf + | cmp expscratch, 0xff800000; je >2 // Special case: e^-Inf = 0 + |->vm_exp2raw: // Entry point for vm_pow. Without +-Inf check. + | fdup; frndint; fsub st1, st0; fxch // Split into frac/int part. + | f2xm1; fld1; faddp st1; fscale; fpop1 // ==> (2^frac-1 +1) << int + |1: + | ret + |2: + | fpop; fldz; ret + | + |// Generic power function x^y. Called by BC_POW, math.pow fast function, + |// and vm_arith. + |// Args/ret on x87 stack (y on top). RC (eax) modified. + |// Caveat: needs 3 slots on x87 stack! + |->vm_pow: + |.if not SSE + | fist dword [esp+4] // Store/reload int before comparison. + | fild dword [esp+4] // Integral exponent used in vm_powi. + | fucomip st1 + | jnz >8 // Branch for FP exponents. + | jp >9 // Branch for NaN exponent. + | fpop // Pop y and fallthrough to vm_powi. + | + |// FP/int power function x^i. Arg1/ret on x87 stack. + |// Arg2 (int) on C stack. RC (eax) modified. + |// Caveat: needs 2 slots on x87 stack! + | mov eax, [esp+4] + | cmp eax, 1; jle >6 // i<=1? + | // Now 1 < (unsigned)i <= 0x80000000. + |1: // Handle leading zeros. + | test eax, 1; jnz >2 + | fmul st0 + | shr eax, 1 + | jmp <1 + |2: + | shr eax, 1; jz >5 + | fdup + |3: // Handle trailing bits. + | fmul st0 + | shr eax, 1; jz >4 + | jnc <3 + | fmul st1, st0 + | jmp <3 + |4: + | fmulp st1 + |5: + | ret + |6: + | je <5 // x^1 ==> x + | jb >7 + | fld1; fdivrp st1 + | neg eax + | cmp eax, 1; je <5 // x^-1 ==> 1/x + | jmp <1 // x^-i ==> (1/x)^i + |7: + | fpop; fld1 // x^0 ==> 1 + | ret + | + |8: // FP/FP power function x^y. + | fst dword [esp+4] + | fxch + | fst dword [esp+8] + | mov eax, [esp+4]; shl eax, 1 + | cmp eax, 0xff000000; je >2 // x^+-Inf? + | mov eax, [esp+8]; shl eax, 1; je >4 // +-0^y? + | cmp eax, 0xff000000; je >4 // +-Inf^y? + | fyl2x + | jmp ->vm_exp2raw + | + |9: // Handle x^NaN. + | fld1 + | fucomip st2 + | je >1 // 1^NaN ==> 1 + | fxch // x^NaN ==> NaN + |1: + | fpop + | ret + | + |2: // Handle x^+-Inf. + | fabs + | fld1 + | fucomip st1 + | je >3 // +-1^+-Inf ==> 1 + | fpop; fabs; fldz; mov eax, 0; setc al + | ror eax, 1; xor eax, [esp+4]; jns >3 // |x|<>1, x^+-Inf ==> +Inf/0 + | fxch + |3: + | fpop1; fabs + | ret + | + |4: // Handle +-0^y or +-Inf^y. + | cmp dword [esp+4], 0; jge <3 // y >= 0, x^y ==> |x| + | fpop; fpop + | test eax, eax; jz >5 // y < 0, +-0^y ==> +Inf + | fldz // y < 0, +-Inf^y ==> 0 + | ret + |5: + | mov dword [esp+4], 0x7f800000 // Return +Inf. + | fld dword [esp+4] + | ret + |.endif + | + |// Args in xmm0/xmm1. Ret in xmm0. xmm0-xmm2 and RC (eax) modified. + |// Needs 16 byte scratch area for x86. Also called from JIT code. + |->vm_pow_sse: + | cvtsd2si eax, xmm1 + | cvtsi2sd xmm2, eax + | ucomisd xmm1, xmm2 + | jnz >8 // Branch for FP exponents. + | jp >9 // Branch for NaN exponent. + | // Fallthrough to vm_powi_sse. + | + |// Args in xmm0/eax. Ret in xmm0. xmm0-xmm1 and eax modified. + |->vm_powi_sse: + | cmp eax, 1; jle >6 // i<=1? + | // Now 1 < (unsigned)i <= 0x80000000. + |1: // Handle leading zeros. + | test eax, 1; jnz >2 + | mulsd xmm0, xmm0 + | shr eax, 1 + | jmp <1 + |2: + | shr eax, 1; jz >5 + | movaps xmm1, xmm0 + |3: // Handle trailing bits. + | mulsd xmm0, xmm0 + | shr eax, 1; jz >4 + | jnc <3 + | mulsd xmm1, xmm0 + | jmp <3 + |4: + | mulsd xmm0, xmm1 + |5: + | ret + |6: + | je <5 // x^1 ==> x + | jb >7 // x^0 ==> 1 + | neg eax + | call <1 + | sseconst_1 xmm1, RDa + | divsd xmm1, xmm0 + | movaps xmm0, xmm1 + | ret + |7: + | sseconst_1 xmm0, RDa + | ret + | + |8: // FP/FP power function x^y. + |.if X64 + | movd rax, xmm1; shl rax, 1 + | rol rax, 12; cmp rax, 0xffe; je >2 // x^+-Inf? + | movd rax, xmm0; shl rax, 1; je >4 // +-0^y? + | rol rax, 12; cmp rax, 0xffe; je >5 // +-Inf^y? + | .if X64WIN + | movsd qword [rsp+16], xmm1 // Use scratch area. + | movsd qword [rsp+8], xmm0 + | fld qword [rsp+16] + | fld qword [rsp+8] + | .else + | movsd qword [rsp-16], xmm1 // Use red zone. + | movsd qword [rsp-8], xmm0 + | fld qword [rsp-16] + | fld qword [rsp-8] + | .endif + |.else + | movsd qword [esp+12], xmm1 // Needs 16 byte scratch area. + | movsd qword [esp+4], xmm0 + | cmp dword [esp+12], 0; jne >1 + | mov eax, [esp+16]; shl eax, 1 + | cmp eax, 0xffe00000; je >2 // x^+-Inf? + |1: + | cmp dword [esp+4], 0; jne >1 + | mov eax, [esp+8]; shl eax, 1; je >4 // +-0^y? + | cmp eax, 0xffe00000; je >5 // +-Inf^y? + |1: + | fld qword [esp+12] + | fld qword [esp+4] + |.endif + | fyl2x // y*log2(x) + | fdup; frndint; fsub st1, st0; fxch // Split into frac/int part. + | f2xm1; fld1; faddp st1; fscale; fpop1 // ==> (2^frac-1 +1) << int + |.if X64WIN + | fstp qword [rsp+8] // Use scratch area. + | movsd xmm0, qword [rsp+8] + |.elif X64 + | fstp qword [rsp-8] // Use red zone. + | movsd xmm0, qword [rsp-8] + |.else + | fstp qword [esp+4] // Needs 8 byte scratch area. + | movsd xmm0, qword [esp+4] + |.endif + | ret + | + |9: // Handle x^NaN. + | sseconst_1 xmm2, RDa + | ucomisd xmm0, xmm2; je >1 // 1^NaN ==> 1 + | movaps xmm0, xmm1 // x^NaN ==> NaN + |1: + | ret + | + |2: // Handle x^+-Inf. + | sseconst_abs xmm2, RDa + | andpd xmm0, xmm2 // |x| + | sseconst_1 xmm2, RDa + | ucomisd xmm0, xmm2; je <1 // +-1^+-Inf ==> 1 + | movmskpd eax, xmm1 + | xorps xmm0, xmm0 + | mov ah, al; setc al; xor al, ah; jne <1 // |x|<>1, x^+-Inf ==> +Inf/0 + |3: + | sseconst_hi xmm0, RDa, 7ff00000 // +Inf + | ret + | + |4: // Handle +-0^y. + | movmskpd eax, xmm1; test eax, eax; jnz <3 // y < 0, +-0^y ==> +Inf + | xorps xmm0, xmm0 // y >= 0, +-0^y ==> 0 + | ret + | + |5: // Handle +-Inf^y. + | movmskpd eax, xmm1; test eax, eax; jz <3 // y >= 0, +-Inf^y ==> +Inf + | xorps xmm0, xmm0 // y < 0, +-Inf^y ==> 0 + | ret + | + |// Callable from C: double lj_vm_foldfpm(double x, int fpm) + |// Computes fpm(x) for extended math functions. ORDER FPM. + |->vm_foldfpm: + |.if JIT + |.if X64 + | .if X64WIN + | .define fpmop, CARG2d + | .else + | .define fpmop, CARG1d + | .endif + | cmp fpmop, 1; jb ->vm_floor; je ->vm_ceil + | cmp fpmop, 3; jb ->vm_trunc; ja >2 + | sqrtsd xmm0, xmm0; ret + |2: + | .if X64WIN + | movsd qword [rsp+8], xmm0 // Use scratch area. + | fld qword [rsp+8] + | .else + | movsd qword [rsp-8], xmm0 // Use red zone. + | fld qword [rsp-8] + | .endif + | cmp fpmop, 5; ja >2 + | .if X64WIN; pop rax; .endif + | je >1 + | call ->vm_exp_x87 + | .if X64WIN; push rax; .endif + | jmp >7 + |1: + | call ->vm_exp2_x87 + | .if X64WIN; push rax; .endif + | jmp >7 + |2: ; cmp fpmop, 7; je >1; ja >2 + | fldln2; fxch; fyl2x; jmp >7 + |1: ; fld1; fxch; fyl2x; jmp >7 + |2: ; cmp fpmop, 9; je >1; ja >2 + | fldlg2; fxch; fyl2x; jmp >7 + |1: ; fsin; jmp >7 + |2: ; cmp fpmop, 11; je >1; ja >9 + | fcos; jmp >7 + |1: ; fptan; fpop + |7: + | .if X64WIN + | fstp qword [rsp+8] // Use scratch area. + | movsd xmm0, qword [rsp+8] + | .else + | fstp qword [rsp-8] // Use red zone. + | movsd xmm0, qword [rsp-8] + | .endif + | ret + |.else // x86 calling convention. + | .define fpmop, eax + |.if SSE + | mov fpmop, [esp+12] + | movsd xmm0, qword [esp+4] + | cmp fpmop, 1; je >1; ja >2 + | call ->vm_floor; jmp >7 + |1: ; call ->vm_ceil; jmp >7 + |2: ; cmp fpmop, 3; je >1; ja >2 + | call ->vm_trunc; jmp >7 + |1: + | sqrtsd xmm0, xmm0 + |7: + | movsd qword [esp+4], xmm0 // Overwrite callee-owned args. + | fld qword [esp+4] + | ret + |2: ; fld qword [esp+4] + | cmp fpmop, 5; jb ->vm_exp_x87; je ->vm_exp2_x87 + |2: ; cmp fpmop, 7; je >1; ja >2 + | fldln2; fxch; fyl2x; ret + |1: ; fld1; fxch; fyl2x; ret + |2: ; cmp fpmop, 9; je >1; ja >2 + | fldlg2; fxch; fyl2x; ret + |1: ; fsin; ret + |2: ; cmp fpmop, 11; je >1; ja >9 + | fcos; ret + |1: ; fptan; fpop; ret + |.else + | mov fpmop, [esp+12] + | fld qword [esp+4] + | cmp fpmop, 1; jb ->vm_floor; je ->vm_ceil + | cmp fpmop, 3; jb ->vm_trunc; ja >2 + | fsqrt; ret + |2: ; cmp fpmop, 5; jb ->vm_exp_x87; je ->vm_exp2_x87 + | cmp fpmop, 7; je >1; ja >2 + | fldln2; fxch; fyl2x; ret + |1: ; fld1; fxch; fyl2x; ret + |2: ; cmp fpmop, 9; je >1; ja >2 + | fldlg2; fxch; fyl2x; ret + |1: ; fsin; ret + |2: ; cmp fpmop, 11; je >1; ja >9 + | fcos; ret + |1: ; fptan; fpop; ret + |.endif + |.endif + |9: ; int3 // Bad fpm. + |.endif + | + |// Callable from C: double lj_vm_foldarith(double x, double y, int op) + |// Compute x op y for basic arithmetic operators (+ - * / % ^ and unary -) + |// and basic math functions. ORDER ARITH + |->vm_foldarith: + |.if X64 + | + | .if X64WIN + | .define foldop, CARG3d + | .else + | .define foldop, CARG1d + | .endif + | cmp foldop, 1; je >1; ja >2 + | addsd xmm0, xmm1; ret + |1: ; subsd xmm0, xmm1; ret + |2: ; cmp foldop, 3; je >1; ja >2 + | mulsd xmm0, xmm1; ret + |1: ; divsd xmm0, xmm1; ret + |2: ; cmp foldop, 5; jb ->vm_mod; je ->vm_pow + | cmp foldop, 7; je >1; ja >2 + | sseconst_sign xmm1, RDa; xorps xmm0, xmm1; ret + |1: ; sseconst_abs xmm1, RDa; andps xmm0, xmm1; ret + |2: ; cmp foldop, 9; ja >2 + |.if X64WIN + | movsd qword [rsp+8], xmm0 // Use scratch area. + | movsd qword [rsp+16], xmm1 + | fld qword [rsp+8] + | fld qword [rsp+16] + |.else + | movsd qword [rsp-8], xmm0 // Use red zone. + | movsd qword [rsp-16], xmm1 + | fld qword [rsp-8] + | fld qword [rsp-16] + |.endif + | je >1 + | fpatan + |7: + |.if X64WIN + | fstp qword [rsp+8] // Use scratch area. + | movsd xmm0, qword [rsp+8] + |.else + | fstp qword [rsp-8] // Use red zone. + | movsd xmm0, qword [rsp-8] + |.endif + | ret + |1: ; fxch; fscale; fpop1; jmp <7 + |2: ; cmp foldop, 11; je >1; ja >9 + | minsd xmm0, xmm1; ret + |1: ; maxsd xmm0, xmm1; ret + |9: ; int3 // Bad op. + | + |.elif SSE // x86 calling convention with SSE ops. + | + | .define foldop, eax + | mov foldop, [esp+20] + | movsd xmm0, qword [esp+4] + | movsd xmm1, qword [esp+12] + | cmp foldop, 1; je >1; ja >2 + | addsd xmm0, xmm1 + |7: + | movsd qword [esp+4], xmm0 // Overwrite callee-owned args. + | fld qword [esp+4] + | ret + |1: ; subsd xmm0, xmm1; jmp <7 + |2: ; cmp foldop, 3; je >1; ja >2 + | mulsd xmm0, xmm1; jmp <7 + |1: ; divsd xmm0, xmm1; jmp <7 + |2: ; cmp foldop, 5 + | je >1; ja >2 + | call ->vm_mod; jmp <7 + |1: ; pop edx; call ->vm_pow; push edx; jmp <7 // Writes to scratch area. + |2: ; cmp foldop, 7; je >1; ja >2 + | sseconst_sign xmm1, RDa; xorps xmm0, xmm1; jmp <7 + |1: ; sseconst_abs xmm1, RDa; andps xmm0, xmm1; jmp <7 + |2: ; cmp foldop, 9; ja >2 + | fld qword [esp+4] // Reload from stack + | fld qword [esp+12] + | je >1 + | fpatan; ret + |1: ; fxch; fscale; fpop1; ret + |2: ; cmp foldop, 11; je >1; ja >9 + | minsd xmm0, xmm1; jmp <7 + |1: ; maxsd xmm0, xmm1; jmp <7 + |9: ; int3 // Bad op. + | + |.else // x86 calling convention with x87 ops. + | + | mov eax, [esp+20] + | fld qword [esp+4] + | fld qword [esp+12] + | cmp eax, 1; je >1; ja >2 + | faddp st1; ret + |1: ; fsubp st1; ret + |2: ; cmp eax, 3; je >1; ja >2 + | fmulp st1; ret + |1: ; fdivp st1; ret + |2: ; cmp eax, 5; jb ->vm_mod; je ->vm_pow + | cmp eax, 7; je >1; ja >2 + | fpop; fchs; ret + |1: ; fpop; fabs; ret + |2: ; cmp eax, 9; je >1; ja >2 + | fpatan; ret + |1: ; fxch; fscale; fpop1; ret + |2: ; cmp eax, 11; je >1; ja >9 + | fucomi st1; fcmovnbe st1; fpop1; ret + |1: ; fucomi st1; fcmovbe st1; fpop1; ret + |9: ; int3 // Bad op. + | + |.endif + | + |//----------------------------------------------------------------------- + |//-- Miscellaneous functions -------------------------------------------- + |//----------------------------------------------------------------------- + | + |// int lj_vm_cpuid(uint32_t f, uint32_t res[4]) + |->vm_cpuid: + |.if X64 + | mov eax, CARG1d + | .if X64WIN; push rsi; mov rsi, CARG2; .endif + | push rbx + | cpuid + | mov [rsi], eax + | mov [rsi+4], ebx + | mov [rsi+8], ecx + | mov [rsi+12], edx + | pop rbx + | .if X64WIN; pop rsi; .endif + | ret + |.else + | pushfd + | pop edx + | mov ecx, edx + | xor edx, 0x00200000 // Toggle ID bit in flags. + | push edx + | popfd + | pushfd + | pop edx + | xor eax, eax // Zero means no features supported. + | cmp ecx, edx + | jz >1 // No ID toggle means no CPUID support. + | mov eax, [esp+4] // Argument 1 is function number. + | push edi + | push ebx + | cpuid + | mov edi, [esp+16] // Argument 2 is result area. + | mov [edi], eax + | mov [edi+4], ebx + | mov [edi+8], ecx + | mov [edi+12], edx + | pop ebx + | pop edi + |1: + | ret + |.endif + | + |//----------------------------------------------------------------------- + |//-- Assertions --------------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->assert_bad_for_arg_type: +#ifdef LUA_USE_ASSERT + | int3 +#endif + | int3 + | + |//----------------------------------------------------------------------- + |//-- FFI helper functions ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |// Handler for callback functions. Callback slot number in ah/al. + |->vm_ffi_callback: + |.if FFI + |.type CTSTATE, CTState, PC + |.if not X64 + | sub esp, 16 // Leave room for SAVE_ERRF etc. + |.endif + | saveregs_ // ebp/rbp already saved. ebp now holds global_State *. + | lea DISPATCH, [ebp+GG_G2DISP] + | mov CTSTATE, GL:ebp->ctype_state + | movzx eax, ax + | mov CTSTATE->cb.slot, eax + |.if X64 + | mov CTSTATE->cb.gpr[0], CARG1 + | mov CTSTATE->cb.gpr[1], CARG2 + | mov CTSTATE->cb.gpr[2], CARG3 + | mov CTSTATE->cb.gpr[3], CARG4 + | movsd qword CTSTATE->cb.fpr[0], xmm0 + | movsd qword CTSTATE->cb.fpr[1], xmm1 + | movsd qword CTSTATE->cb.fpr[2], xmm2 + | movsd qword CTSTATE->cb.fpr[3], xmm3 + |.if X64WIN + | lea rax, [rsp+CFRAME_SIZE+4*8] + |.else + | lea rax, [rsp+CFRAME_SIZE] + | mov CTSTATE->cb.gpr[4], CARG5 + | mov CTSTATE->cb.gpr[5], CARG6 + | movsd qword CTSTATE->cb.fpr[4], xmm4 + | movsd qword CTSTATE->cb.fpr[5], xmm5 + | movsd qword CTSTATE->cb.fpr[6], xmm6 + | movsd qword CTSTATE->cb.fpr[7], xmm7 + |.endif + | mov CTSTATE->cb.stack, rax + | mov CARG2, rsp + |.else + | lea eax, [esp+CFRAME_SIZE+16] + | mov CTSTATE->cb.gpr[0], FCARG1 + | mov CTSTATE->cb.gpr[1], FCARG2 + | mov CTSTATE->cb.stack, eax + | mov FCARG1, [esp+CFRAME_SIZE+12] // Move around misplaced retaddr/ebp. + | mov FCARG2, [esp+CFRAME_SIZE+8] + | mov SAVE_RET, FCARG1 + | mov SAVE_R4, FCARG2 + | mov FCARG2, esp + |.endif + | mov SAVE_PC, CTSTATE // Any value outside of bytecode is ok. + | mov FCARG1, CTSTATE + | call extern lj_ccallback_enter@8 // (CTState *cts, void *cf) + | // lua_State * returned in eax (RD). + | set_vmstate INTERP + | mov BASE, L:RD->base + | mov RD, L:RD->top + | sub RD, BASE + | mov LFUNC:RB, [BASE-8] + | shr RD, 3 + | add RD, 1 + | ins_callt + |.endif + | + |->cont_ffi_callback: // Return from FFI callback. + |.if FFI + | mov L:RA, SAVE_L + | mov CTSTATE, [DISPATCH+DISPATCH_GL(ctype_state)] + | mov aword CTSTATE->L, L:RAa + | mov L:RA->base, BASE + | mov L:RA->top, RB + | mov FCARG1, CTSTATE + | mov FCARG2, RC + | call extern lj_ccallback_leave@8 // (CTState *cts, TValue *o) + |.if X64 + | mov rax, CTSTATE->cb.gpr[0] + | movsd xmm0, qword CTSTATE->cb.fpr[0] + | jmp ->vm_leave_unw + |.else + | mov L:RB, SAVE_L + | mov eax, CTSTATE->cb.gpr[0] + | mov edx, CTSTATE->cb.gpr[1] + | cmp dword CTSTATE->cb.gpr[2], 1 + | jb >7 + | je >6 + | fld qword CTSTATE->cb.fpr[0].d + | jmp >7 + |6: + | fld dword CTSTATE->cb.fpr[0].f + |7: + | mov ecx, L:RB->top + | movzx ecx, word [ecx+6] // Get stack adjustment and copy up. + | mov SAVE_L, ecx // Must be one slot above SAVE_RET + | restoreregs + | pop ecx // Move return addr from SAVE_RET. + | add esp, [esp] // Adjust stack. + | add esp, 16 + | push ecx + | ret + |.endif + |.endif + | + |->vm_ffi_call@4: // Call C function via FFI. + | // Caveat: needs special frame unwinding, see below. + |.if FFI + |.if X64 + | .type CCSTATE, CCallState, rbx + | push rbp; mov rbp, rsp; push rbx; mov CCSTATE, CARG1 + |.else + | .type CCSTATE, CCallState, ebx + | push ebp; mov ebp, esp; push ebx; mov CCSTATE, FCARG1 + |.endif + | + | // Readjust stack. + |.if X64 + | mov eax, CCSTATE->spadj + | sub rsp, rax + |.else + | sub esp, CCSTATE->spadj + |.if WIN + | mov CCSTATE->spadj, esp + |.endif + |.endif + | + | // Copy stack slots. + | movzx ecx, byte CCSTATE->nsp + | sub ecx, 1 + | js >2 + |1: + |.if X64 + | mov rax, [CCSTATE+rcx*8+offsetof(CCallState, stack)] + | mov [rsp+rcx*8+CCALL_SPS_EXTRA*8], rax + |.else + | mov eax, [CCSTATE+ecx*4+offsetof(CCallState, stack)] + | mov [esp+ecx*4], eax + |.endif + | sub ecx, 1 + | jns <1 + |2: + | + |.if X64 + | movzx eax, byte CCSTATE->nfpr + | mov CARG1, CCSTATE->gpr[0] + | mov CARG2, CCSTATE->gpr[1] + | mov CARG3, CCSTATE->gpr[2] + | mov CARG4, CCSTATE->gpr[3] + |.if not X64WIN + | mov CARG5, CCSTATE->gpr[4] + | mov CARG6, CCSTATE->gpr[5] + |.endif + | test eax, eax; jz >5 + | movaps xmm0, CCSTATE->fpr[0] + | movaps xmm1, CCSTATE->fpr[1] + | movaps xmm2, CCSTATE->fpr[2] + | movaps xmm3, CCSTATE->fpr[3] + |.if not X64WIN + | cmp eax, 4; jbe >5 + | movaps xmm4, CCSTATE->fpr[4] + | movaps xmm5, CCSTATE->fpr[5] + | movaps xmm6, CCSTATE->fpr[6] + | movaps xmm7, CCSTATE->fpr[7] + |.endif + |5: + |.else + | mov FCARG1, CCSTATE->gpr[0] + | mov FCARG2, CCSTATE->gpr[1] + |.endif + | + | call aword CCSTATE->func + | + |.if X64 + | mov CCSTATE->gpr[0], rax + | movaps CCSTATE->fpr[0], xmm0 + |.if not X64WIN + | mov CCSTATE->gpr[1], rdx + | movaps CCSTATE->fpr[1], xmm1 + |.endif + |.else + | mov CCSTATE->gpr[0], eax + | mov CCSTATE->gpr[1], edx + | cmp byte CCSTATE->resx87, 1 + | jb >7 + | je >6 + | fstp qword CCSTATE->fpr[0].d[0] + | jmp >7 + |6: + | fstp dword CCSTATE->fpr[0].f[0] + |7: + |.if WIN + | sub CCSTATE->spadj, esp + |.endif + |.endif + | + |.if X64 + | mov rbx, [rbp-8]; leave; ret + |.else + | mov ebx, [ebp-4]; leave; ret + |.endif + |.endif + |// Note: vm_ffi_call must be the last function in this object file! + | + |//----------------------------------------------------------------------- +} + +/* Generate the code for a single instruction. */ +static void build_ins(BuildCtx *ctx, BCOp op, int defop) +{ + int vk = 0; + |// Note: aligning all instructions does not pay off. + |=>defop: + + switch (op) { + + /* -- Comparison ops ---------------------------------------------------- */ + + /* Remember: all ops branch for a true comparison, fall through otherwise. */ + + |.macro jmp_comp, lt, ge, le, gt, target + ||switch (op) { + ||case BC_ISLT: + | lt target + ||break; + ||case BC_ISGE: + | ge target + ||break; + ||case BC_ISLE: + | le target + ||break; + ||case BC_ISGT: + | gt target + ||break; + ||default: break; /* Shut up GCC. */ + ||} + |.endmacro + + case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: + | // RA = src1, RD = src2, JMP with RD = target + | ins_AD + |.if DUALNUM + | checkint RA, >7 + | checkint RD, >8 + | mov RB, dword [BASE+RA*8] + | add PC, 4 + | cmp RB, dword [BASE+RD*8] + | jmp_comp jge, jl, jg, jle, >9 + |6: + | movzx RD, PC_RD + | branchPC RD + |9: + | ins_next + | + |7: // RA is not an integer. + | ja ->vmeta_comp + | // RA is a number. + | cmp dword [BASE+RD*8+4], LJ_TISNUM; jb >1; jne ->vmeta_comp + | // RA is a number, RD is an integer. + |.if SSE + | cvtsi2sd xmm0, dword [BASE+RD*8] + | jmp >2 + |.else + | fld qword [BASE+RA*8] + | fild dword [BASE+RD*8] + | jmp >3 + |.endif + | + |8: // RA is an integer, RD is not an integer. + | ja ->vmeta_comp + | // RA is an integer, RD is a number. + |.if SSE + | cvtsi2sd xmm1, dword [BASE+RA*8] + | movsd xmm0, qword [BASE+RD*8] + | add PC, 4 + | ucomisd xmm0, xmm1 + | jmp_comp jbe, ja, jb, jae, <9 + | jmp <6 + |.else + | fild dword [BASE+RA*8] + | jmp >2 + |.endif + |.else + | checknum RA, ->vmeta_comp + | checknum RD, ->vmeta_comp + |.endif + |.if SSE + |1: + | movsd xmm0, qword [BASE+RD*8] + |2: + | add PC, 4 + | ucomisd xmm0, qword [BASE+RA*8] + |3: + |.else + |1: + | fld qword [BASE+RA*8] // Reverse order, i.e like cmp D, A. + |2: + | fld qword [BASE+RD*8] + |3: + | add PC, 4 + | fcomparepp + |.endif + | // Unordered: all of ZF CF PF set, ordered: PF clear. + | // To preserve NaN semantics GE/GT branch on unordered, but LT/LE don't. + |.if DUALNUM + | jmp_comp jbe, ja, jb, jae, <9 + | jmp <6 + |.else + | jmp_comp jbe, ja, jb, jae, >1 + | movzx RD, PC_RD + | branchPC RD + |1: + | ins_next + |.endif + break; + + case BC_ISEQV: case BC_ISNEV: + vk = op == BC_ISEQV; + | ins_AD // RA = src1, RD = src2, JMP with RD = target + | mov RB, [BASE+RD*8+4] + | add PC, 4 + |.if DUALNUM + | cmp RB, LJ_TISNUM; jne >7 + | checkint RA, >8 + | mov RB, dword [BASE+RD*8] + | cmp RB, dword [BASE+RA*8] + if (vk) { + | jne >9 + } else { + | je >9 + } + | movzx RD, PC_RD + | branchPC RD + |9: + | ins_next + | + |7: // RD is not an integer. + | ja >5 + | // RD is a number. + | cmp dword [BASE+RA*8+4], LJ_TISNUM; jb >1; jne >5 + | // RD is a number, RA is an integer. + |.if SSE + | cvtsi2sd xmm0, dword [BASE+RA*8] + |.else + | fild dword [BASE+RA*8] + |.endif + | jmp >2 + | + |8: // RD is an integer, RA is not an integer. + | ja >5 + | // RD is an integer, RA is a number. + |.if SSE + | cvtsi2sd xmm0, dword [BASE+RD*8] + | ucomisd xmm0, qword [BASE+RA*8] + |.else + | fild dword [BASE+RD*8] + | fld qword [BASE+RA*8] + |.endif + | jmp >4 + | + |.else + | cmp RB, LJ_TISNUM; jae >5 + | checknum RA, >5 + |.endif + |.if SSE + |1: + | movsd xmm0, qword [BASE+RA*8] + |2: + | ucomisd xmm0, qword [BASE+RD*8] + |4: + |.else + |1: + | fld qword [BASE+RA*8] + |2: + | fld qword [BASE+RD*8] + |4: + | fcomparepp + |.endif + iseqne_fp: + if (vk) { + | jp >2 // Unordered means not equal. + | jne >2 + } else { + | jp >2 // Unordered means not equal. + | je >1 + } + iseqne_end: + if (vk) { + |1: // EQ: Branch to the target. + | movzx RD, PC_RD + | branchPC RD + |2: // NE: Fallthrough to next instruction. + |.if not FFI + |3: + |.endif + } else { + |.if not FFI + |3: + |.endif + |2: // NE: Branch to the target. + | movzx RD, PC_RD + | branchPC RD + |1: // EQ: Fallthrough to next instruction. + } + if (LJ_DUALNUM && (op == BC_ISEQV || op == BC_ISNEV || + op == BC_ISEQN || op == BC_ISNEN)) { + | jmp <9 + } else { + | ins_next + } + | + if (op == BC_ISEQV || op == BC_ISNEV) { + |5: // Either or both types are not numbers. + |.if FFI + | cmp RB, LJ_TCDATA; je ->vmeta_equal_cd + | checktp RA, LJ_TCDATA; je ->vmeta_equal_cd + |.endif + | checktp RA, RB // Compare types. + | jne <2 // Not the same type? + | cmp RB, LJ_TISPRI + | jae <1 // Same type and primitive type? + | + | // Same types and not a primitive type. Compare GCobj or pvalue. + | mov RA, [BASE+RA*8] + | mov RD, [BASE+RD*8] + | cmp RA, RD + | je <1 // Same GCobjs or pvalues? + | cmp RB, LJ_TISTABUD + | ja <2 // Different objects and not table/ud? + |.if X64 + | cmp RB, LJ_TUDATA // And not 64 bit lightuserdata. + | jb <2 + |.endif + | + | // Different tables or userdatas. Need to check __eq metamethod. + | // Field metatable must be at same offset for GCtab and GCudata! + | mov TAB:RB, TAB:RA->metatable + | test TAB:RB, TAB:RB + | jz <2 // No metatable? + | test byte TAB:RB->nomm, 1<vmeta_equal // Handle __eq metamethod. + } else { + |.if FFI + |3: + | cmp RB, LJ_TCDATA + if (LJ_DUALNUM && vk) { + | jne <9 + } else { + | jne <2 + } + | jmp ->vmeta_equal_cd + |.endif + } + break; + case BC_ISEQS: case BC_ISNES: + vk = op == BC_ISEQS; + | ins_AND // RA = src, RD = str const, JMP with RD = target + | mov RB, [BASE+RA*8+4] + | add PC, 4 + | cmp RB, LJ_TSTR; jne >3 + | mov RA, [BASE+RA*8] + | cmp RA, [KBASE+RD*4] + iseqne_test: + if (vk) { + | jne >2 + } else { + | je >1 + } + goto iseqne_end; + case BC_ISEQN: case BC_ISNEN: + vk = op == BC_ISEQN; + | ins_AD // RA = src, RD = num const, JMP with RD = target + | mov RB, [BASE+RA*8+4] + | add PC, 4 + |.if DUALNUM + | cmp RB, LJ_TISNUM; jne >7 + | cmp dword [KBASE+RD*8+4], LJ_TISNUM; jne >8 + | mov RB, dword [KBASE+RD*8] + | cmp RB, dword [BASE+RA*8] + if (vk) { + | jne >9 + } else { + | je >9 + } + | movzx RD, PC_RD + | branchPC RD + |9: + | ins_next + | + |7: // RA is not an integer. + | ja >3 + | // RA is a number. + | cmp dword [KBASE+RD*8+4], LJ_TISNUM; jb >1 + | // RA is a number, RD is an integer. + |.if SSE + | cvtsi2sd xmm0, dword [KBASE+RD*8] + |.else + | fild dword [KBASE+RD*8] + |.endif + | jmp >2 + | + |8: // RA is an integer, RD is a number. + |.if SSE + | cvtsi2sd xmm0, dword [BASE+RA*8] + | ucomisd xmm0, qword [KBASE+RD*8] + |.else + | fild dword [BASE+RA*8] + | fld qword [KBASE+RD*8] + |.endif + | jmp >4 + |.else + | cmp RB, LJ_TISNUM; jae >3 + |.endif + |.if SSE + |1: + | movsd xmm0, qword [KBASE+RD*8] + |2: + | ucomisd xmm0, qword [BASE+RA*8] + |4: + |.else + |1: + | fld qword [KBASE+RD*8] + |2: + | fld qword [BASE+RA*8] + |4: + | fcomparepp + |.endif + goto iseqne_fp; + case BC_ISEQP: case BC_ISNEP: + vk = op == BC_ISEQP; + | ins_AND // RA = src, RD = primitive type (~), JMP with RD = target + | mov RB, [BASE+RA*8+4] + | add PC, 4 + | cmp RB, RD + if (!LJ_HASFFI) goto iseqne_test; + if (vk) { + | jne >3 + | movzx RD, PC_RD + | branchPC RD + |2: + | ins_next + |3: + | cmp RB, LJ_TCDATA; jne <2 + | jmp ->vmeta_equal_cd + } else { + | je >2 + | cmp RB, LJ_TCDATA; je ->vmeta_equal_cd + | movzx RD, PC_RD + | branchPC RD + |2: + | ins_next + } + break; + + /* -- Unary test and copy ops ------------------------------------------- */ + + case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: + | ins_AD // RA = dst or unused, RD = src, JMP with RD = target + | mov RB, [BASE+RD*8+4] + | add PC, 4 + | cmp RB, LJ_TISTRUECOND + if (op == BC_IST || op == BC_ISTC) { + | jae >1 + } else { + | jb >1 + } + if (op == BC_ISTC || op == BC_ISFC) { + | mov [BASE+RA*8+4], RB + | mov RB, [BASE+RD*8] + | mov [BASE+RA*8], RB + } + | movzx RD, PC_RD + | branchPC RD + |1: // Fallthrough to the next instruction. + | ins_next + break; + + /* -- Unary ops --------------------------------------------------------- */ + + case BC_MOV: + | ins_AD // RA = dst, RD = src + |.if X64 + | mov RBa, [BASE+RD*8] + | mov [BASE+RA*8], RBa + |.else + | mov RB, [BASE+RD*8+4] + | mov RD, [BASE+RD*8] + | mov [BASE+RA*8+4], RB + | mov [BASE+RA*8], RD + |.endif + | ins_next_ + break; + case BC_NOT: + | ins_AD // RA = dst, RD = src + | xor RB, RB + | checktp RD, LJ_TISTRUECOND + | adc RB, LJ_TTRUE + | mov [BASE+RA*8+4], RB + | ins_next + break; + case BC_UNM: + | ins_AD // RA = dst, RD = src + |.if DUALNUM + | checkint RD, >5 + | mov RB, [BASE+RD*8] + | neg RB + | jo >4 + | mov dword [BASE+RA*8+4], LJ_TISNUM + | mov dword [BASE+RA*8], RB + |9: + | ins_next + |4: + | mov dword [BASE+RA*8+4], 0x41e00000 // 2^31. + | mov dword [BASE+RA*8], 0 + | jmp <9 + |5: + | ja ->vmeta_unm + |.else + | checknum RD, ->vmeta_unm + |.endif + |.if SSE + | movsd xmm0, qword [BASE+RD*8] + | sseconst_sign xmm1, RDa + | xorps xmm0, xmm1 + | movsd qword [BASE+RA*8], xmm0 + |.else + | fld qword [BASE+RD*8] + | fchs + | fstp qword [BASE+RA*8] + |.endif + |.if DUALNUM + | jmp <9 + |.else + | ins_next + |.endif + break; + case BC_LEN: + | ins_AD // RA = dst, RD = src + | checkstr RD, >2 + | mov STR:RD, [BASE+RD*8] + |.if DUALNUM + | mov RD, dword STR:RD->len + |1: + | mov dword [BASE+RA*8+4], LJ_TISNUM + | mov dword [BASE+RA*8], RD + |.elif SSE + | xorps xmm0, xmm0 + | cvtsi2sd xmm0, dword STR:RD->len + |1: + | movsd qword [BASE+RA*8], xmm0 + |.else + | fild dword STR:RD->len + |1: + | fstp qword [BASE+RA*8] + |.endif + | ins_next + |2: + | checktab RD, ->vmeta_len + | mov TAB:FCARG1, [BASE+RD*8] +#if LJ_52 + | mov TAB:RB, TAB:FCARG1->metatable + | cmp TAB:RB, 0 + | jnz >9 + |3: +#endif + |->BC_LEN_Z: + | mov RB, BASE // Save BASE. + | call extern lj_tab_len@4 // (GCtab *t) + | // Length of table returned in eax (RD). + |.if DUALNUM + | // Nothing to do. + |.elif SSE + | cvtsi2sd xmm0, RD + |.else + | mov ARG1, RD + | fild ARG1 + |.endif + | mov BASE, RB // Restore BASE. + | movzx RA, PC_RA + | jmp <1 +#if LJ_52 + |9: // Check for __len. + | test byte TAB:RB->nomm, 1<vmeta_len // 'no __len' flag NOT set: check. +#endif + break; + + /* -- Binary ops -------------------------------------------------------- */ + + |.macro ins_arithpre, x87ins, sseins, ssereg + | ins_ABC + ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); + ||switch (vk) { + ||case 0: + | checknum RB, ->vmeta_arith_vn + | .if DUALNUM + | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jae ->vmeta_arith_vn + | .endif + | .if SSE + | movsd xmm0, qword [BASE+RB*8] + | sseins ssereg, qword [KBASE+RC*8] + | .else + | fld qword [BASE+RB*8] + | x87ins qword [KBASE+RC*8] + | .endif + || break; + ||case 1: + | checknum RB, ->vmeta_arith_nv + | .if DUALNUM + | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jae ->vmeta_arith_nv + | .endif + | .if SSE + | movsd xmm0, qword [KBASE+RC*8] + | sseins ssereg, qword [BASE+RB*8] + | .else + | fld qword [KBASE+RC*8] + | x87ins qword [BASE+RB*8] + | .endif + || break; + ||default: + | checknum RB, ->vmeta_arith_vv + | checknum RC, ->vmeta_arith_vv + | .if SSE + | movsd xmm0, qword [BASE+RB*8] + | sseins ssereg, qword [BASE+RC*8] + | .else + | fld qword [BASE+RB*8] + | x87ins qword [BASE+RC*8] + | .endif + || break; + ||} + |.endmacro + | + |.macro ins_arithdn, intins + | ins_ABC + ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); + ||switch (vk) { + ||case 0: + | checkint RB, ->vmeta_arith_vn + | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jne ->vmeta_arith_vn + | mov RB, [BASE+RB*8] + | intins RB, [KBASE+RC*8]; jo ->vmeta_arith_vno + || break; + ||case 1: + | checkint RB, ->vmeta_arith_nv + | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jne ->vmeta_arith_nv + | mov RC, [KBASE+RC*8] + | intins RC, [BASE+RB*8]; jo ->vmeta_arith_nvo + || break; + ||default: + | checkint RB, ->vmeta_arith_vv + | checkint RC, ->vmeta_arith_vv + | mov RB, [BASE+RB*8] + | intins RB, [BASE+RC*8]; jo ->vmeta_arith_vvo + || break; + ||} + | mov dword [BASE+RA*8+4], LJ_TISNUM + ||if (vk == 1) { + | mov dword [BASE+RA*8], RC + ||} else { + | mov dword [BASE+RA*8], RB + ||} + | ins_next + |.endmacro + | + |.macro ins_arithpost + |.if SSE + | movsd qword [BASE+RA*8], xmm0 + |.else + | fstp qword [BASE+RA*8] + |.endif + |.endmacro + | + |.macro ins_arith, x87ins, sseins + | ins_arithpre x87ins, sseins, xmm0 + | ins_arithpost + | ins_next + |.endmacro + | + |.macro ins_arith, intins, x87ins, sseins + |.if DUALNUM + | ins_arithdn intins + |.else + | ins_arith, x87ins, sseins + |.endif + |.endmacro + + | // RA = dst, RB = src1 or num const, RC = src2 or num const + case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: + | ins_arith add, fadd, addsd + break; + case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: + | ins_arith sub, fsub, subsd + break; + case BC_MULVN: case BC_MULNV: case BC_MULVV: + | ins_arith imul, fmul, mulsd + break; + case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: + | ins_arith fdiv, divsd + break; + case BC_MODVN: + | ins_arithpre fld, movsd, xmm1 + |->BC_MODVN_Z: + | call ->vm_mod + | ins_arithpost + | ins_next + break; + case BC_MODNV: case BC_MODVV: + | ins_arithpre fld, movsd, xmm1 + | jmp ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. + break; + case BC_POW: + | ins_arithpre fld, movsd, xmm1 + | call ->vm_pow + | ins_arithpost + | ins_next + break; + + case BC_CAT: + | ins_ABC // RA = dst, RB = src_start, RC = src_end + |.if X64 + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE + | lea CARG2d, [BASE+RC*8] + | mov CARG3d, RC + | sub CARG3d, RB + |->BC_CAT_Z: + | mov L:RB, L:CARG1d + |.else + | lea RA, [BASE+RC*8] + | sub RC, RB + | mov ARG2, RA + | mov ARG3, RC + |->BC_CAT_Z: + | mov L:RB, SAVE_L + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | call extern lj_meta_cat // (lua_State *L, TValue *top, int left) + | // NULL (finished) or TValue * (metamethod) returned in eax (RC). + | mov BASE, L:RB->base + | test RC, RC + | jnz ->vmeta_binop + | movzx RB, PC_RB // Copy result to Stk[RA] from Stk[RB]. + | movzx RA, PC_RA + |.if X64 + | mov RCa, [BASE+RB*8] + | mov [BASE+RA*8], RCa + |.else + | mov RC, [BASE+RB*8+4] + | mov RB, [BASE+RB*8] + | mov [BASE+RA*8+4], RC + | mov [BASE+RA*8], RB + |.endif + | ins_next + break; + + /* -- Constant ops ------------------------------------------------------ */ + + case BC_KSTR: + | ins_AND // RA = dst, RD = str const (~) + | mov RD, [KBASE+RD*4] + | mov dword [BASE+RA*8+4], LJ_TSTR + | mov [BASE+RA*8], RD + | ins_next + break; + case BC_KCDATA: + |.if FFI + | ins_AND // RA = dst, RD = cdata const (~) + | mov RD, [KBASE+RD*4] + | mov dword [BASE+RA*8+4], LJ_TCDATA + | mov [BASE+RA*8], RD + | ins_next + |.endif + break; + case BC_KSHORT: + | ins_AD // RA = dst, RD = signed int16 literal + |.if DUALNUM + | movsx RD, RDW + | mov dword [BASE+RA*8+4], LJ_TISNUM + | mov dword [BASE+RA*8], RD + |.elif SSE + | movsx RD, RDW // Sign-extend literal. + | cvtsi2sd xmm0, RD + | movsd qword [BASE+RA*8], xmm0 + |.else + | fild PC_RD // Refetch signed RD from instruction. + | fstp qword [BASE+RA*8] + |.endif + | ins_next + break; + case BC_KNUM: + | ins_AD // RA = dst, RD = num const + |.if SSE + | movsd xmm0, qword [KBASE+RD*8] + | movsd qword [BASE+RA*8], xmm0 + |.else + | fld qword [KBASE+RD*8] + | fstp qword [BASE+RA*8] + |.endif + | ins_next + break; + case BC_KPRI: + | ins_AND // RA = dst, RD = primitive type (~) + | mov [BASE+RA*8+4], RD + | ins_next + break; + case BC_KNIL: + | ins_AD // RA = dst_start, RD = dst_end + | lea RA, [BASE+RA*8+12] + | lea RD, [BASE+RD*8+4] + | mov RB, LJ_TNIL + | mov [RA-8], RB // Sets minimum 2 slots. + |1: + | mov [RA], RB + | add RA, 8 + | cmp RA, RD + | jbe <1 + | ins_next + break; + + /* -- Upvalue and function ops ------------------------------------------ */ + + case BC_UGET: + | ins_AD // RA = dst, RD = upvalue # + | mov LFUNC:RB, [BASE-8] + | mov UPVAL:RB, [LFUNC:RB+RD*4+offsetof(GCfuncL, uvptr)] + | mov RB, UPVAL:RB->v + |.if X64 + | mov RDa, [RB] + | mov [BASE+RA*8], RDa + |.else + | mov RD, [RB+4] + | mov RB, [RB] + | mov [BASE+RA*8+4], RD + | mov [BASE+RA*8], RB + |.endif + | ins_next + break; + case BC_USETV: +#define TV2MARKOFS \ + ((int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)) + | ins_AD // RA = upvalue #, RD = src + | mov LFUNC:RB, [BASE-8] + | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] + | cmp byte UPVAL:RB->closed, 0 + | mov RB, UPVAL:RB->v + | mov RA, [BASE+RD*8] + | mov RD, [BASE+RD*8+4] + | mov [RB], RA + | mov [RB+4], RD + | jz >1 + | // Check barrier for closed upvalue. + | test byte [RB+TV2MARKOFS], LJ_GC_BLACK // isblack(uv) + | jnz >2 + |1: + | ins_next + | + |2: // Upvalue is black. Check if new value is collectable and white. + | sub RD, LJ_TISGCV + | cmp RD, LJ_TNUMX - LJ_TISGCV // tvisgcv(v) + | jbe <1 + | test byte GCOBJ:RA->gch.marked, LJ_GC_WHITES // iswhite(v) + | jz <1 + | // Crossed a write barrier. Move the barrier forward. + |.if X64 and not X64WIN + | mov FCARG2, RB + | mov RB, BASE // Save BASE. + |.else + | xchg FCARG2, RB // Save BASE (FCARG2 == BASE). + |.endif + | lea GL:FCARG1, [DISPATCH+GG_DISP2G] + | call extern lj_gc_barrieruv@8 // (global_State *g, TValue *tv) + | mov BASE, RB // Restore BASE. + | jmp <1 + break; +#undef TV2MARKOFS + case BC_USETS: + | ins_AND // RA = upvalue #, RD = str const (~) + | mov LFUNC:RB, [BASE-8] + | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] + | mov GCOBJ:RA, [KBASE+RD*4] + | mov RD, UPVAL:RB->v + | mov [RD], GCOBJ:RA + | mov dword [RD+4], LJ_TSTR + | test byte UPVAL:RB->marked, LJ_GC_BLACK // isblack(uv) + | jnz >2 + |1: + | ins_next + | + |2: // Check if string is white and ensure upvalue is closed. + | test byte GCOBJ:RA->gch.marked, LJ_GC_WHITES // iswhite(str) + | jz <1 + | cmp byte UPVAL:RB->closed, 0 + | jz <1 + | // Crossed a write barrier. Move the barrier forward. + | mov RB, BASE // Save BASE (FCARG2 == BASE). + | mov FCARG2, RD + | lea GL:FCARG1, [DISPATCH+GG_DISP2G] + | call extern lj_gc_barrieruv@8 // (global_State *g, TValue *tv) + | mov BASE, RB // Restore BASE. + | jmp <1 + break; + case BC_USETN: + | ins_AD // RA = upvalue #, RD = num const + | mov LFUNC:RB, [BASE-8] + |.if SSE + | movsd xmm0, qword [KBASE+RD*8] + |.else + | fld qword [KBASE+RD*8] + |.endif + | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] + | mov RA, UPVAL:RB->v + |.if SSE + | movsd qword [RA], xmm0 + |.else + | fstp qword [RA] + |.endif + | ins_next + break; + case BC_USETP: + | ins_AND // RA = upvalue #, RD = primitive type (~) + | mov LFUNC:RB, [BASE-8] + | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] + | mov RA, UPVAL:RB->v + | mov [RA+4], RD + | ins_next + break; + case BC_UCLO: + | ins_AD // RA = level, RD = target + | branchPC RD // Do this first to free RD. + | mov L:RB, SAVE_L + | cmp dword L:RB->openupval, 0 + | je >1 + | mov L:RB->base, BASE + | lea FCARG2, [BASE+RA*8] // Caveat: FCARG2 == BASE + | mov L:FCARG1, L:RB // Caveat: FCARG1 == RA + | call extern lj_func_closeuv@8 // (lua_State *L, TValue *level) + | mov BASE, L:RB->base + |1: + | ins_next + break; + + case BC_FNEW: + | ins_AND // RA = dst, RD = proto const (~) (holding function prototype) + |.if X64 + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Caveat: CARG2d/CARG3d may be BASE. + | mov CARG3d, [BASE-8] + | mov CARG2d, [KBASE+RD*4] // Fetch GCproto *. + | mov CARG1d, L:RB + |.else + | mov LFUNC:RA, [BASE-8] + | mov PROTO:RD, [KBASE+RD*4] // Fetch GCproto *. + | mov L:RB, SAVE_L + | mov ARG3, LFUNC:RA + | mov ARG2, PROTO:RD + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | // (lua_State *L, GCproto *pt, GCfuncL *parent) + | call extern lj_func_newL_gc + | // GCfuncL * returned in eax (RC). + | mov BASE, L:RB->base + | movzx RA, PC_RA + | mov [BASE+RA*8], LFUNC:RC + | mov dword [BASE+RA*8+4], LJ_TFUNC + | ins_next + break; + + /* -- Table ops --------------------------------------------------------- */ + + case BC_TNEW: + | ins_AD // RA = dst, RD = hbits|asize + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | mov RA, [DISPATCH+DISPATCH_GL(gc.total)] + | cmp RA, [DISPATCH+DISPATCH_GL(gc.threshold)] + | mov SAVE_PC, PC + | jae >5 + |1: + |.if X64 + | mov CARG3d, RD + | and RD, 0x7ff + | shr CARG3d, 11 + |.else + | mov RA, RD + | and RD, 0x7ff + | shr RA, 11 + | mov ARG3, RA + |.endif + | cmp RD, 0x7ff + | je >3 + |2: + |.if X64 + | mov L:CARG1d, L:RB + | mov CARG2d, RD + |.else + | mov ARG1, L:RB + | mov ARG2, RD + |.endif + | call extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) + | // Table * returned in eax (RC). + | mov BASE, L:RB->base + | movzx RA, PC_RA + | mov [BASE+RA*8], TAB:RC + | mov dword [BASE+RA*8+4], LJ_TTAB + | ins_next + |3: // Turn 0x7ff into 0x801. + | mov RD, 0x801 + | jmp <2 + |5: + | mov L:FCARG1, L:RB + | call extern lj_gc_step_fixtop@4 // (lua_State *L) + | movzx RD, PC_RD + | jmp <1 + break; + case BC_TDUP: + | ins_AND // RA = dst, RD = table const (~) (holding template table) + | mov L:RB, SAVE_L + | mov RA, [DISPATCH+DISPATCH_GL(gc.total)] + | mov SAVE_PC, PC + | cmp RA, [DISPATCH+DISPATCH_GL(gc.threshold)] + | mov L:RB->base, BASE + | jae >3 + |2: + | mov TAB:FCARG2, [KBASE+RD*4] // Caveat: FCARG2 == BASE + | mov L:FCARG1, L:RB // Caveat: FCARG1 == RA + | call extern lj_tab_dup@8 // (lua_State *L, Table *kt) + | // Table * returned in eax (RC). + | mov BASE, L:RB->base + | movzx RA, PC_RA + | mov [BASE+RA*8], TAB:RC + | mov dword [BASE+RA*8+4], LJ_TTAB + | ins_next + |3: + | mov L:FCARG1, L:RB + | call extern lj_gc_step_fixtop@4 // (lua_State *L) + | movzx RD, PC_RD // Need to reload RD. + | not RDa + | jmp <2 + break; + + case BC_GGET: + | ins_AND // RA = dst, RD = str const (~) + | mov LFUNC:RB, [BASE-8] + | mov TAB:RB, LFUNC:RB->env + | mov STR:RC, [KBASE+RD*4] + | jmp ->BC_TGETS_Z + break; + case BC_GSET: + | ins_AND // RA = src, RD = str const (~) + | mov LFUNC:RB, [BASE-8] + | mov TAB:RB, LFUNC:RB->env + | mov STR:RC, [KBASE+RD*4] + | jmp ->BC_TSETS_Z + break; + + case BC_TGETV: + | ins_ABC // RA = dst, RB = table, RC = key + | checktab RB, ->vmeta_tgetv + | mov TAB:RB, [BASE+RB*8] + | + | // Integer key? + |.if DUALNUM + | checkint RC, >5 + | mov RC, dword [BASE+RC*8] + |.else + | // Convert number to int and back and compare. + | checknum RC, >5 + |.if SSE + | movsd xmm0, qword [BASE+RC*8] + | cvtsd2si RC, xmm0 + | cvtsi2sd xmm1, RC + | ucomisd xmm0, xmm1 + |.else + | fld qword [BASE+RC*8] + | fist ARG1 + | fild ARG1 + | fcomparepp + | mov RC, ARG1 + |.endif + | jne ->vmeta_tgetv // Generic numeric key? Use fallback. + |.endif + | cmp RC, TAB:RB->asize // Takes care of unordered, too. + | jae ->vmeta_tgetv // Not in array part? Use fallback. + | shl RC, 3 + | add RC, TAB:RB->array + | cmp dword [RC+4], LJ_TNIL // Avoid overwriting RB in fastpath. + | je >2 + | // Get array slot. + |.if X64 + | mov RBa, [RC] + | mov [BASE+RA*8], RBa + |.else + | mov RB, [RC] + | mov RC, [RC+4] + | mov [BASE+RA*8], RB + | mov [BASE+RA*8+4], RC + |.endif + |1: + | ins_next + | + |2: // Check for __index if table value is nil. + | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. + | jz >3 + | mov TAB:RA, TAB:RB->metatable + | test byte TAB:RA->nomm, 1<vmeta_tgetv // 'no __index' flag NOT set: check. + | movzx RA, PC_RA // Restore RA. + |3: + | mov dword [BASE+RA*8+4], LJ_TNIL + | jmp <1 + | + |5: // String key? + | checkstr RC, ->vmeta_tgetv + | mov STR:RC, [BASE+RC*8] + | jmp ->BC_TGETS_Z + break; + case BC_TGETS: + | ins_ABC // RA = dst, RB = table, RC = str const (~) + | not RCa + | mov STR:RC, [KBASE+RC*4] + | checktab RB, ->vmeta_tgets + | mov TAB:RB, [BASE+RB*8] + |->BC_TGETS_Z: // RB = GCtab *, RC = GCstr *, refetches PC_RA. + | mov RA, TAB:RB->hmask + | and RA, STR:RC->hash + | imul RA, #NODE + | add NODE:RA, TAB:RB->node + |1: + | cmp dword NODE:RA->key.it, LJ_TSTR + | jne >4 + | cmp dword NODE:RA->key.gcr, STR:RC + | jne >4 + | // Ok, key found. Assumes: offsetof(Node, val) == 0 + | cmp dword [RA+4], LJ_TNIL // Avoid overwriting RB in fastpath. + | je >5 // Key found, but nil value? + | movzx RC, PC_RA + | // Get node value. + |.if X64 + | mov RBa, [RA] + | mov [BASE+RC*8], RBa + |.else + | mov RB, [RA] + | mov RA, [RA+4] + | mov [BASE+RC*8], RB + | mov [BASE+RC*8+4], RA + |.endif + |2: + | ins_next + | + |3: + | movzx RC, PC_RA + | mov dword [BASE+RC*8+4], LJ_TNIL + | jmp <2 + | + |4: // Follow hash chain. + | mov NODE:RA, NODE:RA->next + | test NODE:RA, NODE:RA + | jnz <1 + | // End of hash chain: key not found, nil result. + | + |5: // Check for __index if table value is nil. + | mov TAB:RA, TAB:RB->metatable + | test TAB:RA, TAB:RA + | jz <3 // No metatable: done. + | test byte TAB:RA->nomm, 1<vmeta_tgets // Caveat: preserve STR:RC. + break; + case BC_TGETB: + | ins_ABC // RA = dst, RB = table, RC = byte literal + | checktab RB, ->vmeta_tgetb + | mov TAB:RB, [BASE+RB*8] + | cmp RC, TAB:RB->asize + | jae ->vmeta_tgetb + | shl RC, 3 + | add RC, TAB:RB->array + | cmp dword [RC+4], LJ_TNIL // Avoid overwriting RB in fastpath. + | je >2 + | // Get array slot. + |.if X64 + | mov RBa, [RC] + | mov [BASE+RA*8], RBa + |.else + | mov RB, [RC] + | mov RC, [RC+4] + | mov [BASE+RA*8], RB + | mov [BASE+RA*8+4], RC + |.endif + |1: + | ins_next + | + |2: // Check for __index if table value is nil. + | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. + | jz >3 + | mov TAB:RA, TAB:RB->metatable + | test byte TAB:RA->nomm, 1<vmeta_tgetb // 'no __index' flag NOT set: check. + | movzx RA, PC_RA // Restore RA. + |3: + | mov dword [BASE+RA*8+4], LJ_TNIL + | jmp <1 + break; + + case BC_TSETV: + | ins_ABC // RA = src, RB = table, RC = key + | checktab RB, ->vmeta_tsetv + | mov TAB:RB, [BASE+RB*8] + | + | // Integer key? + |.if DUALNUM + | checkint RC, >5 + | mov RC, dword [BASE+RC*8] + |.else + | // Convert number to int and back and compare. + | checknum RC, >5 + |.if SSE + | movsd xmm0, qword [BASE+RC*8] + | cvtsd2si RC, xmm0 + | cvtsi2sd xmm1, RC + | ucomisd xmm0, xmm1 + |.else + | fld qword [BASE+RC*8] + | fist ARG1 + | fild ARG1 + | fcomparepp + | mov RC, ARG1 + |.endif + | jne ->vmeta_tsetv // Generic numeric key? Use fallback. + |.endif + | cmp RC, TAB:RB->asize // Takes care of unordered, too. + | jae ->vmeta_tsetv + | shl RC, 3 + | add RC, TAB:RB->array + | cmp dword [RC+4], LJ_TNIL + | je >3 // Previous value is nil? + |1: + | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) + | jnz >7 + |2: // Set array slot. + |.if X64 + | mov RBa, [BASE+RA*8] + | mov [RC], RBa + |.else + | mov RB, [BASE+RA*8+4] + | mov RA, [BASE+RA*8] + | mov [RC+4], RB + | mov [RC], RA + |.endif + | ins_next + | + |3: // Check for __newindex if previous value is nil. + | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. + | jz <1 + | mov TAB:RA, TAB:RB->metatable + | test byte TAB:RA->nomm, 1<vmeta_tsetv // 'no __newindex' flag NOT set: check. + | movzx RA, PC_RA // Restore RA. + | jmp <1 + | + |5: // String key? + | checkstr RC, ->vmeta_tsetv + | mov STR:RC, [BASE+RC*8] + | jmp ->BC_TSETS_Z + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, RA + | movzx RA, PC_RA // Restore RA. + | jmp <2 + break; + case BC_TSETS: + | ins_ABC // RA = src, RB = table, RC = str const (~) + | not RCa + | mov STR:RC, [KBASE+RC*4] + | checktab RB, ->vmeta_tsets + | mov TAB:RB, [BASE+RB*8] + |->BC_TSETS_Z: // RB = GCtab *, RC = GCstr *, refetches PC_RA. + | mov RA, TAB:RB->hmask + | and RA, STR:RC->hash + | imul RA, #NODE + | mov byte TAB:RB->nomm, 0 // Clear metamethod cache. + | add NODE:RA, TAB:RB->node + |1: + | cmp dword NODE:RA->key.it, LJ_TSTR + | jne >5 + | cmp dword NODE:RA->key.gcr, STR:RC + | jne >5 + | // Ok, key found. Assumes: offsetof(Node, val) == 0 + | cmp dword [RA+4], LJ_TNIL + | je >4 // Previous value is nil? + |2: + | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) + | jnz >7 + |3: // Set node value. + | movzx RC, PC_RA + |.if X64 + | mov RBa, [BASE+RC*8] + | mov [RA], RBa + |.else + | mov RB, [BASE+RC*8+4] + | mov RC, [BASE+RC*8] + | mov [RA+4], RB + | mov [RA], RC + |.endif + | ins_next + | + |4: // Check for __newindex if previous value is nil. + | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. + | jz <2 + | mov TMP1, RA // Save RA. + | mov TAB:RA, TAB:RB->metatable + | test byte TAB:RA->nomm, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. + | mov RA, TMP1 // Restore RA. + | jmp <2 + | + |5: // Follow hash chain. + | mov NODE:RA, NODE:RA->next + | test NODE:RA, NODE:RA + | jnz <1 + | // End of hash chain: key not found, add a new one. + | + | // But check for __newindex first. + | mov TAB:RA, TAB:RB->metatable + | test TAB:RA, TAB:RA + | jz >6 // No metatable: continue. + | test byte TAB:RA->nomm, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. + |6: + | mov TMP1, STR:RC + | mov TMP2, LJ_TSTR + | mov TMP3, TAB:RB // Save TAB:RB for us. + |.if X64 + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE + | lea CARG3, TMP1 + | mov CARG2d, TAB:RB + | mov L:RB, L:CARG1d + |.else + | lea RC, TMP1 // Store temp. TValue in TMP1/TMP2. + | mov ARG2, TAB:RB + | mov L:RB, SAVE_L + | mov ARG3, RC + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | call extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) + | // Handles write barrier for the new key. TValue * returned in eax (RC). + | mov BASE, L:RB->base + | mov TAB:RB, TMP3 // Need TAB:RB for barrier. + | mov RA, eax + | jmp <2 // Must check write barrier for value. + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, RC // Destroys STR:RC. + | jmp <3 + break; + case BC_TSETB: + | ins_ABC // RA = src, RB = table, RC = byte literal + | checktab RB, ->vmeta_tsetb + | mov TAB:RB, [BASE+RB*8] + | cmp RC, TAB:RB->asize + | jae ->vmeta_tsetb + | shl RC, 3 + | add RC, TAB:RB->array + | cmp dword [RC+4], LJ_TNIL + | je >3 // Previous value is nil? + |1: + | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) + | jnz >7 + |2: // Set array slot. + |.if X64 + | mov RAa, [BASE+RA*8] + | mov [RC], RAa + |.else + | mov RB, [BASE+RA*8+4] + | mov RA, [BASE+RA*8] + | mov [RC+4], RB + | mov [RC], RA + |.endif + | ins_next + | + |3: // Check for __newindex if previous value is nil. + | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. + | jz <1 + | mov TAB:RA, TAB:RB->metatable + | test byte TAB:RA->nomm, 1<vmeta_tsetb // 'no __newindex' flag NOT set: check. + | movzx RA, PC_RA // Restore RA. + | jmp <1 + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, RA + | movzx RA, PC_RA // Restore RA. + | jmp <2 + break; + + case BC_TSETM: + | ins_AD // RA = base (table at base-1), RD = num const (start index) + | mov TMP1, KBASE // Need one more free register. + | mov KBASE, dword [KBASE+RD*8] // Integer constant is in lo-word. + |1: + | lea RA, [BASE+RA*8] + | mov TAB:RB, [RA-8] // Guaranteed to be a table. + | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) + | jnz >7 + |2: + | mov RD, MULTRES + | sub RD, 1 + | jz >4 // Nothing to copy? + | add RD, KBASE // Compute needed size. + | cmp RD, TAB:RB->asize + | ja >5 // Doesn't fit into array part? + | sub RD, KBASE + | shl KBASE, 3 + | add KBASE, TAB:RB->array + |3: // Copy result slots to table. + |.if X64 + | mov RBa, [RA] + | add RA, 8 + | mov [KBASE], RBa + |.else + | mov RB, [RA] + | mov [KBASE], RB + | mov RB, [RA+4] + | add RA, 8 + | mov [KBASE+4], RB + |.endif + | add KBASE, 8 + | sub RD, 1 + | jnz <3 + |4: + | mov KBASE, TMP1 + | ins_next + | + |5: // Need to resize array part. + |.if X64 + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. + | mov CARG2d, TAB:RB + | mov CARG3d, RD + | mov L:RB, L:CARG1d + |.else + | mov ARG2, TAB:RB + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | mov ARG3, RD + | mov ARG1, L:RB + |.endif + | mov SAVE_PC, PC + | call extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) + | mov BASE, L:RB->base + | movzx RA, PC_RA // Restore RA. + | jmp <1 // Retry. + | + |7: // Possible table write barrier for any value. Skip valiswhite check. + | barrierback TAB:RB, RD + | jmp <2 + break; + + /* -- Calls and vararg handling ----------------------------------------- */ + + case BC_CALL: case BC_CALLM: + | ins_A_C // RA = base, (RB = nresults+1,) RC = nargs+1 | extra_nargs + if (op == BC_CALLM) { + | add NARGS:RD, MULTRES + } + | cmp dword [BASE+RA*8+4], LJ_TFUNC + | mov LFUNC:RB, [BASE+RA*8] + | jne ->vmeta_call_ra + | lea BASE, [BASE+RA*8+8] + | ins_call + break; + + case BC_CALLMT: + | ins_AD // RA = base, RD = extra_nargs + | add NARGS:RD, MULTRES + | // Fall through. Assumes BC_CALLT follows and ins_AD is a no-op. + break; + case BC_CALLT: + | ins_AD // RA = base, RD = nargs+1 + | lea RA, [BASE+RA*8+8] + | mov KBASE, BASE // Use KBASE for move + vmeta_call hint. + | mov LFUNC:RB, [RA-8] + | cmp dword [RA-4], LJ_TFUNC + | jne ->vmeta_call + |->BC_CALLT_Z: + | mov PC, [BASE-4] + | test PC, FRAME_TYPE + | jnz >7 + |1: + | mov [BASE-8], LFUNC:RB // Copy function down, reloaded below. + | mov MULTRES, NARGS:RD + | sub NARGS:RD, 1 + | jz >3 + |2: // Move args down. + |.if X64 + | mov RBa, [RA] + | add RA, 8 + | mov [KBASE], RBa + |.else + | mov RB, [RA] + | mov [KBASE], RB + | mov RB, [RA+4] + | add RA, 8 + | mov [KBASE+4], RB + |.endif + | add KBASE, 8 + | sub NARGS:RD, 1 + | jnz <2 + | + | mov LFUNC:RB, [BASE-8] + |3: + | mov NARGS:RD, MULTRES + | cmp byte LFUNC:RB->ffid, 1 // (> FF_C) Calling a fast function? + | ja >5 + |4: + | ins_callt + | + |5: // Tailcall to a fast function. + | test PC, FRAME_TYPE // Lua frame below? + | jnz <4 + | movzx RA, PC_RA + | not RAa + | mov LFUNC:KBASE, [BASE+RA*8-8] // Need to prepare KBASE. + | mov KBASE, LFUNC:KBASE->pc + | mov KBASE, [KBASE+PC2PROTO(k)] + | jmp <4 + | + |7: // Tailcall from a vararg function. + | sub PC, FRAME_VARG + | test PC, FRAME_TYPEP + | jnz >8 // Vararg frame below? + | sub BASE, PC // Need to relocate BASE/KBASE down. + | mov KBASE, BASE + | mov PC, [BASE-4] + | jmp <1 + |8: + | add PC, FRAME_VARG + | jmp <1 + break; + + case BC_ITERC: + | ins_A // RA = base, (RB = nresults+1,) RC = nargs+1 (2+1) + | lea RA, [BASE+RA*8+8] // fb = base+1 + |.if X64 + | mov RBa, [RA-24] // Copy state. fb[0] = fb[-3]. + | mov RCa, [RA-16] // Copy control var. fb[1] = fb[-2]. + | mov [RA], RBa + | mov [RA+8], RCa + |.else + | mov RB, [RA-24] // Copy state. fb[0] = fb[-3]. + | mov RC, [RA-20] + | mov [RA], RB + | mov [RA+4], RC + | mov RB, [RA-16] // Copy control var. fb[1] = fb[-2]. + | mov RC, [RA-12] + | mov [RA+8], RB + | mov [RA+12], RC + |.endif + | mov LFUNC:RB, [RA-32] // Copy callable. fb[-1] = fb[-4] + | mov RC, [RA-28] + | mov [RA-8], LFUNC:RB + | mov [RA-4], RC + | cmp RC, LJ_TFUNC // Handle like a regular 2-arg call. + | mov NARGS:RD, 2+1 + | jne ->vmeta_call + | mov BASE, RA + | ins_call + break; + + case BC_ITERN: + | ins_A // RA = base, (RB = nresults+1, RC = nargs+1 (2+1)) + |.if JIT + | // NYI: add hotloop, record BC_ITERN. + |.endif + | mov TMP1, KBASE // Need two more free registers. + | mov TMP2, DISPATCH + | mov TAB:RB, [BASE+RA*8-16] + | mov RC, [BASE+RA*8-8] // Get index from control var. + | mov DISPATCH, TAB:RB->asize + | add PC, 4 + | mov KBASE, TAB:RB->array + |1: // Traverse array part. + | cmp RC, DISPATCH; jae >5 // Index points after array part? + | cmp dword [KBASE+RC*8+4], LJ_TNIL; je >4 + |.if DUALNUM + | mov dword [BASE+RA*8+4], LJ_TISNUM + | mov dword [BASE+RA*8], RC + |.elif SSE + | cvtsi2sd xmm0, RC + |.else + | fild dword [BASE+RA*8-8] + |.endif + | // Copy array slot to returned value. + |.if X64 + | mov RBa, [KBASE+RC*8] + | mov [BASE+RA*8+8], RBa + |.else + | mov RB, [KBASE+RC*8+4] + | mov [BASE+RA*8+12], RB + | mov RB, [KBASE+RC*8] + | mov [BASE+RA*8+8], RB + |.endif + | add RC, 1 + | // Return array index as a numeric key. + |.if DUALNUM + | // See above. + |.elif SSE + | movsd qword [BASE+RA*8], xmm0 + |.else + | fstp qword [BASE+RA*8] + |.endif + | mov [BASE+RA*8-8], RC // Update control var. + |2: + | movzx RD, PC_RD // Get target from ITERL. + | branchPC RD + |3: + | mov DISPATCH, TMP2 + | mov KBASE, TMP1 + | ins_next + | + |4: // Skip holes in array part. + | add RC, 1 + |.if not (DUALNUM or SSE) + | mov [BASE+RA*8-8], RC + |.endif + | jmp <1 + | + |5: // Traverse hash part. + | sub RC, DISPATCH + |6: + | cmp RC, TAB:RB->hmask; ja <3 // End of iteration? Branch to ITERL+1. + | imul KBASE, RC, #NODE + | add NODE:KBASE, TAB:RB->node + | cmp dword NODE:KBASE->val.it, LJ_TNIL; je >7 + | lea DISPATCH, [RC+DISPATCH+1] + | // Copy key and value from hash slot. + |.if X64 + | mov RBa, NODE:KBASE->key + | mov RCa, NODE:KBASE->val + | mov [BASE+RA*8], RBa + | mov [BASE+RA*8+8], RCa + |.else + | mov RB, NODE:KBASE->key.gcr + | mov RC, NODE:KBASE->key.it + | mov [BASE+RA*8], RB + | mov [BASE+RA*8+4], RC + | mov RB, NODE:KBASE->val.gcr + | mov RC, NODE:KBASE->val.it + | mov [BASE+RA*8+8], RB + | mov [BASE+RA*8+12], RC + |.endif + | mov [BASE+RA*8-8], DISPATCH + | jmp <2 + | + |7: // Skip holes in hash part. + | add RC, 1 + | jmp <6 + break; + + case BC_ISNEXT: + | ins_AD // RA = base, RD = target (points to ITERN) + | cmp dword [BASE+RA*8-20], LJ_TFUNC; jne >5 + | mov CFUNC:RB, [BASE+RA*8-24] + | cmp dword [BASE+RA*8-12], LJ_TTAB; jne >5 + | cmp dword [BASE+RA*8-4], LJ_TNIL; jne >5 + | cmp byte CFUNC:RB->ffid, FF_next_N; jne >5 + | branchPC RD + | mov dword [BASE+RA*8-8], 0 // Initialize control var. + | mov dword [BASE+RA*8-4], 0xfffe7fff + |1: + | ins_next + |5: // Despecialize bytecode if any of the checks fail. + | mov PC_OP, BC_JMP + | branchPC RD + | mov byte [PC], BC_ITERC + | jmp <1 + break; + + case BC_VARG: + | ins_ABC // RA = base, RB = nresults+1, RC = numparams + | mov TMP1, KBASE // Need one more free register. + | lea KBASE, [BASE+RC*8+(8+FRAME_VARG)] + | lea RA, [BASE+RA*8] + | sub KBASE, [BASE-4] + | // Note: KBASE may now be even _above_ BASE if nargs was < numparams. + | test RB, RB + | jz >5 // Copy all varargs? + | lea RB, [RA+RB*8-8] + | cmp KBASE, BASE // No vararg slots? + | jnb >2 + |1: // Copy vararg slots to destination slots. + |.if X64 + | mov RCa, [KBASE-8] + | add KBASE, 8 + | mov [RA], RCa + |.else + | mov RC, [KBASE-8] + | mov [RA], RC + | mov RC, [KBASE-4] + | add KBASE, 8 + | mov [RA+4], RC + |.endif + | add RA, 8 + | cmp RA, RB // All destination slots filled? + | jnb >3 + | cmp KBASE, BASE // No more vararg slots? + | jb <1 + |2: // Fill up remainder with nil. + | mov dword [RA+4], LJ_TNIL + | add RA, 8 + | cmp RA, RB + | jb <2 + |3: + | mov KBASE, TMP1 + | ins_next + | + |5: // Copy all varargs. + | mov MULTRES, 1 // MULTRES = 0+1 + | mov RC, BASE + | sub RC, KBASE + | jbe <3 // No vararg slots? + | mov RB, RC + | shr RB, 3 + | add RB, 1 + | mov MULTRES, RB // MULTRES = #varargs+1 + | mov L:RB, SAVE_L + | add RC, RA + | cmp RC, L:RB->maxstack + | ja >7 // Need to grow stack? + |6: // Copy all vararg slots. + |.if X64 + | mov RCa, [KBASE-8] + | add KBASE, 8 + | mov [RA], RCa + |.else + | mov RC, [KBASE-8] + | mov [RA], RC + | mov RC, [KBASE-4] + | add KBASE, 8 + | mov [RA+4], RC + |.endif + | add RA, 8 + | cmp KBASE, BASE // No more vararg slots? + | jb <6 + | jmp <3 + | + |7: // Grow stack for varargs. + | mov L:RB->base, BASE + | mov L:RB->top, RA + | mov SAVE_PC, PC + | sub KBASE, BASE // Need delta, because BASE may change. + | mov FCARG2, MULTRES + | sub FCARG2, 1 + | mov FCARG1, L:RB + | call extern lj_state_growstack@8 // (lua_State *L, int n) + | mov BASE, L:RB->base + | mov RA, L:RB->top + | add KBASE, BASE + | jmp <6 + break; + + /* -- Returns ----------------------------------------------------------- */ + + case BC_RETM: + | ins_AD // RA = results, RD = extra_nresults + | add RD, MULTRES // MULTRES >=1, so RD >=1. + | // Fall through. Assumes BC_RET follows and ins_AD is a no-op. + break; + + case BC_RET: case BC_RET0: case BC_RET1: + | ins_AD // RA = results, RD = nresults+1 + if (op != BC_RET0) { + | shl RA, 3 + } + |1: + | mov PC, [BASE-4] + | mov MULTRES, RD // Save nresults+1. + | test PC, FRAME_TYPE // Check frame type marker. + | jnz >7 // Not returning to a fixarg Lua func? + switch (op) { + case BC_RET: + |->BC_RET_Z: + | mov KBASE, BASE // Use KBASE for result move. + | sub RD, 1 + | jz >3 + |2: // Move results down. + |.if X64 + | mov RBa, [KBASE+RA] + | mov [KBASE-8], RBa + |.else + | mov RB, [KBASE+RA] + | mov [KBASE-8], RB + | mov RB, [KBASE+RA+4] + | mov [KBASE-4], RB + |.endif + | add KBASE, 8 + | sub RD, 1 + | jnz <2 + |3: + | mov RD, MULTRES // Note: MULTRES may be >255. + | movzx RB, PC_RB // So cannot compare with RDL! + |5: + | cmp RB, RD // More results expected? + | ja >6 + break; + case BC_RET1: + |.if X64 + | mov RBa, [BASE+RA] + | mov [BASE-8], RBa + |.else + | mov RB, [BASE+RA+4] + | mov [BASE-4], RB + | mov RB, [BASE+RA] + | mov [BASE-8], RB + |.endif + /* fallthrough */ + case BC_RET0: + |5: + | cmp PC_RB, RDL // More results expected? + | ja >6 + default: + break; + } + | movzx RA, PC_RA + | not RAa // Note: ~RA = -(RA+1) + | lea BASE, [BASE+RA*8] // base = base - (RA+1)*8 + | mov LFUNC:KBASE, [BASE-8] + | mov KBASE, LFUNC:KBASE->pc + | mov KBASE, [KBASE+PC2PROTO(k)] + | ins_next + | + |6: // Fill up results with nil. + if (op == BC_RET) { + | mov dword [KBASE-4], LJ_TNIL // Note: relies on shifted base. + | add KBASE, 8 + } else { + | mov dword [BASE+RD*8-12], LJ_TNIL + } + | add RD, 1 + | jmp <5 + | + |7: // Non-standard return case. + | lea RB, [PC-FRAME_VARG] + | test RB, FRAME_TYPEP + | jnz ->vm_return + | // Return from vararg function: relocate BASE down and RA up. + | sub BASE, RB + if (op != BC_RET0) { + | add RA, RB + } + | jmp <1 + break; + + /* -- Loops and branches ------------------------------------------------ */ + + |.define FOR_IDX, [RA]; .define FOR_TIDX, dword [RA+4] + |.define FOR_STOP, [RA+8]; .define FOR_TSTOP, dword [RA+12] + |.define FOR_STEP, [RA+16]; .define FOR_TSTEP, dword [RA+20] + |.define FOR_EXT, [RA+24]; .define FOR_TEXT, dword [RA+28] + + case BC_FORL: + |.if JIT + | hotloop RB + |.endif + | // Fall through. Assumes BC_IFORL follows and ins_AJ is a no-op. + break; + + case BC_JFORI: + case BC_JFORL: +#if !LJ_HASJIT + break; +#endif + case BC_FORI: + case BC_IFORL: + vk = (op == BC_IFORL || op == BC_JFORL); + | ins_AJ // RA = base, RD = target (after end of loop or start of loop) + | lea RA, [BASE+RA*8] + if (LJ_DUALNUM) { + | cmp FOR_TIDX, LJ_TISNUM; jne >9 + if (!vk) { + | cmp FOR_TSTOP, LJ_TISNUM; jne ->vmeta_for + | cmp FOR_TSTEP, LJ_TISNUM; jne ->vmeta_for + | mov RB, dword FOR_IDX + | cmp dword FOR_STEP, 0; jl >5 + } else { +#ifdef LUA_USE_ASSERT + | cmp FOR_TSTOP, LJ_TISNUM; jne ->assert_bad_for_arg_type + | cmp FOR_TSTEP, LJ_TISNUM; jne ->assert_bad_for_arg_type +#endif + | mov RB, dword FOR_STEP + | test RB, RB; js >5 + | add RB, dword FOR_IDX; jo >1 + | mov dword FOR_IDX, RB + } + | cmp RB, dword FOR_STOP + | mov FOR_TEXT, LJ_TISNUM + | mov dword FOR_EXT, RB + if (op == BC_FORI) { + | jle >7 + |1: + |6: + | branchPC RD + } else if (op == BC_JFORI) { + | branchPC RD + | movzx RD, PC_RD + | jle =>BC_JLOOP + |1: + |6: + } else if (op == BC_IFORL) { + | jg >7 + |6: + | branchPC RD + |1: + } else { + | jle =>BC_JLOOP + |1: + |6: + } + |7: + | ins_next + | + |5: // Invert check for negative step. + if (vk) { + | add RB, dword FOR_IDX; jo <1 + | mov dword FOR_IDX, RB + } + | cmp RB, dword FOR_STOP + | mov FOR_TEXT, LJ_TISNUM + | mov dword FOR_EXT, RB + if (op == BC_FORI) { + | jge <7 + } else if (op == BC_JFORI) { + | branchPC RD + | movzx RD, PC_RD + | jge =>BC_JLOOP + } else if (op == BC_IFORL) { + | jl <7 + } else { + | jge =>BC_JLOOP + } + | jmp <6 + |9: // Fallback to FP variant. + } else if (!vk) { + | cmp FOR_TIDX, LJ_TISNUM + } + if (!vk) { + | jae ->vmeta_for + | cmp FOR_TSTOP, LJ_TISNUM; jae ->vmeta_for + } else { +#ifdef LUA_USE_ASSERT + | cmp FOR_TSTOP, LJ_TISNUM; jae ->assert_bad_for_arg_type + | cmp FOR_TSTEP, LJ_TISNUM; jae ->assert_bad_for_arg_type +#endif + } + | mov RB, FOR_TSTEP // Load type/hiword of for step. + if (!vk) { + | cmp RB, LJ_TISNUM; jae ->vmeta_for + } + |.if SSE + | movsd xmm0, qword FOR_IDX + | movsd xmm1, qword FOR_STOP + if (vk) { + | addsd xmm0, qword FOR_STEP + | movsd qword FOR_IDX, xmm0 + | test RB, RB; js >3 + } else { + | jl >3 + } + | ucomisd xmm1, xmm0 + |1: + | movsd qword FOR_EXT, xmm0 + |.else + | fld qword FOR_STOP + | fld qword FOR_IDX + if (vk) { + | fadd qword FOR_STEP // nidx = idx + step + | fst qword FOR_IDX + | fst qword FOR_EXT + | test RB, RB; js >1 + } else { + | fst qword FOR_EXT + | jl >1 + } + | fxch // Swap lim/(n)idx if step non-negative. + |1: + | fcomparepp + |.endif + if (op == BC_FORI) { + |.if DUALNUM + | jnb <7 + |.else + | jnb >2 + | branchPC RD + |.endif + } else if (op == BC_JFORI) { + | branchPC RD + | movzx RD, PC_RD + | jnb =>BC_JLOOP + } else if (op == BC_IFORL) { + |.if DUALNUM + | jb <7 + |.else + | jb >2 + | branchPC RD + |.endif + } else { + | jnb =>BC_JLOOP + } + |.if DUALNUM + | jmp <6 + |.else + |2: + | ins_next + |.endif + |.if SSE + |3: // Invert comparison if step is negative. + | ucomisd xmm0, xmm1 + | jmp <1 + |.endif + break; + + case BC_ITERL: + |.if JIT + | hotloop RB + |.endif + | // Fall through. Assumes BC_IITERL follows and ins_AJ is a no-op. + break; + + case BC_JITERL: +#if !LJ_HASJIT + break; +#endif + case BC_IITERL: + | ins_AJ // RA = base, RD = target + | lea RA, [BASE+RA*8] + | mov RB, [RA+4] + | cmp RB, LJ_TNIL; je >1 // Stop if iterator returned nil. + if (op == BC_JITERL) { + | mov [RA-4], RB + | mov RB, [RA] + | mov [RA-8], RB + | jmp =>BC_JLOOP + } else { + | branchPC RD // Otherwise save control var + branch. + | mov RD, [RA] + | mov [RA-4], RB + | mov [RA-8], RD + } + |1: + | ins_next + break; + + case BC_LOOP: + | ins_A // RA = base, RD = target (loop extent) + | // Note: RA/RD is only used by trace recorder to determine scope/extent + | // This opcode does NOT jump, it's only purpose is to detect a hot loop. + |.if JIT + | hotloop RB + |.endif + | // Fall through. Assumes BC_ILOOP follows and ins_A is a no-op. + break; + + case BC_ILOOP: + | ins_A // RA = base, RD = target (loop extent) + | ins_next + break; + + case BC_JLOOP: + |.if JIT + | ins_AD // RA = base (ignored), RD = traceno + | mov RA, [DISPATCH+DISPATCH_J(trace)] + | mov TRACE:RD, [RA+RD*4] + | mov RDa, TRACE:RD->mcode + | mov L:RB, SAVE_L + | mov [DISPATCH+DISPATCH_GL(jit_base)], BASE + | mov [DISPATCH+DISPATCH_GL(jit_L)], L:RB + | // Save additional callee-save registers only used in compiled code. + |.if X64WIN + | mov TMPQ, r12 + | mov TMPa, r13 + | mov CSAVE_4, r14 + | mov CSAVE_3, r15 + | mov RAa, rsp + | sub rsp, 9*16+4*8 + | movdqa [RAa], xmm6 + | movdqa [RAa-1*16], xmm7 + | movdqa [RAa-2*16], xmm8 + | movdqa [RAa-3*16], xmm9 + | movdqa [RAa-4*16], xmm10 + | movdqa [RAa-5*16], xmm11 + | movdqa [RAa-6*16], xmm12 + | movdqa [RAa-7*16], xmm13 + | movdqa [RAa-8*16], xmm14 + | movdqa [RAa-9*16], xmm15 + |.elif X64 + | mov TMPQ, r12 + | mov TMPa, r13 + | sub rsp, 16 + |.endif + | jmp RDa + |.endif + break; + + case BC_JMP: + | ins_AJ // RA = unused, RD = target + | branchPC RD + | ins_next + break; + + /* -- Function headers -------------------------------------------------- */ + + /* + ** Reminder: A function may be called with func/args above L->maxstack, + ** i.e. occupying EXTRA_STACK slots. And vmeta_call may add one extra slot, + ** too. This means all FUNC* ops (including fast functions) must check + ** for stack overflow _before_ adding more slots! + */ + + case BC_FUNCF: + |.if JIT + | hotcall RB + |.endif + case BC_FUNCV: /* NYI: compiled vararg functions. */ + | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow and ins_AD is a no-op. + break; + + case BC_JFUNCF: +#if !LJ_HASJIT + break; +#endif + case BC_IFUNCF: + | ins_AD // BASE = new base, RA = framesize, RD = nargs+1 + | mov KBASE, [PC-4+PC2PROTO(k)] + | mov L:RB, SAVE_L + | lea RA, [BASE+RA*8] // Top of frame. + | cmp RA, L:RB->maxstack + | ja ->vm_growstack_f + | movzx RA, byte [PC-4+PC2PROTO(numparams)] + | cmp NARGS:RD, RA // Check for missing parameters. + | jbe >3 + |2: + if (op == BC_JFUNCF) { + | movzx RD, PC_RD + | jmp =>BC_JLOOP + } else { + | ins_next + } + | + |3: // Clear missing parameters. + | mov dword [BASE+NARGS:RD*8-4], LJ_TNIL + | add NARGS:RD, 1 + | cmp NARGS:RD, RA + | jbe <3 + | jmp <2 + break; + + case BC_JFUNCV: +#if !LJ_HASJIT + break; +#endif + | int3 // NYI: compiled vararg functions + break; /* NYI: compiled vararg functions. */ + + case BC_IFUNCV: + | ins_AD // BASE = new base, RA = framesize, RD = nargs+1 + | lea RB, [NARGS:RD*8+FRAME_VARG] + | lea RD, [BASE+NARGS:RD*8] + | mov LFUNC:KBASE, [BASE-8] + | mov [RD-4], RB // Store delta + FRAME_VARG. + | mov [RD-8], LFUNC:KBASE // Store copy of LFUNC. + | mov L:RB, SAVE_L + | lea RA, [RD+RA*8] + | cmp RA, L:RB->maxstack + | ja ->vm_growstack_v // Need to grow stack. + | mov RA, BASE + | mov BASE, RD + | movzx RB, byte [PC-4+PC2PROTO(numparams)] + | test RB, RB + | jz >2 + |1: // Copy fixarg slots up to new frame. + | add RA, 8 + | cmp RA, BASE + | jnb >3 // Less args than parameters? + | mov KBASE, [RA-8] + | mov [RD], KBASE + | mov KBASE, [RA-4] + | mov [RD+4], KBASE + | add RD, 8 + | mov dword [RA-4], LJ_TNIL // Clear old fixarg slot (help the GC). + | sub RB, 1 + | jnz <1 + |2: + if (op == BC_JFUNCV) { + | movzx RD, PC_RD + | jmp =>BC_JLOOP + } else { + | mov KBASE, [PC-4+PC2PROTO(k)] + | ins_next + } + | + |3: // Clear missing parameters. + | mov dword [RD+4], LJ_TNIL + | add RD, 8 + | sub RB, 1 + | jnz <3 + | jmp <2 + break; + + case BC_FUNCC: + case BC_FUNCCW: + | ins_AD // BASE = new base, RA = ins RA|RD (unused), RD = nargs+1 + | mov CFUNC:RB, [BASE-8] + | mov KBASEa, CFUNC:RB->f + | mov L:RB, SAVE_L + | lea RD, [BASE+NARGS:RD*8-8] + | mov L:RB->base, BASE + | lea RA, [RD+8*LUA_MINSTACK] + | cmp RA, L:RB->maxstack + | mov L:RB->top, RD + if (op == BC_FUNCC) { + |.if X64 + | mov CARG1d, L:RB // Caveat: CARG1d may be RA. + |.else + | mov ARG1, L:RB + |.endif + } else { + |.if X64 + | mov CARG2, KBASEa + | mov CARG1d, L:RB // Caveat: CARG1d may be RA. + |.else + | mov ARG2, KBASEa + | mov ARG1, L:RB + |.endif + } + | ja ->vm_growstack_c // Need to grow stack. + | set_vmstate C + if (op == BC_FUNCC) { + | call KBASEa // (lua_State *L) + } else { + | // (lua_State *L, lua_CFunction f) + | call aword [DISPATCH+DISPATCH_GL(wrapf)] + } + | set_vmstate INTERP + | // nresults returned in eax (RD). + | mov BASE, L:RB->base + | lea RA, [BASE+RD*8] + | neg RA + | add RA, L:RB->top // RA = (L->top-(L->base+nresults))*8 + | mov PC, [BASE-4] // Fetch PC of caller. + | jmp ->vm_returnc + break; + + /* ---------------------------------------------------------------------- */ + + default: + fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); + exit(2); + break; + } +} + +static int build_backend(BuildCtx *ctx) +{ + int op; + dasm_growpc(Dst, BC__MAX); + build_subroutines(ctx); + |.code_op + for (op = 0; op < BC__MAX; op++) + build_ins(ctx, (BCOp)op, op); + return BC__MAX; +} + +/* Emit pseudo frame-info for all assembler functions. */ +static void emit_asm_debug(BuildCtx *ctx) +{ + int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); +#if LJ_64 +#define SZPTR "8" +#define BSZPTR "3" +#define REG_SP "0x7" +#define REG_RA "0x10" +#else +#define SZPTR "4" +#define BSZPTR "2" +#define REG_SP "0x4" +#define REG_RA "0x8" +#endif + switch (ctx->mode) { + case BUILD_elfasm: + fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); + fprintf(ctx->fp, + ".Lframe0:\n" + "\t.long .LECIE0-.LSCIE0\n" + ".LSCIE0:\n" + "\t.long 0xffffffff\n" + "\t.byte 0x1\n" + "\t.string \"\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -" SZPTR "\n" + "\t.byte " REG_RA "\n" + "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" + "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" + "\t.align " SZPTR "\n" + ".LECIE0:\n\n"); + fprintf(ctx->fp, + ".LSFDE0:\n" + "\t.long .LEFDE0-.LASFDE0\n" + ".LASFDE0:\n" + "\t.long .Lframe0\n" +#if LJ_64 + "\t.quad .Lbegin\n" + "\t.quad %d\n" + "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ + "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ + "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ + "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ + "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ +#if LJ_NO_UNWIND + "\t.byte 0x8d\n\t.uleb128 0x6\n" /* offset r13 */ + "\t.byte 0x8c\n\t.uleb128 0x7\n" /* offset r12 */ +#endif +#else + "\t.long .Lbegin\n" + "\t.long %d\n" + "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ + "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ + "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */ + "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */ + "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */ +#endif + "\t.align " SZPTR "\n" + ".LEFDE0:\n\n", fcofs, CFRAME_SIZE); +#if LJ_HASFFI + fprintf(ctx->fp, + ".LSFDE1:\n" + "\t.long .LEFDE1-.LASFDE1\n" + ".LASFDE1:\n" + "\t.long .Lframe0\n" +#if LJ_64 + "\t.quad lj_vm_ffi_call\n" + "\t.quad %d\n" + "\t.byte 0xe\n\t.uleb128 16\n" /* def_cfa_offset */ + "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ + "\t.byte 0xd\n\t.uleb128 0x6\n" /* def_cfa_register rbp */ + "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ +#else + "\t.long lj_vm_ffi_call\n" + "\t.long %d\n" + "\t.byte 0xe\n\t.uleb128 8\n" /* def_cfa_offset */ + "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ + "\t.byte 0xd\n\t.uleb128 0x5\n" /* def_cfa_register ebp */ + "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset ebx */ +#endif + "\t.align " SZPTR "\n" + ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); +#endif +#if !LJ_NO_UNWIND +#if (defined(__sun__) && defined(__svr4__)) +#if LJ_64 + fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@unwind\n"); +#else + fprintf(ctx->fp, "\t.section .eh_frame,\"aw\",@progbits\n"); +#endif +#else + fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); +#endif + fprintf(ctx->fp, + ".Lframe1:\n" + "\t.long .LECIE1-.LSCIE1\n" + ".LSCIE1:\n" + "\t.long 0\n" + "\t.byte 0x1\n" + "\t.string \"zPR\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -" SZPTR "\n" + "\t.byte " REG_RA "\n" + "\t.uleb128 6\n" /* augmentation length */ + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.long lj_err_unwind_dwarf-.\n" + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" + "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" + "\t.align " SZPTR "\n" + ".LECIE1:\n\n"); + fprintf(ctx->fp, + ".LSFDE2:\n" + "\t.long .LEFDE2-.LASFDE2\n" + ".LASFDE2:\n" + "\t.long .LASFDE2-.Lframe1\n" + "\t.long .Lbegin-.\n" + "\t.long %d\n" + "\t.uleb128 0\n" /* augmentation length */ + "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ +#if LJ_64 + "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ + "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ + "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ + "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ +#else + "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ + "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */ + "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */ + "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */ +#endif + "\t.align " SZPTR "\n" + ".LEFDE2:\n\n", fcofs, CFRAME_SIZE); +#if LJ_HASFFI + fprintf(ctx->fp, + ".Lframe2:\n" + "\t.long .LECIE2-.LSCIE2\n" + ".LSCIE2:\n" + "\t.long 0\n" + "\t.byte 0x1\n" + "\t.string \"zR\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -" SZPTR "\n" + "\t.byte " REG_RA "\n" + "\t.uleb128 1\n" /* augmentation length */ + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" + "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" + "\t.align " SZPTR "\n" + ".LECIE2:\n\n"); + fprintf(ctx->fp, + ".LSFDE3:\n" + "\t.long .LEFDE3-.LASFDE3\n" + ".LASFDE3:\n" + "\t.long .LASFDE3-.Lframe2\n" + "\t.long lj_vm_ffi_call-.\n" + "\t.long %d\n" + "\t.uleb128 0\n" /* augmentation length */ +#if LJ_64 + "\t.byte 0xe\n\t.uleb128 16\n" /* def_cfa_offset */ + "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ + "\t.byte 0xd\n\t.uleb128 0x6\n" /* def_cfa_register rbp */ + "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ +#else + "\t.byte 0xe\n\t.uleb128 8\n" /* def_cfa_offset */ + "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ + "\t.byte 0xd\n\t.uleb128 0x5\n" /* def_cfa_register ebp */ + "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset ebx */ +#endif + "\t.align " SZPTR "\n" + ".LEFDE3:\n\n", (int)ctx->codesz - fcofs); +#endif +#endif + break; +#if !LJ_NO_UNWIND + /* Mental note: never let Apple design an assembler. + ** Or a linker. Or a plastic case. But I digress. + */ + case BUILD_machasm: { +#if LJ_HASFFI + int fcsize = 0; +#endif + int i; + fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); + fprintf(ctx->fp, + "EH_frame1:\n" + "\t.set L$set$x,LECIEX-LSCIEX\n" + "\t.long L$set$x\n" + "LSCIEX:\n" + "\t.long 0\n" + "\t.byte 0x1\n" + "\t.ascii \"zPR\\0\"\n" + "\t.byte 0x1\n" + "\t.byte 128-" SZPTR "\n" + "\t.byte " REG_RA "\n" + "\t.byte 6\n" /* augmentation length */ + "\t.byte 0x9b\n" /* indirect|pcrel|sdata4 */ +#if LJ_64 + "\t.long _lj_err_unwind_dwarf+4@GOTPCREL\n" + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.byte " REG_SP "\n\t.byte " SZPTR "\n" +#else + "\t.long L_lj_err_unwind_dwarf$non_lazy_ptr-.\n" + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH-O. */ +#endif + "\t.byte 0x80+" REG_RA "\n\t.byte 0x1\n" + "\t.align " BSZPTR "\n" + "LECIEX:\n\n"); + for (i = 0; i < ctx->nsym; i++) { + const char *name = ctx->sym[i].name; + int32_t size = ctx->sym[i+1].ofs - ctx->sym[i].ofs; + if (size == 0) continue; +#if LJ_HASFFI + if (!strcmp(name, "_lj_vm_ffi_call")) { fcsize = size; continue; } +#endif + fprintf(ctx->fp, + "%s.eh:\n" + "LSFDE%d:\n" + "\t.set L$set$%d,LEFDE%d-LASFDE%d\n" + "\t.long L$set$%d\n" + "LASFDE%d:\n" + "\t.long LASFDE%d-EH_frame1\n" + "\t.long %s-.\n" + "\t.long %d\n" + "\t.byte 0\n" /* augmentation length */ + "\t.byte 0xe\n\t.byte %d\n" /* def_cfa_offset */ +#if LJ_64 + "\t.byte 0x86\n\t.byte 0x2\n" /* offset rbp */ + "\t.byte 0x83\n\t.byte 0x3\n" /* offset rbx */ + "\t.byte 0x8f\n\t.byte 0x4\n" /* offset r15 */ + "\t.byte 0x8e\n\t.byte 0x5\n" /* offset r14 */ +#else + "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/ + "\t.byte 0x87\n\t.byte 0x3\n" /* offset edi */ + "\t.byte 0x86\n\t.byte 0x4\n" /* offset esi */ + "\t.byte 0x83\n\t.byte 0x5\n" /* offset ebx */ +#endif + "\t.align " BSZPTR "\n" + "LEFDE%d:\n\n", + name, i, i, i, i, i, i, i, name, size, CFRAME_SIZE, i); + } +#if LJ_HASFFI + if (fcsize) { + fprintf(ctx->fp, + "EH_frame2:\n" + "\t.set L$set$y,LECIEY-LSCIEY\n" + "\t.long L$set$y\n" + "LSCIEY:\n" + "\t.long 0\n" + "\t.byte 0x1\n" + "\t.ascii \"zR\\0\"\n" + "\t.byte 0x1\n" + "\t.byte 128-" SZPTR "\n" + "\t.byte " REG_RA "\n" + "\t.byte 1\n" /* augmentation length */ +#if LJ_64 + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.byte " REG_SP "\n\t.byte " SZPTR "\n" +#else + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH. */ +#endif + "\t.byte 0x80+" REG_RA "\n\t.byte 0x1\n" + "\t.align " BSZPTR "\n" + "LECIEY:\n\n"); + fprintf(ctx->fp, + "_lj_vm_ffi_call.eh:\n" + "LSFDEY:\n" + "\t.set L$set$yy,LEFDEY-LASFDEY\n" + "\t.long L$set$yy\n" + "LASFDEY:\n" + "\t.long LASFDEY-EH_frame2\n" + "\t.long _lj_vm_ffi_call-.\n" + "\t.long %d\n" + "\t.byte 0\n" /* augmentation length */ +#if LJ_64 + "\t.byte 0xe\n\t.byte 16\n" /* def_cfa_offset */ + "\t.byte 0x86\n\t.byte 0x2\n" /* offset rbp */ + "\t.byte 0xd\n\t.byte 0x6\n" /* def_cfa_register rbp */ + "\t.byte 0x83\n\t.byte 0x3\n" /* offset rbx */ +#else + "\t.byte 0xe\n\t.byte 8\n" /* def_cfa_offset */ + "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/ + "\t.byte 0xd\n\t.byte 0x4\n" /* def_cfa_register ebp */ + "\t.byte 0x83\n\t.byte 0x3\n" /* offset ebx */ +#endif + "\t.align " BSZPTR "\n" + "LEFDEY:\n\n", fcsize); + } +#endif +#if LJ_64 + fprintf(ctx->fp, "\t.subsections_via_symbols\n"); +#else + fprintf(ctx->fp, + "\t.non_lazy_symbol_pointer\n" + "L_lj_err_unwind_dwarf$non_lazy_ptr:\n" + ".indirect_symbol _lj_err_unwind_dwarf\n" + ".long 0\n"); +#endif + } + break; +#endif + default: /* Difficult for other modes. */ + break; + } +} + + +``` + +`include/luajit-2.0.5/src/xedkbuild.bat`: + +```bat +@rem Script to build LuaJIT with the Xbox 360 SDK. +@rem Donated to the public domain. +@rem +@rem Open a "Visual Studio .NET Command Prompt" (32 bit host compiler) +@rem Then cd to this directory and run this script. + +@if not defined INCLUDE goto :FAIL +@if not defined XEDK goto :FAIL + +@setlocal +@rem ---- Host compiler ---- +@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE +@set LJLINK=link /nologo +@set LJMT=mt /nologo +@set DASMDIR=..\dynasm +@set DASM=%DASMDIR%\dynasm.lua +@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c + +%LJCOMPILE% host\minilua.c +@if errorlevel 1 goto :BAD +%LJLINK% /out:minilua.exe minilua.obj +@if errorlevel 1 goto :BAD +if exist minilua.exe.manifest^ + %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe + +@rem Error out for 64 bit host compiler +@minilua +@if errorlevel 8 goto :FAIL + +@set DASMFLAGS=-D GPR64 -D FRAME32 -D PPE -D SQRT -D DUALNUM +minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_ppc.dasc +@if errorlevel 1 goto :BAD + +%LJCOMPILE% /I "." /I %DASMDIR% /D_XBOX_VER=200 /DLUAJIT_TARGET=LUAJIT_ARCH_PPC host\buildvm*.c +@if errorlevel 1 goto :BAD +%LJLINK% /out:buildvm.exe buildvm*.obj +@if errorlevel 1 goto :BAD +if exist buildvm.exe.manifest^ + %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe + +buildvm -m peobj -o lj_vm.obj +@if errorlevel 1 goto :BAD +buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m libdef -o lj_libdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m recdef -o lj_recdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m folddef -o lj_folddef.h lj_opt_fold.c +@if errorlevel 1 goto :BAD + +@rem ---- Cross compiler ---- +@set LJCOMPILE="%XEDK%\bin\win32\cl" /nologo /c /MT /O2 /W3 /GF /Gm- /GR- /GS- /Gy /openmp- /D_CRT_SECURE_NO_DEPRECATE /DNDEBUG /D_XBOX /D_LIB /DLUAJIT_USE_SYSMALLOC +@set LJLIB="%XEDK%\bin\win32\lib" /nologo +@set "INCLUDE=%XEDK%\include\xbox" + +@if "%1" neq "debug" goto :NODEBUG +@shift +@set "LJCOMPILE=%LJCOMPILE% /Zi" +:NODEBUG +@if "%1"=="amalg" goto :AMALG +%LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c +@if errorlevel 1 goto :BAD +%LJLIB% /OUT:luajit20.lib lj_*.obj lib_*.obj +@if errorlevel 1 goto :BAD +@goto :NOAMALG +:AMALG +%LJCOMPILE% /DLUA_BUILD_AS_DLL ljamalg.c +@if errorlevel 1 goto :BAD +%LJLIB% /OUT:luajit20.lib ljamalg.obj lj_vm.obj +@if errorlevel 1 goto :BAD +:NOAMALG + +@del *.obj *.manifest minilua.exe buildvm.exe +@echo. +@echo === Successfully built LuaJIT for Xbox 360 === + +@goto :END +:BAD +@echo. +@echo ******************************************************* +@echo *** Build FAILED -- Please check the error messages *** +@echo ******************************************************* +@goto :END +:FAIL +@echo To run this script you must open a "Visual Studio .NET Command Prompt" +@echo (32 bit host compiler). The Xbox 360 SDK must be installed, too. +:END + +``` + +`include/sdk/Readme.txt`: + +```txt + +Just include "VirtualizerSDK.h" in your source code. + +The rest of the files are used by VirtualizerSDK.h if required. + + + +``` + +`include/sdk/Via ASM module/Readme.txt`: + +```txt + +1) include "VirtualizerSDKMacros.h" in your source code. + +2) Read "How to add ASM files in your Solution.pdf" + +3) In Visual Studio, in your Solution Explorer, just add the files + "VirtualizerSDKCustomVmMacros.asm" and "VirtualizerSDKMacros.asm" + + + +``` + +`include/sdk/Via ASM module/VirtualizerSDKCustomVMsMacros.h`: + +```h +/****************************************************************************** + Header: VirtualizerSDKCustomVMsMacros.h + Description: Definition of CustomVM macros + + Author/s: Oreans Technologies + (c) 2015 Oreans Technologies + + --- File generated automatically from Oreans VM Generator (16/6/2015) --- +******************************************************************************/ + + +// **************************************************************************** +// Declaration of Custom VM macros +// **************************************************************************** + +#ifdef __cplusplus + extern "C" { +#endif + +#if defined(PLATFORM_X32) + +void __stdcall VIRTUALIZER_TIGER_WHITE_START_ASM32(); +void __stdcall VIRTUALIZER_TIGER_WHITE_END_ASM32(); +void __stdcall VIRTUALIZER_TIGER_RED_START_ASM32(); +void __stdcall VIRTUALIZER_TIGER_RED_END_ASM32(); +void __stdcall VIRTUALIZER_TIGER_BLACK_START_ASM32(); +void __stdcall VIRTUALIZER_TIGER_BLACK_END_ASM32(); +void __stdcall VIRTUALIZER_FISH_WHITE_START_ASM32(); +void __stdcall VIRTUALIZER_FISH_WHITE_END_ASM32(); +void __stdcall VIRTUALIZER_FISH_RED_START_ASM32(); +void __stdcall VIRTUALIZER_FISH_RED_END_ASM32(); +void __stdcall VIRTUALIZER_FISH_BLACK_START_ASM32(); +void __stdcall VIRTUALIZER_FISH_BLACK_END_ASM32(); +void __stdcall VIRTUALIZER_PUMA_WHITE_START_ASM32(); +void __stdcall VIRTUALIZER_PUMA_WHITE_END_ASM32(); +void __stdcall VIRTUALIZER_PUMA_RED_START_ASM32(); +void __stdcall VIRTUALIZER_PUMA_RED_END_ASM32(); +void __stdcall VIRTUALIZER_PUMA_BLACK_START_ASM32(); +void __stdcall VIRTUALIZER_PUMA_BLACK_END_ASM32(); +void __stdcall VIRTUALIZER_SHARK_WHITE_START_ASM32(); +void __stdcall VIRTUALIZER_SHARK_WHITE_END_ASM32(); +void __stdcall VIRTUALIZER_SHARK_RED_START_ASM32(); +void __stdcall VIRTUALIZER_SHARK_RED_END_ASM32(); +void __stdcall VIRTUALIZER_SHARK_BLACK_START_ASM32(); +void __stdcall VIRTUALIZER_SHARK_BLACK_END_ASM32(); +void __stdcall VIRTUALIZER_DOLPHIN_WHITE_START_ASM32(); +void __stdcall VIRTUALIZER_DOLPHIN_WHITE_END_ASM32(); +void __stdcall VIRTUALIZER_DOLPHIN_RED_START_ASM32(); +void __stdcall VIRTUALIZER_DOLPHIN_RED_END_ASM32(); +void __stdcall VIRTUALIZER_DOLPHIN_BLACK_START_ASM32(); +void __stdcall VIRTUALIZER_DOLPHIN_BLACK_END_ASM32(); +void __stdcall VIRTUALIZER_EAGLE_WHITE_START_ASM32(); +void __stdcall VIRTUALIZER_EAGLE_WHITE_END_ASM32(); +void __stdcall VIRTUALIZER_EAGLE_RED_START_ASM32(); +void __stdcall VIRTUALIZER_EAGLE_RED_END_ASM32(); +void __stdcall VIRTUALIZER_EAGLE_BLACK_START_ASM32(); +void __stdcall VIRTUALIZER_EAGLE_BLACK_END_ASM32(); +void __stdcall VIRTUALIZER_MUTATE_ONLY_START_ASM32(); +void __stdcall VIRTUALIZER_MUTATE_ONLY_END_ASM32(); + +#define VIRTUALIZER_TIGER_WHITE_START VIRTUALIZER_TIGER_WHITE_START_ASM32(); +#define VIRTUALIZER_TIGER_WHITE_END VIRTUALIZER_TIGER_WHITE_END_ASM32(); +#define VIRTUALIZER_TIGER_RED_START VIRTUALIZER_TIGER_RED_START_ASM32(); +#define VIRTUALIZER_TIGER_RED_END VIRTUALIZER_TIGER_RED_END_ASM32(); +#define VIRTUALIZER_TIGER_BLACK_START VIRTUALIZER_TIGER_BLACK_START_ASM32(); +#define VIRTUALIZER_TIGER_BLACK_END VIRTUALIZER_TIGER_BLACK_END_ASM32(); +#define VIRTUALIZER_FISH_WHITE_START VIRTUALIZER_FISH_WHITE_START_ASM32(); +#define VIRTUALIZER_FISH_WHITE_END VIRTUALIZER_FISH_WHITE_END_ASM32(); +#define VIRTUALIZER_FISH_RED_START VIRTUALIZER_FISH_RED_START_ASM32(); +#define VIRTUALIZER_FISH_RED_END VIRTUALIZER_FISH_RED_END_ASM32(); +#define VIRTUALIZER_FISH_BLACK_START VIRTUALIZER_FISH_BLACK_START_ASM32(); +#define VIRTUALIZER_FISH_BLACK_END VIRTUALIZER_FISH_BLACK_END_ASM32(); +#define VIRTUALIZER_PUMA_WHITE_START VIRTUALIZER_PUMA_WHITE_START_ASM32(); +#define VIRTUALIZER_PUMA_WHITE_END VIRTUALIZER_PUMA_WHITE_END_ASM32(); +#define VIRTUALIZER_PUMA_RED_START VIRTUALIZER_PUMA_RED_START_ASM32(); +#define VIRTUALIZER_PUMA_RED_END VIRTUALIZER_PUMA_RED_END_ASM32(); +#define VIRTUALIZER_PUMA_BLACK_START VIRTUALIZER_PUMA_BLACK_START_ASM32(); +#define VIRTUALIZER_PUMA_BLACK_END VIRTUALIZER_PUMA_BLACK_END_ASM32(); +#define VIRTUALIZER_SHARK_WHITE_START VIRTUALIZER_SHARK_WHITE_START_ASM32(); +#define VIRTUALIZER_SHARK_WHITE_END VIRTUALIZER_SHARK_WHITE_END_ASM32(); +#define VIRTUALIZER_SHARK_RED_START VIRTUALIZER_SHARK_RED_START_ASM32(); +#define VIRTUALIZER_SHARK_RED_END VIRTUALIZER_SHARK_RED_END_ASM32(); +#define VIRTUALIZER_SHARK_BLACK_START VIRTUALIZER_SHARK_BLACK_START_ASM32(); +#define VIRTUALIZER_SHARK_BLACK_END VIRTUALIZER_SHARK_BLACK_END_ASM32(); +#define VIRTUALIZER_DOLPHIN_WHITE_START VIRTUALIZER_DOLPHIN_WHITE_START_ASM32(); +#define VIRTUALIZER_DOLPHIN_WHITE_END VIRTUALIZER_DOLPHIN_WHITE_END_ASM32(); +#define VIRTUALIZER_DOLPHIN_RED_START VIRTUALIZER_DOLPHIN_RED_START_ASM32(); +#define VIRTUALIZER_DOLPHIN_RED_END VIRTUALIZER_DOLPHIN_RED_END_ASM32(); +#define VIRTUALIZER_DOLPHIN_BLACK_START VIRTUALIZER_DOLPHIN_BLACK_START_ASM32(); +#define VIRTUALIZER_DOLPHIN_BLACK_END VIRTUALIZER_DOLPHIN_BLACK_END_ASM32(); +#define VIRTUALIZER_EAGLE_WHITE_START VIRTUALIZER_EAGLE_WHITE_START_ASM32(); +#define VIRTUALIZER_EAGLE_WHITE_END VIRTUALIZER_EAGLE_WHITE_END_ASM32(); +#define VIRTUALIZER_EAGLE_RED_START VIRTUALIZER_EAGLE_RED_START_ASM32(); +#define VIRTUALIZER_EAGLE_RED_END VIRTUALIZER_EAGLE_RED_END_ASM32(); +#define VIRTUALIZER_EAGLE_BLACK_START VIRTUALIZER_EAGLE_BLACK_START_ASM32(); +#define VIRTUALIZER_EAGLE_BLACK_END VIRTUALIZER_EAGLE_BLACK_END_ASM32(); +#define VIRTUALIZER_MUTATE_ONLY_START VIRTUALIZER_MUTATE_ONLY_START_ASM32(); +#define VIRTUALIZER_MUTATE_ONLY_END VIRTUALIZER_MUTATE_ONLY_END_ASM32(); + +#endif + +#if defined(PLATFORM_X64) + +void __stdcall VIRTUALIZER_TIGER_WHITE_START_ASM64(); +void __stdcall VIRTUALIZER_TIGER_WHITE_END_ASM64(); +void __stdcall VIRTUALIZER_TIGER_RED_START_ASM64(); +void __stdcall VIRTUALIZER_TIGER_RED_END_ASM64(); +void __stdcall VIRTUALIZER_TIGER_BLACK_START_ASM64(); +void __stdcall VIRTUALIZER_TIGER_BLACK_END_ASM64(); +void __stdcall VIRTUALIZER_FISH_WHITE_START_ASM64(); +void __stdcall VIRTUALIZER_FISH_WHITE_END_ASM64(); +void __stdcall VIRTUALIZER_FISH_RED_START_ASM64(); +void __stdcall VIRTUALIZER_FISH_RED_END_ASM64(); +void __stdcall VIRTUALIZER_FISH_BLACK_START_ASM64(); +void __stdcall VIRTUALIZER_FISH_BLACK_END_ASM64(); +void __stdcall VIRTUALIZER_PUMA_WHITE_START_ASM64(); +void __stdcall VIRTUALIZER_PUMA_WHITE_END_ASM64(); +void __stdcall VIRTUALIZER_PUMA_RED_START_ASM64(); +void __stdcall VIRTUALIZER_PUMA_RED_END_ASM64(); +void __stdcall VIRTUALIZER_PUMA_BLACK_START_ASM64(); +void __stdcall VIRTUALIZER_PUMA_BLACK_END_ASM64(); +void __stdcall VIRTUALIZER_SHARK_WHITE_START_ASM64(); +void __stdcall VIRTUALIZER_SHARK_WHITE_END_ASM64(); +void __stdcall VIRTUALIZER_SHARK_RED_START_ASM64(); +void __stdcall VIRTUALIZER_SHARK_RED_END_ASM64(); +void __stdcall VIRTUALIZER_SHARK_BLACK_START_ASM64(); +void __stdcall VIRTUALIZER_SHARK_BLACK_END_ASM64(); +void __stdcall VIRTUALIZER_DOLPHIN_WHITE_START_ASM64(); +void __stdcall VIRTUALIZER_DOLPHIN_WHITE_END_ASM64(); +void __stdcall VIRTUALIZER_DOLPHIN_RED_START_ASM64(); +void __stdcall VIRTUALIZER_DOLPHIN_RED_END_ASM64(); +void __stdcall VIRTUALIZER_DOLPHIN_BLACK_START_ASM64(); +void __stdcall VIRTUALIZER_DOLPHIN_BLACK_END_ASM64(); +void __stdcall VIRTUALIZER_EAGLE_WHITE_START_ASM64(); +void __stdcall VIRTUALIZER_EAGLE_WHITE_END_ASM64(); +void __stdcall VIRTUALIZER_EAGLE_RED_START_ASM64(); +void __stdcall VIRTUALIZER_EAGLE_RED_END_ASM64(); +void __stdcall VIRTUALIZER_EAGLE_BLACK_START_ASM64(); +void __stdcall VIRTUALIZER_EAGLE_BLACK_END_ASM64(); +void __stdcall VIRTUALIZER_MUTATE_ONLY_START_ASM64(); +void __stdcall VIRTUALIZER_MUTATE_ONLY_END_ASM64(); + +#define VIRTUALIZER_TIGER_WHITE_START VIRTUALIZER_TIGER_WHITE_START_ASM64(); +#define VIRTUALIZER_TIGER_WHITE_END VIRTUALIZER_TIGER_WHITE_END_ASM64(); +#define VIRTUALIZER_TIGER_RED_START VIRTUALIZER_TIGER_RED_START_ASM64(); +#define VIRTUALIZER_TIGER_RED_END VIRTUALIZER_TIGER_RED_END_ASM64(); +#define VIRTUALIZER_TIGER_BLACK_START VIRTUALIZER_TIGER_BLACK_START_ASM64(); +#define VIRTUALIZER_TIGER_BLACK_END VIRTUALIZER_TIGER_BLACK_END_ASM64(); +#define VIRTUALIZER_FISH_WHITE_START VIRTUALIZER_FISH_WHITE_START_ASM64(); +#define VIRTUALIZER_FISH_WHITE_END VIRTUALIZER_FISH_WHITE_END_ASM64(); +#define VIRTUALIZER_FISH_RED_START VIRTUALIZER_FISH_RED_START_ASM64(); +#define VIRTUALIZER_FISH_RED_END VIRTUALIZER_FISH_RED_END_ASM64(); +#define VIRTUALIZER_FISH_BLACK_START VIRTUALIZER_FISH_BLACK_START_ASM64(); +#define VIRTUALIZER_FISH_BLACK_END VIRTUALIZER_FISH_BLACK_END_ASM64(); +#define VIRTUALIZER_PUMA_WHITE_START VIRTUALIZER_PUMA_WHITE_START_ASM64(); +#define VIRTUALIZER_PUMA_WHITE_END VIRTUALIZER_PUMA_WHITE_END_ASM64(); +#define VIRTUALIZER_PUMA_RED_START VIRTUALIZER_PUMA_RED_START_ASM64(); +#define VIRTUALIZER_PUMA_RED_END VIRTUALIZER_PUMA_RED_END_ASM64(); +#define VIRTUALIZER_PUMA_BLACK_START VIRTUALIZER_PUMA_BLACK_START_ASM64(); +#define VIRTUALIZER_PUMA_BLACK_END VIRTUALIZER_PUMA_BLACK_END_ASM64(); +#define VIRTUALIZER_SHARK_WHITE_START VIRTUALIZER_SHARK_WHITE_START_ASM64(); +#define VIRTUALIZER_SHARK_WHITE_END VIRTUALIZER_SHARK_WHITE_END_ASM64(); +#define VIRTUALIZER_SHARK_RED_START VIRTUALIZER_SHARK_RED_START_ASM64(); +#define VIRTUALIZER_SHARK_RED_END VIRTUALIZER_SHARK_RED_END_ASM64(); +#define VIRTUALIZER_SHARK_BLACK_START VIRTUALIZER_SHARK_BLACK_START_ASM64(); +#define VIRTUALIZER_SHARK_BLACK_END VIRTUALIZER_SHARK_BLACK_END_ASM64(); +#define VIRTUALIZER_DOLPHIN_WHITE_START VIRTUALIZER_DOLPHIN_WHITE_START_ASM64(); +#define VIRTUALIZER_DOLPHIN_WHITE_END VIRTUALIZER_DOLPHIN_WHITE_END_ASM64(); +#define VIRTUALIZER_DOLPHIN_RED_START VIRTUALIZER_DOLPHIN_RED_START_ASM64(); +#define VIRTUALIZER_DOLPHIN_RED_END VIRTUALIZER_DOLPHIN_RED_END_ASM64(); +#define VIRTUALIZER_DOLPHIN_BLACK_START VIRTUALIZER_DOLPHIN_BLACK_START_ASM64(); +#define VIRTUALIZER_DOLPHIN_BLACK_END VIRTUALIZER_DOLPHIN_BLACK_END_ASM64(); +#define VIRTUALIZER_EAGLE_WHITE_START VIRTUALIZER_EAGLE_WHITE_START_ASM64(); +#define VIRTUALIZER_EAGLE_WHITE_END VIRTUALIZER_EAGLE_WHITE_END_ASM64(); +#define VIRTUALIZER_EAGLE_RED_START VIRTUALIZER_EAGLE_RED_START_ASM64(); +#define VIRTUALIZER_EAGLE_RED_END VIRTUALIZER_EAGLE_RED_END_ASM64(); +#define VIRTUALIZER_EAGLE_BLACK_START VIRTUALIZER_EAGLE_BLACK_START_ASM64(); +#define VIRTUALIZER_EAGLE_BLACK_END VIRTUALIZER_EAGLE_BLACK_END_ASM64(); +#define VIRTUALIZER_MUTATE_ONLY_START VIRTUALIZER_MUTATE_ONLY_START_ASM64(); +#define VIRTUALIZER_MUTATE_ONLY_END VIRTUALIZER_MUTATE_ONLY_END_ASM64(); + +#endif + +#ifdef __cplusplus +} +#endif + + +``` + +`include/sdk/Via ASM module/VirtualizerSDKCustomVmMacros.asm`: + +```asm +; **************************************************************************** +; Module: VirtualizerSDKCustomVmMacros.asm +; Description: Another way to link with the SecureEngine SDK via an ASM module +; +; Author/s: Oreans Technologies +; (c) 2015 Oreans Technologies +; +; --- File generated automatically from Oreans VM Generator (16/6/2015) --- +; **************************************************************************** + + +IFDEF RAX + +ELSE + +.586 +.model flat,stdcall +option casemap:none + +ENDIF + + +; **************************************************************************** +; Constants +; **************************************************************************** + +.CONST + + +; **************************************************************************** +; Data Segment +; **************************************************************************** + +.DATA + + +; **************************************************************************** +; Code Segment +; **************************************************************************** + +.CODE + +IFDEF RAX + +; **************************************************************************** +; VIRTUALIZER_TIGER_WHITE definition +; **************************************************************************** + +VIRTUALIZER_TIGER_WHITE_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 103 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_TIGER_WHITE_START_ASM64 ENDP + +VIRTUALIZER_TIGER_WHITE_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 503 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_TIGER_WHITE_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_TIGER_RED definition +; **************************************************************************** + +VIRTUALIZER_TIGER_RED_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 104 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_TIGER_RED_START_ASM64 ENDP + +VIRTUALIZER_TIGER_RED_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 504 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_TIGER_RED_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_TIGER_BLACK definition +; **************************************************************************** + +VIRTUALIZER_TIGER_BLACK_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 105 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_TIGER_BLACK_START_ASM64 ENDP + +VIRTUALIZER_TIGER_BLACK_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 505 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_TIGER_BLACK_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_FISH_WHITE definition +; **************************************************************************** + +VIRTUALIZER_FISH_WHITE_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 107 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_FISH_WHITE_START_ASM64 ENDP + +VIRTUALIZER_FISH_WHITE_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 507 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_FISH_WHITE_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_FISH_RED definition +; **************************************************************************** + +VIRTUALIZER_FISH_RED_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 109 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_FISH_RED_START_ASM64 ENDP + +VIRTUALIZER_FISH_RED_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 509 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_FISH_RED_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_FISH_BLACK definition +; **************************************************************************** + +VIRTUALIZER_FISH_BLACK_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 111 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_FISH_BLACK_START_ASM64 ENDP + +VIRTUALIZER_FISH_BLACK_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 511 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_FISH_BLACK_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_PUMA_WHITE definition +; **************************************************************************** + +VIRTUALIZER_PUMA_WHITE_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 113 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_PUMA_WHITE_START_ASM64 ENDP + +VIRTUALIZER_PUMA_WHITE_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 513 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_PUMA_WHITE_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_PUMA_RED definition +; **************************************************************************** + +VIRTUALIZER_PUMA_RED_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 115 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_PUMA_RED_START_ASM64 ENDP + +VIRTUALIZER_PUMA_RED_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 515 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_PUMA_RED_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_PUMA_BLACK definition +; **************************************************************************** + +VIRTUALIZER_PUMA_BLACK_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 117 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_PUMA_BLACK_START_ASM64 ENDP + +VIRTUALIZER_PUMA_BLACK_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 517 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_PUMA_BLACK_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_SHARK_WHITE definition +; **************************************************************************** + +VIRTUALIZER_SHARK_WHITE_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 119 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_SHARK_WHITE_START_ASM64 ENDP + +VIRTUALIZER_SHARK_WHITE_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 519 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_SHARK_WHITE_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_SHARK_RED definition +; **************************************************************************** + +VIRTUALIZER_SHARK_RED_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 121 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_SHARK_RED_START_ASM64 ENDP + +VIRTUALIZER_SHARK_RED_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 521 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_SHARK_RED_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_SHARK_BLACK definition +; **************************************************************************** + +VIRTUALIZER_SHARK_BLACK_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 123 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_SHARK_BLACK_START_ASM64 ENDP + +VIRTUALIZER_SHARK_BLACK_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 523 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_SHARK_BLACK_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_DOLPHIN_WHITE definition +; **************************************************************************** + +VIRTUALIZER_DOLPHIN_WHITE_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 135 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_DOLPHIN_WHITE_START_ASM64 ENDP + +VIRTUALIZER_DOLPHIN_WHITE_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 535 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_DOLPHIN_WHITE_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_DOLPHIN_RED definition +; **************************************************************************** + +VIRTUALIZER_DOLPHIN_RED_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 137 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_DOLPHIN_RED_START_ASM64 ENDP + +VIRTUALIZER_DOLPHIN_RED_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 537 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_DOLPHIN_RED_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_DOLPHIN_BLACK definition +; **************************************************************************** + +VIRTUALIZER_DOLPHIN_BLACK_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 139 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_DOLPHIN_BLACK_START_ASM64 ENDP + +VIRTUALIZER_DOLPHIN_BLACK_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 539 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_DOLPHIN_BLACK_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_EAGLE_WHITE definition +; **************************************************************************** + +VIRTUALIZER_EAGLE_WHITE_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 147 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_EAGLE_WHITE_START_ASM64 ENDP + +VIRTUALIZER_EAGLE_WHITE_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 547 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_EAGLE_WHITE_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_EAGLE_RED definition +; **************************************************************************** + +VIRTUALIZER_EAGLE_RED_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 149 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_EAGLE_RED_START_ASM64 ENDP + +VIRTUALIZER_EAGLE_RED_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 549 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_EAGLE_RED_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_EAGLE_BLACK definition +; **************************************************************************** + +VIRTUALIZER_EAGLE_BLACK_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 151 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_EAGLE_BLACK_START_ASM64 ENDP + +VIRTUALIZER_EAGLE_BLACK_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 551 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_EAGLE_BLACK_END_ASM64 ENDP + + +; **************************************************************************** +; VIRTUALIZER_MUTATE_ONLY definition +; **************************************************************************** + +VIRTUALIZER_MUTATE_ONLY_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 16 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_MUTATE_ONLY_START_ASM64 ENDP + +VIRTUALIZER_MUTATE_ONLY_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 17 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_MUTATE_ONLY_END_ASM64 ENDP + +ELSE + +; **************************************************************************** +; VIRTUALIZER_TIGER_WHITE definition +; **************************************************************************** + +VIRTUALIZER_TIGER_WHITE_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 100 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_TIGER_WHITE_START_ASM32 ENDP + +VIRTUALIZER_TIGER_WHITE_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 500 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_TIGER_WHITE_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_TIGER_RED definition +; **************************************************************************** + +VIRTUALIZER_TIGER_RED_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 101 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_TIGER_RED_START_ASM32 ENDP + +VIRTUALIZER_TIGER_RED_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 501 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_TIGER_RED_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_TIGER_BLACK definition +; **************************************************************************** + +VIRTUALIZER_TIGER_BLACK_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 102 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_TIGER_BLACK_START_ASM32 ENDP + +VIRTUALIZER_TIGER_BLACK_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 502 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_TIGER_BLACK_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_FISH_WHITE definition +; **************************************************************************** + +VIRTUALIZER_FISH_WHITE_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 106 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_FISH_WHITE_START_ASM32 ENDP + +VIRTUALIZER_FISH_WHITE_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 506 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_FISH_WHITE_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_FISH_RED definition +; **************************************************************************** + +VIRTUALIZER_FISH_RED_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 108 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_FISH_RED_START_ASM32 ENDP + +VIRTUALIZER_FISH_RED_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 508 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_FISH_RED_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_FISH_BLACK definition +; **************************************************************************** + +VIRTUALIZER_FISH_BLACK_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 110 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_FISH_BLACK_START_ASM32 ENDP + +VIRTUALIZER_FISH_BLACK_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 510 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_FISH_BLACK_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_PUMA_WHITE definition +; **************************************************************************** + +VIRTUALIZER_PUMA_WHITE_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 112 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_PUMA_WHITE_START_ASM32 ENDP + +VIRTUALIZER_PUMA_WHITE_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 512 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_PUMA_WHITE_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_PUMA_RED definition +; **************************************************************************** + +VIRTUALIZER_PUMA_RED_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 114 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_PUMA_RED_START_ASM32 ENDP + +VIRTUALIZER_PUMA_RED_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 514 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_PUMA_RED_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_PUMA_BLACK definition +; **************************************************************************** + +VIRTUALIZER_PUMA_BLACK_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 116 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_PUMA_BLACK_START_ASM32 ENDP + +VIRTUALIZER_PUMA_BLACK_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 516 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_PUMA_BLACK_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_SHARK_WHITE definition +; **************************************************************************** + +VIRTUALIZER_SHARK_WHITE_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 118 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_SHARK_WHITE_START_ASM32 ENDP + +VIRTUALIZER_SHARK_WHITE_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 518 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_SHARK_WHITE_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_SHARK_RED definition +; **************************************************************************** + +VIRTUALIZER_SHARK_RED_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 120 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_SHARK_RED_START_ASM32 ENDP + +VIRTUALIZER_SHARK_RED_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 520 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_SHARK_RED_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_SHARK_BLACK definition +; **************************************************************************** + +VIRTUALIZER_SHARK_BLACK_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 122 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_SHARK_BLACK_START_ASM32 ENDP + +VIRTUALIZER_SHARK_BLACK_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 522 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_SHARK_BLACK_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_DOLPHIN_WHITE definition +; **************************************************************************** + +VIRTUALIZER_DOLPHIN_WHITE_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 134 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_DOLPHIN_WHITE_START_ASM32 ENDP + +VIRTUALIZER_DOLPHIN_WHITE_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 534 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_DOLPHIN_WHITE_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_DOLPHIN_RED definition +; **************************************************************************** + +VIRTUALIZER_DOLPHIN_RED_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 136 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_DOLPHIN_RED_START_ASM32 ENDP + +VIRTUALIZER_DOLPHIN_RED_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 536 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_DOLPHIN_RED_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_DOLPHIN_BLACK definition +; **************************************************************************** + +VIRTUALIZER_DOLPHIN_BLACK_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 138 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_DOLPHIN_BLACK_START_ASM32 ENDP + +VIRTUALIZER_DOLPHIN_BLACK_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 538 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_DOLPHIN_BLACK_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_EAGLE_WHITE definition +; **************************************************************************** + +VIRTUALIZER_EAGLE_WHITE_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 146 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_EAGLE_WHITE_START_ASM32 ENDP + +VIRTUALIZER_EAGLE_WHITE_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 546 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_EAGLE_WHITE_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_EAGLE_RED definition +; **************************************************************************** + +VIRTUALIZER_EAGLE_RED_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 148 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_EAGLE_RED_START_ASM32 ENDP + +VIRTUALIZER_EAGLE_RED_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 548 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_EAGLE_RED_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_EAGLE_BLACK definition +; **************************************************************************** + +VIRTUALIZER_EAGLE_BLACK_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 150 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_EAGLE_BLACK_START_ASM32 ENDP + +VIRTUALIZER_EAGLE_BLACK_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 550 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_EAGLE_BLACK_END_ASM32 ENDP + + +; **************************************************************************** +; VIRTUALIZER_MUTATE_ONLY definition +; **************************************************************************** + +VIRTUALIZER_MUTATE_ONLY_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 16 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_MUTATE_ONLY_START_ASM32 ENDP + +VIRTUALIZER_MUTATE_ONLY_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 17 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_MUTATE_ONLY_END_ASM32 ENDP + +ENDIF + +END + +``` + +`include/sdk/Via ASM module/VirtualizerSDKMacros.asm`: + +```asm +; **************************************************************************** +; Module: VirtualizerSDKBasicVmMacros.asm +; Description: Another way to link with the SecureEngine SDK via an ASM module +; +; Author/s: Oreans Technologies +; (c) 2019 Oreans Technologies +; **************************************************************************** + +IFDEF RAX + +ELSE + +.586 +.model flat,stdcall +option casemap:none + +ENDIF + + +; **************************************************************************** +; Constants +; **************************************************************************** + +.CONST + + +; **************************************************************************** +; Data Segment +; **************************************************************************** + +.DATA + + +; **************************************************************************** +; Code Segment +; **************************************************************************** + +.CODE + +IFDEF RAX + +; **************************************************************************** +; VIRTUALIZER definition +; **************************************************************************** + +VIRTUALIZER_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 1 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_START_ASM64 ENDP + +VIRTUALIZER_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 2 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_END_ASM64 ENDP + +; **************************************************************************** +; STR_ENCRYPT definition +; **************************************************************************** + +VIRTUALIZER_STR_ENCRYPT_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 23 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_STR_ENCRYPT_START_ASM64 ENDP + +VIRTUALIZER_STR_ENCRYPT_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 24 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_STR_ENCRYPT_END_ASM64 ENDP + +; **************************************************************************** +; STR_ENCRYPTW definition +; **************************************************************************** + +VIRTUALIZER_STR_ENCRYPTW_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 27 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_STR_ENCRYPTW_START_ASM64 ENDP + +VIRTUALIZER_STR_ENCRYPTW_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 28 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_STR_ENCRYPTW_END_ASM64 ENDP + +; **************************************************************************** +; VIRTUALIZER_UNPROTECTED definition +; **************************************************************************** + +VIRTUALIZER_UNPROTECTED_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 18 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_UNPROTECTED_START_ASM64 ENDP + +VIRTUALIZER_UNPROTECTED_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 19 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_UNPROTECTED_END_ASM64 ENDP + +ELSE + +; **************************************************************************** +; VIRTUALIZER definition +; **************************************************************************** + +VIRTUALIZER_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 1 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_START_ASM32 ENDP + +VIRTUALIZER_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 2 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_END_ASM32 ENDP + +; **************************************************************************** +; VIRTUALIZER_STR_ENCRYPT definition +; **************************************************************************** + +VIRTUALIZER_STR_ENCRYPT_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 23 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_STR_ENCRYPT_START_ASM32 ENDP + +VIRTUALIZER_STR_ENCRYPT_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 24 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_STR_ENCRYPT_END_ASM32 ENDP + +; **************************************************************************** +; VIRTUALIZER_STR_ENCRYPTW definition +; **************************************************************************** + +VIRTUALIZER_STR_ENCRYPTW_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 27 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_STR_ENCRYPTW_START_ASM32 ENDP + +VIRTUALIZER_STR_ENCRYPTW_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 28 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_STR_ENCRYPTW_END_ASM32 ENDP + +; **************************************************************************** +; VIRTUALIZER_UNPROTECTED definition +; **************************************************************************** + +VIRTUALIZER_UNPROTECTED_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 18 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_UNPROTECTED_START_ASM32 ENDP + +VIRTUALIZER_UNPROTECTED_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 19 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_UNPROTECTED_END_ASM32 ENDP + +ENDIF + +END + +``` + +`include/sdk/Via ASM module/VirtualizerSDKMacros.h`: + +```h +/****************************************************************************** + Header: VirtualizerMacros.h + Description: Definition of SecureEngine macros via ASM module + + Author/s: Oreans Technologies + (c) 2013 Oreans Technologies +*****************************************************************************/ + +#pragma once + + +// *********************************************** +// Specify platform +// *********************************************** + +#ifdef _WIN64 +#define PLATFORM_X64 +#else +#define PLATFORM_X32 +#endif + + +// *********************************************** +// Include files +// *********************************************** + +#include "VirtualizerSDKCustomVMsMacros.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(PLATFORM_X32) + +void __stdcall VIRTUALIZER_START_ASM32(); +void __stdcall VIRTUALIZER_END_ASM32(); +void __stdcall VIRTUALIZER_STR_ENCRYPT_START_ASM32(); +void __stdcall VIRTUALIZER_STR_ENCRYPT_END_ASM32(); +void __stdcall VIRTUALIZER_STR_ENCRYPTW_START_ASM32(); +void __stdcall VIRTUALIZER_STR_ENCRYPTW_END_ASM32(); +void __stdcall VIRTUALIZER_UNPROTECTED_START_ASM32(); +void __stdcall VIRTUALIZER_UNPROTECTED_END_ASM32(); + +#define VIRTUALIZER_START VIRTUALIZER_START_ASM32(); +#define VIRTUALIZER_END VIRTUALIZER_END_ASM32(); +#define VIRTUALIZER_STR_ENCRYPT_START VIRTUALIZER_STR_ENCRYPT_START_ASM32(); +#define VIRTUALIZER_STR_ENCRYPT_END VIRTUALIZER_STR_ENCRYPT_END_ASM32(); +#define VIRTUALIZER_STR_ENCRYPTW_START VIRTUALIZER_STR_ENCRYPTW_START_ASM32(); +#define VIRTUALIZER_STR_ENCRYPTW_END VIRTUALIZER_STR_ENCRYPTW_END_ASM32(); +#define VIRTUALIZER_UNPROTECTED_START VIRTUALIZER_UNPROTECTED_START_ASM32(); +#define VIRTUALIZER_UNPROTECTED_END VIRTUALIZER_UNPROTECTED_END_ASM32(); + +#endif + +#if defined(PLATFORM_X64) + +void __stdcall VIRTUALIZER_START_ASM64(); +void __stdcall VIRTUALIZER_END_ASM64(); +void __stdcall VIRTUALIZER_STR_ENCRYPT_START_ASM64(); +void __stdcall VIRTUALIZER_STR_ENCRYPT_END_ASM64(); +void __stdcall VIRTUALIZER_STR_ENCRYPTW_START_ASM64(); +void __stdcall VIRTUALIZER_STR_ENCRYPTW_END_ASM64(); +void __stdcall VIRTUALIZER_UNPROTECTED_START_ASM64(); +void __stdcall VIRTUALIZER_UNPROTECTED_END_ASM64(); + +#define VIRTUALIZER_START VIRTUALIZER_START_ASM64(); +#define VIRTUALIZER_END VIRTUALIZER_END_ASM64(); +#define VIRTUALIZER_STR_ENCRYPT_START VIRTUALIZER_STR_ENCRYPT_START_ASM64(); +#define VIRTUALIZER_STR_ENCRYPT_END VIRTUALIZER_STR_ENCRYPT_END_ASM64(); +#define VIRTUALIZER_STR_ENCRYPTW_START VIRTUALIZER_STR_ENCRYPTW_START_ASM64(); +#define VIRTUALIZER_STR_ENCRYPTW_END VIRTUALIZER_STR_ENCRYPTW_END_ASM64(); +#define VIRTUALIZER_UNPROTECTED_START VIRTUALIZER_UNPROTECTED_START_ASM64(); +#define VIRTUALIZER_UNPROTECTED_END VIRTUALIZER_UNPROTECTED_END_ASM64(); + +#endif + +#ifdef __cplusplus +} +#endif +``` + +`include/sdk/Via ASM module/VirtualizerSDK_FISH_LITE.asm`: + +```asm +; **************************************************************************** +; Module: VirtualizerSDK_FISH_LITE.asm +; Description: Another way to link with the SecureEngine SDK via an ASM module +; +; Author/s: Oreans Technologies +; (c) 2014 Oreans Technologies +; +; --- File generated automatically from Oreans VM Generator (2/4/2014) --- +; **************************************************************************** + + +IFDEF RAX + +ELSE + +.586 +.model flat,stdcall +option casemap:none + +ENDIF + + +; **************************************************************************** +; Constants +; **************************************************************************** + +.CONST + + +; **************************************************************************** +; Data Segment +; **************************************************************************** + +.DATA + + +; **************************************************************************** +; Code Segment +; **************************************************************************** + +.CODE + +IFDEF RAX + +; **************************************************************************** +; VIRTUALIZER_FISH_LITE definition +; **************************************************************************** + +VIRTUALIZER_FISH_LITE_START_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 129 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_FISH_LITE_START_ASM64 ENDP + +VIRTUALIZER_FISH_LITE_END_ASM64 PROC + + push rax + push rbx + push rcx + + mov eax, 'CV' + mov ebx, 529 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop rcx + pop rbx + pop rax + ret + +VIRTUALIZER_FISH_LITE_END_ASM64 ENDP + +ELSE + +; **************************************************************************** +; VIRTUALIZER_FISH_LITE definition +; **************************************************************************** + +VIRTUALIZER_FISH_LITE_START_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 128 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_FISH_LITE_START_ASM32 ENDP + +VIRTUALIZER_FISH_LITE_END_ASM32 PROC + + push eax + push ebx + push ecx + + mov eax, 'CV' + mov ebx, 528 + mov ecx, 'CV' + add ebx, eax + add ecx, eax + + pop ecx + pop ebx + pop eax + ret + +VIRTUALIZER_FISH_LITE_END_ASM32 ENDP + +ENDIF + +END + +``` + +`include/sdk/Via ASM module/VirtualizerSDK_FISH_LITE.h`: + +```h +/****************************************************************************** + Header: VirtualizerSDK_FISH_LITE.h + Description: Definition of CustomVM macros + + Author/s: Oreans Technologies + (c) 2014 Oreans Technologies + + --- File generated automatically from Oreans VM Generator (2/4/2014) --- +******************************************************************************/ + + +// **************************************************************************** +// Declaration of Custom VM macros +// **************************************************************************** + +#ifdef __cplusplus + extern "C" { +#endif + +#if defined(PLATFORM_X32) + +void __stdcall VIRTUALIZER_FISH_LITE_START_ASM32(); +void __stdcall VIRTUALIZER_FISH_LITE_END_ASM32(); + +#define VIRTUALIZER_FISH_LITE_START VIRTUALIZER_FISH_LITE_START_ASM32(); +#define VIRTUALIZER_FISH_LITE_END VIRTUALIZER_FISH_LITE_END_ASM32(); + +#endif + +#if defined(PLATFORM_X64) + +void __stdcall VIRTUALIZER_FISH_LITE_START_ASM64(); +void __stdcall VIRTUALIZER_FISH_LITE_END_ASM64(); + +#define VIRTUALIZER_FISH_LITE_START VIRTUALIZER_FISH_LITE_START_ASM64(); +#define VIRTUALIZER_FISH_LITE_END VIRTUALIZER_FISH_LITE_END_ASM64(); + +#endif + +#ifdef __cplusplus +} +#endif + + +``` + +`include/sdk/VirtualizerSDK.h`: + +```h +/****************************************************************************** + Header: VirtualizerSDK.h + Description: SDK header definition for the C/C++ language + + Author/s: Oreans Technologies + (c) 2011 Oreans Technologies +*****************************************************************************/ + +#pragma once + + +// *********************************************** +// Cross Compiler definitions +// *********************************************** + +#ifdef __GNUC__ + #define DLL_IMPORT extern + #define STDCALL_CONVENTION +#else + #define DLL_IMPORT __declspec(dllimport) + #define STDCALL_CONVENTION __stdcall +#endif + + +// *********************************************** +// Specify platform +// *********************************************** + +#ifdef __GNUC__ + + #ifdef __x86_64__ + #define PLATFORM_X64 + #else + #define PLATFORM_X32 + #endif + +#else + + #ifdef _WIN64 + #define PLATFORM_X64 + #else + #define PLATFORM_X32 + #endif + +#endif + + +// *********************************************** +// Defines +// *********************************************** + +#if defined(__GNUC__) || defined (__ICL) + +#define CV_X32_INSERT_VIA_INLINE +#define CV_X64_INSERT_VIA_INLINE + +#else + +#define CV_X32_INSERT_VIA_INLINE +//#define CV_X64_INSERT_VIA_INLINE + +#endif + + +// *********************************************** +// Include files +// *********************************************** + +#include "VirtualizerSDK_CustomVMs.h" + + +// *********************************************** +// link with correct platform library +// *********************************************** + +#ifndef CV_X64_INSERT_VIA_INLINE + #ifdef PLATFORM_X64 + #ifdef _NTDDK_ + #pragma comment(lib, "VirtualizerDDK.lib") + #else + #pragma comment(lib, "VirtualizerSDK64.lib") + #endif + #endif +#endif + +#ifndef CV_X32_INSERT_VIA_INLINE + #ifdef PLATFORM_X32 + #ifdef _NTDDK_ + #pragma comment(lib, "VirtualizerDDK.lib") + #else + #pragma comment(lib, "VirtualizerSDK32.lib") + #endif + #endif +#endif + + +// *********************************************** +// In latest CV versions, we have removed the +// VirtualizerXStart and VirtualizerMutate macros +// *********************************************** + +#define Virtualizer1Start VirtualizerStart +#define Virtualizer2Start VirtualizerStart +#define Virtualizer3Start VirtualizerStart +#define Virtualizer4Start VirtualizerStart +#define Virtualizer5Start VirtualizerStart +#define Virtualizer1End VirtualizerEnd +#define Virtualizer2End VirtualizerEnd +#define Virtualizer3End VirtualizerEnd +#define Virtualizer4End VirtualizerEnd +#define Virtualizer5End VirtualizerEnd +#define VirtualizerMutate1Start VirtualizerStart +#define VirtualizerMutate2Start VirtualizerStart +#define VirtualizerMutate3Start VirtualizerStart + +#define VIRTUALIZER1_START VIRTUALIZER_START +#define VIRTUALIZER2_START VIRTUALIZER_START +#define VIRTUALIZER3_START VIRTUALIZER_START +#define VIRTUALIZER4_START VIRTUALIZER_START +#define VIRTUALIZER5_START VIRTUALIZER_START +#define VIRTUALIZER1_END VIRTUALIZER_END +#define VIRTUALIZER2_END VIRTUALIZER_END +#define VIRTUALIZER3_END VIRTUALIZER_END +#define VIRTUALIZER4_END VIRTUALIZER_END +#define VIRTUALIZER5_END VIRTUALIZER_END +#define VIRTUALIZER_MUTATE1_START VIRTUALIZER_START +#define VIRTUALIZER_MUTATE2_START VIRTUALIZER_START +#define VIRTUALIZER_MUTATE3_START VIRTUALIZER_START + + +// *********************************************** +// Definition of VirtualizerStart macro to keep +// compatibility with previous CV versions +// *********************************************** + + #ifdef __cplusplus + extern "C" { + #endif + + DLL_IMPORT void STDCALL_CONVENTION VirtualizerStart(void); + DLL_IMPORT void STDCALL_CONVENTION VirtualizerEnd(void); + + DLL_IMPORT void STDCALL_CONVENTION VirtualizerStrEncryptStart(void); + DLL_IMPORT void STDCALL_CONVENTION VirtualizerStrEncryptEnd(void); + + DLL_IMPORT void STDCALL_CONVENTION VirtualizerStrEncryptWStart(void); + DLL_IMPORT void STDCALL_CONVENTION VirtualizerStrEncryptWEnd(void); + + DLL_IMPORT void STDCALL_CONVENTION VirtualizerUnprotectedStart(void); + DLL_IMPORT void STDCALL_CONVENTION VirtualizerUnprotectedEnd(void); + + #ifdef __cplusplus + } + #endif + +#if defined(PLATFORM_X64) && !defined(CV_X64_INSERT_VIA_INLINE) + + #define VIRTUALIZER_START VirtualizerStart(); + #define VIRTUALIZER_END VirtualizerEnd(); + + #define VIRTUALIZER_STR_ENCRYPT_START VirtualizerStrEncryptStart(); + #define VIRTUALIZER_STR_ENCRYPT_END VirtualizerStrEncryptEnd(); + + #define VIRTUALIZER_STR_ENCRYPTW_START VirtualizerStrEncryptWStart(); + #define VIRTUALIZER_STR_ENCRYPTW_END VirtualizerStrEncryptWEnd(); + + #define VIRTUALIZER_UNPROTECTED_START VirtualizerUnprotectedStart(); + #define VIRTUALIZER_UNPROTECTED_END VirtualizerUnprotectedEnd(); + + #define CV_CUSTOM_VMS_DEFINED + +#endif + +#if defined(PLATFORM_X32) && !defined(CV_X32_INSERT_VIA_INLINE) + + #define VIRTUALIZER_START VirtualizerStart(); + #define VIRTUALIZER_END VirtualizerEnd(); + + #define VIRTUALIZER_STR_ENCRYPT_START VirtualizerStrEncryptStart(); + #define VIRTUALIZER_STR_ENCRYPT_END VirtualizerStrEncryptEnd(); + + #define VIRTUALIZER_STR_ENCRYPTW_START VirtualizerStrEncryptWStart(); + #define VIRTUALIZER_STR_ENCRYPTW_END VirtualizerStrEncryptWEnd(); + + #define VIRTUALIZER_UNPROTECTED_START VirtualizerUnprotectedStart(); + #define VIRTUALIZER_UNPROTECTED_END VirtualizerUnprotectedEnd(); + + #define CV_CUSTOM_VMS_DEFINED + +#endif + + +// *********************************************** +// x32/x64 definition as inline assembly +// *********************************************** + +#ifndef CV_CUSTOM_VMS_DEFINED + +#ifdef __BORLANDC__ + #include "VirtualizerSDK_BorlandC_inline.h" +#endif + +#ifdef __GNUC__ + #include "VirtualizerSDK_GNU_inline.h" +#endif + +#ifdef __ICL + #include "VirtualizerSDK_ICL_inline.h" +#endif + +#ifdef __LCC__ + #include "VirtualizerSDK_LCC_inline.h" +#endif + +#if defined(_MSC_VER) || defined(__INTEL_COMPILER) + #include "VirtualizerSDK_VC_inline.h" +#endif + +#endif + +``` + +`include/sdk/VirtualizerSDK_BorlandC_inline.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_BorlandC_inline.h + * Description: Borland C++ inline assembly macros definitions + * + * Author/s: Oreans Technologies + * (c) 2013 Oreans Technologies + * + ******************************************************************************/ + +/*********************************************** + * Definition as inline assembly + ***********************************************/ + +#define VIRTUALIZER_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x0C, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); + +#define VIRTUALIZER_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x0D, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); + +#define VIRTUALIZER_STR_ENCRYPT_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x12, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#define VIRTUALIZER_STR_ENCRYPT_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x13, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#define VIRTUALIZER_STR_ENCRYPTW_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x22, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#define VIRTUALIZER_STR_ENCRYPTW_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x23, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); + +#define VIRTUALIZER_UNPROTECTED_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); + +#define VIRTUALIZER_UNPROTECTED_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x21, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); + + +``` + +`include/sdk/VirtualizerSDK_BorlandC_inline_FISH_LITE.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_BorlandC_inline_FISH_LITE.h + * Description: Borland C++ inline assembly macros definitions + * + * Author/s: Oreans Technologies + * (c) 2014 Oreans Technologies + * + * --- File generated automatically from Oreans VM Generator (2/4/2014) --- + ******************************************************************************/ + +/*********************************************** + * Definition as inline assembly + ***********************************************/ + +#ifdef PLATFORM_X32 + +#ifndef VIRTUALIZER_FISH_LITE_START +#define VIRTUALIZER_FISH_LITE_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x80, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_FISH_LITE_END +#define VIRTUALIZER_FISH_LITE_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x10, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#endif + +#ifdef PLATFORM_X64 + +#ifndef VIRTUALIZER_FISH_LITE_START +#define VIRTUALIZER_FISH_LITE_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x81, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_FISH_LITE_END +#define VIRTUALIZER_FISH_LITE_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x11, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#endif + + +``` + +`include/sdk/VirtualizerSDK_CustomVMs.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_CustomVMs.h + * Description: Definitions for Custom VMs in SecureEngine + * + * Author/s: Oreans Technologies + * (c) 2015 Oreans Technologies + * + * --- File generated automatically from Oreans VM Generator (16/6/2015) --- + ******************************************************************************/ + +// *********************************************** +// Definition of macros as function names +// *********************************************** + + #ifdef __cplusplus + extern "C" { + #endif + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000100_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000100_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000103_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000103_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000101_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000101_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000104_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000104_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000102_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000102_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000105_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000105_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000106_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000106_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000107_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000107_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000108_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000108_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000109_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000109_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000110_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000110_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000111_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000111_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000112_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000112_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000113_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000113_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000114_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000114_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000115_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000115_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000116_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000116_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000117_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000117_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000118_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000118_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000119_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000119_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000120_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000120_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000121_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000121_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000122_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000122_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000123_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000123_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000134_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000134_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000135_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000135_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000136_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000136_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000137_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000137_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000138_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000138_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000139_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000139_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000146_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000146_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000147_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000147_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000148_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000148_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000149_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000149_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000150_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000150_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000151_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000151_End(void); + +DLL_IMPORT void STDCALL_CONVENTION Mutate_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION Mutate_End(void); + +DLL_IMPORT void STDCALL_CONVENTION Mutate_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION Mutate_End(void); + +#ifdef __cplusplus +} +#endif + + +// *********************************************** +// x64 definition as function names +// *********************************************** + +#if defined(PLATFORM_X64) && !defined(CV_X64_INSERT_VIA_INLINE) + +#define VIRTUALIZER_TIGER_WHITE_START CustomVM00000103_Start(); +#define VIRTUALIZER_TIGER_WHITE_END CustomVM00000103_End(); + +#define VIRTUALIZER_TIGER_RED_START CustomVM00000104_Start(); +#define VIRTUALIZER_TIGER_RED_END CustomVM00000104_End(); + +#define VIRTUALIZER_TIGER_BLACK_START CustomVM00000105_Start(); +#define VIRTUALIZER_TIGER_BLACK_END CustomVM00000105_End(); + +#define VIRTUALIZER_FISH_WHITE_START CustomVM00000107_Start(); +#define VIRTUALIZER_FISH_WHITE_END CustomVM00000107_End(); + +#define VIRTUALIZER_FISH_RED_START CustomVM00000109_Start(); +#define VIRTUALIZER_FISH_RED_END CustomVM00000109_End(); + +#define VIRTUALIZER_FISH_BLACK_START CustomVM00000111_Start(); +#define VIRTUALIZER_FISH_BLACK_END CustomVM00000111_End(); + +#define VIRTUALIZER_PUMA_WHITE_START CustomVM00000113_Start(); +#define VIRTUALIZER_PUMA_WHITE_END CustomVM00000113_End(); + +#define VIRTUALIZER_PUMA_RED_START CustomVM00000115_Start(); +#define VIRTUALIZER_PUMA_RED_END CustomVM00000115_End(); + +#define VIRTUALIZER_PUMA_BLACK_START CustomVM00000117_Start(); +#define VIRTUALIZER_PUMA_BLACK_END CustomVM00000117_End(); + +#define VIRTUALIZER_SHARK_WHITE_START CustomVM00000119_Start(); +#define VIRTUALIZER_SHARK_WHITE_END CustomVM00000119_End(); + +#define VIRTUALIZER_SHARK_RED_START CustomVM00000121_Start(); +#define VIRTUALIZER_SHARK_RED_END CustomVM00000121_End(); + +#define VIRTUALIZER_SHARK_BLACK_START CustomVM00000123_Start(); +#define VIRTUALIZER_SHARK_BLACK_END CustomVM00000123_End(); + +#define VIRTUALIZER_DOLPHIN_WHITE_START CustomVM00000135_Start(); +#define VIRTUALIZER_DOLPHIN_WHITE_END CustomVM00000135_End(); + +#define VIRTUALIZER_DOLPHIN_RED_START CustomVM00000137_Start(); +#define VIRTUALIZER_DOLPHIN_RED_END CustomVM00000137_End(); + +#define VIRTUALIZER_DOLPHIN_BLACK_START CustomVM00000139_Start(); +#define VIRTUALIZER_DOLPHIN_BLACK_END CustomVM00000139_End(); + +#define VIRTUALIZER_EAGLE_WHITE_START CustomVM00000147_Start(); +#define VIRTUALIZER_EAGLE_WHITE_END CustomVM00000147_End(); + +#define VIRTUALIZER_EAGLE_RED_START CustomVM00000149_Start(); +#define VIRTUALIZER_EAGLE_RED_END CustomVM00000149_End(); + +#define VIRTUALIZER_EAGLE_BLACK_START CustomVM00000151_Start(); +#define VIRTUALIZER_EAGLE_BLACK_END CustomVM00000151_End(); + +#define VIRTUALIZER_MUTATE_ONLY_START Mutate_Start(); +#define VIRTUALIZER_MUTATE_ONLY_END Mutate_End(); + +#define CV_CUSTOM_VMS_DEFINED + +#endif + + +// *********************************************** +// x32 definition as function names +// *********************************************** + +#if defined(PLATFORM_X32) && !defined(CV_X32_INSERT_VIA_INLINE) + +#define VIRTUALIZER_TIGER_WHITE_START CustomVM00000100_Start(); +#define VIRTUALIZER_TIGER_WHITE_END CustomVM00000100_End(); + +#define VIRTUALIZER_TIGER_RED_START CustomVM00000101_Start(); +#define VIRTUALIZER_TIGER_RED_END CustomVM00000101_End(); + +#define VIRTUALIZER_TIGER_BLACK_START CustomVM00000102_Start(); +#define VIRTUALIZER_TIGER_BLACK_END CustomVM00000102_End(); + +#define VIRTUALIZER_FISH_WHITE_START CustomVM00000106_Start(); +#define VIRTUALIZER_FISH_WHITE_END CustomVM00000106_End(); + +#define VIRTUALIZER_FISH_RED_START CustomVM00000108_Start(); +#define VIRTUALIZER_FISH_RED_END CustomVM00000108_End(); + +#define VIRTUALIZER_FISH_BLACK_START CustomVM00000110_Start(); +#define VIRTUALIZER_FISH_BLACK_END CustomVM00000110_End(); + +#define VIRTUALIZER_PUMA_WHITE_START CustomVM00000112_Start(); +#define VIRTUALIZER_PUMA_WHITE_END CustomVM00000112_End(); + +#define VIRTUALIZER_PUMA_RED_START CustomVM00000114_Start(); +#define VIRTUALIZER_PUMA_RED_END CustomVM00000114_End(); + +#define VIRTUALIZER_PUMA_BLACK_START CustomVM00000116_Start(); +#define VIRTUALIZER_PUMA_BLACK_END CustomVM00000116_End(); + +#define VIRTUALIZER_SHARK_WHITE_START CustomVM00000118_Start(); +#define VIRTUALIZER_SHARK_WHITE_END CustomVM00000118_End(); + +#define VIRTUALIZER_SHARK_RED_START CustomVM00000120_Start(); +#define VIRTUALIZER_SHARK_RED_END CustomVM00000120_End(); + +#define VIRTUALIZER_SHARK_BLACK_START CustomVM00000122_Start(); +#define VIRTUALIZER_SHARK_BLACK_END CustomVM00000122_End(); + +#define VIRTUALIZER_DOLPHIN_WHITE_START CustomVM00000134_Start(); +#define VIRTUALIZER_DOLPHIN_WHITE_END CustomVM00000134_End(); + +#define VIRTUALIZER_DOLPHIN_RED_START CustomVM00000136_Start(); +#define VIRTUALIZER_DOLPHIN_RED_END CustomVM00000136_End(); + +#define VIRTUALIZER_DOLPHIN_BLACK_START CustomVM00000138_Start(); +#define VIRTUALIZER_DOLPHIN_BLACK_END CustomVM00000138_End(); + +#define VIRTUALIZER_EAGLE_WHITE_START CustomVM00000146_Start(); +#define VIRTUALIZER_EAGLE_WHITE_END CustomVM00000146_End(); + +#define VIRTUALIZER_EAGLE_RED_START CustomVM00000148_Start(); +#define VIRTUALIZER_EAGLE_RED_END CustomVM00000148_End(); + +#define VIRTUALIZER_EAGLE_BLACK_START CustomVM00000150_Start(); +#define VIRTUALIZER_EAGLE_BLACK_END CustomVM00000150_End(); + +#define VIRTUALIZER_MUTATE_ONLY_START Mutate_Start(); +#define VIRTUALIZER_MUTATE_ONLY_END Mutate_End(); + +#define CV_CUSTOM_VMS_DEFINED + +#endif + + +// *********************************************** +// x32/x64 definition as inline assembly +// *********************************************** + +#ifndef CV_CUSTOM_VMS_DEFINED + +#ifdef __BORLANDC__ + #include "VirtualizerSDK_CustomVMs_BorlandC_inline.h" +#endif + +#ifdef __GNUC__ + #include "VirtualizerSDK_CustomVMs_GNU_inline.h" +#endif + +#ifdef __ICL + #include "VirtualizerSDK_CustomVMs_ICL_inline.h" +#endif + +#ifdef __LCC__ + #include "VirtualizerSDK_CustomVMs_LCC_inline.h" +#endif + +#if defined(_MSC_VER) || defined(__INTEL_COMPILER) + #include "VirtualizerSDK_CustomVMs_VC_inline.h" +#endif + +#endif + +``` + +`include/sdk/VirtualizerSDK_CustomVMs_BorlandC_inline.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_CustomVMs_BorlandC_inline.h + * Description: Borland C++ inline assembly macros definitions + * + * Author/s: Oreans Technologies + * (c) 2015 Oreans Technologies + * + * --- File generated automatically from Oreans VM Generator (16/6/2015) --- + ******************************************************************************/ + +/*********************************************** + * Definition as inline assembly + ***********************************************/ + +#ifdef PLATFORM_X32 + +#ifndef VIRTUALIZER_TIGER_WHITE_START +#define VIRTUALIZER_TIGER_WHITE_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x64, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_TIGER_WHITE_END +#define VIRTUALIZER_TIGER_WHITE_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xF4, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_TIGER_RED_START +#define VIRTUALIZER_TIGER_RED_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x65, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_TIGER_RED_END +#define VIRTUALIZER_TIGER_RED_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xF5, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_START +#define VIRTUALIZER_TIGER_BLACK_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x66, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_END +#define VIRTUALIZER_TIGER_BLACK_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xF6, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_START +#define VIRTUALIZER_FISH_WHITE_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x6A, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_END +#define VIRTUALIZER_FISH_WHITE_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xFA, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_FISH_RED_START +#define VIRTUALIZER_FISH_RED_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x6C, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_FISH_RED_END +#define VIRTUALIZER_FISH_RED_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xFC, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_START +#define VIRTUALIZER_FISH_BLACK_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x6E, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_END +#define VIRTUALIZER_FISH_BLACK_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xFE, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_START +#define VIRTUALIZER_PUMA_WHITE_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x70, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_END +#define VIRTUALIZER_PUMA_WHITE_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x00, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_PUMA_RED_START +#define VIRTUALIZER_PUMA_RED_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x72, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_PUMA_RED_END +#define VIRTUALIZER_PUMA_RED_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x02, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_START +#define VIRTUALIZER_PUMA_BLACK_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x74, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_END +#define VIRTUALIZER_PUMA_BLACK_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x04, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_START +#define VIRTUALIZER_SHARK_WHITE_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x76, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_END +#define VIRTUALIZER_SHARK_WHITE_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x06, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_SHARK_RED_START +#define VIRTUALIZER_SHARK_RED_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x78, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_SHARK_RED_END +#define VIRTUALIZER_SHARK_RED_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x08, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_START +#define VIRTUALIZER_SHARK_BLACK_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x7A, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_END +#define VIRTUALIZER_SHARK_BLACK_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x0A, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_START +#define VIRTUALIZER_DOLPHIN_WHITE_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x86, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_END +#define VIRTUALIZER_DOLPHIN_WHITE_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x16, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_START +#define VIRTUALIZER_DOLPHIN_RED_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x88, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_END +#define VIRTUALIZER_DOLPHIN_RED_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x18, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_START +#define VIRTUALIZER_DOLPHIN_BLACK_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x8A, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_END +#define VIRTUALIZER_DOLPHIN_BLACK_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x1A, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_START +#define VIRTUALIZER_EAGLE_WHITE_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x92, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_END +#define VIRTUALIZER_EAGLE_WHITE_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x22, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_START +#define VIRTUALIZER_EAGLE_RED_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x94, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_END +#define VIRTUALIZER_EAGLE_RED_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x24, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_START +#define VIRTUALIZER_EAGLE_BLACK_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x96, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_END +#define VIRTUALIZER_EAGLE_BLACK_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x26, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_START +#define VIRTUALIZER_MUTATE_ONLY_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x10, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_END +#define VIRTUALIZER_MUTATE_ONLY_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x11, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#endif + +#ifdef PLATFORM_X64 + +#ifndef VIRTUALIZER_TIGER_WHITE_START +#define VIRTUALIZER_TIGER_WHITE_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x67, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_TIGER_WHITE_END +#define VIRTUALIZER_TIGER_WHITE_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xF7, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_TIGER_RED_START +#define VIRTUALIZER_TIGER_RED_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x68, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_TIGER_RED_END +#define VIRTUALIZER_TIGER_RED_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xF8, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_START +#define VIRTUALIZER_TIGER_BLACK_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x69, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_END +#define VIRTUALIZER_TIGER_BLACK_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xF9, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_START +#define VIRTUALIZER_FISH_WHITE_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x6B, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_END +#define VIRTUALIZER_FISH_WHITE_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xFB, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_FISH_RED_START +#define VIRTUALIZER_FISH_RED_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x6D, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_FISH_RED_END +#define VIRTUALIZER_FISH_RED_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xFD, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_START +#define VIRTUALIZER_FISH_BLACK_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x6F, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_END +#define VIRTUALIZER_FISH_BLACK_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xFF, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_START +#define VIRTUALIZER_PUMA_WHITE_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x71, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_END +#define VIRTUALIZER_PUMA_WHITE_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x01, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_PUMA_RED_START +#define VIRTUALIZER_PUMA_RED_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x73, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_PUMA_RED_END +#define VIRTUALIZER_PUMA_RED_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x03, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_START +#define VIRTUALIZER_PUMA_BLACK_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x75, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_END +#define VIRTUALIZER_PUMA_BLACK_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x05, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_START +#define VIRTUALIZER_SHARK_WHITE_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x77, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_END +#define VIRTUALIZER_SHARK_WHITE_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x07, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_SHARK_RED_START +#define VIRTUALIZER_SHARK_RED_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x79, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_SHARK_RED_END +#define VIRTUALIZER_SHARK_RED_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x09, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_START +#define VIRTUALIZER_SHARK_BLACK_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x7B, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_END +#define VIRTUALIZER_SHARK_BLACK_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x0B, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_START +#define VIRTUALIZER_DOLPHIN_WHITE_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x87, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_END +#define VIRTUALIZER_DOLPHIN_WHITE_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x17, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_START +#define VIRTUALIZER_DOLPHIN_RED_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x89, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_END +#define VIRTUALIZER_DOLPHIN_RED_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x19, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_START +#define VIRTUALIZER_DOLPHIN_BLACK_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x8B, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_END +#define VIRTUALIZER_DOLPHIN_BLACK_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x1B, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_START +#define VIRTUALIZER_EAGLE_WHITE_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x93, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_END +#define VIRTUALIZER_EAGLE_WHITE_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x23, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_START +#define VIRTUALIZER_EAGLE_RED_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x95, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_END +#define VIRTUALIZER_EAGLE_RED_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x25, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_START +#define VIRTUALIZER_EAGLE_BLACK_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x97, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_END +#define VIRTUALIZER_EAGLE_BLACK_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x27, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_START +#define VIRTUALIZER_MUTATE_ONLY_START __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x10, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_END +#define VIRTUALIZER_MUTATE_ONLY_END __emit__ (0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x11, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20); +#endif + +#endif + + +``` + +`include/sdk/VirtualizerSDK_CustomVMs_GNU_inline.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_CustomVMs_GNU_inline.h + * Description: GNU C inline assembly macros definitions + * + * Author/s: Oreans Technologies + * (c) 2015 Oreans Technologies + * + * --- File generated automatically from Oreans VM Generator (16/6/2015) --- + ******************************************************************************/ + +/*********************************************** + * Definition as inline assembly + ***********************************************/ + +#ifdef PLATFORM_X32 + +#ifndef VIRTUALIZER_TIGER_WHITE_START +#define VIRTUALIZER_TIGER_WHITE_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x64\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_TIGER_WHITE_END +#define VIRTUALIZER_TIGER_WHITE_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0xF4\n"\ + ".byte 0x01\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_TIGER_RED_START +#define VIRTUALIZER_TIGER_RED_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x65\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_TIGER_RED_END +#define VIRTUALIZER_TIGER_RED_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0xF5\n"\ + ".byte 0x01\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_START +#define VIRTUALIZER_TIGER_BLACK_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x66\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_END +#define VIRTUALIZER_TIGER_BLACK_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0xF6\n"\ + ".byte 0x01\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_START +#define VIRTUALIZER_FISH_WHITE_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x6A\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_END +#define VIRTUALIZER_FISH_WHITE_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0xFA\n"\ + ".byte 0x01\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_FISH_RED_START +#define VIRTUALIZER_FISH_RED_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x6C\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_FISH_RED_END +#define VIRTUALIZER_FISH_RED_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0xFC\n"\ + ".byte 0x01\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_START +#define VIRTUALIZER_FISH_BLACK_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x6E\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_END +#define VIRTUALIZER_FISH_BLACK_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0xFE\n"\ + ".byte 0x01\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_START +#define VIRTUALIZER_PUMA_WHITE_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x70\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_END +#define VIRTUALIZER_PUMA_WHITE_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x00\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_PUMA_RED_START +#define VIRTUALIZER_PUMA_RED_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x72\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_PUMA_RED_END +#define VIRTUALIZER_PUMA_RED_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x02\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_START +#define VIRTUALIZER_PUMA_BLACK_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x74\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_END +#define VIRTUALIZER_PUMA_BLACK_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x04\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_START +#define VIRTUALIZER_SHARK_WHITE_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x76\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_END +#define VIRTUALIZER_SHARK_WHITE_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x06\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_SHARK_RED_START +#define VIRTUALIZER_SHARK_RED_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x78\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_SHARK_RED_END +#define VIRTUALIZER_SHARK_RED_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x08\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_START +#define VIRTUALIZER_SHARK_BLACK_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x7A\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_END +#define VIRTUALIZER_SHARK_BLACK_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x0A\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_START +#define VIRTUALIZER_DOLPHIN_WHITE_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x86\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_END +#define VIRTUALIZER_DOLPHIN_WHITE_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x16\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_START +#define VIRTUALIZER_DOLPHIN_RED_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x88\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_END +#define VIRTUALIZER_DOLPHIN_RED_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x18\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_START +#define VIRTUALIZER_DOLPHIN_BLACK_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x8A\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_END +#define VIRTUALIZER_DOLPHIN_BLACK_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x1A\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_START +#define VIRTUALIZER_EAGLE_WHITE_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x92\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_END +#define VIRTUALIZER_EAGLE_WHITE_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x22\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_START +#define VIRTUALIZER_EAGLE_RED_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x94\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_END +#define VIRTUALIZER_EAGLE_RED_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x24\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_START +#define VIRTUALIZER_EAGLE_BLACK_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x96\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_END +#define VIRTUALIZER_EAGLE_BLACK_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x26\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_START +#define VIRTUALIZER_MUTATE_ONLY_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x10\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_END +#define VIRTUALIZER_MUTATE_ONLY_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x11\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#endif + +#ifdef PLATFORM_X64 + +#ifndef VIRTUALIZER_TIGER_WHITE_START +#define VIRTUALIZER_TIGER_WHITE_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x67\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_TIGER_WHITE_END +#define VIRTUALIZER_TIGER_WHITE_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0xF7\n"\ + ".byte 0x01\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_TIGER_RED_START +#define VIRTUALIZER_TIGER_RED_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x68\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_TIGER_RED_END +#define VIRTUALIZER_TIGER_RED_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0xF8\n"\ + ".byte 0x01\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_START +#define VIRTUALIZER_TIGER_BLACK_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x69\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_END +#define VIRTUALIZER_TIGER_BLACK_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0xF9\n"\ + ".byte 0x01\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_START +#define VIRTUALIZER_FISH_WHITE_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x6B\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_END +#define VIRTUALIZER_FISH_WHITE_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0xFB\n"\ + ".byte 0x01\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_FISH_RED_START +#define VIRTUALIZER_FISH_RED_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x6D\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_FISH_RED_END +#define VIRTUALIZER_FISH_RED_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0xFD\n"\ + ".byte 0x01\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_START +#define VIRTUALIZER_FISH_BLACK_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x6F\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_END +#define VIRTUALIZER_FISH_BLACK_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0xFF\n"\ + ".byte 0x01\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_START +#define VIRTUALIZER_PUMA_WHITE_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x71\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_END +#define VIRTUALIZER_PUMA_WHITE_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x01\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_PUMA_RED_START +#define VIRTUALIZER_PUMA_RED_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x73\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_PUMA_RED_END +#define VIRTUALIZER_PUMA_RED_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x03\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_START +#define VIRTUALIZER_PUMA_BLACK_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x75\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_END +#define VIRTUALIZER_PUMA_BLACK_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x05\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_START +#define VIRTUALIZER_SHARK_WHITE_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x77\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_END +#define VIRTUALIZER_SHARK_WHITE_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x07\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_SHARK_RED_START +#define VIRTUALIZER_SHARK_RED_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x79\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_SHARK_RED_END +#define VIRTUALIZER_SHARK_RED_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x09\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_START +#define VIRTUALIZER_SHARK_BLACK_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x7B\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_END +#define VIRTUALIZER_SHARK_BLACK_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x0B\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_START +#define VIRTUALIZER_DOLPHIN_WHITE_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x87\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_END +#define VIRTUALIZER_DOLPHIN_WHITE_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x17\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_START +#define VIRTUALIZER_DOLPHIN_RED_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x89\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_END +#define VIRTUALIZER_DOLPHIN_RED_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x19\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_START +#define VIRTUALIZER_DOLPHIN_BLACK_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x8B\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_END +#define VIRTUALIZER_DOLPHIN_BLACK_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x1B\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_START +#define VIRTUALIZER_EAGLE_WHITE_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x93\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_END +#define VIRTUALIZER_EAGLE_WHITE_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x23\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_START +#define VIRTUALIZER_EAGLE_RED_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x95\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_END +#define VIRTUALIZER_EAGLE_RED_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x25\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_START +#define VIRTUALIZER_EAGLE_BLACK_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x97\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_END +#define VIRTUALIZER_EAGLE_BLACK_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x27\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_START +#define VIRTUALIZER_MUTATE_ONLY_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x10\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_END +#define VIRTUALIZER_MUTATE_ONLY_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x11\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#endif + + +``` + +`include/sdk/VirtualizerSDK_CustomVMs_ICL_inline.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_CustomVMs_ICL_inline.h + * Description: ICL inline assembly macros definitions + * + * Author/s: Oreans Technologies + * (c) 2015 Oreans Technologies + * + * --- File generated automatically from Oreans VM Generator (16/6/2015) --- + ******************************************************************************/ + +/*********************************************** + * Definition as inline assembly + ***********************************************/ + +#ifdef PLATFORM_X32 + +#ifndef VIRTUALIZER_TIGER_WHITE_START +#define VIRTUALIZER_TIGER_WHITE_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x64 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_WHITE_END +#define VIRTUALIZER_TIGER_WHITE_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0xF4 \ + __asm __emit 0x01 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_RED_START +#define VIRTUALIZER_TIGER_RED_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x65 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_RED_END +#define VIRTUALIZER_TIGER_RED_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0xF5 \ + __asm __emit 0x01 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_START +#define VIRTUALIZER_TIGER_BLACK_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x66 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_END +#define VIRTUALIZER_TIGER_BLACK_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0xF6 \ + __asm __emit 0x01 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_START +#define VIRTUALIZER_FISH_WHITE_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x6A \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_END +#define VIRTUALIZER_FISH_WHITE_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0xFA \ + __asm __emit 0x01 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_RED_START +#define VIRTUALIZER_FISH_RED_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x6C \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_RED_END +#define VIRTUALIZER_FISH_RED_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0xFC \ + __asm __emit 0x01 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_START +#define VIRTUALIZER_FISH_BLACK_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x6E \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_END +#define VIRTUALIZER_FISH_BLACK_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0xFE \ + __asm __emit 0x01 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_START +#define VIRTUALIZER_PUMA_WHITE_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x70 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_END +#define VIRTUALIZER_PUMA_WHITE_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x00 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_RED_START +#define VIRTUALIZER_PUMA_RED_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x72 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_RED_END +#define VIRTUALIZER_PUMA_RED_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x02 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_START +#define VIRTUALIZER_PUMA_BLACK_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x74 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_END +#define VIRTUALIZER_PUMA_BLACK_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x04 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_START +#define VIRTUALIZER_SHARK_WHITE_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x76 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_END +#define VIRTUALIZER_SHARK_WHITE_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x06 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_RED_START +#define VIRTUALIZER_SHARK_RED_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x78 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_RED_END +#define VIRTUALIZER_SHARK_RED_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x08 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_START +#define VIRTUALIZER_SHARK_BLACK_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x7A \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_END +#define VIRTUALIZER_SHARK_BLACK_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x0A \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_START +#define VIRTUALIZER_DOLPHIN_WHITE_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x86 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_END +#define VIRTUALIZER_DOLPHIN_WHITE_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x16 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_START +#define VIRTUALIZER_DOLPHIN_RED_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x88 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_END +#define VIRTUALIZER_DOLPHIN_RED_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x18 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_START +#define VIRTUALIZER_DOLPHIN_BLACK_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x8A \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_END +#define VIRTUALIZER_DOLPHIN_BLACK_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x1A \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_START +#define VIRTUALIZER_EAGLE_WHITE_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x92 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_END +#define VIRTUALIZER_EAGLE_WHITE_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x22 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_START +#define VIRTUALIZER_EAGLE_RED_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x94 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_END +#define VIRTUALIZER_EAGLE_RED_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x24 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_START +#define VIRTUALIZER_EAGLE_BLACK_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x96 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_END +#define VIRTUALIZER_EAGLE_BLACK_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x26 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_START +#define VIRTUALIZER_MUTATE_ONLY_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x10 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_END +#define VIRTUALIZER_MUTATE_ONLY_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x11 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#endif + +#ifdef PLATFORM_X64 + +#ifndef VIRTUALIZER_TIGER_WHITE_START +#define VIRTUALIZER_TIGER_WHITE_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x67 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_WHITE_END +#define VIRTUALIZER_TIGER_WHITE_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0xF7 \ + __asm __emit 0x01 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_RED_START +#define VIRTUALIZER_TIGER_RED_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x68 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_RED_END +#define VIRTUALIZER_TIGER_RED_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0xF8 \ + __asm __emit 0x01 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_START +#define VIRTUALIZER_TIGER_BLACK_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x69 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_END +#define VIRTUALIZER_TIGER_BLACK_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0xF9 \ + __asm __emit 0x01 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_START +#define VIRTUALIZER_FISH_WHITE_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x6B \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_END +#define VIRTUALIZER_FISH_WHITE_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0xFB \ + __asm __emit 0x01 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_RED_START +#define VIRTUALIZER_FISH_RED_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x6D \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_RED_END +#define VIRTUALIZER_FISH_RED_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0xFD \ + __asm __emit 0x01 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_START +#define VIRTUALIZER_FISH_BLACK_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x6F \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_END +#define VIRTUALIZER_FISH_BLACK_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0xFF \ + __asm __emit 0x01 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_START +#define VIRTUALIZER_PUMA_WHITE_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x71 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_END +#define VIRTUALIZER_PUMA_WHITE_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x01 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_RED_START +#define VIRTUALIZER_PUMA_RED_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x73 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_RED_END +#define VIRTUALIZER_PUMA_RED_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x03 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_START +#define VIRTUALIZER_PUMA_BLACK_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x75 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_END +#define VIRTUALIZER_PUMA_BLACK_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x05 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_START +#define VIRTUALIZER_SHARK_WHITE_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x77 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_END +#define VIRTUALIZER_SHARK_WHITE_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x07 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_RED_START +#define VIRTUALIZER_SHARK_RED_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x79 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_RED_END +#define VIRTUALIZER_SHARK_RED_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x09 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_START +#define VIRTUALIZER_SHARK_BLACK_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x7B \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_END +#define VIRTUALIZER_SHARK_BLACK_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x0B \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_START +#define VIRTUALIZER_DOLPHIN_WHITE_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x87 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_END +#define VIRTUALIZER_DOLPHIN_WHITE_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x17 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_START +#define VIRTUALIZER_DOLPHIN_RED_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x89 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_END +#define VIRTUALIZER_DOLPHIN_RED_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x19 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_START +#define VIRTUALIZER_DOLPHIN_BLACK_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x8B \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_END +#define VIRTUALIZER_DOLPHIN_BLACK_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x1B \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_START +#define VIRTUALIZER_EAGLE_WHITE_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x93 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_END +#define VIRTUALIZER_EAGLE_WHITE_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x23 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_START +#define VIRTUALIZER_EAGLE_RED_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x95 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_END +#define VIRTUALIZER_EAGLE_RED_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x25 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_START +#define VIRTUALIZER_EAGLE_BLACK_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x97 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_END +#define VIRTUALIZER_EAGLE_BLACK_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x27 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_START +#define VIRTUALIZER_MUTATE_ONLY_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x10 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_END +#define VIRTUALIZER_MUTATE_ONLY_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x11 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#endif + + +``` + +`include/sdk/VirtualizerSDK_CustomVMs_LCC_inline.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_CustomVMs_LCC_inline.h + * Description: LCC inline assembly macros definitions + * + * Author/s: Oreans Technologies + * (c) 2015 Oreans Technologies + * + * --- File generated automatically from Oreans VM Generator (16/6/2015) --- + ******************************************************************************/ + +/*********************************************** + * Definition as inline assembly + ***********************************************/ + +#ifdef PLATFORM_X32 + +#ifndef VIRTUALIZER_TIGER_WHITE_START +#define VIRTUALIZER_TIGER_WHITE_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x64, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_TIGER_WHITE_END +#define VIRTUALIZER_TIGER_WHITE_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xF4, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_TIGER_RED_START +#define VIRTUALIZER_TIGER_RED_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x65, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_TIGER_RED_END +#define VIRTUALIZER_TIGER_RED_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xF5, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_START +#define VIRTUALIZER_TIGER_BLACK_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x66, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_END +#define VIRTUALIZER_TIGER_BLACK_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xF6, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_START +#define VIRTUALIZER_FISH_WHITE_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x6A, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_END +#define VIRTUALIZER_FISH_WHITE_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xFA, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_FISH_RED_START +#define VIRTUALIZER_FISH_RED_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x6C, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_FISH_RED_END +#define VIRTUALIZER_FISH_RED_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xFC, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_START +#define VIRTUALIZER_FISH_BLACK_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x6E, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_END +#define VIRTUALIZER_FISH_BLACK_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xFE, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_START +#define VIRTUALIZER_PUMA_WHITE_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x70, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_END +#define VIRTUALIZER_PUMA_WHITE_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x00, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_PUMA_RED_START +#define VIRTUALIZER_PUMA_RED_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x72, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_PUMA_RED_END +#define VIRTUALIZER_PUMA_RED_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x02, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_START +#define VIRTUALIZER_PUMA_BLACK_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x74, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_END +#define VIRTUALIZER_PUMA_BLACK_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x04, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_START +#define VIRTUALIZER_SHARK_WHITE_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x76, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_END +#define VIRTUALIZER_SHARK_WHITE_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x06, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_SHARK_RED_START +#define VIRTUALIZER_SHARK_RED_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x78, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_SHARK_RED_END +#define VIRTUALIZER_SHARK_RED_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x08, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_START +#define VIRTUALIZER_SHARK_BLACK_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x7A, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_END +#define VIRTUALIZER_SHARK_BLACK_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x0A, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_START +#define VIRTUALIZER_DOLPHIN_WHITE_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x86, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_END +#define VIRTUALIZER_DOLPHIN_WHITE_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x16, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_START +#define VIRTUALIZER_DOLPHIN_RED_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x88, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_END +#define VIRTUALIZER_DOLPHIN_RED_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x18, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_START +#define VIRTUALIZER_DOLPHIN_BLACK_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x8A, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_END +#define VIRTUALIZER_DOLPHIN_BLACK_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x1A, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_START +#define VIRTUALIZER_EAGLE_WHITE_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x92, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_END +#define VIRTUALIZER_EAGLE_WHITE_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x22, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_START +#define VIRTUALIZER_EAGLE_RED_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x94, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_END +#define VIRTUALIZER_EAGLE_RED_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x24, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_START +#define VIRTUALIZER_EAGLE_BLACK_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x96, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_END +#define VIRTUALIZER_EAGLE_BLACK_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x26, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_START +#define VIRTUALIZER_MUTATE_ONLY_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x10, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_END +#define VIRTUALIZER_MUTATE_ONLY_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x11, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#endif + +#ifdef PLATFORM_X64 + +#ifndef VIRTUALIZER_TIGER_WHITE_START +#define VIRTUALIZER_TIGER_WHITE_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x67, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_TIGER_WHITE_END +#define VIRTUALIZER_TIGER_WHITE_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xF7, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_TIGER_RED_START +#define VIRTUALIZER_TIGER_RED_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x68, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_TIGER_RED_END +#define VIRTUALIZER_TIGER_RED_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xF8, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_START +#define VIRTUALIZER_TIGER_BLACK_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x69, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_END +#define VIRTUALIZER_TIGER_BLACK_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xF9, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_START +#define VIRTUALIZER_FISH_WHITE_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x6B, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_END +#define VIRTUALIZER_FISH_WHITE_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xFB, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_FISH_RED_START +#define VIRTUALIZER_FISH_RED_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x6D, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_FISH_RED_END +#define VIRTUALIZER_FISH_RED_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xFD, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_START +#define VIRTUALIZER_FISH_BLACK_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x6F, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_END +#define VIRTUALIZER_FISH_BLACK_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0xFF, 0x01, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_START +#define VIRTUALIZER_PUMA_WHITE_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x71, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_END +#define VIRTUALIZER_PUMA_WHITE_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x01, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_PUMA_RED_START +#define VIRTUALIZER_PUMA_RED_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x73, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_PUMA_RED_END +#define VIRTUALIZER_PUMA_RED_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x03, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_START +#define VIRTUALIZER_PUMA_BLACK_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x75, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_END +#define VIRTUALIZER_PUMA_BLACK_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x05, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_START +#define VIRTUALIZER_SHARK_WHITE_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x77, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_END +#define VIRTUALIZER_SHARK_WHITE_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x07, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_SHARK_RED_START +#define VIRTUALIZER_SHARK_RED_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x79, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_SHARK_RED_END +#define VIRTUALIZER_SHARK_RED_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x09, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_START +#define VIRTUALIZER_SHARK_BLACK_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x7B, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_END +#define VIRTUALIZER_SHARK_BLACK_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x0B, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_START +#define VIRTUALIZER_DOLPHIN_WHITE_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x87, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_END +#define VIRTUALIZER_DOLPHIN_WHITE_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x17, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_START +#define VIRTUALIZER_DOLPHIN_RED_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x89, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_END +#define VIRTUALIZER_DOLPHIN_RED_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x19, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_START +#define VIRTUALIZER_DOLPHIN_BLACK_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x8B, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_END +#define VIRTUALIZER_DOLPHIN_BLACK_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x1B, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_START +#define VIRTUALIZER_EAGLE_WHITE_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x93, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_END +#define VIRTUALIZER_EAGLE_WHITE_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x23, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_START +#define VIRTUALIZER_EAGLE_RED_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x95, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_END +#define VIRTUALIZER_EAGLE_RED_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x25, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_START +#define VIRTUALIZER_EAGLE_BLACK_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x97, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_END +#define VIRTUALIZER_EAGLE_BLACK_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x27, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_START +#define VIRTUALIZER_MUTATE_ONLY_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x10, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_END +#define VIRTUALIZER_MUTATE_ONLY_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x11, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#endif + + +``` + +`include/sdk/VirtualizerSDK_CustomVMs_VC_inline.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_CustomVMs_VC_inline.h + * Description: VC inline assembly macros definitions + * + * Author/s: Oreans Technologies + * (c) 2015 Oreans Technologies + * + * --- File generated automatically from Oreans VM Generator (16/6/2015) --- + ******************************************************************************/ + +/*********************************************** + * Definition as inline assembly + ***********************************************/ + +#ifdef PLATFORM_X32 + +#ifndef VIRTUALIZER_TIGER_WHITE_START +#define VIRTUALIZER_TIGER_WHITE_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x64 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_WHITE_END +#define VIRTUALIZER_TIGER_WHITE_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0xF4 \ + __asm _emit 0x01 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_RED_START +#define VIRTUALIZER_TIGER_RED_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x65 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_RED_END +#define VIRTUALIZER_TIGER_RED_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0xF5 \ + __asm _emit 0x01 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_START +#define VIRTUALIZER_TIGER_BLACK_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x66 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_END +#define VIRTUALIZER_TIGER_BLACK_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0xF6 \ + __asm _emit 0x01 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_START +#define VIRTUALIZER_FISH_WHITE_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x6A \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_END +#define VIRTUALIZER_FISH_WHITE_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0xFA \ + __asm _emit 0x01 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_RED_START +#define VIRTUALIZER_FISH_RED_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x6C \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_RED_END +#define VIRTUALIZER_FISH_RED_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0xFC \ + __asm _emit 0x01 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_START +#define VIRTUALIZER_FISH_BLACK_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x6E \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_END +#define VIRTUALIZER_FISH_BLACK_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0xFE \ + __asm _emit 0x01 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_START +#define VIRTUALIZER_PUMA_WHITE_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x70 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_END +#define VIRTUALIZER_PUMA_WHITE_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x00 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_RED_START +#define VIRTUALIZER_PUMA_RED_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x72 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_RED_END +#define VIRTUALIZER_PUMA_RED_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x02 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_START +#define VIRTUALIZER_PUMA_BLACK_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x74 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_END +#define VIRTUALIZER_PUMA_BLACK_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x04 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_START +#define VIRTUALIZER_SHARK_WHITE_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x76 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_END +#define VIRTUALIZER_SHARK_WHITE_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x06 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_RED_START +#define VIRTUALIZER_SHARK_RED_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x78 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_RED_END +#define VIRTUALIZER_SHARK_RED_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x08 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_START +#define VIRTUALIZER_SHARK_BLACK_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x7A \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_END +#define VIRTUALIZER_SHARK_BLACK_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x0A \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_START +#define VIRTUALIZER_DOLPHIN_WHITE_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x86 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_END +#define VIRTUALIZER_DOLPHIN_WHITE_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x16 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_START +#define VIRTUALIZER_DOLPHIN_RED_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x88 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_END +#define VIRTUALIZER_DOLPHIN_RED_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x18 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_START +#define VIRTUALIZER_DOLPHIN_BLACK_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x8A \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_END +#define VIRTUALIZER_DOLPHIN_BLACK_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x1A \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_START +#define VIRTUALIZER_EAGLE_WHITE_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x92 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_END +#define VIRTUALIZER_EAGLE_WHITE_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x22 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_START +#define VIRTUALIZER_EAGLE_RED_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x94 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_END +#define VIRTUALIZER_EAGLE_RED_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x24 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_START +#define VIRTUALIZER_EAGLE_BLACK_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x96 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_END +#define VIRTUALIZER_EAGLE_BLACK_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x26 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_START +#define VIRTUALIZER_MUTATE_ONLY_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x10 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_END +#define VIRTUALIZER_MUTATE_ONLY_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x11 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#endif + +#ifdef PLATFORM_X64 + +#ifndef VIRTUALIZER_TIGER_WHITE_START +#define VIRTUALIZER_TIGER_WHITE_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x67 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_WHITE_END +#define VIRTUALIZER_TIGER_WHITE_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0xF7 \ + __asm _emit 0x01 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_RED_START +#define VIRTUALIZER_TIGER_RED_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x68 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_RED_END +#define VIRTUALIZER_TIGER_RED_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0xF8 \ + __asm _emit 0x01 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_START +#define VIRTUALIZER_TIGER_BLACK_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x69 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_TIGER_BLACK_END +#define VIRTUALIZER_TIGER_BLACK_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0xF9 \ + __asm _emit 0x01 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_START +#define VIRTUALIZER_FISH_WHITE_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x6B \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_WHITE_END +#define VIRTUALIZER_FISH_WHITE_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0xFB \ + __asm _emit 0x01 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_RED_START +#define VIRTUALIZER_FISH_RED_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x6D \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_RED_END +#define VIRTUALIZER_FISH_RED_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0xFD \ + __asm _emit 0x01 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_START +#define VIRTUALIZER_FISH_BLACK_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x6F \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_BLACK_END +#define VIRTUALIZER_FISH_BLACK_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0xFF \ + __asm _emit 0x01 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_START +#define VIRTUALIZER_PUMA_WHITE_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x71 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_WHITE_END +#define VIRTUALIZER_PUMA_WHITE_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x01 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_RED_START +#define VIRTUALIZER_PUMA_RED_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x73 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_RED_END +#define VIRTUALIZER_PUMA_RED_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x03 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_START +#define VIRTUALIZER_PUMA_BLACK_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x75 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_PUMA_BLACK_END +#define VIRTUALIZER_PUMA_BLACK_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x05 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_START +#define VIRTUALIZER_SHARK_WHITE_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x77 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_WHITE_END +#define VIRTUALIZER_SHARK_WHITE_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x07 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_RED_START +#define VIRTUALIZER_SHARK_RED_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x79 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_RED_END +#define VIRTUALIZER_SHARK_RED_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x09 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_START +#define VIRTUALIZER_SHARK_BLACK_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x7B \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_SHARK_BLACK_END +#define VIRTUALIZER_SHARK_BLACK_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x0B \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_START +#define VIRTUALIZER_DOLPHIN_WHITE_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x87 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_WHITE_END +#define VIRTUALIZER_DOLPHIN_WHITE_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x17 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_START +#define VIRTUALIZER_DOLPHIN_RED_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x89 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_RED_END +#define VIRTUALIZER_DOLPHIN_RED_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x19 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_START +#define VIRTUALIZER_DOLPHIN_BLACK_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x8B \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_DOLPHIN_BLACK_END +#define VIRTUALIZER_DOLPHIN_BLACK_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x1B \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_START +#define VIRTUALIZER_EAGLE_WHITE_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x93 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_WHITE_END +#define VIRTUALIZER_EAGLE_WHITE_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x23 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_START +#define VIRTUALIZER_EAGLE_RED_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x95 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_RED_END +#define VIRTUALIZER_EAGLE_RED_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x25 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_START +#define VIRTUALIZER_EAGLE_BLACK_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x97 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_EAGLE_BLACK_END +#define VIRTUALIZER_EAGLE_BLACK_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x27 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_START +#define VIRTUALIZER_MUTATE_ONLY_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x10 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_MUTATE_ONLY_END +#define VIRTUALIZER_MUTATE_ONLY_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x11 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#endif + + +``` + +`include/sdk/VirtualizerSDK_FISH_LITE.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_FISH_LITE.h + * Description: Definitions for Private VM in SecureEngine + * + * Author/s: Oreans Technologies + * (c) 2014 Oreans Technologies + * + * --- File generated automatically from Oreans VM Generator (2/4/2014) --- + ******************************************************************************/ + +// *********************************************** +// Definition of macros as function names +// *********************************************** + + #ifdef __cplusplus + extern "C" { + #endif + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000128_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000128_End(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000129_Start(void); + +DLL_IMPORT void STDCALL_CONVENTION CustomVM00000129_End(void); + +#ifdef __cplusplus +} +#endif + + +// *********************************************** +// x64 definition as function names +// *********************************************** + +#if defined(PLATFORM_X64) && !defined(CV_X64_INSERT_VIA_INLINE) + +#define VIRTUALIZER_FISH_LITE_START CustomVM00000129_Start(); +#define VIRTUALIZER_FISH_LITE_END CustomVM00000129_End(); + +#define CV_CUSTOM_VMS_DEFINED + +#endif + + +// *********************************************** +// x32 definition as function names +// *********************************************** + +#if defined(PLATFORM_X32) && !defined(CV_X32_INSERT_VIA_INLINE) + +#define VIRTUALIZER_FISH_LITE_START CustomVM00000128_Start(); +#define VIRTUALIZER_FISH_LITE_END CustomVM00000128_End(); + +#define CV_CUSTOM_VMS_DEFINED + +#endif + + +// *********************************************** +// x32/x64 definition as inline assembly +// *********************************************** + +#ifndef CV_CUSTOM_VMS_DEFINED + +#ifdef __BORLANDC__ + #include "VirtualizerSDK_BorlandC_inline_FISH_LITE.h" +#endif + +#ifdef __GNUC__ + #include "VirtualizerSDK_GNU_inline_FISH_LITE.h" +#endif + +#ifdef __ICL + #include "VirtualizerSDK_ICL_inline_FISH_LITE.h" +#endif + +#ifdef __LCC__ + #include "VirtualizerSDK_LCC_inline_FISH_LITE.h" +#endif + +#if defined(_MSC_VER) || defined(__INTEL_COMPILER) + #include "VirtualizerSDK_VC_inline_FISH_LITE.h" +#endif + +#endif + +``` + +`include/sdk/VirtualizerSDK_GNU_inline.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_GNU_inline.h + * Description: GNU C inline assembly macros definitions + * + * Author/s: Oreans Technologies + * (c) 2013 Oreans Technologies + * + ******************************************************************************/ + +/*********************************************** + * Definition as inline assembly + ***********************************************/ + +#define VIRTUALIZER_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x0C\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); + +#define VIRTUALIZER_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x0D\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); + +#define VIRTUALIZER_STR_ENCRYPT_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x12\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); + +#define VIRTUALIZER_STR_ENCRYPT_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x13\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); + +#define VIRTUALIZER_STR_ENCRYPTW_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x22\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); + +#define VIRTUALIZER_STR_ENCRYPTW_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x23\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); + +#define VIRTUALIZER_UNPROTECTED_START \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); + +#define VIRTUALIZER_UNPROTECTED_END \ +__asm__ (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x21\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); + +``` + +`include/sdk/VirtualizerSDK_GNU_inline_FISH_LITE.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_GNU_inline_FISH_LITE.h + * Description: GNU C inline assembly macros definitions + * + * Author/s: Oreans Technologies + * (c) 2014 Oreans Technologies + * + * --- File generated automatically from Oreans VM Generator (2/4/2014) --- + ******************************************************************************/ + +/*********************************************** + * Definition as inline assembly + ***********************************************/ + +#ifdef PLATFORM_X32 + +#ifndef VIRTUALIZER_FISH_LITE_START +#define VIRTUALIZER_FISH_LITE_START \ +asm (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x80\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_FISH_LITE_END +#define VIRTUALIZER_FISH_LITE_END \ +asm (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x10\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#endif + +#ifdef PLATFORM_X64 + +#ifndef VIRTUALIZER_FISH_LITE_START +#define VIRTUALIZER_FISH_LITE_START \ +asm (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x81\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#ifndef VIRTUALIZER_FISH_LITE_END +#define VIRTUALIZER_FISH_LITE_END \ +asm (".byte 0xEB\n"\ + ".byte 0x10\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"\ + ".byte 0x11\n"\ + ".byte 0x02\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x00\n"\ + ".byte 0x43\n"\ + ".byte 0x56\n"\ + ".byte 0x20\n"\ + ".byte 0x20\n"); +#endif + +#endif + + +``` + +`include/sdk/VirtualizerSDK_ICL_inline.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_ICL_inline.h + * Description: ICL inline assembly macros definitions + * + * Author/s: Oreans Technologies + * (c) 2013 Oreans Technologies + ******************************************************************************/ + +/*********************************************** + * Definition as inline assembly + ***********************************************/ + +#define VIRTUALIZER_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x0C \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + +#define VIRTUALIZER_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x0D \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + +#define VIRTUALIZER_STR_ENCRYPT_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43 \ + __asm __emit 0x56 \ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x12 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43 \ + __asm __emit 0x56 \ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + + #define VIRTUALIZER_STR_ENCRYPT_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43 \ + __asm __emit 0x56 \ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x13 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43 \ + __asm __emit 0x56 \ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + + #define VIRTUALIZER_STR_ENCRYPTW_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43 \ + __asm __emit 0x56 \ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x22 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43 \ + __asm __emit 0x56 \ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + + #define VIRTUALIZER_STR_ENCRYPTW_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43 \ + __asm __emit 0x56 \ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x23 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43 \ + __asm __emit 0x56 \ + __asm __emit 0x20 \ + __asm __emit 0x20 + + #define VIRTUALIZER_UNPROTECTED_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43 \ + __asm __emit 0x56 \ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43 \ + __asm __emit 0x56 \ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + + #define VIRTUALIZER_UNPROTECTED_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43 \ + __asm __emit 0x56 \ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x21 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43 \ + __asm __emit 0x56 \ + __asm __emit 0x20 \ + __asm __emit 0x20 + +``` + +`include/sdk/VirtualizerSDK_ICL_inline_FISH_LITE.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_ICL_inline_FISH_LITE.h + * Description: ICL inline assembly macros definitions + * + * Author/s: Oreans Technologies + * (c) 2014 Oreans Technologies + * + * --- File generated automatically from Oreans VM Generator (2/4/2014) --- + ******************************************************************************/ + +/*********************************************** + * Definition as inline assembly + ***********************************************/ + +#ifdef PLATFORM_X32 + +#ifndef VIRTUALIZER_FISH_LITE_START +#define VIRTUALIZER_FISH_LITE_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x80 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_LITE_END +#define VIRTUALIZER_FISH_LITE_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x10 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#endif + +#ifdef PLATFORM_X64 + +#ifndef VIRTUALIZER_FISH_LITE_START +#define VIRTUALIZER_FISH_LITE_START \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x81 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_LITE_END +#define VIRTUALIZER_FISH_LITE_END \ + __asm __emit 0xEB \ + __asm __emit 0x10 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 \ + __asm __emit 0x11 \ + __asm __emit 0x02 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x00 \ + __asm __emit 0x43\ + __asm __emit 0x56\ + __asm __emit 0x20 \ + __asm __emit 0x20 +#endif + +#endif + + +``` + +`include/sdk/VirtualizerSDK_LCC_inline.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_LCC_inline.h + * Description: LCC inline assembly macros definitions + * + * Author/s: Oreans Technologies + * (c) 2013 Oreans Technologies + ******************************************************************************/ + +/*********************************************** + * Definition as inline assembly + ***********************************************/ + +#define VIRTUALIZER_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x0C, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); + +#define VIRTUALIZER_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x0D, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); + +#define VIRTUALIZER_STR_ENCRYPT_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x12, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); + +#define VIRTUALIZER_STR_ENCRYPT_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x13, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); + +#define VIRTUALIZER_STR_ENCRYPTW_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x22, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); + +#define VIRTUALIZER_STR_ENCRYPTW_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x23, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); + +#define VIRTUALIZER_UNPROTECTED_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); + +#define VIRTUALIZER_UNPROTECTED_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x21, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); + +``` + +`include/sdk/VirtualizerSDK_LCC_inline_FISH_LITE.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_LCC_inline_FISH_LITE.h + * Description: LCC inline assembly macros definitions + * + * Author/s: Oreans Technologies + * (c) 2014 Oreans Technologies + * + * --- File generated automatically from Oreans VM Generator (2/4/2014) --- + ******************************************************************************/ + +/*********************************************** + * Definition as inline assembly + ***********************************************/ + +#ifdef PLATFORM_X32 + +#ifndef VIRTUALIZER_FISH_LITE_START +#define VIRTUALIZER_FISH_LITE_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x80, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_FISH_LITE_END +#define VIRTUALIZER_FISH_LITE_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x10, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#endif + +#ifdef PLATFORM_X64 + +#ifndef VIRTUALIZER_FISH_LITE_START +#define VIRTUALIZER_FISH_LITE_START __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x81, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#ifndef VIRTUALIZER_FISH_LITE_END +#define VIRTUALIZER_FISH_LITE_END __asm__ (" .byte\t0xEB, 0x10, 0x43, 0x56, 0x20, 0x20, 0x11, 0x02, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x43, 0x56, 0x20, 0x20"); +#endif + +#endif + + +``` + +`include/sdk/VirtualizerSDK_VC_inline.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_VC_inline.h + * Description: VC inline assembly macros definitions + * + * Author/s: Oreans Technologies + * (c) 2013 Oreans Technologies + ******************************************************************************/ + +/*********************************************** + * Definition as inline assembly + ***********************************************/ + +#define VIRTUALIZER_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x0C \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + +#define VIRTUALIZER_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x0D \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + +#define VIRTUALIZER_STR_ENCRYPT_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43 \ + __asm _emit 0x56 \ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x12 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43 \ + __asm _emit 0x56 \ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + + #define VIRTUALIZER_STR_ENCRYPT_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43 \ + __asm _emit 0x56 \ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x13 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43 \ + __asm _emit 0x56 \ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + + #define VIRTUALIZER_STR_ENCRYPTW_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43 \ + __asm _emit 0x56 \ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x22 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43 \ + __asm _emit 0x56 \ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + + #define VIRTUALIZER_STR_ENCRYPTW_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43 \ + __asm _emit 0x56 \ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x23 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43 \ + __asm _emit 0x56 \ + __asm _emit 0x20 \ + __asm _emit 0x20 + + #define VIRTUALIZER_UNPROTECTED_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43 \ + __asm _emit 0x56 \ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43 \ + __asm _emit 0x56 \ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + + #define VIRTUALIZER_UNPROTECTED_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43 \ + __asm _emit 0x56 \ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x21 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43 \ + __asm _emit 0x56 \ + __asm _emit 0x20 \ + __asm _emit 0x20 + +``` + +`include/sdk/VirtualizerSDK_VC_inline_FISH_LITE.h`: + +```h +/****************************************************************************** + * Header: VirtualizerSDK_VC_inline_FISH_LITE.h + * Description: VC inline assembly macros definitions + * + * Author/s: Oreans Technologies + * (c) 2014 Oreans Technologies + * + * --- File generated automatically from Oreans VM Generator (2/4/2014) --- + ******************************************************************************/ + +/*********************************************** + * Definition as inline assembly + ***********************************************/ + +#ifdef PLATFORM_X32 + +#ifdef _DEBUG +#define VIRTUALIZER_FISH_LITE_START +#define VIRTUALIZER_FISH_LITE_END +#else + +#ifndef VIRTUALIZER_FISH_LITE_START +#define VIRTUALIZER_FISH_LITE_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x80 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_LITE_END +#define VIRTUALIZER_FISH_LITE_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x10 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif +#endif + +#endif + +#ifdef PLATFORM_X64 + +#ifndef VIRTUALIZER_FISH_LITE_START +#define VIRTUALIZER_FISH_LITE_START \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x81 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#ifndef VIRTUALIZER_FISH_LITE_END +#define VIRTUALIZER_FISH_LITE_END \ + __asm _emit 0xEB \ + __asm _emit 0x10 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 \ + __asm _emit 0x11 \ + __asm _emit 0x02 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x00 \ + __asm _emit 0x43\ + __asm _emit 0x56\ + __asm _emit 0x20 \ + __asm _emit 0x20 +#endif + +#endif + + +``` + +`include/sol/sol.hpp`: + +```hpp +// The MIT License (MIT) + +// Copyright (c) 2013-2019 Rapptz, ThePhD and contributors + +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +// This file was generated with a script. +// Generated 2019-10-02 08:43:38.869924 UTC +// This header was generated with sol v3.0.3 (revision 908074e) +// https://github.com/ThePhD/sol2 + +#ifndef SOL_SINGLE_INCLUDE_HPP +#define SOL_SINGLE_INCLUDE_HPP + +// beginning of sol/sol.hpp + +#ifndef SOL_HPP +#define SOL_HPP + +#if defined(UE_BUILD_DEBUG) || defined(UE_BUILD_DEVELOPMENT) || defined(UE_BUILD_TEST) || defined(UE_BUILD_SHIPPING) || defined(UE_SERVER) +#define SOL_INSIDE_UNREAL +#ifdef check +#pragma push_macro("check") +#undef check +#endif +#endif // Unreal Engine 4 Bullshit + +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#pragma GCC diagnostic ignored "-Wconversion" +#if __GNUC__ > 6 +#pragma GCC diagnostic ignored "-Wnoexcept-type" +#endif +#elif defined(__clang__) +#elif defined _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4505) // unreferenced local function has been removed GEE THANKS +#endif // clang++ vs. g++ vs. VC++ + +// beginning of sol/forward.hpp + +#ifndef SOL_FORWARD_HPP +#define SOL_FORWARD_HPP + +// beginning of sol/feature_test.hpp + +#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_MSC_VER) && _MSC_VER > 1900 && ((defined(_HAS_CXX17) && _HAS_CXX17 == 1) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201402L)))) +#ifndef SOL_CXX17_FEATURES +#define SOL_CXX17_FEATURES 1 +#endif // C++17 features macro +#endif // C++17 features check + +#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES +#if defined(__cpp_noexcept_function_type) || ((defined(_MSC_VER) && _MSC_VER > 1911) && (defined(_MSVC_LANG) && ((_MSVC_LANG >= 201403L)))) +#ifndef SOL_NOEXCEPT_FUNCTION_TYPE +#define SOL_NOEXCEPT_FUNCTION_TYPE 1 +#endif // noexcept is part of a function's type +#endif // compiler-specific checks +#if defined(__clang__) && defined(__APPLE__) +#if defined(__has_include) +#if __has_include() +#define SOL_STD_VARIANT 1 +#endif // has include nonsense +#endif // __has_include +#else +#define SOL_STD_VARIANT 1 +#endif // Clang screws up variant +#endif // C++17 only + +// beginning of sol/config.hpp + +#ifdef _MSC_VER +#if defined(_DEBUG) && !defined(NDEBUG) +#ifndef SOL_IN_DEBUG_DETECTED +#define SOL_IN_DEBUG_DETECTED 1 +#endif +#endif // VC++ Debug macros + +#if !defined(_CPPUNWIND) +#if !defined(SOL_NO_EXCEPTIONS) +#define SOL_NO_EXCEPTIONS 1 +#endif +#endif // Automatic Exceptions + +#if !defined(_CPPRTTI) +#if !defined(SOL_NO_RTTI) +#define SOL_NO_RTTI 1 +#endif +#endif // Automatic RTTI +#elif defined(__GNUC__) || defined(__clang__) + +#if !defined(NDEBUG) && !defined(__OPTIMIZE__) +#if !defined(SOL_IN_DEBUG_DETECTED) +#define SOL_IN_DEBUG_DETECTED 1 +#endif +#endif // Not Debug && g++ optimizer flag + +#if !defined(__EXCEPTIONS) +#if !defined(SOL_NO_EXCEPTIONS) +#define SOL_NO_EXCEPTIONS 1 +#endif +#endif // No Exceptions + +#if !defined(__GXX_RTTI) +#if !defined(SOL_NO_RTTI) +#define SOL_NO_RTTI 1 +#endif +#endif // No RTTI + +#endif // vc++ || clang++/g++ + +#if defined(SOL_CHECK_ARGUMENTS) && SOL_CHECK_ARGUMENTS +#if defined(SOL_ALL_SAFETIES_ON) +#define SOL_ALL_SAFETIES_ON 1 +#endif // turn all the safeties on +#endif // Compatibility define + +#if defined(SOL_ALL_SAFETIES_ON) && SOL_ALL_SAFETIES_ON + + // Checks low-level getter function + // (and thusly, affects nearly entire framework) +#if !defined(SOL_SAFE_GETTER) +#define SOL_SAFE_GETTER 1 +#endif + +// Checks access on usertype functions +// local my_obj = my_type.new() +// my_obj.my_member_function() +// -- bad syntax and crash +#if !defined(SOL_SAFE_USERTYPE) +#define SOL_SAFE_USERTYPE 1 +#endif + +// Checks sol::reference derived boundaries +// sol::function ref(L, 1); +// sol::userdata sref(L, 2); +#if !defined(SOL_SAFE_REFERENCES) +#define SOL_SAFE_REFERENCES 1 +#endif + +// Changes all typedefs of sol::function to point to the +// protected_function version, instead of unsafe_function +#if !defined(SOL_SAFE_FUNCTION) +#define SOL_SAFE_FUNCTION 1 +#endif + +// Checks function parameters and +// returns upon call into/from Lua +// local a = 1 +// local b = "woof" +// my_c_function(a, b) +#if !defined(SOL_SAFE_FUNCTION_CALLS) +#define SOL_SAFE_FUNCTION_CALLS 1 +#endif + +// Checks conversions +// int v = lua["bark"]; +// int v2 = my_sol_function(); +#if !defined(SOL_SAFE_PROXIES) +#define SOL_SAFE_PROXIES 1 +#endif + +// Check overflowing number conversions +// for things like 64 bit integers that don't fit in a typical lua_Number +// for Lua 5.1 and 5.2 +#if !defined(SOL_SAFE_NUMERICS) +#define SOL_SAFE_NUMERICS 1 +#endif + +// Turn off Number Precision Checks +// if this is defined, we do not do range +// checks on integers / unsigned integers that might +// be bigger than what Lua can represent +#if !defined(SOL_NO_CHECK_NUMBER_PRECISION) +// off by default +#define SOL_NO_CHECK_NUMBER_PRECISION 0 +#endif + +// Print any exceptions / errors that occur +// in debug mode to the default error stream / console +#if !defined(SOL_SAFE_STACK_CHECK) +#define SOL_SAFE_STACK_CHECK 1 +#endif + +#endif // Turn on Safety for all if top-level macro is defined + +#if defined(SOL_IN_DEBUG_DETECTED) && SOL_IN_DEBUG_DETECTED + +#if !defined(SOL_SAFE_REFERENCES) +// Ensure that references are forcefully type-checked upon construction +#define SOL_SAFE_REFERENCES 1 +#endif + +// Safe usertypes checks for errors such as +// obj = my_type.new() +// obj.f() -- note the '.' instead of ':' +// usertypes should be safe no matter what +#if !defined(SOL_SAFE_USERTYPE) +#define SOL_SAFE_USERTYPE 1 +#endif + +#if !defined(SOL_SAFE_FUNCTION_CALLS) +// Function calls from Lua should be automatically safe in debug mode +#define SOL_SAFE_FUNCTION_CALLS 1 +#endif + +// Print any exceptions / errors that occur +// in debug mode to the default error stream / console +#if !defined(SOL_PRINT_ERRORS) +#define SOL_PRINT_ERRORS 1 +#endif + +// Print any exceptions / errors that occur +// in debug mode to the default error stream / console +#if !defined(SOL_SAFE_STACK_CHECK) +#define SOL_SAFE_STACK_CHECK 1 +#endif + +#endif // DEBUG: Turn on all debug safety features for VC++ / g++ / clang++ and similar + +#if !defined(SOL_PRINT_ERRORS) +#define SOL_PRINT_ERRORS 0 +#endif + +#if !defined(SOL_DEFAULT_PASS_ON_ERROR) +#define SOL_DEFAULT_PASS_ON_ERROR 0 +#endif + +#if !defined(SOL_ENABLE_INTEROP) +#define SOL_ENABLE_INTEROP 0 +#endif + +#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || defined(__OBJC__) || defined(nil) +#if !defined(SOL_NO_NIL) +#define SOL_NO_NIL 1 +#endif +#endif // avoiding nil defines / keywords + +#if defined(SOL_USE_BOOST) && SOL_USE_BOOST +#if !defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) +#define SOL_UNORDERED_MAP_COMPATIBLE_HASH 1 +#endif // SOL_UNORDERED_MAP_COMPATIBLE_HASH +#endif + +#ifndef SOL_STACK_STRING_OPTIMIZATION_SIZE +#define SOL_STACK_STRING_OPTIMIZATION_SIZE 1024 +#endif // Optimized conversion routines using a KB or so off the stack + +#if !defined(SOL_SAFE_STACK_CHECK) +#define SOL_SAFE_STACK_CHECK 0 +#endif // use luaL_checkstack to check stack overflow / overrun + +// end of sol/config.hpp + +// beginning of sol/config_setup.hpp + +// end of sol/config_setup.hpp + +// end of sol/feature_test.hpp + +#include +#include +#include + +#if defined(SOL_USING_CXX_LUA) && SOL_USING_CXX_LUA +struct lua_State; +#else +extern "C" { + struct lua_State; +} +#endif // C++ Mangling for Lua vs. Not + +namespace sol { + + enum class type; + + class stateless_reference; + template + class basic_reference; + using reference = basic_reference; + using main_reference = basic_reference; + class stateless_stack_reference; + class stack_reference; + + template + class basic_bytecode; + + struct lua_value; + + struct proxy_base_tag; + template + struct proxy_base; + template + struct table_proxy; + + template + class basic_table_core; + template + using table_core = basic_table_core; + template + using main_table_core = basic_table_core; + template + using stack_table_core = basic_table_core; + template + using basic_table = basic_table_core; + using table = table_core; + using global_table = table_core; + using main_table = main_table_core; + using main_global_table = main_table_core; + using stack_table = stack_table_core; + using stack_global_table = stack_table_core; + + template + struct basic_lua_table; + using lua_table = basic_lua_table; + using stack_lua_table = basic_lua_table; + + template + class basic_usertype; + template + using usertype = basic_usertype; + template + using stack_usertype = basic_usertype; + + template + class basic_metatable; + using metatable = basic_metatable; + using stack_metatable = basic_metatable; + + template + struct basic_environment; + using environment = basic_environment; + using main_environment = basic_environment; + using stack_environment = basic_environment; + + template + class basic_function; + template + class basic_protected_function; + using unsafe_function = basic_function; + using safe_function = basic_protected_function; + using main_unsafe_function = basic_function; + using main_safe_function = basic_protected_function; + using stack_unsafe_function = basic_function; + using stack_safe_function = basic_protected_function; + using stack_aligned_unsafe_function = basic_function; + using stack_aligned_safe_function = basic_protected_function; + using protected_function = safe_function; + using main_protected_function = main_safe_function; + using stack_protected_function = stack_safe_function; + using stack_aligned_protected_function = stack_aligned_safe_function; +#if defined(SOL_SAFE_FUNCTION) && SOL_SAFE_FUNCTION + using function = protected_function; + using main_function = main_protected_function; + using stack_function = stack_protected_function; +#else + using function = unsafe_function; + using main_function = main_unsafe_function; + using stack_function = stack_unsafe_function; +#endif + using stack_aligned_function = stack_aligned_unsafe_function; + using stack_aligned_stack_handler_function = basic_protected_function; + + struct unsafe_function_result; + struct protected_function_result; + using safe_function_result = protected_function_result; +#if defined(SOL_SAFE_FUNCTION) && SOL_SAFE_FUNCTION + using function_result = safe_function_result; +#else + using function_result = unsafe_function_result; +#endif + + template + class basic_object_base; + template + class basic_object; + template + class basic_userdata; + template + class basic_lightuserdata; + template + class basic_coroutine; + template + class basic_thread; + + using object = basic_object; + using userdata = basic_userdata; + using lightuserdata = basic_lightuserdata; + using thread = basic_thread; + using coroutine = basic_coroutine; + using main_object = basic_object; + using main_userdata = basic_userdata; + using main_lightuserdata = basic_lightuserdata; + using main_coroutine = basic_coroutine; + using stack_object = basic_object; + using stack_userdata = basic_userdata; + using stack_lightuserdata = basic_lightuserdata; + using stack_thread = basic_thread; + using stack_coroutine = basic_coroutine; + + struct stack_proxy_base; + struct stack_proxy; + struct variadic_args; + struct variadic_results; + struct stack_count; + struct this_state; + struct this_main_state; + struct this_environment; + + class state_view; + class state; + + template + struct as_table_t; + template + struct as_container_t; + template + struct nested; + template + struct light; + template + struct user; + template + struct as_args_t; + template + struct protect_t; + template + struct policy_wrapper; + + template + struct usertype_traits; + template + struct unique_usertype_traits; + + template + struct types { + typedef std::make_index_sequence indices; + static constexpr std::size_t size() { + return sizeof...(Args); + } + }; + + template + struct derive : std::false_type { + typedef types<> type; + }; + + template + struct base : std::false_type { + typedef types<> type; + }; + + template + struct weak_derive { + static bool value; + }; + + template + bool weak_derive::value = false; + + namespace stack { + struct record; + } + +#if !defined(SOL_USE_BOOST) || (SOL_USE_BOOST == 0) + template + class optional; + + template + class optional; +#endif + + using check_handler_type = int(lua_State*, int, type, type, const char*); + +} // namespace sol + +#define SOL_BASE_CLASSES(T, ...) \ + namespace sol { \ + template <> \ + struct base : std::true_type { \ + typedef ::sol::types<__VA_ARGS__> type; \ + }; \ + } \ + void a_sol3_detail_function_decl_please_no_collide() +#define SOL_DERIVED_CLASSES(T, ...) \ + namespace sol { \ + template <> \ + struct derive : std::true_type { \ + typedef ::sol::types<__VA_ARGS__> type; \ + }; \ + } \ + void a_sol3_detail_function_decl_please_no_collide() + +#endif // SOL_FORWARD_HPP +// end of sol/forward.hpp + +// beginning of sol/forward_detail.hpp + +#ifndef SOL_FORWARD_DETAIL_HPP +#define SOL_FORWARD_DETAIL_HPP + +// beginning of sol/traits.hpp + +// beginning of sol/tuple.hpp + +// beginning of sol/base_traits.hpp + +namespace sol { + namespace detail { + struct unchecked_t {}; + const unchecked_t unchecked = unchecked_t{}; + } // namespace detail + + namespace meta { + using sfinae_yes_t = std::true_type; + using sfinae_no_t = std::false_type; + + template + using void_t = void; + + template + using unqualified = std::remove_cv>; + + template + using unqualified_t = typename unqualified::type; + + namespace meta_detail { + template + struct unqualified_non_alias : unqualified {}; + + template